@base44-preview/cli 0.1.7-pr.584.b9b7274 → 0.1.7-pr.584.bd4da00
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/dist/cli/index.js +1377 -1201
- package/dist/cli/index.js.map +25 -19
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -23352,15 +23352,15 @@ var require_windows = __commonJS((exports, module) => {
|
|
|
23352
23352
|
}
|
|
23353
23353
|
return false;
|
|
23354
23354
|
}
|
|
23355
|
-
function checkStat(
|
|
23356
|
-
if (!
|
|
23355
|
+
function checkStat(stat3, path11, options) {
|
|
23356
|
+
if (!stat3.isSymbolicLink() && !stat3.isFile()) {
|
|
23357
23357
|
return false;
|
|
23358
23358
|
}
|
|
23359
23359
|
return checkPathExt(path11, options);
|
|
23360
23360
|
}
|
|
23361
23361
|
function isexe(path11, options, cb) {
|
|
23362
|
-
fs14.stat(path11, function(er,
|
|
23363
|
-
cb(er, er ? false : checkStat(
|
|
23362
|
+
fs14.stat(path11, function(er, stat3) {
|
|
23363
|
+
cb(er, er ? false : checkStat(stat3, path11, options));
|
|
23364
23364
|
});
|
|
23365
23365
|
}
|
|
23366
23366
|
function sync(path11, options) {
|
|
@@ -23374,20 +23374,20 @@ var require_mode = __commonJS((exports, module) => {
|
|
|
23374
23374
|
isexe.sync = sync;
|
|
23375
23375
|
var fs14 = __require("fs");
|
|
23376
23376
|
function isexe(path11, options, cb) {
|
|
23377
|
-
fs14.stat(path11, function(er,
|
|
23378
|
-
cb(er, er ? false : checkStat(
|
|
23377
|
+
fs14.stat(path11, function(er, stat3) {
|
|
23378
|
+
cb(er, er ? false : checkStat(stat3, options));
|
|
23379
23379
|
});
|
|
23380
23380
|
}
|
|
23381
23381
|
function sync(path11, options) {
|
|
23382
23382
|
return checkStat(fs14.statSync(path11), options);
|
|
23383
23383
|
}
|
|
23384
|
-
function checkStat(
|
|
23385
|
-
return
|
|
23384
|
+
function checkStat(stat3, options) {
|
|
23385
|
+
return stat3.isFile() && checkMode(stat3, options);
|
|
23386
23386
|
}
|
|
23387
|
-
function checkMode(
|
|
23388
|
-
var mod =
|
|
23389
|
-
var uid =
|
|
23390
|
-
var gid =
|
|
23387
|
+
function checkMode(stat3, options) {
|
|
23388
|
+
var mod = stat3.mode;
|
|
23389
|
+
var uid = stat3.uid;
|
|
23390
|
+
var gid = stat3.gid;
|
|
23391
23391
|
var myUid = options.uid !== undefined ? options.uid : process.getuid && process.getuid();
|
|
23392
23392
|
var myGid = options.gid !== undefined ? options.gid : process.getgid && process.getgid();
|
|
23393
23393
|
var u = parseInt("100", 8);
|
|
@@ -23419,12 +23419,12 @@ var require_isexe = __commonJS((exports, module) => {
|
|
|
23419
23419
|
if (typeof Promise !== "function") {
|
|
23420
23420
|
throw new TypeError("callback not provided");
|
|
23421
23421
|
}
|
|
23422
|
-
return new Promise(function(
|
|
23422
|
+
return new Promise(function(resolve5, reject) {
|
|
23423
23423
|
isexe(path11, options || {}, function(er, is) {
|
|
23424
23424
|
if (er) {
|
|
23425
23425
|
reject(er);
|
|
23426
23426
|
} else {
|
|
23427
|
-
|
|
23427
|
+
resolve5(is);
|
|
23428
23428
|
}
|
|
23429
23429
|
});
|
|
23430
23430
|
});
|
|
@@ -23486,27 +23486,27 @@ var require_which = __commonJS((exports, module) => {
|
|
|
23486
23486
|
opt = {};
|
|
23487
23487
|
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
23488
23488
|
const found = [];
|
|
23489
|
-
const step = (i) => new Promise((
|
|
23489
|
+
const step = (i) => new Promise((resolve5, reject) => {
|
|
23490
23490
|
if (i === pathEnv.length)
|
|
23491
|
-
return opt.all && found.length ?
|
|
23491
|
+
return opt.all && found.length ? resolve5(found) : reject(getNotFoundError(cmd));
|
|
23492
23492
|
const ppRaw = pathEnv[i];
|
|
23493
23493
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
23494
23494
|
const pCmd = path11.join(pathPart, cmd);
|
|
23495
23495
|
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
23496
|
-
|
|
23496
|
+
resolve5(subStep(p, i, 0));
|
|
23497
23497
|
});
|
|
23498
|
-
const subStep = (p, i, ii) => new Promise((
|
|
23498
|
+
const subStep = (p, i, ii) => new Promise((resolve5, reject) => {
|
|
23499
23499
|
if (ii === pathExt.length)
|
|
23500
|
-
return
|
|
23500
|
+
return resolve5(step(i + 1));
|
|
23501
23501
|
const ext = pathExt[ii];
|
|
23502
23502
|
isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
|
|
23503
23503
|
if (!er && is) {
|
|
23504
23504
|
if (opt.all)
|
|
23505
23505
|
found.push(p + ext);
|
|
23506
23506
|
else
|
|
23507
|
-
return
|
|
23507
|
+
return resolve5(p + ext);
|
|
23508
23508
|
}
|
|
23509
|
-
return
|
|
23509
|
+
return resolve5(subStep(p, i, ii + 1));
|
|
23510
23510
|
});
|
|
23511
23511
|
});
|
|
23512
23512
|
return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
|
|
@@ -27034,7 +27034,7 @@ var require_lodash8 = __commonJS((exports, module) => {
|
|
|
27034
27034
|
}
|
|
27035
27035
|
return mapped.length && mapped[0] === arrays[0] ? baseIntersection(mapped, undefined2, comparator) : [];
|
|
27036
27036
|
});
|
|
27037
|
-
function
|
|
27037
|
+
function join18(array2, separator) {
|
|
27038
27038
|
return array2 == null ? "" : nativeJoin.call(array2, separator);
|
|
27039
27039
|
}
|
|
27040
27040
|
function last(array2) {
|
|
@@ -28966,7 +28966,7 @@ __p += '`;
|
|
|
28966
28966
|
lodash.isUndefined = isUndefined;
|
|
28967
28967
|
lodash.isWeakMap = isWeakMap;
|
|
28968
28968
|
lodash.isWeakSet = isWeakSet;
|
|
28969
|
-
lodash.join =
|
|
28969
|
+
lodash.join = join18;
|
|
28970
28970
|
lodash.kebabCase = kebabCase;
|
|
28971
28971
|
lodash.last = last;
|
|
28972
28972
|
lodash.lastIndexOf = lastIndexOf;
|
|
@@ -31176,7 +31176,7 @@ function cleanDoc(doc2) {
|
|
|
31176
31176
|
return mapDoc(doc2, (currentDoc) => cleanDocFn(currentDoc));
|
|
31177
31177
|
}
|
|
31178
31178
|
function replaceEndOfLine(doc2, replacement = literalline) {
|
|
31179
|
-
return mapDoc(doc2, (currentDoc) => typeof currentDoc === "string" ?
|
|
31179
|
+
return mapDoc(doc2, (currentDoc) => typeof currentDoc === "string" ? join27(replacement, currentDoc.split(`
|
|
31180
31180
|
`)) : currentDoc);
|
|
31181
31181
|
}
|
|
31182
31182
|
function canBreakFn(doc2) {
|
|
@@ -31256,7 +31256,7 @@ function indentIfBreak(contents, options) {
|
|
|
31256
31256
|
negate: options.negate
|
|
31257
31257
|
};
|
|
31258
31258
|
}
|
|
31259
|
-
function
|
|
31259
|
+
function join27(separator, docs) {
|
|
31260
31260
|
assertDoc(separator);
|
|
31261
31261
|
assertDocArray(docs);
|
|
31262
31262
|
const parts = [];
|
|
@@ -31967,7 +31967,7 @@ var init_doc = __esm(() => {
|
|
|
31967
31967
|
MODE_FLAT = Symbol("MODE_FLAT");
|
|
31968
31968
|
DOC_FILL_PRINTED_LENGTH = Symbol("DOC_FILL_PRINTED_LENGTH");
|
|
31969
31969
|
builders = {
|
|
31970
|
-
join:
|
|
31970
|
+
join: join27,
|
|
31971
31971
|
line,
|
|
31972
31972
|
softline,
|
|
31973
31973
|
hardline,
|
|
@@ -120896,7 +120896,7 @@ function parse42(toml, { maxDepth = 1000, integersAsBigInt } = {}) {
|
|
|
120896
120896
|
}
|
|
120897
120897
|
return res;
|
|
120898
120898
|
}
|
|
120899
|
-
async function
|
|
120899
|
+
async function readFile7(file2) {
|
|
120900
120900
|
if (isUrlString(file2)) {
|
|
120901
120901
|
file2 = new URL(file2);
|
|
120902
120902
|
}
|
|
@@ -134690,7 +134690,7 @@ ${codeblock}`, options8);
|
|
|
134690
134690
|
"\\": "\\"
|
|
134691
134691
|
};
|
|
134692
134692
|
KEY_PART_RE = /^[a-zA-Z0-9-_]+[ \t]*$/;
|
|
134693
|
-
read_file_default =
|
|
134693
|
+
read_file_default = readFile7;
|
|
134694
134694
|
loadConfigFromPackageJson = process.versions.bun ? async function loadConfigFromBunPackageJson(file2) {
|
|
134695
134695
|
const { prettier } = await readBunPackageJson(file2);
|
|
134696
134696
|
return prettier;
|
|
@@ -136881,7 +136881,7 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`;
|
|
|
136881
136881
|
return mapDoc2(doc2, (currentDoc) => cleanDocFn2(currentDoc));
|
|
136882
136882
|
}
|
|
136883
136883
|
function replaceEndOfLine2(doc2, replacement = literalline2) {
|
|
136884
|
-
return mapDoc2(doc2, (currentDoc) => typeof currentDoc === "string" ?
|
|
136884
|
+
return mapDoc2(doc2, (currentDoc) => typeof currentDoc === "string" ? join29(replacement, currentDoc.split(`
|
|
136885
136885
|
`)) : currentDoc);
|
|
136886
136886
|
}
|
|
136887
136887
|
function canBreakFn2(doc2) {
|
|
@@ -136967,7 +136967,7 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`;
|
|
|
136967
136967
|
negate: options8.negate
|
|
136968
136968
|
};
|
|
136969
136969
|
}
|
|
136970
|
-
function
|
|
136970
|
+
function join29(separator, docs) {
|
|
136971
136971
|
assertDoc2(separator);
|
|
136972
136972
|
assertDocArray2(docs);
|
|
136973
136973
|
const parts = [];
|
|
@@ -137632,7 +137632,7 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`;
|
|
|
137632
137632
|
}
|
|
137633
137633
|
}
|
|
137634
137634
|
var builders2 = {
|
|
137635
|
-
join:
|
|
137635
|
+
join: join29,
|
|
137636
137636
|
line: line3,
|
|
137637
137637
|
softline: softline2,
|
|
137638
137638
|
hardline: hardline4,
|
|
@@ -138287,11 +138287,11 @@ var require_prettier = __commonJS((exports, module) => {
|
|
|
138287
138287
|
var require_formatter = __commonJS((exports) => {
|
|
138288
138288
|
var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P9, generator) {
|
|
138289
138289
|
function adopt(value) {
|
|
138290
|
-
return value instanceof P9 ? value : new P9(function(
|
|
138291
|
-
|
|
138290
|
+
return value instanceof P9 ? value : new P9(function(resolve15) {
|
|
138291
|
+
resolve15(value);
|
|
138292
138292
|
});
|
|
138293
138293
|
}
|
|
138294
|
-
return new (P9 || (P9 = Promise))(function(
|
|
138294
|
+
return new (P9 || (P9 = Promise))(function(resolve15, reject) {
|
|
138295
138295
|
function fulfilled(value) {
|
|
138296
138296
|
try {
|
|
138297
138297
|
step(generator.next(value));
|
|
@@ -138307,7 +138307,7 @@ var require_formatter = __commonJS((exports) => {
|
|
|
138307
138307
|
}
|
|
138308
138308
|
}
|
|
138309
138309
|
function step(result) {
|
|
138310
|
-
result.done ?
|
|
138310
|
+
result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
138311
138311
|
}
|
|
138312
138312
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
138313
138313
|
});
|
|
@@ -142960,7 +142960,7 @@ var require_url = __commonJS((exports) => {
|
|
|
142960
142960
|
};
|
|
142961
142961
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
142962
142962
|
exports.parse = undefined;
|
|
142963
|
-
exports.resolve =
|
|
142963
|
+
exports.resolve = resolve15;
|
|
142964
142964
|
exports.cwd = cwd;
|
|
142965
142965
|
exports.getProtocol = getProtocol;
|
|
142966
142966
|
exports.getExtension = getExtension;
|
|
@@ -142988,7 +142988,7 @@ var require_url = __commonJS((exports) => {
|
|
|
142988
142988
|
var urlDecodePatterns = [/%23/g, "#", /%24/g, "$", /%26/g, "&", /%2C/g, ",", /%40/g, "@"];
|
|
142989
142989
|
var parse11 = (u4) => new URL(u4);
|
|
142990
142990
|
exports.parse = parse11;
|
|
142991
|
-
function
|
|
142991
|
+
function resolve15(from, to5) {
|
|
142992
142992
|
const fromUrl = new URL((0, convert_path_to_posix_1.default)(from), "https://aaa.nonexistanturl.com");
|
|
142993
142993
|
const resolvedUrl = new URL((0, convert_path_to_posix_1.default)(to5), fromUrl);
|
|
142994
142994
|
const endSpaces = to5.match(/(\s*)$/)?.[1] || "";
|
|
@@ -143124,7 +143124,7 @@ var require_url = __commonJS((exports) => {
|
|
|
143124
143124
|
}
|
|
143125
143125
|
function relative5(from, to5) {
|
|
143126
143126
|
if (!isFileSystemPath(from) || !isFileSystemPath(to5)) {
|
|
143127
|
-
return
|
|
143127
|
+
return resolve15(from, to5);
|
|
143128
143128
|
}
|
|
143129
143129
|
const fromDir = path_1.default.dirname(stripHash(from));
|
|
143130
143130
|
const toPath4 = stripHash(to5);
|
|
@@ -143800,7 +143800,7 @@ var require_plugins = __commonJS((exports) => {
|
|
|
143800
143800
|
let plugin;
|
|
143801
143801
|
let lastError;
|
|
143802
143802
|
let index = 0;
|
|
143803
|
-
return new Promise((
|
|
143803
|
+
return new Promise((resolve15, reject) => {
|
|
143804
143804
|
runNextPlugin();
|
|
143805
143805
|
function runNextPlugin() {
|
|
143806
143806
|
plugin = plugins[index++];
|
|
@@ -143828,7 +143828,7 @@ var require_plugins = __commonJS((exports) => {
|
|
|
143828
143828
|
}
|
|
143829
143829
|
}
|
|
143830
143830
|
function onSuccess(result) {
|
|
143831
|
-
|
|
143831
|
+
resolve15({
|
|
143832
143832
|
plugin,
|
|
143833
143833
|
result
|
|
143834
143834
|
});
|
|
@@ -143925,7 +143925,7 @@ var require_parse7 = __commonJS((exports) => {
|
|
|
143925
143925
|
extension: url3.getExtension(path18)
|
|
143926
143926
|
};
|
|
143927
143927
|
try {
|
|
143928
|
-
const resolver = await
|
|
143928
|
+
const resolver = await readFile8(file2, options8, $refs);
|
|
143929
143929
|
$ref.pathType = resolver.plugin.name;
|
|
143930
143930
|
file2.data = resolver.result;
|
|
143931
143931
|
const parser2 = await parseFile(file2, options8, $refs);
|
|
@@ -143938,7 +143938,7 @@ var require_parse7 = __commonJS((exports) => {
|
|
|
143938
143938
|
throw err;
|
|
143939
143939
|
}
|
|
143940
143940
|
}
|
|
143941
|
-
async function
|
|
143941
|
+
async function readFile8(file2, options8, $refs) {
|
|
143942
143942
|
let resolvers = plugins.all(options8.resolve);
|
|
143943
143943
|
resolvers = plugins.filter(resolvers, "canRead", file2);
|
|
143944
143944
|
plugins.sort(resolvers);
|
|
@@ -145161,11 +145161,11 @@ var require_lib3 = __commonJS((exports) => {
|
|
|
145161
145161
|
var require_resolver = __commonJS((exports) => {
|
|
145162
145162
|
var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P9, generator) {
|
|
145163
145163
|
function adopt(value) {
|
|
145164
|
-
return value instanceof P9 ? value : new P9(function(
|
|
145165
|
-
|
|
145164
|
+
return value instanceof P9 ? value : new P9(function(resolve15) {
|
|
145165
|
+
resolve15(value);
|
|
145166
145166
|
});
|
|
145167
145167
|
}
|
|
145168
|
-
return new (P9 || (P9 = Promise))(function(
|
|
145168
|
+
return new (P9 || (P9 = Promise))(function(resolve15, reject) {
|
|
145169
145169
|
function fulfilled(value) {
|
|
145170
145170
|
try {
|
|
145171
145171
|
step(generator.next(value));
|
|
@@ -145181,7 +145181,7 @@ var require_resolver = __commonJS((exports) => {
|
|
|
145181
145181
|
}
|
|
145182
145182
|
}
|
|
145183
145183
|
function step(result) {
|
|
145184
|
-
result.done ?
|
|
145184
|
+
result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
145185
145185
|
}
|
|
145186
145186
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
145187
145187
|
});
|
|
@@ -145302,11 +145302,11 @@ var require_optionValidator = __commonJS((exports) => {
|
|
|
145302
145302
|
var require_src3 = __commonJS((exports) => {
|
|
145303
145303
|
var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P9, generator) {
|
|
145304
145304
|
function adopt(value) {
|
|
145305
|
-
return value instanceof P9 ? value : new P9(function(
|
|
145306
|
-
|
|
145305
|
+
return value instanceof P9 ? value : new P9(function(resolve15) {
|
|
145306
|
+
resolve15(value);
|
|
145307
145307
|
});
|
|
145308
145308
|
}
|
|
145309
|
-
return new (P9 || (P9 = Promise))(function(
|
|
145309
|
+
return new (P9 || (P9 = Promise))(function(resolve15, reject) {
|
|
145310
145310
|
function fulfilled(value) {
|
|
145311
145311
|
try {
|
|
145312
145312
|
step(generator.next(value));
|
|
@@ -145322,7 +145322,7 @@ var require_src3 = __commonJS((exports) => {
|
|
|
145322
145322
|
}
|
|
145323
145323
|
}
|
|
145324
145324
|
function step(result) {
|
|
145325
|
-
result.done ?
|
|
145325
|
+
result.done ? resolve15(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
145326
145326
|
}
|
|
145327
145327
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
145328
145328
|
});
|
|
@@ -150984,11 +150984,11 @@ var require_raw_body = __commonJS((exports, module) => {
|
|
|
150984
150984
|
if (done) {
|
|
150985
150985
|
return readStream(stream, encoding, length, limit, wrap(done));
|
|
150986
150986
|
}
|
|
150987
|
-
return new Promise(function executor(
|
|
150987
|
+
return new Promise(function executor(resolve15, reject) {
|
|
150988
150988
|
readStream(stream, encoding, length, limit, function onRead2(err, buf) {
|
|
150989
150989
|
if (err)
|
|
150990
150990
|
return reject(err);
|
|
150991
|
-
|
|
150991
|
+
resolve15(buf);
|
|
150992
150992
|
});
|
|
150993
150993
|
});
|
|
150994
150994
|
}
|
|
@@ -164112,8 +164112,8 @@ var require_view = __commonJS((exports, module) => {
|
|
|
164112
164112
|
var dirname21 = path18.dirname;
|
|
164113
164113
|
var basename6 = path18.basename;
|
|
164114
164114
|
var extname3 = path18.extname;
|
|
164115
|
-
var
|
|
164116
|
-
var
|
|
164115
|
+
var join30 = path18.join;
|
|
164116
|
+
var resolve15 = path18.resolve;
|
|
164117
164117
|
module.exports = View;
|
|
164118
164118
|
function View(name2, options8) {
|
|
164119
164119
|
var opts = options8 || {};
|
|
@@ -164147,7 +164147,7 @@ var require_view = __commonJS((exports, module) => {
|
|
|
164147
164147
|
debug('lookup "%s"', name2);
|
|
164148
164148
|
for (var i5 = 0;i5 < roots.length && !path19; i5++) {
|
|
164149
164149
|
var root2 = roots[i5];
|
|
164150
|
-
var loc =
|
|
164150
|
+
var loc = resolve15(root2, name2);
|
|
164151
164151
|
var dir = dirname21(loc);
|
|
164152
164152
|
var file2 = basename6(loc);
|
|
164153
164153
|
path19 = this.resolve(dir, file2);
|
|
@@ -164172,14 +164172,14 @@ var require_view = __commonJS((exports, module) => {
|
|
|
164172
164172
|
});
|
|
164173
164173
|
sync = false;
|
|
164174
164174
|
};
|
|
164175
|
-
View.prototype.resolve = function
|
|
164175
|
+
View.prototype.resolve = function resolve16(dir, file2) {
|
|
164176
164176
|
var ext = this.ext;
|
|
164177
|
-
var path19 =
|
|
164177
|
+
var path19 = join30(dir, file2);
|
|
164178
164178
|
var stat4 = tryStat(path19);
|
|
164179
164179
|
if (stat4 && stat4.isFile()) {
|
|
164180
164180
|
return path19;
|
|
164181
164181
|
}
|
|
164182
|
-
path19 =
|
|
164182
|
+
path19 = join30(dir, basename6(file2, ext), "index" + ext);
|
|
164183
164183
|
stat4 = tryStat(path19);
|
|
164184
164184
|
if (stat4 && stat4.isFile()) {
|
|
164185
164185
|
return path19;
|
|
@@ -166331,7 +166331,7 @@ var require_application = __commonJS((exports, module) => {
|
|
|
166331
166331
|
var compileETag = require_utils10().compileETag;
|
|
166332
166332
|
var compileQueryParser = require_utils10().compileQueryParser;
|
|
166333
166333
|
var compileTrust = require_utils10().compileTrust;
|
|
166334
|
-
var
|
|
166334
|
+
var resolve15 = __require("node:path").resolve;
|
|
166335
166335
|
var once9 = require_once();
|
|
166336
166336
|
var Router = require_router();
|
|
166337
166337
|
var slice = Array.prototype.slice;
|
|
@@ -166385,7 +166385,7 @@ var require_application = __commonJS((exports, module) => {
|
|
|
166385
166385
|
this.mountpath = "/";
|
|
166386
166386
|
this.locals.settings = this.settings;
|
|
166387
166387
|
this.set("view", View);
|
|
166388
|
-
this.set("views",
|
|
166388
|
+
this.set("views", resolve15("views"));
|
|
166389
166389
|
this.set("jsonp callback name", "callback");
|
|
166390
166390
|
if (env4 === "production") {
|
|
166391
166391
|
this.enable("view cache");
|
|
@@ -167874,9 +167874,9 @@ var require_send = __commonJS((exports, module) => {
|
|
|
167874
167874
|
var Stream2 = __require("stream");
|
|
167875
167875
|
var util2 = __require("util");
|
|
167876
167876
|
var extname3 = path18.extname;
|
|
167877
|
-
var
|
|
167877
|
+
var join30 = path18.join;
|
|
167878
167878
|
var normalize2 = path18.normalize;
|
|
167879
|
-
var
|
|
167879
|
+
var resolve15 = path18.resolve;
|
|
167880
167880
|
var sep2 = path18.sep;
|
|
167881
167881
|
var BYTES_RANGE_REGEXP = /^ *bytes=/;
|
|
167882
167882
|
var MAX_MAXAGE = 60 * 60 * 24 * 365 * 1000;
|
|
@@ -167905,7 +167905,7 @@ var require_send = __commonJS((exports, module) => {
|
|
|
167905
167905
|
this._maxage = opts.maxAge || opts.maxage;
|
|
167906
167906
|
this._maxage = typeof this._maxage === "string" ? ms9(this._maxage) : Number(this._maxage);
|
|
167907
167907
|
this._maxage = !isNaN(this._maxage) ? Math.min(Math.max(0, this._maxage), MAX_MAXAGE) : 0;
|
|
167908
|
-
this._root = opts.root ?
|
|
167908
|
+
this._root = opts.root ? resolve15(opts.root) : null;
|
|
167909
167909
|
}
|
|
167910
167910
|
util2.inherits(SendStream, Stream2);
|
|
167911
167911
|
SendStream.prototype.error = function error48(status, err) {
|
|
@@ -168046,7 +168046,7 @@ var require_send = __commonJS((exports, module) => {
|
|
|
168046
168046
|
return res;
|
|
168047
168047
|
}
|
|
168048
168048
|
parts = path19.split(sep2);
|
|
168049
|
-
path19 = normalize2(
|
|
168049
|
+
path19 = normalize2(join30(root2, path19));
|
|
168050
168050
|
} else {
|
|
168051
168051
|
if (UP_PATH_REGEXP.test(path19)) {
|
|
168052
168052
|
debug('malicious path "%s"', path19);
|
|
@@ -168054,7 +168054,7 @@ var require_send = __commonJS((exports, module) => {
|
|
|
168054
168054
|
return res;
|
|
168055
168055
|
}
|
|
168056
168056
|
parts = normalize2(path19).split(sep2);
|
|
168057
|
-
path19 =
|
|
168057
|
+
path19 = resolve15(path19);
|
|
168058
168058
|
}
|
|
168059
168059
|
if (containsDotFile(parts)) {
|
|
168060
168060
|
debug('%s dotfile "%s"', this._dotfiles, path19);
|
|
@@ -168186,7 +168186,7 @@ var require_send = __commonJS((exports, module) => {
|
|
|
168186
168186
|
return self2.onStatError(err);
|
|
168187
168187
|
return self2.error(404);
|
|
168188
168188
|
}
|
|
168189
|
-
var p4 =
|
|
168189
|
+
var p4 = join30(path19, self2._index[i5]);
|
|
168190
168190
|
debug('stat "%s"', p4);
|
|
168191
168191
|
fs28.stat(p4, function(err2, stat4) {
|
|
168192
168192
|
if (err2)
|
|
@@ -168382,7 +168382,7 @@ var require_response = __commonJS((exports, module) => {
|
|
|
168382
168382
|
var cookie = require_cookie();
|
|
168383
168383
|
var send = require_send();
|
|
168384
168384
|
var extname3 = path18.extname;
|
|
168385
|
-
var
|
|
168385
|
+
var resolve15 = path18.resolve;
|
|
168386
168386
|
var vary = require_vary();
|
|
168387
168387
|
var { Buffer: Buffer7 } = __require("node:buffer");
|
|
168388
168388
|
var res = Object.create(http.ServerResponse.prototype);
|
|
@@ -168591,7 +168591,7 @@ var require_response = __commonJS((exports, module) => {
|
|
|
168591
168591
|
}
|
|
168592
168592
|
opts = Object.create(opts);
|
|
168593
168593
|
opts.headers = headers;
|
|
168594
|
-
var fullPath = !opts.root ?
|
|
168594
|
+
var fullPath = !opts.root ? resolve15(path19) : path19;
|
|
168595
168595
|
return this.sendFile(fullPath, opts, done);
|
|
168596
168596
|
};
|
|
168597
168597
|
res.contentType = res.type = function contentType(type) {
|
|
@@ -168852,7 +168852,7 @@ var require_serve_static = __commonJS((exports, module) => {
|
|
|
168852
168852
|
var encodeUrl = require_encodeurl();
|
|
168853
168853
|
var escapeHtml = require_escape_html();
|
|
168854
168854
|
var parseUrl = require_parseurl();
|
|
168855
|
-
var
|
|
168855
|
+
var resolve15 = __require("path").resolve;
|
|
168856
168856
|
var send = require_send();
|
|
168857
168857
|
var url3 = __require("url");
|
|
168858
168858
|
module.exports = serveStatic;
|
|
@@ -168871,7 +168871,7 @@ var require_serve_static = __commonJS((exports, module) => {
|
|
|
168871
168871
|
throw new TypeError("option setHeaders must be function");
|
|
168872
168872
|
}
|
|
168873
168873
|
opts.maxage = opts.maxage || opts.maxAge || 0;
|
|
168874
|
-
opts.root =
|
|
168874
|
+
opts.root = resolve15(root2);
|
|
168875
168875
|
var onDirectory = redirect ? createRedirectDirectoryListener() : createNotFoundDirectoryListener();
|
|
168876
168876
|
return function serveStatic2(req, res, next) {
|
|
168877
168877
|
if (req.method !== "GET" && req.method !== "HEAD") {
|
|
@@ -172245,8 +172245,8 @@ var require_executor = __commonJS((exports, module) => {
|
|
|
172245
172245
|
}
|
|
172246
172246
|
resetBuffer() {
|
|
172247
172247
|
this.buffer = new Waterfall;
|
|
172248
|
-
this.buffer.chain(new Promise((
|
|
172249
|
-
this._triggerBuffer =
|
|
172248
|
+
this.buffer.chain(new Promise((resolve15) => {
|
|
172249
|
+
this._triggerBuffer = resolve15;
|
|
172250
172250
|
}));
|
|
172251
172251
|
if (this.ready)
|
|
172252
172252
|
this._triggerBuffer();
|
|
@@ -173266,7 +173266,7 @@ var require_storage = __commonJS((exports, module) => {
|
|
|
173266
173266
|
throw e8;
|
|
173267
173267
|
}
|
|
173268
173268
|
};
|
|
173269
|
-
var writeFileLinesAsync = (filename, lines, mode = DEFAULT_FILE_MODE) => new Promise((
|
|
173269
|
+
var writeFileLinesAsync = (filename, lines, mode = DEFAULT_FILE_MODE) => new Promise((resolve15, reject) => {
|
|
173270
173270
|
try {
|
|
173271
173271
|
const stream = writeFileStream(filename, { mode });
|
|
173272
173272
|
const readable2 = Readable6.from(lines);
|
|
@@ -173283,7 +173283,7 @@ var require_storage = __commonJS((exports, module) => {
|
|
|
173283
173283
|
if (err)
|
|
173284
173284
|
reject(err);
|
|
173285
173285
|
else
|
|
173286
|
-
|
|
173286
|
+
resolve15();
|
|
173287
173287
|
});
|
|
173288
173288
|
});
|
|
173289
173289
|
readable2.on("error", (err) => {
|
|
@@ -173454,7 +173454,7 @@ var require_persistence = __commonJS((exports, module) => {
|
|
|
173454
173454
|
return { data: tdata, indexes };
|
|
173455
173455
|
}
|
|
173456
173456
|
treatRawStreamAsync(rawStream) {
|
|
173457
|
-
return new Promise((
|
|
173457
|
+
return new Promise((resolve15, reject) => {
|
|
173458
173458
|
const dataById = {};
|
|
173459
173459
|
const indexes = {};
|
|
173460
173460
|
let corruptItems = 0;
|
|
@@ -173497,7 +173497,7 @@ var require_persistence = __commonJS((exports, module) => {
|
|
|
173497
173497
|
}
|
|
173498
173498
|
}
|
|
173499
173499
|
const data = Object.values(dataById);
|
|
173500
|
-
|
|
173500
|
+
resolve15({ data, indexes });
|
|
173501
173501
|
});
|
|
173502
173502
|
lineStream.on("error", function(err) {
|
|
173503
173503
|
reject(err, null);
|
|
@@ -199108,13 +199108,13 @@ var require_broadcast_operator = __commonJS((exports) => {
|
|
|
199108
199108
|
return true;
|
|
199109
199109
|
}
|
|
199110
199110
|
emitWithAck(ev2, ...args) {
|
|
199111
|
-
return new Promise((
|
|
199111
|
+
return new Promise((resolve15, reject) => {
|
|
199112
199112
|
args.push((err, responses) => {
|
|
199113
199113
|
if (err) {
|
|
199114
199114
|
err.responses = responses;
|
|
199115
199115
|
return reject(err);
|
|
199116
199116
|
} else {
|
|
199117
|
-
return
|
|
199117
|
+
return resolve15(responses);
|
|
199118
199118
|
}
|
|
199119
199119
|
});
|
|
199120
199120
|
this.emit(ev2, ...args);
|
|
@@ -199302,12 +199302,12 @@ var require_socket2 = __commonJS((exports) => {
|
|
|
199302
199302
|
}
|
|
199303
199303
|
emitWithAck(ev2, ...args) {
|
|
199304
199304
|
const withErr = this.flags.timeout !== undefined;
|
|
199305
|
-
return new Promise((
|
|
199305
|
+
return new Promise((resolve15, reject) => {
|
|
199306
199306
|
args.push((arg1, arg2) => {
|
|
199307
199307
|
if (withErr) {
|
|
199308
|
-
return arg1 ? reject(arg1) :
|
|
199308
|
+
return arg1 ? reject(arg1) : resolve15(arg2);
|
|
199309
199309
|
} else {
|
|
199310
|
-
return
|
|
199310
|
+
return resolve15(arg1);
|
|
199311
199311
|
}
|
|
199312
199312
|
});
|
|
199313
199313
|
this.emit(ev2, ...args);
|
|
@@ -199762,13 +199762,13 @@ var require_namespace = __commonJS((exports) => {
|
|
|
199762
199762
|
return true;
|
|
199763
199763
|
}
|
|
199764
199764
|
serverSideEmitWithAck(ev2, ...args) {
|
|
199765
|
-
return new Promise((
|
|
199765
|
+
return new Promise((resolve15, reject) => {
|
|
199766
199766
|
args.push((err, responses) => {
|
|
199767
199767
|
if (err) {
|
|
199768
199768
|
err.responses = responses;
|
|
199769
199769
|
return reject(err);
|
|
199770
199770
|
} else {
|
|
199771
|
-
return
|
|
199771
|
+
return resolve15(responses);
|
|
199772
199772
|
}
|
|
199773
199773
|
});
|
|
199774
199774
|
this.serverSideEmit(ev2, ...args);
|
|
@@ -203303,7 +203303,7 @@ var require_cluster_adapter = __commonJS((exports) => {
|
|
|
203303
203303
|
return localSockets;
|
|
203304
203304
|
}
|
|
203305
203305
|
const requestId = randomId();
|
|
203306
|
-
return new Promise((
|
|
203306
|
+
return new Promise((resolve15, reject) => {
|
|
203307
203307
|
const timeout3 = setTimeout(() => {
|
|
203308
203308
|
const storedRequest2 = this.requests.get(requestId);
|
|
203309
203309
|
if (storedRequest2) {
|
|
@@ -203313,7 +203313,7 @@ var require_cluster_adapter = __commonJS((exports) => {
|
|
|
203313
203313
|
}, opts.flags.timeout || DEFAULT_TIMEOUT);
|
|
203314
203314
|
const storedRequest = {
|
|
203315
203315
|
type: MessageType.FETCH_SOCKETS,
|
|
203316
|
-
resolve:
|
|
203316
|
+
resolve: resolve15,
|
|
203317
203317
|
timeout: timeout3,
|
|
203318
203318
|
current: 0,
|
|
203319
203319
|
expected: expectedResponseCount,
|
|
@@ -203523,7 +203523,7 @@ var require_cluster_adapter = __commonJS((exports) => {
|
|
|
203523
203523
|
return localSockets;
|
|
203524
203524
|
}
|
|
203525
203525
|
const requestId = randomId();
|
|
203526
|
-
return new Promise((
|
|
203526
|
+
return new Promise((resolve15, reject) => {
|
|
203527
203527
|
const timeout3 = setTimeout(() => {
|
|
203528
203528
|
const storedRequest2 = this.customRequests.get(requestId);
|
|
203529
203529
|
if (storedRequest2) {
|
|
@@ -203533,7 +203533,7 @@ var require_cluster_adapter = __commonJS((exports) => {
|
|
|
203533
203533
|
}, opts.flags.timeout || DEFAULT_TIMEOUT);
|
|
203534
203534
|
const storedRequest = {
|
|
203535
203535
|
type: MessageType.FETCH_SOCKETS,
|
|
203536
|
-
resolve:
|
|
203536
|
+
resolve: resolve15,
|
|
203537
203537
|
timeout: timeout3,
|
|
203538
203538
|
missingUids: new Set([...this.nodesMap.keys()]),
|
|
203539
203539
|
responses: localSockets
|
|
@@ -204262,13 +204262,13 @@ var require_dist4 = __commonJS((exports, module) => {
|
|
|
204262
204262
|
this.engine.close();
|
|
204263
204263
|
(0, uws_1.restoreAdapter)();
|
|
204264
204264
|
if (this.httpServer) {
|
|
204265
|
-
return new Promise((
|
|
204265
|
+
return new Promise((resolve15) => {
|
|
204266
204266
|
this.httpServer.close((err) => {
|
|
204267
204267
|
fn9 && fn9(err);
|
|
204268
204268
|
if (err) {
|
|
204269
204269
|
debug("server was not running");
|
|
204270
204270
|
}
|
|
204271
|
-
|
|
204271
|
+
resolve15();
|
|
204272
204272
|
});
|
|
204273
204273
|
});
|
|
204274
204274
|
} else {
|
|
@@ -217632,7 +217632,7 @@ var require_buffer_list = __commonJS((exports, module) => {
|
|
|
217632
217632
|
}
|
|
217633
217633
|
}, {
|
|
217634
217634
|
key: "join",
|
|
217635
|
-
value: function
|
|
217635
|
+
value: function join33(s5) {
|
|
217636
217636
|
if (this.length === 0)
|
|
217637
217637
|
return "";
|
|
217638
217638
|
var p4 = this.head;
|
|
@@ -218930,14 +218930,14 @@ var require_async_iterator = __commonJS((exports, module) => {
|
|
|
218930
218930
|
};
|
|
218931
218931
|
}
|
|
218932
218932
|
function readAndResolve(iter) {
|
|
218933
|
-
var
|
|
218934
|
-
if (
|
|
218933
|
+
var resolve15 = iter[kLastResolve];
|
|
218934
|
+
if (resolve15 !== null) {
|
|
218935
218935
|
var data = iter[kStream].read();
|
|
218936
218936
|
if (data !== null) {
|
|
218937
218937
|
iter[kLastPromise] = null;
|
|
218938
218938
|
iter[kLastResolve] = null;
|
|
218939
218939
|
iter[kLastReject] = null;
|
|
218940
|
-
|
|
218940
|
+
resolve15(createIterResult(data, false));
|
|
218941
218941
|
}
|
|
218942
218942
|
}
|
|
218943
218943
|
}
|
|
@@ -218945,13 +218945,13 @@ var require_async_iterator = __commonJS((exports, module) => {
|
|
|
218945
218945
|
process.nextTick(readAndResolve, iter);
|
|
218946
218946
|
}
|
|
218947
218947
|
function wrapForNext(lastPromise, iter) {
|
|
218948
|
-
return function(
|
|
218948
|
+
return function(resolve15, reject) {
|
|
218949
218949
|
lastPromise.then(function() {
|
|
218950
218950
|
if (iter[kEnded]) {
|
|
218951
|
-
|
|
218951
|
+
resolve15(createIterResult(undefined, true));
|
|
218952
218952
|
return;
|
|
218953
218953
|
}
|
|
218954
|
-
iter[kHandlePromise](
|
|
218954
|
+
iter[kHandlePromise](resolve15, reject);
|
|
218955
218955
|
}, reject);
|
|
218956
218956
|
};
|
|
218957
218957
|
}
|
|
@@ -218970,12 +218970,12 @@ var require_async_iterator = __commonJS((exports, module) => {
|
|
|
218970
218970
|
return Promise.resolve(createIterResult(undefined, true));
|
|
218971
218971
|
}
|
|
218972
218972
|
if (this[kStream].destroyed) {
|
|
218973
|
-
return new Promise(function(
|
|
218973
|
+
return new Promise(function(resolve15, reject) {
|
|
218974
218974
|
process.nextTick(function() {
|
|
218975
218975
|
if (_this[kError]) {
|
|
218976
218976
|
reject(_this[kError]);
|
|
218977
218977
|
} else {
|
|
218978
|
-
|
|
218978
|
+
resolve15(createIterResult(undefined, true));
|
|
218979
218979
|
}
|
|
218980
218980
|
});
|
|
218981
218981
|
});
|
|
@@ -218998,13 +218998,13 @@ var require_async_iterator = __commonJS((exports, module) => {
|
|
|
218998
218998
|
return this;
|
|
218999
218999
|
}), _defineProperty(_Object$setPrototypeO, "return", function _return() {
|
|
219000
219000
|
var _this2 = this;
|
|
219001
|
-
return new Promise(function(
|
|
219001
|
+
return new Promise(function(resolve15, reject) {
|
|
219002
219002
|
_this2[kStream].destroy(null, function(err) {
|
|
219003
219003
|
if (err) {
|
|
219004
219004
|
reject(err);
|
|
219005
219005
|
return;
|
|
219006
219006
|
}
|
|
219007
|
-
|
|
219007
|
+
resolve15(createIterResult(undefined, true));
|
|
219008
219008
|
});
|
|
219009
219009
|
});
|
|
219010
219010
|
}), _Object$setPrototypeO), AsyncIteratorPrototype);
|
|
@@ -219026,15 +219026,15 @@ var require_async_iterator = __commonJS((exports, module) => {
|
|
|
219026
219026
|
value: stream._readableState.endEmitted,
|
|
219027
219027
|
writable: true
|
|
219028
219028
|
}), _defineProperty(_Object$create, kHandlePromise, {
|
|
219029
|
-
value: function value(
|
|
219029
|
+
value: function value(resolve15, reject) {
|
|
219030
219030
|
var data = iterator[kStream].read();
|
|
219031
219031
|
if (data) {
|
|
219032
219032
|
iterator[kLastPromise] = null;
|
|
219033
219033
|
iterator[kLastResolve] = null;
|
|
219034
219034
|
iterator[kLastReject] = null;
|
|
219035
|
-
|
|
219035
|
+
resolve15(createIterResult(data, false));
|
|
219036
219036
|
} else {
|
|
219037
|
-
iterator[kLastResolve] =
|
|
219037
|
+
iterator[kLastResolve] = resolve15;
|
|
219038
219038
|
iterator[kLastReject] = reject;
|
|
219039
219039
|
}
|
|
219040
219040
|
},
|
|
@@ -219053,12 +219053,12 @@ var require_async_iterator = __commonJS((exports, module) => {
|
|
|
219053
219053
|
iterator[kError] = err;
|
|
219054
219054
|
return;
|
|
219055
219055
|
}
|
|
219056
|
-
var
|
|
219057
|
-
if (
|
|
219056
|
+
var resolve15 = iterator[kLastResolve];
|
|
219057
|
+
if (resolve15 !== null) {
|
|
219058
219058
|
iterator[kLastPromise] = null;
|
|
219059
219059
|
iterator[kLastResolve] = null;
|
|
219060
219060
|
iterator[kLastReject] = null;
|
|
219061
|
-
|
|
219061
|
+
resolve15(createIterResult(undefined, true));
|
|
219062
219062
|
}
|
|
219063
219063
|
iterator[kEnded] = true;
|
|
219064
219064
|
});
|
|
@@ -219070,7 +219070,7 @@ var require_async_iterator = __commonJS((exports, module) => {
|
|
|
219070
219070
|
|
|
219071
219071
|
// ../../node_modules/readable-stream/lib/internal/streams/from.js
|
|
219072
219072
|
var require_from = __commonJS((exports, module) => {
|
|
219073
|
-
function asyncGeneratorStep(gen,
|
|
219073
|
+
function asyncGeneratorStep(gen, resolve15, reject, _next, _throw, key2, arg) {
|
|
219074
219074
|
try {
|
|
219075
219075
|
var info = gen[key2](arg);
|
|
219076
219076
|
var value = info.value;
|
|
@@ -219079,7 +219079,7 @@ var require_from = __commonJS((exports, module) => {
|
|
|
219079
219079
|
return;
|
|
219080
219080
|
}
|
|
219081
219081
|
if (info.done) {
|
|
219082
|
-
|
|
219082
|
+
resolve15(value);
|
|
219083
219083
|
} else {
|
|
219084
219084
|
Promise.resolve(value).then(_next, _throw);
|
|
219085
219085
|
}
|
|
@@ -219087,13 +219087,13 @@ var require_from = __commonJS((exports, module) => {
|
|
|
219087
219087
|
function _asyncToGenerator(fn9) {
|
|
219088
219088
|
return function() {
|
|
219089
219089
|
var self2 = this, args = arguments;
|
|
219090
|
-
return new Promise(function(
|
|
219090
|
+
return new Promise(function(resolve15, reject) {
|
|
219091
219091
|
var gen = fn9.apply(self2, args);
|
|
219092
219092
|
function _next(value) {
|
|
219093
|
-
asyncGeneratorStep(gen,
|
|
219093
|
+
asyncGeneratorStep(gen, resolve15, reject, _next, _throw, "next", value);
|
|
219094
219094
|
}
|
|
219095
219095
|
function _throw(err) {
|
|
219096
|
-
asyncGeneratorStep(gen,
|
|
219096
|
+
asyncGeneratorStep(gen, resolve15, reject, _next, _throw, "throw", err);
|
|
219097
219097
|
}
|
|
219098
219098
|
_next(undefined);
|
|
219099
219099
|
});
|
|
@@ -221220,7 +221220,7 @@ var require_dist5 = __commonJS((exports, module) => {
|
|
|
221220
221220
|
determineAgent: () => determineAgent
|
|
221221
221221
|
});
|
|
221222
221222
|
module.exports = __toCommonJS2(src_exports);
|
|
221223
|
-
var
|
|
221223
|
+
var import_promises27 = __require("node:fs/promises");
|
|
221224
221224
|
var import_node_fs24 = __require("node:fs");
|
|
221225
221225
|
var DEVIN_LOCAL_PATH = "/opt/.devin";
|
|
221226
221226
|
var CURSOR2 = "cursor";
|
|
@@ -221278,7 +221278,7 @@ var require_dist5 = __commonJS((exports, module) => {
|
|
|
221278
221278
|
return { isAgent: true, agent: { name: REPLIT } };
|
|
221279
221279
|
}
|
|
221280
221280
|
try {
|
|
221281
|
-
await (0,
|
|
221281
|
+
await (0, import_promises27.access)(DEVIN_LOCAL_PATH, import_node_fs24.constants.F_OK);
|
|
221282
221282
|
return { isAgent: true, agent: { name: DEVIN } };
|
|
221283
221283
|
} catch (error48) {}
|
|
221284
221284
|
return { isAgent: false, agent: undefined };
|
|
@@ -237049,7 +237049,7 @@ function normalizeBase44Env() {
|
|
|
237049
237049
|
loadProjectEnvFiles();
|
|
237050
237050
|
|
|
237051
237051
|
// src/cli/index.ts
|
|
237052
|
-
import { dirname as dirname26, join as
|
|
237052
|
+
import { dirname as dirname26, join as join37 } from "node:path";
|
|
237053
237053
|
import { fileURLToPath as fileURLToPath6 } from "node:url";
|
|
237054
237054
|
|
|
237055
237055
|
// ../../node_modules/@clack/core/dist/index.mjs
|
|
@@ -238257,7 +238257,7 @@ var {
|
|
|
238257
238257
|
} = import__.default;
|
|
238258
238258
|
|
|
238259
238259
|
// src/cli/commands/agent-skills/pull.ts
|
|
238260
|
-
import { dirname as dirname11, join as
|
|
238260
|
+
import { dirname as dirname11, join as join18 } from "node:path";
|
|
238261
238261
|
// ../../node_modules/chalk/source/vendor/ansi-styles/index.js
|
|
238262
238262
|
var ANSI_BACKGROUND_OFFSET = 10;
|
|
238263
238263
|
var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
|
|
@@ -247439,7 +247439,7 @@ async function createProjectFilesForExistingProject(options) {
|
|
|
247439
247439
|
};
|
|
247440
247440
|
}
|
|
247441
247441
|
// src/core/project/deploy.ts
|
|
247442
|
-
import { resolve as
|
|
247442
|
+
import { resolve as resolve6 } from "node:path";
|
|
247443
247443
|
|
|
247444
247444
|
// src/core/site/api.ts
|
|
247445
247445
|
async function uploadSite(archivePath) {
|
|
@@ -247506,340 +247506,616 @@ async function createArchive(pathToArchive, targetArchivePath) {
|
|
|
247506
247506
|
cwd: pathToArchive
|
|
247507
247507
|
}, ["."]);
|
|
247508
247508
|
}
|
|
247509
|
-
// src/core/
|
|
247510
|
-
|
|
247511
|
-
|
|
247512
|
-
|
|
247513
|
-
|
|
247514
|
-
|
|
247515
|
-
|
|
247516
|
-
|
|
247517
|
-
|
|
247518
|
-
|
|
247519
|
-
|
|
247520
|
-
|
|
247521
|
-
|
|
247522
|
-
|
|
247523
|
-
|
|
247524
|
-
|
|
247525
|
-
|
|
247526
|
-
|
|
247527
|
-
|
|
247528
|
-
|
|
247529
|
-
|
|
247530
|
-
|
|
247531
|
-
|
|
247532
|
-
|
|
247533
|
-
|
|
247534
|
-
|
|
247535
|
-
|
|
247536
|
-
|
|
247537
|
-
|
|
247538
|
-
|
|
247539
|
-
|
|
247540
|
-
|
|
247541
|
-
|
|
247542
|
-
|
|
247509
|
+
// src/core/site/deploy-app.ts
|
|
247510
|
+
import { resolve as resolve5 } from "node:path";
|
|
247511
|
+
|
|
247512
|
+
// src/core/deployments/api.ts
|
|
247513
|
+
import { readFile as readFile2 } from "node:fs/promises";
|
|
247514
|
+
|
|
247515
|
+
// src/core/deployments/schema.ts
|
|
247516
|
+
var GIT_HASH_PATTERN = /^[a-fA-F0-9]{7,64}$/;
|
|
247517
|
+
var CreateDeploymentResponseSchema = exports_external.object({
|
|
247518
|
+
deployment_id: exports_external.string(),
|
|
247519
|
+
asset_uploads: exports_external.discriminatedUnion("type", [
|
|
247520
|
+
exports_external.object({
|
|
247521
|
+
type: exports_external.literal("cf"),
|
|
247522
|
+
url: exports_external.string(),
|
|
247523
|
+
jwt: exports_external.string(),
|
|
247524
|
+
buckets: exports_external.array(exports_external.array(exports_external.string()))
|
|
247525
|
+
}),
|
|
247526
|
+
exports_external.object({
|
|
247527
|
+
type: exports_external.literal("s3"),
|
|
247528
|
+
uploads: exports_external.array(exports_external.object({
|
|
247529
|
+
path: exports_external.string(),
|
|
247530
|
+
content_type: exports_external.string(),
|
|
247531
|
+
content_length: exports_external.number(),
|
|
247532
|
+
url: exports_external.string()
|
|
247533
|
+
}))
|
|
247534
|
+
})
|
|
247535
|
+
]).nullable().optional()
|
|
247536
|
+
}).transform((data) => ({
|
|
247537
|
+
deploymentId: data.deployment_id,
|
|
247538
|
+
assetUploads: data.asset_uploads == null ? null : data.asset_uploads.type === "cf" ? data.asset_uploads : {
|
|
247539
|
+
type: "s3",
|
|
247540
|
+
uploads: data.asset_uploads.uploads.map((upload) => ({
|
|
247541
|
+
path: upload.path,
|
|
247542
|
+
contentType: upload.content_type,
|
|
247543
|
+
contentLength: upload.content_length,
|
|
247544
|
+
url: upload.url
|
|
247545
|
+
}))
|
|
247543
247546
|
}
|
|
247544
|
-
|
|
247545
|
-
|
|
247546
|
-
|
|
247547
|
-
|
|
247548
|
-
|
|
247549
|
-
|
|
247550
|
-
|
|
247551
|
-
|
|
247552
|
-
|
|
247553
|
-
|
|
247554
|
-
|
|
247555
|
-
|
|
247556
|
-
|
|
247557
|
-
|
|
247547
|
+
}));
|
|
247548
|
+
var AssetUploadResponseSchema = exports_external.looseObject({
|
|
247549
|
+
result: exports_external.looseObject({ jwt: exports_external.string().nullable().optional() }).nullable().optional()
|
|
247550
|
+
});
|
|
247551
|
+
var FinalizeDeploymentResponseSchema = exports_external.object({
|
|
247552
|
+
deployment_id: exports_external.string()
|
|
247553
|
+
}).transform((data) => ({
|
|
247554
|
+
deploymentId: data.deployment_id
|
|
247555
|
+
}));
|
|
247556
|
+
|
|
247557
|
+
// src/core/deployments/api.ts
|
|
247558
|
+
var MODULE_CONTENT_TYPES = {
|
|
247559
|
+
esm: "application/javascript+module",
|
|
247560
|
+
sourcemap: "application/source-map",
|
|
247561
|
+
wasm: "application/wasm",
|
|
247562
|
+
text: "text/plain",
|
|
247563
|
+
data: "application/octet-stream"
|
|
247564
|
+
};
|
|
247565
|
+
async function createDeployment(request) {
|
|
247566
|
+
const appClient = getAppClient();
|
|
247567
|
+
let response;
|
|
247568
|
+
try {
|
|
247569
|
+
response = await appClient.post("deployments", {
|
|
247570
|
+
json: request,
|
|
247571
|
+
timeout: 120000
|
|
247572
|
+
});
|
|
247573
|
+
} catch (error48) {
|
|
247574
|
+
throw await ApiError.fromHttpError(error48, "creating deployment");
|
|
247558
247575
|
}
|
|
247559
|
-
|
|
247560
|
-
|
|
247561
|
-
|
|
247562
|
-
var retriedRequests = new WeakSet;
|
|
247563
|
-
async function captureRequestBody(request, options) {
|
|
247564
|
-
if (request.body == null) {
|
|
247565
|
-
return;
|
|
247576
|
+
const result = CreateDeploymentResponseSchema.safeParse(await response.json());
|
|
247577
|
+
if (!result.success) {
|
|
247578
|
+
throw new SchemaValidationError("Invalid response from server", result.error);
|
|
247566
247579
|
}
|
|
247567
|
-
|
|
247568
|
-
const cloned = request.clone();
|
|
247569
|
-
const text = await cloned.text();
|
|
247570
|
-
options.context.__requestBody = text;
|
|
247571
|
-
} catch {}
|
|
247580
|
+
return result.data;
|
|
247572
247581
|
}
|
|
247573
|
-
async function
|
|
247574
|
-
|
|
247575
|
-
|
|
247576
|
-
|
|
247577
|
-
|
|
247578
|
-
|
|
247582
|
+
async function uploadAssetBucket(target, formData) {
|
|
247583
|
+
const response = await distribution_default.post(target.url, {
|
|
247584
|
+
searchParams: { base64: "true" },
|
|
247585
|
+
headers: { Authorization: `Bearer ${target.jwt}` },
|
|
247586
|
+
body: formData,
|
|
247587
|
+
timeout: 120000,
|
|
247588
|
+
retry: 0
|
|
247589
|
+
});
|
|
247590
|
+
const parsed = AssetUploadResponseSchema.safeParse(await response.json());
|
|
247591
|
+
const jwt3 = parsed.success ? parsed.data.result?.jwt : null;
|
|
247592
|
+
return jwt3 || null;
|
|
247593
|
+
}
|
|
247594
|
+
async function finalizeDeployment(deploymentId, completionJwt, modules) {
|
|
247595
|
+
const formData = new FormData;
|
|
247596
|
+
formData.append("payload", JSON.stringify({ completion_jwt: completionJwt }));
|
|
247597
|
+
for (const module of modules) {
|
|
247598
|
+
const content = await readFile2(module.absolutePath);
|
|
247599
|
+
formData.append(module.name, new File([new Uint8Array(content)], module.name, {
|
|
247600
|
+
type: MODULE_CONTENT_TYPES[module.type]
|
|
247601
|
+
}));
|
|
247579
247602
|
}
|
|
247580
|
-
|
|
247581
|
-
|
|
247603
|
+
return await postFinalize(deploymentId, formData);
|
|
247604
|
+
}
|
|
247605
|
+
async function finalizeStaticDeployment(deploymentId, indexHtml) {
|
|
247606
|
+
const formData = new FormData;
|
|
247607
|
+
formData.append("index.html", new File([indexHtml], "index.html", { type: "text/html" }));
|
|
247608
|
+
return await postFinalize(deploymentId, formData);
|
|
247609
|
+
}
|
|
247610
|
+
async function postFinalize(deploymentId, formData) {
|
|
247611
|
+
const appClient = getAppClient();
|
|
247612
|
+
let response;
|
|
247613
|
+
try {
|
|
247614
|
+
response = await appClient.post(`deployments/${encodeURIComponent(deploymentId)}/finalize`, { body: formData, timeout: 180000 });
|
|
247615
|
+
} catch (error48) {
|
|
247616
|
+
throw await ApiError.fromHttpError(error48, "finalizing deployment");
|
|
247582
247617
|
}
|
|
247583
|
-
const
|
|
247584
|
-
if (!
|
|
247585
|
-
|
|
247618
|
+
const result = FinalizeDeploymentResponseSchema.safeParse(await response.json());
|
|
247619
|
+
if (!result.success) {
|
|
247620
|
+
throw new SchemaValidationError("Invalid response from server", result.error);
|
|
247586
247621
|
}
|
|
247587
|
-
|
|
247588
|
-
const requestId = request.headers.get("X-Request-ID");
|
|
247589
|
-
return distribution_default(request.clone(), {
|
|
247590
|
-
headers: {
|
|
247591
|
-
...requestId && { "X-Request-ID": requestId },
|
|
247592
|
-
Authorization: `Bearer ${newAccessToken}`
|
|
247593
|
-
}
|
|
247594
|
-
});
|
|
247622
|
+
return result.data;
|
|
247595
247623
|
}
|
|
247596
|
-
|
|
247597
|
-
|
|
247598
|
-
|
|
247599
|
-
|
|
247600
|
-
|
|
247601
|
-
|
|
247602
|
-
|
|
247603
|
-
|
|
247604
|
-
|
|
247605
|
-
|
|
247606
|
-
|
|
247607
|
-
|
|
247608
|
-
|
|
247609
|
-
|
|
247610
|
-
|
|
247611
|
-
|
|
247612
|
-
|
|
247613
|
-
|
|
247614
|
-
|
|
247615
|
-
|
|
247616
|
-
|
|
247617
|
-
|
|
247618
|
-
|
|
247619
|
-
|
|
247620
|
-
|
|
247621
|
-
|
|
247622
|
-
|
|
247623
|
-
|
|
247624
|
+
// src/core/deployments/manifest.ts
|
|
247625
|
+
import { createHash } from "node:crypto";
|
|
247626
|
+
import { readdir as readdir2, readFile as readFile3, stat } from "node:fs/promises";
|
|
247627
|
+
import { extname, join as join15 } from "node:path";
|
|
247628
|
+
var MAX_ASSET_SIZE_BYTES = 25 * 1024 * 1024;
|
|
247629
|
+
var MAX_ASSET_COUNT = 1e5;
|
|
247630
|
+
var ASSETS_IGNORE_FILE = ".assetsignore";
|
|
247631
|
+
var ALWAYS_SKIPPED_FILES = new Set([
|
|
247632
|
+
ASSETS_IGNORE_FILE,
|
|
247633
|
+
"wrangler.json",
|
|
247634
|
+
".dev.vars"
|
|
247635
|
+
]);
|
|
247636
|
+
var MIME_TYPES = {
|
|
247637
|
+
".html": "text/html",
|
|
247638
|
+
".htm": "text/html",
|
|
247639
|
+
".css": "text/css",
|
|
247640
|
+
".js": "text/javascript",
|
|
247641
|
+
".mjs": "text/javascript",
|
|
247642
|
+
".json": "application/json",
|
|
247643
|
+
".map": "application/json",
|
|
247644
|
+
".txt": "text/plain",
|
|
247645
|
+
".xml": "application/xml",
|
|
247646
|
+
".svg": "image/svg+xml",
|
|
247647
|
+
".png": "image/png",
|
|
247648
|
+
".jpg": "image/jpeg",
|
|
247649
|
+
".jpeg": "image/jpeg",
|
|
247650
|
+
".gif": "image/gif",
|
|
247651
|
+
".webp": "image/webp",
|
|
247652
|
+
".avif": "image/avif",
|
|
247653
|
+
".ico": "image/x-icon",
|
|
247654
|
+
".woff": "font/woff",
|
|
247655
|
+
".woff2": "font/woff2",
|
|
247656
|
+
".ttf": "font/ttf",
|
|
247657
|
+
".otf": "font/otf",
|
|
247658
|
+
".eot": "application/vnd.ms-fontobject",
|
|
247659
|
+
".mp3": "audio/mpeg",
|
|
247660
|
+
".mp4": "video/mp4",
|
|
247661
|
+
".webm": "video/webm",
|
|
247662
|
+
".pdf": "application/pdf",
|
|
247663
|
+
".wasm": "application/wasm",
|
|
247664
|
+
".webmanifest": "application/manifest+json"
|
|
247665
|
+
};
|
|
247666
|
+
function getAssetContentType(filePath) {
|
|
247667
|
+
return MIME_TYPES[extname(filePath).toLowerCase()] ?? "application/octet-stream";
|
|
247668
|
+
}
|
|
247669
|
+
function hashAsset(appId, content) {
|
|
247670
|
+
return createHash("sha256").update(Buffer.from(appId, "utf8")).update(content).digest("hex").slice(0, 32);
|
|
247671
|
+
}
|
|
247672
|
+
function globToRegExp(glob) {
|
|
247673
|
+
let source = "";
|
|
247674
|
+
for (let i = 0;i < glob.length; i++) {
|
|
247675
|
+
const char = glob[i];
|
|
247676
|
+
if (char === "*") {
|
|
247677
|
+
if (glob[i + 1] === "*") {
|
|
247678
|
+
source += ".*";
|
|
247679
|
+
i++;
|
|
247680
|
+
} else {
|
|
247681
|
+
source += "[^/]*";
|
|
247624
247682
|
}
|
|
247625
|
-
|
|
247626
|
-
|
|
247683
|
+
} else if (char === "?") {
|
|
247684
|
+
source += "[^/]";
|
|
247685
|
+
} else {
|
|
247686
|
+
source += char.replace(/[.+^${}()|[\]\\]/g, "\\$&");
|
|
247687
|
+
}
|
|
247627
247688
|
}
|
|
247628
|
-
});
|
|
247629
|
-
function getAppClient() {
|
|
247630
|
-
const { id } = getAppContext();
|
|
247631
|
-
return base44Client.extend({
|
|
247632
|
-
prefixUrl: new URL(`/api/apps/${id}/`, getBase44ApiUrl()).href
|
|
247633
|
-
});
|
|
247689
|
+
return new RegExp(`^${source}$`);
|
|
247634
247690
|
}
|
|
247635
|
-
function
|
|
247636
|
-
|
|
247637
|
-
|
|
247691
|
+
function createIgnoreMatcher(lines) {
|
|
247692
|
+
const rules = lines.map((line) => line.trim()).filter((line) => line.length > 0 && !line.startsWith("#")).map((line) => {
|
|
247693
|
+
const isDirOnly = line.endsWith("/");
|
|
247694
|
+
let pattern = isDirOnly ? line.slice(0, -1) : line;
|
|
247695
|
+
const anchored = pattern.includes("/");
|
|
247696
|
+
pattern = pattern.replace(/^\//, "");
|
|
247697
|
+
return { regex: globToRegExp(pattern), anchored, isDirOnly };
|
|
247638
247698
|
});
|
|
247639
|
-
|
|
247640
|
-
|
|
247641
|
-
|
|
247642
|
-
|
|
247643
|
-
|
|
247644
|
-
|
|
247645
|
-
|
|
247646
|
-
|
|
247647
|
-
|
|
247648
|
-
beforeRequest: [
|
|
247649
|
-
(request) => {
|
|
247650
|
-
request.headers.set("X-Request-ID", randomUUID3());
|
|
247699
|
+
return (relativePath, isDirectory2) => {
|
|
247700
|
+
const segments = relativePath.split("/");
|
|
247701
|
+
return rules.some((rule) => {
|
|
247702
|
+
if (rule.anchored) {
|
|
247703
|
+
if (rule.isDirOnly ? isDirectory2 : true) {
|
|
247704
|
+
if (rule.regex.test(relativePath))
|
|
247705
|
+
return true;
|
|
247706
|
+
}
|
|
247707
|
+
return false;
|
|
247651
247708
|
}
|
|
247652
|
-
|
|
247709
|
+
const basename4 = segments[segments.length - 1];
|
|
247710
|
+
if (rule.isDirOnly && !isDirectory2)
|
|
247711
|
+
return false;
|
|
247712
|
+
return rule.regex.test(basename4);
|
|
247713
|
+
});
|
|
247714
|
+
};
|
|
247715
|
+
}
|
|
247716
|
+
async function loadIgnoreMatcher(assetsDir) {
|
|
247717
|
+
const ignorePath = join15(assetsDir, ASSETS_IGNORE_FILE);
|
|
247718
|
+
if (!await pathExists(ignorePath)) {
|
|
247719
|
+
return () => false;
|
|
247653
247720
|
}
|
|
247654
|
-
|
|
247655
|
-
|
|
247656
|
-
|
|
247657
|
-
|
|
247658
|
-
|
|
247659
|
-
|
|
247660
|
-
|
|
247661
|
-
|
|
247662
|
-
|
|
247663
|
-
|
|
247664
|
-
if (!response.ok) {
|
|
247665
|
-
throw new ApiError(`Failed to generate device code: ${response.status} ${response.statusText}`, { statusCode: response.status });
|
|
247721
|
+
const content = await readTextFile(ignorePath);
|
|
247722
|
+
return createIgnoreMatcher(content.split(/\r?\n/));
|
|
247723
|
+
}
|
|
247724
|
+
async function buildAssetManifest(assetsDir, appId) {
|
|
247725
|
+
const isIgnored = await loadIgnoreMatcher(assetsDir);
|
|
247726
|
+
const manifest = {};
|
|
247727
|
+
const filesByHash = new Map;
|
|
247728
|
+
const relativeFilePaths = await collectFilePaths(assetsDir, "", isIgnored);
|
|
247729
|
+
if (relativeFilePaths.length > MAX_ASSET_COUNT) {
|
|
247730
|
+
throw new InvalidInputError(`Too many static assets: found ${relativeFilePaths.length}, the limit is ${MAX_ASSET_COUNT} files.`);
|
|
247666
247731
|
}
|
|
247667
|
-
const
|
|
247668
|
-
|
|
247669
|
-
|
|
247732
|
+
for (const relativePath of relativeFilePaths.sort()) {
|
|
247733
|
+
const absolutePath = join15(assetsDir, ...relativePath.split("/"));
|
|
247734
|
+
const { size } = await stat(absolutePath);
|
|
247735
|
+
if (size > MAX_ASSET_SIZE_BYTES) {
|
|
247736
|
+
throw new InvalidInputError(`Static asset "${relativePath}" is ${size} bytes, which exceeds the 25 MiB per-file limit.`);
|
|
247737
|
+
}
|
|
247738
|
+
const content = await readFile3(absolutePath);
|
|
247739
|
+
const hash2 = hashAsset(appId, content);
|
|
247740
|
+
manifest[`/${relativePath}`] = { hash: hash2, size };
|
|
247741
|
+
if (!filesByHash.has(hash2)) {
|
|
247742
|
+
filesByHash.set(hash2, {
|
|
247743
|
+
absolutePath,
|
|
247744
|
+
hash: hash2,
|
|
247745
|
+
size,
|
|
247746
|
+
contentType: getAssetContentType(absolutePath)
|
|
247747
|
+
});
|
|
247748
|
+
}
|
|
247670
247749
|
}
|
|
247671
|
-
return
|
|
247750
|
+
return { manifest, filesByHash };
|
|
247672
247751
|
}
|
|
247673
|
-
async function
|
|
247674
|
-
const
|
|
247675
|
-
|
|
247676
|
-
|
|
247677
|
-
|
|
247678
|
-
|
|
247679
|
-
|
|
247680
|
-
|
|
247681
|
-
|
|
247682
|
-
|
|
247683
|
-
|
|
247752
|
+
async function collectFilePaths(dir, relativeDir, isIgnored) {
|
|
247753
|
+
const entries = await readdir2(dir, { withFileTypes: true });
|
|
247754
|
+
const results = [];
|
|
247755
|
+
for (const entry of entries) {
|
|
247756
|
+
const relativePath = relativeDir ? `${relativeDir}/${entry.name}` : entry.name;
|
|
247757
|
+
if (entry.isDirectory()) {
|
|
247758
|
+
if (isIgnored(relativePath, true))
|
|
247759
|
+
continue;
|
|
247760
|
+
results.push(...await collectFilePaths(join15(dir, entry.name), relativePath, isIgnored));
|
|
247761
|
+
continue;
|
|
247762
|
+
}
|
|
247763
|
+
if (!entry.isFile())
|
|
247764
|
+
continue;
|
|
247765
|
+
if (ALWAYS_SKIPPED_FILES.has(entry.name))
|
|
247766
|
+
continue;
|
|
247767
|
+
if (isIgnored(relativePath, false))
|
|
247768
|
+
continue;
|
|
247769
|
+
results.push(relativePath);
|
|
247770
|
+
}
|
|
247771
|
+
return results;
|
|
247772
|
+
}
|
|
247773
|
+
|
|
247774
|
+
// src/core/deployments/modules.ts
|
|
247775
|
+
import { stat as stat2 } from "node:fs/promises";
|
|
247776
|
+
import { relative as relative3, resolve as resolve3, sep } from "node:path";
|
|
247777
|
+
var MAX_TOTAL_MODULE_BYTES = 40 * 1024 * 1024;
|
|
247778
|
+
var MODULE_IGNORE = ["wrangler.json", ".dev.vars"];
|
|
247779
|
+
var RULE_TYPE_TO_MODULE_TYPE = {
|
|
247780
|
+
ESModule: "esm",
|
|
247781
|
+
CompiledWasm: "wasm",
|
|
247782
|
+
Text: "text",
|
|
247783
|
+
Data: "data"
|
|
247784
|
+
};
|
|
247785
|
+
function toPosix(path11) {
|
|
247786
|
+
return path11.split(sep).join("/");
|
|
247787
|
+
}
|
|
247788
|
+
async function collectModules(config9) {
|
|
247789
|
+
const entryPath = resolve3(config9.configDir, config9.main);
|
|
247790
|
+
if (!await pathExists(entryPath)) {
|
|
247791
|
+
throw new InvalidInputError(`Worker entry module does not exist: ${entryPath} (from "main" in ${config9.configPath})`, {
|
|
247792
|
+
hints: [{ message: "Rebuild the project to regenerate the artifact" }]
|
|
247793
|
+
});
|
|
247794
|
+
}
|
|
247795
|
+
const modulesByName = new Map;
|
|
247796
|
+
const entryName = toPosix(relative3(config9.configDir, entryPath));
|
|
247797
|
+
modulesByName.set(entryName, {
|
|
247798
|
+
name: entryName,
|
|
247799
|
+
absolutePath: entryPath,
|
|
247800
|
+
size: 0,
|
|
247801
|
+
type: "esm"
|
|
247684
247802
|
});
|
|
247685
|
-
const
|
|
247686
|
-
if (
|
|
247687
|
-
|
|
247688
|
-
|
|
247689
|
-
|
|
247803
|
+
const ignore = [...MODULE_IGNORE];
|
|
247804
|
+
if (config9.assetsDirectory?.startsWith(config9.configDir + sep)) {
|
|
247805
|
+
ignore.push(`${toPosix(relative3(config9.configDir, config9.assetsDirectory))}/**`);
|
|
247806
|
+
}
|
|
247807
|
+
for (const rule of config9.rules) {
|
|
247808
|
+
const type = RULE_TYPE_TO_MODULE_TYPE[rule.type];
|
|
247809
|
+
if (!type) {
|
|
247810
|
+
throw new InvalidInputError(`Unsupported module rule type "${rule.type}" in ${config9.configPath}. Supported: ${Object.keys(RULE_TYPE_TO_MODULE_TYPE).join(", ")}.`);
|
|
247690
247811
|
}
|
|
247691
|
-
const
|
|
247692
|
-
|
|
247693
|
-
|
|
247812
|
+
const matches = await globby(rule.globs, {
|
|
247813
|
+
cwd: config9.configDir,
|
|
247814
|
+
onlyFiles: true,
|
|
247815
|
+
dot: true,
|
|
247816
|
+
ignore
|
|
247817
|
+
});
|
|
247818
|
+
for (const match of matches.sort()) {
|
|
247819
|
+
if (!modulesByName.has(match)) {
|
|
247820
|
+
modulesByName.set(match, {
|
|
247821
|
+
name: match,
|
|
247822
|
+
absolutePath: resolve3(config9.configDir, match),
|
|
247823
|
+
size: 0,
|
|
247824
|
+
type
|
|
247825
|
+
});
|
|
247826
|
+
}
|
|
247694
247827
|
}
|
|
247695
|
-
|
|
247696
|
-
|
|
247828
|
+
}
|
|
247829
|
+
if (config9.uploadSourceMaps) {
|
|
247830
|
+
const maps = await globby("**/*.map", {
|
|
247831
|
+
cwd: config9.configDir,
|
|
247832
|
+
onlyFiles: true,
|
|
247833
|
+
dot: true,
|
|
247834
|
+
ignore
|
|
247697
247835
|
});
|
|
247836
|
+
for (const map2 of maps.sort()) {
|
|
247837
|
+
addSourcemap(modulesByName, config9.configDir, map2);
|
|
247838
|
+
}
|
|
247839
|
+
} else {
|
|
247840
|
+
for (const name2 of [...modulesByName.keys()]) {
|
|
247841
|
+
const mapName = `${name2}.map`;
|
|
247842
|
+
if (await pathExists(resolve3(config9.configDir, mapName))) {
|
|
247843
|
+
addSourcemap(modulesByName, config9.configDir, mapName);
|
|
247844
|
+
}
|
|
247845
|
+
}
|
|
247698
247846
|
}
|
|
247699
|
-
const
|
|
247700
|
-
|
|
247701
|
-
|
|
247847
|
+
const modules = [...modulesByName.values()];
|
|
247848
|
+
let totalBytes = 0;
|
|
247849
|
+
for (const module of modules) {
|
|
247850
|
+
module.size = (await stat2(module.absolutePath)).size;
|
|
247851
|
+
totalBytes += module.size;
|
|
247702
247852
|
}
|
|
247703
|
-
|
|
247853
|
+
if (totalBytes > MAX_TOTAL_MODULE_BYTES) {
|
|
247854
|
+
throw new InvalidInputError(`Worker modules total ${totalBytes} bytes, which exceeds the 40 MB limit for Base44 full-stack deploys.`);
|
|
247855
|
+
}
|
|
247856
|
+
return modules;
|
|
247704
247857
|
}
|
|
247705
|
-
|
|
247706
|
-
|
|
247707
|
-
|
|
247708
|
-
|
|
247709
|
-
|
|
247710
|
-
|
|
247711
|
-
|
|
247712
|
-
|
|
247713
|
-
"Content-Type": "application/x-www-form-urlencoded"
|
|
247714
|
-
},
|
|
247715
|
-
throwHttpErrors: false
|
|
247858
|
+
function addSourcemap(modulesByName, configDir, name2) {
|
|
247859
|
+
if (modulesByName.has(name2))
|
|
247860
|
+
return;
|
|
247861
|
+
modulesByName.set(name2, {
|
|
247862
|
+
name: name2,
|
|
247863
|
+
absolutePath: resolve3(configDir, name2),
|
|
247864
|
+
size: 0,
|
|
247865
|
+
type: "sourcemap"
|
|
247716
247866
|
});
|
|
247717
|
-
|
|
247718
|
-
|
|
247719
|
-
|
|
247720
|
-
|
|
247721
|
-
|
|
247722
|
-
|
|
247723
|
-
|
|
247867
|
+
}
|
|
247868
|
+
|
|
247869
|
+
// src/core/deployments/upload.ts
|
|
247870
|
+
import { readFile as readFile4 } from "node:fs/promises";
|
|
247871
|
+
var UPLOAD_CONCURRENCY = 3;
|
|
247872
|
+
var MAX_ATTEMPTS_PER_UPLOAD = 3;
|
|
247873
|
+
var RETRY_BASE_DELAY_MS = 500;
|
|
247874
|
+
var MAX_RATE_LIMIT_WAITS = 10;
|
|
247875
|
+
var RATE_LIMIT_DELAY_MS = 15000;
|
|
247876
|
+
async function uploadAssetBuckets(target, filesByHash, onProgress) {
|
|
247877
|
+
const { buckets } = target;
|
|
247878
|
+
const totalFiles = buckets.reduce((sum, bucket) => sum + bucket.length, 0);
|
|
247879
|
+
let uploadedFiles = 0;
|
|
247880
|
+
let completionJwt = null;
|
|
247881
|
+
let nextBucket = 0;
|
|
247882
|
+
const worker = async () => {
|
|
247883
|
+
while (nextBucket < buckets.length) {
|
|
247884
|
+
const bucket = buckets[nextBucket++];
|
|
247885
|
+
const jwt3 = await uploadBucketWithRetry(target, bucket, filesByHash);
|
|
247886
|
+
if (jwt3) {
|
|
247887
|
+
completionJwt = jwt3;
|
|
247888
|
+
}
|
|
247889
|
+
uploadedFiles += bucket.length;
|
|
247890
|
+
onProgress?.({ uploadedFiles, totalFiles });
|
|
247724
247891
|
}
|
|
247725
|
-
|
|
247726
|
-
|
|
247727
|
-
|
|
247728
|
-
|
|
247729
|
-
}
|
|
247730
|
-
const result = TokenResponseSchema.safeParse(json2);
|
|
247731
|
-
if (!result.success) {
|
|
247732
|
-
throw new SchemaValidationError("Invalid token response from server", result.error);
|
|
247892
|
+
};
|
|
247893
|
+
await Promise.all(Array.from({ length: Math.min(UPLOAD_CONCURRENCY, buckets.length) }, worker));
|
|
247894
|
+
if (!completionJwt) {
|
|
247895
|
+
throw new ApiError("Asset upload finished but the server did not return a completion token.");
|
|
247733
247896
|
}
|
|
247734
|
-
return
|
|
247897
|
+
return completionJwt;
|
|
247735
247898
|
}
|
|
247736
|
-
async function
|
|
247737
|
-
|
|
247738
|
-
|
|
247739
|
-
|
|
247740
|
-
|
|
247741
|
-
|
|
247742
|
-
|
|
247743
|
-
}
|
|
247899
|
+
async function uploadBucketWithRetry(target, bucket, filesByHash) {
|
|
247900
|
+
let lastError;
|
|
247901
|
+
let rateLimitWaits = 0;
|
|
247902
|
+
const formData = await buildBucketForm(bucket, filesByHash);
|
|
247903
|
+
for (let attempt = 0;attempt < MAX_ATTEMPTS_PER_UPLOAD; attempt++) {
|
|
247904
|
+
if (attempt > 0) {
|
|
247905
|
+
await sleep3(RETRY_BASE_DELAY_MS * 2 ** (attempt - 1));
|
|
247906
|
+
}
|
|
247907
|
+
try {
|
|
247908
|
+
return await uploadAssetBucket(target, formData);
|
|
247909
|
+
} catch (error48) {
|
|
247910
|
+
if (error48 instanceof HTTPError && error48.response.status === 429 && rateLimitWaits < MAX_RATE_LIMIT_WAITS) {
|
|
247911
|
+
rateLimitWaits++;
|
|
247912
|
+
attempt--;
|
|
247913
|
+
await sleep3(RATE_LIMIT_DELAY_MS);
|
|
247914
|
+
continue;
|
|
247915
|
+
}
|
|
247916
|
+
lastError = error48;
|
|
247917
|
+
}
|
|
247744
247918
|
}
|
|
247745
|
-
|
|
247746
|
-
|
|
247747
|
-
throw new SchemaValidationError("Invalid UserInfo response from server", result.error);
|
|
247919
|
+
if (lastError instanceof HTTPError && (lastError.response.status === 401 || lastError.response.status === 403)) {
|
|
247920
|
+
throw new ApiError("This deploy's upload session has expired — rerun deploy. Already-uploaded assets are skipped on the next attempt.", { statusCode: lastError.response.status, cause: lastError });
|
|
247748
247921
|
}
|
|
247749
|
-
|
|
247922
|
+
throw await ApiError.fromHttpError(lastError, "uploading assets to Cloudflare");
|
|
247750
247923
|
}
|
|
247751
|
-
|
|
247752
|
-
|
|
247753
|
-
|
|
247754
|
-
|
|
247755
|
-
|
|
247756
|
-
|
|
247757
|
-
|
|
247758
|
-
|
|
247759
|
-
|
|
247760
|
-
|
|
247761
|
-
return
|
|
247924
|
+
async function buildBucketForm(bucket, filesByHash) {
|
|
247925
|
+
const formData = new FormData;
|
|
247926
|
+
for (const hash2 of bucket) {
|
|
247927
|
+
const file2 = filesByHash.get(hash2);
|
|
247928
|
+
if (!file2) {
|
|
247929
|
+
throw new InternalError(`Server requested upload of unknown asset hash: ${hash2}`);
|
|
247930
|
+
}
|
|
247931
|
+
const content = await readFile4(file2.absolutePath);
|
|
247932
|
+
formData.append(hash2, new File([content.toString("base64")], hash2, { type: file2.contentType }));
|
|
247933
|
+
}
|
|
247934
|
+
return formData;
|
|
247762
247935
|
}
|
|
247763
|
-
async function
|
|
247764
|
-
let
|
|
247765
|
-
|
|
247766
|
-
|
|
247767
|
-
|
|
247768
|
-
|
|
247769
|
-
|
|
247770
|
-
|
|
247771
|
-
|
|
247772
|
-
|
|
247773
|
-
|
|
247774
|
-
|
|
247775
|
-
|
|
247776
|
-
|
|
247936
|
+
async function uploadPresignedAssets(uploads, assets, onProgress) {
|
|
247937
|
+
let uploadedFiles = 0;
|
|
247938
|
+
let nextUpload = 0;
|
|
247939
|
+
const worker = async () => {
|
|
247940
|
+
while (nextUpload < uploads.length) {
|
|
247941
|
+
const upload = uploads[nextUpload++];
|
|
247942
|
+
await uploadPresignedAssetWithRetry(upload, assets);
|
|
247943
|
+
uploadedFiles++;
|
|
247944
|
+
onProgress?.({ uploadedFiles, totalFiles: uploads.length });
|
|
247945
|
+
}
|
|
247946
|
+
};
|
|
247947
|
+
await Promise.all(Array.from({ length: Math.min(UPLOAD_CONCURRENCY, uploads.length) }, worker));
|
|
247948
|
+
}
|
|
247949
|
+
async function uploadPresignedAssetWithRetry(upload, assets) {
|
|
247950
|
+
const entry = assets.manifest[upload.path];
|
|
247951
|
+
const file2 = entry && assets.filesByHash.get(entry.hash);
|
|
247952
|
+
if (!file2) {
|
|
247953
|
+
throw new InternalError(`Server requested upload of unknown asset path: ${upload.path}`);
|
|
247954
|
+
}
|
|
247955
|
+
const content = await readFile4(file2.absolutePath);
|
|
247956
|
+
let lastError;
|
|
247957
|
+
for (let attempt = 0;attempt < MAX_ATTEMPTS_PER_UPLOAD; attempt++) {
|
|
247958
|
+
if (attempt > 0) {
|
|
247959
|
+
await sleep3(RETRY_BASE_DELAY_MS * 2 ** (attempt - 1));
|
|
247960
|
+
}
|
|
247961
|
+
try {
|
|
247962
|
+
await distribution_default.put(upload.url, {
|
|
247963
|
+
body: new Uint8Array(content),
|
|
247964
|
+
headers: { "Content-Type": upload.contentType },
|
|
247965
|
+
timeout: 120000,
|
|
247966
|
+
retry: 0
|
|
247777
247967
|
});
|
|
247778
|
-
|
|
247779
|
-
|
|
247780
|
-
|
|
247781
|
-
});
|
|
247782
|
-
} catch (error48) {
|
|
247783
|
-
if (error48 instanceof Error && error48.message.includes("timed out")) {
|
|
247784
|
-
throw new AuthExpiredError("Authentication timed out. Please try again.");
|
|
247968
|
+
return;
|
|
247969
|
+
} catch (error48) {
|
|
247970
|
+
lastError = error48;
|
|
247785
247971
|
}
|
|
247786
|
-
throw error48;
|
|
247787
247972
|
}
|
|
247788
|
-
|
|
247789
|
-
|
|
247973
|
+
throw await ApiError.fromHttpError(lastError, "uploading static assets");
|
|
247974
|
+
}
|
|
247975
|
+
function sleep3(ms) {
|
|
247976
|
+
return new Promise((resolve4) => setTimeout(resolve4, ms));
|
|
247977
|
+
}
|
|
247978
|
+
|
|
247979
|
+
// src/core/deployments/wrangler-config.ts
|
|
247980
|
+
import { dirname as dirname10, join as join16, resolve as resolve4 } from "node:path";
|
|
247981
|
+
var WRANGLER_REDIRECT_PATH = join16(".wrangler", "deploy", "config.json");
|
|
247982
|
+
var RedirectConfigSchema = exports_external.looseObject({
|
|
247983
|
+
configPath: exports_external.string().min(1)
|
|
247984
|
+
});
|
|
247985
|
+
var WranglerConfigSchema = exports_external.looseObject({
|
|
247986
|
+
main: exports_external.string().min(1, "wrangler config is missing a 'main' entry module"),
|
|
247987
|
+
no_bundle: exports_external.boolean().optional(),
|
|
247988
|
+
rules: exports_external.array(exports_external.looseObject({ type: exports_external.string(), globs: exports_external.array(exports_external.string()) })).optional(),
|
|
247989
|
+
assets: exports_external.looseObject({
|
|
247990
|
+
directory: exports_external.string().optional(),
|
|
247991
|
+
html_handling: exports_external.string().optional(),
|
|
247992
|
+
not_found_handling: exports_external.string().optional(),
|
|
247993
|
+
run_worker_first: exports_external.union([exports_external.boolean(), exports_external.array(exports_external.string())]).optional(),
|
|
247994
|
+
headers: exports_external.string().optional(),
|
|
247995
|
+
redirects: exports_external.string().optional()
|
|
247996
|
+
}).optional(),
|
|
247997
|
+
compatibility_date: exports_external.string().optional(),
|
|
247998
|
+
compatibility_flags: exports_external.array(exports_external.string()).optional(),
|
|
247999
|
+
vars: exports_external.record(exports_external.string(), exports_external.unknown()).optional(),
|
|
248000
|
+
upload_source_maps: exports_external.boolean().optional()
|
|
248001
|
+
});
|
|
248002
|
+
async function detectFullStackArtifact(projectRoot) {
|
|
248003
|
+
const redirectPath = join16(projectRoot, WRANGLER_REDIRECT_PATH);
|
|
248004
|
+
return await pathExists(redirectPath) ? redirectPath : null;
|
|
248005
|
+
}
|
|
248006
|
+
async function resolveWranglerConfig(projectRoot) {
|
|
248007
|
+
const redirectPath = await detectFullStackArtifact(projectRoot);
|
|
248008
|
+
if (!redirectPath) {
|
|
248009
|
+
throw new InvalidInputError("No full-stack build artifact found. Expected a .wrangler/deploy/config.json redirect file.", {
|
|
248010
|
+
hints: [{ message: "Run your framework's build command first" }]
|
|
248011
|
+
});
|
|
247790
248012
|
}
|
|
247791
|
-
|
|
248013
|
+
const configPath = await resolveRedirectedConfigPath(redirectPath);
|
|
248014
|
+
const parsed = await readJsonFile(configPath);
|
|
248015
|
+
const result = WranglerConfigSchema.safeParse(parsed);
|
|
248016
|
+
if (!result.success) {
|
|
248017
|
+
throw new ConfigInvalidError(`Invalid wrangler config: ${exports_external.prettifyError(result.error)}`, configPath);
|
|
248018
|
+
}
|
|
248019
|
+
const config9 = result.data;
|
|
248020
|
+
if (config9.no_bundle !== true) {
|
|
248021
|
+
throw new InvalidInputError("This framework's output requires bundling; not yet supported. Base44 full-stack deploys only support pre-bundled Workers output (no_bundle: true).");
|
|
248022
|
+
}
|
|
248023
|
+
const configDir = dirname10(configPath);
|
|
248024
|
+
const assetsDirectory = config9.assets?.directory ? resolve4(configDir, config9.assets.directory) : null;
|
|
248025
|
+
return {
|
|
248026
|
+
configPath,
|
|
248027
|
+
configDir,
|
|
248028
|
+
main: config9.main,
|
|
248029
|
+
assetsDirectory,
|
|
248030
|
+
assetsConfig: config9.assets ? toResolvedAssetsConfig(config9.assets) : null,
|
|
248031
|
+
compatibilityDate: config9.compatibility_date ?? null,
|
|
248032
|
+
compatibilityFlags: config9.compatibility_flags ?? [],
|
|
248033
|
+
vars: config9.vars ?? {},
|
|
248034
|
+
rules: (config9.rules ?? []).map((rule) => ({
|
|
248035
|
+
type: rule.type,
|
|
248036
|
+
globs: rule.globs
|
|
248037
|
+
})),
|
|
248038
|
+
uploadSourceMaps: config9.upload_source_maps ?? false
|
|
248039
|
+
};
|
|
247792
248040
|
}
|
|
247793
|
-
async function
|
|
247794
|
-
const
|
|
247795
|
-
|
|
247796
|
-
|
|
247797
|
-
|
|
247798
|
-
|
|
247799
|
-
|
|
247800
|
-
|
|
247801
|
-
|
|
248041
|
+
async function resolveRedirectedConfigPath(redirectPath) {
|
|
248042
|
+
const parsed = await readJsonFile(redirectPath);
|
|
248043
|
+
const result = RedirectConfigSchema.safeParse(parsed);
|
|
248044
|
+
if (!result.success) {
|
|
248045
|
+
throw new ConfigInvalidError(`Invalid deploy redirect file: ${exports_external.prettifyError(result.error)}`, redirectPath);
|
|
248046
|
+
}
|
|
248047
|
+
const configPath = resolve4(dirname10(redirectPath), result.data.configPath);
|
|
248048
|
+
if (!await pathExists(configPath)) {
|
|
248049
|
+
throw new ConfigInvalidError(`Wrangler config referenced by ${redirectPath} does not exist: ${configPath}`, redirectPath, {
|
|
248050
|
+
hints: [{ message: "Rebuild the project to regenerate the artifact" }]
|
|
248051
|
+
});
|
|
248052
|
+
}
|
|
248053
|
+
return configPath;
|
|
247802
248054
|
}
|
|
247803
|
-
|
|
247804
|
-
log,
|
|
247805
|
-
runTask
|
|
247806
|
-
}) {
|
|
247807
|
-
const deviceCodeResponse = await generateAndDisplayDeviceCode(log, runTask);
|
|
247808
|
-
const token = await waitForAuthentication(deviceCodeResponse.deviceCode, deviceCodeResponse.expiresIn, deviceCodeResponse.interval, runTask);
|
|
247809
|
-
const userInfo = await getUserInfo(token.accessToken);
|
|
247810
|
-
await saveAuthData(token, userInfo);
|
|
248055
|
+
function toResolvedAssetsConfig(assets) {
|
|
247811
248056
|
return {
|
|
247812
|
-
|
|
248057
|
+
htmlHandling: assets.html_handling,
|
|
248058
|
+
notFoundHandling: assets.not_found_handling,
|
|
248059
|
+
runWorkerFirst: assets.run_worker_first,
|
|
248060
|
+
headers: assets.headers,
|
|
248061
|
+
redirects: assets.redirects
|
|
247813
248062
|
};
|
|
247814
248063
|
}
|
|
247815
248064
|
|
|
247816
|
-
// src/
|
|
247817
|
-
async function
|
|
247818
|
-
|
|
247819
|
-
|
|
247820
|
-
|
|
247821
|
-
|
|
247822
|
-
return;
|
|
248065
|
+
// src/core/deployments/deploy.ts
|
|
248066
|
+
async function deployFullStack(options) {
|
|
248067
|
+
const { projectRoot, gitHash, progress } = options;
|
|
248068
|
+
const config9 = await resolveWranglerConfig(projectRoot);
|
|
248069
|
+
if (!config9.compatibilityFlags.includes("nodejs_compat")) {
|
|
248070
|
+
progress?.onWarning?.("The wrangler config has no 'nodejs_compat' compatibility flag; Node.js built-ins will be unavailable at runtime. Enable it in your framework's Cloudflare adapter settings if your server code needs Node APIs.");
|
|
247823
248071
|
}
|
|
247824
|
-
|
|
247825
|
-
|
|
247826
|
-
if (!loggedIn) {
|
|
247827
|
-
ctx.log.info("You need to login first to continue.");
|
|
247828
|
-
await login(ctx);
|
|
248072
|
+
if (config9.vars && Object.keys(config9.vars).length > 0) {
|
|
248073
|
+
progress?.onWarning?.("wrangler 'vars' are not supported and were ignored — a worker's environment comes from the app's secrets (base44 secrets set).");
|
|
247829
248074
|
}
|
|
247830
|
-
|
|
247831
|
-
|
|
247832
|
-
|
|
247833
|
-
|
|
247834
|
-
|
|
247835
|
-
|
|
248075
|
+
const modules = await collectModules(config9);
|
|
248076
|
+
let assets = { manifest: {}, filesByHash: new Map };
|
|
248077
|
+
if (config9.assetsDirectory && await pathExists(config9.assetsDirectory)) {
|
|
248078
|
+
assets = await buildAssetManifest(config9.assetsDirectory, getAppContext().id);
|
|
248079
|
+
}
|
|
248080
|
+
const created = await createDeployment({
|
|
248081
|
+
git_hash: gitHash,
|
|
248082
|
+
config: {
|
|
248083
|
+
main: config9.main,
|
|
248084
|
+
compatibility_date: config9.compatibilityDate,
|
|
248085
|
+
compatibility_flags: config9.compatibilityFlags,
|
|
248086
|
+
assets: buildAssetsConfig(config9.assetsConfig, progress)
|
|
248087
|
+
},
|
|
248088
|
+
asset_manifest: assets.manifest
|
|
248089
|
+
});
|
|
248090
|
+
if (created.assetUploads && created.assetUploads.type !== "cf") {
|
|
248091
|
+
throw new ApiError(`The server answered a full-stack deploy with the "${created.assetUploads.type}" upload target.`);
|
|
248092
|
+
}
|
|
248093
|
+
const totalAssets = Object.keys(assets.manifest).length;
|
|
248094
|
+
const newAssets = created.assetUploads ? new Set(created.assetUploads.buckets.flat()).size : 0;
|
|
248095
|
+
progress?.onAssets?.({ totalAssets, newAssets });
|
|
248096
|
+
const completionJwt = created.assetUploads ? await uploadAssetBuckets(created.assetUploads, assets.filesByHash, progress?.onAssetUpload) : null;
|
|
248097
|
+
progress?.onWorker?.({ moduleCount: modules.length });
|
|
248098
|
+
const finalized = await finalizeDeployment(created.deploymentId, completionJwt, modules);
|
|
248099
|
+
return { deploymentId: finalized.deploymentId, gitHash };
|
|
247836
248100
|
}
|
|
247837
|
-
|
|
247838
|
-
|
|
247839
|
-
|
|
247840
|
-
|
|
248101
|
+
function buildAssetsConfig(assetsConfig, progress) {
|
|
248102
|
+
if (!assetsConfig)
|
|
248103
|
+
return null;
|
|
248104
|
+
if (assetsConfig.headers || assetsConfig.redirects) {
|
|
248105
|
+
progress?.onWarning?.("_headers/_redirects files are not supported yet and were ignored for this deploy.");
|
|
248106
|
+
}
|
|
248107
|
+
let runWorkerFirst;
|
|
248108
|
+
if (Array.isArray(assetsConfig.runWorkerFirst)) {
|
|
248109
|
+
progress?.onWarning?.("'run_worker_first' route patterns are not supported yet and were ignored for this deploy.");
|
|
248110
|
+
} else {
|
|
248111
|
+
runWorkerFirst = assetsConfig.runWorkerFirst;
|
|
248112
|
+
}
|
|
248113
|
+
return {
|
|
248114
|
+
html_handling: assetsConfig.htmlHandling,
|
|
248115
|
+
not_found_handling: assetsConfig.notFoundHandling,
|
|
248116
|
+
run_worker_first: runWorkerFirst
|
|
248117
|
+
};
|
|
247841
248118
|
}
|
|
247842
|
-
|
|
247843
248119
|
// ../../node_modules/is-plain-obj/index.js
|
|
247844
248120
|
function isPlainObject2(value) {
|
|
247845
248121
|
if (typeof value !== "object" || value === null) {
|
|
@@ -247937,13 +248213,13 @@ var getJoinLength = (uint8Arrays) => {
|
|
|
247937
248213
|
var isTemplateString = (templates) => Array.isArray(templates) && Array.isArray(templates.raw);
|
|
247938
248214
|
var parseTemplates = (templates, expressions) => {
|
|
247939
248215
|
let tokens = [];
|
|
247940
|
-
for (const [index,
|
|
248216
|
+
for (const [index, template] of templates.entries()) {
|
|
247941
248217
|
tokens = parseTemplate({
|
|
247942
248218
|
templates,
|
|
247943
248219
|
expressions,
|
|
247944
248220
|
tokens,
|
|
247945
248221
|
index,
|
|
247946
|
-
template
|
|
248222
|
+
template
|
|
247947
248223
|
});
|
|
247948
248224
|
}
|
|
247949
248225
|
if (tokens.length === 0) {
|
|
@@ -247952,11 +248228,11 @@ var parseTemplates = (templates, expressions) => {
|
|
|
247952
248228
|
const [file2, ...commandArguments] = tokens;
|
|
247953
248229
|
return [file2, commandArguments, {}];
|
|
247954
248230
|
};
|
|
247955
|
-
var parseTemplate = ({ templates, expressions, tokens, index, template
|
|
247956
|
-
if (
|
|
248231
|
+
var parseTemplate = ({ templates, expressions, tokens, index, template }) => {
|
|
248232
|
+
if (template === undefined) {
|
|
247957
248233
|
throw new TypeError(`Invalid backslash sequence: ${templates.raw[index]}`);
|
|
247958
248234
|
}
|
|
247959
|
-
const { nextTokens, leadingWhitespaces, trailingWhitespaces } = splitByWhitespaces(
|
|
248235
|
+
const { nextTokens, leadingWhitespaces, trailingWhitespaces } = splitByWhitespaces(template, templates.raw[index]);
|
|
247960
248236
|
const newTokens = concatTokens(tokens, nextTokens, leadingWhitespaces);
|
|
247961
248237
|
if (index === expressions.length) {
|
|
247962
248238
|
return newTokens;
|
|
@@ -247965,18 +248241,18 @@ var parseTemplate = ({ templates, expressions, tokens, index, template: template
|
|
|
247965
248241
|
const expressionTokens = Array.isArray(expression) ? expression.map((expression2) => parseExpression(expression2)) : [parseExpression(expression)];
|
|
247966
248242
|
return concatTokens(newTokens, expressionTokens, trailingWhitespaces);
|
|
247967
248243
|
};
|
|
247968
|
-
var splitByWhitespaces = (
|
|
248244
|
+
var splitByWhitespaces = (template, rawTemplate) => {
|
|
247969
248245
|
if (rawTemplate.length === 0) {
|
|
247970
248246
|
return { nextTokens: [], leadingWhitespaces: false, trailingWhitespaces: false };
|
|
247971
248247
|
}
|
|
247972
248248
|
const nextTokens = [];
|
|
247973
248249
|
let templateStart = 0;
|
|
247974
248250
|
const leadingWhitespaces = DELIMITERS.has(rawTemplate[0]);
|
|
247975
|
-
for (let templateIndex = 0, rawIndex = 0;templateIndex <
|
|
248251
|
+
for (let templateIndex = 0, rawIndex = 0;templateIndex < template.length; templateIndex += 1, rawIndex += 1) {
|
|
247976
248252
|
const rawCharacter = rawTemplate[rawIndex];
|
|
247977
248253
|
if (DELIMITERS.has(rawCharacter)) {
|
|
247978
248254
|
if (templateStart !== templateIndex) {
|
|
247979
|
-
nextTokens.push(
|
|
248255
|
+
nextTokens.push(template.slice(templateStart, templateIndex));
|
|
247980
248256
|
}
|
|
247981
248257
|
templateStart = templateIndex + 1;
|
|
247982
248258
|
} else if (rawCharacter === "\\") {
|
|
@@ -247992,9 +248268,9 @@ var splitByWhitespaces = (template2, rawTemplate) => {
|
|
|
247992
248268
|
}
|
|
247993
248269
|
}
|
|
247994
248270
|
}
|
|
247995
|
-
const trailingWhitespaces = templateStart ===
|
|
248271
|
+
const trailingWhitespaces = templateStart === template.length;
|
|
247996
248272
|
if (!trailingWhitespaces) {
|
|
247997
|
-
nextTokens.push(
|
|
248273
|
+
nextTokens.push(template.slice(templateStart));
|
|
247998
248274
|
}
|
|
247999
248275
|
return { nextTokens, leadingWhitespaces, trailingWhitespaces };
|
|
248000
248276
|
};
|
|
@@ -249388,8 +249664,8 @@ var disconnect = (anyProcess) => {
|
|
|
249388
249664
|
// ../../node_modules/execa/lib/utils/deferred.js
|
|
249389
249665
|
var createDeferred = () => {
|
|
249390
249666
|
const methods = {};
|
|
249391
|
-
const promise2 = new Promise((
|
|
249392
|
-
Object.assign(methods, { resolve:
|
|
249667
|
+
const promise2 = new Promise((resolve5, reject) => {
|
|
249668
|
+
Object.assign(methods, { resolve: resolve5, reject });
|
|
249393
249669
|
});
|
|
249394
249670
|
return Object.assign(promise2, methods);
|
|
249395
249671
|
};
|
|
@@ -253753,11 +254029,11 @@ var addConcurrentStream = (concurrentStreams, stream, waitName) => {
|
|
|
253753
254029
|
const promises = weakMap.get(stream);
|
|
253754
254030
|
const promise2 = createDeferred();
|
|
253755
254031
|
promises.push(promise2);
|
|
253756
|
-
const
|
|
253757
|
-
return { resolve:
|
|
254032
|
+
const resolve5 = promise2.resolve.bind(promise2);
|
|
254033
|
+
return { resolve: resolve5, promises };
|
|
253758
254034
|
};
|
|
253759
|
-
var waitForConcurrentStreams = async ({ resolve:
|
|
253760
|
-
|
|
254035
|
+
var waitForConcurrentStreams = async ({ resolve: resolve5, promises }, subprocess) => {
|
|
254036
|
+
resolve5();
|
|
253761
254037
|
const [isSubprocessExit] = await Promise.race([
|
|
253762
254038
|
Promise.allSettled([true, subprocess]),
|
|
253763
254039
|
Promise.all([false, ...promises])
|
|
@@ -254336,6 +254612,441 @@ var {
|
|
|
254336
254612
|
getCancelSignal: getCancelSignal2
|
|
254337
254613
|
} = getIpcExport();
|
|
254338
254614
|
|
|
254615
|
+
// src/core/deployments/git-hash.ts
|
|
254616
|
+
async function resolveGitHash(projectRoot, explicit) {
|
|
254617
|
+
const hash2 = explicit ?? await gitHead(projectRoot);
|
|
254618
|
+
if (!hash2 || !GIT_HASH_PATTERN.test(hash2)) {
|
|
254619
|
+
throw new InvalidInputError(explicit ? `'${explicit}' is not a git commit hash.` : "Deployments are addressed by the commit that produced the build, and no git commit was found.", {
|
|
254620
|
+
hints: [
|
|
254621
|
+
{
|
|
254622
|
+
message: "Run the deploy from a git checkout, or pass the commit explicitly with --git-hash."
|
|
254623
|
+
}
|
|
254624
|
+
]
|
|
254625
|
+
});
|
|
254626
|
+
}
|
|
254627
|
+
return hash2;
|
|
254628
|
+
}
|
|
254629
|
+
async function gitHead(projectRoot) {
|
|
254630
|
+
try {
|
|
254631
|
+
const { stdout } = await execa("git", ["rev-parse", "HEAD"], {
|
|
254632
|
+
cwd: projectRoot
|
|
254633
|
+
});
|
|
254634
|
+
return stdout.trim();
|
|
254635
|
+
} catch {
|
|
254636
|
+
return null;
|
|
254637
|
+
}
|
|
254638
|
+
}
|
|
254639
|
+
// src/core/deployments/static-site.ts
|
|
254640
|
+
import { readFile as readFile5 } from "node:fs/promises";
|
|
254641
|
+
import { join as join17 } from "node:path";
|
|
254642
|
+
var STATIC_DEPLOYMENTS_ENV = "BASE44_STATIC_DEPLOYMENTS";
|
|
254643
|
+
function staticDeploymentsEnabled(env2 = process.env) {
|
|
254644
|
+
const value = env2[STATIC_DEPLOYMENTS_ENV];
|
|
254645
|
+
return value === "1" || value === "true";
|
|
254646
|
+
}
|
|
254647
|
+
async function deployStaticSite(options) {
|
|
254648
|
+
const { outputDir, gitHash, progress } = options;
|
|
254649
|
+
const assets = await buildAssetManifest(outputDir, getAppContext().id);
|
|
254650
|
+
if (!assets.manifest["/index.html"]) {
|
|
254651
|
+
throw new InvalidInputError(`No index.html found in "${outputDir}" — a static site needs one at the output directory root.`);
|
|
254652
|
+
}
|
|
254653
|
+
const created = await createDeployment({
|
|
254654
|
+
git_hash: gitHash,
|
|
254655
|
+
asset_manifest: assets.manifest
|
|
254656
|
+
});
|
|
254657
|
+
if (created.assetUploads && created.assetUploads.type !== "s3") {
|
|
254658
|
+
throw new ApiError(`The server answered a static-site deploy with the "${created.assetUploads.type}" upload target.`);
|
|
254659
|
+
}
|
|
254660
|
+
const totalAssets = Object.keys(assets.manifest).length;
|
|
254661
|
+
progress?.onAssets?.({
|
|
254662
|
+
totalAssets,
|
|
254663
|
+
newAssets: created.assetUploads?.uploads.length ?? 0
|
|
254664
|
+
});
|
|
254665
|
+
if (created.assetUploads) {
|
|
254666
|
+
await uploadPresignedAssets(created.assetUploads.uploads, assets, progress?.onAssetUpload);
|
|
254667
|
+
}
|
|
254668
|
+
const indexHtml = await readFile5(join17(outputDir, "index.html"));
|
|
254669
|
+
const finalized = await finalizeStaticDeployment(created.deploymentId, new Uint8Array(indexHtml));
|
|
254670
|
+
return { deploymentId: finalized.deploymentId, gitHash };
|
|
254671
|
+
}
|
|
254672
|
+
// src/core/site/deploy-app.ts
|
|
254673
|
+
async function planAppDeploy(target) {
|
|
254674
|
+
if (await detectFullStackArtifact(target.root)) {
|
|
254675
|
+
return { kind: "full-stack" };
|
|
254676
|
+
}
|
|
254677
|
+
const outputDirectory = target.site?.outputDirectory;
|
|
254678
|
+
if (!outputDirectory) {
|
|
254679
|
+
return { kind: "none" };
|
|
254680
|
+
}
|
|
254681
|
+
const outputDir = resolve5(target.root, outputDirectory);
|
|
254682
|
+
return staticDeploymentsEnabled() ? { kind: "static-deployment", outputDir } : { kind: "static", outputDir };
|
|
254683
|
+
}
|
|
254684
|
+
async function detectAppDeployKind(target) {
|
|
254685
|
+
return (await planAppDeploy(target)).kind;
|
|
254686
|
+
}
|
|
254687
|
+
async function deployAppSite(target, options = {}) {
|
|
254688
|
+
const plan = await planAppDeploy(target);
|
|
254689
|
+
switch (plan.kind) {
|
|
254690
|
+
case "full-stack": {
|
|
254691
|
+
const gitHash = await resolveGitHash(target.root, options.gitHash);
|
|
254692
|
+
const { deploymentId } = await deployFullStack({
|
|
254693
|
+
projectRoot: target.root,
|
|
254694
|
+
gitHash,
|
|
254695
|
+
progress: options.progress
|
|
254696
|
+
});
|
|
254697
|
+
return { kind: "full-stack", deploymentId, gitHash };
|
|
254698
|
+
}
|
|
254699
|
+
case "static-deployment": {
|
|
254700
|
+
const gitHash = await resolveGitHash(target.root, options.gitHash);
|
|
254701
|
+
const { deploymentId } = await deployStaticSite({
|
|
254702
|
+
outputDir: plan.outputDir,
|
|
254703
|
+
gitHash,
|
|
254704
|
+
progress: options.progress
|
|
254705
|
+
});
|
|
254706
|
+
return { kind: "static-deployment", deploymentId, gitHash };
|
|
254707
|
+
}
|
|
254708
|
+
case "static": {
|
|
254709
|
+
const { appUrl } = await deploySite(plan.outputDir);
|
|
254710
|
+
return { kind: "static", appUrl };
|
|
254711
|
+
}
|
|
254712
|
+
case "none":
|
|
254713
|
+
return { kind: "none" };
|
|
254714
|
+
}
|
|
254715
|
+
}
|
|
254716
|
+
// src/core/project/deploy.ts
|
|
254717
|
+
function hasResourcesToDeploy(projectData) {
|
|
254718
|
+
const {
|
|
254719
|
+
project,
|
|
254720
|
+
entities,
|
|
254721
|
+
functions,
|
|
254722
|
+
agents,
|
|
254723
|
+
agentSkills,
|
|
254724
|
+
connectors,
|
|
254725
|
+
authConfig
|
|
254726
|
+
} = projectData;
|
|
254727
|
+
const hasSite = Boolean(project.site?.outputDirectory || project.site?.buildCommand);
|
|
254728
|
+
const hasEntities = entities.length > 0;
|
|
254729
|
+
const hasFunctions = functions.length > 0;
|
|
254730
|
+
const hasAgents = agents.length > 0;
|
|
254731
|
+
const hasAgentSkills = agentSkills.length > 0;
|
|
254732
|
+
const hasConnectors = connectors.length > 0;
|
|
254733
|
+
const hasAuthConfig = authConfig.length > 0;
|
|
254734
|
+
const hasVisibility = Boolean(project.visibility);
|
|
254735
|
+
return hasEntities || hasFunctions || hasAgents || hasAgentSkills || hasConnectors || hasAuthConfig || hasVisibility || hasSite;
|
|
254736
|
+
}
|
|
254737
|
+
async function deployAll(projectData, options) {
|
|
254738
|
+
const {
|
|
254739
|
+
project,
|
|
254740
|
+
entities,
|
|
254741
|
+
functions,
|
|
254742
|
+
agents,
|
|
254743
|
+
agentSkills,
|
|
254744
|
+
connectors,
|
|
254745
|
+
authConfig
|
|
254746
|
+
} = projectData;
|
|
254747
|
+
await setAppVisibility(project.visibility);
|
|
254748
|
+
if (project.visibility) {
|
|
254749
|
+
options?.onVisibilitySet?.(project.visibility);
|
|
254750
|
+
}
|
|
254751
|
+
await entityResource.push(entities);
|
|
254752
|
+
await deployFunctionsSequentially(functions, {
|
|
254753
|
+
onStart: options?.onFunctionStart,
|
|
254754
|
+
onResult: options?.onFunctionResult
|
|
254755
|
+
});
|
|
254756
|
+
await agentSkillResource.push(agentSkills);
|
|
254757
|
+
await agentResource.push(agents);
|
|
254758
|
+
await authConfigResource.push(authConfig);
|
|
254759
|
+
const skipConnectorSync = connectors.length === 0 && hasWorkspaceApiKeyAuth();
|
|
254760
|
+
const connectorResults = skipConnectorSync ? [] : (await pushConnectors(connectors)).results;
|
|
254761
|
+
if ((options?.site ?? true) && project.site?.outputDirectory) {
|
|
254762
|
+
const outputDir = resolve6(project.root, project.site.outputDirectory);
|
|
254763
|
+
const { appUrl } = await deploySite(outputDir);
|
|
254764
|
+
return { appUrl, connectorResults };
|
|
254765
|
+
}
|
|
254766
|
+
return { connectorResults };
|
|
254767
|
+
}
|
|
254768
|
+
// src/core/clients/base44-client.ts
|
|
254769
|
+
var retriedRequests = new WeakSet;
|
|
254770
|
+
async function captureRequestBody(request, options) {
|
|
254771
|
+
if (request.body == null) {
|
|
254772
|
+
return;
|
|
254773
|
+
}
|
|
254774
|
+
try {
|
|
254775
|
+
const cloned = request.clone();
|
|
254776
|
+
const text = await cloned.text();
|
|
254777
|
+
options.context.__requestBody = text;
|
|
254778
|
+
} catch {}
|
|
254779
|
+
}
|
|
254780
|
+
async function handleUnauthorized(request, _options, response) {
|
|
254781
|
+
if (response.status !== 401) {
|
|
254782
|
+
return;
|
|
254783
|
+
}
|
|
254784
|
+
if (hasWorkspaceApiKeyAuth()) {
|
|
254785
|
+
return;
|
|
254786
|
+
}
|
|
254787
|
+
if (retriedRequests.has(request)) {
|
|
254788
|
+
return;
|
|
254789
|
+
}
|
|
254790
|
+
const newAccessToken = await refreshAndSaveTokens();
|
|
254791
|
+
if (!newAccessToken) {
|
|
254792
|
+
return;
|
|
254793
|
+
}
|
|
254794
|
+
retriedRequests.add(request);
|
|
254795
|
+
const requestId = request.headers.get("X-Request-ID");
|
|
254796
|
+
return distribution_default(request.clone(), {
|
|
254797
|
+
headers: {
|
|
254798
|
+
...requestId && { "X-Request-ID": requestId },
|
|
254799
|
+
Authorization: `Bearer ${newAccessToken}`
|
|
254800
|
+
}
|
|
254801
|
+
});
|
|
254802
|
+
}
|
|
254803
|
+
var base44Client = distribution_default.create({
|
|
254804
|
+
prefixUrl: getBase44ApiUrl(),
|
|
254805
|
+
headers: {
|
|
254806
|
+
"User-Agent": "Base44 CLI"
|
|
254807
|
+
},
|
|
254808
|
+
hooks: {
|
|
254809
|
+
beforeRequest: [
|
|
254810
|
+
(request) => {
|
|
254811
|
+
request.headers.set("X-Request-ID", randomUUID2());
|
|
254812
|
+
},
|
|
254813
|
+
captureRequestBody,
|
|
254814
|
+
async (request) => {
|
|
254815
|
+
const workspaceApiKey = getWorkspaceApiKeyFromEnv();
|
|
254816
|
+
if (workspaceApiKey && isWorkspaceApiKey(workspaceApiKey)) {
|
|
254817
|
+
request.headers.set("api_key", workspaceApiKey);
|
|
254818
|
+
return;
|
|
254819
|
+
}
|
|
254820
|
+
try {
|
|
254821
|
+
const auth = await readAuth();
|
|
254822
|
+
if (isTokenExpired(auth)) {
|
|
254823
|
+
const newAccessToken = await refreshAndSaveTokens();
|
|
254824
|
+
if (newAccessToken) {
|
|
254825
|
+
request.headers.set("Authorization", `Bearer ${newAccessToken}`);
|
|
254826
|
+
return;
|
|
254827
|
+
}
|
|
254828
|
+
}
|
|
254829
|
+
request.headers.set("Authorization", `Bearer ${auth.accessToken}`);
|
|
254830
|
+
} catch {}
|
|
254831
|
+
}
|
|
254832
|
+
],
|
|
254833
|
+
afterResponse: [handleUnauthorized]
|
|
254834
|
+
}
|
|
254835
|
+
});
|
|
254836
|
+
function getAppClient() {
|
|
254837
|
+
const { id } = getAppContext();
|
|
254838
|
+
return base44Client.extend({
|
|
254839
|
+
prefixUrl: new URL(`/api/apps/${id}/`, getBase44ApiUrl()).href
|
|
254840
|
+
});
|
|
254841
|
+
}
|
|
254842
|
+
function getSandboxClient(appId) {
|
|
254843
|
+
return base44Client.extend({
|
|
254844
|
+
prefixUrl: new URL(`/api/apps/${appId}/sandbox-bridge/`, getBase44ApiUrl()).href
|
|
254845
|
+
});
|
|
254846
|
+
}
|
|
254847
|
+
// src/core/clients/oauth-client.ts
|
|
254848
|
+
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
254849
|
+
var oauthClient = distribution_default.create({
|
|
254850
|
+
prefixUrl: getBase44ApiUrl(),
|
|
254851
|
+
headers: {
|
|
254852
|
+
"User-Agent": "Base44 CLI"
|
|
254853
|
+
},
|
|
254854
|
+
hooks: {
|
|
254855
|
+
beforeRequest: [
|
|
254856
|
+
(request) => {
|
|
254857
|
+
request.headers.set("X-Request-ID", randomUUID3());
|
|
254858
|
+
}
|
|
254859
|
+
]
|
|
254860
|
+
}
|
|
254861
|
+
});
|
|
254862
|
+
// src/core/auth/api.ts
|
|
254863
|
+
async function generateDeviceCode() {
|
|
254864
|
+
const response = await oauthClient.post("oauth/device/code", {
|
|
254865
|
+
json: {
|
|
254866
|
+
client_id: AUTH_CLIENT_ID,
|
|
254867
|
+
scope: "apps:read apps:write sandbox:write"
|
|
254868
|
+
},
|
|
254869
|
+
throwHttpErrors: false
|
|
254870
|
+
});
|
|
254871
|
+
if (!response.ok) {
|
|
254872
|
+
throw new ApiError(`Failed to generate device code: ${response.status} ${response.statusText}`, { statusCode: response.status });
|
|
254873
|
+
}
|
|
254874
|
+
const result = DeviceCodeResponseSchema.safeParse(await response.json());
|
|
254875
|
+
if (!result.success) {
|
|
254876
|
+
throw new SchemaValidationError("Invalid device code response from server", result.error);
|
|
254877
|
+
}
|
|
254878
|
+
return result.data;
|
|
254879
|
+
}
|
|
254880
|
+
async function getTokenFromDeviceCode(deviceCode) {
|
|
254881
|
+
const searchParams = new URLSearchParams;
|
|
254882
|
+
searchParams.set("grant_type", "urn:ietf:params:oauth:grant-type:device_code");
|
|
254883
|
+
searchParams.set("device_code", deviceCode);
|
|
254884
|
+
searchParams.set("client_id", AUTH_CLIENT_ID);
|
|
254885
|
+
const response = await oauthClient.post("oauth/token", {
|
|
254886
|
+
body: searchParams.toString(),
|
|
254887
|
+
headers: {
|
|
254888
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
254889
|
+
},
|
|
254890
|
+
throwHttpErrors: false
|
|
254891
|
+
});
|
|
254892
|
+
const json2 = await response.json();
|
|
254893
|
+
if (!response.ok) {
|
|
254894
|
+
const errorResult = OAuthErrorSchema.safeParse(json2);
|
|
254895
|
+
if (!errorResult.success) {
|
|
254896
|
+
throw new SchemaValidationError("Token request failed", errorResult.error);
|
|
254897
|
+
}
|
|
254898
|
+
const { error: error48, error_description } = errorResult.data;
|
|
254899
|
+
if (error48 === "authorization_pending" || error48 === "slow_down") {
|
|
254900
|
+
return null;
|
|
254901
|
+
}
|
|
254902
|
+
throw new ApiError(error_description ?? `OAuth error: ${error48}`, {
|
|
254903
|
+
statusCode: response.status
|
|
254904
|
+
});
|
|
254905
|
+
}
|
|
254906
|
+
const result = TokenResponseSchema.safeParse(json2);
|
|
254907
|
+
if (!result.success) {
|
|
254908
|
+
throw new SchemaValidationError("Invalid token response from server", result.error);
|
|
254909
|
+
}
|
|
254910
|
+
return result.data;
|
|
254911
|
+
}
|
|
254912
|
+
async function renewAccessToken(refreshToken) {
|
|
254913
|
+
const searchParams = new URLSearchParams;
|
|
254914
|
+
searchParams.set("grant_type", "refresh_token");
|
|
254915
|
+
searchParams.set("refresh_token", refreshToken);
|
|
254916
|
+
searchParams.set("client_id", AUTH_CLIENT_ID);
|
|
254917
|
+
const response = await oauthClient.post("oauth/token", {
|
|
254918
|
+
body: searchParams.toString(),
|
|
254919
|
+
headers: {
|
|
254920
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
254921
|
+
},
|
|
254922
|
+
throwHttpErrors: false
|
|
254923
|
+
});
|
|
254924
|
+
const json2 = await response.json();
|
|
254925
|
+
if (!response.ok) {
|
|
254926
|
+
const errorResult = OAuthErrorSchema.safeParse(json2);
|
|
254927
|
+
if (!errorResult.success) {
|
|
254928
|
+
throw new ApiError(`Token refresh failed: ${response.statusText}`, {
|
|
254929
|
+
statusCode: response.status
|
|
254930
|
+
});
|
|
254931
|
+
}
|
|
254932
|
+
const { error: error48, error_description } = errorResult.data;
|
|
254933
|
+
throw new ApiError(error_description ?? `OAuth error: ${error48}`, {
|
|
254934
|
+
statusCode: response.status
|
|
254935
|
+
});
|
|
254936
|
+
}
|
|
254937
|
+
const result = TokenResponseSchema.safeParse(json2);
|
|
254938
|
+
if (!result.success) {
|
|
254939
|
+
throw new SchemaValidationError("Invalid token response from server", result.error);
|
|
254940
|
+
}
|
|
254941
|
+
return result.data;
|
|
254942
|
+
}
|
|
254943
|
+
async function getUserInfo(accessToken) {
|
|
254944
|
+
const response = await oauthClient.get("oauth/userinfo", {
|
|
254945
|
+
headers: { Authorization: `Bearer ${accessToken}` }
|
|
254946
|
+
});
|
|
254947
|
+
if (!response.ok) {
|
|
254948
|
+
throw new ApiError(`Failed to fetch user info: ${response.status}`, {
|
|
254949
|
+
statusCode: response.status
|
|
254950
|
+
});
|
|
254951
|
+
}
|
|
254952
|
+
const result = UserInfoSchema.safeParse(await response.json());
|
|
254953
|
+
if (!result.success) {
|
|
254954
|
+
throw new SchemaValidationError("Invalid UserInfo response from server", result.error);
|
|
254955
|
+
}
|
|
254956
|
+
return result.data;
|
|
254957
|
+
}
|
|
254958
|
+
// src/cli/commands/auth/login-flow.ts
|
|
254959
|
+
async function generateAndDisplayDeviceCode(log, runTask) {
|
|
254960
|
+
const deviceCodeResponse = await runTask("Generating device code...", async () => {
|
|
254961
|
+
return await generateDeviceCode();
|
|
254962
|
+
}, {
|
|
254963
|
+
successMessage: "Device code generated",
|
|
254964
|
+
errorMessage: "Failed to generate device code"
|
|
254965
|
+
});
|
|
254966
|
+
log.info(`Verification code: ${theme.styles.bold(deviceCodeResponse.userCode)}` + `
|
|
254967
|
+
Please confirm this code at: ${deviceCodeResponse.verificationUri}`);
|
|
254968
|
+
return deviceCodeResponse;
|
|
254969
|
+
}
|
|
254970
|
+
async function waitForAuthentication(deviceCode, expiresIn, interval, runTask) {
|
|
254971
|
+
let tokenResponse;
|
|
254972
|
+
try {
|
|
254973
|
+
await runTask("Waiting for authentication...", async () => {
|
|
254974
|
+
await pWaitFor(async () => {
|
|
254975
|
+
const result = await getTokenFromDeviceCode(deviceCode);
|
|
254976
|
+
if (result !== null) {
|
|
254977
|
+
tokenResponse = result;
|
|
254978
|
+
return true;
|
|
254979
|
+
}
|
|
254980
|
+
return false;
|
|
254981
|
+
}, {
|
|
254982
|
+
interval: interval * 1000,
|
|
254983
|
+
timeout: expiresIn * 1000
|
|
254984
|
+
});
|
|
254985
|
+
}, {
|
|
254986
|
+
successMessage: "Authentication completed!",
|
|
254987
|
+
errorMessage: "Authentication failed"
|
|
254988
|
+
});
|
|
254989
|
+
} catch (error48) {
|
|
254990
|
+
if (error48 instanceof Error && error48.message.includes("timed out")) {
|
|
254991
|
+
throw new AuthExpiredError("Authentication timed out. Please try again.");
|
|
254992
|
+
}
|
|
254993
|
+
throw error48;
|
|
254994
|
+
}
|
|
254995
|
+
if (tokenResponse === undefined) {
|
|
254996
|
+
throw new InternalError("Failed to retrieve authentication token.");
|
|
254997
|
+
}
|
|
254998
|
+
return tokenResponse;
|
|
254999
|
+
}
|
|
255000
|
+
async function saveAuthData(response, userInfo) {
|
|
255001
|
+
const expiresAt = Date.now() + response.expiresIn * 1000;
|
|
255002
|
+
await writeAuth({
|
|
255003
|
+
accessToken: response.accessToken,
|
|
255004
|
+
refreshToken: response.refreshToken,
|
|
255005
|
+
expiresAt,
|
|
255006
|
+
email: userInfo.email,
|
|
255007
|
+
name: userInfo.name
|
|
255008
|
+
});
|
|
255009
|
+
}
|
|
255010
|
+
async function login({
|
|
255011
|
+
log,
|
|
255012
|
+
runTask
|
|
255013
|
+
}) {
|
|
255014
|
+
const deviceCodeResponse = await generateAndDisplayDeviceCode(log, runTask);
|
|
255015
|
+
const token = await waitForAuthentication(deviceCodeResponse.deviceCode, deviceCodeResponse.expiresIn, deviceCodeResponse.interval, runTask);
|
|
255016
|
+
const userInfo = await getUserInfo(token.accessToken);
|
|
255017
|
+
await saveAuthData(token, userInfo);
|
|
255018
|
+
return {
|
|
255019
|
+
outroMessage: `Successfully logged in as ${theme.styles.bold(userInfo.email)}`
|
|
255020
|
+
};
|
|
255021
|
+
}
|
|
255022
|
+
|
|
255023
|
+
// src/cli/utils/command/middleware.ts
|
|
255024
|
+
async function ensureAuth(ctx) {
|
|
255025
|
+
if (hasWorkspaceApiKeyAuth()) {
|
|
255026
|
+
ctx.errorReporter.setContext({
|
|
255027
|
+
user: { email: "workspace-api-key", name: "Workspace API key" }
|
|
255028
|
+
});
|
|
255029
|
+
return;
|
|
255030
|
+
}
|
|
255031
|
+
await seedAuthFromEnv();
|
|
255032
|
+
const loggedIn = await isLoggedIn();
|
|
255033
|
+
if (!loggedIn) {
|
|
255034
|
+
ctx.log.info("You need to login first to continue.");
|
|
255035
|
+
await login(ctx);
|
|
255036
|
+
}
|
|
255037
|
+
try {
|
|
255038
|
+
const userInfo = await readAuth();
|
|
255039
|
+
ctx.errorReporter.setContext({
|
|
255040
|
+
user: { email: userInfo.email, name: userInfo.name }
|
|
255041
|
+
});
|
|
255042
|
+
} catch {}
|
|
255043
|
+
}
|
|
255044
|
+
async function ensureAppContext(ctx, options = {}) {
|
|
255045
|
+
const appContext = await initAppContext(options);
|
|
255046
|
+
ctx.app = appContext;
|
|
255047
|
+
ctx.errorReporter.setContext({ appId: appContext.id });
|
|
255048
|
+
}
|
|
255049
|
+
|
|
254339
255050
|
// src/cli/utils/version-check.ts
|
|
254340
255051
|
async function checkForUpgrade() {
|
|
254341
255052
|
const testLatestVersion = getTestOverrides()?.latestVersion;
|
|
@@ -254714,623 +255425,6 @@ function formatYaml(data, options = {}) {
|
|
|
254714
255425
|
const replacer = stripEmpty ? stripEmptyReplacer : undefined;
|
|
254715
255426
|
return $stringify(data, replacer, { indent: YAML_INDENT }).trimEnd();
|
|
254716
255427
|
}
|
|
254717
|
-
// src/core/deployments/api.ts
|
|
254718
|
-
import { readFile as readFile2 } from "node:fs/promises";
|
|
254719
|
-
|
|
254720
|
-
// src/core/deployments/schema.ts
|
|
254721
|
-
var GIT_HASH_PATTERN = /^[a-fA-F0-9]{7,64}$/;
|
|
254722
|
-
var CreateDeploymentResponseSchema = exports_external.object({
|
|
254723
|
-
deployment_id: exports_external.string(),
|
|
254724
|
-
asset_buckets: exports_external.array(exports_external.array(exports_external.string()))
|
|
254725
|
-
}).transform((data) => ({
|
|
254726
|
-
deploymentId: data.deployment_id,
|
|
254727
|
-
assetBuckets: data.asset_buckets
|
|
254728
|
-
}));
|
|
254729
|
-
var AssetUploadResponseSchema = exports_external.looseObject({
|
|
254730
|
-
result: exports_external.looseObject({ jwt: exports_external.string().nullable().optional() }).nullable().optional()
|
|
254731
|
-
});
|
|
254732
|
-
var FinalizeDeploymentResponseSchema = exports_external.object({
|
|
254733
|
-
deployment_id: exports_external.string()
|
|
254734
|
-
}).transform((data) => ({
|
|
254735
|
-
deploymentId: data.deployment_id
|
|
254736
|
-
}));
|
|
254737
|
-
|
|
254738
|
-
// src/core/deployments/api.ts
|
|
254739
|
-
var MODULE_CONTENT_TYPES = {
|
|
254740
|
-
esm: "application/javascript+module",
|
|
254741
|
-
sourcemap: "application/source-map",
|
|
254742
|
-
wasm: "application/wasm",
|
|
254743
|
-
text: "text/plain",
|
|
254744
|
-
data: "application/octet-stream"
|
|
254745
|
-
};
|
|
254746
|
-
async function createDeployment(request) {
|
|
254747
|
-
const appClient = getAppClient();
|
|
254748
|
-
let response;
|
|
254749
|
-
try {
|
|
254750
|
-
response = await appClient.post("deployments", {
|
|
254751
|
-
json: request,
|
|
254752
|
-
timeout: 120000
|
|
254753
|
-
});
|
|
254754
|
-
} catch (error48) {
|
|
254755
|
-
throw await ApiError.fromHttpError(error48, "creating deployment");
|
|
254756
|
-
}
|
|
254757
|
-
const result = CreateDeploymentResponseSchema.safeParse(await response.json());
|
|
254758
|
-
if (!result.success) {
|
|
254759
|
-
throw new SchemaValidationError("Invalid response from server", result.error);
|
|
254760
|
-
}
|
|
254761
|
-
return result.data;
|
|
254762
|
-
}
|
|
254763
|
-
async function uploadAssetBucket(deploymentId, formData) {
|
|
254764
|
-
const appClient = getAppClient();
|
|
254765
|
-
const response = await appClient.post(`deployments/${encodeURIComponent(deploymentId)}/assets`, {
|
|
254766
|
-
searchParams: { base64: "true" },
|
|
254767
|
-
body: formData,
|
|
254768
|
-
timeout: 120000,
|
|
254769
|
-
retry: 0
|
|
254770
|
-
});
|
|
254771
|
-
const parsed = AssetUploadResponseSchema.safeParse(await response.json());
|
|
254772
|
-
const jwt3 = parsed.success ? parsed.data.result?.jwt : null;
|
|
254773
|
-
return jwt3 || null;
|
|
254774
|
-
}
|
|
254775
|
-
async function finalizeDeployment(deploymentId, completionJwt, modules) {
|
|
254776
|
-
const appClient = getAppClient();
|
|
254777
|
-
const formData = new FormData;
|
|
254778
|
-
formData.append("payload", JSON.stringify({ completion_jwt: completionJwt }));
|
|
254779
|
-
for (const module of modules) {
|
|
254780
|
-
const content = await readFile2(module.absolutePath);
|
|
254781
|
-
formData.append(module.name, new File([new Uint8Array(content)], module.name, {
|
|
254782
|
-
type: MODULE_CONTENT_TYPES[module.type]
|
|
254783
|
-
}));
|
|
254784
|
-
}
|
|
254785
|
-
let response;
|
|
254786
|
-
try {
|
|
254787
|
-
response = await appClient.post(`deployments/${encodeURIComponent(deploymentId)}/finalize`, { body: formData, timeout: 180000 });
|
|
254788
|
-
} catch (error48) {
|
|
254789
|
-
throw await ApiError.fromHttpError(error48, "finalizing deployment");
|
|
254790
|
-
}
|
|
254791
|
-
const result = FinalizeDeploymentResponseSchema.safeParse(await response.json());
|
|
254792
|
-
if (!result.success) {
|
|
254793
|
-
throw new SchemaValidationError("Invalid response from server", result.error);
|
|
254794
|
-
}
|
|
254795
|
-
return result.data;
|
|
254796
|
-
}
|
|
254797
|
-
// src/core/deployments/manifest.ts
|
|
254798
|
-
import { createHash } from "node:crypto";
|
|
254799
|
-
import { readdir as readdir2, readFile as readFile3, stat } from "node:fs/promises";
|
|
254800
|
-
import { extname, join as join15 } from "node:path";
|
|
254801
|
-
var MAX_ASSET_SIZE_BYTES = 25 * 1024 * 1024;
|
|
254802
|
-
var MAX_ASSET_COUNT = 1e5;
|
|
254803
|
-
var ASSETS_IGNORE_FILE = ".assetsignore";
|
|
254804
|
-
var ALWAYS_SKIPPED_FILES = new Set([
|
|
254805
|
-
ASSETS_IGNORE_FILE,
|
|
254806
|
-
"wrangler.json",
|
|
254807
|
-
".dev.vars"
|
|
254808
|
-
]);
|
|
254809
|
-
var MIME_TYPES = {
|
|
254810
|
-
".html": "text/html",
|
|
254811
|
-
".htm": "text/html",
|
|
254812
|
-
".css": "text/css",
|
|
254813
|
-
".js": "text/javascript",
|
|
254814
|
-
".mjs": "text/javascript",
|
|
254815
|
-
".json": "application/json",
|
|
254816
|
-
".map": "application/json",
|
|
254817
|
-
".txt": "text/plain",
|
|
254818
|
-
".xml": "application/xml",
|
|
254819
|
-
".svg": "image/svg+xml",
|
|
254820
|
-
".png": "image/png",
|
|
254821
|
-
".jpg": "image/jpeg",
|
|
254822
|
-
".jpeg": "image/jpeg",
|
|
254823
|
-
".gif": "image/gif",
|
|
254824
|
-
".webp": "image/webp",
|
|
254825
|
-
".avif": "image/avif",
|
|
254826
|
-
".ico": "image/x-icon",
|
|
254827
|
-
".woff": "font/woff",
|
|
254828
|
-
".woff2": "font/woff2",
|
|
254829
|
-
".ttf": "font/ttf",
|
|
254830
|
-
".otf": "font/otf",
|
|
254831
|
-
".eot": "application/vnd.ms-fontobject",
|
|
254832
|
-
".mp3": "audio/mpeg",
|
|
254833
|
-
".mp4": "video/mp4",
|
|
254834
|
-
".webm": "video/webm",
|
|
254835
|
-
".pdf": "application/pdf",
|
|
254836
|
-
".wasm": "application/wasm",
|
|
254837
|
-
".webmanifest": "application/manifest+json"
|
|
254838
|
-
};
|
|
254839
|
-
function getMimeType(filePath) {
|
|
254840
|
-
return MIME_TYPES[extname(filePath).toLowerCase()] ?? "application/octet-stream";
|
|
254841
|
-
}
|
|
254842
|
-
function hashAsset(appId, content) {
|
|
254843
|
-
return createHash("sha256").update(Buffer.from(appId, "utf8")).update(content).digest("hex").slice(0, 32);
|
|
254844
|
-
}
|
|
254845
|
-
function globToRegExp(glob) {
|
|
254846
|
-
let source = "";
|
|
254847
|
-
for (let i2 = 0;i2 < glob.length; i2++) {
|
|
254848
|
-
const char = glob[i2];
|
|
254849
|
-
if (char === "*") {
|
|
254850
|
-
if (glob[i2 + 1] === "*") {
|
|
254851
|
-
source += ".*";
|
|
254852
|
-
i2++;
|
|
254853
|
-
} else {
|
|
254854
|
-
source += "[^/]*";
|
|
254855
|
-
}
|
|
254856
|
-
} else if (char === "?") {
|
|
254857
|
-
source += "[^/]";
|
|
254858
|
-
} else {
|
|
254859
|
-
source += char.replace(/[.+^${}()|[\]\\]/g, "\\$&");
|
|
254860
|
-
}
|
|
254861
|
-
}
|
|
254862
|
-
return new RegExp(`^${source}$`);
|
|
254863
|
-
}
|
|
254864
|
-
function createIgnoreMatcher(lines) {
|
|
254865
|
-
const rules = lines.map((line) => line.trim()).filter((line) => line.length > 0 && !line.startsWith("#")).map((line) => {
|
|
254866
|
-
const isDirOnly = line.endsWith("/");
|
|
254867
|
-
let pattern = isDirOnly ? line.slice(0, -1) : line;
|
|
254868
|
-
const anchored = pattern.includes("/");
|
|
254869
|
-
pattern = pattern.replace(/^\//, "");
|
|
254870
|
-
return { regex: globToRegExp(pattern), anchored, isDirOnly };
|
|
254871
|
-
});
|
|
254872
|
-
return (relativePath, isDirectory2) => {
|
|
254873
|
-
const segments = relativePath.split("/");
|
|
254874
|
-
return rules.some((rule) => {
|
|
254875
|
-
if (rule.anchored) {
|
|
254876
|
-
if (rule.isDirOnly ? isDirectory2 : true) {
|
|
254877
|
-
if (rule.regex.test(relativePath))
|
|
254878
|
-
return true;
|
|
254879
|
-
}
|
|
254880
|
-
return false;
|
|
254881
|
-
}
|
|
254882
|
-
const basename4 = segments[segments.length - 1];
|
|
254883
|
-
if (rule.isDirOnly && !isDirectory2)
|
|
254884
|
-
return false;
|
|
254885
|
-
return rule.regex.test(basename4);
|
|
254886
|
-
});
|
|
254887
|
-
};
|
|
254888
|
-
}
|
|
254889
|
-
async function loadIgnoreMatcher(assetsDir) {
|
|
254890
|
-
const ignorePath = join15(assetsDir, ASSETS_IGNORE_FILE);
|
|
254891
|
-
if (!await pathExists(ignorePath)) {
|
|
254892
|
-
return () => false;
|
|
254893
|
-
}
|
|
254894
|
-
const content = await readTextFile(ignorePath);
|
|
254895
|
-
return createIgnoreMatcher(content.split(/\r?\n/));
|
|
254896
|
-
}
|
|
254897
|
-
async function buildAssetManifest(assetsDir, appId) {
|
|
254898
|
-
const isIgnored = await loadIgnoreMatcher(assetsDir);
|
|
254899
|
-
const manifest = {};
|
|
254900
|
-
const filesByHash = new Map;
|
|
254901
|
-
const relativeFilePaths = await collectFilePaths(assetsDir, "", isIgnored);
|
|
254902
|
-
if (relativeFilePaths.length > MAX_ASSET_COUNT) {
|
|
254903
|
-
throw new InvalidInputError(`Too many static assets: found ${relativeFilePaths.length}, the limit is ${MAX_ASSET_COUNT} files.`);
|
|
254904
|
-
}
|
|
254905
|
-
for (const relativePath of relativeFilePaths.sort()) {
|
|
254906
|
-
const absolutePath = join15(assetsDir, ...relativePath.split("/"));
|
|
254907
|
-
const { size } = await stat(absolutePath);
|
|
254908
|
-
if (size > MAX_ASSET_SIZE_BYTES) {
|
|
254909
|
-
throw new InvalidInputError(`Static asset "${relativePath}" is ${size} bytes, which exceeds the 25 MiB per-file limit.`);
|
|
254910
|
-
}
|
|
254911
|
-
const content = await readFile3(absolutePath);
|
|
254912
|
-
const hash2 = hashAsset(appId, content);
|
|
254913
|
-
manifest[`/${relativePath}`] = { hash: hash2, size };
|
|
254914
|
-
if (!filesByHash.has(hash2)) {
|
|
254915
|
-
filesByHash.set(hash2, {
|
|
254916
|
-
absolutePath,
|
|
254917
|
-
hash: hash2,
|
|
254918
|
-
size,
|
|
254919
|
-
contentType: getMimeType(absolutePath)
|
|
254920
|
-
});
|
|
254921
|
-
}
|
|
254922
|
-
}
|
|
254923
|
-
return { manifest, filesByHash };
|
|
254924
|
-
}
|
|
254925
|
-
async function collectFilePaths(dir, relativeDir, isIgnored) {
|
|
254926
|
-
const entries = await readdir2(dir, { withFileTypes: true });
|
|
254927
|
-
const results = [];
|
|
254928
|
-
for (const entry of entries) {
|
|
254929
|
-
const relativePath = relativeDir ? `${relativeDir}/${entry.name}` : entry.name;
|
|
254930
|
-
if (entry.isDirectory()) {
|
|
254931
|
-
if (isIgnored(relativePath, true))
|
|
254932
|
-
continue;
|
|
254933
|
-
results.push(...await collectFilePaths(join15(dir, entry.name), relativePath, isIgnored));
|
|
254934
|
-
continue;
|
|
254935
|
-
}
|
|
254936
|
-
if (!entry.isFile())
|
|
254937
|
-
continue;
|
|
254938
|
-
if (ALWAYS_SKIPPED_FILES.has(entry.name))
|
|
254939
|
-
continue;
|
|
254940
|
-
if (isIgnored(relativePath, false))
|
|
254941
|
-
continue;
|
|
254942
|
-
results.push(relativePath);
|
|
254943
|
-
}
|
|
254944
|
-
return results;
|
|
254945
|
-
}
|
|
254946
|
-
|
|
254947
|
-
// src/core/deployments/modules.ts
|
|
254948
|
-
import { stat as stat2 } from "node:fs/promises";
|
|
254949
|
-
import { relative as relative3, resolve as resolve4, sep } from "node:path";
|
|
254950
|
-
var MAX_TOTAL_MODULE_BYTES = 40 * 1024 * 1024;
|
|
254951
|
-
var MODULE_IGNORE = ["wrangler.json", ".dev.vars"];
|
|
254952
|
-
var RULE_TYPE_TO_MODULE_TYPE = {
|
|
254953
|
-
ESModule: "esm",
|
|
254954
|
-
CompiledWasm: "wasm",
|
|
254955
|
-
Text: "text",
|
|
254956
|
-
Data: "data"
|
|
254957
|
-
};
|
|
254958
|
-
function toPosix(path16) {
|
|
254959
|
-
return path16.split(sep).join("/");
|
|
254960
|
-
}
|
|
254961
|
-
async function collectModules(config12) {
|
|
254962
|
-
const entryPath = resolve4(config12.configDir, config12.main);
|
|
254963
|
-
if (!await pathExists(entryPath)) {
|
|
254964
|
-
throw new InvalidInputError(`Worker entry module does not exist: ${entryPath} (from "main" in ${config12.configPath})`, {
|
|
254965
|
-
hints: [{ message: "Rebuild the project to regenerate the artifact" }]
|
|
254966
|
-
});
|
|
254967
|
-
}
|
|
254968
|
-
const modulesByName = new Map;
|
|
254969
|
-
const entryName = toPosix(relative3(config12.configDir, entryPath));
|
|
254970
|
-
modulesByName.set(entryName, {
|
|
254971
|
-
name: entryName,
|
|
254972
|
-
absolutePath: entryPath,
|
|
254973
|
-
size: 0,
|
|
254974
|
-
type: "esm"
|
|
254975
|
-
});
|
|
254976
|
-
const ignore = [...MODULE_IGNORE];
|
|
254977
|
-
if (config12.assetsDirectory?.startsWith(config12.configDir + sep)) {
|
|
254978
|
-
ignore.push(`${toPosix(relative3(config12.configDir, config12.assetsDirectory))}/**`);
|
|
254979
|
-
}
|
|
254980
|
-
for (const rule of config12.rules) {
|
|
254981
|
-
const type = RULE_TYPE_TO_MODULE_TYPE[rule.type];
|
|
254982
|
-
if (!type) {
|
|
254983
|
-
throw new InvalidInputError(`Unsupported module rule type "${rule.type}" in ${config12.configPath}. Supported: ${Object.keys(RULE_TYPE_TO_MODULE_TYPE).join(", ")}.`);
|
|
254984
|
-
}
|
|
254985
|
-
const matches = await globby(rule.globs, {
|
|
254986
|
-
cwd: config12.configDir,
|
|
254987
|
-
onlyFiles: true,
|
|
254988
|
-
dot: true,
|
|
254989
|
-
ignore
|
|
254990
|
-
});
|
|
254991
|
-
for (const match of matches.sort()) {
|
|
254992
|
-
if (!modulesByName.has(match)) {
|
|
254993
|
-
modulesByName.set(match, {
|
|
254994
|
-
name: match,
|
|
254995
|
-
absolutePath: resolve4(config12.configDir, match),
|
|
254996
|
-
size: 0,
|
|
254997
|
-
type
|
|
254998
|
-
});
|
|
254999
|
-
}
|
|
255000
|
-
}
|
|
255001
|
-
}
|
|
255002
|
-
if (config12.uploadSourceMaps) {
|
|
255003
|
-
const maps = await globby("**/*.map", {
|
|
255004
|
-
cwd: config12.configDir,
|
|
255005
|
-
onlyFiles: true,
|
|
255006
|
-
dot: true,
|
|
255007
|
-
ignore
|
|
255008
|
-
});
|
|
255009
|
-
for (const map2 of maps.sort()) {
|
|
255010
|
-
addSourcemap(modulesByName, config12.configDir, map2);
|
|
255011
|
-
}
|
|
255012
|
-
} else {
|
|
255013
|
-
for (const name2 of [...modulesByName.keys()]) {
|
|
255014
|
-
const mapName = `${name2}.map`;
|
|
255015
|
-
if (await pathExists(resolve4(config12.configDir, mapName))) {
|
|
255016
|
-
addSourcemap(modulesByName, config12.configDir, mapName);
|
|
255017
|
-
}
|
|
255018
|
-
}
|
|
255019
|
-
}
|
|
255020
|
-
const modules = [...modulesByName.values()];
|
|
255021
|
-
let totalBytes = 0;
|
|
255022
|
-
for (const module of modules) {
|
|
255023
|
-
module.size = (await stat2(module.absolutePath)).size;
|
|
255024
|
-
totalBytes += module.size;
|
|
255025
|
-
}
|
|
255026
|
-
if (totalBytes > MAX_TOTAL_MODULE_BYTES) {
|
|
255027
|
-
throw new InvalidInputError(`Worker modules total ${totalBytes} bytes, which exceeds the 40 MB limit for Base44 full-stack deploys.`);
|
|
255028
|
-
}
|
|
255029
|
-
return modules;
|
|
255030
|
-
}
|
|
255031
|
-
function addSourcemap(modulesByName, configDir, name2) {
|
|
255032
|
-
if (modulesByName.has(name2))
|
|
255033
|
-
return;
|
|
255034
|
-
modulesByName.set(name2, {
|
|
255035
|
-
name: name2,
|
|
255036
|
-
absolutePath: resolve4(configDir, name2),
|
|
255037
|
-
size: 0,
|
|
255038
|
-
type: "sourcemap"
|
|
255039
|
-
});
|
|
255040
|
-
}
|
|
255041
|
-
|
|
255042
|
-
// src/core/deployments/upload.ts
|
|
255043
|
-
import { readFile as readFile4 } from "node:fs/promises";
|
|
255044
|
-
var BUCKET_CONCURRENCY = 3;
|
|
255045
|
-
var MAX_ATTEMPTS_PER_BUCKET = 3;
|
|
255046
|
-
var RETRY_BASE_DELAY_MS = 500;
|
|
255047
|
-
var MAX_RATE_LIMIT_WAITS = 10;
|
|
255048
|
-
var RATE_LIMIT_DELAY_MS = 15000;
|
|
255049
|
-
async function uploadAssetBuckets(deploymentId, buckets, filesByHash, onProgress) {
|
|
255050
|
-
if (buckets.length === 0) {
|
|
255051
|
-
return null;
|
|
255052
|
-
}
|
|
255053
|
-
const totalFiles = buckets.reduce((sum, bucket) => sum + bucket.length, 0);
|
|
255054
|
-
let uploadedFiles = 0;
|
|
255055
|
-
let completedBuckets = 0;
|
|
255056
|
-
let completionJwt = null;
|
|
255057
|
-
let nextBucket = 0;
|
|
255058
|
-
const worker = async () => {
|
|
255059
|
-
while (nextBucket < buckets.length) {
|
|
255060
|
-
const bucket = buckets[nextBucket++];
|
|
255061
|
-
const jwt3 = await uploadBucketWithRetry(deploymentId, bucket, filesByHash);
|
|
255062
|
-
if (jwt3) {
|
|
255063
|
-
completionJwt = jwt3;
|
|
255064
|
-
}
|
|
255065
|
-
uploadedFiles += bucket.length;
|
|
255066
|
-
completedBuckets++;
|
|
255067
|
-
onProgress?.({
|
|
255068
|
-
uploadedFiles,
|
|
255069
|
-
totalFiles,
|
|
255070
|
-
completedBuckets,
|
|
255071
|
-
totalBuckets: buckets.length
|
|
255072
|
-
});
|
|
255073
|
-
}
|
|
255074
|
-
};
|
|
255075
|
-
await Promise.all(Array.from({ length: Math.min(BUCKET_CONCURRENCY, buckets.length) }, worker));
|
|
255076
|
-
if (!completionJwt) {
|
|
255077
|
-
throw new ApiError("Asset upload finished but the server did not return a completion token.");
|
|
255078
|
-
}
|
|
255079
|
-
return completionJwt;
|
|
255080
|
-
}
|
|
255081
|
-
async function uploadBucketWithRetry(deploymentId, bucket, filesByHash) {
|
|
255082
|
-
let lastError;
|
|
255083
|
-
let rateLimitWaits = 0;
|
|
255084
|
-
const formData = await buildBucketForm(bucket, filesByHash);
|
|
255085
|
-
for (let attempt = 0;attempt < MAX_ATTEMPTS_PER_BUCKET; attempt++) {
|
|
255086
|
-
if (attempt > 0) {
|
|
255087
|
-
await sleep3(RETRY_BASE_DELAY_MS * 2 ** (attempt - 1));
|
|
255088
|
-
}
|
|
255089
|
-
try {
|
|
255090
|
-
return await uploadAssetBucket(deploymentId, formData);
|
|
255091
|
-
} catch (error48) {
|
|
255092
|
-
if (error48 instanceof HTTPError && error48.response.status === 429 && rateLimitWaits < MAX_RATE_LIMIT_WAITS) {
|
|
255093
|
-
rateLimitWaits++;
|
|
255094
|
-
attempt--;
|
|
255095
|
-
await sleep3(RATE_LIMIT_DELAY_MS);
|
|
255096
|
-
continue;
|
|
255097
|
-
}
|
|
255098
|
-
lastError = error48;
|
|
255099
|
-
}
|
|
255100
|
-
}
|
|
255101
|
-
if (lastError instanceof HTTPError && lastError.response.status === 409) {
|
|
255102
|
-
throw new ApiError("This deploy's upload session has expired — rerun deploy. Already-uploaded assets are skipped on the next attempt.", { statusCode: 409, cause: lastError });
|
|
255103
|
-
}
|
|
255104
|
-
throw await ApiError.fromHttpError(lastError, "uploading static assets");
|
|
255105
|
-
}
|
|
255106
|
-
async function buildBucketForm(bucket, filesByHash) {
|
|
255107
|
-
const formData = new FormData;
|
|
255108
|
-
for (const hash2 of bucket) {
|
|
255109
|
-
const file2 = filesByHash.get(hash2);
|
|
255110
|
-
if (!file2) {
|
|
255111
|
-
throw new InternalError(`Server requested upload of unknown asset hash: ${hash2}`);
|
|
255112
|
-
}
|
|
255113
|
-
const content = await readFile4(file2.absolutePath);
|
|
255114
|
-
formData.append(hash2, new File([content.toString("base64")], hash2, { type: file2.contentType }));
|
|
255115
|
-
}
|
|
255116
|
-
return formData;
|
|
255117
|
-
}
|
|
255118
|
-
function sleep3(ms) {
|
|
255119
|
-
return new Promise((resolve5) => setTimeout(resolve5, ms));
|
|
255120
|
-
}
|
|
255121
|
-
|
|
255122
|
-
// src/core/deployments/wrangler-config.ts
|
|
255123
|
-
import { dirname as dirname10, join as join16, resolve as resolve5 } from "node:path";
|
|
255124
|
-
var WRANGLER_REDIRECT_PATH = join16(".wrangler", "deploy", "config.json");
|
|
255125
|
-
var RedirectConfigSchema = exports_external.looseObject({
|
|
255126
|
-
configPath: exports_external.string().min(1)
|
|
255127
|
-
});
|
|
255128
|
-
var BindingArraySchema = exports_external.array(exports_external.unknown()).optional();
|
|
255129
|
-
var WranglerConfigSchema = exports_external.looseObject({
|
|
255130
|
-
name: exports_external.string().optional(),
|
|
255131
|
-
main: exports_external.string().min(1, "wrangler config is missing a 'main' entry module"),
|
|
255132
|
-
no_bundle: exports_external.boolean().optional(),
|
|
255133
|
-
rules: exports_external.array(exports_external.looseObject({ type: exports_external.string(), globs: exports_external.array(exports_external.string()) })).optional(),
|
|
255134
|
-
assets: exports_external.looseObject({
|
|
255135
|
-
directory: exports_external.string().optional(),
|
|
255136
|
-
html_handling: exports_external.string().optional(),
|
|
255137
|
-
not_found_handling: exports_external.string().optional(),
|
|
255138
|
-
run_worker_first: exports_external.union([exports_external.boolean(), exports_external.array(exports_external.string())]).optional(),
|
|
255139
|
-
headers: exports_external.string().optional(),
|
|
255140
|
-
redirects: exports_external.string().optional()
|
|
255141
|
-
}).optional(),
|
|
255142
|
-
compatibility_date: exports_external.string().optional(),
|
|
255143
|
-
compatibility_flags: exports_external.array(exports_external.string()).optional(),
|
|
255144
|
-
vars: exports_external.record(exports_external.string(), exports_external.unknown()).optional(),
|
|
255145
|
-
upload_source_maps: exports_external.boolean().optional(),
|
|
255146
|
-
kv_namespaces: BindingArraySchema,
|
|
255147
|
-
d1_databases: BindingArraySchema,
|
|
255148
|
-
r2_buckets: BindingArraySchema,
|
|
255149
|
-
durable_objects: exports_external.looseObject({ bindings: BindingArraySchema }).optional(),
|
|
255150
|
-
services: BindingArraySchema,
|
|
255151
|
-
queues: exports_external.looseObject({
|
|
255152
|
-
producers: BindingArraySchema,
|
|
255153
|
-
consumers: BindingArraySchema
|
|
255154
|
-
}).optional(),
|
|
255155
|
-
hyperdrive: BindingArraySchema,
|
|
255156
|
-
analytics_engine_datasets: BindingArraySchema,
|
|
255157
|
-
vectorize: BindingArraySchema
|
|
255158
|
-
});
|
|
255159
|
-
async function detectFullStackArtifact(projectRoot) {
|
|
255160
|
-
const redirectPath = join16(projectRoot, WRANGLER_REDIRECT_PATH);
|
|
255161
|
-
if (await pathExists(redirectPath)) {
|
|
255162
|
-
return { source: "redirect", path: redirectPath };
|
|
255163
|
-
}
|
|
255164
|
-
for (const name2 of ["wrangler.jsonc", "wrangler.json"]) {
|
|
255165
|
-
const configPath = join16(projectRoot, name2);
|
|
255166
|
-
if (await pathExists(configPath)) {
|
|
255167
|
-
return { source: "root-config", path: configPath };
|
|
255168
|
-
}
|
|
255169
|
-
}
|
|
255170
|
-
const tomlPath = join16(projectRoot, "wrangler.toml");
|
|
255171
|
-
if (await pathExists(tomlPath)) {
|
|
255172
|
-
return { source: "toml", path: tomlPath };
|
|
255173
|
-
}
|
|
255174
|
-
return null;
|
|
255175
|
-
}
|
|
255176
|
-
async function resolveWranglerConfig(projectRoot) {
|
|
255177
|
-
const artifact = await detectFullStackArtifact(projectRoot);
|
|
255178
|
-
if (!artifact) {
|
|
255179
|
-
throw new InvalidInputError("No full-stack build artifact found. Expected a .wrangler/deploy/config.json redirect file or a root wrangler.jsonc.", {
|
|
255180
|
-
hints: [{ message: "Run your framework's build command first" }]
|
|
255181
|
-
});
|
|
255182
|
-
}
|
|
255183
|
-
if (artifact.source === "toml") {
|
|
255184
|
-
throw new InvalidInputError("wrangler.toml is not supported for Base44 full-stack deploys. Convert your config to wrangler.jsonc.");
|
|
255185
|
-
}
|
|
255186
|
-
const configPath = artifact.source === "redirect" ? await resolveRedirectedConfigPath(artifact.path) : artifact.path;
|
|
255187
|
-
const parsed = await readJsonFile(configPath);
|
|
255188
|
-
const result = WranglerConfigSchema.safeParse(parsed);
|
|
255189
|
-
if (!result.success) {
|
|
255190
|
-
throw new ConfigInvalidError(`Invalid wrangler config: ${exports_external.prettifyError(result.error)}`, configPath);
|
|
255191
|
-
}
|
|
255192
|
-
const config12 = result.data;
|
|
255193
|
-
if (config12.no_bundle !== true) {
|
|
255194
|
-
throw new InvalidInputError("This framework's output requires bundling; not yet supported. Base44 full-stack deploys only support pre-bundled Workers output (no_bundle: true).");
|
|
255195
|
-
}
|
|
255196
|
-
assertNoUnsupportedBindings(config12, configPath);
|
|
255197
|
-
const configDir = dirname10(configPath);
|
|
255198
|
-
const assetsDirectory = config12.assets?.directory ? resolve5(configDir, config12.assets.directory) : null;
|
|
255199
|
-
return {
|
|
255200
|
-
configPath,
|
|
255201
|
-
configDir,
|
|
255202
|
-
name: config12.name ?? null,
|
|
255203
|
-
main: config12.main,
|
|
255204
|
-
assetsDirectory,
|
|
255205
|
-
assetsConfig: config12.assets ? toResolvedAssetsConfig(config12.assets) : null,
|
|
255206
|
-
compatibilityDate: config12.compatibility_date ?? null,
|
|
255207
|
-
compatibilityFlags: config12.compatibility_flags ?? [],
|
|
255208
|
-
vars: config12.vars ?? {},
|
|
255209
|
-
rules: (config12.rules ?? []).map((rule) => ({
|
|
255210
|
-
type: rule.type,
|
|
255211
|
-
globs: rule.globs
|
|
255212
|
-
})),
|
|
255213
|
-
uploadSourceMaps: config12.upload_source_maps ?? false
|
|
255214
|
-
};
|
|
255215
|
-
}
|
|
255216
|
-
async function resolveRedirectedConfigPath(redirectPath) {
|
|
255217
|
-
const parsed = await readJsonFile(redirectPath);
|
|
255218
|
-
const result = RedirectConfigSchema.safeParse(parsed);
|
|
255219
|
-
if (!result.success) {
|
|
255220
|
-
throw new ConfigInvalidError(`Invalid deploy redirect file: ${exports_external.prettifyError(result.error)}`, redirectPath);
|
|
255221
|
-
}
|
|
255222
|
-
const configPath = resolve5(dirname10(redirectPath), result.data.configPath);
|
|
255223
|
-
if (!await pathExists(configPath)) {
|
|
255224
|
-
throw new ConfigInvalidError(`Wrangler config referenced by ${redirectPath} does not exist: ${configPath}`, redirectPath, {
|
|
255225
|
-
hints: [{ message: "Rebuild the project to regenerate the artifact" }]
|
|
255226
|
-
});
|
|
255227
|
-
}
|
|
255228
|
-
return configPath;
|
|
255229
|
-
}
|
|
255230
|
-
function toResolvedAssetsConfig(assets) {
|
|
255231
|
-
return {
|
|
255232
|
-
htmlHandling: assets.html_handling,
|
|
255233
|
-
notFoundHandling: assets.not_found_handling,
|
|
255234
|
-
runWorkerFirst: assets.run_worker_first,
|
|
255235
|
-
headers: assets.headers,
|
|
255236
|
-
redirects: assets.redirects
|
|
255237
|
-
};
|
|
255238
|
-
}
|
|
255239
|
-
function assertNoUnsupportedBindings(config12, configPath) {
|
|
255240
|
-
const bindingSources = {
|
|
255241
|
-
kv_namespaces: config12.kv_namespaces,
|
|
255242
|
-
d1_databases: config12.d1_databases,
|
|
255243
|
-
r2_buckets: config12.r2_buckets,
|
|
255244
|
-
"durable_objects.bindings": config12.durable_objects?.bindings,
|
|
255245
|
-
services: config12.services,
|
|
255246
|
-
"queues.producers": config12.queues?.producers,
|
|
255247
|
-
"queues.consumers": config12.queues?.consumers,
|
|
255248
|
-
hyperdrive: config12.hyperdrive,
|
|
255249
|
-
analytics_engine_datasets: config12.analytics_engine_datasets,
|
|
255250
|
-
vectorize: config12.vectorize
|
|
255251
|
-
};
|
|
255252
|
-
const used = Object.entries(bindingSources).filter(([, values]) => (values?.length ?? 0) > 0).map(([name2]) => name2);
|
|
255253
|
-
if (used.length > 0) {
|
|
255254
|
-
throw new InvalidInputError(`Unsupported bindings for Base44 full-stack deploys: ${used.join(", ")}. Remove them or file a feature request.`, {
|
|
255255
|
-
hints: [{ message: `Edit the bindings in ${configPath}` }]
|
|
255256
|
-
});
|
|
255257
|
-
}
|
|
255258
|
-
}
|
|
255259
|
-
|
|
255260
|
-
// src/core/deployments/deploy.ts
|
|
255261
|
-
async function resolveGitHash(projectRoot, explicit) {
|
|
255262
|
-
const hash2 = explicit ?? await gitHead(projectRoot);
|
|
255263
|
-
if (!hash2 || !GIT_HASH_PATTERN.test(hash2)) {
|
|
255264
|
-
throw new InvalidInputError(explicit ? `'${explicit}' is not a git commit hash.` : "Full-stack deployments are addressed by the commit that produced the build, and no git commit was found.", {
|
|
255265
|
-
hints: [
|
|
255266
|
-
{
|
|
255267
|
-
message: "Run the deploy from a git checkout, or pass the commit explicitly with --git-hash."
|
|
255268
|
-
}
|
|
255269
|
-
]
|
|
255270
|
-
});
|
|
255271
|
-
}
|
|
255272
|
-
return hash2;
|
|
255273
|
-
}
|
|
255274
|
-
async function gitHead(projectRoot) {
|
|
255275
|
-
try {
|
|
255276
|
-
const { stdout } = await execa("git", ["rev-parse", "HEAD"], {
|
|
255277
|
-
cwd: projectRoot
|
|
255278
|
-
});
|
|
255279
|
-
return stdout.trim();
|
|
255280
|
-
} catch {
|
|
255281
|
-
return null;
|
|
255282
|
-
}
|
|
255283
|
-
}
|
|
255284
|
-
async function deployFullStack(options) {
|
|
255285
|
-
const { projectRoot, gitHash, progress } = options;
|
|
255286
|
-
const config12 = await resolveWranglerConfig(projectRoot);
|
|
255287
|
-
if (!config12.compatibilityFlags.includes("nodejs_compat")) {
|
|
255288
|
-
progress?.onWarning?.("The wrangler config has no 'nodejs_compat' compatibility flag; Node.js built-ins will be unavailable at runtime. Enable it in your framework's Cloudflare adapter settings if your server code needs Node APIs.");
|
|
255289
|
-
}
|
|
255290
|
-
if (config12.vars && Object.keys(config12.vars).length > 0) {
|
|
255291
|
-
progress?.onWarning?.("wrangler 'vars' are not supported and were ignored — a worker's environment comes from the app's secrets (base44 secrets set).");
|
|
255292
|
-
}
|
|
255293
|
-
const modules = await collectModules(config12);
|
|
255294
|
-
let assets = { manifest: {}, filesByHash: new Map };
|
|
255295
|
-
if (config12.assetsDirectory && await pathExists(config12.assetsDirectory)) {
|
|
255296
|
-
assets = await buildAssetManifest(config12.assetsDirectory, getAppContext().id);
|
|
255297
|
-
}
|
|
255298
|
-
const created = await createDeployment({
|
|
255299
|
-
git_hash: gitHash,
|
|
255300
|
-
config: {
|
|
255301
|
-
main: config12.main,
|
|
255302
|
-
compatibility_date: config12.compatibilityDate,
|
|
255303
|
-
compatibility_flags: config12.compatibilityFlags,
|
|
255304
|
-
assets: buildAssetsConfig(config12.assetsConfig, progress)
|
|
255305
|
-
},
|
|
255306
|
-
asset_manifest: assets.manifest
|
|
255307
|
-
});
|
|
255308
|
-
const totalAssets = Object.keys(assets.manifest).length;
|
|
255309
|
-
const newAssets = new Set(created.assetBuckets.flat()).size;
|
|
255310
|
-
progress?.onAssets?.({ totalAssets, newAssets });
|
|
255311
|
-
const completionJwt = await uploadAssetBuckets(created.deploymentId, created.assetBuckets, assets.filesByHash, progress?.onAssetUpload);
|
|
255312
|
-
progress?.onWorker?.({ moduleCount: modules.length });
|
|
255313
|
-
const finalized = await finalizeDeployment(created.deploymentId, completionJwt, modules);
|
|
255314
|
-
return { deploymentId: finalized.deploymentId, gitHash };
|
|
255315
|
-
}
|
|
255316
|
-
function buildAssetsConfig(assetsConfig, progress) {
|
|
255317
|
-
if (!assetsConfig)
|
|
255318
|
-
return null;
|
|
255319
|
-
if (assetsConfig.headers || assetsConfig.redirects) {
|
|
255320
|
-
progress?.onWarning?.("_headers/_redirects files are not supported yet and were ignored for this deploy.");
|
|
255321
|
-
}
|
|
255322
|
-
let runWorkerFirst;
|
|
255323
|
-
if (Array.isArray(assetsConfig.runWorkerFirst)) {
|
|
255324
|
-
progress?.onWarning?.("'run_worker_first' route patterns are not supported yet and were ignored for this deploy.");
|
|
255325
|
-
} else {
|
|
255326
|
-
runWorkerFirst = assetsConfig.runWorkerFirst;
|
|
255327
|
-
}
|
|
255328
|
-
return {
|
|
255329
|
-
html_handling: assetsConfig.htmlHandling,
|
|
255330
|
-
not_found_handling: assetsConfig.notFoundHandling,
|
|
255331
|
-
run_worker_first: runWorkerFirst
|
|
255332
|
-
};
|
|
255333
|
-
}
|
|
255334
255428
|
// src/core/utils/dependencies.ts
|
|
255335
255429
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
255336
255430
|
function verifyDenoInstalled(context) {
|
|
@@ -255419,7 +255513,7 @@ async function pullAction({
|
|
|
255419
255513
|
runTask: runTask2
|
|
255420
255514
|
}) {
|
|
255421
255515
|
const { project: project2 } = await readProjectConfig();
|
|
255422
|
-
const dir =
|
|
255516
|
+
const dir = join18(dirname11(project2.configPath), project2.agentSkillsDir);
|
|
255423
255517
|
const remote = await runTask2("Fetching agent skills from Base44", () => fetchAgentSkills(), {
|
|
255424
255518
|
successMessage: "Agent skills fetched successfully",
|
|
255425
255519
|
errorMessage: "Failed to fetch agent skills"
|
|
@@ -255475,14 +255569,14 @@ function getAgentSkillsCommand() {
|
|
|
255475
255569
|
}
|
|
255476
255570
|
|
|
255477
255571
|
// src/cli/commands/agents/pull.ts
|
|
255478
|
-
import { dirname as dirname12, join as
|
|
255572
|
+
import { dirname as dirname12, join as join19 } from "node:path";
|
|
255479
255573
|
async function pullAgentsAction({
|
|
255480
255574
|
log,
|
|
255481
255575
|
runTask: runTask2
|
|
255482
255576
|
}) {
|
|
255483
255577
|
const { project: project2 } = await readProjectConfig();
|
|
255484
255578
|
const configDir = dirname12(project2.configPath);
|
|
255485
|
-
const agentsDir =
|
|
255579
|
+
const agentsDir = join19(configDir, project2.agentsDir);
|
|
255486
255580
|
const remoteAgents = await runTask2("Fetching agents from Base44", async () => {
|
|
255487
255581
|
return await fetchAgents();
|
|
255488
255582
|
}, {
|
|
@@ -255552,12 +255646,12 @@ function getAgentsCommand() {
|
|
|
255552
255646
|
}
|
|
255553
255647
|
|
|
255554
255648
|
// src/cli/commands/auth/password-login.ts
|
|
255555
|
-
import { dirname as dirname13, join as
|
|
255649
|
+
import { dirname as dirname13, join as join20 } from "node:path";
|
|
255556
255650
|
async function passwordLoginAction({ log, runTask: runTask2 }, action) {
|
|
255557
255651
|
const shouldEnable = action === "enable";
|
|
255558
255652
|
const { project: project2 } = await readProjectConfig();
|
|
255559
255653
|
const configDir = dirname13(project2.configPath);
|
|
255560
|
-
const authDir =
|
|
255654
|
+
const authDir = join20(configDir, project2.authDir);
|
|
255561
255655
|
const updated = await runTask2("Updating local auth config", async () => {
|
|
255562
255656
|
const current = await readAuthConfig(authDir) ?? DEFAULT_AUTH_CONFIG;
|
|
255563
255657
|
const merged = { ...current, enableUsernamePassword: shouldEnable };
|
|
@@ -255577,14 +255671,14 @@ function getPasswordLoginCommand() {
|
|
|
255577
255671
|
}
|
|
255578
255672
|
|
|
255579
255673
|
// src/cli/commands/auth/pull.ts
|
|
255580
|
-
import { dirname as dirname14, join as
|
|
255674
|
+
import { dirname as dirname14, join as join21 } from "node:path";
|
|
255581
255675
|
async function pullAuthAction({
|
|
255582
255676
|
log,
|
|
255583
255677
|
runTask: runTask2
|
|
255584
255678
|
}) {
|
|
255585
255679
|
const { project: project2 } = await readProjectConfig();
|
|
255586
255680
|
const configDir = dirname14(project2.configPath);
|
|
255587
|
-
const authDir =
|
|
255681
|
+
const authDir = join21(configDir, project2.authDir);
|
|
255588
255682
|
const remoteConfig = await runTask2("Fetching auth config from Base44", async () => {
|
|
255589
255683
|
return await pullAuthConfig();
|
|
255590
255684
|
}, {
|
|
@@ -255648,7 +255742,7 @@ function getAuthPushCommand() {
|
|
|
255648
255742
|
}
|
|
255649
255743
|
|
|
255650
255744
|
// src/cli/commands/auth/social-login.ts
|
|
255651
|
-
import { dirname as dirname15, join as
|
|
255745
|
+
import { dirname as dirname15, join as join22, resolve as resolve7 } from "node:path";
|
|
255652
255746
|
var PROVIDER_LABELS = {
|
|
255653
255747
|
google: "Google",
|
|
255654
255748
|
microsoft: "Microsoft",
|
|
@@ -255688,7 +255782,7 @@ async function socialLoginAction({ log, isNonInteractive, runTask: runTask2 }, p
|
|
|
255688
255782
|
let clientSecret;
|
|
255689
255783
|
if (useCustomOAuth && oauth && oauthCli && hasSecretOptions(options)) {
|
|
255690
255784
|
if (options.envFile) {
|
|
255691
|
-
const secrets = await parseEnvFile(
|
|
255785
|
+
const secrets = await parseEnvFile(resolve7(options.envFile));
|
|
255692
255786
|
const value = secrets[oauthCli.envVar];
|
|
255693
255787
|
if (!value) {
|
|
255694
255788
|
throw new InvalidInputError(`Key "${oauthCli.envVar}" not found in ${options.envFile}.`);
|
|
@@ -255719,7 +255813,7 @@ async function socialLoginAction({ log, isNonInteractive, runTask: runTask2 }, p
|
|
|
255719
255813
|
}
|
|
255720
255814
|
const { project: project2 } = await readProjectConfig();
|
|
255721
255815
|
const configDir = dirname15(project2.configPath);
|
|
255722
|
-
const authDir =
|
|
255816
|
+
const authDir = join22(configDir, project2.authDir);
|
|
255723
255817
|
const { config: updated } = await runTask2("Updating local auth config", async () => updateSocialLoginConfig(authDir, provider, shouldEnable, useCustomOAuth && options.clientId ? { clientId: options.clientId } : undefined));
|
|
255724
255818
|
if (clientSecret) {
|
|
255725
255819
|
await runTask2("Saving client secret", async () => pushCustomOAuthSecret(provider, clientSecret));
|
|
@@ -255744,7 +255838,7 @@ function getSocialLoginCommand() {
|
|
|
255744
255838
|
}
|
|
255745
255839
|
|
|
255746
255840
|
// src/cli/commands/auth/sso.ts
|
|
255747
|
-
import { dirname as dirname16, join as
|
|
255841
|
+
import { dirname as dirname16, join as join23, resolve as resolve8 } from "node:path";
|
|
255748
255842
|
var SSOConfigFileSchema = exports_external.object({
|
|
255749
255843
|
provider: exports_external.enum(Object.values(KNOWN_SSO_PROVIDERS)),
|
|
255750
255844
|
clientId: exports_external.string(),
|
|
@@ -255760,7 +255854,7 @@ var SSOConfigFileSchema = exports_external.object({
|
|
|
255760
255854
|
ssoName: exports_external.string().optional()
|
|
255761
255855
|
});
|
|
255762
255856
|
async function loadSSOConfigFile(filePath) {
|
|
255763
|
-
const resolved =
|
|
255857
|
+
const resolved = resolve8(filePath);
|
|
255764
255858
|
const raw2 = await readJsonFile(resolved);
|
|
255765
255859
|
const result = SSOConfigFileSchema.safeParse(raw2);
|
|
255766
255860
|
if (!result.success) {
|
|
@@ -255848,7 +255942,7 @@ async function ssoEnableAction({ isNonInteractive, runTask: runTask2 }, options)
|
|
|
255848
255942
|
}
|
|
255849
255943
|
let clientSecret;
|
|
255850
255944
|
if (merged.envFile && !merged.clientSecret) {
|
|
255851
|
-
const secrets2 = await parseEnvFile(
|
|
255945
|
+
const secrets2 = await parseEnvFile(resolve8(merged.envFile));
|
|
255852
255946
|
const value = secrets2.sso_client_secret;
|
|
255853
255947
|
if (!value) {
|
|
255854
255948
|
throw new InvalidInputError(`Key "sso_client_secret" not found in ${merged.envFile}.`);
|
|
@@ -255908,7 +256002,7 @@ async function ssoEnableAction({ isNonInteractive, runTask: runTask2 }, options)
|
|
|
255908
256002
|
}
|
|
255909
256003
|
const { project: project2 } = await readProjectConfig();
|
|
255910
256004
|
const configDir = dirname16(project2.configPath);
|
|
255911
|
-
const authDir =
|
|
256005
|
+
const authDir = join23(configDir, project2.authDir);
|
|
255912
256006
|
await runTask2("Updating local auth config", async () => updateSSOConfig(authDir, provider, true));
|
|
255913
256007
|
await runTask2("Saving SSO credentials", async () => pushSSOSecrets(secrets));
|
|
255914
256008
|
return {
|
|
@@ -255924,7 +256018,7 @@ async function ssoDisableAction({ log, runTask: runTask2 }, options) {
|
|
|
255924
256018
|
}
|
|
255925
256019
|
const { project: project2 } = await readProjectConfig();
|
|
255926
256020
|
const configDir = dirname16(project2.configPath);
|
|
255927
|
-
const authDir =
|
|
256021
|
+
const authDir = join23(configDir, project2.authDir);
|
|
255928
256022
|
const updated = await runTask2("Updating local auth config", async () => updateSSOConfig(authDir, null, false));
|
|
255929
256023
|
await runTask2("Removing SSO credentials", async () => deleteSSOSecrets());
|
|
255930
256024
|
if (!hasAnyLoginMethod(updated)) {
|
|
@@ -256486,19 +256580,19 @@ var baseOpen = async (options) => {
|
|
|
256486
256580
|
}
|
|
256487
256581
|
const subprocess = childProcess3.spawn(command2, cliArguments, childProcessOptions);
|
|
256488
256582
|
if (options.wait) {
|
|
256489
|
-
return new Promise((
|
|
256583
|
+
return new Promise((resolve9, reject) => {
|
|
256490
256584
|
subprocess.once("error", reject);
|
|
256491
256585
|
subprocess.once("close", (exitCode) => {
|
|
256492
256586
|
if (!options.allowNonzeroExitCode && exitCode !== 0) {
|
|
256493
256587
|
reject(new Error(`Exited with code ${exitCode}`));
|
|
256494
256588
|
return;
|
|
256495
256589
|
}
|
|
256496
|
-
|
|
256590
|
+
resolve9(subprocess);
|
|
256497
256591
|
});
|
|
256498
256592
|
});
|
|
256499
256593
|
}
|
|
256500
256594
|
if (isFallbackAttempt) {
|
|
256501
|
-
return new Promise((
|
|
256595
|
+
return new Promise((resolve9, reject) => {
|
|
256502
256596
|
subprocess.once("error", reject);
|
|
256503
256597
|
subprocess.once("spawn", () => {
|
|
256504
256598
|
subprocess.once("close", (exitCode) => {
|
|
@@ -256508,17 +256602,17 @@ var baseOpen = async (options) => {
|
|
|
256508
256602
|
return;
|
|
256509
256603
|
}
|
|
256510
256604
|
subprocess.unref();
|
|
256511
|
-
|
|
256605
|
+
resolve9(subprocess);
|
|
256512
256606
|
});
|
|
256513
256607
|
});
|
|
256514
256608
|
});
|
|
256515
256609
|
}
|
|
256516
256610
|
subprocess.unref();
|
|
256517
|
-
return new Promise((
|
|
256611
|
+
return new Promise((resolve9, reject) => {
|
|
256518
256612
|
subprocess.once("error", reject);
|
|
256519
256613
|
subprocess.once("spawn", () => {
|
|
256520
256614
|
subprocess.off("error", reject);
|
|
256521
|
-
|
|
256615
|
+
resolve9(subprocess);
|
|
256522
256616
|
});
|
|
256523
256617
|
});
|
|
256524
256618
|
};
|
|
@@ -256781,13 +256875,13 @@ function getConnectorsListAvailableCommand() {
|
|
|
256781
256875
|
}
|
|
256782
256876
|
|
|
256783
256877
|
// src/cli/commands/connectors/pull.ts
|
|
256784
|
-
import { dirname as dirname17, join as
|
|
256878
|
+
import { dirname as dirname17, join as join24, resolve as resolve9 } from "node:path";
|
|
256785
256879
|
async function resolveConnectorsDir(options) {
|
|
256786
256880
|
if (!getAppContext().projectRoot) {
|
|
256787
|
-
return
|
|
256881
|
+
return resolve9(options.dir ?? "connectors");
|
|
256788
256882
|
}
|
|
256789
256883
|
const { project: project2 } = await readProjectConfig();
|
|
256790
|
-
return
|
|
256884
|
+
return join24(dirname17(project2.configPath), project2.connectorsDir);
|
|
256791
256885
|
}
|
|
256792
256886
|
async function pullConnectorsAction({ log, runTask: runTask2, jsonMode }, options) {
|
|
256793
256887
|
const connectorsDir = await resolveConnectorsDir(options);
|
|
@@ -256828,10 +256922,10 @@ function getConnectorsPullCommand() {
|
|
|
256828
256922
|
}
|
|
256829
256923
|
|
|
256830
256924
|
// src/cli/commands/connectors/push.ts
|
|
256831
|
-
import { resolve as
|
|
256925
|
+
import { resolve as resolve10 } from "node:path";
|
|
256832
256926
|
async function readConnectorsToPush(options) {
|
|
256833
256927
|
if (!getAppContext().projectRoot) {
|
|
256834
|
-
return readAllConnectors(
|
|
256928
|
+
return readAllConnectors(resolve10(options.dir ?? "connectors"));
|
|
256835
256929
|
}
|
|
256836
256930
|
const { connectors } = await readProjectConfig();
|
|
256837
256931
|
return connectors;
|
|
@@ -257195,11 +257289,11 @@ function getListCommand() {
|
|
|
257195
257289
|
}
|
|
257196
257290
|
|
|
257197
257291
|
// src/cli/commands/functions/pull.ts
|
|
257198
|
-
import { dirname as dirname18, join as
|
|
257292
|
+
import { dirname as dirname18, join as join25 } from "node:path";
|
|
257199
257293
|
async function pullFunctionsAction({ log, runTask: runTask2 }, name2) {
|
|
257200
257294
|
const { project: project2, functions } = await readProjectConfig();
|
|
257201
257295
|
const configDir = dirname18(project2.configPath);
|
|
257202
|
-
const functionsDir =
|
|
257296
|
+
const functionsDir = join25(configDir, project2.functionsDir);
|
|
257203
257297
|
const pluginFunctionNames = new Set(functions.filter((fn) => fn.source.type === "plugin").map((fn) => fn.name));
|
|
257204
257298
|
const remoteFunctions = await runTask2("Fetching functions from Base44", async () => {
|
|
257205
257299
|
const { functions: functions2 } = await listDeployedFunctions();
|
|
@@ -257257,12 +257351,86 @@ function getFunctionsCommand() {
|
|
|
257257
257351
|
return new Command("functions").description("Manage backend functions").addCommand(getDeployCommand()).addCommand(getDeleteCommand()).addCommand(getListCommand()).addCommand(getPullCommand());
|
|
257258
257352
|
}
|
|
257259
257353
|
|
|
257354
|
+
// src/cli/commands/project/site-build.ts
|
|
257355
|
+
async function runSiteBuild({ runTask: runTask2 }, { root, buildCommand, appId }) {
|
|
257356
|
+
if (!buildCommand) {
|
|
257357
|
+
throw new ConfigNotFoundError("No site build command found.", {
|
|
257358
|
+
hints: [
|
|
257359
|
+
{
|
|
257360
|
+
message: `Add 'site.buildCommand' to your config.jsonc (e.g., "site": { "buildCommand": "npm run build" })`
|
|
257361
|
+
}
|
|
257362
|
+
]
|
|
257363
|
+
});
|
|
257364
|
+
}
|
|
257365
|
+
await runTask2("Building site...", () => execa({
|
|
257366
|
+
cwd: root,
|
|
257367
|
+
shell: true,
|
|
257368
|
+
env: { VITE_BASE44_APP_ID: appId }
|
|
257369
|
+
})`${buildCommand}`, {
|
|
257370
|
+
successMessage: "Site built successfully",
|
|
257371
|
+
errorMessage: "Build failed"
|
|
257372
|
+
});
|
|
257373
|
+
}
|
|
257374
|
+
async function maybeBuildBeforeDeploy(ctx, project2, build) {
|
|
257375
|
+
if (!ctx.app) {
|
|
257376
|
+
return;
|
|
257377
|
+
}
|
|
257378
|
+
if (build === true) {
|
|
257379
|
+
await runSiteBuild(ctx, {
|
|
257380
|
+
root: project2.root,
|
|
257381
|
+
buildCommand: project2.site?.buildCommand,
|
|
257382
|
+
appId: ctx.app.id
|
|
257383
|
+
});
|
|
257384
|
+
return;
|
|
257385
|
+
}
|
|
257386
|
+
if (build === false || !project2.site?.outputDirectory) {
|
|
257387
|
+
return;
|
|
257388
|
+
}
|
|
257389
|
+
const shouldBuild = await shouldAskToBuild(ctx.isNonInteractive, project2.site.buildCommand);
|
|
257390
|
+
if (shouldBuild) {
|
|
257391
|
+
await runSiteBuild(ctx, {
|
|
257392
|
+
root: project2.root,
|
|
257393
|
+
buildCommand: project2.site.buildCommand,
|
|
257394
|
+
appId: ctx.app.id
|
|
257395
|
+
});
|
|
257396
|
+
}
|
|
257397
|
+
}
|
|
257398
|
+
async function shouldAskToBuild(isNonInteractive, buildCommand) {
|
|
257399
|
+
if (!buildCommand || isNonInteractive) {
|
|
257400
|
+
return false;
|
|
257401
|
+
}
|
|
257402
|
+
const answer = await Re({
|
|
257403
|
+
message: `Build the site first? (runs '${buildCommand}' with your app id)`
|
|
257404
|
+
});
|
|
257405
|
+
return !Ct(answer) && answer;
|
|
257406
|
+
}
|
|
257407
|
+
|
|
257408
|
+
// src/cli/commands/project/build.ts
|
|
257409
|
+
async function buildAction(ctx) {
|
|
257410
|
+
const { app } = ctx;
|
|
257411
|
+
if (!app?.projectRoot) {
|
|
257412
|
+
throw new ConfigInvalidError("base44 build requires a linked local project. Run it from a project with base44/.app.jsonc.");
|
|
257413
|
+
}
|
|
257414
|
+
const { project: project2 } = await readProjectConfig(app.projectRoot);
|
|
257415
|
+
await runSiteBuild(ctx, {
|
|
257416
|
+
root: project2.root,
|
|
257417
|
+
buildCommand: project2.site?.buildCommand,
|
|
257418
|
+
appId: app.id
|
|
257419
|
+
});
|
|
257420
|
+
return {
|
|
257421
|
+
outroMessage: `Site built with app id ${theme.styles.bold(app.id)}`
|
|
257422
|
+
};
|
|
257423
|
+
}
|
|
257424
|
+
function getBuildCommand() {
|
|
257425
|
+
return new Base44Command("build").description("Build the site with the Base44 app id injected").action(buildAction);
|
|
257426
|
+
}
|
|
257427
|
+
|
|
257260
257428
|
// src/cli/commands/project/create.ts
|
|
257261
|
-
import { basename as basename4, resolve as
|
|
257429
|
+
import { basename as basename4, resolve as resolve11 } from "node:path";
|
|
257262
257430
|
var import_kebabCase = __toESM(require_kebabCase(), 1);
|
|
257263
257431
|
|
|
257264
257432
|
// src/cli/commands/project/scaffold-shared.ts
|
|
257265
|
-
import { join as
|
|
257433
|
+
import { join as join26 } from "node:path";
|
|
257266
257434
|
var DEFAULT_TEMPLATE_ID = "backend-only";
|
|
257267
257435
|
async function getTemplateById(templateId) {
|
|
257268
257436
|
const templates = await listTemplates();
|
|
@@ -257321,7 +257489,7 @@ async function completeProjectSetup({
|
|
|
257321
257489
|
updateMessage("Building project...");
|
|
257322
257490
|
await execa({ cwd: resolvedPath, shell: true })`${buildCommand}`;
|
|
257323
257491
|
updateMessage("Deploying site...");
|
|
257324
|
-
return await deploySite(
|
|
257492
|
+
return await deploySite(join26(resolvedPath, outputDirectory));
|
|
257325
257493
|
}, {
|
|
257326
257494
|
successMessage: theme.colors.base44Orange("Site deployed successfully"),
|
|
257327
257495
|
errorMessage: "Failed to deploy site"
|
|
@@ -257450,7 +257618,7 @@ async function createInteractive(options, ctx) {
|
|
|
257450
257618
|
}, ctx);
|
|
257451
257619
|
}
|
|
257452
257620
|
async function createNonInteractive(options, ctx) {
|
|
257453
|
-
ctx.log.info(`Creating a new project at ${
|
|
257621
|
+
ctx.log.info(`Creating a new project at ${resolve11(options.path)}`);
|
|
257454
257622
|
const template2 = await getTemplateById(options.template ?? DEFAULT_TEMPLATE_ID);
|
|
257455
257623
|
return await executeCreate({
|
|
257456
257624
|
template: template2,
|
|
@@ -257474,7 +257642,7 @@ async function executeCreate({
|
|
|
257474
257642
|
}, ctx) {
|
|
257475
257643
|
const { log, runTask: runTask2 } = ctx;
|
|
257476
257644
|
const name2 = rawName.trim();
|
|
257477
|
-
const resolvedPath =
|
|
257645
|
+
const resolvedPath = resolve11(projectPath);
|
|
257478
257646
|
const organizationId = await resolveWorkspaceId(ctx, flagWorkspaceId, isInteractive);
|
|
257479
257647
|
const { projectId } = await runTask2("Setting up your project...", async () => {
|
|
257480
257648
|
return await createProjectFiles({
|
|
@@ -257524,21 +257692,72 @@ Examples:
|
|
|
257524
257692
|
$ base44 create my-app --workspace 507f1f77bcf86cd799439011 Creates a base44 project in the given workspace`).hook("preAction", validateCreateOptions).action(createAction);
|
|
257525
257693
|
}
|
|
257526
257694
|
|
|
257695
|
+
// src/cli/commands/site/run-app-deploy.ts
|
|
257696
|
+
var TASK_LABELS = {
|
|
257697
|
+
"full-stack": {
|
|
257698
|
+
start: "Deploying full-stack app...",
|
|
257699
|
+
success: theme.colors.base44Orange("Full-stack app deployed"),
|
|
257700
|
+
error: "Full-stack deploy failed"
|
|
257701
|
+
},
|
|
257702
|
+
"static-deployment": {
|
|
257703
|
+
start: "Deploying site...",
|
|
257704
|
+
success: "Site deployed",
|
|
257705
|
+
error: "Site deploy failed"
|
|
257706
|
+
},
|
|
257707
|
+
static: {
|
|
257708
|
+
start: "Creating archive and deploying site...",
|
|
257709
|
+
success: "Site deployed successfully",
|
|
257710
|
+
error: "Deployment failed"
|
|
257711
|
+
}
|
|
257712
|
+
};
|
|
257713
|
+
async function runAppSiteDeploy({ runTask: runTask2, log }, target, options = {}) {
|
|
257714
|
+
const kind = await detectAppDeployKind(target);
|
|
257715
|
+
if (kind === "none")
|
|
257716
|
+
return { kind: "none" };
|
|
257717
|
+
const labels = TASK_LABELS[kind];
|
|
257718
|
+
const progressLines = [];
|
|
257719
|
+
const warnings = [];
|
|
257720
|
+
const result = await runTask2(labels.start, async (updateMessage) => await deployAppSite(target, {
|
|
257721
|
+
gitHash: options.gitHash,
|
|
257722
|
+
progress: {
|
|
257723
|
+
onWarning: (message) => {
|
|
257724
|
+
warnings.push(message);
|
|
257725
|
+
},
|
|
257726
|
+
onAssets: ({ totalAssets, newAssets }) => {
|
|
257727
|
+
const line = `Found ${totalAssets} static assets (${newAssets} new)`;
|
|
257728
|
+
progressLines.push(line);
|
|
257729
|
+
updateMessage(line);
|
|
257730
|
+
},
|
|
257731
|
+
onAssetUpload: ({ uploadedFiles, totalFiles }) => {
|
|
257732
|
+
updateMessage(`Uploaded ${uploadedFiles} of ${totalFiles} assets`);
|
|
257733
|
+
},
|
|
257734
|
+
onWorker: ({ moduleCount }) => {
|
|
257735
|
+
updateMessage(`Deploying worker (${moduleCount} modules)…`);
|
|
257736
|
+
}
|
|
257737
|
+
}
|
|
257738
|
+
}), {
|
|
257739
|
+
successMessage: labels.success,
|
|
257740
|
+
errorMessage: labels.error
|
|
257741
|
+
});
|
|
257742
|
+
for (const line of progressLines) {
|
|
257743
|
+
log.message(theme.styles.dim(line));
|
|
257744
|
+
}
|
|
257745
|
+
for (const warning of warnings) {
|
|
257746
|
+
log.warn(warning);
|
|
257747
|
+
}
|
|
257748
|
+
return result;
|
|
257749
|
+
}
|
|
257750
|
+
|
|
257527
257751
|
// src/cli/commands/project/deploy.ts
|
|
257528
|
-
import { resolve as resolve11 } from "node:path";
|
|
257529
257752
|
async function deployAction(ctx, options = {}) {
|
|
257530
257753
|
const { isNonInteractive, log } = ctx;
|
|
257531
257754
|
if (isNonInteractive && !options.yes) {
|
|
257532
257755
|
throw new InvalidInputError("--yes is required in non-interactive mode");
|
|
257533
257756
|
}
|
|
257534
|
-
if (options.build && options.prebuilt) {
|
|
257535
|
-
throw new InvalidInputError("--build and --prebuilt cannot be combined.");
|
|
257536
|
-
}
|
|
257537
257757
|
const projectData = await readProjectConfig(options.projectRoot);
|
|
257538
257758
|
const { project: project2, entities, functions, agents, connectors, authConfig } = projectData;
|
|
257539
|
-
|
|
257540
|
-
|
|
257541
|
-
if (!hasResourcesToDeploy(projectData) && !isFullStackCandidate) {
|
|
257759
|
+
const plannedSite = await detectAppDeployKind(project2);
|
|
257760
|
+
if (!hasResourcesToDeploy(projectData) && plannedSite === "none") {
|
|
257542
257761
|
return {
|
|
257543
257762
|
outroMessage: "No resources found to deploy"
|
|
257544
257763
|
};
|
|
@@ -257562,7 +257781,7 @@ async function deployAction(ctx, options = {}) {
|
|
|
257562
257781
|
if (project2.visibility) {
|
|
257563
257782
|
summaryLines.push(` - Visibility: ${project2.visibility}`);
|
|
257564
257783
|
}
|
|
257565
|
-
if (
|
|
257784
|
+
if (plannedSite === "full-stack") {
|
|
257566
257785
|
summaryLines.push(" - Full-stack app");
|
|
257567
257786
|
} else if (project2.site?.outputDirectory) {
|
|
257568
257787
|
summaryLines.push(` - Site from ${project2.site.outputDirectory}`);
|
|
@@ -257582,6 +257801,7 @@ ${summaryLines.join(`
|
|
|
257582
257801
|
${summaryLines.join(`
|
|
257583
257802
|
`)}`);
|
|
257584
257803
|
}
|
|
257804
|
+
await maybeBuildBeforeDeploy(ctx, project2, options.build);
|
|
257585
257805
|
let functionCompleted = 0;
|
|
257586
257806
|
const functionTotal = functions.length;
|
|
257587
257807
|
const result = await deployAll(projectData, {
|
|
@@ -257598,16 +257818,9 @@ ${summaryLines.join(`
|
|
|
257598
257818
|
formatDeployResult(r, log);
|
|
257599
257819
|
}
|
|
257600
257820
|
});
|
|
257601
|
-
await
|
|
257602
|
-
|
|
257603
|
-
|
|
257604
|
-
let fullStackResult;
|
|
257605
|
-
if (fullStackArtifact) {
|
|
257606
|
-
fullStackResult = await runFullStackDeploy(ctx, project2.root, options);
|
|
257607
|
-
} else if (project2.site?.outputDirectory) {
|
|
257608
|
-
const outputDir = resolve11(project2.root, project2.site.outputDirectory);
|
|
257609
|
-
({ appUrl } = await deploySite(outputDir));
|
|
257610
|
-
}
|
|
257821
|
+
const siteResult = await runAppSiteDeploy(ctx, project2, {
|
|
257822
|
+
gitHash: options.gitHash
|
|
257823
|
+
});
|
|
257611
257824
|
const connectorResults = result.connectorResults ?? [];
|
|
257612
257825
|
await handleOAuthConnectors(connectorResults, isNonInteractive, options, log);
|
|
257613
257826
|
const stripeResult = connectorResults.find((r) => r.type === "stripe");
|
|
@@ -257615,80 +257828,27 @@ ${summaryLines.join(`
|
|
|
257615
257828
|
printStripeResult(stripeResult, log);
|
|
257616
257829
|
}
|
|
257617
257830
|
log.message(`${theme.styles.header("Dashboard")}: ${theme.colors.links(getDashboardUrl())}`);
|
|
257618
|
-
if (
|
|
257619
|
-
log.message(`${theme.styles.header("App URL")}: ${theme.colors.links(appUrl)}`);
|
|
257831
|
+
if (siteResult.kind === "static") {
|
|
257832
|
+
log.message(`${theme.styles.header("App URL")}: ${theme.colors.links(siteResult.appUrl)}`);
|
|
257620
257833
|
}
|
|
257621
|
-
|
|
257622
|
-
|
|
257834
|
+
const deployment = siteResult.kind === "full-stack" || siteResult.kind === "static-deployment" ? siteResult : undefined;
|
|
257835
|
+
if (deployment) {
|
|
257836
|
+
printDeploymentSummary(deployment, log);
|
|
257623
257837
|
}
|
|
257624
257838
|
return {
|
|
257625
257839
|
outroMessage: "App deployed successfully",
|
|
257626
|
-
stdout: ctx.jsonMode &&
|
|
257627
|
-
deploymentId:
|
|
257628
|
-
gitHash:
|
|
257840
|
+
stdout: ctx.jsonMode && deployment ? `${JSON.stringify({
|
|
257841
|
+
deploymentId: deployment.deploymentId,
|
|
257842
|
+
gitHash: deployment.gitHash
|
|
257629
257843
|
}, null, 2)}
|
|
257630
257844
|
` : undefined
|
|
257631
257845
|
};
|
|
257632
257846
|
}
|
|
257633
|
-
|
|
257634
|
-
const site2 = project2.site;
|
|
257635
|
-
if (!site2?.buildCommand || options.prebuilt)
|
|
257636
|
-
return;
|
|
257637
|
-
const artifactPresent = fullStackArtifact !== null || (site2.outputDirectory ? await pathExists(resolve11(project2.root, site2.outputDirectory)) : false);
|
|
257638
|
-
if (artifactPresent && !options.build)
|
|
257639
|
-
return;
|
|
257640
|
-
const { installCommand, buildCommand } = site2;
|
|
257641
|
-
await runTask2(installCommand ? "Installing dependencies..." : "Building project...", async (updateMessage) => {
|
|
257642
|
-
if (installCommand) {
|
|
257643
|
-
await execa({ cwd: project2.root, shell: true })`${installCommand}`;
|
|
257644
|
-
updateMessage("Building project...");
|
|
257645
|
-
}
|
|
257646
|
-
await execa({ cwd: project2.root, shell: true })`${buildCommand}`;
|
|
257647
|
-
}, {
|
|
257648
|
-
successMessage: "Project built successfully",
|
|
257649
|
-
errorMessage: "Failed to build project"
|
|
257650
|
-
});
|
|
257651
|
-
}
|
|
257652
|
-
async function runFullStackDeploy({ runTask: runTask2, log }, projectRoot, options) {
|
|
257653
|
-
const gitHash = await resolveGitHash(projectRoot, options.gitHash);
|
|
257654
|
-
const progressLines = [];
|
|
257655
|
-
const warnings = [];
|
|
257656
|
-
const deployment = await runTask2("Deploying full-stack app...", async (updateMessage) => await deployFullStack({
|
|
257657
|
-
projectRoot,
|
|
257658
|
-
gitHash,
|
|
257659
|
-
progress: {
|
|
257660
|
-
onWarning: (message) => {
|
|
257661
|
-
warnings.push(message);
|
|
257662
|
-
},
|
|
257663
|
-
onAssets: ({ totalAssets, newAssets }) => {
|
|
257664
|
-
const line = `Found ${totalAssets} static assets (${newAssets} new)`;
|
|
257665
|
-
progressLines.push(line);
|
|
257666
|
-
updateMessage(line);
|
|
257667
|
-
},
|
|
257668
|
-
onAssetUpload: ({ uploadedFiles, totalFiles }) => {
|
|
257669
|
-
updateMessage(`Uploaded ${uploadedFiles} of ${totalFiles} assets`);
|
|
257670
|
-
},
|
|
257671
|
-
onWorker: ({ moduleCount }) => {
|
|
257672
|
-
updateMessage(`Deploying worker (${moduleCount} modules)…`);
|
|
257673
|
-
}
|
|
257674
|
-
}
|
|
257675
|
-
}), {
|
|
257676
|
-
successMessage: theme.colors.base44Orange("Full-stack app deployed"),
|
|
257677
|
-
errorMessage: "Full-stack deploy failed"
|
|
257678
|
-
});
|
|
257679
|
-
for (const line of progressLines) {
|
|
257680
|
-
log.message(theme.styles.dim(line));
|
|
257681
|
-
}
|
|
257682
|
-
for (const warning of warnings) {
|
|
257683
|
-
log.warn(warning);
|
|
257684
|
-
}
|
|
257685
|
-
return deployment;
|
|
257686
|
-
}
|
|
257687
|
-
function printFullStackSummary(deployment, log) {
|
|
257847
|
+
function printDeploymentSummary(deployment, log) {
|
|
257688
257848
|
log.message(`${theme.styles.header("Deployment")}: ${deployment.deploymentId} ${theme.styles.dim(`(commit ${deployment.gitHash.slice(0, 12)})`)}`);
|
|
257689
257849
|
}
|
|
257690
257850
|
function getDeployCommand2() {
|
|
257691
|
-
return new Base44Command("deploy").description("Deploy all project resources (entities, functions, agents, connectors, and site)").option("-y, --yes", "Skip confirmation prompt").option("--git-hash <hash>", "Commit the
|
|
257851
|
+
return new Base44Command("deploy").description("Deploy all project resources (entities, functions, agents, connectors, and site)").option("-y, --yes", "Skip confirmation prompt").option("--git-hash <hash>", "Commit the build came from (defaults to the checkout's HEAD)").option("--build", "Build the site before deploying (skips the prompt)").option("--no-build", "Deploy without building (skips the prompt)").action(deployAction);
|
|
257692
257852
|
}
|
|
257693
257853
|
async function handleOAuthConnectors(connectorResults, isNonInteractive, options, log) {
|
|
257694
257854
|
const needsOAuth = filterPendingOAuth(connectorResults);
|
|
@@ -258279,7 +258439,7 @@ async function callTool(appId, tool, payload, schema13, context, timeout2 = 6000
|
|
|
258279
258439
|
function listDirectory(appId, params) {
|
|
258280
258440
|
return callTool(appId, "list_directory", { ...params }, ListDirectoryResponseSchema, "listing directory");
|
|
258281
258441
|
}
|
|
258282
|
-
function
|
|
258442
|
+
function readFile6(appId, params) {
|
|
258283
258443
|
return callTool(appId, "read_file", { ...params }, ReadFileResponseSchema, "reading file");
|
|
258284
258444
|
}
|
|
258285
258445
|
function writeFile2(appId, params) {
|
|
@@ -258409,7 +258569,7 @@ async function readFileAction({ runTask: runTask2 }, paths, options) {
|
|
|
258409
258569
|
const { id: appId } = getAppContext();
|
|
258410
258570
|
const offset = parsePositiveInt(options.offset, "--offset");
|
|
258411
258571
|
const limit = parsePositiveInt(options.limit, "--limit");
|
|
258412
|
-
const result = await runTask2("Reading file", () =>
|
|
258572
|
+
const result = await runTask2("Reading file", () => readFile6(appId, { paths, offset, limit }));
|
|
258413
258573
|
return { outroMessage: "Read file", stdout: toJsonStdout(result) };
|
|
258414
258574
|
}
|
|
258415
258575
|
function getSandboxReadFileCommand() {
|
|
@@ -258553,40 +258713,51 @@ function getSecretsCommand() {
|
|
|
258553
258713
|
}
|
|
258554
258714
|
|
|
258555
258715
|
// src/cli/commands/site/deploy.ts
|
|
258556
|
-
|
|
258557
|
-
|
|
258716
|
+
async function deployAction2(ctx, options) {
|
|
258717
|
+
const { isNonInteractive } = ctx;
|
|
258558
258718
|
if (isNonInteractive && !options.yes) {
|
|
258559
258719
|
throw new InvalidInputError("--yes is required in non-interactive mode");
|
|
258560
258720
|
}
|
|
258561
258721
|
const { project: project2 } = await readProjectConfig();
|
|
258562
|
-
|
|
258722
|
+
const kind = await detectAppDeployKind(project2);
|
|
258723
|
+
if (kind === "none") {
|
|
258563
258724
|
throw new ConfigNotFoundError("No site configuration found.", {
|
|
258564
258725
|
hints: [
|
|
258565
258726
|
{
|
|
258566
258727
|
message: `Add 'site.outputDirectory' to your config.jsonc (e.g., "site": { "outputDirectory": "dist" })`
|
|
258728
|
+
},
|
|
258729
|
+
{
|
|
258730
|
+
message: "Full-stack apps ship from their build artifact — run your framework's build first"
|
|
258567
258731
|
}
|
|
258568
258732
|
]
|
|
258569
258733
|
});
|
|
258570
258734
|
}
|
|
258571
|
-
const outputDir = resolve14(project2.root, project2.site.outputDirectory);
|
|
258572
258735
|
if (!options.yes) {
|
|
258573
258736
|
const shouldDeploy = await Re({
|
|
258574
|
-
message: `Deploy site from ${project2.site
|
|
258737
|
+
message: kind === "full-stack" ? "Deploy full-stack app?" : `Deploy site from ${project2.site?.outputDirectory}?`
|
|
258575
258738
|
});
|
|
258576
258739
|
if (Ct(shouldDeploy) || !shouldDeploy) {
|
|
258577
258740
|
return { outroMessage: "Deployment cancelled" };
|
|
258578
258741
|
}
|
|
258579
258742
|
}
|
|
258580
|
-
|
|
258581
|
-
|
|
258582
|
-
|
|
258583
|
-
successMessage: "Site deployed successfully",
|
|
258584
|
-
errorMessage: "Deployment failed"
|
|
258743
|
+
await maybeBuildBeforeDeploy(ctx, project2, options.build);
|
|
258744
|
+
const result = await runAppSiteDeploy(ctx, project2, {
|
|
258745
|
+
gitHash: options.gitHash
|
|
258585
258746
|
});
|
|
258586
|
-
|
|
258747
|
+
if (result.kind === "full-stack" || result.kind === "static-deployment") {
|
|
258748
|
+
return {
|
|
258749
|
+
outroMessage: `Deployment ${result.deploymentId} (commit ${result.gitHash.slice(0, 12)})`,
|
|
258750
|
+
stdout: ctx.jsonMode ? `${JSON.stringify({ deploymentId: result.deploymentId, gitHash: result.gitHash }, null, 2)}
|
|
258751
|
+
` : undefined
|
|
258752
|
+
};
|
|
258753
|
+
}
|
|
258754
|
+
if (result.kind === "static") {
|
|
258755
|
+
return { outroMessage: `Visit your site at: ${result.appUrl}` };
|
|
258756
|
+
}
|
|
258757
|
+
return { outroMessage: "Nothing to deploy" };
|
|
258587
258758
|
}
|
|
258588
258759
|
function getSiteDeployCommand() {
|
|
258589
|
-
return new Base44Command("deploy").description("Deploy built site
|
|
258760
|
+
return new Base44Command("deploy").description("Deploy the built site to Base44 hosting (full-stack apps deploy their Workers build)").option("-y, --yes", "Skip confirmation prompt").option("--git-hash <hash>", "Commit the build came from (defaults to the checkout's HEAD)").option("--build", "Build the site before deploying (skips the prompt)").option("--no-build", "Deploy without building (skips the prompt)").action(deployAction2);
|
|
258590
258761
|
}
|
|
258591
258762
|
|
|
258592
258763
|
// src/cli/commands/site/open.ts
|
|
@@ -258693,10 +258864,10 @@ function toPascalCase(name2) {
|
|
|
258693
258864
|
return name2.split(/[-_\s]+/).map((w8) => w8.charAt(0).toUpperCase() + w8.slice(1)).join("");
|
|
258694
258865
|
}
|
|
258695
258866
|
// src/core/types/update-project.ts
|
|
258696
|
-
import { join as
|
|
258867
|
+
import { join as join29 } from "node:path";
|
|
258697
258868
|
var TYPES_INCLUDE_PATH = `${PROJECT_SUBDIR}/${TYPES_OUTPUT_SUBDIR}/*.d.ts`;
|
|
258698
258869
|
async function updateProjectConfig(projectRoot) {
|
|
258699
|
-
const tsconfigPath =
|
|
258870
|
+
const tsconfigPath = join29(projectRoot, "tsconfig.json");
|
|
258700
258871
|
if (!await pathExists(tsconfigPath)) {
|
|
258701
258872
|
return false;
|
|
258702
258873
|
}
|
|
@@ -258931,7 +259102,7 @@ function createDevLogger(label2, labelColor = theme.styles.dim) {
|
|
|
258931
259102
|
// src/cli/dev/dev-server/main.ts
|
|
258932
259103
|
var import_cors = __toESM(require_lib4(), 1);
|
|
258933
259104
|
var import_express6 = __toESM(require_express(), 1);
|
|
258934
|
-
import { dirname as dirname24, join as
|
|
259105
|
+
import { dirname as dirname24, join as join36 } from "node:path";
|
|
258935
259106
|
|
|
258936
259107
|
// ../../node_modules/get-port/index.js
|
|
258937
259108
|
import net from "node:net";
|
|
@@ -258958,14 +259129,14 @@ var getLocalHosts = () => {
|
|
|
258958
259129
|
}
|
|
258959
259130
|
return results;
|
|
258960
259131
|
};
|
|
258961
|
-
var checkAvailablePort = (options8) => new Promise((
|
|
259132
|
+
var checkAvailablePort = (options8) => new Promise((resolve15, reject) => {
|
|
258962
259133
|
const server = net.createServer();
|
|
258963
259134
|
server.unref();
|
|
258964
259135
|
server.on("error", reject);
|
|
258965
259136
|
server.listen(options8, () => {
|
|
258966
259137
|
const { port } = server.address();
|
|
258967
259138
|
server.close(() => {
|
|
258968
|
-
|
|
259139
|
+
resolve15(port);
|
|
258969
259140
|
});
|
|
258970
259141
|
});
|
|
258971
259142
|
});
|
|
@@ -259066,7 +259237,7 @@ var $setGracefulCleanup = tmp.setGracefulCleanup;
|
|
|
259066
259237
|
|
|
259067
259238
|
// src/cli/dev/dev-server/function-manager.ts
|
|
259068
259239
|
import { spawn as spawn2 } from "node:child_process";
|
|
259069
|
-
import { dirname as dirname21, join as
|
|
259240
|
+
import { dirname as dirname21, join as join30 } from "node:path";
|
|
259070
259241
|
import { pathToFileURL } from "node:url";
|
|
259071
259242
|
|
|
259072
259243
|
// src/cli/dev/dev-server/base-function-manager.ts
|
|
@@ -259171,7 +259342,7 @@ class FunctionManager extends BaseFunctionManager {
|
|
|
259171
259342
|
}
|
|
259172
259343
|
spawnFunction(func, port) {
|
|
259173
259344
|
this.logger.log(`Spawning function "${func.name}" on port ${port}`);
|
|
259174
|
-
const importMapPath =
|
|
259345
|
+
const importMapPath = join30(dirname21(this.wrapperPath), "import-map.json");
|
|
259175
259346
|
const process23 = spawn2("deno", ["run", "--allow-all", "--import-map", importMapPath, this.wrapperPath], {
|
|
259176
259347
|
env: {
|
|
259177
259348
|
...globalThis.process.env,
|
|
@@ -259210,7 +259381,7 @@ class FunctionManager extends BaseFunctionManager {
|
|
|
259210
259381
|
});
|
|
259211
259382
|
}
|
|
259212
259383
|
waitForReady(name2, runningFunc) {
|
|
259213
|
-
return new Promise((
|
|
259384
|
+
return new Promise((resolve15, reject) => {
|
|
259214
259385
|
runningFunc.process.on("exit", (code2) => {
|
|
259215
259386
|
if (!runningFunc.ready) {
|
|
259216
259387
|
clearTimeout(timeout3);
|
|
@@ -259233,7 +259404,7 @@ class FunctionManager extends BaseFunctionManager {
|
|
|
259233
259404
|
runningFunc.ready = true;
|
|
259234
259405
|
clearTimeout(timeout3);
|
|
259235
259406
|
runningFunc.process.stdout?.off("data", onData);
|
|
259236
|
-
|
|
259407
|
+
resolve15(runningFunc.port);
|
|
259237
259408
|
}
|
|
259238
259409
|
};
|
|
259239
259410
|
runningFunc.process.stdout?.on("data", onData);
|
|
@@ -259245,7 +259416,7 @@ class FunctionManager extends BaseFunctionManager {
|
|
|
259245
259416
|
import { mkdirSync as mkdirSync2, writeFileSync as writeFileSync2 } from "node:fs";
|
|
259246
259417
|
import { isBuiltin } from "node:module";
|
|
259247
259418
|
import { homedir as homedir3 } from "node:os";
|
|
259248
|
-
import { join as
|
|
259419
|
+
import { join as join31 } from "node:path";
|
|
259249
259420
|
import { pathToFileURL as pathToFileURL6 } from "node:url";
|
|
259250
259421
|
var depsPromise;
|
|
259251
259422
|
function loadDeps() {
|
|
@@ -259366,9 +259537,9 @@ export default {
|
|
|
259366
259537
|
};
|
|
259367
259538
|
`;
|
|
259368
259539
|
function ensureBundlerConfig() {
|
|
259369
|
-
const dir =
|
|
259540
|
+
const dir = join31(homedir3(), ".base44", "function-bundler");
|
|
259370
259541
|
mkdirSync2(dir, { recursive: true });
|
|
259371
|
-
const configPath =
|
|
259542
|
+
const configPath = join31(dir, "deno.json");
|
|
259372
259543
|
writeFileSync2(configPath, `${JSON.stringify({ nodeModulesDir: "auto" }, null, 2)}
|
|
259373
259544
|
`);
|
|
259374
259545
|
return configPath;
|
|
@@ -261667,7 +261838,7 @@ class NodeFsHandler {
|
|
|
261667
261838
|
this._addToNodeFs(path19, initialAdd, wh2, depth + 1);
|
|
261668
261839
|
}
|
|
261669
261840
|
}).on(EV.ERROR, this._boundHandleError);
|
|
261670
|
-
return new Promise((
|
|
261841
|
+
return new Promise((resolve16, reject) => {
|
|
261671
261842
|
if (!stream)
|
|
261672
261843
|
return reject();
|
|
261673
261844
|
stream.once(STR_END, () => {
|
|
@@ -261676,7 +261847,7 @@ class NodeFsHandler {
|
|
|
261676
261847
|
return;
|
|
261677
261848
|
}
|
|
261678
261849
|
const wasThrottled = throttler ? throttler.clear() : false;
|
|
261679
|
-
|
|
261850
|
+
resolve16(undefined);
|
|
261680
261851
|
previous.getChildren().filter((item) => {
|
|
261681
261852
|
return item !== directory && !current.has(item);
|
|
261682
261853
|
}).forEach((item) => {
|
|
@@ -262593,7 +262764,7 @@ async function createDevServer(options8) {
|
|
|
262593
262764
|
}
|
|
262594
262765
|
remoteProxy(req, res, next);
|
|
262595
262766
|
});
|
|
262596
|
-
const server = await new Promise((
|
|
262767
|
+
const server = await new Promise((resolve17, reject) => {
|
|
262597
262768
|
const s5 = app.listen(port, "127.0.0.1", (err) => {
|
|
262598
262769
|
if (err) {
|
|
262599
262770
|
if ("code" in err && err.code === "EADDRINUSE") {
|
|
@@ -262602,7 +262773,7 @@ async function createDevServer(options8) {
|
|
|
262602
262773
|
reject(err);
|
|
262603
262774
|
}
|
|
262604
262775
|
} else {
|
|
262605
|
-
|
|
262776
|
+
resolve17(s5);
|
|
262606
262777
|
}
|
|
262607
262778
|
});
|
|
262608
262779
|
});
|
|
@@ -262611,8 +262782,8 @@ async function createDevServer(options8) {
|
|
|
262611
262782
|
broadcastEntityEvent(io6, appId, entityName, event);
|
|
262612
262783
|
};
|
|
262613
262784
|
const base44ConfigWatcher = new WatchBase44({
|
|
262614
|
-
functions:
|
|
262615
|
-
entities:
|
|
262785
|
+
functions: join36(dirname24(project2.configPath), project2.functionsDir),
|
|
262786
|
+
entities: join36(dirname24(project2.configPath), project2.entitiesDir)
|
|
262616
262787
|
}, devLogger);
|
|
262617
262788
|
base44ConfigWatcher.on("change", async (name2) => {
|
|
262618
262789
|
try {
|
|
@@ -262652,13 +262823,13 @@ async function createDevServer(options8) {
|
|
|
262652
262823
|
if (!server.listening) {
|
|
262653
262824
|
return;
|
|
262654
262825
|
}
|
|
262655
|
-
await new Promise((
|
|
262826
|
+
await new Promise((resolve17, reject) => {
|
|
262656
262827
|
server.close((error48) => {
|
|
262657
262828
|
if (error48) {
|
|
262658
262829
|
reject(error48);
|
|
262659
262830
|
return;
|
|
262660
262831
|
}
|
|
262661
|
-
|
|
262832
|
+
resolve17();
|
|
262662
262833
|
});
|
|
262663
262834
|
});
|
|
262664
262835
|
};
|
|
@@ -262729,15 +262900,15 @@ class ServeRunner {
|
|
|
262729
262900
|
return;
|
|
262730
262901
|
}
|
|
262731
262902
|
this.stopping = true;
|
|
262732
|
-
const exited = new Promise((
|
|
262903
|
+
const exited = new Promise((resolve17) => child.once("exit", () => resolve17()));
|
|
262733
262904
|
if (process23.platform === "win32" && child.pid) {
|
|
262734
262905
|
const taskkill = spawn3("taskkill", ["/pid", String(child.pid), "/T", "/F"], {
|
|
262735
262906
|
stdio: "ignore",
|
|
262736
262907
|
windowsHide: true
|
|
262737
262908
|
});
|
|
262738
|
-
await new Promise((
|
|
262739
|
-
taskkill.once("exit", () =>
|
|
262740
|
-
taskkill.once("error", () =>
|
|
262909
|
+
await new Promise((resolve17) => {
|
|
262910
|
+
taskkill.once("exit", () => resolve17());
|
|
262911
|
+
taskkill.once("error", () => resolve17());
|
|
262741
262912
|
});
|
|
262742
262913
|
} else if (child.pid) {
|
|
262743
262914
|
try {
|
|
@@ -262907,13 +263078,13 @@ async function runScript(options8) {
|
|
|
262907
263078
|
}
|
|
262908
263079
|
// src/cli/commands/exec.ts
|
|
262909
263080
|
function readStdin2() {
|
|
262910
|
-
return new Promise((
|
|
263081
|
+
return new Promise((resolve17, reject) => {
|
|
262911
263082
|
let data = "";
|
|
262912
263083
|
process.stdin.setEncoding("utf-8");
|
|
262913
263084
|
process.stdin.on("data", (chunk) => {
|
|
262914
263085
|
data += chunk;
|
|
262915
263086
|
});
|
|
262916
|
-
process.stdin.on("end", () =>
|
|
263087
|
+
process.stdin.on("end", () => resolve17(data));
|
|
262917
263088
|
process.stdin.on("error", reject);
|
|
262918
263089
|
});
|
|
262919
263090
|
}
|
|
@@ -262984,7 +263155,7 @@ Examples:
|
|
|
262984
263155
|
}
|
|
262985
263156
|
|
|
262986
263157
|
// src/cli/commands/project/eject.ts
|
|
262987
|
-
import { resolve as
|
|
263158
|
+
import { resolve as resolve17 } from "node:path";
|
|
262988
263159
|
var import_kebabCase2 = __toESM(require_kebabCase(), 1);
|
|
262989
263160
|
async function eject(ctx, options8, command2) {
|
|
262990
263161
|
const { log, runTask: runTask2, isNonInteractive } = ctx;
|
|
@@ -263048,7 +263219,7 @@ async function eject(ctx, options8, command2) {
|
|
|
263048
263219
|
Ne("Operation cancelled.");
|
|
263049
263220
|
throw new CLIExitError(0);
|
|
263050
263221
|
}
|
|
263051
|
-
const resolvedPath =
|
|
263222
|
+
const resolvedPath = resolve17(selectedPath);
|
|
263052
263223
|
await runTask2("Downloading your project's code...", async (updateMessage) => {
|
|
263053
263224
|
await createProjectFilesForExistingProject({
|
|
263054
263225
|
projectId,
|
|
@@ -263081,7 +263252,11 @@ async function eject(ctx, options8, command2) {
|
|
|
263081
263252
|
successMessage: theme.colors.base44Orange("Project built successfully"),
|
|
263082
263253
|
errorMessage: "Failed to build project"
|
|
263083
263254
|
});
|
|
263084
|
-
await deployAction(ctx, {
|
|
263255
|
+
await deployAction(ctx, {
|
|
263256
|
+
yes: true,
|
|
263257
|
+
build: false,
|
|
263258
|
+
projectRoot: resolvedPath
|
|
263259
|
+
});
|
|
263085
263260
|
}
|
|
263086
263261
|
}
|
|
263087
263262
|
return { outroMessage: "Your new project is set and ready to use" };
|
|
@@ -263110,6 +263285,7 @@ function createProgram(context) {
|
|
|
263110
263285
|
program2.addCommand(getCreateCommand());
|
|
263111
263286
|
program2.addCommand(getScaffoldCommand());
|
|
263112
263287
|
program2.addCommand(getDashboardCommand());
|
|
263288
|
+
program2.addCommand(getBuildCommand());
|
|
263113
263289
|
program2.addCommand(getDeployCommand2());
|
|
263114
263290
|
program2.addCommand(getVisibilityCommand());
|
|
263115
263291
|
program2.addCommand(getLinkCommand());
|
|
@@ -265423,14 +265599,14 @@ async function addSourceContext(frames) {
|
|
|
265423
265599
|
return frames;
|
|
265424
265600
|
}
|
|
265425
265601
|
function getContextLinesFromFile(path19, ranges, output) {
|
|
265426
|
-
return new Promise((
|
|
265602
|
+
return new Promise((resolve18) => {
|
|
265427
265603
|
const stream = createReadStream2(path19);
|
|
265428
265604
|
const lineReaded = createInterface2({
|
|
265429
265605
|
input: stream
|
|
265430
265606
|
});
|
|
265431
265607
|
function destroyStreamAndResolve() {
|
|
265432
265608
|
stream.destroy();
|
|
265433
|
-
|
|
265609
|
+
resolve18();
|
|
265434
265610
|
}
|
|
265435
265611
|
let lineNumber = 0;
|
|
265436
265612
|
let currentRangeIndex = 0;
|
|
@@ -266542,15 +266718,15 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
266542
266718
|
return true;
|
|
266543
266719
|
if (this.featureFlagsPoller === undefined)
|
|
266544
266720
|
return false;
|
|
266545
|
-
return new Promise((
|
|
266721
|
+
return new Promise((resolve18) => {
|
|
266546
266722
|
const timeout3 = setTimeout(() => {
|
|
266547
266723
|
cleanup();
|
|
266548
|
-
|
|
266724
|
+
resolve18(false);
|
|
266549
266725
|
}, timeoutMs);
|
|
266550
266726
|
const cleanup = this._events.on("localEvaluationFlagsLoaded", (count2) => {
|
|
266551
266727
|
clearTimeout(timeout3);
|
|
266552
266728
|
cleanup();
|
|
266553
|
-
|
|
266729
|
+
resolve18(count2 > 0);
|
|
266554
266730
|
});
|
|
266555
266731
|
});
|
|
266556
266732
|
}
|
|
@@ -267336,7 +267512,7 @@ function addCommandInfoToErrorReporter(program2, errorReporter) {
|
|
|
267336
267512
|
// src/cli/index.ts
|
|
267337
267513
|
var __dirname4 = dirname26(fileURLToPath6(import.meta.url));
|
|
267338
267514
|
async function runCLI(options8) {
|
|
267339
|
-
ensureNpmAssets(
|
|
267515
|
+
ensureNpmAssets(join37(__dirname4, "../assets"));
|
|
267340
267516
|
const errorReporter = new ErrorReporter;
|
|
267341
267517
|
errorReporter.registerProcessErrorHandlers();
|
|
267342
267518
|
const jsonMode = process.argv.includes("--json");
|
|
@@ -267375,4 +267551,4 @@ export {
|
|
|
267375
267551
|
CLIExitError
|
|
267376
267552
|
};
|
|
267377
267553
|
|
|
267378
|
-
//# debugId=
|
|
267554
|
+
//# debugId=F2B952437C9258C064756E2164756E21
|