create-prisma 0.4.2 → 0.5.0-pr.41.123.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 +33 -0
- package/dist/cli.mjs +1 -1
- package/dist/{create-Cy_IS-sg.mjs → create-C0alltck.mjs} +432 -62
- package/dist/index.d.mts +2 -0
- package/dist/index.mjs +2 -2
- package/package.json +1 -1
- package/templates/create/astro/README.md.hbs +11 -0
- package/templates/create/astro/astro.config.mjs.hbs +10 -0
- package/templates/create/astro/package.json.hbs +2 -1
- package/templates/create/elysia/README.md.hbs +11 -0
- package/templates/create/elysia/package.json.hbs +1 -0
- package/templates/create/elysia/src/index.ts.hbs +1 -1
- package/templates/create/hono/README.md.hbs +11 -0
- package/templates/create/hono/package.json.hbs +1 -0
- package/templates/create/hono/src/index.ts.hbs +1 -1
- package/templates/create/nest/README.md.hbs +11 -0
- package/templates/create/next/README.md.hbs +11 -0
- package/templates/create/next/{next.config.ts → next.config.ts.hbs} +1 -1
- package/templates/create/nuxt/README.md.hbs +11 -0
- package/templates/create/svelte/README.md.hbs +11 -0
- package/templates/create/tanstack-start/README.md.hbs +11 -0
- package/templates/create/tanstack-start/package.json.hbs +7 -7
- package/templates/create/tanstack-start/vite.config.ts +10 -2
- package/templates/create/turborepo/README.md.hbs +11 -0
- package/templates/create/astro/astro.config.mjs +0 -5
package/README.md
CHANGED
|
@@ -13,6 +13,7 @@ Scaffold a new app with Prisma already wired up.
|
|
|
13
13
|
- adds `db:generate`, `db:migrate`, and `db:seed` scripts
|
|
14
14
|
- creates or updates `.env` with `DATABASE_URL`
|
|
15
15
|
- can install dependencies and run `prisma generate` for you
|
|
16
|
+
- can deploy the finished app to Prisma Compute and return a live URL
|
|
16
17
|
|
|
17
18
|
## Quick Start
|
|
18
19
|
|
|
@@ -76,6 +77,14 @@ Use Prisma Postgres auto-provisioning:
|
|
|
76
77
|
create-prisma --name my-app --template nest --provider postgresql --prisma-postgres
|
|
77
78
|
```
|
|
78
79
|
|
|
80
|
+
Deploy a supported app to Prisma Compute:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
create-prisma --name my-api --template hono --provider postgresql --deploy
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
With PostgreSQL, no `--database-url`, and no `--no-prisma-postgres`, the Compute flow creates a Prisma Compute project, creates a `main` Prisma Postgres database on the `main` branch, writes `DATABASE_URL` to `.env`, and deploys the app with environment variables loaded from `.env`.
|
|
87
|
+
|
|
79
88
|
## Supported Templates
|
|
80
89
|
|
|
81
90
|
- `hono`
|
|
@@ -88,6 +97,13 @@ create-prisma --name my-app --template nest --provider postgresql --prisma-postg
|
|
|
88
97
|
- `tanstack-start`
|
|
89
98
|
- `turborepo`
|
|
90
99
|
|
|
100
|
+
Prisma Compute deployment is currently supported for:
|
|
101
|
+
|
|
102
|
+
- `hono`
|
|
103
|
+
- `elysia`
|
|
104
|
+
- `next`
|
|
105
|
+
- `tanstack-start`
|
|
106
|
+
|
|
91
107
|
## Supported Databases
|
|
92
108
|
|
|
93
109
|
- `postgresql`
|
|
@@ -111,6 +127,7 @@ create-prisma --name my-app --template nest --provider postgresql --prisma-postg
|
|
|
111
127
|
- `--provider` choose the database provider
|
|
112
128
|
- `--package-manager` choose the package manager/runtime
|
|
113
129
|
- `--schema-preset empty|basic`
|
|
130
|
+
- `--deploy` deploy supported templates to Prisma Compute
|
|
114
131
|
- `--yes` accept defaults and skip prompts
|
|
115
132
|
- `--no-install` scaffold only
|
|
116
133
|
- `--no-generate` skip `prisma generate`
|
|
@@ -129,6 +146,22 @@ create-prisma --name my-app --template nest --provider postgresql --prisma-postg
|
|
|
129
146
|
|
|
130
147
|
These can be selected interactively or enabled with flags.
|
|
131
148
|
|
|
149
|
+
## Deploy to Prisma Compute
|
|
150
|
+
|
|
151
|
+
After scaffolding, `create-prisma` can deploy your app to [Prisma Compute](https://www.prisma.io/docs/compute), the serverless hosting for TypeScript apps that runs next to your Prisma Postgres database. It is offered for the templates the Prisma CLI can deploy today: `hono`, `elysia`, `next`, and `tanstack-start`.
|
|
152
|
+
|
|
153
|
+
Accept the prompt ("Deploy to Prisma Compute now?") when it appears, or pass the flag:
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
create-prisma --name my-api --template hono --provider postgresql --deploy
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
The deploy step signs you in with the Prisma CLI if you are not signed in yet. With PostgreSQL, no `--database-url`, and no `--no-prisma-postgres`, setup creates a Prisma Compute project, creates a `main` Prisma Postgres database on the `main` branch, writes `DATABASE_URL` to `.env`, runs the requested Prisma setup, then deploys the app with environment variables loaded from `.env`.
|
|
160
|
+
|
|
161
|
+
A `compute:deploy` script is added to the generated project so you can redeploy app changes later. That script only runs `@prisma/cli@latest app deploy` with `.env`; it does not create a new project, create a new database, run migrations, or seed data.
|
|
162
|
+
|
|
163
|
+
The deploy prompt is skipped in `--yes` runs unless you pass `--deploy`. Browser sign-in may still need a person at the keyboard if no Prisma CLI session exists.
|
|
164
|
+
|
|
132
165
|
## Local Development
|
|
133
166
|
|
|
134
167
|
```bash
|
package/dist/cli.mjs
CHANGED
|
@@ -127,7 +127,7 @@ const CommonCommandOptionsSchema = z.object({
|
|
|
127
127
|
const PrismaSetupOptionsSchema = z.object({
|
|
128
128
|
provider: DatabaseProviderSchema.optional().describe("Database provider"),
|
|
129
129
|
packageManager: PackageManagerSchema.optional().describe("Package manager used for dependency installation"),
|
|
130
|
-
prismaPostgres: z.boolean().optional().describe("
|
|
130
|
+
prismaPostgres: z.boolean().optional().describe("Use Prisma Postgres when provider is postgresql"),
|
|
131
131
|
databaseUrl: DatabaseUrlSchema.optional().describe("DATABASE_URL value"),
|
|
132
132
|
install: z.boolean().optional().describe("Install dependencies with selected package manager"),
|
|
133
133
|
generate: z.boolean().optional().describe("Generate Prisma Client after scaffolding"),
|
|
@@ -141,8 +141,18 @@ const CreateScaffoldOptionsSchema = z.object({
|
|
|
141
141
|
skills: z.boolean().optional().describe("Enable skills addon"),
|
|
142
142
|
mcp: z.boolean().optional().describe("Enable MCP addon"),
|
|
143
143
|
extension: z.boolean().optional().describe("Enable extension addon"),
|
|
144
|
+
deploy: z.boolean().optional().describe("Deploy the scaffolded project to Prisma Compute"),
|
|
144
145
|
force: z.boolean().optional().describe("Allow scaffolding into a non-empty target directory")
|
|
145
146
|
});
|
|
147
|
+
const COMPUTE_DEPLOYABLE_TEMPLATES = new Set([
|
|
148
|
+
"hono",
|
|
149
|
+
"elysia",
|
|
150
|
+
"next",
|
|
151
|
+
"tanstack-start"
|
|
152
|
+
]);
|
|
153
|
+
function isComputeDeployableTemplate(template) {
|
|
154
|
+
return COMPUTE_DEPLOYABLE_TEMPLATES.has(template);
|
|
155
|
+
}
|
|
146
156
|
const CreateCommandInputSchema = PrismaSetupCommandInputSchema.extend(CreateScaffoldOptionsSchema.shape);
|
|
147
157
|
|
|
148
158
|
//#endregion
|
|
@@ -340,11 +350,6 @@ function getPackageExecutionCommand(packageManager, commandArgs) {
|
|
|
340
350
|
return [execution.command, ...execution.args].join(" ");
|
|
341
351
|
}
|
|
342
352
|
function getPrismaCliArgs(packageManager, prismaArgs) {
|
|
343
|
-
if (packageManager === "bun") return getPackageExecutionArgs(packageManager, [
|
|
344
|
-
"--bun",
|
|
345
|
-
"prisma",
|
|
346
|
-
...prismaArgs
|
|
347
|
-
]);
|
|
348
353
|
if (packageManager === "deno") return {
|
|
349
354
|
command: "deno",
|
|
350
355
|
args: [
|
|
@@ -357,7 +362,7 @@ function getPrismaCliArgs(packageManager, prismaArgs) {
|
|
|
357
362
|
};
|
|
358
363
|
return getPackageExecutionArgs(packageManager, ["prisma", ...prismaArgs]);
|
|
359
364
|
}
|
|
360
|
-
function getPrismaCliCommand(packageManager, prismaArgs) {
|
|
365
|
+
function getPrismaCliCommand$1(packageManager, prismaArgs) {
|
|
361
366
|
const execution = getPrismaCliArgs(packageManager, prismaArgs);
|
|
362
367
|
return [execution.command, ...execution.args].join(" ");
|
|
363
368
|
}
|
|
@@ -460,12 +465,13 @@ async function renderTemplateTree(opts) {
|
|
|
460
465
|
function getCreateTemplateDir(template) {
|
|
461
466
|
return resolveTemplatesDir(`templates/create/${template}`);
|
|
462
467
|
}
|
|
463
|
-
function createTemplateContext(projectName, provider, schemaPreset, packageManager) {
|
|
468
|
+
function createTemplateContext(projectName, provider, schemaPreset, packageManager, compute) {
|
|
464
469
|
return {
|
|
465
470
|
projectName,
|
|
466
471
|
provider,
|
|
467
472
|
schemaPreset,
|
|
468
|
-
packageManager
|
|
473
|
+
packageManager,
|
|
474
|
+
compute
|
|
469
475
|
};
|
|
470
476
|
}
|
|
471
477
|
async function scaffoldCreateTemplate(opts) {
|
|
@@ -473,7 +479,7 @@ async function scaffoldCreateTemplate(opts) {
|
|
|
473
479
|
await renderTemplateTree({
|
|
474
480
|
templateRoot: getCreateTemplateDir(template),
|
|
475
481
|
outputDir: projectDir,
|
|
476
|
-
context: createTemplateContext(projectName, provider, schemaPreset, packageManager)
|
|
482
|
+
context: createTemplateContext(projectName, provider, schemaPreset, packageManager, opts.compute === true)
|
|
477
483
|
});
|
|
478
484
|
}
|
|
479
485
|
|
|
@@ -813,7 +819,7 @@ function getCommandErrorMessage(error) {
|
|
|
813
819
|
}
|
|
814
820
|
return error instanceof Error ? error.message : String(error);
|
|
815
821
|
}
|
|
816
|
-
async function
|
|
822
|
+
async function collectPrismaSetupInitialContext(input, options = {}) {
|
|
817
823
|
const projectDir = path.resolve(options.projectDir ?? process.cwd());
|
|
818
824
|
const useDefaults = input.yes === true;
|
|
819
825
|
const verbose = input.verbose === true;
|
|
@@ -822,19 +828,11 @@ async function collectPrismaSetupContext(input, options = {}) {
|
|
|
822
828
|
if (!databaseProvider) return;
|
|
823
829
|
const schemaPreset = input.schemaPreset ?? options.defaultSchemaPreset ?? DEFAULT_SCHEMA_PRESET$1;
|
|
824
830
|
const databaseUrl = input.databaseUrl;
|
|
825
|
-
let shouldUsePrismaPostgres = false;
|
|
826
|
-
if (databaseProvider === "postgresql" && !databaseUrl) {
|
|
827
|
-
const prismaPostgresChoice = input.prismaPostgres ?? (useDefaults ? DEFAULT_PRISMA_POSTGRES : await promptForPrismaPostgres());
|
|
828
|
-
if (prismaPostgresChoice === void 0) return;
|
|
829
|
-
shouldUsePrismaPostgres = prismaPostgresChoice;
|
|
830
|
-
}
|
|
831
831
|
const detectedPackageManager = await detectPackageManager(projectDir);
|
|
832
832
|
const packageManager = input.packageManager ?? (useDefaults ? detectedPackageManager : await promptForPackageManager(detectedPackageManager));
|
|
833
833
|
if (!packageManager) return;
|
|
834
834
|
const shouldInstall = input.install ?? (useDefaults ? DEFAULT_INSTALL : await promptForDependencyInstall(packageManager));
|
|
835
835
|
if (shouldInstall === void 0) return;
|
|
836
|
-
const shouldMigrateAndSeed = !(shouldInstall && shouldGenerate) ? false : input.migrateAndSeed ?? (useDefaults ? DEFAULT_MIGRATE_AND_SEED : await promptForMigrateAndSeed());
|
|
837
|
-
if (shouldMigrateAndSeed === void 0) return;
|
|
838
836
|
return {
|
|
839
837
|
projectDir,
|
|
840
838
|
verbose,
|
|
@@ -842,9 +840,24 @@ async function collectPrismaSetupContext(input, options = {}) {
|
|
|
842
840
|
databaseProvider,
|
|
843
841
|
schemaPreset,
|
|
844
842
|
databaseUrl,
|
|
845
|
-
shouldUsePrismaPostgres,
|
|
846
843
|
packageManager,
|
|
847
|
-
shouldInstall
|
|
844
|
+
shouldInstall
|
|
845
|
+
};
|
|
846
|
+
}
|
|
847
|
+
async function completePrismaSetupContext(input, context, options = {}) {
|
|
848
|
+
const useDefaults = input.yes === true;
|
|
849
|
+
let shouldUsePrismaPostgres = false;
|
|
850
|
+
const shouldUseComputePostgres = context.databaseProvider === "postgresql" && !context.databaseUrl && options.useComputePostgres === true;
|
|
851
|
+
if (context.databaseProvider === "postgresql" && !context.databaseUrl && !shouldUseComputePostgres) {
|
|
852
|
+
const prismaPostgresChoice = input.prismaPostgres ?? (useDefaults ? DEFAULT_PRISMA_POSTGRES : await promptForPrismaPostgres());
|
|
853
|
+
if (prismaPostgresChoice === void 0) return;
|
|
854
|
+
shouldUsePrismaPostgres = prismaPostgresChoice;
|
|
855
|
+
}
|
|
856
|
+
const shouldMigrateAndSeed = !(context.shouldInstall && context.shouldGenerate && !(shouldUseComputePostgres && options.skipMigrateAndSeedPrompt)) ? false : input.migrateAndSeed ?? (useDefaults ? DEFAULT_MIGRATE_AND_SEED : await promptForMigrateAndSeed());
|
|
857
|
+
if (shouldMigrateAndSeed === void 0) return;
|
|
858
|
+
return {
|
|
859
|
+
...context,
|
|
860
|
+
shouldUsePrismaPostgres,
|
|
848
861
|
shouldMigrateAndSeed
|
|
849
862
|
};
|
|
850
863
|
}
|
|
@@ -1038,7 +1051,7 @@ async function finalizePrismaFilesForContext(context, projectDir, provisionResul
|
|
|
1038
1051
|
async function generatePrismaClientForContext(context, projectDir) {
|
|
1039
1052
|
const prismaProjectDir = await resolvePrismaProjectDir(projectDir);
|
|
1040
1053
|
if (!context.shouldGenerate) return { didGenerateClient: false };
|
|
1041
|
-
const generateCommand = getPrismaCliCommand(context.packageManager, ["generate"]);
|
|
1054
|
+
const generateCommand = getPrismaCliCommand$1(context.packageManager, ["generate"]);
|
|
1042
1055
|
if (context.verbose) log.step(`Running ${generateCommand}`);
|
|
1043
1056
|
const generateSpinner = context.verbose ? void 0 : spinner();
|
|
1044
1057
|
generateSpinner?.start("Generating Prisma Client...");
|
|
@@ -1072,33 +1085,37 @@ function buildNextStepsForContext(opts) {
|
|
|
1072
1085
|
const nextSteps = [...options.prependNextSteps ?? []];
|
|
1073
1086
|
if (!context.shouldInstall) nextSteps.push(`- ${getInstallCommand(context.packageManager)}`);
|
|
1074
1087
|
if (!didGenerateClient || !context.shouldGenerate) nextSteps.push(`- ${getRunScriptCommand(context.packageManager, "db:generate")}`);
|
|
1075
|
-
if (!didMigrate) nextSteps.push(`- ${getRunScriptCommand(context.packageManager, "db:migrate")}`);
|
|
1076
|
-
if (!didSeed) nextSteps.push(`- ${getRunScriptCommand(context.packageManager, "db:seed")}`);
|
|
1088
|
+
if (options.includeMigrationAndSeedNextSteps !== false && !didMigrate) nextSteps.push(`- ${getRunScriptCommand(context.packageManager, "db:migrate")}`);
|
|
1089
|
+
if (options.includeMigrationAndSeedNextSteps !== false && !didSeed) nextSteps.push(`- ${getRunScriptCommand(context.packageManager, "db:seed")}`);
|
|
1077
1090
|
if (options.includeDevNextStep) nextSteps.push(`- ${getRunScriptCommand(context.packageManager, "dev")}`);
|
|
1078
1091
|
return nextSteps;
|
|
1079
1092
|
}
|
|
1080
1093
|
async function executePrismaSetupContext(context, options = {}) {
|
|
1081
1094
|
const projectDir = path.resolve(options.projectDir ?? context.projectDir);
|
|
1082
1095
|
const provisionResult = await provisionPrismaPostgresIfNeeded(context, projectDir);
|
|
1083
|
-
if (!provisionResult) return false;
|
|
1084
|
-
if (!await writeDependenciesForContext(context, projectDir)) return false;
|
|
1085
|
-
if (!await installDependenciesForContext(context, projectDir)) return false;
|
|
1086
|
-
if (!await finalizePrismaFilesForContext(context, projectDir, provisionResult)) return false;
|
|
1096
|
+
if (!provisionResult) return { ok: false };
|
|
1097
|
+
if (!await writeDependenciesForContext(context, projectDir)) return { ok: false };
|
|
1098
|
+
if (!await installDependenciesForContext(context, projectDir)) return { ok: false };
|
|
1099
|
+
if (!await finalizePrismaFilesForContext(context, projectDir, provisionResult)) return { ok: false };
|
|
1100
|
+
const databaseUrl = provisionResult.databaseUrl ?? context.databaseUrl ?? getDefaultDatabaseUrl(context.databaseProvider);
|
|
1087
1101
|
const generateResult = await generatePrismaClientForContext(context, projectDir);
|
|
1088
|
-
const migrateAndSeedResult = await migrateAndSeedIfRequested(context, projectDir, {
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
context,
|
|
1092
|
-
options,
|
|
1093
|
-
didGenerateClient: generateResult.didGenerateClient,
|
|
1094
|
-
didMigrate: migrateAndSeedResult.didMigrate,
|
|
1095
|
-
didSeed: migrateAndSeedResult.didSeed
|
|
1102
|
+
const migrateAndSeedResult = await migrateAndSeedIfRequested(context, projectDir, {
|
|
1103
|
+
databaseUrl,
|
|
1104
|
+
didGenerateClient: generateResult.didGenerateClient
|
|
1096
1105
|
});
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1106
|
+
const warningLines = buildWarningLines(provisionResult.warning, generateResult.warning, migrateAndSeedResult.warning);
|
|
1107
|
+
return {
|
|
1108
|
+
ok: true,
|
|
1109
|
+
nextSteps: buildNextStepsForContext({
|
|
1110
|
+
context,
|
|
1111
|
+
options,
|
|
1112
|
+
didGenerateClient: generateResult.didGenerateClient,
|
|
1113
|
+
didMigrate: migrateAndSeedResult.didMigrate,
|
|
1114
|
+
didSeed: migrateAndSeedResult.didSeed
|
|
1115
|
+
}),
|
|
1116
|
+
warningSection: warningLines.length > 0 ? `\n\n${warningLines.join("\n")}` : "",
|
|
1117
|
+
databaseUrl: provisionResult.databaseUrl ?? context.databaseUrl
|
|
1118
|
+
};
|
|
1102
1119
|
}
|
|
1103
1120
|
async function migrateAndSeedIfRequested(context, projectDir, options) {
|
|
1104
1121
|
const prismaProjectDir = await resolvePrismaProjectDir(projectDir);
|
|
@@ -1111,6 +1128,11 @@ async function migrateAndSeedIfRequested(context, projectDir, options) {
|
|
|
1111
1128
|
didSeed: false,
|
|
1112
1129
|
warning: "Skipped migrate + seed because the Prisma Client was not generated."
|
|
1113
1130
|
};
|
|
1131
|
+
if (!options.databaseUrl) return {
|
|
1132
|
+
didMigrate: false,
|
|
1133
|
+
didSeed: false,
|
|
1134
|
+
warning: "Skipped migrate + seed because no DATABASE_URL is available."
|
|
1135
|
+
};
|
|
1114
1136
|
const migrateInvocation = getPrismaCliArgs(context.packageManager, [
|
|
1115
1137
|
"migrate",
|
|
1116
1138
|
"dev",
|
|
@@ -1130,7 +1152,7 @@ async function migrateAndSeedIfRequested(context, projectDir, options) {
|
|
|
1130
1152
|
migrateSpinner.stop("Initial migration applied.");
|
|
1131
1153
|
didMigrate = true;
|
|
1132
1154
|
} catch (error) {
|
|
1133
|
-
migrateSpinner.
|
|
1155
|
+
migrateSpinner.stop(`Migration failed${error instanceof Error ? `: ${error.message}` : "."}`);
|
|
1134
1156
|
return {
|
|
1135
1157
|
didMigrate: false,
|
|
1136
1158
|
didSeed: false,
|
|
@@ -1148,7 +1170,7 @@ async function migrateAndSeedIfRequested(context, projectDir, options) {
|
|
|
1148
1170
|
seedSpinner.stop("Database seeded.");
|
|
1149
1171
|
didSeed = true;
|
|
1150
1172
|
} catch (error) {
|
|
1151
|
-
seedSpinner.
|
|
1173
|
+
seedSpinner.stop(`Seed failed${error instanceof Error ? `: ${error.message}` : "."}`);
|
|
1152
1174
|
return {
|
|
1153
1175
|
didMigrate,
|
|
1154
1176
|
didSeed: false,
|
|
@@ -1689,23 +1711,295 @@ async function executeCreateAddonSetupContext(params) {
|
|
|
1689
1711
|
addonSpinner.stop("Add-ons applied.");
|
|
1690
1712
|
}
|
|
1691
1713
|
|
|
1714
|
+
//#endregion
|
|
1715
|
+
//#region src/tasks/deploy-to-compute.ts
|
|
1716
|
+
const PRISMA_CLI_PACKAGE = "@prisma/cli@latest";
|
|
1717
|
+
const DEPLOY_OPTIONS_BY_TEMPLATE = {
|
|
1718
|
+
hono: {
|
|
1719
|
+
framework: "hono",
|
|
1720
|
+
httpPort: 8080
|
|
1721
|
+
},
|
|
1722
|
+
elysia: {
|
|
1723
|
+
framework: "bun",
|
|
1724
|
+
httpPort: 8080,
|
|
1725
|
+
requiresExplicitFramework: true
|
|
1726
|
+
},
|
|
1727
|
+
next: { framework: "nextjs" },
|
|
1728
|
+
"tanstack-start": { framework: "tanstack-start" }
|
|
1729
|
+
};
|
|
1730
|
+
function getPrismaCliCommand(packageManager) {
|
|
1731
|
+
return getPackageExecutionCommand(getPrismaCliExecutionPackageManager(packageManager), [PRISMA_CLI_PACKAGE]);
|
|
1732
|
+
}
|
|
1733
|
+
function getPrismaCliAppDeployCommand(packageManager) {
|
|
1734
|
+
return getPackageExecutionCommand(getPrismaCliExecutionPackageManager(packageManager), [
|
|
1735
|
+
PRISMA_CLI_PACKAGE,
|
|
1736
|
+
"app",
|
|
1737
|
+
"deploy"
|
|
1738
|
+
]);
|
|
1739
|
+
}
|
|
1740
|
+
function getComputeDeployScriptMap(context) {
|
|
1741
|
+
const deployArgs = [
|
|
1742
|
+
"--prod",
|
|
1743
|
+
"--yes",
|
|
1744
|
+
"--env",
|
|
1745
|
+
".env",
|
|
1746
|
+
...getComputeDeployRuntimeArgs(context)
|
|
1747
|
+
];
|
|
1748
|
+
const deployCommand = [getPrismaCliAppDeployCommand(context.packageManager), ...deployArgs].join(" ");
|
|
1749
|
+
return { "compute:deploy": deployCommand };
|
|
1750
|
+
}
|
|
1751
|
+
function getComputeDeployRuntimeArgs(context) {
|
|
1752
|
+
return [...context.requiresExplicitFramework ? ["--framework", context.framework] : [], ...context.httpPort ? ["--http-port", String(context.httpPort)] : []];
|
|
1753
|
+
}
|
|
1754
|
+
function runPrismaCli(packageManager, args, options = {}) {
|
|
1755
|
+
const execution = getPackageExecutionArgs(getPrismaCliExecutionPackageManager(packageManager), [PRISMA_CLI_PACKAGE, ...args]);
|
|
1756
|
+
return execa(execution.command, execution.args, options);
|
|
1757
|
+
}
|
|
1758
|
+
function getPrismaCliExecutionPackageManager(packageManager) {
|
|
1759
|
+
return packageManager === "deno" ? "npm" : packageManager;
|
|
1760
|
+
}
|
|
1761
|
+
async function isAuthenticated(packageManager) {
|
|
1762
|
+
try {
|
|
1763
|
+
await runPrismaCli(packageManager, [
|
|
1764
|
+
"project",
|
|
1765
|
+
"list",
|
|
1766
|
+
"--json"
|
|
1767
|
+
], { stdio: "pipe" });
|
|
1768
|
+
return true;
|
|
1769
|
+
} catch {
|
|
1770
|
+
return false;
|
|
1771
|
+
}
|
|
1772
|
+
}
|
|
1773
|
+
async function ensurePrismaCliAvailable(packageManager) {
|
|
1774
|
+
try {
|
|
1775
|
+
await runPrismaCli(packageManager, ["--help"], { stdio: "pipe" });
|
|
1776
|
+
return true;
|
|
1777
|
+
} catch (error) {
|
|
1778
|
+
const command = getPrismaCliCommand(packageManager);
|
|
1779
|
+
if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") {
|
|
1780
|
+
log.warn(`Could not find the selected package manager. Re-run ${command} manually.`);
|
|
1781
|
+
return false;
|
|
1782
|
+
}
|
|
1783
|
+
log.warn(`Could not run ${command}${error instanceof Error ? `: ${redactSecrets(error.message)}` : "."}`);
|
|
1784
|
+
return false;
|
|
1785
|
+
}
|
|
1786
|
+
}
|
|
1787
|
+
async function collectComputeDeployContext(input, options) {
|
|
1788
|
+
if (!isComputeDeployableTemplate(options.template)) return null;
|
|
1789
|
+
if (input.deploy === false) return null;
|
|
1790
|
+
let wantsDeploy;
|
|
1791
|
+
if (input.deploy === true) wantsDeploy = true;
|
|
1792
|
+
else if (options.useDefaults) return null;
|
|
1793
|
+
else {
|
|
1794
|
+
const confirmed = await confirm({
|
|
1795
|
+
message: "Deploy to Prisma Compute now?",
|
|
1796
|
+
initialValue: false
|
|
1797
|
+
});
|
|
1798
|
+
if (isCancel(confirmed)) {
|
|
1799
|
+
cancel("Operation cancelled.");
|
|
1800
|
+
return;
|
|
1801
|
+
}
|
|
1802
|
+
wantsDeploy = confirmed;
|
|
1803
|
+
}
|
|
1804
|
+
if (!wantsDeploy) return null;
|
|
1805
|
+
if (!await ensurePrismaCliAvailable(options.packageManager)) {
|
|
1806
|
+
if (input.deploy === true) throw createExplicitDeployError("the Prisma CLI is not available");
|
|
1807
|
+
return null;
|
|
1808
|
+
}
|
|
1809
|
+
if (!await isAuthenticated(options.packageManager)) {
|
|
1810
|
+
log.info("Authenticating with Prisma...");
|
|
1811
|
+
try {
|
|
1812
|
+
await runPrismaCli(options.packageManager, ["auth", "login"], { stdio: "inherit" });
|
|
1813
|
+
} catch (error) {
|
|
1814
|
+
log.warn(`Prisma login was not completed${error instanceof Error ? `: ${redactSecrets(error.message)}` : "."}`);
|
|
1815
|
+
if (input.deploy === true) throw createExplicitDeployError("authentication failed", error);
|
|
1816
|
+
return null;
|
|
1817
|
+
}
|
|
1818
|
+
}
|
|
1819
|
+
const deployOptions = DEPLOY_OPTIONS_BY_TEMPLATE[options.template];
|
|
1820
|
+
if (!deployOptions) {
|
|
1821
|
+
if (input.deploy === true) throw createExplicitDeployError(`${options.template} is not supported by prisma app deploy yet`);
|
|
1822
|
+
return null;
|
|
1823
|
+
}
|
|
1824
|
+
return {
|
|
1825
|
+
template: options.template,
|
|
1826
|
+
packageManager: options.packageManager,
|
|
1827
|
+
createProjectName: options.defaultServiceName,
|
|
1828
|
+
framework: deployOptions.framework,
|
|
1829
|
+
httpPort: deployOptions.httpPort,
|
|
1830
|
+
requiresExplicitFramework: deployOptions.requiresExplicitFramework
|
|
1831
|
+
};
|
|
1832
|
+
}
|
|
1833
|
+
function redactSecrets(message) {
|
|
1834
|
+
return message.replace(/(['"])([A-Z0-9_]*(?:DATABASE_URL|DIRECT_URL|TOKEN|SECRET|PASSWORD|API_KEY|PRIVATE_KEY|ACCESS_KEY)[A-Z0-9_]*=)(.*?)\1/g, "$1$2<redacted>$1").replace(/\b([A-Z0-9_]*(?:DATABASE_URL|DIRECT_URL|TOKEN|SECRET|PASSWORD|API_KEY|PRIVATE_KEY|ACCESS_KEY)[A-Z0-9_]*=)[^\s]+/g, "$1<redacted>");
|
|
1835
|
+
}
|
|
1836
|
+
function parseJson(stdout) {
|
|
1837
|
+
if (typeof stdout !== "string" || stdout.trim().length === 0) return null;
|
|
1838
|
+
try {
|
|
1839
|
+
return JSON.parse(stdout);
|
|
1840
|
+
} catch {
|
|
1841
|
+
return null;
|
|
1842
|
+
}
|
|
1843
|
+
}
|
|
1844
|
+
function getJsonErrorMessage(error, fallback) {
|
|
1845
|
+
return error?.summary ?? error?.message ?? error?.name ?? fallback;
|
|
1846
|
+
}
|
|
1847
|
+
function getErrorMessage(error) {
|
|
1848
|
+
return redactSecrets(error instanceof Error ? error.message : String(error));
|
|
1849
|
+
}
|
|
1850
|
+
function createDeployError(message) {
|
|
1851
|
+
return new Error(redactSecrets(message ?? "unknown error"));
|
|
1852
|
+
}
|
|
1853
|
+
function createExplicitDeployError(reason, error) {
|
|
1854
|
+
const detail = error instanceof Error ? `: ${redactSecrets(error.message)}` : "";
|
|
1855
|
+
return /* @__PURE__ */ new Error(`Deploy requested but ${reason}${detail}`);
|
|
1856
|
+
}
|
|
1857
|
+
async function runPrismaCliJson(params) {
|
|
1858
|
+
try {
|
|
1859
|
+
const { stdout, exitCode } = await runPrismaCli(params.packageManager, params.args, {
|
|
1860
|
+
cwd: params.cwd,
|
|
1861
|
+
reject: false,
|
|
1862
|
+
stdio: [
|
|
1863
|
+
"ignore",
|
|
1864
|
+
"pipe",
|
|
1865
|
+
"pipe"
|
|
1866
|
+
]
|
|
1867
|
+
});
|
|
1868
|
+
const parsed = parseJson(stdout);
|
|
1869
|
+
if (!parsed) return {
|
|
1870
|
+
ok: false,
|
|
1871
|
+
error: new Error(params.invalidOutputError)
|
|
1872
|
+
};
|
|
1873
|
+
if (exitCode !== 0 || !parsed.ok) return {
|
|
1874
|
+
ok: false,
|
|
1875
|
+
error: createDeployError(parsed.ok ? params.fallbackError : getJsonErrorMessage(parsed.error, params.fallbackError))
|
|
1876
|
+
};
|
|
1877
|
+
return {
|
|
1878
|
+
ok: true,
|
|
1879
|
+
result: parsed.result
|
|
1880
|
+
};
|
|
1881
|
+
} catch (error) {
|
|
1882
|
+
return {
|
|
1883
|
+
ok: false,
|
|
1884
|
+
error: new Error(getErrorMessage(error))
|
|
1885
|
+
};
|
|
1886
|
+
}
|
|
1887
|
+
}
|
|
1888
|
+
function toComputeDeployResult(data) {
|
|
1889
|
+
return {
|
|
1890
|
+
appUrl: data.deployment.url,
|
|
1891
|
+
appId: data.app.id,
|
|
1892
|
+
appName: data.app.name,
|
|
1893
|
+
deploymentId: data.deployment.id,
|
|
1894
|
+
projectId: data.project.id,
|
|
1895
|
+
projectName: data.project.name,
|
|
1896
|
+
branchName: data.branch.name,
|
|
1897
|
+
database: data.branchDatabase?.database
|
|
1898
|
+
};
|
|
1899
|
+
}
|
|
1900
|
+
async function executeComputeDatabaseSetup(params) {
|
|
1901
|
+
const projectSpinner = spinner();
|
|
1902
|
+
projectSpinner.start("Creating Prisma Compute project...");
|
|
1903
|
+
const projectResult = await runPrismaCliJson({
|
|
1904
|
+
packageManager: params.context.packageManager,
|
|
1905
|
+
args: [
|
|
1906
|
+
"project",
|
|
1907
|
+
"create",
|
|
1908
|
+
params.context.createProjectName,
|
|
1909
|
+
"--json"
|
|
1910
|
+
],
|
|
1911
|
+
cwd: params.projectDir,
|
|
1912
|
+
fallbackError: "Prisma project create failed.",
|
|
1913
|
+
invalidOutputError: "Invalid prisma project create output"
|
|
1914
|
+
});
|
|
1915
|
+
if (!projectResult.ok) {
|
|
1916
|
+
projectSpinner.error(`Project creation failed: ${projectResult.error.message}`);
|
|
1917
|
+
return {
|
|
1918
|
+
ok: false,
|
|
1919
|
+
cancelled: false,
|
|
1920
|
+
error: projectResult.error
|
|
1921
|
+
};
|
|
1922
|
+
}
|
|
1923
|
+
projectSpinner.stop("Prisma Compute project created.");
|
|
1924
|
+
const databaseSpinner = spinner();
|
|
1925
|
+
databaseSpinner.start("Creating Prisma Postgres database...");
|
|
1926
|
+
const databaseResult = await runPrismaCliJson({
|
|
1927
|
+
packageManager: params.context.packageManager,
|
|
1928
|
+
args: [
|
|
1929
|
+
"database",
|
|
1930
|
+
"create",
|
|
1931
|
+
"main",
|
|
1932
|
+
"--branch",
|
|
1933
|
+
"main",
|
|
1934
|
+
"--json"
|
|
1935
|
+
],
|
|
1936
|
+
cwd: params.projectDir,
|
|
1937
|
+
fallbackError: "Prisma database create failed.",
|
|
1938
|
+
invalidOutputError: "Invalid prisma database create output"
|
|
1939
|
+
});
|
|
1940
|
+
if (!databaseResult.ok) {
|
|
1941
|
+
databaseSpinner.error(`Database creation failed: ${databaseResult.error.message}`);
|
|
1942
|
+
return {
|
|
1943
|
+
ok: false,
|
|
1944
|
+
cancelled: false,
|
|
1945
|
+
error: databaseResult.error
|
|
1946
|
+
};
|
|
1947
|
+
}
|
|
1948
|
+
databaseSpinner.stop("Prisma Postgres database created.");
|
|
1949
|
+
return {
|
|
1950
|
+
ok: true,
|
|
1951
|
+
result: {
|
|
1952
|
+
databaseUrl: databaseResult.result.connectionString,
|
|
1953
|
+
projectId: databaseResult.result.projectId,
|
|
1954
|
+
projectName: databaseResult.result.projectName,
|
|
1955
|
+
database: databaseResult.result.database
|
|
1956
|
+
}
|
|
1957
|
+
};
|
|
1958
|
+
}
|
|
1959
|
+
async function executeComputeDeployContext(params) {
|
|
1960
|
+
const deploySpinner = spinner();
|
|
1961
|
+
deploySpinner.start("Deploying to Prisma Compute...");
|
|
1962
|
+
const args = [
|
|
1963
|
+
"app",
|
|
1964
|
+
"deploy",
|
|
1965
|
+
"--json",
|
|
1966
|
+
"--yes",
|
|
1967
|
+
"--prod",
|
|
1968
|
+
"--env",
|
|
1969
|
+
".env",
|
|
1970
|
+
...params.createProject === false ? [] : ["--create-project", params.context.createProjectName],
|
|
1971
|
+
...getComputeDeployRuntimeArgs(params.context)
|
|
1972
|
+
];
|
|
1973
|
+
const deployResult = await runPrismaCliJson({
|
|
1974
|
+
packageManager: params.context.packageManager,
|
|
1975
|
+
args,
|
|
1976
|
+
cwd: params.projectDir,
|
|
1977
|
+
fallbackError: "Prisma app deploy failed.",
|
|
1978
|
+
invalidOutputError: "Invalid prisma app deploy output"
|
|
1979
|
+
});
|
|
1980
|
+
if (!deployResult.ok) {
|
|
1981
|
+
deploySpinner.error(`Deploy failed: ${deployResult.error.message}`);
|
|
1982
|
+
return {
|
|
1983
|
+
ok: false,
|
|
1984
|
+
cancelled: false,
|
|
1985
|
+
error: deployResult.error
|
|
1986
|
+
};
|
|
1987
|
+
}
|
|
1988
|
+
deploySpinner.stop("Deployed to Prisma Compute.");
|
|
1989
|
+
return {
|
|
1990
|
+
ok: true,
|
|
1991
|
+
result: toComputeDeployResult(deployResult.result)
|
|
1992
|
+
};
|
|
1993
|
+
}
|
|
1994
|
+
|
|
1692
1995
|
//#endregion
|
|
1693
1996
|
//#region src/telemetry/client.ts
|
|
1694
|
-
const TELEMETRY_API_KEY = "
|
|
1997
|
+
const TELEMETRY_API_KEY = "";
|
|
1695
1998
|
const TELEMETRY_HOST = "https://us.i.posthog.com";
|
|
1696
1999
|
const TELEMETRY_CONFIG_FILE = "telemetry.json";
|
|
1697
2000
|
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;
|
|
1698
|
-
function isTruthyEnvValue(value) {
|
|
1699
|
-
return [
|
|
1700
|
-
"1",
|
|
1701
|
-
"true",
|
|
1702
|
-
"yes",
|
|
1703
|
-
"on"
|
|
1704
|
-
].includes(String(value ?? "").trim().toLowerCase());
|
|
1705
|
-
}
|
|
1706
2001
|
function shouldDisableTelemetry() {
|
|
1707
|
-
|
|
1708
|
-
return process.env.CREATE_PRISMA_DISABLE_TELEMETRY !== void 0 || process.env.CREATE_PRISMA_TELEMETRY_DISABLED !== void 0 || process.env.DO_NOT_TRACK !== void 0;
|
|
2002
|
+
return true;
|
|
1709
2003
|
}
|
|
1710
2004
|
function getTelemetryConfigDir() {
|
|
1711
2005
|
if (process.platform === "darwin") return path.join(os.homedir(), "Library", "Application Support", "create-prisma");
|
|
@@ -1727,7 +2021,7 @@ async function getAnonymousId() {
|
|
|
1727
2021
|
}
|
|
1728
2022
|
function getCommonProperties() {
|
|
1729
2023
|
return {
|
|
1730
|
-
"cli-version": "0.
|
|
2024
|
+
"cli-version": "0.5.0-pr.41.123.1",
|
|
1731
2025
|
"node-version": process.version,
|
|
1732
2026
|
platform: process.platform,
|
|
1733
2027
|
arch: process.arch
|
|
@@ -2003,10 +2297,21 @@ async function collectCreateContext(input) {
|
|
|
2003
2297
|
cancel(`Target directory ${formatPathForDisplay(targetDirectory)} is not empty. Use --force to continue.`);
|
|
2004
2298
|
return;
|
|
2005
2299
|
}
|
|
2006
|
-
const
|
|
2300
|
+
const prismaSetupInitialContext = await collectPrismaSetupInitialContext(input, {
|
|
2007
2301
|
projectDir: targetDirectory,
|
|
2008
2302
|
defaultSchemaPreset: DEFAULT_SCHEMA_PRESET
|
|
2009
2303
|
});
|
|
2304
|
+
if (!prismaSetupInitialContext) return;
|
|
2305
|
+
const projectPackageName = toPackageName(path.basename(targetDirectory));
|
|
2306
|
+
const computeDeployContext = await collectComputeDeployContext(input, {
|
|
2307
|
+
template,
|
|
2308
|
+
packageManager: prismaSetupInitialContext.packageManager,
|
|
2309
|
+
useDefaults,
|
|
2310
|
+
defaultServiceName: projectPackageName
|
|
2311
|
+
});
|
|
2312
|
+
if (computeDeployContext === void 0) return;
|
|
2313
|
+
const useComputeDatabase = Boolean(computeDeployContext && prismaSetupInitialContext.databaseProvider === "postgresql" && !prismaSetupInitialContext.databaseUrl && input.prismaPostgres !== false);
|
|
2314
|
+
const prismaSetupContext = await completePrismaSetupContext(input, prismaSetupInitialContext, { useComputePostgres: useComputeDatabase });
|
|
2010
2315
|
if (!prismaSetupContext) return;
|
|
2011
2316
|
const addonSetupContext = await collectCreateAddonSetupContext(input, {
|
|
2012
2317
|
useDefaults,
|
|
@@ -2019,9 +2324,11 @@ async function collectCreateContext(input) {
|
|
|
2019
2324
|
targetPathState,
|
|
2020
2325
|
force,
|
|
2021
2326
|
template,
|
|
2022
|
-
projectPackageName
|
|
2327
|
+
projectPackageName,
|
|
2023
2328
|
prismaSetupContext,
|
|
2024
|
-
addonSetupContext: addonSetupContext ?? void 0
|
|
2329
|
+
addonSetupContext: addonSetupContext ?? void 0,
|
|
2330
|
+
computeDeployContext: computeDeployContext ?? void 0,
|
|
2331
|
+
useComputeDatabase
|
|
2025
2332
|
};
|
|
2026
2333
|
}
|
|
2027
2334
|
async function executeCreateContext(context) {
|
|
@@ -2034,7 +2341,8 @@ async function executeCreateContext(context) {
|
|
|
2034
2341
|
template: context.template,
|
|
2035
2342
|
schemaPreset: context.prismaSetupContext.schemaPreset,
|
|
2036
2343
|
provider: context.prismaSetupContext.databaseProvider,
|
|
2037
|
-
packageManager: context.prismaSetupContext.packageManager
|
|
2344
|
+
packageManager: context.prismaSetupContext.packageManager,
|
|
2345
|
+
compute: Boolean(context.computeDeployContext)
|
|
2038
2346
|
});
|
|
2039
2347
|
scaffoldSpinner.stop("Project files scaffolded.");
|
|
2040
2348
|
} catch (error) {
|
|
@@ -2051,6 +2359,11 @@ async function executeCreateContext(context) {
|
|
|
2051
2359
|
packageManager: context.prismaSetupContext.packageManager,
|
|
2052
2360
|
projectDir: context.targetDirectory
|
|
2053
2361
|
});
|
|
2362
|
+
if (context.computeDeployContext) await addPackageDependency({
|
|
2363
|
+
scripts: getComputeDeployScriptMap(context.computeDeployContext),
|
|
2364
|
+
scriptMode: "if-missing",
|
|
2365
|
+
projectDir: context.targetDirectory
|
|
2366
|
+
});
|
|
2054
2367
|
} catch (error) {
|
|
2055
2368
|
return {
|
|
2056
2369
|
ok: false,
|
|
@@ -2074,12 +2387,38 @@ async function executeCreateContext(context) {
|
|
|
2074
2387
|
error
|
|
2075
2388
|
};
|
|
2076
2389
|
}
|
|
2390
|
+
let computeDatabaseResult;
|
|
2391
|
+
if (context.useComputeDatabase && context.computeDeployContext) try {
|
|
2392
|
+
const result = await executeComputeDatabaseSetup({
|
|
2393
|
+
context: context.computeDeployContext,
|
|
2394
|
+
projectDir: context.targetDirectory
|
|
2395
|
+
});
|
|
2396
|
+
if (!result.ok && !result.cancelled) return {
|
|
2397
|
+
ok: false,
|
|
2398
|
+
stage: "compute_deploy",
|
|
2399
|
+
error: result.error
|
|
2400
|
+
};
|
|
2401
|
+
if (result.ok) computeDatabaseResult = result.result;
|
|
2402
|
+
} catch (error) {
|
|
2403
|
+
return {
|
|
2404
|
+
ok: false,
|
|
2405
|
+
stage: "compute_deploy",
|
|
2406
|
+
error
|
|
2407
|
+
};
|
|
2408
|
+
}
|
|
2409
|
+
const prismaSetupContext = computeDatabaseResult ? {
|
|
2410
|
+
...context.prismaSetupContext,
|
|
2411
|
+
databaseUrl: computeDatabaseResult.databaseUrl,
|
|
2412
|
+
shouldUsePrismaPostgres: false
|
|
2413
|
+
} : context.prismaSetupContext;
|
|
2414
|
+
let prismaResult;
|
|
2077
2415
|
try {
|
|
2078
|
-
|
|
2416
|
+
prismaResult = await executePrismaSetupContext(prismaSetupContext, {
|
|
2079
2417
|
prependNextSteps: nextSteps,
|
|
2080
2418
|
projectDir: context.targetDirectory,
|
|
2081
|
-
includeDevNextStep:
|
|
2082
|
-
})
|
|
2419
|
+
includeDevNextStep: !context.useComputeDatabase
|
|
2420
|
+
});
|
|
2421
|
+
if (!prismaResult.ok) return {
|
|
2083
2422
|
ok: false,
|
|
2084
2423
|
stage: "prisma_setup"
|
|
2085
2424
|
};
|
|
@@ -2090,6 +2429,37 @@ async function executeCreateContext(context) {
|
|
|
2090
2429
|
error
|
|
2091
2430
|
};
|
|
2092
2431
|
}
|
|
2432
|
+
let deployResult;
|
|
2433
|
+
if (context.computeDeployContext) try {
|
|
2434
|
+
const result = await executeComputeDeployContext({
|
|
2435
|
+
context: context.computeDeployContext,
|
|
2436
|
+
projectDir: context.targetDirectory,
|
|
2437
|
+
createProject: !computeDatabaseResult
|
|
2438
|
+
});
|
|
2439
|
+
if (!result.ok && !result.cancelled) return {
|
|
2440
|
+
ok: false,
|
|
2441
|
+
stage: "compute_deploy",
|
|
2442
|
+
error: result.error
|
|
2443
|
+
};
|
|
2444
|
+
if (result.ok) {
|
|
2445
|
+
deployResult = result.result;
|
|
2446
|
+
prismaResult.nextSteps.push(`- ${getRunScriptCommand(context.prismaSetupContext.packageManager, "compute:deploy")}`);
|
|
2447
|
+
}
|
|
2448
|
+
} catch (error) {
|
|
2449
|
+
return {
|
|
2450
|
+
ok: false,
|
|
2451
|
+
stage: "compute_deploy",
|
|
2452
|
+
error
|
|
2453
|
+
};
|
|
2454
|
+
}
|
|
2455
|
+
const summaryLines = [];
|
|
2456
|
+
summaryLines.push(`Setup complete.${prismaResult.warningSection}`);
|
|
2457
|
+
if (deployResult) {
|
|
2458
|
+
const database = computeDatabaseResult?.database ?? deployResult.database;
|
|
2459
|
+
summaryLines.push("", "Deployed to Prisma Compute:", ...deployResult.appUrl ? [`- App URL: ${deployResult.appUrl}`] : [], `- App: ${deployResult.appName} (${deployResult.appId})`, `- Deployment: ${deployResult.deploymentId}`, ...database ? [`- Database: ${database.name} (${database.id})`] : []);
|
|
2460
|
+
}
|
|
2461
|
+
summaryLines.push("", "Next steps:", prismaResult.nextSteps.join("\n"));
|
|
2462
|
+
outro(summaryLines.join("\n"));
|
|
2093
2463
|
return { ok: true };
|
|
2094
2464
|
}
|
|
2095
2465
|
|
package/dist/index.d.mts
CHANGED
|
@@ -248,6 +248,7 @@ declare const CreateCommandInputSchema: z.ZodObject<{
|
|
|
248
248
|
skills: z.ZodOptional<z.ZodBoolean>;
|
|
249
249
|
mcp: z.ZodOptional<z.ZodBoolean>;
|
|
250
250
|
extension: z.ZodOptional<z.ZodBoolean>;
|
|
251
|
+
deploy: z.ZodOptional<z.ZodBoolean>;
|
|
251
252
|
force: z.ZodOptional<z.ZodBoolean>;
|
|
252
253
|
}, z.core.$strip>;
|
|
253
254
|
type CreateCommandInput = z.infer<typeof CreateCommandInputSchema>;
|
|
@@ -295,6 +296,7 @@ declare const router: {
|
|
|
295
296
|
skills: zod.ZodOptional<zod.ZodBoolean>;
|
|
296
297
|
mcp: zod.ZodOptional<zod.ZodBoolean>;
|
|
297
298
|
extension: zod.ZodOptional<zod.ZodBoolean>;
|
|
299
|
+
deploy: zod.ZodOptional<zod.ZodBoolean>;
|
|
298
300
|
force: zod.ZodOptional<zod.ZodBoolean>;
|
|
299
301
|
}, zod_v4_core0.$strip>>, Schema<void, void>, MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
|
|
300
302
|
};
|
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-C0alltck.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.
|
|
7
|
+
const CLI_VERSION = "0.5.0-pr.41.123.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
|
@@ -8,6 +8,9 @@ Generated by `create-prisma` with the Astro template.
|
|
|
8
8
|
- `{{runScriptCommand packageManager "build"}}` - build for production
|
|
9
9
|
- `{{runScriptCommand packageManager "preview"}}` - preview the production build
|
|
10
10
|
- `{{runScriptCommand packageManager "astro"}}` - run Astro CLI commands
|
|
11
|
+
{{#if compute}}
|
|
12
|
+
- `{{runScriptCommand packageManager "compute:deploy"}}` - redeploy to Prisma Compute with environment variables from `.env`
|
|
13
|
+
{{/if}}
|
|
11
14
|
|
|
12
15
|
## Prisma
|
|
13
16
|
|
|
@@ -33,3 +36,11 @@ The starter page queries a basic `User` model in `src/pages/index.astro`, and `s
|
|
|
33
36
|
|
|
34
37
|
The starter page keeps the official Astro minimal structure and points you to `prisma/schema.prisma` for your first model.
|
|
35
38
|
{{/if}}
|
|
39
|
+
{{#if compute}}
|
|
40
|
+
|
|
41
|
+
## Prisma Compute
|
|
42
|
+
|
|
43
|
+
This project includes a Prisma Compute deploy script. Deploys load environment variables from `.env`; if setup created a Prisma Postgres database, its `DATABASE_URL` is already written there.
|
|
44
|
+
|
|
45
|
+
After local changes, run `{{runScriptCommand packageManager "compute:deploy"}}` to redeploy.
|
|
46
|
+
{{/if}}
|
|
@@ -7,6 +7,9 @@ Generated by `create-prisma` with the Elysia template.
|
|
|
7
7
|
- `{{runScriptCommand packageManager "dev"}}` - start local dev server with hot reload
|
|
8
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
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
|
+
{{#if compute}}
|
|
11
|
+
- `{{runScriptCommand packageManager "compute:deploy"}}` - redeploy to Prisma Compute with environment variables from `.env`
|
|
12
|
+
{{/if}}
|
|
10
13
|
|
|
11
14
|
## Prisma
|
|
12
15
|
|
|
@@ -30,3 +33,11 @@ Generated Prisma files are written to `src/generated/prisma`.
|
|
|
30
33
|
|
|
31
34
|
The template includes a basic `User` model, a sample `GET /users` endpoint, and seed data in `prisma/seed.ts`.
|
|
32
35
|
{{/if}}
|
|
36
|
+
{{#if compute}}
|
|
37
|
+
|
|
38
|
+
## Prisma Compute
|
|
39
|
+
|
|
40
|
+
This project includes a Prisma Compute deploy script. Deploys load environment variables from `.env`; if setup created a Prisma Postgres database, its `DATABASE_URL` is already written there.
|
|
41
|
+
|
|
42
|
+
After local changes, run `{{runScriptCommand packageManager "compute:deploy"}}` to redeploy.
|
|
43
|
+
{{/if}}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
"packageManager": "{{packageManagerManifestValue packageManager}}",
|
|
6
6
|
{{/if}}
|
|
7
7
|
"type": "module",
|
|
8
|
+
"main": "src/index.ts",
|
|
8
9
|
"scripts": {
|
|
9
10
|
"dev": "{{runtimeScript packageManager "dev" "src/index.ts" "dist/src/index.js" denoFlags="--unstable-net"}}",
|
|
10
11
|
"build": "{{runtimeScript packageManager "build" "src/index.ts" "dist/src/index.js"}}",
|
|
@@ -13,7 +13,7 @@ import { prisma } from "./lib/prisma{{#if (eq packageManager "deno")}}.ts{{/if}}
|
|
|
13
13
|
const rawPort = ({{#if (eq packageManager "deno")}}Deno.env.get("PORT"){{else}}process.env.PORT{{/if}} ?? "").trim();
|
|
14
14
|
const parsedPort = rawPort.length > 0 ? Number(rawPort) : Number.NaN;
|
|
15
15
|
const port =
|
|
16
|
-
Number.isInteger(parsedPort) && parsedPort >= 0 && parsedPort <= 65535 ? parsedPort :
|
|
16
|
+
Number.isInteger(parsedPort) && parsedPort >= 0 && parsedPort <= 65535 ? parsedPort : 8080;
|
|
17
17
|
|
|
18
18
|
const app = new Elysia({{#if (eq packageManager "deno")}}{{else}}{ adapter: node() }{{/if}})
|
|
19
19
|
.get("/", () => {
|
|
@@ -7,6 +7,9 @@ Generated by `create-prisma` with the Hono template.
|
|
|
7
7
|
- `{{runScriptCommand packageManager "dev"}}` - start local dev server
|
|
8
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
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
|
+
{{#if compute}}
|
|
11
|
+
- `{{runScriptCommand packageManager "compute:deploy"}}` - redeploy to Prisma Compute with environment variables from `.env`
|
|
12
|
+
{{/if}}
|
|
10
13
|
|
|
11
14
|
## Prisma
|
|
12
15
|
|
|
@@ -30,3 +33,11 @@ Generated Prisma files are written to `src/generated/prisma`.
|
|
|
30
33
|
|
|
31
34
|
The template includes a basic `User` model, a sample `GET /users` endpoint, and seed data in `prisma/seed.ts`.
|
|
32
35
|
{{/if}}
|
|
36
|
+
{{#if compute}}
|
|
37
|
+
|
|
38
|
+
## Prisma Compute
|
|
39
|
+
|
|
40
|
+
This project includes a Prisma Compute deploy script. Deploys load environment variables from `.env`; if setup created a Prisma Postgres database, its `DATABASE_URL` is already written there.
|
|
41
|
+
|
|
42
|
+
After local changes, run `{{runScriptCommand packageManager "compute:deploy"}}` to redeploy.
|
|
43
|
+
{{/if}}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
"packageManager": "{{packageManagerManifestValue packageManager}}",
|
|
6
6
|
{{/if}}
|
|
7
7
|
"type": "module",
|
|
8
|
+
"main": "src/index.ts",
|
|
8
9
|
"scripts": {
|
|
9
10
|
"dev": "{{runtimeScript packageManager "dev" "src/index.ts" "dist/src/index.js"}}",
|
|
10
11
|
"build": "{{runtimeScript packageManager "build" "src/index.ts" "dist/src/index.js"}}",
|
|
@@ -31,7 +31,7 @@ app.get("/users", async (c) => {
|
|
|
31
31
|
const rawPort = ({{#if (eq packageManager "deno")}}Deno.env.get("PORT"){{else}}process.env.PORT{{/if}} ?? "").trim();
|
|
32
32
|
const parsedPort = rawPort.length > 0 ? Number(rawPort) : Number.NaN;
|
|
33
33
|
const port =
|
|
34
|
-
Number.isInteger(parsedPort) && parsedPort >= 0 && parsedPort <= 65535 ? parsedPort :
|
|
34
|
+
Number.isInteger(parsedPort) && parsedPort >= 0 && parsedPort <= 65535 ? parsedPort : 8080;
|
|
35
35
|
serve({
|
|
36
36
|
fetch: app.fetch,
|
|
37
37
|
port,
|
|
@@ -7,6 +7,9 @@ Generated by `create-prisma` with the NestJS template.
|
|
|
7
7
|
- `{{runScriptCommand packageManager "dev"}}` - start the Nest dev server with watch mode
|
|
8
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}}compile the app into `dist/`{{/if}}{{/if}}
|
|
9
9
|
- `{{runScriptCommand packageManager "start"}}` - {{#if (eq packageManager "deno")}}run the server directly from `src/main.ts` with Deno{{else}}{{#if (eq packageManager "bun")}}run the server directly from `src/main.ts` with Bun{{else}}run the compiled server from `dist/main.js`{{/if}}{{/if}}
|
|
10
|
+
{{#if compute}}
|
|
11
|
+
- `{{runScriptCommand packageManager "compute:deploy"}}` - redeploy to Prisma Compute with environment variables from `.env`
|
|
12
|
+
{{/if}}
|
|
10
13
|
|
|
11
14
|
## Prisma
|
|
12
15
|
|
|
@@ -30,3 +33,11 @@ Generated Prisma files are written to `src/generated/prisma`.
|
|
|
30
33
|
|
|
31
34
|
The template includes a basic `User` model, a sample `GET /users` endpoint, and seed data in `prisma/seed.ts`.
|
|
32
35
|
{{/if}}
|
|
36
|
+
{{#if compute}}
|
|
37
|
+
|
|
38
|
+
## Prisma Compute
|
|
39
|
+
|
|
40
|
+
This project includes a Prisma Compute deploy script. Deploys load environment variables from `.env`; if setup created a Prisma Postgres database, its `DATABASE_URL` is already written there.
|
|
41
|
+
|
|
42
|
+
After local changes, run `{{runScriptCommand packageManager "compute:deploy"}}` to redeploy.
|
|
43
|
+
{{/if}}
|
|
@@ -7,6 +7,9 @@ Generated by `create-prisma` with the Next.js template.
|
|
|
7
7
|
- `{{runScriptCommand packageManager "dev"}}` - start local dev server
|
|
8
8
|
- `{{runScriptCommand packageManager "build"}}` - production build
|
|
9
9
|
- `{{runScriptCommand packageManager "start"}}` - run production server
|
|
10
|
+
{{#if compute}}
|
|
11
|
+
- `{{runScriptCommand packageManager "compute:deploy"}}` - redeploy to Prisma Compute with environment variables from `.env`
|
|
12
|
+
{{/if}}
|
|
10
13
|
|
|
11
14
|
## Prisma
|
|
12
15
|
|
|
@@ -28,3 +31,11 @@ Database helper scripts are added to `package.json`:
|
|
|
28
31
|
|
|
29
32
|
The starter page in `src/app/page.tsx` reads from a basic `User` model so you can verify queries quickly, and `prisma/seed.ts` inserts starter users.
|
|
30
33
|
{{/if}}
|
|
34
|
+
{{#if compute}}
|
|
35
|
+
|
|
36
|
+
## Prisma Compute
|
|
37
|
+
|
|
38
|
+
This project includes a Prisma Compute deploy script. Deploys load environment variables from `.env`; if setup created a Prisma Postgres database, its `DATABASE_URL` is already written there.
|
|
39
|
+
|
|
40
|
+
After local changes, run `{{runScriptCommand packageManager "compute:deploy"}}` to redeploy.
|
|
41
|
+
{{/if}}
|
|
@@ -8,6 +8,9 @@ Generated by `create-prisma` with the Nuxt template.
|
|
|
8
8
|
- `{{runScriptCommand packageManager "build"}}` - build for production
|
|
9
9
|
- `{{runScriptCommand packageManager "preview"}}` - preview the production build
|
|
10
10
|
- `{{runScriptCommand packageManager "typecheck"}}` - run Nuxt type checks
|
|
11
|
+
{{#if compute}}
|
|
12
|
+
- `{{runScriptCommand packageManager "compute:deploy"}}` - redeploy to Prisma Compute with environment variables from `.env`
|
|
13
|
+
{{/if}}
|
|
11
14
|
|
|
12
15
|
## Prisma
|
|
13
16
|
|
|
@@ -30,3 +33,11 @@ Database helper scripts are added to `package.json`:
|
|
|
30
33
|
|
|
31
34
|
The starter page in `app/pages/index.vue` fetches seeded users from `server/api/users.get.ts`, and `prisma/seed.ts` inserts starter users.
|
|
32
35
|
{{/if}}
|
|
36
|
+
{{#if compute}}
|
|
37
|
+
|
|
38
|
+
## Prisma Compute
|
|
39
|
+
|
|
40
|
+
This project includes a Prisma Compute deploy script. Deploys load environment variables from `.env`; if setup created a Prisma Postgres database, its `DATABASE_URL` is already written there.
|
|
41
|
+
|
|
42
|
+
After local changes, run `{{runScriptCommand packageManager "compute:deploy"}}` to redeploy.
|
|
43
|
+
{{/if}}
|
|
@@ -8,6 +8,9 @@ Generated by `create-prisma` with the SvelteKit template.
|
|
|
8
8
|
- `{{runScriptCommand packageManager "build"}}` - build for production
|
|
9
9
|
- `{{runScriptCommand packageManager "preview"}}` - preview the production build
|
|
10
10
|
- `{{runScriptCommand packageManager "check"}}` - run SvelteKit sync and type checks
|
|
11
|
+
{{#if compute}}
|
|
12
|
+
- `{{runScriptCommand packageManager "compute:deploy"}}` - redeploy to Prisma Compute with environment variables from `.env`
|
|
13
|
+
{{/if}}
|
|
11
14
|
|
|
12
15
|
## Prisma
|
|
13
16
|
|
|
@@ -32,3 +35,11 @@ The starter page loads users in `+page.server.ts`, renders them in `+page.svelte
|
|
|
32
35
|
|
|
33
36
|
The starter page keeps the official SvelteKit minimal structure and points you to `prisma/schema.prisma` for your first model.
|
|
34
37
|
{{/if}}
|
|
38
|
+
{{#if compute}}
|
|
39
|
+
|
|
40
|
+
## Prisma Compute
|
|
41
|
+
|
|
42
|
+
This project includes a Prisma Compute deploy script. Deploys load environment variables from `.env`; if setup created a Prisma Postgres database, its `DATABASE_URL` is already written there.
|
|
43
|
+
|
|
44
|
+
After local changes, run `{{runScriptCommand packageManager "compute:deploy"}}` to redeploy.
|
|
45
|
+
{{/if}}
|
|
@@ -8,6 +8,9 @@ Generated by `create-prisma` with the TanStack Start template.
|
|
|
8
8
|
- `{{runScriptCommand packageManager "build"}}` - build for production
|
|
9
9
|
- `{{runScriptCommand packageManager "preview"}}` - preview the production build
|
|
10
10
|
- `{{runScriptCommand packageManager "typecheck"}}` - run TypeScript checks
|
|
11
|
+
{{#if compute}}
|
|
12
|
+
- `{{runScriptCommand packageManager "compute:deploy"}}` - redeploy to Prisma Compute with environment variables from `.env`
|
|
13
|
+
{{/if}}
|
|
11
14
|
|
|
12
15
|
## Prisma
|
|
13
16
|
|
|
@@ -29,3 +32,11 @@ Database helper scripts are added to `package.json`:
|
|
|
29
32
|
|
|
30
33
|
The home route uses a TanStack Start server function to load users with the Prisma client from `src/lib/prisma.server.ts`, so you can verify a real database query without adding an API route first.
|
|
31
34
|
{{/if}}
|
|
35
|
+
{{#if compute}}
|
|
36
|
+
|
|
37
|
+
## Prisma Compute
|
|
38
|
+
|
|
39
|
+
This project includes a Prisma Compute deploy script. Deploys load environment variables from `.env`; if setup created a Prisma Postgres database, its `DATABASE_URL` is already written there.
|
|
40
|
+
|
|
41
|
+
After local changes, run `{{runScriptCommand packageManager "compute:deploy"}}` to redeploy.
|
|
42
|
+
{{/if}}
|
|
@@ -7,27 +7,27 @@
|
|
|
7
7
|
{{/if}}
|
|
8
8
|
"type": "module",
|
|
9
9
|
"scripts": {
|
|
10
|
-
"dev": "vite dev
|
|
10
|
+
"dev": "vite dev",
|
|
11
11
|
"build": "vite build",
|
|
12
|
+
"start": "node .output/server/index.mjs",
|
|
12
13
|
"preview": "vite preview",
|
|
13
14
|
"typecheck": "tsc --noEmit"
|
|
14
15
|
},
|
|
15
16
|
"dependencies": {
|
|
16
|
-
"@tanstack/react-router": "^1.
|
|
17
|
-
"@tanstack/react-start": "^1.
|
|
17
|
+
"@tanstack/react-router": "^1.167.42",
|
|
18
|
+
"@tanstack/react-start": "^1.167.42",
|
|
19
|
+
"nitro": "^3.0.260415-beta",
|
|
18
20
|
"react": "^19.2.0",
|
|
19
21
|
"react-dom": "^19.2.0"
|
|
20
22
|
},
|
|
21
23
|
"devDependencies": {
|
|
22
|
-
"@tanstack/router-plugin": "^1.132.0",
|
|
23
24
|
"@types/node": "^24.3.0",
|
|
24
25
|
"@types/react": "^19.2.2",
|
|
25
26
|
"@types/react-dom": "^19.2.2",
|
|
26
|
-
"@vitejs/plugin-react": "^
|
|
27
|
+
"@vitejs/plugin-react": "^6.0.0",
|
|
27
28
|
"tsx": "^4.7.1",
|
|
28
29
|
"typescript": "^5.9.3",
|
|
29
|
-
"vite": "^
|
|
30
|
-
"vite-tsconfig-paths": "^5.1.4"
|
|
30
|
+
"vite": "^8.0.8"
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import { defineConfig } from "vite";
|
|
2
2
|
import viteReact from "@vitejs/plugin-react";
|
|
3
3
|
import { tanstackStart } from "@tanstack/react-start/plugin/vite";
|
|
4
|
-
import
|
|
4
|
+
import { nitro } from "nitro/vite";
|
|
5
5
|
|
|
6
6
|
export default defineConfig({
|
|
7
|
-
|
|
7
|
+
resolve: {
|
|
8
|
+
tsconfigPaths: true,
|
|
9
|
+
},
|
|
10
|
+
plugins: [
|
|
11
|
+
tanstackStart(),
|
|
12
|
+
nitro(),
|
|
13
|
+
// react's vite plugin must come after start's vite plugin
|
|
14
|
+
viteReact(),
|
|
15
|
+
],
|
|
8
16
|
});
|
|
@@ -15,6 +15,9 @@ Generated by `create-prisma` with the Turborepo template.
|
|
|
15
15
|
- `{{runScriptCommand packageManager "db:generate"}}` - generate Prisma Client in `packages/db`
|
|
16
16
|
- `{{runScriptCommand packageManager "db:migrate"}}` - create/apply migrations in `packages/db`
|
|
17
17
|
- `{{runScriptCommand packageManager "db:seed"}}` - run seed script in `packages/db`
|
|
18
|
+
{{#if compute}}
|
|
19
|
+
- `{{runScriptCommand packageManager "compute:deploy"}}` - redeploy to Prisma Compute with environment variables from `.env`
|
|
20
|
+
{{/if}}
|
|
18
21
|
|
|
19
22
|
## Prisma
|
|
20
23
|
|
|
@@ -27,3 +30,11 @@ Prisma is scaffolded inside `packages/db`:
|
|
|
27
30
|
- `packages/db/src/generated/prisma`
|
|
28
31
|
|
|
29
32
|
`apps/api/src/index.ts` imports the shared Prisma client from `@repo/db`.
|
|
33
|
+
{{#if compute}}
|
|
34
|
+
|
|
35
|
+
## Prisma Compute
|
|
36
|
+
|
|
37
|
+
This project includes a Prisma Compute deploy script. Deploys load environment variables from `.env`; if setup created a Prisma Postgres database, its `DATABASE_URL` is already written there.
|
|
38
|
+
|
|
39
|
+
After local changes, run `{{runScriptCommand packageManager "compute:deploy"}}` to redeploy.
|
|
40
|
+
{{/if}}
|