fix(cli): parse kebab-case flags (--dry-run) instead of silently ignoring them#6
Open
MasonStation wants to merge 2 commits into
Open
fix(cli): parse kebab-case flags (--dry-run) instead of silently ignoring them#6MasonStation wants to merge 2 commits into
MasonStation wants to merge 2 commits into
Conversation
…ring them citty 0.1.6 maps kebab CLI tokens onto camelCase arg keys via a Proxy whose fallback uses `??`. A boolean arg with `default: false` shadows the kebab-parsed value, so `--dry-run` was silently ignored while `--dryRun` worked. For `stack add` this fell through to the REAL provisioning flow (live OAuth / network / vault writes) when the user asked for the documented no-op preview. Normalize raw argv (`--dry-run` -> `--dryRun`) before citty parses it. This fixes every command at once — add/init/import/swap/upgrade `--dry-run`, plus `--all-orphans`, `--keep-remote`, `--keep-from`, `--continue-on-error`, `--recipe-id` — while preserving camelCase, citty `--no-*` negation (the disable path for default-true `continueOnError`), and `--` passthrough. Bumps VERSION to 0.2.1. Tests: 9 parser-level unit tests + 3 add --dry-run integration tests (kebab works / camelCase regression guard / no-flag opt-in guard). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
The "preview branch does NOT run without --dry-run" test asserted the SUPABASE_STACK_CLIENT_ID OAuth error, but the no-flag path hits requirePhantom() first — on a runner without Phantom installed it fails there instead, so that string never appears (CI was red on this). Assert the real invariant instead: no "(dry-run)" title and no preview line, which proves the dry-run branch was skipped regardless of whether the downstream failure is the Phantom preflight or the OAuth guard. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Problem
stack add <provider> --dry-run(the documented "safe, no-op preview" form) was silently ignored and ran the real provisioning flow — live OAuth / network calls / Phantom vault writes — instead of printing the preview.--dryRun(camelCase) worked;--dry-run(kebab, the form in README/--help/docs) did not.Root cause
citty 0.1.6 maps kebab CLI tokens onto camelCase arg keys through a Proxy whose fallback uses
??:A boolean arg with
default: falsegetsout.dryRun = falsepopulated by citty's defaults pass, sofalse ?? …short-circuits and the kebab-parsedout["dry-run"] = trueis never consulted. Net:--dry-run→dryRun = false→ skips the dry-run branch → realaddService → provider.login().Fix
Normalize raw argv (
--dry-run→--dryRun) before citty parses it, inpackages/cli/src/lib/normalize-args.ts, applied once inindex.ts. One change fixes every command:--dry-runonadd,init,import,swap,upgrade--all-orphans,--keep-remote,--keep-from,--continue-on-error,--recipe-idDeliberately left untouched (so existing behavior is preserved):
--dryRun) — still work.--no-*tokens — citty's negation, which is the disable path for the only default-true boolean (templates apply --continue-on-error).--—stack execpassthrough.=is rewritten, so--region=us-east-1is safe.Tests
normalize-args.test.ts— 9 parser-level unit tests (kebab→camel, 3-word flags,=valuepreserved, hyphenated values not dragged in,--no-*left alone,--passthrough).add-dry-run.test.ts— 3 integration tests:--dry-runprints the preview and never hitsSUPABASE_STACK_CLIENT_ID(reallogin());--dryRunregression guard; no-flag guard (preview is opt-in).All pass. Full CLI suite green except one pre-existing, unrelated Windows path-separator assertion in
recommend.test.ts(confirmed failing onmain).Known limitation (not addressed here)
The positive
noWire/noProvision/noInteractive/noRollbackflags are a different mechanism: kebab--no-wirehits citty's negation branch (sets an unusedwire=false), so it can't set the positive flag via any alias — even in newer citty. The canonical documented form--noWire(used by the MCP server and generated CLI ref) works and is unchanged. Fixing--no-wirecleanly means renaming these to positive flags (wire, default true) across add/apply/init/swap + the MCP server — out of scope for this patch.Version
Bumps
VERSIONto0.2.1(the constant inindex.tsis not auto-bumped byscripts/publish.sh, so the compiled binary would otherwise report the wrong version).🤖 Generated with Claude Code