create-prisma 0.9.5 → 0.10.0-pr.74.259.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 CHANGED
@@ -63,6 +63,22 @@ older cached version. Prisma Compute does not support Deno deployments yet.
63
63
  - `--yes`
64
64
  - `--force`
65
65
  - `--verbose`
66
+ - `--json`
67
+
68
+ ### JSON output for agents and automation
69
+
70
+ Use `--json` when another program is driving `create-prisma`:
71
+
72
+ ```bash
73
+ bunx create-prisma@latest my-app --template next --package-manager bun --no-deploy --json
74
+ ```
75
+
76
+ JSON mode is non-interactive and deploys by default; pass `--no-deploy` to generate locally only. It
77
+ writes exactly one compact result object to stdout and suppresses all human UI and subprocess output.
78
+ Successful results include the generated project, deployment metadata, next steps, and warnings.
79
+ Errors use the same envelope with `ok: false`, an actionable message, and the stage that failed.
80
+ `--verbose` is intentionally incompatible with `--json` so the machine-readable contract stays
81
+ deterministic.
66
82
 
67
83
  This branch intentionally targets Prisma 8 only. It does not generate a Prisma 7 compatibility path.
68
84
 
package/dist/cli.mjs CHANGED
@@ -1,12 +1,63 @@
1
1
  #!/usr/bin/env node
2
- import "./create-C2fGwZxV.mjs";
2
+ import { c as createCommandFailureResult } from "./create-DtOJylMU.mjs";
3
3
  import { createCreatePrismaCli } from "./index.mjs";
4
4
 
5
+ //#region src/ui/json-output.ts
6
+ function isCreateCommandResult(value) {
7
+ if (typeof value !== "object" || value === null) return false;
8
+ return Reflect.get(value, "schemaVersion") === 1 && typeof Reflect.get(value, "ok") === "boolean";
9
+ }
10
+ function formatLoggerMessage(values) {
11
+ return values.map((value) => {
12
+ if (value instanceof Error) return value.message;
13
+ if (typeof value === "string") return value.trim();
14
+ try {
15
+ return JSON.stringify(value);
16
+ } catch {
17
+ return String(value);
18
+ }
19
+ }).filter(Boolean).join(" ");
20
+ }
21
+ function isJsonOutputRequested(argv) {
22
+ let requested = false;
23
+ for (const [index, argument] of argv.entries()) {
24
+ if (argument === "--json") requested = argv[index + 1]?.toLowerCase() !== "false";
25
+ if (argument.startsWith("--json=")) requested = argument.slice(7).toLowerCase() !== "false";
26
+ if (argument === "--no-json") requested = false;
27
+ }
28
+ return requested;
29
+ }
30
+ function createJsonOutputLogger(write = (output) => process.stdout.write(output)) {
31
+ let didWrite = false;
32
+ const writeResult = (result) => {
33
+ if (didWrite) return;
34
+ didWrite = true;
35
+ write(`${JSON.stringify(result)}\n`);
36
+ };
37
+ return {
38
+ info(...values) {
39
+ const result = values.length === 1 ? values[0] : void 0;
40
+ if (isCreateCommandResult(result)) {
41
+ writeResult(result);
42
+ return;
43
+ }
44
+ writeResult(createCommandFailureResult("parse_arguments", formatLoggerMessage(values) || "The CLI returned an unexpected result."));
45
+ },
46
+ error(...values) {
47
+ writeResult(createCommandFailureResult("parse_arguments", formatLoggerMessage(values) || "Could not parse command arguments."));
48
+ }
49
+ };
50
+ }
51
+
52
+ //#endregion
5
53
  //#region src/cli.ts
6
- createCreatePrismaCli().run({ process: { exit(code) {
7
- const commandExitCode = typeof process.exitCode === "number" && process.exitCode !== 0 ? process.exitCode : code;
8
- process.exit(commandExitCode);
9
- } } });
54
+ createCreatePrismaCli().run({
55
+ ...isJsonOutputRequested(process.argv) ? { logger: createJsonOutputLogger() } : {},
56
+ process: { exit(code) {
57
+ const commandExitCode = typeof process.exitCode === "number" && process.exitCode !== 0 ? process.exitCode : code;
58
+ process.exit(commandExitCode);
59
+ } }
60
+ });
10
61
 
11
62
  //#endregion
12
63
  export { };
@@ -10,25 +10,32 @@ import Handlebars from "handlebars";
10
10
  import { existsSync } from "node:fs";
11
11
  import { fileURLToPath } from "node:url";
12
12
  import { execa } from "execa";
13
+ import { Writable } from "node:stream";
13
14
  import { createInterface } from "node:readline";
14
15
  import { styleText } from "node:util";
15
16
 
17
+ //#region src/result.ts
18
+ const CREATE_PRISMA_RESULT_SCHEMA_VERSION = 1;
19
+ function createCommandFailureResult(stage, message, project) {
20
+ return {
21
+ schemaVersion: CREATE_PRISMA_RESULT_SCHEMA_VERSION,
22
+ ok: false,
23
+ error: {
24
+ stage,
25
+ message
26
+ },
27
+ ...project ? { project } : {}
28
+ };
29
+ }
30
+
31
+ //#endregion
16
32
  //#region src/telemetry/client.ts
17
- const TELEMETRY_API_KEY = "phc_cmc85avbWyuJ2JyKdGPdv7dxXli8xLdWDBPbvIXWJfs";
33
+ const TELEMETRY_API_KEY = "";
18
34
  const TELEMETRY_HOST = "https://us.i.posthog.com";
19
35
  const TELEMETRY_CONFIG_FILE = "telemetry.json";
20
36
  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;
21
- function isTruthyEnvValue(value) {
22
- return [
23
- "1",
24
- "true",
25
- "yes",
26
- "on"
27
- ].includes(String(value ?? "").trim().toLowerCase());
28
- }
29
37
  function shouldDisableTelemetry() {
30
- if (isTruthyEnvValue(process.env.CI) || isTruthyEnvValue(process.env.GITHUB_ACTIONS)) return true;
31
- return process.env.CREATE_PRISMA_DISABLE_TELEMETRY !== void 0 || process.env.CREATE_PRISMA_TELEMETRY_DISABLED !== void 0 || process.env.DO_NOT_TRACK !== void 0;
38
+ return true;
32
39
  }
33
40
  function getTelemetryConfigDir() {
34
41
  if (process.platform === "darwin") return path.join(os.homedir(), "Library", "Application Support", "create-prisma");
@@ -50,7 +57,7 @@ async function getAnonymousId() {
50
57
  }
51
58
  function getCommonProperties() {
52
59
  return {
53
- "cli-version": "0.9.5",
60
+ "cli-version": "0.10.0-pr.74.259.1",
54
61
  "node-version": process.version,
55
62
  platform: process.platform,
56
63
  arch: process.arch
@@ -98,7 +105,8 @@ function getTargetDirectoryState(context) {
98
105
  function getBaseCreateProperties(input, context) {
99
106
  return {
100
107
  command: "create",
101
- "uses-defaults": input.yes === true,
108
+ "uses-defaults": input.yes === true || input.json === true,
109
+ json: input.json === true,
102
110
  verbose: input.verbose === true,
103
111
  force: input.force === true,
104
112
  template: context?.template ?? input.template ?? null,
@@ -174,7 +182,8 @@ const AuthoringStyleSchema = z.enum(authoringStyles);
174
182
  const CreateTemplateSchema = z.enum(createTemplates);
175
183
  const CommonCommandOptionsSchema = z.object({
176
184
  yes: z.boolean().optional().describe("Skip prompts and accept default choices"),
177
- verbose: z.boolean().optional().describe("Show verbose command output during setup")
185
+ verbose: z.boolean().optional().describe("Show verbose command output during setup"),
186
+ json: z.boolean().optional().describe("Emit one quiet JSON result for agents and automation (non-interactive; deploys unless --no-deploy)")
178
187
  });
179
188
  const PrismaSetupOptionsSchema = z.object({
180
189
  provider: DatabaseProviderSchema.optional().describe("Prisma 8 database target: PostgreSQL relational models or MongoDB document models"),
@@ -541,6 +550,21 @@ function getDbPackages(provider) {
541
550
  }
542
551
  }
543
552
 
553
+ //#endregion
554
+ //#region src/utils/run-command.ts
555
+ /**
556
+ * Runs a setup command without allowing child output to corrupt structured CLI output.
557
+ * Human verbose mode keeps native streaming; JSON mode always captures child output.
558
+ */
559
+ async function runSetupCommand(options) {
560
+ const shouldInheritOutput = options.verbose && !options.json;
561
+ await execa(options.command, options.args, {
562
+ cwd: options.cwd,
563
+ env: options.env,
564
+ stdio: shouldInheritOutput ? "inherit" : "pipe"
565
+ });
566
+ }
567
+
544
568
  //#endregion
545
569
  //#region src/tasks/install.ts
546
570
  function getPrismaScriptMap(packageManager) {
@@ -661,22 +685,46 @@ async function writeCreateTemplateDependencies(opts) {
661
685
  async function installProjectDependencies(packageManager, projectDir = process.cwd(), options = {}) {
662
686
  const installCommand = getInstallArgs(packageManager);
663
687
  const env = packageManager === "yarn" ? { YARN_ENABLE_IMMUTABLE_INSTALLS: "false" } : void 0;
664
- await execa(installCommand.command, installCommand.args, {
688
+ await runSetupCommand({
689
+ command: installCommand.command,
690
+ args: installCommand.args,
665
691
  cwd: projectDir,
666
692
  env,
667
- stdio: options.verbose === true ? "inherit" : "pipe"
693
+ verbose: options.verbose === true,
694
+ json: options.json === true
668
695
  });
669
696
  }
670
697
 
671
698
  //#endregion
672
- //#region src/tasks/deploy-with-composer.ts
699
+ //#region src/ui/output.ts
700
+ const silentOutput = new Writable({ write(_chunk, _encoding, callback) {
701
+ callback();
702
+ } });
703
+ /** Resolves the shared interaction policy for human and machine-readable modes. */
704
+ function resolveExecutionSettings(options) {
705
+ const json = options.json === true;
706
+ return {
707
+ json,
708
+ output: json ? silentOutput : process.stdout,
709
+ useDefaults: options.yes === true || json
710
+ };
711
+ }
712
+
713
+ //#endregion
714
+ //#region src/utils/errors.ts
673
715
  function redactSecrets(message) {
674
716
  return message.replace(/\b((?:(?:prisma\+)?postgres(?:ql)?|mongodb(?:\+srv)?):\/\/)[^\s'"]+/gi, "$1<redacted>").replace(/\b([A-Z0-9_]*(?:MONGODB_(?:URL|URI)|DATABASE_URL|TOKEN|SECRET|PASSWORD|API_KEY|PRIVATE_KEY)[A-Z0-9_]*\s*=\s*)(?:"[^"]*"|'[^']*'|[^\s]+)/gi, "$1<redacted>").replace(/(\bAuthorization\s*:\s*Bearer\s+)[^\s'"]+/gi, "$1<redacted>");
675
717
  }
676
718
  function getErrorMessage(error) {
677
- if (error instanceof Error) return redactSecrets(error.message);
678
- return redactSecrets(String(error));
719
+ if (error instanceof Error && "stderr" in error) {
720
+ const stderr = String(error.stderr ?? "").trim();
721
+ if (stderr) return redactSecrets(stderr);
722
+ }
723
+ return redactSecrets(error instanceof Error ? error.message : String(error));
679
724
  }
725
+
726
+ //#endregion
727
+ //#region src/tasks/deploy-with-composer.ts
680
728
  function stripResourcePrefix(id, prefix) {
681
729
  const marker = `${prefix}_`;
682
730
  return id.startsWith(marker) ? id.slice(marker.length) : id;
@@ -742,25 +790,25 @@ async function ensureProjectNameAvailable(options) {
742
790
  const projectIds = collisions.map((project) => project.id).join(", ");
743
791
  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.`);
744
792
  }
745
- async function ensureAuthentication(packageManager, projectDir, beforeInteractiveLogin) {
793
+ async function ensureAuthentication(options) {
746
794
  const whoami = () => runPrismaJsonCommand({
747
- packageManager,
748
- projectDir,
795
+ packageManager: options.packageManager,
796
+ projectDir: options.projectDir,
749
797
  args: ["auth", "whoami"]
750
798
  });
751
799
  const authState = await whoami();
752
800
  if (authState.authenticated) return authState;
753
- const loginCommand = getPackageExecutionCommand(packageManager, [
801
+ const loginCommand = getPackageExecutionCommand(options.packageManager, [
754
802
  PRISMA_PLATFORM_CLI_PACKAGE,
755
803
  "auth",
756
804
  "login"
757
805
  ]);
758
- if (process.stdin.isTTY !== true) throw new Error(`Sign in first with ${loginCommand}, then run ${getRunScriptCommand(packageManager, "deploy")}.`);
759
- beforeInteractiveLogin?.();
760
- log.info("Sign in to Prisma to deploy.");
761
- const login = getPrismaCliArgs(packageManager, ["auth", "login"]);
806
+ if (!options.allowInteractiveLogin || process.stdin.isTTY !== true) throw new Error(`Sign in first with ${loginCommand}, then run ${getRunScriptCommand(options.packageManager, "deploy")}.`);
807
+ options.beforeInteractiveLogin?.();
808
+ log.info("Sign in to Prisma to deploy.", { output: options.output });
809
+ const login = getPrismaCliArgs(options.packageManager, ["auth", "login"]);
762
810
  await execa(login.command, login.args, {
763
- cwd: projectDir,
811
+ cwd: options.projectDir,
764
812
  env: process.env,
765
813
  stdio: "inherit"
766
814
  });
@@ -816,10 +864,11 @@ async function selectDeploymentWorkspace(options) {
816
864
  value: workspace.workspaceId,
817
865
  label: workspace.workspaceName ?? workspace.workspaceId,
818
866
  hint: workspace.current ? `${workspace.workspaceId}, current` : workspace.workspaceId
819
- }))
867
+ })),
868
+ output: options.output
820
869
  });
821
870
  if (isCancel(selectedWorkspaceId)) {
822
- cancel("Operation cancelled.");
871
+ cancel("Operation cancelled.", { output: options.output });
823
872
  return;
824
873
  }
825
874
  options.afterPrompt?.();
@@ -836,6 +885,7 @@ function parseComposerDeployResult(result) {
836
885
  const computeService = summary.nodes.flatMap((node) => node.entities).find((entity) => entity.kind === "compute-service");
837
886
  return {
838
887
  appName: summary.app,
888
+ ...computeService?.id ? { serviceId: computeService.id } : {},
839
889
  ...computeService?.url ? { appUrl: computeService.url.replace(/\/$/, "") } : {}
840
890
  };
841
891
  }
@@ -868,7 +918,8 @@ async function getProjectDetails(options) {
868
918
  * Generated projects use their own `deploy` script for every subsequent deployment.
869
919
  */
870
920
  async function deployNewProjectWithComposer(options) {
871
- const progress = options.verbose ? void 0 : spinner();
921
+ const output = options.output ?? process.stdout;
922
+ const progress = options.verbose ? void 0 : spinner({ output });
872
923
  let deploymentLog;
873
924
  let progressRunning = false;
874
925
  const showProgress = (message) => {
@@ -886,22 +937,29 @@ async function deployNewProjectWithComposer(options) {
886
937
  };
887
938
  try {
888
939
  showProgress("Checking Prisma account...");
889
- if (options.verbose) log.step("Checking Prisma account.");
890
- const authState = await ensureAuthentication(options.packageManager, options.projectDir, clearProgress);
940
+ if (options.verbose) log.step("Checking Prisma account.", { output });
941
+ const authState = await ensureAuthentication({
942
+ packageManager: options.packageManager,
943
+ projectDir: options.projectDir,
944
+ output,
945
+ allowInteractiveLogin: options.allowInteractiveLogin ?? true,
946
+ beforeInteractiveLogin: clearProgress
947
+ });
891
948
  showProgress("Checking Prisma workspace...");
892
- if (options.verbose) log.step("Checking Prisma workspace.");
949
+ if (options.verbose) log.step("Checking Prisma workspace.", { output });
893
950
  const selectedWorkspace = await selectDeploymentWorkspace({
894
951
  packageManager: options.packageManager,
895
952
  projectDir: options.projectDir,
896
953
  shouldPrompt: options.shouldPromptForWorkspace,
897
954
  authState,
955
+ output,
898
956
  beforePrompt: clearProgress,
899
957
  afterPrompt: () => showProgress("Selecting Prisma workspace..."),
900
958
  ...options.workspace ? { workspace: options.workspace } : {}
901
959
  });
902
960
  if (!selectedWorkspace) return;
903
961
  showProgress("Checking Prisma project name...");
904
- if (options.verbose) log.step("Checking Prisma project name.");
962
+ if (options.verbose) log.step("Checking Prisma project name.", { output });
905
963
  await ensureProjectNameAvailable({
906
964
  appName: options.appName,
907
965
  packageManager: options.packageManager,
@@ -909,12 +967,15 @@ async function deployNewProjectWithComposer(options) {
909
967
  workspace: selectedWorkspace
910
968
  });
911
969
  showProgress("Building for deployment...");
912
- if (options.verbose) log.step("Building for deployment.");
970
+ if (options.verbose) log.step("Building for deployment.", { output });
913
971
  const build = getRunScriptArgs(options.packageManager, "build");
914
- await execa(build.command, build.args, {
972
+ await runSetupCommand({
973
+ command: build.command,
974
+ args: build.args,
915
975
  cwd: options.projectDir,
916
976
  env: process.env,
917
- stdio: options.verbose ? "inherit" : "pipe"
977
+ verbose: options.verbose,
978
+ json: options.json === true
918
979
  });
919
980
  clearProgress();
920
981
  const deployCommand = getPackageExecutionCommand(options.packageManager, [
@@ -922,11 +983,12 @@ async function deployNewProjectWithComposer(options) {
922
983
  "deploy",
923
984
  "module.ts"
924
985
  ]);
925
- if (options.verbose) log.step(`Deploying to Prisma with ${deployCommand}.`);
986
+ if (options.verbose) log.step(`Deploying to Prisma with ${deployCommand}.`, { output });
926
987
  else {
927
988
  deploymentLog = taskLog({
928
989
  title: "Deploying to Prisma...",
929
- limit: 10
990
+ limit: 10,
991
+ output
930
992
  });
931
993
  deploymentLog.message(`$ ${deployCommand}`);
932
994
  }
@@ -936,12 +998,12 @@ async function deployNewProjectWithComposer(options) {
936
998
  args: ["deploy", "module.ts"],
937
999
  onStderrLine: (line) => {
938
1000
  const redactedLine = redactSecrets(line);
939
- if (options.verbose) process.stderr.write(`${redactedLine}\n`);
1001
+ if (options.verbose) output.write(`${redactedLine}\n`);
940
1002
  else deploymentLog?.message(redactedLine);
941
1003
  }
942
1004
  }));
943
1005
  const appName = deployment?.appName ?? options.appName;
944
- if (options.verbose) log.step("Loading deployment details.");
1006
+ if (options.verbose) log.step("Loading deployment details.", { output });
945
1007
  else deploymentLog?.message("Loading deployment details...");
946
1008
  const details = await getProjectDetails({
947
1009
  packageManager: options.packageManager,
@@ -951,11 +1013,12 @@ async function deployNewProjectWithComposer(options) {
951
1013
  deploymentLog?.success("Deployed to Prisma.");
952
1014
  deploymentLog = void 0;
953
1015
  progressRunning = false;
954
- if (options.verbose) log.success("Deployed to Prisma.");
1016
+ if (options.verbose) log.success("Deployed to Prisma.", { output });
955
1017
  const workspace = details?.workspace ?? selectedWorkspace;
956
1018
  return {
957
1019
  appName,
958
1020
  ...deployment?.appUrl ? { appUrl: deployment.appUrl } : {},
1021
+ ...deployment?.serviceId ? { serviceId: deployment.serviceId } : {},
959
1022
  ...workspace ? { workspace } : {},
960
1023
  project: details?.project ?? { name: appName }
961
1024
  };
@@ -965,7 +1028,8 @@ async function deployNewProjectWithComposer(options) {
965
1028
  deploymentLog = void 0;
966
1029
  } else progress?.error("Deployment failed.");
967
1030
  progressRunning = false;
968
- log.error(`Deploy failed: ${getErrorMessage(error)}`);
1031
+ log.error(`Deploy failed: ${getErrorMessage(error)}`, { output });
1032
+ if (options.throwOnError) throw error;
969
1033
  return;
970
1034
  }
971
1035
  }
@@ -1031,7 +1095,7 @@ async function initializeGitRepository(projectDir, env = process.env) {
1031
1095
  //#region src/tasks/setup-prisma.ts
1032
1096
  const DEFAULT_DATABASE_PROVIDER = "postgres";
1033
1097
  const DEFAULT_AUTHORING = "psl";
1034
- async function promptForDatabaseProvider() {
1098
+ async function promptForDatabaseProvider(output) {
1035
1099
  const databaseProvider = await select({
1036
1100
  message: "Select your database",
1037
1101
  initialValue: DEFAULT_DATABASE_PROVIDER,
@@ -1043,15 +1107,16 @@ async function promptForDatabaseProvider() {
1043
1107
  value: "mongo",
1044
1108
  label: "MongoDB",
1045
1109
  hint: "Connect an existing MongoDB database"
1046
- }]
1110
+ }],
1111
+ output
1047
1112
  });
1048
1113
  if (isCancel(databaseProvider)) {
1049
- cancel("Operation cancelled.");
1114
+ cancel("Operation cancelled.", { output });
1050
1115
  return;
1051
1116
  }
1052
1117
  return DatabaseProviderSchema.parse(databaseProvider);
1053
1118
  }
1054
- async function promptForAuthoringStyle() {
1119
+ async function promptForAuthoringStyle(output) {
1055
1120
  const authoring = await select({
1056
1121
  message: "Choose contract authoring style",
1057
1122
  initialValue: DEFAULT_AUTHORING,
@@ -1063,10 +1128,11 @@ async function promptForAuthoringStyle() {
1063
1128
  value: "typescript",
1064
1129
  label: "TypeScript",
1065
1130
  hint: "TypeScript contract builder"
1066
- }]
1131
+ }],
1132
+ output
1067
1133
  });
1068
1134
  if (isCancel(authoring)) {
1069
- cancel("Operation cancelled.");
1135
+ cancel("Operation cancelled.", { output });
1070
1136
  return;
1071
1137
  }
1072
1138
  return AuthoringStyleSchema.parse(authoring);
@@ -1081,7 +1147,7 @@ function getPackageManagerHint(option, detected) {
1081
1147
  };
1082
1148
  return option === detected ? `Detected; ${hints[option]}` : hints[option];
1083
1149
  }
1084
- async function promptForPackageManager(detected) {
1150
+ async function promptForPackageManager(detected, output) {
1085
1151
  const packageManager = await select({
1086
1152
  message: "Choose package manager",
1087
1153
  initialValue: detected,
@@ -1089,43 +1155,47 @@ async function promptForPackageManager(detected) {
1089
1155
  value,
1090
1156
  label: value,
1091
1157
  hint: getPackageManagerHint(value, detected)
1092
- }))
1158
+ })),
1159
+ output
1093
1160
  });
1094
1161
  if (isCancel(packageManager)) {
1095
- cancel("Operation cancelled.");
1162
+ cancel("Operation cancelled.", { output });
1096
1163
  return;
1097
1164
  }
1098
1165
  return PackageManagerSchema.parse(packageManager);
1099
1166
  }
1100
- async function promptForDeployment() {
1167
+ async function promptForDeployment(output) {
1101
1168
  const shouldDeploy = await confirm({
1102
1169
  message: "Deploy to Prisma now?",
1103
- initialValue: true
1170
+ initialValue: true,
1171
+ output
1104
1172
  });
1105
1173
  if (isCancel(shouldDeploy)) {
1106
- cancel("Operation cancelled.");
1174
+ cancel("Operation cancelled.", { output });
1107
1175
  return;
1108
1176
  }
1109
1177
  return Boolean(shouldDeploy);
1110
1178
  }
1111
1179
  async function collectPrismaSetupContext(input, options = {}) {
1112
1180
  const projectDir = path.resolve(options.projectDir ?? process.cwd());
1113
- const useDefaults = input.yes === true;
1114
- const databaseProvider = input.provider ?? (useDefaults ? DEFAULT_DATABASE_PROVIDER : await promptForDatabaseProvider());
1181
+ const { json, output, useDefaults } = resolveExecutionSettings(input);
1182
+ const databaseProvider = input.provider ?? (useDefaults ? DEFAULT_DATABASE_PROVIDER : await promptForDatabaseProvider(output));
1115
1183
  if (!databaseProvider) return;
1116
- const authoring = input.authoring ?? (useDefaults ? DEFAULT_AUTHORING : await promptForAuthoringStyle());
1184
+ const authoring = input.authoring ?? (useDefaults ? DEFAULT_AUTHORING : await promptForAuthoringStyle(output));
1117
1185
  if (!authoring) return;
1118
1186
  const detectedPackageManager = await detectPackageManager(projectDir);
1119
- const packageManager = input.packageManager ?? (useDefaults ? detectedPackageManager : await promptForPackageManager(detectedPackageManager));
1187
+ const packageManager = input.packageManager ?? (useDefaults ? detectedPackageManager : await promptForPackageManager(detectedPackageManager, output));
1120
1188
  if (!packageManager) return;
1121
1189
  if (packageManager === "deno" && databaseProvider !== "postgres") throw new Error("Deno support currently requires PostgreSQL.");
1122
1190
  if (packageManager === "deno" && options.template && options.template !== "minimal") throw new Error("Deno support currently requires the minimal template.");
1123
1191
  if (packageManager === "deno" && input.deploy === true) throw new Error("Prisma Compute does not support Deno deployments yet. Use --no-deploy.");
1124
- const shouldDeploy = packageManager === "deno" ? false : input.deploy ?? (useDefaults ? false : await promptForDeployment());
1192
+ const shouldDeploy = packageManager === "deno" ? false : input.deploy ?? (json ? true : useDefaults ? false : await promptForDeployment(output));
1125
1193
  if (shouldDeploy === void 0) return;
1126
1194
  return {
1127
1195
  projectDir,
1128
1196
  verbose: input.verbose === true,
1197
+ json,
1198
+ output,
1129
1199
  databaseProvider,
1130
1200
  authoring,
1131
1201
  packageManager,
@@ -1134,13 +1204,6 @@ async function collectPrismaSetupContext(input, options = {}) {
1134
1204
  ...input.workspace ? { workspace: input.workspace } : {}
1135
1205
  };
1136
1206
  }
1137
- function getCommandErrorMessage(error) {
1138
- if (error instanceof Error && "stderr" in error) {
1139
- const stderr = String(error.stderr ?? "").trim();
1140
- if (stderr) return stderr;
1141
- }
1142
- return error instanceof Error ? error.message : String(error);
1143
- }
1144
1207
  function getContractPath(authoring) {
1145
1208
  return `src/prisma/contract${authoring === "typescript" ? ".ts" : ".prisma"}`;
1146
1209
  }
@@ -1165,14 +1228,17 @@ async function runPrismaInit(context, projectDir) {
1165
1228
  "--skip-install"
1166
1229
  ];
1167
1230
  const invocation = getPrismaCliInvocation(context.packageManager, args);
1168
- if (context.verbose) log.step(`Running ${[invocation.command, ...invocation.args].join(" ")}`);
1169
- await execa(invocation.command, invocation.args, {
1231
+ if (context.verbose) log.step(`Running ${[invocation.command, ...invocation.args].join(" ")}`, { output: context.output });
1232
+ await runSetupCommand({
1233
+ command: invocation.command,
1234
+ args: invocation.args,
1170
1235
  cwd: projectDir,
1171
- stdio: context.verbose ? "inherit" : "pipe",
1172
1236
  env: {
1173
1237
  ...process.env,
1174
1238
  CI: "1"
1175
- }
1239
+ },
1240
+ verbose: context.verbose,
1241
+ json: context.json
1176
1242
  });
1177
1243
  if (context.packageManager === "deno") await fs.remove(path.join(projectDir, "prisma-next.md"));
1178
1244
  }
@@ -1183,14 +1249,17 @@ async function initializeAgentSkills(context, projectDir) {
1183
1249
  "--yes",
1184
1250
  "--no-interactive"
1185
1251
  ]);
1186
- if (context.verbose) log.step(`Running ${[invocation.command, ...invocation.args].join(" ")}`);
1187
- await execa(invocation.command, invocation.args, {
1252
+ if (context.verbose) log.step(`Running ${[invocation.command, ...invocation.args].join(" ")}`, { output: context.output });
1253
+ await runSetupCommand({
1254
+ command: invocation.command,
1255
+ args: invocation.args,
1188
1256
  cwd: projectDir,
1189
- stdio: context.verbose ? "inherit" : "pipe",
1190
1257
  env: {
1191
1258
  ...process.env,
1192
1259
  CI: "1"
1193
- }
1260
+ },
1261
+ verbose: context.verbose,
1262
+ json: context.json
1194
1263
  });
1195
1264
  }
1196
1265
  async function ensureGitignoreEntry(projectDir, entry) {
@@ -1219,14 +1288,17 @@ async function ensureComposerTypeScriptOptions(projectDir) {
1219
1288
  }
1220
1289
  async function runPrismaCli(context, projectDir, args) {
1221
1290
  const invocation = getPrismaCliInvocation(context.packageManager, args);
1222
- if (context.verbose) log.step([invocation.command, ...invocation.args].join(" "));
1223
- await execa(invocation.command, invocation.args, {
1291
+ if (context.verbose) log.step([invocation.command, ...invocation.args].join(" "), { output: context.output });
1292
+ await runSetupCommand({
1293
+ command: invocation.command,
1294
+ args: invocation.args,
1224
1295
  cwd: projectDir,
1225
- stdio: context.verbose ? "inherit" : "pipe",
1226
1296
  env: {
1227
1297
  ...process.env,
1228
1298
  CI: "1"
1229
- }
1299
+ },
1300
+ verbose: context.verbose,
1301
+ json: context.json
1230
1302
  });
1231
1303
  }
1232
1304
  async function emitContract(context, projectDir) {
@@ -1278,7 +1350,7 @@ async function executePrismaSetupContext(context, options = {}) {
1278
1350
  const projectDir = path.resolve(options.projectDir ?? context.projectDir);
1279
1351
  const projectName = options.projectName ?? path.basename(projectDir);
1280
1352
  const template = options.template ?? "minimal";
1281
- const progress = context.verbose ? void 0 : options.progressSpinner ?? spinner();
1353
+ const progress = context.verbose ? void 0 : options.progressSpinner ?? spinner({ output: context.output });
1282
1354
  const ownsProgress = progress !== void 0 && !options.progressSpinner;
1283
1355
  let gitInitialization;
1284
1356
  if (ownsProgress) progress.start("Creating Prisma 8 project...");
@@ -1301,7 +1373,10 @@ async function executePrismaSetupContext(context, options = {}) {
1301
1373
  await ensureGitignoreEntry(projectDir, "/.prisma-composer");
1302
1374
  }
1303
1375
  progress?.message(`Installing dependencies with ${getInstallCommand(context.packageManager)}...`);
1304
- await installProjectDependencies(context.packageManager, projectDir, { verbose: context.verbose });
1376
+ await installProjectDependencies(context.packageManager, projectDir, {
1377
+ verbose: context.verbose,
1378
+ json: context.json
1379
+ });
1305
1380
  progress?.message("Installing Prisma agent skills...");
1306
1381
  await initializeAgentSkills(context, projectDir);
1307
1382
  progress?.message("Generating Prisma 8 contract artifacts...");
@@ -1315,12 +1390,16 @@ async function executePrismaSetupContext(context, options = {}) {
1315
1390
  gitInitialization = await initializeGitRepository(projectDir);
1316
1391
  }
1317
1392
  progress?.stop("Prisma 8 project ready.");
1318
- if (gitInitialization?.status === "initialized" && context.verbose) log.success("Initialized Git repository with an initial commit.");
1319
- else if (gitInitialization?.status === "skipped") log.warn(`Could not initialize Git repository: ${gitInitialization.reason}`);
1393
+ if (gitInitialization?.status === "initialized" && context.verbose) log.success("Initialized Git repository with an initial commit.", { output: context.output });
1394
+ else if (gitInitialization?.status === "skipped") log.warn(`Could not initialize Git repository: ${gitInitialization.reason}`, { output: context.output });
1320
1395
  } catch (error) {
1321
1396
  progress?.error("Could not create Prisma 8 project.");
1322
- cancel(getCommandErrorMessage(error));
1323
- return false;
1397
+ cancel(getErrorMessage(error), { output: context.output });
1398
+ return {
1399
+ ok: false,
1400
+ error,
1401
+ errorReported: true
1402
+ };
1324
1403
  }
1325
1404
  let deployment;
1326
1405
  if (context.shouldDeploy) {
@@ -1330,18 +1409,33 @@ async function executePrismaSetupContext(context, options = {}) {
1330
1409
  projectDir,
1331
1410
  shouldPromptForWorkspace: context.shouldPromptForWorkspace,
1332
1411
  verbose: context.verbose,
1412
+ output: context.output,
1413
+ allowInteractiveLogin: !context.json,
1414
+ json: context.json,
1415
+ throwOnError: context.json,
1333
1416
  ...context.workspace ? { workspace: context.workspace } : {}
1334
1417
  });
1335
- if (!deployment) return false;
1418
+ if (!deployment) return {
1419
+ ok: false,
1420
+ errorReported: true
1421
+ };
1336
1422
  }
1423
+ const nextSteps = buildNextSteps(context, options);
1424
+ const warnings = gitInitialization?.status === "skipped" ? [`Could not initialize Git repository: ${gitInitialization.reason}`] : [];
1337
1425
  const projectSummary = formatProjectSummary({
1338
1426
  createdProjectPath: options.createdProjectPath,
1339
1427
  deployment
1340
1428
  });
1341
- if (projectSummary) note(projectSummary, context.shouldDeploy ? "Deployment" : "Project");
1342
- note(formatNextSteps(buildNextSteps(context, options)), "Next steps");
1343
- outro(context.shouldDeploy ? "Prisma 8 app deployed." : "Prisma 8 project ready.");
1344
- return true;
1429
+ if (projectSummary) note(projectSummary, context.shouldDeploy ? "Deployment" : "Project", { output: context.output });
1430
+ note(formatNextSteps(nextSteps), "Next steps", { output: context.output });
1431
+ outro(context.shouldDeploy ? "Prisma 8 app deployed." : "Prisma 8 project ready.", { output: context.output });
1432
+ return {
1433
+ ok: true,
1434
+ deployment: deployment ?? null,
1435
+ nextSteps,
1436
+ ...gitInitialization ? { gitInitialization } : {},
1437
+ warnings
1438
+ };
1345
1439
  }
1346
1440
 
1347
1441
  //#endregion
@@ -1398,20 +1492,31 @@ function validateProjectName(value) {
1398
1492
  if (trimmed === "..") return "Project name cannot be '..'.";
1399
1493
  if (path.isAbsolute(trimmed)) return "Use a relative project name instead of an absolute path.";
1400
1494
  }
1401
- async function promptForProjectName() {
1495
+ function getProjectResult(context) {
1496
+ return {
1497
+ name: context.projectPackageName,
1498
+ path: context.targetDirectory,
1499
+ template: context.template,
1500
+ databaseProvider: context.prismaSetupContext.databaseProvider,
1501
+ authoring: context.prismaSetupContext.authoring,
1502
+ packageManager: context.prismaSetupContext.packageManager
1503
+ };
1504
+ }
1505
+ async function promptForProjectName(output) {
1402
1506
  const projectName = await text({
1403
1507
  message: "Project name",
1404
1508
  placeholder: DEFAULT_PROJECT_NAME,
1405
1509
  initialValue: DEFAULT_PROJECT_NAME,
1406
- validate: validateProjectName
1510
+ validate: validateProjectName,
1511
+ output
1407
1512
  });
1408
1513
  if (isCancel(projectName)) {
1409
- cancel("Operation cancelled.");
1514
+ cancel("Operation cancelled.", { output });
1410
1515
  return;
1411
1516
  }
1412
1517
  return String(projectName).trim();
1413
1518
  }
1414
- async function promptForCreateTemplate() {
1519
+ async function promptForCreateTemplate(output) {
1415
1520
  const template = await select({
1416
1521
  message: "Select template",
1417
1522
  initialValue: DEFAULT_TEMPLATE,
@@ -1461,10 +1566,11 @@ async function promptForCreateTemplate() {
1461
1566
  label: "TanStack Start",
1462
1567
  hint: "React app with file routes and server functions"
1463
1568
  }
1464
- ]
1569
+ ],
1570
+ output
1465
1571
  });
1466
1572
  if (isCancel(template)) {
1467
- cancel("Operation cancelled.");
1573
+ cancel("Operation cancelled.", { output });
1468
1574
  return;
1469
1575
  }
1470
1576
  return CreateTemplateSchema.parse(template);
@@ -1491,22 +1597,36 @@ async function runCreateCommand(rawInput = {}) {
1491
1597
  let input = {};
1492
1598
  let context;
1493
1599
  let failureStage = "validate_input";
1600
+ const { output } = resolveExecutionSettings(rawInput);
1494
1601
  try {
1495
1602
  input = CreateCommandInputSchema.parse(rawInput);
1603
+ if (input.json && input.verbose) throw new Error("--verbose cannot be used with --json because JSON mode is output-only.");
1496
1604
  if (!supportsPrismaNext()) {
1497
- cancel(getUnsupportedNodeMessage());
1605
+ const message = getUnsupportedNodeMessage();
1606
+ cancel(message, { output });
1498
1607
  process.exitCode = 1;
1499
- return;
1608
+ return createCommandFailureResult(failureStage, message);
1500
1609
  }
1501
- intro(getCreatePrismaIntro());
1610
+ intro(getCreatePrismaIntro(), { output });
1502
1611
  failureStage = "collect_context";
1503
- context = await collectCreateContext(input);
1504
- if (!context) return;
1612
+ const collected = await collectCreateContext(input);
1613
+ if (!collected.ok) {
1614
+ process.exitCode = 1;
1615
+ const result = createCommandFailureResult(failureStage, collected.message);
1616
+ await trackCreateFailed({
1617
+ input,
1618
+ durationMs: Date.now() - startedAt,
1619
+ stage: failureStage
1620
+ });
1621
+ return result;
1622
+ }
1623
+ context = collected.context;
1505
1624
  failureStage = "unknown";
1506
1625
  const executionResult = await executeCreateContext(context);
1507
1626
  if (!executionResult.ok) {
1508
1627
  process.exitCode = 1;
1509
- if (executionResult.error) cancel(`Create command failed: ${executionResult.error instanceof Error ? executionResult.error.message : String(executionResult.error)}`);
1628
+ const message = executionResult.error ? getErrorMessage(executionResult.error) : "Project setup did not complete.";
1629
+ if (executionResult.error && !executionResult.errorReported) cancel(`Create command failed: ${message}`, { output });
1510
1630
  await trackCreateFailed({
1511
1631
  input,
1512
1632
  context,
@@ -1514,16 +1634,18 @@ async function runCreateCommand(rawInput = {}) {
1514
1634
  error: executionResult.error,
1515
1635
  stage: executionResult.stage
1516
1636
  });
1517
- return;
1637
+ return createCommandFailureResult(executionResult.stage, message, getProjectResult(context));
1518
1638
  }
1519
1639
  await trackCreateCompleted({
1520
1640
  input,
1521
1641
  context,
1522
1642
  durationMs: Date.now() - startedAt
1523
1643
  });
1644
+ return executionResult.result;
1524
1645
  } catch (error) {
1525
1646
  process.exitCode = 1;
1526
- cancel(`Create command failed: ${error instanceof Error ? error.message : String(error)}`);
1647
+ const message = getErrorMessage(error);
1648
+ cancel(`Create command failed: ${message}`, { output });
1527
1649
  await trackCreateFailed({
1528
1650
  input,
1529
1651
  context,
@@ -1531,50 +1653,75 @@ async function runCreateCommand(rawInput = {}) {
1531
1653
  error,
1532
1654
  stage: failureStage
1533
1655
  });
1656
+ return createCommandFailureResult(failureStage, message, context ? getProjectResult(context) : void 0);
1534
1657
  }
1535
1658
  }
1536
1659
  async function collectCreateContext(input) {
1537
1660
  const force = input.force === true;
1538
- const useDefaults = input.yes === true;
1539
- const projectNameInput = input.name ?? (useDefaults ? DEFAULT_PROJECT_NAME : await promptForProjectName());
1540
- if (projectNameInput === void 0) return;
1661
+ const { output, useDefaults } = resolveExecutionSettings(input);
1662
+ const projectNameInput = input.name ?? (useDefaults ? DEFAULT_PROJECT_NAME : await promptForProjectName(output));
1663
+ if (projectNameInput === void 0) return {
1664
+ ok: false,
1665
+ message: "Operation cancelled."
1666
+ };
1541
1667
  const projectName = String(projectNameInput).trim();
1542
1668
  const projectNameValidationError = validateProjectName(projectName);
1543
1669
  if (projectNameValidationError) {
1544
- cancel(projectNameValidationError);
1545
- return;
1670
+ cancel(projectNameValidationError, { output });
1671
+ return {
1672
+ ok: false,
1673
+ message: projectNameValidationError
1674
+ };
1546
1675
  }
1547
- const template = input.template ?? (useDefaults ? DEFAULT_TEMPLATE : await promptForCreateTemplate());
1548
- if (!template) return;
1676
+ const template = input.template ?? (useDefaults ? DEFAULT_TEMPLATE : await promptForCreateTemplate(output));
1677
+ if (!template) return {
1678
+ ok: false,
1679
+ message: "Operation cancelled."
1680
+ };
1549
1681
  const targetDirectory = path.resolve(process.cwd(), projectName);
1550
1682
  const targetPathState = await inspectTargetPath(targetDirectory);
1551
1683
  if (targetPathState.exists && !targetPathState.isDirectory) {
1552
- cancel(`Target path ${formatPathForDisplay(targetDirectory)} already exists and is not a directory. Choose a different project name.`);
1553
- return;
1684
+ const message = `Target path ${formatPathForDisplay(targetDirectory)} already exists and is not a directory. Choose a different project name.`;
1685
+ cancel(message, { output });
1686
+ return {
1687
+ ok: false,
1688
+ message
1689
+ };
1554
1690
  }
1555
1691
  if (targetPathState.exists && !targetPathState.isEmptyDirectory && !force) {
1556
- cancel(`Target directory ${formatPathForDisplay(targetDirectory)} is not empty. Use --force to continue.`);
1557
- return;
1692
+ const message = `Target directory ${formatPathForDisplay(targetDirectory)} is not empty. Use --force to continue.`;
1693
+ cancel(message, { output });
1694
+ return {
1695
+ ok: false,
1696
+ message
1697
+ };
1558
1698
  }
1559
1699
  const prismaSetupContext = await collectPrismaSetupContext(input, {
1560
1700
  projectDir: targetDirectory,
1561
1701
  template
1562
1702
  });
1563
- if (!prismaSetupContext) return;
1703
+ if (!prismaSetupContext) return {
1704
+ ok: false,
1705
+ message: "Operation cancelled."
1706
+ };
1564
1707
  return {
1565
- targetDirectory,
1566
- targetPathState,
1567
- force,
1568
- template,
1569
- projectPackageName: toPackageName(path.basename(targetDirectory)),
1570
- prismaSetupContext
1708
+ ok: true,
1709
+ context: {
1710
+ targetDirectory,
1711
+ targetPathState,
1712
+ force,
1713
+ template,
1714
+ projectPackageName: toPackageName(path.basename(targetDirectory)),
1715
+ prismaSetupContext
1716
+ }
1571
1717
  };
1572
1718
  }
1573
1719
  async function executeCreateContext(context) {
1574
- const createSpinner = context.prismaSetupContext.verbose ? void 0 : spinner();
1720
+ const output = context.prismaSetupContext.output;
1721
+ const createSpinner = context.prismaSetupContext.verbose ? void 0 : spinner({ output });
1575
1722
  createSpinner?.start("Creating Prisma 8 project...");
1576
1723
  try {
1577
- if (context.prismaSetupContext.verbose) log.step(`Scaffolding ${context.template} starter.`);
1724
+ if (context.prismaSetupContext.verbose) log.step(`Scaffolding ${context.template} starter.`, { output });
1578
1725
  await scaffoldCreateFrameworkTemplate({
1579
1726
  projectDir: context.targetDirectory,
1580
1727
  projectName: context.projectPackageName,
@@ -1583,7 +1730,7 @@ async function executeCreateContext(context) {
1583
1730
  authoring: context.prismaSetupContext.authoring,
1584
1731
  packageManager: context.prismaSetupContext.packageManager
1585
1732
  });
1586
- if (context.prismaSetupContext.verbose) log.success("Starter files scaffolded.");
1733
+ if (context.prismaSetupContext.verbose) log.success("Starter files scaffolded.", { output });
1587
1734
  } catch (error) {
1588
1735
  createSpinner?.error("Could not create Prisma 8 project.");
1589
1736
  return {
@@ -1606,13 +1753,14 @@ async function executeCreateContext(context) {
1606
1753
  error
1607
1754
  };
1608
1755
  }
1609
- if (context.targetPathState.exists && !context.targetPathState.isEmptyDirectory && context.force) log.warn(`Used --force in non-empty directory ${formatPathForDisplay(context.targetDirectory)}.`);
1756
+ const forceWarning = context.targetPathState.exists && !context.targetPathState.isEmptyDirectory && context.force ? `Used --force in non-empty directory ${formatPathForDisplay(context.targetDirectory)}.` : void 0;
1757
+ if (forceWarning) log.warn(forceWarning, { output });
1610
1758
  const nextSteps = formatPathForDisplay(context.targetDirectory) === "." ? [] : [{
1611
1759
  command: `cd ${formatPathForDisplay(context.targetDirectory)}`,
1612
1760
  description: "Enter your new project directory."
1613
1761
  }];
1614
1762
  try {
1615
- if (!await executePrismaSetupContext(context.prismaSetupContext, {
1763
+ const setupResult = await executePrismaSetupContext(context.prismaSetupContext, {
1616
1764
  prependNextSteps: nextSteps,
1617
1765
  projectDir: context.targetDirectory,
1618
1766
  projectName: context.projectPackageName,
@@ -1621,9 +1769,25 @@ async function executeCreateContext(context) {
1621
1769
  includeDevNextStep: true,
1622
1770
  initializeGit: !context.targetPathState.exists || context.targetPathState.isEmptyDirectory,
1623
1771
  progressSpinner: createSpinner
1624
- })) return {
1772
+ });
1773
+ if (!setupResult.ok) return {
1625
1774
  ok: false,
1626
- stage: "prisma_setup"
1775
+ stage: "prisma_setup",
1776
+ error: setupResult.error,
1777
+ errorReported: setupResult.errorReported
1778
+ };
1779
+ const warnings = [...setupResult.warnings];
1780
+ if (forceWarning) warnings.unshift(forceWarning);
1781
+ return {
1782
+ ok: true,
1783
+ result: {
1784
+ schemaVersion: CREATE_PRISMA_RESULT_SCHEMA_VERSION,
1785
+ ok: true,
1786
+ project: getProjectResult(context),
1787
+ deployment: setupResult.deployment,
1788
+ nextSteps: setupResult.nextSteps,
1789
+ warnings
1790
+ }
1627
1791
  };
1628
1792
  } catch (error) {
1629
1793
  createSpinner?.error("Could not create Prisma 8 project.");
@@ -1633,8 +1797,7 @@ async function executeCreateContext(context) {
1633
1797
  error
1634
1798
  };
1635
1799
  }
1636
- return { ok: true };
1637
1800
  }
1638
1801
 
1639
1802
  //#endregion
1640
- export { DatabaseProviderSchema as a, CreateTemplateSchema as i, AuthoringStyleSchema as n, PackageManagerSchema as o, CreateCommandInputSchema as r, runCreateCommand as t };
1803
+ export { DatabaseProviderSchema as a, createCommandFailureResult as c, CreateTemplateSchema as i, AuthoringStyleSchema as n, PackageManagerSchema as o, CreateCommandInputSchema as r, CREATE_PRISMA_RESULT_SCHEMA_VERSION as s, runCreateCommand as t };
package/dist/index.d.mts CHANGED
@@ -2,7 +2,135 @@
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
+ import { Writable } from "node:stream";
5
7
 
8
+ //#region src/types.d.ts
9
+ declare const DatabaseProviderSchema: z.ZodPipe<z.ZodEnum<{
10
+ postgres: "postgres";
11
+ postgresql: "postgresql";
12
+ mongo: "mongo";
13
+ mongodb: "mongodb";
14
+ }>, z.ZodTransform<"postgres" | "mongo", "postgres" | "postgresql" | "mongo" | "mongodb">>;
15
+ type DatabaseProvider = z.infer<typeof DatabaseProviderSchema>;
16
+ declare const PackageManagerSchema: z.ZodEnum<{
17
+ npm: "npm";
18
+ pnpm: "pnpm";
19
+ yarn: "yarn";
20
+ bun: "bun";
21
+ deno: "deno";
22
+ }>;
23
+ type PackageManager = z.infer<typeof PackageManagerSchema>;
24
+ declare const AuthoringStyleSchema: z.ZodEnum<{
25
+ psl: "psl";
26
+ typescript: "typescript";
27
+ }>;
28
+ type AuthoringStyle = z.infer<typeof AuthoringStyleSchema>;
29
+ declare const CreateTemplateSchema: z.ZodEnum<{
30
+ minimal: "minimal";
31
+ hono: "hono";
32
+ elysia: "elysia";
33
+ nest: "nest";
34
+ next: "next";
35
+ svelte: "svelte";
36
+ astro: "astro";
37
+ nuxt: "nuxt";
38
+ "tanstack-start": "tanstack-start";
39
+ }>;
40
+ type CreateTemplate = z.infer<typeof CreateTemplateSchema>;
41
+ declare const CreateCommandInputSchema: z.ZodObject<{
42
+ yes: z.ZodOptional<z.ZodBoolean>;
43
+ verbose: z.ZodOptional<z.ZodBoolean>;
44
+ json: z.ZodOptional<z.ZodBoolean>;
45
+ provider: z.ZodOptional<z.ZodPipe<z.ZodEnum<{
46
+ postgres: "postgres";
47
+ postgresql: "postgresql";
48
+ mongo: "mongo";
49
+ mongodb: "mongodb";
50
+ }>, z.ZodTransform<"postgres" | "mongo", "postgres" | "postgresql" | "mongo" | "mongodb">>>;
51
+ authoring: z.ZodOptional<z.ZodEnum<{
52
+ psl: "psl";
53
+ typescript: "typescript";
54
+ }>>;
55
+ packageManager: z.ZodOptional<z.ZodEnum<{
56
+ npm: "npm";
57
+ pnpm: "pnpm";
58
+ yarn: "yarn";
59
+ bun: "bun";
60
+ deno: "deno";
61
+ }>>;
62
+ deploy: z.ZodOptional<z.ZodBoolean>;
63
+ workspace: z.ZodOptional<z.ZodString>;
64
+ name: z.ZodOptional<z.ZodString>;
65
+ template: z.ZodOptional<z.ZodEnum<{
66
+ minimal: "minimal";
67
+ hono: "hono";
68
+ elysia: "elysia";
69
+ nest: "nest";
70
+ next: "next";
71
+ svelte: "svelte";
72
+ astro: "astro";
73
+ nuxt: "nuxt";
74
+ "tanstack-start": "tanstack-start";
75
+ }>>;
76
+ force: z.ZodOptional<z.ZodBoolean>;
77
+ }, z.core.$strip>;
78
+ type CreateCommandInput = z.infer<typeof CreateCommandInputSchema>;
79
+ //#endregion
80
+ //#region src/tasks/deploy-with-composer.d.ts
81
+ type PrismaWorkspace = {
82
+ id: string;
83
+ name: string | null;
84
+ };
85
+ type ComposerDeployResult = {
86
+ appName: string;
87
+ appUrl?: string;
88
+ serviceId?: string;
89
+ workspace?: PrismaWorkspace;
90
+ project: {
91
+ id?: string;
92
+ name: string;
93
+ consoleUrl?: string;
94
+ };
95
+ };
96
+ //#endregion
97
+ //#region src/telemetry/create.d.ts
98
+ type CreateTelemetryFailureStage = "validate_input" | "collect_context" | "scaffold_template" | "prisma_setup" | "unknown";
99
+ //#endregion
100
+ //#region src/result.d.ts
101
+ declare const CREATE_PRISMA_RESULT_SCHEMA_VERSION: 1;
102
+ type CreateNextStep = {
103
+ command: string;
104
+ description: string;
105
+ };
106
+ type CreateProjectResult = {
107
+ name: string;
108
+ path: string;
109
+ template: CreateTemplate;
110
+ databaseProvider: DatabaseProvider;
111
+ authoring: AuthoringStyle;
112
+ packageManager: PackageManager;
113
+ };
114
+ type CreateCommandFailureStage = CreateTelemetryFailureStage | "parse_arguments";
115
+ type CreateCommandSuccessResult = {
116
+ schemaVersion: typeof CREATE_PRISMA_RESULT_SCHEMA_VERSION;
117
+ ok: true;
118
+ project: CreateProjectResult;
119
+ deployment: ComposerDeployResult | null;
120
+ nextSteps: CreateNextStep[];
121
+ warnings: string[];
122
+ };
123
+ type CreateCommandFailureResult = {
124
+ schemaVersion: typeof CREATE_PRISMA_RESULT_SCHEMA_VERSION;
125
+ ok: false;
126
+ error: {
127
+ stage: CreateCommandFailureStage;
128
+ message: string;
129
+ };
130
+ project?: CreateProjectResult;
131
+ };
132
+ type CreateCommandResult = CreateCommandSuccessResult | CreateCommandFailureResult;
133
+ //#endregion
6
134
  //#region node_modules/@orpc/client/dist/index.d.mts
7
135
  declare const COMMON_ORPC_ERROR_DEFS: {
8
136
  readonly BAD_REQUEST: {
@@ -174,78 +302,12 @@ interface ErrorMapItem<TDataSchema extends AnySchema> {
174
302
  type ErrorMap = { [key in ORPCErrorCode]?: ErrorMapItem<AnySchema> };
175
303
  type MergedErrorMap<T1 extends ErrorMap, T2 extends ErrorMap> = Omit<T1, keyof T2> & T2;
176
304
  //#endregion
177
- //#region src/types.d.ts
178
- declare const DatabaseProviderSchema: z.ZodPipe<z.ZodEnum<{
179
- postgres: "postgres";
180
- postgresql: "postgresql";
181
- mongo: "mongo";
182
- mongodb: "mongodb";
183
- }>, z.ZodTransform<"postgres" | "mongo", "postgres" | "postgresql" | "mongo" | "mongodb">>;
184
- declare const PackageManagerSchema: z.ZodEnum<{
185
- npm: "npm";
186
- pnpm: "pnpm";
187
- yarn: "yarn";
188
- bun: "bun";
189
- deno: "deno";
190
- }>;
191
- declare const AuthoringStyleSchema: z.ZodEnum<{
192
- psl: "psl";
193
- typescript: "typescript";
194
- }>;
195
- declare const CreateTemplateSchema: z.ZodEnum<{
196
- minimal: "minimal";
197
- hono: "hono";
198
- elysia: "elysia";
199
- nest: "nest";
200
- next: "next";
201
- svelte: "svelte";
202
- astro: "astro";
203
- nuxt: "nuxt";
204
- "tanstack-start": "tanstack-start";
205
- }>;
206
- declare const CreateCommandInputSchema: z.ZodObject<{
207
- yes: z.ZodOptional<z.ZodBoolean>;
208
- verbose: z.ZodOptional<z.ZodBoolean>;
209
- provider: z.ZodOptional<z.ZodPipe<z.ZodEnum<{
210
- postgres: "postgres";
211
- postgresql: "postgresql";
212
- mongo: "mongo";
213
- mongodb: "mongodb";
214
- }>, z.ZodTransform<"postgres" | "mongo", "postgres" | "postgresql" | "mongo" | "mongodb">>>;
215
- authoring: z.ZodOptional<z.ZodEnum<{
216
- psl: "psl";
217
- typescript: "typescript";
218
- }>>;
219
- packageManager: z.ZodOptional<z.ZodEnum<{
220
- npm: "npm";
221
- pnpm: "pnpm";
222
- yarn: "yarn";
223
- bun: "bun";
224
- deno: "deno";
225
- }>>;
226
- deploy: z.ZodOptional<z.ZodBoolean>;
227
- workspace: z.ZodOptional<z.ZodString>;
228
- name: z.ZodOptional<z.ZodString>;
229
- template: z.ZodOptional<z.ZodEnum<{
230
- minimal: "minimal";
231
- hono: "hono";
232
- elysia: "elysia";
233
- nest: "nest";
234
- next: "next";
235
- svelte: "svelte";
236
- astro: "astro";
237
- nuxt: "nuxt";
238
- "tanstack-start": "tanstack-start";
239
- }>>;
240
- force: z.ZodOptional<z.ZodBoolean>;
241
- }, z.core.$strip>;
242
- type CreateCommandInput = z.infer<typeof CreateCommandInputSchema>;
243
- //#endregion
244
305
  //#region src/index.d.ts
245
306
  declare const router: {
246
307
  create: _orpc_server0.Procedure<_orpc_server0.MergedInitialContext<Record<never, never>, Record<never, never>, Record<never, never>>, Record<never, never>, z.ZodTuple<[z.ZodOptional<z.ZodString>, z.ZodObject<{
247
308
  yes: z.ZodOptional<z.ZodBoolean>;
248
309
  verbose: z.ZodOptional<z.ZodBoolean>;
310
+ json: z.ZodOptional<z.ZodBoolean>;
249
311
  provider: z.ZodOptional<z.ZodPipe<z.ZodEnum<{
250
312
  postgres: "postgres";
251
313
  postgresql: "postgresql";
@@ -278,9 +340,9 @@ declare const router: {
278
340
  "tanstack-start": "tanstack-start";
279
341
  }>>;
280
342
  force: z.ZodOptional<z.ZodBoolean>;
281
- }, z.core.$strip>], null>, Schema<void, void>, MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
343
+ }, z.core.$strip>], null>, Schema<CreateCommandResult | undefined, CreateCommandResult | undefined>, MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
282
344
  };
283
345
  declare function createCreatePrismaCli(): trpc_cli0.TrpcCli;
284
346
  declare function create(input?: CreateCommandInput): Promise<void>;
285
347
  //#endregion
286
- export { AuthoringStyleSchema, type CreateCommandInput, CreateCommandInputSchema, CreateTemplateSchema, DatabaseProviderSchema, PackageManagerSchema, create, createCreatePrismaCli, router };
348
+ export { AuthoringStyleSchema, CREATE_PRISMA_RESULT_SCHEMA_VERSION, type CreateCommandFailureResult, type CreateCommandFailureStage, type CreateCommandInput, CreateCommandInputSchema, type CreateCommandResult, type CreateCommandSuccessResult, type CreateNextStep, type CreateProjectResult, CreateTemplateSchema, DatabaseProviderSchema, PackageManagerSchema, create, createCreatePrismaCli, router };
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, t as runCreateCommand } from "./create-C2fGwZxV.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-DtOJylMU.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.9.5";
8
+ const CLI_VERSION = "0.10.0-pr.74.259.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;
@@ -19,7 +19,9 @@ const router = os.router({ create: os.meta({
19
19
  default: true,
20
20
  negateBooleans: true
21
21
  }).input(CreateCliInputSchema).handler(async ({ input }) => {
22
- await runCreateCommand(normalizeCreateCliInput(input));
22
+ const createInput = normalizeCreateCliInput(input);
23
+ const result = await runCreateCommand(createInput);
24
+ return createInput.json ? result : void 0;
23
25
  }) });
24
26
  function createCreatePrismaCli() {
25
27
  return createCli({
@@ -33,4 +35,4 @@ async function create(input = {}) {
33
35
  }
34
36
 
35
37
  //#endregion
36
- export { AuthoringStyleSchema, CreateCommandInputSchema, CreateTemplateSchema, DatabaseProviderSchema, PackageManagerSchema, create, createCreatePrismaCli, router };
38
+ export { AuthoringStyleSchema, CREATE_PRISMA_RESULT_SCHEMA_VERSION, CreateCommandInputSchema, CreateTemplateSchema, DatabaseProviderSchema, PackageManagerSchema, create, createCreatePrismaCli, router };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-prisma",
3
- "version": "0.9.5",
3
+ "version": "0.10.0-pr.74.259.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",
@@ -37,7 +37,7 @@
37
37
  "dev": "tsdown --watch",
38
38
  "start": "bun run ./dist/cli.mjs",
39
39
  "test": "bun run test:unit && bun run test:e2e",
40
- "test:unit": "bun test ./tests/dependencies.test.ts ./tests/deploy-with-composer.test.ts ./tests/initialize-git.test.ts ./tests/install.test.ts ./tests/node-version.test.ts ./tests/setup-prisma.test.ts ./tests/telemetry.test.ts",
40
+ "test:unit": "bun test ./tests/dependencies.test.ts ./tests/deploy-with-composer.test.ts ./tests/initialize-git.test.ts ./tests/install.test.ts ./tests/json-output.test.ts ./tests/node-version.test.ts ./tests/setup-prisma.test.ts ./tests/telemetry.test.ts",
41
41
  "test:e2e": "bun test --timeout 180000 ./tests/e2e/create-prisma.e2e.test.ts",
42
42
  "check": "bun run format:check && bun run lint",
43
43
  "lint": "oxlint . --deny-warnings",