refactor(cli): co-locate command registration in each command folder#309
refactor(cli): co-locate command registration in each command folder#309rafa-thayto wants to merge 2 commits into
Conversation
🦋 Changeset detectedLatest commit: 59dee03 The changes in this PR will be included in the next version bump. This PR includes changesets to release 0 packagesWhen changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Warning Review limit reached
More reviews will be available in 51 minutes and 31 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (22)
📝 WalkthroughWalkthroughThis PR refactors the Clerk CLI from a monolithic command wiring approach in Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
!snapshot |
1a4f549 to
999e72a
Compare
|
Actionable comments posted: 0 |
999e72a to
1a9db1b
Compare
1a9db1b to
569e165
Compare
Move Commander wiring out of the monolithic cli-program.ts into per-command registerX(program) functions co-located with each command. createProgram() now just calls them in registration order, shrinking cli-program.ts from 1109 to ~320 lines and making each command's surface owned by its own folder. - Each command folder exposes registerX(program): void (mirrors the existing registerExtras precedent) - New commands/toggles/ owns the shared enable/disable parents that wire the orgs + billing handlers (neither feature folder cleanly owns them) - Shared option parsers (parseIntegerOption, collectOptionValues) extracted to lib/option-parsers.ts - clerk --help output verified byte-identical across all 39 command nodes; no user-facing change
…add option-parsers tests Address PR review comments from wyattjoh: - Refactor command registration into a static `registrants` array iterated with a single loop, providing a common/standard registration pattern (comment on cli-program.ts) - Add unit tests for `option-parsers.ts` covering `collectOptionValues` and `parseIntegerOption` (comment on option-parsers.ts) - Also wire in `registerDeploy` for the deploy command added in main and remove the now-deleted `registerSkill` (cleanup after rebase)
569e165 to
59dee03
Compare
What
Splits the command-registration wiring out of the monolithic
packages/cli-core/src/cli-program.ts(1109 lines) into per-commandregisterX(program)functions co-located in each command's folder.createProgram()is now a short, ordered list ofregisterX(program)calls.This makes each command's surface (name, flags, examples, action) owned by its own folder — you add or change a command by editing
commands/<name>/index.ts, not by editing one giant file. It follows the pattern already established byregisterExtras(program).How it works
export function registerX(program: Command): voidholding its own.command()/.option()/.setExamples()/.action()chain (mirrors the existingregisterExtrasprecedent).commands/toggles/owns the sharedenable/disableparents, wiring theorgs+billinghandlers under both (neither feature folder cleanly owns those parents).parseIntegerOption,collectOptionValues) extracted tolib/option-parsers.ts; theusers-onlyUSER_LIST_ORDER_BY_CHOICESmoved into theusersfolder.apps/usersaggregate exports that only existed to feedcli-program.ts.Behavior
No user-facing change. Registration order is preserved exactly, so
clerk --helpand every subcommand's help is unchanged. This was verified by capturing the full--helptree (39 command nodes) frommainbefore the change and diffing it against the result after — byte-identical.Test plan
bun run format— cleanbun run typecheck— cleanbun run lint— 0 warnings, 0 errorsbun run build:compile— compiles (336 modules)bun run test— no new failures introduced (pre-existing local-env failures unchanged vsmain; full verdict from CI)--helptree byte-identical across all 39 nodes (init, auth, link, unlink, whoami, open, apps, users, env, config, enable/disable, api, doctor, switch-env, completion, skill, update, bird)Empty changeset included (internal refactor, no user-facing impact).