create-prisma 0.11.0-pr.79.272.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-BspW_Z2y.mjs → create-DX_T1T1y.mjs} +26 -62
- 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
|
|
|
@@ -546,7 +534,6 @@ const dependencyVersionMap = {
|
|
|
546
534
|
"@elysiajs/node": "^1.4.5",
|
|
547
535
|
"@prisma/composer": "0.16.0",
|
|
548
536
|
"@prisma/composer-prisma-cloud": "0.16.0",
|
|
549
|
-
"@prisma/dev": "0.24.7",
|
|
550
537
|
"@prisma/orm-mongo": "8.0.0-rc.8",
|
|
551
538
|
"@prisma/orm-postgres": "8.0.0-rc.8",
|
|
552
539
|
"@sveltejs/adapter-node": "^5.3.2",
|
|
@@ -561,7 +548,6 @@ const dependencyVersionMap = {
|
|
|
561
548
|
nitro: "^3.0.260610-beta",
|
|
562
549
|
prisma: "8.0.0-rc.12",
|
|
563
550
|
"temporal-polyfill": "^1.0.4",
|
|
564
|
-
turbo: "2.10.12",
|
|
565
551
|
tsx: "^4.21.0",
|
|
566
552
|
typescript: "^5.9.3"
|
|
567
553
|
};
|
|
@@ -590,18 +576,11 @@ function getCreateTemplateDependencies(template, _packageManager) {
|
|
|
590
576
|
if (template === "svelte") devDependencies.push("@sveltejs/adapter-node");
|
|
591
577
|
if (template === "astro") dependencies.push("@astrojs/node");
|
|
592
578
|
if (template === "tanstack-start") devDependencies.push("nitro");
|
|
593
|
-
|
|
594
|
-
const targets = [{
|
|
579
|
+
return [{
|
|
595
580
|
packageJsonPath: "package.json",
|
|
596
581
|
dependencies,
|
|
597
582
|
devDependencies
|
|
598
583
|
}];
|
|
599
|
-
if (template === "turborepo") targets.push({
|
|
600
|
-
packageJsonPath: "packages/database/package.json",
|
|
601
|
-
dependencies: [],
|
|
602
|
-
devDependencies: ["typescript"]
|
|
603
|
-
});
|
|
604
|
-
return targets;
|
|
605
584
|
}
|
|
606
585
|
|
|
607
586
|
//#endregion
|
|
@@ -710,27 +689,17 @@ async function addPackageDependency(opts) {
|
|
|
710
689
|
pkgJson.scripts = sortRecord(pkgJson.scripts);
|
|
711
690
|
await fs.writeJson(pkgJsonPath, pkgJson, { spaces: 2 });
|
|
712
691
|
}
|
|
713
|
-
async function writePrismaDependencies(provider, packageManager, _authoring, projectDir = process.cwd()
|
|
692
|
+
async function writePrismaDependencies(provider, packageManager, _authoring, projectDir = process.cwd()) {
|
|
714
693
|
const dependencies = [getDbPackages(provider)];
|
|
715
694
|
if (provider === "postgres" && packageManager !== "deno") dependencies.push("temporal-polyfill");
|
|
716
695
|
if (provider === "mongo") dependencies.push("arktype", "mongodb");
|
|
717
696
|
if (packageManager === "deno") dependencies.push("dotenv");
|
|
718
|
-
const devDependencies = ["@types/node", "prisma"];
|
|
719
|
-
if (packageManager !== "deno") devDependencies.push("@prisma/dev");
|
|
720
697
|
await addPackageDependency({
|
|
721
698
|
dependencies,
|
|
722
|
-
devDependencies,
|
|
699
|
+
devDependencies: ["@types/node", "prisma"],
|
|
723
700
|
scripts: getPrismaScriptMap(packageManager),
|
|
724
701
|
projectDir
|
|
725
702
|
});
|
|
726
|
-
if (template === "turborepo" && packageManager !== "deno") {
|
|
727
|
-
const databaseDependencies = [getDbPackages(provider)];
|
|
728
|
-
if (provider === "postgres") databaseDependencies.push("temporal-polyfill");
|
|
729
|
-
await addPackageDependency({
|
|
730
|
-
dependencies: databaseDependencies,
|
|
731
|
-
projectDir: path.join(projectDir, "packages/database")
|
|
732
|
-
});
|
|
733
|
-
}
|
|
734
703
|
}
|
|
735
704
|
async function writeCreateTemplateDependencies(opts) {
|
|
736
705
|
const { template, packageManager, projectDir = process.cwd() } = opts;
|
|
@@ -1317,8 +1286,8 @@ async function collectPrismaSetupContext(input, options = {}) {
|
|
|
1317
1286
|
...input.workspace ? { workspace: input.workspace } : {}
|
|
1318
1287
|
};
|
|
1319
1288
|
}
|
|
1320
|
-
function getContractPath(authoring
|
|
1321
|
-
return
|
|
1289
|
+
function getContractPath(authoring) {
|
|
1290
|
+
return `src/prisma/contract${authoring === "typescript" ? ".ts" : ".prisma"}`;
|
|
1322
1291
|
}
|
|
1323
1292
|
function getInitTarget(provider) {
|
|
1324
1293
|
return provider === "mongo" ? "mongodb" : "postgres";
|
|
@@ -1326,7 +1295,7 @@ function getInitTarget(provider) {
|
|
|
1326
1295
|
function getPrismaCliInvocation(packageManager, args) {
|
|
1327
1296
|
return getPackageExecutionArgs(packageManager, [packageManager === "deno" ? PRISMA_DENO_CLI_PACKAGE : PRISMA_PLATFORM_CLI_PACKAGE, ...args]);
|
|
1328
1297
|
}
|
|
1329
|
-
async function runPrismaInit(context, projectDir
|
|
1298
|
+
async function runPrismaInit(context, projectDir) {
|
|
1330
1299
|
const args = [
|
|
1331
1300
|
"orm",
|
|
1332
1301
|
"init",
|
|
@@ -1337,7 +1306,7 @@ async function runPrismaInit(context, projectDir, template) {
|
|
|
1337
1306
|
"--authoring",
|
|
1338
1307
|
context.authoring,
|
|
1339
1308
|
"--schema-path",
|
|
1340
|
-
getContractPath(context.authoring
|
|
1309
|
+
getContractPath(context.authoring),
|
|
1341
1310
|
"--skip-install"
|
|
1342
1311
|
];
|
|
1343
1312
|
const invocation = getPrismaCliInvocation(context.packageManager, args);
|
|
@@ -1471,7 +1440,7 @@ async function executePrismaSetupContext(context, options = {}) {
|
|
|
1471
1440
|
if (ownsProgress) progress.start("Creating Prisma 8 project...");
|
|
1472
1441
|
try {
|
|
1473
1442
|
progress?.message("Preparing Prisma 8 project files...");
|
|
1474
|
-
await runPrismaInit(context, projectDir
|
|
1443
|
+
await runPrismaInit(context, projectDir);
|
|
1475
1444
|
setupStage = "configure_project";
|
|
1476
1445
|
setupReason = "project_configuration_failed";
|
|
1477
1446
|
await scaffoldCreateSharedTemplates({
|
|
@@ -1482,7 +1451,7 @@ async function executePrismaSetupContext(context, options = {}) {
|
|
|
1482
1451
|
authoring: context.authoring,
|
|
1483
1452
|
packageManager: context.packageManager
|
|
1484
1453
|
});
|
|
1485
|
-
await writePrismaDependencies(context.databaseProvider, context.packageManager, context.authoring, projectDir
|
|
1454
|
+
await writePrismaDependencies(context.databaseProvider, context.packageManager, context.authoring, projectDir);
|
|
1486
1455
|
await ensureComposerTypeScriptOptions(projectDir);
|
|
1487
1456
|
if (context.databaseProvider === "mongo") await ensureMongoEnvironment(projectDir);
|
|
1488
1457
|
if (context.packageManager !== "deno") {
|
|
@@ -1686,11 +1655,6 @@ async function promptForCreateTemplate(output) {
|
|
|
1686
1655
|
label: "Next.js",
|
|
1687
1656
|
hint: "Full-stack React app with App Router"
|
|
1688
1657
|
},
|
|
1689
|
-
{
|
|
1690
|
-
value: "turborepo",
|
|
1691
|
-
label: "Monorepo (Turborepo)",
|
|
1692
|
-
hint: "Next.js app with a shared Prisma database package"
|
|
1693
|
-
},
|
|
1694
1658
|
{
|
|
1695
1659
|
value: "svelte",
|
|
1696
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
|
-
}
|