@jannael/glinter 1.2.1 → 1.2.3
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 +93 -80
- package/dist/index.js +652 -598
- package/package.json +27 -14
package/dist/index.js
CHANGED
|
@@ -95,38 +95,33 @@ var AVAILABLE_COMMANDS = [
|
|
|
95
95
|
{
|
|
96
96
|
name: "add",
|
|
97
97
|
command: "g add",
|
|
98
|
-
description: "Interactive add"
|
|
99
|
-
allowGitArgs: true
|
|
98
|
+
description: "Interactive add"
|
|
100
99
|
},
|
|
101
100
|
{
|
|
102
101
|
name: "commit",
|
|
103
102
|
command: "g commit",
|
|
104
|
-
description: "Interactive commit"
|
|
105
|
-
allowGitArgs: true
|
|
103
|
+
description: "Interactive commit"
|
|
106
104
|
},
|
|
107
105
|
{
|
|
108
106
|
name: "switch",
|
|
109
107
|
command: "g switch",
|
|
110
|
-
description: "Interactive switch"
|
|
111
|
-
allowGitArgs: true
|
|
108
|
+
description: "Interactive switch"
|
|
112
109
|
},
|
|
113
110
|
{
|
|
114
111
|
name: "alias",
|
|
115
112
|
command: "g alias",
|
|
116
|
-
description: "Show all the aliases"
|
|
117
|
-
allowGitArgs: false
|
|
113
|
+
description: "Show all the aliases"
|
|
118
114
|
},
|
|
119
115
|
{
|
|
120
116
|
name: "setup",
|
|
121
117
|
command: "g setup",
|
|
122
|
-
description: "Setup alias for git and glinter"
|
|
123
|
-
allowGitArgs: true
|
|
118
|
+
description: "Setup alias for git and glinter"
|
|
124
119
|
}
|
|
125
120
|
];
|
|
126
121
|
|
|
127
122
|
// apps/cli/error/error-constructor.ts
|
|
123
|
+
var capitalize = (text) => text.charAt(0).toUpperCase() + text.slice(1);
|
|
128
124
|
function CreateError(name) {
|
|
129
|
-
const capitalize = (text) => text.charAt(0).toUpperCase() + text.slice(1);
|
|
130
125
|
return class extends Error {
|
|
131
126
|
description;
|
|
132
127
|
constructor(message, description) {
|
|
@@ -179,25 +174,34 @@ function errorHandler(error) {
|
|
|
179
174
|
}
|
|
180
175
|
|
|
181
176
|
// node_modules/@clack/core/dist/index.mjs
|
|
182
|
-
import { styleText as
|
|
183
|
-
import { stdout as
|
|
184
|
-
import * as
|
|
185
|
-
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";
|
|
186
181
|
|
|
187
182
|
// node_modules/fast-string-truncated-width/dist/utils.js
|
|
188
|
-
var
|
|
189
|
-
|
|
190
|
-
|
|
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
|
+
})();
|
|
191
194
|
var isFullWidth = (x) => {
|
|
192
195
|
return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
|
|
193
196
|
};
|
|
194
|
-
var
|
|
195
|
-
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;
|
|
196
199
|
};
|
|
197
200
|
|
|
198
201
|
// node_modules/fast-string-truncated-width/dist/index.js
|
|
199
|
-
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;
|
|
200
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;
|
|
201
205
|
var TAB_RE = /\t{1,1000}/y;
|
|
202
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;
|
|
203
207
|
var LATIN_RE = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
|
|
@@ -207,14 +211,21 @@ var getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {})
|
|
|
207
211
|
const LIMIT = truncationOptions.limit ?? Infinity;
|
|
208
212
|
const ELLIPSIS = truncationOptions.ellipsis ?? "";
|
|
209
213
|
const ELLIPSIS_WIDTH = truncationOptions?.ellipsisWidth ?? (ELLIPSIS ? getStringTruncatedWidth(ELLIPSIS, NO_TRUNCATION, widthOptions).width : 0);
|
|
210
|
-
const ANSI_WIDTH =
|
|
214
|
+
const ANSI_WIDTH = 0;
|
|
211
215
|
const CONTROL_WIDTH = widthOptions.controlWidth ?? 0;
|
|
212
216
|
const TAB_WIDTH = widthOptions.tabWidth ?? 8;
|
|
213
|
-
const AMBIGUOUS_WIDTH = widthOptions.ambiguousWidth ?? 1;
|
|
214
217
|
const EMOJI_WIDTH = widthOptions.emojiWidth ?? 2;
|
|
215
|
-
const FULL_WIDTH_WIDTH =
|
|
218
|
+
const FULL_WIDTH_WIDTH = 2;
|
|
216
219
|
const REGULAR_WIDTH = widthOptions.regularWidth ?? 1;
|
|
217
|
-
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
|
+
];
|
|
218
229
|
let indexPrev = 0;
|
|
219
230
|
let index = 0;
|
|
220
231
|
let length = input.length;
|
|
@@ -235,10 +246,8 @@ var getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {})
|
|
|
235
246
|
const codePoint = char.codePointAt(0) || 0;
|
|
236
247
|
if (isFullWidth(codePoint)) {
|
|
237
248
|
widthExtra = FULL_WIDTH_WIDTH;
|
|
238
|
-
} else if (
|
|
249
|
+
} else if (isWideNotCJKTNotEmoji(codePoint)) {
|
|
239
250
|
widthExtra = WIDE_WIDTH;
|
|
240
|
-
} else if (AMBIGUOUS_WIDTH !== REGULAR_WIDTH && isAmbiguous(codePoint)) {
|
|
241
|
-
widthExtra = AMBIGUOUS_WIDTH;
|
|
242
251
|
} else {
|
|
243
252
|
widthExtra = REGULAR_WIDTH;
|
|
244
253
|
}
|
|
@@ -254,88 +263,28 @@ var getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {})
|
|
|
254
263
|
}
|
|
255
264
|
unmatchedStart = unmatchedEnd = 0;
|
|
256
265
|
}
|
|
257
|
-
if (index >= length)
|
|
258
|
-
break;
|
|
259
|
-
LATIN_RE.lastIndex = index;
|
|
260
|
-
if (LATIN_RE.test(input)) {
|
|
261
|
-
lengthExtra = LATIN_RE.lastIndex - index;
|
|
262
|
-
widthExtra = lengthExtra * REGULAR_WIDTH;
|
|
263
|
-
if (width + widthExtra > truncationLimit) {
|
|
264
|
-
truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / REGULAR_WIDTH));
|
|
265
|
-
}
|
|
266
|
-
if (width + widthExtra > LIMIT) {
|
|
267
|
-
truncationEnabled = true;
|
|
268
|
-
break;
|
|
269
|
-
}
|
|
270
|
-
width += widthExtra;
|
|
271
|
-
unmatchedStart = indexPrev;
|
|
272
|
-
unmatchedEnd = index;
|
|
273
|
-
index = indexPrev = LATIN_RE.lastIndex;
|
|
274
|
-
continue;
|
|
275
|
-
}
|
|
276
|
-
ANSI_RE.lastIndex = index;
|
|
277
|
-
if (ANSI_RE.test(input)) {
|
|
278
|
-
if (width + ANSI_WIDTH > truncationLimit) {
|
|
279
|
-
truncationIndex = Math.min(truncationIndex, index);
|
|
280
|
-
}
|
|
281
|
-
if (width + ANSI_WIDTH > LIMIT) {
|
|
282
|
-
truncationEnabled = true;
|
|
283
|
-
break;
|
|
284
|
-
}
|
|
285
|
-
width += ANSI_WIDTH;
|
|
286
|
-
unmatchedStart = indexPrev;
|
|
287
|
-
unmatchedEnd = index;
|
|
288
|
-
index = indexPrev = ANSI_RE.lastIndex;
|
|
289
|
-
continue;
|
|
290
|
-
}
|
|
291
|
-
CONTROL_RE.lastIndex = index;
|
|
292
|
-
if (CONTROL_RE.test(input)) {
|
|
293
|
-
lengthExtra = CONTROL_RE.lastIndex - index;
|
|
294
|
-
widthExtra = lengthExtra * CONTROL_WIDTH;
|
|
295
|
-
if (width + widthExtra > truncationLimit) {
|
|
296
|
-
truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / CONTROL_WIDTH));
|
|
297
|
-
}
|
|
298
|
-
if (width + widthExtra > LIMIT) {
|
|
299
|
-
truncationEnabled = true;
|
|
300
|
-
break;
|
|
301
|
-
}
|
|
302
|
-
width += widthExtra;
|
|
303
|
-
unmatchedStart = indexPrev;
|
|
304
|
-
unmatchedEnd = index;
|
|
305
|
-
index = indexPrev = CONTROL_RE.lastIndex;
|
|
306
|
-
continue;
|
|
307
|
-
}
|
|
308
|
-
TAB_RE.lastIndex = index;
|
|
309
|
-
if (TAB_RE.test(input)) {
|
|
310
|
-
lengthExtra = TAB_RE.lastIndex - index;
|
|
311
|
-
widthExtra = lengthExtra * TAB_WIDTH;
|
|
312
|
-
if (width + widthExtra > truncationLimit) {
|
|
313
|
-
truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / TAB_WIDTH));
|
|
314
|
-
}
|
|
315
|
-
if (width + widthExtra > LIMIT) {
|
|
316
|
-
truncationEnabled = true;
|
|
317
|
-
break;
|
|
318
|
-
}
|
|
319
|
-
width += widthExtra;
|
|
320
|
-
unmatchedStart = indexPrev;
|
|
321
|
-
unmatchedEnd = index;
|
|
322
|
-
index = indexPrev = TAB_RE.lastIndex;
|
|
323
|
-
continue;
|
|
266
|
+
if (index >= length) {
|
|
267
|
+
break outer;
|
|
324
268
|
}
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
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;
|
|
333
287
|
}
|
|
334
|
-
width += EMOJI_WIDTH;
|
|
335
|
-
unmatchedStart = indexPrev;
|
|
336
|
-
unmatchedEnd = index;
|
|
337
|
-
index = indexPrev = EMOJI_RE.lastIndex;
|
|
338
|
-
continue;
|
|
339
288
|
}
|
|
340
289
|
index += 1;
|
|
341
290
|
}
|
|
@@ -527,8 +476,11 @@ var exec = (string, columns, options = {}) => {
|
|
|
527
476
|
returnValue += character;
|
|
528
477
|
if (!inSurrogate) {
|
|
529
478
|
inSurrogate = character >= "\uD800" && character <= "\uDBFF";
|
|
479
|
+
if (inSurrogate) {
|
|
480
|
+
continue;
|
|
481
|
+
}
|
|
530
482
|
} else {
|
|
531
|
-
|
|
483
|
+
inSurrogate = false;
|
|
532
484
|
}
|
|
533
485
|
if (character === ESC || character === CSI) {
|
|
534
486
|
GROUP_REGEX.lastIndex = i + 1;
|
|
@@ -570,74 +522,96 @@ function wrapAnsi(string, columns, options) {
|
|
|
570
522
|
|
|
571
523
|
// node_modules/@clack/core/dist/index.mjs
|
|
572
524
|
var import_sisteransi = __toESM(require_src(), 1);
|
|
573
|
-
import { ReadStream as
|
|
574
|
-
function
|
|
575
|
-
if (!
|
|
525
|
+
import { ReadStream as O } from "tty";
|
|
526
|
+
function f(r, t, s) {
|
|
527
|
+
if (!s.some((o) => !o.disabled))
|
|
576
528
|
return r;
|
|
577
|
-
const
|
|
578
|
-
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;
|
|
579
550
|
}
|
|
580
|
-
var
|
|
581
|
-
var
|
|
582
|
-
var
|
|
583
|
-
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) {
|
|
584
555
|
if (typeof r == "string")
|
|
585
|
-
return
|
|
586
|
-
for (const
|
|
587
|
-
if (
|
|
556
|
+
return h.aliases.get(r) === t;
|
|
557
|
+
for (const s of r)
|
|
558
|
+
if (s !== undefined && C(s, t))
|
|
588
559
|
return true;
|
|
589
560
|
return false;
|
|
590
561
|
}
|
|
591
|
-
function
|
|
562
|
+
function z(r, t) {
|
|
592
563
|
if (r === t)
|
|
593
564
|
return;
|
|
594
|
-
const
|
|
595
|
-
`),
|
|
596
|
-
`), i = Math.max(
|
|
565
|
+
const s = r.split(`
|
|
566
|
+
`), e = t.split(`
|
|
567
|
+
`), i = Math.max(s.length, e.length), n = [];
|
|
597
568
|
for (let o = 0;o < i; o++)
|
|
598
|
-
|
|
599
|
-
return { lines: n, numLinesBefore:
|
|
569
|
+
s[o] !== e[o] && n.push(o);
|
|
570
|
+
return { lines: n, numLinesBefore: s.length, numLinesAfter: e.length, numLines: i };
|
|
600
571
|
}
|
|
601
572
|
var Y = globalThis.process.platform.startsWith("win");
|
|
602
|
-
var
|
|
573
|
+
var k = Symbol("clack:cancel");
|
|
603
574
|
function q(r) {
|
|
604
|
-
return r ===
|
|
575
|
+
return r === k;
|
|
605
576
|
}
|
|
606
577
|
function w(r, t) {
|
|
607
|
-
const
|
|
608
|
-
|
|
578
|
+
const s = r;
|
|
579
|
+
s.isTTY && s.setRawMode(t);
|
|
609
580
|
}
|
|
610
|
-
function
|
|
611
|
-
const i =
|
|
612
|
-
|
|
613
|
-
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 }) => {
|
|
614
585
|
const l = String(o);
|
|
615
|
-
if (
|
|
616
|
-
|
|
586
|
+
if (C([l, u, a], "cancel")) {
|
|
587
|
+
e && t.write(import_sisteransi.cursor.show), process.exit(0);
|
|
617
588
|
return;
|
|
618
589
|
}
|
|
619
|
-
if (!
|
|
590
|
+
if (!s)
|
|
620
591
|
return;
|
|
621
|
-
const
|
|
622
|
-
|
|
623
|
-
|
|
592
|
+
const c = u === "return" ? 0 : -1, y = u === "return" ? -1 : 0;
|
|
593
|
+
b.moveCursor(t, c, y, () => {
|
|
594
|
+
b.clearLine(t, 1, () => {
|
|
624
595
|
r.once("keypress", n);
|
|
625
596
|
});
|
|
626
597
|
});
|
|
627
598
|
};
|
|
628
|
-
return
|
|
629
|
-
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();
|
|
630
601
|
};
|
|
631
602
|
}
|
|
632
|
-
var
|
|
633
|
-
var
|
|
634
|
-
function
|
|
635
|
-
const
|
|
636
|
-
return wrapAnsi(t,
|
|
637
|
-
`).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(`
|
|
638
612
|
`);
|
|
639
613
|
}
|
|
640
|
-
var
|
|
614
|
+
var m = class {
|
|
641
615
|
input;
|
|
642
616
|
output;
|
|
643
617
|
_abortSignal;
|
|
@@ -652,27 +626,27 @@ var p = class {
|
|
|
652
626
|
error = "";
|
|
653
627
|
value;
|
|
654
628
|
userInput = "";
|
|
655
|
-
constructor(t,
|
|
656
|
-
const { input:
|
|
657
|
-
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;
|
|
658
632
|
}
|
|
659
633
|
unsubscribe() {
|
|
660
634
|
this._subscribers.clear();
|
|
661
635
|
}
|
|
662
|
-
setSubscriber(t,
|
|
663
|
-
const
|
|
664
|
-
|
|
636
|
+
setSubscriber(t, s) {
|
|
637
|
+
const e = this._subscribers.get(t) ?? [];
|
|
638
|
+
e.push(s), this._subscribers.set(t, e);
|
|
665
639
|
}
|
|
666
|
-
on(t,
|
|
667
|
-
this.setSubscriber(t, { cb:
|
|
640
|
+
on(t, s) {
|
|
641
|
+
this.setSubscriber(t, { cb: s });
|
|
668
642
|
}
|
|
669
|
-
once(t,
|
|
670
|
-
this.setSubscriber(t, { cb:
|
|
643
|
+
once(t, s) {
|
|
644
|
+
this.setSubscriber(t, { cb: s, once: true });
|
|
671
645
|
}
|
|
672
|
-
emit(t, ...
|
|
673
|
-
const
|
|
674
|
-
for (const n of
|
|
675
|
-
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));
|
|
676
650
|
for (const n of i)
|
|
677
651
|
n();
|
|
678
652
|
}
|
|
@@ -680,39 +654,42 @@ var p = class {
|
|
|
680
654
|
return new Promise((t) => {
|
|
681
655
|
if (this._abortSignal) {
|
|
682
656
|
if (this._abortSignal.aborted)
|
|
683
|
-
return this.state = "cancel", this.close(), t(
|
|
657
|
+
return this.state = "cancel", this.close(), t(k);
|
|
684
658
|
this._abortSignal.addEventListener("abort", () => {
|
|
685
659
|
this.state = "cancel", this.close();
|
|
686
660
|
}, { once: true });
|
|
687
661
|
}
|
|
688
|
-
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", () => {
|
|
689
663
|
this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), w(this.input, false), t(this.value);
|
|
690
664
|
}), this.once("cancel", () => {
|
|
691
|
-
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);
|
|
692
666
|
});
|
|
693
667
|
});
|
|
694
668
|
}
|
|
695
|
-
_isActionKey(t,
|
|
669
|
+
_isActionKey(t, s) {
|
|
696
670
|
return t === "\t";
|
|
697
671
|
}
|
|
672
|
+
_shouldSubmit(t, s) {
|
|
673
|
+
return true;
|
|
674
|
+
}
|
|
698
675
|
_setValue(t) {
|
|
699
676
|
this.value = t, this.emit("value", this.value);
|
|
700
677
|
}
|
|
701
|
-
_setUserInput(t,
|
|
702
|
-
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);
|
|
703
680
|
}
|
|
704
681
|
_clearUserInput() {
|
|
705
682
|
this.rl?.write(null, { ctrl: true, name: "u" }), this._setUserInput("");
|
|
706
683
|
}
|
|
707
|
-
onKeypress(t,
|
|
708
|
-
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)) {
|
|
709
686
|
if (this.opts.validate) {
|
|
710
|
-
const
|
|
711
|
-
|
|
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));
|
|
712
689
|
}
|
|
713
690
|
this.state !== "error" && (this.state = "submit");
|
|
714
691
|
}
|
|
715
|
-
|
|
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();
|
|
716
693
|
}
|
|
717
694
|
close() {
|
|
718
695
|
this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
|
|
@@ -729,31 +706,31 @@ var p = class {
|
|
|
729
706
|
if (this.state === "initial")
|
|
730
707
|
this.output.write(import_sisteransi.cursor.hide);
|
|
731
708
|
else {
|
|
732
|
-
const
|
|
733
|
-
if (this.restoreCursor(),
|
|
734
|
-
const i = Math.max(0,
|
|
735
|
-
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);
|
|
736
713
|
if (o === undefined) {
|
|
737
714
|
this._prevFrame = t;
|
|
738
715
|
return;
|
|
739
716
|
}
|
|
740
|
-
if (
|
|
717
|
+
if (s.lines.length === 1) {
|
|
741
718
|
this.output.write(import_sisteransi.cursor.move(0, o - n)), this.output.write(import_sisteransi.erase.lines(1));
|
|
742
|
-
const
|
|
719
|
+
const u = t.split(`
|
|
743
720
|
`);
|
|
744
|
-
this.output.write(
|
|
721
|
+
this.output.write(u[o]), this._prevFrame = t, this.output.write(import_sisteransi.cursor.move(0, u.length - o - 1));
|
|
745
722
|
return;
|
|
746
|
-
} else if (
|
|
723
|
+
} else if (s.lines.length > 1) {
|
|
747
724
|
if (i < n)
|
|
748
725
|
o = i;
|
|
749
726
|
else {
|
|
750
|
-
const
|
|
751
|
-
|
|
727
|
+
const a = o - n;
|
|
728
|
+
a > 0 && this.output.write(import_sisteransi.cursor.move(0, a));
|
|
752
729
|
}
|
|
753
730
|
this.output.write(import_sisteransi.erase.down());
|
|
754
|
-
const
|
|
731
|
+
const u = t.split(`
|
|
755
732
|
`).slice(o);
|
|
756
|
-
this.output.write(
|
|
733
|
+
this.output.write(u.join(`
|
|
757
734
|
`)), this._prevFrame = t;
|
|
758
735
|
return;
|
|
759
736
|
}
|
|
@@ -764,87 +741,87 @@ var p = class {
|
|
|
764
741
|
}
|
|
765
742
|
}
|
|
766
743
|
};
|
|
767
|
-
function
|
|
744
|
+
function B(r, t) {
|
|
768
745
|
if (r === undefined || t.length === 0)
|
|
769
746
|
return 0;
|
|
770
|
-
const
|
|
771
|
-
return
|
|
747
|
+
const s = t.findIndex((e) => e.value === r);
|
|
748
|
+
return s !== -1 ? s : 0;
|
|
772
749
|
}
|
|
773
|
-
function
|
|
750
|
+
function J(r, t) {
|
|
774
751
|
return (t.label ?? String(t.value)).toLowerCase().includes(r.toLowerCase());
|
|
775
752
|
}
|
|
776
|
-
function
|
|
753
|
+
function H(r, t) {
|
|
777
754
|
if (t)
|
|
778
755
|
return r ? t : t[0];
|
|
779
756
|
}
|
|
780
|
-
var
|
|
757
|
+
var Q = class extends m {
|
|
781
758
|
filteredOptions;
|
|
782
759
|
multiple;
|
|
783
760
|
isNavigating = false;
|
|
784
761
|
selectedValues = [];
|
|
785
762
|
focusedValue;
|
|
786
|
-
#
|
|
787
|
-
#
|
|
763
|
+
#s = 0;
|
|
764
|
+
#r = "";
|
|
788
765
|
#t;
|
|
789
766
|
#n;
|
|
790
|
-
#
|
|
767
|
+
#u;
|
|
791
768
|
get cursor() {
|
|
792
|
-
return this.#
|
|
769
|
+
return this.#s;
|
|
793
770
|
}
|
|
794
771
|
get userInputWithCursor() {
|
|
795
772
|
if (!this.userInput)
|
|
796
|
-
return
|
|
773
|
+
return v(["inverse", "hidden"], "_");
|
|
797
774
|
if (this._cursor >= this.userInput.length)
|
|
798
775
|
return `${this.userInput}\u2588`;
|
|
799
|
-
const t = this.userInput.slice(0, this._cursor), [
|
|
800
|
-
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("")}`;
|
|
801
778
|
}
|
|
802
779
|
get options() {
|
|
803
780
|
return typeof this.#n == "function" ? this.#n() : this.#n;
|
|
804
781
|
}
|
|
805
782
|
constructor(t) {
|
|
806
|
-
super(t), this.#n = t.options, this.#
|
|
807
|
-
const
|
|
808
|
-
this.filteredOptions = [...
|
|
809
|
-
let
|
|
810
|
-
if (t.initialValue && Array.isArray(t.initialValue) ? this.multiple ?
|
|
811
|
-
for (const i of
|
|
812
|
-
const n =
|
|
813
|
-
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);
|
|
814
791
|
}
|
|
815
|
-
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));
|
|
816
793
|
}
|
|
817
|
-
_isActionKey(t,
|
|
818
|
-
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 !== "";
|
|
819
796
|
}
|
|
820
|
-
#
|
|
821
|
-
const
|
|
822
|
-
if (
|
|
823
|
-
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;
|
|
824
801
|
return;
|
|
825
802
|
}
|
|
826
|
-
|
|
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);
|
|
827
804
|
}
|
|
828
805
|
deselectAll() {
|
|
829
806
|
this.selectedValues = [];
|
|
830
807
|
}
|
|
831
808
|
toggleSelected(t) {
|
|
832
|
-
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]);
|
|
833
810
|
}
|
|
834
811
|
#i(t) {
|
|
835
|
-
if (t !== this.#
|
|
836
|
-
this.#
|
|
837
|
-
const
|
|
838
|
-
t && this.#t ? this.filteredOptions =
|
|
839
|
-
const
|
|
840
|
-
this.#
|
|
841
|
-
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];
|
|
842
819
|
i && !i.disabled ? this.focusedValue = i.value : this.focusedValue = undefined, this.multiple || (this.focusedValue !== undefined ? this.toggleSelected(this.focusedValue) : this.deselectAll());
|
|
843
820
|
}
|
|
844
821
|
}
|
|
845
822
|
};
|
|
846
823
|
|
|
847
|
-
class
|
|
824
|
+
class X2 extends m {
|
|
848
825
|
get cursor() {
|
|
849
826
|
return this.value ? 0 : 1;
|
|
850
827
|
}
|
|
@@ -854,102 +831,102 @@ class Q extends p {
|
|
|
854
831
|
constructor(t) {
|
|
855
832
|
super(t, false), this.value = !!t.initialValue, this.on("userInput", () => {
|
|
856
833
|
this.value = this._value;
|
|
857
|
-
}), this.on("confirm", (
|
|
858
|
-
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();
|
|
859
836
|
}), this.on("cursor", () => {
|
|
860
837
|
this.value = !this.value;
|
|
861
838
|
});
|
|
862
839
|
}
|
|
863
840
|
}
|
|
864
|
-
var
|
|
865
|
-
function
|
|
866
|
-
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]);
|
|
867
844
|
}
|
|
868
|
-
function
|
|
869
|
-
const t = new Intl.DateTimeFormat(r, { year: "numeric", month: "2-digit", day: "2-digit" }).formatToParts(new Date(2000, 0, 15)),
|
|
870
|
-
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 = "/";
|
|
871
848
|
for (const i of t)
|
|
872
|
-
i.type === "literal" ?
|
|
873
|
-
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 };
|
|
874
851
|
}
|
|
875
|
-
function
|
|
852
|
+
function $(r) {
|
|
876
853
|
return Number.parseInt((r || "0").replace(/_/g, "0"), 10) || 0;
|
|
877
854
|
}
|
|
878
|
-
function
|
|
879
|
-
return { year:
|
|
855
|
+
function S(r) {
|
|
856
|
+
return { year: $(r.year), month: $(r.month), day: $(r.day) };
|
|
880
857
|
}
|
|
881
|
-
function
|
|
858
|
+
function U(r, t) {
|
|
882
859
|
return new Date(r || 2001, t || 1, 0).getDate();
|
|
883
860
|
}
|
|
884
861
|
function F(r) {
|
|
885
|
-
const { year: t, month:
|
|
886
|
-
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)
|
|
887
864
|
return;
|
|
888
|
-
const i = new Date(Date.UTC(t,
|
|
889
|
-
if (!(i.getUTCFullYear() !== t || i.getUTCMonth() !==
|
|
890
|
-
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 };
|
|
891
868
|
}
|
|
892
869
|
function N(r) {
|
|
893
870
|
const t = F(r);
|
|
894
871
|
return t ? new Date(Date.UTC(t.year, t.month - 1, t.day)) : undefined;
|
|
895
872
|
}
|
|
896
|
-
function
|
|
897
|
-
const i =
|
|
898
|
-
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) };
|
|
899
876
|
}
|
|
900
877
|
|
|
901
|
-
class et extends
|
|
902
|
-
#
|
|
903
|
-
#
|
|
878
|
+
class et extends m {
|
|
879
|
+
#s;
|
|
880
|
+
#r;
|
|
904
881
|
#t;
|
|
905
882
|
#n;
|
|
906
|
-
#
|
|
907
|
-
#
|
|
883
|
+
#u;
|
|
884
|
+
#e = { segmentIndex: 0, positionInSegment: 0 };
|
|
908
885
|
#i = true;
|
|
909
|
-
#
|
|
886
|
+
#o = null;
|
|
910
887
|
inlineError = "";
|
|
911
888
|
get segmentCursor() {
|
|
912
|
-
return { ...this.#
|
|
889
|
+
return { ...this.#e };
|
|
913
890
|
}
|
|
914
891
|
get segmentValues() {
|
|
915
892
|
return { ...this.#t };
|
|
916
893
|
}
|
|
917
894
|
get segments() {
|
|
918
|
-
return this.#
|
|
895
|
+
return this.#s;
|
|
919
896
|
}
|
|
920
897
|
get separator() {
|
|
921
|
-
return this.#
|
|
898
|
+
return this.#r;
|
|
922
899
|
}
|
|
923
900
|
get formattedValue() {
|
|
924
901
|
return this.#c(this.#t);
|
|
925
902
|
}
|
|
926
903
|
#c(t) {
|
|
927
|
-
return this.#
|
|
904
|
+
return this.#s.map((s) => t[s.type]).join(this.#r);
|
|
928
905
|
}
|
|
929
|
-
#
|
|
906
|
+
#a() {
|
|
930
907
|
this._setUserInput(this.#c(this.#t)), this._setValue(N(this.#t) ?? undefined);
|
|
931
908
|
}
|
|
932
909
|
constructor(t) {
|
|
933
|
-
const
|
|
934
|
-
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));
|
|
935
912
|
}
|
|
936
|
-
#
|
|
937
|
-
const t = Math.max(0, Math.min(this.#
|
|
938
|
-
if (
|
|
939
|
-
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 };
|
|
940
917
|
}
|
|
941
918
|
#l(t) {
|
|
942
|
-
this.inlineError = "", this.#
|
|
943
|
-
const
|
|
944
|
-
|
|
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);
|
|
945
922
|
}
|
|
946
923
|
#p(t) {
|
|
947
|
-
const
|
|
948
|
-
if (!
|
|
924
|
+
const s = this.#h();
|
|
925
|
+
if (!s)
|
|
949
926
|
return;
|
|
950
|
-
const { segment:
|
|
951
|
-
let
|
|
952
|
-
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();
|
|
953
930
|
}
|
|
954
931
|
#d(t) {
|
|
955
932
|
if (t)
|
|
@@ -964,124 +941,124 @@ class et extends p {
|
|
|
964
941
|
return this.#p(-1);
|
|
965
942
|
}
|
|
966
943
|
}
|
|
967
|
-
#f(t,
|
|
968
|
-
if (
|
|
944
|
+
#f(t, s) {
|
|
945
|
+
if (s?.name === "backspace" || s?.sequence === "\x7F" || s?.sequence === "\b" || t === "\x7F" || t === "\b") {
|
|
969
946
|
this.inlineError = "";
|
|
970
|
-
const
|
|
971
|
-
if (!
|
|
947
|
+
const e = this.#h();
|
|
948
|
+
if (!e)
|
|
972
949
|
return;
|
|
973
|
-
if (!this.#t[
|
|
950
|
+
if (!this.#t[e.segment.type].replace(/_/g, "")) {
|
|
974
951
|
this.#l(-1);
|
|
975
952
|
return;
|
|
976
953
|
}
|
|
977
|
-
this.#t[
|
|
954
|
+
this.#t[e.segment.type] = "_".repeat(e.segment.len), this.#i = true, this.#e.positionInSegment = 0, this.#a();
|
|
978
955
|
return;
|
|
979
956
|
}
|
|
980
|
-
if (
|
|
957
|
+
if (s?.name === "tab") {
|
|
981
958
|
this.inlineError = "";
|
|
982
|
-
const
|
|
983
|
-
if (!
|
|
959
|
+
const e = this.#h();
|
|
960
|
+
if (!e)
|
|
984
961
|
return;
|
|
985
|
-
const i =
|
|
986
|
-
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);
|
|
987
964
|
return;
|
|
988
965
|
}
|
|
989
966
|
if (t && /^[0-9]$/.test(t)) {
|
|
990
|
-
const
|
|
991
|
-
if (!
|
|
967
|
+
const e = this.#h();
|
|
968
|
+
if (!e)
|
|
992
969
|
return;
|
|
993
|
-
const { segment: i } =
|
|
994
|
-
if (this.#i && this.#
|
|
995
|
-
const
|
|
996
|
-
if (
|
|
997
|
-
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;
|
|
998
975
|
return;
|
|
999
976
|
}
|
|
1000
|
-
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);
|
|
1001
978
|
return;
|
|
1002
979
|
}
|
|
1003
|
-
this.#i && !n && (this.#t[i.type] = "_".repeat(i.len), this.#
|
|
1004
|
-
const o = this.#t[i.type],
|
|
1005
|
-
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)
|
|
1006
983
|
return;
|
|
1007
|
-
let l = o.slice(0,
|
|
1008
|
-
if (
|
|
1009
|
-
const
|
|
1010
|
-
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);
|
|
1011
988
|
}
|
|
1012
989
|
if (i.type === "year" && (l = (o.replace(/_/g, "") + t).padStart(i.len, "_")), !l.includes("_")) {
|
|
1013
|
-
const
|
|
990
|
+
const d = { ...this.#t, [i.type]: l }, g = this.#m(d, i);
|
|
1014
991
|
if (g) {
|
|
1015
992
|
this.inlineError = g;
|
|
1016
993
|
return;
|
|
1017
994
|
}
|
|
1018
995
|
}
|
|
1019
996
|
this.inlineError = "", this.#t[i.type] = l;
|
|
1020
|
-
const
|
|
1021
|
-
if (
|
|
1022
|
-
const { year:
|
|
1023
|
-
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") };
|
|
1024
1001
|
}
|
|
1025
|
-
this.#
|
|
1026
|
-
const
|
|
1027
|
-
|
|
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);
|
|
1028
1005
|
}
|
|
1029
1006
|
}
|
|
1030
|
-
#m(t,
|
|
1031
|
-
const { month:
|
|
1032
|
-
if (
|
|
1033
|
-
return
|
|
1034
|
-
if (
|
|
1035
|
-
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");
|
|
1036
1013
|
}
|
|
1037
1014
|
#g(t) {
|
|
1038
|
-
const { year:
|
|
1039
|
-
if (
|
|
1040
|
-
const n =
|
|
1015
|
+
const { year: s, month: e, day: i } = S(this.#t);
|
|
1016
|
+
if (s && e && i) {
|
|
1017
|
+
const n = U(s, e);
|
|
1041
1018
|
this.#t = { ...this.#t, day: String(Math.min(i, n)).padStart(2, "0") };
|
|
1042
1019
|
}
|
|
1043
1020
|
this.value = N(this.#t) ?? t.defaultValue ?? undefined;
|
|
1044
1021
|
}
|
|
1045
1022
|
}
|
|
1046
1023
|
|
|
1047
|
-
class
|
|
1024
|
+
class it extends m {
|
|
1048
1025
|
options;
|
|
1049
1026
|
cursor = 0;
|
|
1050
|
-
#
|
|
1027
|
+
#s;
|
|
1051
1028
|
getGroupItems(t) {
|
|
1052
|
-
return this.options.filter((
|
|
1029
|
+
return this.options.filter((s) => s.group === t);
|
|
1053
1030
|
}
|
|
1054
1031
|
isGroupSelected(t) {
|
|
1055
|
-
const
|
|
1056
|
-
return
|
|
1032
|
+
const s = this.getGroupItems(t), e = this.value;
|
|
1033
|
+
return e === undefined ? false : s.every((i) => e.includes(i.value));
|
|
1057
1034
|
}
|
|
1058
1035
|
toggleValue() {
|
|
1059
1036
|
const t = this.options[this.cursor];
|
|
1060
1037
|
if (this.value === undefined && (this.value = []), t.group === true) {
|
|
1061
|
-
const
|
|
1062
|
-
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));
|
|
1063
1040
|
} else {
|
|
1064
|
-
const
|
|
1065
|
-
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];
|
|
1066
1043
|
}
|
|
1067
1044
|
}
|
|
1068
1045
|
constructor(t) {
|
|
1069
1046
|
super(t, false);
|
|
1070
|
-
const { options:
|
|
1071
|
-
this.#
|
|
1072
|
-
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) {
|
|
1073
1050
|
case "left":
|
|
1074
1051
|
case "up": {
|
|
1075
1052
|
this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
|
|
1076
1053
|
const i = this.options[this.cursor]?.group === true;
|
|
1077
|
-
!this.#
|
|
1054
|
+
!this.#s && i && (this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1);
|
|
1078
1055
|
break;
|
|
1079
1056
|
}
|
|
1080
1057
|
case "down":
|
|
1081
1058
|
case "right": {
|
|
1082
1059
|
this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
|
|
1083
1060
|
const i = this.options[this.cursor]?.group === true;
|
|
1084
|
-
!this.#
|
|
1061
|
+
!this.#s && i && (this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1);
|
|
1085
1062
|
break;
|
|
1086
1063
|
}
|
|
1087
1064
|
case "space":
|
|
@@ -1091,7 +1068,87 @@ class st extends p {
|
|
|
1091
1068
|
});
|
|
1092
1069
|
}
|
|
1093
1070
|
}
|
|
1094
|
-
|
|
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 {
|
|
1095
1152
|
options;
|
|
1096
1153
|
cursor = 0;
|
|
1097
1154
|
get _value() {
|
|
@@ -1101,35 +1158,35 @@ var it = class extends p {
|
|
|
1101
1158
|
return this.options.filter((t) => t.disabled !== true);
|
|
1102
1159
|
}
|
|
1103
1160
|
toggleAll() {
|
|
1104
|
-
const t = this._enabledOptions,
|
|
1105
|
-
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);
|
|
1106
1163
|
}
|
|
1107
1164
|
toggleInvert() {
|
|
1108
1165
|
const t = this.value;
|
|
1109
1166
|
if (!t)
|
|
1110
1167
|
return;
|
|
1111
|
-
const
|
|
1112
|
-
this.value =
|
|
1168
|
+
const s = this._enabledOptions.filter((e) => !t.includes(e.value));
|
|
1169
|
+
this.value = s.map((e) => e.value);
|
|
1113
1170
|
}
|
|
1114
1171
|
toggleValue() {
|
|
1115
1172
|
this.value === undefined && (this.value = []);
|
|
1116
1173
|
const t = this.value.includes(this._value);
|
|
1117
|
-
this.value = t ? this.value.filter((
|
|
1174
|
+
this.value = t ? this.value.filter((s) => s !== this._value) : [...this.value, this._value];
|
|
1118
1175
|
}
|
|
1119
1176
|
constructor(t) {
|
|
1120
1177
|
super(t, false), this.options = t.options, this.value = [...t.initialValues ?? []];
|
|
1121
|
-
const
|
|
1122
|
-
this.cursor = this.options[
|
|
1123
|
-
|
|
1124
|
-
}), this.on("cursor", (
|
|
1125
|
-
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) {
|
|
1126
1183
|
case "left":
|
|
1127
1184
|
case "up":
|
|
1128
|
-
this.cursor =
|
|
1185
|
+
this.cursor = f(this.cursor, -1, this.options);
|
|
1129
1186
|
break;
|
|
1130
1187
|
case "down":
|
|
1131
1188
|
case "right":
|
|
1132
|
-
this.cursor =
|
|
1189
|
+
this.cursor = f(this.cursor, 1, this.options);
|
|
1133
1190
|
break;
|
|
1134
1191
|
case "space":
|
|
1135
1192
|
this.toggleValue();
|
|
@@ -1138,7 +1195,7 @@ var it = class extends p {
|
|
|
1138
1195
|
});
|
|
1139
1196
|
}
|
|
1140
1197
|
};
|
|
1141
|
-
class
|
|
1198
|
+
class ut extends m {
|
|
1142
1199
|
options;
|
|
1143
1200
|
cursor = 0;
|
|
1144
1201
|
get _selectedValue() {
|
|
@@ -1149,38 +1206,38 @@ class nt extends p {
|
|
|
1149
1206
|
}
|
|
1150
1207
|
constructor(t) {
|
|
1151
1208
|
super(t, false), this.options = t.options;
|
|
1152
|
-
const
|
|
1153
|
-
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) => {
|
|
1154
1211
|
switch (i) {
|
|
1155
1212
|
case "left":
|
|
1156
1213
|
case "up":
|
|
1157
|
-
this.cursor =
|
|
1214
|
+
this.cursor = f(this.cursor, -1, this.options);
|
|
1158
1215
|
break;
|
|
1159
1216
|
case "down":
|
|
1160
1217
|
case "right":
|
|
1161
|
-
this.cursor =
|
|
1218
|
+
this.cursor = f(this.cursor, 1, this.options);
|
|
1162
1219
|
break;
|
|
1163
1220
|
}
|
|
1164
1221
|
this.changeValue();
|
|
1165
1222
|
});
|
|
1166
1223
|
}
|
|
1167
1224
|
}
|
|
1168
|
-
class
|
|
1225
|
+
class ht extends m {
|
|
1169
1226
|
get userInputWithCursor() {
|
|
1170
1227
|
if (this.state === "submit")
|
|
1171
1228
|
return this.userInput;
|
|
1172
1229
|
const t = this.userInput;
|
|
1173
1230
|
if (this.cursor >= t.length)
|
|
1174
1231
|
return `${this.userInput}\u2588`;
|
|
1175
|
-
const
|
|
1176
|
-
return `${
|
|
1232
|
+
const s = t.slice(0, this.cursor), [e, ...i] = t.slice(this.cursor);
|
|
1233
|
+
return `${s}${v("inverse", e)}${i.join("")}`;
|
|
1177
1234
|
}
|
|
1178
1235
|
get cursor() {
|
|
1179
1236
|
return this._cursor;
|
|
1180
1237
|
}
|
|
1181
1238
|
constructor(t) {
|
|
1182
|
-
super({ ...t, initialUserInput: t.initialUserInput ?? t.initialValue }), this.on("userInput", (
|
|
1183
|
-
this._setValue(
|
|
1239
|
+
super({ ...t, initialUserInput: t.initialUserInput ?? t.initialValue }), this.on("userInput", (s) => {
|
|
1240
|
+
this._setValue(s);
|
|
1184
1241
|
}), this.on("finalize", () => {
|
|
1185
1242
|
this.value || (this.value = t.defaultValue), this.value === undefined && (this.value = "");
|
|
1186
1243
|
});
|
|
@@ -1188,332 +1245,335 @@ class at extends p {
|
|
|
1188
1245
|
}
|
|
1189
1246
|
|
|
1190
1247
|
// node_modules/@clack/prompts/dist/index.mjs
|
|
1191
|
-
import { styleText as
|
|
1192
|
-
import
|
|
1248
|
+
import { styleText as e, stripVTControlCharacters as nt2 } from "util";
|
|
1249
|
+
import V2 from "process";
|
|
1193
1250
|
var import_sisteransi2 = __toESM(require_src(), 1);
|
|
1194
|
-
function
|
|
1195
|
-
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";
|
|
1196
1253
|
}
|
|
1197
|
-
var
|
|
1198
|
-
var
|
|
1199
|
-
var w2 = (
|
|
1200
|
-
var
|
|
1201
|
-
var
|
|
1202
|
-
var
|
|
1203
|
-
var
|
|
1204
|
-
var
|
|
1205
|
-
var
|
|
1206
|
-
var
|
|
1207
|
-
var
|
|
1208
|
-
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");
|
|
1209
1266
|
var z2 = w2("\u25CF", ">");
|
|
1210
|
-
var
|
|
1211
|
-
var
|
|
1212
|
-
var
|
|
1213
|
-
var
|
|
1214
|
-
var
|
|
1215
|
-
var
|
|
1216
|
-
var
|
|
1217
|
-
var
|
|
1218
|
-
var $
|
|
1219
|
-
var
|
|
1220
|
-
var
|
|
1221
|
-
var
|
|
1222
|
-
var
|
|
1223
|
-
var
|
|
1224
|
-
var
|
|
1225
|
-
var
|
|
1226
|
-
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) {
|
|
1227
1284
|
case "initial":
|
|
1228
1285
|
case "active":
|
|
1229
|
-
return
|
|
1286
|
+
return e("cyan", Tt);
|
|
1230
1287
|
case "cancel":
|
|
1231
|
-
return
|
|
1288
|
+
return e("red", at2);
|
|
1232
1289
|
case "error":
|
|
1233
|
-
return
|
|
1290
|
+
return e("yellow", ut2);
|
|
1234
1291
|
case "submit":
|
|
1235
|
-
return
|
|
1292
|
+
return e("green", H2);
|
|
1236
1293
|
}
|
|
1237
1294
|
};
|
|
1238
|
-
var
|
|
1239
|
-
switch (
|
|
1295
|
+
var yt = (t) => {
|
|
1296
|
+
switch (t) {
|
|
1240
1297
|
case "initial":
|
|
1241
1298
|
case "active":
|
|
1242
|
-
return
|
|
1299
|
+
return e("cyan", $2);
|
|
1243
1300
|
case "cancel":
|
|
1244
|
-
return
|
|
1301
|
+
return e("red", $2);
|
|
1245
1302
|
case "error":
|
|
1246
|
-
return
|
|
1303
|
+
return e("yellow", $2);
|
|
1247
1304
|
case "submit":
|
|
1248
|
-
return
|
|
1305
|
+
return e("green", $2);
|
|
1249
1306
|
}
|
|
1250
1307
|
};
|
|
1251
|
-
var
|
|
1252
|
-
let
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
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 };
|
|
1259
1317
|
};
|
|
1260
|
-
var
|
|
1261
|
-
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);
|
|
1262
1320
|
let p2 = 0;
|
|
1263
|
-
|
|
1264
|
-
let
|
|
1265
|
-
const
|
|
1266
|
-
let
|
|
1267
|
-
|
|
1268
|
-
const
|
|
1269
|
-
for (let
|
|
1270
|
-
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(`
|
|
1271
1329
|
`);
|
|
1272
|
-
|
|
1273
|
-
}
|
|
1274
|
-
if (
|
|
1275
|
-
let
|
|
1276
|
-
const
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
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;
|
|
1285
1345
|
};
|
|
1286
|
-
var
|
|
1287
|
-
const i =
|
|
1288
|
-
return new
|
|
1289
|
-
const r =
|
|
1290
|
-
` : ""}${
|
|
1291
|
-
`,
|
|
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;
|
|
1292
1352
|
switch (this.state) {
|
|
1293
1353
|
case "submit": {
|
|
1294
|
-
const l = r ? `${
|
|
1295
|
-
return `${
|
|
1354
|
+
const l = r ? `${e("gray", $2)} ` : "";
|
|
1355
|
+
return `${c}${l}${e("dim", o)}`;
|
|
1296
1356
|
}
|
|
1297
1357
|
case "cancel": {
|
|
1298
|
-
const l = r ? `${
|
|
1299
|
-
return `${
|
|
1300
|
-
${
|
|
1358
|
+
const l = r ? `${e("gray", $2)} ` : "";
|
|
1359
|
+
return `${c}${l}${e(["strikethrough", "dim"], o)}${r ? `
|
|
1360
|
+
${e("gray", $2)}` : ""}`;
|
|
1301
1361
|
}
|
|
1302
1362
|
default: {
|
|
1303
|
-
const l = r ? `${
|
|
1304
|
-
return `${
|
|
1305
|
-
${
|
|
1306
|
-
` : ` ${
|
|
1307
|
-
${
|
|
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}
|
|
1308
1368
|
`;
|
|
1309
1369
|
}
|
|
1310
1370
|
}
|
|
1311
1371
|
} }).prompt();
|
|
1312
1372
|
};
|
|
1313
|
-
var
|
|
1314
|
-
const s = i?.output ?? process.stdout, r = i?.withGuide ??
|
|
1315
|
-
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)}
|
|
1316
1376
|
|
|
1317
1377
|
`);
|
|
1318
1378
|
};
|
|
1319
|
-
var
|
|
1320
|
-
const s = i?.output ?? process.stdout, r = i?.withGuide ??
|
|
1321
|
-
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}
|
|
1322
1382
|
`);
|
|
1323
1383
|
};
|
|
1324
|
-
var
|
|
1325
|
-
const s = i?.output ?? process.stdout, r = i?.withGuide ??
|
|
1326
|
-
${
|
|
1327
|
-
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}
|
|
1328
1388
|
|
|
1329
1389
|
`);
|
|
1330
1390
|
};
|
|
1331
|
-
var Q2 = (
|
|
1391
|
+
var Q2 = (t, i) => t.split(`
|
|
1332
1392
|
`).map((s) => i(s)).join(`
|
|
1333
1393
|
`);
|
|
1334
|
-
var
|
|
1335
|
-
const i = (r,
|
|
1394
|
+
var ve = (t) => {
|
|
1395
|
+
const i = (r, u) => {
|
|
1336
1396
|
const n = r.label ?? String(r.value);
|
|
1337
|
-
return
|
|
1338
|
-
}, s =
|
|
1339
|
-
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) {
|
|
1340
1400
|
if (s && (r === undefined || r.length === 0))
|
|
1341
1401
|
return `Please select at least one option.
|
|
1342
|
-
${
|
|
1402
|
+
${e("reset", e("dim", `Press ${e(["gray", "bgWhite", "inverse"], " space ")} to select, ${e("gray", e("bgWhite", e("inverse", " enter ")))} to submit`))}`;
|
|
1343
1403
|
}, render() {
|
|
1344
|
-
const r =
|
|
1345
|
-
` : ""}${
|
|
1346
|
-
`,
|
|
1347
|
-
if (
|
|
1348
|
-
return i(
|
|
1349
|
-
const
|
|
1350
|
-
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");
|
|
1351
1411
|
};
|
|
1352
1412
|
switch (this.state) {
|
|
1353
1413
|
case "submit": {
|
|
1354
|
-
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)} ` : "");
|
|
1355
1415
|
return `${n}${l}`;
|
|
1356
1416
|
}
|
|
1357
1417
|
case "cancel": {
|
|
1358
|
-
const
|
|
1359
|
-
if (
|
|
1360
|
-
return `${n}${
|
|
1361
|
-
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)} ` : "");
|
|
1362
1422
|
return `${n}${l}${r ? `
|
|
1363
|
-
${
|
|
1423
|
+
${e("gray", $2)}` : ""}`;
|
|
1364
1424
|
}
|
|
1365
1425
|
case "error": {
|
|
1366
|
-
const
|
|
1367
|
-
`).map((p2,
|
|
1368
|
-
`),
|
|
1369
|
-
`).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(`
|
|
1370
1430
|
`).length + 1;
|
|
1371
|
-
return `${n}${
|
|
1372
|
-
${
|
|
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}`)}
|
|
1373
1433
|
${l}
|
|
1374
1434
|
`;
|
|
1375
1435
|
}
|
|
1376
1436
|
default: {
|
|
1377
|
-
const
|
|
1378
|
-
`).length,
|
|
1379
|
-
return `${n}${
|
|
1380
|
-
${
|
|
1381
|
-
${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) : ""}
|
|
1382
1442
|
`;
|
|
1383
1443
|
}
|
|
1384
1444
|
}
|
|
1385
1445
|
} }).prompt();
|
|
1386
1446
|
};
|
|
1387
|
-
var
|
|
1388
|
-
var
|
|
1389
|
-
const l =
|
|
1390
|
-
let
|
|
1391
|
-
const
|
|
1392
|
-
const A2 =
|
|
1393
|
-
|
|
1394
|
-
},
|
|
1395
|
-
process.on("uncaughtExceptionMonitor",
|
|
1396
|
-
},
|
|
1397
|
-
process.removeListener("uncaughtExceptionMonitor",
|
|
1398
|
-
},
|
|
1399
|
-
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)
|
|
1400
1460
|
return;
|
|
1401
1461
|
l && s.write(`
|
|
1402
1462
|
`);
|
|
1403
|
-
const
|
|
1463
|
+
const _ = wrapAnsi(I2, y, { hard: true, trim: false }).split(`
|
|
1404
1464
|
`);
|
|
1405
|
-
|
|
1406
|
-
},
|
|
1407
|
-
const A2 = (performance.now() -
|
|
1408
|
-
return
|
|
1409
|
-
},
|
|
1410
|
-
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)}
|
|
1411
1471
|
`);
|
|
1412
|
-
let A2 = 0,
|
|
1413
|
-
|
|
1414
|
-
if (l &&
|
|
1472
|
+
let A2 = 0, L2 = 0;
|
|
1473
|
+
G2(), g = setInterval(() => {
|
|
1474
|
+
if (l && h2 === I2)
|
|
1415
1475
|
return;
|
|
1416
|
-
|
|
1417
|
-
const
|
|
1476
|
+
N2(), I2 = h2;
|
|
1477
|
+
const D2 = v2(n[A2]);
|
|
1418
1478
|
let Z2;
|
|
1419
1479
|
if (l)
|
|
1420
|
-
Z2 = `${
|
|
1421
|
-
else if (
|
|
1422
|
-
Z2 = `${
|
|
1480
|
+
Z2 = `${D2} ${h2}...`;
|
|
1481
|
+
else if (t === "timer")
|
|
1482
|
+
Z2 = `${D2} ${h2} ${j2(m2)}`;
|
|
1423
1483
|
else {
|
|
1424
|
-
const
|
|
1425
|
-
Z2 = `${
|
|
1484
|
+
const kt = ".".repeat(Math.floor(L2)).slice(0, 3);
|
|
1485
|
+
Z2 = `${D2} ${h2}${kt}`;
|
|
1426
1486
|
}
|
|
1427
|
-
const
|
|
1428
|
-
s.write(
|
|
1429
|
-
},
|
|
1430
|
-
}, 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) => {
|
|
1431
1491
|
if (!p2)
|
|
1432
1492
|
return;
|
|
1433
|
-
p2 = false, clearInterval(
|
|
1434
|
-
const
|
|
1435
|
-
|
|
1436
|
-
`) : s.write(`${
|
|
1437
|
-
`)),
|
|
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();
|
|
1438
1498
|
};
|
|
1439
|
-
return { start:
|
|
1440
|
-
|
|
1441
|
-
}, cancel: (
|
|
1442
|
-
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;
|
|
1443
1503
|
} };
|
|
1444
1504
|
};
|
|
1445
|
-
var
|
|
1446
|
-
var
|
|
1447
|
-
`) ?
|
|
1505
|
+
var jt = { light: w2("\u2500", "-"), heavy: w2("\u2501", "="), block: w2("\u2588", "#") };
|
|
1506
|
+
var it2 = (t, i) => t.includes(`
|
|
1507
|
+
`) ? t.split(`
|
|
1448
1508
|
`).map((s) => i(s)).join(`
|
|
1449
|
-
`) : i(
|
|
1450
|
-
var
|
|
1509
|
+
`) : i(t);
|
|
1510
|
+
var xe = (t) => {
|
|
1451
1511
|
const i = (s, r) => {
|
|
1452
|
-
const
|
|
1512
|
+
const u = s.label ?? String(s.value);
|
|
1453
1513
|
switch (r) {
|
|
1454
1514
|
case "disabled":
|
|
1455
|
-
return `${
|
|
1515
|
+
return `${e("gray", U2)} ${it2(u, (n) => e("gray", n))}${s.hint ? ` ${e("dim", `(${s.hint ?? "disabled"})`)}` : ""}`;
|
|
1456
1516
|
case "selected":
|
|
1457
|
-
return `${
|
|
1517
|
+
return `${it2(u, (n) => e("dim", n))}`;
|
|
1458
1518
|
case "active":
|
|
1459
|
-
return `${
|
|
1519
|
+
return `${e("green", z2)} ${u}${s.hint ? ` ${e("dim", `(${s.hint})`)}` : ""}`;
|
|
1460
1520
|
case "cancelled":
|
|
1461
|
-
return `${
|
|
1521
|
+
return `${it2(u, (n) => e(["strikethrough", "dim"], n))}`;
|
|
1462
1522
|
default:
|
|
1463
|
-
return `${
|
|
1523
|
+
return `${e("dim", U2)} ${it2(u, (n) => e("dim", n))}`;
|
|
1464
1524
|
}
|
|
1465
1525
|
};
|
|
1466
|
-
return new
|
|
1467
|
-
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)}
|
|
1468
1528
|
` : ""}${n}
|
|
1469
1529
|
`;
|
|
1470
1530
|
switch (this.state) {
|
|
1471
1531
|
case "submit": {
|
|
1472
|
-
const
|
|
1473
|
-
return `${
|
|
1532
|
+
const c = s ? `${e("gray", $2)} ` : "", o = W(t.output, i(this.options[this.cursor], "selected"), c);
|
|
1533
|
+
return `${a}${o}`;
|
|
1474
1534
|
}
|
|
1475
1535
|
case "cancel": {
|
|
1476
|
-
const
|
|
1477
|
-
return `${
|
|
1478
|
-
${
|
|
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)}` : ""}`;
|
|
1479
1539
|
}
|
|
1480
1540
|
default: {
|
|
1481
|
-
const
|
|
1482
|
-
`).length,
|
|
1483
|
-
return `${
|
|
1484
|
-
${
|
|
1485
|
-
${
|
|
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}
|
|
1486
1546
|
`;
|
|
1487
1547
|
}
|
|
1488
1548
|
}
|
|
1489
1549
|
} }).prompt();
|
|
1490
1550
|
};
|
|
1491
|
-
var
|
|
1492
|
-
var
|
|
1493
|
-
const i =
|
|
1494
|
-
` : ""}${
|
|
1495
|
-
`, 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 ?? "";
|
|
1496
1556
|
switch (this.state) {
|
|
1497
1557
|
case "error": {
|
|
1498
|
-
const
|
|
1558
|
+
const a = this.error ? ` ${e("yellow", this.error)}` : "", c = i ? `${e("yellow", $2)} ` : "", o = i ? e("yellow", x2) : "";
|
|
1499
1559
|
return `${s.trim()}
|
|
1500
|
-
${
|
|
1501
|
-
${
|
|
1560
|
+
${c}${u}
|
|
1561
|
+
${o}${a}
|
|
1502
1562
|
`;
|
|
1503
1563
|
}
|
|
1504
1564
|
case "submit": {
|
|
1505
|
-
const
|
|
1506
|
-
return `${s}${
|
|
1565
|
+
const a = n ? ` ${e("dim", n)}` : "", c = i ? e("gray", $2) : "";
|
|
1566
|
+
return `${s}${c}${a}`;
|
|
1507
1567
|
}
|
|
1508
1568
|
case "cancel": {
|
|
1509
|
-
const
|
|
1510
|
-
return `${s}${
|
|
1511
|
-
${
|
|
1569
|
+
const a = n ? ` ${e(["strikethrough", "dim"], n)}` : "", c = i ? e("gray", $2) : "";
|
|
1570
|
+
return `${s}${c}${a}${n.trim() ? `
|
|
1571
|
+
${c}` : ""}`;
|
|
1512
1572
|
}
|
|
1513
1573
|
default: {
|
|
1514
|
-
const
|
|
1515
|
-
return `${s}${
|
|
1516
|
-
${
|
|
1574
|
+
const a = i ? `${e("cyan", $2)} ` : "", c = i ? e("cyan", x2) : "";
|
|
1575
|
+
return `${s}${a}${u}
|
|
1576
|
+
${c}
|
|
1517
1577
|
`;
|
|
1518
1578
|
}
|
|
1519
1579
|
}
|
|
@@ -1524,13 +1584,13 @@ async function MultiSelect({
|
|
|
1524
1584
|
message,
|
|
1525
1585
|
options
|
|
1526
1586
|
}) {
|
|
1527
|
-
const selected = await
|
|
1587
|
+
const selected = await ve({
|
|
1528
1588
|
message,
|
|
1529
1589
|
options,
|
|
1530
1590
|
required: true
|
|
1531
1591
|
});
|
|
1532
1592
|
if (q(selected)) {
|
|
1533
|
-
|
|
1593
|
+
me("Operation cancelled.");
|
|
1534
1594
|
process.exit(0);
|
|
1535
1595
|
}
|
|
1536
1596
|
return selected;
|
|
@@ -1551,9 +1611,7 @@ class AddCommand {
|
|
|
1551
1611
|
console.log(`${CHECK({ text: "All changes are either staged or sensitive (like .env)." })}`);
|
|
1552
1612
|
return;
|
|
1553
1613
|
}
|
|
1554
|
-
const options =
|
|
1555
|
-
...changes.map((c2) => ({ value: c2.value, label: c2.label }))
|
|
1556
|
-
];
|
|
1614
|
+
const options = changes.map((c) => ({ value: c.value, label: c.label }));
|
|
1557
1615
|
const selectedChanges = await MultiSelect({
|
|
1558
1616
|
message: `Select the changes you want to commit.
|
|
1559
1617
|
` + BLUE({ text: "[space] to select" }) + `
|
|
@@ -1565,7 +1623,7 @@ class AddCommand {
|
|
|
1565
1623
|
});
|
|
1566
1624
|
let selected = selectedChanges.map((file) => file.trim());
|
|
1567
1625
|
if (selected.includes("all")) {
|
|
1568
|
-
selected = changes.map((
|
|
1626
|
+
selected = changes.map((c) => c.value);
|
|
1569
1627
|
}
|
|
1570
1628
|
if (selected.length > 0) {
|
|
1571
1629
|
await this.stageChangesUseCase.execute(selected);
|
|
@@ -1692,11 +1750,11 @@ class StageChangesUseCase {
|
|
|
1692
1750
|
}
|
|
1693
1751
|
|
|
1694
1752
|
// apps/cli/modules/add/infra/bun-git.repository.ts
|
|
1695
|
-
var {$: $
|
|
1753
|
+
var {$: $3 } = globalThis.Bun;
|
|
1696
1754
|
class BunGitRepository {
|
|
1697
1755
|
async getEntries() {
|
|
1698
1756
|
try {
|
|
1699
|
-
const output = await $
|
|
1757
|
+
const output = await $3`git status --porcelain -z`.quiet().text();
|
|
1700
1758
|
if (!output.trim()) {
|
|
1701
1759
|
return [];
|
|
1702
1760
|
}
|
|
@@ -1723,8 +1781,8 @@ async function addCommand() {
|
|
|
1723
1781
|
const gitRepository = new BunGitRepository;
|
|
1724
1782
|
const getChangesUseCase = new GetChangesUseCase(gitRepository);
|
|
1725
1783
|
const stageChangesUseCase = new StageChangesUseCase(gitRepository);
|
|
1726
|
-
const
|
|
1727
|
-
await
|
|
1784
|
+
const addCmd = new AddCommand(getChangesUseCase, stageChangesUseCase);
|
|
1785
|
+
await addCmd.execute();
|
|
1728
1786
|
}
|
|
1729
1787
|
|
|
1730
1788
|
// apps/cli/alias.ts
|
|
@@ -1833,7 +1891,7 @@ async function Input({
|
|
|
1833
1891
|
message,
|
|
1834
1892
|
placeholder
|
|
1835
1893
|
}) {
|
|
1836
|
-
const value = await
|
|
1894
|
+
const value = await Pe({
|
|
1837
1895
|
message,
|
|
1838
1896
|
placeholder,
|
|
1839
1897
|
validate(input) {
|
|
@@ -1843,7 +1901,7 @@ async function Input({
|
|
|
1843
1901
|
}
|
|
1844
1902
|
});
|
|
1845
1903
|
if (q(value)) {
|
|
1846
|
-
|
|
1904
|
+
me("Operation cancelled.");
|
|
1847
1905
|
process.exit(0);
|
|
1848
1906
|
}
|
|
1849
1907
|
return value.trim();
|
|
@@ -1854,12 +1912,12 @@ async function Select({
|
|
|
1854
1912
|
message,
|
|
1855
1913
|
options
|
|
1856
1914
|
}) {
|
|
1857
|
-
const selected = await
|
|
1915
|
+
const selected = await xe({
|
|
1858
1916
|
message,
|
|
1859
1917
|
options
|
|
1860
1918
|
});
|
|
1861
1919
|
if (q(selected)) {
|
|
1862
|
-
|
|
1920
|
+
me("Operation cancelled.");
|
|
1863
1921
|
process.exit(0);
|
|
1864
1922
|
}
|
|
1865
1923
|
return selected;
|
|
@@ -1907,8 +1965,8 @@ class BunCommitRepository {
|
|
|
1907
1965
|
async function commitCommand() {
|
|
1908
1966
|
const commitRepository = new BunCommitRepository;
|
|
1909
1967
|
const commitUseCase = new CommitUseCase(commitRepository);
|
|
1910
|
-
const
|
|
1911
|
-
await
|
|
1968
|
+
const commitCmd = new CommitCommand(commitUseCase);
|
|
1969
|
+
await commitCmd.execute();
|
|
1912
1970
|
}
|
|
1913
1971
|
|
|
1914
1972
|
// apps/cli/modules/setup/app/setup-aliases.use-case.ts
|
|
@@ -1936,12 +1994,12 @@ async function Confirm({
|
|
|
1936
1994
|
cancelMessage,
|
|
1937
1995
|
exitOnCancel = true
|
|
1938
1996
|
}) {
|
|
1939
|
-
const confirmed = await
|
|
1997
|
+
const confirmed = await ue({
|
|
1940
1998
|
message
|
|
1941
1999
|
});
|
|
1942
2000
|
if (q(confirmed)) {
|
|
1943
2001
|
if (exitOnCancel) {
|
|
1944
|
-
|
|
2002
|
+
me(cancelMessage ?? "Operation cancelled.");
|
|
1945
2003
|
process.exit(0);
|
|
1946
2004
|
}
|
|
1947
2005
|
return null;
|
|
@@ -1951,17 +2009,17 @@ async function Confirm({
|
|
|
1951
2009
|
|
|
1952
2010
|
// apps/cli/utils/intro.ts
|
|
1953
2011
|
function Intro(message) {
|
|
1954
|
-
|
|
2012
|
+
ge(message);
|
|
1955
2013
|
}
|
|
1956
2014
|
|
|
1957
2015
|
// apps/cli/utils/outro.ts
|
|
1958
2016
|
function Outro(message) {
|
|
1959
|
-
|
|
2017
|
+
ye(message);
|
|
1960
2018
|
}
|
|
1961
2019
|
|
|
1962
2020
|
// apps/cli/utils/spinner.ts
|
|
1963
2021
|
function Spinner() {
|
|
1964
|
-
return
|
|
2022
|
+
return ft();
|
|
1965
2023
|
}
|
|
1966
2024
|
|
|
1967
2025
|
// apps/cli/modules/setup/app/setup-command.ts
|
|
@@ -2121,8 +2179,8 @@ class BunAliasRepository {
|
|
|
2121
2179
|
async function setupCommand() {
|
|
2122
2180
|
const aliasRepository = new BunAliasRepository;
|
|
2123
2181
|
const setupAliasesUseCase = new SetupAliasesUseCase(aliasRepository);
|
|
2124
|
-
const
|
|
2125
|
-
await
|
|
2182
|
+
const setupCmd = new SetupCommand(setupAliasesUseCase);
|
|
2183
|
+
await setupCmd.execute();
|
|
2126
2184
|
}
|
|
2127
2185
|
|
|
2128
2186
|
// apps/cli/modules/switch/domain/branch.ts
|
|
@@ -2231,11 +2289,11 @@ class SwitchCommand {
|
|
|
2231
2289
|
}
|
|
2232
2290
|
|
|
2233
2291
|
// apps/cli/modules/switch/infra/bun-switch-repository.ts
|
|
2234
|
-
var {$: $
|
|
2292
|
+
var {$: $4 } = globalThis.Bun;
|
|
2235
2293
|
class BunSwitchRepository {
|
|
2236
2294
|
async getBranches() {
|
|
2237
2295
|
try {
|
|
2238
|
-
const output = await $
|
|
2296
|
+
const output = await $4`git branch -a`.quiet().text();
|
|
2239
2297
|
if (!output.trim()) {
|
|
2240
2298
|
return [];
|
|
2241
2299
|
}
|
|
@@ -2261,8 +2319,8 @@ async function switchCommand() {
|
|
|
2261
2319
|
const switchRepo = new BunSwitchRepository;
|
|
2262
2320
|
const switchBranchUseCase = new SwitchBranch(switchRepo);
|
|
2263
2321
|
const getBranchesUseCase = new GetBranchesUseCase(switchRepo);
|
|
2264
|
-
const
|
|
2265
|
-
await
|
|
2322
|
+
const switchCmd = new SwitchCommand(getBranchesUseCase, switchBranchUseCase);
|
|
2323
|
+
await switchCmd.execute();
|
|
2266
2324
|
}
|
|
2267
2325
|
|
|
2268
2326
|
// apps/cli/commands-fn.ts
|
|
@@ -2276,12 +2334,8 @@ var COMMANDS_FN = {
|
|
|
2276
2334
|
|
|
2277
2335
|
// apps/cli/index.ts
|
|
2278
2336
|
var args = Bun.argv.slice(2);
|
|
2279
|
-
var command = AVAILABLE_COMMANDS.find((
|
|
2280
|
-
if (command) {
|
|
2281
|
-
if (args.length > 1 && !command.allowGitArgs) {
|
|
2282
|
-
console.error("This command does not accept any arguments");
|
|
2283
|
-
process.exit(1);
|
|
2284
|
-
}
|
|
2337
|
+
var command = AVAILABLE_COMMANDS.find((cmd) => cmd.name === args[0]);
|
|
2338
|
+
if (command && args.length === 1) {
|
|
2285
2339
|
await COMMANDS_FN[command.name]?.(args.slice(1));
|
|
2286
2340
|
} else {
|
|
2287
2341
|
const proc = Bun.spawn(["git", ...args], {
|