refactor: split the create barrel into wiring, scaffolding and catalog constants - #46
Conversation
…g constants Completes the series: `create` was the last command whose wiring lived in `src/app.ts`, and `create-feature-index.ts` the last barrel. `create-feature.ts` now exports `createCreateCommand(deps): Command` and owns the commander boundary — the command declaration, the `parseOptions` override and its `templateOptions` closure, `extractTemplateOptions` with its helpers, and `parsePackageManagerOption`. `create-feature-scaffold.ts` (the renamed barrel) keeps `runCreate`, the create-solana-dapp API surface, the prompt helpers and template resolution, and no longer imports commander at all. `CUSTOM_TEMPLATES_URL` and `MINIMAL_TEMPLATE_NAME` move to `data-access/template-catalog.ts`, since they describe the template catalog rather than the CLI. `src/app.ts` is down to 110 lines from 660 at the start of the series. It now holds package metadata, the version-check hook, `--skip-version-check` propagation, the `addCommand` settings copy, eight `addCommand` calls and `runApp` — no command declarations, and one injectable dependency of its own. The 28 create tests and the `validate project name` suite move out of `test/core.test.ts` (965 lines to 388) into a new `test/create.test.ts`, with the two create helpers and the template fixtures. `core.test.ts` is now only CLI-command formatting, package metadata, version checking, and app-level wiring. One test is added: `create` is registered with `addCommand` like the rest, so it also depends on createApp copying `showHelpAfterError`, but it cannot join the app-level guard for the other seven — its `parseOptions` override collects unknown long flags as template options before commander can reject them, so the probe has to be an argument the override itself rejects. Also restores the blank line between consecutive tests in `test/device.test.ts`, `test/emulator.test.ts` and `test/templates.test.ts`. The previous commit in this series moved those tests with a join that dropped it, which biome does not flag; `test/doctor.test.ts` is left alone because its own runs predate this work. Behaviour is unchanged: 487 tests pass with and without a TTY, and `create`'s usage line, argument, option list, help footer, `--minimal`/`--template` rejection and template-option passthrough are all identical.
|
commit: |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (9)
💤 Files with no reviewable changes (1)
Included review availability: 0 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour. 📝 WalkthroughWalkthroughThe create command now owns Commander registration, option parsing, validation, and delegation. The application injects dependencies through ChangesCreate command migration
Estimated code review effort: 4 (Complex) | ~45 minutes Merge Risk: ⚪ Minimal · up to The create-command ownership migration preserves the documented command behavior and its covered parsing, validation, delegation, and error paths. No merge-blocking risk remains. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
Completes the series after #41 (localnet) and #45 (the other six).
createwas the last command whose wiring lived insrc/app.ts, andcreate-feature-index.tsthe last*-feature-index.tsbarrel — both are gone.src/app.tsis now 110 lines, down from 660 at the start of the series. It holds package metadata, the version-check hook,--skip-version-checkpropagation, theaddCommandsettings copy, eightaddCommandcalls andrunApp. No command declarations, and one injectable dependency of its own.The split
create-feature.ts(new)createCreateCommand(deps), theparseOptionsoverride and itstemplateOptionsclosure,extractTemplateOptionswithfindKnownOption/hasInlineValue,parsePackageManagerOptioncreate-feature-scaffold.ts(renamed barrel)runCreate, the create-solana-dapp API surface, prompt helpers, template resolution — no longer imports commander at alldata-access/template-catalog.ts(new)CUSTOM_TEMPLATES_URL,MINIMAL_TEMPLATE_NAME— they describe the template catalog, not the CLIThe
parseOptionsoverride and itslet templateOptionsclosure were previously inapp.ts, physically separated from theextractTemplateOptionsthey call. They are now adjacent, with the comment explaining why the extraction works on raw argv sitting next to both.Tests
The 28 create tests and the
validate project namesuite move out oftest/core.test.ts(965 → 388 lines) into a newtest/create.test.ts, along with the two create helpers and the template fixtures.core.test.tsis now only CLI-command formatting, package metadata, version checking, and app-level wiring.One test is added.
createisaddCommand-registered like every other feature command, so it also depends oncreateAppcopying the root'sshowHelpAfterError— but it cannot join the app-level guard covering the other seven: itsparseOptionsoverride collects unknown long flags as template options before commander can reject them, so--bogusis not an error there. The probe has to be-x, which the override itself rejects.Whitespace fix I owe this series
This also restores the blank line between consecutive tests in
test/device.test.ts(2),test/emulator.test.ts(17) andtest/templates.test.ts(3). #45 moved those tests with a join that dropped it, and biome does not flag it, so it merged green. Verified against2fc829dthat all three had zero such gaps before #45, and thatcore.test.tshas none across ~90 tests, so the blank line is the convention.test/doctor.test.tshas 11 of these and is deliberately untouched — they predate this whole series and are the original author's style, not mine to reformat.Verification
bun run ci— build, lint,tsc -b --noEmit, 487 pass / 0 fail. Also 487/0 under a pseudo-TTY.The command declaration changed from
app.command('create [projectName]')tonew Command('create').argument('[projectName]'), so its visible surface was checked directly and is identical:Usage: solana-mobile create [options] [projectName]create [options] [projectName]registers create command options)--minimalwith--templatestill rejectedcreate my-app --minimal --reset-project --dry-runstill passestemplateOptions: ["reset-project"]throughNo changeset: the
solana-mobilebin and the./templatesexport are unchanged.Summary by CodeRabbit
New Features
Tests