create-prisma 0.4.2-pr.53.198.1 → 0.4.2-pr.53.200.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import "./create-BHcAcUH1.mjs";
2
+ import "./create-DbthKFmi.mjs";
3
3
  import { createCreatePrismaCli } from "./index.mjs";
4
4
 
5
5
  //#region src/cli.ts
@@ -40,7 +40,7 @@ async function getAnonymousId() {
40
40
  }
41
41
  function getCommonProperties() {
42
42
  return {
43
- "cli-version": "0.4.2-pr.53.198.1",
43
+ "cli-version": "0.4.2-pr.53.200.1",
44
44
  "node-version": process.version,
45
45
  platform: process.platform,
46
46
  arch: process.arch
@@ -301,39 +301,6 @@ function getPackageExecutionCommand(packageManager, commandArgs) {
301
301
  const execution = getPackageExecutionArgs(packageManager, commandArgs);
302
302
  return [execution.command, ...execution.args].join(" ");
303
303
  }
304
- function getLocalPackageBinaryArgs(packageManager, binaryName, binaryArgs) {
305
- switch (packageManager) {
306
- case "pnpm": return {
307
- command: "pnpm",
308
- args: [
309
- "exec",
310
- binaryName,
311
- ...binaryArgs
312
- ]
313
- };
314
- case "yarn": return {
315
- command: "yarn",
316
- args: [binaryName, ...binaryArgs]
317
- };
318
- case "bun": return {
319
- command: "bun",
320
- args: [binaryName, ...binaryArgs]
321
- };
322
- default: return {
323
- command: "npm",
324
- args: [
325
- "exec",
326
- binaryName,
327
- "--",
328
- ...binaryArgs
329
- ]
330
- };
331
- }
332
- }
333
- function getLocalPackageBinaryCommand(packageManager, binaryName, binaryArgs) {
334
- const execution = getLocalPackageBinaryArgs(packageManager, binaryName, binaryArgs);
335
- return [execution.command, ...execution.args].join(" ");
336
- }
337
304
  function getRunScriptArgs(packageManager, scriptName) {
338
305
  switch (packageManager) {
339
306
  case "bun": return {
@@ -355,21 +322,11 @@ function getRunScriptArgs(packageManager, scriptName) {
355
322
  }
356
323
  }
357
324
 
358
- //#endregion
359
- //#region src/utils/runtime.ts
360
- function usesNodeStyleRuntime(packageManager) {
361
- return packageManager !== void 0 && packageManager !== "bun";
362
- }
363
- function requiresDotenvConfigImport(packageManager) {
364
- return usesNodeStyleRuntime(packageManager);
365
- }
366
-
367
325
  //#endregion
368
326
  //#region src/templates/shared.ts
369
327
  Handlebars.registerHelper("eq", (left, right) => left === right);
370
328
  Handlebars.registerHelper("runScriptCommand", (packageManager, scriptName) => packageManager ? getRunScriptCommand(packageManager, scriptName) : "");
371
329
  Handlebars.registerHelper("packageManagerManifestValue", (packageManager) => getPackageManagerManifestValue(packageManager) ?? "");
372
- Handlebars.registerHelper("requiresDotenvConfigImport", (packageManager) => requiresDotenvConfigImport(packageManager));
373
330
  Handlebars.registerHelper("runtimeScript", (packageManager, kind, sourceEntrypoint, builtEntrypoint, _options) => {
374
331
  if (!packageManager) return "";
375
332
  return getRuntimeScriptCommand(packageManager, kind, {
@@ -471,27 +428,24 @@ async function scaffoldCreateFrameworkTemplate(opts) {
471
428
  const dependencyVersionMap = {
472
429
  "@astrojs/node": "^10.0.2",
473
430
  "@elysiajs/node": "^1.4.5",
474
- "@prisma/cli": "8.0.0-rc.2",
475
- "@prisma/cli-engine": "8.0.0-rc.2",
476
- "@prisma/composer": "0.7.0",
477
- "@prisma/composer-prisma-cloud": "0.7.0",
478
- "@prisma/orm-mongo": "8.0.0-rc.1",
479
- "@prisma/orm-postgres": "8.0.0-rc.1",
431
+ "@prisma/cli-engine": "0.2.0",
432
+ "@prisma/composer": "0.9.0",
433
+ "@prisma/composer-prisma-cloud": "0.9.0",
434
+ "@prisma/orm-mongo": "8.0.0-rc.3",
435
+ "@prisma/orm-postgres": "8.0.0-rc.3",
480
436
  "@sveltejs/adapter-node": "^5.3.2",
481
437
  "@types/node": "^25.6.2",
482
438
  alchemy: "2.0.0-beta.67",
483
439
  arktype: "^2.2.3",
484
- dotenv: "^17.4.2",
485
440
  esbuild: "^0.28.1",
486
441
  effect: "4.0.0-beta.103",
487
442
  mongodb: "^7.1.0",
488
443
  "mongodb-memory-server": "^11.1.0",
489
444
  nitro: "^3.0.260610-beta",
490
- "prisma-next": "8.0.0-rc.1",
491
445
  tsx: "^4.21.0",
492
446
  typescript: "^5.9.3"
493
447
  };
494
- const PRISMA_PLATFORM_CLI_PACKAGE = `@prisma/cli@${dependencyVersionMap["@prisma/cli"]}`;
448
+ const PRISMA_PLATFORM_CLI_PACKAGE = "prisma@next";
495
449
  function getDependencyVersion(packageName) {
496
450
  return dependencyVersionMap[packageName];
497
451
  }
@@ -533,17 +487,17 @@ function getDbPackages(provider) {
533
487
 
534
488
  //#endregion
535
489
  //#region src/tasks/install.ts
536
- function getPrismaNextScriptMap(packageManager) {
490
+ function getPrismaScriptMap(packageManager) {
491
+ const prismaCommand = (...args) => getPackageExecutionCommand(packageManager, [PRISMA_PLATFORM_CLI_PACKAGE, ...args]);
537
492
  return {
538
- "contract:emit": "prisma-next contract emit",
539
- "db:init": "prisma-next db init",
540
- "db:update": "prisma-next db update",
541
- "db:verify": "prisma-next db verify",
542
- "db:seed": packageManager === "bun" ? "bun src/prisma/seed.ts" : "tsx src/prisma/seed.ts",
543
- "migration:plan": "prisma-next migration plan",
544
- migrate: "prisma-next migrate",
545
- "migration:status": "prisma-next migration status",
546
- "migration:show": "prisma-next migration show"
493
+ "contract:emit": prismaCommand("contract", "emit"),
494
+ "db:init": prismaCommand("db", "init"),
495
+ "db:update": prismaCommand("db", "update"),
496
+ "db:verify": prismaCommand("db", "verify"),
497
+ "migration:plan": prismaCommand("migration", "plan"),
498
+ migrate: prismaCommand("migrate"),
499
+ "migration:status": prismaCommand("migration", "status"),
500
+ "migration:show": prismaCommand("migration", "show")
547
501
  };
548
502
  }
549
503
  function getComposerScriptMap(packageManager) {
@@ -597,12 +551,12 @@ async function addPackageDependency(opts) {
597
551
  await fs.writeJson(pkgJsonPath, pkgJson, { spaces: 2 });
598
552
  }
599
553
  async function writePrismaDependencies(provider, packageManager, _authoring, projectDir = process.cwd()) {
600
- const dependencies = [getDbPackages(provider), "dotenv"];
554
+ const dependencies = [getDbPackages(provider)];
601
555
  if (provider === "mongo") dependencies.push("arktype", "mongodb");
602
556
  await addPackageDependency({
603
557
  dependencies,
604
- devDependencies: ["prisma-next", "@types/node"],
605
- scripts: getPrismaNextScriptMap(packageManager),
558
+ devDependencies: ["@prisma/cli-engine", "@types/node"],
559
+ scripts: getPrismaScriptMap(packageManager),
606
560
  projectDir
607
561
  });
608
562
  }
@@ -897,9 +851,9 @@ async function ensureComposerTypeScriptOptions(projectDir) {
897
851
  await fs.writeFile(tsconfigPath, updated, "utf8");
898
852
  }
899
853
  async function emitContract(context, projectDir) {
900
- const args = getLocalPackageBinaryArgs(context.packageManager, "prisma-next", ["contract", "emit"]);
901
- if (context.verbose) log.step(getLocalPackageBinaryCommand(context.packageManager, "prisma-next", ["contract", "emit"]));
902
- await execa(args.command, args.args, {
854
+ const invocation = getPrismaCliInvocation(context.packageManager, ["contract", "emit"]);
855
+ if (context.verbose) log.step([invocation.command, ...invocation.args].join(" "));
856
+ await execa(invocation.command, invocation.args, {
903
857
  cwd: projectDir,
904
858
  stdio: context.verbose ? "inherit" : "pipe"
905
859
  });
package/dist/index.mjs CHANGED
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
- import { a as DatabaseProviderSchema, i as CreateTemplateSchema, n as AuthoringStyleSchema, o as PackageManagerSchema, r as CreateCommandInputSchema, t as runCreateCommand } from "./create-BHcAcUH1.mjs";
2
+ import { a as DatabaseProviderSchema, i as CreateTemplateSchema, n as AuthoringStyleSchema, o as PackageManagerSchema, r as CreateCommandInputSchema, t as runCreateCommand } from "./create-DbthKFmi.mjs";
3
3
  import { os } from "@orpc/server";
4
4
  import { createCli } from "trpc-cli";
5
5
  import { z } from "zod";
6
6
 
7
7
  //#region src/index.ts
8
- const CLI_VERSION = "0.4.2-pr.53.198.1";
8
+ const CLI_VERSION = "0.4.2-pr.53.200.1";
9
9
  const CreateCliInputSchema = z.tuple([z.string().trim().min(1, "Please enter a valid project name").optional().describe("Project name / directory"), CreateCommandInputSchema]);
10
10
  function normalizeCreateCliInput(input) {
11
11
  const [projectName, options] = input;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-prisma",
3
- "version": "0.4.2-pr.53.198.1",
3
+ "version": "0.4.2-pr.53.200.1",
4
4
  "private": false,
5
5
  "description": "Create Prisma 8 projects with first-party templates and great DX.",
6
6
  "homepage": "https://github.com/prisma/create-prisma",
@@ -18,7 +18,7 @@ This builds the app and starts it with Composer. PostgreSQL projects get a local
18
18
 
19
19
  The deploy script builds the framework output, provisions Prisma Postgres when selected, applies migrations, and deploys the app to Prisma Compute.
20
20
 
21
- The starter users are inserted idempotently on the first database query through the Composer service binding. `{{runScriptCommand packageManager "db:seed"}}` starts the app with Composer, seeds through its database route, and stops it again. If `DATABASE_URL` is set explicitly, the command seeds that database directly instead.
21
+ The starter users are inserted idempotently from `src/prisma/seed.ts` on the first database query through the Composer service binding.
22
22
 
23
23
  {{#if (eq provider "mongo")}}
24
24
  MongoDB is not provisioned by Composer. Set `MONGODB_URL` before running Composer locally or deploying.
@@ -11,7 +11,6 @@ allowBuilds:
11
11
  workerd: true
12
12
  minimumReleaseAgeExclude:
13
13
  - "@prisma/*"
14
- - "prisma-next"
15
14
  overrides:
16
15
  effect: "4.0.0-beta.103"
17
16
  {{/if}}
@@ -1,4 +1,3 @@
1
- import "dotenv/config";
2
1
  import { defineConfig } from "@prisma/orm-{{#if (eq provider "postgres")}}postgres{{else}}mongo{{/if}}/config";
3
2
 
4
3
  export default defineConfig({
@@ -1,8 +1,8 @@
1
- import { defineConfig } from "@prisma/cli-engine";
1
+ import { definePrismaConfig } from "@prisma/cli-engine";
2
2
 
3
3
  import orm from "./prisma-next.config.ts";
4
4
 
5
- export default defineConfig({
5
+ export default definePrismaConfig({
6
6
  orm,
7
7
  composer: {
8
8
  configPath: "./prisma-composer.config.ts",
@@ -1,97 +1,36 @@
1
- import "dotenv/config";
2
- import { spawn, type ChildProcess } from "node:child_process";
1
+ import { connectDatabase, db } from "./db.ts";
3
2
 
4
- const seedPath = {{#if (eq template "astro")}}"/api/users"{{else if (eq template "nuxt")}}"/api/users"{{else if (eq template "hono")}}"/users"{{else if (eq template "elysia")}}"/users"{{else if (eq template "nest")}}"/users"{{else}}"/"{{/if}};
3
+ const users = [
4
+ { email: "alice@prisma.io", username: "alice", name: "Alice" },
5
+ { email: "bob@prisma.io", username: "bob", name: "Bob" },
6
+ { email: "carol@prisma.io", username: "carol", name: "Carol" },
7
+ ];
5
8
 
6
- async function seedExplicitDatabase(): Promise<void> {
7
- const [{ db }, { seedStarterData }] = await Promise.all([
8
- import("./db.ts"),
9
- import("./starter-data.ts"),
10
- ]);
9
+ let pendingSeed: Promise<void> | undefined;
11
10
 
12
- try {
13
- await seedStarterData();
14
- } finally {
15
- await db.close();
16
- }
17
- }
11
+ async function runSeed(): Promise<void> {
12
+ await connectDatabase();
18
13
 
19
- function stopComposer(child: ChildProcess): void {
20
- if (child.exitCode !== null || child.pid === undefined) return;
21
- try {
22
- if (process.platform === "win32") child.kill("SIGINT");
23
- else process.kill(-child.pid, "SIGINT");
24
- } catch (error) {
25
- if (!(error instanceof Error && "code" in error && error.code === "ESRCH")) throw error;
14
+ {{#if (eq provider "mongo")}}
15
+ for (const user of users) {
16
+ const existingUser = await db.orm.users.where({ email: user.email }).first();
17
+ if (!existingUser) await db.orm.users.create(user);
26
18
  }
27
- }
28
-
29
- async function requestStarterUsers(origin: string): Promise<void> {
30
- let lastStatus = 0;
31
- for (let attempt = 0; attempt < 30; attempt += 1) {
32
- try {
33
- const response = await fetch(new URL(seedPath, origin));
34
- const body = await response.text();
35
- lastStatus = response.status;
36
- if (response.ok && ["Alice", "Bob", "Carol"].every((name) => body.includes(name))) return;
37
- } catch {
38
- // The service may still be accepting its first connection after Composer reports ready.
39
- }
40
- await new Promise((resolve) => setTimeout(resolve, 1_000));
19
+ {{else}}
20
+ for (const user of users) {
21
+ await db.orm.public.User.upsert({
22
+ create: user,
23
+ update: {},
24
+ conflictOn: { email: user.email },
25
+ });
41
26
  }
42
- throw new Error(`The app's database route did not return the starter users (HTTP ${lastStatus}).`);
27
+ {{/if}}
43
28
  }
44
29
 
45
- async function seedThroughComposer(): Promise<void> {
46
- const child = spawn("{{packageManager}}", ["run", "dev:composer"], {
47
- cwd: new URL("../..", import.meta.url),
48
- detached: process.platform !== "win32",
49
- env: process.env,
50
- stdio: ["ignore", "pipe", "pipe"],
30
+ export function seed(): Promise<void> {
31
+ pendingSeed ??= runSeed().catch((error: unknown) => {
32
+ pendingSeed = undefined;
33
+ throw error;
51
34
  });
52
-
53
- let output = "";
54
- let settled = false;
55
- const ready = new Promise<string>((resolve, reject) => {
56
- const timeout = setTimeout(() => reject(new Error("Timed out waiting for composer dev.")), 120_000);
57
- const consume = (chunk: Buffer) => {
58
- const text = chunk.toString();
59
- output = `${output}${text}`.slice(-20_000);
60
- if (!settled) process.stderr.write(text);
61
- const url = output.match(/\bapp(?::|\s+)\s+(http:\/\/(?:127\.0\.0\.1|localhost):\d+)/)?.[1];
62
- if (url && !settled) {
63
- settled = true;
64
- clearTimeout(timeout);
65
- resolve(url);
66
- }
67
- };
68
- child.stdout?.on("data", consume);
69
- child.stderr?.on("data", consume);
70
- child.once("error", (error) => {
71
- clearTimeout(timeout);
72
- reject(error);
73
- });
74
- child.once("exit", (code) => {
75
- if (settled) return;
76
- clearTimeout(timeout);
77
- reject(new Error(`composer dev exited before the app was ready (code ${String(code)}).`));
78
- });
79
- });
80
-
81
- const stopOnSignal = () => stopComposer(child);
82
- process.once("SIGINT", stopOnSignal);
83
- process.once("SIGTERM", stopOnSignal);
84
- try {
85
- const origin = await ready;
86
- await requestStarterUsers(origin);
87
- } finally {
88
- process.removeListener("SIGINT", stopOnSignal);
89
- process.removeListener("SIGTERM", stopOnSignal);
90
- stopComposer(child);
91
- }
35
+ return pendingSeed;
92
36
  }
93
-
94
- if (process.env.DATABASE_URL) await seedExplicitDatabase();
95
- else await seedThroughComposer();
96
-
97
- console.log("Starter users are ready.");
@@ -1,12 +1,10 @@
1
- import "dotenv/config";
2
-
3
1
  import { db } from "./db.ts";
4
- import { seedStarterData } from "./starter-data.ts";
2
+ import { seed } from "./seed.ts";
5
3
 
6
4
  export { db };
7
5
 
8
6
  export async function listUsers(limit = 10) {
9
- await seedStarterData();
7
+ await seed();
10
8
  {{#if (eq provider "mongo")}}
11
9
  const users = [];
12
10
 
@@ -1,6 +1,3 @@
1
- {{#if (requiresDotenvConfigImport packageManager)}}
2
- import "dotenv/config";
3
- {{/if}}
4
1
  import { node } from "@elysiajs/node";
5
2
  import { Elysia } from "elysia";
6
3
 
@@ -1,6 +1,3 @@
1
- {{#if (requiresDotenvConfigImport packageManager)}}
2
- import "dotenv/config";
3
- {{/if}}
4
1
  import { serve } from "@hono/node-server";
5
2
  import { Hono } from "hono";
6
3
 
@@ -1,5 +1,3 @@
1
- import "dotenv/config";
2
-
3
1
  import { createServer } from "node:http";
4
2
 
5
3
  import { listUsers } from "./prisma/users";
@@ -1,7 +1,4 @@
1
1
  import "reflect-metadata";
2
- {{#if (requiresDotenvConfigImport packageManager)}}
3
- import "dotenv/config";
4
- {{/if}}
5
2
 
6
3
  import { NestFactory } from "@nestjs/core";
7
4
 
@@ -1,36 +0,0 @@
1
- import { connectDatabase, db } from "./db.ts";
2
-
3
- const starterUsers = [
4
- { email: "alice@prisma.io", username: "alice", name: "Alice" },
5
- { email: "bob@prisma.io", username: "bob", name: "Bob" },
6
- { email: "carol@prisma.io", username: "carol", name: "Carol" },
7
- ];
8
-
9
- let seed: Promise<void> | undefined;
10
-
11
- async function seedOnce(): Promise<void> {
12
- await connectDatabase();
13
-
14
- {{#if (eq provider "mongo")}}
15
- for (const user of starterUsers) {
16
- const existingUser = await db.orm.users.where({ email: user.email }).first();
17
- if (!existingUser) await db.orm.users.create(user);
18
- }
19
- {{else}}
20
- for (const user of starterUsers) {
21
- await db.orm.public.User.upsert({
22
- create: user,
23
- update: {},
24
- conflictOn: { email: user.email },
25
- });
26
- }
27
- {{/if}}
28
- }
29
-
30
- export function seedStarterData(): Promise<void> {
31
- seed ??= seedOnce().catch((error: unknown) => {
32
- seed = undefined;
33
- throw error;
34
- });
35
- return seed;
36
- }