create-prisma 0.3.1 → 0.3.2-pr.31.50.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 +19 -1
- package/dist/cli.mjs +1 -1
- package/dist/{create-C43eBbSj.mjs → create-CCickgHj.mjs} +172 -35
- package/dist/index.d.mts +6 -0
- package/dist/index.mjs +2 -2
- package/package.json +2 -2
- package/templates/create/astro/src/pages/index.astro.hbs +39 -49
- package/templates/create/elysia/README.md.hbs +31 -0
- package/templates/create/elysia/deno.json.hbs +5 -0
- package/templates/create/elysia/package.json.hbs +23 -0
- package/templates/create/elysia/prisma/schema.prisma.hbs +25 -0
- package/templates/create/elysia/prisma/seed.ts.hbs +42 -0
- package/templates/create/elysia/prisma.config.ts.hbs +15 -0
- package/templates/create/elysia/src/index.ts.hbs +30 -0
- package/templates/create/elysia/src/lib/prisma.ts.hbs +57 -0
- package/templates/create/elysia/tsconfig.json +14 -0
- package/templates/create/hono/README.md.hbs +2 -2
- package/templates/create/hono/package.json.hbs +3 -4
- package/templates/create/hono/prisma/schema.prisma.hbs +4 -0
- package/templates/create/hono/prisma/seed.ts.hbs +5 -1
- package/templates/create/hono/prisma.config.ts.hbs +15 -0
- package/templates/create/hono/src/index.ts.hbs +4 -1
- package/templates/create/hono/src/lib/prisma.ts.hbs +6 -2
- package/templates/create/nest/.yarnrc.yml.hbs +3 -0
- package/templates/create/nest/README.md.hbs +31 -0
- package/templates/create/nest/deno.json.hbs +5 -0
- package/templates/create/nest/package.json.hbs +24 -0
- package/templates/create/nest/prisma/schema.prisma.hbs +25 -0
- package/templates/create/nest/prisma/seed.ts.hbs +44 -0
- package/templates/create/nest/prisma.config.ts.hbs +15 -0
- package/templates/create/nest/scripts/dev.ts.hbs +105 -0
- package/templates/create/nest/src/app.controller.ts.hbs +11 -0
- package/templates/create/nest/src/app.module.ts.hbs +20 -0
- package/templates/create/nest/src/lib/prisma.ts.hbs +59 -0
- package/templates/create/nest/src/main.ts.hbs +17 -0
- package/templates/create/nest/src/prisma.service.ts.hbs +10 -0
- package/templates/create/nest/src/users.controller.ts.hbs +15 -0
- package/templates/create/nest/src/users.service.ts.hbs +19 -0
- package/templates/create/nest/tsconfig.json +16 -0
- package/templates/create/next/src/app/globals.css +38 -46
- package/templates/create/nuxt/app/pages/index.vue.hbs +45 -55
- package/templates/create/svelte/src/routes/+page.svelte.hbs +78 -99
- package/templates/create/tanstack-start/prisma/schema.prisma.hbs +0 -1
- package/templates/create/tanstack-start/src/routes/index.tsx.hbs +28 -30
- package/templates/create/tanstack-start/src/styles.css +80 -121
- package/templates/create/turborepo/apps/api/src/index.ts.hbs +3 -0
- package/templates/create/hono/prisma.config.ts +0 -13
package/README.md
CHANGED
|
@@ -44,6 +44,24 @@ Create a Hono project non-interactively:
|
|
|
44
44
|
create-prisma --name my-api --template hono --provider postgresql
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
+
Scaffold into the current directory:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
create-prisma --name . --template hono --provider postgresql
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Create an Elysia project non-interactively:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
create-prisma --name my-elysia-api --template elysia --provider postgresql
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Create a NestJS project non-interactively:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
create-prisma --name my-nest-api --template nest --provider postgresql
|
|
63
|
+
```
|
|
64
|
+
|
|
47
65
|
Create a Next.js project non-interactively:
|
|
48
66
|
|
|
49
67
|
```bash
|
|
@@ -137,7 +155,7 @@ The CLI updates `package.json` with Prisma dependencies, optionally runs depende
|
|
|
137
155
|
|
|
138
156
|
`create` is the default command and currently supports:
|
|
139
157
|
|
|
140
|
-
- templates: `hono`, `next`, `svelte`, `astro`, `nuxt`, `tanstack-start`, `turborepo`
|
|
158
|
+
- templates: `hono`, `elysia`, `nest`, `next`, `svelte`, `astro`, `nuxt`, `tanstack-start`, `turborepo`
|
|
141
159
|
- project name via `--name`
|
|
142
160
|
- schema presets via `--schema-preset empty|basic` (default: `basic`)
|
|
143
161
|
|
package/dist/cli.mjs
CHANGED
|
@@ -21,7 +21,8 @@ const dependencyVersionMap = {
|
|
|
21
21
|
"@prisma/adapter-mssql": "^7.4.0",
|
|
22
22
|
dotenv: "^17.2.3",
|
|
23
23
|
"node-gyp": "^11.5.0",
|
|
24
|
-
prisma: "^7.4.0"
|
|
24
|
+
prisma: "^7.4.0",
|
|
25
|
+
tsx: "^4.21.0"
|
|
25
26
|
};
|
|
26
27
|
|
|
27
28
|
//#endregion
|
|
@@ -43,6 +44,8 @@ const packageManagers = [
|
|
|
43
44
|
const schemaPresets = ["empty", "basic"];
|
|
44
45
|
const createTemplates = [
|
|
45
46
|
"hono",
|
|
47
|
+
"elysia",
|
|
48
|
+
"nest",
|
|
46
49
|
"next",
|
|
47
50
|
"svelte",
|
|
48
51
|
"astro",
|
|
@@ -109,6 +112,9 @@ const packageManagerManifestValues = {
|
|
|
109
112
|
yarn: "yarn@4.13.0",
|
|
110
113
|
bun: "bun@1.3.9"
|
|
111
114
|
};
|
|
115
|
+
function normalizeVersion(version) {
|
|
116
|
+
return version.replace(/^[^0-9]*/, "");
|
|
117
|
+
}
|
|
112
118
|
function parseUserAgent(userAgent) {
|
|
113
119
|
if (userAgent?.startsWith("pnpm")) return "pnpm";
|
|
114
120
|
if (userAgent?.startsWith("yarn")) return "yarn";
|
|
@@ -181,10 +187,17 @@ function getPackageManagerManifestValue(packageManager) {
|
|
|
181
187
|
return packageManagerManifestValues[packageManager];
|
|
182
188
|
}
|
|
183
189
|
function getDenoPrismaSpecifier() {
|
|
184
|
-
return `npm:prisma@${dependencyVersionMap.prisma
|
|
190
|
+
return `npm:prisma@${normalizeVersion(dependencyVersionMap.prisma)}`;
|
|
191
|
+
}
|
|
192
|
+
function getDenoAllowedScriptSpecifiers() {
|
|
193
|
+
return [
|
|
194
|
+
`npm:prisma@${normalizeVersion(dependencyVersionMap.prisma)}`,
|
|
195
|
+
`npm:@prisma/client@${normalizeVersion(dependencyVersionMap["@prisma/client"])}`,
|
|
196
|
+
`npm:@prisma/engines@${normalizeVersion(dependencyVersionMap.prisma)}`
|
|
197
|
+
].join(",");
|
|
185
198
|
}
|
|
186
199
|
function getInstallCommand(packageManager) {
|
|
187
|
-
if (packageManager === "deno") return
|
|
200
|
+
if (packageManager === "deno") return `deno install --allow-scripts=${getDenoAllowedScriptSpecifiers()}`;
|
|
188
201
|
return `${packageManager} install`;
|
|
189
202
|
}
|
|
190
203
|
function getRunScriptCommand(packageManager, scriptName) {
|
|
@@ -196,10 +209,52 @@ function getRunScriptCommand(packageManager, scriptName) {
|
|
|
196
209
|
default: return `npm run ${scriptName}`;
|
|
197
210
|
}
|
|
198
211
|
}
|
|
212
|
+
function joinCommandParts(parts) {
|
|
213
|
+
return parts.filter((part) => typeof part === "string" && part.length > 0).join(" ");
|
|
214
|
+
}
|
|
215
|
+
function usesNodeStyleRuntime(packageManager) {
|
|
216
|
+
return packageManager !== void 0 && packageManager !== "bun" && packageManager !== "deno";
|
|
217
|
+
}
|
|
218
|
+
function requiresDotenvConfigImport(packageManager) {
|
|
219
|
+
return usesNodeStyleRuntime(packageManager);
|
|
220
|
+
}
|
|
221
|
+
function getRuntimeScriptCommand(packageManager, kind, options) {
|
|
222
|
+
const { sourceEntrypoint, builtEntrypoint, denoFlags = [], nodeDevCommand, nodeBuildCommand, nodeStartCommand, bunDevCommand, bunBuildCommand, bunStartCommand } = options;
|
|
223
|
+
if (packageManager === "deno") switch (kind) {
|
|
224
|
+
case "dev": return joinCommandParts([
|
|
225
|
+
"deno",
|
|
226
|
+
"run",
|
|
227
|
+
"-A",
|
|
228
|
+
"--env-file=.env",
|
|
229
|
+
...denoFlags,
|
|
230
|
+
"--watch",
|
|
231
|
+
sourceEntrypoint
|
|
232
|
+
]);
|
|
233
|
+
case "build": return `deno check ${sourceEntrypoint}`;
|
|
234
|
+
case "start": return joinCommandParts([
|
|
235
|
+
"deno",
|
|
236
|
+
"run",
|
|
237
|
+
"-A",
|
|
238
|
+
"--env-file=.env",
|
|
239
|
+
...denoFlags,
|
|
240
|
+
sourceEntrypoint
|
|
241
|
+
]);
|
|
242
|
+
}
|
|
243
|
+
if (packageManager === "bun") switch (kind) {
|
|
244
|
+
case "dev": return bunDevCommand ?? `bun --watch ${sourceEntrypoint}`;
|
|
245
|
+
case "build": return bunBuildCommand ?? "tsc --noEmit";
|
|
246
|
+
case "start": return bunStartCommand ?? `bun ${sourceEntrypoint}`;
|
|
247
|
+
}
|
|
248
|
+
switch (kind) {
|
|
249
|
+
case "dev": return nodeDevCommand ?? `tsx watch ${sourceEntrypoint}`;
|
|
250
|
+
case "build": return nodeBuildCommand ?? "tsc";
|
|
251
|
+
case "start": return nodeStartCommand ?? `tsx ${builtEntrypoint ?? sourceEntrypoint}`;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
199
254
|
function getInstallArgs(packageManager) {
|
|
200
255
|
if (packageManager === "deno") return {
|
|
201
256
|
command: "deno",
|
|
202
|
-
args: ["install",
|
|
257
|
+
args: ["install", `--allow-scripts=${getDenoAllowedScriptSpecifiers()}`]
|
|
203
258
|
};
|
|
204
259
|
return {
|
|
205
260
|
command: packageManager,
|
|
@@ -254,6 +309,7 @@ function getPrismaCliArgs(packageManager, prismaArgs) {
|
|
|
254
309
|
args: [
|
|
255
310
|
"run",
|
|
256
311
|
"-A",
|
|
312
|
+
"--env-file=.env",
|
|
257
313
|
getDenoPrismaSpecifier(),
|
|
258
314
|
...prismaArgs
|
|
259
315
|
]
|
|
@@ -267,10 +323,33 @@ function getPrismaCliCommand(packageManager, prismaArgs) {
|
|
|
267
323
|
|
|
268
324
|
//#endregion
|
|
269
325
|
//#region src/templates/shared.ts
|
|
326
|
+
function getOptionalHashString(hash, key) {
|
|
327
|
+
const value = hash[key];
|
|
328
|
+
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
329
|
+
}
|
|
330
|
+
function getOptionalHashStringList(hash, key) {
|
|
331
|
+
return getOptionalHashString(hash, key)?.split(" ") ?? [];
|
|
332
|
+
}
|
|
270
333
|
Handlebars.registerHelper("eq", (left, right) => left === right);
|
|
271
334
|
Handlebars.registerHelper("installCommand", (packageManager) => packageManager ? getInstallCommand(packageManager) : "");
|
|
272
335
|
Handlebars.registerHelper("runScriptCommand", (packageManager, scriptName) => packageManager ? getRunScriptCommand(packageManager, scriptName) : "");
|
|
273
336
|
Handlebars.registerHelper("packageManagerManifestValue", (packageManager) => getPackageManagerManifestValue(packageManager) ?? "");
|
|
337
|
+
Handlebars.registerHelper("requiresDotenvConfigImport", (packageManager) => requiresDotenvConfigImport(packageManager));
|
|
338
|
+
Handlebars.registerHelper("runtimeScript", (packageManager, kind, sourceEntrypoint, builtEntrypoint, options) => {
|
|
339
|
+
if (!packageManager) return "";
|
|
340
|
+
const hash = options.hash;
|
|
341
|
+
return getRuntimeScriptCommand(packageManager, kind, {
|
|
342
|
+
sourceEntrypoint,
|
|
343
|
+
builtEntrypoint,
|
|
344
|
+
denoFlags: getOptionalHashStringList(hash, "denoFlags"),
|
|
345
|
+
nodeDevCommand: getOptionalHashString(hash, "nodeDev"),
|
|
346
|
+
nodeBuildCommand: getOptionalHashString(hash, "nodeBuild"),
|
|
347
|
+
nodeStartCommand: getOptionalHashString(hash, "nodeStart"),
|
|
348
|
+
bunDevCommand: getOptionalHashString(hash, "bunDev"),
|
|
349
|
+
bunBuildCommand: getOptionalHashString(hash, "bunBuild"),
|
|
350
|
+
bunStartCommand: getOptionalHashString(hash, "bunStart")
|
|
351
|
+
});
|
|
352
|
+
});
|
|
274
353
|
function findPackageRoot(startDir) {
|
|
275
354
|
let currentDir = startDir;
|
|
276
355
|
while (true) {
|
|
@@ -370,10 +449,19 @@ function getPrismaScriptMap(packageManager) {
|
|
|
370
449
|
if (packageManager === "deno") {
|
|
371
450
|
const prismaSpecifier = getDenoPrismaSpecifier();
|
|
372
451
|
return {
|
|
373
|
-
"db:generate": `deno run -A ${prismaSpecifier} generate`,
|
|
374
|
-
"db:push": `deno run -A ${prismaSpecifier} db push`,
|
|
375
|
-
"db:migrate": `deno run -A ${prismaSpecifier} migrate dev`,
|
|
376
|
-
"db:seed": `deno run -A ${prismaSpecifier} db seed`
|
|
452
|
+
"db:generate": `deno run -A --env-file=.env ${prismaSpecifier} generate`,
|
|
453
|
+
"db:push": `deno run -A --env-file=.env ${prismaSpecifier} db push`,
|
|
454
|
+
"db:migrate": `deno run -A --env-file=.env ${prismaSpecifier} migrate dev`,
|
|
455
|
+
"db:seed": `deno run -A --env-file=.env ${prismaSpecifier} db seed`
|
|
456
|
+
};
|
|
457
|
+
}
|
|
458
|
+
if (packageManager === "bun") {
|
|
459
|
+
const prismaCli = "bun --env-file=.env ./node_modules/.bin/prisma";
|
|
460
|
+
return {
|
|
461
|
+
"db:generate": `${prismaCli} generate`,
|
|
462
|
+
"db:push": `${prismaCli} db push`,
|
|
463
|
+
"db:migrate": `${prismaCli} migrate dev`,
|
|
464
|
+
"db:seed": `${prismaCli} db seed`
|
|
377
465
|
};
|
|
378
466
|
}
|
|
379
467
|
return {
|
|
@@ -392,6 +480,29 @@ function unique(items) {
|
|
|
392
480
|
function sortRecord(record) {
|
|
393
481
|
return Object.fromEntries(Object.entries(record).sort(([a], [b]) => a.localeCompare(b)));
|
|
394
482
|
}
|
|
483
|
+
async function projectContainsText(projectDir, text) {
|
|
484
|
+
const entries = await fs.readdir(projectDir, { withFileTypes: true });
|
|
485
|
+
for (const entry of entries) {
|
|
486
|
+
if (entry.name === "node_modules" || entry.name === ".git") continue;
|
|
487
|
+
const entryPath = path.join(projectDir, entry.name);
|
|
488
|
+
if (entry.isDirectory()) {
|
|
489
|
+
if (await projectContainsText(entryPath, text)) return true;
|
|
490
|
+
continue;
|
|
491
|
+
}
|
|
492
|
+
if (!entry.isFile() || !/\.(c|m)?[jt]sx?$/.test(entry.name)) continue;
|
|
493
|
+
if ((await fs.readFile(entryPath, "utf8")).includes(text)) return true;
|
|
494
|
+
}
|
|
495
|
+
return false;
|
|
496
|
+
}
|
|
497
|
+
function scriptUsesBinary(command, binaryName) {
|
|
498
|
+
return command.split(/\s+/).includes(binaryName);
|
|
499
|
+
}
|
|
500
|
+
async function projectUsesScriptBinary(projectDir, binaryName) {
|
|
501
|
+
const pkgJsonPath = path.join(projectDir, "package.json");
|
|
502
|
+
if (!await fs.pathExists(pkgJsonPath)) return false;
|
|
503
|
+
const pkgJson = await fs.readJson(pkgJsonPath);
|
|
504
|
+
return Object.values(pkgJson.scripts ?? {}).some((script) => typeof script === "string" && scriptUsesBinary(script, binaryName));
|
|
505
|
+
}
|
|
395
506
|
async function addPackageDependency(opts) {
|
|
396
507
|
const { dependencies = [], devDependencies = [], customDependencies = {}, customDevDependencies = {}, scripts = {}, scriptMode = "upsert", projectDir } = opts;
|
|
397
508
|
const addedScripts = [];
|
|
@@ -435,10 +546,11 @@ async function addPackageDependency(opts) {
|
|
|
435
546
|
};
|
|
436
547
|
}
|
|
437
548
|
async function writePrismaDependencies(provider, packageManager, projectDir = process.cwd()) {
|
|
438
|
-
const dependencies = ["@prisma/client"
|
|
549
|
+
const dependencies = ["@prisma/client"];
|
|
439
550
|
const devDependencies = ["prisma"];
|
|
440
551
|
const { adapterPackage } = getDbPackages(provider);
|
|
441
552
|
dependencies.push(adapterPackage);
|
|
553
|
+
if (requiresDotenvConfigImport(packageManager) || await projectContainsText(projectDir, "dotenv/config")) dependencies.push("dotenv");
|
|
442
554
|
if (provider === "sqlite" && packageManager === "deno") devDependencies.push("node-gyp");
|
|
443
555
|
const prismaScriptMap = getPrismaScriptMap(packageManager);
|
|
444
556
|
const scriptWriteResult = await addPackageDependency({
|
|
@@ -456,6 +568,15 @@ async function writePrismaDependencies(provider, packageManager, projectDir = pr
|
|
|
456
568
|
existingScripts: scriptWriteResult.existingScripts
|
|
457
569
|
};
|
|
458
570
|
}
|
|
571
|
+
async function writeCreateTemplateDependencies(opts) {
|
|
572
|
+
const { projectDir = process.cwd() } = opts;
|
|
573
|
+
const devDependencies = await projectUsesScriptBinary(projectDir, "tsx") ? ["tsx"] : [];
|
|
574
|
+
if (devDependencies.length === 0) return;
|
|
575
|
+
await addPackageDependency({
|
|
576
|
+
devDependencies,
|
|
577
|
+
projectDir
|
|
578
|
+
});
|
|
579
|
+
}
|
|
459
580
|
async function installProjectDependencies(packageManager, projectDir = process.cwd(), options = {}) {
|
|
460
581
|
const verbose = options.verbose === true;
|
|
461
582
|
const installCommand = getInstallArgs(packageManager);
|
|
@@ -1500,21 +1621,12 @@ async function executeCreateAddonSetupContext(params) {
|
|
|
1500
1621
|
|
|
1501
1622
|
//#endregion
|
|
1502
1623
|
//#region src/telemetry/client.ts
|
|
1503
|
-
const TELEMETRY_API_KEY = "
|
|
1624
|
+
const TELEMETRY_API_KEY = "";
|
|
1504
1625
|
const TELEMETRY_HOST = "https://us.i.posthog.com";
|
|
1505
1626
|
const TELEMETRY_CONFIG_FILE = "telemetry.json";
|
|
1506
1627
|
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;
|
|
1507
|
-
function isTruthyEnvValue(value) {
|
|
1508
|
-
return [
|
|
1509
|
-
"1",
|
|
1510
|
-
"true",
|
|
1511
|
-
"yes",
|
|
1512
|
-
"on"
|
|
1513
|
-
].includes(String(value ?? "").trim().toLowerCase());
|
|
1514
|
-
}
|
|
1515
1628
|
function shouldDisableTelemetry() {
|
|
1516
|
-
|
|
1517
|
-
return process.env.CREATE_PRISMA_DISABLE_TELEMETRY !== void 0 || process.env.CREATE_PRISMA_TELEMETRY_DISABLED !== void 0 || process.env.DO_NOT_TRACK !== void 0;
|
|
1629
|
+
return true;
|
|
1518
1630
|
}
|
|
1519
1631
|
function getTelemetryConfigDir() {
|
|
1520
1632
|
if (process.platform === "darwin") return path.join(os.homedir(), "Library", "Application Support", "create-prisma");
|
|
@@ -1536,7 +1648,7 @@ async function getAnonymousId() {
|
|
|
1536
1648
|
}
|
|
1537
1649
|
function getCommonProperties() {
|
|
1538
1650
|
return {
|
|
1539
|
-
"cli-version": "0.3.1",
|
|
1651
|
+
"cli-version": "0.3.2-pr.31.50.1",
|
|
1540
1652
|
"node-version": process.version,
|
|
1541
1653
|
platform: process.platform,
|
|
1542
1654
|
arch: process.arch
|
|
@@ -1549,22 +1661,22 @@ async function trackCliTelemetry(event, properties) {
|
|
|
1549
1661
|
if (shouldDisableTelemetry()) return;
|
|
1550
1662
|
let client;
|
|
1551
1663
|
try {
|
|
1664
|
+
const distinctId = await getAnonymousId();
|
|
1665
|
+
const sanitizedProperties = sanitizeProperties({
|
|
1666
|
+
...getCommonProperties(),
|
|
1667
|
+
...properties,
|
|
1668
|
+
$process_person_profile: false
|
|
1669
|
+
});
|
|
1552
1670
|
client = new PostHog(TELEMETRY_API_KEY, {
|
|
1553
1671
|
host: TELEMETRY_HOST,
|
|
1554
|
-
captureMode: "json",
|
|
1555
1672
|
disableGeoip: true,
|
|
1556
1673
|
flushAt: 1,
|
|
1557
|
-
flushInterval: 0
|
|
1558
|
-
persistence: "memory"
|
|
1674
|
+
flushInterval: 0
|
|
1559
1675
|
});
|
|
1560
1676
|
await client.captureImmediate({
|
|
1561
|
-
distinctId
|
|
1677
|
+
distinctId,
|
|
1562
1678
|
event,
|
|
1563
|
-
properties:
|
|
1564
|
-
...getCommonProperties(),
|
|
1565
|
-
...properties,
|
|
1566
|
-
$process_person_profile: false
|
|
1567
|
-
}),
|
|
1679
|
+
properties: sanitizedProperties,
|
|
1568
1680
|
disableGeoip: true
|
|
1569
1681
|
});
|
|
1570
1682
|
} catch {} finally {
|
|
@@ -1658,7 +1770,7 @@ function formatPathForDisplay(filePath) {
|
|
|
1658
1770
|
function validateProjectName(value) {
|
|
1659
1771
|
const trimmed = String(value ?? "").trim();
|
|
1660
1772
|
if (trimmed.length === 0) return "Please enter a project name.";
|
|
1661
|
-
if (trimmed === "
|
|
1773
|
+
if (trimmed === "..") return "Project name cannot be '..'.";
|
|
1662
1774
|
if (path.isAbsolute(trimmed)) return "Use a relative project name instead of an absolute path.";
|
|
1663
1775
|
}
|
|
1664
1776
|
async function promptForProjectName() {
|
|
@@ -1684,6 +1796,16 @@ async function promptForCreateTemplate() {
|
|
|
1684
1796
|
label: "Hono",
|
|
1685
1797
|
hint: "TypeScript API starter"
|
|
1686
1798
|
},
|
|
1799
|
+
{
|
|
1800
|
+
value: "elysia",
|
|
1801
|
+
label: "Elysia",
|
|
1802
|
+
hint: "TypeScript API starter with Elysia's Node adapter"
|
|
1803
|
+
},
|
|
1804
|
+
{
|
|
1805
|
+
value: "nest",
|
|
1806
|
+
label: "NestJS",
|
|
1807
|
+
hint: "Official Nest-style API starter with a Prisma service"
|
|
1808
|
+
},
|
|
1687
1809
|
{
|
|
1688
1810
|
value: "next",
|
|
1689
1811
|
label: "Next.js",
|
|
@@ -1782,8 +1904,14 @@ async function runCreateCommand(rawInput = {}) {
|
|
|
1782
1904
|
async function collectCreateContext(input) {
|
|
1783
1905
|
const useDefaults = input.yes === true;
|
|
1784
1906
|
const force = input.force === true;
|
|
1785
|
-
const
|
|
1786
|
-
if (!
|
|
1907
|
+
const projectNameInput = input.name ?? (useDefaults ? DEFAULT_PROJECT_NAME : await promptForProjectName());
|
|
1908
|
+
if (!projectNameInput) return;
|
|
1909
|
+
const projectName = String(projectNameInput).trim();
|
|
1910
|
+
const projectNameValidationError = validateProjectName(projectName);
|
|
1911
|
+
if (projectNameValidationError) {
|
|
1912
|
+
cancel(projectNameValidationError);
|
|
1913
|
+
return;
|
|
1914
|
+
}
|
|
1787
1915
|
const template = input.template ?? (useDefaults ? DEFAULT_TEMPLATE : await promptForCreateTemplate());
|
|
1788
1916
|
if (!template) return;
|
|
1789
1917
|
const targetDirectory = path.resolve(process.cwd(), projectName);
|
|
@@ -1839,8 +1967,17 @@ async function executeCreateContext(context) {
|
|
|
1839
1967
|
error
|
|
1840
1968
|
};
|
|
1841
1969
|
}
|
|
1970
|
+
try {
|
|
1971
|
+
await writeCreateTemplateDependencies({ projectDir: context.targetDirectory });
|
|
1972
|
+
} catch (error) {
|
|
1973
|
+
return {
|
|
1974
|
+
ok: false,
|
|
1975
|
+
stage: "scaffold_template",
|
|
1976
|
+
error
|
|
1977
|
+
};
|
|
1978
|
+
}
|
|
1842
1979
|
if (context.targetPathState.exists && !context.targetPathState.isEmptyDirectory && context.force) log.warn(`Used --force in non-empty directory ${formatPathForDisplay(context.targetDirectory)}.`);
|
|
1843
|
-
const
|
|
1980
|
+
const nextSteps = formatPathForDisplay(context.targetDirectory) === "." ? [] : [`- cd ${formatPathForDisplay(context.targetDirectory)}`];
|
|
1844
1981
|
if (context.addonSetupContext) try {
|
|
1845
1982
|
await executeCreateAddonSetupContext({
|
|
1846
1983
|
context: context.addonSetupContext,
|
|
@@ -1857,7 +1994,7 @@ async function executeCreateContext(context) {
|
|
|
1857
1994
|
}
|
|
1858
1995
|
try {
|
|
1859
1996
|
if (!await executePrismaSetupContext(context.prismaSetupContext, {
|
|
1860
|
-
prependNextSteps:
|
|
1997
|
+
prependNextSteps: nextSteps,
|
|
1861
1998
|
projectDir: context.targetDirectory,
|
|
1862
1999
|
includeDevNextStep: true
|
|
1863
2000
|
})) return {
|
package/dist/index.d.mts
CHANGED
|
@@ -197,6 +197,8 @@ declare const SchemaPresetSchema: z.ZodEnum<{
|
|
|
197
197
|
}>;
|
|
198
198
|
declare const CreateTemplateSchema: z.ZodEnum<{
|
|
199
199
|
hono: "hono";
|
|
200
|
+
elysia: "elysia";
|
|
201
|
+
nest: "nest";
|
|
200
202
|
next: "next";
|
|
201
203
|
svelte: "svelte";
|
|
202
204
|
astro: "astro";
|
|
@@ -233,6 +235,8 @@ declare const CreateCommandInputSchema: z.ZodObject<{
|
|
|
233
235
|
name: z.ZodOptional<z.ZodString>;
|
|
234
236
|
template: z.ZodOptional<z.ZodEnum<{
|
|
235
237
|
hono: "hono";
|
|
238
|
+
elysia: "elysia";
|
|
239
|
+
nest: "nest";
|
|
236
240
|
next: "next";
|
|
237
241
|
svelte: "svelte";
|
|
238
242
|
astro: "astro";
|
|
@@ -277,6 +281,8 @@ declare const router: {
|
|
|
277
281
|
name: zod.ZodOptional<zod.ZodString>;
|
|
278
282
|
template: zod.ZodOptional<zod.ZodEnum<{
|
|
279
283
|
hono: "hono";
|
|
284
|
+
elysia: "elysia";
|
|
285
|
+
nest: "nest";
|
|
280
286
|
next: "next";
|
|
281
287
|
svelte: "svelte";
|
|
282
288
|
astro: "astro";
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as DatabaseUrlSchema, i as DatabaseProviderSchema, n as CreateCommandInputSchema, o as PackageManagerSchema, r as CreateTemplateSchema, s as SchemaPresetSchema, t as runCreateCommand } from "./create-
|
|
2
|
+
import { a as DatabaseUrlSchema, i as DatabaseProviderSchema, n as CreateCommandInputSchema, o as PackageManagerSchema, r as CreateTemplateSchema, s as SchemaPresetSchema, t as runCreateCommand } from "./create-CCickgHj.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.3.1";
|
|
7
|
+
const CLI_VERSION = "0.3.2-pr.31.50.1";
|
|
8
8
|
const router = os.router({ create: os.meta({
|
|
9
9
|
description: "Create a new project with Prisma setup",
|
|
10
10
|
default: true,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-prisma",
|
|
3
|
-
"version": "0.3.1",
|
|
3
|
+
"version": "0.3.2-pr.31.50.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Create Prisma 7 projects with first-party templates and great DX.",
|
|
6
6
|
"homepage": "https://github.com/prisma/create-prisma",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"execa": "^9.6.1",
|
|
53
53
|
"fs-extra": "^11.3.3",
|
|
54
54
|
"handlebars": "^4.7.8",
|
|
55
|
-
"posthog-node": "
|
|
55
|
+
"posthog-node": "^5.28.2",
|
|
56
56
|
"trpc-cli": "^0.12.4",
|
|
57
57
|
"zod": "^4.3.6"
|
|
58
58
|
},
|
|
@@ -111,53 +111,48 @@ const users = await prisma.user
|
|
|
111
111
|
<style>
|
|
112
112
|
:global(body) {
|
|
113
113
|
margin: 0;
|
|
114
|
-
font-family:
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
sans-serif;
|
|
118
|
-
background: #f7f8fb;
|
|
119
|
-
color: #0f172a;
|
|
114
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
|
|
115
|
+
background: #fff;
|
|
116
|
+
color: #111;
|
|
120
117
|
}
|
|
121
118
|
|
|
122
119
|
.shell {
|
|
123
|
-
width:
|
|
120
|
+
max-width: 40rem;
|
|
124
121
|
margin: 0 auto;
|
|
125
|
-
padding:
|
|
122
|
+
padding: 3rem 1.5rem;
|
|
126
123
|
}
|
|
127
124
|
|
|
128
125
|
.hero {
|
|
129
|
-
margin-bottom:
|
|
126
|
+
margin-bottom: 1.5rem;
|
|
130
127
|
}
|
|
131
128
|
|
|
132
129
|
.eyebrow {
|
|
133
|
-
margin: 0 0 0.
|
|
134
|
-
color: #
|
|
135
|
-
font-size: 0.
|
|
136
|
-
font-weight:
|
|
137
|
-
letter-spacing: 0.
|
|
130
|
+
margin: 0 0 0.5rem;
|
|
131
|
+
color: #666;
|
|
132
|
+
font-size: 0.75rem;
|
|
133
|
+
font-weight: 600;
|
|
134
|
+
letter-spacing: 0.06em;
|
|
138
135
|
text-transform: uppercase;
|
|
139
136
|
}
|
|
140
137
|
|
|
141
138
|
h1 {
|
|
142
139
|
margin: 0;
|
|
143
|
-
|
|
144
|
-
font-
|
|
145
|
-
line-height:
|
|
140
|
+
font-size: 1.25rem;
|
|
141
|
+
font-weight: 600;
|
|
142
|
+
line-height: 1.4;
|
|
146
143
|
}
|
|
147
144
|
|
|
148
145
|
.lede {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
146
|
+
margin: 0.5rem 0 0;
|
|
147
|
+
color: #666;
|
|
148
|
+
font-size: 0.875rem;
|
|
149
|
+
line-height: 1.6;
|
|
153
150
|
}
|
|
154
151
|
|
|
155
152
|
.panel {
|
|
156
|
-
|
|
157
|
-
border:
|
|
158
|
-
|
|
159
|
-
background: #ffffff;
|
|
160
|
-
box-shadow: 0 12px 32px rgba(15, 23, 42, 0.06);
|
|
153
|
+
border: 1px solid #e5e5e5;
|
|
154
|
+
border-radius: 0.5rem;
|
|
155
|
+
padding: 1rem;
|
|
161
156
|
}
|
|
162
157
|
|
|
163
158
|
.panel-header {
|
|
@@ -165,22 +160,25 @@ const users = await prisma.user
|
|
|
165
160
|
align-items: center;
|
|
166
161
|
justify-content: space-between;
|
|
167
162
|
gap: 1rem;
|
|
168
|
-
margin-bottom:
|
|
163
|
+
margin-bottom: 0.75rem;
|
|
169
164
|
}
|
|
170
165
|
|
|
171
166
|
h2 {
|
|
172
167
|
margin: 0;
|
|
173
|
-
font-size:
|
|
168
|
+
font-size: 0.875rem;
|
|
169
|
+
font-weight: 600;
|
|
174
170
|
}
|
|
175
171
|
|
|
176
172
|
.panel-header span,
|
|
177
173
|
.empty,
|
|
178
174
|
time {
|
|
179
|
-
color: #
|
|
175
|
+
color: #888;
|
|
176
|
+
font-size: 0.8rem;
|
|
180
177
|
}
|
|
181
178
|
|
|
182
179
|
.panel p {
|
|
183
|
-
color: #
|
|
180
|
+
color: #666;
|
|
181
|
+
font-size: 0.8rem;
|
|
184
182
|
}
|
|
185
183
|
|
|
186
184
|
.users {
|
|
@@ -188,7 +186,7 @@ const users = await prisma.user
|
|
|
188
186
|
margin: 0;
|
|
189
187
|
padding: 0;
|
|
190
188
|
display: grid;
|
|
191
|
-
gap: 0.
|
|
189
|
+
gap: 0.5rem;
|
|
192
190
|
}
|
|
193
191
|
|
|
194
192
|
.users li {
|
|
@@ -196,37 +194,29 @@ const users = await prisma.user
|
|
|
196
194
|
align-items: center;
|
|
197
195
|
justify-content: space-between;
|
|
198
196
|
gap: 1rem;
|
|
199
|
-
padding:
|
|
200
|
-
border
|
|
201
|
-
|
|
202
|
-
border: 1px solid #dbe2ea;
|
|
197
|
+
padding: 0.625rem 0.75rem;
|
|
198
|
+
border: 1px solid #eee;
|
|
199
|
+
border-radius: 0.375rem;
|
|
203
200
|
}
|
|
204
201
|
|
|
205
202
|
.users p {
|
|
206
|
-
margin: 0.
|
|
203
|
+
margin: 0.125rem 0 0;
|
|
207
204
|
}
|
|
208
205
|
|
|
209
206
|
time {
|
|
210
|
-
font-size: 0.
|
|
207
|
+
font-size: 0.75rem;
|
|
211
208
|
white-space: nowrap;
|
|
212
209
|
}
|
|
213
210
|
|
|
214
211
|
code {
|
|
215
|
-
padding: 0.
|
|
216
|
-
border-radius: 0.
|
|
217
|
-
background: #
|
|
218
|
-
font-family:
|
|
219
|
-
|
|
220
|
-
Consolas,
|
|
221
|
-
monospace;
|
|
222
|
-
font-size: 0.95em;
|
|
212
|
+
padding: 0.125rem 0.25rem;
|
|
213
|
+
border-radius: 0.25rem;
|
|
214
|
+
background: #f5f5f5;
|
|
215
|
+
font-family: SFMono-Regular, Consolas, monospace;
|
|
216
|
+
font-size: 0.875em;
|
|
223
217
|
}
|
|
224
218
|
|
|
225
219
|
@media (max-width: 640px) {
|
|
226
|
-
.shell {
|
|
227
|
-
padding-top: 3rem;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
220
|
.users li,
|
|
231
221
|
.panel-header {
|
|
232
222
|
flex-direction: column;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# {{projectName}}
|
|
2
|
+
|
|
3
|
+
Generated by `create-prisma` with the Elysia template.
|
|
4
|
+
|
|
5
|
+
## Scripts
|
|
6
|
+
|
|
7
|
+
- `{{runScriptCommand packageManager "dev"}}` - start local dev server with hot reload
|
|
8
|
+
- `{{runScriptCommand packageManager "build"}}` - {{#if (eq packageManager "deno")}}type-check the app with Deno{{else}}{{#if (eq packageManager "bun")}}type-check the app for Bun{{else}}typecheck and compile{{/if}}{{/if}}
|
|
9
|
+
- `{{runScriptCommand packageManager "start"}}` - {{#if (eq packageManager "deno")}}run the server directly from `src/index.ts` with Deno{{else}}{{#if (eq packageManager "bun")}}run the server directly from `src/index.ts` with Bun{{else}}run compiled server from `dist/`{{/if}}{{/if}}
|
|
10
|
+
|
|
11
|
+
## Prisma
|
|
12
|
+
|
|
13
|
+
1. Make sure dependencies are installed.
|
|
14
|
+
2. Generate Prisma Client:
|
|
15
|
+
|
|
16
|
+
`{{runScriptCommand packageManager "db:generate"}}`
|
|
17
|
+
|
|
18
|
+
3. Run your first migration:
|
|
19
|
+
|
|
20
|
+
`{{runScriptCommand packageManager "db:migrate"}}`
|
|
21
|
+
4. Seed the database:
|
|
22
|
+
|
|
23
|
+
`{{runScriptCommand packageManager "db:seed"}}`
|
|
24
|
+
|
|
25
|
+
5. Use the Prisma client from `src/lib/prisma.ts`.
|
|
26
|
+
|
|
27
|
+
Generated Prisma files are written to `src/generated/prisma`.
|
|
28
|
+
{{#if (eq schemaPreset "basic")}}
|
|
29
|
+
|
|
30
|
+
The template includes a basic `User` model, a sample `GET /users` endpoint, and seed data in `prisma/seed.ts`.
|
|
31
|
+
{{/if}}
|
|
@@ -0,0 +1,23 @@
|
|
|
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 "dev" "src/index.ts" "dist/src/index.js" denoFlags="--unstable-net"}}",
|
|
10
|
+
"build": "{{runtimeScript packageManager "build" "src/index.ts" "dist/src/index.js"}}",
|
|
11
|
+
"start": "{{runtimeScript packageManager "start" "src/index.ts" "dist/src/index.js" denoFlags="--unstable-net"}}"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@elysiajs/node": "^1.4.5",
|
|
15
|
+
"@sinclair/typebox": "^0.34.48",
|
|
16
|
+
"elysia": "^1.4.28",
|
|
17
|
+
"openapi-types": "^12.1.3"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@types/node": "^24.3.0",
|
|
21
|
+
"typescript": "^5.9.3"
|
|
22
|
+
}
|
|
23
|
+
}
|