create-prisma 0.4.2-pr.34.115.1 → 0.4.2-pr.34.116.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/dist/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import "./create-C6wQ1yYn.mjs";
2
+ import "./create-DRZe4NlG.mjs";
3
3
  import { createCreatePrismaCli } from "./index.mjs";
4
4
 
5
5
  //#region src/cli.ts
@@ -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("Provision Prisma Postgres with create-db when provider is postgresql"),
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"),
@@ -829,7 +829,8 @@ async function collectPrismaSetupContext(input, options = {}) {
829
829
  const schemaPreset = input.schemaPreset ?? options.defaultSchemaPreset ?? DEFAULT_SCHEMA_PRESET$1;
830
830
  const databaseUrl = input.databaseUrl;
831
831
  let shouldUsePrismaPostgres = false;
832
- if (databaseProvider === "postgresql" && !databaseUrl) {
832
+ const shouldUseComputePostgres = databaseProvider === "postgresql" && !databaseUrl && options.skipPrismaPostgresProvisioning === true;
833
+ if (databaseProvider === "postgresql" && !databaseUrl && !shouldUseComputePostgres) {
833
834
  const prismaPostgresChoice = input.prismaPostgres ?? (useDefaults ? DEFAULT_PRISMA_POSTGRES : await promptForPrismaPostgres());
834
835
  if (prismaPostgresChoice === void 0) return;
835
836
  shouldUsePrismaPostgres = prismaPostgresChoice;
@@ -839,7 +840,7 @@ async function collectPrismaSetupContext(input, options = {}) {
839
840
  if (!packageManager) return;
840
841
  const shouldInstall = input.install ?? (useDefaults ? DEFAULT_INSTALL : await promptForDependencyInstall(packageManager));
841
842
  if (shouldInstall === void 0) return;
842
- const shouldMigrateAndSeed = !(shouldInstall && shouldGenerate) ? false : input.migrateAndSeed ?? (useDefaults ? DEFAULT_MIGRATE_AND_SEED : await promptForMigrateAndSeed());
843
+ const shouldMigrateAndSeed = !(shouldInstall && shouldGenerate && !(shouldUseComputePostgres && options.skipMigrateAndSeedPrompt)) ? false : input.migrateAndSeed ?? (useDefaults ? DEFAULT_MIGRATE_AND_SEED : await promptForMigrateAndSeed());
843
844
  if (shouldMigrateAndSeed === void 0) return;
844
845
  return {
845
846
  projectDir,
@@ -1078,8 +1079,8 @@ function buildNextStepsForContext(opts) {
1078
1079
  const nextSteps = [...options.prependNextSteps ?? []];
1079
1080
  if (!context.shouldInstall) nextSteps.push(`- ${getInstallCommand(context.packageManager)}`);
1080
1081
  if (!didGenerateClient || !context.shouldGenerate) nextSteps.push(`- ${getRunScriptCommand(context.packageManager, "db:generate")}`);
1081
- if (!didMigrate) nextSteps.push(`- ${getRunScriptCommand(context.packageManager, "db:migrate")}`);
1082
- if (!didSeed) nextSteps.push(`- ${getRunScriptCommand(context.packageManager, "db:seed")}`);
1082
+ if (options.includeMigrationAndSeedNextSteps !== false && !didMigrate) nextSteps.push(`- ${getRunScriptCommand(context.packageManager, "db:migrate")}`);
1083
+ if (options.includeMigrationAndSeedNextSteps !== false && !didSeed) nextSteps.push(`- ${getRunScriptCommand(context.packageManager, "db:seed")}`);
1083
1084
  if (options.includeDevNextStep) nextSteps.push(`- ${getRunScriptCommand(context.packageManager, "dev")}`);
1084
1085
  return nextSteps;
1085
1086
  }
@@ -1733,10 +1734,7 @@ function getPrismaCliAppDeployCommand(packageManager) {
1733
1734
  function getComputeDeployScriptMap(context) {
1734
1735
  const deployArgs = ["--prod", ...getComputeDeployRuntimeArgs(context)];
1735
1736
  const deployCommand = [getPrismaCliAppDeployCommand(context.packageManager), ...deployArgs].join(" ");
1736
- return {
1737
- "compute:deploy": deployCommand,
1738
- "compute:deploy:ci": `${deployCommand} --yes`
1739
- };
1737
+ return { "compute:deploy": deployCommand };
1740
1738
  }
1741
1739
  function getComputeDeployRuntimeArgs(context) {
1742
1740
  return [...context.requiresExplicitFramework ? ["--framework", context.framework] : [], ...context.httpPort ? ["--http-port", String(context.httpPort)] : []];
@@ -1774,11 +1772,26 @@ async function ensurePrismaCliAvailable(packageManager) {
1774
1772
  return false;
1775
1773
  }
1776
1774
  }
1777
- async function collectComputeDeployContext(input, options) {
1775
+ async function collectComputeDeployIntent(input, options) {
1778
1776
  if (!isComputeDeployableTemplate(options.template)) return null;
1779
1777
  if (input.deploy === false) return null;
1778
+ if (input.deploy === true) return true;
1779
+ if (options.useDefaults) return null;
1780
+ const confirmed = await confirm({
1781
+ message: "Deploy to Prisma Compute now?",
1782
+ initialValue: true
1783
+ });
1784
+ if (isCancel(confirmed)) {
1785
+ cancel("Operation cancelled.");
1786
+ return;
1787
+ }
1788
+ return confirmed;
1789
+ }
1790
+ async function collectComputeDeployContext(input, options) {
1791
+ if (!isComputeDeployableTemplate(options.template)) return null;
1792
+ if (options.wantsDeploy === false || options.wantsDeploy === null || input.deploy === false) return null;
1780
1793
  let wantsDeploy;
1781
- if (input.deploy === true) wantsDeploy = true;
1794
+ if (options.wantsDeploy === true || input.deploy === true) wantsDeploy = true;
1782
1795
  else if (options.useDefaults) return null;
1783
1796
  else {
1784
1797
  const confirmed = await confirm({
@@ -1852,7 +1865,8 @@ function toComputeDeployResult(data) {
1852
1865
  deploymentId: data.result.deployment.id,
1853
1866
  projectId: data.result.project.id,
1854
1867
  projectName: data.result.project.name,
1855
- branchName: data.result.branch.name
1868
+ branchName: data.result.branch.name,
1869
+ database: data.result.branchDatabase?.database
1856
1870
  };
1857
1871
  }
1858
1872
  async function executeComputeDeployContext(params) {
@@ -1867,9 +1881,9 @@ async function executeComputeDeployContext(params) {
1867
1881
  params.context.createProjectName,
1868
1882
  ...getComputeDeployRuntimeArgs(params.context)
1869
1883
  ];
1884
+ if (params.databaseSetup === "compute-postgres") args.push("--db");
1870
1885
  try {
1871
1886
  for (const [key, value] of Object.entries(params.envVars ?? {})) args.push("--env", `${key}=${value}`);
1872
- if (params.context.httpPort) args.push("--http-port", String(params.context.httpPort));
1873
1887
  const { stdout, exitCode } = await runPrismaCli(params.context.packageManager, args, {
1874
1888
  cwd: params.projectDir,
1875
1889
  reject: false,
@@ -1959,7 +1973,7 @@ async function getAnonymousId() {
1959
1973
  }
1960
1974
  function getCommonProperties() {
1961
1975
  return {
1962
- "cli-version": "0.4.2-pr.34.115.1",
1976
+ "cli-version": "0.4.2-pr.34.116.1",
1963
1977
  "node-version": process.version,
1964
1978
  platform: process.platform,
1965
1979
  arch: process.arch
@@ -2235,9 +2249,16 @@ async function collectCreateContext(input) {
2235
2249
  cancel(`Target directory ${formatPathForDisplay(targetDirectory)} is not empty. Use --force to continue.`);
2236
2250
  return;
2237
2251
  }
2252
+ const computeDeployIntent = await collectComputeDeployIntent(input, {
2253
+ template,
2254
+ useDefaults
2255
+ });
2256
+ if (computeDeployIntent === void 0) return;
2238
2257
  const prismaSetupContext = await collectPrismaSetupContext(input, {
2239
2258
  projectDir: targetDirectory,
2240
- defaultSchemaPreset: DEFAULT_SCHEMA_PRESET
2259
+ defaultSchemaPreset: DEFAULT_SCHEMA_PRESET,
2260
+ skipPrismaPostgresProvisioning: computeDeployIntent === true && input.prismaPostgres !== false,
2261
+ skipMigrateAndSeedPrompt: computeDeployIntent === true && input.prismaPostgres !== false
2241
2262
  });
2242
2263
  if (!prismaSetupContext) return;
2243
2264
  const addonSetupContext = await collectCreateAddonSetupContext(input, {
@@ -2251,9 +2272,11 @@ async function collectCreateContext(input) {
2251
2272
  template,
2252
2273
  packageManager: prismaSetupContext.packageManager,
2253
2274
  useDefaults,
2254
- defaultServiceName: projectPackageName
2275
+ defaultServiceName: projectPackageName,
2276
+ wantsDeploy: computeDeployIntent
2255
2277
  });
2256
2278
  if (computeDeployContext === void 0) return;
2279
+ const useComputeDatabase = Boolean(computeDeployContext && prismaSetupContext.databaseProvider === "postgresql" && !prismaSetupContext.databaseUrl && input.prismaPostgres !== false);
2257
2280
  return {
2258
2281
  targetDirectory,
2259
2282
  targetPathState,
@@ -2262,7 +2285,8 @@ async function collectCreateContext(input) {
2262
2285
  projectPackageName,
2263
2286
  prismaSetupContext,
2264
2287
  addonSetupContext: addonSetupContext ?? void 0,
2265
- computeDeployContext: computeDeployContext ?? void 0
2288
+ computeDeployContext: computeDeployContext ?? void 0,
2289
+ useComputeDatabase
2266
2290
  };
2267
2291
  }
2268
2292
  async function executeCreateContext(context) {
@@ -2321,12 +2345,18 @@ async function executeCreateContext(context) {
2321
2345
  error
2322
2346
  };
2323
2347
  }
2348
+ const prismaSetupContext = context.useComputeDatabase ? {
2349
+ ...context.prismaSetupContext,
2350
+ shouldUsePrismaPostgres: false,
2351
+ shouldMigrateAndSeed: false
2352
+ } : context.prismaSetupContext;
2324
2353
  let prismaResult;
2325
2354
  try {
2326
- prismaResult = await executePrismaSetupContext(context.prismaSetupContext, {
2355
+ prismaResult = await executePrismaSetupContext(prismaSetupContext, {
2327
2356
  prependNextSteps: nextSteps,
2328
2357
  projectDir: context.targetDirectory,
2329
- includeDevNextStep: true
2358
+ includeDevNextStep: !context.useComputeDatabase,
2359
+ includeMigrationAndSeedNextSteps: !context.useComputeDatabase
2330
2360
  });
2331
2361
  if (!prismaResult.ok) return {
2332
2362
  ok: false,
@@ -2344,7 +2374,8 @@ async function executeCreateContext(context) {
2344
2374
  const result = await executeComputeDeployContext({
2345
2375
  context: context.computeDeployContext,
2346
2376
  projectDir: context.targetDirectory,
2347
- envVars: prismaResult.databaseUrl ? { DATABASE_URL: prismaResult.databaseUrl } : void 0
2377
+ envVars: prismaResult.databaseUrl ? { DATABASE_URL: prismaResult.databaseUrl } : void 0,
2378
+ databaseSetup: context.useComputeDatabase ? "compute-postgres" : void 0
2348
2379
  });
2349
2380
  if (!result.ok && !result.cancelled) return {
2350
2381
  ok: false,
@@ -2364,7 +2395,7 @@ async function executeCreateContext(context) {
2364
2395
  }
2365
2396
  const summaryLines = [];
2366
2397
  summaryLines.push(`Setup complete.${prismaResult.warningSection}`);
2367
- if (deployResult) summaryLines.push("", "Deployed to Prisma Compute:", ...deployResult.appUrl ? [`- App URL: ${deployResult.appUrl}`] : [], `- App: ${deployResult.appName} (${deployResult.appId})`, `- Deployment: ${deployResult.deploymentId}`);
2398
+ if (deployResult) summaryLines.push("", "Deployed to Prisma Compute:", ...deployResult.appUrl ? [`- App URL: ${deployResult.appUrl}`] : [], `- App: ${deployResult.appName} (${deployResult.appId})`, `- Deployment: ${deployResult.deploymentId}`, ...deployResult.database ? [`- Database: ${deployResult.database.name} (${deployResult.database.id})`] : []);
2368
2399
  summaryLines.push("", "Next steps:", prismaResult.nextSteps.join("\n"));
2369
2400
  outro(summaryLines.join("\n"));
2370
2401
  return { ok: true };
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-C6wQ1yYn.mjs";
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-DRZe4NlG.mjs";
3
3
  import { os } from "@orpc/server";
4
4
  import { createCli } from "trpc-cli";
5
5
 
6
6
  //#region src/index.ts
7
- const CLI_VERSION = "0.4.2-pr.34.115.1";
7
+ const CLI_VERSION = "0.4.2-pr.34.116.1";
8
8
  const router = os.router({ create: os.meta({
9
9
  description: "Create a new project with Prisma setup",
10
10
  default: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-prisma",
3
- "version": "0.4.2-pr.34.115.1",
3
+ "version": "0.4.2-pr.34.116.1",
4
4
  "private": false,
5
5
  "description": "Create Prisma 7 projects with first-party templates and great DX.",
6
6
  "homepage": "https://github.com/prisma/create-prisma",