gh-postplan 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +799 -1529
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { createRequire } from "node:module";
|
|
3
2
|
var __create = Object.create;
|
|
4
3
|
var __getProtoOf = Object.getPrototypeOf;
|
|
5
4
|
var __defProp = Object.defineProperty;
|
|
@@ -33,772 +32,69 @@ var __toESM = (mod, isNodeMode, target) => {
|
|
|
33
32
|
return to;
|
|
34
33
|
};
|
|
35
34
|
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
36
|
-
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
37
35
|
|
|
38
|
-
// node_modules/
|
|
39
|
-
var
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return defaultOpts;
|
|
49
|
-
}
|
|
50
|
-
Object.keys(defaultOpts).forEach(function(key) {
|
|
51
|
-
if (!options[key]) {
|
|
52
|
-
options[key] = defaultOpts[key];
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
return options;
|
|
56
|
-
}
|
|
57
|
-
function cliWidth(options) {
|
|
58
|
-
const opts = normalizeOpts(options);
|
|
59
|
-
if (opts.output.getWindowSize) {
|
|
60
|
-
return opts.output.getWindowSize()[0] || opts.defaultWidth;
|
|
61
|
-
}
|
|
62
|
-
if (opts.tty.getWindowSize) {
|
|
63
|
-
return opts.tty.getWindowSize()[1] || opts.defaultWidth;
|
|
64
|
-
}
|
|
65
|
-
if (opts.output.columns) {
|
|
66
|
-
return opts.output.columns;
|
|
67
|
-
}
|
|
68
|
-
if (process.env.CLI_WIDTH) {
|
|
69
|
-
const width = parseInt(process.env.CLI_WIDTH, 10);
|
|
70
|
-
if (!isNaN(width) && width !== 0) {
|
|
71
|
-
return width;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return opts.defaultWidth;
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
// node_modules/mute-stream/lib/index.js
|
|
79
|
-
var require_lib = __commonJS(function(exports, module) {
|
|
80
|
-
var Stream = __require("stream");
|
|
81
|
-
|
|
82
|
-
class MuteStream extends Stream {
|
|
83
|
-
#isTTY = null;
|
|
84
|
-
constructor(opts = {}) {
|
|
85
|
-
super(opts);
|
|
86
|
-
this.writable = this.readable = true;
|
|
87
|
-
this.muted = false;
|
|
88
|
-
this.on("pipe", this._onpipe);
|
|
89
|
-
this.replace = opts.replace;
|
|
90
|
-
this._prompt = opts.prompt || null;
|
|
91
|
-
this._hadControl = false;
|
|
92
|
-
}
|
|
93
|
-
#destSrc(key, def) {
|
|
94
|
-
if (this._dest) {
|
|
95
|
-
return this._dest[key];
|
|
96
|
-
}
|
|
97
|
-
if (this._src) {
|
|
98
|
-
return this._src[key];
|
|
99
|
-
}
|
|
100
|
-
return def;
|
|
101
|
-
}
|
|
102
|
-
#proxy(method, ...args) {
|
|
103
|
-
if (typeof this._dest?.[method] === "function") {
|
|
104
|
-
this._dest[method](...args);
|
|
105
|
-
}
|
|
106
|
-
if (typeof this._src?.[method] === "function") {
|
|
107
|
-
this._src[method](...args);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
get isTTY() {
|
|
111
|
-
if (this.#isTTY !== null) {
|
|
112
|
-
return this.#isTTY;
|
|
113
|
-
}
|
|
114
|
-
return this.#destSrc("isTTY", false);
|
|
115
|
-
}
|
|
116
|
-
set isTTY(val) {
|
|
117
|
-
this.#isTTY = val;
|
|
118
|
-
}
|
|
119
|
-
get rows() {
|
|
120
|
-
return this.#destSrc("rows");
|
|
121
|
-
}
|
|
122
|
-
get columns() {
|
|
123
|
-
return this.#destSrc("columns");
|
|
124
|
-
}
|
|
125
|
-
mute() {
|
|
126
|
-
this.muted = true;
|
|
127
|
-
}
|
|
128
|
-
unmute() {
|
|
129
|
-
this.muted = false;
|
|
130
|
-
}
|
|
131
|
-
_onpipe(src) {
|
|
132
|
-
this._src = src;
|
|
133
|
-
}
|
|
134
|
-
pipe(dest, options) {
|
|
135
|
-
this._dest = dest;
|
|
136
|
-
return super.pipe(dest, options);
|
|
137
|
-
}
|
|
138
|
-
pause() {
|
|
139
|
-
if (this._src) {
|
|
140
|
-
return this._src.pause();
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
resume() {
|
|
144
|
-
if (this._src) {
|
|
145
|
-
return this._src.resume();
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
write(c) {
|
|
149
|
-
if (this.muted) {
|
|
150
|
-
if (!this.replace) {
|
|
151
|
-
return true;
|
|
152
|
-
}
|
|
153
|
-
if (c.match(/^\u001b/)) {
|
|
154
|
-
if (c.indexOf(this._prompt) === 0) {
|
|
155
|
-
c = c.slice(this._prompt.length);
|
|
156
|
-
c = c.replace(/./g, this.replace);
|
|
157
|
-
c = this._prompt + c;
|
|
158
|
-
}
|
|
159
|
-
this._hadControl = true;
|
|
160
|
-
return this.emit("data", c);
|
|
161
|
-
} else {
|
|
162
|
-
if (this._prompt && this._hadControl && c.indexOf(this._prompt) === 0) {
|
|
163
|
-
this._hadControl = false;
|
|
164
|
-
this.emit("data", this._prompt);
|
|
165
|
-
c = c.slice(this._prompt.length);
|
|
166
|
-
}
|
|
167
|
-
c = c.toString().replace(/./g, this.replace);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
this.emit("data", c);
|
|
171
|
-
}
|
|
172
|
-
end(c) {
|
|
173
|
-
if (this.muted) {
|
|
174
|
-
if (c && this.replace) {
|
|
175
|
-
c = c.toString().replace(/./g, this.replace);
|
|
176
|
-
} else {
|
|
177
|
-
c = null;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
if (c) {
|
|
181
|
-
this.emit("data", c);
|
|
182
|
-
}
|
|
183
|
-
this.emit("end");
|
|
184
|
-
}
|
|
185
|
-
destroy(...args) {
|
|
186
|
-
return this.#proxy("destroy", ...args);
|
|
187
|
-
}
|
|
188
|
-
destroySoon(...args) {
|
|
189
|
-
return this.#proxy("destroySoon", ...args);
|
|
190
|
-
}
|
|
191
|
-
close(...args) {
|
|
192
|
-
return this.#proxy("close", ...args);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
module.exports = MuteStream;
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
// node_modules/@inquirer/core/dist/lib/key.js
|
|
199
|
-
var keybindings = ["emacs", "vim"];
|
|
200
|
-
var keybindingLookup = new Set(keybindings);
|
|
201
|
-
function isKeybinding(value) {
|
|
202
|
-
return keybindingLookup.has(value);
|
|
203
|
-
}
|
|
204
|
-
function getDefaultKeybindings() {
|
|
205
|
-
const env = process.env["INQUIRER_KEYBINDINGS"];
|
|
206
|
-
if (!env)
|
|
207
|
-
return [];
|
|
208
|
-
return Array.from(new Set(env.toLowerCase().split(/[\s,]+/).filter(isKeybinding)));
|
|
209
|
-
}
|
|
210
|
-
var isUpKey = (key, keybindings2 = []) => key.name === "up" || keybindings2.includes("vim") && key.name === "k" || keybindings2.includes("emacs") && key.ctrl && key.name === "p";
|
|
211
|
-
var isDownKey = (key, keybindings2 = []) => key.name === "down" || keybindings2.includes("vim") && key.name === "j" || keybindings2.includes("emacs") && key.ctrl && key.name === "n";
|
|
212
|
-
var isSpaceKey = (key) => key.name === "space";
|
|
213
|
-
var isNumberKey = (key) => "1234567890".includes(key.name);
|
|
214
|
-
var isEnterKey = (key) => key.name === "enter" || key.name === "return";
|
|
215
|
-
// node_modules/@inquirer/core/dist/lib/errors.js
|
|
216
|
-
class AbortPromptError extends Error {
|
|
217
|
-
name = "AbortPromptError";
|
|
218
|
-
message = "Prompt was aborted";
|
|
219
|
-
constructor(options) {
|
|
220
|
-
super();
|
|
221
|
-
this.cause = options?.cause;
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
class CancelPromptError extends Error {
|
|
226
|
-
name = "CancelPromptError";
|
|
227
|
-
message = "Prompt was canceled";
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
class ExitPromptError extends Error {
|
|
231
|
-
name = "ExitPromptError";
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
class HookError extends Error {
|
|
235
|
-
name = "HookError";
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
class ValidationError extends Error {
|
|
239
|
-
name = "ValidationError";
|
|
240
|
-
}
|
|
241
|
-
// node_modules/@inquirer/core/dist/lib/use-state.js
|
|
242
|
-
import { AsyncResource as AsyncResource2 } from "node:async_hooks";
|
|
243
|
-
|
|
244
|
-
// node_modules/@inquirer/core/dist/lib/hook-engine.js
|
|
245
|
-
import { AsyncLocalStorage, AsyncResource } from "node:async_hooks";
|
|
246
|
-
var hookStorage = new AsyncLocalStorage;
|
|
247
|
-
function createStore(rl) {
|
|
248
|
-
const store = {
|
|
249
|
-
rl,
|
|
250
|
-
hooks: [],
|
|
251
|
-
hooksCleanup: [],
|
|
252
|
-
hooksEffect: [],
|
|
253
|
-
index: 0,
|
|
254
|
-
handleChange() {}
|
|
255
|
-
};
|
|
256
|
-
return store;
|
|
257
|
-
}
|
|
258
|
-
function withHooks(rl, cb) {
|
|
259
|
-
const store = createStore(rl);
|
|
260
|
-
return hookStorage.run(store, () => {
|
|
261
|
-
function cycle(render) {
|
|
262
|
-
store.handleChange = () => {
|
|
263
|
-
store.index = 0;
|
|
264
|
-
render();
|
|
265
|
-
};
|
|
266
|
-
store.handleChange();
|
|
267
|
-
}
|
|
268
|
-
return cb(cycle);
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
|
-
function getStore() {
|
|
272
|
-
const store = hookStorage.getStore();
|
|
273
|
-
if (!store) {
|
|
274
|
-
throw new HookError("[Inquirer] Hook functions can only be called from within a prompt");
|
|
275
|
-
}
|
|
276
|
-
return store;
|
|
277
|
-
}
|
|
278
|
-
function readline() {
|
|
279
|
-
return getStore().rl;
|
|
280
|
-
}
|
|
281
|
-
function withUpdates(fn) {
|
|
282
|
-
const wrapped = (...args) => {
|
|
283
|
-
const store = getStore();
|
|
284
|
-
let shouldUpdate = false;
|
|
285
|
-
const oldHandleChange = store.handleChange;
|
|
286
|
-
store.handleChange = () => {
|
|
287
|
-
shouldUpdate = true;
|
|
288
|
-
};
|
|
289
|
-
const returnValue = fn(...args);
|
|
290
|
-
if (shouldUpdate) {
|
|
291
|
-
oldHandleChange();
|
|
292
|
-
}
|
|
293
|
-
store.handleChange = oldHandleChange;
|
|
294
|
-
return returnValue;
|
|
295
|
-
};
|
|
296
|
-
return AsyncResource.bind(wrapped);
|
|
297
|
-
}
|
|
298
|
-
function withPointer(cb) {
|
|
299
|
-
const store = getStore();
|
|
300
|
-
const { index } = store;
|
|
301
|
-
const pointer = {
|
|
302
|
-
get() {
|
|
303
|
-
return store.hooks[index];
|
|
36
|
+
// node_modules/sisteransi/src/index.js
|
|
37
|
+
var require_src = __commonJS(function(exports, module) {
|
|
38
|
+
var ESC2 = "\x1B";
|
|
39
|
+
var CSI2 = `${ESC2}[`;
|
|
40
|
+
var beep = "\x07";
|
|
41
|
+
var cursor = {
|
|
42
|
+
to(x, y) {
|
|
43
|
+
if (!y)
|
|
44
|
+
return `${CSI2}${x + 1}G`;
|
|
45
|
+
return `${CSI2}${y + 1};${x + 1}H`;
|
|
304
46
|
},
|
|
305
|
-
|
|
306
|
-
|
|
47
|
+
move(x, y) {
|
|
48
|
+
let ret = "";
|
|
49
|
+
if (x < 0)
|
|
50
|
+
ret += `${CSI2}${-x}D`;
|
|
51
|
+
else if (x > 0)
|
|
52
|
+
ret += `${CSI2}${x}C`;
|
|
53
|
+
if (y < 0)
|
|
54
|
+
ret += `${CSI2}${-y}A`;
|
|
55
|
+
else if (y > 0)
|
|
56
|
+
ret += `${CSI2}${y}B`;
|
|
57
|
+
return ret;
|
|
307
58
|
},
|
|
308
|
-
|
|
59
|
+
up: (count = 1) => `${CSI2}${count}A`,
|
|
60
|
+
down: (count = 1) => `${CSI2}${count}B`,
|
|
61
|
+
forward: (count = 1) => `${CSI2}${count}C`,
|
|
62
|
+
backward: (count = 1) => `${CSI2}${count}D`,
|
|
63
|
+
nextLine: (count = 1) => `${CSI2}E`.repeat(count),
|
|
64
|
+
prevLine: (count = 1) => `${CSI2}F`.repeat(count),
|
|
65
|
+
left: `${CSI2}G`,
|
|
66
|
+
hide: `${CSI2}?25l`,
|
|
67
|
+
show: `${CSI2}?25h`,
|
|
68
|
+
save: `${ESC2}7`,
|
|
69
|
+
restore: `${ESC2}8`
|
|
309
70
|
};
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
}
|
|
314
|
-
function handleChange() {
|
|
315
|
-
getStore().handleChange();
|
|
316
|
-
}
|
|
317
|
-
var effectScheduler = {
|
|
318
|
-
queue(cb) {
|
|
319
|
-
const store = getStore();
|
|
320
|
-
const { index } = store;
|
|
321
|
-
store.hooksEffect.push(() => {
|
|
322
|
-
store.hooksCleanup[index]?.();
|
|
323
|
-
const cleanFn = cb(readline());
|
|
324
|
-
if (cleanFn != null && typeof cleanFn !== "function") {
|
|
325
|
-
throw new ValidationError("useEffect return value must be a cleanup function or nothing.");
|
|
326
|
-
}
|
|
327
|
-
store.hooksCleanup[index] = cleanFn;
|
|
328
|
-
});
|
|
329
|
-
},
|
|
330
|
-
run() {
|
|
331
|
-
const store = getStore();
|
|
332
|
-
withUpdates(() => {
|
|
333
|
-
store.hooksEffect.forEach((effect) => {
|
|
334
|
-
effect();
|
|
335
|
-
});
|
|
336
|
-
store.hooksEffect.length = 0;
|
|
337
|
-
})();
|
|
338
|
-
},
|
|
339
|
-
clearAll() {
|
|
340
|
-
const store = getStore();
|
|
341
|
-
store.hooksCleanup.forEach((cleanFn) => {
|
|
342
|
-
cleanFn?.();
|
|
343
|
-
});
|
|
344
|
-
store.hooksEffect.length = 0;
|
|
345
|
-
store.hooksCleanup.length = 0;
|
|
346
|
-
}
|
|
347
|
-
};
|
|
348
|
-
|
|
349
|
-
// node_modules/@inquirer/core/dist/lib/use-state.js
|
|
350
|
-
function isFactory(value) {
|
|
351
|
-
return typeof value === "function";
|
|
352
|
-
}
|
|
353
|
-
function isReducer(value) {
|
|
354
|
-
return typeof value === "function";
|
|
355
|
-
}
|
|
356
|
-
function useState(defaultValue) {
|
|
357
|
-
return withPointer((pointer) => {
|
|
358
|
-
const setState = AsyncResource2.bind(function setState2(newValue) {
|
|
359
|
-
const currentValue = pointer.get();
|
|
360
|
-
const nextValue = isReducer(newValue) ? newValue(currentValue) : newValue;
|
|
361
|
-
if (!Object.is(currentValue, nextValue)) {
|
|
362
|
-
pointer.set(nextValue);
|
|
363
|
-
handleChange();
|
|
364
|
-
}
|
|
365
|
-
});
|
|
366
|
-
if (pointer.initialized) {
|
|
367
|
-
return [pointer.get(), setState];
|
|
368
|
-
}
|
|
369
|
-
const value = isFactory(defaultValue) ? defaultValue() : defaultValue;
|
|
370
|
-
pointer.set(value);
|
|
371
|
-
return [value, setState];
|
|
372
|
-
});
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
// node_modules/@inquirer/core/dist/lib/use-effect.js
|
|
376
|
-
function useEffect(cb, depArray) {
|
|
377
|
-
withPointer((pointer) => {
|
|
378
|
-
const oldDeps = pointer.get();
|
|
379
|
-
const hasChanged = !Array.isArray(oldDeps) || depArray.some((dep, i) => !Object.is(dep, oldDeps[i]));
|
|
380
|
-
if (hasChanged) {
|
|
381
|
-
effectScheduler.queue(cb);
|
|
382
|
-
}
|
|
383
|
-
pointer.set(depArray);
|
|
384
|
-
});
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
// node_modules/@inquirer/core/dist/lib/theme.js
|
|
388
|
-
import { styleText } from "node:util";
|
|
389
|
-
|
|
390
|
-
// node_modules/@inquirer/figures/dist/index.js
|
|
391
|
-
import process2 from "node:process";
|
|
392
|
-
function isUnicodeSupported() {
|
|
393
|
-
if (!process2.platform.startsWith("win")) {
|
|
394
|
-
return process2.env["TERM"] !== "linux";
|
|
395
|
-
}
|
|
396
|
-
return Boolean(process2.env["CI"]) || Boolean(process2.env["WT_SESSION"]) || Boolean(process2.env["TERMINUS_SUBLIME"]) || process2.env["ConEmuTask"] === "{cmd::Cmder}" || process2.env["TERM_PROGRAM"] === "Terminus-Sublime" || process2.env["TERM_PROGRAM"] === "vscode" || process2.env["TERM"] === "xterm-256color" || process2.env["TERM"] === "alacritty" || process2.env["TERMINAL_EMULATOR"] === "JetBrains-JediTerm";
|
|
397
|
-
}
|
|
398
|
-
var common = {
|
|
399
|
-
circleQuestionMark: "(?)",
|
|
400
|
-
questionMarkPrefix: "(?)",
|
|
401
|
-
square: "█",
|
|
402
|
-
squareDarkShade: "▓",
|
|
403
|
-
squareMediumShade: "▒",
|
|
404
|
-
squareLightShade: "░",
|
|
405
|
-
squareTop: "▀",
|
|
406
|
-
squareBottom: "▄",
|
|
407
|
-
squareLeft: "▌",
|
|
408
|
-
squareRight: "▐",
|
|
409
|
-
squareCenter: "■",
|
|
410
|
-
bullet: "●",
|
|
411
|
-
dot: "․",
|
|
412
|
-
ellipsis: "…",
|
|
413
|
-
pointerSmall: "›",
|
|
414
|
-
triangleUp: "▲",
|
|
415
|
-
triangleUpSmall: "▴",
|
|
416
|
-
triangleDown: "▼",
|
|
417
|
-
triangleDownSmall: "▾",
|
|
418
|
-
triangleLeftSmall: "◂",
|
|
419
|
-
triangleRightSmall: "▸",
|
|
420
|
-
home: "⌂",
|
|
421
|
-
heart: "♥",
|
|
422
|
-
musicNote: "♪",
|
|
423
|
-
musicNoteBeamed: "♫",
|
|
424
|
-
arrowUp: "↑",
|
|
425
|
-
arrowDown: "↓",
|
|
426
|
-
arrowLeft: "←",
|
|
427
|
-
arrowRight: "→",
|
|
428
|
-
arrowLeftRight: "↔",
|
|
429
|
-
arrowUpDown: "↕",
|
|
430
|
-
almostEqual: "≈",
|
|
431
|
-
notEqual: "≠",
|
|
432
|
-
lessOrEqual: "≤",
|
|
433
|
-
greaterOrEqual: "≥",
|
|
434
|
-
identical: "≡",
|
|
435
|
-
infinity: "∞",
|
|
436
|
-
subscriptZero: "₀",
|
|
437
|
-
subscriptOne: "₁",
|
|
438
|
-
subscriptTwo: "₂",
|
|
439
|
-
subscriptThree: "₃",
|
|
440
|
-
subscriptFour: "₄",
|
|
441
|
-
subscriptFive: "₅",
|
|
442
|
-
subscriptSix: "₆",
|
|
443
|
-
subscriptSeven: "₇",
|
|
444
|
-
subscriptEight: "₈",
|
|
445
|
-
subscriptNine: "₉",
|
|
446
|
-
oneHalf: "½",
|
|
447
|
-
oneThird: "⅓",
|
|
448
|
-
oneQuarter: "¼",
|
|
449
|
-
oneFifth: "⅕",
|
|
450
|
-
oneSixth: "⅙",
|
|
451
|
-
oneEighth: "⅛",
|
|
452
|
-
twoThirds: "⅔",
|
|
453
|
-
twoFifths: "⅖",
|
|
454
|
-
threeQuarters: "¾",
|
|
455
|
-
threeFifths: "⅗",
|
|
456
|
-
threeEighths: "⅜",
|
|
457
|
-
fourFifths: "⅘",
|
|
458
|
-
fiveSixths: "⅚",
|
|
459
|
-
fiveEighths: "⅝",
|
|
460
|
-
sevenEighths: "⅞",
|
|
461
|
-
line: "─",
|
|
462
|
-
lineBold: "━",
|
|
463
|
-
lineDouble: "═",
|
|
464
|
-
lineDashed0: "┄",
|
|
465
|
-
lineDashed1: "┅",
|
|
466
|
-
lineDashed2: "┈",
|
|
467
|
-
lineDashed3: "┉",
|
|
468
|
-
lineDashed4: "╌",
|
|
469
|
-
lineDashed5: "╍",
|
|
470
|
-
lineDashed6: "╴",
|
|
471
|
-
lineDashed7: "╶",
|
|
472
|
-
lineDashed8: "╸",
|
|
473
|
-
lineDashed9: "╺",
|
|
474
|
-
lineDashed10: "╼",
|
|
475
|
-
lineDashed11: "╾",
|
|
476
|
-
lineDashed12: "−",
|
|
477
|
-
lineDashed13: "–",
|
|
478
|
-
lineDashed14: "‐",
|
|
479
|
-
lineDashed15: "⁃",
|
|
480
|
-
lineVertical: "│",
|
|
481
|
-
lineVerticalBold: "┃",
|
|
482
|
-
lineVerticalDouble: "║",
|
|
483
|
-
lineVerticalDashed0: "┆",
|
|
484
|
-
lineVerticalDashed1: "┇",
|
|
485
|
-
lineVerticalDashed2: "┊",
|
|
486
|
-
lineVerticalDashed3: "┋",
|
|
487
|
-
lineVerticalDashed4: "╎",
|
|
488
|
-
lineVerticalDashed5: "╏",
|
|
489
|
-
lineVerticalDashed6: "╵",
|
|
490
|
-
lineVerticalDashed7: "╷",
|
|
491
|
-
lineVerticalDashed8: "╹",
|
|
492
|
-
lineVerticalDashed9: "╻",
|
|
493
|
-
lineVerticalDashed10: "╽",
|
|
494
|
-
lineVerticalDashed11: "╿",
|
|
495
|
-
lineDownLeft: "┐",
|
|
496
|
-
lineDownLeftArc: "╮",
|
|
497
|
-
lineDownBoldLeftBold: "┓",
|
|
498
|
-
lineDownBoldLeft: "┒",
|
|
499
|
-
lineDownLeftBold: "┑",
|
|
500
|
-
lineDownDoubleLeftDouble: "╗",
|
|
501
|
-
lineDownDoubleLeft: "╖",
|
|
502
|
-
lineDownLeftDouble: "╕",
|
|
503
|
-
lineDownRight: "┌",
|
|
504
|
-
lineDownRightArc: "╭",
|
|
505
|
-
lineDownBoldRightBold: "┏",
|
|
506
|
-
lineDownBoldRight: "┎",
|
|
507
|
-
lineDownRightBold: "┍",
|
|
508
|
-
lineDownDoubleRightDouble: "╔",
|
|
509
|
-
lineDownDoubleRight: "╓",
|
|
510
|
-
lineDownRightDouble: "╒",
|
|
511
|
-
lineUpLeft: "┘",
|
|
512
|
-
lineUpLeftArc: "╯",
|
|
513
|
-
lineUpBoldLeftBold: "┛",
|
|
514
|
-
lineUpBoldLeft: "┚",
|
|
515
|
-
lineUpLeftBold: "┙",
|
|
516
|
-
lineUpDoubleLeftDouble: "╝",
|
|
517
|
-
lineUpDoubleLeft: "╜",
|
|
518
|
-
lineUpLeftDouble: "╛",
|
|
519
|
-
lineUpRight: "└",
|
|
520
|
-
lineUpRightArc: "╰",
|
|
521
|
-
lineUpBoldRightBold: "┗",
|
|
522
|
-
lineUpBoldRight: "┖",
|
|
523
|
-
lineUpRightBold: "┕",
|
|
524
|
-
lineUpDoubleRightDouble: "╚",
|
|
525
|
-
lineUpDoubleRight: "╙",
|
|
526
|
-
lineUpRightDouble: "╘",
|
|
527
|
-
lineUpDownLeft: "┤",
|
|
528
|
-
lineUpBoldDownBoldLeftBold: "┫",
|
|
529
|
-
lineUpBoldDownBoldLeft: "┨",
|
|
530
|
-
lineUpDownLeftBold: "┥",
|
|
531
|
-
lineUpBoldDownLeftBold: "┩",
|
|
532
|
-
lineUpDownBoldLeftBold: "┪",
|
|
533
|
-
lineUpDownBoldLeft: "┧",
|
|
534
|
-
lineUpBoldDownLeft: "┦",
|
|
535
|
-
lineUpDoubleDownDoubleLeftDouble: "╣",
|
|
536
|
-
lineUpDoubleDownDoubleLeft: "╢",
|
|
537
|
-
lineUpDownLeftDouble: "╡",
|
|
538
|
-
lineUpDownRight: "├",
|
|
539
|
-
lineUpBoldDownBoldRightBold: "┣",
|
|
540
|
-
lineUpBoldDownBoldRight: "┠",
|
|
541
|
-
lineUpDownRightBold: "┝",
|
|
542
|
-
lineUpBoldDownRightBold: "┡",
|
|
543
|
-
lineUpDownBoldRightBold: "┢",
|
|
544
|
-
lineUpDownBoldRight: "┟",
|
|
545
|
-
lineUpBoldDownRight: "┞",
|
|
546
|
-
lineUpDoubleDownDoubleRightDouble: "╠",
|
|
547
|
-
lineUpDoubleDownDoubleRight: "╟",
|
|
548
|
-
lineUpDownRightDouble: "╞",
|
|
549
|
-
lineDownLeftRight: "┬",
|
|
550
|
-
lineDownBoldLeftBoldRightBold: "┳",
|
|
551
|
-
lineDownLeftBoldRightBold: "┯",
|
|
552
|
-
lineDownBoldLeftRight: "┰",
|
|
553
|
-
lineDownBoldLeftBoldRight: "┱",
|
|
554
|
-
lineDownBoldLeftRightBold: "┲",
|
|
555
|
-
lineDownLeftRightBold: "┮",
|
|
556
|
-
lineDownLeftBoldRight: "┭",
|
|
557
|
-
lineDownDoubleLeftDoubleRightDouble: "╦",
|
|
558
|
-
lineDownDoubleLeftRight: "╥",
|
|
559
|
-
lineDownLeftDoubleRightDouble: "╤",
|
|
560
|
-
lineUpLeftRight: "┴",
|
|
561
|
-
lineUpBoldLeftBoldRightBold: "┻",
|
|
562
|
-
lineUpLeftBoldRightBold: "┷",
|
|
563
|
-
lineUpBoldLeftRight: "┸",
|
|
564
|
-
lineUpBoldLeftBoldRight: "┹",
|
|
565
|
-
lineUpBoldLeftRightBold: "┺",
|
|
566
|
-
lineUpLeftRightBold: "┶",
|
|
567
|
-
lineUpLeftBoldRight: "┵",
|
|
568
|
-
lineUpDoubleLeftDoubleRightDouble: "╩",
|
|
569
|
-
lineUpDoubleLeftRight: "╨",
|
|
570
|
-
lineUpLeftDoubleRightDouble: "╧",
|
|
571
|
-
lineUpDownLeftRight: "┼",
|
|
572
|
-
lineUpBoldDownBoldLeftBoldRightBold: "╋",
|
|
573
|
-
lineUpDownBoldLeftBoldRightBold: "╈",
|
|
574
|
-
lineUpBoldDownLeftBoldRightBold: "╇",
|
|
575
|
-
lineUpBoldDownBoldLeftRightBold: "╊",
|
|
576
|
-
lineUpBoldDownBoldLeftBoldRight: "╉",
|
|
577
|
-
lineUpBoldDownLeftRight: "╀",
|
|
578
|
-
lineUpDownBoldLeftRight: "╁",
|
|
579
|
-
lineUpDownLeftBoldRight: "┽",
|
|
580
|
-
lineUpDownLeftRightBold: "┾",
|
|
581
|
-
lineUpBoldDownBoldLeftRight: "╂",
|
|
582
|
-
lineUpDownLeftBoldRightBold: "┿",
|
|
583
|
-
lineUpBoldDownLeftBoldRight: "╃",
|
|
584
|
-
lineUpBoldDownLeftRightBold: "╄",
|
|
585
|
-
lineUpDownBoldLeftBoldRight: "╅",
|
|
586
|
-
lineUpDownBoldLeftRightBold: "╆",
|
|
587
|
-
lineUpDoubleDownDoubleLeftDoubleRightDouble: "╬",
|
|
588
|
-
lineUpDoubleDownDoubleLeftRight: "╫",
|
|
589
|
-
lineUpDownLeftDoubleRightDouble: "╪",
|
|
590
|
-
lineCross: "╳",
|
|
591
|
-
lineBackslash: "╲",
|
|
592
|
-
lineSlash: "╱"
|
|
593
|
-
};
|
|
594
|
-
var specialMainSymbols = {
|
|
595
|
-
tick: "✔",
|
|
596
|
-
info: "ℹ",
|
|
597
|
-
warning: "⚠",
|
|
598
|
-
cross: "✘",
|
|
599
|
-
squareSmall: "◻",
|
|
600
|
-
squareSmallFilled: "◼",
|
|
601
|
-
circle: "◯",
|
|
602
|
-
circleFilled: "◉",
|
|
603
|
-
circleDotted: "◌",
|
|
604
|
-
circleDouble: "◎",
|
|
605
|
-
circleCircle: "ⓞ",
|
|
606
|
-
circleCross: "ⓧ",
|
|
607
|
-
circlePipe: "Ⓘ",
|
|
608
|
-
radioOn: "◉",
|
|
609
|
-
radioOff: "◯",
|
|
610
|
-
checkboxOn: "☒",
|
|
611
|
-
checkboxOff: "☐",
|
|
612
|
-
checkboxCircleOn: "ⓧ",
|
|
613
|
-
checkboxCircleOff: "Ⓘ",
|
|
614
|
-
pointer: "❯",
|
|
615
|
-
triangleUpOutline: "△",
|
|
616
|
-
triangleLeft: "◀",
|
|
617
|
-
triangleRight: "▶",
|
|
618
|
-
lozenge: "◆",
|
|
619
|
-
lozengeOutline: "◇",
|
|
620
|
-
hamburger: "☰",
|
|
621
|
-
smiley: "㋡",
|
|
622
|
-
mustache: "෴",
|
|
623
|
-
star: "★",
|
|
624
|
-
play: "▶",
|
|
625
|
-
nodejs: "⬢",
|
|
626
|
-
oneSeventh: "⅐",
|
|
627
|
-
oneNinth: "⅑",
|
|
628
|
-
oneTenth: "⅒"
|
|
629
|
-
};
|
|
630
|
-
var specialFallbackSymbols = {
|
|
631
|
-
tick: "√",
|
|
632
|
-
info: "i",
|
|
633
|
-
warning: "‼",
|
|
634
|
-
cross: "×",
|
|
635
|
-
squareSmall: "□",
|
|
636
|
-
squareSmallFilled: "■",
|
|
637
|
-
circle: "( )",
|
|
638
|
-
circleFilled: "(*)",
|
|
639
|
-
circleDotted: "( )",
|
|
640
|
-
circleDouble: "( )",
|
|
641
|
-
circleCircle: "(○)",
|
|
642
|
-
circleCross: "(×)",
|
|
643
|
-
circlePipe: "(│)",
|
|
644
|
-
radioOn: "(*)",
|
|
645
|
-
radioOff: "( )",
|
|
646
|
-
checkboxOn: "[×]",
|
|
647
|
-
checkboxOff: "[ ]",
|
|
648
|
-
checkboxCircleOn: "(×)",
|
|
649
|
-
checkboxCircleOff: "( )",
|
|
650
|
-
pointer: ">",
|
|
651
|
-
triangleUpOutline: "∆",
|
|
652
|
-
triangleLeft: "◄",
|
|
653
|
-
triangleRight: "►",
|
|
654
|
-
lozenge: "♦",
|
|
655
|
-
lozengeOutline: "◊",
|
|
656
|
-
hamburger: "≡",
|
|
657
|
-
smiley: "☺",
|
|
658
|
-
mustache: "┌─┐",
|
|
659
|
-
star: "✶",
|
|
660
|
-
play: "►",
|
|
661
|
-
nodejs: "♦",
|
|
662
|
-
oneSeventh: "1/7",
|
|
663
|
-
oneNinth: "1/9",
|
|
664
|
-
oneTenth: "1/10"
|
|
665
|
-
};
|
|
666
|
-
var mainSymbols = {
|
|
667
|
-
...common,
|
|
668
|
-
...specialMainSymbols
|
|
669
|
-
};
|
|
670
|
-
var fallbackSymbols = {
|
|
671
|
-
...common,
|
|
672
|
-
...specialFallbackSymbols
|
|
673
|
-
};
|
|
674
|
-
var shouldUseMain = isUnicodeSupported();
|
|
675
|
-
var figures = shouldUseMain ? mainSymbols : fallbackSymbols;
|
|
676
|
-
var dist_default = figures;
|
|
677
|
-
var replacements = Object.entries(specialMainSymbols);
|
|
678
|
-
|
|
679
|
-
// node_modules/@inquirer/core/dist/lib/theme.js
|
|
680
|
-
var defaultTheme = {
|
|
681
|
-
prefix: {
|
|
682
|
-
idle: styleText("blue", "?"),
|
|
683
|
-
done: styleText("green", dist_default.tick)
|
|
684
|
-
},
|
|
685
|
-
spinner: {
|
|
686
|
-
interval: 80,
|
|
687
|
-
frames: ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"].map((frame) => styleText("yellow", frame))
|
|
688
|
-
},
|
|
689
|
-
keybindings: [],
|
|
690
|
-
style: {
|
|
691
|
-
answer: (text) => styleText("cyan", text),
|
|
692
|
-
message: (text) => styleText("bold", text),
|
|
693
|
-
error: (text) => styleText("red", `> ${text}`),
|
|
694
|
-
defaultAnswer: (text) => styleText("dim", `(${text})`),
|
|
695
|
-
help: (text) => styleText("dim", text),
|
|
696
|
-
highlight: (text) => styleText("cyan", text),
|
|
697
|
-
key: (text) => styleText("cyan", styleText("bold", `<${text}>`))
|
|
698
|
-
}
|
|
699
|
-
};
|
|
700
|
-
function getDefaultTheme() {
|
|
701
|
-
return {
|
|
702
|
-
...defaultTheme,
|
|
703
|
-
keybindings: getDefaultKeybindings()
|
|
71
|
+
var scroll = {
|
|
72
|
+
up: (count = 1) => `${CSI2}S`.repeat(count),
|
|
73
|
+
down: (count = 1) => `${CSI2}T`.repeat(count)
|
|
704
74
|
};
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
for (const obj of objects) {
|
|
720
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
721
|
-
const prevValue = output[key];
|
|
722
|
-
output[key] = isPlainObject(prevValue) && isPlainObject(value) ? deepMerge(prevValue, value) : value;
|
|
723
|
-
}
|
|
724
|
-
}
|
|
725
|
-
return output;
|
|
726
|
-
}
|
|
727
|
-
function makeTheme(...themes) {
|
|
728
|
-
const themesToMerge = [
|
|
729
|
-
getDefaultTheme(),
|
|
730
|
-
...themes.filter((theme) => theme != null)
|
|
731
|
-
];
|
|
732
|
-
return deepMerge(...themesToMerge);
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
// node_modules/@inquirer/core/dist/lib/use-prefix.js
|
|
736
|
-
function usePrefix({ status = "idle", theme }) {
|
|
737
|
-
const [showLoader, setShowLoader] = useState(false);
|
|
738
|
-
const [tick, setTick] = useState(0);
|
|
739
|
-
const { prefix, spinner } = makeTheme(theme);
|
|
740
|
-
useEffect(() => {
|
|
741
|
-
if (status === "loading") {
|
|
742
|
-
let tickInterval;
|
|
743
|
-
let inc = -1;
|
|
744
|
-
const delayTimeout = setTimeout(() => {
|
|
745
|
-
setShowLoader(true);
|
|
746
|
-
tickInterval = setInterval(() => {
|
|
747
|
-
inc = inc + 1;
|
|
748
|
-
setTick(inc % spinner.frames.length);
|
|
749
|
-
}, spinner.interval);
|
|
750
|
-
}, 300);
|
|
751
|
-
return () => {
|
|
752
|
-
clearTimeout(delayTimeout);
|
|
753
|
-
clearInterval(tickInterval);
|
|
754
|
-
};
|
|
755
|
-
} else {
|
|
756
|
-
setShowLoader(false);
|
|
75
|
+
var erase = {
|
|
76
|
+
screen: `${CSI2}2J`,
|
|
77
|
+
up: (count = 1) => `${CSI2}1J`.repeat(count),
|
|
78
|
+
down: (count = 1) => `${CSI2}J`.repeat(count),
|
|
79
|
+
line: `${CSI2}2K`,
|
|
80
|
+
lineEnd: `${CSI2}K`,
|
|
81
|
+
lineStart: `${CSI2}1K`,
|
|
82
|
+
lines(count) {
|
|
83
|
+
let clear = "";
|
|
84
|
+
for (let i = 0;i < count; i++)
|
|
85
|
+
clear += this.line + (i < count - 1 ? cursor.up() : "");
|
|
86
|
+
if (count)
|
|
87
|
+
clear += cursor.left;
|
|
88
|
+
return clear;
|
|
757
89
|
}
|
|
758
|
-
}
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
}
|
|
762
|
-
const iconName = status === "loading" ? "idle" : status;
|
|
763
|
-
return typeof prefix === "string" ? prefix : prefix[iconName] ?? prefix["idle"];
|
|
764
|
-
}
|
|
765
|
-
// node_modules/@inquirer/core/dist/lib/use-memo.js
|
|
766
|
-
function useMemo(fn, dependencies) {
|
|
767
|
-
return withPointer((pointer) => {
|
|
768
|
-
const prev = pointer.get();
|
|
769
|
-
if (!pointer.initialized || prev.dependencies.length !== dependencies.length || prev.dependencies.some((dep, i) => dep !== dependencies[i])) {
|
|
770
|
-
const value = fn();
|
|
771
|
-
pointer.set({ value, dependencies });
|
|
772
|
-
return value;
|
|
773
|
-
}
|
|
774
|
-
return prev.value;
|
|
775
|
-
});
|
|
776
|
-
}
|
|
777
|
-
// node_modules/@inquirer/core/dist/lib/use-ref.js
|
|
778
|
-
function useRef(val) {
|
|
779
|
-
return useState({ current: val })[0];
|
|
780
|
-
}
|
|
90
|
+
};
|
|
91
|
+
module.exports = { cursor, scroll, erase, beep };
|
|
92
|
+
});
|
|
781
93
|
|
|
782
|
-
// node_modules/@
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
useEffect((rl) => {
|
|
787
|
-
let ignore = false;
|
|
788
|
-
const handler = withUpdates((_input, event) => {
|
|
789
|
-
if (ignore)
|
|
790
|
-
return;
|
|
791
|
-
signal.current(event, rl);
|
|
792
|
-
});
|
|
793
|
-
rl.input.on("keypress", handler);
|
|
794
|
-
return () => {
|
|
795
|
-
ignore = true;
|
|
796
|
-
rl.input.removeListener("keypress", handler);
|
|
797
|
-
};
|
|
798
|
-
}, []);
|
|
799
|
-
}
|
|
800
|
-
// node_modules/@inquirer/core/dist/lib/utils.js
|
|
801
|
-
var import_cli_width = __toESM(require_cli_width(), 1);
|
|
94
|
+
// node_modules/@clack/core/dist/index.mjs
|
|
95
|
+
import { stdout, stdin } from "node:process";
|
|
96
|
+
import * as l from "node:readline";
|
|
97
|
+
import l__default from "node:readline";
|
|
802
98
|
|
|
803
99
|
// node_modules/fast-string-truncated-width/dist/utils.js
|
|
804
100
|
var getCodePointsLength = (() => {
|
|
@@ -916,7 +212,7 @@ var getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {})
|
|
|
916
212
|
ellipsed: truncationEnabled && LIMIT >= ELLIPSIS_WIDTH
|
|
917
213
|
};
|
|
918
214
|
};
|
|
919
|
-
var
|
|
215
|
+
var dist_default = getStringTruncatedWidth;
|
|
920
216
|
|
|
921
217
|
// node_modules/fast-string-width/dist/index.js
|
|
922
218
|
var NO_TRUNCATION2 = {
|
|
@@ -925,9 +221,9 @@ var NO_TRUNCATION2 = {
|
|
|
925
221
|
ellipsisWidth: 0
|
|
926
222
|
};
|
|
927
223
|
var fastStringWidth = (input, options = {}) => {
|
|
928
|
-
return
|
|
224
|
+
return dist_default(input, NO_TRUNCATION2, options).width;
|
|
929
225
|
};
|
|
930
|
-
var
|
|
226
|
+
var dist_default2 = fastStringWidth;
|
|
931
227
|
|
|
932
228
|
// node_modules/fast-wrap-ansi/lib/main.js
|
|
933
229
|
var ESC = "\x1B";
|
|
@@ -971,13 +267,13 @@ var wrapWord = (rows, word, columns) => {
|
|
|
971
267
|
let isInsideEscape = false;
|
|
972
268
|
let isInsideLinkEscape = false;
|
|
973
269
|
let lastRow = rows.at(-1);
|
|
974
|
-
let visible = lastRow === undefined ? 0 :
|
|
270
|
+
let visible = lastRow === undefined ? 0 : dist_default2(lastRow);
|
|
975
271
|
let currentCharacter = characters.next();
|
|
976
272
|
let nextCharacter = characters.next();
|
|
977
273
|
let rawCharacterIndex = 0;
|
|
978
274
|
while (!currentCharacter.done) {
|
|
979
275
|
const character = currentCharacter.value;
|
|
980
|
-
const characterLength =
|
|
276
|
+
const characterLength = dist_default2(character);
|
|
981
277
|
if (visible + characterLength <= columns) {
|
|
982
278
|
rows[rows.length - 1] += character;
|
|
983
279
|
} else {
|
|
@@ -1017,7 +313,7 @@ var stringVisibleTrimSpacesRight = (string) => {
|
|
|
1017
313
|
const words = string.split(" ");
|
|
1018
314
|
let last = words.length;
|
|
1019
315
|
while (last) {
|
|
1020
|
-
if (
|
|
316
|
+
if (dist_default2(words[last - 1])) {
|
|
1021
317
|
break;
|
|
1022
318
|
}
|
|
1023
319
|
last--;
|
|
@@ -1044,7 +340,7 @@ var exec = (string, columns, options = {}) => {
|
|
|
1044
340
|
const trimmed = row.trimStart();
|
|
1045
341
|
if (row.length !== trimmed.length) {
|
|
1046
342
|
rows[rows.length - 1] = trimmed;
|
|
1047
|
-
rowLength =
|
|
343
|
+
rowLength = dist_default2(trimmed);
|
|
1048
344
|
}
|
|
1049
345
|
}
|
|
1050
346
|
if (index !== 0) {
|
|
@@ -1057,7 +353,7 @@ var exec = (string, columns, options = {}) => {
|
|
|
1057
353
|
rowLength++;
|
|
1058
354
|
}
|
|
1059
355
|
}
|
|
1060
|
-
const wordLength =
|
|
356
|
+
const wordLength = dist_default2(word);
|
|
1061
357
|
if (options.hard && wordLength > columns) {
|
|
1062
358
|
const remainingColumns = columns - rowLength;
|
|
1063
359
|
const breaksStartingThisLine = 1 + Math.floor((wordLength - remainingColumns - 1) / columns);
|
|
@@ -1066,13 +362,13 @@ var exec = (string, columns, options = {}) => {
|
|
|
1066
362
|
rows.push("");
|
|
1067
363
|
}
|
|
1068
364
|
wrapWord(rows, word, columns);
|
|
1069
|
-
rowLength =
|
|
365
|
+
rowLength = dist_default2(rows.at(-1) ?? "");
|
|
1070
366
|
continue;
|
|
1071
367
|
}
|
|
1072
368
|
if (rowLength + wordLength > columns && rowLength && wordLength) {
|
|
1073
369
|
if (options.wordWrap === false && rowLength < columns) {
|
|
1074
370
|
wrapWord(rows, word, columns);
|
|
1075
|
-
rowLength =
|
|
371
|
+
rowLength = dist_default2(rows.at(-1) ?? "");
|
|
1076
372
|
continue;
|
|
1077
373
|
}
|
|
1078
374
|
rows.push("");
|
|
@@ -1080,7 +376,7 @@ var exec = (string, columns, options = {}) => {
|
|
|
1080
376
|
}
|
|
1081
377
|
if (rowLength + wordLength > columns && options.wordWrap === false) {
|
|
1082
378
|
wrapWord(rows, word, columns);
|
|
1083
|
-
rowLength =
|
|
379
|
+
rowLength = dist_default2(rows.at(-1) ?? "");
|
|
1084
380
|
continue;
|
|
1085
381
|
}
|
|
1086
382
|
rows[rows.length - 1] += word;
|
|
@@ -1141,709 +437,676 @@ function wrapAnsi(string, columns, options) {
|
|
|
1141
437
|
`);
|
|
1142
438
|
}
|
|
1143
439
|
|
|
1144
|
-
// node_modules/@
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
440
|
+
// node_modules/@clack/core/dist/index.mjs
|
|
441
|
+
var import_sisteransi = __toESM(require_src(), 1);
|
|
442
|
+
import { ReadStream } from "node:tty";
|
|
443
|
+
function findCursor(s, o, l2) {
|
|
444
|
+
if (!l2.some((r) => !r.disabled))
|
|
445
|
+
return s;
|
|
446
|
+
const t = s + o, n = Math.max(l2.length - 1, 0), e = t < 0 ? n : t > n ? 0 : t;
|
|
447
|
+
return l2[e]?.disabled ? findCursor(e, o < 0 ? -1 : 1, l2) : e;
|
|
448
|
+
}
|
|
449
|
+
var a$1 = ["up", "down", "left", "right", "space", "enter", "cancel"];
|
|
450
|
+
var t = [
|
|
451
|
+
"January",
|
|
452
|
+
"February",
|
|
453
|
+
"March",
|
|
454
|
+
"April",
|
|
455
|
+
"May",
|
|
456
|
+
"June",
|
|
457
|
+
"July",
|
|
458
|
+
"August",
|
|
459
|
+
"September",
|
|
460
|
+
"October",
|
|
461
|
+
"November",
|
|
462
|
+
"December"
|
|
463
|
+
];
|
|
464
|
+
var settings = {
|
|
465
|
+
actions: new Set(a$1),
|
|
466
|
+
aliases: /* @__PURE__ */ new Map([
|
|
467
|
+
["k", "up"],
|
|
468
|
+
["j", "down"],
|
|
469
|
+
["h", "left"],
|
|
470
|
+
["l", "right"],
|
|
471
|
+
["\x03", "cancel"],
|
|
472
|
+
["escape", "cancel"]
|
|
473
|
+
]),
|
|
474
|
+
messages: {
|
|
475
|
+
cancel: "Canceled",
|
|
476
|
+
error: "Something went wrong"
|
|
477
|
+
},
|
|
478
|
+
withGuide: true,
|
|
479
|
+
date: {
|
|
480
|
+
monthNames: [...t],
|
|
481
|
+
messages: {
|
|
482
|
+
required: "Please enter a valid date",
|
|
483
|
+
invalidMonth: "There are only 12 months in a year",
|
|
484
|
+
invalidDay: (n, e) => `There are only ${n} days in ${e}`,
|
|
485
|
+
afterMin: (n) => `Date must be on or after ${n.toISOString().slice(0, 10)}`,
|
|
486
|
+
beforeMax: (n) => `Date must be on or before ${n.toISOString().slice(0, 10)}`
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
};
|
|
490
|
+
function isActionKey(n, e) {
|
|
491
|
+
if (typeof n == "string")
|
|
492
|
+
return settings.aliases.get(n) === e;
|
|
493
|
+
for (const s of n)
|
|
494
|
+
if (s !== undefined && isActionKey(s, e))
|
|
495
|
+
return true;
|
|
496
|
+
return false;
|
|
1150
497
|
}
|
|
1151
|
-
function
|
|
1152
|
-
|
|
498
|
+
function diffLines(i, s) {
|
|
499
|
+
if (i === s)
|
|
500
|
+
return;
|
|
501
|
+
const e = i.split(`
|
|
502
|
+
`), t2 = s.split(`
|
|
503
|
+
`), r = Math.max(e.length, t2.length), f = [];
|
|
504
|
+
for (let n = 0;n < r; n++)
|
|
505
|
+
e[n] !== t2[n] && f.push(n);
|
|
506
|
+
return {
|
|
507
|
+
lines: f,
|
|
508
|
+
numLinesBefore: e.length,
|
|
509
|
+
numLinesAfter: t2.length,
|
|
510
|
+
numLines: r
|
|
511
|
+
};
|
|
1153
512
|
}
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
function
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
513
|
+
var R = globalThis.process.platform.startsWith("win");
|
|
514
|
+
var CANCEL_SYMBOL = Symbol("clack:cancel");
|
|
515
|
+
function isCancel(e) {
|
|
516
|
+
return e === CANCEL_SYMBOL;
|
|
517
|
+
}
|
|
518
|
+
function setRawMode(e, r) {
|
|
519
|
+
const o = e;
|
|
520
|
+
o.isTTY && o.setRawMode(r);
|
|
521
|
+
}
|
|
522
|
+
function block({
|
|
523
|
+
input: e = stdin,
|
|
524
|
+
output: r = stdout,
|
|
525
|
+
overwrite: o = true,
|
|
526
|
+
hideCursor: t2 = true
|
|
527
|
+
} = {}) {
|
|
528
|
+
const s = l.createInterface({
|
|
529
|
+
input: e,
|
|
530
|
+
output: r,
|
|
531
|
+
prompt: "",
|
|
532
|
+
tabSize: 1
|
|
1160
533
|
});
|
|
1161
|
-
|
|
1162
|
-
const
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
if (loop) {
|
|
1168
|
-
pointer = lastPointer;
|
|
1169
|
-
if (lastActive != null && lastActive < active && active - lastActive < pageSize) {
|
|
1170
|
-
pointer = Math.min(middle, Math.abs(active - lastActive) === 1 ? Math.min(lastPointer + (renderedItems[lastActive]?.length ?? 0), Math.max(defaultPointerPosition, lastPointer)) : lastPointer + active - lastActive);
|
|
1171
|
-
}
|
|
1172
|
-
} else {
|
|
1173
|
-
const spaceUnderActive = renderedItems.slice(active).reduce((acc, item) => acc + item.length, 0);
|
|
1174
|
-
pointer = spaceUnderActive < pageSize - middle ? pageSize - spaceUnderActive : Math.min(defaultPointerPosition, middle);
|
|
534
|
+
l.emitKeypressEvents(e, s), e instanceof ReadStream && e.isTTY && e.setRawMode(true);
|
|
535
|
+
const n = (f, { name: a, sequence: p }) => {
|
|
536
|
+
const c = String(f);
|
|
537
|
+
if (isActionKey([c, a, p], "cancel")) {
|
|
538
|
+
t2 && r.write(import_sisteransi.cursor.show), process.exit(0);
|
|
539
|
+
return;
|
|
1175
540
|
}
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
541
|
+
if (!o)
|
|
542
|
+
return;
|
|
543
|
+
const i = a === "return" ? 0 : -1, m = a === "return" ? -1 : 0;
|
|
544
|
+
l.moveCursor(r, i, m, () => {
|
|
545
|
+
l.clearLine(r, 1, () => {
|
|
546
|
+
e.once("keypress", n);
|
|
547
|
+
});
|
|
548
|
+
});
|
|
549
|
+
};
|
|
550
|
+
return t2 && r.write(import_sisteransi.cursor.hide), e.once("keypress", n), () => {
|
|
551
|
+
e.off("keypress", n), t2 && r.write(import_sisteransi.cursor.show), e instanceof ReadStream && e.isTTY && !R && e.setRawMode(false), s.terminal = false, s.close();
|
|
552
|
+
};
|
|
1180
553
|
}
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
const
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
`
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
const activeItem = renderItemAtIndex(active).slice(0, pageSize);
|
|
1194
|
-
const activeItemPosition = pointer + activeItem.length <= pageSize ? pointer : pageSize - activeItem.length;
|
|
1195
|
-
const pageBuffer = Array.from({ length: pageSize });
|
|
1196
|
-
pageBuffer.splice(activeItemPosition, activeItem.length, ...activeItem);
|
|
1197
|
-
const itemVisited = new Set([active]);
|
|
1198
|
-
let bufferPointer = activeItemPosition + activeItem.length;
|
|
1199
|
-
let itemPointer = bound(active + 1);
|
|
1200
|
-
while (bufferPointer < pageSize && !itemVisited.has(itemPointer) && (loop && renderedLength > pageSize ? itemPointer !== active : itemPointer > active)) {
|
|
1201
|
-
const lines = renderItemAtIndex(itemPointer);
|
|
1202
|
-
const linesToAdd = lines.slice(0, pageSize - bufferPointer);
|
|
1203
|
-
pageBuffer.splice(bufferPointer, linesToAdd.length, ...linesToAdd);
|
|
1204
|
-
itemVisited.add(itemPointer);
|
|
1205
|
-
bufferPointer += linesToAdd.length;
|
|
1206
|
-
itemPointer = bound(itemPointer + 1);
|
|
1207
|
-
}
|
|
1208
|
-
bufferPointer = activeItemPosition - 1;
|
|
1209
|
-
itemPointer = bound(active - 1);
|
|
1210
|
-
while (bufferPointer >= 0 && !itemVisited.has(itemPointer) && (loop && renderedLength > pageSize ? itemPointer !== active : itemPointer < active)) {
|
|
1211
|
-
const lines = renderItemAtIndex(itemPointer);
|
|
1212
|
-
const linesToAdd = lines.slice(Math.max(0, lines.length - bufferPointer - 1));
|
|
1213
|
-
pageBuffer.splice(bufferPointer - linesToAdd.length + 1, linesToAdd.length, ...linesToAdd);
|
|
1214
|
-
itemVisited.add(itemPointer);
|
|
1215
|
-
bufferPointer -= linesToAdd.length;
|
|
1216
|
-
itemPointer = bound(itemPointer - 1);
|
|
1217
|
-
}
|
|
1218
|
-
return pageBuffer.filter((line) => typeof line === "string").join(`
|
|
554
|
+
var getColumns = (e) => ("columns" in e) && typeof e.columns == "number" ? e.columns : 80;
|
|
555
|
+
var getRows = (e) => ("rows" in e) && typeof e.rows == "number" ? e.rows : 20;
|
|
556
|
+
function wrapTextWithPrefix(e, r, o, t2 = o, s = o, n) {
|
|
557
|
+
const f = getColumns(e ?? stdout);
|
|
558
|
+
return wrapAnsi(r, f - o.length, {
|
|
559
|
+
hard: true,
|
|
560
|
+
trim: false
|
|
561
|
+
}).split(`
|
|
562
|
+
`).map((c, i, m) => {
|
|
563
|
+
const d = n ? n(c, i) : c;
|
|
564
|
+
return i === 0 ? `${t2}${d}` : i === m.length - 1 ? `${s}${d}` : `${o}${d}`;
|
|
565
|
+
}).join(`
|
|
1219
566
|
`);
|
|
1220
567
|
}
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
if (process.platform !== "win32") {
|
|
1230
|
-
signals.push("SIGALRM", "SIGABRT", "SIGVTALRM", "SIGXCPU", "SIGXFSZ", "SIGUSR2", "SIGTRAP", "SIGSYS", "SIGQUIT", "SIGIOT");
|
|
1231
|
-
}
|
|
1232
|
-
if (process.platform === "linux") {
|
|
1233
|
-
signals.push("SIGIO", "SIGPOLL", "SIGPWR", "SIGSTKFLT");
|
|
568
|
+
function runValidation(e, n) {
|
|
569
|
+
if ("~standard" in e) {
|
|
570
|
+
const a = e["~standard"].validate(n);
|
|
571
|
+
if (a instanceof Promise)
|
|
572
|
+
throw new TypeError("Schema validation must be synchronous. Update `validate()` and remove any asynchronous logic.");
|
|
573
|
+
return a.issues?.at(0)?.message;
|
|
574
|
+
}
|
|
575
|
+
return e(n);
|
|
1234
576
|
}
|
|
1235
577
|
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
if (global[kExitEmitter]) {
|
|
1255
|
-
return global[kExitEmitter];
|
|
1256
|
-
}
|
|
1257
|
-
ObjectDefineProperty(global, kExitEmitter, {
|
|
1258
|
-
value: this,
|
|
1259
|
-
writable: false,
|
|
1260
|
-
enumerable: false,
|
|
1261
|
-
configurable: false
|
|
1262
|
-
});
|
|
578
|
+
class V {
|
|
579
|
+
input;
|
|
580
|
+
output;
|
|
581
|
+
_abortSignal;
|
|
582
|
+
rl;
|
|
583
|
+
opts;
|
|
584
|
+
_render;
|
|
585
|
+
_track = false;
|
|
586
|
+
_prevFrame = "";
|
|
587
|
+
_subscribers = /* @__PURE__ */ new Map;
|
|
588
|
+
_cursor = 0;
|
|
589
|
+
state = "initial";
|
|
590
|
+
error = "";
|
|
591
|
+
value;
|
|
592
|
+
userInput = "";
|
|
593
|
+
constructor(t2, e = true) {
|
|
594
|
+
const { input: i = stdin, output: n = stdout, render: s, signal: r, ...o } = t2;
|
|
595
|
+
this.opts = o, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = s.bind(this), this._track = e, this._abortSignal = r, this.input = i, this.output = n;
|
|
1263
596
|
}
|
|
1264
|
-
|
|
1265
|
-
this.
|
|
597
|
+
unsubscribe() {
|
|
598
|
+
this._subscribers.clear();
|
|
1266
599
|
}
|
|
1267
|
-
|
|
1268
|
-
const
|
|
1269
|
-
|
|
1270
|
-
if (i === -1) {
|
|
1271
|
-
return;
|
|
1272
|
-
}
|
|
1273
|
-
if (i === 0 && list.length === 1) {
|
|
1274
|
-
list.length = 0;
|
|
1275
|
-
} else {
|
|
1276
|
-
list.splice(i, 1);
|
|
1277
|
-
}
|
|
600
|
+
setSubscriber(t2, e) {
|
|
601
|
+
const i = this._subscribers.get(t2) ?? [];
|
|
602
|
+
i.push(e), this._subscribers.set(t2, i);
|
|
1278
603
|
}
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
return false;
|
|
1282
|
-
}
|
|
1283
|
-
this.emitted[ev] = true;
|
|
1284
|
-
let ret = false;
|
|
1285
|
-
for (const fn of this.listeners[ev]) {
|
|
1286
|
-
ret = fn(code, signal) === true || ret;
|
|
1287
|
-
}
|
|
1288
|
-
if (ev === "exit") {
|
|
1289
|
-
ret = this.emit("afterExit", code, signal) || ret;
|
|
1290
|
-
}
|
|
1291
|
-
return ret;
|
|
604
|
+
on(t2, e) {
|
|
605
|
+
this.setSubscriber(t2, { cb: e });
|
|
1292
606
|
}
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
class SignalExitBase {
|
|
1296
|
-
}
|
|
1297
|
-
var signalExitWrap = (handler) => {
|
|
1298
|
-
return {
|
|
1299
|
-
onExit(cb, opts) {
|
|
1300
|
-
return handler.onExit(cb, opts);
|
|
1301
|
-
},
|
|
1302
|
-
load() {
|
|
1303
|
-
return handler.load();
|
|
1304
|
-
},
|
|
1305
|
-
unload() {
|
|
1306
|
-
return handler.unload();
|
|
1307
|
-
}
|
|
1308
|
-
};
|
|
1309
|
-
};
|
|
1310
|
-
|
|
1311
|
-
class SignalExitFallback extends SignalExitBase {
|
|
1312
|
-
onExit() {
|
|
1313
|
-
return () => {};
|
|
607
|
+
once(t2, e) {
|
|
608
|
+
this.setSubscriber(t2, { cb: e, once: true });
|
|
1314
609
|
}
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
#emitter = new Emitter;
|
|
1322
|
-
#process;
|
|
1323
|
-
#originalProcessEmit;
|
|
1324
|
-
#originalProcessReallyExit;
|
|
1325
|
-
#sigListeners = {};
|
|
1326
|
-
#loaded = false;
|
|
1327
|
-
constructor(process3) {
|
|
1328
|
-
super();
|
|
1329
|
-
this.#process = process3;
|
|
1330
|
-
this.#sigListeners = {};
|
|
1331
|
-
for (const sig of signals) {
|
|
1332
|
-
this.#sigListeners[sig] = () => {
|
|
1333
|
-
const listeners = this.#process.listeners(sig);
|
|
1334
|
-
let { count } = this.#emitter;
|
|
1335
|
-
const p = process3;
|
|
1336
|
-
if (typeof p.__signal_exit_emitter__ === "object" && typeof p.__signal_exit_emitter__.count === "number") {
|
|
1337
|
-
count += p.__signal_exit_emitter__.count;
|
|
1338
|
-
}
|
|
1339
|
-
if (listeners.length === count) {
|
|
1340
|
-
this.unload();
|
|
1341
|
-
const ret = this.#emitter.emit("exit", null, sig);
|
|
1342
|
-
const s = sig === "SIGHUP" ? this.#hupSig : sig;
|
|
1343
|
-
if (!ret)
|
|
1344
|
-
process3.kill(process3.pid, s);
|
|
1345
|
-
}
|
|
1346
|
-
};
|
|
1347
|
-
}
|
|
1348
|
-
this.#originalProcessReallyExit = process3.reallyExit;
|
|
1349
|
-
this.#originalProcessEmit = process3.emit;
|
|
610
|
+
emit(t2, ...e) {
|
|
611
|
+
const i = this._subscribers.get(t2) ?? [], n = [];
|
|
612
|
+
for (const s of i)
|
|
613
|
+
s.cb(...e), s.once && n.push(() => i.splice(i.indexOf(s), 1));
|
|
614
|
+
for (const s of n)
|
|
615
|
+
s();
|
|
1350
616
|
}
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
this.#emitter.on(ev, cb);
|
|
1360
|
-
return () => {
|
|
1361
|
-
this.#emitter.removeListener(ev, cb);
|
|
1362
|
-
if (this.#emitter.listeners["exit"].length === 0 && this.#emitter.listeners["afterExit"].length === 0) {
|
|
1363
|
-
this.unload();
|
|
617
|
+
prompt() {
|
|
618
|
+
return new Promise((t2) => {
|
|
619
|
+
if (this._abortSignal) {
|
|
620
|
+
if (this._abortSignal.aborted)
|
|
621
|
+
return this.state = "cancel", this.close(), t2(CANCEL_SYMBOL);
|
|
622
|
+
this._abortSignal.addEventListener("abort", () => {
|
|
623
|
+
this.state = "cancel", this.close();
|
|
624
|
+
}, { once: true });
|
|
1364
625
|
}
|
|
1365
|
-
|
|
626
|
+
this.rl = l__default.createInterface({
|
|
627
|
+
input: this.input,
|
|
628
|
+
tabSize: 2,
|
|
629
|
+
prompt: "",
|
|
630
|
+
escapeCodeTimeout: 50,
|
|
631
|
+
terminal: true
|
|
632
|
+
}), this.rl.prompt(), this.opts.initialUserInput !== undefined && this._setUserInput(this.opts.initialUserInput, true), this.input.on("keypress", this.onKeypress), setRawMode(this.input, true), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
|
|
633
|
+
this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t2(this.value);
|
|
634
|
+
}), this.once("cancel", () => {
|
|
635
|
+
this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t2(CANCEL_SYMBOL);
|
|
636
|
+
});
|
|
637
|
+
});
|
|
1366
638
|
}
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
return;
|
|
1370
|
-
}
|
|
1371
|
-
this.#loaded = true;
|
|
1372
|
-
this.#emitter.count += 1;
|
|
1373
|
-
for (const sig of signals) {
|
|
1374
|
-
try {
|
|
1375
|
-
const fn = this.#sigListeners[sig];
|
|
1376
|
-
if (fn)
|
|
1377
|
-
this.#process.on(sig, fn);
|
|
1378
|
-
} catch (_) {}
|
|
1379
|
-
}
|
|
1380
|
-
this.#process.emit = (ev, ...a) => {
|
|
1381
|
-
return this.#processEmit(ev, ...a);
|
|
1382
|
-
};
|
|
1383
|
-
this.#process.reallyExit = (code) => {
|
|
1384
|
-
return this.#processReallyExit(code);
|
|
1385
|
-
};
|
|
639
|
+
_isActionKey(t2, e) {
|
|
640
|
+
return t2 === "\t";
|
|
1386
641
|
}
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
return;
|
|
1390
|
-
}
|
|
1391
|
-
this.#loaded = false;
|
|
1392
|
-
signals.forEach((sig) => {
|
|
1393
|
-
const listener = this.#sigListeners[sig];
|
|
1394
|
-
if (!listener) {
|
|
1395
|
-
throw new Error("Listener not defined for signal: " + sig);
|
|
1396
|
-
}
|
|
1397
|
-
try {
|
|
1398
|
-
this.#process.removeListener(sig, listener);
|
|
1399
|
-
} catch (_) {}
|
|
1400
|
-
});
|
|
1401
|
-
this.#process.emit = this.#originalProcessEmit;
|
|
1402
|
-
this.#process.reallyExit = this.#originalProcessReallyExit;
|
|
1403
|
-
this.#emitter.count -= 1;
|
|
642
|
+
_shouldSubmit(t2, e) {
|
|
643
|
+
return true;
|
|
1404
644
|
}
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
645
|
+
_setValue(t2) {
|
|
646
|
+
this.value = t2, this.emit("value", this.value);
|
|
647
|
+
}
|
|
648
|
+
_setUserInput(t2, e) {
|
|
649
|
+
this.userInput = t2 ?? "", this.emit("userInput", this.userInput), e && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
|
|
650
|
+
}
|
|
651
|
+
_clearUserInput() {
|
|
652
|
+
this.rl?.write(null, { ctrl: true, name: "u" }), this._setUserInput("");
|
|
653
|
+
}
|
|
654
|
+
onKeypress(t2, e) {
|
|
655
|
+
if (this._track && e.name !== "return" && (e.name && this._isActionKey(t2, e) && this.rl?.write(null, { ctrl: true, name: "h" }), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"), e?.name && (!this._track && settings.aliases.has(e.name) && this.emit("cursor", settings.aliases.get(e.name)), settings.actions.has(e.name) && this.emit("cursor", e.name)), t2 && (t2.toLowerCase() === "y" || t2.toLowerCase() === "n") && this.emit("confirm", t2.toLowerCase() === "y"), this.emit("key", t2, e), e?.name === "return" && this._shouldSubmit(t2, e)) {
|
|
656
|
+
if (this.opts.validate) {
|
|
657
|
+
const i = runValidation(this.opts.validate, this.value);
|
|
658
|
+
i && (this.error = i instanceof Error ? i.message : i, this.state = "error", this.rl?.write(this.userInput));
|
|
659
|
+
}
|
|
660
|
+
this.state !== "error" && (this.state = "submit");
|
|
1408
661
|
}
|
|
1409
|
-
this
|
|
1410
|
-
|
|
1411
|
-
|
|
662
|
+
isActionKey([t2, e?.name, e?.sequence], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
|
|
663
|
+
}
|
|
664
|
+
close() {
|
|
665
|
+
this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
|
|
666
|
+
`), setRawMode(this.input, false), this.rl?.close(), this.rl = undefined, this.emit(`${this.state}`, this.value), this.unsubscribe();
|
|
667
|
+
}
|
|
668
|
+
restoreCursor() {
|
|
669
|
+
const t2 = wrapAnsi(this._prevFrame, process.stdout.columns, { hard: true, trim: false }).split(`
|
|
670
|
+
`).length - 1;
|
|
671
|
+
this.output.write(import_sisteransi.cursor.move(-999, t2 * -1));
|
|
1412
672
|
}
|
|
1413
|
-
|
|
1414
|
-
const
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
673
|
+
render() {
|
|
674
|
+
const t2 = wrapAnsi(this._render(this) ?? "", process.stdout.columns, {
|
|
675
|
+
hard: true,
|
|
676
|
+
trim: false
|
|
677
|
+
});
|
|
678
|
+
if (t2 !== this._prevFrame) {
|
|
679
|
+
if (this.state === "initial")
|
|
680
|
+
this.output.write(import_sisteransi.cursor.hide);
|
|
681
|
+
else {
|
|
682
|
+
const e = diffLines(this._prevFrame, t2), i = getRows(this.output);
|
|
683
|
+
if (this.restoreCursor(), e) {
|
|
684
|
+
const n = Math.max(0, e.numLinesAfter - i), s = Math.max(0, e.numLinesBefore - i);
|
|
685
|
+
let r = e.lines.find((o) => o >= n);
|
|
686
|
+
if (r === undefined) {
|
|
687
|
+
this._prevFrame = t2;
|
|
688
|
+
return;
|
|
689
|
+
}
|
|
690
|
+
if (e.lines.length === 1) {
|
|
691
|
+
this.output.write(import_sisteransi.cursor.move(0, r - s)), this.output.write(import_sisteransi.erase.lines(1));
|
|
692
|
+
const o = t2.split(`
|
|
693
|
+
`);
|
|
694
|
+
this.output.write(o[r]), this._prevFrame = t2, this.output.write(import_sisteransi.cursor.move(0, o.length - r - 1));
|
|
695
|
+
return;
|
|
696
|
+
} else if (e.lines.length > 1) {
|
|
697
|
+
if (n < s)
|
|
698
|
+
r = n;
|
|
699
|
+
else {
|
|
700
|
+
const h = r - s;
|
|
701
|
+
h > 0 && this.output.write(import_sisteransi.cursor.move(0, h));
|
|
702
|
+
}
|
|
703
|
+
this.output.write(import_sisteransi.erase.down());
|
|
704
|
+
const f = t2.split(`
|
|
705
|
+
`).slice(r);
|
|
706
|
+
this.output.write(f.join(`
|
|
707
|
+
`)), this._prevFrame = t2;
|
|
708
|
+
return;
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
this.output.write(import_sisteransi.erase.down());
|
|
1418
712
|
}
|
|
1419
|
-
|
|
1420
|
-
this.#emitter.emit("exit", this.#process.exitCode, null);
|
|
1421
|
-
return ret;
|
|
1422
|
-
} else {
|
|
1423
|
-
return og.call(this.#process, ev, ...args);
|
|
713
|
+
this.output.write(t2), this.state === "initial" && (this.state = "active"), this._prevFrame = t2;
|
|
1424
714
|
}
|
|
1425
715
|
}
|
|
1426
716
|
}
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
} = signalExitWrap(processOk(process3) ? new SignalExit(process3) : new SignalExitFallback);
|
|
1433
|
-
|
|
1434
|
-
// node_modules/@inquirer/core/dist/lib/screen-manager.js
|
|
1435
|
-
import { stripVTControlCharacters } from "node:util";
|
|
1436
|
-
|
|
1437
|
-
// node_modules/@inquirer/ansi/dist/index.js
|
|
1438
|
-
var ESC2 = "\x1B[";
|
|
1439
|
-
var cursorLeft = ESC2 + "G";
|
|
1440
|
-
var cursorHide = ESC2 + "?25l";
|
|
1441
|
-
var cursorShow = ESC2 + "?25h";
|
|
1442
|
-
var cursorUp = (rows = 1) => rows > 0 ? `${ESC2}${rows}A` : "";
|
|
1443
|
-
var cursorDown = (rows = 1) => rows > 0 ? `${ESC2}${rows}B` : "";
|
|
1444
|
-
var cursorTo = (x, y) => {
|
|
1445
|
-
if (typeof y === "number" && !Number.isNaN(y)) {
|
|
1446
|
-
return `${ESC2}${y + 1};${x + 1}H`;
|
|
717
|
+
class a extends V {
|
|
718
|
+
options;
|
|
719
|
+
cursor = 0;
|
|
720
|
+
get _value() {
|
|
721
|
+
return this.options[this.cursor]?.value;
|
|
1447
722
|
}
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
var eraseLine = ESC2 + "2K";
|
|
1451
|
-
var eraseLines = (lines) => lines > 0 ? (eraseLine + cursorUp(1)).repeat(lines - 1) + eraseLine + cursorLeft : "";
|
|
1452
|
-
|
|
1453
|
-
// node_modules/@inquirer/core/dist/lib/screen-manager.js
|
|
1454
|
-
var height = (content) => content.split(`
|
|
1455
|
-
`).length;
|
|
1456
|
-
var lastLine = (content) => content.split(`
|
|
1457
|
-
`).pop() ?? "";
|
|
1458
|
-
|
|
1459
|
-
class ScreenManager {
|
|
1460
|
-
height = 0;
|
|
1461
|
-
extraLinesUnderPrompt = 0;
|
|
1462
|
-
cursorPos;
|
|
1463
|
-
rl;
|
|
1464
|
-
constructor(rl) {
|
|
1465
|
-
this.rl = rl;
|
|
1466
|
-
this.cursorPos = rl.getCursorPos();
|
|
723
|
+
get _enabledOptions() {
|
|
724
|
+
return this.options.filter((e) => e.disabled !== true);
|
|
1467
725
|
}
|
|
1468
|
-
|
|
1469
|
-
this.
|
|
1470
|
-
this.
|
|
1471
|
-
this.rl.output.mute();
|
|
726
|
+
toggleAll() {
|
|
727
|
+
const e = this._enabledOptions, i = this.value !== undefined && this.value.length === e.length;
|
|
728
|
+
this.value = i ? [] : e.map((t2) => t2.value);
|
|
1472
729
|
}
|
|
1473
|
-
|
|
1474
|
-
const
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
}
|
|
1480
|
-
this.rl.setPrompt(prompt);
|
|
1481
|
-
this.cursorPos = this.rl.getCursorPos();
|
|
1482
|
-
const width = readlineWidth();
|
|
1483
|
-
content = breakLines(content, width);
|
|
1484
|
-
bottomContent = breakLines(bottomContent, width);
|
|
1485
|
-
if (rawPromptLine.length % width === 0) {
|
|
1486
|
-
content += `
|
|
1487
|
-
`;
|
|
1488
|
-
}
|
|
1489
|
-
let output = content + (bottomContent ? `
|
|
1490
|
-
` + bottomContent : "");
|
|
1491
|
-
const promptLineUpDiff = Math.floor(rawPromptLine.length / width) - this.cursorPos.rows;
|
|
1492
|
-
const bottomContentHeight = promptLineUpDiff + (bottomContent ? height(bottomContent) : 0);
|
|
1493
|
-
if (bottomContentHeight > 0)
|
|
1494
|
-
output += cursorUp(bottomContentHeight);
|
|
1495
|
-
output += cursorTo(this.cursorPos.cols);
|
|
1496
|
-
this.write(cursorDown(this.extraLinesUnderPrompt) + eraseLines(this.height) + output);
|
|
1497
|
-
this.extraLinesUnderPrompt = bottomContentHeight;
|
|
1498
|
-
this.height = height(output);
|
|
1499
|
-
}
|
|
1500
|
-
checkCursorPos() {
|
|
1501
|
-
const cursorPos = this.rl.getCursorPos();
|
|
1502
|
-
if (cursorPos.cols !== this.cursorPos.cols) {
|
|
1503
|
-
this.write(cursorTo(cursorPos.cols));
|
|
1504
|
-
this.cursorPos = cursorPos;
|
|
1505
|
-
}
|
|
730
|
+
toggleInvert() {
|
|
731
|
+
const e = this.value;
|
|
732
|
+
if (!e)
|
|
733
|
+
return;
|
|
734
|
+
const i = this._enabledOptions.filter((t2) => !e.includes(t2.value));
|
|
735
|
+
this.value = i.map((t2) => t2.value);
|
|
1506
736
|
}
|
|
1507
|
-
|
|
1508
|
-
this.
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
`;
|
|
1512
|
-
output += cursorLeft;
|
|
1513
|
-
output += cursorShow;
|
|
1514
|
-
this.write(output);
|
|
1515
|
-
this.rl.close();
|
|
737
|
+
toggleValue() {
|
|
738
|
+
this.value === undefined && (this.value = []);
|
|
739
|
+
const e = this.value.includes(this._value);
|
|
740
|
+
this.value = e ? this.value.filter((i) => i !== this._value) : [...this.value, this._value];
|
|
1516
741
|
}
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
742
|
+
constructor(e) {
|
|
743
|
+
super(e, false), this.options = e.options, this.value = [...e.initialValues ?? []];
|
|
744
|
+
const i = Math.max(this.options.findIndex(({ value: t2 }) => t2 === e.cursorAt), 0);
|
|
745
|
+
this.cursor = this.options[i]?.disabled ? findCursor(i, 1, this.options) : i, this.on("key", (t2, l2) => {
|
|
746
|
+
l2.name === "a" && this.toggleAll(), l2.name === "i" && this.toggleInvert();
|
|
747
|
+
}), this.on("cursor", (t2) => {
|
|
748
|
+
switch (t2) {
|
|
749
|
+
case "left":
|
|
750
|
+
case "up":
|
|
751
|
+
this.cursor = findCursor(this.cursor, -1, this.options);
|
|
752
|
+
break;
|
|
753
|
+
case "down":
|
|
754
|
+
case "right":
|
|
755
|
+
this.cursor = findCursor(this.cursor, 1, this.options);
|
|
756
|
+
break;
|
|
757
|
+
case "space":
|
|
758
|
+
this.toggleValue();
|
|
759
|
+
break;
|
|
760
|
+
}
|
|
1527
761
|
});
|
|
1528
|
-
return { promise, resolve, reject };
|
|
1529
762
|
}
|
|
1530
763
|
}
|
|
1531
764
|
|
|
1532
|
-
// node_modules/@
|
|
1533
|
-
import
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
Error.prepareStackTrace = (_, callSites) => {
|
|
1540
|
-
const callSitesWithoutCurrent = callSites.slice(1);
|
|
1541
|
-
result = callSitesWithoutCurrent;
|
|
1542
|
-
return callSitesWithoutCurrent;
|
|
1543
|
-
};
|
|
1544
|
-
new Error().stack;
|
|
1545
|
-
} catch {
|
|
1546
|
-
return result;
|
|
765
|
+
// node_modules/@clack/prompts/dist/index.mjs
|
|
766
|
+
import { styleText, stripVTControlCharacters } from "node:util";
|
|
767
|
+
import process$1 from "node:process";
|
|
768
|
+
var import_sisteransi2 = __toESM(require_src(), 1);
|
|
769
|
+
function isUnicodeSupported() {
|
|
770
|
+
if (process$1.platform !== "win32") {
|
|
771
|
+
return process$1.env.TERM !== "linux";
|
|
1547
772
|
}
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
773
|
+
return Boolean(process$1.env.CI) || Boolean(process$1.env.WT_SESSION) || Boolean(process$1.env.TERMINUS_SUBLIME) || process$1.env.ConEmuTask === "{cmd::Cmder}" || process$1.env.TERM_PROGRAM === "Terminus-Sublime" || process$1.env.TERM_PROGRAM === "vscode" || process$1.env.TERM === "xterm-256color" || process$1.env.TERM === "alacritty" || process$1.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
774
|
+
}
|
|
775
|
+
var unicode = isUnicodeSupported();
|
|
776
|
+
var isCI = () => process.env.CI === "true";
|
|
777
|
+
var unicodeOr = (o, e) => unicode ? o : e;
|
|
778
|
+
var S_STEP_ACTIVE = unicodeOr("◆", "*");
|
|
779
|
+
var S_STEP_CANCEL = unicodeOr("■", "x");
|
|
780
|
+
var S_STEP_ERROR = unicodeOr("▲", "x");
|
|
781
|
+
var S_STEP_SUBMIT = unicodeOr("◇", "o");
|
|
782
|
+
var S_BAR_START = unicodeOr("┌", "T");
|
|
783
|
+
var S_BAR = unicodeOr("│", "|");
|
|
784
|
+
var S_BAR_END = unicodeOr("└", "—");
|
|
785
|
+
var S_BAR_START_RIGHT = unicodeOr("┐", "T");
|
|
786
|
+
var S_BAR_END_RIGHT = unicodeOr("┘", "—");
|
|
787
|
+
var S_RADIO_ACTIVE = unicodeOr("●", ">");
|
|
788
|
+
var S_RADIO_INACTIVE = unicodeOr("○", " ");
|
|
789
|
+
var S_CHECKBOX_ACTIVE = unicodeOr("◻", "[•]");
|
|
790
|
+
var S_CHECKBOX_SELECTED = unicodeOr("◼", "[+]");
|
|
791
|
+
var S_CHECKBOX_INACTIVE = unicodeOr("◻", "[ ]");
|
|
792
|
+
var S_PASSWORD_MASK = unicodeOr("▪", "•");
|
|
793
|
+
var S_BAR_H = unicodeOr("─", "-");
|
|
794
|
+
var S_CORNER_TOP_RIGHT = unicodeOr("╮", "+");
|
|
795
|
+
var S_CONNECT_LEFT = unicodeOr("├", "+");
|
|
796
|
+
var S_CORNER_BOTTOM_RIGHT = unicodeOr("╯", "+");
|
|
797
|
+
var S_CORNER_BOTTOM_LEFT = unicodeOr("╰", "+");
|
|
798
|
+
var S_CORNER_TOP_LEFT = unicodeOr("╭", "+");
|
|
799
|
+
var S_INFO = unicodeOr("●", "•");
|
|
800
|
+
var S_SUCCESS = unicodeOr("◆", "*");
|
|
801
|
+
var S_WARN = unicodeOr("▲", "!");
|
|
802
|
+
var S_ERROR = unicodeOr("■", "x");
|
|
803
|
+
var symbol = (o) => {
|
|
804
|
+
switch (o) {
|
|
805
|
+
case "initial":
|
|
806
|
+
case "active":
|
|
807
|
+
return styleText("cyan", S_STEP_ACTIVE);
|
|
808
|
+
case "cancel":
|
|
809
|
+
return styleText("red", S_STEP_CANCEL);
|
|
810
|
+
case "error":
|
|
811
|
+
return styleText("yellow", S_STEP_ERROR);
|
|
812
|
+
case "submit":
|
|
813
|
+
return styleText("green", S_STEP_SUBMIT);
|
|
814
|
+
}
|
|
815
|
+
};
|
|
816
|
+
var symbolBar = (o) => {
|
|
817
|
+
switch (o) {
|
|
818
|
+
case "initial":
|
|
819
|
+
case "active":
|
|
820
|
+
return styleText("cyan", S_BAR);
|
|
821
|
+
case "cancel":
|
|
822
|
+
return styleText("red", S_BAR);
|
|
823
|
+
case "error":
|
|
824
|
+
return styleText("yellow", S_BAR);
|
|
825
|
+
case "submit":
|
|
826
|
+
return styleText("green", S_BAR);
|
|
827
|
+
}
|
|
828
|
+
};
|
|
829
|
+
function formatInstructionFooter(o, e) {
|
|
830
|
+
const r2 = [`${e ? `${styleText("cyan", S_BAR)} ` : ""}${o.join(" • ")}`];
|
|
831
|
+
return e && r2.push(styleText("cyan", S_BAR_END)), r2;
|
|
832
|
+
}
|
|
833
|
+
var I = (l2, e, w, p, b, C = false) => {
|
|
834
|
+
let r2 = e, O = 0;
|
|
835
|
+
if (C)
|
|
836
|
+
for (let i = p - 1;i >= w; i--) {
|
|
837
|
+
const m = l2[i];
|
|
838
|
+
if (m && (r2 -= m.length), O++, r2 <= b)
|
|
839
|
+
break;
|
|
1575
840
|
}
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
cleanups.add(() => rl.removeListener("SIGINT", sigint));
|
|
1582
|
-
return withHooks(rl, (cycle) => {
|
|
1583
|
-
const hooksCleanup = AsyncResource3.bind(() => effectScheduler.clearAll());
|
|
1584
|
-
rl.on("close", hooksCleanup);
|
|
1585
|
-
cleanups.add(() => rl.removeListener("close", hooksCleanup));
|
|
1586
|
-
const startCycle = () => {
|
|
1587
|
-
const checkCursorPos = () => screen.checkCursorPos();
|
|
1588
|
-
rl.input.on("keypress", checkCursorPos);
|
|
1589
|
-
cleanups.add(() => rl.input.removeListener("keypress", checkCursorPos));
|
|
1590
|
-
let pendingDone = null;
|
|
1591
|
-
cycle(() => {
|
|
1592
|
-
let effectsSettled = false;
|
|
1593
|
-
try {
|
|
1594
|
-
const nextView = view(config, (value) => {
|
|
1595
|
-
if (effectsSettled) {
|
|
1596
|
-
resolve(value);
|
|
1597
|
-
} else {
|
|
1598
|
-
pendingDone = { value };
|
|
1599
|
-
}
|
|
1600
|
-
});
|
|
1601
|
-
if (nextView === undefined) {
|
|
1602
|
-
let callerFilename = callSites[1]?.getFileName();
|
|
1603
|
-
if (callerFilename && !callerFilename.startsWith("file://")) {
|
|
1604
|
-
callerFilename = path.resolve(callerFilename);
|
|
1605
|
-
}
|
|
1606
|
-
throw new Error(`Prompt functions must return a string.
|
|
1607
|
-
at ${callerFilename}`);
|
|
1608
|
-
}
|
|
1609
|
-
const [content, bottomContent] = typeof nextView === "string" ? [nextView] : nextView;
|
|
1610
|
-
screen.render(content, bottomContent);
|
|
1611
|
-
effectScheduler.run();
|
|
1612
|
-
} catch (error) {
|
|
1613
|
-
reject(error);
|
|
1614
|
-
}
|
|
1615
|
-
effectsSettled = true;
|
|
1616
|
-
if (pendingDone !== null) {
|
|
1617
|
-
const { value } = pendingDone;
|
|
1618
|
-
pendingDone = null;
|
|
1619
|
-
resolve(value);
|
|
1620
|
-
}
|
|
1621
|
-
});
|
|
1622
|
-
};
|
|
1623
|
-
if ("readableFlowing" in input) {
|
|
1624
|
-
nativeSetImmediate(startCycle);
|
|
1625
|
-
} else {
|
|
1626
|
-
startCycle();
|
|
1627
|
-
}
|
|
1628
|
-
return Object.assign(promise.then((answer) => {
|
|
1629
|
-
effectScheduler.clearAll();
|
|
1630
|
-
return answer;
|
|
1631
|
-
}, (error) => {
|
|
1632
|
-
effectScheduler.clearAll();
|
|
1633
|
-
throw error;
|
|
1634
|
-
}).finally(() => {
|
|
1635
|
-
cleanups.forEach((cleanup) => cleanup());
|
|
1636
|
-
screen.done({ clearContent: Boolean(context.clearPromptOnDone) });
|
|
1637
|
-
output.end();
|
|
1638
|
-
}).then(() => promise), { cancel });
|
|
1639
|
-
});
|
|
1640
|
-
};
|
|
1641
|
-
return prompt;
|
|
1642
|
-
}
|
|
1643
|
-
// node_modules/@inquirer/core/dist/lib/Separator.js
|
|
1644
|
-
import { styleText as styleText2 } from "node:util";
|
|
1645
|
-
class Separator {
|
|
1646
|
-
separator = styleText2("dim", Array.from({ length: 15 }).join(dist_default.line));
|
|
1647
|
-
type = "separator";
|
|
1648
|
-
constructor(separator) {
|
|
1649
|
-
if (separator) {
|
|
1650
|
-
this.separator = separator;
|
|
841
|
+
else
|
|
842
|
+
for (let i = w;i < p; i++) {
|
|
843
|
+
const m = l2[i];
|
|
844
|
+
if (m && (r2 -= m.length), O++, r2 <= b)
|
|
845
|
+
break;
|
|
1651
846
|
}
|
|
847
|
+
return { lineCount: r2, removals: O };
|
|
848
|
+
};
|
|
849
|
+
var limitOptions = ({
|
|
850
|
+
cursor: l2,
|
|
851
|
+
options: e,
|
|
852
|
+
style: w,
|
|
853
|
+
output: p = process.stdout,
|
|
854
|
+
maxItems: b = Number.POSITIVE_INFINITY,
|
|
855
|
+
columnPadding: C = 0,
|
|
856
|
+
rowPadding: r2 = 4
|
|
857
|
+
}) => {
|
|
858
|
+
const i = getColumns(p) - C, m = getRows(p), M = styleText("dim", "..."), v = Math.max(m - r2, 0), a2 = Math.max(Math.min(b, v), 5);
|
|
859
|
+
let f = 0;
|
|
860
|
+
l2 >= a2 - 3 && (f = Math.max(Math.min(l2 - a2 + 3, e.length - a2), 0));
|
|
861
|
+
let d = a2 < e.length && f > 0, c = a2 < e.length && f + a2 < e.length;
|
|
862
|
+
const W = Math.min(f + a2, e.length), s = [];
|
|
863
|
+
let g = 0;
|
|
864
|
+
d && g++, c && g++;
|
|
865
|
+
const T = f + (d ? 1 : 0), y = W - (c ? 1 : 0);
|
|
866
|
+
for (let t2 = T;t2 < y; t2++) {
|
|
867
|
+
const n2 = e[t2], o = n2 ? w(n2, t2 === l2) : "", h2 = wrapAnsi(o, i, {
|
|
868
|
+
hard: true,
|
|
869
|
+
trim: false
|
|
870
|
+
}).split(`
|
|
871
|
+
`);
|
|
872
|
+
s.push(h2), g += h2.length;
|
|
1652
873
|
}
|
|
1653
|
-
|
|
1654
|
-
|
|
874
|
+
if (g > v) {
|
|
875
|
+
let t2 = 0, n2 = 0, o = g;
|
|
876
|
+
const h2 = l2 - T;
|
|
877
|
+
let u2 = v;
|
|
878
|
+
const L = () => I(s, o, 0, h2, u2), E = () => I(s, o, h2 + 1, s.length, u2, true);
|
|
879
|
+
d ? ({ lineCount: o, removals: t2 } = L(), o > u2 && (c || (u2 -= 1), { lineCount: o, removals: n2 } = E())) : (c || (u2 -= 1), { lineCount: o, removals: n2 } = E(), o > u2 && (u2 -= 1, { lineCount: o, removals: t2 } = L())), t2 > 0 && (d = true, s.splice(0, t2)), n2 > 0 && (c = true, s.splice(s.length - n2, n2));
|
|
1655
880
|
}
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
unchecked: dist_default.circle,
|
|
1663
|
-
cursor: dist_default.pointer,
|
|
1664
|
-
disabledChecked: styleText3("green", dist_default.circleDouble),
|
|
1665
|
-
disabledUnchecked: "-"
|
|
1666
|
-
},
|
|
1667
|
-
style: {
|
|
1668
|
-
disabled: (text) => styleText3("dim", text),
|
|
1669
|
-
renderSelectedChoices: (selectedChoices) => selectedChoices.map((choice) => choice.short).join(", "),
|
|
1670
|
-
description: (text) => styleText3("cyan", text),
|
|
1671
|
-
keysHelpTip: (keys) => keys.map(([key, action]) => `${styleText3("bold", key)} ${styleText3("dim", action)}`).join(styleText3("dim", " • "))
|
|
1672
|
-
},
|
|
1673
|
-
i18n: { disabledError: "This option is disabled and cannot be toggled." }
|
|
881
|
+
const x = [];
|
|
882
|
+
d && x.push(M);
|
|
883
|
+
for (const t2 of s)
|
|
884
|
+
for (const n2 of t2)
|
|
885
|
+
x.push(n2);
|
|
886
|
+
return c && x.push(M), x;
|
|
1674
887
|
};
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
}
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
}
|
|
1687
|
-
|
|
1688
|
-
return
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
888
|
+
var MULTISELECT_INSTRUCTIONS = [
|
|
889
|
+
`${styleText("dim", "↑/↓")} to navigate`,
|
|
890
|
+
`${styleText("dim", "Space:")} select`,
|
|
891
|
+
`${styleText("dim", "Enter:")} confirm`
|
|
892
|
+
];
|
|
893
|
+
var m = (i, u2) => i.split(`
|
|
894
|
+
`).map((d) => u2(d)).join(`
|
|
895
|
+
`);
|
|
896
|
+
var multiselect = (i) => {
|
|
897
|
+
const u2 = (t2, a2) => {
|
|
898
|
+
const r2 = t2.label ?? String(t2.value);
|
|
899
|
+
return a2 === "disabled" ? `${styleText("gray", S_CHECKBOX_INACTIVE)} ${m(r2, (o) => styleText(["strikethrough", "gray"], o))}${t2.hint ? ` ${styleText("dim", `(${t2.hint ?? "disabled"})`)}` : ""}` : a2 === "active" ? `${styleText("cyan", S_CHECKBOX_ACTIVE)} ${r2}${t2.hint ? ` ${styleText("dim", `(${t2.hint})`)}` : ""}` : a2 === "selected" ? `${styleText("green", S_CHECKBOX_SELECTED)} ${m(r2, (o) => styleText("dim", o))}${t2.hint ? ` ${styleText("dim", `(${t2.hint})`)}` : ""}` : a2 === "cancelled" ? `${m(r2, (o) => styleText(["strikethrough", "dim"], o))}` : a2 === "active-selected" ? `${styleText("green", S_CHECKBOX_SELECTED)} ${r2}${t2.hint ? ` ${styleText("dim", `(${t2.hint})`)}` : ""}` : a2 === "submitted" ? `${m(r2, (o) => styleText("dim", o))}` : `${styleText("dim", S_CHECKBOX_INACTIVE)} ${m(r2, (o) => styleText("dim", o))}`;
|
|
900
|
+
}, d = i.required ?? true, v = i.showInstructions ?? true;
|
|
901
|
+
return new a({
|
|
902
|
+
options: i.options,
|
|
903
|
+
signal: i.signal,
|
|
904
|
+
input: i.input,
|
|
905
|
+
output: i.output,
|
|
906
|
+
initialValues: i.initialValues,
|
|
907
|
+
required: d,
|
|
908
|
+
cursorAt: i.cursorAt,
|
|
909
|
+
validate(t2) {
|
|
910
|
+
if (d && (t2 === undefined || t2.length === 0))
|
|
911
|
+
return `Please select at least one option.
|
|
912
|
+
${styleText("reset", styleText("dim", `Press ${styleText(["gray", "bgWhite", "inverse"], " space ")} to select, ${styleText("gray", styleText("bgWhite", styleText("inverse", " enter ")))} to submit`))}`;
|
|
913
|
+
},
|
|
914
|
+
render() {
|
|
915
|
+
const t2 = i.withGuide ?? settings.withGuide, a2 = wrapTextWithPrefix(i.output, i.message, t2 ? `${symbolBar(this.state)} ` : "", `${symbol(this.state)} `), r2 = `${t2 ? `${styleText("gray", S_BAR)}
|
|
916
|
+
` : ""}${a2}
|
|
917
|
+
`, o = this.value ?? [], p = (n2, l2) => {
|
|
918
|
+
if (n2.disabled)
|
|
919
|
+
return u2(n2, "disabled");
|
|
920
|
+
const s = o.includes(n2.value);
|
|
921
|
+
return l2 && s ? u2(n2, "active-selected") : s ? u2(n2, "selected") : u2(n2, l2 ? "active" : "inactive");
|
|
1705
922
|
};
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
}
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
setError(undefined);
|
|
1755
|
-
}
|
|
1756
|
-
if (loop || isUpKey(key, keybindings2) && active !== bounds.first || isDownKey(key, keybindings2) && active !== bounds.last) {
|
|
1757
|
-
const offset = isUpKey(key, keybindings2) ? -1 : 1;
|
|
1758
|
-
let next = active;
|
|
1759
|
-
do {
|
|
1760
|
-
next = (next + offset + items.length) % items.length;
|
|
1761
|
-
} while (!isNavigable(items[next]));
|
|
1762
|
-
setActive(next);
|
|
1763
|
-
}
|
|
1764
|
-
} else if (isSpaceKey(key)) {
|
|
1765
|
-
const activeItem = items[active];
|
|
1766
|
-
if (activeItem && !Separator.isSeparator(activeItem)) {
|
|
1767
|
-
if (activeItem.disabled) {
|
|
1768
|
-
setError(theme.i18n.disabledError);
|
|
1769
|
-
} else {
|
|
1770
|
-
setError(undefined);
|
|
1771
|
-
setItems(items.map((choice, i) => i === active ? toggle(choice) : choice));
|
|
923
|
+
switch (this.state) {
|
|
924
|
+
case "submit": {
|
|
925
|
+
const n2 = this.options.filter(({ value: s }) => o.includes(s)).map((s) => u2(s, "submitted")).join(styleText("dim", ", ")) || styleText("dim", "none"), l2 = wrapTextWithPrefix(i.output, n2, t2 ? `${styleText("gray", S_BAR)} ` : "");
|
|
926
|
+
return `${r2}${l2}`;
|
|
927
|
+
}
|
|
928
|
+
case "cancel": {
|
|
929
|
+
const n2 = this.options.filter(({ value: s }) => o.includes(s)).map((s) => u2(s, "cancelled")).join(styleText("dim", ", "));
|
|
930
|
+
if (n2.trim() === "")
|
|
931
|
+
return `${r2}${styleText("gray", S_BAR)}`;
|
|
932
|
+
const l2 = wrapTextWithPrefix(i.output, n2, t2 ? `${styleText("gray", S_BAR)} ` : "");
|
|
933
|
+
return `${r2}${l2}${t2 ? `
|
|
934
|
+
${styleText("gray", S_BAR)}` : ""}`;
|
|
935
|
+
}
|
|
936
|
+
case "error": {
|
|
937
|
+
const n2 = t2 ? `${styleText("yellow", S_BAR)} ` : "", l2 = this.error.split(`
|
|
938
|
+
`).map(($, C) => C === 0 ? `${t2 ? `${styleText("yellow", S_BAR_END)} ` : ""}${styleText("yellow", $)}` : ` ${$}`).join(`
|
|
939
|
+
`), s = r2.split(`
|
|
940
|
+
`).length, h2 = l2.split(`
|
|
941
|
+
`).length + 1;
|
|
942
|
+
return `${r2}${n2}${limitOptions({
|
|
943
|
+
output: i.output,
|
|
944
|
+
options: this.options,
|
|
945
|
+
cursor: this.cursor,
|
|
946
|
+
maxItems: i.maxItems,
|
|
947
|
+
columnPadding: n2.length,
|
|
948
|
+
rowPadding: s + h2,
|
|
949
|
+
style: p
|
|
950
|
+
}).join(`
|
|
951
|
+
${n2}`)}
|
|
952
|
+
${l2}
|
|
953
|
+
`;
|
|
954
|
+
}
|
|
955
|
+
default: {
|
|
956
|
+
const n2 = t2 ? `${styleText("cyan", S_BAR)} ` : "", l2 = r2.split(`
|
|
957
|
+
`).length, s = v ? formatInstructionFooter(MULTISELECT_INSTRUCTIONS, t2) : t2 ? [styleText("cyan", S_BAR_END)] : [], h2 = s.join(`
|
|
958
|
+
`), $ = s.length + 1;
|
|
959
|
+
return `${r2}${n2}${limitOptions({
|
|
960
|
+
output: i.output,
|
|
961
|
+
options: this.options,
|
|
962
|
+
cursor: this.cursor,
|
|
963
|
+
maxItems: i.maxItems,
|
|
964
|
+
columnPadding: n2.length,
|
|
965
|
+
rowPadding: l2 + $,
|
|
966
|
+
style: p
|
|
967
|
+
}).join(`
|
|
968
|
+
${n2}`)}
|
|
969
|
+
${h2}
|
|
970
|
+
`;
|
|
1772
971
|
}
|
|
1773
|
-
}
|
|
1774
|
-
} else if (key.name === shortcuts.all) {
|
|
1775
|
-
const selectAll = items.some((choice) => isSelectable(choice) && !choice.checked);
|
|
1776
|
-
setItems(items.map(check(selectAll)));
|
|
1777
|
-
} else if (key.name === shortcuts.invert) {
|
|
1778
|
-
setItems(items.map(toggle));
|
|
1779
|
-
} else if (isNumberKey(key)) {
|
|
1780
|
-
const selectedIndex = Number(key.name) - 1;
|
|
1781
|
-
let selectableIndex = -1;
|
|
1782
|
-
const position = items.findIndex((item) => {
|
|
1783
|
-
if (Separator.isSeparator(item))
|
|
1784
|
-
return false;
|
|
1785
|
-
selectableIndex++;
|
|
1786
|
-
return selectableIndex === selectedIndex;
|
|
1787
|
-
});
|
|
1788
|
-
const selectedItem = items[position];
|
|
1789
|
-
if (selectedItem && isSelectable(selectedItem)) {
|
|
1790
|
-
setActive(position);
|
|
1791
|
-
setItems(items.map((choice, i) => i === position ? toggle(choice) : choice));
|
|
1792
972
|
}
|
|
1793
973
|
}
|
|
1794
|
-
});
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
974
|
+
}).prompt();
|
|
975
|
+
};
|
|
976
|
+
var log = {
|
|
977
|
+
message: (s = [], {
|
|
978
|
+
symbol: e = styleText("gray", S_BAR),
|
|
979
|
+
secondarySymbol: r2 = styleText("gray", S_BAR),
|
|
980
|
+
output: m2 = process.stdout,
|
|
981
|
+
spacing: l2 = 1,
|
|
982
|
+
withGuide: c
|
|
983
|
+
} = {}) => {
|
|
984
|
+
const t2 = [], o = c ?? settings.withGuide, f = o ? r2 : "", O = o ? `${e} ` : "", u2 = o ? `${r2} ` : "";
|
|
985
|
+
for (let i = 0;i < l2; i++)
|
|
986
|
+
t2.push(f);
|
|
987
|
+
const g = Array.isArray(s) ? s : s.split(`
|
|
988
|
+
`);
|
|
989
|
+
if (g.length > 0) {
|
|
990
|
+
const [i, ...y] = g;
|
|
991
|
+
i.length > 0 ? t2.push(`${O}${i}`) : t2.push(o ? e : "");
|
|
992
|
+
for (const p of y)
|
|
993
|
+
p.length > 0 ? t2.push(`${u2}${p}`) : t2.push(o ? r2 : "");
|
|
994
|
+
}
|
|
995
|
+
m2.write(`${t2.join(`
|
|
996
|
+
`)}
|
|
997
|
+
`);
|
|
998
|
+
},
|
|
999
|
+
info: (s, e) => {
|
|
1000
|
+
log.message(s, { ...e, symbol: styleText("blue", S_INFO) });
|
|
1001
|
+
},
|
|
1002
|
+
success: (s, e) => {
|
|
1003
|
+
log.message(s, { ...e, symbol: styleText("green", S_SUCCESS) });
|
|
1004
|
+
},
|
|
1005
|
+
step: (s, e) => {
|
|
1006
|
+
log.message(s, { ...e, symbol: styleText("green", S_STEP_SUBMIT) });
|
|
1007
|
+
},
|
|
1008
|
+
warn: (s, e) => {
|
|
1009
|
+
log.message(s, { ...e, symbol: styleText("yellow", S_WARN) });
|
|
1010
|
+
},
|
|
1011
|
+
warning: (s, e) => {
|
|
1012
|
+
log.warn(s, e);
|
|
1013
|
+
},
|
|
1014
|
+
error: (s, e) => {
|
|
1015
|
+
log.message(s, { ...e, symbol: styleText("red", S_ERROR) });
|
|
1016
|
+
}
|
|
1017
|
+
};
|
|
1018
|
+
var W = (l2) => styleText("magenta", l2);
|
|
1019
|
+
var spinner = ({
|
|
1020
|
+
indicator: l2 = "dots",
|
|
1021
|
+
onCancel: h2,
|
|
1022
|
+
output: n2 = process.stdout,
|
|
1023
|
+
cancelMessage: G,
|
|
1024
|
+
errorMessage: O,
|
|
1025
|
+
frames: E = unicode ? ["◒", "◐", "◓", "◑"] : ["•", "o", "O", "0"],
|
|
1026
|
+
delay: F = unicode ? 80 : 120,
|
|
1027
|
+
signal: m2,
|
|
1028
|
+
...I2
|
|
1029
|
+
} = {}) => {
|
|
1030
|
+
const u2 = isCI();
|
|
1031
|
+
let M, T, d = false, S = false, s = "", p, w = performance.now();
|
|
1032
|
+
const x = getColumns(n2), k = I2?.styleFrame ?? W, g = (e) => {
|
|
1033
|
+
const r2 = e > 1 ? O ?? settings.messages.error : G ?? settings.messages.cancel;
|
|
1034
|
+
S = e === 1, d && (a2(r2, e), S && typeof h2 == "function" && h2());
|
|
1035
|
+
}, f = () => g(2), i = () => g(1), A = () => {
|
|
1036
|
+
process.on("uncaughtExceptionMonitor", f), process.on("unhandledRejection", f), process.on("SIGINT", i), process.on("SIGTERM", i), process.on("exit", g), m2 && m2.addEventListener("abort", i);
|
|
1037
|
+
}, H = () => {
|
|
1038
|
+
process.removeListener("uncaughtExceptionMonitor", f), process.removeListener("unhandledRejection", f), process.removeListener("SIGINT", i), process.removeListener("SIGTERM", i), process.removeListener("exit", g), m2 && m2.removeEventListener("abort", i);
|
|
1039
|
+
}, y = () => {
|
|
1040
|
+
if (p === undefined)
|
|
1041
|
+
return;
|
|
1042
|
+
u2 && n2.write(`
|
|
1043
|
+
`);
|
|
1044
|
+
const r2 = wrapAnsi(p, x, {
|
|
1045
|
+
hard: true,
|
|
1046
|
+
trim: false
|
|
1047
|
+
}).split(`
|
|
1048
|
+
`);
|
|
1049
|
+
r2.length > 1 && n2.write(import_sisteransi2.cursor.up(r2.length - 1)), n2.write(import_sisteransi2.cursor.to(0)), n2.write(import_sisteransi2.erase.down());
|
|
1050
|
+
}, C = (e) => e.replace(/\.+$/, ""), _ = (e) => {
|
|
1051
|
+
const r2 = (performance.now() - e) / 1000, t2 = Math.floor(r2 / 60), o = Math.floor(r2 % 60);
|
|
1052
|
+
return t2 > 0 ? `[${t2}m ${o}s]` : `[${o}s]`;
|
|
1053
|
+
}, N = I2.withGuide ?? settings.withGuide, P = (e = "") => {
|
|
1054
|
+
d = true, M = block({ output: n2 }), s = C(e), w = performance.now(), N && n2.write(`${styleText("gray", S_BAR)}
|
|
1055
|
+
`);
|
|
1056
|
+
let r2 = 0, t2 = 0;
|
|
1057
|
+
A(), T = setInterval(() => {
|
|
1058
|
+
if (u2 && s === p)
|
|
1059
|
+
return;
|
|
1060
|
+
y(), p = s;
|
|
1061
|
+
const o = k(E[r2]);
|
|
1062
|
+
let v;
|
|
1063
|
+
if (u2)
|
|
1064
|
+
v = `${o} ${s}...`;
|
|
1065
|
+
else if (l2 === "timer")
|
|
1066
|
+
v = `${o} ${s} ${_(w)}`;
|
|
1067
|
+
else {
|
|
1068
|
+
const B = ".".repeat(Math.floor(t2)).slice(0, 3);
|
|
1069
|
+
v = `${o} ${s}${B}`;
|
|
1812
1070
|
}
|
|
1813
|
-
const
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1071
|
+
const j = wrapAnsi(v, x, {
|
|
1072
|
+
hard: true,
|
|
1073
|
+
trim: false
|
|
1074
|
+
});
|
|
1075
|
+
n2.write(j), r2 = r2 + 1 < E.length ? r2 + 1 : 0, t2 = t2 < 4 ? t2 + 0.125 : 0;
|
|
1076
|
+
}, F);
|
|
1077
|
+
}, a2 = (e = "", r2 = 0, t2 = false) => {
|
|
1078
|
+
if (!d)
|
|
1079
|
+
return;
|
|
1080
|
+
d = false, clearInterval(T), y();
|
|
1081
|
+
const o = r2 === 0 ? styleText("green", S_STEP_SUBMIT) : r2 === 1 ? styleText("red", S_STEP_CANCEL) : styleText("red", S_STEP_ERROR);
|
|
1082
|
+
s = e ?? s, t2 || (l2 === "timer" ? n2.write(`${o} ${s} ${_(w)}
|
|
1083
|
+
`) : n2.write(`${o} ${s}
|
|
1084
|
+
`)), H(), M();
|
|
1085
|
+
};
|
|
1086
|
+
return {
|
|
1087
|
+
start: P,
|
|
1088
|
+
stop: (e = "") => a2(e, 0),
|
|
1089
|
+
message: (e = "") => {
|
|
1090
|
+
s = C(e ?? s);
|
|
1817
1091
|
},
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
const lines = [
|
|
1837
|
-
[prefix, message].filter(Boolean).join(" "),
|
|
1838
|
-
page,
|
|
1839
|
-
" ",
|
|
1840
|
-
description ? theme.style.description(description) : "",
|
|
1841
|
-
errorMsg ? theme.style.error(errorMsg) : "",
|
|
1842
|
-
helpLine
|
|
1843
|
-
].filter(Boolean).join(`
|
|
1844
|
-
`).trimEnd();
|
|
1845
|
-
return `${lines}${cursorHide}`;
|
|
1846
|
-
});
|
|
1092
|
+
cancel: (e = "") => a2(e, 1),
|
|
1093
|
+
error: (e = "") => a2(e, 2),
|
|
1094
|
+
clear: () => a2("", 0, true),
|
|
1095
|
+
get isCancelled() {
|
|
1096
|
+
return S;
|
|
1097
|
+
}
|
|
1098
|
+
};
|
|
1099
|
+
};
|
|
1100
|
+
var u2 = {
|
|
1101
|
+
light: unicodeOr("─", "-"),
|
|
1102
|
+
heavy: unicodeOr("━", "="),
|
|
1103
|
+
block: unicodeOr("█", "#")
|
|
1104
|
+
};
|
|
1105
|
+
var SELECT_INSTRUCTIONS = [
|
|
1106
|
+
`${styleText("dim", "↑/↓")} to navigate`,
|
|
1107
|
+
`${styleText("dim", "Enter:")} confirm`
|
|
1108
|
+
];
|
|
1109
|
+
var i = `${styleText("gray", S_BAR)} `;
|
|
1847
1110
|
|
|
1848
1111
|
// src/cli.ts
|
|
1849
1112
|
import { randomBytes } from "node:crypto";
|
|
@@ -1861,9 +1124,9 @@ import {
|
|
|
1861
1124
|
} from "node:fs/promises";
|
|
1862
1125
|
import { homedir } from "node:os";
|
|
1863
1126
|
import { dirname, extname, join, resolve } from "node:path";
|
|
1864
|
-
import { styleText as
|
|
1127
|
+
import { styleText as styleText2 } from "node:util";
|
|
1865
1128
|
import { fileURLToPath } from "node:url";
|
|
1866
|
-
var packageVersion = "0.3.
|
|
1129
|
+
var packageVersion = "0.3.1";
|
|
1867
1130
|
var configDirectory = join(process.env.XDG_CONFIG_HOME ?? join(homedir(), ".config"), "gh-postplan");
|
|
1868
1131
|
var cacheDirectory = join(process.env.XDG_CACHE_HOME ?? join(homedir(), ".cache"), "gh-postplan");
|
|
1869
1132
|
var configPath = join(configDirectory, "config.json");
|
|
@@ -1945,13 +1208,13 @@ function validateRepo(repo) {
|
|
|
1945
1208
|
async function run(command, args, cwd) {
|
|
1946
1209
|
return new Promise((resolveRun, reject) => {
|
|
1947
1210
|
const child = spawn(command, args, { cwd, stdio: ["ignore", "pipe", "pipe"] });
|
|
1948
|
-
const
|
|
1211
|
+
const stdout2 = [];
|
|
1949
1212
|
const stderr = [];
|
|
1950
|
-
child.stdout.on("data", (chunk) =>
|
|
1213
|
+
child.stdout.on("data", (chunk) => stdout2.push(chunk));
|
|
1951
1214
|
child.stderr.on("data", (chunk) => stderr.push(chunk));
|
|
1952
1215
|
child.on("error", reject);
|
|
1953
1216
|
child.on("close", (code) => {
|
|
1954
|
-
const output = Buffer.concat(
|
|
1217
|
+
const output = Buffer.concat(stdout2).toString().trim();
|
|
1955
1218
|
const error = Buffer.concat(stderr).toString().trim();
|
|
1956
1219
|
if (code === 0)
|
|
1957
1220
|
resolveRun(output);
|
|
@@ -1968,26 +1231,26 @@ async function succeeds(command, args, cwd) {
|
|
|
1968
1231
|
return false;
|
|
1969
1232
|
}
|
|
1970
1233
|
}
|
|
1971
|
-
async function exists(
|
|
1234
|
+
async function exists(path) {
|
|
1972
1235
|
try {
|
|
1973
|
-
await access(
|
|
1236
|
+
await access(path, constants.F_OK);
|
|
1974
1237
|
return true;
|
|
1975
1238
|
} catch {
|
|
1976
1239
|
return false;
|
|
1977
1240
|
}
|
|
1978
1241
|
}
|
|
1979
|
-
async function readJson(
|
|
1242
|
+
async function readJson(path, fallback) {
|
|
1980
1243
|
try {
|
|
1981
|
-
return JSON.parse(await readFile(
|
|
1244
|
+
return JSON.parse(await readFile(path, "utf8"));
|
|
1982
1245
|
} catch (error) {
|
|
1983
1246
|
if (fallback !== undefined && error.code === "ENOENT")
|
|
1984
1247
|
return fallback;
|
|
1985
|
-
throw new Error(`Cannot read ${
|
|
1248
|
+
throw new Error(`Cannot read ${path}: ${error.message}`);
|
|
1986
1249
|
}
|
|
1987
1250
|
}
|
|
1988
|
-
async function writeJson(
|
|
1989
|
-
await mkdir(dirname(
|
|
1990
|
-
await writeFile(
|
|
1251
|
+
async function writeJson(path, value) {
|
|
1252
|
+
await mkdir(dirname(path), { recursive: true });
|
|
1253
|
+
await writeFile(path, `${JSON.stringify(value, null, 2)}
|
|
1991
1254
|
`);
|
|
1992
1255
|
}
|
|
1993
1256
|
async function checkTools() {
|
|
@@ -1999,32 +1262,32 @@ function clonePath(repo) {
|
|
|
1999
1262
|
return join(cacheDirectory, ...repo.split("/"));
|
|
2000
1263
|
}
|
|
2001
1264
|
async function cloneRepo(repo) {
|
|
2002
|
-
const
|
|
2003
|
-
if (await exists(join(
|
|
2004
|
-
return
|
|
2005
|
-
if (await exists(
|
|
2006
|
-
throw new Error(`Cache path exists but is not a Git clone: ${
|
|
2007
|
-
await mkdir(dirname(
|
|
2008
|
-
await run("gh", ["repo", "clone", repo,
|
|
2009
|
-
return
|
|
2010
|
-
}
|
|
2011
|
-
async function setGitIdentity(
|
|
1265
|
+
const path = clonePath(repo);
|
|
1266
|
+
if (await exists(join(path, ".git")))
|
|
1267
|
+
return path;
|
|
1268
|
+
if (await exists(path))
|
|
1269
|
+
throw new Error(`Cache path exists but is not a Git clone: ${path}`);
|
|
1270
|
+
await mkdir(dirname(path), { recursive: true });
|
|
1271
|
+
await run("gh", ["repo", "clone", repo, path]);
|
|
1272
|
+
return path;
|
|
1273
|
+
}
|
|
1274
|
+
async function setGitIdentity(path) {
|
|
2012
1275
|
const user = JSON.parse(await run("gh", ["api", "user"]));
|
|
2013
1276
|
if (!user.login || !user.id)
|
|
2014
1277
|
throw new Error("GitHub did not return an account login and ID");
|
|
2015
|
-
await run("git", ["config", "user.name", user.login],
|
|
2016
|
-
await run("git", ["config", "user.email", `${user.id}+${user.login}@users.noreply.github.com`],
|
|
1278
|
+
await run("git", ["config", "user.name", user.login], path);
|
|
1279
|
+
await run("git", ["config", "user.email", `${user.id}+${user.login}@users.noreply.github.com`], path);
|
|
2017
1280
|
}
|
|
2018
|
-
async function switchToPagesBranch(
|
|
2019
|
-
await run("git", ["fetch", "origin"],
|
|
2020
|
-
const remoteExists = await succeeds("git", ["ls-remote", "--exit-code", "--heads", "origin", "gh-pages"],
|
|
1281
|
+
async function switchToPagesBranch(path) {
|
|
1282
|
+
await run("git", ["fetch", "origin"], path);
|
|
1283
|
+
const remoteExists = await succeeds("git", ["ls-remote", "--exit-code", "--heads", "origin", "gh-pages"], path);
|
|
2021
1284
|
if (!remoteExists) {
|
|
2022
|
-
await run("git", ["switch", "--orphan", "gh-pages"],
|
|
1285
|
+
await run("git", ["switch", "--orphan", "gh-pages"], path);
|
|
2023
1286
|
return false;
|
|
2024
1287
|
}
|
|
2025
|
-
const localExists = await succeeds("git", ["show-ref", "--verify", "--quiet", "refs/heads/gh-pages"],
|
|
2026
|
-
await run("git", localExists ? ["switch", "gh-pages"] : ["switch", "--track", "origin/gh-pages"],
|
|
2027
|
-
await run("git", ["pull", "--ff-only", "origin", "gh-pages"],
|
|
1288
|
+
const localExists = await succeeds("git", ["show-ref", "--verify", "--quiet", "refs/heads/gh-pages"], path);
|
|
1289
|
+
await run("git", localExists ? ["switch", "gh-pages"] : ["switch", "--track", "origin/gh-pages"], path);
|
|
1290
|
+
await run("git", ["pull", "--ff-only", "origin", "gh-pages"], path);
|
|
2028
1291
|
return true;
|
|
2029
1292
|
}
|
|
2030
1293
|
async function configurePages(repo) {
|
|
@@ -2064,16 +1327,16 @@ async function setup({ repo, create }) {
|
|
|
2064
1327
|
} else {
|
|
2065
1328
|
await run("gh", ["repo", "view", repo, "--json", "nameWithOwner"]);
|
|
2066
1329
|
}
|
|
2067
|
-
const
|
|
2068
|
-
await setGitIdentity(
|
|
2069
|
-
const hadRemoteBranch = await switchToPagesBranch(
|
|
2070
|
-
const noJekyll = join(
|
|
1330
|
+
const path = await cloneRepo(repo);
|
|
1331
|
+
await setGitIdentity(path);
|
|
1332
|
+
const hadRemoteBranch = await switchToPagesBranch(path);
|
|
1333
|
+
const noJekyll = join(path, ".nojekyll");
|
|
2071
1334
|
if (!await exists(noJekyll))
|
|
2072
1335
|
await writeFile(noJekyll, "");
|
|
2073
|
-
await run("git", ["add", ".nojekyll"],
|
|
2074
|
-
if (!await succeeds("git", ["diff", "--cached", "--quiet"],
|
|
2075
|
-
await run("git", ["commit", "-m", "chore: initialize GitHub Pages"],
|
|
2076
|
-
await run("git", ["push", ...hadRemoteBranch ? [] : ["-u"], "origin", "gh-pages"],
|
|
1336
|
+
await run("git", ["add", ".nojekyll"], path);
|
|
1337
|
+
if (!await succeeds("git", ["diff", "--cached", "--quiet"], path)) {
|
|
1338
|
+
await run("git", ["commit", "-m", "chore: initialize GitHub Pages"], path);
|
|
1339
|
+
await run("git", ["push", ...hadRemoteBranch ? [] : ["-u"], "origin", "gh-pages"], path);
|
|
2077
1340
|
}
|
|
2078
1341
|
const pages = await configurePages(repo);
|
|
2079
1342
|
await writeJson(configPath, { repo, pagesUrl: pages.html_url });
|
|
@@ -2088,20 +1351,20 @@ Repository ${repo} was created. Fix the issue, then run: gh-postplan setup ${rep
|
|
|
2088
1351
|
}
|
|
2089
1352
|
}
|
|
2090
1353
|
async function syncClone(repo) {
|
|
2091
|
-
let
|
|
2092
|
-
await setGitIdentity(
|
|
2093
|
-
if (!await succeeds("git", ["status", "--porcelain"],
|
|
2094
|
-
throw new Error(`Cannot inspect cached clone: ${
|
|
2095
|
-
await run("git", ["fetch", "origin"],
|
|
2096
|
-
const status = await run("git", ["status", "--porcelain"],
|
|
2097
|
-
const ahead = Number(await run("git", ["rev-list", "--count", "origin/gh-pages..HEAD"],
|
|
1354
|
+
let path = await cloneRepo(repo);
|
|
1355
|
+
await setGitIdentity(path);
|
|
1356
|
+
if (!await succeeds("git", ["status", "--porcelain"], path))
|
|
1357
|
+
throw new Error(`Cannot inspect cached clone: ${path}`);
|
|
1358
|
+
await run("git", ["fetch", "origin"], path);
|
|
1359
|
+
const status = await run("git", ["status", "--porcelain"], path);
|
|
1360
|
+
const ahead = Number(await run("git", ["rev-list", "--count", "origin/gh-pages..HEAD"], path) || 0);
|
|
2098
1361
|
if (status || ahead > 0) {
|
|
2099
|
-
await rm(
|
|
2100
|
-
|
|
2101
|
-
await setGitIdentity(
|
|
1362
|
+
await rm(path, { recursive: true, force: true });
|
|
1363
|
+
path = await cloneRepo(repo);
|
|
1364
|
+
await setGitIdentity(path);
|
|
2102
1365
|
}
|
|
2103
|
-
await switchToPagesBranch(
|
|
2104
|
-
return
|
|
1366
|
+
await switchToPagesBranch(path);
|
|
1367
|
+
return path;
|
|
2105
1368
|
}
|
|
2106
1369
|
async function getRepo() {
|
|
2107
1370
|
const repo = process.env.GH_POSTPLAN_REPO ?? (await readJson(configPath, {})).repo;
|
|
@@ -2110,22 +1373,22 @@ async function getRepo() {
|
|
|
2110
1373
|
validateRepo(repo);
|
|
2111
1374
|
return repo;
|
|
2112
1375
|
}
|
|
2113
|
-
async function cachedPagesUrl(repo,
|
|
1376
|
+
async function cachedPagesUrl(repo, path) {
|
|
2114
1377
|
const config = await readJson(configPath, {});
|
|
2115
1378
|
if (config.repo === repo && config.pagesUrl)
|
|
2116
1379
|
return config.pagesUrl;
|
|
2117
|
-
const customDomain = await readFile(join(
|
|
1380
|
+
const customDomain = await readFile(join(path, "CNAME"), "utf8").catch(() => "");
|
|
2118
1381
|
if (customDomain.trim())
|
|
2119
1382
|
return `https://${customDomain.trim()}/`;
|
|
2120
1383
|
const [owner, name] = repo.split("/");
|
|
2121
1384
|
return name.toLowerCase() === `${owner.toLowerCase()}.github.io` ? `https://${owner}.github.io/` : `https://${owner}.github.io/${name}/`;
|
|
2122
1385
|
}
|
|
2123
1386
|
async function readPublishedDrafts(repo) {
|
|
2124
|
-
const
|
|
2125
|
-
if (!await exists(join(
|
|
1387
|
+
const path = clonePath(repo);
|
|
1388
|
+
if (!await exists(join(path, ".git")))
|
|
2126
1389
|
throw new Error("No cached drafts. Publish one first.");
|
|
2127
|
-
const pagesUrl = await cachedPagesUrl(repo,
|
|
2128
|
-
const directory = join(
|
|
1390
|
+
const pagesUrl = await cachedPagesUrl(repo, path);
|
|
1391
|
+
const directory = join(path, "drafts");
|
|
2129
1392
|
if (!await exists(directory))
|
|
2130
1393
|
return [];
|
|
2131
1394
|
const drafts = [];
|
|
@@ -2137,7 +1400,7 @@ async function readPublishedDrafts(repo) {
|
|
|
2137
1400
|
const title = htmlTitle(await readFile(join(draftDirectory, "index.html"), "utf8"));
|
|
2138
1401
|
drafts.push({ id, versions, title, url: pageUrls(pagesUrl, id, 1).current });
|
|
2139
1402
|
}
|
|
2140
|
-
return drafts.sort((
|
|
1403
|
+
return drafts.sort((a2, b) => a2.title.localeCompare(b.title));
|
|
2141
1404
|
}
|
|
2142
1405
|
async function list() {
|
|
2143
1406
|
const repo = await getRepo();
|
|
@@ -2146,7 +1409,7 @@ async function list() {
|
|
|
2146
1409
|
return void process.stdout.write(`No drafts published.
|
|
2147
1410
|
`);
|
|
2148
1411
|
const color = process.stdout.isTTY && !process.env.NO_COLOR;
|
|
2149
|
-
const paint = (format, text) => color ?
|
|
1412
|
+
const paint = (format, text) => color ? styleText2(format, text) : text;
|
|
2150
1413
|
const titleWidth = Math.min(40, Math.max("TITLE".length, ...drafts.map((draft) => draft.title.length)));
|
|
2151
1414
|
const fitTitle = (title) => title.length > titleWidth ? `${title.slice(0, titleWidth - 1)}…` : title;
|
|
2152
1415
|
const showUrls = (process.stdout.columns ?? 80) >= titleWidth + 31 + Math.max(...drafts.map((draft) => draft.url.length));
|
|
@@ -2175,67 +1438,59 @@ async function deleteDrafts() {
|
|
|
2175
1438
|
if (drafts.length === 0)
|
|
2176
1439
|
return void process.stdout.write(`No drafts published.
|
|
2177
1440
|
`);
|
|
2178
|
-
const
|
|
2179
|
-
const fitTitle = (title) => title.length > titleWidth ? `${title.slice(0, titleWidth - 1)}…` : title;
|
|
2180
|
-
const showUrls = (process.stdout.columns ?? 80) >= titleWidth + 31 + Math.max(...drafts.map((draft) => draft.url.length));
|
|
2181
|
-
const columns = (title, versions, id, url) => `${title.padEnd(titleWidth)} ${versions.padEnd(8)} ${id.padEnd(12)}${showUrls ? ` ${url}` : ""}`;
|
|
2182
|
-
const selected = await dist_default4({
|
|
1441
|
+
const selected = await multiselect({
|
|
2183
1442
|
message: "Select drafts to delete",
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
...!showUrls && { description: draft.url }
|
|
2192
|
-
}))
|
|
2193
|
-
],
|
|
2194
|
-
pageSize: 12,
|
|
2195
|
-
loop: false,
|
|
2196
|
-
theme: { icon: { checked: "◆", unchecked: "◇", cursor: "›" } }
|
|
1443
|
+
options: drafts.map((draft) => ({
|
|
1444
|
+
label: draft.title,
|
|
1445
|
+
value: draft,
|
|
1446
|
+
hint: `${draft.id} · ${draft.versions} version${draft.versions === 1 ? "" : "s"}`
|
|
1447
|
+
})),
|
|
1448
|
+
maxItems: 12,
|
|
1449
|
+
required: false
|
|
2197
1450
|
});
|
|
2198
|
-
if (selected.length === 0)
|
|
1451
|
+
if (isCancel(selected) || selected.length === 0)
|
|
2199
1452
|
return void process.stdout.write(`Cancelled.
|
|
2200
1453
|
`);
|
|
2201
|
-
const
|
|
2202
|
-
const status = await run("git", ["status", "--porcelain"],
|
|
1454
|
+
const path = clonePath(repo);
|
|
1455
|
+
const status = await run("git", ["status", "--porcelain"], path);
|
|
2203
1456
|
if (status)
|
|
2204
1457
|
throw new Error("Cached drafts contain unfinished changes; publish again before deleting");
|
|
2205
|
-
await run("git", ["pull", "--ff-only", "origin", "gh-pages"],
|
|
1458
|
+
await run("git", ["pull", "--ff-only", "origin", "gh-pages"], path);
|
|
2206
1459
|
for (const draft of selected)
|
|
2207
|
-
await rm(join(
|
|
2208
|
-
await run("git", ["add", "-A", ...selected.map((draft) => join("drafts", draft.id))],
|
|
2209
|
-
await run("git", ["commit", "-m", `chore: delete ${selected.map((draft) => draft.id).join(", ")}`],
|
|
2210
|
-
await run("git", ["push", "origin", "gh-pages"],
|
|
1460
|
+
await rm(join(path, "drafts", draft.id), { recursive: true });
|
|
1461
|
+
await run("git", ["add", "-A", ...selected.map((draft) => join("drafts", draft.id))], path);
|
|
1462
|
+
await run("git", ["commit", "-m", `chore: delete ${selected.map((draft) => draft.id).join(", ")}`], path);
|
|
1463
|
+
await run("git", ["push", "origin", "gh-pages"], path);
|
|
2211
1464
|
const localDrafts = await readJson(draftsPath, {});
|
|
2212
1465
|
const deleted = new Set(selected.map((draft) => draft.id));
|
|
2213
1466
|
await writeJson(draftsPath, Object.fromEntries(Object.entries(localDrafts).filter(([, draft]) => !deleted.has(draft.id))));
|
|
2214
1467
|
process.stdout.write(`Deleted ${selected.length} draft${selected.length === 1 ? "" : "s"}.
|
|
2215
1468
|
`);
|
|
2216
1469
|
}
|
|
2217
|
-
async function makeDraftId(
|
|
1470
|
+
async function makeDraftId(path) {
|
|
2218
1471
|
let id;
|
|
2219
1472
|
do
|
|
2220
1473
|
id = randomBytes(6).toString("hex");
|
|
2221
|
-
while (await exists(join(
|
|
1474
|
+
while (await exists(join(path, "drafts", id)));
|
|
2222
1475
|
return id;
|
|
2223
1476
|
}
|
|
2224
|
-
async function verifyPublished(url, expected) {
|
|
1477
|
+
async function verifyPublished(url, expected, signal) {
|
|
2225
1478
|
const deadline = Date.now() + 120000;
|
|
2226
|
-
while (Date.now() < deadline) {
|
|
1479
|
+
while (Date.now() < deadline && !signal.aborted) {
|
|
2227
1480
|
try {
|
|
2228
|
-
const response = await fetch(url, { cache: "no-store" });
|
|
1481
|
+
const response = await fetch(url, { cache: "no-store", signal });
|
|
2229
1482
|
if (response.ok && Buffer.from(await response.arrayBuffer()).equals(expected))
|
|
2230
1483
|
return true;
|
|
2231
1484
|
} catch {}
|
|
1485
|
+
if (signal.aborted)
|
|
1486
|
+
return false;
|
|
2232
1487
|
await new Promise((resolveWait) => setTimeout(resolveWait, 2000));
|
|
2233
1488
|
}
|
|
2234
1489
|
return false;
|
|
2235
1490
|
}
|
|
2236
1491
|
async function publishAttempt(repo, sourcePath, content, id, pages) {
|
|
2237
|
-
const
|
|
2238
|
-
const draftDirectory = join(
|
|
1492
|
+
const path = await syncClone(repo);
|
|
1493
|
+
const draftDirectory = join(path, "drafts", id);
|
|
2239
1494
|
const currentPath = join(draftDirectory, "index.html");
|
|
2240
1495
|
const entries = await exists(draftDirectory) ? await readdir(draftDirectory) : [];
|
|
2241
1496
|
const version = nextVersion(entries);
|
|
@@ -2248,10 +1503,10 @@ async function publishAttempt(repo, sourcePath, content, id, pages) {
|
|
|
2248
1503
|
await mkdir(versionDirectory, { recursive: true });
|
|
2249
1504
|
await writeFile(join(versionDirectory, "index.html"), content);
|
|
2250
1505
|
await writeFile(currentPath, content);
|
|
2251
|
-
await run("git", ["add", join("drafts", id)],
|
|
2252
|
-
await run("git", ["commit", "-m", `chore: publish ${id} v${version}`],
|
|
1506
|
+
await run("git", ["add", join("drafts", id)], path);
|
|
1507
|
+
await run("git", ["commit", "-m", `chore: publish ${id} v${version}`], path);
|
|
2253
1508
|
try {
|
|
2254
|
-
await run("git", ["push", "origin", "gh-pages"],
|
|
1509
|
+
await run("git", ["push", "origin", "gh-pages"], path);
|
|
2255
1510
|
} catch (error) {
|
|
2256
1511
|
throw new PushError(error.message);
|
|
2257
1512
|
}
|
|
@@ -2296,11 +1551,26 @@ async function publish(command) {
|
|
|
2296
1551
|
process.stderr.write(`Permanent version: ${urls.version}
|
|
2297
1552
|
`);
|
|
2298
1553
|
if (command.wait) {
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
1554
|
+
const abort = new AbortController;
|
|
1555
|
+
const deployment = spinner({
|
|
1556
|
+
indicator: "timer",
|
|
1557
|
+
onCancel: () => abort.abort(),
|
|
1558
|
+
output: process.stderr,
|
|
1559
|
+
withGuide: false
|
|
1560
|
+
});
|
|
1561
|
+
deployment.start("Waiting for GitHub Pages");
|
|
1562
|
+
if (await verifyPublished(urls.version, content, abort.signal))
|
|
1563
|
+
deployment.stop("GitHub Pages is ready");
|
|
1564
|
+
else if (deployment.isCancelled) {
|
|
1565
|
+
process.exitCode = 130;
|
|
1566
|
+
return;
|
|
1567
|
+
} else {
|
|
1568
|
+
deployment.clear();
|
|
1569
|
+
log.warn(`GitHub Pages is still deploying ${urls.version}`, {
|
|
1570
|
+
output: process.stderr,
|
|
1571
|
+
spacing: 0,
|
|
1572
|
+
withGuide: false
|
|
1573
|
+
});
|
|
2304
1574
|
}
|
|
2305
1575
|
}
|
|
2306
1576
|
process.stdout.write(`${urls.current}
|