@jannael/glinter 1.2.2 → 1.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -8
- package/dist/index.js +646 -583
- package/package.json +77 -64
package/dist/index.js
CHANGED
|
@@ -120,8 +120,8 @@ var AVAILABLE_COMMANDS = [
|
|
|
120
120
|
];
|
|
121
121
|
|
|
122
122
|
// apps/cli/error/error-constructor.ts
|
|
123
|
+
var capitalize = (text) => text.charAt(0).toUpperCase() + text.slice(1);
|
|
123
124
|
function CreateError(name) {
|
|
124
|
-
const capitalize = (text) => text.charAt(0).toUpperCase() + text.slice(1);
|
|
125
125
|
return class extends Error {
|
|
126
126
|
description;
|
|
127
127
|
constructor(message, description) {
|
|
@@ -174,25 +174,34 @@ function errorHandler(error) {
|
|
|
174
174
|
}
|
|
175
175
|
|
|
176
176
|
// node_modules/@clack/core/dist/index.mjs
|
|
177
|
-
import { styleText as
|
|
178
|
-
import { stdout as
|
|
179
|
-
import * as
|
|
180
|
-
import
|
|
177
|
+
import { styleText as v } from "util";
|
|
178
|
+
import { stdout as x, stdin as D } from "process";
|
|
179
|
+
import * as b from "readline";
|
|
180
|
+
import E from "readline";
|
|
181
181
|
|
|
182
182
|
// node_modules/fast-string-truncated-width/dist/utils.js
|
|
183
|
-
var
|
|
184
|
-
|
|
185
|
-
|
|
183
|
+
var getCodePointsLength = (() => {
|
|
184
|
+
const SURROGATE_PAIR_RE = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
|
|
185
|
+
return (input) => {
|
|
186
|
+
let surrogatePairsNr = 0;
|
|
187
|
+
SURROGATE_PAIR_RE.lastIndex = 0;
|
|
188
|
+
while (SURROGATE_PAIR_RE.test(input)) {
|
|
189
|
+
surrogatePairsNr += 1;
|
|
190
|
+
}
|
|
191
|
+
return input.length - surrogatePairsNr;
|
|
192
|
+
};
|
|
193
|
+
})();
|
|
186
194
|
var isFullWidth = (x) => {
|
|
187
195
|
return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
|
|
188
196
|
};
|
|
189
|
-
var
|
|
190
|
-
return x
|
|
197
|
+
var isWideNotCJKTNotEmoji = (x) => {
|
|
198
|
+
return x === 8987 || x === 9001 || x >= 12272 && x <= 12287 || x >= 12289 && x <= 12350 || x >= 12441 && x <= 12543 || x >= 12549 && x <= 12591 || x >= 12593 && x <= 12686 || x >= 12688 && x <= 12771 || x >= 12783 && x <= 12830 || x >= 12832 && x <= 12871 || x >= 12880 && x <= 19903 || x >= 65040 && x <= 65049 || x >= 65072 && x <= 65106 || x >= 65108 && x <= 65126 || x >= 65128 && x <= 65131 || x >= 127488 && x <= 127490 || x >= 127504 && x <= 127547 || x >= 127552 && x <= 127560 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
|
|
191
199
|
};
|
|
192
200
|
|
|
193
201
|
// node_modules/fast-string-truncated-width/dist/index.js
|
|
194
|
-
var ANSI_RE = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y;
|
|
202
|
+
var ANSI_RE = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y;
|
|
195
203
|
var CONTROL_RE = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
|
|
204
|
+
var CJKT_WIDE_RE = /(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu;
|
|
196
205
|
var TAB_RE = /\t{1,1000}/y;
|
|
197
206
|
var EMOJI_RE = /[\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?))*/yu;
|
|
198
207
|
var LATIN_RE = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
|
|
@@ -202,14 +211,21 @@ var getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {})
|
|
|
202
211
|
const LIMIT = truncationOptions.limit ?? Infinity;
|
|
203
212
|
const ELLIPSIS = truncationOptions.ellipsis ?? "";
|
|
204
213
|
const ELLIPSIS_WIDTH = truncationOptions?.ellipsisWidth ?? (ELLIPSIS ? getStringTruncatedWidth(ELLIPSIS, NO_TRUNCATION, widthOptions).width : 0);
|
|
205
|
-
const ANSI_WIDTH =
|
|
214
|
+
const ANSI_WIDTH = 0;
|
|
206
215
|
const CONTROL_WIDTH = widthOptions.controlWidth ?? 0;
|
|
207
216
|
const TAB_WIDTH = widthOptions.tabWidth ?? 8;
|
|
208
|
-
const AMBIGUOUS_WIDTH = widthOptions.ambiguousWidth ?? 1;
|
|
209
217
|
const EMOJI_WIDTH = widthOptions.emojiWidth ?? 2;
|
|
210
|
-
const FULL_WIDTH_WIDTH =
|
|
218
|
+
const FULL_WIDTH_WIDTH = 2;
|
|
211
219
|
const REGULAR_WIDTH = widthOptions.regularWidth ?? 1;
|
|
212
|
-
const WIDE_WIDTH = widthOptions.wideWidth ??
|
|
220
|
+
const WIDE_WIDTH = widthOptions.wideWidth ?? FULL_WIDTH_WIDTH;
|
|
221
|
+
const PARSE_BLOCKS = [
|
|
222
|
+
[LATIN_RE, REGULAR_WIDTH],
|
|
223
|
+
[ANSI_RE, ANSI_WIDTH],
|
|
224
|
+
[CONTROL_RE, CONTROL_WIDTH],
|
|
225
|
+
[TAB_RE, TAB_WIDTH],
|
|
226
|
+
[EMOJI_RE, EMOJI_WIDTH],
|
|
227
|
+
[CJKT_WIDE_RE, WIDE_WIDTH]
|
|
228
|
+
];
|
|
213
229
|
let indexPrev = 0;
|
|
214
230
|
let index = 0;
|
|
215
231
|
let length = input.length;
|
|
@@ -230,10 +246,8 @@ var getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {})
|
|
|
230
246
|
const codePoint = char.codePointAt(0) || 0;
|
|
231
247
|
if (isFullWidth(codePoint)) {
|
|
232
248
|
widthExtra = FULL_WIDTH_WIDTH;
|
|
233
|
-
} else if (
|
|
249
|
+
} else if (isWideNotCJKTNotEmoji(codePoint)) {
|
|
234
250
|
widthExtra = WIDE_WIDTH;
|
|
235
|
-
} else if (AMBIGUOUS_WIDTH !== REGULAR_WIDTH && isAmbiguous(codePoint)) {
|
|
236
|
-
widthExtra = AMBIGUOUS_WIDTH;
|
|
237
251
|
} else {
|
|
238
252
|
widthExtra = REGULAR_WIDTH;
|
|
239
253
|
}
|
|
@@ -249,88 +263,28 @@ var getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {})
|
|
|
249
263
|
}
|
|
250
264
|
unmatchedStart = unmatchedEnd = 0;
|
|
251
265
|
}
|
|
252
|
-
if (index >= length)
|
|
253
|
-
break;
|
|
254
|
-
LATIN_RE.lastIndex = index;
|
|
255
|
-
if (LATIN_RE.test(input)) {
|
|
256
|
-
lengthExtra = LATIN_RE.lastIndex - index;
|
|
257
|
-
widthExtra = lengthExtra * REGULAR_WIDTH;
|
|
258
|
-
if (width + widthExtra > truncationLimit) {
|
|
259
|
-
truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / REGULAR_WIDTH));
|
|
260
|
-
}
|
|
261
|
-
if (width + widthExtra > LIMIT) {
|
|
262
|
-
truncationEnabled = true;
|
|
263
|
-
break;
|
|
264
|
-
}
|
|
265
|
-
width += widthExtra;
|
|
266
|
-
unmatchedStart = indexPrev;
|
|
267
|
-
unmatchedEnd = index;
|
|
268
|
-
index = indexPrev = LATIN_RE.lastIndex;
|
|
269
|
-
continue;
|
|
270
|
-
}
|
|
271
|
-
ANSI_RE.lastIndex = index;
|
|
272
|
-
if (ANSI_RE.test(input)) {
|
|
273
|
-
if (width + ANSI_WIDTH > truncationLimit) {
|
|
274
|
-
truncationIndex = Math.min(truncationIndex, index);
|
|
275
|
-
}
|
|
276
|
-
if (width + ANSI_WIDTH > LIMIT) {
|
|
277
|
-
truncationEnabled = true;
|
|
278
|
-
break;
|
|
279
|
-
}
|
|
280
|
-
width += ANSI_WIDTH;
|
|
281
|
-
unmatchedStart = indexPrev;
|
|
282
|
-
unmatchedEnd = index;
|
|
283
|
-
index = indexPrev = ANSI_RE.lastIndex;
|
|
284
|
-
continue;
|
|
285
|
-
}
|
|
286
|
-
CONTROL_RE.lastIndex = index;
|
|
287
|
-
if (CONTROL_RE.test(input)) {
|
|
288
|
-
lengthExtra = CONTROL_RE.lastIndex - index;
|
|
289
|
-
widthExtra = lengthExtra * CONTROL_WIDTH;
|
|
290
|
-
if (width + widthExtra > truncationLimit) {
|
|
291
|
-
truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / CONTROL_WIDTH));
|
|
292
|
-
}
|
|
293
|
-
if (width + widthExtra > LIMIT) {
|
|
294
|
-
truncationEnabled = true;
|
|
295
|
-
break;
|
|
296
|
-
}
|
|
297
|
-
width += widthExtra;
|
|
298
|
-
unmatchedStart = indexPrev;
|
|
299
|
-
unmatchedEnd = index;
|
|
300
|
-
index = indexPrev = CONTROL_RE.lastIndex;
|
|
301
|
-
continue;
|
|
302
|
-
}
|
|
303
|
-
TAB_RE.lastIndex = index;
|
|
304
|
-
if (TAB_RE.test(input)) {
|
|
305
|
-
lengthExtra = TAB_RE.lastIndex - index;
|
|
306
|
-
widthExtra = lengthExtra * TAB_WIDTH;
|
|
307
|
-
if (width + widthExtra > truncationLimit) {
|
|
308
|
-
truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / TAB_WIDTH));
|
|
309
|
-
}
|
|
310
|
-
if (width + widthExtra > LIMIT) {
|
|
311
|
-
truncationEnabled = true;
|
|
312
|
-
break;
|
|
313
|
-
}
|
|
314
|
-
width += widthExtra;
|
|
315
|
-
unmatchedStart = indexPrev;
|
|
316
|
-
unmatchedEnd = index;
|
|
317
|
-
index = indexPrev = TAB_RE.lastIndex;
|
|
318
|
-
continue;
|
|
266
|
+
if (index >= length) {
|
|
267
|
+
break outer;
|
|
319
268
|
}
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
269
|
+
for (let i = 0, l = PARSE_BLOCKS.length;i < l; i++) {
|
|
270
|
+
const [BLOCK_RE, BLOCK_WIDTH] = PARSE_BLOCKS[i];
|
|
271
|
+
BLOCK_RE.lastIndex = index;
|
|
272
|
+
if (BLOCK_RE.test(input)) {
|
|
273
|
+
lengthExtra = BLOCK_RE === CJKT_WIDE_RE ? getCodePointsLength(input.slice(index, BLOCK_RE.lastIndex)) : BLOCK_RE === EMOJI_RE ? 1 : BLOCK_RE.lastIndex - index;
|
|
274
|
+
widthExtra = lengthExtra * BLOCK_WIDTH;
|
|
275
|
+
if (width + widthExtra > truncationLimit) {
|
|
276
|
+
truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / BLOCK_WIDTH));
|
|
277
|
+
}
|
|
278
|
+
if (width + widthExtra > LIMIT) {
|
|
279
|
+
truncationEnabled = true;
|
|
280
|
+
break outer;
|
|
281
|
+
}
|
|
282
|
+
width += widthExtra;
|
|
283
|
+
unmatchedStart = indexPrev;
|
|
284
|
+
unmatchedEnd = index;
|
|
285
|
+
index = indexPrev = BLOCK_RE.lastIndex;
|
|
286
|
+
continue outer;
|
|
328
287
|
}
|
|
329
|
-
width += EMOJI_WIDTH;
|
|
330
|
-
unmatchedStart = indexPrev;
|
|
331
|
-
unmatchedEnd = index;
|
|
332
|
-
index = indexPrev = EMOJI_RE.lastIndex;
|
|
333
|
-
continue;
|
|
334
288
|
}
|
|
335
289
|
index += 1;
|
|
336
290
|
}
|
|
@@ -522,8 +476,11 @@ var exec = (string, columns, options = {}) => {
|
|
|
522
476
|
returnValue += character;
|
|
523
477
|
if (!inSurrogate) {
|
|
524
478
|
inSurrogate = character >= "\uD800" && character <= "\uDBFF";
|
|
479
|
+
if (inSurrogate) {
|
|
480
|
+
continue;
|
|
481
|
+
}
|
|
525
482
|
} else {
|
|
526
|
-
|
|
483
|
+
inSurrogate = false;
|
|
527
484
|
}
|
|
528
485
|
if (character === ESC || character === CSI) {
|
|
529
486
|
GROUP_REGEX.lastIndex = i + 1;
|
|
@@ -565,74 +522,96 @@ function wrapAnsi(string, columns, options) {
|
|
|
565
522
|
|
|
566
523
|
// node_modules/@clack/core/dist/index.mjs
|
|
567
524
|
var import_sisteransi = __toESM(require_src(), 1);
|
|
568
|
-
import { ReadStream as
|
|
569
|
-
function
|
|
570
|
-
if (!
|
|
525
|
+
import { ReadStream as O } from "tty";
|
|
526
|
+
function f(r, t, s) {
|
|
527
|
+
if (!s.some((o) => !o.disabled))
|
|
571
528
|
return r;
|
|
572
|
-
const
|
|
573
|
-
return
|
|
529
|
+
const e = r + t, i = Math.max(s.length - 1, 0), n = e < 0 ? i : e > i ? 0 : e;
|
|
530
|
+
return s[n].disabled ? f(n, t < 0 ? -1 : 1, s) : n;
|
|
531
|
+
}
|
|
532
|
+
function I(r, t, s, e) {
|
|
533
|
+
const i = e.split(`
|
|
534
|
+
`);
|
|
535
|
+
let n = 0, o = r;
|
|
536
|
+
for (const a of i) {
|
|
537
|
+
if (o <= a.length)
|
|
538
|
+
break;
|
|
539
|
+
o -= a.length + 1, n++;
|
|
540
|
+
}
|
|
541
|
+
for (n = Math.max(0, Math.min(i.length - 1, n + s)), o = Math.min(o, i[n].length) + t;o < 0 && n > 0; )
|
|
542
|
+
n--, o += i[n].length + 1;
|
|
543
|
+
for (;o > i[n].length && n < i.length - 1; )
|
|
544
|
+
o -= i[n].length + 1, n++;
|
|
545
|
+
o = Math.max(0, Math.min(i[n].length, o));
|
|
546
|
+
let u = 0;
|
|
547
|
+
for (let a = 0;a < n; a++)
|
|
548
|
+
u += i[a].length + 1;
|
|
549
|
+
return u + o;
|
|
574
550
|
}
|
|
575
|
-
var
|
|
576
|
-
var
|
|
577
|
-
var
|
|
578
|
-
function
|
|
551
|
+
var G = ["up", "down", "left", "right", "space", "enter", "cancel"];
|
|
552
|
+
var K = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
|
|
553
|
+
var h = { actions: new Set(G), aliases: new Map([["k", "up"], ["j", "down"], ["h", "left"], ["l", "right"], ["\x03", "cancel"], ["escape", "cancel"]]), messages: { cancel: "Canceled", error: "Something went wrong" }, withGuide: true, date: { monthNames: [...K], messages: { required: "Please enter a valid date", invalidMonth: "There are only 12 months in a year", invalidDay: (r, t) => `There are only ${r} days in ${t}`, afterMin: (r) => `Date must be on or after ${r.toISOString().slice(0, 10)}`, beforeMax: (r) => `Date must be on or before ${r.toISOString().slice(0, 10)}` } } };
|
|
554
|
+
function C(r, t) {
|
|
579
555
|
if (typeof r == "string")
|
|
580
|
-
return
|
|
581
|
-
for (const
|
|
582
|
-
if (
|
|
556
|
+
return h.aliases.get(r) === t;
|
|
557
|
+
for (const s of r)
|
|
558
|
+
if (s !== undefined && C(s, t))
|
|
583
559
|
return true;
|
|
584
560
|
return false;
|
|
585
561
|
}
|
|
586
|
-
function
|
|
562
|
+
function z(r, t) {
|
|
587
563
|
if (r === t)
|
|
588
564
|
return;
|
|
589
|
-
const
|
|
590
|
-
`),
|
|
591
|
-
`), i = Math.max(
|
|
565
|
+
const s = r.split(`
|
|
566
|
+
`), e = t.split(`
|
|
567
|
+
`), i = Math.max(s.length, e.length), n = [];
|
|
592
568
|
for (let o = 0;o < i; o++)
|
|
593
|
-
|
|
594
|
-
return { lines: n, numLinesBefore:
|
|
569
|
+
s[o] !== e[o] && n.push(o);
|
|
570
|
+
return { lines: n, numLinesBefore: s.length, numLinesAfter: e.length, numLines: i };
|
|
595
571
|
}
|
|
596
572
|
var Y = globalThis.process.platform.startsWith("win");
|
|
597
|
-
var
|
|
573
|
+
var k = Symbol("clack:cancel");
|
|
598
574
|
function q(r) {
|
|
599
|
-
return r ===
|
|
575
|
+
return r === k;
|
|
600
576
|
}
|
|
601
577
|
function w(r, t) {
|
|
602
|
-
const
|
|
603
|
-
|
|
578
|
+
const s = r;
|
|
579
|
+
s.isTTY && s.setRawMode(t);
|
|
604
580
|
}
|
|
605
|
-
function
|
|
606
|
-
const i =
|
|
607
|
-
|
|
608
|
-
const n = (o, { name:
|
|
581
|
+
function R({ input: r = D, output: t = x, overwrite: s = true, hideCursor: e = true } = {}) {
|
|
582
|
+
const i = b.createInterface({ input: r, output: t, prompt: "", tabSize: 1 });
|
|
583
|
+
b.emitKeypressEvents(r, i), r instanceof O && r.isTTY && r.setRawMode(true);
|
|
584
|
+
const n = (o, { name: u, sequence: a }) => {
|
|
609
585
|
const l = String(o);
|
|
610
|
-
if (
|
|
611
|
-
|
|
586
|
+
if (C([l, u, a], "cancel")) {
|
|
587
|
+
e && t.write(import_sisteransi.cursor.show), process.exit(0);
|
|
612
588
|
return;
|
|
613
589
|
}
|
|
614
|
-
if (!
|
|
590
|
+
if (!s)
|
|
615
591
|
return;
|
|
616
|
-
const
|
|
617
|
-
|
|
618
|
-
|
|
592
|
+
const c = u === "return" ? 0 : -1, y = u === "return" ? -1 : 0;
|
|
593
|
+
b.moveCursor(t, c, y, () => {
|
|
594
|
+
b.clearLine(t, 1, () => {
|
|
619
595
|
r.once("keypress", n);
|
|
620
596
|
});
|
|
621
597
|
});
|
|
622
598
|
};
|
|
623
|
-
return
|
|
624
|
-
r.off("keypress", n),
|
|
599
|
+
return e && t.write(import_sisteransi.cursor.hide), r.once("keypress", n), () => {
|
|
600
|
+
r.off("keypress", n), e && t.write(import_sisteransi.cursor.show), r instanceof O && r.isTTY && !Y && r.setRawMode(false), i.terminal = false, i.close();
|
|
625
601
|
};
|
|
626
602
|
}
|
|
627
|
-
var
|
|
628
|
-
var
|
|
629
|
-
function
|
|
630
|
-
const
|
|
631
|
-
return wrapAnsi(t,
|
|
632
|
-
`).map((
|
|
603
|
+
var A = (r) => ("columns" in r) && typeof r.columns == "number" ? r.columns : 80;
|
|
604
|
+
var L = (r) => ("rows" in r) && typeof r.rows == "number" ? r.rows : 20;
|
|
605
|
+
function W(r, t, s, e = s, i = s, n) {
|
|
606
|
+
const o = A(r ?? x);
|
|
607
|
+
return wrapAnsi(t, o - s.length, { hard: true, trim: false }).split(`
|
|
608
|
+
`).map((u, a, l) => {
|
|
609
|
+
const c = n ? n(u, a) : u;
|
|
610
|
+
return a === 0 ? `${e}${c}` : a === l.length - 1 ? `${i}${c}` : `${s}${c}`;
|
|
611
|
+
}).join(`
|
|
633
612
|
`);
|
|
634
613
|
}
|
|
635
|
-
var
|
|
614
|
+
var m = class {
|
|
636
615
|
input;
|
|
637
616
|
output;
|
|
638
617
|
_abortSignal;
|
|
@@ -647,27 +626,27 @@ var p = class {
|
|
|
647
626
|
error = "";
|
|
648
627
|
value;
|
|
649
628
|
userInput = "";
|
|
650
|
-
constructor(t,
|
|
651
|
-
const { input:
|
|
652
|
-
this.opts =
|
|
629
|
+
constructor(t, s = true) {
|
|
630
|
+
const { input: e = D, output: i = x, render: n, signal: o, ...u } = t;
|
|
631
|
+
this.opts = u, 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 = o, this.input = e, this.output = i;
|
|
653
632
|
}
|
|
654
633
|
unsubscribe() {
|
|
655
634
|
this._subscribers.clear();
|
|
656
635
|
}
|
|
657
|
-
setSubscriber(t,
|
|
658
|
-
const
|
|
659
|
-
|
|
636
|
+
setSubscriber(t, s) {
|
|
637
|
+
const e = this._subscribers.get(t) ?? [];
|
|
638
|
+
e.push(s), this._subscribers.set(t, e);
|
|
660
639
|
}
|
|
661
|
-
on(t,
|
|
662
|
-
this.setSubscriber(t, { cb:
|
|
640
|
+
on(t, s) {
|
|
641
|
+
this.setSubscriber(t, { cb: s });
|
|
663
642
|
}
|
|
664
|
-
once(t,
|
|
665
|
-
this.setSubscriber(t, { cb:
|
|
643
|
+
once(t, s) {
|
|
644
|
+
this.setSubscriber(t, { cb: s, once: true });
|
|
666
645
|
}
|
|
667
|
-
emit(t, ...
|
|
668
|
-
const
|
|
669
|
-
for (const n of
|
|
670
|
-
n.cb(...
|
|
646
|
+
emit(t, ...s) {
|
|
647
|
+
const e = this._subscribers.get(t) ?? [], i = [];
|
|
648
|
+
for (const n of e)
|
|
649
|
+
n.cb(...s), n.once && i.push(() => e.splice(e.indexOf(n), 1));
|
|
671
650
|
for (const n of i)
|
|
672
651
|
n();
|
|
673
652
|
}
|
|
@@ -675,39 +654,42 @@ var p = class {
|
|
|
675
654
|
return new Promise((t) => {
|
|
676
655
|
if (this._abortSignal) {
|
|
677
656
|
if (this._abortSignal.aborted)
|
|
678
|
-
return this.state = "cancel", this.close(), t(
|
|
657
|
+
return this.state = "cancel", this.close(), t(k);
|
|
679
658
|
this._abortSignal.addEventListener("abort", () => {
|
|
680
659
|
this.state = "cancel", this.close();
|
|
681
660
|
}, { once: true });
|
|
682
661
|
}
|
|
683
|
-
this.rl =
|
|
662
|
+
this.rl = E.createInterface({ input: this.input, tabSize: 2, prompt: "", escapeCodeTimeout: 50, terminal: true }), this.rl.prompt(), this.opts.initialUserInput !== undefined && this._setUserInput(this.opts.initialUserInput, true), this.input.on("keypress", this.onKeypress), w(this.input, true), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
|
|
684
663
|
this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), w(this.input, false), t(this.value);
|
|
685
664
|
}), this.once("cancel", () => {
|
|
686
|
-
this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), w(this.input, false), t(
|
|
665
|
+
this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), w(this.input, false), t(k);
|
|
687
666
|
});
|
|
688
667
|
});
|
|
689
668
|
}
|
|
690
|
-
_isActionKey(t,
|
|
669
|
+
_isActionKey(t, s) {
|
|
691
670
|
return t === "\t";
|
|
692
671
|
}
|
|
672
|
+
_shouldSubmit(t, s) {
|
|
673
|
+
return true;
|
|
674
|
+
}
|
|
693
675
|
_setValue(t) {
|
|
694
676
|
this.value = t, this.emit("value", this.value);
|
|
695
677
|
}
|
|
696
|
-
_setUserInput(t,
|
|
697
|
-
this.userInput = t ?? "", this.emit("userInput", this.userInput),
|
|
678
|
+
_setUserInput(t, s) {
|
|
679
|
+
this.userInput = t ?? "", this.emit("userInput", this.userInput), s && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
|
|
698
680
|
}
|
|
699
681
|
_clearUserInput() {
|
|
700
682
|
this.rl?.write(null, { ctrl: true, name: "u" }), this._setUserInput("");
|
|
701
683
|
}
|
|
702
|
-
onKeypress(t,
|
|
703
|
-
if (this._track &&
|
|
684
|
+
onKeypress(t, s) {
|
|
685
|
+
if (this._track && s.name !== "return" && (s.name && this._isActionKey(t, s) && this.rl?.write(null, { ctrl: true, name: "h" }), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"), s?.name && (!this._track && h.aliases.has(s.name) && this.emit("cursor", h.aliases.get(s.name)), h.actions.has(s.name) && this.emit("cursor", s.name)), t && (t.toLowerCase() === "y" || t.toLowerCase() === "n") && this.emit("confirm", t.toLowerCase() === "y"), this.emit("key", t?.toLowerCase(), s), s?.name === "return" && this._shouldSubmit(t, s)) {
|
|
704
686
|
if (this.opts.validate) {
|
|
705
|
-
const
|
|
706
|
-
|
|
687
|
+
const e = this.opts.validate(this.value);
|
|
688
|
+
e && (this.error = e instanceof Error ? e.message : e, this.state = "error", this.rl?.write(this.userInput));
|
|
707
689
|
}
|
|
708
690
|
this.state !== "error" && (this.state = "submit");
|
|
709
691
|
}
|
|
710
|
-
|
|
692
|
+
C([t, s?.name, s?.sequence], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
|
|
711
693
|
}
|
|
712
694
|
close() {
|
|
713
695
|
this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
|
|
@@ -724,31 +706,31 @@ var p = class {
|
|
|
724
706
|
if (this.state === "initial")
|
|
725
707
|
this.output.write(import_sisteransi.cursor.hide);
|
|
726
708
|
else {
|
|
727
|
-
const
|
|
728
|
-
if (this.restoreCursor(),
|
|
729
|
-
const i = Math.max(0,
|
|
730
|
-
let o =
|
|
709
|
+
const s = z(this._prevFrame, t), e = L(this.output);
|
|
710
|
+
if (this.restoreCursor(), s) {
|
|
711
|
+
const i = Math.max(0, s.numLinesAfter - e), n = Math.max(0, s.numLinesBefore - e);
|
|
712
|
+
let o = s.lines.find((u) => u >= i);
|
|
731
713
|
if (o === undefined) {
|
|
732
714
|
this._prevFrame = t;
|
|
733
715
|
return;
|
|
734
716
|
}
|
|
735
|
-
if (
|
|
717
|
+
if (s.lines.length === 1) {
|
|
736
718
|
this.output.write(import_sisteransi.cursor.move(0, o - n)), this.output.write(import_sisteransi.erase.lines(1));
|
|
737
|
-
const
|
|
719
|
+
const u = t.split(`
|
|
738
720
|
`);
|
|
739
|
-
this.output.write(
|
|
721
|
+
this.output.write(u[o]), this._prevFrame = t, this.output.write(import_sisteransi.cursor.move(0, u.length - o - 1));
|
|
740
722
|
return;
|
|
741
|
-
} else if (
|
|
723
|
+
} else if (s.lines.length > 1) {
|
|
742
724
|
if (i < n)
|
|
743
725
|
o = i;
|
|
744
726
|
else {
|
|
745
|
-
const
|
|
746
|
-
|
|
727
|
+
const a = o - n;
|
|
728
|
+
a > 0 && this.output.write(import_sisteransi.cursor.move(0, a));
|
|
747
729
|
}
|
|
748
730
|
this.output.write(import_sisteransi.erase.down());
|
|
749
|
-
const
|
|
731
|
+
const u = t.split(`
|
|
750
732
|
`).slice(o);
|
|
751
|
-
this.output.write(
|
|
733
|
+
this.output.write(u.join(`
|
|
752
734
|
`)), this._prevFrame = t;
|
|
753
735
|
return;
|
|
754
736
|
}
|
|
@@ -759,87 +741,87 @@ var p = class {
|
|
|
759
741
|
}
|
|
760
742
|
}
|
|
761
743
|
};
|
|
762
|
-
function
|
|
744
|
+
function B(r, t) {
|
|
763
745
|
if (r === undefined || t.length === 0)
|
|
764
746
|
return 0;
|
|
765
|
-
const
|
|
766
|
-
return
|
|
747
|
+
const s = t.findIndex((e) => e.value === r);
|
|
748
|
+
return s !== -1 ? s : 0;
|
|
767
749
|
}
|
|
768
|
-
function
|
|
750
|
+
function J(r, t) {
|
|
769
751
|
return (t.label ?? String(t.value)).toLowerCase().includes(r.toLowerCase());
|
|
770
752
|
}
|
|
771
|
-
function
|
|
753
|
+
function H(r, t) {
|
|
772
754
|
if (t)
|
|
773
755
|
return r ? t : t[0];
|
|
774
756
|
}
|
|
775
|
-
var
|
|
757
|
+
var Q = class extends m {
|
|
776
758
|
filteredOptions;
|
|
777
759
|
multiple;
|
|
778
760
|
isNavigating = false;
|
|
779
761
|
selectedValues = [];
|
|
780
762
|
focusedValue;
|
|
781
|
-
#
|
|
782
|
-
#
|
|
763
|
+
#s = 0;
|
|
764
|
+
#r = "";
|
|
783
765
|
#t;
|
|
784
766
|
#n;
|
|
785
|
-
#
|
|
767
|
+
#u;
|
|
786
768
|
get cursor() {
|
|
787
|
-
return this.#
|
|
769
|
+
return this.#s;
|
|
788
770
|
}
|
|
789
771
|
get userInputWithCursor() {
|
|
790
772
|
if (!this.userInput)
|
|
791
|
-
return
|
|
773
|
+
return v(["inverse", "hidden"], "_");
|
|
792
774
|
if (this._cursor >= this.userInput.length)
|
|
793
775
|
return `${this.userInput}\u2588`;
|
|
794
|
-
const t = this.userInput.slice(0, this._cursor), [
|
|
795
|
-
return `${t}${
|
|
776
|
+
const t = this.userInput.slice(0, this._cursor), [s, ...e] = this.userInput.slice(this._cursor);
|
|
777
|
+
return `${t}${v("inverse", s)}${e.join("")}`;
|
|
796
778
|
}
|
|
797
779
|
get options() {
|
|
798
780
|
return typeof this.#n == "function" ? this.#n() : this.#n;
|
|
799
781
|
}
|
|
800
782
|
constructor(t) {
|
|
801
|
-
super(t), this.#n = t.options, this.#
|
|
802
|
-
const
|
|
803
|
-
this.filteredOptions = [...
|
|
804
|
-
let
|
|
805
|
-
if (t.initialValue && Array.isArray(t.initialValue) ? this.multiple ?
|
|
806
|
-
for (const i of
|
|
807
|
-
const n =
|
|
808
|
-
n !== -1 && (this.toggleSelected(i), this.#
|
|
783
|
+
super(t), this.#n = t.options, this.#u = t.placeholder;
|
|
784
|
+
const s = this.options;
|
|
785
|
+
this.filteredOptions = [...s], this.multiple = t.multiple === true, this.#t = typeof t.options == "function" ? t.filter : t.filter ?? J;
|
|
786
|
+
let e;
|
|
787
|
+
if (t.initialValue && Array.isArray(t.initialValue) ? this.multiple ? e = t.initialValue : e = t.initialValue.slice(0, 1) : !this.multiple && this.options.length > 0 && (e = [this.options[0].value]), e)
|
|
788
|
+
for (const i of e) {
|
|
789
|
+
const n = s.findIndex((o) => o.value === i);
|
|
790
|
+
n !== -1 && (this.toggleSelected(i), this.#s = n);
|
|
809
791
|
}
|
|
810
|
-
this.focusedValue = this.options[this.#
|
|
792
|
+
this.focusedValue = this.options[this.#s]?.value, this.on("key", (i, n) => this.#e(i, n)), this.on("userInput", (i) => this.#i(i));
|
|
811
793
|
}
|
|
812
|
-
_isActionKey(t,
|
|
813
|
-
return t === "\t" || this.multiple && this.isNavigating &&
|
|
794
|
+
_isActionKey(t, s) {
|
|
795
|
+
return t === "\t" || this.multiple && this.isNavigating && s.name === "space" && t !== undefined && t !== "";
|
|
814
796
|
}
|
|
815
|
-
#
|
|
816
|
-
const
|
|
817
|
-
if (
|
|
818
|
-
this.userInput === "\t" && this._clearUserInput(), this._setUserInput(
|
|
797
|
+
#e(t, s) {
|
|
798
|
+
const e = s.name === "up", i = s.name === "down", n = s.name === "return", o = this.userInput === "" || this.userInput === "\t", u = this.#u, a = this.options, l = u !== undefined && u !== "" && a.some((c) => !c.disabled && (this.#t ? this.#t(u, c) : true));
|
|
799
|
+
if (s.name === "tab" && o && l) {
|
|
800
|
+
this.userInput === "\t" && this._clearUserInput(), this._setUserInput(u, true), this.isNavigating = false;
|
|
819
801
|
return;
|
|
820
802
|
}
|
|
821
|
-
|
|
803
|
+
e || i ? (this.#s = f(this.#s, e ? -1 : 1, this.filteredOptions), this.focusedValue = this.filteredOptions[this.#s]?.value, this.multiple || (this.selectedValues = [this.focusedValue]), this.isNavigating = true) : n ? this.value = H(this.multiple, this.selectedValues) : this.multiple ? this.focusedValue !== undefined && (s.name === "tab" || this.isNavigating && s.name === "space") ? this.toggleSelected(this.focusedValue) : this.isNavigating = false : (this.focusedValue && (this.selectedValues = [this.focusedValue]), this.isNavigating = false);
|
|
822
804
|
}
|
|
823
805
|
deselectAll() {
|
|
824
806
|
this.selectedValues = [];
|
|
825
807
|
}
|
|
826
808
|
toggleSelected(t) {
|
|
827
|
-
this.filteredOptions.length !== 0 && (this.multiple ? this.selectedValues.includes(t) ? this.selectedValues = this.selectedValues.filter((
|
|
809
|
+
this.filteredOptions.length !== 0 && (this.multiple ? this.selectedValues.includes(t) ? this.selectedValues = this.selectedValues.filter((s) => s !== t) : this.selectedValues = [...this.selectedValues, t] : this.selectedValues = [t]);
|
|
828
810
|
}
|
|
829
811
|
#i(t) {
|
|
830
|
-
if (t !== this.#
|
|
831
|
-
this.#
|
|
832
|
-
const
|
|
833
|
-
t && this.#t ? this.filteredOptions =
|
|
834
|
-
const
|
|
835
|
-
this.#
|
|
836
|
-
const i = this.filteredOptions[this.#
|
|
812
|
+
if (t !== this.#r) {
|
|
813
|
+
this.#r = t;
|
|
814
|
+
const s = this.options;
|
|
815
|
+
t && this.#t ? this.filteredOptions = s.filter((n) => this.#t?.(t, n)) : this.filteredOptions = [...s];
|
|
816
|
+
const e = B(this.focusedValue, this.filteredOptions);
|
|
817
|
+
this.#s = f(e, 0, this.filteredOptions);
|
|
818
|
+
const i = this.filteredOptions[this.#s];
|
|
837
819
|
i && !i.disabled ? this.focusedValue = i.value : this.focusedValue = undefined, this.multiple || (this.focusedValue !== undefined ? this.toggleSelected(this.focusedValue) : this.deselectAll());
|
|
838
820
|
}
|
|
839
821
|
}
|
|
840
822
|
};
|
|
841
823
|
|
|
842
|
-
class
|
|
824
|
+
class X2 extends m {
|
|
843
825
|
get cursor() {
|
|
844
826
|
return this.value ? 0 : 1;
|
|
845
827
|
}
|
|
@@ -849,102 +831,102 @@ class Q extends p {
|
|
|
849
831
|
constructor(t) {
|
|
850
832
|
super(t, false), this.value = !!t.initialValue, this.on("userInput", () => {
|
|
851
833
|
this.value = this._value;
|
|
852
|
-
}), this.on("confirm", (
|
|
853
|
-
this.output.write(import_sisteransi.cursor.move(0, -1)), this.value =
|
|
834
|
+
}), this.on("confirm", (s) => {
|
|
835
|
+
this.output.write(import_sisteransi.cursor.move(0, -1)), this.value = s, this.state = "submit", this.close();
|
|
854
836
|
}), this.on("cursor", () => {
|
|
855
837
|
this.value = !this.value;
|
|
856
838
|
});
|
|
857
839
|
}
|
|
858
840
|
}
|
|
859
|
-
var
|
|
860
|
-
function
|
|
861
|
-
return [...r].map((t) =>
|
|
841
|
+
var Z = { Y: { type: "year", len: 4 }, M: { type: "month", len: 2 }, D: { type: "day", len: 2 } };
|
|
842
|
+
function P(r) {
|
|
843
|
+
return [...r].map((t) => Z[t]);
|
|
862
844
|
}
|
|
863
|
-
function
|
|
864
|
-
const t = new Intl.DateTimeFormat(r, { year: "numeric", month: "2-digit", day: "2-digit" }).formatToParts(new Date(2000, 0, 15)),
|
|
865
|
-
let
|
|
845
|
+
function tt(r) {
|
|
846
|
+
const t = new Intl.DateTimeFormat(r, { year: "numeric", month: "2-digit", day: "2-digit" }).formatToParts(new Date(2000, 0, 15)), s = [];
|
|
847
|
+
let e = "/";
|
|
866
848
|
for (const i of t)
|
|
867
|
-
i.type === "literal" ?
|
|
868
|
-
return { segments:
|
|
849
|
+
i.type === "literal" ? e = i.value.trim() || i.value : (i.type === "year" || i.type === "month" || i.type === "day") && s.push({ type: i.type, len: i.type === "year" ? 4 : 2 });
|
|
850
|
+
return { segments: s, separator: e };
|
|
869
851
|
}
|
|
870
|
-
function
|
|
852
|
+
function $(r) {
|
|
871
853
|
return Number.parseInt((r || "0").replace(/_/g, "0"), 10) || 0;
|
|
872
854
|
}
|
|
873
|
-
function
|
|
874
|
-
return { year:
|
|
855
|
+
function S(r) {
|
|
856
|
+
return { year: $(r.year), month: $(r.month), day: $(r.day) };
|
|
875
857
|
}
|
|
876
|
-
function
|
|
858
|
+
function U(r, t) {
|
|
877
859
|
return new Date(r || 2001, t || 1, 0).getDate();
|
|
878
860
|
}
|
|
879
861
|
function F(r) {
|
|
880
|
-
const { year: t, month:
|
|
881
|
-
if (!t || t < 0 || t > 9999 || !
|
|
862
|
+
const { year: t, month: s, day: e } = S(r);
|
|
863
|
+
if (!t || t < 0 || t > 9999 || !s || s < 1 || s > 12 || !e || e < 1)
|
|
882
864
|
return;
|
|
883
|
-
const i = new Date(Date.UTC(t,
|
|
884
|
-
if (!(i.getUTCFullYear() !== t || i.getUTCMonth() !==
|
|
885
|
-
return { year: t, month:
|
|
865
|
+
const i = new Date(Date.UTC(t, s - 1, e));
|
|
866
|
+
if (!(i.getUTCFullYear() !== t || i.getUTCMonth() !== s - 1 || i.getUTCDate() !== e))
|
|
867
|
+
return { year: t, month: s, day: e };
|
|
886
868
|
}
|
|
887
869
|
function N(r) {
|
|
888
870
|
const t = F(r);
|
|
889
871
|
return t ? new Date(Date.UTC(t.year, t.month - 1, t.day)) : undefined;
|
|
890
872
|
}
|
|
891
|
-
function
|
|
892
|
-
const i =
|
|
893
|
-
return r === "year" ? { min: i?.year ?? 1, max: n?.year ?? 9999 } : r === "month" ? { min: i && t.year === i.year ? i.month : 1, max: n && t.year === n.year ? n.month : 12 } : { min: i && t.year === i.year && t.month === i.month ? i.day : 1, max: n && t.year === n.year && t.month === n.month ? n.day :
|
|
873
|
+
function st(r, t, s, e) {
|
|
874
|
+
const i = s ? { year: s.getUTCFullYear(), month: s.getUTCMonth() + 1, day: s.getUTCDate() } : null, n = e ? { year: e.getUTCFullYear(), month: e.getUTCMonth() + 1, day: e.getUTCDate() } : null;
|
|
875
|
+
return r === "year" ? { min: i?.year ?? 1, max: n?.year ?? 9999 } : r === "month" ? { min: i && t.year === i.year ? i.month : 1, max: n && t.year === n.year ? n.month : 12 } : { min: i && t.year === i.year && t.month === i.month ? i.day : 1, max: n && t.year === n.year && t.month === n.month ? n.day : U(t.year, t.month) };
|
|
894
876
|
}
|
|
895
877
|
|
|
896
|
-
class et extends
|
|
897
|
-
#
|
|
898
|
-
#
|
|
878
|
+
class et extends m {
|
|
879
|
+
#s;
|
|
880
|
+
#r;
|
|
899
881
|
#t;
|
|
900
882
|
#n;
|
|
901
|
-
#
|
|
902
|
-
#
|
|
883
|
+
#u;
|
|
884
|
+
#e = { segmentIndex: 0, positionInSegment: 0 };
|
|
903
885
|
#i = true;
|
|
904
|
-
#
|
|
886
|
+
#o = null;
|
|
905
887
|
inlineError = "";
|
|
906
888
|
get segmentCursor() {
|
|
907
|
-
return { ...this.#
|
|
889
|
+
return { ...this.#e };
|
|
908
890
|
}
|
|
909
891
|
get segmentValues() {
|
|
910
892
|
return { ...this.#t };
|
|
911
893
|
}
|
|
912
894
|
get segments() {
|
|
913
|
-
return this.#
|
|
895
|
+
return this.#s;
|
|
914
896
|
}
|
|
915
897
|
get separator() {
|
|
916
|
-
return this.#
|
|
898
|
+
return this.#r;
|
|
917
899
|
}
|
|
918
900
|
get formattedValue() {
|
|
919
901
|
return this.#c(this.#t);
|
|
920
902
|
}
|
|
921
903
|
#c(t) {
|
|
922
|
-
return this.#
|
|
904
|
+
return this.#s.map((s) => t[s.type]).join(this.#r);
|
|
923
905
|
}
|
|
924
|
-
#
|
|
906
|
+
#a() {
|
|
925
907
|
this._setUserInput(this.#c(this.#t)), this._setValue(N(this.#t) ?? undefined);
|
|
926
908
|
}
|
|
927
909
|
constructor(t) {
|
|
928
|
-
const
|
|
929
|
-
super({ ...t, initialUserInput:
|
|
910
|
+
const s = t.format ? { segments: P(t.format), separator: t.separator ?? "/" } : tt(t.locale), e = t.separator ?? s.separator, i = t.format ? P(t.format) : s.segments, n = t.initialValue ?? t.defaultValue, o = n ? { year: String(n.getUTCFullYear()).padStart(4, "0"), month: String(n.getUTCMonth() + 1).padStart(2, "0"), day: String(n.getUTCDate()).padStart(2, "0") } : { year: "____", month: "__", day: "__" }, u = i.map((a) => o[a.type]).join(e);
|
|
911
|
+
super({ ...t, initialUserInput: u }, false), this.#s = i, this.#r = e, this.#t = o, this.#n = t.minDate, this.#u = t.maxDate, this.#a(), this.on("cursor", (a) => this.#d(a)), this.on("key", (a, l) => this.#f(a, l)), this.on("finalize", () => this.#g(t));
|
|
930
912
|
}
|
|
931
|
-
#
|
|
932
|
-
const t = Math.max(0, Math.min(this.#
|
|
933
|
-
if (
|
|
934
|
-
return this.#
|
|
913
|
+
#h() {
|
|
914
|
+
const t = Math.max(0, Math.min(this.#e.segmentIndex, this.#s.length - 1)), s = this.#s[t];
|
|
915
|
+
if (s)
|
|
916
|
+
return this.#e.positionInSegment = Math.max(0, Math.min(this.#e.positionInSegment, s.len - 1)), { segment: s, index: t };
|
|
935
917
|
}
|
|
936
918
|
#l(t) {
|
|
937
|
-
this.inlineError = "", this.#
|
|
938
|
-
const
|
|
939
|
-
|
|
919
|
+
this.inlineError = "", this.#o = null;
|
|
920
|
+
const s = this.#h();
|
|
921
|
+
s && (this.#e.segmentIndex = Math.max(0, Math.min(this.#s.length - 1, s.index + t)), this.#e.positionInSegment = 0, this.#i = true);
|
|
940
922
|
}
|
|
941
923
|
#p(t) {
|
|
942
|
-
const
|
|
943
|
-
if (!
|
|
924
|
+
const s = this.#h();
|
|
925
|
+
if (!s)
|
|
944
926
|
return;
|
|
945
|
-
const { segment:
|
|
946
|
-
let
|
|
947
|
-
n ?
|
|
927
|
+
const { segment: e } = s, i = this.#t[e.type], n = !i || i.replace(/_/g, "") === "", o = Number.parseInt((i || "0").replace(/_/g, "0"), 10) || 0, u = st(e.type, S(this.#t), this.#n, this.#u);
|
|
928
|
+
let a;
|
|
929
|
+
n ? a = t === 1 ? u.min : u.max : a = Math.max(Math.min(u.max, o + t), u.min), this.#t = { ...this.#t, [e.type]: a.toString().padStart(e.len, "0") }, this.#i = true, this.#o = null, this.#a();
|
|
948
930
|
}
|
|
949
931
|
#d(t) {
|
|
950
932
|
if (t)
|
|
@@ -959,124 +941,124 @@ class et extends p {
|
|
|
959
941
|
return this.#p(-1);
|
|
960
942
|
}
|
|
961
943
|
}
|
|
962
|
-
#f(t,
|
|
963
|
-
if (
|
|
944
|
+
#f(t, s) {
|
|
945
|
+
if (s?.name === "backspace" || s?.sequence === "\x7F" || s?.sequence === "\b" || t === "\x7F" || t === "\b") {
|
|
964
946
|
this.inlineError = "";
|
|
965
|
-
const
|
|
966
|
-
if (!
|
|
947
|
+
const e = this.#h();
|
|
948
|
+
if (!e)
|
|
967
949
|
return;
|
|
968
|
-
if (!this.#t[
|
|
950
|
+
if (!this.#t[e.segment.type].replace(/_/g, "")) {
|
|
969
951
|
this.#l(-1);
|
|
970
952
|
return;
|
|
971
953
|
}
|
|
972
|
-
this.#t[
|
|
954
|
+
this.#t[e.segment.type] = "_".repeat(e.segment.len), this.#i = true, this.#e.positionInSegment = 0, this.#a();
|
|
973
955
|
return;
|
|
974
956
|
}
|
|
975
|
-
if (
|
|
957
|
+
if (s?.name === "tab") {
|
|
976
958
|
this.inlineError = "";
|
|
977
|
-
const
|
|
978
|
-
if (!
|
|
959
|
+
const e = this.#h();
|
|
960
|
+
if (!e)
|
|
979
961
|
return;
|
|
980
|
-
const i =
|
|
981
|
-
n >= 0 && n < this.#
|
|
962
|
+
const i = s.shift ? -1 : 1, n = e.index + i;
|
|
963
|
+
n >= 0 && n < this.#s.length && (this.#e.segmentIndex = n, this.#e.positionInSegment = 0, this.#i = true);
|
|
982
964
|
return;
|
|
983
965
|
}
|
|
984
966
|
if (t && /^[0-9]$/.test(t)) {
|
|
985
|
-
const
|
|
986
|
-
if (!
|
|
967
|
+
const e = this.#h();
|
|
968
|
+
if (!e)
|
|
987
969
|
return;
|
|
988
|
-
const { segment: i } =
|
|
989
|
-
if (this.#i && this.#
|
|
990
|
-
const
|
|
991
|
-
if (
|
|
992
|
-
this.inlineError =
|
|
970
|
+
const { segment: i } = e, n = !this.#t[i.type].replace(/_/g, "");
|
|
971
|
+
if (this.#i && this.#o !== null && !n) {
|
|
972
|
+
const d = this.#o + t, g = { ...this.#t, [i.type]: d }, _ = this.#m(g, i);
|
|
973
|
+
if (_) {
|
|
974
|
+
this.inlineError = _, this.#o = null, this.#i = false;
|
|
993
975
|
return;
|
|
994
976
|
}
|
|
995
|
-
this.inlineError = "", this.#t[i.type] =
|
|
977
|
+
this.inlineError = "", this.#t[i.type] = d, this.#o = null, this.#i = false, this.#a(), e.index < this.#s.length - 1 && (this.#e.segmentIndex = e.index + 1, this.#e.positionInSegment = 0, this.#i = true);
|
|
996
978
|
return;
|
|
997
979
|
}
|
|
998
|
-
this.#i && !n && (this.#t[i.type] = "_".repeat(i.len), this.#
|
|
999
|
-
const o = this.#t[i.type],
|
|
1000
|
-
if (
|
|
980
|
+
this.#i && !n && (this.#t[i.type] = "_".repeat(i.len), this.#e.positionInSegment = 0), this.#i = false, this.#o = null;
|
|
981
|
+
const o = this.#t[i.type], u = o.indexOf("_"), a = u >= 0 ? u : Math.min(this.#e.positionInSegment, i.len - 1);
|
|
982
|
+
if (a < 0 || a >= i.len)
|
|
1001
983
|
return;
|
|
1002
|
-
let l = o.slice(0,
|
|
1003
|
-
if (
|
|
1004
|
-
const
|
|
1005
|
-
l = `0${t}`,
|
|
984
|
+
let l = o.slice(0, a) + t + o.slice(a + 1), c = false;
|
|
985
|
+
if (a === 0 && o === "__" && (i.type === "month" || i.type === "day")) {
|
|
986
|
+
const d = Number.parseInt(t, 10);
|
|
987
|
+
l = `0${t}`, c = d <= (i.type === "month" ? 1 : 2);
|
|
1006
988
|
}
|
|
1007
989
|
if (i.type === "year" && (l = (o.replace(/_/g, "") + t).padStart(i.len, "_")), !l.includes("_")) {
|
|
1008
|
-
const
|
|
990
|
+
const d = { ...this.#t, [i.type]: l }, g = this.#m(d, i);
|
|
1009
991
|
if (g) {
|
|
1010
992
|
this.inlineError = g;
|
|
1011
993
|
return;
|
|
1012
994
|
}
|
|
1013
995
|
}
|
|
1014
996
|
this.inlineError = "", this.#t[i.type] = l;
|
|
1015
|
-
const
|
|
1016
|
-
if (
|
|
1017
|
-
const { year:
|
|
1018
|
-
this.#t = { year: String(Math.max(0, Math.min(9999,
|
|
997
|
+
const y = l.includes("_") ? undefined : F(this.#t);
|
|
998
|
+
if (y) {
|
|
999
|
+
const { year: d, month: g } = y, _ = U(d, g);
|
|
1000
|
+
this.#t = { year: String(Math.max(0, Math.min(9999, d))).padStart(4, "0"), month: String(Math.max(1, Math.min(12, g))).padStart(2, "0"), day: String(Math.max(1, Math.min(_, y.day))).padStart(2, "0") };
|
|
1019
1001
|
}
|
|
1020
|
-
this.#
|
|
1021
|
-
const
|
|
1022
|
-
|
|
1002
|
+
this.#a();
|
|
1003
|
+
const T = l.indexOf("_");
|
|
1004
|
+
c ? (this.#i = true, this.#o = t) : T >= 0 ? this.#e.positionInSegment = T : u >= 0 && e.index < this.#s.length - 1 ? (this.#e.segmentIndex = e.index + 1, this.#e.positionInSegment = 0, this.#i = true) : this.#e.positionInSegment = Math.min(a + 1, i.len - 1);
|
|
1023
1005
|
}
|
|
1024
1006
|
}
|
|
1025
|
-
#m(t,
|
|
1026
|
-
const { month:
|
|
1027
|
-
if (
|
|
1028
|
-
return
|
|
1029
|
-
if (
|
|
1030
|
-
return
|
|
1007
|
+
#m(t, s) {
|
|
1008
|
+
const { month: e, day: i } = S(t);
|
|
1009
|
+
if (s.type === "month" && (e < 0 || e > 12))
|
|
1010
|
+
return h.date.messages.invalidMonth;
|
|
1011
|
+
if (s.type === "day" && (i < 0 || i > 31))
|
|
1012
|
+
return h.date.messages.invalidDay(31, "any month");
|
|
1031
1013
|
}
|
|
1032
1014
|
#g(t) {
|
|
1033
|
-
const { year:
|
|
1034
|
-
if (
|
|
1035
|
-
const n =
|
|
1015
|
+
const { year: s, month: e, day: i } = S(this.#t);
|
|
1016
|
+
if (s && e && i) {
|
|
1017
|
+
const n = U(s, e);
|
|
1036
1018
|
this.#t = { ...this.#t, day: String(Math.min(i, n)).padStart(2, "0") };
|
|
1037
1019
|
}
|
|
1038
1020
|
this.value = N(this.#t) ?? t.defaultValue ?? undefined;
|
|
1039
1021
|
}
|
|
1040
1022
|
}
|
|
1041
1023
|
|
|
1042
|
-
class
|
|
1024
|
+
class it extends m {
|
|
1043
1025
|
options;
|
|
1044
1026
|
cursor = 0;
|
|
1045
|
-
#
|
|
1027
|
+
#s;
|
|
1046
1028
|
getGroupItems(t) {
|
|
1047
|
-
return this.options.filter((
|
|
1029
|
+
return this.options.filter((s) => s.group === t);
|
|
1048
1030
|
}
|
|
1049
1031
|
isGroupSelected(t) {
|
|
1050
|
-
const
|
|
1051
|
-
return
|
|
1032
|
+
const s = this.getGroupItems(t), e = this.value;
|
|
1033
|
+
return e === undefined ? false : s.every((i) => e.includes(i.value));
|
|
1052
1034
|
}
|
|
1053
1035
|
toggleValue() {
|
|
1054
1036
|
const t = this.options[this.cursor];
|
|
1055
1037
|
if (this.value === undefined && (this.value = []), t.group === true) {
|
|
1056
|
-
const
|
|
1057
|
-
this.isGroupSelected(
|
|
1038
|
+
const s = t.value, e = this.getGroupItems(s);
|
|
1039
|
+
this.isGroupSelected(s) ? this.value = this.value.filter((i) => e.findIndex((n) => n.value === i) === -1) : this.value = [...this.value, ...e.map((i) => i.value)], this.value = Array.from(new Set(this.value));
|
|
1058
1040
|
} else {
|
|
1059
|
-
const
|
|
1060
|
-
this.value =
|
|
1041
|
+
const s = this.value.includes(t.value);
|
|
1042
|
+
this.value = s ? this.value.filter((e) => e !== t.value) : [...this.value, t.value];
|
|
1061
1043
|
}
|
|
1062
1044
|
}
|
|
1063
1045
|
constructor(t) {
|
|
1064
1046
|
super(t, false);
|
|
1065
|
-
const { options:
|
|
1066
|
-
this.#
|
|
1067
|
-
switch (
|
|
1047
|
+
const { options: s } = t;
|
|
1048
|
+
this.#s = t.selectableGroups !== false, this.options = Object.entries(s).flatMap(([e, i]) => [{ value: e, group: true, label: e }, ...i.map((n) => ({ ...n, group: e }))]), this.value = [...t.initialValues ?? []], this.cursor = Math.max(this.options.findIndex(({ value: e }) => e === t.cursorAt), this.#s ? 0 : 1), this.on("cursor", (e) => {
|
|
1049
|
+
switch (e) {
|
|
1068
1050
|
case "left":
|
|
1069
1051
|
case "up": {
|
|
1070
1052
|
this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
|
|
1071
1053
|
const i = this.options[this.cursor]?.group === true;
|
|
1072
|
-
!this.#
|
|
1054
|
+
!this.#s && i && (this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1);
|
|
1073
1055
|
break;
|
|
1074
1056
|
}
|
|
1075
1057
|
case "down":
|
|
1076
1058
|
case "right": {
|
|
1077
1059
|
this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
|
|
1078
1060
|
const i = this.options[this.cursor]?.group === true;
|
|
1079
|
-
!this.#
|
|
1061
|
+
!this.#s && i && (this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1);
|
|
1080
1062
|
break;
|
|
1081
1063
|
}
|
|
1082
1064
|
case "space":
|
|
@@ -1086,7 +1068,87 @@ class st extends p {
|
|
|
1086
1068
|
});
|
|
1087
1069
|
}
|
|
1088
1070
|
}
|
|
1089
|
-
|
|
1071
|
+
|
|
1072
|
+
class rt extends m {
|
|
1073
|
+
#s = false;
|
|
1074
|
+
#r;
|
|
1075
|
+
focused = "editor";
|
|
1076
|
+
get userInputWithCursor() {
|
|
1077
|
+
if (this.state === "submit")
|
|
1078
|
+
return this.userInput;
|
|
1079
|
+
const t = this.userInput;
|
|
1080
|
+
if (this.cursor >= t.length)
|
|
1081
|
+
return `${t}\u2588`;
|
|
1082
|
+
const s = t.slice(0, this.cursor), e = t[this.cursor], i = t.slice(this.cursor + 1);
|
|
1083
|
+
return e === `
|
|
1084
|
+
` ? `${s}\u2588
|
|
1085
|
+
${i}` : `${s}${v("inverse", e)}${i}`;
|
|
1086
|
+
}
|
|
1087
|
+
get cursor() {
|
|
1088
|
+
return this._cursor;
|
|
1089
|
+
}
|
|
1090
|
+
#t(t) {
|
|
1091
|
+
if (this.userInput.length === 0) {
|
|
1092
|
+
this._setUserInput(t);
|
|
1093
|
+
return;
|
|
1094
|
+
}
|
|
1095
|
+
this._setUserInput(this.userInput.slice(0, this.cursor) + t + this.userInput.slice(this.cursor));
|
|
1096
|
+
}
|
|
1097
|
+
#n(t) {
|
|
1098
|
+
const s = this.value ?? "";
|
|
1099
|
+
switch (t) {
|
|
1100
|
+
case "up":
|
|
1101
|
+
this._cursor = I(this._cursor, 0, -1, s);
|
|
1102
|
+
return;
|
|
1103
|
+
case "down":
|
|
1104
|
+
this._cursor = I(this._cursor, 0, 1, s);
|
|
1105
|
+
return;
|
|
1106
|
+
case "left":
|
|
1107
|
+
this._cursor = I(this._cursor, -1, 0, s);
|
|
1108
|
+
return;
|
|
1109
|
+
case "right":
|
|
1110
|
+
this._cursor = I(this._cursor, 1, 0, s);
|
|
1111
|
+
return;
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
_shouldSubmit(t, s) {
|
|
1115
|
+
if (this.#r)
|
|
1116
|
+
return this.focused === "submit" ? true : (this.#t(`
|
|
1117
|
+
`), this._cursor++, false);
|
|
1118
|
+
const e = this.#s;
|
|
1119
|
+
return this.#s = true, e ? (this.userInput[this.cursor - 1] === `
|
|
1120
|
+
` && (this._setUserInput(this.userInput.slice(0, this.cursor - 1) + this.userInput.slice(this.cursor)), this._cursor--), true) : (this.#t(`
|
|
1121
|
+
`), this._cursor++, false);
|
|
1122
|
+
}
|
|
1123
|
+
constructor(t) {
|
|
1124
|
+
super(t, false), this.#r = t.showSubmit ?? false, this.on("key", (s, e) => {
|
|
1125
|
+
if (e?.name && h.actions.has(e.name)) {
|
|
1126
|
+
this.#n(e.name);
|
|
1127
|
+
return;
|
|
1128
|
+
}
|
|
1129
|
+
if (s === "\t" && this.#r) {
|
|
1130
|
+
this.focused = this.focused === "editor" ? "submit" : "editor";
|
|
1131
|
+
return;
|
|
1132
|
+
}
|
|
1133
|
+
if (e?.name !== "return") {
|
|
1134
|
+
if (this.#s = false, e?.name === "backspace" && this.cursor > 0) {
|
|
1135
|
+
this._setUserInput(this.userInput.slice(0, this.cursor - 1) + this.userInput.slice(this.cursor)), this._cursor--;
|
|
1136
|
+
return;
|
|
1137
|
+
}
|
|
1138
|
+
if (e?.name === "delete" && this.cursor < this.userInput.length) {
|
|
1139
|
+
this._setUserInput(this.userInput.slice(0, this.cursor) + this.userInput.slice(this.cursor + 1));
|
|
1140
|
+
return;
|
|
1141
|
+
}
|
|
1142
|
+
s && (this.#r && this.focused === "submit" && (this.focused = "editor"), this.#t(s ?? ""), this._cursor++);
|
|
1143
|
+
}
|
|
1144
|
+
}), this.on("userInput", (s) => {
|
|
1145
|
+
this._setValue(s);
|
|
1146
|
+
}), this.on("finalize", () => {
|
|
1147
|
+
this.value || (this.value = t.defaultValue), this.value === undefined && (this.value = "");
|
|
1148
|
+
});
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1151
|
+
var nt = class extends m {
|
|
1090
1152
|
options;
|
|
1091
1153
|
cursor = 0;
|
|
1092
1154
|
get _value() {
|
|
@@ -1096,35 +1158,35 @@ var it = class extends p {
|
|
|
1096
1158
|
return this.options.filter((t) => t.disabled !== true);
|
|
1097
1159
|
}
|
|
1098
1160
|
toggleAll() {
|
|
1099
|
-
const t = this._enabledOptions,
|
|
1100
|
-
this.value =
|
|
1161
|
+
const t = this._enabledOptions, s = this.value !== undefined && this.value.length === t.length;
|
|
1162
|
+
this.value = s ? [] : t.map((e) => e.value);
|
|
1101
1163
|
}
|
|
1102
1164
|
toggleInvert() {
|
|
1103
1165
|
const t = this.value;
|
|
1104
1166
|
if (!t)
|
|
1105
1167
|
return;
|
|
1106
|
-
const
|
|
1107
|
-
this.value =
|
|
1168
|
+
const s = this._enabledOptions.filter((e) => !t.includes(e.value));
|
|
1169
|
+
this.value = s.map((e) => e.value);
|
|
1108
1170
|
}
|
|
1109
1171
|
toggleValue() {
|
|
1110
1172
|
this.value === undefined && (this.value = []);
|
|
1111
1173
|
const t = this.value.includes(this._value);
|
|
1112
|
-
this.value = t ? this.value.filter((
|
|
1174
|
+
this.value = t ? this.value.filter((s) => s !== this._value) : [...this.value, this._value];
|
|
1113
1175
|
}
|
|
1114
1176
|
constructor(t) {
|
|
1115
1177
|
super(t, false), this.options = t.options, this.value = [...t.initialValues ?? []];
|
|
1116
|
-
const
|
|
1117
|
-
this.cursor = this.options[
|
|
1118
|
-
|
|
1119
|
-
}), this.on("cursor", (
|
|
1120
|
-
switch (
|
|
1178
|
+
const s = Math.max(this.options.findIndex(({ value: e }) => e === t.cursorAt), 0);
|
|
1179
|
+
this.cursor = this.options[s].disabled ? f(s, 1, this.options) : s, this.on("key", (e) => {
|
|
1180
|
+
e === "a" && this.toggleAll(), e === "i" && this.toggleInvert();
|
|
1181
|
+
}), this.on("cursor", (e) => {
|
|
1182
|
+
switch (e) {
|
|
1121
1183
|
case "left":
|
|
1122
1184
|
case "up":
|
|
1123
|
-
this.cursor =
|
|
1185
|
+
this.cursor = f(this.cursor, -1, this.options);
|
|
1124
1186
|
break;
|
|
1125
1187
|
case "down":
|
|
1126
1188
|
case "right":
|
|
1127
|
-
this.cursor =
|
|
1189
|
+
this.cursor = f(this.cursor, 1, this.options);
|
|
1128
1190
|
break;
|
|
1129
1191
|
case "space":
|
|
1130
1192
|
this.toggleValue();
|
|
@@ -1133,7 +1195,7 @@ var it = class extends p {
|
|
|
1133
1195
|
});
|
|
1134
1196
|
}
|
|
1135
1197
|
};
|
|
1136
|
-
class
|
|
1198
|
+
class ut extends m {
|
|
1137
1199
|
options;
|
|
1138
1200
|
cursor = 0;
|
|
1139
1201
|
get _selectedValue() {
|
|
@@ -1144,38 +1206,38 @@ class nt extends p {
|
|
|
1144
1206
|
}
|
|
1145
1207
|
constructor(t) {
|
|
1146
1208
|
super(t, false), this.options = t.options;
|
|
1147
|
-
const
|
|
1148
|
-
this.cursor = this.options[
|
|
1209
|
+
const s = this.options.findIndex(({ value: i }) => i === t.initialValue), e = s === -1 ? 0 : s;
|
|
1210
|
+
this.cursor = this.options[e].disabled ? f(e, 1, this.options) : e, this.changeValue(), this.on("cursor", (i) => {
|
|
1149
1211
|
switch (i) {
|
|
1150
1212
|
case "left":
|
|
1151
1213
|
case "up":
|
|
1152
|
-
this.cursor =
|
|
1214
|
+
this.cursor = f(this.cursor, -1, this.options);
|
|
1153
1215
|
break;
|
|
1154
1216
|
case "down":
|
|
1155
1217
|
case "right":
|
|
1156
|
-
this.cursor =
|
|
1218
|
+
this.cursor = f(this.cursor, 1, this.options);
|
|
1157
1219
|
break;
|
|
1158
1220
|
}
|
|
1159
1221
|
this.changeValue();
|
|
1160
1222
|
});
|
|
1161
1223
|
}
|
|
1162
1224
|
}
|
|
1163
|
-
class
|
|
1225
|
+
class ht extends m {
|
|
1164
1226
|
get userInputWithCursor() {
|
|
1165
1227
|
if (this.state === "submit")
|
|
1166
1228
|
return this.userInput;
|
|
1167
1229
|
const t = this.userInput;
|
|
1168
1230
|
if (this.cursor >= t.length)
|
|
1169
1231
|
return `${this.userInput}\u2588`;
|
|
1170
|
-
const
|
|
1171
|
-
return `${
|
|
1232
|
+
const s = t.slice(0, this.cursor), [e, ...i] = t.slice(this.cursor);
|
|
1233
|
+
return `${s}${v("inverse", e)}${i.join("")}`;
|
|
1172
1234
|
}
|
|
1173
1235
|
get cursor() {
|
|
1174
1236
|
return this._cursor;
|
|
1175
1237
|
}
|
|
1176
1238
|
constructor(t) {
|
|
1177
|
-
super({ ...t, initialUserInput: t.initialUserInput ?? t.initialValue }), this.on("userInput", (
|
|
1178
|
-
this._setValue(
|
|
1239
|
+
super({ ...t, initialUserInput: t.initialUserInput ?? t.initialValue }), this.on("userInput", (s) => {
|
|
1240
|
+
this._setValue(s);
|
|
1179
1241
|
}), this.on("finalize", () => {
|
|
1180
1242
|
this.value || (this.value = t.defaultValue), this.value === undefined && (this.value = "");
|
|
1181
1243
|
});
|
|
@@ -1183,332 +1245,335 @@ class at extends p {
|
|
|
1183
1245
|
}
|
|
1184
1246
|
|
|
1185
1247
|
// node_modules/@clack/prompts/dist/index.mjs
|
|
1186
|
-
import { styleText as
|
|
1187
|
-
import
|
|
1248
|
+
import { styleText as e, stripVTControlCharacters as nt2 } from "util";
|
|
1249
|
+
import V2 from "process";
|
|
1188
1250
|
var import_sisteransi2 = __toESM(require_src(), 1);
|
|
1189
|
-
function
|
|
1190
|
-
return
|
|
1251
|
+
function ee() {
|
|
1252
|
+
return V2.platform !== "win32" ? V2.env.TERM !== "linux" : !!V2.env.CI || !!V2.env.WT_SESSION || !!V2.env.TERMINUS_SUBLIME || V2.env.ConEmuTask === "{cmd::Cmder}" || V2.env.TERM_PROGRAM === "Terminus-Sublime" || V2.env.TERM_PROGRAM === "vscode" || V2.env.TERM === "xterm-256color" || V2.env.TERM === "alacritty" || V2.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
1191
1253
|
}
|
|
1192
|
-
var
|
|
1193
|
-
var
|
|
1194
|
-
var w2 = (
|
|
1195
|
-
var
|
|
1196
|
-
var
|
|
1197
|
-
var
|
|
1198
|
-
var
|
|
1199
|
-
var
|
|
1200
|
-
var
|
|
1201
|
-
var
|
|
1202
|
-
var
|
|
1203
|
-
var
|
|
1254
|
+
var tt2 = ee();
|
|
1255
|
+
var ot2 = () => process.env.CI === "true";
|
|
1256
|
+
var w2 = (t, i) => tt2 ? t : i;
|
|
1257
|
+
var Tt = w2("\u25C6", "*");
|
|
1258
|
+
var at2 = w2("\u25A0", "x");
|
|
1259
|
+
var ut2 = w2("\u25B2", "x");
|
|
1260
|
+
var H2 = w2("\u25C7", "o");
|
|
1261
|
+
var lt = w2("\u250C", "T");
|
|
1262
|
+
var $2 = w2("\u2502", "|");
|
|
1263
|
+
var x2 = w2("\u2514", "\u2014");
|
|
1264
|
+
var _t = w2("\u2510", "T");
|
|
1265
|
+
var xt = w2("\u2518", "\u2014");
|
|
1204
1266
|
var z2 = w2("\u25CF", ">");
|
|
1205
|
-
var
|
|
1206
|
-
var
|
|
1207
|
-
var
|
|
1208
|
-
var
|
|
1209
|
-
var
|
|
1210
|
-
var
|
|
1211
|
-
var
|
|
1212
|
-
var
|
|
1213
|
-
var $
|
|
1214
|
-
var
|
|
1215
|
-
var
|
|
1216
|
-
var
|
|
1217
|
-
var
|
|
1218
|
-
var
|
|
1219
|
-
var
|
|
1220
|
-
var
|
|
1221
|
-
switch (
|
|
1267
|
+
var U2 = w2("\u25CB", " ");
|
|
1268
|
+
var et2 = w2("\u25FB", "[\u2022]");
|
|
1269
|
+
var K2 = w2("\u25FC", "[+]");
|
|
1270
|
+
var Y2 = w2("\u25FB", "[ ]");
|
|
1271
|
+
var Et = w2("\u25AA", "\u2022");
|
|
1272
|
+
var st2 = w2("\u2500", "-");
|
|
1273
|
+
var ct = w2("\u256E", "+");
|
|
1274
|
+
var Gt = w2("\u251C", "+");
|
|
1275
|
+
var $t = w2("\u256F", "+");
|
|
1276
|
+
var dt = w2("\u2570", "+");
|
|
1277
|
+
var Mt = w2("\u256D", "+");
|
|
1278
|
+
var ht2 = w2("\u25CF", "\u2022");
|
|
1279
|
+
var pt = w2("\u25C6", "*");
|
|
1280
|
+
var mt = w2("\u25B2", "!");
|
|
1281
|
+
var gt = w2("\u25A0", "x");
|
|
1282
|
+
var P2 = (t) => {
|
|
1283
|
+
switch (t) {
|
|
1222
1284
|
case "initial":
|
|
1223
1285
|
case "active":
|
|
1224
|
-
return
|
|
1286
|
+
return e("cyan", Tt);
|
|
1225
1287
|
case "cancel":
|
|
1226
|
-
return
|
|
1288
|
+
return e("red", at2);
|
|
1227
1289
|
case "error":
|
|
1228
|
-
return
|
|
1290
|
+
return e("yellow", ut2);
|
|
1229
1291
|
case "submit":
|
|
1230
|
-
return
|
|
1292
|
+
return e("green", H2);
|
|
1231
1293
|
}
|
|
1232
1294
|
};
|
|
1233
|
-
var
|
|
1234
|
-
switch (
|
|
1295
|
+
var yt = (t) => {
|
|
1296
|
+
switch (t) {
|
|
1235
1297
|
case "initial":
|
|
1236
1298
|
case "active":
|
|
1237
|
-
return
|
|
1299
|
+
return e("cyan", $2);
|
|
1238
1300
|
case "cancel":
|
|
1239
|
-
return
|
|
1301
|
+
return e("red", $2);
|
|
1240
1302
|
case "error":
|
|
1241
|
-
return
|
|
1303
|
+
return e("yellow", $2);
|
|
1242
1304
|
case "submit":
|
|
1243
|
-
return
|
|
1305
|
+
return e("green", $2);
|
|
1244
1306
|
}
|
|
1245
1307
|
};
|
|
1246
|
-
var
|
|
1247
|
-
let
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1308
|
+
var Ot = (t, i, s, r, u, n = false) => {
|
|
1309
|
+
let a = i, c = 0;
|
|
1310
|
+
if (n)
|
|
1311
|
+
for (let o = r - 1;o >= s && (a -= t[o].length, c++, !(a <= u)); o--)
|
|
1312
|
+
;
|
|
1313
|
+
else
|
|
1314
|
+
for (let o = s;o < r && (a -= t[o].length, c++, !(a <= u)); o++)
|
|
1315
|
+
;
|
|
1316
|
+
return { lineCount: a, removals: c };
|
|
1254
1317
|
};
|
|
1255
|
-
var
|
|
1256
|
-
const
|
|
1318
|
+
var F2 = ({ cursor: t, options: i, style: s, output: r = process.stdout, maxItems: u = Number.POSITIVE_INFINITY, columnPadding: n = 0, rowPadding: a = 4 }) => {
|
|
1319
|
+
const c = A(r) - n, o = L(r), l = e("dim", "..."), d = Math.max(o - a, 0), g = Math.max(Math.min(u, d), 5);
|
|
1257
1320
|
let p2 = 0;
|
|
1258
|
-
|
|
1259
|
-
let
|
|
1260
|
-
const
|
|
1261
|
-
let
|
|
1262
|
-
|
|
1263
|
-
const
|
|
1264
|
-
for (let
|
|
1265
|
-
const
|
|
1321
|
+
t >= g - 3 && (p2 = Math.max(Math.min(t - g + 3, i.length - g), 0));
|
|
1322
|
+
let f2 = g < i.length && p2 > 0, h2 = g < i.length && p2 + g < i.length;
|
|
1323
|
+
const I2 = Math.min(p2 + g, i.length), m2 = [];
|
|
1324
|
+
let y = 0;
|
|
1325
|
+
f2 && y++, h2 && y++;
|
|
1326
|
+
const v2 = p2 + (f2 ? 1 : 0), C2 = I2 - (h2 ? 1 : 0);
|
|
1327
|
+
for (let b2 = v2;b2 < C2; b2++) {
|
|
1328
|
+
const G2 = wrapAnsi(s(i[b2], b2 === t), c, { hard: true, trim: false }).split(`
|
|
1266
1329
|
`);
|
|
1267
|
-
|
|
1268
|
-
}
|
|
1269
|
-
if (
|
|
1270
|
-
let
|
|
1271
|
-
const
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1330
|
+
m2.push(G2), y += G2.length;
|
|
1331
|
+
}
|
|
1332
|
+
if (y > d) {
|
|
1333
|
+
let b2 = 0, G2 = 0, M = y;
|
|
1334
|
+
const N2 = t - v2;
|
|
1335
|
+
let O2 = d;
|
|
1336
|
+
const j2 = () => Ot(m2, M, 0, N2, O2), k2 = () => Ot(m2, M, N2 + 1, m2.length, O2, true);
|
|
1337
|
+
f2 ? ({ lineCount: M, removals: b2 } = j2(), M > O2 && (h2 || (O2 -= 1), { lineCount: M, removals: G2 } = k2())) : (h2 || (O2 -= 1), { lineCount: M, removals: G2 } = k2(), M > O2 && (O2 -= 1, { lineCount: M, removals: b2 } = j2())), b2 > 0 && (f2 = true, m2.splice(0, b2)), G2 > 0 && (h2 = true, m2.splice(m2.length - G2, G2));
|
|
1338
|
+
}
|
|
1339
|
+
const S2 = [];
|
|
1340
|
+
f2 && S2.push(l);
|
|
1341
|
+
for (const b2 of m2)
|
|
1342
|
+
for (const G2 of b2)
|
|
1343
|
+
S2.push(G2);
|
|
1344
|
+
return h2 && S2.push(l), S2;
|
|
1280
1345
|
};
|
|
1281
|
-
var
|
|
1282
|
-
const i =
|
|
1283
|
-
return new
|
|
1284
|
-
const r =
|
|
1285
|
-
` : ""}${
|
|
1286
|
-
`,
|
|
1346
|
+
var ue = (t) => {
|
|
1347
|
+
const i = t.active ?? "Yes", s = t.inactive ?? "No";
|
|
1348
|
+
return new X2({ active: i, inactive: s, signal: t.signal, input: t.input, output: t.output, initialValue: t.initialValue ?? true, render() {
|
|
1349
|
+
const r = t.withGuide ?? h.withGuide, u = `${P2(this.state)} `, n = r ? `${e("gray", $2)} ` : "", a = W(t.output, t.message, n, u), c = `${r ? `${e("gray", $2)}
|
|
1350
|
+
` : ""}${a}
|
|
1351
|
+
`, o = this.value ? i : s;
|
|
1287
1352
|
switch (this.state) {
|
|
1288
1353
|
case "submit": {
|
|
1289
|
-
const l = r ? `${
|
|
1290
|
-
return `${
|
|
1354
|
+
const l = r ? `${e("gray", $2)} ` : "";
|
|
1355
|
+
return `${c}${l}${e("dim", o)}`;
|
|
1291
1356
|
}
|
|
1292
1357
|
case "cancel": {
|
|
1293
|
-
const l = r ? `${
|
|
1294
|
-
return `${
|
|
1295
|
-
${
|
|
1358
|
+
const l = r ? `${e("gray", $2)} ` : "";
|
|
1359
|
+
return `${c}${l}${e(["strikethrough", "dim"], o)}${r ? `
|
|
1360
|
+
${e("gray", $2)}` : ""}`;
|
|
1296
1361
|
}
|
|
1297
1362
|
default: {
|
|
1298
|
-
const l = r ? `${
|
|
1299
|
-
return `${
|
|
1300
|
-
${
|
|
1301
|
-
` : ` ${
|
|
1302
|
-
${
|
|
1363
|
+
const l = r ? `${e("cyan", $2)} ` : "", d = r ? e("cyan", x2) : "";
|
|
1364
|
+
return `${c}${l}${this.value ? `${e("green", z2)} ${i}` : `${e("dim", U2)} ${e("dim", i)}`}${t.vertical ? r ? `
|
|
1365
|
+
${e("cyan", $2)} ` : `
|
|
1366
|
+
` : ` ${e("dim", "/")} `}${this.value ? `${e("dim", U2)} ${e("dim", s)}` : `${e("green", z2)} ${s}`}
|
|
1367
|
+
${d}
|
|
1303
1368
|
`;
|
|
1304
1369
|
}
|
|
1305
1370
|
}
|
|
1306
1371
|
} }).prompt();
|
|
1307
1372
|
};
|
|
1308
|
-
var
|
|
1309
|
-
const s = i?.output ?? process.stdout, r = i?.withGuide ??
|
|
1310
|
-
s.write(`${r}${
|
|
1373
|
+
var me = (t = "", i) => {
|
|
1374
|
+
const s = i?.output ?? process.stdout, r = i?.withGuide ?? h.withGuide ? `${e("gray", x2)} ` : "";
|
|
1375
|
+
s.write(`${r}${e("red", t)}
|
|
1311
1376
|
|
|
1312
1377
|
`);
|
|
1313
1378
|
};
|
|
1314
|
-
var
|
|
1315
|
-
const s = i?.output ?? process.stdout, r = i?.withGuide ??
|
|
1316
|
-
s.write(`${r}${
|
|
1379
|
+
var ge = (t = "", i) => {
|
|
1380
|
+
const s = i?.output ?? process.stdout, r = i?.withGuide ?? h.withGuide ? `${e("gray", lt)} ` : "";
|
|
1381
|
+
s.write(`${r}${t}
|
|
1317
1382
|
`);
|
|
1318
1383
|
};
|
|
1319
|
-
var
|
|
1320
|
-
const s = i?.output ?? process.stdout, r = i?.withGuide ??
|
|
1321
|
-
${
|
|
1322
|
-
s.write(`${r}${
|
|
1384
|
+
var ye = (t = "", i) => {
|
|
1385
|
+
const s = i?.output ?? process.stdout, r = i?.withGuide ?? h.withGuide ? `${e("gray", $2)}
|
|
1386
|
+
${e("gray", x2)} ` : "";
|
|
1387
|
+
s.write(`${r}${t}
|
|
1323
1388
|
|
|
1324
1389
|
`);
|
|
1325
1390
|
};
|
|
1326
|
-
var Q2 = (
|
|
1391
|
+
var Q2 = (t, i) => t.split(`
|
|
1327
1392
|
`).map((s) => i(s)).join(`
|
|
1328
1393
|
`);
|
|
1329
|
-
var
|
|
1330
|
-
const i = (r,
|
|
1394
|
+
var ve = (t) => {
|
|
1395
|
+
const i = (r, u) => {
|
|
1331
1396
|
const n = r.label ?? String(r.value);
|
|
1332
|
-
return
|
|
1333
|
-
}, s =
|
|
1334
|
-
return new
|
|
1397
|
+
return u === "disabled" ? `${e("gray", Y2)} ${Q2(n, (a) => e(["strikethrough", "gray"], a))}${r.hint ? ` ${e("dim", `(${r.hint ?? "disabled"})`)}` : ""}` : u === "active" ? `${e("cyan", et2)} ${n}${r.hint ? ` ${e("dim", `(${r.hint})`)}` : ""}` : u === "selected" ? `${e("green", K2)} ${Q2(n, (a) => e("dim", a))}${r.hint ? ` ${e("dim", `(${r.hint})`)}` : ""}` : u === "cancelled" ? `${Q2(n, (a) => e(["strikethrough", "dim"], a))}` : u === "active-selected" ? `${e("green", K2)} ${n}${r.hint ? ` ${e("dim", `(${r.hint})`)}` : ""}` : u === "submitted" ? `${Q2(n, (a) => e("dim", a))}` : `${e("dim", Y2)} ${Q2(n, (a) => e("dim", a))}`;
|
|
1398
|
+
}, s = t.required ?? true;
|
|
1399
|
+
return new nt({ options: t.options, signal: t.signal, input: t.input, output: t.output, initialValues: t.initialValues, required: s, cursorAt: t.cursorAt, validate(r) {
|
|
1335
1400
|
if (s && (r === undefined || r.length === 0))
|
|
1336
1401
|
return `Please select at least one option.
|
|
1337
|
-
${
|
|
1402
|
+
${e("reset", e("dim", `Press ${e(["gray", "bgWhite", "inverse"], " space ")} to select, ${e("gray", e("bgWhite", e("inverse", " enter ")))} to submit`))}`;
|
|
1338
1403
|
}, render() {
|
|
1339
|
-
const r =
|
|
1340
|
-
` : ""}${
|
|
1341
|
-
`,
|
|
1342
|
-
if (
|
|
1343
|
-
return i(
|
|
1344
|
-
const
|
|
1345
|
-
return l &&
|
|
1404
|
+
const r = t.withGuide ?? h.withGuide, u = W(t.output, t.message, r ? `${yt(this.state)} ` : "", `${P2(this.state)} `), n = `${r ? `${e("gray", $2)}
|
|
1405
|
+
` : ""}${u}
|
|
1406
|
+
`, a = this.value ?? [], c = (o, l) => {
|
|
1407
|
+
if (o.disabled)
|
|
1408
|
+
return i(o, "disabled");
|
|
1409
|
+
const d = a.includes(o.value);
|
|
1410
|
+
return l && d ? i(o, "active-selected") : d ? i(o, "selected") : i(o, l ? "active" : "inactive");
|
|
1346
1411
|
};
|
|
1347
1412
|
switch (this.state) {
|
|
1348
1413
|
case "submit": {
|
|
1349
|
-
const
|
|
1414
|
+
const o = this.options.filter(({ value: d }) => a.includes(d)).map((d) => i(d, "submitted")).join(e("dim", ", ")) || e("dim", "none"), l = W(t.output, o, r ? `${e("gray", $2)} ` : "");
|
|
1350
1415
|
return `${n}${l}`;
|
|
1351
1416
|
}
|
|
1352
1417
|
case "cancel": {
|
|
1353
|
-
const
|
|
1354
|
-
if (
|
|
1355
|
-
return `${n}${
|
|
1356
|
-
const l =
|
|
1418
|
+
const o = this.options.filter(({ value: d }) => a.includes(d)).map((d) => i(d, "cancelled")).join(e("dim", ", "));
|
|
1419
|
+
if (o.trim() === "")
|
|
1420
|
+
return `${n}${e("gray", $2)}`;
|
|
1421
|
+
const l = W(t.output, o, r ? `${e("gray", $2)} ` : "");
|
|
1357
1422
|
return `${n}${l}${r ? `
|
|
1358
|
-
${
|
|
1423
|
+
${e("gray", $2)}` : ""}`;
|
|
1359
1424
|
}
|
|
1360
1425
|
case "error": {
|
|
1361
|
-
const
|
|
1362
|
-
`).map((p2,
|
|
1363
|
-
`),
|
|
1364
|
-
`).length,
|
|
1426
|
+
const o = r ? `${e("yellow", $2)} ` : "", l = this.error.split(`
|
|
1427
|
+
`).map((p2, f2) => f2 === 0 ? `${r ? `${e("yellow", x2)} ` : ""}${e("yellow", p2)}` : ` ${p2}`).join(`
|
|
1428
|
+
`), d = n.split(`
|
|
1429
|
+
`).length, g = l.split(`
|
|
1365
1430
|
`).length + 1;
|
|
1366
|
-
return `${n}${
|
|
1367
|
-
${
|
|
1431
|
+
return `${n}${o}${F2({ output: t.output, options: this.options, cursor: this.cursor, maxItems: t.maxItems, columnPadding: o.length, rowPadding: d + g, style: c }).join(`
|
|
1432
|
+
${o}`)}
|
|
1368
1433
|
${l}
|
|
1369
1434
|
`;
|
|
1370
1435
|
}
|
|
1371
1436
|
default: {
|
|
1372
|
-
const
|
|
1373
|
-
`).length,
|
|
1374
|
-
return `${n}${
|
|
1375
|
-
${
|
|
1376
|
-
${r ?
|
|
1437
|
+
const o = r ? `${e("cyan", $2)} ` : "", l = n.split(`
|
|
1438
|
+
`).length, d = r ? 2 : 1;
|
|
1439
|
+
return `${n}${o}${F2({ output: t.output, options: this.options, cursor: this.cursor, maxItems: t.maxItems, columnPadding: o.length, rowPadding: l + d, style: c }).join(`
|
|
1440
|
+
${o}`)}
|
|
1441
|
+
${r ? e("cyan", x2) : ""}
|
|
1377
1442
|
`;
|
|
1378
1443
|
}
|
|
1379
1444
|
}
|
|
1380
1445
|
} }).prompt();
|
|
1381
1446
|
};
|
|
1382
|
-
var
|
|
1383
|
-
var
|
|
1384
|
-
const l =
|
|
1385
|
-
let
|
|
1386
|
-
const
|
|
1387
|
-
const A2 =
|
|
1388
|
-
|
|
1389
|
-
},
|
|
1390
|
-
process.on("uncaughtExceptionMonitor",
|
|
1391
|
-
},
|
|
1392
|
-
process.removeListener("uncaughtExceptionMonitor",
|
|
1393
|
-
},
|
|
1394
|
-
if (
|
|
1447
|
+
var Te = (t) => e("magenta", t);
|
|
1448
|
+
var ft = ({ indicator: t = "dots", onCancel: i, output: s = process.stdout, cancelMessage: r, errorMessage: u, frames: n = tt2 ? ["\u25D2", "\u25D0", "\u25D3", "\u25D1"] : ["\u2022", "o", "O", "0"], delay: a = tt2 ? 80 : 120, signal: c, ...o } = {}) => {
|
|
1449
|
+
const l = ot2();
|
|
1450
|
+
let d, g, p2 = false, f2 = false, h2 = "", I2, m2 = performance.now();
|
|
1451
|
+
const y = A(s), v2 = o?.styleFrame ?? Te, C2 = (_) => {
|
|
1452
|
+
const A2 = _ > 1 ? u ?? h.messages.error : r ?? h.messages.cancel;
|
|
1453
|
+
f2 = _ === 1, p2 && (W2(A2, _), f2 && typeof i == "function" && i());
|
|
1454
|
+
}, S2 = () => C2(2), b2 = () => C2(1), G2 = () => {
|
|
1455
|
+
process.on("uncaughtExceptionMonitor", S2), process.on("unhandledRejection", S2), process.on("SIGINT", b2), process.on("SIGTERM", b2), process.on("exit", C2), c && c.addEventListener("abort", b2);
|
|
1456
|
+
}, M = () => {
|
|
1457
|
+
process.removeListener("uncaughtExceptionMonitor", S2), process.removeListener("unhandledRejection", S2), process.removeListener("SIGINT", b2), process.removeListener("SIGTERM", b2), process.removeListener("exit", C2), c && c.removeEventListener("abort", b2);
|
|
1458
|
+
}, N2 = () => {
|
|
1459
|
+
if (I2 === undefined)
|
|
1395
1460
|
return;
|
|
1396
1461
|
l && s.write(`
|
|
1397
1462
|
`);
|
|
1398
|
-
const
|
|
1463
|
+
const _ = wrapAnsi(I2, y, { hard: true, trim: false }).split(`
|
|
1399
1464
|
`);
|
|
1400
|
-
|
|
1401
|
-
},
|
|
1402
|
-
const A2 = (performance.now() -
|
|
1403
|
-
return
|
|
1404
|
-
},
|
|
1405
|
-
p2 = true,
|
|
1465
|
+
_.length > 1 && s.write(import_sisteransi2.cursor.up(_.length - 1)), s.write(import_sisteransi2.cursor.to(0)), s.write(import_sisteransi2.erase.down());
|
|
1466
|
+
}, O2 = (_) => _.replace(/\.+$/, ""), j2 = (_) => {
|
|
1467
|
+
const A2 = (performance.now() - _) / 1000, L2 = Math.floor(A2 / 60), D2 = Math.floor(A2 % 60);
|
|
1468
|
+
return L2 > 0 ? `[${L2}m ${D2}s]` : `[${D2}s]`;
|
|
1469
|
+
}, k2 = o.withGuide ?? h.withGuide, rt2 = (_ = "") => {
|
|
1470
|
+
p2 = true, d = R({ output: s }), h2 = O2(_), m2 = performance.now(), k2 && s.write(`${e("gray", $2)}
|
|
1406
1471
|
`);
|
|
1407
|
-
let A2 = 0,
|
|
1408
|
-
|
|
1409
|
-
if (l &&
|
|
1472
|
+
let A2 = 0, L2 = 0;
|
|
1473
|
+
G2(), g = setInterval(() => {
|
|
1474
|
+
if (l && h2 === I2)
|
|
1410
1475
|
return;
|
|
1411
|
-
|
|
1412
|
-
const
|
|
1476
|
+
N2(), I2 = h2;
|
|
1477
|
+
const D2 = v2(n[A2]);
|
|
1413
1478
|
let Z2;
|
|
1414
1479
|
if (l)
|
|
1415
|
-
Z2 = `${
|
|
1416
|
-
else if (
|
|
1417
|
-
Z2 = `${
|
|
1480
|
+
Z2 = `${D2} ${h2}...`;
|
|
1481
|
+
else if (t === "timer")
|
|
1482
|
+
Z2 = `${D2} ${h2} ${j2(m2)}`;
|
|
1418
1483
|
else {
|
|
1419
|
-
const
|
|
1420
|
-
Z2 = `${
|
|
1484
|
+
const kt = ".".repeat(Math.floor(L2)).slice(0, 3);
|
|
1485
|
+
Z2 = `${D2} ${h2}${kt}`;
|
|
1421
1486
|
}
|
|
1422
|
-
const
|
|
1423
|
-
s.write(
|
|
1424
|
-
},
|
|
1425
|
-
}, W2 = (
|
|
1487
|
+
const Bt = wrapAnsi(Z2, y, { hard: true, trim: false });
|
|
1488
|
+
s.write(Bt), A2 = A2 + 1 < n.length ? A2 + 1 : 0, L2 = L2 < 4 ? L2 + 0.125 : 0;
|
|
1489
|
+
}, a);
|
|
1490
|
+
}, W2 = (_ = "", A2 = 0, L2 = false) => {
|
|
1426
1491
|
if (!p2)
|
|
1427
1492
|
return;
|
|
1428
|
-
p2 = false, clearInterval(
|
|
1429
|
-
const
|
|
1430
|
-
|
|
1431
|
-
`) : s.write(`${
|
|
1432
|
-
`)),
|
|
1493
|
+
p2 = false, clearInterval(g), N2();
|
|
1494
|
+
const D2 = A2 === 0 ? e("green", H2) : A2 === 1 ? e("red", at2) : e("red", ut2);
|
|
1495
|
+
h2 = _ ?? h2, L2 || (t === "timer" ? s.write(`${D2} ${h2} ${j2(m2)}
|
|
1496
|
+
`) : s.write(`${D2} ${h2}
|
|
1497
|
+
`)), M(), d();
|
|
1433
1498
|
};
|
|
1434
|
-
return { start:
|
|
1435
|
-
|
|
1436
|
-
}, cancel: (
|
|
1437
|
-
return
|
|
1499
|
+
return { start: rt2, stop: (_ = "") => W2(_, 0), message: (_ = "") => {
|
|
1500
|
+
h2 = O2(_ ?? h2);
|
|
1501
|
+
}, cancel: (_ = "") => W2(_, 1), error: (_ = "") => W2(_, 2), clear: () => W2("", 0, true), get isCancelled() {
|
|
1502
|
+
return f2;
|
|
1438
1503
|
} };
|
|
1439
1504
|
};
|
|
1440
|
-
var
|
|
1441
|
-
var
|
|
1442
|
-
`) ?
|
|
1505
|
+
var jt = { light: w2("\u2500", "-"), heavy: w2("\u2501", "="), block: w2("\u2588", "#") };
|
|
1506
|
+
var it2 = (t, i) => t.includes(`
|
|
1507
|
+
`) ? t.split(`
|
|
1443
1508
|
`).map((s) => i(s)).join(`
|
|
1444
|
-
`) : i(
|
|
1445
|
-
var
|
|
1509
|
+
`) : i(t);
|
|
1510
|
+
var xe = (t) => {
|
|
1446
1511
|
const i = (s, r) => {
|
|
1447
|
-
const
|
|
1512
|
+
const u = s.label ?? String(s.value);
|
|
1448
1513
|
switch (r) {
|
|
1449
1514
|
case "disabled":
|
|
1450
|
-
return `${
|
|
1515
|
+
return `${e("gray", U2)} ${it2(u, (n) => e("gray", n))}${s.hint ? ` ${e("dim", `(${s.hint ?? "disabled"})`)}` : ""}`;
|
|
1451
1516
|
case "selected":
|
|
1452
|
-
return `${
|
|
1517
|
+
return `${it2(u, (n) => e("dim", n))}`;
|
|
1453
1518
|
case "active":
|
|
1454
|
-
return `${
|
|
1519
|
+
return `${e("green", z2)} ${u}${s.hint ? ` ${e("dim", `(${s.hint})`)}` : ""}`;
|
|
1455
1520
|
case "cancelled":
|
|
1456
|
-
return `${
|
|
1521
|
+
return `${it2(u, (n) => e(["strikethrough", "dim"], n))}`;
|
|
1457
1522
|
default:
|
|
1458
|
-
return `${
|
|
1523
|
+
return `${e("dim", U2)} ${it2(u, (n) => e("dim", n))}`;
|
|
1459
1524
|
}
|
|
1460
1525
|
};
|
|
1461
|
-
return new
|
|
1462
|
-
const s =
|
|
1526
|
+
return new ut({ options: t.options, signal: t.signal, input: t.input, output: t.output, initialValue: t.initialValue, render() {
|
|
1527
|
+
const s = t.withGuide ?? h.withGuide, r = `${P2(this.state)} `, u = `${yt(this.state)} `, n = W(t.output, t.message, u, r), a = `${s ? `${e("gray", $2)}
|
|
1463
1528
|
` : ""}${n}
|
|
1464
1529
|
`;
|
|
1465
1530
|
switch (this.state) {
|
|
1466
1531
|
case "submit": {
|
|
1467
|
-
const
|
|
1468
|
-
return `${
|
|
1532
|
+
const c = s ? `${e("gray", $2)} ` : "", o = W(t.output, i(this.options[this.cursor], "selected"), c);
|
|
1533
|
+
return `${a}${o}`;
|
|
1469
1534
|
}
|
|
1470
1535
|
case "cancel": {
|
|
1471
|
-
const
|
|
1472
|
-
return `${
|
|
1473
|
-
${
|
|
1536
|
+
const c = s ? `${e("gray", $2)} ` : "", o = W(t.output, i(this.options[this.cursor], "cancelled"), c);
|
|
1537
|
+
return `${a}${o}${s ? `
|
|
1538
|
+
${e("gray", $2)}` : ""}`;
|
|
1474
1539
|
}
|
|
1475
1540
|
default: {
|
|
1476
|
-
const
|
|
1477
|
-
`).length,
|
|
1478
|
-
return `${
|
|
1479
|
-
${
|
|
1480
|
-
${
|
|
1541
|
+
const c = s ? `${e("cyan", $2)} ` : "", o = s ? e("cyan", x2) : "", l = a.split(`
|
|
1542
|
+
`).length, d = s ? 2 : 1;
|
|
1543
|
+
return `${a}${c}${F2({ output: t.output, cursor: this.cursor, options: this.options, maxItems: t.maxItems, columnPadding: c.length, rowPadding: l + d, style: (g, p2) => i(g, g.disabled ? "disabled" : p2 ? "active" : "inactive") }).join(`
|
|
1544
|
+
${c}`)}
|
|
1545
|
+
${o}
|
|
1481
1546
|
`;
|
|
1482
1547
|
}
|
|
1483
1548
|
}
|
|
1484
1549
|
} }).prompt();
|
|
1485
1550
|
};
|
|
1486
|
-
var
|
|
1487
|
-
var
|
|
1488
|
-
const i =
|
|
1489
|
-
` : ""}${
|
|
1490
|
-
`, r =
|
|
1551
|
+
var Nt = `${e("gray", $2)} `;
|
|
1552
|
+
var Pe = (t) => new ht({ validate: t.validate, placeholder: t.placeholder, defaultValue: t.defaultValue, initialValue: t.initialValue, output: t.output, signal: t.signal, input: t.input, render() {
|
|
1553
|
+
const i = t?.withGuide ?? h.withGuide, s = `${`${i ? `${e("gray", $2)}
|
|
1554
|
+
` : ""}${P2(this.state)} `}${t.message}
|
|
1555
|
+
`, r = t.placeholder ? e("inverse", t.placeholder[0]) + e("dim", t.placeholder.slice(1)) : e(["inverse", "hidden"], "_"), u = this.userInput ? this.userInputWithCursor : r, n = this.value ?? "";
|
|
1491
1556
|
switch (this.state) {
|
|
1492
1557
|
case "error": {
|
|
1493
|
-
const
|
|
1558
|
+
const a = this.error ? ` ${e("yellow", this.error)}` : "", c = i ? `${e("yellow", $2)} ` : "", o = i ? e("yellow", x2) : "";
|
|
1494
1559
|
return `${s.trim()}
|
|
1495
|
-
${
|
|
1496
|
-
${
|
|
1560
|
+
${c}${u}
|
|
1561
|
+
${o}${a}
|
|
1497
1562
|
`;
|
|
1498
1563
|
}
|
|
1499
1564
|
case "submit": {
|
|
1500
|
-
const
|
|
1501
|
-
return `${s}${
|
|
1565
|
+
const a = n ? ` ${e("dim", n)}` : "", c = i ? e("gray", $2) : "";
|
|
1566
|
+
return `${s}${c}${a}`;
|
|
1502
1567
|
}
|
|
1503
1568
|
case "cancel": {
|
|
1504
|
-
const
|
|
1505
|
-
return `${s}${
|
|
1506
|
-
${
|
|
1569
|
+
const a = n ? ` ${e(["strikethrough", "dim"], n)}` : "", c = i ? e("gray", $2) : "";
|
|
1570
|
+
return `${s}${c}${a}${n.trim() ? `
|
|
1571
|
+
${c}` : ""}`;
|
|
1507
1572
|
}
|
|
1508
1573
|
default: {
|
|
1509
|
-
const
|
|
1510
|
-
return `${s}${
|
|
1511
|
-
${
|
|
1574
|
+
const a = i ? `${e("cyan", $2)} ` : "", c = i ? e("cyan", x2) : "";
|
|
1575
|
+
return `${s}${a}${u}
|
|
1576
|
+
${c}
|
|
1512
1577
|
`;
|
|
1513
1578
|
}
|
|
1514
1579
|
}
|
|
@@ -1519,13 +1584,13 @@ async function MultiSelect({
|
|
|
1519
1584
|
message,
|
|
1520
1585
|
options
|
|
1521
1586
|
}) {
|
|
1522
|
-
const selected = await
|
|
1587
|
+
const selected = await ve({
|
|
1523
1588
|
message,
|
|
1524
1589
|
options,
|
|
1525
1590
|
required: true
|
|
1526
1591
|
});
|
|
1527
1592
|
if (q(selected)) {
|
|
1528
|
-
|
|
1593
|
+
me("Operation cancelled.");
|
|
1529
1594
|
process.exit(0);
|
|
1530
1595
|
}
|
|
1531
1596
|
return selected;
|
|
@@ -1546,9 +1611,7 @@ class AddCommand {
|
|
|
1546
1611
|
console.log(`${CHECK({ text: "All changes are either staged or sensitive (like .env)." })}`);
|
|
1547
1612
|
return;
|
|
1548
1613
|
}
|
|
1549
|
-
const options =
|
|
1550
|
-
...changes.map((c2) => ({ value: c2.value, label: c2.label }))
|
|
1551
|
-
];
|
|
1614
|
+
const options = changes.map((c) => ({ value: c.value, label: c.label }));
|
|
1552
1615
|
const selectedChanges = await MultiSelect({
|
|
1553
1616
|
message: `Select the changes you want to commit.
|
|
1554
1617
|
` + BLUE({ text: "[space] to select" }) + `
|
|
@@ -1560,7 +1623,7 @@ class AddCommand {
|
|
|
1560
1623
|
});
|
|
1561
1624
|
let selected = selectedChanges.map((file) => file.trim());
|
|
1562
1625
|
if (selected.includes("all")) {
|
|
1563
|
-
selected = changes.map((
|
|
1626
|
+
selected = changes.map((c) => c.value);
|
|
1564
1627
|
}
|
|
1565
1628
|
if (selected.length > 0) {
|
|
1566
1629
|
await this.stageChangesUseCase.execute(selected);
|
|
@@ -1687,11 +1750,11 @@ class StageChangesUseCase {
|
|
|
1687
1750
|
}
|
|
1688
1751
|
|
|
1689
1752
|
// apps/cli/modules/add/infra/bun-git.repository.ts
|
|
1690
|
-
var {$: $
|
|
1753
|
+
var {$: $3 } = globalThis.Bun;
|
|
1691
1754
|
class BunGitRepository {
|
|
1692
1755
|
async getEntries() {
|
|
1693
1756
|
try {
|
|
1694
|
-
const output = await $
|
|
1757
|
+
const output = await $3`git status --porcelain -z`.quiet().text();
|
|
1695
1758
|
if (!output.trim()) {
|
|
1696
1759
|
return [];
|
|
1697
1760
|
}
|
|
@@ -1718,8 +1781,8 @@ async function addCommand() {
|
|
|
1718
1781
|
const gitRepository = new BunGitRepository;
|
|
1719
1782
|
const getChangesUseCase = new GetChangesUseCase(gitRepository);
|
|
1720
1783
|
const stageChangesUseCase = new StageChangesUseCase(gitRepository);
|
|
1721
|
-
const
|
|
1722
|
-
await
|
|
1784
|
+
const addCmd = new AddCommand(getChangesUseCase, stageChangesUseCase);
|
|
1785
|
+
await addCmd.execute();
|
|
1723
1786
|
}
|
|
1724
1787
|
|
|
1725
1788
|
// apps/cli/alias.ts
|
|
@@ -1828,7 +1891,7 @@ async function Input({
|
|
|
1828
1891
|
message,
|
|
1829
1892
|
placeholder
|
|
1830
1893
|
}) {
|
|
1831
|
-
const value = await
|
|
1894
|
+
const value = await Pe({
|
|
1832
1895
|
message,
|
|
1833
1896
|
placeholder,
|
|
1834
1897
|
validate(input) {
|
|
@@ -1838,7 +1901,7 @@ async function Input({
|
|
|
1838
1901
|
}
|
|
1839
1902
|
});
|
|
1840
1903
|
if (q(value)) {
|
|
1841
|
-
|
|
1904
|
+
me("Operation cancelled.");
|
|
1842
1905
|
process.exit(0);
|
|
1843
1906
|
}
|
|
1844
1907
|
return value.trim();
|
|
@@ -1849,12 +1912,12 @@ async function Select({
|
|
|
1849
1912
|
message,
|
|
1850
1913
|
options
|
|
1851
1914
|
}) {
|
|
1852
|
-
const selected = await
|
|
1915
|
+
const selected = await xe({
|
|
1853
1916
|
message,
|
|
1854
1917
|
options
|
|
1855
1918
|
});
|
|
1856
1919
|
if (q(selected)) {
|
|
1857
|
-
|
|
1920
|
+
me("Operation cancelled.");
|
|
1858
1921
|
process.exit(0);
|
|
1859
1922
|
}
|
|
1860
1923
|
return selected;
|
|
@@ -1902,8 +1965,8 @@ class BunCommitRepository {
|
|
|
1902
1965
|
async function commitCommand() {
|
|
1903
1966
|
const commitRepository = new BunCommitRepository;
|
|
1904
1967
|
const commitUseCase = new CommitUseCase(commitRepository);
|
|
1905
|
-
const
|
|
1906
|
-
await
|
|
1968
|
+
const commitCmd = new CommitCommand(commitUseCase);
|
|
1969
|
+
await commitCmd.execute();
|
|
1907
1970
|
}
|
|
1908
1971
|
|
|
1909
1972
|
// apps/cli/modules/setup/app/setup-aliases.use-case.ts
|
|
@@ -1931,12 +1994,12 @@ async function Confirm({
|
|
|
1931
1994
|
cancelMessage,
|
|
1932
1995
|
exitOnCancel = true
|
|
1933
1996
|
}) {
|
|
1934
|
-
const confirmed = await
|
|
1997
|
+
const confirmed = await ue({
|
|
1935
1998
|
message
|
|
1936
1999
|
});
|
|
1937
2000
|
if (q(confirmed)) {
|
|
1938
2001
|
if (exitOnCancel) {
|
|
1939
|
-
|
|
2002
|
+
me(cancelMessage ?? "Operation cancelled.");
|
|
1940
2003
|
process.exit(0);
|
|
1941
2004
|
}
|
|
1942
2005
|
return null;
|
|
@@ -1946,17 +2009,17 @@ async function Confirm({
|
|
|
1946
2009
|
|
|
1947
2010
|
// apps/cli/utils/intro.ts
|
|
1948
2011
|
function Intro(message) {
|
|
1949
|
-
|
|
2012
|
+
ge(message);
|
|
1950
2013
|
}
|
|
1951
2014
|
|
|
1952
2015
|
// apps/cli/utils/outro.ts
|
|
1953
2016
|
function Outro(message) {
|
|
1954
|
-
|
|
2017
|
+
ye(message);
|
|
1955
2018
|
}
|
|
1956
2019
|
|
|
1957
2020
|
// apps/cli/utils/spinner.ts
|
|
1958
2021
|
function Spinner() {
|
|
1959
|
-
return
|
|
2022
|
+
return ft();
|
|
1960
2023
|
}
|
|
1961
2024
|
|
|
1962
2025
|
// apps/cli/modules/setup/app/setup-command.ts
|
|
@@ -2116,8 +2179,8 @@ class BunAliasRepository {
|
|
|
2116
2179
|
async function setupCommand() {
|
|
2117
2180
|
const aliasRepository = new BunAliasRepository;
|
|
2118
2181
|
const setupAliasesUseCase = new SetupAliasesUseCase(aliasRepository);
|
|
2119
|
-
const
|
|
2120
|
-
await
|
|
2182
|
+
const setupCmd = new SetupCommand(setupAliasesUseCase);
|
|
2183
|
+
await setupCmd.execute();
|
|
2121
2184
|
}
|
|
2122
2185
|
|
|
2123
2186
|
// apps/cli/modules/switch/domain/branch.ts
|
|
@@ -2226,11 +2289,11 @@ class SwitchCommand {
|
|
|
2226
2289
|
}
|
|
2227
2290
|
|
|
2228
2291
|
// apps/cli/modules/switch/infra/bun-switch-repository.ts
|
|
2229
|
-
var {$: $
|
|
2292
|
+
var {$: $4 } = globalThis.Bun;
|
|
2230
2293
|
class BunSwitchRepository {
|
|
2231
2294
|
async getBranches() {
|
|
2232
2295
|
try {
|
|
2233
|
-
const output = await $
|
|
2296
|
+
const output = await $4`git branch -a`.quiet().text();
|
|
2234
2297
|
if (!output.trim()) {
|
|
2235
2298
|
return [];
|
|
2236
2299
|
}
|
|
@@ -2256,8 +2319,8 @@ async function switchCommand() {
|
|
|
2256
2319
|
const switchRepo = new BunSwitchRepository;
|
|
2257
2320
|
const switchBranchUseCase = new SwitchBranch(switchRepo);
|
|
2258
2321
|
const getBranchesUseCase = new GetBranchesUseCase(switchRepo);
|
|
2259
|
-
const
|
|
2260
|
-
await
|
|
2322
|
+
const switchCmd = new SwitchCommand(getBranchesUseCase, switchBranchUseCase);
|
|
2323
|
+
await switchCmd.execute();
|
|
2261
2324
|
}
|
|
2262
2325
|
|
|
2263
2326
|
// apps/cli/commands-fn.ts
|
|
@@ -2271,7 +2334,7 @@ var COMMANDS_FN = {
|
|
|
2271
2334
|
|
|
2272
2335
|
// apps/cli/index.ts
|
|
2273
2336
|
var args = Bun.argv.slice(2);
|
|
2274
|
-
var command = AVAILABLE_COMMANDS.find((
|
|
2337
|
+
var command = AVAILABLE_COMMANDS.find((cmd) => cmd.name === args[0]);
|
|
2275
2338
|
if (command && args.length === 1) {
|
|
2276
2339
|
await COMMANDS_FN[command.name]?.(args.slice(1));
|
|
2277
2340
|
} else {
|