create-prisma 0.4.2-pr.39.99.1 → 0.4.2-pr.40.103.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.
Files changed (31) hide show
  1. package/README.md +18 -3
  2. package/dist/cli.mjs +1 -1
  3. package/dist/{create-BOeaiXBK.mjs → create-CHVnIodq.mjs} +156 -153
  4. package/dist/index.d.mts +2 -2
  5. package/dist/index.mjs +2 -2
  6. package/package.json +2 -2
  7. package/templates/create/_shared/prisma/seed.ts.hbs +3 -4
  8. package/templates/create/astro/README.md.hbs +23 -40
  9. package/templates/create/astro/src/lib/prisma.ts.hbs +8 -6
  10. package/templates/create/astro/src/pages/index.astro.hbs +1 -1
  11. package/templates/create/elysia/README.md.hbs +20 -38
  12. package/templates/create/elysia/src/lib/prisma.ts.hbs +8 -6
  13. package/templates/create/hono/README.md.hbs +20 -38
  14. package/templates/create/hono/src/lib/prisma.ts.hbs +8 -6
  15. package/templates/create/minimal/README.md.hbs +17 -37
  16. package/templates/create/minimal/src/index.ts.hbs +1 -0
  17. package/templates/create/minimal/src/lib/prisma.ts.hbs +8 -6
  18. package/templates/create/nest/README.md.hbs +20 -38
  19. package/templates/create/nest/src/lib/prisma.ts.hbs +8 -6
  20. package/templates/create/next/README.md.hbs +21 -39
  21. package/templates/create/next/src/app/page.tsx.hbs +1 -1
  22. package/templates/create/next/src/lib/prisma.ts.hbs +8 -6
  23. package/templates/create/nuxt/README.md.hbs +24 -41
  24. package/templates/create/nuxt/app/pages/index.vue.hbs +2 -1
  25. package/templates/create/nuxt/server/utils/prisma.ts.hbs +8 -6
  26. package/templates/create/svelte/README.md.hbs +24 -41
  27. package/templates/create/svelte/src/lib/server/prisma.ts.hbs +8 -6
  28. package/templates/create/svelte/src/routes/+page.svelte.hbs +1 -2
  29. package/templates/create/tanstack-start/README.md.hbs +23 -40
  30. package/templates/create/tanstack-start/src/lib/prisma.server.ts.hbs +8 -6
  31. package/templates/create/tanstack-start/src/routes/index.tsx.hbs +1 -1
package/README.md CHANGED
@@ -11,13 +11,13 @@ Scaffold a new app with Prisma Next already wired up.
11
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
12
  - writes a template-specific Prisma Next runtime helper
13
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` / `db:reset` plus `scripts/mongo.mjs` when you opt into local MongoDB (`mongodb-memory-server`, each project gets its own port)
14
+ - adds `db:up` / `db:down` and `docker-compose.yml` for default MongoDB projects
15
15
  - creates or updates `.env` with `DATABASE_URL`
16
16
  - can install dependencies and run `prisma-next contract emit`
17
17
 
18
18
  `db:init`, migrations, and seeding are never run automatically. PostgreSQL projects show
19
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. The generated `README.md` has a numbered `## Getting Started` section that lists the exact commands to run.
20
+ plan/apply path for initial schema setup.
21
21
 
22
22
  ## Quick Start
23
23
 
@@ -93,6 +93,18 @@ Use Prisma Postgres auto-provisioning:
93
93
  create-prisma --name my-app --template nest --provider postgres --prisma-postgres
94
94
  ```
95
95
 
96
+ Target a specific Prisma Next release (useful for regression / bisect work):
97
+
98
+ ```bash
99
+ create-prisma --name 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 --name my-app --template hono --prisma-next-version pkg-pr-new:bad6795
106
+ ```
107
+
96
108
  ## Supported Templates
97
109
 
98
110
  - `minimal` - script-first Prisma Next starter with no web framework
@@ -130,7 +142,10 @@ create-prisma --name my-app --template nest --provider postgres --prisma-postgre
130
142
  - `--no-install` scaffold only
131
143
  - `--no-emit` skip `prisma-next contract emit`
132
144
  - `--prisma-postgres` provision Prisma Postgres for PostgreSQL
133
- - `--local-mongo` scaffold the local `mongodb-memory-server` helper for MongoDB (default with `--yes`; pass `--no-local-mongo` to opt out)
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>`.
134
149
  - `--force` allow scaffolding into a non-empty directory
135
150
  - `--verbose` print full command output
136
151
 
package/dist/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import "./create-BOeaiXBK.mjs";
2
+ import "./create-CHVnIodq.mjs";
3
3
  import { createCreatePrismaCli } from "./index.mjs";
4
4
 
5
5
  //#region src/cli.ts
@@ -12,6 +12,88 @@ import { z } from "zod";
12
12
  import { execa } from "execa";
13
13
  import { styleText } from "node:util";
14
14
 
15
+ //#region src/utils/runtime.ts
16
+ function usesNodeStyleRuntime(packageManager) {
17
+ return packageManager !== void 0 && packageManager !== "bun" && packageManager !== "deno";
18
+ }
19
+ function requiresDotenvConfigImport(packageManager) {
20
+ return usesNodeStyleRuntime(packageManager);
21
+ }
22
+
23
+ //#endregion
24
+ //#region src/constants/dependencies.ts
25
+ const dependencyVersionMap = {
26
+ "@elysiajs/node": "^1.4.5",
27
+ "@types/node": "^25.6.2",
28
+ dotenv: "^17.4.2",
29
+ "mongodb-memory-server": "^11.1.0",
30
+ tsx: "^4.21.0"
31
+ };
32
+ const PRISMA_NEXT_DEFAULT_VERSION = "latest";
33
+ const PKG_PR_NEW_PREFIX = "pkg-pr-new:";
34
+ const PKG_PR_NEW_BASE_URL = "https://pkg.pr.new/prisma/prisma-next";
35
+ const DEFAULT_PRISMA_NEXT_SPEC = {
36
+ kind: "npm",
37
+ spec: PRISMA_NEXT_DEFAULT_VERSION
38
+ };
39
+ function parsePrismaNextVersionSpec(input) {
40
+ if (input === void 0) return DEFAULT_PRISMA_NEXT_SPEC;
41
+ const trimmed = input.trim();
42
+ if (trimmed.length === 0) return DEFAULT_PRISMA_NEXT_SPEC;
43
+ if (trimmed.startsWith(PKG_PR_NEW_PREFIX)) {
44
+ const ref = trimmed.slice(11).trim();
45
+ if (ref.length === 0) throw new Error(`Invalid --prisma-next-version value: '${input}'. Expected 'pkg-pr-new:<sha|branch|pr-number>'.`);
46
+ return {
47
+ kind: "pkg-pr-new",
48
+ ref
49
+ };
50
+ }
51
+ return {
52
+ kind: "npm",
53
+ spec: trimmed
54
+ };
55
+ }
56
+ function isPrismaNextPackage(packageName) {
57
+ return packageName === "prisma-next" || packageName.startsWith("@prisma-next/");
58
+ }
59
+ function getPrismaNextPackageSpecifier(packageName, spec = DEFAULT_PRISMA_NEXT_SPEC) {
60
+ if (spec.kind === "pkg-pr-new") return `${PKG_PR_NEW_BASE_URL}/${packageName}@${spec.ref}`;
61
+ return `${packageName}@${spec.spec}`;
62
+ }
63
+ function getDependencyVersion(packageName, prismaNextSpec = DEFAULT_PRISMA_NEXT_SPEC) {
64
+ if (isPrismaNextPackage(packageName)) {
65
+ if (prismaNextSpec.kind === "pkg-pr-new") return `${PKG_PR_NEW_BASE_URL}/${packageName}@${prismaNextSpec.ref}`;
66
+ return prismaNextSpec.spec;
67
+ }
68
+ return dependencyVersionMap[packageName];
69
+ }
70
+ function usesViteDevServer(template) {
71
+ return template === "astro" || template === "nuxt" || template === "svelte" || template === "tanstack-start";
72
+ }
73
+ function getCreateTemplateDependencies(template, packageManager) {
74
+ const targets = [];
75
+ if (usesViteDevServer(template)) targets.push({
76
+ packageJsonPath: "package.json",
77
+ dependencies: [],
78
+ devDependencies: ["@prisma-next/vite-plugin-contract-emit"]
79
+ });
80
+ if (template === "minimal" || template === "hono" || template === "elysia" || template === "nest") {
81
+ const runtimeDevDependencies = usesNodeStyleRuntime(packageManager) ? ["tsx"] : [];
82
+ if (template === "elysia" && packageManager !== "deno") targets.push({
83
+ packageJsonPath: "package.json",
84
+ dependencies: ["@elysiajs/node"],
85
+ devDependencies: ["@types/node", ...runtimeDevDependencies]
86
+ });
87
+ else if (runtimeDevDependencies.length > 0) targets.push({
88
+ packageJsonPath: "package.json",
89
+ dependencies: [],
90
+ devDependencies: runtimeDevDependencies
91
+ });
92
+ }
93
+ return targets;
94
+ }
95
+
96
+ //#endregion
15
97
  //#region src/telemetry/client.ts
16
98
  const TELEMETRY_API_KEY = "";
17
99
  const TELEMETRY_HOST = "https://us.i.posthog.com";
@@ -40,7 +122,7 @@ async function getAnonymousId() {
40
122
  }
41
123
  function getCommonProperties() {
42
124
  return {
43
- "cli-version": "0.4.2-pr.39.99.1",
125
+ "cli-version": "0.4.2-pr.40.103.1",
44
126
  "node-version": process.version,
45
127
  platform: process.platform,
46
128
  arch: process.arch
@@ -78,6 +160,16 @@ async function trackCliTelemetry(event, properties) {
78
160
 
79
161
  //#endregion
80
162
  //#region src/telemetry/create.ts
163
+ function classifyPrismaNextSpec(spec) {
164
+ if (!spec || spec === DEFAULT_PRISMA_NEXT_SPEC) return "default";
165
+ if (spec.kind === "pkg-pr-new") return "pkg-pr-new";
166
+ if (spec.spec === PRISMA_NEXT_DEFAULT_VERSION) return "default";
167
+ return /^[0-9]/.test(spec.spec) ? "npm-version" : "npm-tag";
168
+ }
169
+ function getPrismaNextVersionSpecString(spec) {
170
+ if (!spec) return null;
171
+ return spec.kind === "pkg-pr-new" ? `pkg-pr-new:${spec.ref}` : spec.spec;
172
+ }
81
173
  const CREATE_PRISMA_NEXT_COMPLETED_EVENT = "cli:create_prisma_next_command_completed";
82
174
  const CREATE_PRISMA_NEXT_FAILED_EVENT = "cli:create_prisma_next_command_failed";
83
175
  function getTargetDirectoryState(context) {
@@ -86,6 +178,7 @@ function getTargetDirectoryState(context) {
86
178
  return "non_empty_directory";
87
179
  }
88
180
  function getBaseCreateProperties(input, context) {
181
+ const resolvedPrismaNextSpec = context?.prismaSetupContext.prismaNextSpec;
89
182
  return {
90
183
  command: "create",
91
184
  "uses-defaults": input.yes === true,
@@ -98,7 +191,9 @@ function getBaseCreateProperties(input, context) {
98
191
  "should-install": context?.prismaSetupContext.shouldInstall ?? input.install ?? null,
99
192
  "should-emit": context?.prismaSetupContext.shouldEmit ?? input.emit ?? null,
100
193
  "uses-prisma-postgres": context?.prismaSetupContext.shouldUsePrismaPostgres ?? input.prismaPostgres ?? null,
101
- "target-directory-state": context ? getTargetDirectoryState(context) : null
194
+ "target-directory-state": context ? getTargetDirectoryState(context) : null,
195
+ "prisma-next-version-kind": classifyPrismaNextSpec(resolvedPrismaNextSpec),
196
+ "prisma-next-version-spec": getPrismaNextVersionSpecString(resolvedPrismaNextSpec) ?? input.prismaNextVersion ?? null
102
197
  };
103
198
  }
104
199
  function getErrorName(error) {
@@ -174,10 +269,10 @@ const PrismaSetupOptionsSchema = z.object({
174
269
  authoring: AuthoringStyleSchema.optional().describe("Contract authoring style"),
175
270
  packageManager: PackageManagerSchema.optional().describe("Package manager used for dependency installation"),
176
271
  prismaPostgres: z.boolean().optional().describe("Provision Prisma Postgres with create-db when target is postgres"),
177
- localMongo: z.boolean().optional().describe("Scaffold an in-memory MongoDB replica set (mongodb-memory-server) when target is mongo"),
178
272
  databaseUrl: DatabaseUrlSchema.optional().describe("DATABASE_URL value"),
179
273
  install: z.boolean().optional().describe("Install dependencies with selected package manager"),
180
- emit: z.boolean().optional().describe("Emit Prisma Next contract artifacts after scaffolding")
274
+ emit: z.boolean().optional().describe("Emit Prisma Next contract artifacts after scaffolding"),
275
+ prismaNextVersion: z.string().trim().min(1).optional().describe("Prisma Next version, npm dist-tag, or 'pkg-pr-new:<sha|branch|pr>' (default: latest)")
181
276
  });
182
277
  const PrismaSetupCommandInputSchema = CommonCommandOptionsSchema.extend(PrismaSetupOptionsSchema.shape);
183
278
  const CreateScaffoldOptionsSchema = z.object({
@@ -419,15 +514,6 @@ function getLocalPackageBinaryCommand(packageManager, binaryName, binaryArgs) {
419
514
  return [execution.command, ...execution.args].join(" ");
420
515
  }
421
516
 
422
- //#endregion
423
- //#region src/utils/runtime.ts
424
- function usesNodeStyleRuntime(packageManager) {
425
- return packageManager !== void 0 && packageManager !== "bun" && packageManager !== "deno";
426
- }
427
- function requiresDotenvConfigImport(packageManager) {
428
- return usesNodeStyleRuntime(packageManager);
429
- }
430
-
431
517
  //#endregion
432
518
  //#region src/templates/shared.ts
433
519
  function getOptionalHashString(hash, key) {
@@ -513,21 +599,20 @@ function getCreateTemplateDir(template) {
513
599
  function getCreateSharedTemplateDir() {
514
600
  return resolveTemplatesDir("templates/create/_shared");
515
601
  }
516
- function createTemplateContext(projectName, template, provider, authoring, packageManager, useLocalMongo) {
602
+ function createTemplateContext(projectName, template, provider, authoring, packageManager) {
517
603
  return {
518
604
  projectName,
519
605
  template,
520
606
  provider,
521
607
  authoring,
522
- packageManager,
523
- useLocalMongo
608
+ packageManager
524
609
  };
525
610
  }
526
611
  async function scaffoldCreateTemplate(opts) {
527
- const { projectDir, projectName, template, provider, authoring, packageManager, useLocalMongo } = opts;
612
+ const { projectDir, projectName, template, provider, authoring, packageManager } = opts;
528
613
  const templateRoot = getCreateTemplateDir(template);
529
614
  const sharedTemplateRoot = getCreateSharedTemplateDir();
530
- const context = createTemplateContext(projectName, template, provider, authoring, packageManager, useLocalMongo);
615
+ const context = createTemplateContext(projectName, template, provider, authoring, packageManager);
531
616
  await renderTemplateTree({
532
617
  templateRoot: sharedTemplateRoot,
533
618
  outputDir: projectDir,
@@ -540,52 +625,6 @@ async function scaffoldCreateTemplate(opts) {
540
625
  });
541
626
  }
542
627
 
543
- //#endregion
544
- //#region src/constants/dependencies.ts
545
- const dependencyVersionMap = {
546
- "@elysiajs/node": "^1.4.5",
547
- "@types/node": "^25.6.2",
548
- dotenv: "^17.4.2",
549
- "mongodb-memory-server": "^11.1.0",
550
- tsx: "^4.21.0"
551
- };
552
- const PRISMA_NEXT_PACKAGE_VERSION = "latest";
553
- function isPrismaNextPackage(packageName) {
554
- return packageName === "prisma-next" || packageName.startsWith("@prisma-next/");
555
- }
556
- function getPrismaNextPackageSpecifier(packageName) {
557
- return `${packageName}@${PRISMA_NEXT_PACKAGE_VERSION}`;
558
- }
559
- function getDependencyVersion(packageName) {
560
- if (isPrismaNextPackage(packageName)) return PRISMA_NEXT_PACKAGE_VERSION;
561
- return dependencyVersionMap[packageName];
562
- }
563
- function usesViteDevServer(template) {
564
- return template === "astro" || template === "nuxt" || template === "svelte" || template === "tanstack-start";
565
- }
566
- function getCreateTemplateDependencies(template, packageManager) {
567
- const targets = [];
568
- if (usesViteDevServer(template)) targets.push({
569
- packageJsonPath: "package.json",
570
- dependencies: [],
571
- devDependencies: ["@prisma-next/vite-plugin-contract-emit"]
572
- });
573
- if (template === "minimal" || template === "hono" || template === "elysia" || template === "nest") {
574
- const runtimeDevDependencies = usesNodeStyleRuntime(packageManager) ? ["tsx"] : [];
575
- if (template === "elysia" && packageManager !== "deno") targets.push({
576
- packageJsonPath: "package.json",
577
- dependencies: ["@elysiajs/node"],
578
- devDependencies: ["@types/node", ...runtimeDevDependencies]
579
- });
580
- else if (runtimeDevDependencies.length > 0) targets.push({
581
- packageJsonPath: "package.json",
582
- dependencies: [],
583
- devDependencies: runtimeDevDependencies
584
- });
585
- }
586
- return targets;
587
- }
588
-
589
628
  //#endregion
590
629
  //#region src/constants/db-packages.ts
591
630
  function getDbPackages(provider, _packageManager) {
@@ -683,7 +722,7 @@ function getOrmTypePackages(provider) {
683
722
  return ["@prisma-next/sql-orm-client"];
684
723
  }
685
724
  async function addPackageDependency(opts) {
686
- const { dependencies = [], devDependencies = [], customDependencies = {}, scripts = {}, scriptMode, projectDir } = opts;
725
+ const { dependencies = [], devDependencies = [], customDependencies = {}, scripts = {}, scriptMode, projectDir, prismaNextSpec = DEFAULT_PRISMA_NEXT_SPEC } = opts;
687
726
  const pkgJsonPath = path.join(projectDir, "package.json");
688
727
  if (!await fs.pathExists(pkgJsonPath)) throw new Error(`No package.json found in ${projectDir}. Run this command inside an existing JavaScript/TypeScript project.`);
689
728
  const pkgJson = await fs.readJson(pkgJsonPath);
@@ -691,12 +730,12 @@ async function addPackageDependency(opts) {
691
730
  if (!pkgJson.devDependencies) pkgJson.devDependencies = {};
692
731
  if (!pkgJson.scripts) pkgJson.scripts = {};
693
732
  for (const pkgName of unique(dependencies)) {
694
- const version = getDependencyVersion(pkgName);
733
+ const version = getDependencyVersion(pkgName, prismaNextSpec);
695
734
  if (version) pkgJson.dependencies[pkgName] = version;
696
735
  else console.warn(`Warning: Dependency ${pkgName} not found in version map.`);
697
736
  }
698
737
  for (const pkgName of unique(devDependencies)) {
699
- const version = getDependencyVersion(pkgName);
738
+ const version = getDependencyVersion(pkgName, prismaNextSpec);
700
739
  if (version) pkgJson.devDependencies[pkgName] = version;
701
740
  else console.warn(`Warning: Dev dependency ${pkgName} not found in version map.`);
702
741
  }
@@ -712,7 +751,7 @@ async function addPackageDependency(opts) {
712
751
  pkgJson.devDependencies = sortRecord(pkgJson.devDependencies);
713
752
  await fs.writeJson(pkgJsonPath, pkgJson, { spaces: 2 });
714
753
  }
715
- async function writePrismaDependencies(provider, packageManager, authoring, projectDir = process.cwd()) {
754
+ async function writePrismaDependencies(provider, packageManager, authoring, projectDir = process.cwd(), prismaNextSpec = DEFAULT_PRISMA_NEXT_SPEC) {
716
755
  const dependencies = [getDbPackages(provider, packageManager), "dotenv"];
717
756
  const devDependencies = [
718
757
  "prisma-next",
@@ -727,11 +766,12 @@ async function writePrismaDependencies(provider, packageManager, authoring, proj
727
766
  dependencies,
728
767
  devDependencies,
729
768
  scripts: getPrismaNextScriptMap(packageManager),
730
- projectDir
769
+ projectDir,
770
+ prismaNextSpec
731
771
  });
732
772
  }
733
773
  async function writeCreateTemplateDependencies(opts) {
734
- const { template, packageManager, projectDir = process.cwd() } = opts;
774
+ const { template, packageManager, projectDir = process.cwd(), prismaNextSpec = DEFAULT_PRISMA_NEXT_SPEC } = opts;
735
775
  const targets = getCreateTemplateDependencies(template, packageManager);
736
776
  for (const dependencyTarget of targets) {
737
777
  const targetDirectory = path.join(projectDir, path.dirname(dependencyTarget.packageJsonPath));
@@ -739,7 +779,8 @@ async function writeCreateTemplateDependencies(opts) {
739
779
  dependencies: dependencyTarget.dependencies,
740
780
  devDependencies: dependencyTarget.devDependencies,
741
781
  customDependencies: dependencyTarget.customDependencies,
742
- projectDir: targetDirectory
782
+ projectDir: targetDirectory,
783
+ prismaNextSpec
743
784
  });
744
785
  }
745
786
  }
@@ -817,10 +858,6 @@ const DEFAULT_INSTALL = true;
817
858
  const DEFAULT_EMIT = true;
818
859
  const DEFAULT_INTERACTIVE_PRISMA_POSTGRES = true;
819
860
  const DEFAULT_AUTOMATED_PRISMA_POSTGRES = false;
820
- const DEFAULT_INTERACTIVE_LOCAL_MONGO = true;
821
- const DEFAULT_AUTOMATED_LOCAL_MONGO = true;
822
- const LOCAL_MONGO_PORT_BASE = 27018;
823
- const LOCAL_MONGO_PORT_RANGE = 1e3;
824
861
  const MONGO_MEMORY_SERVER_SCRIPT = `import { spawn } from "node:child_process";
825
862
  import { closeSync, existsSync, mkdirSync, openSync, readFileSync, rmSync, writeFileSync } from "node:fs";
826
863
  import path from "node:path";
@@ -877,8 +914,7 @@ function getChildCommand() {
877
914
  async function runServer() {
878
915
  mkdirSync(dbPath, { recursive: true });
879
916
  const config = getMongoConfig();
880
- const specifier = process.versions.deno ? "npm:mongodb-memory-server" : "mongodb-memory-server";
881
- const memoryServer = await import(specifier);
917
+ const memoryServer = await import("mongodb-memory-server");
882
918
  const { MongoMemoryReplSet } = memoryServer.default ?? memoryServer;
883
919
  const replSet = await MongoMemoryReplSet.create({
884
920
  replSet: { name: config.replSetName, count: 1 },
@@ -892,8 +928,6 @@ async function runServer() {
892
928
  };
893
929
  process.on("SIGINT", shutdown);
894
930
  process.on("SIGTERM", shutdown);
895
- // Keep the event loop alive: Deno doesn't ref signal listeners.
896
- await new Promise(() => {});
897
931
  }
898
932
 
899
933
  async function up() {
@@ -1085,19 +1119,6 @@ async function promptForPrismaPostgres() {
1085
1119
  }
1086
1120
  return Boolean(shouldUsePrismaPostgres);
1087
1121
  }
1088
- async function promptForLocalMongo() {
1089
- const useLocalMongo = await confirm({
1090
- message: "Run a local MongoDB for development?",
1091
- active: "Yes, start an in-memory replica set with mongodb-memory-server",
1092
- inactive: "No, I'll set DATABASE_URL myself",
1093
- initialValue: DEFAULT_INTERACTIVE_LOCAL_MONGO
1094
- });
1095
- if (isCancel(useLocalMongo)) {
1096
- cancel("Operation cancelled.");
1097
- return;
1098
- }
1099
- return Boolean(useLocalMongo);
1100
- }
1101
1122
  function getPackageManagerHint(option, detected) {
1102
1123
  const hint = {
1103
1124
  npm: "Node.js default",
@@ -1171,29 +1192,26 @@ async function collectPrismaSetupContext(input, options = {}) {
1171
1192
  const useDefaults = input.yes === true;
1172
1193
  const verbose = input.verbose === true;
1173
1194
  const shouldEmit = input.emit ?? DEFAULT_EMIT;
1195
+ let prismaNextSpec;
1196
+ try {
1197
+ prismaNextSpec = parsePrismaNextVersionSpec(input.prismaNextVersion);
1198
+ } catch (error) {
1199
+ cancel(error instanceof Error ? error.message : String(error));
1200
+ return;
1201
+ }
1174
1202
  const databaseProvider = input.provider ?? (useDefaults ? DEFAULT_DATABASE_PROVIDER : await promptForDatabaseProvider());
1175
1203
  if (!databaseProvider) return;
1176
1204
  const databaseUrl = input.databaseUrl;
1177
- if (input.prismaPostgres === true && databaseProvider !== "postgres") {
1205
+ const shouldUsePrismaPostgres = input.prismaPostgres ?? (databaseProvider === "postgres" && !databaseUrl && !useDefaults ? await promptForPrismaPostgres() : DEFAULT_AUTOMATED_PRISMA_POSTGRES);
1206
+ if (shouldUsePrismaPostgres === void 0) return;
1207
+ if (shouldUsePrismaPostgres && databaseProvider !== "postgres") {
1178
1208
  cancel("--prisma-postgres is only supported with --provider postgres.");
1179
1209
  return;
1180
1210
  }
1181
- if (input.localMongo === true && databaseProvider !== "mongo") {
1182
- cancel("--local-mongo is only supported with --provider mongo.");
1183
- return;
1184
- }
1185
- if (input.prismaPostgres === true && databaseUrl) {
1211
+ if (shouldUsePrismaPostgres && databaseUrl) {
1186
1212
  cancel("Use either --database-url or --prisma-postgres, not both.");
1187
1213
  return;
1188
1214
  }
1189
- if (input.localMongo === true && databaseUrl) {
1190
- cancel("Use either --database-url or --local-mongo, not both.");
1191
- return;
1192
- }
1193
- const shouldUsePrismaPostgres = databaseProvider === "postgres" && !databaseUrl ? input.prismaPostgres ?? (useDefaults ? DEFAULT_AUTOMATED_PRISMA_POSTGRES : await promptForPrismaPostgres()) : false;
1194
- if (shouldUsePrismaPostgres === void 0) return;
1195
- const useLocalMongo = databaseProvider === "mongo" && !databaseUrl ? input.localMongo ?? (useDefaults ? DEFAULT_AUTOMATED_LOCAL_MONGO : await promptForLocalMongo()) : false;
1196
- if (useLocalMongo === void 0) return;
1197
1215
  const authoring = input.authoring ?? (useDefaults ? DEFAULT_AUTHORING : await promptForAuthoringStyle());
1198
1216
  if (!authoring) return;
1199
1217
  const detectedPackageManager = await detectPackageManager(projectDir);
@@ -1209,26 +1227,15 @@ async function collectPrismaSetupContext(input, options = {}) {
1209
1227
  authoring,
1210
1228
  databaseUrl,
1211
1229
  shouldUsePrismaPostgres,
1212
- useLocalMongo,
1213
1230
  packageManager,
1214
- shouldInstall
1231
+ shouldInstall,
1232
+ prismaNextSpec
1215
1233
  };
1216
1234
  }
1217
- function hashStringToOffset(value, range) {
1218
- let hash = 0;
1219
- for (let i = 0; i < value.length; i++) hash = hash * 31 + value.charCodeAt(i) | 0;
1220
- return Math.abs(hash) % range;
1221
- }
1222
- function sanitizeMongoDbName(value) {
1223
- return value.toLowerCase().replace(/[^a-z0-9_-]+/g, "_").replace(/^[_-]+|[_-]+$/g, "") || "app";
1224
- }
1225
- function getLocalMongoDatabaseUrl(projectName) {
1226
- return `mongodb://localhost:${LOCAL_MONGO_PORT_BASE + hashStringToOffset(projectName, LOCAL_MONGO_PORT_RANGE)}/${sanitizeMongoDbName(projectName)}?replicaSet=rs0&directConnection=true`;
1227
- }
1228
- function getDefaultDatabaseUrl(provider, opts) {
1235
+ function getDefaultDatabaseUrl(provider) {
1229
1236
  switch (provider) {
1230
1237
  case "postgres": return "postgresql://user:password@localhost:5432/mydb";
1231
- case "mongo": return opts.useLocalMongo ? getLocalMongoDatabaseUrl(opts.projectName) : "mongodb://user:password@localhost:27017/mydb?replicaSet=rs0&directConnection=true";
1238
+ case "mongo": return "mongodb://localhost:27017/mydb?replicaSet=rs0&directConnection=true";
1232
1239
  default: {
1233
1240
  const exhaustiveCheck = provider;
1234
1241
  throw new Error(`Unsupported Prisma Next target: ${String(exhaustiveCheck)}`);
@@ -1331,7 +1338,7 @@ async function ensureMongoMemoryServerDevDependency(projectDir) {
1331
1338
  await fs.writeJson(packageJsonPath, packageJson, { spaces: 2 });
1332
1339
  }
1333
1340
  async function writeMongoLocalHelpersForContext(context, projectDir) {
1334
- if (!context.useLocalMongo) return true;
1341
+ if (context.databaseProvider !== "mongo" || context.databaseUrl) return true;
1335
1342
  try {
1336
1343
  await ensureMongoMemoryServerScript(projectDir);
1337
1344
  await ensureMongoMemoryServerDevDependency(projectDir);
@@ -1361,10 +1368,7 @@ async function ensureRequiredPrismaFiles(projectDir) {
1361
1368
  async function finalizePrismaFiles(options) {
1362
1369
  const projectDir = options.projectDir ?? process.cwd();
1363
1370
  await ensureRequiredPrismaFiles(projectDir);
1364
- await ensureEnvVarInEnv(projectDir, "DATABASE_URL", options.databaseUrl ?? getDefaultDatabaseUrl(options.provider, {
1365
- projectName: path.basename(projectDir),
1366
- useLocalMongo: options.useLocalMongo
1367
- }), {
1371
+ await ensureEnvVarInEnv(projectDir, "DATABASE_URL", options.databaseUrl ?? getDefaultDatabaseUrl(options.provider), {
1368
1372
  mode: options.databaseUrl ? "upsert" : "keep-existing",
1369
1373
  comment: "Added by create-prisma"
1370
1374
  });
@@ -1398,37 +1402,37 @@ async function provisionPrismaPostgresIfNeeded(context, projectDir) {
1398
1402
  }
1399
1403
  async function writeDependenciesForContext(context, projectDir) {
1400
1404
  try {
1401
- await writePrismaDependencies(context.databaseProvider, context.packageManager, context.authoring, projectDir);
1405
+ await writePrismaDependencies(context.databaseProvider, context.packageManager, context.authoring, projectDir, context.prismaNextSpec);
1402
1406
  return true;
1403
1407
  } catch (error) {
1404
1408
  cancel(getCommandErrorMessage(error));
1405
1409
  return false;
1406
1410
  }
1407
1411
  }
1408
- function getPrismaNextCliPackageSpecifier() {
1409
- return getPrismaNextPackageSpecifier("prisma-next");
1412
+ function getPrismaNextCliPackageSpecifier(prismaNextSpec = DEFAULT_PRISMA_NEXT_SPEC) {
1413
+ return getPrismaNextPackageSpecifier("prisma-next", prismaNextSpec);
1410
1414
  }
1411
1415
  function getPrismaNextInitTarget(provider) {
1412
1416
  return provider === "mongo" ? "mongodb" : "postgres";
1413
1417
  }
1414
- function getPrismaNextInitCliArgs(packageManager, prismaNextArgs) {
1418
+ function getPrismaNextInitCliArgs(packageManager, prismaNextArgs, prismaNextSpec = DEFAULT_PRISMA_NEXT_SPEC) {
1415
1419
  if (packageManager === "npm") return {
1416
1420
  command: "npx",
1417
1421
  args: [
1418
1422
  "--yes",
1419
- getPrismaNextCliPackageSpecifier(),
1423
+ getPrismaNextCliPackageSpecifier(prismaNextSpec),
1420
1424
  "init",
1421
1425
  ...prismaNextArgs
1422
1426
  ]
1423
1427
  };
1424
1428
  return getPackageExecutionArgs(packageManager, [
1425
- getPrismaNextCliPackageSpecifier(),
1429
+ getPrismaNextCliPackageSpecifier(prismaNextSpec),
1426
1430
  "init",
1427
1431
  ...prismaNextArgs
1428
1432
  ]);
1429
1433
  }
1430
- function getPrismaNextInitCliCommand(packageManager, prismaNextArgs) {
1431
- const execution = getPrismaNextInitCliArgs(packageManager, prismaNextArgs);
1434
+ function getPrismaNextInitCliCommand(packageManager, prismaNextArgs, prismaNextSpec = DEFAULT_PRISMA_NEXT_SPEC) {
1435
+ const execution = getPrismaNextInitCliArgs(packageManager, prismaNextArgs, prismaNextSpec);
1432
1436
  return [execution.command, ...execution.args].join(" ");
1433
1437
  }
1434
1438
  async function runPrismaNextInitForContext(context, projectDir) {
@@ -1443,10 +1447,10 @@ async function runPrismaNextInitForContext(context, projectDir) {
1443
1447
  getContractPath(context.authoring),
1444
1448
  "--no-install"
1445
1449
  ];
1446
- const initCommand = getPrismaNextInitCliCommand(context.packageManager, initArgs);
1450
+ const initCommand = getPrismaNextInitCliCommand(context.packageManager, initArgs, context.prismaNextSpec);
1447
1451
  if (context.verbose) log.step(`Running ${initCommand}`);
1448
1452
  try {
1449
- const initExecution = getPrismaNextInitCliArgs(context.packageManager, initArgs);
1453
+ const initExecution = getPrismaNextInitCliArgs(context.packageManager, initArgs, context.prismaNextSpec);
1450
1454
  await execa(initExecution.command, initExecution.args, {
1451
1455
  cwd: projectDir,
1452
1456
  stdio: context.verbose ? "inherit" : "pipe",
@@ -1482,7 +1486,6 @@ async function finalizePrismaFilesForContext(context, projectDir, provisionResul
1482
1486
  provider: context.databaseProvider,
1483
1487
  databaseUrl: provisionResult.databaseUrl,
1484
1488
  claimUrl: provisionResult.claimUrl,
1485
- useLocalMongo: context.useLocalMongo,
1486
1489
  projectDir
1487
1490
  });
1488
1491
  if (context.verbose) log.success("Prisma Next environment configured.");
@@ -1554,7 +1557,7 @@ function buildNextStepsForContext(opts) {
1554
1557
  command: getRunScriptCommand(context.packageManager, "db:init"),
1555
1558
  description: "Create the initial PostgreSQL database objects and sign the database."
1556
1559
  });
1557
- if (context.useLocalMongo) nextSteps.push({
1560
+ if (context.databaseProvider === "mongo" && !context.databaseUrl) nextSteps.push({
1558
1561
  command: getRunScriptCommand(context.packageManager, "db:up"),
1559
1562
  description: "Start the local MongoDB replica set with mongodb-memory-server. Stop with `db:down`, wipe with `db:reset`."
1560
1563
  });
@@ -1568,7 +1571,7 @@ function buildNextStepsForContext(opts) {
1568
1571
  });
1569
1572
  nextSteps.push({
1570
1573
  command: getRunScriptCommand(context.packageManager, "db:seed"),
1571
- description: "Insert the sample user and post data from prisma/seed.ts."
1574
+ description: "Insert the sample users from prisma/seed.ts."
1572
1575
  });
1573
1576
  if (options.includeDevNextStep) nextSteps.push({
1574
1577
  command: getRunScriptCommand(context.packageManager, "dev"),
@@ -1579,15 +1582,15 @@ function buildNextStepsForContext(opts) {
1579
1582
  function formatNextSteps(nextSteps) {
1580
1583
  return nextSteps.map((step) => `${step.command}\n ${step.description}`).join("\n\n");
1581
1584
  }
1582
- function formatFirstSteps(prependNextSteps) {
1583
- const lines = [];
1584
- for (const step of prependNextSteps) lines.push(step.command);
1585
- lines.push("");
1586
- lines.push("Ask your agent:");
1587
- lines.push("What can I do with Prisma Next?");
1588
- lines.push("");
1589
- lines.push("See README.md for the full setup sequence and available scripts.");
1590
- return lines.join("\n");
1585
+ function formatAgentPrompt() {
1586
+ return [
1587
+ "Ask your agent:",
1588
+ "What can I do with Prisma Next?",
1589
+ "",
1590
+ "Learn more:",
1591
+ `Docs: prisma-next.md`,
1592
+ "Skills: https://github.com/prisma/prisma-next/tree/main/skills"
1593
+ ].join("\n");
1591
1594
  }
1592
1595
  async function executePrismaSetupContext(context, options = {}) {
1593
1596
  const projectDir = path.resolve(options.projectDir ?? context.projectDir);
@@ -1635,8 +1638,8 @@ async function executePrismaSetupContext(context, options = {}) {
1635
1638
  });
1636
1639
  progressSpinner?.stop("Prisma Next project ready.");
1637
1640
  if (warningLines.length > 0) note(warningLines.map((line) => line.replace(/^- /, "")).join("\n"), "Heads up");
1638
- note(formatFirstSteps(options.prependNextSteps ?? []), "Next steps");
1639
- if (context.verbose) note(formatNextSteps(nextSteps), "Full command reference");
1641
+ note(formatAgentPrompt(), "Agent prompt");
1642
+ if (context.verbose) note(formatNextSteps(nextSteps), "Next steps for Prisma Next");
1640
1643
  outro("Prisma Next setup complete.");
1641
1644
  return true;
1642
1645
  }
@@ -1837,8 +1840,7 @@ async function executeCreateContext(context) {
1837
1840
  template: context.template,
1838
1841
  provider: context.prismaSetupContext.databaseProvider,
1839
1842
  authoring: context.prismaSetupContext.authoring,
1840
- packageManager: context.prismaSetupContext.packageManager,
1841
- useLocalMongo: context.prismaSetupContext.useLocalMongo
1843
+ packageManager: context.prismaSetupContext.packageManager
1842
1844
  });
1843
1845
  if (context.prismaSetupContext.verbose) log.success("Starter files scaffolded.");
1844
1846
  } catch (error) {
@@ -1853,7 +1855,8 @@ async function executeCreateContext(context) {
1853
1855
  await writeCreateTemplateDependencies({
1854
1856
  template: context.template,
1855
1857
  packageManager: context.prismaSetupContext.packageManager,
1856
- projectDir: context.targetDirectory
1858
+ projectDir: context.targetDirectory,
1859
+ prismaNextSpec: context.prismaSetupContext.prismaNextSpec
1857
1860
  });
1858
1861
  } catch (error) {
1859
1862
  createSpinner?.stop("Could not create Prisma Next project.");
package/dist/index.d.mts CHANGED
@@ -227,10 +227,10 @@ declare const CreateCommandInputSchema: z.ZodObject<{
227
227
  deno: "deno";
228
228
  }>>;
229
229
  prismaPostgres: z.ZodOptional<z.ZodBoolean>;
230
- localMongo: z.ZodOptional<z.ZodBoolean>;
231
230
  databaseUrl: z.ZodOptional<z.ZodString>;
232
231
  install: z.ZodOptional<z.ZodBoolean>;
233
232
  emit: z.ZodOptional<z.ZodBoolean>;
233
+ prismaNextVersion: z.ZodOptional<z.ZodString>;
234
234
  name: z.ZodOptional<z.ZodString>;
235
235
  template: z.ZodOptional<z.ZodEnum<{
236
236
  minimal: "minimal";
@@ -270,10 +270,10 @@ declare const router: {
270
270
  deno: "deno";
271
271
  }>>;
272
272
  prismaPostgres: zod.ZodOptional<zod.ZodBoolean>;
273
- localMongo: zod.ZodOptional<zod.ZodBoolean>;
274
273
  databaseUrl: zod.ZodOptional<zod.ZodString>;
275
274
  install: zod.ZodOptional<zod.ZodBoolean>;
276
275
  emit: zod.ZodOptional<zod.ZodBoolean>;
276
+ prismaNextVersion: zod.ZodOptional<zod.ZodString>;
277
277
  name: zod.ZodOptional<zod.ZodString>;
278
278
  template: zod.ZodOptional<zod.ZodEnum<{
279
279
  minimal: "minimal";
package/dist/index.mjs CHANGED
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
- import { a as DatabaseProviderSchema, i as CreateTemplateSchema, n as AuthoringStyleSchema, o as DatabaseUrlSchema, r as CreateCommandInputSchema, s as PackageManagerSchema, t as runCreateCommand } from "./create-BOeaiXBK.mjs";
2
+ import { a as DatabaseProviderSchema, i as CreateTemplateSchema, n as AuthoringStyleSchema, o as DatabaseUrlSchema, r as CreateCommandInputSchema, s as PackageManagerSchema, t as runCreateCommand } from "./create-CHVnIodq.mjs";
3
3
  import { os } from "@orpc/server";
4
4
  import { createCli } from "trpc-cli";
5
5
 
6
6
  //#region src/index.ts
7
- const CLI_VERSION = "0.4.2-pr.39.99.1";
7
+ const CLI_VERSION = "0.4.2-pr.40.103.1";
8
8
  const router = os.router({ create: os.meta({
9
9
  description: "Create a new project with Prisma setup",
10
10
  default: true,