create-prisma 0.4.2-pr.34.115.1 → 0.4.2-pr.34.117.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-yihruvVK.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"),
@@ -819,7 +819,7 @@ function getCommandErrorMessage(error) {
819
819
  }
820
820
  return error instanceof Error ? error.message : String(error);
821
821
  }
822
- async function collectPrismaSetupContext(input, options = {}) {
822
+ async function collectPrismaSetupInitialContext(input, options = {}) {
823
823
  const projectDir = path.resolve(options.projectDir ?? process.cwd());
824
824
  const useDefaults = input.yes === true;
825
825
  const verbose = input.verbose === true;
@@ -828,19 +828,11 @@ async function collectPrismaSetupContext(input, options = {}) {
828
828
  if (!databaseProvider) return;
829
829
  const schemaPreset = input.schemaPreset ?? options.defaultSchemaPreset ?? DEFAULT_SCHEMA_PRESET$1;
830
830
  const databaseUrl = input.databaseUrl;
831
- let shouldUsePrismaPostgres = false;
832
- if (databaseProvider === "postgresql" && !databaseUrl) {
833
- const prismaPostgresChoice = input.prismaPostgres ?? (useDefaults ? DEFAULT_PRISMA_POSTGRES : await promptForPrismaPostgres());
834
- if (prismaPostgresChoice === void 0) return;
835
- shouldUsePrismaPostgres = prismaPostgresChoice;
836
- }
837
831
  const detectedPackageManager = await detectPackageManager(projectDir);
838
832
  const packageManager = input.packageManager ?? (useDefaults ? detectedPackageManager : await promptForPackageManager(detectedPackageManager));
839
833
  if (!packageManager) return;
840
834
  const shouldInstall = input.install ?? (useDefaults ? DEFAULT_INSTALL : await promptForDependencyInstall(packageManager));
841
835
  if (shouldInstall === void 0) return;
842
- const shouldMigrateAndSeed = !(shouldInstall && shouldGenerate) ? false : input.migrateAndSeed ?? (useDefaults ? DEFAULT_MIGRATE_AND_SEED : await promptForMigrateAndSeed());
843
- if (shouldMigrateAndSeed === void 0) return;
844
836
  return {
845
837
  projectDir,
846
838
  verbose,
@@ -848,9 +840,24 @@ async function collectPrismaSetupContext(input, options = {}) {
848
840
  databaseProvider,
849
841
  schemaPreset,
850
842
  databaseUrl,
851
- shouldUsePrismaPostgres,
852
843
  packageManager,
853
- 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,
854
861
  shouldMigrateAndSeed
855
862
  };
856
863
  }
@@ -1078,8 +1085,8 @@ function buildNextStepsForContext(opts) {
1078
1085
  const nextSteps = [...options.prependNextSteps ?? []];
1079
1086
  if (!context.shouldInstall) nextSteps.push(`- ${getInstallCommand(context.packageManager)}`);
1080
1087
  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")}`);
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")}`);
1083
1090
  if (options.includeDevNextStep) nextSteps.push(`- ${getRunScriptCommand(context.packageManager, "dev")}`);
1084
1091
  return nextSteps;
1085
1092
  }
@@ -1733,10 +1740,7 @@ function getPrismaCliAppDeployCommand(packageManager) {
1733
1740
  function getComputeDeployScriptMap(context) {
1734
1741
  const deployArgs = ["--prod", ...getComputeDeployRuntimeArgs(context)];
1735
1742
  const deployCommand = [getPrismaCliAppDeployCommand(context.packageManager), ...deployArgs].join(" ");
1736
- return {
1737
- "compute:deploy": deployCommand,
1738
- "compute:deploy:ci": `${deployCommand} --yes`
1739
- };
1743
+ return { "compute:deploy": deployCommand };
1740
1744
  }
1741
1745
  function getComputeDeployRuntimeArgs(context) {
1742
1746
  return [...context.requiresExplicitFramework ? ["--framework", context.framework] : [], ...context.httpPort ? ["--http-port", String(context.httpPort)] : []];
@@ -1852,7 +1856,8 @@ function toComputeDeployResult(data) {
1852
1856
  deploymentId: data.result.deployment.id,
1853
1857
  projectId: data.result.project.id,
1854
1858
  projectName: data.result.project.name,
1855
- branchName: data.result.branch.name
1859
+ branchName: data.result.branch.name,
1860
+ database: data.result.branchDatabase?.database
1856
1861
  };
1857
1862
  }
1858
1863
  async function executeComputeDeployContext(params) {
@@ -1867,9 +1872,9 @@ async function executeComputeDeployContext(params) {
1867
1872
  params.context.createProjectName,
1868
1873
  ...getComputeDeployRuntimeArgs(params.context)
1869
1874
  ];
1875
+ if (params.databaseSetup === "compute-postgres") args.push("--db");
1870
1876
  try {
1871
1877
  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
1878
  const { stdout, exitCode } = await runPrismaCli(params.context.packageManager, args, {
1874
1879
  cwd: params.projectDir,
1875
1880
  reject: false,
@@ -1959,7 +1964,7 @@ async function getAnonymousId() {
1959
1964
  }
1960
1965
  function getCommonProperties() {
1961
1966
  return {
1962
- "cli-version": "0.4.2-pr.34.115.1",
1967
+ "cli-version": "0.4.2-pr.34.117.1",
1963
1968
  "node-version": process.version,
1964
1969
  platform: process.platform,
1965
1970
  arch: process.arch
@@ -2235,25 +2240,31 @@ async function collectCreateContext(input) {
2235
2240
  cancel(`Target directory ${formatPathForDisplay(targetDirectory)} is not empty. Use --force to continue.`);
2236
2241
  return;
2237
2242
  }
2238
- const prismaSetupContext = await collectPrismaSetupContext(input, {
2243
+ const prismaSetupInitialContext = await collectPrismaSetupInitialContext(input, {
2239
2244
  projectDir: targetDirectory,
2240
2245
  defaultSchemaPreset: DEFAULT_SCHEMA_PRESET
2241
2246
  });
2242
- if (!prismaSetupContext) return;
2243
- const addonSetupContext = await collectCreateAddonSetupContext(input, {
2244
- useDefaults,
2245
- provider: prismaSetupContext.databaseProvider,
2246
- shouldUsePrismaPostgres: prismaSetupContext.shouldUsePrismaPostgres
2247
- });
2248
- if (addonSetupContext === void 0) return;
2247
+ if (!prismaSetupInitialContext) return;
2249
2248
  const projectPackageName = toPackageName(path.basename(targetDirectory));
2250
2249
  const computeDeployContext = await collectComputeDeployContext(input, {
2251
2250
  template,
2252
- packageManager: prismaSetupContext.packageManager,
2251
+ packageManager: prismaSetupInitialContext.packageManager,
2253
2252
  useDefaults,
2254
2253
  defaultServiceName: projectPackageName
2255
2254
  });
2256
2255
  if (computeDeployContext === void 0) return;
2256
+ const useComputeDatabase = Boolean(computeDeployContext && prismaSetupInitialContext.databaseProvider === "postgresql" && !prismaSetupInitialContext.databaseUrl && input.prismaPostgres !== false);
2257
+ const prismaSetupContext = await completePrismaSetupContext(input, prismaSetupInitialContext, {
2258
+ useComputePostgres: useComputeDatabase,
2259
+ skipMigrateAndSeedPrompt: useComputeDatabase
2260
+ });
2261
+ if (!prismaSetupContext) return;
2262
+ const addonSetupContext = await collectCreateAddonSetupContext(input, {
2263
+ useDefaults,
2264
+ provider: prismaSetupContext.databaseProvider,
2265
+ shouldUsePrismaPostgres: prismaSetupContext.shouldUsePrismaPostgres
2266
+ });
2267
+ if (addonSetupContext === void 0) return;
2257
2268
  return {
2258
2269
  targetDirectory,
2259
2270
  targetPathState,
@@ -2262,7 +2273,8 @@ async function collectCreateContext(input) {
2262
2273
  projectPackageName,
2263
2274
  prismaSetupContext,
2264
2275
  addonSetupContext: addonSetupContext ?? void 0,
2265
- computeDeployContext: computeDeployContext ?? void 0
2276
+ computeDeployContext: computeDeployContext ?? void 0,
2277
+ useComputeDatabase
2266
2278
  };
2267
2279
  }
2268
2280
  async function executeCreateContext(context) {
@@ -2321,12 +2333,18 @@ async function executeCreateContext(context) {
2321
2333
  error
2322
2334
  };
2323
2335
  }
2336
+ const prismaSetupContext = context.useComputeDatabase ? {
2337
+ ...context.prismaSetupContext,
2338
+ shouldUsePrismaPostgres: false,
2339
+ shouldMigrateAndSeed: false
2340
+ } : context.prismaSetupContext;
2324
2341
  let prismaResult;
2325
2342
  try {
2326
- prismaResult = await executePrismaSetupContext(context.prismaSetupContext, {
2343
+ prismaResult = await executePrismaSetupContext(prismaSetupContext, {
2327
2344
  prependNextSteps: nextSteps,
2328
2345
  projectDir: context.targetDirectory,
2329
- includeDevNextStep: true
2346
+ includeDevNextStep: !context.useComputeDatabase,
2347
+ includeMigrationAndSeedNextSteps: !context.useComputeDatabase
2330
2348
  });
2331
2349
  if (!prismaResult.ok) return {
2332
2350
  ok: false,
@@ -2344,7 +2362,8 @@ async function executeCreateContext(context) {
2344
2362
  const result = await executeComputeDeployContext({
2345
2363
  context: context.computeDeployContext,
2346
2364
  projectDir: context.targetDirectory,
2347
- envVars: prismaResult.databaseUrl ? { DATABASE_URL: prismaResult.databaseUrl } : void 0
2365
+ envVars: prismaResult.databaseUrl ? { DATABASE_URL: prismaResult.databaseUrl } : void 0,
2366
+ databaseSetup: context.useComputeDatabase ? "compute-postgres" : void 0
2348
2367
  });
2349
2368
  if (!result.ok && !result.cancelled) return {
2350
2369
  ok: false,
@@ -2364,7 +2383,7 @@ async function executeCreateContext(context) {
2364
2383
  }
2365
2384
  const summaryLines = [];
2366
2385
  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}`);
2386
+ 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
2387
  summaryLines.push("", "Next steps:", prismaResult.nextSteps.join("\n"));
2369
2388
  outro(summaryLines.join("\n"));
2370
2389
  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-yihruvVK.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.117.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.117.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",