fix: harden generated app installs and deploys#50
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (5)
💤 Files with no reviewable changes (1)
Summary by CodeRabbit
WalkthroughThis PR updates CLI exit handling and create-command error propagation, adds explicit deploy failure handling for unsupported templates, adjusts yarn install environment handling, refactors Prisma client generation to use package-manager run-script helpers, introduces Sequence Diagram(s)sequenceDiagram
participant cli.ts
participant createCreatePrismaCli
participant runCreateCommand
participant executeCreateContext
participant process
cli.ts->>createCreatePrismaCli: await run(formatError)
createCreatePrismaCli->>runCreateCommand: execute create command
runCreateCommand->>executeCreateContext: executeCreateContext()
executeCreateContext-->>runCreateCommand: non-ok result
runCreateCommand->>runCreateCommand: normalize and throw Error
createCreatePrismaCli-->>cli.ts: sets process.exitCode
cli.ts->>process: exit(process.exitCode) if non-zero
Related PRs: None found. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
Comment |
PR preview published
|
380691b to
dfe4bf6
Compare
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 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.
Inline comments:
In `@src/utils/package-manager.ts`:
- Around line 176-208: `getRunScriptArgs` duplicates the package-manager mapping
already defined in `getRunScriptCommand`, which can cause the logged command and
executed command to drift. Refactor `getRunScriptArgs` to derive its `{ command,
args }` from the same single source of truth used by `getRunScriptCommand`
(using the `packageManager` switch in `src/utils/package-manager.ts`), so both
`generatePrismaClientForContext` and other callers stay consistent. Keep the
existing `deno`/`npm` behavior intact while centralizing the script invocation
mapping.
In `@templates/create/astro/astro.config.mjs.hbs`:
- Around line 9-14: The Astro template currently sets vite.ssr.noExternal to
true for every generated app, which is too broad. Update the
astro.config.mjs.hbs template so the SSR bundling workaround is either gated on
the compute template context flag or narrowed in the vite.ssr configuration to
only the packages that need it, using the existing Astro config block as the
place to adjust this behavior.
In `@templates/create/elysia/tsconfig.json`:
- Line 10: The Elysia template’s tsconfig references node globals via the
"types": ["node"] setting, but the template package manifest only installs
typescript. Update templates/create/elysia/package.json.hbs to include
`@types/node` in devDependencies, or remove the node types entry from
tsconfig.json if Node typings are not intended; make the change in the template
files so generated projects stay consistent.
In `@templates/create/nuxt/pnpm-workspace.yaml.hbs`:
- Around line 1-9: The pnpm allowlist is duplicated in every
pnpm-workspace.yaml.hbs template, so centralize the shared allowBuilds map
instead of keeping the same six-package block in each template. Update the
relevant template(s) such as the Nuxt pnpm-workspace.yaml.hbs to include a
shared Handlebars partial or helper, and wire it through the template rendering
flow so all framework templates reuse the same allowBuilds source.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: fff679a8-6bd5-46d8-8d58-6a252f10beab
📒 Files selected for processing (24)
src/cli.tssrc/commands/create.tssrc/tasks/deploy-to-compute.tssrc/tasks/install.tssrc/tasks/setup-prisma.tssrc/utils/package-manager.tstemplates/create/astro/astro.config.mjs.hbstemplates/create/astro/pnpm-workspace.yaml.hbstemplates/create/elysia/.yarnrc.yml.hbstemplates/create/elysia/pnpm-workspace.yaml.hbstemplates/create/elysia/tsconfig.jsontemplates/create/hono/pnpm-workspace.yaml.hbstemplates/create/hono/tsconfig.jsontemplates/create/nest/pnpm-workspace.yaml.hbstemplates/create/nest/tsconfig.jsontemplates/create/next/pnpm-workspace.yaml.hbstemplates/create/nuxt/pnpm-workspace.yaml.hbstemplates/create/svelte/pnpm-workspace.yaml.hbstemplates/create/tanstack-start/pnpm-workspace.yaml.hbstemplates/create/tanstack-start/src/routes/index.tsx.hbstemplates/create/tanstack-start/tsconfig.jsontemplates/create/turborepo/apps/api/tsconfig.jsontemplates/create/turborepo/packages/db/tsconfig.jsontemplates/create/turborepo/pnpm-workspace.yaml
5b4f923 to
096c279
Compare
096c279 to
20d4147
Compare
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 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.
Inline comments:
In `@src/commands/create.ts`:
- Around line 243-254: The catch block in createCommand is letting
trackCreateFailed replace the original command error if telemetry throws, which
hides the real failure. Wrap the await trackCreateFailed(...) call in its own
try/catch inside createCommand’s catch handler, keep commandError as the error
that gets rethrown, and treat telemetry failures as best-effort only so
src/cli.ts and formatError still receive the original create-command exception.
In `@src/tasks/setup-prisma.ts`:
- Around line 663-671: The Prisma generation path in
generatePrismaClientForContext() is invoking db:generate from the package
itself, but the package that owns it does not define that script. Add a
db:generate entry to the relevant package.json.hbs template(s), especially
packages/db in the turborepo template, and update any other Prisma starter
packages still missing it so getRunScriptCommand/getRunScriptArgs resolve
correctly from the package working directory.
In `@src/templates/render-create-template.ts`:
- Around line 63-66: The early return in render-create-template based on
matching allowBuilds: prevents merging required packages into an existing
workspace config. Update render-create-template to inspect the current
pnpm-workspace.yaml content and merge any missing allowBuilds entries instead of
skipping when the key already exists, using the existing allowBuilds handling
logic to preserve required packages like prisma, sharp, and esbuild.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 95a7b673-10e9-4cf9-b317-c1996d900794
📒 Files selected for processing (16)
src/cli.tssrc/commands/create.tssrc/tasks/deploy-to-compute.tssrc/tasks/install.tssrc/tasks/setup-prisma.tssrc/templates/render-create-template.tssrc/utils/package-manager.tstemplates/create/elysia/.yarnrc.yml.hbstemplates/create/elysia/package.json.hbstemplates/create/elysia/tsconfig.jsontemplates/create/hono/tsconfig.jsontemplates/create/nest/tsconfig.jsontemplates/create/tanstack-start/src/routes/index.tsx.hbstemplates/create/tanstack-start/tsconfig.jsontemplates/create/turborepo/apps/api/tsconfig.jsontemplates/create/turborepo/packages/db/tsconfig.json
20d4147 to
1abdb19
Compare
1abdb19 to
ae8a60f
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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.
Inline comments:
In `@src/templates/render-create-template.ts`:
- Around line 44-46: The render-create-template.ts file defines a duplicate
escapeRegExp helper that matches the one in setup-prisma, so update the shared
behavior instead of keeping two copies. Extract escapeRegExp into a common
utility module and have both render-create-template and setup-prisma import it,
or otherwise centralize the helper so there is only one implementation to
maintain.
In `@templates/create/tanstack-start/src/routes/index.tsx.hbs`:
- Around line 2-7: Merge the two adjacent `{{`#if` (eq schemaPreset "basic")}}`
blocks in `index.tsx.hbs` into a single conditional block so both
`createServerFn` and `prisma` imports are grouped together. Update the template
around the `createServerFn` and `prisma` import statements to keep one
`schemaPreset === "basic"` check instead of duplicating the same condition
twice.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: c0b0ed0d-7f59-4e6a-a027-204077041485
📒 Files selected for processing (18)
src/cli.tssrc/commands/create.tssrc/tasks/deploy-to-compute.tssrc/tasks/install.tssrc/tasks/setup-prisma.tssrc/templates/render-create-template.tssrc/utils/package-manager.tstemplates/create/astro/astro.config.mjs.hbstemplates/create/elysia/.yarnrc.yml.hbstemplates/create/elysia/package.json.hbstemplates/create/elysia/tsconfig.jsontemplates/create/hono/tsconfig.jsontemplates/create/nest/tsconfig.jsontemplates/create/tanstack-start/src/routes/index.tsx.hbstemplates/create/tanstack-start/tsconfig.jsontemplates/create/turborepo/apps/api/tsconfig.jsontemplates/create/turborepo/packages/db/package.json.hbstemplates/create/turborepo/packages/db/tsconfig.json
…amed exports at runtime
|
@coderabbitai review |
✅ Action performedReview finished.
|
Summary
db:generatescripts so framework-specific setup, such as SvelteKit sync, happens before Prisma Client generation.allowBuildsgeneration/merging.vite.ssr.noExternal: trueuntil the Compute runtime can safely execute Astro externalized SSR deps without Bun runtime package resolution drift.Notes
The pnpm workspace file is now generated programmatically only when
packageManager === "pnpm":pnpm-workspace.yamlcontainingallowBuildsallowBuildsonly for pnpmallowBuildsblocks are merged with any missing required packagesAstro note:
@prisma/compute-sdk@0.32.0now traces Astro runtime dependencies, but a real PR-preview deploy withoutnoExternalstill crashed in Compute under Bun withExport named 'parse' not found in module '/.bun/install/cache/cookie@2.0.1@@@1/dist/index.js'. Keeping the generated SSR bundle self-contained is the safer production default for now.Validation
bun run checkbun run typecheckbun run buildpackages/dbhas package-localdb:*scripts andpnpm-workspace.yamlkeeps package globs plusallowBuilds.@prisma/compute-sdk@0.32.0has AstrotraceDependencies: true.vite.ssr.noExternalbuilt and staged successfully withAstroBuild, and the staged artifact returned200 OKlocally.vite.ssr.noExternalreproduced the Compute runtime crash above, so the template keepsnoExternal: true.pnpm-workspace.yamlallowBuildsgeneratedallowBuilds