@tradejs/cli 1.0.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/README.md +65 -0
- package/dist/cli.js +10727 -0
- package/dist/lib/runBot.js +157 -0
- package/dist/scripts/backtest.js +2044 -0
- package/dist/scripts/bot.js +153 -0
- package/dist/scripts/cleanDir.js +40 -0
- package/dist/scripts/cleanRedis.js +40 -0
- package/dist/scripts/cleanTests.js +81 -0
- package/dist/scripts/continuity.js +183 -0
- package/dist/scripts/derivativesIngest.js +107 -0
- package/dist/scripts/derivativesIngestCoinalyzeAll.js +391 -0
- package/dist/scripts/doctor.js +5143 -0
- package/dist/scripts/findMlSignalsByTestSuite.js +83 -0
- package/dist/scripts/infraCommon.js +135 -0
- package/dist/scripts/infraDown.js +82 -0
- package/dist/scripts/infraInit.js +107 -0
- package/dist/scripts/infraUp.js +82 -0
- package/dist/scripts/migration.js +67 -0
- package/dist/scripts/mlExport.js +95 -0
- package/dist/scripts/mlExportSelect.js +100 -0
- package/dist/scripts/mlInspect.js +553 -0
- package/dist/scripts/mlTrainLatestSelect.js +1056 -0
- package/dist/scripts/results.js +1909 -0
- package/dist/scripts/selectStrategy.js +99 -0
- package/dist/scripts/signals.js +300 -0
- package/dist/scripts/test-ml.js +133 -0
- package/dist/scripts/test.js +16 -0
- package/dist/scripts/user-add.js +64 -0
- package/dist/workers/testerWorker.js +54 -0
- package/package.json +75 -0
|
@@ -0,0 +1,1909 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
+
};
|
|
11
|
+
var __export = (target, all) => {
|
|
12
|
+
for (var name in all)
|
|
13
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from))
|
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
+
mod
|
|
30
|
+
));
|
|
31
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
|
+
|
|
33
|
+
// ../../node_modules/debug/node_modules/ms/index.js
|
|
34
|
+
var require_ms = __commonJS({
|
|
35
|
+
"../../node_modules/debug/node_modules/ms/index.js"(exports2, module2) {
|
|
36
|
+
"use strict";
|
|
37
|
+
var s = 1e3;
|
|
38
|
+
var m = s * 60;
|
|
39
|
+
var h = m * 60;
|
|
40
|
+
var d = h * 24;
|
|
41
|
+
var w = d * 7;
|
|
42
|
+
var y = d * 365.25;
|
|
43
|
+
module2.exports = function(val, options) {
|
|
44
|
+
options = options || {};
|
|
45
|
+
var type = typeof val;
|
|
46
|
+
if (type === "string" && val.length > 0) {
|
|
47
|
+
return parse(val);
|
|
48
|
+
} else if (type === "number" && isFinite(val)) {
|
|
49
|
+
return options.long ? fmtLong(val) : fmtShort(val);
|
|
50
|
+
}
|
|
51
|
+
throw new Error(
|
|
52
|
+
"val is not a non-empty string or a valid number. val=" + JSON.stringify(val)
|
|
53
|
+
);
|
|
54
|
+
};
|
|
55
|
+
function parse(str) {
|
|
56
|
+
str = String(str);
|
|
57
|
+
if (str.length > 100) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
|
|
61
|
+
str
|
|
62
|
+
);
|
|
63
|
+
if (!match) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
var n = parseFloat(match[1]);
|
|
67
|
+
var type = (match[2] || "ms").toLowerCase();
|
|
68
|
+
switch (type) {
|
|
69
|
+
case "years":
|
|
70
|
+
case "year":
|
|
71
|
+
case "yrs":
|
|
72
|
+
case "yr":
|
|
73
|
+
case "y":
|
|
74
|
+
return n * y;
|
|
75
|
+
case "weeks":
|
|
76
|
+
case "week":
|
|
77
|
+
case "w":
|
|
78
|
+
return n * w;
|
|
79
|
+
case "days":
|
|
80
|
+
case "day":
|
|
81
|
+
case "d":
|
|
82
|
+
return n * d;
|
|
83
|
+
case "hours":
|
|
84
|
+
case "hour":
|
|
85
|
+
case "hrs":
|
|
86
|
+
case "hr":
|
|
87
|
+
case "h":
|
|
88
|
+
return n * h;
|
|
89
|
+
case "minutes":
|
|
90
|
+
case "minute":
|
|
91
|
+
case "mins":
|
|
92
|
+
case "min":
|
|
93
|
+
case "m":
|
|
94
|
+
return n * m;
|
|
95
|
+
case "seconds":
|
|
96
|
+
case "second":
|
|
97
|
+
case "secs":
|
|
98
|
+
case "sec":
|
|
99
|
+
case "s":
|
|
100
|
+
return n * s;
|
|
101
|
+
case "milliseconds":
|
|
102
|
+
case "millisecond":
|
|
103
|
+
case "msecs":
|
|
104
|
+
case "msec":
|
|
105
|
+
case "ms":
|
|
106
|
+
return n;
|
|
107
|
+
default:
|
|
108
|
+
return void 0;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
function fmtShort(ms) {
|
|
112
|
+
var msAbs = Math.abs(ms);
|
|
113
|
+
if (msAbs >= d) {
|
|
114
|
+
return Math.round(ms / d) + "d";
|
|
115
|
+
}
|
|
116
|
+
if (msAbs >= h) {
|
|
117
|
+
return Math.round(ms / h) + "h";
|
|
118
|
+
}
|
|
119
|
+
if (msAbs >= m) {
|
|
120
|
+
return Math.round(ms / m) + "m";
|
|
121
|
+
}
|
|
122
|
+
if (msAbs >= s) {
|
|
123
|
+
return Math.round(ms / s) + "s";
|
|
124
|
+
}
|
|
125
|
+
return ms + "ms";
|
|
126
|
+
}
|
|
127
|
+
function fmtLong(ms) {
|
|
128
|
+
var msAbs = Math.abs(ms);
|
|
129
|
+
if (msAbs >= d) {
|
|
130
|
+
return plural(ms, msAbs, d, "day");
|
|
131
|
+
}
|
|
132
|
+
if (msAbs >= h) {
|
|
133
|
+
return plural(ms, msAbs, h, "hour");
|
|
134
|
+
}
|
|
135
|
+
if (msAbs >= m) {
|
|
136
|
+
return plural(ms, msAbs, m, "minute");
|
|
137
|
+
}
|
|
138
|
+
if (msAbs >= s) {
|
|
139
|
+
return plural(ms, msAbs, s, "second");
|
|
140
|
+
}
|
|
141
|
+
return ms + " ms";
|
|
142
|
+
}
|
|
143
|
+
function plural(ms, msAbs, n, name) {
|
|
144
|
+
var isPlural = msAbs >= n * 1.5;
|
|
145
|
+
return Math.round(ms / n) + " " + name + (isPlural ? "s" : "");
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
// ../../node_modules/debug/src/common.js
|
|
151
|
+
var require_common = __commonJS({
|
|
152
|
+
"../../node_modules/debug/src/common.js"(exports2, module2) {
|
|
153
|
+
"use strict";
|
|
154
|
+
function setup(env) {
|
|
155
|
+
createDebug.debug = createDebug;
|
|
156
|
+
createDebug.default = createDebug;
|
|
157
|
+
createDebug.coerce = coerce;
|
|
158
|
+
createDebug.disable = disable;
|
|
159
|
+
createDebug.enable = enable;
|
|
160
|
+
createDebug.enabled = enabled;
|
|
161
|
+
createDebug.humanize = require_ms();
|
|
162
|
+
createDebug.destroy = destroy;
|
|
163
|
+
Object.keys(env).forEach((key) => {
|
|
164
|
+
createDebug[key] = env[key];
|
|
165
|
+
});
|
|
166
|
+
createDebug.names = [];
|
|
167
|
+
createDebug.skips = [];
|
|
168
|
+
createDebug.formatters = {};
|
|
169
|
+
function selectColor(namespace) {
|
|
170
|
+
let hash = 0;
|
|
171
|
+
for (let i = 0; i < namespace.length; i++) {
|
|
172
|
+
hash = (hash << 5) - hash + namespace.charCodeAt(i);
|
|
173
|
+
hash |= 0;
|
|
174
|
+
}
|
|
175
|
+
return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
|
|
176
|
+
}
|
|
177
|
+
createDebug.selectColor = selectColor;
|
|
178
|
+
function createDebug(namespace) {
|
|
179
|
+
let prevTime;
|
|
180
|
+
let enableOverride = null;
|
|
181
|
+
let namespacesCache;
|
|
182
|
+
let enabledCache;
|
|
183
|
+
function debug(...args2) {
|
|
184
|
+
if (!debug.enabled) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
const self = debug;
|
|
188
|
+
const curr = Number(/* @__PURE__ */ new Date());
|
|
189
|
+
const ms = curr - (prevTime || curr);
|
|
190
|
+
self.diff = ms;
|
|
191
|
+
self.prev = prevTime;
|
|
192
|
+
self.curr = curr;
|
|
193
|
+
prevTime = curr;
|
|
194
|
+
args2[0] = createDebug.coerce(args2[0]);
|
|
195
|
+
if (typeof args2[0] !== "string") {
|
|
196
|
+
args2.unshift("%O");
|
|
197
|
+
}
|
|
198
|
+
let index = 0;
|
|
199
|
+
args2[0] = args2[0].replace(/%([a-zA-Z%])/g, (match, format) => {
|
|
200
|
+
if (match === "%%") {
|
|
201
|
+
return "%";
|
|
202
|
+
}
|
|
203
|
+
index++;
|
|
204
|
+
const formatter = createDebug.formatters[format];
|
|
205
|
+
if (typeof formatter === "function") {
|
|
206
|
+
const val = args2[index];
|
|
207
|
+
match = formatter.call(self, val);
|
|
208
|
+
args2.splice(index, 1);
|
|
209
|
+
index--;
|
|
210
|
+
}
|
|
211
|
+
return match;
|
|
212
|
+
});
|
|
213
|
+
createDebug.formatArgs.call(self, args2);
|
|
214
|
+
const logFn = self.log || createDebug.log;
|
|
215
|
+
logFn.apply(self, args2);
|
|
216
|
+
}
|
|
217
|
+
debug.namespace = namespace;
|
|
218
|
+
debug.useColors = createDebug.useColors();
|
|
219
|
+
debug.color = createDebug.selectColor(namespace);
|
|
220
|
+
debug.extend = extend;
|
|
221
|
+
debug.destroy = createDebug.destroy;
|
|
222
|
+
Object.defineProperty(debug, "enabled", {
|
|
223
|
+
enumerable: true,
|
|
224
|
+
configurable: false,
|
|
225
|
+
get: () => {
|
|
226
|
+
if (enableOverride !== null) {
|
|
227
|
+
return enableOverride;
|
|
228
|
+
}
|
|
229
|
+
if (namespacesCache !== createDebug.namespaces) {
|
|
230
|
+
namespacesCache = createDebug.namespaces;
|
|
231
|
+
enabledCache = createDebug.enabled(namespace);
|
|
232
|
+
}
|
|
233
|
+
return enabledCache;
|
|
234
|
+
},
|
|
235
|
+
set: (v) => {
|
|
236
|
+
enableOverride = v;
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
if (typeof createDebug.init === "function") {
|
|
240
|
+
createDebug.init(debug);
|
|
241
|
+
}
|
|
242
|
+
return debug;
|
|
243
|
+
}
|
|
244
|
+
function extend(namespace, delimiter) {
|
|
245
|
+
const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace);
|
|
246
|
+
newDebug.log = this.log;
|
|
247
|
+
return newDebug;
|
|
248
|
+
}
|
|
249
|
+
function enable(namespaces) {
|
|
250
|
+
createDebug.save(namespaces);
|
|
251
|
+
createDebug.namespaces = namespaces;
|
|
252
|
+
createDebug.names = [];
|
|
253
|
+
createDebug.skips = [];
|
|
254
|
+
let i;
|
|
255
|
+
const split = (typeof namespaces === "string" ? namespaces : "").split(/[\s,]+/);
|
|
256
|
+
const len = split.length;
|
|
257
|
+
for (i = 0; i < len; i++) {
|
|
258
|
+
if (!split[i]) {
|
|
259
|
+
continue;
|
|
260
|
+
}
|
|
261
|
+
namespaces = split[i].replace(/\*/g, ".*?");
|
|
262
|
+
if (namespaces[0] === "-") {
|
|
263
|
+
createDebug.skips.push(new RegExp("^" + namespaces.slice(1) + "$"));
|
|
264
|
+
} else {
|
|
265
|
+
createDebug.names.push(new RegExp("^" + namespaces + "$"));
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
function disable() {
|
|
270
|
+
const namespaces = [
|
|
271
|
+
...createDebug.names.map(toNamespace),
|
|
272
|
+
...createDebug.skips.map(toNamespace).map((namespace) => "-" + namespace)
|
|
273
|
+
].join(",");
|
|
274
|
+
createDebug.enable("");
|
|
275
|
+
return namespaces;
|
|
276
|
+
}
|
|
277
|
+
function enabled(name) {
|
|
278
|
+
if (name[name.length - 1] === "*") {
|
|
279
|
+
return true;
|
|
280
|
+
}
|
|
281
|
+
let i;
|
|
282
|
+
let len;
|
|
283
|
+
for (i = 0, len = createDebug.skips.length; i < len; i++) {
|
|
284
|
+
if (createDebug.skips[i].test(name)) {
|
|
285
|
+
return false;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
for (i = 0, len = createDebug.names.length; i < len; i++) {
|
|
289
|
+
if (createDebug.names[i].test(name)) {
|
|
290
|
+
return true;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
return false;
|
|
294
|
+
}
|
|
295
|
+
function toNamespace(regexp) {
|
|
296
|
+
return regexp.toString().substring(2, regexp.toString().length - 2).replace(/\.\*\?$/, "*");
|
|
297
|
+
}
|
|
298
|
+
function coerce(val) {
|
|
299
|
+
if (val instanceof Error) {
|
|
300
|
+
return val.stack || val.message;
|
|
301
|
+
}
|
|
302
|
+
return val;
|
|
303
|
+
}
|
|
304
|
+
function destroy() {
|
|
305
|
+
console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
|
|
306
|
+
}
|
|
307
|
+
createDebug.enable(createDebug.load());
|
|
308
|
+
return createDebug;
|
|
309
|
+
}
|
|
310
|
+
module2.exports = setup;
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
// ../../node_modules/debug/src/browser.js
|
|
315
|
+
var require_browser = __commonJS({
|
|
316
|
+
"../../node_modules/debug/src/browser.js"(exports2, module2) {
|
|
317
|
+
"use strict";
|
|
318
|
+
exports2.formatArgs = formatArgs;
|
|
319
|
+
exports2.save = save;
|
|
320
|
+
exports2.load = load;
|
|
321
|
+
exports2.useColors = useColors;
|
|
322
|
+
exports2.storage = localstorage();
|
|
323
|
+
exports2.destroy = /* @__PURE__ */ (() => {
|
|
324
|
+
let warned = false;
|
|
325
|
+
return () => {
|
|
326
|
+
if (!warned) {
|
|
327
|
+
warned = true;
|
|
328
|
+
console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
})();
|
|
332
|
+
exports2.colors = [
|
|
333
|
+
"#0000CC",
|
|
334
|
+
"#0000FF",
|
|
335
|
+
"#0033CC",
|
|
336
|
+
"#0033FF",
|
|
337
|
+
"#0066CC",
|
|
338
|
+
"#0066FF",
|
|
339
|
+
"#0099CC",
|
|
340
|
+
"#0099FF",
|
|
341
|
+
"#00CC00",
|
|
342
|
+
"#00CC33",
|
|
343
|
+
"#00CC66",
|
|
344
|
+
"#00CC99",
|
|
345
|
+
"#00CCCC",
|
|
346
|
+
"#00CCFF",
|
|
347
|
+
"#3300CC",
|
|
348
|
+
"#3300FF",
|
|
349
|
+
"#3333CC",
|
|
350
|
+
"#3333FF",
|
|
351
|
+
"#3366CC",
|
|
352
|
+
"#3366FF",
|
|
353
|
+
"#3399CC",
|
|
354
|
+
"#3399FF",
|
|
355
|
+
"#33CC00",
|
|
356
|
+
"#33CC33",
|
|
357
|
+
"#33CC66",
|
|
358
|
+
"#33CC99",
|
|
359
|
+
"#33CCCC",
|
|
360
|
+
"#33CCFF",
|
|
361
|
+
"#6600CC",
|
|
362
|
+
"#6600FF",
|
|
363
|
+
"#6633CC",
|
|
364
|
+
"#6633FF",
|
|
365
|
+
"#66CC00",
|
|
366
|
+
"#66CC33",
|
|
367
|
+
"#9900CC",
|
|
368
|
+
"#9900FF",
|
|
369
|
+
"#9933CC",
|
|
370
|
+
"#9933FF",
|
|
371
|
+
"#99CC00",
|
|
372
|
+
"#99CC33",
|
|
373
|
+
"#CC0000",
|
|
374
|
+
"#CC0033",
|
|
375
|
+
"#CC0066",
|
|
376
|
+
"#CC0099",
|
|
377
|
+
"#CC00CC",
|
|
378
|
+
"#CC00FF",
|
|
379
|
+
"#CC3300",
|
|
380
|
+
"#CC3333",
|
|
381
|
+
"#CC3366",
|
|
382
|
+
"#CC3399",
|
|
383
|
+
"#CC33CC",
|
|
384
|
+
"#CC33FF",
|
|
385
|
+
"#CC6600",
|
|
386
|
+
"#CC6633",
|
|
387
|
+
"#CC9900",
|
|
388
|
+
"#CC9933",
|
|
389
|
+
"#CCCC00",
|
|
390
|
+
"#CCCC33",
|
|
391
|
+
"#FF0000",
|
|
392
|
+
"#FF0033",
|
|
393
|
+
"#FF0066",
|
|
394
|
+
"#FF0099",
|
|
395
|
+
"#FF00CC",
|
|
396
|
+
"#FF00FF",
|
|
397
|
+
"#FF3300",
|
|
398
|
+
"#FF3333",
|
|
399
|
+
"#FF3366",
|
|
400
|
+
"#FF3399",
|
|
401
|
+
"#FF33CC",
|
|
402
|
+
"#FF33FF",
|
|
403
|
+
"#FF6600",
|
|
404
|
+
"#FF6633",
|
|
405
|
+
"#FF9900",
|
|
406
|
+
"#FF9933",
|
|
407
|
+
"#FFCC00",
|
|
408
|
+
"#FFCC33"
|
|
409
|
+
];
|
|
410
|
+
function useColors() {
|
|
411
|
+
if (typeof window !== "undefined" && window.process && (window.process.type === "renderer" || window.process.__nwjs)) {
|
|
412
|
+
return true;
|
|
413
|
+
}
|
|
414
|
+
if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
|
|
415
|
+
return false;
|
|
416
|
+
}
|
|
417
|
+
return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773
|
|
418
|
+
typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31?
|
|
419
|
+
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
|
|
420
|
+
typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker
|
|
421
|
+
typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
|
|
422
|
+
}
|
|
423
|
+
function formatArgs(args2) {
|
|
424
|
+
args2[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args2[0] + (this.useColors ? "%c " : " ") + "+" + module2.exports.humanize(this.diff);
|
|
425
|
+
if (!this.useColors) {
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
const c = "color: " + this.color;
|
|
429
|
+
args2.splice(1, 0, c, "color: inherit");
|
|
430
|
+
let index = 0;
|
|
431
|
+
let lastC = 0;
|
|
432
|
+
args2[0].replace(/%[a-zA-Z%]/g, (match) => {
|
|
433
|
+
if (match === "%%") {
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
436
|
+
index++;
|
|
437
|
+
if (match === "%c") {
|
|
438
|
+
lastC = index;
|
|
439
|
+
}
|
|
440
|
+
});
|
|
441
|
+
args2.splice(lastC, 0, c);
|
|
442
|
+
}
|
|
443
|
+
exports2.log = console.debug || console.log || (() => {
|
|
444
|
+
});
|
|
445
|
+
function save(namespaces) {
|
|
446
|
+
try {
|
|
447
|
+
if (namespaces) {
|
|
448
|
+
exports2.storage.setItem("debug", namespaces);
|
|
449
|
+
} else {
|
|
450
|
+
exports2.storage.removeItem("debug");
|
|
451
|
+
}
|
|
452
|
+
} catch (error) {
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
function load() {
|
|
456
|
+
let r;
|
|
457
|
+
try {
|
|
458
|
+
r = exports2.storage.getItem("debug");
|
|
459
|
+
} catch (error) {
|
|
460
|
+
}
|
|
461
|
+
if (!r && typeof process !== "undefined" && "env" in process) {
|
|
462
|
+
r = process.env.DEBUG;
|
|
463
|
+
}
|
|
464
|
+
return r;
|
|
465
|
+
}
|
|
466
|
+
function localstorage() {
|
|
467
|
+
try {
|
|
468
|
+
return localStorage;
|
|
469
|
+
} catch (error) {
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
module2.exports = require_common()(exports2);
|
|
473
|
+
var { formatters } = module2.exports;
|
|
474
|
+
formatters.j = function(v) {
|
|
475
|
+
try {
|
|
476
|
+
return JSON.stringify(v);
|
|
477
|
+
} catch (error) {
|
|
478
|
+
return "[UnexpectedJSONParseError]: " + error.message;
|
|
479
|
+
}
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
});
|
|
483
|
+
|
|
484
|
+
// ../../node_modules/has-flag/index.js
|
|
485
|
+
var require_has_flag = __commonJS({
|
|
486
|
+
"../../node_modules/has-flag/index.js"(exports2, module2) {
|
|
487
|
+
"use strict";
|
|
488
|
+
module2.exports = (flag, argv = process.argv) => {
|
|
489
|
+
const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
|
|
490
|
+
const position = argv.indexOf(prefix + flag);
|
|
491
|
+
const terminatorPosition = argv.indexOf("--");
|
|
492
|
+
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
|
493
|
+
};
|
|
494
|
+
}
|
|
495
|
+
});
|
|
496
|
+
|
|
497
|
+
// ../../node_modules/supports-color/index.js
|
|
498
|
+
var require_supports_color = __commonJS({
|
|
499
|
+
"../../node_modules/supports-color/index.js"(exports2, module2) {
|
|
500
|
+
"use strict";
|
|
501
|
+
var os = require("os");
|
|
502
|
+
var tty = require("tty");
|
|
503
|
+
var hasFlag = require_has_flag();
|
|
504
|
+
var { env } = process;
|
|
505
|
+
var forceColor;
|
|
506
|
+
if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
|
|
507
|
+
forceColor = 0;
|
|
508
|
+
} else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
|
|
509
|
+
forceColor = 1;
|
|
510
|
+
}
|
|
511
|
+
if ("FORCE_COLOR" in env) {
|
|
512
|
+
if (env.FORCE_COLOR === "true") {
|
|
513
|
+
forceColor = 1;
|
|
514
|
+
} else if (env.FORCE_COLOR === "false") {
|
|
515
|
+
forceColor = 0;
|
|
516
|
+
} else {
|
|
517
|
+
forceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3);
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
function translateLevel(level) {
|
|
521
|
+
if (level === 0) {
|
|
522
|
+
return false;
|
|
523
|
+
}
|
|
524
|
+
return {
|
|
525
|
+
level,
|
|
526
|
+
hasBasic: true,
|
|
527
|
+
has256: level >= 2,
|
|
528
|
+
has16m: level >= 3
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
function supportsColor(haveStream, streamIsTTY) {
|
|
532
|
+
if (forceColor === 0) {
|
|
533
|
+
return 0;
|
|
534
|
+
}
|
|
535
|
+
if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
|
|
536
|
+
return 3;
|
|
537
|
+
}
|
|
538
|
+
if (hasFlag("color=256")) {
|
|
539
|
+
return 2;
|
|
540
|
+
}
|
|
541
|
+
if (haveStream && !streamIsTTY && forceColor === void 0) {
|
|
542
|
+
return 0;
|
|
543
|
+
}
|
|
544
|
+
const min = forceColor || 0;
|
|
545
|
+
if (env.TERM === "dumb") {
|
|
546
|
+
return min;
|
|
547
|
+
}
|
|
548
|
+
if (process.platform === "win32") {
|
|
549
|
+
const osRelease = os.release().split(".");
|
|
550
|
+
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
551
|
+
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
552
|
+
}
|
|
553
|
+
return 1;
|
|
554
|
+
}
|
|
555
|
+
if ("CI" in env) {
|
|
556
|
+
if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "GITHUB_ACTIONS", "BUILDKITE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
|
|
557
|
+
return 1;
|
|
558
|
+
}
|
|
559
|
+
return min;
|
|
560
|
+
}
|
|
561
|
+
if ("TEAMCITY_VERSION" in env) {
|
|
562
|
+
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
|
563
|
+
}
|
|
564
|
+
if (env.COLORTERM === "truecolor") {
|
|
565
|
+
return 3;
|
|
566
|
+
}
|
|
567
|
+
if ("TERM_PROGRAM" in env) {
|
|
568
|
+
const version = parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
|
|
569
|
+
switch (env.TERM_PROGRAM) {
|
|
570
|
+
case "iTerm.app":
|
|
571
|
+
return version >= 3 ? 3 : 2;
|
|
572
|
+
case "Apple_Terminal":
|
|
573
|
+
return 2;
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
if (/-256(color)?$/i.test(env.TERM)) {
|
|
577
|
+
return 2;
|
|
578
|
+
}
|
|
579
|
+
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
|
|
580
|
+
return 1;
|
|
581
|
+
}
|
|
582
|
+
if ("COLORTERM" in env) {
|
|
583
|
+
return 1;
|
|
584
|
+
}
|
|
585
|
+
return min;
|
|
586
|
+
}
|
|
587
|
+
function getSupportLevel(stream) {
|
|
588
|
+
const level = supportsColor(stream, stream && stream.isTTY);
|
|
589
|
+
return translateLevel(level);
|
|
590
|
+
}
|
|
591
|
+
module2.exports = {
|
|
592
|
+
supportsColor: getSupportLevel,
|
|
593
|
+
stdout: translateLevel(supportsColor(true, tty.isatty(1))),
|
|
594
|
+
stderr: translateLevel(supportsColor(true, tty.isatty(2)))
|
|
595
|
+
};
|
|
596
|
+
}
|
|
597
|
+
});
|
|
598
|
+
|
|
599
|
+
// ../../node_modules/debug/src/node.js
|
|
600
|
+
var require_node = __commonJS({
|
|
601
|
+
"../../node_modules/debug/src/node.js"(exports2, module2) {
|
|
602
|
+
"use strict";
|
|
603
|
+
var tty = require("tty");
|
|
604
|
+
var util = require("util");
|
|
605
|
+
exports2.init = init;
|
|
606
|
+
exports2.log = log;
|
|
607
|
+
exports2.formatArgs = formatArgs;
|
|
608
|
+
exports2.save = save;
|
|
609
|
+
exports2.load = load;
|
|
610
|
+
exports2.useColors = useColors;
|
|
611
|
+
exports2.destroy = util.deprecate(
|
|
612
|
+
() => {
|
|
613
|
+
},
|
|
614
|
+
"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."
|
|
615
|
+
);
|
|
616
|
+
exports2.colors = [6, 2, 3, 4, 5, 1];
|
|
617
|
+
try {
|
|
618
|
+
const supportsColor = require_supports_color();
|
|
619
|
+
if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
|
|
620
|
+
exports2.colors = [
|
|
621
|
+
20,
|
|
622
|
+
21,
|
|
623
|
+
26,
|
|
624
|
+
27,
|
|
625
|
+
32,
|
|
626
|
+
33,
|
|
627
|
+
38,
|
|
628
|
+
39,
|
|
629
|
+
40,
|
|
630
|
+
41,
|
|
631
|
+
42,
|
|
632
|
+
43,
|
|
633
|
+
44,
|
|
634
|
+
45,
|
|
635
|
+
56,
|
|
636
|
+
57,
|
|
637
|
+
62,
|
|
638
|
+
63,
|
|
639
|
+
68,
|
|
640
|
+
69,
|
|
641
|
+
74,
|
|
642
|
+
75,
|
|
643
|
+
76,
|
|
644
|
+
77,
|
|
645
|
+
78,
|
|
646
|
+
79,
|
|
647
|
+
80,
|
|
648
|
+
81,
|
|
649
|
+
92,
|
|
650
|
+
93,
|
|
651
|
+
98,
|
|
652
|
+
99,
|
|
653
|
+
112,
|
|
654
|
+
113,
|
|
655
|
+
128,
|
|
656
|
+
129,
|
|
657
|
+
134,
|
|
658
|
+
135,
|
|
659
|
+
148,
|
|
660
|
+
149,
|
|
661
|
+
160,
|
|
662
|
+
161,
|
|
663
|
+
162,
|
|
664
|
+
163,
|
|
665
|
+
164,
|
|
666
|
+
165,
|
|
667
|
+
166,
|
|
668
|
+
167,
|
|
669
|
+
168,
|
|
670
|
+
169,
|
|
671
|
+
170,
|
|
672
|
+
171,
|
|
673
|
+
172,
|
|
674
|
+
173,
|
|
675
|
+
178,
|
|
676
|
+
179,
|
|
677
|
+
184,
|
|
678
|
+
185,
|
|
679
|
+
196,
|
|
680
|
+
197,
|
|
681
|
+
198,
|
|
682
|
+
199,
|
|
683
|
+
200,
|
|
684
|
+
201,
|
|
685
|
+
202,
|
|
686
|
+
203,
|
|
687
|
+
204,
|
|
688
|
+
205,
|
|
689
|
+
206,
|
|
690
|
+
207,
|
|
691
|
+
208,
|
|
692
|
+
209,
|
|
693
|
+
214,
|
|
694
|
+
215,
|
|
695
|
+
220,
|
|
696
|
+
221
|
|
697
|
+
];
|
|
698
|
+
}
|
|
699
|
+
} catch (error) {
|
|
700
|
+
}
|
|
701
|
+
exports2.inspectOpts = Object.keys(process.env).filter((key) => {
|
|
702
|
+
return /^debug_/i.test(key);
|
|
703
|
+
}).reduce((obj, key) => {
|
|
704
|
+
const prop = key.substring(6).toLowerCase().replace(/_([a-z])/g, (_, k) => {
|
|
705
|
+
return k.toUpperCase();
|
|
706
|
+
});
|
|
707
|
+
let val = process.env[key];
|
|
708
|
+
if (/^(yes|on|true|enabled)$/i.test(val)) {
|
|
709
|
+
val = true;
|
|
710
|
+
} else if (/^(no|off|false|disabled)$/i.test(val)) {
|
|
711
|
+
val = false;
|
|
712
|
+
} else if (val === "null") {
|
|
713
|
+
val = null;
|
|
714
|
+
} else {
|
|
715
|
+
val = Number(val);
|
|
716
|
+
}
|
|
717
|
+
obj[prop] = val;
|
|
718
|
+
return obj;
|
|
719
|
+
}, {});
|
|
720
|
+
function useColors() {
|
|
721
|
+
return "colors" in exports2.inspectOpts ? Boolean(exports2.inspectOpts.colors) : tty.isatty(process.stderr.fd);
|
|
722
|
+
}
|
|
723
|
+
function formatArgs(args2) {
|
|
724
|
+
const { namespace: name, useColors: useColors2 } = this;
|
|
725
|
+
if (useColors2) {
|
|
726
|
+
const c = this.color;
|
|
727
|
+
const colorCode = "\x1B[3" + (c < 8 ? c : "8;5;" + c);
|
|
728
|
+
const prefix = ` ${colorCode};1m${name} \x1B[0m`;
|
|
729
|
+
args2[0] = prefix + args2[0].split("\n").join("\n" + prefix);
|
|
730
|
+
args2.push(colorCode + "m+" + module2.exports.humanize(this.diff) + "\x1B[0m");
|
|
731
|
+
} else {
|
|
732
|
+
args2[0] = getDate() + name + " " + args2[0];
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
function getDate() {
|
|
736
|
+
if (exports2.inspectOpts.hideDate) {
|
|
737
|
+
return "";
|
|
738
|
+
}
|
|
739
|
+
return (/* @__PURE__ */ new Date()).toISOString() + " ";
|
|
740
|
+
}
|
|
741
|
+
function log(...args2) {
|
|
742
|
+
return process.stderr.write(util.format(...args2) + "\n");
|
|
743
|
+
}
|
|
744
|
+
function save(namespaces) {
|
|
745
|
+
if (namespaces) {
|
|
746
|
+
process.env.DEBUG = namespaces;
|
|
747
|
+
} else {
|
|
748
|
+
delete process.env.DEBUG;
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
function load() {
|
|
752
|
+
return process.env.DEBUG;
|
|
753
|
+
}
|
|
754
|
+
function init(debug) {
|
|
755
|
+
debug.inspectOpts = {};
|
|
756
|
+
const keys = Object.keys(exports2.inspectOpts);
|
|
757
|
+
for (let i = 0; i < keys.length; i++) {
|
|
758
|
+
debug.inspectOpts[keys[i]] = exports2.inspectOpts[keys[i]];
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
module2.exports = require_common()(exports2);
|
|
762
|
+
var { formatters } = module2.exports;
|
|
763
|
+
formatters.o = function(v) {
|
|
764
|
+
this.inspectOpts.colors = this.useColors;
|
|
765
|
+
return util.inspect(v, this.inspectOpts).split("\n").map((str) => str.trim()).join(" ");
|
|
766
|
+
};
|
|
767
|
+
formatters.O = function(v) {
|
|
768
|
+
this.inspectOpts.colors = this.useColors;
|
|
769
|
+
return util.inspect(v, this.inspectOpts);
|
|
770
|
+
};
|
|
771
|
+
}
|
|
772
|
+
});
|
|
773
|
+
|
|
774
|
+
// ../../node_modules/debug/src/index.js
|
|
775
|
+
var require_src = __commonJS({
|
|
776
|
+
"../../node_modules/debug/src/index.js"(exports2, module2) {
|
|
777
|
+
"use strict";
|
|
778
|
+
if (typeof process === "undefined" || process.type === "renderer" || process.browser === true || process.__nwjs) {
|
|
779
|
+
module2.exports = require_browser();
|
|
780
|
+
} else {
|
|
781
|
+
module2.exports = require_node();
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
});
|
|
785
|
+
|
|
786
|
+
// ../../node_modules/eastasianwidth/eastasianwidth.js
|
|
787
|
+
var require_eastasianwidth = __commonJS({
|
|
788
|
+
"../../node_modules/eastasianwidth/eastasianwidth.js"(exports2, module2) {
|
|
789
|
+
"use strict";
|
|
790
|
+
var eaw = {};
|
|
791
|
+
if ("undefined" == typeof module2) {
|
|
792
|
+
window.eastasianwidth = eaw;
|
|
793
|
+
} else {
|
|
794
|
+
module2.exports = eaw;
|
|
795
|
+
}
|
|
796
|
+
eaw.eastAsianWidth = function(character) {
|
|
797
|
+
var x = character.charCodeAt(0);
|
|
798
|
+
var y = character.length == 2 ? character.charCodeAt(1) : 0;
|
|
799
|
+
var codePoint = x;
|
|
800
|
+
if (55296 <= x && x <= 56319 && (56320 <= y && y <= 57343)) {
|
|
801
|
+
x &= 1023;
|
|
802
|
+
y &= 1023;
|
|
803
|
+
codePoint = x << 10 | y;
|
|
804
|
+
codePoint += 65536;
|
|
805
|
+
}
|
|
806
|
+
if (12288 == codePoint || 65281 <= codePoint && codePoint <= 65376 || 65504 <= codePoint && codePoint <= 65510) {
|
|
807
|
+
return "F";
|
|
808
|
+
}
|
|
809
|
+
if (8361 == codePoint || 65377 <= codePoint && codePoint <= 65470 || 65474 <= codePoint && codePoint <= 65479 || 65482 <= codePoint && codePoint <= 65487 || 65490 <= codePoint && codePoint <= 65495 || 65498 <= codePoint && codePoint <= 65500 || 65512 <= codePoint && codePoint <= 65518) {
|
|
810
|
+
return "H";
|
|
811
|
+
}
|
|
812
|
+
if (4352 <= codePoint && codePoint <= 4447 || 4515 <= codePoint && codePoint <= 4519 || 4602 <= codePoint && codePoint <= 4607 || 9001 <= codePoint && codePoint <= 9002 || 11904 <= codePoint && codePoint <= 11929 || 11931 <= codePoint && codePoint <= 12019 || 12032 <= codePoint && codePoint <= 12245 || 12272 <= codePoint && codePoint <= 12283 || 12289 <= codePoint && codePoint <= 12350 || 12353 <= codePoint && codePoint <= 12438 || 12441 <= codePoint && codePoint <= 12543 || 12549 <= codePoint && codePoint <= 12589 || 12593 <= codePoint && codePoint <= 12686 || 12688 <= codePoint && codePoint <= 12730 || 12736 <= codePoint && codePoint <= 12771 || 12784 <= codePoint && codePoint <= 12830 || 12832 <= codePoint && codePoint <= 12871 || 12880 <= codePoint && codePoint <= 13054 || 13056 <= codePoint && codePoint <= 19903 || 19968 <= codePoint && codePoint <= 42124 || 42128 <= codePoint && codePoint <= 42182 || 43360 <= codePoint && codePoint <= 43388 || 44032 <= codePoint && codePoint <= 55203 || 55216 <= codePoint && codePoint <= 55238 || 55243 <= codePoint && codePoint <= 55291 || 63744 <= codePoint && codePoint <= 64255 || 65040 <= codePoint && codePoint <= 65049 || 65072 <= codePoint && codePoint <= 65106 || 65108 <= codePoint && codePoint <= 65126 || 65128 <= codePoint && codePoint <= 65131 || 110592 <= codePoint && codePoint <= 110593 || 127488 <= codePoint && codePoint <= 127490 || 127504 <= codePoint && codePoint <= 127546 || 127552 <= codePoint && codePoint <= 127560 || 127568 <= codePoint && codePoint <= 127569 || 131072 <= codePoint && codePoint <= 194367 || 177984 <= codePoint && codePoint <= 196605 || 196608 <= codePoint && codePoint <= 262141) {
|
|
813
|
+
return "W";
|
|
814
|
+
}
|
|
815
|
+
if (32 <= codePoint && codePoint <= 126 || 162 <= codePoint && codePoint <= 163 || 165 <= codePoint && codePoint <= 166 || 172 == codePoint || 175 == codePoint || 10214 <= codePoint && codePoint <= 10221 || 10629 <= codePoint && codePoint <= 10630) {
|
|
816
|
+
return "Na";
|
|
817
|
+
}
|
|
818
|
+
if (161 == codePoint || 164 == codePoint || 167 <= codePoint && codePoint <= 168 || 170 == codePoint || 173 <= codePoint && codePoint <= 174 || 176 <= codePoint && codePoint <= 180 || 182 <= codePoint && codePoint <= 186 || 188 <= codePoint && codePoint <= 191 || 198 == codePoint || 208 == codePoint || 215 <= codePoint && codePoint <= 216 || 222 <= codePoint && codePoint <= 225 || 230 == codePoint || 232 <= codePoint && codePoint <= 234 || 236 <= codePoint && codePoint <= 237 || 240 == codePoint || 242 <= codePoint && codePoint <= 243 || 247 <= codePoint && codePoint <= 250 || 252 == codePoint || 254 == codePoint || 257 == codePoint || 273 == codePoint || 275 == codePoint || 283 == codePoint || 294 <= codePoint && codePoint <= 295 || 299 == codePoint || 305 <= codePoint && codePoint <= 307 || 312 == codePoint || 319 <= codePoint && codePoint <= 322 || 324 == codePoint || 328 <= codePoint && codePoint <= 331 || 333 == codePoint || 338 <= codePoint && codePoint <= 339 || 358 <= codePoint && codePoint <= 359 || 363 == codePoint || 462 == codePoint || 464 == codePoint || 466 == codePoint || 468 == codePoint || 470 == codePoint || 472 == codePoint || 474 == codePoint || 476 == codePoint || 593 == codePoint || 609 == codePoint || 708 == codePoint || 711 == codePoint || 713 <= codePoint && codePoint <= 715 || 717 == codePoint || 720 == codePoint || 728 <= codePoint && codePoint <= 731 || 733 == codePoint || 735 == codePoint || 768 <= codePoint && codePoint <= 879 || 913 <= codePoint && codePoint <= 929 || 931 <= codePoint && codePoint <= 937 || 945 <= codePoint && codePoint <= 961 || 963 <= codePoint && codePoint <= 969 || 1025 == codePoint || 1040 <= codePoint && codePoint <= 1103 || 1105 == codePoint || 8208 == codePoint || 8211 <= codePoint && codePoint <= 8214 || 8216 <= codePoint && codePoint <= 8217 || 8220 <= codePoint && codePoint <= 8221 || 8224 <= codePoint && codePoint <= 8226 || 8228 <= codePoint && codePoint <= 8231 || 8240 == codePoint || 8242 <= codePoint && codePoint <= 8243 || 8245 == codePoint || 8251 == codePoint || 8254 == codePoint || 8308 == codePoint || 8319 == codePoint || 8321 <= codePoint && codePoint <= 8324 || 8364 == codePoint || 8451 == codePoint || 8453 == codePoint || 8457 == codePoint || 8467 == codePoint || 8470 == codePoint || 8481 <= codePoint && codePoint <= 8482 || 8486 == codePoint || 8491 == codePoint || 8531 <= codePoint && codePoint <= 8532 || 8539 <= codePoint && codePoint <= 8542 || 8544 <= codePoint && codePoint <= 8555 || 8560 <= codePoint && codePoint <= 8569 || 8585 == codePoint || 8592 <= codePoint && codePoint <= 8601 || 8632 <= codePoint && codePoint <= 8633 || 8658 == codePoint || 8660 == codePoint || 8679 == codePoint || 8704 == codePoint || 8706 <= codePoint && codePoint <= 8707 || 8711 <= codePoint && codePoint <= 8712 || 8715 == codePoint || 8719 == codePoint || 8721 == codePoint || 8725 == codePoint || 8730 == codePoint || 8733 <= codePoint && codePoint <= 8736 || 8739 == codePoint || 8741 == codePoint || 8743 <= codePoint && codePoint <= 8748 || 8750 == codePoint || 8756 <= codePoint && codePoint <= 8759 || 8764 <= codePoint && codePoint <= 8765 || 8776 == codePoint || 8780 == codePoint || 8786 == codePoint || 8800 <= codePoint && codePoint <= 8801 || 8804 <= codePoint && codePoint <= 8807 || 8810 <= codePoint && codePoint <= 8811 || 8814 <= codePoint && codePoint <= 8815 || 8834 <= codePoint && codePoint <= 8835 || 8838 <= codePoint && codePoint <= 8839 || 8853 == codePoint || 8857 == codePoint || 8869 == codePoint || 8895 == codePoint || 8978 == codePoint || 9312 <= codePoint && codePoint <= 9449 || 9451 <= codePoint && codePoint <= 9547 || 9552 <= codePoint && codePoint <= 9587 || 9600 <= codePoint && codePoint <= 9615 || 9618 <= codePoint && codePoint <= 9621 || 9632 <= codePoint && codePoint <= 9633 || 9635 <= codePoint && codePoint <= 9641 || 9650 <= codePoint && codePoint <= 9651 || 9654 <= codePoint && codePoint <= 9655 || 9660 <= codePoint && codePoint <= 9661 || 9664 <= codePoint && codePoint <= 9665 || 9670 <= codePoint && codePoint <= 9672 || 9675 == codePoint || 9678 <= codePoint && codePoint <= 9681 || 9698 <= codePoint && codePoint <= 9701 || 9711 == codePoint || 9733 <= codePoint && codePoint <= 9734 || 9737 == codePoint || 9742 <= codePoint && codePoint <= 9743 || 9748 <= codePoint && codePoint <= 9749 || 9756 == codePoint || 9758 == codePoint || 9792 == codePoint || 9794 == codePoint || 9824 <= codePoint && codePoint <= 9825 || 9827 <= codePoint && codePoint <= 9829 || 9831 <= codePoint && codePoint <= 9834 || 9836 <= codePoint && codePoint <= 9837 || 9839 == codePoint || 9886 <= codePoint && codePoint <= 9887 || 9918 <= codePoint && codePoint <= 9919 || 9924 <= codePoint && codePoint <= 9933 || 9935 <= codePoint && codePoint <= 9953 || 9955 == codePoint || 9960 <= codePoint && codePoint <= 9983 || 10045 == codePoint || 10071 == codePoint || 10102 <= codePoint && codePoint <= 10111 || 11093 <= codePoint && codePoint <= 11097 || 12872 <= codePoint && codePoint <= 12879 || 57344 <= codePoint && codePoint <= 63743 || 65024 <= codePoint && codePoint <= 65039 || 65533 == codePoint || 127232 <= codePoint && codePoint <= 127242 || 127248 <= codePoint && codePoint <= 127277 || 127280 <= codePoint && codePoint <= 127337 || 127344 <= codePoint && codePoint <= 127386 || 917760 <= codePoint && codePoint <= 917999 || 983040 <= codePoint && codePoint <= 1048573 || 1048576 <= codePoint && codePoint <= 1114109) {
|
|
819
|
+
return "A";
|
|
820
|
+
}
|
|
821
|
+
return "N";
|
|
822
|
+
};
|
|
823
|
+
eaw.characterLength = function(character) {
|
|
824
|
+
var code = this.eastAsianWidth(character);
|
|
825
|
+
if (code == "F" || code == "W" || code == "A") {
|
|
826
|
+
return 2;
|
|
827
|
+
} else {
|
|
828
|
+
return 1;
|
|
829
|
+
}
|
|
830
|
+
};
|
|
831
|
+
function stringToArray(string) {
|
|
832
|
+
return string.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g) || [];
|
|
833
|
+
}
|
|
834
|
+
eaw.length = function(string) {
|
|
835
|
+
var characters = stringToArray(string);
|
|
836
|
+
var len = 0;
|
|
837
|
+
for (var i = 0; i < characters.length; i++) {
|
|
838
|
+
len = len + this.characterLength(characters[i]);
|
|
839
|
+
}
|
|
840
|
+
return len;
|
|
841
|
+
};
|
|
842
|
+
eaw.slice = function(text, start, end) {
|
|
843
|
+
textLen = eaw.length(text);
|
|
844
|
+
start = start ? start : 0;
|
|
845
|
+
end = end ? end : 1;
|
|
846
|
+
if (start < 0) {
|
|
847
|
+
start = textLen + start;
|
|
848
|
+
}
|
|
849
|
+
if (end < 0) {
|
|
850
|
+
end = textLen + end;
|
|
851
|
+
}
|
|
852
|
+
var result = "";
|
|
853
|
+
var eawLen = 0;
|
|
854
|
+
var chars = stringToArray(text);
|
|
855
|
+
for (var i = 0; i < chars.length; i++) {
|
|
856
|
+
var char = chars[i];
|
|
857
|
+
var charLen = eaw.length(char);
|
|
858
|
+
if (eawLen >= start - (charLen == 2 ? 1 : 0)) {
|
|
859
|
+
if (eawLen + charLen <= end) {
|
|
860
|
+
result += char;
|
|
861
|
+
} else {
|
|
862
|
+
break;
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
eawLen += charLen;
|
|
866
|
+
}
|
|
867
|
+
return result;
|
|
868
|
+
};
|
|
869
|
+
}
|
|
870
|
+
});
|
|
871
|
+
|
|
872
|
+
// ../../node_modules/list-it/lib/data-cell.js
|
|
873
|
+
var require_data_cell = __commonJS({
|
|
874
|
+
"../../node_modules/list-it/lib/data-cell.js"(exports2, module2) {
|
|
875
|
+
"use strict";
|
|
876
|
+
var eaw = require_eastasianwidth();
|
|
877
|
+
function DataCell() {
|
|
878
|
+
this.data = "";
|
|
879
|
+
}
|
|
880
|
+
module2.exports = DataCell;
|
|
881
|
+
DataCell.prototype.getData = function() {
|
|
882
|
+
return this.data;
|
|
883
|
+
};
|
|
884
|
+
DataCell.prototype.setData = function(data) {
|
|
885
|
+
this.data = data;
|
|
886
|
+
};
|
|
887
|
+
DataCell.prototype.visibleLength = function() {
|
|
888
|
+
if (typeof this.data != "string") {
|
|
889
|
+
return ("" + this.data).length;
|
|
890
|
+
}
|
|
891
|
+
return DataCell.visibleLength(this.data);
|
|
892
|
+
};
|
|
893
|
+
DataCell.visibleLength = function(data) {
|
|
894
|
+
const s = data.replace(/\x1b[^m]*m/g, "");
|
|
895
|
+
return eaw.length(s);
|
|
896
|
+
};
|
|
897
|
+
}
|
|
898
|
+
});
|
|
899
|
+
|
|
900
|
+
// ../../node_modules/list-it/lib/row.js
|
|
901
|
+
var require_row = __commonJS({
|
|
902
|
+
"../../node_modules/list-it/lib/row.js"(exports2, module2) {
|
|
903
|
+
"use strict";
|
|
904
|
+
function Row() {
|
|
905
|
+
this.cells = [];
|
|
906
|
+
this.empty = true;
|
|
907
|
+
this.fixed = false;
|
|
908
|
+
}
|
|
909
|
+
module2.exports = Row;
|
|
910
|
+
Row.prototype.getCellLength = function() {
|
|
911
|
+
return this.cells.length;
|
|
912
|
+
};
|
|
913
|
+
Row.prototype.getCell = function(idx) {
|
|
914
|
+
return this.cells[idx];
|
|
915
|
+
};
|
|
916
|
+
Row.prototype.pushCell = function(cell) {
|
|
917
|
+
if (this.isFixed()) {
|
|
918
|
+
throw "pushCell Fail, The row was already fixed.";
|
|
919
|
+
}
|
|
920
|
+
this.empty = false;
|
|
921
|
+
return this.cells.push(cell);
|
|
922
|
+
};
|
|
923
|
+
Row.prototype.fix = function() {
|
|
924
|
+
this.fixed = true;
|
|
925
|
+
};
|
|
926
|
+
Row.prototype.isEmpty = function() {
|
|
927
|
+
return this.empty;
|
|
928
|
+
};
|
|
929
|
+
Row.prototype.isFixed = function() {
|
|
930
|
+
return this.fixed;
|
|
931
|
+
};
|
|
932
|
+
}
|
|
933
|
+
});
|
|
934
|
+
|
|
935
|
+
// ../../node_modules/list-it/lib/column.js
|
|
936
|
+
var require_column = __commonJS({
|
|
937
|
+
"../../node_modules/list-it/lib/column.js"(exports2, module2) {
|
|
938
|
+
"use strict";
|
|
939
|
+
var DataCell = require_data_cell();
|
|
940
|
+
function Column() {
|
|
941
|
+
this.opt = {
|
|
942
|
+
"autoAlign": false
|
|
943
|
+
};
|
|
944
|
+
this.width = 0;
|
|
945
|
+
this.textWidth = null;
|
|
946
|
+
this.intLen = 0;
|
|
947
|
+
this.fracLen = 0;
|
|
948
|
+
this.expLen = 0;
|
|
949
|
+
this.cellAtRow = {};
|
|
950
|
+
this.header = null;
|
|
951
|
+
}
|
|
952
|
+
module2.exports = Column;
|
|
953
|
+
Column.prototype.getWidth = function() {
|
|
954
|
+
return this.width;
|
|
955
|
+
};
|
|
956
|
+
Column.prototype.setTextWidth = function(textWidth) {
|
|
957
|
+
this.textWidth = textWidth;
|
|
958
|
+
};
|
|
959
|
+
Column.prototype.setCellAt = function(row, cell) {
|
|
960
|
+
this.cellAtRow[row] = cell;
|
|
961
|
+
};
|
|
962
|
+
Column.prototype.setHeader = function(header) {
|
|
963
|
+
this.header = header;
|
|
964
|
+
};
|
|
965
|
+
Column.prototype.hasHeader = function() {
|
|
966
|
+
return this.header != null;
|
|
967
|
+
};
|
|
968
|
+
Column.prototype.updateWidth = function() {
|
|
969
|
+
const headerWidth = !this.hasHeader() ? 0 : DataCell.visibleLength("" + this.header);
|
|
970
|
+
this.width = headerWidth;
|
|
971
|
+
Object.keys(this.cellAtRow).forEach((key) => {
|
|
972
|
+
const cell = this.cellAtRow[key];
|
|
973
|
+
const data = cell.getData();
|
|
974
|
+
let width = cell.visibleLength();
|
|
975
|
+
if (typeof data == "number") {
|
|
976
|
+
if (this.opt.autoAlign) {
|
|
977
|
+
this.updateNumWidth(data);
|
|
978
|
+
width = this.getNumMaxWidth();
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
if (width > this.width) {
|
|
982
|
+
this.width = width;
|
|
983
|
+
}
|
|
984
|
+
if (typeof data == "string") {
|
|
985
|
+
if (this.textWidth && this.textWidth > headerWidth) {
|
|
986
|
+
if (this.width > this.textWidth) {
|
|
987
|
+
this.width = this.textWidth;
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
});
|
|
992
|
+
};
|
|
993
|
+
Column.prototype.formatColumnHeader = function() {
|
|
994
|
+
if (!this.hasHeader()) {
|
|
995
|
+
return null;
|
|
996
|
+
}
|
|
997
|
+
const width = this.getWidth();
|
|
998
|
+
const header = this.header;
|
|
999
|
+
const headerWidth = DataCell.visibleLength("" + header);
|
|
1000
|
+
if (header.length == headerWidth && width - headerWidth <= 0) {
|
|
1001
|
+
return ("" + header).substring(0, width);
|
|
1002
|
+
}
|
|
1003
|
+
return "" + header + " ".repeat(width - headerWidth);
|
|
1004
|
+
};
|
|
1005
|
+
Column.prototype.formatCell = function(data) {
|
|
1006
|
+
const width = this.getWidth();
|
|
1007
|
+
if (this.opt.autoAlign) {
|
|
1008
|
+
if (typeof data == "number") {
|
|
1009
|
+
return this.makeAutoAlignNum(data).padStart(width, " ");
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
const dataWidth = DataCell.visibleLength("" + data);
|
|
1013
|
+
if (data.length == dataWidth && width - dataWidth <= 0) {
|
|
1014
|
+
return ("" + data).substring(0, width);
|
|
1015
|
+
}
|
|
1016
|
+
return "" + data + " ".repeat(width - dataWidth);
|
|
1017
|
+
};
|
|
1018
|
+
Column.prototype.setAutoAlign = function(autoAlign) {
|
|
1019
|
+
this.opt.autoAlign = autoAlign;
|
|
1020
|
+
};
|
|
1021
|
+
Column.prototype.updateNumWidth = function(num) {
|
|
1022
|
+
const numInfo = this.analyzeNumber(num);
|
|
1023
|
+
const intLen = numInfo.intStr.length;
|
|
1024
|
+
const fracLen = numInfo.fracStr.length;
|
|
1025
|
+
const expLen = numInfo.expStr.length;
|
|
1026
|
+
if (intLen > this.intLen) {
|
|
1027
|
+
this.intLen = intLen;
|
|
1028
|
+
}
|
|
1029
|
+
if (fracLen > this.fracLen) {
|
|
1030
|
+
this.fracLen = fracLen;
|
|
1031
|
+
}
|
|
1032
|
+
if (expLen > this.expLen) {
|
|
1033
|
+
this.expLen = expLen;
|
|
1034
|
+
}
|
|
1035
|
+
};
|
|
1036
|
+
Column.prototype.getNumMaxWidth = function() {
|
|
1037
|
+
return this.intLen + this.fracLen + (this.fracLen > 0 ? 1 : 0) + this.expLen + (this.expLen > 0 ? 1 : 0);
|
|
1038
|
+
};
|
|
1039
|
+
Column.prototype.makeAutoAlignNum = function(num) {
|
|
1040
|
+
const numInfo = this.analyzeNumber(num);
|
|
1041
|
+
const intStr = numInfo.intStr.padStart(this.intLen, " ");
|
|
1042
|
+
const fracStr = numInfo.expStr != "" ? numInfo.fracStr.padEnd(this.fracLen, "0") : numInfo.fracStr.padEnd(this.fracLen, " ");
|
|
1043
|
+
const expStr = numInfo.expStr.padEnd(this.expLen, " ");
|
|
1044
|
+
if (numInfo.expStr != "") {
|
|
1045
|
+
return [intStr, ".", fracStr, "e", expStr].join("");
|
|
1046
|
+
}
|
|
1047
|
+
if (numInfo.pointPos >= 0) {
|
|
1048
|
+
if (this.expLen > 0) {
|
|
1049
|
+
return [intStr, ".", fracStr, " ", expStr].join("");
|
|
1050
|
+
}
|
|
1051
|
+
return [intStr, ".", fracStr].join("");
|
|
1052
|
+
} else if (this.fracLen == 0) {
|
|
1053
|
+
return intStr;
|
|
1054
|
+
}
|
|
1055
|
+
if (this.expLen > 0) {
|
|
1056
|
+
return [intStr, ".0", fracStr.substr(1), " ", expStr].join("");
|
|
1057
|
+
}
|
|
1058
|
+
return [intStr, ".0", fracStr.substr(1)].join("");
|
|
1059
|
+
};
|
|
1060
|
+
Column.prototype.analyzeNumber = function(num) {
|
|
1061
|
+
const s = "" + num;
|
|
1062
|
+
let intStr = "";
|
|
1063
|
+
let fracStr = "";
|
|
1064
|
+
const pointPos = s.indexOf(".");
|
|
1065
|
+
const expIndex = s.indexOf("e");
|
|
1066
|
+
if (expIndex >= 0) {
|
|
1067
|
+
if (pointPos < 0) {
|
|
1068
|
+
return {
|
|
1069
|
+
pointPos: expIndex,
|
|
1070
|
+
intStr: s.substr(0, expIndex),
|
|
1071
|
+
fracStr: "0",
|
|
1072
|
+
expStr: s.substr(expIndex + 1)
|
|
1073
|
+
};
|
|
1074
|
+
}
|
|
1075
|
+
return {
|
|
1076
|
+
pointPos,
|
|
1077
|
+
intStr: s.substr(0, pointPos),
|
|
1078
|
+
fracStr: s.substring(pointPos + 1, expIndex),
|
|
1079
|
+
expStr: s.substr(expIndex + 1)
|
|
1080
|
+
};
|
|
1081
|
+
}
|
|
1082
|
+
if (pointPos < 0) {
|
|
1083
|
+
intStr = s;
|
|
1084
|
+
} else {
|
|
1085
|
+
intStr = s.substr(0, pointPos);
|
|
1086
|
+
fracStr = s.substr(pointPos + 1);
|
|
1087
|
+
}
|
|
1088
|
+
return {
|
|
1089
|
+
"pointPos": pointPos,
|
|
1090
|
+
"intStr": intStr,
|
|
1091
|
+
"fracStr": fracStr,
|
|
1092
|
+
"expStr": ""
|
|
1093
|
+
};
|
|
1094
|
+
};
|
|
1095
|
+
}
|
|
1096
|
+
});
|
|
1097
|
+
|
|
1098
|
+
// ../../node_modules/ansi-escape-sequences/dist/index.cjs
|
|
1099
|
+
var require_dist = __commonJS({
|
|
1100
|
+
"../../node_modules/ansi-escape-sequences/dist/index.cjs"(exports2, module2) {
|
|
1101
|
+
"use strict";
|
|
1102
|
+
function isObject(input) {
|
|
1103
|
+
return typeof input === "object" && input !== null;
|
|
1104
|
+
}
|
|
1105
|
+
function isArrayLike(input) {
|
|
1106
|
+
return isObject(input) && typeof input.length === "number";
|
|
1107
|
+
}
|
|
1108
|
+
function arrayify(input) {
|
|
1109
|
+
if (Array.isArray(input)) {
|
|
1110
|
+
return input;
|
|
1111
|
+
} else if (input === void 0) {
|
|
1112
|
+
return [];
|
|
1113
|
+
} else if (isArrayLike(input) || input instanceof Set) {
|
|
1114
|
+
return Array.from(input);
|
|
1115
|
+
} else {
|
|
1116
|
+
return [input];
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
var csi = "\x1B[";
|
|
1120
|
+
var ansi = {};
|
|
1121
|
+
ansi.style = {
|
|
1122
|
+
reset: "\x1B[0m",
|
|
1123
|
+
bold: "\x1B[1m",
|
|
1124
|
+
italic: "\x1B[3m",
|
|
1125
|
+
underline: "\x1B[4m",
|
|
1126
|
+
fontDefault: "\x1B[10m",
|
|
1127
|
+
font2: "\x1B[11m",
|
|
1128
|
+
font3: "\x1B[12m",
|
|
1129
|
+
font4: "\x1B[13m",
|
|
1130
|
+
font5: "\x1B[14m",
|
|
1131
|
+
font6: "\x1B[15m",
|
|
1132
|
+
imageNegative: "\x1B[7m",
|
|
1133
|
+
imagePositive: "\x1B[27m",
|
|
1134
|
+
black: "\x1B[30m",
|
|
1135
|
+
red: "\x1B[31m",
|
|
1136
|
+
green: "\x1B[32m",
|
|
1137
|
+
yellow: "\x1B[33m",
|
|
1138
|
+
blue: "\x1B[34m",
|
|
1139
|
+
magenta: "\x1B[35m",
|
|
1140
|
+
cyan: "\x1B[36m",
|
|
1141
|
+
white: "\x1B[37m",
|
|
1142
|
+
grey: "\x1B[90m",
|
|
1143
|
+
gray: "\x1B[90m",
|
|
1144
|
+
brightRed: "\x1B[91m",
|
|
1145
|
+
brightGreen: "\x1B[92m",
|
|
1146
|
+
brightYellow: "\x1B[93m",
|
|
1147
|
+
brightBlue: "\x1B[94m",
|
|
1148
|
+
brightMagenta: "\x1B[95m",
|
|
1149
|
+
brightCyan: "\x1B[96m",
|
|
1150
|
+
brightWhite: "\x1B[97m",
|
|
1151
|
+
"bg-black": "\x1B[40m",
|
|
1152
|
+
"bg-red": "\x1B[41m",
|
|
1153
|
+
"bg-green": "\x1B[42m",
|
|
1154
|
+
"bg-yellow": "\x1B[43m",
|
|
1155
|
+
"bg-blue": "\x1B[44m",
|
|
1156
|
+
"bg-magenta": "\x1B[45m",
|
|
1157
|
+
"bg-cyan": "\x1B[46m",
|
|
1158
|
+
"bg-white": "\x1B[47m",
|
|
1159
|
+
"bg-grey": "\x1B[100m",
|
|
1160
|
+
"bg-gray": "\x1B[100m",
|
|
1161
|
+
"bg-brightRed": "\x1B[101m",
|
|
1162
|
+
"bg-brightGreen": "\x1B[102m",
|
|
1163
|
+
"bg-brightYellow": "\x1B[103m",
|
|
1164
|
+
"bg-brightBlue": "\x1B[104m",
|
|
1165
|
+
"bg-brightMagenta": "\x1B[105m",
|
|
1166
|
+
"bg-brightCyan": "\x1B[106m",
|
|
1167
|
+
"bg-brightWhite": "\x1B[107m"
|
|
1168
|
+
};
|
|
1169
|
+
ansi.rgb = function(r, g, b) {
|
|
1170
|
+
return `\x1B[38;2;${r};${g};${b}m`;
|
|
1171
|
+
};
|
|
1172
|
+
ansi.bgRgb = function(r, g, b) {
|
|
1173
|
+
return `\x1B[48;2;${r};${g};${b}m`;
|
|
1174
|
+
};
|
|
1175
|
+
ansi.styles = function(styles) {
|
|
1176
|
+
styles = arrayify(styles);
|
|
1177
|
+
return styles.map(function(effect) {
|
|
1178
|
+
const rgbMatches = effect.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);
|
|
1179
|
+
const bgRgbMatches = effect.match(/bg-rgb\((\d+),\s*(\d+),\s*(\d+)\)/);
|
|
1180
|
+
if (bgRgbMatches) {
|
|
1181
|
+
const [full, r, g, b] = bgRgbMatches;
|
|
1182
|
+
return ansi.bgRgb(r, g, b);
|
|
1183
|
+
} else if (rgbMatches) {
|
|
1184
|
+
const [full, r, g, b] = rgbMatches;
|
|
1185
|
+
return ansi.rgb(r, g, b);
|
|
1186
|
+
} else {
|
|
1187
|
+
return ansi.style[effect];
|
|
1188
|
+
}
|
|
1189
|
+
}).join("");
|
|
1190
|
+
};
|
|
1191
|
+
ansi.format = function(str, styleArray) {
|
|
1192
|
+
const re = /\[([\w\s-\(\),]+)\]{([^]*?)}/;
|
|
1193
|
+
let matches;
|
|
1194
|
+
str = String(str);
|
|
1195
|
+
if (!str) return "";
|
|
1196
|
+
while (matches = str.match(re)) {
|
|
1197
|
+
const inlineStyles = matches[1].split(/\s+/);
|
|
1198
|
+
const inlineString = matches[2];
|
|
1199
|
+
str = str.replace(matches[0], ansi.format(inlineString, inlineStyles));
|
|
1200
|
+
}
|
|
1201
|
+
return styleArray && styleArray.length ? ansi.styles(styleArray) + str + ansi.style.reset : str;
|
|
1202
|
+
};
|
|
1203
|
+
ansi.cursor = {
|
|
1204
|
+
/**
|
|
1205
|
+
* Moves the cursor `lines` cells up. If the cursor is already at the edge of the screen, this has no effect
|
|
1206
|
+
* @param [lines=1] {number}
|
|
1207
|
+
* @return {string}
|
|
1208
|
+
*/
|
|
1209
|
+
up: function(lines) {
|
|
1210
|
+
return csi + (lines || 1) + "A";
|
|
1211
|
+
},
|
|
1212
|
+
/**
|
|
1213
|
+
* Moves the cursor `lines` cells down. If the cursor is already at the edge of the screen, this has no effect
|
|
1214
|
+
* @param [lines=1] {number}
|
|
1215
|
+
* @return {string}
|
|
1216
|
+
*/
|
|
1217
|
+
down: function(lines) {
|
|
1218
|
+
return csi + (lines || 1) + "B";
|
|
1219
|
+
},
|
|
1220
|
+
/**
|
|
1221
|
+
* Moves the cursor `lines` cells forward. If the cursor is already at the edge of the screen, this has no effect
|
|
1222
|
+
* @param [lines=1] {number}
|
|
1223
|
+
* @return {string}
|
|
1224
|
+
*/
|
|
1225
|
+
forward: function(lines) {
|
|
1226
|
+
return csi + (lines || 1) + "C";
|
|
1227
|
+
},
|
|
1228
|
+
/**
|
|
1229
|
+
* Moves the cursor `lines` cells back. If the cursor is already at the edge of the screen, this has no effect
|
|
1230
|
+
* @param [lines=1] {number}
|
|
1231
|
+
* @return {string}
|
|
1232
|
+
*/
|
|
1233
|
+
back: function(lines) {
|
|
1234
|
+
return csi + (lines || 1) + "D";
|
|
1235
|
+
},
|
|
1236
|
+
/**
|
|
1237
|
+
* Moves cursor to beginning of the line n lines down.
|
|
1238
|
+
* @param [lines=1] {number}
|
|
1239
|
+
* @return {string}
|
|
1240
|
+
*/
|
|
1241
|
+
nextLine: function(lines) {
|
|
1242
|
+
return csi + (lines || 1) + "E";
|
|
1243
|
+
},
|
|
1244
|
+
/**
|
|
1245
|
+
* Moves cursor to beginning of the line n lines up.
|
|
1246
|
+
* @param [lines=1] {number}
|
|
1247
|
+
* @return {string}
|
|
1248
|
+
*/
|
|
1249
|
+
previousLine: function(lines) {
|
|
1250
|
+
return csi + (lines || 1) + "F";
|
|
1251
|
+
},
|
|
1252
|
+
/**
|
|
1253
|
+
* Moves the cursor to column n.
|
|
1254
|
+
* @param n {number} - column number
|
|
1255
|
+
* @return {string}
|
|
1256
|
+
*/
|
|
1257
|
+
horizontalAbsolute: function(n) {
|
|
1258
|
+
return csi + n + "G";
|
|
1259
|
+
},
|
|
1260
|
+
/**
|
|
1261
|
+
* Moves the cursor to row n, column m. The values are 1-based, and default to 1 (top left corner) if omitted.
|
|
1262
|
+
* @param n {number} - row number
|
|
1263
|
+
* @param m {number} - column number
|
|
1264
|
+
* @return {string}
|
|
1265
|
+
*/
|
|
1266
|
+
position: function(n, m) {
|
|
1267
|
+
return csi + (n || 1) + ";" + (m || 1) + "H";
|
|
1268
|
+
},
|
|
1269
|
+
/**
|
|
1270
|
+
* Hides the cursor
|
|
1271
|
+
*/
|
|
1272
|
+
hide: csi + "?25l",
|
|
1273
|
+
/**
|
|
1274
|
+
* Shows the cursor
|
|
1275
|
+
*/
|
|
1276
|
+
show: csi + "?25h"
|
|
1277
|
+
};
|
|
1278
|
+
ansi.erase = {
|
|
1279
|
+
/**
|
|
1280
|
+
* Clears part of the screen. If n is 0 (or missing), clear from cursor to end of screen. If n is 1, clear from cursor to beginning of the screen. If n is 2, clear entire screen.
|
|
1281
|
+
* @param n {number}
|
|
1282
|
+
* @return {string}
|
|
1283
|
+
*/
|
|
1284
|
+
display: function(n) {
|
|
1285
|
+
return csi + (n || 0) + "J";
|
|
1286
|
+
},
|
|
1287
|
+
/**
|
|
1288
|
+
* Erases part of the line. If n is zero (or missing), clear from cursor to the end of the line. If n is one, clear from cursor to beginning of the line. If n is two, clear entire line. Cursor position does not change.
|
|
1289
|
+
* @param n {number}
|
|
1290
|
+
* @return {string}
|
|
1291
|
+
*/
|
|
1292
|
+
inLine: function(n) {
|
|
1293
|
+
return csi + (n || 0) + "K";
|
|
1294
|
+
}
|
|
1295
|
+
};
|
|
1296
|
+
module2.exports = ansi;
|
|
1297
|
+
}
|
|
1298
|
+
});
|
|
1299
|
+
|
|
1300
|
+
// ../../node_modules/list-it/lib/list-it-buffer.js
|
|
1301
|
+
var require_list_it_buffer = __commonJS({
|
|
1302
|
+
"../../node_modules/list-it/lib/list-it-buffer.js"(exports2, module2) {
|
|
1303
|
+
"use strict";
|
|
1304
|
+
var debug = require_src()("list-it-buffer");
|
|
1305
|
+
var DataCell = require_data_cell();
|
|
1306
|
+
var Row = require_row();
|
|
1307
|
+
var Column = require_column();
|
|
1308
|
+
var ansi = require_dist();
|
|
1309
|
+
function ListItBuffer(opt) {
|
|
1310
|
+
opt = opt || {};
|
|
1311
|
+
this.opt = {
|
|
1312
|
+
"autoAlign": true,
|
|
1313
|
+
"columnWidth": null,
|
|
1314
|
+
"header": null,
|
|
1315
|
+
"headerBold": false,
|
|
1316
|
+
"headerColor": "",
|
|
1317
|
+
"headerUnderline": false
|
|
1318
|
+
};
|
|
1319
|
+
if (opt.header != null && !Array.isArray(opt.header)) {
|
|
1320
|
+
throw new Error([
|
|
1321
|
+
`Invalid header was specified. It must be an array, but (${JSON.stringify(opt.header)}):${typeof opt.header} was specified.`
|
|
1322
|
+
].join(" "));
|
|
1323
|
+
}
|
|
1324
|
+
if (opt.headerColor && !(opt.headerColor in COLORS)) {
|
|
1325
|
+
throw new Error([
|
|
1326
|
+
`Invalid color ${JSON.stringify(opt.headerColor)} was specified.`,
|
|
1327
|
+
"Available color names:",
|
|
1328
|
+
...AVAILABLE_COLORS.map((color) => `* ${JSON.stringify(color)}`)
|
|
1329
|
+
].join("\n"));
|
|
1330
|
+
}
|
|
1331
|
+
Object.keys(this.opt).forEach((key) => {
|
|
1332
|
+
if (key in opt) {
|
|
1333
|
+
this.opt[key] = opt[key];
|
|
1334
|
+
}
|
|
1335
|
+
});
|
|
1336
|
+
this.lines = [];
|
|
1337
|
+
this.columns = [];
|
|
1338
|
+
this.columnWidth = this.opt.columnWidth;
|
|
1339
|
+
if (this.opt.header) {
|
|
1340
|
+
this.setHeaderRow(this.opt.header);
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1343
|
+
module2.exports = ListItBuffer;
|
|
1344
|
+
ListItBuffer.prototype.nl = function() {
|
|
1345
|
+
const lastRowIndex = this.lines.length - 1;
|
|
1346
|
+
if (lastRowIndex >= 0 && !this.lines[lastRowIndex].isFixed()) {
|
|
1347
|
+
this.lines[lastRowIndex].fix();
|
|
1348
|
+
}
|
|
1349
|
+
this.pushNewRow();
|
|
1350
|
+
return this;
|
|
1351
|
+
};
|
|
1352
|
+
ListItBuffer.prototype.d = function(data) {
|
|
1353
|
+
if (arguments.length > 1) {
|
|
1354
|
+
const array = Array.apply(null, arguments);
|
|
1355
|
+
if (ListItBuffer.isMultiDimensionalArray(array)) {
|
|
1356
|
+
array.forEach((row) => this.addRow(row));
|
|
1357
|
+
} else {
|
|
1358
|
+
array.forEach((data2) => this.d(data2));
|
|
1359
|
+
}
|
|
1360
|
+
return this;
|
|
1361
|
+
}
|
|
1362
|
+
if (Array.isArray(data)) {
|
|
1363
|
+
if (ListItBuffer.isMultiDimensionalArray(data)) {
|
|
1364
|
+
data.forEach((row) => this.addRow(row));
|
|
1365
|
+
} else if (ListItBuffer.isObjectArray(data)) {
|
|
1366
|
+
data = objectArrayToTable(data);
|
|
1367
|
+
if (!this.header && (this.opt.headerBold || this.opt.headerColor || this.opt.headerUnderline)) {
|
|
1368
|
+
this.setHeaderRow(data.shift());
|
|
1369
|
+
}
|
|
1370
|
+
data.forEach((row) => this.addRow(row));
|
|
1371
|
+
} else {
|
|
1372
|
+
this.addRow(data);
|
|
1373
|
+
}
|
|
1374
|
+
return this;
|
|
1375
|
+
}
|
|
1376
|
+
const rowidx = this.lines.length - 1;
|
|
1377
|
+
if (rowidx < 0 || this.lines[rowidx].isFixed()) {
|
|
1378
|
+
this.pushNewRow();
|
|
1379
|
+
}
|
|
1380
|
+
const cell = new DataCell();
|
|
1381
|
+
cell.setData(data);
|
|
1382
|
+
const iRow = this.lines.length - 1;
|
|
1383
|
+
let iCol = this.lines[iRow].getCellLength();
|
|
1384
|
+
if (iCol >= this.columns.length) {
|
|
1385
|
+
this.addColumn();
|
|
1386
|
+
}
|
|
1387
|
+
this.columns[iCol].setCellAt(iRow, cell);
|
|
1388
|
+
this.lines[iRow].pushCell(cell);
|
|
1389
|
+
return this;
|
|
1390
|
+
};
|
|
1391
|
+
ListItBuffer.isMultiDimensionalArray = function(arr) {
|
|
1392
|
+
if (!Array.isArray(arr)) {
|
|
1393
|
+
throw Error("The parameter arr must be array");
|
|
1394
|
+
}
|
|
1395
|
+
for (let element of arr) {
|
|
1396
|
+
if (!Array.isArray(element)) {
|
|
1397
|
+
return false;
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1400
|
+
return true;
|
|
1401
|
+
};
|
|
1402
|
+
ListItBuffer.isObjectArray = function(arr) {
|
|
1403
|
+
if (!Array.isArray(arr)) {
|
|
1404
|
+
throw Error("The parameter arr must be array");
|
|
1405
|
+
}
|
|
1406
|
+
const ctor = arr[0].constructor;
|
|
1407
|
+
for (let element of arr) {
|
|
1408
|
+
if (typeof element != "object") {
|
|
1409
|
+
return false;
|
|
1410
|
+
} else {
|
|
1411
|
+
if (element.constructor.name != ctor.name) {
|
|
1412
|
+
return false;
|
|
1413
|
+
}
|
|
1414
|
+
}
|
|
1415
|
+
}
|
|
1416
|
+
return true;
|
|
1417
|
+
};
|
|
1418
|
+
ListItBuffer.prototype.addRow = function(row) {
|
|
1419
|
+
row.forEach((col) => {
|
|
1420
|
+
switch (typeof col) {
|
|
1421
|
+
case "string":
|
|
1422
|
+
case "number":
|
|
1423
|
+
this.d(col);
|
|
1424
|
+
break;
|
|
1425
|
+
default:
|
|
1426
|
+
this.d(col != null ? col.toString() : "(null)");
|
|
1427
|
+
break;
|
|
1428
|
+
}
|
|
1429
|
+
});
|
|
1430
|
+
this.nl();
|
|
1431
|
+
};
|
|
1432
|
+
ListItBuffer.prototype.pushNewRow = function() {
|
|
1433
|
+
this.lines.push(new Row());
|
|
1434
|
+
};
|
|
1435
|
+
ListItBuffer.prototype.toString = function() {
|
|
1436
|
+
const rows = [];
|
|
1437
|
+
this.columns.forEach((column, iCol) => {
|
|
1438
|
+
if (this.header != null) {
|
|
1439
|
+
column.setHeader(this.header[iCol] || "");
|
|
1440
|
+
}
|
|
1441
|
+
column.setTextWidth(this.getColumnWidth(iCol));
|
|
1442
|
+
column.updateWidth();
|
|
1443
|
+
});
|
|
1444
|
+
if (this.header != null) {
|
|
1445
|
+
const headerLine = this.applyHeaderStyleOption(
|
|
1446
|
+
this.columns.map((column) => column.formatColumnHeader()).join(" ")
|
|
1447
|
+
);
|
|
1448
|
+
rows.push(headerLine);
|
|
1449
|
+
const headerUnderline = this.generateHeaderUnderline();
|
|
1450
|
+
if (headerUnderline) {
|
|
1451
|
+
rows.push(headerUnderline);
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
this.lines.forEach((line) => {
|
|
1455
|
+
if (line.isFixed() || !line.isEmpty()) {
|
|
1456
|
+
if (line.isEmpty()) {
|
|
1457
|
+
rows.push("\n");
|
|
1458
|
+
} else {
|
|
1459
|
+
rows.push(this.columns.map((column, iCol) => {
|
|
1460
|
+
const cell = line.getCell(iCol);
|
|
1461
|
+
const data = cell.getData();
|
|
1462
|
+
return column.formatCell(data);
|
|
1463
|
+
}).join(" "));
|
|
1464
|
+
}
|
|
1465
|
+
}
|
|
1466
|
+
});
|
|
1467
|
+
return rows.join("\n");
|
|
1468
|
+
};
|
|
1469
|
+
var COLORS = {};
|
|
1470
|
+
var BGCOLORS = {};
|
|
1471
|
+
Object.keys(ansi.style).forEach((key) => {
|
|
1472
|
+
const value = ansi.style[key];
|
|
1473
|
+
if (/^bg-/.test(key)) {
|
|
1474
|
+
BGCOLORS[key.substr(3)] = value;
|
|
1475
|
+
} else {
|
|
1476
|
+
COLORS[key] = value;
|
|
1477
|
+
debug(`COLOR-KEY: ${key}`);
|
|
1478
|
+
}
|
|
1479
|
+
});
|
|
1480
|
+
Object.keys(COLORS).forEach((key) => {
|
|
1481
|
+
if (!(key in BGCOLORS)) {
|
|
1482
|
+
delete COLORS[key];
|
|
1483
|
+
debug(`remove COLOR-KEY: ${key}`);
|
|
1484
|
+
}
|
|
1485
|
+
});
|
|
1486
|
+
var AVAILABLE_COLORS = Object.keys(COLORS);
|
|
1487
|
+
debug(`AVAILABLE_COLORS:${JSON.stringify(AVAILABLE_COLORS)}`);
|
|
1488
|
+
ListItBuffer.prototype.applyHeaderStyleOption = function(line) {
|
|
1489
|
+
if (!this.opt.headerBold && !this.opt.headerColor) {
|
|
1490
|
+
return line;
|
|
1491
|
+
}
|
|
1492
|
+
const textBuffer = [];
|
|
1493
|
+
if (this.opt.headerBold) {
|
|
1494
|
+
textBuffer.push(ansi.style.bold);
|
|
1495
|
+
}
|
|
1496
|
+
if (this.opt.headerColor) {
|
|
1497
|
+
textBuffer.push(COLORS[this.opt.headerColor]);
|
|
1498
|
+
}
|
|
1499
|
+
textBuffer.push(line);
|
|
1500
|
+
textBuffer.push(ansi.style.reset);
|
|
1501
|
+
return textBuffer.join("");
|
|
1502
|
+
};
|
|
1503
|
+
ListItBuffer.prototype.generateHeaderUnderline = function() {
|
|
1504
|
+
if (!this.opt.headerUnderline) {
|
|
1505
|
+
return null;
|
|
1506
|
+
}
|
|
1507
|
+
if (this.header == null) {
|
|
1508
|
+
return null;
|
|
1509
|
+
}
|
|
1510
|
+
return this.columns.map(
|
|
1511
|
+
(column) => "-".repeat(column.getWidth())
|
|
1512
|
+
).join(" ");
|
|
1513
|
+
};
|
|
1514
|
+
function objectArrayToTable(objects) {
|
|
1515
|
+
const keys = Object.keys(objects[0]);
|
|
1516
|
+
const body = objects.map((item) => keys.map((key) => {
|
|
1517
|
+
if (item[key] != null && typeof item[key] == "object" && item[key].constructor.name == "Date") {
|
|
1518
|
+
return item[key].toISOString();
|
|
1519
|
+
}
|
|
1520
|
+
return item[key];
|
|
1521
|
+
}));
|
|
1522
|
+
return [keys, ...body];
|
|
1523
|
+
}
|
|
1524
|
+
ListItBuffer.prototype.setColumnWidth = function(indexOfColumns, width) {
|
|
1525
|
+
this.columnWidth = this.columnWidth || [];
|
|
1526
|
+
if (typeof indexOfColumns !== "number") {
|
|
1527
|
+
throw new Error("indexOfColumns must be a number");
|
|
1528
|
+
}
|
|
1529
|
+
if (!width) {
|
|
1530
|
+
delete this.columnWidth[indexOfColumns];
|
|
1531
|
+
} else {
|
|
1532
|
+
if (typeof width !== "number") {
|
|
1533
|
+
throw new Error("width must be a number");
|
|
1534
|
+
}
|
|
1535
|
+
this.columnWidth[indexOfColumns] = width;
|
|
1536
|
+
}
|
|
1537
|
+
return this;
|
|
1538
|
+
};
|
|
1539
|
+
ListItBuffer.prototype.setColumnWidthAll = function(widthForAll) {
|
|
1540
|
+
if (widthForAll != null && !Array.isArray(widthForAll) && typeof widthForAll !== "number") {
|
|
1541
|
+
throw new Error(
|
|
1542
|
+
"widthForAll must be one of a null, an Array or a number"
|
|
1543
|
+
);
|
|
1544
|
+
}
|
|
1545
|
+
if (Array.isArray(widthForAll)) {
|
|
1546
|
+
for (let i = 0; i < widthForAll.length; i++) {
|
|
1547
|
+
const width = widthForAll[i];
|
|
1548
|
+
if (width != void 0 && typeof width !== "number") {
|
|
1549
|
+
throw new Error(
|
|
1550
|
+
`widthForAll[${i}] must be an undefined or a number`
|
|
1551
|
+
);
|
|
1552
|
+
}
|
|
1553
|
+
}
|
|
1554
|
+
}
|
|
1555
|
+
this.columnWidth = widthForAll;
|
|
1556
|
+
return this;
|
|
1557
|
+
};
|
|
1558
|
+
ListItBuffer.prototype.getColumnWidth = function(indexOfColumns) {
|
|
1559
|
+
if (Array.isArray(this.columnWidth)) {
|
|
1560
|
+
return this.columnWidth[indexOfColumns];
|
|
1561
|
+
}
|
|
1562
|
+
return this.columnWidth;
|
|
1563
|
+
};
|
|
1564
|
+
ListItBuffer.prototype.setHeaderRow = function(header) {
|
|
1565
|
+
if (header && !Array.isArray(header)) {
|
|
1566
|
+
throw new Error([
|
|
1567
|
+
"The header must be an array,",
|
|
1568
|
+
`but ${typeof header} was specified.`,
|
|
1569
|
+
`header: ${JSON.stringify(header)}`
|
|
1570
|
+
].join(" "));
|
|
1571
|
+
}
|
|
1572
|
+
this.header = header;
|
|
1573
|
+
if (this.header == null) {
|
|
1574
|
+
this.columns.forEach((column) => column.setHeader(null));
|
|
1575
|
+
} else {
|
|
1576
|
+
this.header.forEach((headerText, iCol) => {
|
|
1577
|
+
if (iCol >= this.columns.length) {
|
|
1578
|
+
this.addColumn(headerText);
|
|
1579
|
+
}
|
|
1580
|
+
});
|
|
1581
|
+
}
|
|
1582
|
+
return this;
|
|
1583
|
+
};
|
|
1584
|
+
ListItBuffer.prototype.addColumn = function(headerText) {
|
|
1585
|
+
const column = new Column();
|
|
1586
|
+
if (headerText) {
|
|
1587
|
+
column.setHeader(headerText);
|
|
1588
|
+
}
|
|
1589
|
+
if (this.opt.autoAlign) {
|
|
1590
|
+
column.setAutoAlign(true);
|
|
1591
|
+
}
|
|
1592
|
+
this.columns.push(column);
|
|
1593
|
+
};
|
|
1594
|
+
}
|
|
1595
|
+
});
|
|
1596
|
+
|
|
1597
|
+
// ../../node_modules/list-it/index.js
|
|
1598
|
+
var require_list_it = __commonJS({
|
|
1599
|
+
"../../node_modules/list-it/index.js"(exports2, module2) {
|
|
1600
|
+
"use strict";
|
|
1601
|
+
var ListItBuffer = require_list_it_buffer();
|
|
1602
|
+
function ListIt2(opt) {
|
|
1603
|
+
ListItBuffer.call(this, opt);
|
|
1604
|
+
}
|
|
1605
|
+
ListIt2.prototype = new ListItBuffer();
|
|
1606
|
+
ListIt2.buffer = function(opt) {
|
|
1607
|
+
opt = opt || {};
|
|
1608
|
+
if (!("autoAlign" in opt)) {
|
|
1609
|
+
opt.autoAlign = false;
|
|
1610
|
+
}
|
|
1611
|
+
return new ListIt2(opt);
|
|
1612
|
+
};
|
|
1613
|
+
module2.exports = ListIt2;
|
|
1614
|
+
}
|
|
1615
|
+
});
|
|
1616
|
+
|
|
1617
|
+
// src/scripts/results.ts
|
|
1618
|
+
var results_exports = {};
|
|
1619
|
+
__export(results_exports, {
|
|
1620
|
+
results: () => results
|
|
1621
|
+
});
|
|
1622
|
+
module.exports = __toCommonJS(results_exports);
|
|
1623
|
+
var import_args = __toESM(require("args"));
|
|
1624
|
+
var import_chalk = __toESM(require("chalk"));
|
|
1625
|
+
var import_connectors = require("@tradejs/connectors");
|
|
1626
|
+
var import_cli = require("@tradejs/node/cli");
|
|
1627
|
+
var import_redis = require("@tradejs/infra/redis");
|
|
1628
|
+
var ListIt = require_list_it();
|
|
1629
|
+
import_args.default.example(
|
|
1630
|
+
"yarn results --strategy TrendLine --coverage",
|
|
1631
|
+
"Show best results per symbol and coverage"
|
|
1632
|
+
);
|
|
1633
|
+
import_args.default.option(["s", "strategy"], "Strategy name");
|
|
1634
|
+
import_args.default.option(["C", "coverage"], "Show coverage table", false);
|
|
1635
|
+
import_args.default.option(["u", "update"], "Update results config in redis", false);
|
|
1636
|
+
import_args.default.option(["m", "merge"], "Merge results config in redis", false);
|
|
1637
|
+
import_args.default.option(["c", "clear"], "Clear results config in redis", false);
|
|
1638
|
+
import_args.default.option(["V", "verbose"], "Verbose output", false);
|
|
1639
|
+
import_args.default.option(["U", "user"], "Use user config", "root");
|
|
1640
|
+
var flags = import_args.default.parse(process.argv);
|
|
1641
|
+
var MIN_PROFIT = 2;
|
|
1642
|
+
var MIN_WIN_RATE = 40;
|
|
1643
|
+
var MIN_ORDERS_PER_MONTH = 1;
|
|
1644
|
+
var createListIt = () => new ListIt({
|
|
1645
|
+
autoAlign: true,
|
|
1646
|
+
headerUnderline: true
|
|
1647
|
+
});
|
|
1648
|
+
var formatPercent = (value) => `${value.toFixed(2)}%`;
|
|
1649
|
+
var getMonthlyReturn = (totalReturn, periodMonths) => {
|
|
1650
|
+
if (periodMonths <= 0) {
|
|
1651
|
+
return 0;
|
|
1652
|
+
}
|
|
1653
|
+
const base = 1 + totalReturn / 100;
|
|
1654
|
+
if (base <= 0) {
|
|
1655
|
+
return -100;
|
|
1656
|
+
}
|
|
1657
|
+
return (Math.pow(base, 1 / periodMonths) - 1) * 100;
|
|
1658
|
+
};
|
|
1659
|
+
var toStrategyResultEntry = (row) => ({
|
|
1660
|
+
config: row.config,
|
|
1661
|
+
stats: row.stats
|
|
1662
|
+
});
|
|
1663
|
+
var toStrategyResults = (rows) => Object.fromEntries(
|
|
1664
|
+
[...rows].map((row) => [row.symbol, toStrategyResultEntry(row)])
|
|
1665
|
+
);
|
|
1666
|
+
var getTestConfigs = async (userName) => {
|
|
1667
|
+
const testsPrefix = import_redis.redisKeys.tests(userName);
|
|
1668
|
+
const keys = await (0, import_redis.getKeys)(testsPrefix);
|
|
1669
|
+
const configKeys = keys.filter((key) => key.endsWith(":config"));
|
|
1670
|
+
return configKeys.map((key) => {
|
|
1671
|
+
const parts = key.split(":");
|
|
1672
|
+
if (parts.length < 5) {
|
|
1673
|
+
return null;
|
|
1674
|
+
}
|
|
1675
|
+
const strategyName = parts[3];
|
|
1676
|
+
const testName = parts[4];
|
|
1677
|
+
return { strategyName, testName };
|
|
1678
|
+
}).filter(Boolean);
|
|
1679
|
+
};
|
|
1680
|
+
var buildBestResults = async (userName, strategyName) => {
|
|
1681
|
+
const testConfigs = await getTestConfigs(userName);
|
|
1682
|
+
const bestBySymbol = /* @__PURE__ */ new Map();
|
|
1683
|
+
for await (const {
|
|
1684
|
+
testName,
|
|
1685
|
+
strategyName: strategyFromIndex
|
|
1686
|
+
} of testConfigs) {
|
|
1687
|
+
const config = await (0, import_redis.getData)(
|
|
1688
|
+
import_redis.redisKeys.testConfig(userName, strategyFromIndex, testName),
|
|
1689
|
+
null
|
|
1690
|
+
);
|
|
1691
|
+
if (!config || config.strategyName !== strategyName) {
|
|
1692
|
+
continue;
|
|
1693
|
+
}
|
|
1694
|
+
const stat = await (0, import_redis.getData)(
|
|
1695
|
+
import_redis.redisKeys.testStat(userName, strategyFromIndex, testName),
|
|
1696
|
+
null
|
|
1697
|
+
);
|
|
1698
|
+
if (!stat) {
|
|
1699
|
+
continue;
|
|
1700
|
+
}
|
|
1701
|
+
const profit = getMonthlyReturn(
|
|
1702
|
+
stat.totalReturn ?? 0,
|
|
1703
|
+
stat.periodMonths ?? 0
|
|
1704
|
+
);
|
|
1705
|
+
const winRate = stat.winRate ?? 0;
|
|
1706
|
+
const ordersPerMonth = stat.ordersPerMonth ?? 0;
|
|
1707
|
+
if (profit <= MIN_PROFIT || winRate <= MIN_WIN_RATE || ordersPerMonth <= MIN_ORDERS_PER_MONTH) {
|
|
1708
|
+
continue;
|
|
1709
|
+
}
|
|
1710
|
+
const prev = bestBySymbol.get(config.symbol);
|
|
1711
|
+
if (!prev || profit > prev.profit) {
|
|
1712
|
+
bestBySymbol.set(config.symbol, {
|
|
1713
|
+
symbol: config.symbol,
|
|
1714
|
+
profit,
|
|
1715
|
+
winRate,
|
|
1716
|
+
orders: stat.orders ?? 0,
|
|
1717
|
+
config: config.strategyConfig,
|
|
1718
|
+
stats: stat
|
|
1719
|
+
});
|
|
1720
|
+
}
|
|
1721
|
+
}
|
|
1722
|
+
return bestBySymbol;
|
|
1723
|
+
};
|
|
1724
|
+
var getSavedProfitsBySymbol = async (currentResults) => {
|
|
1725
|
+
const savedProfitBySymbol = /* @__PURE__ */ new Map();
|
|
1726
|
+
for (const [symbol, result] of Object.entries(currentResults)) {
|
|
1727
|
+
const stat = result.stats;
|
|
1728
|
+
const profit = getMonthlyReturn(
|
|
1729
|
+
stat.totalReturn ?? 0,
|
|
1730
|
+
stat.periodMonths ?? 0
|
|
1731
|
+
);
|
|
1732
|
+
const prevProfit = savedProfitBySymbol.get(symbol);
|
|
1733
|
+
if (prevProfit === void 0 || profit > prevProfit) {
|
|
1734
|
+
savedProfitBySymbol.set(symbol, profit);
|
|
1735
|
+
}
|
|
1736
|
+
}
|
|
1737
|
+
return savedProfitBySymbol;
|
|
1738
|
+
};
|
|
1739
|
+
var getCoverageRow = async (strategyName, userName, goodSymbols) => {
|
|
1740
|
+
const currentResults = await (0, import_redis.getData)(
|
|
1741
|
+
import_redis.redisKeys.strategyResults(userName, strategyName),
|
|
1742
|
+
{}
|
|
1743
|
+
);
|
|
1744
|
+
const existingSymbols = new Set(Object.keys(currentResults));
|
|
1745
|
+
let goodMissing = 0;
|
|
1746
|
+
let goodExisting = 0;
|
|
1747
|
+
for (const symbol of goodSymbols) {
|
|
1748
|
+
if (existingSymbols.has(symbol)) {
|
|
1749
|
+
goodExisting += 1;
|
|
1750
|
+
} else {
|
|
1751
|
+
goodMissing += 1;
|
|
1752
|
+
}
|
|
1753
|
+
}
|
|
1754
|
+
const byBitConnector = await import_connectors.connectors.ByBit({
|
|
1755
|
+
userName
|
|
1756
|
+
});
|
|
1757
|
+
const tickers = await (0, import_cli.getTickers)(byBitConnector);
|
|
1758
|
+
const total = tickers.length;
|
|
1759
|
+
const coverage = total ? (goodMissing + goodExisting) / total * 100 : 0;
|
|
1760
|
+
return {
|
|
1761
|
+
goodMissing,
|
|
1762
|
+
goodExisting,
|
|
1763
|
+
total,
|
|
1764
|
+
coverage
|
|
1765
|
+
};
|
|
1766
|
+
};
|
|
1767
|
+
var results = async () => {
|
|
1768
|
+
if (!flags.strategy) {
|
|
1769
|
+
console.error(import_chalk.default.red("Missing --strategy"));
|
|
1770
|
+
process.exit(1);
|
|
1771
|
+
}
|
|
1772
|
+
const strategyName = flags.strategy;
|
|
1773
|
+
const userName = flags.user;
|
|
1774
|
+
if (flags.clear) {
|
|
1775
|
+
const cleared = await (0, import_redis.delKey)(
|
|
1776
|
+
import_redis.redisKeys.strategyResults(userName, strategyName)
|
|
1777
|
+
);
|
|
1778
|
+
console.log(
|
|
1779
|
+
cleared ? import_chalk.default.green(`Cleared results:${strategyName}`) : import_chalk.default.yellow(`No results to clear for ${strategyName}`)
|
|
1780
|
+
);
|
|
1781
|
+
if (!flags.coverage && !flags.update && !flags.merge) {
|
|
1782
|
+
process.exit();
|
|
1783
|
+
}
|
|
1784
|
+
}
|
|
1785
|
+
const bestBySymbol = await buildBestResults(userName, strategyName);
|
|
1786
|
+
if (flags.coverage) {
|
|
1787
|
+
const rows = [...bestBySymbol.values()].sort((a, b) => b.profit - a.profit).map((row) => [
|
|
1788
|
+
import_chalk.default.yellow(row.symbol),
|
|
1789
|
+
import_chalk.default.green(formatPercent(row.profit)),
|
|
1790
|
+
import_chalk.default.magenta(formatPercent(row.winRate)),
|
|
1791
|
+
import_chalk.default.blue(row.orders.toString())
|
|
1792
|
+
]);
|
|
1793
|
+
console.log("");
|
|
1794
|
+
console.log(import_chalk.default.gray("RESULTS:"));
|
|
1795
|
+
console.log(
|
|
1796
|
+
createListIt().setHeaderRow([
|
|
1797
|
+
import_chalk.default.yellow("SYMBOL"),
|
|
1798
|
+
import_chalk.default.green("PROFIT"),
|
|
1799
|
+
import_chalk.default.magenta("WINRATE"),
|
|
1800
|
+
import_chalk.default.blue("ORDERS")
|
|
1801
|
+
]).d(rows).toString()
|
|
1802
|
+
);
|
|
1803
|
+
console.log("");
|
|
1804
|
+
const goodSymbols = new Set(bestBySymbol.keys());
|
|
1805
|
+
const { goodMissing, goodExisting, total, coverage } = await getCoverageRow(
|
|
1806
|
+
strategyName,
|
|
1807
|
+
userName,
|
|
1808
|
+
goodSymbols
|
|
1809
|
+
);
|
|
1810
|
+
console.log(
|
|
1811
|
+
import_chalk.default.gray(
|
|
1812
|
+
`COVERAGE: ${goodMissing} / ${goodExisting} / ${total} (${coverage.toFixed(2)} %)`
|
|
1813
|
+
)
|
|
1814
|
+
);
|
|
1815
|
+
console.log("");
|
|
1816
|
+
}
|
|
1817
|
+
if (flags.update || flags.merge) {
|
|
1818
|
+
const resultsConfig = toStrategyResults(bestBySymbol.values());
|
|
1819
|
+
if (flags.merge) {
|
|
1820
|
+
if (Object.keys(resultsConfig).length === 0) {
|
|
1821
|
+
console.log(import_chalk.default.yellow("No good results to merge."));
|
|
1822
|
+
process.exit(0);
|
|
1823
|
+
}
|
|
1824
|
+
const current = await (0, import_redis.getData)(
|
|
1825
|
+
import_redis.redisKeys.strategyResults(userName, strategyName),
|
|
1826
|
+
{}
|
|
1827
|
+
);
|
|
1828
|
+
const savedProfitBySymbol = await getSavedProfitsBySymbol(current);
|
|
1829
|
+
const updates = [...bestBySymbol.values()].filter(
|
|
1830
|
+
({ symbol, profit }) => {
|
|
1831
|
+
const savedProfit = savedProfitBySymbol.get(symbol);
|
|
1832
|
+
return savedProfit === void 0 || profit > savedProfit;
|
|
1833
|
+
}
|
|
1834
|
+
);
|
|
1835
|
+
if (updates.length === 0) {
|
|
1836
|
+
console.log(
|
|
1837
|
+
import_chalk.default.yellow(
|
|
1838
|
+
`No symbols with higher profit than saved results:${strategyName}`
|
|
1839
|
+
)
|
|
1840
|
+
);
|
|
1841
|
+
process.exit(0);
|
|
1842
|
+
}
|
|
1843
|
+
const merged = {
|
|
1844
|
+
...current,
|
|
1845
|
+
...toStrategyResults(updates)
|
|
1846
|
+
};
|
|
1847
|
+
await (0, import_redis.setData)(import_redis.redisKeys.strategyResults(userName, strategyName), merged, {
|
|
1848
|
+
expire: 0
|
|
1849
|
+
});
|
|
1850
|
+
if (flags.verbose) {
|
|
1851
|
+
const updateRows = updates.sort((a, b) => {
|
|
1852
|
+
const prevA = savedProfitBySymbol.get(a.symbol) ?? -Infinity;
|
|
1853
|
+
const prevB = savedProfitBySymbol.get(b.symbol) ?? -Infinity;
|
|
1854
|
+
return b.profit - prevB - (a.profit - prevA);
|
|
1855
|
+
}).map((row) => {
|
|
1856
|
+
const prevProfit = savedProfitBySymbol.get(row.symbol);
|
|
1857
|
+
const delta = row.profit - (prevProfit ?? 0);
|
|
1858
|
+
return [
|
|
1859
|
+
import_chalk.default.yellow(row.symbol),
|
|
1860
|
+
import_chalk.default.gray(
|
|
1861
|
+
prevProfit === void 0 ? "N/A" : formatPercent(prevProfit)
|
|
1862
|
+
),
|
|
1863
|
+
import_chalk.default.green(formatPercent(row.profit)),
|
|
1864
|
+
import_chalk.default.blue(
|
|
1865
|
+
`${delta >= 0 ? "+" : ""}${formatPercent(delta).replace("+", "")}`
|
|
1866
|
+
)
|
|
1867
|
+
];
|
|
1868
|
+
});
|
|
1869
|
+
console.log("");
|
|
1870
|
+
console.log(import_chalk.default.gray("MERGE UPDATES:"));
|
|
1871
|
+
console.log(
|
|
1872
|
+
createListIt().setHeaderRow([
|
|
1873
|
+
import_chalk.default.yellow("SYMBOL"),
|
|
1874
|
+
import_chalk.default.gray("PREV_PROFIT"),
|
|
1875
|
+
import_chalk.default.green("NEW_PROFIT"),
|
|
1876
|
+
import_chalk.default.blue("DELTA")
|
|
1877
|
+
]).d(updateRows).toString()
|
|
1878
|
+
);
|
|
1879
|
+
console.log("");
|
|
1880
|
+
}
|
|
1881
|
+
console.log(
|
|
1882
|
+
import_chalk.default.green(
|
|
1883
|
+
`Merged ${updates.length} symbols into results:${strategyName} (only higher profit)`
|
|
1884
|
+
)
|
|
1885
|
+
);
|
|
1886
|
+
process.exit(0);
|
|
1887
|
+
}
|
|
1888
|
+
await (0, import_redis.setData)(
|
|
1889
|
+
import_redis.redisKeys.strategyResults(userName, strategyName),
|
|
1890
|
+
resultsConfig,
|
|
1891
|
+
{
|
|
1892
|
+
expire: 0
|
|
1893
|
+
}
|
|
1894
|
+
);
|
|
1895
|
+
console.log(
|
|
1896
|
+
import_chalk.default.green(
|
|
1897
|
+
`Updated results:${strategyName} with ${Object.keys(resultsConfig).length} symbols`
|
|
1898
|
+
)
|
|
1899
|
+
);
|
|
1900
|
+
}
|
|
1901
|
+
process.exit();
|
|
1902
|
+
};
|
|
1903
|
+
if (process.env.NODE_ENV !== "test") {
|
|
1904
|
+
void results();
|
|
1905
|
+
}
|
|
1906
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
1907
|
+
0 && (module.exports = {
|
|
1908
|
+
results
|
|
1909
|
+
});
|