create-prisma 0.4.2-next.37.87.1 → 0.4.2-next.37.89.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 +0 -1
- package/dist/cli.mjs +1 -1
- package/dist/{create-BP5eQN0b.mjs → create-C6SFJkUe.mjs} +34 -55
- package/dist/index.d.mts +1 -13
- package/dist/index.mjs +3 -3
- package/package.json +2 -2
- package/templates/create/_shared/prisma/seed.ts.hbs +1 -4
- package/templates/create/astro/README.md.hbs +1 -6
- package/templates/create/astro/src/lib/prisma.ts.hbs +4 -8
- package/templates/create/astro/src/pages/api/users.ts.hbs +1 -10
- package/templates/create/astro/src/pages/index.astro.hbs +3 -38
- package/templates/create/elysia/README.md.hbs +2 -4
- package/templates/create/elysia/src/index.ts.hbs +3 -4
- package/templates/create/elysia/src/lib/prisma.ts.hbs +4 -8
- package/templates/create/hono/README.md.hbs +2 -4
- package/templates/create/hono/src/index.ts.hbs +1 -4
- package/templates/create/hono/src/lib/prisma.ts.hbs +4 -8
- package/templates/create/nest/README.md.hbs +2 -4
- package/templates/create/nest/src/app.module.ts.hbs +5 -6
- package/templates/create/nest/src/lib/prisma.ts.hbs +4 -8
- package/templates/create/nest/src/users.controller.ts.hbs +1 -2
- package/templates/create/nest/src/users.service.ts.hbs +1 -2
- package/templates/create/next/README.md.hbs +2 -4
- package/templates/create/next/src/app/page.tsx.hbs +2 -38
- package/templates/create/next/src/lib/prisma.ts.hbs +4 -8
- package/templates/create/nuxt/README.md.hbs +2 -4
- package/templates/create/nuxt/app/pages/index.vue.hbs +2 -38
- package/templates/create/nuxt/server/api/users.get.ts.hbs +1 -6
- package/templates/create/nuxt/server/utils/prisma.ts.hbs +4 -8
- package/templates/create/svelte/README.md.hbs +1 -6
- package/templates/create/svelte/src/lib/server/prisma.ts.hbs +4 -8
- package/templates/create/svelte/src/routes/+page.server.ts.hbs +1 -6
- package/templates/create/svelte/src/routes/+page.svelte.hbs +0 -154
- package/templates/create/tanstack-start/README.md.hbs +2 -4
- package/templates/create/tanstack-start/src/lib/prisma.server.ts.hbs +4 -8
- package/templates/create/tanstack-start/src/routes/index.tsx.hbs +5 -45
package/README.md
CHANGED
|
@@ -118,7 +118,6 @@ create-prisma --name my-app --template nest --provider postgres --prisma-postgre
|
|
|
118
118
|
- `--provider postgres|postgresql|mongo|mongodb` (default: `postgres`)
|
|
119
119
|
- `--authoring psl|typescript` (default: `psl`)
|
|
120
120
|
- `--package-manager` choose the package manager/runtime
|
|
121
|
-
- `--schema-preset empty|basic` (default: `basic`)
|
|
122
121
|
- `--database-url` set `DATABASE_URL`
|
|
123
122
|
- `--yes` accept defaults and skip prompts
|
|
124
123
|
- `--no-install` scaffold only
|
package/dist/cli.mjs
CHANGED
|
@@ -13,12 +13,21 @@ import { execa } from "execa";
|
|
|
13
13
|
import { styleText } from "node:util";
|
|
14
14
|
|
|
15
15
|
//#region src/telemetry/client.ts
|
|
16
|
-
const TELEMETRY_API_KEY = "";
|
|
16
|
+
const TELEMETRY_API_KEY = "phc_cmc85avbWyuJ2JyKdGPdv7dxXli8xLdWDBPbvIXWJfs";
|
|
17
17
|
const TELEMETRY_HOST = "https://us.i.posthog.com";
|
|
18
18
|
const TELEMETRY_CONFIG_FILE = "telemetry.json";
|
|
19
19
|
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;
|
|
20
|
+
function isTruthyEnvValue(value) {
|
|
21
|
+
return [
|
|
22
|
+
"1",
|
|
23
|
+
"true",
|
|
24
|
+
"yes",
|
|
25
|
+
"on"
|
|
26
|
+
].includes(String(value ?? "").trim().toLowerCase());
|
|
27
|
+
}
|
|
20
28
|
function shouldDisableTelemetry() {
|
|
21
|
-
return true;
|
|
29
|
+
if (isTruthyEnvValue(process.env.CI) || isTruthyEnvValue(process.env.GITHUB_ACTIONS)) return true;
|
|
30
|
+
return process.env.CREATE_PRISMA_DISABLE_TELEMETRY !== void 0 || process.env.CREATE_PRISMA_TELEMETRY_DISABLED !== void 0 || process.env.DO_NOT_TRACK !== void 0;
|
|
22
31
|
}
|
|
23
32
|
function getTelemetryConfigDir() {
|
|
24
33
|
if (process.platform === "darwin") return path.join(os.homedir(), "Library", "Application Support", "create-prisma");
|
|
@@ -40,7 +49,7 @@ async function getAnonymousId() {
|
|
|
40
49
|
}
|
|
41
50
|
function getCommonProperties() {
|
|
42
51
|
return {
|
|
43
|
-
"cli-version": "0.4.2-next.37.
|
|
52
|
+
"cli-version": "0.4.2-next.37.89.1",
|
|
44
53
|
"node-version": process.version,
|
|
45
54
|
platform: process.platform,
|
|
46
55
|
arch: process.arch
|
|
@@ -78,6 +87,8 @@ async function trackCliTelemetry(event, properties) {
|
|
|
78
87
|
|
|
79
88
|
//#endregion
|
|
80
89
|
//#region src/telemetry/create.ts
|
|
90
|
+
const CREATE_PRISMA_NEXT_COMPLETED_EVENT = "cli:create_prisma_next_command_completed";
|
|
91
|
+
const CREATE_PRISMA_NEXT_FAILED_EVENT = "cli:create_prisma_next_command_failed";
|
|
81
92
|
function getTargetDirectoryState(context) {
|
|
82
93
|
if (!context.targetPathState.exists) return "new";
|
|
83
94
|
if (context.targetPathState.isEmptyDirectory) return "empty_directory";
|
|
@@ -93,7 +104,6 @@ function getBaseCreateProperties(input, context) {
|
|
|
93
104
|
"database-provider": context?.prismaSetupContext.databaseProvider ?? input.provider ?? null,
|
|
94
105
|
"authoring-style": context?.prismaSetupContext.authoring ?? input.authoring ?? null,
|
|
95
106
|
"package-manager": context?.prismaSetupContext.packageManager ?? input.packageManager ?? null,
|
|
96
|
-
"schema-preset": context?.prismaSetupContext.schemaPreset ?? input.schemaPreset ?? null,
|
|
97
107
|
"should-install": context?.prismaSetupContext.shouldInstall ?? input.install ?? null,
|
|
98
108
|
"should-emit": context?.prismaSetupContext.shouldEmit ?? input.emit ?? null,
|
|
99
109
|
"uses-prisma-postgres": context?.prismaSetupContext.shouldUsePrismaPostgres ?? input.prismaPostgres ?? null,
|
|
@@ -112,13 +122,13 @@ function getErrorCode(error) {
|
|
|
112
122
|
return typeof code === "number" || typeof code === "string" ? code : null;
|
|
113
123
|
}
|
|
114
124
|
async function trackCreateCompleted(params) {
|
|
115
|
-
await trackCliTelemetry(
|
|
125
|
+
await trackCliTelemetry(CREATE_PRISMA_NEXT_COMPLETED_EVENT, {
|
|
116
126
|
...getBaseCreateProperties(params.input, params.context),
|
|
117
127
|
"duration-ms": params.durationMs
|
|
118
128
|
});
|
|
119
129
|
}
|
|
120
130
|
async function trackCreateFailed(params) {
|
|
121
|
-
await trackCliTelemetry(
|
|
131
|
+
await trackCliTelemetry(CREATE_PRISMA_NEXT_FAILED_EVENT, {
|
|
122
132
|
...getBaseCreateProperties(params.input, params.context),
|
|
123
133
|
"duration-ms": params.durationMs,
|
|
124
134
|
"failure-stage": params.stage,
|
|
@@ -205,7 +215,6 @@ const packageManagers = [
|
|
|
205
215
|
"bun",
|
|
206
216
|
"deno"
|
|
207
217
|
];
|
|
208
|
-
const schemaPresets = ["empty", "basic"];
|
|
209
218
|
const authoringStyles = ["psl", "typescript"];
|
|
210
219
|
const createTemplates = [
|
|
211
220
|
"hono",
|
|
@@ -224,7 +233,6 @@ function normalizeDatabaseProvider(value) {
|
|
|
224
233
|
}
|
|
225
234
|
const DatabaseProviderSchema = z.enum(databaseProviderInputs).transform(normalizeDatabaseProvider);
|
|
226
235
|
const PackageManagerSchema = z.enum(packageManagers);
|
|
227
|
-
const SchemaPresetSchema = z.enum(schemaPresets);
|
|
228
236
|
const AuthoringStyleSchema = z.enum(authoringStyles);
|
|
229
237
|
const CreateTemplateSchema = z.enum(createTemplates);
|
|
230
238
|
const DatabaseUrlSchema = z.string().trim().min(1, "Please enter a valid database URL");
|
|
@@ -239,8 +247,7 @@ const PrismaSetupOptionsSchema = z.object({
|
|
|
239
247
|
prismaPostgres: z.boolean().optional().describe("Provision Prisma Postgres with create-db when target is postgres"),
|
|
240
248
|
databaseUrl: DatabaseUrlSchema.optional().describe("DATABASE_URL value"),
|
|
241
249
|
install: z.boolean().optional().describe("Install dependencies with selected package manager"),
|
|
242
|
-
emit: z.boolean().optional().describe("Emit Prisma Next contract artifacts after scaffolding")
|
|
243
|
-
schemaPreset: SchemaPresetSchema.optional().describe("Schema preset to scaffold in prisma/contract.prisma or prisma/contract.ts")
|
|
250
|
+
emit: z.boolean().optional().describe("Emit Prisma Next contract artifacts after scaffolding")
|
|
244
251
|
});
|
|
245
252
|
const PrismaSetupCommandInputSchema = CommonCommandOptionsSchema.extend(PrismaSetupOptionsSchema.shape);
|
|
246
253
|
const CreateScaffoldOptionsSchema = z.object({
|
|
@@ -560,21 +567,20 @@ function getCreateTemplateDir(template) {
|
|
|
560
567
|
function getCreateSharedTemplateDir() {
|
|
561
568
|
return resolveTemplatesDir("templates/create/_shared");
|
|
562
569
|
}
|
|
563
|
-
function createTemplateContext(projectName, template, provider, authoring,
|
|
570
|
+
function createTemplateContext(projectName, template, provider, authoring, packageManager) {
|
|
564
571
|
return {
|
|
565
572
|
projectName,
|
|
566
573
|
template,
|
|
567
574
|
provider,
|
|
568
575
|
authoring,
|
|
569
|
-
schemaPreset,
|
|
570
576
|
packageManager
|
|
571
577
|
};
|
|
572
578
|
}
|
|
573
579
|
async function scaffoldCreateTemplate(opts) {
|
|
574
|
-
const { projectDir, projectName, template, provider, authoring,
|
|
580
|
+
const { projectDir, projectName, template, provider, authoring, packageManager } = opts;
|
|
575
581
|
const templateRoot = getCreateTemplateDir(template);
|
|
576
582
|
const sharedTemplateRoot = getCreateSharedTemplateDir();
|
|
577
|
-
const context = createTemplateContext(projectName, template, provider, authoring,
|
|
583
|
+
const context = createTemplateContext(projectName, template, provider, authoring, packageManager);
|
|
578
584
|
await renderTemplateTree({
|
|
579
585
|
templateRoot: sharedTemplateRoot,
|
|
580
586
|
outputDir: projectDir,
|
|
@@ -823,7 +829,6 @@ function getCreateDbCommand(packageManager) {
|
|
|
823
829
|
//#region src/tasks/setup-prisma.ts
|
|
824
830
|
const DEFAULT_DATABASE_PROVIDER = "postgres";
|
|
825
831
|
const DEFAULT_AUTHORING = "psl";
|
|
826
|
-
const DEFAULT_SCHEMA_PRESET$1 = "basic";
|
|
827
832
|
const DEFAULT_INSTALL = true;
|
|
828
833
|
const DEFAULT_EMIT = true;
|
|
829
834
|
const DEFAULT_INTERACTIVE_PRISMA_POSTGRES = true;
|
|
@@ -867,31 +872,6 @@ const requiredPrismaFileGroups = [
|
|
|
867
872
|
function getContractPath(authoring) {
|
|
868
873
|
return `prisma/contract${authoring === "typescript" ? ".ts" : ".prisma"}`;
|
|
869
874
|
}
|
|
870
|
-
function getEmptyContractContent(provider, authoring) {
|
|
871
|
-
if (authoring === "psl") return "// use prisma-next\n";
|
|
872
|
-
if (provider === "mongo") return `import { defineContract } from "@prisma-next/mongo/contract-builder";
|
|
873
|
-
import mongoFamily from "@prisma-next/mongo/family";
|
|
874
|
-
import mongoTarget from "@prisma-next/mongo/target";
|
|
875
|
-
|
|
876
|
-
export const contract = defineContract(
|
|
877
|
-
{ family: mongoFamily, target: mongoTarget },
|
|
878
|
-
() => ({
|
|
879
|
-
models: {},
|
|
880
|
-
}),
|
|
881
|
-
);
|
|
882
|
-
`;
|
|
883
|
-
return `import { defineContract } from "@prisma-next/postgres/contract-builder";
|
|
884
|
-
import sqlFamily from "@prisma-next/postgres/family";
|
|
885
|
-
import postgresTarget from "@prisma-next/postgres/target";
|
|
886
|
-
|
|
887
|
-
export const contract = defineContract(
|
|
888
|
-
{ family: sqlFamily, target: postgresTarget },
|
|
889
|
-
() => ({
|
|
890
|
-
models: {},
|
|
891
|
-
}),
|
|
892
|
-
);
|
|
893
|
-
`;
|
|
894
|
-
}
|
|
895
875
|
async function promptForDatabaseProvider() {
|
|
896
876
|
const databaseProvider = await select({
|
|
897
877
|
message: "Select your database",
|
|
@@ -1033,7 +1013,6 @@ async function collectPrismaSetupContext(input, options = {}) {
|
|
|
1033
1013
|
}
|
|
1034
1014
|
const authoring = input.authoring ?? (useDefaults ? DEFAULT_AUTHORING : await promptForAuthoringStyle());
|
|
1035
1015
|
if (!authoring) return;
|
|
1036
|
-
const schemaPreset = input.schemaPreset ?? options.defaultSchemaPreset ?? DEFAULT_SCHEMA_PRESET$1;
|
|
1037
1016
|
const detectedPackageManager = await detectPackageManager(projectDir);
|
|
1038
1017
|
const packageManager = input.packageManager ?? (useDefaults ? detectedPackageManager : await promptForPackageManager(detectedPackageManager));
|
|
1039
1018
|
if (!packageManager) return;
|
|
@@ -1045,7 +1024,6 @@ async function collectPrismaSetupContext(input, options = {}) {
|
|
|
1045
1024
|
shouldEmit,
|
|
1046
1025
|
databaseProvider,
|
|
1047
1026
|
authoring,
|
|
1048
|
-
schemaPreset,
|
|
1049
1027
|
databaseUrl,
|
|
1050
1028
|
shouldUsePrismaPostgres,
|
|
1051
1029
|
packageManager,
|
|
@@ -1265,7 +1243,6 @@ async function runPrismaNextInitForContext(context, projectDir) {
|
|
|
1265
1243
|
CI: "1"
|
|
1266
1244
|
}
|
|
1267
1245
|
});
|
|
1268
|
-
if (context.schemaPreset === "empty") await fs.writeFile(path.join(projectDir, getContractPath(context.authoring)), getEmptyContractContent(context.databaseProvider, context.authoring), "utf8");
|
|
1269
1246
|
if (context.verbose) log.success("Prisma Next project files ready.");
|
|
1270
1247
|
return true;
|
|
1271
1248
|
} catch (error) {
|
|
@@ -1434,7 +1411,7 @@ function buildNextStepsForContext(opts) {
|
|
|
1434
1411
|
command: getRunScriptCommand(context.packageManager, "migration:apply"),
|
|
1435
1412
|
description: "Apply the planned migration to the database."
|
|
1436
1413
|
});
|
|
1437
|
-
|
|
1414
|
+
nextSteps.push({
|
|
1438
1415
|
command: getRunScriptCommand(context.packageManager, "db:seed"),
|
|
1439
1416
|
description: "Insert the sample user and post data from prisma/seed.ts."
|
|
1440
1417
|
});
|
|
@@ -1448,9 +1425,14 @@ function formatNextSteps(nextSteps) {
|
|
|
1448
1425
|
return nextSteps.map((step) => `${step.command}\n ${step.description}`).join("\n\n");
|
|
1449
1426
|
}
|
|
1450
1427
|
function formatAgentPrompt(didSyncAgentSkills) {
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1428
|
+
return [
|
|
1429
|
+
"Ask your agent:",
|
|
1430
|
+
"What can I do with Prisma Next?",
|
|
1431
|
+
"",
|
|
1432
|
+
"Learn more:",
|
|
1433
|
+
`Docs: prisma-next.md`,
|
|
1434
|
+
`Skill: ${didSyncAgentSkills ? ".agents/skills/prisma-next/SKILL.md" : ".agents/skills/prisma-next/SKILL.md (after skills sync)"}`
|
|
1435
|
+
].join("\n");
|
|
1454
1436
|
}
|
|
1455
1437
|
async function executePrismaSetupContext(context, options = {}) {
|
|
1456
1438
|
const projectDir = path.resolve(options.projectDir ?? context.projectDir);
|
|
@@ -1502,7 +1484,7 @@ async function executePrismaSetupContext(context, options = {}) {
|
|
|
1502
1484
|
progressSpinner?.stop("Prisma Next project ready.");
|
|
1503
1485
|
if (warningLines.length > 0) note(warningLines.map((line) => line.replace(/^- /, "")).join("\n"), "Heads up");
|
|
1504
1486
|
note(formatAgentPrompt(skillSyncResult.didSyncAgentSkills), "Agent prompt");
|
|
1505
|
-
note(formatNextSteps(nextSteps), "Next steps for Prisma Next");
|
|
1487
|
+
if (context.verbose) note(formatNextSteps(nextSteps), "Next steps for Prisma Next");
|
|
1506
1488
|
outro("Prisma Next setup complete.");
|
|
1507
1489
|
return true;
|
|
1508
1490
|
}
|
|
@@ -1518,7 +1500,6 @@ function getCreatePrismaIntro() {
|
|
|
1518
1500
|
//#region src/commands/create.ts
|
|
1519
1501
|
const DEFAULT_PROJECT_NAME = "my-app";
|
|
1520
1502
|
const DEFAULT_TEMPLATE = "hono";
|
|
1521
|
-
const DEFAULT_SCHEMA_PRESET = "basic";
|
|
1522
1503
|
function toPackageName(projectName) {
|
|
1523
1504
|
return projectName.toLowerCase().replace(/[^a-z0-9._-]/g, "-").replace(/^-+/, "").replace(/-+$/, "") || "app";
|
|
1524
1505
|
}
|
|
@@ -1677,10 +1658,7 @@ async function collectCreateContext(input) {
|
|
|
1677
1658
|
cancel(`Target directory ${formatPathForDisplay(targetDirectory)} is not empty. Use --force to continue.`);
|
|
1678
1659
|
return;
|
|
1679
1660
|
}
|
|
1680
|
-
const prismaSetupContext = await collectPrismaSetupContext(input, {
|
|
1681
|
-
projectDir: targetDirectory,
|
|
1682
|
-
defaultSchemaPreset: DEFAULT_SCHEMA_PRESET
|
|
1683
|
-
});
|
|
1661
|
+
const prismaSetupContext = await collectPrismaSetupContext(input, { projectDir: targetDirectory });
|
|
1684
1662
|
if (!prismaSetupContext) return;
|
|
1685
1663
|
return {
|
|
1686
1664
|
targetDirectory,
|
|
@@ -1695,15 +1673,16 @@ async function executeCreateContext(context) {
|
|
|
1695
1673
|
const createSpinner = context.prismaSetupContext.verbose ? void 0 : spinner();
|
|
1696
1674
|
createSpinner?.start("Creating Prisma Next project...");
|
|
1697
1675
|
try {
|
|
1676
|
+
if (context.prismaSetupContext.verbose) log.step(`Scaffolding ${context.template} starter.`);
|
|
1698
1677
|
await scaffoldCreateTemplate({
|
|
1699
1678
|
projectDir: context.targetDirectory,
|
|
1700
1679
|
projectName: context.projectPackageName,
|
|
1701
1680
|
template: context.template,
|
|
1702
|
-
schemaPreset: context.prismaSetupContext.schemaPreset,
|
|
1703
1681
|
provider: context.prismaSetupContext.databaseProvider,
|
|
1704
1682
|
authoring: context.prismaSetupContext.authoring,
|
|
1705
1683
|
packageManager: context.prismaSetupContext.packageManager
|
|
1706
1684
|
});
|
|
1685
|
+
if (context.prismaSetupContext.verbose) log.success("Starter files scaffolded.");
|
|
1707
1686
|
} catch (error) {
|
|
1708
1687
|
createSpinner?.stop("Could not create Prisma Next project.");
|
|
1709
1688
|
return {
|
|
@@ -1753,4 +1732,4 @@ async function executeCreateContext(context) {
|
|
|
1753
1732
|
}
|
|
1754
1733
|
|
|
1755
1734
|
//#endregion
|
|
1756
|
-
export { DatabaseProviderSchema as a,
|
|
1735
|
+
export { DatabaseProviderSchema as a, CreateTemplateSchema as i, AuthoringStyleSchema as n, DatabaseUrlSchema as o, CreateCommandInputSchema as r, PackageManagerSchema as s, runCreateCommand as t };
|
package/dist/index.d.mts
CHANGED
|
@@ -190,10 +190,6 @@ declare const PackageManagerSchema: z.ZodEnum<{
|
|
|
190
190
|
bun: "bun";
|
|
191
191
|
deno: "deno";
|
|
192
192
|
}>;
|
|
193
|
-
declare const SchemaPresetSchema: z.ZodEnum<{
|
|
194
|
-
empty: "empty";
|
|
195
|
-
basic: "basic";
|
|
196
|
-
}>;
|
|
197
193
|
declare const AuthoringStyleSchema: z.ZodEnum<{
|
|
198
194
|
psl: "psl";
|
|
199
195
|
typescript: "typescript";
|
|
@@ -233,10 +229,6 @@ declare const CreateCommandInputSchema: z.ZodObject<{
|
|
|
233
229
|
databaseUrl: z.ZodOptional<z.ZodString>;
|
|
234
230
|
install: z.ZodOptional<z.ZodBoolean>;
|
|
235
231
|
emit: z.ZodOptional<z.ZodBoolean>;
|
|
236
|
-
schemaPreset: z.ZodOptional<z.ZodEnum<{
|
|
237
|
-
empty: "empty";
|
|
238
|
-
basic: "basic";
|
|
239
|
-
}>>;
|
|
240
232
|
name: z.ZodOptional<z.ZodString>;
|
|
241
233
|
template: z.ZodOptional<z.ZodEnum<{
|
|
242
234
|
hono: "hono";
|
|
@@ -278,10 +270,6 @@ declare const router: {
|
|
|
278
270
|
databaseUrl: zod.ZodOptional<zod.ZodString>;
|
|
279
271
|
install: zod.ZodOptional<zod.ZodBoolean>;
|
|
280
272
|
emit: zod.ZodOptional<zod.ZodBoolean>;
|
|
281
|
-
schemaPreset: zod.ZodOptional<zod.ZodEnum<{
|
|
282
|
-
empty: "empty";
|
|
283
|
-
basic: "basic";
|
|
284
|
-
}>>;
|
|
285
273
|
name: zod.ZodOptional<zod.ZodString>;
|
|
286
274
|
template: zod.ZodOptional<zod.ZodEnum<{
|
|
287
275
|
hono: "hono";
|
|
@@ -299,4 +287,4 @@ declare const router: {
|
|
|
299
287
|
declare function createCreatePrismaCli(): trpc_cli0.TrpcCli;
|
|
300
288
|
declare function create(input?: CreateCommandInput): Promise<void>;
|
|
301
289
|
//#endregion
|
|
302
|
-
export { AuthoringStyleSchema, type CreateCommandInput, CreateCommandInputSchema, CreateTemplateSchema, DatabaseProviderSchema, DatabaseUrlSchema, PackageManagerSchema,
|
|
290
|
+
export { AuthoringStyleSchema, type CreateCommandInput, CreateCommandInputSchema, CreateTemplateSchema, DatabaseProviderSchema, DatabaseUrlSchema, PackageManagerSchema, create, createCreatePrismaCli, router };
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as DatabaseProviderSchema,
|
|
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-C6SFJkUe.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.89.1";
|
|
8
8
|
const router = os.router({ create: os.meta({
|
|
9
9
|
description: "Create a new project with Prisma setup",
|
|
10
10
|
default: true,
|
|
@@ -24,4 +24,4 @@ async function create(input = {}) {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
//#endregion
|
|
27
|
-
export { AuthoringStyleSchema, CreateCommandInputSchema, CreateTemplateSchema, DatabaseProviderSchema, DatabaseUrlSchema, PackageManagerSchema,
|
|
27
|
+
export { AuthoringStyleSchema, CreateCommandInputSchema, CreateTemplateSchema, DatabaseProviderSchema, DatabaseUrlSchema, PackageManagerSchema, create, createCreatePrismaCli, router };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-prisma",
|
|
3
|
-
"version": "0.4.2-next.37.
|
|
3
|
+
"version": "0.4.2-next.37.89.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Create Prisma Next projects with first-party templates and great DX.",
|
|
6
6
|
"homepage": "https://github.com/prisma/create-prisma",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"dev": "tsdown --watch",
|
|
38
38
|
"start": "bun run ./dist/cli.mjs",
|
|
39
39
|
"test": "bun run test:unit && bun run test:e2e",
|
|
40
|
-
"test:unit": "bun test ./tests/install.test.ts",
|
|
40
|
+
"test:unit": "bun test ./tests/install.test.ts ./tests/telemetry.test.ts",
|
|
41
41
|
"test:e2e": "bun test --timeout 180000 ./tests/e2e/create-prisma.e2e.test.ts",
|
|
42
42
|
"check": "bun run format:check && bun run lint",
|
|
43
43
|
"lint": "oxlint . --deny-warnings",
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
{{#if (eq schemaPreset "basic")}}
|
|
2
1
|
{{#if (requiresDotenvConfigImport packageManager)}}
|
|
3
2
|
import "dotenv/config";
|
|
4
3
|
{{/if}}
|
|
@@ -51,6 +50,4 @@ try {
|
|
|
51
50
|
await db.runtime().close();
|
|
52
51
|
}
|
|
53
52
|
{{/if}}
|
|
54
|
-
|
|
55
|
-
console.log("No seed data for the empty schema preset.");
|
|
56
|
-
{{/if}}
|
|
53
|
+
|
|
@@ -32,18 +32,13 @@ Database helper scripts are added to `package.json`:
|
|
|
32
32
|
- `{{runScriptCommand packageManager "migration:plan"}}` - create a migration plan
|
|
33
33
|
- `{{runScriptCommand packageManager "migration:apply"}}` - apply a planned migration
|
|
34
34
|
{{/if}}
|
|
35
|
-
|
|
35
|
+
|
|
36
36
|
- `{{runScriptCommand packageManager "db:seed"}}` - insert sample users manually
|
|
37
|
-
{{/if}}
|
|
38
37
|
|
|
39
38
|
For provider-specific Prisma Next reference docs, see `prisma-next.md`. Agent-specific project guidance is scaffolded in `.agents/skills/prisma-next/SKILL.md`.
|
|
40
39
|
The Astro Vite dev server also auto-emits Prisma Next contract artifacts when the contract changes.
|
|
41
40
|
|
|
42
41
|
Node-based Prisma Next projects expect Node.js 24 LTS or newer.
|
|
43
|
-
{{#if (eq schemaPreset "basic")}}
|
|
44
42
|
|
|
45
43
|
The starter page queries a basic `User` model in `src/pages/index.astro`, and `src/pages/api/users.ts` shows an Astro API route backed by the same Prisma Next helper.
|
|
46
|
-
{{else}}
|
|
47
44
|
|
|
48
|
-
The starter page keeps the official Astro minimal structure and points you to your Prisma Next contract for the first model.
|
|
49
|
-
{{/if}}
|
|
@@ -4,13 +4,13 @@ import mongo from "@prisma-next/mongo/runtime";
|
|
|
4
4
|
{{else}}
|
|
5
5
|
import postgres from "@prisma-next/postgres/runtime";
|
|
6
6
|
{{/if}}
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
{{#if (eq provider "mongo")}}
|
|
9
9
|
import type { DefaultModelRow } from "@prisma-next/mongo-orm";
|
|
10
10
|
{{else}}
|
|
11
11
|
import type { DefaultModelRow } from "@prisma-next/sql-orm-client";
|
|
12
12
|
{{/if}}
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
import type { Contract } from "../../prisma/contract.d";
|
|
15
15
|
import contractJson from "../../prisma/contract.json" with { type: "json" };
|
|
16
16
|
|
|
@@ -26,7 +26,6 @@ export const db = postgres<Contract>({
|
|
|
26
26
|
});
|
|
27
27
|
{{/if}}
|
|
28
28
|
|
|
29
|
-
{{#if (eq schemaPreset "basic")}}
|
|
30
29
|
type UserRow = DefaultModelRow<Contract, "User">;
|
|
31
30
|
|
|
32
31
|
{{#if (eq provider "mongo")}}
|
|
@@ -48,10 +47,9 @@ function toStarterUser(user: Pick<UserRow, "id" | "email" | "name" | "createdAt"
|
|
|
48
47
|
};
|
|
49
48
|
}
|
|
50
49
|
{{/if}}
|
|
51
|
-
{{/if}}
|
|
52
50
|
|
|
53
51
|
export async function listUsers(limit = 10) {
|
|
54
|
-
|
|
52
|
+
|
|
55
53
|
{{#if (eq provider "mongo")}}
|
|
56
54
|
const users: ReturnType<typeof toStarterUser>[] = [];
|
|
57
55
|
|
|
@@ -65,9 +63,7 @@ export async function listUsers(limit = 10) {
|
|
|
65
63
|
|
|
66
64
|
return users.map(toStarterUser);
|
|
67
65
|
{{/if}}
|
|
68
|
-
|
|
69
|
-
return [];
|
|
70
|
-
{{/if}}
|
|
66
|
+
|
|
71
67
|
}
|
|
72
68
|
|
|
73
69
|
export type StarterUser = Awaited<ReturnType<typeof listUsers>>[number];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { APIRoute } from "astro";
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
import { listUsers } from "../../lib/prisma";
|
|
4
4
|
|
|
5
5
|
export const GET: APIRoute = async () => {
|
|
@@ -23,13 +23,4 @@ export const GET: APIRoute = async () => {
|
|
|
23
23
|
},
|
|
24
24
|
});
|
|
25
25
|
};
|
|
26
|
-
{{else}}
|
|
27
26
|
|
|
28
|
-
export const GET: APIRoute = async () => {
|
|
29
|
-
return new Response(JSON.stringify([]), {
|
|
30
|
-
headers: {
|
|
31
|
-
"Content-Type": "application/json",
|
|
32
|
-
},
|
|
33
|
-
});
|
|
34
|
-
};
|
|
35
|
-
{{/if}}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
import { listUsers } from "../lib/prisma";
|
|
4
4
|
|
|
5
5
|
const formatter = new Intl.DateTimeFormat("en", {
|
|
@@ -8,7 +8,7 @@ const formatter = new Intl.DateTimeFormat("en", {
|
|
|
8
8
|
});
|
|
9
9
|
|
|
10
10
|
const users = await listUsers(10).catch(() => undefined);
|
|
11
|
-
|
|
11
|
+
|
|
12
12
|
---
|
|
13
13
|
|
|
14
14
|
<html lang="en">
|
|
@@ -23,7 +23,7 @@ const users = await listUsers(10).catch(() => undefined);
|
|
|
23
23
|
<main class="shell">
|
|
24
24
|
<div class="hero">
|
|
25
25
|
<p class="eyebrow">Astro + Prisma Next</p>
|
|
26
|
-
|
|
26
|
+
|
|
27
27
|
<h1>Users from your database, loaded on the server.</h1>
|
|
28
28
|
<p class="lede">
|
|
29
29
|
This page reads from <code>src/pages/index.astro</code> using the Prisma Next helper in
|
|
@@ -65,42 +65,7 @@ const users = await listUsers(10).catch(() => undefined);
|
|
|
65
65
|
</ul>
|
|
66
66
|
)}
|
|
67
67
|
</section>
|
|
68
|
-
{{else}}
|
|
69
|
-
<h1>Your Astro app is ready.</h1>
|
|
70
|
-
<p class="lede">
|
|
71
|
-
Edit your Prisma Next contract, run <code>contract:emit</code>, then load your data
|
|
72
|
-
in Astro pages or API routes with the helper in <code>src/lib/prisma.ts</code>.
|
|
73
|
-
</p>
|
|
74
|
-
</div>
|
|
75
68
|
|
|
76
|
-
<section class="panel">
|
|
77
|
-
<div class="panel-header">
|
|
78
|
-
<h2>What's included</h2>
|
|
79
|
-
<span>Starter kit</span>
|
|
80
|
-
</div>
|
|
81
|
-
|
|
82
|
-
<ul class="users">
|
|
83
|
-
<li>
|
|
84
|
-
<div>
|
|
85
|
-
<strong>Prisma client</strong>
|
|
86
|
-
<p>Use the shared Prisma Next runtime from <code>src/lib/prisma.ts</code>.</p>
|
|
87
|
-
</div>
|
|
88
|
-
</li>
|
|
89
|
-
<li>
|
|
90
|
-
<div>
|
|
91
|
-
<strong>API route example</strong>
|
|
92
|
-
<p>See <code>src/pages/api/users.ts</code> for an Astro server endpoint.</p>
|
|
93
|
-
</div>
|
|
94
|
-
</li>
|
|
95
|
-
<li>
|
|
96
|
-
<div>
|
|
97
|
-
<strong>Manual database setup</strong>
|
|
98
|
-
<p>Run the schema setup commands when you are ready.</p>
|
|
99
|
-
</div>
|
|
100
|
-
</li>
|
|
101
|
-
</ul>
|
|
102
|
-
</section>
|
|
103
|
-
{{/if}}
|
|
104
69
|
</main>
|
|
105
70
|
</body>
|
|
106
71
|
</html>
|
|
@@ -30,14 +30,12 @@ Database helper scripts are added to `package.json`:
|
|
|
30
30
|
- `{{runScriptCommand packageManager "migration:plan"}}` - create a migration plan
|
|
31
31
|
- `{{runScriptCommand packageManager "migration:apply"}}` - apply a planned migration
|
|
32
32
|
{{/if}}
|
|
33
|
-
|
|
33
|
+
|
|
34
34
|
- `{{runScriptCommand packageManager "db:seed"}}` - insert sample users manually
|
|
35
|
-
{{/if}}
|
|
36
35
|
|
|
37
36
|
For provider-specific Prisma Next reference docs, see `prisma-next.md`. Agent-specific project guidance is scaffolded in `.agents/skills/prisma-next/SKILL.md`.
|
|
38
37
|
|
|
39
38
|
Node-based Prisma Next projects expect Node.js 24 LTS or newer.
|
|
40
|
-
{{#if (eq schemaPreset "basic")}}
|
|
41
39
|
|
|
42
40
|
The template includes a basic `User` model and a sample `GET /users` endpoint.
|
|
43
|
-
|
|
41
|
+
|
|
@@ -6,9 +6,8 @@ import "dotenv/config";
|
|
|
6
6
|
import { node } from "@elysiajs/node";
|
|
7
7
|
{{/if}}
|
|
8
8
|
import { Elysia } from "elysia";
|
|
9
|
-
|
|
9
|
+
|
|
10
10
|
import { listUsers } from "./lib/prisma{{#if (eq packageManager "deno")}}.ts{{/if}}";
|
|
11
|
-
{{/if}}
|
|
12
11
|
|
|
13
12
|
const rawPort = ({{#if (eq packageManager "deno")}}Deno.env.get("PORT"){{else}}process.env.PORT{{/if}} ?? "").trim();
|
|
14
13
|
const parsedPort = rawPort.length > 0 ? Number(rawPort) : Number.NaN;
|
|
@@ -21,7 +20,7 @@ const app = new Elysia({{#if (eq packageManager "deno")}}{{else}}{ adapter: node
|
|
|
21
20
|
message: "hello from create-prisma + elysia",
|
|
22
21
|
};
|
|
23
22
|
})
|
|
24
|
-
|
|
23
|
+
|
|
25
24
|
.get("/users", async ({ set }) => {
|
|
26
25
|
const users = await listUsers(10).catch((error) => {
|
|
27
26
|
console.error("Failed to query users:", error);
|
|
@@ -35,7 +34,7 @@ const app = new Elysia({{#if (eq packageManager "deno")}}{{else}}{ adapter: node
|
|
|
35
34
|
|
|
36
35
|
return users;
|
|
37
36
|
})
|
|
38
|
-
|
|
37
|
+
|
|
39
38
|
{{#if (eq packageManager "deno")}}
|
|
40
39
|
;
|
|
41
40
|
|
|
@@ -4,13 +4,13 @@ import mongo from "@prisma-next/mongo/runtime";
|
|
|
4
4
|
{{else}}
|
|
5
5
|
import postgres from "@prisma-next/postgres/runtime";
|
|
6
6
|
{{/if}}
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
{{#if (eq provider "mongo")}}
|
|
9
9
|
import type { DefaultModelRow } from "@prisma-next/mongo-orm";
|
|
10
10
|
{{else}}
|
|
11
11
|
import type { DefaultModelRow } from "@prisma-next/sql-orm-client";
|
|
12
12
|
{{/if}}
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
import type { Contract } from "../../prisma/contract.d";
|
|
15
15
|
import contractJson from "../../prisma/contract.json" with { type: "json" };
|
|
16
16
|
|
|
@@ -26,7 +26,6 @@ export const db = postgres<Contract>({
|
|
|
26
26
|
});
|
|
27
27
|
{{/if}}
|
|
28
28
|
|
|
29
|
-
{{#if (eq schemaPreset "basic")}}
|
|
30
29
|
type UserRow = DefaultModelRow<Contract, "User">;
|
|
31
30
|
|
|
32
31
|
{{#if (eq provider "mongo")}}
|
|
@@ -48,10 +47,9 @@ function toStarterUser(user: Pick<UserRow, "id" | "email" | "name" | "createdAt"
|
|
|
48
47
|
};
|
|
49
48
|
}
|
|
50
49
|
{{/if}}
|
|
51
|
-
{{/if}}
|
|
52
50
|
|
|
53
51
|
export async function listUsers(limit = 10) {
|
|
54
|
-
|
|
52
|
+
|
|
55
53
|
{{#if (eq provider "mongo")}}
|
|
56
54
|
const users: ReturnType<typeof toStarterUser>[] = [];
|
|
57
55
|
|
|
@@ -65,9 +63,7 @@ export async function listUsers(limit = 10) {
|
|
|
65
63
|
|
|
66
64
|
return users.map(toStarterUser);
|
|
67
65
|
{{/if}}
|
|
68
|
-
|
|
69
|
-
return [];
|
|
70
|
-
{{/if}}
|
|
66
|
+
|
|
71
67
|
}
|
|
72
68
|
|
|
73
69
|
export type StarterUser = Awaited<ReturnType<typeof listUsers>>[number];
|
|
@@ -30,14 +30,12 @@ Database helper scripts are added to `package.json`:
|
|
|
30
30
|
- `{{runScriptCommand packageManager "migration:plan"}}` - create a migration plan
|
|
31
31
|
- `{{runScriptCommand packageManager "migration:apply"}}` - apply a planned migration
|
|
32
32
|
{{/if}}
|
|
33
|
-
|
|
33
|
+
|
|
34
34
|
- `{{runScriptCommand packageManager "db:seed"}}` - insert sample users manually
|
|
35
|
-
{{/if}}
|
|
36
35
|
|
|
37
36
|
For provider-specific Prisma Next reference docs, see `prisma-next.md`. Agent-specific project guidance is scaffolded in `.agents/skills/prisma-next/SKILL.md`.
|
|
38
37
|
|
|
39
38
|
Node-based Prisma Next projects expect Node.js 24 LTS or newer.
|
|
40
|
-
{{#if (eq schemaPreset "basic")}}
|
|
41
39
|
|
|
42
40
|
The template includes a basic `User` model and a sample `GET /users` endpoint.
|
|
43
|
-
|
|
41
|
+
|
|
@@ -3,9 +3,8 @@ import "dotenv/config";
|
|
|
3
3
|
{{/if}}
|
|
4
4
|
import { serve } from "@hono/node-server";
|
|
5
5
|
import { Hono } from "hono";
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
import { listUsers } from "./lib/prisma{{#if (eq packageManager "deno")}}.ts{{/if}}";
|
|
8
|
-
{{/if}}
|
|
9
8
|
|
|
10
9
|
const app = new Hono();
|
|
11
10
|
|
|
@@ -14,7 +13,6 @@ app.get("/", (c) => {
|
|
|
14
13
|
message: "hello from create-prisma + hono",
|
|
15
14
|
});
|
|
16
15
|
});
|
|
17
|
-
{{#if (eq schemaPreset "basic")}}
|
|
18
16
|
|
|
19
17
|
app.get("/users", async (c) => {
|
|
20
18
|
const users = await listUsers(10).catch((error) => {
|
|
@@ -28,7 +26,6 @@ app.get("/users", async (c) => {
|
|
|
28
26
|
|
|
29
27
|
return c.json(users);
|
|
30
28
|
});
|
|
31
|
-
{{/if}}
|
|
32
29
|
|
|
33
30
|
const rawPort = ({{#if (eq packageManager "deno")}}Deno.env.get("PORT"){{else}}process.env.PORT{{/if}} ?? "").trim();
|
|
34
31
|
const parsedPort = rawPort.length > 0 ? Number(rawPort) : Number.NaN;
|