create-prisma 0.8.0 → 0.9.0
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 +13 -5
- package/dist/cli.mjs +1 -1
- package/dist/{create-BeQ3QH6g.mjs → create-CsM1p1qA.mjs} +96 -16
- package/dist/index.d.mts +3 -0
- package/dist/index.mjs +2 -2
- package/package.json +1 -1
- package/templates/create/_shared/README.md.hbs +33 -0
- package/templates/create/_shared/deno.json.hbs +5 -0
- package/templates/create/_shared/module.ts.hbs +2 -0
- package/templates/create/_shared/prisma-composer.config.ts.hbs +2 -0
- package/templates/create/_shared/prisma.config.ts.hbs +2 -0
- package/templates/create/_shared/service.ts.hbs +2 -0
- package/templates/create/_shared/src/prisma/composer.ts.hbs +2 -0
- package/templates/create/_shared/src/prisma/db.ts.hbs +12 -0
- package/templates/create/minimal/package.json.hbs +6 -0
- package/templates/create/minimal/src/index.ts.hbs +2 -2
package/README.md
CHANGED
|
@@ -7,10 +7,10 @@ Create a Prisma 8 app with Prisma Composer built in.
|
|
|
7
7
|
Use your package manager:
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
npx create-prisma@
|
|
11
|
-
pnpm dlx create-prisma@
|
|
12
|
-
yarn dlx create-prisma@
|
|
13
|
-
bunx create-prisma@
|
|
10
|
+
npx create-prisma@latest my-app
|
|
11
|
+
pnpm dlx create-prisma@latest my-app
|
|
12
|
+
yarn dlx create-prisma@latest my-app
|
|
13
|
+
bunx create-prisma@latest my-app
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
The CLI initializes Prisma 8 with `prisma@next`, 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.
|
|
@@ -41,13 +41,21 @@ workspace. Choosing another workspace also updates the Prisma CLI's active works
|
|
|
41
41
|
|
|
42
42
|
PostgreSQL and MongoDB are supported with PSL or TypeScript contract authoring. npm, pnpm, Yarn, and Bun are supported.
|
|
43
43
|
|
|
44
|
+
Deno is supported for local minimal PostgreSQL apps:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
deno run -A npm:create-prisma@latest my-deno-app --template minimal --provider postgres --package-manager deno --no-deploy
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Prisma Compute does not support Deno deployments yet.
|
|
51
|
+
|
|
44
52
|
## Options
|
|
45
53
|
|
|
46
54
|
- positional project name or `--name`
|
|
47
55
|
- `--template`
|
|
48
56
|
- `--provider postgres|postgresql|mongo|mongodb`
|
|
49
57
|
- `--authoring psl|typescript`
|
|
50
|
-
- `--package-manager npm|pnpm|yarn|bun`
|
|
58
|
+
- `--package-manager npm|pnpm|yarn|bun|deno`
|
|
51
59
|
- `--deploy` / `--no-deploy`
|
|
52
60
|
- `--workspace <id-or-name>`
|
|
53
61
|
- `--yes`
|
package/dist/cli.mjs
CHANGED
|
@@ -49,7 +49,7 @@ async function getAnonymousId() {
|
|
|
49
49
|
}
|
|
50
50
|
function getCommonProperties() {
|
|
51
51
|
return {
|
|
52
|
-
"cli-version": "0.
|
|
52
|
+
"cli-version": "0.9.0",
|
|
53
53
|
"node-version": process.version,
|
|
54
54
|
platform: process.platform,
|
|
55
55
|
arch: process.arch
|
|
@@ -147,7 +147,8 @@ const packageManagers = [
|
|
|
147
147
|
"npm",
|
|
148
148
|
"pnpm",
|
|
149
149
|
"yarn",
|
|
150
|
-
"bun"
|
|
150
|
+
"bun",
|
|
151
|
+
"deno"
|
|
151
152
|
];
|
|
152
153
|
const authoringStyles = ["psl", "typescript"];
|
|
153
154
|
const createTemplates = [
|
|
@@ -201,6 +202,7 @@ function parseUserAgent(userAgent) {
|
|
|
201
202
|
if (userAgent?.startsWith("pnpm")) return "pnpm";
|
|
202
203
|
if (userAgent?.startsWith("yarn")) return "yarn";
|
|
203
204
|
if (userAgent?.startsWith("bun")) return "bun";
|
|
205
|
+
if (userAgent?.startsWith("deno")) return "deno";
|
|
204
206
|
if (userAgent?.startsWith("npm")) return "npm";
|
|
205
207
|
return null;
|
|
206
208
|
}
|
|
@@ -215,6 +217,10 @@ async function detectFromPackageJson(projectDir) {
|
|
|
215
217
|
if (!await fs.pathExists(packageJsonPath)) return null;
|
|
216
218
|
return parsePackageManagerField((await fs.readJson(packageJsonPath)).packageManager);
|
|
217
219
|
}
|
|
220
|
+
async function detectFromDenoConfig(projectDir) {
|
|
221
|
+
for (const configFile of ["deno.json", "deno.jsonc"]) if (await fs.pathExists(path.join(projectDir, configFile))) return "deno";
|
|
222
|
+
return null;
|
|
223
|
+
}
|
|
218
224
|
async function detectFromLockfile(projectDir) {
|
|
219
225
|
for (const check of [
|
|
220
226
|
{
|
|
@@ -240,6 +246,10 @@ async function detectFromLockfile(projectDir) {
|
|
|
240
246
|
{
|
|
241
247
|
manager: "npm",
|
|
242
248
|
lockfile: "npm-shrinkwrap.json"
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
manager: "deno",
|
|
252
|
+
lockfile: "deno.lock"
|
|
243
253
|
}
|
|
244
254
|
]) if (await fs.pathExists(path.join(projectDir, check.lockfile))) return check.manager;
|
|
245
255
|
return null;
|
|
@@ -249,19 +259,24 @@ async function detectPackageManager(projectDir = process.cwd()) {
|
|
|
249
259
|
if (fromPackageJson) return fromPackageJson;
|
|
250
260
|
const fromLockfile = await detectFromLockfile(projectDir);
|
|
251
261
|
if (fromLockfile) return fromLockfile;
|
|
262
|
+
const fromDenoConfig = await detectFromDenoConfig(projectDir);
|
|
263
|
+
if (fromDenoConfig) return fromDenoConfig;
|
|
252
264
|
const fromUserAgent = parseUserAgent(process.env.npm_config_user_agent);
|
|
253
265
|
if (fromUserAgent) return fromUserAgent;
|
|
254
266
|
return "npm";
|
|
255
267
|
}
|
|
256
268
|
function getPackageManagerManifestValue(packageManager) {
|
|
257
269
|
if (!packageManager) return;
|
|
270
|
+
if (packageManager === "deno") return;
|
|
258
271
|
return packageManagerManifestValues[packageManager];
|
|
259
272
|
}
|
|
260
273
|
function getInstallCommand(packageManager) {
|
|
274
|
+
if (packageManager === "deno") return "deno install";
|
|
261
275
|
return `${packageManager} install`;
|
|
262
276
|
}
|
|
263
277
|
function getRunScriptCommand(packageManager, scriptName) {
|
|
264
278
|
switch (packageManager) {
|
|
279
|
+
case "deno": return `deno task ${scriptName}`;
|
|
265
280
|
case "bun": return `bun run ${scriptName}`;
|
|
266
281
|
case "pnpm": return `pnpm run ${scriptName}`;
|
|
267
282
|
case "yarn": return `yarn run ${scriptName}`;
|
|
@@ -270,6 +285,11 @@ function getRunScriptCommand(packageManager, scriptName) {
|
|
|
270
285
|
}
|
|
271
286
|
function getRuntimeScriptCommand(packageManager, kind, options) {
|
|
272
287
|
const { sourceEntrypoint, builtEntrypoint } = options;
|
|
288
|
+
if (packageManager === "deno") switch (kind) {
|
|
289
|
+
case "dev": return `deno run -A --env-file=.env --watch ${sourceEntrypoint}`;
|
|
290
|
+
case "build": return `deno check ${sourceEntrypoint}`;
|
|
291
|
+
case "start": return `deno run -A --env-file=.env ${sourceEntrypoint}`;
|
|
292
|
+
}
|
|
273
293
|
if (packageManager === "bun") switch (kind) {
|
|
274
294
|
case "dev": return `bun --watch ${sourceEntrypoint}`;
|
|
275
295
|
case "build": return "tsc --noEmit";
|
|
@@ -282,6 +302,10 @@ function getRuntimeScriptCommand(packageManager, kind, options) {
|
|
|
282
302
|
}
|
|
283
303
|
}
|
|
284
304
|
function getInstallArgs(packageManager) {
|
|
305
|
+
if (packageManager === "deno") return {
|
|
306
|
+
command: "deno",
|
|
307
|
+
args: ["install"]
|
|
308
|
+
};
|
|
285
309
|
return {
|
|
286
310
|
command: packageManager,
|
|
287
311
|
args: ["install"]
|
|
@@ -289,6 +313,19 @@ function getInstallArgs(packageManager) {
|
|
|
289
313
|
}
|
|
290
314
|
function getPackageExecutionArgs(packageManager, commandArgs) {
|
|
291
315
|
switch (packageManager) {
|
|
316
|
+
case "deno": {
|
|
317
|
+
const [packageName, ...args] = commandArgs;
|
|
318
|
+
if (!packageName) throw new Error("Package execution requires a package name.");
|
|
319
|
+
return {
|
|
320
|
+
command: "deno",
|
|
321
|
+
args: [
|
|
322
|
+
"run",
|
|
323
|
+
"-A",
|
|
324
|
+
`npm:${packageName}`,
|
|
325
|
+
...args
|
|
326
|
+
]
|
|
327
|
+
};
|
|
328
|
+
}
|
|
292
329
|
case "pnpm": return {
|
|
293
330
|
command: "pnpm",
|
|
294
331
|
args: ["dlx", ...commandArgs]
|
|
@@ -313,6 +350,10 @@ function getPackageExecutionCommand(packageManager, commandArgs) {
|
|
|
313
350
|
}
|
|
314
351
|
function getRunScriptArgs(packageManager, scriptName) {
|
|
315
352
|
switch (packageManager) {
|
|
353
|
+
case "deno": return {
|
|
354
|
+
command: "deno",
|
|
355
|
+
args: ["task", scriptName]
|
|
356
|
+
};
|
|
316
357
|
case "bun": return {
|
|
317
358
|
command: "bun",
|
|
318
359
|
args: ["run", scriptName]
|
|
@@ -447,6 +488,7 @@ const dependencyVersionMap = {
|
|
|
447
488
|
"@types/node": "^25.6.2",
|
|
448
489
|
alchemy: "2.0.0-beta.67",
|
|
449
490
|
arktype: "^2.2.3",
|
|
491
|
+
dotenv: "^17.4.2",
|
|
450
492
|
esbuild: "^0.28.1",
|
|
451
493
|
effect: "4.0.0-beta.103",
|
|
452
494
|
mongodb: "^7.1.0",
|
|
@@ -456,6 +498,7 @@ const dependencyVersionMap = {
|
|
|
456
498
|
typescript: "^5.9.3"
|
|
457
499
|
};
|
|
458
500
|
const PRISMA_PLATFORM_CLI_PACKAGE = "prisma@next";
|
|
501
|
+
const PRISMA_DENO_CLI_PACKAGE = "prisma-next";
|
|
459
502
|
function getDependencyVersion(packageName) {
|
|
460
503
|
return dependencyVersionMap[packageName];
|
|
461
504
|
}
|
|
@@ -498,6 +541,24 @@ function getDbPackages(provider) {
|
|
|
498
541
|
//#endregion
|
|
499
542
|
//#region src/tasks/install.ts
|
|
500
543
|
function getPrismaScriptMap(packageManager) {
|
|
544
|
+
if (packageManager === "deno") {
|
|
545
|
+
const prismaCommand = (needsDatabase, ...args) => [
|
|
546
|
+
"deno run -A",
|
|
547
|
+
...needsDatabase ? ["--env-file=.env"] : [],
|
|
548
|
+
`npm:${PRISMA_DENO_CLI_PACKAGE}`,
|
|
549
|
+
...args
|
|
550
|
+
].join(" ");
|
|
551
|
+
return {
|
|
552
|
+
"contract:emit": prismaCommand(false, "contract", "emit"),
|
|
553
|
+
"db:init": prismaCommand(true, "db", "init"),
|
|
554
|
+
"db:update": prismaCommand(true, "db", "update"),
|
|
555
|
+
"db:verify": prismaCommand(true, "db", "verify"),
|
|
556
|
+
"migration:plan": prismaCommand(true, "migration", "plan"),
|
|
557
|
+
migrate: prismaCommand(true, "migrate"),
|
|
558
|
+
"migration:status": prismaCommand(true, "migration", "status"),
|
|
559
|
+
"migration:show": prismaCommand(true, "migration", "show")
|
|
560
|
+
};
|
|
561
|
+
}
|
|
501
562
|
const prismaCommand = (...args) => getPackageExecutionCommand(packageManager, [PRISMA_PLATFORM_CLI_PACKAGE, ...args]);
|
|
502
563
|
return {
|
|
503
564
|
"contract:emit": prismaCommand("contract", "emit"),
|
|
@@ -511,6 +572,7 @@ function getPrismaScriptMap(packageManager) {
|
|
|
511
572
|
};
|
|
512
573
|
}
|
|
513
574
|
function getComposerScriptMap(packageManager) {
|
|
575
|
+
if (packageManager === "deno") return {};
|
|
514
576
|
const composerCommand = (subcommand, extraArgs = []) => getPackageExecutionCommand(packageManager, [
|
|
515
577
|
PRISMA_PLATFORM_CLI_PACKAGE,
|
|
516
578
|
"composer",
|
|
@@ -563,15 +625,17 @@ async function addPackageDependency(opts) {
|
|
|
563
625
|
async function writePrismaDependencies(provider, packageManager, _authoring, projectDir = process.cwd()) {
|
|
564
626
|
const dependencies = [getDbPackages(provider)];
|
|
565
627
|
if (provider === "mongo") dependencies.push("arktype", "mongodb");
|
|
628
|
+
if (packageManager === "deno") dependencies.push("dotenv");
|
|
566
629
|
await addPackageDependency({
|
|
567
630
|
dependencies,
|
|
568
|
-
devDependencies: ["@prisma/cli-engine", "@types/node"],
|
|
631
|
+
devDependencies: packageManager === "deno" ? ["@types/node"] : ["@prisma/cli-engine", "@types/node"],
|
|
569
632
|
scripts: getPrismaScriptMap(packageManager),
|
|
570
633
|
projectDir
|
|
571
634
|
});
|
|
572
635
|
}
|
|
573
636
|
async function writeCreateTemplateDependencies(opts) {
|
|
574
637
|
const { template, packageManager, projectDir = process.cwd() } = opts;
|
|
638
|
+
if (packageManager === "deno") return;
|
|
575
639
|
for (const target of getCreateTemplateDependencies(template, packageManager)) await addPackageDependency({
|
|
576
640
|
dependencies: target.dependencies,
|
|
577
641
|
devDependencies: target.devDependencies,
|
|
@@ -908,7 +972,8 @@ function getPackageManagerHint(option, detected) {
|
|
|
908
972
|
npm: "Node.js default",
|
|
909
973
|
pnpm: "Fast, disk-efficient package manager",
|
|
910
974
|
yarn: "Yarn package manager",
|
|
911
|
-
bun: "Fast runtime and package manager"
|
|
975
|
+
bun: "Fast runtime and package manager",
|
|
976
|
+
deno: "Deno runtime (minimal PostgreSQL apps)"
|
|
912
977
|
};
|
|
913
978
|
return option === detected ? `Detected; ${hints[option]}` : hints[option];
|
|
914
979
|
}
|
|
@@ -916,12 +981,7 @@ async function promptForPackageManager(detected) {
|
|
|
916
981
|
const packageManager = await select({
|
|
917
982
|
message: "Choose package manager",
|
|
918
983
|
initialValue: detected,
|
|
919
|
-
options:
|
|
920
|
-
"npm",
|
|
921
|
-
"pnpm",
|
|
922
|
-
"yarn",
|
|
923
|
-
"bun"
|
|
924
|
-
].map((value) => ({
|
|
984
|
+
options: packageManagers.map((value) => ({
|
|
925
985
|
value,
|
|
926
986
|
label: value,
|
|
927
987
|
hint: getPackageManagerHint(value, detected)
|
|
@@ -954,7 +1014,10 @@ async function collectPrismaSetupContext(input, options = {}) {
|
|
|
954
1014
|
const detectedPackageManager = await detectPackageManager(projectDir);
|
|
955
1015
|
const packageManager = input.packageManager ?? (useDefaults ? detectedPackageManager : await promptForPackageManager(detectedPackageManager));
|
|
956
1016
|
if (!packageManager) return;
|
|
957
|
-
|
|
1017
|
+
if (packageManager === "deno" && databaseProvider !== "postgres") throw new Error("Deno support currently requires PostgreSQL.");
|
|
1018
|
+
if (packageManager === "deno" && options.template && options.template !== "minimal") throw new Error("Deno support currently requires the minimal template.");
|
|
1019
|
+
if (packageManager === "deno" && input.deploy === true) throw new Error("Prisma Compute does not support Deno deployments yet. Use --no-deploy.");
|
|
1020
|
+
const shouldDeploy = packageManager === "deno" ? false : input.deploy ?? (useDefaults ? false : await promptForDeployment());
|
|
958
1021
|
if (shouldDeploy === void 0) return;
|
|
959
1022
|
return {
|
|
960
1023
|
projectDir,
|
|
@@ -981,10 +1044,22 @@ function getInitTarget(provider) {
|
|
|
981
1044
|
return provider === "mongo" ? "mongodb" : "postgres";
|
|
982
1045
|
}
|
|
983
1046
|
function getPrismaCliInvocation(packageManager, args) {
|
|
984
|
-
return getPackageExecutionArgs(packageManager, [PRISMA_PLATFORM_CLI_PACKAGE, ...args]);
|
|
1047
|
+
return getPackageExecutionArgs(packageManager, [packageManager === "deno" ? PRISMA_DENO_CLI_PACKAGE : PRISMA_PLATFORM_CLI_PACKAGE, ...args]);
|
|
985
1048
|
}
|
|
986
1049
|
async function runPrismaInit(context, projectDir) {
|
|
987
|
-
const args = [
|
|
1050
|
+
const args = context.packageManager === "deno" ? [
|
|
1051
|
+
"init",
|
|
1052
|
+
"--yes",
|
|
1053
|
+
"--no-interactive",
|
|
1054
|
+
"--target",
|
|
1055
|
+
getInitTarget(context.databaseProvider),
|
|
1056
|
+
"--authoring",
|
|
1057
|
+
context.authoring,
|
|
1058
|
+
"--schema-path",
|
|
1059
|
+
getContractPath(context.authoring),
|
|
1060
|
+
"--no-install",
|
|
1061
|
+
"--no-skill"
|
|
1062
|
+
] : [
|
|
988
1063
|
"orm",
|
|
989
1064
|
"init",
|
|
990
1065
|
"--yes",
|
|
@@ -1008,6 +1083,7 @@ async function runPrismaInit(context, projectDir) {
|
|
|
1008
1083
|
CI: "1"
|
|
1009
1084
|
}
|
|
1010
1085
|
});
|
|
1086
|
+
if (context.packageManager === "deno") await fs.remove(path.join(projectDir, "prisma-next.md"));
|
|
1011
1087
|
}
|
|
1012
1088
|
async function ensureGitignoreEntry(projectDir, entry) {
|
|
1013
1089
|
const gitignorePath = path.join(projectDir, ".gitignore");
|
|
@@ -1065,9 +1141,10 @@ function buildNextSteps(context, options) {
|
|
|
1065
1141
|
description: "Composer uses this secret when deploying the MongoDB template."
|
|
1066
1142
|
});
|
|
1067
1143
|
if (options.includeDevNextStep) nextSteps.push({
|
|
1068
|
-
command: getRunScriptCommand(context.packageManager, "dev:composer"),
|
|
1069
|
-
description: "Build and start the app with Prisma Composer locally."
|
|
1144
|
+
command: getRunScriptCommand(context.packageManager, context.packageManager === "deno" ? "dev" : "dev:composer"),
|
|
1145
|
+
description: context.packageManager === "deno" ? "Start the Deno app after setting DATABASE_URL in .env." : "Build and start the app with Prisma Composer locally."
|
|
1070
1146
|
});
|
|
1147
|
+
if (context.packageManager === "deno") return nextSteps;
|
|
1071
1148
|
nextSteps.push({
|
|
1072
1149
|
command: getRunScriptCommand(context.packageManager, "deploy"),
|
|
1073
1150
|
description: "Build and deploy the app with Prisma Composer."
|
|
@@ -1338,7 +1415,10 @@ async function collectCreateContext(input) {
|
|
|
1338
1415
|
cancel(`Target directory ${formatPathForDisplay(targetDirectory)} is not empty. Use --force to continue.`);
|
|
1339
1416
|
return;
|
|
1340
1417
|
}
|
|
1341
|
-
const prismaSetupContext = await collectPrismaSetupContext(input, {
|
|
1418
|
+
const prismaSetupContext = await collectPrismaSetupContext(input, {
|
|
1419
|
+
projectDir: targetDirectory,
|
|
1420
|
+
template
|
|
1421
|
+
});
|
|
1342
1422
|
if (!prismaSetupContext) return;
|
|
1343
1423
|
return {
|
|
1344
1424
|
targetDirectory,
|
package/dist/index.d.mts
CHANGED
|
@@ -186,6 +186,7 @@ declare const PackageManagerSchema: z.ZodEnum<{
|
|
|
186
186
|
pnpm: "pnpm";
|
|
187
187
|
yarn: "yarn";
|
|
188
188
|
bun: "bun";
|
|
189
|
+
deno: "deno";
|
|
189
190
|
}>;
|
|
190
191
|
declare const AuthoringStyleSchema: z.ZodEnum<{
|
|
191
192
|
psl: "psl";
|
|
@@ -220,6 +221,7 @@ declare const CreateCommandInputSchema: z.ZodObject<{
|
|
|
220
221
|
pnpm: "pnpm";
|
|
221
222
|
yarn: "yarn";
|
|
222
223
|
bun: "bun";
|
|
224
|
+
deno: "deno";
|
|
223
225
|
}>>;
|
|
224
226
|
deploy: z.ZodOptional<z.ZodBoolean>;
|
|
225
227
|
workspace: z.ZodOptional<z.ZodString>;
|
|
@@ -259,6 +261,7 @@ declare const router: {
|
|
|
259
261
|
pnpm: "pnpm";
|
|
260
262
|
yarn: "yarn";
|
|
261
263
|
bun: "bun";
|
|
264
|
+
deno: "deno";
|
|
262
265
|
}>>;
|
|
263
266
|
deploy: z.ZodOptional<z.ZodBoolean>;
|
|
264
267
|
workspace: z.ZodOptional<z.ZodString>;
|
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-
|
|
2
|
+
import { a as DatabaseProviderSchema, i as CreateTemplateSchema, n as AuthoringStyleSchema, o as PackageManagerSchema, r as CreateCommandInputSchema, t as runCreateCommand } from "./create-CsM1p1qA.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.
|
|
8
|
+
const CLI_VERSION = "0.9.0";
|
|
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,5 +1,37 @@
|
|
|
1
1
|
# {{projectName}}
|
|
2
2
|
|
|
3
|
+
{{#if (eq packageManager "deno")}}
|
|
4
|
+
A minimal Prisma 8 app for Deno and PostgreSQL.
|
|
5
|
+
|
|
6
|
+
## Run locally
|
|
7
|
+
|
|
8
|
+
Copy `.env.example` to `.env`, set `DATABASE_URL`, then initialize the database:
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
deno task db:init
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Start the app:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
deno task dev
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
The starter users are inserted idempotently from `src/prisma/seed.ts` on the first database query.
|
|
21
|
+
|
|
22
|
+
## Prisma
|
|
23
|
+
|
|
24
|
+
- Contract: `src/prisma/contract{{#if (eq authoring "typescript")}}.ts{{else}}.prisma{{/if}}`
|
|
25
|
+
- Prisma config: `prisma-next.config.ts`
|
|
26
|
+
|
|
27
|
+
After changing the contract, run:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
deno task contract:emit
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Prisma Compute does not support Deno deployments yet.
|
|
34
|
+
{{else}}
|
|
3
35
|
A minimal {{template}} app with Prisma 8 and Prisma Composer.
|
|
4
36
|
|
|
5
37
|
## Run locally
|
|
@@ -37,3 +69,4 @@ After changing the contract, run:
|
|
|
37
69
|
```
|
|
38
70
|
|
|
39
71
|
To use the framework's development server directly, run `{{runScriptCommand packageManager "dev"}}`. This direct mode requires `DATABASE_URL`.
|
|
72
|
+
{{/if}}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
{{#unless (eq packageManager "deno")}}
|
|
1
2
|
import { module } from "@prisma/composer";
|
|
2
3
|
{{#if (eq provider "postgres")}}
|
|
3
4
|
import { pnPostgres } from "@prisma/composer-prisma-cloud/prisma-next";
|
|
@@ -26,3 +27,4 @@ export default module("{{projectName}}", ({ provision }) => {
|
|
|
26
27
|
});
|
|
27
28
|
{{/if}}
|
|
28
29
|
});
|
|
30
|
+
{{/unless}}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
{{#unless (eq packageManager "deno")}}
|
|
1
2
|
import { defineConfig } from "@prisma/composer/config";
|
|
2
3
|
import { nodeBuild } from "@prisma/composer/node/control";
|
|
3
4
|
{{#if (eq template "next")}}
|
|
@@ -9,3 +10,4 @@ export default defineConfig({
|
|
|
9
10
|
extensions: [prismaCloud(), nodeBuild(){{#if (eq template "next")}}, nextjsBuild(){{/if}}],
|
|
10
11
|
state: prismaState(),
|
|
11
12
|
});
|
|
13
|
+
{{/unless}}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
{{#unless (eq packageManager "deno")}}
|
|
1
2
|
import { definePrismaConfig } from "@prisma/cli-engine";
|
|
2
3
|
import { defineConfig as ormConfig } from "@prisma/orm-{{#if (eq provider "postgres")}}postgres{{else}}mongo{{/if}}/config";
|
|
3
4
|
|
|
@@ -15,3 +16,4 @@ export default definePrismaConfig({
|
|
|
15
16
|
configPath: "./prisma-composer.config.ts",
|
|
16
17
|
},
|
|
17
18
|
});
|
|
19
|
+
{{/unless}}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
{{#unless (eq packageManager "deno")}}
|
|
1
2
|
{{#if (eq template "next")}}
|
|
2
3
|
import nextjs from "@prisma/composer/nextjs";
|
|
3
4
|
{{else}}
|
|
@@ -40,3 +41,4 @@ export default compute({
|
|
|
40
41
|
build: node({ module: import.meta.url, entry: "./dist/server.mjs" }),
|
|
41
42
|
{{/if}}
|
|
42
43
|
});
|
|
44
|
+
{{/unless}}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
{{#unless (eq packageManager "deno")}}
|
|
1
2
|
{{#if (eq provider "postgres")}}
|
|
2
3
|
import { pnContract } from "@prisma/composer-prisma-cloud/prisma-next";
|
|
3
4
|
|
|
@@ -6,3 +7,4 @@ import contractJson from "./{{#if (eq authoring "typescript")}}generated/{{/if}}
|
|
|
6
7
|
|
|
7
8
|
export const appContract = pnContract<Contract>(contractJson);
|
|
8
9
|
{{/if}}
|
|
10
|
+
{{/unless}}
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
{{#if (eq provider "postgres")}}
|
|
2
2
|
import postgres from "@prisma/orm-postgres/runtime";
|
|
3
3
|
|
|
4
|
+
{{#if (eq packageManager "deno")}}
|
|
5
|
+
import type { Contract } from "./{{#if (eq authoring "typescript")}}generated/{{/if}}contract.d.ts";
|
|
6
|
+
import contractJson from "./{{#if (eq authoring "typescript")}}generated/{{/if}}contract.json" with { type: "json" };
|
|
7
|
+
|
|
8
|
+
const databaseUrl = Deno.env.get("DATABASE_URL");
|
|
9
|
+
if (!databaseUrl) {
|
|
10
|
+
throw new Error("DATABASE_URL is not set. Add it to .env before starting the app.");
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const db = postgres<Contract>({ contractJson, url: databaseUrl });
|
|
14
|
+
{{else}}
|
|
4
15
|
import service from "../../service.ts";
|
|
5
16
|
import type { Contract } from "./{{#if (eq authoring "typescript")}}generated/{{/if}}contract.d.ts";
|
|
6
17
|
import contractJson from "./{{#if (eq authoring "typescript")}}generated/{{/if}}contract.json" with { type: "json" };
|
|
@@ -18,6 +29,7 @@ export const db =
|
|
|
18
29
|
(process.env.DATABASE_URL
|
|
19
30
|
? postgres<Contract>({ contractJson, url: process.env.DATABASE_URL })
|
|
20
31
|
: postgres<Contract>({ contractJson }));
|
|
32
|
+
{{/if}}
|
|
21
33
|
{{else}}
|
|
22
34
|
import mongo from "@prisma/orm-mongo/runtime";
|
|
23
35
|
|
|
@@ -6,9 +6,15 @@
|
|
|
6
6
|
{{/if}}
|
|
7
7
|
"type": "module",
|
|
8
8
|
"scripts": {
|
|
9
|
+
{{#if (eq packageManager "deno")}}
|
|
10
|
+
"dev": "{{runtimeScript packageManager "dev" "src/index.ts" "dist/server.mjs"}}",
|
|
11
|
+
"build": "{{runtimeScript packageManager "build" "src/index.ts" "dist/server.mjs"}}",
|
|
12
|
+
"start": "{{runtimeScript packageManager "start" "src/index.ts" "dist/server.mjs"}}"
|
|
13
|
+
{{else}}
|
|
9
14
|
"dev": "tsx watch src/index.ts",
|
|
10
15
|
"build": "esbuild src/index.ts --bundle --platform=node --format=esm --outfile=dist/server.mjs",
|
|
11
16
|
"start": "node dist/server.mjs"
|
|
17
|
+
{{/if}}
|
|
12
18
|
},
|
|
13
19
|
"dependencies": {},
|
|
14
20
|
"devDependencies": {}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createServer } from "node:http";
|
|
2
2
|
|
|
3
|
-
import { listUsers } from "./prisma/users";
|
|
3
|
+
import { listUsers } from "./prisma/users{{#if (eq packageManager "deno")}}.ts{{/if}}";
|
|
4
4
|
|
|
5
|
-
const port = Number(process.env.PORT ?? 3000);
|
|
5
|
+
const port = Number({{#if (eq packageManager "deno")}}Deno.env.get("PORT"){{else}}process.env.PORT{{/if}} ?? 3000);
|
|
6
6
|
|
|
7
7
|
createServer(async (_request, response) => {
|
|
8
8
|
try {
|