Dashboard › cli › Distillation
ec5b57a9-9b47-4268-99ed-57f7579edb46["lore_tm_v1_h5K0aIe0LEywL9UzeDh5qZ_UPbQyHr9LQlKpraO5-a0"]
packages/cli/test/lib/scanner-flags.integration.test.ts is an integration-test file for top-level flag handling by Stricli’s patched route scanner and application runner; it imports run from @stricli/core, the real app from ../../src/app.js, SentryContext from ../../src/context.js, CLI_VERSION from ../../src/lib/constants.js, and useTestConfigDir from ../helpers.js.@stricli/core patch at packages/cli/patches/@stricli%2Fcore@1.2.8.patch modifies buildRouteScanner to accept the fixed Sentry global-flag allow-list --verbose, --json, --org, --project, --log-level, --fields, and -v at any route depth, forwarding these flags to the leaf command instead of failing route resolution.--version at any route depth for version printing from runApplication and exposes a documentation.renderHelp hook used by the app to render --help --json as structured JSON; these changes replace the former argv-glue/argv-hoist preprocessors.packages/cli/test/lib/scanner-flags.integration.test.ts exercises the real app end-to-end through run() so the Stricli patch itself—not preprocessing—drives behavior for sentry --verbose bash-hook, sentry cli --version, and sentry issue list --help --json.packages/cli/test/lib/scanner-flags.integration.test.ts calls useTestConfigDir("scanner-flags-integration-") and creates emptyCwd with mkdtempSync(join(tmpdir(), "scanner-flags-cwd-")); the empty working directory prevents DSN auto-detection and makes commands that reach target resolution fail quickly without real network calls.runApp(args: string[]) returns Promise<{ stdout: string; stderr: string; exitCode: number }> and executes run(app, args, context), returning exitCode ?? 0.runApp() builds a mock SentryContext with buffered stdout and stderr, env: { ...process.env }, cwd: emptyCwd, homeDir: "/tmp", configDir: "/tmp", and stdin: process.stdin. It also overrides context.process.stdout and context.process.stderr because Stricli argument-scanner errors write to context.process.stderr rather than context.stderr; string and Uint8Array writes are supported via TextDecoder.packages/cli/test/lib/scanner-flags.integration.test.ts defines NO_COMMAND_REGISTERED = "No command registered" as the error substring produced when Stricli’s route scanner mistakes a token for an unknown subcommand.describe("top-level flags on a leaf command (bash-hook, no auth)") test group uses bash-hook because it requires no authentication and emits a script containing _sentry_err_trap, making successful routing and execution observable regardless of global-flag position.--verbose before the command still runs it invokes runApp(["--verbose", "bash-hook"]), expects stderr not to contain NO_COMMAND_REGISTERED, and expects stdout to contain _sentry_err_trap.-v (verbose alias) before the command runs it, not \--version`invokesrunApp(["-v", "bash-hook"]), expects no NO_COMMAND_REGISTEREDerror, expects_sentry_err_trapinstdout, and expects stdoutnot to match the bare-version regex/^\d+.\d+.\d+/. The patch removes Stricli’s built-in -vversion alias so-vremains Sentry CLI’s--verbose` alias and reaches the leaf command.--log-level with a value before the command still runs it invokes runApp(["--log-level", "debug", "bash-hook"]), expects no NO_COMMAND_REGISTERED error, and expects _sentry_err_trap in stdout.a value flag's value is not mistaken for the command invokes runApp(["--org", "acme", "bash-hook"]), verifying that --org consumes acme as its value and leaves bash-hook as the route; it expects no NO_COMMAND_REGISTERED error and _sentry_err_trap in stdout.--org=acme inline form before the command still runs it invokes runApp(["--org=acme", "bash-hook"]) and expects stderr not to contain NO_COMMAND_REGISTERED; the supplied file excerpt ends at line 130 during this test.