@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.
@@ -850,6 +850,148 @@ var init_cli_output = __esm({
850
850
  }
851
851
  });
852
852
 
853
+ // packages/tooling/src/utils/errors.ts
854
+ var DO_NOT_DEV_ERROR_CODES, DoNotDevError;
855
+ var init_errors = __esm({
856
+ "packages/tooling/src/utils/errors.ts"() {
857
+ "use strict";
858
+ init_utils();
859
+ DO_NOT_DEV_ERROR_CODES = {
860
+ CONFIGURATION_ERROR: "configuration-error",
861
+ CONFIG_NOT_FOUND: "config-not-found",
862
+ CONFIG_INVALID: "config-invalid",
863
+ PATH_RESOLUTION_ERROR: "path-resolution-error",
864
+ FILE_OPERATION_ERROR: "file-operation-error",
865
+ FILE_NOT_FOUND: "file-not-found",
866
+ PERMISSION_DENIED: "permission-denied",
867
+ GENERATION_ERROR: "generation-error",
868
+ TEMPLATE_ERROR: "template-error",
869
+ TEMPLATE_NOT_FOUND: "template-not-found",
870
+ CLI_EXECUTION_ERROR: "cli-execution-error",
871
+ COMMAND_NOT_FOUND: "command-not-found",
872
+ COMMAND_FAILED: "command-failed",
873
+ VALIDATION_ERROR: "validation-error",
874
+ SCHEMA_ERROR: "schema-error",
875
+ DEPENDENCY_ERROR: "dependency-error",
876
+ DEPENDENCY_NOT_FOUND: "dependency-not-found",
877
+ DEPENDENCY_VERSION_ERROR: "dependency-version-error",
878
+ INVALID_ARGUMENT: "invalid-argument",
879
+ MISSING_ARGUMENT: "missing-argument",
880
+ MISSING_PROJECT_ID: "missing-project-id",
881
+ FIREBASE_CLI_ERROR: "firebase-cli-error",
882
+ DEPLOYMENT_FAILED: "deployment-failed",
883
+ VERCEL_API_ERROR: "vercel-api-error",
884
+ OPERATION_CANCELLED: "operation-cancelled",
885
+ TIMEOUT_ERROR: "timeout-error",
886
+ UNKNOWN_ERROR: "unknown-error"
887
+ };
888
+ DoNotDevError = class _DoNotDevError extends Error {
889
+ /** The error code categorizing this error */
890
+ code;
891
+ /** Original error if this is wrapping another error */
892
+ originalError;
893
+ /** Additional context for the error */
894
+ context;
895
+ /** Whether this error should be displayed to the user */
896
+ displayable;
897
+ /**
898
+ * Creates a new DoNotDev error
899
+ *
900
+ * @param {string} message - Error message
901
+ * @param {DoNotDevErrorCode} code - Error code
902
+ * @param {object} [options] - Additional error options
903
+ * @param {Error} [options.originalError] - Original error if wrapping
904
+ * @param {Record<string, any>} [options.context] - Additional context data
905
+ * @param {boolean} [options.displayable=true] - Whether this error should be displayed to the user
906
+ */
907
+ constructor(message, code = DO_NOT_DEV_ERROR_CODES.UNKNOWN_ERROR, options) {
908
+ super(message);
909
+ this.name = "DoNotDevError";
910
+ this.code = code;
911
+ this.originalError = options?.originalError;
912
+ this.context = options?.context;
913
+ this.displayable = options?.displayable !== false;
914
+ Object.setPrototypeOf(this, _DoNotDevError.prototype);
915
+ if (Error.captureStackTrace) {
916
+ Error.captureStackTrace(this, _DoNotDevError);
917
+ }
918
+ }
919
+ /**
920
+ * Formats the error for logging or display
921
+ *
922
+ * @returns {string} Formatted error message with code
923
+ */
924
+ format() {
925
+ return `[${this.code}] ${this.message}`;
926
+ }
927
+ /**
928
+ * Creates a wrapped error from another error
929
+ *
930
+ * @param {Error} error - Original error to wrap
931
+ * @param {string} [context] - Additional context for the error
932
+ * @param {DoNotDevErrorCode} [code='unknown-error'] - Error code
933
+ * @param {object} [options] - Additional error options
934
+ * @param {Record<string, any>} [options.context] - Additional context data
935
+ * @param {boolean} [options.displayable=true] - Whether this error should be displayed to the user
936
+ * @returns {DoNotDevError} New DoNotDev error wrapping the original
937
+ */
938
+ static from(error2, context, code = DO_NOT_DEV_ERROR_CODES.UNKNOWN_ERROR, options) {
939
+ if (!(error2 instanceof Error)) {
940
+ return new _DoNotDevError(
941
+ `Unknown error: ${String(error2)}`,
942
+ code,
943
+ options
944
+ );
945
+ }
946
+ if (error2 instanceof _DoNotDevError) {
947
+ if (!context) {
948
+ return error2;
949
+ }
950
+ return new _DoNotDevError(`${context}: ${error2.message}`, error2.code, {
951
+ originalError: error2.originalError || error2,
952
+ context: { ...error2.context, ...options?.context || {} },
953
+ displayable: options?.displayable ?? error2.displayable
954
+ });
955
+ }
956
+ const message = context ? `${context}: ${error2.message}` : error2.message;
957
+ return new _DoNotDevError(message, code, {
958
+ originalError: error2,
959
+ context: options?.context,
960
+ displayable: options?.displayable
961
+ });
962
+ }
963
+ /**
964
+ * Maps common error types to DoNotDevErrorCode
965
+ *
966
+ * @param {Error} error - Error to analyze
967
+ * @returns {DoNotDevErrorCode} Mapped error code
968
+ */
969
+ static getErrorCodeFromError(error2) {
970
+ if (error2 instanceof _DoNotDevError) {
971
+ return error2.code;
972
+ }
973
+ const message = error2.message.toLowerCase();
974
+ if (error2.name === "ValidationError" || message.includes("validation")) {
975
+ return DO_NOT_DEV_ERROR_CODES.VALIDATION_ERROR;
976
+ }
977
+ if (message.includes("not found") || message.includes("no such file")) {
978
+ return DO_NOT_DEV_ERROR_CODES.FILE_NOT_FOUND;
979
+ }
980
+ if (message.includes("permission") || message.includes("access denied")) {
981
+ return DO_NOT_DEV_ERROR_CODES.PERMISSION_DENIED;
982
+ }
983
+ if (message.includes("timeout") || message.includes("timed out")) {
984
+ return DO_NOT_DEV_ERROR_CODES.TIMEOUT_ERROR;
985
+ }
986
+ if (message.includes("dependency") || message.includes("module not found")) {
987
+ return DO_NOT_DEV_ERROR_CODES.DEPENDENCY_ERROR;
988
+ }
989
+ return DO_NOT_DEV_ERROR_CODES.UNKNOWN_ERROR;
990
+ }
991
+ };
992
+ }
993
+ });
994
+
853
995
  // node_modules/.bun/fast-glob@3.3.3/node_modules/fast-glob/out/utils/array.js
854
996
  var require_array = __commonJS({
855
997
  "node_modules/.bun/fast-glob@3.3.3/node_modules/fast-glob/out/utils/array.js"(exports) {
@@ -7593,147 +7735,6 @@ var init_PathResolver = __esm({
7593
7735
  }
7594
7736
  });
7595
7737
 
7596
- // packages/tooling/src/utils/errors.ts
7597
- var DO_NOT_DEV_ERROR_CODES, DoNotDevError;
7598
- var init_errors = __esm({
7599
- "packages/tooling/src/utils/errors.ts"() {
7600
- "use strict";
7601
- init_utils();
7602
- DO_NOT_DEV_ERROR_CODES = {
7603
- CONFIGURATION_ERROR: "configuration-error",
7604
- CONFIG_NOT_FOUND: "config-not-found",
7605
- CONFIG_INVALID: "config-invalid",
7606
- PATH_RESOLUTION_ERROR: "path-resolution-error",
7607
- FILE_OPERATION_ERROR: "file-operation-error",
7608
- FILE_NOT_FOUND: "file-not-found",
7609
- PERMISSION_DENIED: "permission-denied",
7610
- GENERATION_ERROR: "generation-error",
7611
- TEMPLATE_ERROR: "template-error",
7612
- TEMPLATE_NOT_FOUND: "template-not-found",
7613
- CLI_EXECUTION_ERROR: "cli-execution-error",
7614
- COMMAND_NOT_FOUND: "command-not-found",
7615
- COMMAND_FAILED: "command-failed",
7616
- VALIDATION_ERROR: "validation-error",
7617
- SCHEMA_ERROR: "schema-error",
7618
- DEPENDENCY_ERROR: "dependency-error",
7619
- DEPENDENCY_NOT_FOUND: "dependency-not-found",
7620
- DEPENDENCY_VERSION_ERROR: "dependency-version-error",
7621
- INVALID_ARGUMENT: "invalid-argument",
7622
- MISSING_ARGUMENT: "missing-argument",
7623
- MISSING_PROJECT_ID: "missing-project-id",
7624
- FIREBASE_CLI_ERROR: "firebase-cli-error",
7625
- DEPLOYMENT_FAILED: "deployment-failed",
7626
- OPERATION_CANCELLED: "operation-cancelled",
7627
- TIMEOUT_ERROR: "timeout-error",
7628
- UNKNOWN_ERROR: "unknown-error"
7629
- };
7630
- DoNotDevError = class _DoNotDevError extends Error {
7631
- /** The error code categorizing this error */
7632
- code;
7633
- /** Original error if this is wrapping another error */
7634
- originalError;
7635
- /** Additional context for the error */
7636
- context;
7637
- /** Whether this error should be displayed to the user */
7638
- displayable;
7639
- /**
7640
- * Creates a new DoNotDev error
7641
- *
7642
- * @param {string} message - Error message
7643
- * @param {DoNotDevErrorCode} code - Error code
7644
- * @param {object} [options] - Additional error options
7645
- * @param {Error} [options.originalError] - Original error if wrapping
7646
- * @param {Record<string, any>} [options.context] - Additional context data
7647
- * @param {boolean} [options.displayable=true] - Whether this error should be displayed to the user
7648
- */
7649
- constructor(message, code = DO_NOT_DEV_ERROR_CODES.UNKNOWN_ERROR, options) {
7650
- super(message);
7651
- this.name = "DoNotDevError";
7652
- this.code = code;
7653
- this.originalError = options?.originalError;
7654
- this.context = options?.context;
7655
- this.displayable = options?.displayable !== false;
7656
- Object.setPrototypeOf(this, _DoNotDevError.prototype);
7657
- if (Error.captureStackTrace) {
7658
- Error.captureStackTrace(this, _DoNotDevError);
7659
- }
7660
- }
7661
- /**
7662
- * Formats the error for logging or display
7663
- *
7664
- * @returns {string} Formatted error message with code
7665
- */
7666
- format() {
7667
- return `[${this.code}] ${this.message}`;
7668
- }
7669
- /**
7670
- * Creates a wrapped error from another error
7671
- *
7672
- * @param {Error} error - Original error to wrap
7673
- * @param {string} [context] - Additional context for the error
7674
- * @param {DoNotDevErrorCode} [code='unknown-error'] - Error code
7675
- * @param {object} [options] - Additional error options
7676
- * @param {Record<string, any>} [options.context] - Additional context data
7677
- * @param {boolean} [options.displayable=true] - Whether this error should be displayed to the user
7678
- * @returns {DoNotDevError} New DoNotDev error wrapping the original
7679
- */
7680
- static from(error2, context, code = DO_NOT_DEV_ERROR_CODES.UNKNOWN_ERROR, options) {
7681
- if (!(error2 instanceof Error)) {
7682
- return new _DoNotDevError(
7683
- `Unknown error: ${String(error2)}`,
7684
- code,
7685
- options
7686
- );
7687
- }
7688
- if (error2 instanceof _DoNotDevError) {
7689
- if (!context) {
7690
- return error2;
7691
- }
7692
- return new _DoNotDevError(`${context}: ${error2.message}`, error2.code, {
7693
- originalError: error2.originalError || error2,
7694
- context: { ...error2.context, ...options?.context || {} },
7695
- displayable: options?.displayable ?? error2.displayable
7696
- });
7697
- }
7698
- const message = context ? `${context}: ${error2.message}` : error2.message;
7699
- return new _DoNotDevError(message, code, {
7700
- originalError: error2,
7701
- context: options?.context,
7702
- displayable: options?.displayable
7703
- });
7704
- }
7705
- /**
7706
- * Maps common error types to DoNotDevErrorCode
7707
- *
7708
- * @param {Error} error - Error to analyze
7709
- * @returns {DoNotDevErrorCode} Mapped error code
7710
- */
7711
- static getErrorCodeFromError(error2) {
7712
- if (error2 instanceof _DoNotDevError) {
7713
- return error2.code;
7714
- }
7715
- const message = error2.message.toLowerCase();
7716
- if (error2.name === "ValidationError" || message.includes("validation")) {
7717
- return DO_NOT_DEV_ERROR_CODES.VALIDATION_ERROR;
7718
- }
7719
- if (message.includes("not found") || message.includes("no such file")) {
7720
- return DO_NOT_DEV_ERROR_CODES.FILE_NOT_FOUND;
7721
- }
7722
- if (message.includes("permission") || message.includes("access denied")) {
7723
- return DO_NOT_DEV_ERROR_CODES.PERMISSION_DENIED;
7724
- }
7725
- if (message.includes("timeout") || message.includes("timed out")) {
7726
- return DO_NOT_DEV_ERROR_CODES.TIMEOUT_ERROR;
7727
- }
7728
- if (message.includes("dependency") || message.includes("module not found")) {
7729
- return DO_NOT_DEV_ERROR_CODES.DEPENDENCY_ERROR;
7730
- }
7731
- return DO_NOT_DEV_ERROR_CODES.UNKNOWN_ERROR;
7732
- }
7733
- };
7734
- }
7735
- });
7736
-
7737
7738
  // packages/tooling/src/utils/pathResolver.ts
7738
7739
  import { createRequire as createRequire2 } from "node:module";
7739
7740
  import {
@@ -7812,8 +7813,8 @@ var init_typed_file_operations = __esm({
7812
7813
  "packages/tooling/src/utils/typed-file-operations.ts"() {
7813
7814
  "use strict";
7814
7815
  init_utils();
7815
- init_pathResolver();
7816
7816
  init_errors();
7817
+ init_pathResolver();
7817
7818
  }
7818
7819
  });
7819
7820
 
@@ -7903,23 +7904,23 @@ function analyzeApp(appPath, appName) {
7903
7904
  const functionsPath = joinPath(appPath, "functions");
7904
7905
  const functionsStat = statSync2(functionsPath);
7905
7906
  const hasFunctions = pathExists(functionsPath) && (functionsStat?.isDirectory() ?? false);
7906
- let platform4;
7907
+ let platform5;
7907
7908
  const firebaseJsonInFunctions = hasFunctions && pathExists(joinPath(functionsPath, "firebase.json"));
7908
7909
  const firebaseJsonInApp = pathExists(joinPath(appPath, "firebase.json"));
7909
7910
  if (firebaseJsonInFunctions || firebaseJsonInApp) {
7910
- platform4 = "firebase";
7911
+ platform5 = "firebase";
7911
7912
  }
7912
- if (!platform4) {
7913
+ if (!platform5) {
7913
7914
  const supabaseConfigPath = joinPath(appPath, "supabase", "config.toml");
7914
7915
  const hasSupabaseDep = !!(packageJson.dependencies?.["@donotdev/supabase"] || packageJson.dependencies?.["@supabase/supabase-js"]);
7915
7916
  if (pathExists(supabaseConfigPath) || hasSupabaseDep) {
7916
- platform4 = "supabase";
7917
+ platform5 = "supabase";
7917
7918
  }
7918
7919
  }
7919
- if (!platform4) {
7920
+ if (!platform5) {
7920
7921
  const vercelJsonPath = joinPath(appPath, "vercel.json");
7921
7922
  if (pathExists(vercelJsonPath)) {
7922
- platform4 = "vercel";
7923
+ platform5 = "vercel";
7923
7924
  }
7924
7925
  }
7925
7926
  return {
@@ -7930,7 +7931,7 @@ function analyzeApp(appPath, appName) {
7930
7931
  framework,
7931
7932
  hasFunctions,
7932
7933
  functionsPath: hasFunctions ? functionsPath : void 0,
7933
- platform: platform4
7934
+ platform: platform5
7934
7935
  };
7935
7936
  }
7936
7937
  var init_app_detection = __esm({
@@ -8024,7 +8025,12 @@ init_utils();
8024
8025
 
8025
8026
  // packages/tooling/src/utils/spawn-utils.ts
8026
8027
  init_utils();
8027
- import { spawnSync, execSync } from "node:child_process";
8028
+ import {
8029
+ spawn,
8030
+ spawnSync,
8031
+ execSync
8032
+ } from "node:child_process";
8033
+ import { platform } from "node:os";
8028
8034
  function createAppEnv(appPath) {
8029
8035
  return {
8030
8036
  ...process.env,
@@ -8066,23 +8072,19 @@ function createEmulatorEnv(appPath, framework = "vite", options) {
8066
8072
 
8067
8073
  // packages/tooling/src/apps/emu.ts
8068
8074
  init_utils();
8069
- init_app_selector();
8070
- init_cli_output();
8071
- init_errors();
8072
- init_pathResolver();
8073
8075
 
8074
8076
  // packages/tooling/src/apps/emu-firebase.ts
8075
8077
  init_utils();
8076
8078
  init_cli_input();
8077
8079
  init_cli_output();
8078
8080
  init_pathResolver();
8079
- init_typed_file_operations();
8080
8081
  import {
8081
- spawn,
8082
+ spawn as spawn2,
8082
8083
  spawnSync as spawnSync2,
8083
8084
  execSync as execSync2
8084
8085
  } from "node:child_process";
8085
- import { platform } from "node:os";
8086
+ import { platform as platform2 } from "node:os";
8087
+ init_typed_file_operations();
8086
8088
  function discoverFirebaseProjectId(appPath) {
8087
8089
  const firebasercPath = joinPath(appPath, ".firebaserc");
8088
8090
  if (pathExists(firebasercPath)) {
@@ -8338,8 +8340,8 @@ FIREBASE_AUTH_EMULATOR_HOST=${authEmulatorHost}
8338
8340
  log.info(" stripe trigger checkout.session.completed");
8339
8341
  log.info("");
8340
8342
  }
8341
- const isWindows = platform() === "win32";
8342
- const childProcess = spawn(
8343
+ const isWindows = platform2() === "win32";
8344
+ const childProcess = spawn2(
8343
8345
  "bunx",
8344
8346
  ["concurrently", ...concurrentlyArgs],
8345
8347
  {
@@ -8413,8 +8415,8 @@ FIREBASE_AUTH_EMULATOR_HOST=${authEmulatorHost}
8413
8415
  // packages/tooling/src/apps/emu-supabase.ts
8414
8416
  init_utils();
8415
8417
  init_cli_output();
8416
- import { spawn as spawn2, execSync as execSync3 } from "node:child_process";
8417
- import { platform as platform2 } from "node:os";
8418
+ import { spawn as spawn3, execSync as execSync3 } from "node:child_process";
8419
+ import { platform as platform3 } from "node:os";
8418
8420
  function isDockerRunning() {
8419
8421
  try {
8420
8422
  execSync3("docker info", { stdio: "pipe", timeout: 5e3 });
@@ -8438,7 +8440,7 @@ async function startSupabase(app, _projectRoot) {
8438
8440
  log.error(" bun install -g supabase\n");
8439
8441
  return 1;
8440
8442
  }
8441
- const isWindows = platform2() === "win32";
8443
+ const isWindows = platform3() === "win32";
8442
8444
  const concurrentlyArgs = [
8443
8445
  "--kill-others-on-fail",
8444
8446
  "--prefix-colors",
@@ -8450,7 +8452,7 @@ async function startSupabase(app, _projectRoot) {
8450
8452
  "supabase start",
8451
8453
  `bunx turbo dev --filter=${app.packageName}`
8452
8454
  ];
8453
- const childProcess = spawn2(
8455
+ const childProcess = spawn3(
8454
8456
  "bunx",
8455
8457
  ["concurrently", ...concurrentlyArgs],
8456
8458
  {
@@ -8496,8 +8498,8 @@ async function startSupabase(app, _projectRoot) {
8496
8498
  // packages/tooling/src/apps/emu-vercel.ts
8497
8499
  init_utils();
8498
8500
  init_cli_output();
8499
- import { spawn as spawn3, execSync as execSync4 } from "node:child_process";
8500
- import { platform as platform3 } from "node:os";
8501
+ import { spawn as spawn4, execSync as execSync4 } from "node:child_process";
8502
+ import { platform as platform4 } from "node:os";
8501
8503
  async function startVercel(app, _projectRoot) {
8502
8504
  log.info(`Starting Vercel dev server for ${app.name}...
8503
8505
  `);
@@ -8508,8 +8510,8 @@ async function startVercel(app, _projectRoot) {
8508
8510
  log.error(" bun install -g vercel\n");
8509
8511
  return 1;
8510
8512
  }
8511
- const isWindows = platform3() === "win32";
8512
- const childProcess = spawn3("vercel", ["dev"], {
8513
+ const isWindows = platform4() === "win32";
8514
+ const childProcess = spawn4("vercel", ["dev"], {
8513
8515
  stdio: "inherit",
8514
8516
  cwd: app.path,
8515
8517
  shell: isWindows
@@ -8549,6 +8551,10 @@ async function startVercel(app, _projectRoot) {
8549
8551
  }
8550
8552
 
8551
8553
  // packages/tooling/src/apps/emu.ts
8554
+ init_app_selector();
8555
+ init_cli_output();
8556
+ init_errors();
8557
+ init_pathResolver();
8552
8558
  async function main(options) {
8553
8559
  const args = process.argv.slice(2);
8554
8560
  const projectRoot = getRepoRoot();