@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.
- package/README.md +7 -295
- package/dependencies-matrix.json +47 -135
- package/dist/bin/commands/agent-setup.js +3 -3
- package/dist/bin/commands/build.js +144 -143
- package/dist/bin/commands/bump.js +146 -145
- package/dist/bin/commands/cacheout.js +143 -142
- package/dist/bin/commands/coach.js +157 -152
- package/dist/bin/commands/create-app.js +23 -23
- package/dist/bin/commands/create-project.js +166 -165
- package/dist/bin/commands/db.js +46705 -46704
- package/dist/bin/commands/deploy.js +684 -580
- package/dist/bin/commands/dev.js +180 -160
- package/dist/bin/commands/doctor.js +153 -152
- package/dist/bin/commands/emu.js +174 -168
- package/dist/bin/commands/format.js +144 -143
- package/dist/bin/commands/get-demo.js +2 -2
- package/dist/bin/commands/make-admin.js +64122 -64043
- package/dist/bin/commands/preview.js +179 -160
- package/dist/bin/commands/seed.js +46705 -46704
- package/dist/bin/commands/setup-cicd.js +165 -159
- package/dist/bin/commands/setup.js +414 -214
- package/dist/bin/commands/staging.js +684 -580
- package/dist/bin/commands/sync-secrets.js +143 -142
- package/dist/bin/commands/type-check.js +143 -142
- package/dist/bin/commands/wai.js +1 -1
- package/dist/bin/dndev.js +79 -1
- package/dist/index.js +713 -593
- package/package.json +1 -1
- package/templates/root-consumer/.cursor/mcp.json.example +1 -1
- package/templates/root-consumer/.gemini/settings.json.example +1 -1
- package/templates/root-consumer/.mcp.json.example +1 -1
- package/templates/root-consumer/bunfig.toml.example +6 -53
- package/templates/root-consumer/guides/dndev/SETUP_VERCEL.md.example +26 -9
- package/templates/root-consumer/vercel.json.example +2 -1
|
@@ -947,6 +947,148 @@ var init_cli_output = __esm({
|
|
|
947
947
|
}
|
|
948
948
|
});
|
|
949
949
|
|
|
950
|
+
// packages/tooling/src/utils/errors.ts
|
|
951
|
+
var DO_NOT_DEV_ERROR_CODES, DoNotDevError;
|
|
952
|
+
var init_errors = __esm({
|
|
953
|
+
"packages/tooling/src/utils/errors.ts"() {
|
|
954
|
+
"use strict";
|
|
955
|
+
init_utils();
|
|
956
|
+
DO_NOT_DEV_ERROR_CODES = {
|
|
957
|
+
CONFIGURATION_ERROR: "configuration-error",
|
|
958
|
+
CONFIG_NOT_FOUND: "config-not-found",
|
|
959
|
+
CONFIG_INVALID: "config-invalid",
|
|
960
|
+
PATH_RESOLUTION_ERROR: "path-resolution-error",
|
|
961
|
+
FILE_OPERATION_ERROR: "file-operation-error",
|
|
962
|
+
FILE_NOT_FOUND: "file-not-found",
|
|
963
|
+
PERMISSION_DENIED: "permission-denied",
|
|
964
|
+
GENERATION_ERROR: "generation-error",
|
|
965
|
+
TEMPLATE_ERROR: "template-error",
|
|
966
|
+
TEMPLATE_NOT_FOUND: "template-not-found",
|
|
967
|
+
CLI_EXECUTION_ERROR: "cli-execution-error",
|
|
968
|
+
COMMAND_NOT_FOUND: "command-not-found",
|
|
969
|
+
COMMAND_FAILED: "command-failed",
|
|
970
|
+
VALIDATION_ERROR: "validation-error",
|
|
971
|
+
SCHEMA_ERROR: "schema-error",
|
|
972
|
+
DEPENDENCY_ERROR: "dependency-error",
|
|
973
|
+
DEPENDENCY_NOT_FOUND: "dependency-not-found",
|
|
974
|
+
DEPENDENCY_VERSION_ERROR: "dependency-version-error",
|
|
975
|
+
INVALID_ARGUMENT: "invalid-argument",
|
|
976
|
+
MISSING_ARGUMENT: "missing-argument",
|
|
977
|
+
MISSING_PROJECT_ID: "missing-project-id",
|
|
978
|
+
FIREBASE_CLI_ERROR: "firebase-cli-error",
|
|
979
|
+
DEPLOYMENT_FAILED: "deployment-failed",
|
|
980
|
+
VERCEL_API_ERROR: "vercel-api-error",
|
|
981
|
+
OPERATION_CANCELLED: "operation-cancelled",
|
|
982
|
+
TIMEOUT_ERROR: "timeout-error",
|
|
983
|
+
UNKNOWN_ERROR: "unknown-error"
|
|
984
|
+
};
|
|
985
|
+
DoNotDevError = class _DoNotDevError extends Error {
|
|
986
|
+
/** The error code categorizing this error */
|
|
987
|
+
code;
|
|
988
|
+
/** Original error if this is wrapping another error */
|
|
989
|
+
originalError;
|
|
990
|
+
/** Additional context for the error */
|
|
991
|
+
context;
|
|
992
|
+
/** Whether this error should be displayed to the user */
|
|
993
|
+
displayable;
|
|
994
|
+
/**
|
|
995
|
+
* Creates a new DoNotDev error
|
|
996
|
+
*
|
|
997
|
+
* @param {string} message - Error message
|
|
998
|
+
* @param {DoNotDevErrorCode} code - Error code
|
|
999
|
+
* @param {object} [options] - Additional error options
|
|
1000
|
+
* @param {Error} [options.originalError] - Original error if wrapping
|
|
1001
|
+
* @param {Record<string, any>} [options.context] - Additional context data
|
|
1002
|
+
* @param {boolean} [options.displayable=true] - Whether this error should be displayed to the user
|
|
1003
|
+
*/
|
|
1004
|
+
constructor(message, code = DO_NOT_DEV_ERROR_CODES.UNKNOWN_ERROR, options) {
|
|
1005
|
+
super(message);
|
|
1006
|
+
this.name = "DoNotDevError";
|
|
1007
|
+
this.code = code;
|
|
1008
|
+
this.originalError = options?.originalError;
|
|
1009
|
+
this.context = options?.context;
|
|
1010
|
+
this.displayable = options?.displayable !== false;
|
|
1011
|
+
Object.setPrototypeOf(this, _DoNotDevError.prototype);
|
|
1012
|
+
if (Error.captureStackTrace) {
|
|
1013
|
+
Error.captureStackTrace(this, _DoNotDevError);
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
/**
|
|
1017
|
+
* Formats the error for logging or display
|
|
1018
|
+
*
|
|
1019
|
+
* @returns {string} Formatted error message with code
|
|
1020
|
+
*/
|
|
1021
|
+
format() {
|
|
1022
|
+
return `[${this.code}] ${this.message}`;
|
|
1023
|
+
}
|
|
1024
|
+
/**
|
|
1025
|
+
* Creates a wrapped error from another error
|
|
1026
|
+
*
|
|
1027
|
+
* @param {Error} error - Original error to wrap
|
|
1028
|
+
* @param {string} [context] - Additional context for the error
|
|
1029
|
+
* @param {DoNotDevErrorCode} [code='unknown-error'] - Error code
|
|
1030
|
+
* @param {object} [options] - Additional error options
|
|
1031
|
+
* @param {Record<string, any>} [options.context] - Additional context data
|
|
1032
|
+
* @param {boolean} [options.displayable=true] - Whether this error should be displayed to the user
|
|
1033
|
+
* @returns {DoNotDevError} New DoNotDev error wrapping the original
|
|
1034
|
+
*/
|
|
1035
|
+
static from(error2, context, code = DO_NOT_DEV_ERROR_CODES.UNKNOWN_ERROR, options) {
|
|
1036
|
+
if (!(error2 instanceof Error)) {
|
|
1037
|
+
return new _DoNotDevError(
|
|
1038
|
+
`Unknown error: ${String(error2)}`,
|
|
1039
|
+
code,
|
|
1040
|
+
options
|
|
1041
|
+
);
|
|
1042
|
+
}
|
|
1043
|
+
if (error2 instanceof _DoNotDevError) {
|
|
1044
|
+
if (!context) {
|
|
1045
|
+
return error2;
|
|
1046
|
+
}
|
|
1047
|
+
return new _DoNotDevError(`${context}: ${error2.message}`, error2.code, {
|
|
1048
|
+
originalError: error2.originalError || error2,
|
|
1049
|
+
context: { ...error2.context, ...options?.context || {} },
|
|
1050
|
+
displayable: options?.displayable ?? error2.displayable
|
|
1051
|
+
});
|
|
1052
|
+
}
|
|
1053
|
+
const message = context ? `${context}: ${error2.message}` : error2.message;
|
|
1054
|
+
return new _DoNotDevError(message, code, {
|
|
1055
|
+
originalError: error2,
|
|
1056
|
+
context: options?.context,
|
|
1057
|
+
displayable: options?.displayable
|
|
1058
|
+
});
|
|
1059
|
+
}
|
|
1060
|
+
/**
|
|
1061
|
+
* Maps common error types to DoNotDevErrorCode
|
|
1062
|
+
*
|
|
1063
|
+
* @param {Error} error - Error to analyze
|
|
1064
|
+
* @returns {DoNotDevErrorCode} Mapped error code
|
|
1065
|
+
*/
|
|
1066
|
+
static getErrorCodeFromError(error2) {
|
|
1067
|
+
if (error2 instanceof _DoNotDevError) {
|
|
1068
|
+
return error2.code;
|
|
1069
|
+
}
|
|
1070
|
+
const message = error2.message.toLowerCase();
|
|
1071
|
+
if (error2.name === "ValidationError" || message.includes("validation")) {
|
|
1072
|
+
return DO_NOT_DEV_ERROR_CODES.VALIDATION_ERROR;
|
|
1073
|
+
}
|
|
1074
|
+
if (message.includes("not found") || message.includes("no such file")) {
|
|
1075
|
+
return DO_NOT_DEV_ERROR_CODES.FILE_NOT_FOUND;
|
|
1076
|
+
}
|
|
1077
|
+
if (message.includes("permission") || message.includes("access denied")) {
|
|
1078
|
+
return DO_NOT_DEV_ERROR_CODES.PERMISSION_DENIED;
|
|
1079
|
+
}
|
|
1080
|
+
if (message.includes("timeout") || message.includes("timed out")) {
|
|
1081
|
+
return DO_NOT_DEV_ERROR_CODES.TIMEOUT_ERROR;
|
|
1082
|
+
}
|
|
1083
|
+
if (message.includes("dependency") || message.includes("module not found")) {
|
|
1084
|
+
return DO_NOT_DEV_ERROR_CODES.DEPENDENCY_ERROR;
|
|
1085
|
+
}
|
|
1086
|
+
return DO_NOT_DEV_ERROR_CODES.UNKNOWN_ERROR;
|
|
1087
|
+
}
|
|
1088
|
+
};
|
|
1089
|
+
}
|
|
1090
|
+
});
|
|
1091
|
+
|
|
950
1092
|
// node_modules/.bun/fast-glob@3.3.3/node_modules/fast-glob/out/utils/array.js
|
|
951
1093
|
var require_array = __commonJS({
|
|
952
1094
|
"node_modules/.bun/fast-glob@3.3.3/node_modules/fast-glob/out/utils/array.js"(exports) {
|
|
@@ -7690,173 +7832,32 @@ var init_PathResolver = __esm({
|
|
|
7690
7832
|
}
|
|
7691
7833
|
});
|
|
7692
7834
|
|
|
7693
|
-
// packages/tooling/src/utils/
|
|
7694
|
-
|
|
7695
|
-
|
|
7696
|
-
|
|
7835
|
+
// packages/tooling/src/utils/pathResolver.ts
|
|
7836
|
+
import { createRequire as createRequire2 } from "node:module";
|
|
7837
|
+
import {
|
|
7838
|
+
join as join2,
|
|
7839
|
+
dirname as dirname2,
|
|
7840
|
+
basename as basename2,
|
|
7841
|
+
extname as extname2,
|
|
7842
|
+
relative as relative2,
|
|
7843
|
+
resolve as resolve2,
|
|
7844
|
+
parse,
|
|
7845
|
+
isAbsolute as pathIsAbsolute
|
|
7846
|
+
} from "node:path";
|
|
7847
|
+
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
7848
|
+
function readdirSync2(dirPath, options) {
|
|
7849
|
+
return pathResolverInstance.readdirSync(dirPath, options);
|
|
7850
|
+
}
|
|
7851
|
+
var pathResolverInstance, resolvePackage, normalizePath, pathExists, readSync, writeSync, removeSync, statSync2, ensureDirSync, getRelativePathBetween, getDirname, joinPath;
|
|
7852
|
+
var init_pathResolver = __esm({
|
|
7853
|
+
"packages/tooling/src/utils/pathResolver.ts"() {
|
|
7697
7854
|
"use strict";
|
|
7698
7855
|
init_utils();
|
|
7699
|
-
|
|
7700
|
-
|
|
7701
|
-
|
|
7702
|
-
|
|
7703
|
-
|
|
7704
|
-
FILE_OPERATION_ERROR: "file-operation-error",
|
|
7705
|
-
FILE_NOT_FOUND: "file-not-found",
|
|
7706
|
-
PERMISSION_DENIED: "permission-denied",
|
|
7707
|
-
GENERATION_ERROR: "generation-error",
|
|
7708
|
-
TEMPLATE_ERROR: "template-error",
|
|
7709
|
-
TEMPLATE_NOT_FOUND: "template-not-found",
|
|
7710
|
-
CLI_EXECUTION_ERROR: "cli-execution-error",
|
|
7711
|
-
COMMAND_NOT_FOUND: "command-not-found",
|
|
7712
|
-
COMMAND_FAILED: "command-failed",
|
|
7713
|
-
VALIDATION_ERROR: "validation-error",
|
|
7714
|
-
SCHEMA_ERROR: "schema-error",
|
|
7715
|
-
DEPENDENCY_ERROR: "dependency-error",
|
|
7716
|
-
DEPENDENCY_NOT_FOUND: "dependency-not-found",
|
|
7717
|
-
DEPENDENCY_VERSION_ERROR: "dependency-version-error",
|
|
7718
|
-
INVALID_ARGUMENT: "invalid-argument",
|
|
7719
|
-
MISSING_ARGUMENT: "missing-argument",
|
|
7720
|
-
MISSING_PROJECT_ID: "missing-project-id",
|
|
7721
|
-
FIREBASE_CLI_ERROR: "firebase-cli-error",
|
|
7722
|
-
DEPLOYMENT_FAILED: "deployment-failed",
|
|
7723
|
-
OPERATION_CANCELLED: "operation-cancelled",
|
|
7724
|
-
TIMEOUT_ERROR: "timeout-error",
|
|
7725
|
-
UNKNOWN_ERROR: "unknown-error"
|
|
7726
|
-
};
|
|
7727
|
-
DoNotDevError = class _DoNotDevError extends Error {
|
|
7728
|
-
/** The error code categorizing this error */
|
|
7729
|
-
code;
|
|
7730
|
-
/** Original error if this is wrapping another error */
|
|
7731
|
-
originalError;
|
|
7732
|
-
/** Additional context for the error */
|
|
7733
|
-
context;
|
|
7734
|
-
/** Whether this error should be displayed to the user */
|
|
7735
|
-
displayable;
|
|
7736
|
-
/**
|
|
7737
|
-
* Creates a new DoNotDev error
|
|
7738
|
-
*
|
|
7739
|
-
* @param {string} message - Error message
|
|
7740
|
-
* @param {DoNotDevErrorCode} code - Error code
|
|
7741
|
-
* @param {object} [options] - Additional error options
|
|
7742
|
-
* @param {Error} [options.originalError] - Original error if wrapping
|
|
7743
|
-
* @param {Record<string, any>} [options.context] - Additional context data
|
|
7744
|
-
* @param {boolean} [options.displayable=true] - Whether this error should be displayed to the user
|
|
7745
|
-
*/
|
|
7746
|
-
constructor(message, code = DO_NOT_DEV_ERROR_CODES.UNKNOWN_ERROR, options) {
|
|
7747
|
-
super(message);
|
|
7748
|
-
this.name = "DoNotDevError";
|
|
7749
|
-
this.code = code;
|
|
7750
|
-
this.originalError = options?.originalError;
|
|
7751
|
-
this.context = options?.context;
|
|
7752
|
-
this.displayable = options?.displayable !== false;
|
|
7753
|
-
Object.setPrototypeOf(this, _DoNotDevError.prototype);
|
|
7754
|
-
if (Error.captureStackTrace) {
|
|
7755
|
-
Error.captureStackTrace(this, _DoNotDevError);
|
|
7756
|
-
}
|
|
7757
|
-
}
|
|
7758
|
-
/**
|
|
7759
|
-
* Formats the error for logging or display
|
|
7760
|
-
*
|
|
7761
|
-
* @returns {string} Formatted error message with code
|
|
7762
|
-
*/
|
|
7763
|
-
format() {
|
|
7764
|
-
return `[${this.code}] ${this.message}`;
|
|
7765
|
-
}
|
|
7766
|
-
/**
|
|
7767
|
-
* Creates a wrapped error from another error
|
|
7768
|
-
*
|
|
7769
|
-
* @param {Error} error - Original error to wrap
|
|
7770
|
-
* @param {string} [context] - Additional context for the error
|
|
7771
|
-
* @param {DoNotDevErrorCode} [code='unknown-error'] - Error code
|
|
7772
|
-
* @param {object} [options] - Additional error options
|
|
7773
|
-
* @param {Record<string, any>} [options.context] - Additional context data
|
|
7774
|
-
* @param {boolean} [options.displayable=true] - Whether this error should be displayed to the user
|
|
7775
|
-
* @returns {DoNotDevError} New DoNotDev error wrapping the original
|
|
7776
|
-
*/
|
|
7777
|
-
static from(error2, context, code = DO_NOT_DEV_ERROR_CODES.UNKNOWN_ERROR, options) {
|
|
7778
|
-
if (!(error2 instanceof Error)) {
|
|
7779
|
-
return new _DoNotDevError(
|
|
7780
|
-
`Unknown error: ${String(error2)}`,
|
|
7781
|
-
code,
|
|
7782
|
-
options
|
|
7783
|
-
);
|
|
7784
|
-
}
|
|
7785
|
-
if (error2 instanceof _DoNotDevError) {
|
|
7786
|
-
if (!context) {
|
|
7787
|
-
return error2;
|
|
7788
|
-
}
|
|
7789
|
-
return new _DoNotDevError(`${context}: ${error2.message}`, error2.code, {
|
|
7790
|
-
originalError: error2.originalError || error2,
|
|
7791
|
-
context: { ...error2.context, ...options?.context || {} },
|
|
7792
|
-
displayable: options?.displayable ?? error2.displayable
|
|
7793
|
-
});
|
|
7794
|
-
}
|
|
7795
|
-
const message = context ? `${context}: ${error2.message}` : error2.message;
|
|
7796
|
-
return new _DoNotDevError(message, code, {
|
|
7797
|
-
originalError: error2,
|
|
7798
|
-
context: options?.context,
|
|
7799
|
-
displayable: options?.displayable
|
|
7800
|
-
});
|
|
7801
|
-
}
|
|
7802
|
-
/**
|
|
7803
|
-
* Maps common error types to DoNotDevErrorCode
|
|
7804
|
-
*
|
|
7805
|
-
* @param {Error} error - Error to analyze
|
|
7806
|
-
* @returns {DoNotDevErrorCode} Mapped error code
|
|
7807
|
-
*/
|
|
7808
|
-
static getErrorCodeFromError(error2) {
|
|
7809
|
-
if (error2 instanceof _DoNotDevError) {
|
|
7810
|
-
return error2.code;
|
|
7811
|
-
}
|
|
7812
|
-
const message = error2.message.toLowerCase();
|
|
7813
|
-
if (error2.name === "ValidationError" || message.includes("validation")) {
|
|
7814
|
-
return DO_NOT_DEV_ERROR_CODES.VALIDATION_ERROR;
|
|
7815
|
-
}
|
|
7816
|
-
if (message.includes("not found") || message.includes("no such file")) {
|
|
7817
|
-
return DO_NOT_DEV_ERROR_CODES.FILE_NOT_FOUND;
|
|
7818
|
-
}
|
|
7819
|
-
if (message.includes("permission") || message.includes("access denied")) {
|
|
7820
|
-
return DO_NOT_DEV_ERROR_CODES.PERMISSION_DENIED;
|
|
7821
|
-
}
|
|
7822
|
-
if (message.includes("timeout") || message.includes("timed out")) {
|
|
7823
|
-
return DO_NOT_DEV_ERROR_CODES.TIMEOUT_ERROR;
|
|
7824
|
-
}
|
|
7825
|
-
if (message.includes("dependency") || message.includes("module not found")) {
|
|
7826
|
-
return DO_NOT_DEV_ERROR_CODES.DEPENDENCY_ERROR;
|
|
7827
|
-
}
|
|
7828
|
-
return DO_NOT_DEV_ERROR_CODES.UNKNOWN_ERROR;
|
|
7829
|
-
}
|
|
7830
|
-
};
|
|
7831
|
-
}
|
|
7832
|
-
});
|
|
7833
|
-
|
|
7834
|
-
// packages/tooling/src/utils/pathResolver.ts
|
|
7835
|
-
import { createRequire as createRequire2 } from "node:module";
|
|
7836
|
-
import {
|
|
7837
|
-
join as join2,
|
|
7838
|
-
dirname as dirname2,
|
|
7839
|
-
basename as basename2,
|
|
7840
|
-
extname as extname2,
|
|
7841
|
-
relative as relative2,
|
|
7842
|
-
resolve as resolve2,
|
|
7843
|
-
parse,
|
|
7844
|
-
isAbsolute as pathIsAbsolute
|
|
7845
|
-
} from "node:path";
|
|
7846
|
-
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
7847
|
-
function readdirSync2(dirPath, options) {
|
|
7848
|
-
return pathResolverInstance.readdirSync(dirPath, options);
|
|
7849
|
-
}
|
|
7850
|
-
var pathResolverInstance, resolvePackage, normalizePath, pathExists, readSync, writeSync, removeSync, statSync2, ensureDirSync, getRelativePathBetween, getDirname, joinPath;
|
|
7851
|
-
var init_pathResolver = __esm({
|
|
7852
|
-
"packages/tooling/src/utils/pathResolver.ts"() {
|
|
7853
|
-
"use strict";
|
|
7854
|
-
init_utils();
|
|
7855
|
-
init_PathResolver();
|
|
7856
|
-
pathResolverInstance = PathResolver.getInstance({ debug: false });
|
|
7857
|
-
resolvePackage = (spec, from) => pathResolverInstance.resolvePackage(spec, from || null);
|
|
7858
|
-
normalizePath = (...pathSegments) => {
|
|
7859
|
-
return pathResolverInstance.normalizePath(join2(...pathSegments));
|
|
7856
|
+
init_PathResolver();
|
|
7857
|
+
pathResolverInstance = PathResolver.getInstance({ debug: false });
|
|
7858
|
+
resolvePackage = (spec, from) => pathResolverInstance.resolvePackage(spec, from || null);
|
|
7859
|
+
normalizePath = (...pathSegments) => {
|
|
7860
|
+
return pathResolverInstance.normalizePath(join2(...pathSegments));
|
|
7860
7861
|
};
|
|
7861
7862
|
pathExists = (filePath, silent = false) => pathResolverInstance.pathExists(filePath, silent);
|
|
7862
7863
|
readSync = (filePath, options) => pathResolverInstance.readSync(filePath, options);
|
|
@@ -7964,14 +7965,14 @@ var init_typed_file_operations = __esm({
|
|
|
7964
7965
|
"packages/tooling/src/utils/typed-file-operations.ts"() {
|
|
7965
7966
|
"use strict";
|
|
7966
7967
|
init_utils();
|
|
7967
|
-
init_pathResolver();
|
|
7968
7968
|
init_errors();
|
|
7969
|
+
init_pathResolver();
|
|
7969
7970
|
}
|
|
7970
7971
|
});
|
|
7971
7972
|
|
|
7972
7973
|
// packages/tooling/src/bundler/utils.ts
|
|
7973
7974
|
import { Buffer } from "node:buffer";
|
|
7974
|
-
import { readFileSync as readFileSync2, writeFileSync as writeFileSync2, mkdirSync as mkdirSync2 } from "node:fs";
|
|
7975
|
+
import { copyFileSync as copyFileSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync2, mkdirSync as mkdirSync2 } from "node:fs";
|
|
7975
7976
|
import { createRequire as createRequire3 } from "node:module";
|
|
7976
7977
|
import { dirname as dirname3, resolve as resolve3 } from "node:path";
|
|
7977
7978
|
import process from "node:process";
|
|
@@ -8107,7 +8108,7 @@ function checkCLI(command, args = ["--version"], useCache = true) {
|
|
|
8107
8108
|
}
|
|
8108
8109
|
);
|
|
8109
8110
|
} else {
|
|
8110
|
-
result = spawnSync2(command
|
|
8111
|
+
result = spawnSync2(`${command} ${args.join(" ")}`, {
|
|
8111
8112
|
stdio: "pipe",
|
|
8112
8113
|
shell: true
|
|
8113
8114
|
});
|
|
@@ -8145,7 +8146,7 @@ function checkTsx() {
|
|
|
8145
8146
|
return checkCLI("tsx");
|
|
8146
8147
|
}
|
|
8147
8148
|
function getCLIInstallInstructions(tool) {
|
|
8148
|
-
const
|
|
8149
|
+
const platform2 = process.platform;
|
|
8149
8150
|
const instructions = {
|
|
8150
8151
|
[CLI_TOOLS.BUN]: {
|
|
8151
8152
|
win32: [
|
|
@@ -8261,7 +8262,7 @@ function getCLIInstallInstructions(tool) {
|
|
|
8261
8262
|
linux: ["bun install -g tsx"]
|
|
8262
8263
|
}
|
|
8263
8264
|
};
|
|
8264
|
-
const platformInstructions = instructions[tool]?.[
|
|
8265
|
+
const platformInstructions = instructions[tool]?.[platform2] || instructions[tool]?.linux || [];
|
|
8265
8266
|
return platformInstructions.join("\n \u2022 ");
|
|
8266
8267
|
}
|
|
8267
8268
|
function formatCLIMissingError(tool, additionalContext) {
|
|
@@ -8276,9 +8277,9 @@ function formatCLIMissingError(tool, additionalContext) {
|
|
|
8276
8277
|
M2.info(`
|
|
8277
8278
|
${additionalContext}`);
|
|
8278
8279
|
}
|
|
8279
|
-
const
|
|
8280
|
+
const platform2 = process.platform;
|
|
8280
8281
|
M2.info("\nIf already installed, ensure it's in your PATH:");
|
|
8281
|
-
if (
|
|
8282
|
+
if (platform2 === "win32") {
|
|
8282
8283
|
M2.message(" \u2022 Check with: where " + tool);
|
|
8283
8284
|
M2.message(
|
|
8284
8285
|
" \u2022 Common location: C:\\Users\\<username>\\AppData\\Roaming\\npm\\"
|
|
@@ -8335,153 +8336,6 @@ var init_cli_tools = __esm({
|
|
|
8335
8336
|
}
|
|
8336
8337
|
});
|
|
8337
8338
|
|
|
8338
|
-
// packages/tooling/src/utils/secrets-resolver.ts
|
|
8339
|
-
function parseEnvFile(filePath) {
|
|
8340
|
-
if (!pathExists(filePath)) return {};
|
|
8341
|
-
const content = readSync(filePath, { format: "text" });
|
|
8342
|
-
if (typeof content !== "string" || !content) return {};
|
|
8343
|
-
const result = {};
|
|
8344
|
-
for (const line of content.split(/\r?\n/)) {
|
|
8345
|
-
const trimmed = line.trim();
|
|
8346
|
-
if (!trimmed || trimmed.startsWith("#")) continue;
|
|
8347
|
-
const eqIdx = trimmed.indexOf("=");
|
|
8348
|
-
if (eqIdx === -1) continue;
|
|
8349
|
-
const key = trimmed.slice(0, eqIdx).trim();
|
|
8350
|
-
let value = trimmed.slice(eqIdx + 1).trim();
|
|
8351
|
-
if (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'")) {
|
|
8352
|
-
value = value.slice(1, -1);
|
|
8353
|
-
}
|
|
8354
|
-
if (key && value) {
|
|
8355
|
-
result[key] = value;
|
|
8356
|
-
}
|
|
8357
|
-
}
|
|
8358
|
-
return result;
|
|
8359
|
-
}
|
|
8360
|
-
function readEnvVar(filePath, varName) {
|
|
8361
|
-
if (!pathExists(filePath)) return null;
|
|
8362
|
-
const content = readSync(filePath, { format: "text" });
|
|
8363
|
-
if (typeof content !== "string") return null;
|
|
8364
|
-
for (const line of content.split(/\r?\n/)) {
|
|
8365
|
-
const trimmed = line.trim();
|
|
8366
|
-
if (!trimmed || trimmed.startsWith("#")) continue;
|
|
8367
|
-
if (trimmed.startsWith(`${varName}=`)) {
|
|
8368
|
-
let val = trimmed.substring(`${varName}=`.length).trim();
|
|
8369
|
-
if (val.startsWith('"') && val.endsWith('"') || val.startsWith("'") && val.endsWith("'")) {
|
|
8370
|
-
val = val.slice(1, -1);
|
|
8371
|
-
}
|
|
8372
|
-
return val || null;
|
|
8373
|
-
}
|
|
8374
|
-
}
|
|
8375
|
-
return null;
|
|
8376
|
-
}
|
|
8377
|
-
function loadDndevSecrets(projectRoot) {
|
|
8378
|
-
const secretsPath = joinPath(projectRoot, ".dndev.secrets");
|
|
8379
|
-
if (cachedSecretsPath === secretsPath && cachedSecrets) {
|
|
8380
|
-
return cachedSecrets;
|
|
8381
|
-
}
|
|
8382
|
-
cachedSecrets = parseEnvFile(secretsPath);
|
|
8383
|
-
cachedSecretsPath = secretsPath;
|
|
8384
|
-
return cachedSecrets;
|
|
8385
|
-
}
|
|
8386
|
-
function resolveSecret(name, projectRoot, opts) {
|
|
8387
|
-
const appDir = opts?.appDir ?? projectRoot;
|
|
8388
|
-
const envValue = process.env[name];
|
|
8389
|
-
if (envValue) {
|
|
8390
|
-
return { value: envValue, source: "process.env" };
|
|
8391
|
-
}
|
|
8392
|
-
const secrets = loadDndevSecrets(projectRoot);
|
|
8393
|
-
if (secrets[name]) {
|
|
8394
|
-
return { value: secrets[name], source: ".dndev.secrets" };
|
|
8395
|
-
}
|
|
8396
|
-
if (name === "SUPABASE_SECRET_KEY" && secrets["SUPABASE_SERVICE_ROLE_KEY"]) {
|
|
8397
|
-
return {
|
|
8398
|
-
value: secrets["SUPABASE_SERVICE_ROLE_KEY"],
|
|
8399
|
-
source: ".dndev.secrets"
|
|
8400
|
-
};
|
|
8401
|
-
}
|
|
8402
|
-
const legacyPaths = LEGACY_PATHS[name];
|
|
8403
|
-
if (legacyPaths) {
|
|
8404
|
-
for (const relPath of legacyPaths) {
|
|
8405
|
-
const fullPath = joinPath(appDir, relPath);
|
|
8406
|
-
const value = readEnvVar(fullPath, name);
|
|
8407
|
-
if (value) {
|
|
8408
|
-
if (!opts?.silent && !warnedLegacy.has(name)) {
|
|
8409
|
-
warnedLegacy.add(name);
|
|
8410
|
-
log.warn(
|
|
8411
|
-
`${name} found in ${relPath} (legacy). Move it to .dndev.secrets at project root.`
|
|
8412
|
-
);
|
|
8413
|
-
}
|
|
8414
|
-
return { value, source: "legacy", legacyPath: relPath };
|
|
8415
|
-
}
|
|
8416
|
-
if (name === "SUPABASE_SECRET_KEY") {
|
|
8417
|
-
const aliasValue = readEnvVar(fullPath, "SUPABASE_SERVICE_ROLE_KEY");
|
|
8418
|
-
if (aliasValue) {
|
|
8419
|
-
if (!opts?.silent && !warnedLegacy.has(name)) {
|
|
8420
|
-
warnedLegacy.add(name);
|
|
8421
|
-
log.warn(
|
|
8422
|
-
`${name} found in ${relPath} (legacy). Move it to .dndev.secrets at project root.`
|
|
8423
|
-
);
|
|
8424
|
-
}
|
|
8425
|
-
return { value: aliasValue, source: "legacy", legacyPath: relPath };
|
|
8426
|
-
}
|
|
8427
|
-
}
|
|
8428
|
-
}
|
|
8429
|
-
}
|
|
8430
|
-
return null;
|
|
8431
|
-
}
|
|
8432
|
-
var LEGACY_PATHS, warnedLegacy, cachedSecretsPath, cachedSecrets;
|
|
8433
|
-
var init_secrets_resolver = __esm({
|
|
8434
|
-
"packages/tooling/src/utils/secrets-resolver.ts"() {
|
|
8435
|
-
"use strict";
|
|
8436
|
-
init_utils();
|
|
8437
|
-
init_pathResolver();
|
|
8438
|
-
init_cli_output();
|
|
8439
|
-
LEGACY_PATHS = {
|
|
8440
|
-
VERCEL_TOKEN: [".env.local"],
|
|
8441
|
-
SUPABASE_SECRET_KEY: ["supabase/functions/.env", "functions/.env"],
|
|
8442
|
-
SUPABASE_DB_URL: ["supabase/functions/.env", "functions/.env"],
|
|
8443
|
-
SUPABASE_ACCESS_TOKEN: ["supabase/functions/.env", "functions/.env"],
|
|
8444
|
-
STRIPE_SECRET_KEY: ["supabase/functions/.env", "functions/.env"],
|
|
8445
|
-
STRIPE_WEBHOOK_SECRET: ["supabase/functions/.env", "functions/.env"]
|
|
8446
|
-
};
|
|
8447
|
-
warnedLegacy = /* @__PURE__ */ new Set();
|
|
8448
|
-
cachedSecretsPath = null;
|
|
8449
|
-
cachedSecrets = null;
|
|
8450
|
-
}
|
|
8451
|
-
});
|
|
8452
|
-
|
|
8453
|
-
// packages/tooling/src/cli/setup/vercel-token.ts
|
|
8454
|
-
function resolvePerAppVar(appDir, varName) {
|
|
8455
|
-
if (process.env[varName]) return process.env[varName];
|
|
8456
|
-
const fromLocal = readEnvVar(joinPath(appDir, ".env.local"), varName);
|
|
8457
|
-
if (fromLocal) return fromLocal;
|
|
8458
|
-
const fromEnv = readEnvVar(joinPath(appDir, ".env"), varName);
|
|
8459
|
-
if (fromEnv) return fromEnv;
|
|
8460
|
-
return null;
|
|
8461
|
-
}
|
|
8462
|
-
function resolveVercelCredentials(appDir, projectRoot) {
|
|
8463
|
-
const root = projectRoot ?? process.cwd();
|
|
8464
|
-
const token = resolveSecret("VERCEL_TOKEN", root, { appDir })?.value ?? null;
|
|
8465
|
-
const orgId = resolvePerAppVar(appDir, "VERCEL_ORG_ID");
|
|
8466
|
-
const projectId = resolvePerAppVar(appDir, "VERCEL_PROJECT_ID");
|
|
8467
|
-
const missing = [];
|
|
8468
|
-
if (!token) missing.push("VERCEL_TOKEN");
|
|
8469
|
-
if (!orgId) missing.push("VERCEL_ORG_ID");
|
|
8470
|
-
if (!projectId) missing.push("VERCEL_PROJECT_ID");
|
|
8471
|
-
if (missing.length > 0) return { missing };
|
|
8472
|
-
return {
|
|
8473
|
-
credentials: { token, orgId, projectId }
|
|
8474
|
-
};
|
|
8475
|
-
}
|
|
8476
|
-
var init_vercel_token = __esm({
|
|
8477
|
-
"packages/tooling/src/cli/setup/vercel-token.ts"() {
|
|
8478
|
-
"use strict";
|
|
8479
|
-
init_utils();
|
|
8480
|
-
init_secrets_resolver();
|
|
8481
|
-
init_pathResolver();
|
|
8482
|
-
}
|
|
8483
|
-
});
|
|
8484
|
-
|
|
8485
8339
|
// node_modules/.bun/yaml@2.8.2/node_modules/yaml/dist/nodes/identity.js
|
|
8486
8340
|
var require_identity = __commonJS({
|
|
8487
8341
|
"node_modules/.bun/yaml@2.8.2/node_modules/yaml/dist/nodes/identity.js"(exports) {
|
|
@@ -15866,38 +15720,267 @@ var init_error_handling = __esm({
|
|
|
15866
15720
|
}
|
|
15867
15721
|
});
|
|
15868
15722
|
|
|
15869
|
-
// packages/tooling/src/apps/
|
|
15870
|
-
|
|
15871
|
-
|
|
15872
|
-
|
|
15873
|
-
|
|
15874
|
-
|
|
15875
|
-
|
|
15876
|
-
|
|
15877
|
-
|
|
15878
|
-
}
|
|
15879
|
-
import { spawnSync as spawnSync5 } from "node:child_process";
|
|
15880
|
-
function parseEnvFile2(filePath) {
|
|
15881
|
-
if (!pathExists(filePath)) {
|
|
15882
|
-
throw new DoNotDevError(
|
|
15883
|
-
`Environment file not found: ${filePath}`,
|
|
15884
|
-
"file-not-found",
|
|
15885
|
-
{ context: { filePath } }
|
|
15886
|
-
);
|
|
15723
|
+
// packages/tooling/src/apps/vercel-api.ts
|
|
15724
|
+
function formatVercelError(status, body, context) {
|
|
15725
|
+
let vercelCode;
|
|
15726
|
+
let vercelMessage;
|
|
15727
|
+
try {
|
|
15728
|
+
const parsed = JSON.parse(body);
|
|
15729
|
+
const err = parsed.error ?? parsed;
|
|
15730
|
+
vercelCode = err.code;
|
|
15731
|
+
vercelMessage = err.message;
|
|
15732
|
+
} catch {
|
|
15887
15733
|
}
|
|
15888
|
-
|
|
15889
|
-
|
|
15890
|
-
|
|
15734
|
+
let message;
|
|
15735
|
+
switch (status) {
|
|
15736
|
+
case 401:
|
|
15737
|
+
message = "Vercel token is invalid or expired. Generate a new one at https://vercel.com/account/tokens and update .dndev.secrets";
|
|
15738
|
+
break;
|
|
15739
|
+
case 403:
|
|
15740
|
+
if (vercelCode === "team_unauthorized" || body.includes("teamId")) {
|
|
15741
|
+
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.";
|
|
15742
|
+
} else {
|
|
15743
|
+
message = `Vercel access denied: ${vercelMessage ?? "check token scope and permissions"}`;
|
|
15744
|
+
}
|
|
15745
|
+
break;
|
|
15746
|
+
case 404:
|
|
15747
|
+
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.";
|
|
15748
|
+
break;
|
|
15749
|
+
case 400:
|
|
15750
|
+
if (vercelCode === "invalid_project_name") {
|
|
15751
|
+
message = "Vercel rejected the project name. This is a framework bug \u2014 please report it.";
|
|
15752
|
+
} else {
|
|
15753
|
+
message = `Vercel rejected the request: ${vercelMessage ?? body}`;
|
|
15754
|
+
}
|
|
15755
|
+
break;
|
|
15756
|
+
case 429:
|
|
15757
|
+
message = "Vercel rate limit hit. Wait a few minutes and try again.";
|
|
15758
|
+
break;
|
|
15759
|
+
default:
|
|
15760
|
+
message = `Vercel API error during ${context} (${status}): ${vercelMessage ?? body}`;
|
|
15891
15761
|
}
|
|
15892
|
-
return
|
|
15762
|
+
return new DoNotDevError(message, DO_NOT_DEV_ERROR_CODES.VERCEL_API_ERROR, {
|
|
15763
|
+
context: { status, vercelCode, context }
|
|
15764
|
+
});
|
|
15893
15765
|
}
|
|
15894
|
-
function
|
|
15895
|
-
const
|
|
15896
|
-
|
|
15897
|
-
|
|
15898
|
-
|
|
15899
|
-
|
|
15900
|
-
|
|
15766
|
+
async function validateToken(token) {
|
|
15767
|
+
const res = await fetch(`${VERCEL_API}/v2/user`, {
|
|
15768
|
+
headers: { Authorization: `Bearer ${token}` }
|
|
15769
|
+
});
|
|
15770
|
+
if (!res.ok) {
|
|
15771
|
+
const body = await res.text();
|
|
15772
|
+
throw formatVercelError(res.status, body, "validate token");
|
|
15773
|
+
}
|
|
15774
|
+
const data = await res.json();
|
|
15775
|
+
return { username: data.user.username, email: data.user.email };
|
|
15776
|
+
}
|
|
15777
|
+
async function validateProject(token, projectId, orgId) {
|
|
15778
|
+
const q2 = orgId ? `?teamId=${encodeURIComponent(orgId)}` : "";
|
|
15779
|
+
const res = await fetch(
|
|
15780
|
+
`${VERCEL_API}/v9/projects/${encodeURIComponent(projectId)}${q2}`,
|
|
15781
|
+
{
|
|
15782
|
+
headers: { Authorization: `Bearer ${token}` }
|
|
15783
|
+
}
|
|
15784
|
+
);
|
|
15785
|
+
if (!res.ok) {
|
|
15786
|
+
const body = await res.text();
|
|
15787
|
+
throw formatVercelError(res.status, body, "validate project");
|
|
15788
|
+
}
|
|
15789
|
+
const data = await res.json();
|
|
15790
|
+
return { projectName: data.name };
|
|
15791
|
+
}
|
|
15792
|
+
var VERCEL_API;
|
|
15793
|
+
var init_vercel_api = __esm({
|
|
15794
|
+
"packages/tooling/src/apps/vercel-api.ts"() {
|
|
15795
|
+
"use strict";
|
|
15796
|
+
init_utils();
|
|
15797
|
+
init_errors();
|
|
15798
|
+
VERCEL_API = "https://api.vercel.com";
|
|
15799
|
+
}
|
|
15800
|
+
});
|
|
15801
|
+
|
|
15802
|
+
// packages/tooling/src/utils/secrets-resolver.ts
|
|
15803
|
+
function parseEnvFile(filePath) {
|
|
15804
|
+
if (!pathExists(filePath)) return {};
|
|
15805
|
+
const content = readSync(filePath, { format: "text" });
|
|
15806
|
+
if (typeof content !== "string" || !content) return {};
|
|
15807
|
+
const result = {};
|
|
15808
|
+
for (const line of content.split(/\r?\n/)) {
|
|
15809
|
+
const trimmed = line.trim();
|
|
15810
|
+
if (!trimmed || trimmed.startsWith("#")) continue;
|
|
15811
|
+
const eqIdx = trimmed.indexOf("=");
|
|
15812
|
+
if (eqIdx === -1) continue;
|
|
15813
|
+
const key = trimmed.slice(0, eqIdx).trim();
|
|
15814
|
+
let value = trimmed.slice(eqIdx + 1).trim();
|
|
15815
|
+
if (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'")) {
|
|
15816
|
+
value = value.slice(1, -1);
|
|
15817
|
+
}
|
|
15818
|
+
if (key && value) {
|
|
15819
|
+
result[key] = value;
|
|
15820
|
+
}
|
|
15821
|
+
}
|
|
15822
|
+
return result;
|
|
15823
|
+
}
|
|
15824
|
+
function readEnvVar(filePath, varName) {
|
|
15825
|
+
if (!pathExists(filePath)) return null;
|
|
15826
|
+
const content = readSync(filePath, { format: "text" });
|
|
15827
|
+
if (typeof content !== "string") return null;
|
|
15828
|
+
for (const line of content.split(/\r?\n/)) {
|
|
15829
|
+
const trimmed = line.trim();
|
|
15830
|
+
if (!trimmed || trimmed.startsWith("#")) continue;
|
|
15831
|
+
if (trimmed.startsWith(`${varName}=`)) {
|
|
15832
|
+
let val = trimmed.substring(`${varName}=`.length).trim();
|
|
15833
|
+
if (val.startsWith('"') && val.endsWith('"') || val.startsWith("'") && val.endsWith("'")) {
|
|
15834
|
+
val = val.slice(1, -1);
|
|
15835
|
+
}
|
|
15836
|
+
return val || null;
|
|
15837
|
+
}
|
|
15838
|
+
}
|
|
15839
|
+
return null;
|
|
15840
|
+
}
|
|
15841
|
+
function loadDndevSecrets(projectRoot) {
|
|
15842
|
+
const secretsPath = joinPath(projectRoot, ".dndev.secrets");
|
|
15843
|
+
if (cachedSecretsPath === secretsPath && cachedSecrets) {
|
|
15844
|
+
return cachedSecrets;
|
|
15845
|
+
}
|
|
15846
|
+
cachedSecrets = parseEnvFile(secretsPath);
|
|
15847
|
+
cachedSecretsPath = secretsPath;
|
|
15848
|
+
return cachedSecrets;
|
|
15849
|
+
}
|
|
15850
|
+
function resolveSecret(name, projectRoot, opts) {
|
|
15851
|
+
const appDir = opts?.appDir ?? projectRoot;
|
|
15852
|
+
const secrets = loadDndevSecrets(projectRoot);
|
|
15853
|
+
if (secrets[name]) {
|
|
15854
|
+
return { value: secrets[name], source: ".dndev.secrets" };
|
|
15855
|
+
}
|
|
15856
|
+
if (name === "SUPABASE_SECRET_KEY" && secrets["SUPABASE_SERVICE_ROLE_KEY"]) {
|
|
15857
|
+
return {
|
|
15858
|
+
value: secrets["SUPABASE_SERVICE_ROLE_KEY"],
|
|
15859
|
+
source: ".dndev.secrets"
|
|
15860
|
+
};
|
|
15861
|
+
}
|
|
15862
|
+
const envValue = process.env[name];
|
|
15863
|
+
if (envValue) {
|
|
15864
|
+
return { value: envValue, source: "process.env" };
|
|
15865
|
+
}
|
|
15866
|
+
const legacyPaths = LEGACY_PATHS[name];
|
|
15867
|
+
if (legacyPaths) {
|
|
15868
|
+
for (const relPath of legacyPaths) {
|
|
15869
|
+
const fullPath = joinPath(appDir, relPath);
|
|
15870
|
+
const value = readEnvVar(fullPath, name);
|
|
15871
|
+
if (value) {
|
|
15872
|
+
if (!opts?.silent && !warnedLegacy.has(name)) {
|
|
15873
|
+
warnedLegacy.add(name);
|
|
15874
|
+
log.warn(
|
|
15875
|
+
`${name} found in ${relPath} (legacy). Move it to .dndev.secrets at project root.`
|
|
15876
|
+
);
|
|
15877
|
+
}
|
|
15878
|
+
return { value, source: "legacy", legacyPath: relPath };
|
|
15879
|
+
}
|
|
15880
|
+
if (name === "SUPABASE_SECRET_KEY") {
|
|
15881
|
+
const aliasValue = readEnvVar(fullPath, "SUPABASE_SERVICE_ROLE_KEY");
|
|
15882
|
+
if (aliasValue) {
|
|
15883
|
+
if (!opts?.silent && !warnedLegacy.has(name)) {
|
|
15884
|
+
warnedLegacy.add(name);
|
|
15885
|
+
log.warn(
|
|
15886
|
+
`${name} found in ${relPath} (legacy). Move it to .dndev.secrets at project root.`
|
|
15887
|
+
);
|
|
15888
|
+
}
|
|
15889
|
+
return { value: aliasValue, source: "legacy", legacyPath: relPath };
|
|
15890
|
+
}
|
|
15891
|
+
}
|
|
15892
|
+
}
|
|
15893
|
+
}
|
|
15894
|
+
return null;
|
|
15895
|
+
}
|
|
15896
|
+
var LEGACY_PATHS, warnedLegacy, cachedSecretsPath, cachedSecrets;
|
|
15897
|
+
var init_secrets_resolver = __esm({
|
|
15898
|
+
"packages/tooling/src/utils/secrets-resolver.ts"() {
|
|
15899
|
+
"use strict";
|
|
15900
|
+
init_utils();
|
|
15901
|
+
init_cli_output();
|
|
15902
|
+
init_pathResolver();
|
|
15903
|
+
LEGACY_PATHS = {
|
|
15904
|
+
VERCEL_TOKEN: [".env.local"],
|
|
15905
|
+
SUPABASE_SECRET_KEY: ["supabase/functions/.env", "functions/.env"],
|
|
15906
|
+
SUPABASE_DB_URL: ["supabase/functions/.env", "functions/.env"],
|
|
15907
|
+
SUPABASE_ACCESS_TOKEN: ["supabase/functions/.env", "functions/.env"],
|
|
15908
|
+
STRIPE_SECRET_KEY: ["supabase/functions/.env", "functions/.env"],
|
|
15909
|
+
STRIPE_WEBHOOK_SECRET: ["supabase/functions/.env", "functions/.env"]
|
|
15910
|
+
};
|
|
15911
|
+
warnedLegacy = /* @__PURE__ */ new Set();
|
|
15912
|
+
cachedSecretsPath = null;
|
|
15913
|
+
cachedSecrets = null;
|
|
15914
|
+
}
|
|
15915
|
+
});
|
|
15916
|
+
|
|
15917
|
+
// packages/tooling/src/cli/setup/vercel-token.ts
|
|
15918
|
+
function resolvePerAppVar(appDir, varName) {
|
|
15919
|
+
const fromLocal = readEnvVar(joinPath(appDir, ".env.local"), varName);
|
|
15920
|
+
if (fromLocal) return fromLocal;
|
|
15921
|
+
const fromEnv = readEnvVar(joinPath(appDir, ".env"), varName);
|
|
15922
|
+
if (fromEnv) return fromEnv;
|
|
15923
|
+
if (process.env[varName]) return process.env[varName];
|
|
15924
|
+
return null;
|
|
15925
|
+
}
|
|
15926
|
+
function resolveVercelCredentials(appDir, projectRoot) {
|
|
15927
|
+
const root = projectRoot ?? process.cwd();
|
|
15928
|
+
const token = resolveSecret("VERCEL_TOKEN", root, { appDir })?.value ?? null;
|
|
15929
|
+
const orgId = resolvePerAppVar(appDir, "VERCEL_ORG_ID");
|
|
15930
|
+
const projectId = resolvePerAppVar(appDir, "VERCEL_PROJECT_ID");
|
|
15931
|
+
const missing = [];
|
|
15932
|
+
if (!token) missing.push("VERCEL_TOKEN");
|
|
15933
|
+
if (!projectId) missing.push("VERCEL_PROJECT_ID");
|
|
15934
|
+
if (missing.length > 0) return { missing };
|
|
15935
|
+
return {
|
|
15936
|
+
credentials: {
|
|
15937
|
+
token,
|
|
15938
|
+
orgId: orgId ?? void 0,
|
|
15939
|
+
projectId
|
|
15940
|
+
}
|
|
15941
|
+
};
|
|
15942
|
+
}
|
|
15943
|
+
var init_vercel_token = __esm({
|
|
15944
|
+
"packages/tooling/src/cli/setup/vercel-token.ts"() {
|
|
15945
|
+
"use strict";
|
|
15946
|
+
init_utils();
|
|
15947
|
+
init_pathResolver();
|
|
15948
|
+
init_secrets_resolver();
|
|
15949
|
+
}
|
|
15950
|
+
});
|
|
15951
|
+
|
|
15952
|
+
// packages/tooling/src/apps/sync-secrets.ts
|
|
15953
|
+
var sync_secrets_exports = {};
|
|
15954
|
+
__export(sync_secrets_exports, {
|
|
15955
|
+
default: () => sync_secrets_default,
|
|
15956
|
+
detectGitHubRepo: () => detectGitHubRepo,
|
|
15957
|
+
main: () => main,
|
|
15958
|
+
parseSecretsWithFallback: () => parseSecretsWithFallback,
|
|
15959
|
+
setGitHubSecret: () => setGitHubSecret,
|
|
15960
|
+
uploadServiceAccountToGitHub: () => uploadServiceAccountToGitHub
|
|
15961
|
+
});
|
|
15962
|
+
import { spawnSync as spawnSync5 } from "node:child_process";
|
|
15963
|
+
function parseEnvFile2(filePath) {
|
|
15964
|
+
if (!pathExists(filePath)) {
|
|
15965
|
+
throw new DoNotDevError(
|
|
15966
|
+
`Environment file not found: ${filePath}`,
|
|
15967
|
+
"file-not-found",
|
|
15968
|
+
{ context: { filePath } }
|
|
15969
|
+
);
|
|
15970
|
+
}
|
|
15971
|
+
const result = parseEnvFile(filePath);
|
|
15972
|
+
if (Object.keys(result).length === 0) {
|
|
15973
|
+
log.debug(`No key-value pairs found in ${filePath}`);
|
|
15974
|
+
}
|
|
15975
|
+
return result;
|
|
15976
|
+
}
|
|
15977
|
+
function parseSecretsWithFallback(envFilePath, projectRoot) {
|
|
15978
|
+
const dndevSecretsPath = joinPath(projectRoot, ".dndev.secrets");
|
|
15979
|
+
if (pathExists(dndevSecretsPath)) {
|
|
15980
|
+
const secrets = parseEnvFile(dndevSecretsPath);
|
|
15981
|
+
if (Object.keys(secrets).length > 0) {
|
|
15982
|
+
log.info(`Reading secrets from: ${dndevSecretsPath}`);
|
|
15983
|
+
return secrets;
|
|
15901
15984
|
}
|
|
15902
15985
|
}
|
|
15903
15986
|
return parseEnvFile2(envFilePath);
|
|
@@ -16382,11 +16465,11 @@ Examples:
|
|
|
16382
16465
|
}
|
|
16383
16466
|
return 0;
|
|
16384
16467
|
}
|
|
16385
|
-
const
|
|
16468
|
+
const platform2 = config.platform || detectPlatform();
|
|
16386
16469
|
if (config.verbose) {
|
|
16387
16470
|
log.debug(`Working directory: ${currentDir}`);
|
|
16388
16471
|
log.debug(`Environment file: ${envFilePath}`);
|
|
16389
|
-
log.debug(`Platform: ${
|
|
16472
|
+
log.debug(`Platform: ${platform2}`);
|
|
16390
16473
|
log.debug(`Dry run mode: ${config.dryRun}`);
|
|
16391
16474
|
}
|
|
16392
16475
|
const secrets = parseSecretsWithFallback(envFilePath, currentDir);
|
|
@@ -16395,7 +16478,7 @@ Examples:
|
|
|
16395
16478
|
log.info("No secrets found in .env file");
|
|
16396
16479
|
return 0;
|
|
16397
16480
|
}
|
|
16398
|
-
log.info(`Found ${secretKeys.length} secrets to sync to ${
|
|
16481
|
+
log.info(`Found ${secretKeys.length} secrets to sync to ${platform2}:`);
|
|
16399
16482
|
secretKeys.forEach((key) => {
|
|
16400
16483
|
if (config.verbose) {
|
|
16401
16484
|
const value = secrets[key];
|
|
@@ -16406,12 +16489,12 @@ Examples:
|
|
|
16406
16489
|
log.info(` ${key}`);
|
|
16407
16490
|
}
|
|
16408
16491
|
});
|
|
16409
|
-
const finalFirebaseProjectDir =
|
|
16492
|
+
const finalFirebaseProjectDir = platform2 === "firebase" ? firebaseProjectDir || findFirebaseProjectDir(config.envFile) : void 0;
|
|
16410
16493
|
if (config.verbose && finalFirebaseProjectDir) {
|
|
16411
16494
|
log.debug(`Firebase project directory: ${finalFirebaseProjectDir}`);
|
|
16412
16495
|
}
|
|
16413
16496
|
for (const [key, value] of Object.entries(secrets)) {
|
|
16414
|
-
if (
|
|
16497
|
+
if (platform2 === "firebase") {
|
|
16415
16498
|
await setFirebaseSecret(
|
|
16416
16499
|
key,
|
|
16417
16500
|
value,
|
|
@@ -16419,18 +16502,18 @@ Examples:
|
|
|
16419
16502
|
config.dryRun,
|
|
16420
16503
|
finalFirebaseProjectDir
|
|
16421
16504
|
);
|
|
16422
|
-
} else if (
|
|
16505
|
+
} else if (platform2 === "vercel") {
|
|
16423
16506
|
setVercelSecret(key, value, config.vercelProjectId, config.dryRun);
|
|
16424
16507
|
}
|
|
16425
16508
|
}
|
|
16426
16509
|
if (config.dryRun) {
|
|
16427
16510
|
log.success(
|
|
16428
16511
|
`
|
|
16429
|
-
Dry run completed. No secrets were actually set to ${
|
|
16512
|
+
Dry run completed. No secrets were actually set to ${platform2}.`
|
|
16430
16513
|
);
|
|
16431
16514
|
} else {
|
|
16432
16515
|
log.success(`
|
|
16433
|
-
All secrets synced successfully to ${
|
|
16516
|
+
All secrets synced successfully to ${platform2}!`);
|
|
16434
16517
|
}
|
|
16435
16518
|
return 0;
|
|
16436
16519
|
} catch (err) {
|
|
@@ -16524,10 +16607,10 @@ var init_deploy_supabase_functions = __esm({
|
|
|
16524
16607
|
"packages/tooling/src/apps/deploy-supabase-functions.ts"() {
|
|
16525
16608
|
"use strict";
|
|
16526
16609
|
init_utils();
|
|
16527
|
-
init_pathResolver();
|
|
16528
16610
|
init_cli_output();
|
|
16529
16611
|
init_cli_tools();
|
|
16530
16612
|
init_errors();
|
|
16613
|
+
init_pathResolver();
|
|
16531
16614
|
}
|
|
16532
16615
|
});
|
|
16533
16616
|
|
|
@@ -16545,7 +16628,12 @@ init_utils();
|
|
|
16545
16628
|
init_cli_output();
|
|
16546
16629
|
init_errors();
|
|
16547
16630
|
init_pathResolver();
|
|
16548
|
-
import {
|
|
16631
|
+
import {
|
|
16632
|
+
spawn,
|
|
16633
|
+
spawnSync,
|
|
16634
|
+
execSync
|
|
16635
|
+
} from "node:child_process";
|
|
16636
|
+
import { platform } from "node:os";
|
|
16549
16637
|
function clearConflictingAuth(env) {
|
|
16550
16638
|
const cleaned = { ...env };
|
|
16551
16639
|
delete cleaned.FIREBASE_TOKEN;
|
|
@@ -16568,7 +16656,10 @@ function executeFirebaseCommand(args, options) {
|
|
|
16568
16656
|
env: deployEnv
|
|
16569
16657
|
};
|
|
16570
16658
|
let result;
|
|
16571
|
-
result = spawnSync(
|
|
16659
|
+
result = spawnSync(`firebase ${args.join(" ")}`, {
|
|
16660
|
+
...spawnOptions,
|
|
16661
|
+
shell: true
|
|
16662
|
+
});
|
|
16572
16663
|
if (result.error) {
|
|
16573
16664
|
return {
|
|
16574
16665
|
success: false,
|
|
@@ -16645,232 +16736,62 @@ function safeRemove(path, options = {}) {
|
|
|
16645
16736
|
return false;
|
|
16646
16737
|
}
|
|
16647
16738
|
try {
|
|
16648
|
-
removeSync(path);
|
|
16649
|
-
if (options.logSuccess) {
|
|
16650
|
-
log.debug(options.successMessage ?? `Removed: ${path}`);
|
|
16651
|
-
}
|
|
16652
|
-
return true;
|
|
16653
|
-
} catch (error2) {
|
|
16654
|
-
const message = options.failureMessage ?? `Could not remove ${path}: ${error2 instanceof Error ? error2.message : String(error2)}`;
|
|
16655
|
-
if (options.silent !== false) {
|
|
16656
|
-
log.warn(message);
|
|
16657
|
-
}
|
|
16658
|
-
return false;
|
|
16659
|
-
}
|
|
16660
|
-
}
|
|
16661
|
-
|
|
16662
|
-
// packages/tooling/src/apps/deploy.ts
|
|
16663
|
-
init_utils();
|
|
16664
|
-
import { execSync as execSync4 } from "node:child_process";
|
|
16665
|
-
|
|
16666
|
-
// packages/tooling/src/apps/deploy-frontend.ts
|
|
16667
|
-
init_utils();
|
|
16668
|
-
async function deployFrontend(appDir, serviceAccountPath, projectId, config) {
|
|
16669
|
-
const s = Y2();
|
|
16670
|
-
s.start("Deploying frontend to Firebase Hosting...");
|
|
16671
|
-
const args = buildFirebaseDeployArgs(
|
|
16672
|
-
"hosting",
|
|
16673
|
-
projectId,
|
|
16674
|
-
config.debug,
|
|
16675
|
-
config.force ?? true
|
|
16676
|
-
);
|
|
16677
|
-
const result = executeFirebaseCommand(args, {
|
|
16678
|
-
cwd: appDir,
|
|
16679
|
-
serviceAccountPath,
|
|
16680
|
-
projectId,
|
|
16681
|
-
debug: config.debug
|
|
16682
|
-
});
|
|
16683
|
-
if (result.error) {
|
|
16684
|
-
s.stop("Deployment failed");
|
|
16685
|
-
throw result.error;
|
|
16686
|
-
}
|
|
16687
|
-
if (!result.success) {
|
|
16688
|
-
s.stop("Deployment failed");
|
|
16689
|
-
handleDeploymentFailure(
|
|
16690
|
-
result,
|
|
16691
|
-
`firebase ${args.join(" ")}`,
|
|
16692
|
-
serviceAccountPath
|
|
16693
|
-
);
|
|
16694
|
-
}
|
|
16695
|
-
s.stop("Frontend deployed successfully");
|
|
16696
|
-
}
|
|
16697
|
-
|
|
16698
|
-
// packages/tooling/src/apps/deploy-vercel-frontend.ts
|
|
16699
|
-
init_utils();
|
|
16700
|
-
init_cli_output();
|
|
16701
|
-
init_vercel_token();
|
|
16702
|
-
init_pathResolver();
|
|
16703
|
-
import { createHash } from "node:crypto";
|
|
16704
|
-
import { readFile, readdir } from "node:fs/promises";
|
|
16705
|
-
import { join as join3, relative as relative3 } from "node:path";
|
|
16706
|
-
var VERCEL_API = "https://api.vercel.com";
|
|
16707
|
-
var UPLOAD_BATCH_SIZE = 10;
|
|
16708
|
-
var POLL_INTERVAL_MS = 3e3;
|
|
16709
|
-
var POLL_MAX_ATTEMPTS = 100;
|
|
16710
|
-
function apiHeaders(token, extra) {
|
|
16711
|
-
return { Authorization: `Bearer ${token}`, ...extra };
|
|
16712
|
-
}
|
|
16713
|
-
function teamQuery(orgId) {
|
|
16714
|
-
return `?teamId=${encodeURIComponent(orgId)}`;
|
|
16715
|
-
}
|
|
16716
|
-
async function collectDistFiles(distDir) {
|
|
16717
|
-
const files = [];
|
|
16718
|
-
async function walk(dir) {
|
|
16719
|
-
const entries = await readdir(dir, { withFileTypes: true });
|
|
16720
|
-
for (const entry of entries) {
|
|
16721
|
-
const fullPath = join3(dir, entry.name);
|
|
16722
|
-
if (entry.isDirectory()) {
|
|
16723
|
-
await walk(fullPath);
|
|
16724
|
-
} else {
|
|
16725
|
-
const content = await readFile(fullPath);
|
|
16726
|
-
const sha = createHash("sha1").update(content).digest("hex");
|
|
16727
|
-
const rel = relative3(distDir, fullPath).split("\\").join("/");
|
|
16728
|
-
files.push({
|
|
16729
|
-
relativePath: rel,
|
|
16730
|
-
content,
|
|
16731
|
-
sha,
|
|
16732
|
-
size: content.byteLength
|
|
16733
|
-
});
|
|
16734
|
-
}
|
|
16735
|
-
}
|
|
16736
|
-
}
|
|
16737
|
-
await walk(distDir);
|
|
16738
|
-
return files;
|
|
16739
|
-
}
|
|
16740
|
-
async function uploadFiles(files, token, orgId) {
|
|
16741
|
-
const q2 = teamQuery(orgId);
|
|
16742
|
-
for (let i = 0; i < files.length; i += UPLOAD_BATCH_SIZE) {
|
|
16743
|
-
const batch = files.slice(i, i + UPLOAD_BATCH_SIZE);
|
|
16744
|
-
await Promise.all(
|
|
16745
|
-
batch.map(async (file) => {
|
|
16746
|
-
const res = await fetch(`${VERCEL_API}/v2/files${q2}`, {
|
|
16747
|
-
method: "POST",
|
|
16748
|
-
headers: apiHeaders(token, {
|
|
16749
|
-
"Content-Type": "application/octet-stream",
|
|
16750
|
-
"x-vercel-digest": file.sha,
|
|
16751
|
-
"Content-Length": String(file.size)
|
|
16752
|
-
}),
|
|
16753
|
-
body: new Uint8Array(file.content)
|
|
16754
|
-
});
|
|
16755
|
-
if (!res.ok) {
|
|
16756
|
-
const body = await res.text();
|
|
16757
|
-
log.warn(`Upload failed: ${file.relativePath} (${res.status})`);
|
|
16758
|
-
log.warn(` URL: ${VERCEL_API}/v2/files${q2}`);
|
|
16759
|
-
log.warn(` SHA: ${file.sha}, Size: ${file.size}`);
|
|
16760
|
-
log.warn(` Response: ${body}`);
|
|
16761
|
-
throw new Error(
|
|
16762
|
-
`File upload failed for ${file.relativePath} (${res.status}): ${body}`
|
|
16763
|
-
);
|
|
16764
|
-
}
|
|
16765
|
-
})
|
|
16766
|
-
);
|
|
16767
|
-
}
|
|
16768
|
-
}
|
|
16769
|
-
async function createDeployment(files, token, orgId, projectId) {
|
|
16770
|
-
const q2 = teamQuery(orgId);
|
|
16771
|
-
const body = {
|
|
16772
|
-
name: projectId,
|
|
16773
|
-
project: projectId,
|
|
16774
|
-
target: "production",
|
|
16775
|
-
files: files.map((f) => ({
|
|
16776
|
-
file: f.relativePath,
|
|
16777
|
-
sha: f.sha,
|
|
16778
|
-
size: f.size
|
|
16779
|
-
})),
|
|
16780
|
-
projectSettings: {
|
|
16781
|
-
buildCommand: "",
|
|
16782
|
-
installCommand: "",
|
|
16783
|
-
outputDirectory: "."
|
|
16784
|
-
}
|
|
16785
|
-
};
|
|
16786
|
-
const res = await fetch(`${VERCEL_API}/v13/deployments${q2}`, {
|
|
16787
|
-
method: "POST",
|
|
16788
|
-
headers: apiHeaders(token, { "Content-Type": "application/json" }),
|
|
16789
|
-
body: JSON.stringify(body)
|
|
16790
|
-
});
|
|
16791
|
-
if (!res.ok) {
|
|
16792
|
-
const text = await res.text();
|
|
16793
|
-
throw new Error(`Create deployment failed (${res.status}): ${text}`);
|
|
16794
|
-
}
|
|
16795
|
-
return await res.json();
|
|
16796
|
-
}
|
|
16797
|
-
async function waitForReady(deploymentId, token, orgId) {
|
|
16798
|
-
const q2 = teamQuery(orgId);
|
|
16799
|
-
for (let attempt = 0; attempt < POLL_MAX_ATTEMPTS; attempt++) {
|
|
16800
|
-
const res = await fetch(
|
|
16801
|
-
`${VERCEL_API}/v13/deployments/${deploymentId}${q2}`,
|
|
16802
|
-
{ headers: apiHeaders(token) }
|
|
16803
|
-
);
|
|
16804
|
-
if (!res.ok) {
|
|
16805
|
-
const text = await res.text();
|
|
16806
|
-
throw new Error(
|
|
16807
|
-
`Deployment status check failed (${res.status}): ${text}`
|
|
16808
|
-
);
|
|
16809
|
-
}
|
|
16810
|
-
const data = await res.json();
|
|
16811
|
-
if (data.readyState === "READY") return data;
|
|
16812
|
-
if (data.readyState === "ERROR") {
|
|
16813
|
-
throw new Error(
|
|
16814
|
-
`Deployment failed: ${data.errorMessage || "Unknown error"}`
|
|
16815
|
-
);
|
|
16739
|
+
removeSync(path);
|
|
16740
|
+
if (options.logSuccess) {
|
|
16741
|
+
log.debug(options.successMessage ?? `Removed: ${path}`);
|
|
16816
16742
|
}
|
|
16817
|
-
|
|
16818
|
-
|
|
16743
|
+
return true;
|
|
16744
|
+
} catch (error2) {
|
|
16745
|
+
const message = options.failureMessage ?? `Could not remove ${path}: ${error2 instanceof Error ? error2.message : String(error2)}`;
|
|
16746
|
+
if (options.silent !== false) {
|
|
16747
|
+
log.warn(message);
|
|
16819
16748
|
}
|
|
16820
|
-
|
|
16749
|
+
return false;
|
|
16821
16750
|
}
|
|
16822
|
-
throw new Error("Deployment timed out (5+ minutes)");
|
|
16823
16751
|
}
|
|
16824
|
-
|
|
16825
|
-
|
|
16826
|
-
|
|
16827
|
-
|
|
16828
|
-
|
|
16829
|
-
|
|
16830
|
-
|
|
16831
|
-
|
|
16832
|
-
|
|
16833
|
-
|
|
16834
|
-
|
|
16835
|
-
|
|
16836
|
-
|
|
16837
|
-
|
|
16838
|
-
|
|
16839
|
-
|
|
16840
|
-
const
|
|
16841
|
-
|
|
16842
|
-
|
|
16843
|
-
|
|
16844
|
-
|
|
16845
|
-
|
|
16846
|
-
|
|
16847
|
-
|
|
16848
|
-
|
|
16849
|
-
const files = await collectDistFiles(distDir);
|
|
16850
|
-
if (files.length === 0) {
|
|
16851
|
-
throw new Error("dist/ is empty \u2014 nothing to deploy.");
|
|
16752
|
+
|
|
16753
|
+
// packages/tooling/src/apps/deploy.ts
|
|
16754
|
+
init_utils();
|
|
16755
|
+
import { execSync as execSync4 } from "node:child_process";
|
|
16756
|
+
|
|
16757
|
+
// packages/tooling/src/apps/deploy-frontend.ts
|
|
16758
|
+
init_utils();
|
|
16759
|
+
async function deployFrontend(appDir, serviceAccountPath, projectId, config) {
|
|
16760
|
+
const s = Y2();
|
|
16761
|
+
s.start("Deploying frontend to Firebase Hosting...");
|
|
16762
|
+
const args = buildFirebaseDeployArgs(
|
|
16763
|
+
"hosting",
|
|
16764
|
+
projectId,
|
|
16765
|
+
config.debug,
|
|
16766
|
+
config.force ?? true
|
|
16767
|
+
);
|
|
16768
|
+
const result = executeFirebaseCommand(args, {
|
|
16769
|
+
cwd: appDir,
|
|
16770
|
+
serviceAccountPath,
|
|
16771
|
+
projectId,
|
|
16772
|
+
debug: config.debug
|
|
16773
|
+
});
|
|
16774
|
+
if (result.error) {
|
|
16775
|
+
s.stop("Deployment failed");
|
|
16776
|
+
throw result.error;
|
|
16852
16777
|
}
|
|
16853
|
-
|
|
16854
|
-
|
|
16855
|
-
|
|
16856
|
-
|
|
16857
|
-
|
|
16858
|
-
|
|
16859
|
-
|
|
16860
|
-
const ready = await waitForReady(deployment.id, token, orgId);
|
|
16861
|
-
const prodUrl = `https://${ready.url}`;
|
|
16862
|
-
log.success(`Production: ${prodUrl}`);
|
|
16863
|
-
if (ready.alias?.length) {
|
|
16864
|
-
log.info(`Aliases: ${ready.alias.join(", ")}`);
|
|
16778
|
+
if (!result.success) {
|
|
16779
|
+
s.stop("Deployment failed");
|
|
16780
|
+
handleDeploymentFailure(
|
|
16781
|
+
result,
|
|
16782
|
+
`firebase ${args.join(" ")}`,
|
|
16783
|
+
serviceAccountPath
|
|
16784
|
+
);
|
|
16865
16785
|
}
|
|
16786
|
+
s.stop("Frontend deployed successfully");
|
|
16866
16787
|
}
|
|
16867
16788
|
|
|
16868
16789
|
// packages/tooling/src/apps/deploy-functions.ts
|
|
16869
16790
|
init_utils();
|
|
16870
16791
|
var import_yaml = __toESM(require_dist(), 1);
|
|
16871
16792
|
import { execSync as execSync2, spawnSync as spawnSync3 } from "node:child_process";
|
|
16872
|
-
init_pathResolver();
|
|
16873
16793
|
init_cli_tools();
|
|
16794
|
+
init_pathResolver();
|
|
16874
16795
|
init_typed_file_operations();
|
|
16875
16796
|
function backupFiles(functionsDir) {
|
|
16876
16797
|
const backupDir = joinPath(functionsDir, ".deploy-backup");
|
|
@@ -17361,9 +17282,9 @@ async function deployRules(appDir, serviceAccountPath, projectId, config, option
|
|
|
17361
17282
|
// packages/tooling/src/apps/deploy-utils.ts
|
|
17362
17283
|
init_utils();
|
|
17363
17284
|
import { spawnSync as spawnSync4 } from "node:child_process";
|
|
17285
|
+
init_error_handling();
|
|
17364
17286
|
init_pathResolver();
|
|
17365
17287
|
init_typed_file_operations();
|
|
17366
|
-
init_error_handling();
|
|
17367
17288
|
function detectAvailableApps() {
|
|
17368
17289
|
const currentDir = process.cwd();
|
|
17369
17290
|
const appsDir = joinPath(currentDir, "apps");
|
|
@@ -17548,7 +17469,7 @@ How to fix:
|
|
|
17548
17469
|
if (shouldOpen) {
|
|
17549
17470
|
try {
|
|
17550
17471
|
const openCommand = process.platform === "win32" ? "start" : process.platform === "darwin" ? "open" : "xdg-open";
|
|
17551
|
-
spawnSync4(openCommand
|
|
17472
|
+
spawnSync4(`${openCommand} ${consoleUrl}`, { shell: true });
|
|
17552
17473
|
log.success("Opening Firebase Console...");
|
|
17553
17474
|
} catch {
|
|
17554
17475
|
log.warn("Could not open browser. Please open the URL manually.");
|
|
@@ -17596,6 +17517,195 @@ function clearFirebaseCache(appDir) {
|
|
|
17596
17517
|
}
|
|
17597
17518
|
}
|
|
17598
17519
|
|
|
17520
|
+
// packages/tooling/src/apps/deploy-vercel-frontend.ts
|
|
17521
|
+
init_utils();
|
|
17522
|
+
init_vercel_api();
|
|
17523
|
+
init_vercel_token();
|
|
17524
|
+
init_cli_output();
|
|
17525
|
+
init_pathResolver();
|
|
17526
|
+
import { createHash } from "node:crypto";
|
|
17527
|
+
import { readFile, readdir } from "node:fs/promises";
|
|
17528
|
+
import { join as join3, relative as relative3 } from "node:path";
|
|
17529
|
+
var VERCEL_API2 = "https://api.vercel.com";
|
|
17530
|
+
var UPLOAD_BATCH_SIZE = 10;
|
|
17531
|
+
var POLL_INTERVAL_MS = 3e3;
|
|
17532
|
+
var POLL_MAX_ATTEMPTS = 100;
|
|
17533
|
+
function apiHeaders(token, extra) {
|
|
17534
|
+
return { Authorization: `Bearer ${token}`, ...extra };
|
|
17535
|
+
}
|
|
17536
|
+
function teamQuery(orgId) {
|
|
17537
|
+
if (!orgId) return "";
|
|
17538
|
+
return `?teamId=${encodeURIComponent(orgId)}`;
|
|
17539
|
+
}
|
|
17540
|
+
async function collectDistFiles(distDir) {
|
|
17541
|
+
const files = [];
|
|
17542
|
+
async function walk(dir) {
|
|
17543
|
+
const entries = await readdir(dir, { withFileTypes: true });
|
|
17544
|
+
for (const entry of entries) {
|
|
17545
|
+
const fullPath = join3(dir, entry.name);
|
|
17546
|
+
if (entry.isDirectory()) {
|
|
17547
|
+
await walk(fullPath);
|
|
17548
|
+
} else {
|
|
17549
|
+
const content = await readFile(fullPath);
|
|
17550
|
+
const sha = createHash("sha1").update(content).digest("hex");
|
|
17551
|
+
const rel = relative3(distDir, fullPath).split("\\").join("/");
|
|
17552
|
+
files.push({
|
|
17553
|
+
relativePath: rel,
|
|
17554
|
+
content,
|
|
17555
|
+
sha,
|
|
17556
|
+
size: content.byteLength
|
|
17557
|
+
});
|
|
17558
|
+
}
|
|
17559
|
+
}
|
|
17560
|
+
}
|
|
17561
|
+
await walk(distDir);
|
|
17562
|
+
return files;
|
|
17563
|
+
}
|
|
17564
|
+
async function uploadFiles(files, token, orgId) {
|
|
17565
|
+
const q2 = teamQuery(orgId);
|
|
17566
|
+
for (let i = 0; i < files.length; i += UPLOAD_BATCH_SIZE) {
|
|
17567
|
+
const batch = files.slice(i, i + UPLOAD_BATCH_SIZE);
|
|
17568
|
+
await Promise.all(
|
|
17569
|
+
batch.map(async (file) => {
|
|
17570
|
+
const res = await fetch(`${VERCEL_API2}/v2/files${q2}`, {
|
|
17571
|
+
method: "POST",
|
|
17572
|
+
headers: apiHeaders(token, {
|
|
17573
|
+
"Content-Type": "application/octet-stream",
|
|
17574
|
+
"x-vercel-digest": file.sha,
|
|
17575
|
+
"Content-Length": String(file.size)
|
|
17576
|
+
}),
|
|
17577
|
+
body: new Uint8Array(file.content)
|
|
17578
|
+
});
|
|
17579
|
+
if (!res.ok) {
|
|
17580
|
+
const body = await res.text();
|
|
17581
|
+
throw formatVercelError(
|
|
17582
|
+
res.status,
|
|
17583
|
+
body,
|
|
17584
|
+
`upload file ${file.relativePath}`
|
|
17585
|
+
);
|
|
17586
|
+
}
|
|
17587
|
+
})
|
|
17588
|
+
);
|
|
17589
|
+
}
|
|
17590
|
+
}
|
|
17591
|
+
async function createDeployment(files, token, orgId, projectId, projectName) {
|
|
17592
|
+
const q2 = teamQuery(orgId);
|
|
17593
|
+
const body = {
|
|
17594
|
+
name: projectName,
|
|
17595
|
+
project: projectId,
|
|
17596
|
+
target: "production",
|
|
17597
|
+
files: files.map((f) => ({
|
|
17598
|
+
file: f.relativePath,
|
|
17599
|
+
sha: f.sha,
|
|
17600
|
+
size: f.size
|
|
17601
|
+
})),
|
|
17602
|
+
projectSettings: {
|
|
17603
|
+
buildCommand: "",
|
|
17604
|
+
installCommand: "",
|
|
17605
|
+
outputDirectory: "."
|
|
17606
|
+
}
|
|
17607
|
+
};
|
|
17608
|
+
const res = await fetch(`${VERCEL_API2}/v13/deployments${q2}`, {
|
|
17609
|
+
method: "POST",
|
|
17610
|
+
headers: apiHeaders(token, { "Content-Type": "application/json" }),
|
|
17611
|
+
body: JSON.stringify(body)
|
|
17612
|
+
});
|
|
17613
|
+
if (!res.ok) {
|
|
17614
|
+
const text = await res.text();
|
|
17615
|
+
throw formatVercelError(res.status, text, "create deployment");
|
|
17616
|
+
}
|
|
17617
|
+
return await res.json();
|
|
17618
|
+
}
|
|
17619
|
+
async function waitForReady(deploymentId, token, orgId) {
|
|
17620
|
+
const q2 = teamQuery(orgId);
|
|
17621
|
+
for (let attempt = 0; attempt < POLL_MAX_ATTEMPTS; attempt++) {
|
|
17622
|
+
const res = await fetch(
|
|
17623
|
+
`${VERCEL_API2}/v13/deployments/${deploymentId}${q2}`,
|
|
17624
|
+
{ headers: apiHeaders(token) }
|
|
17625
|
+
);
|
|
17626
|
+
if (!res.ok) {
|
|
17627
|
+
const text = await res.text();
|
|
17628
|
+
throw formatVercelError(res.status, text, "check deployment status");
|
|
17629
|
+
}
|
|
17630
|
+
const data = await res.json();
|
|
17631
|
+
if (data.readyState === "READY") return data;
|
|
17632
|
+
if (data.readyState === "ERROR") {
|
|
17633
|
+
throw new Error(
|
|
17634
|
+
`Deployment failed: ${data.errorMessage || "Unknown error"}`
|
|
17635
|
+
);
|
|
17636
|
+
}
|
|
17637
|
+
if (data.readyState === "CANCELED") {
|
|
17638
|
+
throw new Error("Deployment was canceled");
|
|
17639
|
+
}
|
|
17640
|
+
await new Promise((r2) => setTimeout(r2, POLL_INTERVAL_MS));
|
|
17641
|
+
}
|
|
17642
|
+
throw new Error("Deployment timed out (5+ minutes)");
|
|
17643
|
+
}
|
|
17644
|
+
async function deployVercelFrontend(appDir, _config) {
|
|
17645
|
+
const result = resolveVercelCredentials(appDir);
|
|
17646
|
+
if (result.missing) {
|
|
17647
|
+
const secretVars = result.missing.filter((v2) => v2 === "VERCEL_TOKEN");
|
|
17648
|
+
const appVars = result.missing.filter((v2) => v2 !== "VERCEL_TOKEN");
|
|
17649
|
+
const hints = [];
|
|
17650
|
+
if (secretVars.length > 0)
|
|
17651
|
+
hints.push("Add VERCEL_TOKEN to .dndev.secrets at project root.");
|
|
17652
|
+
if (appVars.length > 0)
|
|
17653
|
+
hints.push(`Add ${appVars.join(", ")} to apps/<app>/.env`);
|
|
17654
|
+
throw new Error(
|
|
17655
|
+
`Missing Vercel credentials: ${result.missing.join(", ")}
|
|
17656
|
+
` + hints.join("\n") + "\nSee guides/dndev/SETUP_VERCEL.md"
|
|
17657
|
+
);
|
|
17658
|
+
}
|
|
17659
|
+
const { token, orgId, projectId } = result.credentials;
|
|
17660
|
+
const distDir = joinPath(appDir, "dist");
|
|
17661
|
+
if (!pathExists(distDir)) {
|
|
17662
|
+
throw new Error(`dist/ not found at ${distDir}. Run build first.`);
|
|
17663
|
+
}
|
|
17664
|
+
log.debug("Using Vercel REST API (token-based, no CLI)");
|
|
17665
|
+
log.info(`Vercel org: ${orgId ?? "(personal account)"}`);
|
|
17666
|
+
log.info(`Vercel project: ${projectId}`);
|
|
17667
|
+
log.info(
|
|
17668
|
+
`Token: ${token.slice(0, 6)}...${token.slice(-4)} (${token.length} chars)`
|
|
17669
|
+
);
|
|
17670
|
+
log.info("Validating Vercel credentials...");
|
|
17671
|
+
const user = await validateToken(token);
|
|
17672
|
+
log.success(`Token valid (${user.username})`);
|
|
17673
|
+
const project = await validateProject(token, projectId, orgId);
|
|
17674
|
+
log.success(`Project accessible (${project.projectName})`);
|
|
17675
|
+
log.info("Collecting dist/ files...");
|
|
17676
|
+
const files = await collectDistFiles(distDir);
|
|
17677
|
+
if (files.length === 0) {
|
|
17678
|
+
throw new Error("dist/ is empty \u2014 nothing to deploy.");
|
|
17679
|
+
}
|
|
17680
|
+
log.info(`Found ${files.length} files`);
|
|
17681
|
+
log.info("Uploading files to Vercel...");
|
|
17682
|
+
await uploadFiles(files, token, orgId);
|
|
17683
|
+
log.success(`${files.length} files uploaded`);
|
|
17684
|
+
log.info("Creating production deployment...");
|
|
17685
|
+
const deployment = await createDeployment(
|
|
17686
|
+
files,
|
|
17687
|
+
token,
|
|
17688
|
+
orgId,
|
|
17689
|
+
projectId,
|
|
17690
|
+
project.projectName
|
|
17691
|
+
);
|
|
17692
|
+
log.info(`Deployment ${deployment.id} created, waiting...`);
|
|
17693
|
+
const ready = await waitForReady(deployment.id, token, orgId);
|
|
17694
|
+
const prodUrl = `https://${ready.url}`;
|
|
17695
|
+
log.success(`Production: ${prodUrl}`);
|
|
17696
|
+
if (ready.alias?.length) {
|
|
17697
|
+
log.info(`Aliases: ${ready.alias.join(", ")}`);
|
|
17698
|
+
}
|
|
17699
|
+
}
|
|
17700
|
+
|
|
17701
|
+
// packages/tooling/src/apps/deploy.ts
|
|
17702
|
+
init_cli_input();
|
|
17703
|
+
init_cli_output();
|
|
17704
|
+
init_cli_output();
|
|
17705
|
+
init_cli_tools();
|
|
17706
|
+
init_errors();
|
|
17707
|
+
init_pathResolver();
|
|
17708
|
+
|
|
17599
17709
|
// packages/tooling/src/utils/provider-detection.ts
|
|
17600
17710
|
init_utils();
|
|
17601
17711
|
init_pathResolver();
|
|
@@ -17680,12 +17790,6 @@ function detectProvider(appDir) {
|
|
|
17680
17790
|
}
|
|
17681
17791
|
|
|
17682
17792
|
// packages/tooling/src/apps/deploy.ts
|
|
17683
|
-
init_cli_input();
|
|
17684
|
-
init_cli_output();
|
|
17685
|
-
init_cli_output();
|
|
17686
|
-
init_cli_tools();
|
|
17687
|
-
init_errors();
|
|
17688
|
-
init_pathResolver();
|
|
17689
17793
|
async function main2(options = {}) {
|
|
17690
17794
|
const isStaging = options.staging ?? false;
|
|
17691
17795
|
const config = {
|