@baton-dx/cli 0.6.1 → 0.7.1
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/{ai-tool-detection-Bw4qveB8.mjs → ai-tool-detection-46GECWyV.mjs} +1 -1
- package/dist/{ai-tool-detection-DMnwwNBI.mjs → ai-tool-detection-CMsBNa9e.mjs} +1 -1
- package/dist/{ai-tool-detection-DMnwwNBI.mjs.map → ai-tool-detection-CMsBNa9e.mjs.map} +1 -1
- package/dist/context-detection-DO0ZeRyQ.mjs +3191 -0
- package/dist/context-detection-DO0ZeRyQ.mjs.map +1 -0
- package/dist/{create-Cq7dvT9C.mjs → create-BiE2_2Fo.mjs} +5 -4
- package/dist/{create-Cq7dvT9C.mjs.map → create-BiE2_2Fo.mjs.map} +1 -1
- package/dist/{context-detection-CGh_5f6N.mjs → dist-BoZnMvNi.mjs} +2 -3188
- package/dist/dist-BoZnMvNi.mjs.map +1 -0
- package/dist/index.mjs +111 -59
- package/dist/index.mjs.map +1 -1
- package/dist/{list-xZTyCWwl.mjs → list-7GvmRp3q.mjs} +5 -4
- package/dist/{list-xZTyCWwl.mjs.map → list-7GvmRp3q.mjs.map} +1 -1
- package/dist/{prompt-JYaE4U2w.mjs → prompt-DXfUeR3X.mjs} +4 -4
- package/dist/prompt-DXfUeR3X.mjs.map +1 -0
- package/dist/{remove-DSBMNbtP.mjs → remove-Cx8jC2vY.mjs} +3 -2
- package/dist/{remove-DSBMNbtP.mjs.map → remove-Cx8jC2vY.mjs.map} +1 -1
- package/dist/src-C-rwSQpx.mjs +6 -0
- package/dist/{src-B-Z49jsg.mjs → src-C0c228gb.mjs} +76 -16
- package/dist/src-C0c228gb.mjs.map +1 -0
- package/package.json +1 -1
- package/dist/context-detection-CGh_5f6N.mjs.map +0 -1
- package/dist/prompt-JYaE4U2w.mjs.map +0 -1
- package/dist/src-B-Z49jsg.mjs.map +0 -1
|
@@ -0,0 +1,3191 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { i as __toESM, n as __commonJSMin } from "./dist-BoZnMvNi.mjs";
|
|
3
|
+
import { access } from "node:fs/promises";
|
|
4
|
+
import { dirname, join, sep } from "node:path";
|
|
5
|
+
import { formatWithOptions, stripVTControlCharacters } from "node:util";
|
|
6
|
+
import N, { stdin, stdout } from "node:process";
|
|
7
|
+
import * as tty from "node:tty";
|
|
8
|
+
import { ReadStream } from "node:tty";
|
|
9
|
+
import * as k from "node:readline";
|
|
10
|
+
import ot from "node:readline";
|
|
11
|
+
import { existsSync, lstatSync, readdirSync } from "node:fs";
|
|
12
|
+
|
|
13
|
+
//#region ../../node_modules/.bun/consola@3.4.2/node_modules/consola/dist/core.mjs
|
|
14
|
+
const LogLevels = {
|
|
15
|
+
silent: Number.NEGATIVE_INFINITY,
|
|
16
|
+
fatal: 0,
|
|
17
|
+
error: 0,
|
|
18
|
+
warn: 1,
|
|
19
|
+
log: 2,
|
|
20
|
+
info: 3,
|
|
21
|
+
success: 3,
|
|
22
|
+
fail: 3,
|
|
23
|
+
ready: 3,
|
|
24
|
+
start: 3,
|
|
25
|
+
box: 3,
|
|
26
|
+
debug: 4,
|
|
27
|
+
trace: 5,
|
|
28
|
+
verbose: Number.POSITIVE_INFINITY
|
|
29
|
+
};
|
|
30
|
+
const LogTypes = {
|
|
31
|
+
silent: { level: -1 },
|
|
32
|
+
fatal: { level: LogLevels.fatal },
|
|
33
|
+
error: { level: LogLevels.error },
|
|
34
|
+
warn: { level: LogLevels.warn },
|
|
35
|
+
log: { level: LogLevels.log },
|
|
36
|
+
info: { level: LogLevels.info },
|
|
37
|
+
success: { level: LogLevels.success },
|
|
38
|
+
fail: { level: LogLevels.fail },
|
|
39
|
+
ready: { level: LogLevels.info },
|
|
40
|
+
start: { level: LogLevels.info },
|
|
41
|
+
box: { level: LogLevels.info },
|
|
42
|
+
debug: { level: LogLevels.debug },
|
|
43
|
+
trace: { level: LogLevels.trace },
|
|
44
|
+
verbose: { level: LogLevels.verbose }
|
|
45
|
+
};
|
|
46
|
+
function isPlainObject$1(value) {
|
|
47
|
+
if (value === null || typeof value !== "object") return false;
|
|
48
|
+
const prototype = Object.getPrototypeOf(value);
|
|
49
|
+
if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) return false;
|
|
50
|
+
if (Symbol.iterator in value) return false;
|
|
51
|
+
if (Symbol.toStringTag in value) return Object.prototype.toString.call(value) === "[object Module]";
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
function _defu(baseObject, defaults, namespace = ".", merger) {
|
|
55
|
+
if (!isPlainObject$1(defaults)) return _defu(baseObject, {}, namespace, merger);
|
|
56
|
+
const object = Object.assign({}, defaults);
|
|
57
|
+
for (const key in baseObject) {
|
|
58
|
+
if (key === "__proto__" || key === "constructor") continue;
|
|
59
|
+
const value = baseObject[key];
|
|
60
|
+
if (value === null || value === void 0) continue;
|
|
61
|
+
if (merger && merger(object, key, value, namespace)) continue;
|
|
62
|
+
if (Array.isArray(value) && Array.isArray(object[key])) object[key] = [...value, ...object[key]];
|
|
63
|
+
else if (isPlainObject$1(value) && isPlainObject$1(object[key])) object[key] = _defu(value, object[key], (namespace ? `${namespace}.` : "") + key.toString(), merger);
|
|
64
|
+
else object[key] = value;
|
|
65
|
+
}
|
|
66
|
+
return object;
|
|
67
|
+
}
|
|
68
|
+
function createDefu(merger) {
|
|
69
|
+
return (...arguments_) => arguments_.reduce((p, c) => _defu(p, c, "", merger), {});
|
|
70
|
+
}
|
|
71
|
+
const defu = createDefu();
|
|
72
|
+
function isPlainObject(obj) {
|
|
73
|
+
return Object.prototype.toString.call(obj) === "[object Object]";
|
|
74
|
+
}
|
|
75
|
+
function isLogObj(arg) {
|
|
76
|
+
if (!isPlainObject(arg)) return false;
|
|
77
|
+
if (!arg.message && !arg.args) return false;
|
|
78
|
+
if (arg.stack) return false;
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
let paused = false;
|
|
82
|
+
const queue = [];
|
|
83
|
+
var Consola = class Consola {
|
|
84
|
+
options;
|
|
85
|
+
_lastLog;
|
|
86
|
+
_mockFn;
|
|
87
|
+
/**
|
|
88
|
+
* Creates an instance of Consola with specified options or defaults.
|
|
89
|
+
*
|
|
90
|
+
* @param {Partial<ConsolaOptions>} [options={}] - Configuration options for the Consola instance.
|
|
91
|
+
*/
|
|
92
|
+
constructor(options = {}) {
|
|
93
|
+
const types = options.types || LogTypes;
|
|
94
|
+
this.options = defu({
|
|
95
|
+
...options,
|
|
96
|
+
defaults: { ...options.defaults },
|
|
97
|
+
level: _normalizeLogLevel(options.level, types),
|
|
98
|
+
reporters: [...options.reporters || []]
|
|
99
|
+
}, {
|
|
100
|
+
types: LogTypes,
|
|
101
|
+
throttle: 1e3,
|
|
102
|
+
throttleMin: 5,
|
|
103
|
+
formatOptions: {
|
|
104
|
+
date: true,
|
|
105
|
+
colors: false,
|
|
106
|
+
compact: true
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
for (const type in types) {
|
|
110
|
+
const defaults = {
|
|
111
|
+
type,
|
|
112
|
+
...this.options.defaults,
|
|
113
|
+
...types[type]
|
|
114
|
+
};
|
|
115
|
+
this[type] = this._wrapLogFn(defaults);
|
|
116
|
+
this[type].raw = this._wrapLogFn(defaults, true);
|
|
117
|
+
}
|
|
118
|
+
if (this.options.mockFn) this.mockTypes();
|
|
119
|
+
this._lastLog = {};
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Gets the current log level of the Consola instance.
|
|
123
|
+
*
|
|
124
|
+
* @returns {number} The current log level.
|
|
125
|
+
*/
|
|
126
|
+
get level() {
|
|
127
|
+
return this.options.level;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Sets the minimum log level that will be output by the instance.
|
|
131
|
+
*
|
|
132
|
+
* @param {number} level - The new log level to set.
|
|
133
|
+
*/
|
|
134
|
+
set level(level) {
|
|
135
|
+
this.options.level = _normalizeLogLevel(level, this.options.types, this.options.level);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Displays a prompt to the user and returns the response.
|
|
139
|
+
* Throw an error if `prompt` is not supported by the current configuration.
|
|
140
|
+
*
|
|
141
|
+
* @template T
|
|
142
|
+
* @param {string} message - The message to display in the prompt.
|
|
143
|
+
* @param {T} [opts] - Optional options for the prompt. See {@link PromptOptions}.
|
|
144
|
+
* @returns {promise<T>} A promise that infer with the prompt options. See {@link PromptOptions}.
|
|
145
|
+
*/
|
|
146
|
+
prompt(message, opts) {
|
|
147
|
+
if (!this.options.prompt) throw new Error("prompt is not supported!");
|
|
148
|
+
return this.options.prompt(message, opts);
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Creates a new instance of Consola, inheriting options from the current instance, with possible overrides.
|
|
152
|
+
*
|
|
153
|
+
* @param {Partial<ConsolaOptions>} options - Optional overrides for the new instance. See {@link ConsolaOptions}.
|
|
154
|
+
* @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
|
|
155
|
+
*/
|
|
156
|
+
create(options) {
|
|
157
|
+
const instance = new Consola({
|
|
158
|
+
...this.options,
|
|
159
|
+
...options
|
|
160
|
+
});
|
|
161
|
+
if (this._mockFn) instance.mockTypes(this._mockFn);
|
|
162
|
+
return instance;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Creates a new Consola instance with the specified default log object properties.
|
|
166
|
+
*
|
|
167
|
+
* @param {InputLogObject} defaults - Default properties to include in any log from the new instance. See {@link InputLogObject}.
|
|
168
|
+
* @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
|
|
169
|
+
*/
|
|
170
|
+
withDefaults(defaults) {
|
|
171
|
+
return this.create({
|
|
172
|
+
...this.options,
|
|
173
|
+
defaults: {
|
|
174
|
+
...this.options.defaults,
|
|
175
|
+
...defaults
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Creates a new Consola instance with a specified tag, which will be included in every log.
|
|
181
|
+
*
|
|
182
|
+
* @param {string} tag - The tag to include in each log of the new instance.
|
|
183
|
+
* @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
|
|
184
|
+
*/
|
|
185
|
+
withTag(tag) {
|
|
186
|
+
return this.withDefaults({ tag: this.options.defaults.tag ? this.options.defaults.tag + ":" + tag : tag });
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Adds a custom reporter to the Consola instance.
|
|
190
|
+
* Reporters will be called for each log message, depending on their implementation and log level.
|
|
191
|
+
*
|
|
192
|
+
* @param {ConsolaReporter} reporter - The reporter to add. See {@link ConsolaReporter}.
|
|
193
|
+
* @returns {Consola} The current Consola instance.
|
|
194
|
+
*/
|
|
195
|
+
addReporter(reporter) {
|
|
196
|
+
this.options.reporters.push(reporter);
|
|
197
|
+
return this;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Removes a custom reporter from the Consola instance.
|
|
201
|
+
* If no reporter is specified, all reporters will be removed.
|
|
202
|
+
*
|
|
203
|
+
* @param {ConsolaReporter} reporter - The reporter to remove. See {@link ConsolaReporter}.
|
|
204
|
+
* @returns {Consola} The current Consola instance.
|
|
205
|
+
*/
|
|
206
|
+
removeReporter(reporter) {
|
|
207
|
+
if (reporter) {
|
|
208
|
+
const i = this.options.reporters.indexOf(reporter);
|
|
209
|
+
if (i !== -1) return this.options.reporters.splice(i, 1);
|
|
210
|
+
} else this.options.reporters.splice(0);
|
|
211
|
+
return this;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Replaces all reporters of the Consola instance with the specified array of reporters.
|
|
215
|
+
*
|
|
216
|
+
* @param {ConsolaReporter[]} reporters - The new reporters to set. See {@link ConsolaReporter}.
|
|
217
|
+
* @returns {Consola} The current Consola instance.
|
|
218
|
+
*/
|
|
219
|
+
setReporters(reporters) {
|
|
220
|
+
this.options.reporters = Array.isArray(reporters) ? reporters : [reporters];
|
|
221
|
+
return this;
|
|
222
|
+
}
|
|
223
|
+
wrapAll() {
|
|
224
|
+
this.wrapConsole();
|
|
225
|
+
this.wrapStd();
|
|
226
|
+
}
|
|
227
|
+
restoreAll() {
|
|
228
|
+
this.restoreConsole();
|
|
229
|
+
this.restoreStd();
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Overrides console methods with Consola logging methods for consistent logging.
|
|
233
|
+
*/
|
|
234
|
+
wrapConsole() {
|
|
235
|
+
for (const type in this.options.types) {
|
|
236
|
+
if (!console["__" + type]) console["__" + type] = console[type];
|
|
237
|
+
console[type] = this[type].raw;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Restores the original console methods, removing Consola overrides.
|
|
242
|
+
*/
|
|
243
|
+
restoreConsole() {
|
|
244
|
+
for (const type in this.options.types) if (console["__" + type]) {
|
|
245
|
+
console[type] = console["__" + type];
|
|
246
|
+
delete console["__" + type];
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Overrides standard output and error streams to redirect them through Consola.
|
|
251
|
+
*/
|
|
252
|
+
wrapStd() {
|
|
253
|
+
this._wrapStream(this.options.stdout, "log");
|
|
254
|
+
this._wrapStream(this.options.stderr, "log");
|
|
255
|
+
}
|
|
256
|
+
_wrapStream(stream, type) {
|
|
257
|
+
if (!stream) return;
|
|
258
|
+
if (!stream.__write) stream.__write = stream.write;
|
|
259
|
+
stream.write = (data) => {
|
|
260
|
+
this[type].raw(String(data).trim());
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Restores the original standard output and error streams, removing the Consola redirection.
|
|
265
|
+
*/
|
|
266
|
+
restoreStd() {
|
|
267
|
+
this._restoreStream(this.options.stdout);
|
|
268
|
+
this._restoreStream(this.options.stderr);
|
|
269
|
+
}
|
|
270
|
+
_restoreStream(stream) {
|
|
271
|
+
if (!stream) return;
|
|
272
|
+
if (stream.__write) {
|
|
273
|
+
stream.write = stream.__write;
|
|
274
|
+
delete stream.__write;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Pauses logging, queues incoming logs until resumed.
|
|
279
|
+
*/
|
|
280
|
+
pauseLogs() {
|
|
281
|
+
paused = true;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Resumes logging, processing any queued logs.
|
|
285
|
+
*/
|
|
286
|
+
resumeLogs() {
|
|
287
|
+
paused = false;
|
|
288
|
+
const _queue = queue.splice(0);
|
|
289
|
+
for (const item of _queue) item[0]._logFn(item[1], item[2]);
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Replaces logging methods with mocks if a mock function is provided.
|
|
293
|
+
*
|
|
294
|
+
* @param {ConsolaOptions["mockFn"]} mockFn - The function to use for mocking logging methods. See {@link ConsolaOptions["mockFn"]}.
|
|
295
|
+
*/
|
|
296
|
+
mockTypes(mockFn) {
|
|
297
|
+
const _mockFn = mockFn || this.options.mockFn;
|
|
298
|
+
this._mockFn = _mockFn;
|
|
299
|
+
if (typeof _mockFn !== "function") return;
|
|
300
|
+
for (const type in this.options.types) {
|
|
301
|
+
this[type] = _mockFn(type, this.options.types[type]) || this[type];
|
|
302
|
+
this[type].raw = this[type];
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
_wrapLogFn(defaults, isRaw) {
|
|
306
|
+
return (...args) => {
|
|
307
|
+
if (paused) {
|
|
308
|
+
queue.push([
|
|
309
|
+
this,
|
|
310
|
+
defaults,
|
|
311
|
+
args,
|
|
312
|
+
isRaw
|
|
313
|
+
]);
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
return this._logFn(defaults, args, isRaw);
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
_logFn(defaults, args, isRaw) {
|
|
320
|
+
if ((defaults.level || 0) > this.level) return false;
|
|
321
|
+
const logObj = {
|
|
322
|
+
date: /* @__PURE__ */ new Date(),
|
|
323
|
+
args: [],
|
|
324
|
+
...defaults,
|
|
325
|
+
level: _normalizeLogLevel(defaults.level, this.options.types)
|
|
326
|
+
};
|
|
327
|
+
if (!isRaw && args.length === 1 && isLogObj(args[0])) Object.assign(logObj, args[0]);
|
|
328
|
+
else logObj.args = [...args];
|
|
329
|
+
if (logObj.message) {
|
|
330
|
+
logObj.args.unshift(logObj.message);
|
|
331
|
+
delete logObj.message;
|
|
332
|
+
}
|
|
333
|
+
if (logObj.additional) {
|
|
334
|
+
if (!Array.isArray(logObj.additional)) logObj.additional = logObj.additional.split("\n");
|
|
335
|
+
logObj.args.push("\n" + logObj.additional.join("\n"));
|
|
336
|
+
delete logObj.additional;
|
|
337
|
+
}
|
|
338
|
+
logObj.type = typeof logObj.type === "string" ? logObj.type.toLowerCase() : "log";
|
|
339
|
+
logObj.tag = typeof logObj.tag === "string" ? logObj.tag : "";
|
|
340
|
+
const resolveLog = (newLog = false) => {
|
|
341
|
+
const repeated = (this._lastLog.count || 0) - this.options.throttleMin;
|
|
342
|
+
if (this._lastLog.object && repeated > 0) {
|
|
343
|
+
const args2 = [...this._lastLog.object.args];
|
|
344
|
+
if (repeated > 1) args2.push(`(repeated ${repeated} times)`);
|
|
345
|
+
this._log({
|
|
346
|
+
...this._lastLog.object,
|
|
347
|
+
args: args2
|
|
348
|
+
});
|
|
349
|
+
this._lastLog.count = 1;
|
|
350
|
+
}
|
|
351
|
+
if (newLog) {
|
|
352
|
+
this._lastLog.object = logObj;
|
|
353
|
+
this._log(logObj);
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
clearTimeout(this._lastLog.timeout);
|
|
357
|
+
const diffTime = this._lastLog.time && logObj.date ? logObj.date.getTime() - this._lastLog.time.getTime() : 0;
|
|
358
|
+
this._lastLog.time = logObj.date;
|
|
359
|
+
if (diffTime < this.options.throttle) try {
|
|
360
|
+
const serializedLog = JSON.stringify([
|
|
361
|
+
logObj.type,
|
|
362
|
+
logObj.tag,
|
|
363
|
+
logObj.args
|
|
364
|
+
]);
|
|
365
|
+
const isSameLog = this._lastLog.serialized === serializedLog;
|
|
366
|
+
this._lastLog.serialized = serializedLog;
|
|
367
|
+
if (isSameLog) {
|
|
368
|
+
this._lastLog.count = (this._lastLog.count || 0) + 1;
|
|
369
|
+
if (this._lastLog.count > this.options.throttleMin) {
|
|
370
|
+
this._lastLog.timeout = setTimeout(resolveLog, this.options.throttle);
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
} catch {}
|
|
375
|
+
resolveLog(true);
|
|
376
|
+
}
|
|
377
|
+
_log(logObj) {
|
|
378
|
+
for (const reporter of this.options.reporters) reporter.log(logObj, { options: this.options });
|
|
379
|
+
}
|
|
380
|
+
};
|
|
381
|
+
function _normalizeLogLevel(input, types = {}, defaultLevel = 3) {
|
|
382
|
+
if (input === void 0) return defaultLevel;
|
|
383
|
+
if (typeof input === "number") return input;
|
|
384
|
+
if (types[input] && types[input].level !== void 0) return types[input].level;
|
|
385
|
+
return defaultLevel;
|
|
386
|
+
}
|
|
387
|
+
Consola.prototype.add = Consola.prototype.addReporter;
|
|
388
|
+
Consola.prototype.remove = Consola.prototype.removeReporter;
|
|
389
|
+
Consola.prototype.clear = Consola.prototype.removeReporter;
|
|
390
|
+
Consola.prototype.withScope = Consola.prototype.withTag;
|
|
391
|
+
Consola.prototype.mock = Consola.prototype.mockTypes;
|
|
392
|
+
Consola.prototype.pause = Consola.prototype.pauseLogs;
|
|
393
|
+
Consola.prototype.resume = Consola.prototype.resumeLogs;
|
|
394
|
+
function createConsola$1(options = {}) {
|
|
395
|
+
return new Consola(options);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
//#endregion
|
|
399
|
+
//#region ../../node_modules/.bun/consola@3.4.2/node_modules/consola/dist/shared/consola.DRwqZj3T.mjs
|
|
400
|
+
function parseStack(stack, message) {
|
|
401
|
+
const cwd = process.cwd() + sep;
|
|
402
|
+
return stack.split("\n").splice(message.split("\n").length).map((l) => l.trim().replace("file://", "").replace(cwd, ""));
|
|
403
|
+
}
|
|
404
|
+
function writeStream(data, stream) {
|
|
405
|
+
return (stream.__write || stream.write).call(stream, data);
|
|
406
|
+
}
|
|
407
|
+
const bracket = (x) => x ? `[${x}]` : "";
|
|
408
|
+
var BasicReporter = class {
|
|
409
|
+
formatStack(stack, message, opts) {
|
|
410
|
+
const indent = " ".repeat((opts?.errorLevel || 0) + 1);
|
|
411
|
+
return indent + parseStack(stack, message).join(`
|
|
412
|
+
${indent}`);
|
|
413
|
+
}
|
|
414
|
+
formatError(err, opts) {
|
|
415
|
+
const message = err.message ?? formatWithOptions(opts, err);
|
|
416
|
+
const stack = err.stack ? this.formatStack(err.stack, message, opts) : "";
|
|
417
|
+
const level = opts?.errorLevel || 0;
|
|
418
|
+
const causedPrefix = level > 0 ? `${" ".repeat(level)}[cause]: ` : "";
|
|
419
|
+
const causedError = err.cause ? "\n\n" + this.formatError(err.cause, {
|
|
420
|
+
...opts,
|
|
421
|
+
errorLevel: level + 1
|
|
422
|
+
}) : "";
|
|
423
|
+
return causedPrefix + message + "\n" + stack + causedError;
|
|
424
|
+
}
|
|
425
|
+
formatArgs(args, opts) {
|
|
426
|
+
return formatWithOptions(opts, ...args.map((arg) => {
|
|
427
|
+
if (arg && typeof arg.stack === "string") return this.formatError(arg, opts);
|
|
428
|
+
return arg;
|
|
429
|
+
}));
|
|
430
|
+
}
|
|
431
|
+
formatDate(date, opts) {
|
|
432
|
+
return opts.date ? date.toLocaleTimeString() : "";
|
|
433
|
+
}
|
|
434
|
+
filterAndJoin(arr) {
|
|
435
|
+
return arr.filter(Boolean).join(" ");
|
|
436
|
+
}
|
|
437
|
+
formatLogObj(logObj, opts) {
|
|
438
|
+
const message = this.formatArgs(logObj.args, opts);
|
|
439
|
+
if (logObj.type === "box") return "\n" + [
|
|
440
|
+
bracket(logObj.tag),
|
|
441
|
+
logObj.title && logObj.title,
|
|
442
|
+
...message.split("\n")
|
|
443
|
+
].filter(Boolean).map((l) => " > " + l).join("\n") + "\n";
|
|
444
|
+
return this.filterAndJoin([
|
|
445
|
+
bracket(logObj.type),
|
|
446
|
+
bracket(logObj.tag),
|
|
447
|
+
message
|
|
448
|
+
]);
|
|
449
|
+
}
|
|
450
|
+
log(logObj, ctx) {
|
|
451
|
+
return writeStream(this.formatLogObj(logObj, {
|
|
452
|
+
columns: ctx.options.stdout.columns || 0,
|
|
453
|
+
...ctx.options.formatOptions
|
|
454
|
+
}) + "\n", logObj.level < 2 ? ctx.options.stderr || process.stderr : ctx.options.stdout || process.stdout);
|
|
455
|
+
}
|
|
456
|
+
};
|
|
457
|
+
|
|
458
|
+
//#endregion
|
|
459
|
+
//#region ../../node_modules/.bun/consola@3.4.2/node_modules/consola/dist/shared/consola.DXBYu-KD.mjs
|
|
460
|
+
const { env = {}, argv = [], platform = "" } = typeof process === "undefined" ? {} : process;
|
|
461
|
+
const isDisabled = "NO_COLOR" in env || argv.includes("--no-color");
|
|
462
|
+
const isForced = "FORCE_COLOR" in env || argv.includes("--color");
|
|
463
|
+
const isWindows = platform === "win32";
|
|
464
|
+
const isDumbTerminal = env.TERM === "dumb";
|
|
465
|
+
const isCompatibleTerminal = tty && tty.isatty && tty.isatty(1) && env.TERM && !isDumbTerminal;
|
|
466
|
+
const isCI = "CI" in env && ("GITHUB_ACTIONS" in env || "GITLAB_CI" in env || "CIRCLECI" in env);
|
|
467
|
+
const isColorSupported = !isDisabled && (isForced || isWindows && !isDumbTerminal || isCompatibleTerminal || isCI);
|
|
468
|
+
function replaceClose(index, string, close, replace, head = string.slice(0, Math.max(0, index)) + replace, tail = string.slice(Math.max(0, index + close.length)), next = tail.indexOf(close)) {
|
|
469
|
+
return head + (next < 0 ? tail : replaceClose(next, tail, close, replace));
|
|
470
|
+
}
|
|
471
|
+
function clearBleed(index, string, open, close, replace) {
|
|
472
|
+
return index < 0 ? open + string + close : open + replaceClose(index, string, close, replace) + close;
|
|
473
|
+
}
|
|
474
|
+
function filterEmpty(open, close, replace = open, at = open.length + 1) {
|
|
475
|
+
return (string) => string || !(string === "" || string === void 0) ? clearBleed(("" + string).indexOf(close, at), string, open, close, replace) : "";
|
|
476
|
+
}
|
|
477
|
+
function init(open, close, replace) {
|
|
478
|
+
return filterEmpty(`\x1B[${open}m`, `\x1B[${close}m`, replace);
|
|
479
|
+
}
|
|
480
|
+
const colorDefs = {
|
|
481
|
+
reset: init(0, 0),
|
|
482
|
+
bold: init(1, 22, "\x1B[22m\x1B[1m"),
|
|
483
|
+
dim: init(2, 22, "\x1B[22m\x1B[2m"),
|
|
484
|
+
italic: init(3, 23),
|
|
485
|
+
underline: init(4, 24),
|
|
486
|
+
inverse: init(7, 27),
|
|
487
|
+
hidden: init(8, 28),
|
|
488
|
+
strikethrough: init(9, 29),
|
|
489
|
+
black: init(30, 39),
|
|
490
|
+
red: init(31, 39),
|
|
491
|
+
green: init(32, 39),
|
|
492
|
+
yellow: init(33, 39),
|
|
493
|
+
blue: init(34, 39),
|
|
494
|
+
magenta: init(35, 39),
|
|
495
|
+
cyan: init(36, 39),
|
|
496
|
+
white: init(37, 39),
|
|
497
|
+
gray: init(90, 39),
|
|
498
|
+
bgBlack: init(40, 49),
|
|
499
|
+
bgRed: init(41, 49),
|
|
500
|
+
bgGreen: init(42, 49),
|
|
501
|
+
bgYellow: init(43, 49),
|
|
502
|
+
bgBlue: init(44, 49),
|
|
503
|
+
bgMagenta: init(45, 49),
|
|
504
|
+
bgCyan: init(46, 49),
|
|
505
|
+
bgWhite: init(47, 49),
|
|
506
|
+
blackBright: init(90, 39),
|
|
507
|
+
redBright: init(91, 39),
|
|
508
|
+
greenBright: init(92, 39),
|
|
509
|
+
yellowBright: init(93, 39),
|
|
510
|
+
blueBright: init(94, 39),
|
|
511
|
+
magentaBright: init(95, 39),
|
|
512
|
+
cyanBright: init(96, 39),
|
|
513
|
+
whiteBright: init(97, 39),
|
|
514
|
+
bgBlackBright: init(100, 49),
|
|
515
|
+
bgRedBright: init(101, 49),
|
|
516
|
+
bgGreenBright: init(102, 49),
|
|
517
|
+
bgYellowBright: init(103, 49),
|
|
518
|
+
bgBlueBright: init(104, 49),
|
|
519
|
+
bgMagentaBright: init(105, 49),
|
|
520
|
+
bgCyanBright: init(106, 49),
|
|
521
|
+
bgWhiteBright: init(107, 49)
|
|
522
|
+
};
|
|
523
|
+
function createColors(useColor = isColorSupported) {
|
|
524
|
+
return useColor ? colorDefs : Object.fromEntries(Object.keys(colorDefs).map((key) => [key, String]));
|
|
525
|
+
}
|
|
526
|
+
const colors = createColors();
|
|
527
|
+
function getColor$1(color, fallback = "reset") {
|
|
528
|
+
return colors[color] || colors[fallback];
|
|
529
|
+
}
|
|
530
|
+
const ansiRegex$1 = [String.raw`[\u001B\u009B][[\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\d\/#&.:=?%@~_]+)*|[a-zA-Z\d]+(?:;[-a-zA-Z\d\/#&.:=?%@~_]*)*)?\u0007)`, String.raw`(?:(?:\d{1,4}(?:;\d{0,4})*)?[\dA-PR-TZcf-nq-uy=><~]))`].join("|");
|
|
531
|
+
function stripAnsi$1(text) {
|
|
532
|
+
return text.replace(new RegExp(ansiRegex$1, "g"), "");
|
|
533
|
+
}
|
|
534
|
+
const boxStylePresets = {
|
|
535
|
+
solid: {
|
|
536
|
+
tl: "┌",
|
|
537
|
+
tr: "┐",
|
|
538
|
+
bl: "└",
|
|
539
|
+
br: "┘",
|
|
540
|
+
h: "─",
|
|
541
|
+
v: "│"
|
|
542
|
+
},
|
|
543
|
+
double: {
|
|
544
|
+
tl: "╔",
|
|
545
|
+
tr: "╗",
|
|
546
|
+
bl: "╚",
|
|
547
|
+
br: "╝",
|
|
548
|
+
h: "═",
|
|
549
|
+
v: "║"
|
|
550
|
+
},
|
|
551
|
+
doubleSingle: {
|
|
552
|
+
tl: "╓",
|
|
553
|
+
tr: "╖",
|
|
554
|
+
bl: "╙",
|
|
555
|
+
br: "╜",
|
|
556
|
+
h: "─",
|
|
557
|
+
v: "║"
|
|
558
|
+
},
|
|
559
|
+
doubleSingleRounded: {
|
|
560
|
+
tl: "╭",
|
|
561
|
+
tr: "╮",
|
|
562
|
+
bl: "╰",
|
|
563
|
+
br: "╯",
|
|
564
|
+
h: "─",
|
|
565
|
+
v: "║"
|
|
566
|
+
},
|
|
567
|
+
singleThick: {
|
|
568
|
+
tl: "┏",
|
|
569
|
+
tr: "┓",
|
|
570
|
+
bl: "┗",
|
|
571
|
+
br: "┛",
|
|
572
|
+
h: "━",
|
|
573
|
+
v: "┃"
|
|
574
|
+
},
|
|
575
|
+
singleDouble: {
|
|
576
|
+
tl: "╒",
|
|
577
|
+
tr: "╕",
|
|
578
|
+
bl: "╘",
|
|
579
|
+
br: "╛",
|
|
580
|
+
h: "═",
|
|
581
|
+
v: "│"
|
|
582
|
+
},
|
|
583
|
+
singleDoubleRounded: {
|
|
584
|
+
tl: "╭",
|
|
585
|
+
tr: "╮",
|
|
586
|
+
bl: "╰",
|
|
587
|
+
br: "╯",
|
|
588
|
+
h: "═",
|
|
589
|
+
v: "│"
|
|
590
|
+
},
|
|
591
|
+
rounded: {
|
|
592
|
+
tl: "╭",
|
|
593
|
+
tr: "╮",
|
|
594
|
+
bl: "╰",
|
|
595
|
+
br: "╯",
|
|
596
|
+
h: "─",
|
|
597
|
+
v: "│"
|
|
598
|
+
}
|
|
599
|
+
};
|
|
600
|
+
const defaultStyle = {
|
|
601
|
+
borderColor: "white",
|
|
602
|
+
borderStyle: "rounded",
|
|
603
|
+
valign: "center",
|
|
604
|
+
padding: 2,
|
|
605
|
+
marginLeft: 1,
|
|
606
|
+
marginTop: 1,
|
|
607
|
+
marginBottom: 1
|
|
608
|
+
};
|
|
609
|
+
function box(text, _opts = {}) {
|
|
610
|
+
const opts = {
|
|
611
|
+
..._opts,
|
|
612
|
+
style: {
|
|
613
|
+
...defaultStyle,
|
|
614
|
+
..._opts.style
|
|
615
|
+
}
|
|
616
|
+
};
|
|
617
|
+
const textLines = text.split("\n");
|
|
618
|
+
const boxLines = [];
|
|
619
|
+
const _color = getColor$1(opts.style.borderColor);
|
|
620
|
+
const borderStyle = { ...typeof opts.style.borderStyle === "string" ? boxStylePresets[opts.style.borderStyle] || boxStylePresets.solid : opts.style.borderStyle };
|
|
621
|
+
if (_color) for (const key in borderStyle) borderStyle[key] = _color(borderStyle[key]);
|
|
622
|
+
const paddingOffset = opts.style.padding % 2 === 0 ? opts.style.padding : opts.style.padding + 1;
|
|
623
|
+
const height = textLines.length + paddingOffset;
|
|
624
|
+
const width = Math.max(...textLines.map((line) => stripAnsi$1(line).length), opts.title ? stripAnsi$1(opts.title).length : 0) + paddingOffset;
|
|
625
|
+
const widthOffset = width + paddingOffset;
|
|
626
|
+
const leftSpace = opts.style.marginLeft > 0 ? " ".repeat(opts.style.marginLeft) : "";
|
|
627
|
+
if (opts.style.marginTop > 0) boxLines.push("".repeat(opts.style.marginTop));
|
|
628
|
+
if (opts.title) {
|
|
629
|
+
const title = _color ? _color(opts.title) : opts.title;
|
|
630
|
+
const left = borderStyle.h.repeat(Math.floor((width - stripAnsi$1(opts.title).length) / 2));
|
|
631
|
+
const right = borderStyle.h.repeat(width - stripAnsi$1(opts.title).length - stripAnsi$1(left).length + paddingOffset);
|
|
632
|
+
boxLines.push(`${leftSpace}${borderStyle.tl}${left}${title}${right}${borderStyle.tr}`);
|
|
633
|
+
} else boxLines.push(`${leftSpace}${borderStyle.tl}${borderStyle.h.repeat(widthOffset)}${borderStyle.tr}`);
|
|
634
|
+
const valignOffset = opts.style.valign === "center" ? Math.floor((height - textLines.length) / 2) : opts.style.valign === "top" ? height - textLines.length - paddingOffset : height - textLines.length;
|
|
635
|
+
for (let i = 0; i < height; i++) if (i < valignOffset || i >= valignOffset + textLines.length) boxLines.push(`${leftSpace}${borderStyle.v}${" ".repeat(widthOffset)}${borderStyle.v}`);
|
|
636
|
+
else {
|
|
637
|
+
const line = textLines[i - valignOffset];
|
|
638
|
+
const left = " ".repeat(paddingOffset);
|
|
639
|
+
const right = " ".repeat(width - stripAnsi$1(line).length);
|
|
640
|
+
boxLines.push(`${leftSpace}${borderStyle.v}${left}${line}${right}${borderStyle.v}`);
|
|
641
|
+
}
|
|
642
|
+
boxLines.push(`${leftSpace}${borderStyle.bl}${borderStyle.h.repeat(widthOffset)}${borderStyle.br}`);
|
|
643
|
+
if (opts.style.marginBottom > 0) boxLines.push("".repeat(opts.style.marginBottom));
|
|
644
|
+
return boxLines.join("\n");
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
//#endregion
|
|
648
|
+
//#region ../../node_modules/.bun/consola@3.4.2/node_modules/consola/dist/index.mjs
|
|
649
|
+
const r = Object.create(null), i = (e) => globalThis.process?.env || import.meta.env || globalThis.Deno?.env.toObject() || globalThis.__env__ || (e ? r : globalThis), o = new Proxy(r, {
|
|
650
|
+
get(e, s) {
|
|
651
|
+
return i()[s] ?? r[s];
|
|
652
|
+
},
|
|
653
|
+
has(e, s) {
|
|
654
|
+
return s in i() || s in r;
|
|
655
|
+
},
|
|
656
|
+
set(e, s, E) {
|
|
657
|
+
const B = i(true);
|
|
658
|
+
return B[s] = E, true;
|
|
659
|
+
},
|
|
660
|
+
deleteProperty(e, s) {
|
|
661
|
+
if (!s) return false;
|
|
662
|
+
const E = i(true);
|
|
663
|
+
return delete E[s], true;
|
|
664
|
+
},
|
|
665
|
+
ownKeys() {
|
|
666
|
+
const e = i(true);
|
|
667
|
+
return Object.keys(e);
|
|
668
|
+
}
|
|
669
|
+
}), t = typeof process < "u" && process.env && process.env.NODE_ENV || "", f = [
|
|
670
|
+
["APPVEYOR"],
|
|
671
|
+
[
|
|
672
|
+
"AWS_AMPLIFY",
|
|
673
|
+
"AWS_APP_ID",
|
|
674
|
+
{ ci: true }
|
|
675
|
+
],
|
|
676
|
+
["AZURE_PIPELINES", "SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"],
|
|
677
|
+
["AZURE_STATIC", "INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN"],
|
|
678
|
+
["APPCIRCLE", "AC_APPCIRCLE"],
|
|
679
|
+
["BAMBOO", "bamboo_planKey"],
|
|
680
|
+
["BITBUCKET", "BITBUCKET_COMMIT"],
|
|
681
|
+
["BITRISE", "BITRISE_IO"],
|
|
682
|
+
["BUDDY", "BUDDY_WORKSPACE_ID"],
|
|
683
|
+
["BUILDKITE"],
|
|
684
|
+
["CIRCLE", "CIRCLECI"],
|
|
685
|
+
["CIRRUS", "CIRRUS_CI"],
|
|
686
|
+
[
|
|
687
|
+
"CLOUDFLARE_PAGES",
|
|
688
|
+
"CF_PAGES",
|
|
689
|
+
{ ci: true }
|
|
690
|
+
],
|
|
691
|
+
["CODEBUILD", "CODEBUILD_BUILD_ARN"],
|
|
692
|
+
["CODEFRESH", "CF_BUILD_ID"],
|
|
693
|
+
["DRONE"],
|
|
694
|
+
["DRONE", "DRONE_BUILD_EVENT"],
|
|
695
|
+
["DSARI"],
|
|
696
|
+
["GITHUB_ACTIONS"],
|
|
697
|
+
["GITLAB", "GITLAB_CI"],
|
|
698
|
+
["GITLAB", "CI_MERGE_REQUEST_ID"],
|
|
699
|
+
["GOCD", "GO_PIPELINE_LABEL"],
|
|
700
|
+
["LAYERCI"],
|
|
701
|
+
["HUDSON", "HUDSON_URL"],
|
|
702
|
+
["JENKINS", "JENKINS_URL"],
|
|
703
|
+
["MAGNUM"],
|
|
704
|
+
["NETLIFY"],
|
|
705
|
+
[
|
|
706
|
+
"NETLIFY",
|
|
707
|
+
"NETLIFY_LOCAL",
|
|
708
|
+
{ ci: false }
|
|
709
|
+
],
|
|
710
|
+
["NEVERCODE"],
|
|
711
|
+
["RENDER"],
|
|
712
|
+
["SAIL", "SAILCI"],
|
|
713
|
+
["SEMAPHORE"],
|
|
714
|
+
["SCREWDRIVER"],
|
|
715
|
+
["SHIPPABLE"],
|
|
716
|
+
["SOLANO", "TDDIUM"],
|
|
717
|
+
["STRIDER"],
|
|
718
|
+
["TEAMCITY", "TEAMCITY_VERSION"],
|
|
719
|
+
["TRAVIS"],
|
|
720
|
+
["VERCEL", "NOW_BUILDER"],
|
|
721
|
+
[
|
|
722
|
+
"VERCEL",
|
|
723
|
+
"VERCEL",
|
|
724
|
+
{ ci: false }
|
|
725
|
+
],
|
|
726
|
+
[
|
|
727
|
+
"VERCEL",
|
|
728
|
+
"VERCEL_ENV",
|
|
729
|
+
{ ci: false }
|
|
730
|
+
],
|
|
731
|
+
["APPCENTER", "APPCENTER_BUILD_ID"],
|
|
732
|
+
[
|
|
733
|
+
"CODESANDBOX",
|
|
734
|
+
"CODESANDBOX_SSE",
|
|
735
|
+
{ ci: false }
|
|
736
|
+
],
|
|
737
|
+
[
|
|
738
|
+
"CODESANDBOX",
|
|
739
|
+
"CODESANDBOX_HOST",
|
|
740
|
+
{ ci: false }
|
|
741
|
+
],
|
|
742
|
+
["STACKBLITZ"],
|
|
743
|
+
["STORMKIT"],
|
|
744
|
+
["CLEAVR"],
|
|
745
|
+
["ZEABUR"],
|
|
746
|
+
[
|
|
747
|
+
"CODESPHERE",
|
|
748
|
+
"CODESPHERE_APP_ID",
|
|
749
|
+
{ ci: true }
|
|
750
|
+
],
|
|
751
|
+
["RAILWAY", "RAILWAY_PROJECT_ID"],
|
|
752
|
+
["RAILWAY", "RAILWAY_SERVICE_ID"],
|
|
753
|
+
["DENO-DEPLOY", "DENO_DEPLOYMENT_ID"],
|
|
754
|
+
[
|
|
755
|
+
"FIREBASE_APP_HOSTING",
|
|
756
|
+
"FIREBASE_APP_HOSTING",
|
|
757
|
+
{ ci: true }
|
|
758
|
+
]
|
|
759
|
+
];
|
|
760
|
+
function b() {
|
|
761
|
+
if (globalThis.process?.env) for (const e of f) {
|
|
762
|
+
const s = e[1] || e[0];
|
|
763
|
+
if (globalThis.process?.env[s]) return {
|
|
764
|
+
name: e[0].toLowerCase(),
|
|
765
|
+
...e[2]
|
|
766
|
+
};
|
|
767
|
+
}
|
|
768
|
+
return globalThis.process?.env?.SHELL === "/bin/jsh" && globalThis.process?.versions?.webcontainer ? {
|
|
769
|
+
name: "stackblitz",
|
|
770
|
+
ci: false
|
|
771
|
+
} : {
|
|
772
|
+
name: "",
|
|
773
|
+
ci: false
|
|
774
|
+
};
|
|
775
|
+
}
|
|
776
|
+
const l = b();
|
|
777
|
+
l.name;
|
|
778
|
+
function n(e) {
|
|
779
|
+
return e ? e !== "false" : false;
|
|
780
|
+
}
|
|
781
|
+
const I$1 = globalThis.process?.platform || "", T$1 = n(o.CI) || l.ci !== false, a = n(globalThis.process?.stdout && globalThis.process?.stdout.isTTY), g = n(o.DEBUG), R$1 = t === "test" || n(o.TEST);
|
|
782
|
+
n(o.MINIMAL);
|
|
783
|
+
const A = /^win/i.test(I$1);
|
|
784
|
+
!n(o.NO_COLOR) && (n(o.FORCE_COLOR) || (a || A) && o.TERM);
|
|
785
|
+
const C$1 = (globalThis.process?.versions?.node || "").replace(/^v/, "") || null;
|
|
786
|
+
Number(C$1?.split(".")[0]);
|
|
787
|
+
const y$1 = globalThis.process || Object.create(null), _$1 = { versions: {} };
|
|
788
|
+
new Proxy(y$1, { get(e, s) {
|
|
789
|
+
if (s === "env") return o;
|
|
790
|
+
if (s in e) return e[s];
|
|
791
|
+
if (s in _$1) return _$1[s];
|
|
792
|
+
} });
|
|
793
|
+
const c = globalThis.process?.release?.name === "node", O$1 = !!globalThis.Bun || !!globalThis.process?.versions?.bun, D$1 = !!globalThis.Deno, L$1 = !!globalThis.fastly, S$1 = !!globalThis.Netlify, u = !!globalThis.EdgeRuntime, N$2 = globalThis.navigator?.userAgent === "Cloudflare-Workers", F = [
|
|
794
|
+
[S$1, "netlify"],
|
|
795
|
+
[u, "edge-light"],
|
|
796
|
+
[N$2, "workerd"],
|
|
797
|
+
[L$1, "fastly"],
|
|
798
|
+
[D$1, "deno"],
|
|
799
|
+
[O$1, "bun"],
|
|
800
|
+
[c, "node"]
|
|
801
|
+
];
|
|
802
|
+
function G$1() {
|
|
803
|
+
const e = F.find((s) => s[0]);
|
|
804
|
+
if (e) return { name: e[1] };
|
|
805
|
+
}
|
|
806
|
+
G$1()?.name;
|
|
807
|
+
function ansiRegex({ onlyFirst = false } = {}) {
|
|
808
|
+
const pattern = [`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))`, "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");
|
|
809
|
+
return new RegExp(pattern, onlyFirst ? void 0 : "g");
|
|
810
|
+
}
|
|
811
|
+
const regex = ansiRegex();
|
|
812
|
+
function stripAnsi(string) {
|
|
813
|
+
if (typeof string !== "string") throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
|
|
814
|
+
return string.replace(regex, "");
|
|
815
|
+
}
|
|
816
|
+
function isAmbiguous(x) {
|
|
817
|
+
return x === 161 || x === 164 || x === 167 || x === 168 || x === 170 || x === 173 || x === 174 || x >= 176 && x <= 180 || x >= 182 && x <= 186 || x >= 188 && x <= 191 || x === 198 || x === 208 || x === 215 || x === 216 || x >= 222 && x <= 225 || x === 230 || x >= 232 && x <= 234 || x === 236 || x === 237 || x === 240 || x === 242 || x === 243 || x >= 247 && x <= 250 || x === 252 || x === 254 || x === 257 || x === 273 || x === 275 || x === 283 || x === 294 || x === 295 || x === 299 || x >= 305 && x <= 307 || x === 312 || x >= 319 && x <= 322 || x === 324 || x >= 328 && x <= 331 || x === 333 || x === 338 || x === 339 || x === 358 || x === 359 || x === 363 || x === 462 || x === 464 || x === 466 || x === 468 || x === 470 || x === 472 || x === 474 || x === 476 || x === 593 || x === 609 || x === 708 || x === 711 || x >= 713 && x <= 715 || x === 717 || x === 720 || x >= 728 && x <= 731 || x === 733 || x === 735 || x >= 768 && x <= 879 || x >= 913 && x <= 929 || x >= 931 && x <= 937 || x >= 945 && x <= 961 || x >= 963 && x <= 969 || x === 1025 || x >= 1040 && x <= 1103 || x === 1105 || x === 8208 || x >= 8211 && x <= 8214 || x === 8216 || x === 8217 || x === 8220 || x === 8221 || x >= 8224 && x <= 8226 || x >= 8228 && x <= 8231 || x === 8240 || x === 8242 || x === 8243 || x === 8245 || x === 8251 || x === 8254 || x === 8308 || x === 8319 || x >= 8321 && x <= 8324 || x === 8364 || x === 8451 || x === 8453 || x === 8457 || x === 8467 || x === 8470 || x === 8481 || x === 8482 || x === 8486 || x === 8491 || x === 8531 || x === 8532 || x >= 8539 && x <= 8542 || x >= 8544 && x <= 8555 || x >= 8560 && x <= 8569 || x === 8585 || x >= 8592 && x <= 8601 || x === 8632 || x === 8633 || x === 8658 || x === 8660 || x === 8679 || x === 8704 || x === 8706 || x === 8707 || x === 8711 || x === 8712 || x === 8715 || x === 8719 || x === 8721 || x === 8725 || x === 8730 || x >= 8733 && x <= 8736 || x === 8739 || x === 8741 || x >= 8743 && x <= 8748 || x === 8750 || x >= 8756 && x <= 8759 || x === 8764 || x === 8765 || x === 8776 || x === 8780 || x === 8786 || x === 8800 || x === 8801 || x >= 8804 && x <= 8807 || x === 8810 || x === 8811 || x === 8814 || x === 8815 || x === 8834 || x === 8835 || x === 8838 || x === 8839 || x === 8853 || x === 8857 || x === 8869 || x === 8895 || x === 8978 || x >= 9312 && x <= 9449 || x >= 9451 && x <= 9547 || x >= 9552 && x <= 9587 || x >= 9600 && x <= 9615 || x >= 9618 && x <= 9621 || x === 9632 || x === 9633 || x >= 9635 && x <= 9641 || x === 9650 || x === 9651 || x === 9654 || x === 9655 || x === 9660 || x === 9661 || x === 9664 || x === 9665 || x >= 9670 && x <= 9672 || x === 9675 || x >= 9678 && x <= 9681 || x >= 9698 && x <= 9701 || x === 9711 || x === 9733 || x === 9734 || x === 9737 || x === 9742 || x === 9743 || x === 9756 || x === 9758 || x === 9792 || x === 9794 || x === 9824 || x === 9825 || x >= 9827 && x <= 9829 || x >= 9831 && x <= 9834 || x === 9836 || x === 9837 || x === 9839 || x === 9886 || x === 9887 || x === 9919 || x >= 9926 && x <= 9933 || x >= 9935 && x <= 9939 || x >= 9941 && x <= 9953 || x === 9955 || x === 9960 || x === 9961 || x >= 9963 && x <= 9969 || x === 9972 || x >= 9974 && x <= 9977 || x === 9979 || x === 9980 || x === 9982 || x === 9983 || x === 10045 || x >= 10102 && x <= 10111 || x >= 11094 && x <= 11097 || x >= 12872 && x <= 12879 || x >= 57344 && x <= 63743 || x >= 65024 && x <= 65039 || x === 65533 || x >= 127232 && x <= 127242 || x >= 127248 && x <= 127277 || x >= 127280 && x <= 127337 || x >= 127344 && x <= 127373 || x === 127375 || x === 127376 || x >= 127387 && x <= 127404 || x >= 917760 && x <= 917999 || x >= 983040 && x <= 1048573 || x >= 1048576 && x <= 1114109;
|
|
818
|
+
}
|
|
819
|
+
function isFullWidth(x) {
|
|
820
|
+
return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
|
|
821
|
+
}
|
|
822
|
+
function isWide(x) {
|
|
823
|
+
return x >= 4352 && x <= 4447 || x === 8986 || x === 8987 || x === 9001 || x === 9002 || x >= 9193 && x <= 9196 || x === 9200 || x === 9203 || x === 9725 || x === 9726 || x === 9748 || x === 9749 || x >= 9776 && x <= 9783 || x >= 9800 && x <= 9811 || x === 9855 || x >= 9866 && x <= 9871 || x === 9875 || x === 9889 || x === 9898 || x === 9899 || x === 9917 || x === 9918 || x === 9924 || x === 9925 || x === 9934 || x === 9940 || x === 9962 || x === 9970 || x === 9971 || x === 9973 || x === 9978 || x === 9981 || x === 9989 || x === 9994 || x === 9995 || x === 10024 || x === 10060 || x === 10062 || x >= 10067 && x <= 10069 || x === 10071 || x >= 10133 && x <= 10135 || x === 10160 || x === 10175 || x === 11035 || x === 11036 || x === 11088 || x === 11093 || x >= 11904 && x <= 11929 || x >= 11931 && x <= 12019 || x >= 12032 && x <= 12245 || x >= 12272 && x <= 12287 || x >= 12289 && x <= 12350 || x >= 12353 && x <= 12438 || x >= 12441 && x <= 12543 || x >= 12549 && x <= 12591 || x >= 12593 && x <= 12686 || x >= 12688 && x <= 12773 || x >= 12783 && x <= 12830 || x >= 12832 && x <= 12871 || x >= 12880 && x <= 42124 || x >= 42128 && x <= 42182 || x >= 43360 && x <= 43388 || x >= 44032 && x <= 55203 || x >= 63744 && x <= 64255 || x >= 65040 && x <= 65049 || x >= 65072 && x <= 65106 || x >= 65108 && x <= 65126 || x >= 65128 && x <= 65131 || x >= 94176 && x <= 94180 || x === 94192 || x === 94193 || x >= 94208 && x <= 100343 || x >= 100352 && x <= 101589 || x >= 101631 && x <= 101640 || x >= 110576 && x <= 110579 || x >= 110581 && x <= 110587 || x === 110589 || x === 110590 || x >= 110592 && x <= 110882 || x === 110898 || x >= 110928 && x <= 110930 || x === 110933 || x >= 110948 && x <= 110951 || x >= 110960 && x <= 111355 || x >= 119552 && x <= 119638 || x >= 119648 && x <= 119670 || x === 126980 || x === 127183 || x === 127374 || x >= 127377 && x <= 127386 || x >= 127488 && x <= 127490 || x >= 127504 && x <= 127547 || x >= 127552 && x <= 127560 || x === 127568 || x === 127569 || x >= 127584 && x <= 127589 || x >= 127744 && x <= 127776 || x >= 127789 && x <= 127797 || x >= 127799 && x <= 127868 || x >= 127870 && x <= 127891 || x >= 127904 && x <= 127946 || x >= 127951 && x <= 127955 || x >= 127968 && x <= 127984 || x === 127988 || x >= 127992 && x <= 128062 || x === 128064 || x >= 128066 && x <= 128252 || x >= 128255 && x <= 128317 || x >= 128331 && x <= 128334 || x >= 128336 && x <= 128359 || x === 128378 || x === 128405 || x === 128406 || x === 128420 || x >= 128507 && x <= 128591 || x >= 128640 && x <= 128709 || x === 128716 || x >= 128720 && x <= 128722 || x >= 128725 && x <= 128727 || x >= 128732 && x <= 128735 || x === 128747 || x === 128748 || x >= 128756 && x <= 128764 || x >= 128992 && x <= 129003 || x === 129008 || x >= 129292 && x <= 129338 || x >= 129340 && x <= 129349 || x >= 129351 && x <= 129535 || x >= 129648 && x <= 129660 || x >= 129664 && x <= 129673 || x >= 129679 && x <= 129734 || x >= 129742 && x <= 129756 || x >= 129759 && x <= 129769 || x >= 129776 && x <= 129784 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
|
|
824
|
+
}
|
|
825
|
+
function validate(codePoint) {
|
|
826
|
+
if (!Number.isSafeInteger(codePoint)) throw new TypeError(`Expected a code point, got \`${typeof codePoint}\`.`);
|
|
827
|
+
}
|
|
828
|
+
function eastAsianWidth(codePoint, { ambiguousAsWide = false } = {}) {
|
|
829
|
+
validate(codePoint);
|
|
830
|
+
if (isFullWidth(codePoint) || isWide(codePoint) || ambiguousAsWide && isAmbiguous(codePoint)) return 2;
|
|
831
|
+
return 1;
|
|
832
|
+
}
|
|
833
|
+
const emojiRegex = () => {
|
|
834
|
+
return /[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE])))?))?|\uDC6F(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE89\uDE8F-\uDEC2\uDEC6\uDECE-\uDEDC\uDEDF-\uDEE9]|\uDD3C(?:\u200D[\u2640\u2642]\uFE0F?|\uD83C[\uDFFB-\uDFFF])?|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g;
|
|
835
|
+
};
|
|
836
|
+
const segmenter = globalThis.Intl?.Segmenter ? new Intl.Segmenter() : { segment: (str) => str.split("") };
|
|
837
|
+
const defaultIgnorableCodePointRegex = /^\p{Default_Ignorable_Code_Point}$/u;
|
|
838
|
+
function stringWidth$1(string, options = {}) {
|
|
839
|
+
if (typeof string !== "string" || string.length === 0) return 0;
|
|
840
|
+
const { ambiguousIsNarrow = true, countAnsiEscapeCodes = false } = options;
|
|
841
|
+
if (!countAnsiEscapeCodes) string = stripAnsi(string);
|
|
842
|
+
if (string.length === 0) return 0;
|
|
843
|
+
let width = 0;
|
|
844
|
+
const eastAsianWidthOptions = { ambiguousAsWide: !ambiguousIsNarrow };
|
|
845
|
+
for (const { segment: character } of segmenter.segment(string)) {
|
|
846
|
+
const codePoint = character.codePointAt(0);
|
|
847
|
+
if (codePoint <= 31 || codePoint >= 127 && codePoint <= 159) continue;
|
|
848
|
+
if (codePoint >= 8203 && codePoint <= 8207 || codePoint === 65279) continue;
|
|
849
|
+
if (codePoint >= 768 && codePoint <= 879 || codePoint >= 6832 && codePoint <= 6911 || codePoint >= 7616 && codePoint <= 7679 || codePoint >= 8400 && codePoint <= 8447 || codePoint >= 65056 && codePoint <= 65071) continue;
|
|
850
|
+
if (codePoint >= 55296 && codePoint <= 57343) continue;
|
|
851
|
+
if (codePoint >= 65024 && codePoint <= 65039) continue;
|
|
852
|
+
if (defaultIgnorableCodePointRegex.test(character)) continue;
|
|
853
|
+
if (emojiRegex().test(character)) {
|
|
854
|
+
width += 2;
|
|
855
|
+
continue;
|
|
856
|
+
}
|
|
857
|
+
width += eastAsianWidth(codePoint, eastAsianWidthOptions);
|
|
858
|
+
}
|
|
859
|
+
return width;
|
|
860
|
+
}
|
|
861
|
+
function isUnicodeSupported() {
|
|
862
|
+
const { env } = N;
|
|
863
|
+
const { TERM, TERM_PROGRAM } = env;
|
|
864
|
+
if (N.platform !== "win32") return TERM !== "linux";
|
|
865
|
+
return Boolean(env.WT_SESSION) || Boolean(env.TERMINUS_SUBLIME) || env.ConEmuTask === "{cmd::Cmder}" || TERM_PROGRAM === "Terminus-Sublime" || TERM_PROGRAM === "vscode" || TERM === "xterm-256color" || TERM === "alacritty" || TERM === "rxvt-unicode" || TERM === "rxvt-unicode-256color" || env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
866
|
+
}
|
|
867
|
+
const TYPE_COLOR_MAP = {
|
|
868
|
+
info: "cyan",
|
|
869
|
+
fail: "red",
|
|
870
|
+
success: "green",
|
|
871
|
+
ready: "green",
|
|
872
|
+
start: "magenta"
|
|
873
|
+
};
|
|
874
|
+
const LEVEL_COLOR_MAP = {
|
|
875
|
+
0: "red",
|
|
876
|
+
1: "yellow"
|
|
877
|
+
};
|
|
878
|
+
const unicode = isUnicodeSupported();
|
|
879
|
+
const s = (c, fallback) => unicode ? c : fallback;
|
|
880
|
+
const TYPE_ICONS = {
|
|
881
|
+
error: s("✖", "×"),
|
|
882
|
+
fatal: s("✖", "×"),
|
|
883
|
+
ready: s("✔", "√"),
|
|
884
|
+
warn: s("⚠", "‼"),
|
|
885
|
+
info: s("ℹ", "i"),
|
|
886
|
+
success: s("✔", "√"),
|
|
887
|
+
debug: s("⚙", "D"),
|
|
888
|
+
trace: s("→", "→"),
|
|
889
|
+
fail: s("✖", "×"),
|
|
890
|
+
start: s("◐", "o"),
|
|
891
|
+
log: ""
|
|
892
|
+
};
|
|
893
|
+
function stringWidth(str) {
|
|
894
|
+
if (!(typeof Intl === "object") || !Intl.Segmenter) return stripAnsi$1(str).length;
|
|
895
|
+
return stringWidth$1(str);
|
|
896
|
+
}
|
|
897
|
+
var FancyReporter = class extends BasicReporter {
|
|
898
|
+
formatStack(stack, message, opts) {
|
|
899
|
+
const indent = " ".repeat((opts?.errorLevel || 0) + 1);
|
|
900
|
+
return `
|
|
901
|
+
${indent}` + parseStack(stack, message).map((line) => " " + line.replace(/^at +/, (m) => colors.gray(m)).replace(/\((.+)\)/, (_, m) => `(${colors.cyan(m)})`)).join(`
|
|
902
|
+
${indent}`);
|
|
903
|
+
}
|
|
904
|
+
formatType(logObj, isBadge, opts) {
|
|
905
|
+
const typeColor = TYPE_COLOR_MAP[logObj.type] || LEVEL_COLOR_MAP[logObj.level] || "gray";
|
|
906
|
+
if (isBadge) return getBgColor(typeColor)(colors.black(` ${logObj.type.toUpperCase()} `));
|
|
907
|
+
const _type = typeof TYPE_ICONS[logObj.type] === "string" ? TYPE_ICONS[logObj.type] : logObj.icon || logObj.type;
|
|
908
|
+
return _type ? getColor(typeColor)(_type) : "";
|
|
909
|
+
}
|
|
910
|
+
formatLogObj(logObj, opts) {
|
|
911
|
+
const [message, ...additional] = this.formatArgs(logObj.args, opts).split("\n");
|
|
912
|
+
if (logObj.type === "box") return box(characterFormat(message + (additional.length > 0 ? "\n" + additional.join("\n") : "")), {
|
|
913
|
+
title: logObj.title ? characterFormat(logObj.title) : void 0,
|
|
914
|
+
style: logObj.style
|
|
915
|
+
});
|
|
916
|
+
const date = this.formatDate(logObj.date, opts);
|
|
917
|
+
const coloredDate = date && colors.gray(date);
|
|
918
|
+
const isBadge = logObj.badge ?? logObj.level < 2;
|
|
919
|
+
const type = this.formatType(logObj, isBadge, opts);
|
|
920
|
+
const tag = logObj.tag ? colors.gray(logObj.tag) : "";
|
|
921
|
+
let line;
|
|
922
|
+
const left = this.filterAndJoin([type, characterFormat(message)]);
|
|
923
|
+
const right = this.filterAndJoin(opts.columns ? [tag, coloredDate] : [tag]);
|
|
924
|
+
const space = (opts.columns || 0) - stringWidth(left) - stringWidth(right) - 2;
|
|
925
|
+
line = space > 0 && (opts.columns || 0) >= 80 ? left + " ".repeat(space) + right : (right ? `${colors.gray(`[${right}]`)} ` : "") + left;
|
|
926
|
+
line += characterFormat(additional.length > 0 ? "\n" + additional.join("\n") : "");
|
|
927
|
+
if (logObj.type === "trace") {
|
|
928
|
+
const _err = /* @__PURE__ */ new Error("Trace: " + logObj.message);
|
|
929
|
+
line += this.formatStack(_err.stack || "", _err.message);
|
|
930
|
+
}
|
|
931
|
+
return isBadge ? "\n" + line + "\n" : line;
|
|
932
|
+
}
|
|
933
|
+
};
|
|
934
|
+
function characterFormat(str) {
|
|
935
|
+
return str.replace(/`([^`]+)`/gm, (_, m) => colors.cyan(m)).replace(/\s+_([^_]+)_\s+/gm, (_, m) => ` ${colors.underline(m)} `);
|
|
936
|
+
}
|
|
937
|
+
function getColor(color = "white") {
|
|
938
|
+
return colors[color] || colors.white;
|
|
939
|
+
}
|
|
940
|
+
function getBgColor(color = "bgWhite") {
|
|
941
|
+
return colors[`bg${color[0].toUpperCase()}${color.slice(1)}`] || colors.bgWhite;
|
|
942
|
+
}
|
|
943
|
+
function createConsola(options = {}) {
|
|
944
|
+
let level = _getDefaultLogLevel();
|
|
945
|
+
if (process.env.CONSOLA_LEVEL) level = Number.parseInt(process.env.CONSOLA_LEVEL) ?? level;
|
|
946
|
+
return createConsola$1({
|
|
947
|
+
level,
|
|
948
|
+
defaults: { level },
|
|
949
|
+
stdout: process.stdout,
|
|
950
|
+
stderr: process.stderr,
|
|
951
|
+
prompt: (...args) => import("./prompt-DXfUeR3X.mjs").then((m) => m.prompt(...args)),
|
|
952
|
+
reporters: options.reporters || [options.fancy ?? !(T$1 || R$1) ? new FancyReporter() : new BasicReporter()],
|
|
953
|
+
...options
|
|
954
|
+
});
|
|
955
|
+
}
|
|
956
|
+
function _getDefaultLogLevel() {
|
|
957
|
+
if (g) return LogLevels.debug;
|
|
958
|
+
if (R$1) return LogLevels.warn;
|
|
959
|
+
return LogLevels.info;
|
|
960
|
+
}
|
|
961
|
+
const consola = createConsola();
|
|
962
|
+
|
|
963
|
+
//#endregion
|
|
964
|
+
//#region ../../node_modules/.bun/citty@0.1.6/node_modules/citty/dist/index.mjs
|
|
965
|
+
function toArray(val) {
|
|
966
|
+
if (Array.isArray(val)) return val;
|
|
967
|
+
return val === void 0 ? [] : [val];
|
|
968
|
+
}
|
|
969
|
+
function formatLineColumns(lines, linePrefix = "") {
|
|
970
|
+
const maxLengh = [];
|
|
971
|
+
for (const line of lines) for (const [i, element] of line.entries()) maxLengh[i] = Math.max(maxLengh[i] || 0, element.length);
|
|
972
|
+
return lines.map((l) => l.map((c, i) => linePrefix + c[i === 0 ? "padStart" : "padEnd"](maxLengh[i])).join(" ")).join("\n");
|
|
973
|
+
}
|
|
974
|
+
function resolveValue(input) {
|
|
975
|
+
return typeof input === "function" ? input() : input;
|
|
976
|
+
}
|
|
977
|
+
var CLIError = class extends Error {
|
|
978
|
+
constructor(message, code) {
|
|
979
|
+
super(message);
|
|
980
|
+
this.code = code;
|
|
981
|
+
this.name = "CLIError";
|
|
982
|
+
}
|
|
983
|
+
};
|
|
984
|
+
const NUMBER_CHAR_RE = /\d/;
|
|
985
|
+
const STR_SPLITTERS = [
|
|
986
|
+
"-",
|
|
987
|
+
"_",
|
|
988
|
+
"/",
|
|
989
|
+
"."
|
|
990
|
+
];
|
|
991
|
+
function isUppercase(char = "") {
|
|
992
|
+
if (NUMBER_CHAR_RE.test(char)) return;
|
|
993
|
+
return char !== char.toLowerCase();
|
|
994
|
+
}
|
|
995
|
+
function splitByCase(str, separators) {
|
|
996
|
+
const splitters = separators ?? STR_SPLITTERS;
|
|
997
|
+
const parts = [];
|
|
998
|
+
if (!str || typeof str !== "string") return parts;
|
|
999
|
+
let buff = "";
|
|
1000
|
+
let previousUpper;
|
|
1001
|
+
let previousSplitter;
|
|
1002
|
+
for (const char of str) {
|
|
1003
|
+
const isSplitter = splitters.includes(char);
|
|
1004
|
+
if (isSplitter === true) {
|
|
1005
|
+
parts.push(buff);
|
|
1006
|
+
buff = "";
|
|
1007
|
+
previousUpper = void 0;
|
|
1008
|
+
continue;
|
|
1009
|
+
}
|
|
1010
|
+
const isUpper = isUppercase(char);
|
|
1011
|
+
if (previousSplitter === false) {
|
|
1012
|
+
if (previousUpper === false && isUpper === true) {
|
|
1013
|
+
parts.push(buff);
|
|
1014
|
+
buff = char;
|
|
1015
|
+
previousUpper = isUpper;
|
|
1016
|
+
continue;
|
|
1017
|
+
}
|
|
1018
|
+
if (previousUpper === true && isUpper === false && buff.length > 1) {
|
|
1019
|
+
const lastChar = buff.at(-1);
|
|
1020
|
+
parts.push(buff.slice(0, Math.max(0, buff.length - 1)));
|
|
1021
|
+
buff = lastChar + char;
|
|
1022
|
+
previousUpper = isUpper;
|
|
1023
|
+
continue;
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1026
|
+
buff += char;
|
|
1027
|
+
previousUpper = isUpper;
|
|
1028
|
+
previousSplitter = isSplitter;
|
|
1029
|
+
}
|
|
1030
|
+
parts.push(buff);
|
|
1031
|
+
return parts;
|
|
1032
|
+
}
|
|
1033
|
+
function upperFirst(str) {
|
|
1034
|
+
return str ? str[0].toUpperCase() + str.slice(1) : "";
|
|
1035
|
+
}
|
|
1036
|
+
function lowerFirst(str) {
|
|
1037
|
+
return str ? str[0].toLowerCase() + str.slice(1) : "";
|
|
1038
|
+
}
|
|
1039
|
+
function pascalCase(str, opts) {
|
|
1040
|
+
return str ? (Array.isArray(str) ? str : splitByCase(str)).map((p) => upperFirst(opts?.normalize ? p.toLowerCase() : p)).join("") : "";
|
|
1041
|
+
}
|
|
1042
|
+
function camelCase(str, opts) {
|
|
1043
|
+
return lowerFirst(pascalCase(str || "", opts));
|
|
1044
|
+
}
|
|
1045
|
+
function kebabCase(str, joiner) {
|
|
1046
|
+
return str ? (Array.isArray(str) ? str : splitByCase(str)).map((p) => p.toLowerCase()).join(joiner ?? "-") : "";
|
|
1047
|
+
}
|
|
1048
|
+
function toArr(any) {
|
|
1049
|
+
return any == void 0 ? [] : Array.isArray(any) ? any : [any];
|
|
1050
|
+
}
|
|
1051
|
+
function toVal(out, key, val, opts) {
|
|
1052
|
+
let x;
|
|
1053
|
+
const old = out[key];
|
|
1054
|
+
const nxt = ~opts.string.indexOf(key) ? val == void 0 || val === true ? "" : String(val) : typeof val === "boolean" ? val : ~opts.boolean.indexOf(key) ? val === "false" ? false : val === "true" || (out._.push((x = +val, x * 0 === 0) ? x : val), !!val) : (x = +val, x * 0 === 0) ? x : val;
|
|
1055
|
+
out[key] = old == void 0 ? nxt : Array.isArray(old) ? old.concat(nxt) : [old, nxt];
|
|
1056
|
+
}
|
|
1057
|
+
function parseRawArgs(args = [], opts = {}) {
|
|
1058
|
+
let k;
|
|
1059
|
+
let arr;
|
|
1060
|
+
let arg;
|
|
1061
|
+
let name;
|
|
1062
|
+
let val;
|
|
1063
|
+
const out = { _: [] };
|
|
1064
|
+
let i = 0;
|
|
1065
|
+
let j = 0;
|
|
1066
|
+
let idx = 0;
|
|
1067
|
+
const len = args.length;
|
|
1068
|
+
const alibi = opts.alias !== void 0;
|
|
1069
|
+
const strict = opts.unknown !== void 0;
|
|
1070
|
+
const defaults = opts.default !== void 0;
|
|
1071
|
+
opts.alias = opts.alias || {};
|
|
1072
|
+
opts.string = toArr(opts.string);
|
|
1073
|
+
opts.boolean = toArr(opts.boolean);
|
|
1074
|
+
if (alibi) for (k in opts.alias) {
|
|
1075
|
+
arr = opts.alias[k] = toArr(opts.alias[k]);
|
|
1076
|
+
for (i = 0; i < arr.length; i++) (opts.alias[arr[i]] = arr.concat(k)).splice(i, 1);
|
|
1077
|
+
}
|
|
1078
|
+
for (i = opts.boolean.length; i-- > 0;) {
|
|
1079
|
+
arr = opts.alias[opts.boolean[i]] || [];
|
|
1080
|
+
for (j = arr.length; j-- > 0;) opts.boolean.push(arr[j]);
|
|
1081
|
+
}
|
|
1082
|
+
for (i = opts.string.length; i-- > 0;) {
|
|
1083
|
+
arr = opts.alias[opts.string[i]] || [];
|
|
1084
|
+
for (j = arr.length; j-- > 0;) opts.string.push(arr[j]);
|
|
1085
|
+
}
|
|
1086
|
+
if (defaults) for (k in opts.default) {
|
|
1087
|
+
name = typeof opts.default[k];
|
|
1088
|
+
arr = opts.alias[k] = opts.alias[k] || [];
|
|
1089
|
+
if (opts[name] !== void 0) {
|
|
1090
|
+
opts[name].push(k);
|
|
1091
|
+
for (i = 0; i < arr.length; i++) opts[name].push(arr[i]);
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
const keys = strict ? Object.keys(opts.alias) : [];
|
|
1095
|
+
for (i = 0; i < len; i++) {
|
|
1096
|
+
arg = args[i];
|
|
1097
|
+
if (arg === "--") {
|
|
1098
|
+
out._ = out._.concat(args.slice(++i));
|
|
1099
|
+
break;
|
|
1100
|
+
}
|
|
1101
|
+
for (j = 0; j < arg.length; j++) if (arg.charCodeAt(j) !== 45) break;
|
|
1102
|
+
if (j === 0) out._.push(arg);
|
|
1103
|
+
else if (arg.substring(j, j + 3) === "no-") {
|
|
1104
|
+
name = arg.slice(Math.max(0, j + 3));
|
|
1105
|
+
if (strict && !~keys.indexOf(name)) return opts.unknown(arg);
|
|
1106
|
+
out[name] = false;
|
|
1107
|
+
} else {
|
|
1108
|
+
for (idx = j + 1; idx < arg.length; idx++) if (arg.charCodeAt(idx) === 61) break;
|
|
1109
|
+
name = arg.substring(j, idx);
|
|
1110
|
+
val = arg.slice(Math.max(0, ++idx)) || i + 1 === len || ("" + args[i + 1]).charCodeAt(0) === 45 || args[++i];
|
|
1111
|
+
arr = j === 2 ? [name] : name;
|
|
1112
|
+
for (idx = 0; idx < arr.length; idx++) {
|
|
1113
|
+
name = arr[idx];
|
|
1114
|
+
if (strict && !~keys.indexOf(name)) return opts.unknown("-".repeat(j) + name);
|
|
1115
|
+
toVal(out, name, idx + 1 < arr.length || val, opts);
|
|
1116
|
+
}
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
if (defaults) {
|
|
1120
|
+
for (k in opts.default) if (out[k] === void 0) out[k] = opts.default[k];
|
|
1121
|
+
}
|
|
1122
|
+
if (alibi) for (k in out) {
|
|
1123
|
+
arr = opts.alias[k] || [];
|
|
1124
|
+
while (arr.length > 0) out[arr.shift()] = out[k];
|
|
1125
|
+
}
|
|
1126
|
+
return out;
|
|
1127
|
+
}
|
|
1128
|
+
function parseArgs(rawArgs, argsDef) {
|
|
1129
|
+
const parseOptions = {
|
|
1130
|
+
boolean: [],
|
|
1131
|
+
string: [],
|
|
1132
|
+
mixed: [],
|
|
1133
|
+
alias: {},
|
|
1134
|
+
default: {}
|
|
1135
|
+
};
|
|
1136
|
+
const args = resolveArgs(argsDef);
|
|
1137
|
+
for (const arg of args) {
|
|
1138
|
+
if (arg.type === "positional") continue;
|
|
1139
|
+
if (arg.type === "string") parseOptions.string.push(arg.name);
|
|
1140
|
+
else if (arg.type === "boolean") parseOptions.boolean.push(arg.name);
|
|
1141
|
+
if (arg.default !== void 0) parseOptions.default[arg.name] = arg.default;
|
|
1142
|
+
if (arg.alias) parseOptions.alias[arg.name] = arg.alias;
|
|
1143
|
+
}
|
|
1144
|
+
const parsed = parseRawArgs(rawArgs, parseOptions);
|
|
1145
|
+
const [ ...positionalArguments] = parsed._;
|
|
1146
|
+
const parsedArgsProxy = new Proxy(parsed, { get(target, prop) {
|
|
1147
|
+
return target[prop] ?? target[camelCase(prop)] ?? target[kebabCase(prop)];
|
|
1148
|
+
} });
|
|
1149
|
+
for (const [, arg] of args.entries()) if (arg.type === "positional") {
|
|
1150
|
+
const nextPositionalArgument = positionalArguments.shift();
|
|
1151
|
+
if (nextPositionalArgument !== void 0) parsedArgsProxy[arg.name] = nextPositionalArgument;
|
|
1152
|
+
else if (arg.default === void 0 && arg.required !== false) throw new CLIError(`Missing required positional argument: ${arg.name.toUpperCase()}`, "EARG");
|
|
1153
|
+
else parsedArgsProxy[arg.name] = arg.default;
|
|
1154
|
+
} else if (arg.required && parsedArgsProxy[arg.name] === void 0) throw new CLIError(`Missing required argument: --${arg.name}`, "EARG");
|
|
1155
|
+
return parsedArgsProxy;
|
|
1156
|
+
}
|
|
1157
|
+
function resolveArgs(argsDef) {
|
|
1158
|
+
const args = [];
|
|
1159
|
+
for (const [name, argDef] of Object.entries(argsDef || {})) args.push({
|
|
1160
|
+
...argDef,
|
|
1161
|
+
name,
|
|
1162
|
+
alias: toArray(argDef.alias)
|
|
1163
|
+
});
|
|
1164
|
+
return args;
|
|
1165
|
+
}
|
|
1166
|
+
function defineCommand(def) {
|
|
1167
|
+
return def;
|
|
1168
|
+
}
|
|
1169
|
+
async function runCommand(cmd, opts) {
|
|
1170
|
+
const cmdArgs = await resolveValue(cmd.args || {});
|
|
1171
|
+
const parsedArgs = parseArgs(opts.rawArgs, cmdArgs);
|
|
1172
|
+
const context = {
|
|
1173
|
+
rawArgs: opts.rawArgs,
|
|
1174
|
+
args: parsedArgs,
|
|
1175
|
+
data: opts.data,
|
|
1176
|
+
cmd
|
|
1177
|
+
};
|
|
1178
|
+
if (typeof cmd.setup === "function") await cmd.setup(context);
|
|
1179
|
+
let result;
|
|
1180
|
+
try {
|
|
1181
|
+
const subCommands = await resolveValue(cmd.subCommands);
|
|
1182
|
+
if (subCommands && Object.keys(subCommands).length > 0) {
|
|
1183
|
+
const subCommandArgIndex = opts.rawArgs.findIndex((arg) => !arg.startsWith("-"));
|
|
1184
|
+
const subCommandName = opts.rawArgs[subCommandArgIndex];
|
|
1185
|
+
if (subCommandName) {
|
|
1186
|
+
if (!subCommands[subCommandName]) throw new CLIError(`Unknown command \`${subCommandName}\``, "E_UNKNOWN_COMMAND");
|
|
1187
|
+
const subCommand = await resolveValue(subCommands[subCommandName]);
|
|
1188
|
+
if (subCommand) await runCommand(subCommand, { rawArgs: opts.rawArgs.slice(subCommandArgIndex + 1) });
|
|
1189
|
+
} else if (!cmd.run) throw new CLIError(`No command specified.`, "E_NO_COMMAND");
|
|
1190
|
+
}
|
|
1191
|
+
if (typeof cmd.run === "function") result = await cmd.run(context);
|
|
1192
|
+
} finally {
|
|
1193
|
+
if (typeof cmd.cleanup === "function") await cmd.cleanup(context);
|
|
1194
|
+
}
|
|
1195
|
+
return { result };
|
|
1196
|
+
}
|
|
1197
|
+
async function resolveSubCommand(cmd, rawArgs, parent) {
|
|
1198
|
+
const subCommands = await resolveValue(cmd.subCommands);
|
|
1199
|
+
if (subCommands && Object.keys(subCommands).length > 0) {
|
|
1200
|
+
const subCommandArgIndex = rawArgs.findIndex((arg) => !arg.startsWith("-"));
|
|
1201
|
+
const subCommandName = rawArgs[subCommandArgIndex];
|
|
1202
|
+
const subCommand = await resolveValue(subCommands[subCommandName]);
|
|
1203
|
+
if (subCommand) return resolveSubCommand(subCommand, rawArgs.slice(subCommandArgIndex + 1), cmd);
|
|
1204
|
+
}
|
|
1205
|
+
return [cmd, parent];
|
|
1206
|
+
}
|
|
1207
|
+
async function showUsage(cmd, parent) {
|
|
1208
|
+
try {
|
|
1209
|
+
consola.log(await renderUsage(cmd, parent) + "\n");
|
|
1210
|
+
} catch (error) {
|
|
1211
|
+
consola.error(error);
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
async function renderUsage(cmd, parent) {
|
|
1215
|
+
const cmdMeta = await resolveValue(cmd.meta || {});
|
|
1216
|
+
const cmdArgs = resolveArgs(await resolveValue(cmd.args || {}));
|
|
1217
|
+
const parentMeta = await resolveValue(parent?.meta || {});
|
|
1218
|
+
const commandName = `${parentMeta.name ? `${parentMeta.name} ` : ""}` + (cmdMeta.name || process.argv[1]);
|
|
1219
|
+
const argLines = [];
|
|
1220
|
+
const posLines = [];
|
|
1221
|
+
const commandsLines = [];
|
|
1222
|
+
const usageLine = [];
|
|
1223
|
+
for (const arg of cmdArgs) if (arg.type === "positional") {
|
|
1224
|
+
const name = arg.name.toUpperCase();
|
|
1225
|
+
const isRequired = arg.required !== false && arg.default === void 0;
|
|
1226
|
+
const defaultHint = arg.default ? `="${arg.default}"` : "";
|
|
1227
|
+
posLines.push([
|
|
1228
|
+
"`" + name + defaultHint + "`",
|
|
1229
|
+
arg.description || "",
|
|
1230
|
+
arg.valueHint ? `<${arg.valueHint}>` : ""
|
|
1231
|
+
]);
|
|
1232
|
+
usageLine.push(isRequired ? `<${name}>` : `[${name}]`);
|
|
1233
|
+
} else {
|
|
1234
|
+
const isRequired = arg.required === true && arg.default === void 0;
|
|
1235
|
+
const argStr = (arg.type === "boolean" && arg.default === true ? [...(arg.alias || []).map((a) => `--no-${a}`), `--no-${arg.name}`].join(", ") : [...(arg.alias || []).map((a) => `-${a}`), `--${arg.name}`].join(", ")) + (arg.type === "string" && (arg.valueHint || arg.default) ? `=${arg.valueHint ? `<${arg.valueHint}>` : `"${arg.default || ""}"`}` : "");
|
|
1236
|
+
argLines.push(["`" + argStr + (isRequired ? " (required)" : "") + "`", arg.description || ""]);
|
|
1237
|
+
if (isRequired) usageLine.push(argStr);
|
|
1238
|
+
}
|
|
1239
|
+
if (cmd.subCommands) {
|
|
1240
|
+
const commandNames = [];
|
|
1241
|
+
const subCommands = await resolveValue(cmd.subCommands);
|
|
1242
|
+
for (const [name, sub] of Object.entries(subCommands)) {
|
|
1243
|
+
const meta = await resolveValue((await resolveValue(sub))?.meta);
|
|
1244
|
+
commandsLines.push([`\`${name}\``, meta?.description || ""]);
|
|
1245
|
+
commandNames.push(name);
|
|
1246
|
+
}
|
|
1247
|
+
usageLine.push(commandNames.join("|"));
|
|
1248
|
+
}
|
|
1249
|
+
const usageLines = [];
|
|
1250
|
+
const version = cmdMeta.version || parentMeta.version;
|
|
1251
|
+
usageLines.push(colors.gray(`${cmdMeta.description} (${commandName + (version ? ` v${version}` : "")})`), "");
|
|
1252
|
+
const hasOptions = argLines.length > 0 || posLines.length > 0;
|
|
1253
|
+
usageLines.push(`${colors.underline(colors.bold("USAGE"))} \`${commandName}${hasOptions ? " [OPTIONS]" : ""} ${usageLine.join(" ")}\``, "");
|
|
1254
|
+
if (posLines.length > 0) {
|
|
1255
|
+
usageLines.push(colors.underline(colors.bold("ARGUMENTS")), "");
|
|
1256
|
+
usageLines.push(formatLineColumns(posLines, " "));
|
|
1257
|
+
usageLines.push("");
|
|
1258
|
+
}
|
|
1259
|
+
if (argLines.length > 0) {
|
|
1260
|
+
usageLines.push(colors.underline(colors.bold("OPTIONS")), "");
|
|
1261
|
+
usageLines.push(formatLineColumns(argLines, " "));
|
|
1262
|
+
usageLines.push("");
|
|
1263
|
+
}
|
|
1264
|
+
if (commandsLines.length > 0) {
|
|
1265
|
+
usageLines.push(colors.underline(colors.bold("COMMANDS")), "");
|
|
1266
|
+
usageLines.push(formatLineColumns(commandsLines, " "));
|
|
1267
|
+
usageLines.push("", `Use \`${commandName} <command> --help\` for more information about a command.`);
|
|
1268
|
+
}
|
|
1269
|
+
return usageLines.filter((l) => typeof l === "string").join("\n");
|
|
1270
|
+
}
|
|
1271
|
+
async function runMain(cmd, opts = {}) {
|
|
1272
|
+
const rawArgs = opts.rawArgs || process.argv.slice(2);
|
|
1273
|
+
const showUsage$1 = opts.showUsage || showUsage;
|
|
1274
|
+
try {
|
|
1275
|
+
if (rawArgs.includes("--help") || rawArgs.includes("-h")) {
|
|
1276
|
+
await showUsage$1(...await resolveSubCommand(cmd, rawArgs));
|
|
1277
|
+
process.exit(0);
|
|
1278
|
+
} else if (rawArgs.length === 1 && rawArgs[0] === "--version") {
|
|
1279
|
+
const meta = typeof cmd.meta === "function" ? await cmd.meta() : await cmd.meta;
|
|
1280
|
+
if (!meta?.version) throw new CLIError("No version specified", "E_NO_VERSION");
|
|
1281
|
+
consola.log(meta.version);
|
|
1282
|
+
} else await runCommand(cmd, { rawArgs });
|
|
1283
|
+
} catch (error) {
|
|
1284
|
+
const isCLIError = error instanceof CLIError;
|
|
1285
|
+
if (!isCLIError) consola.error(error, "\n");
|
|
1286
|
+
if (isCLIError) await showUsage$1(...await resolveSubCommand(cmd, rawArgs));
|
|
1287
|
+
consola.error(error.message);
|
|
1288
|
+
process.exit(1);
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1292
|
+
//#endregion
|
|
1293
|
+
//#region ../../node_modules/.bun/picocolors@1.1.1/node_modules/picocolors/picocolors.js
|
|
1294
|
+
var require_picocolors = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1295
|
+
let p = process || {}, argv = p.argv || [], env = p.env || {};
|
|
1296
|
+
let isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
|
|
1297
|
+
let formatter = (open, close, replace = open) => (input) => {
|
|
1298
|
+
let string = "" + input, index = string.indexOf(close, open.length);
|
|
1299
|
+
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
|
|
1300
|
+
};
|
|
1301
|
+
let replaceClose = (string, close, replace, index) => {
|
|
1302
|
+
let result = "", cursor = 0;
|
|
1303
|
+
do {
|
|
1304
|
+
result += string.substring(cursor, index) + replace;
|
|
1305
|
+
cursor = index + close.length;
|
|
1306
|
+
index = string.indexOf(close, cursor);
|
|
1307
|
+
} while (~index);
|
|
1308
|
+
return result + string.substring(cursor);
|
|
1309
|
+
};
|
|
1310
|
+
let createColors = (enabled = isColorSupported) => {
|
|
1311
|
+
let f = enabled ? formatter : () => String;
|
|
1312
|
+
return {
|
|
1313
|
+
isColorSupported: enabled,
|
|
1314
|
+
reset: f("\x1B[0m", "\x1B[0m"),
|
|
1315
|
+
bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
|
|
1316
|
+
dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
|
|
1317
|
+
italic: f("\x1B[3m", "\x1B[23m"),
|
|
1318
|
+
underline: f("\x1B[4m", "\x1B[24m"),
|
|
1319
|
+
inverse: f("\x1B[7m", "\x1B[27m"),
|
|
1320
|
+
hidden: f("\x1B[8m", "\x1B[28m"),
|
|
1321
|
+
strikethrough: f("\x1B[9m", "\x1B[29m"),
|
|
1322
|
+
black: f("\x1B[30m", "\x1B[39m"),
|
|
1323
|
+
red: f("\x1B[31m", "\x1B[39m"),
|
|
1324
|
+
green: f("\x1B[32m", "\x1B[39m"),
|
|
1325
|
+
yellow: f("\x1B[33m", "\x1B[39m"),
|
|
1326
|
+
blue: f("\x1B[34m", "\x1B[39m"),
|
|
1327
|
+
magenta: f("\x1B[35m", "\x1B[39m"),
|
|
1328
|
+
cyan: f("\x1B[36m", "\x1B[39m"),
|
|
1329
|
+
white: f("\x1B[37m", "\x1B[39m"),
|
|
1330
|
+
gray: f("\x1B[90m", "\x1B[39m"),
|
|
1331
|
+
bgBlack: f("\x1B[40m", "\x1B[49m"),
|
|
1332
|
+
bgRed: f("\x1B[41m", "\x1B[49m"),
|
|
1333
|
+
bgGreen: f("\x1B[42m", "\x1B[49m"),
|
|
1334
|
+
bgYellow: f("\x1B[43m", "\x1B[49m"),
|
|
1335
|
+
bgBlue: f("\x1B[44m", "\x1B[49m"),
|
|
1336
|
+
bgMagenta: f("\x1B[45m", "\x1B[49m"),
|
|
1337
|
+
bgCyan: f("\x1B[46m", "\x1B[49m"),
|
|
1338
|
+
bgWhite: f("\x1B[47m", "\x1B[49m"),
|
|
1339
|
+
blackBright: f("\x1B[90m", "\x1B[39m"),
|
|
1340
|
+
redBright: f("\x1B[91m", "\x1B[39m"),
|
|
1341
|
+
greenBright: f("\x1B[92m", "\x1B[39m"),
|
|
1342
|
+
yellowBright: f("\x1B[93m", "\x1B[39m"),
|
|
1343
|
+
blueBright: f("\x1B[94m", "\x1B[39m"),
|
|
1344
|
+
magentaBright: f("\x1B[95m", "\x1B[39m"),
|
|
1345
|
+
cyanBright: f("\x1B[96m", "\x1B[39m"),
|
|
1346
|
+
whiteBright: f("\x1B[97m", "\x1B[39m"),
|
|
1347
|
+
bgBlackBright: f("\x1B[100m", "\x1B[49m"),
|
|
1348
|
+
bgRedBright: f("\x1B[101m", "\x1B[49m"),
|
|
1349
|
+
bgGreenBright: f("\x1B[102m", "\x1B[49m"),
|
|
1350
|
+
bgYellowBright: f("\x1B[103m", "\x1B[49m"),
|
|
1351
|
+
bgBlueBright: f("\x1B[104m", "\x1B[49m"),
|
|
1352
|
+
bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
|
|
1353
|
+
bgCyanBright: f("\x1B[106m", "\x1B[49m"),
|
|
1354
|
+
bgWhiteBright: f("\x1B[107m", "\x1B[49m")
|
|
1355
|
+
};
|
|
1356
|
+
};
|
|
1357
|
+
module.exports = createColors();
|
|
1358
|
+
module.exports.createColors = createColors;
|
|
1359
|
+
}));
|
|
1360
|
+
|
|
1361
|
+
//#endregion
|
|
1362
|
+
//#region ../../node_modules/.bun/sisteransi@1.0.5/node_modules/sisteransi/src/index.js
|
|
1363
|
+
var require_src = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1364
|
+
const ESC = "\x1B";
|
|
1365
|
+
const CSI = `${ESC}[`;
|
|
1366
|
+
const beep = "\x07";
|
|
1367
|
+
const cursor = {
|
|
1368
|
+
to(x, y) {
|
|
1369
|
+
if (!y) return `${CSI}${x + 1}G`;
|
|
1370
|
+
return `${CSI}${y + 1};${x + 1}H`;
|
|
1371
|
+
},
|
|
1372
|
+
move(x, y) {
|
|
1373
|
+
let ret = "";
|
|
1374
|
+
if (x < 0) ret += `${CSI}${-x}D`;
|
|
1375
|
+
else if (x > 0) ret += `${CSI}${x}C`;
|
|
1376
|
+
if (y < 0) ret += `${CSI}${-y}A`;
|
|
1377
|
+
else if (y > 0) ret += `${CSI}${y}B`;
|
|
1378
|
+
return ret;
|
|
1379
|
+
},
|
|
1380
|
+
up: (count = 1) => `${CSI}${count}A`,
|
|
1381
|
+
down: (count = 1) => `${CSI}${count}B`,
|
|
1382
|
+
forward: (count = 1) => `${CSI}${count}C`,
|
|
1383
|
+
backward: (count = 1) => `${CSI}${count}D`,
|
|
1384
|
+
nextLine: (count = 1) => `${CSI}E`.repeat(count),
|
|
1385
|
+
prevLine: (count = 1) => `${CSI}F`.repeat(count),
|
|
1386
|
+
left: `${CSI}G`,
|
|
1387
|
+
hide: `${CSI}?25l`,
|
|
1388
|
+
show: `${CSI}?25h`,
|
|
1389
|
+
save: `${ESC}7`,
|
|
1390
|
+
restore: `${ESC}8`
|
|
1391
|
+
};
|
|
1392
|
+
const scroll = {
|
|
1393
|
+
up: (count = 1) => `${CSI}S`.repeat(count),
|
|
1394
|
+
down: (count = 1) => `${CSI}T`.repeat(count)
|
|
1395
|
+
};
|
|
1396
|
+
const erase = {
|
|
1397
|
+
screen: `${CSI}2J`,
|
|
1398
|
+
up: (count = 1) => `${CSI}1J`.repeat(count),
|
|
1399
|
+
down: (count = 1) => `${CSI}J`.repeat(count),
|
|
1400
|
+
line: `${CSI}2K`,
|
|
1401
|
+
lineEnd: `${CSI}K`,
|
|
1402
|
+
lineStart: `${CSI}1K`,
|
|
1403
|
+
lines(count) {
|
|
1404
|
+
let clear = "";
|
|
1405
|
+
for (let i = 0; i < count; i++) clear += this.line + (i < count - 1 ? cursor.up() : "");
|
|
1406
|
+
if (count) clear += cursor.left;
|
|
1407
|
+
return clear;
|
|
1408
|
+
}
|
|
1409
|
+
};
|
|
1410
|
+
module.exports = {
|
|
1411
|
+
cursor,
|
|
1412
|
+
scroll,
|
|
1413
|
+
erase,
|
|
1414
|
+
beep
|
|
1415
|
+
};
|
|
1416
|
+
}));
|
|
1417
|
+
|
|
1418
|
+
//#endregion
|
|
1419
|
+
//#region ../../node_modules/.bun/@clack+core@1.0.1/node_modules/@clack/core/dist/index.mjs
|
|
1420
|
+
var import_picocolors = /* @__PURE__ */ __toESM(require_picocolors(), 1);
|
|
1421
|
+
var import_src = require_src();
|
|
1422
|
+
function B(t, e, s) {
|
|
1423
|
+
if (!s.some((u) => !u.disabled)) return t;
|
|
1424
|
+
const i = t + e, r = Math.max(s.length - 1, 0), n = i < 0 ? r : i > r ? 0 : i;
|
|
1425
|
+
return s[n].disabled ? B(n, e < 0 ? -1 : 1, s) : n;
|
|
1426
|
+
}
|
|
1427
|
+
const at$1 = (t) => t === 161 || t === 164 || t === 167 || t === 168 || t === 170 || t === 173 || t === 174 || t >= 176 && t <= 180 || t >= 182 && t <= 186 || t >= 188 && t <= 191 || t === 198 || t === 208 || t === 215 || t === 216 || t >= 222 && t <= 225 || t === 230 || t >= 232 && t <= 234 || t === 236 || t === 237 || t === 240 || t === 242 || t === 243 || t >= 247 && t <= 250 || t === 252 || t === 254 || t === 257 || t === 273 || t === 275 || t === 283 || t === 294 || t === 295 || t === 299 || t >= 305 && t <= 307 || t === 312 || t >= 319 && t <= 322 || t === 324 || t >= 328 && t <= 331 || t === 333 || t === 338 || t === 339 || t === 358 || t === 359 || t === 363 || t === 462 || t === 464 || t === 466 || t === 468 || t === 470 || t === 472 || t === 474 || t === 476 || t === 593 || t === 609 || t === 708 || t === 711 || t >= 713 && t <= 715 || t === 717 || t === 720 || t >= 728 && t <= 731 || t === 733 || t === 735 || t >= 768 && t <= 879 || t >= 913 && t <= 929 || t >= 931 && t <= 937 || t >= 945 && t <= 961 || t >= 963 && t <= 969 || t === 1025 || t >= 1040 && t <= 1103 || t === 1105 || t === 8208 || t >= 8211 && t <= 8214 || t === 8216 || t === 8217 || t === 8220 || t === 8221 || t >= 8224 && t <= 8226 || t >= 8228 && t <= 8231 || t === 8240 || t === 8242 || t === 8243 || t === 8245 || t === 8251 || t === 8254 || t === 8308 || t === 8319 || t >= 8321 && t <= 8324 || t === 8364 || t === 8451 || t === 8453 || t === 8457 || t === 8467 || t === 8470 || t === 8481 || t === 8482 || t === 8486 || t === 8491 || t === 8531 || t === 8532 || t >= 8539 && t <= 8542 || t >= 8544 && t <= 8555 || t >= 8560 && t <= 8569 || t === 8585 || t >= 8592 && t <= 8601 || t === 8632 || t === 8633 || t === 8658 || t === 8660 || t === 8679 || t === 8704 || t === 8706 || t === 8707 || t === 8711 || t === 8712 || t === 8715 || t === 8719 || t === 8721 || t === 8725 || t === 8730 || t >= 8733 && t <= 8736 || t === 8739 || t === 8741 || t >= 8743 && t <= 8748 || t === 8750 || t >= 8756 && t <= 8759 || t === 8764 || t === 8765 || t === 8776 || t === 8780 || t === 8786 || t === 8800 || t === 8801 || t >= 8804 && t <= 8807 || t === 8810 || t === 8811 || t === 8814 || t === 8815 || t === 8834 || t === 8835 || t === 8838 || t === 8839 || t === 8853 || t === 8857 || t === 8869 || t === 8895 || t === 8978 || t >= 9312 && t <= 9449 || t >= 9451 && t <= 9547 || t >= 9552 && t <= 9587 || t >= 9600 && t <= 9615 || t >= 9618 && t <= 9621 || t === 9632 || t === 9633 || t >= 9635 && t <= 9641 || t === 9650 || t === 9651 || t === 9654 || t === 9655 || t === 9660 || t === 9661 || t === 9664 || t === 9665 || t >= 9670 && t <= 9672 || t === 9675 || t >= 9678 && t <= 9681 || t >= 9698 && t <= 9701 || t === 9711 || t === 9733 || t === 9734 || t === 9737 || t === 9742 || t === 9743 || t === 9756 || t === 9758 || t === 9792 || t === 9794 || t === 9824 || t === 9825 || t >= 9827 && t <= 9829 || t >= 9831 && t <= 9834 || t === 9836 || t === 9837 || t === 9839 || t === 9886 || t === 9887 || t === 9919 || t >= 9926 && t <= 9933 || t >= 9935 && t <= 9939 || t >= 9941 && t <= 9953 || t === 9955 || t === 9960 || t === 9961 || t >= 9963 && t <= 9969 || t === 9972 || t >= 9974 && t <= 9977 || t === 9979 || t === 9980 || t === 9982 || t === 9983 || t === 10045 || t >= 10102 && t <= 10111 || t >= 11094 && t <= 11097 || t >= 12872 && t <= 12879 || t >= 57344 && t <= 63743 || t >= 65024 && t <= 65039 || t === 65533 || t >= 127232 && t <= 127242 || t >= 127248 && t <= 127277 || t >= 127280 && t <= 127337 || t >= 127344 && t <= 127373 || t === 127375 || t === 127376 || t >= 127387 && t <= 127404 || t >= 917760 && t <= 917999 || t >= 983040 && t <= 1048573 || t >= 1048576 && t <= 1114109, lt$1 = (t) => t === 12288 || t >= 65281 && t <= 65376 || t >= 65504 && t <= 65510, ht$1 = (t) => t >= 4352 && t <= 4447 || t === 8986 || t === 8987 || t === 9001 || t === 9002 || t >= 9193 && t <= 9196 || t === 9200 || t === 9203 || t === 9725 || t === 9726 || t === 9748 || t === 9749 || t >= 9800 && t <= 9811 || t === 9855 || t === 9875 || t === 9889 || t === 9898 || t === 9899 || t === 9917 || t === 9918 || t === 9924 || t === 9925 || t === 9934 || t === 9940 || t === 9962 || t === 9970 || t === 9971 || t === 9973 || t === 9978 || t === 9981 || t === 9989 || t === 9994 || t === 9995 || t === 10024 || t === 10060 || t === 10062 || t >= 10067 && t <= 10069 || t === 10071 || t >= 10133 && t <= 10135 || t === 10160 || t === 10175 || t === 11035 || t === 11036 || t === 11088 || t === 11093 || t >= 11904 && t <= 11929 || t >= 11931 && t <= 12019 || t >= 12032 && t <= 12245 || t >= 12272 && t <= 12287 || t >= 12289 && t <= 12350 || t >= 12353 && t <= 12438 || t >= 12441 && t <= 12543 || t >= 12549 && t <= 12591 || t >= 12593 && t <= 12686 || t >= 12688 && t <= 12771 || t >= 12783 && t <= 12830 || t >= 12832 && t <= 12871 || t >= 12880 && t <= 19903 || t >= 19968 && t <= 42124 || t >= 42128 && t <= 42182 || t >= 43360 && t <= 43388 || t >= 44032 && t <= 55203 || t >= 63744 && t <= 64255 || t >= 65040 && t <= 65049 || t >= 65072 && t <= 65106 || t >= 65108 && t <= 65126 || t >= 65128 && t <= 65131 || t >= 94176 && t <= 94180 || t === 94192 || t === 94193 || t >= 94208 && t <= 100343 || t >= 100352 && t <= 101589 || t >= 101632 && t <= 101640 || t >= 110576 && t <= 110579 || t >= 110581 && t <= 110587 || t === 110589 || t === 110590 || t >= 110592 && t <= 110882 || t === 110898 || t >= 110928 && t <= 110930 || t === 110933 || t >= 110948 && t <= 110951 || t >= 110960 && t <= 111355 || t === 126980 || t === 127183 || t === 127374 || t >= 127377 && t <= 127386 || t >= 127488 && t <= 127490 || t >= 127504 && t <= 127547 || t >= 127552 && t <= 127560 || t === 127568 || t === 127569 || t >= 127584 && t <= 127589 || t >= 127744 && t <= 127776 || t >= 127789 && t <= 127797 || t >= 127799 && t <= 127868 || t >= 127870 && t <= 127891 || t >= 127904 && t <= 127946 || t >= 127951 && t <= 127955 || t >= 127968 && t <= 127984 || t === 127988 || t >= 127992 && t <= 128062 || t === 128064 || t >= 128066 && t <= 128252 || t >= 128255 && t <= 128317 || t >= 128331 && t <= 128334 || t >= 128336 && t <= 128359 || t === 128378 || t === 128405 || t === 128406 || t === 128420 || t >= 128507 && t <= 128591 || t >= 128640 && t <= 128709 || t === 128716 || t >= 128720 && t <= 128722 || t >= 128725 && t <= 128727 || t >= 128732 && t <= 128735 || t === 128747 || t === 128748 || t >= 128756 && t <= 128764 || t >= 128992 && t <= 129003 || t === 129008 || t >= 129292 && t <= 129338 || t >= 129340 && t <= 129349 || t >= 129351 && t <= 129535 || t >= 129648 && t <= 129660 || t >= 129664 && t <= 129672 || t >= 129680 && t <= 129725 || t >= 129727 && t <= 129733 || t >= 129742 && t <= 129755 || t >= 129760 && t <= 129768 || t >= 129776 && t <= 129784 || t >= 131072 && t <= 196605 || t >= 196608 && t <= 262141, O = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y, y = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y, L = /\t{1,1000}/y, P = /[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/uy, M$1 = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y, ct$1 = /\p{M}+/gu, ft$1 = {
|
|
1428
|
+
limit: Infinity,
|
|
1429
|
+
ellipsis: ""
|
|
1430
|
+
}, X$1 = (t, e = {}, s = {}) => {
|
|
1431
|
+
const i = e.limit ?? Infinity, r = e.ellipsis ?? "", n = e?.ellipsisWidth ?? (r ? X$1(r, ft$1, s).width : 0), u = s.ansiWidth ?? 0, a = s.controlWidth ?? 0, l = s.tabWidth ?? 8, E = s.ambiguousWidth ?? 1, g = s.emojiWidth ?? 2, m = s.fullWidthWidth ?? 2, A = s.regularWidth ?? 1, V = s.wideWidth ?? 2;
|
|
1432
|
+
let h = 0, o = 0, p = t.length, v = 0, F = !1, d = p, b = Math.max(0, i - n), C = 0, w = 0, c = 0, f = 0;
|
|
1433
|
+
t: for (;;) {
|
|
1434
|
+
if (w > C || o >= p && o > h) {
|
|
1435
|
+
const ut = t.slice(C, w) || t.slice(h, o);
|
|
1436
|
+
v = 0;
|
|
1437
|
+
for (const Y of ut.replaceAll(ct$1, "")) {
|
|
1438
|
+
const $ = Y.codePointAt(0) || 0;
|
|
1439
|
+
if (lt$1($) ? f = m : ht$1($) ? f = V : E !== A && at$1($) ? f = E : f = A, c + f > b && (d = Math.min(d, Math.max(C, h) + v)), c + f > i) {
|
|
1440
|
+
F = !0;
|
|
1441
|
+
break t;
|
|
1442
|
+
}
|
|
1443
|
+
v += Y.length, c += f;
|
|
1444
|
+
}
|
|
1445
|
+
C = w = 0;
|
|
1446
|
+
}
|
|
1447
|
+
if (o >= p) break;
|
|
1448
|
+
if (M$1.lastIndex = o, M$1.test(t)) {
|
|
1449
|
+
if (v = M$1.lastIndex - o, f = v * A, c + f > b && (d = Math.min(d, o + Math.floor((b - c) / A))), c + f > i) {
|
|
1450
|
+
F = !0;
|
|
1451
|
+
break;
|
|
1452
|
+
}
|
|
1453
|
+
c += f, C = h, w = o, o = h = M$1.lastIndex;
|
|
1454
|
+
continue;
|
|
1455
|
+
}
|
|
1456
|
+
if (O.lastIndex = o, O.test(t)) {
|
|
1457
|
+
if (c + u > b && (d = Math.min(d, o)), c + u > i) {
|
|
1458
|
+
F = !0;
|
|
1459
|
+
break;
|
|
1460
|
+
}
|
|
1461
|
+
c += u, C = h, w = o, o = h = O.lastIndex;
|
|
1462
|
+
continue;
|
|
1463
|
+
}
|
|
1464
|
+
if (y.lastIndex = o, y.test(t)) {
|
|
1465
|
+
if (v = y.lastIndex - o, f = v * a, c + f > b && (d = Math.min(d, o + Math.floor((b - c) / a))), c + f > i) {
|
|
1466
|
+
F = !0;
|
|
1467
|
+
break;
|
|
1468
|
+
}
|
|
1469
|
+
c += f, C = h, w = o, o = h = y.lastIndex;
|
|
1470
|
+
continue;
|
|
1471
|
+
}
|
|
1472
|
+
if (L.lastIndex = o, L.test(t)) {
|
|
1473
|
+
if (v = L.lastIndex - o, f = v * l, c + f > b && (d = Math.min(d, o + Math.floor((b - c) / l))), c + f > i) {
|
|
1474
|
+
F = !0;
|
|
1475
|
+
break;
|
|
1476
|
+
}
|
|
1477
|
+
c += f, C = h, w = o, o = h = L.lastIndex;
|
|
1478
|
+
continue;
|
|
1479
|
+
}
|
|
1480
|
+
if (P.lastIndex = o, P.test(t)) {
|
|
1481
|
+
if (c + g > b && (d = Math.min(d, o)), c + g > i) {
|
|
1482
|
+
F = !0;
|
|
1483
|
+
break;
|
|
1484
|
+
}
|
|
1485
|
+
c += g, C = h, w = o, o = h = P.lastIndex;
|
|
1486
|
+
continue;
|
|
1487
|
+
}
|
|
1488
|
+
o += 1;
|
|
1489
|
+
}
|
|
1490
|
+
return {
|
|
1491
|
+
width: F ? b : c,
|
|
1492
|
+
index: F ? d : p,
|
|
1493
|
+
truncated: F,
|
|
1494
|
+
ellipsed: F && i >= n
|
|
1495
|
+
};
|
|
1496
|
+
}, pt$1 = {
|
|
1497
|
+
limit: Infinity,
|
|
1498
|
+
ellipsis: "",
|
|
1499
|
+
ellipsisWidth: 0
|
|
1500
|
+
}, S = (t, e = {}) => X$1(t, pt$1, e).width, W$1 = "\x1B", Z$1 = "", Ft$1 = 39, j = "\x07", Q$1 = "[", dt$1 = "]", tt = "m", U$1 = `${dt$1}8;;`, et$1 = new RegExp(`(?:\\${Q$1}(?<code>\\d+)m|\\${U$1}(?<uri>.*)${j})`, "y"), mt$1 = (t) => {
|
|
1501
|
+
if (t >= 30 && t <= 37 || t >= 90 && t <= 97) return 39;
|
|
1502
|
+
if (t >= 40 && t <= 47 || t >= 100 && t <= 107) return 49;
|
|
1503
|
+
if (t === 1 || t === 2) return 22;
|
|
1504
|
+
if (t === 3) return 23;
|
|
1505
|
+
if (t === 4) return 24;
|
|
1506
|
+
if (t === 7) return 27;
|
|
1507
|
+
if (t === 8) return 28;
|
|
1508
|
+
if (t === 9) return 29;
|
|
1509
|
+
if (t === 0) return 0;
|
|
1510
|
+
}, st$1 = (t) => `${W$1}${Q$1}${t}${tt}`, it$1 = (t) => `${W$1}${U$1}${t}${j}`, gt$1 = (t) => t.map((e) => S(e)), G = (t, e, s) => {
|
|
1511
|
+
const i = e[Symbol.iterator]();
|
|
1512
|
+
let r = !1, n = !1, u = t.at(-1), a = u === void 0 ? 0 : S(u), l = i.next(), E = i.next(), g = 0;
|
|
1513
|
+
for (; !l.done;) {
|
|
1514
|
+
const m = l.value, A = S(m);
|
|
1515
|
+
a + A <= s ? t[t.length - 1] += m : (t.push(m), a = 0), (m === W$1 || m === Z$1) && (r = !0, n = e.startsWith(U$1, g + 1)), r ? n ? m === j && (r = !1, n = !1) : m === tt && (r = !1) : (a += A, a === s && !E.done && (t.push(""), a = 0)), l = E, E = i.next(), g += m.length;
|
|
1516
|
+
}
|
|
1517
|
+
u = t.at(-1), !a && u !== void 0 && u.length > 0 && t.length > 1 && (t[t.length - 2] += t.pop());
|
|
1518
|
+
}, vt$1 = (t) => {
|
|
1519
|
+
const e = t.split(" ");
|
|
1520
|
+
let s = e.length;
|
|
1521
|
+
for (; s > 0 && !(S(e[s - 1]) > 0);) s--;
|
|
1522
|
+
return s === e.length ? t : e.slice(0, s).join(" ") + e.slice(s).join("");
|
|
1523
|
+
}, Et$1 = (t, e, s = {}) => {
|
|
1524
|
+
if (s.trim !== !1 && t.trim() === "") return "";
|
|
1525
|
+
let i = "", r, n;
|
|
1526
|
+
const u = t.split(" "), a = gt$1(u);
|
|
1527
|
+
let l = [""];
|
|
1528
|
+
for (const [h, o] of u.entries()) {
|
|
1529
|
+
s.trim !== !1 && (l[l.length - 1] = (l.at(-1) ?? "").trimStart());
|
|
1530
|
+
let p = S(l.at(-1) ?? "");
|
|
1531
|
+
if (h !== 0 && (p >= e && (s.wordWrap === !1 || s.trim === !1) && (l.push(""), p = 0), (p > 0 || s.trim === !1) && (l[l.length - 1] += " ", p++)), s.hard && a[h] > e) {
|
|
1532
|
+
const v = e - p, F = 1 + Math.floor((a[h] - v - 1) / e);
|
|
1533
|
+
Math.floor((a[h] - 1) / e) < F && l.push(""), G(l, o, e);
|
|
1534
|
+
continue;
|
|
1535
|
+
}
|
|
1536
|
+
if (p + a[h] > e && p > 0 && a[h] > 0) {
|
|
1537
|
+
if (s.wordWrap === !1 && p < e) {
|
|
1538
|
+
G(l, o, e);
|
|
1539
|
+
continue;
|
|
1540
|
+
}
|
|
1541
|
+
l.push("");
|
|
1542
|
+
}
|
|
1543
|
+
if (p + a[h] > e && s.wordWrap === !1) {
|
|
1544
|
+
G(l, o, e);
|
|
1545
|
+
continue;
|
|
1546
|
+
}
|
|
1547
|
+
l[l.length - 1] += o;
|
|
1548
|
+
}
|
|
1549
|
+
s.trim !== !1 && (l = l.map((h) => vt$1(h)));
|
|
1550
|
+
const E = l.join(`
|
|
1551
|
+
`), g = E[Symbol.iterator]();
|
|
1552
|
+
let m = g.next(), A = g.next(), V = 0;
|
|
1553
|
+
for (; !m.done;) {
|
|
1554
|
+
const h = m.value, o = A.value;
|
|
1555
|
+
if (i += h, h === W$1 || h === Z$1) {
|
|
1556
|
+
et$1.lastIndex = V + 1;
|
|
1557
|
+
const F = et$1.exec(E)?.groups;
|
|
1558
|
+
if (F?.code !== void 0) {
|
|
1559
|
+
const d = Number.parseFloat(F.code);
|
|
1560
|
+
r = d === Ft$1 ? void 0 : d;
|
|
1561
|
+
} else F?.uri !== void 0 && (n = F.uri.length === 0 ? void 0 : F.uri);
|
|
1562
|
+
}
|
|
1563
|
+
const p = r ? mt$1(r) : void 0;
|
|
1564
|
+
o === `
|
|
1565
|
+
` ? (n && (i += it$1("")), r && p && (i += st$1(p))) : h === `
|
|
1566
|
+
` && (r && p && (i += st$1(r)), n && (i += it$1(n))), V += h.length, m = A, A = g.next();
|
|
1567
|
+
}
|
|
1568
|
+
return i;
|
|
1569
|
+
};
|
|
1570
|
+
function K$1(t, e, s) {
|
|
1571
|
+
return String(t).normalize().replaceAll(`\r
|
|
1572
|
+
`, `
|
|
1573
|
+
`).split(`
|
|
1574
|
+
`).map((i) => Et$1(i, e, s)).join(`
|
|
1575
|
+
`);
|
|
1576
|
+
}
|
|
1577
|
+
const _ = {
|
|
1578
|
+
actions: new Set([
|
|
1579
|
+
"up",
|
|
1580
|
+
"down",
|
|
1581
|
+
"left",
|
|
1582
|
+
"right",
|
|
1583
|
+
"space",
|
|
1584
|
+
"enter",
|
|
1585
|
+
"cancel"
|
|
1586
|
+
]),
|
|
1587
|
+
aliases: new Map([
|
|
1588
|
+
["k", "up"],
|
|
1589
|
+
["j", "down"],
|
|
1590
|
+
["h", "left"],
|
|
1591
|
+
["l", "right"],
|
|
1592
|
+
["", "cancel"],
|
|
1593
|
+
["escape", "cancel"]
|
|
1594
|
+
]),
|
|
1595
|
+
messages: {
|
|
1596
|
+
cancel: "Canceled",
|
|
1597
|
+
error: "Something went wrong"
|
|
1598
|
+
},
|
|
1599
|
+
withGuide: !0
|
|
1600
|
+
};
|
|
1601
|
+
function H$1(t, e) {
|
|
1602
|
+
if (typeof t == "string") return _.aliases.get(t) === e;
|
|
1603
|
+
for (const s of t) if (s !== void 0 && H$1(s, e)) return !0;
|
|
1604
|
+
return !1;
|
|
1605
|
+
}
|
|
1606
|
+
function _t(t, e) {
|
|
1607
|
+
if (t === e) return;
|
|
1608
|
+
const s = t.split(`
|
|
1609
|
+
`), i = e.split(`
|
|
1610
|
+
`), r = Math.max(s.length, i.length), n = [];
|
|
1611
|
+
for (let u = 0; u < r; u++) s[u] !== i[u] && n.push(u);
|
|
1612
|
+
return {
|
|
1613
|
+
lines: n,
|
|
1614
|
+
numLinesBefore: s.length,
|
|
1615
|
+
numLinesAfter: i.length,
|
|
1616
|
+
numLines: r
|
|
1617
|
+
};
|
|
1618
|
+
}
|
|
1619
|
+
const bt$1 = globalThis.process.platform.startsWith("win"), z = Symbol("clack:cancel");
|
|
1620
|
+
function Ct$1(t) {
|
|
1621
|
+
return t === z;
|
|
1622
|
+
}
|
|
1623
|
+
function T(t, e) {
|
|
1624
|
+
const s = t;
|
|
1625
|
+
s.isTTY && s.setRawMode(e);
|
|
1626
|
+
}
|
|
1627
|
+
function Bt({ input: t = stdin, output: e = stdout, overwrite: s = !0, hideCursor: i = !0 } = {}) {
|
|
1628
|
+
const r = k.createInterface({
|
|
1629
|
+
input: t,
|
|
1630
|
+
output: e,
|
|
1631
|
+
prompt: "",
|
|
1632
|
+
tabSize: 1
|
|
1633
|
+
});
|
|
1634
|
+
k.emitKeypressEvents(t, r), t instanceof ReadStream && t.isTTY && t.setRawMode(!0);
|
|
1635
|
+
const n = (u, { name: a, sequence: l }) => {
|
|
1636
|
+
if (H$1([
|
|
1637
|
+
String(u),
|
|
1638
|
+
a,
|
|
1639
|
+
l
|
|
1640
|
+
], "cancel")) {
|
|
1641
|
+
i && e.write(import_src.cursor.show), process.exit(0);
|
|
1642
|
+
return;
|
|
1643
|
+
}
|
|
1644
|
+
if (!s) return;
|
|
1645
|
+
const g = a === "return" ? 0 : -1, m = a === "return" ? -1 : 0;
|
|
1646
|
+
k.moveCursor(e, g, m, () => {
|
|
1647
|
+
k.clearLine(e, 1, () => {
|
|
1648
|
+
t.once("keypress", n);
|
|
1649
|
+
});
|
|
1650
|
+
});
|
|
1651
|
+
};
|
|
1652
|
+
return i && e.write(import_src.cursor.hide), t.once("keypress", n), () => {
|
|
1653
|
+
t.off("keypress", n), i && e.write(import_src.cursor.show), t instanceof ReadStream && t.isTTY && !bt$1 && t.setRawMode(!1), r.terminal = !1, r.close();
|
|
1654
|
+
};
|
|
1655
|
+
}
|
|
1656
|
+
const rt$1 = (t) => "columns" in t && typeof t.columns == "number" ? t.columns : 80, nt$1 = (t) => "rows" in t && typeof t.rows == "number" ? t.rows : 20;
|
|
1657
|
+
function xt(t, e, s, i = s) {
|
|
1658
|
+
return K$1(e, rt$1(t ?? stdout) - s.length, {
|
|
1659
|
+
hard: !0,
|
|
1660
|
+
trim: !1
|
|
1661
|
+
}).split(`
|
|
1662
|
+
`).map((n, u) => `${u === 0 ? i : s}${n}`).join(`
|
|
1663
|
+
`);
|
|
1664
|
+
}
|
|
1665
|
+
var x$1 = class {
|
|
1666
|
+
input;
|
|
1667
|
+
output;
|
|
1668
|
+
_abortSignal;
|
|
1669
|
+
rl;
|
|
1670
|
+
opts;
|
|
1671
|
+
_render;
|
|
1672
|
+
_track = !1;
|
|
1673
|
+
_prevFrame = "";
|
|
1674
|
+
_subscribers = /* @__PURE__ */ new Map();
|
|
1675
|
+
_cursor = 0;
|
|
1676
|
+
state = "initial";
|
|
1677
|
+
error = "";
|
|
1678
|
+
value;
|
|
1679
|
+
userInput = "";
|
|
1680
|
+
constructor(e, s = !0) {
|
|
1681
|
+
const { input: i = stdin, output: r = stdout, render: n, signal: u, ...a } = e;
|
|
1682
|
+
this.opts = a, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = n.bind(this), this._track = s, this._abortSignal = u, this.input = i, this.output = r;
|
|
1683
|
+
}
|
|
1684
|
+
unsubscribe() {
|
|
1685
|
+
this._subscribers.clear();
|
|
1686
|
+
}
|
|
1687
|
+
setSubscriber(e, s) {
|
|
1688
|
+
const i = this._subscribers.get(e) ?? [];
|
|
1689
|
+
i.push(s), this._subscribers.set(e, i);
|
|
1690
|
+
}
|
|
1691
|
+
on(e, s) {
|
|
1692
|
+
this.setSubscriber(e, { cb: s });
|
|
1693
|
+
}
|
|
1694
|
+
once(e, s) {
|
|
1695
|
+
this.setSubscriber(e, {
|
|
1696
|
+
cb: s,
|
|
1697
|
+
once: !0
|
|
1698
|
+
});
|
|
1699
|
+
}
|
|
1700
|
+
emit(e, ...s) {
|
|
1701
|
+
const i = this._subscribers.get(e) ?? [], r = [];
|
|
1702
|
+
for (const n of i) n.cb(...s), n.once && r.push(() => i.splice(i.indexOf(n), 1));
|
|
1703
|
+
for (const n of r) n();
|
|
1704
|
+
}
|
|
1705
|
+
prompt() {
|
|
1706
|
+
return new Promise((e) => {
|
|
1707
|
+
if (this._abortSignal) {
|
|
1708
|
+
if (this._abortSignal.aborted) return this.state = "cancel", this.close(), e(z);
|
|
1709
|
+
this._abortSignal.addEventListener("abort", () => {
|
|
1710
|
+
this.state = "cancel", this.close();
|
|
1711
|
+
}, { once: !0 });
|
|
1712
|
+
}
|
|
1713
|
+
this.rl = ot.createInterface({
|
|
1714
|
+
input: this.input,
|
|
1715
|
+
tabSize: 2,
|
|
1716
|
+
prompt: "",
|
|
1717
|
+
escapeCodeTimeout: 50,
|
|
1718
|
+
terminal: !0
|
|
1719
|
+
}), this.rl.prompt(), this.opts.initialUserInput !== void 0 && this._setUserInput(this.opts.initialUserInput, !0), this.input.on("keypress", this.onKeypress), T(this.input, !0), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
|
|
1720
|
+
this.output.write(import_src.cursor.show), this.output.off("resize", this.render), T(this.input, !1), e(this.value);
|
|
1721
|
+
}), this.once("cancel", () => {
|
|
1722
|
+
this.output.write(import_src.cursor.show), this.output.off("resize", this.render), T(this.input, !1), e(z);
|
|
1723
|
+
});
|
|
1724
|
+
});
|
|
1725
|
+
}
|
|
1726
|
+
_isActionKey(e, s) {
|
|
1727
|
+
return e === " ";
|
|
1728
|
+
}
|
|
1729
|
+
_setValue(e) {
|
|
1730
|
+
this.value = e, this.emit("value", this.value);
|
|
1731
|
+
}
|
|
1732
|
+
_setUserInput(e, s) {
|
|
1733
|
+
this.userInput = e ?? "", this.emit("userInput", this.userInput), s && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
|
|
1734
|
+
}
|
|
1735
|
+
_clearUserInput() {
|
|
1736
|
+
this.rl?.write(null, {
|
|
1737
|
+
ctrl: !0,
|
|
1738
|
+
name: "u"
|
|
1739
|
+
}), this._setUserInput("");
|
|
1740
|
+
}
|
|
1741
|
+
onKeypress(e, s) {
|
|
1742
|
+
if (this._track && s.name !== "return" && (s.name && this._isActionKey(e, s) && this.rl?.write(null, {
|
|
1743
|
+
ctrl: !0,
|
|
1744
|
+
name: "h"
|
|
1745
|
+
}), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"), s?.name && (!this._track && _.aliases.has(s.name) && this.emit("cursor", _.aliases.get(s.name)), _.actions.has(s.name) && this.emit("cursor", s.name)), e && (e.toLowerCase() === "y" || e.toLowerCase() === "n") && this.emit("confirm", e.toLowerCase() === "y"), this.emit("key", e?.toLowerCase(), s), s?.name === "return") {
|
|
1746
|
+
if (this.opts.validate) {
|
|
1747
|
+
const i = this.opts.validate(this.value);
|
|
1748
|
+
i && (this.error = i instanceof Error ? i.message : i, this.state = "error", this.rl?.write(this.userInput));
|
|
1749
|
+
}
|
|
1750
|
+
this.state !== "error" && (this.state = "submit");
|
|
1751
|
+
}
|
|
1752
|
+
H$1([
|
|
1753
|
+
e,
|
|
1754
|
+
s?.name,
|
|
1755
|
+
s?.sequence
|
|
1756
|
+
], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
|
|
1757
|
+
}
|
|
1758
|
+
close() {
|
|
1759
|
+
this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
|
|
1760
|
+
`), T(this.input, !1), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
|
|
1761
|
+
}
|
|
1762
|
+
restoreCursor() {
|
|
1763
|
+
const e = K$1(this._prevFrame, process.stdout.columns, {
|
|
1764
|
+
hard: !0,
|
|
1765
|
+
trim: !1
|
|
1766
|
+
}).split(`
|
|
1767
|
+
`).length - 1;
|
|
1768
|
+
this.output.write(import_src.cursor.move(-999, e * -1));
|
|
1769
|
+
}
|
|
1770
|
+
render() {
|
|
1771
|
+
const e = K$1(this._render(this) ?? "", process.stdout.columns, {
|
|
1772
|
+
hard: !0,
|
|
1773
|
+
trim: !1
|
|
1774
|
+
});
|
|
1775
|
+
if (e !== this._prevFrame) {
|
|
1776
|
+
if (this.state === "initial") this.output.write(import_src.cursor.hide);
|
|
1777
|
+
else {
|
|
1778
|
+
const s = _t(this._prevFrame, e), i = nt$1(this.output);
|
|
1779
|
+
if (this.restoreCursor(), s) {
|
|
1780
|
+
const r = Math.max(0, s.numLinesAfter - i), n = Math.max(0, s.numLinesBefore - i);
|
|
1781
|
+
let u = s.lines.find((a) => a >= r);
|
|
1782
|
+
if (u === void 0) {
|
|
1783
|
+
this._prevFrame = e;
|
|
1784
|
+
return;
|
|
1785
|
+
}
|
|
1786
|
+
if (s.lines.length === 1) {
|
|
1787
|
+
this.output.write(import_src.cursor.move(0, u - n)), this.output.write(import_src.erase.lines(1));
|
|
1788
|
+
const a = e.split(`
|
|
1789
|
+
`);
|
|
1790
|
+
this.output.write(a[u]), this._prevFrame = e, this.output.write(import_src.cursor.move(0, a.length - u - 1));
|
|
1791
|
+
return;
|
|
1792
|
+
} else if (s.lines.length > 1) {
|
|
1793
|
+
if (r < n) u = r;
|
|
1794
|
+
else {
|
|
1795
|
+
const l = u - n;
|
|
1796
|
+
l > 0 && this.output.write(import_src.cursor.move(0, l));
|
|
1797
|
+
}
|
|
1798
|
+
this.output.write(import_src.erase.down());
|
|
1799
|
+
const a = e.split(`
|
|
1800
|
+
`).slice(u);
|
|
1801
|
+
this.output.write(a.join(`
|
|
1802
|
+
`)), this._prevFrame = e;
|
|
1803
|
+
return;
|
|
1804
|
+
}
|
|
1805
|
+
}
|
|
1806
|
+
this.output.write(import_src.erase.down());
|
|
1807
|
+
}
|
|
1808
|
+
this.output.write(e), this.state === "initial" && (this.state = "active"), this._prevFrame = e;
|
|
1809
|
+
}
|
|
1810
|
+
}
|
|
1811
|
+
};
|
|
1812
|
+
function wt$1(t, e) {
|
|
1813
|
+
if (t === void 0 || e.length === 0) return 0;
|
|
1814
|
+
const s = e.findIndex((i) => i.value === t);
|
|
1815
|
+
return s !== -1 ? s : 0;
|
|
1816
|
+
}
|
|
1817
|
+
function Dt$1(t, e) {
|
|
1818
|
+
return (e.label ?? String(e.value)).toLowerCase().includes(t.toLowerCase());
|
|
1819
|
+
}
|
|
1820
|
+
function St$1(t, e) {
|
|
1821
|
+
if (e) return t ? e : e[0];
|
|
1822
|
+
}
|
|
1823
|
+
var Vt$1 = class extends x$1 {
|
|
1824
|
+
filteredOptions;
|
|
1825
|
+
multiple;
|
|
1826
|
+
isNavigating = !1;
|
|
1827
|
+
selectedValues = [];
|
|
1828
|
+
focusedValue;
|
|
1829
|
+
#t = 0;
|
|
1830
|
+
#s = "";
|
|
1831
|
+
#i;
|
|
1832
|
+
#e;
|
|
1833
|
+
get cursor() {
|
|
1834
|
+
return this.#t;
|
|
1835
|
+
}
|
|
1836
|
+
get userInputWithCursor() {
|
|
1837
|
+
if (!this.userInput) return import_picocolors.default.inverse(import_picocolors.default.hidden("_"));
|
|
1838
|
+
if (this._cursor >= this.userInput.length) return `${this.userInput}\u2588`;
|
|
1839
|
+
const e = this.userInput.slice(0, this._cursor), [s, ...i] = this.userInput.slice(this._cursor);
|
|
1840
|
+
return `${e}${import_picocolors.default.inverse(s)}${i.join("")}`;
|
|
1841
|
+
}
|
|
1842
|
+
get options() {
|
|
1843
|
+
return typeof this.#e == "function" ? this.#e() : this.#e;
|
|
1844
|
+
}
|
|
1845
|
+
constructor(e) {
|
|
1846
|
+
super(e), this.#e = e.options;
|
|
1847
|
+
const s = this.options;
|
|
1848
|
+
this.filteredOptions = [...s], this.multiple = e.multiple === !0, this.#i = e.filter ?? Dt$1;
|
|
1849
|
+
let i;
|
|
1850
|
+
if (e.initialValue && Array.isArray(e.initialValue) ? this.multiple ? i = e.initialValue : i = e.initialValue.slice(0, 1) : !this.multiple && this.options.length > 0 && (i = [this.options[0].value]), i) for (const r of i) {
|
|
1851
|
+
const n = s.findIndex((u) => u.value === r);
|
|
1852
|
+
n !== -1 && (this.toggleSelected(r), this.#t = n);
|
|
1853
|
+
}
|
|
1854
|
+
this.focusedValue = this.options[this.#t]?.value, this.on("key", (r, n) => this.#r(r, n)), this.on("userInput", (r) => this.#n(r));
|
|
1855
|
+
}
|
|
1856
|
+
_isActionKey(e, s) {
|
|
1857
|
+
return e === " " || this.multiple && this.isNavigating && s.name === "space" && e !== void 0 && e !== "";
|
|
1858
|
+
}
|
|
1859
|
+
#r(e, s) {
|
|
1860
|
+
const i = s.name === "up", r = s.name === "down", n = s.name === "return";
|
|
1861
|
+
i || r ? (this.#t = B(this.#t, i ? -1 : 1, this.filteredOptions), this.focusedValue = this.filteredOptions[this.#t]?.value, this.multiple || (this.selectedValues = [this.focusedValue]), this.isNavigating = !0) : n ? this.value = St$1(this.multiple, this.selectedValues) : this.multiple ? this.focusedValue !== void 0 && (s.name === "tab" || this.isNavigating && s.name === "space") ? this.toggleSelected(this.focusedValue) : this.isNavigating = !1 : (this.focusedValue && (this.selectedValues = [this.focusedValue]), this.isNavigating = !1);
|
|
1862
|
+
}
|
|
1863
|
+
deselectAll() {
|
|
1864
|
+
this.selectedValues = [];
|
|
1865
|
+
}
|
|
1866
|
+
toggleSelected(e) {
|
|
1867
|
+
this.filteredOptions.length !== 0 && (this.multiple ? this.selectedValues.includes(e) ? this.selectedValues = this.selectedValues.filter((s) => s !== e) : this.selectedValues = [...this.selectedValues, e] : this.selectedValues = [e]);
|
|
1868
|
+
}
|
|
1869
|
+
#n(e) {
|
|
1870
|
+
if (e !== this.#s) {
|
|
1871
|
+
this.#s = e;
|
|
1872
|
+
const s = this.options;
|
|
1873
|
+
e ? this.filteredOptions = s.filter((n) => this.#i(e, n)) : this.filteredOptions = [...s];
|
|
1874
|
+
this.#t = B(wt$1(this.focusedValue, this.filteredOptions), 0, this.filteredOptions);
|
|
1875
|
+
const r = this.filteredOptions[this.#t];
|
|
1876
|
+
r && !r.disabled ? this.focusedValue = r.value : this.focusedValue = void 0, this.multiple || (this.focusedValue !== void 0 ? this.toggleSelected(this.focusedValue) : this.deselectAll());
|
|
1877
|
+
}
|
|
1878
|
+
}
|
|
1879
|
+
};
|
|
1880
|
+
var kt$1 = class extends x$1 {
|
|
1881
|
+
get cursor() {
|
|
1882
|
+
return this.value ? 0 : 1;
|
|
1883
|
+
}
|
|
1884
|
+
get _value() {
|
|
1885
|
+
return this.cursor === 0;
|
|
1886
|
+
}
|
|
1887
|
+
constructor(e) {
|
|
1888
|
+
super(e, !1), this.value = !!e.initialValue, this.on("userInput", () => {
|
|
1889
|
+
this.value = this._value;
|
|
1890
|
+
}), this.on("confirm", (s) => {
|
|
1891
|
+
this.output.write(import_src.cursor.move(0, -1)), this.value = s, this.state = "submit", this.close();
|
|
1892
|
+
}), this.on("cursor", () => {
|
|
1893
|
+
this.value = !this.value;
|
|
1894
|
+
});
|
|
1895
|
+
}
|
|
1896
|
+
};
|
|
1897
|
+
var yt$1 = class extends x$1 {
|
|
1898
|
+
options;
|
|
1899
|
+
cursor = 0;
|
|
1900
|
+
#t;
|
|
1901
|
+
getGroupItems(e) {
|
|
1902
|
+
return this.options.filter((s) => s.group === e);
|
|
1903
|
+
}
|
|
1904
|
+
isGroupSelected(e) {
|
|
1905
|
+
const s = this.getGroupItems(e), i = this.value;
|
|
1906
|
+
return i === void 0 ? !1 : s.every((r) => i.includes(r.value));
|
|
1907
|
+
}
|
|
1908
|
+
toggleValue() {
|
|
1909
|
+
const e = this.options[this.cursor];
|
|
1910
|
+
if (this.value === void 0 && (this.value = []), e.group === !0) {
|
|
1911
|
+
const s = e.value, i = this.getGroupItems(s);
|
|
1912
|
+
this.isGroupSelected(s) ? this.value = this.value.filter((r) => i.findIndex((n) => n.value === r) === -1) : this.value = [...this.value, ...i.map((r) => r.value)], this.value = Array.from(new Set(this.value));
|
|
1913
|
+
} else this.value = this.value.includes(e.value) ? this.value.filter((i) => i !== e.value) : [...this.value, e.value];
|
|
1914
|
+
}
|
|
1915
|
+
constructor(e) {
|
|
1916
|
+
super(e, !1);
|
|
1917
|
+
const { options: s } = e;
|
|
1918
|
+
this.#t = e.selectableGroups !== !1, this.options = Object.entries(s).flatMap(([i, r]) => [{
|
|
1919
|
+
value: i,
|
|
1920
|
+
group: !0,
|
|
1921
|
+
label: i
|
|
1922
|
+
}, ...r.map((n) => ({
|
|
1923
|
+
...n,
|
|
1924
|
+
group: i
|
|
1925
|
+
}))]), this.value = [...e.initialValues ?? []], this.cursor = Math.max(this.options.findIndex(({ value: i }) => i === e.cursorAt), this.#t ? 0 : 1), this.on("cursor", (i) => {
|
|
1926
|
+
switch (i) {
|
|
1927
|
+
case "left":
|
|
1928
|
+
case "up": {
|
|
1929
|
+
this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
|
|
1930
|
+
const r = this.options[this.cursor]?.group === !0;
|
|
1931
|
+
!this.#t && r && (this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1);
|
|
1932
|
+
break;
|
|
1933
|
+
}
|
|
1934
|
+
case "down":
|
|
1935
|
+
case "right": {
|
|
1936
|
+
this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
|
|
1937
|
+
const r = this.options[this.cursor]?.group === !0;
|
|
1938
|
+
!this.#t && r && (this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1);
|
|
1939
|
+
break;
|
|
1940
|
+
}
|
|
1941
|
+
case "space":
|
|
1942
|
+
this.toggleValue();
|
|
1943
|
+
break;
|
|
1944
|
+
}
|
|
1945
|
+
});
|
|
1946
|
+
}
|
|
1947
|
+
};
|
|
1948
|
+
var Lt$1 = class extends x$1 {
|
|
1949
|
+
options;
|
|
1950
|
+
cursor = 0;
|
|
1951
|
+
get _value() {
|
|
1952
|
+
return this.options[this.cursor].value;
|
|
1953
|
+
}
|
|
1954
|
+
get _enabledOptions() {
|
|
1955
|
+
return this.options.filter((e) => e.disabled !== !0);
|
|
1956
|
+
}
|
|
1957
|
+
toggleAll() {
|
|
1958
|
+
const e = this._enabledOptions;
|
|
1959
|
+
this.value = this.value !== void 0 && this.value.length === e.length ? [] : e.map((i) => i.value);
|
|
1960
|
+
}
|
|
1961
|
+
toggleInvert() {
|
|
1962
|
+
const e = this.value;
|
|
1963
|
+
if (!e) return;
|
|
1964
|
+
this.value = this._enabledOptions.filter((i) => !e.includes(i.value)).map((i) => i.value);
|
|
1965
|
+
}
|
|
1966
|
+
toggleValue() {
|
|
1967
|
+
this.value === void 0 && (this.value = []);
|
|
1968
|
+
this.value = this.value.includes(this._value) ? this.value.filter((s) => s !== this._value) : [...this.value, this._value];
|
|
1969
|
+
}
|
|
1970
|
+
constructor(e) {
|
|
1971
|
+
super(e, !1), this.options = e.options, this.value = [...e.initialValues ?? []];
|
|
1972
|
+
const s = Math.max(this.options.findIndex(({ value: i }) => i === e.cursorAt), 0);
|
|
1973
|
+
this.cursor = this.options[s].disabled ? B(s, 1, this.options) : s, this.on("key", (i) => {
|
|
1974
|
+
i === "a" && this.toggleAll(), i === "i" && this.toggleInvert();
|
|
1975
|
+
}), this.on("cursor", (i) => {
|
|
1976
|
+
switch (i) {
|
|
1977
|
+
case "left":
|
|
1978
|
+
case "up":
|
|
1979
|
+
this.cursor = B(this.cursor, -1, this.options);
|
|
1980
|
+
break;
|
|
1981
|
+
case "down":
|
|
1982
|
+
case "right":
|
|
1983
|
+
this.cursor = B(this.cursor, 1, this.options);
|
|
1984
|
+
break;
|
|
1985
|
+
case "space":
|
|
1986
|
+
this.toggleValue();
|
|
1987
|
+
break;
|
|
1988
|
+
}
|
|
1989
|
+
});
|
|
1990
|
+
}
|
|
1991
|
+
};
|
|
1992
|
+
let Mt$1 = class extends x$1 {
|
|
1993
|
+
_mask = "•";
|
|
1994
|
+
get cursor() {
|
|
1995
|
+
return this._cursor;
|
|
1996
|
+
}
|
|
1997
|
+
get masked() {
|
|
1998
|
+
return this.userInput.replaceAll(/./g, this._mask);
|
|
1999
|
+
}
|
|
2000
|
+
get userInputWithCursor() {
|
|
2001
|
+
if (this.state === "submit" || this.state === "cancel") return this.masked;
|
|
2002
|
+
const e = this.userInput;
|
|
2003
|
+
if (this.cursor >= e.length) return `${this.masked}${import_picocolors.default.inverse(import_picocolors.default.hidden("_"))}`;
|
|
2004
|
+
const s = this.masked, i = s.slice(0, this.cursor), r = s.slice(this.cursor);
|
|
2005
|
+
return `${i}${import_picocolors.default.inverse(r[0])}${r.slice(1)}`;
|
|
2006
|
+
}
|
|
2007
|
+
clear() {
|
|
2008
|
+
this._clearUserInput();
|
|
2009
|
+
}
|
|
2010
|
+
constructor({ mask: e, ...s }) {
|
|
2011
|
+
super(s), this._mask = e ?? "•", this.on("userInput", (i) => {
|
|
2012
|
+
this._setValue(i);
|
|
2013
|
+
});
|
|
2014
|
+
}
|
|
2015
|
+
};
|
|
2016
|
+
var Wt$1 = class extends x$1 {
|
|
2017
|
+
options;
|
|
2018
|
+
cursor = 0;
|
|
2019
|
+
get _selectedValue() {
|
|
2020
|
+
return this.options[this.cursor];
|
|
2021
|
+
}
|
|
2022
|
+
changeValue() {
|
|
2023
|
+
this.value = this._selectedValue.value;
|
|
2024
|
+
}
|
|
2025
|
+
constructor(e) {
|
|
2026
|
+
super(e, !1), this.options = e.options;
|
|
2027
|
+
const s = this.options.findIndex(({ value: r }) => r === e.initialValue), i = s === -1 ? 0 : s;
|
|
2028
|
+
this.cursor = this.options[i].disabled ? B(i, 1, this.options) : i, this.changeValue(), this.on("cursor", (r) => {
|
|
2029
|
+
switch (r) {
|
|
2030
|
+
case "left":
|
|
2031
|
+
case "up":
|
|
2032
|
+
this.cursor = B(this.cursor, -1, this.options);
|
|
2033
|
+
break;
|
|
2034
|
+
case "down":
|
|
2035
|
+
case "right":
|
|
2036
|
+
this.cursor = B(this.cursor, 1, this.options);
|
|
2037
|
+
break;
|
|
2038
|
+
}
|
|
2039
|
+
this.changeValue();
|
|
2040
|
+
});
|
|
2041
|
+
}
|
|
2042
|
+
};
|
|
2043
|
+
var Tt$1 = class extends x$1 {
|
|
2044
|
+
options;
|
|
2045
|
+
cursor = 0;
|
|
2046
|
+
constructor(e) {
|
|
2047
|
+
super(e, !1), this.options = e.options;
|
|
2048
|
+
const s = e.caseSensitive === !0, i = this.options.map(({ value: [r] }) => s ? r : r?.toLowerCase());
|
|
2049
|
+
this.cursor = Math.max(i.indexOf(e.initialValue), 0), this.on("key", (r, n) => {
|
|
2050
|
+
if (!r) return;
|
|
2051
|
+
const u = s && n.shift ? r.toUpperCase() : r;
|
|
2052
|
+
if (!i.includes(u)) return;
|
|
2053
|
+
const a = this.options.find(({ value: [l] }) => s ? l === u : l?.toLowerCase() === r);
|
|
2054
|
+
a && (this.value = a.value, this.state = "submit", this.emit("submit"));
|
|
2055
|
+
});
|
|
2056
|
+
}
|
|
2057
|
+
};
|
|
2058
|
+
var $t$1 = class extends x$1 {
|
|
2059
|
+
get userInputWithCursor() {
|
|
2060
|
+
if (this.state === "submit") return this.userInput;
|
|
2061
|
+
const e = this.userInput;
|
|
2062
|
+
if (this.cursor >= e.length) return `${this.userInput}\u2588`;
|
|
2063
|
+
const s = e.slice(0, this.cursor), [i, ...r] = e.slice(this.cursor);
|
|
2064
|
+
return `${s}${import_picocolors.default.inverse(i)}${r.join("")}`;
|
|
2065
|
+
}
|
|
2066
|
+
get cursor() {
|
|
2067
|
+
return this._cursor;
|
|
2068
|
+
}
|
|
2069
|
+
constructor(e) {
|
|
2070
|
+
super({
|
|
2071
|
+
...e,
|
|
2072
|
+
initialUserInput: e.initialUserInput ?? e.initialValue
|
|
2073
|
+
}), this.on("userInput", (s) => {
|
|
2074
|
+
this._setValue(s);
|
|
2075
|
+
}), this.on("finalize", () => {
|
|
2076
|
+
this.value || (this.value = e.defaultValue), this.value === void 0 && (this.value = "");
|
|
2077
|
+
});
|
|
2078
|
+
}
|
|
2079
|
+
};
|
|
2080
|
+
|
|
2081
|
+
//#endregion
|
|
2082
|
+
//#region ../../node_modules/.bun/@clack+prompts@1.0.1/node_modules/@clack/prompts/dist/index.mjs
|
|
2083
|
+
function me() {
|
|
2084
|
+
return N.platform !== "win32" ? N.env.TERM !== "linux" : !!N.env.CI || !!N.env.WT_SESSION || !!N.env.TERMINUS_SUBLIME || N.env.ConEmuTask === "{cmd::Cmder}" || N.env.TERM_PROGRAM === "Terminus-Sublime" || N.env.TERM_PROGRAM === "vscode" || N.env.TERM === "xterm-256color" || N.env.TERM === "alacritty" || N.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
2085
|
+
}
|
|
2086
|
+
const et = me(), ct = () => process.env.CI === "true", Mt = (t) => t.isTTY === !0, C = (t, r) => et ? t : r, Rt = C("◆", "*"), dt = C("■", "x"), $t = C("▲", "x"), V = C("◇", "o"), ht = C("┌", "T"), d = C("│", "|"), x = C("└", "—"), Ot = C("┐", "T"), Pt = C("┘", "—"), Q = C("●", ">"), H = C("○", " "), st = C("◻", "[•]"), U = C("◼", "[+]"), q = C("◻", "[ ]"), Nt = C("▪", "•"), rt = C("─", "-"), mt = C("╮", "+"), Wt = C("├", "+"), pt = C("╯", "+"), gt = C("╰", "+"), Lt = C("╭", "+"), ft = C("●", "•"), Ft = C("◆", "*"), yt = C("▲", "!"), Et = C("■", "x"), W = (t) => {
|
|
2087
|
+
switch (t) {
|
|
2088
|
+
case "initial":
|
|
2089
|
+
case "active": return import_picocolors.default.cyan(Rt);
|
|
2090
|
+
case "cancel": return import_picocolors.default.red(dt);
|
|
2091
|
+
case "error": return import_picocolors.default.yellow($t);
|
|
2092
|
+
case "submit": return import_picocolors.default.green(V);
|
|
2093
|
+
}
|
|
2094
|
+
}, vt = (t) => {
|
|
2095
|
+
switch (t) {
|
|
2096
|
+
case "initial":
|
|
2097
|
+
case "active": return import_picocolors.default.cyan(d);
|
|
2098
|
+
case "cancel": return import_picocolors.default.red(d);
|
|
2099
|
+
case "error": return import_picocolors.default.yellow(d);
|
|
2100
|
+
case "submit": return import_picocolors.default.green(d);
|
|
2101
|
+
}
|
|
2102
|
+
}, pe = (t) => t === 161 || t === 164 || t === 167 || t === 168 || t === 170 || t === 173 || t === 174 || t >= 176 && t <= 180 || t >= 182 && t <= 186 || t >= 188 && t <= 191 || t === 198 || t === 208 || t === 215 || t === 216 || t >= 222 && t <= 225 || t === 230 || t >= 232 && t <= 234 || t === 236 || t === 237 || t === 240 || t === 242 || t === 243 || t >= 247 && t <= 250 || t === 252 || t === 254 || t === 257 || t === 273 || t === 275 || t === 283 || t === 294 || t === 295 || t === 299 || t >= 305 && t <= 307 || t === 312 || t >= 319 && t <= 322 || t === 324 || t >= 328 && t <= 331 || t === 333 || t === 338 || t === 339 || t === 358 || t === 359 || t === 363 || t === 462 || t === 464 || t === 466 || t === 468 || t === 470 || t === 472 || t === 474 || t === 476 || t === 593 || t === 609 || t === 708 || t === 711 || t >= 713 && t <= 715 || t === 717 || t === 720 || t >= 728 && t <= 731 || t === 733 || t === 735 || t >= 768 && t <= 879 || t >= 913 && t <= 929 || t >= 931 && t <= 937 || t >= 945 && t <= 961 || t >= 963 && t <= 969 || t === 1025 || t >= 1040 && t <= 1103 || t === 1105 || t === 8208 || t >= 8211 && t <= 8214 || t === 8216 || t === 8217 || t === 8220 || t === 8221 || t >= 8224 && t <= 8226 || t >= 8228 && t <= 8231 || t === 8240 || t === 8242 || t === 8243 || t === 8245 || t === 8251 || t === 8254 || t === 8308 || t === 8319 || t >= 8321 && t <= 8324 || t === 8364 || t === 8451 || t === 8453 || t === 8457 || t === 8467 || t === 8470 || t === 8481 || t === 8482 || t === 8486 || t === 8491 || t === 8531 || t === 8532 || t >= 8539 && t <= 8542 || t >= 8544 && t <= 8555 || t >= 8560 && t <= 8569 || t === 8585 || t >= 8592 && t <= 8601 || t === 8632 || t === 8633 || t === 8658 || t === 8660 || t === 8679 || t === 8704 || t === 8706 || t === 8707 || t === 8711 || t === 8712 || t === 8715 || t === 8719 || t === 8721 || t === 8725 || t === 8730 || t >= 8733 && t <= 8736 || t === 8739 || t === 8741 || t >= 8743 && t <= 8748 || t === 8750 || t >= 8756 && t <= 8759 || t === 8764 || t === 8765 || t === 8776 || t === 8780 || t === 8786 || t === 8800 || t === 8801 || t >= 8804 && t <= 8807 || t === 8810 || t === 8811 || t === 8814 || t === 8815 || t === 8834 || t === 8835 || t === 8838 || t === 8839 || t === 8853 || t === 8857 || t === 8869 || t === 8895 || t === 8978 || t >= 9312 && t <= 9449 || t >= 9451 && t <= 9547 || t >= 9552 && t <= 9587 || t >= 9600 && t <= 9615 || t >= 9618 && t <= 9621 || t === 9632 || t === 9633 || t >= 9635 && t <= 9641 || t === 9650 || t === 9651 || t === 9654 || t === 9655 || t === 9660 || t === 9661 || t === 9664 || t === 9665 || t >= 9670 && t <= 9672 || t === 9675 || t >= 9678 && t <= 9681 || t >= 9698 && t <= 9701 || t === 9711 || t === 9733 || t === 9734 || t === 9737 || t === 9742 || t === 9743 || t === 9756 || t === 9758 || t === 9792 || t === 9794 || t === 9824 || t === 9825 || t >= 9827 && t <= 9829 || t >= 9831 && t <= 9834 || t === 9836 || t === 9837 || t === 9839 || t === 9886 || t === 9887 || t === 9919 || t >= 9926 && t <= 9933 || t >= 9935 && t <= 9939 || t >= 9941 && t <= 9953 || t === 9955 || t === 9960 || t === 9961 || t >= 9963 && t <= 9969 || t === 9972 || t >= 9974 && t <= 9977 || t === 9979 || t === 9980 || t === 9982 || t === 9983 || t === 10045 || t >= 10102 && t <= 10111 || t >= 11094 && t <= 11097 || t >= 12872 && t <= 12879 || t >= 57344 && t <= 63743 || t >= 65024 && t <= 65039 || t === 65533 || t >= 127232 && t <= 127242 || t >= 127248 && t <= 127277 || t >= 127280 && t <= 127337 || t >= 127344 && t <= 127373 || t === 127375 || t === 127376 || t >= 127387 && t <= 127404 || t >= 917760 && t <= 917999 || t >= 983040 && t <= 1048573 || t >= 1048576 && t <= 1114109, ge = (t) => t === 12288 || t >= 65281 && t <= 65376 || t >= 65504 && t <= 65510, fe = (t) => t >= 4352 && t <= 4447 || t === 8986 || t === 8987 || t === 9001 || t === 9002 || t >= 9193 && t <= 9196 || t === 9200 || t === 9203 || t === 9725 || t === 9726 || t === 9748 || t === 9749 || t >= 9800 && t <= 9811 || t === 9855 || t === 9875 || t === 9889 || t === 9898 || t === 9899 || t === 9917 || t === 9918 || t === 9924 || t === 9925 || t === 9934 || t === 9940 || t === 9962 || t === 9970 || t === 9971 || t === 9973 || t === 9978 || t === 9981 || t === 9989 || t === 9994 || t === 9995 || t === 10024 || t === 10060 || t === 10062 || t >= 10067 && t <= 10069 || t === 10071 || t >= 10133 && t <= 10135 || t === 10160 || t === 10175 || t === 11035 || t === 11036 || t === 11088 || t === 11093 || t >= 11904 && t <= 11929 || t >= 11931 && t <= 12019 || t >= 12032 && t <= 12245 || t >= 12272 && t <= 12287 || t >= 12289 && t <= 12350 || t >= 12353 && t <= 12438 || t >= 12441 && t <= 12543 || t >= 12549 && t <= 12591 || t >= 12593 && t <= 12686 || t >= 12688 && t <= 12771 || t >= 12783 && t <= 12830 || t >= 12832 && t <= 12871 || t >= 12880 && t <= 19903 || t >= 19968 && t <= 42124 || t >= 42128 && t <= 42182 || t >= 43360 && t <= 43388 || t >= 44032 && t <= 55203 || t >= 63744 && t <= 64255 || t >= 65040 && t <= 65049 || t >= 65072 && t <= 65106 || t >= 65108 && t <= 65126 || t >= 65128 && t <= 65131 || t >= 94176 && t <= 94180 || t === 94192 || t === 94193 || t >= 94208 && t <= 100343 || t >= 100352 && t <= 101589 || t >= 101632 && t <= 101640 || t >= 110576 && t <= 110579 || t >= 110581 && t <= 110587 || t === 110589 || t === 110590 || t >= 110592 && t <= 110882 || t === 110898 || t >= 110928 && t <= 110930 || t === 110933 || t >= 110948 && t <= 110951 || t >= 110960 && t <= 111355 || t === 126980 || t === 127183 || t === 127374 || t >= 127377 && t <= 127386 || t >= 127488 && t <= 127490 || t >= 127504 && t <= 127547 || t >= 127552 && t <= 127560 || t === 127568 || t === 127569 || t >= 127584 && t <= 127589 || t >= 127744 && t <= 127776 || t >= 127789 && t <= 127797 || t >= 127799 && t <= 127868 || t >= 127870 && t <= 127891 || t >= 127904 && t <= 127946 || t >= 127951 && t <= 127955 || t >= 127968 && t <= 127984 || t === 127988 || t >= 127992 && t <= 128062 || t === 128064 || t >= 128066 && t <= 128252 || t >= 128255 && t <= 128317 || t >= 128331 && t <= 128334 || t >= 128336 && t <= 128359 || t === 128378 || t === 128405 || t === 128406 || t === 128420 || t >= 128507 && t <= 128591 || t >= 128640 && t <= 128709 || t === 128716 || t >= 128720 && t <= 128722 || t >= 128725 && t <= 128727 || t >= 128732 && t <= 128735 || t === 128747 || t === 128748 || t >= 128756 && t <= 128764 || t >= 128992 && t <= 129003 || t === 129008 || t >= 129292 && t <= 129338 || t >= 129340 && t <= 129349 || t >= 129351 && t <= 129535 || t >= 129648 && t <= 129660 || t >= 129664 && t <= 129672 || t >= 129680 && t <= 129725 || t >= 129727 && t <= 129733 || t >= 129742 && t <= 129755 || t >= 129760 && t <= 129768 || t >= 129776 && t <= 129784 || t >= 131072 && t <= 196605 || t >= 196608 && t <= 262141, At = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y, it = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y, nt = /\t{1,1000}/y, wt = /[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/uy, at = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y, Fe = /\p{M}+/gu, ye = {
|
|
2103
|
+
limit: Infinity,
|
|
2104
|
+
ellipsis: ""
|
|
2105
|
+
}, jt = (t, r = {}, s = {}) => {
|
|
2106
|
+
const i = r.limit ?? Infinity, a = r.ellipsis ?? "", o = r?.ellipsisWidth ?? (a ? jt(a, ye, s).width : 0), u = s.ansiWidth ?? 0, l = s.controlWidth ?? 0, n = s.tabWidth ?? 8, c = s.ambiguousWidth ?? 1, g = s.emojiWidth ?? 2, F = s.fullWidthWidth ?? 2, p = s.regularWidth ?? 1, E = s.wideWidth ?? 2;
|
|
2107
|
+
let $ = 0, m = 0, h = t.length, y = 0, f = !1, v = h, S = Math.max(0, i - o), I = 0, B = 0, A = 0, w = 0;
|
|
2108
|
+
t: for (;;) {
|
|
2109
|
+
if (B > I || m >= h && m > $) {
|
|
2110
|
+
const _ = t.slice(I, B) || t.slice($, m);
|
|
2111
|
+
y = 0;
|
|
2112
|
+
for (const D of _.replaceAll(Fe, "")) {
|
|
2113
|
+
const T = D.codePointAt(0) || 0;
|
|
2114
|
+
if (ge(T) ? w = F : fe(T) ? w = E : c !== p && pe(T) ? w = c : w = p, A + w > S && (v = Math.min(v, Math.max(I, $) + y)), A + w > i) {
|
|
2115
|
+
f = !0;
|
|
2116
|
+
break t;
|
|
2117
|
+
}
|
|
2118
|
+
y += D.length, A += w;
|
|
2119
|
+
}
|
|
2120
|
+
I = B = 0;
|
|
2121
|
+
}
|
|
2122
|
+
if (m >= h) break;
|
|
2123
|
+
if (at.lastIndex = m, at.test(t)) {
|
|
2124
|
+
if (y = at.lastIndex - m, w = y * p, A + w > S && (v = Math.min(v, m + Math.floor((S - A) / p))), A + w > i) {
|
|
2125
|
+
f = !0;
|
|
2126
|
+
break;
|
|
2127
|
+
}
|
|
2128
|
+
A += w, I = $, B = m, m = $ = at.lastIndex;
|
|
2129
|
+
continue;
|
|
2130
|
+
}
|
|
2131
|
+
if (At.lastIndex = m, At.test(t)) {
|
|
2132
|
+
if (A + u > S && (v = Math.min(v, m)), A + u > i) {
|
|
2133
|
+
f = !0;
|
|
2134
|
+
break;
|
|
2135
|
+
}
|
|
2136
|
+
A += u, I = $, B = m, m = $ = At.lastIndex;
|
|
2137
|
+
continue;
|
|
2138
|
+
}
|
|
2139
|
+
if (it.lastIndex = m, it.test(t)) {
|
|
2140
|
+
if (y = it.lastIndex - m, w = y * l, A + w > S && (v = Math.min(v, m + Math.floor((S - A) / l))), A + w > i) {
|
|
2141
|
+
f = !0;
|
|
2142
|
+
break;
|
|
2143
|
+
}
|
|
2144
|
+
A += w, I = $, B = m, m = $ = it.lastIndex;
|
|
2145
|
+
continue;
|
|
2146
|
+
}
|
|
2147
|
+
if (nt.lastIndex = m, nt.test(t)) {
|
|
2148
|
+
if (y = nt.lastIndex - m, w = y * n, A + w > S && (v = Math.min(v, m + Math.floor((S - A) / n))), A + w > i) {
|
|
2149
|
+
f = !0;
|
|
2150
|
+
break;
|
|
2151
|
+
}
|
|
2152
|
+
A += w, I = $, B = m, m = $ = nt.lastIndex;
|
|
2153
|
+
continue;
|
|
2154
|
+
}
|
|
2155
|
+
if (wt.lastIndex = m, wt.test(t)) {
|
|
2156
|
+
if (A + g > S && (v = Math.min(v, m)), A + g > i) {
|
|
2157
|
+
f = !0;
|
|
2158
|
+
break;
|
|
2159
|
+
}
|
|
2160
|
+
A += g, I = $, B = m, m = $ = wt.lastIndex;
|
|
2161
|
+
continue;
|
|
2162
|
+
}
|
|
2163
|
+
m += 1;
|
|
2164
|
+
}
|
|
2165
|
+
return {
|
|
2166
|
+
width: f ? S : A,
|
|
2167
|
+
index: f ? v : h,
|
|
2168
|
+
truncated: f,
|
|
2169
|
+
ellipsed: f && i >= o
|
|
2170
|
+
};
|
|
2171
|
+
}, Ee = {
|
|
2172
|
+
limit: Infinity,
|
|
2173
|
+
ellipsis: "",
|
|
2174
|
+
ellipsisWidth: 0
|
|
2175
|
+
}, M = (t, r = {}) => jt(t, Ee, r).width, ot$1 = "\x1B", Gt = "", ve = 39, Ct = "\x07", kt = "[", Ae = "]", Vt = "m", St = `${Ae}8;;`, Ht = new RegExp(`(?:\\${kt}(?<code>\\d+)m|\\${St}(?<uri>.*)${Ct})`, "y"), we = (t) => {
|
|
2176
|
+
if (t >= 30 && t <= 37 || t >= 90 && t <= 97) return 39;
|
|
2177
|
+
if (t >= 40 && t <= 47 || t >= 100 && t <= 107) return 49;
|
|
2178
|
+
if (t === 1 || t === 2) return 22;
|
|
2179
|
+
if (t === 3) return 23;
|
|
2180
|
+
if (t === 4) return 24;
|
|
2181
|
+
if (t === 7) return 27;
|
|
2182
|
+
if (t === 8) return 28;
|
|
2183
|
+
if (t === 9) return 29;
|
|
2184
|
+
if (t === 0) return 0;
|
|
2185
|
+
}, Ut = (t) => `${ot$1}${kt}${t}${Vt}`, Kt = (t) => `${ot$1}${St}${t}${Ct}`, Ce = (t) => t.map((r) => M(r)), It = (t, r, s) => {
|
|
2186
|
+
const i = r[Symbol.iterator]();
|
|
2187
|
+
let a = !1, o = !1, u = t.at(-1), l = u === void 0 ? 0 : M(u), n = i.next(), c = i.next(), g = 0;
|
|
2188
|
+
for (; !n.done;) {
|
|
2189
|
+
const F = n.value, p = M(F);
|
|
2190
|
+
l + p <= s ? t[t.length - 1] += F : (t.push(F), l = 0), (F === ot$1 || F === Gt) && (a = !0, o = r.startsWith(St, g + 1)), a ? o ? F === Ct && (a = !1, o = !1) : F === Vt && (a = !1) : (l += p, l === s && !c.done && (t.push(""), l = 0)), n = c, c = i.next(), g += F.length;
|
|
2191
|
+
}
|
|
2192
|
+
u = t.at(-1), !l && u !== void 0 && u.length > 0 && t.length > 1 && (t[t.length - 2] += t.pop());
|
|
2193
|
+
}, Se = (t) => {
|
|
2194
|
+
const r = t.split(" ");
|
|
2195
|
+
let s = r.length;
|
|
2196
|
+
for (; s > 0 && !(M(r[s - 1]) > 0);) s--;
|
|
2197
|
+
return s === r.length ? t : r.slice(0, s).join(" ") + r.slice(s).join("");
|
|
2198
|
+
}, Ie = (t, r, s = {}) => {
|
|
2199
|
+
if (s.trim !== !1 && t.trim() === "") return "";
|
|
2200
|
+
let i = "", a, o;
|
|
2201
|
+
const u = t.split(" "), l = Ce(u);
|
|
2202
|
+
let n = [""];
|
|
2203
|
+
for (const [$, m] of u.entries()) {
|
|
2204
|
+
s.trim !== !1 && (n[n.length - 1] = (n.at(-1) ?? "").trimStart());
|
|
2205
|
+
let h = M(n.at(-1) ?? "");
|
|
2206
|
+
if ($ !== 0 && (h >= r && (s.wordWrap === !1 || s.trim === !1) && (n.push(""), h = 0), (h > 0 || s.trim === !1) && (n[n.length - 1] += " ", h++)), s.hard && l[$] > r) {
|
|
2207
|
+
const y = r - h, f = 1 + Math.floor((l[$] - y - 1) / r);
|
|
2208
|
+
Math.floor((l[$] - 1) / r) < f && n.push(""), It(n, m, r);
|
|
2209
|
+
continue;
|
|
2210
|
+
}
|
|
2211
|
+
if (h + l[$] > r && h > 0 && l[$] > 0) {
|
|
2212
|
+
if (s.wordWrap === !1 && h < r) {
|
|
2213
|
+
It(n, m, r);
|
|
2214
|
+
continue;
|
|
2215
|
+
}
|
|
2216
|
+
n.push("");
|
|
2217
|
+
}
|
|
2218
|
+
if (h + l[$] > r && s.wordWrap === !1) {
|
|
2219
|
+
It(n, m, r);
|
|
2220
|
+
continue;
|
|
2221
|
+
}
|
|
2222
|
+
n[n.length - 1] += m;
|
|
2223
|
+
}
|
|
2224
|
+
s.trim !== !1 && (n = n.map(($) => Se($)));
|
|
2225
|
+
const c = n.join(`
|
|
2226
|
+
`), g = c[Symbol.iterator]();
|
|
2227
|
+
let F = g.next(), p = g.next(), E = 0;
|
|
2228
|
+
for (; !F.done;) {
|
|
2229
|
+
const $ = F.value, m = p.value;
|
|
2230
|
+
if (i += $, $ === ot$1 || $ === Gt) {
|
|
2231
|
+
Ht.lastIndex = E + 1;
|
|
2232
|
+
const f = Ht.exec(c)?.groups;
|
|
2233
|
+
if (f?.code !== void 0) {
|
|
2234
|
+
const v = Number.parseFloat(f.code);
|
|
2235
|
+
a = v === ve ? void 0 : v;
|
|
2236
|
+
} else f?.uri !== void 0 && (o = f.uri.length === 0 ? void 0 : f.uri);
|
|
2237
|
+
}
|
|
2238
|
+
const h = a ? we(a) : void 0;
|
|
2239
|
+
m === `
|
|
2240
|
+
` ? (o && (i += Kt("")), a && h && (i += Ut(h))) : $ === `
|
|
2241
|
+
` && (a && h && (i += Ut(a)), o && (i += Kt(o))), E += $.length, F = p, p = g.next();
|
|
2242
|
+
}
|
|
2243
|
+
return i;
|
|
2244
|
+
};
|
|
2245
|
+
function J(t, r, s) {
|
|
2246
|
+
return String(t).normalize().replaceAll(`\r
|
|
2247
|
+
`, `
|
|
2248
|
+
`).split(`
|
|
2249
|
+
`).map((i) => Ie(i, r, s)).join(`
|
|
2250
|
+
`);
|
|
2251
|
+
}
|
|
2252
|
+
const be = (t, r, s, i, a) => {
|
|
2253
|
+
let o = r, u = 0;
|
|
2254
|
+
for (let l = s; l < i; l++) {
|
|
2255
|
+
const n = t[l];
|
|
2256
|
+
if (o = o - n.length, u++, o <= a) break;
|
|
2257
|
+
}
|
|
2258
|
+
return {
|
|
2259
|
+
lineCount: o,
|
|
2260
|
+
removals: u
|
|
2261
|
+
};
|
|
2262
|
+
}, X = (t) => {
|
|
2263
|
+
const { cursor: r, options: s, style: i } = t, a = t.output ?? process.stdout, o = rt$1(a), u = t.columnPadding ?? 0, l = t.rowPadding ?? 4, n = o - u, c = nt$1(a), g = import_picocolors.default.dim("..."), F = t.maxItems ?? Number.POSITIVE_INFINITY, p = Math.max(c - l, 0), E = Math.max(Math.min(F, p), 5);
|
|
2264
|
+
let $ = 0;
|
|
2265
|
+
r >= E - 3 && ($ = Math.max(Math.min(r - E + 3, s.length - E), 0));
|
|
2266
|
+
let m = E < s.length && $ > 0, h = E < s.length && $ + E < s.length;
|
|
2267
|
+
const y = Math.min($ + E, s.length), f = [];
|
|
2268
|
+
let v = 0;
|
|
2269
|
+
m && v++, h && v++;
|
|
2270
|
+
const S = $ + (m ? 1 : 0), I = y - (h ? 1 : 0);
|
|
2271
|
+
for (let A = S; A < I; A++) {
|
|
2272
|
+
const w = J(i(s[A], A === r), n, {
|
|
2273
|
+
hard: !0,
|
|
2274
|
+
trim: !1
|
|
2275
|
+
}).split(`
|
|
2276
|
+
`);
|
|
2277
|
+
f.push(w), v += w.length;
|
|
2278
|
+
}
|
|
2279
|
+
if (v > p) {
|
|
2280
|
+
let A = 0, w = 0, _ = v;
|
|
2281
|
+
const D = r - S, T = (Y, L) => be(f, _, Y, L, p);
|
|
2282
|
+
m ? ({lineCount: _, removals: A} = T(0, D), _ > p && ({lineCount: _, removals: w} = T(D + 1, f.length))) : ({lineCount: _, removals: w} = T(D + 1, f.length), _ > p && ({lineCount: _, removals: A} = T(0, D))), A > 0 && (m = !0, f.splice(0, A)), w > 0 && (h = !0, f.splice(f.length - w, w));
|
|
2283
|
+
}
|
|
2284
|
+
const B = [];
|
|
2285
|
+
m && B.push(g);
|
|
2286
|
+
for (const A of f) for (const w of A) B.push(w);
|
|
2287
|
+
return h && B.push(g), B;
|
|
2288
|
+
};
|
|
2289
|
+
function qt(t) {
|
|
2290
|
+
return t.label ?? String(t.value ?? "");
|
|
2291
|
+
}
|
|
2292
|
+
function Jt(t, r) {
|
|
2293
|
+
if (!t) return !0;
|
|
2294
|
+
const s = (r.label ?? String(r.value ?? "")).toLowerCase(), i = (r.hint ?? "").toLowerCase(), a = String(r.value).toLowerCase(), o = t.toLowerCase();
|
|
2295
|
+
return s.includes(o) || i.includes(o) || a.includes(o);
|
|
2296
|
+
}
|
|
2297
|
+
function Be(t, r) {
|
|
2298
|
+
const s = [];
|
|
2299
|
+
for (const i of r) t.includes(i.value) && s.push(i);
|
|
2300
|
+
return s;
|
|
2301
|
+
}
|
|
2302
|
+
const Xt = (t) => new Vt$1({
|
|
2303
|
+
options: t.options,
|
|
2304
|
+
initialValue: t.initialValue ? [t.initialValue] : void 0,
|
|
2305
|
+
initialUserInput: t.initialUserInput,
|
|
2306
|
+
filter: t.filter ?? ((r, s) => Jt(r, s)),
|
|
2307
|
+
signal: t.signal,
|
|
2308
|
+
input: t.input,
|
|
2309
|
+
output: t.output,
|
|
2310
|
+
validate: t.validate,
|
|
2311
|
+
render() {
|
|
2312
|
+
const r = t.withGuide ?? _.withGuide, s = r ? [`${import_picocolors.default.gray(d)}`, `${W(this.state)} ${t.message}`] : [`${W(this.state)} ${t.message}`], i = this.userInput, a = this.options, o = t.placeholder, u = i === "" && o !== void 0, l = (n, c) => {
|
|
2313
|
+
const g = qt(n), F = n.hint && n.value === this.focusedValue ? import_picocolors.default.dim(` (${n.hint})`) : "";
|
|
2314
|
+
switch (c) {
|
|
2315
|
+
case "active": return `${import_picocolors.default.green(Q)} ${g}${F}`;
|
|
2316
|
+
case "inactive": return `${import_picocolors.default.dim(H)} ${import_picocolors.default.dim(g)}`;
|
|
2317
|
+
case "disabled": return `${import_picocolors.default.gray(H)} ${import_picocolors.default.strikethrough(import_picocolors.default.gray(g))}`;
|
|
2318
|
+
}
|
|
2319
|
+
};
|
|
2320
|
+
switch (this.state) {
|
|
2321
|
+
case "submit": {
|
|
2322
|
+
const n = Be(this.selectedValues, a), c = n.length > 0 ? ` ${import_picocolors.default.dim(n.map(qt).join(", "))}` : "", g = r ? import_picocolors.default.gray(d) : "";
|
|
2323
|
+
return `${s.join(`
|
|
2324
|
+
`)}
|
|
2325
|
+
${g}${c}`;
|
|
2326
|
+
}
|
|
2327
|
+
case "cancel": {
|
|
2328
|
+
const n = i ? ` ${import_picocolors.default.strikethrough(import_picocolors.default.dim(i))}` : "", c = r ? import_picocolors.default.gray(d) : "";
|
|
2329
|
+
return `${s.join(`
|
|
2330
|
+
`)}
|
|
2331
|
+
${c}${n}`;
|
|
2332
|
+
}
|
|
2333
|
+
default: {
|
|
2334
|
+
const n = this.state === "error" ? import_picocolors.default.yellow : import_picocolors.default.cyan, c = r ? `${n(d)} ` : "", g = r ? n(x) : "";
|
|
2335
|
+
let F = "";
|
|
2336
|
+
if (this.isNavigating || u) {
|
|
2337
|
+
const f = u ? o : i;
|
|
2338
|
+
F = f !== "" ? ` ${import_picocolors.default.dim(f)}` : "";
|
|
2339
|
+
} else F = ` ${this.userInputWithCursor}`;
|
|
2340
|
+
const p = this.filteredOptions.length !== a.length ? import_picocolors.default.dim(` (${this.filteredOptions.length} match${this.filteredOptions.length === 1 ? "" : "es"})`) : "", E = this.filteredOptions.length === 0 && i ? [`${c}${import_picocolors.default.yellow("No matches found")}`] : [], $ = this.state === "error" ? [`${c}${import_picocolors.default.yellow(this.error)}`] : [];
|
|
2341
|
+
r && s.push(`${c.trimEnd()}`), s.push(`${c}${import_picocolors.default.dim("Search:")}${F}${p}`, ...E, ...$);
|
|
2342
|
+
const h = [`${c}${[
|
|
2343
|
+
`${import_picocolors.default.dim("↑/↓")} to select`,
|
|
2344
|
+
`${import_picocolors.default.dim("Enter:")} confirm`,
|
|
2345
|
+
`${import_picocolors.default.dim("Type:")} to search`
|
|
2346
|
+
].join(" • ")}`, g], y = this.filteredOptions.length === 0 ? [] : X({
|
|
2347
|
+
cursor: this.cursor,
|
|
2348
|
+
options: this.filteredOptions,
|
|
2349
|
+
columnPadding: r ? 3 : 0,
|
|
2350
|
+
rowPadding: s.length + h.length,
|
|
2351
|
+
style: (f, v) => l(f, f.disabled ? "disabled" : v ? "active" : "inactive"),
|
|
2352
|
+
maxItems: t.maxItems,
|
|
2353
|
+
output: t.output
|
|
2354
|
+
});
|
|
2355
|
+
return [
|
|
2356
|
+
...s,
|
|
2357
|
+
...y.map((f) => `${c}${f}`),
|
|
2358
|
+
...h
|
|
2359
|
+
].join(`
|
|
2360
|
+
`);
|
|
2361
|
+
}
|
|
2362
|
+
}
|
|
2363
|
+
}
|
|
2364
|
+
}).prompt(), xe = (t) => {
|
|
2365
|
+
const r = (i, a, o, u) => {
|
|
2366
|
+
const l = o.includes(i.value), n = i.label ?? String(i.value ?? ""), c = i.hint && u !== void 0 && i.value === u ? import_picocolors.default.dim(` (${i.hint})`) : "", g = l ? import_picocolors.default.green(U) : import_picocolors.default.dim(q);
|
|
2367
|
+
return i.disabled ? `${import_picocolors.default.gray(q)} ${import_picocolors.default.strikethrough(import_picocolors.default.gray(n))}` : a ? `${g} ${n}${c}` : `${g} ${import_picocolors.default.dim(n)}`;
|
|
2368
|
+
}, s = new Vt$1({
|
|
2369
|
+
options: t.options,
|
|
2370
|
+
multiple: !0,
|
|
2371
|
+
filter: t.filter ?? ((i, a) => Jt(i, a)),
|
|
2372
|
+
validate: () => {
|
|
2373
|
+
if (t.required && s.selectedValues.length === 0) return "Please select at least one item";
|
|
2374
|
+
},
|
|
2375
|
+
initialValue: t.initialValues,
|
|
2376
|
+
signal: t.signal,
|
|
2377
|
+
input: t.input,
|
|
2378
|
+
output: t.output,
|
|
2379
|
+
render() {
|
|
2380
|
+
const i = `${import_picocolors.default.gray(d)}
|
|
2381
|
+
${W(this.state)} ${t.message}
|
|
2382
|
+
`, a = this.userInput, o = t.placeholder, u = a === "" && o !== void 0, l = this.isNavigating || u ? import_picocolors.default.dim(u ? o : a) : this.userInputWithCursor, n = this.options, c = this.filteredOptions.length !== n.length ? import_picocolors.default.dim(` (${this.filteredOptions.length} match${this.filteredOptions.length === 1 ? "" : "es"})`) : "";
|
|
2383
|
+
switch (this.state) {
|
|
2384
|
+
case "submit": return `${i}${import_picocolors.default.gray(d)} ${import_picocolors.default.dim(`${this.selectedValues.length} items selected`)}`;
|
|
2385
|
+
case "cancel": return `${i}${import_picocolors.default.gray(d)} ${import_picocolors.default.strikethrough(import_picocolors.default.dim(a))}`;
|
|
2386
|
+
default: {
|
|
2387
|
+
const g = this.state === "error" ? import_picocolors.default.yellow : import_picocolors.default.cyan, F = [
|
|
2388
|
+
`${import_picocolors.default.dim("↑/↓")} to navigate`,
|
|
2389
|
+
`${import_picocolors.default.dim(this.isNavigating ? "Space/Tab:" : "Tab:")} select`,
|
|
2390
|
+
`${import_picocolors.default.dim("Enter:")} confirm`,
|
|
2391
|
+
`${import_picocolors.default.dim("Type:")} to search`
|
|
2392
|
+
], p = this.filteredOptions.length === 0 && a ? [`${g(d)} ${import_picocolors.default.yellow("No matches found")}`] : [], E = this.state === "error" ? [`${g(d)} ${import_picocolors.default.yellow(this.error)}`] : [], $ = [
|
|
2393
|
+
...`${i}${g(d)}`.split(`
|
|
2394
|
+
`),
|
|
2395
|
+
`${g(d)} ${import_picocolors.default.dim("Search:")} ${l}${c}`,
|
|
2396
|
+
...p,
|
|
2397
|
+
...E
|
|
2398
|
+
], m = [`${g(d)} ${F.join(" • ")}`, `${g(x)}`], h = X({
|
|
2399
|
+
cursor: this.cursor,
|
|
2400
|
+
options: this.filteredOptions,
|
|
2401
|
+
style: (y, f) => r(y, f, this.selectedValues, this.focusedValue),
|
|
2402
|
+
maxItems: t.maxItems,
|
|
2403
|
+
output: t.output,
|
|
2404
|
+
rowPadding: $.length + m.length
|
|
2405
|
+
});
|
|
2406
|
+
return [
|
|
2407
|
+
...$,
|
|
2408
|
+
...h.map((y) => `${g(d)} ${y}`),
|
|
2409
|
+
...m
|
|
2410
|
+
].join(`
|
|
2411
|
+
`);
|
|
2412
|
+
}
|
|
2413
|
+
}
|
|
2414
|
+
}
|
|
2415
|
+
});
|
|
2416
|
+
return s.prompt();
|
|
2417
|
+
}, _e = [
|
|
2418
|
+
Lt,
|
|
2419
|
+
mt,
|
|
2420
|
+
gt,
|
|
2421
|
+
pt
|
|
2422
|
+
], De = [
|
|
2423
|
+
ht,
|
|
2424
|
+
Ot,
|
|
2425
|
+
x,
|
|
2426
|
+
Pt
|
|
2427
|
+
];
|
|
2428
|
+
function Yt(t, r, s, i) {
|
|
2429
|
+
let a = s, o = s;
|
|
2430
|
+
return i === "center" ? a = Math.floor((r - t) / 2) : i === "right" && (a = r - t - s), o = r - a - t, [a, o];
|
|
2431
|
+
}
|
|
2432
|
+
const Te = (t) => t, Me = (t = "", r = "", s) => {
|
|
2433
|
+
const i = s?.output ?? process.stdout, a = rt$1(i), o = 2, u = s?.titlePadding ?? 1, l = s?.contentPadding ?? 2, n = s?.width === void 0 || s.width === "auto" ? 1 : Math.min(1, s.width), c = s?.withGuide ?? _.withGuide ? `${d} ` : "", g = s?.formatBorder ?? Te, F = (s?.rounded ? _e : De).map(g), p = g(rt), E = g(d), $ = M(c), m = M(r), h = a - $;
|
|
2434
|
+
let y = Math.floor(a * n) - $;
|
|
2435
|
+
if (s?.width === "auto") {
|
|
2436
|
+
const _ = t.split(`
|
|
2437
|
+
`);
|
|
2438
|
+
let D = m + u * 2;
|
|
2439
|
+
for (const Y of _) {
|
|
2440
|
+
const L = M(Y) + l * 2;
|
|
2441
|
+
L > D && (D = L);
|
|
2442
|
+
}
|
|
2443
|
+
const T = D + o;
|
|
2444
|
+
T < y && (y = T);
|
|
2445
|
+
}
|
|
2446
|
+
y % 2 !== 0 && (y < h ? y++ : y--);
|
|
2447
|
+
const f = y - o, v = f - u * 2, S = m > v ? `${r.slice(0, v - 3)}...` : r, [I, B] = Yt(M(S), f, u, s?.titleAlign), A = J(t, f - l * 2, {
|
|
2448
|
+
hard: !0,
|
|
2449
|
+
trim: !1
|
|
2450
|
+
});
|
|
2451
|
+
i.write(`${c}${F[0]}${p.repeat(I)}${S}${p.repeat(B)}${F[1]}
|
|
2452
|
+
`);
|
|
2453
|
+
const w = A.split(`
|
|
2454
|
+
`);
|
|
2455
|
+
for (const _ of w) {
|
|
2456
|
+
const [D, T] = Yt(M(_), f, l, s?.contentAlign);
|
|
2457
|
+
i.write(`${c}${E}${" ".repeat(D)}${_}${" ".repeat(T)}${E}
|
|
2458
|
+
`);
|
|
2459
|
+
}
|
|
2460
|
+
i.write(`${c}${F[2]}${p.repeat(f)}${F[3]}
|
|
2461
|
+
`);
|
|
2462
|
+
}, Re = (t) => {
|
|
2463
|
+
const r = t.active ?? "Yes", s = t.inactive ?? "No";
|
|
2464
|
+
return new kt$1({
|
|
2465
|
+
active: r,
|
|
2466
|
+
inactive: s,
|
|
2467
|
+
signal: t.signal,
|
|
2468
|
+
input: t.input,
|
|
2469
|
+
output: t.output,
|
|
2470
|
+
initialValue: t.initialValue ?? !0,
|
|
2471
|
+
render() {
|
|
2472
|
+
const i = t.withGuide ?? _.withGuide, a = `${i ? `${import_picocolors.default.gray(d)}
|
|
2473
|
+
` : ""}${W(this.state)} ${t.message}
|
|
2474
|
+
`, o = this.value ? r : s;
|
|
2475
|
+
switch (this.state) {
|
|
2476
|
+
case "submit": return `${a}${i ? `${import_picocolors.default.gray(d)} ` : ""}${import_picocolors.default.dim(o)}`;
|
|
2477
|
+
case "cancel": return `${a}${i ? `${import_picocolors.default.gray(d)} ` : ""}${import_picocolors.default.strikethrough(import_picocolors.default.dim(o))}${i ? `
|
|
2478
|
+
${import_picocolors.default.gray(d)}` : ""}`;
|
|
2479
|
+
default: {
|
|
2480
|
+
const u = i ? `${import_picocolors.default.cyan(d)} ` : "", l = i ? import_picocolors.default.cyan(x) : "";
|
|
2481
|
+
return `${a}${u}${this.value ? `${import_picocolors.default.green(Q)} ${r}` : `${import_picocolors.default.dim(H)} ${import_picocolors.default.dim(r)}`}${t.vertical ? i ? `
|
|
2482
|
+
${import_picocolors.default.cyan(d)} ` : `
|
|
2483
|
+
` : ` ${import_picocolors.default.dim("/")} `}${this.value ? `${import_picocolors.default.dim(H)} ${import_picocolors.default.dim(s)}` : `${import_picocolors.default.green(Q)} ${s}`}
|
|
2484
|
+
${l}
|
|
2485
|
+
`;
|
|
2486
|
+
}
|
|
2487
|
+
}
|
|
2488
|
+
}
|
|
2489
|
+
}).prompt();
|
|
2490
|
+
}, Oe = async (t, r) => {
|
|
2491
|
+
const s = {}, i = Object.keys(t);
|
|
2492
|
+
for (const a of i) {
|
|
2493
|
+
const o = t[a], u = await o({ results: s })?.catch((l) => {
|
|
2494
|
+
throw l;
|
|
2495
|
+
});
|
|
2496
|
+
if (typeof r?.onCancel == "function" && Ct$1(u)) {
|
|
2497
|
+
s[a] = "canceled", r.onCancel({ results: s });
|
|
2498
|
+
continue;
|
|
2499
|
+
}
|
|
2500
|
+
s[a] = u;
|
|
2501
|
+
}
|
|
2502
|
+
return s;
|
|
2503
|
+
}, Pe = (t) => {
|
|
2504
|
+
const { selectableGroups: r = !0, groupSpacing: s = 0 } = t, i = (o, u, l = []) => {
|
|
2505
|
+
const n = o.label ?? String(o.value), c = typeof o.group == "string", g = c && (l[l.indexOf(o) + 1] ?? { group: !0 }), F = c && g && g.group === !0, p = c ? r ? `${F ? x : d} ` : " " : "";
|
|
2506
|
+
let E = "";
|
|
2507
|
+
if (s > 0 && !c) {
|
|
2508
|
+
const m = `
|
|
2509
|
+
${import_picocolors.default.cyan(d)}`;
|
|
2510
|
+
E = `${m.repeat(s - 1)}${m} `;
|
|
2511
|
+
}
|
|
2512
|
+
if (u === "active") return `${E}${import_picocolors.default.dim(p)}${import_picocolors.default.cyan(st)} ${n}${o.hint ? ` ${import_picocolors.default.dim(`(${o.hint})`)}` : ""}`;
|
|
2513
|
+
if (u === "group-active") return `${E}${p}${import_picocolors.default.cyan(st)} ${import_picocolors.default.dim(n)}`;
|
|
2514
|
+
if (u === "group-active-selected") return `${E}${p}${import_picocolors.default.green(U)} ${import_picocolors.default.dim(n)}`;
|
|
2515
|
+
if (u === "selected") {
|
|
2516
|
+
const m = c || r ? import_picocolors.default.green(U) : "";
|
|
2517
|
+
return `${E}${import_picocolors.default.dim(p)}${m} ${import_picocolors.default.dim(n)}${o.hint ? ` ${import_picocolors.default.dim(`(${o.hint})`)}` : ""}`;
|
|
2518
|
+
}
|
|
2519
|
+
if (u === "cancelled") return `${import_picocolors.default.strikethrough(import_picocolors.default.dim(n))}`;
|
|
2520
|
+
if (u === "active-selected") return `${E}${import_picocolors.default.dim(p)}${import_picocolors.default.green(U)} ${n}${o.hint ? ` ${import_picocolors.default.dim(`(${o.hint})`)}` : ""}`;
|
|
2521
|
+
if (u === "submitted") return `${import_picocolors.default.dim(n)}`;
|
|
2522
|
+
const $ = c || r ? import_picocolors.default.dim(q) : "";
|
|
2523
|
+
return `${E}${import_picocolors.default.dim(p)}${$} ${import_picocolors.default.dim(n)}`;
|
|
2524
|
+
}, a = t.required ?? !0;
|
|
2525
|
+
return new yt$1({
|
|
2526
|
+
options: t.options,
|
|
2527
|
+
signal: t.signal,
|
|
2528
|
+
input: t.input,
|
|
2529
|
+
output: t.output,
|
|
2530
|
+
initialValues: t.initialValues,
|
|
2531
|
+
required: a,
|
|
2532
|
+
cursorAt: t.cursorAt,
|
|
2533
|
+
selectableGroups: r,
|
|
2534
|
+
validate(o) {
|
|
2535
|
+
if (a && (o === void 0 || o.length === 0)) return `Please select at least one option.
|
|
2536
|
+
${import_picocolors.default.reset(import_picocolors.default.dim(`Press ${import_picocolors.default.gray(import_picocolors.default.bgWhite(import_picocolors.default.inverse(" space ")))} to select, ${import_picocolors.default.gray(import_picocolors.default.bgWhite(import_picocolors.default.inverse(" enter ")))} to submit`))}`;
|
|
2537
|
+
},
|
|
2538
|
+
render() {
|
|
2539
|
+
const o = `${import_picocolors.default.gray(d)}
|
|
2540
|
+
${W(this.state)} ${t.message}
|
|
2541
|
+
`, u = this.value ?? [];
|
|
2542
|
+
switch (this.state) {
|
|
2543
|
+
case "submit": {
|
|
2544
|
+
const l = this.options.filter(({ value: c }) => u.includes(c)).map((c) => i(c, "submitted")), n = l.length === 0 ? "" : ` ${l.join(import_picocolors.default.dim(", "))}`;
|
|
2545
|
+
return `${o}${import_picocolors.default.gray(d)}${n}`;
|
|
2546
|
+
}
|
|
2547
|
+
case "cancel": {
|
|
2548
|
+
const l = this.options.filter(({ value: n }) => u.includes(n)).map((n) => i(n, "cancelled")).join(import_picocolors.default.dim(", "));
|
|
2549
|
+
return `${o}${import_picocolors.default.gray(d)} ${l.trim() ? `${l}
|
|
2550
|
+
${import_picocolors.default.gray(d)}` : ""}`;
|
|
2551
|
+
}
|
|
2552
|
+
case "error": {
|
|
2553
|
+
const l = this.error.split(`
|
|
2554
|
+
`).map((n, c) => c === 0 ? `${import_picocolors.default.yellow(x)} ${import_picocolors.default.yellow(n)}` : ` ${n}`).join(`
|
|
2555
|
+
`);
|
|
2556
|
+
return `${o}${import_picocolors.default.yellow(d)} ${this.options.map((n, c, g) => {
|
|
2557
|
+
const F = u.includes(n.value) || n.group === !0 && this.isGroupSelected(`${n.value}`), p = c === this.cursor;
|
|
2558
|
+
return !p && typeof n.group == "string" && this.options[this.cursor].value === n.group ? i(n, F ? "group-active-selected" : "group-active", g) : p && F ? i(n, "active-selected", g) : F ? i(n, "selected", g) : i(n, p ? "active" : "inactive", g);
|
|
2559
|
+
}).join(`
|
|
2560
|
+
${import_picocolors.default.yellow(d)} `)}
|
|
2561
|
+
${l}
|
|
2562
|
+
`;
|
|
2563
|
+
}
|
|
2564
|
+
default: {
|
|
2565
|
+
const l = this.options.map((c, g, F) => {
|
|
2566
|
+
const p = u.includes(c.value) || c.group === !0 && this.isGroupSelected(`${c.value}`), E = g === this.cursor, $ = !E && typeof c.group == "string" && this.options[this.cursor].value === c.group;
|
|
2567
|
+
let m = "";
|
|
2568
|
+
return $ ? m = i(c, p ? "group-active-selected" : "group-active", F) : E && p ? m = i(c, "active-selected", F) : p ? m = i(c, "selected", F) : m = i(c, E ? "active" : "inactive", F), `${g !== 0 && !m.startsWith(`
|
|
2569
|
+
`) ? " " : ""}${m}`;
|
|
2570
|
+
}).join(`
|
|
2571
|
+
${import_picocolors.default.cyan(d)}`), n = l.startsWith(`
|
|
2572
|
+
`) ? "" : " ";
|
|
2573
|
+
return `${o}${import_picocolors.default.cyan(d)}${n}${l}
|
|
2574
|
+
${import_picocolors.default.cyan(x)}
|
|
2575
|
+
`;
|
|
2576
|
+
}
|
|
2577
|
+
}
|
|
2578
|
+
}
|
|
2579
|
+
}).prompt();
|
|
2580
|
+
}, R = {
|
|
2581
|
+
message: (t = [], { symbol: r = import_picocolors.default.gray(d), secondarySymbol: s = import_picocolors.default.gray(d), output: i = process.stdout, spacing: a = 1, withGuide: o } = {}) => {
|
|
2582
|
+
const u = [], l = o ?? _.withGuide, n = l ? s : "", c = l ? `${r} ` : "", g = l ? `${s} ` : "";
|
|
2583
|
+
for (let p = 0; p < a; p++) u.push(n);
|
|
2584
|
+
const F = Array.isArray(t) ? t : t.split(`
|
|
2585
|
+
`);
|
|
2586
|
+
if (F.length > 0) {
|
|
2587
|
+
const [p, ...E] = F;
|
|
2588
|
+
p.length > 0 ? u.push(`${c}${p}`) : u.push(l ? r : "");
|
|
2589
|
+
for (const $ of E) $.length > 0 ? u.push(`${g}${$}`) : u.push(l ? s : "");
|
|
2590
|
+
}
|
|
2591
|
+
i.write(`${u.join(`
|
|
2592
|
+
`)}
|
|
2593
|
+
`);
|
|
2594
|
+
},
|
|
2595
|
+
info: (t, r) => {
|
|
2596
|
+
R.message(t, {
|
|
2597
|
+
...r,
|
|
2598
|
+
symbol: import_picocolors.default.blue(ft)
|
|
2599
|
+
});
|
|
2600
|
+
},
|
|
2601
|
+
success: (t, r) => {
|
|
2602
|
+
R.message(t, {
|
|
2603
|
+
...r,
|
|
2604
|
+
symbol: import_picocolors.default.green(Ft)
|
|
2605
|
+
});
|
|
2606
|
+
},
|
|
2607
|
+
step: (t, r) => {
|
|
2608
|
+
R.message(t, {
|
|
2609
|
+
...r,
|
|
2610
|
+
symbol: import_picocolors.default.green(V)
|
|
2611
|
+
});
|
|
2612
|
+
},
|
|
2613
|
+
warn: (t, r) => {
|
|
2614
|
+
R.message(t, {
|
|
2615
|
+
...r,
|
|
2616
|
+
symbol: import_picocolors.default.yellow(yt)
|
|
2617
|
+
});
|
|
2618
|
+
},
|
|
2619
|
+
warning: (t, r) => {
|
|
2620
|
+
R.warn(t, r);
|
|
2621
|
+
},
|
|
2622
|
+
error: (t, r) => {
|
|
2623
|
+
R.message(t, {
|
|
2624
|
+
...r,
|
|
2625
|
+
symbol: import_picocolors.default.red(Et)
|
|
2626
|
+
});
|
|
2627
|
+
}
|
|
2628
|
+
}, Ne = (t = "", r) => {
|
|
2629
|
+
(r?.output ?? process.stdout).write(`${import_picocolors.default.gray(x)} ${import_picocolors.default.red(t)}
|
|
2630
|
+
|
|
2631
|
+
`);
|
|
2632
|
+
}, We = (t = "", r) => {
|
|
2633
|
+
(r?.output ?? process.stdout).write(`${import_picocolors.default.gray(ht)} ${t}
|
|
2634
|
+
`);
|
|
2635
|
+
}, Le = (t = "", r) => {
|
|
2636
|
+
(r?.output ?? process.stdout).write(`${import_picocolors.default.gray(d)}
|
|
2637
|
+
${import_picocolors.default.gray(x)} ${t}
|
|
2638
|
+
|
|
2639
|
+
`);
|
|
2640
|
+
}, Z = (t, r) => t.split(`
|
|
2641
|
+
`).map((s) => r(s)).join(`
|
|
2642
|
+
`), je = (t) => {
|
|
2643
|
+
const r = (i, a) => {
|
|
2644
|
+
const o = i.label ?? String(i.value);
|
|
2645
|
+
return a === "disabled" ? `${import_picocolors.default.gray(q)} ${Z(o, (u) => import_picocolors.default.strikethrough(import_picocolors.default.gray(u)))}${i.hint ? ` ${import_picocolors.default.dim(`(${i.hint ?? "disabled"})`)}` : ""}` : a === "active" ? `${import_picocolors.default.cyan(st)} ${o}${i.hint ? ` ${import_picocolors.default.dim(`(${i.hint})`)}` : ""}` : a === "selected" ? `${import_picocolors.default.green(U)} ${Z(o, import_picocolors.default.dim)}${i.hint ? ` ${import_picocolors.default.dim(`(${i.hint})`)}` : ""}` : a === "cancelled" ? `${Z(o, (u) => import_picocolors.default.strikethrough(import_picocolors.default.dim(u)))}` : a === "active-selected" ? `${import_picocolors.default.green(U)} ${o}${i.hint ? ` ${import_picocolors.default.dim(`(${i.hint})`)}` : ""}` : a === "submitted" ? `${Z(o, import_picocolors.default.dim)}` : `${import_picocolors.default.dim(q)} ${Z(o, import_picocolors.default.dim)}`;
|
|
2646
|
+
}, s = t.required ?? !0;
|
|
2647
|
+
return new Lt$1({
|
|
2648
|
+
options: t.options,
|
|
2649
|
+
signal: t.signal,
|
|
2650
|
+
input: t.input,
|
|
2651
|
+
output: t.output,
|
|
2652
|
+
initialValues: t.initialValues,
|
|
2653
|
+
required: s,
|
|
2654
|
+
cursorAt: t.cursorAt,
|
|
2655
|
+
validate(i) {
|
|
2656
|
+
if (s && (i === void 0 || i.length === 0)) return `Please select at least one option.
|
|
2657
|
+
${import_picocolors.default.reset(import_picocolors.default.dim(`Press ${import_picocolors.default.gray(import_picocolors.default.bgWhite(import_picocolors.default.inverse(" space ")))} to select, ${import_picocolors.default.gray(import_picocolors.default.bgWhite(import_picocolors.default.inverse(" enter ")))} to submit`))}`;
|
|
2658
|
+
},
|
|
2659
|
+
render() {
|
|
2660
|
+
const i = xt(t.output, t.message, `${vt(this.state)} `, `${W(this.state)} `), a = `${import_picocolors.default.gray(d)}
|
|
2661
|
+
${i}
|
|
2662
|
+
`, o = this.value ?? [], u = (l, n) => {
|
|
2663
|
+
if (l.disabled) return r(l, "disabled");
|
|
2664
|
+
const c = o.includes(l.value);
|
|
2665
|
+
return n && c ? r(l, "active-selected") : c ? r(l, "selected") : r(l, n ? "active" : "inactive");
|
|
2666
|
+
};
|
|
2667
|
+
switch (this.state) {
|
|
2668
|
+
case "submit": {
|
|
2669
|
+
const l = this.options.filter(({ value: c }) => o.includes(c)).map((c) => r(c, "submitted")).join(import_picocolors.default.dim(", ")) || import_picocolors.default.dim("none");
|
|
2670
|
+
return `${a}${xt(t.output, l, `${import_picocolors.default.gray(d)} `)}`;
|
|
2671
|
+
}
|
|
2672
|
+
case "cancel": {
|
|
2673
|
+
const l = this.options.filter(({ value: c }) => o.includes(c)).map((c) => r(c, "cancelled")).join(import_picocolors.default.dim(", "));
|
|
2674
|
+
if (l.trim() === "") return `${a}${import_picocolors.default.gray(d)}`;
|
|
2675
|
+
return `${a}${xt(t.output, l, `${import_picocolors.default.gray(d)} `)}
|
|
2676
|
+
${import_picocolors.default.gray(d)}`;
|
|
2677
|
+
}
|
|
2678
|
+
case "error": {
|
|
2679
|
+
const l = `${import_picocolors.default.yellow(d)} `, n = this.error.split(`
|
|
2680
|
+
`).map((F, p) => p === 0 ? `${import_picocolors.default.yellow(x)} ${import_picocolors.default.yellow(F)}` : ` ${F}`).join(`
|
|
2681
|
+
`), c = a.split(`
|
|
2682
|
+
`).length, g = n.split(`
|
|
2683
|
+
`).length + 1;
|
|
2684
|
+
return `${a}${l}${X({
|
|
2685
|
+
output: t.output,
|
|
2686
|
+
options: this.options,
|
|
2687
|
+
cursor: this.cursor,
|
|
2688
|
+
maxItems: t.maxItems,
|
|
2689
|
+
columnPadding: l.length,
|
|
2690
|
+
rowPadding: c + g,
|
|
2691
|
+
style: u
|
|
2692
|
+
}).join(`
|
|
2693
|
+
${l}`)}
|
|
2694
|
+
${n}
|
|
2695
|
+
`;
|
|
2696
|
+
}
|
|
2697
|
+
default: {
|
|
2698
|
+
const l = `${import_picocolors.default.cyan(d)} `, n = a.split(`
|
|
2699
|
+
`).length;
|
|
2700
|
+
return `${a}${l}${X({
|
|
2701
|
+
output: t.output,
|
|
2702
|
+
options: this.options,
|
|
2703
|
+
cursor: this.cursor,
|
|
2704
|
+
maxItems: t.maxItems,
|
|
2705
|
+
columnPadding: l.length,
|
|
2706
|
+
rowPadding: n + 2,
|
|
2707
|
+
style: u
|
|
2708
|
+
}).join(`
|
|
2709
|
+
${l}`)}
|
|
2710
|
+
${import_picocolors.default.cyan(x)}
|
|
2711
|
+
`;
|
|
2712
|
+
}
|
|
2713
|
+
}
|
|
2714
|
+
}
|
|
2715
|
+
}).prompt();
|
|
2716
|
+
}, Ge = (t) => import_picocolors.default.dim(t), ke = (t, r, s) => {
|
|
2717
|
+
const i = {
|
|
2718
|
+
hard: !0,
|
|
2719
|
+
trim: !1
|
|
2720
|
+
}, a = J(t, r, i).split(`
|
|
2721
|
+
`), o = a.reduce((n, c) => Math.max(M(c), n), 0);
|
|
2722
|
+
return J(t, r - (a.map(s).reduce((n, c) => Math.max(M(c), n), 0) - o), i);
|
|
2723
|
+
}, Ve = (t = "", r = "", s) => {
|
|
2724
|
+
const i = s?.output ?? N.stdout, a = s?.withGuide ?? _.withGuide, o = s?.format ?? Ge, u = [
|
|
2725
|
+
"",
|
|
2726
|
+
...ke(t, rt$1(i) - 6, o).split(`
|
|
2727
|
+
`).map(o),
|
|
2728
|
+
""
|
|
2729
|
+
], l = M(r), n = Math.max(u.reduce((p, E) => {
|
|
2730
|
+
const $ = M(E);
|
|
2731
|
+
return $ > p ? $ : p;
|
|
2732
|
+
}, 0), l) + 2, c = u.map((p) => `${import_picocolors.default.gray(d)} ${p}${" ".repeat(n - M(p))}${import_picocolors.default.gray(d)}`).join(`
|
|
2733
|
+
`), g = a ? `${import_picocolors.default.gray(d)}
|
|
2734
|
+
` : "", F = a ? Wt : gt;
|
|
2735
|
+
i.write(`${g}${import_picocolors.default.green(V)} ${import_picocolors.default.reset(r)} ${import_picocolors.default.gray(rt.repeat(Math.max(n - l - 1, 1)) + mt)}
|
|
2736
|
+
${c}
|
|
2737
|
+
${import_picocolors.default.gray(F + rt.repeat(n + 2) + pt)}
|
|
2738
|
+
`);
|
|
2739
|
+
}, He = (t) => new Mt$1({
|
|
2740
|
+
validate: t.validate,
|
|
2741
|
+
mask: t.mask ?? Nt,
|
|
2742
|
+
signal: t.signal,
|
|
2743
|
+
input: t.input,
|
|
2744
|
+
output: t.output,
|
|
2745
|
+
render() {
|
|
2746
|
+
const r = t.withGuide ?? _.withGuide, s = `${r ? `${import_picocolors.default.gray(d)}
|
|
2747
|
+
` : ""}${W(this.state)} ${t.message}
|
|
2748
|
+
`, i = this.userInputWithCursor, a = this.masked;
|
|
2749
|
+
switch (this.state) {
|
|
2750
|
+
case "error": {
|
|
2751
|
+
const o = r ? `${import_picocolors.default.yellow(d)} ` : "", u = r ? `${import_picocolors.default.yellow(x)} ` : "", l = a ?? "";
|
|
2752
|
+
return t.clearOnError && this.clear(), `${s.trim()}
|
|
2753
|
+
${o}${l}
|
|
2754
|
+
${u}${import_picocolors.default.yellow(this.error)}
|
|
2755
|
+
`;
|
|
2756
|
+
}
|
|
2757
|
+
case "submit": return `${s}${r ? `${import_picocolors.default.gray(d)} ` : ""}${a ? import_picocolors.default.dim(a) : ""}`;
|
|
2758
|
+
case "cancel": return `${s}${r ? `${import_picocolors.default.gray(d)} ` : ""}${a ? import_picocolors.default.strikethrough(import_picocolors.default.dim(a)) : ""}${a && r ? `
|
|
2759
|
+
${import_picocolors.default.gray(d)}` : ""}`;
|
|
2760
|
+
default: return `${s}${r ? `${import_picocolors.default.cyan(d)} ` : ""}${i}
|
|
2761
|
+
${r ? import_picocolors.default.cyan(x) : ""}
|
|
2762
|
+
`;
|
|
2763
|
+
}
|
|
2764
|
+
}
|
|
2765
|
+
}).prompt(), Ue = (t) => {
|
|
2766
|
+
const r = t.validate;
|
|
2767
|
+
return Xt({
|
|
2768
|
+
...t,
|
|
2769
|
+
initialUserInput: t.initialValue ?? t.root ?? process.cwd(),
|
|
2770
|
+
maxItems: 5,
|
|
2771
|
+
validate(s) {
|
|
2772
|
+
if (!Array.isArray(s)) {
|
|
2773
|
+
if (!s) return "Please select a path";
|
|
2774
|
+
if (r) return r(s);
|
|
2775
|
+
}
|
|
2776
|
+
},
|
|
2777
|
+
options() {
|
|
2778
|
+
const s = this.userInput;
|
|
2779
|
+
if (s === "") return [];
|
|
2780
|
+
try {
|
|
2781
|
+
let i;
|
|
2782
|
+
return existsSync(s) ? lstatSync(s).isDirectory() ? i = s : i = dirname(s) : i = dirname(s), readdirSync(i).map((a) => {
|
|
2783
|
+
const o = join(i, a);
|
|
2784
|
+
return {
|
|
2785
|
+
name: a,
|
|
2786
|
+
path: o,
|
|
2787
|
+
isDirectory: lstatSync(o).isDirectory()
|
|
2788
|
+
};
|
|
2789
|
+
}).filter(({ path: a, isDirectory: o }) => a.startsWith(s) && (t.directory || !o)).map((a) => ({ value: a.path }));
|
|
2790
|
+
} catch {
|
|
2791
|
+
return [];
|
|
2792
|
+
}
|
|
2793
|
+
}
|
|
2794
|
+
});
|
|
2795
|
+
}, Ke = import_picocolors.default.magenta, bt = ({ indicator: t = "dots", onCancel: r, output: s = process.stdout, cancelMessage: i, errorMessage: a, frames: o = et ? [
|
|
2796
|
+
"◒",
|
|
2797
|
+
"◐",
|
|
2798
|
+
"◓",
|
|
2799
|
+
"◑"
|
|
2800
|
+
] : [
|
|
2801
|
+
"•",
|
|
2802
|
+
"o",
|
|
2803
|
+
"O",
|
|
2804
|
+
"0"
|
|
2805
|
+
], delay: u = et ? 80 : 120, signal: l, ...n } = {}) => {
|
|
2806
|
+
const c = ct();
|
|
2807
|
+
let g, F, p = !1, E = !1, $ = "", m, h = performance.now();
|
|
2808
|
+
const y = rt$1(s), f = n?.styleFrame ?? Ke, v = (b) => {
|
|
2809
|
+
const O = b > 1 ? a ?? _.messages.error : i ?? _.messages.cancel;
|
|
2810
|
+
E = b === 1, p && (L(O, b), E && typeof r == "function" && r());
|
|
2811
|
+
}, S = () => v(2), I = () => v(1), B = () => {
|
|
2812
|
+
process.on("uncaughtExceptionMonitor", S), process.on("unhandledRejection", S), process.on("SIGINT", I), process.on("SIGTERM", I), process.on("exit", v), l && l.addEventListener("abort", I);
|
|
2813
|
+
}, A = () => {
|
|
2814
|
+
process.removeListener("uncaughtExceptionMonitor", S), process.removeListener("unhandledRejection", S), process.removeListener("SIGINT", I), process.removeListener("SIGTERM", I), process.removeListener("exit", v), l && l.removeEventListener("abort", I);
|
|
2815
|
+
}, w = () => {
|
|
2816
|
+
if (m === void 0) return;
|
|
2817
|
+
c && s.write(`
|
|
2818
|
+
`);
|
|
2819
|
+
const b = J(m, y, {
|
|
2820
|
+
hard: !0,
|
|
2821
|
+
trim: !1
|
|
2822
|
+
}).split(`
|
|
2823
|
+
`);
|
|
2824
|
+
b.length > 1 && s.write(import_src.cursor.up(b.length - 1)), s.write(import_src.cursor.to(0)), s.write(import_src.erase.down());
|
|
2825
|
+
}, _$2 = (b) => b.replace(/\.+$/, ""), D = (b) => {
|
|
2826
|
+
const O = (performance.now() - b) / 1e3, j = Math.floor(O / 60), G = Math.floor(O % 60);
|
|
2827
|
+
return j > 0 ? `[${j}m ${G}s]` : `[${G}s]`;
|
|
2828
|
+
}, T = n.withGuide ?? _.withGuide, Y = (b = "") => {
|
|
2829
|
+
p = !0, g = Bt({ output: s }), $ = _$2(b), h = performance.now(), T && s.write(`${import_picocolors.default.gray(d)}
|
|
2830
|
+
`);
|
|
2831
|
+
let O = 0, j = 0;
|
|
2832
|
+
B(), F = setInterval(() => {
|
|
2833
|
+
if (c && $ === m) return;
|
|
2834
|
+
w(), m = $;
|
|
2835
|
+
const G = f(o[O]);
|
|
2836
|
+
let tt;
|
|
2837
|
+
if (c) tt = `${G} ${$}...`;
|
|
2838
|
+
else if (t === "timer") tt = `${G} ${$} ${D(h)}`;
|
|
2839
|
+
else {
|
|
2840
|
+
const te = ".".repeat(Math.floor(j)).slice(0, 3);
|
|
2841
|
+
tt = `${G} ${$}${te}`;
|
|
2842
|
+
}
|
|
2843
|
+
const Zt = J(tt, y, {
|
|
2844
|
+
hard: !0,
|
|
2845
|
+
trim: !1
|
|
2846
|
+
});
|
|
2847
|
+
s.write(Zt), O = O + 1 < o.length ? O + 1 : 0, j = j < 4 ? j + .125 : 0;
|
|
2848
|
+
}, u);
|
|
2849
|
+
}, L = (b = "", O = 0, j = !1) => {
|
|
2850
|
+
if (!p) return;
|
|
2851
|
+
p = !1, clearInterval(F), w();
|
|
2852
|
+
const G = O === 0 ? import_picocolors.default.green(V) : O === 1 ? import_picocolors.default.red(dt) : import_picocolors.default.red($t);
|
|
2853
|
+
$ = b ?? $, j || (t === "timer" ? s.write(`${G} ${$} ${D(h)}
|
|
2854
|
+
`) : s.write(`${G} ${$}
|
|
2855
|
+
`)), A(), g();
|
|
2856
|
+
};
|
|
2857
|
+
return {
|
|
2858
|
+
start: Y,
|
|
2859
|
+
stop: (b = "") => L(b, 0),
|
|
2860
|
+
message: (b = "") => {
|
|
2861
|
+
$ = _$2(b ?? $);
|
|
2862
|
+
},
|
|
2863
|
+
cancel: (b = "") => L(b, 1),
|
|
2864
|
+
error: (b = "") => L(b, 2),
|
|
2865
|
+
clear: () => L("", 0, !0),
|
|
2866
|
+
get isCancelled() {
|
|
2867
|
+
return E;
|
|
2868
|
+
}
|
|
2869
|
+
};
|
|
2870
|
+
}, zt = {
|
|
2871
|
+
light: C("─", "-"),
|
|
2872
|
+
heavy: C("━", "="),
|
|
2873
|
+
block: C("█", "#")
|
|
2874
|
+
};
|
|
2875
|
+
const lt = (t, r) => t.includes(`
|
|
2876
|
+
`) ? t.split(`
|
|
2877
|
+
`).map((s) => r(s)).join(`
|
|
2878
|
+
`) : r(t), Je = (t) => {
|
|
2879
|
+
const r = (s, i) => {
|
|
2880
|
+
const a = s.label ?? String(s.value);
|
|
2881
|
+
switch (i) {
|
|
2882
|
+
case "disabled": return `${import_picocolors.default.gray(H)} ${lt(a, import_picocolors.default.gray)}${s.hint ? ` ${import_picocolors.default.dim(`(${s.hint ?? "disabled"})`)}` : ""}`;
|
|
2883
|
+
case "selected": return `${lt(a, import_picocolors.default.dim)}`;
|
|
2884
|
+
case "active": return `${import_picocolors.default.green(Q)} ${a}${s.hint ? ` ${import_picocolors.default.dim(`(${s.hint})`)}` : ""}`;
|
|
2885
|
+
case "cancelled": return `${lt(a, (o) => import_picocolors.default.strikethrough(import_picocolors.default.dim(o)))}`;
|
|
2886
|
+
default: return `${import_picocolors.default.dim(H)} ${lt(a, import_picocolors.default.dim)}`;
|
|
2887
|
+
}
|
|
2888
|
+
};
|
|
2889
|
+
return new Wt$1({
|
|
2890
|
+
options: t.options,
|
|
2891
|
+
signal: t.signal,
|
|
2892
|
+
input: t.input,
|
|
2893
|
+
output: t.output,
|
|
2894
|
+
initialValue: t.initialValue,
|
|
2895
|
+
render() {
|
|
2896
|
+
const s = t.withGuide ?? _.withGuide, i = `${W(this.state)} `, a = `${vt(this.state)} `, o = xt(t.output, t.message, a, i), u = `${s ? `${import_picocolors.default.gray(d)}
|
|
2897
|
+
` : ""}${o}
|
|
2898
|
+
`;
|
|
2899
|
+
switch (this.state) {
|
|
2900
|
+
case "submit": {
|
|
2901
|
+
const l = s ? `${import_picocolors.default.gray(d)} ` : "";
|
|
2902
|
+
return `${u}${xt(t.output, r(this.options[this.cursor], "selected"), l)}`;
|
|
2903
|
+
}
|
|
2904
|
+
case "cancel": {
|
|
2905
|
+
const l = s ? `${import_picocolors.default.gray(d)} ` : "";
|
|
2906
|
+
return `${u}${xt(t.output, r(this.options[this.cursor], "cancelled"), l)}${s ? `
|
|
2907
|
+
${import_picocolors.default.gray(d)}` : ""}`;
|
|
2908
|
+
}
|
|
2909
|
+
default: {
|
|
2910
|
+
const l = s ? `${import_picocolors.default.cyan(d)} ` : "", n = s ? import_picocolors.default.cyan(x) : "", c = u.split(`
|
|
2911
|
+
`).length, g = s ? 2 : 1;
|
|
2912
|
+
return `${u}${l}${X({
|
|
2913
|
+
output: t.output,
|
|
2914
|
+
cursor: this.cursor,
|
|
2915
|
+
options: this.options,
|
|
2916
|
+
maxItems: t.maxItems,
|
|
2917
|
+
columnPadding: l.length,
|
|
2918
|
+
rowPadding: c + g,
|
|
2919
|
+
style: (F, p) => r(F, F.disabled ? "disabled" : p ? "active" : "inactive")
|
|
2920
|
+
}).join(`
|
|
2921
|
+
${l}`)}
|
|
2922
|
+
${n}
|
|
2923
|
+
`;
|
|
2924
|
+
}
|
|
2925
|
+
}
|
|
2926
|
+
}
|
|
2927
|
+
}).prompt();
|
|
2928
|
+
}, Xe = (t) => {
|
|
2929
|
+
const r = (s, i = "inactive") => {
|
|
2930
|
+
const a = s.label ?? String(s.value);
|
|
2931
|
+
return i === "selected" ? `${import_picocolors.default.dim(a)}` : i === "cancelled" ? `${import_picocolors.default.strikethrough(import_picocolors.default.dim(a))}` : i === "active" ? `${import_picocolors.default.bgCyan(import_picocolors.default.gray(` ${s.value} `))} ${a}${s.hint ? ` ${import_picocolors.default.dim(`(${s.hint})`)}` : ""}` : `${import_picocolors.default.gray(import_picocolors.default.bgWhite(import_picocolors.default.inverse(` ${s.value} `)))} ${a}${s.hint ? ` ${import_picocolors.default.dim(`(${s.hint})`)}` : ""}`;
|
|
2932
|
+
};
|
|
2933
|
+
return new Tt$1({
|
|
2934
|
+
options: t.options,
|
|
2935
|
+
signal: t.signal,
|
|
2936
|
+
input: t.input,
|
|
2937
|
+
output: t.output,
|
|
2938
|
+
initialValue: t.initialValue,
|
|
2939
|
+
caseSensitive: t.caseSensitive,
|
|
2940
|
+
render() {
|
|
2941
|
+
const s = t.withGuide ?? _.withGuide, i = `${s ? `${import_picocolors.default.gray(d)}
|
|
2942
|
+
` : ""}${W(this.state)} ${t.message}
|
|
2943
|
+
`;
|
|
2944
|
+
switch (this.state) {
|
|
2945
|
+
case "submit": {
|
|
2946
|
+
const a = s ? `${import_picocolors.default.gray(d)} ` : "", o = this.options.find((l) => l.value === this.value) ?? t.options[0];
|
|
2947
|
+
return `${i}${xt(t.output, r(o, "selected"), a)}`;
|
|
2948
|
+
}
|
|
2949
|
+
case "cancel": {
|
|
2950
|
+
const a = s ? `${import_picocolors.default.gray(d)} ` : "";
|
|
2951
|
+
return `${i}${xt(t.output, r(this.options[0], "cancelled"), a)}${s ? `
|
|
2952
|
+
${import_picocolors.default.gray(d)}` : ""}`;
|
|
2953
|
+
}
|
|
2954
|
+
default: {
|
|
2955
|
+
const a = s ? `${import_picocolors.default.cyan(d)} ` : "", o = s ? import_picocolors.default.cyan(x) : "";
|
|
2956
|
+
return `${i}${this.options.map((l, n) => xt(t.output, r(l, n === this.cursor ? "active" : "inactive"), a)).join(`
|
|
2957
|
+
`)}
|
|
2958
|
+
${o}
|
|
2959
|
+
`;
|
|
2960
|
+
}
|
|
2961
|
+
}
|
|
2962
|
+
}
|
|
2963
|
+
}).prompt();
|
|
2964
|
+
}, Qt = `${import_picocolors.default.gray(d)} `, K = {
|
|
2965
|
+
message: async (t, { symbol: r = import_picocolors.default.gray(d) } = {}) => {
|
|
2966
|
+
process.stdout.write(`${import_picocolors.default.gray(d)}
|
|
2967
|
+
${r} `);
|
|
2968
|
+
let s = 3;
|
|
2969
|
+
for await (let i of t) {
|
|
2970
|
+
i = i.replace(/\n/g, `
|
|
2971
|
+
${Qt}`), i.includes(`
|
|
2972
|
+
`) && (s = 3 + stripVTControlCharacters(i.slice(i.lastIndexOf(`
|
|
2973
|
+
`))).length);
|
|
2974
|
+
const a = stripVTControlCharacters(i).length;
|
|
2975
|
+
s + a < process.stdout.columns ? (s += a, process.stdout.write(i)) : (process.stdout.write(`
|
|
2976
|
+
${Qt}${i.trimStart()}`), s = 3 + stripVTControlCharacters(i.trimStart()).length);
|
|
2977
|
+
}
|
|
2978
|
+
process.stdout.write(`
|
|
2979
|
+
`);
|
|
2980
|
+
},
|
|
2981
|
+
info: (t) => K.message(t, { symbol: import_picocolors.default.blue(ft) }),
|
|
2982
|
+
success: (t) => K.message(t, { symbol: import_picocolors.default.green(Ft) }),
|
|
2983
|
+
step: (t) => K.message(t, { symbol: import_picocolors.default.green(V) }),
|
|
2984
|
+
warn: (t) => K.message(t, { symbol: import_picocolors.default.yellow(yt) }),
|
|
2985
|
+
warning: (t) => K.warn(t),
|
|
2986
|
+
error: (t) => K.message(t, { symbol: import_picocolors.default.red(Et) })
|
|
2987
|
+
}, Ye = async (t, r) => {
|
|
2988
|
+
for (const s of t) {
|
|
2989
|
+
if (s.enabled === !1) continue;
|
|
2990
|
+
const i = bt(r);
|
|
2991
|
+
i.start(s.title);
|
|
2992
|
+
const a = await s.task(i.message);
|
|
2993
|
+
i.stop(a || s.title);
|
|
2994
|
+
}
|
|
2995
|
+
}, ze = (t) => t.replace(/\x1b\[(?:\d+;)*\d*[ABCDEFGHfJKSTsu]|\x1b\[(s|u)/g, ""), Qe = (t) => {
|
|
2996
|
+
const r = t.output ?? process.stdout, s = rt$1(r), i = import_picocolors.default.gray(d), a = t.spacing ?? 1, o = 3, u = t.retainLog === !0, l = !ct() && Mt(r);
|
|
2997
|
+
r.write(`${i}
|
|
2998
|
+
`), r.write(`${import_picocolors.default.green(V)} ${t.title}
|
|
2999
|
+
`);
|
|
3000
|
+
for (let h = 0; h < a; h++) r.write(`${i}
|
|
3001
|
+
`);
|
|
3002
|
+
const n = [{
|
|
3003
|
+
value: "",
|
|
3004
|
+
full: ""
|
|
3005
|
+
}];
|
|
3006
|
+
let c = !1;
|
|
3007
|
+
const g = (h) => {
|
|
3008
|
+
if (n.length === 0) return;
|
|
3009
|
+
let y = 0;
|
|
3010
|
+
h && (y += a + 2);
|
|
3011
|
+
for (const f of n) {
|
|
3012
|
+
const { value: v, result: S } = f;
|
|
3013
|
+
let I = S?.message ?? v;
|
|
3014
|
+
if (I.length === 0) continue;
|
|
3015
|
+
S === void 0 && f.header !== void 0 && f.header !== "" && (I += `
|
|
3016
|
+
${f.header}`);
|
|
3017
|
+
const B = I.split(`
|
|
3018
|
+
`).reduce((A, w) => w === "" ? A + 1 : A + Math.ceil((w.length + o) / s), 0);
|
|
3019
|
+
y += B;
|
|
3020
|
+
}
|
|
3021
|
+
y > 0 && (y += 1, r.write(import_src.erase.lines(y)));
|
|
3022
|
+
}, F = (h, y, f) => {
|
|
3023
|
+
const v = f ? `${h.full}
|
|
3024
|
+
${h.value}` : h.value;
|
|
3025
|
+
h.header !== void 0 && h.header !== "" && R.message(h.header.split(`
|
|
3026
|
+
`).map(import_picocolors.default.bold), {
|
|
3027
|
+
output: r,
|
|
3028
|
+
secondarySymbol: i,
|
|
3029
|
+
symbol: i,
|
|
3030
|
+
spacing: 0
|
|
3031
|
+
}), R.message(v.split(`
|
|
3032
|
+
`).map(import_picocolors.default.dim), {
|
|
3033
|
+
output: r,
|
|
3034
|
+
secondarySymbol: i,
|
|
3035
|
+
symbol: i,
|
|
3036
|
+
spacing: y ?? a
|
|
3037
|
+
});
|
|
3038
|
+
}, p = () => {
|
|
3039
|
+
for (const h of n) {
|
|
3040
|
+
const { header: y, value: f, full: v } = h;
|
|
3041
|
+
(y === void 0 || y.length === 0) && f.length === 0 || F(h, void 0, u === !0 && v.length > 0);
|
|
3042
|
+
}
|
|
3043
|
+
}, E = (h, y, f) => {
|
|
3044
|
+
if (g(!1), (f?.raw !== !0 || !c) && h.value !== "" && (h.value += `
|
|
3045
|
+
`), h.value += ze(y), c = f?.raw === !0, t.limit !== void 0) {
|
|
3046
|
+
const v = h.value.split(`
|
|
3047
|
+
`), S = v.length - t.limit;
|
|
3048
|
+
if (S > 0) {
|
|
3049
|
+
const I = v.splice(0, S);
|
|
3050
|
+
u && (h.full += (h.full === "" ? "" : `
|
|
3051
|
+
`) + I.join(`
|
|
3052
|
+
`));
|
|
3053
|
+
}
|
|
3054
|
+
h.value = v.join(`
|
|
3055
|
+
`);
|
|
3056
|
+
}
|
|
3057
|
+
l && $();
|
|
3058
|
+
}, $ = () => {
|
|
3059
|
+
for (const h of n) h.result ? h.result.status === "error" ? R.error(h.result.message, {
|
|
3060
|
+
output: r,
|
|
3061
|
+
secondarySymbol: i,
|
|
3062
|
+
spacing: 0
|
|
3063
|
+
}) : R.success(h.result.message, {
|
|
3064
|
+
output: r,
|
|
3065
|
+
secondarySymbol: i,
|
|
3066
|
+
spacing: 0
|
|
3067
|
+
}) : h.value !== "" && F(h, 0);
|
|
3068
|
+
}, m = (h, y) => {
|
|
3069
|
+
g(!1), h.result = y, l && $();
|
|
3070
|
+
};
|
|
3071
|
+
return {
|
|
3072
|
+
message(h, y) {
|
|
3073
|
+
E(n[0], h, y);
|
|
3074
|
+
},
|
|
3075
|
+
group(h) {
|
|
3076
|
+
const y = {
|
|
3077
|
+
header: h,
|
|
3078
|
+
value: "",
|
|
3079
|
+
full: ""
|
|
3080
|
+
};
|
|
3081
|
+
return n.push(y), {
|
|
3082
|
+
message(f, v) {
|
|
3083
|
+
E(y, f, v);
|
|
3084
|
+
},
|
|
3085
|
+
error(f) {
|
|
3086
|
+
m(y, {
|
|
3087
|
+
status: "error",
|
|
3088
|
+
message: f
|
|
3089
|
+
});
|
|
3090
|
+
},
|
|
3091
|
+
success(f) {
|
|
3092
|
+
m(y, {
|
|
3093
|
+
status: "success",
|
|
3094
|
+
message: f
|
|
3095
|
+
});
|
|
3096
|
+
}
|
|
3097
|
+
};
|
|
3098
|
+
},
|
|
3099
|
+
error(h, y) {
|
|
3100
|
+
g(!0), R.error(h, {
|
|
3101
|
+
output: r,
|
|
3102
|
+
secondarySymbol: i,
|
|
3103
|
+
spacing: 1
|
|
3104
|
+
}), y?.showLog !== !1 && p(), n.splice(1, n.length - 1), n[0].value = "", n[0].full = "";
|
|
3105
|
+
},
|
|
3106
|
+
success(h, y) {
|
|
3107
|
+
g(!0), R.success(h, {
|
|
3108
|
+
output: r,
|
|
3109
|
+
secondarySymbol: i,
|
|
3110
|
+
spacing: 1
|
|
3111
|
+
}), y?.showLog === !0 && p(), n.splice(1, n.length - 1), n[0].value = "", n[0].full = "";
|
|
3112
|
+
}
|
|
3113
|
+
};
|
|
3114
|
+
}, Ze = (t) => new $t$1({
|
|
3115
|
+
validate: t.validate,
|
|
3116
|
+
placeholder: t.placeholder,
|
|
3117
|
+
defaultValue: t.defaultValue,
|
|
3118
|
+
initialValue: t.initialValue,
|
|
3119
|
+
output: t.output,
|
|
3120
|
+
signal: t.signal,
|
|
3121
|
+
input: t.input,
|
|
3122
|
+
render() {
|
|
3123
|
+
const r = t?.withGuide ?? _.withGuide, s = `${`${r ? `${import_picocolors.default.gray(d)}
|
|
3124
|
+
` : ""}${W(this.state)} `}${t.message}
|
|
3125
|
+
`, i = t.placeholder ? import_picocolors.default.inverse(t.placeholder[0]) + import_picocolors.default.dim(t.placeholder.slice(1)) : import_picocolors.default.inverse(import_picocolors.default.hidden("_")), a = this.userInput ? this.userInputWithCursor : i, o = this.value ?? "";
|
|
3126
|
+
switch (this.state) {
|
|
3127
|
+
case "error": {
|
|
3128
|
+
const u = this.error ? ` ${import_picocolors.default.yellow(this.error)}` : "", l = r ? `${import_picocolors.default.yellow(d)} ` : "", n = r ? import_picocolors.default.yellow(x) : "";
|
|
3129
|
+
return `${s.trim()}
|
|
3130
|
+
${l}${a}
|
|
3131
|
+
${n}${u}
|
|
3132
|
+
`;
|
|
3133
|
+
}
|
|
3134
|
+
case "submit": {
|
|
3135
|
+
const u = o ? ` ${import_picocolors.default.dim(o)}` : "";
|
|
3136
|
+
return `${s}${r ? import_picocolors.default.gray(d) : ""}${u}`;
|
|
3137
|
+
}
|
|
3138
|
+
case "cancel": {
|
|
3139
|
+
const u = o ? ` ${import_picocolors.default.strikethrough(import_picocolors.default.dim(o))}` : "", l = r ? import_picocolors.default.gray(d) : "";
|
|
3140
|
+
return `${s}${l}${u}${o.trim() ? `
|
|
3141
|
+
${l}` : ""}`;
|
|
3142
|
+
}
|
|
3143
|
+
default: return `${s}${r ? `${import_picocolors.default.cyan(d)} ` : ""}${a}
|
|
3144
|
+
${r ? import_picocolors.default.cyan(x) : ""}
|
|
3145
|
+
`;
|
|
3146
|
+
}
|
|
3147
|
+
}
|
|
3148
|
+
}).prompt();
|
|
3149
|
+
|
|
3150
|
+
//#endregion
|
|
3151
|
+
//#region src/utils/context-detection.ts
|
|
3152
|
+
/**
|
|
3153
|
+
* Check if the current directory is a source repository
|
|
3154
|
+
* A source repository contains a baton.source.yaml file in the root
|
|
3155
|
+
* @param cwd - Current working directory (defaults to process.cwd())
|
|
3156
|
+
* @returns true if baton.source.yaml exists in cwd, false otherwise
|
|
3157
|
+
*/
|
|
3158
|
+
async function isInSourceRepo(cwd = process.cwd()) {
|
|
3159
|
+
const manifestPath = join(cwd, "baton.source.yaml");
|
|
3160
|
+
try {
|
|
3161
|
+
await access(manifestPath);
|
|
3162
|
+
return true;
|
|
3163
|
+
} catch {
|
|
3164
|
+
return false;
|
|
3165
|
+
}
|
|
3166
|
+
}
|
|
3167
|
+
/**
|
|
3168
|
+
* Find the source repository root by searching upwards from cwd
|
|
3169
|
+
* Checks the current directory and all parent directories for baton.source.yaml
|
|
3170
|
+
* @param cwd - Starting directory (defaults to process.cwd())
|
|
3171
|
+
* @param options.fallbackToStart - If true, return cwd instead of null when not found
|
|
3172
|
+
* @returns The absolute path to the source root, or null (or cwd) if not found
|
|
3173
|
+
*/
|
|
3174
|
+
async function findSourceRoot(cwd = process.cwd(), options) {
|
|
3175
|
+
let current = cwd;
|
|
3176
|
+
while (true) {
|
|
3177
|
+
const manifestPath = join(current, "baton.source.yaml");
|
|
3178
|
+
try {
|
|
3179
|
+
await access(manifestPath);
|
|
3180
|
+
return current;
|
|
3181
|
+
} catch {
|
|
3182
|
+
const parent = dirname(current);
|
|
3183
|
+
if (parent === current) return options?.fallbackToStart ? cwd : null;
|
|
3184
|
+
current = parent;
|
|
3185
|
+
}
|
|
3186
|
+
}
|
|
3187
|
+
}
|
|
3188
|
+
|
|
3189
|
+
//#endregion
|
|
3190
|
+
export { Ne as a, Ve as c, bt as d, je as f, runMain as h, Le as i, We as l, defineCommand as m, isInSourceRepo as n, R as o, Ct$1 as p, Je as r, Re as s, findSourceRoot as t, Ze as u };
|
|
3191
|
+
//# sourceMappingURL=context-detection-DO0ZeRyQ.mjs.map
|