@arcote.tech/arc-cli 0.5.2 → 0.5.5
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/index.js +2854 -637
- package/package.json +8 -7
- package/src/builder/module-builder.ts +35 -9
- package/src/commands/platform-deploy.ts +143 -0
- package/src/commands/platform-start.ts +4 -1
- package/src/deploy/ansible.ts +69 -0
- package/src/deploy/assets/ansible/site.yml +169 -0
- package/src/deploy/assets/terraform/main.tf +38 -0
- package/src/deploy/assets/terraform/variables.tf +35 -0
- package/src/deploy/assets.ts +282 -0
- package/src/deploy/bootstrap.ts +131 -0
- package/src/deploy/caddyfile.ts +59 -0
- package/src/deploy/compose.ts +73 -0
- package/src/deploy/config.ts +279 -0
- package/src/deploy/remote-state.ts +92 -0
- package/src/deploy/remote-sync.ts +202 -0
- package/src/deploy/ssh.ts +246 -0
- package/src/deploy/survey.ts +172 -0
- package/src/deploy/terraform.ts +109 -0
- package/src/index.ts +12 -0
- package/src/platform/deploy-api.ts +183 -0
- package/src/platform/server.ts +49 -25
- package/src/platform/shared.ts +45 -3
package/dist/index.js
CHANGED
|
@@ -8974,6 +8974,134 @@ var require_chokidar = __commonJS((exports) => {
|
|
|
8974
8974
|
exports.watch = watch;
|
|
8975
8975
|
});
|
|
8976
8976
|
|
|
8977
|
+
// ../../node_modules/.bun/sisteransi@1.0.5/node_modules/sisteransi/src/index.js
|
|
8978
|
+
var require_src = __commonJS((exports, module) => {
|
|
8979
|
+
var ESC2 = "\x1B";
|
|
8980
|
+
var CSI = `${ESC2}[`;
|
|
8981
|
+
var beep2 = "\x07";
|
|
8982
|
+
var cursor = {
|
|
8983
|
+
to(x, y) {
|
|
8984
|
+
if (!y)
|
|
8985
|
+
return `${CSI}${x + 1}G`;
|
|
8986
|
+
return `${CSI}${y + 1};${x + 1}H`;
|
|
8987
|
+
},
|
|
8988
|
+
move(x, y) {
|
|
8989
|
+
let ret = "";
|
|
8990
|
+
if (x < 0)
|
|
8991
|
+
ret += `${CSI}${-x}D`;
|
|
8992
|
+
else if (x > 0)
|
|
8993
|
+
ret += `${CSI}${x}C`;
|
|
8994
|
+
if (y < 0)
|
|
8995
|
+
ret += `${CSI}${-y}A`;
|
|
8996
|
+
else if (y > 0)
|
|
8997
|
+
ret += `${CSI}${y}B`;
|
|
8998
|
+
return ret;
|
|
8999
|
+
},
|
|
9000
|
+
up: (count = 1) => `${CSI}${count}A`,
|
|
9001
|
+
down: (count = 1) => `${CSI}${count}B`,
|
|
9002
|
+
forward: (count = 1) => `${CSI}${count}C`,
|
|
9003
|
+
backward: (count = 1) => `${CSI}${count}D`,
|
|
9004
|
+
nextLine: (count = 1) => `${CSI}E`.repeat(count),
|
|
9005
|
+
prevLine: (count = 1) => `${CSI}F`.repeat(count),
|
|
9006
|
+
left: `${CSI}G`,
|
|
9007
|
+
hide: `${CSI}?25l`,
|
|
9008
|
+
show: `${CSI}?25h`,
|
|
9009
|
+
save: `${ESC2}7`,
|
|
9010
|
+
restore: `${ESC2}8`
|
|
9011
|
+
};
|
|
9012
|
+
var scroll = {
|
|
9013
|
+
up: (count = 1) => `${CSI}S`.repeat(count),
|
|
9014
|
+
down: (count = 1) => `${CSI}T`.repeat(count)
|
|
9015
|
+
};
|
|
9016
|
+
var erase = {
|
|
9017
|
+
screen: `${CSI}2J`,
|
|
9018
|
+
up: (count = 1) => `${CSI}1J`.repeat(count),
|
|
9019
|
+
down: (count = 1) => `${CSI}J`.repeat(count),
|
|
9020
|
+
line: `${CSI}2K`,
|
|
9021
|
+
lineEnd: `${CSI}K`,
|
|
9022
|
+
lineStart: `${CSI}1K`,
|
|
9023
|
+
lines(count) {
|
|
9024
|
+
let clear = "";
|
|
9025
|
+
for (let i = 0;i < count; i++)
|
|
9026
|
+
clear += this.line + (i < count - 1 ? cursor.up() : "");
|
|
9027
|
+
if (count)
|
|
9028
|
+
clear += cursor.left;
|
|
9029
|
+
return clear;
|
|
9030
|
+
}
|
|
9031
|
+
};
|
|
9032
|
+
module.exports = { cursor, scroll, erase, beep: beep2 };
|
|
9033
|
+
});
|
|
9034
|
+
|
|
9035
|
+
// ../../node_modules/.bun/picocolors@1.1.1/node_modules/picocolors/picocolors.js
|
|
9036
|
+
var require_picocolors = __commonJS((exports, module) => {
|
|
9037
|
+
var p = process || {};
|
|
9038
|
+
var argv2 = p.argv || [];
|
|
9039
|
+
var env2 = p.env || {};
|
|
9040
|
+
var isColorSupported2 = !(!!env2.NO_COLOR || argv2.includes("--no-color")) && (!!env2.FORCE_COLOR || argv2.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env2.TERM !== "dumb" || !!env2.CI);
|
|
9041
|
+
var formatter = (open, close, replace = open) => (input) => {
|
|
9042
|
+
let string = "" + input, index = string.indexOf(close, open.length);
|
|
9043
|
+
return ~index ? open + replaceClose2(string, close, replace, index) + close : open + string + close;
|
|
9044
|
+
};
|
|
9045
|
+
var replaceClose2 = (string, close, replace, index) => {
|
|
9046
|
+
let result = "", cursor = 0;
|
|
9047
|
+
do {
|
|
9048
|
+
result += string.substring(cursor, index) + replace;
|
|
9049
|
+
cursor = index + close.length;
|
|
9050
|
+
index = string.indexOf(close, cursor);
|
|
9051
|
+
} while (~index);
|
|
9052
|
+
return result + string.substring(cursor);
|
|
9053
|
+
};
|
|
9054
|
+
var createColors2 = (enabled = isColorSupported2) => {
|
|
9055
|
+
let f = enabled ? formatter : () => String;
|
|
9056
|
+
return {
|
|
9057
|
+
isColorSupported: enabled,
|
|
9058
|
+
reset: f("\x1B[0m", "\x1B[0m"),
|
|
9059
|
+
bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
|
|
9060
|
+
dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
|
|
9061
|
+
italic: f("\x1B[3m", "\x1B[23m"),
|
|
9062
|
+
underline: f("\x1B[4m", "\x1B[24m"),
|
|
9063
|
+
inverse: f("\x1B[7m", "\x1B[27m"),
|
|
9064
|
+
hidden: f("\x1B[8m", "\x1B[28m"),
|
|
9065
|
+
strikethrough: f("\x1B[9m", "\x1B[29m"),
|
|
9066
|
+
black: f("\x1B[30m", "\x1B[39m"),
|
|
9067
|
+
red: f("\x1B[31m", "\x1B[39m"),
|
|
9068
|
+
green: f("\x1B[32m", "\x1B[39m"),
|
|
9069
|
+
yellow: f("\x1B[33m", "\x1B[39m"),
|
|
9070
|
+
blue: f("\x1B[34m", "\x1B[39m"),
|
|
9071
|
+
magenta: f("\x1B[35m", "\x1B[39m"),
|
|
9072
|
+
cyan: f("\x1B[36m", "\x1B[39m"),
|
|
9073
|
+
white: f("\x1B[37m", "\x1B[39m"),
|
|
9074
|
+
gray: f("\x1B[90m", "\x1B[39m"),
|
|
9075
|
+
bgBlack: f("\x1B[40m", "\x1B[49m"),
|
|
9076
|
+
bgRed: f("\x1B[41m", "\x1B[49m"),
|
|
9077
|
+
bgGreen: f("\x1B[42m", "\x1B[49m"),
|
|
9078
|
+
bgYellow: f("\x1B[43m", "\x1B[49m"),
|
|
9079
|
+
bgBlue: f("\x1B[44m", "\x1B[49m"),
|
|
9080
|
+
bgMagenta: f("\x1B[45m", "\x1B[49m"),
|
|
9081
|
+
bgCyan: f("\x1B[46m", "\x1B[49m"),
|
|
9082
|
+
bgWhite: f("\x1B[47m", "\x1B[49m"),
|
|
9083
|
+
blackBright: f("\x1B[90m", "\x1B[39m"),
|
|
9084
|
+
redBright: f("\x1B[91m", "\x1B[39m"),
|
|
9085
|
+
greenBright: f("\x1B[92m", "\x1B[39m"),
|
|
9086
|
+
yellowBright: f("\x1B[93m", "\x1B[39m"),
|
|
9087
|
+
blueBright: f("\x1B[94m", "\x1B[39m"),
|
|
9088
|
+
magentaBright: f("\x1B[95m", "\x1B[39m"),
|
|
9089
|
+
cyanBright: f("\x1B[96m", "\x1B[39m"),
|
|
9090
|
+
whiteBright: f("\x1B[97m", "\x1B[39m"),
|
|
9091
|
+
bgBlackBright: f("\x1B[100m", "\x1B[49m"),
|
|
9092
|
+
bgRedBright: f("\x1B[101m", "\x1B[49m"),
|
|
9093
|
+
bgGreenBright: f("\x1B[102m", "\x1B[49m"),
|
|
9094
|
+
bgYellowBright: f("\x1B[103m", "\x1B[49m"),
|
|
9095
|
+
bgBlueBright: f("\x1B[104m", "\x1B[49m"),
|
|
9096
|
+
bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
|
|
9097
|
+
bgCyanBright: f("\x1B[106m", "\x1B[49m"),
|
|
9098
|
+
bgWhiteBright: f("\x1B[107m", "\x1B[49m")
|
|
9099
|
+
};
|
|
9100
|
+
};
|
|
9101
|
+
module.exports = createColors2();
|
|
9102
|
+
module.exports.createColors = createColors2;
|
|
9103
|
+
});
|
|
9104
|
+
|
|
8977
9105
|
// ../../node_modules/.bun/safe-buffer@5.2.1/node_modules/safe-buffer/index.js
|
|
8978
9106
|
var require_safe_buffer = __commonJS((exports, module) => {
|
|
8979
9107
|
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
@@ -9240,18 +9368,18 @@ var require_buffer_equal_constant_time = __commonJS((exports, module) => {
|
|
|
9240
9368
|
var Buffer2 = __require("buffer").Buffer;
|
|
9241
9369
|
var SlowBuffer = __require("buffer").SlowBuffer;
|
|
9242
9370
|
module.exports = bufferEq;
|
|
9243
|
-
function bufferEq(
|
|
9244
|
-
if (!Buffer2.isBuffer(
|
|
9371
|
+
function bufferEq(a2, b2) {
|
|
9372
|
+
if (!Buffer2.isBuffer(a2) || !Buffer2.isBuffer(b2)) {
|
|
9245
9373
|
return false;
|
|
9246
9374
|
}
|
|
9247
|
-
if (
|
|
9375
|
+
if (a2.length !== b2.length) {
|
|
9248
9376
|
return false;
|
|
9249
9377
|
}
|
|
9250
|
-
var
|
|
9251
|
-
for (var i = 0;i <
|
|
9252
|
-
|
|
9378
|
+
var c2 = 0;
|
|
9379
|
+
for (var i = 0;i < a2.length; i++) {
|
|
9380
|
+
c2 |= a2[i] ^ b2[i];
|
|
9253
9381
|
}
|
|
9254
|
-
return
|
|
9382
|
+
return c2 === 0;
|
|
9255
9383
|
}
|
|
9256
9384
|
bufferEq.install = function() {
|
|
9257
9385
|
Buffer2.prototype.equal = SlowBuffer.prototype.equal = function equal(that) {
|
|
@@ -9374,16 +9502,16 @@ var require_jwa = __commonJS((exports, module) => {
|
|
|
9374
9502
|
};
|
|
9375
9503
|
}
|
|
9376
9504
|
var bufferEqual;
|
|
9377
|
-
var timingSafeEqual = "timingSafeEqual" in crypto2 ? function timingSafeEqual2(
|
|
9378
|
-
if (
|
|
9505
|
+
var timingSafeEqual = "timingSafeEqual" in crypto2 ? function timingSafeEqual2(a2, b2) {
|
|
9506
|
+
if (a2.byteLength !== b2.byteLength) {
|
|
9379
9507
|
return false;
|
|
9380
9508
|
}
|
|
9381
|
-
return crypto2.timingSafeEqual(
|
|
9382
|
-
} : function timingSafeEqual2(
|
|
9509
|
+
return crypto2.timingSafeEqual(a2, b2);
|
|
9510
|
+
} : function timingSafeEqual2(a2, b2) {
|
|
9383
9511
|
if (!bufferEqual) {
|
|
9384
9512
|
bufferEqual = require_buffer_equal_constant_time();
|
|
9385
9513
|
}
|
|
9386
|
-
return bufferEqual(
|
|
9514
|
+
return bufferEqual(a2, b2);
|
|
9387
9515
|
};
|
|
9388
9516
|
function createHmacVerifier(bits) {
|
|
9389
9517
|
return function verify(thing, signature, secret) {
|
|
@@ -9565,9 +9693,9 @@ var require_sign_stream = __commonJS((exports, module) => {
|
|
|
9565
9693
|
this.emit("end");
|
|
9566
9694
|
this.readable = false;
|
|
9567
9695
|
return signature;
|
|
9568
|
-
} catch (
|
|
9696
|
+
} catch (e2) {
|
|
9569
9697
|
this.readable = false;
|
|
9570
|
-
this.emit("error",
|
|
9698
|
+
this.emit("error", e2);
|
|
9571
9699
|
this.emit("close");
|
|
9572
9700
|
}
|
|
9573
9701
|
};
|
|
@@ -9584,15 +9712,15 @@ var require_verify_stream = __commonJS((exports, module) => {
|
|
|
9584
9712
|
var toString = require_tostring();
|
|
9585
9713
|
var util = __require("util");
|
|
9586
9714
|
var JWS_REGEX = /^[a-zA-Z0-9\-_]+?\.[a-zA-Z0-9\-_]+?\.([a-zA-Z0-9\-_]+)?$/;
|
|
9587
|
-
function
|
|
9715
|
+
function isObject2(thing) {
|
|
9588
9716
|
return Object.prototype.toString.call(thing) === "[object Object]";
|
|
9589
9717
|
}
|
|
9590
9718
|
function safeJsonParse(thing) {
|
|
9591
|
-
if (
|
|
9719
|
+
if (isObject2(thing))
|
|
9592
9720
|
return thing;
|
|
9593
9721
|
try {
|
|
9594
9722
|
return JSON.parse(thing);
|
|
9595
|
-
} catch (
|
|
9723
|
+
} catch (e2) {
|
|
9596
9724
|
return;
|
|
9597
9725
|
}
|
|
9598
9726
|
}
|
|
@@ -9616,9 +9744,9 @@ var require_verify_stream = __commonJS((exports, module) => {
|
|
|
9616
9744
|
}
|
|
9617
9745
|
function jwsVerify(jwsSig, algorithm, secretOrKey) {
|
|
9618
9746
|
if (!algorithm) {
|
|
9619
|
-
var
|
|
9620
|
-
|
|
9621
|
-
throw
|
|
9747
|
+
var err3 = new Error("Missing algorithm parameter for jws.verify");
|
|
9748
|
+
err3.code = "MISSING_ALGORITHM";
|
|
9749
|
+
throw err3;
|
|
9622
9750
|
}
|
|
9623
9751
|
jwsSig = toString(jwsSig);
|
|
9624
9752
|
var signature = signatureFromJWS(jwsSig);
|
|
@@ -9676,9 +9804,9 @@ var require_verify_stream = __commonJS((exports, module) => {
|
|
|
9676
9804
|
this.emit("end");
|
|
9677
9805
|
this.readable = false;
|
|
9678
9806
|
return valid;
|
|
9679
|
-
} catch (
|
|
9807
|
+
} catch (e2) {
|
|
9680
9808
|
this.readable = false;
|
|
9681
|
-
this.emit("error",
|
|
9809
|
+
this.emit("error", e2);
|
|
9682
9810
|
this.emit("close");
|
|
9683
9811
|
}
|
|
9684
9812
|
};
|
|
@@ -9735,7 +9863,7 @@ var require_decode = __commonJS((exports, module) => {
|
|
|
9735
9863
|
if (obj !== null && typeof obj === "object") {
|
|
9736
9864
|
payload = obj;
|
|
9737
9865
|
}
|
|
9738
|
-
} catch (
|
|
9866
|
+
} catch (e2) {}
|
|
9739
9867
|
}
|
|
9740
9868
|
if (options.complete === true) {
|
|
9741
9869
|
return {
|
|
@@ -9794,11 +9922,11 @@ var require_TokenExpiredError = __commonJS((exports, module) => {
|
|
|
9794
9922
|
// ../../node_modules/.bun/ms@2.1.3/node_modules/ms/index.js
|
|
9795
9923
|
var require_ms = __commonJS((exports, module) => {
|
|
9796
9924
|
var s = 1000;
|
|
9797
|
-
var
|
|
9798
|
-
var
|
|
9799
|
-
var
|
|
9800
|
-
var
|
|
9801
|
-
var
|
|
9925
|
+
var m3 = s * 60;
|
|
9926
|
+
var h2 = m3 * 60;
|
|
9927
|
+
var d2 = h2 * 24;
|
|
9928
|
+
var w2 = d2 * 7;
|
|
9929
|
+
var y3 = d2 * 365.25;
|
|
9802
9930
|
module.exports = function(val, options) {
|
|
9803
9931
|
options = options || {};
|
|
9804
9932
|
var type = typeof val;
|
|
@@ -9826,27 +9954,27 @@ var require_ms = __commonJS((exports, module) => {
|
|
|
9826
9954
|
case "yrs":
|
|
9827
9955
|
case "yr":
|
|
9828
9956
|
case "y":
|
|
9829
|
-
return n *
|
|
9957
|
+
return n * y3;
|
|
9830
9958
|
case "weeks":
|
|
9831
9959
|
case "week":
|
|
9832
9960
|
case "w":
|
|
9833
|
-
return n *
|
|
9961
|
+
return n * w2;
|
|
9834
9962
|
case "days":
|
|
9835
9963
|
case "day":
|
|
9836
9964
|
case "d":
|
|
9837
|
-
return n *
|
|
9965
|
+
return n * d2;
|
|
9838
9966
|
case "hours":
|
|
9839
9967
|
case "hour":
|
|
9840
9968
|
case "hrs":
|
|
9841
9969
|
case "hr":
|
|
9842
9970
|
case "h":
|
|
9843
|
-
return n *
|
|
9971
|
+
return n * h2;
|
|
9844
9972
|
case "minutes":
|
|
9845
9973
|
case "minute":
|
|
9846
9974
|
case "mins":
|
|
9847
9975
|
case "min":
|
|
9848
9976
|
case "m":
|
|
9849
|
-
return n *
|
|
9977
|
+
return n * m3;
|
|
9850
9978
|
case "seconds":
|
|
9851
9979
|
case "second":
|
|
9852
9980
|
case "secs":
|
|
@@ -9865,14 +9993,14 @@ var require_ms = __commonJS((exports, module) => {
|
|
|
9865
9993
|
}
|
|
9866
9994
|
function fmtShort(ms) {
|
|
9867
9995
|
var msAbs = Math.abs(ms);
|
|
9868
|
-
if (msAbs >=
|
|
9869
|
-
return Math.round(ms /
|
|
9996
|
+
if (msAbs >= d2) {
|
|
9997
|
+
return Math.round(ms / d2) + "d";
|
|
9870
9998
|
}
|
|
9871
|
-
if (msAbs >=
|
|
9872
|
-
return Math.round(ms /
|
|
9999
|
+
if (msAbs >= h2) {
|
|
10000
|
+
return Math.round(ms / h2) + "h";
|
|
9873
10001
|
}
|
|
9874
|
-
if (msAbs >=
|
|
9875
|
-
return Math.round(ms /
|
|
10002
|
+
if (msAbs >= m3) {
|
|
10003
|
+
return Math.round(ms / m3) + "m";
|
|
9876
10004
|
}
|
|
9877
10005
|
if (msAbs >= s) {
|
|
9878
10006
|
return Math.round(ms / s) + "s";
|
|
@@ -9881,14 +10009,14 @@ var require_ms = __commonJS((exports, module) => {
|
|
|
9881
10009
|
}
|
|
9882
10010
|
function fmtLong(ms) {
|
|
9883
10011
|
var msAbs = Math.abs(ms);
|
|
9884
|
-
if (msAbs >=
|
|
9885
|
-
return plural(ms, msAbs,
|
|
10012
|
+
if (msAbs >= d2) {
|
|
10013
|
+
return plural(ms, msAbs, d2, "day");
|
|
9886
10014
|
}
|
|
9887
|
-
if (msAbs >=
|
|
9888
|
-
return plural(ms, msAbs,
|
|
10015
|
+
if (msAbs >= h2) {
|
|
10016
|
+
return plural(ms, msAbs, h2, "hour");
|
|
9889
10017
|
}
|
|
9890
|
-
if (msAbs >=
|
|
9891
|
-
return plural(ms, msAbs,
|
|
10018
|
+
if (msAbs >= m3) {
|
|
10019
|
+
return plural(ms, msAbs, m3, "minute");
|
|
9892
10020
|
}
|
|
9893
10021
|
if (msAbs >= s) {
|
|
9894
10022
|
return plural(ms, msAbs, s, "second");
|
|
@@ -9963,12 +10091,12 @@ var require_re = __commonJS((exports, module) => {
|
|
|
9963
10091
|
} = require_constants4();
|
|
9964
10092
|
var debug = require_debug();
|
|
9965
10093
|
exports = module.exports = {};
|
|
9966
|
-
var
|
|
10094
|
+
var re2 = exports.re = [];
|
|
9967
10095
|
var safeRe = exports.safeRe = [];
|
|
9968
10096
|
var src = exports.src = [];
|
|
9969
10097
|
var safeSrc = exports.safeSrc = [];
|
|
9970
10098
|
var t = exports.t = {};
|
|
9971
|
-
var
|
|
10099
|
+
var R3 = 0;
|
|
9972
10100
|
var LETTERDASHNUMBER = "[a-zA-Z0-9-]";
|
|
9973
10101
|
var safeRegexReplacements = [
|
|
9974
10102
|
["\\s", 1],
|
|
@@ -9983,12 +10111,12 @@ var require_re = __commonJS((exports, module) => {
|
|
|
9983
10111
|
};
|
|
9984
10112
|
var createToken = (name, value, isGlobal) => {
|
|
9985
10113
|
const safe = makeSafeRegex(value);
|
|
9986
|
-
const index =
|
|
10114
|
+
const index = R3++;
|
|
9987
10115
|
debug(name, index, value);
|
|
9988
10116
|
t[name] = index;
|
|
9989
10117
|
src[index] = value;
|
|
9990
10118
|
safeSrc[index] = safe;
|
|
9991
|
-
|
|
10119
|
+
re2[index] = new RegExp(value, isGlobal ? "g" : undefined);
|
|
9992
10120
|
safeRe[index] = new RegExp(safe, isGlobal ? "g" : undefined);
|
|
9993
10121
|
};
|
|
9994
10122
|
createToken("NUMERICIDENTIFIER", "0|[1-9]\\d*");
|
|
@@ -10058,19 +10186,19 @@ var require_parse_options = __commonJS((exports, module) => {
|
|
|
10058
10186
|
// ../../node_modules/.bun/semver@7.7.4/node_modules/semver/internal/identifiers.js
|
|
10059
10187
|
var require_identifiers = __commonJS((exports, module) => {
|
|
10060
10188
|
var numeric = /^[0-9]+$/;
|
|
10061
|
-
var compareIdentifiers = (
|
|
10062
|
-
if (typeof
|
|
10063
|
-
return
|
|
10189
|
+
var compareIdentifiers = (a2, b2) => {
|
|
10190
|
+
if (typeof a2 === "number" && typeof b2 === "number") {
|
|
10191
|
+
return a2 === b2 ? 0 : a2 < b2 ? -1 : 1;
|
|
10064
10192
|
}
|
|
10065
|
-
const anum = numeric.test(
|
|
10066
|
-
const bnum = numeric.test(
|
|
10193
|
+
const anum = numeric.test(a2);
|
|
10194
|
+
const bnum = numeric.test(b2);
|
|
10067
10195
|
if (anum && bnum) {
|
|
10068
|
-
|
|
10069
|
-
|
|
10196
|
+
a2 = +a2;
|
|
10197
|
+
b2 = +b2;
|
|
10070
10198
|
}
|
|
10071
|
-
return
|
|
10199
|
+
return a2 === b2 ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a2 < b2 ? -1 : 1;
|
|
10072
10200
|
};
|
|
10073
|
-
var rcompareIdentifiers = (
|
|
10201
|
+
var rcompareIdentifiers = (a2, b2) => compareIdentifiers(b2, a2);
|
|
10074
10202
|
module.exports = {
|
|
10075
10203
|
compareIdentifiers,
|
|
10076
10204
|
rcompareIdentifiers
|
|
@@ -10081,7 +10209,7 @@ var require_identifiers = __commonJS((exports, module) => {
|
|
|
10081
10209
|
var require_semver = __commonJS((exports, module) => {
|
|
10082
10210
|
var debug = require_debug();
|
|
10083
10211
|
var { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants4();
|
|
10084
|
-
var { safeRe:
|
|
10212
|
+
var { safeRe: re2, t } = require_re();
|
|
10085
10213
|
var parseOptions = require_parse_options();
|
|
10086
10214
|
var { compareIdentifiers } = require_identifiers();
|
|
10087
10215
|
|
|
@@ -10104,14 +10232,14 @@ var require_semver = __commonJS((exports, module) => {
|
|
|
10104
10232
|
this.options = options;
|
|
10105
10233
|
this.loose = !!options.loose;
|
|
10106
10234
|
this.includePrerelease = !!options.includePrerelease;
|
|
10107
|
-
const
|
|
10108
|
-
if (!
|
|
10235
|
+
const m3 = version.trim().match(options.loose ? re2[t.LOOSE] : re2[t.FULL]);
|
|
10236
|
+
if (!m3) {
|
|
10109
10237
|
throw new TypeError(`Invalid Version: ${version}`);
|
|
10110
10238
|
}
|
|
10111
10239
|
this.raw = version;
|
|
10112
|
-
this.major = +
|
|
10113
|
-
this.minor = +
|
|
10114
|
-
this.patch = +
|
|
10240
|
+
this.major = +m3[1];
|
|
10241
|
+
this.minor = +m3[2];
|
|
10242
|
+
this.patch = +m3[3];
|
|
10115
10243
|
if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
|
|
10116
10244
|
throw new TypeError("Invalid major version");
|
|
10117
10245
|
}
|
|
@@ -10121,10 +10249,10 @@ var require_semver = __commonJS((exports, module) => {
|
|
|
10121
10249
|
if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
|
|
10122
10250
|
throw new TypeError("Invalid patch version");
|
|
10123
10251
|
}
|
|
10124
|
-
if (!
|
|
10252
|
+
if (!m3[4]) {
|
|
10125
10253
|
this.prerelease = [];
|
|
10126
10254
|
} else {
|
|
10127
|
-
this.prerelease =
|
|
10255
|
+
this.prerelease = m3[4].split(".").map((id) => {
|
|
10128
10256
|
if (/^[0-9]+$/.test(id)) {
|
|
10129
10257
|
const num = +id;
|
|
10130
10258
|
if (num >= 0 && num < MAX_SAFE_INTEGER) {
|
|
@@ -10134,7 +10262,7 @@ var require_semver = __commonJS((exports, module) => {
|
|
|
10134
10262
|
return id;
|
|
10135
10263
|
});
|
|
10136
10264
|
}
|
|
10137
|
-
this.build =
|
|
10265
|
+
this.build = m3[5] ? m3[5].split(".") : [];
|
|
10138
10266
|
this.format();
|
|
10139
10267
|
}
|
|
10140
10268
|
format() {
|
|
@@ -10197,19 +10325,19 @@ var require_semver = __commonJS((exports, module) => {
|
|
|
10197
10325
|
}
|
|
10198
10326
|
let i = 0;
|
|
10199
10327
|
do {
|
|
10200
|
-
const
|
|
10201
|
-
const
|
|
10202
|
-
debug("prerelease compare", i,
|
|
10203
|
-
if (
|
|
10328
|
+
const a2 = this.prerelease[i];
|
|
10329
|
+
const b2 = other.prerelease[i];
|
|
10330
|
+
debug("prerelease compare", i, a2, b2);
|
|
10331
|
+
if (a2 === undefined && b2 === undefined) {
|
|
10204
10332
|
return 0;
|
|
10205
|
-
} else if (
|
|
10333
|
+
} else if (b2 === undefined) {
|
|
10206
10334
|
return 1;
|
|
10207
|
-
} else if (
|
|
10335
|
+
} else if (a2 === undefined) {
|
|
10208
10336
|
return -1;
|
|
10209
|
-
} else if (
|
|
10337
|
+
} else if (a2 === b2) {
|
|
10210
10338
|
continue;
|
|
10211
10339
|
} else {
|
|
10212
|
-
return compareIdentifiers(
|
|
10340
|
+
return compareIdentifiers(a2, b2);
|
|
10213
10341
|
}
|
|
10214
10342
|
} while (++i);
|
|
10215
10343
|
}
|
|
@@ -10219,19 +10347,19 @@ var require_semver = __commonJS((exports, module) => {
|
|
|
10219
10347
|
}
|
|
10220
10348
|
let i = 0;
|
|
10221
10349
|
do {
|
|
10222
|
-
const
|
|
10223
|
-
const
|
|
10224
|
-
debug("build compare", i,
|
|
10225
|
-
if (
|
|
10350
|
+
const a2 = this.build[i];
|
|
10351
|
+
const b2 = other.build[i];
|
|
10352
|
+
debug("build compare", i, a2, b2);
|
|
10353
|
+
if (a2 === undefined && b2 === undefined) {
|
|
10226
10354
|
return 0;
|
|
10227
|
-
} else if (
|
|
10355
|
+
} else if (b2 === undefined) {
|
|
10228
10356
|
return 1;
|
|
10229
|
-
} else if (
|
|
10357
|
+
} else if (a2 === undefined) {
|
|
10230
10358
|
return -1;
|
|
10231
|
-
} else if (
|
|
10359
|
+
} else if (a2 === b2) {
|
|
10232
10360
|
continue;
|
|
10233
10361
|
} else {
|
|
10234
|
-
return compareIdentifiers(
|
|
10362
|
+
return compareIdentifiers(a2, b2);
|
|
10235
10363
|
}
|
|
10236
10364
|
} while (++i);
|
|
10237
10365
|
}
|
|
@@ -10241,7 +10369,7 @@ var require_semver = __commonJS((exports, module) => {
|
|
|
10241
10369
|
throw new Error("invalid increment argument: identifier is empty");
|
|
10242
10370
|
}
|
|
10243
10371
|
if (identifier) {
|
|
10244
|
-
const match2 = `-${identifier}`.match(this.options.loose ?
|
|
10372
|
+
const match2 = `-${identifier}`.match(this.options.loose ? re2[t.PRERELEASELOOSE] : re2[t.PRERELEASE]);
|
|
10245
10373
|
if (!match2 || match2[1] !== identifier) {
|
|
10246
10374
|
throw new Error(`invalid identifier: ${identifier}`);
|
|
10247
10375
|
}
|
|
@@ -10369,8 +10497,8 @@ var require_parse3 = __commonJS((exports, module) => {
|
|
|
10369
10497
|
var require_valid = __commonJS((exports, module) => {
|
|
10370
10498
|
var parse = require_parse3();
|
|
10371
10499
|
var valid = (version, options) => {
|
|
10372
|
-
const
|
|
10373
|
-
return
|
|
10500
|
+
const v2 = parse(version, options);
|
|
10501
|
+
return v2 ? v2.version : null;
|
|
10374
10502
|
};
|
|
10375
10503
|
module.exports = valid;
|
|
10376
10504
|
});
|
|
@@ -10447,21 +10575,21 @@ var require_diff = __commonJS((exports, module) => {
|
|
|
10447
10575
|
// ../../node_modules/.bun/semver@7.7.4/node_modules/semver/functions/major.js
|
|
10448
10576
|
var require_major = __commonJS((exports, module) => {
|
|
10449
10577
|
var SemVer = require_semver();
|
|
10450
|
-
var major = (
|
|
10578
|
+
var major = (a2, loose) => new SemVer(a2, loose).major;
|
|
10451
10579
|
module.exports = major;
|
|
10452
10580
|
});
|
|
10453
10581
|
|
|
10454
10582
|
// ../../node_modules/.bun/semver@7.7.4/node_modules/semver/functions/minor.js
|
|
10455
10583
|
var require_minor = __commonJS((exports, module) => {
|
|
10456
10584
|
var SemVer = require_semver();
|
|
10457
|
-
var minor = (
|
|
10585
|
+
var minor = (a2, loose) => new SemVer(a2, loose).minor;
|
|
10458
10586
|
module.exports = minor;
|
|
10459
10587
|
});
|
|
10460
10588
|
|
|
10461
10589
|
// ../../node_modules/.bun/semver@7.7.4/node_modules/semver/functions/patch.js
|
|
10462
10590
|
var require_patch = __commonJS((exports, module) => {
|
|
10463
10591
|
var SemVer = require_semver();
|
|
10464
|
-
var patch = (
|
|
10592
|
+
var patch = (a2, loose) => new SemVer(a2, loose).patch;
|
|
10465
10593
|
module.exports = patch;
|
|
10466
10594
|
});
|
|
10467
10595
|
|
|
@@ -10478,30 +10606,30 @@ var require_prerelease = __commonJS((exports, module) => {
|
|
|
10478
10606
|
// ../../node_modules/.bun/semver@7.7.4/node_modules/semver/functions/compare.js
|
|
10479
10607
|
var require_compare = __commonJS((exports, module) => {
|
|
10480
10608
|
var SemVer = require_semver();
|
|
10481
|
-
var compare = (
|
|
10609
|
+
var compare = (a2, b2, loose) => new SemVer(a2, loose).compare(new SemVer(b2, loose));
|
|
10482
10610
|
module.exports = compare;
|
|
10483
10611
|
});
|
|
10484
10612
|
|
|
10485
10613
|
// ../../node_modules/.bun/semver@7.7.4/node_modules/semver/functions/rcompare.js
|
|
10486
10614
|
var require_rcompare = __commonJS((exports, module) => {
|
|
10487
10615
|
var compare = require_compare();
|
|
10488
|
-
var rcompare = (
|
|
10616
|
+
var rcompare = (a2, b2, loose) => compare(b2, a2, loose);
|
|
10489
10617
|
module.exports = rcompare;
|
|
10490
10618
|
});
|
|
10491
10619
|
|
|
10492
10620
|
// ../../node_modules/.bun/semver@7.7.4/node_modules/semver/functions/compare-loose.js
|
|
10493
10621
|
var require_compare_loose = __commonJS((exports, module) => {
|
|
10494
10622
|
var compare = require_compare();
|
|
10495
|
-
var compareLoose = (
|
|
10623
|
+
var compareLoose = (a2, b2) => compare(a2, b2, true);
|
|
10496
10624
|
module.exports = compareLoose;
|
|
10497
10625
|
});
|
|
10498
10626
|
|
|
10499
10627
|
// ../../node_modules/.bun/semver@7.7.4/node_modules/semver/functions/compare-build.js
|
|
10500
10628
|
var require_compare_build = __commonJS((exports, module) => {
|
|
10501
10629
|
var SemVer = require_semver();
|
|
10502
|
-
var compareBuild = (
|
|
10503
|
-
const versionA = new SemVer(
|
|
10504
|
-
const versionB = new SemVer(
|
|
10630
|
+
var compareBuild = (a2, b2, loose) => {
|
|
10631
|
+
const versionA = new SemVer(a2, loose);
|
|
10632
|
+
const versionB = new SemVer(b2, loose);
|
|
10505
10633
|
return versionA.compare(versionB) || versionA.compareBuild(versionB);
|
|
10506
10634
|
};
|
|
10507
10635
|
module.exports = compareBuild;
|
|
@@ -10510,56 +10638,56 @@ var require_compare_build = __commonJS((exports, module) => {
|
|
|
10510
10638
|
// ../../node_modules/.bun/semver@7.7.4/node_modules/semver/functions/sort.js
|
|
10511
10639
|
var require_sort = __commonJS((exports, module) => {
|
|
10512
10640
|
var compareBuild = require_compare_build();
|
|
10513
|
-
var sort = (list, loose) => list.sort((
|
|
10641
|
+
var sort = (list, loose) => list.sort((a2, b2) => compareBuild(a2, b2, loose));
|
|
10514
10642
|
module.exports = sort;
|
|
10515
10643
|
});
|
|
10516
10644
|
|
|
10517
10645
|
// ../../node_modules/.bun/semver@7.7.4/node_modules/semver/functions/rsort.js
|
|
10518
10646
|
var require_rsort = __commonJS((exports, module) => {
|
|
10519
10647
|
var compareBuild = require_compare_build();
|
|
10520
|
-
var rsort = (list, loose) => list.sort((
|
|
10648
|
+
var rsort = (list, loose) => list.sort((a2, b2) => compareBuild(b2, a2, loose));
|
|
10521
10649
|
module.exports = rsort;
|
|
10522
10650
|
});
|
|
10523
10651
|
|
|
10524
10652
|
// ../../node_modules/.bun/semver@7.7.4/node_modules/semver/functions/gt.js
|
|
10525
10653
|
var require_gt = __commonJS((exports, module) => {
|
|
10526
10654
|
var compare = require_compare();
|
|
10527
|
-
var gt = (
|
|
10655
|
+
var gt = (a2, b2, loose) => compare(a2, b2, loose) > 0;
|
|
10528
10656
|
module.exports = gt;
|
|
10529
10657
|
});
|
|
10530
10658
|
|
|
10531
10659
|
// ../../node_modules/.bun/semver@7.7.4/node_modules/semver/functions/lt.js
|
|
10532
10660
|
var require_lt = __commonJS((exports, module) => {
|
|
10533
10661
|
var compare = require_compare();
|
|
10534
|
-
var lt = (
|
|
10662
|
+
var lt = (a2, b2, loose) => compare(a2, b2, loose) < 0;
|
|
10535
10663
|
module.exports = lt;
|
|
10536
10664
|
});
|
|
10537
10665
|
|
|
10538
10666
|
// ../../node_modules/.bun/semver@7.7.4/node_modules/semver/functions/eq.js
|
|
10539
10667
|
var require_eq = __commonJS((exports, module) => {
|
|
10540
10668
|
var compare = require_compare();
|
|
10541
|
-
var eq = (
|
|
10669
|
+
var eq = (a2, b2, loose) => compare(a2, b2, loose) === 0;
|
|
10542
10670
|
module.exports = eq;
|
|
10543
10671
|
});
|
|
10544
10672
|
|
|
10545
10673
|
// ../../node_modules/.bun/semver@7.7.4/node_modules/semver/functions/neq.js
|
|
10546
10674
|
var require_neq = __commonJS((exports, module) => {
|
|
10547
10675
|
var compare = require_compare();
|
|
10548
|
-
var neq = (
|
|
10676
|
+
var neq = (a2, b2, loose) => compare(a2, b2, loose) !== 0;
|
|
10549
10677
|
module.exports = neq;
|
|
10550
10678
|
});
|
|
10551
10679
|
|
|
10552
10680
|
// ../../node_modules/.bun/semver@7.7.4/node_modules/semver/functions/gte.js
|
|
10553
10681
|
var require_gte = __commonJS((exports, module) => {
|
|
10554
10682
|
var compare = require_compare();
|
|
10555
|
-
var gte = (
|
|
10683
|
+
var gte = (a2, b2, loose) => compare(a2, b2, loose) >= 0;
|
|
10556
10684
|
module.exports = gte;
|
|
10557
10685
|
});
|
|
10558
10686
|
|
|
10559
10687
|
// ../../node_modules/.bun/semver@7.7.4/node_modules/semver/functions/lte.js
|
|
10560
10688
|
var require_lte = __commonJS((exports, module) => {
|
|
10561
10689
|
var compare = require_compare();
|
|
10562
|
-
var lte = (
|
|
10690
|
+
var lte = (a2, b2, loose) => compare(a2, b2, loose) <= 0;
|
|
10563
10691
|
module.exports = lte;
|
|
10564
10692
|
});
|
|
10565
10693
|
|
|
@@ -10571,38 +10699,38 @@ var require_cmp = __commonJS((exports, module) => {
|
|
|
10571
10699
|
var gte = require_gte();
|
|
10572
10700
|
var lt = require_lt();
|
|
10573
10701
|
var lte = require_lte();
|
|
10574
|
-
var cmp = (
|
|
10702
|
+
var cmp = (a2, op, b2, loose) => {
|
|
10575
10703
|
switch (op) {
|
|
10576
10704
|
case "===":
|
|
10577
|
-
if (typeof
|
|
10578
|
-
|
|
10705
|
+
if (typeof a2 === "object") {
|
|
10706
|
+
a2 = a2.version;
|
|
10579
10707
|
}
|
|
10580
|
-
if (typeof
|
|
10581
|
-
|
|
10708
|
+
if (typeof b2 === "object") {
|
|
10709
|
+
b2 = b2.version;
|
|
10582
10710
|
}
|
|
10583
|
-
return
|
|
10711
|
+
return a2 === b2;
|
|
10584
10712
|
case "!==":
|
|
10585
|
-
if (typeof
|
|
10586
|
-
|
|
10713
|
+
if (typeof a2 === "object") {
|
|
10714
|
+
a2 = a2.version;
|
|
10587
10715
|
}
|
|
10588
|
-
if (typeof
|
|
10589
|
-
|
|
10716
|
+
if (typeof b2 === "object") {
|
|
10717
|
+
b2 = b2.version;
|
|
10590
10718
|
}
|
|
10591
|
-
return
|
|
10719
|
+
return a2 !== b2;
|
|
10592
10720
|
case "":
|
|
10593
10721
|
case "=":
|
|
10594
10722
|
case "==":
|
|
10595
|
-
return eq(
|
|
10723
|
+
return eq(a2, b2, loose);
|
|
10596
10724
|
case "!=":
|
|
10597
|
-
return neq(
|
|
10725
|
+
return neq(a2, b2, loose);
|
|
10598
10726
|
case ">":
|
|
10599
|
-
return gt(
|
|
10727
|
+
return gt(a2, b2, loose);
|
|
10600
10728
|
case ">=":
|
|
10601
|
-
return gte(
|
|
10729
|
+
return gte(a2, b2, loose);
|
|
10602
10730
|
case "<":
|
|
10603
|
-
return lt(
|
|
10731
|
+
return lt(a2, b2, loose);
|
|
10604
10732
|
case "<=":
|
|
10605
|
-
return lte(
|
|
10733
|
+
return lte(a2, b2, loose);
|
|
10606
10734
|
default:
|
|
10607
10735
|
throw new TypeError(`Invalid operator: ${op}`);
|
|
10608
10736
|
}
|
|
@@ -10614,7 +10742,7 @@ var require_cmp = __commonJS((exports, module) => {
|
|
|
10614
10742
|
var require_coerce = __commonJS((exports, module) => {
|
|
10615
10743
|
var SemVer = require_semver();
|
|
10616
10744
|
var parse = require_parse3();
|
|
10617
|
-
var { safeRe:
|
|
10745
|
+
var { safeRe: re2, t } = require_re();
|
|
10618
10746
|
var coerce = (version, options) => {
|
|
10619
10747
|
if (version instanceof SemVer) {
|
|
10620
10748
|
return version;
|
|
@@ -10628,9 +10756,9 @@ var require_coerce = __commonJS((exports, module) => {
|
|
|
10628
10756
|
options = options || {};
|
|
10629
10757
|
let match2 = null;
|
|
10630
10758
|
if (!options.rtl) {
|
|
10631
|
-
match2 = version.match(options.includePrerelease ?
|
|
10759
|
+
match2 = version.match(options.includePrerelease ? re2[t.COERCEFULL] : re2[t.COERCE]);
|
|
10632
10760
|
} else {
|
|
10633
|
-
const coerceRtlRegex = options.includePrerelease ?
|
|
10761
|
+
const coerceRtlRegex = options.includePrerelease ? re2[t.COERCERTLFULL] : re2[t.COERCERTL];
|
|
10634
10762
|
let next;
|
|
10635
10763
|
while ((next = coerceRtlRegex.exec(version)) && (!match2 || match2.index + match2[0].length !== version.length)) {
|
|
10636
10764
|
if (!match2 || next.index + next[0].length !== match2.index + match2[0].length) {
|
|
@@ -10712,19 +10840,19 @@ var require_range = __commonJS((exports, module) => {
|
|
|
10712
10840
|
this.loose = !!options.loose;
|
|
10713
10841
|
this.includePrerelease = !!options.includePrerelease;
|
|
10714
10842
|
this.raw = range.trim().replace(SPACE_CHARACTERS, " ");
|
|
10715
|
-
this.set = this.raw.split("||").map((
|
|
10843
|
+
this.set = this.raw.split("||").map((r2) => this.parseRange(r2.trim())).filter((c2) => c2.length);
|
|
10716
10844
|
if (!this.set.length) {
|
|
10717
10845
|
throw new TypeError(`Invalid SemVer Range: ${this.raw}`);
|
|
10718
10846
|
}
|
|
10719
10847
|
if (this.set.length > 1) {
|
|
10720
10848
|
const first = this.set[0];
|
|
10721
|
-
this.set = this.set.filter((
|
|
10849
|
+
this.set = this.set.filter((c2) => !isNullSet(c2[0]));
|
|
10722
10850
|
if (this.set.length === 0) {
|
|
10723
10851
|
this.set = [first];
|
|
10724
10852
|
} else if (this.set.length > 1) {
|
|
10725
|
-
for (const
|
|
10726
|
-
if (
|
|
10727
|
-
this.set = [
|
|
10853
|
+
for (const c2 of this.set) {
|
|
10854
|
+
if (c2.length === 1 && isAny(c2[0])) {
|
|
10855
|
+
this.set = [c2];
|
|
10728
10856
|
break;
|
|
10729
10857
|
}
|
|
10730
10858
|
}
|
|
@@ -10740,11 +10868,11 @@ var require_range = __commonJS((exports, module) => {
|
|
|
10740
10868
|
this.formatted += "||";
|
|
10741
10869
|
}
|
|
10742
10870
|
const comps = this.set[i];
|
|
10743
|
-
for (let
|
|
10744
|
-
if (
|
|
10871
|
+
for (let k3 = 0;k3 < comps.length; k3++) {
|
|
10872
|
+
if (k3 > 0) {
|
|
10745
10873
|
this.formatted += " ";
|
|
10746
10874
|
}
|
|
10747
|
-
this.formatted += comps[
|
|
10875
|
+
this.formatted += comps[k3].toString().trim();
|
|
10748
10876
|
}
|
|
10749
10877
|
}
|
|
10750
10878
|
}
|
|
@@ -10764,20 +10892,20 @@ var require_range = __commonJS((exports, module) => {
|
|
|
10764
10892
|
return cached;
|
|
10765
10893
|
}
|
|
10766
10894
|
const loose = this.options.loose;
|
|
10767
|
-
const hr = loose ?
|
|
10895
|
+
const hr = loose ? re2[t.HYPHENRANGELOOSE] : re2[t.HYPHENRANGE];
|
|
10768
10896
|
range = range.replace(hr, hyphenReplace(this.options.includePrerelease));
|
|
10769
10897
|
debug("hyphen replace", range);
|
|
10770
|
-
range = range.replace(
|
|
10898
|
+
range = range.replace(re2[t.COMPARATORTRIM], comparatorTrimReplace);
|
|
10771
10899
|
debug("comparator trim", range);
|
|
10772
|
-
range = range.replace(
|
|
10900
|
+
range = range.replace(re2[t.TILDETRIM], tildeTrimReplace);
|
|
10773
10901
|
debug("tilde trim", range);
|
|
10774
|
-
range = range.replace(
|
|
10902
|
+
range = range.replace(re2[t.CARETTRIM], caretTrimReplace);
|
|
10775
10903
|
debug("caret trim", range);
|
|
10776
10904
|
let rangeList = range.split(" ").map((comp) => parseComparator(comp, this.options)).join(" ").split(/\s+/).map((comp) => replaceGTE0(comp, this.options));
|
|
10777
10905
|
if (loose) {
|
|
10778
10906
|
rangeList = rangeList.filter((comp) => {
|
|
10779
10907
|
debug("loose invalid filter", comp, this.options);
|
|
10780
|
-
return !!comp.match(
|
|
10908
|
+
return !!comp.match(re2[t.COMPARATORLOOSE]);
|
|
10781
10909
|
});
|
|
10782
10910
|
}
|
|
10783
10911
|
debug("range list", rangeList);
|
|
@@ -10837,15 +10965,15 @@ var require_range = __commonJS((exports, module) => {
|
|
|
10837
10965
|
var debug = require_debug();
|
|
10838
10966
|
var SemVer = require_semver();
|
|
10839
10967
|
var {
|
|
10840
|
-
safeRe:
|
|
10968
|
+
safeRe: re2,
|
|
10841
10969
|
t,
|
|
10842
10970
|
comparatorTrimReplace,
|
|
10843
10971
|
tildeTrimReplace,
|
|
10844
10972
|
caretTrimReplace
|
|
10845
10973
|
} = require_re();
|
|
10846
10974
|
var { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require_constants4();
|
|
10847
|
-
var isNullSet = (
|
|
10848
|
-
var isAny = (
|
|
10975
|
+
var isNullSet = (c2) => c2.value === "<0.0.0-0";
|
|
10976
|
+
var isAny = (c2) => c2.value === "";
|
|
10849
10977
|
var isSatisfiable = (comparators, options) => {
|
|
10850
10978
|
let result = true;
|
|
10851
10979
|
const remainingComparators = comparators.slice();
|
|
@@ -10859,7 +10987,7 @@ var require_range = __commonJS((exports, module) => {
|
|
|
10859
10987
|
return result;
|
|
10860
10988
|
};
|
|
10861
10989
|
var parseComparator = (comp, options) => {
|
|
10862
|
-
comp = comp.replace(
|
|
10990
|
+
comp = comp.replace(re2[t.BUILD], "");
|
|
10863
10991
|
debug("comp", comp, options);
|
|
10864
10992
|
comp = replaceCarets(comp, options);
|
|
10865
10993
|
debug("caret", comp);
|
|
@@ -10873,70 +11001,70 @@ var require_range = __commonJS((exports, module) => {
|
|
|
10873
11001
|
};
|
|
10874
11002
|
var isX = (id) => !id || id.toLowerCase() === "x" || id === "*";
|
|
10875
11003
|
var replaceTildes = (comp, options) => {
|
|
10876
|
-
return comp.trim().split(/\s+/).map((
|
|
11004
|
+
return comp.trim().split(/\s+/).map((c2) => replaceTilde(c2, options)).join(" ");
|
|
10877
11005
|
};
|
|
10878
11006
|
var replaceTilde = (comp, options) => {
|
|
10879
|
-
const
|
|
10880
|
-
return comp.replace(
|
|
10881
|
-
debug("tilde", comp,
|
|
11007
|
+
const r2 = options.loose ? re2[t.TILDELOOSE] : re2[t.TILDE];
|
|
11008
|
+
return comp.replace(r2, (_2, M3, m3, p2, pr) => {
|
|
11009
|
+
debug("tilde", comp, _2, M3, m3, p2, pr);
|
|
10882
11010
|
let ret;
|
|
10883
|
-
if (isX(
|
|
11011
|
+
if (isX(M3)) {
|
|
10884
11012
|
ret = "";
|
|
10885
|
-
} else if (isX(
|
|
10886
|
-
ret = `>=${
|
|
10887
|
-
} else if (isX(
|
|
10888
|
-
ret = `>=${
|
|
11013
|
+
} else if (isX(m3)) {
|
|
11014
|
+
ret = `>=${M3}.0.0 <${+M3 + 1}.0.0-0`;
|
|
11015
|
+
} else if (isX(p2)) {
|
|
11016
|
+
ret = `>=${M3}.${m3}.0 <${M3}.${+m3 + 1}.0-0`;
|
|
10889
11017
|
} else if (pr) {
|
|
10890
11018
|
debug("replaceTilde pr", pr);
|
|
10891
|
-
ret = `>=${
|
|
11019
|
+
ret = `>=${M3}.${m3}.${p2}-${pr} <${M3}.${+m3 + 1}.0-0`;
|
|
10892
11020
|
} else {
|
|
10893
|
-
ret = `>=${
|
|
11021
|
+
ret = `>=${M3}.${m3}.${p2} <${M3}.${+m3 + 1}.0-0`;
|
|
10894
11022
|
}
|
|
10895
11023
|
debug("tilde return", ret);
|
|
10896
11024
|
return ret;
|
|
10897
11025
|
});
|
|
10898
11026
|
};
|
|
10899
11027
|
var replaceCarets = (comp, options) => {
|
|
10900
|
-
return comp.trim().split(/\s+/).map((
|
|
11028
|
+
return comp.trim().split(/\s+/).map((c2) => replaceCaret(c2, options)).join(" ");
|
|
10901
11029
|
};
|
|
10902
11030
|
var replaceCaret = (comp, options) => {
|
|
10903
11031
|
debug("caret", comp, options);
|
|
10904
|
-
const
|
|
10905
|
-
const
|
|
10906
|
-
return comp.replace(
|
|
10907
|
-
debug("caret", comp,
|
|
11032
|
+
const r2 = options.loose ? re2[t.CARETLOOSE] : re2[t.CARET];
|
|
11033
|
+
const z2 = options.includePrerelease ? "-0" : "";
|
|
11034
|
+
return comp.replace(r2, (_2, M3, m3, p2, pr) => {
|
|
11035
|
+
debug("caret", comp, _2, M3, m3, p2, pr);
|
|
10908
11036
|
let ret;
|
|
10909
|
-
if (isX(
|
|
11037
|
+
if (isX(M3)) {
|
|
10910
11038
|
ret = "";
|
|
10911
|
-
} else if (isX(
|
|
10912
|
-
ret = `>=${
|
|
10913
|
-
} else if (isX(
|
|
10914
|
-
if (
|
|
10915
|
-
ret = `>=${
|
|
11039
|
+
} else if (isX(m3)) {
|
|
11040
|
+
ret = `>=${M3}.0.0${z2} <${+M3 + 1}.0.0-0`;
|
|
11041
|
+
} else if (isX(p2)) {
|
|
11042
|
+
if (M3 === "0") {
|
|
11043
|
+
ret = `>=${M3}.${m3}.0${z2} <${M3}.${+m3 + 1}.0-0`;
|
|
10916
11044
|
} else {
|
|
10917
|
-
ret = `>=${
|
|
11045
|
+
ret = `>=${M3}.${m3}.0${z2} <${+M3 + 1}.0.0-0`;
|
|
10918
11046
|
}
|
|
10919
11047
|
} else if (pr) {
|
|
10920
11048
|
debug("replaceCaret pr", pr);
|
|
10921
|
-
if (
|
|
10922
|
-
if (
|
|
10923
|
-
ret = `>=${
|
|
11049
|
+
if (M3 === "0") {
|
|
11050
|
+
if (m3 === "0") {
|
|
11051
|
+
ret = `>=${M3}.${m3}.${p2}-${pr} <${M3}.${m3}.${+p2 + 1}-0`;
|
|
10924
11052
|
} else {
|
|
10925
|
-
ret = `>=${
|
|
11053
|
+
ret = `>=${M3}.${m3}.${p2}-${pr} <${M3}.${+m3 + 1}.0-0`;
|
|
10926
11054
|
}
|
|
10927
11055
|
} else {
|
|
10928
|
-
ret = `>=${
|
|
11056
|
+
ret = `>=${M3}.${m3}.${p2}-${pr} <${+M3 + 1}.0.0-0`;
|
|
10929
11057
|
}
|
|
10930
11058
|
} else {
|
|
10931
11059
|
debug("no pr");
|
|
10932
|
-
if (
|
|
10933
|
-
if (
|
|
10934
|
-
ret = `>=${
|
|
11060
|
+
if (M3 === "0") {
|
|
11061
|
+
if (m3 === "0") {
|
|
11062
|
+
ret = `>=${M3}.${m3}.${p2}${z2} <${M3}.${m3}.${+p2 + 1}-0`;
|
|
10935
11063
|
} else {
|
|
10936
|
-
ret = `>=${
|
|
11064
|
+
ret = `>=${M3}.${m3}.${p2}${z2} <${M3}.${+m3 + 1}.0-0`;
|
|
10937
11065
|
}
|
|
10938
11066
|
} else {
|
|
10939
|
-
ret = `>=${
|
|
11067
|
+
ret = `>=${M3}.${m3}.${p2} <${+M3 + 1}.0.0-0`;
|
|
10940
11068
|
}
|
|
10941
11069
|
}
|
|
10942
11070
|
debug("caret return", ret);
|
|
@@ -10945,16 +11073,16 @@ var require_range = __commonJS((exports, module) => {
|
|
|
10945
11073
|
};
|
|
10946
11074
|
var replaceXRanges = (comp, options) => {
|
|
10947
11075
|
debug("replaceXRanges", comp, options);
|
|
10948
|
-
return comp.split(/\s+/).map((
|
|
11076
|
+
return comp.split(/\s+/).map((c2) => replaceXRange(c2, options)).join(" ");
|
|
10949
11077
|
};
|
|
10950
11078
|
var replaceXRange = (comp, options) => {
|
|
10951
11079
|
comp = comp.trim();
|
|
10952
|
-
const
|
|
10953
|
-
return comp.replace(
|
|
10954
|
-
debug("xRange", comp, ret, gtlt,
|
|
10955
|
-
const xM = isX(
|
|
10956
|
-
const xm = xM || isX(
|
|
10957
|
-
const xp = xm || isX(
|
|
11080
|
+
const r2 = options.loose ? re2[t.XRANGELOOSE] : re2[t.XRANGE];
|
|
11081
|
+
return comp.replace(r2, (ret, gtlt, M3, m3, p2, pr) => {
|
|
11082
|
+
debug("xRange", comp, ret, gtlt, M3, m3, p2, pr);
|
|
11083
|
+
const xM = isX(M3);
|
|
11084
|
+
const xm = xM || isX(m3);
|
|
11085
|
+
const xp = xm || isX(p2);
|
|
10958
11086
|
const anyX = xp;
|
|
10959
11087
|
if (gtlt === "=" && anyX) {
|
|
10960
11088
|
gtlt = "";
|
|
@@ -10968,35 +11096,35 @@ var require_range = __commonJS((exports, module) => {
|
|
|
10968
11096
|
}
|
|
10969
11097
|
} else if (gtlt && anyX) {
|
|
10970
11098
|
if (xm) {
|
|
10971
|
-
|
|
11099
|
+
m3 = 0;
|
|
10972
11100
|
}
|
|
10973
|
-
|
|
11101
|
+
p2 = 0;
|
|
10974
11102
|
if (gtlt === ">") {
|
|
10975
11103
|
gtlt = ">=";
|
|
10976
11104
|
if (xm) {
|
|
10977
|
-
|
|
10978
|
-
|
|
10979
|
-
|
|
11105
|
+
M3 = +M3 + 1;
|
|
11106
|
+
m3 = 0;
|
|
11107
|
+
p2 = 0;
|
|
10980
11108
|
} else {
|
|
10981
|
-
|
|
10982
|
-
|
|
11109
|
+
m3 = +m3 + 1;
|
|
11110
|
+
p2 = 0;
|
|
10983
11111
|
}
|
|
10984
11112
|
} else if (gtlt === "<=") {
|
|
10985
11113
|
gtlt = "<";
|
|
10986
11114
|
if (xm) {
|
|
10987
|
-
|
|
11115
|
+
M3 = +M3 + 1;
|
|
10988
11116
|
} else {
|
|
10989
|
-
|
|
11117
|
+
m3 = +m3 + 1;
|
|
10990
11118
|
}
|
|
10991
11119
|
}
|
|
10992
11120
|
if (gtlt === "<") {
|
|
10993
11121
|
pr = "-0";
|
|
10994
11122
|
}
|
|
10995
|
-
ret = `${gtlt +
|
|
11123
|
+
ret = `${gtlt + M3}.${m3}.${p2}${pr}`;
|
|
10996
11124
|
} else if (xm) {
|
|
10997
|
-
ret = `>=${
|
|
11125
|
+
ret = `>=${M3}.0.0${pr} <${+M3 + 1}.0.0-0`;
|
|
10998
11126
|
} else if (xp) {
|
|
10999
|
-
ret = `>=${
|
|
11127
|
+
ret = `>=${M3}.${m3}.0${pr} <${M3}.${+m3 + 1}.0-0`;
|
|
11000
11128
|
}
|
|
11001
11129
|
debug("xRange return", ret);
|
|
11002
11130
|
return ret;
|
|
@@ -11004,11 +11132,11 @@ var require_range = __commonJS((exports, module) => {
|
|
|
11004
11132
|
};
|
|
11005
11133
|
var replaceStars = (comp, options) => {
|
|
11006
11134
|
debug("replaceStars", comp, options);
|
|
11007
|
-
return comp.trim().replace(
|
|
11135
|
+
return comp.trim().replace(re2[t.STAR], "");
|
|
11008
11136
|
};
|
|
11009
11137
|
var replaceGTE0 = (comp, options) => {
|
|
11010
11138
|
debug("replaceGTE0", comp, options);
|
|
11011
|
-
return comp.trim().replace(
|
|
11139
|
+
return comp.trim().replace(re2[options.includePrerelease ? t.GTE0PRE : t.GTE0], "");
|
|
11012
11140
|
};
|
|
11013
11141
|
var hyphenReplace = (incPr) => ($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr) => {
|
|
11014
11142
|
if (isX(fM)) {
|
|
@@ -11092,19 +11220,19 @@ var require_comparator = __commonJS((exports, module) => {
|
|
|
11092
11220
|
debug("comp", this);
|
|
11093
11221
|
}
|
|
11094
11222
|
parse(comp) {
|
|
11095
|
-
const
|
|
11096
|
-
const
|
|
11097
|
-
if (!
|
|
11223
|
+
const r2 = this.options.loose ? re2[t.COMPARATORLOOSE] : re2[t.COMPARATOR];
|
|
11224
|
+
const m3 = comp.match(r2);
|
|
11225
|
+
if (!m3) {
|
|
11098
11226
|
throw new TypeError(`Invalid comparator: ${comp}`);
|
|
11099
11227
|
}
|
|
11100
|
-
this.operator =
|
|
11228
|
+
this.operator = m3[1] !== undefined ? m3[1] : "";
|
|
11101
11229
|
if (this.operator === "=") {
|
|
11102
11230
|
this.operator = "";
|
|
11103
11231
|
}
|
|
11104
|
-
if (!
|
|
11232
|
+
if (!m3[2]) {
|
|
11105
11233
|
this.semver = ANY;
|
|
11106
11234
|
} else {
|
|
11107
|
-
this.semver = new SemVer(
|
|
11235
|
+
this.semver = new SemVer(m3[2], this.options.loose);
|
|
11108
11236
|
}
|
|
11109
11237
|
}
|
|
11110
11238
|
toString() {
|
|
@@ -11166,7 +11294,7 @@ var require_comparator = __commonJS((exports, module) => {
|
|
|
11166
11294
|
}
|
|
11167
11295
|
module.exports = Comparator;
|
|
11168
11296
|
var parseOptions = require_parse_options();
|
|
11169
|
-
var { safeRe:
|
|
11297
|
+
var { safeRe: re2, t } = require_re();
|
|
11170
11298
|
var cmp = require_cmp();
|
|
11171
11299
|
var debug = require_debug();
|
|
11172
11300
|
var SemVer = require_semver();
|
|
@@ -11190,7 +11318,7 @@ var require_satisfies = __commonJS((exports, module) => {
|
|
|
11190
11318
|
// ../../node_modules/.bun/semver@7.7.4/node_modules/semver/ranges/to-comparators.js
|
|
11191
11319
|
var require_to_comparators = __commonJS((exports, module) => {
|
|
11192
11320
|
var Range = require_range();
|
|
11193
|
-
var toComparators = (range, options) => new Range(range, options).set.map((comp) => comp.map((
|
|
11321
|
+
var toComparators = (range, options) => new Range(range, options).set.map((comp) => comp.map((c2) => c2.value).join(" ").trim().split(" "));
|
|
11194
11322
|
module.exports = toComparators;
|
|
11195
11323
|
});
|
|
11196
11324
|
|
|
@@ -11207,10 +11335,10 @@ var require_max_satisfying = __commonJS((exports, module) => {
|
|
|
11207
11335
|
} catch (er) {
|
|
11208
11336
|
return null;
|
|
11209
11337
|
}
|
|
11210
|
-
versions.forEach((
|
|
11211
|
-
if (rangeObj.test(
|
|
11212
|
-
if (!max || maxSV.compare(
|
|
11213
|
-
max =
|
|
11338
|
+
versions.forEach((v2) => {
|
|
11339
|
+
if (rangeObj.test(v2)) {
|
|
11340
|
+
if (!max || maxSV.compare(v2) === -1) {
|
|
11341
|
+
max = v2;
|
|
11214
11342
|
maxSV = new SemVer(max, options);
|
|
11215
11343
|
}
|
|
11216
11344
|
}
|
|
@@ -11233,10 +11361,10 @@ var require_min_satisfying = __commonJS((exports, module) => {
|
|
|
11233
11361
|
} catch (er) {
|
|
11234
11362
|
return null;
|
|
11235
11363
|
}
|
|
11236
|
-
versions.forEach((
|
|
11237
|
-
if (rangeObj.test(
|
|
11238
|
-
if (!min || minSV.compare(
|
|
11239
|
-
min =
|
|
11364
|
+
versions.forEach((v2) => {
|
|
11365
|
+
if (rangeObj.test(v2)) {
|
|
11366
|
+
if (!min || minSV.compare(v2) === 1) {
|
|
11367
|
+
min = v2;
|
|
11240
11368
|
minSV = new SemVer(min, options);
|
|
11241
11369
|
}
|
|
11242
11370
|
}
|
|
@@ -11412,8 +11540,8 @@ var require_simplify = __commonJS((exports, module) => {
|
|
|
11412
11540
|
const set = [];
|
|
11413
11541
|
let first = null;
|
|
11414
11542
|
let prev = null;
|
|
11415
|
-
const
|
|
11416
|
-
for (const version of
|
|
11543
|
+
const v2 = versions.sort((a2, b2) => compare(a2, b2, options));
|
|
11544
|
+
for (const version of v2) {
|
|
11417
11545
|
const included = satisfies(version, range, options);
|
|
11418
11546
|
if (included) {
|
|
11419
11547
|
prev = version;
|
|
@@ -11435,11 +11563,11 @@ var require_simplify = __commonJS((exports, module) => {
|
|
|
11435
11563
|
for (const [min, max] of set) {
|
|
11436
11564
|
if (min === max) {
|
|
11437
11565
|
ranges.push(min);
|
|
11438
|
-
} else if (!max && min ===
|
|
11566
|
+
} else if (!max && min === v2[0]) {
|
|
11439
11567
|
ranges.push("*");
|
|
11440
11568
|
} else if (!max) {
|
|
11441
11569
|
ranges.push(`>=${min}`);
|
|
11442
|
-
} else if (min ===
|
|
11570
|
+
} else if (min === v2[0]) {
|
|
11443
11571
|
ranges.push(`<=${max}`);
|
|
11444
11572
|
} else {
|
|
11445
11573
|
ranges.push(`${min} - ${max}`);
|
|
@@ -11504,13 +11632,13 @@ var require_subset = __commonJS((exports, module) => {
|
|
|
11504
11632
|
}
|
|
11505
11633
|
const eqSet = new Set;
|
|
11506
11634
|
let gt, lt;
|
|
11507
|
-
for (const
|
|
11508
|
-
if (
|
|
11509
|
-
gt = higherGT(gt,
|
|
11510
|
-
} else if (
|
|
11511
|
-
lt = lowerLT(lt,
|
|
11635
|
+
for (const c2 of sub) {
|
|
11636
|
+
if (c2.operator === ">" || c2.operator === ">=") {
|
|
11637
|
+
gt = higherGT(gt, c2, options);
|
|
11638
|
+
} else if (c2.operator === "<" || c2.operator === "<=") {
|
|
11639
|
+
lt = lowerLT(lt, c2, options);
|
|
11512
11640
|
} else {
|
|
11513
|
-
eqSet.add(
|
|
11641
|
+
eqSet.add(c2.semver);
|
|
11514
11642
|
}
|
|
11515
11643
|
}
|
|
11516
11644
|
if (eqSet.size > 1) {
|
|
@@ -11532,8 +11660,8 @@ var require_subset = __commonJS((exports, module) => {
|
|
|
11532
11660
|
if (lt && !satisfies(eq, String(lt), options)) {
|
|
11533
11661
|
return null;
|
|
11534
11662
|
}
|
|
11535
|
-
for (const
|
|
11536
|
-
if (!satisfies(eq, String(
|
|
11663
|
+
for (const c2 of dom) {
|
|
11664
|
+
if (!satisfies(eq, String(c2), options)) {
|
|
11537
11665
|
return false;
|
|
11538
11666
|
}
|
|
11539
11667
|
}
|
|
@@ -11546,40 +11674,40 @@ var require_subset = __commonJS((exports, module) => {
|
|
|
11546
11674
|
if (needDomLTPre && needDomLTPre.prerelease.length === 1 && lt.operator === "<" && needDomLTPre.prerelease[0] === 0) {
|
|
11547
11675
|
needDomLTPre = false;
|
|
11548
11676
|
}
|
|
11549
|
-
for (const
|
|
11550
|
-
hasDomGT = hasDomGT ||
|
|
11551
|
-
hasDomLT = hasDomLT ||
|
|
11677
|
+
for (const c2 of dom) {
|
|
11678
|
+
hasDomGT = hasDomGT || c2.operator === ">" || c2.operator === ">=";
|
|
11679
|
+
hasDomLT = hasDomLT || c2.operator === "<" || c2.operator === "<=";
|
|
11552
11680
|
if (gt) {
|
|
11553
11681
|
if (needDomGTPre) {
|
|
11554
|
-
if (
|
|
11682
|
+
if (c2.semver.prerelease && c2.semver.prerelease.length && c2.semver.major === needDomGTPre.major && c2.semver.minor === needDomGTPre.minor && c2.semver.patch === needDomGTPre.patch) {
|
|
11555
11683
|
needDomGTPre = false;
|
|
11556
11684
|
}
|
|
11557
11685
|
}
|
|
11558
|
-
if (
|
|
11559
|
-
higher = higherGT(gt,
|
|
11560
|
-
if (higher ===
|
|
11686
|
+
if (c2.operator === ">" || c2.operator === ">=") {
|
|
11687
|
+
higher = higherGT(gt, c2, options);
|
|
11688
|
+
if (higher === c2 && higher !== gt) {
|
|
11561
11689
|
return false;
|
|
11562
11690
|
}
|
|
11563
|
-
} else if (gt.operator === ">=" && !satisfies(gt.semver, String(
|
|
11691
|
+
} else if (gt.operator === ">=" && !satisfies(gt.semver, String(c2), options)) {
|
|
11564
11692
|
return false;
|
|
11565
11693
|
}
|
|
11566
11694
|
}
|
|
11567
11695
|
if (lt) {
|
|
11568
11696
|
if (needDomLTPre) {
|
|
11569
|
-
if (
|
|
11697
|
+
if (c2.semver.prerelease && c2.semver.prerelease.length && c2.semver.major === needDomLTPre.major && c2.semver.minor === needDomLTPre.minor && c2.semver.patch === needDomLTPre.patch) {
|
|
11570
11698
|
needDomLTPre = false;
|
|
11571
11699
|
}
|
|
11572
11700
|
}
|
|
11573
|
-
if (
|
|
11574
|
-
lower = lowerLT(lt,
|
|
11575
|
-
if (lower ===
|
|
11701
|
+
if (c2.operator === "<" || c2.operator === "<=") {
|
|
11702
|
+
lower = lowerLT(lt, c2, options);
|
|
11703
|
+
if (lower === c2 && lower !== lt) {
|
|
11576
11704
|
return false;
|
|
11577
11705
|
}
|
|
11578
|
-
} else if (lt.operator === "<=" && !satisfies(lt.semver, String(
|
|
11706
|
+
} else if (lt.operator === "<=" && !satisfies(lt.semver, String(c2), options)) {
|
|
11579
11707
|
return false;
|
|
11580
11708
|
}
|
|
11581
11709
|
}
|
|
11582
|
-
if (!
|
|
11710
|
+
if (!c2.operator && (lt || gt) && gtltComp !== 0) {
|
|
11583
11711
|
return false;
|
|
11584
11712
|
}
|
|
11585
11713
|
}
|
|
@@ -11594,19 +11722,19 @@ var require_subset = __commonJS((exports, module) => {
|
|
|
11594
11722
|
}
|
|
11595
11723
|
return true;
|
|
11596
11724
|
};
|
|
11597
|
-
var higherGT = (
|
|
11598
|
-
if (!
|
|
11599
|
-
return
|
|
11725
|
+
var higherGT = (a2, b2, options) => {
|
|
11726
|
+
if (!a2) {
|
|
11727
|
+
return b2;
|
|
11600
11728
|
}
|
|
11601
|
-
const comp = compare(
|
|
11602
|
-
return comp > 0 ?
|
|
11729
|
+
const comp = compare(a2.semver, b2.semver, options);
|
|
11730
|
+
return comp > 0 ? a2 : comp < 0 ? b2 : b2.operator === ">" && a2.operator === ">=" ? b2 : a2;
|
|
11603
11731
|
};
|
|
11604
|
-
var lowerLT = (
|
|
11605
|
-
if (!
|
|
11606
|
-
return
|
|
11732
|
+
var lowerLT = (a2, b2, options) => {
|
|
11733
|
+
if (!a2) {
|
|
11734
|
+
return b2;
|
|
11607
11735
|
}
|
|
11608
|
-
const comp = compare(
|
|
11609
|
-
return comp < 0 ?
|
|
11736
|
+
const comp = compare(a2.semver, b2.semver, options);
|
|
11737
|
+
return comp < 0 ? a2 : comp > 0 ? b2 : b2.operator === "<" && a2.operator === "<=" ? b2 : a2;
|
|
11610
11738
|
};
|
|
11611
11739
|
module.exports = subset;
|
|
11612
11740
|
});
|
|
@@ -11806,9 +11934,9 @@ var require_verify = __commonJS((exports, module) => {
|
|
|
11806
11934
|
if (callback) {
|
|
11807
11935
|
done = callback;
|
|
11808
11936
|
} else {
|
|
11809
|
-
done = function(
|
|
11810
|
-
if (
|
|
11811
|
-
throw
|
|
11937
|
+
done = function(err3, data) {
|
|
11938
|
+
if (err3)
|
|
11939
|
+
throw err3;
|
|
11812
11940
|
return data;
|
|
11813
11941
|
};
|
|
11814
11942
|
}
|
|
@@ -11835,8 +11963,8 @@ var require_verify = __commonJS((exports, module) => {
|
|
|
11835
11963
|
let decodedToken;
|
|
11836
11964
|
try {
|
|
11837
11965
|
decodedToken = decode(jwtString, { complete: true });
|
|
11838
|
-
} catch (
|
|
11839
|
-
return done(
|
|
11966
|
+
} catch (err3) {
|
|
11967
|
+
return done(err3);
|
|
11840
11968
|
}
|
|
11841
11969
|
if (!decodedToken) {
|
|
11842
11970
|
return done(new JsonWebTokenError("invalid token"));
|
|
@@ -11853,9 +11981,9 @@ var require_verify = __commonJS((exports, module) => {
|
|
|
11853
11981
|
return secretCallback(null, secretOrPublicKey);
|
|
11854
11982
|
};
|
|
11855
11983
|
}
|
|
11856
|
-
return getSecret(header, function(
|
|
11857
|
-
if (
|
|
11858
|
-
return done(new JsonWebTokenError("error in secret or public key callback: " +
|
|
11984
|
+
return getSecret(header, function(err3, secretOrPublicKey2) {
|
|
11985
|
+
if (err3) {
|
|
11986
|
+
return done(new JsonWebTokenError("error in secret or public key callback: " + err3.message));
|
|
11859
11987
|
}
|
|
11860
11988
|
const hasSignature = parts[2].trim() !== "";
|
|
11861
11989
|
if (!hasSignature && secretOrPublicKey2) {
|
|
@@ -11870,10 +11998,10 @@ var require_verify = __commonJS((exports, module) => {
|
|
|
11870
11998
|
if (secretOrPublicKey2 != null && !(secretOrPublicKey2 instanceof KeyObject)) {
|
|
11871
11999
|
try {
|
|
11872
12000
|
secretOrPublicKey2 = createPublicKey(secretOrPublicKey2);
|
|
11873
|
-
} catch (
|
|
12001
|
+
} catch (_2) {
|
|
11874
12002
|
try {
|
|
11875
12003
|
secretOrPublicKey2 = createSecretKey(typeof secretOrPublicKey2 === "string" ? Buffer.from(secretOrPublicKey2) : secretOrPublicKey2);
|
|
11876
|
-
} catch (
|
|
12004
|
+
} catch (_3) {
|
|
11877
12005
|
return done(new JsonWebTokenError("secretOrPublicKey is not valid key material"));
|
|
11878
12006
|
}
|
|
11879
12007
|
}
|
|
@@ -11900,15 +12028,15 @@ var require_verify = __commonJS((exports, module) => {
|
|
|
11900
12028
|
if (!options.allowInvalidAsymmetricKeyTypes) {
|
|
11901
12029
|
try {
|
|
11902
12030
|
validateAsymmetricKey(header.alg, secretOrPublicKey2);
|
|
11903
|
-
} catch (
|
|
11904
|
-
return done(
|
|
12031
|
+
} catch (e2) {
|
|
12032
|
+
return done(e2);
|
|
11905
12033
|
}
|
|
11906
12034
|
}
|
|
11907
12035
|
let valid;
|
|
11908
12036
|
try {
|
|
11909
12037
|
valid = jws.verify(jwtString, decodedToken.header.alg, secretOrPublicKey2);
|
|
11910
|
-
} catch (
|
|
11911
|
-
return done(
|
|
12038
|
+
} catch (e2) {
|
|
12039
|
+
return done(e2);
|
|
11912
12040
|
}
|
|
11913
12041
|
if (!valid) {
|
|
11914
12042
|
return done(new JsonWebTokenError("invalid signature"));
|
|
@@ -12109,13 +12237,13 @@ var require_lodash = __commonJS((exports, module) => {
|
|
|
12109
12237
|
return isObjectLike(value) && isArrayLike(value);
|
|
12110
12238
|
}
|
|
12111
12239
|
function isFunction(value) {
|
|
12112
|
-
var tag =
|
|
12240
|
+
var tag = isObject2(value) ? objectToString.call(value) : "";
|
|
12113
12241
|
return tag == funcTag || tag == genTag;
|
|
12114
12242
|
}
|
|
12115
12243
|
function isLength(value) {
|
|
12116
12244
|
return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
|
|
12117
12245
|
}
|
|
12118
|
-
function
|
|
12246
|
+
function isObject2(value) {
|
|
12119
12247
|
var type = typeof value;
|
|
12120
12248
|
return !!value && (type == "object" || type == "function");
|
|
12121
12249
|
}
|
|
@@ -12150,9 +12278,9 @@ var require_lodash = __commonJS((exports, module) => {
|
|
|
12150
12278
|
if (isSymbol(value)) {
|
|
12151
12279
|
return NAN;
|
|
12152
12280
|
}
|
|
12153
|
-
if (
|
|
12281
|
+
if (isObject2(value)) {
|
|
12154
12282
|
var other = typeof value.valueOf == "function" ? value.valueOf() : value;
|
|
12155
|
-
value =
|
|
12283
|
+
value = isObject2(other) ? other + "" : other;
|
|
12156
12284
|
}
|
|
12157
12285
|
if (typeof value != "string") {
|
|
12158
12286
|
return value === 0 ? value : +value;
|
|
@@ -12200,7 +12328,7 @@ var require_lodash3 = __commonJS((exports, module) => {
|
|
|
12200
12328
|
function isInteger(value) {
|
|
12201
12329
|
return typeof value == "number" && value == toInteger(value);
|
|
12202
12330
|
}
|
|
12203
|
-
function
|
|
12331
|
+
function isObject2(value) {
|
|
12204
12332
|
var type = typeof value;
|
|
12205
12333
|
return !!value && (type == "object" || type == "function");
|
|
12206
12334
|
}
|
|
@@ -12232,9 +12360,9 @@ var require_lodash3 = __commonJS((exports, module) => {
|
|
|
12232
12360
|
if (isSymbol(value)) {
|
|
12233
12361
|
return NAN;
|
|
12234
12362
|
}
|
|
12235
|
-
if (
|
|
12363
|
+
if (isObject2(value)) {
|
|
12236
12364
|
var other = typeof value.valueOf == "function" ? value.valueOf() : value;
|
|
12237
|
-
value =
|
|
12365
|
+
value = isObject2(other) ? other + "" : other;
|
|
12238
12366
|
}
|
|
12239
12367
|
if (typeof value != "string") {
|
|
12240
12368
|
return value === 0 ? value : +value;
|
|
@@ -12268,7 +12396,7 @@ var require_lodash5 = __commonJS((exports, module) => {
|
|
|
12268
12396
|
if (value != null && typeof value.toString != "function") {
|
|
12269
12397
|
try {
|
|
12270
12398
|
result = !!(value + "");
|
|
12271
|
-
} catch (
|
|
12399
|
+
} catch (e2) {}
|
|
12272
12400
|
}
|
|
12273
12401
|
return result;
|
|
12274
12402
|
}
|
|
@@ -12349,7 +12477,7 @@ var require_lodash7 = __commonJS((exports, module) => {
|
|
|
12349
12477
|
function once(func) {
|
|
12350
12478
|
return before(2, func);
|
|
12351
12479
|
}
|
|
12352
|
-
function
|
|
12480
|
+
function isObject2(value) {
|
|
12353
12481
|
var type = typeof value;
|
|
12354
12482
|
return !!value && (type == "object" || type == "function");
|
|
12355
12483
|
}
|
|
@@ -12381,9 +12509,9 @@ var require_lodash7 = __commonJS((exports, module) => {
|
|
|
12381
12509
|
if (isSymbol(value)) {
|
|
12382
12510
|
return NAN;
|
|
12383
12511
|
}
|
|
12384
|
-
if (
|
|
12512
|
+
if (isObject2(value)) {
|
|
12385
12513
|
var other = typeof value.valueOf == "function" ? value.valueOf() : value;
|
|
12386
|
-
value =
|
|
12514
|
+
value = isObject2(other) ? other + "" : other;
|
|
12387
12515
|
}
|
|
12388
12516
|
if (typeof value != "string") {
|
|
12389
12517
|
return value === 0 ? value : +value;
|
|
@@ -12491,11 +12619,11 @@ var require_sign = __commonJS((exports, module) => {
|
|
|
12491
12619
|
typ: isObjectPayload ? "JWT" : undefined,
|
|
12492
12620
|
kid: options.keyid
|
|
12493
12621
|
}, options.header);
|
|
12494
|
-
function failure(
|
|
12622
|
+
function failure(err3) {
|
|
12495
12623
|
if (callback) {
|
|
12496
|
-
return callback(
|
|
12624
|
+
return callback(err3);
|
|
12497
12625
|
}
|
|
12498
|
-
throw
|
|
12626
|
+
throw err3;
|
|
12499
12627
|
}
|
|
12500
12628
|
if (!secretOrPrivateKey && options.algorithm !== "none") {
|
|
12501
12629
|
return failure(new Error("secretOrPrivateKey must have a value"));
|
|
@@ -12503,10 +12631,10 @@ var require_sign = __commonJS((exports, module) => {
|
|
|
12503
12631
|
if (secretOrPrivateKey != null && !(secretOrPrivateKey instanceof KeyObject)) {
|
|
12504
12632
|
try {
|
|
12505
12633
|
secretOrPrivateKey = createPrivateKey(secretOrPrivateKey);
|
|
12506
|
-
} catch (
|
|
12634
|
+
} catch (_2) {
|
|
12507
12635
|
try {
|
|
12508
12636
|
secretOrPrivateKey = createSecretKey(typeof secretOrPrivateKey === "string" ? Buffer.from(secretOrPrivateKey) : secretOrPrivateKey);
|
|
12509
|
-
} catch (
|
|
12637
|
+
} catch (_3) {
|
|
12510
12638
|
return failure(new Error("secretOrPrivateKey is not valid key material"));
|
|
12511
12639
|
}
|
|
12512
12640
|
}
|
|
@@ -12567,8 +12695,8 @@ var require_sign = __commonJS((exports, module) => {
|
|
|
12567
12695
|
if (typeof options.notBefore !== "undefined") {
|
|
12568
12696
|
try {
|
|
12569
12697
|
payload.nbf = timespan(options.notBefore, timestamp2);
|
|
12570
|
-
} catch (
|
|
12571
|
-
return failure(
|
|
12698
|
+
} catch (err3) {
|
|
12699
|
+
return failure(err3);
|
|
12572
12700
|
}
|
|
12573
12701
|
if (typeof payload.nbf === "undefined") {
|
|
12574
12702
|
return failure(new Error('"notBefore" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'));
|
|
@@ -12577,8 +12705,8 @@ var require_sign = __commonJS((exports, module) => {
|
|
|
12577
12705
|
if (typeof options.expiresIn !== "undefined" && typeof payload === "object") {
|
|
12578
12706
|
try {
|
|
12579
12707
|
payload.exp = timespan(options.expiresIn, timestamp2);
|
|
12580
|
-
} catch (
|
|
12581
|
-
return failure(
|
|
12708
|
+
} catch (err3) {
|
|
12709
|
+
return failure(err3);
|
|
12582
12710
|
}
|
|
12583
12711
|
if (typeof payload.exp === "undefined") {
|
|
12584
12712
|
return failure(new Error('"expiresIn" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'));
|
|
@@ -12630,8 +12758,8 @@ var require_jsonwebtoken = __commonJS((exports, module) => {
|
|
|
12630
12758
|
});
|
|
12631
12759
|
|
|
12632
12760
|
// ../adapters/db/sqlite/dist/index.js
|
|
12633
|
-
var
|
|
12634
|
-
__export(
|
|
12761
|
+
var exports_dist2 = {};
|
|
12762
|
+
__export(exports_dist2, {
|
|
12635
12763
|
createSQLiteAdapterFactory: () => createSQLiteAdapterFactory,
|
|
12636
12764
|
createBunSQLiteAdapterFactory: () => createBunSQLiteAdapterFactory,
|
|
12637
12765
|
SQLiteAdapter: () => SQLiteAdapter,
|
|
@@ -12701,7 +12829,7 @@ function getPath(target, path4 = []) {
|
|
|
12701
12829
|
path4.reverse();
|
|
12702
12830
|
try {
|
|
12703
12831
|
resolvePath(target.copy, path4);
|
|
12704
|
-
} catch (
|
|
12832
|
+
} catch (e2) {
|
|
12705
12833
|
return null;
|
|
12706
12834
|
}
|
|
12707
12835
|
return path4;
|
|
@@ -12731,11 +12859,11 @@ function peek(target, key) {
|
|
|
12731
12859
|
const source = state ? latest(state) : target;
|
|
12732
12860
|
return source[key];
|
|
12733
12861
|
}
|
|
12734
|
-
function isEqual(
|
|
12735
|
-
if (
|
|
12736
|
-
return
|
|
12862
|
+
function isEqual(x2, y4) {
|
|
12863
|
+
if (x2 === y4) {
|
|
12864
|
+
return x2 !== 0 || 1 / x2 === 1 / y4;
|
|
12737
12865
|
} else {
|
|
12738
|
-
return
|
|
12866
|
+
return x2 !== x2 && y4 !== y4;
|
|
12739
12867
|
}
|
|
12740
12868
|
}
|
|
12741
12869
|
function revokeProxy(proxyDraft) {
|
|
@@ -12844,9 +12972,9 @@ function deepClone(target) {
|
|
|
12844
12972
|
if (Array.isArray(target))
|
|
12845
12973
|
return target.map(deepClone);
|
|
12846
12974
|
if (target instanceof Map) {
|
|
12847
|
-
const iterable = Array.from(target.entries()).map(([
|
|
12848
|
-
|
|
12849
|
-
deepClone(
|
|
12975
|
+
const iterable = Array.from(target.entries()).map(([k4, v3]) => [
|
|
12976
|
+
k4,
|
|
12977
|
+
deepClone(v3)
|
|
12850
12978
|
]);
|
|
12851
12979
|
if (!isBaseMapInstance(target)) {
|
|
12852
12980
|
const SubClass = Object.getPrototypeOf(target).constructor;
|
|
@@ -13633,8 +13761,8 @@ class EventWire {
|
|
|
13633
13761
|
try {
|
|
13634
13762
|
const message = JSON.parse(event.data);
|
|
13635
13763
|
this.handleMessage(message);
|
|
13636
|
-
} catch (
|
|
13637
|
-
console.error("EventWire: Failed to parse message",
|
|
13764
|
+
} catch (err3) {
|
|
13765
|
+
console.error("EventWire: Failed to parse message", err3);
|
|
13638
13766
|
}
|
|
13639
13767
|
};
|
|
13640
13768
|
this.ws.onclose = (event) => {
|
|
@@ -13643,17 +13771,17 @@ class EventWire {
|
|
|
13643
13771
|
console.log("EventWire disconnected");
|
|
13644
13772
|
this.scheduleReconnect();
|
|
13645
13773
|
};
|
|
13646
|
-
this.ws.onerror = (
|
|
13647
|
-
console.error("EventWire error:",
|
|
13774
|
+
this.ws.onerror = (err3) => {
|
|
13775
|
+
console.error("EventWire error:", err3);
|
|
13648
13776
|
if (this.state === "connecting") {
|
|
13649
13777
|
this.state = "disconnected";
|
|
13650
13778
|
this.ws = null;
|
|
13651
13779
|
}
|
|
13652
13780
|
};
|
|
13653
|
-
} catch (
|
|
13781
|
+
} catch (err3) {
|
|
13654
13782
|
this.state = "disconnected";
|
|
13655
13783
|
this.ws = null;
|
|
13656
|
-
console.error("EventWire: Failed to connect",
|
|
13784
|
+
console.error("EventWire: Failed to connect", err3);
|
|
13657
13785
|
this.scheduleReconnect();
|
|
13658
13786
|
}
|
|
13659
13787
|
}
|
|
@@ -13684,11 +13812,11 @@ class EventWire {
|
|
|
13684
13812
|
if (this.ws) {
|
|
13685
13813
|
this.ws.send(JSON.stringify({
|
|
13686
13814
|
type: "sync-events",
|
|
13687
|
-
events: events.map((
|
|
13688
|
-
localId:
|
|
13689
|
-
type:
|
|
13690
|
-
payload:
|
|
13691
|
-
createdAt:
|
|
13815
|
+
events: events.map((e2) => ({
|
|
13816
|
+
localId: e2.localId,
|
|
13817
|
+
type: e2.type,
|
|
13818
|
+
payload: e2.payload,
|
|
13819
|
+
createdAt: e2.createdAt
|
|
13692
13820
|
}))
|
|
13693
13821
|
}));
|
|
13694
13822
|
}
|
|
@@ -13919,7 +14047,7 @@ class LocalEventPublisher2 {
|
|
|
13919
14047
|
}
|
|
13920
14048
|
}
|
|
13921
14049
|
if (promises.length > 0) {
|
|
13922
|
-
await Promise.all(promises.map((
|
|
14050
|
+
await Promise.all(promises.map((p3) => p3.catch((e2) => console.error(e2))));
|
|
13923
14051
|
}
|
|
13924
14052
|
}
|
|
13925
14053
|
async markSynced(eventIds) {
|
|
@@ -14264,6 +14392,81 @@ function typeValidatorBuilder(typeName, comparatorStrategy) {
|
|
|
14264
14392
|
}
|
|
14265
14393
|
};
|
|
14266
14394
|
}
|
|
14395
|
+
|
|
14396
|
+
class DataStorage {
|
|
14397
|
+
async commitChanges(changes) {
|
|
14398
|
+
await Promise.all(changes.map(({ store, changes: changes2 }) => this.getStore(store).applyChanges(changes2)));
|
|
14399
|
+
}
|
|
14400
|
+
}
|
|
14401
|
+
|
|
14402
|
+
class ScopedStore {
|
|
14403
|
+
#inner;
|
|
14404
|
+
#restrictions;
|
|
14405
|
+
#canWrite;
|
|
14406
|
+
#storeName;
|
|
14407
|
+
constructor(inner, restrictions, canWrite) {
|
|
14408
|
+
this.#inner = inner;
|
|
14409
|
+
this.#restrictions = restrictions;
|
|
14410
|
+
this.#canWrite = canWrite;
|
|
14411
|
+
this.#storeName = inner.storeName;
|
|
14412
|
+
}
|
|
14413
|
+
get storeName() {
|
|
14414
|
+
return this.#storeName;
|
|
14415
|
+
}
|
|
14416
|
+
async find(options, listener) {
|
|
14417
|
+
const restricted = this.#applyReadRestrictions(options);
|
|
14418
|
+
return this.#inner.find(restricted, listener);
|
|
14419
|
+
}
|
|
14420
|
+
async set(item) {
|
|
14421
|
+
this.#assertWriteAccess();
|
|
14422
|
+
this.#validateScopeFields(item);
|
|
14423
|
+
return this.#inner.set(item);
|
|
14424
|
+
}
|
|
14425
|
+
async remove(id) {
|
|
14426
|
+
this.#assertWriteAccess();
|
|
14427
|
+
return this.#inner.remove(id);
|
|
14428
|
+
}
|
|
14429
|
+
async modify(id, data) {
|
|
14430
|
+
this.#assertWriteAccess();
|
|
14431
|
+
this.#validateScopeFields(data);
|
|
14432
|
+
return this.#inner.modify(id, data);
|
|
14433
|
+
}
|
|
14434
|
+
async applyChanges(changes) {
|
|
14435
|
+
this.#assertWriteAccess();
|
|
14436
|
+
for (const change of changes) {
|
|
14437
|
+
if (change.type === "set") {
|
|
14438
|
+
this.#validateScopeFields(change.data);
|
|
14439
|
+
} else if (change.type === "modify") {
|
|
14440
|
+
this.#validateScopeFields(change.data);
|
|
14441
|
+
}
|
|
14442
|
+
}
|
|
14443
|
+
return this.#inner.applyChanges(changes);
|
|
14444
|
+
}
|
|
14445
|
+
unsubscribe(listener) {
|
|
14446
|
+
this.#inner.unsubscribe(listener);
|
|
14447
|
+
}
|
|
14448
|
+
#applyReadRestrictions(options) {
|
|
14449
|
+
if (Object.keys(this.#restrictions).length === 0) {
|
|
14450
|
+
return options ?? {};
|
|
14451
|
+
}
|
|
14452
|
+
return {
|
|
14453
|
+
...options,
|
|
14454
|
+
where: { ...options?.where ?? {}, ...this.#restrictions }
|
|
14455
|
+
};
|
|
14456
|
+
}
|
|
14457
|
+
#assertWriteAccess() {
|
|
14458
|
+
if (!this.#canWrite) {
|
|
14459
|
+
throw new Error(`Scope violation: write access denied to store "${this.#storeName}" (read-only)`);
|
|
14460
|
+
}
|
|
14461
|
+
}
|
|
14462
|
+
#validateScopeFields(data) {
|
|
14463
|
+
for (const [key, value] of Object.entries(this.#restrictions)) {
|
|
14464
|
+
if (key in data && data[key] !== value) {
|
|
14465
|
+
throw new Error(`Scope violation: field "${key}" must be "${value}", got "${data[key]}" in store "${this.#storeName}"`);
|
|
14466
|
+
}
|
|
14467
|
+
}
|
|
14468
|
+
}
|
|
14469
|
+
}
|
|
14267
14470
|
function string() {
|
|
14268
14471
|
return new ArcString;
|
|
14269
14472
|
}
|
|
@@ -14273,9 +14476,6 @@ class ArcFragmentBase {
|
|
|
14273
14476
|
return this.types.includes(type);
|
|
14274
14477
|
}
|
|
14275
14478
|
}
|
|
14276
|
-
function id(name, generateFn) {
|
|
14277
|
-
return new ArcId(name, generateFn);
|
|
14278
|
-
}
|
|
14279
14479
|
function buildElementContext(queryElements, mutationElements, adapters) {
|
|
14280
14480
|
const queryMap = new Map;
|
|
14281
14481
|
const mutateMap = new Map;
|
|
@@ -14324,6 +14524,9 @@ function buildElementContext(queryElements, mutationElements, adapters) {
|
|
|
14324
14524
|
mutate: mutateFn
|
|
14325
14525
|
};
|
|
14326
14526
|
}
|
|
14527
|
+
function id(name, generateFn) {
|
|
14528
|
+
return new ArcId(name, generateFn);
|
|
14529
|
+
}
|
|
14327
14530
|
|
|
14328
14531
|
class ArcFunction {
|
|
14329
14532
|
data;
|
|
@@ -14456,12 +14659,6 @@ class AggregateBase {
|
|
|
14456
14659
|
}
|
|
14457
14660
|
}
|
|
14458
14661
|
|
|
14459
|
-
class DataStorage {
|
|
14460
|
-
async commitChanges(changes) {
|
|
14461
|
-
await Promise.all(changes.map(({ store, changes: changes2 }) => this.getStore(store).applyChanges(changes2)));
|
|
14462
|
-
}
|
|
14463
|
-
}
|
|
14464
|
-
|
|
14465
14662
|
class StoreState {
|
|
14466
14663
|
storeName;
|
|
14467
14664
|
dataStorage;
|
|
@@ -14503,7 +14700,7 @@ class StoreState {
|
|
|
14503
14700
|
const object2 = result[0];
|
|
14504
14701
|
const [draft, finalize] = create(object2 || {}, { enablePatches: true });
|
|
14505
14702
|
await editCallback(draft);
|
|
14506
|
-
const [
|
|
14703
|
+
const [_3, patches] = finalize();
|
|
14507
14704
|
const change = {
|
|
14508
14705
|
type: "mutate",
|
|
14509
14706
|
id: id2,
|
|
@@ -14546,7 +14743,7 @@ function isPlainObject(item) {
|
|
|
14546
14743
|
return item && typeof item === "object" && !Array.isArray(item) && !(item instanceof Date) && Object.prototype.toString.call(item) === "[object Object]";
|
|
14547
14744
|
}
|
|
14548
14745
|
function resolveQueryChange(currentResult, event3, options) {
|
|
14549
|
-
const index = currentResult.findIndex((
|
|
14746
|
+
const index = currentResult.findIndex((e2) => e2._id === event3.id);
|
|
14550
14747
|
const isInCurrentResult = index !== -1;
|
|
14551
14748
|
if (event3.type === "delete") {
|
|
14552
14749
|
if (isInCurrentResult) {
|
|
@@ -14604,10 +14801,10 @@ function checkItemMatchesWhere(item, where) {
|
|
|
14604
14801
|
function applyOrderByAndLimit(result, options) {
|
|
14605
14802
|
let sorted = result;
|
|
14606
14803
|
if (options.orderBy) {
|
|
14607
|
-
sorted = [...result].sort((
|
|
14804
|
+
sorted = [...result].sort((a2, b3) => {
|
|
14608
14805
|
for (const [key, direction] of Object.entries(options.orderBy)) {
|
|
14609
|
-
const aVal =
|
|
14610
|
-
const bVal =
|
|
14806
|
+
const aVal = a2[key];
|
|
14807
|
+
const bVal = b3[key];
|
|
14611
14808
|
if (aVal < bVal)
|
|
14612
14809
|
return direction === "asc" ? -1 : 1;
|
|
14613
14810
|
if (aVal > bVal)
|
|
@@ -15189,7 +15386,7 @@ class StreamingEventPublisher {
|
|
|
15189
15386
|
}
|
|
15190
15387
|
}
|
|
15191
15388
|
if (promises.length > 0) {
|
|
15192
|
-
await Promise.all(promises.map((
|
|
15389
|
+
await Promise.all(promises.map((p3) => p3.catch((e2) => console.error(e2))));
|
|
15193
15390
|
}
|
|
15194
15391
|
}
|
|
15195
15392
|
}
|
|
@@ -16025,7 +16222,7 @@ var Operation, PROXY_DRAFT, RAW_RETURN_SYMBOL, iteratorSymbol, dataTypes, intern
|
|
|
16025
16222
|
}
|
|
16026
16223
|
return returnValue(result);
|
|
16027
16224
|
};
|
|
16028
|
-
}, create, constructorString, TOKEN_PREFIX = "arc:token:", eventWireInstanceCounter = 0, EVENT_TABLES, arrayValidator, ArcArray, objectValidator, ArcObject, ArcPrimitive, stringValidator, ArcString, ArcContextElement, ArcBoolean, ArcId, numberValidator, ArcNumber, ArcEvent, ArcCommand, ArcListener, ArcRoute, ForkedStoreState, ForkedDataStorage, MasterStoreState, MasterDataStorage2, dateValidator, SQLiteReadWriteTransaction, createSQLiteAdapterFactory = (db) => {
|
|
16225
|
+
}, create, constructorString, TOKEN_PREFIX = "arc:token:", eventWireInstanceCounter = 0, EVENT_TABLES, arrayValidator, ArcArray, objectValidator, ArcObject, ScopedDataStorage, ArcPrimitive, stringValidator, ArcString, ArcContextElement, ArcBoolean, ArcId, numberValidator, ArcNumber, ArcEvent, ArcCommand, ArcListener, ArcRoute, ForkedStoreState, ForkedDataStorage, MasterStoreState, MasterDataStorage2, dateValidator, SQLiteReadWriteTransaction, createSQLiteAdapterFactory = (db) => {
|
|
16029
16226
|
return async (context) => {
|
|
16030
16227
|
const adapter = new SQLiteAdapter(db, context);
|
|
16031
16228
|
await adapter.initialize();
|
|
@@ -16505,15 +16702,15 @@ var init_dist = __esm(() => {
|
|
|
16505
16702
|
});
|
|
16506
16703
|
}
|
|
16507
16704
|
parse(value) {
|
|
16508
|
-
return value.map((
|
|
16705
|
+
return value.map((v3) => this.parent.parse(v3));
|
|
16509
16706
|
}
|
|
16510
16707
|
serialize(value) {
|
|
16511
|
-
return value.map((
|
|
16708
|
+
return value.map((v3) => this.parent.serialize(v3));
|
|
16512
16709
|
}
|
|
16513
16710
|
deserialize(value) {
|
|
16514
16711
|
if (!Array.isArray(value))
|
|
16515
16712
|
return [];
|
|
16516
|
-
return value.map((
|
|
16713
|
+
return value.map((v3) => this.parent.deserialize(v3));
|
|
16517
16714
|
}
|
|
16518
16715
|
deserializePath(path4, value) {
|
|
16519
16716
|
if (path4.length === 0) {
|
|
@@ -16705,6 +16902,34 @@ var init_dist = __esm(() => {
|
|
|
16705
16902
|
return new ArcObject(partialShape);
|
|
16706
16903
|
}
|
|
16707
16904
|
};
|
|
16905
|
+
ScopedDataStorage = class ScopedDataStorage extends DataStorage {
|
|
16906
|
+
#inner;
|
|
16907
|
+
#allowedStores;
|
|
16908
|
+
#restrictions;
|
|
16909
|
+
constructor(inner, allowedStores, restrictions) {
|
|
16910
|
+
super();
|
|
16911
|
+
this.#inner = inner;
|
|
16912
|
+
this.#allowedStores = allowedStores;
|
|
16913
|
+
this.#restrictions = restrictions;
|
|
16914
|
+
}
|
|
16915
|
+
getStore(storeName) {
|
|
16916
|
+
const permission = this.#allowedStores.get(storeName);
|
|
16917
|
+
if (!permission) {
|
|
16918
|
+
throw new Error(`Scope violation: access denied to store "${storeName}" (not declared in query/mutate)`);
|
|
16919
|
+
}
|
|
16920
|
+
const inner = this.#inner.getStore(storeName);
|
|
16921
|
+
return new ScopedStore(inner, this.#restrictions, permission === "read-write");
|
|
16922
|
+
}
|
|
16923
|
+
fork() {
|
|
16924
|
+
return this.#inner.fork();
|
|
16925
|
+
}
|
|
16926
|
+
getReadTransaction() {
|
|
16927
|
+
return this.#inner.getReadTransaction();
|
|
16928
|
+
}
|
|
16929
|
+
getReadWriteTransaction() {
|
|
16930
|
+
return this.#inner.getReadWriteTransaction();
|
|
16931
|
+
}
|
|
16932
|
+
};
|
|
16708
16933
|
ArcPrimitive = class ArcPrimitive extends ArcAbstract {
|
|
16709
16934
|
serialize(value) {
|
|
16710
16935
|
return value;
|
|
@@ -17263,9 +17488,10 @@ var init_dist = __esm(() => {
|
|
|
17263
17488
|
async handleEvent(event2, adapters) {
|
|
17264
17489
|
if (!this.data.handler)
|
|
17265
17490
|
return;
|
|
17266
|
-
const
|
|
17267
|
-
|
|
17268
|
-
|
|
17491
|
+
const scopedAdapters = this.buildScopedAdapters(event2, adapters);
|
|
17492
|
+
const context2 = this.#fn.buildContext(scopedAdapters);
|
|
17493
|
+
if (scopedAdapters.authAdapter) {
|
|
17494
|
+
const decoded = scopedAdapters.authAdapter.getDecoded();
|
|
17269
17495
|
if (decoded) {
|
|
17270
17496
|
context2.$auth = {
|
|
17271
17497
|
params: decoded.params,
|
|
@@ -17281,6 +17507,37 @@ var init_dist = __esm(() => {
|
|
|
17281
17507
|
await this.data.handler(context2, event2);
|
|
17282
17508
|
}
|
|
17283
17509
|
}
|
|
17510
|
+
buildScopedAdapters(event2, adapters) {
|
|
17511
|
+
if (adapters.authAdapter?.isAuthenticated()) {
|
|
17512
|
+
return adapters;
|
|
17513
|
+
}
|
|
17514
|
+
const allElements = [
|
|
17515
|
+
...this.data.queryElements,
|
|
17516
|
+
...this.data.mutationElements
|
|
17517
|
+
];
|
|
17518
|
+
let tokenName = null;
|
|
17519
|
+
for (const element of allElements) {
|
|
17520
|
+
const protections = element.__aggregateProtections ?? element.data?.protections;
|
|
17521
|
+
if (protections?.length > 0) {
|
|
17522
|
+
tokenName = protections[0].token.name;
|
|
17523
|
+
break;
|
|
17524
|
+
}
|
|
17525
|
+
}
|
|
17526
|
+
if (!tokenName || !event2.payload) {
|
|
17527
|
+
return adapters;
|
|
17528
|
+
}
|
|
17529
|
+
const scopedAuth = new AuthAdapter;
|
|
17530
|
+
scopedAuth.scopes = new Map([
|
|
17531
|
+
["default", {
|
|
17532
|
+
raw: "",
|
|
17533
|
+
decoded: {
|
|
17534
|
+
tokenName,
|
|
17535
|
+
params: event2.payload
|
|
17536
|
+
}
|
|
17537
|
+
}]
|
|
17538
|
+
]);
|
|
17539
|
+
return { ...adapters, authAdapter: scopedAuth };
|
|
17540
|
+
}
|
|
17284
17541
|
destroy() {
|
|
17285
17542
|
for (const unsubscribe of this.unsubscribers) {
|
|
17286
17543
|
unsubscribe();
|
|
@@ -17767,7 +18024,7 @@ var init_dist = __esm(() => {
|
|
|
17767
18024
|
if (store === "events") {
|
|
17768
18025
|
const simpleInsertSql = `
|
|
17769
18026
|
INSERT INTO "${table.name}"
|
|
17770
|
-
(${columnNames.map((
|
|
18027
|
+
(${columnNames.map((c2) => `"${c2}"`).join(", ")})
|
|
17771
18028
|
VALUES (${placeholders})
|
|
17772
18029
|
`;
|
|
17773
18030
|
this.queries.push({
|
|
@@ -17777,7 +18034,7 @@ var init_dist = __esm(() => {
|
|
|
17777
18034
|
} else {
|
|
17778
18035
|
const sql = `
|
|
17779
18036
|
INSERT OR REPLACE INTO "${table.name}"
|
|
17780
|
-
(${columnNames.map((
|
|
18037
|
+
(${columnNames.map((c2) => `"${c2}"`).join(", ")})
|
|
17781
18038
|
VALUES (${placeholders})
|
|
17782
18039
|
`;
|
|
17783
18040
|
this.queries.push({
|
|
@@ -17807,7 +18064,7 @@ var init_dist = __esm(() => {
|
|
|
17807
18064
|
RETURNING last_version
|
|
17808
18065
|
)
|
|
17809
18066
|
INSERT OR REPLACE INTO "${table.name}"
|
|
17810
|
-
(${columnNames.map((
|
|
18067
|
+
(${columnNames.map((c2) => `"${c2}"`).join(", ")})
|
|
17811
18068
|
VALUES (${placeholders}, (SELECT last_version FROM next_version))
|
|
17812
18069
|
`;
|
|
17813
18070
|
this.queries.push({
|
|
@@ -26091,7 +26348,7 @@ ${colors3.yellow}Type declaration errors:${colors3.reset}`);
|
|
|
26091
26348
|
}
|
|
26092
26349
|
|
|
26093
26350
|
// src/platform/shared.ts
|
|
26094
|
-
import { copyFileSync, existsSync as existsSync6, mkdirSync as mkdirSync6, readFileSync as readFileSync6 } from "fs";
|
|
26351
|
+
import { copyFileSync, existsSync as existsSync6, mkdirSync as mkdirSync6, readFileSync as readFileSync6, readdirSync as readdirSync4, writeFileSync as writeFileSync6 } from "fs";
|
|
26095
26352
|
import { dirname as dirname6, join as join7 } from "path";
|
|
26096
26353
|
|
|
26097
26354
|
// src/builder/module-builder.ts
|
|
@@ -26426,6 +26683,22 @@ var SHELL_EXTERNALS = [
|
|
|
26426
26683
|
"@arcote.tech/arc-workspace",
|
|
26427
26684
|
"@arcote.tech/platform"
|
|
26428
26685
|
];
|
|
26686
|
+
function sha256Hex(bytes) {
|
|
26687
|
+
const hasher = new Bun.CryptoHasher("sha256");
|
|
26688
|
+
hasher.update(bytes);
|
|
26689
|
+
return hasher.digest("hex");
|
|
26690
|
+
}
|
|
26691
|
+
function sha256OfFiles(paths) {
|
|
26692
|
+
const hasher = new Bun.CryptoHasher("sha256");
|
|
26693
|
+
const sorted = [...paths].sort();
|
|
26694
|
+
for (const p of sorted) {
|
|
26695
|
+
if (!existsSync5(p))
|
|
26696
|
+
continue;
|
|
26697
|
+
hasher.update(readFileSync5(p));
|
|
26698
|
+
hasher.update("\x00");
|
|
26699
|
+
}
|
|
26700
|
+
return hasher.digest("hex");
|
|
26701
|
+
}
|
|
26429
26702
|
function discoverPackages(rootDir) {
|
|
26430
26703
|
const rootPkg = JSON.parse(readFileSync5(join6(rootDir, "package.json"), "utf-8"));
|
|
26431
26704
|
const workspaceGlobs = rootPkg.workspaces ?? [];
|
|
@@ -26546,10 +26819,17 @@ async function buildPackages(rootDir, outDir, packages) {
|
|
|
26546
26819
|
const moduleEntries = result.outputs.filter((o) => o.kind === "entry-point").map((o) => {
|
|
26547
26820
|
const file = o.path.split("/").pop();
|
|
26548
26821
|
const safeName = file.replace(/\.js$/, "");
|
|
26549
|
-
|
|
26822
|
+
const bytes = readFileSync5(o.path);
|
|
26823
|
+
return {
|
|
26824
|
+
file,
|
|
26825
|
+
name: fileToName.get(safeName) ?? safeName,
|
|
26826
|
+
hash: sha256Hex(bytes)
|
|
26827
|
+
};
|
|
26550
26828
|
});
|
|
26551
26829
|
const manifest = {
|
|
26552
26830
|
modules: moduleEntries,
|
|
26831
|
+
shellHash: "",
|
|
26832
|
+
stylesHash: "",
|
|
26553
26833
|
buildTime: new Date().toISOString()
|
|
26554
26834
|
};
|
|
26555
26835
|
writeFileSync5(join6(outDir, "manifest.json"), JSON.stringify(manifest, null, 2));
|
|
@@ -26702,7 +26982,35 @@ async function buildAll(ws) {
|
|
|
26702
26982
|
log2("Building shell...");
|
|
26703
26983
|
await buildShell(ws.shellDir, ws.packages);
|
|
26704
26984
|
ok("Shell built");
|
|
26705
|
-
|
|
26985
|
+
const finalManifest = finalizeManifest(ws, manifest);
|
|
26986
|
+
writeFileSync6(join7(ws.modulesDir, "manifest.json"), JSON.stringify(finalManifest, null, 2));
|
|
26987
|
+
return finalManifest;
|
|
26988
|
+
}
|
|
26989
|
+
function finalizeManifest(ws, manifest) {
|
|
26990
|
+
const shellFiles = listFilesRec(ws.shellDir);
|
|
26991
|
+
const stylesFiles = [
|
|
26992
|
+
join7(ws.arcDir, "styles.css"),
|
|
26993
|
+
join7(ws.arcDir, "theme.css")
|
|
26994
|
+
].filter((p) => existsSync6(p));
|
|
26995
|
+
return {
|
|
26996
|
+
modules: manifest.modules,
|
|
26997
|
+
shellHash: sha256OfFiles(shellFiles),
|
|
26998
|
+
stylesHash: sha256OfFiles(stylesFiles),
|
|
26999
|
+
buildTime: manifest.buildTime
|
|
27000
|
+
};
|
|
27001
|
+
}
|
|
27002
|
+
function listFilesRec(dir) {
|
|
27003
|
+
if (!existsSync6(dir))
|
|
27004
|
+
return [];
|
|
27005
|
+
const out = [];
|
|
27006
|
+
for (const entry of readdirSync4(dir, { withFileTypes: true })) {
|
|
27007
|
+
const p = join7(dir, entry.name);
|
|
27008
|
+
if (entry.isDirectory())
|
|
27009
|
+
out.push(...listFilesRec(p));
|
|
27010
|
+
else if (entry.isFile())
|
|
27011
|
+
out.push(p);
|
|
27012
|
+
}
|
|
27013
|
+
return out;
|
|
26706
27014
|
}
|
|
26707
27015
|
function collectArcPeerDeps(packages) {
|
|
26708
27016
|
const seen = new Set;
|
|
@@ -26860,9 +27168,1815 @@ async function platformBuild() {
|
|
|
26860
27168
|
ok(`Platform built \u2014 ${manifest.modules.length} module(s)`);
|
|
26861
27169
|
}
|
|
26862
27170
|
|
|
26863
|
-
// src/commands/platform-
|
|
26864
|
-
import { existsSync as
|
|
27171
|
+
// src/commands/platform-deploy.ts
|
|
27172
|
+
import { existsSync as existsSync10, readFileSync as readFileSync9 } from "fs";
|
|
27173
|
+
import { join as join13 } from "path";
|
|
27174
|
+
|
|
27175
|
+
// src/deploy/bootstrap.ts
|
|
27176
|
+
import { mkdirSync as mkdirSync9, writeFileSync as writeFileSync10 } from "fs";
|
|
27177
|
+
import { tmpdir as tmpdir3 } from "os";
|
|
27178
|
+
import { join as join11 } from "path";
|
|
27179
|
+
|
|
27180
|
+
// src/deploy/ansible.ts
|
|
27181
|
+
var {spawn: spawn2 } = globalThis.Bun;
|
|
27182
|
+
import { mkdirSync as mkdirSync7, writeFileSync as writeFileSync7 } from "fs";
|
|
27183
|
+
import { tmpdir } from "os";
|
|
27184
|
+
import { join as join8 } from "path";
|
|
27185
|
+
|
|
27186
|
+
// src/deploy/assets.ts
|
|
27187
|
+
var TERRAFORM_MAIN_TF = `terraform {
|
|
27188
|
+
required_providers {
|
|
27189
|
+
hcloud = {
|
|
27190
|
+
source = "hetznercloud/hcloud"
|
|
27191
|
+
version = "~> 1.51"
|
|
27192
|
+
}
|
|
27193
|
+
}
|
|
27194
|
+
}
|
|
27195
|
+
|
|
27196
|
+
provider "hcloud" {
|
|
27197
|
+
token = var.hcloud_token
|
|
27198
|
+
}
|
|
27199
|
+
|
|
27200
|
+
resource "hcloud_ssh_key" "deploy" {
|
|
27201
|
+
name = "\${var.server_name}-deploy"
|
|
27202
|
+
public_key = file(var.ssh_public_key)
|
|
27203
|
+
}
|
|
27204
|
+
|
|
27205
|
+
resource "hcloud_server" "arc" {
|
|
27206
|
+
name = var.server_name
|
|
27207
|
+
image = var.server_image
|
|
27208
|
+
server_type = var.server_type
|
|
27209
|
+
location = var.server_location
|
|
27210
|
+
ssh_keys = [hcloud_ssh_key.deploy.id]
|
|
27211
|
+
|
|
27212
|
+
public_net {
|
|
27213
|
+
ipv4_enabled = true
|
|
27214
|
+
ipv6_enabled = true
|
|
27215
|
+
}
|
|
27216
|
+
}
|
|
27217
|
+
|
|
27218
|
+
output "server_ip" {
|
|
27219
|
+
value = hcloud_server.arc.ipv4_address
|
|
27220
|
+
}
|
|
27221
|
+
|
|
27222
|
+
output "server_name" {
|
|
27223
|
+
value = hcloud_server.arc.name
|
|
27224
|
+
}
|
|
27225
|
+
`;
|
|
27226
|
+
var TERRAFORM_VARIABLES_TF = `variable "hcloud_token" {
|
|
27227
|
+
description = "Hetzner Cloud API token"
|
|
27228
|
+
type = string
|
|
27229
|
+
sensitive = true
|
|
27230
|
+
}
|
|
27231
|
+
|
|
27232
|
+
variable "server_name" {
|
|
27233
|
+
description = "Name of the Hetzner server (shown in the console)"
|
|
27234
|
+
type = string
|
|
27235
|
+
default = "arc-platform"
|
|
27236
|
+
}
|
|
27237
|
+
|
|
27238
|
+
variable "server_type" {
|
|
27239
|
+
description = "Hetzner server type (cx22, cx32, cx42, ...)"
|
|
27240
|
+
type = string
|
|
27241
|
+
default = "cx32"
|
|
27242
|
+
}
|
|
27243
|
+
|
|
27244
|
+
variable "server_location" {
|
|
27245
|
+
description = "Hetzner datacenter location (nbg1, fsn1, hel1, ...)"
|
|
27246
|
+
type = string
|
|
27247
|
+
default = "nbg1"
|
|
27248
|
+
}
|
|
27249
|
+
|
|
27250
|
+
variable "server_image" {
|
|
27251
|
+
description = "OS image"
|
|
27252
|
+
type = string
|
|
27253
|
+
default = "ubuntu-22.04"
|
|
27254
|
+
}
|
|
27255
|
+
|
|
27256
|
+
variable "ssh_public_key" {
|
|
27257
|
+
description = "Path to the public key uploaded to the server"
|
|
27258
|
+
type = string
|
|
27259
|
+
default = "~/.ssh/id_ed25519.pub"
|
|
27260
|
+
}
|
|
27261
|
+
`;
|
|
27262
|
+
var ANSIBLE_SITE_YML = `---
|
|
27263
|
+
# Arc platform bootstrap playbook \u2014 minimal hardened Docker host.
|
|
27264
|
+
- name: Bootstrap Arc host
|
|
27265
|
+
hosts: all
|
|
27266
|
+
become: true
|
|
27267
|
+
gather_facts: true
|
|
27268
|
+
vars:
|
|
27269
|
+
deploy_user: "{{ username | default('deploy') }}"
|
|
27270
|
+
ssh_port: "{{ ssh_port | default(22) }}"
|
|
27271
|
+
extra_allowed_ips: "{{ extra_allowed_ips | default([]) }}"
|
|
27272
|
+
|
|
27273
|
+
tasks:
|
|
27274
|
+
- name: Update apt cache
|
|
27275
|
+
apt:
|
|
27276
|
+
update_cache: true
|
|
27277
|
+
cache_valid_time: 3600
|
|
27278
|
+
|
|
27279
|
+
- name: Install base packages
|
|
27280
|
+
apt:
|
|
27281
|
+
name:
|
|
27282
|
+
- ca-certificates
|
|
27283
|
+
- curl
|
|
27284
|
+
- gnupg
|
|
27285
|
+
- ufw
|
|
27286
|
+
- fail2ban
|
|
27287
|
+
- unattended-upgrades
|
|
27288
|
+
- python3-docker
|
|
27289
|
+
state: present
|
|
27290
|
+
|
|
27291
|
+
- name: Create deploy user
|
|
27292
|
+
user:
|
|
27293
|
+
name: "{{ deploy_user }}"
|
|
27294
|
+
shell: /bin/bash
|
|
27295
|
+
groups: sudo
|
|
27296
|
+
append: true
|
|
27297
|
+
create_home: true
|
|
27298
|
+
state: present
|
|
27299
|
+
|
|
27300
|
+
- name: Copy SSH key from root to deploy user
|
|
27301
|
+
shell: |
|
|
27302
|
+
mkdir -p /home/{{ deploy_user }}/.ssh
|
|
27303
|
+
cp /root/.ssh/authorized_keys /home/{{ deploy_user }}/.ssh/authorized_keys
|
|
27304
|
+
chown -R {{ deploy_user }}:{{ deploy_user }} /home/{{ deploy_user }}/.ssh
|
|
27305
|
+
chmod 700 /home/{{ deploy_user }}/.ssh
|
|
27306
|
+
chmod 600 /home/{{ deploy_user }}/.ssh/authorized_keys
|
|
27307
|
+
args:
|
|
27308
|
+
creates: "/home/{{ deploy_user }}/.ssh/authorized_keys"
|
|
27309
|
+
|
|
27310
|
+
- name: Passwordless sudo for deploy user
|
|
27311
|
+
copy:
|
|
27312
|
+
dest: /etc/sudoers.d/99-{{ deploy_user }}
|
|
27313
|
+
content: "{{ deploy_user }} ALL=(ALL) NOPASSWD:ALL\\n"
|
|
27314
|
+
mode: "0440"
|
|
27315
|
+
validate: "visudo -cf %s"
|
|
27316
|
+
|
|
27317
|
+
- name: Harden sshd
|
|
27318
|
+
lineinfile:
|
|
27319
|
+
path: /etc/ssh/sshd_config
|
|
27320
|
+
regexp: "{{ item.re }}"
|
|
27321
|
+
line: "{{ item.line }}"
|
|
27322
|
+
state: present
|
|
27323
|
+
loop:
|
|
27324
|
+
- { re: "^#?PermitRootLogin", line: "PermitRootLogin no" }
|
|
27325
|
+
- { re: "^#?PasswordAuthentication", line: "PasswordAuthentication no" }
|
|
27326
|
+
- { re: "^#?PubkeyAuthentication", line: "PubkeyAuthentication yes" }
|
|
27327
|
+
- { re: "^#?MaxAuthTries", line: "MaxAuthTries 3" }
|
|
27328
|
+
notify: restart ssh
|
|
27329
|
+
|
|
27330
|
+
- name: Install Docker via official convenience script
|
|
27331
|
+
shell: |
|
|
27332
|
+
curl -fsSL https://get.docker.com | sh
|
|
27333
|
+
args:
|
|
27334
|
+
creates: /usr/bin/docker
|
|
27335
|
+
|
|
27336
|
+
- name: Enable and start docker
|
|
27337
|
+
systemd:
|
|
27338
|
+
name: docker
|
|
27339
|
+
enabled: true
|
|
27340
|
+
state: started
|
|
27341
|
+
|
|
27342
|
+
- name: Add deploy user to docker group
|
|
27343
|
+
user:
|
|
27344
|
+
name: "{{ deploy_user }}"
|
|
27345
|
+
groups: docker
|
|
27346
|
+
append: true
|
|
27347
|
+
|
|
27348
|
+
- name: Configure docker log rotation
|
|
27349
|
+
copy:
|
|
27350
|
+
dest: /etc/docker/daemon.json
|
|
27351
|
+
content: |
|
|
27352
|
+
{
|
|
27353
|
+
"log-driver": "json-file",
|
|
27354
|
+
"log-opts": {
|
|
27355
|
+
"max-size": "10m",
|
|
27356
|
+
"max-file": "3"
|
|
27357
|
+
}
|
|
27358
|
+
}
|
|
27359
|
+
mode: "0644"
|
|
27360
|
+
notify: restart docker
|
|
27361
|
+
|
|
27362
|
+
- name: Ensure /opt/arc exists
|
|
27363
|
+
file:
|
|
27364
|
+
path: /opt/arc
|
|
27365
|
+
state: directory
|
|
27366
|
+
owner: "{{ deploy_user }}"
|
|
27367
|
+
group: "{{ deploy_user }}"
|
|
27368
|
+
mode: "0755"
|
|
27369
|
+
|
|
27370
|
+
- name: Configure ufw defaults
|
|
27371
|
+
ufw:
|
|
27372
|
+
policy: "{{ item.policy }}"
|
|
27373
|
+
direction: "{{ item.dir }}"
|
|
27374
|
+
loop:
|
|
27375
|
+
- { policy: deny, dir: incoming }
|
|
27376
|
+
- { policy: allow, dir: outgoing }
|
|
27377
|
+
|
|
27378
|
+
- name: Open firewall ports
|
|
27379
|
+
ufw:
|
|
27380
|
+
rule: allow
|
|
27381
|
+
port: "{{ item }}"
|
|
27382
|
+
proto: tcp
|
|
27383
|
+
loop:
|
|
27384
|
+
- "{{ ssh_port }}"
|
|
27385
|
+
- "80"
|
|
27386
|
+
- "443"
|
|
27387
|
+
|
|
27388
|
+
- name: Enable ufw
|
|
27389
|
+
ufw:
|
|
27390
|
+
state: enabled
|
|
27391
|
+
|
|
27392
|
+
- name: Configure fail2ban for sshd
|
|
27393
|
+
copy:
|
|
27394
|
+
dest: /etc/fail2ban/jail.local
|
|
27395
|
+
content: |
|
|
27396
|
+
[sshd]
|
|
27397
|
+
enabled = true
|
|
27398
|
+
port = {{ ssh_port }}
|
|
27399
|
+
maxretry = 5
|
|
27400
|
+
findtime = 600
|
|
27401
|
+
bantime = 3600
|
|
27402
|
+
ignoreip = 127.0.0.1/8 ::1 {{ extra_allowed_ips | join(' ') }}
|
|
27403
|
+
mode: "0644"
|
|
27404
|
+
notify: restart fail2ban
|
|
27405
|
+
|
|
27406
|
+
- name: Enable unattended upgrades
|
|
27407
|
+
copy:
|
|
27408
|
+
dest: /etc/apt/apt.conf.d/20auto-upgrades
|
|
27409
|
+
content: |
|
|
27410
|
+
APT::Periodic::Update-Package-Lists "1";
|
|
27411
|
+
APT::Periodic::Unattended-Upgrade "1";
|
|
27412
|
+
APT::Periodic::AutocleanInterval "7";
|
|
27413
|
+
mode: "0644"
|
|
27414
|
+
|
|
27415
|
+
handlers:
|
|
27416
|
+
- name: restart ssh
|
|
27417
|
+
systemd:
|
|
27418
|
+
name: ssh
|
|
27419
|
+
state: restarted
|
|
27420
|
+
|
|
27421
|
+
- name: restart docker
|
|
27422
|
+
systemd:
|
|
27423
|
+
name: docker
|
|
27424
|
+
state: restarted
|
|
27425
|
+
|
|
27426
|
+
- name: restart fail2ban
|
|
27427
|
+
systemd:
|
|
27428
|
+
name: fail2ban
|
|
27429
|
+
state: restarted
|
|
27430
|
+
`;
|
|
27431
|
+
var ASSETS = {
|
|
27432
|
+
terraform: {
|
|
27433
|
+
"main.tf": TERRAFORM_MAIN_TF,
|
|
27434
|
+
"variables.tf": TERRAFORM_VARIABLES_TF
|
|
27435
|
+
},
|
|
27436
|
+
ansible: {
|
|
27437
|
+
"site.yml": ANSIBLE_SITE_YML
|
|
27438
|
+
}
|
|
27439
|
+
};
|
|
27440
|
+
async function materializeAssets(targetDir, files) {
|
|
27441
|
+
const { mkdirSync: mkdirSync7, writeFileSync: writeFileSync7 } = await import("fs");
|
|
27442
|
+
const { join: join8 } = await import("path");
|
|
27443
|
+
mkdirSync7(targetDir, { recursive: true });
|
|
27444
|
+
for (const [name, content] of Object.entries(files)) {
|
|
27445
|
+
writeFileSync7(join8(targetDir, name), content);
|
|
27446
|
+
}
|
|
27447
|
+
}
|
|
27448
|
+
|
|
27449
|
+
// src/deploy/ansible.ts
|
|
27450
|
+
async function runAnsible(inputs) {
|
|
27451
|
+
const workDir = join8(tmpdir(), "arc-deploy", `ansible-${Date.now()}`);
|
|
27452
|
+
mkdirSync7(workDir, { recursive: true });
|
|
27453
|
+
await materializeAssets(workDir, ASSETS.ansible);
|
|
27454
|
+
const user = inputs.asRoot ? "root" : inputs.target.user;
|
|
27455
|
+
const port = inputs.ansible?.sshPort ?? inputs.target.port;
|
|
27456
|
+
const inventory = [
|
|
27457
|
+
"[arc]",
|
|
27458
|
+
`${inputs.target.host} ansible_user=${user} ansible_port=${port}`,
|
|
27459
|
+
"",
|
|
27460
|
+
"[arc:vars]",
|
|
27461
|
+
"ansible_ssh_common_args='-o StrictHostKeyChecking=accept-new -o BatchMode=yes'",
|
|
27462
|
+
"ansible_python_interpreter=/usr/bin/python3",
|
|
27463
|
+
""
|
|
27464
|
+
].join(`
|
|
27465
|
+
`);
|
|
27466
|
+
writeFileSync7(join8(workDir, "inventory.ini"), inventory);
|
|
27467
|
+
const extraVars = [
|
|
27468
|
+
`username=${inputs.target.user}`,
|
|
27469
|
+
`ssh_port=${port}`
|
|
27470
|
+
];
|
|
27471
|
+
if (inputs.ansible?.extraAllowedIps?.length) {
|
|
27472
|
+
extraVars.push(`extra_allowed_ips=${JSON.stringify(inputs.ansible.extraAllowedIps)}`);
|
|
27473
|
+
}
|
|
27474
|
+
const proc2 = spawn2({
|
|
27475
|
+
cmd: [
|
|
27476
|
+
"ansible-playbook",
|
|
27477
|
+
"-i",
|
|
27478
|
+
"inventory.ini",
|
|
27479
|
+
"site.yml",
|
|
27480
|
+
"-e",
|
|
27481
|
+
extraVars.join(" ")
|
|
27482
|
+
],
|
|
27483
|
+
cwd: workDir,
|
|
27484
|
+
stdout: "inherit",
|
|
27485
|
+
stderr: "inherit",
|
|
27486
|
+
env: { ...process.env, ANSIBLE_HOST_KEY_CHECKING: "False" }
|
|
27487
|
+
});
|
|
27488
|
+
const exit = await proc2.exited;
|
|
27489
|
+
if (exit !== 0) {
|
|
27490
|
+
throw new Error(`ansible-playbook failed (exit ${exit})`);
|
|
27491
|
+
}
|
|
27492
|
+
}
|
|
27493
|
+
|
|
27494
|
+
// src/deploy/caddyfile.ts
|
|
27495
|
+
function generateCaddyfile(cfg) {
|
|
27496
|
+
const email = cfg.caddy.email === "internal" ? "" : `
|
|
27497
|
+
email ${cfg.caddy.email}`;
|
|
27498
|
+
const tlsDirective = cfg.caddy.email === "internal" ? `
|
|
27499
|
+
tls internal` : "";
|
|
27500
|
+
const lines = [];
|
|
27501
|
+
lines.push("# Generated by `arc platform deploy` \u2014 do not edit by hand.");
|
|
27502
|
+
lines.push("");
|
|
27503
|
+
lines.push("{");
|
|
27504
|
+
lines.push(" admin off");
|
|
27505
|
+
if (email)
|
|
27506
|
+
lines.push(` ${email.trim()}`);
|
|
27507
|
+
lines.push("}");
|
|
27508
|
+
lines.push("");
|
|
27509
|
+
for (const [name, env2] of Object.entries(cfg.envs)) {
|
|
27510
|
+
lines.push(`${env2.domain} {${tlsDirective}`);
|
|
27511
|
+
lines.push(" @deploy path /api/deploy /api/deploy/*");
|
|
27512
|
+
lines.push(" respond @deploy 404");
|
|
27513
|
+
lines.push("");
|
|
27514
|
+
lines.push(` reverse_proxy arc-${name}:5005`);
|
|
27515
|
+
lines.push("}");
|
|
27516
|
+
lines.push("");
|
|
27517
|
+
}
|
|
27518
|
+
lines.push("# Loopback-only management listener (SSH tunnel access).");
|
|
27519
|
+
lines.push("http://127.0.0.1:2019 {");
|
|
27520
|
+
lines.push(" bind 127.0.0.1");
|
|
27521
|
+
for (const [name] of Object.entries(cfg.envs)) {
|
|
27522
|
+
lines.push(` handle_path /env/${name}/* {`);
|
|
27523
|
+
lines.push(` reverse_proxy arc-${name}:5005`);
|
|
27524
|
+
lines.push(` }`);
|
|
27525
|
+
}
|
|
27526
|
+
lines.push(" respond 404");
|
|
27527
|
+
lines.push("}");
|
|
27528
|
+
return lines.join(`
|
|
27529
|
+
`) + `
|
|
27530
|
+
`;
|
|
27531
|
+
}
|
|
27532
|
+
|
|
27533
|
+
// src/deploy/compose.ts
|
|
27534
|
+
function generateCompose({ cfg }) {
|
|
27535
|
+
const lines = [];
|
|
27536
|
+
lines.push("# Generated by `arc platform deploy` \u2014 do not edit by hand.");
|
|
27537
|
+
lines.push("");
|
|
27538
|
+
lines.push("services:");
|
|
27539
|
+
lines.push(" caddy:");
|
|
27540
|
+
lines.push(" image: caddy:2-alpine");
|
|
27541
|
+
lines.push(" restart: unless-stopped");
|
|
27542
|
+
lines.push(" ports:");
|
|
27543
|
+
lines.push(' - "80:80"');
|
|
27544
|
+
lines.push(' - "443:443"');
|
|
27545
|
+
lines.push(' - "127.0.0.1:2019:2019"');
|
|
27546
|
+
lines.push(" volumes:");
|
|
27547
|
+
lines.push(" - ./Caddyfile:/etc/caddy/Caddyfile:ro");
|
|
27548
|
+
lines.push(" - caddy_data:/data");
|
|
27549
|
+
lines.push(" - caddy_config:/config");
|
|
27550
|
+
lines.push(" networks:");
|
|
27551
|
+
lines.push(" - arc-net");
|
|
27552
|
+
lines.push("");
|
|
27553
|
+
for (const [name, env2] of Object.entries(cfg.envs)) {
|
|
27554
|
+
lines.push(` arc-${name}:`);
|
|
27555
|
+
lines.push(" image: oven/bun:1-alpine");
|
|
27556
|
+
lines.push(" restart: unless-stopped");
|
|
27557
|
+
lines.push(` working_dir: /app`);
|
|
27558
|
+
lines.push(" volumes:");
|
|
27559
|
+
lines.push(` - ${cfg.target.remoteDir}/${name}:/app`);
|
|
27560
|
+
lines.push(` - arc-data-${name}:/app/.arc/data`);
|
|
27561
|
+
lines.push(" environment:");
|
|
27562
|
+
lines.push(" PORT: 5005");
|
|
27563
|
+
lines.push(' ARC_DEPLOY_API: "1"');
|
|
27564
|
+
lines.push(" NODE_ENV: production");
|
|
27565
|
+
for (const [k, v] of Object.entries(env2.envVars ?? {})) {
|
|
27566
|
+
lines.push(` ${k}: ${JSON.stringify(v)}`);
|
|
27567
|
+
}
|
|
27568
|
+
lines.push(' command: ["node_modules/.bin/arc", "platform", "start"]');
|
|
27569
|
+
lines.push(" networks:");
|
|
27570
|
+
lines.push(" - arc-net");
|
|
27571
|
+
lines.push(" expose:");
|
|
27572
|
+
lines.push(' - "5005"');
|
|
27573
|
+
lines.push("");
|
|
27574
|
+
}
|
|
27575
|
+
lines.push("networks:");
|
|
27576
|
+
lines.push(" arc-net:");
|
|
27577
|
+
lines.push("");
|
|
27578
|
+
lines.push("volumes:");
|
|
27579
|
+
lines.push(" caddy_data:");
|
|
27580
|
+
lines.push(" caddy_config:");
|
|
27581
|
+
for (const [name] of Object.entries(cfg.envs)) {
|
|
27582
|
+
lines.push(` arc-data-${name}:`);
|
|
27583
|
+
}
|
|
27584
|
+
return lines.join(`
|
|
27585
|
+
`) + `
|
|
27586
|
+
`;
|
|
27587
|
+
}
|
|
27588
|
+
|
|
27589
|
+
// src/deploy/terraform.ts
|
|
27590
|
+
var {spawn: spawn3 } = globalThis.Bun;
|
|
27591
|
+
import { existsSync as existsSync7, mkdirSync as mkdirSync8, writeFileSync as writeFileSync8 } from "fs";
|
|
27592
|
+
import { tmpdir as tmpdir2 } from "os";
|
|
26865
27593
|
import { join as join9 } from "path";
|
|
27594
|
+
async function runTerraform(inputs) {
|
|
27595
|
+
const workDir = join9(tmpdir2(), "arc-deploy", `tf-${Date.now()}`);
|
|
27596
|
+
mkdirSync8(workDir, { recursive: true });
|
|
27597
|
+
await materializeAssets(workDir, ASSETS.terraform);
|
|
27598
|
+
const sshPubKey = inputs.tf.sshPublicKey ?? expandHome("~/.ssh/id_ed25519.pub");
|
|
27599
|
+
if (!existsSync7(expandHome(sshPubKey))) {
|
|
27600
|
+
throw new Error(`SSH public key not found at ${sshPubKey}. Set provision.terraform.sshPublicKey in deploy.arc.json.`);
|
|
27601
|
+
}
|
|
27602
|
+
const tfvars = [
|
|
27603
|
+
`hcloud_token = "${inputs.token}"`,
|
|
27604
|
+
`server_name = "${inputs.serverName}"`,
|
|
27605
|
+
`server_type = "${inputs.tf.serverType}"`,
|
|
27606
|
+
`server_location = "${inputs.tf.location}"`,
|
|
27607
|
+
`server_image = "${inputs.tf.image}"`,
|
|
27608
|
+
`ssh_public_key = "${expandHome(sshPubKey)}"`
|
|
27609
|
+
].join(`
|
|
27610
|
+
`) + `
|
|
27611
|
+
`;
|
|
27612
|
+
writeFileSync8(join9(workDir, "terraform.tfvars"), tfvars);
|
|
27613
|
+
await runTf(workDir, ["init", "-input=false", "-no-color"]);
|
|
27614
|
+
await runTf(workDir, [
|
|
27615
|
+
"apply",
|
|
27616
|
+
"-auto-approve",
|
|
27617
|
+
"-input=false",
|
|
27618
|
+
"-no-color"
|
|
27619
|
+
]);
|
|
27620
|
+
const ip = await runTfCapture(workDir, [
|
|
27621
|
+
"output",
|
|
27622
|
+
"-raw",
|
|
27623
|
+
"server_ip",
|
|
27624
|
+
"-no-color"
|
|
27625
|
+
]);
|
|
27626
|
+
return { serverIp: ip.trim(), serverName: inputs.serverName, workDir };
|
|
27627
|
+
}
|
|
27628
|
+
async function runTf(workDir, args) {
|
|
27629
|
+
const proc2 = spawn3({
|
|
27630
|
+
cmd: ["terraform", ...args],
|
|
27631
|
+
cwd: workDir,
|
|
27632
|
+
stdout: "inherit",
|
|
27633
|
+
stderr: "inherit"
|
|
27634
|
+
});
|
|
27635
|
+
const exit = await proc2.exited;
|
|
27636
|
+
if (exit !== 0) {
|
|
27637
|
+
throw new Error(`terraform ${args[0]} failed (exit ${exit})`);
|
|
27638
|
+
}
|
|
27639
|
+
}
|
|
27640
|
+
async function runTfCapture(workDir, args) {
|
|
27641
|
+
const proc2 = spawn3({
|
|
27642
|
+
cmd: ["terraform", ...args],
|
|
27643
|
+
cwd: workDir,
|
|
27644
|
+
stdout: "pipe",
|
|
27645
|
+
stderr: "pipe"
|
|
27646
|
+
});
|
|
27647
|
+
const [stdout, exit] = await Promise.all([
|
|
27648
|
+
new Response(proc2.stdout).text(),
|
|
27649
|
+
proc2.exited
|
|
27650
|
+
]);
|
|
27651
|
+
if (exit !== 0) {
|
|
27652
|
+
throw new Error(`terraform ${args[0]} failed (exit ${exit})`);
|
|
27653
|
+
}
|
|
27654
|
+
return stdout;
|
|
27655
|
+
}
|
|
27656
|
+
function expandHome(p) {
|
|
27657
|
+
if (p.startsWith("~/")) {
|
|
27658
|
+
return p.replace(/^~/, process.env.HOME ?? "~");
|
|
27659
|
+
}
|
|
27660
|
+
return p;
|
|
27661
|
+
}
|
|
27662
|
+
|
|
27663
|
+
// src/deploy/config.ts
|
|
27664
|
+
import { existsSync as existsSync8, readFileSync as readFileSync7, writeFileSync as writeFileSync9 } from "fs";
|
|
27665
|
+
import { join as join10 } from "path";
|
|
27666
|
+
var DEPLOY_CONFIG_FILE = "deploy.arc.json";
|
|
27667
|
+
function deployConfigPath(rootDir) {
|
|
27668
|
+
return join10(rootDir, DEPLOY_CONFIG_FILE);
|
|
27669
|
+
}
|
|
27670
|
+
function deployConfigExists(rootDir) {
|
|
27671
|
+
return existsSync8(deployConfigPath(rootDir));
|
|
27672
|
+
}
|
|
27673
|
+
function loadDeployConfig(rootDir) {
|
|
27674
|
+
const path4 = deployConfigPath(rootDir);
|
|
27675
|
+
if (!existsSync8(path4)) {
|
|
27676
|
+
throw new Error(`Missing ${DEPLOY_CONFIG_FILE} at ${path4}`);
|
|
27677
|
+
}
|
|
27678
|
+
const raw = readFileSync7(path4, "utf-8");
|
|
27679
|
+
let parsed;
|
|
27680
|
+
try {
|
|
27681
|
+
parsed = JSON.parse(raw);
|
|
27682
|
+
} catch (e) {
|
|
27683
|
+
throw new Error(`Invalid JSON in ${DEPLOY_CONFIG_FILE}: ${e.message}`);
|
|
27684
|
+
}
|
|
27685
|
+
const expanded = expandEnvVars(parsed, process.env);
|
|
27686
|
+
return validateDeployConfig(expanded);
|
|
27687
|
+
}
|
|
27688
|
+
function saveDeployConfig(rootDir, cfg) {
|
|
27689
|
+
writeFileSync9(deployConfigPath(rootDir), JSON.stringify(cfg, null, 2) + `
|
|
27690
|
+
`);
|
|
27691
|
+
}
|
|
27692
|
+
var VAR_REGEX = /\$\{([A-Z0-9_]+)\}|\$([A-Z0-9_]+)/g;
|
|
27693
|
+
function expandEnvVars(value, env2) {
|
|
27694
|
+
if (typeof value === "string") {
|
|
27695
|
+
return value.replace(VAR_REGEX, (_, a, b) => env2[a ?? b] ?? "");
|
|
27696
|
+
}
|
|
27697
|
+
if (Array.isArray(value)) {
|
|
27698
|
+
return value.map((v) => expandEnvVars(v, env2));
|
|
27699
|
+
}
|
|
27700
|
+
if (value && typeof value === "object") {
|
|
27701
|
+
const out = {};
|
|
27702
|
+
for (const [k, v] of Object.entries(value)) {
|
|
27703
|
+
out[k] = expandEnvVars(v, env2);
|
|
27704
|
+
}
|
|
27705
|
+
return out;
|
|
27706
|
+
}
|
|
27707
|
+
return value;
|
|
27708
|
+
}
|
|
27709
|
+
function validateDeployConfig(input) {
|
|
27710
|
+
if (!isObject(input))
|
|
27711
|
+
throw cfgErr("root", "object");
|
|
27712
|
+
const target = requireObject(input, "target");
|
|
27713
|
+
const envs = requireObject(input, "envs");
|
|
27714
|
+
const caddy = requireObject(input, "caddy");
|
|
27715
|
+
const validated = {
|
|
27716
|
+
target: {
|
|
27717
|
+
host: requireString(target, "target.host"),
|
|
27718
|
+
user: optionalString(target, "target.user") ?? "deploy",
|
|
27719
|
+
port: optionalNumber(target, "target.port") ?? 22,
|
|
27720
|
+
remoteDir: optionalString(target, "target.remoteDir") ?? "/opt/arc",
|
|
27721
|
+
sshKey: optionalString(target, "target.sshKey")
|
|
27722
|
+
},
|
|
27723
|
+
envs: {},
|
|
27724
|
+
caddy: {
|
|
27725
|
+
email: requireString(caddy, "caddy.email")
|
|
27726
|
+
}
|
|
27727
|
+
};
|
|
27728
|
+
const envKeys = Object.keys(envs);
|
|
27729
|
+
if (envKeys.length === 0) {
|
|
27730
|
+
throw new Error("deploy.arc.json: envs must contain at least one environment");
|
|
27731
|
+
}
|
|
27732
|
+
for (const name of envKeys) {
|
|
27733
|
+
if (!/^[a-z][a-z0-9-]*$/.test(name)) {
|
|
27734
|
+
throw new Error(`deploy.arc.json: env name "${name}" must match [a-z][a-z0-9-]*`);
|
|
27735
|
+
}
|
|
27736
|
+
const env2 = requireObject(envs, `envs.${name}`);
|
|
27737
|
+
const domain = requireString(env2, `envs.${name}.domain`);
|
|
27738
|
+
if (!/^[a-z0-9.-]+\.[a-z]{2,}$/i.test(domain)) {
|
|
27739
|
+
throw new Error(`deploy.arc.json: envs.${name}.domain "${domain}" doesn't look like a domain`);
|
|
27740
|
+
}
|
|
27741
|
+
const envVarsRaw = env2.envVars;
|
|
27742
|
+
let envVars;
|
|
27743
|
+
if (envVarsRaw !== undefined) {
|
|
27744
|
+
if (!isObject(envVarsRaw))
|
|
27745
|
+
throw cfgErr(`envs.${name}.envVars`, "object");
|
|
27746
|
+
envVars = {};
|
|
27747
|
+
for (const [k, v] of Object.entries(envVarsRaw)) {
|
|
27748
|
+
if (typeof v !== "string") {
|
|
27749
|
+
throw new Error(`deploy.arc.json: envs.${name}.envVars.${k} must be a string`);
|
|
27750
|
+
}
|
|
27751
|
+
envVars[k] = v;
|
|
27752
|
+
}
|
|
27753
|
+
}
|
|
27754
|
+
validated.envs[name] = { domain, envVars };
|
|
27755
|
+
}
|
|
27756
|
+
const provision = input.provision;
|
|
27757
|
+
if (provision !== undefined) {
|
|
27758
|
+
if (!isObject(provision))
|
|
27759
|
+
throw cfgErr("provision", "object");
|
|
27760
|
+
const tf = requireObject(provision, "provision.terraform");
|
|
27761
|
+
const providerVal = requireString(tf, "provision.terraform.provider");
|
|
27762
|
+
if (providerVal !== "hcloud") {
|
|
27763
|
+
throw new Error(`deploy.arc.json: provision.terraform.provider must be "hcloud" (got "${providerVal}")`);
|
|
27764
|
+
}
|
|
27765
|
+
const terraform = {
|
|
27766
|
+
provider: "hcloud",
|
|
27767
|
+
serverType: requireString(tf, "provision.terraform.serverType"),
|
|
27768
|
+
location: requireString(tf, "provision.terraform.location"),
|
|
27769
|
+
image: optionalString(tf, "provision.terraform.image") ?? "ubuntu-22.04",
|
|
27770
|
+
tokenEnv: requireString(tf, "provision.terraform.tokenEnv"),
|
|
27771
|
+
sshPublicKey: optionalString(tf, "provision.terraform.sshPublicKey")
|
|
27772
|
+
};
|
|
27773
|
+
let ansible;
|
|
27774
|
+
const ansibleRaw = provision.ansible;
|
|
27775
|
+
if (ansibleRaw !== undefined) {
|
|
27776
|
+
if (!isObject(ansibleRaw))
|
|
27777
|
+
throw cfgErr("provision.ansible", "object");
|
|
27778
|
+
const allowed = ansibleRaw.extraAllowedIps;
|
|
27779
|
+
let extraAllowedIps;
|
|
27780
|
+
if (allowed !== undefined) {
|
|
27781
|
+
if (!Array.isArray(allowed)) {
|
|
27782
|
+
throw cfgErr("provision.ansible.extraAllowedIps", "string[]");
|
|
27783
|
+
}
|
|
27784
|
+
extraAllowedIps = allowed.map((v, i) => {
|
|
27785
|
+
if (typeof v !== "string") {
|
|
27786
|
+
throw cfgErr(`provision.ansible.extraAllowedIps[${i}]`, "string");
|
|
27787
|
+
}
|
|
27788
|
+
return v;
|
|
27789
|
+
});
|
|
27790
|
+
}
|
|
27791
|
+
ansible = {
|
|
27792
|
+
sshPort: optionalNumber(ansibleRaw, "provision.ansible.sshPort"),
|
|
27793
|
+
extraAllowedIps
|
|
27794
|
+
};
|
|
27795
|
+
}
|
|
27796
|
+
validated.provision = { terraform, ansible };
|
|
27797
|
+
}
|
|
27798
|
+
return validated;
|
|
27799
|
+
}
|
|
27800
|
+
function isObject(v) {
|
|
27801
|
+
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
27802
|
+
}
|
|
27803
|
+
function requireObject(parent, key) {
|
|
27804
|
+
const bare = key.includes(".") ? key.split(".").pop() : key;
|
|
27805
|
+
const v = parent[bare];
|
|
27806
|
+
if (!isObject(v))
|
|
27807
|
+
throw cfgErr(key, "object");
|
|
27808
|
+
return v;
|
|
27809
|
+
}
|
|
27810
|
+
function requireString(parent, key) {
|
|
27811
|
+
const bare = key.includes(".") ? key.split(".").pop() : key;
|
|
27812
|
+
const v = parent[bare];
|
|
27813
|
+
if (typeof v !== "string" || v.length === 0)
|
|
27814
|
+
throw cfgErr(key, "non-empty string");
|
|
27815
|
+
return v;
|
|
27816
|
+
}
|
|
27817
|
+
function optionalString(parent, key) {
|
|
27818
|
+
const bare = key.includes(".") ? key.split(".").pop() : key;
|
|
27819
|
+
const v = parent[bare];
|
|
27820
|
+
if (v === undefined)
|
|
27821
|
+
return;
|
|
27822
|
+
if (typeof v !== "string")
|
|
27823
|
+
throw cfgErr(key, "string");
|
|
27824
|
+
return v;
|
|
27825
|
+
}
|
|
27826
|
+
function optionalNumber(parent, key) {
|
|
27827
|
+
const bare = key.includes(".") ? key.split(".").pop() : key;
|
|
27828
|
+
const v = parent[bare];
|
|
27829
|
+
if (v === undefined)
|
|
27830
|
+
return;
|
|
27831
|
+
if (typeof v !== "number")
|
|
27832
|
+
throw cfgErr(key, "number");
|
|
27833
|
+
return v;
|
|
27834
|
+
}
|
|
27835
|
+
function cfgErr(path4, expected) {
|
|
27836
|
+
return new Error(`deploy.arc.json: ${path4} must be ${expected}`);
|
|
27837
|
+
}
|
|
27838
|
+
|
|
27839
|
+
// src/deploy/ssh.ts
|
|
27840
|
+
var {spawn: spawn4 } = globalThis.Bun;
|
|
27841
|
+
async function streamToString(stream2) {
|
|
27842
|
+
if (!stream2 || typeof stream2 === "number")
|
|
27843
|
+
return "";
|
|
27844
|
+
return new Response(stream2).text();
|
|
27845
|
+
}
|
|
27846
|
+
function baseSshArgs(target) {
|
|
27847
|
+
const args = [
|
|
27848
|
+
"-o",
|
|
27849
|
+
"BatchMode=yes",
|
|
27850
|
+
"-o",
|
|
27851
|
+
"StrictHostKeyChecking=accept-new",
|
|
27852
|
+
"-p",
|
|
27853
|
+
String(target.port)
|
|
27854
|
+
];
|
|
27855
|
+
if (target.sshKey)
|
|
27856
|
+
args.push("-i", target.sshKey);
|
|
27857
|
+
return args;
|
|
27858
|
+
}
|
|
27859
|
+
async function sshExec(target, cmd, opts = {}) {
|
|
27860
|
+
const args = [
|
|
27861
|
+
...baseSshArgs(target),
|
|
27862
|
+
`${target.user}@${target.host}`,
|
|
27863
|
+
"--",
|
|
27864
|
+
cmd
|
|
27865
|
+
];
|
|
27866
|
+
const proc2 = spawn4({
|
|
27867
|
+
cmd: ["ssh", ...args],
|
|
27868
|
+
stdin: opts.stdin ? "pipe" : "ignore",
|
|
27869
|
+
stdout: "pipe",
|
|
27870
|
+
stderr: "pipe"
|
|
27871
|
+
});
|
|
27872
|
+
if (opts.stdin && proc2.stdin) {
|
|
27873
|
+
const data = typeof opts.stdin === "string" ? new TextEncoder().encode(opts.stdin) : opts.stdin;
|
|
27874
|
+
await proc2.stdin.write(data);
|
|
27875
|
+
await proc2.stdin.end?.();
|
|
27876
|
+
}
|
|
27877
|
+
const [stdout, stderr, exitCode] = await Promise.all([
|
|
27878
|
+
streamToString(proc2.stdout),
|
|
27879
|
+
streamToString(proc2.stderr),
|
|
27880
|
+
proc2.exited
|
|
27881
|
+
]);
|
|
27882
|
+
if (!opts.quiet && exitCode !== 0) {
|
|
27883
|
+
process.stderr.write(stderr);
|
|
27884
|
+
}
|
|
27885
|
+
return { stdout, stderr, exitCode };
|
|
27886
|
+
}
|
|
27887
|
+
async function assertExec(target, cmd) {
|
|
27888
|
+
const res = await sshExec(target, cmd);
|
|
27889
|
+
if (res.exitCode !== 0) {
|
|
27890
|
+
throw new Error(`SSH command failed (exit ${res.exitCode}): ${cmd}
|
|
27891
|
+
${res.stderr}`);
|
|
27892
|
+
}
|
|
27893
|
+
return res.stdout;
|
|
27894
|
+
}
|
|
27895
|
+
async function canSsh(target) {
|
|
27896
|
+
const res = await sshExec(target, "true", { quiet: true });
|
|
27897
|
+
return res.exitCode === 0;
|
|
27898
|
+
}
|
|
27899
|
+
async function waitForSsh(target, opts = {}) {
|
|
27900
|
+
const timeout = opts.timeoutMs ?? 300000;
|
|
27901
|
+
const interval = opts.intervalMs ?? 1e4;
|
|
27902
|
+
const start = Date.now();
|
|
27903
|
+
while (Date.now() - start < timeout) {
|
|
27904
|
+
if (await canSsh(target))
|
|
27905
|
+
return;
|
|
27906
|
+
await Bun.sleep(interval);
|
|
27907
|
+
}
|
|
27908
|
+
throw new Error(`Timed out waiting for SSH on ${target.user}@${target.host}`);
|
|
27909
|
+
}
|
|
27910
|
+
async function scpUpload(target, localPath, remotePath) {
|
|
27911
|
+
const args = [
|
|
27912
|
+
"-o",
|
|
27913
|
+
"BatchMode=yes",
|
|
27914
|
+
"-o",
|
|
27915
|
+
"StrictHostKeyChecking=accept-new",
|
|
27916
|
+
"-P",
|
|
27917
|
+
String(target.port)
|
|
27918
|
+
];
|
|
27919
|
+
if (target.sshKey)
|
|
27920
|
+
args.push("-i", target.sshKey);
|
|
27921
|
+
args.push(localPath, `${target.user}@${target.host}:${remotePath}`);
|
|
27922
|
+
const proc2 = spawn4({ cmd: ["scp", ...args], stderr: "pipe" });
|
|
27923
|
+
const [stderr, exitCode] = await Promise.all([
|
|
27924
|
+
streamToString(proc2.stderr),
|
|
27925
|
+
proc2.exited
|
|
27926
|
+
]);
|
|
27927
|
+
if (exitCode !== 0) {
|
|
27928
|
+
throw new Error(`scp failed (${exitCode}): ${stderr}`);
|
|
27929
|
+
}
|
|
27930
|
+
}
|
|
27931
|
+
async function rsyncDir(target, localDir, remoteDir, opts = {}) {
|
|
27932
|
+
const sshCmdParts = ["ssh", "-p", String(target.port)];
|
|
27933
|
+
if (target.sshKey)
|
|
27934
|
+
sshCmdParts.push("-i", target.sshKey);
|
|
27935
|
+
const sshCmd = sshCmdParts.join(" ");
|
|
27936
|
+
const args = ["-azL", "-e", sshCmd];
|
|
27937
|
+
if (opts.delete)
|
|
27938
|
+
args.push("--delete");
|
|
27939
|
+
const src = localDir.endsWith("/") ? localDir : `${localDir}/`;
|
|
27940
|
+
args.push(src, `${target.user}@${target.host}:${remoteDir}`);
|
|
27941
|
+
const proc2 = spawn4({
|
|
27942
|
+
cmd: ["rsync", ...args],
|
|
27943
|
+
stderr: "pipe",
|
|
27944
|
+
stdout: "pipe"
|
|
27945
|
+
});
|
|
27946
|
+
const [stderr, exitCode] = await Promise.all([
|
|
27947
|
+
streamToString(proc2.stderr),
|
|
27948
|
+
proc2.exited
|
|
27949
|
+
]);
|
|
27950
|
+
if (exitCode !== 0) {
|
|
27951
|
+
throw new Error(`rsync failed (${exitCode}): ${stderr}`);
|
|
27952
|
+
}
|
|
27953
|
+
}
|
|
27954
|
+
async function openTunnel(target, localPort, remoteHost, remotePort) {
|
|
27955
|
+
const args = [
|
|
27956
|
+
...baseSshArgs(target),
|
|
27957
|
+
"-N",
|
|
27958
|
+
"-L",
|
|
27959
|
+
`${localPort}:${remoteHost}:${remotePort}`,
|
|
27960
|
+
`${target.user}@${target.host}`
|
|
27961
|
+
];
|
|
27962
|
+
const proc2 = spawn4({
|
|
27963
|
+
cmd: ["ssh", ...args],
|
|
27964
|
+
stdin: "ignore",
|
|
27965
|
+
stdout: "pipe",
|
|
27966
|
+
stderr: "pipe"
|
|
27967
|
+
});
|
|
27968
|
+
const deadline = Date.now() + 1e4;
|
|
27969
|
+
let lastErr;
|
|
27970
|
+
while (Date.now() < deadline) {
|
|
27971
|
+
if (proc2.exitCode !== null) {
|
|
27972
|
+
const stderr = await streamToString(proc2.stderr);
|
|
27973
|
+
throw new Error(`ssh tunnel exited early: ${stderr}`);
|
|
27974
|
+
}
|
|
27975
|
+
try {
|
|
27976
|
+
const probe = await Bun.connect({
|
|
27977
|
+
hostname: "127.0.0.1",
|
|
27978
|
+
port: localPort,
|
|
27979
|
+
socket: { data() {}, open() {}, close() {}, error() {} }
|
|
27980
|
+
});
|
|
27981
|
+
probe.end();
|
|
27982
|
+
return {
|
|
27983
|
+
localPort,
|
|
27984
|
+
close() {
|
|
27985
|
+
try {
|
|
27986
|
+
proc2.kill();
|
|
27987
|
+
} catch {}
|
|
27988
|
+
}
|
|
27989
|
+
};
|
|
27990
|
+
} catch (e) {
|
|
27991
|
+
lastErr = e;
|
|
27992
|
+
await Bun.sleep(200);
|
|
27993
|
+
}
|
|
27994
|
+
}
|
|
27995
|
+
try {
|
|
27996
|
+
proc2.kill();
|
|
27997
|
+
} catch {}
|
|
27998
|
+
throw new Error(`Failed to establish SSH tunnel on localhost:${localPort}: ${String(lastErr)}`);
|
|
27999
|
+
}
|
|
28000
|
+
|
|
28001
|
+
// src/deploy/remote-state.ts
|
|
28002
|
+
var STATE_MARKER_PATH = "/opt/arc/.arc-state.json";
|
|
28003
|
+
async function detectRemoteState(cfg) {
|
|
28004
|
+
if (cfg.target.host === "PENDING_TERRAFORM" || !cfg.target.host) {
|
|
28005
|
+
return { kind: "unreachable", reason: "target.host not yet set" };
|
|
28006
|
+
}
|
|
28007
|
+
if (!await canSsh(cfg.target)) {
|
|
28008
|
+
return { kind: "unreachable", reason: "ssh connection failed" };
|
|
28009
|
+
}
|
|
28010
|
+
const dockerCheck = await sshExec(cfg.target, "command -v docker", {
|
|
28011
|
+
quiet: true
|
|
28012
|
+
});
|
|
28013
|
+
if (dockerCheck.exitCode !== 0) {
|
|
28014
|
+
return { kind: "no-docker" };
|
|
28015
|
+
}
|
|
28016
|
+
const composeDir = `${cfg.target.remoteDir}`;
|
|
28017
|
+
const psCheck = await sshExec(cfg.target, `test -f ${composeDir}/docker-compose.yml && cd ${composeDir} && docker compose ps --format '{{.Service}}' || true`, { quiet: true });
|
|
28018
|
+
if (psCheck.exitCode !== 0 || psCheck.stdout.trim() === "") {
|
|
28019
|
+
return { kind: "no-stack" };
|
|
28020
|
+
}
|
|
28021
|
+
const running = psCheck.stdout.split(`
|
|
28022
|
+
`).map((l) => l.trim()).filter((l) => l.startsWith("arc-")).map((l) => l.replace(/^arc-/, ""));
|
|
28023
|
+
const markerRaw = await sshExec(cfg.target, `cat ${STATE_MARKER_PATH}`, {
|
|
28024
|
+
quiet: true
|
|
28025
|
+
});
|
|
28026
|
+
let marker = null;
|
|
28027
|
+
if (markerRaw.exitCode === 0) {
|
|
28028
|
+
try {
|
|
28029
|
+
marker = JSON.parse(markerRaw.stdout);
|
|
28030
|
+
} catch {
|
|
28031
|
+
marker = null;
|
|
28032
|
+
}
|
|
28033
|
+
}
|
|
28034
|
+
return { kind: "ready", runningEnvs: running, marker };
|
|
28035
|
+
}
|
|
28036
|
+
async function writeStateMarker(target, marker) {
|
|
28037
|
+
const json = JSON.stringify(marker, null, 2);
|
|
28038
|
+
await assertExec(target, `sudo tee ${STATE_MARKER_PATH} > /dev/null <<'JSON'
|
|
28039
|
+
${json}
|
|
28040
|
+
JSON`);
|
|
28041
|
+
}
|
|
28042
|
+
|
|
28043
|
+
// src/deploy/bootstrap.ts
|
|
28044
|
+
async function bootstrap(inputs) {
|
|
28045
|
+
const { cfg, state, rootDir } = inputs;
|
|
28046
|
+
if (state.kind === "unreachable") {
|
|
28047
|
+
if (!cfg.provision?.terraform) {
|
|
28048
|
+
throw new Error(`Server ${cfg.target.host} is unreachable and deploy.arc.json has no provision.terraform section. Either fix SSH access or add a provision block.`);
|
|
28049
|
+
}
|
|
28050
|
+
log2("Provisioning server via Terraform...");
|
|
28051
|
+
const token = process.env[cfg.provision.terraform.tokenEnv];
|
|
28052
|
+
if (!token) {
|
|
28053
|
+
throw new Error(`Environment variable ${cfg.provision.terraform.tokenEnv} is not set`);
|
|
28054
|
+
}
|
|
28055
|
+
const tfOut = await runTerraform({
|
|
28056
|
+
tf: cfg.provision.terraform,
|
|
28057
|
+
token,
|
|
28058
|
+
serverName: `arc-${Object.keys(cfg.envs)[0] ?? "host"}`
|
|
28059
|
+
});
|
|
28060
|
+
ok(`Server provisioned: ${tfOut.serverIp}`);
|
|
28061
|
+
cfg.target.host = tfOut.serverIp;
|
|
28062
|
+
saveDeployConfig(rootDir, cfg);
|
|
28063
|
+
log2("Waiting for SSH to come up...");
|
|
28064
|
+
await waitForSsh({ ...cfg.target, user: "root" });
|
|
28065
|
+
ok("SSH reachable");
|
|
28066
|
+
}
|
|
28067
|
+
if (state.kind === "unreachable" || state.kind === "no-docker") {
|
|
28068
|
+
log2("Running Ansible bootstrap (Docker + firewall + SSH hardening)...");
|
|
28069
|
+
const asRoot = state.kind === "unreachable";
|
|
28070
|
+
await runAnsible({
|
|
28071
|
+
target: cfg.target,
|
|
28072
|
+
ansible: cfg.provision?.ansible,
|
|
28073
|
+
asRoot
|
|
28074
|
+
});
|
|
28075
|
+
ok("Host bootstrapped");
|
|
28076
|
+
}
|
|
28077
|
+
if (state.kind !== "ready") {
|
|
28078
|
+
await upStack(inputs);
|
|
28079
|
+
ok("Docker stack up");
|
|
28080
|
+
}
|
|
28081
|
+
await writeStateMarker(cfg.target, {
|
|
28082
|
+
cliVersion: inputs.cliVersion,
|
|
28083
|
+
configHash: inputs.configHash,
|
|
28084
|
+
updatedAt: new Date().toISOString()
|
|
28085
|
+
});
|
|
28086
|
+
}
|
|
28087
|
+
async function upStack(inputs) {
|
|
28088
|
+
const { cfg } = inputs;
|
|
28089
|
+
const workDir = join11(tmpdir3(), "arc-deploy", `stack-${Date.now()}`);
|
|
28090
|
+
mkdirSync9(workDir, { recursive: true });
|
|
28091
|
+
writeFileSync10(join11(workDir, "Caddyfile"), generateCaddyfile(cfg));
|
|
28092
|
+
writeFileSync10(join11(workDir, "docker-compose.yml"), generateCompose({ cfg }));
|
|
28093
|
+
await assertExec(cfg.target, `sudo mkdir -p ${cfg.target.remoteDir} && sudo chown ${cfg.target.user}:${cfg.target.user} ${cfg.target.remoteDir}`);
|
|
28094
|
+
for (const name of Object.keys(cfg.envs)) {
|
|
28095
|
+
await assertExec(cfg.target, `mkdir -p ${cfg.target.remoteDir}/${name}`);
|
|
28096
|
+
}
|
|
28097
|
+
await scpUpload(cfg.target, join11(workDir, "Caddyfile"), `${cfg.target.remoteDir}/Caddyfile`);
|
|
28098
|
+
await scpUpload(cfg.target, join11(workDir, "docker-compose.yml"), `${cfg.target.remoteDir}/docker-compose.yml`);
|
|
28099
|
+
await assertExec(cfg.target, `cd ${cfg.target.remoteDir} && docker compose pull --ignore-pull-failures && docker compose up -d`);
|
|
28100
|
+
}
|
|
28101
|
+
|
|
28102
|
+
// src/deploy/remote-sync.ts
|
|
28103
|
+
import { existsSync as existsSync9, readFileSync as readFileSync8 } from "fs";
|
|
28104
|
+
import { join as join12, relative as relative3 } from "path";
|
|
28105
|
+
function diffManifests(local, remote) {
|
|
28106
|
+
const remoteByName = new Map(remote.modules.map((m) => [m.name, m]));
|
|
28107
|
+
const changedModules = local.modules.filter((m) => remoteByName.get(m.name)?.hash !== m.hash);
|
|
28108
|
+
return {
|
|
28109
|
+
changedModules: [...changedModules],
|
|
28110
|
+
shellChanged: local.shellHash !== remote.shellHash,
|
|
28111
|
+
stylesChanged: local.stylesHash !== remote.stylesHash
|
|
28112
|
+
};
|
|
28113
|
+
}
|
|
28114
|
+
async function syncEnv(inputs) {
|
|
28115
|
+
const { cfg, env: env2, ws, projectDir } = inputs;
|
|
28116
|
+
const envConfig = cfg.envs[env2];
|
|
28117
|
+
if (!envConfig)
|
|
28118
|
+
throw new Error(`Unknown env: ${env2}`);
|
|
28119
|
+
const remotePath = `${cfg.target.remoteDir}/${env2}`;
|
|
28120
|
+
await rsyncDir(cfg.target, projectDir, remotePath);
|
|
28121
|
+
const localManifestPath = join12(ws.modulesDir, "manifest.json");
|
|
28122
|
+
if (!existsSync9(localManifestPath)) {
|
|
28123
|
+
throw new Error(`Local build missing at ${localManifestPath}. Run arc platform build first.`);
|
|
28124
|
+
}
|
|
28125
|
+
const localManifest = JSON.parse(readFileSync8(localManifestPath, "utf-8"));
|
|
28126
|
+
const localPort = 15500 + hashEnvToOffset(env2);
|
|
28127
|
+
const tunnel = await openTunnel(cfg.target, localPort, "127.0.0.1", 2019);
|
|
28128
|
+
try {
|
|
28129
|
+
const base2 = `http://127.0.0.1:${localPort}/env/${env2}`;
|
|
28130
|
+
const remoteManifestRes = await fetch(`${base2}/api/deploy/manifest`);
|
|
28131
|
+
if (!remoteManifestRes.ok) {
|
|
28132
|
+
throw new Error(`Failed to fetch remote manifest: ${remoteManifestRes.status}`);
|
|
28133
|
+
}
|
|
28134
|
+
const remoteManifest = await remoteManifestRes.json();
|
|
28135
|
+
const diff = diffManifests(localManifest, remoteManifest);
|
|
28136
|
+
if (diff.shellChanged) {
|
|
28137
|
+
const shellFiles = collectFiles(ws.shellDir);
|
|
28138
|
+
const form = new FormData;
|
|
28139
|
+
for (const absPath of shellFiles) {
|
|
28140
|
+
const rel = relative3(ws.shellDir, absPath);
|
|
28141
|
+
form.append(rel, new Blob([readFileSync8(absPath)]), rel);
|
|
28142
|
+
}
|
|
28143
|
+
const res2 = await fetch(`${base2}/api/deploy/shell`, {
|
|
28144
|
+
method: "POST",
|
|
28145
|
+
body: form
|
|
28146
|
+
});
|
|
28147
|
+
if (!res2.ok)
|
|
28148
|
+
throw new Error(`Shell upload failed: ${res2.status} ${await res2.text()}`);
|
|
28149
|
+
}
|
|
28150
|
+
if (diff.stylesChanged) {
|
|
28151
|
+
const form = new FormData;
|
|
28152
|
+
for (const name of ["styles.css", "theme.css"]) {
|
|
28153
|
+
const p = join12(ws.arcDir, name);
|
|
28154
|
+
if (existsSync9(p)) {
|
|
28155
|
+
form.append(name, new Blob([readFileSync8(p)]), name);
|
|
28156
|
+
}
|
|
28157
|
+
}
|
|
28158
|
+
const res2 = await fetch(`${base2}/api/deploy/shell`, {
|
|
28159
|
+
method: "POST",
|
|
28160
|
+
body: form
|
|
28161
|
+
});
|
|
28162
|
+
if (!res2.ok)
|
|
28163
|
+
throw new Error(`Styles upload failed: ${res2.status} ${await res2.text()}`);
|
|
28164
|
+
}
|
|
28165
|
+
if (diff.changedModules.length > 0) {
|
|
28166
|
+
const form = new FormData;
|
|
28167
|
+
for (const mod of diff.changedModules) {
|
|
28168
|
+
const p = join12(ws.modulesDir, mod.file);
|
|
28169
|
+
form.append(mod.file, new Blob([readFileSync8(p)]), mod.file);
|
|
28170
|
+
}
|
|
28171
|
+
const res2 = await fetch(`${base2}/api/deploy/modules`, {
|
|
28172
|
+
method: "POST",
|
|
28173
|
+
body: form
|
|
28174
|
+
});
|
|
28175
|
+
if (!res2.ok)
|
|
28176
|
+
throw new Error(`Modules upload failed: ${res2.status} ${await res2.text()}`);
|
|
28177
|
+
}
|
|
28178
|
+
const res = await fetch(`${base2}/api/deploy/manifest`, {
|
|
28179
|
+
method: "POST",
|
|
28180
|
+
headers: { "Content-Type": "application/json" },
|
|
28181
|
+
body: JSON.stringify(localManifest)
|
|
28182
|
+
});
|
|
28183
|
+
if (!res.ok)
|
|
28184
|
+
throw new Error(`Manifest update failed: ${res.status} ${await res.text()}`);
|
|
28185
|
+
return {
|
|
28186
|
+
env: env2,
|
|
28187
|
+
changedModules: diff.changedModules.map((m) => m.name),
|
|
28188
|
+
shellChanged: diff.shellChanged,
|
|
28189
|
+
stylesChanged: diff.stylesChanged
|
|
28190
|
+
};
|
|
28191
|
+
} finally {
|
|
28192
|
+
tunnel.close();
|
|
28193
|
+
}
|
|
28194
|
+
}
|
|
28195
|
+
function collectFiles(dir) {
|
|
28196
|
+
if (!existsSync9(dir))
|
|
28197
|
+
return [];
|
|
28198
|
+
const { readdirSync: readdirSync5 } = __require("fs");
|
|
28199
|
+
const out = [];
|
|
28200
|
+
for (const entry of readdirSync5(dir, { withFileTypes: true })) {
|
|
28201
|
+
const p = join12(dir, entry.name);
|
|
28202
|
+
if (entry.isDirectory())
|
|
28203
|
+
out.push(...collectFiles(p));
|
|
28204
|
+
else if (entry.isFile())
|
|
28205
|
+
out.push(p);
|
|
28206
|
+
}
|
|
28207
|
+
return out;
|
|
28208
|
+
}
|
|
28209
|
+
function hashEnvToOffset(env2) {
|
|
28210
|
+
let h = 0;
|
|
28211
|
+
for (const ch of env2)
|
|
28212
|
+
h = h * 31 + ch.charCodeAt(0) >>> 0;
|
|
28213
|
+
return h % 100;
|
|
28214
|
+
}
|
|
28215
|
+
|
|
28216
|
+
// ../../node_modules/.bun/@clack+core@0.4.1/node_modules/@clack/core/dist/index.mjs
|
|
28217
|
+
var import_sisteransi = __toESM(require_src(), 1);
|
|
28218
|
+
import { stdin as $, stdout as j } from "process";
|
|
28219
|
+
var import_picocolors = __toESM(require_picocolors(), 1);
|
|
28220
|
+
import M from "readline";
|
|
28221
|
+
import { WriteStream as U } from "tty";
|
|
28222
|
+
function J({ onlyFirst: t = false } = {}) {
|
|
28223
|
+
const F = ["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))", "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");
|
|
28224
|
+
return new RegExp(F, t ? undefined : "g");
|
|
28225
|
+
}
|
|
28226
|
+
var Q = J();
|
|
28227
|
+
function T(t) {
|
|
28228
|
+
if (typeof t != "string")
|
|
28229
|
+
throw new TypeError(`Expected a \`string\`, got \`${typeof t}\``);
|
|
28230
|
+
return t.replace(Q, "");
|
|
28231
|
+
}
|
|
28232
|
+
function O(t) {
|
|
28233
|
+
return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
|
|
28234
|
+
}
|
|
28235
|
+
var P = { exports: {} };
|
|
28236
|
+
(function(t) {
|
|
28237
|
+
var u = {};
|
|
28238
|
+
t.exports = u, u.eastAsianWidth = function(e) {
|
|
28239
|
+
var s = e.charCodeAt(0), i = e.length == 2 ? e.charCodeAt(1) : 0, D = s;
|
|
28240
|
+
return 55296 <= s && s <= 56319 && 56320 <= i && i <= 57343 && (s &= 1023, i &= 1023, D = s << 10 | i, D += 65536), D == 12288 || 65281 <= D && D <= 65376 || 65504 <= D && D <= 65510 ? "F" : D == 8361 || 65377 <= D && D <= 65470 || 65474 <= D && D <= 65479 || 65482 <= D && D <= 65487 || 65490 <= D && D <= 65495 || 65498 <= D && D <= 65500 || 65512 <= D && D <= 65518 ? "H" : 4352 <= D && D <= 4447 || 4515 <= D && D <= 4519 || 4602 <= D && D <= 4607 || 9001 <= D && D <= 9002 || 11904 <= D && D <= 11929 || 11931 <= D && D <= 12019 || 12032 <= D && D <= 12245 || 12272 <= D && D <= 12283 || 12289 <= D && D <= 12350 || 12353 <= D && D <= 12438 || 12441 <= D && D <= 12543 || 12549 <= D && D <= 12589 || 12593 <= D && D <= 12686 || 12688 <= D && D <= 12730 || 12736 <= D && D <= 12771 || 12784 <= D && D <= 12830 || 12832 <= D && D <= 12871 || 12880 <= D && D <= 13054 || 13056 <= D && D <= 19903 || 19968 <= D && D <= 42124 || 42128 <= D && D <= 42182 || 43360 <= D && D <= 43388 || 44032 <= D && D <= 55203 || 55216 <= D && D <= 55238 || 55243 <= D && D <= 55291 || 63744 <= D && D <= 64255 || 65040 <= D && D <= 65049 || 65072 <= D && D <= 65106 || 65108 <= D && D <= 65126 || 65128 <= D && D <= 65131 || 110592 <= D && D <= 110593 || 127488 <= D && D <= 127490 || 127504 <= D && D <= 127546 || 127552 <= D && D <= 127560 || 127568 <= D && D <= 127569 || 131072 <= D && D <= 194367 || 177984 <= D && D <= 196605 || 196608 <= D && D <= 262141 ? "W" : 32 <= D && D <= 126 || 162 <= D && D <= 163 || 165 <= D && D <= 166 || D == 172 || D == 175 || 10214 <= D && D <= 10221 || 10629 <= D && D <= 10630 ? "Na" : D == 161 || D == 164 || 167 <= D && D <= 168 || D == 170 || 173 <= D && D <= 174 || 176 <= D && D <= 180 || 182 <= D && D <= 186 || 188 <= D && D <= 191 || D == 198 || D == 208 || 215 <= D && D <= 216 || 222 <= D && D <= 225 || D == 230 || 232 <= D && D <= 234 || 236 <= D && D <= 237 || D == 240 || 242 <= D && D <= 243 || 247 <= D && D <= 250 || D == 252 || D == 254 || D == 257 || D == 273 || D == 275 || D == 283 || 294 <= D && D <= 295 || D == 299 || 305 <= D && D <= 307 || D == 312 || 319 <= D && D <= 322 || D == 324 || 328 <= D && D <= 331 || D == 333 || 338 <= D && D <= 339 || 358 <= D && D <= 359 || D == 363 || D == 462 || D == 464 || D == 466 || D == 468 || D == 470 || D == 472 || D == 474 || D == 476 || D == 593 || D == 609 || D == 708 || D == 711 || 713 <= D && D <= 715 || D == 717 || D == 720 || 728 <= D && D <= 731 || D == 733 || D == 735 || 768 <= D && D <= 879 || 913 <= D && D <= 929 || 931 <= D && D <= 937 || 945 <= D && D <= 961 || 963 <= D && D <= 969 || D == 1025 || 1040 <= D && D <= 1103 || D == 1105 || D == 8208 || 8211 <= D && D <= 8214 || 8216 <= D && D <= 8217 || 8220 <= D && D <= 8221 || 8224 <= D && D <= 8226 || 8228 <= D && D <= 8231 || D == 8240 || 8242 <= D && D <= 8243 || D == 8245 || D == 8251 || D == 8254 || D == 8308 || D == 8319 || 8321 <= D && D <= 8324 || D == 8364 || D == 8451 || D == 8453 || D == 8457 || D == 8467 || D == 8470 || 8481 <= D && D <= 8482 || D == 8486 || D == 8491 || 8531 <= D && D <= 8532 || 8539 <= D && D <= 8542 || 8544 <= D && D <= 8555 || 8560 <= D && D <= 8569 || D == 8585 || 8592 <= D && D <= 8601 || 8632 <= D && D <= 8633 || D == 8658 || D == 8660 || D == 8679 || D == 8704 || 8706 <= D && D <= 8707 || 8711 <= D && D <= 8712 || D == 8715 || D == 8719 || D == 8721 || D == 8725 || D == 8730 || 8733 <= D && D <= 8736 || D == 8739 || D == 8741 || 8743 <= D && D <= 8748 || D == 8750 || 8756 <= D && D <= 8759 || 8764 <= D && D <= 8765 || D == 8776 || D == 8780 || D == 8786 || 8800 <= D && D <= 8801 || 8804 <= D && D <= 8807 || 8810 <= D && D <= 8811 || 8814 <= D && D <= 8815 || 8834 <= D && D <= 8835 || 8838 <= D && D <= 8839 || D == 8853 || D == 8857 || D == 8869 || D == 8895 || D == 8978 || 9312 <= D && D <= 9449 || 9451 <= D && D <= 9547 || 9552 <= D && D <= 9587 || 9600 <= D && D <= 9615 || 9618 <= D && D <= 9621 || 9632 <= D && D <= 9633 || 9635 <= D && D <= 9641 || 9650 <= D && D <= 9651 || 9654 <= D && D <= 9655 || 9660 <= D && D <= 9661 || 9664 <= D && D <= 9665 || 9670 <= D && D <= 9672 || D == 9675 || 9678 <= D && D <= 9681 || 9698 <= D && D <= 9701 || D == 9711 || 9733 <= D && D <= 9734 || D == 9737 || 9742 <= D && D <= 9743 || 9748 <= D && D <= 9749 || D == 9756 || D == 9758 || D == 9792 || D == 9794 || 9824 <= D && D <= 9825 || 9827 <= D && D <= 9829 || 9831 <= D && D <= 9834 || 9836 <= D && D <= 9837 || D == 9839 || 9886 <= D && D <= 9887 || 9918 <= D && D <= 9919 || 9924 <= D && D <= 9933 || 9935 <= D && D <= 9953 || D == 9955 || 9960 <= D && D <= 9983 || D == 10045 || D == 10071 || 10102 <= D && D <= 10111 || 11093 <= D && D <= 11097 || 12872 <= D && D <= 12879 || 57344 <= D && D <= 63743 || 65024 <= D && D <= 65039 || D == 65533 || 127232 <= D && D <= 127242 || 127248 <= D && D <= 127277 || 127280 <= D && D <= 127337 || 127344 <= D && D <= 127386 || 917760 <= D && D <= 917999 || 983040 <= D && D <= 1048573 || 1048576 <= D && D <= 1114109 ? "A" : "N";
|
|
28241
|
+
}, u.characterLength = function(e) {
|
|
28242
|
+
var s = this.eastAsianWidth(e);
|
|
28243
|
+
return s == "F" || s == "W" || s == "A" ? 2 : 1;
|
|
28244
|
+
};
|
|
28245
|
+
function F(e) {
|
|
28246
|
+
return e.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g) || [];
|
|
28247
|
+
}
|
|
28248
|
+
u.length = function(e) {
|
|
28249
|
+
for (var s = F(e), i = 0, D = 0;D < s.length; D++)
|
|
28250
|
+
i = i + this.characterLength(s[D]);
|
|
28251
|
+
return i;
|
|
28252
|
+
}, u.slice = function(e, s, i) {
|
|
28253
|
+
textLen = u.length(e), s = s || 0, i = i || 1, s < 0 && (s = textLen + s), i < 0 && (i = textLen + i);
|
|
28254
|
+
for (var D = "", C2 = 0, o = F(e), E = 0;E < o.length; E++) {
|
|
28255
|
+
var a = o[E], n = u.length(a);
|
|
28256
|
+
if (C2 >= s - (n == 2 ? 1 : 0))
|
|
28257
|
+
if (C2 + n <= i)
|
|
28258
|
+
D += a;
|
|
28259
|
+
else
|
|
28260
|
+
break;
|
|
28261
|
+
C2 += n;
|
|
28262
|
+
}
|
|
28263
|
+
return D;
|
|
28264
|
+
};
|
|
28265
|
+
})(P);
|
|
28266
|
+
var X = P.exports;
|
|
28267
|
+
var DD = O(X);
|
|
28268
|
+
var uD = function() {
|
|
28269
|
+
return /\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g;
|
|
28270
|
+
};
|
|
28271
|
+
var FD = O(uD);
|
|
28272
|
+
function A(t, u = {}) {
|
|
28273
|
+
if (typeof t != "string" || t.length === 0 || (u = { ambiguousIsNarrow: true, ...u }, t = T(t), t.length === 0))
|
|
28274
|
+
return 0;
|
|
28275
|
+
t = t.replace(FD(), " ");
|
|
28276
|
+
const F = u.ambiguousIsNarrow ? 1 : 2;
|
|
28277
|
+
let e = 0;
|
|
28278
|
+
for (const s of t) {
|
|
28279
|
+
const i = s.codePointAt(0);
|
|
28280
|
+
if (i <= 31 || i >= 127 && i <= 159 || i >= 768 && i <= 879)
|
|
28281
|
+
continue;
|
|
28282
|
+
switch (DD.eastAsianWidth(s)) {
|
|
28283
|
+
case "F":
|
|
28284
|
+
case "W":
|
|
28285
|
+
e += 2;
|
|
28286
|
+
break;
|
|
28287
|
+
case "A":
|
|
28288
|
+
e += F;
|
|
28289
|
+
break;
|
|
28290
|
+
default:
|
|
28291
|
+
e += 1;
|
|
28292
|
+
}
|
|
28293
|
+
}
|
|
28294
|
+
return e;
|
|
28295
|
+
}
|
|
28296
|
+
var m = 10;
|
|
28297
|
+
var L = (t = 0) => (u) => `\x1B[${u + t}m`;
|
|
28298
|
+
var N = (t = 0) => (u) => `\x1B[${38 + t};5;${u}m`;
|
|
28299
|
+
var I = (t = 0) => (u, F, e) => `\x1B[${38 + t};2;${u};${F};${e}m`;
|
|
28300
|
+
var r = { modifier: { reset: [0, 0], bold: [1, 22], dim: [2, 22], italic: [3, 23], underline: [4, 24], overline: [53, 55], inverse: [7, 27], hidden: [8, 28], strikethrough: [9, 29] }, color: { black: [30, 39], red: [31, 39], green: [32, 39], yellow: [33, 39], blue: [34, 39], magenta: [35, 39], cyan: [36, 39], white: [37, 39], blackBright: [90, 39], gray: [90, 39], grey: [90, 39], redBright: [91, 39], greenBright: [92, 39], yellowBright: [93, 39], blueBright: [94, 39], magentaBright: [95, 39], cyanBright: [96, 39], whiteBright: [97, 39] }, bgColor: { bgBlack: [40, 49], bgRed: [41, 49], bgGreen: [42, 49], bgYellow: [43, 49], bgBlue: [44, 49], bgMagenta: [45, 49], bgCyan: [46, 49], bgWhite: [47, 49], bgBlackBright: [100, 49], bgGray: [100, 49], bgGrey: [100, 49], bgRedBright: [101, 49], bgGreenBright: [102, 49], bgYellowBright: [103, 49], bgBlueBright: [104, 49], bgMagentaBright: [105, 49], bgCyanBright: [106, 49], bgWhiteBright: [107, 49] } };
|
|
28301
|
+
Object.keys(r.modifier);
|
|
28302
|
+
var tD = Object.keys(r.color);
|
|
28303
|
+
var eD = Object.keys(r.bgColor);
|
|
28304
|
+
[...tD, ...eD];
|
|
28305
|
+
function sD() {
|
|
28306
|
+
const t = new Map;
|
|
28307
|
+
for (const [u, F] of Object.entries(r)) {
|
|
28308
|
+
for (const [e, s] of Object.entries(F))
|
|
28309
|
+
r[e] = { open: `\x1B[${s[0]}m`, close: `\x1B[${s[1]}m` }, F[e] = r[e], t.set(s[0], s[1]);
|
|
28310
|
+
Object.defineProperty(r, u, { value: F, enumerable: false });
|
|
28311
|
+
}
|
|
28312
|
+
return Object.defineProperty(r, "codes", { value: t, enumerable: false }), r.color.close = "\x1B[39m", r.bgColor.close = "\x1B[49m", r.color.ansi = L(), r.color.ansi256 = N(), r.color.ansi16m = I(), r.bgColor.ansi = L(m), r.bgColor.ansi256 = N(m), r.bgColor.ansi16m = I(m), Object.defineProperties(r, { rgbToAnsi256: { value: (u, F, e) => u === F && F === e ? u < 8 ? 16 : u > 248 ? 231 : Math.round((u - 8) / 247 * 24) + 232 : 16 + 36 * Math.round(u / 255 * 5) + 6 * Math.round(F / 255 * 5) + Math.round(e / 255 * 5), enumerable: false }, hexToRgb: { value: (u) => {
|
|
28313
|
+
const F = /[a-f\d]{6}|[a-f\d]{3}/i.exec(u.toString(16));
|
|
28314
|
+
if (!F)
|
|
28315
|
+
return [0, 0, 0];
|
|
28316
|
+
let [e] = F;
|
|
28317
|
+
e.length === 3 && (e = [...e].map((i) => i + i).join(""));
|
|
28318
|
+
const s = Number.parseInt(e, 16);
|
|
28319
|
+
return [s >> 16 & 255, s >> 8 & 255, s & 255];
|
|
28320
|
+
}, enumerable: false }, hexToAnsi256: { value: (u) => r.rgbToAnsi256(...r.hexToRgb(u)), enumerable: false }, ansi256ToAnsi: { value: (u) => {
|
|
28321
|
+
if (u < 8)
|
|
28322
|
+
return 30 + u;
|
|
28323
|
+
if (u < 16)
|
|
28324
|
+
return 90 + (u - 8);
|
|
28325
|
+
let F, e, s;
|
|
28326
|
+
if (u >= 232)
|
|
28327
|
+
F = ((u - 232) * 10 + 8) / 255, e = F, s = F;
|
|
28328
|
+
else {
|
|
28329
|
+
u -= 16;
|
|
28330
|
+
const C2 = u % 36;
|
|
28331
|
+
F = Math.floor(u / 36) / 5, e = Math.floor(C2 / 6) / 5, s = C2 % 6 / 5;
|
|
28332
|
+
}
|
|
28333
|
+
const i = Math.max(F, e, s) * 2;
|
|
28334
|
+
if (i === 0)
|
|
28335
|
+
return 30;
|
|
28336
|
+
let D = 30 + (Math.round(s) << 2 | Math.round(e) << 1 | Math.round(F));
|
|
28337
|
+
return i === 2 && (D += 60), D;
|
|
28338
|
+
}, enumerable: false }, rgbToAnsi: { value: (u, F, e) => r.ansi256ToAnsi(r.rgbToAnsi256(u, F, e)), enumerable: false }, hexToAnsi: { value: (u) => r.ansi256ToAnsi(r.hexToAnsi256(u)), enumerable: false } }), r;
|
|
28339
|
+
}
|
|
28340
|
+
var iD = sD();
|
|
28341
|
+
var v = new Set(["\x1B", "\x9B"]);
|
|
28342
|
+
var CD = 39;
|
|
28343
|
+
var w = "\x07";
|
|
28344
|
+
var W = "[";
|
|
28345
|
+
var rD = "]";
|
|
28346
|
+
var R = "m";
|
|
28347
|
+
var y = `${rD}8;;`;
|
|
28348
|
+
var V = (t) => `${v.values().next().value}${W}${t}${R}`;
|
|
28349
|
+
var z = (t) => `${v.values().next().value}${y}${t}${w}`;
|
|
28350
|
+
var ED = (t) => t.split(" ").map((u) => A(u));
|
|
28351
|
+
var _ = (t, u, F) => {
|
|
28352
|
+
const e = [...u];
|
|
28353
|
+
let s = false, i = false, D = A(T(t[t.length - 1]));
|
|
28354
|
+
for (const [C2, o] of e.entries()) {
|
|
28355
|
+
const E = A(o);
|
|
28356
|
+
if (D + E <= F ? t[t.length - 1] += o : (t.push(o), D = 0), v.has(o) && (s = true, i = e.slice(C2 + 1).join("").startsWith(y)), s) {
|
|
28357
|
+
i ? o === w && (s = false, i = false) : o === R && (s = false);
|
|
28358
|
+
continue;
|
|
28359
|
+
}
|
|
28360
|
+
D += E, D === F && C2 < e.length - 1 && (t.push(""), D = 0);
|
|
28361
|
+
}
|
|
28362
|
+
!D && t[t.length - 1].length > 0 && t.length > 1 && (t[t.length - 2] += t.pop());
|
|
28363
|
+
};
|
|
28364
|
+
var nD = (t) => {
|
|
28365
|
+
const u = t.split(" ");
|
|
28366
|
+
let F = u.length;
|
|
28367
|
+
for (;F > 0 && !(A(u[F - 1]) > 0); )
|
|
28368
|
+
F--;
|
|
28369
|
+
return F === u.length ? t : u.slice(0, F).join(" ") + u.slice(F).join("");
|
|
28370
|
+
};
|
|
28371
|
+
var oD = (t, u, F = {}) => {
|
|
28372
|
+
if (F.trim !== false && t.trim() === "")
|
|
28373
|
+
return "";
|
|
28374
|
+
let e = "", s, i;
|
|
28375
|
+
const D = ED(t);
|
|
28376
|
+
let C2 = [""];
|
|
28377
|
+
for (const [E, a] of t.split(" ").entries()) {
|
|
28378
|
+
F.trim !== false && (C2[C2.length - 1] = C2[C2.length - 1].trimStart());
|
|
28379
|
+
let n = A(C2[C2.length - 1]);
|
|
28380
|
+
if (E !== 0 && (n >= u && (F.wordWrap === false || F.trim === false) && (C2.push(""), n = 0), (n > 0 || F.trim === false) && (C2[C2.length - 1] += " ", n++)), F.hard && D[E] > u) {
|
|
28381
|
+
const B = u - n, p = 1 + Math.floor((D[E] - B - 1) / u);
|
|
28382
|
+
Math.floor((D[E] - 1) / u) < p && C2.push(""), _(C2, a, u);
|
|
28383
|
+
continue;
|
|
28384
|
+
}
|
|
28385
|
+
if (n + D[E] > u && n > 0 && D[E] > 0) {
|
|
28386
|
+
if (F.wordWrap === false && n < u) {
|
|
28387
|
+
_(C2, a, u);
|
|
28388
|
+
continue;
|
|
28389
|
+
}
|
|
28390
|
+
C2.push("");
|
|
28391
|
+
}
|
|
28392
|
+
if (n + D[E] > u && F.wordWrap === false) {
|
|
28393
|
+
_(C2, a, u);
|
|
28394
|
+
continue;
|
|
28395
|
+
}
|
|
28396
|
+
C2[C2.length - 1] += a;
|
|
28397
|
+
}
|
|
28398
|
+
F.trim !== false && (C2 = C2.map((E) => nD(E)));
|
|
28399
|
+
const o = [...C2.join(`
|
|
28400
|
+
`)];
|
|
28401
|
+
for (const [E, a] of o.entries()) {
|
|
28402
|
+
if (e += a, v.has(a)) {
|
|
28403
|
+
const { groups: B } = new RegExp(`(?:\\${W}(?<code>\\d+)m|\\${y}(?<uri>.*)${w})`).exec(o.slice(E).join("")) || { groups: {} };
|
|
28404
|
+
if (B.code !== undefined) {
|
|
28405
|
+
const p = Number.parseFloat(B.code);
|
|
28406
|
+
s = p === CD ? undefined : p;
|
|
28407
|
+
} else
|
|
28408
|
+
B.uri !== undefined && (i = B.uri.length === 0 ? undefined : B.uri);
|
|
28409
|
+
}
|
|
28410
|
+
const n = iD.codes.get(Number(s));
|
|
28411
|
+
o[E + 1] === `
|
|
28412
|
+
` ? (i && (e += z("")), s && n && (e += V(n))) : a === `
|
|
28413
|
+
` && (s && n && (e += V(s)), i && (e += z(i)));
|
|
28414
|
+
}
|
|
28415
|
+
return e;
|
|
28416
|
+
};
|
|
28417
|
+
function G(t, u, F) {
|
|
28418
|
+
return String(t).normalize().replace(/\r\n/g, `
|
|
28419
|
+
`).split(`
|
|
28420
|
+
`).map((e) => oD(e, u, F)).join(`
|
|
28421
|
+
`);
|
|
28422
|
+
}
|
|
28423
|
+
var aD = ["up", "down", "left", "right", "space", "enter", "cancel"];
|
|
28424
|
+
var c = { actions: new Set(aD), aliases: new Map([["k", "up"], ["j", "down"], ["h", "left"], ["l", "right"], ["\x03", "cancel"], ["escape", "cancel"]]) };
|
|
28425
|
+
function k(t, u) {
|
|
28426
|
+
if (typeof t == "string")
|
|
28427
|
+
return c.aliases.get(t) === u;
|
|
28428
|
+
for (const F of t)
|
|
28429
|
+
if (F !== undefined && k(F, u))
|
|
28430
|
+
return true;
|
|
28431
|
+
return false;
|
|
28432
|
+
}
|
|
28433
|
+
function lD(t, u) {
|
|
28434
|
+
if (t === u)
|
|
28435
|
+
return;
|
|
28436
|
+
const F = t.split(`
|
|
28437
|
+
`), e = u.split(`
|
|
28438
|
+
`), s = [];
|
|
28439
|
+
for (let i = 0;i < Math.max(F.length, e.length); i++)
|
|
28440
|
+
F[i] !== e[i] && s.push(i);
|
|
28441
|
+
return s;
|
|
28442
|
+
}
|
|
28443
|
+
var xD = globalThis.process.platform.startsWith("win");
|
|
28444
|
+
var S = Symbol("clack:cancel");
|
|
28445
|
+
function BD(t) {
|
|
28446
|
+
return t === S;
|
|
28447
|
+
}
|
|
28448
|
+
function d(t, u) {
|
|
28449
|
+
const F = t;
|
|
28450
|
+
F.isTTY && F.setRawMode(u);
|
|
28451
|
+
}
|
|
28452
|
+
var AD = Object.defineProperty;
|
|
28453
|
+
var pD = (t, u, F) => (u in t) ? AD(t, u, { enumerable: true, configurable: true, writable: true, value: F }) : t[u] = F;
|
|
28454
|
+
var h = (t, u, F) => (pD(t, typeof u != "symbol" ? u + "" : u, F), F);
|
|
28455
|
+
|
|
28456
|
+
class x {
|
|
28457
|
+
constructor(u, F = true) {
|
|
28458
|
+
h(this, "input"), h(this, "output"), h(this, "_abortSignal"), h(this, "rl"), h(this, "opts"), h(this, "_render"), h(this, "_track", false), h(this, "_prevFrame", ""), h(this, "_subscribers", new Map), h(this, "_cursor", 0), h(this, "state", "initial"), h(this, "error", ""), h(this, "value");
|
|
28459
|
+
const { input: e = $, output: s = j, render: i, signal: D, ...C2 } = u;
|
|
28460
|
+
this.opts = C2, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = i.bind(this), this._track = F, this._abortSignal = D, this.input = e, this.output = s;
|
|
28461
|
+
}
|
|
28462
|
+
unsubscribe() {
|
|
28463
|
+
this._subscribers.clear();
|
|
28464
|
+
}
|
|
28465
|
+
setSubscriber(u, F) {
|
|
28466
|
+
const e = this._subscribers.get(u) ?? [];
|
|
28467
|
+
e.push(F), this._subscribers.set(u, e);
|
|
28468
|
+
}
|
|
28469
|
+
on(u, F) {
|
|
28470
|
+
this.setSubscriber(u, { cb: F });
|
|
28471
|
+
}
|
|
28472
|
+
once(u, F) {
|
|
28473
|
+
this.setSubscriber(u, { cb: F, once: true });
|
|
28474
|
+
}
|
|
28475
|
+
emit(u, ...F) {
|
|
28476
|
+
const e = this._subscribers.get(u) ?? [], s = [];
|
|
28477
|
+
for (const i of e)
|
|
28478
|
+
i.cb(...F), i.once && s.push(() => e.splice(e.indexOf(i), 1));
|
|
28479
|
+
for (const i of s)
|
|
28480
|
+
i();
|
|
28481
|
+
}
|
|
28482
|
+
prompt() {
|
|
28483
|
+
return new Promise((u, F) => {
|
|
28484
|
+
if (this._abortSignal) {
|
|
28485
|
+
if (this._abortSignal.aborted)
|
|
28486
|
+
return this.state = "cancel", this.close(), u(S);
|
|
28487
|
+
this._abortSignal.addEventListener("abort", () => {
|
|
28488
|
+
this.state = "cancel", this.close();
|
|
28489
|
+
}, { once: true });
|
|
28490
|
+
}
|
|
28491
|
+
const e = new U(0);
|
|
28492
|
+
e._write = (s, i, D) => {
|
|
28493
|
+
this._track && (this.value = this.rl?.line.replace(/\t/g, ""), this._cursor = this.rl?.cursor ?? 0, this.emit("value", this.value)), D();
|
|
28494
|
+
}, this.input.pipe(e), this.rl = M.createInterface({ input: this.input, output: e, tabSize: 2, prompt: "", escapeCodeTimeout: 50 }), M.emitKeypressEvents(this.input, this.rl), this.rl.prompt(), this.opts.initialValue !== undefined && this._track && this.rl.write(this.opts.initialValue), this.input.on("keypress", this.onKeypress), d(this.input, true), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
|
|
28495
|
+
this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), d(this.input, false), u(this.value);
|
|
28496
|
+
}), this.once("cancel", () => {
|
|
28497
|
+
this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), d(this.input, false), u(S);
|
|
28498
|
+
});
|
|
28499
|
+
});
|
|
28500
|
+
}
|
|
28501
|
+
onKeypress(u, F) {
|
|
28502
|
+
if (this.state === "error" && (this.state = "active"), F?.name && (!this._track && c.aliases.has(F.name) && this.emit("cursor", c.aliases.get(F.name)), c.actions.has(F.name) && this.emit("cursor", F.name)), u && (u.toLowerCase() === "y" || u.toLowerCase() === "n") && this.emit("confirm", u.toLowerCase() === "y"), u === "\t" && this.opts.placeholder && (this.value || (this.rl?.write(this.opts.placeholder), this.emit("value", this.opts.placeholder))), u && this.emit("key", u.toLowerCase()), F?.name === "return") {
|
|
28503
|
+
if (this.opts.validate) {
|
|
28504
|
+
const e = this.opts.validate(this.value);
|
|
28505
|
+
e && (this.error = e instanceof Error ? e.message : e, this.state = "error", this.rl?.write(this.value));
|
|
28506
|
+
}
|
|
28507
|
+
this.state !== "error" && (this.state = "submit");
|
|
28508
|
+
}
|
|
28509
|
+
k([u, F?.name, F?.sequence], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
|
|
28510
|
+
}
|
|
28511
|
+
close() {
|
|
28512
|
+
this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
|
|
28513
|
+
`), d(this.input, false), this.rl?.close(), this.rl = undefined, this.emit(`${this.state}`, this.value), this.unsubscribe();
|
|
28514
|
+
}
|
|
28515
|
+
restoreCursor() {
|
|
28516
|
+
const u = G(this._prevFrame, process.stdout.columns, { hard: true }).split(`
|
|
28517
|
+
`).length - 1;
|
|
28518
|
+
this.output.write(import_sisteransi.cursor.move(-999, u * -1));
|
|
28519
|
+
}
|
|
28520
|
+
render() {
|
|
28521
|
+
const u = G(this._render(this) ?? "", process.stdout.columns, { hard: true });
|
|
28522
|
+
if (u !== this._prevFrame) {
|
|
28523
|
+
if (this.state === "initial")
|
|
28524
|
+
this.output.write(import_sisteransi.cursor.hide);
|
|
28525
|
+
else {
|
|
28526
|
+
const F = lD(this._prevFrame, u);
|
|
28527
|
+
if (this.restoreCursor(), F && F?.length === 1) {
|
|
28528
|
+
const e = F[0];
|
|
28529
|
+
this.output.write(import_sisteransi.cursor.move(0, e)), this.output.write(import_sisteransi.erase.lines(1));
|
|
28530
|
+
const s = u.split(`
|
|
28531
|
+
`);
|
|
28532
|
+
this.output.write(s[e]), this._prevFrame = u, this.output.write(import_sisteransi.cursor.move(0, s.length - e - 1));
|
|
28533
|
+
return;
|
|
28534
|
+
}
|
|
28535
|
+
if (F && F?.length > 1) {
|
|
28536
|
+
const e = F[0];
|
|
28537
|
+
this.output.write(import_sisteransi.cursor.move(0, e)), this.output.write(import_sisteransi.erase.down());
|
|
28538
|
+
const s = u.split(`
|
|
28539
|
+
`).slice(e);
|
|
28540
|
+
this.output.write(s.join(`
|
|
28541
|
+
`)), this._prevFrame = u;
|
|
28542
|
+
return;
|
|
28543
|
+
}
|
|
28544
|
+
this.output.write(import_sisteransi.erase.down());
|
|
28545
|
+
}
|
|
28546
|
+
this.output.write(u), this.state === "initial" && (this.state = "active"), this._prevFrame = u;
|
|
28547
|
+
}
|
|
28548
|
+
}
|
|
28549
|
+
}
|
|
28550
|
+
|
|
28551
|
+
class fD extends x {
|
|
28552
|
+
get cursor() {
|
|
28553
|
+
return this.value ? 0 : 1;
|
|
28554
|
+
}
|
|
28555
|
+
get _value() {
|
|
28556
|
+
return this.cursor === 0;
|
|
28557
|
+
}
|
|
28558
|
+
constructor(u) {
|
|
28559
|
+
super(u, false), this.value = !!u.initialValue, this.on("value", () => {
|
|
28560
|
+
this.value = this._value;
|
|
28561
|
+
}), this.on("confirm", (F) => {
|
|
28562
|
+
this.output.write(import_sisteransi.cursor.move(0, -1)), this.value = F, this.state = "submit", this.close();
|
|
28563
|
+
}), this.on("cursor", () => {
|
|
28564
|
+
this.value = !this.value;
|
|
28565
|
+
});
|
|
28566
|
+
}
|
|
28567
|
+
}
|
|
28568
|
+
var SD = Object.defineProperty;
|
|
28569
|
+
var $D = (t, u, F) => (u in t) ? SD(t, u, { enumerable: true, configurable: true, writable: true, value: F }) : t[u] = F;
|
|
28570
|
+
var q = (t, u, F) => ($D(t, typeof u != "symbol" ? u + "" : u, F), F);
|
|
28571
|
+
|
|
28572
|
+
class jD extends x {
|
|
28573
|
+
constructor(u) {
|
|
28574
|
+
super(u, false), q(this, "options"), q(this, "cursor", 0), this.options = u.options, this.cursor = this.options.findIndex(({ value: F }) => F === u.initialValue), this.cursor === -1 && (this.cursor = 0), this.changeValue(), this.on("cursor", (F) => {
|
|
28575
|
+
switch (F) {
|
|
28576
|
+
case "left":
|
|
28577
|
+
case "up":
|
|
28578
|
+
this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
|
|
28579
|
+
break;
|
|
28580
|
+
case "down":
|
|
28581
|
+
case "right":
|
|
28582
|
+
this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
|
|
28583
|
+
break;
|
|
28584
|
+
}
|
|
28585
|
+
this.changeValue();
|
|
28586
|
+
});
|
|
28587
|
+
}
|
|
28588
|
+
get _value() {
|
|
28589
|
+
return this.options[this.cursor];
|
|
28590
|
+
}
|
|
28591
|
+
changeValue() {
|
|
28592
|
+
this.value = this._value.value;
|
|
28593
|
+
}
|
|
28594
|
+
}
|
|
28595
|
+
class PD extends x {
|
|
28596
|
+
get valueWithCursor() {
|
|
28597
|
+
if (this.state === "submit")
|
|
28598
|
+
return this.value;
|
|
28599
|
+
if (this.cursor >= this.value.length)
|
|
28600
|
+
return `${this.value}\u2588`;
|
|
28601
|
+
const u = this.value.slice(0, this.cursor), [F, ...e] = this.value.slice(this.cursor);
|
|
28602
|
+
return `${u}${import_picocolors.default.inverse(F)}${e.join("")}`;
|
|
28603
|
+
}
|
|
28604
|
+
get cursor() {
|
|
28605
|
+
return this._cursor;
|
|
28606
|
+
}
|
|
28607
|
+
constructor(u) {
|
|
28608
|
+
super(u), this.on("finalize", () => {
|
|
28609
|
+
this.value || (this.value = u.defaultValue);
|
|
28610
|
+
});
|
|
28611
|
+
}
|
|
28612
|
+
}
|
|
28613
|
+
|
|
28614
|
+
// ../../node_modules/.bun/@clack+prompts@0.9.1/node_modules/@clack/prompts/dist/index.mjs
|
|
28615
|
+
var import_picocolors2 = __toESM(require_picocolors(), 1);
|
|
28616
|
+
var import_sisteransi2 = __toESM(require_src(), 1);
|
|
28617
|
+
import p from "process";
|
|
28618
|
+
function X2() {
|
|
28619
|
+
return p.platform !== "win32" ? p.env.TERM !== "linux" : !!p.env.CI || !!p.env.WT_SESSION || !!p.env.TERMINUS_SUBLIME || p.env.ConEmuTask === "{cmd::Cmder}" || p.env.TERM_PROGRAM === "Terminus-Sublime" || p.env.TERM_PROGRAM === "vscode" || p.env.TERM === "xterm-256color" || p.env.TERM === "alacritty" || p.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
28620
|
+
}
|
|
28621
|
+
var E = X2();
|
|
28622
|
+
var u = (s, n) => E ? s : n;
|
|
28623
|
+
var ee = u("\u25C6", "*");
|
|
28624
|
+
var A2 = u("\u25A0", "x");
|
|
28625
|
+
var B = u("\u25B2", "x");
|
|
28626
|
+
var S2 = u("\u25C7", "o");
|
|
28627
|
+
var te = u("\u250C", "T");
|
|
28628
|
+
var a = u("\u2502", "|");
|
|
28629
|
+
var m2 = u("\u2514", "\u2014");
|
|
28630
|
+
var j2 = u("\u25CF", ">");
|
|
28631
|
+
var R2 = u("\u25CB", " ");
|
|
28632
|
+
var V2 = u("\u25FB", "[\u2022]");
|
|
28633
|
+
var M2 = u("\u25FC", "[+]");
|
|
28634
|
+
var G2 = u("\u25FB", "[ ]");
|
|
28635
|
+
var se = u("\u25AA", "\u2022");
|
|
28636
|
+
var N2 = u("\u2500", "-");
|
|
28637
|
+
var re = u("\u256E", "+");
|
|
28638
|
+
var ie = u("\u251C", "+");
|
|
28639
|
+
var ne = u("\u256F", "+");
|
|
28640
|
+
var ae = u("\u25CF", "\u2022");
|
|
28641
|
+
var oe = u("\u25C6", "*");
|
|
28642
|
+
var ce = u("\u25B2", "!");
|
|
28643
|
+
var le = u("\u25A0", "x");
|
|
28644
|
+
var y2 = (s) => {
|
|
28645
|
+
switch (s) {
|
|
28646
|
+
case "initial":
|
|
28647
|
+
case "active":
|
|
28648
|
+
return import_picocolors2.default.cyan(ee);
|
|
28649
|
+
case "cancel":
|
|
28650
|
+
return import_picocolors2.default.red(A2);
|
|
28651
|
+
case "error":
|
|
28652
|
+
return import_picocolors2.default.yellow(B);
|
|
28653
|
+
case "submit":
|
|
28654
|
+
return import_picocolors2.default.green(S2);
|
|
28655
|
+
}
|
|
28656
|
+
};
|
|
28657
|
+
var k2 = (s) => {
|
|
28658
|
+
const { cursor: n, options: t, style: i } = s, r2 = s.maxItems ?? Number.POSITIVE_INFINITY, c2 = Math.max(process.stdout.rows - 4, 0), o = Math.min(c2, Math.max(r2, 5));
|
|
28659
|
+
let l2 = 0;
|
|
28660
|
+
n >= l2 + o - 3 ? l2 = Math.max(Math.min(n - o + 3, t.length - o), 0) : n < l2 + 2 && (l2 = Math.max(n - 2, 0));
|
|
28661
|
+
const $2 = o < t.length && l2 > 0, d2 = o < t.length && l2 + o < t.length;
|
|
28662
|
+
return t.slice(l2, l2 + o).map((w2, b2, C2) => {
|
|
28663
|
+
const I2 = b2 === 0 && $2, x2 = b2 === C2.length - 1 && d2;
|
|
28664
|
+
return I2 || x2 ? import_picocolors2.default.dim("...") : i(w2, b2 + l2 === n);
|
|
28665
|
+
});
|
|
28666
|
+
};
|
|
28667
|
+
var ue = (s) => new PD({ validate: s.validate, placeholder: s.placeholder, defaultValue: s.defaultValue, initialValue: s.initialValue, render() {
|
|
28668
|
+
const n = `${import_picocolors2.default.gray(a)}
|
|
28669
|
+
${y2(this.state)} ${s.message}
|
|
28670
|
+
`, t = s.placeholder ? import_picocolors2.default.inverse(s.placeholder[0]) + import_picocolors2.default.dim(s.placeholder.slice(1)) : import_picocolors2.default.inverse(import_picocolors2.default.hidden("_")), i = this.value ? this.valueWithCursor : t;
|
|
28671
|
+
switch (this.state) {
|
|
28672
|
+
case "error":
|
|
28673
|
+
return `${n.trim()}
|
|
28674
|
+
${import_picocolors2.default.yellow(a)} ${i}
|
|
28675
|
+
${import_picocolors2.default.yellow(m2)} ${import_picocolors2.default.yellow(this.error)}
|
|
28676
|
+
`;
|
|
28677
|
+
case "submit":
|
|
28678
|
+
return `${n}${import_picocolors2.default.gray(a)} ${import_picocolors2.default.dim(this.value || s.placeholder)}`;
|
|
28679
|
+
case "cancel":
|
|
28680
|
+
return `${n}${import_picocolors2.default.gray(a)} ${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(this.value ?? ""))}${this.value?.trim() ? `
|
|
28681
|
+
${import_picocolors2.default.gray(a)}` : ""}`;
|
|
28682
|
+
default:
|
|
28683
|
+
return `${n}${import_picocolors2.default.cyan(a)} ${i}
|
|
28684
|
+
${import_picocolors2.default.cyan(m2)}
|
|
28685
|
+
`;
|
|
28686
|
+
}
|
|
28687
|
+
} }).prompt();
|
|
28688
|
+
var me = (s) => {
|
|
28689
|
+
const n = s.active ?? "Yes", t = s.inactive ?? "No";
|
|
28690
|
+
return new fD({ active: n, inactive: t, initialValue: s.initialValue ?? true, render() {
|
|
28691
|
+
const i = `${import_picocolors2.default.gray(a)}
|
|
28692
|
+
${y2(this.state)} ${s.message}
|
|
28693
|
+
`, r2 = this.value ? n : t;
|
|
28694
|
+
switch (this.state) {
|
|
28695
|
+
case "submit":
|
|
28696
|
+
return `${i}${import_picocolors2.default.gray(a)} ${import_picocolors2.default.dim(r2)}`;
|
|
28697
|
+
case "cancel":
|
|
28698
|
+
return `${i}${import_picocolors2.default.gray(a)} ${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(r2))}
|
|
28699
|
+
${import_picocolors2.default.gray(a)}`;
|
|
28700
|
+
default:
|
|
28701
|
+
return `${i}${import_picocolors2.default.cyan(a)} ${this.value ? `${import_picocolors2.default.green(j2)} ${n}` : `${import_picocolors2.default.dim(R2)} ${import_picocolors2.default.dim(n)}`} ${import_picocolors2.default.dim("/")} ${this.value ? `${import_picocolors2.default.dim(R2)} ${import_picocolors2.default.dim(t)}` : `${import_picocolors2.default.green(j2)} ${t}`}
|
|
28702
|
+
${import_picocolors2.default.cyan(m2)}
|
|
28703
|
+
`;
|
|
28704
|
+
}
|
|
28705
|
+
} }).prompt();
|
|
28706
|
+
};
|
|
28707
|
+
var de = (s) => {
|
|
28708
|
+
const n = (t, i) => {
|
|
28709
|
+
const r2 = t.label ?? String(t.value);
|
|
28710
|
+
switch (i) {
|
|
28711
|
+
case "selected":
|
|
28712
|
+
return `${import_picocolors2.default.dim(r2)}`;
|
|
28713
|
+
case "active":
|
|
28714
|
+
return `${import_picocolors2.default.green(j2)} ${r2} ${t.hint ? import_picocolors2.default.dim(`(${t.hint})`) : ""}`;
|
|
28715
|
+
case "cancelled":
|
|
28716
|
+
return `${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(r2))}`;
|
|
28717
|
+
default:
|
|
28718
|
+
return `${import_picocolors2.default.dim(R2)} ${import_picocolors2.default.dim(r2)}`;
|
|
28719
|
+
}
|
|
28720
|
+
};
|
|
28721
|
+
return new jD({ options: s.options, initialValue: s.initialValue, render() {
|
|
28722
|
+
const t = `${import_picocolors2.default.gray(a)}
|
|
28723
|
+
${y2(this.state)} ${s.message}
|
|
28724
|
+
`;
|
|
28725
|
+
switch (this.state) {
|
|
28726
|
+
case "submit":
|
|
28727
|
+
return `${t}${import_picocolors2.default.gray(a)} ${n(this.options[this.cursor], "selected")}`;
|
|
28728
|
+
case "cancel":
|
|
28729
|
+
return `${t}${import_picocolors2.default.gray(a)} ${n(this.options[this.cursor], "cancelled")}
|
|
28730
|
+
${import_picocolors2.default.gray(a)}`;
|
|
28731
|
+
default:
|
|
28732
|
+
return `${t}${import_picocolors2.default.cyan(a)} ${k2({ cursor: this.cursor, options: this.options, maxItems: s.maxItems, style: (i, r2) => n(i, r2 ? "active" : "inactive") }).join(`
|
|
28733
|
+
${import_picocolors2.default.cyan(a)} `)}
|
|
28734
|
+
${import_picocolors2.default.cyan(m2)}
|
|
28735
|
+
`;
|
|
28736
|
+
}
|
|
28737
|
+
} }).prompt();
|
|
28738
|
+
};
|
|
28739
|
+
var ve = (s = "") => {
|
|
28740
|
+
process.stdout.write(`${import_picocolors2.default.gray(m2)} ${import_picocolors2.default.red(s)}
|
|
28741
|
+
|
|
28742
|
+
`);
|
|
28743
|
+
};
|
|
28744
|
+
var we = (s = "") => {
|
|
28745
|
+
process.stdout.write(`${import_picocolors2.default.gray(te)} ${s}
|
|
28746
|
+
`);
|
|
28747
|
+
};
|
|
28748
|
+
var fe = (s = "") => {
|
|
28749
|
+
process.stdout.write(`${import_picocolors2.default.gray(a)}
|
|
28750
|
+
${import_picocolors2.default.gray(m2)} ${s}
|
|
28751
|
+
|
|
28752
|
+
`);
|
|
28753
|
+
};
|
|
28754
|
+
|
|
28755
|
+
// src/deploy/survey.ts
|
|
28756
|
+
async function runSurvey() {
|
|
28757
|
+
we("arc platform deploy \u2014 initial setup");
|
|
28758
|
+
const mode = await de({
|
|
28759
|
+
message: "How should deploy reach the target server?",
|
|
28760
|
+
options: [
|
|
28761
|
+
{
|
|
28762
|
+
value: "existing",
|
|
28763
|
+
label: "Use an existing server (I have SSH access)"
|
|
28764
|
+
},
|
|
28765
|
+
{
|
|
28766
|
+
value: "provision",
|
|
28767
|
+
label: "Provision a new server via Terraform (Hetzner Cloud)"
|
|
28768
|
+
}
|
|
28769
|
+
],
|
|
28770
|
+
initialValue: "existing"
|
|
28771
|
+
});
|
|
28772
|
+
if (BD(mode))
|
|
28773
|
+
cancel();
|
|
28774
|
+
const host = await ue({
|
|
28775
|
+
message: mode === "provision" ? "Alias for the server (leave blank \u2014 will be filled after terraform apply)" : "SSH host (IP or alias from ~/.ssh/config)",
|
|
28776
|
+
placeholder: mode === "provision" ? "auto" : "example.com or 1.2.3.4",
|
|
28777
|
+
validate: (v2) => {
|
|
28778
|
+
if (mode === "provision")
|
|
28779
|
+
return;
|
|
28780
|
+
if (!v2 || v2.length === 0)
|
|
28781
|
+
return "Host is required";
|
|
28782
|
+
return;
|
|
28783
|
+
}
|
|
28784
|
+
});
|
|
28785
|
+
if (BD(host))
|
|
28786
|
+
cancel();
|
|
28787
|
+
const user = await ue({
|
|
28788
|
+
message: "SSH user",
|
|
28789
|
+
initialValue: "deploy",
|
|
28790
|
+
validate: (v2) => /^[a-z_][a-z0-9_-]*$/.test(v2) ? undefined : "Invalid username"
|
|
28791
|
+
});
|
|
28792
|
+
if (BD(user))
|
|
28793
|
+
cancel();
|
|
28794
|
+
const portRaw = await ue({
|
|
28795
|
+
message: "SSH port",
|
|
28796
|
+
initialValue: "22",
|
|
28797
|
+
validate: (v2) => {
|
|
28798
|
+
const n = Number(v2);
|
|
28799
|
+
return Number.isInteger(n) && n > 0 && n < 65536 ? undefined : "Must be a port number";
|
|
28800
|
+
}
|
|
28801
|
+
});
|
|
28802
|
+
if (BD(portRaw))
|
|
28803
|
+
cancel();
|
|
28804
|
+
const port = Number(portRaw);
|
|
28805
|
+
const envs = {};
|
|
28806
|
+
let more = true;
|
|
28807
|
+
while (more) {
|
|
28808
|
+
const name = await ue({
|
|
28809
|
+
message: `Environment name (lowercase, e.g. "prod", "staging")`,
|
|
28810
|
+
initialValue: Object.keys(envs).length === 0 ? "prod" : "staging",
|
|
28811
|
+
validate: (v2) => {
|
|
28812
|
+
if (!/^[a-z][a-z0-9-]*$/.test(v2))
|
|
28813
|
+
return "Must match [a-z][a-z0-9-]*";
|
|
28814
|
+
if (envs[v2])
|
|
28815
|
+
return "Already defined";
|
|
28816
|
+
return;
|
|
28817
|
+
}
|
|
28818
|
+
});
|
|
28819
|
+
if (BD(name))
|
|
28820
|
+
cancel();
|
|
28821
|
+
const domain = await ue({
|
|
28822
|
+
message: `Domain for "${name}" (Caddy will route by Host header)`,
|
|
28823
|
+
placeholder: `${name === "prod" ? "app" : name}.example.com`,
|
|
28824
|
+
validate: (v2) => /^[a-z0-9.-]+\.[a-z]{2,}$/i.test(v2) ? undefined : "Expected a domain like app.example.com"
|
|
28825
|
+
});
|
|
28826
|
+
if (BD(domain))
|
|
28827
|
+
cancel();
|
|
28828
|
+
envs[name] = { domain };
|
|
28829
|
+
const addAnother = await me({
|
|
28830
|
+
message: "Add another environment?",
|
|
28831
|
+
initialValue: false
|
|
28832
|
+
});
|
|
28833
|
+
if (BD(addAnother))
|
|
28834
|
+
cancel();
|
|
28835
|
+
more = addAnother;
|
|
28836
|
+
}
|
|
28837
|
+
let provision;
|
|
28838
|
+
if (mode === "provision") {
|
|
28839
|
+
const tokenEnv = await ue({
|
|
28840
|
+
message: "Name of env var holding your Hetzner Cloud API token",
|
|
28841
|
+
initialValue: "HCLOUD_TOKEN",
|
|
28842
|
+
validate: (v2) => /^[A-Z_][A-Z0-9_]*$/.test(v2) ? undefined : "Must be SCREAMING_SNAKE_CASE"
|
|
28843
|
+
});
|
|
28844
|
+
if (BD(tokenEnv))
|
|
28845
|
+
cancel();
|
|
28846
|
+
const serverType = await ue({
|
|
28847
|
+
message: "Hetzner server type",
|
|
28848
|
+
initialValue: "cx32"
|
|
28849
|
+
});
|
|
28850
|
+
if (BD(serverType))
|
|
28851
|
+
cancel();
|
|
28852
|
+
const location = await ue({
|
|
28853
|
+
message: "Hetzner datacenter location",
|
|
28854
|
+
initialValue: "nbg1"
|
|
28855
|
+
});
|
|
28856
|
+
if (BD(location))
|
|
28857
|
+
cancel();
|
|
28858
|
+
const terraform = {
|
|
28859
|
+
provider: "hcloud",
|
|
28860
|
+
serverType,
|
|
28861
|
+
location,
|
|
28862
|
+
image: "ubuntu-22.04",
|
|
28863
|
+
tokenEnv
|
|
28864
|
+
};
|
|
28865
|
+
provision = { terraform };
|
|
28866
|
+
}
|
|
28867
|
+
const email = await ue({
|
|
28868
|
+
message: `Email for Let's Encrypt (use "internal" for self-signed certs)`,
|
|
28869
|
+
placeholder: "admin@example.com",
|
|
28870
|
+
validate: (v2) => {
|
|
28871
|
+
if (v2 === "internal")
|
|
28872
|
+
return;
|
|
28873
|
+
if (!/^\S+@\S+\.\S+$/.test(v2))
|
|
28874
|
+
return "Expected an email or 'internal'";
|
|
28875
|
+
return;
|
|
28876
|
+
}
|
|
28877
|
+
});
|
|
28878
|
+
if (BD(email))
|
|
28879
|
+
cancel();
|
|
28880
|
+
fe("Configuration ready \u2014 writing deploy.arc.json");
|
|
28881
|
+
return {
|
|
28882
|
+
target: {
|
|
28883
|
+
host: host || "PENDING_TERRAFORM",
|
|
28884
|
+
user,
|
|
28885
|
+
port,
|
|
28886
|
+
remoteDir: "/opt/arc"
|
|
28887
|
+
},
|
|
28888
|
+
envs,
|
|
28889
|
+
caddy: { email },
|
|
28890
|
+
provision
|
|
28891
|
+
};
|
|
28892
|
+
}
|
|
28893
|
+
function cancel() {
|
|
28894
|
+
ve("Cancelled.");
|
|
28895
|
+
process.exit(0);
|
|
28896
|
+
}
|
|
28897
|
+
|
|
28898
|
+
// src/commands/platform-deploy.ts
|
|
28899
|
+
async function platformDeploy(envArg, options = {}) {
|
|
28900
|
+
const ws = resolveWorkspace();
|
|
28901
|
+
let cfg;
|
|
28902
|
+
if (!deployConfigExists(ws.rootDir)) {
|
|
28903
|
+
log2("No deploy.arc.json found \u2014 launching survey.");
|
|
28904
|
+
cfg = await runSurvey();
|
|
28905
|
+
saveDeployConfig(ws.rootDir, cfg);
|
|
28906
|
+
ok("Saved deploy.arc.json");
|
|
28907
|
+
}
|
|
28908
|
+
cfg = loadDeployConfig(ws.rootDir);
|
|
28909
|
+
const targetEnvs = envArg ? envArg in cfg.envs ? [envArg] : (() => {
|
|
28910
|
+
err(`Unknown env "${envArg}". Known: ${Object.keys(cfg.envs).join(", ")}`);
|
|
28911
|
+
process.exit(1);
|
|
28912
|
+
})() : Object.keys(cfg.envs);
|
|
28913
|
+
const manifestPath = join13(ws.modulesDir, "manifest.json");
|
|
28914
|
+
const needBuild = options.rebuild || !existsSync10(manifestPath);
|
|
28915
|
+
if (needBuild && !options.skipBuild) {
|
|
28916
|
+
log2("Building platform...");
|
|
28917
|
+
await buildAll(ws);
|
|
28918
|
+
ok("Build complete");
|
|
28919
|
+
} else if (!existsSync10(manifestPath)) {
|
|
28920
|
+
err("No build found and --skip-build was set.");
|
|
28921
|
+
process.exit(1);
|
|
28922
|
+
}
|
|
28923
|
+
log2("Inspecting remote server...");
|
|
28924
|
+
const state = await detectRemoteState(cfg);
|
|
28925
|
+
log2(`Remote state: ${state.kind}`);
|
|
28926
|
+
const cliVersion = readCliVersion();
|
|
28927
|
+
const configHash = await hashDeployConfig(ws.rootDir);
|
|
28928
|
+
if (state.kind !== "ready") {
|
|
28929
|
+
await bootstrap({
|
|
28930
|
+
cfg,
|
|
28931
|
+
rootDir: ws.rootDir,
|
|
28932
|
+
state,
|
|
28933
|
+
cliVersion,
|
|
28934
|
+
configHash
|
|
28935
|
+
});
|
|
28936
|
+
}
|
|
28937
|
+
for (const env2 of targetEnvs) {
|
|
28938
|
+
log2(`Syncing env "${env2}"...`);
|
|
28939
|
+
const outcome = await syncEnv({
|
|
28940
|
+
cfg,
|
|
28941
|
+
env: env2,
|
|
28942
|
+
ws,
|
|
28943
|
+
projectDir: ws.rootDir
|
|
28944
|
+
});
|
|
28945
|
+
if (outcome.changedModules.length === 0 && !outcome.shellChanged && !outcome.stylesChanged) {
|
|
28946
|
+
ok(`${env2}: already up to date`);
|
|
28947
|
+
} else {
|
|
28948
|
+
const parts = [];
|
|
28949
|
+
if (outcome.changedModules.length > 0) {
|
|
28950
|
+
parts.push(`${outcome.changedModules.length} module(s): ${outcome.changedModules.join(", ")}`);
|
|
28951
|
+
}
|
|
28952
|
+
if (outcome.shellChanged)
|
|
28953
|
+
parts.push("shell");
|
|
28954
|
+
if (outcome.stylesChanged)
|
|
28955
|
+
parts.push("styles");
|
|
28956
|
+
ok(`${env2}: updated ${parts.join(", ")}`);
|
|
28957
|
+
}
|
|
28958
|
+
}
|
|
28959
|
+
}
|
|
28960
|
+
function readCliVersion() {
|
|
28961
|
+
try {
|
|
28962
|
+
const pkgPath = join13(import.meta.dir, "..", "..", "package.json");
|
|
28963
|
+
const pkg = JSON.parse(readFileSync9(pkgPath, "utf-8"));
|
|
28964
|
+
return pkg.version ?? "unknown";
|
|
28965
|
+
} catch {
|
|
28966
|
+
return "unknown";
|
|
28967
|
+
}
|
|
28968
|
+
}
|
|
28969
|
+
async function hashDeployConfig(rootDir) {
|
|
28970
|
+
const p2 = join13(rootDir, "deploy.arc.json");
|
|
28971
|
+
const content = readFileSync9(p2);
|
|
28972
|
+
const hasher = new Bun.CryptoHasher("sha256");
|
|
28973
|
+
hasher.update(content);
|
|
28974
|
+
return hasher.digest("hex").slice(0, 16);
|
|
28975
|
+
}
|
|
28976
|
+
|
|
28977
|
+
// src/commands/platform-dev.ts
|
|
28978
|
+
import { existsSync as existsSync13, watch } from "fs";
|
|
28979
|
+
import { join as join16 } from "path";
|
|
26866
28980
|
|
|
26867
28981
|
// ../host/src/create-server.ts
|
|
26868
28982
|
var import_jsonwebtoken = __toESM(require_jsonwebtoken(), 1);
|
|
@@ -26909,7 +29023,7 @@ class ConnectionManager {
|
|
|
26909
29023
|
const client = this.clients.get(clientId);
|
|
26910
29024
|
if (!client)
|
|
26911
29025
|
return [];
|
|
26912
|
-
return Array.from(client.scopeTokens.values()).map((
|
|
29026
|
+
return Array.from(client.scopeTokens.values()).map((v2) => v2.decoded);
|
|
26913
29027
|
}
|
|
26914
29028
|
updateLastSyncedEventId(clientId, hostEventId) {
|
|
26915
29029
|
const client = this.clients.get(clientId);
|
|
@@ -27123,19 +29237,22 @@ class ContextHandler {
|
|
|
27123
29237
|
continue;
|
|
27124
29238
|
}
|
|
27125
29239
|
const hostId = `host_${++this.hostEventIdCounter}_${Date.now()}`;
|
|
29240
|
+
const eventAuthContext = event.authContext ?? null;
|
|
27126
29241
|
const syncableEvent = {
|
|
27127
29242
|
localId: event.localId,
|
|
27128
29243
|
hostId,
|
|
27129
29244
|
type: event.type,
|
|
27130
29245
|
payload: event.payload,
|
|
27131
29246
|
createdAt: event.createdAt,
|
|
27132
|
-
clientId
|
|
29247
|
+
clientId,
|
|
29248
|
+
authContext: eventAuthContext
|
|
27133
29249
|
};
|
|
27134
29250
|
await this.eventPublisher.publish({
|
|
27135
29251
|
id: hostId,
|
|
27136
29252
|
type: event.type,
|
|
27137
29253
|
payload: event.payload,
|
|
27138
|
-
createdAt: new Date(event.createdAt)
|
|
29254
|
+
createdAt: new Date(event.createdAt),
|
|
29255
|
+
authContext: eventAuthContext
|
|
27139
29256
|
});
|
|
27140
29257
|
persistedEvents.push(syncableEvent);
|
|
27141
29258
|
}
|
|
@@ -27148,28 +29265,29 @@ class ContextHandler {
|
|
|
27148
29265
|
if (lastHostEventId) {
|
|
27149
29266
|
const parts = lastHostEventId.split("_");
|
|
27150
29267
|
const lastTimestamp = parts.length >= 3 ? parseInt(parts[2], 10) : 0;
|
|
27151
|
-
filteredEvents = allEvents.filter((
|
|
27152
|
-
if (!
|
|
29268
|
+
filteredEvents = allEvents.filter((e2) => {
|
|
29269
|
+
if (!e2._id.startsWith("host_"))
|
|
27153
29270
|
return false;
|
|
27154
|
-
const eventParts =
|
|
29271
|
+
const eventParts = e2._id.split("_");
|
|
27155
29272
|
const eventTimestamp = eventParts.length >= 3 ? parseInt(eventParts[2], 10) : 0;
|
|
27156
29273
|
return eventTimestamp > lastTimestamp;
|
|
27157
29274
|
});
|
|
27158
29275
|
} else {
|
|
27159
|
-
filteredEvents = allEvents.filter((
|
|
29276
|
+
filteredEvents = allEvents.filter((e2) => e2._id.startsWith("host_"));
|
|
27160
29277
|
}
|
|
27161
|
-
filteredEvents.sort((
|
|
27162
|
-
const aTimestamp = parseInt(
|
|
27163
|
-
const bTimestamp = parseInt(
|
|
29278
|
+
filteredEvents.sort((a2, b2) => {
|
|
29279
|
+
const aTimestamp = parseInt(a2._id.split("_")[2] || "0", 10);
|
|
29280
|
+
const bTimestamp = parseInt(b2._id.split("_")[2] || "0", 10);
|
|
27164
29281
|
return aTimestamp - bTimestamp;
|
|
27165
29282
|
});
|
|
27166
|
-
const syncableEvents = filteredEvents.map((
|
|
27167
|
-
localId:
|
|
27168
|
-
hostId:
|
|
27169
|
-
type:
|
|
27170
|
-
payload: typeof
|
|
27171
|
-
createdAt:
|
|
27172
|
-
clientId: "host"
|
|
29283
|
+
const syncableEvents = filteredEvents.map((e2) => ({
|
|
29284
|
+
localId: e2._id,
|
|
29285
|
+
hostId: e2._id,
|
|
29286
|
+
type: e2.type,
|
|
29287
|
+
payload: typeof e2.payload === "string" ? JSON.parse(e2.payload) : e2.payload,
|
|
29288
|
+
createdAt: e2.createdAt,
|
|
29289
|
+
clientId: "host",
|
|
29290
|
+
authContext: typeof e2.authContext === "string" ? JSON.parse(e2.authContext) : e2.authContext ?? null
|
|
27173
29291
|
}));
|
|
27174
29292
|
return filterEventsForToken(token, syncableEvents, this.eventDefinitions);
|
|
27175
29293
|
}
|
|
@@ -27188,46 +29306,46 @@ class ContextHandler {
|
|
|
27188
29306
|
}
|
|
27189
29307
|
|
|
27190
29308
|
// ../../node_modules/.bun/croner@9.1.0/node_modules/croner/dist/croner.js
|
|
27191
|
-
function
|
|
27192
|
-
return
|
|
29309
|
+
function h2(n, t, e2, r2, s, i, a2, l2) {
|
|
29310
|
+
return h2.fromTZ(h2.tp(n, t, e2, r2, s, i, a2), l2);
|
|
27193
29311
|
}
|
|
27194
|
-
|
|
27195
|
-
|
|
27196
|
-
let
|
|
27197
|
-
if (i -
|
|
29312
|
+
h2.fromTZISO = (n, t, e2) => h2.fromTZ(k3(n, t), e2);
|
|
29313
|
+
h2.fromTZ = function(n, t) {
|
|
29314
|
+
let e2 = new Date(Date.UTC(n.y, n.m - 1, n.d, n.h, n.i, n.s)), r2 = D(n.tz, e2), s = new Date(e2.getTime() - r2), i = D(n.tz, s);
|
|
29315
|
+
if (i - r2 === 0)
|
|
27198
29316
|
return s;
|
|
27199
29317
|
{
|
|
27200
|
-
let
|
|
27201
|
-
if (
|
|
27202
|
-
return
|
|
27203
|
-
if (!t &&
|
|
27204
|
-
return
|
|
29318
|
+
let a2 = new Date(e2.getTime() - i), l2 = D(n.tz, a2);
|
|
29319
|
+
if (l2 - i === 0)
|
|
29320
|
+
return a2;
|
|
29321
|
+
if (!t && l2 - i > 0)
|
|
29322
|
+
return a2;
|
|
27205
29323
|
if (t)
|
|
27206
29324
|
throw new Error("Invalid date passed to fromTZ()");
|
|
27207
29325
|
return s;
|
|
27208
29326
|
}
|
|
27209
29327
|
};
|
|
27210
|
-
|
|
27211
|
-
let
|
|
27212
|
-
return { y:
|
|
29328
|
+
h2.toTZ = function(n, t) {
|
|
29329
|
+
let e2 = n.toLocaleString("en-US", { timeZone: t }).replace(/[\u202f]/, " "), r2 = new Date(e2);
|
|
29330
|
+
return { y: r2.getFullYear(), m: r2.getMonth() + 1, d: r2.getDate(), h: r2.getHours(), i: r2.getMinutes(), s: r2.getSeconds(), tz: t };
|
|
27213
29331
|
};
|
|
27214
|
-
|
|
29332
|
+
h2.tp = (n, t, e2, r2, s, i, a2) => ({ y: n, m: t, d: e2, h: r2, i: s, s: i, tz: a2 });
|
|
27215
29333
|
function D(n, t = new Date) {
|
|
27216
|
-
let
|
|
27217
|
-
return Date.parse(`${
|
|
29334
|
+
let e2 = t.toLocaleString("en-US", { timeZone: n, timeZoneName: "shortOffset" }).split(" ").slice(-1)[0], r2 = t.toLocaleString("en-US").replace(/[\u202f]/, " ");
|
|
29335
|
+
return Date.parse(`${r2} GMT`) - Date.parse(`${r2} ${e2}`);
|
|
27218
29336
|
}
|
|
27219
|
-
function
|
|
27220
|
-
let
|
|
27221
|
-
if (isNaN(
|
|
29337
|
+
function k3(n, t) {
|
|
29338
|
+
let e2 = new Date(Date.parse(n));
|
|
29339
|
+
if (isNaN(e2))
|
|
27222
29340
|
throw new Error("minitz: Invalid ISO8601 passed to parser.");
|
|
27223
|
-
let
|
|
27224
|
-
return n.includes("Z") ||
|
|
27225
|
-
}
|
|
27226
|
-
|
|
27227
|
-
var
|
|
27228
|
-
var
|
|
27229
|
-
var
|
|
27230
|
-
var
|
|
29341
|
+
let r2 = n.substring(9);
|
|
29342
|
+
return n.includes("Z") || r2.includes("-") || r2.includes("+") ? h2.tp(e2.getUTCFullYear(), e2.getUTCMonth() + 1, e2.getUTCDate(), e2.getUTCHours(), e2.getUTCMinutes(), e2.getUTCSeconds(), "Etc/UTC") : h2.tp(e2.getFullYear(), e2.getMonth() + 1, e2.getDate(), e2.getHours(), e2.getMinutes(), e2.getSeconds(), t);
|
|
29343
|
+
}
|
|
29344
|
+
h2.minitz = h2;
|
|
29345
|
+
var b2 = 32;
|
|
29346
|
+
var p2 = 31 | b2;
|
|
29347
|
+
var v2 = [1, 2, 4, 8, 16];
|
|
29348
|
+
var d2 = class {
|
|
27231
29349
|
pattern;
|
|
27232
29350
|
timezone;
|
|
27233
29351
|
second;
|
|
@@ -27239,8 +29357,8 @@ var d = class {
|
|
|
27239
29357
|
lastDayOfMonth;
|
|
27240
29358
|
starDOM;
|
|
27241
29359
|
starDOW;
|
|
27242
|
-
constructor(t,
|
|
27243
|
-
this.pattern = t, this.timezone =
|
|
29360
|
+
constructor(t, e2) {
|
|
29361
|
+
this.pattern = t, this.timezone = e2, this.second = Array(60).fill(0), this.minute = Array(60).fill(0), this.hour = Array(24).fill(0), this.day = Array(31).fill(0), this.month = Array(12).fill(0), this.dayOfWeek = Array(7).fill(0), this.lastDayOfMonth = false, this.starDOM = false, this.starDOW = false, this.parse();
|
|
27244
29362
|
}
|
|
27245
29363
|
parse() {
|
|
27246
29364
|
if (!(typeof this.pattern == "string" || this.pattern instanceof String))
|
|
@@ -27250,116 +29368,116 @@ var d = class {
|
|
|
27250
29368
|
if (t.length < 5 || t.length > 6)
|
|
27251
29369
|
throw new TypeError("CronPattern: invalid configuration format ('" + this.pattern + "'), exactly five or six space separated parts are required.");
|
|
27252
29370
|
if (t.length === 5 && t.unshift("0"), t[3].indexOf("L") >= 0 && (t[3] = t[3].replace("L", ""), this.lastDayOfMonth = true), t[3] == "*" && (this.starDOM = true), t[4].length >= 3 && (t[4] = this.replaceAlphaMonths(t[4])), t[5].length >= 3 && (t[5] = this.replaceAlphaDays(t[5])), t[5] == "*" && (this.starDOW = true), this.pattern.indexOf("?") >= 0) {
|
|
27253
|
-
let
|
|
27254
|
-
t[0] = t[0].replace("?",
|
|
29371
|
+
let e2 = new f(new Date, this.timezone).getDate(true);
|
|
29372
|
+
t[0] = t[0].replace("?", e2.getSeconds().toString()), t[1] = t[1].replace("?", e2.getMinutes().toString()), t[2] = t[2].replace("?", e2.getHours().toString()), this.starDOM || (t[3] = t[3].replace("?", e2.getDate().toString())), t[4] = t[4].replace("?", (e2.getMonth() + 1).toString()), this.starDOW || (t[5] = t[5].replace("?", e2.getDay().toString()));
|
|
27255
29373
|
}
|
|
27256
|
-
this.throwAtIllegalCharacters(t), this.partToArray("second", t[0], 0, 1), this.partToArray("minute", t[1], 0, 1), this.partToArray("hour", t[2], 0, 1), this.partToArray("day", t[3], -1, 1), this.partToArray("month", t[4], -1, 1), this.partToArray("dayOfWeek", t[5], 0,
|
|
29374
|
+
this.throwAtIllegalCharacters(t), this.partToArray("second", t[0], 0, 1), this.partToArray("minute", t[1], 0, 1), this.partToArray("hour", t[2], 0, 1), this.partToArray("day", t[3], -1, 1), this.partToArray("month", t[4], -1, 1), this.partToArray("dayOfWeek", t[5], 0, p2), this.dayOfWeek[7] && (this.dayOfWeek[0] = this.dayOfWeek[7]);
|
|
27257
29375
|
}
|
|
27258
|
-
partToArray(t,
|
|
27259
|
-
let i = this[t],
|
|
27260
|
-
if (
|
|
27261
|
-
throw new TypeError("CronPattern: configuration entry " + t + " (" +
|
|
27262
|
-
if (
|
|
29376
|
+
partToArray(t, e2, r2, s) {
|
|
29377
|
+
let i = this[t], a2 = t === "day" && this.lastDayOfMonth;
|
|
29378
|
+
if (e2 === "" && !a2)
|
|
29379
|
+
throw new TypeError("CronPattern: configuration entry " + t + " (" + e2 + ") is empty, check for trailing spaces.");
|
|
29380
|
+
if (e2 === "*")
|
|
27263
29381
|
return i.fill(s);
|
|
27264
|
-
let
|
|
27265
|
-
if (
|
|
27266
|
-
for (let o = 0;o <
|
|
27267
|
-
this.partToArray(t,
|
|
29382
|
+
let l2 = e2.split(",");
|
|
29383
|
+
if (l2.length > 1)
|
|
29384
|
+
for (let o = 0;o < l2.length; o++)
|
|
29385
|
+
this.partToArray(t, l2[o], r2, s);
|
|
27268
29386
|
else
|
|
27269
|
-
|
|
29387
|
+
e2.indexOf("-") !== -1 && e2.indexOf("/") !== -1 ? this.handleRangeWithStepping(e2, t, r2, s) : e2.indexOf("-") !== -1 ? this.handleRange(e2, t, r2, s) : e2.indexOf("/") !== -1 ? this.handleStepping(e2, t, r2, s) : e2 !== "" && this.handleNumber(e2, t, r2, s);
|
|
27270
29388
|
}
|
|
27271
29389
|
throwAtIllegalCharacters(t) {
|
|
27272
|
-
for (let
|
|
27273
|
-
if ((
|
|
27274
|
-
throw new TypeError("CronPattern: configuration entry " +
|
|
29390
|
+
for (let e2 = 0;e2 < t.length; e2++)
|
|
29391
|
+
if ((e2 === 5 ? /[^/*0-9,\-#L]+/ : /[^/*0-9,-]+/).test(t[e2]))
|
|
29392
|
+
throw new TypeError("CronPattern: configuration entry " + e2 + " (" + t[e2] + ") contains illegal characters.");
|
|
27275
29393
|
}
|
|
27276
|
-
handleNumber(t,
|
|
27277
|
-
let i = this.extractNth(t,
|
|
27278
|
-
if (isNaN(
|
|
27279
|
-
throw new TypeError("CronPattern: " +
|
|
27280
|
-
this.setPart(
|
|
29394
|
+
handleNumber(t, e2, r2, s) {
|
|
29395
|
+
let i = this.extractNth(t, e2), a2 = parseInt(i[0], 10) + r2;
|
|
29396
|
+
if (isNaN(a2))
|
|
29397
|
+
throw new TypeError("CronPattern: " + e2 + " is not a number: '" + t + "'");
|
|
29398
|
+
this.setPart(e2, a2, i[1] || s);
|
|
27281
29399
|
}
|
|
27282
|
-
setPart(t,
|
|
29400
|
+
setPart(t, e2, r2) {
|
|
27283
29401
|
if (!Object.prototype.hasOwnProperty.call(this, t))
|
|
27284
29402
|
throw new TypeError("CronPattern: Invalid part specified: " + t);
|
|
27285
29403
|
if (t === "dayOfWeek") {
|
|
27286
|
-
if (
|
|
27287
|
-
throw new RangeError("CronPattern: Invalid value for dayOfWeek: " +
|
|
27288
|
-
this.setNthWeekdayOfMonth(
|
|
29404
|
+
if (e2 === 7 && (e2 = 0), e2 < 0 || e2 > 6)
|
|
29405
|
+
throw new RangeError("CronPattern: Invalid value for dayOfWeek: " + e2);
|
|
29406
|
+
this.setNthWeekdayOfMonth(e2, r2);
|
|
27289
29407
|
return;
|
|
27290
29408
|
}
|
|
27291
29409
|
if (t === "second" || t === "minute") {
|
|
27292
|
-
if (
|
|
27293
|
-
throw new RangeError("CronPattern: Invalid value for " + t + ": " +
|
|
29410
|
+
if (e2 < 0 || e2 >= 60)
|
|
29411
|
+
throw new RangeError("CronPattern: Invalid value for " + t + ": " + e2);
|
|
27294
29412
|
} else if (t === "hour") {
|
|
27295
|
-
if (
|
|
27296
|
-
throw new RangeError("CronPattern: Invalid value for " + t + ": " +
|
|
29413
|
+
if (e2 < 0 || e2 >= 24)
|
|
29414
|
+
throw new RangeError("CronPattern: Invalid value for " + t + ": " + e2);
|
|
27297
29415
|
} else if (t === "day") {
|
|
27298
|
-
if (
|
|
27299
|
-
throw new RangeError("CronPattern: Invalid value for " + t + ": " +
|
|
27300
|
-
} else if (t === "month" && (
|
|
27301
|
-
throw new RangeError("CronPattern: Invalid value for " + t + ": " +
|
|
27302
|
-
this[t][
|
|
27303
|
-
}
|
|
27304
|
-
handleRangeWithStepping(t,
|
|
27305
|
-
let i = this.extractNth(t,
|
|
27306
|
-
if (
|
|
29416
|
+
if (e2 < 0 || e2 >= 31)
|
|
29417
|
+
throw new RangeError("CronPattern: Invalid value for " + t + ": " + e2);
|
|
29418
|
+
} else if (t === "month" && (e2 < 0 || e2 >= 12))
|
|
29419
|
+
throw new RangeError("CronPattern: Invalid value for " + t + ": " + e2);
|
|
29420
|
+
this[t][e2] = r2;
|
|
29421
|
+
}
|
|
29422
|
+
handleRangeWithStepping(t, e2, r2, s) {
|
|
29423
|
+
let i = this.extractNth(t, e2), a2 = i[0].match(/^(\d+)-(\d+)\/(\d+)$/);
|
|
29424
|
+
if (a2 === null)
|
|
27307
29425
|
throw new TypeError("CronPattern: Syntax error, illegal range with stepping: '" + t + "'");
|
|
27308
|
-
let [,
|
|
27309
|
-
if (isNaN(
|
|
29426
|
+
let [, l2, o, u2] = a2, c2 = parseInt(l2, 10) + r2, w2 = parseInt(o, 10) + r2, C2 = parseInt(u2, 10);
|
|
29427
|
+
if (isNaN(c2))
|
|
27310
29428
|
throw new TypeError("CronPattern: Syntax error, illegal lower range (NaN)");
|
|
27311
|
-
if (isNaN(
|
|
29429
|
+
if (isNaN(w2))
|
|
27312
29430
|
throw new TypeError("CronPattern: Syntax error, illegal upper range (NaN)");
|
|
27313
29431
|
if (isNaN(C2))
|
|
27314
29432
|
throw new TypeError("CronPattern: Syntax error, illegal stepping: (NaN)");
|
|
27315
29433
|
if (C2 === 0)
|
|
27316
29434
|
throw new TypeError("CronPattern: Syntax error, illegal stepping: 0");
|
|
27317
|
-
if (C2 > this[
|
|
27318
|
-
throw new TypeError("CronPattern: Syntax error, steps cannot be greater than maximum value of part (" + this[
|
|
27319
|
-
if (
|
|
29435
|
+
if (C2 > this[e2].length)
|
|
29436
|
+
throw new TypeError("CronPattern: Syntax error, steps cannot be greater than maximum value of part (" + this[e2].length + ")");
|
|
29437
|
+
if (c2 > w2)
|
|
27320
29438
|
throw new TypeError("CronPattern: From value is larger than to value: '" + t + "'");
|
|
27321
|
-
for (let
|
|
27322
|
-
this.setPart(
|
|
29439
|
+
for (let T2 = c2;T2 <= w2; T2 += C2)
|
|
29440
|
+
this.setPart(e2, T2, i[1] || s);
|
|
27323
29441
|
}
|
|
27324
|
-
extractNth(t,
|
|
27325
|
-
let
|
|
27326
|
-
if (
|
|
27327
|
-
if (
|
|
29442
|
+
extractNth(t, e2) {
|
|
29443
|
+
let r2 = t, s;
|
|
29444
|
+
if (r2.includes("#")) {
|
|
29445
|
+
if (e2 !== "dayOfWeek")
|
|
27328
29446
|
throw new Error("CronPattern: nth (#) only allowed in day-of-week field");
|
|
27329
|
-
s =
|
|
29447
|
+
s = r2.split("#")[1], r2 = r2.split("#")[0];
|
|
27330
29448
|
}
|
|
27331
|
-
return [
|
|
29449
|
+
return [r2, s];
|
|
27332
29450
|
}
|
|
27333
|
-
handleRange(t,
|
|
27334
|
-
let i = this.extractNth(t,
|
|
27335
|
-
if (
|
|
29451
|
+
handleRange(t, e2, r2, s) {
|
|
29452
|
+
let i = this.extractNth(t, e2), a2 = i[0].split("-");
|
|
29453
|
+
if (a2.length !== 2)
|
|
27336
29454
|
throw new TypeError("CronPattern: Syntax error, illegal range: '" + t + "'");
|
|
27337
|
-
let
|
|
27338
|
-
if (isNaN(
|
|
29455
|
+
let l2 = parseInt(a2[0], 10) + r2, o = parseInt(a2[1], 10) + r2;
|
|
29456
|
+
if (isNaN(l2))
|
|
27339
29457
|
throw new TypeError("CronPattern: Syntax error, illegal lower range (NaN)");
|
|
27340
29458
|
if (isNaN(o))
|
|
27341
29459
|
throw new TypeError("CronPattern: Syntax error, illegal upper range (NaN)");
|
|
27342
|
-
if (
|
|
29460
|
+
if (l2 > o)
|
|
27343
29461
|
throw new TypeError("CronPattern: From value is larger than to value: '" + t + "'");
|
|
27344
|
-
for (let
|
|
27345
|
-
this.setPart(
|
|
29462
|
+
for (let u2 = l2;u2 <= o; u2++)
|
|
29463
|
+
this.setPart(e2, u2, i[1] || s);
|
|
27346
29464
|
}
|
|
27347
|
-
handleStepping(t,
|
|
27348
|
-
let i = this.extractNth(t,
|
|
27349
|
-
if (
|
|
29465
|
+
handleStepping(t, e2, r2, s) {
|
|
29466
|
+
let i = this.extractNth(t, e2), a2 = i[0].split("/");
|
|
29467
|
+
if (a2.length !== 2)
|
|
27350
29468
|
throw new TypeError("CronPattern: Syntax error, illegal stepping: '" + t + "'");
|
|
27351
|
-
|
|
27352
|
-
let
|
|
27353
|
-
|
|
27354
|
-
let o = parseInt(
|
|
29469
|
+
a2[0] === "" && (a2[0] = "*");
|
|
29470
|
+
let l2 = 0;
|
|
29471
|
+
a2[0] !== "*" && (l2 = parseInt(a2[0], 10) + r2);
|
|
29472
|
+
let o = parseInt(a2[1], 10);
|
|
27355
29473
|
if (isNaN(o))
|
|
27356
29474
|
throw new TypeError("CronPattern: Syntax error, illegal stepping: (NaN)");
|
|
27357
29475
|
if (o === 0)
|
|
27358
29476
|
throw new TypeError("CronPattern: Syntax error, illegal stepping: 0");
|
|
27359
|
-
if (o > this[
|
|
27360
|
-
throw new TypeError("CronPattern: Syntax error, max steps for part is (" + this[
|
|
27361
|
-
for (let
|
|
27362
|
-
this.setPart(
|
|
29477
|
+
if (o > this[e2].length)
|
|
29478
|
+
throw new TypeError("CronPattern: Syntax error, max steps for part is (" + this[e2].length + ")");
|
|
29479
|
+
for (let u2 = l2;u2 < this[e2].length; u2 += o)
|
|
29480
|
+
this.setPart(e2, u2, i[1] || s);
|
|
27363
29481
|
}
|
|
27364
29482
|
replaceAlphaDays(t) {
|
|
27365
29483
|
return t.replace(/-sun/gi, "-7").replace(/sun/gi, "0").replace(/mon/gi, "1").replace(/tue/gi, "2").replace(/wed/gi, "3").replace(/thu/gi, "4").replace(/fri/gi, "5").replace(/sat/gi, "6");
|
|
@@ -27368,22 +29486,22 @@ var d = class {
|
|
|
27368
29486
|
return t.replace(/jan/gi, "1").replace(/feb/gi, "2").replace(/mar/gi, "3").replace(/apr/gi, "4").replace(/may/gi, "5").replace(/jun/gi, "6").replace(/jul/gi, "7").replace(/aug/gi, "8").replace(/sep/gi, "9").replace(/oct/gi, "10").replace(/nov/gi, "11").replace(/dec/gi, "12");
|
|
27369
29487
|
}
|
|
27370
29488
|
handleNicknames(t) {
|
|
27371
|
-
let
|
|
27372
|
-
return
|
|
27373
|
-
}
|
|
27374
|
-
setNthWeekdayOfMonth(t,
|
|
27375
|
-
if (typeof
|
|
27376
|
-
this.dayOfWeek[t] = this.dayOfWeek[t] |
|
|
27377
|
-
else if (
|
|
27378
|
-
this.dayOfWeek[t] =
|
|
27379
|
-
else if (
|
|
27380
|
-
this.dayOfWeek[t] = this.dayOfWeek[t] |
|
|
29489
|
+
let e2 = t.trim().toLowerCase();
|
|
29490
|
+
return e2 === "@yearly" || e2 === "@annually" ? "0 0 1 1 *" : e2 === "@monthly" ? "0 0 1 * *" : e2 === "@weekly" ? "0 0 * * 0" : e2 === "@daily" ? "0 0 * * *" : e2 === "@hourly" ? "0 * * * *" : t;
|
|
29491
|
+
}
|
|
29492
|
+
setNthWeekdayOfMonth(t, e2) {
|
|
29493
|
+
if (typeof e2 != "number" && e2 === "L")
|
|
29494
|
+
this.dayOfWeek[t] = this.dayOfWeek[t] | b2;
|
|
29495
|
+
else if (e2 === p2)
|
|
29496
|
+
this.dayOfWeek[t] = p2;
|
|
29497
|
+
else if (e2 < 6 && e2 > 0)
|
|
29498
|
+
this.dayOfWeek[t] = this.dayOfWeek[t] | v2[e2 - 1];
|
|
27381
29499
|
else
|
|
27382
|
-
throw new TypeError(`CronPattern: nth weekday out of range, should be 1-5 or L. Value: ${
|
|
29500
|
+
throw new TypeError(`CronPattern: nth weekday out of range, should be 1-5 or L. Value: ${e2}, Type: ${typeof e2}`);
|
|
27383
29501
|
}
|
|
27384
29502
|
};
|
|
27385
|
-
var
|
|
27386
|
-
var
|
|
29503
|
+
var O2 = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
29504
|
+
var m3 = [["month", "year", 0], ["day", "month", -1], ["hour", "day", 0], ["minute", "hour", 0], ["second", "minute", 0]];
|
|
27387
29505
|
var f = class n {
|
|
27388
29506
|
tz;
|
|
27389
29507
|
ms;
|
|
@@ -27393,8 +29511,8 @@ var f = class n {
|
|
|
27393
29511
|
day;
|
|
27394
29512
|
month;
|
|
27395
29513
|
year;
|
|
27396
|
-
constructor(t,
|
|
27397
|
-
if (this.tz =
|
|
29514
|
+
constructor(t, e2) {
|
|
29515
|
+
if (this.tz = e2, t && t instanceof Date)
|
|
27398
29516
|
if (!isNaN(t))
|
|
27399
29517
|
this.fromDate(t);
|
|
27400
29518
|
else
|
|
@@ -27408,16 +29526,16 @@ var f = class n {
|
|
|
27408
29526
|
else
|
|
27409
29527
|
throw new TypeError("CronDate: Invalid type (" + typeof t + ") passed to CronDate constructor");
|
|
27410
29528
|
}
|
|
27411
|
-
isNthWeekdayOfMonth(t,
|
|
27412
|
-
let
|
|
27413
|
-
for (let o = 1;o <=
|
|
27414
|
-
new Date(Date.UTC(t,
|
|
27415
|
-
if (s &
|
|
29529
|
+
isNthWeekdayOfMonth(t, e2, r2, s) {
|
|
29530
|
+
let a2 = new Date(Date.UTC(t, e2, r2)).getUTCDay(), l2 = 0;
|
|
29531
|
+
for (let o = 1;o <= r2; o++)
|
|
29532
|
+
new Date(Date.UTC(t, e2, o)).getUTCDay() === a2 && l2++;
|
|
29533
|
+
if (s & p2 && v2[l2 - 1] & s)
|
|
27416
29534
|
return true;
|
|
27417
|
-
if (s &
|
|
27418
|
-
let o = new Date(Date.UTC(t,
|
|
27419
|
-
for (let
|
|
27420
|
-
if (new Date(Date.UTC(t,
|
|
29535
|
+
if (s & b2) {
|
|
29536
|
+
let o = new Date(Date.UTC(t, e2 + 1, 0)).getUTCDate();
|
|
29537
|
+
for (let u2 = r2 + 1;u2 <= o; u2++)
|
|
29538
|
+
if (new Date(Date.UTC(t, e2, u2)).getUTCDay() === a2)
|
|
27421
29539
|
return false;
|
|
27422
29540
|
return true;
|
|
27423
29541
|
}
|
|
@@ -27428,8 +29546,8 @@ var f = class n {
|
|
|
27428
29546
|
if (typeof this.tz == "number")
|
|
27429
29547
|
this.ms = t.getUTCMilliseconds(), this.second = t.getUTCSeconds(), this.minute = t.getUTCMinutes() + this.tz, this.hour = t.getUTCHours(), this.day = t.getUTCDate(), this.month = t.getUTCMonth(), this.year = t.getUTCFullYear(), this.apply();
|
|
27430
29548
|
else {
|
|
27431
|
-
let
|
|
27432
|
-
this.ms = t.getMilliseconds(), this.second =
|
|
29549
|
+
let e2 = h2.toTZ(t, this.tz);
|
|
29550
|
+
this.ms = t.getMilliseconds(), this.second = e2.s, this.minute = e2.i, this.hour = e2.h, this.day = e2.d, this.month = e2.m - 1, this.year = e2.y;
|
|
27433
29551
|
}
|
|
27434
29552
|
else
|
|
27435
29553
|
this.ms = t.getMilliseconds(), this.second = t.getSeconds(), this.minute = t.getMinutes(), this.hour = t.getHours(), this.day = t.getDate(), this.month = t.getMonth(), this.year = t.getFullYear();
|
|
@@ -27438,7 +29556,7 @@ var f = class n {
|
|
|
27438
29556
|
this.tz = t.tz, this.year = t.year, this.month = t.month, this.day = t.day, this.hour = t.hour, this.minute = t.minute, this.second = t.second, this.ms = t.ms;
|
|
27439
29557
|
}
|
|
27440
29558
|
apply() {
|
|
27441
|
-
if (this.month > 11 || this.day >
|
|
29559
|
+
if (this.month > 11 || this.day > O2[this.month] || this.hour > 59 || this.minute > 59 || this.second > 59 || this.hour < 0 || this.minute < 0 || this.second < 0) {
|
|
27442
29560
|
let t = new Date(Date.UTC(this.year, this.month, this.day, this.hour, this.minute, this.second, this.ms));
|
|
27443
29561
|
return this.ms = t.getUTCMilliseconds(), this.second = t.getUTCSeconds(), this.minute = t.getUTCMinutes(), this.hour = t.getUTCHours(), this.day = t.getUTCDate(), this.month = t.getUTCMonth(), this.year = t.getUTCFullYear(), true;
|
|
27444
29562
|
} else
|
|
@@ -27446,54 +29564,54 @@ var f = class n {
|
|
|
27446
29564
|
}
|
|
27447
29565
|
fromString(t) {
|
|
27448
29566
|
if (typeof this.tz == "number") {
|
|
27449
|
-
let
|
|
27450
|
-
this.ms =
|
|
29567
|
+
let e2 = h2.fromTZISO(t);
|
|
29568
|
+
this.ms = e2.getUTCMilliseconds(), this.second = e2.getUTCSeconds(), this.minute = e2.getUTCMinutes(), this.hour = e2.getUTCHours(), this.day = e2.getUTCDate(), this.month = e2.getUTCMonth(), this.year = e2.getUTCFullYear(), this.apply();
|
|
27451
29569
|
} else
|
|
27452
|
-
return this.fromDate(
|
|
27453
|
-
}
|
|
27454
|
-
findNext(t,
|
|
27455
|
-
let i = this[
|
|
27456
|
-
|
|
27457
|
-
let
|
|
27458
|
-
for (let o = this[
|
|
27459
|
-
let
|
|
27460
|
-
if (
|
|
27461
|
-
let
|
|
27462
|
-
if (
|
|
27463
|
-
|
|
27464
|
-
else if (
|
|
27465
|
-
throw new Error(`CronDate: Invalid value for dayOfWeek encountered. ${
|
|
27466
|
-
t.legacyMode && !
|
|
27467
|
-
}
|
|
27468
|
-
if (
|
|
27469
|
-
return this[
|
|
29570
|
+
return this.fromDate(h2.fromTZISO(t, this.tz));
|
|
29571
|
+
}
|
|
29572
|
+
findNext(t, e2, r2, s) {
|
|
29573
|
+
let i = this[e2], a2;
|
|
29574
|
+
r2.lastDayOfMonth && (this.month !== 1 ? a2 = O2[this.month] : a2 = new Date(Date.UTC(this.year, this.month + 1, 0, 0, 0, 0, 0)).getUTCDate());
|
|
29575
|
+
let l2 = !r2.starDOW && e2 == "day" ? new Date(Date.UTC(this.year, this.month, 1, 0, 0, 0, 0)).getUTCDay() : undefined;
|
|
29576
|
+
for (let o = this[e2] + s;o < r2[e2].length; o++) {
|
|
29577
|
+
let u2 = r2[e2][o];
|
|
29578
|
+
if (e2 === "day" && r2.lastDayOfMonth && o - s == a2 && (u2 = 1), e2 === "day" && !r2.starDOW) {
|
|
29579
|
+
let c2 = r2.dayOfWeek[(l2 + (o - s - 1)) % 7];
|
|
29580
|
+
if (c2 && c2 & p2)
|
|
29581
|
+
c2 = this.isNthWeekdayOfMonth(this.year, this.month, o - s, c2) ? 1 : 0;
|
|
29582
|
+
else if (c2)
|
|
29583
|
+
throw new Error(`CronDate: Invalid value for dayOfWeek encountered. ${c2}`);
|
|
29584
|
+
t.legacyMode && !r2.starDOM ? u2 = u2 || c2 : u2 = u2 && c2;
|
|
29585
|
+
}
|
|
29586
|
+
if (u2)
|
|
29587
|
+
return this[e2] = o - s, i !== this[e2] ? 2 : 1;
|
|
27470
29588
|
}
|
|
27471
29589
|
return 3;
|
|
27472
29590
|
}
|
|
27473
|
-
recurse(t,
|
|
27474
|
-
let s = this.findNext(
|
|
29591
|
+
recurse(t, e2, r2) {
|
|
29592
|
+
let s = this.findNext(e2, m3[r2][0], t, m3[r2][2]);
|
|
27475
29593
|
if (s > 1) {
|
|
27476
|
-
let i =
|
|
27477
|
-
for (;i <
|
|
27478
|
-
this[
|
|
29594
|
+
let i = r2 + 1;
|
|
29595
|
+
for (;i < m3.length; )
|
|
29596
|
+
this[m3[i][0]] = -m3[i][2], i++;
|
|
27479
29597
|
if (s === 3)
|
|
27480
|
-
return this[
|
|
29598
|
+
return this[m3[r2][1]]++, this[m3[r2][0]] = -m3[r2][2], this.apply(), this.recurse(t, e2, 0);
|
|
27481
29599
|
if (this.apply())
|
|
27482
|
-
return this.recurse(t,
|
|
29600
|
+
return this.recurse(t, e2, r2 - 1);
|
|
27483
29601
|
}
|
|
27484
|
-
return
|
|
29602
|
+
return r2 += 1, r2 >= m3.length ? this : this.year >= 3000 ? null : this.recurse(t, e2, r2);
|
|
27485
29603
|
}
|
|
27486
|
-
increment(t,
|
|
27487
|
-
return this.second +=
|
|
29604
|
+
increment(t, e2, r2) {
|
|
29605
|
+
return this.second += e2.interval !== undefined && e2.interval > 1 && r2 ? e2.interval : 1, this.ms = 0, this.apply(), this.recurse(t, e2, 0);
|
|
27488
29606
|
}
|
|
27489
29607
|
getDate(t) {
|
|
27490
|
-
return t || this.tz === undefined ? new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.ms) : typeof this.tz == "number" ? new Date(Date.UTC(this.year, this.month, this.day, this.hour, this.minute - this.tz, this.second, this.ms)) :
|
|
29608
|
+
return t || this.tz === undefined ? new Date(this.year, this.month, this.day, this.hour, this.minute, this.second, this.ms) : typeof this.tz == "number" ? new Date(Date.UTC(this.year, this.month, this.day, this.hour, this.minute - this.tz, this.second, this.ms)) : h2.fromTZ(h2.tp(this.year, this.month + 1, this.day, this.hour, this.minute, this.second, this.tz), false);
|
|
27491
29609
|
}
|
|
27492
29610
|
getTime() {
|
|
27493
29611
|
return this.getDate(false).getTime();
|
|
27494
29612
|
}
|
|
27495
29613
|
};
|
|
27496
|
-
function
|
|
29614
|
+
function N3(n2) {
|
|
27497
29615
|
if (n2 === undefined && (n2 = {}), delete n2.name, n2.legacyMode = n2.legacyMode === undefined ? true : n2.legacyMode, n2.paused = n2.paused === undefined ? false : n2.paused, n2.maxRuns = n2.maxRuns === undefined ? 1 / 0 : n2.maxRuns, n2.catch = n2.catch === undefined ? false : n2.catch, n2.interval = n2.interval === undefined ? 0 : parseInt(n2.interval.toString(), 10), n2.utcOffset = n2.utcOffset === undefined ? undefined : parseInt(n2.utcOffset.toString(), 10), n2.unref = n2.unref === undefined ? false : n2.unref, n2.startAt && (n2.startAt = new f(n2.startAt, n2.timezone)), n2.stopAt && (n2.stopAt = new f(n2.stopAt, n2.timezone)), n2.interval !== null) {
|
|
27498
29616
|
if (isNaN(n2.interval))
|
|
27499
29617
|
throw new Error("CronOptions: Supplied value for interval is not a number");
|
|
@@ -27512,60 +29630,60 @@ function N(n2) {
|
|
|
27512
29630
|
throw new Error("CronOptions: Unref should be either true, false or undefined(false).");
|
|
27513
29631
|
return n2;
|
|
27514
29632
|
}
|
|
27515
|
-
function
|
|
29633
|
+
function g2(n2) {
|
|
27516
29634
|
return Object.prototype.toString.call(n2) === "[object Function]" || typeof n2 == "function" || n2 instanceof Function;
|
|
27517
29635
|
}
|
|
27518
|
-
function
|
|
27519
|
-
return
|
|
29636
|
+
function S3(n2) {
|
|
29637
|
+
return g2(n2);
|
|
27520
29638
|
}
|
|
27521
|
-
function
|
|
29639
|
+
function P2(n2) {
|
|
27522
29640
|
typeof Deno < "u" && typeof Deno.unrefTimer < "u" ? Deno.unrefTimer(n2) : n2 && typeof n2.unref < "u" && n2.unref();
|
|
27523
29641
|
}
|
|
27524
|
-
var
|
|
27525
|
-
var
|
|
27526
|
-
var
|
|
29642
|
+
var _2 = 30 * 1000;
|
|
29643
|
+
var y3 = [];
|
|
29644
|
+
var R3 = class {
|
|
27527
29645
|
name;
|
|
27528
29646
|
options;
|
|
27529
29647
|
_states;
|
|
27530
29648
|
fn;
|
|
27531
|
-
constructor(t,
|
|
29649
|
+
constructor(t, e2, r2) {
|
|
27532
29650
|
let s, i;
|
|
27533
|
-
if (
|
|
27534
|
-
i =
|
|
27535
|
-
else if (typeof
|
|
27536
|
-
s =
|
|
27537
|
-
else if (
|
|
29651
|
+
if (g2(e2))
|
|
29652
|
+
i = e2;
|
|
29653
|
+
else if (typeof e2 == "object")
|
|
29654
|
+
s = e2;
|
|
29655
|
+
else if (e2 !== undefined)
|
|
27538
29656
|
throw new Error("Cron: Invalid argument passed for optionsIn. Should be one of function, or object (options).");
|
|
27539
|
-
if (
|
|
27540
|
-
i =
|
|
27541
|
-
else if (typeof
|
|
27542
|
-
s =
|
|
27543
|
-
else if (
|
|
29657
|
+
if (g2(r2))
|
|
29658
|
+
i = r2;
|
|
29659
|
+
else if (typeof r2 == "object")
|
|
29660
|
+
s = r2;
|
|
29661
|
+
else if (r2 !== undefined)
|
|
27544
29662
|
throw new Error("Cron: Invalid argument passed for funcIn. Should be one of function, or object (options).");
|
|
27545
|
-
if (this.name = s?.name, this.options =
|
|
27546
|
-
if (
|
|
29663
|
+
if (this.name = s?.name, this.options = N3(s), this._states = { kill: false, blocking: false, previousRun: undefined, currentRun: undefined, once: undefined, currentTimeout: undefined, maxRuns: s ? s.maxRuns : undefined, paused: s ? s.paused : false, pattern: new d2("* * * * *") }, t && (t instanceof Date || typeof t == "string" && t.indexOf(":") > 0) ? this._states.once = new f(t, this.options.timezone || this.options.utcOffset) : this._states.pattern = new d2(t, this.options.timezone), this.name) {
|
|
29664
|
+
if (y3.find((l2) => l2.name === this.name))
|
|
27547
29665
|
throw new Error("Cron: Tried to initialize new named job '" + this.name + "', but name already taken.");
|
|
27548
|
-
|
|
29666
|
+
y3.push(this);
|
|
27549
29667
|
}
|
|
27550
|
-
return i !== undefined &&
|
|
29668
|
+
return i !== undefined && S3(i) && (this.fn = i, this.schedule()), this;
|
|
27551
29669
|
}
|
|
27552
29670
|
nextRun(t) {
|
|
27553
|
-
let
|
|
27554
|
-
return
|
|
29671
|
+
let e2 = this._next(t);
|
|
29672
|
+
return e2 ? e2.getDate(false) : null;
|
|
27555
29673
|
}
|
|
27556
|
-
nextRuns(t,
|
|
29674
|
+
nextRuns(t, e2) {
|
|
27557
29675
|
this._states.maxRuns !== undefined && t > this._states.maxRuns && (t = this._states.maxRuns);
|
|
27558
|
-
let
|
|
29676
|
+
let r2 = [], s = e2 || this._states.currentRun || undefined;
|
|
27559
29677
|
for (;t-- && (s = this.nextRun(s)); )
|
|
27560
|
-
|
|
27561
|
-
return
|
|
29678
|
+
r2.push(s);
|
|
29679
|
+
return r2;
|
|
27562
29680
|
}
|
|
27563
29681
|
getPattern() {
|
|
27564
29682
|
return this._states.pattern ? this._states.pattern.pattern : undefined;
|
|
27565
29683
|
}
|
|
27566
29684
|
isRunning() {
|
|
27567
|
-
let t = this.nextRun(this._states.currentRun),
|
|
27568
|
-
return
|
|
29685
|
+
let t = this.nextRun(this._states.currentRun), e2 = !this._states.paused, r2 = this.fn !== undefined, s = !this._states.kill;
|
|
29686
|
+
return e2 && r2 && s && t !== null;
|
|
27569
29687
|
}
|
|
27570
29688
|
isStopped() {
|
|
27571
29689
|
return this._states.kill;
|
|
@@ -27580,13 +29698,13 @@ var R = class {
|
|
|
27580
29698
|
return this._states.previousRun ? this._states.previousRun.getDate() : null;
|
|
27581
29699
|
}
|
|
27582
29700
|
msToNext(t) {
|
|
27583
|
-
let
|
|
27584
|
-
return
|
|
29701
|
+
let e2 = this._next(t);
|
|
29702
|
+
return e2 ? t instanceof f || t instanceof Date ? e2.getTime() - t.getTime() : e2.getTime() - new f(t).getTime() : null;
|
|
27585
29703
|
}
|
|
27586
29704
|
stop() {
|
|
27587
29705
|
this._states.kill = true, this._states.currentTimeout && clearTimeout(this._states.currentTimeout);
|
|
27588
|
-
let t =
|
|
27589
|
-
t >= 0 &&
|
|
29706
|
+
let t = y3.indexOf(this);
|
|
29707
|
+
t >= 0 && y3.splice(t, 1);
|
|
27590
29708
|
}
|
|
27591
29709
|
pause() {
|
|
27592
29710
|
return this._states.paused = true, !this._states.kill;
|
|
@@ -27598,15 +29716,15 @@ var R = class {
|
|
|
27598
29716
|
if (t && this.fn)
|
|
27599
29717
|
throw new Error("Cron: It is not allowed to schedule two functions using the same Croner instance.");
|
|
27600
29718
|
t && (this.fn = t);
|
|
27601
|
-
let
|
|
27602
|
-
return
|
|
29719
|
+
let e2 = this.msToNext(), r2 = this.nextRun(this._states.currentRun);
|
|
29720
|
+
return e2 == null || isNaN(e2) || r2 === null ? this : (e2 > _2 && (e2 = _2), this._states.currentTimeout = setTimeout(() => this._checkTrigger(r2), e2), this._states.currentTimeout && this.options.unref && P2(this._states.currentTimeout), this);
|
|
27603
29721
|
}
|
|
27604
29722
|
async _trigger(t) {
|
|
27605
29723
|
if (this._states.blocking = true, this._states.currentRun = new f(undefined, this.options.timezone || this.options.utcOffset), this.options.catch)
|
|
27606
29724
|
try {
|
|
27607
29725
|
this.fn !== undefined && await this.fn(this, this.options.context);
|
|
27608
|
-
} catch (
|
|
27609
|
-
|
|
29726
|
+
} catch (e2) {
|
|
29727
|
+
g2(this.options.catch) && this.options.catch(e2, this);
|
|
27610
29728
|
}
|
|
27611
29729
|
else
|
|
27612
29730
|
this.fn !== undefined && await this.fn(this, this.options.context);
|
|
@@ -27619,25 +29737,25 @@ var R = class {
|
|
|
27619
29737
|
return this._states.maxRuns;
|
|
27620
29738
|
}
|
|
27621
29739
|
_checkTrigger(t) {
|
|
27622
|
-
let
|
|
27623
|
-
|
|
29740
|
+
let e2 = new Date, r2 = !this._states.paused && e2.getTime() >= t.getTime(), s = this._states.blocking && this.options.protect;
|
|
29741
|
+
r2 && !s ? (this._states.maxRuns !== undefined && this._states.maxRuns--, this._trigger()) : r2 && s && g2(this.options.protect) && setTimeout(() => this.options.protect(this), 0), this.schedule();
|
|
27624
29742
|
}
|
|
27625
29743
|
_next(t) {
|
|
27626
|
-
let
|
|
27627
|
-
!t && this.options.startAt && this.options.interval && ([t,
|
|
29744
|
+
let e2 = !!(t || this._states.currentRun), r2 = false;
|
|
29745
|
+
!t && this.options.startAt && this.options.interval && ([t, e2] = this._calculatePreviousRun(t, e2), r2 = !t), t = new f(t, this.options.timezone || this.options.utcOffset), this.options.startAt && t && t.getTime() < this.options.startAt.getTime() && (t = this.options.startAt);
|
|
27628
29746
|
let s = this._states.once || new f(t, this.options.timezone || this.options.utcOffset);
|
|
27629
|
-
return !
|
|
29747
|
+
return !r2 && s !== this._states.once && (s = s.increment(this._states.pattern, this.options, e2)), this._states.once && this._states.once.getTime() <= t.getTime() || s === null || this._states.maxRuns !== undefined && this._states.maxRuns <= 0 || this._states.kill || this.options.stopAt && s.getTime() >= this.options.stopAt.getTime() ? null : s;
|
|
27630
29748
|
}
|
|
27631
|
-
_calculatePreviousRun(t,
|
|
27632
|
-
let
|
|
27633
|
-
if (this.options.startAt.getTime() <=
|
|
29749
|
+
_calculatePreviousRun(t, e2) {
|
|
29750
|
+
let r2 = new f(undefined, this.options.timezone || this.options.utcOffset), s = t;
|
|
29751
|
+
if (this.options.startAt.getTime() <= r2.getTime()) {
|
|
27634
29752
|
s = this.options.startAt;
|
|
27635
29753
|
let i = s.getTime() + this.options.interval * 1000;
|
|
27636
|
-
for (;i <=
|
|
29754
|
+
for (;i <= r2.getTime(); )
|
|
27637
29755
|
s = new f(s, this.options.timezone || this.options.utcOffset).increment(this._states.pattern, this.options, true), i = s.getTime() + this.options.interval * 1000;
|
|
27638
|
-
|
|
29756
|
+
e2 = true;
|
|
27639
29757
|
}
|
|
27640
|
-
return s === null && (s = undefined), [s,
|
|
29758
|
+
return s === null && (s = undefined), [s, e2];
|
|
27641
29759
|
}
|
|
27642
29760
|
};
|
|
27643
29761
|
|
|
@@ -27656,7 +29774,7 @@ class CronScheduler {
|
|
|
27656
29774
|
console.log(`[ARC:Cron] Discovered ${cronEntries.length} cron method(s):`);
|
|
27657
29775
|
for (const entry of cronEntries) {
|
|
27658
29776
|
console.log(`[ARC:Cron] ${entry.aggregateName}.${entry.methodName} \u2192 "${entry.cronExpression}"`);
|
|
27659
|
-
const task = new
|
|
29777
|
+
const task = new R3(entry.cronExpression, async () => {
|
|
27660
29778
|
await this.executeCronMethod(entry);
|
|
27661
29779
|
});
|
|
27662
29780
|
this.jobs.push({ entry, task });
|
|
@@ -27872,13 +29990,13 @@ function eventSyncHandler(ch) {
|
|
|
27872
29990
|
try {
|
|
27873
29991
|
const body = await req.json();
|
|
27874
29992
|
const events = body.events || [];
|
|
27875
|
-
const persisted = await ch.persistEvents(events.map((
|
|
27876
|
-
localId:
|
|
27877
|
-
type:
|
|
27878
|
-
payload:
|
|
27879
|
-
createdAt:
|
|
29993
|
+
const persisted = await ch.persistEvents(events.map((e2) => ({
|
|
29994
|
+
localId: e2.localId,
|
|
29995
|
+
type: e2.type,
|
|
29996
|
+
payload: e2.payload,
|
|
29997
|
+
createdAt: e2.createdAt
|
|
27880
29998
|
})), "http-sync", ctx.tokenPayload);
|
|
27881
|
-
return Response.json({ success: true, syncedIds: persisted.map((
|
|
29999
|
+
return Response.json({ success: true, syncedIds: persisted.map((e2) => e2.localId) }, { headers: ctx.corsHeaders });
|
|
27882
30000
|
} catch (error) {
|
|
27883
30001
|
return Response.json({ success: false, error: error.message }, { status: 500, headers: ctx.corsHeaders });
|
|
27884
30002
|
}
|
|
@@ -28006,13 +30124,13 @@ function syncEventsHandler() {
|
|
|
28006
30124
|
const persisted = await ctx.contextHandler.persistEvents(message.events, client.id, token);
|
|
28007
30125
|
if (persisted.length === 0)
|
|
28008
30126
|
return true;
|
|
28009
|
-
for (const
|
|
28010
|
-
if (
|
|
30127
|
+
for (const c2 of ctx.connectionManager.getAllClients()) {
|
|
30128
|
+
if (c2.id === client.id)
|
|
28011
30129
|
continue;
|
|
28012
|
-
const clientTokens = ctx.connectionManager.getAllScopeTokens(
|
|
30130
|
+
const clientTokens = ctx.connectionManager.getAllScopeTokens(c2.id);
|
|
28013
30131
|
const authorized = filterEventsForTokens(clientTokens, persisted, ctx.contextHandler.getEventDefinitions());
|
|
28014
30132
|
if (authorized.length > 0) {
|
|
28015
|
-
ctx.connectionManager.sendToClient(
|
|
30133
|
+
ctx.connectionManager.sendToClient(c2.id, {
|
|
28016
30134
|
type: "events",
|
|
28017
30135
|
events: authorized
|
|
28018
30136
|
});
|
|
@@ -28104,8 +30222,8 @@ function querySubscriptionHandler() {
|
|
|
28104
30222
|
subscriptionId,
|
|
28105
30223
|
data: data ?? null
|
|
28106
30224
|
});
|
|
28107
|
-
} catch (
|
|
28108
|
-
console.error(`[Arc] Query subscription error:`,
|
|
30225
|
+
} catch (err3) {
|
|
30226
|
+
console.error(`[Arc] Query subscription error:`, err3);
|
|
28109
30227
|
}
|
|
28110
30228
|
};
|
|
28111
30229
|
sendData();
|
|
@@ -28305,8 +30423,101 @@ async function createArcServer(config) {
|
|
|
28305
30423
|
};
|
|
28306
30424
|
}
|
|
28307
30425
|
// src/platform/server.ts
|
|
28308
|
-
import { existsSync as
|
|
28309
|
-
import { join as
|
|
30426
|
+
import { existsSync as existsSync12, mkdirSync as mkdirSync11 } from "fs";
|
|
30427
|
+
import { join as join15 } from "path";
|
|
30428
|
+
|
|
30429
|
+
// src/platform/deploy-api.ts
|
|
30430
|
+
import { existsSync as existsSync11, mkdirSync as mkdirSync10, readFileSync as readFileSync10, writeFileSync as writeFileSync11 } from "fs";
|
|
30431
|
+
import { dirname as dirname7, join as join14, normalize as normalize2, relative as relative4, resolve } from "path";
|
|
30432
|
+
function createDeployApiHandler(opts) {
|
|
30433
|
+
return async (req, url, ctx) => {
|
|
30434
|
+
const p3 = url.pathname;
|
|
30435
|
+
if (!p3.startsWith("/api/deploy/"))
|
|
30436
|
+
return null;
|
|
30437
|
+
if (p3 === "/api/deploy/health" && req.method === "GET") {
|
|
30438
|
+
return Response.json({ ok: true, modules: opts.getManifest().modules.length }, { headers: ctx.corsHeaders });
|
|
30439
|
+
}
|
|
30440
|
+
if (p3 === "/api/deploy/manifest" && req.method === "GET") {
|
|
30441
|
+
return Response.json(opts.getManifest(), { headers: ctx.corsHeaders });
|
|
30442
|
+
}
|
|
30443
|
+
if (p3 === "/api/deploy/manifest" && req.method === "POST") {
|
|
30444
|
+
const body = await req.json();
|
|
30445
|
+
if (!validateManifest(body)) {
|
|
30446
|
+
return Response.json({ error: "Invalid manifest body" }, { status: 400, headers: ctx.corsHeaders });
|
|
30447
|
+
}
|
|
30448
|
+
writeFileSync11(join14(opts.ws.modulesDir, "manifest.json"), JSON.stringify(body, null, 2));
|
|
30449
|
+
opts.setManifest(body);
|
|
30450
|
+
opts.notifyReload(body);
|
|
30451
|
+
return Response.json({ ok: true, moduleCount: body.modules.length }, { headers: ctx.corsHeaders });
|
|
30452
|
+
}
|
|
30453
|
+
if (p3 === "/api/deploy/modules" && req.method === "POST") {
|
|
30454
|
+
const form = await req.formData();
|
|
30455
|
+
const written = await writeUploadedFiles(form, opts.ws.modulesDir);
|
|
30456
|
+
return Response.json({ ok: true, written }, { headers: ctx.corsHeaders });
|
|
30457
|
+
}
|
|
30458
|
+
if (p3 === "/api/deploy/shell" && req.method === "POST") {
|
|
30459
|
+
const form = await req.formData();
|
|
30460
|
+
const shellFiles = [];
|
|
30461
|
+
const rootFiles = [];
|
|
30462
|
+
for (const [name, value] of form.entries()) {
|
|
30463
|
+
if (!isFile(value))
|
|
30464
|
+
continue;
|
|
30465
|
+
if (name === "styles.css" || name === "theme.css") {
|
|
30466
|
+
rootFiles.push({ name, file: value });
|
|
30467
|
+
} else {
|
|
30468
|
+
shellFiles.push(value);
|
|
30469
|
+
}
|
|
30470
|
+
}
|
|
30471
|
+
const writtenShell = await writeUploadedFileList(shellFiles, opts.ws.shellDir);
|
|
30472
|
+
const writtenRoot = [];
|
|
30473
|
+
for (const { name, file } of rootFiles) {
|
|
30474
|
+
const target = join14(opts.ws.arcDir, name);
|
|
30475
|
+
writeFileSync11(target, Buffer.from(await file.arrayBuffer()));
|
|
30476
|
+
writtenRoot.push(name);
|
|
30477
|
+
}
|
|
30478
|
+
return Response.json({ ok: true, written: [...writtenShell, ...writtenRoot] }, { headers: ctx.corsHeaders });
|
|
30479
|
+
}
|
|
30480
|
+
return new Response("Not Found", {
|
|
30481
|
+
status: 404,
|
|
30482
|
+
headers: ctx.corsHeaders
|
|
30483
|
+
});
|
|
30484
|
+
};
|
|
30485
|
+
}
|
|
30486
|
+
async function writeUploadedFiles(form, targetDir) {
|
|
30487
|
+
const files = [];
|
|
30488
|
+
for (const [, value] of form.entries()) {
|
|
30489
|
+
if (isFile(value))
|
|
30490
|
+
files.push(value);
|
|
30491
|
+
}
|
|
30492
|
+
return writeUploadedFileList(files, targetDir);
|
|
30493
|
+
}
|
|
30494
|
+
function isFile(v3) {
|
|
30495
|
+
return typeof v3 === "object" && v3 !== null && typeof v3.arrayBuffer === "function" && typeof v3.name === "string";
|
|
30496
|
+
}
|
|
30497
|
+
async function writeUploadedFileList(files, targetDir) {
|
|
30498
|
+
const written = [];
|
|
30499
|
+
const safeRoot = resolve(targetDir);
|
|
30500
|
+
mkdirSync10(safeRoot, { recursive: true });
|
|
30501
|
+
for (const file of files) {
|
|
30502
|
+
const rel = normalize2(file.name);
|
|
30503
|
+
const full = resolve(safeRoot, rel);
|
|
30504
|
+
if (!full.startsWith(safeRoot + "/") && full !== safeRoot) {
|
|
30505
|
+
throw new Error(`Path traversal rejected: ${file.name}`);
|
|
30506
|
+
}
|
|
30507
|
+
mkdirSync10(dirname7(full), { recursive: true });
|
|
30508
|
+
writeFileSync11(full, Buffer.from(await file.arrayBuffer()));
|
|
30509
|
+
written.push(relative4(safeRoot, full) || rel);
|
|
30510
|
+
}
|
|
30511
|
+
return written;
|
|
30512
|
+
}
|
|
30513
|
+
function validateManifest(m4) {
|
|
30514
|
+
if (!m4 || typeof m4 !== "object")
|
|
30515
|
+
return false;
|
|
30516
|
+
const cast = m4;
|
|
30517
|
+
return Array.isArray(cast.modules) && typeof cast.shellHash === "string" && typeof cast.stylesHash === "string" && typeof cast.buildTime === "string";
|
|
30518
|
+
}
|
|
30519
|
+
|
|
30520
|
+
// src/platform/server.ts
|
|
28310
30521
|
function generateShellHtml(appName, manifest, arcEntries) {
|
|
28311
30522
|
const arcImports = {};
|
|
28312
30523
|
if (arcEntries) {
|
|
@@ -28369,7 +30580,7 @@ function getMime(path4) {
|
|
|
28369
30580
|
return MIME[ext2] ?? "application/octet-stream";
|
|
28370
30581
|
}
|
|
28371
30582
|
function serveFile(filePath, headers = {}) {
|
|
28372
|
-
if (!
|
|
30583
|
+
if (!existsSync12(filePath))
|
|
28373
30584
|
return new Response("Not Found", { status: 404 });
|
|
28374
30585
|
return new Response(Bun.file(filePath), {
|
|
28375
30586
|
headers: { "Content-Type": getMime(filePath), ...headers }
|
|
@@ -28447,13 +30658,18 @@ async function filterManifestForTokens(manifest, moduleAccessMap, tokenPayloads)
|
|
|
28447
30658
|
filtered.push({ ...mod, url: signModuleUrl(mod.file) });
|
|
28448
30659
|
}
|
|
28449
30660
|
}
|
|
28450
|
-
return {
|
|
30661
|
+
return {
|
|
30662
|
+
modules: filtered,
|
|
30663
|
+
shellHash: manifest.shellHash,
|
|
30664
|
+
stylesHash: manifest.stylesHash,
|
|
30665
|
+
buildTime: manifest.buildTime
|
|
30666
|
+
};
|
|
28451
30667
|
}
|
|
28452
30668
|
function staticFilesHandler(ws, devMode, moduleAccessMap) {
|
|
28453
30669
|
return (_req, url, ctx) => {
|
|
28454
30670
|
const path4 = url.pathname;
|
|
28455
30671
|
if (path4.startsWith("/shell/"))
|
|
28456
|
-
return serveFile(
|
|
30672
|
+
return serveFile(join15(ws.shellDir, path4.slice(7)), ctx.corsHeaders);
|
|
28457
30673
|
if (path4.startsWith("/modules/")) {
|
|
28458
30674
|
const fileWithParams = path4.slice(9);
|
|
28459
30675
|
const filename = fileWithParams.split("?")[0];
|
|
@@ -28465,23 +30681,23 @@ function staticFilesHandler(ws, devMode, moduleAccessMap) {
|
|
|
28465
30681
|
return new Response("Forbidden", { status: 403, headers: ctx.corsHeaders });
|
|
28466
30682
|
}
|
|
28467
30683
|
}
|
|
28468
|
-
return serveFile(
|
|
30684
|
+
return serveFile(join15(ws.modulesDir, filename), {
|
|
28469
30685
|
...ctx.corsHeaders,
|
|
28470
30686
|
"Cache-Control": devMode ? "no-cache" : "max-age=31536000,immutable"
|
|
28471
30687
|
});
|
|
28472
30688
|
}
|
|
28473
30689
|
if (path4.startsWith("/locales/"))
|
|
28474
|
-
return serveFile(
|
|
30690
|
+
return serveFile(join15(ws.arcDir, path4.slice(1)), ctx.corsHeaders);
|
|
28475
30691
|
if (path4 === "/styles.css")
|
|
28476
|
-
return serveFile(
|
|
30692
|
+
return serveFile(join15(ws.arcDir, "styles.css"), ctx.corsHeaders);
|
|
28477
30693
|
if (path4 === "/theme.css")
|
|
28478
|
-
return serveFile(
|
|
30694
|
+
return serveFile(join15(ws.arcDir, "theme.css"), ctx.corsHeaders);
|
|
28479
30695
|
if ((path4 === "/manifest.json" || path4 === "/manifest.webmanifest") && ws.manifest) {
|
|
28480
30696
|
return serveFile(ws.manifest.path, ctx.corsHeaders);
|
|
28481
30697
|
}
|
|
28482
30698
|
if (path4.lastIndexOf(".") > path4.lastIndexOf("/")) {
|
|
28483
|
-
const publicFile =
|
|
28484
|
-
if (
|
|
30699
|
+
const publicFile = join15(ws.publicDir, path4.slice(1));
|
|
30700
|
+
if (existsSync12(publicFile))
|
|
28485
30701
|
return serveFile(publicFile, ctx.corsHeaders);
|
|
28486
30702
|
}
|
|
28487
30703
|
return null;
|
|
@@ -28550,8 +30766,30 @@ async function startPlatformServer(opts) {
|
|
|
28550
30766
|
const moduleAccessMap = opts.moduleAccess ?? new Map;
|
|
28551
30767
|
let manifest = opts.manifest;
|
|
28552
30768
|
const getManifest = () => manifest;
|
|
30769
|
+
const setManifest = (m4) => {
|
|
30770
|
+
manifest = m4;
|
|
30771
|
+
};
|
|
28553
30772
|
const shellHtml = generateShellHtml(ws.appName, ws.manifest, opts.arcEntries);
|
|
28554
30773
|
const sseClients = new Set;
|
|
30774
|
+
const notifyReload = (m4) => {
|
|
30775
|
+
const data = JSON.stringify(m4);
|
|
30776
|
+
for (const c2 of sseClients) {
|
|
30777
|
+
try {
|
|
30778
|
+
c2.enqueue(`data: ${data}
|
|
30779
|
+
|
|
30780
|
+
`);
|
|
30781
|
+
} catch {
|
|
30782
|
+
sseClients.delete(c2);
|
|
30783
|
+
}
|
|
30784
|
+
}
|
|
30785
|
+
};
|
|
30786
|
+
const deployApiEnabled = opts.deployApi ?? process.env.ARC_DEPLOY_API === "1";
|
|
30787
|
+
const deployApiHandler = deployApiEnabled ? createDeployApiHandler({
|
|
30788
|
+
ws,
|
|
30789
|
+
getManifest,
|
|
30790
|
+
setManifest,
|
|
30791
|
+
notifyReload
|
|
30792
|
+
}) : null;
|
|
28555
30793
|
if (!context) {
|
|
28556
30794
|
const cors = {
|
|
28557
30795
|
"Access-Control-Allow-Origin": "*",
|
|
@@ -28560,7 +30798,7 @@ async function startPlatformServer(opts) {
|
|
|
28560
30798
|
};
|
|
28561
30799
|
const server = Bun.serve({
|
|
28562
30800
|
port,
|
|
28563
|
-
fetch(req) {
|
|
30801
|
+
async fetch(req) {
|
|
28564
30802
|
const url = new URL(req.url);
|
|
28565
30803
|
if (req.method === "OPTIONS")
|
|
28566
30804
|
return new Response(null, { headers: cors });
|
|
@@ -28570,15 +30808,14 @@ async function startPlatformServer(opts) {
|
|
|
28570
30808
|
corsHeaders: cors
|
|
28571
30809
|
};
|
|
28572
30810
|
const handlers = [
|
|
30811
|
+
...deployApiHandler ? [deployApiHandler] : [],
|
|
28573
30812
|
apiEndpointsHandler(ws, getManifest, null, moduleAccessMap),
|
|
28574
|
-
|
|
30813
|
+
devReloadHandler(sseClients),
|
|
28575
30814
|
staticFilesHandler(ws, !!devMode, moduleAccessMap),
|
|
28576
30815
|
spaFallbackHandler(shellHtml)
|
|
28577
30816
|
];
|
|
28578
30817
|
for (const handler of handlers) {
|
|
28579
|
-
const response = handler(req, url, ctx);
|
|
28580
|
-
if (response instanceof Promise)
|
|
28581
|
-
return response;
|
|
30818
|
+
const response = await handler(req, url, ctx);
|
|
28582
30819
|
if (response)
|
|
28583
30820
|
return response;
|
|
28584
30821
|
}
|
|
@@ -28589,36 +30826,24 @@ async function startPlatformServer(opts) {
|
|
|
28589
30826
|
server,
|
|
28590
30827
|
contextHandler: null,
|
|
28591
30828
|
connectionManager: null,
|
|
28592
|
-
setManifest
|
|
28593
|
-
|
|
28594
|
-
},
|
|
28595
|
-
notifyReload: (m2) => {
|
|
28596
|
-
const data = JSON.stringify(m2);
|
|
28597
|
-
for (const c of sseClients) {
|
|
28598
|
-
try {
|
|
28599
|
-
c.enqueue(`data: ${data}
|
|
28600
|
-
|
|
28601
|
-
`);
|
|
28602
|
-
} catch {
|
|
28603
|
-
sseClients.delete(c);
|
|
28604
|
-
}
|
|
28605
|
-
}
|
|
28606
|
-
},
|
|
30829
|
+
setManifest,
|
|
30830
|
+
notifyReload,
|
|
28607
30831
|
stop: () => server.stop()
|
|
28608
30832
|
};
|
|
28609
30833
|
}
|
|
28610
|
-
const { createBunSQLiteAdapterFactory: createBunSQLiteAdapterFactory2 } = await Promise.resolve().then(() => (init_dist(),
|
|
28611
|
-
const dbPath = opts.dbPath ||
|
|
30834
|
+
const { createBunSQLiteAdapterFactory: createBunSQLiteAdapterFactory2 } = await Promise.resolve().then(() => (init_dist(), exports_dist2));
|
|
30835
|
+
const dbPath = opts.dbPath || join15(ws.arcDir, "data", "arc.db");
|
|
28612
30836
|
const dbDir = dbPath.substring(0, dbPath.lastIndexOf("/"));
|
|
28613
30837
|
if (dbDir)
|
|
28614
|
-
|
|
30838
|
+
mkdirSync11(dbDir, { recursive: true });
|
|
28615
30839
|
const arcServer = await createArcServer({
|
|
28616
30840
|
context,
|
|
28617
30841
|
dbAdapterFactory: createBunSQLiteAdapterFactory2(dbPath),
|
|
28618
30842
|
port,
|
|
28619
30843
|
httpHandlers: [
|
|
30844
|
+
...deployApiHandler ? [deployApiHandler] : [],
|
|
28620
30845
|
apiEndpointsHandler(ws, getManifest, null, moduleAccessMap),
|
|
28621
|
-
|
|
30846
|
+
devReloadHandler(sseClients),
|
|
28622
30847
|
staticFilesHandler(ws, !!devMode, moduleAccessMap),
|
|
28623
30848
|
spaFallbackHandler(shellHtml)
|
|
28624
30849
|
],
|
|
@@ -28628,21 +30853,8 @@ async function startPlatformServer(opts) {
|
|
|
28628
30853
|
server: arcServer.server,
|
|
28629
30854
|
contextHandler: arcServer.contextHandler,
|
|
28630
30855
|
connectionManager: arcServer.connectionManager,
|
|
28631
|
-
setManifest
|
|
28632
|
-
|
|
28633
|
-
},
|
|
28634
|
-
notifyReload: (m2) => {
|
|
28635
|
-
const data = JSON.stringify(m2);
|
|
28636
|
-
for (const c of sseClients) {
|
|
28637
|
-
try {
|
|
28638
|
-
c.enqueue(`data: ${data}
|
|
28639
|
-
|
|
28640
|
-
`);
|
|
28641
|
-
} catch {
|
|
28642
|
-
sseClients.delete(c);
|
|
28643
|
-
}
|
|
28644
|
-
}
|
|
28645
|
-
},
|
|
30856
|
+
setManifest,
|
|
30857
|
+
notifyReload,
|
|
28646
30858
|
stop: () => arcServer.stop()
|
|
28647
30859
|
};
|
|
28648
30860
|
}
|
|
@@ -28666,7 +30878,7 @@ async function platformDev() {
|
|
|
28666
30878
|
manifest,
|
|
28667
30879
|
context,
|
|
28668
30880
|
moduleAccess,
|
|
28669
|
-
dbPath:
|
|
30881
|
+
dbPath: join16(ws.rootDir, ".arc", "data", "dev.db"),
|
|
28670
30882
|
devMode: true,
|
|
28671
30883
|
arcEntries
|
|
28672
30884
|
});
|
|
@@ -28677,8 +30889,8 @@ async function platformDev() {
|
|
|
28677
30889
|
let rebuildTimer = null;
|
|
28678
30890
|
let isRebuilding = false;
|
|
28679
30891
|
for (const pkg of ws.packages) {
|
|
28680
|
-
const srcDir =
|
|
28681
|
-
if (!
|
|
30892
|
+
const srcDir = join16(pkg.path, "src");
|
|
30893
|
+
if (!existsSync13(srcDir))
|
|
28682
30894
|
continue;
|
|
28683
30895
|
watch(srcDir, { recursive: true }, (_event, filename) => {
|
|
28684
30896
|
if (!filename || filename.includes(".arc") || filename.endsWith(".d.ts") || filename.includes("node_modules") || filename.includes("dist"))
|
|
@@ -28698,16 +30910,16 @@ async function platformDev() {
|
|
|
28698
30910
|
platform3.setManifest(manifest);
|
|
28699
30911
|
platform3.notifyReload(manifest);
|
|
28700
30912
|
ok(`Rebuilt ${manifest.modules.length} module(s)`);
|
|
28701
|
-
} catch (
|
|
28702
|
-
console.error(`Rebuild failed: ${
|
|
30913
|
+
} catch (e2) {
|
|
30914
|
+
console.error(`Rebuild failed: ${e2}`);
|
|
28703
30915
|
} finally {
|
|
28704
30916
|
isRebuilding = false;
|
|
28705
30917
|
}
|
|
28706
30918
|
}, 300);
|
|
28707
30919
|
});
|
|
28708
30920
|
}
|
|
28709
|
-
const localesDir =
|
|
28710
|
-
if (
|
|
30921
|
+
const localesDir = join16(ws.rootDir, "locales");
|
|
30922
|
+
if (existsSync13(localesDir)) {
|
|
28711
30923
|
let poTimer = null;
|
|
28712
30924
|
watch(localesDir, { recursive: false }, (_event, filename) => {
|
|
28713
30925
|
if (!filename?.endsWith(".po"))
|
|
@@ -28716,11 +30928,11 @@ async function platformDev() {
|
|
|
28716
30928
|
clearTimeout(poTimer);
|
|
28717
30929
|
poTimer = setTimeout(async () => {
|
|
28718
30930
|
try {
|
|
28719
|
-
compileAllCatalogs(localesDir,
|
|
30931
|
+
compileAllCatalogs(localesDir, join16(ws.arcDir, "locales"));
|
|
28720
30932
|
ok("Translations recompiled");
|
|
28721
30933
|
platform3.notifyReload(manifest);
|
|
28722
|
-
} catch (
|
|
28723
|
-
console.error(`Translation compile failed: ${
|
|
30934
|
+
} catch (e2) {
|
|
30935
|
+
console.error(`Translation compile failed: ${e2}`);
|
|
28724
30936
|
}
|
|
28725
30937
|
}, 200);
|
|
28726
30938
|
});
|
|
@@ -28734,17 +30946,17 @@ async function platformDev() {
|
|
|
28734
30946
|
}
|
|
28735
30947
|
|
|
28736
30948
|
// src/commands/platform-start.ts
|
|
28737
|
-
import { existsSync as
|
|
28738
|
-
import { join as
|
|
30949
|
+
import { existsSync as existsSync14, readFileSync as readFileSync11 } from "fs";
|
|
30950
|
+
import { join as join17 } from "path";
|
|
28739
30951
|
async function platformStart() {
|
|
28740
30952
|
const ws = resolveWorkspace();
|
|
28741
30953
|
const port = parseInt(process.env.PORT || "5005", 10);
|
|
28742
|
-
const manifestPath =
|
|
28743
|
-
if (!
|
|
30954
|
+
const manifestPath = join17(ws.modulesDir, "manifest.json");
|
|
30955
|
+
if (!existsSync14(manifestPath)) {
|
|
28744
30956
|
err("No build found. Run `arc platform build` first.");
|
|
28745
30957
|
process.exit(1);
|
|
28746
30958
|
}
|
|
28747
|
-
const manifest = JSON.parse(
|
|
30959
|
+
const manifest = JSON.parse(readFileSync11(manifestPath, "utf-8"));
|
|
28748
30960
|
log2("Loading server context...");
|
|
28749
30961
|
const { context, moduleAccess } = await loadServerContext(ws.packages);
|
|
28750
30962
|
if (context) {
|
|
@@ -28753,14 +30965,18 @@ async function platformStart() {
|
|
|
28753
30965
|
log2("No context \u2014 server endpoints skipped");
|
|
28754
30966
|
}
|
|
28755
30967
|
const arcEntries = collectArcPeerDeps(ws.packages);
|
|
30968
|
+
const deployApi = process.env.ARC_DEPLOY_API === "1";
|
|
30969
|
+
if (deployApi)
|
|
30970
|
+
ok("Deploy API enabled (/api/deploy/*)");
|
|
28756
30971
|
const platform3 = await startPlatformServer({
|
|
28757
30972
|
ws,
|
|
28758
30973
|
port,
|
|
28759
30974
|
manifest,
|
|
28760
30975
|
context,
|
|
28761
30976
|
moduleAccess,
|
|
28762
|
-
dbPath:
|
|
30977
|
+
dbPath: join17(ws.rootDir, ".arc", "data", "prod.db"),
|
|
28763
30978
|
devMode: false,
|
|
30979
|
+
deployApi,
|
|
28764
30980
|
arcEntries
|
|
28765
30981
|
});
|
|
28766
30982
|
ok(`Server on http://localhost:${port}`);
|
|
@@ -28783,6 +30999,7 @@ var platform3 = program2.command("platform").description("Platform commands \u20
|
|
|
28783
30999
|
platform3.command("dev").description("Start platform in dev mode (Bun server + Vite HMR)").action(platformDev);
|
|
28784
31000
|
platform3.command("build").description("Build platform for production").action(platformBuild);
|
|
28785
31001
|
platform3.command("start").description("Start platform in production mode (requires prior build)").action(platformStart);
|
|
31002
|
+
platform3.command("deploy [env]").description("Deploy platform to a remote server (reads deploy.arc.json, surveys if missing)").option("--skip-build", "Skip local build step").option("--rebuild", "Force rebuild before deploy").action((env2, opts) => platformDeploy(env2, opts));
|
|
28786
31003
|
program2.parse(process.argv);
|
|
28787
31004
|
if (process.argv.length === 2) {
|
|
28788
31005
|
program2.help();
|