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