create-prisma 0.4.2-pr.34.114.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-CzguBCmV.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
  }
@@ -1714,7 +1715,8 @@ const DEPLOY_OPTIONS_BY_TEMPLATE = {
1714
1715
  },
1715
1716
  elysia: {
1716
1717
  framework: "bun",
1717
- httpPort: 8080
1718
+ httpPort: 8080,
1719
+ requiresExplicitFramework: true
1718
1720
  },
1719
1721
  next: { framework: "nextjs" },
1720
1722
  "tanstack-start": { framework: "tanstack-start" }
@@ -1730,17 +1732,12 @@ function getPrismaCliAppDeployCommand(packageManager) {
1730
1732
  ]);
1731
1733
  }
1732
1734
  function getComputeDeployScriptMap(context) {
1733
- const deployArgs = [
1734
- "--prod",
1735
- "--framework",
1736
- context.framework,
1737
- ...context.httpPort ? ["--http-port", String(context.httpPort)] : []
1738
- ];
1735
+ const deployArgs = ["--prod", ...getComputeDeployRuntimeArgs(context)];
1739
1736
  const deployCommand = [getPrismaCliAppDeployCommand(context.packageManager), ...deployArgs].join(" ");
1740
- return {
1741
- "compute:deploy": deployCommand,
1742
- "compute:deploy:ci": `${deployCommand} --yes`
1743
- };
1737
+ return { "compute:deploy": deployCommand };
1738
+ }
1739
+ function getComputeDeployRuntimeArgs(context) {
1740
+ return [...context.requiresExplicitFramework ? ["--framework", context.framework] : [], ...context.httpPort ? ["--http-port", String(context.httpPort)] : []];
1744
1741
  }
1745
1742
  function runPrismaCli(packageManager, args, options = {}) {
1746
1743
  const execution = getPackageExecutionArgs(getPrismaCliExecutionPackageManager(packageManager), [PRISMA_CLI_PACKAGE, ...args]);
@@ -1775,11 +1772,26 @@ async function ensurePrismaCliAvailable(packageManager) {
1775
1772
  return false;
1776
1773
  }
1777
1774
  }
1778
- async function collectComputeDeployContext(input, options) {
1775
+ async function collectComputeDeployIntent(input, options) {
1779
1776
  if (!isComputeDeployableTemplate(options.template)) return null;
1780
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;
1781
1793
  let wantsDeploy;
1782
- if (input.deploy === true) wantsDeploy = true;
1794
+ if (options.wantsDeploy === true || input.deploy === true) wantsDeploy = true;
1783
1795
  else if (options.useDefaults) return null;
1784
1796
  else {
1785
1797
  const confirmed = await confirm({
@@ -1817,7 +1829,8 @@ async function collectComputeDeployContext(input, options) {
1817
1829
  packageManager: options.packageManager,
1818
1830
  createProjectName: options.defaultServiceName,
1819
1831
  framework: deployOptions.framework,
1820
- httpPort: deployOptions.httpPort
1832
+ httpPort: deployOptions.httpPort,
1833
+ requiresExplicitFramework: deployOptions.requiresExplicitFramework
1821
1834
  };
1822
1835
  }
1823
1836
  function redactSecrets(message) {
@@ -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) {
@@ -1863,14 +1877,13 @@ async function executeComputeDeployContext(params) {
1863
1877
  "deploy",
1864
1878
  "--json",
1865
1879
  "--yes",
1866
- "--framework",
1867
- params.context.framework,
1868
1880
  "--create-project",
1869
- params.context.createProjectName
1881
+ params.context.createProjectName,
1882
+ ...getComputeDeployRuntimeArgs(params.context)
1870
1883
  ];
1884
+ if (params.databaseSetup === "compute-postgres") args.push("--db");
1871
1885
  try {
1872
1886
  for (const [key, value] of Object.entries(params.envVars ?? {})) args.push("--env", `${key}=${value}`);
1873
- if (params.context.httpPort) args.push("--http-port", String(params.context.httpPort));
1874
1887
  const { stdout, exitCode } = await runPrismaCli(params.context.packageManager, args, {
1875
1888
  cwd: params.projectDir,
1876
1889
  reject: false,
@@ -1960,7 +1973,7 @@ async function getAnonymousId() {
1960
1973
  }
1961
1974
  function getCommonProperties() {
1962
1975
  return {
1963
- "cli-version": "0.4.2-pr.34.114.1",
1976
+ "cli-version": "0.4.2-pr.34.116.1",
1964
1977
  "node-version": process.version,
1965
1978
  platform: process.platform,
1966
1979
  arch: process.arch
@@ -2236,9 +2249,16 @@ async function collectCreateContext(input) {
2236
2249
  cancel(`Target directory ${formatPathForDisplay(targetDirectory)} is not empty. Use --force to continue.`);
2237
2250
  return;
2238
2251
  }
2252
+ const computeDeployIntent = await collectComputeDeployIntent(input, {
2253
+ template,
2254
+ useDefaults
2255
+ });
2256
+ if (computeDeployIntent === void 0) return;
2239
2257
  const prismaSetupContext = await collectPrismaSetupContext(input, {
2240
2258
  projectDir: targetDirectory,
2241
- defaultSchemaPreset: DEFAULT_SCHEMA_PRESET
2259
+ defaultSchemaPreset: DEFAULT_SCHEMA_PRESET,
2260
+ skipPrismaPostgresProvisioning: computeDeployIntent === true && input.prismaPostgres !== false,
2261
+ skipMigrateAndSeedPrompt: computeDeployIntent === true && input.prismaPostgres !== false
2242
2262
  });
2243
2263
  if (!prismaSetupContext) return;
2244
2264
  const addonSetupContext = await collectCreateAddonSetupContext(input, {
@@ -2252,9 +2272,11 @@ async function collectCreateContext(input) {
2252
2272
  template,
2253
2273
  packageManager: prismaSetupContext.packageManager,
2254
2274
  useDefaults,
2255
- defaultServiceName: projectPackageName
2275
+ defaultServiceName: projectPackageName,
2276
+ wantsDeploy: computeDeployIntent
2256
2277
  });
2257
2278
  if (computeDeployContext === void 0) return;
2279
+ const useComputeDatabase = Boolean(computeDeployContext && prismaSetupContext.databaseProvider === "postgresql" && !prismaSetupContext.databaseUrl && input.prismaPostgres !== false);
2258
2280
  return {
2259
2281
  targetDirectory,
2260
2282
  targetPathState,
@@ -2263,7 +2285,8 @@ async function collectCreateContext(input) {
2263
2285
  projectPackageName,
2264
2286
  prismaSetupContext,
2265
2287
  addonSetupContext: addonSetupContext ?? void 0,
2266
- computeDeployContext: computeDeployContext ?? void 0
2288
+ computeDeployContext: computeDeployContext ?? void 0,
2289
+ useComputeDatabase
2267
2290
  };
2268
2291
  }
2269
2292
  async function executeCreateContext(context) {
@@ -2322,12 +2345,18 @@ async function executeCreateContext(context) {
2322
2345
  error
2323
2346
  };
2324
2347
  }
2348
+ const prismaSetupContext = context.useComputeDatabase ? {
2349
+ ...context.prismaSetupContext,
2350
+ shouldUsePrismaPostgres: false,
2351
+ shouldMigrateAndSeed: false
2352
+ } : context.prismaSetupContext;
2325
2353
  let prismaResult;
2326
2354
  try {
2327
- prismaResult = await executePrismaSetupContext(context.prismaSetupContext, {
2355
+ prismaResult = await executePrismaSetupContext(prismaSetupContext, {
2328
2356
  prependNextSteps: nextSteps,
2329
2357
  projectDir: context.targetDirectory,
2330
- includeDevNextStep: true
2358
+ includeDevNextStep: !context.useComputeDatabase,
2359
+ includeMigrationAndSeedNextSteps: !context.useComputeDatabase
2331
2360
  });
2332
2361
  if (!prismaResult.ok) return {
2333
2362
  ok: false,
@@ -2345,7 +2374,8 @@ async function executeCreateContext(context) {
2345
2374
  const result = await executeComputeDeployContext({
2346
2375
  context: context.computeDeployContext,
2347
2376
  projectDir: context.targetDirectory,
2348
- 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
2349
2379
  });
2350
2380
  if (!result.ok && !result.cancelled) return {
2351
2381
  ok: false,
@@ -2365,7 +2395,7 @@ async function executeCreateContext(context) {
2365
2395
  }
2366
2396
  const summaryLines = [];
2367
2397
  summaryLines.push(`Setup complete.${prismaResult.warningSection}`);
2368
- 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})`] : []);
2369
2399
  summaryLines.push("", "Next steps:", prismaResult.nextSteps.join("\n"));
2370
2400
  outro(summaryLines.join("\n"));
2371
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-CzguBCmV.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.114.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.114.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",