@hoox-sh/hoox-cli 0.15.0 → 0.16.0
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 +799 -1705
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -33,19 +33,6 @@ var __toESM = (mod, isNodeMode, target) => {
|
|
|
33
33
|
return to;
|
|
34
34
|
};
|
|
35
35
|
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
36
|
-
var __returnValue = (v) => v;
|
|
37
|
-
function __exportSetter(name, newValue) {
|
|
38
|
-
this[name] = __returnValue.bind(null, newValue);
|
|
39
|
-
}
|
|
40
|
-
var __export = (target, all) => {
|
|
41
|
-
for (var name in all)
|
|
42
|
-
__defProp(target, name, {
|
|
43
|
-
get: all[name],
|
|
44
|
-
enumerable: true,
|
|
45
|
-
configurable: true,
|
|
46
|
-
set: __exportSetter.bind(all, name)
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
36
|
var __esm = (fn, res, err) => () => {
|
|
50
37
|
if (fn)
|
|
51
38
|
try {
|
|
@@ -5633,7 +5620,7 @@ var init_zod = __esm(() => {
|
|
|
5633
5620
|
});
|
|
5634
5621
|
|
|
5635
5622
|
// ../shared/src/types.ts
|
|
5636
|
-
var TradeActionSchema, MAX_WEBHOOK_LEVERAGE = 125, MAX_WEBHOOK_QUANTITY = 1e6, WebhookPayloadSchema, TradeQueueMessageSchema, TradeSignalSchema, PositionSchema, BalanceSchema;
|
|
5623
|
+
var TradeActionSchema, MAX_WEBHOOK_LEVERAGE = 125, MAX_WEBHOOK_QUANTITY = 1e6, WebhookPayloadSchema, TradeQueueMessageSchema, TradeSignalSchema, PositionSchema, BalanceSchema, VIEW_IDS;
|
|
5637
5624
|
var init_types = __esm(() => {
|
|
5638
5625
|
init_zod();
|
|
5639
5626
|
TradeActionSchema = _enum([
|
|
@@ -5695,17 +5682,47 @@ var init_types = __esm(() => {
|
|
|
5695
5682
|
locked: number2().min(0),
|
|
5696
5683
|
timestamp: number2().int().positive()
|
|
5697
5684
|
}).strict();
|
|
5685
|
+
VIEW_IDS = [
|
|
5686
|
+
"dashboard",
|
|
5687
|
+
"workers",
|
|
5688
|
+
"worker-detail",
|
|
5689
|
+
"trade-monitor",
|
|
5690
|
+
"logs-viewer",
|
|
5691
|
+
"service-manager",
|
|
5692
|
+
"config-editor",
|
|
5693
|
+
"setup-wizard",
|
|
5694
|
+
"settings",
|
|
5695
|
+
"queue-depth",
|
|
5696
|
+
"kv-viewer",
|
|
5697
|
+
"secrets-viewer",
|
|
5698
|
+
"db-query",
|
|
5699
|
+
"ai-chat",
|
|
5700
|
+
"edge-topology",
|
|
5701
|
+
"worker-settings"
|
|
5702
|
+
];
|
|
5698
5703
|
});
|
|
5699
5704
|
|
|
5700
5705
|
// ../shared/src/kvKeys.ts
|
|
5706
|
+
var KV_TRADE_KILL_SWITCH = "trade:kill_switch", KV_GLOBAL_KILL_SWITCH = "global:kill_switch";
|
|
5701
5707
|
var init_kvKeys = () => {};
|
|
5702
5708
|
|
|
5703
5709
|
// ../shared/src/tenant.ts
|
|
5704
5710
|
var init_tenant = () => {};
|
|
5705
5711
|
|
|
5706
5712
|
// ../shared/src/kill-switch.ts
|
|
5713
|
+
function isTruthyKillSwitchFlag(value) {
|
|
5714
|
+
if (value == null)
|
|
5715
|
+
return false;
|
|
5716
|
+
const v = value.trim().toLowerCase();
|
|
5717
|
+
return v === "true" || v === "1" || v === "yes" || v === "on";
|
|
5718
|
+
}
|
|
5719
|
+
var KILL_SWITCH_KEYS;
|
|
5707
5720
|
var init_kill_switch = __esm(() => {
|
|
5708
5721
|
init_kvKeys();
|
|
5722
|
+
KILL_SWITCH_KEYS = [
|
|
5723
|
+
KV_TRADE_KILL_SWITCH,
|
|
5724
|
+
KV_GLOBAL_KILL_SWITCH
|
|
5725
|
+
];
|
|
5709
5726
|
});
|
|
5710
5727
|
|
|
5711
5728
|
// ../shared/src/errors.ts
|
|
@@ -5755,77 +5772,6 @@ var init_analytics = __esm(() => {
|
|
|
5755
5772
|
var init_health = __esm(() => {
|
|
5756
5773
|
init_errors3();
|
|
5757
5774
|
});
|
|
5758
|
-
// ../shared/src/d1/repository.ts
|
|
5759
|
-
var init_repository = __esm(() => {
|
|
5760
|
-
init_errors3();
|
|
5761
|
-
});
|
|
5762
|
-
|
|
5763
|
-
// ../shared/src/d1/schemas.ts
|
|
5764
|
-
var TradeRecordSchema, PositionRecordSchema, BalanceRecordSchema, SystemLogRecordSchema, TradeSignalRecordSchema;
|
|
5765
|
-
var init_schemas3 = __esm(() => {
|
|
5766
|
-
init_zod();
|
|
5767
|
-
TradeRecordSchema = object({
|
|
5768
|
-
id: string2(),
|
|
5769
|
-
signal_id: string2().nullable().optional(),
|
|
5770
|
-
timestamp: number2().int().positive(),
|
|
5771
|
-
exchange: string2().min(1),
|
|
5772
|
-
symbol: string2().min(1),
|
|
5773
|
-
action: string2().min(1),
|
|
5774
|
-
quantity: number2().nullable(),
|
|
5775
|
-
price: number2().nullable(),
|
|
5776
|
-
leverage: number2().nullable(),
|
|
5777
|
-
status: string2().min(1),
|
|
5778
|
-
error_message: string2().nullable().optional(),
|
|
5779
|
-
raw_response: string2().nullable().optional(),
|
|
5780
|
-
created_at: number2().int().optional()
|
|
5781
|
-
}).strict();
|
|
5782
|
-
PositionRecordSchema = object({
|
|
5783
|
-
id: string2(),
|
|
5784
|
-
exchange: string2().min(1),
|
|
5785
|
-
symbol: string2().min(1),
|
|
5786
|
-
side: _enum(["LONG", "SHORT"]),
|
|
5787
|
-
entry_price: number2().nullable().optional(),
|
|
5788
|
-
mark_price: number2().nullable().optional(),
|
|
5789
|
-
liquidation_price: number2().nullable().optional(),
|
|
5790
|
-
leverage: number2().nullable().optional(),
|
|
5791
|
-
size: number2().nullable(),
|
|
5792
|
-
unrealized_pnl: number2().nullable().optional(),
|
|
5793
|
-
status: _enum(["OPEN", "CLOSED"]),
|
|
5794
|
-
updated_at: number2().int()
|
|
5795
|
-
}).strict();
|
|
5796
|
-
BalanceRecordSchema = object({
|
|
5797
|
-
id: string2(),
|
|
5798
|
-
exchange: string2().min(1),
|
|
5799
|
-
asset: string2().min(1),
|
|
5800
|
-
free: number2().nullable(),
|
|
5801
|
-
used: number2().nullable(),
|
|
5802
|
-
total: number2().nullable(),
|
|
5803
|
-
timestamp: number2().int().positive()
|
|
5804
|
-
}).strict();
|
|
5805
|
-
SystemLogRecordSchema = object({
|
|
5806
|
-
id: string2(),
|
|
5807
|
-
timestamp: number2().int().optional(),
|
|
5808
|
-
level: string2().min(1),
|
|
5809
|
-
service: string2().min(1),
|
|
5810
|
-
message: string2().min(1),
|
|
5811
|
-
details: string2().nullable().optional()
|
|
5812
|
-
}).strict();
|
|
5813
|
-
TradeSignalRecordSchema = object({
|
|
5814
|
-
signal_id: string2(),
|
|
5815
|
-
timestamp: number2().int().positive(),
|
|
5816
|
-
symbol: string2().min(1),
|
|
5817
|
-
signal_type: string2().min(1),
|
|
5818
|
-
source: string2().nullable().optional(),
|
|
5819
|
-
raw_data: string2().nullable().optional(),
|
|
5820
|
-
processed_at: number2().int().optional()
|
|
5821
|
-
}).strict();
|
|
5822
|
-
});
|
|
5823
|
-
|
|
5824
|
-
// ../shared/src/d1/index.ts
|
|
5825
|
-
var init_d1 = __esm(() => {
|
|
5826
|
-
init_repository();
|
|
5827
|
-
init_schemas3();
|
|
5828
|
-
});
|
|
5829
5775
|
// ../shared/src/service-bindings.ts
|
|
5830
5776
|
var InternalAuthKeyFields, D1_READ_AUTH_KEY_FIELDS, D1_WRITE_AUTH_KEY_FIELDS, TRADE_EXECUTE_AUTH_KEY_FIELDS, TRADE_READ_AUTH_KEY_FIELDS, TELEGRAM_ALERT_AUTH_KEY_FIELDS, WALLET_EXECUTE_AUTH_KEY_FIELDS, DASHBOARD_D1_READ_AUTH_KEY_FIELDS, DASHBOARD_TRADE_EXECUTE_AUTH_KEY_FIELDS, DASHBOARD_TELEGRAM_ALERT_AUTH_KEY_FIELDS;
|
|
5831
5777
|
var init_service_bindings = __esm(() => {
|
|
@@ -5883,6 +5829,7 @@ var init_service_bindings = __esm(() => {
|
|
|
5883
5829
|
InternalAuthKeyFields.DEFAULT
|
|
5884
5830
|
];
|
|
5885
5831
|
});
|
|
5832
|
+
|
|
5886
5833
|
// ../shared/src/colors.ts
|
|
5887
5834
|
var Colors, ConnectionStatusColor, WorkerStatusColor, LogLevelColor, AlertSeverityColor;
|
|
5888
5835
|
var init_colors = __esm(() => {
|
|
@@ -5931,17 +5878,224 @@ var init_colors = __esm(() => {
|
|
|
5931
5878
|
critical: Colors.error
|
|
5932
5879
|
};
|
|
5933
5880
|
});
|
|
5934
|
-
// ../shared/src/
|
|
5881
|
+
// ../shared/src/path-utils.ts
|
|
5935
5882
|
import {
|
|
5936
|
-
readFileSync,
|
|
5937
|
-
writeFileSync,
|
|
5938
5883
|
existsSync,
|
|
5939
5884
|
mkdirSync,
|
|
5940
|
-
|
|
5941
|
-
|
|
5885
|
+
readFileSync,
|
|
5886
|
+
writeFileSync,
|
|
5887
|
+
chmodSync
|
|
5942
5888
|
} from "fs";
|
|
5943
|
-
import { join } from "path";
|
|
5944
5889
|
import { homedir } from "os";
|
|
5890
|
+
import { dirname, join, resolve, sep } from "path";
|
|
5891
|
+
function createHooxPath(path) {
|
|
5892
|
+
return path;
|
|
5893
|
+
}
|
|
5894
|
+
function isInsideDir(child, parent) {
|
|
5895
|
+
const resolvedChild = resolve(child);
|
|
5896
|
+
const resolvedParent = resolve(parent);
|
|
5897
|
+
const cmpChild = process.platform === "win32" ? resolvedChild.toLowerCase() : resolvedChild;
|
|
5898
|
+
const cmpParent = process.platform === "win32" ? resolvedParent.toLowerCase() : resolvedParent;
|
|
5899
|
+
if (cmpChild === cmpParent)
|
|
5900
|
+
return true;
|
|
5901
|
+
const prefix = cmpParent.endsWith(sep) ? cmpParent : cmpParent + sep;
|
|
5902
|
+
return cmpChild.startsWith(prefix);
|
|
5903
|
+
}
|
|
5904
|
+
function getHooxHome() {
|
|
5905
|
+
try {
|
|
5906
|
+
const override = process.env.HOOX_HOME?.trim();
|
|
5907
|
+
if (override) {
|
|
5908
|
+
return createHooxPath(resolve(override));
|
|
5909
|
+
}
|
|
5910
|
+
const home = homedir();
|
|
5911
|
+
if (!home || home.length === 0) {
|
|
5912
|
+
return createHooxPath(resolve(process.cwd(), ".hoox"));
|
|
5913
|
+
}
|
|
5914
|
+
return createHooxPath(join(home, ".hoox"));
|
|
5915
|
+
} catch {
|
|
5916
|
+
return createHooxPath(resolve(process.cwd(), ".hoox"));
|
|
5917
|
+
}
|
|
5918
|
+
}
|
|
5919
|
+
function isHooxSetupRoot(dir) {
|
|
5920
|
+
if (!dir)
|
|
5921
|
+
return false;
|
|
5922
|
+
try {
|
|
5923
|
+
const root = resolve(dir);
|
|
5924
|
+
if (!existsSync(join(root, "packages", "cli", "package.json"))) {
|
|
5925
|
+
return false;
|
|
5926
|
+
}
|
|
5927
|
+
return existsSync(join(root, "wrangler.jsonc")) || existsSync(join(root, "wrangler.jsonc.example")) || existsSync(join(root, "workers")) || existsSync(join(root, ".gitmodules"));
|
|
5928
|
+
} catch {
|
|
5929
|
+
return false;
|
|
5930
|
+
}
|
|
5931
|
+
}
|
|
5932
|
+
function getRememberedMonorepoPath() {
|
|
5933
|
+
return resolveHooxPath("config/monorepo.json");
|
|
5934
|
+
}
|
|
5935
|
+
function getRememberedMonorepoRoot() {
|
|
5936
|
+
try {
|
|
5937
|
+
const path = getRememberedMonorepoPath();
|
|
5938
|
+
if (!existsSync(path))
|
|
5939
|
+
return null;
|
|
5940
|
+
const raw = readFileSync(path, "utf-8");
|
|
5941
|
+
const data = JSON.parse(raw);
|
|
5942
|
+
if (!data.root || typeof data.root !== "string")
|
|
5943
|
+
return null;
|
|
5944
|
+
const resolved = resolve(data.root);
|
|
5945
|
+
return isHooxSetupRoot(resolved) ? resolved : null;
|
|
5946
|
+
} catch {
|
|
5947
|
+
return null;
|
|
5948
|
+
}
|
|
5949
|
+
}
|
|
5950
|
+
function rememberMonorepoRoot(root) {
|
|
5951
|
+
try {
|
|
5952
|
+
const resolved = resolve(root);
|
|
5953
|
+
if (!isHooxSetupRoot(resolved))
|
|
5954
|
+
return false;
|
|
5955
|
+
const configDir = getHooxConfigDir();
|
|
5956
|
+
mkdirSync(configDir, { recursive: true, mode: 448 });
|
|
5957
|
+
try {
|
|
5958
|
+
chmodSync(configDir, 448);
|
|
5959
|
+
} catch {}
|
|
5960
|
+
const payload = {
|
|
5961
|
+
root: resolved,
|
|
5962
|
+
updatedAt: new Date().toISOString()
|
|
5963
|
+
};
|
|
5964
|
+
const path = getRememberedMonorepoPath();
|
|
5965
|
+
writeFileSync(path, JSON.stringify(payload, null, 2) + `
|
|
5966
|
+
`, {
|
|
5967
|
+
mode: 384
|
|
5968
|
+
});
|
|
5969
|
+
try {
|
|
5970
|
+
chmodSync(path, 384);
|
|
5971
|
+
} catch {}
|
|
5972
|
+
return true;
|
|
5973
|
+
} catch {
|
|
5974
|
+
return false;
|
|
5975
|
+
}
|
|
5976
|
+
}
|
|
5977
|
+
function findHooxSetupRoot(startDir = process.cwd()) {
|
|
5978
|
+
let dir = resolve(startDir);
|
|
5979
|
+
for (;; ) {
|
|
5980
|
+
if (isHooxSetupRoot(dir))
|
|
5981
|
+
return dir;
|
|
5982
|
+
const parent = dirname(dir);
|
|
5983
|
+
if (parent === dir)
|
|
5984
|
+
return null;
|
|
5985
|
+
dir = parent;
|
|
5986
|
+
}
|
|
5987
|
+
}
|
|
5988
|
+
function resolveHooxRuntimeRoot(options) {
|
|
5989
|
+
const env = options?.env ?? process.env;
|
|
5990
|
+
const cwd = resolve(options?.cwd ?? process.cwd());
|
|
5991
|
+
const globalRepo = getHooxRepoPath();
|
|
5992
|
+
const remembered = options?.skipRemembered ? null : getRememberedMonorepoRoot();
|
|
5993
|
+
const envRepo = env.HOOX_REPO?.trim();
|
|
5994
|
+
if (envRepo) {
|
|
5995
|
+
const resolved = resolve(envRepo);
|
|
5996
|
+
if (isHooxSetupRoot(resolved)) {
|
|
5997
|
+
return {
|
|
5998
|
+
root: resolved,
|
|
5999
|
+
source: "env",
|
|
6000
|
+
checked: {
|
|
6001
|
+
env: resolved,
|
|
6002
|
+
cwd: findHooxSetupRoot(cwd),
|
|
6003
|
+
remembered,
|
|
6004
|
+
global: globalRepo
|
|
6005
|
+
}
|
|
6006
|
+
};
|
|
6007
|
+
}
|
|
6008
|
+
return {
|
|
6009
|
+
root: null,
|
|
6010
|
+
source: "env",
|
|
6011
|
+
checked: {
|
|
6012
|
+
env: resolved,
|
|
6013
|
+
cwd: findHooxSetupRoot(cwd),
|
|
6014
|
+
remembered,
|
|
6015
|
+
global: globalRepo
|
|
6016
|
+
}
|
|
6017
|
+
};
|
|
6018
|
+
}
|
|
6019
|
+
const local = findHooxSetupRoot(cwd);
|
|
6020
|
+
if (local) {
|
|
6021
|
+
return {
|
|
6022
|
+
root: local,
|
|
6023
|
+
source: "cwd",
|
|
6024
|
+
checked: { cwd: local, remembered, global: globalRepo }
|
|
6025
|
+
};
|
|
6026
|
+
}
|
|
6027
|
+
if (remembered) {
|
|
6028
|
+
return {
|
|
6029
|
+
root: remembered,
|
|
6030
|
+
source: "remembered",
|
|
6031
|
+
checked: { cwd: null, remembered, global: globalRepo }
|
|
6032
|
+
};
|
|
6033
|
+
}
|
|
6034
|
+
if (isHooxSetupRoot(globalRepo)) {
|
|
6035
|
+
return {
|
|
6036
|
+
root: globalRepo,
|
|
6037
|
+
source: "global",
|
|
6038
|
+
checked: { cwd: null, remembered: null, global: globalRepo }
|
|
6039
|
+
};
|
|
6040
|
+
}
|
|
6041
|
+
return {
|
|
6042
|
+
root: null,
|
|
6043
|
+
source: "none",
|
|
6044
|
+
checked: { cwd: null, remembered: null, global: globalRepo }
|
|
6045
|
+
};
|
|
6046
|
+
}
|
|
6047
|
+
function getTuiEntryCandidates(runtimeRoot) {
|
|
6048
|
+
const root = resolve(runtimeRoot);
|
|
6049
|
+
return [
|
|
6050
|
+
join(root, "packages", "tui", "src", "main.tsx"),
|
|
6051
|
+
join(root, "packages", "tui", "dist", "main.js"),
|
|
6052
|
+
join(root, "packages", "tui", "src", "main.ts")
|
|
6053
|
+
];
|
|
6054
|
+
}
|
|
6055
|
+
function resolveHooxPath(relativePath) {
|
|
6056
|
+
if (!relativePath || typeof relativePath !== "string") {
|
|
6057
|
+
throw new Error("relativePath must be a non-empty string");
|
|
6058
|
+
}
|
|
6059
|
+
if (relativePath.includes("..")) {
|
|
6060
|
+
throw new Error(`Path traversal detected in relativePath: "${relativePath}"`);
|
|
6061
|
+
}
|
|
6062
|
+
const normalizedPath = relativePath.replace(/\\/g, "/");
|
|
6063
|
+
const hooxHome = getHooxHome();
|
|
6064
|
+
const fullPath = join(hooxHome, normalizedPath);
|
|
6065
|
+
const resolvedPath = resolve(fullPath);
|
|
6066
|
+
const resolvedHome = resolve(hooxHome);
|
|
6067
|
+
if (!isInsideDir(resolvedPath, resolvedHome)) {
|
|
6068
|
+
throw new Error(`Resolved path "${resolvedPath}" is outside Hoox home directory`);
|
|
6069
|
+
}
|
|
6070
|
+
return createHooxPath(resolvedPath);
|
|
6071
|
+
}
|
|
6072
|
+
function getHooxRepoPath() {
|
|
6073
|
+
return resolveHooxPath("repo");
|
|
6074
|
+
}
|
|
6075
|
+
function getHooxConfigDir() {
|
|
6076
|
+
return resolveHooxPath("config");
|
|
6077
|
+
}
|
|
6078
|
+
function getHooxWranglerPath() {
|
|
6079
|
+
return resolveHooxPath("config/wrangler.jsonc");
|
|
6080
|
+
}
|
|
6081
|
+
var init_path_utils = () => {};
|
|
6082
|
+
|
|
6083
|
+
// ../shared/src/config.ts
|
|
6084
|
+
import {
|
|
6085
|
+
readFileSync as readFileSync2,
|
|
6086
|
+
writeFileSync as writeFileSync2,
|
|
6087
|
+
existsSync as existsSync2,
|
|
6088
|
+
mkdirSync as mkdirSync2,
|
|
6089
|
+
chmodSync as chmodSync2,
|
|
6090
|
+
statSync
|
|
6091
|
+
} from "fs";
|
|
6092
|
+
import { join as join2 } from "path";
|
|
6093
|
+
function hooxDir() {
|
|
6094
|
+
return getHooxHome();
|
|
6095
|
+
}
|
|
6096
|
+
function configPath() {
|
|
6097
|
+
return join2(hooxDir(), "config.json");
|
|
6098
|
+
}
|
|
5945
6099
|
function readConfigSync() {
|
|
5946
6100
|
const envConfig = {
|
|
5947
6101
|
apiUrl: process.env.HOOX_API_URL,
|
|
@@ -5949,8 +6103,8 @@ function readConfigSync() {
|
|
|
5949
6103
|
};
|
|
5950
6104
|
let fileConfig = {};
|
|
5951
6105
|
try {
|
|
5952
|
-
if (
|
|
5953
|
-
fileConfig = JSON.parse(
|
|
6106
|
+
if (existsSync2(configPath())) {
|
|
6107
|
+
fileConfig = JSON.parse(readFileSync2(configPath(), "utf-8"));
|
|
5954
6108
|
}
|
|
5955
6109
|
} catch {}
|
|
5956
6110
|
return {
|
|
@@ -5959,49 +6113,44 @@ function readConfigSync() {
|
|
|
5959
6113
|
...Object.fromEntries(Object.entries(envConfig).filter(([_, v]) => v !== undefined))
|
|
5960
6114
|
};
|
|
5961
6115
|
}
|
|
5962
|
-
function ensureHooxDirSecure(dir =
|
|
5963
|
-
if (!
|
|
5964
|
-
|
|
6116
|
+
function ensureHooxDirSecure(dir = hooxDir()) {
|
|
6117
|
+
if (!existsSync2(dir)) {
|
|
6118
|
+
mkdirSync2(dir, { recursive: true, mode: HOOX_DIR_MODE });
|
|
5965
6119
|
}
|
|
5966
6120
|
try {
|
|
5967
|
-
|
|
6121
|
+
chmodSync2(dir, HOOX_DIR_MODE);
|
|
5968
6122
|
} catch {}
|
|
5969
6123
|
}
|
|
5970
6124
|
function writeSecureFileSync(filePath, contents, mode = HOOX_CONFIG_FILE_MODE) {
|
|
5971
|
-
|
|
6125
|
+
writeFileSync2(filePath, contents, { encoding: "utf-8", mode });
|
|
5972
6126
|
try {
|
|
5973
|
-
|
|
6127
|
+
chmodSync2(filePath, mode);
|
|
5974
6128
|
} catch {}
|
|
5975
6129
|
}
|
|
5976
6130
|
function isUnixModeGroupOrWorldAccessible(mode) {
|
|
5977
6131
|
return (mode & 63) !== 0;
|
|
5978
6132
|
}
|
|
5979
|
-
function isConfigWorldOrGroupReadable(filePath =
|
|
6133
|
+
function isConfigWorldOrGroupReadable(filePath = configPath()) {
|
|
5980
6134
|
try {
|
|
5981
|
-
if (!
|
|
6135
|
+
if (!existsSync2(filePath))
|
|
5982
6136
|
return false;
|
|
5983
6137
|
return isUnixModeGroupOrWorldAccessible(statSync(filePath).mode & 511);
|
|
5984
6138
|
} catch {
|
|
5985
6139
|
return false;
|
|
5986
6140
|
}
|
|
5987
6141
|
}
|
|
5988
|
-
function formatConfigPermissionWarning(filePath =
|
|
6142
|
+
function formatConfigPermissionWarning(filePath = configPath()) {
|
|
5989
6143
|
if (!isConfigWorldOrGroupReadable(filePath))
|
|
5990
6144
|
return null;
|
|
5991
6145
|
return `Warning: ${filePath} is group/world-accessible. ` + `Run: chmod 600 ${filePath} (and chmod 700 on the parent dir). ` + `This file may contain apiToken / operator secrets.`;
|
|
5992
6146
|
}
|
|
5993
6147
|
function writeConfigSync(config) {
|
|
5994
|
-
|
|
5995
|
-
|
|
5996
|
-
writeSecureFileSync(CONFIG_PATH, JSON.stringify(config, null, 2), HOOX_CONFIG_FILE_MODE);
|
|
5997
|
-
} catch (err) {
|
|
5998
|
-
console.error("Failed to write config:", err);
|
|
5999
|
-
}
|
|
6148
|
+
ensureHooxDirSecure(hooxDir());
|
|
6149
|
+
writeSecureFileSync(configPath(), JSON.stringify(config, null, 2), HOOX_CONFIG_FILE_MODE);
|
|
6000
6150
|
}
|
|
6001
|
-
var
|
|
6151
|
+
var HOOX_DIR_MODE = 448, HOOX_CONFIG_FILE_MODE = 384, DEFAULT_CONFIG, VALID_TRANSPORTS;
|
|
6002
6152
|
var init_config = __esm(() => {
|
|
6003
|
-
|
|
6004
|
-
CONFIG_PATH = join(HOX_DIR, "config.json");
|
|
6153
|
+
init_path_utils();
|
|
6005
6154
|
DEFAULT_CONFIG = {
|
|
6006
6155
|
apiUrl: "http://localhost:8787",
|
|
6007
6156
|
apiToken: "",
|
|
@@ -6197,6 +6346,7 @@ var init_api_client = __esm(() => {
|
|
|
6197
6346
|
// ../shared/src/sse.ts
|
|
6198
6347
|
function subscribeSSE(path, callback, onStatus, options) {
|
|
6199
6348
|
let aborted = false;
|
|
6349
|
+
const ac = new AbortController;
|
|
6200
6350
|
const profile = options?.transport ?? (options?.transportEnv ? resolveOperatorTransportProfile(options.transportEnv) : resolveOperatorTransportProfile());
|
|
6201
6351
|
const run = async () => {
|
|
6202
6352
|
let attempt = 0;
|
|
@@ -6207,7 +6357,8 @@ function subscribeSSE(path, callback, onStatus, options) {
|
|
|
6207
6357
|
headers: {
|
|
6208
6358
|
Accept: "text/event-stream",
|
|
6209
6359
|
...buildOperatorAuthHeaders(profile)
|
|
6210
|
-
}
|
|
6360
|
+
},
|
|
6361
|
+
signal: ac.signal
|
|
6211
6362
|
});
|
|
6212
6363
|
if (!response.ok || !response.body) {
|
|
6213
6364
|
throw new Error(`SSE connection failed: HTTP ${response.status}`);
|
|
@@ -6219,17 +6370,21 @@ function subscribeSSE(path, callback, onStatus, options) {
|
|
|
6219
6370
|
let buffer = "";
|
|
6220
6371
|
while (!aborted) {
|
|
6221
6372
|
const { done, value } = await reader.read();
|
|
6222
|
-
if (done)
|
|
6223
|
-
|
|
6373
|
+
if (done) {
|
|
6374
|
+
throw new Error("SSE stream ended");
|
|
6375
|
+
}
|
|
6224
6376
|
buffer += decoder.decode(value, { stream: true });
|
|
6225
6377
|
const lines = buffer.split(`
|
|
6226
6378
|
`);
|
|
6227
6379
|
buffer = lines.pop() || "";
|
|
6228
6380
|
for (const line of lines) {
|
|
6229
6381
|
const trimmed = line.trim();
|
|
6230
|
-
if (trimmed.startsWith("data:
|
|
6382
|
+
if (trimmed.startsWith("data:")) {
|
|
6383
|
+
const jsonText = trimmed.slice(5).replace(/^\s/, "");
|
|
6384
|
+
if (!jsonText)
|
|
6385
|
+
continue;
|
|
6231
6386
|
try {
|
|
6232
|
-
const parsed = JSON.parse(
|
|
6387
|
+
const parsed = JSON.parse(jsonText);
|
|
6233
6388
|
callback(parsed);
|
|
6234
6389
|
} catch {}
|
|
6235
6390
|
}
|
|
@@ -6241,7 +6396,18 @@ function subscribeSSE(path, callback, onStatus, options) {
|
|
|
6241
6396
|
onStatus?.("reconnecting");
|
|
6242
6397
|
const delay = Math.min(RECONNECT_BASE_MS * Math.pow(2, attempt), RECONNECT_MAX_MS);
|
|
6243
6398
|
attempt++;
|
|
6244
|
-
await new Promise((resolve) =>
|
|
6399
|
+
await new Promise((resolve) => {
|
|
6400
|
+
const timer = setTimeout(resolve, delay);
|
|
6401
|
+
const onAbort = () => {
|
|
6402
|
+
clearTimeout(timer);
|
|
6403
|
+
resolve();
|
|
6404
|
+
};
|
|
6405
|
+
if (ac.signal.aborted) {
|
|
6406
|
+
onAbort();
|
|
6407
|
+
return;
|
|
6408
|
+
}
|
|
6409
|
+
ac.signal.addEventListener("abort", onAbort, { once: true });
|
|
6410
|
+
});
|
|
6245
6411
|
}
|
|
6246
6412
|
}
|
|
6247
6413
|
if (!aborted) {
|
|
@@ -6252,6 +6418,7 @@ function subscribeSSE(path, callback, onStatus, options) {
|
|
|
6252
6418
|
return {
|
|
6253
6419
|
abort: () => {
|
|
6254
6420
|
aborted = true;
|
|
6421
|
+
ac.abort();
|
|
6255
6422
|
}
|
|
6256
6423
|
};
|
|
6257
6424
|
}
|
|
@@ -6260,202 +6427,11 @@ var init_sse = __esm(() => {
|
|
|
6260
6427
|
init_operator_transport();
|
|
6261
6428
|
});
|
|
6262
6429
|
|
|
6263
|
-
// ../shared/src/path-utils.ts
|
|
6264
|
-
import {
|
|
6265
|
-
existsSync as existsSync2,
|
|
6266
|
-
mkdirSync as mkdirSync2,
|
|
6267
|
-
readFileSync as readFileSync2,
|
|
6268
|
-
writeFileSync as writeFileSync2,
|
|
6269
|
-
chmodSync as chmodSync2
|
|
6270
|
-
} from "fs";
|
|
6271
|
-
import { homedir as homedir2 } from "os";
|
|
6272
|
-
import { dirname, join as join2, resolve } from "path";
|
|
6273
|
-
function createHooxPath(path) {
|
|
6274
|
-
return path;
|
|
6275
|
-
}
|
|
6276
|
-
function getHooxHome() {
|
|
6277
|
-
try {
|
|
6278
|
-
const override = process.env.HOOX_HOME?.trim();
|
|
6279
|
-
if (override) {
|
|
6280
|
-
return createHooxPath(resolve(override));
|
|
6281
|
-
}
|
|
6282
|
-
const home = homedir2();
|
|
6283
|
-
if (!home || home.length === 0) {
|
|
6284
|
-
return createHooxPath(resolve(process.cwd(), ".hoox"));
|
|
6285
|
-
}
|
|
6286
|
-
return createHooxPath(join2(home, ".hoox"));
|
|
6287
|
-
} catch {
|
|
6288
|
-
return createHooxPath(resolve(process.cwd(), ".hoox"));
|
|
6289
|
-
}
|
|
6290
|
-
}
|
|
6291
|
-
function isHooxSetupRoot(dir) {
|
|
6292
|
-
if (!dir)
|
|
6293
|
-
return false;
|
|
6294
|
-
try {
|
|
6295
|
-
const root = resolve(dir);
|
|
6296
|
-
if (!existsSync2(join2(root, "packages", "cli", "package.json"))) {
|
|
6297
|
-
return false;
|
|
6298
|
-
}
|
|
6299
|
-
return existsSync2(join2(root, "wrangler.jsonc")) || existsSync2(join2(root, "wrangler.jsonc.example")) || existsSync2(join2(root, "workers")) || existsSync2(join2(root, ".gitmodules"));
|
|
6300
|
-
} catch {
|
|
6301
|
-
return false;
|
|
6302
|
-
}
|
|
6303
|
-
}
|
|
6304
|
-
function getRememberedMonorepoPath() {
|
|
6305
|
-
return resolveHooxPath("config/monorepo.json");
|
|
6306
|
-
}
|
|
6307
|
-
function getRememberedMonorepoRoot() {
|
|
6308
|
-
try {
|
|
6309
|
-
const path = getRememberedMonorepoPath();
|
|
6310
|
-
if (!existsSync2(path))
|
|
6311
|
-
return null;
|
|
6312
|
-
const raw = readFileSync2(path, "utf-8");
|
|
6313
|
-
const data = JSON.parse(raw);
|
|
6314
|
-
if (!data.root || typeof data.root !== "string")
|
|
6315
|
-
return null;
|
|
6316
|
-
const resolved = resolve(data.root);
|
|
6317
|
-
return isHooxSetupRoot(resolved) ? resolved : null;
|
|
6318
|
-
} catch {
|
|
6319
|
-
return null;
|
|
6320
|
-
}
|
|
6321
|
-
}
|
|
6322
|
-
function rememberMonorepoRoot(root) {
|
|
6323
|
-
try {
|
|
6324
|
-
const resolved = resolve(root);
|
|
6325
|
-
if (!isHooxSetupRoot(resolved))
|
|
6326
|
-
return false;
|
|
6327
|
-
const configDir = getHooxConfigDir();
|
|
6328
|
-
mkdirSync2(configDir, { recursive: true, mode: 448 });
|
|
6329
|
-
try {
|
|
6330
|
-
chmodSync2(configDir, 448);
|
|
6331
|
-
} catch {}
|
|
6332
|
-
const payload = {
|
|
6333
|
-
root: resolved,
|
|
6334
|
-
updatedAt: new Date().toISOString()
|
|
6335
|
-
};
|
|
6336
|
-
const path = getRememberedMonorepoPath();
|
|
6337
|
-
writeFileSync2(path, JSON.stringify(payload, null, 2) + `
|
|
6338
|
-
`, {
|
|
6339
|
-
mode: 384
|
|
6340
|
-
});
|
|
6341
|
-
try {
|
|
6342
|
-
chmodSync2(path, 384);
|
|
6343
|
-
} catch {}
|
|
6344
|
-
return true;
|
|
6345
|
-
} catch {
|
|
6346
|
-
return false;
|
|
6347
|
-
}
|
|
6348
|
-
}
|
|
6349
|
-
function findHooxSetupRoot(startDir = process.cwd()) {
|
|
6350
|
-
let dir = resolve(startDir);
|
|
6351
|
-
for (;; ) {
|
|
6352
|
-
if (isHooxSetupRoot(dir))
|
|
6353
|
-
return dir;
|
|
6354
|
-
const parent = dirname(dir);
|
|
6355
|
-
if (parent === dir)
|
|
6356
|
-
return null;
|
|
6357
|
-
dir = parent;
|
|
6358
|
-
}
|
|
6359
|
-
}
|
|
6360
|
-
function resolveHooxRuntimeRoot(options) {
|
|
6361
|
-
const env = options?.env ?? process.env;
|
|
6362
|
-
const cwd = resolve(options?.cwd ?? process.cwd());
|
|
6363
|
-
const globalRepo = getHooxRepoPath();
|
|
6364
|
-
const remembered = options?.skipRemembered ? null : getRememberedMonorepoRoot();
|
|
6365
|
-
const envRepo = env.HOOX_REPO?.trim();
|
|
6366
|
-
if (envRepo) {
|
|
6367
|
-
const resolved = resolve(envRepo);
|
|
6368
|
-
if (isHooxSetupRoot(resolved)) {
|
|
6369
|
-
return {
|
|
6370
|
-
root: resolved,
|
|
6371
|
-
source: "env",
|
|
6372
|
-
checked: {
|
|
6373
|
-
env: resolved,
|
|
6374
|
-
cwd: findHooxSetupRoot(cwd),
|
|
6375
|
-
remembered,
|
|
6376
|
-
global: globalRepo
|
|
6377
|
-
}
|
|
6378
|
-
};
|
|
6379
|
-
}
|
|
6380
|
-
return {
|
|
6381
|
-
root: null,
|
|
6382
|
-
source: "env",
|
|
6383
|
-
checked: {
|
|
6384
|
-
env: resolved,
|
|
6385
|
-
cwd: findHooxSetupRoot(cwd),
|
|
6386
|
-
remembered,
|
|
6387
|
-
global: globalRepo
|
|
6388
|
-
}
|
|
6389
|
-
};
|
|
6390
|
-
}
|
|
6391
|
-
const local = findHooxSetupRoot(cwd);
|
|
6392
|
-
if (local) {
|
|
6393
|
-
return {
|
|
6394
|
-
root: local,
|
|
6395
|
-
source: "cwd",
|
|
6396
|
-
checked: { cwd: local, remembered, global: globalRepo }
|
|
6397
|
-
};
|
|
6398
|
-
}
|
|
6399
|
-
if (remembered) {
|
|
6400
|
-
return {
|
|
6401
|
-
root: remembered,
|
|
6402
|
-
source: "remembered",
|
|
6403
|
-
checked: { cwd: null, remembered, global: globalRepo }
|
|
6404
|
-
};
|
|
6405
|
-
}
|
|
6406
|
-
if (isHooxSetupRoot(globalRepo)) {
|
|
6407
|
-
return {
|
|
6408
|
-
root: globalRepo,
|
|
6409
|
-
source: "global",
|
|
6410
|
-
checked: { cwd: null, remembered: null, global: globalRepo }
|
|
6411
|
-
};
|
|
6412
|
-
}
|
|
6413
|
-
return {
|
|
6414
|
-
root: null,
|
|
6415
|
-
source: "none",
|
|
6416
|
-
checked: { cwd: null, remembered: null, global: globalRepo }
|
|
6417
|
-
};
|
|
6418
|
-
}
|
|
6419
|
-
function getTuiEntryCandidates(runtimeRoot) {
|
|
6420
|
-
const root = resolve(runtimeRoot);
|
|
6421
|
-
return [
|
|
6422
|
-
join2(root, "packages", "tui", "src", "main.tsx"),
|
|
6423
|
-
join2(root, "packages", "tui", "dist", "main.js"),
|
|
6424
|
-
join2(root, "packages", "tui", "src", "main.ts")
|
|
6425
|
-
];
|
|
6426
|
-
}
|
|
6427
|
-
function resolveHooxPath(relativePath) {
|
|
6428
|
-
if (!relativePath || typeof relativePath !== "string") {
|
|
6429
|
-
throw new Error("relativePath must be a non-empty string");
|
|
6430
|
-
}
|
|
6431
|
-
if (relativePath.includes("..")) {
|
|
6432
|
-
throw new Error(`Path traversal detected in relativePath: "${relativePath}"`);
|
|
6433
|
-
}
|
|
6434
|
-
const normalizedPath = relativePath.replace(/\\/g, "/");
|
|
6435
|
-
const hooxHome = getHooxHome();
|
|
6436
|
-
const fullPath = join2(hooxHome, normalizedPath);
|
|
6437
|
-
const resolvedPath = resolve(fullPath);
|
|
6438
|
-
const resolvedHome = resolve(hooxHome);
|
|
6439
|
-
if (!resolvedPath.startsWith(resolvedHome)) {
|
|
6440
|
-
throw new Error(`Resolved path "${resolvedPath}" is outside Hoox home directory`);
|
|
6441
|
-
}
|
|
6442
|
-
return createHooxPath(resolvedPath);
|
|
6443
|
-
}
|
|
6444
|
-
function getHooxRepoPath() {
|
|
6445
|
-
return resolveHooxPath("repo");
|
|
6446
|
-
}
|
|
6447
|
-
function getHooxConfigDir() {
|
|
6448
|
-
return resolveHooxPath("config");
|
|
6449
|
-
}
|
|
6450
|
-
function getHooxWranglerPath() {
|
|
6451
|
-
return resolveHooxPath("config/wrangler.jsonc");
|
|
6452
|
-
}
|
|
6453
|
-
var init_path_utils = () => {};
|
|
6454
|
-
|
|
6455
6430
|
// ../shared/src/session.ts
|
|
6456
6431
|
var SessionStateFileSchema, DEFAULT_SESSION, VALID_VIEW_IDS;
|
|
6457
6432
|
var init_session = __esm(() => {
|
|
6458
6433
|
init_path_utils();
|
|
6434
|
+
init_types();
|
|
6459
6435
|
init_zod();
|
|
6460
6436
|
SessionStateFileSchema = object({
|
|
6461
6437
|
activeView: string2().optional(),
|
|
@@ -6474,24 +6450,7 @@ var init_session = __esm(() => {
|
|
|
6474
6450
|
lastData: 0,
|
|
6475
6451
|
savedAt: new Date().toISOString()
|
|
6476
6452
|
};
|
|
6477
|
-
VALID_VIEW_IDS = new Set(
|
|
6478
|
-
"dashboard",
|
|
6479
|
-
"workers",
|
|
6480
|
-
"worker-detail",
|
|
6481
|
-
"trade-monitor",
|
|
6482
|
-
"logs-viewer",
|
|
6483
|
-
"service-manager",
|
|
6484
|
-
"config-editor",
|
|
6485
|
-
"setup-wizard",
|
|
6486
|
-
"settings",
|
|
6487
|
-
"queue-depth",
|
|
6488
|
-
"kv-viewer",
|
|
6489
|
-
"secrets-viewer",
|
|
6490
|
-
"db-query",
|
|
6491
|
-
"ai-chat",
|
|
6492
|
-
"edge-topology",
|
|
6493
|
-
"worker-settings"
|
|
6494
|
-
]);
|
|
6453
|
+
VALID_VIEW_IDS = new Set(VIEW_IDS);
|
|
6495
6454
|
});
|
|
6496
6455
|
// ../shared/src/dashboard-manifest.ts
|
|
6497
6456
|
import { existsSync as existsSync3, readdirSync, readFileSync as readFileSync3 } from "fs";
|
|
@@ -7018,7 +6977,7 @@ var init_presets = __esm(() => {
|
|
|
7018
6977
|
label: "OpenAI (AI Agent)",
|
|
7019
6978
|
workerName: "agent-worker",
|
|
7020
6979
|
secrets: {
|
|
7021
|
-
|
|
6980
|
+
OPENAI_API_KEY: "OpenAI API Key"
|
|
7022
6981
|
}
|
|
7023
6982
|
},
|
|
7024
6983
|
{
|
|
@@ -7026,7 +6985,7 @@ var init_presets = __esm(() => {
|
|
|
7026
6985
|
label: "Anthropic (AI Agent)",
|
|
7027
6986
|
workerName: "agent-worker",
|
|
7028
6987
|
secrets: {
|
|
7029
|
-
|
|
6988
|
+
ANTHROPIC_API_KEY: "Anthropic API Key"
|
|
7030
6989
|
}
|
|
7031
6990
|
},
|
|
7032
6991
|
{
|
|
@@ -7034,7 +6993,7 @@ var init_presets = __esm(() => {
|
|
|
7034
6993
|
label: "Google AI (AI Agent)",
|
|
7035
6994
|
workerName: "agent-worker",
|
|
7036
6995
|
secrets: {
|
|
7037
|
-
|
|
6996
|
+
GOOGLE_API_KEY: "Google AI API Key"
|
|
7038
6997
|
}
|
|
7039
6998
|
},
|
|
7040
6999
|
{
|
|
@@ -7197,8 +7156,9 @@ class WizardEngine {
|
|
|
7197
7156
|
const previousStep = STEP_ORDER[currentIdx - 1];
|
|
7198
7157
|
if (previousStep === undefined)
|
|
7199
7158
|
return;
|
|
7159
|
+
const leaving = this.state.step;
|
|
7200
7160
|
this.state.step = previousStep;
|
|
7201
|
-
this.state.completedSteps = this.state.completedSteps.filter((s) => s !==
|
|
7161
|
+
this.state.completedSteps = this.state.completedSteps.filter((s) => s !== leaving && STEP_ORDER.indexOf(s) < STEP_ORDER.indexOf(previousStep));
|
|
7202
7162
|
}
|
|
7203
7163
|
this.state.updatedAt = Date.now();
|
|
7204
7164
|
}
|
|
@@ -7208,9 +7168,15 @@ class WizardEngine {
|
|
|
7208
7168
|
buildConfig() {
|
|
7209
7169
|
const cf = this.state.cloudflareConfig;
|
|
7210
7170
|
const workers = {};
|
|
7171
|
+
const enabled = new Set(this.state.selectedWorkers);
|
|
7172
|
+
for (const key of this.state.selectedIntegrations) {
|
|
7173
|
+
const integration = INTEGRATIONS.find((i) => i.key === key);
|
|
7174
|
+
if (integration?.workerName)
|
|
7175
|
+
enabled.add(integration.workerName);
|
|
7176
|
+
}
|
|
7211
7177
|
for (const [name, baseCfg] of Object.entries(BASE_WORKERS)) {
|
|
7212
7178
|
workers[name] = {
|
|
7213
|
-
enabled:
|
|
7179
|
+
enabled: enabled.has(name),
|
|
7214
7180
|
path: baseCfg.path,
|
|
7215
7181
|
vars: { ...baseCfg.vars },
|
|
7216
7182
|
secrets: [...BASE_SECRETS[name] ?? []]
|
|
@@ -7270,7 +7236,6 @@ class WizardEngine {
|
|
|
7270
7236
|
vectorizeIndexes: []
|
|
7271
7237
|
};
|
|
7272
7238
|
const allWorkers = [
|
|
7273
|
-
...Object.keys(BASE_WORKERS),
|
|
7274
7239
|
...this.state.selectedWorkers,
|
|
7275
7240
|
...this.state.selectedIntegrations.map((k) => {
|
|
7276
7241
|
const i = INTEGRATIONS.find((i) => i.key === k);
|
|
@@ -7289,7 +7254,7 @@ class WizardEngine {
|
|
|
7289
7254
|
}
|
|
7290
7255
|
if (workerSet.has("hoox") || workerSet.has("telegram-worker")) {
|
|
7291
7256
|
plan.vectorizeIndexes = plan.vectorizeIndexes ?? [];
|
|
7292
|
-
plan.vectorizeIndexes.push("
|
|
7257
|
+
plan.vectorizeIndexes.push("my-rag-index");
|
|
7293
7258
|
}
|
|
7294
7259
|
plan.d1Databases = [...new Set(plan.d1Databases)];
|
|
7295
7260
|
plan.kvNamespaces = [...new Set(plan.kvNamespaces)];
|
|
@@ -7696,7 +7661,10 @@ var init_registry = __esm(() => {
|
|
|
7696
7661
|
INTERNAL_KEY_BINDING: {
|
|
7697
7662
|
type: "secret",
|
|
7698
7663
|
description: "Inter-worker auth key"
|
|
7699
|
-
}
|
|
7664
|
+
},
|
|
7665
|
+
OPENAI_API_KEY: { type: "secret", description: "OpenAI API key" },
|
|
7666
|
+
ANTHROPIC_API_KEY: { type: "secret", description: "Anthropic API key" },
|
|
7667
|
+
GOOGLE_API_KEY: { type: "secret", description: "Google AI API key" }
|
|
7700
7668
|
},
|
|
7701
7669
|
services: [
|
|
7702
7670
|
{
|
|
@@ -9294,12 +9262,15 @@ var init_main = __esm(() => {
|
|
|
9294
9262
|
});
|
|
9295
9263
|
|
|
9296
9264
|
// ../shared/src/schemas/validators.ts
|
|
9265
|
+
function parseJsoncDocument(content) {
|
|
9266
|
+
const errors = [];
|
|
9267
|
+
const value = parse5(content, errors, { allowTrailingComma: true });
|
|
9268
|
+
return { value, errors };
|
|
9269
|
+
}
|
|
9297
9270
|
function validateWranglerJsonc(workerName, manifest, jsoncContent) {
|
|
9298
9271
|
const errors = [];
|
|
9299
|
-
|
|
9300
|
-
|
|
9301
|
-
parsed = parse5(jsoncContent);
|
|
9302
|
-
} catch {
|
|
9272
|
+
const { value: parsed, errors: parseErrors } = parseJsoncDocument(jsoncContent);
|
|
9273
|
+
if (parseErrors.length > 0) {
|
|
9303
9274
|
errors.push({
|
|
9304
9275
|
worker: workerName,
|
|
9305
9276
|
severity: "error",
|
|
@@ -9330,7 +9301,7 @@ function validateWranglerJsonc(workerName, manifest, jsoncContent) {
|
|
|
9330
9301
|
}
|
|
9331
9302
|
}
|
|
9332
9303
|
for (const [name, def] of Object.entries(manifest.vars)) {
|
|
9333
|
-
if (def.type === "secret" && !name.endsWith("_BINDING") && !name.endsWith("_SECRET") && !name.startsWith("CLOUDFLARE_") && name !== "TELEGRAM_SECRET_TOKEN" && name !== "TELEGRAM_ALLOWED_CHAT_IDS" && name !== "AUTHORIZED_CHAT_IDS" && name !== "MAILGUN_API_KEY" && name !== "EMAIL_SCAN_SUBJECT" && name !== "DASHBOARD_USER" && name !== "DASHBOARD_PASS" && name !== "SESSION_SECRET" && name !== "AGENT_INTERNAL_KEY") {
|
|
9304
|
+
if (def.type === "secret" && !name.endsWith("_BINDING") && !name.endsWith("_SECRET") && !name.startsWith("CLOUDFLARE_") && name !== "TELEGRAM_SECRET_TOKEN" && name !== "TELEGRAM_ALLOWED_CHAT_IDS" && name !== "AUTHORIZED_CHAT_IDS" && name !== "MAILGUN_API_KEY" && name !== "EMAIL_SCAN_SUBJECT" && name !== "DASHBOARD_USER" && name !== "DASHBOARD_PASS" && name !== "SESSION_SECRET" && name !== "AGENT_INTERNAL_KEY" && name !== "OPENAI_API_KEY" && name !== "ANTHROPIC_API_KEY" && name !== "GOOGLE_API_KEY") {
|
|
9334
9305
|
errors.push({
|
|
9335
9306
|
worker: workerName,
|
|
9336
9307
|
severity: "warning",
|
|
@@ -9376,10 +9347,8 @@ function validateWranglerJsonc(workerName, manifest, jsoncContent) {
|
|
|
9376
9347
|
}
|
|
9377
9348
|
function validateRootSecrets(workerName, manifest, rootJsoncContent) {
|
|
9378
9349
|
const errors = [];
|
|
9379
|
-
|
|
9380
|
-
|
|
9381
|
-
parsed = parse5(rootJsoncContent);
|
|
9382
|
-
} catch {
|
|
9350
|
+
const { value: parsed, errors: parseErrors } = parseJsoncDocument(rootJsoncContent);
|
|
9351
|
+
if (parseErrors.length > 0) {
|
|
9383
9352
|
errors.push({
|
|
9384
9353
|
worker: workerName,
|
|
9385
9354
|
severity: "error",
|
|
@@ -9437,6 +9406,11 @@ function validateDevVars(workerName, manifest, devVarsContent) {
|
|
|
9437
9406
|
}
|
|
9438
9407
|
return errors;
|
|
9439
9408
|
}
|
|
9409
|
+
function queueProducerBinding(queue) {
|
|
9410
|
+
if (queue === "trade-execution")
|
|
9411
|
+
return "TRADE_QUEUE";
|
|
9412
|
+
return queue.replace(/[^A-Za-z0-9]+/g, "_").toUpperCase();
|
|
9413
|
+
}
|
|
9440
9414
|
function generateWranglerJsonc(manifest) {
|
|
9441
9415
|
const parts = [];
|
|
9442
9416
|
parts.push(`{`);
|
|
@@ -9503,21 +9477,29 @@ function generateWranglerJsonc(manifest) {
|
|
|
9503
9477
|
parts.push(` ],`);
|
|
9504
9478
|
}
|
|
9505
9479
|
if (infra.queues) {
|
|
9506
|
-
|
|
9507
|
-
|
|
9508
|
-
|
|
9509
|
-
|
|
9510
|
-
|
|
9480
|
+
const producers = infra.queues.producer ?? [];
|
|
9481
|
+
const consumers = infra.queues.consumer ?? [];
|
|
9482
|
+
if (producers.length > 0 || consumers.length > 0) {
|
|
9483
|
+
const queueParts = [];
|
|
9484
|
+
if (producers.length > 0) {
|
|
9485
|
+
queueParts.push(` "producers": [`);
|
|
9486
|
+
for (const [i, q] of producers.entries()) {
|
|
9487
|
+
const comma = i < producers.length - 1 ? "," : "";
|
|
9488
|
+
queueParts.push(` { "queue": "${q}", "binding": "${queueProducerBinding(q)}" }${comma}`);
|
|
9489
|
+
}
|
|
9490
|
+
queueParts.push(consumers.length > 0 ? ` ],` : ` ]`);
|
|
9511
9491
|
}
|
|
9512
|
-
|
|
9513
|
-
|
|
9514
|
-
|
|
9515
|
-
|
|
9516
|
-
|
|
9517
|
-
|
|
9518
|
-
|
|
9492
|
+
if (consumers.length > 0) {
|
|
9493
|
+
queueParts.push(` "consumers": [`);
|
|
9494
|
+
for (const [i, q] of consumers.entries()) {
|
|
9495
|
+
const comma = i < consumers.length - 1 ? "," : "";
|
|
9496
|
+
queueParts.push(` { "queue": "${q}" }${comma}`);
|
|
9497
|
+
}
|
|
9498
|
+
queueParts.push(` ]`);
|
|
9519
9499
|
}
|
|
9520
|
-
parts.push(`
|
|
9500
|
+
parts.push(` "queues": {`);
|
|
9501
|
+
parts.push(...queueParts);
|
|
9502
|
+
parts.push(` },`);
|
|
9521
9503
|
}
|
|
9522
9504
|
}
|
|
9523
9505
|
if (infra.durableObjects && infra.durableObjects.length > 0) {
|
|
@@ -9552,7 +9534,7 @@ var init_validators = __esm(() => {
|
|
|
9552
9534
|
});
|
|
9553
9535
|
|
|
9554
9536
|
// ../shared/src/schemas/index.ts
|
|
9555
|
-
var
|
|
9537
|
+
var init_schemas3 = __esm(() => {
|
|
9556
9538
|
init_registry();
|
|
9557
9539
|
init_validators();
|
|
9558
9540
|
});
|
|
@@ -11923,7 +11905,6 @@ var init_src = __esm(() => {
|
|
|
11923
11905
|
init_kvUtils();
|
|
11924
11906
|
init_analytics();
|
|
11925
11907
|
init_health();
|
|
11926
|
-
init_d1();
|
|
11927
11908
|
init_service_bindings();
|
|
11928
11909
|
init_colors();
|
|
11929
11910
|
init_config();
|
|
@@ -11931,6 +11912,7 @@ var init_src = __esm(() => {
|
|
|
11931
11912
|
init_sse();
|
|
11932
11913
|
init_operator_transport();
|
|
11933
11914
|
init_session();
|
|
11915
|
+
init_types();
|
|
11934
11916
|
init_path_utils();
|
|
11935
11917
|
init_dashboard_manifest();
|
|
11936
11918
|
init_agent_config_fields();
|
|
@@ -11938,7 +11920,7 @@ var init_src = __esm(() => {
|
|
|
11938
11920
|
init_ui_store();
|
|
11939
11921
|
init_service_store();
|
|
11940
11922
|
init_config_store();
|
|
11941
|
-
|
|
11923
|
+
init_schemas3();
|
|
11942
11924
|
});
|
|
11943
11925
|
|
|
11944
11926
|
// src/utils/errors.ts
|
|
@@ -12535,44 +12517,6 @@ function d(r, t, s) {
|
|
|
12535
12517
|
const e = r + t, i = Math.max(s.length - 1, 0), n = e < 0 ? i : e > i ? 0 : e;
|
|
12536
12518
|
return s[n].disabled ? d(n, t < 0 ? -1 : 1, s) : n;
|
|
12537
12519
|
}
|
|
12538
|
-
function I(r, t, s, e) {
|
|
12539
|
-
const i = e.split(`
|
|
12540
|
-
`);
|
|
12541
|
-
let n = 0, o = r;
|
|
12542
|
-
for (const a of i) {
|
|
12543
|
-
if (o <= a.length)
|
|
12544
|
-
break;
|
|
12545
|
-
o -= a.length + 1, n++;
|
|
12546
|
-
}
|
|
12547
|
-
for (n = Math.max(0, Math.min(i.length - 1, n + s)), o = Math.min(o, i[n].length) + t;o < 0 && n > 0; )
|
|
12548
|
-
n--, o += i[n].length + 1;
|
|
12549
|
-
for (;o > i[n].length && n < i.length - 1; )
|
|
12550
|
-
o -= i[n].length + 1, n++;
|
|
12551
|
-
o = Math.max(0, Math.min(i[n].length, o));
|
|
12552
|
-
let u = 0;
|
|
12553
|
-
for (let a = 0;a < n; a++)
|
|
12554
|
-
u += i[a].length + 1;
|
|
12555
|
-
return u + o;
|
|
12556
|
-
}
|
|
12557
|
-
function j(r) {
|
|
12558
|
-
if (r.aliases !== undefined) {
|
|
12559
|
-
const t = r.aliases;
|
|
12560
|
-
for (const s in t) {
|
|
12561
|
-
if (!Object.hasOwn(t, s))
|
|
12562
|
-
continue;
|
|
12563
|
-
const e = t[s];
|
|
12564
|
-
h.actions.has(e) && (h.aliases.has(s) || h.aliases.set(s, e));
|
|
12565
|
-
}
|
|
12566
|
-
}
|
|
12567
|
-
if (r.messages !== undefined) {
|
|
12568
|
-
const t = r.messages;
|
|
12569
|
-
t.cancel !== undefined && (h.messages.cancel = t.cancel), t.error !== undefined && (h.messages.error = t.error);
|
|
12570
|
-
}
|
|
12571
|
-
if (r.withGuide !== undefined && (h.withGuide = r.withGuide !== false), r.date !== undefined) {
|
|
12572
|
-
const t = r.date;
|
|
12573
|
-
t.monthNames !== undefined && (h.date.monthNames = [...t.monthNames]), t.messages !== undefined && (t.messages.required !== undefined && (h.date.messages.required = t.messages.required), t.messages.invalidMonth !== undefined && (h.date.messages.invalidMonth = t.messages.invalidMonth), t.messages.invalidDay !== undefined && (h.date.messages.invalidDay = t.messages.invalidDay), t.messages.afterMin !== undefined && (h.date.messages.afterMin = t.messages.afterMin), t.messages.beforeMax !== undefined && (h.date.messages.beforeMax = t.messages.beforeMax));
|
|
12574
|
-
}
|
|
12575
|
-
}
|
|
12576
12520
|
function C(r, t) {
|
|
12577
12521
|
if (typeof r == "string")
|
|
12578
12522
|
return h.aliases.get(r) === t;
|
|
@@ -12629,54 +12573,6 @@ function W(r, t, s, e = s, i) {
|
|
|
12629
12573
|
}).join(`
|
|
12630
12574
|
`);
|
|
12631
12575
|
}
|
|
12632
|
-
function B(r, t) {
|
|
12633
|
-
if (r === undefined || t.length === 0)
|
|
12634
|
-
return 0;
|
|
12635
|
-
const s = t.findIndex((e) => e.value === r);
|
|
12636
|
-
return s !== -1 ? s : 0;
|
|
12637
|
-
}
|
|
12638
|
-
function J(r, t) {
|
|
12639
|
-
return (t.label ?? String(t.value)).toLowerCase().includes(r.toLowerCase());
|
|
12640
|
-
}
|
|
12641
|
-
function H(r, t) {
|
|
12642
|
-
if (t)
|
|
12643
|
-
return r ? t : t[0];
|
|
12644
|
-
}
|
|
12645
|
-
function P(r) {
|
|
12646
|
-
return [...r].map((t) => Z[t]);
|
|
12647
|
-
}
|
|
12648
|
-
function tt(r) {
|
|
12649
|
-
const t = new Intl.DateTimeFormat(r, { year: "numeric", month: "2-digit", day: "2-digit" }).formatToParts(new Date(2000, 0, 15)), s = [];
|
|
12650
|
-
let e = "/";
|
|
12651
|
-
for (const i of t)
|
|
12652
|
-
i.type === "literal" ? e = i.value.trim() || i.value : (i.type === "year" || i.type === "month" || i.type === "day") && s.push({ type: i.type, len: i.type === "year" ? 4 : 2 });
|
|
12653
|
-
return { segments: s, separator: e };
|
|
12654
|
-
}
|
|
12655
|
-
function U(r) {
|
|
12656
|
-
return Number.parseInt((r || "0").replace(/_/g, "0"), 10) || 0;
|
|
12657
|
-
}
|
|
12658
|
-
function x(r) {
|
|
12659
|
-
return { year: U(r.year), month: U(r.month), day: U(r.day) };
|
|
12660
|
-
}
|
|
12661
|
-
function $(r, t) {
|
|
12662
|
-
return new Date(r || 2001, t || 1, 0).getDate();
|
|
12663
|
-
}
|
|
12664
|
-
function F(r) {
|
|
12665
|
-
const { year: t, month: s, day: e } = x(r);
|
|
12666
|
-
if (!t || t < 0 || t > 9999 || !s || s < 1 || s > 12 || !e || e < 1)
|
|
12667
|
-
return;
|
|
12668
|
-
const i = new Date(Date.UTC(t, s - 1, e));
|
|
12669
|
-
if (!(i.getUTCFullYear() !== t || i.getUTCMonth() !== s - 1 || i.getUTCDate() !== e))
|
|
12670
|
-
return { year: t, month: s, day: e };
|
|
12671
|
-
}
|
|
12672
|
-
function N(r) {
|
|
12673
|
-
const t = F(r);
|
|
12674
|
-
return t ? new Date(Date.UTC(t.year, t.month - 1, t.day)) : undefined;
|
|
12675
|
-
}
|
|
12676
|
-
function st(r, t, s, e) {
|
|
12677
|
-
const i = s ? { year: s.getUTCFullYear(), month: s.getUTCMonth() + 1, day: s.getUTCDate() } : null, n = e ? { year: e.getUTCFullYear(), month: e.getUTCMonth() + 1, day: e.getUTCDate() } : null;
|
|
12678
|
-
return r === "year" ? { min: i?.year ?? 1, max: n?.year ?? 9999 } : r === "month" ? { min: i && t.year === i.year ? i.month : 1, max: n && t.year === n.year ? n.month : 12 } : { min: i && t.year === i.year && t.month === i.month ? i.day : 1, max: n && t.year === n.year && t.month === n.month ? n.day : $(t.year, t.month) };
|
|
12679
|
-
}
|
|
12680
12576
|
var import_sisteransi, G, K, h, Y, k, A = (r) => ("columns" in r) && typeof r.columns == "number" ? r.columns : 80, L = (r) => ("rows" in r) && typeof r.rows == "number" ? r.rows : 20, p = class {
|
|
12681
12577
|
input;
|
|
12682
12578
|
output;
|
|
@@ -12806,7 +12702,7 @@ var import_sisteransi, G, K, h, Y, k, A = (r) => ("columns" in r) && typeof r.co
|
|
|
12806
12702
|
this.output.write(t), this.state === "initial" && (this.state = "active"), this._prevFrame = t;
|
|
12807
12703
|
}
|
|
12808
12704
|
}
|
|
12809
|
-
},
|
|
12705
|
+
}, X, ot, ut, ht;
|
|
12810
12706
|
var init_dist3 = __esm(() => {
|
|
12811
12707
|
init_main2();
|
|
12812
12708
|
import_sisteransi = __toESM(require_src(), 1);
|
|
@@ -12815,72 +12711,6 @@ var init_dist3 = __esm(() => {
|
|
|
12815
12711
|
h = { actions: new Set(G), aliases: new Map([["k", "up"], ["j", "down"], ["h", "left"], ["l", "right"], ["\x03", "cancel"], ["escape", "cancel"]]), messages: { cancel: "Canceled", error: "Something went wrong" }, withGuide: true, date: { monthNames: [...K], messages: { required: "Please enter a valid date", invalidMonth: "There are only 12 months in a year", invalidDay: (r, t) => `There are only ${r} days in ${t}`, afterMin: (r) => `Date must be on or after ${r.toISOString().slice(0, 10)}`, beforeMax: (r) => `Date must be on or before ${r.toISOString().slice(0, 10)}` } } };
|
|
12816
12712
|
Y = globalThis.process.platform.startsWith("win");
|
|
12817
12713
|
k = Symbol("clack:cancel");
|
|
12818
|
-
Q = class extends p {
|
|
12819
|
-
filteredOptions;
|
|
12820
|
-
multiple;
|
|
12821
|
-
isNavigating = false;
|
|
12822
|
-
selectedValues = [];
|
|
12823
|
-
focusedValue;
|
|
12824
|
-
#s = 0;
|
|
12825
|
-
#r = "";
|
|
12826
|
-
#t;
|
|
12827
|
-
#n;
|
|
12828
|
-
#u;
|
|
12829
|
-
get cursor() {
|
|
12830
|
-
return this.#s;
|
|
12831
|
-
}
|
|
12832
|
-
get userInputWithCursor() {
|
|
12833
|
-
if (!this.userInput)
|
|
12834
|
-
return v(["inverse", "hidden"], "_");
|
|
12835
|
-
if (this._cursor >= this.userInput.length)
|
|
12836
|
-
return `${this.userInput}\u2588`;
|
|
12837
|
-
const t = this.userInput.slice(0, this._cursor), [s, ...e] = this.userInput.slice(this._cursor);
|
|
12838
|
-
return `${t}${v("inverse", s)}${e.join("")}`;
|
|
12839
|
-
}
|
|
12840
|
-
get options() {
|
|
12841
|
-
return typeof this.#n == "function" ? this.#n() : this.#n;
|
|
12842
|
-
}
|
|
12843
|
-
constructor(t) {
|
|
12844
|
-
super(t), this.#n = t.options, this.#u = t.placeholder;
|
|
12845
|
-
const s = this.options;
|
|
12846
|
-
this.filteredOptions = [...s], this.multiple = t.multiple === true, this.#t = typeof t.options == "function" ? t.filter : t.filter ?? J;
|
|
12847
|
-
let e;
|
|
12848
|
-
if (t.initialValue && Array.isArray(t.initialValue) ? this.multiple ? e = t.initialValue : e = t.initialValue.slice(0, 1) : !this.multiple && this.options.length > 0 && (e = [this.options[0].value]), e)
|
|
12849
|
-
for (const i of e) {
|
|
12850
|
-
const n = s.findIndex((o) => o.value === i);
|
|
12851
|
-
n !== -1 && (this.toggleSelected(i), this.#s = n);
|
|
12852
|
-
}
|
|
12853
|
-
this.focusedValue = this.options[this.#s]?.value, this.on("key", (i, n) => this.#e(i, n)), this.on("userInput", (i) => this.#i(i));
|
|
12854
|
-
}
|
|
12855
|
-
_isActionKey(t, s) {
|
|
12856
|
-
return t === "\t" || this.multiple && this.isNavigating && s.name === "space" && t !== undefined && t !== "";
|
|
12857
|
-
}
|
|
12858
|
-
#e(t, s) {
|
|
12859
|
-
const e = s.name === "up", i = s.name === "down", n = s.name === "return", o = this.userInput === "" || this.userInput === "\t", u = this.#u, a = this.options, l = u !== undefined && u !== "" && a.some((f) => !f.disabled && (this.#t ? this.#t(u, f) : true));
|
|
12860
|
-
if (s.name === "tab" && o && l) {
|
|
12861
|
-
this.userInput === "\t" && this._clearUserInput(), this._setUserInput(u, true), this.isNavigating = false;
|
|
12862
|
-
return;
|
|
12863
|
-
}
|
|
12864
|
-
e || i ? (this.#s = d(this.#s, e ? -1 : 1, this.filteredOptions), this.focusedValue = this.filteredOptions[this.#s]?.value, this.multiple || (this.selectedValues = [this.focusedValue]), this.isNavigating = true) : n ? this.value = H(this.multiple, this.selectedValues) : this.multiple ? this.focusedValue !== undefined && (s.name === "tab" || this.isNavigating && s.name === "space") ? this.toggleSelected(this.focusedValue) : this.isNavigating = false : (this.focusedValue && (this.selectedValues = [this.focusedValue]), this.isNavigating = false);
|
|
12865
|
-
}
|
|
12866
|
-
deselectAll() {
|
|
12867
|
-
this.selectedValues = [];
|
|
12868
|
-
}
|
|
12869
|
-
toggleSelected(t) {
|
|
12870
|
-
this.filteredOptions.length !== 0 && (this.multiple ? this.selectedValues.includes(t) ? this.selectedValues = this.selectedValues.filter((s) => s !== t) : this.selectedValues = [...this.selectedValues, t] : this.selectedValues = [t]);
|
|
12871
|
-
}
|
|
12872
|
-
#i(t) {
|
|
12873
|
-
if (t !== this.#r) {
|
|
12874
|
-
this.#r = t;
|
|
12875
|
-
const s = this.options;
|
|
12876
|
-
t && this.#t ? this.filteredOptions = s.filter((n) => this.#t?.(t, n)) : this.filteredOptions = [...s];
|
|
12877
|
-
const e = B(this.focusedValue, this.filteredOptions);
|
|
12878
|
-
this.#s = d(e, 0, this.filteredOptions);
|
|
12879
|
-
const i = this.filteredOptions[this.#s];
|
|
12880
|
-
i && !i.disabled ? this.focusedValue = i.value : this.focusedValue = undefined, this.multiple || (this.focusedValue !== undefined ? this.toggleSelected(this.focusedValue) : this.deselectAll());
|
|
12881
|
-
}
|
|
12882
|
-
}
|
|
12883
|
-
};
|
|
12884
12714
|
X = class X extends p {
|
|
12885
12715
|
get cursor() {
|
|
12886
12716
|
return this.value ? 0 : 1;
|
|
@@ -12898,325 +12728,6 @@ var init_dist3 = __esm(() => {
|
|
|
12898
12728
|
});
|
|
12899
12729
|
}
|
|
12900
12730
|
};
|
|
12901
|
-
Z = { Y: { type: "year", len: 4 }, M: { type: "month", len: 2 }, D: { type: "day", len: 2 } };
|
|
12902
|
-
et = class et extends p {
|
|
12903
|
-
#s;
|
|
12904
|
-
#r;
|
|
12905
|
-
#t;
|
|
12906
|
-
#n;
|
|
12907
|
-
#u;
|
|
12908
|
-
#e = { segmentIndex: 0, positionInSegment: 0 };
|
|
12909
|
-
#i = true;
|
|
12910
|
-
#o = null;
|
|
12911
|
-
inlineError = "";
|
|
12912
|
-
get segmentCursor() {
|
|
12913
|
-
return { ...this.#e };
|
|
12914
|
-
}
|
|
12915
|
-
get segmentValues() {
|
|
12916
|
-
return { ...this.#t };
|
|
12917
|
-
}
|
|
12918
|
-
get segments() {
|
|
12919
|
-
return this.#s;
|
|
12920
|
-
}
|
|
12921
|
-
get separator() {
|
|
12922
|
-
return this.#r;
|
|
12923
|
-
}
|
|
12924
|
-
get formattedValue() {
|
|
12925
|
-
return this.#c(this.#t);
|
|
12926
|
-
}
|
|
12927
|
-
#c(t) {
|
|
12928
|
-
return this.#s.map((s) => t[s.type]).join(this.#r);
|
|
12929
|
-
}
|
|
12930
|
-
#a() {
|
|
12931
|
-
this._setUserInput(this.#c(this.#t)), this._setValue(N(this.#t) ?? undefined);
|
|
12932
|
-
}
|
|
12933
|
-
constructor(t) {
|
|
12934
|
-
const s = t.format ? { segments: P(t.format), separator: t.separator ?? "/" } : tt(t.locale), e = t.separator ?? s.separator, i = t.format ? P(t.format) : s.segments, n = t.initialValue ?? t.defaultValue, o = n ? { year: String(n.getUTCFullYear()).padStart(4, "0"), month: String(n.getUTCMonth() + 1).padStart(2, "0"), day: String(n.getUTCDate()).padStart(2, "0") } : { year: "____", month: "__", day: "__" }, u = i.map((a) => o[a.type]).join(e);
|
|
12935
|
-
super({ ...t, initialUserInput: u }, false), this.#s = i, this.#r = e, this.#t = o, this.#n = t.minDate, this.#u = t.maxDate, this.#a(), this.on("cursor", (a) => this.#d(a)), this.on("key", (a, l) => this.#f(a, l)), this.on("finalize", () => this.#g(t));
|
|
12936
|
-
}
|
|
12937
|
-
#h() {
|
|
12938
|
-
const t = Math.max(0, Math.min(this.#e.segmentIndex, this.#s.length - 1)), s = this.#s[t];
|
|
12939
|
-
if (s)
|
|
12940
|
-
return this.#e.positionInSegment = Math.max(0, Math.min(this.#e.positionInSegment, s.len - 1)), { segment: s, index: t };
|
|
12941
|
-
}
|
|
12942
|
-
#l(t) {
|
|
12943
|
-
this.inlineError = "", this.#o = null;
|
|
12944
|
-
const s = this.#h();
|
|
12945
|
-
s && (this.#e.segmentIndex = Math.max(0, Math.min(this.#s.length - 1, s.index + t)), this.#e.positionInSegment = 0, this.#i = true);
|
|
12946
|
-
}
|
|
12947
|
-
#p(t) {
|
|
12948
|
-
const s = this.#h();
|
|
12949
|
-
if (!s)
|
|
12950
|
-
return;
|
|
12951
|
-
const { segment: e } = s, i = this.#t[e.type], n = !i || i.replace(/_/g, "") === "", o = Number.parseInt((i || "0").replace(/_/g, "0"), 10) || 0, u = st(e.type, x(this.#t), this.#n, this.#u);
|
|
12952
|
-
let a;
|
|
12953
|
-
n ? a = t === 1 ? u.min : u.max : a = Math.max(Math.min(u.max, o + t), u.min), this.#t = { ...this.#t, [e.type]: a.toString().padStart(e.len, "0") }, this.#i = true, this.#o = null, this.#a();
|
|
12954
|
-
}
|
|
12955
|
-
#d(t) {
|
|
12956
|
-
if (t)
|
|
12957
|
-
switch (t) {
|
|
12958
|
-
case "right":
|
|
12959
|
-
return this.#l(1);
|
|
12960
|
-
case "left":
|
|
12961
|
-
return this.#l(-1);
|
|
12962
|
-
case "up":
|
|
12963
|
-
return this.#p(1);
|
|
12964
|
-
case "down":
|
|
12965
|
-
return this.#p(-1);
|
|
12966
|
-
}
|
|
12967
|
-
}
|
|
12968
|
-
#f(t, s) {
|
|
12969
|
-
if (s?.name === "backspace" || s?.sequence === "\x7F" || s?.sequence === "\b" || t === "\x7F" || t === "\b") {
|
|
12970
|
-
this.inlineError = "";
|
|
12971
|
-
const e = this.#h();
|
|
12972
|
-
if (!e)
|
|
12973
|
-
return;
|
|
12974
|
-
if (!this.#t[e.segment.type].replace(/_/g, "")) {
|
|
12975
|
-
this.#l(-1);
|
|
12976
|
-
return;
|
|
12977
|
-
}
|
|
12978
|
-
this.#t[e.segment.type] = "_".repeat(e.segment.len), this.#i = true, this.#e.positionInSegment = 0, this.#a();
|
|
12979
|
-
return;
|
|
12980
|
-
}
|
|
12981
|
-
if (s?.name === "tab") {
|
|
12982
|
-
this.inlineError = "";
|
|
12983
|
-
const e = this.#h();
|
|
12984
|
-
if (!e)
|
|
12985
|
-
return;
|
|
12986
|
-
const i = s.shift ? -1 : 1, n = e.index + i;
|
|
12987
|
-
n >= 0 && n < this.#s.length && (this.#e.segmentIndex = n, this.#e.positionInSegment = 0, this.#i = true);
|
|
12988
|
-
return;
|
|
12989
|
-
}
|
|
12990
|
-
if (t && /^[0-9]$/.test(t)) {
|
|
12991
|
-
const e = this.#h();
|
|
12992
|
-
if (!e)
|
|
12993
|
-
return;
|
|
12994
|
-
const { segment: i } = e, n = !this.#t[i.type].replace(/_/g, "");
|
|
12995
|
-
if (this.#i && this.#o !== null && !n) {
|
|
12996
|
-
const m = this.#o + t, g = { ...this.#t, [i.type]: m }, _ = this.#m(g, i);
|
|
12997
|
-
if (_) {
|
|
12998
|
-
this.inlineError = _, this.#o = null, this.#i = false;
|
|
12999
|
-
return;
|
|
13000
|
-
}
|
|
13001
|
-
this.inlineError = "", this.#t[i.type] = m, this.#o = null, this.#i = false, this.#a(), e.index < this.#s.length - 1 && (this.#e.segmentIndex = e.index + 1, this.#e.positionInSegment = 0, this.#i = true);
|
|
13002
|
-
return;
|
|
13003
|
-
}
|
|
13004
|
-
this.#i && !n && (this.#t[i.type] = "_".repeat(i.len), this.#e.positionInSegment = 0), this.#i = false, this.#o = null;
|
|
13005
|
-
const o = this.#t[i.type], u = o.indexOf("_"), a = u >= 0 ? u : Math.min(this.#e.positionInSegment, i.len - 1);
|
|
13006
|
-
if (a < 0 || a >= i.len)
|
|
13007
|
-
return;
|
|
13008
|
-
let l = o.slice(0, a) + t + o.slice(a + 1), f = false;
|
|
13009
|
-
if (a === 0 && o === "__" && (i.type === "month" || i.type === "day")) {
|
|
13010
|
-
const m = Number.parseInt(t, 10);
|
|
13011
|
-
l = `0${t}`, f = m <= (i.type === "month" ? 1 : 2);
|
|
13012
|
-
}
|
|
13013
|
-
if (i.type === "year" && (l = (o.replace(/_/g, "") + t).padStart(i.len, "_")), !l.includes("_")) {
|
|
13014
|
-
const m = { ...this.#t, [i.type]: l }, g = this.#m(m, i);
|
|
13015
|
-
if (g) {
|
|
13016
|
-
this.inlineError = g;
|
|
13017
|
-
return;
|
|
13018
|
-
}
|
|
13019
|
-
}
|
|
13020
|
-
this.inlineError = "", this.#t[i.type] = l;
|
|
13021
|
-
const y = l.includes("_") ? undefined : F(this.#t);
|
|
13022
|
-
if (y) {
|
|
13023
|
-
const { year: m, month: g } = y, _ = $(m, g);
|
|
13024
|
-
this.#t = { year: String(Math.max(0, Math.min(9999, m))).padStart(4, "0"), month: String(Math.max(1, Math.min(12, g))).padStart(2, "0"), day: String(Math.max(1, Math.min(_, y.day))).padStart(2, "0") };
|
|
13025
|
-
}
|
|
13026
|
-
this.#a();
|
|
13027
|
-
const T = l.indexOf("_");
|
|
13028
|
-
f ? (this.#i = true, this.#o = t) : T >= 0 ? this.#e.positionInSegment = T : u >= 0 && e.index < this.#s.length - 1 ? (this.#e.segmentIndex = e.index + 1, this.#e.positionInSegment = 0, this.#i = true) : this.#e.positionInSegment = Math.min(a + 1, i.len - 1);
|
|
13029
|
-
}
|
|
13030
|
-
}
|
|
13031
|
-
#m(t, s) {
|
|
13032
|
-
const { month: e, day: i } = x(t);
|
|
13033
|
-
if (s.type === "month" && (e < 0 || e > 12))
|
|
13034
|
-
return h.date.messages.invalidMonth;
|
|
13035
|
-
if (s.type === "day" && (i < 0 || i > 31))
|
|
13036
|
-
return h.date.messages.invalidDay(31, "any month");
|
|
13037
|
-
}
|
|
13038
|
-
#g(t) {
|
|
13039
|
-
const { year: s, month: e, day: i } = x(this.#t);
|
|
13040
|
-
if (s && e && i) {
|
|
13041
|
-
const n = $(s, e);
|
|
13042
|
-
this.#t = { ...this.#t, day: String(Math.min(i, n)).padStart(2, "0") };
|
|
13043
|
-
}
|
|
13044
|
-
this.value = N(this.#t) ?? t.defaultValue ?? undefined;
|
|
13045
|
-
}
|
|
13046
|
-
};
|
|
13047
|
-
it = class it extends p {
|
|
13048
|
-
options;
|
|
13049
|
-
cursor = 0;
|
|
13050
|
-
#s;
|
|
13051
|
-
getGroupItems(t) {
|
|
13052
|
-
return this.options.filter((s) => s.group === t);
|
|
13053
|
-
}
|
|
13054
|
-
isGroupSelected(t) {
|
|
13055
|
-
const s = this.getGroupItems(t), e = this.value;
|
|
13056
|
-
return e === undefined ? false : s.every((i) => e.includes(i.value));
|
|
13057
|
-
}
|
|
13058
|
-
toggleValue() {
|
|
13059
|
-
const t = this.options[this.cursor];
|
|
13060
|
-
if (this.value === undefined && (this.value = []), t.group === true) {
|
|
13061
|
-
const s = t.value, e = this.getGroupItems(s);
|
|
13062
|
-
this.isGroupSelected(s) ? this.value = this.value.filter((i) => e.findIndex((n) => n.value === i) === -1) : this.value = [...this.value, ...e.map((i) => i.value)], this.value = Array.from(new Set(this.value));
|
|
13063
|
-
} else {
|
|
13064
|
-
const s = this.value.includes(t.value);
|
|
13065
|
-
this.value = s ? this.value.filter((e) => e !== t.value) : [...this.value, t.value];
|
|
13066
|
-
}
|
|
13067
|
-
}
|
|
13068
|
-
constructor(t) {
|
|
13069
|
-
super(t, false);
|
|
13070
|
-
const { options: s } = t;
|
|
13071
|
-
this.#s = t.selectableGroups !== false, this.options = Object.entries(s).flatMap(([e, i]) => [{ value: e, group: true, label: e }, ...i.map((n) => ({ ...n, group: e }))]), this.value = [...t.initialValues ?? []], this.cursor = Math.max(this.options.findIndex(({ value: e }) => e === t.cursorAt), this.#s ? 0 : 1), this.on("cursor", (e) => {
|
|
13072
|
-
switch (e) {
|
|
13073
|
-
case "left":
|
|
13074
|
-
case "up": {
|
|
13075
|
-
this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
|
|
13076
|
-
const i = this.options[this.cursor]?.group === true;
|
|
13077
|
-
!this.#s && i && (this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1);
|
|
13078
|
-
break;
|
|
13079
|
-
}
|
|
13080
|
-
case "down":
|
|
13081
|
-
case "right": {
|
|
13082
|
-
this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
|
|
13083
|
-
const i = this.options[this.cursor]?.group === true;
|
|
13084
|
-
!this.#s && i && (this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1);
|
|
13085
|
-
break;
|
|
13086
|
-
}
|
|
13087
|
-
case "space":
|
|
13088
|
-
this.toggleValue();
|
|
13089
|
-
break;
|
|
13090
|
-
}
|
|
13091
|
-
});
|
|
13092
|
-
}
|
|
13093
|
-
};
|
|
13094
|
-
rt = class rt extends p {
|
|
13095
|
-
#s = false;
|
|
13096
|
-
#r;
|
|
13097
|
-
focused = "editor";
|
|
13098
|
-
get userInputWithCursor() {
|
|
13099
|
-
if (this.state === "submit")
|
|
13100
|
-
return this.userInput;
|
|
13101
|
-
const t = this.userInput;
|
|
13102
|
-
if (this.cursor >= t.length)
|
|
13103
|
-
return `${t}\u2588`;
|
|
13104
|
-
const s = t.slice(0, this.cursor), e = t[this.cursor], i = t.slice(this.cursor + 1);
|
|
13105
|
-
return e === `
|
|
13106
|
-
` ? `${s}\u2588
|
|
13107
|
-
${i}` : `${s}${v("inverse", e)}${i}`;
|
|
13108
|
-
}
|
|
13109
|
-
get cursor() {
|
|
13110
|
-
return this._cursor;
|
|
13111
|
-
}
|
|
13112
|
-
#t(t) {
|
|
13113
|
-
if (this.userInput.length === 0) {
|
|
13114
|
-
this._setUserInput(t);
|
|
13115
|
-
return;
|
|
13116
|
-
}
|
|
13117
|
-
this._setUserInput(this.userInput.slice(0, this.cursor) + t + this.userInput.slice(this.cursor));
|
|
13118
|
-
}
|
|
13119
|
-
#n(t) {
|
|
13120
|
-
const s = this.value ?? "";
|
|
13121
|
-
switch (t) {
|
|
13122
|
-
case "up":
|
|
13123
|
-
this._cursor = I(this._cursor, 0, -1, s);
|
|
13124
|
-
return;
|
|
13125
|
-
case "down":
|
|
13126
|
-
this._cursor = I(this._cursor, 0, 1, s);
|
|
13127
|
-
return;
|
|
13128
|
-
case "left":
|
|
13129
|
-
this._cursor = I(this._cursor, -1, 0, s);
|
|
13130
|
-
return;
|
|
13131
|
-
case "right":
|
|
13132
|
-
this._cursor = I(this._cursor, 1, 0, s);
|
|
13133
|
-
return;
|
|
13134
|
-
}
|
|
13135
|
-
}
|
|
13136
|
-
_shouldSubmit(t, s) {
|
|
13137
|
-
if (this.#r)
|
|
13138
|
-
return this.focused === "submit" ? true : (this.#t(`
|
|
13139
|
-
`), this._cursor++, false);
|
|
13140
|
-
const e = this.#s;
|
|
13141
|
-
return this.#s = true, e ? (this.userInput[this.cursor - 1] === `
|
|
13142
|
-
` && (this._setUserInput(this.userInput.slice(0, this.cursor - 1) + this.userInput.slice(this.cursor)), this._cursor--), true) : (this.#t(`
|
|
13143
|
-
`), this._cursor++, false);
|
|
13144
|
-
}
|
|
13145
|
-
constructor(t) {
|
|
13146
|
-
super(t, false), this.#r = t.showSubmit ?? false, this.on("key", (s, e) => {
|
|
13147
|
-
if (e?.name && h.actions.has(e.name)) {
|
|
13148
|
-
this.#n(e.name);
|
|
13149
|
-
return;
|
|
13150
|
-
}
|
|
13151
|
-
if (s === "\t" && this.#r) {
|
|
13152
|
-
this.focused = this.focused === "editor" ? "submit" : "editor";
|
|
13153
|
-
return;
|
|
13154
|
-
}
|
|
13155
|
-
if (e?.name !== "return") {
|
|
13156
|
-
if (this.#s = false, e?.name === "backspace" && this.cursor > 0) {
|
|
13157
|
-
this._setUserInput(this.userInput.slice(0, this.cursor - 1) + this.userInput.slice(this.cursor)), this._cursor--;
|
|
13158
|
-
return;
|
|
13159
|
-
}
|
|
13160
|
-
if (e?.name === "delete" && this.cursor < this.userInput.length) {
|
|
13161
|
-
this._setUserInput(this.userInput.slice(0, this.cursor) + this.userInput.slice(this.cursor + 1));
|
|
13162
|
-
return;
|
|
13163
|
-
}
|
|
13164
|
-
s && (this.#r && this.focused === "submit" && (this.focused = "editor"), this.#t(s ?? ""), this._cursor++);
|
|
13165
|
-
}
|
|
13166
|
-
}), this.on("userInput", (s) => {
|
|
13167
|
-
this._setValue(s);
|
|
13168
|
-
}), this.on("finalize", () => {
|
|
13169
|
-
this.value || (this.value = t.defaultValue), this.value === undefined && (this.value = "");
|
|
13170
|
-
});
|
|
13171
|
-
}
|
|
13172
|
-
};
|
|
13173
|
-
nt = class extends p {
|
|
13174
|
-
options;
|
|
13175
|
-
cursor = 0;
|
|
13176
|
-
get _value() {
|
|
13177
|
-
return this.options[this.cursor].value;
|
|
13178
|
-
}
|
|
13179
|
-
get _enabledOptions() {
|
|
13180
|
-
return this.options.filter((t) => t.disabled !== true);
|
|
13181
|
-
}
|
|
13182
|
-
toggleAll() {
|
|
13183
|
-
const t = this._enabledOptions, s = this.value !== undefined && this.value.length === t.length;
|
|
13184
|
-
this.value = s ? [] : t.map((e) => e.value);
|
|
13185
|
-
}
|
|
13186
|
-
toggleInvert() {
|
|
13187
|
-
const t = this.value;
|
|
13188
|
-
if (!t)
|
|
13189
|
-
return;
|
|
13190
|
-
const s = this._enabledOptions.filter((e) => !t.includes(e.value));
|
|
13191
|
-
this.value = s.map((e) => e.value);
|
|
13192
|
-
}
|
|
13193
|
-
toggleValue() {
|
|
13194
|
-
this.value === undefined && (this.value = []);
|
|
13195
|
-
const t = this.value.includes(this._value);
|
|
13196
|
-
this.value = t ? this.value.filter((s) => s !== this._value) : [...this.value, this._value];
|
|
13197
|
-
}
|
|
13198
|
-
constructor(t) {
|
|
13199
|
-
super(t, false), this.options = t.options, this.value = [...t.initialValues ?? []];
|
|
13200
|
-
const s = Math.max(this.options.findIndex(({ value: e }) => e === t.cursorAt), 0);
|
|
13201
|
-
this.cursor = this.options[s].disabled ? d(s, 1, this.options) : s, this.on("key", (e) => {
|
|
13202
|
-
e === "a" && this.toggleAll(), e === "i" && this.toggleInvert();
|
|
13203
|
-
}), this.on("cursor", (e) => {
|
|
13204
|
-
switch (e) {
|
|
13205
|
-
case "left":
|
|
13206
|
-
case "up":
|
|
13207
|
-
this.cursor = d(this.cursor, -1, this.options);
|
|
13208
|
-
break;
|
|
13209
|
-
case "down":
|
|
13210
|
-
case "right":
|
|
13211
|
-
this.cursor = d(this.cursor, 1, this.options);
|
|
13212
|
-
break;
|
|
13213
|
-
case "space":
|
|
13214
|
-
this.toggleValue();
|
|
13215
|
-
break;
|
|
13216
|
-
}
|
|
13217
|
-
});
|
|
13218
|
-
}
|
|
13219
|
-
};
|
|
13220
12731
|
ot = class ot extends p {
|
|
13221
12732
|
_mask = "\u2022";
|
|
13222
12733
|
get cursor() {
|
|
@@ -13270,23 +12781,6 @@ ${i}` : `${s}${v("inverse", e)}${i}`;
|
|
|
13270
12781
|
});
|
|
13271
12782
|
}
|
|
13272
12783
|
};
|
|
13273
|
-
at = class at extends p {
|
|
13274
|
-
options;
|
|
13275
|
-
cursor = 0;
|
|
13276
|
-
constructor(t) {
|
|
13277
|
-
super(t, false), this.options = t.options;
|
|
13278
|
-
const s = t.caseSensitive === true, e = this.options.map(({ value: [i] }) => s ? i : i?.toLowerCase());
|
|
13279
|
-
this.cursor = Math.max(e.indexOf(t.initialValue), 0), this.on("key", (i, n) => {
|
|
13280
|
-
if (!i)
|
|
13281
|
-
return;
|
|
13282
|
-
const o = s && n.shift ? i.toUpperCase() : i;
|
|
13283
|
-
if (!e.includes(o))
|
|
13284
|
-
return;
|
|
13285
|
-
const u = this.options.find(({ value: [a] }) => s ? a === o : a?.toLowerCase() === i);
|
|
13286
|
-
u && (this.value = u.value, this.state = "submit", this.emit("submit"));
|
|
13287
|
-
});
|
|
13288
|
-
}
|
|
13289
|
-
};
|
|
13290
12784
|
ht = class ht extends p {
|
|
13291
12785
|
get userInputWithCursor() {
|
|
13292
12786
|
if (this.state === "submit")
|
|
@@ -13311,135 +12805,12 @@ ${i}` : `${s}${v("inverse", e)}${i}`;
|
|
|
13311
12805
|
});
|
|
13312
12806
|
|
|
13313
12807
|
// ../../node_modules/.bun/@clack+prompts@1.3.0/node_modules/@clack/prompts/dist/index.mjs
|
|
13314
|
-
var exports_dist = {};
|
|
13315
|
-
__export(exports_dist, {
|
|
13316
|
-
S_BAR: () => $2,
|
|
13317
|
-
S_BAR_END: () => E2,
|
|
13318
|
-
S_BAR_END_RIGHT: () => Et,
|
|
13319
|
-
S_BAR_H: () => st2,
|
|
13320
|
-
S_BAR_START: () => lt,
|
|
13321
|
-
S_BAR_START_RIGHT: () => It,
|
|
13322
|
-
S_CHECKBOX_ACTIVE: () => et2,
|
|
13323
|
-
S_CHECKBOX_INACTIVE: () => J2,
|
|
13324
|
-
S_CHECKBOX_SELECTED: () => U2,
|
|
13325
|
-
S_CONNECT_LEFT: () => xt,
|
|
13326
|
-
S_CORNER_BOTTOM_LEFT: () => dt,
|
|
13327
|
-
S_CORNER_BOTTOM_RIGHT: () => $t,
|
|
13328
|
-
S_CORNER_TOP_LEFT: () => Ot,
|
|
13329
|
-
S_CORNER_TOP_RIGHT: () => ct,
|
|
13330
|
-
S_ERROR: () => gt,
|
|
13331
|
-
S_INFO: () => ht2,
|
|
13332
|
-
S_PASSWORD_MASK: () => Gt,
|
|
13333
|
-
S_RADIO_ACTIVE: () => z2,
|
|
13334
|
-
S_RADIO_INACTIVE: () => H2,
|
|
13335
|
-
S_STEP_ACTIVE: () => _t,
|
|
13336
|
-
S_STEP_CANCEL: () => ot2,
|
|
13337
|
-
S_STEP_ERROR: () => ut2,
|
|
13338
|
-
S_STEP_SUBMIT: () => F2,
|
|
13339
|
-
S_SUCCESS: () => pt,
|
|
13340
|
-
S_WARN: () => mt,
|
|
13341
|
-
autocomplete: () => At,
|
|
13342
|
-
autocompleteMultiselect: () => ie,
|
|
13343
|
-
box: () => oe,
|
|
13344
|
-
cancel: () => me,
|
|
13345
|
-
confirm: () => ue,
|
|
13346
|
-
date: () => le,
|
|
13347
|
-
group: () => he,
|
|
13348
|
-
groupMultiselect: () => pe,
|
|
13349
|
-
intro: () => ge,
|
|
13350
|
-
isCI: () => at2,
|
|
13351
|
-
isCancel: () => q,
|
|
13352
|
-
isTTY: () => Tt,
|
|
13353
|
-
limitOptions: () => Y2,
|
|
13354
|
-
log: () => R2,
|
|
13355
|
-
multiline: () => fe,
|
|
13356
|
-
multiselect: () => ve,
|
|
13357
|
-
note: () => Se,
|
|
13358
|
-
outro: () => ye,
|
|
13359
|
-
password: () => Ce,
|
|
13360
|
-
path: () => Te,
|
|
13361
|
-
progress: () => Ie,
|
|
13362
|
-
select: () => Ee,
|
|
13363
|
-
selectKey: () => Ge,
|
|
13364
|
-
settings: () => h,
|
|
13365
|
-
spinner: () => ft,
|
|
13366
|
-
stream: () => K2,
|
|
13367
|
-
symbol: () => M,
|
|
13368
|
-
symbolBar: () => yt,
|
|
13369
|
-
taskLog: () => Me,
|
|
13370
|
-
tasks: () => xe,
|
|
13371
|
-
text: () => Re,
|
|
13372
|
-
unicode: () => tt2,
|
|
13373
|
-
unicodeOr: () => w2,
|
|
13374
|
-
updateSettings: () => j
|
|
13375
|
-
});
|
|
13376
12808
|
import { styleText as e, stripVTControlCharacters as nt2 } from "util";
|
|
13377
12809
|
import j2 from "process";
|
|
13378
|
-
import { existsSync as zt, lstatSync as wt, readdirSync as Qt } from "fs";
|
|
13379
|
-
import { dirname as bt, join as Zt } from "path";
|
|
13380
12810
|
function te() {
|
|
13381
12811
|
return j2.platform !== "win32" ? j2.env.TERM !== "linux" : !!j2.env.CI || !!j2.env.WT_SESSION || !!j2.env.TERMINUS_SUBLIME || j2.env.ConEmuTask === "{cmd::Cmder}" || j2.env.TERM_PROGRAM === "Terminus-Sublime" || j2.env.TERM_PROGRAM === "vscode" || j2.env.TERM === "xterm-256color" || j2.env.TERM === "alacritty" || j2.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
13382
12812
|
}
|
|
13383
|
-
|
|
13384
|
-
return t.label ?? String(t.value ?? "");
|
|
13385
|
-
}
|
|
13386
|
-
function Rt(t, r) {
|
|
13387
|
-
if (!t)
|
|
13388
|
-
return true;
|
|
13389
|
-
const s = (r.label ?? String(r.value ?? "")).toLowerCase(), i = (r.hint ?? "").toLowerCase(), u = String(r.value).toLowerCase(), n = t.toLowerCase();
|
|
13390
|
-
return s.includes(n) || i.includes(n) || u.includes(n);
|
|
13391
|
-
}
|
|
13392
|
-
function se(t, r) {
|
|
13393
|
-
const s = [];
|
|
13394
|
-
for (const i of r)
|
|
13395
|
-
t.includes(i.value) && s.push(i);
|
|
13396
|
-
return s;
|
|
13397
|
-
}
|
|
13398
|
-
function Pt(t, r, s, i) {
|
|
13399
|
-
let u = s, n = s;
|
|
13400
|
-
return i === "center" ? u = Math.floor((r - t) / 2) : i === "right" && (u = r - t - s), n = r - u - t, [u, n];
|
|
13401
|
-
}
|
|
13402
|
-
function ce(t, r) {
|
|
13403
|
-
const { segmentValues: s, segmentCursor: i } = t;
|
|
13404
|
-
if (r === "submit" || r === "cancel")
|
|
13405
|
-
return t.formattedValue;
|
|
13406
|
-
const u = e("gray", t.separator);
|
|
13407
|
-
return t.segments.map((n, o) => {
|
|
13408
|
-
const c = o === i.segmentIndex && !["submit", "cancel"].includes(r), a = de[n.type];
|
|
13409
|
-
return $e(s[n.type], { isActive: c, label: a });
|
|
13410
|
-
}).join(u);
|
|
13411
|
-
}
|
|
13412
|
-
function $e(t, r) {
|
|
13413
|
-
const s = !t || t.replace(/_/g, "") === "";
|
|
13414
|
-
return r.isActive ? e("inverse", s ? r.label : t.replace(/_/g, " ")) : s ? e("dim", r.label) : t.replace(/_/g, e("dim", " "));
|
|
13415
|
-
}
|
|
13416
|
-
function Ie({ style: t = "heavy", max: r = 100, size: s = 40, ...i } = {}) {
|
|
13417
|
-
const u = ft(i);
|
|
13418
|
-
let n = 0, o = "";
|
|
13419
|
-
const c = Math.max(1, r), a = Math.max(1, s), l = (m) => {
|
|
13420
|
-
switch (m) {
|
|
13421
|
-
case "initial":
|
|
13422
|
-
case "active":
|
|
13423
|
-
return (g) => e("magenta", g);
|
|
13424
|
-
case "error":
|
|
13425
|
-
case "cancel":
|
|
13426
|
-
return (g) => e("red", g);
|
|
13427
|
-
case "submit":
|
|
13428
|
-
return (g) => e("green", g);
|
|
13429
|
-
default:
|
|
13430
|
-
return (g) => e("magenta", g);
|
|
13431
|
-
}
|
|
13432
|
-
}, d = (m, g) => {
|
|
13433
|
-
const S = Math.floor(n / c * a);
|
|
13434
|
-
return `${l(m)(Vt[t].repeat(S))}${e("dim", Vt[t].repeat(a - S))} ${g}`;
|
|
13435
|
-
}, y = (m = "") => {
|
|
13436
|
-
o = m, u.start(d("initial", m));
|
|
13437
|
-
}, p = (m = 1, g) => {
|
|
13438
|
-
n = Math.min(c, m + n), u.message(d("active", g ?? o)), o = g ?? o;
|
|
13439
|
-
};
|
|
13440
|
-
return { start: y, stop: u.stop, cancel: u.cancel, error: u.error, clear: u.clear, advance: p, isCancelled: u.isCancelled, message: (m) => p(0, m) };
|
|
13441
|
-
}
|
|
13442
|
-
var import_sisteransi2, tt2, at2 = () => process.env.CI === "true", Tt = (t) => t.isTTY === true, w2 = (t, r) => tt2 ? t : r, _t, ot2, ut2, F2, lt, $2, E2, It, Et, z2, H2, et2, U2, J2, Gt, st2, ct, xt, $t, dt, Ot, ht2, pt, mt, gt, M = (t) => {
|
|
12813
|
+
var import_sisteransi2, tt, at2 = () => process.env.CI === "true", w2 = (t, r) => tt ? t : r, _t, ot2, ut2, F, lt, $, E2, It, Et, z2, H, et2, U, J, Gt, st, ct, xt, $t, dt, Ot, ht2, pt, mt, gt, M = (t) => {
|
|
13443
12814
|
switch (t) {
|
|
13444
12815
|
case "initial":
|
|
13445
12816
|
case "active":
|
|
@@ -13449,19 +12820,19 @@ var import_sisteransi2, tt2, at2 = () => process.env.CI === "true", Tt = (t) =>
|
|
|
13449
12820
|
case "error":
|
|
13450
12821
|
return e("yellow", ut2);
|
|
13451
12822
|
case "submit":
|
|
13452
|
-
return e("green",
|
|
12823
|
+
return e("green", F);
|
|
13453
12824
|
}
|
|
13454
12825
|
}, yt = (t) => {
|
|
13455
12826
|
switch (t) {
|
|
13456
12827
|
case "initial":
|
|
13457
12828
|
case "active":
|
|
13458
|
-
return e("cyan", $
|
|
12829
|
+
return e("cyan", $);
|
|
13459
12830
|
case "cancel":
|
|
13460
|
-
return e("red", $
|
|
12831
|
+
return e("red", $);
|
|
13461
12832
|
case "error":
|
|
13462
|
-
return e("yellow", $
|
|
12833
|
+
return e("yellow", $);
|
|
13463
12834
|
case "submit":
|
|
13464
|
-
return e("green", $
|
|
12835
|
+
return e("green", $);
|
|
13465
12836
|
}
|
|
13466
12837
|
}, ee = (t, r, s, i, u) => {
|
|
13467
12838
|
let n = r, o = 0;
|
|
@@ -13496,167 +12867,33 @@ var import_sisteransi2, tt2, at2 = () => process.env.CI === "true", Tt = (t) =>
|
|
|
13496
12867
|
for (const G of b)
|
|
13497
12868
|
C.push(G);
|
|
13498
12869
|
return g && C.push(l), C;
|
|
13499
|
-
}, At = (t) => new Q({ options: t.options, initialValue: t.initialValue ? [t.initialValue] : undefined, initialUserInput: t.initialUserInput, placeholder: t.placeholder, filter: t.filter ?? ((r, s) => Rt(r, s)), signal: t.signal, input: t.input, output: t.output, validate: t.validate, render() {
|
|
13500
|
-
const r = t.withGuide ?? h.withGuide, s = r ? [`${e("gray", $2)}`, `${M(this.state)} ${t.message}`] : [`${M(this.state)} ${t.message}`], i = this.userInput, u = this.options, n = t.placeholder, o = i === "" && n !== undefined, c = (a, l) => {
|
|
13501
|
-
const d = Mt(a), y = a.hint && a.value === this.focusedValue ? e("dim", ` (${a.hint})`) : "";
|
|
13502
|
-
switch (l) {
|
|
13503
|
-
case "active":
|
|
13504
|
-
return `${e("green", z2)} ${d}${y}`;
|
|
13505
|
-
case "inactive":
|
|
13506
|
-
return `${e("dim", H2)} ${e("dim", d)}`;
|
|
13507
|
-
case "disabled":
|
|
13508
|
-
return `${e("gray", H2)} ${e(["strikethrough", "gray"], d)}`;
|
|
13509
|
-
}
|
|
13510
|
-
};
|
|
13511
|
-
switch (this.state) {
|
|
13512
|
-
case "submit": {
|
|
13513
|
-
const a = se(this.selectedValues, u), l = a.length > 0 ? ` ${e("dim", a.map(Mt).join(", "))}` : "", d = r ? e("gray", $2) : "";
|
|
13514
|
-
return `${s.join(`
|
|
13515
|
-
`)}
|
|
13516
|
-
${d}${l}`;
|
|
13517
|
-
}
|
|
13518
|
-
case "cancel": {
|
|
13519
|
-
const a = i ? ` ${e(["strikethrough", "dim"], i)}` : "", l = r ? e("gray", $2) : "";
|
|
13520
|
-
return `${s.join(`
|
|
13521
|
-
`)}
|
|
13522
|
-
${l}${a}`;
|
|
13523
|
-
}
|
|
13524
|
-
default: {
|
|
13525
|
-
const a = this.state === "error" ? "yellow" : "cyan", l = r ? `${e(a, $2)} ` : "", d = r ? e(a, E2) : "";
|
|
13526
|
-
let y = "";
|
|
13527
|
-
if (this.isNavigating || o) {
|
|
13528
|
-
const v = o ? n : i;
|
|
13529
|
-
y = v !== "" ? ` ${e("dim", v)}` : "";
|
|
13530
|
-
} else
|
|
13531
|
-
y = ` ${this.userInputWithCursor}`;
|
|
13532
|
-
const p = this.filteredOptions.length !== u.length ? e("dim", ` (${this.filteredOptions.length} match${this.filteredOptions.length === 1 ? "" : "es"})`) : "", m = this.filteredOptions.length === 0 && i ? [`${l}${e("yellow", "No matches found")}`] : [], g = this.state === "error" ? [`${l}${e("yellow", this.error)}`] : [];
|
|
13533
|
-
r && s.push(`${l.trimEnd()}`), s.push(`${l}${e("dim", "Search:")}${y}${p}`, ...m, ...g);
|
|
13534
|
-
const S = [`${e("dim", "\u2191/\u2193")} to select`, `${e("dim", "Enter:")} confirm`, `${e("dim", "Type:")} to search`], h2 = [`${l}${S.join(" \u2022 ")}`, d], f = this.filteredOptions.length === 0 ? [] : Y2({ cursor: this.cursor, options: this.filteredOptions, columnPadding: r ? 3 : 0, rowPadding: s.length + h2.length, style: (v, T) => c(v, v.disabled ? "disabled" : T ? "active" : "inactive"), maxItems: t.maxItems, output: t.output });
|
|
13535
|
-
return [...s, ...f.map((v) => `${l}${v}`), ...h2].join(`
|
|
13536
|
-
`);
|
|
13537
|
-
}
|
|
13538
|
-
}
|
|
13539
|
-
} }).prompt(), ie = (t) => {
|
|
13540
|
-
const r = (i, u, n, o) => {
|
|
13541
|
-
const c = n.includes(i.value), a = i.label ?? String(i.value ?? ""), l = i.hint && o !== undefined && i.value === o ? e("dim", ` (${i.hint})`) : "", d = c ? e("green", U2) : e("dim", J2);
|
|
13542
|
-
return i.disabled ? `${e("gray", J2)} ${e(["strikethrough", "gray"], a)}` : u ? `${d} ${a}${l}` : `${d} ${e("dim", a)}`;
|
|
13543
|
-
}, s = new Q({ options: t.options, multiple: true, placeholder: t.placeholder, filter: t.filter ?? ((i, u) => Rt(i, u)), validate: () => {
|
|
13544
|
-
if (t.required && s.selectedValues.length === 0)
|
|
13545
|
-
return "Please select at least one item";
|
|
13546
|
-
}, initialValue: t.initialValues, signal: t.signal, input: t.input, output: t.output, render() {
|
|
13547
|
-
const i = t.withGuide ?? h.withGuide, u = `${i ? `${e("gray", $2)}
|
|
13548
|
-
` : ""}${M(this.state)} ${t.message}
|
|
13549
|
-
`, n = this.userInput, o = t.placeholder, c = n === "" && o !== undefined, a = this.isNavigating || c ? e("dim", c ? o : n) : this.userInputWithCursor, l = this.options, d = this.filteredOptions.length !== l.length ? e("dim", ` (${this.filteredOptions.length} match${this.filteredOptions.length === 1 ? "" : "es"})`) : "";
|
|
13550
|
-
switch (this.state) {
|
|
13551
|
-
case "submit":
|
|
13552
|
-
return `${u}${i ? `${e("gray", $2)} ` : ""}${e("dim", `${this.selectedValues.length} items selected`)}`;
|
|
13553
|
-
case "cancel":
|
|
13554
|
-
return `${u}${i ? `${e("gray", $2)} ` : ""}${e(["strikethrough", "dim"], n)}`;
|
|
13555
|
-
default: {
|
|
13556
|
-
const y = this.state === "error" ? "yellow" : "cyan", p = i ? `${e(y, $2)} ` : "", m = i ? e(y, E2) : "", g = [`${e("dim", "\u2191/\u2193")} to navigate`, `${e("dim", this.isNavigating ? "Space/Tab:" : "Tab:")} select`, `${e("dim", "Enter:")} confirm`, `${e("dim", "Type:")} to search`], S = this.filteredOptions.length === 0 && n ? [`${p}${e("yellow", "No matches found")}`] : [], h2 = this.state === "error" ? [`${p}${e("yellow", this.error)}`] : [], f = [...`${u}${i ? e(y, $2) : ""}`.split(`
|
|
13557
|
-
`), `${p}${e("dim", "Search:")} ${a}${d}`, ...S, ...h2], v = [`${p}${g.join(" \u2022 ")}`, m], T = Y2({ cursor: this.cursor, options: this.filteredOptions, style: (C, b) => r(C, b, this.selectedValues, this.focusedValue), maxItems: t.maxItems, output: t.output, rowPadding: f.length + v.length });
|
|
13558
|
-
return [...f, ...T.map((C) => `${p}${C}`), ...v].join(`
|
|
13559
|
-
`);
|
|
13560
|
-
}
|
|
13561
|
-
}
|
|
13562
|
-
} });
|
|
13563
|
-
return s.prompt();
|
|
13564
|
-
}, re, ne, ae = (t) => t, oe = (t = "", r = "", s) => {
|
|
13565
|
-
const i = s?.output ?? process.stdout, u = A(i), n = 2, o = s?.titlePadding ?? 1, c = s?.contentPadding ?? 2, a = s?.width === undefined || s.width === "auto" ? 1 : Math.min(1, s.width), l = s?.withGuide ?? h.withGuide ? `${$2} ` : "", d = s?.formatBorder ?? ae, y = ((s?.rounded) ? re : ne).map(d), p = d(st2), m = d($2), g = dist_default2(l), S = dist_default2(r), h2 = u - g;
|
|
13566
|
-
let f = Math.floor(u * a) - g;
|
|
13567
|
-
if (s?.width === "auto") {
|
|
13568
|
-
const P = t.split(`
|
|
13569
|
-
`);
|
|
13570
|
-
let N = S + o * 2;
|
|
13571
|
-
for (const rt of P) {
|
|
13572
|
-
const W = dist_default2(rt) + c * 2;
|
|
13573
|
-
W > N && (N = W);
|
|
13574
|
-
}
|
|
13575
|
-
const D = N + n;
|
|
13576
|
-
D < f && (f = D);
|
|
13577
|
-
}
|
|
13578
|
-
f % 2 !== 0 && (f < h2 ? f++ : f--);
|
|
13579
|
-
const v = f - n, T = v - o * 2, C = S > T ? `${r.slice(0, T - 3)}...` : r, [b, G] = Pt(dist_default2(C), v, o, s?.titleAlign), x = wrapAnsi(t, v - c * 2, { hard: true, trim: false });
|
|
13580
|
-
i.write(`${l}${y[0]}${p.repeat(b)}${C}${p.repeat(G)}${y[1]}
|
|
13581
|
-
`);
|
|
13582
|
-
const A2 = x.split(`
|
|
13583
|
-
`);
|
|
13584
|
-
for (const P of A2) {
|
|
13585
|
-
const [N, D] = Pt(dist_default2(P), v, c, s?.contentAlign);
|
|
13586
|
-
i.write(`${l}${m}${" ".repeat(N)}${P}${" ".repeat(D)}${m}
|
|
13587
|
-
`);
|
|
13588
|
-
}
|
|
13589
|
-
i.write(`${l}${y[2]}${p.repeat(v)}${y[3]}
|
|
13590
|
-
`);
|
|
13591
12870
|
}, ue = (t) => {
|
|
13592
12871
|
const r = t.active ?? "Yes", s = t.inactive ?? "No";
|
|
13593
12872
|
return new X({ active: r, inactive: s, signal: t.signal, input: t.input, output: t.output, initialValue: t.initialValue ?? true, render() {
|
|
13594
|
-
const i = t.withGuide ?? h.withGuide, u = `${M(this.state)} `, n = i ? `${e("gray", $
|
|
12873
|
+
const i = t.withGuide ?? h.withGuide, u = `${M(this.state)} `, n = i ? `${e("gray", $)} ` : "", o = W(t.output, t.message, n, u), c = `${i ? `${e("gray", $)}
|
|
13595
12874
|
` : ""}${o}
|
|
13596
12875
|
`, a = this.value ? r : s;
|
|
13597
12876
|
switch (this.state) {
|
|
13598
12877
|
case "submit": {
|
|
13599
|
-
const l = i ? `${e("gray", $
|
|
12878
|
+
const l = i ? `${e("gray", $)} ` : "";
|
|
13600
12879
|
return `${c}${l}${e("dim", a)}`;
|
|
13601
12880
|
}
|
|
13602
12881
|
case "cancel": {
|
|
13603
|
-
const l = i ? `${e("gray", $
|
|
12882
|
+
const l = i ? `${e("gray", $)} ` : "";
|
|
13604
12883
|
return `${c}${l}${e(["strikethrough", "dim"], a)}${i ? `
|
|
13605
|
-
${e("gray", $
|
|
12884
|
+
${e("gray", $)}` : ""}`;
|
|
13606
12885
|
}
|
|
13607
12886
|
default: {
|
|
13608
|
-
const l = i ? `${e("cyan", $
|
|
13609
|
-
return `${c}${l}${this.value ? `${e("green", z2)} ${r}` : `${e("dim",
|
|
13610
|
-
${e("cyan", $
|
|
13611
|
-
` : ` ${e("dim", "/")} `}${this.value ? `${e("dim",
|
|
12887
|
+
const l = i ? `${e("cyan", $)} ` : "", d = i ? e("cyan", E2) : "";
|
|
12888
|
+
return `${c}${l}${this.value ? `${e("green", z2)} ${r}` : `${e("dim", H)} ${e("dim", r)}`}${t.vertical ? i ? `
|
|
12889
|
+
${e("cyan", $)} ` : `
|
|
12890
|
+
` : ` ${e("dim", "/")} `}${this.value ? `${e("dim", H)} ${e("dim", s)}` : `${e("green", z2)} ${s}`}
|
|
13612
12891
|
${d}
|
|
13613
12892
|
`;
|
|
13614
12893
|
}
|
|
13615
12894
|
}
|
|
13616
12895
|
} }).prompt();
|
|
13617
|
-
},
|
|
13618
|
-
const r = t.validate;
|
|
13619
|
-
return new et({ ...t, validate(s) {
|
|
13620
|
-
if (s === undefined)
|
|
13621
|
-
return t.defaultValue !== undefined ? undefined : r ? r(s) : h.date.messages.required;
|
|
13622
|
-
const i = (u) => u.toISOString().slice(0, 10);
|
|
13623
|
-
if (t.minDate && i(s) < i(t.minDate))
|
|
13624
|
-
return h.date.messages.afterMin(t.minDate);
|
|
13625
|
-
if (t.maxDate && i(s) > i(t.maxDate))
|
|
13626
|
-
return h.date.messages.beforeMax(t.maxDate);
|
|
13627
|
-
if (r)
|
|
13628
|
-
return r(s);
|
|
13629
|
-
}, render() {
|
|
13630
|
-
const s = (t?.withGuide ?? h.withGuide) !== false, i = `${`${s ? `${e("gray", $2)}
|
|
13631
|
-
` : ""}${M(this.state)} `}${t.message}
|
|
13632
|
-
`, u = this.state !== "initial" ? this.state : "active", n = ce(this, u), o = this.value instanceof Date ? this.formattedValue : "";
|
|
13633
|
-
switch (this.state) {
|
|
13634
|
-
case "error": {
|
|
13635
|
-
const c = this.error ? ` ${e("yellow", this.error)}` : "", a = s ? `${e("yellow", $2)} ` : "", l = s ? e("yellow", E2) : "";
|
|
13636
|
-
return `${i.trim()}
|
|
13637
|
-
${a}${n}
|
|
13638
|
-
${l}${c}
|
|
13639
|
-
`;
|
|
13640
|
-
}
|
|
13641
|
-
case "submit": {
|
|
13642
|
-
const c = o ? ` ${e("dim", o)}` : "", a = s ? e("gray", $2) : "";
|
|
13643
|
-
return `${i}${a}${c}`;
|
|
13644
|
-
}
|
|
13645
|
-
case "cancel": {
|
|
13646
|
-
const c = o ? ` ${e(["strikethrough", "dim"], o)}` : "", a = s ? e("gray", $2) : "";
|
|
13647
|
-
return `${i}${a}${c}${o.trim() ? `
|
|
13648
|
-
${a}` : ""}`;
|
|
13649
|
-
}
|
|
13650
|
-
default: {
|
|
13651
|
-
const c = s ? `${e("cyan", $2)} ` : "", a = s ? e("cyan", E2) : "", l = s ? `${e("cyan", $2)} ` : "", d = this.inlineError ? `
|
|
13652
|
-
${l}${e("yellow", this.inlineError)}` : "";
|
|
13653
|
-
return `${i}${c}${n}${d}
|
|
13654
|
-
${a}
|
|
13655
|
-
`;
|
|
13656
|
-
}
|
|
13657
|
-
}
|
|
13658
|
-
} }).prompt();
|
|
13659
|
-
}, de, he = async (t, r) => {
|
|
12896
|
+
}, he = async (t, r) => {
|
|
13660
12897
|
const s = {}, i = Object.keys(t);
|
|
13661
12898
|
for (const u of i) {
|
|
13662
12899
|
const n = t[u], o = await n({ results: s })?.catch((c) => {
|
|
@@ -13669,79 +12906,6 @@ ${a}
|
|
|
13669
12906
|
s[u] = o;
|
|
13670
12907
|
}
|
|
13671
12908
|
return s;
|
|
13672
|
-
}, pe = (t) => {
|
|
13673
|
-
const { selectableGroups: r = true, groupSpacing: s = 0 } = t, i = (n, o, c = []) => {
|
|
13674
|
-
const a = n.label ?? String(n.value), l = typeof n.group == "string", d = l && (c[c.indexOf(n) + 1] ?? { group: true }), y = l && d && d.group === true, p = l ? r ? `${y ? E2 : $2} ` : " " : "";
|
|
13675
|
-
let m = "";
|
|
13676
|
-
if (s > 0 && !l) {
|
|
13677
|
-
const S = `
|
|
13678
|
-
${e("cyan", $2)}`;
|
|
13679
|
-
m = `${S.repeat(s - 1)}${S} `;
|
|
13680
|
-
}
|
|
13681
|
-
if (o === "active")
|
|
13682
|
-
return `${m}${e("dim", p)}${e("cyan", et2)} ${a}${n.hint ? ` ${e("dim", `(${n.hint})`)}` : ""}`;
|
|
13683
|
-
if (o === "group-active")
|
|
13684
|
-
return `${m}${p}${e("cyan", et2)} ${e("dim", a)}`;
|
|
13685
|
-
if (o === "group-active-selected")
|
|
13686
|
-
return `${m}${p}${e("green", U2)} ${e("dim", a)}`;
|
|
13687
|
-
if (o === "selected") {
|
|
13688
|
-
const S = l || r ? e("green", U2) : "";
|
|
13689
|
-
return `${m}${e("dim", p)}${S} ${e("dim", a)}${n.hint ? ` ${e("dim", `(${n.hint})`)}` : ""}`;
|
|
13690
|
-
}
|
|
13691
|
-
if (o === "cancelled")
|
|
13692
|
-
return `${e(["strikethrough", "dim"], a)}`;
|
|
13693
|
-
if (o === "active-selected")
|
|
13694
|
-
return `${m}${e("dim", p)}${e("green", U2)} ${a}${n.hint ? ` ${e("dim", `(${n.hint})`)}` : ""}`;
|
|
13695
|
-
if (o === "submitted")
|
|
13696
|
-
return `${e("dim", a)}`;
|
|
13697
|
-
const g = l || r ? e("dim", J2) : "";
|
|
13698
|
-
return `${m}${e("dim", p)}${g} ${e("dim", a)}`;
|
|
13699
|
-
}, u = t.required ?? true;
|
|
13700
|
-
return new it({ options: t.options, signal: t.signal, input: t.input, output: t.output, initialValues: t.initialValues, required: u, cursorAt: t.cursorAt, selectableGroups: r, validate(n) {
|
|
13701
|
-
if (u && (n === undefined || n.length === 0))
|
|
13702
|
-
return `Please select at least one option.
|
|
13703
|
-
${e("reset", e("dim", `Press ${e(["gray", "bgWhite", "inverse"], " space ")} to select, ${e("gray", e(["bgWhite", "inverse"], " enter "))} to submit`))}`;
|
|
13704
|
-
}, render() {
|
|
13705
|
-
const n = t.withGuide ?? h.withGuide, o = `${n ? `${e("gray", $2)}
|
|
13706
|
-
` : ""}${M(this.state)} ${t.message}
|
|
13707
|
-
`, c = this.value ?? [];
|
|
13708
|
-
switch (this.state) {
|
|
13709
|
-
case "submit": {
|
|
13710
|
-
const a = this.options.filter(({ value: d }) => c.includes(d)).map((d) => i(d, "submitted")), l = a.length === 0 ? "" : ` ${a.join(e("dim", ", "))}`;
|
|
13711
|
-
return `${o}${n ? e("gray", $2) : ""}${l}`;
|
|
13712
|
-
}
|
|
13713
|
-
case "cancel": {
|
|
13714
|
-
const a = this.options.filter(({ value: l }) => c.includes(l)).map((l) => i(l, "cancelled")).join(e("dim", ", "));
|
|
13715
|
-
return `${o}${n ? `${e("gray", $2)} ` : ""}${a.trim() ? `${a}${n ? `
|
|
13716
|
-
${e("gray", $2)}` : ""}` : ""}`;
|
|
13717
|
-
}
|
|
13718
|
-
case "error": {
|
|
13719
|
-
const a = this.error.split(`
|
|
13720
|
-
`).map((l, d) => d === 0 ? `${n ? `${e("yellow", E2)} ` : ""}${e("yellow", l)}` : ` ${l}`).join(`
|
|
13721
|
-
`);
|
|
13722
|
-
return `${o}${n ? `${e("yellow", $2)} ` : ""}${this.options.map((l, d, y) => {
|
|
13723
|
-
const p = c.includes(l.value) || l.group === true && this.isGroupSelected(`${l.value}`), m = d === this.cursor;
|
|
13724
|
-
return !m && typeof l.group == "string" && this.options[this.cursor].value === l.group ? i(l, p ? "group-active-selected" : "group-active", y) : m && p ? i(l, "active-selected", y) : p ? i(l, "selected", y) : i(l, m ? "active" : "inactive", y);
|
|
13725
|
-
}).join(`
|
|
13726
|
-
${n ? `${e("yellow", $2)} ` : ""}`)}
|
|
13727
|
-
${a}
|
|
13728
|
-
`;
|
|
13729
|
-
}
|
|
13730
|
-
default: {
|
|
13731
|
-
const a = this.options.map((d, y, p) => {
|
|
13732
|
-
const m = c.includes(d.value) || d.group === true && this.isGroupSelected(`${d.value}`), g = y === this.cursor, S = !g && typeof d.group == "string" && this.options[this.cursor].value === d.group;
|
|
13733
|
-
let h2 = "";
|
|
13734
|
-
return S ? h2 = i(d, m ? "group-active-selected" : "group-active", p) : g && m ? h2 = i(d, "active-selected", p) : m ? h2 = i(d, "selected", p) : h2 = i(d, g ? "active" : "inactive", p), `${y !== 0 && !h2.startsWith(`
|
|
13735
|
-
`) ? " " : ""}${h2}`;
|
|
13736
|
-
}).join(`
|
|
13737
|
-
${n ? e("cyan", $2) : ""}`), l = a.startsWith(`
|
|
13738
|
-
`) ? "" : " ";
|
|
13739
|
-
return `${o}${n ? e("cyan", $2) : ""}${l}${a}
|
|
13740
|
-
${n ? e("cyan", E2) : ""}
|
|
13741
|
-
`;
|
|
13742
|
-
}
|
|
13743
|
-
}
|
|
13744
|
-
} }).prompt();
|
|
13745
12909
|
}, R2, me = (t = "", r) => {
|
|
13746
12910
|
const s = r?.output ?? process.stdout, i = r?.withGuide ?? h.withGuide ? `${e("gray", E2)} ` : "";
|
|
13747
12911
|
s.write(`${i}${e("red", t)}
|
|
@@ -13752,92 +12916,11 @@ ${n ? e("cyan", E2) : ""}
|
|
|
13752
12916
|
s.write(`${i}${t}
|
|
13753
12917
|
`);
|
|
13754
12918
|
}, ye = (t = "", r) => {
|
|
13755
|
-
const s = r?.output ?? process.stdout, i = r?.withGuide ?? h.withGuide ? `${e("gray", $
|
|
12919
|
+
const s = r?.output ?? process.stdout, i = r?.withGuide ?? h.withGuide ? `${e("gray", $)}
|
|
13756
12920
|
${e("gray", E2)} ` : "";
|
|
13757
12921
|
s.write(`${i}${t}
|
|
13758
12922
|
|
|
13759
12923
|
`);
|
|
13760
|
-
}, fe = (t) => new rt({ validate: t.validate, placeholder: t.placeholder, defaultValue: t.defaultValue, initialValue: t.initialValue, showSubmit: t.showSubmit, output: t.output, signal: t.signal, input: t.input, render() {
|
|
13761
|
-
const r = t?.withGuide ?? h.withGuide, s = `${`${r ? `${e("gray", $2)}
|
|
13762
|
-
` : ""}${M(this.state)} `}${t.message}
|
|
13763
|
-
`, i = t.placeholder ? e("inverse", t.placeholder[0]) + e("dim", t.placeholder.slice(1)) : e(["inverse", "hidden"], "_"), u = this.userInput ? this.userInputWithCursor : i, n = this.value ?? "", o = t.showSubmit ? `
|
|
13764
|
-
${e(this.focused === "submit" ? "cyan" : "dim", "[ submit ]")}` : "";
|
|
13765
|
-
switch (this.state) {
|
|
13766
|
-
case "error": {
|
|
13767
|
-
const c = `${e("yellow", $2)} `, a = r ? W(t.output, u, c, undefined) : u, l = e("yellow", E2);
|
|
13768
|
-
return `${s}${a}
|
|
13769
|
-
${l} ${e("yellow", this.error)}${o}
|
|
13770
|
-
`;
|
|
13771
|
-
}
|
|
13772
|
-
case "submit": {
|
|
13773
|
-
const c = `${e("gray", $2)} `, a = r ? W(t.output, n, c, undefined, (l) => e("dim", l)) : n ? e("dim", n) : "";
|
|
13774
|
-
return `${s}${a}`;
|
|
13775
|
-
}
|
|
13776
|
-
case "cancel": {
|
|
13777
|
-
const c = `${e("gray", $2)} `, a = r ? W(t.output, n, c, undefined, (l) => e(["strikethrough", "dim"], l)) : n ? e(["strikethrough", "dim"], n) : "";
|
|
13778
|
-
return `${s}${a}`;
|
|
13779
|
-
}
|
|
13780
|
-
default: {
|
|
13781
|
-
const c = r ? `${e("cyan", $2)} ` : "", a = r ? e("cyan", E2) : "", l = r ? W(t.output, u, c) : u;
|
|
13782
|
-
return `${s}${l}
|
|
13783
|
-
${a}${o}
|
|
13784
|
-
`;
|
|
13785
|
-
}
|
|
13786
|
-
}
|
|
13787
|
-
} }).prompt(), Q2 = (t, r) => t.split(`
|
|
13788
|
-
`).map((s) => r(s)).join(`
|
|
13789
|
-
`), ve = (t) => {
|
|
13790
|
-
const r = (i, u) => {
|
|
13791
|
-
const n = i.label ?? String(i.value);
|
|
13792
|
-
return u === "disabled" ? `${e("gray", J2)} ${Q2(n, (o) => e(["strikethrough", "gray"], o))}${i.hint ? ` ${e("dim", `(${i.hint ?? "disabled"})`)}` : ""}` : u === "active" ? `${e("cyan", et2)} ${n}${i.hint ? ` ${e("dim", `(${i.hint})`)}` : ""}` : u === "selected" ? `${e("green", U2)} ${Q2(n, (o) => e("dim", o))}${i.hint ? ` ${e("dim", `(${i.hint})`)}` : ""}` : u === "cancelled" ? `${Q2(n, (o) => e(["strikethrough", "dim"], o))}` : u === "active-selected" ? `${e("green", U2)} ${n}${i.hint ? ` ${e("dim", `(${i.hint})`)}` : ""}` : u === "submitted" ? `${Q2(n, (o) => e("dim", o))}` : `${e("dim", J2)} ${Q2(n, (o) => e("dim", o))}`;
|
|
13793
|
-
}, s = t.required ?? true;
|
|
13794
|
-
return new nt({ options: t.options, signal: t.signal, input: t.input, output: t.output, initialValues: t.initialValues, required: s, cursorAt: t.cursorAt, validate(i) {
|
|
13795
|
-
if (s && (i === undefined || i.length === 0))
|
|
13796
|
-
return `Please select at least one option.
|
|
13797
|
-
${e("reset", e("dim", `Press ${e(["gray", "bgWhite", "inverse"], " space ")} to select, ${e("gray", e("bgWhite", e("inverse", " enter ")))} to submit`))}`;
|
|
13798
|
-
}, render() {
|
|
13799
|
-
const i = t.withGuide ?? h.withGuide, u = W(t.output, t.message, i ? `${yt(this.state)} ` : "", `${M(this.state)} `), n = `${i ? `${e("gray", $2)}
|
|
13800
|
-
` : ""}${u}
|
|
13801
|
-
`, o = this.value ?? [], c = (a, l) => {
|
|
13802
|
-
if (a.disabled)
|
|
13803
|
-
return r(a, "disabled");
|
|
13804
|
-
const d = o.includes(a.value);
|
|
13805
|
-
return l && d ? r(a, "active-selected") : d ? r(a, "selected") : r(a, l ? "active" : "inactive");
|
|
13806
|
-
};
|
|
13807
|
-
switch (this.state) {
|
|
13808
|
-
case "submit": {
|
|
13809
|
-
const a = this.options.filter(({ value: d }) => o.includes(d)).map((d) => r(d, "submitted")).join(e("dim", ", ")) || e("dim", "none"), l = W(t.output, a, i ? `${e("gray", $2)} ` : "");
|
|
13810
|
-
return `${n}${l}`;
|
|
13811
|
-
}
|
|
13812
|
-
case "cancel": {
|
|
13813
|
-
const a = this.options.filter(({ value: d }) => o.includes(d)).map((d) => r(d, "cancelled")).join(e("dim", ", "));
|
|
13814
|
-
if (a.trim() === "")
|
|
13815
|
-
return `${n}${e("gray", $2)}`;
|
|
13816
|
-
const l = W(t.output, a, i ? `${e("gray", $2)} ` : "");
|
|
13817
|
-
return `${n}${l}${i ? `
|
|
13818
|
-
${e("gray", $2)}` : ""}`;
|
|
13819
|
-
}
|
|
13820
|
-
case "error": {
|
|
13821
|
-
const a = i ? `${e("yellow", $2)} ` : "", l = this.error.split(`
|
|
13822
|
-
`).map((p, m) => m === 0 ? `${i ? `${e("yellow", E2)} ` : ""}${e("yellow", p)}` : ` ${p}`).join(`
|
|
13823
|
-
`), d = n.split(`
|
|
13824
|
-
`).length, y = l.split(`
|
|
13825
|
-
`).length + 1;
|
|
13826
|
-
return `${n}${a}${Y2({ output: t.output, options: this.options, cursor: this.cursor, maxItems: t.maxItems, columnPadding: a.length, rowPadding: d + y, style: c }).join(`
|
|
13827
|
-
${a}`)}
|
|
13828
|
-
${l}
|
|
13829
|
-
`;
|
|
13830
|
-
}
|
|
13831
|
-
default: {
|
|
13832
|
-
const a = i ? `${e("cyan", $2)} ` : "", l = n.split(`
|
|
13833
|
-
`).length, d = i ? 2 : 1;
|
|
13834
|
-
return `${n}${a}${Y2({ output: t.output, options: this.options, cursor: this.cursor, maxItems: t.maxItems, columnPadding: a.length, rowPadding: l + d, style: c }).join(`
|
|
13835
|
-
${a}`)}
|
|
13836
|
-
${i ? e("cyan", E2) : ""}
|
|
13837
|
-
`;
|
|
13838
|
-
}
|
|
13839
|
-
}
|
|
13840
|
-
} }).prompt();
|
|
13841
12924
|
}, we = (t) => e("dim", t), be = (t, r, s) => {
|
|
13842
12925
|
const i = { hard: true, trim: false }, u = wrapAnsi(t, r, i).split(`
|
|
13843
12926
|
`), n = u.reduce((a, l) => Math.max(dist_default2(l), a), 0), o = u.map(s).reduce((a, l) => Math.max(dist_default2(l), a), 0), c = r - (o - n);
|
|
@@ -13847,67 +12930,42 @@ ${i ? e("cyan", E2) : ""}
|
|
|
13847
12930
|
`).map(n), ""], c = dist_default2(r), a = Math.max(o.reduce((p, m) => {
|
|
13848
12931
|
const g = dist_default2(m);
|
|
13849
12932
|
return g > p ? g : p;
|
|
13850
|
-
}, 0), c) + 2, l = o.map((p) => `${e("gray", $
|
|
13851
|
-
`), d = u ? `${e("gray", $
|
|
12933
|
+
}, 0), c) + 2, l = o.map((p) => `${e("gray", $)} ${p}${" ".repeat(a - dist_default2(p))}${e("gray", $)}`).join(`
|
|
12934
|
+
`), d = u ? `${e("gray", $)}
|
|
13852
12935
|
` : "", y = u ? xt : dt;
|
|
13853
|
-
i.write(`${d}${e("green",
|
|
12936
|
+
i.write(`${d}${e("green", F)} ${e("reset", r)} ${e("gray", st.repeat(Math.max(a - c - 1, 1)) + ct)}
|
|
13854
12937
|
${l}
|
|
13855
|
-
${e("gray", y +
|
|
12938
|
+
${e("gray", y + st.repeat(a + 2) + $t)}
|
|
13856
12939
|
`);
|
|
13857
12940
|
}, Ce = (t) => new ot({ validate: t.validate, mask: t.mask ?? Gt, signal: t.signal, input: t.input, output: t.output, render() {
|
|
13858
|
-
const r = t.withGuide ?? h.withGuide, s = `${r ? `${e("gray", $
|
|
12941
|
+
const r = t.withGuide ?? h.withGuide, s = `${r ? `${e("gray", $)}
|
|
13859
12942
|
` : ""}${M(this.state)} ${t.message}
|
|
13860
12943
|
`, i = this.userInputWithCursor, u = this.masked;
|
|
13861
12944
|
switch (this.state) {
|
|
13862
12945
|
case "error": {
|
|
13863
|
-
const n = r ? `${e("yellow", $
|
|
12946
|
+
const n = r ? `${e("yellow", $)} ` : "", o = r ? `${e("yellow", E2)} ` : "", c = u ?? "";
|
|
13864
12947
|
return t.clearOnError && this.clear(), `${s.trim()}
|
|
13865
12948
|
${n}${c}
|
|
13866
12949
|
${o}${e("yellow", this.error)}
|
|
13867
12950
|
`;
|
|
13868
12951
|
}
|
|
13869
12952
|
case "submit": {
|
|
13870
|
-
const n = r ? `${e("gray", $
|
|
12953
|
+
const n = r ? `${e("gray", $)} ` : "", o = u ? e("dim", u) : "";
|
|
13871
12954
|
return `${s}${n}${o}`;
|
|
13872
12955
|
}
|
|
13873
12956
|
case "cancel": {
|
|
13874
|
-
const n = r ? `${e("gray", $
|
|
12957
|
+
const n = r ? `${e("gray", $)} ` : "", o = u ? e(["strikethrough", "dim"], u) : "";
|
|
13875
12958
|
return `${s}${n}${o}${u && r ? `
|
|
13876
|
-
${e("gray", $
|
|
12959
|
+
${e("gray", $)}` : ""}`;
|
|
13877
12960
|
}
|
|
13878
12961
|
default: {
|
|
13879
|
-
const n = r ? `${e("cyan", $
|
|
12962
|
+
const n = r ? `${e("cyan", $)} ` : "", o = r ? e("cyan", E2) : "";
|
|
13880
12963
|
return `${s}${n}${i}
|
|
13881
12964
|
${o}
|
|
13882
12965
|
`;
|
|
13883
12966
|
}
|
|
13884
12967
|
}
|
|
13885
|
-
} }).prompt(),
|
|
13886
|
-
const r = t.validate;
|
|
13887
|
-
return At({ ...t, initialUserInput: t.initialValue ?? t.root ?? process.cwd(), maxItems: 5, validate(s) {
|
|
13888
|
-
if (!Array.isArray(s)) {
|
|
13889
|
-
if (!s)
|
|
13890
|
-
return "Please select a path";
|
|
13891
|
-
if (r)
|
|
13892
|
-
return r(s);
|
|
13893
|
-
}
|
|
13894
|
-
}, options() {
|
|
13895
|
-
const s = this.userInput;
|
|
13896
|
-
if (s === "")
|
|
13897
|
-
return [];
|
|
13898
|
-
try {
|
|
13899
|
-
let i;
|
|
13900
|
-
zt(s) ? wt(s).isDirectory() && (!t.directory || s.endsWith("/")) ? i = s : i = bt(s) : i = bt(s);
|
|
13901
|
-
const u = s.length > 1 && s.endsWith("/") ? s.slice(0, -1) : s;
|
|
13902
|
-
return Qt(i).map((n) => {
|
|
13903
|
-
const o = Zt(i, n), c = wt(o);
|
|
13904
|
-
return { name: n, path: o, isDirectory: c.isDirectory() };
|
|
13905
|
-
}).filter(({ path: n, isDirectory: o }) => n.startsWith(u) && (o || !t.directory)).map((n) => ({ value: n.path }));
|
|
13906
|
-
} catch {
|
|
13907
|
-
return [];
|
|
13908
|
-
}
|
|
13909
|
-
} });
|
|
13910
|
-
}, _e = (t) => e("magenta", t), ft = ({ indicator: t = "dots", onCancel: r, output: s = process.stdout, cancelMessage: i, errorMessage: u, frames: n = tt2 ? ["\u25D2", "\u25D0", "\u25D3", "\u25D1"] : ["\u2022", "o", "O", "0"], delay: o = tt2 ? 80 : 120, signal: c, ...a } = {}) => {
|
|
12968
|
+
} }).prompt(), _e = (t) => e("magenta", t), ft = ({ indicator: t = "dots", onCancel: r, output: s = process.stdout, cancelMessage: i, errorMessage: u, frames: n = tt ? ["\u25D2", "\u25D0", "\u25D3", "\u25D1"] : ["\u2022", "o", "O", "0"], delay: o = tt ? 80 : 120, signal: c, ...a } = {}) => {
|
|
13911
12969
|
const l = at2();
|
|
13912
12970
|
let d, y, p = false, m = false, g = "", S, h2 = performance.now();
|
|
13913
12971
|
const f = A(s), v = a?.styleFrame ?? _e, T = (I) => {
|
|
@@ -13929,7 +12987,7 @@ ${o}
|
|
|
13929
12987
|
const V = (performance.now() - I) / 1000, B = Math.floor(V / 60), L = Math.floor(V % 60);
|
|
13930
12988
|
return B > 0 ? `[${B}m ${L}s]` : `[${L}s]`;
|
|
13931
12989
|
}, D = a.withGuide ?? h.withGuide, rt = (I = "") => {
|
|
13932
|
-
p = true, d = R({ output: s }), g = P(I), h2 = performance.now(), D && s.write(`${e("gray", $
|
|
12990
|
+
p = true, d = R({ output: s }), g = P(I), h2 = performance.now(), D && s.write(`${e("gray", $)}
|
|
13933
12991
|
`);
|
|
13934
12992
|
let V = 0, B = 0;
|
|
13935
12993
|
G(), y = setInterval(() => {
|
|
@@ -13953,7 +13011,7 @@ ${o}
|
|
|
13953
13011
|
if (!p)
|
|
13954
13012
|
return;
|
|
13955
13013
|
p = false, clearInterval(y), A2();
|
|
13956
|
-
const L = V === 0 ? e("green",
|
|
13014
|
+
const L = V === 0 ? e("green", F) : V === 1 ? e("red", ot2) : e("red", ut2);
|
|
13957
13015
|
g = I ?? g, B || (t === "timer" ? s.write(`${L} ${g} ${N(h2)}
|
|
13958
13016
|
`) : s.write(`${L} ${g}
|
|
13959
13017
|
`)), x(), d();
|
|
@@ -13971,7 +13029,7 @@ ${o}
|
|
|
13971
13029
|
const u = s.label ?? String(s.value);
|
|
13972
13030
|
switch (i) {
|
|
13973
13031
|
case "disabled":
|
|
13974
|
-
return `${e("gray",
|
|
13032
|
+
return `${e("gray", H)} ${it2(u, (n) => e("gray", n))}${s.hint ? ` ${e("dim", `(${s.hint ?? "disabled"})`)}` : ""}`;
|
|
13975
13033
|
case "selected":
|
|
13976
13034
|
return `${it2(u, (n) => e("dim", n))}`;
|
|
13977
13035
|
case "active":
|
|
@@ -13979,25 +13037,25 @@ ${o}
|
|
|
13979
13037
|
case "cancelled":
|
|
13980
13038
|
return `${it2(u, (n) => e(["strikethrough", "dim"], n))}`;
|
|
13981
13039
|
default:
|
|
13982
|
-
return `${e("dim",
|
|
13040
|
+
return `${e("dim", H)} ${it2(u, (n) => e("dim", n))}`;
|
|
13983
13041
|
}
|
|
13984
13042
|
};
|
|
13985
13043
|
return new ut({ options: t.options, signal: t.signal, input: t.input, output: t.output, initialValue: t.initialValue, render() {
|
|
13986
|
-
const s = t.withGuide ?? h.withGuide, i = `${M(this.state)} `, u = `${yt(this.state)} `, n = W(t.output, t.message, u, i), o = `${s ? `${e("gray", $
|
|
13044
|
+
const s = t.withGuide ?? h.withGuide, i = `${M(this.state)} `, u = `${yt(this.state)} `, n = W(t.output, t.message, u, i), o = `${s ? `${e("gray", $)}
|
|
13987
13045
|
` : ""}${n}
|
|
13988
13046
|
`;
|
|
13989
13047
|
switch (this.state) {
|
|
13990
13048
|
case "submit": {
|
|
13991
|
-
const c = s ? `${e("gray", $
|
|
13049
|
+
const c = s ? `${e("gray", $)} ` : "", a = W(t.output, r(this.options[this.cursor], "selected"), c);
|
|
13992
13050
|
return `${o}${a}`;
|
|
13993
13051
|
}
|
|
13994
13052
|
case "cancel": {
|
|
13995
|
-
const c = s ? `${e("gray", $
|
|
13053
|
+
const c = s ? `${e("gray", $)} ` : "", a = W(t.output, r(this.options[this.cursor], "cancelled"), c);
|
|
13996
13054
|
return `${o}${a}${s ? `
|
|
13997
|
-
${e("gray", $
|
|
13055
|
+
${e("gray", $)}` : ""}`;
|
|
13998
13056
|
}
|
|
13999
13057
|
default: {
|
|
14000
|
-
const c = s ? `${e("cyan", $
|
|
13058
|
+
const c = s ? `${e("cyan", $)} ` : "", a = s ? e("cyan", E2) : "", l = o.split(`
|
|
14001
13059
|
`).length, d = s ? 2 : 1;
|
|
14002
13060
|
return `${o}${c}${Y2({ output: t.output, cursor: this.cursor, options: this.options, maxItems: t.maxItems, columnPadding: c.length, rowPadding: l + d, style: (y, p) => r(y, y.disabled ? "disabled" : p ? "active" : "inactive") }).join(`
|
|
14003
13061
|
${c}`)}
|
|
@@ -14006,35 +13064,7 @@ ${a}
|
|
|
14006
13064
|
}
|
|
14007
13065
|
}
|
|
14008
13066
|
} }).prompt();
|
|
14009
|
-
},
|
|
14010
|
-
const r = (s, i = "inactive") => {
|
|
14011
|
-
const u = s.label ?? String(s.value);
|
|
14012
|
-
return i === "selected" ? `${e("dim", u)}` : i === "cancelled" ? `${e(["strikethrough", "dim"], u)}` : i === "active" ? `${e(["bgCyan", "gray"], ` ${s.value} `)} ${u}${s.hint ? ` ${e("dim", `(${s.hint})`)}` : ""}` : `${e(["gray", "bgWhite", "inverse"], ` ${s.value} `)} ${u}${s.hint ? ` ${e("dim", `(${s.hint})`)}` : ""}`;
|
|
14013
|
-
};
|
|
14014
|
-
return new at({ options: t.options, signal: t.signal, input: t.input, output: t.output, initialValue: t.initialValue, caseSensitive: t.caseSensitive, render() {
|
|
14015
|
-
const s = t.withGuide ?? h.withGuide, i = `${s ? `${e("gray", $2)}
|
|
14016
|
-
` : ""}${M(this.state)} ${t.message}
|
|
14017
|
-
`;
|
|
14018
|
-
switch (this.state) {
|
|
14019
|
-
case "submit": {
|
|
14020
|
-
const u = s ? `${e("gray", $2)} ` : "", n = this.options.find((c) => c.value === this.value) ?? t.options[0], o = W(t.output, r(n, "selected"), u);
|
|
14021
|
-
return `${i}${o}`;
|
|
14022
|
-
}
|
|
14023
|
-
case "cancel": {
|
|
14024
|
-
const u = s ? `${e("gray", $2)} ` : "", n = W(t.output, r(this.options[0], "cancelled"), u);
|
|
14025
|
-
return `${i}${n}${s ? `
|
|
14026
|
-
${e("gray", $2)}` : ""}`;
|
|
14027
|
-
}
|
|
14028
|
-
default: {
|
|
14029
|
-
const u = s ? `${e("cyan", $2)} ` : "", n = s ? e("cyan", E2) : "", o = this.options.map((c, a) => W(t.output, r(c, a === this.cursor ? "active" : "inactive"), u)).join(`
|
|
14030
|
-
`);
|
|
14031
|
-
return `${i}${o}
|
|
14032
|
-
${n}
|
|
14033
|
-
`;
|
|
14034
|
-
}
|
|
14035
|
-
}
|
|
14036
|
-
} }).prompt();
|
|
14037
|
-
}, jt, K2, xe = async (t, r) => {
|
|
13067
|
+
}, jt, xe = async (t, r) => {
|
|
14038
13068
|
for (const s of t) {
|
|
14039
13069
|
if (s.enabled === false)
|
|
14040
13070
|
continue;
|
|
@@ -14043,104 +13073,29 @@ ${n}
|
|
|
14043
13073
|
const u = await s.task(i.message);
|
|
14044
13074
|
i.stop(u || s.title);
|
|
14045
13075
|
}
|
|
14046
|
-
}, Oe = (t) => t.replace(/\x1b\[(?:\d+;)*\d*[ABCDEFGHfJKSTsu]|\x1b\[(s|u)/g, ""), Me = (t) => {
|
|
14047
|
-
const r = t.output ?? process.stdout, s = A(r), i = e("gray", $2), u = t.spacing ?? 1, n = 3, o = t.retainLog === true, c = !at2() && Tt(r);
|
|
14048
|
-
r.write(`${i}
|
|
14049
|
-
`), r.write(`${e("green", F2)} ${t.title}
|
|
14050
|
-
`);
|
|
14051
|
-
for (let h2 = 0;h2 < u; h2++)
|
|
14052
|
-
r.write(`${i}
|
|
14053
|
-
`);
|
|
14054
|
-
const a = [{ value: "", full: "" }];
|
|
14055
|
-
let l = false;
|
|
14056
|
-
const d = (h2) => {
|
|
14057
|
-
if (a.length === 0)
|
|
14058
|
-
return;
|
|
14059
|
-
let f = 0;
|
|
14060
|
-
h2 && (f += u + 2);
|
|
14061
|
-
for (const v of a) {
|
|
14062
|
-
const { value: T, result: C } = v;
|
|
14063
|
-
let b = C?.message ?? T;
|
|
14064
|
-
if (b.length === 0)
|
|
14065
|
-
continue;
|
|
14066
|
-
C === undefined && v.header !== undefined && v.header !== "" && (b += `
|
|
14067
|
-
${v.header}`);
|
|
14068
|
-
const G = b.split(`
|
|
14069
|
-
`).reduce((x, A) => A === "" ? x + 1 : x + Math.ceil((A.length + n) / s), 0);
|
|
14070
|
-
f += G;
|
|
14071
|
-
}
|
|
14072
|
-
f > 0 && (f += 1, r.write(import_sisteransi2.erase.lines(f)));
|
|
14073
|
-
}, y = (h2, f, v) => {
|
|
14074
|
-
const T = v ? `${h2.full}
|
|
14075
|
-
${h2.value}` : h2.value;
|
|
14076
|
-
h2.header !== undefined && h2.header !== "" && R2.message(h2.header.split(`
|
|
14077
|
-
`).map((C) => e("bold", C)), { output: r, secondarySymbol: i, symbol: i, spacing: 0 }), R2.message(T.split(`
|
|
14078
|
-
`).map((C) => e("dim", C)), { output: r, secondarySymbol: i, symbol: i, spacing: f ?? u });
|
|
14079
|
-
}, p = () => {
|
|
14080
|
-
for (const h2 of a) {
|
|
14081
|
-
const { header: f, value: v, full: T } = h2;
|
|
14082
|
-
(f === undefined || f.length === 0) && v.length === 0 || y(h2, undefined, o === true && T.length > 0);
|
|
14083
|
-
}
|
|
14084
|
-
}, m = (h2, f, v) => {
|
|
14085
|
-
if (d(false), (v?.raw !== true || !l) && h2.value !== "" && (h2.value += `
|
|
14086
|
-
`), h2.value += Oe(f), l = v?.raw === true, t.limit !== undefined) {
|
|
14087
|
-
const T = h2.value.split(`
|
|
14088
|
-
`), C = T.length - t.limit;
|
|
14089
|
-
if (C > 0) {
|
|
14090
|
-
const b = T.splice(0, C);
|
|
14091
|
-
o && (h2.full += (h2.full === "" ? "" : `
|
|
14092
|
-
`) + b.join(`
|
|
14093
|
-
`));
|
|
14094
|
-
}
|
|
14095
|
-
h2.value = T.join(`
|
|
14096
|
-
`);
|
|
14097
|
-
}
|
|
14098
|
-
c && g();
|
|
14099
|
-
}, g = () => {
|
|
14100
|
-
for (const h2 of a)
|
|
14101
|
-
h2.result ? h2.result.status === "error" ? R2.error(h2.result.message, { output: r, secondarySymbol: i, spacing: 0 }) : R2.success(h2.result.message, { output: r, secondarySymbol: i, spacing: 0 }) : h2.value !== "" && y(h2, 0);
|
|
14102
|
-
}, S = (h2, f) => {
|
|
14103
|
-
d(false), h2.result = f, c && g();
|
|
14104
|
-
};
|
|
14105
|
-
return { message(h2, f) {
|
|
14106
|
-
m(a[0], h2, f);
|
|
14107
|
-
}, group(h2) {
|
|
14108
|
-
const f = { header: h2, value: "", full: "" };
|
|
14109
|
-
return a.push(f), { message(v, T) {
|
|
14110
|
-
m(f, v, T);
|
|
14111
|
-
}, error(v) {
|
|
14112
|
-
S(f, { status: "error", message: v });
|
|
14113
|
-
}, success(v) {
|
|
14114
|
-
S(f, { status: "success", message: v });
|
|
14115
|
-
} };
|
|
14116
|
-
}, error(h2, f) {
|
|
14117
|
-
d(true), R2.error(h2, { output: r, secondarySymbol: i, spacing: 1 }), f?.showLog !== false && p(), a.splice(1, a.length - 1), a[0].value = "", a[0].full = "";
|
|
14118
|
-
}, success(h2, f) {
|
|
14119
|
-
d(true), R2.success(h2, { output: r, secondarySymbol: i, spacing: 1 }), f?.showLog === true && p(), a.splice(1, a.length - 1), a[0].value = "", a[0].full = "";
|
|
14120
|
-
} };
|
|
14121
13076
|
}, Re = (t) => new ht({ validate: t.validate, placeholder: t.placeholder, defaultValue: t.defaultValue, initialValue: t.initialValue, output: t.output, signal: t.signal, input: t.input, render() {
|
|
14122
|
-
const r = t?.withGuide ?? h.withGuide, s = `${`${r ? `${e("gray", $
|
|
13077
|
+
const r = t?.withGuide ?? h.withGuide, s = `${`${r ? `${e("gray", $)}
|
|
14123
13078
|
` : ""}${M(this.state)} `}${t.message}
|
|
14124
13079
|
`, i = t.placeholder ? e("inverse", t.placeholder[0]) + e("dim", t.placeholder.slice(1)) : e(["inverse", "hidden"], "_"), u = this.userInput ? this.userInputWithCursor : i, n = this.value ?? "";
|
|
14125
13080
|
switch (this.state) {
|
|
14126
13081
|
case "error": {
|
|
14127
|
-
const o = this.error ? ` ${e("yellow", this.error)}` : "", c = r ? `${e("yellow", $
|
|
13082
|
+
const o = this.error ? ` ${e("yellow", this.error)}` : "", c = r ? `${e("yellow", $)} ` : "", a = r ? e("yellow", E2) : "";
|
|
14128
13083
|
return `${s.trim()}
|
|
14129
13084
|
${c}${u}
|
|
14130
13085
|
${a}${o}
|
|
14131
13086
|
`;
|
|
14132
13087
|
}
|
|
14133
13088
|
case "submit": {
|
|
14134
|
-
const o = n ? ` ${e("dim", n)}` : "", c = r ? e("gray", $
|
|
13089
|
+
const o = n ? ` ${e("dim", n)}` : "", c = r ? e("gray", $) : "";
|
|
14135
13090
|
return `${s}${c}${o}`;
|
|
14136
13091
|
}
|
|
14137
13092
|
case "cancel": {
|
|
14138
|
-
const o = n ? ` ${e(["strikethrough", "dim"], n)}` : "", c = r ? e("gray", $
|
|
13093
|
+
const o = n ? ` ${e(["strikethrough", "dim"], n)}` : "", c = r ? e("gray", $) : "";
|
|
14139
13094
|
return `${s}${c}${o}${n.trim() ? `
|
|
14140
13095
|
${c}` : ""}`;
|
|
14141
13096
|
}
|
|
14142
13097
|
default: {
|
|
14143
|
-
const o = r ? `${e("cyan", $
|
|
13098
|
+
const o = r ? `${e("cyan", $)} ` : "", c = r ? e("cyan", E2) : "";
|
|
14144
13099
|
return `${s}${o}${u}
|
|
14145
13100
|
${c}
|
|
14146
13101
|
`;
|
|
@@ -14153,23 +13108,23 @@ var init_dist4 = __esm(() => {
|
|
|
14153
13108
|
init_main2();
|
|
14154
13109
|
init_dist2();
|
|
14155
13110
|
import_sisteransi2 = __toESM(require_src(), 1);
|
|
14156
|
-
|
|
13111
|
+
tt = te();
|
|
14157
13112
|
_t = w2("\u25C6", "*");
|
|
14158
13113
|
ot2 = w2("\u25A0", "x");
|
|
14159
13114
|
ut2 = w2("\u25B2", "x");
|
|
14160
|
-
|
|
13115
|
+
F = w2("\u25C7", "o");
|
|
14161
13116
|
lt = w2("\u250C", "T");
|
|
14162
|
-
$
|
|
13117
|
+
$ = w2("\u2502", "|");
|
|
14163
13118
|
E2 = w2("\u2514", "\u2014");
|
|
14164
13119
|
It = w2("\u2510", "T");
|
|
14165
13120
|
Et = w2("\u2518", "\u2014");
|
|
14166
13121
|
z2 = w2("\u25CF", ">");
|
|
14167
|
-
|
|
13122
|
+
H = w2("\u25CB", " ");
|
|
14168
13123
|
et2 = w2("\u25FB", "[\u2022]");
|
|
14169
|
-
|
|
14170
|
-
|
|
13124
|
+
U = w2("\u25FC", "[+]");
|
|
13125
|
+
J = w2("\u25FB", "[ ]");
|
|
14171
13126
|
Gt = w2("\u25AA", "\u2022");
|
|
14172
|
-
|
|
13127
|
+
st = w2("\u2500", "-");
|
|
14173
13128
|
ct = w2("\u256E", "+");
|
|
14174
13129
|
xt = w2("\u251C", "+");
|
|
14175
13130
|
$t = w2("\u256F", "+");
|
|
@@ -14179,10 +13134,7 @@ var init_dist4 = __esm(() => {
|
|
|
14179
13134
|
pt = w2("\u25C6", "*");
|
|
14180
13135
|
mt = w2("\u25B2", "!");
|
|
14181
13136
|
gt = w2("\u25A0", "x");
|
|
14182
|
-
|
|
14183
|
-
ne = [lt, It, E2, Et];
|
|
14184
|
-
de = { year: "yyyy", month: "mm", day: "dd" };
|
|
14185
|
-
R2 = { message: (t = [], { symbol: r = e("gray", $2), secondarySymbol: s = e("gray", $2), output: i = process.stdout, spacing: u = 1, withGuide: n } = {}) => {
|
|
13137
|
+
R2 = { message: (t = [], { symbol: r = e("gray", $), secondarySymbol: s = e("gray", $), output: i = process.stdout, spacing: u = 1, withGuide: n } = {}) => {
|
|
14186
13138
|
const o = [], c = n ?? h.withGuide, a = c ? s : "", l = c ? `${r} ` : "", d = c ? `${s} ` : "";
|
|
14187
13139
|
for (let p = 0;p < u; p++)
|
|
14188
13140
|
o.push(a);
|
|
@@ -14202,7 +13154,7 @@ var init_dist4 = __esm(() => {
|
|
|
14202
13154
|
}, success: (t, r) => {
|
|
14203
13155
|
R2.message(t, { ...r, symbol: e("green", pt) });
|
|
14204
13156
|
}, step: (t, r) => {
|
|
14205
|
-
R2.message(t, { ...r, symbol: e("green",
|
|
13157
|
+
R2.message(t, { ...r, symbol: e("green", F) });
|
|
14206
13158
|
}, warn: (t, r) => {
|
|
14207
13159
|
R2.message(t, { ...r, symbol: e("yellow", mt) });
|
|
14208
13160
|
}, warning: (t, r) => {
|
|
@@ -14211,23 +13163,62 @@ var init_dist4 = __esm(() => {
|
|
|
14211
13163
|
R2.message(t, { ...r, symbol: e("red", gt) });
|
|
14212
13164
|
} };
|
|
14213
13165
|
Vt = { light: w2("\u2500", "-"), heavy: w2("\u2501", "="), block: w2("\u2588", "#") };
|
|
14214
|
-
jt = `${e("gray", $
|
|
14215
|
-
|
|
14216
|
-
|
|
14217
|
-
|
|
14218
|
-
|
|
14219
|
-
|
|
14220
|
-
|
|
14221
|
-
|
|
14222
|
-
|
|
14223
|
-
|
|
14224
|
-
|
|
14225
|
-
|
|
14226
|
-
|
|
14227
|
-
|
|
14228
|
-
|
|
14229
|
-
`
|
|
14230
|
-
|
|
13166
|
+
jt = `${e("gray", $)} `;
|
|
13167
|
+
});
|
|
13168
|
+
|
|
13169
|
+
// src/utils/env-file.ts
|
|
13170
|
+
function formatEnvValue(value) {
|
|
13171
|
+
if (value.length > 0 && BARE_VALUE_RE.test(value))
|
|
13172
|
+
return value;
|
|
13173
|
+
const escaped = value.replace(/\\/g, "\\\\").replace(/"/g, "\\\"").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/\t/g, "\\t");
|
|
13174
|
+
return `"${escaped}"`;
|
|
13175
|
+
}
|
|
13176
|
+
function serializeEnvLine(key, value) {
|
|
13177
|
+
return `${key}=${formatEnvValue(value)}`;
|
|
13178
|
+
}
|
|
13179
|
+
function parseEnvFile(text) {
|
|
13180
|
+
const map = new Map;
|
|
13181
|
+
for (const line of text.split(`
|
|
13182
|
+
`)) {
|
|
13183
|
+
let trimmed = line.trim();
|
|
13184
|
+
if (!trimmed || trimmed.startsWith("#"))
|
|
13185
|
+
continue;
|
|
13186
|
+
if (trimmed.startsWith("export "))
|
|
13187
|
+
trimmed = trimmed.slice(7).trimStart();
|
|
13188
|
+
const eq = trimmed.indexOf("=");
|
|
13189
|
+
if (eq <= 0)
|
|
13190
|
+
continue;
|
|
13191
|
+
const key = trimmed.slice(0, eq).trim();
|
|
13192
|
+
if (!key || /\s/.test(key))
|
|
13193
|
+
continue;
|
|
13194
|
+
map.set(key, unquoteValue(trimmed.slice(eq + 1).trim()));
|
|
13195
|
+
}
|
|
13196
|
+
return map;
|
|
13197
|
+
}
|
|
13198
|
+
function unquoteValue(raw) {
|
|
13199
|
+
if (raw.length >= 2 && raw.startsWith('"') && raw.endsWith('"')) {
|
|
13200
|
+
return raw.slice(1, -1).replace(/\\(\\|"|n|r|t)/g, (_, c) => {
|
|
13201
|
+
switch (c) {
|
|
13202
|
+
case "n":
|
|
13203
|
+
return `
|
|
13204
|
+
`;
|
|
13205
|
+
case "r":
|
|
13206
|
+
return "\r";
|
|
13207
|
+
case "t":
|
|
13208
|
+
return "\t";
|
|
13209
|
+
default:
|
|
13210
|
+
return c;
|
|
13211
|
+
}
|
|
13212
|
+
});
|
|
13213
|
+
}
|
|
13214
|
+
if (raw.length >= 2 && raw.startsWith("'") && raw.endsWith("'")) {
|
|
13215
|
+
return raw.slice(1, -1);
|
|
13216
|
+
}
|
|
13217
|
+
return raw;
|
|
13218
|
+
}
|
|
13219
|
+
var BARE_VALUE_RE;
|
|
13220
|
+
var init_env_file = __esm(() => {
|
|
13221
|
+
BARE_VALUE_RE = /^[A-Za-z0-9_@%+=:,./-]+$/;
|
|
14231
13222
|
});
|
|
14232
13223
|
|
|
14233
13224
|
// src/services/config/config-service.ts
|
|
@@ -14464,13 +13455,11 @@ ${e.errors.map((m) => ` - ${m}`).join(`
|
|
|
14464
13455
|
if (errors.length > 0 || parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
14465
13456
|
throw new Error(`Invalid JSONC in ${filePath}`);
|
|
14466
13457
|
}
|
|
14467
|
-
const
|
|
14468
|
-
|
|
14469
|
-
|
|
14470
|
-
|
|
14471
|
-
|
|
14472
|
-
await Bun.write(filePath, JSON.stringify(config, null, 2) + `
|
|
14473
|
-
`);
|
|
13458
|
+
const edits = modify(raw, ["dev", "runtime"], runtime, {
|
|
13459
|
+
formattingOptions: JSONC_FORMAT
|
|
13460
|
+
});
|
|
13461
|
+
await Bun.write(filePath, applyEdits(raw, edits));
|
|
13462
|
+
await this.load(filePath);
|
|
14474
13463
|
}
|
|
14475
13464
|
ensureLoaded() {
|
|
14476
13465
|
if (!this.config) {
|
|
@@ -14512,11 +13501,45 @@ function sanitizeWranglerOutput(raw, maxLines = 4) {
|
|
|
14512
13501
|
}
|
|
14513
13502
|
return text || "wrangler failed (unrecognized output)";
|
|
14514
13503
|
}
|
|
13504
|
+
function formatSecretFailureDetails(failed) {
|
|
13505
|
+
if (failed.length === 0)
|
|
13506
|
+
return "";
|
|
13507
|
+
return failed.map((f) => `${f.name}: ${f.reason}`).join(`
|
|
13508
|
+
`);
|
|
13509
|
+
}
|
|
14515
13510
|
var NOISE_LINE;
|
|
14516
13511
|
var init_wrangler_output = __esm(() => {
|
|
14517
13512
|
NOISE_LINE = /^(?:\u26C5\uFE0F|\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500|Getting User settings|Logs were written|\uD83E\uDEB5|npm notice|\$ |\u25B2 \[WARNING\])/i;
|
|
14518
13513
|
});
|
|
14519
13514
|
|
|
13515
|
+
// src/utils/placeholder.ts
|
|
13516
|
+
function isPlaceholderValue(value) {
|
|
13517
|
+
if (value == null)
|
|
13518
|
+
return true;
|
|
13519
|
+
const v = value.trim();
|
|
13520
|
+
if (v === "")
|
|
13521
|
+
return true;
|
|
13522
|
+
if (v.startsWith("placeholder_"))
|
|
13523
|
+
return true;
|
|
13524
|
+
if (v.startsWith("your_"))
|
|
13525
|
+
return true;
|
|
13526
|
+
if (v.startsWith("generate_"))
|
|
13527
|
+
return true;
|
|
13528
|
+
if (v.startsWith("<") && v.endsWith(">"))
|
|
13529
|
+
return true;
|
|
13530
|
+
if (v.includes("generate-with"))
|
|
13531
|
+
return true;
|
|
13532
|
+
if (/USE_CLOUDFLARE_API_TOKEN|USE_WRANGLER_SECRET_PUT/i.test(v))
|
|
13533
|
+
return true;
|
|
13534
|
+
return false;
|
|
13535
|
+
}
|
|
13536
|
+
function meetsMinVersion(version, minMajor, minMinor) {
|
|
13537
|
+
const [major, minor] = version.split(".").map(Number);
|
|
13538
|
+
const maj = Number.isFinite(major) ? major : 0;
|
|
13539
|
+
const min = Number.isFinite(minor) ? minor : 0;
|
|
13540
|
+
return maj > minMajor || maj === minMajor && min >= minMinor;
|
|
13541
|
+
}
|
|
13542
|
+
|
|
14520
13543
|
// src/utils/fs-secure.ts
|
|
14521
13544
|
import { chmodSync as chmodSync4, mkdirSync as mkdirSync4 } from "fs";
|
|
14522
13545
|
function secureChmod(path, mode) {
|
|
@@ -14747,23 +13770,7 @@ class SecretsService {
|
|
|
14747
13770
|
return { ok: true, value: result };
|
|
14748
13771
|
}
|
|
14749
13772
|
parseDotEnv(content) {
|
|
14750
|
-
|
|
14751
|
-
for (const line of content.split(`
|
|
14752
|
-
`)) {
|
|
14753
|
-
const trimmed = line.trim();
|
|
14754
|
-
if (trimmed === "" || trimmed.startsWith("#"))
|
|
14755
|
-
continue;
|
|
14756
|
-
const eqIdx = trimmed.indexOf("=");
|
|
14757
|
-
if (eqIdx < 1)
|
|
14758
|
-
continue;
|
|
14759
|
-
const key = trimmed.substring(0, eqIdx).trim();
|
|
14760
|
-
let value = trimmed.substring(eqIdx + 1).trim();
|
|
14761
|
-
if (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'")) {
|
|
14762
|
-
value = value.slice(1, -1);
|
|
14763
|
-
}
|
|
14764
|
-
map.set(key, value);
|
|
14765
|
-
}
|
|
14766
|
-
return map;
|
|
13773
|
+
return parseEnvFile(content);
|
|
14767
13774
|
}
|
|
14768
13775
|
async handleAlreadyInUse(workerPath, name, value, logicalWorkerName) {
|
|
14769
13776
|
try {
|
|
@@ -14802,8 +13809,7 @@ class SecretsService {
|
|
|
14802
13809
|
}
|
|
14803
13810
|
}
|
|
14804
13811
|
isPlaceholder(value) {
|
|
14805
|
-
|
|
14806
|
-
return v === "" || v.startsWith("placeholder_") || v.startsWith("your_") || v.startsWith("generate_") || v.startsWith("<") || v.includes("generate-with");
|
|
13812
|
+
return isPlaceholderValue(value);
|
|
14807
13813
|
}
|
|
14808
13814
|
async execWranglerSecretPut(workerPath, name, value, logicalWorkerName) {
|
|
14809
13815
|
const { configPath, deployName } = await resolveWorkerWranglerConfig(workerPath);
|
|
@@ -14833,6 +13839,7 @@ var SYSTEM_SECRET_NAMES, SYSTEM_SECRET_SET, WORKER_SYSTEM_SECRETS;
|
|
|
14833
13839
|
var init_secrets_service = __esm(() => {
|
|
14834
13840
|
init_main();
|
|
14835
13841
|
init_wrangler_output();
|
|
13842
|
+
init_env_file();
|
|
14836
13843
|
SYSTEM_SECRET_NAMES = [
|
|
14837
13844
|
"INTERNAL_KEY_BINDING",
|
|
14838
13845
|
"AGENT_INTERNAL_KEY",
|
|
@@ -15003,12 +14010,11 @@ class CloudflareService {
|
|
|
15003
14010
|
}
|
|
15004
14011
|
async versionsRollback(workerName, versionId) {
|
|
15005
14012
|
return this.runWrangler([
|
|
15006
|
-
"versions",
|
|
15007
14013
|
"rollback",
|
|
14014
|
+
versionId,
|
|
15008
14015
|
"--name",
|
|
15009
14016
|
workerName,
|
|
15010
|
-
"--
|
|
15011
|
-
versionId
|
|
14017
|
+
"--yes"
|
|
15012
14018
|
]);
|
|
15013
14019
|
}
|
|
15014
14020
|
async dev(workerPath, port) {
|
|
@@ -15196,13 +14202,22 @@ class CloudflareService {
|
|
|
15196
14202
|
}
|
|
15197
14203
|
}
|
|
15198
14204
|
async secretDelete(workerName, secretName) {
|
|
15199
|
-
|
|
15200
|
-
|
|
15201
|
-
|
|
15202
|
-
|
|
15203
|
-
|
|
15204
|
-
|
|
15205
|
-
|
|
14205
|
+
const fallback = ["secret", "delete", secretName, "--name", workerName];
|
|
14206
|
+
try {
|
|
14207
|
+
const workerPath = this.resolveWorkerDirForSecrets(workerName);
|
|
14208
|
+
const { configPath, deployName } = await resolveWorkerWranglerConfig(workerPath);
|
|
14209
|
+
return this.runWrangler([
|
|
14210
|
+
"secret",
|
|
14211
|
+
"delete",
|
|
14212
|
+
secretName,
|
|
14213
|
+
"-c",
|
|
14214
|
+
configPath,
|
|
14215
|
+
"--name",
|
|
14216
|
+
deployName ?? workerName
|
|
14217
|
+
], workerPath);
|
|
14218
|
+
} catch {
|
|
14219
|
+
return this.runWrangler(fallback);
|
|
14220
|
+
}
|
|
15206
14221
|
}
|
|
15207
14222
|
async zonesList() {
|
|
15208
14223
|
const token = process.env.CLOUDFLARE_API_TOKEN;
|
|
@@ -15340,8 +14355,7 @@ class PrerequisitesService {
|
|
|
15340
14355
|
});
|
|
15341
14356
|
const stdout = await new Response(proc.stdout).text();
|
|
15342
14357
|
const version = stdout.trim();
|
|
15343
|
-
const
|
|
15344
|
-
const passed = (major ?? 0) >= 1 && (minor ?? 0) >= 2;
|
|
14358
|
+
const passed = meetsMinVersion(version, 1, 2);
|
|
15345
14359
|
return {
|
|
15346
14360
|
...base,
|
|
15347
14361
|
passed,
|
|
@@ -15367,8 +14381,7 @@ class PrerequisitesService {
|
|
|
15367
14381
|
const stdout = await new Response(proc.stdout).text();
|
|
15368
14382
|
const match = stdout.match(/(\d+\.\d+)/);
|
|
15369
14383
|
const version = match?.[1] ?? "unknown";
|
|
15370
|
-
const
|
|
15371
|
-
const passed = (major ?? 0) >= 2 && (minor ?? 0) >= 40;
|
|
14384
|
+
const passed = meetsMinVersion(version, 2, 40);
|
|
15372
14385
|
return {
|
|
15373
14386
|
...base,
|
|
15374
14387
|
passed,
|
|
@@ -15473,6 +14486,7 @@ class PrerequisitesService {
|
|
|
15473
14486
|
required: "D1/KV/R2/Queues: Edit"
|
|
15474
14487
|
};
|
|
15475
14488
|
const token = process.env.CLOUDFLARE_API_TOKEN;
|
|
14489
|
+
const accountId = process.env.CLOUDFLARE_ACCOUNT_ID;
|
|
15476
14490
|
if (!token) {
|
|
15477
14491
|
return {
|
|
15478
14492
|
...base,
|
|
@@ -15481,8 +14495,16 @@ class PrerequisitesService {
|
|
|
15481
14495
|
hint: "If deploys fail with 403, set CLOUDFLARE_API_TOKEN with D1/KV/R2/Queues:Edit"
|
|
15482
14496
|
};
|
|
15483
14497
|
}
|
|
14498
|
+
if (!accountId) {
|
|
14499
|
+
return {
|
|
14500
|
+
...base,
|
|
14501
|
+
passed: false,
|
|
14502
|
+
version: "CLOUDFLARE_ACCOUNT_ID unset",
|
|
14503
|
+
hint: "Set CLOUDFLARE_ACCOUNT_ID so token scope can be probed against D1"
|
|
14504
|
+
};
|
|
14505
|
+
}
|
|
15484
14506
|
try {
|
|
15485
|
-
const response = await fetch(
|
|
14507
|
+
const response = await fetch(`https://api.cloudflare.com/client/v4/accounts/${accountId}/d1/database`, {
|
|
15486
14508
|
headers: {
|
|
15487
14509
|
Authorization: `Bearer ${token}`,
|
|
15488
14510
|
"Content-Type": "application/json"
|
|
@@ -15493,7 +14515,7 @@ class PrerequisitesService {
|
|
|
15493
14515
|
return {
|
|
15494
14516
|
...base,
|
|
15495
14517
|
passed: true,
|
|
15496
|
-
version: "token
|
|
14518
|
+
version: "token can list D1"
|
|
15497
14519
|
};
|
|
15498
14520
|
}
|
|
15499
14521
|
const errMsg = json.errors?.[0]?.message ?? `HTTP ${response.status}`;
|
|
@@ -15608,9 +14630,12 @@ class PrerequisitesService {
|
|
|
15608
14630
|
};
|
|
15609
14631
|
}
|
|
15610
14632
|
}
|
|
14633
|
+
var init_prerequisites_service = () => {};
|
|
15611
14634
|
|
|
15612
14635
|
// src/services/prerequisites/index.ts
|
|
15613
|
-
var init_prerequisites = () => {
|
|
14636
|
+
var init_prerequisites = __esm(() => {
|
|
14637
|
+
init_prerequisites_service();
|
|
14638
|
+
});
|
|
15614
14639
|
|
|
15615
14640
|
// src/services/update/update-service.ts
|
|
15616
14641
|
import { readFileSync as readFileSync7 } from "fs";
|
|
@@ -18301,6 +17326,7 @@ function startTimer() {
|
|
|
18301
17326
|
}
|
|
18302
17327
|
|
|
18303
17328
|
// src/utils/format-mode.ts
|
|
17329
|
+
init_dist4();
|
|
18304
17330
|
function isRichMode(opts) {
|
|
18305
17331
|
if (opts?.json || opts?.quiet || opts?.noColor)
|
|
18306
17332
|
return false;
|
|
@@ -18310,6 +17336,32 @@ function isRichMode(opts) {
|
|
|
18310
17336
|
return false;
|
|
18311
17337
|
return Boolean(process.stdout.isTTY);
|
|
18312
17338
|
}
|
|
17339
|
+
var NOOP_SPINNER = {
|
|
17340
|
+
start() {},
|
|
17341
|
+
stop() {},
|
|
17342
|
+
message() {}
|
|
17343
|
+
};
|
|
17344
|
+
function createCliSpinner(opts) {
|
|
17345
|
+
if (opts?.json || opts?.quiet)
|
|
17346
|
+
return NOOP_SPINNER;
|
|
17347
|
+
if (isRichMode(opts)) {
|
|
17348
|
+
const s = ft();
|
|
17349
|
+
return {
|
|
17350
|
+
start: (msg) => s.start(msg),
|
|
17351
|
+
stop: (msg) => s.stop(msg),
|
|
17352
|
+
message: (msg) => s.message(msg)
|
|
17353
|
+
};
|
|
17354
|
+
}
|
|
17355
|
+
return {
|
|
17356
|
+
start() {},
|
|
17357
|
+
stop(msg) {
|
|
17358
|
+
if (msg)
|
|
17359
|
+
process.stdout.write(`${msg}
|
|
17360
|
+
`);
|
|
17361
|
+
},
|
|
17362
|
+
message() {}
|
|
17363
|
+
};
|
|
17364
|
+
}
|
|
18313
17365
|
|
|
18314
17366
|
// src/utils/formatters.ts
|
|
18315
17367
|
var formatDuration3 = formatDuration2;
|
|
@@ -18788,6 +17840,8 @@ function getCmdPath(cmd) {
|
|
|
18788
17840
|
// src/commands/init/init-command.ts
|
|
18789
17841
|
init_dist4();
|
|
18790
17842
|
init_src();
|
|
17843
|
+
init_wizard();
|
|
17844
|
+
init_env_file();
|
|
18791
17845
|
import * as fs2 from "fs";
|
|
18792
17846
|
|
|
18793
17847
|
// src/services/cloudflare/index.ts
|
|
@@ -18897,7 +17951,7 @@ import {
|
|
|
18897
17951
|
statSync as statSync2,
|
|
18898
17952
|
writeFileSync as writeFileSync4
|
|
18899
17953
|
} from "fs";
|
|
18900
|
-
import { homedir as
|
|
17954
|
+
import { homedir as homedir2 } from "os";
|
|
18901
17955
|
import { join as join7 } from "path";
|
|
18902
17956
|
|
|
18903
17957
|
// src/services/setup/dex-setup.ts
|
|
@@ -18943,7 +17997,7 @@ function generateSolanaSeedBase58() {
|
|
|
18943
17997
|
crypto.getRandomValues(seed);
|
|
18944
17998
|
return encodeBase58(seed);
|
|
18945
17999
|
}
|
|
18946
|
-
function
|
|
18000
|
+
function parseEnvFile2(text) {
|
|
18947
18001
|
const map = new Map;
|
|
18948
18002
|
for (const line of text.split(`
|
|
18949
18003
|
`)) {
|
|
@@ -18958,10 +18012,11 @@ function parseEnvFile(text) {
|
|
|
18958
18012
|
return map;
|
|
18959
18013
|
}
|
|
18960
18014
|
function ensureSolanaPrivateKey(devVarsPath) {
|
|
18961
|
-
const existing = existsSync5(devVarsPath) ?
|
|
18015
|
+
const existing = existsSync5(devVarsPath) ? parseEnvFile2(readFileSync5(devVarsPath, "utf-8")) : new Map;
|
|
18962
18016
|
const current = existing.get("SOLANA_PRIVATE_KEY")?.trim();
|
|
18963
|
-
if (current)
|
|
18017
|
+
if (current && !isPlaceholderValue(current)) {
|
|
18964
18018
|
return { generated: false, value: current };
|
|
18019
|
+
}
|
|
18965
18020
|
const value = generateSolanaSeedBase58();
|
|
18966
18021
|
const header = existsSync5(devVarsPath) ? readFileSync5(devVarsPath, "utf-8") : `# .dev.vars \u2014 local secrets
|
|
18967
18022
|
# Generated by \`hoox setup\`. NEVER commit.
|
|
@@ -18996,59 +18051,8 @@ function applyWalletRpcDefaults(wranglerPath) {
|
|
|
18996
18051
|
return patched;
|
|
18997
18052
|
}
|
|
18998
18053
|
|
|
18999
|
-
// src/utils/env-file.ts
|
|
19000
|
-
var BARE_VALUE_RE = /^[A-Za-z0-9_@%+=:,./-]+$/;
|
|
19001
|
-
function formatEnvValue(value) {
|
|
19002
|
-
if (value.length > 0 && BARE_VALUE_RE.test(value))
|
|
19003
|
-
return value;
|
|
19004
|
-
const escaped = value.replace(/\\/g, "\\\\").replace(/"/g, "\\\"").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/\t/g, "\\t");
|
|
19005
|
-
return `"${escaped}"`;
|
|
19006
|
-
}
|
|
19007
|
-
function serializeEnvLine(key, value) {
|
|
19008
|
-
return `${key}=${formatEnvValue(value)}`;
|
|
19009
|
-
}
|
|
19010
|
-
function parseEnvFile2(text) {
|
|
19011
|
-
const map = new Map;
|
|
19012
|
-
for (const line of text.split(`
|
|
19013
|
-
`)) {
|
|
19014
|
-
let trimmed = line.trim();
|
|
19015
|
-
if (!trimmed || trimmed.startsWith("#"))
|
|
19016
|
-
continue;
|
|
19017
|
-
if (trimmed.startsWith("export "))
|
|
19018
|
-
trimmed = trimmed.slice(7).trimStart();
|
|
19019
|
-
const eq = trimmed.indexOf("=");
|
|
19020
|
-
if (eq <= 0)
|
|
19021
|
-
continue;
|
|
19022
|
-
const key = trimmed.slice(0, eq).trim();
|
|
19023
|
-
if (!key || /\s/.test(key))
|
|
19024
|
-
continue;
|
|
19025
|
-
map.set(key, unquoteValue(trimmed.slice(eq + 1).trim()));
|
|
19026
|
-
}
|
|
19027
|
-
return map;
|
|
19028
|
-
}
|
|
19029
|
-
function unquoteValue(raw) {
|
|
19030
|
-
if (raw.length >= 2 && raw.startsWith('"') && raw.endsWith('"')) {
|
|
19031
|
-
return raw.slice(1, -1).replace(/\\(\\|"|n|r|t)/g, (_, c) => {
|
|
19032
|
-
switch (c) {
|
|
19033
|
-
case "n":
|
|
19034
|
-
return `
|
|
19035
|
-
`;
|
|
19036
|
-
case "r":
|
|
19037
|
-
return "\r";
|
|
19038
|
-
case "t":
|
|
19039
|
-
return "\t";
|
|
19040
|
-
default:
|
|
19041
|
-
return c;
|
|
19042
|
-
}
|
|
19043
|
-
});
|
|
19044
|
-
}
|
|
19045
|
-
if (raw.length >= 2 && raw.startsWith("'") && raw.endsWith("'")) {
|
|
19046
|
-
return raw.slice(1, -1);
|
|
19047
|
-
}
|
|
19048
|
-
return raw;
|
|
19049
|
-
}
|
|
19050
|
-
|
|
19051
18054
|
// src/services/setup/setup-service.ts
|
|
18055
|
+
init_env_file();
|
|
19052
18056
|
var ALL_WORKERS = [
|
|
19053
18057
|
"d1-worker",
|
|
19054
18058
|
"analytics-worker",
|
|
@@ -19127,7 +18131,7 @@ function loadExistingKeysFromDisk() {
|
|
|
19127
18131
|
} catch {
|
|
19128
18132
|
return null;
|
|
19129
18133
|
}
|
|
19130
|
-
const map =
|
|
18134
|
+
const map = parseEnvFile(text);
|
|
19131
18135
|
const required = [
|
|
19132
18136
|
"INTERNAL_KEY_BINDING",
|
|
19133
18137
|
"AGENT_INTERNAL_KEY",
|
|
@@ -19216,7 +18220,7 @@ class SetupService {
|
|
|
19216
18220
|
const path = `workers/${workerFsDir(worker)}/.dev.vars`;
|
|
19217
18221
|
const meshNames = secretNames;
|
|
19218
18222
|
const meshSet = new Set(meshNames);
|
|
19219
|
-
const existing = existsSync6(path) ?
|
|
18223
|
+
const existing = existsSync6(path) ? parseEnvFile(readFileSync6(path, "utf-8")) : new Map;
|
|
19220
18224
|
for (const secretName of meshNames) {
|
|
19221
18225
|
existing.set(secretName, keys[secretName]);
|
|
19222
18226
|
}
|
|
@@ -19274,13 +18278,14 @@ class SetupService {
|
|
|
19274
18278
|
const path = join7("workers", workerFsDir("web3-wallet-worker"), ".dev.vars");
|
|
19275
18279
|
if (!existsSync6(path))
|
|
19276
18280
|
return [];
|
|
19277
|
-
const map =
|
|
18281
|
+
const map = parseEnvFile(readFileSync6(path, "utf-8"));
|
|
19278
18282
|
const solanaKey = map.get("SOLANA_PRIVATE_KEY")?.trim();
|
|
19279
18283
|
const jupiterKey = map.get("JUPITER_API_KEY")?.trim();
|
|
19280
18284
|
const results = [];
|
|
19281
18285
|
const puts = [];
|
|
19282
|
-
if (solanaKey)
|
|
18286
|
+
if (solanaKey && !isPlaceholderValue(solanaKey)) {
|
|
19283
18287
|
puts.push(["SOLANA_PRIVATE_KEY", solanaKey]);
|
|
18288
|
+
}
|
|
19284
18289
|
if (jupiterKey)
|
|
19285
18290
|
puts.push(["JUPITER_API_KEY", jupiterKey]);
|
|
19286
18291
|
for (const [name, value] of puts) {
|
|
@@ -19575,7 +18580,7 @@ class SetupService {
|
|
|
19575
18580
|
}
|
|
19576
18581
|
const fallbacks = [
|
|
19577
18582
|
"/usr/local/bin/wrangler",
|
|
19578
|
-
join7(
|
|
18583
|
+
join7(homedir2(), ".bun", "bin", "wrangler")
|
|
19579
18584
|
];
|
|
19580
18585
|
for (const fb of fallbacks) {
|
|
19581
18586
|
try {
|
|
@@ -19876,33 +18881,50 @@ class SetupService {
|
|
|
19876
18881
|
message: `Checking D1 database "${dbName}"...`
|
|
19877
18882
|
});
|
|
19878
18883
|
const listResult = await this.cf.d1List();
|
|
19879
|
-
if (listResult.ok) {
|
|
19880
|
-
|
|
19881
|
-
|
|
19882
|
-
|
|
19883
|
-
|
|
19884
|
-
|
|
19885
|
-
|
|
19886
|
-
|
|
19887
|
-
|
|
19888
|
-
|
|
19889
|
-
|
|
19890
|
-
|
|
19891
|
-
|
|
19892
|
-
|
|
19893
|
-
|
|
19894
|
-
|
|
19895
|
-
|
|
19896
|
-
|
|
19897
|
-
|
|
19898
|
-
|
|
19899
|
-
|
|
19900
|
-
|
|
19901
|
-
|
|
19902
|
-
|
|
19903
|
-
|
|
19904
|
-
|
|
19905
|
-
|
|
18884
|
+
if (!listResult.ok) {
|
|
18885
|
+
const msg = `Failed to list D1 databases: ${listResult.error}`;
|
|
18886
|
+
this.onProgress({
|
|
18887
|
+
type: "step-error",
|
|
18888
|
+
step: "d1-database",
|
|
18889
|
+
message: msg
|
|
18890
|
+
});
|
|
18891
|
+
return { step: "d1-database", success: false, message: msg };
|
|
18892
|
+
}
|
|
18893
|
+
let databases;
|
|
18894
|
+
try {
|
|
18895
|
+
const parsed = JSON.parse(listResult.value);
|
|
18896
|
+
databases = Array.isArray(parsed) ? parsed : [];
|
|
18897
|
+
} catch {
|
|
18898
|
+
const msg = `Could not parse D1 list output for "${dbName}"`;
|
|
18899
|
+
this.onProgress({
|
|
18900
|
+
type: "step-error",
|
|
18901
|
+
step: "d1-database",
|
|
18902
|
+
message: msg
|
|
18903
|
+
});
|
|
18904
|
+
return { step: "d1-database", success: false, message: msg };
|
|
18905
|
+
}
|
|
18906
|
+
const exists = databases.some((d) => d.name === dbName);
|
|
18907
|
+
if (!exists) {
|
|
18908
|
+
this.onProgress({
|
|
18909
|
+
type: "info",
|
|
18910
|
+
step: "d1-database",
|
|
18911
|
+
message: `Database "${dbName}" not found \u2014 creating...`
|
|
18912
|
+
});
|
|
18913
|
+
const createResult = await this.cf.d1Create(dbName);
|
|
18914
|
+
if (!createResult.ok) {
|
|
18915
|
+
const msg = `Failed to create D1 database: ${createResult.error}`;
|
|
18916
|
+
this.onProgress({
|
|
18917
|
+
type: "step-error",
|
|
18918
|
+
step: "d1-database",
|
|
18919
|
+
message: msg
|
|
18920
|
+
});
|
|
18921
|
+
return { step: "d1-database", success: false, message: msg };
|
|
18922
|
+
}
|
|
18923
|
+
this.onProgress({
|
|
18924
|
+
type: "info",
|
|
18925
|
+
step: "d1-database",
|
|
18926
|
+
message: `Created D1 database "${dbName}"`
|
|
18927
|
+
});
|
|
19906
18928
|
}
|
|
19907
18929
|
this.onProgress({
|
|
19908
18930
|
type: "step-complete",
|
|
@@ -19946,7 +18968,11 @@ class SetupService {
|
|
|
19946
18968
|
step: "reconcile",
|
|
19947
18969
|
message: `Cleaning up legacy secret "${oldName}" on ${worker}...`
|
|
19948
18970
|
});
|
|
19949
|
-
await this.cf.secretDelete(worker, oldName);
|
|
18971
|
+
const del = await this.cf.secretDelete(worker, oldName);
|
|
18972
|
+
if (!del.ok) {
|
|
18973
|
+
warnings.push(`Could not delete legacy secret "${oldName}" on ${worker}: ${del.error}`);
|
|
18974
|
+
continue;
|
|
18975
|
+
}
|
|
19950
18976
|
fixed.push(`${worker}:${oldName}\u2192deleted`);
|
|
19951
18977
|
warnings.push(`Deleted legacy secret "${oldName}" from ${worker} \u2014 was replaced by "${newName}"`);
|
|
19952
18978
|
} else {
|
|
@@ -19957,8 +18983,12 @@ class SetupService {
|
|
|
19957
18983
|
});
|
|
19958
18984
|
const putResult = await this.cf.secretPut(worker, newName, newValue);
|
|
19959
18985
|
if (putResult.ok) {
|
|
19960
|
-
await this.cf.secretDelete(worker, oldName);
|
|
19961
|
-
|
|
18986
|
+
const del = await this.cf.secretDelete(worker, oldName);
|
|
18987
|
+
if (!del.ok) {
|
|
18988
|
+
warnings.push(`Set "${newName}" on ${worker} but could not delete "${oldName}": ${del.error}`);
|
|
18989
|
+
} else {
|
|
18990
|
+
fixed.push(`${worker}:${oldName}\u2192${newName}`);
|
|
18991
|
+
}
|
|
19962
18992
|
} else {
|
|
19963
18993
|
warnings.push(`Could not migrate "${oldName}" to "${newName}" on ${worker}: ${putResult.error}`);
|
|
19964
18994
|
}
|
|
@@ -20277,9 +19307,12 @@ async function createDevVars(config, secrets, opts) {
|
|
|
20277
19307
|
lines.push(`# .dev.vars \u2014 local secrets for ${workerName}`);
|
|
20278
19308
|
lines.push(`# Generated by \`hoox init\`. NEVER commit this file.`);
|
|
20279
19309
|
lines.push("");
|
|
20280
|
-
for (const [, integrationSecrets] of Object.entries(secrets)) {
|
|
19310
|
+
for (const [integrationKey, integrationSecrets] of Object.entries(secrets)) {
|
|
19311
|
+
const integration = INTEGRATIONS.find((i) => i.key === integrationKey);
|
|
19312
|
+
if (integration && integration.workerName !== workerName)
|
|
19313
|
+
continue;
|
|
20281
19314
|
for (const [key, value] of Object.entries(integrationSecrets)) {
|
|
20282
|
-
lines.push(
|
|
19315
|
+
lines.push(serializeEnvLine(key, value));
|
|
20283
19316
|
}
|
|
20284
19317
|
}
|
|
20285
19318
|
if (lines.length <= 3)
|
|
@@ -20729,7 +19762,12 @@ async function runInitCommand(options, globalOpts, isNonInteractive) {
|
|
|
20729
19762
|
stdout: "inherit",
|
|
20730
19763
|
stderr: "inherit"
|
|
20731
19764
|
});
|
|
20732
|
-
await proc.exited;
|
|
19765
|
+
const code = await proc.exited;
|
|
19766
|
+
if (code !== 0) {
|
|
19767
|
+
process.exitCode = code ?? 1 /* ERROR */;
|
|
19768
|
+
ye(theme.error(`Deploy failed (exit ${code ?? "unknown"}). Config was written; retry with hoox deploy all.`));
|
|
19769
|
+
return;
|
|
19770
|
+
}
|
|
20733
19771
|
}
|
|
20734
19772
|
engine.execute({});
|
|
20735
19773
|
}
|
|
@@ -21765,7 +20803,7 @@ class EnvService {
|
|
|
21765
20803
|
for (const def of EnvService.getDefinitions()) {
|
|
21766
20804
|
if (def.required) {
|
|
21767
20805
|
const val = vars[def.name];
|
|
21768
|
-
if (
|
|
20806
|
+
if (isPlaceholderValue(val)) {
|
|
21769
20807
|
missing.push(def.name);
|
|
21770
20808
|
}
|
|
21771
20809
|
}
|
|
@@ -22005,7 +21043,7 @@ async function deployAll(configService, cf, env, forceRebuildDashboard = false,
|
|
|
22005
21043
|
const tasks = allItems.map((name) => ({
|
|
22006
21044
|
title: name,
|
|
22007
21045
|
run: async () => {
|
|
22008
|
-
const result = name === "dashboard" ? await deployDashboard(cf, forceRebuildDashboard, true, autoMode) : await deploySingle(configService, cf, name, env);
|
|
21046
|
+
const result = name === "dashboard" ? await deployDashboard(cf, forceRebuildDashboard, true, autoMode, format) : await deploySingle(configService, cf, name, env);
|
|
22009
21047
|
if (!result.success) {
|
|
22010
21048
|
throw new CLIError(result.error ?? `${name} deploy failed`, 1 /* ERROR */);
|
|
22011
21049
|
}
|
|
@@ -22064,7 +21102,7 @@ function renderDeploySummary(results, format) {
|
|
|
22064
21102
|
});
|
|
22065
21103
|
formatTable(rows, {});
|
|
22066
21104
|
}
|
|
22067
|
-
async function deployDashboard(_cf, forceRebuild = false, silentMode = false, autoMode = false) {
|
|
21105
|
+
async function deployDashboard(_cf, forceRebuild = false, silentMode = false, autoMode = false, format = {}) {
|
|
22068
21106
|
const dashboardPath = "workers/dashboard";
|
|
22069
21107
|
const buildInfo = getDashboardBuildInfo(dashboardPath);
|
|
22070
21108
|
let action;
|
|
@@ -22097,7 +21135,7 @@ ${theme.heading("Deploying Dashboard")}
|
|
|
22097
21135
|
`);
|
|
22098
21136
|
}
|
|
22099
21137
|
const actionText = action === "rebuild" ? "Building & deploying" : "Deploying";
|
|
22100
|
-
const s =
|
|
21138
|
+
const s = createCliSpinner(format);
|
|
22101
21139
|
try {
|
|
22102
21140
|
s.start(`${actionText} dashboard...`);
|
|
22103
21141
|
if (action === "rebuild") {
|
|
@@ -22349,7 +21387,7 @@ ${setCount} key(s) set, ${errorCount} error(s)
|
|
|
22349
21387
|
}
|
|
22350
21388
|
}
|
|
22351
21389
|
async function doVersionHistory(worker, fmt) {
|
|
22352
|
-
const s =
|
|
21390
|
+
const s = createCliSpinner(fmt);
|
|
22353
21391
|
s.start(`Fetching deployment history for ${worker}...`);
|
|
22354
21392
|
const cf = new CloudflareService;
|
|
22355
21393
|
const result = await cf.versionsList(worker);
|
|
@@ -22381,7 +21419,7 @@ async function doVersionRollback(worker, version, fmt, yes) {
|
|
|
22381
21419
|
const cf = new CloudflareService;
|
|
22382
21420
|
let targetVersion = version;
|
|
22383
21421
|
if (!targetVersion) {
|
|
22384
|
-
const s =
|
|
21422
|
+
const s = createCliSpinner(fmt);
|
|
22385
21423
|
s.start(`Fetching recent versions for ${worker}...`);
|
|
22386
21424
|
const result = await cf.versionsList(worker);
|
|
22387
21425
|
if (!result.ok) {
|
|
@@ -22424,7 +21462,7 @@ async function doVersionRollback(worker, version, fmt, yes) {
|
|
|
22424
21462
|
return;
|
|
22425
21463
|
}
|
|
22426
21464
|
}
|
|
22427
|
-
const s =
|
|
21465
|
+
const s = createCliSpinner(fmt);
|
|
22428
21466
|
s.start(`Rolling back ${worker} to version ${targetVersion}...`);
|
|
22429
21467
|
const rollResult = await cf.versionsRollback(worker, targetVersion);
|
|
22430
21468
|
if (!rollResult.ok) {
|
|
@@ -22519,7 +21557,8 @@ OPTIONS:
|
|
|
22519
21557
|
|
|
22520
21558
|
EXAMPLES:
|
|
22521
21559
|
hoox deploy workers
|
|
22522
|
-
hoox deploy workers --env staging`).option("--env <env>", "Cloudflare environment (e.g. production, staging)").action(withErrorHandling(async (options) => {
|
|
21560
|
+
hoox deploy workers --env staging`).option("--env <env>", "Cloudflare environment (e.g. production, staging)").action(withErrorHandling(async (options, cmd) => {
|
|
21561
|
+
const fmt = getFormatOptions(cmd);
|
|
22523
21562
|
const configService = new ConfigService;
|
|
22524
21563
|
await configService.load();
|
|
22525
21564
|
const cf = new CloudflareService;
|
|
@@ -22546,7 +21585,7 @@ ${theme.heading("Deploying Workers")}
|
|
|
22546
21585
|
|
|
22547
21586
|
`);
|
|
22548
21587
|
for (const name of ordered) {
|
|
22549
|
-
const s =
|
|
21588
|
+
const s = createCliSpinner(fmt);
|
|
22550
21589
|
s.start(`Deploying ${name}...`);
|
|
22551
21590
|
const result = await deploySingle(configService, cf, name, options.env);
|
|
22552
21591
|
results.push(result);
|
|
@@ -22625,7 +21664,7 @@ EXAMPLES:
|
|
|
22625
21664
|
hoox deploy dashboard --rebuild Force rebuild before deploying`).option("--rebuild", "Force rebuild of dashboard before deploying").action(withErrorHandling(async (options, cmd) => {
|
|
22626
21665
|
const fmt = getFormatOptions(cmd);
|
|
22627
21666
|
const cf = new CloudflareService;
|
|
22628
|
-
const result = await deployDashboard(cf, options.rebuild);
|
|
21667
|
+
const result = await deployDashboard(cf, options.rebuild, false, false, fmt);
|
|
22629
21668
|
if (result.success) {
|
|
22630
21669
|
const url = result.url ? ` \u2014 ${result.url}` : "";
|
|
22631
21670
|
formatSuccess(`Dashboard deployed${url}`, fmt);
|
|
@@ -22715,7 +21754,6 @@ function register2(program) {
|
|
|
22715
21754
|
}
|
|
22716
21755
|
}
|
|
22717
21756
|
// src/commands/infra/infra-command.ts
|
|
22718
|
-
init_dist4();
|
|
22719
21757
|
init_main();
|
|
22720
21758
|
import { resolve as resolve3 } from "path";
|
|
22721
21759
|
init_config2();
|
|
@@ -22964,7 +22002,7 @@ async function doProvision(opts, cf, config) {
|
|
|
22964
22002
|
summary: { total: 0, created: 0, errors: 0, exists: 0 }
|
|
22965
22003
|
};
|
|
22966
22004
|
}
|
|
22967
|
-
const s =
|
|
22005
|
+
const s = createCliSpinner(opts);
|
|
22968
22006
|
for (const workerName of enabledWorkers) {
|
|
22969
22007
|
const workerConfig = configService.getWorker(workerName);
|
|
22970
22008
|
if (!workerConfig?.path)
|
|
@@ -23449,7 +22487,13 @@ async function handleShow(opts) {
|
|
|
23449
22487
|
}
|
|
23450
22488
|
const vars = await EnvService.loadDotEnvAsync(".env.local");
|
|
23451
22489
|
if (opts.json) {
|
|
23452
|
-
|
|
22490
|
+
const defs = EnvService.getDefinitions();
|
|
22491
|
+
const secretNames = new Set(defs.filter((d) => d.secret).map((d) => d.name));
|
|
22492
|
+
const redacted = {};
|
|
22493
|
+
for (const [name, val] of Object.entries(vars)) {
|
|
22494
|
+
redacted[name] = secretNames.has(name) && val ? "********" : val;
|
|
22495
|
+
}
|
|
22496
|
+
formatJson(redacted, opts);
|
|
23453
22497
|
} else {
|
|
23454
22498
|
process.stdout.write(EnvService.show(vars));
|
|
23455
22499
|
}
|
|
@@ -23701,11 +22745,11 @@ EXAMPLES:
|
|
|
23701
22745
|
}
|
|
23702
22746
|
|
|
23703
22747
|
// src/commands/config/secrets-subcommands.ts
|
|
23704
|
-
init_dist4();
|
|
23705
22748
|
init_secrets();
|
|
23706
22749
|
init_errors4();
|
|
23707
22750
|
init_theme();
|
|
23708
22751
|
init_wrangler_output();
|
|
22752
|
+
init_env_file();
|
|
23709
22753
|
function reportSecretSync(result, opts, scopeLabel) {
|
|
23710
22754
|
const nOk = result.synced.length;
|
|
23711
22755
|
const nSkip = result.skipped.length;
|
|
@@ -23730,9 +22774,12 @@ function reportSecretSync(result, opts, scopeLabel) {
|
|
|
23730
22774
|
return;
|
|
23731
22775
|
}
|
|
23732
22776
|
const detailParts = [];
|
|
23733
|
-
|
|
23734
|
-
|
|
23735
|
-
|
|
22777
|
+
const failedBlock = formatSecretFailureDetails(result.failed.map((f) => ({
|
|
22778
|
+
name: f.name,
|
|
22779
|
+
reason: f.reason ?? "failed"
|
|
22780
|
+
})));
|
|
22781
|
+
if (failedBlock)
|
|
22782
|
+
detailParts.push(failedBlock);
|
|
23736
22783
|
for (const s of result.skipped) {
|
|
23737
22784
|
detailParts.push(`\xB7 ${s.name}: ${s.reason ?? "skipped"}`);
|
|
23738
22785
|
}
|
|
@@ -23812,14 +22859,14 @@ async function updateDevVars(filePath, key, value) {
|
|
|
23812
22859
|
let found = false;
|
|
23813
22860
|
for (const line of lines) {
|
|
23814
22861
|
if (line.startsWith(`${key}=`)) {
|
|
23815
|
-
updated.push(
|
|
22862
|
+
updated.push(serializeEnvLine(key, value));
|
|
23816
22863
|
found = true;
|
|
23817
22864
|
} else {
|
|
23818
22865
|
updated.push(line);
|
|
23819
22866
|
}
|
|
23820
22867
|
}
|
|
23821
22868
|
if (!found) {
|
|
23822
|
-
updated.push(
|
|
22869
|
+
updated.push(serializeEnvLine(key, value));
|
|
23823
22870
|
}
|
|
23824
22871
|
while (updated.length > 0 && updated[updated.length - 1] === "") {
|
|
23825
22872
|
updated.pop();
|
|
@@ -23828,7 +22875,7 @@ async function updateDevVars(filePath, key, value) {
|
|
|
23828
22875
|
`) + `
|
|
23829
22876
|
`);
|
|
23830
22877
|
} else {
|
|
23831
|
-
await Bun.write(filePath, `${key
|
|
22878
|
+
await Bun.write(filePath, `${serializeEnvLine(key, value)}
|
|
23832
22879
|
`);
|
|
23833
22880
|
}
|
|
23834
22881
|
await Promise.resolve().then(() => init_fs_secure());
|
|
@@ -23916,7 +22963,7 @@ EXAMPLES:
|
|
|
23916
22963
|
const devVarsPath = `${workerPath}/.dev.vars`;
|
|
23917
22964
|
await updateDevVars(devVarsPath, secretName, value);
|
|
23918
22965
|
formatSuccess(`Secret "${secretName}" updated in ${devVarsPath}`, opts);
|
|
23919
|
-
const syncSpin =
|
|
22966
|
+
const syncSpin = createCliSpinner(opts);
|
|
23920
22967
|
syncSpin.start("Syncing to Cloudflare...");
|
|
23921
22968
|
const result = await svc.syncToCloudflare(workerName);
|
|
23922
22969
|
if (!result.ok) {
|
|
@@ -24019,7 +23066,7 @@ EXAMPLES:
|
|
|
24019
23066
|
const scopeLabel = systemOnly ? "system secret(s)" : "secret(s)";
|
|
24020
23067
|
const svc = await SecretsService.create();
|
|
24021
23068
|
if (workerName) {
|
|
24022
|
-
const syncSpin =
|
|
23069
|
+
const syncSpin = createCliSpinner(opts);
|
|
24023
23070
|
syncSpin.start(`Syncing ${scopeLabel} for "${workerName}"...`);
|
|
24024
23071
|
const result = await svc.syncToCloudflare(workerName, syncOpts);
|
|
24025
23072
|
if (!result.ok) {
|
|
@@ -24045,7 +23092,7 @@ EXAMPLES:
|
|
|
24045
23092
|
let workersOk = 0;
|
|
24046
23093
|
let workersFailed = 0;
|
|
24047
23094
|
let totalSecrets = 0;
|
|
24048
|
-
const syncSpin =
|
|
23095
|
+
const syncSpin = createCliSpinner(opts);
|
|
24049
23096
|
const failures = [];
|
|
24050
23097
|
for (const name of workers) {
|
|
24051
23098
|
syncSpin.start(`Syncing ${name}...`);
|
|
@@ -24540,11 +23587,10 @@ EXAMPLES:
|
|
|
24540
23587
|
registerKeysSubcommands(cmd, "keys");
|
|
24541
23588
|
}
|
|
24542
23589
|
// src/commands/check/check-command.ts
|
|
24543
|
-
init_dist4();
|
|
24544
|
-
init_main();
|
|
24545
|
-
init_config2();
|
|
24546
23590
|
import { readdir } from "fs/promises";
|
|
24547
23591
|
import path4 from "path";
|
|
23592
|
+
init_main();
|
|
23593
|
+
init_config2();
|
|
24548
23594
|
init_secrets();
|
|
24549
23595
|
|
|
24550
23596
|
// src/commands/check/prerequisites-command.ts
|
|
@@ -25002,11 +24048,11 @@ async function runDatabaseChecks(cf, configService) {
|
|
|
25002
24048
|
} else {
|
|
25003
24049
|
checks.push({
|
|
25004
24050
|
name: "Required Tables",
|
|
25005
|
-
success:
|
|
25006
|
-
errors: [
|
|
25007
|
-
warnings: [
|
|
24051
|
+
success: false,
|
|
24052
|
+
errors: [
|
|
25008
24053
|
`Table schema not verified: ${sqlResult.error}. Run: wrangler d1 execute ${dbName} --command="SELECT name FROM sqlite_master WHERE type='table'" --remote`
|
|
25009
|
-
]
|
|
24054
|
+
],
|
|
24055
|
+
warnings: []
|
|
25010
24056
|
});
|
|
25011
24057
|
}
|
|
25012
24058
|
}
|
|
@@ -25231,7 +24277,7 @@ ${theme.warning(icons.warning)} Auto-fix flag set but health issues require manu
|
|
|
25231
24277
|
}
|
|
25232
24278
|
}
|
|
25233
24279
|
async function handleFix(opts, dryRun) {
|
|
25234
|
-
const s =
|
|
24280
|
+
const s = createCliSpinner(opts);
|
|
25235
24281
|
const actions = [];
|
|
25236
24282
|
try {
|
|
25237
24283
|
const configService = new ConfigService;
|
|
@@ -25421,7 +24467,6 @@ async function checkSubmoduleGitignore(_opts) {
|
|
|
25421
24467
|
if (!await gitignoreFile.exists()) {
|
|
25422
24468
|
await Bun.write(gitignorePath, WORKER_GITIGNORE_TEMPLATE);
|
|
25423
24469
|
fixed.push(`${workerName}: created .gitignore`);
|
|
25424
|
-
continue;
|
|
25425
24470
|
}
|
|
25426
24471
|
const content = await gitignoreFile.text();
|
|
25427
24472
|
const lines = content.split(`
|
|
@@ -25451,7 +24496,7 @@ async function checkSubmoduleGitignore(_opts) {
|
|
|
25451
24496
|
};
|
|
25452
24497
|
}
|
|
25453
24498
|
async function handleSubmoduleGitignore(opts) {
|
|
25454
|
-
const s =
|
|
24499
|
+
const s = createCliSpinner(opts);
|
|
25455
24500
|
try {
|
|
25456
24501
|
s.start("Checking submodule .gitignore files...");
|
|
25457
24502
|
const result = await checkSubmoduleGitignore(opts);
|
|
@@ -25833,7 +24878,6 @@ function registerLogsCommand(program) {
|
|
|
25833
24878
|
}, { service: "logs" }));
|
|
25834
24879
|
}
|
|
25835
24880
|
// src/commands/test/test-command.ts
|
|
25836
|
-
init_dist4();
|
|
25837
24881
|
init_config2();
|
|
25838
24882
|
init_theme();
|
|
25839
24883
|
init_errors4();
|
|
@@ -25934,7 +24978,7 @@ function registerTestCommand(program) {
|
|
|
25934
24978
|
const useJson = options.json || fmt.json;
|
|
25935
24979
|
const opts = { json: useJson, quiet: fmt.quiet };
|
|
25936
24980
|
const results = [];
|
|
25937
|
-
const s =
|
|
24981
|
+
const s = createCliSpinner(opts);
|
|
25938
24982
|
const pipelineTimer = startTimer();
|
|
25939
24983
|
s.start("Running CI pipeline...");
|
|
25940
24984
|
for (const step of PIPELINE_STEPS) {
|
|
@@ -26011,8 +25055,9 @@ function registerTestCommand(program) {
|
|
|
26011
25055
|
process.exitCode = 1 /* ERROR */;
|
|
26012
25056
|
}
|
|
26013
25057
|
}, { service: "test" }));
|
|
26014
|
-
testCmd.command("live").description("Run live Cloudflare service integration tests (no mocks)").option("--service <name>", "Test a specific service: d1, kv, r2, queues, ai, api, secrets, durable-objects").action(withErrorHandling(async (options) => {
|
|
26015
|
-
const
|
|
25058
|
+
testCmd.command("live").description("Run live Cloudflare service integration tests (no mocks)").option("--service <name>", "Test a specific service: d1, kv, r2, queues, ai, api, secrets, durable-objects").action(withErrorHandling(async (options, cmd) => {
|
|
25059
|
+
const fmt = getFormatOptions(cmd);
|
|
25060
|
+
const s = createCliSpinner(fmt);
|
|
26016
25061
|
const liveTimer = startTimer();
|
|
26017
25062
|
let filePattern = options.service ? `tests/live/${options.service}.test.ts` : "tests/live/";
|
|
26018
25063
|
s.start(`Running live tests${options.service ? ` for ${options.service}` : ""}...`);
|
|
@@ -26066,14 +25111,19 @@ async function cfApi(method, path, body) {
|
|
|
26066
25111
|
return { ok: false, error: `Cloudflare API request failed: ${message}` };
|
|
26067
25112
|
}
|
|
26068
25113
|
}
|
|
25114
|
+
function quoteIp(value) {
|
|
25115
|
+
const v = value.trim();
|
|
25116
|
+
if (/^[0-9a-fA-F:.]+$/.test(v) || v.includes("/"))
|
|
25117
|
+
return v;
|
|
25118
|
+
return `"${v.replace(/"/g, "\\\"")}"`;
|
|
25119
|
+
}
|
|
26069
25120
|
function buildExpression(type, value) {
|
|
26070
25121
|
switch (type) {
|
|
26071
25122
|
case "ip-allowlist":
|
|
26072
|
-
return `(ip.src eq ${value})`;
|
|
26073
25123
|
case "ip-blocklist":
|
|
26074
|
-
return `(ip.src eq ${value})`;
|
|
25124
|
+
return `(ip.src eq ${quoteIp(value)})`;
|
|
26075
25125
|
case "rate-limit":
|
|
26076
|
-
return
|
|
25126
|
+
return value.trim() ? value : '(http.request.uri.path ne "")';
|
|
26077
25127
|
case "custom":
|
|
26078
25128
|
return value;
|
|
26079
25129
|
}
|
|
@@ -26081,15 +25131,21 @@ function buildExpression(type, value) {
|
|
|
26081
25131
|
function mapAction(type) {
|
|
26082
25132
|
switch (type) {
|
|
26083
25133
|
case "ip-allowlist":
|
|
26084
|
-
return "
|
|
25134
|
+
return "skip";
|
|
26085
25135
|
case "ip-blocklist":
|
|
26086
25136
|
return "block";
|
|
26087
25137
|
case "rate-limit":
|
|
26088
|
-
return "
|
|
25138
|
+
return "block";
|
|
26089
25139
|
case "custom":
|
|
26090
25140
|
return "block";
|
|
26091
25141
|
}
|
|
26092
25142
|
}
|
|
25143
|
+
function customRulesetPath(zoneId) {
|
|
25144
|
+
return `/zones/${zoneId}/rulesets/phases/http_request_firewall_custom/entrypoint`;
|
|
25145
|
+
}
|
|
25146
|
+
function rateLimitRulesetPath(zoneId) {
|
|
25147
|
+
return `/zones/${zoneId}/rulesets/phases/http_ratelimit/entrypoint`;
|
|
25148
|
+
}
|
|
26093
25149
|
async function resolveZone(cf) {
|
|
26094
25150
|
if (process.env.CLOUDFLARE_ZONE_ID) {
|
|
26095
25151
|
return {
|
|
@@ -26106,6 +25162,9 @@ async function resolveZone(cf) {
|
|
|
26106
25162
|
if (lines.length === 0) {
|
|
26107
25163
|
throw new CLIError("No zones found. Set CLOUDFLARE_ZONE_ID environment variable.", 1 /* ERROR */);
|
|
26108
25164
|
}
|
|
25165
|
+
if (lines.length > 1) {
|
|
25166
|
+
throw new CLIError(`Multiple zones found (${lines.length}). Set CLOUDFLARE_ZONE_ID to choose one.`, 2 /* INVALID_USAGE */);
|
|
25167
|
+
}
|
|
26109
25168
|
const firstLine = lines[0];
|
|
26110
25169
|
if (!firstLine) {
|
|
26111
25170
|
throw new CLIError("No zones found. Set CLOUDFLARE_ZONE_ID environment variable.", 1 /* ERROR */);
|
|
@@ -26123,21 +25182,22 @@ async function resolveZone(cf) {
|
|
|
26123
25182
|
async function handleStatus(opts) {
|
|
26124
25183
|
const cf = new CloudflareService;
|
|
26125
25184
|
const zone = await resolveZone(cf);
|
|
26126
|
-
const
|
|
26127
|
-
if (!
|
|
26128
|
-
throw new CLIError(`Failed to get WAF status: ${
|
|
25185
|
+
const securityResult = await cfApi("GET", `/zones/${zone.id}/settings/security_level`);
|
|
25186
|
+
if (!securityResult.ok) {
|
|
25187
|
+
throw new CLIError(`Failed to get WAF status: ${securityResult.error}`, 1 /* ERROR */);
|
|
26129
25188
|
}
|
|
26130
|
-
const rulesResult = await cfApi("GET",
|
|
26131
|
-
const activeRulesCount = rulesResult.ok ? rulesResult.value.length : 0;
|
|
25189
|
+
const rulesResult = await cfApi("GET", customRulesetPath(zone.id));
|
|
25190
|
+
const activeRulesCount = rulesResult.ok ? (rulesResult.value.rules ?? []).filter((r) => r.enabled !== false).length : 0;
|
|
26132
25191
|
let recentBlocks = 0;
|
|
26133
25192
|
const since = new Date(Date.now() - 24 * 60 * 60 * 1000).toISOString();
|
|
26134
25193
|
const analyticsResult = await cfApi("GET", `/zones/${zone.id}/analytics/dashboard?since=${encodeURIComponent(since)}&continuous=true`);
|
|
26135
25194
|
if (analyticsResult.ok) {
|
|
26136
25195
|
recentBlocks = analyticsResult.value.totals?.threats ?? 0;
|
|
26137
25196
|
}
|
|
25197
|
+
const mode = securityResult.value.value;
|
|
26138
25198
|
const status = {
|
|
26139
|
-
enabled:
|
|
26140
|
-
mode
|
|
25199
|
+
enabled: mode !== "essentially_off" && mode !== "off",
|
|
25200
|
+
mode,
|
|
26141
25201
|
activeRulesCount,
|
|
26142
25202
|
recentBlocks,
|
|
26143
25203
|
zoneId: zone.id,
|
|
@@ -26168,17 +25228,17 @@ WAF status for ${zone.name}
|
|
|
26168
25228
|
async function handleRulesList(opts) {
|
|
26169
25229
|
const cf = new CloudflareService;
|
|
26170
25230
|
const zone = await resolveZone(cf);
|
|
26171
|
-
const result = await cfApi("GET",
|
|
25231
|
+
const result = await cfApi("GET", customRulesetPath(zone.id));
|
|
26172
25232
|
if (!result.ok) {
|
|
26173
25233
|
throw new CLIError(`Failed to list firewall rules: ${result.error}`, 1 /* ERROR */);
|
|
26174
25234
|
}
|
|
26175
|
-
const rules = result.value.map((r) => ({
|
|
25235
|
+
const rules = (result.value.rules ?? []).map((r) => ({
|
|
26176
25236
|
id: r.id,
|
|
26177
|
-
description: r.description,
|
|
25237
|
+
description: r.description ?? "",
|
|
26178
25238
|
mode: r.action,
|
|
26179
|
-
expression: r.
|
|
26180
|
-
created_at: r.
|
|
26181
|
-
updated_at: r.
|
|
25239
|
+
expression: r.expression ?? "(unknown)",
|
|
25240
|
+
created_at: r.last_updated ?? "",
|
|
25241
|
+
updated_at: r.last_updated ?? ""
|
|
26182
25242
|
}));
|
|
26183
25243
|
if (opts.json) {
|
|
26184
25244
|
process.stdout.write(JSON.stringify(rules, null, 2) + `
|
|
@@ -26215,31 +25275,44 @@ async function handleRulesAdd(type, value, opts) {
|
|
|
26215
25275
|
const zone = await resolveZone(cf);
|
|
26216
25276
|
const expression = buildExpression(ruleInput.type, value);
|
|
26217
25277
|
const action = mapAction(ruleInput.type);
|
|
26218
|
-
const
|
|
26219
|
-
|
|
26220
|
-
|
|
26221
|
-
|
|
26222
|
-
|
|
26223
|
-
const filterResult = await cfApi("POST", `/zones/${zone.id}/filters`, { expression });
|
|
26224
|
-
if (!filterResult.ok) {
|
|
26225
|
-
throw new CLIError(`Failed to create filter: ${filterResult.error}`, 1 /* ERROR */);
|
|
25278
|
+
const description = ruleInput.description ?? `${ruleInput.type} rule for ${value}`;
|
|
25279
|
+
const phasePath = ruleInput.type === "rate-limit" ? rateLimitRulesetPath(zone.id) : customRulesetPath(zone.id);
|
|
25280
|
+
const entry = await cfApi("GET", phasePath);
|
|
25281
|
+
if (!entry.ok) {
|
|
25282
|
+
throw new CLIError(`Failed to load WAF ruleset: ${entry.error}`, 1 /* ERROR */);
|
|
26226
25283
|
}
|
|
26227
25284
|
const ruleBody = {
|
|
26228
|
-
description
|
|
25285
|
+
description,
|
|
26229
25286
|
action,
|
|
26230
|
-
|
|
25287
|
+
expression,
|
|
25288
|
+
enabled: true
|
|
26231
25289
|
};
|
|
26232
|
-
|
|
25290
|
+
if (ruleInput.type === "ip-allowlist") {
|
|
25291
|
+
ruleBody.action_parameters = { products: ["waf"] };
|
|
25292
|
+
}
|
|
25293
|
+
if (ruleInput.type === "rate-limit") {
|
|
25294
|
+
const perPeriod = Number.parseInt(value, 10);
|
|
25295
|
+
ruleBody.ratelimit = {
|
|
25296
|
+
characteristics: ["cf.colo.id", "ip.src"],
|
|
25297
|
+
period: 10,
|
|
25298
|
+
requests_per_period: Number.isFinite(perPeriod) && perPeriod > 0 ? perPeriod : 100,
|
|
25299
|
+
mitigation_timeout: 60
|
|
25300
|
+
};
|
|
25301
|
+
}
|
|
25302
|
+
const ruleResult = await cfApi("POST", `/zones/${zone.id}/rulesets/${entry.value.id}/rules`, ruleBody);
|
|
26233
25303
|
if (!ruleResult.ok) {
|
|
26234
25304
|
throw new CLIError(`Failed to create firewall rule: ${ruleResult.error}`, 1 /* ERROR */);
|
|
26235
25305
|
}
|
|
26236
|
-
|
|
26237
|
-
formatSuccess(`WAF rule added (${created.id}) \u2014 ${created.action} for "${value}"`, opts);
|
|
25306
|
+
formatSuccess(`WAF rule added (${ruleResult.value.id}) \u2014 ${ruleResult.value.action} for "${value}"`, opts);
|
|
26238
25307
|
}
|
|
26239
25308
|
async function handleRulesRemove(ruleId, opts) {
|
|
26240
25309
|
const cf = new CloudflareService;
|
|
26241
25310
|
const zone = await resolveZone(cf);
|
|
26242
|
-
const
|
|
25311
|
+
const entry = await cfApi("GET", customRulesetPath(zone.id));
|
|
25312
|
+
if (!entry.ok) {
|
|
25313
|
+
throw new CLIError(`Failed to load WAF ruleset: ${entry.error}`, 1 /* ERROR */);
|
|
25314
|
+
}
|
|
25315
|
+
const result = await cfApi("DELETE", `/zones/${zone.id}/rulesets/${entry.value.id}/rules/${ruleId}`);
|
|
26243
25316
|
if (!result.ok) {
|
|
26244
25317
|
throw new CLIError(`Failed to remove firewall rule: ${result.error}`, 1 /* ERROR */);
|
|
26245
25318
|
}
|
|
@@ -26248,7 +25321,7 @@ async function handleRulesRemove(ruleId, opts) {
|
|
|
26248
25321
|
async function handleMode(mode, opts) {
|
|
26249
25322
|
const cf = new CloudflareService;
|
|
26250
25323
|
const zone = await resolveZone(cf);
|
|
26251
|
-
const result = await cfApi("PATCH", `/zones/${zone.id}/settings/
|
|
25324
|
+
const result = await cfApi("PATCH", `/zones/${zone.id}/settings/security_level`, { value: mode === "on" ? "medium" : "essentially_off" });
|
|
26252
25325
|
if (!result.ok) {
|
|
26253
25326
|
throw new CLIError(`Failed to ${mode === "on" ? "enable" : "disable"} WAF: ${result.error}`, 1 /* ERROR */);
|
|
26254
25327
|
}
|
|
@@ -26285,7 +25358,6 @@ function registerWafCommand(program) {
|
|
|
26285
25358
|
}, { service: "waf" }));
|
|
26286
25359
|
}
|
|
26287
25360
|
// src/commands/clone/clone-command.ts
|
|
26288
|
-
init_dist4();
|
|
26289
25361
|
init_config2();
|
|
26290
25362
|
init_src();
|
|
26291
25363
|
init_theme();
|
|
@@ -26429,7 +25501,7 @@ EXAMPLES:
|
|
|
26429
25501
|
return;
|
|
26430
25502
|
}
|
|
26431
25503
|
const repoBase = options.org ? `https://github.com/${options.org}` : await resolveRepoBase();
|
|
26432
|
-
const s =
|
|
25504
|
+
const s = createCliSpinner(fmt);
|
|
26433
25505
|
const cloneTimer = startTimer();
|
|
26434
25506
|
const location = options.home ? "$HOME/.hoox/workers" : "workers/";
|
|
26435
25507
|
s.start(`Cloning ${workers.length} worker(s) to ${location}...`);
|
|
@@ -26502,7 +25574,7 @@ EXAMPLES:
|
|
|
26502
25574
|
return;
|
|
26503
25575
|
}
|
|
26504
25576
|
const repoBase = options.org ? `https://github.com/${options.org}` : await resolveRepoBase();
|
|
26505
|
-
const s =
|
|
25577
|
+
const s = createCliSpinner(fmt);
|
|
26506
25578
|
const singleTimer = startTimer();
|
|
26507
25579
|
const location = options.home ? "$HOME/.hoox/workers" : "workers/";
|
|
26508
25580
|
s.start(`Cloning ${name} to ${location}...`);
|
|
@@ -26570,7 +25642,6 @@ EXAMPLES:
|
|
|
26570
25642
|
}
|
|
26571
25643
|
// src/commands/db/db-command.ts
|
|
26572
25644
|
init_dist4();
|
|
26573
|
-
init_dist4();
|
|
26574
25645
|
|
|
26575
25646
|
// src/services/db/db-service.ts
|
|
26576
25647
|
init_config2();
|
|
@@ -26729,7 +25800,7 @@ async function resolveDb(cmd, svc) {
|
|
|
26729
25800
|
}
|
|
26730
25801
|
async function handleApply(opts, dbName, remote, file) {
|
|
26731
25802
|
const svc = new DbService;
|
|
26732
|
-
const s =
|
|
25803
|
+
const s = createCliSpinner(opts);
|
|
26733
25804
|
const t = startTimer();
|
|
26734
25805
|
s.start("Applying schema...");
|
|
26735
25806
|
try {
|
|
@@ -26747,7 +25818,7 @@ async function handleApply(opts, dbName, remote, file) {
|
|
|
26747
25818
|
}
|
|
26748
25819
|
async function handleMigrate(opts, dbName, remote) {
|
|
26749
25820
|
const svc = new DbService;
|
|
26750
|
-
const s =
|
|
25821
|
+
const s = createCliSpinner(opts);
|
|
26751
25822
|
const t = startTimer();
|
|
26752
25823
|
s.start("Running migrations...");
|
|
26753
25824
|
try {
|
|
@@ -26826,7 +25897,7 @@ async function handleQuery(opts, dbName, sql, remote, allowDestructive) {
|
|
|
26826
25897
|
}
|
|
26827
25898
|
async function handleExport(opts, dbName, outputPath) {
|
|
26828
25899
|
const svc = new DbService;
|
|
26829
|
-
const s =
|
|
25900
|
+
const s = createCliSpinner(opts);
|
|
26830
25901
|
const t = startTimer();
|
|
26831
25902
|
s.start("Exporting database...");
|
|
26832
25903
|
try {
|
|
@@ -26850,7 +25921,7 @@ async function handleReset(opts, dbName, confirmed) {
|
|
|
26850
25921
|
}
|
|
26851
25922
|
}
|
|
26852
25923
|
const svc = new DbService;
|
|
26853
|
-
const s =
|
|
25924
|
+
const s = createCliSpinner(opts);
|
|
26854
25925
|
const t = startTimer();
|
|
26855
25926
|
s.start("Resetting database...");
|
|
26856
25927
|
try {
|
|
@@ -26935,6 +26006,7 @@ EXAMPLES:
|
|
|
26935
26006
|
init_kv_sync_service();
|
|
26936
26007
|
init_errors4();
|
|
26937
26008
|
init_theme();
|
|
26009
|
+
init_src();
|
|
26938
26010
|
function assertSafeInteger(value, name, max) {
|
|
26939
26011
|
if (!Number.isInteger(value) || value < 0 || value > max || !Number.isSafeInteger(value)) {
|
|
26940
26012
|
throw new Error(`Invalid ${name}: ${value} (must be a non-negative integer \u2264 ${max})`);
|
|
@@ -26982,15 +26054,32 @@ async function doMonitorKillSwitch(action, fmt) {
|
|
|
26982
26054
|
try {
|
|
26983
26055
|
const kv = new KvSyncService;
|
|
26984
26056
|
const namespaceId = await kv.resolveNamespaceId();
|
|
26985
|
-
const key = "trade:kill_switch";
|
|
26986
26057
|
if (action === "show") {
|
|
26987
|
-
const
|
|
26988
|
-
|
|
26989
|
-
|
|
26058
|
+
const pairs = await Promise.all(KILL_SWITCH_KEYS.map(async (key) => {
|
|
26059
|
+
const value = await kv.get(namespaceId, key);
|
|
26060
|
+
return [key, value];
|
|
26061
|
+
}));
|
|
26062
|
+
const engaged = pairs.some(([, value]) => isTruthyKillSwitchFlag(value));
|
|
26063
|
+
const header = engaged ? "KILL SWITCH IS ON (trading halted)" : "Kill switch is off (trading active)";
|
|
26064
|
+
if (fmt.json) {
|
|
26065
|
+
process.stdout.write(JSON.stringify({
|
|
26066
|
+
engaged,
|
|
26067
|
+
keys: Object.fromEntries(pairs)
|
|
26068
|
+
}, null, 2) + `
|
|
26990
26069
|
`);
|
|
26070
|
+
return;
|
|
26071
|
+
}
|
|
26072
|
+
process.stdout.write(`${theme.info(header)}
|
|
26073
|
+
`);
|
|
26074
|
+
for (const [key, value] of pairs) {
|
|
26075
|
+
process.stdout.write(theme.dim(` ${key}=${value ?? "(not set)"}
|
|
26076
|
+
`));
|
|
26077
|
+
}
|
|
26991
26078
|
} else {
|
|
26992
26079
|
const newValue = action === "on" ? "true" : "false";
|
|
26993
|
-
|
|
26080
|
+
for (const key of KILL_SWITCH_KEYS) {
|
|
26081
|
+
await kv.set(namespaceId, key, newValue);
|
|
26082
|
+
}
|
|
26994
26083
|
formatSuccess(`Kill switch turned ${action === "on" ? "ON" : "OFF"}`, fmt);
|
|
26995
26084
|
}
|
|
26996
26085
|
} catch (err) {
|
|
@@ -27181,21 +26270,21 @@ EXAMPLES:
|
|
|
27181
26270
|
const fmt = getFormatOptions(cmd);
|
|
27182
26271
|
await doMonitorLogs(worker, fmt);
|
|
27183
26272
|
}, { service: "monitor" }));
|
|
27184
|
-
const ksCmd = monitorCmd.command("kill-switch").summary("Emergency stop or resume trading").description(`Control
|
|
26273
|
+
const ksCmd = monitorCmd.command("kill-switch").summary("Emergency stop or resume trading").description(`Control trade:kill_switch and global:kill_switch.
|
|
27185
26274
|
|
|
27186
26275
|
Commands:
|
|
27187
|
-
show Display current kill switch status
|
|
27188
|
-
on Halt all trading (set
|
|
27189
|
-
off Resume trading (set
|
|
26276
|
+
show Display current kill switch status (either key engaged \u2192 halted)
|
|
26277
|
+
on Halt all trading (set both keys true)
|
|
26278
|
+
off Resume trading (set both keys false)`);
|
|
27190
26279
|
ksCmd.command("show").summary("Show kill switch status").description("Display whether trading is halted or active.").action(withErrorHandling(async (_, cmd) => {
|
|
27191
26280
|
const fmt = getFormatOptions(cmd);
|
|
27192
26281
|
await doMonitorKillSwitch("show", fmt);
|
|
27193
26282
|
}, { service: "monitor" }));
|
|
27194
|
-
ksCmd.command("on").summary("Halt all trading").description("Set trade:kill_switch
|
|
26283
|
+
ksCmd.command("on").summary("Halt all trading").description("Set trade:kill_switch and global:kill_switch to true. WARNING: This halts ALL trading activity immediately.").action(withErrorHandling(async (_, cmd) => {
|
|
27195
26284
|
const fmt = getFormatOptions(cmd);
|
|
27196
26285
|
await doMonitorKillSwitch("on", fmt);
|
|
27197
26286
|
}, { service: "monitor" }));
|
|
27198
|
-
ksCmd.command("off").summary("Resume trading").description("Set trade:kill_switch
|
|
26287
|
+
ksCmd.command("off").summary("Resume trading").description("Set trade:kill_switch and global:kill_switch to false to resume trading.").action(withErrorHandling(async (_, cmd) => {
|
|
27199
26288
|
const fmt = getFormatOptions(cmd);
|
|
27200
26289
|
await doMonitorKillSwitch("off", fmt);
|
|
27201
26290
|
}, { service: "monitor" }));
|
|
@@ -27728,8 +26817,13 @@ async function handleRebuild(fmt) {
|
|
|
27728
26817
|
await config.load();
|
|
27729
26818
|
for (const worker of config.listEnabledWorkers()) {
|
|
27730
26819
|
const cfg = config.getWorker(worker);
|
|
27731
|
-
if (cfg)
|
|
27732
|
-
|
|
26820
|
+
if (!cfg)
|
|
26821
|
+
continue;
|
|
26822
|
+
const deployResult = await cf.deploy(cfg.path);
|
|
26823
|
+
if (!deployResult.ok) {
|
|
26824
|
+
formatError2(new CLIError(`Deploy failed for ${worker}: ${deployResult.error}`, 1 /* ERROR */), fmt);
|
|
26825
|
+
process.exitCode = 1 /* ERROR */;
|
|
26826
|
+
return;
|
|
27733
26827
|
}
|
|
27734
26828
|
}
|
|
27735
26829
|
formatSuccess("Rebuild complete", fmt);
|
|
@@ -27770,7 +26864,6 @@ function registerRepairCommand(program) {
|
|
|
27770
26864
|
}, { service: "repair" }));
|
|
27771
26865
|
}
|
|
27772
26866
|
// src/commands/update/update-command.ts
|
|
27773
|
-
init_dist4();
|
|
27774
26867
|
init_config2();
|
|
27775
26868
|
init_update();
|
|
27776
26869
|
init_errors4();
|
|
@@ -27785,7 +26878,8 @@ With "wrangler", updates wrangler to the latest version.
|
|
|
27785
26878
|
EXAMPLES:
|
|
27786
26879
|
hoox update Pull latest for main repo
|
|
27787
26880
|
hoox update d1-worker Update the d1-worker submodule
|
|
27788
|
-
hoox update wrangler Update wrangler to latest version`).argument("[target]", 'What to update: worker name (e.g. d1-worker) or "wrangler"').action(withErrorHandling(async (target) => {
|
|
26881
|
+
hoox update wrangler Update wrangler to latest version`).argument("[target]", 'What to update: worker name (e.g. d1-worker) or "wrangler"').action(withErrorHandling(async (target, cmd) => {
|
|
26882
|
+
const fmt = getFormatOptions(cmd);
|
|
27789
26883
|
const cwd = process.cwd();
|
|
27790
26884
|
if (target === "wrangler") {
|
|
27791
26885
|
const service = new UpdateService;
|
|
@@ -27809,14 +26903,14 @@ EXAMPLES:
|
|
|
27809
26903
|
if (!await isSubmodule(cwd, submodulePath)) {
|
|
27810
26904
|
throw new CLIError(`"${submodulePath}" is not a git submodule \u2014 nothing to update`, 2 /* INVALID_USAGE */);
|
|
27811
26905
|
}
|
|
27812
|
-
const s =
|
|
26906
|
+
const s = createCliSpinner(fmt);
|
|
27813
26907
|
const t = startTimer();
|
|
27814
26908
|
s.start(`Updating ${target}...`);
|
|
27815
26909
|
const output = await gitSubmoduleUpdate(cwd, submodulePath);
|
|
27816
26910
|
const dur = formatDuration3(t.ms());
|
|
27817
26911
|
s.stop(output ? theme.success(`Updated ${target} (${dur})`) : theme.muted(`${target} already up to date (${dur})`));
|
|
27818
26912
|
} else {
|
|
27819
|
-
const s =
|
|
26913
|
+
const s = createCliSpinner(fmt);
|
|
27820
26914
|
const t = startTimer();
|
|
27821
26915
|
s.start("Pulling latest from remote...");
|
|
27822
26916
|
const output = await gitPull(cwd);
|
|
@@ -27913,7 +27007,7 @@ import { createRequire } from "module";
|
|
|
27913
27007
|
import { resolve as resolve6, dirname as dirname3, join as join9 } from "path";
|
|
27914
27008
|
import { fileURLToPath } from "url";
|
|
27915
27009
|
import { existsSync as existsSync13, realpathSync } from "fs";
|
|
27916
|
-
import { homedir as
|
|
27010
|
+
import { homedir as homedir3 } from "os";
|
|
27917
27011
|
|
|
27918
27012
|
// src/services/perf/endpoint-resolver.ts
|
|
27919
27013
|
import { readFileSync as readFileSync11 } from "fs";
|
|
@@ -27966,7 +27060,7 @@ function collectTuiCandidates() {
|
|
|
27966
27060
|
const cwdRequire = createRequire(join9(process.cwd(), "package.json"));
|
|
27967
27061
|
pushPackageEntries(candidates, cwdRequire);
|
|
27968
27062
|
} catch {}
|
|
27969
|
-
const bunGlobal = join9(
|
|
27063
|
+
const bunGlobal = join9(homedir3(), ".bun", "install", "global", "node_modules", TUI_PKG);
|
|
27970
27064
|
pushPackageRootEntries(candidates, bunGlobal);
|
|
27971
27065
|
const npmGlobal = process.env.npm_config_prefix?.trim();
|
|
27972
27066
|
if (npmGlobal) {
|
|
@@ -28204,6 +27298,7 @@ TUI session ended.
|
|
|
28204
27298
|
console.log(theme.dim(`
|
|
28205
27299
|
TUI exited with code ${code}
|
|
28206
27300
|
`));
|
|
27301
|
+
process.exitCode = code;
|
|
28207
27302
|
resolveChild();
|
|
28208
27303
|
} else {
|
|
28209
27304
|
reject(new CLIError("TUI process terminated abnormally", 1 /* ERROR */));
|
|
@@ -28216,10 +27311,9 @@ TUI exited with code ${code}
|
|
|
28216
27311
|
}, { service: "tui" }));
|
|
28217
27312
|
}
|
|
28218
27313
|
// src/commands/doctor/doctor-command.ts
|
|
28219
|
-
init_dist4();
|
|
28220
27314
|
init_src();
|
|
28221
27315
|
import { join as join11 } from "path";
|
|
28222
|
-
import { homedir as
|
|
27316
|
+
import { homedir as homedir4 } from "os";
|
|
28223
27317
|
|
|
28224
27318
|
// src/services/runtime/runtime-service.ts
|
|
28225
27319
|
init_src();
|
|
@@ -28700,7 +27794,7 @@ Hoox doctor
|
|
|
28700
27794
|
return failed === 0 ? 0 /* SUCCESS */ : 1 /* ERROR */;
|
|
28701
27795
|
}
|
|
28702
27796
|
function printSecurityHygieneSection(env = process.env) {
|
|
28703
|
-
const configPath = join11(
|
|
27797
|
+
const configPath = join11(homedir4(), ".hoox", "config.json");
|
|
28704
27798
|
const lines = collectSecurityHygiene(env, { configPath });
|
|
28705
27799
|
process.stdout.write(theme.heading(`Security hygiene
|
|
28706
27800
|
`));
|
|
@@ -28718,7 +27812,7 @@ async function runSecurityDoctor(options) {
|
|
|
28718
27812
|
env.HOOX_API_URL = options.apiUrl;
|
|
28719
27813
|
}
|
|
28720
27814
|
const profile = resolveOperatorTransportProfile(env);
|
|
28721
|
-
const configPath = join11(
|
|
27815
|
+
const configPath = join11(homedir4(), ".hoox", "config.json");
|
|
28722
27816
|
const hygiene = collectSecurityHygiene(env, { configPath });
|
|
28723
27817
|
const isLocal = profile.apiBase.includes("localhost") || profile.apiBase.includes("127.0.0.1");
|
|
28724
27818
|
const shouldProbe = options.probe === true || options.probe !== false && !isLocal;
|
|
@@ -28810,7 +27904,7 @@ EXAMPLES:
|
|
|
28810
27904
|
return;
|
|
28811
27905
|
}
|
|
28812
27906
|
if (options.fixRuntime) {
|
|
28813
|
-
const s =
|
|
27907
|
+
const s = createCliSpinner(fmt);
|
|
28814
27908
|
const t = startTimer();
|
|
28815
27909
|
s.start("Ensuring global Hoox runtime...");
|
|
28816
27910
|
try {
|
|
@@ -30100,7 +29194,7 @@ EXAMPLES:
|
|
|
30100
29194
|
ye("Dry run complete. Run without --dry-run to execute.");
|
|
30101
29195
|
return;
|
|
30102
29196
|
}
|
|
30103
|
-
const authCheck =
|
|
29197
|
+
const authCheck = createCliSpinner(globalOpts);
|
|
30104
29198
|
authCheck.start("Checking Cloudflare authentication...");
|
|
30105
29199
|
const tempSvc = new SetupService;
|
|
30106
29200
|
const authOk = await tempSvc.checkAuth();
|
|
@@ -30134,7 +29228,7 @@ EXAMPLES:
|
|
|
30134
29228
|
const setupSvc = new SetupService(wireProgress((msg) => {
|
|
30135
29229
|
if (currentSpinner)
|
|
30136
29230
|
currentSpinner.stop();
|
|
30137
|
-
currentSpinner =
|
|
29231
|
+
currentSpinner = createCliSpinner(globalOpts);
|
|
30138
29232
|
currentSpinner.start(msg);
|
|
30139
29233
|
}, (msg) => {
|
|
30140
29234
|
if (currentSpinner)
|
|
@@ -31059,11 +30153,11 @@ async function handleRun(opts, fmt) {
|
|
|
31059
30153
|
config.timeoutMs = parseInt(opts.timeout, 10);
|
|
31060
30154
|
if (opts.apiKey !== undefined)
|
|
31061
30155
|
config.apiKey = opts.apiKey;
|
|
31062
|
-
const
|
|
31063
|
-
|
|
30156
|
+
const spin = createCliSpinner(fmt);
|
|
30157
|
+
spin.start(`Probing fast path: 0/0`);
|
|
31064
30158
|
const service = new FastPathService;
|
|
31065
30159
|
const report = await service.run(config);
|
|
31066
|
-
|
|
30160
|
+
spin.stop(`${report.successful}/${report.iterations} successful (${report.failed} failed${report.degraded ? ", degraded" : ""})`);
|
|
31067
30161
|
if (fmt.json) {
|
|
31068
30162
|
process.stdout.write(JSON.stringify(report, null, 2) + `
|
|
31069
30163
|
`);
|
|
@@ -31127,7 +30221,7 @@ Tailing fast path for ${durationSec}s (interval=${intervalMs}ms, concurrency=${c
|
|
|
31127
30221
|
process.stdout.write(JSON.stringify(report) + `
|
|
31128
30222
|
`);
|
|
31129
30223
|
} else {
|
|
31130
|
-
process.stdout.write(`[${new Date().toISOString()}] n=${report.successful}/${report.iterations} p50=${report.total.p50}ms p95=${report.total.p95}ms
|
|
30224
|
+
process.stdout.write(`[${new Date().toISOString()}] ` + `n=${report.successful}/${report.iterations} ` + `p50=${report.total.p50}ms p95=${report.total.p95}ms
|
|
31131
30225
|
`);
|
|
31132
30226
|
}
|
|
31133
30227
|
const elapsed = Date.now() - batchStart;
|
|
@@ -31190,7 +30284,7 @@ function formatTableAsText(rows, columns) {
|
|
|
31190
30284
|
function parseTimeRange(fromStr, toStr) {
|
|
31191
30285
|
const now = Date.now();
|
|
31192
30286
|
const to = toStr ? parseTimeOrThrow(toStr, "to") : now;
|
|
31193
|
-
const from = fromStr ? parseTimeOrThrow(fromStr, "from") : now -
|
|
30287
|
+
const from = fromStr ? parseTimeOrThrow(fromStr, "from") : now - 60 * 60 * 1000;
|
|
31194
30288
|
return { from, to };
|
|
31195
30289
|
}
|
|
31196
30290
|
function parseTimeOrThrow(s, name) {
|