Add central CLI error handler and exit codes#11
Merged
Conversation
Route command failures through a shared handler so every error type exits consistently and keeps stdout clean for scripted usage. This also aligns SDK validation/rate-limit failures with explicit exit codes expected by downstream automation. Co-authored-by: Cursor <cursoragent@cursor.com>
- Simplified the error handling logic in `handleCliError` by consolidating condition checks. - Removed the `handleScrapeError` function and directly utilized `handleCliError` in the scrape execution flow. - Updated tests to reflect changes in error handling, ensuring consistent behavior across different error types. - Enhanced test cases by directly instantiating error objects instead of using a custom error creation function.
…ify build process - Changed the dependency for @decodo/sdk-ts from a local file reference to version 2.1.1 in package.json and pnpm-lock.yaml. - Removed the prebuild and build:sdk-ts scripts, streamlining the pretest process to only run pnpm build. - Updated README to reflect the new development setup without the sibling checkout requirement for sdk-ts. - Adjusted CI workflow to eliminate unnecessary checkout steps for sdk-ts, improving efficiency.
- Added a new service, `resolveTargetGroup`, to determine the group of targets based on schema metadata and naming conventions. - Updated `createCodegenTargetCommands` and `createListTargetsCommand` to utilize the new group resolution logic, improving command descriptions. - Enhanced tests to ensure that "None" is not exposed as a command description group and to validate the new group resolution functionality.
e941f5f to
05552f6
Compare
- Updated the build script to use a single TypeScript configuration for building. - Removed the CommonJS build configuration and associated renaming script. - Adjusted the `RootOptions` interface to reorder properties for consistency. - Cleaned up error handling tests by replacing custom error creation with direct instantiation.
Merged
9 tasks
ChinchillaLover9000
approved these changes
Jun 8, 2026
Comment on lines
+44
to
+56
| if (target.startsWith("universal")) { | ||
| const universalGroup = schema.getTargetMeta("universal")?.group; | ||
| if (isValidGroup(universalGroup)) { | ||
| return universalGroup; | ||
| } | ||
| } | ||
|
|
||
| if (target.includes("ecommerce")) { | ||
| const ecommerceGroup = schema.getTargetMeta("ecommerce")?.group; | ||
| if (isValidGroup(ecommerceGroup)) { | ||
| return ecommerceGroup; | ||
| } | ||
| } |
There was a problem hiding this comment.
would remove this special handling of groups - the sdk is the source of truth
Collaborator
Author
There was a problem hiding this comment.
Removed the CLI-side group inference — will fix missing groups in sdk-ts instead, then bump the dependency here.
Comment on lines
+9
to
+28
| function inferGroupFromPrefix( | ||
| schema: DecodoSchema, | ||
| target: string | ||
| ): string | undefined { | ||
| const prefix = target.split("_")[0]; | ||
| if (prefix.length === 0) { | ||
| return; | ||
| } | ||
|
|
||
| for (const other of schema.listTargets()) { | ||
| if (other === target || !other.startsWith(`${prefix}_`)) { | ||
| continue; | ||
| } | ||
|
|
||
| const otherGroup = schema.getTargetMeta(other)?.group; | ||
| if (isValidGroup(otherGroup)) { | ||
| return otherGroup; | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
A better option would be to enforce a group for each target, that way we can get rid of this magic guessing.
Collaborator
Author
There was a problem hiding this comment.
Agreed. Dropped prefix inference from this PR; enforcing groups in sdk-ts.
domantas-jurkus-dcd
approved these changes
Jun 8, 2026
…nd logic - Eliminated the `resolveTargetGroup` service, integrating its functionality directly into command creation. - Updated `createCodegenTargetCommands` and `createListTargetsCommand` to use `schema.getTargetMeta` for group resolution, enhancing command descriptions. - Removed related tests for `resolveTargetGroup` and ensured that "None" is not exposed in command descriptions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
@decodo/sdk-tsfrom npm and simplify CI/dev setup.group: "None"in the bundled schema are outscoped to sdk-ts — the CLI readsgetTargetMeta(target).groupdirectly with no inference layer. Fix groups in the SDK, publish, then bump the CLI dependency.Test plan
pnpm test