create-prisma 0.4.2-next.37.92.1 → 0.4.2-next.37.94.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 +17 -10
- package/dist/cli.mjs +1 -1
- package/dist/{create-B0eFGNQ2.mjs → create-DgTPw_xS.mjs} +28 -109
- package/dist/index.d.mts +3 -0
- package/dist/index.mjs +2 -2
- package/package.json +1 -1
- package/templates/create/astro/README.md.hbs +1 -1
- package/templates/create/elysia/README.md.hbs +1 -1
- package/templates/create/hono/README.md.hbs +1 -1
- package/templates/create/minimal/.yarnrc.yml.hbs +3 -0
- package/templates/create/minimal/README.md.hbs +38 -0
- package/templates/create/minimal/deno.json.hbs +5 -0
- package/templates/create/minimal/package.json.hbs +13 -0
- package/templates/create/minimal/src/index.ts.hbs +42 -0
- package/templates/create/minimal/src/lib/prisma.ts.hbs +71 -0
- package/templates/create/minimal/tsconfig.json +14 -0
- package/templates/create/nest/README.md.hbs +1 -1
- package/templates/create/next/README.md.hbs +1 -1
- package/templates/create/nuxt/README.md.hbs +1 -1
- package/templates/create/svelte/README.md.hbs +1 -1
- package/templates/create/tanstack-start/README.md.hbs +1 -1
package/README.md
CHANGED
|
@@ -8,9 +8,9 @@ Scaffold a new app with Prisma Next already wired up.
|
|
|
8
8
|
|
|
9
9
|
- creates a new app from a supported template
|
|
10
10
|
- adds Prisma Next dependencies for PostgreSQL or MongoDB
|
|
11
|
-
- runs `prisma-next init --no-install` to scaffold `prisma/contract.*`, `prisma-next.config.ts`, `prisma/db.ts`, `prisma-next.md`, `.env.example
|
|
11
|
+
- runs `prisma-next init --no-install` to scaffold `prisma/contract.*`, `prisma-next.config.ts`, `prisma/db.ts`, `prisma-next.md`, and `.env.example`
|
|
12
12
|
- writes a template-specific Prisma Next runtime helper
|
|
13
|
-
- adds `contract:emit`, `db:init`, `db:update`, `db:verify`, `db:seed`, `migration:plan`, `
|
|
13
|
+
- adds `contract:emit`, `db:init`, `db:update`, `db:verify`, `db:seed`, `migration:plan`, `migrate`, `migration:status`, and `migration:show` scripts
|
|
14
14
|
- adds `db:up` / `db:down` and `docker-compose.yml` for default MongoDB projects
|
|
15
15
|
- creates or updates `.env` with `DATABASE_URL`
|
|
16
16
|
- can install dependencies and run `prisma-next contract emit`
|
|
@@ -57,6 +57,12 @@ Create a project interactively:
|
|
|
57
57
|
create-prisma
|
|
58
58
|
```
|
|
59
59
|
|
|
60
|
+
Create a Minimal project non-interactively:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
create-prisma --name my-script --template minimal --provider postgres
|
|
64
|
+
```
|
|
65
|
+
|
|
60
66
|
Create a Hono app non-interactively:
|
|
61
67
|
|
|
62
68
|
```bash
|
|
@@ -89,14 +95,15 @@ create-prisma --name my-app --template nest --provider postgres --prisma-postgre
|
|
|
89
95
|
|
|
90
96
|
## Supported Templates
|
|
91
97
|
|
|
92
|
-
- `
|
|
93
|
-
- `
|
|
94
|
-
- `
|
|
95
|
-
- `
|
|
96
|
-
- `
|
|
97
|
-
- `
|
|
98
|
-
- `
|
|
99
|
-
- `
|
|
98
|
+
- `minimal` - script-first Prisma Next starter with no web framework
|
|
99
|
+
- `hono` - lightweight TypeScript API server
|
|
100
|
+
- `elysia` - Bun-friendly TypeScript API server
|
|
101
|
+
- `nest` - structured Node API with controllers and services
|
|
102
|
+
- `next` - full-stack React app with App Router
|
|
103
|
+
- `svelte` - full-stack Svelte 5 app with Vite
|
|
104
|
+
- `astro` - content-oriented web app with server routes
|
|
105
|
+
- `nuxt` - full-stack Vue app with Nitro server routes
|
|
106
|
+
- `tanstack-start` - React app with file routes and server functions
|
|
100
107
|
|
|
101
108
|
## Supported Databases
|
|
102
109
|
|
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.4.2-next.37.
|
|
52
|
+
"cli-version": "0.4.2-next.37.94.1",
|
|
53
53
|
"node-version": process.version,
|
|
54
54
|
platform: process.platform,
|
|
55
55
|
arch: process.arch
|
|
@@ -152,7 +152,6 @@ const dependencyVersionMap = {
|
|
|
152
152
|
"@elysiajs/node": "^1.4.5",
|
|
153
153
|
"@types/node": "^25.6.2",
|
|
154
154
|
dotenv: "^17.4.2",
|
|
155
|
-
skills: "1.5.7",
|
|
156
155
|
tsx: "^4.21.0"
|
|
157
156
|
};
|
|
158
157
|
const PRISMA_NEXT_PACKAGE_VERSION = "latest";
|
|
@@ -176,7 +175,7 @@ function getCreateTemplateDependencies(template, packageManager) {
|
|
|
176
175
|
dependencies: [],
|
|
177
176
|
devDependencies: ["@prisma-next/vite-plugin-contract-emit"]
|
|
178
177
|
});
|
|
179
|
-
if (template === "hono" || template === "elysia" || template === "nest") {
|
|
178
|
+
if (template === "minimal" || template === "hono" || template === "elysia" || template === "nest") {
|
|
180
179
|
const runtimeDevDependencies = usesNodeStyleRuntime(packageManager) ? ["tsx"] : [];
|
|
181
180
|
if (template === "elysia" && packageManager !== "deno") targets.push({
|
|
182
181
|
packageJsonPath: "package.json",
|
|
@@ -209,6 +208,7 @@ const packageManagers = [
|
|
|
209
208
|
];
|
|
210
209
|
const authoringStyles = ["psl", "typescript"];
|
|
211
210
|
const createTemplates = [
|
|
211
|
+
"minimal",
|
|
212
212
|
"hono",
|
|
213
213
|
"elysia",
|
|
214
214
|
"nest",
|
|
@@ -601,7 +601,6 @@ function getDbPackages(provider, _packageManager) {
|
|
|
601
601
|
//#endregion
|
|
602
602
|
//#region src/tasks/install.ts
|
|
603
603
|
function getPrismaNextScriptMap(packageManager) {
|
|
604
|
-
const skillsSyncCommand = packageManager === "deno" ? `deno run -A npm:skills@${dependencyVersionMap.skills} experimental_sync --agent "*" -y` : "skills experimental_sync --agent \"*\" -y";
|
|
605
604
|
if (packageManager === "deno") {
|
|
606
605
|
const prismaNextCli = `deno run -A --env-file=.env npm:${getPrismaNextPackageSpecifier("prisma-next")}`;
|
|
607
606
|
return {
|
|
@@ -613,8 +612,7 @@ function getPrismaNextScriptMap(packageManager) {
|
|
|
613
612
|
"migration:plan": `${prismaNextCli} migration plan`,
|
|
614
613
|
migrate: `${prismaNextCli} migrate`,
|
|
615
614
|
"migration:status": `${prismaNextCli} migration status`,
|
|
616
|
-
"migration:show": `${prismaNextCli} migration show
|
|
617
|
-
"skills:sync": skillsSyncCommand
|
|
615
|
+
"migration:show": `${prismaNextCli} migration show`
|
|
618
616
|
};
|
|
619
617
|
}
|
|
620
618
|
if (packageManager === "bun") {
|
|
@@ -628,8 +626,7 @@ function getPrismaNextScriptMap(packageManager) {
|
|
|
628
626
|
"migration:plan": `${prismaNextCli} migration plan`,
|
|
629
627
|
migrate: `${prismaNextCli} migrate`,
|
|
630
628
|
"migration:status": `${prismaNextCli} migration status`,
|
|
631
|
-
"migration:show": `${prismaNextCli} migration show
|
|
632
|
-
"skills:sync": skillsSyncCommand
|
|
629
|
+
"migration:show": `${prismaNextCli} migration show`
|
|
633
630
|
};
|
|
634
631
|
}
|
|
635
632
|
return {
|
|
@@ -641,8 +638,7 @@ function getPrismaNextScriptMap(packageManager) {
|
|
|
641
638
|
"migration:plan": "prisma-next migration plan",
|
|
642
639
|
migrate: "prisma-next migrate",
|
|
643
640
|
"migration:status": "prisma-next migration status",
|
|
644
|
-
"migration:show": "prisma-next migration show"
|
|
645
|
-
"skills:sync": skillsSyncCommand
|
|
641
|
+
"migration:show": "prisma-next migration show"
|
|
646
642
|
};
|
|
647
643
|
}
|
|
648
644
|
function unique(items) {
|
|
@@ -720,9 +716,7 @@ async function writePrismaDependencies(provider, packageManager, authoring, proj
|
|
|
720
716
|
const devDependencies = [
|
|
721
717
|
"prisma-next",
|
|
722
718
|
"@prisma-next/cli",
|
|
723
|
-
"@
|
|
724
|
-
"@types/node",
|
|
725
|
-
"skills"
|
|
719
|
+
"@types/node"
|
|
726
720
|
];
|
|
727
721
|
devDependencies.push(...getGeneratedContractTypePackages(provider));
|
|
728
722
|
devDependencies.push(...getMigrationPackages(provider));
|
|
@@ -822,7 +816,6 @@ const DEFAULT_INSTALL = true;
|
|
|
822
816
|
const DEFAULT_EMIT = true;
|
|
823
817
|
const DEFAULT_INTERACTIVE_PRISMA_POSTGRES = true;
|
|
824
818
|
const DEFAULT_AUTOMATED_PRISMA_POSTGRES = false;
|
|
825
|
-
const CLAUDE_SKILLS_DIR = ".claude/skills";
|
|
826
819
|
const MONGO_DOCKER_COMPOSE = `services:
|
|
827
820
|
mongodb:
|
|
828
821
|
image: mongo:latest
|
|
@@ -1254,77 +1247,6 @@ async function installDependenciesForContext(context, projectDir) {
|
|
|
1254
1247
|
return false;
|
|
1255
1248
|
}
|
|
1256
1249
|
}
|
|
1257
|
-
function getSkillsSyncCliCommand(packageManager) {
|
|
1258
|
-
if (packageManager === "deno") return `deno run -A npm:skills@${dependencyVersionMap.skills} experimental_sync --agent "*" -y`;
|
|
1259
|
-
return getLocalPackageBinaryCommand(packageManager, "skills", [
|
|
1260
|
-
"experimental_sync",
|
|
1261
|
-
"--agent",
|
|
1262
|
-
"*",
|
|
1263
|
-
"-y"
|
|
1264
|
-
]);
|
|
1265
|
-
}
|
|
1266
|
-
function getSkillsSyncCliArgs(packageManager) {
|
|
1267
|
-
if (packageManager === "deno") return {
|
|
1268
|
-
command: "deno",
|
|
1269
|
-
args: [
|
|
1270
|
-
"run",
|
|
1271
|
-
"-A",
|
|
1272
|
-
`npm:skills@${dependencyVersionMap.skills}`,
|
|
1273
|
-
"experimental_sync",
|
|
1274
|
-
"--agent",
|
|
1275
|
-
"*",
|
|
1276
|
-
"-y"
|
|
1277
|
-
]
|
|
1278
|
-
};
|
|
1279
|
-
return getLocalPackageBinaryArgs(packageManager, "skills", [
|
|
1280
|
-
"experimental_sync",
|
|
1281
|
-
"--agent",
|
|
1282
|
-
"*",
|
|
1283
|
-
"-y"
|
|
1284
|
-
]);
|
|
1285
|
-
}
|
|
1286
|
-
async function syncAgentSkillsForContext(context, projectDir) {
|
|
1287
|
-
if (!context.shouldInstall) return { didSyncAgentSkills: false };
|
|
1288
|
-
const claudeDirectory = await prepareClaudeSkillsDirectory(projectDir);
|
|
1289
|
-
const syncCommand = getSkillsSyncCliCommand(context.packageManager);
|
|
1290
|
-
if (context.verbose) log.step(`Running ${syncCommand}`);
|
|
1291
|
-
try {
|
|
1292
|
-
const syncArgs = getSkillsSyncCliArgs(context.packageManager);
|
|
1293
|
-
await execa(syncArgs.command, syncArgs.args, {
|
|
1294
|
-
cwd: projectDir,
|
|
1295
|
-
stdio: context.verbose ? "inherit" : "pipe",
|
|
1296
|
-
env: {
|
|
1297
|
-
...process.env,
|
|
1298
|
-
CI: "1"
|
|
1299
|
-
}
|
|
1300
|
-
});
|
|
1301
|
-
if (context.verbose) log.success("Prisma Next agent skills synced.");
|
|
1302
|
-
return { didSyncAgentSkills: true };
|
|
1303
|
-
} catch (error) {
|
|
1304
|
-
if (context.verbose) log.warn("Could not sync Prisma Next agent skills.");
|
|
1305
|
-
if (claudeDirectory.didCreateClaudeRoot) await removeEmptyClaudeSkillsDirectory(projectDir);
|
|
1306
|
-
return {
|
|
1307
|
-
didSyncAgentSkills: false,
|
|
1308
|
-
warning: `Agent skill sync failed: ${getCommandErrorMessage(error)}`
|
|
1309
|
-
};
|
|
1310
|
-
}
|
|
1311
|
-
}
|
|
1312
|
-
async function prepareClaudeSkillsDirectory(projectDir) {
|
|
1313
|
-
const claudeRoot = path.join(projectDir, ".claude");
|
|
1314
|
-
const didCreateClaudeRoot = !await fs.pathExists(claudeRoot);
|
|
1315
|
-
try {
|
|
1316
|
-
await fs.ensureDir(path.join(projectDir, CLAUDE_SKILLS_DIR));
|
|
1317
|
-
return { didCreateClaudeRoot };
|
|
1318
|
-
} catch {
|
|
1319
|
-
return { didCreateClaudeRoot: false };
|
|
1320
|
-
}
|
|
1321
|
-
}
|
|
1322
|
-
async function removeEmptyClaudeSkillsDirectory(projectDir) {
|
|
1323
|
-
const claudeSkillsDir = path.join(projectDir, CLAUDE_SKILLS_DIR);
|
|
1324
|
-
const claudeRoot = path.dirname(claudeSkillsDir);
|
|
1325
|
-
if (await fs.pathExists(claudeSkillsDir) && (await fs.readdir(claudeSkillsDir)).length === 0) await fs.remove(claudeSkillsDir);
|
|
1326
|
-
if (await fs.pathExists(claudeRoot) && (await fs.readdir(claudeRoot)).length === 0) await fs.remove(claudeRoot);
|
|
1327
|
-
}
|
|
1328
1250
|
async function finalizePrismaFilesForContext(context, projectDir, provisionResult) {
|
|
1329
1251
|
try {
|
|
1330
1252
|
await finalizePrismaFiles({
|
|
@@ -1381,24 +1303,19 @@ async function emitPrismaNextContractForContext(context, projectDir) {
|
|
|
1381
1303
|
};
|
|
1382
1304
|
}
|
|
1383
1305
|
}
|
|
1384
|
-
function buildWarningLines(provisionWarning, emitWarning
|
|
1306
|
+
function buildWarningLines(provisionWarning, emitWarning) {
|
|
1385
1307
|
const warningLines = [];
|
|
1386
1308
|
if (provisionWarning) warningLines.push(`- ${provisionWarning}`);
|
|
1387
|
-
if (skillSyncWarning) warningLines.push(`- ${skillSyncWarning}`);
|
|
1388
1309
|
if (emitWarning) warningLines.push(`- ${emitWarning}`);
|
|
1389
1310
|
return warningLines;
|
|
1390
1311
|
}
|
|
1391
1312
|
function buildNextStepsForContext(opts) {
|
|
1392
|
-
const { context, options, didEmitContract
|
|
1313
|
+
const { context, options, didEmitContract } = opts;
|
|
1393
1314
|
const nextSteps = [...options.prependNextSteps ?? []];
|
|
1394
1315
|
if (!context.shouldInstall) nextSteps.push({
|
|
1395
1316
|
command: getInstallCommand(context.packageManager),
|
|
1396
1317
|
description: "Install the project dependencies."
|
|
1397
1318
|
});
|
|
1398
|
-
if (!didSyncAgentSkills) nextSteps.push({
|
|
1399
|
-
command: getRunScriptCommand(context.packageManager, "skills:sync"),
|
|
1400
|
-
description: "Sync the Prisma Next agent skills from installed packages."
|
|
1401
|
-
});
|
|
1402
1319
|
if (!didEmitContract || !context.shouldEmit) nextSteps.push({
|
|
1403
1320
|
command: getRunScriptCommand(context.packageManager, "contract:emit"),
|
|
1404
1321
|
description: "Emit contract.json and TypeScript types from your Prisma Next contract."
|
|
@@ -1432,14 +1349,14 @@ function buildNextStepsForContext(opts) {
|
|
|
1432
1349
|
function formatNextSteps(nextSteps) {
|
|
1433
1350
|
return nextSteps.map((step) => `${step.command}\n ${step.description}`).join("\n\n");
|
|
1434
1351
|
}
|
|
1435
|
-
function formatAgentPrompt(
|
|
1352
|
+
function formatAgentPrompt() {
|
|
1436
1353
|
return [
|
|
1437
1354
|
"Ask your agent:",
|
|
1438
1355
|
"What can I do with Prisma Next?",
|
|
1439
1356
|
"",
|
|
1440
1357
|
"Learn more:",
|
|
1441
1358
|
`Docs: prisma-next.md`,
|
|
1442
|
-
|
|
1359
|
+
"Skills: https://github.com/prisma/prisma-next/tree/main/skills"
|
|
1443
1360
|
].join("\n");
|
|
1444
1361
|
}
|
|
1445
1362
|
async function executePrismaSetupContext(context, options = {}) {
|
|
@@ -1469,8 +1386,6 @@ async function executePrismaSetupContext(context, options = {}) {
|
|
|
1469
1386
|
stopProgressOnFailure();
|
|
1470
1387
|
return false;
|
|
1471
1388
|
}
|
|
1472
|
-
if (context.shouldInstall) progressSpinner?.message("Syncing Prisma Next agent skills...");
|
|
1473
|
-
const skillSyncResult = await syncAgentSkillsForContext(context, projectDir);
|
|
1474
1389
|
progressSpinner?.message("Configuring Prisma Next...");
|
|
1475
1390
|
if (!await finalizePrismaFilesForContext(context, projectDir, provisionResult)) {
|
|
1476
1391
|
stopProgressOnFailure();
|
|
@@ -1482,16 +1397,15 @@ async function executePrismaSetupContext(context, options = {}) {
|
|
|
1482
1397
|
}
|
|
1483
1398
|
if (context.shouldEmit && context.shouldInstall) progressSpinner?.message("Emitting Prisma Next contract artifacts...");
|
|
1484
1399
|
const emitResult = await emitPrismaNextContractForContext(context, projectDir);
|
|
1485
|
-
const warningLines = buildWarningLines(provisionResult.warning, emitResult.warning
|
|
1400
|
+
const warningLines = buildWarningLines(provisionResult.warning, emitResult.warning);
|
|
1486
1401
|
const nextSteps = buildNextStepsForContext({
|
|
1487
1402
|
context,
|
|
1488
1403
|
options,
|
|
1489
|
-
didEmitContract: emitResult.didEmitContract
|
|
1490
|
-
didSyncAgentSkills: skillSyncResult.didSyncAgentSkills
|
|
1404
|
+
didEmitContract: emitResult.didEmitContract
|
|
1491
1405
|
});
|
|
1492
1406
|
progressSpinner?.stop("Prisma Next project ready.");
|
|
1493
1407
|
if (warningLines.length > 0) note(warningLines.map((line) => line.replace(/^- /, "")).join("\n"), "Heads up");
|
|
1494
|
-
note(formatAgentPrompt(
|
|
1408
|
+
note(formatAgentPrompt(), "Agent prompt");
|
|
1495
1409
|
if (context.verbose) note(formatNextSteps(nextSteps), "Next steps for Prisma Next");
|
|
1496
1410
|
outro("Prisma Next setup complete.");
|
|
1497
1411
|
return true;
|
|
@@ -1507,7 +1421,7 @@ function getCreatePrismaIntro() {
|
|
|
1507
1421
|
//#endregion
|
|
1508
1422
|
//#region src/commands/create.ts
|
|
1509
1423
|
const DEFAULT_PROJECT_NAME = "my-app";
|
|
1510
|
-
const DEFAULT_TEMPLATE = "
|
|
1424
|
+
const DEFAULT_TEMPLATE = "minimal";
|
|
1511
1425
|
function toPackageName(projectName) {
|
|
1512
1426
|
return projectName.toLowerCase().replace(/[^a-z0-9._-]/g, "-").replace(/^-+/, "").replace(/-+$/, "") || "app";
|
|
1513
1427
|
}
|
|
@@ -1538,45 +1452,50 @@ async function promptForCreateTemplate() {
|
|
|
1538
1452
|
message: "Select template",
|
|
1539
1453
|
initialValue: DEFAULT_TEMPLATE,
|
|
1540
1454
|
options: [
|
|
1455
|
+
{
|
|
1456
|
+
value: "minimal",
|
|
1457
|
+
label: "Minimal",
|
|
1458
|
+
hint: "Script-first Prisma Next starter with no web framework"
|
|
1459
|
+
},
|
|
1541
1460
|
{
|
|
1542
1461
|
value: "hono",
|
|
1543
1462
|
label: "Hono",
|
|
1544
|
-
hint: "
|
|
1463
|
+
hint: "Lightweight TypeScript API server"
|
|
1545
1464
|
},
|
|
1546
1465
|
{
|
|
1547
1466
|
value: "elysia",
|
|
1548
1467
|
label: "Elysia",
|
|
1549
|
-
hint: "TypeScript API
|
|
1468
|
+
hint: "Bun-friendly TypeScript API server"
|
|
1550
1469
|
},
|
|
1551
1470
|
{
|
|
1552
1471
|
value: "nest",
|
|
1553
1472
|
label: "NestJS",
|
|
1554
|
-
hint: "
|
|
1473
|
+
hint: "Structured Node API with controllers and services"
|
|
1555
1474
|
},
|
|
1556
1475
|
{
|
|
1557
1476
|
value: "next",
|
|
1558
1477
|
label: "Next.js",
|
|
1559
|
-
hint: "
|
|
1478
|
+
hint: "Full-stack React app with App Router"
|
|
1560
1479
|
},
|
|
1561
1480
|
{
|
|
1562
1481
|
value: "svelte",
|
|
1563
1482
|
label: "SvelteKit",
|
|
1564
|
-
hint: "
|
|
1483
|
+
hint: "Full-stack Svelte 5 app with Vite"
|
|
1565
1484
|
},
|
|
1566
1485
|
{
|
|
1567
1486
|
value: "astro",
|
|
1568
1487
|
label: "Astro",
|
|
1569
|
-
hint: "
|
|
1488
|
+
hint: "Content-oriented web app with server routes"
|
|
1570
1489
|
},
|
|
1571
1490
|
{
|
|
1572
1491
|
value: "nuxt",
|
|
1573
1492
|
label: "Nuxt",
|
|
1574
|
-
hint: "
|
|
1493
|
+
hint: "Full-stack Vue app with Nitro server routes"
|
|
1575
1494
|
},
|
|
1576
1495
|
{
|
|
1577
1496
|
value: "tanstack-start",
|
|
1578
1497
|
label: "TanStack Start",
|
|
1579
|
-
hint: "
|
|
1498
|
+
hint: "React app with file routes and server functions"
|
|
1580
1499
|
}
|
|
1581
1500
|
]
|
|
1582
1501
|
});
|
package/dist/index.d.mts
CHANGED
|
@@ -195,6 +195,7 @@ declare const AuthoringStyleSchema: z.ZodEnum<{
|
|
|
195
195
|
typescript: "typescript";
|
|
196
196
|
}>;
|
|
197
197
|
declare const CreateTemplateSchema: z.ZodEnum<{
|
|
198
|
+
minimal: "minimal";
|
|
198
199
|
hono: "hono";
|
|
199
200
|
elysia: "elysia";
|
|
200
201
|
nest: "nest";
|
|
@@ -231,6 +232,7 @@ declare const CreateCommandInputSchema: z.ZodObject<{
|
|
|
231
232
|
emit: z.ZodOptional<z.ZodBoolean>;
|
|
232
233
|
name: z.ZodOptional<z.ZodString>;
|
|
233
234
|
template: z.ZodOptional<z.ZodEnum<{
|
|
235
|
+
minimal: "minimal";
|
|
234
236
|
hono: "hono";
|
|
235
237
|
elysia: "elysia";
|
|
236
238
|
nest: "nest";
|
|
@@ -272,6 +274,7 @@ declare const router: {
|
|
|
272
274
|
emit: zod.ZodOptional<zod.ZodBoolean>;
|
|
273
275
|
name: zod.ZodOptional<zod.ZodString>;
|
|
274
276
|
template: zod.ZodOptional<zod.ZodEnum<{
|
|
277
|
+
minimal: "minimal";
|
|
275
278
|
hono: "hono";
|
|
276
279
|
elysia: "elysia";
|
|
277
280
|
nest: "nest";
|
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-DgTPw_xS.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.94.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
|
@@ -35,7 +35,7 @@ Database helper scripts are added to `package.json`:
|
|
|
35
35
|
|
|
36
36
|
- `{{runScriptCommand packageManager "db:seed"}}` - insert sample users manually
|
|
37
37
|
|
|
38
|
-
For provider-specific Prisma Next reference docs, see `prisma-next.md`.
|
|
38
|
+
For provider-specific Prisma Next reference docs, see `prisma-next.md`. Prisma Next skills live in the upstream `skills/` directory: https://github.com/prisma/prisma-next/tree/main/skills.
|
|
39
39
|
The Astro Vite dev server also auto-emits Prisma Next contract artifacts when the contract changes.
|
|
40
40
|
|
|
41
41
|
Node-based Prisma Next projects expect Node.js 24 LTS or newer.
|
|
@@ -33,7 +33,7 @@ Database helper scripts are added to `package.json`:
|
|
|
33
33
|
|
|
34
34
|
- `{{runScriptCommand packageManager "db:seed"}}` - insert sample users manually
|
|
35
35
|
|
|
36
|
-
For provider-specific Prisma Next reference docs, see `prisma-next.md`.
|
|
36
|
+
For provider-specific Prisma Next reference docs, see `prisma-next.md`. Prisma Next skills live in the upstream `skills/` directory: https://github.com/prisma/prisma-next/tree/main/skills.
|
|
37
37
|
|
|
38
38
|
Node-based Prisma Next projects expect Node.js 24 LTS or newer.
|
|
39
39
|
|
|
@@ -33,7 +33,7 @@ Database helper scripts are added to `package.json`:
|
|
|
33
33
|
|
|
34
34
|
- `{{runScriptCommand packageManager "db:seed"}}` - insert sample users manually
|
|
35
35
|
|
|
36
|
-
For provider-specific Prisma Next reference docs, see `prisma-next.md`.
|
|
36
|
+
For provider-specific Prisma Next reference docs, see `prisma-next.md`. Prisma Next skills live in the upstream `skills/` directory: https://github.com/prisma/prisma-next/tree/main/skills.
|
|
37
37
|
|
|
38
38
|
Node-based Prisma Next projects expect Node.js 24 LTS or newer.
|
|
39
39
|
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# {{projectName}}
|
|
2
|
+
|
|
3
|
+
Generated by `create-prisma` with the Minimal template.
|
|
4
|
+
|
|
5
|
+
## Scripts
|
|
6
|
+
|
|
7
|
+
- `{{runScriptCommand packageManager "dev"}}` - run the Prisma Next sample script
|
|
8
|
+
|
|
9
|
+
## Prisma Next
|
|
10
|
+
|
|
11
|
+
Prisma Next setup is scaffolded in:
|
|
12
|
+
|
|
13
|
+
- `prisma/contract{{#if (eq authoring "typescript")}}.ts{{else}}.prisma{{/if}}`
|
|
14
|
+
- `prisma-next.config.ts`
|
|
15
|
+
- `prisma/db.ts`
|
|
16
|
+
- `src/lib/prisma.ts`
|
|
17
|
+
|
|
18
|
+
Database helper scripts are added to `package.json`:
|
|
19
|
+
|
|
20
|
+
- `{{runScriptCommand packageManager "contract:emit"}}` - emit contract artifacts after contract changes
|
|
21
|
+
{{#if (eq provider "mongo")}}
|
|
22
|
+
- `{{runScriptCommand packageManager "db:up"}}` - start the local MongoDB replica set
|
|
23
|
+
- `{{runScriptCommand packageManager "db:down"}}` - stop the local MongoDB replica set
|
|
24
|
+
- `{{runScriptCommand packageManager "migration:plan"}}` - create a MongoDB migration plan
|
|
25
|
+
- `{{runScriptCommand packageManager "migrate"}}` - apply the planned MongoDB migration
|
|
26
|
+
{{else}}
|
|
27
|
+
- `{{runScriptCommand packageManager "db:init"}}` - initialize database state manually
|
|
28
|
+
- `{{runScriptCommand packageManager "db:update"}}` - update database state manually
|
|
29
|
+
- `{{runScriptCommand packageManager "migration:plan"}}` - create a migration plan
|
|
30
|
+
- `{{runScriptCommand packageManager "migrate"}}` - apply a planned migration
|
|
31
|
+
{{/if}}
|
|
32
|
+
- `{{runScriptCommand packageManager "db:seed"}}` - insert sample users manually
|
|
33
|
+
|
|
34
|
+
For provider-specific Prisma Next reference docs, see `prisma-next.md`. Prisma Next skills live in the upstream `skills/` directory: https://github.com/prisma/prisma-next/tree/main/skills.
|
|
35
|
+
|
|
36
|
+
Node-based Prisma Next projects expect Node.js 24 LTS or newer.
|
|
37
|
+
|
|
38
|
+
Run the migration and seed scripts first, then `{{runScriptCommand packageManager "dev"}}` runs a small write/read round trip from `src/index.ts`.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{projectName}}",
|
|
3
|
+
"private": true,
|
|
4
|
+
{{#if (packageManagerManifestValue packageManager)}}
|
|
5
|
+
"packageManager": "{{packageManagerManifestValue packageManager}}",
|
|
6
|
+
{{/if}}
|
|
7
|
+
"type": "module",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"dev": "{{runtimeScript packageManager "start" "src/index.ts" ""}}"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {},
|
|
12
|
+
"devDependencies": {}
|
|
13
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { db, listUsers } from "./lib/prisma{{#if (eq packageManager "deno")}}.ts{{/if}}";
|
|
2
|
+
|
|
3
|
+
const sampleUser = {
|
|
4
|
+
email: "first.user@prisma.io",
|
|
5
|
+
name: "First User",
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
async function main() {
|
|
9
|
+
{{#if (eq provider "mongo")}}
|
|
10
|
+
const existingUser = await db.orm.users.where({ email: sampleUser.email }).first();
|
|
11
|
+
if (!existingUser) {
|
|
12
|
+
await db.orm.users.createCount([sampleUser]);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const user = await db.orm.users.where({ email: sampleUser.email }).first();
|
|
16
|
+
{{else}}
|
|
17
|
+
const existingUser = await db.orm.User.where({ email: sampleUser.email }).first();
|
|
18
|
+
if (!existingUser) {
|
|
19
|
+
await db.orm.User.createCount([sampleUser]);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const user = await db.orm.User.where({ email: sampleUser.email }).first();
|
|
23
|
+
{{/if}}
|
|
24
|
+
const users = await listUsers();
|
|
25
|
+
|
|
26
|
+
console.log(`Prisma Next is ready. Found ${users.length} user${users.length === 1 ? "" : "s"}.`);
|
|
27
|
+
console.log(user);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
try {
|
|
31
|
+
await main();
|
|
32
|
+
} catch (error) {
|
|
33
|
+
console.error("Prisma Next query failed.");
|
|
34
|
+
console.error("Emit the contract, set DATABASE_URL, then apply migrations before running this script.");
|
|
35
|
+
throw error;
|
|
36
|
+
} finally {
|
|
37
|
+
{{#if (eq provider "mongo")}}
|
|
38
|
+
await db.close();
|
|
39
|
+
{{else}}
|
|
40
|
+
await db.runtime().close();
|
|
41
|
+
{{/if}}
|
|
42
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import "dotenv/config";
|
|
2
|
+
{{#if (eq provider "mongo")}}
|
|
3
|
+
import mongo from "@prisma-next/mongo/runtime";
|
|
4
|
+
{{else}}
|
|
5
|
+
import postgres from "@prisma-next/postgres/runtime";
|
|
6
|
+
{{/if}}
|
|
7
|
+
|
|
8
|
+
{{#if (eq provider "mongo")}}
|
|
9
|
+
import type { DefaultModelRow } from "@prisma-next/mongo-orm";
|
|
10
|
+
{{else}}
|
|
11
|
+
import type { DefaultModelRow } from "@prisma-next/sql-orm-client";
|
|
12
|
+
{{/if}}
|
|
13
|
+
|
|
14
|
+
import type { Contract } from "../../prisma/contract.d";
|
|
15
|
+
import contractJson from "../../prisma/contract.json" with { type: "json" };
|
|
16
|
+
|
|
17
|
+
{{#if (eq provider "mongo")}}
|
|
18
|
+
export const db = mongo<Contract>({
|
|
19
|
+
contractJson,
|
|
20
|
+
url: process.env["DATABASE_URL"],
|
|
21
|
+
});
|
|
22
|
+
{{else}}
|
|
23
|
+
export const db = postgres<Contract>({
|
|
24
|
+
contractJson,
|
|
25
|
+
url: process.env["DATABASE_URL"],
|
|
26
|
+
});
|
|
27
|
+
{{/if}}
|
|
28
|
+
|
|
29
|
+
type UserRow = DefaultModelRow<Contract, "User">;
|
|
30
|
+
|
|
31
|
+
{{#if (eq provider "mongo")}}
|
|
32
|
+
function toStarterUser(user: Pick<UserRow, "_id" | "email" | "name">) {
|
|
33
|
+
return {
|
|
34
|
+
id: String(user._id),
|
|
35
|
+
email: user.email,
|
|
36
|
+
name: user.name ?? null,
|
|
37
|
+
createdAt: null as Date | null,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
{{else}}
|
|
41
|
+
function toStarterUser(user: Pick<UserRow, "id" | "email" | "name" | "createdAt">) {
|
|
42
|
+
return {
|
|
43
|
+
id: String(user.id),
|
|
44
|
+
email: user.email,
|
|
45
|
+
name: user.name ?? null,
|
|
46
|
+
createdAt: user.createdAt,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
{{/if}}
|
|
50
|
+
|
|
51
|
+
export async function listUsers(limit = 10) {
|
|
52
|
+
|
|
53
|
+
{{#if (eq provider "mongo")}}
|
|
54
|
+
const users: ReturnType<typeof toStarterUser>[] = [];
|
|
55
|
+
|
|
56
|
+
for await (const user of db.orm.users.select("_id", "email", "name").take(limit).all()) {
|
|
57
|
+
users.push(toStarterUser(user));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return users;
|
|
61
|
+
{{else}}
|
|
62
|
+
const users = await db.orm.User.select("id", "email", "name", "createdAt").take(limit).all();
|
|
63
|
+
|
|
64
|
+
return users.map(toStarterUser);
|
|
65
|
+
{{/if}}
|
|
66
|
+
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export type StarterUser = Awaited<ReturnType<typeof listUsers>>[number];
|
|
70
|
+
|
|
71
|
+
export default db;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "Bundler",
|
|
6
|
+
"resolveJsonModule": true,
|
|
7
|
+
"verbatimModuleSyntax": true,
|
|
8
|
+
"strict": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"forceConsistentCasingInFileNames": true
|
|
12
|
+
},
|
|
13
|
+
"include": ["src/**/*.ts", "prisma/**/*.ts"]
|
|
14
|
+
}
|
|
@@ -34,7 +34,7 @@ Database helper scripts are added to `package.json`:
|
|
|
34
34
|
|
|
35
35
|
- `{{runScriptCommand packageManager "db:seed"}}` - insert sample users manually
|
|
36
36
|
|
|
37
|
-
For provider-specific Prisma Next reference docs, see `prisma-next.md`.
|
|
37
|
+
For provider-specific Prisma Next reference docs, see `prisma-next.md`. Prisma Next skills live in the upstream `skills/` directory: https://github.com/prisma/prisma-next/tree/main/skills.
|
|
38
38
|
|
|
39
39
|
Node-based Prisma Next projects expect Node.js 24 LTS or newer.
|
|
40
40
|
|
|
@@ -33,7 +33,7 @@ Database helper scripts are added to `package.json`:
|
|
|
33
33
|
|
|
34
34
|
- `{{runScriptCommand packageManager "db:seed"}}` - insert sample users manually
|
|
35
35
|
|
|
36
|
-
For provider-specific Prisma Next reference docs, see `prisma-next.md`.
|
|
36
|
+
For provider-specific Prisma Next reference docs, see `prisma-next.md`. Prisma Next skills live in the upstream `skills/` directory: https://github.com/prisma/prisma-next/tree/main/skills.
|
|
37
37
|
|
|
38
38
|
Node-based Prisma Next projects expect Node.js 24 LTS or newer.
|
|
39
39
|
|
|
@@ -35,7 +35,7 @@ Database helper scripts are added to `package.json`:
|
|
|
35
35
|
|
|
36
36
|
- `{{runScriptCommand packageManager "db:seed"}}` - insert sample users manually
|
|
37
37
|
|
|
38
|
-
For provider-specific Prisma Next reference docs, see `prisma-next.md`.
|
|
38
|
+
For provider-specific Prisma Next reference docs, see `prisma-next.md`. Prisma Next skills live in the upstream `skills/` directory: https://github.com/prisma/prisma-next/tree/main/skills.
|
|
39
39
|
The Nuxt Vite dev server also auto-emits Prisma Next contract artifacts when the contract changes.
|
|
40
40
|
|
|
41
41
|
Node-based Prisma Next projects expect Node.js 24 LTS or newer.
|
|
@@ -34,7 +34,7 @@ Database helper scripts are added to `package.json`:
|
|
|
34
34
|
|
|
35
35
|
- `{{runScriptCommand packageManager "db:seed"}}` - insert sample users manually
|
|
36
36
|
|
|
37
|
-
For provider-specific Prisma Next reference docs, see `prisma-next.md`.
|
|
37
|
+
For provider-specific Prisma Next reference docs, see `prisma-next.md`. Prisma Next skills live in the upstream `skills/` directory: https://github.com/prisma/prisma-next/tree/main/skills.
|
|
38
38
|
The SvelteKit Vite dev server also auto-emits Prisma Next contract artifacts when the contract changes.
|
|
39
39
|
|
|
40
40
|
Node-based Prisma Next projects expect Node.js 24 LTS or newer.
|
|
@@ -34,7 +34,7 @@ Database helper scripts are added to `package.json`:
|
|
|
34
34
|
|
|
35
35
|
- `{{runScriptCommand packageManager "db:seed"}}` - insert sample users manually
|
|
36
36
|
|
|
37
|
-
For provider-specific Prisma Next reference docs, see `prisma-next.md`.
|
|
37
|
+
For provider-specific Prisma Next reference docs, see `prisma-next.md`. Prisma Next skills live in the upstream `skills/` directory: https://github.com/prisma/prisma-next/tree/main/skills.
|
|
38
38
|
The TanStack Start Vite dev server also auto-emits Prisma Next contract artifacts when the contract changes.
|
|
39
39
|
|
|
40
40
|
Node-based Prisma Next projects expect Node.js 24 LTS or newer.
|