vite-plus 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/binding/index.cjs +2 -0
- package/binding/index.d.cts +32 -0
- package/dist/global/{prompts-CAIahN1u.js → agent-BE4Xze8Q.js} +380 -1280
- 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 +353 -496
- 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 +223 -83
- 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 +654 -1521
- 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-lRm8huz4.js} +1625 -2816
- 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 +32 -3
- package/dist/utils/prompts.js +32 -8
- package/dist/utils/tsconfig.d.ts +6 -0
- package/dist/utils/tsconfig.js +16 -0
- package/package.json +13 -13
- 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 } 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
6
|
import colors 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,21 +544,6 @@ 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;
|
|
@@ -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,33 +574,27 @@ 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("▲", "!");
|
|
@@ -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";
|
|
@@ -1463,125 +1019,12 @@ const confirm = (opts) => {
|
|
|
1463
1019
|
const title = `${hasGuide ? `${colors.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 ? `${colors.gray(S_BAR)} ` : nestedPrefix}${colors.dim(value)}\n
|
|
1467
|
-
case "cancel": return `${title}${hasGuide ? `${colors.gray(S_BAR)} ` : nestedPrefix}${colors.strikethrough(colors.dim(value))}${hasGuide ? `\n${colors.gray(S_BAR)}` : ""}\n
|
|
1022
|
+
case "submit": return `${title}${hasGuide ? `${colors.gray(S_BAR)} ` : nestedPrefix}${colors.dim(value)}\n`;
|
|
1023
|
+
case "cancel": return `${title}${hasGuide ? `${colors.gray(S_BAR)} ` : nestedPrefix}${colors.strikethrough(colors.dim(value))}${hasGuide ? `\n${colors.gray(S_BAR)}` : ""}\n`;
|
|
1468
1024
|
default: {
|
|
1469
1025
|
const defaultPrefix = hasGuide ? `${colors.blue(S_BAR)} ` : nestedPrefix;
|
|
1470
1026
|
const defaultPrefixEnd = hasGuide ? colors.blue(S_BAR_END) : "";
|
|
1471
|
-
return `${title}${defaultPrefix}${this.value ? `${colors.blue(S_POINTER_ACTIVE)} ${colors.bold(active)}` : `${colors.dim(
|
|
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
|
-
}
|
|
1571
|
-
default: {
|
|
1572
|
-
const optionsText = this.options.map((option, i, options) => {
|
|
1573
|
-
const selected = value.includes(option.value) || option.group === true && this.isGroupSelected(String(option.value));
|
|
1574
|
-
const active = i === this.cursor;
|
|
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`;
|
|
1027
|
+
return `${title}${defaultPrefix}${this.value ? `${colors.blue(S_POINTER_ACTIVE)} ${colors.bold(active)}` : `${colors.dim(" ")} ${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(" ")} ${colors.dim(inactive)}`}\n${defaultPrefixEnd}\n`;
|
|
1585
1028
|
}
|
|
1586
1029
|
}
|
|
1587
1030
|
}
|
|
@@ -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");
|
|
@@ -1662,13 +1105,13 @@ const multiselect = (opts) => {
|
|
|
1662
1105
|
const opt = (option, state) => {
|
|
1663
1106
|
const label = option.label ?? String(option.value);
|
|
1664
1107
|
const hint = option.hint ? ` ${colors.gray(`(${option.hint})`)}` : "";
|
|
1665
|
-
if (state === "disabled") return withMarkerAndCheckbox(colors.gray(
|
|
1108
|
+
if (state === "disabled") return withMarkerAndCheckbox(colors.gray(" "), colors.gray(S_CHECKBOX_INACTIVE), S_CHECKBOX_INACTIVE.length, label, (str) => colors.strikethrough(colors.gray(str)), option.hint ? ` ${colors.dim(`(${option.hint ?? "disabled"})`)}` : "");
|
|
1666
1109
|
if (state === "active") return withMarkerAndCheckbox(colors.blue(S_POINTER_ACTIVE), colors.blue(S_CHECKBOX_ACTIVE), S_CHECKBOX_ACTIVE.length, label, (text) => colors.blue(colors.bold(text)), hint);
|
|
1667
|
-
if (state === "selected") return withMarkerAndCheckbox(colors.dim(
|
|
1110
|
+
if (state === "selected") return withMarkerAndCheckbox(colors.dim(" "), colors.blue(S_CHECKBOX_SELECTED), S_CHECKBOX_SELECTED.length, label, colors.dim, hint);
|
|
1668
1111
|
if (state === "cancelled") return computeLabel$1(label, (text) => colors.strikethrough(colors.dim(text)));
|
|
1669
1112
|
if (state === "active-selected") return withMarkerAndCheckbox(colors.blue(S_POINTER_ACTIVE), colors.blue(S_CHECKBOX_SELECTED), S_CHECKBOX_SELECTED.length, label, (text) => colors.blue(colors.bold(text)), hint);
|
|
1670
1113
|
if (state === "submitted") return computeLabel$1(label, colors.dim);
|
|
1671
|
-
return withMarkerAndCheckbox(colors.dim(
|
|
1114
|
+
return withMarkerAndCheckbox(colors.dim(" "), colors.dim(S_CHECKBOX_INACTIVE), S_CHECKBOX_INACTIVE.length, label, colors.dim);
|
|
1672
1115
|
};
|
|
1673
1116
|
const required = opts.required ?? true;
|
|
1674
1117
|
return new Lt({
|
|
@@ -1702,14 +1145,14 @@ const multiselect = (opts) => {
|
|
|
1702
1145
|
case "submit": {
|
|
1703
1146
|
const submitText = this.options.filter(({ value: optionValue }) => value.includes(optionValue)).map((option) => opt(option, "submitted")).join(colors.dim(", ")) || colors.dim("none");
|
|
1704
1147
|
const submitPrefix = hasGuide ? `${colors.gray(S_BAR)} ` : nestedPrefix;
|
|
1705
|
-
return `${title}${xt(opts.output, submitText, submitPrefix)}\n
|
|
1148
|
+
return `${title}${xt(opts.output, submitText, submitPrefix)}\n`;
|
|
1706
1149
|
}
|
|
1707
1150
|
case "cancel": {
|
|
1708
1151
|
const label = this.options.filter(({ value: optionValue }) => value.includes(optionValue)).map((option) => opt(option, "cancelled")).join(colors.dim(", "));
|
|
1709
|
-
if (label.trim() === "") return hasGuide ? `${title}${colors.gray(S_BAR)}\n
|
|
1152
|
+
if (label.trim() === "") return hasGuide ? `${title}${colors.gray(S_BAR)}\n` : `${title.trimEnd()}\n`;
|
|
1710
1153
|
const cancelPrefix = hasGuide ? `${colors.gray(S_BAR)} ` : nestedPrefix;
|
|
1711
1154
|
const wrappedLabel = xt(opts.output, label, cancelPrefix);
|
|
1712
|
-
return hasGuide ? `${title}${wrappedLabel}\n${colors.gray(S_BAR)}\n
|
|
1155
|
+
return hasGuide ? `${title}${wrappedLabel}\n${colors.gray(S_BAR)}\n` : `${title}${wrappedLabel}\n`;
|
|
1713
1156
|
}
|
|
1714
1157
|
case "error": {
|
|
1715
1158
|
const prefix = hasGuide ? `${colors.yellow(S_BAR)} ` : nestedPrefix;
|
|
@@ -1774,67 +1217,6 @@ const note = (message = "", title = "", opts) => {
|
|
|
1774
1217
|
const bottomLeft = hasGuide ? S_CONNECT_LEFT : S_CORNER_BOTTOM_LEFT;
|
|
1775
1218
|
output.write(`${leadingBorder}${completeColor(S_STEP_SUBMIT)} ${colors.reset(title)} ${colors.gray(S_BAR_H.repeat(Math.max(len - titleLen - 1, 1)) + S_CORNER_TOP_RIGHT)}\n${msg}\n${colors.gray(bottomLeft + S_BAR_H.repeat(len + 2) + S_CORNER_BOTTOM_RIGHT)}\n`);
|
|
1776
1219
|
};
|
|
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
|
-
});
|
|
1837
|
-
};
|
|
1838
1220
|
const defaultStyleFn = colors.magenta;
|
|
1839
1221
|
const removeTrailingDots = (msg) => {
|
|
1840
1222
|
return msg.replace(/\.+$/, "");
|
|
@@ -1965,51 +1347,7 @@ const spinner = ({ indicator = "dots", onCancel, output = process.stdout, cancel
|
|
|
1965
1347
|
}
|
|
1966
1348
|
};
|
|
1967
1349
|
};
|
|
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
|
-
}
|
|
1350
|
+
unicodeOr("─", "-"), unicodeOr("━", "="), unicodeOr("█", "#");
|
|
2013
1351
|
const computeLabel = (label, format) => {
|
|
2014
1352
|
if (!label.includes("\n")) return format(label);
|
|
2015
1353
|
return label.split("\n").map((line) => format(line)).join("\n");
|
|
@@ -2018,18 +1356,18 @@ const withMarker = (marker, label, format, firstLineSuffix = "") => {
|
|
|
2018
1356
|
const lines = label.split("\n");
|
|
2019
1357
|
if (lines.length === 1) return `${marker} ${format(lines[0])}${firstLineSuffix}`;
|
|
2020
1358
|
const [firstLine, ...rest] = lines;
|
|
2021
|
-
return [`${marker} ${format(firstLine)}${firstLineSuffix}`, ...rest.map((line) =>
|
|
1359
|
+
return [`${marker} ${format(firstLine)}${firstLineSuffix}`, ...rest.map((line) => ` ${format(line)}`)].join("\n");
|
|
2022
1360
|
};
|
|
2023
1361
|
const select = (opts) => {
|
|
2024
1362
|
const opt = (option, state) => {
|
|
2025
1363
|
const label = option.label ?? String(option.value);
|
|
2026
1364
|
const hint = option.hint ? `: ${colors.gray(option.hint)}` : "";
|
|
2027
1365
|
switch (state) {
|
|
2028
|
-
case "disabled": return withMarker(colors.gray(
|
|
1366
|
+
case "disabled": return withMarker(colors.gray(" "), label, (text) => colors.strikethrough(colors.gray(text)), option.hint ? `: ${colors.gray(option.hint ?? "disabled")}` : "");
|
|
2029
1367
|
case "selected": return computeLabel(label, colors.dim);
|
|
2030
1368
|
case "active": return withMarker(colors.blue(S_POINTER_ACTIVE), label, (text) => colors.blue(colors.bold(text)), hint);
|
|
2031
1369
|
case "cancelled": return computeLabel(label, (str) => colors.strikethrough(colors.dim(str)));
|
|
2032
|
-
default: return withMarker(colors.dim(
|
|
1370
|
+
default: return withMarker(colors.dim(" "), label, (text) => text, hint);
|
|
2033
1371
|
}
|
|
2034
1372
|
};
|
|
2035
1373
|
return new Wt({
|
|
@@ -2075,50 +1413,6 @@ const select = (opts) => {
|
|
|
2075
1413
|
}
|
|
2076
1414
|
}).prompt();
|
|
2077
1415
|
};
|
|
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
1416
|
const prefix = " ";
|
|
2123
1417
|
const stream = {
|
|
2124
1418
|
message: async (iterable, { symbol = "" } = {}) => {
|
|
@@ -2158,171 +1452,6 @@ const stream = {
|
|
|
2158
1452
|
return stream.message(iterable, { symbol: colors.red(S_ERROR) });
|
|
2159
1453
|
}
|
|
2160
1454
|
};
|
|
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);
|
|
2171
|
-
}
|
|
2172
|
-
};
|
|
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
1455
|
const text = (opts) => {
|
|
2327
1456
|
return new $t({
|
|
2328
1457
|
validate: opts.validate,
|
|
@@ -2348,19 +1477,18 @@ const text = (opts) => {
|
|
|
2348
1477
|
}
|
|
2349
1478
|
case "submit": {
|
|
2350
1479
|
const valueText = value ? colors.dim(value) : "";
|
|
2351
|
-
return `${title}${hasGuide ? `${colors.gray(S_BAR)} ` : nestedPrefix}${valueText}\n
|
|
1480
|
+
return `${title}${hasGuide ? `${colors.gray(S_BAR)} ` : nestedPrefix}${valueText}\n`;
|
|
2352
1481
|
}
|
|
2353
1482
|
case "cancel": {
|
|
2354
1483
|
const valueText = value ? colors.strikethrough(colors.dim(value)) : "";
|
|
2355
1484
|
const cancelPrefix = hasGuide ? `${colors.gray(S_BAR)} ` : nestedPrefix;
|
|
2356
|
-
return `${title}${cancelPrefix}${valueText}${value.trim() ? `\n${cancelPrefix}` : ""}\n
|
|
1485
|
+
return `${title}${cancelPrefix}${valueText}${value.trim() ? `\n${cancelPrefix}` : ""}\n`;
|
|
2357
1486
|
}
|
|
2358
1487
|
default: return `${title}${hasGuide ? `${colors.blue(S_BAR)} ` : nestedPrefix}${userInput}\n${hasGuide ? colors.blue(S_BAR_END) : ""}\n`;
|
|
2359
1488
|
}
|
|
2360
1489
|
}
|
|
2361
1490
|
}).prompt();
|
|
2362
1491
|
};
|
|
2363
|
-
|
|
2364
1492
|
//#endregion
|
|
2365
1493
|
//#region src/types/package.ts
|
|
2366
1494
|
const PackageManager = {
|
|
@@ -2374,15 +1502,41 @@ const DependencyType = {
|
|
|
2374
1502
|
peerDependencies: "peerDependencies",
|
|
2375
1503
|
optionalDependencies: "optionalDependencies"
|
|
2376
1504
|
};
|
|
2377
|
-
|
|
1505
|
+
//#endregion
|
|
1506
|
+
//#region src/utils/command.ts
|
|
1507
|
+
async function runCommandSilently(options) {
|
|
1508
|
+
const child = spawn(options.command, options.args, {
|
|
1509
|
+
stdio: "pipe",
|
|
1510
|
+
cwd: options.cwd,
|
|
1511
|
+
env: options.envs
|
|
1512
|
+
});
|
|
1513
|
+
return await new Promise((resolve, reject) => {
|
|
1514
|
+
const stdout = [];
|
|
1515
|
+
const stderr = [];
|
|
1516
|
+
child.stdout?.on("data", (data) => {
|
|
1517
|
+
stdout.push(data);
|
|
1518
|
+
});
|
|
1519
|
+
child.stderr?.on("data", (data) => {
|
|
1520
|
+
stderr.push(data);
|
|
1521
|
+
});
|
|
1522
|
+
child.on("close", (code) => {
|
|
1523
|
+
resolve({
|
|
1524
|
+
exitCode: code ?? 0,
|
|
1525
|
+
stdout: Buffer.concat(stdout),
|
|
1526
|
+
stderr: Buffer.concat(stderr)
|
|
1527
|
+
});
|
|
1528
|
+
});
|
|
1529
|
+
child.on("error", (err) => {
|
|
1530
|
+
reject(err);
|
|
1531
|
+
});
|
|
1532
|
+
});
|
|
1533
|
+
}
|
|
2378
1534
|
//#endregion
|
|
2379
1535
|
//#region src/utils/path.ts
|
|
2380
1536
|
function findPkgRoot() {
|
|
2381
1537
|
let dir = import.meta.dirname;
|
|
2382
1538
|
while (dir !== path.dirname(dir)) {
|
|
2383
|
-
if (fs.existsSync(path.join(dir, "package.json")))
|
|
2384
|
-
return dir;
|
|
2385
|
-
}
|
|
1539
|
+
if (fs.existsSync(path.join(dir, "package.json"))) return dir;
|
|
2386
1540
|
dir = path.dirname(dir);
|
|
2387
1541
|
}
|
|
2388
1542
|
return dir;
|
|
@@ -2393,7 +1547,200 @@ const rulesDir = path.join(pkgRoot, "rules");
|
|
|
2393
1547
|
function displayRelative(to, from = process.cwd()) {
|
|
2394
1548
|
return path.relative(from, to).replaceAll("\\", "/");
|
|
2395
1549
|
}
|
|
2396
|
-
|
|
1550
|
+
//#endregion
|
|
1551
|
+
//#region src/resolve-fmt.ts
|
|
1552
|
+
/**
|
|
1553
|
+
* Oxfmt tool resolver for the vite-plus CLI.
|
|
1554
|
+
*
|
|
1555
|
+
* This module exports a function that resolves the oxfmt binary path
|
|
1556
|
+
* using Node.js module resolution. The resolved path is passed back
|
|
1557
|
+
* to the Rust core, which then executes oxfmt for code formatting.
|
|
1558
|
+
*
|
|
1559
|
+
* Used for: `vite-plus fmt` command
|
|
1560
|
+
*
|
|
1561
|
+
* Oxfmt is a fast JavaScript/TypeScript formatter written in Rust that
|
|
1562
|
+
* provides high-performance code formatting capabilities.
|
|
1563
|
+
*/
|
|
1564
|
+
/**
|
|
1565
|
+
* Resolves the oxfmt binary path and environment variables.
|
|
1566
|
+
*
|
|
1567
|
+
* @returns Promise containing:
|
|
1568
|
+
* - binPath: Absolute path to the oxfmt binary
|
|
1569
|
+
* - envs: Environment variables to set when executing oxfmt
|
|
1570
|
+
*
|
|
1571
|
+
* The environment variables provide runtime context to oxfmt,
|
|
1572
|
+
* including Node.js version information and package manager details.
|
|
1573
|
+
*/
|
|
1574
|
+
async function fmt() {
|
|
1575
|
+
return {
|
|
1576
|
+
binPath: resolve("oxfmt/bin/oxfmt"),
|
|
1577
|
+
envs: { ...DEFAULT_ENVS }
|
|
1578
|
+
};
|
|
1579
|
+
}
|
|
1580
|
+
//#endregion
|
|
1581
|
+
//#region src/utils/prompts.ts
|
|
1582
|
+
function cancelAndExit(message = "Operation cancelled", exitCode = 0) {
|
|
1583
|
+
cancel(message);
|
|
1584
|
+
process.exit(exitCode);
|
|
1585
|
+
}
|
|
1586
|
+
async function selectPackageManager(interactive, silent = false) {
|
|
1587
|
+
if (interactive) {
|
|
1588
|
+
const selected = await select({
|
|
1589
|
+
message: "Which package manager would you like to use?",
|
|
1590
|
+
options: [
|
|
1591
|
+
{
|
|
1592
|
+
value: PackageManager.pnpm,
|
|
1593
|
+
hint: "recommended"
|
|
1594
|
+
},
|
|
1595
|
+
{ value: PackageManager.yarn },
|
|
1596
|
+
{ value: PackageManager.npm }
|
|
1597
|
+
],
|
|
1598
|
+
initialValue: PackageManager.pnpm
|
|
1599
|
+
});
|
|
1600
|
+
if (Ct(selected)) cancelAndExit();
|
|
1601
|
+
return selected;
|
|
1602
|
+
} else {
|
|
1603
|
+
if (!silent) log.info(`Using default package manager: ${accent(PackageManager.pnpm)}`);
|
|
1604
|
+
return PackageManager.pnpm;
|
|
1605
|
+
}
|
|
1606
|
+
}
|
|
1607
|
+
async function downloadPackageManager$1(packageManager, version, interactive, silent = false) {
|
|
1608
|
+
const spinner = silent ? getSilentSpinner() : getSpinner(interactive);
|
|
1609
|
+
spinner.start(`${packageManager}@${version} installing...`);
|
|
1610
|
+
const downloadResult = await downloadPackageManager({
|
|
1611
|
+
name: packageManager,
|
|
1612
|
+
version
|
|
1613
|
+
});
|
|
1614
|
+
spinner.stop(`${packageManager}@${downloadResult.version} installed`);
|
|
1615
|
+
return downloadResult;
|
|
1616
|
+
}
|
|
1617
|
+
async function runViteInstall(cwd, interactive, extraArgs, options) {
|
|
1618
|
+
if (process.env.VITE_PLUS_SKIP_INSTALL) return {
|
|
1619
|
+
durationMs: 0,
|
|
1620
|
+
status: "skipped"
|
|
1621
|
+
};
|
|
1622
|
+
const spinner = options?.silent ? getSilentSpinner() : getSpinner(interactive);
|
|
1623
|
+
const startTime = Date.now();
|
|
1624
|
+
spinner.start(`Installing dependencies...`);
|
|
1625
|
+
const { exitCode, stderr, stdout } = await runCommandSilently({
|
|
1626
|
+
command: process.env.VITE_PLUS_CLI_BIN ?? "vp",
|
|
1627
|
+
args: ["install", ...extraArgs ?? []],
|
|
1628
|
+
cwd,
|
|
1629
|
+
envs: process.env
|
|
1630
|
+
});
|
|
1631
|
+
if (exitCode === 0) {
|
|
1632
|
+
spinner.stop(`Dependencies installed`);
|
|
1633
|
+
return {
|
|
1634
|
+
durationMs: Date.now() - startTime,
|
|
1635
|
+
exitCode,
|
|
1636
|
+
status: "installed"
|
|
1637
|
+
};
|
|
1638
|
+
} else {
|
|
1639
|
+
spinner.stop(`Install failed`);
|
|
1640
|
+
log.info(stdout.toString());
|
|
1641
|
+
log.error(stderr.toString());
|
|
1642
|
+
log.info(`You may need to run "vp install" manually in ${cwd}`);
|
|
1643
|
+
return {
|
|
1644
|
+
durationMs: Date.now() - startTime,
|
|
1645
|
+
exitCode,
|
|
1646
|
+
status: "failed"
|
|
1647
|
+
};
|
|
1648
|
+
}
|
|
1649
|
+
}
|
|
1650
|
+
async function runViteFmt(cwd, interactive, paths, options) {
|
|
1651
|
+
const spinner = options?.silent ? getSilentSpinner() : getSpinner(interactive);
|
|
1652
|
+
const startTime = Date.now();
|
|
1653
|
+
spinner.start(`Formatting code...`);
|
|
1654
|
+
const { binPath, envs } = await fmt();
|
|
1655
|
+
const { exitCode, stderr, stdout } = await runCommandSilently({
|
|
1656
|
+
command: binPath,
|
|
1657
|
+
args: ["--write", ...paths ?? []],
|
|
1658
|
+
cwd,
|
|
1659
|
+
envs: {
|
|
1660
|
+
...process.env,
|
|
1661
|
+
...envs
|
|
1662
|
+
}
|
|
1663
|
+
});
|
|
1664
|
+
if (exitCode === 0) {
|
|
1665
|
+
spinner.stop(`Code formatted`);
|
|
1666
|
+
return {
|
|
1667
|
+
durationMs: Date.now() - startTime,
|
|
1668
|
+
exitCode,
|
|
1669
|
+
status: "formatted"
|
|
1670
|
+
};
|
|
1671
|
+
} else {
|
|
1672
|
+
spinner.stop(`Format failed`);
|
|
1673
|
+
log.info(stdout.toString());
|
|
1674
|
+
log.error(stderr.toString());
|
|
1675
|
+
const relativePaths = (paths ?? []).length > 0 ? ` ${(paths ?? []).join(" ")}` : "";
|
|
1676
|
+
log.info(`You may need to run "vp fmt --write${relativePaths}" manually in ${cwd}`);
|
|
1677
|
+
return {
|
|
1678
|
+
durationMs: Date.now() - startTime,
|
|
1679
|
+
exitCode,
|
|
1680
|
+
status: "failed"
|
|
1681
|
+
};
|
|
1682
|
+
}
|
|
1683
|
+
}
|
|
1684
|
+
async function upgradeYarn(cwd, interactive) {
|
|
1685
|
+
const spinner = getSpinner(interactive);
|
|
1686
|
+
spinner.start(`Running yarn set version stable...`);
|
|
1687
|
+
const { exitCode, stderr, stdout } = await runCommandSilently({
|
|
1688
|
+
command: "yarn",
|
|
1689
|
+
args: [
|
|
1690
|
+
"set",
|
|
1691
|
+
"version",
|
|
1692
|
+
"stable"
|
|
1693
|
+
],
|
|
1694
|
+
cwd,
|
|
1695
|
+
envs: process.env
|
|
1696
|
+
});
|
|
1697
|
+
if (exitCode === 0) spinner.stop(`Yarn upgraded to stable version`);
|
|
1698
|
+
else {
|
|
1699
|
+
spinner.stop(`yarn upgrade failed`);
|
|
1700
|
+
log.info(stdout.toString());
|
|
1701
|
+
log.error(stderr.toString());
|
|
1702
|
+
}
|
|
1703
|
+
}
|
|
1704
|
+
async function promptGitHooks(options) {
|
|
1705
|
+
if (options.hooks === false) return false;
|
|
1706
|
+
if (options.hooks === true) return true;
|
|
1707
|
+
if (options.interactive) {
|
|
1708
|
+
const selected = await confirm({
|
|
1709
|
+
message: "Set up pre-commit hooks to run formatting, linting, and type checking with auto-fixes?",
|
|
1710
|
+
initialValue: true
|
|
1711
|
+
});
|
|
1712
|
+
if (Ct(selected)) {
|
|
1713
|
+
cancelAndExit();
|
|
1714
|
+
return false;
|
|
1715
|
+
}
|
|
1716
|
+
return selected;
|
|
1717
|
+
}
|
|
1718
|
+
return true;
|
|
1719
|
+
}
|
|
1720
|
+
function defaultInteractive() {
|
|
1721
|
+
return !process.env.CI && process.stdin.isTTY;
|
|
1722
|
+
}
|
|
1723
|
+
function getSpinner(interactive) {
|
|
1724
|
+
if (interactive) return spinner();
|
|
1725
|
+
return {
|
|
1726
|
+
start: (msg) => {
|
|
1727
|
+
if (msg) log.info(msg);
|
|
1728
|
+
},
|
|
1729
|
+
stop: (msg) => {
|
|
1730
|
+
if (msg) log.info(msg);
|
|
1731
|
+
},
|
|
1732
|
+
message: (msg) => {
|
|
1733
|
+
if (msg) log.info(msg);
|
|
1734
|
+
}
|
|
1735
|
+
};
|
|
1736
|
+
}
|
|
1737
|
+
function getSilentSpinner() {
|
|
1738
|
+
return {
|
|
1739
|
+
start: () => {},
|
|
1740
|
+
stop: () => {},
|
|
1741
|
+
message: () => {}
|
|
1742
|
+
};
|
|
1743
|
+
}
|
|
2397
1744
|
//#endregion
|
|
2398
1745
|
//#region src/utils/agent.ts
|
|
2399
1746
|
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 +1929,7 @@ const AGENT_STANDARD_PATH = "AGENTS.md";
|
|
|
2582
1929
|
const AGENT_INSTRUCTIONS_START_MARKER = "<!--VITE PLUS START-->";
|
|
2583
1930
|
const AGENT_INSTRUCTIONS_END_MARKER = "<!--VITE PLUS END-->";
|
|
2584
1931
|
async function selectAgentTargetPaths({ interactive, agent, onCancel }) {
|
|
2585
|
-
if (agent === false)
|
|
2586
|
-
return undefined;
|
|
2587
|
-
}
|
|
1932
|
+
if (agent === false) return;
|
|
2588
1933
|
if (interactive && !agent) {
|
|
2589
1934
|
const selectedAgents = await multiselect({
|
|
2590
1935
|
message: "Which agents are you using?",
|
|
@@ -2598,122 +1943,127 @@ async function selectAgentTargetPaths({ interactive, agent, onCancel }) {
|
|
|
2598
1943
|
});
|
|
2599
1944
|
if (Ct(selectedAgents)) {
|
|
2600
1945
|
onCancel();
|
|
2601
|
-
return
|
|
2602
|
-
}
|
|
2603
|
-
if (selectedAgents.length === 0) {
|
|
2604
|
-
return undefined;
|
|
1946
|
+
return;
|
|
2605
1947
|
}
|
|
1948
|
+
if (selectedAgents.length === 0) return;
|
|
2606
1949
|
return resolveAgentTargetPaths(selectedAgents);
|
|
2607
1950
|
}
|
|
2608
1951
|
return resolveAgentTargetPaths(agent ?? "other");
|
|
2609
1952
|
}
|
|
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
1953
|
function detectExistingAgentTargetPaths(projectRoot) {
|
|
2619
1954
|
const detectedPaths = [];
|
|
2620
|
-
const seenTargetPaths = new Set();
|
|
1955
|
+
const seenTargetPaths = /* @__PURE__ */ new Set();
|
|
2621
1956
|
for (const option of AGENTS) {
|
|
2622
|
-
if (seenTargetPaths.has(option.targetPath))
|
|
2623
|
-
continue;
|
|
2624
|
-
}
|
|
1957
|
+
if (seenTargetPaths.has(option.targetPath)) continue;
|
|
2625
1958
|
seenTargetPaths.add(option.targetPath);
|
|
2626
1959
|
const targetPath = path.join(projectRoot, option.targetPath);
|
|
2627
|
-
if (fs.existsSync(targetPath) && !fs.lstatSync(targetPath).isSymbolicLink())
|
|
2628
|
-
detectedPaths.push(option.targetPath);
|
|
2629
|
-
}
|
|
1960
|
+
if (fs.existsSync(targetPath) && !fs.lstatSync(targetPath).isSymbolicLink()) detectedPaths.push(option.targetPath);
|
|
2630
1961
|
}
|
|
2631
|
-
return detectedPaths.length > 0 ? detectedPaths :
|
|
2632
|
-
}
|
|
2633
|
-
function detectExistingAgentTargetPath(projectRoot) {
|
|
2634
|
-
return detectExistingAgentTargetPaths(projectRoot)?.[0];
|
|
1962
|
+
return detectedPaths.length > 0 ? detectedPaths : void 0;
|
|
2635
1963
|
}
|
|
2636
1964
|
function resolveAgentTargetPaths(agent) {
|
|
2637
1965
|
const agentNames = parseAgentNames(agent);
|
|
2638
1966
|
const resolvedAgentNames = agentNames.length > 0 ? agentNames : ["other"];
|
|
2639
1967
|
const dedupedTargetPaths = [];
|
|
2640
|
-
const seenTargetPaths = new Set();
|
|
1968
|
+
const seenTargetPaths = /* @__PURE__ */ new Set();
|
|
2641
1969
|
for (const name of resolvedAgentNames) {
|
|
2642
1970
|
const targetPath = resolveSingleAgentTargetPath(name);
|
|
2643
|
-
if (seenTargetPaths.has(targetPath))
|
|
2644
|
-
continue;
|
|
2645
|
-
}
|
|
1971
|
+
if (seenTargetPaths.has(targetPath)) continue;
|
|
2646
1972
|
seenTargetPaths.add(targetPath);
|
|
2647
1973
|
dedupedTargetPaths.push(targetPath);
|
|
2648
1974
|
}
|
|
2649
1975
|
return dedupedTargetPaths;
|
|
2650
1976
|
}
|
|
2651
|
-
function resolveAgentTargetPath(agent) {
|
|
2652
|
-
return resolveAgentTargetPaths(agent)[0] ?? "AGENTS.md";
|
|
2653
|
-
}
|
|
2654
1977
|
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);
|
|
1978
|
+
if (!agent) return [];
|
|
1979
|
+
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
1980
|
}
|
|
2661
1981
|
function resolveSingleAgentTargetPath(agent) {
|
|
2662
1982
|
const normalized = normalizeAgentName(agent);
|
|
2663
1983
|
const alias = AGENT_ALIASES[normalized];
|
|
2664
1984
|
const resolved = alias ? normalizeAgentName(alias) : normalized;
|
|
2665
|
-
|
|
2666
|
-
return match?.targetPath ?? AGENTS[AGENTS.length - 1].targetPath;
|
|
1985
|
+
return AGENTS.find((option) => normalizeAgentName(option.id) === resolved || normalizeAgentName(option.label) === resolved)?.targetPath ?? AGENTS[AGENTS.length - 1].targetPath;
|
|
2667
1986
|
}
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
1987
|
+
/**
|
|
1988
|
+
* Detect agent instruction files that would conflict (exist without markers).
|
|
1989
|
+
* Returns only files that need a user decision (append or skip).
|
|
1990
|
+
* Read-only — does not write or modify any files.
|
|
1991
|
+
*/
|
|
1992
|
+
async function detectAgentConflicts({ projectRoot, targetPaths }) {
|
|
1993
|
+
if (!targetPaths || targetPaths.length === 0) return [];
|
|
1994
|
+
const sourcePath = path.join(pkgRoot, "AGENTS.md");
|
|
1995
|
+
if (!fs.existsSync(sourcePath)) return [];
|
|
1996
|
+
const incomingContent = await fsPromises.readFile(sourcePath, "utf-8");
|
|
1997
|
+
const shouldLinkToAgents = targetPaths.includes(AGENT_STANDARD_PATH);
|
|
1998
|
+
const orderedPaths = shouldLinkToAgents ? [AGENT_STANDARD_PATH, ...targetPaths.filter((p) => p !== AGENT_STANDARD_PATH)] : targetPaths;
|
|
1999
|
+
const conflicts = [];
|
|
2000
|
+
const seenDestinationPaths = /* @__PURE__ */ new Set();
|
|
2001
|
+
const seenRealPaths = /* @__PURE__ */ new Set();
|
|
2002
|
+
for (const targetPathToCheck of orderedPaths) {
|
|
2003
|
+
const destinationPath = path.join(projectRoot, targetPathToCheck);
|
|
2004
|
+
const destinationKey = path.resolve(destinationPath);
|
|
2005
|
+
if (seenDestinationPaths.has(destinationKey)) continue;
|
|
2006
|
+
seenDestinationPaths.add(destinationKey);
|
|
2007
|
+
if (shouldLinkToAgents && targetPathToCheck !== AGENT_STANDARD_PATH) {
|
|
2008
|
+
if (await getExistingPathKind(destinationPath) !== "file") continue;
|
|
2009
|
+
}
|
|
2010
|
+
if (fs.existsSync(destinationPath)) {
|
|
2011
|
+
if (fs.lstatSync(destinationPath).isSymbolicLink()) continue;
|
|
2012
|
+
const destinationRealPath = await fsPromises.realpath(destinationPath);
|
|
2013
|
+
if (seenRealPaths.has(destinationRealPath)) continue;
|
|
2014
|
+
if (replaceMarkedAgentInstructionsSection(await fsPromises.readFile(destinationPath, "utf-8"), incomingContent) !== void 0) {
|
|
2015
|
+
seenRealPaths.add(destinationRealPath);
|
|
2016
|
+
continue;
|
|
2017
|
+
}
|
|
2018
|
+
conflicts.push({ targetPath: targetPathToCheck });
|
|
2019
|
+
seenRealPaths.add(destinationRealPath);
|
|
2020
|
+
}
|
|
2672
2021
|
}
|
|
2022
|
+
return conflicts;
|
|
2023
|
+
}
|
|
2024
|
+
async function writeAgentInstructions({ projectRoot, targetPath, targetPaths, interactive, conflictDecisions, silent = false }) {
|
|
2025
|
+
const paths = [...targetPaths ?? [], ...targetPath ? [targetPath] : []];
|
|
2026
|
+
if (paths.length === 0) return;
|
|
2673
2027
|
const sourcePath = path.join(pkgRoot, "AGENTS.md");
|
|
2674
2028
|
if (!fs.existsSync(sourcePath)) {
|
|
2675
|
-
log.warn("Agent instructions template not found; skipping.");
|
|
2029
|
+
if (!silent) log.warn("Agent instructions template not found; skipping.");
|
|
2676
2030
|
return;
|
|
2677
2031
|
}
|
|
2678
|
-
const seenDestinationPaths = new Set();
|
|
2679
|
-
const seenRealPaths = new Set();
|
|
2032
|
+
const seenDestinationPaths = /* @__PURE__ */ new Set();
|
|
2033
|
+
const seenRealPaths = /* @__PURE__ */ new Set();
|
|
2680
2034
|
const incomingContent = await fsPromises.readFile(sourcePath, "utf-8");
|
|
2681
2035
|
const shouldLinkToAgents = paths.includes(AGENT_STANDARD_PATH);
|
|
2682
2036
|
const orderedPaths = shouldLinkToAgents ? [AGENT_STANDARD_PATH, ...paths.filter((p) => p !== AGENT_STANDARD_PATH)] : paths;
|
|
2683
2037
|
for (const targetPathToWrite of orderedPaths) {
|
|
2684
2038
|
const destinationPath = path.join(projectRoot, targetPathToWrite);
|
|
2685
2039
|
const destinationKey = path.resolve(destinationPath);
|
|
2686
|
-
if (seenDestinationPaths.has(destinationKey))
|
|
2687
|
-
continue;
|
|
2688
|
-
}
|
|
2040
|
+
if (seenDestinationPaths.has(destinationKey)) continue;
|
|
2689
2041
|
seenDestinationPaths.add(destinationKey);
|
|
2690
2042
|
await fsPromises.mkdir(path.dirname(destinationPath), { recursive: true });
|
|
2691
2043
|
if (shouldLinkToAgents && targetPathToWrite !== AGENT_STANDARD_PATH) {
|
|
2692
|
-
|
|
2693
|
-
if (linked) {
|
|
2694
|
-
continue;
|
|
2695
|
-
}
|
|
2044
|
+
if (await tryLinkTargetToAgents(projectRoot, targetPathToWrite, silent)) continue;
|
|
2696
2045
|
}
|
|
2697
2046
|
if (fs.existsSync(destinationPath)) {
|
|
2698
2047
|
if (fs.lstatSync(destinationPath).isSymbolicLink()) {
|
|
2699
|
-
log.info(`Skipped writing ${targetPathToWrite} (symlink)`);
|
|
2048
|
+
if (!silent) log.info(`Skipped writing ${targetPathToWrite} (symlink)`);
|
|
2700
2049
|
continue;
|
|
2701
2050
|
}
|
|
2702
2051
|
const destinationRealPath = await fsPromises.realpath(destinationPath);
|
|
2703
2052
|
if (seenRealPaths.has(destinationRealPath)) {
|
|
2704
|
-
log.info(`Skipped writing ${targetPathToWrite} (duplicate target)`);
|
|
2053
|
+
if (!silent) log.info(`Skipped writing ${targetPathToWrite} (duplicate target)`);
|
|
2705
2054
|
continue;
|
|
2706
2055
|
}
|
|
2707
2056
|
const existingContent = await fsPromises.readFile(destinationPath, "utf-8");
|
|
2708
2057
|
const updatedContent = replaceMarkedAgentInstructionsSection(existingContent, incomingContent);
|
|
2709
|
-
if (updatedContent !==
|
|
2710
|
-
if (updatedContent !== existingContent)
|
|
2711
|
-
await fsPromises.writeFile(destinationPath, updatedContent);
|
|
2712
|
-
}
|
|
2058
|
+
if (updatedContent !== void 0) {
|
|
2059
|
+
if (updatedContent !== existingContent) await fsPromises.writeFile(destinationPath, updatedContent);
|
|
2713
2060
|
seenRealPaths.add(destinationRealPath);
|
|
2714
2061
|
continue;
|
|
2715
2062
|
}
|
|
2716
|
-
|
|
2063
|
+
let conflictAction;
|
|
2064
|
+
const preResolved = conflictDecisions?.get(targetPathToWrite);
|
|
2065
|
+
if (preResolved) conflictAction = preResolved;
|
|
2066
|
+
else if (interactive) {
|
|
2717
2067
|
const action = await select({
|
|
2718
2068
|
message: `Agent instructions already exist at ${targetPathToWrite}.`,
|
|
2719
2069
|
options: [{
|
|
@@ -2727,317 +2077,67 @@ async function writeAgentInstructions({ projectRoot, targetPath, targetPaths, in
|
|
|
2727
2077
|
}],
|
|
2728
2078
|
initialValue: "skip"
|
|
2729
2079
|
});
|
|
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;
|
|
2080
|
+
conflictAction = Ct(action) || action === "skip" ? "skip" : "append";
|
|
2081
|
+
} else conflictAction = "skip";
|
|
2082
|
+
if (conflictAction === "append") await appendAgentContent(destinationPath, targetPathToWrite, existingContent, incomingContent, silent);
|
|
2083
|
+
else {
|
|
2084
|
+
const suffix = !preResolved && !interactive ? " (already exists)" : "";
|
|
2085
|
+
if (!silent) log.info(`Skipped writing ${targetPathToWrite}${suffix}`);
|
|
2740
2086
|
}
|
|
2741
|
-
log.info(`Skipped writing ${targetPathToWrite} (already exists)`);
|
|
2742
2087
|
seenRealPaths.add(destinationRealPath);
|
|
2743
2088
|
continue;
|
|
2744
2089
|
}
|
|
2745
2090
|
await fsPromises.writeFile(destinationPath, incomingContent);
|
|
2746
|
-
log.success(`Wrote agent instructions to ${targetPathToWrite}`);
|
|
2091
|
+
if (!silent) log.success(`Wrote agent instructions to ${targetPathToWrite}`);
|
|
2747
2092
|
seenRealPaths.add(await fsPromises.realpath(destinationPath));
|
|
2748
2093
|
}
|
|
2749
2094
|
}
|
|
2095
|
+
async function appendAgentContent(destinationPath, targetPath, existingContent, incomingContent, silent = false) {
|
|
2096
|
+
const separator = existingContent.endsWith("\n") ? "" : "\n";
|
|
2097
|
+
await fsPromises.appendFile(destinationPath, `${separator}\n${incomingContent}`);
|
|
2098
|
+
if (!silent) log.success(`Appended agent instructions to ${targetPath}`);
|
|
2099
|
+
}
|
|
2750
2100
|
function normalizeAgentName(value) {
|
|
2751
2101
|
return value.trim().toLowerCase().replace(/[^a-z0-9]+/g, "");
|
|
2752
2102
|
}
|
|
2753
2103
|
function replaceMarkedAgentInstructionsSection(existing, incoming) {
|
|
2754
2104
|
const existingRange = getMarkedRange(existing, AGENT_INSTRUCTIONS_START_MARKER, AGENT_INSTRUCTIONS_END_MARKER);
|
|
2755
|
-
if (!existingRange)
|
|
2756
|
-
return undefined;
|
|
2757
|
-
}
|
|
2105
|
+
if (!existingRange) return;
|
|
2758
2106
|
const incomingRange = getMarkedRange(incoming, AGENT_INSTRUCTIONS_START_MARKER, AGENT_INSTRUCTIONS_END_MARKER);
|
|
2759
|
-
if (!incomingRange)
|
|
2760
|
-
return undefined;
|
|
2761
|
-
}
|
|
2107
|
+
if (!incomingRange) return;
|
|
2762
2108
|
return `${existing.slice(0, existingRange.start)}${incoming.slice(incomingRange.start, incomingRange.end)}${existing.slice(existingRange.end)}`;
|
|
2763
2109
|
}
|
|
2764
|
-
async function tryLinkTargetToAgents(projectRoot, targetPath) {
|
|
2110
|
+
async function tryLinkTargetToAgents(projectRoot, targetPath, silent = false) {
|
|
2765
2111
|
const destinationPath = path.join(projectRoot, targetPath);
|
|
2766
2112
|
const agentsPath = path.join(projectRoot, AGENT_STANDARD_PATH);
|
|
2767
2113
|
const symlinkTarget = path.relative(path.dirname(destinationPath), agentsPath);
|
|
2768
2114
|
const existing = await getExistingPathKind(destinationPath);
|
|
2769
|
-
if (existing === "file")
|
|
2770
|
-
return false;
|
|
2771
|
-
}
|
|
2115
|
+
if (existing === "file") return false;
|
|
2772
2116
|
if (existing === "symlink") {
|
|
2773
2117
|
const currentLink = await fsPromises.readlink(destinationPath);
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
log.info(`Skipped linking ${targetPath} (already linked to ${AGENT_STANDARD_PATH})`);
|
|
2118
|
+
if (path.resolve(path.dirname(destinationPath), currentLink) === agentsPath) {
|
|
2119
|
+
if (!silent) log.info(`Skipped linking ${targetPath} (already linked to ${AGENT_STANDARD_PATH})`);
|
|
2777
2120
|
return true;
|
|
2778
2121
|
}
|
|
2779
2122
|
await fsPromises.unlink(destinationPath);
|
|
2780
2123
|
}
|
|
2781
2124
|
await fsPromises.symlink(symlinkTarget, destinationPath);
|
|
2782
|
-
log.success(`Linked ${targetPath} to ${AGENT_STANDARD_PATH}`);
|
|
2125
|
+
if (!silent) log.success(`Linked ${targetPath} to ${AGENT_STANDARD_PATH}`);
|
|
2783
2126
|
return true;
|
|
2784
2127
|
}
|
|
2785
2128
|
async function getExistingPathKind(filePath) {
|
|
2786
|
-
if (!fs.existsSync(filePath))
|
|
2787
|
-
|
|
2788
|
-
}
|
|
2789
|
-
const stat = await fsPromises.lstat(filePath);
|
|
2790
|
-
return stat.isSymbolicLink() ? "symlink" : "file";
|
|
2129
|
+
if (!fs.existsSync(filePath)) return "missing";
|
|
2130
|
+
return (await fsPromises.lstat(filePath)).isSymbolicLink() ? "symlink" : "file";
|
|
2791
2131
|
}
|
|
2792
2132
|
function getMarkedRange(content, startMarker, endMarker) {
|
|
2793
2133
|
const start = content.indexOf(startMarker);
|
|
2794
|
-
if (start === -1)
|
|
2795
|
-
return undefined;
|
|
2796
|
-
}
|
|
2134
|
+
if (start === -1) return;
|
|
2797
2135
|
const endMarkerIndex = content.indexOf(endMarker, start + startMarker.length);
|
|
2798
|
-
if (endMarkerIndex === -1)
|
|
2799
|
-
return undefined;
|
|
2800
|
-
}
|
|
2136
|
+
if (endMarkerIndex === -1) return;
|
|
2801
2137
|
return {
|
|
2802
2138
|
start,
|
|
2803
2139
|
end: endMarkerIndex + endMarker.length
|
|
2804
2140
|
};
|
|
2805
2141
|
}
|
|
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
2142
|
//#endregion
|
|
3043
|
-
export {
|
|
2143
|
+
export { select as A, cancel as C, multiselect as D, log as E, Ct as M, 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, text 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 };
|