@donotdev/cli 0.0.25 → 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.
@@ -905,6 +905,148 @@ var init_cli_output = __esm({
905
905
  }
906
906
  });
907
907
 
908
+ // packages/tooling/src/utils/errors.ts
909
+ var DO_NOT_DEV_ERROR_CODES, DoNotDevError;
910
+ var init_errors = __esm({
911
+ "packages/tooling/src/utils/errors.ts"() {
912
+ "use strict";
913
+ init_utils();
914
+ DO_NOT_DEV_ERROR_CODES = {
915
+ CONFIGURATION_ERROR: "configuration-error",
916
+ CONFIG_NOT_FOUND: "config-not-found",
917
+ CONFIG_INVALID: "config-invalid",
918
+ PATH_RESOLUTION_ERROR: "path-resolution-error",
919
+ FILE_OPERATION_ERROR: "file-operation-error",
920
+ FILE_NOT_FOUND: "file-not-found",
921
+ PERMISSION_DENIED: "permission-denied",
922
+ GENERATION_ERROR: "generation-error",
923
+ TEMPLATE_ERROR: "template-error",
924
+ TEMPLATE_NOT_FOUND: "template-not-found",
925
+ CLI_EXECUTION_ERROR: "cli-execution-error",
926
+ COMMAND_NOT_FOUND: "command-not-found",
927
+ COMMAND_FAILED: "command-failed",
928
+ VALIDATION_ERROR: "validation-error",
929
+ SCHEMA_ERROR: "schema-error",
930
+ DEPENDENCY_ERROR: "dependency-error",
931
+ DEPENDENCY_NOT_FOUND: "dependency-not-found",
932
+ DEPENDENCY_VERSION_ERROR: "dependency-version-error",
933
+ INVALID_ARGUMENT: "invalid-argument",
934
+ MISSING_ARGUMENT: "missing-argument",
935
+ MISSING_PROJECT_ID: "missing-project-id",
936
+ FIREBASE_CLI_ERROR: "firebase-cli-error",
937
+ DEPLOYMENT_FAILED: "deployment-failed",
938
+ VERCEL_API_ERROR: "vercel-api-error",
939
+ OPERATION_CANCELLED: "operation-cancelled",
940
+ TIMEOUT_ERROR: "timeout-error",
941
+ UNKNOWN_ERROR: "unknown-error"
942
+ };
943
+ DoNotDevError = class _DoNotDevError extends Error {
944
+ /** The error code categorizing this error */
945
+ code;
946
+ /** Original error if this is wrapping another error */
947
+ originalError;
948
+ /** Additional context for the error */
949
+ context;
950
+ /** Whether this error should be displayed to the user */
951
+ displayable;
952
+ /**
953
+ * Creates a new DoNotDev error
954
+ *
955
+ * @param {string} message - Error message
956
+ * @param {DoNotDevErrorCode} code - Error code
957
+ * @param {object} [options] - Additional error options
958
+ * @param {Error} [options.originalError] - Original error if wrapping
959
+ * @param {Record<string, any>} [options.context] - Additional context data
960
+ * @param {boolean} [options.displayable=true] - Whether this error should be displayed to the user
961
+ */
962
+ constructor(message, code = DO_NOT_DEV_ERROR_CODES.UNKNOWN_ERROR, options) {
963
+ super(message);
964
+ this.name = "DoNotDevError";
965
+ this.code = code;
966
+ this.originalError = options?.originalError;
967
+ this.context = options?.context;
968
+ this.displayable = options?.displayable !== false;
969
+ Object.setPrototypeOf(this, _DoNotDevError.prototype);
970
+ if (Error.captureStackTrace) {
971
+ Error.captureStackTrace(this, _DoNotDevError);
972
+ }
973
+ }
974
+ /**
975
+ * Formats the error for logging or display
976
+ *
977
+ * @returns {string} Formatted error message with code
978
+ */
979
+ format() {
980
+ return `[${this.code}] ${this.message}`;
981
+ }
982
+ /**
983
+ * Creates a wrapped error from another error
984
+ *
985
+ * @param {Error} error - Original error to wrap
986
+ * @param {string} [context] - Additional context for the error
987
+ * @param {DoNotDevErrorCode} [code='unknown-error'] - Error code
988
+ * @param {object} [options] - Additional error options
989
+ * @param {Record<string, any>} [options.context] - Additional context data
990
+ * @param {boolean} [options.displayable=true] - Whether this error should be displayed to the user
991
+ * @returns {DoNotDevError} New DoNotDev error wrapping the original
992
+ */
993
+ static from(error2, context, code = DO_NOT_DEV_ERROR_CODES.UNKNOWN_ERROR, options) {
994
+ if (!(error2 instanceof Error)) {
995
+ return new _DoNotDevError(
996
+ `Unknown error: ${String(error2)}`,
997
+ code,
998
+ options
999
+ );
1000
+ }
1001
+ if (error2 instanceof _DoNotDevError) {
1002
+ if (!context) {
1003
+ return error2;
1004
+ }
1005
+ return new _DoNotDevError(`${context}: ${error2.message}`, error2.code, {
1006
+ originalError: error2.originalError || error2,
1007
+ context: { ...error2.context, ...options?.context || {} },
1008
+ displayable: options?.displayable ?? error2.displayable
1009
+ });
1010
+ }
1011
+ const message = context ? `${context}: ${error2.message}` : error2.message;
1012
+ return new _DoNotDevError(message, code, {
1013
+ originalError: error2,
1014
+ context: options?.context,
1015
+ displayable: options?.displayable
1016
+ });
1017
+ }
1018
+ /**
1019
+ * Maps common error types to DoNotDevErrorCode
1020
+ *
1021
+ * @param {Error} error - Error to analyze
1022
+ * @returns {DoNotDevErrorCode} Mapped error code
1023
+ */
1024
+ static getErrorCodeFromError(error2) {
1025
+ if (error2 instanceof _DoNotDevError) {
1026
+ return error2.code;
1027
+ }
1028
+ const message = error2.message.toLowerCase();
1029
+ if (error2.name === "ValidationError" || message.includes("validation")) {
1030
+ return DO_NOT_DEV_ERROR_CODES.VALIDATION_ERROR;
1031
+ }
1032
+ if (message.includes("not found") || message.includes("no such file")) {
1033
+ return DO_NOT_DEV_ERROR_CODES.FILE_NOT_FOUND;
1034
+ }
1035
+ if (message.includes("permission") || message.includes("access denied")) {
1036
+ return DO_NOT_DEV_ERROR_CODES.PERMISSION_DENIED;
1037
+ }
1038
+ if (message.includes("timeout") || message.includes("timed out")) {
1039
+ return DO_NOT_DEV_ERROR_CODES.TIMEOUT_ERROR;
1040
+ }
1041
+ if (message.includes("dependency") || message.includes("module not found")) {
1042
+ return DO_NOT_DEV_ERROR_CODES.DEPENDENCY_ERROR;
1043
+ }
1044
+ return DO_NOT_DEV_ERROR_CODES.UNKNOWN_ERROR;
1045
+ }
1046
+ };
1047
+ }
1048
+ });
1049
+
908
1050
  // node_modules/.bun/fast-glob@3.3.3/node_modules/fast-glob/out/utils/array.js
909
1051
  var require_array = __commonJS({
910
1052
  "node_modules/.bun/fast-glob@3.3.3/node_modules/fast-glob/out/utils/array.js"(exports) {
@@ -7648,147 +7790,6 @@ var init_PathResolver = __esm({
7648
7790
  }
7649
7791
  });
7650
7792
 
7651
- // packages/tooling/src/utils/errors.ts
7652
- var DO_NOT_DEV_ERROR_CODES, DoNotDevError;
7653
- var init_errors = __esm({
7654
- "packages/tooling/src/utils/errors.ts"() {
7655
- "use strict";
7656
- init_utils();
7657
- DO_NOT_DEV_ERROR_CODES = {
7658
- CONFIGURATION_ERROR: "configuration-error",
7659
- CONFIG_NOT_FOUND: "config-not-found",
7660
- CONFIG_INVALID: "config-invalid",
7661
- PATH_RESOLUTION_ERROR: "path-resolution-error",
7662
- FILE_OPERATION_ERROR: "file-operation-error",
7663
- FILE_NOT_FOUND: "file-not-found",
7664
- PERMISSION_DENIED: "permission-denied",
7665
- GENERATION_ERROR: "generation-error",
7666
- TEMPLATE_ERROR: "template-error",
7667
- TEMPLATE_NOT_FOUND: "template-not-found",
7668
- CLI_EXECUTION_ERROR: "cli-execution-error",
7669
- COMMAND_NOT_FOUND: "command-not-found",
7670
- COMMAND_FAILED: "command-failed",
7671
- VALIDATION_ERROR: "validation-error",
7672
- SCHEMA_ERROR: "schema-error",
7673
- DEPENDENCY_ERROR: "dependency-error",
7674
- DEPENDENCY_NOT_FOUND: "dependency-not-found",
7675
- DEPENDENCY_VERSION_ERROR: "dependency-version-error",
7676
- INVALID_ARGUMENT: "invalid-argument",
7677
- MISSING_ARGUMENT: "missing-argument",
7678
- MISSING_PROJECT_ID: "missing-project-id",
7679
- FIREBASE_CLI_ERROR: "firebase-cli-error",
7680
- DEPLOYMENT_FAILED: "deployment-failed",
7681
- OPERATION_CANCELLED: "operation-cancelled",
7682
- TIMEOUT_ERROR: "timeout-error",
7683
- UNKNOWN_ERROR: "unknown-error"
7684
- };
7685
- DoNotDevError = class _DoNotDevError extends Error {
7686
- /** The error code categorizing this error */
7687
- code;
7688
- /** Original error if this is wrapping another error */
7689
- originalError;
7690
- /** Additional context for the error */
7691
- context;
7692
- /** Whether this error should be displayed to the user */
7693
- displayable;
7694
- /**
7695
- * Creates a new DoNotDev error
7696
- *
7697
- * @param {string} message - Error message
7698
- * @param {DoNotDevErrorCode} code - Error code
7699
- * @param {object} [options] - Additional error options
7700
- * @param {Error} [options.originalError] - Original error if wrapping
7701
- * @param {Record<string, any>} [options.context] - Additional context data
7702
- * @param {boolean} [options.displayable=true] - Whether this error should be displayed to the user
7703
- */
7704
- constructor(message, code = DO_NOT_DEV_ERROR_CODES.UNKNOWN_ERROR, options) {
7705
- super(message);
7706
- this.name = "DoNotDevError";
7707
- this.code = code;
7708
- this.originalError = options?.originalError;
7709
- this.context = options?.context;
7710
- this.displayable = options?.displayable !== false;
7711
- Object.setPrototypeOf(this, _DoNotDevError.prototype);
7712
- if (Error.captureStackTrace) {
7713
- Error.captureStackTrace(this, _DoNotDevError);
7714
- }
7715
- }
7716
- /**
7717
- * Formats the error for logging or display
7718
- *
7719
- * @returns {string} Formatted error message with code
7720
- */
7721
- format() {
7722
- return `[${this.code}] ${this.message}`;
7723
- }
7724
- /**
7725
- * Creates a wrapped error from another error
7726
- *
7727
- * @param {Error} error - Original error to wrap
7728
- * @param {string} [context] - Additional context for the error
7729
- * @param {DoNotDevErrorCode} [code='unknown-error'] - Error code
7730
- * @param {object} [options] - Additional error options
7731
- * @param {Record<string, any>} [options.context] - Additional context data
7732
- * @param {boolean} [options.displayable=true] - Whether this error should be displayed to the user
7733
- * @returns {DoNotDevError} New DoNotDev error wrapping the original
7734
- */
7735
- static from(error2, context, code = DO_NOT_DEV_ERROR_CODES.UNKNOWN_ERROR, options) {
7736
- if (!(error2 instanceof Error)) {
7737
- return new _DoNotDevError(
7738
- `Unknown error: ${String(error2)}`,
7739
- code,
7740
- options
7741
- );
7742
- }
7743
- if (error2 instanceof _DoNotDevError) {
7744
- if (!context) {
7745
- return error2;
7746
- }
7747
- return new _DoNotDevError(`${context}: ${error2.message}`, error2.code, {
7748
- originalError: error2.originalError || error2,
7749
- context: { ...error2.context, ...options?.context || {} },
7750
- displayable: options?.displayable ?? error2.displayable
7751
- });
7752
- }
7753
- const message = context ? `${context}: ${error2.message}` : error2.message;
7754
- return new _DoNotDevError(message, code, {
7755
- originalError: error2,
7756
- context: options?.context,
7757
- displayable: options?.displayable
7758
- });
7759
- }
7760
- /**
7761
- * Maps common error types to DoNotDevErrorCode
7762
- *
7763
- * @param {Error} error - Error to analyze
7764
- * @returns {DoNotDevErrorCode} Mapped error code
7765
- */
7766
- static getErrorCodeFromError(error2) {
7767
- if (error2 instanceof _DoNotDevError) {
7768
- return error2.code;
7769
- }
7770
- const message = error2.message.toLowerCase();
7771
- if (error2.name === "ValidationError" || message.includes("validation")) {
7772
- return DO_NOT_DEV_ERROR_CODES.VALIDATION_ERROR;
7773
- }
7774
- if (message.includes("not found") || message.includes("no such file")) {
7775
- return DO_NOT_DEV_ERROR_CODES.FILE_NOT_FOUND;
7776
- }
7777
- if (message.includes("permission") || message.includes("access denied")) {
7778
- return DO_NOT_DEV_ERROR_CODES.PERMISSION_DENIED;
7779
- }
7780
- if (message.includes("timeout") || message.includes("timed out")) {
7781
- return DO_NOT_DEV_ERROR_CODES.TIMEOUT_ERROR;
7782
- }
7783
- if (message.includes("dependency") || message.includes("module not found")) {
7784
- return DO_NOT_DEV_ERROR_CODES.DEPENDENCY_ERROR;
7785
- }
7786
- return DO_NOT_DEV_ERROR_CODES.UNKNOWN_ERROR;
7787
- }
7788
- };
7789
- }
7790
- });
7791
-
7792
7793
  // packages/tooling/src/utils/pathResolver.ts
7793
7794
  import { createRequire as createRequire2 } from "node:module";
7794
7795
  import {
@@ -7846,8 +7847,8 @@ var init_typed_file_operations = __esm({
7846
7847
  "packages/tooling/src/utils/typed-file-operations.ts"() {
7847
7848
  "use strict";
7848
7849
  init_utils();
7849
- init_pathResolver();
7850
7850
  init_errors();
7851
+ init_pathResolver();
7851
7852
  }
7852
7853
  });
7853
7854
 
@@ -7965,10 +7966,6 @@ function loadDndevSecrets(projectRoot) {
7965
7966
  }
7966
7967
  function resolveSecret(name, projectRoot, opts) {
7967
7968
  const appDir = opts?.appDir ?? projectRoot;
7968
- const envValue = process.env[name];
7969
- if (envValue) {
7970
- return { value: envValue, source: "process.env" };
7971
- }
7972
7969
  const secrets = loadDndevSecrets(projectRoot);
7973
7970
  if (secrets[name]) {
7974
7971
  return { value: secrets[name], source: ".dndev.secrets" };
@@ -7979,6 +7976,10 @@ function resolveSecret(name, projectRoot, opts) {
7979
7976
  source: ".dndev.secrets"
7980
7977
  };
7981
7978
  }
7979
+ const envValue = process.env[name];
7980
+ if (envValue) {
7981
+ return { value: envValue, source: "process.env" };
7982
+ }
7982
7983
  const legacyPaths = LEGACY_PATHS[name];
7983
7984
  if (legacyPaths) {
7984
7985
  for (const relPath of legacyPaths) {
@@ -8014,8 +8015,8 @@ var init_secrets_resolver = __esm({
8014
8015
  "packages/tooling/src/utils/secrets-resolver.ts"() {
8015
8016
  "use strict";
8016
8017
  init_utils();
8017
- init_pathResolver();
8018
8018
  init_cli_output();
8019
+ init_pathResolver();
8019
8020
  LEGACY_PATHS = {
8020
8021
  VERCEL_TOKEN: [".env.local"],
8021
8022
  SUPABASE_SECRET_KEY: ["supabase/functions/.env", "functions/.env"],
@@ -8032,11 +8033,11 @@ var init_secrets_resolver = __esm({
8032
8033
 
8033
8034
  // packages/tooling/src/cli/setup/vercel-token.ts
8034
8035
  function resolvePerAppVar(appDir, varName) {
8035
- if (process.env[varName]) return process.env[varName];
8036
8036
  const fromLocal = readEnvVar(joinPath(appDir, ".env.local"), varName);
8037
8037
  if (fromLocal) return fromLocal;
8038
8038
  const fromEnv = readEnvVar(joinPath(appDir, ".env"), varName);
8039
8039
  if (fromEnv) return fromEnv;
8040
+ if (process.env[varName]) return process.env[varName];
8040
8041
  return null;
8041
8042
  }
8042
8043
  function resolveVercelCredentials(appDir, projectRoot) {
@@ -8046,19 +8047,22 @@ function resolveVercelCredentials(appDir, projectRoot) {
8046
8047
  const projectId = resolvePerAppVar(appDir, "VERCEL_PROJECT_ID");
8047
8048
  const missing = [];
8048
8049
  if (!token) missing.push("VERCEL_TOKEN");
8049
- if (!orgId) missing.push("VERCEL_ORG_ID");
8050
8050
  if (!projectId) missing.push("VERCEL_PROJECT_ID");
8051
8051
  if (missing.length > 0) return { missing };
8052
8052
  return {
8053
- credentials: { token, orgId, projectId }
8053
+ credentials: {
8054
+ token,
8055
+ orgId: orgId ?? void 0,
8056
+ projectId
8057
+ }
8054
8058
  };
8055
8059
  }
8056
8060
  var init_vercel_token = __esm({
8057
8061
  "packages/tooling/src/cli/setup/vercel-token.ts"() {
8058
8062
  "use strict";
8059
8063
  init_utils();
8060
- init_secrets_resolver();
8061
8064
  init_pathResolver();
8065
+ init_secrets_resolver();
8062
8066
  }
8063
8067
  });
8064
8068
 
@@ -8297,10 +8301,10 @@ function detectProvider(appDir) {
8297
8301
  // packages/tooling/src/scaffolding/setup-cicd.ts
8298
8302
  init_utils();
8299
8303
  import { execSync } from "node:child_process";
8300
- init_pathResolver();
8301
8304
  init_sync_secrets();
8302
- init_secrets_resolver();
8303
8305
  init_vercel_token();
8306
+ init_pathResolver();
8307
+ init_secrets_resolver();
8304
8308
  function isGhCliAvailable() {
8305
8309
  try {
8306
8310
  execSync("gh --version", { stdio: "ignore" });
@@ -8355,11 +8359,13 @@ function collectSecrets(config) {
8355
8359
  value: vercelResult.credentials.token,
8356
8360
  source: ".dndev.secrets"
8357
8361
  });
8358
- secrets.push({
8359
- name: "VERCEL_ORG_ID",
8360
- value: vercelResult.credentials.orgId,
8361
- source: ".env"
8362
- });
8362
+ if (vercelResult.credentials.orgId) {
8363
+ secrets.push({
8364
+ name: "VERCEL_ORG_ID",
8365
+ value: vercelResult.credentials.orgId,
8366
+ source: ".env"
8367
+ });
8368
+ }
8363
8369
  secrets.push({
8364
8370
  name: "VERCEL_PROJECT_ID",
8365
8371
  value: vercelResult.credentials.projectId,