Skip to content

fix: harden generated app installs and deploys#50

Merged
AmanVarshney01 merged 4 commits into
mainfrom
aman/fix-template-matrix-deploy
Jul 1, 2026
Merged

fix: harden generated app installs and deploys#50
AmanVarshney01 merged 4 commits into
mainfrom
aman/fix-template-matrix-deploy

Conversation

@AmanVarshney01

@AmanVarshney01 AmanVarshney01 commented Jul 1, 2026

Copy link
Copy Markdown
Member

Summary

  • Run generated db:generate scripts so framework-specific setup, such as SvelteKit sync, happens before Prisma Client generation.
  • Harden generated installs across package managers: Yarn non-immutable installs, Elysia Yarn node-modules config, missing Node typings, package-local turborepo DB scripts, and centralized pnpm allowBuilds generation/merging.
  • Keep generated Astro SSR builds self-contained for Prisma Compute with vite.ssr.noExternal: true until the Compute runtime can safely execute Astro externalized SSR deps without Bun runtime package resolution drift.
  • Make explicit unsupported deploy requests fail with a non-zero exit, while keeping failure telemetry best-effort so it cannot mask the original command error.

Notes

The pnpm workspace file is now generated programmatically only when packageManager === "pnpm":

  • single-app pnpm templates get a pnpm-workspace.yaml containing allowBuilds
  • non-pnpm single-app templates do not get a pnpm workspace file
  • turborepo keeps its package globs and receives allowBuilds only for pnpm
  • existing allowBuilds blocks are merged with any missing required packages

Astro note: @prisma/compute-sdk@0.32.0 now traces Astro runtime dependencies, but a real PR-preview deploy without noExternal still crashed in Compute under Bun with Export 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 check
  • bun run typecheck
  • bun run build
  • Focused turborepo + pnpm scaffold check: packages/db has package-local db:* scripts and pnpm-workspace.yaml keeps package globs plus allowBuilds.
  • Verified published @prisma/compute-sdk@0.32.0 has Astro traceDependencies: true.
  • Local Astro/Postgres scaffold without vite.ssr.noExternal built and staged successfully with AstroBuild, and the staged artifact returned 200 OK locally.
  • Real PR-preview Astro deploy without vite.ssr.noExternal reproduced the Compute runtime crash above, so the template keeps noExternal: true.
  • Manual scaffold matrix: 450/450 passed across templates, providers, package managers, and schema presets.
  • Manual Astro post-fix matrix: 50/50 scaffold and 10/10 install/build/typecheck passed.
  • Focused render check for pnpm workspace behavior:
    • Astro + Bun: no pnpm-workspace.yaml
    • Astro + pnpm: allowBuilds generated
    • Turborepo + Bun: package globs only
    • Turborepo + pnpm: package globs plus allowBuilds
  • Real Prisma Compute smoke deploys for supported templates.

@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: e18b2acc-7a00-461d-a77c-48379eaec9d4

📥 Commits

Reviewing files that changed from the base of the PR and between ae8a60f and fe0a33d.

📒 Files selected for processing (5)
  • src/tasks/setup-prisma.ts
  • src/templates/render-create-template.ts
  • src/utils/regexp.ts
  • templates/create/astro/astro.config.mjs.hbs
  • templates/create/tanstack-start/src/routes/index.tsx.hbs
💤 Files with no reviewable changes (1)
  • templates/create/tanstack-start/src/routes/index.tsx.hbs

Summary by CodeRabbit

  • New Features

    • Improved project scaffolding for several starters, including better TypeScript support and package-manager-specific setup.
    • Added support for more reliable script execution during generated project setup.
  • Bug Fixes

    • Fixed command-line error handling so failures are reported and exit codes are respected more consistently.
    • Improved install and build behavior for Yarn, pnpm, and server-side deployments to reduce setup and runtime issues.

Walkthrough

This 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 escapeRegExp, and adds pnpm workspace allowBuilds management. Several templates were also updated with Node.js type definitions, conditional yarn and import config, Prisma scripts, and Astro SSR settings.

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
Loading

Related PRs: None found.
Suggested labels: bug, templates, cli
Suggested reviewers: None specified.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 5.88% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title matches the main theme of the PR: hardening generated installs and deploy behavior.
Description check ✅ Passed The description directly summarizes the template, install, and deploy changes in the changeset.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch aman/fix-template-matrix-deploy
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch aman/fix-template-matrix-deploy

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

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

PR preview published

  • Version: 0.7.1-pr.50.164.1
  • Tag: pr50
  • Run with Bun: bunx create-prisma@pr50
  • Run with npm: npx create-prisma@pr50
  • Run with Yarn: yarn dlx create-prisma@pr50
  • Run with pnpm: pnpm dlx create-prisma@pr50
  • Run with Deno: deno run -A npm:create-prisma@pr50
  • Workflow run: https://github.com/prisma/create-prisma/actions/runs/28544742505

@AmanVarshney01
AmanVarshney01 marked this pull request as ready for review July 1, 2026 07:59
@AmanVarshney01
AmanVarshney01 marked this pull request as draft July 1, 2026 08:02
@AmanVarshney01
AmanVarshney01 force-pushed the aman/fix-template-matrix-deploy branch from 380691b to dfe4bf6 Compare July 1, 2026 08:05

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between d6235e5 and 380691b.

📒 Files selected for processing (24)
  • src/cli.ts
  • src/commands/create.ts
  • src/tasks/deploy-to-compute.ts
  • src/tasks/install.ts
  • src/tasks/setup-prisma.ts
  • src/utils/package-manager.ts
  • templates/create/astro/astro.config.mjs.hbs
  • templates/create/astro/pnpm-workspace.yaml.hbs
  • templates/create/elysia/.yarnrc.yml.hbs
  • templates/create/elysia/pnpm-workspace.yaml.hbs
  • templates/create/elysia/tsconfig.json
  • templates/create/hono/pnpm-workspace.yaml.hbs
  • templates/create/hono/tsconfig.json
  • templates/create/nest/pnpm-workspace.yaml.hbs
  • templates/create/nest/tsconfig.json
  • templates/create/next/pnpm-workspace.yaml.hbs
  • templates/create/nuxt/pnpm-workspace.yaml.hbs
  • templates/create/svelte/pnpm-workspace.yaml.hbs
  • templates/create/tanstack-start/pnpm-workspace.yaml.hbs
  • templates/create/tanstack-start/src/routes/index.tsx.hbs
  • templates/create/tanstack-start/tsconfig.json
  • templates/create/turborepo/apps/api/tsconfig.json
  • templates/create/turborepo/packages/db/tsconfig.json
  • templates/create/turborepo/pnpm-workspace.yaml

Comment thread src/utils/package-manager.ts
Comment thread templates/create/astro/astro.config.mjs.hbs
Comment thread templates/create/elysia/tsconfig.json
Comment thread templates/create/nuxt/pnpm-workspace.yaml.hbs Outdated
@AmanVarshney01
AmanVarshney01 force-pushed the aman/fix-template-matrix-deploy branch 3 times, most recently from 5b4f923 to 096c279 Compare July 1, 2026 10:49
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 1, 2026
@AmanVarshney01
AmanVarshney01 marked this pull request as ready for review July 1, 2026 13:53
@AmanVarshney01
AmanVarshney01 force-pushed the aman/fix-template-matrix-deploy branch from 096c279 to 20d4147 Compare July 1, 2026 14:06

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 096c279 and 20d4147.

📒 Files selected for processing (16)
  • src/cli.ts
  • src/commands/create.ts
  • src/tasks/deploy-to-compute.ts
  • src/tasks/install.ts
  • src/tasks/setup-prisma.ts
  • src/templates/render-create-template.ts
  • src/utils/package-manager.ts
  • templates/create/elysia/.yarnrc.yml.hbs
  • templates/create/elysia/package.json.hbs
  • templates/create/elysia/tsconfig.json
  • templates/create/hono/tsconfig.json
  • templates/create/nest/tsconfig.json
  • templates/create/tanstack-start/src/routes/index.tsx.hbs
  • templates/create/tanstack-start/tsconfig.json
  • templates/create/turborepo/apps/api/tsconfig.json
  • templates/create/turborepo/packages/db/tsconfig.json

Comment thread src/commands/create.ts
Comment thread src/tasks/setup-prisma.ts
Comment thread src/templates/render-create-template.ts
@AmanVarshney01
AmanVarshney01 force-pushed the aman/fix-template-matrix-deploy branch from 20d4147 to 1abdb19 Compare July 1, 2026 14:19
@AmanVarshney01
AmanVarshney01 force-pushed the aman/fix-template-matrix-deploy branch from 1abdb19 to ae8a60f Compare July 1, 2026 14:24

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 20d4147 and ae8a60f.

📒 Files selected for processing (18)
  • src/cli.ts
  • src/commands/create.ts
  • src/tasks/deploy-to-compute.ts
  • src/tasks/install.ts
  • src/tasks/setup-prisma.ts
  • src/templates/render-create-template.ts
  • src/utils/package-manager.ts
  • templates/create/astro/astro.config.mjs.hbs
  • templates/create/elysia/.yarnrc.yml.hbs
  • templates/create/elysia/package.json.hbs
  • templates/create/elysia/tsconfig.json
  • templates/create/hono/tsconfig.json
  • templates/create/nest/tsconfig.json
  • templates/create/tanstack-start/src/routes/index.tsx.hbs
  • templates/create/tanstack-start/tsconfig.json
  • templates/create/turborepo/apps/api/tsconfig.json
  • templates/create/turborepo/packages/db/package.json.hbs
  • templates/create/turborepo/packages/db/tsconfig.json

Comment thread src/templates/render-create-template.ts Outdated
Comment thread templates/create/tanstack-start/src/routes/index.tsx.hbs
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 1, 2026
@AmanVarshney01

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@AmanVarshney01
AmanVarshney01 merged commit a917311 into main Jul 1, 2026
6 checks passed
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