varlock 0.2.1 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/auto-load.js +8 -8
- package/dist/chunk-2YPKUF3A.js +18 -0
- package/dist/{chunk-7SH6C6WJ.js.map → chunk-2YPKUF3A.js.map} +1 -1
- package/dist/{chunk-RZT65DRA.js → chunk-35SAMS66.js} +4 -4
- package/dist/{chunk-RZT65DRA.js.map → chunk-35SAMS66.js.map} +1 -1
- package/dist/{chunk-XN24GZXQ.js → chunk-6PEHRAEP.js} +3 -8
- package/dist/{chunk-XN24GZXQ.js.map → chunk-6PEHRAEP.js.map} +1 -1
- package/dist/{chunk-ZLM3MCYF.js → chunk-BXR2RIO6.js} +6 -6
- package/dist/{chunk-ZLM3MCYF.js.map → chunk-BXR2RIO6.js.map} +1 -1
- package/dist/{chunk-NA4YDM42.js → chunk-HTF7NU5C.js} +10 -9
- package/dist/chunk-HTF7NU5C.js.map +1 -0
- package/dist/{chunk-NDWB3TT5.js → chunk-ISSW6NKZ.js} +9 -4
- package/dist/chunk-ISSW6NKZ.js.map +1 -0
- package/dist/{chunk-FGMXIEFA.js → chunk-MIBOBKI4.js} +3 -3
- package/dist/{chunk-FGMXIEFA.js.map → chunk-MIBOBKI4.js.map} +1 -1
- package/dist/chunk-OY5U5WTF.js +10829 -0
- package/dist/chunk-OY5U5WTF.js.map +1 -0
- package/dist/chunk-PESTWPBG.js +307 -0
- package/dist/chunk-PESTWPBG.js.map +1 -0
- package/dist/{chunk-H5IG4ZVM.js → chunk-Q3C4VKFT.js} +6 -6
- package/dist/chunk-Q3C4VKFT.js.map +1 -0
- package/dist/chunk-QZ6HBRJC.js +97 -0
- package/dist/chunk-QZ6HBRJC.js.map +1 -0
- package/dist/{chunk-FUDH2TTI.js → chunk-TVFOIGJP.js} +3 -3
- package/dist/{chunk-FUDH2TTI.js.map → chunk-TVFOIGJP.js.map} +1 -1
- package/dist/{chunk-5IMCRQTM.js → chunk-TYIS6T2T.js} +4 -4
- package/dist/{chunk-5IMCRQTM.js.map → chunk-TYIS6T2T.js.map} +1 -1
- package/dist/chunk-UDXNNRWI.js +1386 -0
- package/dist/chunk-UDXNNRWI.js.map +1 -0
- package/dist/{chunk-HPNRKYVF.js → chunk-UIOEEWG5.js} +4 -4
- package/dist/{chunk-HPNRKYVF.js.map → chunk-UIOEEWG5.js.map} +1 -1
- package/dist/{chunk-MSRPV5WH.js → chunk-WAMBVZL2.js} +4 -4
- package/dist/{chunk-MSRPV5WH.js.map → chunk-WAMBVZL2.js.map} +1 -1
- package/dist/chunk-YIXN7TC7.js +1532 -0
- package/dist/chunk-YIXN7TC7.js.map +1 -0
- package/dist/{chunk-NSY7JMFV.js → chunk-ZXJ4CEDK.js} +4 -4
- package/dist/{chunk-NSY7JMFV.js.map → chunk-ZXJ4CEDK.js.map} +1 -1
- package/dist/cli/cli-executable.js +20 -21
- package/dist/cli/cli-executable.js.map +1 -1
- package/dist/dotenv-compat.js +8 -8
- package/dist/{env-graph-BZwrHQbb.d.ts → env-graph-DIcuAiYh.d.ts} +9 -2
- package/dist/help.command-MLH2WA5Y.js +5 -0
- package/dist/{help.command-B7VWA53B.js.map → help.command-MLH2WA5Y.js.map} +1 -1
- package/dist/index.d.ts +2 -3
- package/dist/index.js +10 -9
- package/dist/index.js.map +1 -1
- package/dist/init.command-RAYBZ66R.js +9 -0
- package/dist/{init.command-GNLFBWYF.js.map → init.command-RAYBZ66R.js.map} +1 -1
- package/dist/lib/exec-sync-varlock.js +2 -2
- package/dist/load.command-KOSPGLV6.js +9 -0
- package/dist/{load.command-WR5QCE6M.js.map → load.command-KOSPGLV6.js.map} +1 -1
- package/dist/plugin-lib.d.ts +2 -3
- package/dist/plugin-lib.js +2 -1
- package/dist/run.command-BOBQIELJ.js +10 -0
- package/dist/{run.command-GXQTDDDP.js.map → run.command-BOBQIELJ.js.map} +1 -1
- package/dist/runtime/env.d.ts +1 -2
- package/dist/runtime/env.js +3 -3
- package/dist/runtime/patch-console.js +4 -4
- package/dist/runtime/patch-response.js +4 -4
- package/dist/runtime/patch-server-response.js +4 -4
- package/dist/telemetry.command-SFEMMU3U.js +9 -0
- package/dist/{telemetry.command-ZFW55RLH.js.map → telemetry.command-SFEMMU3U.js.map} +1 -1
- package/package.json +35 -22
- package/dist/chunk-33ROL4J5.js +0 -1013
- package/dist/chunk-33ROL4J5.js.map +0 -1
- package/dist/chunk-4CRDKWAU.js +0 -1281
- package/dist/chunk-4CRDKWAU.js.map +0 -1
- package/dist/chunk-7SH6C6WJ.js +0 -18
- package/dist/chunk-H5IG4ZVM.js.map +0 -1
- package/dist/chunk-NA4YDM42.js.map +0 -1
- package/dist/chunk-NDWB3TT5.js.map +0 -1
- package/dist/chunk-NHA2P5AV.js +0 -135
- package/dist/chunk-NHA2P5AV.js.map +0 -1
- package/dist/chunk-OKNWYS57.js +0 -4061
- package/dist/chunk-OKNWYS57.js.map +0 -1
- package/dist/en-US-TSGNDI2P.js +0 -22
- package/dist/en-US-TSGNDI2P.js.map +0 -1
- package/dist/help.command-B7VWA53B.js +0 -5
- package/dist/init.command-GNLFBWYF.js +0 -8
- package/dist/ja-JP-UBPCQAAD.js +0 -22
- package/dist/ja-JP-UBPCQAAD.js.map +0 -1
- package/dist/load.command-WR5QCE6M.js +0 -8
- package/dist/run.command-GXQTDDDP.js +0 -9
- package/dist/telemetry.command-ZFW55RLH.js +0 -8
|
@@ -0,0 +1,1532 @@
|
|
|
1
|
+
import { detectJsPackageManager, logLines, fmt, installJsDependency } from './chunk-Q3C4VKFT.js';
|
|
2
|
+
import { define } from './chunk-UDXNNRWI.js';
|
|
3
|
+
import { envSpecUpdater, ParsedEnvSpecStaticValue, tryCatch, parseEnvSpecDotEnvFile, gracefulExit, ansis_default, pathExists } from './chunk-OY5U5WTF.js';
|
|
4
|
+
import { __commonJS, __name, __toESM } from './chunk-6PEHRAEP.js';
|
|
5
|
+
import path2, { dirname } from 'path';
|
|
6
|
+
import fs3 from 'fs/promises';
|
|
7
|
+
import N2, { stdin, stdout } from 'process';
|
|
8
|
+
import ot from 'readline';
|
|
9
|
+
import { WriteStream } from 'tty';
|
|
10
|
+
import 'fs';
|
|
11
|
+
import { promisify } from 'util';
|
|
12
|
+
import { exec, spawn } from 'child_process';
|
|
13
|
+
|
|
14
|
+
// ../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js
|
|
15
|
+
var require_picocolors = __commonJS({
|
|
16
|
+
"../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js"(exports, module) {
|
|
17
|
+
var p = process || {};
|
|
18
|
+
var argv = p.argv || [];
|
|
19
|
+
var env = p.env || {};
|
|
20
|
+
var isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
|
|
21
|
+
var formatter = /* @__PURE__ */ __name((open, close, replace = open) => (input) => {
|
|
22
|
+
let string = "" + input, index = string.indexOf(close, open.length);
|
|
23
|
+
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
|
|
24
|
+
}, "formatter");
|
|
25
|
+
var replaceClose = /* @__PURE__ */ __name((string, close, replace, index) => {
|
|
26
|
+
let result = "", cursor = 0;
|
|
27
|
+
do {
|
|
28
|
+
result += string.substring(cursor, index) + replace;
|
|
29
|
+
cursor = index + close.length;
|
|
30
|
+
index = string.indexOf(close, cursor);
|
|
31
|
+
} while (~index);
|
|
32
|
+
return result + string.substring(cursor);
|
|
33
|
+
}, "replaceClose");
|
|
34
|
+
var createColors = /* @__PURE__ */ __name((enabled = isColorSupported) => {
|
|
35
|
+
let f = enabled ? formatter : () => String;
|
|
36
|
+
return {
|
|
37
|
+
isColorSupported: enabled,
|
|
38
|
+
reset: f("\x1B[0m", "\x1B[0m"),
|
|
39
|
+
bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
|
|
40
|
+
dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
|
|
41
|
+
italic: f("\x1B[3m", "\x1B[23m"),
|
|
42
|
+
underline: f("\x1B[4m", "\x1B[24m"),
|
|
43
|
+
inverse: f("\x1B[7m", "\x1B[27m"),
|
|
44
|
+
hidden: f("\x1B[8m", "\x1B[28m"),
|
|
45
|
+
strikethrough: f("\x1B[9m", "\x1B[29m"),
|
|
46
|
+
black: f("\x1B[30m", "\x1B[39m"),
|
|
47
|
+
red: f("\x1B[31m", "\x1B[39m"),
|
|
48
|
+
green: f("\x1B[32m", "\x1B[39m"),
|
|
49
|
+
yellow: f("\x1B[33m", "\x1B[39m"),
|
|
50
|
+
blue: f("\x1B[34m", "\x1B[39m"),
|
|
51
|
+
magenta: f("\x1B[35m", "\x1B[39m"),
|
|
52
|
+
cyan: f("\x1B[36m", "\x1B[39m"),
|
|
53
|
+
white: f("\x1B[37m", "\x1B[39m"),
|
|
54
|
+
gray: f("\x1B[90m", "\x1B[39m"),
|
|
55
|
+
bgBlack: f("\x1B[40m", "\x1B[49m"),
|
|
56
|
+
bgRed: f("\x1B[41m", "\x1B[49m"),
|
|
57
|
+
bgGreen: f("\x1B[42m", "\x1B[49m"),
|
|
58
|
+
bgYellow: f("\x1B[43m", "\x1B[49m"),
|
|
59
|
+
bgBlue: f("\x1B[44m", "\x1B[49m"),
|
|
60
|
+
bgMagenta: f("\x1B[45m", "\x1B[49m"),
|
|
61
|
+
bgCyan: f("\x1B[46m", "\x1B[49m"),
|
|
62
|
+
bgWhite: f("\x1B[47m", "\x1B[49m"),
|
|
63
|
+
blackBright: f("\x1B[90m", "\x1B[39m"),
|
|
64
|
+
redBright: f("\x1B[91m", "\x1B[39m"),
|
|
65
|
+
greenBright: f("\x1B[92m", "\x1B[39m"),
|
|
66
|
+
yellowBright: f("\x1B[93m", "\x1B[39m"),
|
|
67
|
+
blueBright: f("\x1B[94m", "\x1B[39m"),
|
|
68
|
+
magentaBright: f("\x1B[95m", "\x1B[39m"),
|
|
69
|
+
cyanBright: f("\x1B[96m", "\x1B[39m"),
|
|
70
|
+
whiteBright: f("\x1B[97m", "\x1B[39m"),
|
|
71
|
+
bgBlackBright: f("\x1B[100m", "\x1B[49m"),
|
|
72
|
+
bgRedBright: f("\x1B[101m", "\x1B[49m"),
|
|
73
|
+
bgGreenBright: f("\x1B[102m", "\x1B[49m"),
|
|
74
|
+
bgYellowBright: f("\x1B[103m", "\x1B[49m"),
|
|
75
|
+
bgBlueBright: f("\x1B[104m", "\x1B[49m"),
|
|
76
|
+
bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
|
|
77
|
+
bgCyanBright: f("\x1B[106m", "\x1B[49m"),
|
|
78
|
+
bgWhiteBright: f("\x1B[107m", "\x1B[49m")
|
|
79
|
+
};
|
|
80
|
+
}, "createColors");
|
|
81
|
+
module.exports = createColors();
|
|
82
|
+
module.exports.createColors = createColors;
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
// ../../node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js
|
|
87
|
+
var require_src = __commonJS({
|
|
88
|
+
"../../node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js"(exports, module) {
|
|
89
|
+
var ESC = "\x1B";
|
|
90
|
+
var CSI = `${ESC}[`;
|
|
91
|
+
var beep = "\x07";
|
|
92
|
+
var cursor = {
|
|
93
|
+
to(x3, y2) {
|
|
94
|
+
if (!y2) return `${CSI}${x3 + 1}G`;
|
|
95
|
+
return `${CSI}${y2 + 1};${x3 + 1}H`;
|
|
96
|
+
},
|
|
97
|
+
move(x3, y2) {
|
|
98
|
+
let ret = "";
|
|
99
|
+
if (x3 < 0) ret += `${CSI}${-x3}D`;
|
|
100
|
+
else if (x3 > 0) ret += `${CSI}${x3}C`;
|
|
101
|
+
if (y2 < 0) ret += `${CSI}${-y2}A`;
|
|
102
|
+
else if (y2 > 0) ret += `${CSI}${y2}B`;
|
|
103
|
+
return ret;
|
|
104
|
+
},
|
|
105
|
+
up: /* @__PURE__ */ __name((count = 1) => `${CSI}${count}A`, "up"),
|
|
106
|
+
down: /* @__PURE__ */ __name((count = 1) => `${CSI}${count}B`, "down"),
|
|
107
|
+
forward: /* @__PURE__ */ __name((count = 1) => `${CSI}${count}C`, "forward"),
|
|
108
|
+
backward: /* @__PURE__ */ __name((count = 1) => `${CSI}${count}D`, "backward"),
|
|
109
|
+
nextLine: /* @__PURE__ */ __name((count = 1) => `${CSI}E`.repeat(count), "nextLine"),
|
|
110
|
+
prevLine: /* @__PURE__ */ __name((count = 1) => `${CSI}F`.repeat(count), "prevLine"),
|
|
111
|
+
left: `${CSI}G`,
|
|
112
|
+
hide: `${CSI}?25l`,
|
|
113
|
+
show: `${CSI}?25h`,
|
|
114
|
+
save: `${ESC}7`,
|
|
115
|
+
restore: `${ESC}8`
|
|
116
|
+
};
|
|
117
|
+
var scroll = {
|
|
118
|
+
up: /* @__PURE__ */ __name((count = 1) => `${CSI}S`.repeat(count), "up"),
|
|
119
|
+
down: /* @__PURE__ */ __name((count = 1) => `${CSI}T`.repeat(count), "down")
|
|
120
|
+
};
|
|
121
|
+
var erase = {
|
|
122
|
+
screen: `${CSI}2J`,
|
|
123
|
+
up: /* @__PURE__ */ __name((count = 1) => `${CSI}1J`.repeat(count), "up"),
|
|
124
|
+
down: /* @__PURE__ */ __name((count = 1) => `${CSI}J`.repeat(count), "down"),
|
|
125
|
+
line: `${CSI}2K`,
|
|
126
|
+
lineEnd: `${CSI}K`,
|
|
127
|
+
lineStart: `${CSI}1K`,
|
|
128
|
+
lines(count) {
|
|
129
|
+
let clear = "";
|
|
130
|
+
for (let i = 0; i < count; i++)
|
|
131
|
+
clear += this.line + (i < count - 1 ? cursor.up() : "");
|
|
132
|
+
if (count)
|
|
133
|
+
clear += cursor.left;
|
|
134
|
+
return clear;
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
module.exports = { cursor, scroll, erase, beep };
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
// ../../node_modules/.pnpm/@clack+core@1.0.1/node_modules/@clack/core/dist/index.mjs
|
|
142
|
+
var import_sisteransi = __toESM(require_src(), 1);
|
|
143
|
+
function B(t, e2, s) {
|
|
144
|
+
if (!s.some((u) => !u.disabled)) return t;
|
|
145
|
+
const i = t + e2, r = Math.max(s.length - 1, 0), n = i < 0 ? r : i > r ? 0 : i;
|
|
146
|
+
return s[n].disabled ? B(n, e2 < 0 ? -1 : 1, s) : n;
|
|
147
|
+
}
|
|
148
|
+
__name(B, "B");
|
|
149
|
+
var at = /* @__PURE__ */ __name((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, "at");
|
|
150
|
+
var lt = /* @__PURE__ */ __name((t) => t === 12288 || t >= 65281 && t <= 65376 || t >= 65504 && t <= 65510, "lt");
|
|
151
|
+
var ht = /* @__PURE__ */ __name((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, "ht");
|
|
152
|
+
var O = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y;
|
|
153
|
+
var y = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
|
|
154
|
+
var L = /\t{1,1000}/y;
|
|
155
|
+
var P = new RegExp("[\\u{1F1E6}-\\u{1F1FF}]{2}|\\u{1F3F4}[\\u{E0061}-\\u{E007A}]{2}[\\u{E0030}-\\u{E0039}\\u{E0061}-\\u{E007A}]{1,3}\\u{E007F}|(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation})(?:\\u200D(?:\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation}|\\p{Emoji}\\uFE0F\\u20E3?))*", "yu");
|
|
156
|
+
var M = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
|
|
157
|
+
var ct = new RegExp("\\p{M}+", "gu");
|
|
158
|
+
var ft = { limit: 1 / 0, ellipsis: "" };
|
|
159
|
+
var X = /* @__PURE__ */ __name((t, e2 = {}, s = {}) => {
|
|
160
|
+
const i = e2.limit ?? 1 / 0, r = e2.ellipsis ?? "", n = e2?.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, V2 = s.wideWidth ?? 2;
|
|
161
|
+
let h = 0, o = 0, p = t.length, v = 0, F = false, d2 = p, b = Math.max(0, i - n), C2 = 0, w = 0, c = 0, f = 0;
|
|
162
|
+
t: for (; ; ) {
|
|
163
|
+
if (w > C2 || o >= p && o > h) {
|
|
164
|
+
const ut2 = t.slice(C2, w) || t.slice(h, o);
|
|
165
|
+
v = 0;
|
|
166
|
+
for (const Y of ut2.replaceAll(ct, "")) {
|
|
167
|
+
const $ = Y.codePointAt(0) || 0;
|
|
168
|
+
if (lt($) ? f = m : ht($) ? f = V2 : E !== A && at($) ? f = E : f = A, c + f > b && (d2 = Math.min(d2, Math.max(C2, h) + v)), c + f > i) {
|
|
169
|
+
F = true;
|
|
170
|
+
break t;
|
|
171
|
+
}
|
|
172
|
+
v += Y.length, c += f;
|
|
173
|
+
}
|
|
174
|
+
C2 = w = 0;
|
|
175
|
+
}
|
|
176
|
+
if (o >= p) break;
|
|
177
|
+
if (M.lastIndex = o, M.test(t)) {
|
|
178
|
+
if (v = M.lastIndex - o, f = v * A, c + f > b && (d2 = Math.min(d2, o + Math.floor((b - c) / A))), c + f > i) {
|
|
179
|
+
F = true;
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
c += f, C2 = h, w = o, o = h = M.lastIndex;
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
if (O.lastIndex = o, O.test(t)) {
|
|
186
|
+
if (c + u > b && (d2 = Math.min(d2, o)), c + u > i) {
|
|
187
|
+
F = true;
|
|
188
|
+
break;
|
|
189
|
+
}
|
|
190
|
+
c += u, C2 = h, w = o, o = h = O.lastIndex;
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
193
|
+
if (y.lastIndex = o, y.test(t)) {
|
|
194
|
+
if (v = y.lastIndex - o, f = v * a, c + f > b && (d2 = Math.min(d2, o + Math.floor((b - c) / a))), c + f > i) {
|
|
195
|
+
F = true;
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
c += f, C2 = h, w = o, o = h = y.lastIndex;
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
if (L.lastIndex = o, L.test(t)) {
|
|
202
|
+
if (v = L.lastIndex - o, f = v * l, c + f > b && (d2 = Math.min(d2, o + Math.floor((b - c) / l))), c + f > i) {
|
|
203
|
+
F = true;
|
|
204
|
+
break;
|
|
205
|
+
}
|
|
206
|
+
c += f, C2 = h, w = o, o = h = L.lastIndex;
|
|
207
|
+
continue;
|
|
208
|
+
}
|
|
209
|
+
if (P.lastIndex = o, P.test(t)) {
|
|
210
|
+
if (c + g > b && (d2 = Math.min(d2, o)), c + g > i) {
|
|
211
|
+
F = true;
|
|
212
|
+
break;
|
|
213
|
+
}
|
|
214
|
+
c += g, C2 = h, w = o, o = h = P.lastIndex;
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
217
|
+
o += 1;
|
|
218
|
+
}
|
|
219
|
+
return { width: F ? b : c, index: F ? d2 : p, truncated: F, ellipsed: F && i >= n };
|
|
220
|
+
}, "X");
|
|
221
|
+
var pt = { limit: 1 / 0, ellipsis: "", ellipsisWidth: 0 };
|
|
222
|
+
var S = /* @__PURE__ */ __name((t, e2 = {}) => X(t, pt, e2).width, "S");
|
|
223
|
+
var W = "\x1B";
|
|
224
|
+
var Z = "\x9B";
|
|
225
|
+
var Ft = 39;
|
|
226
|
+
var j = "\x07";
|
|
227
|
+
var Q = "[";
|
|
228
|
+
var dt = "]";
|
|
229
|
+
var tt = "m";
|
|
230
|
+
var U = `${dt}8;;`;
|
|
231
|
+
var et = new RegExp(`(?:\\${Q}(?<code>\\d+)m|\\${U}(?<uri>.*)${j})`, "y");
|
|
232
|
+
var mt = /* @__PURE__ */ __name((t) => {
|
|
233
|
+
if (t >= 30 && t <= 37 || t >= 90 && t <= 97) return 39;
|
|
234
|
+
if (t >= 40 && t <= 47 || t >= 100 && t <= 107) return 49;
|
|
235
|
+
if (t === 1 || t === 2) return 22;
|
|
236
|
+
if (t === 3) return 23;
|
|
237
|
+
if (t === 4) return 24;
|
|
238
|
+
if (t === 7) return 27;
|
|
239
|
+
if (t === 8) return 28;
|
|
240
|
+
if (t === 9) return 29;
|
|
241
|
+
if (t === 0) return 0;
|
|
242
|
+
}, "mt");
|
|
243
|
+
var st = /* @__PURE__ */ __name((t) => `${W}${Q}${t}${tt}`, "st");
|
|
244
|
+
var it = /* @__PURE__ */ __name((t) => `${W}${U}${t}${j}`, "it");
|
|
245
|
+
var gt = /* @__PURE__ */ __name((t) => t.map((e2) => S(e2)), "gt");
|
|
246
|
+
var G = /* @__PURE__ */ __name((t, e2, s) => {
|
|
247
|
+
const i = e2[Symbol.iterator]();
|
|
248
|
+
let r = false, n = false, u = t.at(-1), a = u === void 0 ? 0 : S(u), l = i.next(), E = i.next(), g = 0;
|
|
249
|
+
for (; !l.done; ) {
|
|
250
|
+
const m = l.value, A = S(m);
|
|
251
|
+
a + A <= s ? t[t.length - 1] += m : (t.push(m), a = 0), (m === W || m === Z) && (r = true, n = e2.startsWith(U, g + 1)), r ? n ? m === j && (r = false, n = false) : m === tt && (r = false) : (a += A, a === s && !E.done && (t.push(""), a = 0)), l = E, E = i.next(), g += m.length;
|
|
252
|
+
}
|
|
253
|
+
u = t.at(-1), !a && u !== void 0 && u.length > 0 && t.length > 1 && (t[t.length - 2] += t.pop());
|
|
254
|
+
}, "G");
|
|
255
|
+
var vt = /* @__PURE__ */ __name((t) => {
|
|
256
|
+
const e2 = t.split(" ");
|
|
257
|
+
let s = e2.length;
|
|
258
|
+
for (; s > 0 && !(S(e2[s - 1]) > 0); ) s--;
|
|
259
|
+
return s === e2.length ? t : e2.slice(0, s).join(" ") + e2.slice(s).join("");
|
|
260
|
+
}, "vt");
|
|
261
|
+
var Et = /* @__PURE__ */ __name((t, e2, s = {}) => {
|
|
262
|
+
if (s.trim !== false && t.trim() === "") return "";
|
|
263
|
+
let i = "", r, n;
|
|
264
|
+
const u = t.split(" "), a = gt(u);
|
|
265
|
+
let l = [""];
|
|
266
|
+
for (const [h, o] of u.entries()) {
|
|
267
|
+
s.trim !== false && (l[l.length - 1] = (l.at(-1) ?? "").trimStart());
|
|
268
|
+
let p = S(l.at(-1) ?? "");
|
|
269
|
+
if (h !== 0 && (p >= e2 && (s.wordWrap === false || s.trim === false) && (l.push(""), p = 0), (p > 0 || s.trim === false) && (l[l.length - 1] += " ", p++)), s.hard && a[h] > e2) {
|
|
270
|
+
const v = e2 - p, F = 1 + Math.floor((a[h] - v - 1) / e2);
|
|
271
|
+
Math.floor((a[h] - 1) / e2) < F && l.push(""), G(l, o, e2);
|
|
272
|
+
continue;
|
|
273
|
+
}
|
|
274
|
+
if (p + a[h] > e2 && p > 0 && a[h] > 0) {
|
|
275
|
+
if (s.wordWrap === false && p < e2) {
|
|
276
|
+
G(l, o, e2);
|
|
277
|
+
continue;
|
|
278
|
+
}
|
|
279
|
+
l.push("");
|
|
280
|
+
}
|
|
281
|
+
if (p + a[h] > e2 && s.wordWrap === false) {
|
|
282
|
+
G(l, o, e2);
|
|
283
|
+
continue;
|
|
284
|
+
}
|
|
285
|
+
l[l.length - 1] += o;
|
|
286
|
+
}
|
|
287
|
+
s.trim !== false && (l = l.map((h) => vt(h)));
|
|
288
|
+
const E = l.join(`
|
|
289
|
+
`), g = E[Symbol.iterator]();
|
|
290
|
+
let m = g.next(), A = g.next(), V2 = 0;
|
|
291
|
+
for (; !m.done; ) {
|
|
292
|
+
const h = m.value, o = A.value;
|
|
293
|
+
if (i += h, h === W || h === Z) {
|
|
294
|
+
et.lastIndex = V2 + 1;
|
|
295
|
+
const F = et.exec(E)?.groups;
|
|
296
|
+
if (F?.code !== void 0) {
|
|
297
|
+
const d2 = Number.parseFloat(F.code);
|
|
298
|
+
r = d2 === Ft ? void 0 : d2;
|
|
299
|
+
} else F?.uri !== void 0 && (n = F.uri.length === 0 ? void 0 : F.uri);
|
|
300
|
+
}
|
|
301
|
+
const p = r ? mt(r) : void 0;
|
|
302
|
+
o === `
|
|
303
|
+
` ? (n && (i += it("")), r && p && (i += st(p))) : h === `
|
|
304
|
+
` && (r && p && (i += st(r)), n && (i += it(n))), V2 += h.length, m = A, A = g.next();
|
|
305
|
+
}
|
|
306
|
+
return i;
|
|
307
|
+
}, "Et");
|
|
308
|
+
function K(t, e2, s) {
|
|
309
|
+
return String(t).normalize().replaceAll(`\r
|
|
310
|
+
`, `
|
|
311
|
+
`).split(`
|
|
312
|
+
`).map((i) => Et(i, e2, s)).join(`
|
|
313
|
+
`);
|
|
314
|
+
}
|
|
315
|
+
__name(K, "K");
|
|
316
|
+
var At = ["up", "down", "left", "right", "space", "enter", "cancel"];
|
|
317
|
+
var _ = { actions: new Set(At), aliases: /* @__PURE__ */ new Map([["k", "up"], ["j", "down"], ["h", "left"], ["l", "right"], ["", "cancel"], ["escape", "cancel"]]), withGuide: true };
|
|
318
|
+
function H(t, e2) {
|
|
319
|
+
if (typeof t == "string") return _.aliases.get(t) === e2;
|
|
320
|
+
for (const s of t) if (s !== void 0 && H(s, e2)) return true;
|
|
321
|
+
return false;
|
|
322
|
+
}
|
|
323
|
+
__name(H, "H");
|
|
324
|
+
function _t(t, e2) {
|
|
325
|
+
if (t === e2) return;
|
|
326
|
+
const s = t.split(`
|
|
327
|
+
`), i = e2.split(`
|
|
328
|
+
`), r = Math.max(s.length, i.length), n = [];
|
|
329
|
+
for (let u = 0; u < r; u++) s[u] !== i[u] && n.push(u);
|
|
330
|
+
return { lines: n, numLinesBefore: s.length, numLinesAfter: i.length, numLines: r };
|
|
331
|
+
}
|
|
332
|
+
__name(_t, "_t");
|
|
333
|
+
globalThis.process.platform.startsWith("win");
|
|
334
|
+
var z = /* @__PURE__ */ Symbol("clack:cancel");
|
|
335
|
+
function Ct(t) {
|
|
336
|
+
return t === z;
|
|
337
|
+
}
|
|
338
|
+
__name(Ct, "Ct");
|
|
339
|
+
function T(t, e2) {
|
|
340
|
+
const s = t;
|
|
341
|
+
s.isTTY && s.setRawMode(e2);
|
|
342
|
+
}
|
|
343
|
+
__name(T, "T");
|
|
344
|
+
var rt = /* @__PURE__ */ __name((t) => "columns" in t && typeof t.columns == "number" ? t.columns : 80, "rt");
|
|
345
|
+
var nt = /* @__PURE__ */ __name((t) => "rows" in t && typeof t.rows == "number" ? t.rows : 20, "nt");
|
|
346
|
+
function xt(t, e2, s, i = s) {
|
|
347
|
+
const r = rt(t ?? stdout);
|
|
348
|
+
return K(e2, r - s.length, { hard: true, trim: false }).split(`
|
|
349
|
+
`).map((n, u) => `${u === 0 ? i : s}${n}`).join(`
|
|
350
|
+
`);
|
|
351
|
+
}
|
|
352
|
+
__name(xt, "xt");
|
|
353
|
+
var x = class {
|
|
354
|
+
static {
|
|
355
|
+
__name(this, "x");
|
|
356
|
+
}
|
|
357
|
+
input;
|
|
358
|
+
output;
|
|
359
|
+
_abortSignal;
|
|
360
|
+
rl;
|
|
361
|
+
opts;
|
|
362
|
+
_render;
|
|
363
|
+
_track = false;
|
|
364
|
+
_prevFrame = "";
|
|
365
|
+
_subscribers = /* @__PURE__ */ new Map();
|
|
366
|
+
_cursor = 0;
|
|
367
|
+
state = "initial";
|
|
368
|
+
error = "";
|
|
369
|
+
value;
|
|
370
|
+
userInput = "";
|
|
371
|
+
constructor(e2, s = true) {
|
|
372
|
+
const { input: i = stdin, output: r = stdout, render: n, signal: u, ...a } = e2;
|
|
373
|
+
this.opts = a, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = n.bind(this), this._track = s, this._abortSignal = u, this.input = i, this.output = r;
|
|
374
|
+
}
|
|
375
|
+
unsubscribe() {
|
|
376
|
+
this._subscribers.clear();
|
|
377
|
+
}
|
|
378
|
+
setSubscriber(e2, s) {
|
|
379
|
+
const i = this._subscribers.get(e2) ?? [];
|
|
380
|
+
i.push(s), this._subscribers.set(e2, i);
|
|
381
|
+
}
|
|
382
|
+
on(e2, s) {
|
|
383
|
+
this.setSubscriber(e2, { cb: s });
|
|
384
|
+
}
|
|
385
|
+
once(e2, s) {
|
|
386
|
+
this.setSubscriber(e2, { cb: s, once: true });
|
|
387
|
+
}
|
|
388
|
+
emit(e2, ...s) {
|
|
389
|
+
const i = this._subscribers.get(e2) ?? [], r = [];
|
|
390
|
+
for (const n of i) n.cb(...s), n.once && r.push(() => i.splice(i.indexOf(n), 1));
|
|
391
|
+
for (const n of r) n();
|
|
392
|
+
}
|
|
393
|
+
prompt() {
|
|
394
|
+
return new Promise((e2) => {
|
|
395
|
+
if (this._abortSignal) {
|
|
396
|
+
if (this._abortSignal.aborted) return this.state = "cancel", this.close(), e2(z);
|
|
397
|
+
this._abortSignal.addEventListener("abort", () => {
|
|
398
|
+
this.state = "cancel", this.close();
|
|
399
|
+
}, { once: true });
|
|
400
|
+
}
|
|
401
|
+
this.rl = ot.createInterface({ input: this.input, tabSize: 2, prompt: "", escapeCodeTimeout: 50, terminal: true }), this.rl.prompt(), this.opts.initialUserInput !== void 0 && this._setUserInput(this.opts.initialUserInput, true), this.input.on("keypress", this.onKeypress), T(this.input, true), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
|
|
402
|
+
this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), T(this.input, false), e2(this.value);
|
|
403
|
+
}), this.once("cancel", () => {
|
|
404
|
+
this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), T(this.input, false), e2(z);
|
|
405
|
+
});
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
_isActionKey(e2, s) {
|
|
409
|
+
return e2 === " ";
|
|
410
|
+
}
|
|
411
|
+
_setValue(e2) {
|
|
412
|
+
this.value = e2, this.emit("value", this.value);
|
|
413
|
+
}
|
|
414
|
+
_setUserInput(e2, s) {
|
|
415
|
+
this.userInput = e2 ?? "", this.emit("userInput", this.userInput), s && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
|
|
416
|
+
}
|
|
417
|
+
_clearUserInput() {
|
|
418
|
+
this.rl?.write(null, { ctrl: true, name: "u" }), this._setUserInput("");
|
|
419
|
+
}
|
|
420
|
+
onKeypress(e2, s) {
|
|
421
|
+
if (this._track && s.name !== "return" && (s.name && this._isActionKey(e2, s) && this.rl?.write(null, { ctrl: true, name: "h" }), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"), s?.name && (!this._track && _.aliases.has(s.name) && this.emit("cursor", _.aliases.get(s.name)), _.actions.has(s.name) && this.emit("cursor", s.name)), e2 && (e2.toLowerCase() === "y" || e2.toLowerCase() === "n") && this.emit("confirm", e2.toLowerCase() === "y"), this.emit("key", e2?.toLowerCase(), s), s?.name === "return") {
|
|
422
|
+
if (this.opts.validate) {
|
|
423
|
+
const i = this.opts.validate(this.value);
|
|
424
|
+
i && (this.error = i instanceof Error ? i.message : i, this.state = "error", this.rl?.write(this.userInput));
|
|
425
|
+
}
|
|
426
|
+
this.state !== "error" && (this.state = "submit");
|
|
427
|
+
}
|
|
428
|
+
H([e2, s?.name, s?.sequence], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
|
|
429
|
+
}
|
|
430
|
+
close() {
|
|
431
|
+
this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
|
|
432
|
+
`), T(this.input, false), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
|
|
433
|
+
}
|
|
434
|
+
restoreCursor() {
|
|
435
|
+
const e2 = K(this._prevFrame, process.stdout.columns, { hard: true, trim: false }).split(`
|
|
436
|
+
`).length - 1;
|
|
437
|
+
this.output.write(import_sisteransi.cursor.move(-999, e2 * -1));
|
|
438
|
+
}
|
|
439
|
+
render() {
|
|
440
|
+
const e2 = K(this._render(this) ?? "", process.stdout.columns, { hard: true, trim: false });
|
|
441
|
+
if (e2 !== this._prevFrame) {
|
|
442
|
+
if (this.state === "initial") this.output.write(import_sisteransi.cursor.hide);
|
|
443
|
+
else {
|
|
444
|
+
const s = _t(this._prevFrame, e2), i = nt(this.output);
|
|
445
|
+
if (this.restoreCursor(), s) {
|
|
446
|
+
const r = Math.max(0, s.numLinesAfter - i), n = Math.max(0, s.numLinesBefore - i);
|
|
447
|
+
let u = s.lines.find((a) => a >= r);
|
|
448
|
+
if (u === void 0) {
|
|
449
|
+
this._prevFrame = e2;
|
|
450
|
+
return;
|
|
451
|
+
}
|
|
452
|
+
if (s.lines.length === 1) {
|
|
453
|
+
this.output.write(import_sisteransi.cursor.move(0, u - n)), this.output.write(import_sisteransi.erase.lines(1));
|
|
454
|
+
const a = e2.split(`
|
|
455
|
+
`);
|
|
456
|
+
this.output.write(a[u]), this._prevFrame = e2, this.output.write(import_sisteransi.cursor.move(0, a.length - u - 1));
|
|
457
|
+
return;
|
|
458
|
+
} else if (s.lines.length > 1) {
|
|
459
|
+
if (r < n) u = r;
|
|
460
|
+
else {
|
|
461
|
+
const l = u - n;
|
|
462
|
+
l > 0 && this.output.write(import_sisteransi.cursor.move(0, l));
|
|
463
|
+
}
|
|
464
|
+
this.output.write(import_sisteransi.erase.down());
|
|
465
|
+
const a = e2.split(`
|
|
466
|
+
`).slice(u);
|
|
467
|
+
this.output.write(a.join(`
|
|
468
|
+
`)), this._prevFrame = e2;
|
|
469
|
+
return;
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
this.output.write(import_sisteransi.erase.down());
|
|
473
|
+
}
|
|
474
|
+
this.output.write(e2), this.state === "initial" && (this.state = "active"), this._prevFrame = e2;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
};
|
|
478
|
+
var kt = class extends x {
|
|
479
|
+
static {
|
|
480
|
+
__name(this, "kt");
|
|
481
|
+
}
|
|
482
|
+
get cursor() {
|
|
483
|
+
return this.value ? 0 : 1;
|
|
484
|
+
}
|
|
485
|
+
get _value() {
|
|
486
|
+
return this.cursor === 0;
|
|
487
|
+
}
|
|
488
|
+
constructor(e2) {
|
|
489
|
+
super(e2, false), this.value = !!e2.initialValue, this.on("userInput", () => {
|
|
490
|
+
this.value = this._value;
|
|
491
|
+
}), this.on("confirm", (s) => {
|
|
492
|
+
this.output.write(import_sisteransi.cursor.move(0, -1)), this.value = s, this.state = "submit", this.close();
|
|
493
|
+
}), this.on("cursor", () => {
|
|
494
|
+
this.value = !this.value;
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
};
|
|
498
|
+
var Lt = class extends x {
|
|
499
|
+
static {
|
|
500
|
+
__name(this, "Lt");
|
|
501
|
+
}
|
|
502
|
+
options;
|
|
503
|
+
cursor = 0;
|
|
504
|
+
get _value() {
|
|
505
|
+
return this.options[this.cursor].value;
|
|
506
|
+
}
|
|
507
|
+
get _enabledOptions() {
|
|
508
|
+
return this.options.filter((e2) => e2.disabled !== true);
|
|
509
|
+
}
|
|
510
|
+
toggleAll() {
|
|
511
|
+
const e2 = this._enabledOptions, s = this.value !== void 0 && this.value.length === e2.length;
|
|
512
|
+
this.value = s ? [] : e2.map((i) => i.value);
|
|
513
|
+
}
|
|
514
|
+
toggleInvert() {
|
|
515
|
+
const e2 = this.value;
|
|
516
|
+
if (!e2) return;
|
|
517
|
+
const s = this._enabledOptions.filter((i) => !e2.includes(i.value));
|
|
518
|
+
this.value = s.map((i) => i.value);
|
|
519
|
+
}
|
|
520
|
+
toggleValue() {
|
|
521
|
+
this.value === void 0 && (this.value = []);
|
|
522
|
+
const e2 = this.value.includes(this._value);
|
|
523
|
+
this.value = e2 ? this.value.filter((s) => s !== this._value) : [...this.value, this._value];
|
|
524
|
+
}
|
|
525
|
+
constructor(e2) {
|
|
526
|
+
super(e2, false), this.options = e2.options, this.value = [...e2.initialValues ?? []];
|
|
527
|
+
const s = Math.max(this.options.findIndex(({ value: i }) => i === e2.cursorAt), 0);
|
|
528
|
+
this.cursor = this.options[s].disabled ? B(s, 1, this.options) : s, this.on("key", (i) => {
|
|
529
|
+
i === "a" && this.toggleAll(), i === "i" && this.toggleInvert();
|
|
530
|
+
}), this.on("cursor", (i) => {
|
|
531
|
+
switch (i) {
|
|
532
|
+
case "left":
|
|
533
|
+
case "up":
|
|
534
|
+
this.cursor = B(this.cursor, -1, this.options);
|
|
535
|
+
break;
|
|
536
|
+
case "down":
|
|
537
|
+
case "right":
|
|
538
|
+
this.cursor = B(this.cursor, 1, this.options);
|
|
539
|
+
break;
|
|
540
|
+
case "space":
|
|
541
|
+
this.toggleValue();
|
|
542
|
+
break;
|
|
543
|
+
}
|
|
544
|
+
});
|
|
545
|
+
}
|
|
546
|
+
};
|
|
547
|
+
var Wt = class extends x {
|
|
548
|
+
static {
|
|
549
|
+
__name(this, "Wt");
|
|
550
|
+
}
|
|
551
|
+
options;
|
|
552
|
+
cursor = 0;
|
|
553
|
+
get _selectedValue() {
|
|
554
|
+
return this.options[this.cursor];
|
|
555
|
+
}
|
|
556
|
+
changeValue() {
|
|
557
|
+
this.value = this._selectedValue.value;
|
|
558
|
+
}
|
|
559
|
+
constructor(e2) {
|
|
560
|
+
super(e2, false), this.options = e2.options;
|
|
561
|
+
const s = this.options.findIndex(({ value: r }) => r === e2.initialValue), i = s === -1 ? 0 : s;
|
|
562
|
+
this.cursor = this.options[i].disabled ? B(i, 1, this.options) : i, this.changeValue(), this.on("cursor", (r) => {
|
|
563
|
+
switch (r) {
|
|
564
|
+
case "left":
|
|
565
|
+
case "up":
|
|
566
|
+
this.cursor = B(this.cursor, -1, this.options);
|
|
567
|
+
break;
|
|
568
|
+
case "down":
|
|
569
|
+
case "right":
|
|
570
|
+
this.cursor = B(this.cursor, 1, this.options);
|
|
571
|
+
break;
|
|
572
|
+
}
|
|
573
|
+
this.changeValue();
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
};
|
|
577
|
+
|
|
578
|
+
// ../../node_modules/.pnpm/@clack+prompts@1.0.1/node_modules/@clack/prompts/dist/index.mjs
|
|
579
|
+
var import_picocolors = __toESM(require_picocolors(), 1);
|
|
580
|
+
__toESM(require_src(), 1);
|
|
581
|
+
function me() {
|
|
582
|
+
return N2.platform !== "win32" ? N2.env.TERM !== "linux" : !!N2.env.CI || !!N2.env.WT_SESSION || !!N2.env.TERMINUS_SUBLIME || N2.env.ConEmuTask === "{cmd::Cmder}" || N2.env.TERM_PROGRAM === "Terminus-Sublime" || N2.env.TERM_PROGRAM === "vscode" || N2.env.TERM === "xterm-256color" || N2.env.TERM === "alacritty" || N2.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
583
|
+
}
|
|
584
|
+
__name(me, "me");
|
|
585
|
+
var et2 = me();
|
|
586
|
+
var C = /* @__PURE__ */ __name((t, r) => et2 ? t : r, "C");
|
|
587
|
+
var Rt = C("\u25C6", "*");
|
|
588
|
+
var dt2 = C("\u25A0", "x");
|
|
589
|
+
var $t2 = C("\u25B2", "x");
|
|
590
|
+
var V = C("\u25C7", "o");
|
|
591
|
+
C("\u250C", "T");
|
|
592
|
+
var d = C("\u2502", "|");
|
|
593
|
+
var x2 = C("\u2514", "\u2014");
|
|
594
|
+
C("\u2510", "T");
|
|
595
|
+
C("\u2518", "\u2014");
|
|
596
|
+
var Q2 = C("\u25CF", ">");
|
|
597
|
+
var H2 = C("\u25CB", " ");
|
|
598
|
+
C("\u25FB", "[\u2022]");
|
|
599
|
+
C("\u25FC", "[+]");
|
|
600
|
+
C("\u25FB", "[ ]");
|
|
601
|
+
C("\u25AA", "\u2022");
|
|
602
|
+
C("\u2500", "-");
|
|
603
|
+
C("\u256E", "+");
|
|
604
|
+
C("\u251C", "+");
|
|
605
|
+
C("\u256F", "+");
|
|
606
|
+
C("\u2570", "+");
|
|
607
|
+
C("\u256D", "+");
|
|
608
|
+
C("\u25CF", "\u2022");
|
|
609
|
+
C("\u25C6", "*");
|
|
610
|
+
C("\u25B2", "!");
|
|
611
|
+
C("\u25A0", "x");
|
|
612
|
+
var W2 = /* @__PURE__ */ __name((t) => {
|
|
613
|
+
switch (t) {
|
|
614
|
+
case "initial":
|
|
615
|
+
case "active":
|
|
616
|
+
return import_picocolors.default.cyan(Rt);
|
|
617
|
+
case "cancel":
|
|
618
|
+
return import_picocolors.default.red(dt2);
|
|
619
|
+
case "error":
|
|
620
|
+
return import_picocolors.default.yellow($t2);
|
|
621
|
+
case "submit":
|
|
622
|
+
return import_picocolors.default.green(V);
|
|
623
|
+
}
|
|
624
|
+
}, "W");
|
|
625
|
+
var vt2 = /* @__PURE__ */ __name((t) => {
|
|
626
|
+
switch (t) {
|
|
627
|
+
case "initial":
|
|
628
|
+
case "active":
|
|
629
|
+
return import_picocolors.default.cyan(d);
|
|
630
|
+
case "cancel":
|
|
631
|
+
return import_picocolors.default.red(d);
|
|
632
|
+
case "error":
|
|
633
|
+
return import_picocolors.default.yellow(d);
|
|
634
|
+
case "submit":
|
|
635
|
+
return import_picocolors.default.green(d);
|
|
636
|
+
}
|
|
637
|
+
}, "vt");
|
|
638
|
+
var pe = /* @__PURE__ */ __name((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, "pe");
|
|
639
|
+
var ge = /* @__PURE__ */ __name((t) => t === 12288 || t >= 65281 && t <= 65376 || t >= 65504 && t <= 65510, "ge");
|
|
640
|
+
var fe = /* @__PURE__ */ __name((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, "fe");
|
|
641
|
+
var At2 = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y;
|
|
642
|
+
var it2 = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
|
|
643
|
+
var nt2 = /\t{1,1000}/y;
|
|
644
|
+
var wt = new RegExp("[\\u{1F1E6}-\\u{1F1FF}]{2}|\\u{1F3F4}[\\u{E0061}-\\u{E007A}]{2}[\\u{E0030}-\\u{E0039}\\u{E0061}-\\u{E007A}]{1,3}\\u{E007F}|(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation})(?:\\u200D(?:\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation}|\\p{Emoji}\\uFE0F\\u20E3?))*", "yu");
|
|
645
|
+
var at2 = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
|
|
646
|
+
var Fe = new RegExp("\\p{M}+", "gu");
|
|
647
|
+
var ye = { limit: 1 / 0, ellipsis: "" };
|
|
648
|
+
var jt = /* @__PURE__ */ __name((t, r = {}, s = {}) => {
|
|
649
|
+
const i = r.limit ?? 1 / 0, a = r.ellipsis ?? "", o = r?.ellipsisWidth ?? (a ? jt(a, ye, s).width : 0), u = s.ansiWidth ?? 0, l = s.controlWidth ?? 0, n = s.tabWidth ?? 8, c = s.ambiguousWidth ?? 1, g = s.emojiWidth ?? 2, F = s.fullWidthWidth ?? 2, p = s.regularWidth ?? 1, E = s.wideWidth ?? 2;
|
|
650
|
+
let $ = 0, m = 0, h = t.length, y2 = 0, f = false, v = h, S2 = Math.max(0, i - o), I2 = 0, B2 = 0, A = 0, w = 0;
|
|
651
|
+
t: for (; ; ) {
|
|
652
|
+
if (B2 > I2 || m >= h && m > $) {
|
|
653
|
+
const _3 = t.slice(I2, B2) || t.slice($, m);
|
|
654
|
+
y2 = 0;
|
|
655
|
+
for (const D of _3.replaceAll(Fe, "")) {
|
|
656
|
+
const T2 = D.codePointAt(0) || 0;
|
|
657
|
+
if (ge(T2) ? w = F : fe(T2) ? w = E : c !== p && pe(T2) ? w = c : w = p, A + w > S2 && (v = Math.min(v, Math.max(I2, $) + y2)), A + w > i) {
|
|
658
|
+
f = true;
|
|
659
|
+
break t;
|
|
660
|
+
}
|
|
661
|
+
y2 += D.length, A += w;
|
|
662
|
+
}
|
|
663
|
+
I2 = B2 = 0;
|
|
664
|
+
}
|
|
665
|
+
if (m >= h) break;
|
|
666
|
+
if (at2.lastIndex = m, at2.test(t)) {
|
|
667
|
+
if (y2 = at2.lastIndex - m, w = y2 * p, A + w > S2 && (v = Math.min(v, m + Math.floor((S2 - A) / p))), A + w > i) {
|
|
668
|
+
f = true;
|
|
669
|
+
break;
|
|
670
|
+
}
|
|
671
|
+
A += w, I2 = $, B2 = m, m = $ = at2.lastIndex;
|
|
672
|
+
continue;
|
|
673
|
+
}
|
|
674
|
+
if (At2.lastIndex = m, At2.test(t)) {
|
|
675
|
+
if (A + u > S2 && (v = Math.min(v, m)), A + u > i) {
|
|
676
|
+
f = true;
|
|
677
|
+
break;
|
|
678
|
+
}
|
|
679
|
+
A += u, I2 = $, B2 = m, m = $ = At2.lastIndex;
|
|
680
|
+
continue;
|
|
681
|
+
}
|
|
682
|
+
if (it2.lastIndex = m, it2.test(t)) {
|
|
683
|
+
if (y2 = it2.lastIndex - m, w = y2 * l, A + w > S2 && (v = Math.min(v, m + Math.floor((S2 - A) / l))), A + w > i) {
|
|
684
|
+
f = true;
|
|
685
|
+
break;
|
|
686
|
+
}
|
|
687
|
+
A += w, I2 = $, B2 = m, m = $ = it2.lastIndex;
|
|
688
|
+
continue;
|
|
689
|
+
}
|
|
690
|
+
if (nt2.lastIndex = m, nt2.test(t)) {
|
|
691
|
+
if (y2 = nt2.lastIndex - m, w = y2 * n, A + w > S2 && (v = Math.min(v, m + Math.floor((S2 - A) / n))), A + w > i) {
|
|
692
|
+
f = true;
|
|
693
|
+
break;
|
|
694
|
+
}
|
|
695
|
+
A += w, I2 = $, B2 = m, m = $ = nt2.lastIndex;
|
|
696
|
+
continue;
|
|
697
|
+
}
|
|
698
|
+
if (wt.lastIndex = m, wt.test(t)) {
|
|
699
|
+
if (A + g > S2 && (v = Math.min(v, m)), A + g > i) {
|
|
700
|
+
f = true;
|
|
701
|
+
break;
|
|
702
|
+
}
|
|
703
|
+
A += g, I2 = $, B2 = m, m = $ = wt.lastIndex;
|
|
704
|
+
continue;
|
|
705
|
+
}
|
|
706
|
+
m += 1;
|
|
707
|
+
}
|
|
708
|
+
return { width: f ? S2 : A, index: f ? v : h, truncated: f, ellipsed: f && i >= o };
|
|
709
|
+
}, "jt");
|
|
710
|
+
var Ee = { limit: 1 / 0, ellipsis: "", ellipsisWidth: 0 };
|
|
711
|
+
var M2 = /* @__PURE__ */ __name((t, r = {}) => jt(t, Ee, r).width, "M");
|
|
712
|
+
var ot2 = "\x1B";
|
|
713
|
+
var Gt = "\x9B";
|
|
714
|
+
var ve = 39;
|
|
715
|
+
var Ct2 = "\x07";
|
|
716
|
+
var kt2 = "[";
|
|
717
|
+
var Ae = "]";
|
|
718
|
+
var Vt2 = "m";
|
|
719
|
+
var St = `${Ae}8;;`;
|
|
720
|
+
var Ht = new RegExp(`(?:\\${kt2}(?<code>\\d+)m|\\${St}(?<uri>.*)${Ct2})`, "y");
|
|
721
|
+
var we = /* @__PURE__ */ __name((t) => {
|
|
722
|
+
if (t >= 30 && t <= 37 || t >= 90 && t <= 97) return 39;
|
|
723
|
+
if (t >= 40 && t <= 47 || t >= 100 && t <= 107) return 49;
|
|
724
|
+
if (t === 1 || t === 2) return 22;
|
|
725
|
+
if (t === 3) return 23;
|
|
726
|
+
if (t === 4) return 24;
|
|
727
|
+
if (t === 7) return 27;
|
|
728
|
+
if (t === 8) return 28;
|
|
729
|
+
if (t === 9) return 29;
|
|
730
|
+
if (t === 0) return 0;
|
|
731
|
+
}, "we");
|
|
732
|
+
var Ut = /* @__PURE__ */ __name((t) => `${ot2}${kt2}${t}${Vt2}`, "Ut");
|
|
733
|
+
var Kt = /* @__PURE__ */ __name((t) => `${ot2}${St}${t}${Ct2}`, "Kt");
|
|
734
|
+
var Ce = /* @__PURE__ */ __name((t) => t.map((r) => M2(r)), "Ce");
|
|
735
|
+
var It2 = /* @__PURE__ */ __name((t, r, s) => {
|
|
736
|
+
const i = r[Symbol.iterator]();
|
|
737
|
+
let a = false, o = false, u = t.at(-1), l = u === void 0 ? 0 : M2(u), n = i.next(), c = i.next(), g = 0;
|
|
738
|
+
for (; !n.done; ) {
|
|
739
|
+
const F = n.value, p = M2(F);
|
|
740
|
+
l + p <= s ? t[t.length - 1] += F : (t.push(F), l = 0), (F === ot2 || F === Gt) && (a = true, o = r.startsWith(St, g + 1)), a ? o ? F === Ct2 && (a = false, o = false) : F === Vt2 && (a = false) : (l += p, l === s && !c.done && (t.push(""), l = 0)), n = c, c = i.next(), g += F.length;
|
|
741
|
+
}
|
|
742
|
+
u = t.at(-1), !l && u !== void 0 && u.length > 0 && t.length > 1 && (t[t.length - 2] += t.pop());
|
|
743
|
+
}, "It");
|
|
744
|
+
var Se = /* @__PURE__ */ __name((t) => {
|
|
745
|
+
const r = t.split(" ");
|
|
746
|
+
let s = r.length;
|
|
747
|
+
for (; s > 0 && !(M2(r[s - 1]) > 0); ) s--;
|
|
748
|
+
return s === r.length ? t : r.slice(0, s).join(" ") + r.slice(s).join("");
|
|
749
|
+
}, "Se");
|
|
750
|
+
var Ie = /* @__PURE__ */ __name((t, r, s = {}) => {
|
|
751
|
+
if (s.trim !== false && t.trim() === "") return "";
|
|
752
|
+
let i = "", a, o;
|
|
753
|
+
const u = t.split(" "), l = Ce(u);
|
|
754
|
+
let n = [""];
|
|
755
|
+
for (const [$, m] of u.entries()) {
|
|
756
|
+
s.trim !== false && (n[n.length - 1] = (n.at(-1) ?? "").trimStart());
|
|
757
|
+
let h = M2(n.at(-1) ?? "");
|
|
758
|
+
if ($ !== 0 && (h >= r && (s.wordWrap === false || s.trim === false) && (n.push(""), h = 0), (h > 0 || s.trim === false) && (n[n.length - 1] += " ", h++)), s.hard && l[$] > r) {
|
|
759
|
+
const y2 = r - h, f = 1 + Math.floor((l[$] - y2 - 1) / r);
|
|
760
|
+
Math.floor((l[$] - 1) / r) < f && n.push(""), It2(n, m, r);
|
|
761
|
+
continue;
|
|
762
|
+
}
|
|
763
|
+
if (h + l[$] > r && h > 0 && l[$] > 0) {
|
|
764
|
+
if (s.wordWrap === false && h < r) {
|
|
765
|
+
It2(n, m, r);
|
|
766
|
+
continue;
|
|
767
|
+
}
|
|
768
|
+
n.push("");
|
|
769
|
+
}
|
|
770
|
+
if (h + l[$] > r && s.wordWrap === false) {
|
|
771
|
+
It2(n, m, r);
|
|
772
|
+
continue;
|
|
773
|
+
}
|
|
774
|
+
n[n.length - 1] += m;
|
|
775
|
+
}
|
|
776
|
+
s.trim !== false && (n = n.map(($) => Se($)));
|
|
777
|
+
const c = n.join(`
|
|
778
|
+
`), g = c[Symbol.iterator]();
|
|
779
|
+
let F = g.next(), p = g.next(), E = 0;
|
|
780
|
+
for (; !F.done; ) {
|
|
781
|
+
const $ = F.value, m = p.value;
|
|
782
|
+
if (i += $, $ === ot2 || $ === Gt) {
|
|
783
|
+
Ht.lastIndex = E + 1;
|
|
784
|
+
const f = Ht.exec(c)?.groups;
|
|
785
|
+
if (f?.code !== void 0) {
|
|
786
|
+
const v = Number.parseFloat(f.code);
|
|
787
|
+
a = v === ve ? void 0 : v;
|
|
788
|
+
} else f?.uri !== void 0 && (o = f.uri.length === 0 ? void 0 : f.uri);
|
|
789
|
+
}
|
|
790
|
+
const h = a ? we(a) : void 0;
|
|
791
|
+
m === `
|
|
792
|
+
` ? (o && (i += Kt("")), a && h && (i += Ut(h))) : $ === `
|
|
793
|
+
` && (a && h && (i += Ut(a)), o && (i += Kt(o))), E += $.length, F = p, p = g.next();
|
|
794
|
+
}
|
|
795
|
+
return i;
|
|
796
|
+
}, "Ie");
|
|
797
|
+
function J2(t, r, s) {
|
|
798
|
+
return String(t).normalize().replaceAll(`\r
|
|
799
|
+
`, `
|
|
800
|
+
`).split(`
|
|
801
|
+
`).map((i) => Ie(i, r, s)).join(`
|
|
802
|
+
`);
|
|
803
|
+
}
|
|
804
|
+
__name(J2, "J");
|
|
805
|
+
var be = /* @__PURE__ */ __name((t, r, s, i, a) => {
|
|
806
|
+
let o = r, u = 0;
|
|
807
|
+
for (let l = s; l < i; l++) {
|
|
808
|
+
const n = t[l];
|
|
809
|
+
if (o = o - n.length, u++, o <= a) break;
|
|
810
|
+
}
|
|
811
|
+
return { lineCount: o, removals: u };
|
|
812
|
+
}, "be");
|
|
813
|
+
var X2 = /* @__PURE__ */ __name((t) => {
|
|
814
|
+
const { cursor: r, options: s, style: i } = t, a = t.output ?? process.stdout, o = rt(a), u = t.columnPadding ?? 0, l = t.rowPadding ?? 4, n = o - u, c = nt(a), g = import_picocolors.default.dim("..."), F = t.maxItems ?? Number.POSITIVE_INFINITY, p = Math.max(c - l, 0), E = Math.max(Math.min(F, p), 5);
|
|
815
|
+
let $ = 0;
|
|
816
|
+
r >= E - 3 && ($ = Math.max(Math.min(r - E + 3, s.length - E), 0));
|
|
817
|
+
let m = E < s.length && $ > 0, h = E < s.length && $ + E < s.length;
|
|
818
|
+
const y2 = Math.min($ + E, s.length), f = [];
|
|
819
|
+
let v = 0;
|
|
820
|
+
m && v++, h && v++;
|
|
821
|
+
const S2 = $ + (m ? 1 : 0), I2 = y2 - (h ? 1 : 0);
|
|
822
|
+
for (let A = S2; A < I2; A++) {
|
|
823
|
+
const w = J2(i(s[A], A === r), n, { hard: true, trim: false }).split(`
|
|
824
|
+
`);
|
|
825
|
+
f.push(w), v += w.length;
|
|
826
|
+
}
|
|
827
|
+
if (v > p) {
|
|
828
|
+
let A = 0, w = 0, _3 = v;
|
|
829
|
+
const D = r - S2, T2 = /* @__PURE__ */ __name((Y, L2) => be(f, _3, Y, L2, p), "T");
|
|
830
|
+
m ? ({ lineCount: _3, removals: A } = T2(0, D), _3 > p && ({ lineCount: _3, removals: w } = T2(D + 1, f.length))) : ({ lineCount: _3, removals: w } = T2(D + 1, f.length), _3 > p && ({ lineCount: _3, removals: A } = T2(0, D))), A > 0 && (m = true, f.splice(0, A)), w > 0 && (h = true, f.splice(f.length - w, w));
|
|
831
|
+
}
|
|
832
|
+
const B2 = [];
|
|
833
|
+
m && B2.push(g);
|
|
834
|
+
for (const A of f) for (const w of A) B2.push(w);
|
|
835
|
+
return h && B2.push(g), B2;
|
|
836
|
+
}, "X");
|
|
837
|
+
import_picocolors.default.magenta;
|
|
838
|
+
({ light: C("\u2500", "-"), heavy: C("\u2501", "="), block: C("\u2588", "#") });
|
|
839
|
+
var lt2 = /* @__PURE__ */ __name((t, r) => t.includes(`
|
|
840
|
+
`) ? t.split(`
|
|
841
|
+
`).map((s) => r(s)).join(`
|
|
842
|
+
`) : r(t), "lt");
|
|
843
|
+
var Je = /* @__PURE__ */ __name((t) => {
|
|
844
|
+
const r = /* @__PURE__ */ __name((s, i) => {
|
|
845
|
+
const a = s.label ?? String(s.value);
|
|
846
|
+
switch (i) {
|
|
847
|
+
case "disabled":
|
|
848
|
+
return `${import_picocolors.default.gray(H2)} ${lt2(a, import_picocolors.default.gray)}${s.hint ? ` ${import_picocolors.default.dim(`(${s.hint ?? "disabled"})`)}` : ""}`;
|
|
849
|
+
case "selected":
|
|
850
|
+
return `${lt2(a, import_picocolors.default.dim)}`;
|
|
851
|
+
case "active":
|
|
852
|
+
return `${import_picocolors.default.green(Q2)} ${a}${s.hint ? ` ${import_picocolors.default.dim(`(${s.hint})`)}` : ""}`;
|
|
853
|
+
case "cancelled":
|
|
854
|
+
return `${lt2(a, (o) => import_picocolors.default.strikethrough(import_picocolors.default.dim(o)))}`;
|
|
855
|
+
default:
|
|
856
|
+
return `${import_picocolors.default.dim(H2)} ${lt2(a, import_picocolors.default.dim)}`;
|
|
857
|
+
}
|
|
858
|
+
}, "r");
|
|
859
|
+
return new Wt({ options: t.options, signal: t.signal, input: t.input, output: t.output, initialValue: t.initialValue, render() {
|
|
860
|
+
const s = t.withGuide ?? _.withGuide, i = `${W2(this.state)} `, a = `${vt2(this.state)} `, o = xt(t.output, t.message, a, i), u = `${s ? `${import_picocolors.default.gray(d)}
|
|
861
|
+
` : ""}${o}
|
|
862
|
+
`;
|
|
863
|
+
switch (this.state) {
|
|
864
|
+
case "submit": {
|
|
865
|
+
const l = s ? `${import_picocolors.default.gray(d)} ` : "", n = xt(t.output, r(this.options[this.cursor], "selected"), l);
|
|
866
|
+
return `${u}${n}`;
|
|
867
|
+
}
|
|
868
|
+
case "cancel": {
|
|
869
|
+
const l = s ? `${import_picocolors.default.gray(d)} ` : "", n = xt(t.output, r(this.options[this.cursor], "cancelled"), l);
|
|
870
|
+
return `${u}${n}${s ? `
|
|
871
|
+
${import_picocolors.default.gray(d)}` : ""}`;
|
|
872
|
+
}
|
|
873
|
+
default: {
|
|
874
|
+
const l = s ? `${import_picocolors.default.cyan(d)} ` : "", n = s ? import_picocolors.default.cyan(x2) : "", c = u.split(`
|
|
875
|
+
`).length, g = s ? 2 : 1;
|
|
876
|
+
return `${u}${l}${X2({ output: t.output, cursor: this.cursor, options: this.options, maxItems: t.maxItems, columnPadding: l.length, rowPadding: c + g, style: /* @__PURE__ */ __name((F, p) => r(F, F.disabled ? "disabled" : p ? "active" : "inactive"), "style") }).join(`
|
|
877
|
+
${l}`)}
|
|
878
|
+
${n}
|
|
879
|
+
`;
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
} }).prompt();
|
|
883
|
+
}, "Je");
|
|
884
|
+
`${import_picocolors.default.gray(d)} `;
|
|
885
|
+
var ExecError = class extends Error {
|
|
886
|
+
constructor(exitCode, signal, data = "command gave no output") {
|
|
887
|
+
super(data);
|
|
888
|
+
this.exitCode = exitCode;
|
|
889
|
+
this.signal = signal;
|
|
890
|
+
this.data = data;
|
|
891
|
+
}
|
|
892
|
+
static {
|
|
893
|
+
__name(this, "ExecError");
|
|
894
|
+
}
|
|
895
|
+
};
|
|
896
|
+
function spawnAsyncHelper(command, args, spawnOptions) {
|
|
897
|
+
const childProcess = spawn(command, args, spawnOptions || {});
|
|
898
|
+
const deferred = new Promise((resolve, reject) => {
|
|
899
|
+
let stdoutData = "";
|
|
900
|
+
let stderrData = "";
|
|
901
|
+
childProcess.stdout?.on("data", (data) => {
|
|
902
|
+
stdoutData += data.toString();
|
|
903
|
+
});
|
|
904
|
+
childProcess.stderr?.on("data", (data) => {
|
|
905
|
+
stderrData += data.toString();
|
|
906
|
+
});
|
|
907
|
+
childProcess.stdout?.on("error", (err) => {
|
|
908
|
+
reject(err);
|
|
909
|
+
});
|
|
910
|
+
childProcess.stderr?.on("error", (err) => {
|
|
911
|
+
reject(err);
|
|
912
|
+
});
|
|
913
|
+
childProcess.on("error", (err) => {
|
|
914
|
+
reject(err);
|
|
915
|
+
});
|
|
916
|
+
childProcess.on("exit", (exitCode, signal) => {
|
|
917
|
+
if (!exitCode) {
|
|
918
|
+
resolve(stdoutData);
|
|
919
|
+
} else {
|
|
920
|
+
reject(
|
|
921
|
+
new ExecError(exitCode, signal, stderrData)
|
|
922
|
+
);
|
|
923
|
+
}
|
|
924
|
+
});
|
|
925
|
+
});
|
|
926
|
+
return { childProcess, execResult: deferred };
|
|
927
|
+
}
|
|
928
|
+
__name(spawnAsyncHelper, "spawnAsyncHelper");
|
|
929
|
+
async function spawnAsync(command, args, opts) {
|
|
930
|
+
const { execResult } = spawnAsyncHelper(command, args, opts);
|
|
931
|
+
return execResult;
|
|
932
|
+
}
|
|
933
|
+
__name(spawnAsync, "spawnAsync");
|
|
934
|
+
promisify(exec);
|
|
935
|
+
async function checkIsFileGitIgnored(path3, warnIfNotGitRepo = false) {
|
|
936
|
+
try {
|
|
937
|
+
await spawnAsync("git", ["check-ignore", path3, "-q"], { cwd: dirname(path3) });
|
|
938
|
+
return true;
|
|
939
|
+
} catch (err) {
|
|
940
|
+
const errorOutput = err.data;
|
|
941
|
+
if (err.exitCode === 127 || errorOutput.includes("not found") || errorOutput.includes("not recognized")) {
|
|
942
|
+
return void 0;
|
|
943
|
+
}
|
|
944
|
+
if (err.code === "ENOENT") return void 0;
|
|
945
|
+
if (errorOutput === "") return false;
|
|
946
|
+
if (errorOutput.includes("not a git repository")) {
|
|
947
|
+
if (warnIfNotGitRepo) {
|
|
948
|
+
console.log("\u{1F536} Your code is not currently in a git repository - run `git init` to initialize a new repo.");
|
|
949
|
+
}
|
|
950
|
+
return false;
|
|
951
|
+
}
|
|
952
|
+
if (stderr.includes("is outside repository")) {
|
|
953
|
+
return void 0;
|
|
954
|
+
}
|
|
955
|
+
throw err;
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
__name(checkIsFileGitIgnored, "checkIsFileGitIgnored");
|
|
959
|
+
function isUnicodeSupported() {
|
|
960
|
+
const { env } = N2;
|
|
961
|
+
const { TERM, TERM_PROGRAM } = env;
|
|
962
|
+
if (N2.platform !== "win32") {
|
|
963
|
+
return TERM !== "linux";
|
|
964
|
+
}
|
|
965
|
+
return Boolean(env.WT_SESSION) || Boolean(env.TERMINUS_SUBLIME) || env.ConEmuTask === "{cmd::Cmder}" || TERM_PROGRAM === "Terminus-Sublime" || TERM_PROGRAM === "vscode" || TERM === "xterm-256color" || TERM === "alacritty" || TERM === "rxvt-unicode" || TERM === "rxvt-unicode-256color" || env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
966
|
+
}
|
|
967
|
+
__name(isUnicodeSupported, "isUnicodeSupported");
|
|
968
|
+
|
|
969
|
+
// src/cli/helpers/prompts.ts
|
|
970
|
+
var unicode = isUnicodeSupported();
|
|
971
|
+
var unicodeOr = /* @__PURE__ */ __name((c, fallback) => unicode ? c : fallback, "unicodeOr");
|
|
972
|
+
var S_STEP_ACTIVE = unicodeOr("\u25C6", "*");
|
|
973
|
+
var S_STEP_CANCEL = unicodeOr("\u25A0", "x");
|
|
974
|
+
var S_STEP_ERROR = unicodeOr("\u25B2", "x");
|
|
975
|
+
var S_STEP_SUBMIT = unicodeOr("\u25C7", "o");
|
|
976
|
+
unicodeOr("\u250C", "T");
|
|
977
|
+
var S_BAR = unicodeOr("\u2502", "|");
|
|
978
|
+
var S_BAR_END = unicodeOr("\u2514", "\u2014");
|
|
979
|
+
var S_RADIO_ACTIVE = unicodeOr("\u25CF", ">");
|
|
980
|
+
var S_RADIO_INACTIVE = unicodeOr("\u25CB", " ");
|
|
981
|
+
var S_CHECKBOX_ACTIVE = unicodeOr("\u25FB", "[\u2022]");
|
|
982
|
+
var S_CHECKBOX_SELECTED = unicodeOr("\u25FC", "[+]");
|
|
983
|
+
var S_CHECKBOX_INACTIVE = unicodeOr("\u25FB", "[ ]");
|
|
984
|
+
unicodeOr("\u25AA", "\u2022");
|
|
985
|
+
unicodeOr("\u2500", "-");
|
|
986
|
+
unicodeOr("\u256E", "+");
|
|
987
|
+
unicodeOr("\u251C", "+");
|
|
988
|
+
unicodeOr("\u256F", "+");
|
|
989
|
+
unicodeOr("\u25CF", "\u2022");
|
|
990
|
+
unicodeOr("\u25C6", "*");
|
|
991
|
+
unicodeOr("\u25B2", "!");
|
|
992
|
+
unicodeOr("\u25A0", "x");
|
|
993
|
+
var symbol = /* @__PURE__ */ __name((state) => {
|
|
994
|
+
switch (state) {
|
|
995
|
+
case "initial":
|
|
996
|
+
case "active":
|
|
997
|
+
return ansis_default.cyan(S_STEP_ACTIVE);
|
|
998
|
+
case "cancel":
|
|
999
|
+
return ansis_default.red(S_STEP_CANCEL);
|
|
1000
|
+
case "error":
|
|
1001
|
+
return ansis_default.yellow(S_STEP_ERROR);
|
|
1002
|
+
case "submit":
|
|
1003
|
+
return ansis_default.green(S_STEP_SUBMIT);
|
|
1004
|
+
}
|
|
1005
|
+
}, "symbol");
|
|
1006
|
+
var limitOptions = /* @__PURE__ */ __name((params) => {
|
|
1007
|
+
const { cursor, options, style } = params;
|
|
1008
|
+
const output = params.output ?? process.stdout;
|
|
1009
|
+
const rows = output instanceof WriteStream && output.rows !== void 0 ? output.rows : 10;
|
|
1010
|
+
const paramMaxItems = params.maxItems ?? Number.POSITIVE_INFINITY;
|
|
1011
|
+
const outputMaxItems = Math.max(rows - 4, 0);
|
|
1012
|
+
const maxItems = Math.min(outputMaxItems, Math.max(paramMaxItems, 5));
|
|
1013
|
+
let slidingWindowLocation = 0;
|
|
1014
|
+
if (cursor >= slidingWindowLocation + maxItems - 3) {
|
|
1015
|
+
slidingWindowLocation = Math.max(Math.min(cursor - maxItems + 3, options.length - maxItems), 0);
|
|
1016
|
+
} else if (cursor < slidingWindowLocation + 2) {
|
|
1017
|
+
slidingWindowLocation = Math.max(cursor - 2, 0);
|
|
1018
|
+
}
|
|
1019
|
+
const shouldRenderTopEllipsis = maxItems < options.length && slidingWindowLocation > 0;
|
|
1020
|
+
const shouldRenderBottomEllipsis = maxItems < options.length && slidingWindowLocation + maxItems < options.length;
|
|
1021
|
+
return options.slice(slidingWindowLocation, slidingWindowLocation + maxItems).map((option, i, arr) => {
|
|
1022
|
+
const isTopLimit = i === 0 && shouldRenderTopEllipsis;
|
|
1023
|
+
const isBottomLimit = i === arr.length - 1 && shouldRenderBottomEllipsis;
|
|
1024
|
+
return isTopLimit || isBottomLimit ? ansis_default.dim("...") : style(option, i + slidingWindowLocation === cursor);
|
|
1025
|
+
});
|
|
1026
|
+
}, "limitOptions");
|
|
1027
|
+
var confirm = /* @__PURE__ */ __name((opts) => {
|
|
1028
|
+
const active = opts.active ?? "Yes";
|
|
1029
|
+
const inactive = opts.inactive ?? "No";
|
|
1030
|
+
return new kt({
|
|
1031
|
+
active,
|
|
1032
|
+
inactive,
|
|
1033
|
+
input: opts.input,
|
|
1034
|
+
output: opts.output,
|
|
1035
|
+
initialValue: opts.initialValue ?? true,
|
|
1036
|
+
render() {
|
|
1037
|
+
const title = `
|
|
1038
|
+
${symbol(this.state)} ${opts.message}
|
|
1039
|
+
`;
|
|
1040
|
+
const value = this.value ? active : inactive;
|
|
1041
|
+
switch (this.state) {
|
|
1042
|
+
case "submit":
|
|
1043
|
+
return `${title}\u200E ${ansis_default.dim(value)}`;
|
|
1044
|
+
case "cancel":
|
|
1045
|
+
return `${title}\u200E ${ansis_default.strikethrough(
|
|
1046
|
+
ansis_default.dim(value)
|
|
1047
|
+
)}
|
|
1048
|
+
`;
|
|
1049
|
+
default: {
|
|
1050
|
+
return `${title}\u200E ${this.value ? `${ansis_default.green(S_RADIO_ACTIVE)} ${active}` : `${ansis_default.dim(S_RADIO_INACTIVE)} ${ansis_default.dim(active)}`} ${ansis_default.dim("/")} ${!this.value ? `${ansis_default.green(S_RADIO_ACTIVE)} ${inactive}` : `${ansis_default.dim(S_RADIO_INACTIVE)} ${ansis_default.dim(inactive)}`}
|
|
1051
|
+
`;
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
}).prompt();
|
|
1056
|
+
}, "confirm");
|
|
1057
|
+
var select = /* @__PURE__ */ __name((opts) => {
|
|
1058
|
+
const opt = /* @__PURE__ */ __name((option, state) => {
|
|
1059
|
+
const label = option.label ?? String(option.value);
|
|
1060
|
+
switch (state) {
|
|
1061
|
+
case "selected":
|
|
1062
|
+
return `${ansis_default.dim(label)}`;
|
|
1063
|
+
case "active":
|
|
1064
|
+
return `${ansis_default.green(S_RADIO_ACTIVE)} ${label} ${option.hint ? ansis_default.dim(`(${option.hint})`) : ""}`;
|
|
1065
|
+
case "cancelled":
|
|
1066
|
+
return `${ansis_default.strikethrough(ansis_default.dim(label))}`;
|
|
1067
|
+
default:
|
|
1068
|
+
return `${ansis_default.dim(S_RADIO_INACTIVE)} ${ansis_default.dim(label)}`;
|
|
1069
|
+
}
|
|
1070
|
+
}, "opt");
|
|
1071
|
+
return new Wt({
|
|
1072
|
+
options: opts.options,
|
|
1073
|
+
input: opts.input,
|
|
1074
|
+
output: opts.output,
|
|
1075
|
+
initialValue: opts.initialValue,
|
|
1076
|
+
render() {
|
|
1077
|
+
const title = `${ansis_default.gray(S_BAR)}
|
|
1078
|
+
${symbol(this.state)} ${opts.message}
|
|
1079
|
+
`;
|
|
1080
|
+
switch (this.state) {
|
|
1081
|
+
case "submit":
|
|
1082
|
+
return `${title}${ansis_default.gray(S_BAR)} ${opt(this.options[this.cursor], "selected")}`;
|
|
1083
|
+
case "cancel":
|
|
1084
|
+
return `${title}${ansis_default.gray(S_BAR)} ${opt(
|
|
1085
|
+
this.options[this.cursor],
|
|
1086
|
+
"cancelled"
|
|
1087
|
+
)}
|
|
1088
|
+
${ansis_default.gray(S_BAR)}`;
|
|
1089
|
+
default: {
|
|
1090
|
+
return `${title}${ansis_default.cyan(S_BAR)} ${limitOptions({
|
|
1091
|
+
output: opts.output,
|
|
1092
|
+
cursor: this.cursor,
|
|
1093
|
+
options: this.options,
|
|
1094
|
+
maxItems: opts.maxItems,
|
|
1095
|
+
style: /* @__PURE__ */ __name((item, active) => opt(item, active ? "active" : "inactive"), "style")
|
|
1096
|
+
}).join(`
|
|
1097
|
+
${ansis_default.cyan(S_BAR)} `)}
|
|
1098
|
+
${ansis_default.cyan(S_BAR_END)}
|
|
1099
|
+
`;
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1103
|
+
}).prompt();
|
|
1104
|
+
}, "select");
|
|
1105
|
+
var multiselect = /* @__PURE__ */ __name((opts) => {
|
|
1106
|
+
const opt = /* @__PURE__ */ __name((option, state) => {
|
|
1107
|
+
const label = option.label ?? String(option.value);
|
|
1108
|
+
if (state === "active") {
|
|
1109
|
+
return `${ansis_default.cyan(S_CHECKBOX_ACTIVE)} ${label} ${option.hint ? ansis_default.dim(`(${option.hint})`) : ""}`;
|
|
1110
|
+
}
|
|
1111
|
+
if (state === "selected") {
|
|
1112
|
+
return `${ansis_default.green(S_CHECKBOX_SELECTED)} ${ansis_default.dim(label)} ${option.hint ? ansis_default.dim(`(${option.hint})`) : ""}`;
|
|
1113
|
+
}
|
|
1114
|
+
if (state === "cancelled") {
|
|
1115
|
+
return `${ansis_default.strikethrough(ansis_default.dim(label))}`;
|
|
1116
|
+
}
|
|
1117
|
+
if (state === "active-selected") {
|
|
1118
|
+
return `${ansis_default.green(S_CHECKBOX_SELECTED)} ${label} ${option.hint ? ansis_default.dim(`(${option.hint})`) : ""}`;
|
|
1119
|
+
}
|
|
1120
|
+
if (state === "submitted") {
|
|
1121
|
+
return `${ansis_default.dim(label)}`;
|
|
1122
|
+
}
|
|
1123
|
+
return `${ansis_default.dim(S_CHECKBOX_INACTIVE)} ${ansis_default.dim(label)}`;
|
|
1124
|
+
}, "opt");
|
|
1125
|
+
return new Lt({
|
|
1126
|
+
options: opts.options,
|
|
1127
|
+
input: opts.input,
|
|
1128
|
+
output: opts.output,
|
|
1129
|
+
initialValues: opts.initialValues,
|
|
1130
|
+
required: opts.required ?? true,
|
|
1131
|
+
cursorAt: opts.cursorAt,
|
|
1132
|
+
validate(selected) {
|
|
1133
|
+
if (this.required && selected.length === 0) {
|
|
1134
|
+
return `Please select at least one option.
|
|
1135
|
+
${ansis_default.reset(
|
|
1136
|
+
ansis_default.dim(
|
|
1137
|
+
`Press ${ansis_default.gray(ansis_default.bgWhite(ansis_default.inverse(" space ")))} to select, ${ansis_default.gray(
|
|
1138
|
+
ansis_default.bgWhite(ansis_default.inverse(" enter "))
|
|
1139
|
+
)} to submit`
|
|
1140
|
+
)
|
|
1141
|
+
)}`;
|
|
1142
|
+
}
|
|
1143
|
+
},
|
|
1144
|
+
render() {
|
|
1145
|
+
let title = `${ansis_default.gray(S_BAR)}
|
|
1146
|
+
${symbol(this.state)} ${opts.message}
|
|
1147
|
+
`;
|
|
1148
|
+
if (opts.details) title += `${ansis_default.gray(S_BAR)} ${opts.details}
|
|
1149
|
+
`;
|
|
1150
|
+
const styleOption = /* @__PURE__ */ __name((option, active) => {
|
|
1151
|
+
const selected = this.value.includes(option.value);
|
|
1152
|
+
if (active && selected) {
|
|
1153
|
+
return opt(option, "active-selected");
|
|
1154
|
+
}
|
|
1155
|
+
if (selected) {
|
|
1156
|
+
return opt(option, "selected");
|
|
1157
|
+
}
|
|
1158
|
+
return opt(option, active ? "active" : "inactive");
|
|
1159
|
+
}, "styleOption");
|
|
1160
|
+
switch (this.state) {
|
|
1161
|
+
case "submit": {
|
|
1162
|
+
return `${title}${ansis_default.gray(S_BAR)} ${this.options.filter(({ value }) => this.value.includes(value)).map((option) => opt(option, "submitted")).join(ansis_default.dim(", ")) || ansis_default.dim("none")}`;
|
|
1163
|
+
}
|
|
1164
|
+
case "cancel": {
|
|
1165
|
+
const label = this.options.filter(({ value }) => this.value.includes(value)).map((option) => opt(option, "cancelled")).join(ansis_default.dim(", "));
|
|
1166
|
+
return `${title}${ansis_default.gray(S_BAR)} ${label.trim() ? `${label}
|
|
1167
|
+
${ansis_default.gray(S_BAR)}` : ""}`;
|
|
1168
|
+
}
|
|
1169
|
+
case "error": {
|
|
1170
|
+
const footer = this.error.split("\n").map((ln, i) => i === 0 ? `${ansis_default.yellow(S_BAR_END)} ${ansis_default.yellow(ln)}` : ` ${ln}`).join("\n");
|
|
1171
|
+
return `${title + ansis_default.yellow(S_BAR)} ${limitOptions({
|
|
1172
|
+
output: opts.output,
|
|
1173
|
+
options: this.options,
|
|
1174
|
+
cursor: this.cursor,
|
|
1175
|
+
maxItems: opts.maxItems,
|
|
1176
|
+
style: styleOption
|
|
1177
|
+
}).join(`
|
|
1178
|
+
${ansis_default.yellow(S_BAR)} `)}
|
|
1179
|
+
${footer}
|
|
1180
|
+
`;
|
|
1181
|
+
}
|
|
1182
|
+
default: {
|
|
1183
|
+
return `${title}${ansis_default.cyan(S_BAR)} ${limitOptions({
|
|
1184
|
+
output: opts.output,
|
|
1185
|
+
options: this.options,
|
|
1186
|
+
cursor: this.cursor,
|
|
1187
|
+
maxItems: opts.maxItems,
|
|
1188
|
+
style: styleOption
|
|
1189
|
+
}).join(`
|
|
1190
|
+
${ansis_default.cyan(S_BAR)} `)}
|
|
1191
|
+
${ansis_default.cyan(S_BAR_END)}
|
|
1192
|
+
`;
|
|
1193
|
+
}
|
|
1194
|
+
}
|
|
1195
|
+
}
|
|
1196
|
+
}).prompt();
|
|
1197
|
+
}, "multiselect");
|
|
1198
|
+
var prompts = {
|
|
1199
|
+
confirm,
|
|
1200
|
+
select,
|
|
1201
|
+
multiselect
|
|
1202
|
+
};
|
|
1203
|
+
var prompts_default = prompts;
|
|
1204
|
+
var PUBLIC_PREFIXES = [
|
|
1205
|
+
"PUBLIC",
|
|
1206
|
+
"VITE",
|
|
1207
|
+
"NEXT_PUBLIC",
|
|
1208
|
+
"NUXT_PUBLIC"
|
|
1209
|
+
];
|
|
1210
|
+
var PUBLIC_KEYWORDS = ["PUBLIC"];
|
|
1211
|
+
var SENSITIVE_KEYWORDS = [
|
|
1212
|
+
"SECRET",
|
|
1213
|
+
"API_KEY",
|
|
1214
|
+
"PASSWORD",
|
|
1215
|
+
"TOKEN",
|
|
1216
|
+
"PRIVATE",
|
|
1217
|
+
"CREDENTIALS"
|
|
1218
|
+
];
|
|
1219
|
+
function isValidUrl(val) {
|
|
1220
|
+
try {
|
|
1221
|
+
const u = new URL(val);
|
|
1222
|
+
return true;
|
|
1223
|
+
} catch (err) {
|
|
1224
|
+
return false;
|
|
1225
|
+
}
|
|
1226
|
+
}
|
|
1227
|
+
__name(isValidUrl, "isValidUrl");
|
|
1228
|
+
var EMAIL_REGEX = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
|
1229
|
+
var VALID_NUMBER_REGEX = /^(0|([1-9][0-9]*))?(\.[0-9]+)?$/;
|
|
1230
|
+
function inferItemDecorators(file, itemKey, valueStr) {
|
|
1231
|
+
let itemIsPublic = false;
|
|
1232
|
+
if (PUBLIC_PREFIXES.some((prefix) => itemKey.startsWith(prefix))) itemIsPublic = true;
|
|
1233
|
+
if (PUBLIC_KEYWORDS.some((keyword) => itemKey.includes(keyword))) itemIsPublic = true;
|
|
1234
|
+
let itemIsSensitive = false;
|
|
1235
|
+
if (SENSITIVE_KEYWORDS.some((keyword) => itemKey.includes(keyword))) itemIsSensitive = true;
|
|
1236
|
+
if (itemIsPublic) ; else if (itemIsSensitive) {
|
|
1237
|
+
envSpecUpdater.setItemDecorator(file, itemKey, "sensitive", "true");
|
|
1238
|
+
}
|
|
1239
|
+
if (itemKey === "PORT" || itemKey.endsWith("_PORT")) {
|
|
1240
|
+
envSpecUpdater.setItemDecorator(file, itemKey, "type", "port");
|
|
1241
|
+
} else if (itemKey.endsWith("_EMAIL")) {
|
|
1242
|
+
envSpecUpdater.setItemDecorator(file, itemKey, "type", "email");
|
|
1243
|
+
} else if (itemKey.endsWith("_URL") || itemKey.endsWith("_URI")) {
|
|
1244
|
+
envSpecUpdater.setItemDecorator(file, itemKey, "type", "url");
|
|
1245
|
+
} else if (valueStr) {
|
|
1246
|
+
if (valueStr.startsWith("<") && valueStr.endsWith(">")) {
|
|
1247
|
+
envSpecUpdater.setItemDecorator(file, itemKey, "example", valueStr);
|
|
1248
|
+
}
|
|
1249
|
+
if (valueStr === "true" || valueStr === "false") {
|
|
1250
|
+
envSpecUpdater.setItemDecorator(file, itemKey, "type", "boolean");
|
|
1251
|
+
} else if (EMAIL_REGEX.test(valueStr)) {
|
|
1252
|
+
envSpecUpdater.setItemDecorator(file, itemKey, "type", "email");
|
|
1253
|
+
} else if (valueStr !== "0" && valueStr !== "1" && VALID_NUMBER_REGEX.test(valueStr)) {
|
|
1254
|
+
envSpecUpdater.setItemDecorator(file, itemKey, "type", "number");
|
|
1255
|
+
} else if (isValidUrl(valueStr)) {
|
|
1256
|
+
envSpecUpdater.setItemDecorator(file, itemKey, "type", "url");
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1260
|
+
__name(inferItemDecorators, "inferItemDecorators");
|
|
1261
|
+
function inferSchemaUpdates(file) {
|
|
1262
|
+
for (const item of file.configItems) {
|
|
1263
|
+
const valueStr = item.value instanceof ParsedEnvSpecStaticValue && item.value.value?.toString() || "";
|
|
1264
|
+
inferItemDecorators(file, item.key, valueStr);
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
1267
|
+
__name(inferSchemaUpdates, "inferSchemaUpdates");
|
|
1268
|
+
function ensureAllItemsExist(schemaFile, otherFiles) {
|
|
1269
|
+
const addedItemKeys = [];
|
|
1270
|
+
for (const otherFile of otherFiles) {
|
|
1271
|
+
for (const item of otherFile.parsedFile.configItems) {
|
|
1272
|
+
const itemInSchema = schemaFile.configItems.find((i) => i.key === item.key);
|
|
1273
|
+
if (itemInSchema) continue;
|
|
1274
|
+
if (addedItemKeys.length === 0) {
|
|
1275
|
+
envSpecUpdater.injectFromStr(schemaFile, [
|
|
1276
|
+
"",
|
|
1277
|
+
"# items added to schema by `varlock init`",
|
|
1278
|
+
"# that were missing in example, but detected in other .env files",
|
|
1279
|
+
"# PLEASE REVIEW THESE!",
|
|
1280
|
+
"# ---",
|
|
1281
|
+
""
|
|
1282
|
+
].join("\n"), { location: "end" });
|
|
1283
|
+
}
|
|
1284
|
+
addedItemKeys.push(item.key);
|
|
1285
|
+
envSpecUpdater.injectFromStr(schemaFile, `${item.key}=`);
|
|
1286
|
+
const itemValue = item.value instanceof ParsedEnvSpecStaticValue && item.value.value?.toString() || "";
|
|
1287
|
+
inferItemDecorators(schemaFile, item.key, String(itemValue));
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
__name(ensureAllItemsExist, "ensureAllItemsExist");
|
|
1292
|
+
async function detectRedundantValues(schemaFile, otherFiles, opts = {}) {
|
|
1293
|
+
const redundantItemsBySourcePath = {};
|
|
1294
|
+
const schemaValues = schemaFile.toSimpleObj();
|
|
1295
|
+
for (const otherFile of Object.values(otherFiles)) {
|
|
1296
|
+
if (otherFile.fileName.startsWith(".env.schema") || otherFile.fileName.startsWith(".env.example") || otherFile.fileName.startsWith(".env.sample") || otherFile.fileName.startsWith(".env.default")) continue;
|
|
1297
|
+
const otherFileValues = otherFile.parsedFile.toSimpleObj();
|
|
1298
|
+
for (const itemKey in otherFileValues) {
|
|
1299
|
+
if (!(itemKey in schemaValues)) continue;
|
|
1300
|
+
if (otherFileValues[itemKey] !== schemaValues[itemKey]) continue;
|
|
1301
|
+
redundantItemsBySourcePath[otherFile.fullPath] ||= [];
|
|
1302
|
+
redundantItemsBySourcePath[otherFile.fullPath].push(itemKey);
|
|
1303
|
+
if (opts.delete) {
|
|
1304
|
+
envSpecUpdater.deleteItem(otherFile.parsedFile, itemKey);
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1307
|
+
if (opts.delete) {
|
|
1308
|
+
await fs3.writeFile(otherFile.fullPath, otherFile.parsedFile.toString(), "utf8");
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
return redundantItemsBySourcePath;
|
|
1312
|
+
}
|
|
1313
|
+
__name(detectRedundantValues, "detectRedundantValues");
|
|
1314
|
+
var SKIP_FILE_TYPES = [".md", ".d.ts"];
|
|
1315
|
+
async function findEnvFiles(opts) {
|
|
1316
|
+
const cwd = opts?.cwd || process.cwd();
|
|
1317
|
+
const envFiles = [];
|
|
1318
|
+
const filesWithinDir = await fs3.readdir(cwd);
|
|
1319
|
+
for (const fileName of filesWithinDir) {
|
|
1320
|
+
if (fileName === ".env" || fileName.startsWith(".env.")) {
|
|
1321
|
+
let skip = false;
|
|
1322
|
+
for (const fileType of SKIP_FILE_TYPES) {
|
|
1323
|
+
if (fileName.endsWith(fileType)) skip = true;
|
|
1324
|
+
}
|
|
1325
|
+
if (skip) continue;
|
|
1326
|
+
envFiles.push(path2.join(cwd, fileName));
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
1329
|
+
return envFiles;
|
|
1330
|
+
}
|
|
1331
|
+
__name(findEnvFiles, "findEnvFiles");
|
|
1332
|
+
|
|
1333
|
+
// src/cli/commands/init.command.ts
|
|
1334
|
+
var commandSpec = define({
|
|
1335
|
+
name: "init",
|
|
1336
|
+
description: "Set up varlock in the current project",
|
|
1337
|
+
args: {},
|
|
1338
|
+
examples: `
|
|
1339
|
+
This command starts an interactive onboarding process to help you get started with Varlock.
|
|
1340
|
+
It will:
|
|
1341
|
+
- Scan for existing .env files in your project
|
|
1342
|
+
- Help create a .env.schema file from your .env.example or .env.sample file
|
|
1343
|
+
- Install varlock as a dependency in package.json (if applicable)
|
|
1344
|
+
|
|
1345
|
+
\u{1F4CD} Run this command in directories that contain .env or .env.* files
|
|
1346
|
+
|
|
1347
|
+
Examples:
|
|
1348
|
+
varlock init # Run in the current directory
|
|
1349
|
+
cd path/to/your/project && varlock init
|
|
1350
|
+
|
|
1351
|
+
For more information, visit https://varlock.dev/getting-started/installation
|
|
1352
|
+
`.trim()
|
|
1353
|
+
});
|
|
1354
|
+
var commandFn = /* @__PURE__ */ __name(async (ctx) => {
|
|
1355
|
+
const jsPackageManager = detectJsPackageManager();
|
|
1356
|
+
console.log("\u{1F9D9} Hello and welcome to Varlock \u{1F512}\u{1F525}\u2728");
|
|
1357
|
+
const envFilePaths = await findEnvFiles();
|
|
1358
|
+
const parsedEnvFiles = {};
|
|
1359
|
+
for (const filePath of envFilePaths) {
|
|
1360
|
+
const fileContents = await fs3.readFile(filePath, "utf-8");
|
|
1361
|
+
const fileName = path2.basename(filePath);
|
|
1362
|
+
const parsedFile = await tryCatch(async () => parseEnvSpecDotEnvFile(fileContents), () => {
|
|
1363
|
+
logLines([
|
|
1364
|
+
"",
|
|
1365
|
+
`Unable to parse ${fmt.filePath(filePath)}`,
|
|
1366
|
+
"This file will be skipped."
|
|
1367
|
+
]);
|
|
1368
|
+
});
|
|
1369
|
+
if (!parsedFile) {
|
|
1370
|
+
continue;
|
|
1371
|
+
}
|
|
1372
|
+
parsedEnvFiles[fileName] = {
|
|
1373
|
+
fileName,
|
|
1374
|
+
fullPath: filePath,
|
|
1375
|
+
parsedFile
|
|
1376
|
+
};
|
|
1377
|
+
}
|
|
1378
|
+
const existingSchemaFile = parsedEnvFiles[".env.schema"];
|
|
1379
|
+
if (existingSchemaFile) {
|
|
1380
|
+
logLines([
|
|
1381
|
+
`It looks like you already have a ${fmt.fileName(".env.schema")} file \u{1F389}`,
|
|
1382
|
+
"This init helper is meant to help you get a new project set up.",
|
|
1383
|
+
"If you need to make changes to your schema or values, you can update your files directly.",
|
|
1384
|
+
"See more docs at https://varlock.dev/guides/schema"
|
|
1385
|
+
]);
|
|
1386
|
+
} else {
|
|
1387
|
+
const allExampleFileNames = Object.keys(parsedEnvFiles).filter((fileName) => {
|
|
1388
|
+
return fileName.startsWith(".env.example") || fileName.startsWith(".env.sample");
|
|
1389
|
+
});
|
|
1390
|
+
let exampleFileToConvert;
|
|
1391
|
+
if (allExampleFileNames.length === 1) {
|
|
1392
|
+
exampleFileToConvert = parsedEnvFiles[allExampleFileNames[0]];
|
|
1393
|
+
} else if (allExampleFileNames.length > 1) {
|
|
1394
|
+
console.log("");
|
|
1395
|
+
const selectedExample = await Je({
|
|
1396
|
+
message: `We detected more than one example .env file. Which one should we use to create your new ${fmt.fileName(".env.schema")}?`,
|
|
1397
|
+
options: allExampleFileNames.map((fileName) => ({
|
|
1398
|
+
label: fileName,
|
|
1399
|
+
value: parsedEnvFiles[fileName]
|
|
1400
|
+
}))
|
|
1401
|
+
});
|
|
1402
|
+
if (Ct(selectedExample)) return gracefulExit(0);
|
|
1403
|
+
exampleFileToConvert = selectedExample;
|
|
1404
|
+
}
|
|
1405
|
+
const parsedEnvSchemaFile = exampleFileToConvert?.parsedFile || parseEnvSpecDotEnvFile("");
|
|
1406
|
+
if (!parsedEnvSchemaFile) throw new Error("expected parsed .env example file");
|
|
1407
|
+
envSpecUpdater.ensureHeader(parsedEnvSchemaFile, [
|
|
1408
|
+
"This env file uses @env-spec - see https://varlock.dev/env-spec for more info",
|
|
1409
|
+
""
|
|
1410
|
+
// TODO: add env spec version? real links?
|
|
1411
|
+
].join("\n"));
|
|
1412
|
+
envSpecUpdater.setRootDecorator(parsedEnvSchemaFile, "defaultRequired", "infer", { explicitTrue: true });
|
|
1413
|
+
envSpecUpdater.setRootDecorator(parsedEnvSchemaFile, "defaultSensitive", "false", { explicitTrue: true });
|
|
1414
|
+
envSpecUpdater.setRootDecorator(parsedEnvSchemaFile, "generateTypes", "lang=ts, path=env.d.ts", { bareFnArgs: true });
|
|
1415
|
+
envSpecUpdater.injectFromStr(parsedEnvSchemaFile, [
|
|
1416
|
+
"",
|
|
1417
|
+
"# example env variable injected by `varlock init` \u26A0\uFE0F DELETE THIS ITEM! \u26A0\uFE0F",
|
|
1418
|
+
'# @required @sensitive @example="example value"',
|
|
1419
|
+
'EXAMPLE_ITEM="delete me!"',
|
|
1420
|
+
""
|
|
1421
|
+
].join("\n"), { location: "after_header" });
|
|
1422
|
+
inferSchemaUpdates(parsedEnvSchemaFile);
|
|
1423
|
+
ensureAllItemsExist(parsedEnvSchemaFile, Object.values(parsedEnvFiles));
|
|
1424
|
+
const schemaFilePath = path2.join(process.cwd(), ".env.schema");
|
|
1425
|
+
await fs3.writeFile(schemaFilePath, parsedEnvSchemaFile.toString());
|
|
1426
|
+
if (exampleFileToConvert) {
|
|
1427
|
+
logLines([
|
|
1428
|
+
"",
|
|
1429
|
+
`Your ${fmt.fileName(exampleFileToConvert.fileName)} has been used to generate your new ${fmt.fileName(".env.schema")}:`,
|
|
1430
|
+
fmt.filePath(schemaFilePath)
|
|
1431
|
+
]);
|
|
1432
|
+
} else {
|
|
1433
|
+
logLines([
|
|
1434
|
+
"",
|
|
1435
|
+
`Your new ${fmt.fileName(".env.schema")} file has been created:`,
|
|
1436
|
+
fmt.filePath(schemaFilePath)
|
|
1437
|
+
]);
|
|
1438
|
+
}
|
|
1439
|
+
if (await checkIsFileGitIgnored(schemaFilePath)) {
|
|
1440
|
+
logLines([ansis_default.dim(`(and updated ${fmt.fileName(".gitignore")} to ensure it will be tracked by git)`)]);
|
|
1441
|
+
await fs3.appendFile(".gitignore", "\n!.env.schema");
|
|
1442
|
+
}
|
|
1443
|
+
logLines([
|
|
1444
|
+
"",
|
|
1445
|
+
ansis_default.bold(`\u{1F6A7} Please review and update your new ${fmt.fileName(".env.schema")} file! \u{1F6A7}`),
|
|
1446
|
+
`We've done our best to get you started, but you must review and make sure it is correct!`,
|
|
1447
|
+
"",
|
|
1448
|
+
`\u{1F449} Some helpful pointers to get you started:`,
|
|
1449
|
+
`- add a description to each item when the name is not self explanitory - it will come through in generated types`,
|
|
1450
|
+
`- use ${fmt.decorator("@required")} (or ${fmt.decorator("@optional")}) to tag items that should fail validation when empty`,
|
|
1451
|
+
`- use ${fmt.decorator("@sensitive")} to tag items that contain sensitive secrets, and must be handled accordingly`,
|
|
1452
|
+
`- use ${fmt.decorator("@type")} to set an item's data type (if not a basic string), which affects validation and coercion logic`,
|
|
1453
|
+
`- if an item value is a ${ansis_default.italic("useful example")} rather than a default, use ${fmt.decorator("@example")}`,
|
|
1454
|
+
`- if an item value is just a dummy placeholder, delete it`
|
|
1455
|
+
]);
|
|
1456
|
+
const confirmReviewed = await prompts_default.confirm({
|
|
1457
|
+
message: `Have you reviewed and updated your new ${fmt.fileName(".env.schema")} file?`
|
|
1458
|
+
});
|
|
1459
|
+
if (Ct(confirmReviewed)) return gracefulExit(0);
|
|
1460
|
+
const reloadedSchemaFile = await parseEnvSpecDotEnvFile(await fs3.readFile(schemaFilePath, "utf-8"));
|
|
1461
|
+
if (reloadedSchemaFile.configItems.find((i) => i.key === "EXAMPLE_ITEM")) {
|
|
1462
|
+
logLines([
|
|
1463
|
+
"",
|
|
1464
|
+
ansis_default.bold(`\u{1F6A8} Really? ${ansis_default.red("You didn't remove the EXAMPLE_ITEM!")}`),
|
|
1465
|
+
`Please make sure your schema is all correct before using it...`
|
|
1466
|
+
]);
|
|
1467
|
+
}
|
|
1468
|
+
if (exampleFileToConvert) {
|
|
1469
|
+
const confirmDeleteExample = await prompts_default.confirm({
|
|
1470
|
+
message: `Should we delete your ${fmt.fileName(exampleFileToConvert.fileName)} file? ${ansis_default.italic.gray("(you can always do this yourself later)")}`
|
|
1471
|
+
});
|
|
1472
|
+
if (Ct(confirmDeleteExample)) return gracefulExit(0);
|
|
1473
|
+
if (confirmDeleteExample) {
|
|
1474
|
+
await fs3.unlink(exampleFileToConvert.fullPath);
|
|
1475
|
+
}
|
|
1476
|
+
}
|
|
1477
|
+
const defaultsFile = Object.values(parsedEnvFiles).find((f) => {
|
|
1478
|
+
return f.fileName.startsWith(".env.default");
|
|
1479
|
+
});
|
|
1480
|
+
if (defaultsFile) {
|
|
1481
|
+
logLines([
|
|
1482
|
+
"",
|
|
1483
|
+
`\u{1F6A7} We detected a ${fmt.fileName(defaultsFile.fileName)} file in your project`,
|
|
1484
|
+
`You should migrate these default values into ${fmt.fileName(".env.schema")} and delete it.`
|
|
1485
|
+
]);
|
|
1486
|
+
}
|
|
1487
|
+
const redundantInfo = await detectRedundantValues(parsedEnvSchemaFile, parsedEnvFiles);
|
|
1488
|
+
if (Object.keys(redundantInfo).length > 0) {
|
|
1489
|
+
logLines([
|
|
1490
|
+
"",
|
|
1491
|
+
ansis_default.bold("\u203C\uFE0F Now that your schema contains defaults, some values in your other .env files are redundant:")
|
|
1492
|
+
]);
|
|
1493
|
+
for (const [sourcePath, itemKeys] of Object.entries(redundantInfo)) {
|
|
1494
|
+
console.log(fmt.filePath(sourcePath));
|
|
1495
|
+
console.log(" ", itemKeys.map((k2) => ansis_default.italic(k2)).join(", "));
|
|
1496
|
+
}
|
|
1497
|
+
const confirmDeleteRedundant = await prompts_default.confirm({
|
|
1498
|
+
message: "Should we delete these redundant values from your other .env files?"
|
|
1499
|
+
});
|
|
1500
|
+
if (Ct(confirmDeleteRedundant)) return gracefulExit(0);
|
|
1501
|
+
if (confirmDeleteRedundant) {
|
|
1502
|
+
await detectRedundantValues(parsedEnvSchemaFile, parsedEnvFiles, { delete: true });
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
logLines([
|
|
1506
|
+
"",
|
|
1507
|
+
ansis_default.bold("\u{1F389} Great!"),
|
|
1508
|
+
`You can run ${fmt.command("varlock load", { jsPackageManager })} to attempt loading your env vars validate against your new schema.`,
|
|
1509
|
+
"",
|
|
1510
|
+
"Check out our docs for more info about integrating into your application.",
|
|
1511
|
+
"",
|
|
1512
|
+
"\u{1F4D6} https://varlock.dev \u{1F448}",
|
|
1513
|
+
""
|
|
1514
|
+
]);
|
|
1515
|
+
}
|
|
1516
|
+
if (jsPackageManager && await pathExists(path2.join(process.cwd(), "package.json"))) {
|
|
1517
|
+
const installResult = installJsDependency({
|
|
1518
|
+
packageManager: jsPackageManager.name,
|
|
1519
|
+
packageName: "varlock"
|
|
1520
|
+
});
|
|
1521
|
+
if (installResult) {
|
|
1522
|
+
logLines([
|
|
1523
|
+
"",
|
|
1524
|
+
`\u2705 Added ${fmt.packageName("varlock")} as a dependency in your package.json`
|
|
1525
|
+
]);
|
|
1526
|
+
}
|
|
1527
|
+
}
|
|
1528
|
+
}, "commandFn");
|
|
1529
|
+
|
|
1530
|
+
export { commandFn, commandSpec };
|
|
1531
|
+
//# sourceMappingURL=chunk-YIXN7TC7.js.map
|
|
1532
|
+
//# sourceMappingURL=chunk-YIXN7TC7.js.map
|