TML-3053: Export a programmatic init plan/apply API from @prisma-next/cli#1004
TML-3053: Export a programmatic init plan/apply API from @prisma-next/cli#1004AmanVarshney01 wants to merge 1 commit into
Conversation
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 35 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (8)
📝 WalkthroughWalkthroughThe init command now separates input resolution, scaffold planning, and filesystem application. A new programmatic ChangesInit planning and application
Estimated code review effort: 4 (Complex) | ~45 minutes Suggested reviewers: Sequence Diagram(s)sequenceDiagram
participant InitCommand
participant buildInitPlan
participant applyInitPlan
participant Filesystem
InitCommand->>buildInitPlan: resolve inputs and create InitPlan
buildInitPlan-->>InitCommand: staged files, deletions, warnings
InitCommand->>applyInitPlan: apply InitPlan
applyInitPlan->>Filesystem: write planned files
applyInitPlan->>Filesystem: delete planned paths
applyInitPlan-->>InitCommand: written and deleted paths
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
@prisma-next/extension-author-tools
@prisma-next/mongo-runtime
@prisma-next/family-mongo
@prisma-next/sql-runtime
@prisma-next/family-sql
@prisma-next/extension-arktype-json
@prisma-next/middleware-cache
@prisma-next/mongo
@prisma-next/extension-paradedb
@prisma-next/extension-pgvector
@prisma-next/extension-postgis
@prisma-next/postgres
@prisma-next/sql-orm-client
@prisma-next/sqlite
@prisma-next/extension-supabase
@prisma-next/target-mongo
@prisma-next/adapter-mongo
@prisma-next/driver-mongo
@prisma-next/contract
@prisma-next/utils
@prisma-next/config
@prisma-next/errors
@prisma-next/framework-components
@prisma-next/operations
@prisma-next/ts-render
@prisma-next/contract-authoring
@prisma-next/ids
@prisma-next/psl-parser
@prisma-next/psl-printer
@prisma-next/cli
@prisma-next/cli-telemetry
@prisma-next/config-loader
@prisma-next/emitter
@prisma-next/language-server
@prisma-next/migration-tools
prisma-next
@prisma-next/vite-plugin-contract-emit
@prisma-next/mongo-codec
@prisma-next/mongo-contract
@prisma-next/mongo-value
@prisma-next/mongo-contract-psl
@prisma-next/mongo-contract-ts
@prisma-next/mongo-emitter
@prisma-next/mongo-schema-ir
@prisma-next/mongo-query-ast
@prisma-next/mongo-orm
@prisma-next/mongo-query-builder
@prisma-next/mongo-lowering
@prisma-next/mongo-wire
@prisma-next/sql-contract
@prisma-next/sql-errors
@prisma-next/sql-operations
@prisma-next/sql-schema-ir
@prisma-next/sql-contract-psl
@prisma-next/sql-contract-ts
@prisma-next/sql-contract-emitter
@prisma-next/sql-lane-query-builder
@prisma-next/sql-relational-core
@prisma-next/sql-builder
@prisma-next/target-postgres
@prisma-next/target-sqlite
@prisma-next/adapter-postgres
@prisma-next/adapter-sqlite
@prisma-next/driver-postgres
@prisma-next/driver-sqlite
commit: |
size-limit report 📦
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/1-framework/3-tooling/cli/src/commands/init/plan.ts (1)
254-254: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valuePrefer the repo cast helpers over bare
as.
JSON.parse(pkgRaw) as Record<string, unknown>(Line 254) and(err as { code: string }).code(Line 373) are bare casts in production code. As per coding guidelines ("No bareasin production code. UseblindCast<T, \"Reason\">orcastAs<T>from@prisma-next/utils/casts"), wrap these with the sanctioned helpers. This is mechanically-moved code, so treat it as cleanup rather than a blocker.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/1-framework/3-tooling/cli/src/commands/init/plan.ts` at line 254, Replace the bare casts in the init planning flow with the sanctioned cast helpers from `@prisma-next/utils/casts`: update the JSON.parse assignment near parsedPackageJson and the error-code access near the existing err handling to use blindCast or castAs with an appropriate reason. Preserve the current runtime behavior and types.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/1-framework/3-tooling/cli/src/commands/init/plan.ts`:
- Line 254: Replace the bare casts in the init planning flow with the sanctioned
cast helpers from `@prisma-next/utils/casts`: update the JSON.parse assignment
near parsedPackageJson and the error-code access near the existing err handling
to use blindCast or castAs with an appropriate reason. Preserve the current
runtime behavior and types.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: 5197b18e-148d-4fec-a781-34a3b8d2f759
📒 Files selected for processing (8)
packages/1-framework/3-tooling/cli/package.jsonpackages/1-framework/3-tooling/cli/src/commands/init/init.tspackages/1-framework/3-tooling/cli/src/commands/init/inputs.tspackages/1-framework/3-tooling/cli/src/commands/init/plan.tspackages/1-framework/3-tooling/cli/src/exports/init.tspackages/1-framework/3-tooling/cli/test/commands/init/init.test.tspackages/1-framework/3-tooling/cli/test/commands/init/plan.test.tspackages/1-framework/3-tooling/cli/tsdown.config.ts
…/cli Signed-off-by: Aman Varshney <amanvarshney.work@gmail.com>
df330d9 to
841c1fe
Compare
wmadden
left a comment
There was a problem hiding this comment.
We have a programmatic API for CLI commands already, called the ControlClient. Extend that with access to the init operations
Linked issue
TML-3053
Summary
Scaffolders (create-prisma@next, prisma/create-prisma#37) can only reach
initby spawning the CLI and re-editing the files it wrote, which is nondeterministic at render time and fragile (write-then-merge ordering). This PR splitsrunInitat the seam it already had — the FR6.2 precondition phase vs the write phase — intobuildInitPlan/applyInitPlaninsrc/commands/init/plan.ts, and exports a prompt-freeplanInit+applyInitPlanpair as a new@prisma-next/cli/initsubpath so consumers can stage the scaffold in memory, merge it with their own templates, and write once.runInitnow consumes the same pair, so CLI behavior is unchanged (same file set, ordering, warnings, structured errors, and exit codes).resolveInitInputstakesautoAcceptPrompts: booleaninstead of the fullGlobalFlagsso prompt-free callers do not synthesise CLI flag state;hasDirectDep/defaultPackageJsonContentmoved toplan.tswith the logic that uses them (no compat re-exports, per convention).Testing performed
pnpm --filter @prisma-next/cli test— 1360 tests / 107 files pass, including newtest/commands/init/plan.test.ts(14 tests: plan purity, apply fidelity, structured errors 5002/5004/5010/5011/5014, target alias mapping,.envopt-in, re-init deletions, package-manager threading)pnpm --filter @prisma-next/cli typecheckpnpm --filter @prisma-next/cli lint(baseline infos only, no new diagnostics)pnpm --filter @prisma-next/cli build—dist/exports/init.mjs/.d.mtsemitted for the new subpathSkill update
n/a — the
initCLI surface (flags, prompts, JSON output, exit codes) is unchanged; this adds a package-level programmatic API whose first consumer is create-prisma. Theinit --jsondocument contract remains exported via@prisma-next/cli/init-output.Checklist
git commit -s) per the DCO.TML-NNNN: <sentence-case title>form.Summary by CodeRabbit
New Features
initinterface for planning and applying project scaffolding.Bug Fixes