create-prisma 0.4.2-next.37.102.1 → 0.4.2-next.37.105.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/README.md +16 -0
- package/dist/cli.mjs +1 -1
- package/dist/{create-DsDWZbPE.mjs → create-BIV2KC9D.mjs} +142 -79
- package/dist/index.d.mts +2 -0
- package/dist/index.mjs +2 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -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,6 +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
|
|
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>`.
|
|
133
149
|
- `--force` allow scaffolding into a non-empty directory
|
|
134
150
|
- `--verbose` print full command output
|
|
135
151
|
|
package/dist/cli.mjs
CHANGED
|
@@ -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 = "phc_cmc85avbWyuJ2JyKdGPdv7dxXli8xLdWDBPbvIXWJfs";
|
|
17
99
|
const TELEMETRY_HOST = "https://us.i.posthog.com";
|
|
@@ -49,7 +131,7 @@ async function getAnonymousId() {
|
|
|
49
131
|
}
|
|
50
132
|
function getCommonProperties() {
|
|
51
133
|
return {
|
|
52
|
-
"cli-version": "0.4.2-next.37.
|
|
134
|
+
"cli-version": "0.4.2-next.37.105.1",
|
|
53
135
|
"node-version": process.version,
|
|
54
136
|
platform: process.platform,
|
|
55
137
|
arch: process.arch
|
|
@@ -87,6 +169,16 @@ async function trackCliTelemetry(event, properties) {
|
|
|
87
169
|
|
|
88
170
|
//#endregion
|
|
89
171
|
//#region src/telemetry/create.ts
|
|
172
|
+
function classifyPrismaNextSpec(spec) {
|
|
173
|
+
if (!spec || spec === DEFAULT_PRISMA_NEXT_SPEC) return "default";
|
|
174
|
+
if (spec.kind === "pkg-pr-new") return "pkg-pr-new";
|
|
175
|
+
if (spec.spec === PRISMA_NEXT_DEFAULT_VERSION) return "default";
|
|
176
|
+
return /^[0-9]/.test(spec.spec) ? "npm-version" : "npm-tag";
|
|
177
|
+
}
|
|
178
|
+
function getPrismaNextVersionSpecString(spec) {
|
|
179
|
+
if (!spec) return null;
|
|
180
|
+
return spec.kind === "pkg-pr-new" ? `pkg-pr-new:${spec.ref}` : spec.spec;
|
|
181
|
+
}
|
|
90
182
|
const CREATE_PRISMA_NEXT_COMPLETED_EVENT = "cli:create_prisma_next_command_completed";
|
|
91
183
|
const CREATE_PRISMA_NEXT_FAILED_EVENT = "cli:create_prisma_next_command_failed";
|
|
92
184
|
function getTargetDirectoryState(context) {
|
|
@@ -95,6 +187,7 @@ function getTargetDirectoryState(context) {
|
|
|
95
187
|
return "non_empty_directory";
|
|
96
188
|
}
|
|
97
189
|
function getBaseCreateProperties(input, context) {
|
|
190
|
+
const resolvedPrismaNextSpec = context?.prismaSetupContext.prismaNextSpec;
|
|
98
191
|
return {
|
|
99
192
|
command: "create",
|
|
100
193
|
"uses-defaults": input.yes === true,
|
|
@@ -107,7 +200,9 @@ function getBaseCreateProperties(input, context) {
|
|
|
107
200
|
"should-install": context?.prismaSetupContext.shouldInstall ?? input.install ?? null,
|
|
108
201
|
"should-emit": context?.prismaSetupContext.shouldEmit ?? input.emit ?? null,
|
|
109
202
|
"uses-prisma-postgres": context?.prismaSetupContext.shouldUsePrismaPostgres ?? input.prismaPostgres ?? null,
|
|
110
|
-
"target-directory-state": context ? getTargetDirectoryState(context) : null
|
|
203
|
+
"target-directory-state": context ? getTargetDirectoryState(context) : null,
|
|
204
|
+
"prisma-next-version-kind": classifyPrismaNextSpec(resolvedPrismaNextSpec),
|
|
205
|
+
"prisma-next-version-spec": getPrismaNextVersionSpecString(resolvedPrismaNextSpec) ?? input.prismaNextVersion ?? null
|
|
111
206
|
};
|
|
112
207
|
}
|
|
113
208
|
function getErrorName(error) {
|
|
@@ -185,7 +280,8 @@ const PrismaSetupOptionsSchema = z.object({
|
|
|
185
280
|
prismaPostgres: z.boolean().optional().describe("Provision Prisma Postgres with create-db when target is postgres"),
|
|
186
281
|
databaseUrl: DatabaseUrlSchema.optional().describe("DATABASE_URL value"),
|
|
187
282
|
install: z.boolean().optional().describe("Install dependencies with selected package manager"),
|
|
188
|
-
emit: z.boolean().optional().describe("Emit Prisma Next contract artifacts after scaffolding")
|
|
283
|
+
emit: z.boolean().optional().describe("Emit Prisma Next contract artifacts after scaffolding"),
|
|
284
|
+
prismaNextVersion: z.string().trim().min(1).optional().describe("Prisma Next version, npm dist-tag, or 'pkg-pr-new:<sha|branch|pr>' (default: latest)")
|
|
189
285
|
});
|
|
190
286
|
const PrismaSetupCommandInputSchema = CommonCommandOptionsSchema.extend(PrismaSetupOptionsSchema.shape);
|
|
191
287
|
const CreateScaffoldOptionsSchema = z.object({
|
|
@@ -427,15 +523,6 @@ function getLocalPackageBinaryCommand(packageManager, binaryName, binaryArgs) {
|
|
|
427
523
|
return [execution.command, ...execution.args].join(" ");
|
|
428
524
|
}
|
|
429
525
|
|
|
430
|
-
//#endregion
|
|
431
|
-
//#region src/utils/runtime.ts
|
|
432
|
-
function usesNodeStyleRuntime(packageManager) {
|
|
433
|
-
return packageManager !== void 0 && packageManager !== "bun" && packageManager !== "deno";
|
|
434
|
-
}
|
|
435
|
-
function requiresDotenvConfigImport(packageManager) {
|
|
436
|
-
return usesNodeStyleRuntime(packageManager);
|
|
437
|
-
}
|
|
438
|
-
|
|
439
526
|
//#endregion
|
|
440
527
|
//#region src/templates/shared.ts
|
|
441
528
|
function getOptionalHashString(hash, key) {
|
|
@@ -547,52 +634,6 @@ async function scaffoldCreateTemplate(opts) {
|
|
|
547
634
|
});
|
|
548
635
|
}
|
|
549
636
|
|
|
550
|
-
//#endregion
|
|
551
|
-
//#region src/constants/dependencies.ts
|
|
552
|
-
const dependencyVersionMap = {
|
|
553
|
-
"@elysiajs/node": "^1.4.5",
|
|
554
|
-
"@types/node": "^25.6.2",
|
|
555
|
-
dotenv: "^17.4.2",
|
|
556
|
-
"mongodb-memory-server": "^11.1.0",
|
|
557
|
-
tsx: "^4.21.0"
|
|
558
|
-
};
|
|
559
|
-
const PRISMA_NEXT_PACKAGE_VERSION = "latest";
|
|
560
|
-
function isPrismaNextPackage(packageName) {
|
|
561
|
-
return packageName === "prisma-next" || packageName.startsWith("@prisma-next/");
|
|
562
|
-
}
|
|
563
|
-
function getPrismaNextPackageSpecifier(packageName) {
|
|
564
|
-
return `${packageName}@${PRISMA_NEXT_PACKAGE_VERSION}`;
|
|
565
|
-
}
|
|
566
|
-
function getDependencyVersion(packageName) {
|
|
567
|
-
if (isPrismaNextPackage(packageName)) return PRISMA_NEXT_PACKAGE_VERSION;
|
|
568
|
-
return dependencyVersionMap[packageName];
|
|
569
|
-
}
|
|
570
|
-
function usesViteDevServer(template) {
|
|
571
|
-
return template === "astro" || template === "nuxt" || template === "svelte" || template === "tanstack-start";
|
|
572
|
-
}
|
|
573
|
-
function getCreateTemplateDependencies(template, packageManager) {
|
|
574
|
-
const targets = [];
|
|
575
|
-
if (usesViteDevServer(template)) targets.push({
|
|
576
|
-
packageJsonPath: "package.json",
|
|
577
|
-
dependencies: [],
|
|
578
|
-
devDependencies: ["@prisma-next/vite-plugin-contract-emit"]
|
|
579
|
-
});
|
|
580
|
-
if (template === "minimal" || template === "hono" || template === "elysia" || template === "nest") {
|
|
581
|
-
const runtimeDevDependencies = usesNodeStyleRuntime(packageManager) ? ["tsx"] : [];
|
|
582
|
-
if (template === "elysia" && packageManager !== "deno") targets.push({
|
|
583
|
-
packageJsonPath: "package.json",
|
|
584
|
-
dependencies: ["@elysiajs/node"],
|
|
585
|
-
devDependencies: ["@types/node", ...runtimeDevDependencies]
|
|
586
|
-
});
|
|
587
|
-
else if (runtimeDevDependencies.length > 0) targets.push({
|
|
588
|
-
packageJsonPath: "package.json",
|
|
589
|
-
dependencies: [],
|
|
590
|
-
devDependencies: runtimeDevDependencies
|
|
591
|
-
});
|
|
592
|
-
}
|
|
593
|
-
return targets;
|
|
594
|
-
}
|
|
595
|
-
|
|
596
637
|
//#endregion
|
|
597
638
|
//#region src/constants/db-packages.ts
|
|
598
639
|
function getDbPackages(provider, _packageManager) {
|
|
@@ -690,7 +731,7 @@ function getOrmTypePackages(provider) {
|
|
|
690
731
|
return ["@prisma-next/sql-orm-client"];
|
|
691
732
|
}
|
|
692
733
|
async function addPackageDependency(opts) {
|
|
693
|
-
const { dependencies = [], devDependencies = [], customDependencies = {}, scripts = {}, scriptMode, projectDir } = opts;
|
|
734
|
+
const { dependencies = [], devDependencies = [], customDependencies = {}, scripts = {}, scriptMode, projectDir, prismaNextSpec = DEFAULT_PRISMA_NEXT_SPEC } = opts;
|
|
694
735
|
const pkgJsonPath = path.join(projectDir, "package.json");
|
|
695
736
|
if (!await fs.pathExists(pkgJsonPath)) throw new Error(`No package.json found in ${projectDir}. Run this command inside an existing JavaScript/TypeScript project.`);
|
|
696
737
|
const pkgJson = await fs.readJson(pkgJsonPath);
|
|
@@ -698,12 +739,12 @@ async function addPackageDependency(opts) {
|
|
|
698
739
|
if (!pkgJson.devDependencies) pkgJson.devDependencies = {};
|
|
699
740
|
if (!pkgJson.scripts) pkgJson.scripts = {};
|
|
700
741
|
for (const pkgName of unique(dependencies)) {
|
|
701
|
-
const version = getDependencyVersion(pkgName);
|
|
742
|
+
const version = getDependencyVersion(pkgName, prismaNextSpec);
|
|
702
743
|
if (version) pkgJson.dependencies[pkgName] = version;
|
|
703
744
|
else console.warn(`Warning: Dependency ${pkgName} not found in version map.`);
|
|
704
745
|
}
|
|
705
746
|
for (const pkgName of unique(devDependencies)) {
|
|
706
|
-
const version = getDependencyVersion(pkgName);
|
|
747
|
+
const version = getDependencyVersion(pkgName, prismaNextSpec);
|
|
707
748
|
if (version) pkgJson.devDependencies[pkgName] = version;
|
|
708
749
|
else console.warn(`Warning: Dev dependency ${pkgName} not found in version map.`);
|
|
709
750
|
}
|
|
@@ -719,7 +760,7 @@ async function addPackageDependency(opts) {
|
|
|
719
760
|
pkgJson.devDependencies = sortRecord(pkgJson.devDependencies);
|
|
720
761
|
await fs.writeJson(pkgJsonPath, pkgJson, { spaces: 2 });
|
|
721
762
|
}
|
|
722
|
-
async function writePrismaDependencies(provider, packageManager, authoring, projectDir = process.cwd()) {
|
|
763
|
+
async function writePrismaDependencies(provider, packageManager, authoring, projectDir = process.cwd(), prismaNextSpec = DEFAULT_PRISMA_NEXT_SPEC) {
|
|
723
764
|
const dependencies = [getDbPackages(provider, packageManager), "dotenv"];
|
|
724
765
|
const devDependencies = [
|
|
725
766
|
"prisma-next",
|
|
@@ -734,11 +775,12 @@ async function writePrismaDependencies(provider, packageManager, authoring, proj
|
|
|
734
775
|
dependencies,
|
|
735
776
|
devDependencies,
|
|
736
777
|
scripts: getPrismaNextScriptMap(packageManager),
|
|
737
|
-
projectDir
|
|
778
|
+
projectDir,
|
|
779
|
+
prismaNextSpec
|
|
738
780
|
});
|
|
739
781
|
}
|
|
740
782
|
async function writeCreateTemplateDependencies(opts) {
|
|
741
|
-
const { template, packageManager, projectDir = process.cwd() } = opts;
|
|
783
|
+
const { template, packageManager, projectDir = process.cwd(), prismaNextSpec = DEFAULT_PRISMA_NEXT_SPEC } = opts;
|
|
742
784
|
const targets = getCreateTemplateDependencies(template, packageManager);
|
|
743
785
|
for (const dependencyTarget of targets) {
|
|
744
786
|
const targetDirectory = path.join(projectDir, path.dirname(dependencyTarget.packageJsonPath));
|
|
@@ -746,7 +788,8 @@ async function writeCreateTemplateDependencies(opts) {
|
|
|
746
788
|
dependencies: dependencyTarget.dependencies,
|
|
747
789
|
devDependencies: dependencyTarget.devDependencies,
|
|
748
790
|
customDependencies: dependencyTarget.customDependencies,
|
|
749
|
-
projectDir: targetDirectory
|
|
791
|
+
projectDir: targetDirectory,
|
|
792
|
+
prismaNextSpec
|
|
750
793
|
});
|
|
751
794
|
}
|
|
752
795
|
}
|
|
@@ -823,7 +866,7 @@ const DEFAULT_AUTHORING = "psl";
|
|
|
823
866
|
const DEFAULT_INSTALL = true;
|
|
824
867
|
const DEFAULT_EMIT = true;
|
|
825
868
|
const DEFAULT_INTERACTIVE_PRISMA_POSTGRES = true;
|
|
826
|
-
const DEFAULT_AUTOMATED_PRISMA_POSTGRES =
|
|
869
|
+
const DEFAULT_AUTOMATED_PRISMA_POSTGRES = true;
|
|
827
870
|
const MONGO_MEMORY_SERVER_SCRIPT = `import { spawn } from "node:child_process";
|
|
828
871
|
import { closeSync, existsSync, mkdirSync, openSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
829
872
|
import path from "node:path";
|
|
@@ -1085,6 +1128,12 @@ async function promptForPrismaPostgres() {
|
|
|
1085
1128
|
}
|
|
1086
1129
|
return Boolean(shouldUsePrismaPostgres);
|
|
1087
1130
|
}
|
|
1131
|
+
async function resolvePrismaPostgresChoice(options) {
|
|
1132
|
+
const { explicitChoice, databaseProvider, databaseUrl, useDefaults } = options;
|
|
1133
|
+
if (explicitChoice !== void 0) return explicitChoice;
|
|
1134
|
+
if (databaseProvider !== "postgres" || databaseUrl) return false;
|
|
1135
|
+
return useDefaults ? DEFAULT_AUTOMATED_PRISMA_POSTGRES : await promptForPrismaPostgres();
|
|
1136
|
+
}
|
|
1088
1137
|
function getPackageManagerHint(option, detected) {
|
|
1089
1138
|
const hint = {
|
|
1090
1139
|
npm: "Node.js default",
|
|
@@ -1158,10 +1207,22 @@ async function collectPrismaSetupContext(input, options = {}) {
|
|
|
1158
1207
|
const useDefaults = input.yes === true;
|
|
1159
1208
|
const verbose = input.verbose === true;
|
|
1160
1209
|
const shouldEmit = input.emit ?? DEFAULT_EMIT;
|
|
1210
|
+
let prismaNextSpec;
|
|
1211
|
+
try {
|
|
1212
|
+
prismaNextSpec = parsePrismaNextVersionSpec(input.prismaNextVersion);
|
|
1213
|
+
} catch (error) {
|
|
1214
|
+
cancel(error instanceof Error ? error.message : String(error));
|
|
1215
|
+
return;
|
|
1216
|
+
}
|
|
1161
1217
|
const databaseProvider = input.provider ?? (useDefaults ? DEFAULT_DATABASE_PROVIDER : await promptForDatabaseProvider());
|
|
1162
1218
|
if (!databaseProvider) return;
|
|
1163
1219
|
const databaseUrl = input.databaseUrl;
|
|
1164
|
-
const shouldUsePrismaPostgres =
|
|
1220
|
+
const shouldUsePrismaPostgres = await resolvePrismaPostgresChoice({
|
|
1221
|
+
explicitChoice: input.prismaPostgres,
|
|
1222
|
+
databaseProvider,
|
|
1223
|
+
databaseUrl,
|
|
1224
|
+
useDefaults
|
|
1225
|
+
});
|
|
1165
1226
|
if (shouldUsePrismaPostgres === void 0) return;
|
|
1166
1227
|
if (shouldUsePrismaPostgres && databaseProvider !== "postgres") {
|
|
1167
1228
|
cancel("--prisma-postgres is only supported with --provider postgres.");
|
|
@@ -1187,7 +1248,8 @@ async function collectPrismaSetupContext(input, options = {}) {
|
|
|
1187
1248
|
databaseUrl,
|
|
1188
1249
|
shouldUsePrismaPostgres,
|
|
1189
1250
|
packageManager,
|
|
1190
|
-
shouldInstall
|
|
1251
|
+
shouldInstall,
|
|
1252
|
+
prismaNextSpec
|
|
1191
1253
|
};
|
|
1192
1254
|
}
|
|
1193
1255
|
function getDefaultDatabaseUrl(provider) {
|
|
@@ -1360,37 +1422,37 @@ async function provisionPrismaPostgresIfNeeded(context, projectDir) {
|
|
|
1360
1422
|
}
|
|
1361
1423
|
async function writeDependenciesForContext(context, projectDir) {
|
|
1362
1424
|
try {
|
|
1363
|
-
await writePrismaDependencies(context.databaseProvider, context.packageManager, context.authoring, projectDir);
|
|
1425
|
+
await writePrismaDependencies(context.databaseProvider, context.packageManager, context.authoring, projectDir, context.prismaNextSpec);
|
|
1364
1426
|
return true;
|
|
1365
1427
|
} catch (error) {
|
|
1366
1428
|
cancel(getCommandErrorMessage(error));
|
|
1367
1429
|
return false;
|
|
1368
1430
|
}
|
|
1369
1431
|
}
|
|
1370
|
-
function getPrismaNextCliPackageSpecifier() {
|
|
1371
|
-
return getPrismaNextPackageSpecifier("prisma-next");
|
|
1432
|
+
function getPrismaNextCliPackageSpecifier(prismaNextSpec = DEFAULT_PRISMA_NEXT_SPEC) {
|
|
1433
|
+
return getPrismaNextPackageSpecifier("prisma-next", prismaNextSpec);
|
|
1372
1434
|
}
|
|
1373
1435
|
function getPrismaNextInitTarget(provider) {
|
|
1374
1436
|
return provider === "mongo" ? "mongodb" : "postgres";
|
|
1375
1437
|
}
|
|
1376
|
-
function getPrismaNextInitCliArgs(packageManager, prismaNextArgs) {
|
|
1438
|
+
function getPrismaNextInitCliArgs(packageManager, prismaNextArgs, prismaNextSpec = DEFAULT_PRISMA_NEXT_SPEC) {
|
|
1377
1439
|
if (packageManager === "npm") return {
|
|
1378
1440
|
command: "npx",
|
|
1379
1441
|
args: [
|
|
1380
1442
|
"--yes",
|
|
1381
|
-
getPrismaNextCliPackageSpecifier(),
|
|
1443
|
+
getPrismaNextCliPackageSpecifier(prismaNextSpec),
|
|
1382
1444
|
"init",
|
|
1383
1445
|
...prismaNextArgs
|
|
1384
1446
|
]
|
|
1385
1447
|
};
|
|
1386
1448
|
return getPackageExecutionArgs(packageManager, [
|
|
1387
|
-
getPrismaNextCliPackageSpecifier(),
|
|
1449
|
+
getPrismaNextCliPackageSpecifier(prismaNextSpec),
|
|
1388
1450
|
"init",
|
|
1389
1451
|
...prismaNextArgs
|
|
1390
1452
|
]);
|
|
1391
1453
|
}
|
|
1392
|
-
function getPrismaNextInitCliCommand(packageManager, prismaNextArgs) {
|
|
1393
|
-
const execution = getPrismaNextInitCliArgs(packageManager, prismaNextArgs);
|
|
1454
|
+
function getPrismaNextInitCliCommand(packageManager, prismaNextArgs, prismaNextSpec = DEFAULT_PRISMA_NEXT_SPEC) {
|
|
1455
|
+
const execution = getPrismaNextInitCliArgs(packageManager, prismaNextArgs, prismaNextSpec);
|
|
1394
1456
|
return [execution.command, ...execution.args].join(" ");
|
|
1395
1457
|
}
|
|
1396
1458
|
async function runPrismaNextInitForContext(context, projectDir) {
|
|
@@ -1405,10 +1467,10 @@ async function runPrismaNextInitForContext(context, projectDir) {
|
|
|
1405
1467
|
getContractPath(context.authoring),
|
|
1406
1468
|
"--no-install"
|
|
1407
1469
|
];
|
|
1408
|
-
const initCommand = getPrismaNextInitCliCommand(context.packageManager, initArgs);
|
|
1470
|
+
const initCommand = getPrismaNextInitCliCommand(context.packageManager, initArgs, context.prismaNextSpec);
|
|
1409
1471
|
if (context.verbose) log.step(`Running ${initCommand}`);
|
|
1410
1472
|
try {
|
|
1411
|
-
const initExecution = getPrismaNextInitCliArgs(context.packageManager, initArgs);
|
|
1473
|
+
const initExecution = getPrismaNextInitCliArgs(context.packageManager, initArgs, context.prismaNextSpec);
|
|
1412
1474
|
await execa(initExecution.command, initExecution.args, {
|
|
1413
1475
|
cwd: projectDir,
|
|
1414
1476
|
stdio: context.verbose ? "inherit" : "pipe",
|
|
@@ -1813,7 +1875,8 @@ async function executeCreateContext(context) {
|
|
|
1813
1875
|
await writeCreateTemplateDependencies({
|
|
1814
1876
|
template: context.template,
|
|
1815
1877
|
packageManager: context.prismaSetupContext.packageManager,
|
|
1816
|
-
projectDir: context.targetDirectory
|
|
1878
|
+
projectDir: context.targetDirectory,
|
|
1879
|
+
prismaNextSpec: context.prismaSetupContext.prismaNextSpec
|
|
1817
1880
|
});
|
|
1818
1881
|
} catch (error) {
|
|
1819
1882
|
createSpinner?.stop("Could not create Prisma Next project.");
|
package/dist/index.d.mts
CHANGED
|
@@ -230,6 +230,7 @@ declare const CreateCommandInputSchema: z.ZodObject<{
|
|
|
230
230
|
databaseUrl: z.ZodOptional<z.ZodString>;
|
|
231
231
|
install: z.ZodOptional<z.ZodBoolean>;
|
|
232
232
|
emit: z.ZodOptional<z.ZodBoolean>;
|
|
233
|
+
prismaNextVersion: z.ZodOptional<z.ZodString>;
|
|
233
234
|
name: z.ZodOptional<z.ZodString>;
|
|
234
235
|
template: z.ZodOptional<z.ZodEnum<{
|
|
235
236
|
minimal: "minimal";
|
|
@@ -272,6 +273,7 @@ declare const router: {
|
|
|
272
273
|
databaseUrl: zod.ZodOptional<zod.ZodString>;
|
|
273
274
|
install: zod.ZodOptional<zod.ZodBoolean>;
|
|
274
275
|
emit: zod.ZodOptional<zod.ZodBoolean>;
|
|
276
|
+
prismaNextVersion: zod.ZodOptional<zod.ZodString>;
|
|
275
277
|
name: zod.ZodOptional<zod.ZodString>;
|
|
276
278
|
template: zod.ZodOptional<zod.ZodEnum<{
|
|
277
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-
|
|
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-BIV2KC9D.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-next.37.
|
|
7
|
+
const CLI_VERSION = "0.4.2-next.37.105.1";
|
|
8
8
|
const router = os.router({ create: os.meta({
|
|
9
9
|
description: "Create a new project with Prisma setup",
|
|
10
10
|
default: true,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-prisma",
|
|
3
|
-
"version": "0.4.2-next.37.
|
|
3
|
+
"version": "0.4.2-next.37.105.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Create Prisma Next projects with first-party templates and great DX.",
|
|
6
6
|
"homepage": "https://github.com/prisma/create-prisma",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"dev": "tsdown --watch",
|
|
38
38
|
"start": "bun run ./dist/cli.mjs",
|
|
39
39
|
"test": "bun run test:unit && bun run test:e2e",
|
|
40
|
-
"test:unit": "bun test ./tests/install.test.ts ./tests/telemetry.test.ts",
|
|
40
|
+
"test:unit": "bun test ./tests/dependencies.test.ts ./tests/install.test.ts ./tests/setup-prisma.test.ts ./tests/telemetry.test.ts",
|
|
41
41
|
"test:e2e": "bun test --timeout 180000 ./tests/e2e/create-prisma.e2e.test.ts",
|
|
42
42
|
"check": "bun run format:check && bun run lint",
|
|
43
43
|
"lint": "oxlint . --deny-warnings",
|