@hoox-sh/hoox-cli 0.14.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 +828 -1722
- 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,12 +9534,12 @@ 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
|
});
|
|
9559
9541
|
|
|
9560
|
-
// ../../node_modules/.bun/zustand@5.0.
|
|
9542
|
+
// ../../node_modules/.bun/zustand@5.0.16+efb21c635b69fae1/node_modules/zustand/esm/vanilla.mjs
|
|
9561
9543
|
var createStoreImpl = (createState) => {
|
|
9562
9544
|
let state;
|
|
9563
9545
|
const listeners = /* @__PURE__ */ new Set;
|
|
@@ -9581,7 +9563,7 @@ var createStoreImpl = (createState) => {
|
|
|
9581
9563
|
}, createStore = (createState) => createState ? createStoreImpl(createState) : createStoreImpl;
|
|
9582
9564
|
var init_vanilla = () => {};
|
|
9583
9565
|
|
|
9584
|
-
// ../../node_modules/.bun/react@19.3.
|
|
9566
|
+
// ../../node_modules/.bun/react@19.3.1/node_modules/react/cjs/react.development.js
|
|
9585
9567
|
var require_react_development = __commonJS(function(exports, module) {
|
|
9586
9568
|
(function() {
|
|
9587
9569
|
function defineDeprecationWarning(methodName, info) {
|
|
@@ -10422,12 +10404,12 @@ See https://react.dev/link/invalid-hook-call for tips about how to debug and fix
|
|
|
10422
10404
|
exports.useTransition = function() {
|
|
10423
10405
|
return resolveDispatcher().useTransition();
|
|
10424
10406
|
};
|
|
10425
|
-
exports.version = "19.3.
|
|
10407
|
+
exports.version = "19.3.1";
|
|
10426
10408
|
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop === "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
|
|
10427
10409
|
})();
|
|
10428
10410
|
});
|
|
10429
10411
|
|
|
10430
|
-
// ../../node_modules/.bun/react@19.3.
|
|
10412
|
+
// ../../node_modules/.bun/react@19.3.1/node_modules/react/index.js
|
|
10431
10413
|
var require_react = __commonJS(function(exports, module) {
|
|
10432
10414
|
var react_development = __toESM(require_react_development());
|
|
10433
10415
|
if (false) {} else {
|
|
@@ -10435,9 +10417,9 @@ var require_react = __commonJS(function(exports, module) {
|
|
|
10435
10417
|
}
|
|
10436
10418
|
});
|
|
10437
10419
|
|
|
10438
|
-
// ../../node_modules/.bun/zustand@5.0.
|
|
10420
|
+
// ../../node_modules/.bun/zustand@5.0.16+efb21c635b69fae1/node_modules/zustand/esm/react.mjs
|
|
10439
10421
|
function useStore(api, selector = identity) {
|
|
10440
|
-
const slice = import_react.default.useSyncExternalStore(api.subscribe, import_react.default.useCallback(() => selector(api.getState()), [api, selector]),
|
|
10422
|
+
const slice = import_react.default.useSyncExternalStore(api.subscribe, import_react.default.useCallback(() => selector(api.getState()), [api, selector]), () => selector(api.getInitialState()));
|
|
10441
10423
|
import_react.default.useDebugValue(slice);
|
|
10442
10424
|
return slice;
|
|
10443
10425
|
}
|
|
@@ -10452,13 +10434,13 @@ var init_react = __esm(() => {
|
|
|
10452
10434
|
import_react = __toESM(require_react(), 1);
|
|
10453
10435
|
});
|
|
10454
10436
|
|
|
10455
|
-
// ../../node_modules/.bun/zustand@5.0.
|
|
10437
|
+
// ../../node_modules/.bun/zustand@5.0.16+efb21c635b69fae1/node_modules/zustand/esm/index.mjs
|
|
10456
10438
|
var init_esm = __esm(() => {
|
|
10457
10439
|
init_vanilla();
|
|
10458
10440
|
init_react();
|
|
10459
10441
|
});
|
|
10460
10442
|
|
|
10461
|
-
// ../../node_modules/.bun/immer@11.
|
|
10443
|
+
// ../../node_modules/.bun/immer@11.2.9/node_modules/immer/dist/immer.mjs
|
|
10462
10444
|
function die(error, ...args) {
|
|
10463
10445
|
if (true) {
|
|
10464
10446
|
const e = errors3[error];
|
|
@@ -10806,7 +10788,7 @@ function peek(draft, prop) {
|
|
|
10806
10788
|
return source[prop];
|
|
10807
10789
|
}
|
|
10808
10790
|
function isRelocatedBaseRef(state, prop, value) {
|
|
10809
|
-
if (state.type_ !== 1 || !state.allIndicesReassigned_ ||
|
|
10791
|
+
if (state.type_ !== 1 || !state.allIndicesReassigned_ || !isDraftable(value) || value[DRAFT_STATE]) {
|
|
10810
10792
|
return false;
|
|
10811
10793
|
}
|
|
10812
10794
|
return state.baseRefs_.has(value);
|
|
@@ -10880,7 +10862,10 @@ function currentImpl(value) {
|
|
|
10880
10862
|
} else {
|
|
10881
10863
|
copy = shallowCopy(value, true);
|
|
10882
10864
|
}
|
|
10883
|
-
|
|
10865
|
+
const source = copy;
|
|
10866
|
+
if (isSet(copy))
|
|
10867
|
+
copy = /* @__PURE__ */ new Set;
|
|
10868
|
+
each(source, (key, childValue) => {
|
|
10884
10869
|
set(copy, key, currentImpl(childValue));
|
|
10885
10870
|
}, strict);
|
|
10886
10871
|
if (state) {
|
|
@@ -11192,7 +11177,7 @@ var init_immer = __esm(() => {
|
|
|
11192
11177
|
produce = immer.produce;
|
|
11193
11178
|
});
|
|
11194
11179
|
|
|
11195
|
-
// ../../node_modules/.bun/zustand@5.0.
|
|
11180
|
+
// ../../node_modules/.bun/zustand@5.0.16+efb21c635b69fae1/node_modules/zustand/esm/middleware/immer.mjs
|
|
11196
11181
|
var immerImpl = (initializer) => (set, get, store) => {
|
|
11197
11182
|
store.setState = (updater, replace, ...args) => {
|
|
11198
11183
|
const nextState = typeof updater === "function" ? produce(updater) : updater;
|
|
@@ -11570,7 +11555,7 @@ var init_service_store = __esm(() => {
|
|
|
11570
11555
|
};
|
|
11571
11556
|
});
|
|
11572
11557
|
|
|
11573
|
-
// ../../node_modules/.bun/zustand@5.0.
|
|
11558
|
+
// ../../node_modules/.bun/zustand@5.0.16+efb21c635b69fae1/node_modules/zustand/esm/middleware.mjs
|
|
11574
11559
|
function createJSONStorage(getStorage, options) {
|
|
11575
11560
|
let storage;
|
|
11576
11561
|
try {
|
|
@@ -11652,8 +11637,8 @@ var toThenable = (fn) => (input) => {
|
|
|
11652
11637
|
});
|
|
11653
11638
|
};
|
|
11654
11639
|
const savedSetState = api.setState;
|
|
11655
|
-
api.setState = (
|
|
11656
|
-
savedSetState(
|
|
11640
|
+
api.setState = (...args) => {
|
|
11641
|
+
savedSetState(...args);
|
|
11657
11642
|
return setItem();
|
|
11658
11643
|
};
|
|
11659
11644
|
const configResult = config((...args) => {
|
|
@@ -11920,7 +11905,6 @@ var init_src = __esm(() => {
|
|
|
11920
11905
|
init_kvUtils();
|
|
11921
11906
|
init_analytics();
|
|
11922
11907
|
init_health();
|
|
11923
|
-
init_d1();
|
|
11924
11908
|
init_service_bindings();
|
|
11925
11909
|
init_colors();
|
|
11926
11910
|
init_config();
|
|
@@ -11928,6 +11912,7 @@ var init_src = __esm(() => {
|
|
|
11928
11912
|
init_sse();
|
|
11929
11913
|
init_operator_transport();
|
|
11930
11914
|
init_session();
|
|
11915
|
+
init_types();
|
|
11931
11916
|
init_path_utils();
|
|
11932
11917
|
init_dashboard_manifest();
|
|
11933
11918
|
init_agent_config_fields();
|
|
@@ -11935,7 +11920,7 @@ var init_src = __esm(() => {
|
|
|
11935
11920
|
init_ui_store();
|
|
11936
11921
|
init_service_store();
|
|
11937
11922
|
init_config_store();
|
|
11938
|
-
|
|
11923
|
+
init_schemas3();
|
|
11939
11924
|
});
|
|
11940
11925
|
|
|
11941
11926
|
// src/utils/errors.ts
|
|
@@ -12532,44 +12517,6 @@ function d(r, t, s) {
|
|
|
12532
12517
|
const e = r + t, i = Math.max(s.length - 1, 0), n = e < 0 ? i : e > i ? 0 : e;
|
|
12533
12518
|
return s[n].disabled ? d(n, t < 0 ? -1 : 1, s) : n;
|
|
12534
12519
|
}
|
|
12535
|
-
function I(r, t, s, e) {
|
|
12536
|
-
const i = e.split(`
|
|
12537
|
-
`);
|
|
12538
|
-
let n = 0, o = r;
|
|
12539
|
-
for (const a of i) {
|
|
12540
|
-
if (o <= a.length)
|
|
12541
|
-
break;
|
|
12542
|
-
o -= a.length + 1, n++;
|
|
12543
|
-
}
|
|
12544
|
-
for (n = Math.max(0, Math.min(i.length - 1, n + s)), o = Math.min(o, i[n].length) + t;o < 0 && n > 0; )
|
|
12545
|
-
n--, o += i[n].length + 1;
|
|
12546
|
-
for (;o > i[n].length && n < i.length - 1; )
|
|
12547
|
-
o -= i[n].length + 1, n++;
|
|
12548
|
-
o = Math.max(0, Math.min(i[n].length, o));
|
|
12549
|
-
let u = 0;
|
|
12550
|
-
for (let a = 0;a < n; a++)
|
|
12551
|
-
u += i[a].length + 1;
|
|
12552
|
-
return u + o;
|
|
12553
|
-
}
|
|
12554
|
-
function j(r) {
|
|
12555
|
-
if (r.aliases !== undefined) {
|
|
12556
|
-
const t = r.aliases;
|
|
12557
|
-
for (const s in t) {
|
|
12558
|
-
if (!Object.hasOwn(t, s))
|
|
12559
|
-
continue;
|
|
12560
|
-
const e = t[s];
|
|
12561
|
-
h.actions.has(e) && (h.aliases.has(s) || h.aliases.set(s, e));
|
|
12562
|
-
}
|
|
12563
|
-
}
|
|
12564
|
-
if (r.messages !== undefined) {
|
|
12565
|
-
const t = r.messages;
|
|
12566
|
-
t.cancel !== undefined && (h.messages.cancel = t.cancel), t.error !== undefined && (h.messages.error = t.error);
|
|
12567
|
-
}
|
|
12568
|
-
if (r.withGuide !== undefined && (h.withGuide = r.withGuide !== false), r.date !== undefined) {
|
|
12569
|
-
const t = r.date;
|
|
12570
|
-
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));
|
|
12571
|
-
}
|
|
12572
|
-
}
|
|
12573
12520
|
function C(r, t) {
|
|
12574
12521
|
if (typeof r == "string")
|
|
12575
12522
|
return h.aliases.get(r) === t;
|
|
@@ -12626,54 +12573,6 @@ function W(r, t, s, e = s, i) {
|
|
|
12626
12573
|
}).join(`
|
|
12627
12574
|
`);
|
|
12628
12575
|
}
|
|
12629
|
-
function B(r, t) {
|
|
12630
|
-
if (r === undefined || t.length === 0)
|
|
12631
|
-
return 0;
|
|
12632
|
-
const s = t.findIndex((e) => e.value === r);
|
|
12633
|
-
return s !== -1 ? s : 0;
|
|
12634
|
-
}
|
|
12635
|
-
function J(r, t) {
|
|
12636
|
-
return (t.label ?? String(t.value)).toLowerCase().includes(r.toLowerCase());
|
|
12637
|
-
}
|
|
12638
|
-
function H(r, t) {
|
|
12639
|
-
if (t)
|
|
12640
|
-
return r ? t : t[0];
|
|
12641
|
-
}
|
|
12642
|
-
function P(r) {
|
|
12643
|
-
return [...r].map((t) => Z[t]);
|
|
12644
|
-
}
|
|
12645
|
-
function tt(r) {
|
|
12646
|
-
const t = new Intl.DateTimeFormat(r, { year: "numeric", month: "2-digit", day: "2-digit" }).formatToParts(new Date(2000, 0, 15)), s = [];
|
|
12647
|
-
let e = "/";
|
|
12648
|
-
for (const i of t)
|
|
12649
|
-
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 });
|
|
12650
|
-
return { segments: s, separator: e };
|
|
12651
|
-
}
|
|
12652
|
-
function U(r) {
|
|
12653
|
-
return Number.parseInt((r || "0").replace(/_/g, "0"), 10) || 0;
|
|
12654
|
-
}
|
|
12655
|
-
function x(r) {
|
|
12656
|
-
return { year: U(r.year), month: U(r.month), day: U(r.day) };
|
|
12657
|
-
}
|
|
12658
|
-
function $(r, t) {
|
|
12659
|
-
return new Date(r || 2001, t || 1, 0).getDate();
|
|
12660
|
-
}
|
|
12661
|
-
function F(r) {
|
|
12662
|
-
const { year: t, month: s, day: e } = x(r);
|
|
12663
|
-
if (!t || t < 0 || t > 9999 || !s || s < 1 || s > 12 || !e || e < 1)
|
|
12664
|
-
return;
|
|
12665
|
-
const i = new Date(Date.UTC(t, s - 1, e));
|
|
12666
|
-
if (!(i.getUTCFullYear() !== t || i.getUTCMonth() !== s - 1 || i.getUTCDate() !== e))
|
|
12667
|
-
return { year: t, month: s, day: e };
|
|
12668
|
-
}
|
|
12669
|
-
function N(r) {
|
|
12670
|
-
const t = F(r);
|
|
12671
|
-
return t ? new Date(Date.UTC(t.year, t.month - 1, t.day)) : undefined;
|
|
12672
|
-
}
|
|
12673
|
-
function st(r, t, s, e) {
|
|
12674
|
-
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;
|
|
12675
|
-
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) };
|
|
12676
|
-
}
|
|
12677
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 {
|
|
12678
12577
|
input;
|
|
12679
12578
|
output;
|
|
@@ -12803,7 +12702,7 @@ var import_sisteransi, G, K, h, Y, k, A = (r) => ("columns" in r) && typeof r.co
|
|
|
12803
12702
|
this.output.write(t), this.state === "initial" && (this.state = "active"), this._prevFrame = t;
|
|
12804
12703
|
}
|
|
12805
12704
|
}
|
|
12806
|
-
},
|
|
12705
|
+
}, X, ot, ut, ht;
|
|
12807
12706
|
var init_dist3 = __esm(() => {
|
|
12808
12707
|
init_main2();
|
|
12809
12708
|
import_sisteransi = __toESM(require_src(), 1);
|
|
@@ -12812,72 +12711,6 @@ var init_dist3 = __esm(() => {
|
|
|
12812
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)}` } } };
|
|
12813
12712
|
Y = globalThis.process.platform.startsWith("win");
|
|
12814
12713
|
k = Symbol("clack:cancel");
|
|
12815
|
-
Q = class extends p {
|
|
12816
|
-
filteredOptions;
|
|
12817
|
-
multiple;
|
|
12818
|
-
isNavigating = false;
|
|
12819
|
-
selectedValues = [];
|
|
12820
|
-
focusedValue;
|
|
12821
|
-
#s = 0;
|
|
12822
|
-
#r = "";
|
|
12823
|
-
#t;
|
|
12824
|
-
#n;
|
|
12825
|
-
#u;
|
|
12826
|
-
get cursor() {
|
|
12827
|
-
return this.#s;
|
|
12828
|
-
}
|
|
12829
|
-
get userInputWithCursor() {
|
|
12830
|
-
if (!this.userInput)
|
|
12831
|
-
return v(["inverse", "hidden"], "_");
|
|
12832
|
-
if (this._cursor >= this.userInput.length)
|
|
12833
|
-
return `${this.userInput}\u2588`;
|
|
12834
|
-
const t = this.userInput.slice(0, this._cursor), [s, ...e] = this.userInput.slice(this._cursor);
|
|
12835
|
-
return `${t}${v("inverse", s)}${e.join("")}`;
|
|
12836
|
-
}
|
|
12837
|
-
get options() {
|
|
12838
|
-
return typeof this.#n == "function" ? this.#n() : this.#n;
|
|
12839
|
-
}
|
|
12840
|
-
constructor(t) {
|
|
12841
|
-
super(t), this.#n = t.options, this.#u = t.placeholder;
|
|
12842
|
-
const s = this.options;
|
|
12843
|
-
this.filteredOptions = [...s], this.multiple = t.multiple === true, this.#t = typeof t.options == "function" ? t.filter : t.filter ?? J;
|
|
12844
|
-
let e;
|
|
12845
|
-
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)
|
|
12846
|
-
for (const i of e) {
|
|
12847
|
-
const n = s.findIndex((o) => o.value === i);
|
|
12848
|
-
n !== -1 && (this.toggleSelected(i), this.#s = n);
|
|
12849
|
-
}
|
|
12850
|
-
this.focusedValue = this.options[this.#s]?.value, this.on("key", (i, n) => this.#e(i, n)), this.on("userInput", (i) => this.#i(i));
|
|
12851
|
-
}
|
|
12852
|
-
_isActionKey(t, s) {
|
|
12853
|
-
return t === "\t" || this.multiple && this.isNavigating && s.name === "space" && t !== undefined && t !== "";
|
|
12854
|
-
}
|
|
12855
|
-
#e(t, s) {
|
|
12856
|
-
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));
|
|
12857
|
-
if (s.name === "tab" && o && l) {
|
|
12858
|
-
this.userInput === "\t" && this._clearUserInput(), this._setUserInput(u, true), this.isNavigating = false;
|
|
12859
|
-
return;
|
|
12860
|
-
}
|
|
12861
|
-
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);
|
|
12862
|
-
}
|
|
12863
|
-
deselectAll() {
|
|
12864
|
-
this.selectedValues = [];
|
|
12865
|
-
}
|
|
12866
|
-
toggleSelected(t) {
|
|
12867
|
-
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]);
|
|
12868
|
-
}
|
|
12869
|
-
#i(t) {
|
|
12870
|
-
if (t !== this.#r) {
|
|
12871
|
-
this.#r = t;
|
|
12872
|
-
const s = this.options;
|
|
12873
|
-
t && this.#t ? this.filteredOptions = s.filter((n) => this.#t?.(t, n)) : this.filteredOptions = [...s];
|
|
12874
|
-
const e = B(this.focusedValue, this.filteredOptions);
|
|
12875
|
-
this.#s = d(e, 0, this.filteredOptions);
|
|
12876
|
-
const i = this.filteredOptions[this.#s];
|
|
12877
|
-
i && !i.disabled ? this.focusedValue = i.value : this.focusedValue = undefined, this.multiple || (this.focusedValue !== undefined ? this.toggleSelected(this.focusedValue) : this.deselectAll());
|
|
12878
|
-
}
|
|
12879
|
-
}
|
|
12880
|
-
};
|
|
12881
12714
|
X = class X extends p {
|
|
12882
12715
|
get cursor() {
|
|
12883
12716
|
return this.value ? 0 : 1;
|
|
@@ -12895,325 +12728,6 @@ var init_dist3 = __esm(() => {
|
|
|
12895
12728
|
});
|
|
12896
12729
|
}
|
|
12897
12730
|
};
|
|
12898
|
-
Z = { Y: { type: "year", len: 4 }, M: { type: "month", len: 2 }, D: { type: "day", len: 2 } };
|
|
12899
|
-
et = class et extends p {
|
|
12900
|
-
#s;
|
|
12901
|
-
#r;
|
|
12902
|
-
#t;
|
|
12903
|
-
#n;
|
|
12904
|
-
#u;
|
|
12905
|
-
#e = { segmentIndex: 0, positionInSegment: 0 };
|
|
12906
|
-
#i = true;
|
|
12907
|
-
#o = null;
|
|
12908
|
-
inlineError = "";
|
|
12909
|
-
get segmentCursor() {
|
|
12910
|
-
return { ...this.#e };
|
|
12911
|
-
}
|
|
12912
|
-
get segmentValues() {
|
|
12913
|
-
return { ...this.#t };
|
|
12914
|
-
}
|
|
12915
|
-
get segments() {
|
|
12916
|
-
return this.#s;
|
|
12917
|
-
}
|
|
12918
|
-
get separator() {
|
|
12919
|
-
return this.#r;
|
|
12920
|
-
}
|
|
12921
|
-
get formattedValue() {
|
|
12922
|
-
return this.#c(this.#t);
|
|
12923
|
-
}
|
|
12924
|
-
#c(t) {
|
|
12925
|
-
return this.#s.map((s) => t[s.type]).join(this.#r);
|
|
12926
|
-
}
|
|
12927
|
-
#a() {
|
|
12928
|
-
this._setUserInput(this.#c(this.#t)), this._setValue(N(this.#t) ?? undefined);
|
|
12929
|
-
}
|
|
12930
|
-
constructor(t) {
|
|
12931
|
-
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);
|
|
12932
|
-
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));
|
|
12933
|
-
}
|
|
12934
|
-
#h() {
|
|
12935
|
-
const t = Math.max(0, Math.min(this.#e.segmentIndex, this.#s.length - 1)), s = this.#s[t];
|
|
12936
|
-
if (s)
|
|
12937
|
-
return this.#e.positionInSegment = Math.max(0, Math.min(this.#e.positionInSegment, s.len - 1)), { segment: s, index: t };
|
|
12938
|
-
}
|
|
12939
|
-
#l(t) {
|
|
12940
|
-
this.inlineError = "", this.#o = null;
|
|
12941
|
-
const s = this.#h();
|
|
12942
|
-
s && (this.#e.segmentIndex = Math.max(0, Math.min(this.#s.length - 1, s.index + t)), this.#e.positionInSegment = 0, this.#i = true);
|
|
12943
|
-
}
|
|
12944
|
-
#p(t) {
|
|
12945
|
-
const s = this.#h();
|
|
12946
|
-
if (!s)
|
|
12947
|
-
return;
|
|
12948
|
-
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);
|
|
12949
|
-
let a;
|
|
12950
|
-
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();
|
|
12951
|
-
}
|
|
12952
|
-
#d(t) {
|
|
12953
|
-
if (t)
|
|
12954
|
-
switch (t) {
|
|
12955
|
-
case "right":
|
|
12956
|
-
return this.#l(1);
|
|
12957
|
-
case "left":
|
|
12958
|
-
return this.#l(-1);
|
|
12959
|
-
case "up":
|
|
12960
|
-
return this.#p(1);
|
|
12961
|
-
case "down":
|
|
12962
|
-
return this.#p(-1);
|
|
12963
|
-
}
|
|
12964
|
-
}
|
|
12965
|
-
#f(t, s) {
|
|
12966
|
-
if (s?.name === "backspace" || s?.sequence === "\x7F" || s?.sequence === "\b" || t === "\x7F" || t === "\b") {
|
|
12967
|
-
this.inlineError = "";
|
|
12968
|
-
const e = this.#h();
|
|
12969
|
-
if (!e)
|
|
12970
|
-
return;
|
|
12971
|
-
if (!this.#t[e.segment.type].replace(/_/g, "")) {
|
|
12972
|
-
this.#l(-1);
|
|
12973
|
-
return;
|
|
12974
|
-
}
|
|
12975
|
-
this.#t[e.segment.type] = "_".repeat(e.segment.len), this.#i = true, this.#e.positionInSegment = 0, this.#a();
|
|
12976
|
-
return;
|
|
12977
|
-
}
|
|
12978
|
-
if (s?.name === "tab") {
|
|
12979
|
-
this.inlineError = "";
|
|
12980
|
-
const e = this.#h();
|
|
12981
|
-
if (!e)
|
|
12982
|
-
return;
|
|
12983
|
-
const i = s.shift ? -1 : 1, n = e.index + i;
|
|
12984
|
-
n >= 0 && n < this.#s.length && (this.#e.segmentIndex = n, this.#e.positionInSegment = 0, this.#i = true);
|
|
12985
|
-
return;
|
|
12986
|
-
}
|
|
12987
|
-
if (t && /^[0-9]$/.test(t)) {
|
|
12988
|
-
const e = this.#h();
|
|
12989
|
-
if (!e)
|
|
12990
|
-
return;
|
|
12991
|
-
const { segment: i } = e, n = !this.#t[i.type].replace(/_/g, "");
|
|
12992
|
-
if (this.#i && this.#o !== null && !n) {
|
|
12993
|
-
const m = this.#o + t, g = { ...this.#t, [i.type]: m }, _ = this.#m(g, i);
|
|
12994
|
-
if (_) {
|
|
12995
|
-
this.inlineError = _, this.#o = null, this.#i = false;
|
|
12996
|
-
return;
|
|
12997
|
-
}
|
|
12998
|
-
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);
|
|
12999
|
-
return;
|
|
13000
|
-
}
|
|
13001
|
-
this.#i && !n && (this.#t[i.type] = "_".repeat(i.len), this.#e.positionInSegment = 0), this.#i = false, this.#o = null;
|
|
13002
|
-
const o = this.#t[i.type], u = o.indexOf("_"), a = u >= 0 ? u : Math.min(this.#e.positionInSegment, i.len - 1);
|
|
13003
|
-
if (a < 0 || a >= i.len)
|
|
13004
|
-
return;
|
|
13005
|
-
let l = o.slice(0, a) + t + o.slice(a + 1), f = false;
|
|
13006
|
-
if (a === 0 && o === "__" && (i.type === "month" || i.type === "day")) {
|
|
13007
|
-
const m = Number.parseInt(t, 10);
|
|
13008
|
-
l = `0${t}`, f = m <= (i.type === "month" ? 1 : 2);
|
|
13009
|
-
}
|
|
13010
|
-
if (i.type === "year" && (l = (o.replace(/_/g, "") + t).padStart(i.len, "_")), !l.includes("_")) {
|
|
13011
|
-
const m = { ...this.#t, [i.type]: l }, g = this.#m(m, i);
|
|
13012
|
-
if (g) {
|
|
13013
|
-
this.inlineError = g;
|
|
13014
|
-
return;
|
|
13015
|
-
}
|
|
13016
|
-
}
|
|
13017
|
-
this.inlineError = "", this.#t[i.type] = l;
|
|
13018
|
-
const y = l.includes("_") ? undefined : F(this.#t);
|
|
13019
|
-
if (y) {
|
|
13020
|
-
const { year: m, month: g } = y, _ = $(m, g);
|
|
13021
|
-
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") };
|
|
13022
|
-
}
|
|
13023
|
-
this.#a();
|
|
13024
|
-
const T = l.indexOf("_");
|
|
13025
|
-
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);
|
|
13026
|
-
}
|
|
13027
|
-
}
|
|
13028
|
-
#m(t, s) {
|
|
13029
|
-
const { month: e, day: i } = x(t);
|
|
13030
|
-
if (s.type === "month" && (e < 0 || e > 12))
|
|
13031
|
-
return h.date.messages.invalidMonth;
|
|
13032
|
-
if (s.type === "day" && (i < 0 || i > 31))
|
|
13033
|
-
return h.date.messages.invalidDay(31, "any month");
|
|
13034
|
-
}
|
|
13035
|
-
#g(t) {
|
|
13036
|
-
const { year: s, month: e, day: i } = x(this.#t);
|
|
13037
|
-
if (s && e && i) {
|
|
13038
|
-
const n = $(s, e);
|
|
13039
|
-
this.#t = { ...this.#t, day: String(Math.min(i, n)).padStart(2, "0") };
|
|
13040
|
-
}
|
|
13041
|
-
this.value = N(this.#t) ?? t.defaultValue ?? undefined;
|
|
13042
|
-
}
|
|
13043
|
-
};
|
|
13044
|
-
it = class it extends p {
|
|
13045
|
-
options;
|
|
13046
|
-
cursor = 0;
|
|
13047
|
-
#s;
|
|
13048
|
-
getGroupItems(t) {
|
|
13049
|
-
return this.options.filter((s) => s.group === t);
|
|
13050
|
-
}
|
|
13051
|
-
isGroupSelected(t) {
|
|
13052
|
-
const s = this.getGroupItems(t), e = this.value;
|
|
13053
|
-
return e === undefined ? false : s.every((i) => e.includes(i.value));
|
|
13054
|
-
}
|
|
13055
|
-
toggleValue() {
|
|
13056
|
-
const t = this.options[this.cursor];
|
|
13057
|
-
if (this.value === undefined && (this.value = []), t.group === true) {
|
|
13058
|
-
const s = t.value, e = this.getGroupItems(s);
|
|
13059
|
-
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));
|
|
13060
|
-
} else {
|
|
13061
|
-
const s = this.value.includes(t.value);
|
|
13062
|
-
this.value = s ? this.value.filter((e) => e !== t.value) : [...this.value, t.value];
|
|
13063
|
-
}
|
|
13064
|
-
}
|
|
13065
|
-
constructor(t) {
|
|
13066
|
-
super(t, false);
|
|
13067
|
-
const { options: s } = t;
|
|
13068
|
-
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) => {
|
|
13069
|
-
switch (e) {
|
|
13070
|
-
case "left":
|
|
13071
|
-
case "up": {
|
|
13072
|
-
this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
|
|
13073
|
-
const i = this.options[this.cursor]?.group === true;
|
|
13074
|
-
!this.#s && i && (this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1);
|
|
13075
|
-
break;
|
|
13076
|
-
}
|
|
13077
|
-
case "down":
|
|
13078
|
-
case "right": {
|
|
13079
|
-
this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
|
|
13080
|
-
const i = this.options[this.cursor]?.group === true;
|
|
13081
|
-
!this.#s && i && (this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1);
|
|
13082
|
-
break;
|
|
13083
|
-
}
|
|
13084
|
-
case "space":
|
|
13085
|
-
this.toggleValue();
|
|
13086
|
-
break;
|
|
13087
|
-
}
|
|
13088
|
-
});
|
|
13089
|
-
}
|
|
13090
|
-
};
|
|
13091
|
-
rt = class rt extends p {
|
|
13092
|
-
#s = false;
|
|
13093
|
-
#r;
|
|
13094
|
-
focused = "editor";
|
|
13095
|
-
get userInputWithCursor() {
|
|
13096
|
-
if (this.state === "submit")
|
|
13097
|
-
return this.userInput;
|
|
13098
|
-
const t = this.userInput;
|
|
13099
|
-
if (this.cursor >= t.length)
|
|
13100
|
-
return `${t}\u2588`;
|
|
13101
|
-
const s = t.slice(0, this.cursor), e = t[this.cursor], i = t.slice(this.cursor + 1);
|
|
13102
|
-
return e === `
|
|
13103
|
-
` ? `${s}\u2588
|
|
13104
|
-
${i}` : `${s}${v("inverse", e)}${i}`;
|
|
13105
|
-
}
|
|
13106
|
-
get cursor() {
|
|
13107
|
-
return this._cursor;
|
|
13108
|
-
}
|
|
13109
|
-
#t(t) {
|
|
13110
|
-
if (this.userInput.length === 0) {
|
|
13111
|
-
this._setUserInput(t);
|
|
13112
|
-
return;
|
|
13113
|
-
}
|
|
13114
|
-
this._setUserInput(this.userInput.slice(0, this.cursor) + t + this.userInput.slice(this.cursor));
|
|
13115
|
-
}
|
|
13116
|
-
#n(t) {
|
|
13117
|
-
const s = this.value ?? "";
|
|
13118
|
-
switch (t) {
|
|
13119
|
-
case "up":
|
|
13120
|
-
this._cursor = I(this._cursor, 0, -1, s);
|
|
13121
|
-
return;
|
|
13122
|
-
case "down":
|
|
13123
|
-
this._cursor = I(this._cursor, 0, 1, s);
|
|
13124
|
-
return;
|
|
13125
|
-
case "left":
|
|
13126
|
-
this._cursor = I(this._cursor, -1, 0, s);
|
|
13127
|
-
return;
|
|
13128
|
-
case "right":
|
|
13129
|
-
this._cursor = I(this._cursor, 1, 0, s);
|
|
13130
|
-
return;
|
|
13131
|
-
}
|
|
13132
|
-
}
|
|
13133
|
-
_shouldSubmit(t, s) {
|
|
13134
|
-
if (this.#r)
|
|
13135
|
-
return this.focused === "submit" ? true : (this.#t(`
|
|
13136
|
-
`), this._cursor++, false);
|
|
13137
|
-
const e = this.#s;
|
|
13138
|
-
return this.#s = true, e ? (this.userInput[this.cursor - 1] === `
|
|
13139
|
-
` && (this._setUserInput(this.userInput.slice(0, this.cursor - 1) + this.userInput.slice(this.cursor)), this._cursor--), true) : (this.#t(`
|
|
13140
|
-
`), this._cursor++, false);
|
|
13141
|
-
}
|
|
13142
|
-
constructor(t) {
|
|
13143
|
-
super(t, false), this.#r = t.showSubmit ?? false, this.on("key", (s, e) => {
|
|
13144
|
-
if (e?.name && h.actions.has(e.name)) {
|
|
13145
|
-
this.#n(e.name);
|
|
13146
|
-
return;
|
|
13147
|
-
}
|
|
13148
|
-
if (s === "\t" && this.#r) {
|
|
13149
|
-
this.focused = this.focused === "editor" ? "submit" : "editor";
|
|
13150
|
-
return;
|
|
13151
|
-
}
|
|
13152
|
-
if (e?.name !== "return") {
|
|
13153
|
-
if (this.#s = false, e?.name === "backspace" && this.cursor > 0) {
|
|
13154
|
-
this._setUserInput(this.userInput.slice(0, this.cursor - 1) + this.userInput.slice(this.cursor)), this._cursor--;
|
|
13155
|
-
return;
|
|
13156
|
-
}
|
|
13157
|
-
if (e?.name === "delete" && this.cursor < this.userInput.length) {
|
|
13158
|
-
this._setUserInput(this.userInput.slice(0, this.cursor) + this.userInput.slice(this.cursor + 1));
|
|
13159
|
-
return;
|
|
13160
|
-
}
|
|
13161
|
-
s && (this.#r && this.focused === "submit" && (this.focused = "editor"), this.#t(s ?? ""), this._cursor++);
|
|
13162
|
-
}
|
|
13163
|
-
}), this.on("userInput", (s) => {
|
|
13164
|
-
this._setValue(s);
|
|
13165
|
-
}), this.on("finalize", () => {
|
|
13166
|
-
this.value || (this.value = t.defaultValue), this.value === undefined && (this.value = "");
|
|
13167
|
-
});
|
|
13168
|
-
}
|
|
13169
|
-
};
|
|
13170
|
-
nt = class extends p {
|
|
13171
|
-
options;
|
|
13172
|
-
cursor = 0;
|
|
13173
|
-
get _value() {
|
|
13174
|
-
return this.options[this.cursor].value;
|
|
13175
|
-
}
|
|
13176
|
-
get _enabledOptions() {
|
|
13177
|
-
return this.options.filter((t) => t.disabled !== true);
|
|
13178
|
-
}
|
|
13179
|
-
toggleAll() {
|
|
13180
|
-
const t = this._enabledOptions, s = this.value !== undefined && this.value.length === t.length;
|
|
13181
|
-
this.value = s ? [] : t.map((e) => e.value);
|
|
13182
|
-
}
|
|
13183
|
-
toggleInvert() {
|
|
13184
|
-
const t = this.value;
|
|
13185
|
-
if (!t)
|
|
13186
|
-
return;
|
|
13187
|
-
const s = this._enabledOptions.filter((e) => !t.includes(e.value));
|
|
13188
|
-
this.value = s.map((e) => e.value);
|
|
13189
|
-
}
|
|
13190
|
-
toggleValue() {
|
|
13191
|
-
this.value === undefined && (this.value = []);
|
|
13192
|
-
const t = this.value.includes(this._value);
|
|
13193
|
-
this.value = t ? this.value.filter((s) => s !== this._value) : [...this.value, this._value];
|
|
13194
|
-
}
|
|
13195
|
-
constructor(t) {
|
|
13196
|
-
super(t, false), this.options = t.options, this.value = [...t.initialValues ?? []];
|
|
13197
|
-
const s = Math.max(this.options.findIndex(({ value: e }) => e === t.cursorAt), 0);
|
|
13198
|
-
this.cursor = this.options[s].disabled ? d(s, 1, this.options) : s, this.on("key", (e) => {
|
|
13199
|
-
e === "a" && this.toggleAll(), e === "i" && this.toggleInvert();
|
|
13200
|
-
}), this.on("cursor", (e) => {
|
|
13201
|
-
switch (e) {
|
|
13202
|
-
case "left":
|
|
13203
|
-
case "up":
|
|
13204
|
-
this.cursor = d(this.cursor, -1, this.options);
|
|
13205
|
-
break;
|
|
13206
|
-
case "down":
|
|
13207
|
-
case "right":
|
|
13208
|
-
this.cursor = d(this.cursor, 1, this.options);
|
|
13209
|
-
break;
|
|
13210
|
-
case "space":
|
|
13211
|
-
this.toggleValue();
|
|
13212
|
-
break;
|
|
13213
|
-
}
|
|
13214
|
-
});
|
|
13215
|
-
}
|
|
13216
|
-
};
|
|
13217
12731
|
ot = class ot extends p {
|
|
13218
12732
|
_mask = "\u2022";
|
|
13219
12733
|
get cursor() {
|
|
@@ -13267,23 +12781,6 @@ ${i}` : `${s}${v("inverse", e)}${i}`;
|
|
|
13267
12781
|
});
|
|
13268
12782
|
}
|
|
13269
12783
|
};
|
|
13270
|
-
at = class at extends p {
|
|
13271
|
-
options;
|
|
13272
|
-
cursor = 0;
|
|
13273
|
-
constructor(t) {
|
|
13274
|
-
super(t, false), this.options = t.options;
|
|
13275
|
-
const s = t.caseSensitive === true, e = this.options.map(({ value: [i] }) => s ? i : i?.toLowerCase());
|
|
13276
|
-
this.cursor = Math.max(e.indexOf(t.initialValue), 0), this.on("key", (i, n) => {
|
|
13277
|
-
if (!i)
|
|
13278
|
-
return;
|
|
13279
|
-
const o = s && n.shift ? i.toUpperCase() : i;
|
|
13280
|
-
if (!e.includes(o))
|
|
13281
|
-
return;
|
|
13282
|
-
const u = this.options.find(({ value: [a] }) => s ? a === o : a?.toLowerCase() === i);
|
|
13283
|
-
u && (this.value = u.value, this.state = "submit", this.emit("submit"));
|
|
13284
|
-
});
|
|
13285
|
-
}
|
|
13286
|
-
};
|
|
13287
12784
|
ht = class ht extends p {
|
|
13288
12785
|
get userInputWithCursor() {
|
|
13289
12786
|
if (this.state === "submit")
|
|
@@ -13308,135 +12805,12 @@ ${i}` : `${s}${v("inverse", e)}${i}`;
|
|
|
13308
12805
|
});
|
|
13309
12806
|
|
|
13310
12807
|
// ../../node_modules/.bun/@clack+prompts@1.3.0/node_modules/@clack/prompts/dist/index.mjs
|
|
13311
|
-
var exports_dist = {};
|
|
13312
|
-
__export(exports_dist, {
|
|
13313
|
-
S_BAR: () => $2,
|
|
13314
|
-
S_BAR_END: () => E2,
|
|
13315
|
-
S_BAR_END_RIGHT: () => Et,
|
|
13316
|
-
S_BAR_H: () => st2,
|
|
13317
|
-
S_BAR_START: () => lt,
|
|
13318
|
-
S_BAR_START_RIGHT: () => It,
|
|
13319
|
-
S_CHECKBOX_ACTIVE: () => et2,
|
|
13320
|
-
S_CHECKBOX_INACTIVE: () => J2,
|
|
13321
|
-
S_CHECKBOX_SELECTED: () => U2,
|
|
13322
|
-
S_CONNECT_LEFT: () => xt,
|
|
13323
|
-
S_CORNER_BOTTOM_LEFT: () => dt,
|
|
13324
|
-
S_CORNER_BOTTOM_RIGHT: () => $t,
|
|
13325
|
-
S_CORNER_TOP_LEFT: () => Ot,
|
|
13326
|
-
S_CORNER_TOP_RIGHT: () => ct,
|
|
13327
|
-
S_ERROR: () => gt,
|
|
13328
|
-
S_INFO: () => ht2,
|
|
13329
|
-
S_PASSWORD_MASK: () => Gt,
|
|
13330
|
-
S_RADIO_ACTIVE: () => z2,
|
|
13331
|
-
S_RADIO_INACTIVE: () => H2,
|
|
13332
|
-
S_STEP_ACTIVE: () => _t,
|
|
13333
|
-
S_STEP_CANCEL: () => ot2,
|
|
13334
|
-
S_STEP_ERROR: () => ut2,
|
|
13335
|
-
S_STEP_SUBMIT: () => F2,
|
|
13336
|
-
S_SUCCESS: () => pt,
|
|
13337
|
-
S_WARN: () => mt,
|
|
13338
|
-
autocomplete: () => At,
|
|
13339
|
-
autocompleteMultiselect: () => ie,
|
|
13340
|
-
box: () => oe,
|
|
13341
|
-
cancel: () => me,
|
|
13342
|
-
confirm: () => ue,
|
|
13343
|
-
date: () => le,
|
|
13344
|
-
group: () => he,
|
|
13345
|
-
groupMultiselect: () => pe,
|
|
13346
|
-
intro: () => ge,
|
|
13347
|
-
isCI: () => at2,
|
|
13348
|
-
isCancel: () => q,
|
|
13349
|
-
isTTY: () => Tt,
|
|
13350
|
-
limitOptions: () => Y2,
|
|
13351
|
-
log: () => R2,
|
|
13352
|
-
multiline: () => fe,
|
|
13353
|
-
multiselect: () => ve,
|
|
13354
|
-
note: () => Se,
|
|
13355
|
-
outro: () => ye,
|
|
13356
|
-
password: () => Ce,
|
|
13357
|
-
path: () => Te,
|
|
13358
|
-
progress: () => Ie,
|
|
13359
|
-
select: () => Ee,
|
|
13360
|
-
selectKey: () => Ge,
|
|
13361
|
-
settings: () => h,
|
|
13362
|
-
spinner: () => ft,
|
|
13363
|
-
stream: () => K2,
|
|
13364
|
-
symbol: () => M,
|
|
13365
|
-
symbolBar: () => yt,
|
|
13366
|
-
taskLog: () => Me,
|
|
13367
|
-
tasks: () => xe,
|
|
13368
|
-
text: () => Re,
|
|
13369
|
-
unicode: () => tt2,
|
|
13370
|
-
unicodeOr: () => w2,
|
|
13371
|
-
updateSettings: () => j
|
|
13372
|
-
});
|
|
13373
12808
|
import { styleText as e, stripVTControlCharacters as nt2 } from "util";
|
|
13374
12809
|
import j2 from "process";
|
|
13375
|
-
import { existsSync as zt, lstatSync as wt, readdirSync as Qt } from "fs";
|
|
13376
|
-
import { dirname as bt, join as Zt } from "path";
|
|
13377
12810
|
function te() {
|
|
13378
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";
|
|
13379
12812
|
}
|
|
13380
|
-
|
|
13381
|
-
return t.label ?? String(t.value ?? "");
|
|
13382
|
-
}
|
|
13383
|
-
function Rt(t, r) {
|
|
13384
|
-
if (!t)
|
|
13385
|
-
return true;
|
|
13386
|
-
const s = (r.label ?? String(r.value ?? "")).toLowerCase(), i = (r.hint ?? "").toLowerCase(), u = String(r.value).toLowerCase(), n = t.toLowerCase();
|
|
13387
|
-
return s.includes(n) || i.includes(n) || u.includes(n);
|
|
13388
|
-
}
|
|
13389
|
-
function se(t, r) {
|
|
13390
|
-
const s = [];
|
|
13391
|
-
for (const i of r)
|
|
13392
|
-
t.includes(i.value) && s.push(i);
|
|
13393
|
-
return s;
|
|
13394
|
-
}
|
|
13395
|
-
function Pt(t, r, s, i) {
|
|
13396
|
-
let u = s, n = s;
|
|
13397
|
-
return i === "center" ? u = Math.floor((r - t) / 2) : i === "right" && (u = r - t - s), n = r - u - t, [u, n];
|
|
13398
|
-
}
|
|
13399
|
-
function ce(t, r) {
|
|
13400
|
-
const { segmentValues: s, segmentCursor: i } = t;
|
|
13401
|
-
if (r === "submit" || r === "cancel")
|
|
13402
|
-
return t.formattedValue;
|
|
13403
|
-
const u = e("gray", t.separator);
|
|
13404
|
-
return t.segments.map((n, o) => {
|
|
13405
|
-
const c = o === i.segmentIndex && !["submit", "cancel"].includes(r), a = de[n.type];
|
|
13406
|
-
return $e(s[n.type], { isActive: c, label: a });
|
|
13407
|
-
}).join(u);
|
|
13408
|
-
}
|
|
13409
|
-
function $e(t, r) {
|
|
13410
|
-
const s = !t || t.replace(/_/g, "") === "";
|
|
13411
|
-
return r.isActive ? e("inverse", s ? r.label : t.replace(/_/g, " ")) : s ? e("dim", r.label) : t.replace(/_/g, e("dim", " "));
|
|
13412
|
-
}
|
|
13413
|
-
function Ie({ style: t = "heavy", max: r = 100, size: s = 40, ...i } = {}) {
|
|
13414
|
-
const u = ft(i);
|
|
13415
|
-
let n = 0, o = "";
|
|
13416
|
-
const c = Math.max(1, r), a = Math.max(1, s), l = (m) => {
|
|
13417
|
-
switch (m) {
|
|
13418
|
-
case "initial":
|
|
13419
|
-
case "active":
|
|
13420
|
-
return (g) => e("magenta", g);
|
|
13421
|
-
case "error":
|
|
13422
|
-
case "cancel":
|
|
13423
|
-
return (g) => e("red", g);
|
|
13424
|
-
case "submit":
|
|
13425
|
-
return (g) => e("green", g);
|
|
13426
|
-
default:
|
|
13427
|
-
return (g) => e("magenta", g);
|
|
13428
|
-
}
|
|
13429
|
-
}, d = (m, g) => {
|
|
13430
|
-
const S = Math.floor(n / c * a);
|
|
13431
|
-
return `${l(m)(Vt[t].repeat(S))}${e("dim", Vt[t].repeat(a - S))} ${g}`;
|
|
13432
|
-
}, y = (m = "") => {
|
|
13433
|
-
o = m, u.start(d("initial", m));
|
|
13434
|
-
}, p = (m = 1, g) => {
|
|
13435
|
-
n = Math.min(c, m + n), u.message(d("active", g ?? o)), o = g ?? o;
|
|
13436
|
-
};
|
|
13437
|
-
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) };
|
|
13438
|
-
}
|
|
13439
|
-
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) => {
|
|
13440
12814
|
switch (t) {
|
|
13441
12815
|
case "initial":
|
|
13442
12816
|
case "active":
|
|
@@ -13446,19 +12820,19 @@ var import_sisteransi2, tt2, at2 = () => process.env.CI === "true", Tt = (t) =>
|
|
|
13446
12820
|
case "error":
|
|
13447
12821
|
return e("yellow", ut2);
|
|
13448
12822
|
case "submit":
|
|
13449
|
-
return e("green",
|
|
12823
|
+
return e("green", F);
|
|
13450
12824
|
}
|
|
13451
12825
|
}, yt = (t) => {
|
|
13452
12826
|
switch (t) {
|
|
13453
12827
|
case "initial":
|
|
13454
12828
|
case "active":
|
|
13455
|
-
return e("cyan", $
|
|
12829
|
+
return e("cyan", $);
|
|
13456
12830
|
case "cancel":
|
|
13457
|
-
return e("red", $
|
|
12831
|
+
return e("red", $);
|
|
13458
12832
|
case "error":
|
|
13459
|
-
return e("yellow", $
|
|
12833
|
+
return e("yellow", $);
|
|
13460
12834
|
case "submit":
|
|
13461
|
-
return e("green", $
|
|
12835
|
+
return e("green", $);
|
|
13462
12836
|
}
|
|
13463
12837
|
}, ee = (t, r, s, i, u) => {
|
|
13464
12838
|
let n = r, o = 0;
|
|
@@ -13493,167 +12867,33 @@ var import_sisteransi2, tt2, at2 = () => process.env.CI === "true", Tt = (t) =>
|
|
|
13493
12867
|
for (const G of b)
|
|
13494
12868
|
C.push(G);
|
|
13495
12869
|
return g && C.push(l), C;
|
|
13496
|
-
}, 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() {
|
|
13497
|
-
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) => {
|
|
13498
|
-
const d = Mt(a), y = a.hint && a.value === this.focusedValue ? e("dim", ` (${a.hint})`) : "";
|
|
13499
|
-
switch (l) {
|
|
13500
|
-
case "active":
|
|
13501
|
-
return `${e("green", z2)} ${d}${y}`;
|
|
13502
|
-
case "inactive":
|
|
13503
|
-
return `${e("dim", H2)} ${e("dim", d)}`;
|
|
13504
|
-
case "disabled":
|
|
13505
|
-
return `${e("gray", H2)} ${e(["strikethrough", "gray"], d)}`;
|
|
13506
|
-
}
|
|
13507
|
-
};
|
|
13508
|
-
switch (this.state) {
|
|
13509
|
-
case "submit": {
|
|
13510
|
-
const a = se(this.selectedValues, u), l = a.length > 0 ? ` ${e("dim", a.map(Mt).join(", "))}` : "", d = r ? e("gray", $2) : "";
|
|
13511
|
-
return `${s.join(`
|
|
13512
|
-
`)}
|
|
13513
|
-
${d}${l}`;
|
|
13514
|
-
}
|
|
13515
|
-
case "cancel": {
|
|
13516
|
-
const a = i ? ` ${e(["strikethrough", "dim"], i)}` : "", l = r ? e("gray", $2) : "";
|
|
13517
|
-
return `${s.join(`
|
|
13518
|
-
`)}
|
|
13519
|
-
${l}${a}`;
|
|
13520
|
-
}
|
|
13521
|
-
default: {
|
|
13522
|
-
const a = this.state === "error" ? "yellow" : "cyan", l = r ? `${e(a, $2)} ` : "", d = r ? e(a, E2) : "";
|
|
13523
|
-
let y = "";
|
|
13524
|
-
if (this.isNavigating || o) {
|
|
13525
|
-
const v = o ? n : i;
|
|
13526
|
-
y = v !== "" ? ` ${e("dim", v)}` : "";
|
|
13527
|
-
} else
|
|
13528
|
-
y = ` ${this.userInputWithCursor}`;
|
|
13529
|
-
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)}`] : [];
|
|
13530
|
-
r && s.push(`${l.trimEnd()}`), s.push(`${l}${e("dim", "Search:")}${y}${p}`, ...m, ...g);
|
|
13531
|
-
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 });
|
|
13532
|
-
return [...s, ...f.map((v) => `${l}${v}`), ...h2].join(`
|
|
13533
|
-
`);
|
|
13534
|
-
}
|
|
13535
|
-
}
|
|
13536
|
-
} }).prompt(), ie = (t) => {
|
|
13537
|
-
const r = (i, u, n, o) => {
|
|
13538
|
-
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);
|
|
13539
|
-
return i.disabled ? `${e("gray", J2)} ${e(["strikethrough", "gray"], a)}` : u ? `${d} ${a}${l}` : `${d} ${e("dim", a)}`;
|
|
13540
|
-
}, s = new Q({ options: t.options, multiple: true, placeholder: t.placeholder, filter: t.filter ?? ((i, u) => Rt(i, u)), validate: () => {
|
|
13541
|
-
if (t.required && s.selectedValues.length === 0)
|
|
13542
|
-
return "Please select at least one item";
|
|
13543
|
-
}, initialValue: t.initialValues, signal: t.signal, input: t.input, output: t.output, render() {
|
|
13544
|
-
const i = t.withGuide ?? h.withGuide, u = `${i ? `${e("gray", $2)}
|
|
13545
|
-
` : ""}${M(this.state)} ${t.message}
|
|
13546
|
-
`, 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"})`) : "";
|
|
13547
|
-
switch (this.state) {
|
|
13548
|
-
case "submit":
|
|
13549
|
-
return `${u}${i ? `${e("gray", $2)} ` : ""}${e("dim", `${this.selectedValues.length} items selected`)}`;
|
|
13550
|
-
case "cancel":
|
|
13551
|
-
return `${u}${i ? `${e("gray", $2)} ` : ""}${e(["strikethrough", "dim"], n)}`;
|
|
13552
|
-
default: {
|
|
13553
|
-
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(`
|
|
13554
|
-
`), `${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 });
|
|
13555
|
-
return [...f, ...T.map((C) => `${p}${C}`), ...v].join(`
|
|
13556
|
-
`);
|
|
13557
|
-
}
|
|
13558
|
-
}
|
|
13559
|
-
} });
|
|
13560
|
-
return s.prompt();
|
|
13561
|
-
}, re, ne, ae = (t) => t, oe = (t = "", r = "", s) => {
|
|
13562
|
-
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;
|
|
13563
|
-
let f = Math.floor(u * a) - g;
|
|
13564
|
-
if (s?.width === "auto") {
|
|
13565
|
-
const P = t.split(`
|
|
13566
|
-
`);
|
|
13567
|
-
let N = S + o * 2;
|
|
13568
|
-
for (const rt of P) {
|
|
13569
|
-
const W = dist_default2(rt) + c * 2;
|
|
13570
|
-
W > N && (N = W);
|
|
13571
|
-
}
|
|
13572
|
-
const D = N + n;
|
|
13573
|
-
D < f && (f = D);
|
|
13574
|
-
}
|
|
13575
|
-
f % 2 !== 0 && (f < h2 ? f++ : f--);
|
|
13576
|
-
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 });
|
|
13577
|
-
i.write(`${l}${y[0]}${p.repeat(b)}${C}${p.repeat(G)}${y[1]}
|
|
13578
|
-
`);
|
|
13579
|
-
const A2 = x.split(`
|
|
13580
|
-
`);
|
|
13581
|
-
for (const P of A2) {
|
|
13582
|
-
const [N, D] = Pt(dist_default2(P), v, c, s?.contentAlign);
|
|
13583
|
-
i.write(`${l}${m}${" ".repeat(N)}${P}${" ".repeat(D)}${m}
|
|
13584
|
-
`);
|
|
13585
|
-
}
|
|
13586
|
-
i.write(`${l}${y[2]}${p.repeat(v)}${y[3]}
|
|
13587
|
-
`);
|
|
13588
12870
|
}, ue = (t) => {
|
|
13589
12871
|
const r = t.active ?? "Yes", s = t.inactive ?? "No";
|
|
13590
12872
|
return new X({ active: r, inactive: s, signal: t.signal, input: t.input, output: t.output, initialValue: t.initialValue ?? true, render() {
|
|
13591
|
-
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", $)}
|
|
13592
12874
|
` : ""}${o}
|
|
13593
12875
|
`, a = this.value ? r : s;
|
|
13594
12876
|
switch (this.state) {
|
|
13595
12877
|
case "submit": {
|
|
13596
|
-
const l = i ? `${e("gray", $
|
|
12878
|
+
const l = i ? `${e("gray", $)} ` : "";
|
|
13597
12879
|
return `${c}${l}${e("dim", a)}`;
|
|
13598
12880
|
}
|
|
13599
12881
|
case "cancel": {
|
|
13600
|
-
const l = i ? `${e("gray", $
|
|
12882
|
+
const l = i ? `${e("gray", $)} ` : "";
|
|
13601
12883
|
return `${c}${l}${e(["strikethrough", "dim"], a)}${i ? `
|
|
13602
|
-
${e("gray", $
|
|
12884
|
+
${e("gray", $)}` : ""}`;
|
|
13603
12885
|
}
|
|
13604
12886
|
default: {
|
|
13605
|
-
const l = i ? `${e("cyan", $
|
|
13606
|
-
return `${c}${l}${this.value ? `${e("green", z2)} ${r}` : `${e("dim",
|
|
13607
|
-
${e("cyan", $
|
|
13608
|
-
` : ` ${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}`}
|
|
13609
12891
|
${d}
|
|
13610
12892
|
`;
|
|
13611
12893
|
}
|
|
13612
12894
|
}
|
|
13613
12895
|
} }).prompt();
|
|
13614
|
-
},
|
|
13615
|
-
const r = t.validate;
|
|
13616
|
-
return new et({ ...t, validate(s) {
|
|
13617
|
-
if (s === undefined)
|
|
13618
|
-
return t.defaultValue !== undefined ? undefined : r ? r(s) : h.date.messages.required;
|
|
13619
|
-
const i = (u) => u.toISOString().slice(0, 10);
|
|
13620
|
-
if (t.minDate && i(s) < i(t.minDate))
|
|
13621
|
-
return h.date.messages.afterMin(t.minDate);
|
|
13622
|
-
if (t.maxDate && i(s) > i(t.maxDate))
|
|
13623
|
-
return h.date.messages.beforeMax(t.maxDate);
|
|
13624
|
-
if (r)
|
|
13625
|
-
return r(s);
|
|
13626
|
-
}, render() {
|
|
13627
|
-
const s = (t?.withGuide ?? h.withGuide) !== false, i = `${`${s ? `${e("gray", $2)}
|
|
13628
|
-
` : ""}${M(this.state)} `}${t.message}
|
|
13629
|
-
`, u = this.state !== "initial" ? this.state : "active", n = ce(this, u), o = this.value instanceof Date ? this.formattedValue : "";
|
|
13630
|
-
switch (this.state) {
|
|
13631
|
-
case "error": {
|
|
13632
|
-
const c = this.error ? ` ${e("yellow", this.error)}` : "", a = s ? `${e("yellow", $2)} ` : "", l = s ? e("yellow", E2) : "";
|
|
13633
|
-
return `${i.trim()}
|
|
13634
|
-
${a}${n}
|
|
13635
|
-
${l}${c}
|
|
13636
|
-
`;
|
|
13637
|
-
}
|
|
13638
|
-
case "submit": {
|
|
13639
|
-
const c = o ? ` ${e("dim", o)}` : "", a = s ? e("gray", $2) : "";
|
|
13640
|
-
return `${i}${a}${c}`;
|
|
13641
|
-
}
|
|
13642
|
-
case "cancel": {
|
|
13643
|
-
const c = o ? ` ${e(["strikethrough", "dim"], o)}` : "", a = s ? e("gray", $2) : "";
|
|
13644
|
-
return `${i}${a}${c}${o.trim() ? `
|
|
13645
|
-
${a}` : ""}`;
|
|
13646
|
-
}
|
|
13647
|
-
default: {
|
|
13648
|
-
const c = s ? `${e("cyan", $2)} ` : "", a = s ? e("cyan", E2) : "", l = s ? `${e("cyan", $2)} ` : "", d = this.inlineError ? `
|
|
13649
|
-
${l}${e("yellow", this.inlineError)}` : "";
|
|
13650
|
-
return `${i}${c}${n}${d}
|
|
13651
|
-
${a}
|
|
13652
|
-
`;
|
|
13653
|
-
}
|
|
13654
|
-
}
|
|
13655
|
-
} }).prompt();
|
|
13656
|
-
}, de, he = async (t, r) => {
|
|
12896
|
+
}, he = async (t, r) => {
|
|
13657
12897
|
const s = {}, i = Object.keys(t);
|
|
13658
12898
|
for (const u of i) {
|
|
13659
12899
|
const n = t[u], o = await n({ results: s })?.catch((c) => {
|
|
@@ -13666,79 +12906,6 @@ ${a}
|
|
|
13666
12906
|
s[u] = o;
|
|
13667
12907
|
}
|
|
13668
12908
|
return s;
|
|
13669
|
-
}, pe = (t) => {
|
|
13670
|
-
const { selectableGroups: r = true, groupSpacing: s = 0 } = t, i = (n, o, c = []) => {
|
|
13671
|
-
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} ` : " " : "";
|
|
13672
|
-
let m = "";
|
|
13673
|
-
if (s > 0 && !l) {
|
|
13674
|
-
const S = `
|
|
13675
|
-
${e("cyan", $2)}`;
|
|
13676
|
-
m = `${S.repeat(s - 1)}${S} `;
|
|
13677
|
-
}
|
|
13678
|
-
if (o === "active")
|
|
13679
|
-
return `${m}${e("dim", p)}${e("cyan", et2)} ${a}${n.hint ? ` ${e("dim", `(${n.hint})`)}` : ""}`;
|
|
13680
|
-
if (o === "group-active")
|
|
13681
|
-
return `${m}${p}${e("cyan", et2)} ${e("dim", a)}`;
|
|
13682
|
-
if (o === "group-active-selected")
|
|
13683
|
-
return `${m}${p}${e("green", U2)} ${e("dim", a)}`;
|
|
13684
|
-
if (o === "selected") {
|
|
13685
|
-
const S = l || r ? e("green", U2) : "";
|
|
13686
|
-
return `${m}${e("dim", p)}${S} ${e("dim", a)}${n.hint ? ` ${e("dim", `(${n.hint})`)}` : ""}`;
|
|
13687
|
-
}
|
|
13688
|
-
if (o === "cancelled")
|
|
13689
|
-
return `${e(["strikethrough", "dim"], a)}`;
|
|
13690
|
-
if (o === "active-selected")
|
|
13691
|
-
return `${m}${e("dim", p)}${e("green", U2)} ${a}${n.hint ? ` ${e("dim", `(${n.hint})`)}` : ""}`;
|
|
13692
|
-
if (o === "submitted")
|
|
13693
|
-
return `${e("dim", a)}`;
|
|
13694
|
-
const g = l || r ? e("dim", J2) : "";
|
|
13695
|
-
return `${m}${e("dim", p)}${g} ${e("dim", a)}`;
|
|
13696
|
-
}, u = t.required ?? true;
|
|
13697
|
-
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) {
|
|
13698
|
-
if (u && (n === undefined || n.length === 0))
|
|
13699
|
-
return `Please select at least one option.
|
|
13700
|
-
${e("reset", e("dim", `Press ${e(["gray", "bgWhite", "inverse"], " space ")} to select, ${e("gray", e(["bgWhite", "inverse"], " enter "))} to submit`))}`;
|
|
13701
|
-
}, render() {
|
|
13702
|
-
const n = t.withGuide ?? h.withGuide, o = `${n ? `${e("gray", $2)}
|
|
13703
|
-
` : ""}${M(this.state)} ${t.message}
|
|
13704
|
-
`, c = this.value ?? [];
|
|
13705
|
-
switch (this.state) {
|
|
13706
|
-
case "submit": {
|
|
13707
|
-
const a = this.options.filter(({ value: d }) => c.includes(d)).map((d) => i(d, "submitted")), l = a.length === 0 ? "" : ` ${a.join(e("dim", ", "))}`;
|
|
13708
|
-
return `${o}${n ? e("gray", $2) : ""}${l}`;
|
|
13709
|
-
}
|
|
13710
|
-
case "cancel": {
|
|
13711
|
-
const a = this.options.filter(({ value: l }) => c.includes(l)).map((l) => i(l, "cancelled")).join(e("dim", ", "));
|
|
13712
|
-
return `${o}${n ? `${e("gray", $2)} ` : ""}${a.trim() ? `${a}${n ? `
|
|
13713
|
-
${e("gray", $2)}` : ""}` : ""}`;
|
|
13714
|
-
}
|
|
13715
|
-
case "error": {
|
|
13716
|
-
const a = this.error.split(`
|
|
13717
|
-
`).map((l, d) => d === 0 ? `${n ? `${e("yellow", E2)} ` : ""}${e("yellow", l)}` : ` ${l}`).join(`
|
|
13718
|
-
`);
|
|
13719
|
-
return `${o}${n ? `${e("yellow", $2)} ` : ""}${this.options.map((l, d, y) => {
|
|
13720
|
-
const p = c.includes(l.value) || l.group === true && this.isGroupSelected(`${l.value}`), m = d === this.cursor;
|
|
13721
|
-
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);
|
|
13722
|
-
}).join(`
|
|
13723
|
-
${n ? `${e("yellow", $2)} ` : ""}`)}
|
|
13724
|
-
${a}
|
|
13725
|
-
`;
|
|
13726
|
-
}
|
|
13727
|
-
default: {
|
|
13728
|
-
const a = this.options.map((d, y, p) => {
|
|
13729
|
-
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;
|
|
13730
|
-
let h2 = "";
|
|
13731
|
-
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(`
|
|
13732
|
-
`) ? " " : ""}${h2}`;
|
|
13733
|
-
}).join(`
|
|
13734
|
-
${n ? e("cyan", $2) : ""}`), l = a.startsWith(`
|
|
13735
|
-
`) ? "" : " ";
|
|
13736
|
-
return `${o}${n ? e("cyan", $2) : ""}${l}${a}
|
|
13737
|
-
${n ? e("cyan", E2) : ""}
|
|
13738
|
-
`;
|
|
13739
|
-
}
|
|
13740
|
-
}
|
|
13741
|
-
} }).prompt();
|
|
13742
12909
|
}, R2, me = (t = "", r) => {
|
|
13743
12910
|
const s = r?.output ?? process.stdout, i = r?.withGuide ?? h.withGuide ? `${e("gray", E2)} ` : "";
|
|
13744
12911
|
s.write(`${i}${e("red", t)}
|
|
@@ -13749,92 +12916,11 @@ ${n ? e("cyan", E2) : ""}
|
|
|
13749
12916
|
s.write(`${i}${t}
|
|
13750
12917
|
`);
|
|
13751
12918
|
}, ye = (t = "", r) => {
|
|
13752
|
-
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", $)}
|
|
13753
12920
|
${e("gray", E2)} ` : "";
|
|
13754
12921
|
s.write(`${i}${t}
|
|
13755
12922
|
|
|
13756
12923
|
`);
|
|
13757
|
-
}, 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() {
|
|
13758
|
-
const r = t?.withGuide ?? h.withGuide, s = `${`${r ? `${e("gray", $2)}
|
|
13759
|
-
` : ""}${M(this.state)} `}${t.message}
|
|
13760
|
-
`, 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 ? `
|
|
13761
|
-
${e(this.focused === "submit" ? "cyan" : "dim", "[ submit ]")}` : "";
|
|
13762
|
-
switch (this.state) {
|
|
13763
|
-
case "error": {
|
|
13764
|
-
const c = `${e("yellow", $2)} `, a = r ? W(t.output, u, c, undefined) : u, l = e("yellow", E2);
|
|
13765
|
-
return `${s}${a}
|
|
13766
|
-
${l} ${e("yellow", this.error)}${o}
|
|
13767
|
-
`;
|
|
13768
|
-
}
|
|
13769
|
-
case "submit": {
|
|
13770
|
-
const c = `${e("gray", $2)} `, a = r ? W(t.output, n, c, undefined, (l) => e("dim", l)) : n ? e("dim", n) : "";
|
|
13771
|
-
return `${s}${a}`;
|
|
13772
|
-
}
|
|
13773
|
-
case "cancel": {
|
|
13774
|
-
const c = `${e("gray", $2)} `, a = r ? W(t.output, n, c, undefined, (l) => e(["strikethrough", "dim"], l)) : n ? e(["strikethrough", "dim"], n) : "";
|
|
13775
|
-
return `${s}${a}`;
|
|
13776
|
-
}
|
|
13777
|
-
default: {
|
|
13778
|
-
const c = r ? `${e("cyan", $2)} ` : "", a = r ? e("cyan", E2) : "", l = r ? W(t.output, u, c) : u;
|
|
13779
|
-
return `${s}${l}
|
|
13780
|
-
${a}${o}
|
|
13781
|
-
`;
|
|
13782
|
-
}
|
|
13783
|
-
}
|
|
13784
|
-
} }).prompt(), Q2 = (t, r) => t.split(`
|
|
13785
|
-
`).map((s) => r(s)).join(`
|
|
13786
|
-
`), ve = (t) => {
|
|
13787
|
-
const r = (i, u) => {
|
|
13788
|
-
const n = i.label ?? String(i.value);
|
|
13789
|
-
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))}`;
|
|
13790
|
-
}, s = t.required ?? true;
|
|
13791
|
-
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) {
|
|
13792
|
-
if (s && (i === undefined || i.length === 0))
|
|
13793
|
-
return `Please select at least one option.
|
|
13794
|
-
${e("reset", e("dim", `Press ${e(["gray", "bgWhite", "inverse"], " space ")} to select, ${e("gray", e("bgWhite", e("inverse", " enter ")))} to submit`))}`;
|
|
13795
|
-
}, render() {
|
|
13796
|
-
const i = t.withGuide ?? h.withGuide, u = W(t.output, t.message, i ? `${yt(this.state)} ` : "", `${M(this.state)} `), n = `${i ? `${e("gray", $2)}
|
|
13797
|
-
` : ""}${u}
|
|
13798
|
-
`, o = this.value ?? [], c = (a, l) => {
|
|
13799
|
-
if (a.disabled)
|
|
13800
|
-
return r(a, "disabled");
|
|
13801
|
-
const d = o.includes(a.value);
|
|
13802
|
-
return l && d ? r(a, "active-selected") : d ? r(a, "selected") : r(a, l ? "active" : "inactive");
|
|
13803
|
-
};
|
|
13804
|
-
switch (this.state) {
|
|
13805
|
-
case "submit": {
|
|
13806
|
-
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)} ` : "");
|
|
13807
|
-
return `${n}${l}`;
|
|
13808
|
-
}
|
|
13809
|
-
case "cancel": {
|
|
13810
|
-
const a = this.options.filter(({ value: d }) => o.includes(d)).map((d) => r(d, "cancelled")).join(e("dim", ", "));
|
|
13811
|
-
if (a.trim() === "")
|
|
13812
|
-
return `${n}${e("gray", $2)}`;
|
|
13813
|
-
const l = W(t.output, a, i ? `${e("gray", $2)} ` : "");
|
|
13814
|
-
return `${n}${l}${i ? `
|
|
13815
|
-
${e("gray", $2)}` : ""}`;
|
|
13816
|
-
}
|
|
13817
|
-
case "error": {
|
|
13818
|
-
const a = i ? `${e("yellow", $2)} ` : "", l = this.error.split(`
|
|
13819
|
-
`).map((p, m) => m === 0 ? `${i ? `${e("yellow", E2)} ` : ""}${e("yellow", p)}` : ` ${p}`).join(`
|
|
13820
|
-
`), d = n.split(`
|
|
13821
|
-
`).length, y = l.split(`
|
|
13822
|
-
`).length + 1;
|
|
13823
|
-
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(`
|
|
13824
|
-
${a}`)}
|
|
13825
|
-
${l}
|
|
13826
|
-
`;
|
|
13827
|
-
}
|
|
13828
|
-
default: {
|
|
13829
|
-
const a = i ? `${e("cyan", $2)} ` : "", l = n.split(`
|
|
13830
|
-
`).length, d = i ? 2 : 1;
|
|
13831
|
-
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(`
|
|
13832
|
-
${a}`)}
|
|
13833
|
-
${i ? e("cyan", E2) : ""}
|
|
13834
|
-
`;
|
|
13835
|
-
}
|
|
13836
|
-
}
|
|
13837
|
-
} }).prompt();
|
|
13838
12924
|
}, we = (t) => e("dim", t), be = (t, r, s) => {
|
|
13839
12925
|
const i = { hard: true, trim: false }, u = wrapAnsi(t, r, i).split(`
|
|
13840
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);
|
|
@@ -13844,67 +12930,42 @@ ${i ? e("cyan", E2) : ""}
|
|
|
13844
12930
|
`).map(n), ""], c = dist_default2(r), a = Math.max(o.reduce((p, m) => {
|
|
13845
12931
|
const g = dist_default2(m);
|
|
13846
12932
|
return g > p ? g : p;
|
|
13847
|
-
}, 0), c) + 2, l = o.map((p) => `${e("gray", $
|
|
13848
|
-
`), 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", $)}
|
|
13849
12935
|
` : "", y = u ? xt : dt;
|
|
13850
|
-
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)}
|
|
13851
12937
|
${l}
|
|
13852
|
-
${e("gray", y +
|
|
12938
|
+
${e("gray", y + st.repeat(a + 2) + $t)}
|
|
13853
12939
|
`);
|
|
13854
12940
|
}, Ce = (t) => new ot({ validate: t.validate, mask: t.mask ?? Gt, signal: t.signal, input: t.input, output: t.output, render() {
|
|
13855
|
-
const r = t.withGuide ?? h.withGuide, s = `${r ? `${e("gray", $
|
|
12941
|
+
const r = t.withGuide ?? h.withGuide, s = `${r ? `${e("gray", $)}
|
|
13856
12942
|
` : ""}${M(this.state)} ${t.message}
|
|
13857
12943
|
`, i = this.userInputWithCursor, u = this.masked;
|
|
13858
12944
|
switch (this.state) {
|
|
13859
12945
|
case "error": {
|
|
13860
|
-
const n = r ? `${e("yellow", $
|
|
12946
|
+
const n = r ? `${e("yellow", $)} ` : "", o = r ? `${e("yellow", E2)} ` : "", c = u ?? "";
|
|
13861
12947
|
return t.clearOnError && this.clear(), `${s.trim()}
|
|
13862
12948
|
${n}${c}
|
|
13863
12949
|
${o}${e("yellow", this.error)}
|
|
13864
12950
|
`;
|
|
13865
12951
|
}
|
|
13866
12952
|
case "submit": {
|
|
13867
|
-
const n = r ? `${e("gray", $
|
|
12953
|
+
const n = r ? `${e("gray", $)} ` : "", o = u ? e("dim", u) : "";
|
|
13868
12954
|
return `${s}${n}${o}`;
|
|
13869
12955
|
}
|
|
13870
12956
|
case "cancel": {
|
|
13871
|
-
const n = r ? `${e("gray", $
|
|
12957
|
+
const n = r ? `${e("gray", $)} ` : "", o = u ? e(["strikethrough", "dim"], u) : "";
|
|
13872
12958
|
return `${s}${n}${o}${u && r ? `
|
|
13873
|
-
${e("gray", $
|
|
12959
|
+
${e("gray", $)}` : ""}`;
|
|
13874
12960
|
}
|
|
13875
12961
|
default: {
|
|
13876
|
-
const n = r ? `${e("cyan", $
|
|
12962
|
+
const n = r ? `${e("cyan", $)} ` : "", o = r ? e("cyan", E2) : "";
|
|
13877
12963
|
return `${s}${n}${i}
|
|
13878
12964
|
${o}
|
|
13879
12965
|
`;
|
|
13880
12966
|
}
|
|
13881
12967
|
}
|
|
13882
|
-
} }).prompt(),
|
|
13883
|
-
const r = t.validate;
|
|
13884
|
-
return At({ ...t, initialUserInput: t.initialValue ?? t.root ?? process.cwd(), maxItems: 5, validate(s) {
|
|
13885
|
-
if (!Array.isArray(s)) {
|
|
13886
|
-
if (!s)
|
|
13887
|
-
return "Please select a path";
|
|
13888
|
-
if (r)
|
|
13889
|
-
return r(s);
|
|
13890
|
-
}
|
|
13891
|
-
}, options() {
|
|
13892
|
-
const s = this.userInput;
|
|
13893
|
-
if (s === "")
|
|
13894
|
-
return [];
|
|
13895
|
-
try {
|
|
13896
|
-
let i;
|
|
13897
|
-
zt(s) ? wt(s).isDirectory() && (!t.directory || s.endsWith("/")) ? i = s : i = bt(s) : i = bt(s);
|
|
13898
|
-
const u = s.length > 1 && s.endsWith("/") ? s.slice(0, -1) : s;
|
|
13899
|
-
return Qt(i).map((n) => {
|
|
13900
|
-
const o = Zt(i, n), c = wt(o);
|
|
13901
|
-
return { name: n, path: o, isDirectory: c.isDirectory() };
|
|
13902
|
-
}).filter(({ path: n, isDirectory: o }) => n.startsWith(u) && (o || !t.directory)).map((n) => ({ value: n.path }));
|
|
13903
|
-
} catch {
|
|
13904
|
-
return [];
|
|
13905
|
-
}
|
|
13906
|
-
} });
|
|
13907
|
-
}, _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 } = {}) => {
|
|
13908
12969
|
const l = at2();
|
|
13909
12970
|
let d, y, p = false, m = false, g = "", S, h2 = performance.now();
|
|
13910
12971
|
const f = A(s), v = a?.styleFrame ?? _e, T = (I) => {
|
|
@@ -13926,7 +12987,7 @@ ${o}
|
|
|
13926
12987
|
const V = (performance.now() - I) / 1000, B = Math.floor(V / 60), L = Math.floor(V % 60);
|
|
13927
12988
|
return B > 0 ? `[${B}m ${L}s]` : `[${L}s]`;
|
|
13928
12989
|
}, D = a.withGuide ?? h.withGuide, rt = (I = "") => {
|
|
13929
|
-
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", $)}
|
|
13930
12991
|
`);
|
|
13931
12992
|
let V = 0, B = 0;
|
|
13932
12993
|
G(), y = setInterval(() => {
|
|
@@ -13950,7 +13011,7 @@ ${o}
|
|
|
13950
13011
|
if (!p)
|
|
13951
13012
|
return;
|
|
13952
13013
|
p = false, clearInterval(y), A2();
|
|
13953
|
-
const L = V === 0 ? e("green",
|
|
13014
|
+
const L = V === 0 ? e("green", F) : V === 1 ? e("red", ot2) : e("red", ut2);
|
|
13954
13015
|
g = I ?? g, B || (t === "timer" ? s.write(`${L} ${g} ${N(h2)}
|
|
13955
13016
|
`) : s.write(`${L} ${g}
|
|
13956
13017
|
`)), x(), d();
|
|
@@ -13968,7 +13029,7 @@ ${o}
|
|
|
13968
13029
|
const u = s.label ?? String(s.value);
|
|
13969
13030
|
switch (i) {
|
|
13970
13031
|
case "disabled":
|
|
13971
|
-
return `${e("gray",
|
|
13032
|
+
return `${e("gray", H)} ${it2(u, (n) => e("gray", n))}${s.hint ? ` ${e("dim", `(${s.hint ?? "disabled"})`)}` : ""}`;
|
|
13972
13033
|
case "selected":
|
|
13973
13034
|
return `${it2(u, (n) => e("dim", n))}`;
|
|
13974
13035
|
case "active":
|
|
@@ -13976,25 +13037,25 @@ ${o}
|
|
|
13976
13037
|
case "cancelled":
|
|
13977
13038
|
return `${it2(u, (n) => e(["strikethrough", "dim"], n))}`;
|
|
13978
13039
|
default:
|
|
13979
|
-
return `${e("dim",
|
|
13040
|
+
return `${e("dim", H)} ${it2(u, (n) => e("dim", n))}`;
|
|
13980
13041
|
}
|
|
13981
13042
|
};
|
|
13982
13043
|
return new ut({ options: t.options, signal: t.signal, input: t.input, output: t.output, initialValue: t.initialValue, render() {
|
|
13983
|
-
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", $)}
|
|
13984
13045
|
` : ""}${n}
|
|
13985
13046
|
`;
|
|
13986
13047
|
switch (this.state) {
|
|
13987
13048
|
case "submit": {
|
|
13988
|
-
const c = s ? `${e("gray", $
|
|
13049
|
+
const c = s ? `${e("gray", $)} ` : "", a = W(t.output, r(this.options[this.cursor], "selected"), c);
|
|
13989
13050
|
return `${o}${a}`;
|
|
13990
13051
|
}
|
|
13991
13052
|
case "cancel": {
|
|
13992
|
-
const c = s ? `${e("gray", $
|
|
13053
|
+
const c = s ? `${e("gray", $)} ` : "", a = W(t.output, r(this.options[this.cursor], "cancelled"), c);
|
|
13993
13054
|
return `${o}${a}${s ? `
|
|
13994
|
-
${e("gray", $
|
|
13055
|
+
${e("gray", $)}` : ""}`;
|
|
13995
13056
|
}
|
|
13996
13057
|
default: {
|
|
13997
|
-
const c = s ? `${e("cyan", $
|
|
13058
|
+
const c = s ? `${e("cyan", $)} ` : "", a = s ? e("cyan", E2) : "", l = o.split(`
|
|
13998
13059
|
`).length, d = s ? 2 : 1;
|
|
13999
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(`
|
|
14000
13061
|
${c}`)}
|
|
@@ -14003,35 +13064,7 @@ ${a}
|
|
|
14003
13064
|
}
|
|
14004
13065
|
}
|
|
14005
13066
|
} }).prompt();
|
|
14006
|
-
},
|
|
14007
|
-
const r = (s, i = "inactive") => {
|
|
14008
|
-
const u = s.label ?? String(s.value);
|
|
14009
|
-
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})`)}` : ""}`;
|
|
14010
|
-
};
|
|
14011
|
-
return new at({ options: t.options, signal: t.signal, input: t.input, output: t.output, initialValue: t.initialValue, caseSensitive: t.caseSensitive, render() {
|
|
14012
|
-
const s = t.withGuide ?? h.withGuide, i = `${s ? `${e("gray", $2)}
|
|
14013
|
-
` : ""}${M(this.state)} ${t.message}
|
|
14014
|
-
`;
|
|
14015
|
-
switch (this.state) {
|
|
14016
|
-
case "submit": {
|
|
14017
|
-
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);
|
|
14018
|
-
return `${i}${o}`;
|
|
14019
|
-
}
|
|
14020
|
-
case "cancel": {
|
|
14021
|
-
const u = s ? `${e("gray", $2)} ` : "", n = W(t.output, r(this.options[0], "cancelled"), u);
|
|
14022
|
-
return `${i}${n}${s ? `
|
|
14023
|
-
${e("gray", $2)}` : ""}`;
|
|
14024
|
-
}
|
|
14025
|
-
default: {
|
|
14026
|
-
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(`
|
|
14027
|
-
`);
|
|
14028
|
-
return `${i}${o}
|
|
14029
|
-
${n}
|
|
14030
|
-
`;
|
|
14031
|
-
}
|
|
14032
|
-
}
|
|
14033
|
-
} }).prompt();
|
|
14034
|
-
}, jt, K2, xe = async (t, r) => {
|
|
13067
|
+
}, jt, xe = async (t, r) => {
|
|
14035
13068
|
for (const s of t) {
|
|
14036
13069
|
if (s.enabled === false)
|
|
14037
13070
|
continue;
|
|
@@ -14040,104 +13073,29 @@ ${n}
|
|
|
14040
13073
|
const u = await s.task(i.message);
|
|
14041
13074
|
i.stop(u || s.title);
|
|
14042
13075
|
}
|
|
14043
|
-
}, Oe = (t) => t.replace(/\x1b\[(?:\d+;)*\d*[ABCDEFGHfJKSTsu]|\x1b\[(s|u)/g, ""), Me = (t) => {
|
|
14044
|
-
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);
|
|
14045
|
-
r.write(`${i}
|
|
14046
|
-
`), r.write(`${e("green", F2)} ${t.title}
|
|
14047
|
-
`);
|
|
14048
|
-
for (let h2 = 0;h2 < u; h2++)
|
|
14049
|
-
r.write(`${i}
|
|
14050
|
-
`);
|
|
14051
|
-
const a = [{ value: "", full: "" }];
|
|
14052
|
-
let l = false;
|
|
14053
|
-
const d = (h2) => {
|
|
14054
|
-
if (a.length === 0)
|
|
14055
|
-
return;
|
|
14056
|
-
let f = 0;
|
|
14057
|
-
h2 && (f += u + 2);
|
|
14058
|
-
for (const v of a) {
|
|
14059
|
-
const { value: T, result: C } = v;
|
|
14060
|
-
let b = C?.message ?? T;
|
|
14061
|
-
if (b.length === 0)
|
|
14062
|
-
continue;
|
|
14063
|
-
C === undefined && v.header !== undefined && v.header !== "" && (b += `
|
|
14064
|
-
${v.header}`);
|
|
14065
|
-
const G = b.split(`
|
|
14066
|
-
`).reduce((x, A) => A === "" ? x + 1 : x + Math.ceil((A.length + n) / s), 0);
|
|
14067
|
-
f += G;
|
|
14068
|
-
}
|
|
14069
|
-
f > 0 && (f += 1, r.write(import_sisteransi2.erase.lines(f)));
|
|
14070
|
-
}, y = (h2, f, v) => {
|
|
14071
|
-
const T = v ? `${h2.full}
|
|
14072
|
-
${h2.value}` : h2.value;
|
|
14073
|
-
h2.header !== undefined && h2.header !== "" && R2.message(h2.header.split(`
|
|
14074
|
-
`).map((C) => e("bold", C)), { output: r, secondarySymbol: i, symbol: i, spacing: 0 }), R2.message(T.split(`
|
|
14075
|
-
`).map((C) => e("dim", C)), { output: r, secondarySymbol: i, symbol: i, spacing: f ?? u });
|
|
14076
|
-
}, p = () => {
|
|
14077
|
-
for (const h2 of a) {
|
|
14078
|
-
const { header: f, value: v, full: T } = h2;
|
|
14079
|
-
(f === undefined || f.length === 0) && v.length === 0 || y(h2, undefined, o === true && T.length > 0);
|
|
14080
|
-
}
|
|
14081
|
-
}, m = (h2, f, v) => {
|
|
14082
|
-
if (d(false), (v?.raw !== true || !l) && h2.value !== "" && (h2.value += `
|
|
14083
|
-
`), h2.value += Oe(f), l = v?.raw === true, t.limit !== undefined) {
|
|
14084
|
-
const T = h2.value.split(`
|
|
14085
|
-
`), C = T.length - t.limit;
|
|
14086
|
-
if (C > 0) {
|
|
14087
|
-
const b = T.splice(0, C);
|
|
14088
|
-
o && (h2.full += (h2.full === "" ? "" : `
|
|
14089
|
-
`) + b.join(`
|
|
14090
|
-
`));
|
|
14091
|
-
}
|
|
14092
|
-
h2.value = T.join(`
|
|
14093
|
-
`);
|
|
14094
|
-
}
|
|
14095
|
-
c && g();
|
|
14096
|
-
}, g = () => {
|
|
14097
|
-
for (const h2 of a)
|
|
14098
|
-
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);
|
|
14099
|
-
}, S = (h2, f) => {
|
|
14100
|
-
d(false), h2.result = f, c && g();
|
|
14101
|
-
};
|
|
14102
|
-
return { message(h2, f) {
|
|
14103
|
-
m(a[0], h2, f);
|
|
14104
|
-
}, group(h2) {
|
|
14105
|
-
const f = { header: h2, value: "", full: "" };
|
|
14106
|
-
return a.push(f), { message(v, T) {
|
|
14107
|
-
m(f, v, T);
|
|
14108
|
-
}, error(v) {
|
|
14109
|
-
S(f, { status: "error", message: v });
|
|
14110
|
-
}, success(v) {
|
|
14111
|
-
S(f, { status: "success", message: v });
|
|
14112
|
-
} };
|
|
14113
|
-
}, error(h2, f) {
|
|
14114
|
-
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 = "";
|
|
14115
|
-
}, success(h2, f) {
|
|
14116
|
-
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 = "";
|
|
14117
|
-
} };
|
|
14118
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() {
|
|
14119
|
-
const r = t?.withGuide ?? h.withGuide, s = `${`${r ? `${e("gray", $
|
|
13077
|
+
const r = t?.withGuide ?? h.withGuide, s = `${`${r ? `${e("gray", $)}
|
|
14120
13078
|
` : ""}${M(this.state)} `}${t.message}
|
|
14121
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 ?? "";
|
|
14122
13080
|
switch (this.state) {
|
|
14123
13081
|
case "error": {
|
|
14124
|
-
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) : "";
|
|
14125
13083
|
return `${s.trim()}
|
|
14126
13084
|
${c}${u}
|
|
14127
13085
|
${a}${o}
|
|
14128
13086
|
`;
|
|
14129
13087
|
}
|
|
14130
13088
|
case "submit": {
|
|
14131
|
-
const o = n ? ` ${e("dim", n)}` : "", c = r ? e("gray", $
|
|
13089
|
+
const o = n ? ` ${e("dim", n)}` : "", c = r ? e("gray", $) : "";
|
|
14132
13090
|
return `${s}${c}${o}`;
|
|
14133
13091
|
}
|
|
14134
13092
|
case "cancel": {
|
|
14135
|
-
const o = n ? ` ${e(["strikethrough", "dim"], n)}` : "", c = r ? e("gray", $
|
|
13093
|
+
const o = n ? ` ${e(["strikethrough", "dim"], n)}` : "", c = r ? e("gray", $) : "";
|
|
14136
13094
|
return `${s}${c}${o}${n.trim() ? `
|
|
14137
13095
|
${c}` : ""}`;
|
|
14138
13096
|
}
|
|
14139
13097
|
default: {
|
|
14140
|
-
const o = r ? `${e("cyan", $
|
|
13098
|
+
const o = r ? `${e("cyan", $)} ` : "", c = r ? e("cyan", E2) : "";
|
|
14141
13099
|
return `${s}${o}${u}
|
|
14142
13100
|
${c}
|
|
14143
13101
|
`;
|
|
@@ -14150,23 +13108,23 @@ var init_dist4 = __esm(() => {
|
|
|
14150
13108
|
init_main2();
|
|
14151
13109
|
init_dist2();
|
|
14152
13110
|
import_sisteransi2 = __toESM(require_src(), 1);
|
|
14153
|
-
|
|
13111
|
+
tt = te();
|
|
14154
13112
|
_t = w2("\u25C6", "*");
|
|
14155
13113
|
ot2 = w2("\u25A0", "x");
|
|
14156
13114
|
ut2 = w2("\u25B2", "x");
|
|
14157
|
-
|
|
13115
|
+
F = w2("\u25C7", "o");
|
|
14158
13116
|
lt = w2("\u250C", "T");
|
|
14159
|
-
$
|
|
13117
|
+
$ = w2("\u2502", "|");
|
|
14160
13118
|
E2 = w2("\u2514", "\u2014");
|
|
14161
13119
|
It = w2("\u2510", "T");
|
|
14162
13120
|
Et = w2("\u2518", "\u2014");
|
|
14163
13121
|
z2 = w2("\u25CF", ">");
|
|
14164
|
-
|
|
13122
|
+
H = w2("\u25CB", " ");
|
|
14165
13123
|
et2 = w2("\u25FB", "[\u2022]");
|
|
14166
|
-
|
|
14167
|
-
|
|
13124
|
+
U = w2("\u25FC", "[+]");
|
|
13125
|
+
J = w2("\u25FB", "[ ]");
|
|
14168
13126
|
Gt = w2("\u25AA", "\u2022");
|
|
14169
|
-
|
|
13127
|
+
st = w2("\u2500", "-");
|
|
14170
13128
|
ct = w2("\u256E", "+");
|
|
14171
13129
|
xt = w2("\u251C", "+");
|
|
14172
13130
|
$t = w2("\u256F", "+");
|
|
@@ -14176,10 +13134,7 @@ var init_dist4 = __esm(() => {
|
|
|
14176
13134
|
pt = w2("\u25C6", "*");
|
|
14177
13135
|
mt = w2("\u25B2", "!");
|
|
14178
13136
|
gt = w2("\u25A0", "x");
|
|
14179
|
-
|
|
14180
|
-
ne = [lt, It, E2, Et];
|
|
14181
|
-
de = { year: "yyyy", month: "mm", day: "dd" };
|
|
14182
|
-
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 } = {}) => {
|
|
14183
13138
|
const o = [], c = n ?? h.withGuide, a = c ? s : "", l = c ? `${r} ` : "", d = c ? `${s} ` : "";
|
|
14184
13139
|
for (let p = 0;p < u; p++)
|
|
14185
13140
|
o.push(a);
|
|
@@ -14199,7 +13154,7 @@ var init_dist4 = __esm(() => {
|
|
|
14199
13154
|
}, success: (t, r) => {
|
|
14200
13155
|
R2.message(t, { ...r, symbol: e("green", pt) });
|
|
14201
13156
|
}, step: (t, r) => {
|
|
14202
|
-
R2.message(t, { ...r, symbol: e("green",
|
|
13157
|
+
R2.message(t, { ...r, symbol: e("green", F) });
|
|
14203
13158
|
}, warn: (t, r) => {
|
|
14204
13159
|
R2.message(t, { ...r, symbol: e("yellow", mt) });
|
|
14205
13160
|
}, warning: (t, r) => {
|
|
@@ -14208,23 +13163,62 @@ var init_dist4 = __esm(() => {
|
|
|
14208
13163
|
R2.message(t, { ...r, symbol: e("red", gt) });
|
|
14209
13164
|
} };
|
|
14210
13165
|
Vt = { light: w2("\u2500", "-"), heavy: w2("\u2501", "="), block: w2("\u2588", "#") };
|
|
14211
|
-
jt = `${e("gray", $
|
|
14212
|
-
|
|
14213
|
-
|
|
14214
|
-
|
|
14215
|
-
|
|
14216
|
-
|
|
14217
|
-
|
|
14218
|
-
|
|
14219
|
-
|
|
14220
|
-
|
|
14221
|
-
|
|
14222
|
-
|
|
14223
|
-
|
|
14224
|
-
|
|
14225
|
-
|
|
14226
|
-
`
|
|
14227
|
-
|
|
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_@%+=:,./-]+$/;
|
|
14228
13222
|
});
|
|
14229
13223
|
|
|
14230
13224
|
// src/services/config/config-service.ts
|
|
@@ -14461,13 +13455,11 @@ ${e.errors.map((m) => ` - ${m}`).join(`
|
|
|
14461
13455
|
if (errors.length > 0 || parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
14462
13456
|
throw new Error(`Invalid JSONC in ${filePath}`);
|
|
14463
13457
|
}
|
|
14464
|
-
const
|
|
14465
|
-
|
|
14466
|
-
|
|
14467
|
-
|
|
14468
|
-
|
|
14469
|
-
await Bun.write(filePath, JSON.stringify(config, null, 2) + `
|
|
14470
|
-
`);
|
|
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);
|
|
14471
13463
|
}
|
|
14472
13464
|
ensureLoaded() {
|
|
14473
13465
|
if (!this.config) {
|
|
@@ -14509,11 +13501,45 @@ function sanitizeWranglerOutput(raw, maxLines = 4) {
|
|
|
14509
13501
|
}
|
|
14510
13502
|
return text || "wrangler failed (unrecognized output)";
|
|
14511
13503
|
}
|
|
13504
|
+
function formatSecretFailureDetails(failed) {
|
|
13505
|
+
if (failed.length === 0)
|
|
13506
|
+
return "";
|
|
13507
|
+
return failed.map((f) => `${f.name}: ${f.reason}`).join(`
|
|
13508
|
+
`);
|
|
13509
|
+
}
|
|
14512
13510
|
var NOISE_LINE;
|
|
14513
13511
|
var init_wrangler_output = __esm(() => {
|
|
14514
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;
|
|
14515
13513
|
});
|
|
14516
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
|
+
|
|
14517
13543
|
// src/utils/fs-secure.ts
|
|
14518
13544
|
import { chmodSync as chmodSync4, mkdirSync as mkdirSync4 } from "fs";
|
|
14519
13545
|
function secureChmod(path, mode) {
|
|
@@ -14744,23 +13770,7 @@ class SecretsService {
|
|
|
14744
13770
|
return { ok: true, value: result };
|
|
14745
13771
|
}
|
|
14746
13772
|
parseDotEnv(content) {
|
|
14747
|
-
|
|
14748
|
-
for (const line of content.split(`
|
|
14749
|
-
`)) {
|
|
14750
|
-
const trimmed = line.trim();
|
|
14751
|
-
if (trimmed === "" || trimmed.startsWith("#"))
|
|
14752
|
-
continue;
|
|
14753
|
-
const eqIdx = trimmed.indexOf("=");
|
|
14754
|
-
if (eqIdx < 1)
|
|
14755
|
-
continue;
|
|
14756
|
-
const key = trimmed.substring(0, eqIdx).trim();
|
|
14757
|
-
let value = trimmed.substring(eqIdx + 1).trim();
|
|
14758
|
-
if (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'")) {
|
|
14759
|
-
value = value.slice(1, -1);
|
|
14760
|
-
}
|
|
14761
|
-
map.set(key, value);
|
|
14762
|
-
}
|
|
14763
|
-
return map;
|
|
13773
|
+
return parseEnvFile(content);
|
|
14764
13774
|
}
|
|
14765
13775
|
async handleAlreadyInUse(workerPath, name, value, logicalWorkerName) {
|
|
14766
13776
|
try {
|
|
@@ -14799,8 +13809,7 @@ class SecretsService {
|
|
|
14799
13809
|
}
|
|
14800
13810
|
}
|
|
14801
13811
|
isPlaceholder(value) {
|
|
14802
|
-
|
|
14803
|
-
return v === "" || v.startsWith("placeholder_") || v.startsWith("your_") || v.startsWith("generate_") || v.startsWith("<") || v.includes("generate-with");
|
|
13812
|
+
return isPlaceholderValue(value);
|
|
14804
13813
|
}
|
|
14805
13814
|
async execWranglerSecretPut(workerPath, name, value, logicalWorkerName) {
|
|
14806
13815
|
const { configPath, deployName } = await resolveWorkerWranglerConfig(workerPath);
|
|
@@ -14830,6 +13839,7 @@ var SYSTEM_SECRET_NAMES, SYSTEM_SECRET_SET, WORKER_SYSTEM_SECRETS;
|
|
|
14830
13839
|
var init_secrets_service = __esm(() => {
|
|
14831
13840
|
init_main();
|
|
14832
13841
|
init_wrangler_output();
|
|
13842
|
+
init_env_file();
|
|
14833
13843
|
SYSTEM_SECRET_NAMES = [
|
|
14834
13844
|
"INTERNAL_KEY_BINDING",
|
|
14835
13845
|
"AGENT_INTERNAL_KEY",
|
|
@@ -15000,12 +14010,11 @@ class CloudflareService {
|
|
|
15000
14010
|
}
|
|
15001
14011
|
async versionsRollback(workerName, versionId) {
|
|
15002
14012
|
return this.runWrangler([
|
|
15003
|
-
"versions",
|
|
15004
14013
|
"rollback",
|
|
14014
|
+
versionId,
|
|
15005
14015
|
"--name",
|
|
15006
14016
|
workerName,
|
|
15007
|
-
"--
|
|
15008
|
-
versionId
|
|
14017
|
+
"--yes"
|
|
15009
14018
|
]);
|
|
15010
14019
|
}
|
|
15011
14020
|
async dev(workerPath, port) {
|
|
@@ -15193,13 +14202,22 @@ class CloudflareService {
|
|
|
15193
14202
|
}
|
|
15194
14203
|
}
|
|
15195
14204
|
async secretDelete(workerName, secretName) {
|
|
15196
|
-
|
|
15197
|
-
|
|
15198
|
-
|
|
15199
|
-
|
|
15200
|
-
|
|
15201
|
-
|
|
15202
|
-
|
|
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
|
+
}
|
|
15203
14221
|
}
|
|
15204
14222
|
async zonesList() {
|
|
15205
14223
|
const token = process.env.CLOUDFLARE_API_TOKEN;
|
|
@@ -15337,8 +14355,7 @@ class PrerequisitesService {
|
|
|
15337
14355
|
});
|
|
15338
14356
|
const stdout = await new Response(proc.stdout).text();
|
|
15339
14357
|
const version = stdout.trim();
|
|
15340
|
-
const
|
|
15341
|
-
const passed = (major ?? 0) >= 1 && (minor ?? 0) >= 2;
|
|
14358
|
+
const passed = meetsMinVersion(version, 1, 2);
|
|
15342
14359
|
return {
|
|
15343
14360
|
...base,
|
|
15344
14361
|
passed,
|
|
@@ -15364,8 +14381,7 @@ class PrerequisitesService {
|
|
|
15364
14381
|
const stdout = await new Response(proc.stdout).text();
|
|
15365
14382
|
const match = stdout.match(/(\d+\.\d+)/);
|
|
15366
14383
|
const version = match?.[1] ?? "unknown";
|
|
15367
|
-
const
|
|
15368
|
-
const passed = (major ?? 0) >= 2 && (minor ?? 0) >= 40;
|
|
14384
|
+
const passed = meetsMinVersion(version, 2, 40);
|
|
15369
14385
|
return {
|
|
15370
14386
|
...base,
|
|
15371
14387
|
passed,
|
|
@@ -15470,6 +14486,7 @@ class PrerequisitesService {
|
|
|
15470
14486
|
required: "D1/KV/R2/Queues: Edit"
|
|
15471
14487
|
};
|
|
15472
14488
|
const token = process.env.CLOUDFLARE_API_TOKEN;
|
|
14489
|
+
const accountId = process.env.CLOUDFLARE_ACCOUNT_ID;
|
|
15473
14490
|
if (!token) {
|
|
15474
14491
|
return {
|
|
15475
14492
|
...base,
|
|
@@ -15478,8 +14495,16 @@ class PrerequisitesService {
|
|
|
15478
14495
|
hint: "If deploys fail with 403, set CLOUDFLARE_API_TOKEN with D1/KV/R2/Queues:Edit"
|
|
15479
14496
|
};
|
|
15480
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
|
+
}
|
|
15481
14506
|
try {
|
|
15482
|
-
const response = await fetch(
|
|
14507
|
+
const response = await fetch(`https://api.cloudflare.com/client/v4/accounts/${accountId}/d1/database`, {
|
|
15483
14508
|
headers: {
|
|
15484
14509
|
Authorization: `Bearer ${token}`,
|
|
15485
14510
|
"Content-Type": "application/json"
|
|
@@ -15490,7 +14515,7 @@ class PrerequisitesService {
|
|
|
15490
14515
|
return {
|
|
15491
14516
|
...base,
|
|
15492
14517
|
passed: true,
|
|
15493
|
-
version: "token
|
|
14518
|
+
version: "token can list D1"
|
|
15494
14519
|
};
|
|
15495
14520
|
}
|
|
15496
14521
|
const errMsg = json.errors?.[0]?.message ?? `HTTP ${response.status}`;
|
|
@@ -15605,9 +14630,12 @@ class PrerequisitesService {
|
|
|
15605
14630
|
};
|
|
15606
14631
|
}
|
|
15607
14632
|
}
|
|
14633
|
+
var init_prerequisites_service = () => {};
|
|
15608
14634
|
|
|
15609
14635
|
// src/services/prerequisites/index.ts
|
|
15610
|
-
var init_prerequisites = () => {
|
|
14636
|
+
var init_prerequisites = __esm(() => {
|
|
14637
|
+
init_prerequisites_service();
|
|
14638
|
+
});
|
|
15611
14639
|
|
|
15612
14640
|
// src/services/update/update-service.ts
|
|
15613
14641
|
import { readFileSync as readFileSync7 } from "fs";
|
|
@@ -18298,6 +17326,7 @@ function startTimer() {
|
|
|
18298
17326
|
}
|
|
18299
17327
|
|
|
18300
17328
|
// src/utils/format-mode.ts
|
|
17329
|
+
init_dist4();
|
|
18301
17330
|
function isRichMode(opts) {
|
|
18302
17331
|
if (opts?.json || opts?.quiet || opts?.noColor)
|
|
18303
17332
|
return false;
|
|
@@ -18307,6 +17336,32 @@ function isRichMode(opts) {
|
|
|
18307
17336
|
return false;
|
|
18308
17337
|
return Boolean(process.stdout.isTTY);
|
|
18309
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
|
+
}
|
|
18310
17365
|
|
|
18311
17366
|
// src/utils/formatters.ts
|
|
18312
17367
|
var formatDuration3 = formatDuration2;
|
|
@@ -18785,6 +17840,8 @@ function getCmdPath(cmd) {
|
|
|
18785
17840
|
// src/commands/init/init-command.ts
|
|
18786
17841
|
init_dist4();
|
|
18787
17842
|
init_src();
|
|
17843
|
+
init_wizard();
|
|
17844
|
+
init_env_file();
|
|
18788
17845
|
import * as fs2 from "fs";
|
|
18789
17846
|
|
|
18790
17847
|
// src/services/cloudflare/index.ts
|
|
@@ -18894,7 +17951,7 @@ import {
|
|
|
18894
17951
|
statSync as statSync2,
|
|
18895
17952
|
writeFileSync as writeFileSync4
|
|
18896
17953
|
} from "fs";
|
|
18897
|
-
import { homedir as
|
|
17954
|
+
import { homedir as homedir2 } from "os";
|
|
18898
17955
|
import { join as join7 } from "path";
|
|
18899
17956
|
|
|
18900
17957
|
// src/services/setup/dex-setup.ts
|
|
@@ -18940,7 +17997,7 @@ function generateSolanaSeedBase58() {
|
|
|
18940
17997
|
crypto.getRandomValues(seed);
|
|
18941
17998
|
return encodeBase58(seed);
|
|
18942
17999
|
}
|
|
18943
|
-
function
|
|
18000
|
+
function parseEnvFile2(text) {
|
|
18944
18001
|
const map = new Map;
|
|
18945
18002
|
for (const line of text.split(`
|
|
18946
18003
|
`)) {
|
|
@@ -18955,10 +18012,11 @@ function parseEnvFile(text) {
|
|
|
18955
18012
|
return map;
|
|
18956
18013
|
}
|
|
18957
18014
|
function ensureSolanaPrivateKey(devVarsPath) {
|
|
18958
|
-
const existing = existsSync5(devVarsPath) ?
|
|
18015
|
+
const existing = existsSync5(devVarsPath) ? parseEnvFile2(readFileSync5(devVarsPath, "utf-8")) : new Map;
|
|
18959
18016
|
const current = existing.get("SOLANA_PRIVATE_KEY")?.trim();
|
|
18960
|
-
if (current)
|
|
18017
|
+
if (current && !isPlaceholderValue(current)) {
|
|
18961
18018
|
return { generated: false, value: current };
|
|
18019
|
+
}
|
|
18962
18020
|
const value = generateSolanaSeedBase58();
|
|
18963
18021
|
const header = existsSync5(devVarsPath) ? readFileSync5(devVarsPath, "utf-8") : `# .dev.vars \u2014 local secrets
|
|
18964
18022
|
# Generated by \`hoox setup\`. NEVER commit.
|
|
@@ -18993,59 +18051,8 @@ function applyWalletRpcDefaults(wranglerPath) {
|
|
|
18993
18051
|
return patched;
|
|
18994
18052
|
}
|
|
18995
18053
|
|
|
18996
|
-
// src/utils/env-file.ts
|
|
18997
|
-
var BARE_VALUE_RE = /^[A-Za-z0-9_@%+=:,./-]+$/;
|
|
18998
|
-
function formatEnvValue(value) {
|
|
18999
|
-
if (value.length > 0 && BARE_VALUE_RE.test(value))
|
|
19000
|
-
return value;
|
|
19001
|
-
const escaped = value.replace(/\\/g, "\\\\").replace(/"/g, "\\\"").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/\t/g, "\\t");
|
|
19002
|
-
return `"${escaped}"`;
|
|
19003
|
-
}
|
|
19004
|
-
function serializeEnvLine(key, value) {
|
|
19005
|
-
return `${key}=${formatEnvValue(value)}`;
|
|
19006
|
-
}
|
|
19007
|
-
function parseEnvFile2(text) {
|
|
19008
|
-
const map = new Map;
|
|
19009
|
-
for (const line of text.split(`
|
|
19010
|
-
`)) {
|
|
19011
|
-
let trimmed = line.trim();
|
|
19012
|
-
if (!trimmed || trimmed.startsWith("#"))
|
|
19013
|
-
continue;
|
|
19014
|
-
if (trimmed.startsWith("export "))
|
|
19015
|
-
trimmed = trimmed.slice(7).trimStart();
|
|
19016
|
-
const eq = trimmed.indexOf("=");
|
|
19017
|
-
if (eq <= 0)
|
|
19018
|
-
continue;
|
|
19019
|
-
const key = trimmed.slice(0, eq).trim();
|
|
19020
|
-
if (!key || /\s/.test(key))
|
|
19021
|
-
continue;
|
|
19022
|
-
map.set(key, unquoteValue(trimmed.slice(eq + 1).trim()));
|
|
19023
|
-
}
|
|
19024
|
-
return map;
|
|
19025
|
-
}
|
|
19026
|
-
function unquoteValue(raw) {
|
|
19027
|
-
if (raw.length >= 2 && raw.startsWith('"') && raw.endsWith('"')) {
|
|
19028
|
-
return raw.slice(1, -1).replace(/\\(\\|"|n|r|t)/g, (_, c) => {
|
|
19029
|
-
switch (c) {
|
|
19030
|
-
case "n":
|
|
19031
|
-
return `
|
|
19032
|
-
`;
|
|
19033
|
-
case "r":
|
|
19034
|
-
return "\r";
|
|
19035
|
-
case "t":
|
|
19036
|
-
return "\t";
|
|
19037
|
-
default:
|
|
19038
|
-
return c;
|
|
19039
|
-
}
|
|
19040
|
-
});
|
|
19041
|
-
}
|
|
19042
|
-
if (raw.length >= 2 && raw.startsWith("'") && raw.endsWith("'")) {
|
|
19043
|
-
return raw.slice(1, -1);
|
|
19044
|
-
}
|
|
19045
|
-
return raw;
|
|
19046
|
-
}
|
|
19047
|
-
|
|
19048
18054
|
// src/services/setup/setup-service.ts
|
|
18055
|
+
init_env_file();
|
|
19049
18056
|
var ALL_WORKERS = [
|
|
19050
18057
|
"d1-worker",
|
|
19051
18058
|
"analytics-worker",
|
|
@@ -19124,7 +18131,7 @@ function loadExistingKeysFromDisk() {
|
|
|
19124
18131
|
} catch {
|
|
19125
18132
|
return null;
|
|
19126
18133
|
}
|
|
19127
|
-
const map =
|
|
18134
|
+
const map = parseEnvFile(text);
|
|
19128
18135
|
const required = [
|
|
19129
18136
|
"INTERNAL_KEY_BINDING",
|
|
19130
18137
|
"AGENT_INTERNAL_KEY",
|
|
@@ -19213,7 +18220,7 @@ class SetupService {
|
|
|
19213
18220
|
const path = `workers/${workerFsDir(worker)}/.dev.vars`;
|
|
19214
18221
|
const meshNames = secretNames;
|
|
19215
18222
|
const meshSet = new Set(meshNames);
|
|
19216
|
-
const existing = existsSync6(path) ?
|
|
18223
|
+
const existing = existsSync6(path) ? parseEnvFile(readFileSync6(path, "utf-8")) : new Map;
|
|
19217
18224
|
for (const secretName of meshNames) {
|
|
19218
18225
|
existing.set(secretName, keys[secretName]);
|
|
19219
18226
|
}
|
|
@@ -19271,13 +18278,14 @@ class SetupService {
|
|
|
19271
18278
|
const path = join7("workers", workerFsDir("web3-wallet-worker"), ".dev.vars");
|
|
19272
18279
|
if (!existsSync6(path))
|
|
19273
18280
|
return [];
|
|
19274
|
-
const map =
|
|
18281
|
+
const map = parseEnvFile(readFileSync6(path, "utf-8"));
|
|
19275
18282
|
const solanaKey = map.get("SOLANA_PRIVATE_KEY")?.trim();
|
|
19276
18283
|
const jupiterKey = map.get("JUPITER_API_KEY")?.trim();
|
|
19277
18284
|
const results = [];
|
|
19278
18285
|
const puts = [];
|
|
19279
|
-
if (solanaKey)
|
|
18286
|
+
if (solanaKey && !isPlaceholderValue(solanaKey)) {
|
|
19280
18287
|
puts.push(["SOLANA_PRIVATE_KEY", solanaKey]);
|
|
18288
|
+
}
|
|
19281
18289
|
if (jupiterKey)
|
|
19282
18290
|
puts.push(["JUPITER_API_KEY", jupiterKey]);
|
|
19283
18291
|
for (const [name, value] of puts) {
|
|
@@ -19572,7 +18580,7 @@ class SetupService {
|
|
|
19572
18580
|
}
|
|
19573
18581
|
const fallbacks = [
|
|
19574
18582
|
"/usr/local/bin/wrangler",
|
|
19575
|
-
join7(
|
|
18583
|
+
join7(homedir2(), ".bun", "bin", "wrangler")
|
|
19576
18584
|
];
|
|
19577
18585
|
for (const fb of fallbacks) {
|
|
19578
18586
|
try {
|
|
@@ -19873,33 +18881,50 @@ class SetupService {
|
|
|
19873
18881
|
message: `Checking D1 database "${dbName}"...`
|
|
19874
18882
|
});
|
|
19875
18883
|
const listResult = await this.cf.d1List();
|
|
19876
|
-
if (listResult.ok) {
|
|
19877
|
-
|
|
19878
|
-
|
|
19879
|
-
|
|
19880
|
-
|
|
19881
|
-
|
|
19882
|
-
|
|
19883
|
-
|
|
19884
|
-
|
|
19885
|
-
|
|
19886
|
-
|
|
19887
|
-
|
|
19888
|
-
|
|
19889
|
-
|
|
19890
|
-
|
|
19891
|
-
|
|
19892
|
-
|
|
19893
|
-
|
|
19894
|
-
|
|
19895
|
-
|
|
19896
|
-
|
|
19897
|
-
|
|
19898
|
-
|
|
19899
|
-
|
|
19900
|
-
|
|
19901
|
-
|
|
19902
|
-
|
|
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
|
+
});
|
|
19903
18928
|
}
|
|
19904
18929
|
this.onProgress({
|
|
19905
18930
|
type: "step-complete",
|
|
@@ -19943,7 +18968,11 @@ class SetupService {
|
|
|
19943
18968
|
step: "reconcile",
|
|
19944
18969
|
message: `Cleaning up legacy secret "${oldName}" on ${worker}...`
|
|
19945
18970
|
});
|
|
19946
|
-
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
|
+
}
|
|
19947
18976
|
fixed.push(`${worker}:${oldName}\u2192deleted`);
|
|
19948
18977
|
warnings.push(`Deleted legacy secret "${oldName}" from ${worker} \u2014 was replaced by "${newName}"`);
|
|
19949
18978
|
} else {
|
|
@@ -19954,8 +18983,12 @@ class SetupService {
|
|
|
19954
18983
|
});
|
|
19955
18984
|
const putResult = await this.cf.secretPut(worker, newName, newValue);
|
|
19956
18985
|
if (putResult.ok) {
|
|
19957
|
-
await this.cf.secretDelete(worker, oldName);
|
|
19958
|
-
|
|
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
|
+
}
|
|
19959
18992
|
} else {
|
|
19960
18993
|
warnings.push(`Could not migrate "${oldName}" to "${newName}" on ${worker}: ${putResult.error}`);
|
|
19961
18994
|
}
|
|
@@ -20274,9 +19307,12 @@ async function createDevVars(config, secrets, opts) {
|
|
|
20274
19307
|
lines.push(`# .dev.vars \u2014 local secrets for ${workerName}`);
|
|
20275
19308
|
lines.push(`# Generated by \`hoox init\`. NEVER commit this file.`);
|
|
20276
19309
|
lines.push("");
|
|
20277
|
-
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;
|
|
20278
19314
|
for (const [key, value] of Object.entries(integrationSecrets)) {
|
|
20279
|
-
lines.push(
|
|
19315
|
+
lines.push(serializeEnvLine(key, value));
|
|
20280
19316
|
}
|
|
20281
19317
|
}
|
|
20282
19318
|
if (lines.length <= 3)
|
|
@@ -20726,7 +19762,12 @@ async function runInitCommand(options, globalOpts, isNonInteractive) {
|
|
|
20726
19762
|
stdout: "inherit",
|
|
20727
19763
|
stderr: "inherit"
|
|
20728
19764
|
});
|
|
20729
|
-
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
|
+
}
|
|
20730
19771
|
}
|
|
20731
19772
|
engine.execute({});
|
|
20732
19773
|
}
|
|
@@ -21346,7 +20387,10 @@ async function runRichTasks(tasks, options = {}) {
|
|
|
21346
20387
|
}
|
|
21347
20388
|
if (options.onSummary) {
|
|
21348
20389
|
options.onSummary(results);
|
|
21349
|
-
} else if (
|
|
20390
|
+
} else if (options.format?.json) {
|
|
20391
|
+
process.stdout.write(`${JSON.stringify(results)}
|
|
20392
|
+
`);
|
|
20393
|
+
} else if (!options.format?.quiet) {
|
|
21350
20394
|
renderDefaultSummary(results);
|
|
21351
20395
|
}
|
|
21352
20396
|
return results;
|
|
@@ -21759,7 +20803,7 @@ class EnvService {
|
|
|
21759
20803
|
for (const def of EnvService.getDefinitions()) {
|
|
21760
20804
|
if (def.required) {
|
|
21761
20805
|
const val = vars[def.name];
|
|
21762
|
-
if (
|
|
20806
|
+
if (isPlaceholderValue(val)) {
|
|
21763
20807
|
missing.push(def.name);
|
|
21764
20808
|
}
|
|
21765
20809
|
}
|
|
@@ -21999,7 +21043,7 @@ async function deployAll(configService, cf, env, forceRebuildDashboard = false,
|
|
|
21999
21043
|
const tasks = allItems.map((name) => ({
|
|
22000
21044
|
title: name,
|
|
22001
21045
|
run: async () => {
|
|
22002
|
-
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);
|
|
22003
21047
|
if (!result.success) {
|
|
22004
21048
|
throw new CLIError(result.error ?? `${name} deploy failed`, 1 /* ERROR */);
|
|
22005
21049
|
}
|
|
@@ -22039,7 +21083,12 @@ async function deployAll(configService, cf, env, forceRebuildDashboard = false,
|
|
|
22039
21083
|
});
|
|
22040
21084
|
}
|
|
22041
21085
|
function renderDeploySummary(results, format) {
|
|
22042
|
-
if (format.json
|
|
21086
|
+
if (format.json) {
|
|
21087
|
+
process.stdout.write(`${JSON.stringify(results)}
|
|
21088
|
+
`);
|
|
21089
|
+
return;
|
|
21090
|
+
}
|
|
21091
|
+
if (format.quiet)
|
|
22043
21092
|
return;
|
|
22044
21093
|
const rows = results.map((r) => {
|
|
22045
21094
|
const d = r.value;
|
|
@@ -22053,7 +21102,7 @@ function renderDeploySummary(results, format) {
|
|
|
22053
21102
|
});
|
|
22054
21103
|
formatTable(rows, {});
|
|
22055
21104
|
}
|
|
22056
|
-
async function deployDashboard(_cf, forceRebuild = false, silentMode = false, autoMode = false) {
|
|
21105
|
+
async function deployDashboard(_cf, forceRebuild = false, silentMode = false, autoMode = false, format = {}) {
|
|
22057
21106
|
const dashboardPath = "workers/dashboard";
|
|
22058
21107
|
const buildInfo = getDashboardBuildInfo(dashboardPath);
|
|
22059
21108
|
let action;
|
|
@@ -22086,7 +21135,7 @@ ${theme.heading("Deploying Dashboard")}
|
|
|
22086
21135
|
`);
|
|
22087
21136
|
}
|
|
22088
21137
|
const actionText = action === "rebuild" ? "Building & deploying" : "Deploying";
|
|
22089
|
-
const s =
|
|
21138
|
+
const s = createCliSpinner(format);
|
|
22090
21139
|
try {
|
|
22091
21140
|
s.start(`${actionText} dashboard...`);
|
|
22092
21141
|
if (action === "rebuild") {
|
|
@@ -22338,7 +21387,7 @@ ${setCount} key(s) set, ${errorCount} error(s)
|
|
|
22338
21387
|
}
|
|
22339
21388
|
}
|
|
22340
21389
|
async function doVersionHistory(worker, fmt) {
|
|
22341
|
-
const s =
|
|
21390
|
+
const s = createCliSpinner(fmt);
|
|
22342
21391
|
s.start(`Fetching deployment history for ${worker}...`);
|
|
22343
21392
|
const cf = new CloudflareService;
|
|
22344
21393
|
const result = await cf.versionsList(worker);
|
|
@@ -22370,7 +21419,7 @@ async function doVersionRollback(worker, version, fmt, yes) {
|
|
|
22370
21419
|
const cf = new CloudflareService;
|
|
22371
21420
|
let targetVersion = version;
|
|
22372
21421
|
if (!targetVersion) {
|
|
22373
|
-
const s =
|
|
21422
|
+
const s = createCliSpinner(fmt);
|
|
22374
21423
|
s.start(`Fetching recent versions for ${worker}...`);
|
|
22375
21424
|
const result = await cf.versionsList(worker);
|
|
22376
21425
|
if (!result.ok) {
|
|
@@ -22413,7 +21462,7 @@ async function doVersionRollback(worker, version, fmt, yes) {
|
|
|
22413
21462
|
return;
|
|
22414
21463
|
}
|
|
22415
21464
|
}
|
|
22416
|
-
const s =
|
|
21465
|
+
const s = createCliSpinner(fmt);
|
|
22417
21466
|
s.start(`Rolling back ${worker} to version ${targetVersion}...`);
|
|
22418
21467
|
const rollResult = await cf.versionsRollback(worker, targetVersion);
|
|
22419
21468
|
if (!rollResult.ok) {
|
|
@@ -22508,7 +21557,8 @@ OPTIONS:
|
|
|
22508
21557
|
|
|
22509
21558
|
EXAMPLES:
|
|
22510
21559
|
hoox deploy workers
|
|
22511
|
-
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);
|
|
22512
21562
|
const configService = new ConfigService;
|
|
22513
21563
|
await configService.load();
|
|
22514
21564
|
const cf = new CloudflareService;
|
|
@@ -22535,7 +21585,7 @@ ${theme.heading("Deploying Workers")}
|
|
|
22535
21585
|
|
|
22536
21586
|
`);
|
|
22537
21587
|
for (const name of ordered) {
|
|
22538
|
-
const s =
|
|
21588
|
+
const s = createCliSpinner(fmt);
|
|
22539
21589
|
s.start(`Deploying ${name}...`);
|
|
22540
21590
|
const result = await deploySingle(configService, cf, name, options.env);
|
|
22541
21591
|
results.push(result);
|
|
@@ -22614,7 +21664,7 @@ EXAMPLES:
|
|
|
22614
21664
|
hoox deploy dashboard --rebuild Force rebuild before deploying`).option("--rebuild", "Force rebuild of dashboard before deploying").action(withErrorHandling(async (options, cmd) => {
|
|
22615
21665
|
const fmt = getFormatOptions(cmd);
|
|
22616
21666
|
const cf = new CloudflareService;
|
|
22617
|
-
const result = await deployDashboard(cf, options.rebuild);
|
|
21667
|
+
const result = await deployDashboard(cf, options.rebuild, false, false, fmt);
|
|
22618
21668
|
if (result.success) {
|
|
22619
21669
|
const url = result.url ? ` \u2014 ${result.url}` : "";
|
|
22620
21670
|
formatSuccess(`Dashboard deployed${url}`, fmt);
|
|
@@ -22704,7 +21754,6 @@ function register2(program) {
|
|
|
22704
21754
|
}
|
|
22705
21755
|
}
|
|
22706
21756
|
// src/commands/infra/infra-command.ts
|
|
22707
|
-
init_dist4();
|
|
22708
21757
|
init_main();
|
|
22709
21758
|
import { resolve as resolve3 } from "path";
|
|
22710
21759
|
init_config2();
|
|
@@ -22953,7 +22002,7 @@ async function doProvision(opts, cf, config) {
|
|
|
22953
22002
|
summary: { total: 0, created: 0, errors: 0, exists: 0 }
|
|
22954
22003
|
};
|
|
22955
22004
|
}
|
|
22956
|
-
const s =
|
|
22005
|
+
const s = createCliSpinner(opts);
|
|
22957
22006
|
for (const workerName of enabledWorkers) {
|
|
22958
22007
|
const workerConfig = configService.getWorker(workerName);
|
|
22959
22008
|
if (!workerConfig?.path)
|
|
@@ -23438,7 +22487,13 @@ async function handleShow(opts) {
|
|
|
23438
22487
|
}
|
|
23439
22488
|
const vars = await EnvService.loadDotEnvAsync(".env.local");
|
|
23440
22489
|
if (opts.json) {
|
|
23441
|
-
|
|
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);
|
|
23442
22497
|
} else {
|
|
23443
22498
|
process.stdout.write(EnvService.show(vars));
|
|
23444
22499
|
}
|
|
@@ -23690,11 +22745,11 @@ EXAMPLES:
|
|
|
23690
22745
|
}
|
|
23691
22746
|
|
|
23692
22747
|
// src/commands/config/secrets-subcommands.ts
|
|
23693
|
-
init_dist4();
|
|
23694
22748
|
init_secrets();
|
|
23695
22749
|
init_errors4();
|
|
23696
22750
|
init_theme();
|
|
23697
22751
|
init_wrangler_output();
|
|
22752
|
+
init_env_file();
|
|
23698
22753
|
function reportSecretSync(result, opts, scopeLabel) {
|
|
23699
22754
|
const nOk = result.synced.length;
|
|
23700
22755
|
const nSkip = result.skipped.length;
|
|
@@ -23719,9 +22774,12 @@ function reportSecretSync(result, opts, scopeLabel) {
|
|
|
23719
22774
|
return;
|
|
23720
22775
|
}
|
|
23721
22776
|
const detailParts = [];
|
|
23722
|
-
|
|
23723
|
-
|
|
23724
|
-
|
|
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);
|
|
23725
22783
|
for (const s of result.skipped) {
|
|
23726
22784
|
detailParts.push(`\xB7 ${s.name}: ${s.reason ?? "skipped"}`);
|
|
23727
22785
|
}
|
|
@@ -23801,14 +22859,14 @@ async function updateDevVars(filePath, key, value) {
|
|
|
23801
22859
|
let found = false;
|
|
23802
22860
|
for (const line of lines) {
|
|
23803
22861
|
if (line.startsWith(`${key}=`)) {
|
|
23804
|
-
updated.push(
|
|
22862
|
+
updated.push(serializeEnvLine(key, value));
|
|
23805
22863
|
found = true;
|
|
23806
22864
|
} else {
|
|
23807
22865
|
updated.push(line);
|
|
23808
22866
|
}
|
|
23809
22867
|
}
|
|
23810
22868
|
if (!found) {
|
|
23811
|
-
updated.push(
|
|
22869
|
+
updated.push(serializeEnvLine(key, value));
|
|
23812
22870
|
}
|
|
23813
22871
|
while (updated.length > 0 && updated[updated.length - 1] === "") {
|
|
23814
22872
|
updated.pop();
|
|
@@ -23817,7 +22875,7 @@ async function updateDevVars(filePath, key, value) {
|
|
|
23817
22875
|
`) + `
|
|
23818
22876
|
`);
|
|
23819
22877
|
} else {
|
|
23820
|
-
await Bun.write(filePath, `${key
|
|
22878
|
+
await Bun.write(filePath, `${serializeEnvLine(key, value)}
|
|
23821
22879
|
`);
|
|
23822
22880
|
}
|
|
23823
22881
|
await Promise.resolve().then(() => init_fs_secure());
|
|
@@ -23905,7 +22963,7 @@ EXAMPLES:
|
|
|
23905
22963
|
const devVarsPath = `${workerPath}/.dev.vars`;
|
|
23906
22964
|
await updateDevVars(devVarsPath, secretName, value);
|
|
23907
22965
|
formatSuccess(`Secret "${secretName}" updated in ${devVarsPath}`, opts);
|
|
23908
|
-
const syncSpin =
|
|
22966
|
+
const syncSpin = createCliSpinner(opts);
|
|
23909
22967
|
syncSpin.start("Syncing to Cloudflare...");
|
|
23910
22968
|
const result = await svc.syncToCloudflare(workerName);
|
|
23911
22969
|
if (!result.ok) {
|
|
@@ -24008,7 +23066,7 @@ EXAMPLES:
|
|
|
24008
23066
|
const scopeLabel = systemOnly ? "system secret(s)" : "secret(s)";
|
|
24009
23067
|
const svc = await SecretsService.create();
|
|
24010
23068
|
if (workerName) {
|
|
24011
|
-
const syncSpin =
|
|
23069
|
+
const syncSpin = createCliSpinner(opts);
|
|
24012
23070
|
syncSpin.start(`Syncing ${scopeLabel} for "${workerName}"...`);
|
|
24013
23071
|
const result = await svc.syncToCloudflare(workerName, syncOpts);
|
|
24014
23072
|
if (!result.ok) {
|
|
@@ -24034,7 +23092,7 @@ EXAMPLES:
|
|
|
24034
23092
|
let workersOk = 0;
|
|
24035
23093
|
let workersFailed = 0;
|
|
24036
23094
|
let totalSecrets = 0;
|
|
24037
|
-
const syncSpin =
|
|
23095
|
+
const syncSpin = createCliSpinner(opts);
|
|
24038
23096
|
const failures = [];
|
|
24039
23097
|
for (const name of workers) {
|
|
24040
23098
|
syncSpin.start(`Syncing ${name}...`);
|
|
@@ -24529,11 +23587,10 @@ EXAMPLES:
|
|
|
24529
23587
|
registerKeysSubcommands(cmd, "keys");
|
|
24530
23588
|
}
|
|
24531
23589
|
// src/commands/check/check-command.ts
|
|
24532
|
-
init_dist4();
|
|
24533
|
-
init_main();
|
|
24534
|
-
init_config2();
|
|
24535
23590
|
import { readdir } from "fs/promises";
|
|
24536
23591
|
import path4 from "path";
|
|
23592
|
+
init_main();
|
|
23593
|
+
init_config2();
|
|
24537
23594
|
init_secrets();
|
|
24538
23595
|
|
|
24539
23596
|
// src/commands/check/prerequisites-command.ts
|
|
@@ -24991,11 +24048,11 @@ async function runDatabaseChecks(cf, configService) {
|
|
|
24991
24048
|
} else {
|
|
24992
24049
|
checks.push({
|
|
24993
24050
|
name: "Required Tables",
|
|
24994
|
-
success:
|
|
24995
|
-
errors: [
|
|
24996
|
-
warnings: [
|
|
24051
|
+
success: false,
|
|
24052
|
+
errors: [
|
|
24997
24053
|
`Table schema not verified: ${sqlResult.error}. Run: wrangler d1 execute ${dbName} --command="SELECT name FROM sqlite_master WHERE type='table'" --remote`
|
|
24998
|
-
]
|
|
24054
|
+
],
|
|
24055
|
+
warnings: []
|
|
24999
24056
|
});
|
|
25000
24057
|
}
|
|
25001
24058
|
}
|
|
@@ -25182,7 +24239,8 @@ async function handleHealth(opts, autoFix) {
|
|
|
25182
24239
|
}));
|
|
25183
24240
|
const taskResults = await runRichTasks(tasks, {
|
|
25184
24241
|
title: `Health-checking ${enabledWorkers.length} worker(s)`,
|
|
25185
|
-
format: opts
|
|
24242
|
+
format: opts,
|
|
24243
|
+
...opts.json ? { onSummary: () => {} } : {}
|
|
25186
24244
|
});
|
|
25187
24245
|
for (const r of taskResults) {
|
|
25188
24246
|
if (r.value)
|
|
@@ -25219,7 +24277,7 @@ ${theme.warning(icons.warning)} Auto-fix flag set but health issues require manu
|
|
|
25219
24277
|
}
|
|
25220
24278
|
}
|
|
25221
24279
|
async function handleFix(opts, dryRun) {
|
|
25222
|
-
const s =
|
|
24280
|
+
const s = createCliSpinner(opts);
|
|
25223
24281
|
const actions = [];
|
|
25224
24282
|
try {
|
|
25225
24283
|
const configService = new ConfigService;
|
|
@@ -25409,7 +24467,6 @@ async function checkSubmoduleGitignore(_opts) {
|
|
|
25409
24467
|
if (!await gitignoreFile.exists()) {
|
|
25410
24468
|
await Bun.write(gitignorePath, WORKER_GITIGNORE_TEMPLATE);
|
|
25411
24469
|
fixed.push(`${workerName}: created .gitignore`);
|
|
25412
|
-
continue;
|
|
25413
24470
|
}
|
|
25414
24471
|
const content = await gitignoreFile.text();
|
|
25415
24472
|
const lines = content.split(`
|
|
@@ -25439,7 +24496,7 @@ async function checkSubmoduleGitignore(_opts) {
|
|
|
25439
24496
|
};
|
|
25440
24497
|
}
|
|
25441
24498
|
async function handleSubmoduleGitignore(opts) {
|
|
25442
|
-
const s =
|
|
24499
|
+
const s = createCliSpinner(opts);
|
|
25443
24500
|
try {
|
|
25444
24501
|
s.start("Checking submodule .gitignore files...");
|
|
25445
24502
|
const result = await checkSubmoduleGitignore(opts);
|
|
@@ -25821,7 +24878,6 @@ function registerLogsCommand(program) {
|
|
|
25821
24878
|
}, { service: "logs" }));
|
|
25822
24879
|
}
|
|
25823
24880
|
// src/commands/test/test-command.ts
|
|
25824
|
-
init_dist4();
|
|
25825
24881
|
init_config2();
|
|
25826
24882
|
init_theme();
|
|
25827
24883
|
init_errors4();
|
|
@@ -25922,7 +24978,7 @@ function registerTestCommand(program) {
|
|
|
25922
24978
|
const useJson = options.json || fmt.json;
|
|
25923
24979
|
const opts = { json: useJson, quiet: fmt.quiet };
|
|
25924
24980
|
const results = [];
|
|
25925
|
-
const s =
|
|
24981
|
+
const s = createCliSpinner(opts);
|
|
25926
24982
|
const pipelineTimer = startTimer();
|
|
25927
24983
|
s.start("Running CI pipeline...");
|
|
25928
24984
|
for (const step of PIPELINE_STEPS) {
|
|
@@ -25999,8 +25055,9 @@ function registerTestCommand(program) {
|
|
|
25999
25055
|
process.exitCode = 1 /* ERROR */;
|
|
26000
25056
|
}
|
|
26001
25057
|
}, { service: "test" }));
|
|
26002
|
-
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) => {
|
|
26003
|
-
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);
|
|
26004
25061
|
const liveTimer = startTimer();
|
|
26005
25062
|
let filePattern = options.service ? `tests/live/${options.service}.test.ts` : "tests/live/";
|
|
26006
25063
|
s.start(`Running live tests${options.service ? ` for ${options.service}` : ""}...`);
|
|
@@ -26054,14 +25111,19 @@ async function cfApi(method, path, body) {
|
|
|
26054
25111
|
return { ok: false, error: `Cloudflare API request failed: ${message}` };
|
|
26055
25112
|
}
|
|
26056
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
|
+
}
|
|
26057
25120
|
function buildExpression(type, value) {
|
|
26058
25121
|
switch (type) {
|
|
26059
25122
|
case "ip-allowlist":
|
|
26060
|
-
return `(ip.src eq ${value})`;
|
|
26061
25123
|
case "ip-blocklist":
|
|
26062
|
-
return `(ip.src eq ${value})`;
|
|
25124
|
+
return `(ip.src eq ${quoteIp(value)})`;
|
|
26063
25125
|
case "rate-limit":
|
|
26064
|
-
return
|
|
25126
|
+
return value.trim() ? value : '(http.request.uri.path ne "")';
|
|
26065
25127
|
case "custom":
|
|
26066
25128
|
return value;
|
|
26067
25129
|
}
|
|
@@ -26069,15 +25131,21 @@ function buildExpression(type, value) {
|
|
|
26069
25131
|
function mapAction(type) {
|
|
26070
25132
|
switch (type) {
|
|
26071
25133
|
case "ip-allowlist":
|
|
26072
|
-
return "
|
|
25134
|
+
return "skip";
|
|
26073
25135
|
case "ip-blocklist":
|
|
26074
25136
|
return "block";
|
|
26075
25137
|
case "rate-limit":
|
|
26076
|
-
return "
|
|
25138
|
+
return "block";
|
|
26077
25139
|
case "custom":
|
|
26078
25140
|
return "block";
|
|
26079
25141
|
}
|
|
26080
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
|
+
}
|
|
26081
25149
|
async function resolveZone(cf) {
|
|
26082
25150
|
if (process.env.CLOUDFLARE_ZONE_ID) {
|
|
26083
25151
|
return {
|
|
@@ -26094,6 +25162,9 @@ async function resolveZone(cf) {
|
|
|
26094
25162
|
if (lines.length === 0) {
|
|
26095
25163
|
throw new CLIError("No zones found. Set CLOUDFLARE_ZONE_ID environment variable.", 1 /* ERROR */);
|
|
26096
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
|
+
}
|
|
26097
25168
|
const firstLine = lines[0];
|
|
26098
25169
|
if (!firstLine) {
|
|
26099
25170
|
throw new CLIError("No zones found. Set CLOUDFLARE_ZONE_ID environment variable.", 1 /* ERROR */);
|
|
@@ -26111,21 +25182,22 @@ async function resolveZone(cf) {
|
|
|
26111
25182
|
async function handleStatus(opts) {
|
|
26112
25183
|
const cf = new CloudflareService;
|
|
26113
25184
|
const zone = await resolveZone(cf);
|
|
26114
|
-
const
|
|
26115
|
-
if (!
|
|
26116
|
-
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 */);
|
|
26117
25188
|
}
|
|
26118
|
-
const rulesResult = await cfApi("GET",
|
|
26119
|
-
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;
|
|
26120
25191
|
let recentBlocks = 0;
|
|
26121
25192
|
const since = new Date(Date.now() - 24 * 60 * 60 * 1000).toISOString();
|
|
26122
25193
|
const analyticsResult = await cfApi("GET", `/zones/${zone.id}/analytics/dashboard?since=${encodeURIComponent(since)}&continuous=true`);
|
|
26123
25194
|
if (analyticsResult.ok) {
|
|
26124
25195
|
recentBlocks = analyticsResult.value.totals?.threats ?? 0;
|
|
26125
25196
|
}
|
|
25197
|
+
const mode = securityResult.value.value;
|
|
26126
25198
|
const status = {
|
|
26127
|
-
enabled:
|
|
26128
|
-
mode
|
|
25199
|
+
enabled: mode !== "essentially_off" && mode !== "off",
|
|
25200
|
+
mode,
|
|
26129
25201
|
activeRulesCount,
|
|
26130
25202
|
recentBlocks,
|
|
26131
25203
|
zoneId: zone.id,
|
|
@@ -26156,17 +25228,17 @@ WAF status for ${zone.name}
|
|
|
26156
25228
|
async function handleRulesList(opts) {
|
|
26157
25229
|
const cf = new CloudflareService;
|
|
26158
25230
|
const zone = await resolveZone(cf);
|
|
26159
|
-
const result = await cfApi("GET",
|
|
25231
|
+
const result = await cfApi("GET", customRulesetPath(zone.id));
|
|
26160
25232
|
if (!result.ok) {
|
|
26161
25233
|
throw new CLIError(`Failed to list firewall rules: ${result.error}`, 1 /* ERROR */);
|
|
26162
25234
|
}
|
|
26163
|
-
const rules = result.value.map((r) => ({
|
|
25235
|
+
const rules = (result.value.rules ?? []).map((r) => ({
|
|
26164
25236
|
id: r.id,
|
|
26165
|
-
description: r.description,
|
|
25237
|
+
description: r.description ?? "",
|
|
26166
25238
|
mode: r.action,
|
|
26167
|
-
expression: r.
|
|
26168
|
-
created_at: r.
|
|
26169
|
-
updated_at: r.
|
|
25239
|
+
expression: r.expression ?? "(unknown)",
|
|
25240
|
+
created_at: r.last_updated ?? "",
|
|
25241
|
+
updated_at: r.last_updated ?? ""
|
|
26170
25242
|
}));
|
|
26171
25243
|
if (opts.json) {
|
|
26172
25244
|
process.stdout.write(JSON.stringify(rules, null, 2) + `
|
|
@@ -26203,31 +25275,44 @@ async function handleRulesAdd(type, value, opts) {
|
|
|
26203
25275
|
const zone = await resolveZone(cf);
|
|
26204
25276
|
const expression = buildExpression(ruleInput.type, value);
|
|
26205
25277
|
const action = mapAction(ruleInput.type);
|
|
26206
|
-
const
|
|
26207
|
-
|
|
26208
|
-
|
|
26209
|
-
|
|
26210
|
-
|
|
26211
|
-
const filterResult = await cfApi("POST", `/zones/${zone.id}/filters`, { expression });
|
|
26212
|
-
if (!filterResult.ok) {
|
|
26213
|
-
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 */);
|
|
26214
25283
|
}
|
|
26215
25284
|
const ruleBody = {
|
|
26216
|
-
description
|
|
25285
|
+
description,
|
|
26217
25286
|
action,
|
|
26218
|
-
|
|
25287
|
+
expression,
|
|
25288
|
+
enabled: true
|
|
26219
25289
|
};
|
|
26220
|
-
|
|
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);
|
|
26221
25303
|
if (!ruleResult.ok) {
|
|
26222
25304
|
throw new CLIError(`Failed to create firewall rule: ${ruleResult.error}`, 1 /* ERROR */);
|
|
26223
25305
|
}
|
|
26224
|
-
|
|
26225
|
-
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);
|
|
26226
25307
|
}
|
|
26227
25308
|
async function handleRulesRemove(ruleId, opts) {
|
|
26228
25309
|
const cf = new CloudflareService;
|
|
26229
25310
|
const zone = await resolveZone(cf);
|
|
26230
|
-
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}`);
|
|
26231
25316
|
if (!result.ok) {
|
|
26232
25317
|
throw new CLIError(`Failed to remove firewall rule: ${result.error}`, 1 /* ERROR */);
|
|
26233
25318
|
}
|
|
@@ -26236,7 +25321,7 @@ async function handleRulesRemove(ruleId, opts) {
|
|
|
26236
25321
|
async function handleMode(mode, opts) {
|
|
26237
25322
|
const cf = new CloudflareService;
|
|
26238
25323
|
const zone = await resolveZone(cf);
|
|
26239
|
-
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" });
|
|
26240
25325
|
if (!result.ok) {
|
|
26241
25326
|
throw new CLIError(`Failed to ${mode === "on" ? "enable" : "disable"} WAF: ${result.error}`, 1 /* ERROR */);
|
|
26242
25327
|
}
|
|
@@ -26273,7 +25358,6 @@ function registerWafCommand(program) {
|
|
|
26273
25358
|
}, { service: "waf" }));
|
|
26274
25359
|
}
|
|
26275
25360
|
// src/commands/clone/clone-command.ts
|
|
26276
|
-
init_dist4();
|
|
26277
25361
|
init_config2();
|
|
26278
25362
|
init_src();
|
|
26279
25363
|
init_theme();
|
|
@@ -26417,7 +25501,7 @@ EXAMPLES:
|
|
|
26417
25501
|
return;
|
|
26418
25502
|
}
|
|
26419
25503
|
const repoBase = options.org ? `https://github.com/${options.org}` : await resolveRepoBase();
|
|
26420
|
-
const s =
|
|
25504
|
+
const s = createCliSpinner(fmt);
|
|
26421
25505
|
const cloneTimer = startTimer();
|
|
26422
25506
|
const location = options.home ? "$HOME/.hoox/workers" : "workers/";
|
|
26423
25507
|
s.start(`Cloning ${workers.length} worker(s) to ${location}...`);
|
|
@@ -26490,7 +25574,7 @@ EXAMPLES:
|
|
|
26490
25574
|
return;
|
|
26491
25575
|
}
|
|
26492
25576
|
const repoBase = options.org ? `https://github.com/${options.org}` : await resolveRepoBase();
|
|
26493
|
-
const s =
|
|
25577
|
+
const s = createCliSpinner(fmt);
|
|
26494
25578
|
const singleTimer = startTimer();
|
|
26495
25579
|
const location = options.home ? "$HOME/.hoox/workers" : "workers/";
|
|
26496
25580
|
s.start(`Cloning ${name} to ${location}...`);
|
|
@@ -26558,7 +25642,6 @@ EXAMPLES:
|
|
|
26558
25642
|
}
|
|
26559
25643
|
// src/commands/db/db-command.ts
|
|
26560
25644
|
init_dist4();
|
|
26561
|
-
init_dist4();
|
|
26562
25645
|
|
|
26563
25646
|
// src/services/db/db-service.ts
|
|
26564
25647
|
init_config2();
|
|
@@ -26717,7 +25800,7 @@ async function resolveDb(cmd, svc) {
|
|
|
26717
25800
|
}
|
|
26718
25801
|
async function handleApply(opts, dbName, remote, file) {
|
|
26719
25802
|
const svc = new DbService;
|
|
26720
|
-
const s =
|
|
25803
|
+
const s = createCliSpinner(opts);
|
|
26721
25804
|
const t = startTimer();
|
|
26722
25805
|
s.start("Applying schema...");
|
|
26723
25806
|
try {
|
|
@@ -26735,7 +25818,7 @@ async function handleApply(opts, dbName, remote, file) {
|
|
|
26735
25818
|
}
|
|
26736
25819
|
async function handleMigrate(opts, dbName, remote) {
|
|
26737
25820
|
const svc = new DbService;
|
|
26738
|
-
const s =
|
|
25821
|
+
const s = createCliSpinner(opts);
|
|
26739
25822
|
const t = startTimer();
|
|
26740
25823
|
s.start("Running migrations...");
|
|
26741
25824
|
try {
|
|
@@ -26814,7 +25897,7 @@ async function handleQuery(opts, dbName, sql, remote, allowDestructive) {
|
|
|
26814
25897
|
}
|
|
26815
25898
|
async function handleExport(opts, dbName, outputPath) {
|
|
26816
25899
|
const svc = new DbService;
|
|
26817
|
-
const s =
|
|
25900
|
+
const s = createCliSpinner(opts);
|
|
26818
25901
|
const t = startTimer();
|
|
26819
25902
|
s.start("Exporting database...");
|
|
26820
25903
|
try {
|
|
@@ -26838,7 +25921,7 @@ async function handleReset(opts, dbName, confirmed) {
|
|
|
26838
25921
|
}
|
|
26839
25922
|
}
|
|
26840
25923
|
const svc = new DbService;
|
|
26841
|
-
const s =
|
|
25924
|
+
const s = createCliSpinner(opts);
|
|
26842
25925
|
const t = startTimer();
|
|
26843
25926
|
s.start("Resetting database...");
|
|
26844
25927
|
try {
|
|
@@ -26923,6 +26006,7 @@ EXAMPLES:
|
|
|
26923
26006
|
init_kv_sync_service();
|
|
26924
26007
|
init_errors4();
|
|
26925
26008
|
init_theme();
|
|
26009
|
+
init_src();
|
|
26926
26010
|
function assertSafeInteger(value, name, max) {
|
|
26927
26011
|
if (!Number.isInteger(value) || value < 0 || value > max || !Number.isSafeInteger(value)) {
|
|
26928
26012
|
throw new Error(`Invalid ${name}: ${value} (must be a non-negative integer \u2264 ${max})`);
|
|
@@ -26970,15 +26054,32 @@ async function doMonitorKillSwitch(action, fmt) {
|
|
|
26970
26054
|
try {
|
|
26971
26055
|
const kv = new KvSyncService;
|
|
26972
26056
|
const namespaceId = await kv.resolveNamespaceId();
|
|
26973
|
-
const key = "trade:kill_switch";
|
|
26974
26057
|
if (action === "show") {
|
|
26975
|
-
const
|
|
26976
|
-
|
|
26977
|
-
|
|
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) + `
|
|
26978
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
|
+
}
|
|
26979
26078
|
} else {
|
|
26980
26079
|
const newValue = action === "on" ? "true" : "false";
|
|
26981
|
-
|
|
26080
|
+
for (const key of KILL_SWITCH_KEYS) {
|
|
26081
|
+
await kv.set(namespaceId, key, newValue);
|
|
26082
|
+
}
|
|
26982
26083
|
formatSuccess(`Kill switch turned ${action === "on" ? "ON" : "OFF"}`, fmt);
|
|
26983
26084
|
}
|
|
26984
26085
|
} catch (err) {
|
|
@@ -27169,21 +26270,21 @@ EXAMPLES:
|
|
|
27169
26270
|
const fmt = getFormatOptions(cmd);
|
|
27170
26271
|
await doMonitorLogs(worker, fmt);
|
|
27171
26272
|
}, { service: "monitor" }));
|
|
27172
|
-
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.
|
|
27173
26274
|
|
|
27174
26275
|
Commands:
|
|
27175
|
-
show Display current kill switch status
|
|
27176
|
-
on Halt all trading (set
|
|
27177
|
-
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)`);
|
|
27178
26279
|
ksCmd.command("show").summary("Show kill switch status").description("Display whether trading is halted or active.").action(withErrorHandling(async (_, cmd) => {
|
|
27179
26280
|
const fmt = getFormatOptions(cmd);
|
|
27180
26281
|
await doMonitorKillSwitch("show", fmt);
|
|
27181
26282
|
}, { service: "monitor" }));
|
|
27182
|
-
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) => {
|
|
27183
26284
|
const fmt = getFormatOptions(cmd);
|
|
27184
26285
|
await doMonitorKillSwitch("on", fmt);
|
|
27185
26286
|
}, { service: "monitor" }));
|
|
27186
|
-
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) => {
|
|
27187
26288
|
const fmt = getFormatOptions(cmd);
|
|
27188
26289
|
await doMonitorKillSwitch("off", fmt);
|
|
27189
26290
|
}, { service: "monitor" }));
|
|
@@ -27716,8 +26817,13 @@ async function handleRebuild(fmt) {
|
|
|
27716
26817
|
await config.load();
|
|
27717
26818
|
for (const worker of config.listEnabledWorkers()) {
|
|
27718
26819
|
const cfg = config.getWorker(worker);
|
|
27719
|
-
if (cfg)
|
|
27720
|
-
|
|
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;
|
|
27721
26827
|
}
|
|
27722
26828
|
}
|
|
27723
26829
|
formatSuccess("Rebuild complete", fmt);
|
|
@@ -27758,7 +26864,6 @@ function registerRepairCommand(program) {
|
|
|
27758
26864
|
}, { service: "repair" }));
|
|
27759
26865
|
}
|
|
27760
26866
|
// src/commands/update/update-command.ts
|
|
27761
|
-
init_dist4();
|
|
27762
26867
|
init_config2();
|
|
27763
26868
|
init_update();
|
|
27764
26869
|
init_errors4();
|
|
@@ -27773,7 +26878,8 @@ With "wrangler", updates wrangler to the latest version.
|
|
|
27773
26878
|
EXAMPLES:
|
|
27774
26879
|
hoox update Pull latest for main repo
|
|
27775
26880
|
hoox update d1-worker Update the d1-worker submodule
|
|
27776
|
-
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);
|
|
27777
26883
|
const cwd = process.cwd();
|
|
27778
26884
|
if (target === "wrangler") {
|
|
27779
26885
|
const service = new UpdateService;
|
|
@@ -27797,14 +26903,14 @@ EXAMPLES:
|
|
|
27797
26903
|
if (!await isSubmodule(cwd, submodulePath)) {
|
|
27798
26904
|
throw new CLIError(`"${submodulePath}" is not a git submodule \u2014 nothing to update`, 2 /* INVALID_USAGE */);
|
|
27799
26905
|
}
|
|
27800
|
-
const s =
|
|
26906
|
+
const s = createCliSpinner(fmt);
|
|
27801
26907
|
const t = startTimer();
|
|
27802
26908
|
s.start(`Updating ${target}...`);
|
|
27803
26909
|
const output = await gitSubmoduleUpdate(cwd, submodulePath);
|
|
27804
26910
|
const dur = formatDuration3(t.ms());
|
|
27805
26911
|
s.stop(output ? theme.success(`Updated ${target} (${dur})`) : theme.muted(`${target} already up to date (${dur})`));
|
|
27806
26912
|
} else {
|
|
27807
|
-
const s =
|
|
26913
|
+
const s = createCliSpinner(fmt);
|
|
27808
26914
|
const t = startTimer();
|
|
27809
26915
|
s.start("Pulling latest from remote...");
|
|
27810
26916
|
const output = await gitPull(cwd);
|
|
@@ -27901,7 +27007,7 @@ import { createRequire } from "module";
|
|
|
27901
27007
|
import { resolve as resolve6, dirname as dirname3, join as join9 } from "path";
|
|
27902
27008
|
import { fileURLToPath } from "url";
|
|
27903
27009
|
import { existsSync as existsSync13, realpathSync } from "fs";
|
|
27904
|
-
import { homedir as
|
|
27010
|
+
import { homedir as homedir3 } from "os";
|
|
27905
27011
|
|
|
27906
27012
|
// src/services/perf/endpoint-resolver.ts
|
|
27907
27013
|
import { readFileSync as readFileSync11 } from "fs";
|
|
@@ -27954,7 +27060,7 @@ function collectTuiCandidates() {
|
|
|
27954
27060
|
const cwdRequire = createRequire(join9(process.cwd(), "package.json"));
|
|
27955
27061
|
pushPackageEntries(candidates, cwdRequire);
|
|
27956
27062
|
} catch {}
|
|
27957
|
-
const bunGlobal = join9(
|
|
27063
|
+
const bunGlobal = join9(homedir3(), ".bun", "install", "global", "node_modules", TUI_PKG);
|
|
27958
27064
|
pushPackageRootEntries(candidates, bunGlobal);
|
|
27959
27065
|
const npmGlobal = process.env.npm_config_prefix?.trim();
|
|
27960
27066
|
if (npmGlobal) {
|
|
@@ -28192,6 +27298,7 @@ TUI session ended.
|
|
|
28192
27298
|
console.log(theme.dim(`
|
|
28193
27299
|
TUI exited with code ${code}
|
|
28194
27300
|
`));
|
|
27301
|
+
process.exitCode = code;
|
|
28195
27302
|
resolveChild();
|
|
28196
27303
|
} else {
|
|
28197
27304
|
reject(new CLIError("TUI process terminated abnormally", 1 /* ERROR */));
|
|
@@ -28204,10 +27311,9 @@ TUI exited with code ${code}
|
|
|
28204
27311
|
}, { service: "tui" }));
|
|
28205
27312
|
}
|
|
28206
27313
|
// src/commands/doctor/doctor-command.ts
|
|
28207
|
-
init_dist4();
|
|
28208
27314
|
init_src();
|
|
28209
27315
|
import { join as join11 } from "path";
|
|
28210
|
-
import { homedir as
|
|
27316
|
+
import { homedir as homedir4 } from "os";
|
|
28211
27317
|
|
|
28212
27318
|
// src/services/runtime/runtime-service.ts
|
|
28213
27319
|
init_src();
|
|
@@ -28688,7 +27794,7 @@ Hoox doctor
|
|
|
28688
27794
|
return failed === 0 ? 0 /* SUCCESS */ : 1 /* ERROR */;
|
|
28689
27795
|
}
|
|
28690
27796
|
function printSecurityHygieneSection(env = process.env) {
|
|
28691
|
-
const configPath = join11(
|
|
27797
|
+
const configPath = join11(homedir4(), ".hoox", "config.json");
|
|
28692
27798
|
const lines = collectSecurityHygiene(env, { configPath });
|
|
28693
27799
|
process.stdout.write(theme.heading(`Security hygiene
|
|
28694
27800
|
`));
|
|
@@ -28706,7 +27812,7 @@ async function runSecurityDoctor(options) {
|
|
|
28706
27812
|
env.HOOX_API_URL = options.apiUrl;
|
|
28707
27813
|
}
|
|
28708
27814
|
const profile = resolveOperatorTransportProfile(env);
|
|
28709
|
-
const configPath = join11(
|
|
27815
|
+
const configPath = join11(homedir4(), ".hoox", "config.json");
|
|
28710
27816
|
const hygiene = collectSecurityHygiene(env, { configPath });
|
|
28711
27817
|
const isLocal = profile.apiBase.includes("localhost") || profile.apiBase.includes("127.0.0.1");
|
|
28712
27818
|
const shouldProbe = options.probe === true || options.probe !== false && !isLocal;
|
|
@@ -28798,7 +27904,7 @@ EXAMPLES:
|
|
|
28798
27904
|
return;
|
|
28799
27905
|
}
|
|
28800
27906
|
if (options.fixRuntime) {
|
|
28801
|
-
const s =
|
|
27907
|
+
const s = createCliSpinner(fmt);
|
|
28802
27908
|
const t = startTimer();
|
|
28803
27909
|
s.start("Ensuring global Hoox runtime...");
|
|
28804
27910
|
try {
|
|
@@ -30088,7 +29194,7 @@ EXAMPLES:
|
|
|
30088
29194
|
ye("Dry run complete. Run without --dry-run to execute.");
|
|
30089
29195
|
return;
|
|
30090
29196
|
}
|
|
30091
|
-
const authCheck =
|
|
29197
|
+
const authCheck = createCliSpinner(globalOpts);
|
|
30092
29198
|
authCheck.start("Checking Cloudflare authentication...");
|
|
30093
29199
|
const tempSvc = new SetupService;
|
|
30094
29200
|
const authOk = await tempSvc.checkAuth();
|
|
@@ -30122,7 +29228,7 @@ EXAMPLES:
|
|
|
30122
29228
|
const setupSvc = new SetupService(wireProgress((msg) => {
|
|
30123
29229
|
if (currentSpinner)
|
|
30124
29230
|
currentSpinner.stop();
|
|
30125
|
-
currentSpinner =
|
|
29231
|
+
currentSpinner = createCliSpinner(globalOpts);
|
|
30126
29232
|
currentSpinner.start(msg);
|
|
30127
29233
|
}, (msg) => {
|
|
30128
29234
|
if (currentSpinner)
|
|
@@ -31047,11 +30153,11 @@ async function handleRun(opts, fmt) {
|
|
|
31047
30153
|
config.timeoutMs = parseInt(opts.timeout, 10);
|
|
31048
30154
|
if (opts.apiKey !== undefined)
|
|
31049
30155
|
config.apiKey = opts.apiKey;
|
|
31050
|
-
const
|
|
31051
|
-
|
|
30156
|
+
const spin = createCliSpinner(fmt);
|
|
30157
|
+
spin.start(`Probing fast path: 0/0`);
|
|
31052
30158
|
const service = new FastPathService;
|
|
31053
30159
|
const report = await service.run(config);
|
|
31054
|
-
|
|
30160
|
+
spin.stop(`${report.successful}/${report.iterations} successful (${report.failed} failed${report.degraded ? ", degraded" : ""})`);
|
|
31055
30161
|
if (fmt.json) {
|
|
31056
30162
|
process.stdout.write(JSON.stringify(report, null, 2) + `
|
|
31057
30163
|
`);
|
|
@@ -31115,7 +30221,7 @@ Tailing fast path for ${durationSec}s (interval=${intervalMs}ms, concurrency=${c
|
|
|
31115
30221
|
process.stdout.write(JSON.stringify(report) + `
|
|
31116
30222
|
`);
|
|
31117
30223
|
} else {
|
|
31118
|
-
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
|
|
31119
30225
|
`);
|
|
31120
30226
|
}
|
|
31121
30227
|
const elapsed = Date.now() - batchStart;
|
|
@@ -31178,7 +30284,7 @@ function formatTableAsText(rows, columns) {
|
|
|
31178
30284
|
function parseTimeRange(fromStr, toStr) {
|
|
31179
30285
|
const now = Date.now();
|
|
31180
30286
|
const to = toStr ? parseTimeOrThrow(toStr, "to") : now;
|
|
31181
|
-
const from = fromStr ? parseTimeOrThrow(fromStr, "from") : now -
|
|
30287
|
+
const from = fromStr ? parseTimeOrThrow(fromStr, "from") : now - 60 * 60 * 1000;
|
|
31182
30288
|
return { from, to };
|
|
31183
30289
|
}
|
|
31184
30290
|
function parseTimeOrThrow(s, name) {
|