create-rstack 2.1.1 → 2.1.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/dist/index.d.ts +41 -1
- package/dist/index.js +772 -1067
- package/package.json +17 -19
- package/template-biome/package.json +1 -1
- package/template-eslint/react-js/package.json +2 -2
- package/template-eslint/react-ts/package.json +3 -3
- package/template-eslint/svelte-js/package.json +2 -2
- package/template-eslint/svelte-ts/package.json +3 -3
- package/template-eslint/vanilla-js/package.json +2 -2
- package/template-eslint/vanilla-ts/package.json +3 -3
- package/template-eslint/vue-js/package.json +3 -3
- package/template-eslint/vue-ts/package.json +4 -4
- package/template-rslint/AGENTS.md +4 -0
- package/template-rslint/react-js/package.json +1 -1
- package/template-rslint/react-ts/package.json +1 -1
- package/template-rslint/vanilla-js/package.json +1 -1
- package/template-rslint/vanilla-ts/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
-
import node_fs from "node:fs";
|
|
3
|
-
import node_path, { delimiter, dirname, normalize as external_node_path_normalize, resolve } from "node:path";
|
|
2
|
+
import node_fs, { closeSync, openSync, readSync, statSync } from "node:fs";
|
|
3
|
+
import node_path, { basename, delimiter, dirname, normalize as external_node_path_normalize, resolve } from "node:path";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
5
|
import node_util, { styleText } from "node:util";
|
|
6
6
|
import node_process, { cwd as external_node_process_cwd, stdin, stdout } from "node:process";
|
|
7
7
|
import node_readline from "node:readline";
|
|
8
8
|
import node_tty from "node:tty";
|
|
9
9
|
import node_os from "node:os";
|
|
10
|
-
import { createRequire } from "node:module";
|
|
11
10
|
import { execFileSync, spawn } from "node:child_process";
|
|
12
11
|
import { pipeline } from "node:stream/promises";
|
|
13
12
|
import { PassThrough } from "node:stream";
|
|
@@ -542,11 +541,20 @@ __webpack_require__.add({
|
|
|
542
541
|
module.exports = __rspack_createRequire_require("node:fs/promises");
|
|
543
542
|
}
|
|
544
543
|
});
|
|
545
|
-
const
|
|
544
|
+
const getCodePointsLength = (()=>{
|
|
545
|
+
const SURROGATE_PAIR_RE = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
|
|
546
|
+
return (input)=>{
|
|
547
|
+
let surrogatePairsNr = 0;
|
|
548
|
+
SURROGATE_PAIR_RE.lastIndex = 0;
|
|
549
|
+
while(SURROGATE_PAIR_RE.test(input))surrogatePairsNr += 1;
|
|
550
|
+
return input.length - surrogatePairsNr;
|
|
551
|
+
};
|
|
552
|
+
})();
|
|
546
553
|
const isFullWidth = (x)=>0x3000 === x || x >= 0xFF01 && x <= 0xFF60 || x >= 0xFFE0 && x <= 0xFFE6;
|
|
547
|
-
const
|
|
548
|
-
const ANSI_RE = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y;
|
|
554
|
+
const isWideNotCJKTNotEmoji = (x)=>0x231B === x || 0x2329 === x || x >= 0x2FF0 && x <= 0x2FFF || x >= 0x3001 && x <= 0x303E || x >= 0x3099 && x <= 0x30FF || x >= 0x3105 && x <= 0x312F || x >= 0x3131 && x <= 0x318E || x >= 0x3190 && x <= 0x31E3 || x >= 0x31EF && x <= 0x321E || x >= 0x3220 && x <= 0x3247 || x >= 0x3250 && x <= 0x4DBF || x >= 0xFE10 && x <= 0xFE19 || x >= 0xFE30 && x <= 0xFE52 || x >= 0xFE54 && x <= 0xFE66 || x >= 0xFE68 && x <= 0xFE6B || x >= 0x1F200 && x <= 0x1F202 || x >= 0x1F210 && x <= 0x1F23B || x >= 0x1F240 && x <= 0x1F248 || x >= 0x20000 && x <= 0x2FFFD || x >= 0x30000 && x <= 0x3FFFD;
|
|
555
|
+
const ANSI_RE = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y;
|
|
549
556
|
const CONTROL_RE = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
|
|
557
|
+
const 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;
|
|
550
558
|
const TAB_RE = /\t{1,1000}/y;
|
|
551
559
|
const 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;
|
|
552
560
|
const LATIN_RE = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
|
|
@@ -559,14 +567,39 @@ const getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {
|
|
|
559
567
|
const LIMIT = truncationOptions.limit ?? 1 / 0;
|
|
560
568
|
const ELLIPSIS = truncationOptions.ellipsis ?? '';
|
|
561
569
|
const ELLIPSIS_WIDTH = truncationOptions?.ellipsisWidth ?? (ELLIPSIS ? getStringTruncatedWidth(ELLIPSIS, NO_TRUNCATION, widthOptions).width : 0);
|
|
562
|
-
const ANSI_WIDTH =
|
|
570
|
+
const ANSI_WIDTH = 0;
|
|
563
571
|
const CONTROL_WIDTH = widthOptions.controlWidth ?? 0;
|
|
564
572
|
const TAB_WIDTH = widthOptions.tabWidth ?? 8;
|
|
565
|
-
const AMBIGUOUS_WIDTH = widthOptions.ambiguousWidth ?? 1;
|
|
566
573
|
const EMOJI_WIDTH = widthOptions.emojiWidth ?? 2;
|
|
567
|
-
const FULL_WIDTH_WIDTH =
|
|
574
|
+
const FULL_WIDTH_WIDTH = 2;
|
|
568
575
|
const REGULAR_WIDTH = widthOptions.regularWidth ?? 1;
|
|
569
|
-
const WIDE_WIDTH = widthOptions.wideWidth ??
|
|
576
|
+
const WIDE_WIDTH = widthOptions.wideWidth ?? FULL_WIDTH_WIDTH;
|
|
577
|
+
const PARSE_BLOCKS = [
|
|
578
|
+
[
|
|
579
|
+
LATIN_RE,
|
|
580
|
+
REGULAR_WIDTH
|
|
581
|
+
],
|
|
582
|
+
[
|
|
583
|
+
ANSI_RE,
|
|
584
|
+
ANSI_WIDTH
|
|
585
|
+
],
|
|
586
|
+
[
|
|
587
|
+
CONTROL_RE,
|
|
588
|
+
CONTROL_WIDTH
|
|
589
|
+
],
|
|
590
|
+
[
|
|
591
|
+
TAB_RE,
|
|
592
|
+
TAB_WIDTH
|
|
593
|
+
],
|
|
594
|
+
[
|
|
595
|
+
EMOJI_RE,
|
|
596
|
+
EMOJI_WIDTH
|
|
597
|
+
],
|
|
598
|
+
[
|
|
599
|
+
CJKT_WIDE_RE,
|
|
600
|
+
WIDE_WIDTH
|
|
601
|
+
]
|
|
602
|
+
];
|
|
570
603
|
let indexPrev = 0;
|
|
571
604
|
let index = 0;
|
|
572
605
|
let length = input.length;
|
|
@@ -584,7 +617,7 @@ const getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {
|
|
|
584
617
|
lengthExtra = 0;
|
|
585
618
|
for (const char of unmatched.replaceAll(MODIFIER_RE, '')){
|
|
586
619
|
const codePoint = char.codePointAt(0) || 0;
|
|
587
|
-
widthExtra = isFullWidth(codePoint) ? FULL_WIDTH_WIDTH :
|
|
620
|
+
widthExtra = isFullWidth(codePoint) ? FULL_WIDTH_WIDTH : isWideNotCJKTNotEmoji(codePoint) ? WIDE_WIDTH : REGULAR_WIDTH;
|
|
588
621
|
if (width + widthExtra > truncationLimit) truncationIndex = Math.min(truncationIndex, Math.max(unmatchedStart, indexPrev) + lengthExtra);
|
|
589
622
|
if (width + widthExtra > LIMIT) {
|
|
590
623
|
truncationEnabled = true;
|
|
@@ -596,76 +629,23 @@ const getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {
|
|
|
596
629
|
unmatchedStart = unmatchedEnd = 0;
|
|
597
630
|
}
|
|
598
631
|
if (index >= length) break;
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
if (ANSI_RE.test(input)) {
|
|
616
|
-
if (width + ANSI_WIDTH > truncationLimit) truncationIndex = Math.min(truncationIndex, index);
|
|
617
|
-
if (width + ANSI_WIDTH > LIMIT) {
|
|
618
|
-
truncationEnabled = true;
|
|
619
|
-
break;
|
|
620
|
-
}
|
|
621
|
-
width += ANSI_WIDTH;
|
|
622
|
-
unmatchedStart = indexPrev;
|
|
623
|
-
unmatchedEnd = index;
|
|
624
|
-
index = indexPrev = ANSI_RE.lastIndex;
|
|
625
|
-
continue;
|
|
626
|
-
}
|
|
627
|
-
CONTROL_RE.lastIndex = index;
|
|
628
|
-
if (CONTROL_RE.test(input)) {
|
|
629
|
-
lengthExtra = CONTROL_RE.lastIndex - index;
|
|
630
|
-
widthExtra = lengthExtra * CONTROL_WIDTH;
|
|
631
|
-
if (width + widthExtra > truncationLimit) truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / CONTROL_WIDTH));
|
|
632
|
-
if (width + widthExtra > LIMIT) {
|
|
633
|
-
truncationEnabled = true;
|
|
634
|
-
break;
|
|
635
|
-
}
|
|
636
|
-
width += widthExtra;
|
|
637
|
-
unmatchedStart = indexPrev;
|
|
638
|
-
unmatchedEnd = index;
|
|
639
|
-
index = indexPrev = CONTROL_RE.lastIndex;
|
|
640
|
-
continue;
|
|
641
|
-
}
|
|
642
|
-
TAB_RE.lastIndex = index;
|
|
643
|
-
if (TAB_RE.test(input)) {
|
|
644
|
-
lengthExtra = TAB_RE.lastIndex - index;
|
|
645
|
-
widthExtra = lengthExtra * TAB_WIDTH;
|
|
646
|
-
if (width + widthExtra > truncationLimit) truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / TAB_WIDTH));
|
|
647
|
-
if (width + widthExtra > LIMIT) {
|
|
648
|
-
truncationEnabled = true;
|
|
649
|
-
break;
|
|
650
|
-
}
|
|
651
|
-
width += widthExtra;
|
|
652
|
-
unmatchedStart = indexPrev;
|
|
653
|
-
unmatchedEnd = index;
|
|
654
|
-
index = indexPrev = TAB_RE.lastIndex;
|
|
655
|
-
continue;
|
|
656
|
-
}
|
|
657
|
-
EMOJI_RE.lastIndex = index;
|
|
658
|
-
if (EMOJI_RE.test(input)) {
|
|
659
|
-
if (width + EMOJI_WIDTH > truncationLimit) truncationIndex = Math.min(truncationIndex, index);
|
|
660
|
-
if (width + EMOJI_WIDTH > LIMIT) {
|
|
661
|
-
truncationEnabled = true;
|
|
662
|
-
break;
|
|
632
|
+
for(let i = 0, l = PARSE_BLOCKS.length; i < l; i++){
|
|
633
|
+
const [BLOCK_RE, BLOCK_WIDTH] = PARSE_BLOCKS[i];
|
|
634
|
+
BLOCK_RE.lastIndex = index;
|
|
635
|
+
if (BLOCK_RE.test(input)) {
|
|
636
|
+
lengthExtra = BLOCK_RE === CJKT_WIDE_RE ? getCodePointsLength(input.slice(index, BLOCK_RE.lastIndex)) : BLOCK_RE === EMOJI_RE ? 1 : BLOCK_RE.lastIndex - index;
|
|
637
|
+
widthExtra = lengthExtra * BLOCK_WIDTH;
|
|
638
|
+
if (width + widthExtra > truncationLimit) truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / BLOCK_WIDTH));
|
|
639
|
+
if (width + widthExtra > LIMIT) {
|
|
640
|
+
truncationEnabled = true;
|
|
641
|
+
break outer;
|
|
642
|
+
}
|
|
643
|
+
width += widthExtra;
|
|
644
|
+
unmatchedStart = indexPrev;
|
|
645
|
+
unmatchedEnd = index;
|
|
646
|
+
index = indexPrev = BLOCK_RE.lastIndex;
|
|
647
|
+
continue outer;
|
|
663
648
|
}
|
|
664
|
-
width += EMOJI_WIDTH;
|
|
665
|
-
unmatchedStart = indexPrev;
|
|
666
|
-
unmatchedEnd = index;
|
|
667
|
-
index = indexPrev = EMOJI_RE.lastIndex;
|
|
668
|
-
continue;
|
|
669
649
|
}
|
|
670
650
|
index += 1;
|
|
671
651
|
}
|
|
@@ -823,25 +803,27 @@ const exec = (string, columns, options = {})=>{
|
|
|
823
803
|
for(let i = 0; i < preString.length; i++){
|
|
824
804
|
const character = preString[i];
|
|
825
805
|
returnValue += character;
|
|
826
|
-
if (
|
|
806
|
+
if (inSurrogate) inSurrogate = false;
|
|
807
|
+
else {
|
|
827
808
|
inSurrogate = character >= '\ud800' && character <= '\udbff';
|
|
828
|
-
if (
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
if (
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
809
|
+
if (inSurrogate) continue;
|
|
810
|
+
}
|
|
811
|
+
if (character === ESC || character === CSI) {
|
|
812
|
+
GROUP_REGEX.lastIndex = i + 1;
|
|
813
|
+
const groupsResult = GROUP_REGEX.exec(preString);
|
|
814
|
+
const groups = groupsResult?.groups;
|
|
815
|
+
if (groups?.code !== void 0) {
|
|
816
|
+
const code = Number.parseFloat(groups.code);
|
|
817
|
+
escapeCode = code === END_CODE ? void 0 : code;
|
|
818
|
+
} else if (groups?.uri !== void 0) escapeUrl = 0 === groups.uri.length ? void 0 : groups.uri;
|
|
819
|
+
}
|
|
820
|
+
if ('\n' === preString[i + 1]) {
|
|
821
|
+
if (escapeUrl) returnValue += wrapAnsiHyperlink('');
|
|
822
|
+
const closingCode = escapeCode ? getClosingCode(escapeCode) : void 0;
|
|
823
|
+
if (escapeCode && closingCode) returnValue += wrapAnsiCode(closingCode);
|
|
824
|
+
} else if ('\n' === character) {
|
|
825
|
+
if (escapeCode && getClosingCode(escapeCode)) returnValue += wrapAnsiCode(escapeCode);
|
|
826
|
+
if (escapeUrl) returnValue += wrapAnsiHyperlink(escapeUrl);
|
|
845
827
|
}
|
|
846
828
|
}
|
|
847
829
|
return returnValue;
|
|
@@ -851,12 +833,12 @@ function wrapAnsi(string, columns, options) {
|
|
|
851
833
|
return String(string).normalize().split(CRLF_OR_LF).map((line)=>exec(line, columns, options)).join('\n');
|
|
852
834
|
}
|
|
853
835
|
const src = __webpack_require__("./node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js");
|
|
854
|
-
function
|
|
855
|
-
if (!
|
|
856
|
-
const
|
|
857
|
-
return
|
|
836
|
+
function dist_f(r, t, s) {
|
|
837
|
+
if (!s.some((o)=>!o.disabled)) return r;
|
|
838
|
+
const e = r + t, i = Math.max(s.length - 1, 0), n = e < 0 ? i : e > i ? 0 : e;
|
|
839
|
+
return s[n].disabled ? dist_f(n, t < 0 ? -1 : 1, s) : n;
|
|
858
840
|
}
|
|
859
|
-
const
|
|
841
|
+
const dist_G = [
|
|
860
842
|
"up",
|
|
861
843
|
"down",
|
|
862
844
|
"left",
|
|
@@ -864,7 +846,7 @@ const E = [
|
|
|
864
846
|
"space",
|
|
865
847
|
"enter",
|
|
866
848
|
"cancel"
|
|
867
|
-
],
|
|
849
|
+
], K = [
|
|
868
850
|
"January",
|
|
869
851
|
"February",
|
|
870
852
|
"March",
|
|
@@ -877,8 +859,8 @@ const E = [
|
|
|
877
859
|
"October",
|
|
878
860
|
"November",
|
|
879
861
|
"December"
|
|
880
|
-
],
|
|
881
|
-
actions: new Set(
|
|
862
|
+
], dist_h = {
|
|
863
|
+
actions: new Set(dist_G),
|
|
882
864
|
aliases: new Map([
|
|
883
865
|
[
|
|
884
866
|
"k",
|
|
@@ -912,7 +894,7 @@ const E = [
|
|
|
912
894
|
withGuide: !0,
|
|
913
895
|
date: {
|
|
914
896
|
monthNames: [
|
|
915
|
-
...
|
|
897
|
+
...K
|
|
916
898
|
],
|
|
917
899
|
messages: {
|
|
918
900
|
required: "Please enter a valid date",
|
|
@@ -923,44 +905,47 @@ const E = [
|
|
|
923
905
|
}
|
|
924
906
|
}
|
|
925
907
|
};
|
|
926
|
-
function
|
|
927
|
-
if ("string" == typeof r) return
|
|
928
|
-
for (const
|
|
908
|
+
function dist_C(r, t) {
|
|
909
|
+
if ("string" == typeof r) return dist_h.aliases.get(r) === t;
|
|
910
|
+
for (const s of r)if (void 0 !== s && dist_C(s, t)) return !0;
|
|
929
911
|
return !1;
|
|
930
912
|
}
|
|
931
|
-
function
|
|
913
|
+
function z(r, t) {
|
|
932
914
|
if (r === t) return;
|
|
933
|
-
const
|
|
934
|
-
`),
|
|
935
|
-
`), i = Math.max(
|
|
936
|
-
for(let o = 0; o < i; o++)
|
|
915
|
+
const s = r.split(`
|
|
916
|
+
`), e = t.split(`
|
|
917
|
+
`), i = Math.max(s.length, e.length), n = [];
|
|
918
|
+
for(let o = 0; o < i; o++)s[o] !== e[o] && n.push(o);
|
|
937
919
|
return {
|
|
938
920
|
lines: n,
|
|
939
|
-
numLinesBefore:
|
|
940
|
-
numLinesAfter:
|
|
921
|
+
numLinesBefore: s.length,
|
|
922
|
+
numLinesAfter: e.length,
|
|
941
923
|
numLines: i
|
|
942
924
|
};
|
|
943
925
|
}
|
|
944
926
|
globalThis.process.platform.startsWith("win");
|
|
945
|
-
const
|
|
946
|
-
function
|
|
947
|
-
return r ===
|
|
927
|
+
const dist_k = Symbol("clack:cancel");
|
|
928
|
+
function q(r) {
|
|
929
|
+
return r === dist_k;
|
|
948
930
|
}
|
|
949
931
|
function w(r, t) {
|
|
950
|
-
const
|
|
951
|
-
|
|
932
|
+
const s = r;
|
|
933
|
+
s.isTTY && s.setRawMode(t);
|
|
952
934
|
}
|
|
953
|
-
const
|
|
954
|
-
function
|
|
955
|
-
const
|
|
956
|
-
return wrapAnsi(t,
|
|
935
|
+
const dist_A = (r)=>"columns" in r && "number" == typeof r.columns ? r.columns : 80, dist_L = (r)=>"rows" in r && "number" == typeof r.rows ? r.rows : 20;
|
|
936
|
+
function dist_W(r, t, s, e = s, i = s, n) {
|
|
937
|
+
const o = dist_A(r ?? stdout);
|
|
938
|
+
return wrapAnsi(t, o - s.length, {
|
|
957
939
|
hard: !0,
|
|
958
940
|
trim: !1
|
|
959
941
|
}).split(`
|
|
960
|
-
`).map((
|
|
942
|
+
`).map((u, a, l)=>{
|
|
943
|
+
const c = n ? n(u, a) : u;
|
|
944
|
+
return 0 === a ? `${e}${c}` : a === l.length - 1 ? `${i}${c}` : `${s}${c}`;
|
|
945
|
+
}).join(`
|
|
961
946
|
`);
|
|
962
947
|
}
|
|
963
|
-
let
|
|
948
|
+
let dist_m = class {
|
|
964
949
|
input;
|
|
965
950
|
output;
|
|
966
951
|
_abortSignal;
|
|
@@ -975,37 +960,37 @@ let dist_p = class {
|
|
|
975
960
|
error = "";
|
|
976
961
|
value;
|
|
977
962
|
userInput = "";
|
|
978
|
-
constructor(t,
|
|
979
|
-
const { input:
|
|
980
|
-
this.opts =
|
|
963
|
+
constructor(t, s = !0){
|
|
964
|
+
const { input: e = stdin, output: i = stdout, render: n, signal: o, ...u } = t;
|
|
965
|
+
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;
|
|
981
966
|
}
|
|
982
967
|
unsubscribe() {
|
|
983
968
|
this._subscribers.clear();
|
|
984
969
|
}
|
|
985
|
-
setSubscriber(t,
|
|
986
|
-
const
|
|
987
|
-
|
|
970
|
+
setSubscriber(t, s) {
|
|
971
|
+
const e = this._subscribers.get(t) ?? [];
|
|
972
|
+
e.push(s), this._subscribers.set(t, e);
|
|
988
973
|
}
|
|
989
|
-
on(t,
|
|
974
|
+
on(t, s) {
|
|
990
975
|
this.setSubscriber(t, {
|
|
991
|
-
cb:
|
|
976
|
+
cb: s
|
|
992
977
|
});
|
|
993
978
|
}
|
|
994
|
-
once(t,
|
|
979
|
+
once(t, s) {
|
|
995
980
|
this.setSubscriber(t, {
|
|
996
|
-
cb:
|
|
981
|
+
cb: s,
|
|
997
982
|
once: !0
|
|
998
983
|
});
|
|
999
984
|
}
|
|
1000
|
-
emit(t, ...
|
|
1001
|
-
const
|
|
1002
|
-
for (const n of
|
|
985
|
+
emit(t, ...s) {
|
|
986
|
+
const e = this._subscribers.get(t) ?? [], i = [];
|
|
987
|
+
for (const n of e)n.cb(...s), n.once && i.push(()=>e.splice(e.indexOf(n), 1));
|
|
1003
988
|
for (const n of i)n();
|
|
1004
989
|
}
|
|
1005
990
|
prompt() {
|
|
1006
991
|
return new Promise((t)=>{
|
|
1007
992
|
if (this._abortSignal) {
|
|
1008
|
-
if (this._abortSignal.aborted) return this.state = "cancel", this.close(), t(
|
|
993
|
+
if (this._abortSignal.aborted) return this.state = "cancel", this.close(), t(dist_k);
|
|
1009
994
|
this._abortSignal.addEventListener("abort", ()=>{
|
|
1010
995
|
this.state = "cancel", this.close();
|
|
1011
996
|
}, {
|
|
@@ -1021,18 +1006,21 @@ let dist_p = class {
|
|
|
1021
1006
|
}), this.rl.prompt(), void 0 !== this.opts.initialUserInput && this._setUserInput(this.opts.initialUserInput, !0), this.input.on("keypress", this.onKeypress), w(this.input, !0), this.output.on("resize", this.render), this.render(), this.once("submit", ()=>{
|
|
1022
1007
|
this.output.write(src.cursor.show), this.output.off("resize", this.render), w(this.input, !1), t(this.value);
|
|
1023
1008
|
}), this.once("cancel", ()=>{
|
|
1024
|
-
this.output.write(src.cursor.show), this.output.off("resize", this.render), w(this.input, !1), t(
|
|
1009
|
+
this.output.write(src.cursor.show), this.output.off("resize", this.render), w(this.input, !1), t(dist_k);
|
|
1025
1010
|
});
|
|
1026
1011
|
});
|
|
1027
1012
|
}
|
|
1028
|
-
_isActionKey(t,
|
|
1013
|
+
_isActionKey(t, s) {
|
|
1029
1014
|
return " " === t;
|
|
1030
1015
|
}
|
|
1016
|
+
_shouldSubmit(t, s) {
|
|
1017
|
+
return !0;
|
|
1018
|
+
}
|
|
1031
1019
|
_setValue(t) {
|
|
1032
1020
|
this.value = t, this.emit("value", this.value);
|
|
1033
1021
|
}
|
|
1034
|
-
_setUserInput(t,
|
|
1035
|
-
this.userInput = t ?? "", this.emit("userInput", this.userInput),
|
|
1022
|
+
_setUserInput(t, s) {
|
|
1023
|
+
this.userInput = t ?? "", this.emit("userInput", this.userInput), s && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
|
|
1036
1024
|
}
|
|
1037
1025
|
_clearUserInput() {
|
|
1038
1026
|
this.rl?.write(null, {
|
|
@@ -1040,21 +1028,21 @@ let dist_p = class {
|
|
|
1040
1028
|
name: "u"
|
|
1041
1029
|
}), this._setUserInput("");
|
|
1042
1030
|
}
|
|
1043
|
-
onKeypress(t,
|
|
1044
|
-
if (this._track && "return" !==
|
|
1031
|
+
onKeypress(t, s) {
|
|
1032
|
+
if (this._track && "return" !== s.name && (s.name && this._isActionKey(t, s) && this.rl?.write(null, {
|
|
1045
1033
|
ctrl: !0,
|
|
1046
1034
|
name: "h"
|
|
1047
|
-
}), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), "error" === this.state && (this.state = "active"),
|
|
1035
|
+
}), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), "error" === this.state && (this.state = "active"), s?.name && (!this._track && dist_h.aliases.has(s.name) && this.emit("cursor", dist_h.aliases.get(s.name)), dist_h.actions.has(s.name) && this.emit("cursor", s.name)), t && ("y" === t.toLowerCase() || "n" === t.toLowerCase()) && this.emit("confirm", "y" === t.toLowerCase()), this.emit("key", t?.toLowerCase(), s), s?.name === "return" && this._shouldSubmit(t, s)) {
|
|
1048
1036
|
if (this.opts.validate) {
|
|
1049
|
-
const
|
|
1050
|
-
|
|
1037
|
+
const e = this.opts.validate(this.value);
|
|
1038
|
+
e && (this.error = e instanceof Error ? e.message : e, this.state = "error", this.rl?.write(this.userInput));
|
|
1051
1039
|
}
|
|
1052
1040
|
"error" !== this.state && (this.state = "submit");
|
|
1053
1041
|
}
|
|
1054
|
-
|
|
1042
|
+
dist_C([
|
|
1055
1043
|
t,
|
|
1056
|
-
|
|
1057
|
-
|
|
1044
|
+
s?.name,
|
|
1045
|
+
s?.sequence
|
|
1058
1046
|
], "cancel") && (this.state = "cancel"), ("submit" === this.state || "cancel" === this.state) && this.emit("finalize"), this.render(), ("submit" === this.state || "cancel" === this.state) && this.close();
|
|
1059
1047
|
}
|
|
1060
1048
|
close() {
|
|
@@ -1077,31 +1065,31 @@ let dist_p = class {
|
|
|
1077
1065
|
if (t !== this._prevFrame) {
|
|
1078
1066
|
if ("initial" === this.state) this.output.write(src.cursor.hide);
|
|
1079
1067
|
else {
|
|
1080
|
-
const
|
|
1081
|
-
if (this.restoreCursor(),
|
|
1082
|
-
const i = Math.max(0,
|
|
1083
|
-
let o =
|
|
1068
|
+
const s = z(this._prevFrame, t), e = dist_L(this.output);
|
|
1069
|
+
if (this.restoreCursor(), s) {
|
|
1070
|
+
const i = Math.max(0, s.numLinesAfter - e), n = Math.max(0, s.numLinesBefore - e);
|
|
1071
|
+
let o = s.lines.find((u)=>u >= i);
|
|
1084
1072
|
if (void 0 === o) {
|
|
1085
1073
|
this._prevFrame = t;
|
|
1086
1074
|
return;
|
|
1087
1075
|
}
|
|
1088
|
-
if (1 ===
|
|
1076
|
+
if (1 === s.lines.length) {
|
|
1089
1077
|
this.output.write(src.cursor.move(0, o - n)), this.output.write(src.erase.lines(1));
|
|
1090
|
-
const
|
|
1078
|
+
const u = t.split(`
|
|
1091
1079
|
`);
|
|
1092
|
-
this.output.write(
|
|
1080
|
+
this.output.write(u[o]), this._prevFrame = t, this.output.write(src.cursor.move(0, u.length - o - 1));
|
|
1093
1081
|
return;
|
|
1094
1082
|
}
|
|
1095
|
-
if (
|
|
1083
|
+
if (s.lines.length > 1) {
|
|
1096
1084
|
if (i < n) o = i;
|
|
1097
1085
|
else {
|
|
1098
|
-
const
|
|
1099
|
-
|
|
1086
|
+
const a = o - n;
|
|
1087
|
+
a > 0 && this.output.write(src.cursor.move(0, a));
|
|
1100
1088
|
}
|
|
1101
1089
|
this.output.write(src.erase.down());
|
|
1102
|
-
const
|
|
1090
|
+
const u = t.split(`
|
|
1103
1091
|
`).slice(o);
|
|
1104
|
-
this.output.write(
|
|
1092
|
+
this.output.write(u.join(`
|
|
1105
1093
|
`)), this._prevFrame = t;
|
|
1106
1094
|
return;
|
|
1107
1095
|
}
|
|
@@ -1112,30 +1100,30 @@ let dist_p = class {
|
|
|
1112
1100
|
}
|
|
1113
1101
|
}
|
|
1114
1102
|
};
|
|
1115
|
-
function
|
|
1103
|
+
function dist_B(r, t) {
|
|
1116
1104
|
if (void 0 === r || 0 === t.length) return 0;
|
|
1117
|
-
const
|
|
1118
|
-
return -1 !==
|
|
1105
|
+
const s = t.findIndex((e)=>e.value === r);
|
|
1106
|
+
return -1 !== s ? s : 0;
|
|
1119
1107
|
}
|
|
1120
|
-
function
|
|
1108
|
+
function dist_J(r, t) {
|
|
1121
1109
|
return (t.label ?? String(t.value)).toLowerCase().includes(r.toLowerCase());
|
|
1122
1110
|
}
|
|
1123
|
-
function
|
|
1111
|
+
function H(r, t) {
|
|
1124
1112
|
if (t) return r ? t : t[0];
|
|
1125
1113
|
}
|
|
1126
|
-
let
|
|
1114
|
+
let Q = class extends dist_m {
|
|
1127
1115
|
filteredOptions;
|
|
1128
1116
|
multiple;
|
|
1129
1117
|
isNavigating = !1;
|
|
1130
1118
|
selectedValues = [];
|
|
1131
1119
|
focusedValue;
|
|
1132
|
-
#
|
|
1133
|
-
#
|
|
1120
|
+
#s = 0;
|
|
1121
|
+
#r = "";
|
|
1134
1122
|
#t;
|
|
1135
1123
|
#n;
|
|
1136
|
-
#
|
|
1124
|
+
#u;
|
|
1137
1125
|
get cursor() {
|
|
1138
|
-
return this.#
|
|
1126
|
+
return this.#s;
|
|
1139
1127
|
}
|
|
1140
1128
|
get userInputWithCursor() {
|
|
1141
1129
|
if (!this.userInput) return styleText([
|
|
@@ -1143,39 +1131,39 @@ let H = class extends dist_p {
|
|
|
1143
1131
|
"hidden"
|
|
1144
1132
|
], "_");
|
|
1145
1133
|
if (this._cursor >= this.userInput.length) return `${this.userInput}\u2588`;
|
|
1146
|
-
const t = this.userInput.slice(0, this._cursor), [
|
|
1147
|
-
return `${t}${styleText("inverse",
|
|
1134
|
+
const t = this.userInput.slice(0, this._cursor), [s, ...e] = this.userInput.slice(this._cursor);
|
|
1135
|
+
return `${t}${styleText("inverse", s)}${e.join("")}`;
|
|
1148
1136
|
}
|
|
1149
1137
|
get options() {
|
|
1150
1138
|
return "function" == typeof this.#n ? this.#n() : this.#n;
|
|
1151
1139
|
}
|
|
1152
1140
|
constructor(t){
|
|
1153
|
-
super(t), this.#n = t.options, this.#
|
|
1154
|
-
const
|
|
1141
|
+
super(t), this.#n = t.options, this.#u = t.placeholder;
|
|
1142
|
+
const s = this.options;
|
|
1155
1143
|
this.filteredOptions = [
|
|
1156
|
-
...
|
|
1157
|
-
], this.multiple = !0 === t.multiple, this.#t = "function" == typeof t.options ? t.filter : t.filter ??
|
|
1158
|
-
let
|
|
1159
|
-
if (t.initialValue && Array.isArray(t.initialValue) ? this.multiple ?
|
|
1144
|
+
...s
|
|
1145
|
+
], this.multiple = !0 === t.multiple, this.#t = "function" == typeof t.options ? t.filter : t.filter ?? dist_J;
|
|
1146
|
+
let e;
|
|
1147
|
+
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 = [
|
|
1160
1148
|
this.options[0].value
|
|
1161
|
-
]),
|
|
1162
|
-
const n =
|
|
1163
|
-
-1 !== n && (this.toggleSelected(i), this.#
|
|
1149
|
+
]), e) for (const i of e){
|
|
1150
|
+
const n = s.findIndex((o)=>o.value === i);
|
|
1151
|
+
-1 !== n && (this.toggleSelected(i), this.#s = n);
|
|
1164
1152
|
}
|
|
1165
|
-
this.focusedValue = this.options[this.#
|
|
1153
|
+
this.focusedValue = this.options[this.#s]?.value, this.on("key", (i, n)=>this.#e(i, n)), this.on("userInput", (i)=>this.#i(i));
|
|
1166
1154
|
}
|
|
1167
|
-
_isActionKey(t,
|
|
1168
|
-
return " " === t || this.multiple && this.isNavigating && "space" ===
|
|
1155
|
+
_isActionKey(t, s) {
|
|
1156
|
+
return " " === t || this.multiple && this.isNavigating && "space" === s.name && void 0 !== t && "" !== t;
|
|
1169
1157
|
}
|
|
1170
|
-
#
|
|
1171
|
-
const
|
|
1172
|
-
if ("tab" ===
|
|
1173
|
-
" " === this.userInput && this._clearUserInput(), this._setUserInput(
|
|
1158
|
+
#e(t, s) {
|
|
1159
|
+
const e = "up" === s.name, i = "down" === s.name, n = "return" === s.name, o = "" === this.userInput || " " === this.userInput, u = this.#u, a = this.options, l = void 0 !== u && "" !== u && a.some((c)=>!c.disabled && (this.#t ? this.#t(u, c) : !0));
|
|
1160
|
+
if ("tab" === s.name && o && l) {
|
|
1161
|
+
" " === this.userInput && this._clearUserInput(), this._setUserInput(u, !0), this.isNavigating = !1;
|
|
1174
1162
|
return;
|
|
1175
1163
|
}
|
|
1176
|
-
|
|
1164
|
+
e || i ? (this.#s = dist_f(this.#s, e ? -1 : 1, this.filteredOptions), this.focusedValue = this.filteredOptions[this.#s]?.value, this.multiple || (this.selectedValues = [
|
|
1177
1165
|
this.focusedValue
|
|
1178
|
-
]), this.isNavigating = !0) : n ? this.value =
|
|
1166
|
+
]), this.isNavigating = !0) : n ? this.value = H(this.multiple, this.selectedValues) : this.multiple ? void 0 !== this.focusedValue && ("tab" === s.name || this.isNavigating && "space" === s.name) ? this.toggleSelected(this.focusedValue) : this.isNavigating = !1 : (this.focusedValue && (this.selectedValues = [
|
|
1179
1167
|
this.focusedValue
|
|
1180
1168
|
]), this.isNavigating = !1);
|
|
1181
1169
|
}
|
|
@@ -1183,7 +1171,7 @@ let H = class extends dist_p {
|
|
|
1183
1171
|
this.selectedValues = [];
|
|
1184
1172
|
}
|
|
1185
1173
|
toggleSelected(t) {
|
|
1186
|
-
0 !== this.filteredOptions.length && (this.multiple ? this.selectedValues.includes(t) ? this.selectedValues = this.selectedValues.filter((
|
|
1174
|
+
0 !== this.filteredOptions.length && (this.multiple ? this.selectedValues.includes(t) ? this.selectedValues = this.selectedValues.filter((s)=>s !== t) : this.selectedValues = [
|
|
1187
1175
|
...this.selectedValues,
|
|
1188
1176
|
t
|
|
1189
1177
|
] : this.selectedValues = [
|
|
@@ -1191,41 +1179,41 @@ let H = class extends dist_p {
|
|
|
1191
1179
|
]);
|
|
1192
1180
|
}
|
|
1193
1181
|
#i(t) {
|
|
1194
|
-
if (t !== this.#
|
|
1195
|
-
this.#
|
|
1196
|
-
const
|
|
1197
|
-
t && this.#t ? this.filteredOptions =
|
|
1198
|
-
...
|
|
1182
|
+
if (t !== this.#r) {
|
|
1183
|
+
this.#r = t;
|
|
1184
|
+
const s = this.options;
|
|
1185
|
+
t && this.#t ? this.filteredOptions = s.filter((n)=>this.#t?.(t, n)) : this.filteredOptions = [
|
|
1186
|
+
...s
|
|
1199
1187
|
];
|
|
1200
|
-
const
|
|
1201
|
-
this.#
|
|
1202
|
-
const i = this.filteredOptions[this.#
|
|
1188
|
+
const e = dist_B(this.focusedValue, this.filteredOptions);
|
|
1189
|
+
this.#s = dist_f(e, 0, this.filteredOptions);
|
|
1190
|
+
const i = this.filteredOptions[this.#s];
|
|
1203
1191
|
i && !i.disabled ? this.focusedValue = i.value : this.focusedValue = void 0, this.multiple || (void 0 !== this.focusedValue ? this.toggleSelected(this.focusedValue) : this.deselectAll());
|
|
1204
1192
|
}
|
|
1205
1193
|
}
|
|
1206
1194
|
};
|
|
1207
|
-
class
|
|
1195
|
+
class it extends dist_m {
|
|
1208
1196
|
options;
|
|
1209
1197
|
cursor = 0;
|
|
1210
|
-
#
|
|
1198
|
+
#s;
|
|
1211
1199
|
getGroupItems(t) {
|
|
1212
|
-
return this.options.filter((
|
|
1200
|
+
return this.options.filter((s)=>s.group === t);
|
|
1213
1201
|
}
|
|
1214
1202
|
isGroupSelected(t) {
|
|
1215
|
-
const
|
|
1216
|
-
return void 0 ===
|
|
1203
|
+
const s = this.getGroupItems(t), e = this.value;
|
|
1204
|
+
return void 0 === e ? !1 : s.every((i)=>e.includes(i.value));
|
|
1217
1205
|
}
|
|
1218
1206
|
toggleValue() {
|
|
1219
1207
|
const t = this.options[this.cursor];
|
|
1220
1208
|
if (void 0 === this.value && (this.value = []), !0 === t.group) {
|
|
1221
|
-
const
|
|
1222
|
-
this.isGroupSelected(
|
|
1209
|
+
const s = t.value, e = this.getGroupItems(s);
|
|
1210
|
+
this.isGroupSelected(s) ? this.value = this.value.filter((i)=>-1 === e.findIndex((n)=>n.value === i)) : this.value = [
|
|
1223
1211
|
...this.value,
|
|
1224
|
-
...
|
|
1212
|
+
...e.map((i)=>i.value)
|
|
1225
1213
|
], this.value = Array.from(new Set(this.value));
|
|
1226
1214
|
} else {
|
|
1227
|
-
const
|
|
1228
|
-
this.value =
|
|
1215
|
+
const s = this.value.includes(t.value);
|
|
1216
|
+
this.value = s ? this.value.filter((e)=>e !== t.value) : [
|
|
1229
1217
|
...this.value,
|
|
1230
1218
|
t.value
|
|
1231
1219
|
];
|
|
@@ -1233,27 +1221,27 @@ class st extends dist_p {
|
|
|
1233
1221
|
}
|
|
1234
1222
|
constructor(t){
|
|
1235
1223
|
super(t, !1);
|
|
1236
|
-
const { options:
|
|
1237
|
-
this.#
|
|
1224
|
+
const { options: s } = t;
|
|
1225
|
+
this.#s = !1 !== t.selectableGroups, this.options = Object.entries(s).flatMap(([e, i])=>[
|
|
1238
1226
|
{
|
|
1239
|
-
value:
|
|
1227
|
+
value: e,
|
|
1240
1228
|
group: !0,
|
|
1241
|
-
label:
|
|
1229
|
+
label: e
|
|
1242
1230
|
},
|
|
1243
1231
|
...i.map((n)=>({
|
|
1244
1232
|
...n,
|
|
1245
|
-
group:
|
|
1233
|
+
group: e
|
|
1246
1234
|
}))
|
|
1247
1235
|
]), this.value = [
|
|
1248
1236
|
...t.initialValues ?? []
|
|
1249
|
-
], this.cursor = Math.max(this.options.findIndex(({ value:
|
|
1250
|
-
switch(
|
|
1237
|
+
], this.cursor = Math.max(this.options.findIndex(({ value: e })=>e === t.cursorAt), this.#s ? 0 : 1), this.on("cursor", (e)=>{
|
|
1238
|
+
switch(e){
|
|
1251
1239
|
case "left":
|
|
1252
1240
|
case "up":
|
|
1253
1241
|
{
|
|
1254
1242
|
this.cursor = 0 === this.cursor ? this.options.length - 1 : this.cursor - 1;
|
|
1255
1243
|
const i = this.options[this.cursor]?.group === !0;
|
|
1256
|
-
!this.#
|
|
1244
|
+
!this.#s && i && (this.cursor = 0 === this.cursor ? this.options.length - 1 : this.cursor - 1);
|
|
1257
1245
|
break;
|
|
1258
1246
|
}
|
|
1259
1247
|
case "down":
|
|
@@ -1261,7 +1249,7 @@ class st extends dist_p {
|
|
|
1261
1249
|
{
|
|
1262
1250
|
this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
|
|
1263
1251
|
const i = this.options[this.cursor]?.group === !0;
|
|
1264
|
-
!this.#
|
|
1252
|
+
!this.#s && i && (this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1);
|
|
1265
1253
|
break;
|
|
1266
1254
|
}
|
|
1267
1255
|
case "space":
|
|
@@ -1271,7 +1259,7 @@ class st extends dist_p {
|
|
|
1271
1259
|
});
|
|
1272
1260
|
}
|
|
1273
1261
|
}
|
|
1274
|
-
let
|
|
1262
|
+
let dist_nt = class extends dist_m {
|
|
1275
1263
|
options;
|
|
1276
1264
|
cursor = 0;
|
|
1277
1265
|
get _value() {
|
|
@@ -1281,19 +1269,19 @@ let it = class extends dist_p {
|
|
|
1281
1269
|
return this.options.filter((t)=>!0 !== t.disabled);
|
|
1282
1270
|
}
|
|
1283
1271
|
toggleAll() {
|
|
1284
|
-
const t = this._enabledOptions,
|
|
1285
|
-
this.value =
|
|
1272
|
+
const t = this._enabledOptions, s = void 0 !== this.value && this.value.length === t.length;
|
|
1273
|
+
this.value = s ? [] : t.map((e)=>e.value);
|
|
1286
1274
|
}
|
|
1287
1275
|
toggleInvert() {
|
|
1288
1276
|
const t = this.value;
|
|
1289
1277
|
if (!t) return;
|
|
1290
|
-
const
|
|
1291
|
-
this.value =
|
|
1278
|
+
const s = this._enabledOptions.filter((e)=>!t.includes(e.value));
|
|
1279
|
+
this.value = s.map((e)=>e.value);
|
|
1292
1280
|
}
|
|
1293
1281
|
toggleValue() {
|
|
1294
1282
|
void 0 === this.value && (this.value = []);
|
|
1295
1283
|
const t = this.value.includes(this._value);
|
|
1296
|
-
this.value = t ? this.value.filter((
|
|
1284
|
+
this.value = t ? this.value.filter((s)=>s !== this._value) : [
|
|
1297
1285
|
...this.value,
|
|
1298
1286
|
this._value
|
|
1299
1287
|
];
|
|
@@ -1302,18 +1290,18 @@ let it = class extends dist_p {
|
|
|
1302
1290
|
super(t, !1), this.options = t.options, this.value = [
|
|
1303
1291
|
...t.initialValues ?? []
|
|
1304
1292
|
];
|
|
1305
|
-
const
|
|
1306
|
-
this.cursor = this.options[
|
|
1307
|
-
"a" ===
|
|
1308
|
-
}), this.on("cursor", (
|
|
1309
|
-
switch(
|
|
1293
|
+
const s = Math.max(this.options.findIndex(({ value: e })=>e === t.cursorAt), 0);
|
|
1294
|
+
this.cursor = this.options[s].disabled ? dist_f(s, 1, this.options) : s, this.on("key", (e)=>{
|
|
1295
|
+
"a" === e && this.toggleAll(), "i" === e && this.toggleInvert();
|
|
1296
|
+
}), this.on("cursor", (e)=>{
|
|
1297
|
+
switch(e){
|
|
1310
1298
|
case "left":
|
|
1311
1299
|
case "up":
|
|
1312
|
-
this.cursor =
|
|
1300
|
+
this.cursor = dist_f(this.cursor, -1, this.options);
|
|
1313
1301
|
break;
|
|
1314
1302
|
case "down":
|
|
1315
1303
|
case "right":
|
|
1316
|
-
this.cursor =
|
|
1304
|
+
this.cursor = dist_f(this.cursor, 1, this.options);
|
|
1317
1305
|
break;
|
|
1318
1306
|
case "space":
|
|
1319
1307
|
this.toggleValue();
|
|
@@ -1322,7 +1310,7 @@ let it = class extends dist_p {
|
|
|
1322
1310
|
});
|
|
1323
1311
|
}
|
|
1324
1312
|
};
|
|
1325
|
-
class
|
|
1313
|
+
class ut extends dist_m {
|
|
1326
1314
|
options;
|
|
1327
1315
|
cursor = 0;
|
|
1328
1316
|
get _selectedValue() {
|
|
@@ -1333,29 +1321,29 @@ class nt extends dist_p {
|
|
|
1333
1321
|
}
|
|
1334
1322
|
constructor(t){
|
|
1335
1323
|
super(t, !1), this.options = t.options;
|
|
1336
|
-
const
|
|
1337
|
-
this.cursor = this.options[
|
|
1324
|
+
const s = this.options.findIndex(({ value: i })=>i === t.initialValue), e = -1 === s ? 0 : s;
|
|
1325
|
+
this.cursor = this.options[e].disabled ? dist_f(e, 1, this.options) : e, this.changeValue(), this.on("cursor", (i)=>{
|
|
1338
1326
|
switch(i){
|
|
1339
1327
|
case "left":
|
|
1340
1328
|
case "up":
|
|
1341
|
-
this.cursor =
|
|
1329
|
+
this.cursor = dist_f(this.cursor, -1, this.options);
|
|
1342
1330
|
break;
|
|
1343
1331
|
case "down":
|
|
1344
1332
|
case "right":
|
|
1345
|
-
this.cursor =
|
|
1333
|
+
this.cursor = dist_f(this.cursor, 1, this.options);
|
|
1346
1334
|
break;
|
|
1347
1335
|
}
|
|
1348
1336
|
this.changeValue();
|
|
1349
1337
|
});
|
|
1350
1338
|
}
|
|
1351
1339
|
}
|
|
1352
|
-
class
|
|
1340
|
+
class ht extends dist_m {
|
|
1353
1341
|
get userInputWithCursor() {
|
|
1354
1342
|
if ("submit" === this.state) return this.userInput;
|
|
1355
1343
|
const t = this.userInput;
|
|
1356
1344
|
if (this.cursor >= t.length) return `${this.userInput}\u2588`;
|
|
1357
|
-
const
|
|
1358
|
-
return `${
|
|
1345
|
+
const s = t.slice(0, this.cursor), [e, ...i] = t.slice(this.cursor);
|
|
1346
|
+
return `${s}${styleText("inverse", e)}${i.join("")}`;
|
|
1359
1347
|
}
|
|
1360
1348
|
get cursor() {
|
|
1361
1349
|
return this._cursor;
|
|
@@ -1364,215 +1352,213 @@ class at extends dist_p {
|
|
|
1364
1352
|
super({
|
|
1365
1353
|
...t,
|
|
1366
1354
|
initialUserInput: t.initialUserInput ?? t.initialValue
|
|
1367
|
-
}), this.on("userInput", (
|
|
1368
|
-
this._setValue(
|
|
1355
|
+
}), this.on("userInput", (s)=>{
|
|
1356
|
+
this._setValue(s);
|
|
1369
1357
|
}), this.on("finalize", ()=>{
|
|
1370
1358
|
this.value || (this.value = t.defaultValue), void 0 === this.value && (this.value = "");
|
|
1371
1359
|
});
|
|
1372
1360
|
}
|
|
1373
1361
|
}
|
|
1374
|
-
function
|
|
1362
|
+
function ee() {
|
|
1375
1363
|
return "win32" !== node_process.platform ? "linux" !== node_process.env.TERM : !!node_process.env.CI || !!node_process.env.WT_SESSION || !!node_process.env.TERMINUS_SUBLIME || "{cmd::Cmder}" === node_process.env.ConEmuTask || "Terminus-Sublime" === node_process.env.TERM_PROGRAM || "vscode" === node_process.env.TERM_PROGRAM || "xterm-256color" === node_process.env.TERM || "alacritty" === node_process.env.TERM || "JetBrains-JediTerm" === node_process.env.TERMINAL_EMULATOR;
|
|
1376
1364
|
}
|
|
1377
|
-
const
|
|
1378
|
-
switch(
|
|
1365
|
+
const dist_tt = ee(), dist_ot = ()=>"true" === process.env.CI, It = (t)=>!0 === t.isTTY, dist_w = (t, i)=>dist_tt ? t : i, Tt = dist_w("\u25C6", "*"), dist_at = dist_w("\u25A0", "x"), dist_ut = dist_w("\u25B2", "x"), dist_H = dist_w("\u25C7", "o"), dist_$ = (dist_w("\u250C", "T"), dist_w("\u2502", "|")), dist_x = dist_w("\u2514", "\u2014"), dist_z = (dist_w("\u2510", "T"), dist_w("\u2518", "\u2014"), dist_w("\u25CF", ">")), dist_U = dist_w("\u25CB", " "), dist_et = dist_w("\u25FB", "[\u2022]"), dist_K = dist_w("\u25FC", "[+]"), dist_Y = dist_w("\u25FB", "[ ]"), dist_st = (dist_w("\u25AA", "\u2022"), dist_w("\u2500", "-")), ct = dist_w("\u256E", "+"), Gt = dist_w("\u251C", "+"), $t = dist_w("\u256F", "+"), dt = dist_w("\u2570", "+"), dist_ht = (dist_w("\u256D", "+"), dist_w("\u25CF", "\u2022")), pt = dist_w("\u25C6", "*"), mt = dist_w("\u25B2", "!"), gt = dist_w("\u25A0", "x"), dist_P = (t)=>{
|
|
1366
|
+
switch(t){
|
|
1379
1367
|
case "initial":
|
|
1380
1368
|
case "active":
|
|
1381
|
-
return styleText("cyan",
|
|
1369
|
+
return styleText("cyan", Tt);
|
|
1382
1370
|
case "cancel":
|
|
1383
|
-
return styleText("red",
|
|
1371
|
+
return styleText("red", dist_at);
|
|
1384
1372
|
case "error":
|
|
1385
|
-
return styleText("yellow",
|
|
1373
|
+
return styleText("yellow", dist_ut);
|
|
1386
1374
|
case "submit":
|
|
1387
|
-
return styleText("green",
|
|
1375
|
+
return styleText("green", dist_H);
|
|
1388
1376
|
}
|
|
1389
|
-
},
|
|
1390
|
-
switch(
|
|
1377
|
+
}, yt = (t)=>{
|
|
1378
|
+
switch(t){
|
|
1391
1379
|
case "initial":
|
|
1392
1380
|
case "active":
|
|
1393
|
-
return styleText("cyan",
|
|
1381
|
+
return styleText("cyan", dist_$);
|
|
1394
1382
|
case "cancel":
|
|
1395
|
-
return styleText("red",
|
|
1383
|
+
return styleText("red", dist_$);
|
|
1396
1384
|
case "error":
|
|
1397
|
-
return styleText("yellow",
|
|
1385
|
+
return styleText("yellow", dist_$);
|
|
1398
1386
|
case "submit":
|
|
1399
|
-
return styleText("green",
|
|
1400
|
-
}
|
|
1401
|
-
}, dist_et = (e, i, s, r, u)=>{
|
|
1402
|
-
let n = i, o = 0;
|
|
1403
|
-
for(let c = s; c < r; c++){
|
|
1404
|
-
const a = e[c];
|
|
1405
|
-
if (n -= a.length, o++, n <= u) break;
|
|
1387
|
+
return styleText("green", dist_$);
|
|
1406
1388
|
}
|
|
1389
|
+
}, Ot = (t, i, s, r, u, n = !1)=>{
|
|
1390
|
+
let a = i, c = 0;
|
|
1391
|
+
if (n) for(let o = r - 1; o >= s && (a -= t[o].length, c++, !(a <= u)); o--);
|
|
1392
|
+
else for(let o = s; o < r && (a -= t[o].length, c++, !(a <= u)); o++);
|
|
1407
1393
|
return {
|
|
1408
|
-
lineCount:
|
|
1409
|
-
removals:
|
|
1394
|
+
lineCount: a,
|
|
1395
|
+
removals: c
|
|
1410
1396
|
};
|
|
1411
|
-
},
|
|
1412
|
-
const c =
|
|
1397
|
+
}, dist_F = ({ cursor: t, options: i, style: s, output: r = process.stdout, maxItems: u = 1 / 0, columnPadding: n = 0, rowPadding: a = 4 })=>{
|
|
1398
|
+
const c = dist_A(r) - n, o = dist_L(r), l = styleText("dim", "..."), d = Math.max(o - a, 0), g = Math.max(Math.min(u, d), 5);
|
|
1413
1399
|
let p = 0;
|
|
1414
|
-
|
|
1415
|
-
let
|
|
1416
|
-
const
|
|
1417
|
-
let
|
|
1418
|
-
|
|
1419
|
-
const v = p + (
|
|
1420
|
-
for(let b = v; b <
|
|
1421
|
-
const
|
|
1400
|
+
t >= g - 3 && (p = Math.max(Math.min(t - g + 3, i.length - g), 0));
|
|
1401
|
+
let f = g < i.length && p > 0, h = g < i.length && p + g < i.length;
|
|
1402
|
+
const I = Math.min(p + g, i.length), m = [];
|
|
1403
|
+
let y = 0;
|
|
1404
|
+
f && y++, h && y++;
|
|
1405
|
+
const v = p + (f ? 1 : 0), C = I - (h ? 1 : 0);
|
|
1406
|
+
for(let b = v; b < C; b++){
|
|
1407
|
+
const G = wrapAnsi(s(i[b], b === t), c, {
|
|
1422
1408
|
hard: !0,
|
|
1423
1409
|
trim: !1
|
|
1424
1410
|
}).split(`
|
|
1425
1411
|
`);
|
|
1426
|
-
|
|
1427
|
-
}
|
|
1428
|
-
if (
|
|
1429
|
-
let b = 0,
|
|
1430
|
-
const
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1412
|
+
m.push(G), y += G.length;
|
|
1413
|
+
}
|
|
1414
|
+
if (y > d) {
|
|
1415
|
+
let b = 0, G = 0, M = y;
|
|
1416
|
+
const N = t - v;
|
|
1417
|
+
let O = d;
|
|
1418
|
+
const j = ()=>Ot(m, M, 0, N, O), k = ()=>Ot(m, M, N + 1, m.length, O, !0);
|
|
1419
|
+
f ? ({ lineCount: M, removals: b } = j(), M > O && (h || (O -= 1), { lineCount: M, removals: G } = k())) : (h || (O -= 1), { lineCount: M, removals: G } = k(), M > O && (O -= 1, { lineCount: M, removals: b } = j())), b > 0 && (f = !0, m.splice(0, b)), G > 0 && (h = !0, m.splice(m.length - G, G));
|
|
1420
|
+
}
|
|
1421
|
+
const S = [];
|
|
1422
|
+
f && S.push(l);
|
|
1423
|
+
for (const b of m)for (const G of b)S.push(G);
|
|
1424
|
+
return h && S.push(l), S;
|
|
1437
1425
|
};
|
|
1438
|
-
function
|
|
1439
|
-
return
|
|
1426
|
+
function Pt(t) {
|
|
1427
|
+
return t.label ?? String(t.value ?? "");
|
|
1440
1428
|
}
|
|
1441
|
-
function
|
|
1442
|
-
if (!
|
|
1443
|
-
const s = (i.label ?? String(i.value ?? "")).toLowerCase(), r = (i.hint ?? "").toLowerCase(), u = String(i.value).toLowerCase(), n =
|
|
1429
|
+
function Rt(t, i) {
|
|
1430
|
+
if (!t) return !0;
|
|
1431
|
+
const s = (i.label ?? String(i.value ?? "")).toLowerCase(), r = (i.hint ?? "").toLowerCase(), u = String(i.value).toLowerCase(), n = t.toLowerCase();
|
|
1444
1432
|
return s.includes(n) || r.includes(n) || u.includes(n);
|
|
1445
1433
|
}
|
|
1446
|
-
function
|
|
1434
|
+
function se(t, i) {
|
|
1447
1435
|
const s = [];
|
|
1448
|
-
for (const r of i)
|
|
1436
|
+
for (const r of i)t.includes(r.value) && s.push(r);
|
|
1449
1437
|
return s;
|
|
1450
1438
|
}
|
|
1451
|
-
const
|
|
1452
|
-
options:
|
|
1453
|
-
initialValue:
|
|
1454
|
-
|
|
1439
|
+
const At = (t)=>new Q({
|
|
1440
|
+
options: t.options,
|
|
1441
|
+
initialValue: t.initialValue ? [
|
|
1442
|
+
t.initialValue
|
|
1455
1443
|
] : void 0,
|
|
1456
|
-
initialUserInput:
|
|
1457
|
-
placeholder:
|
|
1458
|
-
filter:
|
|
1459
|
-
signal:
|
|
1460
|
-
input:
|
|
1461
|
-
output:
|
|
1462
|
-
validate:
|
|
1444
|
+
initialUserInput: t.initialUserInput,
|
|
1445
|
+
placeholder: t.placeholder,
|
|
1446
|
+
filter: t.filter ?? ((i, s)=>Rt(i, s)),
|
|
1447
|
+
signal: t.signal,
|
|
1448
|
+
input: t.input,
|
|
1449
|
+
output: t.output,
|
|
1450
|
+
validate: t.validate,
|
|
1463
1451
|
render () {
|
|
1464
|
-
const i =
|
|
1465
|
-
`${styleText("gray",
|
|
1466
|
-
`${
|
|
1452
|
+
const i = t.withGuide ?? dist_h.withGuide, s = i ? [
|
|
1453
|
+
`${styleText("gray", dist_$)}`,
|
|
1454
|
+
`${dist_P(this.state)} ${t.message}`
|
|
1467
1455
|
] : [
|
|
1468
|
-
`${
|
|
1469
|
-
], r = this.userInput, u = this.options, n =
|
|
1470
|
-
const
|
|
1456
|
+
`${dist_P(this.state)} ${t.message}`
|
|
1457
|
+
], r = this.userInput, u = this.options, n = t.placeholder, a = "" === r && void 0 !== n, c = (o, l)=>{
|
|
1458
|
+
const d = Pt(o), g = o.hint && o.value === this.focusedValue ? styleText("dim", ` (${o.hint})`) : "";
|
|
1471
1459
|
switch(l){
|
|
1472
1460
|
case "active":
|
|
1473
|
-
return `${styleText("green", dist_z)} ${
|
|
1461
|
+
return `${styleText("green", dist_z)} ${d}${g}`;
|
|
1474
1462
|
case "inactive":
|
|
1475
|
-
return `${styleText("dim",
|
|
1463
|
+
return `${styleText("dim", dist_U)} ${styleText("dim", d)}`;
|
|
1476
1464
|
case "disabled":
|
|
1477
|
-
return `${styleText("gray",
|
|
1465
|
+
return `${styleText("gray", dist_U)} ${styleText([
|
|
1478
1466
|
"strikethrough",
|
|
1479
1467
|
"gray"
|
|
1480
|
-
],
|
|
1468
|
+
], d)}`;
|
|
1481
1469
|
}
|
|
1482
1470
|
};
|
|
1483
1471
|
switch(this.state){
|
|
1484
1472
|
case "submit":
|
|
1485
1473
|
{
|
|
1486
|
-
const
|
|
1474
|
+
const o = se(this.selectedValues, u), l = o.length > 0 ? ` ${styleText("dim", o.map(Pt).join(", "))}` : "", d = i ? styleText("gray", dist_$) : "";
|
|
1487
1475
|
return `${s.join(`
|
|
1488
1476
|
`)}
|
|
1489
|
-
${
|
|
1477
|
+
${d}${l}`;
|
|
1490
1478
|
}
|
|
1491
1479
|
case "cancel":
|
|
1492
1480
|
{
|
|
1493
|
-
const
|
|
1481
|
+
const o = r ? ` ${styleText([
|
|
1494
1482
|
"strikethrough",
|
|
1495
1483
|
"dim"
|
|
1496
|
-
], r)}` : "", l = i ? styleText("gray",
|
|
1484
|
+
], r)}` : "", l = i ? styleText("gray", dist_$) : "";
|
|
1497
1485
|
return `${s.join(`
|
|
1498
1486
|
`)}
|
|
1499
|
-
${l}${
|
|
1487
|
+
${l}${o}`;
|
|
1500
1488
|
}
|
|
1501
1489
|
default:
|
|
1502
1490
|
{
|
|
1503
|
-
const
|
|
1504
|
-
let
|
|
1505
|
-
if (this.isNavigating ||
|
|
1506
|
-
const v =
|
|
1507
|
-
|
|
1508
|
-
} else
|
|
1509
|
-
const p = this.filteredOptions.length !== u.length ? styleText("dim", ` (${this.filteredOptions.length} match${1 === this.filteredOptions.length ? "" : "es"})`) : "",
|
|
1491
|
+
const o = "error" === this.state ? "yellow" : "cyan", l = i ? `${styleText(o, dist_$)} ` : "", d = i ? styleText(o, dist_x) : "";
|
|
1492
|
+
let g = "";
|
|
1493
|
+
if (this.isNavigating || a) {
|
|
1494
|
+
const v = a ? n : r;
|
|
1495
|
+
g = "" !== v ? ` ${styleText("dim", v)}` : "";
|
|
1496
|
+
} else g = ` ${this.userInputWithCursor}`;
|
|
1497
|
+
const p = this.filteredOptions.length !== u.length ? styleText("dim", ` (${this.filteredOptions.length} match${1 === this.filteredOptions.length ? "" : "es"})`) : "", f = 0 === this.filteredOptions.length && r ? [
|
|
1510
1498
|
`${l}${styleText("yellow", "No matches found")}`
|
|
1511
|
-
] : [],
|
|
1499
|
+
] : [], h = "error" === this.state ? [
|
|
1512
1500
|
`${l}${styleText("yellow", this.error)}`
|
|
1513
1501
|
] : [];
|
|
1514
|
-
i && s.push(`${l.trimEnd()}`), s.push(`${l}${styleText("dim", "Search:")}${
|
|
1515
|
-
const
|
|
1502
|
+
i && s.push(`${l.trimEnd()}`), s.push(`${l}${styleText("dim", "Search:")}${g}${p}`, ...f, ...h);
|
|
1503
|
+
const I = [
|
|
1516
1504
|
`${styleText("dim", "\u2191/\u2193")} to select`,
|
|
1517
1505
|
`${styleText("dim", "Enter:")} confirm`,
|
|
1518
1506
|
`${styleText("dim", "Type:")} to search`
|
|
1519
|
-
],
|
|
1520
|
-
`${l}${
|
|
1521
|
-
|
|
1522
|
-
],
|
|
1507
|
+
], m = [
|
|
1508
|
+
`${l}${I.join(" \u2022 ")}`,
|
|
1509
|
+
d
|
|
1510
|
+
], y = 0 === this.filteredOptions.length ? [] : dist_F({
|
|
1523
1511
|
cursor: this.cursor,
|
|
1524
1512
|
options: this.filteredOptions,
|
|
1525
1513
|
columnPadding: i ? 3 : 0,
|
|
1526
|
-
rowPadding: s.length +
|
|
1527
|
-
style: (v,
|
|
1528
|
-
maxItems:
|
|
1529
|
-
output:
|
|
1514
|
+
rowPadding: s.length + m.length,
|
|
1515
|
+
style: (v, C)=>c(v, v.disabled ? "disabled" : C ? "active" : "inactive"),
|
|
1516
|
+
maxItems: t.maxItems,
|
|
1517
|
+
output: t.output
|
|
1530
1518
|
});
|
|
1531
1519
|
return [
|
|
1532
1520
|
...s,
|
|
1533
|
-
...
|
|
1534
|
-
...
|
|
1521
|
+
...y.map((v)=>`${l}${v}`),
|
|
1522
|
+
...m
|
|
1535
1523
|
].join(`
|
|
1536
1524
|
`);
|
|
1537
1525
|
}
|
|
1538
1526
|
}
|
|
1539
1527
|
}
|
|
1540
1528
|
}).prompt();
|
|
1541
|
-
const
|
|
1542
|
-
const { selectableGroups: i = !0, groupSpacing: s = 0 } =
|
|
1543
|
-
const
|
|
1529
|
+
const pe = (t)=>{
|
|
1530
|
+
const { selectableGroups: i = !0, groupSpacing: s = 0 } = t, r = (n, a, c = [])=>{
|
|
1531
|
+
const o = n.label ?? String(n.value), l = "string" == typeof n.group, d = l && (c[c.indexOf(n) + 1] ?? {
|
|
1544
1532
|
group: !0
|
|
1545
|
-
}),
|
|
1546
|
-
let
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
}
|
|
1552
|
-
if ("active" ===
|
|
1553
|
-
if ("
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
}
|
|
1559
|
-
if ("cancelled" === o) return `${styleText([
|
|
1533
|
+
}), g = l && d && !0 === d.group;
|
|
1534
|
+
let p = "", f = "";
|
|
1535
|
+
l && (i ? (p = g ? `${dist_x} ` : `${dist_$} `, f = g ? " " : `${dist_$} `) : p = " ");
|
|
1536
|
+
let h = "";
|
|
1537
|
+
if (s > 0 && !l && (h = `
|
|
1538
|
+
`.repeat(s)), "active" === a) return dist_W(t.output, `${o}${n.hint ? ` ${styleText("dim", `(${n.hint})`)}` : ""}`, `${h}${styleText("dim", p)} `, `${h}${styleText("dim", p)}${styleText("cyan", dist_et)} `, `${h}${styleText("dim", f)} `);
|
|
1539
|
+
if ("group-active" === a) return dist_W(t.output, o, `${h}${p} `, `${h}${p}${styleText("cyan", dist_et)} `, `${h}${f} `, (m)=>styleText("dim", m));
|
|
1540
|
+
if ("group-active-selected" === a) return dist_W(t.output, o, `${h}${p} `, `${h}${p}${styleText("green", dist_K)} `, `${h}${f} `, (m)=>styleText("dim", m));
|
|
1541
|
+
if ("selected" === a) {
|
|
1542
|
+
const m = l || i ? styleText("green", dist_K) : "";
|
|
1543
|
+
return dist_W(t.output, `${o}${n.hint ? ` (${n.hint})` : ""}`, `${h}${styleText("dim", p)} `, `${h}${styleText("dim", p)}${m} `, `${h}${styleText("dim", f)} `, (y)=>styleText("dim", y));
|
|
1544
|
+
}
|
|
1545
|
+
if ("cancelled" === a) return `${styleText([
|
|
1560
1546
|
"strikethrough",
|
|
1561
1547
|
"dim"
|
|
1562
|
-
],
|
|
1563
|
-
if ("active-selected" ===
|
|
1564
|
-
if ("submitted" ===
|
|
1565
|
-
const
|
|
1566
|
-
return `${
|
|
1567
|
-
}, u =
|
|
1568
|
-
return new
|
|
1569
|
-
options:
|
|
1570
|
-
signal:
|
|
1571
|
-
input:
|
|
1572
|
-
output:
|
|
1573
|
-
initialValues:
|
|
1548
|
+
], o)}`;
|
|
1549
|
+
if ("active-selected" === a) return dist_W(t.output, `${o}${n.hint ? ` ${styleText("dim", `(${n.hint})`)}` : ""}`, `${h}${styleText("dim", p)} `, `${h}${styleText("dim", p)}${styleText("green", dist_K)} `, `${h}${styleText("dim", f)} `);
|
|
1550
|
+
if ("submitted" === a) return `${styleText("dim", o)}`;
|
|
1551
|
+
const I = l || i ? styleText("dim", dist_Y) : "";
|
|
1552
|
+
return dist_W(t.output, o, `${h}${styleText("dim", p)} `, `${h}${styleText("dim", p)}${I} `, `${h}${styleText("dim", f)} `, (m)=>styleText("dim", m));
|
|
1553
|
+
}, u = t.required ?? !0;
|
|
1554
|
+
return new it({
|
|
1555
|
+
options: t.options,
|
|
1556
|
+
signal: t.signal,
|
|
1557
|
+
input: t.input,
|
|
1558
|
+
output: t.output,
|
|
1559
|
+
initialValues: t.initialValues,
|
|
1574
1560
|
required: u,
|
|
1575
|
-
cursorAt:
|
|
1561
|
+
cursorAt: t.cursorAt,
|
|
1576
1562
|
selectableGroups: i,
|
|
1577
1563
|
validate (n) {
|
|
1578
1564
|
if (u && (void 0 === n || 0 === n.length)) return `Please select at least one option.
|
|
@@ -1586,131 +1572,144 @@ ${styleText("reset", styleText("dim", `Press ${styleText([
|
|
|
1586
1572
|
], " enter "))} to submit`))}`;
|
|
1587
1573
|
},
|
|
1588
1574
|
render () {
|
|
1589
|
-
const n =
|
|
1590
|
-
` : ""}${
|
|
1591
|
-
`, c = this.value ?? []
|
|
1575
|
+
const n = t.withGuide ?? dist_h.withGuide, a = `${n ? `${styleText("gray", dist_$)}
|
|
1576
|
+
` : ""}${dist_P(this.state)} ${t.message}
|
|
1577
|
+
`, c = this.value ?? [], o = (l, d)=>{
|
|
1578
|
+
const g = this.options, p = c.includes(l.value) || !0 === l.group && this.isGroupSelected(`${l.value}`);
|
|
1579
|
+
return d || "string" != typeof l.group || this.options[this.cursor].value !== l.group ? d && p ? r(l, "active-selected", g) : p ? r(l, "selected", g) : r(l, d ? "active" : "inactive", g) : r(l, p ? "group-active-selected" : "group-active", g);
|
|
1580
|
+
};
|
|
1592
1581
|
switch(this.state){
|
|
1593
1582
|
case "submit":
|
|
1594
1583
|
{
|
|
1595
|
-
const
|
|
1596
|
-
return `${
|
|
1584
|
+
const l = this.options.filter(({ value: g })=>c.includes(g)).map((g)=>r(g, "submitted")), d = 0 === l.length ? "" : ` ${l.join(styleText("dim", ", "))}`;
|
|
1585
|
+
return `${a}${n ? styleText("gray", dist_$) : ""}${d}`;
|
|
1597
1586
|
}
|
|
1598
1587
|
case "cancel":
|
|
1599
1588
|
{
|
|
1600
|
-
const
|
|
1601
|
-
return `${
|
|
1602
|
-
${styleText("gray",
|
|
1589
|
+
const l = this.options.filter(({ value: d })=>c.includes(d)).map((d)=>r(d, "cancelled")).join(styleText("dim", ", "));
|
|
1590
|
+
return `${a}${n ? `${styleText("gray", dist_$)} ` : ""}${l.trim() ? `${l}${n ? `
|
|
1591
|
+
${styleText("gray", dist_$)}` : ""}` : ""}`;
|
|
1603
1592
|
}
|
|
1604
1593
|
case "error":
|
|
1605
1594
|
{
|
|
1606
|
-
const
|
|
1607
|
-
`).map((
|
|
1608
|
-
`)
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1595
|
+
const l = n ? `${styleText("yellow", dist_$)} ` : "", d = this.error.split(`
|
|
1596
|
+
`).map((h, I)=>0 === I ? `${n ? `${styleText("yellow", dist_x)} ` : ""}${styleText("yellow", h)}` : ` ${h}`).join(`
|
|
1597
|
+
`), g = a.split(`
|
|
1598
|
+
`).length, p = d.split(`
|
|
1599
|
+
`).length + 1, f = dist_F({
|
|
1600
|
+
output: t.output,
|
|
1601
|
+
options: this.options,
|
|
1602
|
+
cursor: this.cursor,
|
|
1603
|
+
maxItems: t.maxItems,
|
|
1604
|
+
columnPadding: l.length,
|
|
1605
|
+
rowPadding: g + p,
|
|
1606
|
+
style: o
|
|
1612
1607
|
}).join(`
|
|
1613
|
-
${
|
|
1614
|
-
|
|
1608
|
+
${l}`);
|
|
1609
|
+
return `${a}${l}${f}
|
|
1610
|
+
${d}
|
|
1615
1611
|
`;
|
|
1616
1612
|
}
|
|
1617
1613
|
default:
|
|
1618
1614
|
{
|
|
1619
|
-
const
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1615
|
+
const l = n ? `${styleText("cyan", dist_$)} ` : "", d = a.split(`
|
|
1616
|
+
`).length, g = (n ? 1 : 0) + 1, p = dist_F({
|
|
1617
|
+
output: t.output,
|
|
1618
|
+
options: this.options,
|
|
1619
|
+
cursor: this.cursor,
|
|
1620
|
+
maxItems: t.maxItems,
|
|
1621
|
+
columnPadding: l.length,
|
|
1622
|
+
rowPadding: d + g,
|
|
1623
|
+
style: o
|
|
1624
1624
|
}).join(`
|
|
1625
|
-
${
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
${n ? styleText("cyan", dist_E) : ""}
|
|
1625
|
+
${l}`);
|
|
1626
|
+
return `${a}${l}${p}
|
|
1627
|
+
${n ? styleText("cyan", dist_x) : ""}
|
|
1629
1628
|
`;
|
|
1630
1629
|
}
|
|
1631
1630
|
}
|
|
1632
1631
|
}
|
|
1633
1632
|
}).prompt();
|
|
1634
|
-
},
|
|
1635
|
-
message: (
|
|
1636
|
-
const
|
|
1637
|
-
for(let p = 0; p < u; p++)
|
|
1638
|
-
const
|
|
1633
|
+
}, dist_R = {
|
|
1634
|
+
message: (t = [], { symbol: i = styleText("gray", dist_$), secondarySymbol: s = styleText("gray", dist_$), output: r = process.stdout, spacing: u = 1, withGuide: n } = {})=>{
|
|
1635
|
+
const a = [], c = n ?? dist_h.withGuide, o = c ? s : "", l = c ? `${i} ` : "", d = c ? `${s} ` : "";
|
|
1636
|
+
for(let p = 0; p < u; p++)a.push(o);
|
|
1637
|
+
const g = Array.isArray(t) ? t : t.split(`
|
|
1639
1638
|
`);
|
|
1640
|
-
if (
|
|
1641
|
-
const [p, ...
|
|
1642
|
-
p.length > 0 ?
|
|
1643
|
-
for (const
|
|
1639
|
+
if (g.length > 0) {
|
|
1640
|
+
const [p, ...f] = g;
|
|
1641
|
+
p.length > 0 ? a.push(`${l}${p}`) : a.push(c ? i : "");
|
|
1642
|
+
for (const h of f)h.length > 0 ? a.push(`${d}${h}`) : a.push(c ? s : "");
|
|
1644
1643
|
}
|
|
1645
|
-
r.write(`${
|
|
1644
|
+
r.write(`${a.join(`
|
|
1646
1645
|
`)}
|
|
1647
1646
|
`);
|
|
1648
1647
|
},
|
|
1649
|
-
info: (
|
|
1650
|
-
|
|
1648
|
+
info: (t, i)=>{
|
|
1649
|
+
dist_R.message(t, {
|
|
1651
1650
|
...i,
|
|
1652
|
-
symbol: styleText("blue",
|
|
1651
|
+
symbol: styleText("blue", dist_ht)
|
|
1653
1652
|
});
|
|
1654
1653
|
},
|
|
1655
|
-
success: (
|
|
1656
|
-
|
|
1654
|
+
success: (t, i)=>{
|
|
1655
|
+
dist_R.message(t, {
|
|
1657
1656
|
...i,
|
|
1658
|
-
symbol: styleText("green",
|
|
1657
|
+
symbol: styleText("green", pt)
|
|
1659
1658
|
});
|
|
1660
1659
|
},
|
|
1661
|
-
step: (
|
|
1662
|
-
|
|
1660
|
+
step: (t, i)=>{
|
|
1661
|
+
dist_R.message(t, {
|
|
1663
1662
|
...i,
|
|
1664
|
-
symbol: styleText("green",
|
|
1663
|
+
symbol: styleText("green", dist_H)
|
|
1665
1664
|
});
|
|
1666
1665
|
},
|
|
1667
|
-
warn: (
|
|
1668
|
-
|
|
1666
|
+
warn: (t, i)=>{
|
|
1667
|
+
dist_R.message(t, {
|
|
1669
1668
|
...i,
|
|
1670
|
-
symbol: styleText("yellow",
|
|
1669
|
+
symbol: styleText("yellow", mt)
|
|
1671
1670
|
});
|
|
1672
1671
|
},
|
|
1673
|
-
warning: (
|
|
1674
|
-
|
|
1672
|
+
warning: (t, i)=>{
|
|
1673
|
+
dist_R.warn(t, i);
|
|
1675
1674
|
},
|
|
1676
|
-
error: (
|
|
1677
|
-
|
|
1675
|
+
error: (t, i)=>{
|
|
1676
|
+
dist_R.message(t, {
|
|
1678
1677
|
...i,
|
|
1679
|
-
symbol: styleText("red",
|
|
1678
|
+
symbol: styleText("red", gt)
|
|
1680
1679
|
});
|
|
1681
1680
|
}
|
|
1682
|
-
},
|
|
1683
|
-
const s = i?.output ?? process.stdout, r = i?.withGuide ??
|
|
1684
|
-
s.write(`${r}${styleText("red",
|
|
1681
|
+
}, me = (t = "", i)=>{
|
|
1682
|
+
const s = i?.output ?? process.stdout, r = i?.withGuide ?? dist_h.withGuide ? `${styleText("gray", dist_x)} ` : "";
|
|
1683
|
+
s.write(`${r}${styleText("red", t)}
|
|
1685
1684
|
|
|
1686
1685
|
`);
|
|
1687
|
-
},
|
|
1688
|
-
const s = i?.output ?? process.stdout, r = i?.withGuide ??
|
|
1689
|
-
${styleText("gray",
|
|
1690
|
-
s.write(`${r}${
|
|
1686
|
+
}, ye = (t = "", i)=>{
|
|
1687
|
+
const s = i?.output ?? process.stdout, r = i?.withGuide ?? dist_h.withGuide ? `${styleText("gray", dist_$)}
|
|
1688
|
+
${styleText("gray", dist_x)} ` : "";
|
|
1689
|
+
s.write(`${r}${t}
|
|
1691
1690
|
|
|
1692
1691
|
`);
|
|
1693
|
-
}, dist_Q = (
|
|
1692
|
+
}, dist_Q = (t, i)=>t.split(`
|
|
1694
1693
|
`).map((s)=>i(s)).join(`
|
|
1695
|
-
`),
|
|
1694
|
+
`), ve = (t)=>{
|
|
1696
1695
|
const i = (r, u)=>{
|
|
1697
1696
|
const n = r.label ?? String(r.value);
|
|
1698
|
-
return "disabled" === u ? `${styleText("gray",
|
|
1697
|
+
return "disabled" === u ? `${styleText("gray", dist_Y)} ${dist_Q(n, (a)=>styleText([
|
|
1699
1698
|
"strikethrough",
|
|
1700
1699
|
"gray"
|
|
1701
|
-
],
|
|
1700
|
+
], a))}${r.hint ? ` ${styleText("dim", `(${r.hint ?? "disabled"})`)}` : ""}` : "active" === u ? `${styleText("cyan", dist_et)} ${n}${r.hint ? ` ${styleText("dim", `(${r.hint})`)}` : ""}` : "selected" === u ? `${styleText("green", dist_K)} ${dist_Q(n, (a)=>styleText("dim", a))}${r.hint ? ` ${styleText("dim", `(${r.hint})`)}` : ""}` : "cancelled" === u ? `${dist_Q(n, (a)=>styleText([
|
|
1702
1701
|
"strikethrough",
|
|
1703
1702
|
"dim"
|
|
1704
|
-
],
|
|
1705
|
-
}, s =
|
|
1706
|
-
return new
|
|
1707
|
-
options:
|
|
1708
|
-
signal:
|
|
1709
|
-
input:
|
|
1710
|
-
output:
|
|
1711
|
-
initialValues:
|
|
1703
|
+
], a))}` : "active-selected" === u ? `${styleText("green", dist_K)} ${n}${r.hint ? ` ${styleText("dim", `(${r.hint})`)}` : ""}` : "submitted" === u ? `${dist_Q(n, (a)=>styleText("dim", a))}` : `${styleText("dim", dist_Y)} ${dist_Q(n, (a)=>styleText("dim", a))}`;
|
|
1704
|
+
}, s = t.required ?? !0;
|
|
1705
|
+
return new dist_nt({
|
|
1706
|
+
options: t.options,
|
|
1707
|
+
signal: t.signal,
|
|
1708
|
+
input: t.input,
|
|
1709
|
+
output: t.output,
|
|
1710
|
+
initialValues: t.initialValues,
|
|
1712
1711
|
required: s,
|
|
1713
|
-
cursorAt:
|
|
1712
|
+
cursorAt: t.cursorAt,
|
|
1714
1713
|
validate (r) {
|
|
1715
1714
|
if (s && (void 0 === r || 0 === r.length)) return `Please select at least one option.
|
|
1716
1715
|
${styleText("reset", styleText("dim", `Press ${styleText([
|
|
@@ -1720,319 +1719,319 @@ ${styleText("reset", styleText("dim", `Press ${styleText([
|
|
|
1720
1719
|
], " space ")} to select, ${styleText("gray", styleText("bgWhite", styleText("inverse", " enter ")))} to submit`))}`;
|
|
1721
1720
|
},
|
|
1722
1721
|
render () {
|
|
1723
|
-
const r =
|
|
1722
|
+
const r = t.withGuide ?? dist_h.withGuide, u = dist_W(t.output, t.message, r ? `${yt(this.state)} ` : "", `${dist_P(this.state)} `), n = `${r ? `${styleText("gray", dist_$)}
|
|
1724
1723
|
` : ""}${u}
|
|
1725
|
-
`,
|
|
1726
|
-
if (
|
|
1727
|
-
const
|
|
1728
|
-
return l &&
|
|
1724
|
+
`, a = this.value ?? [], c = (o, l)=>{
|
|
1725
|
+
if (o.disabled) return i(o, "disabled");
|
|
1726
|
+
const d = a.includes(o.value);
|
|
1727
|
+
return l && d ? i(o, "active-selected") : d ? i(o, "selected") : i(o, l ? "active" : "inactive");
|
|
1729
1728
|
};
|
|
1730
1729
|
switch(this.state){
|
|
1731
1730
|
case "submit":
|
|
1732
1731
|
{
|
|
1733
|
-
const
|
|
1732
|
+
const o = this.options.filter(({ value: d })=>a.includes(d)).map((d)=>i(d, "submitted")).join(styleText("dim", ", ")) || styleText("dim", "none"), l = dist_W(t.output, o, r ? `${styleText("gray", dist_$)} ` : "");
|
|
1734
1733
|
return `${n}${l}`;
|
|
1735
1734
|
}
|
|
1736
1735
|
case "cancel":
|
|
1737
1736
|
{
|
|
1738
|
-
const
|
|
1739
|
-
if ("" ===
|
|
1740
|
-
const l =
|
|
1737
|
+
const o = this.options.filter(({ value: d })=>a.includes(d)).map((d)=>i(d, "cancelled")).join(styleText("dim", ", "));
|
|
1738
|
+
if ("" === o.trim()) return `${n}${styleText("gray", dist_$)}`;
|
|
1739
|
+
const l = dist_W(t.output, o, r ? `${styleText("gray", dist_$)} ` : "");
|
|
1741
1740
|
return `${n}${l}${r ? `
|
|
1742
|
-
${styleText("gray",
|
|
1741
|
+
${styleText("gray", dist_$)}` : ""}`;
|
|
1743
1742
|
}
|
|
1744
1743
|
case "error":
|
|
1745
1744
|
{
|
|
1746
|
-
const
|
|
1747
|
-
`).map((p,
|
|
1748
|
-
`),
|
|
1749
|
-
`).length,
|
|
1745
|
+
const o = r ? `${styleText("yellow", dist_$)} ` : "", l = this.error.split(`
|
|
1746
|
+
`).map((p, f)=>0 === f ? `${r ? `${styleText("yellow", dist_x)} ` : ""}${styleText("yellow", p)}` : ` ${p}`).join(`
|
|
1747
|
+
`), d = n.split(`
|
|
1748
|
+
`).length, g = l.split(`
|
|
1750
1749
|
`).length + 1;
|
|
1751
|
-
return `${n}${
|
|
1752
|
-
output:
|
|
1750
|
+
return `${n}${o}${dist_F({
|
|
1751
|
+
output: t.output,
|
|
1753
1752
|
options: this.options,
|
|
1754
1753
|
cursor: this.cursor,
|
|
1755
|
-
maxItems:
|
|
1756
|
-
columnPadding:
|
|
1757
|
-
rowPadding:
|
|
1754
|
+
maxItems: t.maxItems,
|
|
1755
|
+
columnPadding: o.length,
|
|
1756
|
+
rowPadding: d + g,
|
|
1758
1757
|
style: c
|
|
1759
1758
|
}).join(`
|
|
1760
|
-
${
|
|
1759
|
+
${o}`)}
|
|
1761
1760
|
${l}
|
|
1762
1761
|
`;
|
|
1763
1762
|
}
|
|
1764
1763
|
default:
|
|
1765
1764
|
{
|
|
1766
|
-
const
|
|
1767
|
-
`).length,
|
|
1768
|
-
return `${n}${
|
|
1769
|
-
output:
|
|
1765
|
+
const o = r ? `${styleText("cyan", dist_$)} ` : "", l = n.split(`
|
|
1766
|
+
`).length, d = r ? 2 : 1;
|
|
1767
|
+
return `${n}${o}${dist_F({
|
|
1768
|
+
output: t.output,
|
|
1770
1769
|
options: this.options,
|
|
1771
1770
|
cursor: this.cursor,
|
|
1772
|
-
maxItems:
|
|
1773
|
-
columnPadding:
|
|
1774
|
-
rowPadding: l +
|
|
1771
|
+
maxItems: t.maxItems,
|
|
1772
|
+
columnPadding: o.length,
|
|
1773
|
+
rowPadding: l + d,
|
|
1775
1774
|
style: c
|
|
1776
1775
|
}).join(`
|
|
1777
|
-
${
|
|
1778
|
-
${r ? styleText("cyan",
|
|
1776
|
+
${o}`)}
|
|
1777
|
+
${r ? styleText("cyan", dist_x) : ""}
|
|
1779
1778
|
`;
|
|
1780
1779
|
}
|
|
1781
1780
|
}
|
|
1782
1781
|
}
|
|
1783
1782
|
}).prompt();
|
|
1784
|
-
},
|
|
1783
|
+
}, we = (t)=>styleText("dim", t), be = (t, i, s)=>{
|
|
1785
1784
|
const r = {
|
|
1786
1785
|
hard: !0,
|
|
1787
1786
|
trim: !1
|
|
1788
|
-
}, u = wrapAnsi(
|
|
1789
|
-
`), n = u.reduce((
|
|
1790
|
-
return wrapAnsi(
|
|
1791
|
-
},
|
|
1792
|
-
const r = s?.output ?? node_process.stdout, u = s?.withGuide ??
|
|
1787
|
+
}, u = wrapAnsi(t, i, r).split(`
|
|
1788
|
+
`), n = u.reduce((o, l)=>Math.max(fast_string_width_dist(l), o), 0), a = u.map(s).reduce((o, l)=>Math.max(fast_string_width_dist(l), o), 0), c = i - (a - n);
|
|
1789
|
+
return wrapAnsi(t, c, r);
|
|
1790
|
+
}, Se = (t = "", i = "", s)=>{
|
|
1791
|
+
const r = s?.output ?? node_process.stdout, u = s?.withGuide ?? dist_h.withGuide, n = s?.format ?? we, a = [
|
|
1793
1792
|
"",
|
|
1794
|
-
...
|
|
1793
|
+
...be(t, dist_A(r) - 6, n).split(`
|
|
1795
1794
|
`).map(n),
|
|
1796
1795
|
""
|
|
1797
|
-
], c = fast_string_width_dist(i),
|
|
1798
|
-
const
|
|
1799
|
-
return
|
|
1800
|
-
}, 0), c) + 2, l =
|
|
1801
|
-
`),
|
|
1802
|
-
` : "",
|
|
1803
|
-
r.write(`${
|
|
1796
|
+
], c = fast_string_width_dist(i), o = Math.max(a.reduce((p, f)=>{
|
|
1797
|
+
const h = fast_string_width_dist(f);
|
|
1798
|
+
return h > p ? h : p;
|
|
1799
|
+
}, 0), c) + 2, l = a.map((p)=>`${styleText("gray", dist_$)} ${p}${" ".repeat(o - fast_string_width_dist(p))}${styleText("gray", dist_$)}`).join(`
|
|
1800
|
+
`), d = u ? `${styleText("gray", dist_$)}
|
|
1801
|
+
` : "", g = u ? Gt : dt;
|
|
1802
|
+
r.write(`${d}${styleText("green", dist_H)} ${styleText("reset", i)} ${styleText("gray", dist_st.repeat(Math.max(o - c - 1, 1)) + ct)}
|
|
1804
1803
|
${l}
|
|
1805
|
-
${styleText("gray",
|
|
1804
|
+
${styleText("gray", g + dist_st.repeat(o + 2) + $t)}
|
|
1806
1805
|
`);
|
|
1807
1806
|
};
|
|
1808
1807
|
dist_w("\u2500", "-"), dist_w("\u2501", "="), dist_w("\u2588", "#");
|
|
1809
|
-
const
|
|
1810
|
-
`) ?
|
|
1808
|
+
const dist_it = (t, i)=>t.includes(`
|
|
1809
|
+
`) ? t.split(`
|
|
1811
1810
|
`).map((s)=>i(s)).join(`
|
|
1812
|
-
`) : i(
|
|
1811
|
+
`) : i(t), xe = (t)=>{
|
|
1813
1812
|
const i = (s, r)=>{
|
|
1814
1813
|
const u = s.label ?? String(s.value);
|
|
1815
1814
|
switch(r){
|
|
1816
1815
|
case "disabled":
|
|
1817
|
-
return `${styleText("gray",
|
|
1816
|
+
return `${styleText("gray", dist_U)} ${dist_it(u, (n)=>styleText("gray", n))}${s.hint ? ` ${styleText("dim", `(${s.hint ?? "disabled"})`)}` : ""}`;
|
|
1818
1817
|
case "selected":
|
|
1819
|
-
return `${
|
|
1818
|
+
return `${dist_it(u, (n)=>styleText("dim", n))}`;
|
|
1820
1819
|
case "active":
|
|
1821
1820
|
return `${styleText("green", dist_z)} ${u}${s.hint ? ` ${styleText("dim", `(${s.hint})`)}` : ""}`;
|
|
1822
1821
|
case "cancelled":
|
|
1823
|
-
return `${
|
|
1822
|
+
return `${dist_it(u, (n)=>styleText([
|
|
1824
1823
|
"strikethrough",
|
|
1825
1824
|
"dim"
|
|
1826
1825
|
], n))}`;
|
|
1827
1826
|
default:
|
|
1828
|
-
return `${styleText("dim",
|
|
1827
|
+
return `${styleText("dim", dist_U)} ${dist_it(u, (n)=>styleText("dim", n))}`;
|
|
1829
1828
|
}
|
|
1830
1829
|
};
|
|
1831
|
-
return new
|
|
1832
|
-
options:
|
|
1833
|
-
signal:
|
|
1834
|
-
input:
|
|
1835
|
-
output:
|
|
1836
|
-
initialValue:
|
|
1830
|
+
return new ut({
|
|
1831
|
+
options: t.options,
|
|
1832
|
+
signal: t.signal,
|
|
1833
|
+
input: t.input,
|
|
1834
|
+
output: t.output,
|
|
1835
|
+
initialValue: t.initialValue,
|
|
1837
1836
|
render () {
|
|
1838
|
-
const s =
|
|
1837
|
+
const s = t.withGuide ?? dist_h.withGuide, r = `${dist_P(this.state)} `, u = `${yt(this.state)} `, n = dist_W(t.output, t.message, u, r), a = `${s ? `${styleText("gray", dist_$)}
|
|
1839
1838
|
` : ""}${n}
|
|
1840
1839
|
`;
|
|
1841
1840
|
switch(this.state){
|
|
1842
1841
|
case "submit":
|
|
1843
1842
|
{
|
|
1844
|
-
const c = s ? `${styleText("gray",
|
|
1845
|
-
return `${
|
|
1843
|
+
const c = s ? `${styleText("gray", dist_$)} ` : "", o = dist_W(t.output, i(this.options[this.cursor], "selected"), c);
|
|
1844
|
+
return `${a}${o}`;
|
|
1846
1845
|
}
|
|
1847
1846
|
case "cancel":
|
|
1848
1847
|
{
|
|
1849
|
-
const c = s ? `${styleText("gray",
|
|
1850
|
-
return `${
|
|
1851
|
-
${styleText("gray",
|
|
1848
|
+
const c = s ? `${styleText("gray", dist_$)} ` : "", o = dist_W(t.output, i(this.options[this.cursor], "cancelled"), c);
|
|
1849
|
+
return `${a}${o}${s ? `
|
|
1850
|
+
${styleText("gray", dist_$)}` : ""}`;
|
|
1852
1851
|
}
|
|
1853
1852
|
default:
|
|
1854
1853
|
{
|
|
1855
|
-
const c = s ? `${styleText("cyan",
|
|
1856
|
-
`).length,
|
|
1857
|
-
return `${
|
|
1858
|
-
output:
|
|
1854
|
+
const c = s ? `${styleText("cyan", dist_$)} ` : "", o = s ? styleText("cyan", dist_x) : "", l = a.split(`
|
|
1855
|
+
`).length, d = s ? 2 : 1;
|
|
1856
|
+
return `${a}${c}${dist_F({
|
|
1857
|
+
output: t.output,
|
|
1859
1858
|
cursor: this.cursor,
|
|
1860
1859
|
options: this.options,
|
|
1861
|
-
maxItems:
|
|
1860
|
+
maxItems: t.maxItems,
|
|
1862
1861
|
columnPadding: c.length,
|
|
1863
|
-
rowPadding: l +
|
|
1864
|
-
style: (
|
|
1862
|
+
rowPadding: l + d,
|
|
1863
|
+
style: (g, p)=>i(g, g.disabled ? "disabled" : p ? "active" : "inactive")
|
|
1865
1864
|
}).join(`
|
|
1866
1865
|
${c}`)}
|
|
1867
|
-
${
|
|
1866
|
+
${o}
|
|
1868
1867
|
`;
|
|
1869
1868
|
}
|
|
1870
1869
|
}
|
|
1871
1870
|
}
|
|
1872
1871
|
}).prompt();
|
|
1873
|
-
},
|
|
1874
|
-
const i =
|
|
1872
|
+
}, Me = (styleText("gray", dist_$), (t)=>t.replace(/\x1b\[(?:\d+;)*\d*[ABCDEFGHfJKSTsu]|\x1b\[(s|u)/g, "")), Oe = (t)=>{
|
|
1873
|
+
const i = t.output ?? process.stdout, s = dist_A(i), r = styleText("gray", dist_$), u = t.spacing ?? 1, n = 3, a = !0 === t.retainLog, c = !dist_ot() && It(i);
|
|
1875
1874
|
i.write(`${r}
|
|
1876
|
-
`), i.write(`${styleText("green",
|
|
1875
|
+
`), i.write(`${styleText("green", dist_H)} ${t.title}
|
|
1877
1876
|
`);
|
|
1878
|
-
for(let
|
|
1877
|
+
for(let m = 0; m < u; m++)i.write(`${r}
|
|
1879
1878
|
`);
|
|
1880
|
-
const
|
|
1879
|
+
const o = [
|
|
1881
1880
|
{
|
|
1882
1881
|
value: "",
|
|
1883
1882
|
full: ""
|
|
1884
1883
|
}
|
|
1885
1884
|
];
|
|
1886
1885
|
let l = !1;
|
|
1887
|
-
const
|
|
1888
|
-
if (0 ===
|
|
1889
|
-
let
|
|
1890
|
-
|
|
1891
|
-
for (const v of
|
|
1892
|
-
const { value:
|
|
1893
|
-
let b =
|
|
1886
|
+
const d = (m)=>{
|
|
1887
|
+
if (0 === o.length) return;
|
|
1888
|
+
let y = 0;
|
|
1889
|
+
m && (y += u + 2);
|
|
1890
|
+
for (const v of o){
|
|
1891
|
+
const { value: C, result: S } = v;
|
|
1892
|
+
let b = S?.message ?? C;
|
|
1894
1893
|
if (0 === b.length) continue;
|
|
1895
|
-
void 0 ===
|
|
1894
|
+
void 0 === S && void 0 !== v.header && "" !== v.header && (b += `
|
|
1896
1895
|
${v.header}`);
|
|
1897
|
-
const
|
|
1898
|
-
`).reduce((
|
|
1899
|
-
|
|
1900
|
-
}
|
|
1901
|
-
|
|
1902
|
-
},
|
|
1903
|
-
const
|
|
1904
|
-
${
|
|
1905
|
-
void 0 !==
|
|
1906
|
-
`).map((
|
|
1896
|
+
const G = b.split(`
|
|
1897
|
+
`).reduce((M, N)=>"" === N ? M + 1 : M + Math.ceil((N.length + n) / s), 0);
|
|
1898
|
+
y += G;
|
|
1899
|
+
}
|
|
1900
|
+
y > 0 && (y += 1, i.write(src.erase.lines(y)));
|
|
1901
|
+
}, g = (m, y, v)=>{
|
|
1902
|
+
const C = v ? `${m.full}
|
|
1903
|
+
${m.value}` : m.value;
|
|
1904
|
+
void 0 !== m.header && "" !== m.header && dist_R.message(m.header.split(`
|
|
1905
|
+
`).map((S)=>styleText("bold", S)), {
|
|
1907
1906
|
output: i,
|
|
1908
1907
|
secondarySymbol: r,
|
|
1909
1908
|
symbol: r,
|
|
1910
1909
|
spacing: 0
|
|
1911
|
-
}),
|
|
1912
|
-
`).map((
|
|
1910
|
+
}), dist_R.message(C.split(`
|
|
1911
|
+
`).map((S)=>styleText("dim", S)), {
|
|
1913
1912
|
output: i,
|
|
1914
1913
|
secondarySymbol: r,
|
|
1915
1914
|
symbol: r,
|
|
1916
|
-
spacing:
|
|
1915
|
+
spacing: y ?? u
|
|
1917
1916
|
});
|
|
1918
1917
|
}, p = ()=>{
|
|
1919
|
-
for (const
|
|
1920
|
-
const { header:
|
|
1921
|
-
(void 0 ===
|
|
1922
|
-
}
|
|
1923
|
-
},
|
|
1924
|
-
if (
|
|
1925
|
-
`),
|
|
1926
|
-
const
|
|
1927
|
-
`),
|
|
1928
|
-
if (
|
|
1929
|
-
const b =
|
|
1930
|
-
|
|
1918
|
+
for (const m of o){
|
|
1919
|
+
const { header: y, value: v, full: C } = m;
|
|
1920
|
+
(void 0 === y || 0 === y.length) && 0 === v.length || g(m, void 0, !0 === a && C.length > 0);
|
|
1921
|
+
}
|
|
1922
|
+
}, f = (m, y, v)=>{
|
|
1923
|
+
if (d(!1), v?.raw === !0 && l || "" === m.value || (m.value += `
|
|
1924
|
+
`), m.value += Me(y), l = v?.raw === !0, void 0 !== t.limit) {
|
|
1925
|
+
const C = m.value.split(`
|
|
1926
|
+
`), S = C.length - t.limit;
|
|
1927
|
+
if (S > 0) {
|
|
1928
|
+
const b = C.splice(0, S);
|
|
1929
|
+
a && (m.full += ("" === m.full ? "" : `
|
|
1931
1930
|
`) + b.join(`
|
|
1932
1931
|
`));
|
|
1933
1932
|
}
|
|
1934
|
-
|
|
1933
|
+
m.value = C.join(`
|
|
1935
1934
|
`);
|
|
1936
1935
|
}
|
|
1937
|
-
c &&
|
|
1938
|
-
},
|
|
1939
|
-
for (const
|
|
1936
|
+
c && h();
|
|
1937
|
+
}, h = ()=>{
|
|
1938
|
+
for (const m of o)m.result ? "error" === m.result.status ? dist_R.error(m.result.message, {
|
|
1940
1939
|
output: i,
|
|
1941
1940
|
secondarySymbol: r,
|
|
1942
1941
|
spacing: 0
|
|
1943
|
-
}) :
|
|
1942
|
+
}) : dist_R.success(m.result.message, {
|
|
1944
1943
|
output: i,
|
|
1945
1944
|
secondarySymbol: r,
|
|
1946
1945
|
spacing: 0
|
|
1947
|
-
}) : "" !==
|
|
1948
|
-
},
|
|
1949
|
-
|
|
1946
|
+
}) : "" !== m.value && g(m, 0);
|
|
1947
|
+
}, I = (m, y)=>{
|
|
1948
|
+
d(!1), m.result = y, c && h();
|
|
1950
1949
|
};
|
|
1951
1950
|
return {
|
|
1952
|
-
message (
|
|
1953
|
-
|
|
1951
|
+
message (m, y) {
|
|
1952
|
+
f(o[0], m, y);
|
|
1954
1953
|
},
|
|
1955
|
-
group (
|
|
1956
|
-
const
|
|
1957
|
-
header:
|
|
1954
|
+
group (m) {
|
|
1955
|
+
const y = {
|
|
1956
|
+
header: m,
|
|
1958
1957
|
value: "",
|
|
1959
1958
|
full: ""
|
|
1960
1959
|
};
|
|
1961
|
-
return
|
|
1962
|
-
message (v,
|
|
1963
|
-
|
|
1960
|
+
return o.push(y), {
|
|
1961
|
+
message (v, C) {
|
|
1962
|
+
f(y, v, C);
|
|
1964
1963
|
},
|
|
1965
1964
|
error (v) {
|
|
1966
|
-
|
|
1965
|
+
I(y, {
|
|
1967
1966
|
status: "error",
|
|
1968
1967
|
message: v
|
|
1969
1968
|
});
|
|
1970
1969
|
},
|
|
1971
1970
|
success (v) {
|
|
1972
|
-
|
|
1971
|
+
I(y, {
|
|
1973
1972
|
status: "success",
|
|
1974
1973
|
message: v
|
|
1975
1974
|
});
|
|
1976
1975
|
}
|
|
1977
1976
|
};
|
|
1978
1977
|
},
|
|
1979
|
-
error (
|
|
1980
|
-
|
|
1978
|
+
error (m, y) {
|
|
1979
|
+
d(!0), dist_R.error(m, {
|
|
1981
1980
|
output: i,
|
|
1982
1981
|
secondarySymbol: r,
|
|
1983
1982
|
spacing: 1
|
|
1984
|
-
}),
|
|
1983
|
+
}), y?.showLog !== !1 && p(), o.splice(1, o.length - 1), o[0].value = "", o[0].full = "";
|
|
1985
1984
|
},
|
|
1986
|
-
success (
|
|
1987
|
-
|
|
1985
|
+
success (m, y) {
|
|
1986
|
+
d(!0), dist_R.success(m, {
|
|
1988
1987
|
output: i,
|
|
1989
1988
|
secondarySymbol: r,
|
|
1990
1989
|
spacing: 1
|
|
1991
|
-
}),
|
|
1990
|
+
}), y?.showLog === !0 && p(), o.splice(1, o.length - 1), o[0].value = "", o[0].full = "";
|
|
1992
1991
|
}
|
|
1993
1992
|
};
|
|
1994
|
-
},
|
|
1995
|
-
validate:
|
|
1996
|
-
placeholder:
|
|
1997
|
-
defaultValue:
|
|
1998
|
-
initialValue:
|
|
1999
|
-
output:
|
|
2000
|
-
signal:
|
|
2001
|
-
input:
|
|
1993
|
+
}, Pe = (t)=>new ht({
|
|
1994
|
+
validate: t.validate,
|
|
1995
|
+
placeholder: t.placeholder,
|
|
1996
|
+
defaultValue: t.defaultValue,
|
|
1997
|
+
initialValue: t.initialValue,
|
|
1998
|
+
output: t.output,
|
|
1999
|
+
signal: t.signal,
|
|
2000
|
+
input: t.input,
|
|
2002
2001
|
render () {
|
|
2003
|
-
const i =
|
|
2004
|
-
` : ""}${
|
|
2005
|
-
`, r =
|
|
2002
|
+
const i = t?.withGuide ?? dist_h.withGuide, s = `${i ? `${styleText("gray", dist_$)}
|
|
2003
|
+
` : ""}${dist_P(this.state)} ${t.message}
|
|
2004
|
+
`, r = t.placeholder ? styleText("inverse", t.placeholder[0]) + styleText("dim", t.placeholder.slice(1)) : styleText([
|
|
2006
2005
|
"inverse",
|
|
2007
2006
|
"hidden"
|
|
2008
2007
|
], "_"), u = this.userInput ? this.userInputWithCursor : r, n = this.value ?? "";
|
|
2009
2008
|
switch(this.state){
|
|
2010
2009
|
case "error":
|
|
2011
2010
|
{
|
|
2012
|
-
const
|
|
2011
|
+
const a = this.error ? ` ${styleText("yellow", this.error)}` : "", c = i ? `${styleText("yellow", dist_$)} ` : "", o = i ? styleText("yellow", dist_x) : "";
|
|
2013
2012
|
return `${s.trim()}
|
|
2014
2013
|
${c}${u}
|
|
2015
|
-
${
|
|
2014
|
+
${o}${a}
|
|
2016
2015
|
`;
|
|
2017
2016
|
}
|
|
2018
2017
|
case "submit":
|
|
2019
2018
|
{
|
|
2020
|
-
const
|
|
2021
|
-
return `${s}${c}${
|
|
2019
|
+
const a = n ? ` ${styleText("dim", n)}` : "", c = i ? styleText("gray", dist_$) : "";
|
|
2020
|
+
return `${s}${c}${a}`;
|
|
2022
2021
|
}
|
|
2023
2022
|
case "cancel":
|
|
2024
2023
|
{
|
|
2025
|
-
const
|
|
2024
|
+
const a = n ? ` ${styleText([
|
|
2026
2025
|
"strikethrough",
|
|
2027
2026
|
"dim"
|
|
2028
|
-
], n)}` : "", c = i ? styleText("gray",
|
|
2029
|
-
return `${s}${c}${
|
|
2027
|
+
], n)}` : "", c = i ? styleText("gray", dist_$) : "";
|
|
2028
|
+
return `${s}${c}${a}${n.trim() ? `
|
|
2030
2029
|
${c}` : ""}`;
|
|
2031
2030
|
}
|
|
2032
2031
|
default:
|
|
2033
2032
|
{
|
|
2034
|
-
const
|
|
2035
|
-
return `${s}${
|
|
2033
|
+
const a = i ? `${styleText("cyan", dist_$)} ` : "", c = i ? styleText("cyan", dist_x) : "";
|
|
2034
|
+
return `${s}${a}${u}
|
|
2036
2035
|
${c}
|
|
2037
2036
|
`;
|
|
2038
2037
|
}
|
|
@@ -2310,18 +2309,14 @@ let createLogger = (options = {})=>{
|
|
|
2310
2309
|
return logger;
|
|
2311
2310
|
};
|
|
2312
2311
|
let src_logger = createLogger();
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
}).exports, t), t.exports);
|
|
2316
|
-
var main_f = /* @__PURE__ */ createRequire(import.meta.url);
|
|
2317
|
-
const main_p = /^path$/i;
|
|
2318
|
-
const main_m = {
|
|
2312
|
+
const main_h = /^path$/i;
|
|
2313
|
+
const main_g = {
|
|
2319
2314
|
key: "PATH",
|
|
2320
2315
|
value: ""
|
|
2321
2316
|
};
|
|
2322
|
-
function
|
|
2317
|
+
function main_(e) {
|
|
2323
2318
|
for(const t in e){
|
|
2324
|
-
if (!Object.prototype.hasOwnProperty.call(e, t) || !
|
|
2319
|
+
if (!Object.prototype.hasOwnProperty.call(e, t) || !main_h.test(t)) continue;
|
|
2325
2320
|
const n = e[t];
|
|
2326
2321
|
if (!n) break;
|
|
2327
2322
|
return {
|
|
@@ -2329,35 +2324,36 @@ function main_h(e) {
|
|
|
2329
2324
|
value: n
|
|
2330
2325
|
};
|
|
2331
2326
|
}
|
|
2332
|
-
return
|
|
2327
|
+
return main_g;
|
|
2333
2328
|
}
|
|
2334
|
-
function
|
|
2329
|
+
function main_v(e, t) {
|
|
2335
2330
|
const n = t.value.split(delimiter);
|
|
2336
|
-
const
|
|
2337
|
-
let
|
|
2331
|
+
const r = [];
|
|
2332
|
+
let o = e;
|
|
2338
2333
|
let c;
|
|
2339
2334
|
do {
|
|
2340
|
-
|
|
2341
|
-
c =
|
|
2342
|
-
|
|
2343
|
-
}while (
|
|
2344
|
-
|
|
2345
|
-
const l =
|
|
2335
|
+
r.push(resolve(o, "node_modules", ".bin"));
|
|
2336
|
+
c = o;
|
|
2337
|
+
o = dirname(o);
|
|
2338
|
+
}while (o !== c);
|
|
2339
|
+
r.push(dirname(process.execPath));
|
|
2340
|
+
const l = r.concat(n).join(delimiter);
|
|
2346
2341
|
return {
|
|
2347
2342
|
key: t.key,
|
|
2348
2343
|
value: l
|
|
2349
2344
|
};
|
|
2350
2345
|
}
|
|
2351
|
-
function
|
|
2352
|
-
const
|
|
2346
|
+
function main_y(e, t, n = true) {
|
|
2347
|
+
const r = {
|
|
2353
2348
|
...process.env,
|
|
2354
2349
|
...t
|
|
2355
2350
|
};
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2351
|
+
if (!n) return r;
|
|
2352
|
+
const i = main_v(e, main_(r));
|
|
2353
|
+
r[i.key] = i.value;
|
|
2354
|
+
return r;
|
|
2359
2355
|
}
|
|
2360
|
-
const
|
|
2356
|
+
const main_b = (e)=>{
|
|
2361
2357
|
let t = e.length;
|
|
2362
2358
|
const n = new PassThrough();
|
|
2363
2359
|
const r = ()=>{
|
|
@@ -2368,396 +2364,112 @@ const main_v = (e)=>{
|
|
|
2368
2364
|
}).then(r).catch(r);
|
|
2369
2365
|
return n;
|
|
2370
2366
|
};
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
}
|
|
2395
|
-
function o(e, t) {
|
|
2396
|
-
return i(n.statSync(e), e, t);
|
|
2397
|
-
}
|
|
2398
|
-
});
|
|
2399
|
-
var main_b = /* @__PURE__ */ main_d((e, t)=>{
|
|
2400
|
-
t.exports = r;
|
|
2401
|
-
r.sync = i;
|
|
2402
|
-
var n = main_f("fs");
|
|
2403
|
-
function r(e, t, r) {
|
|
2404
|
-
n.stat(e, function(e, n) {
|
|
2405
|
-
r(e, e ? false : a(n, t));
|
|
2406
|
-
});
|
|
2407
|
-
}
|
|
2408
|
-
function i(e, t) {
|
|
2409
|
-
return a(n.statSync(e), t);
|
|
2410
|
-
}
|
|
2411
|
-
function a(e, t) {
|
|
2412
|
-
return e.isFile() && o(e, t);
|
|
2413
|
-
}
|
|
2414
|
-
function o(e, t) {
|
|
2415
|
-
var n = e.mode;
|
|
2416
|
-
var r = e.uid;
|
|
2417
|
-
var i = e.gid;
|
|
2418
|
-
var a = void 0 !== t.uid ? t.uid : process.getuid && process.getuid();
|
|
2419
|
-
var o = void 0 !== t.gid ? t.gid : process.getgid && process.getgid();
|
|
2420
|
-
var s = parseInt("100", 8);
|
|
2421
|
-
var c = parseInt("010", 8);
|
|
2422
|
-
var l = parseInt("001", 8);
|
|
2423
|
-
var u = s | c;
|
|
2424
|
-
return n & l || n & c && i === o || n & s && r === a || n & u && 0 === a;
|
|
2425
|
-
}
|
|
2426
|
-
});
|
|
2427
|
-
var main_x = /* @__PURE__ */ main_d((e, t)=>{
|
|
2428
|
-
main_f("fs");
|
|
2429
|
-
var n;
|
|
2430
|
-
n = "win32" === process.platform || global.TESTING_WINDOWS ? main_y() : main_b();
|
|
2431
|
-
t.exports = r;
|
|
2432
|
-
r.sync = i;
|
|
2433
|
-
function r(e, t, i) {
|
|
2434
|
-
if ("function" == typeof t) {
|
|
2435
|
-
i = t;
|
|
2436
|
-
t = {};
|
|
2437
|
-
}
|
|
2438
|
-
if (!i) {
|
|
2439
|
-
if ("function" != typeof Promise) throw new TypeError("callback not provided");
|
|
2440
|
-
return new Promise(function(n, i) {
|
|
2441
|
-
r(e, t || {}, function(e, t) {
|
|
2442
|
-
if (e) i(e);
|
|
2443
|
-
else n(t);
|
|
2444
|
-
});
|
|
2445
|
-
});
|
|
2446
|
-
}
|
|
2447
|
-
n(e, t || {}, function(e, n) {
|
|
2448
|
-
if (e) {
|
|
2449
|
-
if ("EACCES" === e.code || t && t.ignoreErrors) {
|
|
2450
|
-
e = null;
|
|
2451
|
-
n = false;
|
|
2452
|
-
}
|
|
2453
|
-
}
|
|
2454
|
-
i(e, n);
|
|
2455
|
-
});
|
|
2456
|
-
}
|
|
2457
|
-
function i(e, t) {
|
|
2367
|
+
const main_x = /([()\][%!^"`<>&|;, *?])/g;
|
|
2368
|
+
const main_S = /^#!\s*(.+)/;
|
|
2369
|
+
const main_C = /\.(?:com|exe)$/i;
|
|
2370
|
+
const main_w = /node_modules[\\/]\.bin[\\/][^\\/]+\.cmd$/i;
|
|
2371
|
+
const main_T = "win32" === process.platform;
|
|
2372
|
+
const main_E = [
|
|
2373
|
+
".EXE",
|
|
2374
|
+
".CMD",
|
|
2375
|
+
".BAT",
|
|
2376
|
+
".COM"
|
|
2377
|
+
];
|
|
2378
|
+
function main_D(e, t = [], n = {}) {
|
|
2379
|
+
if (true === n.shell || !main_T) return {
|
|
2380
|
+
command: e,
|
|
2381
|
+
args: t,
|
|
2382
|
+
options: n
|
|
2383
|
+
};
|
|
2384
|
+
let i = main_O(e, n);
|
|
2385
|
+
let a = null;
|
|
2386
|
+
if (null !== i) {
|
|
2387
|
+
const e = 150;
|
|
2388
|
+
const t = Buffer.alloc(e);
|
|
2389
|
+
let n = null;
|
|
2458
2390
|
try {
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
}
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
] : [
|
|
2479
|
-
...n ? [
|
|
2480
|
-
process.cwd()
|
|
2481
|
-
] : [],
|
|
2482
|
-
...(t.path || process.env.PATH || "").split(r)
|
|
2391
|
+
n = openSync(i, "r");
|
|
2392
|
+
readSync(n, t, 0, e, 0);
|
|
2393
|
+
} catch {} finally{
|
|
2394
|
+
if (null !== n) closeSync(n);
|
|
2395
|
+
}
|
|
2396
|
+
const o = t.toString().match(main_S);
|
|
2397
|
+
if (null !== o) {
|
|
2398
|
+
const e = o[1].trim();
|
|
2399
|
+
const t = e.indexOf(" ");
|
|
2400
|
+
const n = -1 !== t ? e.slice(0, t) : e;
|
|
2401
|
+
const i = -1 !== t ? e.slice(t + 1) : "";
|
|
2402
|
+
const s = basename(n);
|
|
2403
|
+
a = "env" === s ? i || null : s;
|
|
2404
|
+
}
|
|
2405
|
+
}
|
|
2406
|
+
if (null !== a && null !== i) {
|
|
2407
|
+
t = [
|
|
2408
|
+
i,
|
|
2409
|
+
...t
|
|
2483
2410
|
];
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2411
|
+
e = a;
|
|
2412
|
+
i = main_O(e, n);
|
|
2413
|
+
}
|
|
2414
|
+
if (null === i || !main_C.test(i)) {
|
|
2415
|
+
const r = null !== i && main_w.test(i);
|
|
2416
|
+
e = external_node_path_normalize(e);
|
|
2417
|
+
e = e.replace(main_x, "^$1");
|
|
2418
|
+
t = t.map((e)=>{
|
|
2419
|
+
e = e.replace(/(?=(\\+?)?)\1"/g, "$1$1\\\"");
|
|
2420
|
+
e = e.replace(/(?=(\\+?)?)\1$/, "$1$1");
|
|
2421
|
+
e = `"${e}"`;
|
|
2422
|
+
e = e.replace(main_x, "^$1");
|
|
2423
|
+
if (r) e = e.replace(main_x, "^$1");
|
|
2424
|
+
return e;
|
|
2425
|
+
});
|
|
2426
|
+
t = [
|
|
2427
|
+
"/d",
|
|
2428
|
+
"/s",
|
|
2429
|
+
"/c",
|
|
2430
|
+
`"${[
|
|
2431
|
+
e,
|
|
2432
|
+
...t
|
|
2433
|
+
].join(" ")}"`
|
|
2487
2434
|
];
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
pathEnv: a,
|
|
2493
|
-
pathExt: s,
|
|
2494
|
-
pathExtExe: o
|
|
2435
|
+
e = n.env?.comspec ?? "cmd.exe";
|
|
2436
|
+
n = {
|
|
2437
|
+
...n,
|
|
2438
|
+
windowsVerbatimArguments: true
|
|
2495
2439
|
};
|
|
2496
|
-
};
|
|
2497
|
-
const c = (e, t, n)=>{
|
|
2498
|
-
if ("function" == typeof t) {
|
|
2499
|
-
n = t;
|
|
2500
|
-
t = {};
|
|
2501
|
-
}
|
|
2502
|
-
if (!t) t = {};
|
|
2503
|
-
const { pathEnv: i, pathExt: c, pathExtExe: l } = s(e, t);
|
|
2504
|
-
const u = [];
|
|
2505
|
-
const d = (n)=>new Promise((a, s)=>{
|
|
2506
|
-
if (n === i.length) return t.all && u.length ? a(u) : s(o(e));
|
|
2507
|
-
const c = i[n];
|
|
2508
|
-
const l = /^".*"$/.test(c) ? c.slice(1, -1) : c;
|
|
2509
|
-
const d = r.join(l, e);
|
|
2510
|
-
a(f(!l && /^\.[\\\/]/.test(e) ? e.slice(0, 2) + d : d, n, 0));
|
|
2511
|
-
});
|
|
2512
|
-
const f = (e, n, r)=>new Promise((i, o)=>{
|
|
2513
|
-
if (r === c.length) return i(d(n + 1));
|
|
2514
|
-
const s = c[r];
|
|
2515
|
-
a(e + s, {
|
|
2516
|
-
pathExt: l
|
|
2517
|
-
}, (a, o)=>{
|
|
2518
|
-
if (!a && o) if (!t.all) return i(e + s);
|
|
2519
|
-
else u.push(e + s);
|
|
2520
|
-
return i(f(e, n, r + 1));
|
|
2521
|
-
});
|
|
2522
|
-
});
|
|
2523
|
-
return n ? d(0).then((e)=>n(null, e), n) : d(0);
|
|
2524
|
-
};
|
|
2525
|
-
const l = (e, t)=>{
|
|
2526
|
-
t = t || {};
|
|
2527
|
-
const { pathEnv: n, pathExt: i, pathExtExe: c } = s(e, t);
|
|
2528
|
-
const l = [];
|
|
2529
|
-
for(let o = 0; o < n.length; o++){
|
|
2530
|
-
const s = n[o];
|
|
2531
|
-
const u = /^".*"$/.test(s) ? s.slice(1, -1) : s;
|
|
2532
|
-
const d = r.join(u, e);
|
|
2533
|
-
const f = !u && /^\.[\\\/]/.test(e) ? e.slice(0, 2) + d : d;
|
|
2534
|
-
for(let e = 0; e < i.length; e++){
|
|
2535
|
-
const n = f + i[e];
|
|
2536
|
-
try {
|
|
2537
|
-
if (a.sync(n, {
|
|
2538
|
-
pathExt: c
|
|
2539
|
-
})) if (!t.all) return n;
|
|
2540
|
-
else l.push(n);
|
|
2541
|
-
} catch (e) {}
|
|
2542
|
-
}
|
|
2543
|
-
}
|
|
2544
|
-
if (t.all && l.length) return l;
|
|
2545
|
-
if (t.nothrow) return null;
|
|
2546
|
-
throw o(e);
|
|
2547
|
-
};
|
|
2548
|
-
t.exports = c;
|
|
2549
|
-
c.sync = l;
|
|
2550
|
-
});
|
|
2551
|
-
var main_C = /* @__PURE__ */ main_d((e, t)=>{
|
|
2552
|
-
const n = (e = {})=>{
|
|
2553
|
-
const t = e.env || process.env;
|
|
2554
|
-
if ("win32" !== (e.platform || process.platform)) return "PATH";
|
|
2555
|
-
return Object.keys(t).reverse().find((e)=>"PATH" === e.toUpperCase()) || "Path";
|
|
2556
|
-
};
|
|
2557
|
-
t.exports = n;
|
|
2558
|
-
t.exports.default = n;
|
|
2559
|
-
});
|
|
2560
|
-
var main_w = /* @__PURE__ */ main_d((e, t)=>{
|
|
2561
|
-
const n = main_f("path");
|
|
2562
|
-
const r = main_S();
|
|
2563
|
-
const i = main_C();
|
|
2564
|
-
function a(e, t) {
|
|
2565
|
-
const a = e.options.env || process.env;
|
|
2566
|
-
const o = process.cwd();
|
|
2567
|
-
const s = null != e.options.cwd;
|
|
2568
|
-
const c = s && void 0 !== process.chdir && !process.chdir.disabled;
|
|
2569
|
-
if (c) try {
|
|
2570
|
-
process.chdir(e.options.cwd);
|
|
2571
|
-
} catch (e) {}
|
|
2572
|
-
let l;
|
|
2573
|
-
try {
|
|
2574
|
-
l = r.sync(e.command, {
|
|
2575
|
-
path: a[i({
|
|
2576
|
-
env: a
|
|
2577
|
-
})],
|
|
2578
|
-
pathExt: t ? n.delimiter : void 0
|
|
2579
|
-
});
|
|
2580
|
-
} catch (e) {} finally{
|
|
2581
|
-
if (c) process.chdir(o);
|
|
2582
|
-
}
|
|
2583
|
-
if (l) l = n.resolve(s ? e.options.cwd : "", l);
|
|
2584
|
-
return l;
|
|
2585
2440
|
}
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
});
|
|
2591
|
-
var main_T = /* @__PURE__ */ main_d((e, t)=>{
|
|
2592
|
-
const n = /([()\][%!^"`<>&|;, *?])/g;
|
|
2593
|
-
function r(e) {
|
|
2594
|
-
e = e.replace(n, "^$1");
|
|
2595
|
-
return e;
|
|
2596
|
-
}
|
|
2597
|
-
function i(e, t) {
|
|
2598
|
-
e = `${e}`;
|
|
2599
|
-
e = e.replace(/(?=(\\+?)?)\1"/g, "$1$1\\\"");
|
|
2600
|
-
e = e.replace(/(?=(\\+?)?)\1$/, "$1$1");
|
|
2601
|
-
e = `"${e}"`;
|
|
2602
|
-
e = e.replace(n, "^$1");
|
|
2603
|
-
if (t) e = e.replace(n, "^$1");
|
|
2604
|
-
return e;
|
|
2605
|
-
}
|
|
2606
|
-
t.exports.command = r;
|
|
2607
|
-
t.exports.argument = i;
|
|
2608
|
-
});
|
|
2609
|
-
var main_E = /* @__PURE__ */ main_d((e, t)=>{
|
|
2610
|
-
t.exports = /^#!(.*)/;
|
|
2611
|
-
});
|
|
2612
|
-
var main_D = /* @__PURE__ */ main_d((e, t)=>{
|
|
2613
|
-
const n = main_E();
|
|
2614
|
-
t.exports = (e = "")=>{
|
|
2615
|
-
const t = e.match(n);
|
|
2616
|
-
if (!t) return null;
|
|
2617
|
-
const [r, i] = t[0].replace(/#! ?/, "").split(" ");
|
|
2618
|
-
const a = r.split("/").pop();
|
|
2619
|
-
if ("env" === a) return i;
|
|
2620
|
-
return i ? `${a} ${i}` : a;
|
|
2441
|
+
return {
|
|
2442
|
+
command: e,
|
|
2443
|
+
args: t,
|
|
2444
|
+
options: n
|
|
2621
2445
|
};
|
|
2622
|
-
}
|
|
2623
|
-
|
|
2624
|
-
const
|
|
2625
|
-
const
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
const a = main_O();
|
|
2644
|
-
const o = "win32" === process.platform;
|
|
2645
|
-
const s = /\.(?:com|exe)$/i;
|
|
2646
|
-
const c = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
|
|
2647
|
-
function l(e) {
|
|
2648
|
-
e.file = r(e);
|
|
2649
|
-
const t = e.file && a(e.file);
|
|
2650
|
-
if (t) {
|
|
2651
|
-
e.args.unshift(e.file);
|
|
2652
|
-
e.command = t;
|
|
2653
|
-
return r(e);
|
|
2654
|
-
}
|
|
2655
|
-
return e.file;
|
|
2656
|
-
}
|
|
2657
|
-
function u(e) {
|
|
2658
|
-
if (!o) return e;
|
|
2659
|
-
const t = l(e);
|
|
2660
|
-
const r = !s.test(t);
|
|
2661
|
-
if (e.options.forceShell || r) {
|
|
2662
|
-
const r = c.test(t);
|
|
2663
|
-
e.command = n.normalize(e.command);
|
|
2664
|
-
e.command = i.command(e.command);
|
|
2665
|
-
e.args = e.args.map((e)=>i.argument(e, r));
|
|
2666
|
-
e.args = [
|
|
2667
|
-
"/d",
|
|
2668
|
-
"/s",
|
|
2669
|
-
"/c",
|
|
2670
|
-
`"${[
|
|
2671
|
-
e.command
|
|
2672
|
-
].concat(e.args).join(" ")}"`
|
|
2673
|
-
];
|
|
2674
|
-
e.command = process.env.comspec || "cmd.exe";
|
|
2675
|
-
e.options.windowsVerbatimArguments = true;
|
|
2676
|
-
}
|
|
2677
|
-
return e;
|
|
2678
|
-
}
|
|
2679
|
-
function d(e, t, n) {
|
|
2680
|
-
if (t && !Array.isArray(t)) {
|
|
2681
|
-
n = t;
|
|
2682
|
-
t = null;
|
|
2683
|
-
}
|
|
2684
|
-
t = t ? t.slice(0) : [];
|
|
2685
|
-
n = Object.assign({}, n);
|
|
2686
|
-
const r = {
|
|
2687
|
-
command: e,
|
|
2688
|
-
args: t,
|
|
2689
|
-
options: n,
|
|
2690
|
-
file: void 0,
|
|
2691
|
-
original: {
|
|
2692
|
-
command: e,
|
|
2693
|
-
args: t
|
|
2694
|
-
}
|
|
2695
|
-
};
|
|
2696
|
-
return n.shell ? r : u(r);
|
|
2697
|
-
}
|
|
2698
|
-
t.exports = d;
|
|
2699
|
-
});
|
|
2700
|
-
var main_A = /* @__PURE__ */ main_d((e, t)=>{
|
|
2701
|
-
const n = "win32" === process.platform;
|
|
2702
|
-
function r(e, t) {
|
|
2703
|
-
return Object.assign(/* @__PURE__ */ new Error(`${t} ${e.command} ENOENT`), {
|
|
2704
|
-
code: "ENOENT",
|
|
2705
|
-
errno: "ENOENT",
|
|
2706
|
-
syscall: `${t} ${e.command}`,
|
|
2707
|
-
path: e.command,
|
|
2708
|
-
spawnargs: e.args
|
|
2709
|
-
});
|
|
2710
|
-
}
|
|
2711
|
-
function i(e, t) {
|
|
2712
|
-
if (!n) return;
|
|
2713
|
-
const r = e.emit;
|
|
2714
|
-
e.emit = function(n, i) {
|
|
2715
|
-
if ("exit" === n) {
|
|
2716
|
-
const n = a(i, t);
|
|
2717
|
-
if (n) return r.call(e, "error", n);
|
|
2718
|
-
}
|
|
2719
|
-
return r.apply(e, arguments);
|
|
2720
|
-
};
|
|
2721
|
-
}
|
|
2722
|
-
function a(e, t) {
|
|
2723
|
-
if (n && 1 === e && !t.file) return r(t.original, "spawn");
|
|
2724
|
-
return null;
|
|
2725
|
-
}
|
|
2726
|
-
function o(e, t) {
|
|
2727
|
-
if (n && 1 === e && !t.file) return r(t.original, "spawnSync");
|
|
2728
|
-
return null;
|
|
2446
|
+
}
|
|
2447
|
+
function main_O(e, t) {
|
|
2448
|
+
const r = (t.cwd ?? external_node_process_cwd()).toString();
|
|
2449
|
+
const a = t.env ?? process.env;
|
|
2450
|
+
const o = main_(a).value;
|
|
2451
|
+
const c = e.includes("/") || e.includes("\\") ? [
|
|
2452
|
+
""
|
|
2453
|
+
] : [
|
|
2454
|
+
r,
|
|
2455
|
+
...o.split(delimiter)
|
|
2456
|
+
];
|
|
2457
|
+
const l = a.PATHEXT ? a.PATHEXT.split(delimiter) : main_E;
|
|
2458
|
+
if (e.includes(".") && "" !== l[0]) l.unshift("");
|
|
2459
|
+
for (const t of c){
|
|
2460
|
+
const n = resolve(r, t.startsWith("\"") && t.endsWith("\"") && t.length > 1 ? t.slice(1, -1) : t, e);
|
|
2461
|
+
for (const e of l){
|
|
2462
|
+
const t = n + e;
|
|
2463
|
+
try {
|
|
2464
|
+
if (statSync(t).isFile()) return t;
|
|
2465
|
+
} catch {}
|
|
2466
|
+
}
|
|
2729
2467
|
}
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
};
|
|
2736
|
-
});
|
|
2737
|
-
var main_j = /* @__PURE__ */ main_d((e, t)=>{
|
|
2738
|
-
const n = main_f("child_process");
|
|
2739
|
-
const r = main_k();
|
|
2740
|
-
const i = main_A();
|
|
2741
|
-
function a(e, t, a) {
|
|
2742
|
-
const o = r(e, t, a);
|
|
2743
|
-
const s = n.spawn(o.command, o.args, o.options);
|
|
2744
|
-
i.hookChildProcess(s, o);
|
|
2745
|
-
return s;
|
|
2746
|
-
}
|
|
2747
|
-
function o(e, t, a) {
|
|
2748
|
-
const o = r(e, t, a);
|
|
2749
|
-
const s = n.spawnSync(o.command, o.args, o.options);
|
|
2750
|
-
s.error = s.error || i.verifyENOENTSync(s.status, o);
|
|
2751
|
-
return s;
|
|
2752
|
-
}
|
|
2753
|
-
t.exports = a;
|
|
2754
|
-
t.exports.spawn = a;
|
|
2755
|
-
t.exports.sync = o;
|
|
2756
|
-
t.exports._parse = r;
|
|
2757
|
-
t.exports._enoent = i;
|
|
2758
|
-
});
|
|
2759
|
-
var main_M = main_j();
|
|
2760
|
-
var main_N = class extends Error {
|
|
2468
|
+
return null;
|
|
2469
|
+
}
|
|
2470
|
+
var main_k = class extends Error {
|
|
2471
|
+
result;
|
|
2472
|
+
output;
|
|
2761
2473
|
get exitCode() {
|
|
2762
2474
|
if (null !== this.result.exitCode) return this.result.exitCode;
|
|
2763
2475
|
}
|
|
@@ -2767,20 +2479,14 @@ var main_N = class extends Error {
|
|
|
2767
2479
|
this.output = t;
|
|
2768
2480
|
}
|
|
2769
2481
|
};
|
|
2770
|
-
const
|
|
2482
|
+
const main_j = {
|
|
2771
2483
|
timeout: void 0,
|
|
2772
2484
|
persist: false
|
|
2773
2485
|
};
|
|
2774
|
-
const
|
|
2486
|
+
const main_N = {
|
|
2775
2487
|
windowsHide: true
|
|
2776
2488
|
};
|
|
2777
|
-
function
|
|
2778
|
-
return {
|
|
2779
|
-
command: external_node_path_normalize(e),
|
|
2780
|
-
args: t ?? []
|
|
2781
|
-
};
|
|
2782
|
-
}
|
|
2783
|
-
function main_z(e) {
|
|
2489
|
+
function main_P(e) {
|
|
2784
2490
|
const t = new AbortController();
|
|
2785
2491
|
for (const n of e){
|
|
2786
2492
|
if (n.aborted) {
|
|
@@ -2796,14 +2502,14 @@ function main_z(e) {
|
|
|
2796
2502
|
}
|
|
2797
2503
|
return t.signal;
|
|
2798
2504
|
}
|
|
2799
|
-
async function
|
|
2505
|
+
async function main_F(e) {
|
|
2800
2506
|
let t = "";
|
|
2801
2507
|
try {
|
|
2802
2508
|
for await (const n of e)t += n.toString();
|
|
2803
2509
|
} catch {}
|
|
2804
2510
|
return t;
|
|
2805
2511
|
}
|
|
2806
|
-
var
|
|
2512
|
+
var main_I = class {
|
|
2807
2513
|
_process;
|
|
2808
2514
|
_aborted = false;
|
|
2809
2515
|
_options;
|
|
@@ -2823,7 +2529,7 @@ var main_V = class {
|
|
|
2823
2529
|
}
|
|
2824
2530
|
constructor(e, t, n){
|
|
2825
2531
|
this._options = {
|
|
2826
|
-
...
|
|
2532
|
+
...main_j,
|
|
2827
2533
|
...n
|
|
2828
2534
|
};
|
|
2829
2535
|
this._command = e;
|
|
@@ -2842,7 +2548,7 @@ var main_V = class {
|
|
|
2842
2548
|
return this._process?.killed === true;
|
|
2843
2549
|
}
|
|
2844
2550
|
pipe(e, t, n) {
|
|
2845
|
-
return
|
|
2551
|
+
return main_z(e, t, {
|
|
2846
2552
|
...n,
|
|
2847
2553
|
stdin: this
|
|
2848
2554
|
});
|
|
@@ -2853,7 +2559,7 @@ var main_V = class {
|
|
|
2853
2559
|
const t = [];
|
|
2854
2560
|
if (this._streamErr) t.push(this._streamErr);
|
|
2855
2561
|
if (this._streamOut) t.push(this._streamOut);
|
|
2856
|
-
const n =
|
|
2562
|
+
const n = main_b(t);
|
|
2857
2563
|
const r = node_readline.createInterface({
|
|
2858
2564
|
input: n
|
|
2859
2565
|
});
|
|
@@ -2861,14 +2567,14 @@ var main_V = class {
|
|
|
2861
2567
|
await this._processClosed;
|
|
2862
2568
|
e.removeAllListeners();
|
|
2863
2569
|
if (this._thrownError) throw this._thrownError;
|
|
2864
|
-
if (this._options?.throwOnError && 0 !== this.exitCode && void 0 !== this.exitCode) throw new
|
|
2570
|
+
if (this._options?.throwOnError && 0 !== this.exitCode && void 0 !== this.exitCode) throw new main_k(this);
|
|
2865
2571
|
}
|
|
2866
2572
|
async _waitForOutput() {
|
|
2867
2573
|
const e = this._process;
|
|
2868
2574
|
if (!e) throw new Error("No process was started");
|
|
2869
2575
|
const [t, n] = await Promise.all([
|
|
2870
|
-
this._streamOut ?
|
|
2871
|
-
this._streamErr ?
|
|
2576
|
+
this._streamOut ? main_F(this._streamOut) : "",
|
|
2577
|
+
this._streamErr ? main_F(this._streamErr) : ""
|
|
2872
2578
|
]);
|
|
2873
2579
|
await this._processClosed;
|
|
2874
2580
|
const { stdin: r } = this._options;
|
|
@@ -2880,7 +2586,7 @@ var main_V = class {
|
|
|
2880
2586
|
stdout: t,
|
|
2881
2587
|
exitCode: this.exitCode
|
|
2882
2588
|
};
|
|
2883
|
-
if (this._options.throwOnError && 0 !== this.exitCode && void 0 !== this.exitCode) throw new
|
|
2589
|
+
if (this._options.throwOnError && 0 !== this.exitCode && void 0 !== this.exitCode) throw new main_k(this, i);
|
|
2884
2590
|
return i;
|
|
2885
2591
|
}
|
|
2886
2592
|
then(e, t) {
|
|
@@ -2889,31 +2595,30 @@ var main_V = class {
|
|
|
2889
2595
|
_streamOut;
|
|
2890
2596
|
_streamErr;
|
|
2891
2597
|
spawn() {
|
|
2892
|
-
const
|
|
2893
|
-
const
|
|
2894
|
-
const
|
|
2895
|
-
...
|
|
2896
|
-
...
|
|
2598
|
+
const t = external_node_process_cwd();
|
|
2599
|
+
const r = this._options;
|
|
2600
|
+
const i = {
|
|
2601
|
+
...main_N,
|
|
2602
|
+
...r.nodeOptions
|
|
2897
2603
|
};
|
|
2898
|
-
const
|
|
2604
|
+
const a = [];
|
|
2899
2605
|
this._resetState();
|
|
2900
|
-
if (void 0 !==
|
|
2901
|
-
if (void 0 !==
|
|
2902
|
-
if (true ===
|
|
2903
|
-
if (
|
|
2904
|
-
|
|
2905
|
-
const
|
|
2906
|
-
const
|
|
2907
|
-
|
|
2908
|
-
if (
|
|
2909
|
-
|
|
2910
|
-
this.
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
else e?.process?.stdout?.pipe(l.stdin);
|
|
2606
|
+
if (void 0 !== r.timeout) a.push(AbortSignal.timeout(r.timeout));
|
|
2607
|
+
if (void 0 !== r.signal) a.push(r.signal);
|
|
2608
|
+
if (true === r.persist) i.detached = true;
|
|
2609
|
+
if (a.length > 0) i.signal = main_P(a);
|
|
2610
|
+
i.env = main_y(t, i.env, r.nodePath);
|
|
2611
|
+
const o = main_D(this._command, this._args, i);
|
|
2612
|
+
const s = spawn(o.command, o.args, o.options);
|
|
2613
|
+
if (s.stderr) this._streamErr = s.stderr;
|
|
2614
|
+
if (s.stdout) this._streamOut = s.stdout;
|
|
2615
|
+
this._process = s;
|
|
2616
|
+
s.once("error", this._onError);
|
|
2617
|
+
s.once("close", this._onClose);
|
|
2618
|
+
if (s.stdin) {
|
|
2619
|
+
const { stdin: e } = r;
|
|
2620
|
+
if ("string" == typeof e) s.stdin.end(e);
|
|
2621
|
+
else e?.process?.stdout?.pipe(s.stdin);
|
|
2917
2622
|
}
|
|
2918
2623
|
}
|
|
2919
2624
|
_resetState() {
|
|
@@ -2934,12 +2639,12 @@ var main_V = class {
|
|
|
2934
2639
|
if (this._resolveClose) this._resolveClose();
|
|
2935
2640
|
};
|
|
2936
2641
|
};
|
|
2937
|
-
const
|
|
2938
|
-
const r = new
|
|
2642
|
+
const main_R = (e, t, n)=>{
|
|
2643
|
+
const r = new main_I(e, t, n);
|
|
2939
2644
|
r.spawn();
|
|
2940
2645
|
return r;
|
|
2941
2646
|
};
|
|
2942
|
-
const
|
|
2647
|
+
const main_z = main_R;
|
|
2943
2648
|
const NPM_TEMPLATE_PREFIX = 'npm:';
|
|
2944
2649
|
const VALID_NPM_NAME = /^(@[\w.-]+\/)?[\w.-]+$/;
|
|
2945
2650
|
const VALID_NPM_VERSION = /^[\w.\-+^~>=<* ]+$/;
|
|
@@ -3033,11 +2738,11 @@ var minimist_default = /*#__PURE__*/ __webpack_require__.n(minimist);
|
|
|
3033
2738
|
const src_filename = fileURLToPath(import.meta.url);
|
|
3034
2739
|
const src_dirname = dirname(src_filename);
|
|
3035
2740
|
function cancelAndExit() {
|
|
3036
|
-
|
|
2741
|
+
me('Operation cancelled.');
|
|
3037
2742
|
process.exit(0);
|
|
3038
2743
|
}
|
|
3039
2744
|
function checkCancel(value) {
|
|
3040
|
-
if (
|
|
2745
|
+
if (q(value)) cancelAndExit();
|
|
3041
2746
|
return value;
|
|
3042
2747
|
}
|
|
3043
2748
|
function formatProjectName(input) {
|
|
@@ -3129,12 +2834,12 @@ async function getTools({ tools, dir, template }, extraTools, templateName) {
|
|
|
3129
2834
|
if (dir && template) return [];
|
|
3130
2835
|
const options = [
|
|
3131
2836
|
{
|
|
3132
|
-
value: '
|
|
3133
|
-
label: '
|
|
2837
|
+
value: 'rslint',
|
|
2838
|
+
label: 'Rslint - linting'
|
|
3134
2839
|
},
|
|
3135
2840
|
{
|
|
3136
|
-
value: '
|
|
3137
|
-
label: '
|
|
2841
|
+
value: 'eslint',
|
|
2842
|
+
label: 'ESLint - linting'
|
|
3138
2843
|
},
|
|
3139
2844
|
{
|
|
3140
2845
|
value: 'prettier',
|
|
@@ -3154,7 +2859,7 @@ async function getTools({ tools, dir, template }, extraTools, templateName) {
|
|
|
3154
2859
|
options.unshift(...filteredExtraTools.filter((tool)=>'pre' === tool.order).map(normalize));
|
|
3155
2860
|
options.push(...filteredExtraTools.filter((tool)=>'pre' !== tool.order).map(normalize));
|
|
3156
2861
|
}
|
|
3157
|
-
return checkCancel(await
|
|
2862
|
+
return checkCancel(await ve({
|
|
3158
2863
|
message: 'Select additional tools (Use <space> to select, <enter> to continue)',
|
|
3159
2864
|
options,
|
|
3160
2865
|
required: false
|
|
@@ -3177,7 +2882,7 @@ function orderExtraSkills(extraSkills) {
|
|
|
3177
2882
|
...extraSkills.filter((extraSkill)=>'post' === extraSkill.order)
|
|
3178
2883
|
];
|
|
3179
2884
|
}
|
|
3180
|
-
async function getSkills({ skill, dir, template }, extraSkills, templateName, tools = [], promptMultiselect =
|
|
2885
|
+
async function getSkills({ skill, dir, template }, extraSkills, templateName, tools = [], promptMultiselect = ve) {
|
|
3181
2886
|
const parsedSkills = parseSkillsOption(skill);
|
|
3182
2887
|
const filteredExtraSkills = filterExtraSkills(extraSkills, templateName, tools);
|
|
3183
2888
|
if (null !== parsedSkills) return parsedSkills.filter((value)=>extraSkills?.some((extraSkill)=>extraSkill.value === value));
|
|
@@ -3224,7 +2929,7 @@ async function runCommand(command, cwd, packageManager) {
|
|
|
3224
2929
|
if (replacement) command = command.replace('npm create ', replacement).replace(' -- --', ' --');
|
|
3225
2930
|
if ('yarn' === packageManager) command = command.replace('@latest', '');
|
|
3226
2931
|
}
|
|
3227
|
-
const result = await
|
|
2932
|
+
const result = await main_R(command, [], {
|
|
3228
2933
|
nodeOptions: {
|
|
3229
2934
|
shell: true,
|
|
3230
2935
|
stdio: 'inherit',
|
|
@@ -3257,13 +2962,13 @@ async function runSkillCommand(skills, cwd) {
|
|
|
3257
2962
|
...installArgs
|
|
3258
2963
|
];
|
|
3259
2964
|
const command = `npx ${args.join(' ')}`;
|
|
3260
|
-
|
|
2965
|
+
dist_R.info(`Running skill install command: ${color.dim(command)}`);
|
|
3261
2966
|
const skillLabel = skills.map((skill)=>skill.value).join(', ');
|
|
3262
2967
|
const skillNoun = 1 === skills.length ? 'skill' : 'skills';
|
|
3263
|
-
const installationTaskLog =
|
|
2968
|
+
const installationTaskLog = Oe({
|
|
3264
2969
|
title: `Installing ${skillNoun} ${skillLabel}`
|
|
3265
2970
|
});
|
|
3266
|
-
const proc =
|
|
2971
|
+
const proc = main_R('npx', args, {
|
|
3267
2972
|
nodeOptions: {
|
|
3268
2973
|
cwd,
|
|
3269
2974
|
stdio: 'pipe'
|
|
@@ -3286,8 +2991,8 @@ function logNextStepsAndOutro(noteInformation, targetDir, packageManager) {
|
|
|
3286
2991
|
`3. ${color.cyan(`${packageManager} install`)}`,
|
|
3287
2992
|
`4. ${color.cyan(`${packageManager} run dev`)}`
|
|
3288
2993
|
];
|
|
3289
|
-
if (nextSteps.length)
|
|
3290
|
-
|
|
2994
|
+
if (nextSteps.length) Se(nextSteps.map((step)=>color.reset(step)).join('\n'), 'Next steps');
|
|
2995
|
+
ye('All set, happy coding!');
|
|
3291
2996
|
}
|
|
3292
2997
|
async function create({ name, root, templates, skipFiles, getTemplateName, mapESLintTemplate, mapRslintTemplate, version, noteInformation, extraTools, extraSkills, argv: processArgv = process.argv }) {
|
|
3293
2998
|
src_logger.greet(`\n◆ Create ${upperFirst(name)} Project`);
|
|
@@ -3305,7 +3010,7 @@ async function create({ name, root, templates, skipFiles, getTemplateName, mapES
|
|
|
3305
3010
|
packageManager
|
|
3306
3011
|
};
|
|
3307
3012
|
if (!version) version = (await readPackageJson(root)).version;
|
|
3308
|
-
const projectName = argv.dir ?? checkCancel(await
|
|
3013
|
+
const projectName = argv.dir ?? checkCancel(await Pe({
|
|
3309
3014
|
message: 'Project name or path',
|
|
3310
3015
|
placeholder: `${name.toLowerCase()}-project`,
|
|
3311
3016
|
defaultValue: `${name.toLowerCase()}-project`,
|
|
@@ -3318,7 +3023,7 @@ async function create({ name, root, templates, skipFiles, getTemplateName, mapES
|
|
|
3318
3023
|
const packageName = argv.packageName || formatted.packageName;
|
|
3319
3024
|
const distFolder = node_path.isAbsolute(targetDir) ? targetDir : node_path.join(cwd, targetDir);
|
|
3320
3025
|
if (!argv.override && node_fs.existsSync(distFolder) && !isEmptyDir(distFolder)) {
|
|
3321
|
-
const option = checkCancel(await
|
|
3026
|
+
const option = checkCancel(await xe({
|
|
3322
3027
|
message: `"${targetDir}" is not empty, please choose:`,
|
|
3323
3028
|
options: [
|
|
3324
3029
|
{
|
|
@@ -3352,7 +3057,7 @@ async function create({ name, root, templates, skipFiles, getTemplateName, mapES
|
|
|
3352
3057
|
return;
|
|
3353
3058
|
}
|
|
3354
3059
|
const tools = await getTools(argv, extraTools, templateName);
|
|
3355
|
-
const skills = await getSkills(argv, extraSkills, templateName, tools,
|
|
3060
|
+
const skills = await getSkills(argv, extraSkills, templateName, tools, ve);
|
|
3356
3061
|
const commonFolder = node_path.join(root, 'template-common');
|
|
3357
3062
|
if (!node_fs.existsSync(srcFolder)) throw new Error(`Invalid input: template "${templateName}" not found.`);
|
|
3358
3063
|
copyFolder({
|
|
@@ -3621,4 +3326,4 @@ function collectAgentsFiles(agentsMdSearchDirs) {
|
|
|
3621
3326
|
}
|
|
3622
3327
|
return agentsFiles;
|
|
3623
3328
|
}
|
|
3624
|
-
export {
|
|
3329
|
+
export { At as autocomplete, BUILTIN_TOOLS, Pe as text, checkCancel, collectAgentsFiles, copyFolder, create, isNpmTemplate, mergeAgentsFiles, mergePackageJson, pe as groupMultiselect, resolveCustomTemplate, resolveNpmTemplate, sanitizeCacheKey, ve as multiselect, xe as select };
|