create-prisma 0.10.0 → 0.11.0-pr.77.267.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 { c as createCommandFailureResult } from "./create-BoFbgXIm.mjs";
2
+ import { c as createCommandFailureResult } from "./create-CsgEDEx2.mjs";
3
3
  import { createCreatePrismaCli } from "./index.mjs";
4
4
 
5
5
  //#region src/ui/json-output.ts
@@ -14,6 +14,28 @@ import { Writable } from "node:stream";
14
14
  import { createInterface } from "node:readline";
15
15
  import { styleText } from "node:util";
16
16
 
17
+ //#region src/create-outcome.ts
18
+ var CreateCancellationError = class extends Error {
19
+ stage;
20
+ constructor(stage) {
21
+ super("Operation cancelled.");
22
+ this.name = "CreateCancellationError";
23
+ this.stage = stage;
24
+ }
25
+ };
26
+ var ClassifiedCreateError = class extends Error {
27
+ reason;
28
+ constructor(reason, message, options) {
29
+ super(message, options);
30
+ this.name = "ClassifiedCreateError";
31
+ this.reason = reason;
32
+ }
33
+ };
34
+ function getCreateFailureReason(error, fallback) {
35
+ return error instanceof ClassifiedCreateError ? error.reason : fallback;
36
+ }
37
+
38
+ //#endregion
17
39
  //#region src/result.ts
18
40
  const CREATE_PRISMA_RESULT_SCHEMA_VERSION = 1;
19
41
  function createCommandFailureResult(stage, message, project) {
@@ -30,21 +52,12 @@ function createCommandFailureResult(stage, message, project) {
30
52
 
31
53
  //#endregion
32
54
  //#region src/telemetry/client.ts
33
- const TELEMETRY_API_KEY = "phc_cmc85avbWyuJ2JyKdGPdv7dxXli8xLdWDBPbvIXWJfs";
55
+ const TELEMETRY_API_KEY = "";
34
56
  const TELEMETRY_HOST = "https://us.i.posthog.com";
35
57
  const TELEMETRY_CONFIG_FILE = "telemetry.json";
36
58
  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;
37
- function isTruthyEnvValue(value) {
38
- return [
39
- "1",
40
- "true",
41
- "yes",
42
- "on"
43
- ].includes(String(value ?? "").trim().toLowerCase());
44
- }
45
59
  function shouldDisableTelemetry() {
46
- if (isTruthyEnvValue(process.env.CI) || isTruthyEnvValue(process.env.GITHUB_ACTIONS)) return true;
47
- return process.env.CREATE_PRISMA_DISABLE_TELEMETRY !== void 0 || process.env.CREATE_PRISMA_TELEMETRY_DISABLED !== void 0 || process.env.DO_NOT_TRACK !== void 0;
60
+ return true;
48
61
  }
49
62
  function getTelemetryConfigDir() {
50
63
  if (process.platform === "darwin") return path.join(os.homedir(), "Library", "Application Support", "create-prisma");
@@ -66,7 +79,7 @@ async function getAnonymousId() {
66
79
  }
67
80
  function getCommonProperties() {
68
81
  return {
69
- "cli-version": "0.10.0",
82
+ "cli-version": "0.11.0-pr.77.267.1",
70
83
  "node-version": process.version,
71
84
  platform: process.platform,
72
85
  arch: process.arch
@@ -106,6 +119,7 @@ async function trackCliTelemetry(event, properties) {
106
119
  //#region src/telemetry/create.ts
107
120
  const CREATE_PRISMA_NEXT_COMPLETED_EVENT = "cli:create_prisma_next_command_completed";
108
121
  const CREATE_PRISMA_NEXT_FAILED_EVENT = "cli:create_prisma_next_command_failed";
122
+ const CREATE_PRISMA_NEXT_CANCELLED_EVENT = "cli:create_prisma_next_command_cancelled";
109
123
  function getTargetDirectoryState(context) {
110
124
  if (!context.targetPathState.exists) return "new";
111
125
  if (context.targetPathState.isEmptyDirectory) return "empty_directory";
@@ -113,6 +127,7 @@ function getTargetDirectoryState(context) {
113
127
  }
114
128
  function getBaseCreateProperties(input, context) {
115
129
  return {
130
+ "telemetry-schema-version": 2,
116
131
  command: "create",
117
132
  "uses-defaults": input.yes === true || input.json === true,
118
133
  json: input.json === true,
@@ -148,10 +163,18 @@ async function trackCreateFailed(params) {
148
163
  ...getBaseCreateProperties(params.input, params.context),
149
164
  "duration-ms": params.durationMs,
150
165
  "failure-stage": params.stage,
166
+ "failure-reason": params.reason,
151
167
  "error-name": getErrorName(params.error),
152
168
  "error-code": getErrorCode(params.error)
153
169
  });
154
170
  }
171
+ async function trackCreateCancelled(params) {
172
+ await trackCliTelemetry(CREATE_PRISMA_NEXT_CANCELLED_EVENT, {
173
+ ...getBaseCreateProperties(params.input, params.context),
174
+ "duration-ms": params.durationMs,
175
+ "cancellation-stage": params.stage
176
+ });
177
+ }
155
178
 
156
179
  //#endregion
157
180
  //#region src/types.ts
@@ -500,8 +523,8 @@ async function scaffoldCreateFrameworkTemplate(opts) {
500
523
  const dependencyVersionMap = {
501
524
  "@astrojs/node": "^10.0.2",
502
525
  "@elysiajs/node": "^1.4.5",
503
- "@prisma/composer": "0.15.0",
504
- "@prisma/composer-prisma-cloud": "0.15.0",
526
+ "@prisma/composer": "0.16.0",
527
+ "@prisma/composer-prisma-cloud": "0.16.0",
505
528
  "@prisma/orm-mongo": "8.0.0-rc.8",
506
529
  "@prisma/orm-postgres": "8.0.0-rc.8",
507
530
  "@sveltejs/adapter-node": "^5.3.2",
@@ -514,11 +537,12 @@ const dependencyVersionMap = {
514
537
  mongodb: "^7.1.0",
515
538
  "mongodb-memory-server": "^11.1.0",
516
539
  nitro: "^3.0.260610-beta",
517
- prisma: "8.0.0-rc.11",
540
+ prisma: "8.0.0-rc.12",
541
+ "temporal-polyfill": "^1.0.4",
518
542
  tsx: "^4.21.0",
519
543
  typescript: "^5.9.3"
520
544
  };
521
- const PRISMA_PLATFORM_CLI_PACKAGE = "prisma@8.0.0-rc.11";
545
+ const PRISMA_PLATFORM_CLI_PACKAGE = "prisma@8.0.0-rc.12";
522
546
  const PRISMA_DENO_CLI_PACKAGE = PRISMA_PLATFORM_CLI_PACKAGE;
523
547
  function getDependencyVersion(packageName) {
524
548
  return dependencyVersionMap[packageName];
@@ -658,6 +682,7 @@ async function addPackageDependency(opts) {
658
682
  }
659
683
  async function writePrismaDependencies(provider, packageManager, _authoring, projectDir = process.cwd()) {
660
684
  const dependencies = [getDbPackages(provider)];
685
+ if (provider === "postgres" && packageManager !== "deno") dependencies.push("temporal-polyfill");
661
686
  if (provider === "mongo") dependencies.push("arktype", "mongodb");
662
687
  if (packageManager === "deno") dependencies.push("dotenv");
663
688
  await addPackageDependency({
@@ -797,7 +822,7 @@ async function ensureProjectNameAvailable(options) {
797
822
  })).items, options.appName);
798
823
  if (collisions.length === 0) return;
799
824
  const projectIds = collisions.map((project) => project.id).join(", ");
800
- throw new Error(`A Prisma project named "${options.appName}" already exists in workspace ${workspaceLabel(options.workspace)} (${options.workspace.id}). Choose a different project name or delete the existing project (${projectIds}) in Prisma Console, then retry.`);
825
+ throw new ClassifiedCreateError("project_name_collision", `A Prisma project named "${options.appName}" already exists in workspace ${workspaceLabel(options.workspace)} (${options.workspace.id}). Choose a different project name or delete the existing project (${projectIds}) in Prisma Console, then retry.`);
801
826
  }
802
827
  async function ensureAuthentication(options) {
803
828
  const whoami = () => runPrismaJsonCommand({
@@ -812,7 +837,7 @@ async function ensureAuthentication(options) {
812
837
  "auth",
813
838
  "login"
814
839
  ]);
815
- if (!options.allowInteractiveLogin || process.stdin.isTTY !== true) throw new Error(`Sign in first with ${loginCommand}, then run ${getRunScriptCommand(options.packageManager, "deploy")}.`);
840
+ if (!options.allowInteractiveLogin || process.stdin.isTTY !== true) throw new ClassifiedCreateError("not_authenticated", `Sign in first with ${loginCommand}, then run ${getRunScriptCommand(options.packageManager, "deploy")}.`);
816
841
  options.beforeInteractiveLogin?.();
817
842
  log.info("Sign in to Prisma to deploy.", { output: options.output });
818
843
  const login = getPrismaCliArgs(options.packageManager, ["auth", "login"]);
@@ -822,7 +847,7 @@ async function ensureAuthentication(options) {
822
847
  stdio: "inherit"
823
848
  });
824
849
  const authenticatedState = await whoami();
825
- if (!authenticatedState.authenticated) throw new Error("Prisma sign-in completed without an active workspace session.");
850
+ if (!authenticatedState.authenticated) throw new ClassifiedCreateError("authentication_failed", "Prisma sign-in completed without an active workspace session.");
826
851
  return authenticatedState;
827
852
  }
828
853
  function workspaceLabel(workspace) {
@@ -842,19 +867,28 @@ async function useWorkspace(options) {
842
867
  }
843
868
  async function selectDeploymentWorkspace(options) {
844
869
  const activeWorkspace = options.authState.workspace;
845
- if (!activeWorkspace) throw new Error("The active Prisma credential does not specify a workspace.");
870
+ if (!activeWorkspace) throw new ClassifiedCreateError("workspace_missing", "The active Prisma credential does not specify a workspace.");
846
871
  if (options.workspace) {
847
872
  if (options.authState.source === "environment") {
848
- if (options.workspace === activeWorkspace.id || options.workspace === activeWorkspace.name) return activeWorkspace;
849
- throw new Error(`The environment credential is fixed to workspace ${workspaceLabel(activeWorkspace)}. Unset it before using --workspace ${options.workspace}.`);
873
+ if (options.workspace === activeWorkspace.id || options.workspace === activeWorkspace.name) return {
874
+ ok: true,
875
+ workspace: activeWorkspace
876
+ };
877
+ throw new ClassifiedCreateError("workspace_mismatch", `The environment credential is fixed to workspace ${workspaceLabel(activeWorkspace)}. Unset it before using --workspace ${options.workspace}.`);
850
878
  }
851
- return useWorkspace({
852
- packageManager: options.packageManager,
853
- projectDir: options.projectDir,
854
- workspace: options.workspace
855
- });
879
+ return {
880
+ ok: true,
881
+ workspace: await useWorkspace({
882
+ packageManager: options.packageManager,
883
+ projectDir: options.projectDir,
884
+ workspace: options.workspace
885
+ })
886
+ };
856
887
  }
857
- if (!options.shouldPrompt || process.stdin.isTTY !== true) return activeWorkspace;
888
+ if (!options.shouldPrompt || process.stdin.isTTY !== true) return {
889
+ ok: true,
890
+ workspace: activeWorkspace
891
+ };
858
892
  const available = await runPrismaJsonCommand({
859
893
  packageManager: options.packageManager,
860
894
  projectDir: options.projectDir,
@@ -864,7 +898,10 @@ async function selectDeploymentWorkspace(options) {
864
898
  "list"
865
899
  ]
866
900
  });
867
- if (available.items.length <= 1) return activeWorkspace;
901
+ if (available.items.length <= 1) return {
902
+ ok: true,
903
+ workspace: activeWorkspace
904
+ };
868
905
  options.beforePrompt?.();
869
906
  const selectedWorkspaceId = await select({
870
907
  message: "Select Prisma workspace for deployment",
@@ -878,15 +915,24 @@ async function selectDeploymentWorkspace(options) {
878
915
  });
879
916
  if (isCancel(selectedWorkspaceId)) {
880
917
  cancel("Operation cancelled.", { output: options.output });
881
- return;
918
+ return {
919
+ ok: false,
920
+ cancelled: true
921
+ };
882
922
  }
883
923
  options.afterPrompt?.();
884
- if (selectedWorkspaceId === activeWorkspace.id) return activeWorkspace;
885
- return useWorkspace({
886
- packageManager: options.packageManager,
887
- projectDir: options.projectDir,
888
- workspace: selectedWorkspaceId
889
- });
924
+ if (selectedWorkspaceId === activeWorkspace.id) return {
925
+ ok: true,
926
+ workspace: activeWorkspace
927
+ };
928
+ return {
929
+ ok: true,
930
+ workspace: await useWorkspace({
931
+ packageManager: options.packageManager,
932
+ projectDir: options.projectDir,
933
+ workspace: selectedWorkspaceId
934
+ })
935
+ };
890
936
  }
891
937
  function parseComposerDeployResult(result) {
892
938
  const summary = result.summary;
@@ -931,6 +977,8 @@ async function deployNewProjectWithComposer(options) {
931
977
  const progress = options.verbose ? void 0 : spinner({ output });
932
978
  let deploymentLog;
933
979
  let progressRunning = false;
980
+ let failureStage = "authenticate";
981
+ let failureReason = "prisma_auth_command_failed";
934
982
  const showProgress = (message) => {
935
983
  if (!progress) return;
936
984
  if (progressRunning) progress.message(message);
@@ -955,8 +1003,10 @@ async function deployNewProjectWithComposer(options) {
955
1003
  beforeInteractiveLogin: clearProgress
956
1004
  });
957
1005
  showProgress("Checking Prisma workspace...");
1006
+ failureStage = "select_workspace";
1007
+ failureReason = "workspace_selection_failed";
958
1008
  if (options.verbose) log.step("Checking Prisma workspace.", { output });
959
- const selectedWorkspace = await selectDeploymentWorkspace({
1009
+ const workspaceResult = await selectDeploymentWorkspace({
960
1010
  packageManager: options.packageManager,
961
1011
  projectDir: options.projectDir,
962
1012
  shouldPrompt: options.shouldPromptForWorkspace,
@@ -966,8 +1016,15 @@ async function deployNewProjectWithComposer(options) {
966
1016
  afterPrompt: () => showProgress("Selecting Prisma workspace..."),
967
1017
  ...options.workspace ? { workspace: options.workspace } : {}
968
1018
  });
969
- if (!selectedWorkspace) return;
1019
+ if (!workspaceResult.ok) return {
1020
+ ok: false,
1021
+ cancelled: true,
1022
+ stage: "select_workspace"
1023
+ };
1024
+ const selectedWorkspace = workspaceResult.workspace;
970
1025
  showProgress("Checking Prisma project name...");
1026
+ failureStage = "check_project_name";
1027
+ failureReason = "project_lookup_failed";
971
1028
  if (options.verbose) log.step("Checking Prisma project name.", { output });
972
1029
  await ensureProjectNameAvailable({
973
1030
  appName: options.appName,
@@ -976,6 +1033,8 @@ async function deployNewProjectWithComposer(options) {
976
1033
  workspace: selectedWorkspace
977
1034
  });
978
1035
  showProgress("Building for deployment...");
1036
+ failureStage = "build";
1037
+ failureReason = "build_failed";
979
1038
  if (options.verbose) log.step("Building for deployment.", { output });
980
1039
  const build = getRunScriptArgs(options.packageManager, "build");
981
1040
  await runSetupCommand({
@@ -987,6 +1046,8 @@ async function deployNewProjectWithComposer(options) {
987
1046
  json: options.json === true
988
1047
  });
989
1048
  clearProgress();
1049
+ failureStage = "composer_deploy";
1050
+ failureReason = "composer_deploy_failed";
990
1051
  const deployCommand = getPackageExecutionCommand(options.packageManager, [
991
1052
  PRISMA_PLATFORM_CLI_PACKAGE,
992
1053
  "deploy",
@@ -1025,11 +1086,14 @@ async function deployNewProjectWithComposer(options) {
1025
1086
  if (options.verbose) log.success("Deployed to Prisma.", { output });
1026
1087
  const workspace = details?.workspace ?? selectedWorkspace;
1027
1088
  return {
1028
- appName,
1029
- ...deployment?.appUrl ? { appUrl: deployment.appUrl } : {},
1030
- ...deployment?.serviceId ? { serviceId: deployment.serviceId } : {},
1031
- ...workspace ? { workspace } : {},
1032
- project: details?.project ?? { name: appName }
1089
+ ok: true,
1090
+ deployment: {
1091
+ appName,
1092
+ ...deployment?.appUrl ? { appUrl: deployment.appUrl } : {},
1093
+ ...deployment?.serviceId ? { serviceId: deployment.serviceId } : {},
1094
+ ...workspace ? { workspace } : {},
1095
+ project: details?.project ?? { name: appName }
1096
+ }
1033
1097
  };
1034
1098
  } catch (error) {
1035
1099
  if (deploymentLog) {
@@ -1038,8 +1102,12 @@ async function deployNewProjectWithComposer(options) {
1038
1102
  } else progress?.error("Deployment failed.");
1039
1103
  progressRunning = false;
1040
1104
  log.error(`Deploy failed: ${getErrorMessage(error)}`, { output });
1041
- if (options.throwOnError) throw error;
1042
- return;
1105
+ return {
1106
+ ok: false,
1107
+ stage: failureStage,
1108
+ reason: getCreateFailureReason(error, failureReason),
1109
+ error
1110
+ };
1043
1111
  }
1044
1112
  }
1045
1113
 
@@ -1121,7 +1189,7 @@ async function promptForDatabaseProvider(output) {
1121
1189
  });
1122
1190
  if (isCancel(databaseProvider)) {
1123
1191
  cancel("Operation cancelled.", { output });
1124
- return;
1192
+ throw new CreateCancellationError("database_provider");
1125
1193
  }
1126
1194
  return DatabaseProviderSchema.parse(databaseProvider);
1127
1195
  }
@@ -1142,7 +1210,7 @@ async function promptForAuthoringStyle(output) {
1142
1210
  });
1143
1211
  if (isCancel(authoring)) {
1144
1212
  cancel("Operation cancelled.", { output });
1145
- return;
1213
+ throw new CreateCancellationError("authoring_style");
1146
1214
  }
1147
1215
  return AuthoringStyleSchema.parse(authoring);
1148
1216
  }
@@ -1169,7 +1237,7 @@ async function promptForPackageManager(detected, output) {
1169
1237
  });
1170
1238
  if (isCancel(packageManager)) {
1171
1239
  cancel("Operation cancelled.", { output });
1172
- return;
1240
+ throw new CreateCancellationError("package_manager");
1173
1241
  }
1174
1242
  return PackageManagerSchema.parse(packageManager);
1175
1243
  }
@@ -1181,7 +1249,7 @@ async function promptForDeployment(output) {
1181
1249
  });
1182
1250
  if (isCancel(shouldDeploy)) {
1183
1251
  cancel("Operation cancelled.", { output });
1184
- return;
1252
+ throw new CreateCancellationError("deployment_intent");
1185
1253
  }
1186
1254
  return Boolean(shouldDeploy);
1187
1255
  }
@@ -1189,17 +1257,13 @@ async function collectPrismaSetupContext(input, options = {}) {
1189
1257
  const projectDir = path.resolve(options.projectDir ?? process.cwd());
1190
1258
  const { json, output, useDefaults } = resolveExecutionSettings(input);
1191
1259
  const databaseProvider = input.provider ?? (useDefaults ? DEFAULT_DATABASE_PROVIDER : await promptForDatabaseProvider(output));
1192
- if (!databaseProvider) return;
1193
1260
  const authoring = input.authoring ?? (useDefaults ? DEFAULT_AUTHORING : await promptForAuthoringStyle(output));
1194
- if (!authoring) return;
1195
1261
  const detectedPackageManager = await detectPackageManager(projectDir);
1196
1262
  const packageManager = input.packageManager ?? (useDefaults ? detectedPackageManager : await promptForPackageManager(detectedPackageManager, output));
1197
- if (!packageManager) return;
1198
- if (packageManager === "deno" && databaseProvider !== "postgres") throw new Error("Deno support currently requires PostgreSQL.");
1199
- if (packageManager === "deno" && options.template && options.template !== "minimal") throw new Error("Deno support currently requires the minimal template.");
1200
- if (packageManager === "deno" && input.deploy === true) throw new Error("Prisma Compute does not support Deno deployments yet. Use --no-deploy.");
1263
+ if (packageManager === "deno" && databaseProvider !== "postgres") throw new ClassifiedCreateError("unsupported_configuration", "Deno support currently requires PostgreSQL.");
1264
+ if (packageManager === "deno" && options.template && options.template !== "minimal") throw new ClassifiedCreateError("unsupported_configuration", "Deno support currently requires the minimal template.");
1265
+ if (packageManager === "deno" && input.deploy === true) throw new ClassifiedCreateError("unsupported_configuration", "Prisma Compute does not support Deno deployments yet. Use --no-deploy.");
1201
1266
  const shouldDeploy = packageManager === "deno" ? false : input.deploy ?? (json ? true : useDefaults ? false : await promptForDeployment(output));
1202
- if (shouldDeploy === void 0) return;
1203
1267
  return {
1204
1268
  projectDir,
1205
1269
  verbose: input.verbose === true,
@@ -1362,10 +1426,14 @@ async function executePrismaSetupContext(context, options = {}) {
1362
1426
  const progress = context.verbose ? void 0 : options.progressSpinner ?? spinner({ output: context.output });
1363
1427
  const ownsProgress = progress !== void 0 && !options.progressSpinner;
1364
1428
  let gitInitialization;
1429
+ let setupStage = "initialize_prisma";
1430
+ let setupReason = "prisma_init_failed";
1365
1431
  if (ownsProgress) progress.start("Creating Prisma 8 project...");
1366
1432
  try {
1367
1433
  progress?.message("Preparing Prisma 8 project files...");
1368
1434
  await runPrismaInit(context, projectDir);
1435
+ setupStage = "configure_project";
1436
+ setupReason = "project_configuration_failed";
1369
1437
  await scaffoldCreateSharedTemplates({
1370
1438
  projectDir,
1371
1439
  projectName,
@@ -1382,20 +1450,30 @@ async function executePrismaSetupContext(context, options = {}) {
1382
1450
  await ensureGitignoreEntry(projectDir, "/.prisma-composer");
1383
1451
  }
1384
1452
  progress?.message(`Installing dependencies with ${getInstallCommand(context.packageManager)}...`);
1453
+ setupStage = "install_dependencies";
1454
+ setupReason = "dependency_install_failed";
1385
1455
  await installProjectDependencies(context.packageManager, projectDir, {
1386
1456
  verbose: context.verbose,
1387
1457
  json: context.json
1388
1458
  });
1389
1459
  progress?.message("Installing Prisma agent skills...");
1460
+ setupStage = "initialize_agent_skills";
1461
+ setupReason = "agent_skills_init_failed";
1390
1462
  await initializeAgentSkills(context, projectDir);
1391
1463
  progress?.message("Generating Prisma 8 contract artifacts...");
1464
+ setupStage = "emit_contract";
1465
+ setupReason = "contract_emit_failed";
1392
1466
  await emitContract(context, projectDir);
1393
1467
  if (context.databaseProvider === "postgres") {
1394
1468
  progress?.message("Authoring the baseline migration...");
1469
+ setupStage = "plan_migration";
1470
+ setupReason = "migration_plan_failed";
1395
1471
  await planBaselineMigration(context, projectDir);
1396
1472
  }
1397
1473
  if (options.initializeGit) {
1398
1474
  progress?.message("Initializing Git repository...");
1475
+ setupStage = "initialize_git";
1476
+ setupReason = "git_initialization_failed";
1399
1477
  gitInitialization = await initializeGitRepository(projectDir);
1400
1478
  }
1401
1479
  progress?.stop("Prisma 8 project ready.");
@@ -1406,13 +1484,15 @@ async function executePrismaSetupContext(context, options = {}) {
1406
1484
  cancel(getErrorMessage(error), { output: context.output });
1407
1485
  return {
1408
1486
  ok: false,
1487
+ stage: setupStage,
1488
+ reason: getCreateFailureReason(error, setupReason),
1409
1489
  error,
1410
1490
  errorReported: true
1411
1491
  };
1412
1492
  }
1413
1493
  let deployment;
1414
1494
  if (context.shouldDeploy) {
1415
- deployment = await deployNewProjectWithComposer({
1495
+ const deploymentResult = await deployNewProjectWithComposer({
1416
1496
  appName: projectName,
1417
1497
  packageManager: context.packageManager,
1418
1498
  projectDir,
@@ -1421,13 +1501,24 @@ async function executePrismaSetupContext(context, options = {}) {
1421
1501
  output: context.output,
1422
1502
  allowInteractiveLogin: !context.json,
1423
1503
  json: context.json,
1424
- throwOnError: context.json,
1425
1504
  ...context.workspace ? { workspace: context.workspace } : {}
1426
1505
  });
1427
- if (!deployment) return {
1428
- ok: false,
1429
- errorReported: true
1430
- };
1506
+ if (!deploymentResult.ok) {
1507
+ if (deploymentResult.cancelled) return {
1508
+ ok: false,
1509
+ cancelled: true,
1510
+ stage: deploymentResult.stage,
1511
+ errorReported: true
1512
+ };
1513
+ return {
1514
+ ok: false,
1515
+ stage: deploymentResult.stage,
1516
+ reason: deploymentResult.reason,
1517
+ error: deploymentResult.error,
1518
+ errorReported: true
1519
+ };
1520
+ }
1521
+ deployment = deploymentResult.deployment;
1431
1522
  }
1432
1523
  const nextSteps = buildNextSteps(context, options);
1433
1524
  const warnings = gitInitialization?.status === "skipped" ? [`Could not initialize Git repository: ${gitInitialization.reason}`] : [];
@@ -1469,7 +1560,7 @@ function parseVersion(version) {
1469
1560
  Number.parseInt(patch, 10)
1470
1561
  ];
1471
1562
  }
1472
- function supportsPrismaNext(nodeVersion = process.versions.node) {
1563
+ function supportsPrisma(nodeVersion = process.versions.node) {
1473
1564
  const current = parseVersion(nodeVersion);
1474
1565
  for (let index = 0; index < MINIMUM_NODE_VERSION.length; index += 1) {
1475
1566
  if (current[index] > MINIMUM_NODE_VERSION[index]) return true;
@@ -1521,7 +1612,7 @@ async function promptForProjectName(output) {
1521
1612
  });
1522
1613
  if (isCancel(projectName)) {
1523
1614
  cancel("Operation cancelled.", { output });
1524
- return;
1615
+ throw new CreateCancellationError("project_name");
1525
1616
  }
1526
1617
  return String(projectName).trim();
1527
1618
  }
@@ -1580,7 +1671,7 @@ async function promptForCreateTemplate(output) {
1580
1671
  });
1581
1672
  if (isCancel(template)) {
1582
1673
  cancel("Operation cancelled.", { output });
1583
- return;
1674
+ throw new CreateCancellationError("template");
1584
1675
  }
1585
1676
  return CreateTemplateSchema.parse(template);
1586
1677
  }
@@ -1606,18 +1697,26 @@ async function runCreateCommand(rawInput = {}) {
1606
1697
  let input = {};
1607
1698
  let context;
1608
1699
  let failureStage = "validate_input";
1700
+ let failureReason = "invalid_input";
1609
1701
  const { output } = resolveExecutionSettings(rawInput);
1610
1702
  try {
1611
1703
  input = CreateCommandInputSchema.parse(rawInput);
1612
1704
  if (input.json && input.verbose) throw new Error("--verbose cannot be used with --json because JSON mode is output-only.");
1613
- if (!supportsPrismaNext()) {
1705
+ if (!supportsPrisma()) {
1614
1706
  const message = getUnsupportedNodeMessage();
1615
1707
  cancel(message, { output });
1616
1708
  process.exitCode = 1;
1709
+ await trackCreateFailed({
1710
+ input,
1711
+ durationMs: Date.now() - startedAt,
1712
+ stage: failureStage,
1713
+ reason: "unsupported_node_version"
1714
+ });
1617
1715
  return createCommandFailureResult(failureStage, message);
1618
1716
  }
1619
1717
  intro(getCreatePrismaIntro(), { output });
1620
1718
  failureStage = "collect_context";
1719
+ failureReason = "unexpected_error";
1621
1720
  const collected = await collectCreateContext(input);
1622
1721
  if (!collected.ok) {
1623
1722
  process.exitCode = 1;
@@ -1625,7 +1724,8 @@ async function runCreateCommand(rawInput = {}) {
1625
1724
  await trackCreateFailed({
1626
1725
  input,
1627
1726
  durationMs: Date.now() - startedAt,
1628
- stage: failureStage
1727
+ stage: failureStage,
1728
+ reason: collected.reason
1629
1729
  });
1630
1730
  return result;
1631
1731
  }
@@ -1634,6 +1734,15 @@ async function runCreateCommand(rawInput = {}) {
1634
1734
  const executionResult = await executeCreateContext(context);
1635
1735
  if (!executionResult.ok) {
1636
1736
  process.exitCode = 1;
1737
+ if (executionResult.cancelled) {
1738
+ await trackCreateCancelled({
1739
+ input,
1740
+ context,
1741
+ durationMs: Date.now() - startedAt,
1742
+ stage: executionResult.stage
1743
+ });
1744
+ return createCommandFailureResult(executionResult.stage, "Operation cancelled.", getProjectResult(context));
1745
+ }
1637
1746
  const message = executionResult.error ? getErrorMessage(executionResult.error) : "Project setup did not complete.";
1638
1747
  if (executionResult.error && !executionResult.errorReported) cancel(`Create command failed: ${message}`, { output });
1639
1748
  await trackCreateFailed({
@@ -1641,7 +1750,8 @@ async function runCreateCommand(rawInput = {}) {
1641
1750
  context,
1642
1751
  durationMs: Date.now() - startedAt,
1643
1752
  error: executionResult.error,
1644
- stage: executionResult.stage
1753
+ stage: executionResult.stage,
1754
+ reason: executionResult.reason
1645
1755
  });
1646
1756
  return createCommandFailureResult(executionResult.stage, message, getProjectResult(context));
1647
1757
  }
@@ -1653,6 +1763,15 @@ async function runCreateCommand(rawInput = {}) {
1653
1763
  return executionResult.result;
1654
1764
  } catch (error) {
1655
1765
  process.exitCode = 1;
1766
+ if (error instanceof CreateCancellationError) {
1767
+ await trackCreateCancelled({
1768
+ input,
1769
+ context,
1770
+ durationMs: Date.now() - startedAt,
1771
+ stage: error.stage
1772
+ });
1773
+ return createCommandFailureResult(failureStage, error.message, context ? getProjectResult(context) : void 0);
1774
+ }
1656
1775
  const message = getErrorMessage(error);
1657
1776
  cancel(`Create command failed: ${message}`, { output });
1658
1777
  await trackCreateFailed({
@@ -1660,7 +1779,8 @@ async function runCreateCommand(rawInput = {}) {
1660
1779
  context,
1661
1780
  durationMs: Date.now() - startedAt,
1662
1781
  error,
1663
- stage: failureStage
1782
+ stage: failureStage,
1783
+ reason: getCreateFailureReason(error, failureReason)
1664
1784
  });
1665
1785
  return createCommandFailureResult(failureStage, message, context ? getProjectResult(context) : void 0);
1666
1786
  }
@@ -1669,24 +1789,17 @@ async function collectCreateContext(input) {
1669
1789
  const force = input.force === true;
1670
1790
  const { output, useDefaults } = resolveExecutionSettings(input);
1671
1791
  const projectNameInput = input.name ?? (useDefaults ? DEFAULT_PROJECT_NAME : await promptForProjectName(output));
1672
- if (projectNameInput === void 0) return {
1673
- ok: false,
1674
- message: "Operation cancelled."
1675
- };
1676
1792
  const projectName = String(projectNameInput).trim();
1677
1793
  const projectNameValidationError = validateProjectName(projectName);
1678
1794
  if (projectNameValidationError) {
1679
1795
  cancel(projectNameValidationError, { output });
1680
1796
  return {
1681
1797
  ok: false,
1682
- message: projectNameValidationError
1798
+ message: projectNameValidationError,
1799
+ reason: "invalid_project_name"
1683
1800
  };
1684
1801
  }
1685
1802
  const template = input.template ?? (useDefaults ? DEFAULT_TEMPLATE : await promptForCreateTemplate(output));
1686
- if (!template) return {
1687
- ok: false,
1688
- message: "Operation cancelled."
1689
- };
1690
1803
  const targetDirectory = path.resolve(process.cwd(), projectName);
1691
1804
  const targetPathState = await inspectTargetPath(targetDirectory);
1692
1805
  if (targetPathState.exists && !targetPathState.isDirectory) {
@@ -1694,7 +1807,8 @@ async function collectCreateContext(input) {
1694
1807
  cancel(message, { output });
1695
1808
  return {
1696
1809
  ok: false,
1697
- message
1810
+ message,
1811
+ reason: "target_path_not_directory"
1698
1812
  };
1699
1813
  }
1700
1814
  if (targetPathState.exists && !targetPathState.isEmptyDirectory && !force) {
@@ -1702,17 +1816,14 @@ async function collectCreateContext(input) {
1702
1816
  cancel(message, { output });
1703
1817
  return {
1704
1818
  ok: false,
1705
- message
1819
+ message,
1820
+ reason: "target_directory_not_empty"
1706
1821
  };
1707
1822
  }
1708
1823
  const prismaSetupContext = await collectPrismaSetupContext(input, {
1709
1824
  projectDir: targetDirectory,
1710
1825
  template
1711
1826
  });
1712
- if (!prismaSetupContext) return {
1713
- ok: false,
1714
- message: "Operation cancelled."
1715
- };
1716
1827
  return {
1717
1828
  ok: true,
1718
1829
  context: {
@@ -1745,6 +1856,7 @@ async function executeCreateContext(context) {
1745
1856
  return {
1746
1857
  ok: false,
1747
1858
  stage: "scaffold_template",
1859
+ reason: "template_scaffold_failed",
1748
1860
  error
1749
1861
  };
1750
1862
  }
@@ -1759,6 +1871,7 @@ async function executeCreateContext(context) {
1759
1871
  return {
1760
1872
  ok: false,
1761
1873
  stage: "scaffold_template",
1874
+ reason: "template_scaffold_failed",
1762
1875
  error
1763
1876
  };
1764
1877
  }
@@ -1779,12 +1892,21 @@ async function executeCreateContext(context) {
1779
1892
  initializeGit: !context.targetPathState.exists || context.targetPathState.isEmptyDirectory,
1780
1893
  progressSpinner: createSpinner
1781
1894
  });
1782
- if (!setupResult.ok) return {
1783
- ok: false,
1784
- stage: "prisma_setup",
1785
- error: setupResult.error,
1786
- errorReported: setupResult.errorReported
1787
- };
1895
+ if (!setupResult.ok) {
1896
+ if (setupResult.cancelled) return {
1897
+ ok: false,
1898
+ cancelled: true,
1899
+ stage: setupResult.stage,
1900
+ errorReported: setupResult.errorReported
1901
+ };
1902
+ return {
1903
+ ok: false,
1904
+ stage: setupResult.stage,
1905
+ reason: setupResult.reason,
1906
+ error: setupResult.error,
1907
+ errorReported: setupResult.errorReported
1908
+ };
1909
+ }
1788
1910
  const warnings = [...setupResult.warnings];
1789
1911
  if (forceWarning) warnings.unshift(forceWarning);
1790
1912
  return {
@@ -1802,7 +1924,8 @@ async function executeCreateContext(context) {
1802
1924
  createSpinner?.error("Could not create Prisma 8 project.");
1803
1925
  return {
1804
1926
  ok: false,
1805
- stage: "prisma_setup",
1927
+ stage: "unknown",
1928
+ reason: getCreateFailureReason(error, "unexpected_error"),
1806
1929
  error
1807
1930
  };
1808
1931
  }
package/dist/index.d.mts CHANGED
@@ -2,9 +2,11 @@
2
2
  import * as _orpc_server0 from "@orpc/server";
3
3
  import * as trpc_cli0 from "trpc-cli";
4
4
  import { z } from "zod";
5
- import { spinner } from "@clack/prompts";
6
5
  import { Writable } from "node:stream";
7
6
 
7
+ //#region src/create-outcome.d.ts
8
+ type CreateFailureStage = "validate_input" | "collect_context" | "scaffold_template" | "initialize_prisma" | "configure_project" | "install_dependencies" | "initialize_agent_skills" | "emit_contract" | "plan_migration" | "initialize_git" | "authenticate" | "select_workspace" | "check_project_name" | "build" | "composer_deploy" | "unknown";
9
+ //#endregion
8
10
  //#region src/types.d.ts
9
11
  declare const DatabaseProviderSchema: z.ZodPipe<z.ZodEnum<{
10
12
  postgres: "postgres";
@@ -94,9 +96,6 @@ type ComposerDeployResult = {
94
96
  };
95
97
  };
96
98
  //#endregion
97
- //#region src/telemetry/create.d.ts
98
- type CreateTelemetryFailureStage = "validate_input" | "collect_context" | "scaffold_template" | "prisma_setup" | "unknown";
99
- //#endregion
100
99
  //#region src/result.d.ts
101
100
  declare const CREATE_PRISMA_RESULT_SCHEMA_VERSION: 1;
102
101
  type CreateNextStep = {
@@ -111,7 +110,7 @@ type CreateProjectResult = {
111
110
  authoring: AuthoringStyle;
112
111
  packageManager: PackageManager;
113
112
  };
114
- type CreateCommandFailureStage = CreateTelemetryFailureStage | "parse_arguments";
113
+ type CreateCommandFailureStage = CreateFailureStage | "parse_arguments";
115
114
  type CreateCommandSuccessResult = {
116
115
  schemaVersion: typeof CREATE_PRISMA_RESULT_SCHEMA_VERSION;
117
116
  ok: true;
package/dist/index.mjs CHANGED
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
- import { a as DatabaseProviderSchema, i as CreateTemplateSchema, n as AuthoringStyleSchema, o as PackageManagerSchema, r as CreateCommandInputSchema, s as CREATE_PRISMA_RESULT_SCHEMA_VERSION, t as runCreateCommand } from "./create-BoFbgXIm.mjs";
2
+ import { a as DatabaseProviderSchema, i as CreateTemplateSchema, n as AuthoringStyleSchema, o as PackageManagerSchema, r as CreateCommandInputSchema, s as CREATE_PRISMA_RESULT_SCHEMA_VERSION, t as runCreateCommand } from "./create-CsgEDEx2.mjs";
3
3
  import { os } from "@orpc/server";
4
4
  import { createCli } from "trpc-cli";
5
5
  import { z } from "zod";
6
6
 
7
7
  //#region src/index.ts
8
- const CLI_VERSION = "0.10.0";
8
+ const CLI_VERSION = "0.11.0-pr.77.267.1";
9
9
  const CreateCliInputSchema = z.tuple([z.string().trim().min(1, "Please enter a valid project name").optional().describe("Project name / directory"), CreateCommandInputSchema]);
10
10
  function normalizeCreateCliInput(input) {
11
11
  const [projectName, options] = input;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-prisma",
3
- "version": "0.10.0",
3
+ "version": "0.11.0-pr.77.267.1",
4
4
  "private": false,
5
5
  "description": "Create Prisma 8 projects with first-party templates and great DX.",
6
6
  "homepage": "https://github.com/prisma/create-prisma",
@@ -1,7 +1,7 @@
1
1
  {{#unless (eq packageManager "deno")}}
2
2
  import { module } from "@prisma/composer";
3
3
  {{#if (eq provider "postgres")}}
4
- import { pnPostgres } from "@prisma/composer-prisma-cloud/prisma-next";
4
+ import { postgres } from "@prisma/composer-prisma-cloud/orm";
5
5
 
6
6
  import { appContract } from "./src/prisma/composer.ts";
7
7
  {{else}}
@@ -12,7 +12,7 @@ import app from "./service.ts";
12
12
  export default module("{{projectName}}", ({ provision }) => {
13
13
  {{#if (eq provider "postgres")}}
14
14
  const database = provision(
15
- pnPostgres({
15
+ postgres({
16
16
  name: "database",
17
17
  contract: appContract,
18
18
  config: "./prisma.config.ts",
@@ -10,7 +10,7 @@ import { type } from "arktype";
10
10
  {{/if}}
11
11
  import { compute } from "@prisma/composer-prisma-cloud";
12
12
  {{#if (eq provider "postgres")}}
13
- import { pnPostgres } from "@prisma/composer-prisma-cloud/prisma-next";
13
+ import { postgres } from "@prisma/composer-prisma-cloud/orm";
14
14
 
15
15
  import { appContract } from "./src/prisma/composer.ts";
16
16
  {{/if}}
@@ -19,7 +19,7 @@ export default compute({
19
19
  name: "app",
20
20
  deps: {
21
21
  {{#if (eq provider "postgres")}}
22
- database: pnPostgres(appContract),
22
+ database: postgres(appContract),
23
23
  {{/if}}
24
24
  },
25
25
  {{#if (eq provider "mongo")}}
@@ -1,10 +1,10 @@
1
1
  {{#unless (eq packageManager "deno")}}
2
2
  {{#if (eq provider "postgres")}}
3
- import { pnContract } from "@prisma/composer-prisma-cloud/prisma-next";
3
+ import { dataContract } from "@prisma/composer-prisma-cloud/orm";
4
4
 
5
5
  import type { Contract } from "./{{#if (eq authoring "typescript")}}generated/{{/if}}contract.d.ts";
6
6
  import contractJson from "./{{#if (eq authoring "typescript")}}generated/{{/if}}contract.json" with { type: "json" };
7
7
 
8
- export const appContract = pnContract<Contract>(contractJson);
8
+ export const appContract = dataContract<Contract>(contractJson);
9
9
  {{/if}}
10
10
  {{/unless}}
@@ -12,6 +12,8 @@ if (!databaseUrl) {
12
12
 
13
13
  export const db = postgres<Contract>({ contractJson, url: databaseUrl });
14
14
  {{else}}
15
+ import "temporal-polyfill/global";
16
+
15
17
  import service from "../../service.ts";
16
18
  import type { Contract } from "./{{#if (eq authoring "typescript")}}generated/{{/if}}contract.d.ts";
17
19
  import contractJson from "./{{#if (eq authoring "typescript")}}generated/{{/if}}contract.json" with { type: "json" };