vite-plus 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/binding/index.cjs +2 -0
- package/binding/index.d.cts +32 -0
- package/dist/global/{prompts-CAIahN1u.js → agent-CpNB3GIY.js} +475 -1350
- package/dist/global/{browser-CY4NBwxR.js → browser-CBapUTD0.js} +579 -1023
- package/dist/global/{browser-DFpJ6sKb.js → browser-EZnNDcaO.js} +2 -3
- package/dist/global/{chunk-CtfvYSle.js → chunk-CgnkrU7a.js} +13 -22
- package/dist/global/{cli-truncate-BxinOqz5.js → cli-truncate-Da6Y8aM8.js} +25 -74
- package/dist/global/config.js +86 -166
- package/dist/global/create.js +626 -615
- package/dist/global/{terminal-Cb-NuRkb.js → help-BAGHa8fD.js} +22 -54
- package/dist/global/{json-Bfvtp2rL.js → json-BRdVJ52a.js} +24 -58
- package/dist/global/{lib-CibYHP32.js → lib-DxappLRQ.js} +19 -43
- package/dist/global/{log-update-DdU6_LCN.js → log-update-C8WCYCbc.js} +102 -281
- package/dist/global/mcp.js +97 -169
- package/dist/global/migrate.js +330 -86
- package/dist/global/{package-Pq2biU7_.js → package-YAMvX5PJ.js} +6 -13
- package/dist/global/{slice-ansi-BhwAwMdF.js → slice-ansi-Fap0ehe9.js} +21 -52
- package/dist/global/{src-C6aLHRsS.js → src-DwSJ0s0I.js} +28 -110
- package/dist/global/staged.js +1353 -2112
- package/dist/global/{strip-ansi-BL-dgd7n.js → strip-ansi-CE-VDMdw.js} +20 -67
- package/dist/global/version.js +16 -37
- package/dist/global/{workspace-MTwAF3M9.js → workspace-CiqQdO1L.js} +1711 -2834
- package/dist/global/wrap-ansi-Ou9oAs-a.js +3 -0
- package/dist/global/{wrap-ansi-Iww6Ak1s.js → wrap-ansi-eywLlPVQ.js} +29 -80
- package/dist/index.d.ts +1 -1
- package/dist/init-config.js +10 -2
- package/dist/utils/agent.d.ts +15 -1
- package/dist/utils/agent.js +104 -20
- package/dist/utils/constants.d.ts +1 -0
- package/dist/utils/constants.js +2 -0
- package/dist/utils/editor.d.ts +16 -3
- package/dist/utils/editor.js +55 -17
- package/dist/utils/prompts.d.ts +33 -4
- package/dist/utils/prompts.js +34 -10
- package/dist/utils/tsconfig.d.ts +6 -0
- package/dist/utils/tsconfig.js +16 -0
- package/package.json +14 -14
- package/templates/monorepo/package.json +1 -1
- package/dist/global/wrap-ansi-BJxjUEQR.js +0 -4
- package/dist/oxlint-config.d.ts +0 -498
- package/dist/oxlint-config.js +0 -309
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { t as __commonJSMin } from "./chunk-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import path
|
|
1
|
+
import { t as __commonJSMin } from "./chunk-CgnkrU7a.js";
|
|
2
|
+
import { o as DEFAULT_ENVS, u as resolve$1 } from "./json-BRdVJ52a.js";
|
|
3
|
+
import { n as accent } from "./help-BAGHa8fD.js";
|
|
4
|
+
import path from "node:path";
|
|
5
5
|
import { stripVTControlCharacters } from "node:util";
|
|
6
|
-
import
|
|
6
|
+
import color from "picocolors";
|
|
7
7
|
import process$1, { stdin, stdout } from "node:process";
|
|
8
8
|
import * as k from "node:readline";
|
|
9
9
|
import ot from "node:readline";
|
|
10
10
|
import { ReadStream } from "node:tty";
|
|
11
|
-
import fs
|
|
11
|
+
import fs from "node:fs";
|
|
12
12
|
import { downloadPackageManager } from "../../binding/index.js";
|
|
13
13
|
import spawn from "cross-spawn";
|
|
14
14
|
import fsPromises from "node:fs/promises";
|
|
15
|
-
|
|
16
|
-
//#region ../../node_modules/.pnpm
|
|
17
|
-
var
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region ../../node_modules/.pnpm/@clack+core@1.0.1/node_modules/@clack/core/dist/index.mjs
|
|
17
|
+
var import_src = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
18
18
|
const ESC = "\x1B";
|
|
19
19
|
const CSI = `${ESC}[`;
|
|
20
20
|
const beep = "\x07";
|
|
@@ -43,45 +43,39 @@ var require_src = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
43
43
|
save: `${ESC}7`,
|
|
44
44
|
restore: `${ESC}8`
|
|
45
45
|
};
|
|
46
|
-
const scroll = {
|
|
47
|
-
up: (count = 1) => `${CSI}S`.repeat(count),
|
|
48
|
-
down: (count = 1) => `${CSI}T`.repeat(count)
|
|
49
|
-
};
|
|
50
|
-
const erase = {
|
|
51
|
-
screen: `${CSI}2J`,
|
|
52
|
-
up: (count = 1) => `${CSI}1J`.repeat(count),
|
|
53
|
-
down: (count = 1) => `${CSI}J`.repeat(count),
|
|
54
|
-
line: `${CSI}2K`,
|
|
55
|
-
lineEnd: `${CSI}K`,
|
|
56
|
-
lineStart: `${CSI}1K`,
|
|
57
|
-
lines(count) {
|
|
58
|
-
let clear = "";
|
|
59
|
-
for (let i = 0; i < count; i++) clear += this.line + (i < count - 1 ? cursor.up() : "");
|
|
60
|
-
if (count) clear += cursor.left;
|
|
61
|
-
return clear;
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
46
|
module.exports = {
|
|
65
47
|
cursor,
|
|
66
|
-
scroll
|
|
67
|
-
|
|
48
|
+
scroll: {
|
|
49
|
+
up: (count = 1) => `${CSI}S`.repeat(count),
|
|
50
|
+
down: (count = 1) => `${CSI}T`.repeat(count)
|
|
51
|
+
},
|
|
52
|
+
erase: {
|
|
53
|
+
screen: `${CSI}2J`,
|
|
54
|
+
up: (count = 1) => `${CSI}1J`.repeat(count),
|
|
55
|
+
down: (count = 1) => `${CSI}J`.repeat(count),
|
|
56
|
+
line: `${CSI}2K`,
|
|
57
|
+
lineEnd: `${CSI}K`,
|
|
58
|
+
lineStart: `${CSI}1K`,
|
|
59
|
+
lines(count) {
|
|
60
|
+
let clear = "";
|
|
61
|
+
for (let i = 0; i < count; i++) clear += this.line + (i < count - 1 ? cursor.up() : "");
|
|
62
|
+
if (count) clear += cursor.left;
|
|
63
|
+
return clear;
|
|
64
|
+
}
|
|
65
|
+
},
|
|
68
66
|
beep
|
|
69
67
|
};
|
|
70
|
-
}));
|
|
71
|
-
|
|
72
|
-
//#endregion
|
|
73
|
-
//#region ../../node_modules/.pnpm/@clack+core@1.0.1/node_modules/@clack/core/dist/index.mjs
|
|
74
|
-
var import_src = require_src();
|
|
68
|
+
})))();
|
|
75
69
|
function B(t, e, s) {
|
|
76
70
|
if (!s.some((u) => !u.disabled)) return t;
|
|
77
71
|
const i = t + e, r = Math.max(s.length - 1, 0), n = i < 0 ? r : i > r ? 0 : i;
|
|
78
72
|
return s[n].disabled ? B(n, e < 0 ? -1 : 1, s) : n;
|
|
79
73
|
}
|
|
80
74
|
const at = (t) => t === 161 || t === 164 || t === 167 || t === 168 || t === 170 || t === 173 || t === 174 || t >= 176 && t <= 180 || t >= 182 && t <= 186 || t >= 188 && t <= 191 || t === 198 || t === 208 || t === 215 || t === 216 || t >= 222 && t <= 225 || t === 230 || t >= 232 && t <= 234 || t === 236 || t === 237 || t === 240 || t === 242 || t === 243 || t >= 247 && t <= 250 || t === 252 || t === 254 || t === 257 || t === 273 || t === 275 || t === 283 || t === 294 || t === 295 || t === 299 || t >= 305 && t <= 307 || t === 312 || t >= 319 && t <= 322 || t === 324 || t >= 328 && t <= 331 || t === 333 || t === 338 || t === 339 || t === 358 || t === 359 || t === 363 || t === 462 || t === 464 || t === 466 || t === 468 || t === 470 || t === 472 || t === 474 || t === 476 || t === 593 || t === 609 || t === 708 || t === 711 || t >= 713 && t <= 715 || t === 717 || t === 720 || t >= 728 && t <= 731 || t === 733 || t === 735 || t >= 768 && t <= 879 || t >= 913 && t <= 929 || t >= 931 && t <= 937 || t >= 945 && t <= 961 || t >= 963 && t <= 969 || t === 1025 || t >= 1040 && t <= 1103 || t === 1105 || t === 8208 || t >= 8211 && t <= 8214 || t === 8216 || t === 8217 || t === 8220 || t === 8221 || t >= 8224 && t <= 8226 || t >= 8228 && t <= 8231 || t === 8240 || t === 8242 || t === 8243 || t === 8245 || t === 8251 || t === 8254 || t === 8308 || t === 8319 || t >= 8321 && t <= 8324 || t === 8364 || t === 8451 || t === 8453 || t === 8457 || t === 8467 || t === 8470 || t === 8481 || t === 8482 || t === 8486 || t === 8491 || t === 8531 || t === 8532 || t >= 8539 && t <= 8542 || t >= 8544 && t <= 8555 || t >= 8560 && t <= 8569 || t === 8585 || t >= 8592 && t <= 8601 || t === 8632 || t === 8633 || t === 8658 || t === 8660 || t === 8679 || t === 8704 || t === 8706 || t === 8707 || t === 8711 || t === 8712 || t === 8715 || t === 8719 || t === 8721 || t === 8725 || t === 8730 || t >= 8733 && t <= 8736 || t === 8739 || t === 8741 || t >= 8743 && t <= 8748 || t === 8750 || t >= 8756 && t <= 8759 || t === 8764 || t === 8765 || t === 8776 || t === 8780 || t === 8786 || t === 8800 || t === 8801 || t >= 8804 && t <= 8807 || t === 8810 || t === 8811 || t === 8814 || t === 8815 || t === 8834 || t === 8835 || t === 8838 || t === 8839 || t === 8853 || t === 8857 || t === 8869 || t === 8895 || t === 8978 || t >= 9312 && t <= 9449 || t >= 9451 && t <= 9547 || t >= 9552 && t <= 9587 || t >= 9600 && t <= 9615 || t >= 9618 && t <= 9621 || t === 9632 || t === 9633 || t >= 9635 && t <= 9641 || t === 9650 || t === 9651 || t === 9654 || t === 9655 || t === 9660 || t === 9661 || t === 9664 || t === 9665 || t >= 9670 && t <= 9672 || t === 9675 || t >= 9678 && t <= 9681 || t >= 9698 && t <= 9701 || t === 9711 || t === 9733 || t === 9734 || t === 9737 || t === 9742 || t === 9743 || t === 9756 || t === 9758 || t === 9792 || t === 9794 || t === 9824 || t === 9825 || t >= 9827 && t <= 9829 || t >= 9831 && t <= 9834 || t === 9836 || t === 9837 || t === 9839 || t === 9886 || t === 9887 || t === 9919 || t >= 9926 && t <= 9933 || t >= 9935 && t <= 9939 || t >= 9941 && t <= 9953 || t === 9955 || t === 9960 || t === 9961 || t >= 9963 && t <= 9969 || t === 9972 || t >= 9974 && t <= 9977 || t === 9979 || t === 9980 || t === 9982 || t === 9983 || t === 10045 || t >= 10102 && t <= 10111 || t >= 11094 && t <= 11097 || t >= 12872 && t <= 12879 || t >= 57344 && t <= 63743 || t >= 65024 && t <= 65039 || t === 65533 || t >= 127232 && t <= 127242 || t >= 127248 && t <= 127277 || t >= 127280 && t <= 127337 || t >= 127344 && t <= 127373 || t === 127375 || t === 127376 || t >= 127387 && t <= 127404 || t >= 917760 && t <= 917999 || t >= 983040 && t <= 1048573 || t >= 1048576 && t <= 1114109, lt = (t) => t === 12288 || t >= 65281 && t <= 65376 || t >= 65504 && t <= 65510, ht = (t) => t >= 4352 && t <= 4447 || t === 8986 || t === 8987 || t === 9001 || t === 9002 || t >= 9193 && t <= 9196 || t === 9200 || t === 9203 || t === 9725 || t === 9726 || t === 9748 || t === 9749 || t >= 9800 && t <= 9811 || t === 9855 || t === 9875 || t === 9889 || t === 9898 || t === 9899 || t === 9917 || t === 9918 || t === 9924 || t === 9925 || t === 9934 || t === 9940 || t === 9962 || t === 9970 || t === 9971 || t === 9973 || t === 9978 || t === 9981 || t === 9989 || t === 9994 || t === 9995 || t === 10024 || t === 10060 || t === 10062 || t >= 10067 && t <= 10069 || t === 10071 || t >= 10133 && t <= 10135 || t === 10160 || t === 10175 || t === 11035 || t === 11036 || t === 11088 || t === 11093 || t >= 11904 && t <= 11929 || t >= 11931 && t <= 12019 || t >= 12032 && t <= 12245 || t >= 12272 && t <= 12287 || t >= 12289 && t <= 12350 || t >= 12353 && t <= 12438 || t >= 12441 && t <= 12543 || t >= 12549 && t <= 12591 || t >= 12593 && t <= 12686 || t >= 12688 && t <= 12771 || t >= 12783 && t <= 12830 || t >= 12832 && t <= 12871 || t >= 12880 && t <= 19903 || t >= 19968 && t <= 42124 || t >= 42128 && t <= 42182 || t >= 43360 && t <= 43388 || t >= 44032 && t <= 55203 || t >= 63744 && t <= 64255 || t >= 65040 && t <= 65049 || t >= 65072 && t <= 65106 || t >= 65108 && t <= 65126 || t >= 65128 && t <= 65131 || t >= 94176 && t <= 94180 || t === 94192 || t === 94193 || t >= 94208 && t <= 100343 || t >= 100352 && t <= 101589 || t >= 101632 && t <= 101640 || t >= 110576 && t <= 110579 || t >= 110581 && t <= 110587 || t === 110589 || t === 110590 || t >= 110592 && t <= 110882 || t === 110898 || t >= 110928 && t <= 110930 || t === 110933 || t >= 110948 && t <= 110951 || t >= 110960 && t <= 111355 || t === 126980 || t === 127183 || t === 127374 || t >= 127377 && t <= 127386 || t >= 127488 && t <= 127490 || t >= 127504 && t <= 127547 || t >= 127552 && t <= 127560 || t === 127568 || t === 127569 || t >= 127584 && t <= 127589 || t >= 127744 && t <= 127776 || t >= 127789 && t <= 127797 || t >= 127799 && t <= 127868 || t >= 127870 && t <= 127891 || t >= 127904 && t <= 127946 || t >= 127951 && t <= 127955 || t >= 127968 && t <= 127984 || t === 127988 || t >= 127992 && t <= 128062 || t === 128064 || t >= 128066 && t <= 128252 || t >= 128255 && t <= 128317 || t >= 128331 && t <= 128334 || t >= 128336 && t <= 128359 || t === 128378 || t === 128405 || t === 128406 || t === 128420 || t >= 128507 && t <= 128591 || t >= 128640 && t <= 128709 || t === 128716 || t >= 128720 && t <= 128722 || t >= 128725 && t <= 128727 || t >= 128732 && t <= 128735 || t === 128747 || t === 128748 || t >= 128756 && t <= 128764 || t >= 128992 && t <= 129003 || t === 129008 || t >= 129292 && t <= 129338 || t >= 129340 && t <= 129349 || t >= 129351 && t <= 129535 || t >= 129648 && t <= 129660 || t >= 129664 && t <= 129672 || t >= 129680 && t <= 129725 || t >= 129727 && t <= 129733 || t >= 129742 && t <= 129755 || t >= 129760 && t <= 129768 || t >= 129776 && t <= 129784 || t >= 131072 && t <= 196605 || t >= 196608 && t <= 262141, O = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y, y = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y, L = /\t{1,1000}/y, P = /[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/uy, M = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y, ct = /\p{M}+/gu, ft = {
|
|
81
|
-
limit:
|
|
75
|
+
limit: Infinity,
|
|
82
76
|
ellipsis: ""
|
|
83
77
|
}, X = (t, e = {}, s = {}) => {
|
|
84
|
-
const i = e.limit ??
|
|
78
|
+
const i = e.limit ?? Infinity, r = e.ellipsis ?? "", n = e?.ellipsisWidth ?? (r ? X(r, ft, s).width : 0), u = s.ansiWidth ?? 0, a = s.controlWidth ?? 0, l = s.tabWidth ?? 8, E = s.ambiguousWidth ?? 1, g = s.emojiWidth ?? 2, m = s.fullWidthWidth ?? 2, A = s.regularWidth ?? 1, V = s.wideWidth ?? 2;
|
|
85
79
|
let h = 0, o = 0, p = t.length, v = 0, F = !1, d = p, b = Math.max(0, i - n), C = 0, w = 0, c = 0, f = 0;
|
|
86
80
|
t: for (;;) {
|
|
87
81
|
if (w > C || o >= p && o > h) {
|
|
@@ -147,7 +141,7 @@ const at = (t) => t === 161 || t === 164 || t === 167 || t === 168 || t === 170
|
|
|
147
141
|
ellipsed: F && i >= n
|
|
148
142
|
};
|
|
149
143
|
}, pt = {
|
|
150
|
-
limit:
|
|
144
|
+
limit: Infinity,
|
|
151
145
|
ellipsis: "",
|
|
152
146
|
ellipsisWidth: 0
|
|
153
147
|
}, S = (t, e = {}) => X(t, pt, e).width, W = "\x1B", Z = "", Ft = 39, j = "\x07", Q = "[", dt = "]", tt = "m", U = `${dt}8;;`, et = new RegExp(`(?:\\${Q}(?<code>\\d+)m|\\${U}(?<uri>.*)${j})`, "y"), mt = (t) => {
|
|
@@ -227,16 +221,16 @@ function K(t, e, s) {
|
|
|
227
221
|
`).map((i) => Et(i, e, s)).join(`
|
|
228
222
|
`);
|
|
229
223
|
}
|
|
230
|
-
const
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
224
|
+
const _ = {
|
|
225
|
+
actions: new Set([
|
|
226
|
+
"up",
|
|
227
|
+
"down",
|
|
228
|
+
"left",
|
|
229
|
+
"right",
|
|
230
|
+
"space",
|
|
231
|
+
"enter",
|
|
232
|
+
"cancel"
|
|
233
|
+
]),
|
|
240
234
|
aliases: new Map([
|
|
241
235
|
["k", "up"],
|
|
242
236
|
["j", "down"],
|
|
@@ -251,21 +245,6 @@ const At = [
|
|
|
251
245
|
},
|
|
252
246
|
withGuide: !0
|
|
253
247
|
};
|
|
254
|
-
function It(t) {
|
|
255
|
-
if (t.aliases !== void 0) {
|
|
256
|
-
const e = t.aliases;
|
|
257
|
-
for (const s in e) {
|
|
258
|
-
if (!Object.hasOwn(e, s)) continue;
|
|
259
|
-
const i = e[s];
|
|
260
|
-
_.actions.has(i) && (_.aliases.has(s) || _.aliases.set(s, i));
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
if (t.messages !== void 0) {
|
|
264
|
-
const e = t.messages;
|
|
265
|
-
e.cancel !== void 0 && (_.messages.cancel = e.cancel), e.error !== void 0 && (_.messages.error = e.error);
|
|
266
|
-
}
|
|
267
|
-
t.withGuide !== void 0 && (_.withGuide = t.withGuide !== !1);
|
|
268
|
-
}
|
|
269
248
|
function H(t, e) {
|
|
270
249
|
if (typeof t == "string") return _.aliases.get(t) === e;
|
|
271
250
|
for (const s of t) if (s !== void 0 && H(s, e)) return !0;
|
|
@@ -301,9 +280,8 @@ function Bt({ input: t = stdin, output: e = stdout, overwrite: s = !0, hideCurso
|
|
|
301
280
|
});
|
|
302
281
|
k.emitKeypressEvents(t, r), t instanceof ReadStream && t.isTTY && t.setRawMode(!0);
|
|
303
282
|
const n = (u, { name: a, sequence: l }) => {
|
|
304
|
-
const E = String(u);
|
|
305
283
|
if (H([
|
|
306
|
-
|
|
284
|
+
String(u),
|
|
307
285
|
a,
|
|
308
286
|
l
|
|
309
287
|
], "cancel")) {
|
|
@@ -324,8 +302,7 @@ function Bt({ input: t = stdin, output: e = stdout, overwrite: s = !0, hideCurso
|
|
|
324
302
|
}
|
|
325
303
|
const rt = (t) => "columns" in t && typeof t.columns == "number" ? t.columns : 80, nt = (t) => "rows" in t && typeof t.rows == "number" ? t.rows : 20;
|
|
326
304
|
function xt(t, e, s, i = s) {
|
|
327
|
-
|
|
328
|
-
return K(e, r - s.length, {
|
|
305
|
+
return K(e, rt(t ?? stdout) - s.length, {
|
|
329
306
|
hard: !0,
|
|
330
307
|
trim: !1
|
|
331
308
|
}).split(`
|
|
@@ -341,7 +318,7 @@ var x = class {
|
|
|
341
318
|
_render;
|
|
342
319
|
_track = !1;
|
|
343
320
|
_prevFrame = "";
|
|
344
|
-
_subscribers = new Map();
|
|
321
|
+
_subscribers = /* @__PURE__ */ new Map();
|
|
345
322
|
_cursor = 0;
|
|
346
323
|
state = "initial";
|
|
347
324
|
error = "";
|
|
@@ -479,75 +456,6 @@ var x = class {
|
|
|
479
456
|
}
|
|
480
457
|
}
|
|
481
458
|
};
|
|
482
|
-
function wt(t, e) {
|
|
483
|
-
if (t === void 0 || e.length === 0) return 0;
|
|
484
|
-
const s = e.findIndex((i) => i.value === t);
|
|
485
|
-
return s !== -1 ? s : 0;
|
|
486
|
-
}
|
|
487
|
-
function Dt(t, e) {
|
|
488
|
-
return (e.label ?? String(e.value)).toLowerCase().includes(t.toLowerCase());
|
|
489
|
-
}
|
|
490
|
-
function St(t, e) {
|
|
491
|
-
if (e) return t ? e : e[0];
|
|
492
|
-
}
|
|
493
|
-
var Vt = class extends x {
|
|
494
|
-
filteredOptions;
|
|
495
|
-
multiple;
|
|
496
|
-
isNavigating = !1;
|
|
497
|
-
selectedValues = [];
|
|
498
|
-
focusedValue;
|
|
499
|
-
#t = 0;
|
|
500
|
-
#s = "";
|
|
501
|
-
#i;
|
|
502
|
-
#e;
|
|
503
|
-
get cursor() {
|
|
504
|
-
return this.#t;
|
|
505
|
-
}
|
|
506
|
-
get userInputWithCursor() {
|
|
507
|
-
if (!this.userInput) return colors.inverse(colors.hidden("_"));
|
|
508
|
-
if (this._cursor >= this.userInput.length) return `${this.userInput}\u2588`;
|
|
509
|
-
const e = this.userInput.slice(0, this._cursor), [s, ...i] = this.userInput.slice(this._cursor);
|
|
510
|
-
return `${e}${colors.inverse(s)}${i.join("")}`;
|
|
511
|
-
}
|
|
512
|
-
get options() {
|
|
513
|
-
return typeof this.#e == "function" ? this.#e() : this.#e;
|
|
514
|
-
}
|
|
515
|
-
constructor(e) {
|
|
516
|
-
super(e), this.#e = e.options;
|
|
517
|
-
const s = this.options;
|
|
518
|
-
this.filteredOptions = [...s], this.multiple = e.multiple === !0, this.#i = e.filter ?? Dt;
|
|
519
|
-
let i;
|
|
520
|
-
if (e.initialValue && Array.isArray(e.initialValue) ? this.multiple ? i = e.initialValue : i = e.initialValue.slice(0, 1) : !this.multiple && this.options.length > 0 && (i = [this.options[0].value]), i) for (const r of i) {
|
|
521
|
-
const n = s.findIndex((u) => u.value === r);
|
|
522
|
-
n !== -1 && (this.toggleSelected(r), this.#t = n);
|
|
523
|
-
}
|
|
524
|
-
this.focusedValue = this.options[this.#t]?.value, this.on("key", (r, n) => this.#r(r, n)), this.on("userInput", (r) => this.#n(r));
|
|
525
|
-
}
|
|
526
|
-
_isActionKey(e, s) {
|
|
527
|
-
return e === " " || this.multiple && this.isNavigating && s.name === "space" && e !== void 0 && e !== "";
|
|
528
|
-
}
|
|
529
|
-
#r(e, s) {
|
|
530
|
-
const i = s.name === "up", r = s.name === "down", n = s.name === "return";
|
|
531
|
-
i || r ? (this.#t = B(this.#t, i ? -1 : 1, this.filteredOptions), this.focusedValue = this.filteredOptions[this.#t]?.value, this.multiple || (this.selectedValues = [this.focusedValue]), this.isNavigating = !0) : n ? this.value = St(this.multiple, this.selectedValues) : this.multiple ? this.focusedValue !== void 0 && (s.name === "tab" || this.isNavigating && s.name === "space") ? this.toggleSelected(this.focusedValue) : this.isNavigating = !1 : (this.focusedValue && (this.selectedValues = [this.focusedValue]), this.isNavigating = !1);
|
|
532
|
-
}
|
|
533
|
-
deselectAll() {
|
|
534
|
-
this.selectedValues = [];
|
|
535
|
-
}
|
|
536
|
-
toggleSelected(e) {
|
|
537
|
-
this.filteredOptions.length !== 0 && (this.multiple ? this.selectedValues.includes(e) ? this.selectedValues = this.selectedValues.filter((s) => s !== e) : this.selectedValues = [...this.selectedValues, e] : this.selectedValues = [e]);
|
|
538
|
-
}
|
|
539
|
-
#n(e) {
|
|
540
|
-
if (e !== this.#s) {
|
|
541
|
-
this.#s = e;
|
|
542
|
-
const s = this.options;
|
|
543
|
-
e ? this.filteredOptions = s.filter((n) => this.#i(e, n)) : this.filteredOptions = [...s];
|
|
544
|
-
const i = wt(this.focusedValue, this.filteredOptions);
|
|
545
|
-
this.#t = B(i, 0, this.filteredOptions);
|
|
546
|
-
const r = this.filteredOptions[this.#t];
|
|
547
|
-
r && !r.disabled ? this.focusedValue = r.value : this.focusedValue = void 0, this.multiple || (this.focusedValue !== void 0 ? this.toggleSelected(this.focusedValue) : this.deselectAll());
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
};
|
|
551
459
|
var kt = class extends x {
|
|
552
460
|
get cursor() {
|
|
553
461
|
return this.value ? 0 : 1;
|
|
@@ -565,60 +473,6 @@ var kt = class extends x {
|
|
|
565
473
|
});
|
|
566
474
|
}
|
|
567
475
|
};
|
|
568
|
-
var yt = class extends x {
|
|
569
|
-
options;
|
|
570
|
-
cursor = 0;
|
|
571
|
-
#t;
|
|
572
|
-
getGroupItems(e) {
|
|
573
|
-
return this.options.filter((s) => s.group === e);
|
|
574
|
-
}
|
|
575
|
-
isGroupSelected(e) {
|
|
576
|
-
const s = this.getGroupItems(e), i = this.value;
|
|
577
|
-
return i === void 0 ? !1 : s.every((r) => i.includes(r.value));
|
|
578
|
-
}
|
|
579
|
-
toggleValue() {
|
|
580
|
-
const e = this.options[this.cursor];
|
|
581
|
-
if (this.value === void 0 && (this.value = []), e.group === !0) {
|
|
582
|
-
const s = e.value, i = this.getGroupItems(s);
|
|
583
|
-
this.isGroupSelected(s) ? this.value = this.value.filter((r) => i.findIndex((n) => n.value === r) === -1) : this.value = [...this.value, ...i.map((r) => r.value)], this.value = Array.from(new Set(this.value));
|
|
584
|
-
} else {
|
|
585
|
-
const s = this.value.includes(e.value);
|
|
586
|
-
this.value = s ? this.value.filter((i) => i !== e.value) : [...this.value, e.value];
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
constructor(e) {
|
|
590
|
-
super(e, !1);
|
|
591
|
-
const { options: s } = e;
|
|
592
|
-
this.#t = e.selectableGroups !== !1, this.options = Object.entries(s).flatMap(([i, r]) => [{
|
|
593
|
-
value: i,
|
|
594
|
-
group: !0,
|
|
595
|
-
label: i
|
|
596
|
-
}, ...r.map((n) => ({
|
|
597
|
-
...n,
|
|
598
|
-
group: i
|
|
599
|
-
}))]), this.value = [...e.initialValues ?? []], this.cursor = Math.max(this.options.findIndex(({ value: i }) => i === e.cursorAt), this.#t ? 0 : 1), this.on("cursor", (i) => {
|
|
600
|
-
switch (i) {
|
|
601
|
-
case "left":
|
|
602
|
-
case "up": {
|
|
603
|
-
this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
|
|
604
|
-
const r = this.options[this.cursor]?.group === !0;
|
|
605
|
-
!this.#t && r && (this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1);
|
|
606
|
-
break;
|
|
607
|
-
}
|
|
608
|
-
case "down":
|
|
609
|
-
case "right": {
|
|
610
|
-
this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
|
|
611
|
-
const r = this.options[this.cursor]?.group === !0;
|
|
612
|
-
!this.#t && r && (this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1);
|
|
613
|
-
break;
|
|
614
|
-
}
|
|
615
|
-
case "space":
|
|
616
|
-
this.toggleValue();
|
|
617
|
-
break;
|
|
618
|
-
}
|
|
619
|
-
});
|
|
620
|
-
}
|
|
621
|
-
};
|
|
622
476
|
var Lt = class extends x {
|
|
623
477
|
options;
|
|
624
478
|
cursor = 0;
|
|
@@ -629,19 +483,17 @@ var Lt = class extends x {
|
|
|
629
483
|
return this.options.filter((e) => e.disabled !== !0);
|
|
630
484
|
}
|
|
631
485
|
toggleAll() {
|
|
632
|
-
const e = this._enabledOptions
|
|
633
|
-
this.value =
|
|
486
|
+
const e = this._enabledOptions;
|
|
487
|
+
this.value = this.value !== void 0 && this.value.length === e.length ? [] : e.map((i) => i.value);
|
|
634
488
|
}
|
|
635
489
|
toggleInvert() {
|
|
636
490
|
const e = this.value;
|
|
637
491
|
if (!e) return;
|
|
638
|
-
|
|
639
|
-
this.value = s.map((i) => i.value);
|
|
492
|
+
this.value = this._enabledOptions.filter((i) => !e.includes(i.value)).map((i) => i.value);
|
|
640
493
|
}
|
|
641
494
|
toggleValue() {
|
|
642
495
|
this.value === void 0 && (this.value = []);
|
|
643
|
-
|
|
644
|
-
this.value = e ? this.value.filter((s) => s !== this._value) : [...this.value, this._value];
|
|
496
|
+
this.value = this.value.includes(this._value) ? this.value.filter((s) => s !== this._value) : [...this.value, this._value];
|
|
645
497
|
}
|
|
646
498
|
constructor(e) {
|
|
647
499
|
super(e, !1), this.options = e.options, this.value = [...e.initialValues ?? []];
|
|
@@ -665,30 +517,6 @@ var Lt = class extends x {
|
|
|
665
517
|
});
|
|
666
518
|
}
|
|
667
519
|
};
|
|
668
|
-
let Mt = class extends x {
|
|
669
|
-
_mask = "•";
|
|
670
|
-
get cursor() {
|
|
671
|
-
return this._cursor;
|
|
672
|
-
}
|
|
673
|
-
get masked() {
|
|
674
|
-
return this.userInput.replaceAll(/./g, this._mask);
|
|
675
|
-
}
|
|
676
|
-
get userInputWithCursor() {
|
|
677
|
-
if (this.state === "submit" || this.state === "cancel") return this.masked;
|
|
678
|
-
const e = this.userInput;
|
|
679
|
-
if (this.cursor >= e.length) return `${this.masked}${colors.inverse(colors.hidden("_"))}`;
|
|
680
|
-
const s = this.masked, i = s.slice(0, this.cursor), r = s.slice(this.cursor);
|
|
681
|
-
return `${i}${colors.inverse(r[0])}${r.slice(1)}`;
|
|
682
|
-
}
|
|
683
|
-
clear() {
|
|
684
|
-
this._clearUserInput();
|
|
685
|
-
}
|
|
686
|
-
constructor({ mask: e, ...s }) {
|
|
687
|
-
super(s), this._mask = e ?? "•", this.on("userInput", (i) => {
|
|
688
|
-
this._setValue(i);
|
|
689
|
-
});
|
|
690
|
-
}
|
|
691
|
-
};
|
|
692
520
|
var Wt = class extends x {
|
|
693
521
|
options;
|
|
694
522
|
cursor = 0;
|
|
@@ -716,28 +544,13 @@ var Wt = class extends x {
|
|
|
716
544
|
});
|
|
717
545
|
}
|
|
718
546
|
};
|
|
719
|
-
var Tt = class extends x {
|
|
720
|
-
options;
|
|
721
|
-
cursor = 0;
|
|
722
|
-
constructor(e) {
|
|
723
|
-
super(e, !1), this.options = e.options;
|
|
724
|
-
const s = e.caseSensitive === !0, i = this.options.map(({ value: [r] }) => s ? r : r?.toLowerCase());
|
|
725
|
-
this.cursor = Math.max(i.indexOf(e.initialValue), 0), this.on("key", (r, n) => {
|
|
726
|
-
if (!r) return;
|
|
727
|
-
const u = s && n.shift ? r.toUpperCase() : r;
|
|
728
|
-
if (!i.includes(u)) return;
|
|
729
|
-
const a = this.options.find(({ value: [l] }) => s ? l === u : l?.toLowerCase() === r);
|
|
730
|
-
a && (this.value = a.value, this.state = "submit", this.emit("submit"));
|
|
731
|
-
});
|
|
732
|
-
}
|
|
733
|
-
};
|
|
734
547
|
var $t = class extends x {
|
|
735
548
|
get userInputWithCursor() {
|
|
736
549
|
if (this.state === "submit") return this.userInput;
|
|
737
550
|
const e = this.userInput;
|
|
738
551
|
if (this.cursor >= e.length) return `${this.userInput}\u2588`;
|
|
739
552
|
const s = e.slice(0, this.cursor), [i, ...r] = e.slice(this.cursor);
|
|
740
|
-
return `${s}${
|
|
553
|
+
return `${s}${color.inverse(i)}${r.join("")}`;
|
|
741
554
|
}
|
|
742
555
|
get cursor() {
|
|
743
556
|
return this._cursor;
|
|
@@ -753,7 +566,6 @@ var $t = class extends x {
|
|
|
753
566
|
});
|
|
754
567
|
}
|
|
755
568
|
};
|
|
756
|
-
|
|
757
569
|
//#endregion
|
|
758
570
|
//#region ../prompts/dist/index.mjs
|
|
759
571
|
function isUnicodeSupported() {
|
|
@@ -762,53 +574,47 @@ function isUnicodeSupported() {
|
|
|
762
574
|
}
|
|
763
575
|
const unicode = isUnicodeSupported();
|
|
764
576
|
const isCI = () => process.env.CI === "true";
|
|
765
|
-
const isTTY = (output) => {
|
|
766
|
-
return output.isTTY === true;
|
|
767
|
-
};
|
|
768
577
|
const unicodeOr = (c, fallback) => unicode ? c : fallback;
|
|
769
578
|
const S_POINTER_ACTIVE = unicodeOr("›", ">");
|
|
770
|
-
const S_POINTER_INACTIVE = " ";
|
|
771
579
|
const S_STEP_ACTIVE = S_POINTER_ACTIVE;
|
|
772
580
|
const S_STEP_CANCEL = unicodeOr("■", "x");
|
|
773
581
|
const S_STEP_ERROR = unicodeOr("▲", "x");
|
|
774
582
|
const S_STEP_SUBMIT = unicodeOr("◇", "o");
|
|
775
|
-
|
|
583
|
+
unicodeOr("┌", "T");
|
|
776
584
|
const S_BAR = unicodeOr("│", "|");
|
|
777
585
|
const S_BAR_END = unicodeOr("└", "—");
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
const S_RADIO_ACTIVE = S_POINTER_ACTIVE;
|
|
781
|
-
const S_RADIO_INACTIVE = S_POINTER_INACTIVE;
|
|
586
|
+
unicodeOr("┐", "T");
|
|
587
|
+
unicodeOr("┘", "—");
|
|
782
588
|
const S_CHECKBOX_ACTIVE = unicodeOr("◻", "[•]");
|
|
783
589
|
const S_CHECKBOX_SELECTED = unicodeOr("◼", "[+]");
|
|
784
590
|
const S_CHECKBOX_INACTIVE = unicodeOr("◻", "[ ]");
|
|
785
|
-
|
|
591
|
+
unicodeOr("▪", "•");
|
|
786
592
|
const S_BAR_H = unicodeOr("─", "-");
|
|
787
593
|
const S_CORNER_TOP_RIGHT = unicodeOr("╮", "+");
|
|
788
594
|
const S_CONNECT_LEFT = unicodeOr("├", "+");
|
|
789
595
|
const S_CORNER_BOTTOM_RIGHT = unicodeOr("╯", "+");
|
|
790
596
|
const S_CORNER_BOTTOM_LEFT = unicodeOr("╰", "+");
|
|
791
|
-
|
|
597
|
+
unicodeOr("╭", "+");
|
|
792
598
|
const S_INFO = unicodeOr("●", "•");
|
|
793
599
|
const S_SUCCESS = unicodeOr("◆", "*");
|
|
794
600
|
const S_WARN = unicodeOr("▲", "!");
|
|
795
601
|
const S_ERROR = unicodeOr("■", "x");
|
|
796
|
-
const completeColor = (value) =>
|
|
602
|
+
const completeColor = (value) => color.gray(value);
|
|
797
603
|
const symbol = (state) => {
|
|
798
604
|
switch (state) {
|
|
799
605
|
case "initial":
|
|
800
|
-
case "active": return
|
|
801
|
-
case "cancel": return
|
|
802
|
-
case "error": return
|
|
606
|
+
case "active": return color.blue(S_STEP_ACTIVE);
|
|
607
|
+
case "cancel": return color.red(S_STEP_CANCEL);
|
|
608
|
+
case "error": return color.yellow(S_STEP_ERROR);
|
|
803
609
|
case "submit": return completeColor(S_STEP_SUBMIT);
|
|
804
610
|
}
|
|
805
611
|
};
|
|
806
612
|
const symbolBar = (state) => {
|
|
807
613
|
switch (state) {
|
|
808
614
|
case "initial":
|
|
809
|
-
case "active": return
|
|
810
|
-
case "cancel": return
|
|
811
|
-
case "error": return
|
|
615
|
+
case "active": return color.blue(S_BAR);
|
|
616
|
+
case "cancel": return color.red(S_BAR);
|
|
617
|
+
case "error": return color.yellow(S_BAR);
|
|
812
618
|
case "submit": return completeColor(S_BAR);
|
|
813
619
|
}
|
|
814
620
|
};
|
|
@@ -1146,7 +952,7 @@ const limitOptions = (params) => {
|
|
|
1146
952
|
const rowPadding = params.rowPadding ?? 4;
|
|
1147
953
|
const maxWidth = columns - columnPadding;
|
|
1148
954
|
const rows = nt(output);
|
|
1149
|
-
const overflowFormat =
|
|
955
|
+
const overflowFormat = color.dim("...");
|
|
1150
956
|
const paramMaxItems = params.maxItems ?? Number.POSITIVE_INFINITY;
|
|
1151
957
|
const outputMaxItems = Math.max(rows - rowPadding, 0);
|
|
1152
958
|
const maxItems = Math.max(Math.min(paramMaxItems, outputMaxItems), 5);
|
|
@@ -1197,256 +1003,6 @@ const limitOptions = (params) => {
|
|
|
1197
1003
|
if (shouldRenderBottomEllipsis) result.push(overflowFormat);
|
|
1198
1004
|
return result;
|
|
1199
1005
|
};
|
|
1200
|
-
function getLabel(option) {
|
|
1201
|
-
return option.label ?? String(option.value ?? "");
|
|
1202
|
-
}
|
|
1203
|
-
function getFilteredOption(searchText, option) {
|
|
1204
|
-
if (!searchText) return true;
|
|
1205
|
-
const label = (option.label ?? String(option.value ?? "")).toLowerCase();
|
|
1206
|
-
const hint = (option.hint ?? "").toLowerCase();
|
|
1207
|
-
const value = String(option.value).toLowerCase();
|
|
1208
|
-
const term = searchText.toLowerCase();
|
|
1209
|
-
return label.includes(term) || hint.includes(term) || value.includes(term);
|
|
1210
|
-
}
|
|
1211
|
-
function getSelectedOptions(values, options) {
|
|
1212
|
-
const results = [];
|
|
1213
|
-
for (const option of options) if (values.includes(option.value)) results.push(option);
|
|
1214
|
-
return results;
|
|
1215
|
-
}
|
|
1216
|
-
const withMarker$1 = (marker, label, format, firstLineSuffix = "") => {
|
|
1217
|
-
const lines = label.split("\n");
|
|
1218
|
-
if (lines.length === 1) return `${marker} ${format(lines[0])}${firstLineSuffix}`;
|
|
1219
|
-
const [firstLine, ...rest] = lines;
|
|
1220
|
-
return [`${marker} ${format(firstLine)}${firstLineSuffix}`, ...rest.map((line) => `${S_POINTER_INACTIVE} ${format(line)}`)].join("\n");
|
|
1221
|
-
};
|
|
1222
|
-
const withMarkerAndIndicator = (marker, indicator, indicatorWidth, label, format, firstLineSuffix = "") => {
|
|
1223
|
-
const lines = label.split("\n");
|
|
1224
|
-
const continuationPrefix = `${S_POINTER_INACTIVE} ${" ".repeat(indicatorWidth)} `;
|
|
1225
|
-
if (lines.length === 1) return `${marker} ${indicator} ${format(lines[0])}${firstLineSuffix}`;
|
|
1226
|
-
const [firstLine, ...rest] = lines;
|
|
1227
|
-
return [`${marker} ${indicator} ${format(firstLine)}${firstLineSuffix}`, ...rest.map((line) => `${continuationPrefix}${format(line)}`)].join("\n");
|
|
1228
|
-
};
|
|
1229
|
-
const autocomplete = (opts) => {
|
|
1230
|
-
return new Vt({
|
|
1231
|
-
options: opts.options,
|
|
1232
|
-
initialValue: opts.initialValue ? [opts.initialValue] : void 0,
|
|
1233
|
-
initialUserInput: opts.initialUserInput,
|
|
1234
|
-
filter: opts.filter ?? ((search, opt) => {
|
|
1235
|
-
return getFilteredOption(search, opt);
|
|
1236
|
-
}),
|
|
1237
|
-
signal: opts.signal,
|
|
1238
|
-
input: opts.input,
|
|
1239
|
-
output: opts.output,
|
|
1240
|
-
validate: opts.validate,
|
|
1241
|
-
render() {
|
|
1242
|
-
const hasGuide = opts.withGuide ?? false;
|
|
1243
|
-
const nestedPrefix = " ";
|
|
1244
|
-
const headings = hasGuide ? [colors.gray(S_BAR), `${symbol(this.state)} ${opts.message}`] : [`${symbol(this.state)} ${opts.message}`];
|
|
1245
|
-
const userInput = this.userInput;
|
|
1246
|
-
const options = this.options;
|
|
1247
|
-
const placeholder = opts.placeholder;
|
|
1248
|
-
const showPlaceholder = userInput === "" && placeholder !== void 0;
|
|
1249
|
-
switch (this.state) {
|
|
1250
|
-
case "submit": {
|
|
1251
|
-
const selected = getSelectedOptions(this.selectedValues, options);
|
|
1252
|
-
const label = selected.length > 0 ? colors.dim(selected.map(getLabel).join(", ")) : "";
|
|
1253
|
-
const submitPrefix = hasGuide ? `${colors.gray(S_BAR)} ` : nestedPrefix;
|
|
1254
|
-
return `${headings.join("\n")}\n${submitPrefix}${label}\n\n`;
|
|
1255
|
-
}
|
|
1256
|
-
case "cancel": {
|
|
1257
|
-
const userInputText = userInput ? colors.strikethrough(colors.dim(userInput)) : "";
|
|
1258
|
-
const cancelPrefix = hasGuide ? `${colors.gray(S_BAR)} ` : nestedPrefix;
|
|
1259
|
-
return `${headings.join("\n")}\n${cancelPrefix}${userInputText}\n\n`;
|
|
1260
|
-
}
|
|
1261
|
-
default: {
|
|
1262
|
-
const barColor = this.state === "error" ? colors.yellow : colors.blue;
|
|
1263
|
-
const guidePrefix = hasGuide ? `${barColor(S_BAR)} ` : nestedPrefix;
|
|
1264
|
-
const guidePrefixEnd = hasGuide ? barColor(S_BAR_END) : "";
|
|
1265
|
-
let searchText = "";
|
|
1266
|
-
if (this.isNavigating || showPlaceholder) {
|
|
1267
|
-
const searchTextValue = showPlaceholder ? placeholder : userInput;
|
|
1268
|
-
searchText = searchTextValue !== "" ? ` ${colors.dim(searchTextValue)}` : "";
|
|
1269
|
-
} else searchText = ` ${this.userInputWithCursor}`;
|
|
1270
|
-
const matches = this.filteredOptions.length !== options.length ? colors.dim(` (${this.filteredOptions.length} match${this.filteredOptions.length === 1 ? "" : "es"})`) : "";
|
|
1271
|
-
const noResults = this.filteredOptions.length === 0 && userInput ? [`${guidePrefix}${colors.yellow("No matches found")}`] : [];
|
|
1272
|
-
const validationError = this.state === "error" ? [`${guidePrefix}${colors.yellow(this.error)}`] : [];
|
|
1273
|
-
if (hasGuide) headings.push(guidePrefix.trimEnd());
|
|
1274
|
-
headings.push(`${guidePrefix}${colors.dim("Search:")}${searchText}${matches}`, ...noResults, ...validationError);
|
|
1275
|
-
const footers = [`${guidePrefix}${[
|
|
1276
|
-
`${colors.dim("↑/↓")} to select`,
|
|
1277
|
-
`${colors.dim("Enter:")} confirm`,
|
|
1278
|
-
`${colors.dim("Type:")} to search`
|
|
1279
|
-
].join(" • ")}`, guidePrefixEnd];
|
|
1280
|
-
const displayOptions = this.filteredOptions.length === 0 ? [] : limitOptions({
|
|
1281
|
-
cursor: this.cursor,
|
|
1282
|
-
options: this.filteredOptions,
|
|
1283
|
-
columnPadding: hasGuide ? 2 : 2,
|
|
1284
|
-
rowPadding: headings.length + footers.length,
|
|
1285
|
-
style: (option, active) => {
|
|
1286
|
-
const label = getLabel(option);
|
|
1287
|
-
const hint = option.hint && option.value === this.focusedValue ? colors.gray(` (${option.hint})`) : "";
|
|
1288
|
-
return active ? withMarker$1(colors.blue(S_POINTER_ACTIVE), label, (text) => colors.blue(colors.bold(text)), hint) : withMarker$1(colors.dim(S_POINTER_INACTIVE), label, colors.dim, hint);
|
|
1289
|
-
},
|
|
1290
|
-
maxItems: opts.maxItems,
|
|
1291
|
-
output: opts.output
|
|
1292
|
-
});
|
|
1293
|
-
return [
|
|
1294
|
-
...headings,
|
|
1295
|
-
...displayOptions.map((option) => `${guidePrefix}${option}`),
|
|
1296
|
-
...footers
|
|
1297
|
-
].join("\n");
|
|
1298
|
-
}
|
|
1299
|
-
}
|
|
1300
|
-
}
|
|
1301
|
-
}).prompt();
|
|
1302
|
-
};
|
|
1303
|
-
/**
|
|
1304
|
-
* Integrated autocomplete multiselect - combines type-ahead filtering with multiselect in one UI
|
|
1305
|
-
*/
|
|
1306
|
-
const autocompleteMultiselect = (opts) => {
|
|
1307
|
-
const formatOption = (option, active, selectedValues, focusedValue) => {
|
|
1308
|
-
const isSelected = selectedValues.includes(option.value);
|
|
1309
|
-
const label = option.label ?? String(option.value ?? "");
|
|
1310
|
-
const hint = option.hint && focusedValue !== void 0 && option.value === focusedValue ? colors.gray(` (${option.hint})`) : "";
|
|
1311
|
-
const checkboxRaw = isSelected ? S_CHECKBOX_SELECTED : S_CHECKBOX_INACTIVE;
|
|
1312
|
-
const checkbox = isSelected ? colors.blue(checkboxRaw) : colors.dim(checkboxRaw);
|
|
1313
|
-
return withMarkerAndIndicator(active ? colors.blue(S_POINTER_ACTIVE) : colors.dim(S_POINTER_INACTIVE), checkbox, checkboxRaw.length, label, active ? (text) => colors.blue(colors.bold(text)) : colors.dim, hint);
|
|
1314
|
-
};
|
|
1315
|
-
const prompt = new Vt({
|
|
1316
|
-
options: opts.options,
|
|
1317
|
-
multiple: true,
|
|
1318
|
-
filter: opts.filter ?? ((search, opt) => {
|
|
1319
|
-
return getFilteredOption(search, opt);
|
|
1320
|
-
}),
|
|
1321
|
-
validate: () => {
|
|
1322
|
-
if (opts.required && prompt.selectedValues.length === 0) return "Please select at least one item";
|
|
1323
|
-
},
|
|
1324
|
-
initialValue: opts.initialValues,
|
|
1325
|
-
signal: opts.signal,
|
|
1326
|
-
input: opts.input,
|
|
1327
|
-
output: opts.output,
|
|
1328
|
-
render() {
|
|
1329
|
-
const hasGuide = opts.withGuide ?? false;
|
|
1330
|
-
const nestedPrefix = " ";
|
|
1331
|
-
const title = `${hasGuide ? `${colors.gray(S_BAR)}\n` : ""}${symbol(this.state)} ${opts.message}\n`;
|
|
1332
|
-
const userInput = this.userInput;
|
|
1333
|
-
const placeholder = opts.placeholder;
|
|
1334
|
-
const showPlaceholder = userInput === "" && placeholder !== void 0;
|
|
1335
|
-
const searchText = this.isNavigating || showPlaceholder ? colors.dim(showPlaceholder ? placeholder : userInput) : this.userInputWithCursor;
|
|
1336
|
-
const options = this.options;
|
|
1337
|
-
const matches = this.filteredOptions.length !== options.length ? colors.dim(` (${this.filteredOptions.length} match${this.filteredOptions.length === 1 ? "" : "es"})`) : "";
|
|
1338
|
-
switch (this.state) {
|
|
1339
|
-
case "submit": {
|
|
1340
|
-
const submitPrefix = hasGuide ? `${colors.gray(S_BAR)} ` : "";
|
|
1341
|
-
return `${title}${hasGuide ? submitPrefix : nestedPrefix}${colors.dim(`${this.selectedValues.length} items selected`)}\n\n`;
|
|
1342
|
-
}
|
|
1343
|
-
case "cancel": {
|
|
1344
|
-
const cancelPrefix = hasGuide ? `${colors.gray(S_BAR)} ` : "";
|
|
1345
|
-
return `${title}${hasGuide ? cancelPrefix : nestedPrefix}${colors.strikethrough(colors.dim(userInput))}\n\n`;
|
|
1346
|
-
}
|
|
1347
|
-
default: {
|
|
1348
|
-
const barColor = this.state === "error" ? colors.yellow : colors.blue;
|
|
1349
|
-
const prefix = hasGuide ? `${barColor(S_BAR)} ` : nestedPrefix;
|
|
1350
|
-
const footerEnd = hasGuide ? [barColor(S_BAR_END)] : [];
|
|
1351
|
-
const instructions = [
|
|
1352
|
-
`${colors.dim("↑/↓")} to navigate`,
|
|
1353
|
-
`${colors.dim(this.isNavigating ? "Space/Tab:" : "Tab:")} select`,
|
|
1354
|
-
`${colors.dim("Enter:")} confirm`,
|
|
1355
|
-
`${colors.dim("Type:")} to search`
|
|
1356
|
-
];
|
|
1357
|
-
const noResults = this.filteredOptions.length === 0 && userInput ? [`${prefix}${colors.yellow("No matches found")}`] : [];
|
|
1358
|
-
const errorMessage = this.state === "error" ? [`${prefix}${colors.yellow(this.error)}`] : [];
|
|
1359
|
-
const headerLines = [
|
|
1360
|
-
...title.trimEnd().split("\n"),
|
|
1361
|
-
`${prefix}${colors.dim("Search:")} ${searchText}${matches}`,
|
|
1362
|
-
...noResults,
|
|
1363
|
-
...errorMessage
|
|
1364
|
-
];
|
|
1365
|
-
const footerLines = [`${prefix}${instructions.join(" • ")}`, ...footerEnd];
|
|
1366
|
-
const displayOptions = limitOptions({
|
|
1367
|
-
cursor: this.cursor,
|
|
1368
|
-
options: this.filteredOptions,
|
|
1369
|
-
style: (option, active) => formatOption(option, active, this.selectedValues, this.focusedValue),
|
|
1370
|
-
maxItems: opts.maxItems,
|
|
1371
|
-
output: opts.output,
|
|
1372
|
-
rowPadding: headerLines.length + footerLines.length
|
|
1373
|
-
});
|
|
1374
|
-
return [
|
|
1375
|
-
...headerLines,
|
|
1376
|
-
...displayOptions.map((option) => `${prefix}${option}`),
|
|
1377
|
-
...footerLines
|
|
1378
|
-
].join("\n");
|
|
1379
|
-
}
|
|
1380
|
-
}
|
|
1381
|
-
}
|
|
1382
|
-
});
|
|
1383
|
-
return prompt.prompt();
|
|
1384
|
-
};
|
|
1385
|
-
const roundedSymbols = [
|
|
1386
|
-
S_CORNER_TOP_LEFT,
|
|
1387
|
-
S_CORNER_TOP_RIGHT,
|
|
1388
|
-
S_CORNER_BOTTOM_LEFT,
|
|
1389
|
-
S_CORNER_BOTTOM_RIGHT
|
|
1390
|
-
];
|
|
1391
|
-
const squareSymbols = [
|
|
1392
|
-
S_BAR_START,
|
|
1393
|
-
S_BAR_START_RIGHT,
|
|
1394
|
-
S_BAR_END,
|
|
1395
|
-
S_BAR_END_RIGHT
|
|
1396
|
-
];
|
|
1397
|
-
function getPaddingForLine(lineLength, innerWidth, padding, contentAlign) {
|
|
1398
|
-
let leftPadding = padding;
|
|
1399
|
-
let rightPadding = padding;
|
|
1400
|
-
if (contentAlign === "center") leftPadding = Math.floor((innerWidth - lineLength) / 2);
|
|
1401
|
-
else if (contentAlign === "right") leftPadding = innerWidth - lineLength - padding;
|
|
1402
|
-
rightPadding = innerWidth - leftPadding - lineLength;
|
|
1403
|
-
return [leftPadding, rightPadding];
|
|
1404
|
-
}
|
|
1405
|
-
const defaultFormatBorder = (text) => text;
|
|
1406
|
-
const box = (message = "", title = "", opts) => {
|
|
1407
|
-
const output = opts?.output ?? process.stdout;
|
|
1408
|
-
const columns = rt(output);
|
|
1409
|
-
const borderTotalWidth = 2;
|
|
1410
|
-
const titlePadding = opts?.titlePadding ?? 1;
|
|
1411
|
-
const contentPadding = opts?.contentPadding ?? 2;
|
|
1412
|
-
const width = opts?.width === void 0 || opts.width === "auto" ? 1 : Math.min(1, opts.width);
|
|
1413
|
-
const linePrefix = !(opts?.withGuide ?? false) ? "" : `${S_BAR} `;
|
|
1414
|
-
const formatBorder = opts?.formatBorder ?? defaultFormatBorder;
|
|
1415
|
-
const symbols = (opts?.rounded ? roundedSymbols : squareSymbols).map(formatBorder);
|
|
1416
|
-
const hSymbol = formatBorder(S_BAR_H);
|
|
1417
|
-
const vSymbol = formatBorder(S_BAR);
|
|
1418
|
-
const linePrefixWidth = fastStringWidth(linePrefix);
|
|
1419
|
-
const titleWidth = fastStringWidth(title);
|
|
1420
|
-
const maxBoxWidth = columns - linePrefixWidth;
|
|
1421
|
-
let boxWidth = Math.floor(columns * width) - linePrefixWidth;
|
|
1422
|
-
if (opts?.width === "auto") {
|
|
1423
|
-
const lines = message.split("\n");
|
|
1424
|
-
let longestLine = titleWidth + titlePadding * 2;
|
|
1425
|
-
for (const line of lines) {
|
|
1426
|
-
const lineWithPadding = fastStringWidth(line) + contentPadding * 2;
|
|
1427
|
-
if (lineWithPadding > longestLine) longestLine = lineWithPadding;
|
|
1428
|
-
}
|
|
1429
|
-
const longestLineWidth = longestLine + borderTotalWidth;
|
|
1430
|
-
if (longestLineWidth < boxWidth) boxWidth = longestLineWidth;
|
|
1431
|
-
}
|
|
1432
|
-
if (boxWidth % 2 !== 0) if (boxWidth < maxBoxWidth) boxWidth++;
|
|
1433
|
-
else boxWidth--;
|
|
1434
|
-
const innerWidth = boxWidth - borderTotalWidth;
|
|
1435
|
-
const maxTitleLength = innerWidth - titlePadding * 2;
|
|
1436
|
-
const truncatedTitle = titleWidth > maxTitleLength ? `${title.slice(0, maxTitleLength - 3)}...` : title;
|
|
1437
|
-
const [titlePaddingLeft, titlePaddingRight] = getPaddingForLine(fastStringWidth(truncatedTitle), innerWidth, titlePadding, opts?.titleAlign);
|
|
1438
|
-
const wrappedMessage = wrapAnsi(message, innerWidth - contentPadding * 2, {
|
|
1439
|
-
hard: true,
|
|
1440
|
-
trim: false
|
|
1441
|
-
});
|
|
1442
|
-
output.write(`${linePrefix}${symbols[0]}${hSymbol.repeat(titlePaddingLeft)}${truncatedTitle}${hSymbol.repeat(titlePaddingRight)}${symbols[1]}\n`);
|
|
1443
|
-
const wrappedLines = wrappedMessage.split("\n");
|
|
1444
|
-
for (const line of wrappedLines) {
|
|
1445
|
-
const [leftLinePadding, rightLinePadding] = getPaddingForLine(fastStringWidth(line), innerWidth, contentPadding, opts?.contentAlign);
|
|
1446
|
-
output.write(`${linePrefix}${vSymbol}${" ".repeat(leftLinePadding)}${line}${" ".repeat(rightLinePadding)}${vSymbol}\n`);
|
|
1447
|
-
}
|
|
1448
|
-
output.write(`${linePrefix}${symbols[2]}${hSymbol.repeat(innerWidth)}${symbols[3]}\n`);
|
|
1449
|
-
};
|
|
1450
1006
|
const confirm = (opts) => {
|
|
1451
1007
|
const active = opts.active ?? "Yes";
|
|
1452
1008
|
const inactive = opts.inactive ?? "No";
|
|
@@ -1460,135 +1016,22 @@ const confirm = (opts) => {
|
|
|
1460
1016
|
render() {
|
|
1461
1017
|
const hasGuide = opts.withGuide ?? false;
|
|
1462
1018
|
const nestedPrefix = " ";
|
|
1463
|
-
const title = `${hasGuide ? `${
|
|
1019
|
+
const title = `${hasGuide ? `${color.gray(S_BAR)}\n` : ""}${symbol(this.state)} ${opts.message}\n`;
|
|
1464
1020
|
const value = this.value ? active : inactive;
|
|
1465
1021
|
switch (this.state) {
|
|
1466
|
-
case "submit": return `${title}${hasGuide ? `${
|
|
1467
|
-
case "cancel": return `${title}${hasGuide ? `${
|
|
1468
|
-
default: {
|
|
1469
|
-
const defaultPrefix = hasGuide ? `${colors.blue(S_BAR)} ` : nestedPrefix;
|
|
1470
|
-
const defaultPrefixEnd = hasGuide ? colors.blue(S_BAR_END) : "";
|
|
1471
|
-
return `${title}${defaultPrefix}${this.value ? `${colors.blue(S_POINTER_ACTIVE)} ${colors.bold(active)}` : `${colors.dim(S_POINTER_INACTIVE)} ${colors.dim(active)}`}${opts.vertical ? hasGuide ? `\n${colors.blue(S_BAR)} ` : `\n${nestedPrefix}` : ` ${colors.dim("/")} `}${!this.value ? `${colors.blue(S_POINTER_ACTIVE)} ${colors.bold(inactive)}` : `${colors.dim(S_POINTER_INACTIVE)} ${colors.dim(inactive)}`}\n${defaultPrefixEnd}\n`;
|
|
1472
|
-
}
|
|
1473
|
-
}
|
|
1474
|
-
}
|
|
1475
|
-
}).prompt();
|
|
1476
|
-
};
|
|
1477
|
-
/**
|
|
1478
|
-
* Define a group of prompts to be displayed
|
|
1479
|
-
* and return a results of objects within the group
|
|
1480
|
-
*/
|
|
1481
|
-
const group = async (prompts, opts) => {
|
|
1482
|
-
const results = {};
|
|
1483
|
-
const promptNames = Object.keys(prompts);
|
|
1484
|
-
for (const name of promptNames) {
|
|
1485
|
-
const prompt = prompts[name];
|
|
1486
|
-
const result = await prompt({ results })?.catch((e) => {
|
|
1487
|
-
throw e;
|
|
1488
|
-
});
|
|
1489
|
-
if (typeof opts?.onCancel === "function" && Ct(result)) {
|
|
1490
|
-
results[name] = "canceled";
|
|
1491
|
-
opts.onCancel({ results });
|
|
1492
|
-
continue;
|
|
1493
|
-
}
|
|
1494
|
-
results[name] = result;
|
|
1495
|
-
}
|
|
1496
|
-
return results;
|
|
1497
|
-
};
|
|
1498
|
-
const groupMultiselect = (opts) => {
|
|
1499
|
-
const { selectableGroups = true, groupSpacing = 0 } = opts;
|
|
1500
|
-
const hasGuide = opts.withGuide ?? false;
|
|
1501
|
-
const nestedPrefix = " ";
|
|
1502
|
-
const withMarkerAndPrefix = (marker, prefix, prefixWidth, label, format, firstLineSuffix = "", spacingPrefix = "") => {
|
|
1503
|
-
const lines = label.split("\n");
|
|
1504
|
-
const continuationPrefix = `${S_POINTER_INACTIVE} ${" ".repeat(prefixWidth)}`;
|
|
1505
|
-
if (lines.length === 1) return `${spacingPrefix}${marker} ${prefix}${format(lines[0])}${firstLineSuffix}`;
|
|
1506
|
-
const [firstLine, ...rest] = lines;
|
|
1507
|
-
return [`${spacingPrefix}${marker} ${prefix}${format(firstLine)}${firstLineSuffix}`, ...rest.map((line) => `${continuationPrefix}${format(line)}`)].join("\n");
|
|
1508
|
-
};
|
|
1509
|
-
const opt = (option, state, options = []) => {
|
|
1510
|
-
const label = option.label ?? String(option.value);
|
|
1511
|
-
const hint = option.hint ? ` ${colors.gray(`(${option.hint})`)}` : "";
|
|
1512
|
-
const isItem = typeof option.group === "string";
|
|
1513
|
-
const next = isItem && (options[options.indexOf(option) + 1] ?? { group: true });
|
|
1514
|
-
const isLast = isItem && next && next.group === true;
|
|
1515
|
-
const branchPrefixRaw = isItem ? selectableGroups ? `${isLast ? S_BAR_END : S_BAR} ` : " " : "";
|
|
1516
|
-
let spacingPrefix = "";
|
|
1517
|
-
if (groupSpacing > 0 && !isItem) {
|
|
1518
|
-
const spacingPrefixText = hasGuide ? `\n${colors.blue(S_BAR)}` : "\n";
|
|
1519
|
-
const spacingSuffix = hasGuide ? " " : "";
|
|
1520
|
-
spacingPrefix = `${spacingPrefixText.repeat(groupSpacing - 1)}${spacingPrefixText}${spacingSuffix}`;
|
|
1521
|
-
}
|
|
1522
|
-
if (state === "cancelled") return colors.strikethrough(colors.dim(label));
|
|
1523
|
-
if (state === "submitted") return colors.dim(label);
|
|
1524
|
-
const marker = state === "active" || state === "active-selected" ? colors.blue(S_POINTER_ACTIVE) : colors.dim(S_POINTER_INACTIVE);
|
|
1525
|
-
const branchPrefix = colors.dim(branchPrefixRaw);
|
|
1526
|
-
const hasCheckbox = isItem || selectableGroups;
|
|
1527
|
-
const checkboxRaw = hasCheckbox ? state === "active" || state === "group-active" ? S_CHECKBOX_ACTIVE : state === "selected" || state === "active-selected" || state === "group-active-selected" ? S_CHECKBOX_SELECTED : S_CHECKBOX_INACTIVE : "";
|
|
1528
|
-
const checkbox = hasCheckbox ? checkboxRaw === S_CHECKBOX_SELECTED ? colors.blue(checkboxRaw) : checkboxRaw === S_CHECKBOX_ACTIVE ? colors.blue(checkboxRaw) : colors.dim(checkboxRaw) : "";
|
|
1529
|
-
const format = state === "active" || state === "active-selected" ? (text) => colors.blue(colors.bold(text)) : colors.dim;
|
|
1530
|
-
return withMarkerAndPrefix(marker, `${branchPrefix}${hasCheckbox ? `${checkbox} ` : ""}`, branchPrefixRaw.length + (hasCheckbox ? checkboxRaw.length + 1 : 0), label, format, hint, spacingPrefix);
|
|
1531
|
-
};
|
|
1532
|
-
const required = opts.required ?? true;
|
|
1533
|
-
return new yt({
|
|
1534
|
-
options: opts.options,
|
|
1535
|
-
signal: opts.signal,
|
|
1536
|
-
input: opts.input,
|
|
1537
|
-
output: opts.output,
|
|
1538
|
-
initialValues: opts.initialValues,
|
|
1539
|
-
required,
|
|
1540
|
-
cursorAt: opts.cursorAt,
|
|
1541
|
-
selectableGroups,
|
|
1542
|
-
validate(selected) {
|
|
1543
|
-
if (required && (selected === void 0 || selected.length === 0)) return `Please select at least one option.\n${colors.reset(colors.dim(`Press ${colors.gray(colors.bgWhite(colors.inverse(" space ")))} to select, ${colors.gray(colors.bgWhite(colors.inverse(" enter ")))} to submit`))}`;
|
|
1544
|
-
},
|
|
1545
|
-
render() {
|
|
1546
|
-
const title = `${hasGuide ? `${colors.gray(S_BAR)}\n` : ""}${symbol(this.state)} ${opts.message}\n`;
|
|
1547
|
-
const value = this.value ?? [];
|
|
1548
|
-
switch (this.state) {
|
|
1549
|
-
case "submit": {
|
|
1550
|
-
const selectedOptions = this.options.filter(({ value: optionValue }) => value.includes(optionValue)).map((option) => opt(option, "submitted"));
|
|
1551
|
-
return `${title}${hasGuide ? `${colors.gray(S_BAR)} ` : nestedPrefix}${selectedOptions.length === 0 ? "" : selectedOptions.join(colors.dim(", "))}\n\n`;
|
|
1552
|
-
}
|
|
1553
|
-
case "cancel": {
|
|
1554
|
-
const label = this.options.filter(({ value: optionValue }) => value.includes(optionValue)).map((option) => opt(option, "cancelled")).join(colors.dim(", "));
|
|
1555
|
-
if (!label.trim()) return hasGuide ? `${title}${colors.gray(S_BAR)}\n\n` : `${title.trimEnd()}\n\n`;
|
|
1556
|
-
const cancelPrefix = hasGuide ? `${colors.gray(S_BAR)} ` : nestedPrefix;
|
|
1557
|
-
return hasGuide ? `${title}${cancelPrefix}${label}\n${colors.gray(S_BAR)}\n\n` : `${title}${cancelPrefix}${label}\n\n`;
|
|
1558
|
-
}
|
|
1559
|
-
case "error": {
|
|
1560
|
-
const prefix = hasGuide ? `${colors.yellow(S_BAR)} ` : nestedPrefix;
|
|
1561
|
-
const footer = hasGuide ? this.error.split("\n").map((ln, i) => i === 0 ? `${colors.yellow(S_BAR_END)} ${colors.yellow(ln)}` : ` ${ln}`).join("\n") : `${nestedPrefix}${colors.yellow(this.error)}`;
|
|
1562
|
-
return `${title}${prefix}${this.options.map((option, i, options) => {
|
|
1563
|
-
const selected = value.includes(option.value) || option.group === true && this.isGroupSelected(String(option.value));
|
|
1564
|
-
const active = i === this.cursor;
|
|
1565
|
-
if (!active && typeof option.group === "string" && this.options[this.cursor].value === option.group) return opt(option, selected ? "group-active-selected" : "group-active", options);
|
|
1566
|
-
if (active && selected) return opt(option, "active-selected", options);
|
|
1567
|
-
if (selected) return opt(option, "selected", options);
|
|
1568
|
-
return opt(option, active ? "active" : "inactive", options);
|
|
1569
|
-
}).join(`\n${prefix}`)}\n${footer}\n`;
|
|
1570
|
-
}
|
|
1022
|
+
case "submit": return `${title}${hasGuide ? `${color.gray(S_BAR)} ` : nestedPrefix}${color.dim(value)}\n`;
|
|
1023
|
+
case "cancel": return `${title}${hasGuide ? `${color.gray(S_BAR)} ` : nestedPrefix}${color.strikethrough(color.dim(value))}${hasGuide ? `\n${color.gray(S_BAR)}` : ""}\n`;
|
|
1571
1024
|
default: {
|
|
1572
|
-
const
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
const groupActive = !active && typeof option.group === "string" && this.options[this.cursor].value === option.group;
|
|
1576
|
-
let optionText = "";
|
|
1577
|
-
if (groupActive) optionText = opt(option, selected ? "group-active-selected" : "group-active", options);
|
|
1578
|
-
else if (active && selected) optionText = opt(option, "active-selected", options);
|
|
1579
|
-
else if (selected) optionText = opt(option, "selected", options);
|
|
1580
|
-
else optionText = opt(option, active ? "active" : "inactive", options);
|
|
1581
|
-
return `${i !== 0 && !optionText.startsWith("\n") ? " " : ""}${optionText}`;
|
|
1582
|
-
}).join(hasGuide ? `\n${colors.blue(S_BAR)}` : "\n");
|
|
1583
|
-
const optionsPrefix = optionsText.startsWith("\n") ? "" : nestedPrefix;
|
|
1584
|
-
return `${title}${hasGuide ? colors.blue(S_BAR) : ""}${optionsPrefix}${optionsText}\n${hasGuide ? colors.blue(S_BAR_END) : ""}\n`;
|
|
1025
|
+
const defaultPrefix = hasGuide ? `${color.blue(S_BAR)} ` : nestedPrefix;
|
|
1026
|
+
const defaultPrefixEnd = hasGuide ? color.blue(S_BAR_END) : "";
|
|
1027
|
+
return `${title}${defaultPrefix}${this.value ? `${color.blue(S_POINTER_ACTIVE)} ${color.bold(active)}` : `${color.dim(" ")} ${color.dim(active)}`}${opts.vertical ? hasGuide ? `\n${color.blue(S_BAR)} ` : `\n${nestedPrefix}` : ` ${color.dim("/")} `}${!this.value ? `${color.blue(S_POINTER_ACTIVE)} ${color.bold(inactive)}` : `${color.dim(" ")} ${color.dim(inactive)}`}\n${defaultPrefixEnd}\n`;
|
|
1585
1028
|
}
|
|
1586
1029
|
}
|
|
1587
1030
|
}
|
|
1588
1031
|
}).prompt();
|
|
1589
1032
|
};
|
|
1590
1033
|
const log = {
|
|
1591
|
-
message: (message = [], { symbol =
|
|
1034
|
+
message: (message = [], { symbol = color.gray(S_BAR), secondarySymbol = color.gray(S_BAR), output = process.stdout, spacing = 1, withGuide } = {}) => {
|
|
1592
1035
|
const parts = [];
|
|
1593
1036
|
const hasGuide = withGuide ?? false;
|
|
1594
1037
|
const spacingString = !hasGuide ? "" : secondarySymbol;
|
|
@@ -1608,7 +1051,7 @@ const log = {
|
|
|
1608
1051
|
info: (message, opts) => {
|
|
1609
1052
|
log.message(message, {
|
|
1610
1053
|
...opts,
|
|
1611
|
-
symbol:
|
|
1054
|
+
symbol: color.blue(S_INFO)
|
|
1612
1055
|
});
|
|
1613
1056
|
},
|
|
1614
1057
|
success: (message, opts) => {
|
|
@@ -1626,7 +1069,7 @@ const log = {
|
|
|
1626
1069
|
warn: (message, opts) => {
|
|
1627
1070
|
log.message(message, {
|
|
1628
1071
|
...opts,
|
|
1629
|
-
symbol:
|
|
1072
|
+
symbol: color.yellow(S_WARN)
|
|
1630
1073
|
});
|
|
1631
1074
|
},
|
|
1632
1075
|
warning: (message, opts) => {
|
|
@@ -1635,12 +1078,12 @@ const log = {
|
|
|
1635
1078
|
error: (message, opts) => {
|
|
1636
1079
|
log.message(message, {
|
|
1637
1080
|
...opts,
|
|
1638
|
-
symbol:
|
|
1081
|
+
symbol: color.red(S_ERROR)
|
|
1639
1082
|
});
|
|
1640
1083
|
}
|
|
1641
1084
|
};
|
|
1642
1085
|
const cancel = (message = "", opts) => {
|
|
1643
|
-
(opts?.output ?? process.stdout).write(`${
|
|
1086
|
+
(opts?.output ?? process.stdout).write(`${color.red(message)}\n\n`);
|
|
1644
1087
|
};
|
|
1645
1088
|
const intro = (title = "", opts) => {
|
|
1646
1089
|
(opts?.output ?? process.stdout).write(`${title}\n\n`);
|
|
@@ -1653,7 +1096,7 @@ const computeLabel$1 = (label, format) => {
|
|
|
1653
1096
|
};
|
|
1654
1097
|
const withMarkerAndCheckbox = (marker, checkbox, checkboxWidth, label, format, firstLineSuffix = "") => {
|
|
1655
1098
|
const lines = label.split("\n");
|
|
1656
|
-
const continuationPrefix =
|
|
1099
|
+
const continuationPrefix = ` ${" ".repeat(checkboxWidth)} `;
|
|
1657
1100
|
if (lines.length === 1) return `${marker} ${checkbox} ${format(lines[0])}${firstLineSuffix}`;
|
|
1658
1101
|
const [firstLine, ...rest] = lines;
|
|
1659
1102
|
return [`${marker} ${checkbox} ${format(firstLine)}${firstLineSuffix}`, ...rest.map((line) => `${continuationPrefix}${format(line)}`)].join("\n");
|
|
@@ -1661,14 +1104,14 @@ const withMarkerAndCheckbox = (marker, checkbox, checkboxWidth, label, format, f
|
|
|
1661
1104
|
const multiselect = (opts) => {
|
|
1662
1105
|
const opt = (option, state) => {
|
|
1663
1106
|
const label = option.label ?? String(option.value);
|
|
1664
|
-
const hint = option.hint ? ` ${
|
|
1665
|
-
if (state === "disabled") return withMarkerAndCheckbox(
|
|
1666
|
-
if (state === "active") return withMarkerAndCheckbox(
|
|
1667
|
-
if (state === "selected") return withMarkerAndCheckbox(
|
|
1668
|
-
if (state === "cancelled") return computeLabel$1(label, (text) =>
|
|
1669
|
-
if (state === "active-selected") return withMarkerAndCheckbox(
|
|
1670
|
-
if (state === "submitted") return computeLabel$1(label,
|
|
1671
|
-
return withMarkerAndCheckbox(
|
|
1107
|
+
const hint = option.hint ? ` ${color.gray(`(${option.hint})`)}` : "";
|
|
1108
|
+
if (state === "disabled") return withMarkerAndCheckbox(color.gray(" "), color.gray(S_CHECKBOX_INACTIVE), S_CHECKBOX_INACTIVE.length, label, (str) => color.strikethrough(color.gray(str)), option.hint ? ` ${color.dim(`(${option.hint ?? "disabled"})`)}` : "");
|
|
1109
|
+
if (state === "active") return withMarkerAndCheckbox(color.blue(S_POINTER_ACTIVE), color.blue(S_CHECKBOX_ACTIVE), S_CHECKBOX_ACTIVE.length, label, (text) => color.blue(color.bold(text)), hint);
|
|
1110
|
+
if (state === "selected") return withMarkerAndCheckbox(color.dim(" "), color.blue(S_CHECKBOX_SELECTED), S_CHECKBOX_SELECTED.length, label, color.dim, hint);
|
|
1111
|
+
if (state === "cancelled") return computeLabel$1(label, (text) => color.strikethrough(color.dim(text)));
|
|
1112
|
+
if (state === "active-selected") return withMarkerAndCheckbox(color.blue(S_POINTER_ACTIVE), color.blue(S_CHECKBOX_SELECTED), S_CHECKBOX_SELECTED.length, label, (text) => color.blue(color.bold(text)), hint);
|
|
1113
|
+
if (state === "submitted") return computeLabel$1(label, color.dim);
|
|
1114
|
+
return withMarkerAndCheckbox(color.dim(" "), color.dim(S_CHECKBOX_INACTIVE), S_CHECKBOX_INACTIVE.length, label, color.dim);
|
|
1672
1115
|
};
|
|
1673
1116
|
const required = opts.required ?? true;
|
|
1674
1117
|
return new Lt({
|
|
@@ -1680,7 +1123,7 @@ const multiselect = (opts) => {
|
|
|
1680
1123
|
required,
|
|
1681
1124
|
cursorAt: opts.cursorAt,
|
|
1682
1125
|
validate(selected) {
|
|
1683
|
-
if (required && (selected === void 0 || selected.length === 0)) return `Please select at least one option.\n${
|
|
1126
|
+
if (required && (selected === void 0 || selected.length === 0)) return `Please select at least one option.\n${color.reset(color.dim(`Press ${color.gray(color.bgWhite(color.inverse(" space ")))} to select, ${color.gray(color.bgWhite(color.inverse(" enter ")))} to submit`))}`;
|
|
1684
1127
|
},
|
|
1685
1128
|
render() {
|
|
1686
1129
|
const hasGuide = opts.withGuide ?? false;
|
|
@@ -1689,7 +1132,7 @@ const multiselect = (opts) => {
|
|
|
1689
1132
|
return message.split("\n").map((line, index) => `${index === 0 ? `${symbol(this.state)} ` : nestedPrefix}${line}`).join("\n");
|
|
1690
1133
|
};
|
|
1691
1134
|
const wrappedMessage = hasGuide ? xt(opts.output, opts.message, `${symbolBar(this.state)} `, `${symbol(this.state)} `) : formatMessageLines(opts.message);
|
|
1692
|
-
const title = `${hasGuide ? `${
|
|
1135
|
+
const title = `${hasGuide ? `${color.gray(S_BAR)}\n` : ""}${wrappedMessage}\n`;
|
|
1693
1136
|
const value = this.value ?? [];
|
|
1694
1137
|
const styleOption = (option, active) => {
|
|
1695
1138
|
if (option.disabled) return opt(option, "disabled");
|
|
@@ -1700,20 +1143,20 @@ const multiselect = (opts) => {
|
|
|
1700
1143
|
};
|
|
1701
1144
|
switch (this.state) {
|
|
1702
1145
|
case "submit": {
|
|
1703
|
-
const submitText = this.options.filter(({ value: optionValue }) => value.includes(optionValue)).map((option) => opt(option, "submitted")).join(
|
|
1704
|
-
const submitPrefix = hasGuide ? `${
|
|
1705
|
-
return `${title}${xt(opts.output, submitText, submitPrefix)}\n
|
|
1146
|
+
const submitText = this.options.filter(({ value: optionValue }) => value.includes(optionValue)).map((option) => opt(option, "submitted")).join(color.dim(", ")) || color.dim("none");
|
|
1147
|
+
const submitPrefix = hasGuide ? `${color.gray(S_BAR)} ` : nestedPrefix;
|
|
1148
|
+
return `${title}${xt(opts.output, submitText, submitPrefix)}\n`;
|
|
1706
1149
|
}
|
|
1707
1150
|
case "cancel": {
|
|
1708
|
-
const label = this.options.filter(({ value: optionValue }) => value.includes(optionValue)).map((option) => opt(option, "cancelled")).join(
|
|
1709
|
-
if (label.trim() === "") return hasGuide ? `${title}${
|
|
1710
|
-
const cancelPrefix = hasGuide ? `${
|
|
1151
|
+
const label = this.options.filter(({ value: optionValue }) => value.includes(optionValue)).map((option) => opt(option, "cancelled")).join(color.dim(", "));
|
|
1152
|
+
if (label.trim() === "") return hasGuide ? `${title}${color.gray(S_BAR)}\n` : `${title.trimEnd()}\n`;
|
|
1153
|
+
const cancelPrefix = hasGuide ? `${color.gray(S_BAR)} ` : nestedPrefix;
|
|
1711
1154
|
const wrappedLabel = xt(opts.output, label, cancelPrefix);
|
|
1712
|
-
return hasGuide ? `${title}${wrappedLabel}\n${
|
|
1155
|
+
return hasGuide ? `${title}${wrappedLabel}\n${color.gray(S_BAR)}\n` : `${title}${wrappedLabel}\n`;
|
|
1713
1156
|
}
|
|
1714
1157
|
case "error": {
|
|
1715
|
-
const prefix = hasGuide ? `${
|
|
1716
|
-
const footer = hasGuide ? this.error.split("\n").map((ln, i) => i === 0 ? `${
|
|
1158
|
+
const prefix = hasGuide ? `${color.yellow(S_BAR)} ` : nestedPrefix;
|
|
1159
|
+
const footer = hasGuide ? this.error.split("\n").map((ln, i) => i === 0 ? `${color.yellow(S_BAR_END)} ${color.yellow(ln)}` : ` ${ln}`).join("\n") : `${nestedPrefix}${color.yellow(this.error)}`;
|
|
1717
1160
|
const titleLineCount = title.split("\n").length;
|
|
1718
1161
|
const footerLineCount = footer.split("\n").length + 1;
|
|
1719
1162
|
return `${title}${prefix}${limitOptions({
|
|
@@ -1727,7 +1170,7 @@ const multiselect = (opts) => {
|
|
|
1727
1170
|
}).join(`\n${prefix}`)}\n${footer}\n`;
|
|
1728
1171
|
}
|
|
1729
1172
|
default: {
|
|
1730
|
-
const prefix = hasGuide ? `${
|
|
1173
|
+
const prefix = hasGuide ? `${color.blue(S_BAR)} ` : nestedPrefix;
|
|
1731
1174
|
const titleLineCount = title.split("\n").length;
|
|
1732
1175
|
const footerLineCount = hasGuide ? 2 : 1;
|
|
1733
1176
|
return `${title}${prefix}${limitOptions({
|
|
@@ -1738,13 +1181,13 @@ const multiselect = (opts) => {
|
|
|
1738
1181
|
columnPadding: prefix.length,
|
|
1739
1182
|
rowPadding: titleLineCount + footerLineCount,
|
|
1740
1183
|
style: styleOption
|
|
1741
|
-
}).join(`\n${prefix}`)}\n${hasGuide ?
|
|
1184
|
+
}).join(`\n${prefix}`)}\n${hasGuide ? color.blue(S_BAR_END) : ""}\n`;
|
|
1742
1185
|
}
|
|
1743
1186
|
}
|
|
1744
1187
|
}
|
|
1745
1188
|
}).prompt();
|
|
1746
1189
|
};
|
|
1747
|
-
const defaultNoteFormatter = (line) =>
|
|
1190
|
+
const defaultNoteFormatter = (line) => color.dim(line);
|
|
1748
1191
|
const wrapWithFormat = (message, width, format) => {
|
|
1749
1192
|
const opts = {
|
|
1750
1193
|
hard: true,
|
|
@@ -1768,82 +1211,21 @@ const note = (message = "", title = "", opts) => {
|
|
|
1768
1211
|
const width = fastStringWidth(ln);
|
|
1769
1212
|
return width > sum ? width : sum;
|
|
1770
1213
|
}, 0), titleLen) + 2;
|
|
1771
|
-
const lineSymbol = hasGuide ?
|
|
1214
|
+
const lineSymbol = hasGuide ? color.gray(S_BAR) : " ";
|
|
1772
1215
|
const msg = lines.map((ln) => `${lineSymbol} ${ln}${" ".repeat(len - fastStringWidth(ln))}${lineSymbol}`).join("\n");
|
|
1773
|
-
const leadingBorder = hasGuide ? `${
|
|
1216
|
+
const leadingBorder = hasGuide ? `${color.gray(S_BAR)}\n` : "";
|
|
1774
1217
|
const bottomLeft = hasGuide ? S_CONNECT_LEFT : S_CORNER_BOTTOM_LEFT;
|
|
1775
|
-
output.write(`${leadingBorder}${completeColor(S_STEP_SUBMIT)} ${
|
|
1776
|
-
};
|
|
1777
|
-
const password = (opts) => {
|
|
1778
|
-
return new Mt({
|
|
1779
|
-
validate: opts.validate,
|
|
1780
|
-
mask: opts.mask ?? S_PASSWORD_MASK,
|
|
1781
|
-
signal: opts.signal,
|
|
1782
|
-
input: opts.input,
|
|
1783
|
-
output: opts.output,
|
|
1784
|
-
render() {
|
|
1785
|
-
const hasGuide = opts.withGuide ?? false;
|
|
1786
|
-
const nestedPrefix = " ";
|
|
1787
|
-
const title = `${hasGuide ? `${colors.gray(S_BAR)}\n` : ""}${symbol(this.state)} ${opts.message}\n`;
|
|
1788
|
-
const userInput = this.userInputWithCursor;
|
|
1789
|
-
const masked = this.masked;
|
|
1790
|
-
switch (this.state) {
|
|
1791
|
-
case "error": {
|
|
1792
|
-
const errorPrefix = hasGuide ? `${colors.yellow(S_BAR)} ` : nestedPrefix;
|
|
1793
|
-
const errorPrefixEnd = hasGuide ? `${colors.yellow(S_BAR_END)} ` : "";
|
|
1794
|
-
const maskedText = masked ?? "";
|
|
1795
|
-
if (opts.clearOnError) this.clear();
|
|
1796
|
-
return `${title.trim()}\n${errorPrefix}${maskedText}\n${errorPrefixEnd}${colors.yellow(this.error)}\n`;
|
|
1797
|
-
}
|
|
1798
|
-
case "submit": return `${title}${hasGuide ? `${colors.gray(S_BAR)} ` : nestedPrefix}${masked ? colors.dim(masked) : ""}\n\n`;
|
|
1799
|
-
case "cancel": return `${title}${hasGuide ? `${colors.gray(S_BAR)} ` : nestedPrefix}${masked ? colors.strikethrough(colors.dim(masked)) : ""}${masked && hasGuide ? `\n${colors.gray(S_BAR)}` : ""}\n\n`;
|
|
1800
|
-
default: return `${title}${hasGuide ? `${colors.blue(S_BAR)} ` : nestedPrefix}${userInput}\n${hasGuide ? colors.blue(S_BAR_END) : ""}\n`;
|
|
1801
|
-
}
|
|
1802
|
-
}
|
|
1803
|
-
}).prompt();
|
|
1804
|
-
};
|
|
1805
|
-
const path$1 = (opts) => {
|
|
1806
|
-
const validate = opts.validate;
|
|
1807
|
-
return autocomplete({
|
|
1808
|
-
...opts,
|
|
1809
|
-
initialUserInput: opts.initialValue ?? opts.root ?? process.cwd(),
|
|
1810
|
-
maxItems: 5,
|
|
1811
|
-
validate(value) {
|
|
1812
|
-
if (Array.isArray(value)) return;
|
|
1813
|
-
if (!value) return "Please select a path";
|
|
1814
|
-
if (validate) return validate(value);
|
|
1815
|
-
},
|
|
1816
|
-
options() {
|
|
1817
|
-
const userInput = this.userInput;
|
|
1818
|
-
if (userInput === "") return [];
|
|
1819
|
-
try {
|
|
1820
|
-
let searchPath;
|
|
1821
|
-
if (!existsSync(userInput)) searchPath = dirname(userInput);
|
|
1822
|
-
else if (lstatSync(userInput).isDirectory()) searchPath = userInput;
|
|
1823
|
-
else searchPath = dirname(userInput);
|
|
1824
|
-
return readdirSync(searchPath).map((item) => {
|
|
1825
|
-
const path = join(searchPath, item);
|
|
1826
|
-
return {
|
|
1827
|
-
name: item,
|
|
1828
|
-
path,
|
|
1829
|
-
isDirectory: lstatSync(path).isDirectory()
|
|
1830
|
-
};
|
|
1831
|
-
}).filter(({ path, isDirectory }) => path.startsWith(userInput) && (opts.directory || !isDirectory)).map((item) => ({ value: item.path }));
|
|
1832
|
-
} catch {
|
|
1833
|
-
return [];
|
|
1834
|
-
}
|
|
1835
|
-
}
|
|
1836
|
-
});
|
|
1218
|
+
output.write(`${leadingBorder}${completeColor(S_STEP_SUBMIT)} ${color.reset(title)} ${color.gray(S_BAR_H.repeat(Math.max(len - titleLen - 1, 1)) + S_CORNER_TOP_RIGHT)}\n${msg}\n${color.gray(bottomLeft + S_BAR_H.repeat(len + 2) + S_CORNER_BOTTOM_RIGHT)}\n`);
|
|
1837
1219
|
};
|
|
1838
|
-
const defaultStyleFn =
|
|
1220
|
+
const defaultStyleFn = color.magenta;
|
|
1839
1221
|
const removeTrailingDots = (msg) => {
|
|
1840
1222
|
return msg.replace(/\.+$/, "");
|
|
1841
1223
|
};
|
|
1842
|
-
const formatTimer = (
|
|
1843
|
-
const duration =
|
|
1224
|
+
const formatTimer = (durationMs) => {
|
|
1225
|
+
const duration = durationMs / 1e3;
|
|
1844
1226
|
const min = Math.floor(duration / 60);
|
|
1845
1227
|
const secs = Math.floor(duration % 60);
|
|
1846
|
-
return min > 0 ? `
|
|
1228
|
+
return color.gray(min > 0 ? `(${min}m ${secs}s)` : `(${secs}s)`);
|
|
1847
1229
|
};
|
|
1848
1230
|
const spinner = ({ indicator = "dots", onCancel, output = process.stdout, cancelMessage, errorMessage, frames = unicode ? [
|
|
1849
1231
|
"◒",
|
|
@@ -1864,8 +1246,13 @@ const spinner = ({ indicator = "dots", onCancel, output = process.stdout, cancel
|
|
|
1864
1246
|
let _message = "";
|
|
1865
1247
|
let _prevMessage;
|
|
1866
1248
|
let _origin = performance.now();
|
|
1249
|
+
let _elapsedMs = 0;
|
|
1867
1250
|
const columns = rt(output);
|
|
1868
1251
|
const styleFn = opts?.styleFrame ?? defaultStyleFn;
|
|
1252
|
+
const getElapsedMs = () => {
|
|
1253
|
+
if (!isSpinnerActive) return _elapsedMs;
|
|
1254
|
+
return _elapsedMs + (performance.now() - _origin);
|
|
1255
|
+
};
|
|
1869
1256
|
const handleExit = (code) => {
|
|
1870
1257
|
const msg = code > 1 ? errorMessage ?? _.messages.error : cancelMessage ?? _.messages.cancel;
|
|
1871
1258
|
isCancelled = code === 1;
|
|
@@ -1904,12 +1291,12 @@ const spinner = ({ indicator = "dots", onCancel, output = process.stdout, cancel
|
|
|
1904
1291
|
output.write(import_src.erase.down());
|
|
1905
1292
|
};
|
|
1906
1293
|
const hasGuide = opts.withGuide ?? false;
|
|
1907
|
-
const
|
|
1294
|
+
const startLoop = () => {
|
|
1908
1295
|
isSpinnerActive = true;
|
|
1909
1296
|
unblock = Bt({ output });
|
|
1910
|
-
_message = removeTrailingDots(msg);
|
|
1911
1297
|
_origin = performance.now();
|
|
1912
|
-
|
|
1298
|
+
_prevMessage = void 0;
|
|
1299
|
+
if (hasGuide) output.write(`${color.gray(S_BAR)}\n`);
|
|
1913
1300
|
let frameIndex = 0;
|
|
1914
1301
|
let indicatorTimer = 0;
|
|
1915
1302
|
registerHooks();
|
|
@@ -1920,7 +1307,7 @@ const spinner = ({ indicator = "dots", onCancel, output = process.stdout, cancel
|
|
|
1920
1307
|
const frame = styleFn(frames[frameIndex]);
|
|
1921
1308
|
let outputMessage;
|
|
1922
1309
|
if (isCI$1) outputMessage = `${frame} ${_message}...`;
|
|
1923
|
-
else if (indicator === "timer") outputMessage = `${frame} ${_message} ${formatTimer(
|
|
1310
|
+
else if (indicator === "timer") outputMessage = `${frame} ${_message} ${formatTimer(getElapsedMs())}`;
|
|
1924
1311
|
else {
|
|
1925
1312
|
const loadingDots = ".".repeat(Math.floor(indicatorTimer)).slice(0, 3);
|
|
1926
1313
|
outputMessage = `${frame} ${_message}${loadingDots}`;
|
|
@@ -1934,18 +1321,36 @@ const spinner = ({ indicator = "dots", onCancel, output = process.stdout, cancel
|
|
|
1934
1321
|
indicatorTimer = indicatorTimer < 4 ? indicatorTimer + .125 : 0;
|
|
1935
1322
|
}, delay);
|
|
1936
1323
|
};
|
|
1937
|
-
const
|
|
1324
|
+
const start = (msg = "") => {
|
|
1325
|
+
_elapsedMs = 0;
|
|
1326
|
+
_message = removeTrailingDots(msg);
|
|
1327
|
+
startLoop();
|
|
1328
|
+
};
|
|
1329
|
+
const _stop = (msg = "", code = 0, silent = false, preserveElapsed = false) => {
|
|
1938
1330
|
if (!isSpinnerActive) return;
|
|
1939
1331
|
isSpinnerActive = false;
|
|
1940
1332
|
clearInterval(loop);
|
|
1941
1333
|
clearPrevMessage();
|
|
1942
|
-
const
|
|
1334
|
+
const elapsedMs = getElapsedMs();
|
|
1335
|
+
const step = code === 0 ? completeColor(S_STEP_SUBMIT) : code === 1 ? color.red(S_STEP_CANCEL) : color.red(S_STEP_ERROR);
|
|
1943
1336
|
_message = msg ?? _message;
|
|
1944
|
-
if (!silent) if (indicator === "timer") output.write(`${step} ${_message} ${formatTimer(
|
|
1337
|
+
if (!silent) if (indicator === "timer") output.write(`${step} ${_message} ${formatTimer(elapsedMs)}\n\n`);
|
|
1945
1338
|
else output.write(`${step} ${_message}\n\n`);
|
|
1339
|
+
if (!preserveElapsed) _elapsedMs = 0;
|
|
1340
|
+
_prevMessage = void 0;
|
|
1946
1341
|
clearHooks();
|
|
1947
1342
|
unblock();
|
|
1948
1343
|
};
|
|
1344
|
+
const pause = () => {
|
|
1345
|
+
if (!isSpinnerActive) return;
|
|
1346
|
+
_elapsedMs = getElapsedMs();
|
|
1347
|
+
_stop(_message, 0, true, true);
|
|
1348
|
+
};
|
|
1349
|
+
const resume = (msg = _message) => {
|
|
1350
|
+
if (isSpinnerActive) return;
|
|
1351
|
+
_message = removeTrailingDots(msg);
|
|
1352
|
+
startLoop();
|
|
1353
|
+
};
|
|
1949
1354
|
const stop = (msg = "") => _stop(msg, 0);
|
|
1950
1355
|
const cancel = (msg = "") => _stop(msg, 1);
|
|
1951
1356
|
const error = (msg = "") => _stop(msg, 2);
|
|
@@ -1955,6 +1360,8 @@ const spinner = ({ indicator = "dots", onCancel, output = process.stdout, cancel
|
|
|
1955
1360
|
};
|
|
1956
1361
|
return {
|
|
1957
1362
|
start,
|
|
1363
|
+
pause,
|
|
1364
|
+
resume,
|
|
1958
1365
|
stop,
|
|
1959
1366
|
message,
|
|
1960
1367
|
cancel,
|
|
@@ -1965,51 +1372,7 @@ const spinner = ({ indicator = "dots", onCancel, output = process.stdout, cancel
|
|
|
1965
1372
|
}
|
|
1966
1373
|
};
|
|
1967
1374
|
};
|
|
1968
|
-
|
|
1969
|
-
light: unicodeOr("─", "-"),
|
|
1970
|
-
heavy: unicodeOr("━", "="),
|
|
1971
|
-
block: unicodeOr("█", "#")
|
|
1972
|
-
};
|
|
1973
|
-
function progress({ style = "heavy", max: userMax = 100, size: userSize = 40, ...spinnerOptions } = {}) {
|
|
1974
|
-
const spin = spinner(spinnerOptions);
|
|
1975
|
-
let value = 0;
|
|
1976
|
-
let previousMessage = "";
|
|
1977
|
-
const max = Math.max(1, userMax);
|
|
1978
|
-
const size = Math.max(1, userSize);
|
|
1979
|
-
const activeStyle = (state) => {
|
|
1980
|
-
switch (state) {
|
|
1981
|
-
case "initial":
|
|
1982
|
-
case "active": return colors.magenta;
|
|
1983
|
-
case "error":
|
|
1984
|
-
case "cancel": return colors.red;
|
|
1985
|
-
case "submit": return completeColor;
|
|
1986
|
-
default: return colors.magenta;
|
|
1987
|
-
}
|
|
1988
|
-
};
|
|
1989
|
-
const drawProgress = (state, msg) => {
|
|
1990
|
-
const active = Math.floor(value / max * size);
|
|
1991
|
-
return `${activeStyle(state)(S_PROGRESS_CHAR[style].repeat(active))}${colors.dim(S_PROGRESS_CHAR[style].repeat(size - active))} ${msg}`;
|
|
1992
|
-
};
|
|
1993
|
-
const start = (msg = "") => {
|
|
1994
|
-
previousMessage = msg;
|
|
1995
|
-
spin.start(drawProgress("initial", msg));
|
|
1996
|
-
};
|
|
1997
|
-
const advance = (step = 1, msg) => {
|
|
1998
|
-
value = Math.min(max, step + value);
|
|
1999
|
-
spin.message(drawProgress("active", msg ?? previousMessage));
|
|
2000
|
-
previousMessage = msg ?? previousMessage;
|
|
2001
|
-
};
|
|
2002
|
-
return {
|
|
2003
|
-
start,
|
|
2004
|
-
stop: spin.stop.bind(spin),
|
|
2005
|
-
cancel: spin.cancel.bind(spin),
|
|
2006
|
-
error: spin.error.bind(spin),
|
|
2007
|
-
clear: spin.clear.bind(spin),
|
|
2008
|
-
advance,
|
|
2009
|
-
isCancelled: spin.isCancelled,
|
|
2010
|
-
message: (msg) => advance(0, msg)
|
|
2011
|
-
};
|
|
2012
|
-
}
|
|
1375
|
+
unicodeOr("─", "-"), unicodeOr("━", "="), unicodeOr("█", "#");
|
|
2013
1376
|
const computeLabel = (label, format) => {
|
|
2014
1377
|
if (!label.includes("\n")) return format(label);
|
|
2015
1378
|
return label.split("\n").map((line) => format(line)).join("\n");
|
|
@@ -2018,18 +1381,18 @@ const withMarker = (marker, label, format, firstLineSuffix = "") => {
|
|
|
2018
1381
|
const lines = label.split("\n");
|
|
2019
1382
|
if (lines.length === 1) return `${marker} ${format(lines[0])}${firstLineSuffix}`;
|
|
2020
1383
|
const [firstLine, ...rest] = lines;
|
|
2021
|
-
return [`${marker} ${format(firstLine)}${firstLineSuffix}`, ...rest.map((line) =>
|
|
1384
|
+
return [`${marker} ${format(firstLine)}${firstLineSuffix}`, ...rest.map((line) => ` ${format(line)}`)].join("\n");
|
|
2022
1385
|
};
|
|
2023
1386
|
const select = (opts) => {
|
|
2024
1387
|
const opt = (option, state) => {
|
|
2025
1388
|
const label = option.label ?? String(option.value);
|
|
2026
|
-
const hint = option.hint ? `: ${
|
|
1389
|
+
const hint = option.hint ? `: ${color.gray(option.hint)}` : "";
|
|
2027
1390
|
switch (state) {
|
|
2028
|
-
case "disabled": return withMarker(
|
|
2029
|
-
case "selected": return computeLabel(label,
|
|
2030
|
-
case "active": return withMarker(
|
|
2031
|
-
case "cancelled": return computeLabel(label, (str) =>
|
|
2032
|
-
default: return withMarker(
|
|
1391
|
+
case "disabled": return withMarker(color.gray(" "), label, (text) => color.strikethrough(color.gray(text)), option.hint ? `: ${color.gray(option.hint ?? "disabled")}` : "");
|
|
1392
|
+
case "selected": return computeLabel(label, color.dim);
|
|
1393
|
+
case "active": return withMarker(color.blue(S_POINTER_ACTIVE), label, (text) => color.blue(color.bold(text)), hint);
|
|
1394
|
+
case "cancelled": return computeLabel(label, (str) => color.strikethrough(color.dim(str)));
|
|
1395
|
+
default: return withMarker(color.dim(" "), label, (text) => text, hint);
|
|
2033
1396
|
}
|
|
2034
1397
|
};
|
|
2035
1398
|
return new Wt({
|
|
@@ -2046,19 +1409,19 @@ const select = (opts) => {
|
|
|
2046
1409
|
};
|
|
2047
1410
|
const hasMessage = opts.message.trim().length > 0;
|
|
2048
1411
|
const messageLines = !hasMessage ? "" : hasGuide ? xt(opts.output, opts.message, `${symbolBar(this.state)} `, `${symbol(this.state)} `) : formatMessageLines(opts.message);
|
|
2049
|
-
const title = hasMessage ? `${hasGuide ? `${
|
|
1412
|
+
const title = hasMessage ? `${hasGuide ? `${color.gray(S_BAR)}\n` : ""}${messageLines}\n` : "";
|
|
2050
1413
|
switch (this.state) {
|
|
2051
1414
|
case "submit": {
|
|
2052
|
-
const submitPrefix = hasGuide ? `${
|
|
1415
|
+
const submitPrefix = hasGuide ? `${color.gray(S_BAR)} ` : nestedPrefix;
|
|
2053
1416
|
return `${title}${xt(opts.output, opt(this.options[this.cursor], "selected"), submitPrefix)}\n`;
|
|
2054
1417
|
}
|
|
2055
1418
|
case "cancel": {
|
|
2056
|
-
const cancelPrefix = hasGuide ? `${
|
|
2057
|
-
return `${title}${xt(opts.output, opt(this.options[this.cursor], "cancelled"), cancelPrefix)}${hasGuide ? `\n${
|
|
1419
|
+
const cancelPrefix = hasGuide ? `${color.gray(S_BAR)} ` : nestedPrefix;
|
|
1420
|
+
return `${title}${xt(opts.output, opt(this.options[this.cursor], "cancelled"), cancelPrefix)}${hasGuide ? `\n${color.gray(S_BAR)}` : ""}\n`;
|
|
2058
1421
|
}
|
|
2059
1422
|
default: {
|
|
2060
|
-
const prefix = hasGuide ? `${
|
|
2061
|
-
const prefixEnd = hasGuide ?
|
|
1423
|
+
const prefix = hasGuide ? `${color.blue(S_BAR)} ` : nestedPrefix;
|
|
1424
|
+
const prefixEnd = hasGuide ? color.blue(S_BAR_END) : "";
|
|
2062
1425
|
const titleLineCount = title ? title.split("\n").length : 0;
|
|
2063
1426
|
const footerLineCount = hasGuide ? 2 : 1;
|
|
2064
1427
|
return `${title}${prefix}${limitOptions({
|
|
@@ -2075,50 +1438,6 @@ const select = (opts) => {
|
|
|
2075
1438
|
}
|
|
2076
1439
|
}).prompt();
|
|
2077
1440
|
};
|
|
2078
|
-
const selectKey = (opts) => {
|
|
2079
|
-
const withMarker = (marker, value) => {
|
|
2080
|
-
const lines = value.split("\n");
|
|
2081
|
-
if (lines.length === 1) return `${marker} ${lines[0]}`;
|
|
2082
|
-
const [firstLine, ...rest] = lines;
|
|
2083
|
-
return [`${marker} ${firstLine}`, ...rest.map((line) => `${S_POINTER_INACTIVE} ${line}`)].join("\n");
|
|
2084
|
-
};
|
|
2085
|
-
const opt = (option, state = "inactive") => {
|
|
2086
|
-
const label = option.label ?? String(option.value);
|
|
2087
|
-
if (state === "selected") return colors.dim(label);
|
|
2088
|
-
if (state === "cancelled") return colors.strikethrough(colors.dim(label));
|
|
2089
|
-
if (state === "active") return withMarker(colors.blue(S_POINTER_ACTIVE), `${colors.bgBlue(colors.white(` ${option.value} `))} ${colors.bold(label)}${option.hint ? ` ${colors.dim(`(${option.hint})`)}` : ""}`);
|
|
2090
|
-
return withMarker(colors.dim(S_POINTER_INACTIVE), `${colors.gray(colors.bgWhite(colors.inverse(` ${option.value} `)))} ${colors.dim(label)}${option.hint ? ` ${colors.dim(`(${option.hint})`)}` : ""}`);
|
|
2091
|
-
};
|
|
2092
|
-
return new Tt({
|
|
2093
|
-
options: opts.options,
|
|
2094
|
-
signal: opts.signal,
|
|
2095
|
-
input: opts.input,
|
|
2096
|
-
output: opts.output,
|
|
2097
|
-
initialValue: opts.initialValue,
|
|
2098
|
-
caseSensitive: opts.caseSensitive,
|
|
2099
|
-
render() {
|
|
2100
|
-
const hasGuide = opts.withGuide ?? false;
|
|
2101
|
-
const nestedPrefix = " ";
|
|
2102
|
-
const title = `${hasGuide ? `${colors.gray(S_BAR)}\n` : ""}${symbol(this.state)} ${opts.message}\n`;
|
|
2103
|
-
switch (this.state) {
|
|
2104
|
-
case "submit": {
|
|
2105
|
-
const submitPrefix = hasGuide ? `${colors.gray(S_BAR)} ` : nestedPrefix;
|
|
2106
|
-
const selectedOption = this.options.find((opt) => opt.value === this.value) ?? opts.options[0];
|
|
2107
|
-
return `${title}${xt(opts.output, opt(selectedOption, "selected"), submitPrefix)}\n\n`;
|
|
2108
|
-
}
|
|
2109
|
-
case "cancel": {
|
|
2110
|
-
const cancelPrefix = hasGuide ? `${colors.gray(S_BAR)} ` : nestedPrefix;
|
|
2111
|
-
return `${title}${xt(opts.output, opt(this.options[0], "cancelled"), cancelPrefix)}${hasGuide ? `\n${colors.gray(S_BAR)}` : ""}\n\n`;
|
|
2112
|
-
}
|
|
2113
|
-
default: {
|
|
2114
|
-
const defaultPrefix = hasGuide ? `${colors.blue(S_BAR)} ` : nestedPrefix;
|
|
2115
|
-
const defaultPrefixEnd = hasGuide ? colors.blue(S_BAR_END) : "";
|
|
2116
|
-
return `${title}${this.options.map((option, i) => xt(opts.output, opt(option, i === this.cursor ? "active" : "inactive"), defaultPrefix)).join("\n")}\n${defaultPrefixEnd}\n`;
|
|
2117
|
-
}
|
|
2118
|
-
}
|
|
2119
|
-
}
|
|
2120
|
-
}).prompt();
|
|
2121
|
-
};
|
|
2122
1441
|
const prefix = " ";
|
|
2123
1442
|
const stream = {
|
|
2124
1443
|
message: async (iterable, { symbol = "" } = {}) => {
|
|
@@ -2140,7 +1459,7 @@ const stream = {
|
|
|
2140
1459
|
process.stdout.write("\n");
|
|
2141
1460
|
},
|
|
2142
1461
|
info: (iterable) => {
|
|
2143
|
-
return stream.message(iterable, { symbol:
|
|
1462
|
+
return stream.message(iterable, { symbol: color.blue(S_INFO) });
|
|
2144
1463
|
},
|
|
2145
1464
|
success: (iterable) => {
|
|
2146
1465
|
return stream.message(iterable, { symbol: completeColor(S_SUCCESS) });
|
|
@@ -2149,180 +1468,15 @@ const stream = {
|
|
|
2149
1468
|
return stream.message(iterable, { symbol: completeColor(S_STEP_SUBMIT) });
|
|
2150
1469
|
},
|
|
2151
1470
|
warn: (iterable) => {
|
|
2152
|
-
return stream.message(iterable, { symbol:
|
|
1471
|
+
return stream.message(iterable, { symbol: color.yellow(S_WARN) });
|
|
2153
1472
|
},
|
|
2154
1473
|
warning: (iterable) => {
|
|
2155
1474
|
return stream.warn(iterable);
|
|
2156
1475
|
},
|
|
2157
1476
|
error: (iterable) => {
|
|
2158
|
-
return stream.message(iterable, { symbol:
|
|
2159
|
-
}
|
|
2160
|
-
};
|
|
2161
|
-
/**
|
|
2162
|
-
* Define a group of tasks to be executed
|
|
2163
|
-
*/
|
|
2164
|
-
const tasks = async (tasks, opts) => {
|
|
2165
|
-
for (const task of tasks) {
|
|
2166
|
-
if (task.enabled === false) continue;
|
|
2167
|
-
const s = spinner(opts);
|
|
2168
|
-
s.start(task.title);
|
|
2169
|
-
const result = await task.task(s.message.bind(s));
|
|
2170
|
-
s.stop(result || task.title);
|
|
1477
|
+
return stream.message(iterable, { symbol: color.red(S_ERROR) });
|
|
2171
1478
|
}
|
|
2172
1479
|
};
|
|
2173
|
-
const stripDestructiveANSI = (input) => {
|
|
2174
|
-
return input.replace(/\x1b\[(?:\d+;)*\d*[ABCDEFGHfJKSTsu]|\x1b\[(s|u)/g, "");
|
|
2175
|
-
};
|
|
2176
|
-
/**
|
|
2177
|
-
* Renders a log which clears on success and remains on failure
|
|
2178
|
-
*/
|
|
2179
|
-
const taskLog = (opts) => {
|
|
2180
|
-
const output = opts.output ?? process.stdout;
|
|
2181
|
-
const columns = rt(output);
|
|
2182
|
-
const secondarySymbol = colors.gray(S_BAR);
|
|
2183
|
-
const spacing = opts.spacing ?? 1;
|
|
2184
|
-
const barSize = 3;
|
|
2185
|
-
const retainLog = opts.retainLog === true;
|
|
2186
|
-
const isTTY$1 = !isCI() && isTTY(output);
|
|
2187
|
-
output.write(`${secondarySymbol}\n`);
|
|
2188
|
-
output.write(`${completeColor(S_STEP_SUBMIT)} ${opts.title}\n`);
|
|
2189
|
-
for (let i = 0; i < spacing; i++) output.write(`${secondarySymbol}\n`);
|
|
2190
|
-
const buffers = [{
|
|
2191
|
-
value: "",
|
|
2192
|
-
full: ""
|
|
2193
|
-
}];
|
|
2194
|
-
let lastMessageWasRaw = false;
|
|
2195
|
-
const clear = (clearTitle) => {
|
|
2196
|
-
if (buffers.length === 0) return;
|
|
2197
|
-
let lines = 0;
|
|
2198
|
-
if (clearTitle) lines += spacing + 2;
|
|
2199
|
-
for (const buffer of buffers) {
|
|
2200
|
-
const { value, result } = buffer;
|
|
2201
|
-
let text = result?.message ?? value;
|
|
2202
|
-
if (text.length === 0) continue;
|
|
2203
|
-
if (result === void 0 && buffer.header !== void 0 && buffer.header !== "") text += `\n${buffer.header}`;
|
|
2204
|
-
const bufferHeight = text.split("\n").reduce((count, line) => {
|
|
2205
|
-
if (line === "") return count + 1;
|
|
2206
|
-
return count + Math.ceil((line.length + barSize) / columns);
|
|
2207
|
-
}, 0);
|
|
2208
|
-
lines += bufferHeight;
|
|
2209
|
-
}
|
|
2210
|
-
if (lines > 0) {
|
|
2211
|
-
lines += 1;
|
|
2212
|
-
output.write(import_src.erase.lines(lines));
|
|
2213
|
-
}
|
|
2214
|
-
};
|
|
2215
|
-
const printBuffer = (buffer, messageSpacing, full) => {
|
|
2216
|
-
const messages = full ? `${buffer.full}\n${buffer.value}` : buffer.value;
|
|
2217
|
-
if (buffer.header !== void 0 && buffer.header !== "") log.message(buffer.header.split("\n").map(colors.bold), {
|
|
2218
|
-
output,
|
|
2219
|
-
secondarySymbol,
|
|
2220
|
-
symbol: secondarySymbol,
|
|
2221
|
-
spacing: 0
|
|
2222
|
-
});
|
|
2223
|
-
log.message(messages.split("\n").map(colors.dim), {
|
|
2224
|
-
output,
|
|
2225
|
-
secondarySymbol,
|
|
2226
|
-
symbol: secondarySymbol,
|
|
2227
|
-
spacing: messageSpacing ?? spacing
|
|
2228
|
-
});
|
|
2229
|
-
};
|
|
2230
|
-
const renderBuffer = () => {
|
|
2231
|
-
for (const buffer of buffers) {
|
|
2232
|
-
const { header, value, full } = buffer;
|
|
2233
|
-
if ((header === void 0 || header.length === 0) && value.length === 0) continue;
|
|
2234
|
-
printBuffer(buffer, void 0, retainLog === true && full.length > 0);
|
|
2235
|
-
}
|
|
2236
|
-
};
|
|
2237
|
-
const message = (buffer, msg, mopts) => {
|
|
2238
|
-
clear(false);
|
|
2239
|
-
if ((mopts?.raw !== true || !lastMessageWasRaw) && buffer.value !== "") buffer.value += "\n";
|
|
2240
|
-
buffer.value += stripDestructiveANSI(msg);
|
|
2241
|
-
lastMessageWasRaw = mopts?.raw === true;
|
|
2242
|
-
if (opts.limit !== void 0) {
|
|
2243
|
-
const lines = buffer.value.split("\n");
|
|
2244
|
-
const linesToRemove = lines.length - opts.limit;
|
|
2245
|
-
if (linesToRemove > 0) {
|
|
2246
|
-
const removedLines = lines.splice(0, linesToRemove);
|
|
2247
|
-
if (retainLog) buffer.full += (buffer.full === "" ? "" : "\n") + removedLines.join("\n");
|
|
2248
|
-
}
|
|
2249
|
-
buffer.value = lines.join("\n");
|
|
2250
|
-
}
|
|
2251
|
-
if (isTTY$1) printBuffers();
|
|
2252
|
-
};
|
|
2253
|
-
const printBuffers = () => {
|
|
2254
|
-
for (const buffer of buffers) if (buffer.result) if (buffer.result.status === "error") log.error(buffer.result.message, {
|
|
2255
|
-
output,
|
|
2256
|
-
secondarySymbol,
|
|
2257
|
-
spacing: 0
|
|
2258
|
-
});
|
|
2259
|
-
else log.success(buffer.result.message, {
|
|
2260
|
-
output,
|
|
2261
|
-
secondarySymbol,
|
|
2262
|
-
spacing: 0
|
|
2263
|
-
});
|
|
2264
|
-
else if (buffer.value !== "") printBuffer(buffer, 0);
|
|
2265
|
-
};
|
|
2266
|
-
const completeBuffer = (buffer, result) => {
|
|
2267
|
-
clear(false);
|
|
2268
|
-
buffer.result = result;
|
|
2269
|
-
if (isTTY$1) printBuffers();
|
|
2270
|
-
};
|
|
2271
|
-
return {
|
|
2272
|
-
message(msg, mopts) {
|
|
2273
|
-
message(buffers[0], msg, mopts);
|
|
2274
|
-
},
|
|
2275
|
-
group(name) {
|
|
2276
|
-
const buffer = {
|
|
2277
|
-
header: name,
|
|
2278
|
-
value: "",
|
|
2279
|
-
full: ""
|
|
2280
|
-
};
|
|
2281
|
-
buffers.push(buffer);
|
|
2282
|
-
return {
|
|
2283
|
-
message(msg, mopts) {
|
|
2284
|
-
message(buffer, msg, mopts);
|
|
2285
|
-
},
|
|
2286
|
-
error(message) {
|
|
2287
|
-
completeBuffer(buffer, {
|
|
2288
|
-
status: "error",
|
|
2289
|
-
message
|
|
2290
|
-
});
|
|
2291
|
-
},
|
|
2292
|
-
success(message) {
|
|
2293
|
-
completeBuffer(buffer, {
|
|
2294
|
-
status: "success",
|
|
2295
|
-
message
|
|
2296
|
-
});
|
|
2297
|
-
}
|
|
2298
|
-
};
|
|
2299
|
-
},
|
|
2300
|
-
error(message, opts) {
|
|
2301
|
-
clear(true);
|
|
2302
|
-
log.error(message, {
|
|
2303
|
-
output,
|
|
2304
|
-
secondarySymbol,
|
|
2305
|
-
spacing: 1
|
|
2306
|
-
});
|
|
2307
|
-
if (opts?.showLog !== false) renderBuffer();
|
|
2308
|
-
buffers.splice(1, buffers.length - 1);
|
|
2309
|
-
buffers[0].value = "";
|
|
2310
|
-
buffers[0].full = "";
|
|
2311
|
-
},
|
|
2312
|
-
success(message, opts) {
|
|
2313
|
-
clear(true);
|
|
2314
|
-
log.success(message, {
|
|
2315
|
-
output,
|
|
2316
|
-
secondarySymbol,
|
|
2317
|
-
spacing: 1
|
|
2318
|
-
});
|
|
2319
|
-
if (opts?.showLog === true) renderBuffer();
|
|
2320
|
-
buffers.splice(1, buffers.length - 1);
|
|
2321
|
-
buffers[0].value = "";
|
|
2322
|
-
buffers[0].full = "";
|
|
2323
|
-
}
|
|
2324
|
-
};
|
|
2325
|
-
};
|
|
2326
1480
|
const text = (opts) => {
|
|
2327
1481
|
return new $t({
|
|
2328
1482
|
validate: opts.validate,
|
|
@@ -2335,32 +1489,31 @@ const text = (opts) => {
|
|
|
2335
1489
|
render() {
|
|
2336
1490
|
const hasGuide = opts?.withGuide ?? false;
|
|
2337
1491
|
const nestedPrefix = " ";
|
|
2338
|
-
const title = `${hasGuide ? `${
|
|
2339
|
-
const placeholder = opts.placeholder ?
|
|
1492
|
+
const title = `${hasGuide ? `${color.gray(S_BAR)}\n` : ""}${symbol(this.state)} ${opts.message}\n`;
|
|
1493
|
+
const placeholder = opts.placeholder ? color.inverse(opts.placeholder[0]) + color.dim(opts.placeholder.slice(1)) : color.inverse(color.hidden("_"));
|
|
2340
1494
|
const userInput = !this.userInput ? placeholder : this.userInputWithCursor;
|
|
2341
1495
|
const value = this.value ?? "";
|
|
2342
1496
|
switch (this.state) {
|
|
2343
1497
|
case "error": {
|
|
2344
|
-
const errorText = this.error ? ` ${
|
|
2345
|
-
const errorPrefix = hasGuide ? `${
|
|
2346
|
-
const errorPrefixEnd = hasGuide ?
|
|
1498
|
+
const errorText = this.error ? ` ${color.yellow(this.error)}` : "";
|
|
1499
|
+
const errorPrefix = hasGuide ? `${color.yellow(S_BAR)} ` : nestedPrefix;
|
|
1500
|
+
const errorPrefixEnd = hasGuide ? color.yellow(S_BAR_END) : "";
|
|
2347
1501
|
return `${title.trim()}\n${errorPrefix}${userInput}\n${errorPrefixEnd}${errorText}\n`;
|
|
2348
1502
|
}
|
|
2349
1503
|
case "submit": {
|
|
2350
|
-
const valueText = value ?
|
|
2351
|
-
return `${title}${hasGuide ? `${
|
|
1504
|
+
const valueText = value ? color.dim(value) : "";
|
|
1505
|
+
return `${title}${hasGuide ? `${color.gray(S_BAR)} ` : nestedPrefix}${valueText}\n`;
|
|
2352
1506
|
}
|
|
2353
1507
|
case "cancel": {
|
|
2354
|
-
const valueText = value ?
|
|
2355
|
-
const cancelPrefix = hasGuide ? `${
|
|
2356
|
-
return `${title}${cancelPrefix}${valueText}${value.trim() ? `\n${cancelPrefix}` : ""}\n
|
|
1508
|
+
const valueText = value ? color.strikethrough(color.dim(value)) : "";
|
|
1509
|
+
const cancelPrefix = hasGuide ? `${color.gray(S_BAR)} ` : nestedPrefix;
|
|
1510
|
+
return `${title}${cancelPrefix}${valueText}${value.trim() ? `\n${cancelPrefix}` : ""}\n`;
|
|
2357
1511
|
}
|
|
2358
|
-
default: return `${title}${hasGuide ? `${
|
|
1512
|
+
default: return `${title}${hasGuide ? `${color.blue(S_BAR)} ` : nestedPrefix}${userInput}\n${hasGuide ? color.blue(S_BAR_END) : ""}\n`;
|
|
2359
1513
|
}
|
|
2360
1514
|
}
|
|
2361
1515
|
}).prompt();
|
|
2362
1516
|
};
|
|
2363
|
-
|
|
2364
1517
|
//#endregion
|
|
2365
1518
|
//#region src/types/package.ts
|
|
2366
1519
|
const PackageManager = {
|
|
@@ -2374,15 +1527,41 @@ const DependencyType = {
|
|
|
2374
1527
|
peerDependencies: "peerDependencies",
|
|
2375
1528
|
optionalDependencies: "optionalDependencies"
|
|
2376
1529
|
};
|
|
2377
|
-
|
|
1530
|
+
//#endregion
|
|
1531
|
+
//#region src/utils/command.ts
|
|
1532
|
+
async function runCommandSilently(options) {
|
|
1533
|
+
const child = spawn(options.command, options.args, {
|
|
1534
|
+
stdio: "pipe",
|
|
1535
|
+
cwd: options.cwd,
|
|
1536
|
+
env: options.envs
|
|
1537
|
+
});
|
|
1538
|
+
return await new Promise((resolve, reject) => {
|
|
1539
|
+
const stdout = [];
|
|
1540
|
+
const stderr = [];
|
|
1541
|
+
child.stdout?.on("data", (data) => {
|
|
1542
|
+
stdout.push(data);
|
|
1543
|
+
});
|
|
1544
|
+
child.stderr?.on("data", (data) => {
|
|
1545
|
+
stderr.push(data);
|
|
1546
|
+
});
|
|
1547
|
+
child.on("close", (code) => {
|
|
1548
|
+
resolve({
|
|
1549
|
+
exitCode: code ?? 0,
|
|
1550
|
+
stdout: Buffer.concat(stdout),
|
|
1551
|
+
stderr: Buffer.concat(stderr)
|
|
1552
|
+
});
|
|
1553
|
+
});
|
|
1554
|
+
child.on("error", (err) => {
|
|
1555
|
+
reject(err);
|
|
1556
|
+
});
|
|
1557
|
+
});
|
|
1558
|
+
}
|
|
2378
1559
|
//#endregion
|
|
2379
1560
|
//#region src/utils/path.ts
|
|
2380
1561
|
function findPkgRoot() {
|
|
2381
1562
|
let dir = import.meta.dirname;
|
|
2382
1563
|
while (dir !== path.dirname(dir)) {
|
|
2383
|
-
if (fs.existsSync(path.join(dir, "package.json")))
|
|
2384
|
-
return dir;
|
|
2385
|
-
}
|
|
1564
|
+
if (fs.existsSync(path.join(dir, "package.json"))) return dir;
|
|
2386
1565
|
dir = path.dirname(dir);
|
|
2387
1566
|
}
|
|
2388
1567
|
return dir;
|
|
@@ -2393,7 +1572,200 @@ const rulesDir = path.join(pkgRoot, "rules");
|
|
|
2393
1572
|
function displayRelative(to, from = process.cwd()) {
|
|
2394
1573
|
return path.relative(from, to).replaceAll("\\", "/");
|
|
2395
1574
|
}
|
|
2396
|
-
|
|
1575
|
+
//#endregion
|
|
1576
|
+
//#region src/resolve-fmt.ts
|
|
1577
|
+
/**
|
|
1578
|
+
* Oxfmt tool resolver for the vite-plus CLI.
|
|
1579
|
+
*
|
|
1580
|
+
* This module exports a function that resolves the oxfmt binary path
|
|
1581
|
+
* using Node.js module resolution. The resolved path is passed back
|
|
1582
|
+
* to the Rust core, which then executes oxfmt for code formatting.
|
|
1583
|
+
*
|
|
1584
|
+
* Used for: `vite-plus fmt` command
|
|
1585
|
+
*
|
|
1586
|
+
* Oxfmt is a fast JavaScript/TypeScript formatter written in Rust that
|
|
1587
|
+
* provides high-performance code formatting capabilities.
|
|
1588
|
+
*/
|
|
1589
|
+
/**
|
|
1590
|
+
* Resolves the oxfmt binary path and environment variables.
|
|
1591
|
+
*
|
|
1592
|
+
* @returns Promise containing:
|
|
1593
|
+
* - binPath: Absolute path to the oxfmt binary
|
|
1594
|
+
* - envs: Environment variables to set when executing oxfmt
|
|
1595
|
+
*
|
|
1596
|
+
* The environment variables provide runtime context to oxfmt,
|
|
1597
|
+
* including Node.js version information and package manager details.
|
|
1598
|
+
*/
|
|
1599
|
+
async function fmt() {
|
|
1600
|
+
return {
|
|
1601
|
+
binPath: resolve$1("oxfmt/bin/oxfmt"),
|
|
1602
|
+
envs: { ...DEFAULT_ENVS }
|
|
1603
|
+
};
|
|
1604
|
+
}
|
|
1605
|
+
//#endregion
|
|
1606
|
+
//#region src/utils/prompts.ts
|
|
1607
|
+
function cancelAndExit(message = "Operation cancelled", exitCode = 0) {
|
|
1608
|
+
cancel(message);
|
|
1609
|
+
process.exit(exitCode);
|
|
1610
|
+
}
|
|
1611
|
+
async function selectPackageManager(interactive, silent = false) {
|
|
1612
|
+
if (interactive) {
|
|
1613
|
+
const selected = await select({
|
|
1614
|
+
message: "Which package manager would you like to use?",
|
|
1615
|
+
options: [
|
|
1616
|
+
{
|
|
1617
|
+
value: PackageManager.pnpm,
|
|
1618
|
+
hint: "recommended"
|
|
1619
|
+
},
|
|
1620
|
+
{ value: PackageManager.yarn },
|
|
1621
|
+
{ value: PackageManager.npm }
|
|
1622
|
+
],
|
|
1623
|
+
initialValue: PackageManager.pnpm
|
|
1624
|
+
});
|
|
1625
|
+
if (Ct(selected)) cancelAndExit();
|
|
1626
|
+
return selected;
|
|
1627
|
+
} else {
|
|
1628
|
+
if (!silent) log.info(`Using default package manager: ${accent(PackageManager.pnpm)}`);
|
|
1629
|
+
return PackageManager.pnpm;
|
|
1630
|
+
}
|
|
1631
|
+
}
|
|
1632
|
+
async function downloadPackageManager$1(packageManager, version, interactive, silent = false) {
|
|
1633
|
+
const spinner = silent ? getSilentSpinner() : getSpinner(interactive);
|
|
1634
|
+
spinner.start(`${packageManager}@${version} installing...`);
|
|
1635
|
+
const downloadResult = await downloadPackageManager({
|
|
1636
|
+
name: packageManager,
|
|
1637
|
+
version
|
|
1638
|
+
});
|
|
1639
|
+
spinner.stop(`${packageManager}@${downloadResult.version} installed`);
|
|
1640
|
+
return downloadResult;
|
|
1641
|
+
}
|
|
1642
|
+
async function runViteInstall(cwd, interactive, extraArgs, options) {
|
|
1643
|
+
if (process.env.VITE_PLUS_SKIP_INSTALL) return {
|
|
1644
|
+
durationMs: 0,
|
|
1645
|
+
status: "skipped"
|
|
1646
|
+
};
|
|
1647
|
+
const spinner = options?.silent ? getSilentSpinner() : getSpinner(interactive);
|
|
1648
|
+
const startTime = Date.now();
|
|
1649
|
+
spinner.start(`Installing dependencies...`);
|
|
1650
|
+
const { exitCode, stderr, stdout } = await runCommandSilently({
|
|
1651
|
+
command: process.env.VITE_PLUS_CLI_BIN ?? "vp",
|
|
1652
|
+
args: ["install", ...extraArgs ?? []],
|
|
1653
|
+
cwd,
|
|
1654
|
+
envs: process.env
|
|
1655
|
+
});
|
|
1656
|
+
if (exitCode === 0) {
|
|
1657
|
+
spinner.stop(`Dependencies installed`);
|
|
1658
|
+
return {
|
|
1659
|
+
durationMs: Date.now() - startTime,
|
|
1660
|
+
exitCode,
|
|
1661
|
+
status: "installed"
|
|
1662
|
+
};
|
|
1663
|
+
} else {
|
|
1664
|
+
spinner.stop(`Install failed`);
|
|
1665
|
+
log.info(stdout.toString());
|
|
1666
|
+
log.error(stderr.toString());
|
|
1667
|
+
log.info(`You may need to run "vp install" manually in ${cwd}`);
|
|
1668
|
+
return {
|
|
1669
|
+
durationMs: Date.now() - startTime,
|
|
1670
|
+
exitCode,
|
|
1671
|
+
status: "failed"
|
|
1672
|
+
};
|
|
1673
|
+
}
|
|
1674
|
+
}
|
|
1675
|
+
async function runViteFmt(cwd, interactive, paths, options) {
|
|
1676
|
+
const spinner = options?.silent ? getSilentSpinner() : getSpinner(interactive);
|
|
1677
|
+
const startTime = Date.now();
|
|
1678
|
+
spinner.start(`Formatting code...`);
|
|
1679
|
+
const { binPath, envs } = await fmt();
|
|
1680
|
+
const { exitCode, stderr, stdout } = await runCommandSilently({
|
|
1681
|
+
command: binPath,
|
|
1682
|
+
args: ["--write", ...paths ?? []],
|
|
1683
|
+
cwd,
|
|
1684
|
+
envs: {
|
|
1685
|
+
...process.env,
|
|
1686
|
+
...envs
|
|
1687
|
+
}
|
|
1688
|
+
});
|
|
1689
|
+
if (exitCode === 0) {
|
|
1690
|
+
spinner.stop(`Code formatted`);
|
|
1691
|
+
return {
|
|
1692
|
+
durationMs: Date.now() - startTime,
|
|
1693
|
+
exitCode,
|
|
1694
|
+
status: "formatted"
|
|
1695
|
+
};
|
|
1696
|
+
} else {
|
|
1697
|
+
spinner.stop(`Format failed`);
|
|
1698
|
+
log.info(stdout.toString());
|
|
1699
|
+
log.error(stderr.toString());
|
|
1700
|
+
const relativePaths = (paths ?? []).length > 0 ? ` ${(paths ?? []).join(" ")}` : "";
|
|
1701
|
+
log.info(`You may need to run "vp fmt --write${relativePaths}" manually in ${cwd}`);
|
|
1702
|
+
return {
|
|
1703
|
+
durationMs: Date.now() - startTime,
|
|
1704
|
+
exitCode,
|
|
1705
|
+
status: "failed"
|
|
1706
|
+
};
|
|
1707
|
+
}
|
|
1708
|
+
}
|
|
1709
|
+
async function upgradeYarn(cwd, interactive, silent = false) {
|
|
1710
|
+
const spinner = silent ? getSilentSpinner() : getSpinner(interactive);
|
|
1711
|
+
spinner.start(`Running yarn set version stable...`);
|
|
1712
|
+
const { exitCode, stderr, stdout } = await runCommandSilently({
|
|
1713
|
+
command: "yarn",
|
|
1714
|
+
args: [
|
|
1715
|
+
"set",
|
|
1716
|
+
"version",
|
|
1717
|
+
"stable"
|
|
1718
|
+
],
|
|
1719
|
+
cwd,
|
|
1720
|
+
envs: process.env
|
|
1721
|
+
});
|
|
1722
|
+
if (exitCode === 0) spinner.stop(`Yarn upgraded to stable version`);
|
|
1723
|
+
else {
|
|
1724
|
+
spinner.stop(`yarn upgrade failed`);
|
|
1725
|
+
log.info(stdout.toString());
|
|
1726
|
+
log.error(stderr.toString());
|
|
1727
|
+
}
|
|
1728
|
+
}
|
|
1729
|
+
async function promptGitHooks(options) {
|
|
1730
|
+
if (options.hooks === false) return false;
|
|
1731
|
+
if (options.hooks === true) return true;
|
|
1732
|
+
if (options.interactive) {
|
|
1733
|
+
const selected = await confirm({
|
|
1734
|
+
message: "Set up pre-commit hooks to run formatting, linting, and type checking with auto-fixes?",
|
|
1735
|
+
initialValue: true
|
|
1736
|
+
});
|
|
1737
|
+
if (Ct(selected)) {
|
|
1738
|
+
cancelAndExit();
|
|
1739
|
+
return false;
|
|
1740
|
+
}
|
|
1741
|
+
return selected;
|
|
1742
|
+
}
|
|
1743
|
+
return true;
|
|
1744
|
+
}
|
|
1745
|
+
function defaultInteractive() {
|
|
1746
|
+
return !process.env.CI && process.stdin.isTTY;
|
|
1747
|
+
}
|
|
1748
|
+
function getSpinner(interactive) {
|
|
1749
|
+
if (interactive) return spinner();
|
|
1750
|
+
return {
|
|
1751
|
+
start: (msg) => {
|
|
1752
|
+
if (msg) log.info(msg);
|
|
1753
|
+
},
|
|
1754
|
+
stop: (msg) => {
|
|
1755
|
+
if (msg) log.info(msg);
|
|
1756
|
+
},
|
|
1757
|
+
message: (msg) => {
|
|
1758
|
+
if (msg) log.info(msg);
|
|
1759
|
+
}
|
|
1760
|
+
};
|
|
1761
|
+
}
|
|
1762
|
+
function getSilentSpinner() {
|
|
1763
|
+
return {
|
|
1764
|
+
start: () => {},
|
|
1765
|
+
stop: () => {},
|
|
1766
|
+
message: () => {}
|
|
1767
|
+
};
|
|
1768
|
+
}
|
|
2397
1769
|
//#endregion
|
|
2398
1770
|
//#region src/utils/agent.ts
|
|
2399
1771
|
const DEFAULT_MCP_HINT = "Run `npx vp mcp` — this starts a stdio MCP server. See your agent's docs for how to add a local MCP server.";
|
|
@@ -2582,9 +1954,7 @@ const AGENT_STANDARD_PATH = "AGENTS.md";
|
|
|
2582
1954
|
const AGENT_INSTRUCTIONS_START_MARKER = "<!--VITE PLUS START-->";
|
|
2583
1955
|
const AGENT_INSTRUCTIONS_END_MARKER = "<!--VITE PLUS END-->";
|
|
2584
1956
|
async function selectAgentTargetPaths({ interactive, agent, onCancel }) {
|
|
2585
|
-
if (agent === false)
|
|
2586
|
-
return undefined;
|
|
2587
|
-
}
|
|
1957
|
+
if (agent === false) return;
|
|
2588
1958
|
if (interactive && !agent) {
|
|
2589
1959
|
const selectedAgents = await multiselect({
|
|
2590
1960
|
message: "Which agents are you using?",
|
|
@@ -2598,122 +1968,127 @@ async function selectAgentTargetPaths({ interactive, agent, onCancel }) {
|
|
|
2598
1968
|
});
|
|
2599
1969
|
if (Ct(selectedAgents)) {
|
|
2600
1970
|
onCancel();
|
|
2601
|
-
return
|
|
2602
|
-
}
|
|
2603
|
-
if (selectedAgents.length === 0) {
|
|
2604
|
-
return undefined;
|
|
1971
|
+
return;
|
|
2605
1972
|
}
|
|
1973
|
+
if (selectedAgents.length === 0) return;
|
|
2606
1974
|
return resolveAgentTargetPaths(selectedAgents);
|
|
2607
1975
|
}
|
|
2608
1976
|
return resolveAgentTargetPaths(agent ?? "other");
|
|
2609
1977
|
}
|
|
2610
|
-
async function selectAgentTargetPath({ interactive, agent, onCancel }) {
|
|
2611
|
-
const targetPaths = await selectAgentTargetPaths({
|
|
2612
|
-
interactive,
|
|
2613
|
-
agent,
|
|
2614
|
-
onCancel
|
|
2615
|
-
});
|
|
2616
|
-
return targetPaths?.[0];
|
|
2617
|
-
}
|
|
2618
1978
|
function detectExistingAgentTargetPaths(projectRoot) {
|
|
2619
1979
|
const detectedPaths = [];
|
|
2620
|
-
const seenTargetPaths = new Set();
|
|
1980
|
+
const seenTargetPaths = /* @__PURE__ */ new Set();
|
|
2621
1981
|
for (const option of AGENTS) {
|
|
2622
|
-
if (seenTargetPaths.has(option.targetPath))
|
|
2623
|
-
continue;
|
|
2624
|
-
}
|
|
1982
|
+
if (seenTargetPaths.has(option.targetPath)) continue;
|
|
2625
1983
|
seenTargetPaths.add(option.targetPath);
|
|
2626
1984
|
const targetPath = path.join(projectRoot, option.targetPath);
|
|
2627
|
-
if (fs.existsSync(targetPath) && !fs.lstatSync(targetPath).isSymbolicLink())
|
|
2628
|
-
detectedPaths.push(option.targetPath);
|
|
2629
|
-
}
|
|
1985
|
+
if (fs.existsSync(targetPath) && !fs.lstatSync(targetPath).isSymbolicLink()) detectedPaths.push(option.targetPath);
|
|
2630
1986
|
}
|
|
2631
|
-
return detectedPaths.length > 0 ? detectedPaths :
|
|
2632
|
-
}
|
|
2633
|
-
function detectExistingAgentTargetPath(projectRoot) {
|
|
2634
|
-
return detectExistingAgentTargetPaths(projectRoot)?.[0];
|
|
1987
|
+
return detectedPaths.length > 0 ? detectedPaths : void 0;
|
|
2635
1988
|
}
|
|
2636
1989
|
function resolveAgentTargetPaths(agent) {
|
|
2637
1990
|
const agentNames = parseAgentNames(agent);
|
|
2638
1991
|
const resolvedAgentNames = agentNames.length > 0 ? agentNames : ["other"];
|
|
2639
1992
|
const dedupedTargetPaths = [];
|
|
2640
|
-
const seenTargetPaths = new Set();
|
|
1993
|
+
const seenTargetPaths = /* @__PURE__ */ new Set();
|
|
2641
1994
|
for (const name of resolvedAgentNames) {
|
|
2642
1995
|
const targetPath = resolveSingleAgentTargetPath(name);
|
|
2643
|
-
if (seenTargetPaths.has(targetPath))
|
|
2644
|
-
continue;
|
|
2645
|
-
}
|
|
1996
|
+
if (seenTargetPaths.has(targetPath)) continue;
|
|
2646
1997
|
seenTargetPaths.add(targetPath);
|
|
2647
1998
|
dedupedTargetPaths.push(targetPath);
|
|
2648
1999
|
}
|
|
2649
2000
|
return dedupedTargetPaths;
|
|
2650
2001
|
}
|
|
2651
|
-
function resolveAgentTargetPath(agent) {
|
|
2652
|
-
return resolveAgentTargetPaths(agent)[0] ?? "AGENTS.md";
|
|
2653
|
-
}
|
|
2654
2002
|
function parseAgentNames(agent) {
|
|
2655
|
-
if (!agent)
|
|
2656
|
-
|
|
2657
|
-
}
|
|
2658
|
-
const values = Array.isArray(agent) ? agent : [agent];
|
|
2659
|
-
return values.filter((value) => typeof value === "string").flatMap((value) => value.split(",")).map((value) => value.trim()).filter((value) => value.length > 0);
|
|
2003
|
+
if (!agent) return [];
|
|
2004
|
+
return (Array.isArray(agent) ? agent : [agent]).filter((value) => typeof value === "string").flatMap((value) => value.split(",")).map((value) => value.trim()).filter((value) => value.length > 0);
|
|
2660
2005
|
}
|
|
2661
2006
|
function resolveSingleAgentTargetPath(agent) {
|
|
2662
2007
|
const normalized = normalizeAgentName(agent);
|
|
2663
2008
|
const alias = AGENT_ALIASES[normalized];
|
|
2664
2009
|
const resolved = alias ? normalizeAgentName(alias) : normalized;
|
|
2665
|
-
|
|
2666
|
-
return match?.targetPath ?? AGENTS[AGENTS.length - 1].targetPath;
|
|
2010
|
+
return AGENTS.find((option) => normalizeAgentName(option.id) === resolved || normalizeAgentName(option.label) === resolved)?.targetPath ?? AGENTS[AGENTS.length - 1].targetPath;
|
|
2667
2011
|
}
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2012
|
+
/**
|
|
2013
|
+
* Detect agent instruction files that would conflict (exist without markers).
|
|
2014
|
+
* Returns only files that need a user decision (append or skip).
|
|
2015
|
+
* Read-only — does not write or modify any files.
|
|
2016
|
+
*/
|
|
2017
|
+
async function detectAgentConflicts({ projectRoot, targetPaths }) {
|
|
2018
|
+
if (!targetPaths || targetPaths.length === 0) return [];
|
|
2019
|
+
const sourcePath = path.join(pkgRoot, "AGENTS.md");
|
|
2020
|
+
if (!fs.existsSync(sourcePath)) return [];
|
|
2021
|
+
const incomingContent = await fsPromises.readFile(sourcePath, "utf-8");
|
|
2022
|
+
const shouldLinkToAgents = targetPaths.includes(AGENT_STANDARD_PATH);
|
|
2023
|
+
const orderedPaths = shouldLinkToAgents ? [AGENT_STANDARD_PATH, ...targetPaths.filter((p) => p !== AGENT_STANDARD_PATH)] : targetPaths;
|
|
2024
|
+
const conflicts = [];
|
|
2025
|
+
const seenDestinationPaths = /* @__PURE__ */ new Set();
|
|
2026
|
+
const seenRealPaths = /* @__PURE__ */ new Set();
|
|
2027
|
+
for (const targetPathToCheck of orderedPaths) {
|
|
2028
|
+
const destinationPath = path.join(projectRoot, targetPathToCheck);
|
|
2029
|
+
const destinationKey = path.resolve(destinationPath);
|
|
2030
|
+
if (seenDestinationPaths.has(destinationKey)) continue;
|
|
2031
|
+
seenDestinationPaths.add(destinationKey);
|
|
2032
|
+
if (shouldLinkToAgents && targetPathToCheck !== AGENT_STANDARD_PATH) {
|
|
2033
|
+
if (await getExistingPathKind(destinationPath) !== "file") continue;
|
|
2034
|
+
}
|
|
2035
|
+
if (fs.existsSync(destinationPath)) {
|
|
2036
|
+
if (fs.lstatSync(destinationPath).isSymbolicLink()) continue;
|
|
2037
|
+
const destinationRealPath = await fsPromises.realpath(destinationPath);
|
|
2038
|
+
if (seenRealPaths.has(destinationRealPath)) continue;
|
|
2039
|
+
if (replaceMarkedAgentInstructionsSection(await fsPromises.readFile(destinationPath, "utf-8"), incomingContent) !== void 0) {
|
|
2040
|
+
seenRealPaths.add(destinationRealPath);
|
|
2041
|
+
continue;
|
|
2042
|
+
}
|
|
2043
|
+
conflicts.push({ targetPath: targetPathToCheck });
|
|
2044
|
+
seenRealPaths.add(destinationRealPath);
|
|
2045
|
+
}
|
|
2672
2046
|
}
|
|
2047
|
+
return conflicts;
|
|
2048
|
+
}
|
|
2049
|
+
async function writeAgentInstructions({ projectRoot, targetPath, targetPaths, interactive, conflictDecisions, silent = false }) {
|
|
2050
|
+
const paths = [...targetPaths ?? [], ...targetPath ? [targetPath] : []];
|
|
2051
|
+
if (paths.length === 0) return;
|
|
2673
2052
|
const sourcePath = path.join(pkgRoot, "AGENTS.md");
|
|
2674
2053
|
if (!fs.existsSync(sourcePath)) {
|
|
2675
|
-
log.warn("Agent instructions template not found; skipping.");
|
|
2054
|
+
if (!silent) log.warn("Agent instructions template not found; skipping.");
|
|
2676
2055
|
return;
|
|
2677
2056
|
}
|
|
2678
|
-
const seenDestinationPaths = new Set();
|
|
2679
|
-
const seenRealPaths = new Set();
|
|
2057
|
+
const seenDestinationPaths = /* @__PURE__ */ new Set();
|
|
2058
|
+
const seenRealPaths = /* @__PURE__ */ new Set();
|
|
2680
2059
|
const incomingContent = await fsPromises.readFile(sourcePath, "utf-8");
|
|
2681
2060
|
const shouldLinkToAgents = paths.includes(AGENT_STANDARD_PATH);
|
|
2682
2061
|
const orderedPaths = shouldLinkToAgents ? [AGENT_STANDARD_PATH, ...paths.filter((p) => p !== AGENT_STANDARD_PATH)] : paths;
|
|
2683
2062
|
for (const targetPathToWrite of orderedPaths) {
|
|
2684
2063
|
const destinationPath = path.join(projectRoot, targetPathToWrite);
|
|
2685
2064
|
const destinationKey = path.resolve(destinationPath);
|
|
2686
|
-
if (seenDestinationPaths.has(destinationKey))
|
|
2687
|
-
continue;
|
|
2688
|
-
}
|
|
2065
|
+
if (seenDestinationPaths.has(destinationKey)) continue;
|
|
2689
2066
|
seenDestinationPaths.add(destinationKey);
|
|
2690
2067
|
await fsPromises.mkdir(path.dirname(destinationPath), { recursive: true });
|
|
2691
2068
|
if (shouldLinkToAgents && targetPathToWrite !== AGENT_STANDARD_PATH) {
|
|
2692
|
-
|
|
2693
|
-
if (linked) {
|
|
2694
|
-
continue;
|
|
2695
|
-
}
|
|
2069
|
+
if (await tryLinkTargetToAgents(projectRoot, targetPathToWrite, silent)) continue;
|
|
2696
2070
|
}
|
|
2697
2071
|
if (fs.existsSync(destinationPath)) {
|
|
2698
2072
|
if (fs.lstatSync(destinationPath).isSymbolicLink()) {
|
|
2699
|
-
log.info(`Skipped writing ${targetPathToWrite} (symlink)`);
|
|
2073
|
+
if (!silent) log.info(`Skipped writing ${targetPathToWrite} (symlink)`);
|
|
2700
2074
|
continue;
|
|
2701
2075
|
}
|
|
2702
2076
|
const destinationRealPath = await fsPromises.realpath(destinationPath);
|
|
2703
2077
|
if (seenRealPaths.has(destinationRealPath)) {
|
|
2704
|
-
log.info(`Skipped writing ${targetPathToWrite} (duplicate target)`);
|
|
2078
|
+
if (!silent) log.info(`Skipped writing ${targetPathToWrite} (duplicate target)`);
|
|
2705
2079
|
continue;
|
|
2706
2080
|
}
|
|
2707
2081
|
const existingContent = await fsPromises.readFile(destinationPath, "utf-8");
|
|
2708
2082
|
const updatedContent = replaceMarkedAgentInstructionsSection(existingContent, incomingContent);
|
|
2709
|
-
if (updatedContent !==
|
|
2710
|
-
if (updatedContent !== existingContent)
|
|
2711
|
-
await fsPromises.writeFile(destinationPath, updatedContent);
|
|
2712
|
-
}
|
|
2083
|
+
if (updatedContent !== void 0) {
|
|
2084
|
+
if (updatedContent !== existingContent) await fsPromises.writeFile(destinationPath, updatedContent);
|
|
2713
2085
|
seenRealPaths.add(destinationRealPath);
|
|
2714
2086
|
continue;
|
|
2715
2087
|
}
|
|
2716
|
-
|
|
2088
|
+
let conflictAction;
|
|
2089
|
+
const preResolved = conflictDecisions?.get(targetPathToWrite);
|
|
2090
|
+
if (preResolved) conflictAction = preResolved;
|
|
2091
|
+
else if (interactive) {
|
|
2717
2092
|
const action = await select({
|
|
2718
2093
|
message: `Agent instructions already exist at ${targetPathToWrite}.`,
|
|
2719
2094
|
options: [{
|
|
@@ -2727,317 +2102,67 @@ async function writeAgentInstructions({ projectRoot, targetPath, targetPaths, in
|
|
|
2727
2102
|
}],
|
|
2728
2103
|
initialValue: "skip"
|
|
2729
2104
|
});
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
await fsPromises.appendFile(destinationPath, `${separator}\n${incomingContent}`);
|
|
2737
|
-
log.success(`Appended agent instructions to ${targetPathToWrite}`);
|
|
2738
|
-
seenRealPaths.add(destinationRealPath);
|
|
2739
|
-
continue;
|
|
2105
|
+
conflictAction = Ct(action) || action === "skip" ? "skip" : "append";
|
|
2106
|
+
} else conflictAction = "skip";
|
|
2107
|
+
if (conflictAction === "append") await appendAgentContent(destinationPath, targetPathToWrite, existingContent, incomingContent, silent);
|
|
2108
|
+
else {
|
|
2109
|
+
const suffix = !preResolved && !interactive ? " (already exists)" : "";
|
|
2110
|
+
if (!silent) log.info(`Skipped writing ${targetPathToWrite}${suffix}`);
|
|
2740
2111
|
}
|
|
2741
|
-
log.info(`Skipped writing ${targetPathToWrite} (already exists)`);
|
|
2742
2112
|
seenRealPaths.add(destinationRealPath);
|
|
2743
2113
|
continue;
|
|
2744
2114
|
}
|
|
2745
2115
|
await fsPromises.writeFile(destinationPath, incomingContent);
|
|
2746
|
-
log.success(`Wrote agent instructions to ${targetPathToWrite}`);
|
|
2116
|
+
if (!silent) log.success(`Wrote agent instructions to ${targetPathToWrite}`);
|
|
2747
2117
|
seenRealPaths.add(await fsPromises.realpath(destinationPath));
|
|
2748
2118
|
}
|
|
2749
2119
|
}
|
|
2120
|
+
async function appendAgentContent(destinationPath, targetPath, existingContent, incomingContent, silent = false) {
|
|
2121
|
+
const separator = existingContent.endsWith("\n") ? "" : "\n";
|
|
2122
|
+
await fsPromises.appendFile(destinationPath, `${separator}\n${incomingContent}`);
|
|
2123
|
+
if (!silent) log.success(`Appended agent instructions to ${targetPath}`);
|
|
2124
|
+
}
|
|
2750
2125
|
function normalizeAgentName(value) {
|
|
2751
2126
|
return value.trim().toLowerCase().replace(/[^a-z0-9]+/g, "");
|
|
2752
2127
|
}
|
|
2753
2128
|
function replaceMarkedAgentInstructionsSection(existing, incoming) {
|
|
2754
2129
|
const existingRange = getMarkedRange(existing, AGENT_INSTRUCTIONS_START_MARKER, AGENT_INSTRUCTIONS_END_MARKER);
|
|
2755
|
-
if (!existingRange)
|
|
2756
|
-
return undefined;
|
|
2757
|
-
}
|
|
2130
|
+
if (!existingRange) return;
|
|
2758
2131
|
const incomingRange = getMarkedRange(incoming, AGENT_INSTRUCTIONS_START_MARKER, AGENT_INSTRUCTIONS_END_MARKER);
|
|
2759
|
-
if (!incomingRange)
|
|
2760
|
-
return undefined;
|
|
2761
|
-
}
|
|
2132
|
+
if (!incomingRange) return;
|
|
2762
2133
|
return `${existing.slice(0, existingRange.start)}${incoming.slice(incomingRange.start, incomingRange.end)}${existing.slice(existingRange.end)}`;
|
|
2763
2134
|
}
|
|
2764
|
-
async function tryLinkTargetToAgents(projectRoot, targetPath) {
|
|
2135
|
+
async function tryLinkTargetToAgents(projectRoot, targetPath, silent = false) {
|
|
2765
2136
|
const destinationPath = path.join(projectRoot, targetPath);
|
|
2766
2137
|
const agentsPath = path.join(projectRoot, AGENT_STANDARD_PATH);
|
|
2767
2138
|
const symlinkTarget = path.relative(path.dirname(destinationPath), agentsPath);
|
|
2768
2139
|
const existing = await getExistingPathKind(destinationPath);
|
|
2769
|
-
if (existing === "file")
|
|
2770
|
-
return false;
|
|
2771
|
-
}
|
|
2140
|
+
if (existing === "file") return false;
|
|
2772
2141
|
if (existing === "symlink") {
|
|
2773
2142
|
const currentLink = await fsPromises.readlink(destinationPath);
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
log.info(`Skipped linking ${targetPath} (already linked to ${AGENT_STANDARD_PATH})`);
|
|
2143
|
+
if (path.resolve(path.dirname(destinationPath), currentLink) === agentsPath) {
|
|
2144
|
+
if (!silent) log.info(`Skipped linking ${targetPath} (already linked to ${AGENT_STANDARD_PATH})`);
|
|
2777
2145
|
return true;
|
|
2778
2146
|
}
|
|
2779
2147
|
await fsPromises.unlink(destinationPath);
|
|
2780
2148
|
}
|
|
2781
2149
|
await fsPromises.symlink(symlinkTarget, destinationPath);
|
|
2782
|
-
log.success(`Linked ${targetPath} to ${AGENT_STANDARD_PATH}`);
|
|
2150
|
+
if (!silent) log.success(`Linked ${targetPath} to ${AGENT_STANDARD_PATH}`);
|
|
2783
2151
|
return true;
|
|
2784
2152
|
}
|
|
2785
2153
|
async function getExistingPathKind(filePath) {
|
|
2786
|
-
if (!fs.existsSync(filePath))
|
|
2787
|
-
|
|
2788
|
-
}
|
|
2789
|
-
const stat = await fsPromises.lstat(filePath);
|
|
2790
|
-
return stat.isSymbolicLink() ? "symlink" : "file";
|
|
2154
|
+
if (!fs.existsSync(filePath)) return "missing";
|
|
2155
|
+
return (await fsPromises.lstat(filePath)).isSymbolicLink() ? "symlink" : "file";
|
|
2791
2156
|
}
|
|
2792
2157
|
function getMarkedRange(content, startMarker, endMarker) {
|
|
2793
2158
|
const start = content.indexOf(startMarker);
|
|
2794
|
-
if (start === -1)
|
|
2795
|
-
return undefined;
|
|
2796
|
-
}
|
|
2159
|
+
if (start === -1) return;
|
|
2797
2160
|
const endMarkerIndex = content.indexOf(endMarker, start + startMarker.length);
|
|
2798
|
-
if (endMarkerIndex === -1)
|
|
2799
|
-
return undefined;
|
|
2800
|
-
}
|
|
2161
|
+
if (endMarkerIndex === -1) return;
|
|
2801
2162
|
return {
|
|
2802
2163
|
start,
|
|
2803
2164
|
end: endMarkerIndex + endMarker.length
|
|
2804
2165
|
};
|
|
2805
2166
|
}
|
|
2806
|
-
|
|
2807
|
-
//#endregion
|
|
2808
|
-
//#region src/resolve-fmt.ts
|
|
2809
|
-
/**
|
|
2810
|
-
* Oxfmt tool resolver for the vite-plus CLI.
|
|
2811
|
-
*
|
|
2812
|
-
* This module exports a function that resolves the oxfmt binary path
|
|
2813
|
-
* using Node.js module resolution. The resolved path is passed back
|
|
2814
|
-
* to the Rust core, which then executes oxfmt for code formatting.
|
|
2815
|
-
*
|
|
2816
|
-
* Used for: `vite-plus fmt` command
|
|
2817
|
-
*
|
|
2818
|
-
* Oxfmt is a fast JavaScript/TypeScript formatter written in Rust that
|
|
2819
|
-
* provides high-performance code formatting capabilities.
|
|
2820
|
-
*/
|
|
2821
|
-
/**
|
|
2822
|
-
* Resolves the oxfmt binary path and environment variables.
|
|
2823
|
-
*
|
|
2824
|
-
* @returns Promise containing:
|
|
2825
|
-
* - binPath: Absolute path to the oxfmt binary
|
|
2826
|
-
* - envs: Environment variables to set when executing oxfmt
|
|
2827
|
-
*
|
|
2828
|
-
* The environment variables provide runtime context to oxfmt,
|
|
2829
|
-
* including Node.js version information and package manager details.
|
|
2830
|
-
*/
|
|
2831
|
-
async function fmt() {
|
|
2832
|
-
const binPath = resolve("oxfmt/bin/oxfmt");
|
|
2833
|
-
return {
|
|
2834
|
-
binPath,
|
|
2835
|
-
envs: { ...DEFAULT_ENVS }
|
|
2836
|
-
};
|
|
2837
|
-
}
|
|
2838
|
-
|
|
2839
|
-
//#endregion
|
|
2840
|
-
//#region src/utils/command.ts
|
|
2841
|
-
async function runCommandSilently(options) {
|
|
2842
|
-
const child = spawn(options.command, options.args, {
|
|
2843
|
-
stdio: "pipe",
|
|
2844
|
-
cwd: options.cwd,
|
|
2845
|
-
env: options.envs
|
|
2846
|
-
});
|
|
2847
|
-
const promise = new Promise((resolve, reject) => {
|
|
2848
|
-
const stdout = [];
|
|
2849
|
-
const stderr = [];
|
|
2850
|
-
child.stdout?.on("data", (data) => {
|
|
2851
|
-
stdout.push(data);
|
|
2852
|
-
});
|
|
2853
|
-
child.stderr?.on("data", (data) => {
|
|
2854
|
-
stderr.push(data);
|
|
2855
|
-
});
|
|
2856
|
-
child.on("close", (code) => {
|
|
2857
|
-
resolve({
|
|
2858
|
-
exitCode: code ?? 0,
|
|
2859
|
-
stdout: Buffer.concat(stdout),
|
|
2860
|
-
stderr: Buffer.concat(stderr)
|
|
2861
|
-
});
|
|
2862
|
-
});
|
|
2863
|
-
child.on("error", (err) => {
|
|
2864
|
-
reject(err);
|
|
2865
|
-
});
|
|
2866
|
-
});
|
|
2867
|
-
return await promise;
|
|
2868
|
-
}
|
|
2869
|
-
async function runCommand$1(options) {
|
|
2870
|
-
const child = spawn(options.command, options.args, {
|
|
2871
|
-
stdio: "inherit",
|
|
2872
|
-
cwd: options.cwd,
|
|
2873
|
-
env: options.envs
|
|
2874
|
-
});
|
|
2875
|
-
return new Promise((resolve, reject) => {
|
|
2876
|
-
child.on("close", (code) => {
|
|
2877
|
-
resolve(code ?? 0);
|
|
2878
|
-
});
|
|
2879
|
-
child.on("error", (err) => {
|
|
2880
|
-
reject(err);
|
|
2881
|
-
});
|
|
2882
|
-
});
|
|
2883
|
-
}
|
|
2884
|
-
|
|
2885
|
-
//#endregion
|
|
2886
|
-
//#region src/utils/prompts.ts
|
|
2887
|
-
function cancelAndExit(message = "Operation cancelled", exitCode = 0) {
|
|
2888
|
-
cancel(message);
|
|
2889
|
-
process.exit(exitCode);
|
|
2890
|
-
}
|
|
2891
|
-
async function selectPackageManager(interactive) {
|
|
2892
|
-
if (interactive) {
|
|
2893
|
-
const selected = await select({
|
|
2894
|
-
message: "Which package manager would you like to use?",
|
|
2895
|
-
options: [
|
|
2896
|
-
{
|
|
2897
|
-
value: PackageManager.pnpm,
|
|
2898
|
-
hint: "recommended"
|
|
2899
|
-
},
|
|
2900
|
-
{ value: PackageManager.yarn },
|
|
2901
|
-
{ value: PackageManager.npm }
|
|
2902
|
-
],
|
|
2903
|
-
initialValue: PackageManager.pnpm
|
|
2904
|
-
});
|
|
2905
|
-
if (Ct(selected)) {
|
|
2906
|
-
cancelAndExit();
|
|
2907
|
-
}
|
|
2908
|
-
return selected;
|
|
2909
|
-
} else {
|
|
2910
|
-
log.info(`Using default package manager: ${accent(PackageManager.pnpm)}`);
|
|
2911
|
-
return PackageManager.pnpm;
|
|
2912
|
-
}
|
|
2913
|
-
}
|
|
2914
|
-
async function downloadPackageManager$1(packageManager, version, interactive, silent = false) {
|
|
2915
|
-
const spinner = silent ? getSilentSpinner() : getSpinner(interactive);
|
|
2916
|
-
spinner.start(`${packageManager}@${version} installing...`);
|
|
2917
|
-
const downloadResult = await downloadPackageManager({
|
|
2918
|
-
name: packageManager,
|
|
2919
|
-
version
|
|
2920
|
-
});
|
|
2921
|
-
spinner.stop(`${packageManager}@${downloadResult.version} installed`);
|
|
2922
|
-
return downloadResult;
|
|
2923
|
-
}
|
|
2924
|
-
async function runViteInstall(cwd, interactive, extraArgs) {
|
|
2925
|
-
if (process.env.CI) {
|
|
2926
|
-
return;
|
|
2927
|
-
}
|
|
2928
|
-
const spinner = getSpinner(interactive);
|
|
2929
|
-
spinner.start(`Installing dependencies...`);
|
|
2930
|
-
const { exitCode, stderr, stdout } = await runCommandSilently({
|
|
2931
|
-
command: process.env.VITE_PLUS_CLI_BIN ?? "vp",
|
|
2932
|
-
args: ["install", ...extraArgs ?? []],
|
|
2933
|
-
cwd,
|
|
2934
|
-
envs: process.env
|
|
2935
|
-
});
|
|
2936
|
-
if (exitCode === 0) {
|
|
2937
|
-
spinner.stop(`Dependencies installed`);
|
|
2938
|
-
} else {
|
|
2939
|
-
spinner.stop(`Install failed`);
|
|
2940
|
-
log.info(stdout.toString());
|
|
2941
|
-
log.error(stderr.toString());
|
|
2942
|
-
log.info(`You may need to run "vp install" manually in ${cwd}`);
|
|
2943
|
-
}
|
|
2944
|
-
}
|
|
2945
|
-
async function runViteFmt(cwd, interactive, paths) {
|
|
2946
|
-
const spinner = getSpinner(interactive);
|
|
2947
|
-
spinner.start(`Formatting code...`);
|
|
2948
|
-
const { binPath, envs } = await fmt();
|
|
2949
|
-
const { exitCode, stderr, stdout } = await runCommandSilently({
|
|
2950
|
-
command: binPath,
|
|
2951
|
-
args: ["--write", ...paths ?? []],
|
|
2952
|
-
cwd,
|
|
2953
|
-
envs: {
|
|
2954
|
-
...process.env,
|
|
2955
|
-
...envs
|
|
2956
|
-
}
|
|
2957
|
-
});
|
|
2958
|
-
if (exitCode === 0) {
|
|
2959
|
-
spinner.stop(`Code formatted`);
|
|
2960
|
-
} else {
|
|
2961
|
-
spinner.stop(`Format failed`);
|
|
2962
|
-
log.info(stdout.toString());
|
|
2963
|
-
log.error(stderr.toString());
|
|
2964
|
-
const relativePaths = (paths ?? []).length > 0 ? ` ${(paths ?? []).join(" ")}` : "";
|
|
2965
|
-
log.info(`You may need to run "vp fmt --write${relativePaths}" manually in ${cwd}`);
|
|
2966
|
-
}
|
|
2967
|
-
}
|
|
2968
|
-
async function upgradeYarn(cwd, interactive) {
|
|
2969
|
-
const spinner = getSpinner(interactive);
|
|
2970
|
-
spinner.start(`Running yarn set version stable...`);
|
|
2971
|
-
const { exitCode, stderr, stdout } = await runCommandSilently({
|
|
2972
|
-
command: "yarn",
|
|
2973
|
-
args: [
|
|
2974
|
-
"set",
|
|
2975
|
-
"version",
|
|
2976
|
-
"stable"
|
|
2977
|
-
],
|
|
2978
|
-
cwd,
|
|
2979
|
-
envs: process.env
|
|
2980
|
-
});
|
|
2981
|
-
if (exitCode === 0) {
|
|
2982
|
-
spinner.stop(`Yarn upgraded to stable version`);
|
|
2983
|
-
} else {
|
|
2984
|
-
spinner.stop(`yarn upgrade failed`);
|
|
2985
|
-
log.info(stdout.toString());
|
|
2986
|
-
log.error(stderr.toString());
|
|
2987
|
-
}
|
|
2988
|
-
}
|
|
2989
|
-
async function promptGitHooks(options) {
|
|
2990
|
-
if (options.hooks === false) {
|
|
2991
|
-
return false;
|
|
2992
|
-
}
|
|
2993
|
-
if (options.hooks === true) {
|
|
2994
|
-
return true;
|
|
2995
|
-
}
|
|
2996
|
-
if (options.interactive) {
|
|
2997
|
-
const selected = await confirm({
|
|
2998
|
-
message: "Set up pre-commit hooks to run formatting, linting, and type checking with auto-fixes?",
|
|
2999
|
-
initialValue: true
|
|
3000
|
-
});
|
|
3001
|
-
if (Ct(selected)) {
|
|
3002
|
-
cancelAndExit();
|
|
3003
|
-
return false;
|
|
3004
|
-
}
|
|
3005
|
-
return selected;
|
|
3006
|
-
}
|
|
3007
|
-
return true;
|
|
3008
|
-
}
|
|
3009
|
-
function defaultInteractive() {
|
|
3010
|
-
return !process.env.CI && process.stdin.isTTY;
|
|
3011
|
-
}
|
|
3012
|
-
function getSpinner(interactive) {
|
|
3013
|
-
if (interactive) {
|
|
3014
|
-
return spinner();
|
|
3015
|
-
}
|
|
3016
|
-
return {
|
|
3017
|
-
start: (msg) => {
|
|
3018
|
-
if (msg) {
|
|
3019
|
-
log.info(msg);
|
|
3020
|
-
}
|
|
3021
|
-
},
|
|
3022
|
-
stop: (msg) => {
|
|
3023
|
-
if (msg) {
|
|
3024
|
-
log.info(msg);
|
|
3025
|
-
}
|
|
3026
|
-
},
|
|
3027
|
-
message: (msg) => {
|
|
3028
|
-
if (msg) {
|
|
3029
|
-
log.info(msg);
|
|
3030
|
-
}
|
|
3031
|
-
}
|
|
3032
|
-
};
|
|
3033
|
-
}
|
|
3034
|
-
function getSilentSpinner() {
|
|
3035
|
-
return {
|
|
3036
|
-
start: () => {},
|
|
3037
|
-
stop: () => {},
|
|
3038
|
-
message: () => {}
|
|
3039
|
-
};
|
|
3040
|
-
}
|
|
3041
|
-
|
|
3042
2167
|
//#endregion
|
|
3043
|
-
export {
|
|
2168
|
+
export { select as A, cancel as C, multiselect as D, log as E, text as M, Ct as N, note as O, PackageManager as S, intro as T, pkgRoot as _, selectAgentTargetPaths as a, runCommandSilently as b, defaultInteractive as c, promptGitHooks as d, runViteFmt as f, displayRelative as g, upgradeYarn as h, getAgentById as i, spinner as j, outro as k, downloadPackageManager$1 as l, selectPackageManager as m, detectAgents as n, writeAgentInstructions as o, runViteInstall as p, detectExistingAgentTargetPaths as r, cancelAndExit as s, detectAgentConflicts as t, getSpinner as u, rulesDir as v, confirm as w, DependencyType as x, templatesDir as y };
|