create-prisma 0.12.1 → 0.13.0-pr.104.357.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 +5 -0
- package/dist/cli.mjs +1 -1
- package/dist/index.d.mts +15 -9
- package/dist/index.mjs +2 -2
- package/dist/{json-output-BEzP-dBw.mjs → json-output-DRjmY3tO.mjs} +177 -88
- package/package.json +2 -1
- package/templates/create/_package-manager/pnpm-workspace.yaml.hbs +5 -0
- package/templates/create/_shared/.gitattributes.hbs +6 -6
- package/templates/create/_shared/README.md.hbs +44 -0
- package/templates/create/_shared/module.ts.hbs +1 -1
- package/templates/create/_shared/prisma.config.ts.hbs +4 -4
- package/templates/create/_shared/service.ts.hbs +3 -1
- package/templates/create/_shared/src/prisma/db.ts.hbs +2 -2
- package/templates/create/turborepo/.yarnrc.yml.hbs +3 -0
- package/templates/create/turborepo/apps/server/package.json +15 -0
- package/templates/create/turborepo/apps/server/src/index.ts +31 -0
- package/templates/create/turborepo/apps/server/tsconfig.json +4 -0
- package/templates/create/turborepo/package.json.hbs +20 -0
- package/templates/create/turborepo/packages/database/package.json +13 -0
- package/templates/create/turborepo/packages/database/tsconfig.json +4 -0
- package/templates/create/turborepo/tsconfig.json +22 -0
- package/templates/create/turborepo/turbo.json +23 -0
package/README.md
CHANGED
|
@@ -15,6 +15,10 @@ bunx create-prisma@latest my-app
|
|
|
15
15
|
|
|
16
16
|
The CLI initializes Prisma 8 with `prisma@latest`, installs dependencies, emits the contract, and generates a deployable Composer app. PostgreSQL projects use Composer's native Prisma Postgres provider, including migrations and a typed runtime client.
|
|
17
17
|
|
|
18
|
+
PostgreSQL apps with Composer include `@prisma/dev` as a project devDependency for
|
|
19
|
+
local Postgres. In a monorepo it belongs at the root, where Composer runs. Prisma 8
|
|
20
|
+
does not include this runtime itself. MongoDB and Deno-only apps do not need it.
|
|
21
|
+
|
|
18
22
|
For npm, use 11.6.0 or newer, which includes the [upstream resolver fix](https://github.com/npm/cli/pull/8448).
|
|
19
23
|
Older npm releases can crash resolving the dependency tree (`Cannot read properties of null (reading 'edgesOut')`). Run
|
|
20
24
|
`npm install --global npm@11` to update. create-prisma checks the selected npm
|
|
@@ -44,6 +48,7 @@ workspace. Choosing another workspace also updates the Prisma CLI's active works
|
|
|
44
48
|
- `elysia`
|
|
45
49
|
- `nest`
|
|
46
50
|
- `next`
|
|
51
|
+
- `turborepo` (Hello World Node.js server in `apps/server`, shared Prisma package in `packages/database`)
|
|
47
52
|
- `svelte` (SvelteKit)
|
|
48
53
|
- `astro`
|
|
49
54
|
- `nuxt`
|
package/dist/cli.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as ApplicationLayer } from "./json-output-
|
|
2
|
+
import { a as ApplicationLayer } from "./json-output-DRjmY3tO.mjs";
|
|
3
3
|
import { runCreatePrismaCli } from "./index.mjs";
|
|
4
4
|
import { Effect } from "effect";
|
|
5
5
|
import { NodeRuntime } from "@effect/platform-node-shared";
|
package/dist/index.d.mts
CHANGED
|
@@ -4,6 +4,10 @@ import { Command } from "effect/unstable/cli";
|
|
|
4
4
|
import * as effect_FileSystem0 from "effect/FileSystem";
|
|
5
5
|
import * as effect_Cause0 from "effect/Cause";
|
|
6
6
|
|
|
7
|
+
//#region src/utils/child-process-failure.d.ts
|
|
8
|
+
declare const ChildProcessFailureSchema: Schema.Literals<readonly ["cancelled", "command_not_found", "interrupted", "max_buffer", "non_zero_exit", "permission_denied", "spawn_failed", "terminated", "timed_out"]>;
|
|
9
|
+
type ChildProcessFailure = typeof ChildProcessFailureSchema.Type;
|
|
10
|
+
//#endregion
|
|
7
11
|
//#region src/services/command-runner.d.ts
|
|
8
12
|
type CommandSpec = {
|
|
9
13
|
command: string;
|
|
@@ -17,6 +21,7 @@ type CommandResult = {
|
|
|
17
21
|
exitCode: number;
|
|
18
22
|
stdout: string;
|
|
19
23
|
stderr: string;
|
|
24
|
+
childProcessFailure?: ChildProcessFailure;
|
|
20
25
|
};
|
|
21
26
|
declare const CommandExecutionError_base: Schema.Class<CommandExecutionError, Schema.TaggedStruct<"CommandExecutionError", {
|
|
22
27
|
readonly command: Schema.String;
|
|
@@ -25,6 +30,7 @@ declare const CommandExecutionError_base: Schema.Class<CommandExecutionError, Sc
|
|
|
25
30
|
readonly stdout: Schema.String;
|
|
26
31
|
readonly stderr: Schema.String;
|
|
27
32
|
readonly cause: Schema.optionalKey<Schema.Defect>;
|
|
33
|
+
readonly childProcessFailure: Schema.optional<Schema.Literals<readonly ["cancelled", "command_not_found", "interrupted", "max_buffer", "non_zero_exit", "permission_denied", "spawn_failed", "terminated", "timed_out"]>>;
|
|
28
34
|
}>, effect_Cause0.YieldableError>;
|
|
29
35
|
declare class CommandExecutionError extends CommandExecutionError_base {
|
|
30
36
|
get message(): string;
|
|
@@ -42,10 +48,10 @@ declare const DatabaseProviderSchema: Schema.Literals<readonly ["postgres", "mon
|
|
|
42
48
|
declare const PackageManagerSchema: Schema.Literals<readonly ["npm", "pnpm", "yarn", "bun", "deno"]>;
|
|
43
49
|
declare const AuthoringStyleSchema: Schema.Literals<readonly ["psl", "typescript"]>;
|
|
44
50
|
declare const AgentSkillTargetSchema: Schema.Literals<readonly ["claude", "cursor", "agents", "devin"]>;
|
|
45
|
-
declare const CreateTemplateSchema: Schema.Literals<readonly ["minimal", "hono", "elysia", "nest", "next", "svelte", "astro", "nuxt", "tanstack-start"]>;
|
|
51
|
+
declare const CreateTemplateSchema: Schema.Literals<readonly ["minimal", "hono", "elysia", "nest", "next", "turborepo", "svelte", "astro", "nuxt", "tanstack-start"]>;
|
|
46
52
|
declare const CreateCommandInputSchema: Schema.Struct<{
|
|
47
53
|
readonly name: Schema.optionalKey<Schema.Trim>;
|
|
48
|
-
readonly template: Schema.optionalKey<Schema.Literals<readonly ["minimal", "hono", "elysia", "nest", "next", "svelte", "astro", "nuxt", "tanstack-start"]>>;
|
|
54
|
+
readonly template: Schema.optionalKey<Schema.Literals<readonly ["minimal", "hono", "elysia", "nest", "next", "turborepo", "svelte", "astro", "nuxt", "tanstack-start"]>>;
|
|
49
55
|
readonly force: Schema.optionalKey<Schema.Boolean>;
|
|
50
56
|
readonly provider: Schema.optionalKey<Schema.Literals<readonly ["postgres", "mongo"]>>;
|
|
51
57
|
readonly authoring: Schema.optionalKey<Schema.Literals<readonly ["psl", "typescript"]>>;
|
|
@@ -75,7 +81,7 @@ type CreateNextStep = typeof CreateNextStepSchema.Type;
|
|
|
75
81
|
declare const CreateProjectResultSchema: Schema.Struct<{
|
|
76
82
|
readonly name: Schema.String;
|
|
77
83
|
readonly path: Schema.String;
|
|
78
|
-
readonly template: Schema.Literals<readonly ["minimal", "hono", "elysia", "nest", "next", "svelte", "astro", "nuxt", "tanstack-start"]>;
|
|
84
|
+
readonly template: Schema.Literals<readonly ["minimal", "hono", "elysia", "nest", "next", "turborepo", "svelte", "astro", "nuxt", "tanstack-start"]>;
|
|
79
85
|
readonly databaseProvider: Schema.Literals<readonly ["postgres", "mongo"]>;
|
|
80
86
|
readonly authoring: Schema.Literals<readonly ["psl", "typescript"]>;
|
|
81
87
|
readonly packageManager: Schema.Literals<readonly ["npm", "pnpm", "yarn", "bun", "deno"]>;
|
|
@@ -88,7 +94,7 @@ declare const CreateCommandSuccessResultSchema: Schema.Struct<{
|
|
|
88
94
|
readonly project: Schema.Struct<{
|
|
89
95
|
readonly name: Schema.String;
|
|
90
96
|
readonly path: Schema.String;
|
|
91
|
-
readonly template: Schema.Literals<readonly ["minimal", "hono", "elysia", "nest", "next", "svelte", "astro", "nuxt", "tanstack-start"]>;
|
|
97
|
+
readonly template: Schema.Literals<readonly ["minimal", "hono", "elysia", "nest", "next", "turborepo", "svelte", "astro", "nuxt", "tanstack-start"]>;
|
|
92
98
|
readonly databaseProvider: Schema.Literals<readonly ["postgres", "mongo"]>;
|
|
93
99
|
readonly authoring: Schema.Literals<readonly ["psl", "typescript"]>;
|
|
94
100
|
readonly packageManager: Schema.Literals<readonly ["npm", "pnpm", "yarn", "bun", "deno"]>;
|
|
@@ -124,7 +130,7 @@ declare const CreateCommandFailureResultSchema: Schema.Struct<{
|
|
|
124
130
|
readonly project: Schema.optionalKey<Schema.Struct<{
|
|
125
131
|
readonly name: Schema.String;
|
|
126
132
|
readonly path: Schema.String;
|
|
127
|
-
readonly template: Schema.Literals<readonly ["minimal", "hono", "elysia", "nest", "next", "svelte", "astro", "nuxt", "tanstack-start"]>;
|
|
133
|
+
readonly template: Schema.Literals<readonly ["minimal", "hono", "elysia", "nest", "next", "turborepo", "svelte", "astro", "nuxt", "tanstack-start"]>;
|
|
128
134
|
readonly databaseProvider: Schema.Literals<readonly ["postgres", "mongo"]>;
|
|
129
135
|
readonly authoring: Schema.Literals<readonly ["psl", "typescript"]>;
|
|
130
136
|
readonly packageManager: Schema.Literals<readonly ["npm", "pnpm", "yarn", "bun", "deno"]>;
|
|
@@ -137,7 +143,7 @@ declare const CreateCommandResultSchema: Schema.Union<readonly [Schema.Struct<{
|
|
|
137
143
|
readonly project: Schema.Struct<{
|
|
138
144
|
readonly name: Schema.String;
|
|
139
145
|
readonly path: Schema.String;
|
|
140
|
-
readonly template: Schema.Literals<readonly ["minimal", "hono", "elysia", "nest", "next", "svelte", "astro", "nuxt", "tanstack-start"]>;
|
|
146
|
+
readonly template: Schema.Literals<readonly ["minimal", "hono", "elysia", "nest", "next", "turborepo", "svelte", "astro", "nuxt", "tanstack-start"]>;
|
|
141
147
|
readonly databaseProvider: Schema.Literals<readonly ["postgres", "mongo"]>;
|
|
142
148
|
readonly authoring: Schema.Literals<readonly ["psl", "typescript"]>;
|
|
143
149
|
readonly packageManager: Schema.Literals<readonly ["npm", "pnpm", "yarn", "bun", "deno"]>;
|
|
@@ -171,7 +177,7 @@ declare const CreateCommandResultSchema: Schema.Union<readonly [Schema.Struct<{
|
|
|
171
177
|
readonly project: Schema.optionalKey<Schema.Struct<{
|
|
172
178
|
readonly name: Schema.String;
|
|
173
179
|
readonly path: Schema.String;
|
|
174
|
-
readonly template: Schema.Literals<readonly ["minimal", "hono", "elysia", "nest", "next", "svelte", "astro", "nuxt", "tanstack-start"]>;
|
|
180
|
+
readonly template: Schema.Literals<readonly ["minimal", "hono", "elysia", "nest", "next", "turborepo", "svelte", "astro", "nuxt", "tanstack-start"]>;
|
|
175
181
|
readonly databaseProvider: Schema.Literals<readonly ["postgres", "mongo"]>;
|
|
176
182
|
readonly authoring: Schema.Literals<readonly ["psl", "typescript"]>;
|
|
177
183
|
readonly packageManager: Schema.Literals<readonly ["npm", "pnpm", "yarn", "bun", "deno"]>;
|
|
@@ -183,7 +189,7 @@ type CreateCommandResult = typeof CreateCommandResultSchema.Type;
|
|
|
183
189
|
declare const createPrismaCommand: Command.Command<"create-prisma", {
|
|
184
190
|
readonly projectName: string | undefined;
|
|
185
191
|
readonly name: string | undefined;
|
|
186
|
-
readonly template: "minimal" | "hono" | "elysia" | "nest" | "next" | "svelte" | "astro" | "nuxt" | "tanstack-start" | undefined;
|
|
192
|
+
readonly template: "minimal" | "hono" | "elysia" | "nest" | "next" | "turborepo" | "svelte" | "astro" | "nuxt" | "tanstack-start" | undefined;
|
|
187
193
|
readonly provider: "postgres" | "mongo" | undefined;
|
|
188
194
|
readonly authoring: "psl" | "typescript" | undefined;
|
|
189
195
|
readonly packageManager: "npm" | "pnpm" | "yarn" | "bun" | "deno" | undefined;
|
|
@@ -198,7 +204,7 @@ declare const createPrismaCommand: Command.Command<"create-prisma", {
|
|
|
198
204
|
declare function createCreatePrismaCli(): Command.Command<"create-prisma", {
|
|
199
205
|
readonly projectName: string | undefined;
|
|
200
206
|
readonly name: string | undefined;
|
|
201
|
-
readonly template: "minimal" | "hono" | "elysia" | "nest" | "next" | "svelte" | "astro" | "nuxt" | "tanstack-start" | undefined;
|
|
207
|
+
readonly template: "minimal" | "hono" | "elysia" | "nest" | "next" | "turborepo" | "svelte" | "astro" | "nuxt" | "tanstack-start" | undefined;
|
|
202
208
|
readonly provider: "postgres" | "mongo" | undefined;
|
|
203
209
|
readonly authoring: "psl" | "typescript" | undefined;
|
|
204
210
|
readonly packageManager: "npm" | "pnpm" | "yarn" | "bun" | "deno" | undefined;
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { _ as authoringStyles, b as normalizeDatabaseProvider, c as CreateCommandResultSchema, d as AuthoringStyleSchema, f as CreateCommandInputSchema, g as agentSkillTargets, h as PackageManagerSchema, i as getErrorMessage, l as createCommandFailureResult, m as DatabaseProviderSchema, n as writeJsonResult, o as applicationRuntime, p as CreateTemplateSchema, r as runCreateCommandEffect, s as CREATE_PRISMA_RESULT_SCHEMA_VERSION, t as isJsonOutputRequested, u as AgentSkillTargetSchema, v as createTemplates, x as packageManagers, y as databaseProviderInputs } from "./json-output-
|
|
2
|
+
import { _ as authoringStyles, b as normalizeDatabaseProvider, c as CreateCommandResultSchema, d as AuthoringStyleSchema, f as CreateCommandInputSchema, g as agentSkillTargets, h as PackageManagerSchema, i as getErrorMessage, l as createCommandFailureResult, m as DatabaseProviderSchema, n as writeJsonResult, o as applicationRuntime, p as CreateTemplateSchema, r as runCreateCommandEffect, s as CREATE_PRISMA_RESULT_SCHEMA_VERSION, t as isJsonOutputRequested, u as AgentSkillTargetSchema, v as createTemplates, x as packageManagers, y as databaseProviderInputs } from "./json-output-DRjmY3tO.mjs";
|
|
3
3
|
import { Console, Effect, Option } from "effect";
|
|
4
4
|
import { Argument, CliError, Command, Flag } from "effect/unstable/cli";
|
|
5
5
|
|
|
6
6
|
//#region src/index.ts
|
|
7
|
-
const CLI_VERSION = "0.
|
|
7
|
+
const CLI_VERSION = "0.13.0-pr.104.357.1";
|
|
8
8
|
const optionalArgument = (name, description) => Argument.string(name).pipe(Argument.withDescription(description), Argument.optional, Argument.map(Option.getOrUndefined));
|
|
9
9
|
const optionalBoolean = (name, description) => Flag.boolean(name).pipe(Flag.withDescription(description), Flag.optional, Flag.map(Option.getOrUndefined));
|
|
10
10
|
const optionalString = (name, description) => Flag.string(name).pipe(Flag.withDescription(description), Flag.optional, Flag.map(Option.getOrUndefined));
|
|
@@ -13,6 +13,36 @@ import { fileURLToPath } from "node:url";
|
|
|
13
13
|
import { Writable } from "node:stream";
|
|
14
14
|
import { styleText } from "node:util";
|
|
15
15
|
|
|
16
|
+
//#region src/utils/child-process-failure.ts
|
|
17
|
+
const ChildProcessFailureSchema = Schema.Literals([
|
|
18
|
+
"cancelled",
|
|
19
|
+
"command_not_found",
|
|
20
|
+
"interrupted",
|
|
21
|
+
"max_buffer",
|
|
22
|
+
"non_zero_exit",
|
|
23
|
+
"permission_denied",
|
|
24
|
+
"spawn_failed",
|
|
25
|
+
"terminated",
|
|
26
|
+
"timed_out"
|
|
27
|
+
]);
|
|
28
|
+
const WINDOWS_CONTROL_C_EXIT_CODE = 3221225786;
|
|
29
|
+
function getChildProcessFailure(error) {
|
|
30
|
+
if (typeof error !== "object" || error === null) return void 0;
|
|
31
|
+
if (Reflect.get(error, "name") !== "ExecaError" || Reflect.get(error, "failed") !== true) return;
|
|
32
|
+
if (Reflect.get(error, "timedOut") === true) return "timed_out";
|
|
33
|
+
if (Reflect.get(error, "isCanceled") === true) return "cancelled";
|
|
34
|
+
if (Reflect.get(error, "isMaxBuffer") === true) return "max_buffer";
|
|
35
|
+
const exitCode = Reflect.get(error, "exitCode");
|
|
36
|
+
if (Reflect.get(error, "signal") === "SIGINT" || exitCode === 130 || exitCode === WINDOWS_CONTROL_C_EXIT_CODE) return "interrupted";
|
|
37
|
+
if (Reflect.get(error, "isTerminated") === true) return "terminated";
|
|
38
|
+
const code = Reflect.get(error, "code");
|
|
39
|
+
if (code === "ENOENT") return "command_not_found";
|
|
40
|
+
if (code === "EACCES" || code === "EPERM") return "permission_denied";
|
|
41
|
+
if (typeof exitCode === "number") return "non_zero_exit";
|
|
42
|
+
return "spawn_failed";
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
//#endregion
|
|
16
46
|
//#region src/create-outcome.ts
|
|
17
47
|
const CreateFailureStageSchema = Schema.Literals([
|
|
18
48
|
"validate_input",
|
|
@@ -94,7 +124,8 @@ var PrismaCliCommandError = class extends Schema.TaggedError()("PrismaCliCommand
|
|
|
94
124
|
command: Schema.optionalKey(Schema.String),
|
|
95
125
|
code: Schema.optionalKey(Schema.String),
|
|
96
126
|
stderr: Schema.optionalKey(Schema.String),
|
|
97
|
-
exitCode: Schema.optionalKey(Schema.Number)
|
|
127
|
+
exitCode: Schema.optionalKey(Schema.Number),
|
|
128
|
+
childProcessFailure: Schema.optional(ChildProcessFailureSchema)
|
|
98
129
|
}) {
|
|
99
130
|
prismaCliCommand = this.command;
|
|
100
131
|
prismaCliErrorCode = this.code;
|
|
@@ -130,6 +161,7 @@ const createTemplates = [
|
|
|
130
161
|
"elysia",
|
|
131
162
|
"nest",
|
|
132
163
|
"next",
|
|
164
|
+
"turborepo",
|
|
133
165
|
"svelte",
|
|
134
166
|
"astro",
|
|
135
167
|
"nuxt",
|
|
@@ -283,7 +315,8 @@ var CommandExecutionError = class extends Schema.TaggedError()("CommandExecution
|
|
|
283
315
|
exitCode: Schema.optionalKey(Schema.Number),
|
|
284
316
|
stdout: Schema.String,
|
|
285
317
|
stderr: Schema.String,
|
|
286
|
-
cause: Schema.optionalKey(Schema.Defect())
|
|
318
|
+
cause: Schema.optionalKey(Schema.Defect()),
|
|
319
|
+
childProcessFailure: Schema.optional(ChildProcessFailureSchema)
|
|
287
320
|
}) {
|
|
288
321
|
get message() {
|
|
289
322
|
const detail = this.stderr.trim() || this.stdout.trim();
|
|
@@ -319,7 +352,8 @@ var CommandRunner = class CommandRunner extends Context.Service()("create-prisma
|
|
|
319
352
|
return {
|
|
320
353
|
exitCode: result.exitCode ?? 1,
|
|
321
354
|
stdout: typeof result.stdout === "string" ? result.stdout : "",
|
|
322
|
-
stderr: typeof result.stderr === "string" ? result.stderr : ""
|
|
355
|
+
stderr: typeof result.stderr === "string" ? result.stderr : "",
|
|
356
|
+
childProcessFailure: getChildProcessFailure(result)
|
|
323
357
|
};
|
|
324
358
|
},
|
|
325
359
|
catch: (cause) => new CommandExecutionError({
|
|
@@ -327,7 +361,8 @@ var CommandRunner = class CommandRunner extends Context.Service()("create-prisma
|
|
|
327
361
|
args: [...spec.args],
|
|
328
362
|
stdout: "",
|
|
329
363
|
stderr: "",
|
|
330
|
-
cause
|
|
364
|
+
cause,
|
|
365
|
+
childProcessFailure: getChildProcessFailure(cause)
|
|
331
366
|
})
|
|
332
367
|
}));
|
|
333
368
|
const runChecked = Effect.fn("CommandRunner.runChecked")((spec) => Effect.flatMap(run(spec), (result) => result.exitCode === 0 ? Effect.succeed(result) : Effect.fail(new CommandExecutionError({
|
|
@@ -335,7 +370,8 @@ var CommandRunner = class CommandRunner extends Context.Service()("create-prisma
|
|
|
335
370
|
args: [...spec.args],
|
|
336
371
|
exitCode: result.exitCode,
|
|
337
372
|
stdout: result.stdout,
|
|
338
|
-
stderr: result.stderr
|
|
373
|
+
stderr: result.stderr,
|
|
374
|
+
childProcessFailure: result.childProcessFailure
|
|
339
375
|
}))));
|
|
340
376
|
return CommandRunner.of({
|
|
341
377
|
run,
|
|
@@ -352,20 +388,14 @@ const applicationRuntime = ManagedRuntime.make(ApplicationLayer);
|
|
|
352
388
|
|
|
353
389
|
//#endregion
|
|
354
390
|
//#region src/telemetry/client.ts
|
|
355
|
-
const TELEMETRY_API_KEY = "
|
|
391
|
+
const TELEMETRY_API_KEY = "";
|
|
356
392
|
const TELEMETRY_HOST = "https://us.i.posthog.com";
|
|
357
393
|
const TELEMETRY_CONFIG_FILE = "telemetry.json";
|
|
358
394
|
const TELEMETRY_TIMEOUT_MS = 2e3;
|
|
359
395
|
const AnonymousId = Schema.String.check(Schema.isUUID(4));
|
|
360
396
|
const decodeAnonymousId = Schema.decodeUnknownExit(AnonymousId);
|
|
361
|
-
const isTruthyEnvValue = (value) => [
|
|
362
|
-
"1",
|
|
363
|
-
"true",
|
|
364
|
-
"yes",
|
|
365
|
-
"on"
|
|
366
|
-
].includes(String(value ?? "").trim().toLowerCase());
|
|
367
397
|
function shouldDisableTelemetry() {
|
|
368
|
-
return
|
|
398
|
+
return true;
|
|
369
399
|
}
|
|
370
400
|
function getTelemetryConfigDir() {
|
|
371
401
|
if (process.platform === "darwin") return path.join(os.homedir(), "Library", "Application Support", "create-prisma");
|
|
@@ -388,7 +418,7 @@ const getAnonymousIdEffect = Effect.fn("Telemetry.getAnonymousId")(function* ()
|
|
|
388
418
|
return anonymousId;
|
|
389
419
|
});
|
|
390
420
|
const getCommonProperties = () => ({
|
|
391
|
-
"cli-version": "0.
|
|
421
|
+
"cli-version": "0.13.0-pr.104.357.1",
|
|
392
422
|
"node-version": process.version,
|
|
393
423
|
platform: process.platform,
|
|
394
424
|
arch: process.arch
|
|
@@ -474,6 +504,9 @@ function getErrorCode(error) {
|
|
|
474
504
|
const code = Reflect.get(error, "code");
|
|
475
505
|
return typeof code === "number" || typeof code === "string" ? code : null;
|
|
476
506
|
}
|
|
507
|
+
function getChildProcessFailureProperty(error) {
|
|
508
|
+
return error instanceof CommandExecutionError || error instanceof PrismaCliCommandError ? error.childProcessFailure ?? null : null;
|
|
509
|
+
}
|
|
477
510
|
function getPrismaCliFailureProperty(error, property) {
|
|
478
511
|
if (typeof error !== "object" || error === null) return null;
|
|
479
512
|
const value = Reflect.get(error, property);
|
|
@@ -494,6 +527,7 @@ const trackCreateFailedEffect = Effect.fn("Telemetry.createFailed")(function* (p
|
|
|
494
527
|
"failure-reason": params.reason,
|
|
495
528
|
"error-name": getErrorName(params.error),
|
|
496
529
|
"error-code": getErrorCode(params.error),
|
|
530
|
+
"child-process-failure": getChildProcessFailureProperty(params.error),
|
|
497
531
|
"prisma-cli-command": getPrismaCliFailureProperty(params.error, "prismaCliCommand"),
|
|
498
532
|
"prisma-cli-error-code": getPrismaCliFailureProperty(params.error, "prismaCliErrorCode")
|
|
499
533
|
}).pipe(Effect.scoped, Effect.timeout(TELEMETRY_TIMEOUT_MS), Effect.catch(() => Effect.void));
|
|
@@ -506,6 +540,86 @@ const trackCreateCancelledEffect = Effect.fn("Telemetry.createCancelled")(functi
|
|
|
506
540
|
}).pipe(Effect.scoped, Effect.timeout(TELEMETRY_TIMEOUT_MS), Effect.catch(() => Effect.void));
|
|
507
541
|
});
|
|
508
542
|
|
|
543
|
+
//#endregion
|
|
544
|
+
//#region src/constants/dependencies.ts
|
|
545
|
+
const dependencyVersionMap = {
|
|
546
|
+
"@astrojs/node": "^10.0.2",
|
|
547
|
+
"@elysiajs/node": "^1.4.5",
|
|
548
|
+
"@prisma/composer": "0.20.0",
|
|
549
|
+
"@prisma/composer-prisma-cloud": "0.20.0",
|
|
550
|
+
"@prisma/dev": "0.25.2",
|
|
551
|
+
"@prisma/orm-mongo": "8.0.0-rc.11",
|
|
552
|
+
"@prisma/orm-postgres": "8.0.0-rc.11",
|
|
553
|
+
"@sveltejs/adapter-node": "^5.3.2",
|
|
554
|
+
"@types/node": "^25.6.2",
|
|
555
|
+
alchemy: "2.0.0-beta.74",
|
|
556
|
+
arktype: "^2.2.3",
|
|
557
|
+
dotenv: "^17.4.2",
|
|
558
|
+
effect: "4.0.0-rc.112",
|
|
559
|
+
mongodb: "^7.1.0",
|
|
560
|
+
"mongodb-memory-server": "^11.1.0",
|
|
561
|
+
nitro: "^3.0.260610-beta",
|
|
562
|
+
prisma: "8.0.0-rc.15",
|
|
563
|
+
"temporal-polyfill": "^1.0.4",
|
|
564
|
+
tsdown: "^0.22.14",
|
|
565
|
+
turbo: "2.10.12",
|
|
566
|
+
tsx: "^4.21.0",
|
|
567
|
+
typescript: "^5.9.3"
|
|
568
|
+
};
|
|
569
|
+
const PRISMA_PLATFORM_CLI_PACKAGE = `prisma@${dependencyVersionMap.prisma}`;
|
|
570
|
+
const PRISMA_DENO_CLI_PACKAGE = PRISMA_PLATFORM_CLI_PACKAGE;
|
|
571
|
+
function getDependencyVersion(packageName) {
|
|
572
|
+
return dependencyVersionMap[packageName];
|
|
573
|
+
}
|
|
574
|
+
function usesTsdown(template) {
|
|
575
|
+
return template === "minimal" || template === "hono" || template === "elysia" || template === "nest";
|
|
576
|
+
}
|
|
577
|
+
function getCreateTemplateDependencies(template, packageManager) {
|
|
578
|
+
const dependencies = [
|
|
579
|
+
"@prisma/composer",
|
|
580
|
+
"@prisma/composer-prisma-cloud",
|
|
581
|
+
"alchemy"
|
|
582
|
+
];
|
|
583
|
+
const devDependencies = [];
|
|
584
|
+
if (usesTsdown(template)) {
|
|
585
|
+
devDependencies.push("tsdown");
|
|
586
|
+
devDependencies.push("tsx");
|
|
587
|
+
}
|
|
588
|
+
if (template === "minimal") devDependencies.push("typescript");
|
|
589
|
+
if (template === "elysia") {
|
|
590
|
+
dependencies.push("@elysiajs/node");
|
|
591
|
+
devDependencies.push("@types/node");
|
|
592
|
+
}
|
|
593
|
+
if (template === "svelte") devDependencies.push("@sveltejs/adapter-node");
|
|
594
|
+
if (template === "astro") dependencies.push("@astrojs/node");
|
|
595
|
+
if (template === "tanstack-start") devDependencies.push("nitro");
|
|
596
|
+
if (template === "turborepo") devDependencies.push("turbo", "typescript");
|
|
597
|
+
const targets = [{
|
|
598
|
+
packageJsonPath: "package.json",
|
|
599
|
+
dependencies,
|
|
600
|
+
devDependencies
|
|
601
|
+
}];
|
|
602
|
+
if (template === "turborepo") {
|
|
603
|
+
targets.push({
|
|
604
|
+
packageJsonPath: "apps/server/package.json",
|
|
605
|
+
dependencies: [],
|
|
606
|
+
devDependencies: [
|
|
607
|
+
"@types/node",
|
|
608
|
+
"tsdown",
|
|
609
|
+
"tsx",
|
|
610
|
+
"typescript"
|
|
611
|
+
],
|
|
612
|
+
customDependencies: { "@repo/database": packageManager === "npm" ? "*" : "workspace:*" }
|
|
613
|
+
});
|
|
614
|
+
targets.push({
|
|
615
|
+
packageJsonPath: "packages/database/package.json",
|
|
616
|
+
dependencies: [],
|
|
617
|
+
devDependencies: ["typescript"]
|
|
618
|
+
});
|
|
619
|
+
}
|
|
620
|
+
return targets;
|
|
621
|
+
}
|
|
622
|
+
|
|
509
623
|
//#endregion
|
|
510
624
|
//#region src/utils/package-manager.ts
|
|
511
625
|
const DENO_ALLOW_FRESH_DEPENDENCIES = "--minimum-dependency-age=0";
|
|
@@ -656,7 +770,7 @@ function getLocalPackageBinaryArgs(packageManager, binaryName, binaryArgs) {
|
|
|
656
770
|
"run",
|
|
657
771
|
"-A",
|
|
658
772
|
"--frozen",
|
|
659
|
-
`npm:${binaryName}
|
|
773
|
+
`npm:${binaryName}@${getDependencyVersion(binaryName) ?? "latest"}`,
|
|
660
774
|
...binaryArgs
|
|
661
775
|
]
|
|
662
776
|
};
|
|
@@ -767,9 +881,10 @@ const renderTemplateTreeEffect = Effect.fn("Templates.renderTree")(function* (op
|
|
|
767
881
|
for (const relativePath of entries) {
|
|
768
882
|
const templateFilePath = path.join(opts.templateRoot, relativePath);
|
|
769
883
|
if ((yield* fs.stat(templateFilePath)).type !== "File") continue;
|
|
884
|
+
const renderedRelativePath = stripHbsExtension(relativePath);
|
|
770
885
|
yield* renderTemplateFileEffect({
|
|
771
886
|
templateFilePath,
|
|
772
|
-
outputPath: path.join(opts.outputDir,
|
|
887
|
+
outputPath: path.join(opts.outputDir, opts.mapRelativeOutputPath?.(renderedRelativePath) ?? renderedRelativePath),
|
|
773
888
|
context: opts.context
|
|
774
889
|
});
|
|
775
890
|
}
|
|
@@ -777,11 +892,17 @@ const renderTemplateTreeEffect = Effect.fn("Templates.renderTree")(function* (op
|
|
|
777
892
|
|
|
778
893
|
//#endregion
|
|
779
894
|
//#region src/templates/render-create-template.ts
|
|
895
|
+
const DEFAULT_PRISMA_SOURCE_DIR = "src/prisma";
|
|
896
|
+
const TURBOREPO_PRISMA_SOURCE_DIR = "packages/database/src";
|
|
897
|
+
function getCreatePrismaSourceDir(template) {
|
|
898
|
+
return template === "turborepo" ? TURBOREPO_PRISMA_SOURCE_DIR : DEFAULT_PRISMA_SOURCE_DIR;
|
|
899
|
+
}
|
|
780
900
|
const tsdownEntries = {
|
|
781
901
|
minimal: "src/index.ts",
|
|
782
902
|
hono: "src/index.ts",
|
|
783
903
|
elysia: "src/index.ts",
|
|
784
|
-
nest: "src/main.ts"
|
|
904
|
+
nest: "src/main.ts",
|
|
905
|
+
turborepo: "src/index.ts"
|
|
785
906
|
};
|
|
786
907
|
function createTemplateContext(options) {
|
|
787
908
|
return {
|
|
@@ -798,7 +919,14 @@ const scaffoldCreateSharedTemplatesEffect = Effect.fn("Templates.scaffoldShared"
|
|
|
798
919
|
yield* renderTemplateTreeEffect({
|
|
799
920
|
templateRoot: yield* resolveTemplatesDirEffect("templates/create/_shared"),
|
|
800
921
|
outputDir: options.projectDir,
|
|
801
|
-
context: createTemplateContext(options)
|
|
922
|
+
context: createTemplateContext(options),
|
|
923
|
+
mapRelativeOutputPath(relativePath) {
|
|
924
|
+
if (options.template !== "turborepo") return relativePath;
|
|
925
|
+
if (relativePath === "tsdown.config.ts") return path.join("apps/server", relativePath);
|
|
926
|
+
const relativePrismaPath = path.relative(DEFAULT_PRISMA_SOURCE_DIR, relativePath);
|
|
927
|
+
if (relativePrismaPath === ".." || relativePrismaPath.startsWith(`..${path.sep}`) || path.isAbsolute(relativePrismaPath)) return relativePath;
|
|
928
|
+
return path.join(TURBOREPO_PRISMA_SOURCE_DIR, relativePrismaPath);
|
|
929
|
+
}
|
|
802
930
|
});
|
|
803
931
|
});
|
|
804
932
|
const scaffoldCreatePackageManagerTemplatesEffect = Effect.fn("Templates.scaffoldPackageManager")(function* (options) {
|
|
@@ -821,64 +949,6 @@ const scaffoldCreateTemplateEffect = Effect.fn("Templates.scaffold")(function* (
|
|
|
821
949
|
yield* scaffoldCreateSharedTemplatesEffect(options);
|
|
822
950
|
});
|
|
823
951
|
|
|
824
|
-
//#endregion
|
|
825
|
-
//#region src/constants/dependencies.ts
|
|
826
|
-
const dependencyVersionMap = {
|
|
827
|
-
"@astrojs/node": "^10.0.2",
|
|
828
|
-
"@elysiajs/node": "^1.4.5",
|
|
829
|
-
"@prisma/composer": "0.19.0",
|
|
830
|
-
"@prisma/composer-prisma-cloud": "0.19.0",
|
|
831
|
-
"@prisma/orm-mongo": "8.0.0-rc.10",
|
|
832
|
-
"@prisma/orm-postgres": "8.0.0-rc.10",
|
|
833
|
-
"@sveltejs/adapter-node": "^5.3.2",
|
|
834
|
-
"@types/node": "^25.6.2",
|
|
835
|
-
alchemy: "2.0.0-beta.74",
|
|
836
|
-
arktype: "^2.2.3",
|
|
837
|
-
dotenv: "^17.4.2",
|
|
838
|
-
effect: "4.0.0-rc.112",
|
|
839
|
-
mongodb: "^7.1.0",
|
|
840
|
-
"mongodb-memory-server": "^11.1.0",
|
|
841
|
-
nitro: "^3.0.260610-beta",
|
|
842
|
-
prisma: "latest",
|
|
843
|
-
"temporal-polyfill": "^1.0.4",
|
|
844
|
-
tsdown: "^0.22.14",
|
|
845
|
-
tsx: "^4.21.0",
|
|
846
|
-
typescript: "^5.9.3"
|
|
847
|
-
};
|
|
848
|
-
const PRISMA_PLATFORM_CLI_PACKAGE = "prisma@latest";
|
|
849
|
-
const PRISMA_DENO_CLI_PACKAGE = PRISMA_PLATFORM_CLI_PACKAGE;
|
|
850
|
-
function getDependencyVersion(packageName) {
|
|
851
|
-
return dependencyVersionMap[packageName];
|
|
852
|
-
}
|
|
853
|
-
function usesTsdown(template) {
|
|
854
|
-
return template === "minimal" || template === "hono" || template === "elysia" || template === "nest";
|
|
855
|
-
}
|
|
856
|
-
function getCreateTemplateDependencies(template, _packageManager) {
|
|
857
|
-
const dependencies = [
|
|
858
|
-
"@prisma/composer",
|
|
859
|
-
"@prisma/composer-prisma-cloud",
|
|
860
|
-
"alchemy"
|
|
861
|
-
];
|
|
862
|
-
const devDependencies = [];
|
|
863
|
-
if (usesTsdown(template)) {
|
|
864
|
-
devDependencies.push("tsdown");
|
|
865
|
-
devDependencies.push("tsx");
|
|
866
|
-
}
|
|
867
|
-
if (template === "minimal") devDependencies.push("typescript");
|
|
868
|
-
if (template === "elysia") {
|
|
869
|
-
dependencies.push("@elysiajs/node");
|
|
870
|
-
devDependencies.push("@types/node");
|
|
871
|
-
}
|
|
872
|
-
if (template === "svelte") devDependencies.push("@sveltejs/adapter-node");
|
|
873
|
-
if (template === "astro") dependencies.push("@astrojs/node");
|
|
874
|
-
if (template === "tanstack-start") devDependencies.push("nitro");
|
|
875
|
-
return [{
|
|
876
|
-
packageJsonPath: "package.json",
|
|
877
|
-
dependencies,
|
|
878
|
-
devDependencies
|
|
879
|
-
}];
|
|
880
|
-
}
|
|
881
|
-
|
|
882
952
|
//#endregion
|
|
883
953
|
//#region src/constants/db-packages.ts
|
|
884
954
|
function getDbPackages(provider) {
|
|
@@ -995,16 +1065,25 @@ const addPackageDependencyEffect = Effect.fn("Dependencies.add")(function* (opts
|
|
|
995
1065
|
yield* writePackageJson(packageJsonPath, packageJson);
|
|
996
1066
|
});
|
|
997
1067
|
const writePrismaDependenciesEffect = Effect.fn("Dependencies.writePrisma")(function* (provider, packageManager, _authoring, projectDir = process.cwd(), options = {}) {
|
|
998
|
-
const
|
|
999
|
-
|
|
1000
|
-
if (provider === "
|
|
1068
|
+
const databaseDependencies = [getDbPackages(provider)];
|
|
1069
|
+
const devDependencies = ["@types/node", "prisma"];
|
|
1070
|
+
if (provider === "postgres" && packageManager !== "deno") {
|
|
1071
|
+
databaseDependencies.push("temporal-polyfill");
|
|
1072
|
+
devDependencies.push("@prisma/dev");
|
|
1073
|
+
}
|
|
1074
|
+
if (provider === "mongo") databaseDependencies.push("arktype", "mongodb");
|
|
1075
|
+
const dependencies = options.template === "turborepo" ? [getDbPackages(provider), ...provider === "mongo" ? ["arktype"] : []] : [...databaseDependencies];
|
|
1001
1076
|
if (packageManager === "deno") dependencies.push("dotenv");
|
|
1002
1077
|
yield* addPackageDependencyEffect({
|
|
1003
1078
|
dependencies,
|
|
1004
|
-
devDependencies
|
|
1079
|
+
devDependencies,
|
|
1005
1080
|
scripts: getPrismaScriptMap(packageManager, options.skillsSync ?? true),
|
|
1006
1081
|
projectDir
|
|
1007
1082
|
});
|
|
1083
|
+
if (options.template === "turborepo") yield* addPackageDependencyEffect({
|
|
1084
|
+
dependencies: databaseDependencies,
|
|
1085
|
+
projectDir: path.join(projectDir, "packages/database")
|
|
1086
|
+
});
|
|
1008
1087
|
});
|
|
1009
1088
|
const writeCreateTemplateDependenciesEffect = Effect.fn("Dependencies.writeTemplate")(function* (opts) {
|
|
1010
1089
|
const projectDir = opts.projectDir ?? process.cwd();
|
|
@@ -1013,7 +1092,7 @@ const writeCreateTemplateDependenciesEffect = Effect.fn("Dependencies.writeTempl
|
|
|
1013
1092
|
dependencies: target.dependencies,
|
|
1014
1093
|
devDependencies: target.devDependencies,
|
|
1015
1094
|
customDependencies: target.customDependencies,
|
|
1016
|
-
scripts: getComposerScriptMap(opts.packageManager),
|
|
1095
|
+
scripts: target.packageJsonPath === "package.json" ? getComposerScriptMap(opts.packageManager) : void 0,
|
|
1017
1096
|
projectDir: path.join(projectDir, path.dirname(target.packageJsonPath))
|
|
1018
1097
|
});
|
|
1019
1098
|
const packageJsonPath = path.join(projectDir, "package.json");
|
|
@@ -1110,7 +1189,8 @@ const runPrismaJsonCommandEffect = Effect.fn("PrismaCli.runJson")(function* (opt
|
|
|
1110
1189
|
return yield* new PrismaCliCommandError({
|
|
1111
1190
|
message: redactSecrets(result.stderr.trim() || result.stdout.trim()) || getErrorMessage(cause),
|
|
1112
1191
|
stderr: redactSecrets(result.stderr),
|
|
1113
|
-
exitCode: result.exitCode
|
|
1192
|
+
exitCode: result.exitCode,
|
|
1193
|
+
childProcessFailure: result.childProcessFailure
|
|
1114
1194
|
});
|
|
1115
1195
|
}
|
|
1116
1196
|
if (result.exitCode !== 0 || !envelope.ok || envelope.result === void 0) return yield* new PrismaCliCommandError({
|
|
@@ -1118,7 +1198,8 @@ const runPrismaJsonCommandEffect = Effect.fn("PrismaCli.runJson")(function* (opt
|
|
|
1118
1198
|
...envelope.commandId || envelope.command ? { command: envelope.commandId ?? envelope.command } : {},
|
|
1119
1199
|
...envelope.error?.code ? { code: envelope.error.code } : {},
|
|
1120
1200
|
stderr: redactSecrets(result.stderr),
|
|
1121
|
-
exitCode: result.exitCode
|
|
1201
|
+
exitCode: result.exitCode,
|
|
1202
|
+
childProcessFailure: result.childProcessFailure
|
|
1122
1203
|
});
|
|
1123
1204
|
return envelope.result;
|
|
1124
1205
|
});
|
|
@@ -1508,7 +1589,7 @@ const initializeGitRepositoryEffect = Effect.fn("Git.initialize")(function* (pro
|
|
|
1508
1589
|
|
|
1509
1590
|
//#endregion
|
|
1510
1591
|
//#region src/tasks/prisma-setup/commands.ts
|
|
1511
|
-
const getContractPath = (authoring) =>
|
|
1592
|
+
const getContractPath = (authoring, template) => `${getCreatePrismaSourceDir(template)}/contract${authoring === "typescript" ? ".ts" : ".prisma"}`;
|
|
1512
1593
|
const getInitTarget = (provider) => provider === "mongo" ? "mongodb" : "postgres";
|
|
1513
1594
|
const runPrismaCli = Effect.fn("PrismaSetup.runCli")(function* (context, projectDir, args) {
|
|
1514
1595
|
const invocation = getLocalPackageBinaryArgs(context.packageManager, "prisma", args);
|
|
@@ -1526,7 +1607,7 @@ const runPrismaCli = Effect.fn("PrismaSetup.runCli")(function* (context, project
|
|
|
1526
1607
|
...context.verbose ? { onStderrLine: (line) => log.message(redactSecrets(line), { output: context.output }) } : {}
|
|
1527
1608
|
});
|
|
1528
1609
|
});
|
|
1529
|
-
const runPrismaInit = Effect.fn("PrismaSetup.init")(function* (context, projectDir, force = false) {
|
|
1610
|
+
const runPrismaInit = Effect.fn("PrismaSetup.init")(function* (context, projectDir, force = false, template = "minimal") {
|
|
1530
1611
|
yield* runPrismaCli(context, projectDir, [
|
|
1531
1612
|
"orm",
|
|
1532
1613
|
"init",
|
|
@@ -1537,7 +1618,7 @@ const runPrismaInit = Effect.fn("PrismaSetup.init")(function* (context, projectD
|
|
|
1537
1618
|
"--authoring",
|
|
1538
1619
|
context.authoring,
|
|
1539
1620
|
"--schema-path",
|
|
1540
|
-
getContractPath(context.authoring),
|
|
1621
|
+
getContractPath(context.authoring, template),
|
|
1541
1622
|
"--skip-install"
|
|
1542
1623
|
]);
|
|
1543
1624
|
if (context.packageManager === "deno") {
|
|
@@ -1805,14 +1886,17 @@ const executePrismaSetupContextEffect = Effect.fn("PrismaSetup.execute")(functio
|
|
|
1805
1886
|
packageManager: context.packageManager,
|
|
1806
1887
|
skillAgents: context.skillAgents
|
|
1807
1888
|
}), "configure_project", "project_configuration_failed");
|
|
1808
|
-
yield* atCreateStage(writePrismaDependenciesEffect(context.databaseProvider, context.packageManager, context.authoring, projectDir, {
|
|
1889
|
+
yield* atCreateStage(writePrismaDependenciesEffect(context.databaseProvider, context.packageManager, context.authoring, projectDir, {
|
|
1890
|
+
skillsSync: context.skillAgents.length > 0,
|
|
1891
|
+
template
|
|
1892
|
+
}), "configure_project", "project_configuration_failed");
|
|
1809
1893
|
yield* Effect.sync(() => progress?.message(`Installing dependencies with ${getInstallCommand(context.packageManager)}...`));
|
|
1810
1894
|
yield* atCreateStage(installProjectDependenciesEffect(context.packageManager, projectDir, {
|
|
1811
1895
|
verbose: context.verbose,
|
|
1812
1896
|
json: context.json
|
|
1813
1897
|
}), "install_dependencies", "dependency_install_failed");
|
|
1814
1898
|
yield* Effect.sync(() => progress?.message("Preparing Prisma 8 project files..."));
|
|
1815
|
-
yield* atCreateStage(runPrismaInit(context, projectDir, options.force), "initialize_prisma", "prisma_init_failed");
|
|
1899
|
+
yield* atCreateStage(runPrismaInit(context, projectDir, options.force, template), "initialize_prisma", "prisma_init_failed");
|
|
1816
1900
|
yield* atCreateStage(Effect.gen(function* () {
|
|
1817
1901
|
yield* scaffoldCreateSharedTemplatesEffect({
|
|
1818
1902
|
projectDir,
|
|
@@ -1995,6 +2079,11 @@ const promptForCreateTemplate = Effect.fn("Prompts.template")(function* (output)
|
|
|
1995
2079
|
label: "Next.js",
|
|
1996
2080
|
hint: "Full-stack React app with App Router"
|
|
1997
2081
|
},
|
|
2082
|
+
{
|
|
2083
|
+
value: "turborepo",
|
|
2084
|
+
label: "Monorepo (Turborepo)",
|
|
2085
|
+
hint: "Hello World server with a shared Prisma database package"
|
|
2086
|
+
},
|
|
1998
2087
|
{
|
|
1999
2088
|
value: "svelte",
|
|
2000
2089
|
label: "SvelteKit",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-prisma",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0-pr.104.357.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Create Prisma 8 projects with first-party templates and great DX.",
|
|
6
6
|
"homepage": "https://github.com/prisma/create-prisma",
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
"format": "oxfmt --write .",
|
|
46
46
|
"format:check": "oxfmt --check .",
|
|
47
47
|
"typecheck": "tsc --noEmit",
|
|
48
|
+
"check:pins": "bun run scripts/check-pins.ts",
|
|
48
49
|
"bump": "bun run scripts/bump-version.ts",
|
|
49
50
|
"release": "bun run bump",
|
|
50
51
|
"release-notes": "bunx changelogithub"
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{{#if (eq authoring "typescript")}}
|
|
2
|
-
src/prisma/generated/contract.json linguist-generated
|
|
3
|
-
src/prisma/generated/contract.d.ts linguist-generated
|
|
2
|
+
{{#if (eq template "turborepo")}}packages/database/src{{else}}src/prisma{{/if}}/generated/contract.json linguist-generated
|
|
3
|
+
{{#if (eq template "turborepo")}}packages/database/src{{else}}src/prisma{{/if}}/generated/contract.d.ts linguist-generated
|
|
4
4
|
{{else}}
|
|
5
|
-
src/prisma/contract.json linguist-generated
|
|
6
|
-
src/prisma/contract.d.ts linguist-generated
|
|
5
|
+
{{#if (eq template "turborepo")}}packages/database/src{{else}}src/prisma{{/if}}/contract.json linguist-generated
|
|
6
|
+
{{#if (eq template "turborepo")}}packages/database/src{{else}}src/prisma{{/if}}/contract.d.ts linguist-generated
|
|
7
7
|
{{/if}}
|
|
8
|
-
src/prisma/ops.json linguist-generated
|
|
9
|
-
src/prisma/migration.json linguist-generated
|
|
8
|
+
{{#if (eq template "turborepo")}}packages/database/src{{else}}src/prisma{{/if}}/ops.json linguist-generated
|
|
9
|
+
{{#if (eq template "turborepo")}}packages/database/src{{else}}src/prisma{{/if}}/migration.json linguist-generated
|
|
10
10
|
migrations/snapshots/**/contract.json linguist-generated
|
|
11
11
|
migrations/snapshots/**/contract.d.ts linguist-generated
|
|
@@ -31,6 +31,50 @@ deno task contract:emit
|
|
|
31
31
|
```
|
|
32
32
|
|
|
33
33
|
Prisma Compute does not support Deno deployments yet.
|
|
34
|
+
{{else if (eq template "turborepo")}}
|
|
35
|
+
A minimal Prisma 8 monorepo with Turborepo and a plain Node.js HTTP server.
|
|
36
|
+
|
|
37
|
+
## Workspace layout
|
|
38
|
+
|
|
39
|
+
- `apps/server` — Hello World server; `/users` reads from the shared database package
|
|
40
|
+
- `packages/database` — Prisma contract, generated artifacts, runtime client, and seed data
|
|
41
|
+
- `module.ts` and `service.ts` — Composer deployment topology
|
|
42
|
+
|
|
43
|
+
## Run locally
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
{{runScriptCommand packageManager "dev:composer"}}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
This builds the workspace and starts it with Composer. PostgreSQL projects get a local Prisma Postgres database and apply the committed migrations automatically.
|
|
50
|
+
|
|
51
|
+
## Deploy
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
{{runScriptCommand packageManager "deploy"}}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
The deploy script builds the server with tsdown, provisions Prisma Postgres when selected, applies migrations, and deploys the server to Prisma Compute.
|
|
58
|
+
|
|
59
|
+
The home page returns `Hello World!` without querying the database. Visiting `/users` queries the shared Prisma package and inserts starter users idempotently from `packages/database/src/seed.ts`.
|
|
60
|
+
|
|
61
|
+
{{#if (eq provider "mongo")}}
|
|
62
|
+
MongoDB is not provisioned by Composer. Set `MONGODB_URL` before running Composer locally or deploying.
|
|
63
|
+
{{/if}}
|
|
64
|
+
|
|
65
|
+
## Prisma
|
|
66
|
+
|
|
67
|
+
- Contract: `packages/database/src/contract{{#if (eq authoring "typescript")}}.ts{{else}}.prisma{{/if}}`
|
|
68
|
+
- Prisma and Composer config: `prisma.config.ts`
|
|
69
|
+
- Composer app: `module.ts` and `service.ts`
|
|
70
|
+
|
|
71
|
+
After changing the contract, run:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
{{runScriptCommand packageManager "contract:emit"}}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
To run the workspace's development tasks directly, use `{{runScriptCommand packageManager "dev"}}`. This direct mode requires `{{#if (eq provider "postgres")}}DATABASE_URL{{else}}MONGODB_URL{{/if}}`.
|
|
34
78
|
{{else}}
|
|
35
79
|
A minimal {{template}} app with Prisma 8 and Prisma Composer.
|
|
36
80
|
|
|
@@ -3,7 +3,7 @@ import { module } from "@prisma/composer";
|
|
|
3
3
|
{{#if (eq provider "postgres")}}
|
|
4
4
|
import { postgres } from "@prisma/composer-prisma-cloud/orm";
|
|
5
5
|
|
|
6
|
-
import { appContract } from "./src/prisma/composer.ts";
|
|
6
|
+
import { appContract } from "./{{#if (eq template "turborepo")}}packages/database/src{{else}}src/prisma{{/if}}/composer.ts";
|
|
7
7
|
{{else}}
|
|
8
8
|
import { envSecret } from "@prisma/composer-prisma-cloud";
|
|
9
9
|
{{/if}}
|
|
@@ -5,9 +5,9 @@ import { defineConfig as ormConfig } from "@prisma/orm-{{#if (eq provider "postg
|
|
|
5
5
|
|
|
6
6
|
export default definePrismaConfig({
|
|
7
7
|
orm: ormConfig({
|
|
8
|
-
contract: "./src/prisma/contract{{#if (eq authoring "typescript")}}.ts{{else}}.prisma{{/if}}",
|
|
8
|
+
contract: "./{{#if (eq template "turborepo")}}packages/database/src{{else}}src/prisma{{/if}}/contract{{#if (eq authoring "typescript")}}.ts{{else}}.prisma{{/if}}",
|
|
9
9
|
{{#if (eq authoring "typescript")}}
|
|
10
|
-
output: "./src/prisma/generated",
|
|
10
|
+
output: "./{{#if (eq template "turborepo")}}packages/database/src{{else}}src/prisma{{/if}}/generated",
|
|
11
11
|
{{/if}}
|
|
12
12
|
db: {
|
|
13
13
|
connection: process.env.{{#if (eq provider "postgres")}}DATABASE_URL{{else}}MONGODB_URL{{/if}}!,
|
|
@@ -23,9 +23,9 @@ export default definePrismaConfig({
|
|
|
23
23
|
agents: [{{#each skillAgents}}"{{this}}"{{#unless @last}}, {{/unless}}{{/each}}],
|
|
24
24
|
},
|
|
25
25
|
orm: ormConfig({
|
|
26
|
-
contract: "./src/prisma/contract{{#if (eq authoring "typescript")}}.ts{{else}}.prisma{{/if}}",
|
|
26
|
+
contract: "./{{#if (eq template "turborepo")}}packages/database/src{{else}}src/prisma{{/if}}/contract{{#if (eq authoring "typescript")}}.ts{{else}}.prisma{{/if}}",
|
|
27
27
|
{{#if (eq authoring "typescript")}}
|
|
28
|
-
output: "./src/prisma/generated",
|
|
28
|
+
output: "./{{#if (eq template "turborepo")}}packages/database/src{{else}}src/prisma{{/if}}/generated",
|
|
29
29
|
{{/if}}
|
|
30
30
|
db: {
|
|
31
31
|
connection: process.env.{{#if (eq provider "postgres")}}DATABASE_URL{{else}}MONGODB_URL{{/if}}!,
|
|
@@ -12,7 +12,7 @@ import { compute } from "@prisma/composer-prisma-cloud";
|
|
|
12
12
|
{{#if (eq provider "postgres")}}
|
|
13
13
|
import { postgres } from "@prisma/composer-prisma-cloud/orm";
|
|
14
14
|
|
|
15
|
-
import { appContract } from "./src/prisma/composer.ts";
|
|
15
|
+
import { appContract } from "./{{#if (eq template "turborepo")}}packages/database/src{{else}}src/prisma{{/if}}/composer.ts";
|
|
16
16
|
{{/if}}
|
|
17
17
|
|
|
18
18
|
export default compute({
|
|
@@ -29,6 +29,8 @@ export default compute({
|
|
|
29
29
|
{{/if}}
|
|
30
30
|
{{#if (eq template "next")}}
|
|
31
31
|
build: nextjs({ module: import.meta.url, appDir: "." }),
|
|
32
|
+
{{else if (eq template "turborepo")}}
|
|
33
|
+
build: node({ module: import.meta.url, entry: "./apps/server/dist/server.mjs" }),
|
|
32
34
|
{{else if (eq template "svelte")}}
|
|
33
35
|
build: node({ module: import.meta.url, dir: "./build", entry: "index.js" }),
|
|
34
36
|
{{else if (eq template "astro")}}
|
|
@@ -14,7 +14,7 @@ export const db = postgres<Contract>({ contractJson, url: databaseUrl });
|
|
|
14
14
|
{{else}}
|
|
15
15
|
import "temporal-polyfill/global";
|
|
16
16
|
|
|
17
|
-
import service from "../../service.ts";
|
|
17
|
+
import service from "{{#if (eq template "turborepo")}}../../../service.ts{{else}}../../service.ts{{/if}}";
|
|
18
18
|
import type { Contract } from "./{{#if (eq authoring "typescript")}}generated/{{/if}}contract.d.ts";
|
|
19
19
|
import contractJson from "./{{#if (eq authoring "typescript")}}generated/{{/if}}contract.json" with { type: "json" };
|
|
20
20
|
|
|
@@ -35,7 +35,7 @@ export const db =
|
|
|
35
35
|
{{else}}
|
|
36
36
|
import mongo from "@prisma/orm-mongo/runtime";
|
|
37
37
|
|
|
38
|
-
import service from "../../service.ts";
|
|
38
|
+
import service from "{{#if (eq template "turborepo")}}../../../service.ts{{else}}../../service.ts{{/if}}";
|
|
39
39
|
import type { Contract } from "./{{#if (eq authoring "typescript")}}generated/{{/if}}contract.d.ts";
|
|
40
40
|
import contractJson from "./{{#if (eq authoring "typescript")}}generated/{{/if}}contract.json" with { type: "json" };
|
|
41
41
|
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@repo/server",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "tsx watch src/index.ts",
|
|
8
|
+
"build": "tsdown",
|
|
9
|
+
"start": "node dist/server.mjs",
|
|
10
|
+
"typecheck": "tsc --noEmit"
|
|
11
|
+
},
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": "^22.18.0 || >=24.11.0"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { createServer } from "node:http";
|
|
2
|
+
|
|
3
|
+
import { listUsers } from "@repo/database";
|
|
4
|
+
|
|
5
|
+
const port = Number(process.env.PORT ?? 3000);
|
|
6
|
+
|
|
7
|
+
createServer(async (request, response) => {
|
|
8
|
+
if (request.url === "/") {
|
|
9
|
+
response.writeHead(200, { "content-type": "text/plain" });
|
|
10
|
+
response.end("Hello World!");
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (request.url !== "/users") {
|
|
15
|
+
response.writeHead(404, { "content-type": "text/plain" });
|
|
16
|
+
response.end("Not found");
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
try {
|
|
21
|
+
const users = await listUsers();
|
|
22
|
+
response.writeHead(200, { "content-type": "application/json" });
|
|
23
|
+
response.end(JSON.stringify({ users }));
|
|
24
|
+
} catch (error) {
|
|
25
|
+
console.error("Failed to query users:", error);
|
|
26
|
+
response.writeHead(500, { "content-type": "application/json" });
|
|
27
|
+
response.end(JSON.stringify({ error: "Could not query users yet." }));
|
|
28
|
+
}
|
|
29
|
+
}).listen(port, "0.0.0.0", () => {
|
|
30
|
+
console.log(`Server running at http://localhost:${port}`);
|
|
31
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{projectName}}",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
{{#if (packageManagerManifestValue packageManager)}}
|
|
6
|
+
"packageManager": "{{packageManagerManifestValue packageManager}}",
|
|
7
|
+
{{/if}}
|
|
8
|
+
"type": "module",
|
|
9
|
+
"workspaces": [
|
|
10
|
+
"apps/*",
|
|
11
|
+
"packages/*"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "turbo run build",
|
|
15
|
+
"dev": "turbo run dev",
|
|
16
|
+
"start": "turbo run start",
|
|
17
|
+
"typecheck": "tsc --noEmit && turbo run typecheck"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {}
|
|
20
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"lib": ["ES2022"],
|
|
5
|
+
"module": "ESNext",
|
|
6
|
+
"moduleResolution": "Bundler",
|
|
7
|
+
"allowImportingTsExtensions": true,
|
|
8
|
+
"noEmit": true,
|
|
9
|
+
"resolveJsonModule": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"strict": true,
|
|
12
|
+
"types": ["node"]
|
|
13
|
+
},
|
|
14
|
+
"include": [
|
|
15
|
+
"module.ts",
|
|
16
|
+
"service.ts",
|
|
17
|
+
"prisma.config.ts",
|
|
18
|
+
"prisma-composer.config.ts",
|
|
19
|
+
"packages/**/*.ts"
|
|
20
|
+
],
|
|
21
|
+
"exclude": ["node_modules"]
|
|
22
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://turbo.build/schema.json",
|
|
3
|
+
"globalDependencies": ["service.ts", "packages/database/src/**"],
|
|
4
|
+
"globalPassThroughEnv": ["PORT", "DATABASE_URL", "MONGODB_URL"],
|
|
5
|
+
"tasks": {
|
|
6
|
+
"build": {
|
|
7
|
+
"dependsOn": ["^build"],
|
|
8
|
+
"outputs": ["dist/**"]
|
|
9
|
+
},
|
|
10
|
+
"dev": {
|
|
11
|
+
"cache": false,
|
|
12
|
+
"persistent": true
|
|
13
|
+
},
|
|
14
|
+
"start": {
|
|
15
|
+
"cache": false,
|
|
16
|
+
"dependsOn": ["build"],
|
|
17
|
+
"persistent": true
|
|
18
|
+
},
|
|
19
|
+
"typecheck": {
|
|
20
|
+
"dependsOn": ["^typecheck"]
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|