refactor(init): split init flows into separate files#929
Conversation
|
Claude finished @mttdnt's task in 3m 59s —— View job Review
Changeset: Not needed — pure refactor with no public API or behavioral change (other than the intentional
|
📦 Bundle Stats —
|
| Metric | Value | vs main (c555445) |
|---|---|---|
| Internal (raw) | 2.1 KB | - |
| Internal (gzip) | 799 B | - |
| Bundled (raw) | 10.95 MB | - |
| Bundled (gzip) | 2.06 MB | - |
| Import time | 867ms | +28ms, +3.3% |
bin:sanity
| Metric | Value | vs main (c555445) |
|---|---|---|
| Internal (raw) | 975 B | - |
| Internal (gzip) | 460 B | - |
| Bundled (raw) | 9.84 MB | - |
| Bundled (gzip) | 1.77 MB | - |
| Import time | 2.06s | +72ms, +3.6% |
🗺️ View treemap · Artifacts
Details
- Import time regressions over 10% are flagged with
⚠️ - Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.
📦 Bundle Stats — @sanity/cli-core
Compared against main (c5554452)
| Metric | Value | vs main (c555445) |
|---|---|---|
| Internal (raw) | 93.1 KB | - |
| Internal (gzip) | 21.9 KB | - |
| Bundled (raw) | 21.63 MB | - |
| Bundled (gzip) | 3.42 MB | - |
| Import time | 819ms | +20ms, +2.5% |
🗺️ View treemap · Artifacts
Details
- Import time regressions over 10% are flagged with
⚠️ - Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.
📦 Bundle Stats — create-sanity
Compared against main (c5554452)
| Metric | Value | vs main (c555445) |
|---|---|---|
| Internal (raw) | 976 B | - |
| Internal (gzip) | 507 B | - |
| Bundled (raw) | 50.7 KB | - |
| Bundled (gzip) | 12.6 KB | - |
| Import time | ❌ ChildProcess denied: node | - |
Details
- Import time regressions over 10% are flagged with
⚠️ - Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.
Coverage Delta
Comparing 6 changed files against main @ Overall Coverage
|
Extract 9 private methods from the monolithic InitCommand class into 5 standalone modules under actions/init/, preparing the file structure for the bundled-create branch to cleanly rebase on top. New files: - initHelpers.ts (shouldPrompt, flagOrDefault, getPostInitMCPPrompt, writeStagingEnvIfNeeded) - scaffoldTemplate.ts (selectTemplate, scaffoldAndInstall) - initNextJs.ts (initNextJs, writeOrOverwrite, writeSourceFiles) - initApp.ts (initApp — app template flow) - initStudio.ts (initStudio — studio template flow) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1e38824 to
27ef18e
Compare
Description
Splits
packages/@sanity/cli/src/commands/init.ts(~1755 lines) into 5 separate flow modules underactions/init/. This is prep work so thebundled-createbranch (PR #845) can cleanly rebase on top — the file structure now matches commit 2 of that branch (d38cfc05).New files:
initHelpers.ts— shared utilities (shouldPrompt,flagOrDefault,getPostInitMCPPrompt,writeStagingEnvIfNeeded)scaffoldTemplate.ts— template selection + scaffolding pipeline (selectTemplate,scaffoldAndInstall)initNextJs.ts— Next.js integration flowinitApp.ts— app template flowinitStudio.ts— studio template flow (includes dataset import)9 private methods removed from
InitCommand, 13 remain (auth, project/dataset/org management — those move in the future oclif-removal PR).No new types (
InitOptions,InitContext,InitError) are introduced — extracted functions take explicit parameters and use the existingOutputtype. The future rebase PR will consolidate these into the context/options pattern.What to review
actions/init/— each is a straightforward extraction frominit.tsprivate methodsinit.tschanges —run()now delegates toinitApp/initStudio/initNextJsinstead of inline logicinit.nextjs.test.ts— removedthis.exit(0)expectation,init.get-project-details.test.ts— removed stale mock for app template path)Testing
All 78 existing init tests pass. No new tests added — this is a pure refactor with no behavioral changes (except removing the unnecessary
this.exit(0)from the Next.js flow, matching the bundled-create target).pnpm check:types✅pnpm check:lint✅pnpm check:deps✅ (only pre-existing fixture issues)pnpm test(init suite) ✅ 78/78pnpm build:cli✅🤖 Generated with Claude Code