@donotdev/cli 0.0.25 → 0.0.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -295
- package/dependencies-matrix.json +49 -21
- package/dist/bin/commands/agent-setup.js +1 -1
- package/dist/bin/commands/build.js +143 -142
- package/dist/bin/commands/bump.js +145 -144
- package/dist/bin/commands/cacheout.js +142 -141
- package/dist/bin/commands/coach.js +156 -151
- package/dist/bin/commands/create-app.js +22 -22
- package/dist/bin/commands/create-project.js +165 -164
- package/dist/bin/commands/db.js +46704 -46703
- package/dist/bin/commands/deploy.js +674 -575
- package/dist/bin/commands/dev.js +179 -159
- package/dist/bin/commands/doctor.js +152 -151
- package/dist/bin/commands/emu.js +186 -176
- package/dist/bin/commands/format.js +142 -141
- package/dist/bin/commands/get-demo.js +1 -1
- package/dist/bin/commands/make-admin.js +64133 -64040
- package/dist/bin/commands/preview.js +178 -159
- package/dist/bin/commands/seed.js +46704 -46703
- package/dist/bin/commands/setup-cicd.js +164 -158
- package/dist/bin/commands/setup.js +409 -209
- package/dist/bin/commands/staging.js +674 -575
- package/dist/bin/commands/sync-secrets.js +142 -141
- package/dist/bin/commands/type-check.js +142 -141
- package/dist/bin/dndev.js +93 -1
- package/dist/bin/donotdev.js +93 -1
- package/dist/index.js +713 -605
- package/package.json +1 -1
- package/templates/app-next/postcss.config.js.example +3 -54
- package/templates/root-consumer/bunfig.toml.example +6 -49
- package/templates/root-consumer/guides/dndev/SETUP_AUTH.md.example +19 -0
- package/templates/root-consumer/guides/dndev/SETUP_VERCEL.md.example +50 -9
|
@@ -947,6 +947,155 @@ var init_cli_output = __esm({
|
|
|
947
947
|
}
|
|
948
948
|
});
|
|
949
949
|
|
|
950
|
+
// packages/tooling/src/utils/errors.ts
|
|
951
|
+
async function safeExecuteAsync(fn, context, code = DO_NOT_DEV_ERROR_CODES.UNKNOWN_ERROR) {
|
|
952
|
+
try {
|
|
953
|
+
return await fn();
|
|
954
|
+
} catch (error2) {
|
|
955
|
+
throw DoNotDevError.from(error2, context, code);
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
var DO_NOT_DEV_ERROR_CODES, DoNotDevError;
|
|
959
|
+
var init_errors = __esm({
|
|
960
|
+
"packages/tooling/src/utils/errors.ts"() {
|
|
961
|
+
"use strict";
|
|
962
|
+
init_utils();
|
|
963
|
+
DO_NOT_DEV_ERROR_CODES = {
|
|
964
|
+
CONFIGURATION_ERROR: "configuration-error",
|
|
965
|
+
CONFIG_NOT_FOUND: "config-not-found",
|
|
966
|
+
CONFIG_INVALID: "config-invalid",
|
|
967
|
+
PATH_RESOLUTION_ERROR: "path-resolution-error",
|
|
968
|
+
FILE_OPERATION_ERROR: "file-operation-error",
|
|
969
|
+
FILE_NOT_FOUND: "file-not-found",
|
|
970
|
+
PERMISSION_DENIED: "permission-denied",
|
|
971
|
+
GENERATION_ERROR: "generation-error",
|
|
972
|
+
TEMPLATE_ERROR: "template-error",
|
|
973
|
+
TEMPLATE_NOT_FOUND: "template-not-found",
|
|
974
|
+
CLI_EXECUTION_ERROR: "cli-execution-error",
|
|
975
|
+
COMMAND_NOT_FOUND: "command-not-found",
|
|
976
|
+
COMMAND_FAILED: "command-failed",
|
|
977
|
+
VALIDATION_ERROR: "validation-error",
|
|
978
|
+
SCHEMA_ERROR: "schema-error",
|
|
979
|
+
DEPENDENCY_ERROR: "dependency-error",
|
|
980
|
+
DEPENDENCY_NOT_FOUND: "dependency-not-found",
|
|
981
|
+
DEPENDENCY_VERSION_ERROR: "dependency-version-error",
|
|
982
|
+
INVALID_ARGUMENT: "invalid-argument",
|
|
983
|
+
MISSING_ARGUMENT: "missing-argument",
|
|
984
|
+
MISSING_PROJECT_ID: "missing-project-id",
|
|
985
|
+
FIREBASE_CLI_ERROR: "firebase-cli-error",
|
|
986
|
+
DEPLOYMENT_FAILED: "deployment-failed",
|
|
987
|
+
VERCEL_API_ERROR: "vercel-api-error",
|
|
988
|
+
OPERATION_CANCELLED: "operation-cancelled",
|
|
989
|
+
TIMEOUT_ERROR: "timeout-error",
|
|
990
|
+
UNKNOWN_ERROR: "unknown-error"
|
|
991
|
+
};
|
|
992
|
+
DoNotDevError = class _DoNotDevError extends Error {
|
|
993
|
+
/** The error code categorizing this error */
|
|
994
|
+
code;
|
|
995
|
+
/** Original error if this is wrapping another error */
|
|
996
|
+
originalError;
|
|
997
|
+
/** Additional context for the error */
|
|
998
|
+
context;
|
|
999
|
+
/** Whether this error should be displayed to the user */
|
|
1000
|
+
displayable;
|
|
1001
|
+
/**
|
|
1002
|
+
* Creates a new DoNotDev error
|
|
1003
|
+
*
|
|
1004
|
+
* @param {string} message - Error message
|
|
1005
|
+
* @param {DoNotDevErrorCode} code - Error code
|
|
1006
|
+
* @param {object} [options] - Additional error options
|
|
1007
|
+
* @param {Error} [options.originalError] - Original error if wrapping
|
|
1008
|
+
* @param {Record<string, any>} [options.context] - Additional context data
|
|
1009
|
+
* @param {boolean} [options.displayable=true] - Whether this error should be displayed to the user
|
|
1010
|
+
*/
|
|
1011
|
+
constructor(message, code = DO_NOT_DEV_ERROR_CODES.UNKNOWN_ERROR, options) {
|
|
1012
|
+
super(message);
|
|
1013
|
+
this.name = "DoNotDevError";
|
|
1014
|
+
this.code = code;
|
|
1015
|
+
this.originalError = options?.originalError;
|
|
1016
|
+
this.context = options?.context;
|
|
1017
|
+
this.displayable = options?.displayable !== false;
|
|
1018
|
+
Object.setPrototypeOf(this, _DoNotDevError.prototype);
|
|
1019
|
+
if (Error.captureStackTrace) {
|
|
1020
|
+
Error.captureStackTrace(this, _DoNotDevError);
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
/**
|
|
1024
|
+
* Formats the error for logging or display
|
|
1025
|
+
*
|
|
1026
|
+
* @returns {string} Formatted error message with code
|
|
1027
|
+
*/
|
|
1028
|
+
format() {
|
|
1029
|
+
return `[${this.code}] ${this.message}`;
|
|
1030
|
+
}
|
|
1031
|
+
/**
|
|
1032
|
+
* Creates a wrapped error from another error
|
|
1033
|
+
*
|
|
1034
|
+
* @param {Error} error - Original error to wrap
|
|
1035
|
+
* @param {string} [context] - Additional context for the error
|
|
1036
|
+
* @param {DoNotDevErrorCode} [code='unknown-error'] - Error code
|
|
1037
|
+
* @param {object} [options] - Additional error options
|
|
1038
|
+
* @param {Record<string, any>} [options.context] - Additional context data
|
|
1039
|
+
* @param {boolean} [options.displayable=true] - Whether this error should be displayed to the user
|
|
1040
|
+
* @returns {DoNotDevError} New DoNotDev error wrapping the original
|
|
1041
|
+
*/
|
|
1042
|
+
static from(error2, context, code = DO_NOT_DEV_ERROR_CODES.UNKNOWN_ERROR, options) {
|
|
1043
|
+
if (!(error2 instanceof Error)) {
|
|
1044
|
+
return new _DoNotDevError(
|
|
1045
|
+
`Unknown error: ${String(error2)}`,
|
|
1046
|
+
code,
|
|
1047
|
+
options
|
|
1048
|
+
);
|
|
1049
|
+
}
|
|
1050
|
+
if (error2 instanceof _DoNotDevError) {
|
|
1051
|
+
if (!context) {
|
|
1052
|
+
return error2;
|
|
1053
|
+
}
|
|
1054
|
+
return new _DoNotDevError(`${context}: ${error2.message}`, error2.code, {
|
|
1055
|
+
originalError: error2.originalError || error2,
|
|
1056
|
+
context: { ...error2.context, ...options?.context || {} },
|
|
1057
|
+
displayable: options?.displayable ?? error2.displayable
|
|
1058
|
+
});
|
|
1059
|
+
}
|
|
1060
|
+
const message = context ? `${context}: ${error2.message}` : error2.message;
|
|
1061
|
+
return new _DoNotDevError(message, code, {
|
|
1062
|
+
originalError: error2,
|
|
1063
|
+
context: options?.context,
|
|
1064
|
+
displayable: options?.displayable
|
|
1065
|
+
});
|
|
1066
|
+
}
|
|
1067
|
+
/**
|
|
1068
|
+
* Maps common error types to DoNotDevErrorCode
|
|
1069
|
+
*
|
|
1070
|
+
* @param {Error} error - Error to analyze
|
|
1071
|
+
* @returns {DoNotDevErrorCode} Mapped error code
|
|
1072
|
+
*/
|
|
1073
|
+
static getErrorCodeFromError(error2) {
|
|
1074
|
+
if (error2 instanceof _DoNotDevError) {
|
|
1075
|
+
return error2.code;
|
|
1076
|
+
}
|
|
1077
|
+
const message = error2.message.toLowerCase();
|
|
1078
|
+
if (error2.name === "ValidationError" || message.includes("validation")) {
|
|
1079
|
+
return DO_NOT_DEV_ERROR_CODES.VALIDATION_ERROR;
|
|
1080
|
+
}
|
|
1081
|
+
if (message.includes("not found") || message.includes("no such file")) {
|
|
1082
|
+
return DO_NOT_DEV_ERROR_CODES.FILE_NOT_FOUND;
|
|
1083
|
+
}
|
|
1084
|
+
if (message.includes("permission") || message.includes("access denied")) {
|
|
1085
|
+
return DO_NOT_DEV_ERROR_CODES.PERMISSION_DENIED;
|
|
1086
|
+
}
|
|
1087
|
+
if (message.includes("timeout") || message.includes("timed out")) {
|
|
1088
|
+
return DO_NOT_DEV_ERROR_CODES.TIMEOUT_ERROR;
|
|
1089
|
+
}
|
|
1090
|
+
if (message.includes("dependency") || message.includes("module not found")) {
|
|
1091
|
+
return DO_NOT_DEV_ERROR_CODES.DEPENDENCY_ERROR;
|
|
1092
|
+
}
|
|
1093
|
+
return DO_NOT_DEV_ERROR_CODES.UNKNOWN_ERROR;
|
|
1094
|
+
}
|
|
1095
|
+
};
|
|
1096
|
+
}
|
|
1097
|
+
});
|
|
1098
|
+
|
|
950
1099
|
// node_modules/.bun/fast-glob@3.3.3/node_modules/fast-glob/out/utils/array.js
|
|
951
1100
|
var require_array = __commonJS({
|
|
952
1101
|
"node_modules/.bun/fast-glob@3.3.3/node_modules/fast-glob/out/utils/array.js"(exports) {
|
|
@@ -6703,7 +6852,7 @@ import {
|
|
|
6703
6852
|
extname
|
|
6704
6853
|
} from "node:path";
|
|
6705
6854
|
import { fileURLToPath } from "node:url";
|
|
6706
|
-
function
|
|
6855
|
+
function safeExecuteAsync2(fn, message) {
|
|
6707
6856
|
return fn().catch((error2) => {
|
|
6708
6857
|
throw new Error(
|
|
6709
6858
|
`${message}: ${error2 instanceof Error ? error2.message : String(error2)}`
|
|
@@ -7085,7 +7234,7 @@ var init_PathResolver = __esm({
|
|
|
7085
7234
|
writeContent = String(content);
|
|
7086
7235
|
}
|
|
7087
7236
|
try {
|
|
7088
|
-
return await
|
|
7237
|
+
return await safeExecuteAsync2(async () => {
|
|
7089
7238
|
if (Buffer.isBuffer(writeContent)) {
|
|
7090
7239
|
await fs.promises.writeFile(normalizedPath, writeContent);
|
|
7091
7240
|
} else {
|
|
@@ -7192,7 +7341,7 @@ var init_PathResolver = __esm({
|
|
|
7192
7341
|
if (error2?.code !== "EEXIST") throw error2;
|
|
7193
7342
|
}
|
|
7194
7343
|
try {
|
|
7195
|
-
return await
|
|
7344
|
+
return await safeExecuteAsync2(async () => {
|
|
7196
7345
|
await fs.promises.copyFile(srcPath, normalizedDestPath);
|
|
7197
7346
|
if (verbose) {
|
|
7198
7347
|
log2.info(
|
|
@@ -7690,154 +7839,6 @@ var init_PathResolver = __esm({
|
|
|
7690
7839
|
}
|
|
7691
7840
|
});
|
|
7692
7841
|
|
|
7693
|
-
// packages/tooling/src/utils/errors.ts
|
|
7694
|
-
async function safeExecuteAsync2(fn, context, code = DO_NOT_DEV_ERROR_CODES.UNKNOWN_ERROR) {
|
|
7695
|
-
try {
|
|
7696
|
-
return await fn();
|
|
7697
|
-
} catch (error2) {
|
|
7698
|
-
throw DoNotDevError.from(error2, context, code);
|
|
7699
|
-
}
|
|
7700
|
-
}
|
|
7701
|
-
var DO_NOT_DEV_ERROR_CODES, DoNotDevError;
|
|
7702
|
-
var init_errors = __esm({
|
|
7703
|
-
"packages/tooling/src/utils/errors.ts"() {
|
|
7704
|
-
"use strict";
|
|
7705
|
-
init_utils();
|
|
7706
|
-
DO_NOT_DEV_ERROR_CODES = {
|
|
7707
|
-
CONFIGURATION_ERROR: "configuration-error",
|
|
7708
|
-
CONFIG_NOT_FOUND: "config-not-found",
|
|
7709
|
-
CONFIG_INVALID: "config-invalid",
|
|
7710
|
-
PATH_RESOLUTION_ERROR: "path-resolution-error",
|
|
7711
|
-
FILE_OPERATION_ERROR: "file-operation-error",
|
|
7712
|
-
FILE_NOT_FOUND: "file-not-found",
|
|
7713
|
-
PERMISSION_DENIED: "permission-denied",
|
|
7714
|
-
GENERATION_ERROR: "generation-error",
|
|
7715
|
-
TEMPLATE_ERROR: "template-error",
|
|
7716
|
-
TEMPLATE_NOT_FOUND: "template-not-found",
|
|
7717
|
-
CLI_EXECUTION_ERROR: "cli-execution-error",
|
|
7718
|
-
COMMAND_NOT_FOUND: "command-not-found",
|
|
7719
|
-
COMMAND_FAILED: "command-failed",
|
|
7720
|
-
VALIDATION_ERROR: "validation-error",
|
|
7721
|
-
SCHEMA_ERROR: "schema-error",
|
|
7722
|
-
DEPENDENCY_ERROR: "dependency-error",
|
|
7723
|
-
DEPENDENCY_NOT_FOUND: "dependency-not-found",
|
|
7724
|
-
DEPENDENCY_VERSION_ERROR: "dependency-version-error",
|
|
7725
|
-
INVALID_ARGUMENT: "invalid-argument",
|
|
7726
|
-
MISSING_ARGUMENT: "missing-argument",
|
|
7727
|
-
MISSING_PROJECT_ID: "missing-project-id",
|
|
7728
|
-
FIREBASE_CLI_ERROR: "firebase-cli-error",
|
|
7729
|
-
DEPLOYMENT_FAILED: "deployment-failed",
|
|
7730
|
-
OPERATION_CANCELLED: "operation-cancelled",
|
|
7731
|
-
TIMEOUT_ERROR: "timeout-error",
|
|
7732
|
-
UNKNOWN_ERROR: "unknown-error"
|
|
7733
|
-
};
|
|
7734
|
-
DoNotDevError = class _DoNotDevError extends Error {
|
|
7735
|
-
/** The error code categorizing this error */
|
|
7736
|
-
code;
|
|
7737
|
-
/** Original error if this is wrapping another error */
|
|
7738
|
-
originalError;
|
|
7739
|
-
/** Additional context for the error */
|
|
7740
|
-
context;
|
|
7741
|
-
/** Whether this error should be displayed to the user */
|
|
7742
|
-
displayable;
|
|
7743
|
-
/**
|
|
7744
|
-
* Creates a new DoNotDev error
|
|
7745
|
-
*
|
|
7746
|
-
* @param {string} message - Error message
|
|
7747
|
-
* @param {DoNotDevErrorCode} code - Error code
|
|
7748
|
-
* @param {object} [options] - Additional error options
|
|
7749
|
-
* @param {Error} [options.originalError] - Original error if wrapping
|
|
7750
|
-
* @param {Record<string, any>} [options.context] - Additional context data
|
|
7751
|
-
* @param {boolean} [options.displayable=true] - Whether this error should be displayed to the user
|
|
7752
|
-
*/
|
|
7753
|
-
constructor(message, code = DO_NOT_DEV_ERROR_CODES.UNKNOWN_ERROR, options) {
|
|
7754
|
-
super(message);
|
|
7755
|
-
this.name = "DoNotDevError";
|
|
7756
|
-
this.code = code;
|
|
7757
|
-
this.originalError = options?.originalError;
|
|
7758
|
-
this.context = options?.context;
|
|
7759
|
-
this.displayable = options?.displayable !== false;
|
|
7760
|
-
Object.setPrototypeOf(this, _DoNotDevError.prototype);
|
|
7761
|
-
if (Error.captureStackTrace) {
|
|
7762
|
-
Error.captureStackTrace(this, _DoNotDevError);
|
|
7763
|
-
}
|
|
7764
|
-
}
|
|
7765
|
-
/**
|
|
7766
|
-
* Formats the error for logging or display
|
|
7767
|
-
*
|
|
7768
|
-
* @returns {string} Formatted error message with code
|
|
7769
|
-
*/
|
|
7770
|
-
format() {
|
|
7771
|
-
return `[${this.code}] ${this.message}`;
|
|
7772
|
-
}
|
|
7773
|
-
/**
|
|
7774
|
-
* Creates a wrapped error from another error
|
|
7775
|
-
*
|
|
7776
|
-
* @param {Error} error - Original error to wrap
|
|
7777
|
-
* @param {string} [context] - Additional context for the error
|
|
7778
|
-
* @param {DoNotDevErrorCode} [code='unknown-error'] - Error code
|
|
7779
|
-
* @param {object} [options] - Additional error options
|
|
7780
|
-
* @param {Record<string, any>} [options.context] - Additional context data
|
|
7781
|
-
* @param {boolean} [options.displayable=true] - Whether this error should be displayed to the user
|
|
7782
|
-
* @returns {DoNotDevError} New DoNotDev error wrapping the original
|
|
7783
|
-
*/
|
|
7784
|
-
static from(error2, context, code = DO_NOT_DEV_ERROR_CODES.UNKNOWN_ERROR, options) {
|
|
7785
|
-
if (!(error2 instanceof Error)) {
|
|
7786
|
-
return new _DoNotDevError(
|
|
7787
|
-
`Unknown error: ${String(error2)}`,
|
|
7788
|
-
code,
|
|
7789
|
-
options
|
|
7790
|
-
);
|
|
7791
|
-
}
|
|
7792
|
-
if (error2 instanceof _DoNotDevError) {
|
|
7793
|
-
if (!context) {
|
|
7794
|
-
return error2;
|
|
7795
|
-
}
|
|
7796
|
-
return new _DoNotDevError(`${context}: ${error2.message}`, error2.code, {
|
|
7797
|
-
originalError: error2.originalError || error2,
|
|
7798
|
-
context: { ...error2.context, ...options?.context || {} },
|
|
7799
|
-
displayable: options?.displayable ?? error2.displayable
|
|
7800
|
-
});
|
|
7801
|
-
}
|
|
7802
|
-
const message = context ? `${context}: ${error2.message}` : error2.message;
|
|
7803
|
-
return new _DoNotDevError(message, code, {
|
|
7804
|
-
originalError: error2,
|
|
7805
|
-
context: options?.context,
|
|
7806
|
-
displayable: options?.displayable
|
|
7807
|
-
});
|
|
7808
|
-
}
|
|
7809
|
-
/**
|
|
7810
|
-
* Maps common error types to DoNotDevErrorCode
|
|
7811
|
-
*
|
|
7812
|
-
* @param {Error} error - Error to analyze
|
|
7813
|
-
* @returns {DoNotDevErrorCode} Mapped error code
|
|
7814
|
-
*/
|
|
7815
|
-
static getErrorCodeFromError(error2) {
|
|
7816
|
-
if (error2 instanceof _DoNotDevError) {
|
|
7817
|
-
return error2.code;
|
|
7818
|
-
}
|
|
7819
|
-
const message = error2.message.toLowerCase();
|
|
7820
|
-
if (error2.name === "ValidationError" || message.includes("validation")) {
|
|
7821
|
-
return DO_NOT_DEV_ERROR_CODES.VALIDATION_ERROR;
|
|
7822
|
-
}
|
|
7823
|
-
if (message.includes("not found") || message.includes("no such file")) {
|
|
7824
|
-
return DO_NOT_DEV_ERROR_CODES.FILE_NOT_FOUND;
|
|
7825
|
-
}
|
|
7826
|
-
if (message.includes("permission") || message.includes("access denied")) {
|
|
7827
|
-
return DO_NOT_DEV_ERROR_CODES.PERMISSION_DENIED;
|
|
7828
|
-
}
|
|
7829
|
-
if (message.includes("timeout") || message.includes("timed out")) {
|
|
7830
|
-
return DO_NOT_DEV_ERROR_CODES.TIMEOUT_ERROR;
|
|
7831
|
-
}
|
|
7832
|
-
if (message.includes("dependency") || message.includes("module not found")) {
|
|
7833
|
-
return DO_NOT_DEV_ERROR_CODES.DEPENDENCY_ERROR;
|
|
7834
|
-
}
|
|
7835
|
-
return DO_NOT_DEV_ERROR_CODES.UNKNOWN_ERROR;
|
|
7836
|
-
}
|
|
7837
|
-
};
|
|
7838
|
-
}
|
|
7839
|
-
});
|
|
7840
|
-
|
|
7841
7842
|
// packages/tooling/src/utils/pathResolver.ts
|
|
7842
7843
|
import { createRequire as createRequire2 } from "node:module";
|
|
7843
7844
|
import {
|
|
@@ -8028,8 +8029,8 @@ var init_typed_file_operations = __esm({
|
|
|
8028
8029
|
"packages/tooling/src/utils/typed-file-operations.ts"() {
|
|
8029
8030
|
"use strict";
|
|
8030
8031
|
init_utils();
|
|
8031
|
-
init_pathResolver();
|
|
8032
8032
|
init_errors();
|
|
8033
|
+
init_pathResolver();
|
|
8033
8034
|
}
|
|
8034
8035
|
});
|
|
8035
8036
|
|
|
@@ -8251,6 +8252,124 @@ var init_cli_input = __esm({
|
|
|
8251
8252
|
}
|
|
8252
8253
|
});
|
|
8253
8254
|
|
|
8255
|
+
// packages/tooling/src/utils/error-handling.ts
|
|
8256
|
+
function isError(error2) {
|
|
8257
|
+
return error2 instanceof Error;
|
|
8258
|
+
}
|
|
8259
|
+
function getErrorMessage(error2) {
|
|
8260
|
+
if (isError(error2)) {
|
|
8261
|
+
return error2.message;
|
|
8262
|
+
}
|
|
8263
|
+
if (typeof error2 === "string") {
|
|
8264
|
+
return error2;
|
|
8265
|
+
}
|
|
8266
|
+
if (error2 && typeof error2 === "object" && "message" in error2) {
|
|
8267
|
+
return String(error2.message);
|
|
8268
|
+
}
|
|
8269
|
+
return String(error2);
|
|
8270
|
+
}
|
|
8271
|
+
var init_error_handling = __esm({
|
|
8272
|
+
"packages/tooling/src/utils/error-handling.ts"() {
|
|
8273
|
+
"use strict";
|
|
8274
|
+
init_utils();
|
|
8275
|
+
}
|
|
8276
|
+
});
|
|
8277
|
+
|
|
8278
|
+
// packages/tooling/src/apps/vercel-api.ts
|
|
8279
|
+
function formatVercelError(status, body, context) {
|
|
8280
|
+
let vercelCode;
|
|
8281
|
+
let vercelMessage;
|
|
8282
|
+
try {
|
|
8283
|
+
const parsed = JSON.parse(body);
|
|
8284
|
+
const err = parsed.error ?? parsed;
|
|
8285
|
+
vercelCode = err.code;
|
|
8286
|
+
vercelMessage = err.message;
|
|
8287
|
+
} catch {
|
|
8288
|
+
}
|
|
8289
|
+
let message;
|
|
8290
|
+
switch (status) {
|
|
8291
|
+
case 401:
|
|
8292
|
+
message = "Vercel token is invalid or expired. Generate a new one at https://vercel.com/account/tokens and update .dndev.secrets";
|
|
8293
|
+
break;
|
|
8294
|
+
case 403:
|
|
8295
|
+
if (vercelCode === "team_unauthorized" || body.includes("teamId")) {
|
|
8296
|
+
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.";
|
|
8297
|
+
} else {
|
|
8298
|
+
message = `Vercel access denied: ${vercelMessage ?? "check token scope and permissions"}`;
|
|
8299
|
+
}
|
|
8300
|
+
break;
|
|
8301
|
+
case 404:
|
|
8302
|
+
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.";
|
|
8303
|
+
break;
|
|
8304
|
+
case 400:
|
|
8305
|
+
if (vercelCode === "invalid_project_name") {
|
|
8306
|
+
message = "Vercel rejected the project name. This is a framework bug \u2014 please report it.";
|
|
8307
|
+
} else {
|
|
8308
|
+
message = `Vercel rejected the request: ${vercelMessage ?? body}`;
|
|
8309
|
+
}
|
|
8310
|
+
break;
|
|
8311
|
+
case 429:
|
|
8312
|
+
message = "Vercel rate limit hit. Wait a few minutes and try again.";
|
|
8313
|
+
break;
|
|
8314
|
+
default:
|
|
8315
|
+
message = `Vercel API error during ${context} (${status}): ${vercelMessage ?? body}`;
|
|
8316
|
+
}
|
|
8317
|
+
return new DoNotDevError(message, DO_NOT_DEV_ERROR_CODES.VERCEL_API_ERROR, {
|
|
8318
|
+
context: { status, vercelCode, context }
|
|
8319
|
+
});
|
|
8320
|
+
}
|
|
8321
|
+
async function validateToken(token) {
|
|
8322
|
+
const res = await fetch(`${VERCEL_API}/v2/user`, {
|
|
8323
|
+
headers: { Authorization: `Bearer ${token}` }
|
|
8324
|
+
});
|
|
8325
|
+
if (!res.ok) {
|
|
8326
|
+
const body = await res.text();
|
|
8327
|
+
throw formatVercelError(res.status, body, "validate token");
|
|
8328
|
+
}
|
|
8329
|
+
const data = await res.json();
|
|
8330
|
+
return { username: data.user.username, email: data.user.email };
|
|
8331
|
+
}
|
|
8332
|
+
async function validateProject(token, projectId, orgId) {
|
|
8333
|
+
const q2 = orgId ? `?teamId=${encodeURIComponent(orgId)}` : "";
|
|
8334
|
+
const res = await fetch(
|
|
8335
|
+
`${VERCEL_API}/v9/projects/${encodeURIComponent(projectId)}${q2}`,
|
|
8336
|
+
{
|
|
8337
|
+
headers: { Authorization: `Bearer ${token}` }
|
|
8338
|
+
}
|
|
8339
|
+
);
|
|
8340
|
+
if (!res.ok) {
|
|
8341
|
+
const body = await res.text();
|
|
8342
|
+
throw formatVercelError(res.status, body, "validate project");
|
|
8343
|
+
}
|
|
8344
|
+
const data = await res.json();
|
|
8345
|
+
return { projectName: data.name };
|
|
8346
|
+
}
|
|
8347
|
+
async function detectAccountType(token) {
|
|
8348
|
+
const res = await fetch(`${VERCEL_API}/v2/teams`, {
|
|
8349
|
+
headers: { Authorization: `Bearer ${token}` }
|
|
8350
|
+
});
|
|
8351
|
+
if (!res.ok) {
|
|
8352
|
+
const body = await res.text();
|
|
8353
|
+
throw formatVercelError(res.status, body, "detect account type");
|
|
8354
|
+
}
|
|
8355
|
+
const data = await res.json();
|
|
8356
|
+
const teams = data.teams.map((t) => ({
|
|
8357
|
+
id: t.id,
|
|
8358
|
+
name: t.name,
|
|
8359
|
+
slug: t.slug
|
|
8360
|
+
}));
|
|
8361
|
+
return { hasTeams: teams.length > 0, teams };
|
|
8362
|
+
}
|
|
8363
|
+
var VERCEL_API;
|
|
8364
|
+
var init_vercel_api = __esm({
|
|
8365
|
+
"packages/tooling/src/apps/vercel-api.ts"() {
|
|
8366
|
+
"use strict";
|
|
8367
|
+
init_utils();
|
|
8368
|
+
init_errors();
|
|
8369
|
+
VERCEL_API = "https://api.vercel.com";
|
|
8370
|
+
}
|
|
8371
|
+
});
|
|
8372
|
+
|
|
8254
8373
|
// packages/tooling/src/utils/secrets-resolver.ts
|
|
8255
8374
|
function parseEnvFile(filePath) {
|
|
8256
8375
|
if (!pathExists(filePath)) return {};
|
|
@@ -8301,10 +8420,6 @@ function loadDndevSecrets(projectRoot) {
|
|
|
8301
8420
|
}
|
|
8302
8421
|
function resolveSecret(name, projectRoot, opts) {
|
|
8303
8422
|
const appDir = opts?.appDir ?? projectRoot;
|
|
8304
|
-
const envValue = process.env[name];
|
|
8305
|
-
if (envValue) {
|
|
8306
|
-
return { value: envValue, source: "process.env" };
|
|
8307
|
-
}
|
|
8308
8423
|
const secrets = loadDndevSecrets(projectRoot);
|
|
8309
8424
|
if (secrets[name]) {
|
|
8310
8425
|
return { value: secrets[name], source: ".dndev.secrets" };
|
|
@@ -8315,6 +8430,10 @@ function resolveSecret(name, projectRoot, opts) {
|
|
|
8315
8430
|
source: ".dndev.secrets"
|
|
8316
8431
|
};
|
|
8317
8432
|
}
|
|
8433
|
+
const envValue = process.env[name];
|
|
8434
|
+
if (envValue) {
|
|
8435
|
+
return { value: envValue, source: "process.env" };
|
|
8436
|
+
}
|
|
8318
8437
|
const legacyPaths = LEGACY_PATHS[name];
|
|
8319
8438
|
if (legacyPaths) {
|
|
8320
8439
|
for (const relPath of legacyPaths) {
|
|
@@ -8350,8 +8469,8 @@ var init_secrets_resolver = __esm({
|
|
|
8350
8469
|
"packages/tooling/src/utils/secrets-resolver.ts"() {
|
|
8351
8470
|
"use strict";
|
|
8352
8471
|
init_utils();
|
|
8353
|
-
init_pathResolver();
|
|
8354
8472
|
init_cli_output();
|
|
8473
|
+
init_pathResolver();
|
|
8355
8474
|
LEGACY_PATHS = {
|
|
8356
8475
|
VERCEL_TOKEN: [".env.local"],
|
|
8357
8476
|
SUPABASE_SECRET_KEY: ["supabase/functions/.env", "functions/.env"],
|
|
@@ -8368,11 +8487,11 @@ var init_secrets_resolver = __esm({
|
|
|
8368
8487
|
|
|
8369
8488
|
// packages/tooling/src/cli/setup/vercel-token.ts
|
|
8370
8489
|
function resolvePerAppVar(appDir, varName) {
|
|
8371
|
-
if (process.env[varName]) return process.env[varName];
|
|
8372
8490
|
const fromLocal = readEnvVar(joinPath(appDir, ".env.local"), varName);
|
|
8373
8491
|
if (fromLocal) return fromLocal;
|
|
8374
8492
|
const fromEnv = readEnvVar(joinPath(appDir, ".env"), varName);
|
|
8375
8493
|
if (fromEnv) return fromEnv;
|
|
8494
|
+
if (process.env[varName]) return process.env[varName];
|
|
8376
8495
|
return null;
|
|
8377
8496
|
}
|
|
8378
8497
|
function resolveVercelCredentials(appDir, projectRoot) {
|
|
@@ -8382,42 +8501,22 @@ function resolveVercelCredentials(appDir, projectRoot) {
|
|
|
8382
8501
|
const projectId = resolvePerAppVar(appDir, "VERCEL_PROJECT_ID");
|
|
8383
8502
|
const missing = [];
|
|
8384
8503
|
if (!token) missing.push("VERCEL_TOKEN");
|
|
8385
|
-
if (!orgId) missing.push("VERCEL_ORG_ID");
|
|
8386
8504
|
if (!projectId) missing.push("VERCEL_PROJECT_ID");
|
|
8387
8505
|
if (missing.length > 0) return { missing };
|
|
8388
8506
|
return {
|
|
8389
|
-
credentials: {
|
|
8507
|
+
credentials: {
|
|
8508
|
+
token,
|
|
8509
|
+
orgId: orgId ?? void 0,
|
|
8510
|
+
projectId
|
|
8511
|
+
}
|
|
8390
8512
|
};
|
|
8391
8513
|
}
|
|
8392
8514
|
var init_vercel_token = __esm({
|
|
8393
8515
|
"packages/tooling/src/cli/setup/vercel-token.ts"() {
|
|
8394
8516
|
"use strict";
|
|
8395
8517
|
init_utils();
|
|
8396
|
-
init_secrets_resolver();
|
|
8397
8518
|
init_pathResolver();
|
|
8398
|
-
|
|
8399
|
-
});
|
|
8400
|
-
|
|
8401
|
-
// packages/tooling/src/utils/error-handling.ts
|
|
8402
|
-
function isError(error2) {
|
|
8403
|
-
return error2 instanceof Error;
|
|
8404
|
-
}
|
|
8405
|
-
function getErrorMessage(error2) {
|
|
8406
|
-
if (isError(error2)) {
|
|
8407
|
-
return error2.message;
|
|
8408
|
-
}
|
|
8409
|
-
if (typeof error2 === "string") {
|
|
8410
|
-
return error2;
|
|
8411
|
-
}
|
|
8412
|
-
if (error2 && typeof error2 === "object" && "message" in error2) {
|
|
8413
|
-
return String(error2.message);
|
|
8414
|
-
}
|
|
8415
|
-
return String(error2);
|
|
8416
|
-
}
|
|
8417
|
-
var init_error_handling = __esm({
|
|
8418
|
-
"packages/tooling/src/utils/error-handling.ts"() {
|
|
8419
|
-
"use strict";
|
|
8420
|
-
init_utils();
|
|
8519
|
+
init_secrets_resolver();
|
|
8421
8520
|
}
|
|
8422
8521
|
});
|
|
8423
8522
|
|
|
@@ -8852,13 +8951,13 @@ var init_firebase = __esm({
|
|
|
8852
8951
|
"packages/tooling/src/cli/setup/firebase.ts"() {
|
|
8853
8952
|
"use strict";
|
|
8854
8953
|
init_utils();
|
|
8954
|
+
init_types();
|
|
8955
|
+
init_app_selector();
|
|
8956
|
+
init_cli_input();
|
|
8855
8957
|
init_cli_output();
|
|
8856
8958
|
init_cli_output();
|
|
8857
|
-
init_cli_input();
|
|
8858
|
-
init_pathResolver();
|
|
8859
|
-
init_app_selector();
|
|
8860
8959
|
init_error_handling();
|
|
8861
|
-
|
|
8960
|
+
init_pathResolver();
|
|
8862
8961
|
firebase_default = main;
|
|
8863
8962
|
firebaseWizard = {
|
|
8864
8963
|
id: "firebase",
|
|
@@ -9278,7 +9377,7 @@ var init_base_generator = __esm({
|
|
|
9278
9377
|
return true;
|
|
9279
9378
|
}
|
|
9280
9379
|
await ensureDir(dir);
|
|
9281
|
-
const writeResult = await
|
|
9380
|
+
const writeResult = await safeExecuteAsync(
|
|
9282
9381
|
async () => {
|
|
9283
9382
|
await write(normalizedPath, content, { overwrite: true });
|
|
9284
9383
|
return true;
|
|
@@ -9416,7 +9515,7 @@ var init_base_generator = __esm({
|
|
|
9416
9515
|
return true;
|
|
9417
9516
|
}
|
|
9418
9517
|
await ensureDir(getDirname(normalizedOutputPath));
|
|
9419
|
-
const copyResult = await
|
|
9518
|
+
const copyResult = await safeExecuteAsync(
|
|
9420
9519
|
async () => {
|
|
9421
9520
|
await copy(resolvedPath, normalizedOutputPath);
|
|
9422
9521
|
return true;
|
|
@@ -10420,14 +10519,14 @@ var init_supabase = __esm({
|
|
|
10420
10519
|
"packages/tooling/src/cli/setup/supabase.ts"() {
|
|
10421
10520
|
"use strict";
|
|
10422
10521
|
init_utils();
|
|
10423
|
-
|
|
10522
|
+
init_types();
|
|
10523
|
+
init_app_selector();
|
|
10424
10524
|
init_cli_input();
|
|
10525
|
+
init_cli_output();
|
|
10526
|
+
init_error_handling();
|
|
10425
10527
|
init_pathResolver();
|
|
10426
|
-
init_app_selector();
|
|
10427
|
-
init_supabase_management();
|
|
10428
10528
|
init_secrets_resolver();
|
|
10429
|
-
|
|
10430
|
-
init_types();
|
|
10529
|
+
init_supabase_management();
|
|
10431
10530
|
supabase_default = main3;
|
|
10432
10531
|
supabaseWizard = {
|
|
10433
10532
|
id: "supabase",
|
|
@@ -10579,10 +10678,12 @@ var init_vercel = __esm({
|
|
|
10579
10678
|
"packages/tooling/src/cli/setup/vercel.ts"() {
|
|
10580
10679
|
"use strict";
|
|
10581
10680
|
init_utils();
|
|
10582
|
-
init_cli_output();
|
|
10583
|
-
init_pathResolver();
|
|
10584
10681
|
init_types();
|
|
10585
10682
|
init_vercel_token();
|
|
10683
|
+
init_vercel_api();
|
|
10684
|
+
init_cli_output();
|
|
10685
|
+
init_errors();
|
|
10686
|
+
init_pathResolver();
|
|
10586
10687
|
vercelWizard = {
|
|
10587
10688
|
id: "vercel",
|
|
10588
10689
|
name: "Vercel",
|
|
@@ -10592,19 +10693,118 @@ var init_vercel = __esm({
|
|
|
10592
10693
|
async run(ctx) {
|
|
10593
10694
|
const steps = [];
|
|
10594
10695
|
const result = resolveVercelCredentials(ctx.appDir);
|
|
10595
|
-
if (result.
|
|
10596
|
-
|
|
10696
|
+
if (result.missing) {
|
|
10697
|
+
for (const varName of result.missing) {
|
|
10698
|
+
const target = varName === "VERCEL_TOKEN" ? ".dndev.secrets" : `apps/<app>/.env`;
|
|
10699
|
+
const where = varName === "VERCEL_TOKEN" ? "https://vercel.com/account/tokens" : "Vercel Dashboard > Project > Settings > General";
|
|
10700
|
+
log.error(`Missing ${varName} \u2014 add to ${target}`);
|
|
10701
|
+
log.info(` Find it at: ${where}`);
|
|
10702
|
+
steps.push({
|
|
10703
|
+
name: varName,
|
|
10704
|
+
status: "failed",
|
|
10705
|
+
message: `Missing. Add to ${target}`
|
|
10706
|
+
});
|
|
10707
|
+
}
|
|
10708
|
+
return {
|
|
10709
|
+
provider: "vercel",
|
|
10710
|
+
steps,
|
|
10711
|
+
overallStatus: computeOverallStatus(steps)
|
|
10712
|
+
};
|
|
10713
|
+
}
|
|
10714
|
+
const { token, orgId, projectId } = result.credentials;
|
|
10715
|
+
steps.push({
|
|
10716
|
+
name: "Credentials",
|
|
10717
|
+
status: "success",
|
|
10718
|
+
message: "VERCEL_TOKEN and VERCEL_PROJECT_ID found"
|
|
10719
|
+
});
|
|
10720
|
+
try {
|
|
10721
|
+
const user = await validateToken(token);
|
|
10722
|
+
log.success(
|
|
10723
|
+
`Token valid \u2014 logged in as ${user.username} (${user.email})`
|
|
10724
|
+
);
|
|
10597
10725
|
steps.push({
|
|
10598
|
-
name: "
|
|
10726
|
+
name: "Token validation",
|
|
10599
10727
|
status: "success",
|
|
10600
|
-
message:
|
|
10728
|
+
message: `Authenticated as ${user.username}`
|
|
10601
10729
|
});
|
|
10602
|
-
}
|
|
10603
|
-
|
|
10730
|
+
} catch (err) {
|
|
10731
|
+
const msg = err instanceof DoNotDevError ? err.message : "Token validation failed";
|
|
10732
|
+
log.error(msg);
|
|
10604
10733
|
steps.push({
|
|
10605
|
-
name: "
|
|
10734
|
+
name: "Token validation",
|
|
10735
|
+
status: "failed",
|
|
10736
|
+
message: msg
|
|
10737
|
+
});
|
|
10738
|
+
return {
|
|
10739
|
+
provider: "vercel",
|
|
10740
|
+
steps,
|
|
10741
|
+
overallStatus: "failed"
|
|
10742
|
+
};
|
|
10743
|
+
}
|
|
10744
|
+
try {
|
|
10745
|
+
const account = await detectAccountType(token);
|
|
10746
|
+
if (account.hasTeams) {
|
|
10747
|
+
const teamNames = account.teams.map((t) => t.name).join(", ");
|
|
10748
|
+
log.info(`Account type: Team/Pro (teams: ${teamNames})`);
|
|
10749
|
+
if (!orgId) {
|
|
10750
|
+
log.warn(
|
|
10751
|
+
"Team account detected but VERCEL_ORG_ID is not set. Add your Team ID to apps/<app>/.env as VERCEL_ORG_ID."
|
|
10752
|
+
);
|
|
10753
|
+
steps.push({
|
|
10754
|
+
name: "Account type",
|
|
10755
|
+
status: "needs-manual",
|
|
10756
|
+
message: `Team account \u2014 VERCEL_ORG_ID should be set (teams: ${teamNames})`
|
|
10757
|
+
});
|
|
10758
|
+
} else {
|
|
10759
|
+
steps.push({
|
|
10760
|
+
name: "Account type",
|
|
10761
|
+
status: "success",
|
|
10762
|
+
message: `Team account with VERCEL_ORG_ID set`
|
|
10763
|
+
});
|
|
10764
|
+
}
|
|
10765
|
+
} else {
|
|
10766
|
+
log.info("Account type: Hobby/Free (no teams)");
|
|
10767
|
+
if (orgId) {
|
|
10768
|
+
log.warn(
|
|
10769
|
+
"Hobby account detected but VERCEL_ORG_ID is set. This causes 403 errors. Remove VERCEL_ORG_ID from apps/<app>/.env."
|
|
10770
|
+
);
|
|
10771
|
+
steps.push({
|
|
10772
|
+
name: "Account type",
|
|
10773
|
+
status: "failed",
|
|
10774
|
+
message: "Hobby account with VERCEL_ORG_ID set \u2014 remove it to avoid 403"
|
|
10775
|
+
});
|
|
10776
|
+
} else {
|
|
10777
|
+
steps.push({
|
|
10778
|
+
name: "Account type",
|
|
10779
|
+
status: "success",
|
|
10780
|
+
message: "Hobby account \u2014 no VERCEL_ORG_ID needed"
|
|
10781
|
+
});
|
|
10782
|
+
}
|
|
10783
|
+
}
|
|
10784
|
+
} catch (err) {
|
|
10785
|
+
const msg = err instanceof DoNotDevError ? err.message : "Account type detection failed";
|
|
10786
|
+
log.warn(msg);
|
|
10787
|
+
steps.push({
|
|
10788
|
+
name: "Account type",
|
|
10789
|
+
status: "needs-manual",
|
|
10790
|
+
message: msg
|
|
10791
|
+
});
|
|
10792
|
+
}
|
|
10793
|
+
try {
|
|
10794
|
+
const project = await validateProject(token, projectId, orgId);
|
|
10795
|
+
log.success(`Project accessible: ${project.projectName}`);
|
|
10796
|
+
steps.push({
|
|
10797
|
+
name: "Project access",
|
|
10798
|
+
status: "success",
|
|
10799
|
+
message: `Project "${project.projectName}" is accessible`
|
|
10800
|
+
});
|
|
10801
|
+
} catch (err) {
|
|
10802
|
+
const msg = err instanceof DoNotDevError ? err.message : "Project validation failed";
|
|
10803
|
+
log.error(msg);
|
|
10804
|
+
steps.push({
|
|
10805
|
+
name: "Project access",
|
|
10606
10806
|
status: "failed",
|
|
10607
|
-
message:
|
|
10807
|
+
message: msg
|
|
10608
10808
|
});
|
|
10609
10809
|
}
|
|
10610
10810
|
return {
|
|
@@ -10628,14 +10828,11 @@ init_utils();
|
|
|
10628
10828
|
|
|
10629
10829
|
// packages/tooling/src/cli/setup/setup.ts
|
|
10630
10830
|
init_utils();
|
|
10631
|
-
init_cli_output();
|
|
10632
|
-
init_pathResolver();
|
|
10633
|
-
init_cross_app_detection();
|
|
10634
10831
|
|
|
10635
10832
|
// packages/tooling/src/cli/setup/validate-env.ts
|
|
10636
10833
|
init_utils();
|
|
10637
|
-
init_pathResolver();
|
|
10638
10834
|
init_cli_output();
|
|
10835
|
+
init_pathResolver();
|
|
10639
10836
|
init_secrets_resolver();
|
|
10640
10837
|
var FIREBASE_VARS = [
|
|
10641
10838
|
{
|
|
@@ -10819,6 +11016,9 @@ function printAllValidationResults(results, multiApp) {
|
|
|
10819
11016
|
}
|
|
10820
11017
|
|
|
10821
11018
|
// packages/tooling/src/cli/setup/setup.ts
|
|
11019
|
+
init_cli_output();
|
|
11020
|
+
init_cross_app_detection();
|
|
11021
|
+
init_pathResolver();
|
|
10822
11022
|
var WIZARD_REGISTRY = {
|
|
10823
11023
|
firebase: async () => (await Promise.resolve().then(() => (init_firebase(), firebase_exports))).firebaseWizard,
|
|
10824
11024
|
supabase: async () => (await Promise.resolve().then(() => (init_supabase(), supabase_exports))).supabaseWizard,
|