@donotdev/cli 0.0.24 → 0.0.26

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.
Files changed (34) hide show
  1. package/README.md +7 -295
  2. package/dependencies-matrix.json +47 -135
  3. package/dist/bin/commands/agent-setup.js +3 -3
  4. package/dist/bin/commands/build.js +144 -143
  5. package/dist/bin/commands/bump.js +146 -145
  6. package/dist/bin/commands/cacheout.js +143 -142
  7. package/dist/bin/commands/coach.js +157 -152
  8. package/dist/bin/commands/create-app.js +23 -23
  9. package/dist/bin/commands/create-project.js +166 -165
  10. package/dist/bin/commands/db.js +46705 -46704
  11. package/dist/bin/commands/deploy.js +684 -580
  12. package/dist/bin/commands/dev.js +180 -160
  13. package/dist/bin/commands/doctor.js +153 -152
  14. package/dist/bin/commands/emu.js +174 -168
  15. package/dist/bin/commands/format.js +144 -143
  16. package/dist/bin/commands/get-demo.js +2 -2
  17. package/dist/bin/commands/make-admin.js +64122 -64043
  18. package/dist/bin/commands/preview.js +179 -160
  19. package/dist/bin/commands/seed.js +46705 -46704
  20. package/dist/bin/commands/setup-cicd.js +165 -159
  21. package/dist/bin/commands/setup.js +414 -214
  22. package/dist/bin/commands/staging.js +684 -580
  23. package/dist/bin/commands/sync-secrets.js +143 -142
  24. package/dist/bin/commands/type-check.js +143 -142
  25. package/dist/bin/commands/wai.js +1 -1
  26. package/dist/bin/dndev.js +79 -1
  27. package/dist/index.js +713 -593
  28. package/package.json +1 -1
  29. package/templates/root-consumer/.cursor/mcp.json.example +1 -1
  30. package/templates/root-consumer/.gemini/settings.json.example +1 -1
  31. package/templates/root-consumer/.mcp.json.example +1 -1
  32. package/templates/root-consumer/bunfig.toml.example +6 -53
  33. package/templates/root-consumer/guides/dndev/SETUP_VERCEL.md.example +26 -9
  34. package/templates/root-consumer/vercel.json.example +2 -1
package/dist/index.js CHANGED
@@ -1089,6 +1089,148 @@ var init_cli_output = __esm({
1089
1089
  }
1090
1090
  });
1091
1091
 
1092
+ // packages/tooling/src/utils/errors.ts
1093
+ var DO_NOT_DEV_ERROR_CODES, DoNotDevError;
1094
+ var init_errors = __esm({
1095
+ "packages/tooling/src/utils/errors.ts"() {
1096
+ "use strict";
1097
+ init_utils();
1098
+ DO_NOT_DEV_ERROR_CODES = {
1099
+ CONFIGURATION_ERROR: "configuration-error",
1100
+ CONFIG_NOT_FOUND: "config-not-found",
1101
+ CONFIG_INVALID: "config-invalid",
1102
+ PATH_RESOLUTION_ERROR: "path-resolution-error",
1103
+ FILE_OPERATION_ERROR: "file-operation-error",
1104
+ FILE_NOT_FOUND: "file-not-found",
1105
+ PERMISSION_DENIED: "permission-denied",
1106
+ GENERATION_ERROR: "generation-error",
1107
+ TEMPLATE_ERROR: "template-error",
1108
+ TEMPLATE_NOT_FOUND: "template-not-found",
1109
+ CLI_EXECUTION_ERROR: "cli-execution-error",
1110
+ COMMAND_NOT_FOUND: "command-not-found",
1111
+ COMMAND_FAILED: "command-failed",
1112
+ VALIDATION_ERROR: "validation-error",
1113
+ SCHEMA_ERROR: "schema-error",
1114
+ DEPENDENCY_ERROR: "dependency-error",
1115
+ DEPENDENCY_NOT_FOUND: "dependency-not-found",
1116
+ DEPENDENCY_VERSION_ERROR: "dependency-version-error",
1117
+ INVALID_ARGUMENT: "invalid-argument",
1118
+ MISSING_ARGUMENT: "missing-argument",
1119
+ MISSING_PROJECT_ID: "missing-project-id",
1120
+ FIREBASE_CLI_ERROR: "firebase-cli-error",
1121
+ DEPLOYMENT_FAILED: "deployment-failed",
1122
+ VERCEL_API_ERROR: "vercel-api-error",
1123
+ OPERATION_CANCELLED: "operation-cancelled",
1124
+ TIMEOUT_ERROR: "timeout-error",
1125
+ UNKNOWN_ERROR: "unknown-error"
1126
+ };
1127
+ DoNotDevError = class _DoNotDevError extends Error {
1128
+ /** The error code categorizing this error */
1129
+ code;
1130
+ /** Original error if this is wrapping another error */
1131
+ originalError;
1132
+ /** Additional context for the error */
1133
+ context;
1134
+ /** Whether this error should be displayed to the user */
1135
+ displayable;
1136
+ /**
1137
+ * Creates a new DoNotDev error
1138
+ *
1139
+ * @param {string} message - Error message
1140
+ * @param {DoNotDevErrorCode} code - Error code
1141
+ * @param {object} [options] - Additional error options
1142
+ * @param {Error} [options.originalError] - Original error if wrapping
1143
+ * @param {Record<string, any>} [options.context] - Additional context data
1144
+ * @param {boolean} [options.displayable=true] - Whether this error should be displayed to the user
1145
+ */
1146
+ constructor(message, code = DO_NOT_DEV_ERROR_CODES.UNKNOWN_ERROR, options) {
1147
+ super(message);
1148
+ this.name = "DoNotDevError";
1149
+ this.code = code;
1150
+ this.originalError = options?.originalError;
1151
+ this.context = options?.context;
1152
+ this.displayable = options?.displayable !== false;
1153
+ Object.setPrototypeOf(this, _DoNotDevError.prototype);
1154
+ if (Error.captureStackTrace) {
1155
+ Error.captureStackTrace(this, _DoNotDevError);
1156
+ }
1157
+ }
1158
+ /**
1159
+ * Formats the error for logging or display
1160
+ *
1161
+ * @returns {string} Formatted error message with code
1162
+ */
1163
+ format() {
1164
+ return `[${this.code}] ${this.message}`;
1165
+ }
1166
+ /**
1167
+ * Creates a wrapped error from another error
1168
+ *
1169
+ * @param {Error} error - Original error to wrap
1170
+ * @param {string} [context] - Additional context for the error
1171
+ * @param {DoNotDevErrorCode} [code='unknown-error'] - Error code
1172
+ * @param {object} [options] - Additional error options
1173
+ * @param {Record<string, any>} [options.context] - Additional context data
1174
+ * @param {boolean} [options.displayable=true] - Whether this error should be displayed to the user
1175
+ * @returns {DoNotDevError} New DoNotDev error wrapping the original
1176
+ */
1177
+ static from(error2, context, code = DO_NOT_DEV_ERROR_CODES.UNKNOWN_ERROR, options) {
1178
+ if (!(error2 instanceof Error)) {
1179
+ return new _DoNotDevError(
1180
+ `Unknown error: ${String(error2)}`,
1181
+ code,
1182
+ options
1183
+ );
1184
+ }
1185
+ if (error2 instanceof _DoNotDevError) {
1186
+ if (!context) {
1187
+ return error2;
1188
+ }
1189
+ return new _DoNotDevError(`${context}: ${error2.message}`, error2.code, {
1190
+ originalError: error2.originalError || error2,
1191
+ context: { ...error2.context, ...options?.context || {} },
1192
+ displayable: options?.displayable ?? error2.displayable
1193
+ });
1194
+ }
1195
+ const message = context ? `${context}: ${error2.message}` : error2.message;
1196
+ return new _DoNotDevError(message, code, {
1197
+ originalError: error2,
1198
+ context: options?.context,
1199
+ displayable: options?.displayable
1200
+ });
1201
+ }
1202
+ /**
1203
+ * Maps common error types to DoNotDevErrorCode
1204
+ *
1205
+ * @param {Error} error - Error to analyze
1206
+ * @returns {DoNotDevErrorCode} Mapped error code
1207
+ */
1208
+ static getErrorCodeFromError(error2) {
1209
+ if (error2 instanceof _DoNotDevError) {
1210
+ return error2.code;
1211
+ }
1212
+ const message = error2.message.toLowerCase();
1213
+ if (error2.name === "ValidationError" || message.includes("validation")) {
1214
+ return DO_NOT_DEV_ERROR_CODES.VALIDATION_ERROR;
1215
+ }
1216
+ if (message.includes("not found") || message.includes("no such file")) {
1217
+ return DO_NOT_DEV_ERROR_CODES.FILE_NOT_FOUND;
1218
+ }
1219
+ if (message.includes("permission") || message.includes("access denied")) {
1220
+ return DO_NOT_DEV_ERROR_CODES.PERMISSION_DENIED;
1221
+ }
1222
+ if (message.includes("timeout") || message.includes("timed out")) {
1223
+ return DO_NOT_DEV_ERROR_CODES.TIMEOUT_ERROR;
1224
+ }
1225
+ if (message.includes("dependency") || message.includes("module not found")) {
1226
+ return DO_NOT_DEV_ERROR_CODES.DEPENDENCY_ERROR;
1227
+ }
1228
+ return DO_NOT_DEV_ERROR_CODES.UNKNOWN_ERROR;
1229
+ }
1230
+ };
1231
+ }
1232
+ });
1233
+
1092
1234
  // node_modules/.bun/fast-glob@3.3.3/node_modules/fast-glob/out/utils/array.js
1093
1235
  var require_array = __commonJS({
1094
1236
  "node_modules/.bun/fast-glob@3.3.3/node_modules/fast-glob/out/utils/array.js"(exports) {
@@ -7832,147 +7974,6 @@ var init_PathResolver = __esm({
7832
7974
  }
7833
7975
  });
7834
7976
 
7835
- // packages/tooling/src/utils/errors.ts
7836
- var DO_NOT_DEV_ERROR_CODES, DoNotDevError;
7837
- var init_errors = __esm({
7838
- "packages/tooling/src/utils/errors.ts"() {
7839
- "use strict";
7840
- init_utils();
7841
- DO_NOT_DEV_ERROR_CODES = {
7842
- CONFIGURATION_ERROR: "configuration-error",
7843
- CONFIG_NOT_FOUND: "config-not-found",
7844
- CONFIG_INVALID: "config-invalid",
7845
- PATH_RESOLUTION_ERROR: "path-resolution-error",
7846
- FILE_OPERATION_ERROR: "file-operation-error",
7847
- FILE_NOT_FOUND: "file-not-found",
7848
- PERMISSION_DENIED: "permission-denied",
7849
- GENERATION_ERROR: "generation-error",
7850
- TEMPLATE_ERROR: "template-error",
7851
- TEMPLATE_NOT_FOUND: "template-not-found",
7852
- CLI_EXECUTION_ERROR: "cli-execution-error",
7853
- COMMAND_NOT_FOUND: "command-not-found",
7854
- COMMAND_FAILED: "command-failed",
7855
- VALIDATION_ERROR: "validation-error",
7856
- SCHEMA_ERROR: "schema-error",
7857
- DEPENDENCY_ERROR: "dependency-error",
7858
- DEPENDENCY_NOT_FOUND: "dependency-not-found",
7859
- DEPENDENCY_VERSION_ERROR: "dependency-version-error",
7860
- INVALID_ARGUMENT: "invalid-argument",
7861
- MISSING_ARGUMENT: "missing-argument",
7862
- MISSING_PROJECT_ID: "missing-project-id",
7863
- FIREBASE_CLI_ERROR: "firebase-cli-error",
7864
- DEPLOYMENT_FAILED: "deployment-failed",
7865
- OPERATION_CANCELLED: "operation-cancelled",
7866
- TIMEOUT_ERROR: "timeout-error",
7867
- UNKNOWN_ERROR: "unknown-error"
7868
- };
7869
- DoNotDevError = class _DoNotDevError extends Error {
7870
- /** The error code categorizing this error */
7871
- code;
7872
- /** Original error if this is wrapping another error */
7873
- originalError;
7874
- /** Additional context for the error */
7875
- context;
7876
- /** Whether this error should be displayed to the user */
7877
- displayable;
7878
- /**
7879
- * Creates a new DoNotDev error
7880
- *
7881
- * @param {string} message - Error message
7882
- * @param {DoNotDevErrorCode} code - Error code
7883
- * @param {object} [options] - Additional error options
7884
- * @param {Error} [options.originalError] - Original error if wrapping
7885
- * @param {Record<string, any>} [options.context] - Additional context data
7886
- * @param {boolean} [options.displayable=true] - Whether this error should be displayed to the user
7887
- */
7888
- constructor(message, code = DO_NOT_DEV_ERROR_CODES.UNKNOWN_ERROR, options) {
7889
- super(message);
7890
- this.name = "DoNotDevError";
7891
- this.code = code;
7892
- this.originalError = options?.originalError;
7893
- this.context = options?.context;
7894
- this.displayable = options?.displayable !== false;
7895
- Object.setPrototypeOf(this, _DoNotDevError.prototype);
7896
- if (Error.captureStackTrace) {
7897
- Error.captureStackTrace(this, _DoNotDevError);
7898
- }
7899
- }
7900
- /**
7901
- * Formats the error for logging or display
7902
- *
7903
- * @returns {string} Formatted error message with code
7904
- */
7905
- format() {
7906
- return `[${this.code}] ${this.message}`;
7907
- }
7908
- /**
7909
- * Creates a wrapped error from another error
7910
- *
7911
- * @param {Error} error - Original error to wrap
7912
- * @param {string} [context] - Additional context for the error
7913
- * @param {DoNotDevErrorCode} [code='unknown-error'] - Error code
7914
- * @param {object} [options] - Additional error options
7915
- * @param {Record<string, any>} [options.context] - Additional context data
7916
- * @param {boolean} [options.displayable=true] - Whether this error should be displayed to the user
7917
- * @returns {DoNotDevError} New DoNotDev error wrapping the original
7918
- */
7919
- static from(error2, context, code = DO_NOT_DEV_ERROR_CODES.UNKNOWN_ERROR, options) {
7920
- if (!(error2 instanceof Error)) {
7921
- return new _DoNotDevError(
7922
- `Unknown error: ${String(error2)}`,
7923
- code,
7924
- options
7925
- );
7926
- }
7927
- if (error2 instanceof _DoNotDevError) {
7928
- if (!context) {
7929
- return error2;
7930
- }
7931
- return new _DoNotDevError(`${context}: ${error2.message}`, error2.code, {
7932
- originalError: error2.originalError || error2,
7933
- context: { ...error2.context, ...options?.context || {} },
7934
- displayable: options?.displayable ?? error2.displayable
7935
- });
7936
- }
7937
- const message = context ? `${context}: ${error2.message}` : error2.message;
7938
- return new _DoNotDevError(message, code, {
7939
- originalError: error2,
7940
- context: options?.context,
7941
- displayable: options?.displayable
7942
- });
7943
- }
7944
- /**
7945
- * Maps common error types to DoNotDevErrorCode
7946
- *
7947
- * @param {Error} error - Error to analyze
7948
- * @returns {DoNotDevErrorCode} Mapped error code
7949
- */
7950
- static getErrorCodeFromError(error2) {
7951
- if (error2 instanceof _DoNotDevError) {
7952
- return error2.code;
7953
- }
7954
- const message = error2.message.toLowerCase();
7955
- if (error2.name === "ValidationError" || message.includes("validation")) {
7956
- return DO_NOT_DEV_ERROR_CODES.VALIDATION_ERROR;
7957
- }
7958
- if (message.includes("not found") || message.includes("no such file")) {
7959
- return DO_NOT_DEV_ERROR_CODES.FILE_NOT_FOUND;
7960
- }
7961
- if (message.includes("permission") || message.includes("access denied")) {
7962
- return DO_NOT_DEV_ERROR_CODES.PERMISSION_DENIED;
7963
- }
7964
- if (message.includes("timeout") || message.includes("timed out")) {
7965
- return DO_NOT_DEV_ERROR_CODES.TIMEOUT_ERROR;
7966
- }
7967
- if (message.includes("dependency") || message.includes("module not found")) {
7968
- return DO_NOT_DEV_ERROR_CODES.DEPENDENCY_ERROR;
7969
- }
7970
- return DO_NOT_DEV_ERROR_CODES.UNKNOWN_ERROR;
7971
- }
7972
- };
7973
- }
7974
- });
7975
-
7976
7977
  // packages/tooling/src/utils/pathResolver.ts
7977
7978
  var pathResolver_exports = {};
7978
7979
  __export(pathResolver_exports, {
@@ -8485,14 +8486,14 @@ var init_typed_file_operations = __esm({
8485
8486
  "packages/tooling/src/utils/typed-file-operations.ts"() {
8486
8487
  "use strict";
8487
8488
  init_utils();
8488
- init_pathResolver();
8489
8489
  init_errors();
8490
+ init_pathResolver();
8490
8491
  }
8491
8492
  });
8492
8493
 
8493
8494
  // packages/tooling/src/bundler/utils.ts
8494
8495
  import { Buffer } from "node:buffer";
8495
- import { readFileSync as readFileSync2, writeFileSync as writeFileSync2, mkdirSync as mkdirSync2 } from "node:fs";
8496
+ import { copyFileSync as copyFileSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync2, mkdirSync as mkdirSync2 } from "node:fs";
8496
8497
  import { createRequire as createRequire3 } from "node:module";
8497
8498
  import { dirname as dirname3, resolve as resolve3 } from "node:path";
8498
8499
  import process from "node:process";
@@ -8576,23 +8577,23 @@ function analyzeApp(appPath, appName) {
8576
8577
  const functionsPath = joinPath(appPath, "functions");
8577
8578
  const functionsStat = statSync2(functionsPath);
8578
8579
  const hasFunctions = pathExists(functionsPath) && (functionsStat?.isDirectory() ?? false);
8579
- let platform6;
8580
+ let platform7;
8580
8581
  const firebaseJsonInFunctions = hasFunctions && pathExists(joinPath(functionsPath, "firebase.json"));
8581
8582
  const firebaseJsonInApp = pathExists(joinPath(appPath, "firebase.json"));
8582
8583
  if (firebaseJsonInFunctions || firebaseJsonInApp) {
8583
- platform6 = "firebase";
8584
+ platform7 = "firebase";
8584
8585
  }
8585
- if (!platform6) {
8586
+ if (!platform7) {
8586
8587
  const supabaseConfigPath = joinPath(appPath, "supabase", "config.toml");
8587
8588
  const hasSupabaseDep = !!(packageJson.dependencies?.["@donotdev/supabase"] || packageJson.dependencies?.["@supabase/supabase-js"]);
8588
8589
  if (pathExists(supabaseConfigPath) || hasSupabaseDep) {
8589
- platform6 = "supabase";
8590
+ platform7 = "supabase";
8590
8591
  }
8591
8592
  }
8592
- if (!platform6) {
8593
+ if (!platform7) {
8593
8594
  const vercelJsonPath = joinPath(appPath, "vercel.json");
8594
8595
  if (pathExists(vercelJsonPath)) {
8595
- platform6 = "vercel";
8596
+ platform7 = "vercel";
8596
8597
  }
8597
8598
  }
8598
8599
  return {
@@ -8603,7 +8604,7 @@ function analyzeApp(appPath, appName) {
8603
8604
  framework,
8604
8605
  hasFunctions,
8605
8606
  functionsPath: hasFunctions ? functionsPath : void 0,
8606
- platform: platform6
8607
+ platform: platform7
8607
8608
  };
8608
8609
  }
8609
8610
  var init_app_detection = __esm({
@@ -8788,7 +8789,7 @@ function checkCLI(command, args = ["--version"], useCache = true) {
8788
8789
  }
8789
8790
  );
8790
8791
  } else {
8791
- result = spawnSync5(command, args, {
8792
+ result = spawnSync5(`${command} ${args.join(" ")}`, {
8792
8793
  stdio: "pipe",
8793
8794
  shell: true
8794
8795
  });
@@ -8826,7 +8827,7 @@ function checkTsx() {
8826
8827
  return checkCLI("tsx");
8827
8828
  }
8828
8829
  function getCLIInstallInstructions(tool) {
8829
- const platform6 = process.platform;
8830
+ const platform7 = process.platform;
8830
8831
  const instructions = {
8831
8832
  [CLI_TOOLS.BUN]: {
8832
8833
  win32: [
@@ -8942,7 +8943,7 @@ function getCLIInstallInstructions(tool) {
8942
8943
  linux: ["bun install -g tsx"]
8943
8944
  }
8944
8945
  };
8945
- const platformInstructions = instructions[tool]?.[platform6] || instructions[tool]?.linux || [];
8946
+ const platformInstructions = instructions[tool]?.[platform7] || instructions[tool]?.linux || [];
8946
8947
  return platformInstructions.join("\n \u2022 ");
8947
8948
  }
8948
8949
  function formatCLIMissingError(tool, additionalContext) {
@@ -8957,9 +8958,9 @@ function formatCLIMissingError(tool, additionalContext) {
8957
8958
  M2.info(`
8958
8959
  ${additionalContext}`);
8959
8960
  }
8960
- const platform6 = process.platform;
8961
+ const platform7 = process.platform;
8961
8962
  M2.info("\nIf already installed, ensure it's in your PATH:");
8962
- if (platform6 === "win32") {
8963
+ if (platform7 === "win32") {
8963
8964
  M2.message(" \u2022 Check with: where " + tool);
8964
8965
  M2.message(
8965
8966
  " \u2022 Common location: C:\\Users\\<username>\\AppData\\Roaming\\npm\\"
@@ -9016,153 +9017,6 @@ var init_cli_tools = __esm({
9016
9017
  }
9017
9018
  });
9018
9019
 
9019
- // packages/tooling/src/utils/secrets-resolver.ts
9020
- function parseEnvFile(filePath) {
9021
- if (!pathExists(filePath)) return {};
9022
- const content = readSync(filePath, { format: "text" });
9023
- if (typeof content !== "string" || !content) return {};
9024
- const result = {};
9025
- for (const line of content.split(/\r?\n/)) {
9026
- const trimmed = line.trim();
9027
- if (!trimmed || trimmed.startsWith("#")) continue;
9028
- const eqIdx = trimmed.indexOf("=");
9029
- if (eqIdx === -1) continue;
9030
- const key = trimmed.slice(0, eqIdx).trim();
9031
- let value = trimmed.slice(eqIdx + 1).trim();
9032
- if (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'")) {
9033
- value = value.slice(1, -1);
9034
- }
9035
- if (key && value) {
9036
- result[key] = value;
9037
- }
9038
- }
9039
- return result;
9040
- }
9041
- function readEnvVar(filePath, varName) {
9042
- if (!pathExists(filePath)) return null;
9043
- const content = readSync(filePath, { format: "text" });
9044
- if (typeof content !== "string") return null;
9045
- for (const line of content.split(/\r?\n/)) {
9046
- const trimmed = line.trim();
9047
- if (!trimmed || trimmed.startsWith("#")) continue;
9048
- if (trimmed.startsWith(`${varName}=`)) {
9049
- let val = trimmed.substring(`${varName}=`.length).trim();
9050
- if (val.startsWith('"') && val.endsWith('"') || val.startsWith("'") && val.endsWith("'")) {
9051
- val = val.slice(1, -1);
9052
- }
9053
- return val || null;
9054
- }
9055
- }
9056
- return null;
9057
- }
9058
- function loadDndevSecrets(projectRoot) {
9059
- const secretsPath = joinPath(projectRoot, ".dndev.secrets");
9060
- if (cachedSecretsPath === secretsPath && cachedSecrets) {
9061
- return cachedSecrets;
9062
- }
9063
- cachedSecrets = parseEnvFile(secretsPath);
9064
- cachedSecretsPath = secretsPath;
9065
- return cachedSecrets;
9066
- }
9067
- function resolveSecret(name, projectRoot, opts) {
9068
- const appDir = opts?.appDir ?? projectRoot;
9069
- const envValue = process.env[name];
9070
- if (envValue) {
9071
- return { value: envValue, source: "process.env" };
9072
- }
9073
- const secrets = loadDndevSecrets(projectRoot);
9074
- if (secrets[name]) {
9075
- return { value: secrets[name], source: ".dndev.secrets" };
9076
- }
9077
- if (name === "SUPABASE_SECRET_KEY" && secrets["SUPABASE_SERVICE_ROLE_KEY"]) {
9078
- return {
9079
- value: secrets["SUPABASE_SERVICE_ROLE_KEY"],
9080
- source: ".dndev.secrets"
9081
- };
9082
- }
9083
- const legacyPaths = LEGACY_PATHS[name];
9084
- if (legacyPaths) {
9085
- for (const relPath of legacyPaths) {
9086
- const fullPath = joinPath(appDir, relPath);
9087
- const value = readEnvVar(fullPath, name);
9088
- if (value) {
9089
- if (!opts?.silent && !warnedLegacy.has(name)) {
9090
- warnedLegacy.add(name);
9091
- log.warn(
9092
- `${name} found in ${relPath} (legacy). Move it to .dndev.secrets at project root.`
9093
- );
9094
- }
9095
- return { value, source: "legacy", legacyPath: relPath };
9096
- }
9097
- if (name === "SUPABASE_SECRET_KEY") {
9098
- const aliasValue = readEnvVar(fullPath, "SUPABASE_SERVICE_ROLE_KEY");
9099
- if (aliasValue) {
9100
- if (!opts?.silent && !warnedLegacy.has(name)) {
9101
- warnedLegacy.add(name);
9102
- log.warn(
9103
- `${name} found in ${relPath} (legacy). Move it to .dndev.secrets at project root.`
9104
- );
9105
- }
9106
- return { value: aliasValue, source: "legacy", legacyPath: relPath };
9107
- }
9108
- }
9109
- }
9110
- }
9111
- return null;
9112
- }
9113
- var LEGACY_PATHS, warnedLegacy, cachedSecretsPath, cachedSecrets;
9114
- var init_secrets_resolver = __esm({
9115
- "packages/tooling/src/utils/secrets-resolver.ts"() {
9116
- "use strict";
9117
- init_utils();
9118
- init_pathResolver();
9119
- init_cli_output();
9120
- LEGACY_PATHS = {
9121
- VERCEL_TOKEN: [".env.local"],
9122
- SUPABASE_SECRET_KEY: ["supabase/functions/.env", "functions/.env"],
9123
- SUPABASE_DB_URL: ["supabase/functions/.env", "functions/.env"],
9124
- SUPABASE_ACCESS_TOKEN: ["supabase/functions/.env", "functions/.env"],
9125
- STRIPE_SECRET_KEY: ["supabase/functions/.env", "functions/.env"],
9126
- STRIPE_WEBHOOK_SECRET: ["supabase/functions/.env", "functions/.env"]
9127
- };
9128
- warnedLegacy = /* @__PURE__ */ new Set();
9129
- cachedSecretsPath = null;
9130
- cachedSecrets = null;
9131
- }
9132
- });
9133
-
9134
- // packages/tooling/src/cli/setup/vercel-token.ts
9135
- function resolvePerAppVar(appDir, varName) {
9136
- if (process.env[varName]) return process.env[varName];
9137
- const fromLocal = readEnvVar(joinPath(appDir, ".env.local"), varName);
9138
- if (fromLocal) return fromLocal;
9139
- const fromEnv = readEnvVar(joinPath(appDir, ".env"), varName);
9140
- if (fromEnv) return fromEnv;
9141
- return null;
9142
- }
9143
- function resolveVercelCredentials(appDir, projectRoot) {
9144
- const root = projectRoot ?? process.cwd();
9145
- const token = resolveSecret("VERCEL_TOKEN", root, { appDir })?.value ?? null;
9146
- const orgId = resolvePerAppVar(appDir, "VERCEL_ORG_ID");
9147
- const projectId = resolvePerAppVar(appDir, "VERCEL_PROJECT_ID");
9148
- const missing = [];
9149
- if (!token) missing.push("VERCEL_TOKEN");
9150
- if (!orgId) missing.push("VERCEL_ORG_ID");
9151
- if (!projectId) missing.push("VERCEL_PROJECT_ID");
9152
- if (missing.length > 0) return { missing };
9153
- return {
9154
- credentials: { token, orgId, projectId }
9155
- };
9156
- }
9157
- var init_vercel_token = __esm({
9158
- "packages/tooling/src/cli/setup/vercel-token.ts"() {
9159
- "use strict";
9160
- init_utils();
9161
- init_secrets_resolver();
9162
- init_pathResolver();
9163
- }
9164
- });
9165
-
9166
9020
  // node_modules/.bun/yaml@2.8.2/node_modules/yaml/dist/nodes/identity.js
9167
9021
  var require_identity = __commonJS({
9168
9022
  "node_modules/.bun/yaml@2.8.2/node_modules/yaml/dist/nodes/identity.js"(exports) {
@@ -16547,59 +16401,288 @@ var init_error_handling = __esm({
16547
16401
  }
16548
16402
  });
16549
16403
 
16550
- // packages/tooling/src/apps/sync-secrets.ts
16551
- var sync_secrets_exports = {};
16552
- __export(sync_secrets_exports, {
16553
- default: () => sync_secrets_default,
16554
- detectGitHubRepo: () => detectGitHubRepo,
16555
- main: () => main5,
16556
- parseSecretsWithFallback: () => parseSecretsWithFallback,
16557
- setGitHubSecret: () => setGitHubSecret,
16558
- uploadServiceAccountToGitHub: () => uploadServiceAccountToGitHub
16559
- });
16560
- import { spawnSync as spawnSync8 } from "node:child_process";
16561
- function parseEnvFile2(filePath) {
16562
- if (!pathExists(filePath)) {
16563
- throw new DoNotDevError(
16564
- `Environment file not found: ${filePath}`,
16565
- "file-not-found",
16566
- { context: { filePath } }
16567
- );
16404
+ // packages/tooling/src/apps/vercel-api.ts
16405
+ function formatVercelError(status, body, context) {
16406
+ let vercelCode;
16407
+ let vercelMessage;
16408
+ try {
16409
+ const parsed = JSON.parse(body);
16410
+ const err = parsed.error ?? parsed;
16411
+ vercelCode = err.code;
16412
+ vercelMessage = err.message;
16413
+ } catch {
16568
16414
  }
16569
- const result = parseEnvFile(filePath);
16570
- if (Object.keys(result).length === 0) {
16571
- log.debug(`No key-value pairs found in ${filePath}`);
16415
+ let message;
16416
+ switch (status) {
16417
+ case 401:
16418
+ message = "Vercel token is invalid or expired. Generate a new one at https://vercel.com/account/tokens and update .dndev.secrets";
16419
+ break;
16420
+ case 403:
16421
+ if (vercelCode === "team_unauthorized" || body.includes("teamId")) {
16422
+ message = "Vercel token does not have access to this team. Hobby/free accounts: remove VERCEL_ORG_ID from your .env (it causes 403). Team accounts: ensure the token is scoped to the correct team.";
16423
+ } else {
16424
+ message = `Vercel access denied: ${vercelMessage ?? "check token scope and permissions"}`;
16425
+ }
16426
+ break;
16427
+ case 404:
16428
+ message = "Vercel project not found. Check VERCEL_PROJECT_ID in apps/<app>/.env \u2014 it should match the Project ID from Vercel Dashboard > Project > Settings > General.";
16429
+ break;
16430
+ case 400:
16431
+ if (vercelCode === "invalid_project_name") {
16432
+ message = "Vercel rejected the project name. This is a framework bug \u2014 please report it.";
16433
+ } else {
16434
+ message = `Vercel rejected the request: ${vercelMessage ?? body}`;
16435
+ }
16436
+ break;
16437
+ case 429:
16438
+ message = "Vercel rate limit hit. Wait a few minutes and try again.";
16439
+ break;
16440
+ default:
16441
+ message = `Vercel API error during ${context} (${status}): ${vercelMessage ?? body}`;
16572
16442
  }
16573
- return result;
16443
+ return new DoNotDevError(message, DO_NOT_DEV_ERROR_CODES.VERCEL_API_ERROR, {
16444
+ context: { status, vercelCode, context }
16445
+ });
16574
16446
  }
16575
- function parseSecretsWithFallback(envFilePath, projectRoot) {
16576
- const dndevSecretsPath = joinPath(projectRoot, ".dndev.secrets");
16577
- if (pathExists(dndevSecretsPath)) {
16578
- const secrets = parseEnvFile(dndevSecretsPath);
16579
- if (Object.keys(secrets).length > 0) {
16580
- log.info(`Reading secrets from: ${dndevSecretsPath}`);
16581
- return secrets;
16447
+ async function validateToken(token) {
16448
+ const res = await fetch(`${VERCEL_API}/v2/user`, {
16449
+ headers: { Authorization: `Bearer ${token}` }
16450
+ });
16451
+ if (!res.ok) {
16452
+ const body = await res.text();
16453
+ throw formatVercelError(res.status, body, "validate token");
16454
+ }
16455
+ const data = await res.json();
16456
+ return { username: data.user.username, email: data.user.email };
16457
+ }
16458
+ async function validateProject(token, projectId, orgId) {
16459
+ const q2 = orgId ? `?teamId=${encodeURIComponent(orgId)}` : "";
16460
+ const res = await fetch(
16461
+ `${VERCEL_API}/v9/projects/${encodeURIComponent(projectId)}${q2}`,
16462
+ {
16463
+ headers: { Authorization: `Bearer ${token}` }
16582
16464
  }
16465
+ );
16466
+ if (!res.ok) {
16467
+ const body = await res.text();
16468
+ throw formatVercelError(res.status, body, "validate project");
16583
16469
  }
16584
- return parseEnvFile2(envFilePath);
16470
+ const data = await res.json();
16471
+ return { projectName: data.name };
16585
16472
  }
16586
- function detectPlatform() {
16587
- const currentDir = process.cwd();
16588
- if (pathExists(joinPath(currentDir, "firebase.json"))) {
16589
- return "firebase";
16473
+ var VERCEL_API;
16474
+ var init_vercel_api = __esm({
16475
+ "packages/tooling/src/apps/vercel-api.ts"() {
16476
+ "use strict";
16477
+ init_utils();
16478
+ init_errors();
16479
+ VERCEL_API = "https://api.vercel.com";
16590
16480
  }
16591
- if (pathExists(joinPath(currentDir, "vercel.json")) || pathExists(joinPath(currentDir, ".vercel"))) {
16592
- return "vercel";
16481
+ });
16482
+
16483
+ // packages/tooling/src/utils/secrets-resolver.ts
16484
+ function parseEnvFile(filePath) {
16485
+ if (!pathExists(filePath)) return {};
16486
+ const content = readSync(filePath, { format: "text" });
16487
+ if (typeof content !== "string" || !content) return {};
16488
+ const result = {};
16489
+ for (const line of content.split(/\r?\n/)) {
16490
+ const trimmed = line.trim();
16491
+ if (!trimmed || trimmed.startsWith("#")) continue;
16492
+ const eqIdx = trimmed.indexOf("=");
16493
+ if (eqIdx === -1) continue;
16494
+ const key = trimmed.slice(0, eqIdx).trim();
16495
+ let value = trimmed.slice(eqIdx + 1).trim();
16496
+ if (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'")) {
16497
+ value = value.slice(1, -1);
16498
+ }
16499
+ if (key && value) {
16500
+ result[key] = value;
16501
+ }
16593
16502
  }
16594
- log.warn("No platform detected, defaulting to Firebase");
16595
- return "firebase";
16503
+ return result;
16596
16504
  }
16597
- function findFirebaseProjectDir(envFilePath) {
16598
- const currentDir = process.cwd();
16599
- const resolvedPath = joinPath(currentDir, envFilePath);
16600
- const envFileDir = getDirname(resolvedPath);
16601
- const appsMatch = envFileDir.match(/apps[\\/]([^\\/]+)[\\/]functions/);
16602
- if (appsMatch && appsMatch[1]) {
16505
+ function readEnvVar(filePath, varName) {
16506
+ if (!pathExists(filePath)) return null;
16507
+ const content = readSync(filePath, { format: "text" });
16508
+ if (typeof content !== "string") return null;
16509
+ for (const line of content.split(/\r?\n/)) {
16510
+ const trimmed = line.trim();
16511
+ if (!trimmed || trimmed.startsWith("#")) continue;
16512
+ if (trimmed.startsWith(`${varName}=`)) {
16513
+ let val = trimmed.substring(`${varName}=`.length).trim();
16514
+ if (val.startsWith('"') && val.endsWith('"') || val.startsWith("'") && val.endsWith("'")) {
16515
+ val = val.slice(1, -1);
16516
+ }
16517
+ return val || null;
16518
+ }
16519
+ }
16520
+ return null;
16521
+ }
16522
+ function loadDndevSecrets(projectRoot) {
16523
+ const secretsPath = joinPath(projectRoot, ".dndev.secrets");
16524
+ if (cachedSecretsPath === secretsPath && cachedSecrets) {
16525
+ return cachedSecrets;
16526
+ }
16527
+ cachedSecrets = parseEnvFile(secretsPath);
16528
+ cachedSecretsPath = secretsPath;
16529
+ return cachedSecrets;
16530
+ }
16531
+ function resolveSecret(name, projectRoot, opts) {
16532
+ const appDir = opts?.appDir ?? projectRoot;
16533
+ const secrets = loadDndevSecrets(projectRoot);
16534
+ if (secrets[name]) {
16535
+ return { value: secrets[name], source: ".dndev.secrets" };
16536
+ }
16537
+ if (name === "SUPABASE_SECRET_KEY" && secrets["SUPABASE_SERVICE_ROLE_KEY"]) {
16538
+ return {
16539
+ value: secrets["SUPABASE_SERVICE_ROLE_KEY"],
16540
+ source: ".dndev.secrets"
16541
+ };
16542
+ }
16543
+ const envValue = process.env[name];
16544
+ if (envValue) {
16545
+ return { value: envValue, source: "process.env" };
16546
+ }
16547
+ const legacyPaths = LEGACY_PATHS[name];
16548
+ if (legacyPaths) {
16549
+ for (const relPath of legacyPaths) {
16550
+ const fullPath = joinPath(appDir, relPath);
16551
+ const value = readEnvVar(fullPath, name);
16552
+ if (value) {
16553
+ if (!opts?.silent && !warnedLegacy.has(name)) {
16554
+ warnedLegacy.add(name);
16555
+ log.warn(
16556
+ `${name} found in ${relPath} (legacy). Move it to .dndev.secrets at project root.`
16557
+ );
16558
+ }
16559
+ return { value, source: "legacy", legacyPath: relPath };
16560
+ }
16561
+ if (name === "SUPABASE_SECRET_KEY") {
16562
+ const aliasValue = readEnvVar(fullPath, "SUPABASE_SERVICE_ROLE_KEY");
16563
+ if (aliasValue) {
16564
+ if (!opts?.silent && !warnedLegacy.has(name)) {
16565
+ warnedLegacy.add(name);
16566
+ log.warn(
16567
+ `${name} found in ${relPath} (legacy). Move it to .dndev.secrets at project root.`
16568
+ );
16569
+ }
16570
+ return { value: aliasValue, source: "legacy", legacyPath: relPath };
16571
+ }
16572
+ }
16573
+ }
16574
+ }
16575
+ return null;
16576
+ }
16577
+ var LEGACY_PATHS, warnedLegacy, cachedSecretsPath, cachedSecrets;
16578
+ var init_secrets_resolver = __esm({
16579
+ "packages/tooling/src/utils/secrets-resolver.ts"() {
16580
+ "use strict";
16581
+ init_utils();
16582
+ init_cli_output();
16583
+ init_pathResolver();
16584
+ LEGACY_PATHS = {
16585
+ VERCEL_TOKEN: [".env.local"],
16586
+ SUPABASE_SECRET_KEY: ["supabase/functions/.env", "functions/.env"],
16587
+ SUPABASE_DB_URL: ["supabase/functions/.env", "functions/.env"],
16588
+ SUPABASE_ACCESS_TOKEN: ["supabase/functions/.env", "functions/.env"],
16589
+ STRIPE_SECRET_KEY: ["supabase/functions/.env", "functions/.env"],
16590
+ STRIPE_WEBHOOK_SECRET: ["supabase/functions/.env", "functions/.env"]
16591
+ };
16592
+ warnedLegacy = /* @__PURE__ */ new Set();
16593
+ cachedSecretsPath = null;
16594
+ cachedSecrets = null;
16595
+ }
16596
+ });
16597
+
16598
+ // packages/tooling/src/cli/setup/vercel-token.ts
16599
+ function resolvePerAppVar(appDir, varName) {
16600
+ const fromLocal = readEnvVar(joinPath(appDir, ".env.local"), varName);
16601
+ if (fromLocal) return fromLocal;
16602
+ const fromEnv = readEnvVar(joinPath(appDir, ".env"), varName);
16603
+ if (fromEnv) return fromEnv;
16604
+ if (process.env[varName]) return process.env[varName];
16605
+ return null;
16606
+ }
16607
+ function resolveVercelCredentials(appDir, projectRoot) {
16608
+ const root = projectRoot ?? process.cwd();
16609
+ const token = resolveSecret("VERCEL_TOKEN", root, { appDir })?.value ?? null;
16610
+ const orgId = resolvePerAppVar(appDir, "VERCEL_ORG_ID");
16611
+ const projectId = resolvePerAppVar(appDir, "VERCEL_PROJECT_ID");
16612
+ const missing = [];
16613
+ if (!token) missing.push("VERCEL_TOKEN");
16614
+ if (!projectId) missing.push("VERCEL_PROJECT_ID");
16615
+ if (missing.length > 0) return { missing };
16616
+ return {
16617
+ credentials: {
16618
+ token,
16619
+ orgId: orgId ?? void 0,
16620
+ projectId
16621
+ }
16622
+ };
16623
+ }
16624
+ var init_vercel_token = __esm({
16625
+ "packages/tooling/src/cli/setup/vercel-token.ts"() {
16626
+ "use strict";
16627
+ init_utils();
16628
+ init_pathResolver();
16629
+ init_secrets_resolver();
16630
+ }
16631
+ });
16632
+
16633
+ // packages/tooling/src/apps/sync-secrets.ts
16634
+ var sync_secrets_exports = {};
16635
+ __export(sync_secrets_exports, {
16636
+ default: () => sync_secrets_default,
16637
+ detectGitHubRepo: () => detectGitHubRepo,
16638
+ main: () => main5,
16639
+ parseSecretsWithFallback: () => parseSecretsWithFallback,
16640
+ setGitHubSecret: () => setGitHubSecret,
16641
+ uploadServiceAccountToGitHub: () => uploadServiceAccountToGitHub
16642
+ });
16643
+ import { spawnSync as spawnSync8 } from "node:child_process";
16644
+ function parseEnvFile2(filePath) {
16645
+ if (!pathExists(filePath)) {
16646
+ throw new DoNotDevError(
16647
+ `Environment file not found: ${filePath}`,
16648
+ "file-not-found",
16649
+ { context: { filePath } }
16650
+ );
16651
+ }
16652
+ const result = parseEnvFile(filePath);
16653
+ if (Object.keys(result).length === 0) {
16654
+ log.debug(`No key-value pairs found in ${filePath}`);
16655
+ }
16656
+ return result;
16657
+ }
16658
+ function parseSecretsWithFallback(envFilePath, projectRoot) {
16659
+ const dndevSecretsPath = joinPath(projectRoot, ".dndev.secrets");
16660
+ if (pathExists(dndevSecretsPath)) {
16661
+ const secrets = parseEnvFile(dndevSecretsPath);
16662
+ if (Object.keys(secrets).length > 0) {
16663
+ log.info(`Reading secrets from: ${dndevSecretsPath}`);
16664
+ return secrets;
16665
+ }
16666
+ }
16667
+ return parseEnvFile2(envFilePath);
16668
+ }
16669
+ function detectPlatform() {
16670
+ const currentDir = process.cwd();
16671
+ if (pathExists(joinPath(currentDir, "firebase.json"))) {
16672
+ return "firebase";
16673
+ }
16674
+ if (pathExists(joinPath(currentDir, "vercel.json")) || pathExists(joinPath(currentDir, ".vercel"))) {
16675
+ return "vercel";
16676
+ }
16677
+ log.warn("No platform detected, defaulting to Firebase");
16678
+ return "firebase";
16679
+ }
16680
+ function findFirebaseProjectDir(envFilePath) {
16681
+ const currentDir = process.cwd();
16682
+ const resolvedPath = joinPath(currentDir, envFilePath);
16683
+ const envFileDir = getDirname(resolvedPath);
16684
+ const appsMatch = envFileDir.match(/apps[\\/]([^\\/]+)[\\/]functions/);
16685
+ if (appsMatch && appsMatch[1]) {
16603
16686
  const appDir = joinPath(currentDir, "apps", appsMatch[1]);
16604
16687
  if (pathExists(joinPath(appDir, "firebase.json"))) {
16605
16688
  return appDir;
@@ -17063,11 +17146,11 @@ Examples:
17063
17146
  }
17064
17147
  return 0;
17065
17148
  }
17066
- const platform6 = config.platform || detectPlatform();
17149
+ const platform7 = config.platform || detectPlatform();
17067
17150
  if (config.verbose) {
17068
17151
  log.debug(`Working directory: ${currentDir}`);
17069
17152
  log.debug(`Environment file: ${envFilePath}`);
17070
- log.debug(`Platform: ${platform6}`);
17153
+ log.debug(`Platform: ${platform7}`);
17071
17154
  log.debug(`Dry run mode: ${config.dryRun}`);
17072
17155
  }
17073
17156
  const secrets = parseSecretsWithFallback(envFilePath, currentDir);
@@ -17076,7 +17159,7 @@ Examples:
17076
17159
  log.info("No secrets found in .env file");
17077
17160
  return 0;
17078
17161
  }
17079
- log.info(`Found ${secretKeys.length} secrets to sync to ${platform6}:`);
17162
+ log.info(`Found ${secretKeys.length} secrets to sync to ${platform7}:`);
17080
17163
  secretKeys.forEach((key) => {
17081
17164
  if (config.verbose) {
17082
17165
  const value = secrets[key];
@@ -17087,12 +17170,12 @@ Examples:
17087
17170
  log.info(` ${key}`);
17088
17171
  }
17089
17172
  });
17090
- const finalFirebaseProjectDir = platform6 === "firebase" ? firebaseProjectDir || findFirebaseProjectDir(config.envFile) : void 0;
17173
+ const finalFirebaseProjectDir = platform7 === "firebase" ? firebaseProjectDir || findFirebaseProjectDir(config.envFile) : void 0;
17091
17174
  if (config.verbose && finalFirebaseProjectDir) {
17092
17175
  log.debug(`Firebase project directory: ${finalFirebaseProjectDir}`);
17093
17176
  }
17094
17177
  for (const [key, value] of Object.entries(secrets)) {
17095
- if (platform6 === "firebase") {
17178
+ if (platform7 === "firebase") {
17096
17179
  await setFirebaseSecret(
17097
17180
  key,
17098
17181
  value,
@@ -17100,18 +17183,18 @@ Examples:
17100
17183
  config.dryRun,
17101
17184
  finalFirebaseProjectDir
17102
17185
  );
17103
- } else if (platform6 === "vercel") {
17186
+ } else if (platform7 === "vercel") {
17104
17187
  setVercelSecret(key, value, config.vercelProjectId, config.dryRun);
17105
17188
  }
17106
17189
  }
17107
17190
  if (config.dryRun) {
17108
17191
  log.success(
17109
17192
  `
17110
- Dry run completed. No secrets were actually set to ${platform6}.`
17193
+ Dry run completed. No secrets were actually set to ${platform7}.`
17111
17194
  );
17112
17195
  } else {
17113
17196
  log.success(`
17114
- All secrets synced successfully to ${platform6}!`);
17197
+ All secrets synced successfully to ${platform7}!`);
17115
17198
  }
17116
17199
  return 0;
17117
17200
  } catch (err) {
@@ -17205,10 +17288,10 @@ var init_deploy_supabase_functions = __esm({
17205
17288
  "packages/tooling/src/apps/deploy-supabase-functions.ts"() {
17206
17289
  "use strict";
17207
17290
  init_utils();
17208
- init_pathResolver();
17209
17291
  init_cli_output();
17210
17292
  init_cli_tools();
17211
17293
  init_errors();
17294
+ init_pathResolver();
17212
17295
  }
17213
17296
  });
17214
17297
 
@@ -17421,21 +17504,37 @@ init_app_selector();
17421
17504
  init_cli_output();
17422
17505
  init_errors();
17423
17506
  init_pathResolver();
17424
- import { spawn, execSync as execSync3 } from "node:child_process";
17425
- import { platform } from "node:os";
17507
+ import { execSync as execSync3 } from "node:child_process";
17508
+ import { platform as platform2 } from "node:os";
17426
17509
 
17427
17510
  // packages/tooling/src/utils/spawn-utils.ts
17428
17511
  init_utils();
17429
17512
  init_cli_output();
17430
17513
  init_errors();
17431
17514
  init_pathResolver();
17432
- import { spawnSync as spawnSync2, execSync as execSync2 } from "node:child_process";
17515
+ import {
17516
+ spawn,
17517
+ spawnSync as spawnSync2,
17518
+ execSync as execSync2
17519
+ } from "node:child_process";
17520
+ import { platform } from "node:os";
17433
17521
  function createAppEnv(appPath) {
17434
17522
  return {
17435
17523
  ...process.env,
17436
17524
  DNDEV_APP_ROOT: appPath
17437
17525
  };
17438
17526
  }
17527
+ function spawnCrossPlatform(command, args, options) {
17528
+ const isWindows = platform() === "win32";
17529
+ const useShell = options.shell ?? isWindows;
17530
+ if (useShell) {
17531
+ const fullCommand = `${command} ${args.join(" ")}`;
17532
+ const { shell: _4, ...rest2 } = options;
17533
+ return spawn(fullCommand, [], { ...rest2, shell: true });
17534
+ }
17535
+ const { shell: _3, ...rest } = options;
17536
+ return spawn(command, args, rest);
17537
+ }
17439
17538
  function createEmulatorEnv(appPath, framework = "vite", options) {
17440
17539
  const baseEnv = createAppEnv(appPath);
17441
17540
  const prefix = framework === "nextjs" ? "NEXT_PUBLIC_" : "VITE_";
@@ -17490,7 +17589,10 @@ function executeFirebaseCommand(args, options) {
17490
17589
  env: deployEnv
17491
17590
  };
17492
17591
  let result;
17493
- result = spawnSync2("firebase", args, { ...spawnOptions, shell: true });
17592
+ result = spawnSync2(`firebase ${args.join(" ")}`, {
17593
+ ...spawnOptions,
17594
+ shell: true
17595
+ });
17494
17596
  if (result.error) {
17495
17597
  return {
17496
17598
  success: false,
@@ -17605,13 +17707,16 @@ async function main2() {
17605
17707
  log.info(`Starting dev server for ${app.name}...
17606
17708
  `);
17607
17709
  const turboArgs = ["dev", "--filter", app.packageName];
17608
- const isWindows = platform() === "win32";
17609
- const childProcess = spawn("bunx", ["turbo", ...turboArgs], {
17610
- stdio: "inherit",
17611
- env: createAppEnv(app.path),
17612
- cwd: projectRoot,
17613
- shell: isWindows
17614
- });
17710
+ const isWindows = platform2() === "win32";
17711
+ const childProcess = spawnCrossPlatform(
17712
+ "bunx",
17713
+ ["turbo", ...turboArgs],
17714
+ {
17715
+ stdio: "inherit",
17716
+ env: createAppEnv(app.path),
17717
+ cwd: projectRoot
17718
+ }
17719
+ );
17615
17720
  const cleanup = (signal) => {
17616
17721
  if (!childProcess.pid) return;
17617
17722
  log.debug(`Received ${signal}, cleaning up processes...`);
@@ -17668,23 +17773,19 @@ async function main2() {
17668
17773
 
17669
17774
  // packages/tooling/src/apps/emu.ts
17670
17775
  init_utils();
17671
- init_app_selector();
17672
- init_cli_output();
17673
- init_errors();
17674
- init_pathResolver();
17675
17776
 
17676
17777
  // packages/tooling/src/apps/emu-firebase.ts
17677
17778
  init_utils();
17678
17779
  init_cli_input();
17679
17780
  init_cli_output();
17680
17781
  init_pathResolver();
17681
- init_typed_file_operations();
17682
17782
  import {
17683
17783
  spawn as spawn2,
17684
17784
  spawnSync as spawnSync3,
17685
17785
  execSync as execSync4
17686
17786
  } from "node:child_process";
17687
- import { platform as platform2 } from "node:os";
17787
+ import { platform as platform3 } from "node:os";
17788
+ init_typed_file_operations();
17688
17789
  function discoverFirebaseProjectId(appPath) {
17689
17790
  const firebasercPath = joinPath(appPath, ".firebaserc");
17690
17791
  if (pathExists(firebasercPath)) {
@@ -17940,7 +18041,7 @@ FIREBASE_AUTH_EMULATOR_HOST=${authEmulatorHost}
17940
18041
  log.info(" stripe trigger checkout.session.completed");
17941
18042
  log.info("");
17942
18043
  }
17943
- const isWindows = platform2() === "win32";
18044
+ const isWindows = platform3() === "win32";
17944
18045
  const childProcess = spawn2(
17945
18046
  "bunx",
17946
18047
  ["concurrently", ...concurrentlyArgs],
@@ -18016,7 +18117,7 @@ FIREBASE_AUTH_EMULATOR_HOST=${authEmulatorHost}
18016
18117
  init_utils();
18017
18118
  init_cli_output();
18018
18119
  import { spawn as spawn3, execSync as execSync5 } from "node:child_process";
18019
- import { platform as platform3 } from "node:os";
18120
+ import { platform as platform4 } from "node:os";
18020
18121
  function isDockerRunning() {
18021
18122
  try {
18022
18123
  execSync5("docker info", { stdio: "pipe", timeout: 5e3 });
@@ -18040,7 +18141,7 @@ async function startSupabase(app, _projectRoot) {
18040
18141
  log.error(" bun install -g supabase\n");
18041
18142
  return 1;
18042
18143
  }
18043
- const isWindows = platform3() === "win32";
18144
+ const isWindows = platform4() === "win32";
18044
18145
  const concurrentlyArgs = [
18045
18146
  "--kill-others-on-fail",
18046
18147
  "--prefix-colors",
@@ -18099,7 +18200,7 @@ async function startSupabase(app, _projectRoot) {
18099
18200
  init_utils();
18100
18201
  init_cli_output();
18101
18202
  import { spawn as spawn4, execSync as execSync6 } from "node:child_process";
18102
- import { platform as platform4 } from "node:os";
18203
+ import { platform as platform5 } from "node:os";
18103
18204
  async function startVercel(app, _projectRoot) {
18104
18205
  log.info(`Starting Vercel dev server for ${app.name}...
18105
18206
  `);
@@ -18110,7 +18211,7 @@ async function startVercel(app, _projectRoot) {
18110
18211
  log.error(" bun install -g vercel\n");
18111
18212
  return 1;
18112
18213
  }
18113
- const isWindows = platform4() === "win32";
18214
+ const isWindows = platform5() === "win32";
18114
18215
  const childProcess = spawn4("vercel", ["dev"], {
18115
18216
  stdio: "inherit",
18116
18217
  cwd: app.path,
@@ -18151,6 +18252,10 @@ async function startVercel(app, _projectRoot) {
18151
18252
  }
18152
18253
 
18153
18254
  // packages/tooling/src/apps/emu.ts
18255
+ init_app_selector();
18256
+ init_cli_output();
18257
+ init_errors();
18258
+ init_pathResolver();
18154
18259
  async function main3(options) {
18155
18260
  const args = process.argv.slice(2);
18156
18261
  const projectRoot = getRepoRoot();
@@ -18227,11 +18332,10 @@ init_cli_output();
18227
18332
  init_errors();
18228
18333
  init_pathResolver();
18229
18334
  import {
18230
- spawn as spawn5,
18231
18335
  spawnSync as spawnSync4,
18232
18336
  execSync as execSync7
18233
18337
  } from "node:child_process";
18234
- import { platform as platform5 } from "node:os";
18338
+ import { platform as platform6 } from "node:os";
18235
18339
  var SIGNAL_EXIT_CODES2 = {
18236
18340
  SIGINT: 130,
18237
18341
  // 128 + 2
@@ -18274,13 +18378,16 @@ async function main4() {
18274
18378
  log.info(`Previewing ${app.name}...
18275
18379
  `);
18276
18380
  const turboArgs = ["preview", "--filter", app.packageName];
18277
- const isWindows = platform5() === "win32";
18278
- const childProcess = spawn5("bunx", ["turbo", ...turboArgs], {
18279
- stdio: "inherit",
18280
- env: createAppEnv(app.path),
18281
- cwd: projectRoot,
18282
- shell: isWindows
18283
- });
18381
+ const isWindows = platform6() === "win32";
18382
+ const childProcess = spawnCrossPlatform(
18383
+ "bunx",
18384
+ ["turbo", ...turboArgs],
18385
+ {
18386
+ stdio: "inherit",
18387
+ env: createAppEnv(app.path),
18388
+ cwd: projectRoot
18389
+ }
18390
+ );
18284
18391
  const cleanup = (signal) => {
18285
18392
  if (!childProcess.pid) return;
18286
18393
  log.debug(`Received ${signal}, cleaning up processes...`);
@@ -18881,182 +18988,12 @@ async function deployFrontend(appDir, serviceAccountPath, projectId, config) {
18881
18988
  s.stop("Frontend deployed successfully");
18882
18989
  }
18883
18990
 
18884
- // packages/tooling/src/apps/deploy-vercel-frontend.ts
18991
+ // packages/tooling/src/apps/deploy-functions.ts
18885
18992
  init_utils();
18886
- init_cli_output();
18887
- init_vercel_token();
18993
+ var import_yaml = __toESM(require_dist(), 1);
18994
+ import { execSync as execSync8, spawnSync as spawnSync6 } from "node:child_process";
18995
+ init_cli_tools();
18888
18996
  init_pathResolver();
18889
- import { createHash } from "node:crypto";
18890
- import { readFile, readdir as readdir2 } from "node:fs/promises";
18891
- import { join as join3, relative as relative3 } from "node:path";
18892
- var VERCEL_API = "https://api.vercel.com";
18893
- var UPLOAD_BATCH_SIZE = 10;
18894
- var POLL_INTERVAL_MS = 3e3;
18895
- var POLL_MAX_ATTEMPTS = 100;
18896
- function apiHeaders(token, extra) {
18897
- return { Authorization: `Bearer ${token}`, ...extra };
18898
- }
18899
- function teamQuery(orgId) {
18900
- return `?teamId=${encodeURIComponent(orgId)}`;
18901
- }
18902
- async function collectDistFiles(distDir) {
18903
- const files = [];
18904
- async function walk(dir) {
18905
- const entries = await readdir2(dir, { withFileTypes: true });
18906
- for (const entry of entries) {
18907
- const fullPath = join3(dir, entry.name);
18908
- if (entry.isDirectory()) {
18909
- await walk(fullPath);
18910
- } else {
18911
- const content = await readFile(fullPath);
18912
- const sha = createHash("sha1").update(content).digest("hex");
18913
- const rel = relative3(distDir, fullPath).split("\\").join("/");
18914
- files.push({
18915
- relativePath: rel,
18916
- content,
18917
- sha,
18918
- size: content.byteLength
18919
- });
18920
- }
18921
- }
18922
- }
18923
- await walk(distDir);
18924
- return files;
18925
- }
18926
- async function uploadFiles(files, token, orgId) {
18927
- const q2 = teamQuery(orgId);
18928
- for (let i = 0; i < files.length; i += UPLOAD_BATCH_SIZE) {
18929
- const batch = files.slice(i, i + UPLOAD_BATCH_SIZE);
18930
- await Promise.all(
18931
- batch.map(async (file) => {
18932
- const res = await fetch(`${VERCEL_API}/v2/files${q2}`, {
18933
- method: "POST",
18934
- headers: apiHeaders(token, {
18935
- "Content-Type": "application/octet-stream",
18936
- "x-vercel-digest": file.sha,
18937
- "Content-Length": String(file.size)
18938
- }),
18939
- body: new Uint8Array(file.content)
18940
- });
18941
- if (!res.ok) {
18942
- const body = await res.text();
18943
- log.warn(`Upload failed: ${file.relativePath} (${res.status})`);
18944
- log.warn(` URL: ${VERCEL_API}/v2/files${q2}`);
18945
- log.warn(` SHA: ${file.sha}, Size: ${file.size}`);
18946
- log.warn(` Response: ${body}`);
18947
- throw new Error(
18948
- `File upload failed for ${file.relativePath} (${res.status}): ${body}`
18949
- );
18950
- }
18951
- })
18952
- );
18953
- }
18954
- }
18955
- async function createDeployment(files, token, orgId, projectId) {
18956
- const q2 = teamQuery(orgId);
18957
- const body = {
18958
- name: projectId,
18959
- project: projectId,
18960
- target: "production",
18961
- files: files.map((f) => ({
18962
- file: f.relativePath,
18963
- sha: f.sha,
18964
- size: f.size
18965
- })),
18966
- projectSettings: {
18967
- buildCommand: "",
18968
- installCommand: "",
18969
- outputDirectory: "."
18970
- }
18971
- };
18972
- const res = await fetch(`${VERCEL_API}/v13/deployments${q2}`, {
18973
- method: "POST",
18974
- headers: apiHeaders(token, { "Content-Type": "application/json" }),
18975
- body: JSON.stringify(body)
18976
- });
18977
- if (!res.ok) {
18978
- const text = await res.text();
18979
- throw new Error(`Create deployment failed (${res.status}): ${text}`);
18980
- }
18981
- return await res.json();
18982
- }
18983
- async function waitForReady(deploymentId, token, orgId) {
18984
- const q2 = teamQuery(orgId);
18985
- for (let attempt = 0; attempt < POLL_MAX_ATTEMPTS; attempt++) {
18986
- const res = await fetch(
18987
- `${VERCEL_API}/v13/deployments/${deploymentId}${q2}`,
18988
- { headers: apiHeaders(token) }
18989
- );
18990
- if (!res.ok) {
18991
- const text = await res.text();
18992
- throw new Error(
18993
- `Deployment status check failed (${res.status}): ${text}`
18994
- );
18995
- }
18996
- const data = await res.json();
18997
- if (data.readyState === "READY") return data;
18998
- if (data.readyState === "ERROR") {
18999
- throw new Error(
19000
- `Deployment failed: ${data.errorMessage || "Unknown error"}`
19001
- );
19002
- }
19003
- if (data.readyState === "CANCELED") {
19004
- throw new Error("Deployment was canceled");
19005
- }
19006
- await new Promise((r2) => setTimeout(r2, POLL_INTERVAL_MS));
19007
- }
19008
- throw new Error("Deployment timed out (5+ minutes)");
19009
- }
19010
- async function deployVercelFrontend(appDir, _config) {
19011
- const result = resolveVercelCredentials(appDir);
19012
- if (result.missing) {
19013
- const secretVars = result.missing.filter((v2) => v2 === "VERCEL_TOKEN");
19014
- const appVars = result.missing.filter((v2) => v2 !== "VERCEL_TOKEN");
19015
- const hints = [];
19016
- if (secretVars.length > 0)
19017
- hints.push("Add VERCEL_TOKEN to .dndev.secrets at project root.");
19018
- if (appVars.length > 0)
19019
- hints.push(`Add ${appVars.join(", ")} to apps/<app>/.env`);
19020
- throw new Error(
19021
- `Missing Vercel credentials: ${result.missing.join(", ")}
19022
- ` + hints.join("\n") + "\nSee guides/dndev/SETUP_VERCEL.md"
19023
- );
19024
- }
19025
- const { token, orgId, projectId } = result.credentials;
19026
- const distDir = joinPath(appDir, "dist");
19027
- if (!pathExists(distDir)) {
19028
- throw new Error(`dist/ not found at ${distDir}. Run build first.`);
19029
- }
19030
- log.debug("Using Vercel REST API (token-based, no CLI)");
19031
- log.info(`Vercel org: ${orgId}`);
19032
- log.info(`Vercel project: ${projectId}`);
19033
- log.info(`Token: ${token.slice(0, 6)}...${token.slice(-4)} (${token.length} chars)`);
19034
- log.info("Collecting dist/ files...");
19035
- const files = await collectDistFiles(distDir);
19036
- if (files.length === 0) {
19037
- throw new Error("dist/ is empty \u2014 nothing to deploy.");
19038
- }
19039
- log.info(`Found ${files.length} files`);
19040
- log.info("Uploading files to Vercel...");
19041
- await uploadFiles(files, token, orgId);
19042
- log.success(`${files.length} files uploaded`);
19043
- log.info("Creating production deployment...");
19044
- const deployment = await createDeployment(files, token, orgId, projectId);
19045
- log.info(`Deployment ${deployment.id} created, waiting...`);
19046
- const ready = await waitForReady(deployment.id, token, orgId);
19047
- const prodUrl = `https://${ready.url}`;
19048
- log.success(`Production: ${prodUrl}`);
19049
- if (ready.alias?.length) {
19050
- log.info(`Aliases: ${ready.alias.join(", ")}`);
19051
- }
19052
- }
19053
-
19054
- // packages/tooling/src/apps/deploy-functions.ts
19055
- init_utils();
19056
- var import_yaml = __toESM(require_dist(), 1);
19057
- import { execSync as execSync8, spawnSync as spawnSync6 } from "node:child_process";
19058
- init_pathResolver();
19059
- init_cli_tools();
19060
18997
  init_typed_file_operations();
19061
18998
  function backupFiles(functionsDir) {
19062
18999
  const backupDir = joinPath(functionsDir, ".deploy-backup");
@@ -19547,9 +19484,9 @@ async function deployRules(appDir, serviceAccountPath, projectId, config, option
19547
19484
  // packages/tooling/src/apps/deploy-utils.ts
19548
19485
  init_utils();
19549
19486
  import { spawnSync as spawnSync7 } from "node:child_process";
19487
+ init_error_handling();
19550
19488
  init_pathResolver();
19551
19489
  init_typed_file_operations();
19552
- init_error_handling();
19553
19490
  function detectAvailableApps() {
19554
19491
  const currentDir = process.cwd();
19555
19492
  const appsDir = joinPath(currentDir, "apps");
@@ -19734,7 +19671,7 @@ How to fix:
19734
19671
  if (shouldOpen) {
19735
19672
  try {
19736
19673
  const openCommand = process.platform === "win32" ? "start" : process.platform === "darwin" ? "open" : "xdg-open";
19737
- spawnSync7(openCommand, [consoleUrl], { shell: true });
19674
+ spawnSync7(`${openCommand} ${consoleUrl}`, { shell: true });
19738
19675
  log.success("Opening Firebase Console...");
19739
19676
  } catch {
19740
19677
  log.warn("Could not open browser. Please open the URL manually.");
@@ -19782,6 +19719,195 @@ function clearFirebaseCache(appDir) {
19782
19719
  }
19783
19720
  }
19784
19721
 
19722
+ // packages/tooling/src/apps/deploy-vercel-frontend.ts
19723
+ init_utils();
19724
+ init_vercel_api();
19725
+ init_vercel_token();
19726
+ init_cli_output();
19727
+ init_pathResolver();
19728
+ import { createHash } from "node:crypto";
19729
+ import { readFile, readdir as readdir2 } from "node:fs/promises";
19730
+ import { join as join3, relative as relative3 } from "node:path";
19731
+ var VERCEL_API2 = "https://api.vercel.com";
19732
+ var UPLOAD_BATCH_SIZE = 10;
19733
+ var POLL_INTERVAL_MS = 3e3;
19734
+ var POLL_MAX_ATTEMPTS = 100;
19735
+ function apiHeaders(token, extra) {
19736
+ return { Authorization: `Bearer ${token}`, ...extra };
19737
+ }
19738
+ function teamQuery(orgId) {
19739
+ if (!orgId) return "";
19740
+ return `?teamId=${encodeURIComponent(orgId)}`;
19741
+ }
19742
+ async function collectDistFiles(distDir) {
19743
+ const files = [];
19744
+ async function walk(dir) {
19745
+ const entries = await readdir2(dir, { withFileTypes: true });
19746
+ for (const entry of entries) {
19747
+ const fullPath = join3(dir, entry.name);
19748
+ if (entry.isDirectory()) {
19749
+ await walk(fullPath);
19750
+ } else {
19751
+ const content = await readFile(fullPath);
19752
+ const sha = createHash("sha1").update(content).digest("hex");
19753
+ const rel = relative3(distDir, fullPath).split("\\").join("/");
19754
+ files.push({
19755
+ relativePath: rel,
19756
+ content,
19757
+ sha,
19758
+ size: content.byteLength
19759
+ });
19760
+ }
19761
+ }
19762
+ }
19763
+ await walk(distDir);
19764
+ return files;
19765
+ }
19766
+ async function uploadFiles(files, token, orgId) {
19767
+ const q2 = teamQuery(orgId);
19768
+ for (let i = 0; i < files.length; i += UPLOAD_BATCH_SIZE) {
19769
+ const batch = files.slice(i, i + UPLOAD_BATCH_SIZE);
19770
+ await Promise.all(
19771
+ batch.map(async (file) => {
19772
+ const res = await fetch(`${VERCEL_API2}/v2/files${q2}`, {
19773
+ method: "POST",
19774
+ headers: apiHeaders(token, {
19775
+ "Content-Type": "application/octet-stream",
19776
+ "x-vercel-digest": file.sha,
19777
+ "Content-Length": String(file.size)
19778
+ }),
19779
+ body: new Uint8Array(file.content)
19780
+ });
19781
+ if (!res.ok) {
19782
+ const body = await res.text();
19783
+ throw formatVercelError(
19784
+ res.status,
19785
+ body,
19786
+ `upload file ${file.relativePath}`
19787
+ );
19788
+ }
19789
+ })
19790
+ );
19791
+ }
19792
+ }
19793
+ async function createDeployment(files, token, orgId, projectId, projectName) {
19794
+ const q2 = teamQuery(orgId);
19795
+ const body = {
19796
+ name: projectName,
19797
+ project: projectId,
19798
+ target: "production",
19799
+ files: files.map((f) => ({
19800
+ file: f.relativePath,
19801
+ sha: f.sha,
19802
+ size: f.size
19803
+ })),
19804
+ projectSettings: {
19805
+ buildCommand: "",
19806
+ installCommand: "",
19807
+ outputDirectory: "."
19808
+ }
19809
+ };
19810
+ const res = await fetch(`${VERCEL_API2}/v13/deployments${q2}`, {
19811
+ method: "POST",
19812
+ headers: apiHeaders(token, { "Content-Type": "application/json" }),
19813
+ body: JSON.stringify(body)
19814
+ });
19815
+ if (!res.ok) {
19816
+ const text = await res.text();
19817
+ throw formatVercelError(res.status, text, "create deployment");
19818
+ }
19819
+ return await res.json();
19820
+ }
19821
+ async function waitForReady(deploymentId, token, orgId) {
19822
+ const q2 = teamQuery(orgId);
19823
+ for (let attempt = 0; attempt < POLL_MAX_ATTEMPTS; attempt++) {
19824
+ const res = await fetch(
19825
+ `${VERCEL_API2}/v13/deployments/${deploymentId}${q2}`,
19826
+ { headers: apiHeaders(token) }
19827
+ );
19828
+ if (!res.ok) {
19829
+ const text = await res.text();
19830
+ throw formatVercelError(res.status, text, "check deployment status");
19831
+ }
19832
+ const data = await res.json();
19833
+ if (data.readyState === "READY") return data;
19834
+ if (data.readyState === "ERROR") {
19835
+ throw new Error(
19836
+ `Deployment failed: ${data.errorMessage || "Unknown error"}`
19837
+ );
19838
+ }
19839
+ if (data.readyState === "CANCELED") {
19840
+ throw new Error("Deployment was canceled");
19841
+ }
19842
+ await new Promise((r2) => setTimeout(r2, POLL_INTERVAL_MS));
19843
+ }
19844
+ throw new Error("Deployment timed out (5+ minutes)");
19845
+ }
19846
+ async function deployVercelFrontend(appDir, _config) {
19847
+ const result = resolveVercelCredentials(appDir);
19848
+ if (result.missing) {
19849
+ const secretVars = result.missing.filter((v2) => v2 === "VERCEL_TOKEN");
19850
+ const appVars = result.missing.filter((v2) => v2 !== "VERCEL_TOKEN");
19851
+ const hints = [];
19852
+ if (secretVars.length > 0)
19853
+ hints.push("Add VERCEL_TOKEN to .dndev.secrets at project root.");
19854
+ if (appVars.length > 0)
19855
+ hints.push(`Add ${appVars.join(", ")} to apps/<app>/.env`);
19856
+ throw new Error(
19857
+ `Missing Vercel credentials: ${result.missing.join(", ")}
19858
+ ` + hints.join("\n") + "\nSee guides/dndev/SETUP_VERCEL.md"
19859
+ );
19860
+ }
19861
+ const { token, orgId, projectId } = result.credentials;
19862
+ const distDir = joinPath(appDir, "dist");
19863
+ if (!pathExists(distDir)) {
19864
+ throw new Error(`dist/ not found at ${distDir}. Run build first.`);
19865
+ }
19866
+ log.debug("Using Vercel REST API (token-based, no CLI)");
19867
+ log.info(`Vercel org: ${orgId ?? "(personal account)"}`);
19868
+ log.info(`Vercel project: ${projectId}`);
19869
+ log.info(
19870
+ `Token: ${token.slice(0, 6)}...${token.slice(-4)} (${token.length} chars)`
19871
+ );
19872
+ log.info("Validating Vercel credentials...");
19873
+ const user = await validateToken(token);
19874
+ log.success(`Token valid (${user.username})`);
19875
+ const project = await validateProject(token, projectId, orgId);
19876
+ log.success(`Project accessible (${project.projectName})`);
19877
+ log.info("Collecting dist/ files...");
19878
+ const files = await collectDistFiles(distDir);
19879
+ if (files.length === 0) {
19880
+ throw new Error("dist/ is empty \u2014 nothing to deploy.");
19881
+ }
19882
+ log.info(`Found ${files.length} files`);
19883
+ log.info("Uploading files to Vercel...");
19884
+ await uploadFiles(files, token, orgId);
19885
+ log.success(`${files.length} files uploaded`);
19886
+ log.info("Creating production deployment...");
19887
+ const deployment = await createDeployment(
19888
+ files,
19889
+ token,
19890
+ orgId,
19891
+ projectId,
19892
+ project.projectName
19893
+ );
19894
+ log.info(`Deployment ${deployment.id} created, waiting...`);
19895
+ const ready = await waitForReady(deployment.id, token, orgId);
19896
+ const prodUrl = `https://${ready.url}`;
19897
+ log.success(`Production: ${prodUrl}`);
19898
+ if (ready.alias?.length) {
19899
+ log.info(`Aliases: ${ready.alias.join(", ")}`);
19900
+ }
19901
+ }
19902
+
19903
+ // packages/tooling/src/apps/deploy.ts
19904
+ init_cli_input();
19905
+ init_cli_output();
19906
+ init_cli_output();
19907
+ init_cli_tools();
19908
+ init_errors();
19909
+ init_pathResolver();
19910
+
19785
19911
  // packages/tooling/src/utils/provider-detection.ts
19786
19912
  init_utils();
19787
19913
  init_pathResolver();
@@ -19866,12 +19992,6 @@ function detectProvider(appDir) {
19866
19992
  }
19867
19993
 
19868
19994
  // packages/tooling/src/apps/deploy.ts
19869
- init_cli_input();
19870
- init_cli_output();
19871
- init_cli_output();
19872
- init_cli_tools();
19873
- init_errors();
19874
- init_pathResolver();
19875
19995
  async function main6(options = {}) {
19876
19996
  const isStaging = options.staging ?? false;
19877
19997
  const config = {
@@ -20233,6 +20353,28 @@ init_sync_secrets();
20233
20353
 
20234
20354
  // packages/tooling/src/scaffolding/create-app.ts
20235
20355
  init_utils();
20356
+
20357
+ // packages/tooling/src/scaffolding/scaffold-matrix.ts
20358
+ init_utils();
20359
+ function resolveDeployConfig(host, backend) {
20360
+ if (host === "none") return null;
20361
+ if (host === "firebase") return "firebase";
20362
+ if (backend === "supabase") return "vercel-supabase";
20363
+ return "vercel-vercel";
20364
+ }
20365
+ function getScaffoldParts(builder, host, functions, backend) {
20366
+ const baseTemplate = builder === "nextjs" ? "app-next" : builder === "demo" ? "app-demo" : builder === "dndev" ? "app-dndev" : `app-${builder}`;
20367
+ return {
20368
+ builder,
20369
+ backend,
20370
+ baseTemplate,
20371
+ overlay: backend !== "none" ? `overlay-${backend}` : null,
20372
+ deployConfig: resolveDeployConfig(host, backend),
20373
+ functionsTemplate: functions !== "none" ? `functions-${functions}` : null
20374
+ };
20375
+ }
20376
+
20377
+ // packages/tooling/src/scaffolding/create-app.ts
20236
20378
  init_cli_input();
20237
20379
  init_cli_output();
20238
20380
 
@@ -20378,8 +20520,8 @@ function generatePackageJson(templateName, mode, options = {}) {
20378
20520
  result.main = "lib/index.js";
20379
20521
  result.engines = { node: "22" };
20380
20522
  if (options.appName) {
20381
- const platform6 = templateName.includes("vercel") ? "Vercel" : "Firebase";
20382
- result.description = `${options.appName} ${platform6} Functions`;
20523
+ const platform7 = templateName.includes("vercel") ? "Vercel" : "Firebase";
20524
+ result.description = `${options.appName} ${platform7} Functions`;
20383
20525
  }
20384
20526
  if (mode === "development") {
20385
20527
  const workspacePkgs = [
@@ -20417,28 +20559,6 @@ function generatePackageJson(templateName, mode, options = {}) {
20417
20559
  // packages/tooling/src/scaffolding/create-app.ts
20418
20560
  init_pathResolver();
20419
20561
  init_pathResolver();
20420
-
20421
- // packages/tooling/src/scaffolding/scaffold-matrix.ts
20422
- init_utils();
20423
- function resolveDeployConfig(host, backend) {
20424
- if (host === "none") return null;
20425
- if (host === "firebase") return "firebase";
20426
- if (backend === "supabase") return "vercel-supabase";
20427
- return "vercel-vercel";
20428
- }
20429
- function getScaffoldParts(builder, host, functions, backend) {
20430
- const baseTemplate = builder === "nextjs" ? "app-next" : builder === "demo" ? "app-demo" : builder === "dndev" ? "app-dndev" : `app-${builder}`;
20431
- return {
20432
- builder,
20433
- backend,
20434
- baseTemplate,
20435
- overlay: backend !== "none" ? `overlay-${backend}` : null,
20436
- deployConfig: resolveDeployConfig(host, backend),
20437
- functionsTemplate: functions !== "none" ? `functions-${functions}` : null
20438
- };
20439
- }
20440
-
20441
- // packages/tooling/src/scaffolding/create-app.ts
20442
20562
  var SHOW_WIP = process.env.SHOW_WIP === "true" || process.argv.includes("--wip");
20443
20563
  async function createApp(appName, appConfig, workspaceRoot, templatesRoot) {
20444
20564
  const isInteractive = !appName || !appConfig;
@@ -21974,7 +22094,7 @@ async function runPrettier(rootDir, dryRun, verbose) {
21974
22094
  log.info("DRY RUN: Would run Prettier");
21975
22095
  return stats;
21976
22096
  }
21977
- const result = spawnSync9("bunx", prettierArgs, {
22097
+ const result = spawnSync9(`bunx ${prettierArgs.join(" ")}`, {
21978
22098
  cwd: rootDir,
21979
22099
  stdio: "pipe",
21980
22100
  shell: true,