Skip to content

refactor: split the create barrel into wiring, scaffolding and catalog constants - #46

Merged
beeman merged 1 commit into
mainfrom
beeman/split-create-feature-barrel
Sep 4, 2026
Merged

refactor: split the create barrel into wiring, scaffolding and catalog constants#46
beeman merged 1 commit into
mainfrom
beeman/split-create-feature-barrel

Conversation

@beeman

@beeman beeman commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

Completes the series after #41 (localnet) and #45 (the other six). create was the last command whose wiring lived in src/app.ts, and create-feature-index.ts the last *-feature-index.ts barrel — both are gone.

src/app.ts is now 110 lines, down from 660 at the start of the series. It 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 split

file role
create-feature.ts (new) Commander boundary: createCreateCommand(deps), the parseOptions override and its templateOptions closure, extractTemplateOptions with findKnownOption/hasInlineValue, parsePackageManagerOption
create-feature-scaffold.ts (renamed barrel) runCreate, the create-solana-dapp API surface, prompt helpers, template resolution — no longer imports commander at all
data-access/template-catalog.ts (new) CUSTOM_TEMPLATES_URL, MINIMAL_TEMPLATE_NAME — they describe the template catalog, not the CLI

The parseOptions override and its let templateOptions closure were previously in app.ts, physically separated from the extractTemplateOptions they 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 name suite move out of test/core.test.ts (965 → 388 lines) into a new test/create.test.ts, along 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 addCommand-registered like every other feature command, so it also depends on createApp copying the root's showHelpAfterError — but it cannot join the app-level guard covering the other seven: its parseOptions override collects unknown long flags as template options before commander can reject them, so --bogus is 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) and test/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 against 2fc829d that all three had zero such gaps before #45, and that core.test.ts has none across ~90 tests, so the blank line is the convention.

test/doctor.test.ts has 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]') to new Command('create').argument('[projectName]'), so its visible surface was checked directly and is identical:

  • Usage: solana-mobile create [options] [projectName]
  • the top-level listing entry, create [options] [projectName]
  • the option list (asserted by registers create command options)
  • the trailing help text about template flags
  • --minimal with --template still rejected
  • create my-app --minimal --reset-project --dry-run still passes templateOptions: ["reset-project"] through

No changeset: the solana-mobile bin and the ./templates export are unchanged.

Summary by CodeRabbit

  • New Features

    • Added a dedicated project creation command for Solana Mobile projects.
    • Supports package manager selection, custom and minimal templates, dry runs, template listing, Git initialization, dependency installation, verbosity, and template-specific options.
    • Added validation for incompatible options, invalid package managers, and malformed template arguments.
    • Improved support for local and GitHub templates, project-name prompts, cancellation, and built-in help.
  • Tests

    • Expanded coverage for project creation workflows and command-line option handling.

…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.
@changeset-bot

changeset-bot Bot commented Sep 4, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: dd020c9

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Sep 4, 2026

Copy link
Copy Markdown

Open in StackBlitz

bun add https://pkg.pr.new/solana-mobile/solana-mobile-cli/solana-mobile@46

commit: dd020c9

@coderabbitai

coderabbitai Bot commented Sep 4, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: d63cd105-425d-417a-b05c-1d1b9903ec71

📥 Commits

Reviewing files that changed from the base of the PR and between b1d52aa and dd020c9.

📒 Files selected for processing (9)
  • src/app.ts
  • src/create/create-feature-scaffold.ts
  • src/create/create-feature.ts
  • src/create/data-access/template-catalog.ts
  • test/core.test.ts
  • test/create.test.ts
  • test/device.test.ts
  • test/emulator.test.ts
  • test/templates.test.ts
💤 Files with no reviewable changes (1)
  • test/core.test.ts

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.


📝 Walkthrough

Walkthrough

The create command now owns Commander registration, option parsing, validation, and delegation. The application injects dependencies through CreateCommandDeps. Create tests move to test/create.test.ts. Other test files receive spacing-only changes.

Changes

Create command migration

Layer / File(s) Summary
Create command implementation
src/create/create-feature.ts, src/create/create-feature-scaffold.ts, src/create/data-access/template-catalog.ts
The create feature now defines command options, template-flag extraction, package-manager validation, and catalog constants. The scaffold module no longer defines the removed helpers.
Application registration
src/app.ts
createApp now registers createCreateCommand(appOptions). AppOptions extends CreateCommandDeps.
Create command coverage
test/create.test.ts, test/core.test.ts, test/device.test.ts, test/emulator.test.ts, test/templates.test.ts
Create behavior coverage moves to test/create.test.ts. Core create tests and helpers are removed. Other command tests receive spacing-only edits.

Estimated code review effort: 4 (Complex) | ~45 minutes

Merge Risk: ⚪ Minimal · up to dd020

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)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 8 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely describes the main change: splitting the create command implementation into wiring, scaffolding, and template catalog constants.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch beeman/split-create-feature-barrel

Comment @coderabbitai help to get the list of available commands.

@beeman
beeman added this pull request to the merge queue Sep 4, 2026
Merged via the queue into main with commit 56f6149 Sep 4, 2026
6 checks passed
@beeman
beeman deleted the beeman/split-create-feature-barrel branch September 4, 2026 00:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant