Skip to content

Commit 1520c3e

Browse files
feat: add Prisma Composer workflow (#53)
* feat: add Prisma Composer workflow Signed-off-by: Aman Varshney <amanvarshney.work@gmail.com> * fix: update tsdown dependency warning config Signed-off-by: Aman Varshney <amanvarshney.work@gmail.com> * fix: isolate generated TypeScript contract artifacts Write emitted contract JSON and types to a generated directory so TypeScript does not resolve contract.d.ts to the adjacent contract.ts source file. Signed-off-by: Aman Varshney <amanvarshney.work@gmail.com> * fix: pin the Prisma platform CLI prerelease Use the aligned RC2 package for init, authentication, and Composer commands so package-manager tag caches cannot resolve an older CLI without the ORM command. Signed-off-by: Aman Varshney <amanvarshney.work@gmail.com> * fix: show deployed app URL * fix: expose Elysia on Compute * fix: select the Elysia runtime adapter * fix: address deploy matrix failures * fix: align Composer framework dependencies * fix: bundle SvelteKit runtime dependencies Keep SvelteKit on adapter-node while asking Vite to inline the application runtime packages required by the self-contained Composer build artifact. Signed-off-by: Aman Varshney <amanvarshney.work@gmail.com> * fix: inline all SvelteKit SSR dependencies Use Vite noExternal for the full server dependency graph so the adapter-node build is self-contained for Composer. Signed-off-by: Aman Varshney <amanvarshney.work@gmail.com> * fix: default immediate deployment to yes Signed-off-by: Aman Varshney <amanvarshney.work@gmail.com> * chore: call the release Prisma 8 Signed-off-by: Aman Varshney <amanvarshney.work@gmail.com> * fix: consume released framework deployment fixes Signed-off-by: Aman Varshney <amanvarshney.work@gmail.com> * fix: connect and seed starter databases Signed-off-by: Aman Varshney <amanvarshney.work@gmail.com> * fix: keep seeding on public Composer bindings Signed-off-by: Aman Varshney <amanvarshney.work@gmail.com> * fix: seed through Composer service runtime Signed-off-by: Aman Varshney <amanvarshney.work@gmail.com> * refactor: align Prisma 8 templates with consolidated CLI * chore: update Composer packages to 0.9 --------- Signed-off-by: Aman Varshney <amanvarshney.work@gmail.com>
1 parent fca2dac commit 1520c3e

87 files changed

Lines changed: 1396 additions & 3500 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
- name: Setup Node.js
4444
uses: actions/setup-node@v4
4545
with:
46-
node-version: "22.14.0"
46+
node-version: "22.18.0"
4747
registry-url: "https://registry.npmjs.org"
4848

4949
- name: Compute preview metadata
@@ -201,7 +201,7 @@ jobs:
201201
- name: Setup Node.js
202202
uses: actions/setup-node@v4
203203
with:
204-
node-version: "22.14.0"
204+
node-version: "22.18.0"
205205
registry-url: "https://registry.npmjs.org"
206206

207207
- name: Extract version from commit message

README.md

Lines changed: 34 additions & 147 deletions
Original file line numberDiff line numberDiff line change
@@ -1,179 +1,66 @@
11
# create-prisma
22

3-
Scaffold a new app with Prisma Next already wired up.
3+
Create a Prisma 8 app with Prisma Composer built in.
44

5-
`create-prisma@next` gives you a project template, Prisma Next setup, database scripts, and a working starting point without making you assemble everything by hand.
5+
## Quick start
66

7-
## What It Does
8-
9-
- creates a new app from a supported template
10-
- adds Prisma Next dependencies for PostgreSQL or MongoDB
11-
- runs `prisma-next init --no-install` to scaffold `prisma/contract.*`, `prisma-next.config.ts`, `prisma/db.ts`, `prisma-next.md`, and `.env.example`
12-
- writes a template-specific Prisma Next runtime helper
13-
- adds `contract:emit`, `db:init`, `db:update`, `db:verify`, `db:seed`, `migration:plan`, `migrate`, `migration:status`, and `migration:show` scripts
14-
- adds `db:up` / `db:down` and `docker-compose.yml` for default MongoDB projects
15-
- creates or updates `.env` with `DATABASE_URL`
16-
- can install dependencies and run `prisma-next contract emit`
17-
18-
`db:init`, migrations, and seeding are never run automatically. PostgreSQL projects show
19-
`db:init` as a manual follow-up command; MongoDB projects show `db:up` plus the migration
20-
plan/apply path for initial schema setup.
21-
22-
## Quick Start
23-
24-
Use the package runner you already have:
7+
Use your package manager:
258

269
```bash
2710
npx create-prisma@next my-app
28-
```
29-
30-
```bash
3111
pnpm dlx create-prisma@next my-app
32-
```
33-
34-
```bash
3512
yarn dlx create-prisma@next my-app
36-
```
37-
38-
```bash
3913
bunx create-prisma@next my-app
4014
```
4115

42-
```bash
43-
deno run -A npm:create-prisma@next my-app
44-
```
45-
46-
If you already have it available locally:
47-
48-
```bash
49-
create-prisma
50-
```
51-
52-
## Common Examples
53-
54-
Create a project interactively:
55-
56-
```bash
57-
create-prisma
58-
```
59-
60-
Create a Minimal project non-interactively:
16+
The CLI initializes Prisma 8 with the aligned `@prisma/cli` prerelease, installs dependencies, emits the contract, and generates a deployable Composer app. PostgreSQL projects use Composer's native Prisma Postgres provider, including migrations and a typed runtime client.
6117

62-
```bash
63-
create-prisma my-script --template minimal --provider postgres
64-
```
18+
The only Composer prompt is:
6519

66-
Create a Hono app non-interactively:
67-
68-
```bash
69-
create-prisma my-api --template hono --provider postgres
20+
```text
21+
Deploy to Prisma now?
7022
```
7123

72-
Create a MongoDB app:
24+
Choose no to deploy later with the generated `deploy` script.
7325

74-
```bash
75-
create-prisma my-api --template hono --provider mongodb
76-
```
26+
## Templates
7727

78-
Scaffold into the current directory:
28+
- `minimal`
29+
- `hono`
30+
- `elysia`
31+
- `nest`
32+
- `next`
33+
- `svelte` (SvelteKit)
34+
- `astro`
35+
- `nuxt`
36+
- `tanstack-start`
7937

80-
```bash
81-
create-prisma . --template hono --provider postgres
82-
```
83-
84-
Use TypeScript contract authoring:
38+
PostgreSQL and MongoDB are supported with PSL or TypeScript contract authoring. npm, pnpm, Yarn, and Bun are supported.
8539

86-
```bash
87-
create-prisma my-app --template next --authoring typescript
88-
```
40+
## Options
8941

90-
Use Prisma Postgres auto-provisioning:
42+
- positional project name or `--name`
43+
- `--template`
44+
- `--provider postgres|postgresql|mongo|mongodb`
45+
- `--authoring psl|typescript`
46+
- `--package-manager npm|pnpm|yarn|bun`
47+
- `--deploy` / `--no-deploy`
48+
- `--yes`
49+
- `--force`
50+
- `--verbose`
9151

92-
```bash
93-
create-prisma my-app --template nest --provider postgres --prisma-postgres
94-
```
52+
This branch intentionally targets Prisma 8 only. It does not generate a Prisma 7 compatibility path.
9553

96-
Target a specific Prisma Next release (useful for regression / bisect work):
97-
98-
```bash
99-
create-prisma my-app --template hono --prisma-next-version 0.10.0
100-
```
101-
102-
Scaffold against an open PR via pkg.pr.new:
103-
104-
```bash
105-
create-prisma my-app --template hono --prisma-next-version pkg-pr-new:bad6795
106-
```
107-
108-
## Supported Templates
109-
110-
- `minimal` - script-first Prisma Next starter with no web framework
111-
- `hono` - lightweight TypeScript API server
112-
- `elysia` - Bun-friendly TypeScript API server
113-
- `nest` - structured Node API with controllers and services
114-
- `next` - full-stack React app with App Router
115-
- `svelte` - full-stack Svelte 5 app with Vite
116-
- `astro` - content-oriented web app with server routes
117-
- `nuxt` - full-stack Vue app with Nitro server routes
118-
- `tanstack-start` - React app with file routes and server functions
119-
120-
## Supported Databases
121-
122-
- `postgres` / `postgresql`
123-
- `mongo` / `mongodb`
124-
125-
## Supported Package Managers
126-
127-
- `npm`
128-
- `pnpm`
129-
- `yarn`
130-
- `bun`
131-
- `deno`
132-
133-
## Useful Flags
134-
135-
- positional project name or `--name` project name / relative path
136-
- `--template` choose the template
137-
- `--provider postgres|postgresql|mongo|mongodb` (default: `postgres`)
138-
- `--authoring psl|typescript` (default: `psl`)
139-
- `--package-manager` choose the package manager/runtime
140-
- `--database-url` set `DATABASE_URL`
141-
- `--yes` accept defaults and skip prompts
142-
- `--no-install` scaffold only
143-
- `--no-emit` skip `prisma-next contract emit`
144-
- `--prisma-postgres` provision Prisma Postgres for PostgreSQL
145-
- `--prisma-next-version <spec>` target a specific Prisma Next release, npm dist-tag, or
146-
pkg.pr.new PR preview. Accepts a published version (`0.10.0`, `0.11.0-dev.9`),
147-
an npm dist-tag (`latest` (default), `dev`, `next`, …), or `pkg-pr-new:<sha|branch|pr-number>`
148-
to install from `https://pkg.pr.new/prisma/prisma-next/<package>@<ref>`.
149-
- `--force` allow scaffolding into a non-empty directory
150-
- `--verbose` print full command output
151-
152-
Generated Node-based Prisma Next projects document Node.js 24 LTS or newer.
153-
154-
## Local Development
54+
## Development
15555

15656
```bash
15757
bun install
58+
bun run test:unit
59+
bun run typecheck
15860
bun run check
15961
bun run build
160-
bun run start
16162
```
16263

163-
Useful repo scripts:
164-
165-
- `bun run dev`
166-
- `bun run typecheck`
167-
- `bun run format`
168-
- `bun run lint`
169-
- `bun run bump`
170-
17164
## Telemetry
17265

173-
Published builds may send anonymous usage telemetry to help improve the CLI. It does not include project names, file paths, or database URLs.
174-
175-
Disable it with any of:
176-
177-
- `DO_NOT_TRACK`
178-
- `CREATE_PRISMA_DISABLE_TELEMETRY`
179-
- `CREATE_PRISMA_TELEMETRY_DISABLED`
66+
Published builds may send anonymous usage telemetry. It never includes project names, file paths, or database URLs. Disable it with `DO_NOT_TRACK`, `CREATE_PRISMA_DISABLE_TELEMETRY`, or `CREATE_PRISMA_TELEMETRY_DISABLED`.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "create-prisma",
33
"version": "0.4.2",
44
"private": false,
5-
"description": "Create Prisma Next projects with first-party templates and great DX.",
5+
"description": "Create Prisma 8 projects with first-party templates and great DX.",
66
"homepage": "https://github.com/prisma/create-prisma",
77
"bugs": {
88
"url": "https://github.com/prisma/create-prisma/issues"
@@ -37,7 +37,7 @@
3737
"dev": "tsdown --watch",
3838
"start": "bun run ./dist/cli.mjs",
3939
"test": "bun run test:unit && bun run test:e2e",
40-
"test:unit": "bun test ./tests/dependencies.test.ts ./tests/install.test.ts ./tests/setup-prisma.test.ts ./tests/telemetry.test.ts",
40+
"test:unit": "bun test ./tests/dependencies.test.ts ./tests/deploy-with-composer.test.ts ./tests/install.test.ts ./tests/node-version.test.ts ./tests/setup-prisma.test.ts ./tests/telemetry.test.ts",
4141
"test:e2e": "bun test --timeout 180000 ./tests/e2e/create-prisma.e2e.test.ts",
4242
"check": "bun run format:check && bun run lint",
4343
"lint": "oxlint . --deny-warnings",
@@ -73,7 +73,7 @@
7373
},
7474
"engines": {
7575
"bun": ">=1.3.0",
76-
"node": ">=24.0.0"
76+
"node": ">=22.18.0"
7777
},
7878
"packageManager": "bun@1.3.9"
7979
}

src/cli.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
11
import { createCreatePrismaCli } from "./index";
22

3-
createCreatePrismaCli().run();
3+
createCreatePrismaCli().run({
4+
process: {
5+
exit(code): never {
6+
const commandExitCode =
7+
typeof process.exitCode === "number" && process.exitCode !== 0 ? process.exitCode : code;
8+
process.exit(commandExitCode);
9+
},
10+
},
11+
});

src/commands/create.ts

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
trackCreateFailed,
88
type CreateTelemetryFailureStage,
99
} from "../telemetry";
10-
import { scaffoldCreateTemplate } from "../templates/render-create-template";
10+
import { scaffoldCreateFrameworkTemplate } from "../templates/render-create-template";
1111
import { writeCreateTemplateDependencies } from "../tasks/install";
1212
import type { PrismaSetupContext } from "../tasks/setup-prisma";
1313
import { collectPrismaSetupContext, executePrismaSetupContext } from "../tasks/setup-prisma";
@@ -18,6 +18,7 @@ import {
1818
type CreateTemplate,
1919
} from "../types";
2020
import { getCreatePrismaIntro } from "../ui/branding";
21+
import { getUnsupportedNodeMessage, supportsPrismaNext } from "../utils/node-version";
2122

2223
const DEFAULT_PROJECT_NAME = "my-app";
2324
const DEFAULT_TEMPLATE: CreateTemplate = "minimal";
@@ -100,7 +101,7 @@ async function promptForCreateTemplate(): Promise<CreateTemplate | undefined> {
100101
{
101102
value: "minimal",
102103
label: "Minimal",
103-
hint: "Script-first Prisma Next starter with no web framework",
104+
hint: "Script-first Prisma 8 starter with no web framework",
104105
},
105106
{
106107
value: "hono",
@@ -188,6 +189,12 @@ export async function runCreateCommand(rawInput: CreateCommandInput = {}): Promi
188189
try {
189190
input = CreateCommandInputSchema.parse(rawInput);
190191

192+
if (!supportsPrismaNext()) {
193+
cancel(getUnsupportedNodeMessage());
194+
process.exitCode = 1;
195+
return;
196+
}
197+
191198
intro(getCreatePrismaIntro());
192199

193200
failureStage = "collect_context";
@@ -199,6 +206,7 @@ export async function runCreateCommand(rawInput: CreateCommandInput = {}): Promi
199206
failureStage = "unknown";
200207
const executionResult = await executeCreateContext(context);
201208
if (!executionResult.ok) {
209+
process.exitCode = 1;
202210
if (executionResult.error) {
203211
cancel(
204212
`Create command failed: ${
@@ -225,6 +233,7 @@ export async function runCreateCommand(rawInput: CreateCommandInput = {}): Promi
225233
durationMs: Date.now() - startedAt,
226234
});
227235
} catch (error) {
236+
process.exitCode = 1;
228237
cancel(`Create command failed: ${error instanceof Error ? error.message : String(error)}`);
229238
await trackCreateFailed({
230239
input,
@@ -301,14 +310,14 @@ async function executeCreateContext(
301310
context: CreatePromptContext,
302311
): Promise<ExecuteCreateContextResult> {
303312
const createSpinner = context.prismaSetupContext.verbose ? undefined : spinner();
304-
createSpinner?.start("Creating Prisma Next project...");
313+
createSpinner?.start("Creating Prisma 8 project...");
305314

306315
try {
307316
if (context.prismaSetupContext.verbose) {
308317
log.step(`Scaffolding ${context.template} starter.`);
309318
}
310319

311-
await scaffoldCreateTemplate({
320+
await scaffoldCreateFrameworkTemplate({
312321
projectDir: context.targetDirectory,
313322
projectName: context.projectPackageName,
314323
template: context.template,
@@ -321,7 +330,7 @@ async function executeCreateContext(
321330
log.success("Starter files scaffolded.");
322331
}
323332
} catch (error) {
324-
createSpinner?.stop("Could not create Prisma Next project.");
333+
createSpinner?.stop("Could not create Prisma 8 project.");
325334
return {
326335
ok: false,
327336
stage: "scaffold_template",
@@ -334,10 +343,9 @@ async function executeCreateContext(
334343
template: context.template,
335344
packageManager: context.prismaSetupContext.packageManager,
336345
projectDir: context.targetDirectory,
337-
prismaNextSpec: context.prismaSetupContext.prismaNextSpec,
338346
});
339347
} catch (error) {
340-
createSpinner?.stop("Could not create Prisma Next project.");
348+
createSpinner?.stop("Could not create Prisma 8 project.");
341349
return {
342350
ok: false,
343351
stage: "scaffold_template",
@@ -369,6 +377,8 @@ async function executeCreateContext(
369377
const didSetupPrisma = await executePrismaSetupContext(context.prismaSetupContext, {
370378
prependNextSteps: nextSteps,
371379
projectDir: context.targetDirectory,
380+
projectName: context.projectPackageName,
381+
template: context.template,
372382
createdProjectPath: context.targetDirectory,
373383
includeDevNextStep: true,
374384
progressSpinner: createSpinner,
@@ -381,7 +391,7 @@ async function executeCreateContext(
381391
};
382392
}
383393
} catch (error) {
384-
createSpinner?.stop("Could not create Prisma Next project.");
394+
createSpinner?.stop("Could not create Prisma 8 project.");
385395
return {
386396
ok: false,
387397
stage: "prisma_setup",

0 commit comments

Comments
 (0)