create-prisma 0.11.0-pr.79.273.1 → 0.11.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 +1 -2
- package/dist/cli.mjs +1 -1
- package/dist/{create-BSrHf28U.mjs → create-DX_T1T1y.mjs} +27 -60
- package/dist/index.d.mts +0 -3
- package/dist/index.mjs +2 -2
- package/package.json +1 -1
- package/templates/create/_shared/.gitattributes.hbs +6 -6
- package/templates/create/_shared/README.md.hbs +0 -44
- package/templates/create/_shared/module.ts.hbs +1 -1
- package/templates/create/_shared/pnpm-workspace.yaml.hbs +1 -6
- package/templates/create/_shared/prisma-composer.config.ts.hbs +2 -2
- package/templates/create/_shared/prisma.config.ts.hbs +4 -4
- package/templates/create/_shared/service.ts.hbs +2 -4
- package/templates/create/_shared/src/prisma/db.ts.hbs +2 -2
- package/templates/create/next/.yarnrc.yml.hbs +0 -2
- package/templates/create/next/next.config.ts +7 -0
- package/templates/create/next/package.json.hbs +2 -8
- package/templates/create/next/src/app/page.tsx.hbs +4 -4
- package/templates/create/next/next.config.ts.hbs +0 -19
- package/templates/create/turborepo/.yarnrc.yml.hbs +0 -3
- package/templates/create/turborepo/package.json.hbs +0 -21
- package/templates/create/turborepo/packages/database/package.json +0 -13
- package/templates/create/turborepo/packages/database/tsconfig.json +0 -4
- package/templates/create/turborepo/tsconfig.json +0 -22
- package/templates/create/turborepo/turbo.json +0 -24
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ yarn dlx create-prisma@latest my-app
|
|
|
13
13
|
bunx create-prisma@latest my-app
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
-
The CLI initializes Prisma 8 with
|
|
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.
|
|
17
17
|
|
|
18
18
|
The deployment prompt is:
|
|
19
19
|
|
|
@@ -34,7 +34,6 @@ workspace. Choosing another workspace also updates the Prisma CLI's active works
|
|
|
34
34
|
- `elysia`
|
|
35
35
|
- `nest`
|
|
36
36
|
- `next`
|
|
37
|
-
- `turborepo` (Next.js monorepo with a shared Prisma database package)
|
|
38
37
|
- `svelte` (SvelteKit)
|
|
39
38
|
- `astro`
|
|
40
39
|
- `nuxt`
|
package/dist/cli.mjs
CHANGED
|
@@ -52,12 +52,21 @@ function createCommandFailureResult(stage, message, project) {
|
|
|
52
52
|
|
|
53
53
|
//#endregion
|
|
54
54
|
//#region src/telemetry/client.ts
|
|
55
|
-
const TELEMETRY_API_KEY = "";
|
|
55
|
+
const TELEMETRY_API_KEY = "phc_cmc85avbWyuJ2JyKdGPdv7dxXli8xLdWDBPbvIXWJfs";
|
|
56
56
|
const TELEMETRY_HOST = "https://us.i.posthog.com";
|
|
57
57
|
const TELEMETRY_CONFIG_FILE = "telemetry.json";
|
|
58
58
|
const UUID_V4_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
59
|
+
function isTruthyEnvValue(value) {
|
|
60
|
+
return [
|
|
61
|
+
"1",
|
|
62
|
+
"true",
|
|
63
|
+
"yes",
|
|
64
|
+
"on"
|
|
65
|
+
].includes(String(value ?? "").trim().toLowerCase());
|
|
66
|
+
}
|
|
59
67
|
function shouldDisableTelemetry() {
|
|
60
|
-
return true;
|
|
68
|
+
if (isTruthyEnvValue(process.env.CI) || isTruthyEnvValue(process.env.GITHUB_ACTIONS)) return true;
|
|
69
|
+
return process.env.CREATE_PRISMA_DISABLE_TELEMETRY !== void 0 || process.env.CREATE_PRISMA_TELEMETRY_DISABLED !== void 0 || process.env.DO_NOT_TRACK !== void 0;
|
|
61
70
|
}
|
|
62
71
|
function getTelemetryConfigDir() {
|
|
63
72
|
if (process.platform === "darwin") return path.join(os.homedir(), "Library", "Application Support", "create-prisma");
|
|
@@ -79,7 +88,7 @@ async function getAnonymousId() {
|
|
|
79
88
|
}
|
|
80
89
|
function getCommonProperties() {
|
|
81
90
|
return {
|
|
82
|
-
"cli-version": "0.11.0
|
|
91
|
+
"cli-version": "0.11.0",
|
|
83
92
|
"node-version": process.version,
|
|
84
93
|
platform: process.platform,
|
|
85
94
|
arch: process.arch
|
|
@@ -198,7 +207,6 @@ const createTemplates = [
|
|
|
198
207
|
"elysia",
|
|
199
208
|
"nest",
|
|
200
209
|
"next",
|
|
201
|
-
"turborepo",
|
|
202
210
|
"svelte",
|
|
203
211
|
"astro",
|
|
204
212
|
"nuxt",
|
|
@@ -421,7 +429,6 @@ function getRunScriptArgs(packageManager, scriptName) {
|
|
|
421
429
|
//#endregion
|
|
422
430
|
//#region src/templates/shared.ts
|
|
423
431
|
Handlebars.registerHelper("eq", (left, right) => left === right);
|
|
424
|
-
Handlebars.registerHelper("or", (...args) => args.slice(0, -1).some(Boolean));
|
|
425
432
|
Handlebars.registerHelper("runScriptCommand", (packageManager, scriptName) => packageManager ? getRunScriptCommand(packageManager, scriptName) : "");
|
|
426
433
|
Handlebars.registerHelper("packageManagerManifestValue", (packageManager) => getPackageManagerManifestValue(packageManager) ?? "");
|
|
427
434
|
Handlebars.registerHelper("runtimeScript", (packageManager, kind, sourceEntrypoint, builtEntrypoint, _options) => {
|
|
@@ -474,11 +481,10 @@ async function renderTemplateFile(opts) {
|
|
|
474
481
|
await fs.outputFile(outputPath, ensureTrailingNewline(outputContent), "utf8");
|
|
475
482
|
}
|
|
476
483
|
async function renderTemplateTree(opts) {
|
|
477
|
-
const { templateRoot, outputDir, context
|
|
484
|
+
const { templateRoot, outputDir, context } = opts;
|
|
478
485
|
const templateFiles = await getTemplateFilesRecursively(templateRoot);
|
|
479
486
|
for (const templateFilePath of templateFiles) {
|
|
480
|
-
const
|
|
481
|
-
const relativeOutputPath = mapRelativeOutputPath ? mapRelativeOutputPath(renderedRelativePath) : renderedRelativePath;
|
|
487
|
+
const relativeOutputPath = stripHbsExtension(path.relative(templateRoot, templateFilePath));
|
|
482
488
|
await renderTemplateFile({
|
|
483
489
|
templateFilePath,
|
|
484
490
|
outputPath: path.join(outputDir, relativeOutputPath),
|
|
@@ -489,17 +495,12 @@ async function renderTemplateTree(opts) {
|
|
|
489
495
|
|
|
490
496
|
//#endregion
|
|
491
497
|
//#region src/templates/render-create-template.ts
|
|
492
|
-
const DEFAULT_PRISMA_SOURCE_DIR = "src/prisma";
|
|
493
|
-
const TURBOREPO_PRISMA_SOURCE_DIR = "packages/database/src";
|
|
494
498
|
function getCreateTemplateDir(template) {
|
|
495
499
|
return resolveTemplatesDir(`templates/create/${template}`);
|
|
496
500
|
}
|
|
497
501
|
function getCreateSharedTemplateDir() {
|
|
498
502
|
return resolveTemplatesDir("templates/create/_shared");
|
|
499
503
|
}
|
|
500
|
-
function getCreatePrismaSourceDir(template) {
|
|
501
|
-
return template === "turborepo" ? TURBOREPO_PRISMA_SOURCE_DIR : DEFAULT_PRISMA_SOURCE_DIR;
|
|
502
|
-
}
|
|
503
504
|
function createTemplateContext(projectName, template, provider, authoring, packageManager) {
|
|
504
505
|
return {
|
|
505
506
|
projectName,
|
|
@@ -514,28 +515,15 @@ async function scaffoldCreateSharedTemplates(opts) {
|
|
|
514
515
|
await renderTemplateTree({
|
|
515
516
|
templateRoot: getCreateSharedTemplateDir(),
|
|
516
517
|
outputDir: projectDir,
|
|
517
|
-
context: createTemplateContext(projectName, template, provider, authoring, packageManager)
|
|
518
|
-
mapRelativeOutputPath(relativePath) {
|
|
519
|
-
if (template !== "turborepo") return relativePath;
|
|
520
|
-
const relativePrismaPath = path.relative(DEFAULT_PRISMA_SOURCE_DIR, relativePath);
|
|
521
|
-
if (relativePrismaPath === "" || relativePrismaPath === ".." || relativePrismaPath.startsWith(`..${path.sep}`)) return relativePath;
|
|
522
|
-
return path.join(TURBOREPO_PRISMA_SOURCE_DIR, relativePrismaPath);
|
|
523
|
-
}
|
|
518
|
+
context: createTemplateContext(projectName, template, provider, authoring, packageManager)
|
|
524
519
|
});
|
|
525
520
|
}
|
|
526
521
|
async function scaffoldCreateFrameworkTemplate(opts) {
|
|
527
522
|
const { projectDir, projectName, template, provider, authoring, packageManager } = opts;
|
|
528
|
-
const templateRoot = getCreateTemplateDir(template);
|
|
529
|
-
const context = createTemplateContext(projectName, template, provider, authoring, packageManager);
|
|
530
523
|
await renderTemplateTree({
|
|
531
|
-
templateRoot,
|
|
524
|
+
templateRoot: getCreateTemplateDir(template),
|
|
532
525
|
outputDir: projectDir,
|
|
533
|
-
context
|
|
534
|
-
});
|
|
535
|
-
if (template === "turborepo") await renderTemplateTree({
|
|
536
|
-
templateRoot: getCreateTemplateDir("next"),
|
|
537
|
-
outputDir: path.join(projectDir, "apps/web"),
|
|
538
|
-
context
|
|
526
|
+
context: createTemplateContext(projectName, template, provider, authoring, packageManager)
|
|
539
527
|
});
|
|
540
528
|
}
|
|
541
529
|
|
|
@@ -560,7 +548,6 @@ const dependencyVersionMap = {
|
|
|
560
548
|
nitro: "^3.0.260610-beta",
|
|
561
549
|
prisma: "8.0.0-rc.12",
|
|
562
550
|
"temporal-polyfill": "^1.0.4",
|
|
563
|
-
turbo: "2.10.12",
|
|
564
551
|
tsx: "^4.21.0",
|
|
565
552
|
typescript: "^5.9.3"
|
|
566
553
|
};
|
|
@@ -589,18 +576,11 @@ function getCreateTemplateDependencies(template, _packageManager) {
|
|
|
589
576
|
if (template === "svelte") devDependencies.push("@sveltejs/adapter-node");
|
|
590
577
|
if (template === "astro") dependencies.push("@astrojs/node");
|
|
591
578
|
if (template === "tanstack-start") devDependencies.push("nitro");
|
|
592
|
-
|
|
593
|
-
const targets = [{
|
|
579
|
+
return [{
|
|
594
580
|
packageJsonPath: "package.json",
|
|
595
581
|
dependencies,
|
|
596
582
|
devDependencies
|
|
597
583
|
}];
|
|
598
|
-
if (template === "turborepo") targets.push({
|
|
599
|
-
packageJsonPath: "packages/database/package.json",
|
|
600
|
-
dependencies: [],
|
|
601
|
-
devDependencies: ["typescript"]
|
|
602
|
-
});
|
|
603
|
-
return targets;
|
|
604
584
|
}
|
|
605
585
|
|
|
606
586
|
//#endregion
|
|
@@ -709,9 +689,9 @@ async function addPackageDependency(opts) {
|
|
|
709
689
|
pkgJson.scripts = sortRecord(pkgJson.scripts);
|
|
710
690
|
await fs.writeJson(pkgJsonPath, pkgJson, { spaces: 2 });
|
|
711
691
|
}
|
|
712
|
-
async function writePrismaDependencies(provider, packageManager, _authoring, projectDir = process.cwd()
|
|
692
|
+
async function writePrismaDependencies(provider, packageManager, _authoring, projectDir = process.cwd()) {
|
|
713
693
|
const dependencies = [getDbPackages(provider)];
|
|
714
|
-
if (provider === "postgres" && packageManager !== "deno"
|
|
694
|
+
if (provider === "postgres" && packageManager !== "deno") dependencies.push("temporal-polyfill");
|
|
715
695
|
if (provider === "mongo") dependencies.push("arktype", "mongodb");
|
|
716
696
|
if (packageManager === "deno") dependencies.push("dotenv");
|
|
717
697
|
await addPackageDependency({
|
|
@@ -720,14 +700,6 @@ async function writePrismaDependencies(provider, packageManager, _authoring, pro
|
|
|
720
700
|
scripts: getPrismaScriptMap(packageManager),
|
|
721
701
|
projectDir
|
|
722
702
|
});
|
|
723
|
-
if (template === "turborepo" && packageManager !== "deno") {
|
|
724
|
-
const databaseDependencies = [getDbPackages(provider)];
|
|
725
|
-
if (provider === "postgres") databaseDependencies.push("temporal-polyfill");
|
|
726
|
-
await addPackageDependency({
|
|
727
|
-
dependencies: databaseDependencies,
|
|
728
|
-
projectDir: path.join(projectDir, "packages/database")
|
|
729
|
-
});
|
|
730
|
-
}
|
|
731
703
|
}
|
|
732
704
|
async function writeCreateTemplateDependencies(opts) {
|
|
733
705
|
const { template, packageManager, projectDir = process.cwd() } = opts;
|
|
@@ -736,7 +708,7 @@ async function writeCreateTemplateDependencies(opts) {
|
|
|
736
708
|
dependencies: target.dependencies,
|
|
737
709
|
devDependencies: target.devDependencies,
|
|
738
710
|
customDependencies: target.customDependencies,
|
|
739
|
-
scripts:
|
|
711
|
+
scripts: getComposerScriptMap(packageManager),
|
|
740
712
|
projectDir: path.join(projectDir, path.dirname(target.packageJsonPath))
|
|
741
713
|
});
|
|
742
714
|
const packageJsonPath = path.join(projectDir, "package.json");
|
|
@@ -1314,8 +1286,8 @@ async function collectPrismaSetupContext(input, options = {}) {
|
|
|
1314
1286
|
...input.workspace ? { workspace: input.workspace } : {}
|
|
1315
1287
|
};
|
|
1316
1288
|
}
|
|
1317
|
-
function getContractPath(authoring
|
|
1318
|
-
return
|
|
1289
|
+
function getContractPath(authoring) {
|
|
1290
|
+
return `src/prisma/contract${authoring === "typescript" ? ".ts" : ".prisma"}`;
|
|
1319
1291
|
}
|
|
1320
1292
|
function getInitTarget(provider) {
|
|
1321
1293
|
return provider === "mongo" ? "mongodb" : "postgres";
|
|
@@ -1323,7 +1295,7 @@ function getInitTarget(provider) {
|
|
|
1323
1295
|
function getPrismaCliInvocation(packageManager, args) {
|
|
1324
1296
|
return getPackageExecutionArgs(packageManager, [packageManager === "deno" ? PRISMA_DENO_CLI_PACKAGE : PRISMA_PLATFORM_CLI_PACKAGE, ...args]);
|
|
1325
1297
|
}
|
|
1326
|
-
async function runPrismaInit(context, projectDir
|
|
1298
|
+
async function runPrismaInit(context, projectDir) {
|
|
1327
1299
|
const args = [
|
|
1328
1300
|
"orm",
|
|
1329
1301
|
"init",
|
|
@@ -1334,7 +1306,7 @@ async function runPrismaInit(context, projectDir, template) {
|
|
|
1334
1306
|
"--authoring",
|
|
1335
1307
|
context.authoring,
|
|
1336
1308
|
"--schema-path",
|
|
1337
|
-
getContractPath(context.authoring
|
|
1309
|
+
getContractPath(context.authoring),
|
|
1338
1310
|
"--skip-install"
|
|
1339
1311
|
];
|
|
1340
1312
|
const invocation = getPrismaCliInvocation(context.packageManager, args);
|
|
@@ -1468,7 +1440,7 @@ async function executePrismaSetupContext(context, options = {}) {
|
|
|
1468
1440
|
if (ownsProgress) progress.start("Creating Prisma 8 project...");
|
|
1469
1441
|
try {
|
|
1470
1442
|
progress?.message("Preparing Prisma 8 project files...");
|
|
1471
|
-
await runPrismaInit(context, projectDir
|
|
1443
|
+
await runPrismaInit(context, projectDir);
|
|
1472
1444
|
setupStage = "configure_project";
|
|
1473
1445
|
setupReason = "project_configuration_failed";
|
|
1474
1446
|
await scaffoldCreateSharedTemplates({
|
|
@@ -1479,7 +1451,7 @@ async function executePrismaSetupContext(context, options = {}) {
|
|
|
1479
1451
|
authoring: context.authoring,
|
|
1480
1452
|
packageManager: context.packageManager
|
|
1481
1453
|
});
|
|
1482
|
-
await writePrismaDependencies(context.databaseProvider, context.packageManager, context.authoring, projectDir
|
|
1454
|
+
await writePrismaDependencies(context.databaseProvider, context.packageManager, context.authoring, projectDir);
|
|
1483
1455
|
await ensureComposerTypeScriptOptions(projectDir);
|
|
1484
1456
|
if (context.databaseProvider === "mongo") await ensureMongoEnvironment(projectDir);
|
|
1485
1457
|
if (context.packageManager !== "deno") {
|
|
@@ -1683,11 +1655,6 @@ async function promptForCreateTemplate(output) {
|
|
|
1683
1655
|
label: "Next.js",
|
|
1684
1656
|
hint: "Full-stack React app with App Router"
|
|
1685
1657
|
},
|
|
1686
|
-
{
|
|
1687
|
-
value: "turborepo",
|
|
1688
|
-
label: "Monorepo (Turborepo)",
|
|
1689
|
-
hint: "Next.js app with a shared Prisma database package"
|
|
1690
|
-
},
|
|
1691
1658
|
{
|
|
1692
1659
|
value: "svelte",
|
|
1693
1660
|
label: "SvelteKit",
|
package/dist/index.d.mts
CHANGED
|
@@ -35,7 +35,6 @@ declare const CreateTemplateSchema: z.ZodEnum<{
|
|
|
35
35
|
elysia: "elysia";
|
|
36
36
|
nest: "nest";
|
|
37
37
|
next: "next";
|
|
38
|
-
turborepo: "turborepo";
|
|
39
38
|
svelte: "svelte";
|
|
40
39
|
astro: "astro";
|
|
41
40
|
nuxt: "nuxt";
|
|
@@ -72,7 +71,6 @@ declare const CreateCommandInputSchema: z.ZodObject<{
|
|
|
72
71
|
elysia: "elysia";
|
|
73
72
|
nest: "nest";
|
|
74
73
|
next: "next";
|
|
75
|
-
turborepo: "turborepo";
|
|
76
74
|
svelte: "svelte";
|
|
77
75
|
astro: "astro";
|
|
78
76
|
nuxt: "nuxt";
|
|
@@ -336,7 +334,6 @@ declare const router: {
|
|
|
336
334
|
elysia: "elysia";
|
|
337
335
|
nest: "nest";
|
|
338
336
|
next: "next";
|
|
339
|
-
turborepo: "turborepo";
|
|
340
337
|
svelte: "svelte";
|
|
341
338
|
astro: "astro";
|
|
342
339
|
nuxt: "nuxt";
|
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, s as CREATE_PRISMA_RESULT_SCHEMA_VERSION, t as runCreateCommand } from "./create-
|
|
2
|
+
import { a as DatabaseProviderSchema, i as CreateTemplateSchema, n as AuthoringStyleSchema, o as PackageManagerSchema, r as CreateCommandInputSchema, s as CREATE_PRISMA_RESULT_SCHEMA_VERSION, t as runCreateCommand } from "./create-DX_T1T1y.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.11.0
|
|
8
|
+
const CLI_VERSION = "0.11.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,11 +1,11 @@
|
|
|
1
1
|
{{#if (eq authoring "typescript")}}
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
src/prisma/generated/contract.json linguist-generated
|
|
3
|
+
src/prisma/generated/contract.d.ts linguist-generated
|
|
4
4
|
{{else}}
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
src/prisma/contract.json linguist-generated
|
|
6
|
+
src/prisma/contract.d.ts linguist-generated
|
|
7
7
|
{{/if}}
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
src/prisma/ops.json linguist-generated
|
|
9
|
+
src/prisma/migration.json linguist-generated
|
|
10
10
|
migrations/snapshots/**/contract.json linguist-generated
|
|
11
11
|
migrations/snapshots/**/contract.d.ts linguist-generated
|
|
@@ -31,50 +31,6 @@ deno task contract:emit
|
|
|
31
31
|
```
|
|
32
32
|
|
|
33
33
|
Prisma Compute does not support Deno deployments yet.
|
|
34
|
-
{{else if (eq template "turborepo")}}
|
|
35
|
-
A Prisma 8 monorepo powered by Turborepo, Next.js, and Prisma Composer.
|
|
36
|
-
|
|
37
|
-
## Workspace layout
|
|
38
|
-
|
|
39
|
-
- `apps/web` — Next.js application
|
|
40
|
-
- `packages/database` — Prisma contract, generated artifacts, runtime client, and seed data
|
|
41
|
-
- `module.ts` and `service.ts` — Composer deployment topology
|
|
42
|
-
|
|
43
|
-
## Run locally
|
|
44
|
-
|
|
45
|
-
```bash
|
|
46
|
-
{{runScriptCommand packageManager "dev:composer"}}
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
This builds the workspace and starts it with Composer. PostgreSQL projects get a local Prisma Postgres database and apply the committed migrations automatically.
|
|
50
|
-
|
|
51
|
-
## Deploy
|
|
52
|
-
|
|
53
|
-
```bash
|
|
54
|
-
{{runScriptCommand packageManager "deploy"}}
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
The deploy script runs the Turborepo build, provisions Prisma Postgres when selected, applies migrations, and deploys the Next.js app to Prisma Compute.
|
|
58
|
-
|
|
59
|
-
The starter users are inserted idempotently from `packages/database/src/seed.ts` on the first database query through the Composer service binding.
|
|
60
|
-
|
|
61
|
-
{{#if (eq provider "mongo")}}
|
|
62
|
-
MongoDB is not provisioned by Composer. Set `MONGODB_URL` before running Composer locally or deploying.
|
|
63
|
-
{{/if}}
|
|
64
|
-
|
|
65
|
-
## Prisma
|
|
66
|
-
|
|
67
|
-
- Contract: `packages/database/src/contract{{#if (eq authoring "typescript")}}.ts{{else}}.prisma{{/if}}`
|
|
68
|
-
- Prisma and Composer config: `prisma.config.ts`
|
|
69
|
-
- Composer app: `module.ts` and `service.ts`
|
|
70
|
-
|
|
71
|
-
After changing the contract, run:
|
|
72
|
-
|
|
73
|
-
```bash
|
|
74
|
-
{{runScriptCommand packageManager "contract:emit"}}
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
To run the workspace's development tasks directly, use `{{runScriptCommand packageManager "dev"}}`. This direct mode requires `{{#if (eq provider "postgres")}}DATABASE_URL{{else}}MONGODB_URL{{/if}}`.
|
|
78
34
|
{{else}}
|
|
79
35
|
A minimal {{template}} app with Prisma 8 and Prisma Composer.
|
|
80
36
|
|
|
@@ -3,7 +3,7 @@ import { module } from "@prisma/composer";
|
|
|
3
3
|
{{#if (eq provider "postgres")}}
|
|
4
4
|
import { postgres } from "@prisma/composer-prisma-cloud/orm";
|
|
5
5
|
|
|
6
|
-
import { appContract } from "./
|
|
6
|
+
import { appContract } from "./src/prisma/composer.ts";
|
|
7
7
|
{{else}}
|
|
8
8
|
import { envSecret } from "@prisma/composer-prisma-cloud";
|
|
9
9
|
{{/if}}
|
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
{{#if (eq packageManager "pnpm")}}
|
|
2
|
-
{{#if (eq template "turborepo")}}
|
|
3
|
-
packages:
|
|
4
|
-
- "apps/*"
|
|
5
|
-
- "packages/*"
|
|
6
|
-
{{/if}}
|
|
7
2
|
allowBuilds:
|
|
8
3
|
esbuild: true
|
|
9
4
|
msgpackr-extract: true
|
|
10
|
-
{{#if (
|
|
5
|
+
{{#if (eq template "next")}}
|
|
11
6
|
sharp: true
|
|
12
7
|
unrs-resolver: true
|
|
13
8
|
{{else if (eq template "astro")}}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{{#unless (eq packageManager "deno")}}
|
|
2
2
|
import { defineConfig } from "@prisma/composer/config";
|
|
3
3
|
import { nodeBuild } from "@prisma/composer/node/control";
|
|
4
|
-
{{#if (
|
|
4
|
+
{{#if (eq template "next")}}
|
|
5
5
|
import { nextjsBuild } from "@prisma/composer/nextjs/control";
|
|
6
6
|
{{/if}}
|
|
7
7
|
import { prismaCloud, prismaState } from "@prisma/composer-prisma-cloud/control";
|
|
8
8
|
|
|
9
9
|
export default defineConfig({
|
|
10
|
-
extensions: [prismaCloud(), nodeBuild(){{#if (
|
|
10
|
+
extensions: [prismaCloud(), nodeBuild(){{#if (eq template "next")}}, nextjsBuild(){{/if}}],
|
|
11
11
|
state: prismaState(),
|
|
12
12
|
});
|
|
13
13
|
{{/unless}}
|
|
@@ -5,9 +5,9 @@ import { defineConfig as ormConfig } from "@prisma/orm-{{#if (eq provider "postg
|
|
|
5
5
|
|
|
6
6
|
export default definePrismaConfig({
|
|
7
7
|
orm: ormConfig({
|
|
8
|
-
contract: "./
|
|
8
|
+
contract: "./src/prisma/contract{{#if (eq authoring "typescript")}}.ts{{else}}.prisma{{/if}}",
|
|
9
9
|
{{#if (eq authoring "typescript")}}
|
|
10
|
-
output: "./
|
|
10
|
+
output: "./src/prisma/generated",
|
|
11
11
|
{{/if}}
|
|
12
12
|
db: {
|
|
13
13
|
connection: process.env.{{#if (eq provider "postgres")}}DATABASE_URL{{else}}MONGODB_URL{{/if}}!,
|
|
@@ -23,9 +23,9 @@ export default definePrismaConfig({
|
|
|
23
23
|
agents: ["claude", "cursor", "agents", "devin"],
|
|
24
24
|
},
|
|
25
25
|
orm: ormConfig({
|
|
26
|
-
contract: "./
|
|
26
|
+
contract: "./src/prisma/contract{{#if (eq authoring "typescript")}}.ts{{else}}.prisma{{/if}}",
|
|
27
27
|
{{#if (eq authoring "typescript")}}
|
|
28
|
-
output: "./
|
|
28
|
+
output: "./src/prisma/generated",
|
|
29
29
|
{{/if}}
|
|
30
30
|
db: {
|
|
31
31
|
connection: process.env.{{#if (eq provider "postgres")}}DATABASE_URL{{else}}MONGODB_URL{{/if}}!,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{{#unless (eq packageManager "deno")}}
|
|
2
|
-
{{#if (
|
|
2
|
+
{{#if (eq template "next")}}
|
|
3
3
|
import nextjs from "@prisma/composer/nextjs";
|
|
4
4
|
{{else}}
|
|
5
5
|
import node from "@prisma/composer/node";
|
|
@@ -12,7 +12,7 @@ import { compute } from "@prisma/composer-prisma-cloud";
|
|
|
12
12
|
{{#if (eq provider "postgres")}}
|
|
13
13
|
import { postgres } from "@prisma/composer-prisma-cloud/orm";
|
|
14
14
|
|
|
15
|
-
import { appContract } from "./
|
|
15
|
+
import { appContract } from "./src/prisma/composer.ts";
|
|
16
16
|
{{/if}}
|
|
17
17
|
|
|
18
18
|
export default compute({
|
|
@@ -29,8 +29,6 @@ export default compute({
|
|
|
29
29
|
{{/if}}
|
|
30
30
|
{{#if (eq template "next")}}
|
|
31
31
|
build: nextjs({ module: import.meta.url, appDir: "." }),
|
|
32
|
-
{{else if (eq template "turborepo")}}
|
|
33
|
-
build: nextjs({ module: import.meta.url, appDir: "./apps/web" }),
|
|
34
32
|
{{else if (eq template "svelte")}}
|
|
35
33
|
build: node({ module: import.meta.url, dir: "./build", entry: "index.js" }),
|
|
36
34
|
{{else if (eq template "astro")}}
|
|
@@ -14,7 +14,7 @@ export const db = postgres<Contract>({ contractJson, url: databaseUrl });
|
|
|
14
14
|
{{else}}
|
|
15
15
|
import "temporal-polyfill/global";
|
|
16
16
|
|
|
17
|
-
import service from "
|
|
17
|
+
import service from "../../service.ts";
|
|
18
18
|
import type { Contract } from "./{{#if (eq authoring "typescript")}}generated/{{/if}}contract.d.ts";
|
|
19
19
|
import contractJson from "./{{#if (eq authoring "typescript")}}generated/{{/if}}contract.json" with { type: "json" };
|
|
20
20
|
|
|
@@ -35,7 +35,7 @@ export const db =
|
|
|
35
35
|
{{else}}
|
|
36
36
|
import mongo from "@prisma/orm-mongo/runtime";
|
|
37
37
|
|
|
38
|
-
import service from "
|
|
38
|
+
import service from "../../service.ts";
|
|
39
39
|
import type { Contract } from "./{{#if (eq authoring "typescript")}}generated/{{/if}}contract.d.ts";
|
|
40
40
|
import contractJson from "./{{#if (eq authoring "typescript")}}generated/{{/if}}contract.json" with { type: "json" };
|
|
41
41
|
|
|
@@ -1,24 +1,18 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "{{
|
|
2
|
+
"name": "{{projectName}}",
|
|
3
3
|
"version": "0.1.0",
|
|
4
4
|
"private": true,
|
|
5
|
-
{{#unless (eq template "turborepo")}}
|
|
6
5
|
{{#if (packageManagerManifestValue packageManager)}}
|
|
7
6
|
"packageManager": "{{packageManagerManifestValue packageManager}}",
|
|
8
7
|
{{/if}}
|
|
9
|
-
{{/unless}}
|
|
10
8
|
"type": "module",
|
|
11
9
|
"scripts": {
|
|
12
10
|
"dev": "next dev",
|
|
13
11
|
"build": "next build",
|
|
14
12
|
"start": "next start",
|
|
15
|
-
"lint": "eslint"
|
|
16
|
-
"typecheck": "tsc --noEmit"
|
|
13
|
+
"lint": "eslint"
|
|
17
14
|
},
|
|
18
15
|
"dependencies": {
|
|
19
|
-
{{#if (eq template "turborepo")}}
|
|
20
|
-
"@repo/database": "{{#if (eq packageManager "npm")}}*{{else}}workspace:*{{/if}}",
|
|
21
|
-
{{/if}}
|
|
22
16
|
"next": "16.1.6",
|
|
23
17
|
"react": "19.2.3",
|
|
24
18
|
"react-dom": "19.2.3"
|
|
@@ -2,7 +2,7 @@ export const dynamic = "force-dynamic";
|
|
|
2
2
|
|
|
3
3
|
export default async function Home() {
|
|
4
4
|
|
|
5
|
-
const { listUsers } = await import("
|
|
5
|
+
const { listUsers } = await import("../prisma/users");
|
|
6
6
|
const formatter = new Intl.DateTimeFormat("en", {
|
|
7
7
|
dateStyle: "medium",
|
|
8
8
|
timeStyle: "short",
|
|
@@ -12,12 +12,12 @@ export default async function Home() {
|
|
|
12
12
|
return (
|
|
13
13
|
<main className="shell">
|
|
14
14
|
<div className="hero">
|
|
15
|
-
<p className="eyebrow">
|
|
15
|
+
<p className="eyebrow">Next.js + Prisma 8</p>
|
|
16
16
|
|
|
17
17
|
<h1>Users from your database, loaded on the server.</h1>
|
|
18
18
|
<p className="lede">
|
|
19
|
-
This page reads from <code>
|
|
20
|
-
<code>
|
|
19
|
+
This page reads from <code>src/app/page.tsx</code> using the Prisma 8 helper in{" "}
|
|
20
|
+
<code>src/prisma/users.ts</code>.
|
|
21
21
|
</p>
|
|
22
22
|
</div>
|
|
23
23
|
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{{#if (eq template "turborepo")}}
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { fileURLToPath } from "node:url";
|
|
4
|
-
{{/if}}
|
|
5
|
-
import type { NextConfig } from "next";
|
|
6
|
-
|
|
7
|
-
{{#if (eq template "turborepo")}}
|
|
8
|
-
const monorepoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");
|
|
9
|
-
{{/if}}
|
|
10
|
-
|
|
11
|
-
const nextConfig: NextConfig = {
|
|
12
|
-
output: "standalone",
|
|
13
|
-
{{#if (eq template "turborepo")}}
|
|
14
|
-
outputFileTracingRoot: monorepoRoot,
|
|
15
|
-
transpilePackages: ["@repo/database"],
|
|
16
|
-
{{/if}}
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export default nextConfig;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "{{projectName}}",
|
|
3
|
-
"version": "0.1.0",
|
|
4
|
-
"private": true,
|
|
5
|
-
{{#if (packageManagerManifestValue packageManager)}}
|
|
6
|
-
"packageManager": "{{packageManagerManifestValue packageManager}}",
|
|
7
|
-
{{/if}}
|
|
8
|
-
"type": "module",
|
|
9
|
-
"workspaces": [
|
|
10
|
-
"apps/*",
|
|
11
|
-
"packages/*"
|
|
12
|
-
],
|
|
13
|
-
"scripts": {
|
|
14
|
-
"build": "turbo run build",
|
|
15
|
-
"dev": "turbo run dev --parallel",
|
|
16
|
-
"lint": "turbo run lint",
|
|
17
|
-
"start": "turbo run start --parallel",
|
|
18
|
-
"typecheck": "turbo run typecheck"
|
|
19
|
-
},
|
|
20
|
-
"devDependencies": {}
|
|
21
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2022",
|
|
4
|
-
"lib": ["ES2022"],
|
|
5
|
-
"module": "ESNext",
|
|
6
|
-
"moduleResolution": "Bundler",
|
|
7
|
-
"allowImportingTsExtensions": true,
|
|
8
|
-
"noEmit": true,
|
|
9
|
-
"resolveJsonModule": true,
|
|
10
|
-
"skipLibCheck": true,
|
|
11
|
-
"strict": true,
|
|
12
|
-
"types": ["node"]
|
|
13
|
-
},
|
|
14
|
-
"include": [
|
|
15
|
-
"module.ts",
|
|
16
|
-
"service.ts",
|
|
17
|
-
"prisma.config.ts",
|
|
18
|
-
"prisma-composer.config.ts",
|
|
19
|
-
"packages/**/*.ts"
|
|
20
|
-
],
|
|
21
|
-
"exclude": ["node_modules"]
|
|
22
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://turbo.build/schema.json",
|
|
3
|
-
"tasks": {
|
|
4
|
-
"build": {
|
|
5
|
-
"dependsOn": ["^build"],
|
|
6
|
-
"outputs": [".next/**", "!.next/cache/**", "dist/**"]
|
|
7
|
-
},
|
|
8
|
-
"dev": {
|
|
9
|
-
"cache": false,
|
|
10
|
-
"persistent": true
|
|
11
|
-
},
|
|
12
|
-
"lint": {
|
|
13
|
-
"dependsOn": ["^lint"]
|
|
14
|
-
},
|
|
15
|
-
"start": {
|
|
16
|
-
"cache": false,
|
|
17
|
-
"dependsOn": ["build"],
|
|
18
|
-
"persistent": true
|
|
19
|
-
},
|
|
20
|
-
"typecheck": {
|
|
21
|
-
"dependsOn": ["^typecheck"]
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|