create-young-proj 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.mjs +42 -2702
- package/package.json +1 -1
- package/template-vue-admin/Dockerfile +2 -2
- package/template-vue-admin/build/custom-plugin.ts +30 -3
- package/template-vue-admin/package.json +30 -29
- package/template-vue-admin/plugins/{env.ts → init.ts} +6 -1
- package/template-vue-admin/src/apis/get.ts +1 -2
- package/template-vue-admin/src/apis/patch.ts +0 -1
- package/template-vue-admin/src/apis/post.ts +1 -2
- package/template-vue-admin/src/auto-components.d.ts +4 -2
- package/template-vue-admin/src/auto-imports.d.ts +21 -1
- package/template-vue-admin/src/main.ts +2 -0
- package/template-vue-admin/src/modules/1-router.ts +4 -22
- package/template-vue-admin/src/modules/3-net.ts +6 -2
- package/template-vue-admin/src/modules/4-auth.ts +16 -18
- package/template-vue-admin/src/modules/5-checkupdate.ts +38 -0
- package/template-vue-admin/src/stores/local/index.ts +9 -1
- package/template-vue-admin/src/typings/index.ts +1 -38
- package/template-vue-admin/src/typings/system.d.ts +46 -0
- package/template-vue-admin/src/views/403.vue +2 -1
- package/template-vue-admin/src/views/[...all_404].vue +3 -2
- package/template-vue-admin/src/views/base/login.vue +2 -1
- package/template-vue-admin/src/views/dashboard/[name].vue +7 -2
- package/template-vue-admin/src/views/index.vue +7 -1
- package/template-vue-admin/src/views/system/api.vue +0 -1
- package/template-vue-admin/src/views/system/menuList.vue +1 -2
- package/template-vue-admin/src/views/system/role.vue +0 -1
- package/template-vue-admin/src/views/system/user.vue +0 -1
package/dist/index.mjs
CHANGED
@@ -1,2711 +1,51 @@
|
|
1
|
-
import T from 'node:fs';
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
var s = at;
|
26
|
-
function t(n, r) {
|
27
|
-
var l = r.pathExt !== void 0 ? r.pathExt : process.env.PATHEXT;
|
28
|
-
if (!l || ((l = l.split(';')), l.indexOf('') !== -1)) return !0;
|
29
|
-
for (var c = 0; c < l.length; c++) {
|
30
|
-
var h = l[c].toLowerCase();
|
31
|
-
if (h && n.substr(-h.length).toLowerCase() === h) return !0;
|
32
|
-
}
|
33
|
-
return !1;
|
34
|
-
}
|
35
|
-
function e(n, r, l) {
|
36
|
-
return !n.isSymbolicLink() && !n.isFile() ? !1 : t(r, l);
|
37
|
-
}
|
38
|
-
function i(n, r, l) {
|
39
|
-
s.stat(n, function (c, h) {
|
40
|
-
l(c, c ? !1 : e(h, n, r));
|
41
|
-
});
|
42
|
-
}
|
43
|
-
function o(n, r) {
|
44
|
-
return e(s.statSync(n), n, r);
|
45
|
-
}
|
46
|
-
return ht;
|
47
|
-
}
|
48
|
-
var ut, Ft;
|
49
|
-
function He() {
|
50
|
-
if (Ft) return ut;
|
51
|
-
(Ft = 1), (ut = t), (t.sync = e);
|
52
|
-
var s = at;
|
53
|
-
function t(n, r, l) {
|
54
|
-
s.stat(n, function (c, h) {
|
55
|
-
l(c, c ? !1 : i(h, r));
|
56
|
-
});
|
57
|
-
}
|
58
|
-
function e(n, r) {
|
59
|
-
return i(s.statSync(n), r);
|
60
|
-
}
|
61
|
-
function i(n, r) {
|
62
|
-
return n.isFile() && o(n, r);
|
63
|
-
}
|
64
|
-
function o(n, r) {
|
65
|
-
var l = n.mode,
|
66
|
-
c = n.uid,
|
67
|
-
h = n.gid,
|
68
|
-
$ = r.uid !== void 0 ? r.uid : process.getuid && process.getuid(),
|
69
|
-
f = r.gid !== void 0 ? r.gid : process.getgid && process.getgid(),
|
70
|
-
a = parseInt('100', 8),
|
71
|
-
b = parseInt('010', 8),
|
72
|
-
p = parseInt('001', 8),
|
73
|
-
S = a | b,
|
74
|
-
E = l & p || (l & b && h === f) || (l & a && c === $) || (l & S && $ === 0);
|
75
|
-
return E;
|
76
|
-
}
|
77
|
-
return ut;
|
78
|
-
}
|
79
|
-
var tt;
|
80
|
-
process.platform === 'win32' || Ve.TESTING_WINDOWS ? (tt = Ye()) : (tt = He());
|
81
|
-
var Be = ct;
|
82
|
-
ct.sync = Ue;
|
83
|
-
function ct(s, t, e) {
|
84
|
-
if ((typeof t == 'function' && ((e = t), (t = {})), !e)) {
|
85
|
-
if (typeof Promise != 'function') throw new TypeError('callback not provided');
|
86
|
-
return new Promise(function (i, o) {
|
87
|
-
ct(s, t || {}, function (n, r) {
|
88
|
-
n ? o(n) : i(r);
|
89
|
-
});
|
90
|
-
});
|
91
|
-
}
|
92
|
-
tt(s, t || {}, function (i, o) {
|
93
|
-
i && (i.code === 'EACCES' || (t && t.ignoreErrors)) && ((i = null), (o = !1)), e(i, o);
|
94
|
-
});
|
95
|
-
}
|
96
|
-
function Ue(s, t) {
|
97
|
-
try {
|
98
|
-
return tt.sync(s, t || {});
|
99
|
-
} catch (e) {
|
100
|
-
if ((t && t.ignoreErrors) || e.code === 'EACCES') return !1;
|
101
|
-
throw e;
|
102
|
-
}
|
103
|
-
}
|
104
|
-
const U =
|
105
|
-
process.platform === 'win32' ||
|
106
|
-
process.env.OSTYPE === 'cygwin' ||
|
107
|
-
process.env.OSTYPE === 'msys',
|
108
|
-
Lt = lt,
|
109
|
-
ze = U ? ';' : ':',
|
110
|
-
Vt = Be,
|
111
|
-
Yt = (s) => Object.assign(new Error(`not found: ${s}`), { code: 'ENOENT' }),
|
112
|
-
Ht = (s, t) => {
|
113
|
-
const e = t.colon || ze,
|
114
|
-
i =
|
115
|
-
s.match(/\//) || (U && s.match(/\\/))
|
116
|
-
? ['']
|
117
|
-
: [...(U ? [process.cwd()] : []), ...(t.path || process.env.PATH || '').split(e)],
|
118
|
-
o = U ? t.pathExt || process.env.PATHEXT || '.EXE;.CMD;.BAT;.COM' : '',
|
119
|
-
n = U ? o.split(e) : [''];
|
120
|
-
return (
|
121
|
-
U && s.indexOf('.') !== -1 && n[0] !== '' && n.unshift(''),
|
122
|
-
{ pathEnv: i, pathExt: n, pathExtExe: o }
|
123
|
-
);
|
124
|
-
},
|
125
|
-
Bt = (s, t, e) => {
|
126
|
-
typeof t == 'function' && ((e = t), (t = {})), t || (t = {});
|
127
|
-
const { pathEnv: i, pathExt: o, pathExtExe: n } = Ht(s, t),
|
128
|
-
r = [],
|
129
|
-
l = (h) =>
|
130
|
-
new Promise(($, f) => {
|
131
|
-
if (h === i.length) return t.all && r.length ? $(r) : f(Yt(s));
|
132
|
-
const a = i[h],
|
133
|
-
b = /^".*"$/.test(a) ? a.slice(1, -1) : a,
|
134
|
-
p = Lt.join(b, s),
|
135
|
-
S = !b && /^\.[\\\/]/.test(s) ? s.slice(0, 2) + p : p;
|
136
|
-
$(c(S, h, 0));
|
137
|
-
}),
|
138
|
-
c = (h, $, f) =>
|
139
|
-
new Promise((a, b) => {
|
140
|
-
if (f === o.length) return a(l($ + 1));
|
141
|
-
const p = o[f];
|
142
|
-
Vt(h + p, { pathExt: n }, (S, E) => {
|
143
|
-
if (!S && E)
|
144
|
-
if (t.all) r.push(h + p);
|
145
|
-
else return a(h + p);
|
146
|
-
return a(c(h, $, f + 1));
|
147
|
-
});
|
148
|
-
});
|
149
|
-
return e ? l(0).then((h) => e(null, h), e) : l(0);
|
150
|
-
},
|
151
|
-
We = (s, t) => {
|
152
|
-
t = t || {};
|
153
|
-
const { pathEnv: e, pathExt: i, pathExtExe: o } = Ht(s, t),
|
154
|
-
n = [];
|
155
|
-
for (let r = 0; r < e.length; r++) {
|
156
|
-
const l = e[r],
|
157
|
-
c = /^".*"$/.test(l) ? l.slice(1, -1) : l,
|
158
|
-
h = Lt.join(c, s),
|
159
|
-
$ = !c && /^\.[\\\/]/.test(s) ? s.slice(0, 2) + h : h;
|
160
|
-
for (let f = 0; f < i.length; f++) {
|
161
|
-
const a = $ + i[f];
|
162
|
-
try {
|
163
|
-
if (Vt.sync(a, { pathExt: o }))
|
164
|
-
if (t.all) n.push(a);
|
165
|
-
else return a;
|
166
|
-
} catch {}
|
167
|
-
}
|
168
|
-
}
|
169
|
-
if (t.all && n.length) return n;
|
170
|
-
if (t.nothrow) return null;
|
171
|
-
throw Yt(s);
|
172
|
-
};
|
173
|
-
var Ge = Bt;
|
174
|
-
Bt.sync = We;
|
175
|
-
var dt = { exports: {} };
|
176
|
-
const Ut = (s = {}) => {
|
177
|
-
const t = s.env || process.env;
|
178
|
-
return (s.platform || process.platform) !== 'win32'
|
179
|
-
? 'PATH'
|
180
|
-
: Object.keys(t)
|
181
|
-
.reverse()
|
182
|
-
.find((i) => i.toUpperCase() === 'PATH') || 'Path';
|
183
|
-
};
|
184
|
-
(dt.exports = Ut), (dt.exports.default = Ut);
|
185
|
-
const zt = lt,
|
186
|
-
Je = Ge,
|
187
|
-
Ke = dt.exports;
|
188
|
-
function Wt(s, t) {
|
189
|
-
const e = s.options.env || process.env,
|
190
|
-
i = process.cwd(),
|
191
|
-
o = s.options.cwd != null,
|
192
|
-
n = o && process.chdir !== void 0 && !process.chdir.disabled;
|
193
|
-
if (n)
|
194
|
-
try {
|
195
|
-
process.chdir(s.options.cwd);
|
196
|
-
} catch {}
|
197
|
-
let r;
|
198
|
-
try {
|
199
|
-
r = Je.sync(s.command, { path: e[Ke({ env: e })], pathExt: t ? zt.delimiter : void 0 });
|
200
|
-
} catch {
|
201
|
-
} finally {
|
202
|
-
n && process.chdir(i);
|
203
|
-
}
|
204
|
-
return r && (r = zt.resolve(o ? s.options.cwd : '', r)), r;
|
205
|
-
}
|
206
|
-
function qe(s) {
|
207
|
-
return Wt(s) || Wt(s, !0);
|
208
|
-
}
|
209
|
-
var Ze = qe,
|
210
|
-
ft = {};
|
211
|
-
const pt = /([()\][%!^"`<>&|;, *?])/g;
|
212
|
-
function Xe(s) {
|
213
|
-
return (s = s.replace(pt, '^$1')), s;
|
214
|
-
}
|
215
|
-
function Qe(s, t) {
|
216
|
-
return (
|
217
|
-
(s = `${s}`),
|
218
|
-
(s = s.replace(/(\\*)"/g, '$1$1\\"')),
|
219
|
-
(s = s.replace(/(\\*)$/, '$1$1')),
|
220
|
-
(s = `"${s}"`),
|
221
|
-
(s = s.replace(pt, '^$1')),
|
222
|
-
t && (s = s.replace(pt, '^$1')),
|
223
|
-
s
|
224
|
-
);
|
225
|
-
}
|
226
|
-
(ft.command = Xe), (ft.argument = Qe);
|
227
|
-
var ts = /^#!(.*)/;
|
228
|
-
const es = ts;
|
229
|
-
var ss = (s = '') => {
|
230
|
-
const t = s.match(es);
|
231
|
-
if (!t) return null;
|
232
|
-
const [e, i] = t[0].replace(/#! ?/, '').split(' '),
|
233
|
-
o = e.split('/').pop();
|
234
|
-
return o === 'env' ? i : i ? `${o} ${i}` : o;
|
235
|
-
};
|
236
|
-
const mt = at,
|
237
|
-
is = ss;
|
238
|
-
function rs(s) {
|
239
|
-
const e = Buffer.alloc(150);
|
240
|
-
let i;
|
241
|
-
try {
|
242
|
-
(i = mt.openSync(s, 'r')), mt.readSync(i, e, 0, 150, 0), mt.closeSync(i);
|
243
|
-
} catch {}
|
244
|
-
return is(e.toString());
|
245
|
-
}
|
246
|
-
var ns = rs;
|
247
|
-
const os = lt,
|
248
|
-
Gt = Ze,
|
249
|
-
Jt = ft,
|
250
|
-
ls = ns,
|
251
|
-
as = process.platform === 'win32',
|
252
|
-
hs = /\.(?:com|exe)$/i,
|
253
|
-
us = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
|
254
|
-
function cs(s) {
|
255
|
-
s.file = Gt(s);
|
256
|
-
const t = s.file && ls(s.file);
|
257
|
-
return t ? (s.args.unshift(s.file), (s.command = t), Gt(s)) : s.file;
|
258
|
-
}
|
259
|
-
function ds(s) {
|
260
|
-
if (!as) return s;
|
261
|
-
const t = cs(s),
|
262
|
-
e = !hs.test(t);
|
263
|
-
if (s.options.forceShell || e) {
|
264
|
-
const i = us.test(t);
|
265
|
-
(s.command = os.normalize(s.command)),
|
266
|
-
(s.command = Jt.command(s.command)),
|
267
|
-
(s.args = s.args.map((n) => Jt.argument(n, i)));
|
268
|
-
const o = [s.command].concat(s.args).join(' ');
|
269
|
-
(s.args = ['/d', '/s', '/c', `"${o}"`]),
|
270
|
-
(s.command = process.env.comspec || 'cmd.exe'),
|
271
|
-
(s.options.windowsVerbatimArguments = !0);
|
272
|
-
}
|
273
|
-
return s;
|
274
|
-
}
|
275
|
-
function fs(s, t, e) {
|
276
|
-
t && !Array.isArray(t) && ((e = t), (t = null)),
|
277
|
-
(t = t ? t.slice(0) : []),
|
278
|
-
(e = Object.assign({}, e));
|
279
|
-
const i = { command: s, args: t, options: e, file: void 0, original: { command: s, args: t } };
|
280
|
-
return e.shell ? i : ds(i);
|
281
|
-
}
|
282
|
-
var ps = fs;
|
283
|
-
const gt = process.platform === 'win32';
|
284
|
-
function vt(s, t) {
|
285
|
-
return Object.assign(new Error(`${t} ${s.command} ENOENT`), {
|
286
|
-
code: 'ENOENT',
|
287
|
-
errno: 'ENOENT',
|
288
|
-
syscall: `${t} ${s.command}`,
|
289
|
-
path: s.command,
|
290
|
-
spawnargs: s.args,
|
291
|
-
});
|
292
|
-
}
|
293
|
-
function ms(s, t) {
|
294
|
-
if (!gt) return;
|
295
|
-
const e = s.emit;
|
296
|
-
s.emit = function (i, o) {
|
297
|
-
if (i === 'exit') {
|
298
|
-
const n = Kt(o, t);
|
299
|
-
if (n) return e.call(s, 'error', n);
|
300
|
-
}
|
301
|
-
return e.apply(s, arguments);
|
302
|
-
};
|
303
|
-
}
|
304
|
-
function Kt(s, t) {
|
305
|
-
return gt && s === 1 && !t.file ? vt(t.original, 'spawn') : null;
|
306
|
-
}
|
307
|
-
function gs(s, t) {
|
308
|
-
return gt && s === 1 && !t.file ? vt(t.original, 'spawnSync') : null;
|
309
|
-
}
|
310
|
-
var vs = { hookChildProcess: ms, verifyENOENT: Kt, verifyENOENTSync: gs, notFoundError: vt };
|
311
|
-
const qt = je,
|
312
|
-
bt = ps,
|
313
|
-
wt = vs;
|
314
|
-
function Zt(s, t, e) {
|
315
|
-
const i = bt(s, t, e),
|
316
|
-
o = qt.spawn(i.command, i.args, i.options);
|
317
|
-
return wt.hookChildProcess(o, i), o;
|
318
|
-
}
|
319
|
-
function bs(s, t, e) {
|
320
|
-
const i = bt(s, t, e),
|
321
|
-
o = qt.spawnSync(i.command, i.args, i.options);
|
322
|
-
return (o.error = o.error || wt.verifyENOENTSync(o.status, i)), o;
|
323
|
-
}
|
324
|
-
(B.exports = Zt),
|
325
|
-
(B.exports.spawn = Zt),
|
326
|
-
(B.exports.sync = bs),
|
327
|
-
(B.exports._parse = bt),
|
328
|
-
(B.exports._enoent = wt);
|
329
|
-
var ws = function (s, t) {
|
330
|
-
t || (t = {});
|
331
|
-
var e = { bools: {}, strings: {}, unknownFn: null };
|
332
|
-
typeof t.unknown == 'function' && (e.unknownFn = t.unknown),
|
333
|
-
typeof t.boolean == 'boolean' && t.boolean
|
334
|
-
? (e.allBools = !0)
|
335
|
-
: []
|
336
|
-
.concat(t.boolean)
|
337
|
-
.filter(Boolean)
|
338
|
-
.forEach(function (u) {
|
339
|
-
e.bools[u] = !0;
|
340
|
-
});
|
341
|
-
var i = {};
|
342
|
-
Object.keys(t.alias || {}).forEach(function (u) {
|
343
|
-
(i[u] = [].concat(t.alias[u])),
|
344
|
-
i[u].forEach(function (w) {
|
345
|
-
i[w] = [u].concat(
|
346
|
-
i[u].filter(function (P) {
|
347
|
-
return w !== P;
|
348
|
-
}),
|
349
|
-
);
|
350
|
-
});
|
351
|
-
}),
|
352
|
-
[]
|
353
|
-
.concat(t.string)
|
354
|
-
.filter(Boolean)
|
355
|
-
.forEach(function (u) {
|
356
|
-
(e.strings[u] = !0), i[u] && (e.strings[i[u]] = !0);
|
357
|
-
});
|
358
|
-
var o = t.default || {},
|
359
|
-
n = { _: [] };
|
360
|
-
Object.keys(e.bools).forEach(function (u) {
|
361
|
-
c(u, o[u] === void 0 ? !1 : o[u]);
|
362
|
-
});
|
363
|
-
var r = [];
|
364
|
-
s.indexOf('--') !== -1 && ((r = s.slice(s.indexOf('--') + 1)), (s = s.slice(0, s.indexOf('--'))));
|
365
|
-
function l(u, w) {
|
366
|
-
return (e.allBools && /^--[^=]+$/.test(w)) || e.strings[u] || e.bools[u] || i[u];
|
367
|
-
}
|
368
|
-
function c(u, w, P) {
|
369
|
-
if (!(P && e.unknownFn && !l(u, P) && e.unknownFn(P) === !1)) {
|
370
|
-
var g = !e.strings[u] && Xt(w) ? Number(w) : w;
|
371
|
-
h(n, u.split('.'), g),
|
372
|
-
(i[u] || []).forEach(function (K) {
|
373
|
-
h(n, K.split('.'), g);
|
374
|
-
});
|
375
|
-
}
|
376
|
-
}
|
377
|
-
function h(u, w, P) {
|
378
|
-
for (var g = u, K = 0; K < w.length - 1; K++) {
|
379
|
-
var x = w[K];
|
380
|
-
if (Qt(g, x)) return;
|
381
|
-
g[x] === void 0 && (g[x] = {}),
|
382
|
-
(g[x] === Object.prototype || g[x] === Number.prototype || g[x] === String.prototype) &&
|
383
|
-
(g[x] = {}),
|
384
|
-
g[x] === Array.prototype && (g[x] = []),
|
385
|
-
(g = g[x]);
|
386
|
-
}
|
387
|
-
var x = w[w.length - 1];
|
388
|
-
Qt(g, x) ||
|
389
|
-
((g === Object.prototype || g === Number.prototype || g === String.prototype) && (g = {}),
|
390
|
-
g === Array.prototype && (g = []),
|
391
|
-
g[x] === void 0 || e.bools[x] || typeof g[x] == 'boolean'
|
392
|
-
? (g[x] = P)
|
393
|
-
: Array.isArray(g[x])
|
394
|
-
? g[x].push(P)
|
395
|
-
: (g[x] = [g[x], P]));
|
396
|
-
}
|
397
|
-
function $(u) {
|
398
|
-
return i[u].some(function (w) {
|
399
|
-
return e.bools[w];
|
400
|
-
});
|
401
|
-
}
|
402
|
-
for (var f = 0; f < s.length; f++) {
|
403
|
-
var a = s[f];
|
404
|
-
if (/^--.+=/.test(a)) {
|
405
|
-
var b = a.match(/^--([^=]+)=([\s\S]*)$/),
|
406
|
-
p = b[1],
|
407
|
-
S = b[2];
|
408
|
-
e.bools[p] && (S = S !== 'false'), c(p, S, a);
|
409
|
-
} else if (/^--no-.+/.test(a)) {
|
410
|
-
var p = a.match(/^--no-(.+)/)[1];
|
411
|
-
c(p, !1, a);
|
412
|
-
} else if (/^--.+/.test(a)) {
|
413
|
-
var p = a.match(/^--(.+)/)[1],
|
414
|
-
E = s[f + 1];
|
415
|
-
E !== void 0 && !/^-/.test(E) && !e.bools[p] && !e.allBools && (i[p] ? !$(p) : !0)
|
416
|
-
? (c(p, E, a), f++)
|
417
|
-
: /^(true|false)$/.test(E)
|
418
|
-
? (c(p, E === 'true', a), f++)
|
419
|
-
: c(p, e.strings[p] ? '' : !0, a);
|
420
|
-
} else if (/^-[^-]+/.test(a)) {
|
421
|
-
for (var O = a.slice(1, -1).split(''), V = !1, d = 0; d < O.length; d++) {
|
422
|
-
var E = a.slice(d + 2);
|
423
|
-
if (E === '-') {
|
424
|
-
c(O[d], E, a);
|
425
|
-
continue;
|
426
|
-
}
|
427
|
-
if (/[A-Za-z]/.test(O[d]) && /=/.test(E)) {
|
428
|
-
c(O[d], E.split('=')[1], a), (V = !0);
|
429
|
-
break;
|
430
|
-
}
|
431
|
-
if (/[A-Za-z]/.test(O[d]) && /-?\d+(\.\d*)?(e-?\d+)?$/.test(E)) {
|
432
|
-
c(O[d], E, a), (V = !0);
|
433
|
-
break;
|
434
|
-
}
|
435
|
-
if (O[d + 1] && O[d + 1].match(/\W/)) {
|
436
|
-
c(O[d], a.slice(d + 2), a), (V = !0);
|
437
|
-
break;
|
438
|
-
} else c(O[d], e.strings[O[d]] ? '' : !0, a);
|
439
|
-
}
|
440
|
-
var p = a.slice(-1)[0];
|
441
|
-
!V &&
|
442
|
-
p !== '-' &&
|
443
|
-
(s[f + 1] && !/^(-|--)[^-]/.test(s[f + 1]) && !e.bools[p] && (i[p] ? !$(p) : !0)
|
444
|
-
? (c(p, s[f + 1], a), f++)
|
445
|
-
: s[f + 1] && /^(true|false)$/.test(s[f + 1])
|
446
|
-
? (c(p, s[f + 1] === 'true', a), f++)
|
447
|
-
: c(p, e.strings[p] ? '' : !0, a));
|
448
|
-
} else if (
|
449
|
-
((!e.unknownFn || e.unknownFn(a) !== !1) && n._.push(e.strings._ || !Xt(a) ? a : Number(a)),
|
450
|
-
t.stopEarly)
|
451
|
-
) {
|
452
|
-
n._.push.apply(n._, s.slice(f + 1));
|
453
|
-
break;
|
454
|
-
}
|
455
|
-
}
|
456
|
-
return (
|
457
|
-
Object.keys(o).forEach(function (u) {
|
458
|
-
ys(n, u.split('.')) ||
|
459
|
-
(h(n, u.split('.'), o[u]),
|
460
|
-
(i[u] || []).forEach(function (w) {
|
461
|
-
h(n, w.split('.'), o[u]);
|
462
|
-
}));
|
463
|
-
}),
|
464
|
-
t['--']
|
465
|
-
? ((n['--'] = new Array()),
|
466
|
-
r.forEach(function (u) {
|
467
|
-
n['--'].push(u);
|
468
|
-
}))
|
469
|
-
: r.forEach(function (u) {
|
470
|
-
n._.push(u);
|
471
|
-
}),
|
472
|
-
n
|
473
|
-
);
|
474
|
-
};
|
475
|
-
function ys(s, t) {
|
476
|
-
var e = s;
|
477
|
-
t.slice(0, -1).forEach(function (o) {
|
478
|
-
e = e[o] || {};
|
479
|
-
});
|
480
|
-
var i = t[t.length - 1];
|
481
|
-
return i in e;
|
482
|
-
}
|
483
|
-
function Xt(s) {
|
484
|
-
return typeof s == 'number' || /^0x[0-9a-f]+$/i.test(s)
|
485
|
-
? !0
|
486
|
-
: /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(s);
|
487
|
-
}
|
488
|
-
function Qt(s, t) {
|
489
|
-
return (t === 'constructor' && typeof s[t] == 'function') || t === '__proto__';
|
490
|
-
}
|
491
|
-
var te = {};
|
492
|
-
const { FORCE_COLOR: $s, NODE_DISABLE_COLORS: xs, TERM: Ss } = process.env,
|
493
|
-
m = {
|
494
|
-
enabled: !xs && Ss !== 'dumb' && $s !== '0',
|
495
|
-
reset: v(0, 0),
|
496
|
-
bold: v(1, 22),
|
497
|
-
dim: v(2, 22),
|
498
|
-
italic: v(3, 23),
|
499
|
-
underline: v(4, 24),
|
500
|
-
inverse: v(7, 27),
|
501
|
-
hidden: v(8, 28),
|
502
|
-
strikethrough: v(9, 29),
|
503
|
-
black: v(30, 39),
|
504
|
-
red: v(31, 39),
|
505
|
-
green: v(32, 39),
|
506
|
-
yellow: v(33, 39),
|
507
|
-
blue: v(34, 39),
|
508
|
-
magenta: v(35, 39),
|
509
|
-
cyan: v(36, 39),
|
510
|
-
white: v(37, 39),
|
511
|
-
gray: v(90, 39),
|
512
|
-
grey: v(90, 39),
|
513
|
-
bgBlack: v(40, 49),
|
514
|
-
bgRed: v(41, 49),
|
515
|
-
bgGreen: v(42, 49),
|
516
|
-
bgYellow: v(43, 49),
|
517
|
-
bgBlue: v(44, 49),
|
518
|
-
bgMagenta: v(45, 49),
|
519
|
-
bgCyan: v(46, 49),
|
520
|
-
bgWhite: v(47, 49),
|
521
|
-
};
|
522
|
-
function ee(s, t) {
|
523
|
-
let e = 0,
|
524
|
-
i,
|
525
|
-
o = '',
|
526
|
-
n = '';
|
527
|
-
for (; e < s.length; e++)
|
528
|
-
(i = s[e]),
|
529
|
-
(o += i.open),
|
530
|
-
(n += i.close),
|
531
|
-
t.includes(i.close) && (t = t.replace(i.rgx, i.close + i.open));
|
532
|
-
return o + t + n;
|
533
|
-
}
|
534
|
-
function Es(s, t) {
|
535
|
-
let e = { has: s, keys: t };
|
536
|
-
return (
|
537
|
-
(e.reset = m.reset.bind(e)),
|
538
|
-
(e.bold = m.bold.bind(e)),
|
539
|
-
(e.dim = m.dim.bind(e)),
|
540
|
-
(e.italic = m.italic.bind(e)),
|
541
|
-
(e.underline = m.underline.bind(e)),
|
542
|
-
(e.inverse = m.inverse.bind(e)),
|
543
|
-
(e.hidden = m.hidden.bind(e)),
|
544
|
-
(e.strikethrough = m.strikethrough.bind(e)),
|
545
|
-
(e.black = m.black.bind(e)),
|
546
|
-
(e.red = m.red.bind(e)),
|
547
|
-
(e.green = m.green.bind(e)),
|
548
|
-
(e.yellow = m.yellow.bind(e)),
|
549
|
-
(e.blue = m.blue.bind(e)),
|
550
|
-
(e.magenta = m.magenta.bind(e)),
|
551
|
-
(e.cyan = m.cyan.bind(e)),
|
552
|
-
(e.white = m.white.bind(e)),
|
553
|
-
(e.gray = m.gray.bind(e)),
|
554
|
-
(e.grey = m.grey.bind(e)),
|
555
|
-
(e.bgBlack = m.bgBlack.bind(e)),
|
556
|
-
(e.bgRed = m.bgRed.bind(e)),
|
557
|
-
(e.bgGreen = m.bgGreen.bind(e)),
|
558
|
-
(e.bgYellow = m.bgYellow.bind(e)),
|
559
|
-
(e.bgBlue = m.bgBlue.bind(e)),
|
560
|
-
(e.bgMagenta = m.bgMagenta.bind(e)),
|
561
|
-
(e.bgCyan = m.bgCyan.bind(e)),
|
562
|
-
(e.bgWhite = m.bgWhite.bind(e)),
|
563
|
-
e
|
564
|
-
);
|
565
|
-
}
|
566
|
-
function v(s, t) {
|
567
|
-
let e = { open: `\x1B[${s}m`, close: `\x1B[${t}m`, rgx: new RegExp(`\\x1b\\[${t}m`, 'g') };
|
568
|
-
return function (i) {
|
569
|
-
return this !== void 0 && this.has !== void 0
|
570
|
-
? (this.has.includes(s) || (this.has.push(s), this.keys.push(e)),
|
571
|
-
i === void 0 ? this : m.enabled ? ee(this.keys, i + '') : i + '')
|
572
|
-
: i === void 0
|
573
|
-
? Es([s], [e])
|
574
|
-
: m.enabled
|
575
|
-
? ee([e], i + '')
|
576
|
-
: i + '';
|
577
|
-
};
|
578
|
-
}
|
579
|
-
var M = m,
|
580
|
-
Ts = (s, t) => {
|
581
|
-
if (!(s.meta && s.name !== 'escape')) {
|
582
|
-
if (s.ctrl) {
|
583
|
-
if (s.name === 'a') return 'first';
|
584
|
-
if (s.name === 'c' || s.name === 'd') return 'abort';
|
585
|
-
if (s.name === 'e') return 'last';
|
586
|
-
if (s.name === 'g') return 'reset';
|
587
|
-
}
|
588
|
-
if (t) {
|
589
|
-
if (s.name === 'j') return 'down';
|
590
|
-
if (s.name === 'k') return 'up';
|
591
|
-
}
|
592
|
-
return s.name === 'return' || s.name === 'enter'
|
593
|
-
? 'submit'
|
594
|
-
: s.name === 'backspace'
|
595
|
-
? 'delete'
|
596
|
-
: s.name === 'delete'
|
597
|
-
? 'deleteForward'
|
598
|
-
: s.name === 'abort'
|
599
|
-
? 'abort'
|
600
|
-
: s.name === 'escape'
|
601
|
-
? 'exit'
|
602
|
-
: s.name === 'tab'
|
603
|
-
? 'next'
|
604
|
-
: s.name === 'pagedown'
|
605
|
-
? 'nextPage'
|
606
|
-
: s.name === 'pageup'
|
607
|
-
? 'prevPage'
|
608
|
-
: s.name === 'home'
|
609
|
-
? 'home'
|
610
|
-
: s.name === 'end'
|
611
|
-
? 'end'
|
612
|
-
: s.name === 'up'
|
613
|
-
? 'up'
|
614
|
-
: s.name === 'down'
|
615
|
-
? 'down'
|
616
|
-
: s.name === 'right'
|
617
|
-
? 'right'
|
618
|
-
: s.name === 'left'
|
619
|
-
? 'left'
|
620
|
-
: !1;
|
621
|
-
}
|
622
|
-
},
|
623
|
-
yt = (s) => {
|
624
|
-
const t = [
|
625
|
-
'[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)',
|
626
|
-
'(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))',
|
627
|
-
].join('|'),
|
628
|
-
e = new RegExp(t, 'g');
|
629
|
-
return typeof s == 'string' ? s.replace(e, '') : s;
|
630
|
-
};
|
631
|
-
const $t = '\x1B',
|
632
|
-
y = `${$t}[`,
|
633
|
-
Os = '\x07',
|
634
|
-
xt = {
|
635
|
-
to(s, t) {
|
636
|
-
return t ? `${y}${t + 1};${s + 1}H` : `${y}${s + 1}G`;
|
637
|
-
},
|
638
|
-
move(s, t) {
|
639
|
-
let e = '';
|
640
|
-
return (
|
641
|
-
s < 0 ? (e += `${y}${-s}D`) : s > 0 && (e += `${y}${s}C`),
|
642
|
-
t < 0 ? (e += `${y}${-t}A`) : t > 0 && (e += `${y}${t}B`),
|
643
|
-
e
|
644
|
-
);
|
645
|
-
},
|
646
|
-
up: (s = 1) => `${y}${s}A`,
|
647
|
-
down: (s = 1) => `${y}${s}B`,
|
648
|
-
forward: (s = 1) => `${y}${s}C`,
|
649
|
-
backward: (s = 1) => `${y}${s}D`,
|
650
|
-
nextLine: (s = 1) => `${y}E`.repeat(s),
|
651
|
-
prevLine: (s = 1) => `${y}F`.repeat(s),
|
652
|
-
left: `${y}G`,
|
653
|
-
hide: `${y}?25l`,
|
654
|
-
show: `${y}?25h`,
|
655
|
-
save: `${$t}7`,
|
656
|
-
restore: `${$t}8`,
|
657
|
-
},
|
658
|
-
Ps = { up: (s = 1) => `${y}S`.repeat(s), down: (s = 1) => `${y}T`.repeat(s) },
|
659
|
-
Cs = {
|
660
|
-
screen: `${y}2J`,
|
661
|
-
up: (s = 1) => `${y}1J`.repeat(s),
|
662
|
-
down: (s = 1) => `${y}J`.repeat(s),
|
663
|
-
line: `${y}2K`,
|
664
|
-
lineEnd: `${y}K`,
|
665
|
-
lineStart: `${y}1K`,
|
666
|
-
lines(s) {
|
667
|
-
let t = '';
|
668
|
-
for (let e = 0; e < s; e++) t += this.line + (e < s - 1 ? xt.up() : '');
|
669
|
-
return s && (t += xt.left), t;
|
670
|
-
},
|
671
|
-
};
|
672
|
-
var D = { cursor: xt, scroll: Ps, erase: Cs, beep: Os };
|
673
|
-
const Ms = yt,
|
674
|
-
{ erase: se, cursor: Ds } = D,
|
675
|
-
_s = (s) => [...Ms(s)].length;
|
676
|
-
var Is = function (s, t) {
|
677
|
-
if (!t) return se.line + Ds.to(0);
|
678
|
-
let e = 0;
|
679
|
-
const i = s.split(/\r?\n/);
|
680
|
-
for (let o of i) e += 1 + Math.floor(Math.max(_s(o) - 1, 0) / t);
|
681
|
-
return se.lines(e);
|
682
|
-
};
|
683
|
-
const q = {
|
684
|
-
arrowUp: '\u2191',
|
685
|
-
arrowDown: '\u2193',
|
686
|
-
arrowLeft: '\u2190',
|
687
|
-
arrowRight: '\u2192',
|
688
|
-
radioOn: '\u25C9',
|
689
|
-
radioOff: '\u25EF',
|
690
|
-
tick: '\u2714',
|
691
|
-
cross: '\u2716',
|
692
|
-
ellipsis: '\u2026',
|
693
|
-
pointerSmall: '\u203A',
|
694
|
-
line: '\u2500',
|
695
|
-
pointer: '\u276F',
|
696
|
-
},
|
697
|
-
As = {
|
698
|
-
arrowUp: q.arrowUp,
|
699
|
-
arrowDown: q.arrowDown,
|
700
|
-
arrowLeft: q.arrowLeft,
|
701
|
-
arrowRight: q.arrowRight,
|
702
|
-
radioOn: '(*)',
|
703
|
-
radioOff: '( )',
|
704
|
-
tick: '\u221A',
|
705
|
-
cross: '\xD7',
|
706
|
-
ellipsis: '...',
|
707
|
-
pointerSmall: '\xBB',
|
708
|
-
line: '\u2500',
|
709
|
-
pointer: '>',
|
710
|
-
},
|
711
|
-
Rs = process.platform === 'win32' ? As : q;
|
712
|
-
var ie = Rs;
|
713
|
-
const z = M,
|
714
|
-
Y = ie,
|
715
|
-
St = Object.freeze({
|
716
|
-
password: { scale: 1, render: (s) => '*'.repeat(s.length) },
|
717
|
-
emoji: { scale: 2, render: (s) => '\u{1F603}'.repeat(s.length) },
|
718
|
-
invisible: { scale: 0, render: (s) => '' },
|
719
|
-
default: { scale: 1, render: (s) => `${s}` },
|
720
|
-
}),
|
721
|
-
ks = (s) => St[s] || St.default,
|
722
|
-
Z = Object.freeze({
|
723
|
-
aborted: z.red(Y.cross),
|
724
|
-
done: z.green(Y.tick),
|
725
|
-
exited: z.yellow(Y.cross),
|
726
|
-
default: z.cyan('?'),
|
727
|
-
}),
|
728
|
-
Ns = (s, t, e) => (t ? Z.aborted : e ? Z.exited : s ? Z.done : Z.default),
|
729
|
-
js = (s) => z.gray(s ? Y.ellipsis : Y.pointerSmall),
|
730
|
-
Fs = (s, t) => z.gray(s ? (t ? Y.pointerSmall : '+') : Y.line);
|
731
|
-
var Ls = { styles: St, render: ks, symbols: Z, symbol: Ns, delimiter: js, item: Fs };
|
732
|
-
const Vs = yt;
|
733
|
-
var Ys = function (s, t) {
|
734
|
-
let e = String(Vs(s) || '').split(/\r?\n/);
|
735
|
-
return t ? e.map((i) => Math.ceil(i.length / t)).reduce((i, o) => i + o) : e.length;
|
736
|
-
},
|
737
|
-
Hs = (s, t = {}) => {
|
738
|
-
const e = Number.isSafeInteger(parseInt(t.margin))
|
739
|
-
? new Array(parseInt(t.margin)).fill(' ').join('')
|
740
|
-
: t.margin || '',
|
741
|
-
i = t.width;
|
742
|
-
return (s || '')
|
743
|
-
.split(/\r?\n/g)
|
744
|
-
.map((o) =>
|
745
|
-
o
|
746
|
-
.split(/\s+/g)
|
747
|
-
.reduce(
|
748
|
-
(n, r) => (
|
749
|
-
r.length + e.length >= i || n[n.length - 1].length + r.length + 1 < i
|
750
|
-
? (n[n.length - 1] += ` ${r}`)
|
751
|
-
: n.push(`${e}${r}`),
|
752
|
-
n
|
753
|
-
),
|
754
|
-
[e],
|
755
|
-
)
|
756
|
-
.join(`
|
757
|
-
`),
|
758
|
-
)
|
759
|
-
.join(`
|
760
|
-
`);
|
761
|
-
},
|
762
|
-
Bs = (s, t, e) => {
|
763
|
-
e = e || t;
|
764
|
-
let i = Math.min(t - e, s - Math.floor(e / 2));
|
765
|
-
i < 0 && (i = 0);
|
766
|
-
let o = Math.min(i + e, t);
|
767
|
-
return { startIndex: i, endIndex: o };
|
768
|
-
},
|
769
|
-
_ = {
|
770
|
-
action: Ts,
|
771
|
-
clear: Is,
|
772
|
-
style: Ls,
|
773
|
-
strip: yt,
|
774
|
-
figures: ie,
|
775
|
-
lines: Ys,
|
776
|
-
wrap: Hs,
|
777
|
-
entriesToDisplay: Bs,
|
778
|
-
};
|
779
|
-
const re = Fe,
|
780
|
-
{ action: Us } = _,
|
781
|
-
zs = Le,
|
782
|
-
{ beep: Ws, cursor: Gs } = D,
|
783
|
-
Js = M;
|
784
|
-
let Ks = class extends zs {
|
785
|
-
constructor(t = {}) {
|
786
|
-
super(),
|
787
|
-
(this.firstRender = !0),
|
788
|
-
(this.in = t.stdin || process.stdin),
|
789
|
-
(this.out = t.stdout || process.stdout),
|
790
|
-
(this.onRender = (t.onRender || (() => {})).bind(this));
|
791
|
-
const e = re.createInterface({ input: this.in, escapeCodeTimeout: 50 });
|
792
|
-
re.emitKeypressEvents(this.in, e), this.in.isTTY && this.in.setRawMode(!0);
|
793
|
-
const i = ['SelectPrompt', 'MultiselectPrompt'].indexOf(this.constructor.name) > -1,
|
794
|
-
o = (n, r) => {
|
795
|
-
let l = Us(r, i);
|
796
|
-
l === !1 ? this._ && this._(n, r) : typeof this[l] == 'function' ? this[l](r) : this.bell();
|
797
|
-
};
|
798
|
-
(this.close = () => {
|
799
|
-
this.out.write(Gs.show),
|
800
|
-
this.in.removeListener('keypress', o),
|
801
|
-
this.in.isTTY && this.in.setRawMode(!1),
|
802
|
-
e.close(),
|
803
|
-
this.emit(this.aborted ? 'abort' : this.exited ? 'exit' : 'submit', this.value),
|
804
|
-
(this.closed = !0);
|
805
|
-
}),
|
806
|
-
this.in.on('keypress', o);
|
807
|
-
}
|
808
|
-
fire() {
|
809
|
-
this.emit('state', { value: this.value, aborted: !!this.aborted, exited: !!this.exited });
|
810
|
-
}
|
811
|
-
bell() {
|
812
|
-
this.out.write(Ws);
|
813
|
-
}
|
814
|
-
render() {
|
815
|
-
this.onRender(Js), this.firstRender && (this.firstRender = !1);
|
816
|
-
}
|
817
|
-
};
|
818
|
-
var j = Ks;
|
819
|
-
const et = M,
|
820
|
-
qs = j,
|
821
|
-
{ erase: Zs, cursor: X } = D,
|
822
|
-
{ style: Et, clear: Tt, lines: Xs, figures: Qs } = _;
|
823
|
-
class ti extends qs {
|
824
|
-
constructor(t = {}) {
|
825
|
-
super(t),
|
826
|
-
(this.transform = Et.render(t.style)),
|
827
|
-
(this.scale = this.transform.scale),
|
828
|
-
(this.msg = t.message),
|
829
|
-
(this.initial = t.initial || ''),
|
830
|
-
(this.validator = t.validate || (() => !0)),
|
831
|
-
(this.value = ''),
|
832
|
-
(this.errorMsg = t.error || 'Please Enter A Valid Value'),
|
833
|
-
(this.cursor = Number(!!this.initial)),
|
834
|
-
(this.cursorOffset = 0),
|
835
|
-
(this.clear = Tt('', this.out.columns)),
|
836
|
-
this.render();
|
837
|
-
}
|
838
|
-
set value(t) {
|
839
|
-
!t && this.initial
|
840
|
-
? ((this.placeholder = !0), (this.rendered = et.gray(this.transform.render(this.initial))))
|
841
|
-
: ((this.placeholder = !1), (this.rendered = this.transform.render(t))),
|
842
|
-
(this._value = t),
|
843
|
-
this.fire();
|
844
|
-
}
|
845
|
-
get value() {
|
846
|
-
return this._value;
|
847
|
-
}
|
848
|
-
reset() {
|
849
|
-
(this.value = ''),
|
850
|
-
(this.cursor = Number(!!this.initial)),
|
851
|
-
(this.cursorOffset = 0),
|
852
|
-
this.fire(),
|
853
|
-
this.render();
|
854
|
-
}
|
855
|
-
exit() {
|
856
|
-
this.abort();
|
857
|
-
}
|
858
|
-
abort() {
|
859
|
-
(this.value = this.value || this.initial),
|
860
|
-
(this.done = this.aborted = !0),
|
861
|
-
(this.error = !1),
|
862
|
-
(this.red = !1),
|
863
|
-
this.fire(),
|
864
|
-
this.render(),
|
865
|
-
this.out.write(`
|
866
|
-
`),
|
867
|
-
this.close();
|
868
|
-
}
|
869
|
-
async validate() {
|
870
|
-
let t = await this.validator(this.value);
|
871
|
-
typeof t == 'string' && ((this.errorMsg = t), (t = !1)), (this.error = !t);
|
872
|
-
}
|
873
|
-
async submit() {
|
874
|
-
if (
|
875
|
-
((this.value = this.value || this.initial),
|
876
|
-
(this.cursorOffset = 0),
|
877
|
-
(this.cursor = this.rendered.length),
|
878
|
-
await this.validate(),
|
879
|
-
this.error)
|
880
|
-
) {
|
881
|
-
(this.red = !0), this.fire(), this.render();
|
882
|
-
return;
|
883
|
-
}
|
884
|
-
(this.done = !0),
|
885
|
-
(this.aborted = !1),
|
886
|
-
this.fire(),
|
887
|
-
this.render(),
|
888
|
-
this.out.write(`
|
889
|
-
`),
|
890
|
-
this.close();
|
891
|
-
}
|
892
|
-
next() {
|
893
|
-
if (!this.placeholder) return this.bell();
|
894
|
-
(this.value = this.initial), (this.cursor = this.rendered.length), this.fire(), this.render();
|
895
|
-
}
|
896
|
-
moveCursor(t) {
|
897
|
-
this.placeholder || ((this.cursor = this.cursor + t), (this.cursorOffset += t));
|
898
|
-
}
|
899
|
-
_(t, e) {
|
900
|
-
let i = this.value.slice(0, this.cursor),
|
901
|
-
o = this.value.slice(this.cursor);
|
902
|
-
(this.value = `${i}${t}${o}`),
|
903
|
-
(this.red = !1),
|
904
|
-
(this.cursor = this.placeholder ? 0 : i.length + 1),
|
905
|
-
this.render();
|
906
|
-
}
|
907
|
-
delete() {
|
908
|
-
if (this.isCursorAtStart()) return this.bell();
|
909
|
-
let t = this.value.slice(0, this.cursor - 1),
|
910
|
-
e = this.value.slice(this.cursor);
|
911
|
-
(this.value = `${t}${e}`),
|
912
|
-
(this.red = !1),
|
913
|
-
this.isCursorAtStart() ? (this.cursorOffset = 0) : (this.cursorOffset++, this.moveCursor(-1)),
|
914
|
-
this.render();
|
915
|
-
}
|
916
|
-
deleteForward() {
|
917
|
-
if (this.cursor * this.scale >= this.rendered.length || this.placeholder) return this.bell();
|
918
|
-
let t = this.value.slice(0, this.cursor),
|
919
|
-
e = this.value.slice(this.cursor + 1);
|
920
|
-
(this.value = `${t}${e}`),
|
921
|
-
(this.red = !1),
|
922
|
-
this.isCursorAtEnd() ? (this.cursorOffset = 0) : this.cursorOffset++,
|
923
|
-
this.render();
|
924
|
-
}
|
925
|
-
first() {
|
926
|
-
(this.cursor = 0), this.render();
|
927
|
-
}
|
928
|
-
last() {
|
929
|
-
(this.cursor = this.value.length), this.render();
|
930
|
-
}
|
931
|
-
left() {
|
932
|
-
if (this.cursor <= 0 || this.placeholder) return this.bell();
|
933
|
-
this.moveCursor(-1), this.render();
|
934
|
-
}
|
935
|
-
right() {
|
936
|
-
if (this.cursor * this.scale >= this.rendered.length || this.placeholder) return this.bell();
|
937
|
-
this.moveCursor(1), this.render();
|
938
|
-
}
|
939
|
-
isCursorAtStart() {
|
940
|
-
return this.cursor === 0 || (this.placeholder && this.cursor === 1);
|
941
|
-
}
|
942
|
-
isCursorAtEnd() {
|
943
|
-
return (
|
944
|
-
this.cursor === this.rendered.length ||
|
945
|
-
(this.placeholder && this.cursor === this.rendered.length + 1)
|
946
|
-
);
|
947
|
-
}
|
948
|
-
render() {
|
949
|
-
this.closed ||
|
950
|
-
(this.firstRender ||
|
951
|
-
(this.outputError &&
|
952
|
-
this.out.write(
|
953
|
-
X.down(Xs(this.outputError, this.out.columns) - 1) +
|
954
|
-
Tt(this.outputError, this.out.columns),
|
955
|
-
),
|
956
|
-
this.out.write(Tt(this.outputText, this.out.columns))),
|
957
|
-
super.render(),
|
958
|
-
(this.outputError = ''),
|
959
|
-
(this.outputText = [
|
960
|
-
Et.symbol(this.done, this.aborted),
|
961
|
-
et.bold(this.msg),
|
962
|
-
Et.delimiter(this.done),
|
963
|
-
this.red ? et.red(this.rendered) : this.rendered,
|
964
|
-
].join(' ')),
|
965
|
-
this.error &&
|
966
|
-
(this.outputError += this.errorMsg
|
967
|
-
.split(`
|
968
|
-
`)
|
969
|
-
.reduce(
|
970
|
-
(t, e, i) =>
|
971
|
-
t +
|
972
|
-
`
|
973
|
-
${i ? ' ' : Qs.pointerSmall} ${et.red().italic(e)}`,
|
974
|
-
'',
|
975
|
-
)),
|
976
|
-
this.out.write(
|
977
|
-
Zs.line +
|
978
|
-
X.to(0) +
|
979
|
-
this.outputText +
|
980
|
-
X.save +
|
981
|
-
this.outputError +
|
982
|
-
X.restore +
|
983
|
-
X.move(this.cursorOffset, 0),
|
984
|
-
));
|
985
|
-
}
|
986
|
-
}
|
987
|
-
var ei = ti;
|
988
|
-
const A = M,
|
989
|
-
si = j,
|
990
|
-
{ style: ne, clear: oe, figures: st, wrap: ii, entriesToDisplay: ri } = _,
|
991
|
-
{ cursor: ni } = D;
|
992
|
-
class oi extends si {
|
993
|
-
constructor(t = {}) {
|
994
|
-
super(t),
|
995
|
-
(this.msg = t.message),
|
996
|
-
(this.hint = t.hint || '- Use arrow-keys. Return to submit.'),
|
997
|
-
(this.warn = t.warn || '- This option is disabled'),
|
998
|
-
(this.cursor = t.initial || 0),
|
999
|
-
(this.choices = t.choices.map(
|
1000
|
-
(e, i) => (
|
1001
|
-
typeof e == 'string' && (e = { title: e, value: i }),
|
1002
|
-
{
|
1003
|
-
title: e && (e.title || e.value || e),
|
1004
|
-
value: e && (e.value === void 0 ? i : e.value),
|
1005
|
-
description: e && e.description,
|
1006
|
-
selected: e && e.selected,
|
1007
|
-
disabled: e && e.disabled,
|
1008
|
-
}
|
1009
|
-
),
|
1010
|
-
)),
|
1011
|
-
(this.optionsPerPage = t.optionsPerPage || 10),
|
1012
|
-
(this.value = (this.choices[this.cursor] || {}).value),
|
1013
|
-
(this.clear = oe('', this.out.columns)),
|
1014
|
-
this.render();
|
1015
|
-
}
|
1016
|
-
moveCursor(t) {
|
1017
|
-
(this.cursor = t), (this.value = this.choices[t].value), this.fire();
|
1018
|
-
}
|
1019
|
-
reset() {
|
1020
|
-
this.moveCursor(0), this.fire(), this.render();
|
1021
|
-
}
|
1022
|
-
exit() {
|
1023
|
-
this.abort();
|
1024
|
-
}
|
1025
|
-
abort() {
|
1026
|
-
(this.done = this.aborted = !0),
|
1027
|
-
this.fire(),
|
1028
|
-
this.render(),
|
1029
|
-
this.out.write(`
|
1030
|
-
`),
|
1031
|
-
this.close();
|
1032
|
-
}
|
1033
|
-
submit() {
|
1034
|
-
this.selection.disabled
|
1035
|
-
? this.bell()
|
1036
|
-
: ((this.done = !0),
|
1037
|
-
(this.aborted = !1),
|
1038
|
-
this.fire(),
|
1039
|
-
this.render(),
|
1040
|
-
this.out.write(`
|
1041
|
-
`),
|
1042
|
-
this.close());
|
1043
|
-
}
|
1044
|
-
first() {
|
1045
|
-
this.moveCursor(0), this.render();
|
1046
|
-
}
|
1047
|
-
last() {
|
1048
|
-
this.moveCursor(this.choices.length - 1), this.render();
|
1049
|
-
}
|
1050
|
-
up() {
|
1051
|
-
this.cursor === 0 ? this.moveCursor(this.choices.length - 1) : this.moveCursor(this.cursor - 1),
|
1052
|
-
this.render();
|
1053
|
-
}
|
1054
|
-
down() {
|
1055
|
-
this.cursor === this.choices.length - 1 ? this.moveCursor(0) : this.moveCursor(this.cursor + 1),
|
1056
|
-
this.render();
|
1057
|
-
}
|
1058
|
-
next() {
|
1059
|
-
this.moveCursor((this.cursor + 1) % this.choices.length), this.render();
|
1060
|
-
}
|
1061
|
-
_(t, e) {
|
1062
|
-
if (t === ' ') return this.submit();
|
1063
|
-
}
|
1064
|
-
get selection() {
|
1065
|
-
return this.choices[this.cursor];
|
1066
|
-
}
|
1067
|
-
render() {
|
1068
|
-
if (this.closed) return;
|
1069
|
-
this.firstRender
|
1070
|
-
? this.out.write(ni.hide)
|
1071
|
-
: this.out.write(oe(this.outputText, this.out.columns)),
|
1072
|
-
super.render();
|
1073
|
-
let { startIndex: t, endIndex: e } = ri(this.cursor, this.choices.length, this.optionsPerPage);
|
1074
|
-
if (
|
1075
|
-
((this.outputText = [
|
1076
|
-
ne.symbol(this.done, this.aborted),
|
1077
|
-
A.bold(this.msg),
|
1078
|
-
ne.delimiter(!1),
|
1079
|
-
this.done
|
1080
|
-
? this.selection.title
|
1081
|
-
: this.selection.disabled
|
1082
|
-
? A.yellow(this.warn)
|
1083
|
-
: A.gray(this.hint),
|
1084
|
-
].join(' ')),
|
1085
|
-
!this.done)
|
1086
|
-
) {
|
1087
|
-
this.outputText += `
|
1088
|
-
`;
|
1089
|
-
for (let i = t; i < e; i++) {
|
1090
|
-
let o,
|
1091
|
-
n,
|
1092
|
-
r = '',
|
1093
|
-
l = this.choices[i];
|
1094
|
-
i === t && t > 0
|
1095
|
-
? (n = st.arrowUp)
|
1096
|
-
: i === e - 1 && e < this.choices.length
|
1097
|
-
? (n = st.arrowDown)
|
1098
|
-
: (n = ' '),
|
1099
|
-
l.disabled
|
1100
|
-
? ((o =
|
1101
|
-
this.cursor === i ? A.gray().underline(l.title) : A.strikethrough().gray(l.title)),
|
1102
|
-
(n = (this.cursor === i ? A.bold().gray(st.pointer) + ' ' : ' ') + n))
|
1103
|
-
: ((o = this.cursor === i ? A.cyan().underline(l.title) : l.title),
|
1104
|
-
(n = (this.cursor === i ? A.cyan(st.pointer) + ' ' : ' ') + n),
|
1105
|
-
l.description &&
|
1106
|
-
this.cursor === i &&
|
1107
|
-
((r = ` - ${l.description}`),
|
1108
|
-
(n.length + o.length + r.length >= this.out.columns ||
|
1109
|
-
l.description.split(/\r?\n/).length > 1) &&
|
1110
|
-
(r =
|
1111
|
-
`
|
1112
|
-
` + ii(l.description, { margin: 3, width: this.out.columns })))),
|
1113
|
-
(this.outputText += `${n} ${o}${A.gray(r)}
|
1114
|
-
`);
|
1115
|
-
}
|
1116
|
-
}
|
1117
|
-
this.out.write(this.outputText);
|
1118
|
-
}
|
1119
|
-
}
|
1120
|
-
var li = oi;
|
1121
|
-
const it = M,
|
1122
|
-
ai = j,
|
1123
|
-
{ style: le, clear: hi } = _,
|
1124
|
-
{ cursor: ae, erase: ui } = D;
|
1125
|
-
class ci extends ai {
|
1126
|
-
constructor(t = {}) {
|
1127
|
-
super(t),
|
1128
|
-
(this.msg = t.message),
|
1129
|
-
(this.value = !!t.initial),
|
1130
|
-
(this.active = t.active || 'on'),
|
1131
|
-
(this.inactive = t.inactive || 'off'),
|
1132
|
-
(this.initialValue = this.value),
|
1133
|
-
this.render();
|
1134
|
-
}
|
1135
|
-
reset() {
|
1136
|
-
(this.value = this.initialValue), this.fire(), this.render();
|
1137
|
-
}
|
1138
|
-
exit() {
|
1139
|
-
this.abort();
|
1140
|
-
}
|
1141
|
-
abort() {
|
1142
|
-
(this.done = this.aborted = !0),
|
1143
|
-
this.fire(),
|
1144
|
-
this.render(),
|
1145
|
-
this.out.write(`
|
1146
|
-
`),
|
1147
|
-
this.close();
|
1148
|
-
}
|
1149
|
-
submit() {
|
1150
|
-
(this.done = !0),
|
1151
|
-
(this.aborted = !1),
|
1152
|
-
this.fire(),
|
1153
|
-
this.render(),
|
1154
|
-
this.out.write(`
|
1155
|
-
`),
|
1156
|
-
this.close();
|
1157
|
-
}
|
1158
|
-
deactivate() {
|
1159
|
-
if (this.value === !1) return this.bell();
|
1160
|
-
(this.value = !1), this.render();
|
1161
|
-
}
|
1162
|
-
activate() {
|
1163
|
-
if (this.value === !0) return this.bell();
|
1164
|
-
(this.value = !0), this.render();
|
1165
|
-
}
|
1166
|
-
delete() {
|
1167
|
-
this.deactivate();
|
1168
|
-
}
|
1169
|
-
left() {
|
1170
|
-
this.deactivate();
|
1171
|
-
}
|
1172
|
-
right() {
|
1173
|
-
this.activate();
|
1174
|
-
}
|
1175
|
-
down() {
|
1176
|
-
this.deactivate();
|
1177
|
-
}
|
1178
|
-
up() {
|
1179
|
-
this.activate();
|
1180
|
-
}
|
1181
|
-
next() {
|
1182
|
-
(this.value = !this.value), this.fire(), this.render();
|
1183
|
-
}
|
1184
|
-
_(t, e) {
|
1185
|
-
if (t === ' ') this.value = !this.value;
|
1186
|
-
else if (t === '1') this.value = !0;
|
1187
|
-
else if (t === '0') this.value = !1;
|
1188
|
-
else return this.bell();
|
1189
|
-
this.render();
|
1190
|
-
}
|
1191
|
-
render() {
|
1192
|
-
this.closed ||
|
1193
|
-
(this.firstRender
|
1194
|
-
? this.out.write(ae.hide)
|
1195
|
-
: this.out.write(hi(this.outputText, this.out.columns)),
|
1196
|
-
super.render(),
|
1197
|
-
(this.outputText = [
|
1198
|
-
le.symbol(this.done, this.aborted),
|
1199
|
-
it.bold(this.msg),
|
1200
|
-
le.delimiter(this.done),
|
1201
|
-
this.value ? this.inactive : it.cyan().underline(this.inactive),
|
1202
|
-
it.gray('/'),
|
1203
|
-
this.value ? it.cyan().underline(this.active) : this.active,
|
1204
|
-
].join(' ')),
|
1205
|
-
this.out.write(ui.line + ae.to(0) + this.outputText));
|
1206
|
-
}
|
1207
|
-
}
|
1208
|
-
var di = ci;
|
1209
|
-
let Ot = class {
|
1210
|
-
constructor({ token: t, date: e, parts: i, locales: o }) {
|
1211
|
-
(this.token = t),
|
1212
|
-
(this.date = e || new Date()),
|
1213
|
-
(this.parts = i || [this]),
|
1214
|
-
(this.locales = o || {});
|
1215
|
-
}
|
1216
|
-
up() {}
|
1217
|
-
down() {}
|
1218
|
-
next() {
|
1219
|
-
const t = this.parts.indexOf(this);
|
1220
|
-
return this.parts.find((e, i) => i > t && e instanceof Ot);
|
1221
|
-
}
|
1222
|
-
setTo(t) {}
|
1223
|
-
prev() {
|
1224
|
-
let t = [].concat(this.parts).reverse();
|
1225
|
-
const e = t.indexOf(this);
|
1226
|
-
return t.find((i, o) => o > e && i instanceof Ot);
|
1227
|
-
}
|
1228
|
-
toString() {
|
1229
|
-
return String(this.date);
|
1230
|
-
}
|
1231
|
-
};
|
1232
|
-
var R = Ot;
|
1233
|
-
const fi = R;
|
1234
|
-
let pi = class extends fi {
|
1235
|
-
constructor(t = {}) {
|
1236
|
-
super(t);
|
1237
|
-
}
|
1238
|
-
up() {
|
1239
|
-
this.date.setHours((this.date.getHours() + 12) % 24);
|
1240
|
-
}
|
1241
|
-
down() {
|
1242
|
-
this.up();
|
1243
|
-
}
|
1244
|
-
toString() {
|
1245
|
-
let t = this.date.getHours() > 12 ? 'pm' : 'am';
|
1246
|
-
return /\A/.test(this.token) ? t.toUpperCase() : t;
|
1247
|
-
}
|
1248
|
-
};
|
1249
|
-
var mi = pi;
|
1250
|
-
const gi = R,
|
1251
|
-
vi = (s) => ((s = s % 10), s === 1 ? 'st' : s === 2 ? 'nd' : s === 3 ? 'rd' : 'th');
|
1252
|
-
let bi = class extends gi {
|
1253
|
-
constructor(t = {}) {
|
1254
|
-
super(t);
|
1255
|
-
}
|
1256
|
-
up() {
|
1257
|
-
this.date.setDate(this.date.getDate() + 1);
|
1258
|
-
}
|
1259
|
-
down() {
|
1260
|
-
this.date.setDate(this.date.getDate() - 1);
|
1261
|
-
}
|
1262
|
-
setTo(t) {
|
1263
|
-
this.date.setDate(parseInt(t.substr(-2)));
|
1264
|
-
}
|
1265
|
-
toString() {
|
1266
|
-
let t = this.date.getDate(),
|
1267
|
-
e = this.date.getDay();
|
1268
|
-
return this.token === 'DD'
|
1269
|
-
? String(t).padStart(2, '0')
|
1270
|
-
: this.token === 'Do'
|
1271
|
-
? t + vi(t)
|
1272
|
-
: this.token === 'd'
|
1273
|
-
? e + 1
|
1274
|
-
: this.token === 'ddd'
|
1275
|
-
? this.locales.weekdaysShort[e]
|
1276
|
-
: this.token === 'dddd'
|
1277
|
-
? this.locales.weekdays[e]
|
1278
|
-
: t;
|
1279
|
-
}
|
1280
|
-
};
|
1281
|
-
var wi = bi;
|
1282
|
-
const yi = R;
|
1283
|
-
let $i = class extends yi {
|
1284
|
-
constructor(t = {}) {
|
1285
|
-
super(t);
|
1286
|
-
}
|
1287
|
-
up() {
|
1288
|
-
this.date.setHours(this.date.getHours() + 1);
|
1289
|
-
}
|
1290
|
-
down() {
|
1291
|
-
this.date.setHours(this.date.getHours() - 1);
|
1292
|
-
}
|
1293
|
-
setTo(t) {
|
1294
|
-
this.date.setHours(parseInt(t.substr(-2)));
|
1295
|
-
}
|
1296
|
-
toString() {
|
1297
|
-
let t = this.date.getHours();
|
1298
|
-
return (
|
1299
|
-
/h/.test(this.token) && (t = t % 12 || 12),
|
1300
|
-
this.token.length > 1 ? String(t).padStart(2, '0') : t
|
1301
|
-
);
|
1302
|
-
}
|
1303
|
-
};
|
1304
|
-
var xi = $i;
|
1305
|
-
const Si = R;
|
1306
|
-
let Ei = class extends Si {
|
1307
|
-
constructor(t = {}) {
|
1308
|
-
super(t);
|
1309
|
-
}
|
1310
|
-
up() {
|
1311
|
-
this.date.setMilliseconds(this.date.getMilliseconds() + 1);
|
1312
|
-
}
|
1313
|
-
down() {
|
1314
|
-
this.date.setMilliseconds(this.date.getMilliseconds() - 1);
|
1315
|
-
}
|
1316
|
-
setTo(t) {
|
1317
|
-
this.date.setMilliseconds(parseInt(t.substr(-this.token.length)));
|
1318
|
-
}
|
1319
|
-
toString() {
|
1320
|
-
return String(this.date.getMilliseconds()).padStart(4, '0').substr(0, this.token.length);
|
1321
|
-
}
|
1322
|
-
};
|
1323
|
-
var Ti = Ei;
|
1324
|
-
const Oi = R;
|
1325
|
-
let Pi = class extends Oi {
|
1326
|
-
constructor(t = {}) {
|
1327
|
-
super(t);
|
1328
|
-
}
|
1329
|
-
up() {
|
1330
|
-
this.date.setMinutes(this.date.getMinutes() + 1);
|
1331
|
-
}
|
1332
|
-
down() {
|
1333
|
-
this.date.setMinutes(this.date.getMinutes() - 1);
|
1334
|
-
}
|
1335
|
-
setTo(t) {
|
1336
|
-
this.date.setMinutes(parseInt(t.substr(-2)));
|
1337
|
-
}
|
1338
|
-
toString() {
|
1339
|
-
let t = this.date.getMinutes();
|
1340
|
-
return this.token.length > 1 ? String(t).padStart(2, '0') : t;
|
1341
|
-
}
|
1342
|
-
};
|
1343
|
-
var Ci = Pi;
|
1344
|
-
const Mi = R;
|
1345
|
-
let Di = class extends Mi {
|
1346
|
-
constructor(t = {}) {
|
1347
|
-
super(t);
|
1348
|
-
}
|
1349
|
-
up() {
|
1350
|
-
this.date.setMonth(this.date.getMonth() + 1);
|
1351
|
-
}
|
1352
|
-
down() {
|
1353
|
-
this.date.setMonth(this.date.getMonth() - 1);
|
1354
|
-
}
|
1355
|
-
setTo(t) {
|
1356
|
-
(t = parseInt(t.substr(-2)) - 1), this.date.setMonth(t < 0 ? 0 : t);
|
1357
|
-
}
|
1358
|
-
toString() {
|
1359
|
-
let t = this.date.getMonth(),
|
1360
|
-
e = this.token.length;
|
1361
|
-
return e === 2
|
1362
|
-
? String(t + 1).padStart(2, '0')
|
1363
|
-
: e === 3
|
1364
|
-
? this.locales.monthsShort[t]
|
1365
|
-
: e === 4
|
1366
|
-
? this.locales.months[t]
|
1367
|
-
: String(t + 1);
|
1368
|
-
}
|
1369
|
-
};
|
1370
|
-
var _i = Di;
|
1371
|
-
const Ii = R;
|
1372
|
-
let Ai = class extends Ii {
|
1373
|
-
constructor(t = {}) {
|
1374
|
-
super(t);
|
1375
|
-
}
|
1376
|
-
up() {
|
1377
|
-
this.date.setSeconds(this.date.getSeconds() + 1);
|
1378
|
-
}
|
1379
|
-
down() {
|
1380
|
-
this.date.setSeconds(this.date.getSeconds() - 1);
|
1381
|
-
}
|
1382
|
-
setTo(t) {
|
1383
|
-
this.date.setSeconds(parseInt(t.substr(-2)));
|
1384
|
-
}
|
1385
|
-
toString() {
|
1386
|
-
let t = this.date.getSeconds();
|
1387
|
-
return this.token.length > 1 ? String(t).padStart(2, '0') : t;
|
1388
|
-
}
|
1389
|
-
};
|
1390
|
-
var Ri = Ai;
|
1391
|
-
const ki = R;
|
1392
|
-
let Ni = class extends ki {
|
1393
|
-
constructor(t = {}) {
|
1394
|
-
super(t);
|
1395
|
-
}
|
1396
|
-
up() {
|
1397
|
-
this.date.setFullYear(this.date.getFullYear() + 1);
|
1398
|
-
}
|
1399
|
-
down() {
|
1400
|
-
this.date.setFullYear(this.date.getFullYear() - 1);
|
1401
|
-
}
|
1402
|
-
setTo(t) {
|
1403
|
-
this.date.setFullYear(t.substr(-4));
|
1404
|
-
}
|
1405
|
-
toString() {
|
1406
|
-
let t = String(this.date.getFullYear()).padStart(4, '0');
|
1407
|
-
return this.token.length === 2 ? t.substr(-2) : t;
|
1408
|
-
}
|
1409
|
-
};
|
1410
|
-
var ji = Ni,
|
1411
|
-
Fi = {
|
1412
|
-
DatePart: R,
|
1413
|
-
Meridiem: mi,
|
1414
|
-
Day: wi,
|
1415
|
-
Hours: xi,
|
1416
|
-
Milliseconds: Ti,
|
1417
|
-
Minutes: Ci,
|
1418
|
-
Month: _i,
|
1419
|
-
Seconds: Ri,
|
1420
|
-
Year: ji,
|
1421
|
-
};
|
1422
|
-
const Pt = M,
|
1423
|
-
Li = j,
|
1424
|
-
{ style: he, clear: ue, figures: Vi } = _,
|
1425
|
-
{ erase: Yi, cursor: ce } = D,
|
1426
|
-
{
|
1427
|
-
DatePart: de,
|
1428
|
-
Meridiem: Hi,
|
1429
|
-
Day: Bi,
|
1430
|
-
Hours: Ui,
|
1431
|
-
Milliseconds: zi,
|
1432
|
-
Minutes: Wi,
|
1433
|
-
Month: Gi,
|
1434
|
-
Seconds: Ji,
|
1435
|
-
Year: Ki,
|
1436
|
-
} = Fi,
|
1437
|
-
qi =
|
1438
|
-
/\\(.)|"((?:\\["\\]|[^"])+)"|(D[Do]?|d{3,4}|d)|(M{1,4})|(YY(?:YY)?)|([aA])|([Hh]{1,2})|(m{1,2})|(s{1,2})|(S{1,4})|./g,
|
1439
|
-
fe = {
|
1440
|
-
1: ({ token: s }) => s.replace(/\\(.)/g, '$1'),
|
1441
|
-
2: (s) => new Bi(s),
|
1442
|
-
3: (s) => new Gi(s),
|
1443
|
-
4: (s) => new Ki(s),
|
1444
|
-
5: (s) => new Hi(s),
|
1445
|
-
6: (s) => new Ui(s),
|
1446
|
-
7: (s) => new Wi(s),
|
1447
|
-
8: (s) => new Ji(s),
|
1448
|
-
9: (s) => new zi(s),
|
1449
|
-
},
|
1450
|
-
Zi = {
|
1451
|
-
months:
|
1452
|
-
'January,February,March,April,May,June,July,August,September,October,November,December'.split(
|
1453
|
-
',',
|
1454
|
-
),
|
1455
|
-
monthsShort: 'Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec'.split(','),
|
1456
|
-
weekdays: 'Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday'.split(','),
|
1457
|
-
weekdaysShort: 'Sun,Mon,Tue,Wed,Thu,Fri,Sat'.split(','),
|
1458
|
-
};
|
1459
|
-
class Xi extends Li {
|
1460
|
-
constructor(t = {}) {
|
1461
|
-
super(t),
|
1462
|
-
(this.msg = t.message),
|
1463
|
-
(this.cursor = 0),
|
1464
|
-
(this.typed = ''),
|
1465
|
-
(this.locales = Object.assign(Zi, t.locales)),
|
1466
|
-
(this._date = t.initial || new Date()),
|
1467
|
-
(this.errorMsg = t.error || 'Please Enter A Valid Value'),
|
1468
|
-
(this.validator = t.validate || (() => !0)),
|
1469
|
-
(this.mask = t.mask || 'YYYY-MM-DD HH:mm:ss'),
|
1470
|
-
(this.clear = ue('', this.out.columns)),
|
1471
|
-
this.render();
|
1472
|
-
}
|
1473
|
-
get value() {
|
1474
|
-
return this.date;
|
1475
|
-
}
|
1476
|
-
get date() {
|
1477
|
-
return this._date;
|
1478
|
-
}
|
1479
|
-
set date(t) {
|
1480
|
-
t && this._date.setTime(t.getTime());
|
1481
|
-
}
|
1482
|
-
set mask(t) {
|
1483
|
-
let e;
|
1484
|
-
for (this.parts = []; (e = qi.exec(t)); ) {
|
1485
|
-
let o = e.shift(),
|
1486
|
-
n = e.findIndex((r) => r != null);
|
1487
|
-
this.parts.push(
|
1488
|
-
n in fe
|
1489
|
-
? fe[n]({ token: e[n] || o, date: this.date, parts: this.parts, locales: this.locales })
|
1490
|
-
: e[n] || o,
|
1491
|
-
);
|
1492
|
-
}
|
1493
|
-
let i = this.parts.reduce(
|
1494
|
-
(o, n) => (
|
1495
|
-
typeof n == 'string' && typeof o[o.length - 1] == 'string'
|
1496
|
-
? (o[o.length - 1] += n)
|
1497
|
-
: o.push(n),
|
1498
|
-
o
|
1499
|
-
),
|
1500
|
-
[],
|
1501
|
-
);
|
1502
|
-
this.parts.splice(0), this.parts.push(...i), this.reset();
|
1503
|
-
}
|
1504
|
-
moveCursor(t) {
|
1505
|
-
(this.typed = ''), (this.cursor = t), this.fire();
|
1506
|
-
}
|
1507
|
-
reset() {
|
1508
|
-
this.moveCursor(this.parts.findIndex((t) => t instanceof de)), this.fire(), this.render();
|
1509
|
-
}
|
1510
|
-
exit() {
|
1511
|
-
this.abort();
|
1512
|
-
}
|
1513
|
-
abort() {
|
1514
|
-
(this.done = this.aborted = !0),
|
1515
|
-
(this.error = !1),
|
1516
|
-
this.fire(),
|
1517
|
-
this.render(),
|
1518
|
-
this.out.write(`
|
1519
|
-
`),
|
1520
|
-
this.close();
|
1521
|
-
}
|
1522
|
-
async validate() {
|
1523
|
-
let t = await this.validator(this.value);
|
1524
|
-
typeof t == 'string' && ((this.errorMsg = t), (t = !1)), (this.error = !t);
|
1525
|
-
}
|
1526
|
-
async submit() {
|
1527
|
-
if ((await this.validate(), this.error)) {
|
1528
|
-
(this.color = 'red'), this.fire(), this.render();
|
1529
|
-
return;
|
1530
|
-
}
|
1531
|
-
(this.done = !0),
|
1532
|
-
(this.aborted = !1),
|
1533
|
-
this.fire(),
|
1534
|
-
this.render(),
|
1535
|
-
this.out.write(`
|
1536
|
-
`),
|
1537
|
-
this.close();
|
1538
|
-
}
|
1539
|
-
up() {
|
1540
|
-
(this.typed = ''), this.parts[this.cursor].up(), this.render();
|
1541
|
-
}
|
1542
|
-
down() {
|
1543
|
-
(this.typed = ''), this.parts[this.cursor].down(), this.render();
|
1544
|
-
}
|
1545
|
-
left() {
|
1546
|
-
let t = this.parts[this.cursor].prev();
|
1547
|
-
if (t == null) return this.bell();
|
1548
|
-
this.moveCursor(this.parts.indexOf(t)), this.render();
|
1549
|
-
}
|
1550
|
-
right() {
|
1551
|
-
let t = this.parts[this.cursor].next();
|
1552
|
-
if (t == null) return this.bell();
|
1553
|
-
this.moveCursor(this.parts.indexOf(t)), this.render();
|
1554
|
-
}
|
1555
|
-
next() {
|
1556
|
-
let t = this.parts[this.cursor].next();
|
1557
|
-
this.moveCursor(t ? this.parts.indexOf(t) : this.parts.findIndex((e) => e instanceof de)),
|
1558
|
-
this.render();
|
1559
|
-
}
|
1560
|
-
_(t) {
|
1561
|
-
/\d/.test(t) && ((this.typed += t), this.parts[this.cursor].setTo(this.typed), this.render());
|
1562
|
-
}
|
1563
|
-
render() {
|
1564
|
-
this.closed ||
|
1565
|
-
(this.firstRender
|
1566
|
-
? this.out.write(ce.hide)
|
1567
|
-
: this.out.write(ue(this.outputText, this.out.columns)),
|
1568
|
-
super.render(),
|
1569
|
-
(this.outputText = [
|
1570
|
-
he.symbol(this.done, this.aborted),
|
1571
|
-
Pt.bold(this.msg),
|
1572
|
-
he.delimiter(!1),
|
1573
|
-
this.parts
|
1574
|
-
.reduce(
|
1575
|
-
(t, e, i) =>
|
1576
|
-
t.concat(i === this.cursor && !this.done ? Pt.cyan().underline(e.toString()) : e),
|
1577
|
-
[],
|
1578
|
-
)
|
1579
|
-
.join(''),
|
1580
|
-
].join(' ')),
|
1581
|
-
this.error &&
|
1582
|
-
(this.outputText += this.errorMsg
|
1583
|
-
.split(`
|
1584
|
-
`)
|
1585
|
-
.reduce(
|
1586
|
-
(t, e, i) =>
|
1587
|
-
t +
|
1588
|
-
`
|
1589
|
-
${i ? ' ' : Vi.pointerSmall} ${Pt.red().italic(e)}`,
|
1590
|
-
'',
|
1591
|
-
)),
|
1592
|
-
this.out.write(Yi.line + ce.to(0) + this.outputText));
|
1593
|
-
}
|
1594
|
-
}
|
1595
|
-
var Qi = Xi;
|
1596
|
-
const rt = M,
|
1597
|
-
tr = j,
|
1598
|
-
{ cursor: nt, erase: er } = D,
|
1599
|
-
{ style: Ct, figures: sr, clear: pe, lines: ir } = _,
|
1600
|
-
rr = /[0-9]/,
|
1601
|
-
Mt = (s) => s !== void 0,
|
1602
|
-
me = (s, t) => {
|
1603
|
-
let e = Math.pow(10, t);
|
1604
|
-
return Math.round(s * e) / e;
|
1605
|
-
};
|
1606
|
-
class nr extends tr {
|
1607
|
-
constructor(t = {}) {
|
1608
|
-
super(t),
|
1609
|
-
(this.transform = Ct.render(t.style)),
|
1610
|
-
(this.msg = t.message),
|
1611
|
-
(this.initial = Mt(t.initial) ? t.initial : ''),
|
1612
|
-
(this.float = !!t.float),
|
1613
|
-
(this.round = t.round || 2),
|
1614
|
-
(this.inc = t.increment || 1),
|
1615
|
-
(this.min = Mt(t.min) ? t.min : -1 / 0),
|
1616
|
-
(this.max = Mt(t.max) ? t.max : 1 / 0),
|
1617
|
-
(this.errorMsg = t.error || 'Please Enter A Valid Value'),
|
1618
|
-
(this.validator = t.validate || (() => !0)),
|
1619
|
-
(this.color = 'cyan'),
|
1620
|
-
(this.value = ''),
|
1621
|
-
(this.typed = ''),
|
1622
|
-
(this.lastHit = 0),
|
1623
|
-
this.render();
|
1624
|
-
}
|
1625
|
-
set value(t) {
|
1626
|
-
!t && t !== 0
|
1627
|
-
? ((this.placeholder = !0),
|
1628
|
-
(this.rendered = rt.gray(this.transform.render(`${this.initial}`))),
|
1629
|
-
(this._value = ''))
|
1630
|
-
: ((this.placeholder = !1),
|
1631
|
-
(this.rendered = this.transform.render(`${me(t, this.round)}`)),
|
1632
|
-
(this._value = me(t, this.round))),
|
1633
|
-
this.fire();
|
1634
|
-
}
|
1635
|
-
get value() {
|
1636
|
-
return this._value;
|
1637
|
-
}
|
1638
|
-
parse(t) {
|
1639
|
-
return this.float ? parseFloat(t) : parseInt(t);
|
1640
|
-
}
|
1641
|
-
valid(t) {
|
1642
|
-
return t === '-' || (t === '.' && this.float) || rr.test(t);
|
1643
|
-
}
|
1644
|
-
reset() {
|
1645
|
-
(this.typed = ''), (this.value = ''), this.fire(), this.render();
|
1646
|
-
}
|
1647
|
-
exit() {
|
1648
|
-
this.abort();
|
1649
|
-
}
|
1650
|
-
abort() {
|
1651
|
-
let t = this.value;
|
1652
|
-
(this.value = t !== '' ? t : this.initial),
|
1653
|
-
(this.done = this.aborted = !0),
|
1654
|
-
(this.error = !1),
|
1655
|
-
this.fire(),
|
1656
|
-
this.render(),
|
1657
|
-
this.out.write(`
|
1658
|
-
`),
|
1659
|
-
this.close();
|
1660
|
-
}
|
1661
|
-
async validate() {
|
1662
|
-
let t = await this.validator(this.value);
|
1663
|
-
typeof t == 'string' && ((this.errorMsg = t), (t = !1)), (this.error = !t);
|
1664
|
-
}
|
1665
|
-
async submit() {
|
1666
|
-
if ((await this.validate(), this.error)) {
|
1667
|
-
(this.color = 'red'), this.fire(), this.render();
|
1668
|
-
return;
|
1669
|
-
}
|
1670
|
-
let t = this.value;
|
1671
|
-
(this.value = t !== '' ? t : this.initial),
|
1672
|
-
(this.done = !0),
|
1673
|
-
(this.aborted = !1),
|
1674
|
-
(this.error = !1),
|
1675
|
-
this.fire(),
|
1676
|
-
this.render(),
|
1677
|
-
this.out.write(`
|
1678
|
-
`),
|
1679
|
-
this.close();
|
1680
|
-
}
|
1681
|
-
up() {
|
1682
|
-
if (
|
1683
|
-
((this.typed = ''),
|
1684
|
-
this.value === '' && (this.value = this.min - this.inc),
|
1685
|
-
this.value >= this.max)
|
1686
|
-
)
|
1687
|
-
return this.bell();
|
1688
|
-
(this.value += this.inc), (this.color = 'cyan'), this.fire(), this.render();
|
1689
|
-
}
|
1690
|
-
down() {
|
1691
|
-
if (
|
1692
|
-
((this.typed = ''),
|
1693
|
-
this.value === '' && (this.value = this.min + this.inc),
|
1694
|
-
this.value <= this.min)
|
1695
|
-
)
|
1696
|
-
return this.bell();
|
1697
|
-
(this.value -= this.inc), (this.color = 'cyan'), this.fire(), this.render();
|
1698
|
-
}
|
1699
|
-
delete() {
|
1700
|
-
let t = this.value.toString();
|
1701
|
-
if (t.length === 0) return this.bell();
|
1702
|
-
(this.value = this.parse((t = t.slice(0, -1))) || ''),
|
1703
|
-
this.value !== '' && this.value < this.min && (this.value = this.min),
|
1704
|
-
(this.color = 'cyan'),
|
1705
|
-
this.fire(),
|
1706
|
-
this.render();
|
1707
|
-
}
|
1708
|
-
next() {
|
1709
|
-
(this.value = this.initial), this.fire(), this.render();
|
1710
|
-
}
|
1711
|
-
_(t, e) {
|
1712
|
-
if (!this.valid(t)) return this.bell();
|
1713
|
-
const i = Date.now();
|
1714
|
-
if (
|
1715
|
-
(i - this.lastHit > 1e3 && (this.typed = ''),
|
1716
|
-
(this.typed += t),
|
1717
|
-
(this.lastHit = i),
|
1718
|
-
(this.color = 'cyan'),
|
1719
|
-
t === '.')
|
1720
|
-
)
|
1721
|
-
return this.fire();
|
1722
|
-
(this.value = Math.min(this.parse(this.typed), this.max)),
|
1723
|
-
this.value > this.max && (this.value = this.max),
|
1724
|
-
this.value < this.min && (this.value = this.min),
|
1725
|
-
this.fire(),
|
1726
|
-
this.render();
|
1727
|
-
}
|
1728
|
-
render() {
|
1729
|
-
this.closed ||
|
1730
|
-
(this.firstRender ||
|
1731
|
-
(this.outputError &&
|
1732
|
-
this.out.write(
|
1733
|
-
nt.down(ir(this.outputError, this.out.columns) - 1) +
|
1734
|
-
pe(this.outputError, this.out.columns),
|
1735
|
-
),
|
1736
|
-
this.out.write(pe(this.outputText, this.out.columns))),
|
1737
|
-
super.render(),
|
1738
|
-
(this.outputError = ''),
|
1739
|
-
(this.outputText = [
|
1740
|
-
Ct.symbol(this.done, this.aborted),
|
1741
|
-
rt.bold(this.msg),
|
1742
|
-
Ct.delimiter(this.done),
|
1743
|
-
!this.done || (!this.done && !this.placeholder)
|
1744
|
-
? rt[this.color]().underline(this.rendered)
|
1745
|
-
: this.rendered,
|
1746
|
-
].join(' ')),
|
1747
|
-
this.error &&
|
1748
|
-
(this.outputError += this.errorMsg
|
1749
|
-
.split(`
|
1750
|
-
`)
|
1751
|
-
.reduce(
|
1752
|
-
(t, e, i) =>
|
1753
|
-
t +
|
1754
|
-
`
|
1755
|
-
${i ? ' ' : sr.pointerSmall} ${rt.red().italic(e)}`,
|
1756
|
-
'',
|
1757
|
-
)),
|
1758
|
-
this.out.write(
|
1759
|
-
er.line + nt.to(0) + this.outputText + nt.save + this.outputError + nt.restore,
|
1760
|
-
));
|
1761
|
-
}
|
1762
|
-
}
|
1763
|
-
var or = nr;
|
1764
|
-
const I = M,
|
1765
|
-
{ cursor: lr } = D,
|
1766
|
-
ar = j,
|
1767
|
-
{ clear: ge, figures: F, style: ve, wrap: hr, entriesToDisplay: ur } = _;
|
1768
|
-
let cr = class extends ar {
|
1769
|
-
constructor(t = {}) {
|
1770
|
-
super(t),
|
1771
|
-
(this.msg = t.message),
|
1772
|
-
(this.cursor = t.cursor || 0),
|
1773
|
-
(this.scrollIndex = t.cursor || 0),
|
1774
|
-
(this.hint = t.hint || ''),
|
1775
|
-
(this.warn = t.warn || '- This option is disabled -'),
|
1776
|
-
(this.minSelected = t.min),
|
1777
|
-
(this.showMinError = !1),
|
1778
|
-
(this.maxChoices = t.max),
|
1779
|
-
(this.instructions = t.instructions),
|
1780
|
-
(this.optionsPerPage = t.optionsPerPage || 10),
|
1781
|
-
(this.value = t.choices.map(
|
1782
|
-
(e, i) => (
|
1783
|
-
typeof e == 'string' && (e = { title: e, value: i }),
|
1784
|
-
{
|
1785
|
-
title: e && (e.title || e.value || e),
|
1786
|
-
description: e && e.description,
|
1787
|
-
value: e && (e.value === void 0 ? i : e.value),
|
1788
|
-
selected: e && e.selected,
|
1789
|
-
disabled: e && e.disabled,
|
1790
|
-
}
|
1791
|
-
),
|
1792
|
-
)),
|
1793
|
-
(this.clear = ge('', this.out.columns)),
|
1794
|
-
t.overrideRender || this.render();
|
1795
|
-
}
|
1796
|
-
reset() {
|
1797
|
-
this.value.map((t) => !t.selected), (this.cursor = 0), this.fire(), this.render();
|
1798
|
-
}
|
1799
|
-
selected() {
|
1800
|
-
return this.value.filter((t) => t.selected);
|
1801
|
-
}
|
1802
|
-
exit() {
|
1803
|
-
this.abort();
|
1804
|
-
}
|
1805
|
-
abort() {
|
1806
|
-
(this.done = this.aborted = !0),
|
1807
|
-
this.fire(),
|
1808
|
-
this.render(),
|
1809
|
-
this.out.write(`
|
1810
|
-
`),
|
1811
|
-
this.close();
|
1812
|
-
}
|
1813
|
-
submit() {
|
1814
|
-
const t = this.value.filter((e) => e.selected);
|
1815
|
-
this.minSelected && t.length < this.minSelected
|
1816
|
-
? ((this.showMinError = !0), this.render())
|
1817
|
-
: ((this.done = !0),
|
1818
|
-
(this.aborted = !1),
|
1819
|
-
this.fire(),
|
1820
|
-
this.render(),
|
1821
|
-
this.out.write(`
|
1822
|
-
`),
|
1823
|
-
this.close());
|
1824
|
-
}
|
1825
|
-
first() {
|
1826
|
-
(this.cursor = 0), this.render();
|
1827
|
-
}
|
1828
|
-
last() {
|
1829
|
-
(this.cursor = this.value.length - 1), this.render();
|
1830
|
-
}
|
1831
|
-
next() {
|
1832
|
-
(this.cursor = (this.cursor + 1) % this.value.length), this.render();
|
1833
|
-
}
|
1834
|
-
up() {
|
1835
|
-
this.cursor === 0 ? (this.cursor = this.value.length - 1) : this.cursor--, this.render();
|
1836
|
-
}
|
1837
|
-
down() {
|
1838
|
-
this.cursor === this.value.length - 1 ? (this.cursor = 0) : this.cursor++, this.render();
|
1839
|
-
}
|
1840
|
-
left() {
|
1841
|
-
(this.value[this.cursor].selected = !1), this.render();
|
1842
|
-
}
|
1843
|
-
right() {
|
1844
|
-
if (this.value.filter((t) => t.selected).length >= this.maxChoices) return this.bell();
|
1845
|
-
(this.value[this.cursor].selected = !0), this.render();
|
1846
|
-
}
|
1847
|
-
handleSpaceToggle() {
|
1848
|
-
const t = this.value[this.cursor];
|
1849
|
-
if (t.selected) (t.selected = !1), this.render();
|
1850
|
-
else {
|
1851
|
-
if (t.disabled || this.value.filter((e) => e.selected).length >= this.maxChoices)
|
1852
|
-
return this.bell();
|
1853
|
-
(t.selected = !0), this.render();
|
1854
|
-
}
|
1855
|
-
}
|
1856
|
-
toggleAll() {
|
1857
|
-
if (this.maxChoices !== void 0 || this.value[this.cursor].disabled) return this.bell();
|
1858
|
-
const t = !this.value[this.cursor].selected;
|
1859
|
-
this.value.filter((e) => !e.disabled).forEach((e) => (e.selected = t)), this.render();
|
1860
|
-
}
|
1861
|
-
_(t, e) {
|
1862
|
-
if (t === ' ') this.handleSpaceToggle();
|
1863
|
-
else if (t === 'a') this.toggleAll();
|
1864
|
-
else return this.bell();
|
1865
|
-
}
|
1866
|
-
renderInstructions() {
|
1867
|
-
return this.instructions === void 0 || this.instructions
|
1868
|
-
? typeof this.instructions == 'string'
|
1869
|
-
? this.instructions
|
1870
|
-
: `
|
1
|
+
import T from"node:fs";import C from"node:path";import{fileURLToPath as Ne}from"node:url";import je from"child_process";import lt from"path";import at from"fs";import Fe from"readline";import Le from"events";var Ve=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},B={exports:{}},ht,jt;function Ye(){if(jt)return ht;jt=1,ht=i,i.sync=o;var s=at;function t(n,r){var l=r.pathExt!==void 0?r.pathExt:process.env.PATHEXT;if(!l||(l=l.split(";"),l.indexOf("")!==-1))return!0;for(var c=0;c<l.length;c++){var h=l[c].toLowerCase();if(h&&n.substr(-h.length).toLowerCase()===h)return!0}return!1}function e(n,r,l){return!n.isSymbolicLink()&&!n.isFile()?!1:t(r,l)}function i(n,r,l){s.stat(n,function(c,h){l(c,c?!1:e(h,n,r))})}function o(n,r){return e(s.statSync(n),n,r)}return ht}var ut,Ft;function He(){if(Ft)return ut;Ft=1,ut=t,t.sync=e;var s=at;function t(n,r,l){s.stat(n,function(c,h){l(c,c?!1:i(h,r))})}function e(n,r){return i(s.statSync(n),r)}function i(n,r){return n.isFile()&&o(n,r)}function o(n,r){var l=n.mode,c=n.uid,h=n.gid,$=r.uid!==void 0?r.uid:process.getuid&&process.getuid(),f=r.gid!==void 0?r.gid:process.getgid&&process.getgid(),a=parseInt("100",8),b=parseInt("010",8),p=parseInt("001",8),S=a|b,E=l&p||l&b&&h===f||l&a&&c===$||l&S&&$===0;return E}return ut}var tt;process.platform==="win32"||Ve.TESTING_WINDOWS?tt=Ye():tt=He();var Be=ct;ct.sync=Ue;function ct(s,t,e){if(typeof t=="function"&&(e=t,t={}),!e){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(i,o){ct(s,t||{},function(n,r){n?o(n):i(r)})})}tt(s,t||{},function(i,o){i&&(i.code==="EACCES"||t&&t.ignoreErrors)&&(i=null,o=!1),e(i,o)})}function Ue(s,t){try{return tt.sync(s,t||{})}catch(e){if(t&&t.ignoreErrors||e.code==="EACCES")return!1;throw e}}const U=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",Lt=lt,ze=U?";":":",Vt=Be,Yt=s=>Object.assign(new Error(`not found: ${s}`),{code:"ENOENT"}),Ht=(s,t)=>{const e=t.colon||ze,i=s.match(/\//)||U&&s.match(/\\/)?[""]:[...U?[process.cwd()]:[],...(t.path||process.env.PATH||"").split(e)],o=U?t.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",n=U?o.split(e):[""];return U&&s.indexOf(".")!==-1&&n[0]!==""&&n.unshift(""),{pathEnv:i,pathExt:n,pathExtExe:o}},Bt=(s,t,e)=>{typeof t=="function"&&(e=t,t={}),t||(t={});const{pathEnv:i,pathExt:o,pathExtExe:n}=Ht(s,t),r=[],l=h=>new Promise(($,f)=>{if(h===i.length)return t.all&&r.length?$(r):f(Yt(s));const a=i[h],b=/^".*"$/.test(a)?a.slice(1,-1):a,p=Lt.join(b,s),S=!b&&/^\.[\\\/]/.test(s)?s.slice(0,2)+p:p;$(c(S,h,0))}),c=(h,$,f)=>new Promise((a,b)=>{if(f===o.length)return a(l($+1));const p=o[f];Vt(h+p,{pathExt:n},(S,E)=>{if(!S&&E)if(t.all)r.push(h+p);else return a(h+p);return a(c(h,$,f+1))})});return e?l(0).then(h=>e(null,h),e):l(0)},We=(s,t)=>{t=t||{};const{pathEnv:e,pathExt:i,pathExtExe:o}=Ht(s,t),n=[];for(let r=0;r<e.length;r++){const l=e[r],c=/^".*"$/.test(l)?l.slice(1,-1):l,h=Lt.join(c,s),$=!c&&/^\.[\\\/]/.test(s)?s.slice(0,2)+h:h;for(let f=0;f<i.length;f++){const a=$+i[f];try{if(Vt.sync(a,{pathExt:o}))if(t.all)n.push(a);else return a}catch{}}}if(t.all&&n.length)return n;if(t.nothrow)return null;throw Yt(s)};var Ge=Bt;Bt.sync=We;var dt={exports:{}};const Ut=(s={})=>{const t=s.env||process.env;return(s.platform||process.platform)!=="win32"?"PATH":Object.keys(t).reverse().find(i=>i.toUpperCase()==="PATH")||"Path"};dt.exports=Ut,dt.exports.default=Ut;const zt=lt,Je=Ge,Ke=dt.exports;function Wt(s,t){const e=s.options.env||process.env,i=process.cwd(),o=s.options.cwd!=null,n=o&&process.chdir!==void 0&&!process.chdir.disabled;if(n)try{process.chdir(s.options.cwd)}catch{}let r;try{r=Je.sync(s.command,{path:e[Ke({env:e})],pathExt:t?zt.delimiter:void 0})}catch{}finally{n&&process.chdir(i)}return r&&(r=zt.resolve(o?s.options.cwd:"",r)),r}function qe(s){return Wt(s)||Wt(s,!0)}var Ze=qe,ft={};const pt=/([()\][%!^"`<>&|;, *?])/g;function Xe(s){return s=s.replace(pt,"^$1"),s}function Qe(s,t){return s=`${s}`,s=s.replace(/(\\*)"/g,'$1$1\\"'),s=s.replace(/(\\*)$/,"$1$1"),s=`"${s}"`,s=s.replace(pt,"^$1"),t&&(s=s.replace(pt,"^$1")),s}ft.command=Xe,ft.argument=Qe;var ts=/^#!(.*)/;const es=ts;var ss=(s="")=>{const t=s.match(es);if(!t)return null;const[e,i]=t[0].replace(/#! ?/,"").split(" "),o=e.split("/").pop();return o==="env"?i:i?`${o} ${i}`:o};const mt=at,is=ss;function rs(s){const e=Buffer.alloc(150);let i;try{i=mt.openSync(s,"r"),mt.readSync(i,e,0,150,0),mt.closeSync(i)}catch{}return is(e.toString())}var ns=rs;const os=lt,Gt=Ze,Jt=ft,ls=ns,as=process.platform==="win32",hs=/\.(?:com|exe)$/i,us=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function cs(s){s.file=Gt(s);const t=s.file&&ls(s.file);return t?(s.args.unshift(s.file),s.command=t,Gt(s)):s.file}function ds(s){if(!as)return s;const t=cs(s),e=!hs.test(t);if(s.options.forceShell||e){const i=us.test(t);s.command=os.normalize(s.command),s.command=Jt.command(s.command),s.args=s.args.map(n=>Jt.argument(n,i));const o=[s.command].concat(s.args).join(" ");s.args=["/d","/s","/c",`"${o}"`],s.command=process.env.comspec||"cmd.exe",s.options.windowsVerbatimArguments=!0}return s}function fs(s,t,e){t&&!Array.isArray(t)&&(e=t,t=null),t=t?t.slice(0):[],e=Object.assign({},e);const i={command:s,args:t,options:e,file:void 0,original:{command:s,args:t}};return e.shell?i:ds(i)}var ps=fs;const gt=process.platform==="win32";function vt(s,t){return Object.assign(new Error(`${t} ${s.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${t} ${s.command}`,path:s.command,spawnargs:s.args})}function ms(s,t){if(!gt)return;const e=s.emit;s.emit=function(i,o){if(i==="exit"){const n=Kt(o,t);if(n)return e.call(s,"error",n)}return e.apply(s,arguments)}}function Kt(s,t){return gt&&s===1&&!t.file?vt(t.original,"spawn"):null}function gs(s,t){return gt&&s===1&&!t.file?vt(t.original,"spawnSync"):null}var vs={hookChildProcess:ms,verifyENOENT:Kt,verifyENOENTSync:gs,notFoundError:vt};const qt=je,bt=ps,wt=vs;function Zt(s,t,e){const i=bt(s,t,e),o=qt.spawn(i.command,i.args,i.options);return wt.hookChildProcess(o,i),o}function bs(s,t,e){const i=bt(s,t,e),o=qt.spawnSync(i.command,i.args,i.options);return o.error=o.error||wt.verifyENOENTSync(o.status,i),o}B.exports=Zt,B.exports.spawn=Zt,B.exports.sync=bs,B.exports._parse=bt,B.exports._enoent=wt;var ws=function(s,t){t||(t={});var e={bools:{},strings:{},unknownFn:null};typeof t.unknown=="function"&&(e.unknownFn=t.unknown),typeof t.boolean=="boolean"&&t.boolean?e.allBools=!0:[].concat(t.boolean).filter(Boolean).forEach(function(u){e.bools[u]=!0});var i={};Object.keys(t.alias||{}).forEach(function(u){i[u]=[].concat(t.alias[u]),i[u].forEach(function(w){i[w]=[u].concat(i[u].filter(function(P){return w!==P}))})}),[].concat(t.string).filter(Boolean).forEach(function(u){e.strings[u]=!0,i[u]&&(e.strings[i[u]]=!0)});var o=t.default||{},n={_:[]};Object.keys(e.bools).forEach(function(u){c(u,o[u]===void 0?!1:o[u])});var r=[];s.indexOf("--")!==-1&&(r=s.slice(s.indexOf("--")+1),s=s.slice(0,s.indexOf("--")));function l(u,w){return e.allBools&&/^--[^=]+$/.test(w)||e.strings[u]||e.bools[u]||i[u]}function c(u,w,P){if(!(P&&e.unknownFn&&!l(u,P)&&e.unknownFn(P)===!1)){var g=!e.strings[u]&&Xt(w)?Number(w):w;h(n,u.split("."),g),(i[u]||[]).forEach(function(K){h(n,K.split("."),g)})}}function h(u,w,P){for(var g=u,K=0;K<w.length-1;K++){var x=w[K];if(Qt(g,x))return;g[x]===void 0&&(g[x]={}),(g[x]===Object.prototype||g[x]===Number.prototype||g[x]===String.prototype)&&(g[x]={}),g[x]===Array.prototype&&(g[x]=[]),g=g[x]}var x=w[w.length-1];Qt(g,x)||((g===Object.prototype||g===Number.prototype||g===String.prototype)&&(g={}),g===Array.prototype&&(g=[]),g[x]===void 0||e.bools[x]||typeof g[x]=="boolean"?g[x]=P:Array.isArray(g[x])?g[x].push(P):g[x]=[g[x],P])}function $(u){return i[u].some(function(w){return e.bools[w]})}for(var f=0;f<s.length;f++){var a=s[f];if(/^--.+=/.test(a)){var b=a.match(/^--([^=]+)=([\s\S]*)$/),p=b[1],S=b[2];e.bools[p]&&(S=S!=="false"),c(p,S,a)}else if(/^--no-.+/.test(a)){var p=a.match(/^--no-(.+)/)[1];c(p,!1,a)}else if(/^--.+/.test(a)){var p=a.match(/^--(.+)/)[1],E=s[f+1];E!==void 0&&!/^-/.test(E)&&!e.bools[p]&&!e.allBools&&(i[p]?!$(p):!0)?(c(p,E,a),f++):/^(true|false)$/.test(E)?(c(p,E==="true",a),f++):c(p,e.strings[p]?"":!0,a)}else if(/^-[^-]+/.test(a)){for(var O=a.slice(1,-1).split(""),V=!1,d=0;d<O.length;d++){var E=a.slice(d+2);if(E==="-"){c(O[d],E,a);continue}if(/[A-Za-z]/.test(O[d])&&/=/.test(E)){c(O[d],E.split("=")[1],a),V=!0;break}if(/[A-Za-z]/.test(O[d])&&/-?\d+(\.\d*)?(e-?\d+)?$/.test(E)){c(O[d],E,a),V=!0;break}if(O[d+1]&&O[d+1].match(/\W/)){c(O[d],a.slice(d+2),a),V=!0;break}else c(O[d],e.strings[O[d]]?"":!0,a)}var p=a.slice(-1)[0];!V&&p!=="-"&&(s[f+1]&&!/^(-|--)[^-]/.test(s[f+1])&&!e.bools[p]&&(i[p]?!$(p):!0)?(c(p,s[f+1],a),f++):s[f+1]&&/^(true|false)$/.test(s[f+1])?(c(p,s[f+1]==="true",a),f++):c(p,e.strings[p]?"":!0,a))}else if((!e.unknownFn||e.unknownFn(a)!==!1)&&n._.push(e.strings._||!Xt(a)?a:Number(a)),t.stopEarly){n._.push.apply(n._,s.slice(f+1));break}}return Object.keys(o).forEach(function(u){ys(n,u.split("."))||(h(n,u.split("."),o[u]),(i[u]||[]).forEach(function(w){h(n,w.split("."),o[u])}))}),t["--"]?(n["--"]=new Array,r.forEach(function(u){n["--"].push(u)})):r.forEach(function(u){n._.push(u)}),n};function ys(s,t){var e=s;t.slice(0,-1).forEach(function(o){e=e[o]||{}});var i=t[t.length-1];return i in e}function Xt(s){return typeof s=="number"||/^0x[0-9a-f]+$/i.test(s)?!0:/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(s)}function Qt(s,t){return t==="constructor"&&typeof s[t]=="function"||t==="__proto__"}var te={};const{FORCE_COLOR:$s,NODE_DISABLE_COLORS:xs,TERM:Ss}=process.env,m={enabled:!xs&&Ss!=="dumb"&&$s!=="0",reset:v(0,0),bold:v(1,22),dim:v(2,22),italic:v(3,23),underline:v(4,24),inverse:v(7,27),hidden:v(8,28),strikethrough:v(9,29),black:v(30,39),red:v(31,39),green:v(32,39),yellow:v(33,39),blue:v(34,39),magenta:v(35,39),cyan:v(36,39),white:v(37,39),gray:v(90,39),grey:v(90,39),bgBlack:v(40,49),bgRed:v(41,49),bgGreen:v(42,49),bgYellow:v(43,49),bgBlue:v(44,49),bgMagenta:v(45,49),bgCyan:v(46,49),bgWhite:v(47,49)};function ee(s,t){let e=0,i,o="",n="";for(;e<s.length;e++)i=s[e],o+=i.open,n+=i.close,t.includes(i.close)&&(t=t.replace(i.rgx,i.close+i.open));return o+t+n}function Es(s,t){let e={has:s,keys:t};return e.reset=m.reset.bind(e),e.bold=m.bold.bind(e),e.dim=m.dim.bind(e),e.italic=m.italic.bind(e),e.underline=m.underline.bind(e),e.inverse=m.inverse.bind(e),e.hidden=m.hidden.bind(e),e.strikethrough=m.strikethrough.bind(e),e.black=m.black.bind(e),e.red=m.red.bind(e),e.green=m.green.bind(e),e.yellow=m.yellow.bind(e),e.blue=m.blue.bind(e),e.magenta=m.magenta.bind(e),e.cyan=m.cyan.bind(e),e.white=m.white.bind(e),e.gray=m.gray.bind(e),e.grey=m.grey.bind(e),e.bgBlack=m.bgBlack.bind(e),e.bgRed=m.bgRed.bind(e),e.bgGreen=m.bgGreen.bind(e),e.bgYellow=m.bgYellow.bind(e),e.bgBlue=m.bgBlue.bind(e),e.bgMagenta=m.bgMagenta.bind(e),e.bgCyan=m.bgCyan.bind(e),e.bgWhite=m.bgWhite.bind(e),e}function v(s,t){let e={open:`\x1B[${s}m`,close:`\x1B[${t}m`,rgx:new RegExp(`\\x1b\\[${t}m`,"g")};return function(i){return this!==void 0&&this.has!==void 0?(this.has.includes(s)||(this.has.push(s),this.keys.push(e)),i===void 0?this:m.enabled?ee(this.keys,i+""):i+""):i===void 0?Es([s],[e]):m.enabled?ee([e],i+""):i+""}}var M=m,Ts=(s,t)=>{if(!(s.meta&&s.name!=="escape")){if(s.ctrl){if(s.name==="a")return"first";if(s.name==="c"||s.name==="d")return"abort";if(s.name==="e")return"last";if(s.name==="g")return"reset"}if(t){if(s.name==="j")return"down";if(s.name==="k")return"up"}return s.name==="return"||s.name==="enter"?"submit":s.name==="backspace"?"delete":s.name==="delete"?"deleteForward":s.name==="abort"?"abort":s.name==="escape"?"exit":s.name==="tab"?"next":s.name==="pagedown"?"nextPage":s.name==="pageup"?"prevPage":s.name==="home"?"home":s.name==="end"?"end":s.name==="up"?"up":s.name==="down"?"down":s.name==="right"?"right":s.name==="left"?"left":!1}},yt=s=>{const t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))"].join("|"),e=new RegExp(t,"g");return typeof s=="string"?s.replace(e,""):s};const $t="\x1B",y=`${$t}[`,Os="\x07",xt={to(s,t){return t?`${y}${t+1};${s+1}H`:`${y}${s+1}G`},move(s,t){let e="";return s<0?e+=`${y}${-s}D`:s>0&&(e+=`${y}${s}C`),t<0?e+=`${y}${-t}A`:t>0&&(e+=`${y}${t}B`),e},up:(s=1)=>`${y}${s}A`,down:(s=1)=>`${y}${s}B`,forward:(s=1)=>`${y}${s}C`,backward:(s=1)=>`${y}${s}D`,nextLine:(s=1)=>`${y}E`.repeat(s),prevLine:(s=1)=>`${y}F`.repeat(s),left:`${y}G`,hide:`${y}?25l`,show:`${y}?25h`,save:`${$t}7`,restore:`${$t}8`},Ps={up:(s=1)=>`${y}S`.repeat(s),down:(s=1)=>`${y}T`.repeat(s)},Cs={screen:`${y}2J`,up:(s=1)=>`${y}1J`.repeat(s),down:(s=1)=>`${y}J`.repeat(s),line:`${y}2K`,lineEnd:`${y}K`,lineStart:`${y}1K`,lines(s){let t="";for(let e=0;e<s;e++)t+=this.line+(e<s-1?xt.up():"");return s&&(t+=xt.left),t}};var D={cursor:xt,scroll:Ps,erase:Cs,beep:Os};const Ms=yt,{erase:se,cursor:Ds}=D,_s=s=>[...Ms(s)].length;var Is=function(s,t){if(!t)return se.line+Ds.to(0);let e=0;const i=s.split(/\r?\n/);for(let o of i)e+=1+Math.floor(Math.max(_s(o)-1,0)/t);return se.lines(e)};const q={arrowUp:"\u2191",arrowDown:"\u2193",arrowLeft:"\u2190",arrowRight:"\u2192",radioOn:"\u25C9",radioOff:"\u25EF",tick:"\u2714",cross:"\u2716",ellipsis:"\u2026",pointerSmall:"\u203A",line:"\u2500",pointer:"\u276F"},As={arrowUp:q.arrowUp,arrowDown:q.arrowDown,arrowLeft:q.arrowLeft,arrowRight:q.arrowRight,radioOn:"(*)",radioOff:"( )",tick:"\u221A",cross:"\xD7",ellipsis:"...",pointerSmall:"\xBB",line:"\u2500",pointer:">"},Rs=process.platform==="win32"?As:q;var ie=Rs;const z=M,Y=ie,St=Object.freeze({password:{scale:1,render:s=>"*".repeat(s.length)},emoji:{scale:2,render:s=>"\u{1F603}".repeat(s.length)},invisible:{scale:0,render:s=>""},default:{scale:1,render:s=>`${s}`}}),ks=s=>St[s]||St.default,Z=Object.freeze({aborted:z.red(Y.cross),done:z.green(Y.tick),exited:z.yellow(Y.cross),default:z.cyan("?")}),Ns=(s,t,e)=>t?Z.aborted:e?Z.exited:s?Z.done:Z.default,js=s=>z.gray(s?Y.ellipsis:Y.pointerSmall),Fs=(s,t)=>z.gray(s?t?Y.pointerSmall:"+":Y.line);var Ls={styles:St,render:ks,symbols:Z,symbol:Ns,delimiter:js,item:Fs};const Vs=yt;var Ys=function(s,t){let e=String(Vs(s)||"").split(/\r?\n/);return t?e.map(i=>Math.ceil(i.length/t)).reduce((i,o)=>i+o):e.length},Hs=(s,t={})=>{const e=Number.isSafeInteger(parseInt(t.margin))?new Array(parseInt(t.margin)).fill(" ").join(""):t.margin||"",i=t.width;return(s||"").split(/\r?\n/g).map(o=>o.split(/\s+/g).reduce((n,r)=>(r.length+e.length>=i||n[n.length-1].length+r.length+1<i?n[n.length-1]+=` ${r}`:n.push(`${e}${r}`),n),[e]).join(`
|
2
|
+
`)).join(`
|
3
|
+
`)},Bs=(s,t,e)=>{e=e||t;let i=Math.min(t-e,s-Math.floor(e/2));i<0&&(i=0);let o=Math.min(i+e,t);return{startIndex:i,endIndex:o}},_={action:Ts,clear:Is,style:Ls,strip:yt,figures:ie,lines:Ys,wrap:Hs,entriesToDisplay:Bs};const re=Fe,{action:Us}=_,zs=Le,{beep:Ws,cursor:Gs}=D,Js=M;let Ks=class extends zs{constructor(t={}){super(),this.firstRender=!0,this.in=t.stdin||process.stdin,this.out=t.stdout||process.stdout,this.onRender=(t.onRender||(()=>{})).bind(this);const e=re.createInterface({input:this.in,escapeCodeTimeout:50});re.emitKeypressEvents(this.in,e),this.in.isTTY&&this.in.setRawMode(!0);const i=["SelectPrompt","MultiselectPrompt"].indexOf(this.constructor.name)>-1,o=(n,r)=>{let l=Us(r,i);l===!1?this._&&this._(n,r):typeof this[l]=="function"?this[l](r):this.bell()};this.close=()=>{this.out.write(Gs.show),this.in.removeListener("keypress",o),this.in.isTTY&&this.in.setRawMode(!1),e.close(),this.emit(this.aborted?"abort":this.exited?"exit":"submit",this.value),this.closed=!0},this.in.on("keypress",o)}fire(){this.emit("state",{value:this.value,aborted:!!this.aborted,exited:!!this.exited})}bell(){this.out.write(Ws)}render(){this.onRender(Js),this.firstRender&&(this.firstRender=!1)}};var j=Ks;const et=M,qs=j,{erase:Zs,cursor:X}=D,{style:Et,clear:Tt,lines:Xs,figures:Qs}=_;class ti extends qs{constructor(t={}){super(t),this.transform=Et.render(t.style),this.scale=this.transform.scale,this.msg=t.message,this.initial=t.initial||"",this.validator=t.validate||(()=>!0),this.value="",this.errorMsg=t.error||"Please Enter A Valid Value",this.cursor=Number(!!this.initial),this.cursorOffset=0,this.clear=Tt("",this.out.columns),this.render()}set value(t){!t&&this.initial?(this.placeholder=!0,this.rendered=et.gray(this.transform.render(this.initial))):(this.placeholder=!1,this.rendered=this.transform.render(t)),this._value=t,this.fire()}get value(){return this._value}reset(){this.value="",this.cursor=Number(!!this.initial),this.cursorOffset=0,this.fire(),this.render()}exit(){this.abort()}abort(){this.value=this.value||this.initial,this.done=this.aborted=!0,this.error=!1,this.red=!1,this.fire(),this.render(),this.out.write(`
|
4
|
+
`),this.close()}async validate(){let t=await this.validator(this.value);typeof t=="string"&&(this.errorMsg=t,t=!1),this.error=!t}async submit(){if(this.value=this.value||this.initial,this.cursorOffset=0,this.cursor=this.rendered.length,await this.validate(),this.error){this.red=!0,this.fire(),this.render();return}this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
5
|
+
`),this.close()}next(){if(!this.placeholder)return this.bell();this.value=this.initial,this.cursor=this.rendered.length,this.fire(),this.render()}moveCursor(t){this.placeholder||(this.cursor=this.cursor+t,this.cursorOffset+=t)}_(t,e){let i=this.value.slice(0,this.cursor),o=this.value.slice(this.cursor);this.value=`${i}${t}${o}`,this.red=!1,this.cursor=this.placeholder?0:i.length+1,this.render()}delete(){if(this.isCursorAtStart())return this.bell();let t=this.value.slice(0,this.cursor-1),e=this.value.slice(this.cursor);this.value=`${t}${e}`,this.red=!1,this.isCursorAtStart()?this.cursorOffset=0:(this.cursorOffset++,this.moveCursor(-1)),this.render()}deleteForward(){if(this.cursor*this.scale>=this.rendered.length||this.placeholder)return this.bell();let t=this.value.slice(0,this.cursor),e=this.value.slice(this.cursor+1);this.value=`${t}${e}`,this.red=!1,this.isCursorAtEnd()?this.cursorOffset=0:this.cursorOffset++,this.render()}first(){this.cursor=0,this.render()}last(){this.cursor=this.value.length,this.render()}left(){if(this.cursor<=0||this.placeholder)return this.bell();this.moveCursor(-1),this.render()}right(){if(this.cursor*this.scale>=this.rendered.length||this.placeholder)return this.bell();this.moveCursor(1),this.render()}isCursorAtStart(){return this.cursor===0||this.placeholder&&this.cursor===1}isCursorAtEnd(){return this.cursor===this.rendered.length||this.placeholder&&this.cursor===this.rendered.length+1}render(){this.closed||(this.firstRender||(this.outputError&&this.out.write(X.down(Xs(this.outputError,this.out.columns)-1)+Tt(this.outputError,this.out.columns)),this.out.write(Tt(this.outputText,this.out.columns))),super.render(),this.outputError="",this.outputText=[Et.symbol(this.done,this.aborted),et.bold(this.msg),Et.delimiter(this.done),this.red?et.red(this.rendered):this.rendered].join(" "),this.error&&(this.outputError+=this.errorMsg.split(`
|
6
|
+
`).reduce((t,e,i)=>t+`
|
7
|
+
${i?" ":Qs.pointerSmall} ${et.red().italic(e)}`,"")),this.out.write(Zs.line+X.to(0)+this.outputText+X.save+this.outputError+X.restore+X.move(this.cursorOffset,0)))}}var ei=ti;const A=M,si=j,{style:ne,clear:oe,figures:st,wrap:ii,entriesToDisplay:ri}=_,{cursor:ni}=D;class oi extends si{constructor(t={}){super(t),this.msg=t.message,this.hint=t.hint||"- Use arrow-keys. Return to submit.",this.warn=t.warn||"- This option is disabled",this.cursor=t.initial||0,this.choices=t.choices.map((e,i)=>(typeof e=="string"&&(e={title:e,value:i}),{title:e&&(e.title||e.value||e),value:e&&(e.value===void 0?i:e.value),description:e&&e.description,selected:e&&e.selected,disabled:e&&e.disabled})),this.optionsPerPage=t.optionsPerPage||10,this.value=(this.choices[this.cursor]||{}).value,this.clear=oe("",this.out.columns),this.render()}moveCursor(t){this.cursor=t,this.value=this.choices[t].value,this.fire()}reset(){this.moveCursor(0),this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
|
8
|
+
`),this.close()}submit(){this.selection.disabled?this.bell():(this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
9
|
+
`),this.close())}first(){this.moveCursor(0),this.render()}last(){this.moveCursor(this.choices.length-1),this.render()}up(){this.cursor===0?this.moveCursor(this.choices.length-1):this.moveCursor(this.cursor-1),this.render()}down(){this.cursor===this.choices.length-1?this.moveCursor(0):this.moveCursor(this.cursor+1),this.render()}next(){this.moveCursor((this.cursor+1)%this.choices.length),this.render()}_(t,e){if(t===" ")return this.submit()}get selection(){return this.choices[this.cursor]}render(){if(this.closed)return;this.firstRender?this.out.write(ni.hide):this.out.write(oe(this.outputText,this.out.columns)),super.render();let{startIndex:t,endIndex:e}=ri(this.cursor,this.choices.length,this.optionsPerPage);if(this.outputText=[ne.symbol(this.done,this.aborted),A.bold(this.msg),ne.delimiter(!1),this.done?this.selection.title:this.selection.disabled?A.yellow(this.warn):A.gray(this.hint)].join(" "),!this.done){this.outputText+=`
|
10
|
+
`;for(let i=t;i<e;i++){let o,n,r="",l=this.choices[i];i===t&&t>0?n=st.arrowUp:i===e-1&&e<this.choices.length?n=st.arrowDown:n=" ",l.disabled?(o=this.cursor===i?A.gray().underline(l.title):A.strikethrough().gray(l.title),n=(this.cursor===i?A.bold().gray(st.pointer)+" ":" ")+n):(o=this.cursor===i?A.cyan().underline(l.title):l.title,n=(this.cursor===i?A.cyan(st.pointer)+" ":" ")+n,l.description&&this.cursor===i&&(r=` - ${l.description}`,(n.length+o.length+r.length>=this.out.columns||l.description.split(/\r?\n/).length>1)&&(r=`
|
11
|
+
`+ii(l.description,{margin:3,width:this.out.columns})))),this.outputText+=`${n} ${o}${A.gray(r)}
|
12
|
+
`}}this.out.write(this.outputText)}}var li=oi;const it=M,ai=j,{style:le,clear:hi}=_,{cursor:ae,erase:ui}=D;class ci extends ai{constructor(t={}){super(t),this.msg=t.message,this.value=!!t.initial,this.active=t.active||"on",this.inactive=t.inactive||"off",this.initialValue=this.value,this.render()}reset(){this.value=this.initialValue,this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
|
13
|
+
`),this.close()}submit(){this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
14
|
+
`),this.close()}deactivate(){if(this.value===!1)return this.bell();this.value=!1,this.render()}activate(){if(this.value===!0)return this.bell();this.value=!0,this.render()}delete(){this.deactivate()}left(){this.deactivate()}right(){this.activate()}down(){this.deactivate()}up(){this.activate()}next(){this.value=!this.value,this.fire(),this.render()}_(t,e){if(t===" ")this.value=!this.value;else if(t==="1")this.value=!0;else if(t==="0")this.value=!1;else return this.bell();this.render()}render(){this.closed||(this.firstRender?this.out.write(ae.hide):this.out.write(hi(this.outputText,this.out.columns)),super.render(),this.outputText=[le.symbol(this.done,this.aborted),it.bold(this.msg),le.delimiter(this.done),this.value?this.inactive:it.cyan().underline(this.inactive),it.gray("/"),this.value?it.cyan().underline(this.active):this.active].join(" "),this.out.write(ui.line+ae.to(0)+this.outputText))}}var di=ci;let Ot=class{constructor({token:t,date:e,parts:i,locales:o}){this.token=t,this.date=e||new Date,this.parts=i||[this],this.locales=o||{}}up(){}down(){}next(){const t=this.parts.indexOf(this);return this.parts.find((e,i)=>i>t&&e instanceof Ot)}setTo(t){}prev(){let t=[].concat(this.parts).reverse();const e=t.indexOf(this);return t.find((i,o)=>o>e&&i instanceof Ot)}toString(){return String(this.date)}};var R=Ot;const fi=R;let pi=class extends fi{constructor(t={}){super(t)}up(){this.date.setHours((this.date.getHours()+12)%24)}down(){this.up()}toString(){let t=this.date.getHours()>12?"pm":"am";return/\A/.test(this.token)?t.toUpperCase():t}};var mi=pi;const gi=R,vi=s=>(s=s%10,s===1?"st":s===2?"nd":s===3?"rd":"th");let bi=class extends gi{constructor(t={}){super(t)}up(){this.date.setDate(this.date.getDate()+1)}down(){this.date.setDate(this.date.getDate()-1)}setTo(t){this.date.setDate(parseInt(t.substr(-2)))}toString(){let t=this.date.getDate(),e=this.date.getDay();return this.token==="DD"?String(t).padStart(2,"0"):this.token==="Do"?t+vi(t):this.token==="d"?e+1:this.token==="ddd"?this.locales.weekdaysShort[e]:this.token==="dddd"?this.locales.weekdays[e]:t}};var wi=bi;const yi=R;let $i=class extends yi{constructor(t={}){super(t)}up(){this.date.setHours(this.date.getHours()+1)}down(){this.date.setHours(this.date.getHours()-1)}setTo(t){this.date.setHours(parseInt(t.substr(-2)))}toString(){let t=this.date.getHours();return/h/.test(this.token)&&(t=t%12||12),this.token.length>1?String(t).padStart(2,"0"):t}};var xi=$i;const Si=R;let Ei=class extends Si{constructor(t={}){super(t)}up(){this.date.setMilliseconds(this.date.getMilliseconds()+1)}down(){this.date.setMilliseconds(this.date.getMilliseconds()-1)}setTo(t){this.date.setMilliseconds(parseInt(t.substr(-this.token.length)))}toString(){return String(this.date.getMilliseconds()).padStart(4,"0").substr(0,this.token.length)}};var Ti=Ei;const Oi=R;let Pi=class extends Oi{constructor(t={}){super(t)}up(){this.date.setMinutes(this.date.getMinutes()+1)}down(){this.date.setMinutes(this.date.getMinutes()-1)}setTo(t){this.date.setMinutes(parseInt(t.substr(-2)))}toString(){let t=this.date.getMinutes();return this.token.length>1?String(t).padStart(2,"0"):t}};var Ci=Pi;const Mi=R;let Di=class extends Mi{constructor(t={}){super(t)}up(){this.date.setMonth(this.date.getMonth()+1)}down(){this.date.setMonth(this.date.getMonth()-1)}setTo(t){t=parseInt(t.substr(-2))-1,this.date.setMonth(t<0?0:t)}toString(){let t=this.date.getMonth(),e=this.token.length;return e===2?String(t+1).padStart(2,"0"):e===3?this.locales.monthsShort[t]:e===4?this.locales.months[t]:String(t+1)}};var _i=Di;const Ii=R;let Ai=class extends Ii{constructor(t={}){super(t)}up(){this.date.setSeconds(this.date.getSeconds()+1)}down(){this.date.setSeconds(this.date.getSeconds()-1)}setTo(t){this.date.setSeconds(parseInt(t.substr(-2)))}toString(){let t=this.date.getSeconds();return this.token.length>1?String(t).padStart(2,"0"):t}};var Ri=Ai;const ki=R;let Ni=class extends ki{constructor(t={}){super(t)}up(){this.date.setFullYear(this.date.getFullYear()+1)}down(){this.date.setFullYear(this.date.getFullYear()-1)}setTo(t){this.date.setFullYear(t.substr(-4))}toString(){let t=String(this.date.getFullYear()).padStart(4,"0");return this.token.length===2?t.substr(-2):t}};var ji=Ni,Fi={DatePart:R,Meridiem:mi,Day:wi,Hours:xi,Milliseconds:Ti,Minutes:Ci,Month:_i,Seconds:Ri,Year:ji};const Pt=M,Li=j,{style:he,clear:ue,figures:Vi}=_,{erase:Yi,cursor:ce}=D,{DatePart:de,Meridiem:Hi,Day:Bi,Hours:Ui,Milliseconds:zi,Minutes:Wi,Month:Gi,Seconds:Ji,Year:Ki}=Fi,qi=/\\(.)|"((?:\\["\\]|[^"])+)"|(D[Do]?|d{3,4}|d)|(M{1,4})|(YY(?:YY)?)|([aA])|([Hh]{1,2})|(m{1,2})|(s{1,2})|(S{1,4})|./g,fe={1:({token:s})=>s.replace(/\\(.)/g,"$1"),2:s=>new Bi(s),3:s=>new Gi(s),4:s=>new Ki(s),5:s=>new Hi(s),6:s=>new Ui(s),7:s=>new Wi(s),8:s=>new Ji(s),9:s=>new zi(s)},Zi={months:"January,February,March,April,May,June,July,August,September,October,November,December".split(","),monthsShort:"Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec".split(","),weekdays:"Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday".split(","),weekdaysShort:"Sun,Mon,Tue,Wed,Thu,Fri,Sat".split(",")};class Xi extends Li{constructor(t={}){super(t),this.msg=t.message,this.cursor=0,this.typed="",this.locales=Object.assign(Zi,t.locales),this._date=t.initial||new Date,this.errorMsg=t.error||"Please Enter A Valid Value",this.validator=t.validate||(()=>!0),this.mask=t.mask||"YYYY-MM-DD HH:mm:ss",this.clear=ue("",this.out.columns),this.render()}get value(){return this.date}get date(){return this._date}set date(t){t&&this._date.setTime(t.getTime())}set mask(t){let e;for(this.parts=[];e=qi.exec(t);){let o=e.shift(),n=e.findIndex(r=>r!=null);this.parts.push(n in fe?fe[n]({token:e[n]||o,date:this.date,parts:this.parts,locales:this.locales}):e[n]||o)}let i=this.parts.reduce((o,n)=>(typeof n=="string"&&typeof o[o.length-1]=="string"?o[o.length-1]+=n:o.push(n),o),[]);this.parts.splice(0),this.parts.push(...i),this.reset()}moveCursor(t){this.typed="",this.cursor=t,this.fire()}reset(){this.moveCursor(this.parts.findIndex(t=>t instanceof de)),this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.error=!1,this.fire(),this.render(),this.out.write(`
|
15
|
+
`),this.close()}async validate(){let t=await this.validator(this.value);typeof t=="string"&&(this.errorMsg=t,t=!1),this.error=!t}async submit(){if(await this.validate(),this.error){this.color="red",this.fire(),this.render();return}this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
16
|
+
`),this.close()}up(){this.typed="",this.parts[this.cursor].up(),this.render()}down(){this.typed="",this.parts[this.cursor].down(),this.render()}left(){let t=this.parts[this.cursor].prev();if(t==null)return this.bell();this.moveCursor(this.parts.indexOf(t)),this.render()}right(){let t=this.parts[this.cursor].next();if(t==null)return this.bell();this.moveCursor(this.parts.indexOf(t)),this.render()}next(){let t=this.parts[this.cursor].next();this.moveCursor(t?this.parts.indexOf(t):this.parts.findIndex(e=>e instanceof de)),this.render()}_(t){/\d/.test(t)&&(this.typed+=t,this.parts[this.cursor].setTo(this.typed),this.render())}render(){this.closed||(this.firstRender?this.out.write(ce.hide):this.out.write(ue(this.outputText,this.out.columns)),super.render(),this.outputText=[he.symbol(this.done,this.aborted),Pt.bold(this.msg),he.delimiter(!1),this.parts.reduce((t,e,i)=>t.concat(i===this.cursor&&!this.done?Pt.cyan().underline(e.toString()):e),[]).join("")].join(" "),this.error&&(this.outputText+=this.errorMsg.split(`
|
17
|
+
`).reduce((t,e,i)=>t+`
|
18
|
+
${i?" ":Vi.pointerSmall} ${Pt.red().italic(e)}`,"")),this.out.write(Yi.line+ce.to(0)+this.outputText))}}var Qi=Xi;const rt=M,tr=j,{cursor:nt,erase:er}=D,{style:Ct,figures:sr,clear:pe,lines:ir}=_,rr=/[0-9]/,Mt=s=>s!==void 0,me=(s,t)=>{let e=Math.pow(10,t);return Math.round(s*e)/e};class nr extends tr{constructor(t={}){super(t),this.transform=Ct.render(t.style),this.msg=t.message,this.initial=Mt(t.initial)?t.initial:"",this.float=!!t.float,this.round=t.round||2,this.inc=t.increment||1,this.min=Mt(t.min)?t.min:-1/0,this.max=Mt(t.max)?t.max:1/0,this.errorMsg=t.error||"Please Enter A Valid Value",this.validator=t.validate||(()=>!0),this.color="cyan",this.value="",this.typed="",this.lastHit=0,this.render()}set value(t){!t&&t!==0?(this.placeholder=!0,this.rendered=rt.gray(this.transform.render(`${this.initial}`)),this._value=""):(this.placeholder=!1,this.rendered=this.transform.render(`${me(t,this.round)}`),this._value=me(t,this.round)),this.fire()}get value(){return this._value}parse(t){return this.float?parseFloat(t):parseInt(t)}valid(t){return t==="-"||t==="."&&this.float||rr.test(t)}reset(){this.typed="",this.value="",this.fire(),this.render()}exit(){this.abort()}abort(){let t=this.value;this.value=t!==""?t:this.initial,this.done=this.aborted=!0,this.error=!1,this.fire(),this.render(),this.out.write(`
|
19
|
+
`),this.close()}async validate(){let t=await this.validator(this.value);typeof t=="string"&&(this.errorMsg=t,t=!1),this.error=!t}async submit(){if(await this.validate(),this.error){this.color="red",this.fire(),this.render();return}let t=this.value;this.value=t!==""?t:this.initial,this.done=!0,this.aborted=!1,this.error=!1,this.fire(),this.render(),this.out.write(`
|
20
|
+
`),this.close()}up(){if(this.typed="",this.value===""&&(this.value=this.min-this.inc),this.value>=this.max)return this.bell();this.value+=this.inc,this.color="cyan",this.fire(),this.render()}down(){if(this.typed="",this.value===""&&(this.value=this.min+this.inc),this.value<=this.min)return this.bell();this.value-=this.inc,this.color="cyan",this.fire(),this.render()}delete(){let t=this.value.toString();if(t.length===0)return this.bell();this.value=this.parse(t=t.slice(0,-1))||"",this.value!==""&&this.value<this.min&&(this.value=this.min),this.color="cyan",this.fire(),this.render()}next(){this.value=this.initial,this.fire(),this.render()}_(t,e){if(!this.valid(t))return this.bell();const i=Date.now();if(i-this.lastHit>1e3&&(this.typed=""),this.typed+=t,this.lastHit=i,this.color="cyan",t===".")return this.fire();this.value=Math.min(this.parse(this.typed),this.max),this.value>this.max&&(this.value=this.max),this.value<this.min&&(this.value=this.min),this.fire(),this.render()}render(){this.closed||(this.firstRender||(this.outputError&&this.out.write(nt.down(ir(this.outputError,this.out.columns)-1)+pe(this.outputError,this.out.columns)),this.out.write(pe(this.outputText,this.out.columns))),super.render(),this.outputError="",this.outputText=[Ct.symbol(this.done,this.aborted),rt.bold(this.msg),Ct.delimiter(this.done),!this.done||!this.done&&!this.placeholder?rt[this.color]().underline(this.rendered):this.rendered].join(" "),this.error&&(this.outputError+=this.errorMsg.split(`
|
21
|
+
`).reduce((t,e,i)=>t+`
|
22
|
+
${i?" ":sr.pointerSmall} ${rt.red().italic(e)}`,"")),this.out.write(er.line+nt.to(0)+this.outputText+nt.save+this.outputError+nt.restore))}}var or=nr;const I=M,{cursor:lr}=D,ar=j,{clear:ge,figures:F,style:ve,wrap:hr,entriesToDisplay:ur}=_;let cr=class extends ar{constructor(t={}){super(t),this.msg=t.message,this.cursor=t.cursor||0,this.scrollIndex=t.cursor||0,this.hint=t.hint||"",this.warn=t.warn||"- This option is disabled -",this.minSelected=t.min,this.showMinError=!1,this.maxChoices=t.max,this.instructions=t.instructions,this.optionsPerPage=t.optionsPerPage||10,this.value=t.choices.map((e,i)=>(typeof e=="string"&&(e={title:e,value:i}),{title:e&&(e.title||e.value||e),description:e&&e.description,value:e&&(e.value===void 0?i:e.value),selected:e&&e.selected,disabled:e&&e.disabled})),this.clear=ge("",this.out.columns),t.overrideRender||this.render()}reset(){this.value.map(t=>!t.selected),this.cursor=0,this.fire(),this.render()}selected(){return this.value.filter(t=>t.selected)}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
|
23
|
+
`),this.close()}submit(){const t=this.value.filter(e=>e.selected);this.minSelected&&t.length<this.minSelected?(this.showMinError=!0,this.render()):(this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
24
|
+
`),this.close())}first(){this.cursor=0,this.render()}last(){this.cursor=this.value.length-1,this.render()}next(){this.cursor=(this.cursor+1)%this.value.length,this.render()}up(){this.cursor===0?this.cursor=this.value.length-1:this.cursor--,this.render()}down(){this.cursor===this.value.length-1?this.cursor=0:this.cursor++,this.render()}left(){this.value[this.cursor].selected=!1,this.render()}right(){if(this.value.filter(t=>t.selected).length>=this.maxChoices)return this.bell();this.value[this.cursor].selected=!0,this.render()}handleSpaceToggle(){const t=this.value[this.cursor];if(t.selected)t.selected=!1,this.render();else{if(t.disabled||this.value.filter(e=>e.selected).length>=this.maxChoices)return this.bell();t.selected=!0,this.render()}}toggleAll(){if(this.maxChoices!==void 0||this.value[this.cursor].disabled)return this.bell();const t=!this.value[this.cursor].selected;this.value.filter(e=>!e.disabled).forEach(e=>e.selected=t),this.render()}_(t,e){if(t===" ")this.handleSpaceToggle();else if(t==="a")this.toggleAll();else return this.bell()}renderInstructions(){return this.instructions===void 0||this.instructions?typeof this.instructions=="string"?this.instructions:`
|
1871
25
|
Instructions:
|
1872
26
|
${F.arrowUp}/${F.arrowDown}: Highlight option
|
1873
27
|
${F.arrowLeft}/${F.arrowRight}/[space]: Toggle selection
|
1874
|
-
|
1875
|
-
|
1876
|
-
|
1877
|
-
`
|
1878
|
-
|
1879
|
-
|
1880
|
-
|
1881
|
-
}
|
1882
|
-
|
1883
|
-
|
1884
|
-
|
1885
|
-
return (
|
1886
|
-
e.disabled
|
1887
|
-
? (r = t === i ? I.gray().underline(e.title) : I.strikethrough().gray(e.title))
|
1888
|
-
: ((r = t === i ? I.cyan().underline(e.title) : e.title),
|
1889
|
-
t === i &&
|
1890
|
-
e.description &&
|
1891
|
-
((l = ` - ${e.description}`),
|
1892
|
-
(n.length + r.length + l.length >= this.out.columns ||
|
1893
|
-
e.description.split(/\r?\n/).length > 1) &&
|
1894
|
-
(l =
|
1895
|
-
`
|
1896
|
-
` + hr(e.description, { margin: n.length, width: this.out.columns })))),
|
1897
|
-
n + r + I.gray(l || '')
|
1898
|
-
);
|
1899
|
-
}
|
1900
|
-
paginateOptions(t) {
|
1901
|
-
if (t.length === 0) return I.red('No matches for this query.');
|
1902
|
-
let { startIndex: e, endIndex: i } = ur(this.cursor, t.length, this.optionsPerPage),
|
1903
|
-
o,
|
1904
|
-
n = [];
|
1905
|
-
for (let r = e; r < i; r++)
|
1906
|
-
r === e && e > 0
|
1907
|
-
? (o = F.arrowUp)
|
1908
|
-
: r === i - 1 && i < t.length
|
1909
|
-
? (o = F.arrowDown)
|
1910
|
-
: (o = ' '),
|
1911
|
-
n.push(this.renderOption(this.cursor, t[r], r, o));
|
1912
|
-
return (
|
1913
|
-
`
|
1914
|
-
` +
|
1915
|
-
n.join(`
|
1916
|
-
`)
|
1917
|
-
);
|
1918
|
-
}
|
1919
|
-
renderOptions(t) {
|
1920
|
-
return this.done ? '' : this.paginateOptions(t);
|
1921
|
-
}
|
1922
|
-
renderDoneOrInstructions() {
|
1923
|
-
if (this.done)
|
1924
|
-
return this.value
|
1925
|
-
.filter((e) => e.selected)
|
1926
|
-
.map((e) => e.title)
|
1927
|
-
.join(', ');
|
1928
|
-
const t = [I.gray(this.hint), this.renderInstructions()];
|
1929
|
-
return this.value[this.cursor].disabled && t.push(I.yellow(this.warn)), t.join(' ');
|
1930
|
-
}
|
1931
|
-
render() {
|
1932
|
-
if (this.closed) return;
|
1933
|
-
this.firstRender && this.out.write(lr.hide), super.render();
|
1934
|
-
let t = [
|
1935
|
-
ve.symbol(this.done, this.aborted),
|
1936
|
-
I.bold(this.msg),
|
1937
|
-
ve.delimiter(!1),
|
1938
|
-
this.renderDoneOrInstructions(),
|
1939
|
-
].join(' ');
|
1940
|
-
this.showMinError &&
|
1941
|
-
((t += I.red(`You must select a minimum of ${this.minSelected} choices.`)),
|
1942
|
-
(this.showMinError = !1)),
|
1943
|
-
(t += this.renderOptions(this.value)),
|
1944
|
-
this.out.write(this.clear + t),
|
1945
|
-
(this.clear = ge(t, this.out.columns));
|
1946
|
-
}
|
1947
|
-
};
|
1948
|
-
var be = cr;
|
1949
|
-
const Q = M,
|
1950
|
-
dr = j,
|
1951
|
-
{ erase: fr, cursor: we } = D,
|
1952
|
-
{ style: Dt, clear: ye, figures: _t, wrap: pr, entriesToDisplay: mr } = _,
|
1953
|
-
$e = (s, t) => s[t] && (s[t].value || s[t].title || s[t]),
|
1954
|
-
gr = (s, t) => s[t] && (s[t].title || s[t].value || s[t]),
|
1955
|
-
vr = (s, t) => {
|
1956
|
-
const e = s.findIndex((i) => i.value === t || i.title === t);
|
1957
|
-
return e > -1 ? e : void 0;
|
1958
|
-
};
|
1959
|
-
class br extends dr {
|
1960
|
-
constructor(t = {}) {
|
1961
|
-
super(t),
|
1962
|
-
(this.msg = t.message),
|
1963
|
-
(this.suggest = t.suggest),
|
1964
|
-
(this.choices = t.choices),
|
1965
|
-
(this.initial = typeof t.initial == 'number' ? t.initial : vr(t.choices, t.initial)),
|
1966
|
-
(this.select = this.initial || t.cursor || 0),
|
1967
|
-
(this.i18n = { noMatches: t.noMatches || 'no matches found' }),
|
1968
|
-
(this.fallback = t.fallback || this.initial),
|
1969
|
-
(this.clearFirst = t.clearFirst || !1),
|
1970
|
-
(this.suggestions = []),
|
1971
|
-
(this.input = ''),
|
1972
|
-
(this.limit = t.limit || 10),
|
1973
|
-
(this.cursor = 0),
|
1974
|
-
(this.transform = Dt.render(t.style)),
|
1975
|
-
(this.scale = this.transform.scale),
|
1976
|
-
(this.render = this.render.bind(this)),
|
1977
|
-
(this.complete = this.complete.bind(this)),
|
1978
|
-
(this.clear = ye('', this.out.columns)),
|
1979
|
-
this.complete(this.render),
|
1980
|
-
this.render();
|
1981
|
-
}
|
1982
|
-
set fallback(t) {
|
1983
|
-
this._fb = Number.isSafeInteger(parseInt(t)) ? parseInt(t) : t;
|
1984
|
-
}
|
1985
|
-
get fallback() {
|
1986
|
-
let t;
|
1987
|
-
return (
|
1988
|
-
typeof this._fb == 'number'
|
1989
|
-
? (t = this.choices[this._fb])
|
1990
|
-
: typeof this._fb == 'string' && (t = { title: this._fb }),
|
1991
|
-
t || this._fb || { title: this.i18n.noMatches }
|
1992
|
-
);
|
1993
|
-
}
|
1994
|
-
moveSelect(t) {
|
1995
|
-
(this.select = t),
|
1996
|
-
this.suggestions.length > 0
|
1997
|
-
? (this.value = $e(this.suggestions, t))
|
1998
|
-
: (this.value = this.fallback.value),
|
1999
|
-
this.fire();
|
2000
|
-
}
|
2001
|
-
async complete(t) {
|
2002
|
-
const e = (this.completing = this.suggest(this.input, this.choices)),
|
2003
|
-
i = await e;
|
2004
|
-
if (this.completing !== e) return;
|
2005
|
-
(this.suggestions = i.map((n, r, l) => ({
|
2006
|
-
title: gr(l, r),
|
2007
|
-
value: $e(l, r),
|
2008
|
-
description: n.description,
|
2009
|
-
}))),
|
2010
|
-
(this.completing = !1);
|
2011
|
-
const o = Math.max(i.length - 1, 0);
|
2012
|
-
this.moveSelect(Math.min(o, this.select)), t && t();
|
2013
|
-
}
|
2014
|
-
reset() {
|
2015
|
-
(this.input = ''),
|
2016
|
-
this.complete(() => {
|
2017
|
-
this.moveSelect(this.initial !== void 0 ? this.initial : 0), this.render();
|
2018
|
-
}),
|
2019
|
-
this.render();
|
2020
|
-
}
|
2021
|
-
exit() {
|
2022
|
-
this.clearFirst && this.input.length > 0
|
2023
|
-
? this.reset()
|
2024
|
-
: ((this.done = this.exited = !0),
|
2025
|
-
(this.aborted = !1),
|
2026
|
-
this.fire(),
|
2027
|
-
this.render(),
|
2028
|
-
this.out.write(`
|
2029
|
-
`),
|
2030
|
-
this.close());
|
2031
|
-
}
|
2032
|
-
abort() {
|
2033
|
-
(this.done = this.aborted = !0),
|
2034
|
-
(this.exited = !1),
|
2035
|
-
this.fire(),
|
2036
|
-
this.render(),
|
2037
|
-
this.out.write(`
|
2038
|
-
`),
|
2039
|
-
this.close();
|
2040
|
-
}
|
2041
|
-
submit() {
|
2042
|
-
(this.done = !0),
|
2043
|
-
(this.aborted = this.exited = !1),
|
2044
|
-
this.fire(),
|
2045
|
-
this.render(),
|
2046
|
-
this.out.write(`
|
2047
|
-
`),
|
2048
|
-
this.close();
|
2049
|
-
}
|
2050
|
-
_(t, e) {
|
2051
|
-
let i = this.input.slice(0, this.cursor),
|
2052
|
-
o = this.input.slice(this.cursor);
|
2053
|
-
(this.input = `${i}${t}${o}`),
|
2054
|
-
(this.cursor = i.length + 1),
|
2055
|
-
this.complete(this.render),
|
2056
|
-
this.render();
|
2057
|
-
}
|
2058
|
-
delete() {
|
2059
|
-
if (this.cursor === 0) return this.bell();
|
2060
|
-
let t = this.input.slice(0, this.cursor - 1),
|
2061
|
-
e = this.input.slice(this.cursor);
|
2062
|
-
(this.input = `${t}${e}`),
|
2063
|
-
this.complete(this.render),
|
2064
|
-
(this.cursor = this.cursor - 1),
|
2065
|
-
this.render();
|
2066
|
-
}
|
2067
|
-
deleteForward() {
|
2068
|
-
if (this.cursor * this.scale >= this.rendered.length) return this.bell();
|
2069
|
-
let t = this.input.slice(0, this.cursor),
|
2070
|
-
e = this.input.slice(this.cursor + 1);
|
2071
|
-
(this.input = `${t}${e}`), this.complete(this.render), this.render();
|
2072
|
-
}
|
2073
|
-
first() {
|
2074
|
-
this.moveSelect(0), this.render();
|
2075
|
-
}
|
2076
|
-
last() {
|
2077
|
-
this.moveSelect(this.suggestions.length - 1), this.render();
|
2078
|
-
}
|
2079
|
-
up() {
|
2080
|
-
this.select === 0
|
2081
|
-
? this.moveSelect(this.suggestions.length - 1)
|
2082
|
-
: this.moveSelect(this.select - 1),
|
2083
|
-
this.render();
|
2084
|
-
}
|
2085
|
-
down() {
|
2086
|
-
this.select === this.suggestions.length - 1
|
2087
|
-
? this.moveSelect(0)
|
2088
|
-
: this.moveSelect(this.select + 1),
|
2089
|
-
this.render();
|
2090
|
-
}
|
2091
|
-
next() {
|
2092
|
-
this.select === this.suggestions.length - 1
|
2093
|
-
? this.moveSelect(0)
|
2094
|
-
: this.moveSelect(this.select + 1),
|
2095
|
-
this.render();
|
2096
|
-
}
|
2097
|
-
nextPage() {
|
2098
|
-
this.moveSelect(Math.min(this.select + this.limit, this.suggestions.length - 1)), this.render();
|
2099
|
-
}
|
2100
|
-
prevPage() {
|
2101
|
-
this.moveSelect(Math.max(this.select - this.limit, 0)), this.render();
|
2102
|
-
}
|
2103
|
-
left() {
|
2104
|
-
if (this.cursor <= 0) return this.bell();
|
2105
|
-
(this.cursor = this.cursor - 1), this.render();
|
2106
|
-
}
|
2107
|
-
right() {
|
2108
|
-
if (this.cursor * this.scale >= this.rendered.length) return this.bell();
|
2109
|
-
(this.cursor = this.cursor + 1), this.render();
|
2110
|
-
}
|
2111
|
-
renderOption(t, e, i, o) {
|
2112
|
-
let n,
|
2113
|
-
r = i ? _t.arrowUp : o ? _t.arrowDown : ' ',
|
2114
|
-
l = e ? Q.cyan().underline(t.title) : t.title;
|
2115
|
-
return (
|
2116
|
-
(r = (e ? Q.cyan(_t.pointer) + ' ' : ' ') + r),
|
2117
|
-
t.description &&
|
2118
|
-
((n = ` - ${t.description}`),
|
2119
|
-
(r.length + l.length + n.length >= this.out.columns ||
|
2120
|
-
t.description.split(/\r?\n/).length > 1) &&
|
2121
|
-
(n =
|
2122
|
-
`
|
2123
|
-
` + pr(t.description, { margin: 3, width: this.out.columns }))),
|
2124
|
-
r + ' ' + l + Q.gray(n || '')
|
2125
|
-
);
|
2126
|
-
}
|
2127
|
-
render() {
|
2128
|
-
if (this.closed) return;
|
2129
|
-
this.firstRender
|
2130
|
-
? this.out.write(we.hide)
|
2131
|
-
: this.out.write(ye(this.outputText, this.out.columns)),
|
2132
|
-
super.render();
|
2133
|
-
let { startIndex: t, endIndex: e } = mr(this.select, this.choices.length, this.limit);
|
2134
|
-
if (
|
2135
|
-
((this.outputText = [
|
2136
|
-
Dt.symbol(this.done, this.aborted, this.exited),
|
2137
|
-
Q.bold(this.msg),
|
2138
|
-
Dt.delimiter(this.completing),
|
2139
|
-
this.done && this.suggestions[this.select]
|
2140
|
-
? this.suggestions[this.select].title
|
2141
|
-
: (this.rendered = this.transform.render(this.input)),
|
2142
|
-
].join(' ')),
|
2143
|
-
!this.done)
|
2144
|
-
) {
|
2145
|
-
const i = this.suggestions
|
2146
|
-
.slice(t, e)
|
2147
|
-
.map((o, n) =>
|
2148
|
-
this.renderOption(
|
2149
|
-
o,
|
2150
|
-
this.select === n + t,
|
2151
|
-
n === 0 && t > 0,
|
2152
|
-
n + t === e - 1 && e < this.choices.length,
|
2153
|
-
),
|
2154
|
-
)
|
2155
|
-
.join(`
|
2156
|
-
`);
|
2157
|
-
this.outputText +=
|
2158
|
-
`
|
2159
|
-
` + (i || Q.gray(this.fallback.title));
|
2160
|
-
}
|
2161
|
-
this.out.write(fr.line + we.to(0) + this.outputText);
|
2162
|
-
}
|
2163
|
-
}
|
2164
|
-
var wr = br;
|
2165
|
-
const k = M,
|
2166
|
-
{ cursor: yr } = D,
|
2167
|
-
$r = be,
|
2168
|
-
{ clear: xe, style: Se, figures: W } = _;
|
2169
|
-
class xr extends $r {
|
2170
|
-
constructor(t = {}) {
|
2171
|
-
(t.overrideRender = !0),
|
2172
|
-
super(t),
|
2173
|
-
(this.inputValue = ''),
|
2174
|
-
(this.clear = xe('', this.out.columns)),
|
2175
|
-
(this.filteredOptions = this.value),
|
2176
|
-
this.render();
|
2177
|
-
}
|
2178
|
-
last() {
|
2179
|
-
(this.cursor = this.filteredOptions.length - 1), this.render();
|
2180
|
-
}
|
2181
|
-
next() {
|
2182
|
-
(this.cursor = (this.cursor + 1) % this.filteredOptions.length), this.render();
|
2183
|
-
}
|
2184
|
-
up() {
|
2185
|
-
this.cursor === 0 ? (this.cursor = this.filteredOptions.length - 1) : this.cursor--,
|
2186
|
-
this.render();
|
2187
|
-
}
|
2188
|
-
down() {
|
2189
|
-
this.cursor === this.filteredOptions.length - 1 ? (this.cursor = 0) : this.cursor++,
|
2190
|
-
this.render();
|
2191
|
-
}
|
2192
|
-
left() {
|
2193
|
-
(this.filteredOptions[this.cursor].selected = !1), this.render();
|
2194
|
-
}
|
2195
|
-
right() {
|
2196
|
-
if (this.value.filter((t) => t.selected).length >= this.maxChoices) return this.bell();
|
2197
|
-
(this.filteredOptions[this.cursor].selected = !0), this.render();
|
2198
|
-
}
|
2199
|
-
delete() {
|
2200
|
-
this.inputValue.length &&
|
2201
|
-
((this.inputValue = this.inputValue.substr(0, this.inputValue.length - 1)),
|
2202
|
-
this.updateFilteredOptions());
|
2203
|
-
}
|
2204
|
-
updateFilteredOptions() {
|
2205
|
-
const t = this.filteredOptions[this.cursor];
|
2206
|
-
this.filteredOptions = this.value.filter((i) =>
|
2207
|
-
this.inputValue
|
2208
|
-
? !!(
|
2209
|
-
(typeof i.title == 'string' &&
|
2210
|
-
i.title.toLowerCase().includes(this.inputValue.toLowerCase())) ||
|
2211
|
-
(typeof i.value == 'string' &&
|
2212
|
-
i.value.toLowerCase().includes(this.inputValue.toLowerCase()))
|
2213
|
-
)
|
2214
|
-
: !0,
|
2215
|
-
);
|
2216
|
-
const e = this.filteredOptions.findIndex((i) => i === t);
|
2217
|
-
(this.cursor = e < 0 ? 0 : e), this.render();
|
2218
|
-
}
|
2219
|
-
handleSpaceToggle() {
|
2220
|
-
const t = this.filteredOptions[this.cursor];
|
2221
|
-
if (t.selected) (t.selected = !1), this.render();
|
2222
|
-
else {
|
2223
|
-
if (t.disabled || this.value.filter((e) => e.selected).length >= this.maxChoices)
|
2224
|
-
return this.bell();
|
2225
|
-
(t.selected = !0), this.render();
|
2226
|
-
}
|
2227
|
-
}
|
2228
|
-
handleInputChange(t) {
|
2229
|
-
(this.inputValue = this.inputValue + t), this.updateFilteredOptions();
|
2230
|
-
}
|
2231
|
-
_(t, e) {
|
2232
|
-
t === ' ' ? this.handleSpaceToggle() : this.handleInputChange(t);
|
2233
|
-
}
|
2234
|
-
renderInstructions() {
|
2235
|
-
return this.instructions === void 0 || this.instructions
|
2236
|
-
? typeof this.instructions == 'string'
|
2237
|
-
? this.instructions
|
2238
|
-
: `
|
28
|
+
`+(this.maxChoices===void 0?` a: Toggle all
|
29
|
+
`:"")+" enter/return: Complete answer":""}renderOption(t,e,i,o){const n=(e.selected?I.green(F.radioOn):F.radioOff)+" "+o+" ";let r,l;return e.disabled?r=t===i?I.gray().underline(e.title):I.strikethrough().gray(e.title):(r=t===i?I.cyan().underline(e.title):e.title,t===i&&e.description&&(l=` - ${e.description}`,(n.length+r.length+l.length>=this.out.columns||e.description.split(/\r?\n/).length>1)&&(l=`
|
30
|
+
`+hr(e.description,{margin:n.length,width:this.out.columns})))),n+r+I.gray(l||"")}paginateOptions(t){if(t.length===0)return I.red("No matches for this query.");let{startIndex:e,endIndex:i}=ur(this.cursor,t.length,this.optionsPerPage),o,n=[];for(let r=e;r<i;r++)r===e&&e>0?o=F.arrowUp:r===i-1&&i<t.length?o=F.arrowDown:o=" ",n.push(this.renderOption(this.cursor,t[r],r,o));return`
|
31
|
+
`+n.join(`
|
32
|
+
`)}renderOptions(t){return this.done?"":this.paginateOptions(t)}renderDoneOrInstructions(){if(this.done)return this.value.filter(e=>e.selected).map(e=>e.title).join(", ");const t=[I.gray(this.hint),this.renderInstructions()];return this.value[this.cursor].disabled&&t.push(I.yellow(this.warn)),t.join(" ")}render(){if(this.closed)return;this.firstRender&&this.out.write(lr.hide),super.render();let t=[ve.symbol(this.done,this.aborted),I.bold(this.msg),ve.delimiter(!1),this.renderDoneOrInstructions()].join(" ");this.showMinError&&(t+=I.red(`You must select a minimum of ${this.minSelected} choices.`),this.showMinError=!1),t+=this.renderOptions(this.value),this.out.write(this.clear+t),this.clear=ge(t,this.out.columns)}};var be=cr;const Q=M,dr=j,{erase:fr,cursor:we}=D,{style:Dt,clear:ye,figures:_t,wrap:pr,entriesToDisplay:mr}=_,$e=(s,t)=>s[t]&&(s[t].value||s[t].title||s[t]),gr=(s,t)=>s[t]&&(s[t].title||s[t].value||s[t]),vr=(s,t)=>{const e=s.findIndex(i=>i.value===t||i.title===t);return e>-1?e:void 0};class br extends dr{constructor(t={}){super(t),this.msg=t.message,this.suggest=t.suggest,this.choices=t.choices,this.initial=typeof t.initial=="number"?t.initial:vr(t.choices,t.initial),this.select=this.initial||t.cursor||0,this.i18n={noMatches:t.noMatches||"no matches found"},this.fallback=t.fallback||this.initial,this.clearFirst=t.clearFirst||!1,this.suggestions=[],this.input="",this.limit=t.limit||10,this.cursor=0,this.transform=Dt.render(t.style),this.scale=this.transform.scale,this.render=this.render.bind(this),this.complete=this.complete.bind(this),this.clear=ye("",this.out.columns),this.complete(this.render),this.render()}set fallback(t){this._fb=Number.isSafeInteger(parseInt(t))?parseInt(t):t}get fallback(){let t;return typeof this._fb=="number"?t=this.choices[this._fb]:typeof this._fb=="string"&&(t={title:this._fb}),t||this._fb||{title:this.i18n.noMatches}}moveSelect(t){this.select=t,this.suggestions.length>0?this.value=$e(this.suggestions,t):this.value=this.fallback.value,this.fire()}async complete(t){const e=this.completing=this.suggest(this.input,this.choices),i=await e;if(this.completing!==e)return;this.suggestions=i.map((n,r,l)=>({title:gr(l,r),value:$e(l,r),description:n.description})),this.completing=!1;const o=Math.max(i.length-1,0);this.moveSelect(Math.min(o,this.select)),t&&t()}reset(){this.input="",this.complete(()=>{this.moveSelect(this.initial!==void 0?this.initial:0),this.render()}),this.render()}exit(){this.clearFirst&&this.input.length>0?this.reset():(this.done=this.exited=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
33
|
+
`),this.close())}abort(){this.done=this.aborted=!0,this.exited=!1,this.fire(),this.render(),this.out.write(`
|
34
|
+
`),this.close()}submit(){this.done=!0,this.aborted=this.exited=!1,this.fire(),this.render(),this.out.write(`
|
35
|
+
`),this.close()}_(t,e){let i=this.input.slice(0,this.cursor),o=this.input.slice(this.cursor);this.input=`${i}${t}${o}`,this.cursor=i.length+1,this.complete(this.render),this.render()}delete(){if(this.cursor===0)return this.bell();let t=this.input.slice(0,this.cursor-1),e=this.input.slice(this.cursor);this.input=`${t}${e}`,this.complete(this.render),this.cursor=this.cursor-1,this.render()}deleteForward(){if(this.cursor*this.scale>=this.rendered.length)return this.bell();let t=this.input.slice(0,this.cursor),e=this.input.slice(this.cursor+1);this.input=`${t}${e}`,this.complete(this.render),this.render()}first(){this.moveSelect(0),this.render()}last(){this.moveSelect(this.suggestions.length-1),this.render()}up(){this.select===0?this.moveSelect(this.suggestions.length-1):this.moveSelect(this.select-1),this.render()}down(){this.select===this.suggestions.length-1?this.moveSelect(0):this.moveSelect(this.select+1),this.render()}next(){this.select===this.suggestions.length-1?this.moveSelect(0):this.moveSelect(this.select+1),this.render()}nextPage(){this.moveSelect(Math.min(this.select+this.limit,this.suggestions.length-1)),this.render()}prevPage(){this.moveSelect(Math.max(this.select-this.limit,0)),this.render()}left(){if(this.cursor<=0)return this.bell();this.cursor=this.cursor-1,this.render()}right(){if(this.cursor*this.scale>=this.rendered.length)return this.bell();this.cursor=this.cursor+1,this.render()}renderOption(t,e,i,o){let n,r=i?_t.arrowUp:o?_t.arrowDown:" ",l=e?Q.cyan().underline(t.title):t.title;return r=(e?Q.cyan(_t.pointer)+" ":" ")+r,t.description&&(n=` - ${t.description}`,(r.length+l.length+n.length>=this.out.columns||t.description.split(/\r?\n/).length>1)&&(n=`
|
36
|
+
`+pr(t.description,{margin:3,width:this.out.columns}))),r+" "+l+Q.gray(n||"")}render(){if(this.closed)return;this.firstRender?this.out.write(we.hide):this.out.write(ye(this.outputText,this.out.columns)),super.render();let{startIndex:t,endIndex:e}=mr(this.select,this.choices.length,this.limit);if(this.outputText=[Dt.symbol(this.done,this.aborted,this.exited),Q.bold(this.msg),Dt.delimiter(this.completing),this.done&&this.suggestions[this.select]?this.suggestions[this.select].title:this.rendered=this.transform.render(this.input)].join(" "),!this.done){const i=this.suggestions.slice(t,e).map((o,n)=>this.renderOption(o,this.select===n+t,n===0&&t>0,n+t===e-1&&e<this.choices.length)).join(`
|
37
|
+
`);this.outputText+=`
|
38
|
+
`+(i||Q.gray(this.fallback.title))}this.out.write(fr.line+we.to(0)+this.outputText)}}var wr=br;const k=M,{cursor:yr}=D,$r=be,{clear:xe,style:Se,figures:W}=_;class xr extends $r{constructor(t={}){t.overrideRender=!0,super(t),this.inputValue="",this.clear=xe("",this.out.columns),this.filteredOptions=this.value,this.render()}last(){this.cursor=this.filteredOptions.length-1,this.render()}next(){this.cursor=(this.cursor+1)%this.filteredOptions.length,this.render()}up(){this.cursor===0?this.cursor=this.filteredOptions.length-1:this.cursor--,this.render()}down(){this.cursor===this.filteredOptions.length-1?this.cursor=0:this.cursor++,this.render()}left(){this.filteredOptions[this.cursor].selected=!1,this.render()}right(){if(this.value.filter(t=>t.selected).length>=this.maxChoices)return this.bell();this.filteredOptions[this.cursor].selected=!0,this.render()}delete(){this.inputValue.length&&(this.inputValue=this.inputValue.substr(0,this.inputValue.length-1),this.updateFilteredOptions())}updateFilteredOptions(){const t=this.filteredOptions[this.cursor];this.filteredOptions=this.value.filter(i=>this.inputValue?!!(typeof i.title=="string"&&i.title.toLowerCase().includes(this.inputValue.toLowerCase())||typeof i.value=="string"&&i.value.toLowerCase().includes(this.inputValue.toLowerCase())):!0);const e=this.filteredOptions.findIndex(i=>i===t);this.cursor=e<0?0:e,this.render()}handleSpaceToggle(){const t=this.filteredOptions[this.cursor];if(t.selected)t.selected=!1,this.render();else{if(t.disabled||this.value.filter(e=>e.selected).length>=this.maxChoices)return this.bell();t.selected=!0,this.render()}}handleInputChange(t){this.inputValue=this.inputValue+t,this.updateFilteredOptions()}_(t,e){t===" "?this.handleSpaceToggle():this.handleInputChange(t)}renderInstructions(){return this.instructions===void 0||this.instructions?typeof this.instructions=="string"?this.instructions:`
|
2239
39
|
Instructions:
|
2240
40
|
${W.arrowUp}/${W.arrowDown}: Highlight option
|
2241
41
|
${W.arrowLeft}/${W.arrowRight}/[space]: Toggle selection
|
2242
42
|
[a,b,c]/delete: Filter choices
|
2243
43
|
enter/return: Complete answer
|
2244
|
-
`
|
2245
|
-
|
2246
|
-
}
|
2247
|
-
|
2248
|
-
|
2249
|
-
|
2250
|
-
`;
|
2251
|
-
}
|
2252
|
-
renderOption(t, e, i) {
|
2253
|
-
let o;
|
2254
|
-
return (
|
2255
|
-
e.disabled
|
2256
|
-
? (o = t === i ? k.gray().underline(e.title) : k.strikethrough().gray(e.title))
|
2257
|
-
: (o = t === i ? k.cyan().underline(e.title) : e.title),
|
2258
|
-
(e.selected ? k.green(W.radioOn) : W.radioOff) + ' ' + o
|
2259
|
-
);
|
2260
|
-
}
|
2261
|
-
renderDoneOrInstructions() {
|
2262
|
-
if (this.done)
|
2263
|
-
return this.value
|
2264
|
-
.filter((e) => e.selected)
|
2265
|
-
.map((e) => e.title)
|
2266
|
-
.join(', ');
|
2267
|
-
const t = [k.gray(this.hint), this.renderInstructions(), this.renderCurrentInput()];
|
2268
|
-
return (
|
2269
|
-
this.filteredOptions.length &&
|
2270
|
-
this.filteredOptions[this.cursor].disabled &&
|
2271
|
-
t.push(k.yellow(this.warn)),
|
2272
|
-
t.join(' ')
|
2273
|
-
);
|
2274
|
-
}
|
2275
|
-
render() {
|
2276
|
-
if (this.closed) return;
|
2277
|
-
this.firstRender && this.out.write(yr.hide), super.render();
|
2278
|
-
let t = [
|
2279
|
-
Se.symbol(this.done, this.aborted),
|
2280
|
-
k.bold(this.msg),
|
2281
|
-
Se.delimiter(!1),
|
2282
|
-
this.renderDoneOrInstructions(),
|
2283
|
-
].join(' ');
|
2284
|
-
this.showMinError &&
|
2285
|
-
((t += k.red(`You must select a minimum of ${this.minSelected} choices.`)),
|
2286
|
-
(this.showMinError = !1)),
|
2287
|
-
(t += this.renderOptions(this.filteredOptions)),
|
2288
|
-
this.out.write(this.clear + t),
|
2289
|
-
(this.clear = xe(t, this.out.columns));
|
2290
|
-
}
|
2291
|
-
}
|
2292
|
-
var Sr = xr;
|
2293
|
-
const Ee = M,
|
2294
|
-
Er = j,
|
2295
|
-
{ style: Te, clear: Tr } = _,
|
2296
|
-
{ erase: Or, cursor: Oe } = D;
|
2297
|
-
class Pr extends Er {
|
2298
|
-
constructor(t = {}) {
|
2299
|
-
super(t),
|
2300
|
-
(this.msg = t.message),
|
2301
|
-
(this.value = t.initial),
|
2302
|
-
(this.initialValue = !!t.initial),
|
2303
|
-
(this.yesMsg = t.yes || 'yes'),
|
2304
|
-
(this.yesOption = t.yesOption || '(Y/n)'),
|
2305
|
-
(this.noMsg = t.no || 'no'),
|
2306
|
-
(this.noOption = t.noOption || '(y/N)'),
|
2307
|
-
this.render();
|
2308
|
-
}
|
2309
|
-
reset() {
|
2310
|
-
(this.value = this.initialValue), this.fire(), this.render();
|
2311
|
-
}
|
2312
|
-
exit() {
|
2313
|
-
this.abort();
|
2314
|
-
}
|
2315
|
-
abort() {
|
2316
|
-
(this.done = this.aborted = !0),
|
2317
|
-
this.fire(),
|
2318
|
-
this.render(),
|
2319
|
-
this.out.write(`
|
2320
|
-
`),
|
2321
|
-
this.close();
|
2322
|
-
}
|
2323
|
-
submit() {
|
2324
|
-
(this.value = this.value || !1),
|
2325
|
-
(this.done = !0),
|
2326
|
-
(this.aborted = !1),
|
2327
|
-
this.fire(),
|
2328
|
-
this.render(),
|
2329
|
-
this.out.write(`
|
2330
|
-
`),
|
2331
|
-
this.close();
|
2332
|
-
}
|
2333
|
-
_(t, e) {
|
2334
|
-
return t.toLowerCase() === 'y'
|
2335
|
-
? ((this.value = !0), this.submit())
|
2336
|
-
: t.toLowerCase() === 'n'
|
2337
|
-
? ((this.value = !1), this.submit())
|
2338
|
-
: this.bell();
|
2339
|
-
}
|
2340
|
-
render() {
|
2341
|
-
this.closed ||
|
2342
|
-
(this.firstRender
|
2343
|
-
? this.out.write(Oe.hide)
|
2344
|
-
: this.out.write(Tr(this.outputText, this.out.columns)),
|
2345
|
-
super.render(),
|
2346
|
-
(this.outputText = [
|
2347
|
-
Te.symbol(this.done, this.aborted),
|
2348
|
-
Ee.bold(this.msg),
|
2349
|
-
Te.delimiter(this.done),
|
2350
|
-
this.done
|
2351
|
-
? this.value
|
2352
|
-
? this.yesMsg
|
2353
|
-
: this.noMsg
|
2354
|
-
: Ee.gray(this.initialValue ? this.yesOption : this.noOption),
|
2355
|
-
].join(' ')),
|
2356
|
-
this.out.write(Or.line + Oe.to(0) + this.outputText));
|
2357
|
-
}
|
2358
|
-
}
|
2359
|
-
var Cr = Pr,
|
2360
|
-
Mr = {
|
2361
|
-
TextPrompt: ei,
|
2362
|
-
SelectPrompt: li,
|
2363
|
-
TogglePrompt: di,
|
2364
|
-
DatePrompt: Qi,
|
2365
|
-
NumberPrompt: or,
|
2366
|
-
MultiselectPrompt: be,
|
2367
|
-
AutocompletePrompt: wr,
|
2368
|
-
AutocompleteMultiselectPrompt: Sr,
|
2369
|
-
ConfirmPrompt: Cr,
|
2370
|
-
};
|
2371
|
-
(function (s) {
|
2372
|
-
const t = s,
|
2373
|
-
e = Mr,
|
2374
|
-
i = (r) => r;
|
2375
|
-
function o(r, l, c = {}) {
|
2376
|
-
return new Promise((h, $) => {
|
2377
|
-
const f = new e[r](l),
|
2378
|
-
a = c.onAbort || i,
|
2379
|
-
b = c.onSubmit || i,
|
2380
|
-
p = c.onExit || i;
|
2381
|
-
f.on('state', l.onState || i),
|
2382
|
-
f.on('submit', (S) => h(b(S))),
|
2383
|
-
f.on('exit', (S) => h(p(S))),
|
2384
|
-
f.on('abort', (S) => $(a(S)));
|
2385
|
-
});
|
2386
|
-
}
|
2387
|
-
(t.text = (r) => o('TextPrompt', r)),
|
2388
|
-
(t.password = (r) => ((r.style = 'password'), t.text(r))),
|
2389
|
-
(t.invisible = (r) => ((r.style = 'invisible'), t.text(r))),
|
2390
|
-
(t.number = (r) => o('NumberPrompt', r)),
|
2391
|
-
(t.date = (r) => o('DatePrompt', r)),
|
2392
|
-
(t.confirm = (r) => o('ConfirmPrompt', r)),
|
2393
|
-
(t.list = (r) => {
|
2394
|
-
const l = r.separator || ',';
|
2395
|
-
return o('TextPrompt', r, { onSubmit: (c) => c.split(l).map((h) => h.trim()) });
|
2396
|
-
}),
|
2397
|
-
(t.toggle = (r) => o('TogglePrompt', r)),
|
2398
|
-
(t.select = (r) => o('SelectPrompt', r)),
|
2399
|
-
(t.multiselect = (r) => {
|
2400
|
-
r.choices = [].concat(r.choices || []);
|
2401
|
-
const l = (c) => c.filter((h) => h.selected).map((h) => h.value);
|
2402
|
-
return o('MultiselectPrompt', r, { onAbort: l, onSubmit: l });
|
2403
|
-
}),
|
2404
|
-
(t.autocompleteMultiselect = (r) => {
|
2405
|
-
r.choices = [].concat(r.choices || []);
|
2406
|
-
const l = (c) => c.filter((h) => h.selected).map((h) => h.value);
|
2407
|
-
return o('AutocompleteMultiselectPrompt', r, { onAbort: l, onSubmit: l });
|
2408
|
-
});
|
2409
|
-
const n = (r, l) =>
|
2410
|
-
Promise.resolve(l.filter((c) => c.title.slice(0, r.length).toLowerCase() === r.toLowerCase()));
|
2411
|
-
t.autocomplete = (r) => (
|
2412
|
-
(r.suggest = r.suggest || n),
|
2413
|
-
(r.choices = [].concat(r.choices || [])),
|
2414
|
-
o('AutocompletePrompt', r)
|
2415
|
-
);
|
2416
|
-
})(te);
|
2417
|
-
const It = te,
|
2418
|
-
Dr = ['suggest', 'format', 'onState', 'validate', 'onRender', 'type'],
|
2419
|
-
Pe = () => {};
|
2420
|
-
async function L(s = [], { onSubmit: t = Pe, onCancel: e = Pe } = {}) {
|
2421
|
-
const i = {},
|
2422
|
-
o = L._override || {};
|
2423
|
-
s = [].concat(s);
|
2424
|
-
let n, r, l, c, h, $;
|
2425
|
-
const f = async (a, b, p = !1) => {
|
2426
|
-
if (!(!p && a.validate && a.validate(b) !== !0)) return a.format ? await a.format(b, i) : b;
|
2427
|
-
};
|
2428
|
-
for (r of s)
|
2429
|
-
if (
|
2430
|
-
(({ name: c, type: h } = r),
|
2431
|
-
typeof h == 'function' && ((h = await h(n, { ...i }, r)), (r.type = h)),
|
2432
|
-
!!h)
|
2433
|
-
) {
|
2434
|
-
for (let a in r) {
|
2435
|
-
if (Dr.includes(a)) continue;
|
2436
|
-
let b = r[a];
|
2437
|
-
r[a] = typeof b == 'function' ? await b(n, { ...i }, $) : b;
|
2438
|
-
}
|
2439
|
-
if ((($ = r), typeof r.message != 'string')) throw new Error('prompt message is required');
|
2440
|
-
if ((({ name: c, type: h } = r), It[h] === void 0))
|
2441
|
-
throw new Error(`prompt type (${h}) is not defined`);
|
2442
|
-
if (o[r.name] !== void 0 && ((n = await f(r, o[r.name])), n !== void 0)) {
|
2443
|
-
i[c] = n;
|
2444
|
-
continue;
|
2445
|
-
}
|
2446
|
-
try {
|
2447
|
-
(n = L._injected ? _r(L._injected, r.initial) : await It[h](r)),
|
2448
|
-
(i[c] = n = await f(r, n, !0)),
|
2449
|
-
(l = await t(r, n, i));
|
2450
|
-
} catch {
|
2451
|
-
l = !(await e(r, i));
|
2452
|
-
}
|
2453
|
-
if (l) return i;
|
2454
|
-
}
|
2455
|
-
return i;
|
2456
|
-
}
|
2457
|
-
function _r(s, t) {
|
2458
|
-
const e = s.shift();
|
2459
|
-
if (e instanceof Error) throw e;
|
2460
|
-
return e === void 0 ? t : e;
|
2461
|
-
}
|
2462
|
-
function Ir(s) {
|
2463
|
-
L._injected = (L._injected || []).concat(s);
|
2464
|
-
}
|
2465
|
-
function Ar(s) {
|
2466
|
-
L._override = Object.assign({}, s);
|
2467
|
-
}
|
2468
|
-
var Rr = Object.assign(L, { prompt: L, prompts: It, inject: Ir, override: Ar });
|
2469
|
-
let H = !0;
|
2470
|
-
const G =
|
2471
|
-
typeof self < 'u' ? self : typeof window < 'u' ? window : typeof global < 'u' ? global : {};
|
2472
|
-
let Ce = 0;
|
2473
|
-
if (G.process && G.process.env && G.process.stdout) {
|
2474
|
-
const { FORCE_COLOR: s, NODE_DISABLE_COLORS: t, TERM: e } = G.process.env;
|
2475
|
-
t || s === '0'
|
2476
|
-
? (H = !1)
|
2477
|
-
: s === '1'
|
2478
|
-
? (H = !0)
|
2479
|
-
: e === 'dumb'
|
2480
|
-
? (H = !1)
|
2481
|
-
: 'CI' in G.process.env &&
|
2482
|
-
['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'GITHUB_ACTIONS', 'BUILDKITE', 'DRONE'].some(
|
2483
|
-
(i) => i in G.process.env,
|
2484
|
-
)
|
2485
|
-
? (H = !0)
|
2486
|
-
: (H = process.stdout.isTTY),
|
2487
|
-
H && (Ce = e && e.endsWith('-256color') ? 2 : 1);
|
2488
|
-
}
|
2489
|
-
let Me = { enabled: H, supportLevel: Ce };
|
2490
|
-
function ot(s, t, e = 1) {
|
2491
|
-
const i = `\x1B[${s}m`,
|
2492
|
-
o = `\x1B[${t}m`,
|
2493
|
-
n = new RegExp(`\\x1b\\[${t}m`, 'g');
|
2494
|
-
return (r) => (Me.enabled && Me.supportLevel >= e ? i + ('' + r).replace(n, i) + o : '' + r);
|
2495
|
-
}
|
2496
|
-
const N = ot(0, 0),
|
2497
|
-
De = ot(31, 39),
|
2498
|
-
_e = ot(32, 39),
|
2499
|
-
J = ot(34, 39),
|
2500
|
-
At = ws(process.argv.slice(2), { string: ['_'] }),
|
2501
|
-
Rt = process.cwd(),
|
2502
|
-
kt = [
|
2503
|
-
{
|
2504
|
-
name: 'vue',
|
2505
|
-
display: 'Young Designed Vue Template',
|
2506
|
-
color: _e,
|
2507
|
-
variants: [
|
2508
|
-
{ name: 'vue-thin', display: 'Vue3 + TS + Pinia + Unocss', color: _e },
|
2509
|
-
{ name: 'vue-admin', display: 'Vue3 + ElementPlus + TS + Pinia + Unocss', color: J },
|
2510
|
-
{ name: 'admin-server', display: 'Node Server Based on Midwayjs', color: J },
|
2511
|
-
{ name: 'vue-mobile', display: 'Vue3 + Vant4 + TS + Pinia + Unocss', color: J },
|
2512
|
-
{ name: 'nuxt3', display: 'Nuxt3 + TS + Pinia + Unocss', color: J, wip: !0 },
|
2513
|
-
{ name: 'ssr', display: 'NestJS + TS + Pinia + Tailwindcss', color: J, wip: !0 },
|
2514
|
-
{ name: 'solidjs-ssr', display: 'SolidJS + TS + Pinia + Unocss', color: J, wip: !0 },
|
2515
|
-
],
|
2516
|
-
},
|
2517
|
-
{
|
2518
|
-
name: 'vite',
|
2519
|
-
display: 'Vite Formal',
|
2520
|
-
color: N,
|
2521
|
-
variants: [
|
2522
|
-
{
|
2523
|
-
name: 'create-vite',
|
2524
|
-
display: 'create-vite',
|
2525
|
-
color: N,
|
2526
|
-
customCommand: 'npm create vite@latest TARGET_DIR',
|
2527
|
-
},
|
2528
|
-
],
|
2529
|
-
},
|
2530
|
-
{
|
2531
|
-
name: 'others',
|
2532
|
-
display: 'Others',
|
2533
|
-
color: N,
|
2534
|
-
variants: [
|
2535
|
-
{
|
2536
|
-
name: 'create-vite-extra',
|
2537
|
-
display: 'create-vite-extra \u2197',
|
2538
|
-
color: N,
|
2539
|
-
customCommand: 'npm create vite-extra@latest TARGET_DIR',
|
2540
|
-
},
|
2541
|
-
],
|
2542
|
-
},
|
2543
|
-
],
|
2544
|
-
Ie = kt
|
2545
|
-
.map((s) => (s.variants && s.variants.map((t) => t.name)) || [s.name])
|
2546
|
-
.reduce((s, t) => s.concat(t), []),
|
2547
|
-
kr = { _gitignore: '.gitignore', _env: '.env' },
|
2548
|
-
Nt = 'vite-project';
|
2549
|
-
async function Nr() {
|
2550
|
-
const s = Ae(At._[0]),
|
2551
|
-
t = At.template || At.t;
|
2552
|
-
let e = s || Nt;
|
2553
|
-
const i = () => (e === '.' ? C.basename(C.resolve()) : e);
|
2554
|
-
let o;
|
2555
|
-
try {
|
2556
|
-
o = await Rr(
|
2557
|
-
[
|
2558
|
-
{
|
2559
|
-
type: s ? null : 'text',
|
2560
|
-
name: 'projectName',
|
2561
|
-
message: N('Project name:'),
|
2562
|
-
initial: Nt,
|
2563
|
-
onState: (d) => {
|
2564
|
-
e = Ae(d.value) || Nt;
|
2565
|
-
},
|
2566
|
-
},
|
2567
|
-
{
|
2568
|
-
type: () => (!T.existsSync(e) || Lr(e) ? null : 'confirm'),
|
2569
|
-
name: 'overwrite',
|
2570
|
-
message: () =>
|
2571
|
-
(e === '.' ? 'Current directory' : `Target directory "${e}"`) +
|
2572
|
-
' is not empty. Remove existing files and continue?',
|
2573
|
-
},
|
2574
|
-
{
|
2575
|
-
type: (d, { overwrite: u }) => {
|
2576
|
-
if (u === !1) throw new Error(De('\u2716') + ' Operation cancelled');
|
2577
|
-
return null;
|
2578
|
-
},
|
2579
|
-
name: 'overwriteChecker',
|
2580
|
-
},
|
2581
|
-
{
|
2582
|
-
type: () => (ke(i()) ? null : 'text'),
|
2583
|
-
name: 'packageName',
|
2584
|
-
message: N('Package name:'),
|
2585
|
-
initial: () => jr(i()),
|
2586
|
-
validate: (d) => ke(d) || 'Invalid package.json name',
|
2587
|
-
},
|
2588
|
-
{
|
2589
|
-
type: t && Ie.includes(t) ? null : 'select',
|
2590
|
-
name: 'framework',
|
2591
|
-
message:
|
2592
|
-
typeof t == 'string' && !Ie.includes(t)
|
2593
|
-
? N(`"${t}" isn't a valid template. Please choose from below: `)
|
2594
|
-
: N('Select a framework:'),
|
2595
|
-
initial: 0,
|
2596
|
-
choices: kt.map((d) => {
|
2597
|
-
const u = d.color;
|
2598
|
-
return { title: u(d.display || d.name), value: d };
|
2599
|
-
}),
|
2600
|
-
},
|
2601
|
-
{
|
2602
|
-
type: (d) => (d && d.variants ? 'select' : null),
|
2603
|
-
name: 'variant',
|
2604
|
-
message: N('Select a variant:'),
|
2605
|
-
choices: (d) =>
|
2606
|
-
d.variants.map((u) => {
|
2607
|
-
const w = u.color;
|
2608
|
-
return { title: w(u.display || u.name), value: u.name, disabled: u.wip };
|
2609
|
-
}),
|
2610
|
-
},
|
2611
|
-
],
|
2612
|
-
{
|
2613
|
-
onCancel: () => {
|
2614
|
-
throw new Error(De('\u2716') + ' Operation cancelled');
|
2615
|
-
},
|
2616
|
-
},
|
2617
|
-
);
|
2618
|
-
} catch (d) {
|
2619
|
-
console.log(d.message);
|
2620
|
-
return;
|
2621
|
-
}
|
2622
|
-
const { framework: n, overwrite: r, packageName: l, variant: c } = o,
|
2623
|
-
h = C.join(Rt, e);
|
2624
|
-
r ? Vr(h) : T.existsSync(h) || T.mkdirSync(h, { recursive: !0 });
|
2625
|
-
const $ = c || n?.name || t,
|
2626
|
-
f = Yr(process.env.npm_config_user_agent),
|
2627
|
-
a = f ? f.name : 'npm',
|
2628
|
-
b = a === 'yarn' && f?.version.startsWith('1.'),
|
2629
|
-
{ customCommand: p } = kt.flatMap((d) => d.variants).find((d) => d.name === $) ?? {};
|
2630
|
-
if (p) {
|
2631
|
-
const d = p
|
2632
|
-
.replace('TARGET_DIR', e)
|
2633
|
-
.replace(/^npm create/, `${a} create`)
|
2634
|
-
.replace('@latest', () => (b ? '' : '@latest'))
|
2635
|
-
.replace(/^npm exec/, () =>
|
2636
|
-
a === 'pnpm' ? 'pnpm dlx' : a === 'yarn' && !b ? 'yarn dlx' : 'npm exec',
|
2637
|
-
),
|
2638
|
-
[u, ...w] = d.split(' '),
|
2639
|
-
{ status: P } = B.exports.sync(u, w, { stdio: 'inherit' });
|
2640
|
-
process.exit(P ?? 0);
|
2641
|
-
}
|
2642
|
-
console.log(`
|
2643
|
-
Scaffolding project in ${h}...`);
|
2644
|
-
const S = C.resolve(Ne(import.meta.url), '../..', `template-${$}`),
|
2645
|
-
E = (d, u) => {
|
2646
|
-
const w = C.join(h, kr[d] ?? d);
|
2647
|
-
u ? T.writeFileSync(w, u) : Re(C.join(S, d), w);
|
2648
|
-
},
|
2649
|
-
O = T.readdirSync(S);
|
2650
|
-
for (const d of O.filter((u) => u !== 'package.json')) E(d);
|
2651
|
-
const V = JSON.parse(T.readFileSync(C.join(S, 'package.json'), 'utf-8'));
|
2652
|
-
switch (
|
2653
|
-
((V.name = l || i()),
|
2654
|
-
E('package.json', JSON.stringify(V, null, 2)),
|
2655
|
-
console.log(`
|
44
|
+
`:""}renderCurrentInput(){return`
|
45
|
+
Filtered results for: ${this.inputValue?this.inputValue:k.gray("Enter something to filter")}
|
46
|
+
`}renderOption(t,e,i){let o;return e.disabled?o=t===i?k.gray().underline(e.title):k.strikethrough().gray(e.title):o=t===i?k.cyan().underline(e.title):e.title,(e.selected?k.green(W.radioOn):W.radioOff)+" "+o}renderDoneOrInstructions(){if(this.done)return this.value.filter(e=>e.selected).map(e=>e.title).join(", ");const t=[k.gray(this.hint),this.renderInstructions(),this.renderCurrentInput()];return this.filteredOptions.length&&this.filteredOptions[this.cursor].disabled&&t.push(k.yellow(this.warn)),t.join(" ")}render(){if(this.closed)return;this.firstRender&&this.out.write(yr.hide),super.render();let t=[Se.symbol(this.done,this.aborted),k.bold(this.msg),Se.delimiter(!1),this.renderDoneOrInstructions()].join(" ");this.showMinError&&(t+=k.red(`You must select a minimum of ${this.minSelected} choices.`),this.showMinError=!1),t+=this.renderOptions(this.filteredOptions),this.out.write(this.clear+t),this.clear=xe(t,this.out.columns)}}var Sr=xr;const Ee=M,Er=j,{style:Te,clear:Tr}=_,{erase:Or,cursor:Oe}=D;class Pr extends Er{constructor(t={}){super(t),this.msg=t.message,this.value=t.initial,this.initialValue=!!t.initial,this.yesMsg=t.yes||"yes",this.yesOption=t.yesOption||"(Y/n)",this.noMsg=t.no||"no",this.noOption=t.noOption||"(y/N)",this.render()}reset(){this.value=this.initialValue,this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
|
47
|
+
`),this.close()}submit(){this.value=this.value||!1,this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
48
|
+
`),this.close()}_(t,e){return t.toLowerCase()==="y"?(this.value=!0,this.submit()):t.toLowerCase()==="n"?(this.value=!1,this.submit()):this.bell()}render(){this.closed||(this.firstRender?this.out.write(Oe.hide):this.out.write(Tr(this.outputText,this.out.columns)),super.render(),this.outputText=[Te.symbol(this.done,this.aborted),Ee.bold(this.msg),Te.delimiter(this.done),this.done?this.value?this.yesMsg:this.noMsg:Ee.gray(this.initialValue?this.yesOption:this.noOption)].join(" "),this.out.write(Or.line+Oe.to(0)+this.outputText))}}var Cr=Pr,Mr={TextPrompt:ei,SelectPrompt:li,TogglePrompt:di,DatePrompt:Qi,NumberPrompt:or,MultiselectPrompt:be,AutocompletePrompt:wr,AutocompleteMultiselectPrompt:Sr,ConfirmPrompt:Cr};(function(s){const t=s,e=Mr,i=r=>r;function o(r,l,c={}){return new Promise((h,$)=>{const f=new e[r](l),a=c.onAbort||i,b=c.onSubmit||i,p=c.onExit||i;f.on("state",l.onState||i),f.on("submit",S=>h(b(S))),f.on("exit",S=>h(p(S))),f.on("abort",S=>$(a(S)))})}t.text=r=>o("TextPrompt",r),t.password=r=>(r.style="password",t.text(r)),t.invisible=r=>(r.style="invisible",t.text(r)),t.number=r=>o("NumberPrompt",r),t.date=r=>o("DatePrompt",r),t.confirm=r=>o("ConfirmPrompt",r),t.list=r=>{const l=r.separator||",";return o("TextPrompt",r,{onSubmit:c=>c.split(l).map(h=>h.trim())})},t.toggle=r=>o("TogglePrompt",r),t.select=r=>o("SelectPrompt",r),t.multiselect=r=>{r.choices=[].concat(r.choices||[]);const l=c=>c.filter(h=>h.selected).map(h=>h.value);return o("MultiselectPrompt",r,{onAbort:l,onSubmit:l})},t.autocompleteMultiselect=r=>{r.choices=[].concat(r.choices||[]);const l=c=>c.filter(h=>h.selected).map(h=>h.value);return o("AutocompleteMultiselectPrompt",r,{onAbort:l,onSubmit:l})};const n=(r,l)=>Promise.resolve(l.filter(c=>c.title.slice(0,r.length).toLowerCase()===r.toLowerCase()));t.autocomplete=r=>(r.suggest=r.suggest||n,r.choices=[].concat(r.choices||[]),o("AutocompletePrompt",r))})(te);const It=te,Dr=["suggest","format","onState","validate","onRender","type"],Pe=()=>{};async function L(s=[],{onSubmit:t=Pe,onCancel:e=Pe}={}){const i={},o=L._override||{};s=[].concat(s);let n,r,l,c,h,$;const f=async(a,b,p=!1)=>{if(!(!p&&a.validate&&a.validate(b)!==!0))return a.format?await a.format(b,i):b};for(r of s)if({name:c,type:h}=r,typeof h=="function"&&(h=await h(n,{...i},r),r.type=h),!!h){for(let a in r){if(Dr.includes(a))continue;let b=r[a];r[a]=typeof b=="function"?await b(n,{...i},$):b}if($=r,typeof r.message!="string")throw new Error("prompt message is required");if({name:c,type:h}=r,It[h]===void 0)throw new Error(`prompt type (${h}) is not defined`);if(o[r.name]!==void 0&&(n=await f(r,o[r.name]),n!==void 0)){i[c]=n;continue}try{n=L._injected?_r(L._injected,r.initial):await It[h](r),i[c]=n=await f(r,n,!0),l=await t(r,n,i)}catch{l=!await e(r,i)}if(l)return i}return i}function _r(s,t){const e=s.shift();if(e instanceof Error)throw e;return e===void 0?t:e}function Ir(s){L._injected=(L._injected||[]).concat(s)}function Ar(s){L._override=Object.assign({},s)}var Rr=Object.assign(L,{prompt:L,prompts:It,inject:Ir,override:Ar});let H=!0;const G=typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{};let Ce=0;if(G.process&&G.process.env&&G.process.stdout){const{FORCE_COLOR:s,NODE_DISABLE_COLORS:t,TERM:e}=G.process.env;t||s==="0"?H=!1:s==="1"?H=!0:e==="dumb"?H=!1:"CI"in G.process.env&&["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE","DRONE"].some(i=>i in G.process.env)?H=!0:H=process.stdout.isTTY,H&&(Ce=e&&e.endsWith("-256color")?2:1)}let Me={enabled:H,supportLevel:Ce};function ot(s,t,e=1){const i=`\x1B[${s}m`,o=`\x1B[${t}m`,n=new RegExp(`\\x1b\\[${t}m`,"g");return r=>Me.enabled&&Me.supportLevel>=e?i+(""+r).replace(n,i)+o:""+r}const N=ot(0,0),De=ot(31,39),_e=ot(32,39),J=ot(34,39),At=ws(process.argv.slice(2),{string:["_"]}),Rt=process.cwd(),kt=[{name:"vue",display:"Young Designed Vue Template",color:_e,variants:[{name:"vue-thin",display:"Vue3 + TS + Pinia + Unocss",color:_e},{name:"vue-admin",display:"Vue3 + ElementPlus + TS + Pinia + Unocss",color:J},{name:"admin-server",display:"Node Server Based on Midwayjs",color:J},{name:"vue-mobile",display:"Vue3 + Vant4 + TS + Pinia + Unocss",color:J},{name:"nuxt3",display:"Nuxt3 + TS + Pinia + Unocss",color:J,wip:!0},{name:"ssr",display:"NestJS + TS + Pinia + Tailwindcss",color:J,wip:!0},{name:"solidjs-ssr",display:"SolidJS + TS + Pinia + Unocss",color:J,wip:!0}]},{name:"vite",display:"Vite Formal",color:N,variants:[{name:"create-vite",display:"create-vite",color:N,customCommand:"npm create vite@latest TARGET_DIR"}]},{name:"others",display:"Others",color:N,variants:[{name:"create-vite-extra",display:"create-vite-extra \u2197",color:N,customCommand:"npm create vite-extra@latest TARGET_DIR"}]}],Ie=kt.map(s=>s.variants&&s.variants.map(t=>t.name)||[s.name]).reduce((s,t)=>s.concat(t),[]),kr={_gitignore:".gitignore",_env:".env"},Nt="vite-project";async function Nr(){const s=Ae(At._[0]),t=At.template||At.t;let e=s||Nt;const i=()=>e==="."?C.basename(C.resolve()):e;let o;try{o=await Rr([{type:s?null:"text",name:"projectName",message:N("Project name:"),initial:Nt,onState:d=>{e=Ae(d.value)||Nt}},{type:()=>!T.existsSync(e)||Lr(e)?null:"confirm",name:"overwrite",message:()=>(e==="."?"Current directory":`Target directory "${e}"`)+" is not empty. Remove existing files and continue?"},{type:(d,{overwrite:u})=>{if(u===!1)throw new Error(De("\u2716")+" Operation cancelled");return null},name:"overwriteChecker"},{type:()=>ke(i())?null:"text",name:"packageName",message:N("Package name:"),initial:()=>jr(i()),validate:d=>ke(d)||"Invalid package.json name"},{type:t&&Ie.includes(t)?null:"select",name:"framework",message:typeof t=="string"&&!Ie.includes(t)?N(`"${t}" isn't a valid template. Please choose from below: `):N("Select a framework:"),initial:0,choices:kt.map(d=>{const u=d.color;return{title:u(d.display||d.name),value:d}})},{type:d=>d&&d.variants?"select":null,name:"variant",message:N("Select a variant:"),choices:d=>d.variants.map(u=>{const w=u.color;return{title:w(u.display||u.name),value:u.name,disabled:u.wip}})}],{onCancel:()=>{throw new Error(De("\u2716")+" Operation cancelled")}})}catch(d){console.log(d.message);return}const{framework:n,overwrite:r,packageName:l,variant:c}=o,h=C.join(Rt,e);r?Vr(h):T.existsSync(h)||T.mkdirSync(h,{recursive:!0});const $=c||n?.name||t,f=Yr(process.env.npm_config_user_agent),a=f?f.name:"npm",b=a==="yarn"&&f?.version.startsWith("1."),{customCommand:p}=kt.flatMap(d=>d.variants).find(d=>d.name===$)??{};if(p){const d=p.replace("TARGET_DIR",e).replace(/^npm create/,`${a} create`).replace("@latest",()=>b?"":"@latest").replace(/^npm exec/,()=>a==="pnpm"?"pnpm dlx":a==="yarn"&&!b?"yarn dlx":"npm exec"),[u,...w]=d.split(" "),{status:P}=B.exports.sync(u,w,{stdio:"inherit"});process.exit(P??0)}console.log(`
|
49
|
+
Scaffolding project in ${h}...`);const S=C.resolve(Ne(import.meta.url),"../..",`template-${$}`),E=(d,u)=>{const w=C.join(h,kr[d]??d);u?T.writeFileSync(w,u):Re(C.join(S,d),w)},O=T.readdirSync(S);for(const d of O.filter(u=>u!=="package.json"))E(d);const V=JSON.parse(T.readFileSync(C.join(S,"package.json"),"utf-8"));switch(V.name=l||i(),E("package.json",JSON.stringify(V,null,2)),console.log(`
|
2656
50
|
Done. Now run:
|
2657
|
-
`),
|
2658
|
-
h !== Rt && console.log(` cd ${C.relative(Rt, h)}`),
|
2659
|
-
a)
|
2660
|
-
) {
|
2661
|
-
case 'yarn':
|
2662
|
-
console.log(' yarn'), console.log(' yarn dev');
|
2663
|
-
break;
|
2664
|
-
default:
|
2665
|
-
console.log(` ${a} install`), console.log(` ${a} run dev`);
|
2666
|
-
break;
|
2667
|
-
}
|
2668
|
-
console.log();
|
2669
|
-
}
|
2670
|
-
function Ae(s) {
|
2671
|
-
return s?.trim().replace(/\/+$/g, '');
|
2672
|
-
}
|
2673
|
-
function Re(s, t) {
|
2674
|
-
T.statSync(s).isDirectory() ? Fr(s, t) : T.copyFileSync(s, t);
|
2675
|
-
}
|
2676
|
-
function ke(s) {
|
2677
|
-
return /^(?:@[a-z\d\-*~][a-z\d\-*._~]*\/)?[a-z\d\-~][a-z\d\-._~]*$/.test(s);
|
2678
|
-
}
|
2679
|
-
function jr(s) {
|
2680
|
-
return s
|
2681
|
-
.trim()
|
2682
|
-
.toLowerCase()
|
2683
|
-
.replace(/\s+/g, '-')
|
2684
|
-
.replace(/^[._]/, '')
|
2685
|
-
.replace(/[^a-z\d\-~]+/g, '-');
|
2686
|
-
}
|
2687
|
-
function Fr(s, t) {
|
2688
|
-
T.mkdirSync(t, { recursive: !0 });
|
2689
|
-
for (const e of T.readdirSync(s)) {
|
2690
|
-
const i = C.resolve(s, e),
|
2691
|
-
o = C.resolve(t, e);
|
2692
|
-
Re(i, o);
|
2693
|
-
}
|
2694
|
-
}
|
2695
|
-
function Lr(s) {
|
2696
|
-
const t = T.readdirSync(s);
|
2697
|
-
return t.length === 0 || (t.length === 1 && t[0] === '.git');
|
2698
|
-
}
|
2699
|
-
function Vr(s) {
|
2700
|
-
if (!!T.existsSync(s))
|
2701
|
-
for (const t of T.readdirSync(s))
|
2702
|
-
t !== '.git' && T.rmSync(C.resolve(s, t), { recursive: !0, force: !0 });
|
2703
|
-
}
|
2704
|
-
function Yr(s) {
|
2705
|
-
if (!s) return;
|
2706
|
-
const e = s.split(' ')[0].split('/');
|
2707
|
-
return { name: e[0], version: e[1] };
|
2708
|
-
}
|
2709
|
-
Nr().catch((s) => {
|
2710
|
-
console.error(s);
|
2711
|
-
});
|
51
|
+
`),h!==Rt&&console.log(` cd ${C.relative(Rt,h)}`),a){case"yarn":console.log(" yarn"),console.log(" yarn dev");break;default:console.log(` ${a} install`),console.log(` ${a} run dev`);break}console.log()}function Ae(s){return s?.trim().replace(/\/+$/g,"")}function Re(s,t){T.statSync(s).isDirectory()?Fr(s,t):T.copyFileSync(s,t)}function ke(s){return/^(?:@[a-z\d\-*~][a-z\d\-*._~]*\/)?[a-z\d\-~][a-z\d\-._~]*$/.test(s)}function jr(s){return s.trim().toLowerCase().replace(/\s+/g,"-").replace(/^[._]/,"").replace(/[^a-z\d\-~]+/g,"-")}function Fr(s,t){T.mkdirSync(t,{recursive:!0});for(const e of T.readdirSync(s)){const i=C.resolve(s,e),o=C.resolve(t,e);Re(i,o)}}function Lr(s){const t=T.readdirSync(s);return t.length===0||t.length===1&&t[0]===".git"}function Vr(s){if(!!T.existsSync(s))for(const t of T.readdirSync(s))t!==".git"&&T.rmSync(C.resolve(s,t),{recursive:!0,force:!0})}function Yr(s){if(!s)return;const e=s.split(" ")[0].split("/");return{name:e[0],version:e[1]}}Nr().catch(s=>{console.error(s)});
|