gh-postplan 0.1.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -0
- package/dist/cli.js +2023 -58
- package/package.json +4 -1
- package/skills/gh-postplan/SKILL.md +9 -0
package/dist/cli.js
CHANGED
|
@@ -1,4 +1,1849 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
function __accessProp(key) {
|
|
9
|
+
return this[key];
|
|
10
|
+
}
|
|
11
|
+
var __toESMCache_node;
|
|
12
|
+
var __toESMCache_esm;
|
|
13
|
+
var __toESM = (mod, isNodeMode, target) => {
|
|
14
|
+
var canCache = mod != null && typeof mod === "object";
|
|
15
|
+
if (canCache) {
|
|
16
|
+
var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
|
|
17
|
+
var cached = cache.get(mod);
|
|
18
|
+
if (cached)
|
|
19
|
+
return cached;
|
|
20
|
+
}
|
|
21
|
+
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
22
|
+
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
23
|
+
if (mod && typeof mod === "object" || typeof mod === "function") {
|
|
24
|
+
for (let key of __getOwnPropNames(mod))
|
|
25
|
+
if (!__hasOwnProp.call(to, key))
|
|
26
|
+
__defProp(to, key, {
|
|
27
|
+
get: __accessProp.bind(mod, key),
|
|
28
|
+
enumerable: true
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
if (canCache)
|
|
32
|
+
cache.set(mod, to);
|
|
33
|
+
return to;
|
|
34
|
+
};
|
|
35
|
+
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
36
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
37
|
+
|
|
38
|
+
// node_modules/cli-width/index.js
|
|
39
|
+
var require_cli_width = __commonJS(function(exports, module) {
|
|
40
|
+
module.exports = cliWidth;
|
|
41
|
+
function normalizeOpts(options) {
|
|
42
|
+
const defaultOpts = {
|
|
43
|
+
defaultWidth: 0,
|
|
44
|
+
output: process.stdout,
|
|
45
|
+
tty: __require("tty")
|
|
46
|
+
};
|
|
47
|
+
if (!options) {
|
|
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];
|
|
304
|
+
},
|
|
305
|
+
set(value) {
|
|
306
|
+
store.hooks[index] = value;
|
|
307
|
+
},
|
|
308
|
+
initialized: index in store.hooks
|
|
309
|
+
};
|
|
310
|
+
const returnValue = cb(pointer);
|
|
311
|
+
store.index++;
|
|
312
|
+
return returnValue;
|
|
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()
|
|
704
|
+
};
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
// node_modules/@inquirer/core/dist/lib/make-theme.js
|
|
708
|
+
function isPlainObject(value) {
|
|
709
|
+
if (typeof value !== "object" || value === null)
|
|
710
|
+
return false;
|
|
711
|
+
let proto = value;
|
|
712
|
+
while (Object.getPrototypeOf(proto) !== null) {
|
|
713
|
+
proto = Object.getPrototypeOf(proto);
|
|
714
|
+
}
|
|
715
|
+
return Object.getPrototypeOf(value) === proto;
|
|
716
|
+
}
|
|
717
|
+
function deepMerge(...objects) {
|
|
718
|
+
const output = {};
|
|
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);
|
|
757
|
+
}
|
|
758
|
+
}, [status]);
|
|
759
|
+
if (showLoader) {
|
|
760
|
+
return spinner.frames[tick];
|
|
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
|
+
}
|
|
781
|
+
|
|
782
|
+
// node_modules/@inquirer/core/dist/lib/use-keypress.js
|
|
783
|
+
function useKeypress(userHandler) {
|
|
784
|
+
const signal = useRef(userHandler);
|
|
785
|
+
signal.current = userHandler;
|
|
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);
|
|
802
|
+
|
|
803
|
+
// node_modules/fast-string-truncated-width/dist/utils.js
|
|
804
|
+
var getCodePointsLength = (() => {
|
|
805
|
+
const SURROGATE_PAIR_RE = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
|
|
806
|
+
return (input) => {
|
|
807
|
+
let surrogatePairsNr = 0;
|
|
808
|
+
SURROGATE_PAIR_RE.lastIndex = 0;
|
|
809
|
+
while (SURROGATE_PAIR_RE.test(input)) {
|
|
810
|
+
surrogatePairsNr += 1;
|
|
811
|
+
}
|
|
812
|
+
return input.length - surrogatePairsNr;
|
|
813
|
+
};
|
|
814
|
+
})();
|
|
815
|
+
var isFullWidth = (x) => {
|
|
816
|
+
return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
|
|
817
|
+
};
|
|
818
|
+
var isWideNotCJKTNotEmoji = (x) => {
|
|
819
|
+
return x === 8987 || x === 9001 || x >= 12272 && x <= 12287 || x >= 12289 && x <= 12350 || x >= 12441 && x <= 12543 || x >= 12549 && x <= 12591 || x >= 12593 && x <= 12686 || x >= 12688 && x <= 12771 || x >= 12783 && x <= 12830 || x >= 12832 && x <= 12871 || x >= 12880 && x <= 19903 || x >= 65040 && x <= 65049 || x >= 65072 && x <= 65106 || x >= 65108 && x <= 65126 || x >= 65128 && x <= 65131 || x >= 127488 && x <= 127490 || x >= 127504 && x <= 127547 || x >= 127552 && x <= 127560 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
|
|
820
|
+
};
|
|
821
|
+
|
|
822
|
+
// node_modules/fast-string-truncated-width/dist/index.js
|
|
823
|
+
var ANSI_RE = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y;
|
|
824
|
+
var CONTROL_RE = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
|
|
825
|
+
var CJKT_WIDE_RE = /(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu;
|
|
826
|
+
var TAB_RE = /\t{1,1000}/y;
|
|
827
|
+
var EMOJI_RE = /[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu;
|
|
828
|
+
var LATIN_RE = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
|
|
829
|
+
var MODIFIER_RE = /\p{M}+/gu;
|
|
830
|
+
var NO_TRUNCATION = { limit: Infinity, ellipsis: "" };
|
|
831
|
+
var getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {}) => {
|
|
832
|
+
const LIMIT = truncationOptions.limit ?? Infinity;
|
|
833
|
+
const ELLIPSIS = truncationOptions.ellipsis ?? "";
|
|
834
|
+
const ELLIPSIS_WIDTH = truncationOptions?.ellipsisWidth ?? (ELLIPSIS ? getStringTruncatedWidth(ELLIPSIS, NO_TRUNCATION, widthOptions).width : 0);
|
|
835
|
+
const ANSI_WIDTH = 0;
|
|
836
|
+
const CONTROL_WIDTH = widthOptions.controlWidth ?? 0;
|
|
837
|
+
const TAB_WIDTH = widthOptions.tabWidth ?? 8;
|
|
838
|
+
const EMOJI_WIDTH = widthOptions.emojiWidth ?? 2;
|
|
839
|
+
const FULL_WIDTH_WIDTH = 2;
|
|
840
|
+
const REGULAR_WIDTH = widthOptions.regularWidth ?? 1;
|
|
841
|
+
const WIDE_WIDTH = widthOptions.wideWidth ?? FULL_WIDTH_WIDTH;
|
|
842
|
+
const PARSE_BLOCKS = [
|
|
843
|
+
[LATIN_RE, REGULAR_WIDTH],
|
|
844
|
+
[ANSI_RE, ANSI_WIDTH],
|
|
845
|
+
[CONTROL_RE, CONTROL_WIDTH],
|
|
846
|
+
[TAB_RE, TAB_WIDTH],
|
|
847
|
+
[EMOJI_RE, EMOJI_WIDTH],
|
|
848
|
+
[CJKT_WIDE_RE, WIDE_WIDTH]
|
|
849
|
+
];
|
|
850
|
+
let indexPrev = 0;
|
|
851
|
+
let index = 0;
|
|
852
|
+
let length = input.length;
|
|
853
|
+
let lengthExtra = 0;
|
|
854
|
+
let truncationEnabled = false;
|
|
855
|
+
let truncationIndex = length;
|
|
856
|
+
let truncationLimit = Math.max(0, LIMIT - ELLIPSIS_WIDTH);
|
|
857
|
+
let unmatchedStart = 0;
|
|
858
|
+
let unmatchedEnd = 0;
|
|
859
|
+
let width = 0;
|
|
860
|
+
let widthExtra = 0;
|
|
861
|
+
outer:
|
|
862
|
+
while (true) {
|
|
863
|
+
if (unmatchedEnd > unmatchedStart || index >= length && index > indexPrev) {
|
|
864
|
+
const unmatched = input.slice(unmatchedStart, unmatchedEnd) || input.slice(indexPrev, index);
|
|
865
|
+
lengthExtra = 0;
|
|
866
|
+
for (const char of unmatched.replaceAll(MODIFIER_RE, "")) {
|
|
867
|
+
const codePoint = char.codePointAt(0) || 0;
|
|
868
|
+
if (isFullWidth(codePoint)) {
|
|
869
|
+
widthExtra = FULL_WIDTH_WIDTH;
|
|
870
|
+
} else if (isWideNotCJKTNotEmoji(codePoint)) {
|
|
871
|
+
widthExtra = WIDE_WIDTH;
|
|
872
|
+
} else {
|
|
873
|
+
widthExtra = REGULAR_WIDTH;
|
|
874
|
+
}
|
|
875
|
+
if (width + widthExtra > truncationLimit) {
|
|
876
|
+
truncationIndex = Math.min(truncationIndex, Math.max(unmatchedStart, indexPrev) + lengthExtra);
|
|
877
|
+
}
|
|
878
|
+
if (width + widthExtra > LIMIT) {
|
|
879
|
+
truncationEnabled = true;
|
|
880
|
+
break outer;
|
|
881
|
+
}
|
|
882
|
+
lengthExtra += char.length;
|
|
883
|
+
width += widthExtra;
|
|
884
|
+
}
|
|
885
|
+
unmatchedStart = unmatchedEnd = 0;
|
|
886
|
+
}
|
|
887
|
+
if (index >= length) {
|
|
888
|
+
break outer;
|
|
889
|
+
}
|
|
890
|
+
for (let i = 0, l = PARSE_BLOCKS.length;i < l; i++) {
|
|
891
|
+
const [BLOCK_RE, BLOCK_WIDTH] = PARSE_BLOCKS[i];
|
|
892
|
+
BLOCK_RE.lastIndex = index;
|
|
893
|
+
if (BLOCK_RE.test(input)) {
|
|
894
|
+
lengthExtra = BLOCK_RE === CJKT_WIDE_RE ? getCodePointsLength(input.slice(index, BLOCK_RE.lastIndex)) : BLOCK_RE === EMOJI_RE ? 1 : BLOCK_RE.lastIndex - index;
|
|
895
|
+
widthExtra = lengthExtra * BLOCK_WIDTH;
|
|
896
|
+
if (width + widthExtra > truncationLimit) {
|
|
897
|
+
truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / BLOCK_WIDTH));
|
|
898
|
+
}
|
|
899
|
+
if (width + widthExtra > LIMIT) {
|
|
900
|
+
truncationEnabled = true;
|
|
901
|
+
break outer;
|
|
902
|
+
}
|
|
903
|
+
width += widthExtra;
|
|
904
|
+
unmatchedStart = indexPrev;
|
|
905
|
+
unmatchedEnd = index;
|
|
906
|
+
index = indexPrev = BLOCK_RE.lastIndex;
|
|
907
|
+
continue outer;
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
index += 1;
|
|
911
|
+
}
|
|
912
|
+
return {
|
|
913
|
+
width: truncationEnabled ? truncationLimit : width,
|
|
914
|
+
index: truncationEnabled ? truncationIndex : length,
|
|
915
|
+
truncated: truncationEnabled,
|
|
916
|
+
ellipsed: truncationEnabled && LIMIT >= ELLIPSIS_WIDTH
|
|
917
|
+
};
|
|
918
|
+
};
|
|
919
|
+
var dist_default2 = getStringTruncatedWidth;
|
|
920
|
+
|
|
921
|
+
// node_modules/fast-string-width/dist/index.js
|
|
922
|
+
var NO_TRUNCATION2 = {
|
|
923
|
+
limit: Infinity,
|
|
924
|
+
ellipsis: "",
|
|
925
|
+
ellipsisWidth: 0
|
|
926
|
+
};
|
|
927
|
+
var fastStringWidth = (input, options = {}) => {
|
|
928
|
+
return dist_default2(input, NO_TRUNCATION2, options).width;
|
|
929
|
+
};
|
|
930
|
+
var dist_default3 = fastStringWidth;
|
|
931
|
+
|
|
932
|
+
// node_modules/fast-wrap-ansi/lib/main.js
|
|
933
|
+
var ESC = "\x1B";
|
|
934
|
+
var CSI = "";
|
|
935
|
+
var END_CODE = 39;
|
|
936
|
+
var ANSI_ESCAPE_BELL = "\x07";
|
|
937
|
+
var ANSI_CSI = "[";
|
|
938
|
+
var ANSI_OSC = "]";
|
|
939
|
+
var ANSI_SGR_TERMINATOR = "m";
|
|
940
|
+
var ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
|
|
941
|
+
var GROUP_REGEX = new RegExp(`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`, "y");
|
|
942
|
+
var getClosingCode = (openingCode) => {
|
|
943
|
+
if (openingCode >= 30 && openingCode <= 37)
|
|
944
|
+
return 39;
|
|
945
|
+
if (openingCode >= 90 && openingCode <= 97)
|
|
946
|
+
return 39;
|
|
947
|
+
if (openingCode >= 40 && openingCode <= 47)
|
|
948
|
+
return 49;
|
|
949
|
+
if (openingCode >= 100 && openingCode <= 107)
|
|
950
|
+
return 49;
|
|
951
|
+
if (openingCode === 1 || openingCode === 2)
|
|
952
|
+
return 22;
|
|
953
|
+
if (openingCode === 3)
|
|
954
|
+
return 23;
|
|
955
|
+
if (openingCode === 4)
|
|
956
|
+
return 24;
|
|
957
|
+
if (openingCode === 7)
|
|
958
|
+
return 27;
|
|
959
|
+
if (openingCode === 8)
|
|
960
|
+
return 28;
|
|
961
|
+
if (openingCode === 9)
|
|
962
|
+
return 29;
|
|
963
|
+
if (openingCode === 0)
|
|
964
|
+
return 0;
|
|
965
|
+
return;
|
|
966
|
+
};
|
|
967
|
+
var wrapAnsiCode = (code) => `${ESC}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
|
|
968
|
+
var wrapAnsiHyperlink = (url) => `${ESC}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`;
|
|
969
|
+
var wrapWord = (rows, word, columns) => {
|
|
970
|
+
const characters = word[Symbol.iterator]();
|
|
971
|
+
let isInsideEscape = false;
|
|
972
|
+
let isInsideLinkEscape = false;
|
|
973
|
+
let lastRow = rows.at(-1);
|
|
974
|
+
let visible = lastRow === undefined ? 0 : dist_default3(lastRow);
|
|
975
|
+
let currentCharacter = characters.next();
|
|
976
|
+
let nextCharacter = characters.next();
|
|
977
|
+
let rawCharacterIndex = 0;
|
|
978
|
+
while (!currentCharacter.done) {
|
|
979
|
+
const character = currentCharacter.value;
|
|
980
|
+
const characterLength = dist_default3(character);
|
|
981
|
+
if (visible + characterLength <= columns) {
|
|
982
|
+
rows[rows.length - 1] += character;
|
|
983
|
+
} else {
|
|
984
|
+
rows.push(character);
|
|
985
|
+
visible = 0;
|
|
986
|
+
}
|
|
987
|
+
if (character === ESC || character === CSI) {
|
|
988
|
+
isInsideEscape = true;
|
|
989
|
+
isInsideLinkEscape = word.startsWith(ANSI_ESCAPE_LINK, rawCharacterIndex + 1);
|
|
990
|
+
}
|
|
991
|
+
if (isInsideEscape) {
|
|
992
|
+
if (isInsideLinkEscape) {
|
|
993
|
+
if (character === ANSI_ESCAPE_BELL) {
|
|
994
|
+
isInsideEscape = false;
|
|
995
|
+
isInsideLinkEscape = false;
|
|
996
|
+
}
|
|
997
|
+
} else if (character === ANSI_SGR_TERMINATOR) {
|
|
998
|
+
isInsideEscape = false;
|
|
999
|
+
}
|
|
1000
|
+
} else {
|
|
1001
|
+
visible += characterLength;
|
|
1002
|
+
if (visible === columns && !nextCharacter.done) {
|
|
1003
|
+
rows.push("");
|
|
1004
|
+
visible = 0;
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
1007
|
+
currentCharacter = nextCharacter;
|
|
1008
|
+
nextCharacter = characters.next();
|
|
1009
|
+
rawCharacterIndex += character.length;
|
|
1010
|
+
}
|
|
1011
|
+
lastRow = rows.at(-1);
|
|
1012
|
+
if (!visible && lastRow !== undefined && lastRow.length && rows.length > 1) {
|
|
1013
|
+
rows[rows.length - 2] += rows.pop();
|
|
1014
|
+
}
|
|
1015
|
+
};
|
|
1016
|
+
var stringVisibleTrimSpacesRight = (string) => {
|
|
1017
|
+
const words = string.split(" ");
|
|
1018
|
+
let last = words.length;
|
|
1019
|
+
while (last) {
|
|
1020
|
+
if (dist_default3(words[last - 1])) {
|
|
1021
|
+
break;
|
|
1022
|
+
}
|
|
1023
|
+
last--;
|
|
1024
|
+
}
|
|
1025
|
+
if (last === words.length) {
|
|
1026
|
+
return string;
|
|
1027
|
+
}
|
|
1028
|
+
return words.slice(0, last).join(" ") + words.slice(last).join("");
|
|
1029
|
+
};
|
|
1030
|
+
var exec = (string, columns, options = {}) => {
|
|
1031
|
+
if (options.trim !== false && string.trim() === "") {
|
|
1032
|
+
return "";
|
|
1033
|
+
}
|
|
1034
|
+
let returnValue = "";
|
|
1035
|
+
let escapeCode;
|
|
1036
|
+
let escapeUrl;
|
|
1037
|
+
const words = string.split(" ");
|
|
1038
|
+
let rows = [""];
|
|
1039
|
+
let rowLength = 0;
|
|
1040
|
+
for (let index = 0;index < words.length; index++) {
|
|
1041
|
+
const word = words[index];
|
|
1042
|
+
if (options.trim !== false) {
|
|
1043
|
+
const row = rows.at(-1) ?? "";
|
|
1044
|
+
const trimmed = row.trimStart();
|
|
1045
|
+
if (row.length !== trimmed.length) {
|
|
1046
|
+
rows[rows.length - 1] = trimmed;
|
|
1047
|
+
rowLength = dist_default3(trimmed);
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
if (index !== 0) {
|
|
1051
|
+
if (rowLength >= columns && (options.wordWrap === false || options.trim === false)) {
|
|
1052
|
+
rows.push("");
|
|
1053
|
+
rowLength = 0;
|
|
1054
|
+
}
|
|
1055
|
+
if (rowLength || options.trim === false) {
|
|
1056
|
+
rows[rows.length - 1] += " ";
|
|
1057
|
+
rowLength++;
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1060
|
+
const wordLength = dist_default3(word);
|
|
1061
|
+
if (options.hard && wordLength > columns) {
|
|
1062
|
+
const remainingColumns = columns - rowLength;
|
|
1063
|
+
const breaksStartingThisLine = 1 + Math.floor((wordLength - remainingColumns - 1) / columns);
|
|
1064
|
+
const breaksStartingNextLine = Math.floor((wordLength - 1) / columns);
|
|
1065
|
+
if (breaksStartingNextLine < breaksStartingThisLine) {
|
|
1066
|
+
rows.push("");
|
|
1067
|
+
}
|
|
1068
|
+
wrapWord(rows, word, columns);
|
|
1069
|
+
rowLength = dist_default3(rows.at(-1) ?? "");
|
|
1070
|
+
continue;
|
|
1071
|
+
}
|
|
1072
|
+
if (rowLength + wordLength > columns && rowLength && wordLength) {
|
|
1073
|
+
if (options.wordWrap === false && rowLength < columns) {
|
|
1074
|
+
wrapWord(rows, word, columns);
|
|
1075
|
+
rowLength = dist_default3(rows.at(-1) ?? "");
|
|
1076
|
+
continue;
|
|
1077
|
+
}
|
|
1078
|
+
rows.push("");
|
|
1079
|
+
rowLength = 0;
|
|
1080
|
+
}
|
|
1081
|
+
if (rowLength + wordLength > columns && options.wordWrap === false) {
|
|
1082
|
+
wrapWord(rows, word, columns);
|
|
1083
|
+
rowLength = dist_default3(rows.at(-1) ?? "");
|
|
1084
|
+
continue;
|
|
1085
|
+
}
|
|
1086
|
+
rows[rows.length - 1] += word;
|
|
1087
|
+
rowLength += wordLength;
|
|
1088
|
+
}
|
|
1089
|
+
if (options.trim !== false) {
|
|
1090
|
+
rows = rows.map((row) => stringVisibleTrimSpacesRight(row));
|
|
1091
|
+
}
|
|
1092
|
+
const preString = rows.join(`
|
|
1093
|
+
`);
|
|
1094
|
+
let inSurrogate = false;
|
|
1095
|
+
for (let i = 0;i < preString.length; i++) {
|
|
1096
|
+
const character = preString[i];
|
|
1097
|
+
returnValue += character;
|
|
1098
|
+
if (!inSurrogate) {
|
|
1099
|
+
inSurrogate = character >= "\uD800" && character <= "\uDBFF";
|
|
1100
|
+
if (inSurrogate) {
|
|
1101
|
+
continue;
|
|
1102
|
+
}
|
|
1103
|
+
} else {
|
|
1104
|
+
inSurrogate = false;
|
|
1105
|
+
}
|
|
1106
|
+
if (character === ESC || character === CSI) {
|
|
1107
|
+
GROUP_REGEX.lastIndex = i + 1;
|
|
1108
|
+
const groupsResult = GROUP_REGEX.exec(preString);
|
|
1109
|
+
const groups = groupsResult?.groups;
|
|
1110
|
+
if (groups?.code !== undefined) {
|
|
1111
|
+
const code = Number.parseFloat(groups.code);
|
|
1112
|
+
escapeCode = code === END_CODE ? undefined : code;
|
|
1113
|
+
} else if (groups?.uri !== undefined) {
|
|
1114
|
+
escapeUrl = groups.uri.length === 0 ? undefined : groups.uri;
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
if (preString[i + 1] === `
|
|
1118
|
+
`) {
|
|
1119
|
+
if (escapeUrl) {
|
|
1120
|
+
returnValue += wrapAnsiHyperlink("");
|
|
1121
|
+
}
|
|
1122
|
+
const closingCode = escapeCode ? getClosingCode(escapeCode) : undefined;
|
|
1123
|
+
if (escapeCode && closingCode) {
|
|
1124
|
+
returnValue += wrapAnsiCode(closingCode);
|
|
1125
|
+
}
|
|
1126
|
+
} else if (character === `
|
|
1127
|
+
`) {
|
|
1128
|
+
if (escapeCode && getClosingCode(escapeCode)) {
|
|
1129
|
+
returnValue += wrapAnsiCode(escapeCode);
|
|
1130
|
+
}
|
|
1131
|
+
if (escapeUrl) {
|
|
1132
|
+
returnValue += wrapAnsiHyperlink(escapeUrl);
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
return returnValue;
|
|
1137
|
+
};
|
|
1138
|
+
var CRLF_OR_LF = /\r?\n/;
|
|
1139
|
+
function wrapAnsi(string, columns, options) {
|
|
1140
|
+
return String(string).normalize().split(CRLF_OR_LF).map((line) => exec(line, columns, options)).join(`
|
|
1141
|
+
`);
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
// node_modules/@inquirer/core/dist/lib/utils.js
|
|
1145
|
+
function breakLines(content, width) {
|
|
1146
|
+
return content.split(`
|
|
1147
|
+
`).flatMap((line) => wrapAnsi(line, width, { trim: false, wordWrap: false }).split(`
|
|
1148
|
+
`).map((str) => str.trimEnd())).join(`
|
|
1149
|
+
`);
|
|
1150
|
+
}
|
|
1151
|
+
function readlineWidth() {
|
|
1152
|
+
return import_cli_width.default({ defaultWidth: 80, output: readline().output });
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
// node_modules/@inquirer/core/dist/lib/pagination/use-pagination.js
|
|
1156
|
+
function usePointerPosition({ active, renderedItems, pageSize, loop }) {
|
|
1157
|
+
const state = useRef({
|
|
1158
|
+
lastPointer: active,
|
|
1159
|
+
lastActive: undefined
|
|
1160
|
+
});
|
|
1161
|
+
const { lastPointer, lastActive } = state.current;
|
|
1162
|
+
const middle = Math.floor(pageSize / 2);
|
|
1163
|
+
const renderedLength = renderedItems.reduce((acc, item) => acc + item.length, 0);
|
|
1164
|
+
const defaultPointerPosition = renderedItems.slice(0, active).reduce((acc, item) => acc + item.length, 0);
|
|
1165
|
+
let pointer = defaultPointerPosition;
|
|
1166
|
+
if (renderedLength > pageSize) {
|
|
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);
|
|
1175
|
+
}
|
|
1176
|
+
}
|
|
1177
|
+
state.current.lastPointer = pointer;
|
|
1178
|
+
state.current.lastActive = active;
|
|
1179
|
+
return pointer;
|
|
1180
|
+
}
|
|
1181
|
+
function usePagination({ items, active, renderItem, pageSize, loop = true }) {
|
|
1182
|
+
const width = readlineWidth();
|
|
1183
|
+
const bound = (num) => (num % items.length + items.length) % items.length;
|
|
1184
|
+
const renderedItems = items.map((item, index) => {
|
|
1185
|
+
if (item == null)
|
|
1186
|
+
return [];
|
|
1187
|
+
return breakLines(renderItem({ item, index, isActive: index === active }), width).split(`
|
|
1188
|
+
`);
|
|
1189
|
+
});
|
|
1190
|
+
const renderedLength = renderedItems.reduce((acc, item) => acc + item.length, 0);
|
|
1191
|
+
const renderItemAtIndex = (index) => renderedItems[index] ?? [];
|
|
1192
|
+
const pointer = usePointerPosition({ active, renderedItems, pageSize, loop });
|
|
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(`
|
|
1219
|
+
`);
|
|
1220
|
+
}
|
|
1221
|
+
// node_modules/@inquirer/core/dist/lib/create-prompt.js
|
|
1222
|
+
var import_mute_stream = __toESM(require_lib(), 1);
|
|
1223
|
+
import * as readline2 from "node:readline";
|
|
1224
|
+
import { AsyncResource as AsyncResource3 } from "node:async_hooks";
|
|
1225
|
+
|
|
1226
|
+
// node_modules/signal-exit/dist/mjs/signals.js
|
|
1227
|
+
var signals = [];
|
|
1228
|
+
signals.push("SIGHUP", "SIGINT", "SIGTERM");
|
|
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");
|
|
1234
|
+
}
|
|
1235
|
+
|
|
1236
|
+
// node_modules/signal-exit/dist/mjs/index.js
|
|
1237
|
+
var processOk = (process3) => !!process3 && typeof process3 === "object" && typeof process3.removeListener === "function" && typeof process3.emit === "function" && typeof process3.reallyExit === "function" && typeof process3.listeners === "function" && typeof process3.kill === "function" && typeof process3.pid === "number" && typeof process3.on === "function";
|
|
1238
|
+
var kExitEmitter = Symbol.for("signal-exit emitter");
|
|
1239
|
+
var global = globalThis;
|
|
1240
|
+
var ObjectDefineProperty = Object.defineProperty.bind(Object);
|
|
1241
|
+
|
|
1242
|
+
class Emitter {
|
|
1243
|
+
emitted = {
|
|
1244
|
+
afterExit: false,
|
|
1245
|
+
exit: false
|
|
1246
|
+
};
|
|
1247
|
+
listeners = {
|
|
1248
|
+
afterExit: [],
|
|
1249
|
+
exit: []
|
|
1250
|
+
};
|
|
1251
|
+
count = 0;
|
|
1252
|
+
id = Math.random();
|
|
1253
|
+
constructor() {
|
|
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
|
+
});
|
|
1263
|
+
}
|
|
1264
|
+
on(ev, fn) {
|
|
1265
|
+
this.listeners[ev].push(fn);
|
|
1266
|
+
}
|
|
1267
|
+
removeListener(ev, fn) {
|
|
1268
|
+
const list = this.listeners[ev];
|
|
1269
|
+
const i = list.indexOf(fn);
|
|
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
|
+
}
|
|
1278
|
+
}
|
|
1279
|
+
emit(ev, code, signal) {
|
|
1280
|
+
if (this.emitted[ev]) {
|
|
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;
|
|
1292
|
+
}
|
|
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 () => {};
|
|
1314
|
+
}
|
|
1315
|
+
load() {}
|
|
1316
|
+
unload() {}
|
|
1317
|
+
}
|
|
1318
|
+
|
|
1319
|
+
class SignalExit extends SignalExitBase {
|
|
1320
|
+
#hupSig = process3.platform === "win32" ? "SIGINT" : "SIGHUP";
|
|
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;
|
|
1350
|
+
}
|
|
1351
|
+
onExit(cb, opts) {
|
|
1352
|
+
if (!processOk(this.#process)) {
|
|
1353
|
+
return () => {};
|
|
1354
|
+
}
|
|
1355
|
+
if (this.#loaded === false) {
|
|
1356
|
+
this.load();
|
|
1357
|
+
}
|
|
1358
|
+
const ev = opts?.alwaysLast ? "afterExit" : "exit";
|
|
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();
|
|
1364
|
+
}
|
|
1365
|
+
};
|
|
1366
|
+
}
|
|
1367
|
+
load() {
|
|
1368
|
+
if (this.#loaded) {
|
|
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
|
+
};
|
|
1386
|
+
}
|
|
1387
|
+
unload() {
|
|
1388
|
+
if (!this.#loaded) {
|
|
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;
|
|
1404
|
+
}
|
|
1405
|
+
#processReallyExit(code) {
|
|
1406
|
+
if (!processOk(this.#process)) {
|
|
1407
|
+
return 0;
|
|
1408
|
+
}
|
|
1409
|
+
this.#process.exitCode = code || 0;
|
|
1410
|
+
this.#emitter.emit("exit", this.#process.exitCode, null);
|
|
1411
|
+
return this.#originalProcessReallyExit.call(this.#process, this.#process.exitCode);
|
|
1412
|
+
}
|
|
1413
|
+
#processEmit(ev, ...args) {
|
|
1414
|
+
const og = this.#originalProcessEmit;
|
|
1415
|
+
if (ev === "exit" && processOk(this.#process)) {
|
|
1416
|
+
if (typeof args[0] === "number") {
|
|
1417
|
+
this.#process.exitCode = args[0];
|
|
1418
|
+
}
|
|
1419
|
+
const ret = og.call(this.#process, ev, ...args);
|
|
1420
|
+
this.#emitter.emit("exit", this.#process.exitCode, null);
|
|
1421
|
+
return ret;
|
|
1422
|
+
} else {
|
|
1423
|
+
return og.call(this.#process, ev, ...args);
|
|
1424
|
+
}
|
|
1425
|
+
}
|
|
1426
|
+
}
|
|
1427
|
+
var process3 = globalThis.process;
|
|
1428
|
+
var {
|
|
1429
|
+
onExit,
|
|
1430
|
+
load,
|
|
1431
|
+
unload
|
|
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`;
|
|
1447
|
+
}
|
|
1448
|
+
return `${ESC2}${x + 1}G`;
|
|
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();
|
|
1467
|
+
}
|
|
1468
|
+
write(content) {
|
|
1469
|
+
this.rl.output.unmute();
|
|
1470
|
+
this.rl.output.write(content);
|
|
1471
|
+
this.rl.output.mute();
|
|
1472
|
+
}
|
|
1473
|
+
render(content, bottomContent = "") {
|
|
1474
|
+
const promptLine = lastLine(content);
|
|
1475
|
+
const rawPromptLine = stripVTControlCharacters(promptLine);
|
|
1476
|
+
let prompt = rawPromptLine;
|
|
1477
|
+
if (this.rl.line.length > 0) {
|
|
1478
|
+
prompt = prompt.slice(0, -this.rl.line.length);
|
|
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
|
+
}
|
|
1506
|
+
}
|
|
1507
|
+
done({ clearContent }) {
|
|
1508
|
+
this.rl.setPrompt("");
|
|
1509
|
+
let output = cursorDown(this.extraLinesUnderPrompt);
|
|
1510
|
+
output += clearContent ? eraseLines(this.height) : `
|
|
1511
|
+
`;
|
|
1512
|
+
output += cursorLeft;
|
|
1513
|
+
output += cursorShow;
|
|
1514
|
+
this.write(output);
|
|
1515
|
+
this.rl.close();
|
|
1516
|
+
}
|
|
1517
|
+
}
|
|
1518
|
+
|
|
1519
|
+
// node_modules/@inquirer/core/dist/lib/promise-polyfill.js
|
|
1520
|
+
class PromisePolyfill extends Promise {
|
|
1521
|
+
static withResolver() {
|
|
1522
|
+
let resolve;
|
|
1523
|
+
let reject;
|
|
1524
|
+
const promise = new Promise((res, rej) => {
|
|
1525
|
+
resolve = res;
|
|
1526
|
+
reject = rej;
|
|
1527
|
+
});
|
|
1528
|
+
return { promise, resolve, reject };
|
|
1529
|
+
}
|
|
1530
|
+
}
|
|
1531
|
+
|
|
1532
|
+
// node_modules/@inquirer/core/dist/lib/create-prompt.js
|
|
1533
|
+
import path from "node:path";
|
|
1534
|
+
var nativeSetImmediate = globalThis.setImmediate;
|
|
1535
|
+
function getCallSites() {
|
|
1536
|
+
const savedPrepareStackTrace = Error.prepareStackTrace;
|
|
1537
|
+
let result = [];
|
|
1538
|
+
try {
|
|
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;
|
|
1547
|
+
}
|
|
1548
|
+
Error.prepareStackTrace = savedPrepareStackTrace;
|
|
1549
|
+
return result;
|
|
1550
|
+
}
|
|
1551
|
+
function createPrompt(view) {
|
|
1552
|
+
const callSites = getCallSites();
|
|
1553
|
+
const prompt = (config, context = {}) => {
|
|
1554
|
+
const { input = process.stdin, signal } = context;
|
|
1555
|
+
const cleanups = new Set;
|
|
1556
|
+
const output = new import_mute_stream.default;
|
|
1557
|
+
output.pipe(context.output ?? process.stdout);
|
|
1558
|
+
const rl = readline2.createInterface({
|
|
1559
|
+
terminal: true,
|
|
1560
|
+
input,
|
|
1561
|
+
output
|
|
1562
|
+
});
|
|
1563
|
+
output.mute();
|
|
1564
|
+
const screen = new ScreenManager(rl);
|
|
1565
|
+
const { promise, resolve, reject } = PromisePolyfill.withResolver();
|
|
1566
|
+
const cancel = () => reject(new CancelPromptError);
|
|
1567
|
+
if (signal) {
|
|
1568
|
+
const abort = () => reject(new AbortPromptError({ cause: signal.reason }));
|
|
1569
|
+
if (signal.aborted) {
|
|
1570
|
+
abort();
|
|
1571
|
+
return Object.assign(promise, { cancel });
|
|
1572
|
+
}
|
|
1573
|
+
signal.addEventListener("abort", abort);
|
|
1574
|
+
cleanups.add(() => signal.removeEventListener("abort", abort));
|
|
1575
|
+
}
|
|
1576
|
+
cleanups.add(onExit((code, signal2) => {
|
|
1577
|
+
reject(new ExitPromptError(`User force closed the prompt with ${code} ${signal2}`));
|
|
1578
|
+
}));
|
|
1579
|
+
const sigint = () => reject(new ExitPromptError(`User force closed the prompt with SIGINT`));
|
|
1580
|
+
rl.on("SIGINT", sigint);
|
|
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;
|
|
1651
|
+
}
|
|
1652
|
+
}
|
|
1653
|
+
static isSeparator(choice) {
|
|
1654
|
+
return Boolean(choice && typeof choice === "object" && "type" in choice && choice.type === "separator");
|
|
1655
|
+
}
|
|
1656
|
+
}
|
|
1657
|
+
// node_modules/@inquirer/checkbox/dist/index.js
|
|
1658
|
+
import { styleText as styleText3 } from "node:util";
|
|
1659
|
+
var checkboxTheme = {
|
|
1660
|
+
icon: {
|
|
1661
|
+
checked: styleText3("green", dist_default.circleFilled),
|
|
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." }
|
|
1674
|
+
};
|
|
1675
|
+
function isSelectable(item) {
|
|
1676
|
+
return !Separator.isSeparator(item) && !item.disabled;
|
|
1677
|
+
}
|
|
1678
|
+
function isNavigable(item) {
|
|
1679
|
+
return !Separator.isSeparator(item);
|
|
1680
|
+
}
|
|
1681
|
+
function isChecked(item) {
|
|
1682
|
+
return !Separator.isSeparator(item) && item.checked;
|
|
1683
|
+
}
|
|
1684
|
+
function toggle(item) {
|
|
1685
|
+
return isSelectable(item) ? { ...item, checked: !item.checked } : item;
|
|
1686
|
+
}
|
|
1687
|
+
function check(checked) {
|
|
1688
|
+
return function(item) {
|
|
1689
|
+
return isSelectable(item) ? { ...item, checked } : item;
|
|
1690
|
+
};
|
|
1691
|
+
}
|
|
1692
|
+
function normalizeChoices(choices) {
|
|
1693
|
+
return choices.map((choice) => {
|
|
1694
|
+
if (Separator.isSeparator(choice))
|
|
1695
|
+
return choice;
|
|
1696
|
+
if (typeof choice !== "object" || choice === null || !("value" in choice)) {
|
|
1697
|
+
const name2 = String(choice);
|
|
1698
|
+
return {
|
|
1699
|
+
value: choice,
|
|
1700
|
+
name: name2,
|
|
1701
|
+
short: name2,
|
|
1702
|
+
checkedName: name2,
|
|
1703
|
+
disabled: false,
|
|
1704
|
+
checked: false
|
|
1705
|
+
};
|
|
1706
|
+
}
|
|
1707
|
+
const name = choice.name ?? String(choice.value);
|
|
1708
|
+
const normalizedChoice = {
|
|
1709
|
+
value: choice.value,
|
|
1710
|
+
name,
|
|
1711
|
+
short: choice.short ?? name,
|
|
1712
|
+
checkedName: choice.checkedName ?? name,
|
|
1713
|
+
disabled: choice.disabled ?? false,
|
|
1714
|
+
checked: choice.checked ?? false
|
|
1715
|
+
};
|
|
1716
|
+
if (choice.description) {
|
|
1717
|
+
normalizedChoice.description = choice.description;
|
|
1718
|
+
}
|
|
1719
|
+
return normalizedChoice;
|
|
1720
|
+
});
|
|
1721
|
+
}
|
|
1722
|
+
var dist_default4 = createPrompt((config, done) => {
|
|
1723
|
+
const { pageSize = 7, loop = true, required, validate = () => true } = config;
|
|
1724
|
+
const shortcuts = { all: "a", invert: "i", ...config.shortcuts };
|
|
1725
|
+
const theme = makeTheme(checkboxTheme, config.theme);
|
|
1726
|
+
const { keybindings: keybindings2 } = theme;
|
|
1727
|
+
const [status, setStatus] = useState("idle");
|
|
1728
|
+
const prefix = usePrefix({ status, theme });
|
|
1729
|
+
const [items, setItems] = useState(normalizeChoices(config.choices));
|
|
1730
|
+
const bounds = useMemo(() => {
|
|
1731
|
+
const first = items.findIndex(isNavigable);
|
|
1732
|
+
const last = items.findLastIndex(isNavigable);
|
|
1733
|
+
if (first === -1) {
|
|
1734
|
+
throw new ValidationError("[checkbox prompt] No selectable choices. All choices are disabled.");
|
|
1735
|
+
}
|
|
1736
|
+
return { first, last };
|
|
1737
|
+
}, [items]);
|
|
1738
|
+
const [active, setActive] = useState(bounds.first);
|
|
1739
|
+
const [errorMsg, setError] = useState();
|
|
1740
|
+
useKeypress(async (key) => {
|
|
1741
|
+
if (isEnterKey(key)) {
|
|
1742
|
+
const selection = items.filter(isChecked);
|
|
1743
|
+
const isValid = await validate([...selection]);
|
|
1744
|
+
if (required && !selection.length) {
|
|
1745
|
+
setError("At least one choice must be selected");
|
|
1746
|
+
} else if (isValid === true) {
|
|
1747
|
+
setStatus("done");
|
|
1748
|
+
done(selection.map((choice) => choice.value));
|
|
1749
|
+
} else {
|
|
1750
|
+
setError(isValid || "You must select a valid value");
|
|
1751
|
+
}
|
|
1752
|
+
} else if (isUpKey(key, keybindings2) || isDownKey(key, keybindings2)) {
|
|
1753
|
+
if (errorMsg) {
|
|
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));
|
|
1772
|
+
}
|
|
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
|
+
}
|
|
1793
|
+
}
|
|
1794
|
+
});
|
|
1795
|
+
const message = theme.style.message(config.message, status);
|
|
1796
|
+
let description;
|
|
1797
|
+
const page = usePagination({
|
|
1798
|
+
items,
|
|
1799
|
+
active,
|
|
1800
|
+
renderItem({ item, isActive }) {
|
|
1801
|
+
if (Separator.isSeparator(item)) {
|
|
1802
|
+
return ` ${item.separator}`;
|
|
1803
|
+
}
|
|
1804
|
+
const cursor = isActive ? theme.icon.cursor : " ";
|
|
1805
|
+
if (item.disabled) {
|
|
1806
|
+
const disabledLabel = typeof item.disabled === "string" ? item.disabled : "(disabled)";
|
|
1807
|
+
const checkbox2 = item.checked ? theme.icon.disabledChecked : theme.icon.disabledUnchecked;
|
|
1808
|
+
return theme.style.disabled(`${cursor}${checkbox2} ${item.name} ${disabledLabel}`);
|
|
1809
|
+
}
|
|
1810
|
+
if (isActive) {
|
|
1811
|
+
description = item.description;
|
|
1812
|
+
}
|
|
1813
|
+
const checkbox = item.checked ? theme.icon.checked : theme.icon.unchecked;
|
|
1814
|
+
const name = item.checked ? item.checkedName : item.name;
|
|
1815
|
+
const color = isActive ? theme.style.highlight : (x) => x;
|
|
1816
|
+
return color(`${cursor}${checkbox} ${name}`);
|
|
1817
|
+
},
|
|
1818
|
+
pageSize,
|
|
1819
|
+
loop
|
|
1820
|
+
});
|
|
1821
|
+
if (status === "done") {
|
|
1822
|
+
const selection = items.filter(isChecked);
|
|
1823
|
+
const answer = theme.style.answer(theme.style.renderSelectedChoices(selection, items));
|
|
1824
|
+
return [prefix, message, answer].filter(Boolean).join(" ");
|
|
1825
|
+
}
|
|
1826
|
+
const keys = [
|
|
1827
|
+
["↑↓", "navigate"],
|
|
1828
|
+
["space", "select"]
|
|
1829
|
+
];
|
|
1830
|
+
if (shortcuts.all)
|
|
1831
|
+
keys.push([shortcuts.all, "all"]);
|
|
1832
|
+
if (shortcuts.invert)
|
|
1833
|
+
keys.push([shortcuts.invert, "invert"]);
|
|
1834
|
+
keys.push(["⏎", "submit"]);
|
|
1835
|
+
const helpLine = theme.style.keysHelpTip(keys);
|
|
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
|
+
});
|
|
2
1847
|
|
|
3
1848
|
// src/cli.ts
|
|
4
1849
|
import { randomBytes } from "node:crypto";
|
|
@@ -16,8 +1861,9 @@ import {
|
|
|
16
1861
|
} from "node:fs/promises";
|
|
17
1862
|
import { homedir } from "node:os";
|
|
18
1863
|
import { dirname, extname, join, resolve } from "node:path";
|
|
1864
|
+
import { styleText as styleText4 } from "node:util";
|
|
19
1865
|
import { fileURLToPath } from "node:url";
|
|
20
|
-
var packageVersion = "0.
|
|
1866
|
+
var packageVersion = "0.3.0";
|
|
21
1867
|
var configDirectory = join(process.env.XDG_CONFIG_HOME ?? join(homedir(), ".config"), "gh-postplan");
|
|
22
1868
|
var cacheDirectory = join(process.env.XDG_CACHE_HOME ?? join(homedir(), ".cache"), "gh-postplan");
|
|
23
1869
|
var configPath = join(configDirectory, "config.json");
|
|
@@ -28,10 +1874,14 @@ class PushError extends Error {
|
|
|
28
1874
|
var help = `Usage:
|
|
29
1875
|
gh-postplan setup OWNER/REPO [--create]
|
|
30
1876
|
gh-postplan publish FILE [--new | --draft ID] [--no-wait]
|
|
1877
|
+
gh-postplan list
|
|
1878
|
+
gh-postplan delete
|
|
31
1879
|
|
|
32
1880
|
Commands:
|
|
33
1881
|
setup Configure an existing repo, or create a public one with --create
|
|
34
|
-
publish Publish one HTML file and keep its older versions available
|
|
1882
|
+
publish Publish one HTML file and keep its older versions available
|
|
1883
|
+
list List published drafts
|
|
1884
|
+
delete Interactively delete one or more drafts and all their versions`;
|
|
35
1885
|
function parseCommand(args) {
|
|
36
1886
|
if (args.length === 0 || args.includes("--help") || args.includes("-h"))
|
|
37
1887
|
return { kind: "help" };
|
|
@@ -70,6 +1920,8 @@ ${help}`);
|
|
|
70
1920
|
throw new Error("Invalid draft ID");
|
|
71
1921
|
return { kind: "publish", file: subject, draft, fresh, wait };
|
|
72
1922
|
}
|
|
1923
|
+
if ((name === "list" || name === "delete") && !subject && flags.length === 0)
|
|
1924
|
+
return { kind: name };
|
|
73
1925
|
throw new Error(`Unknown command: ${name ?? ""}
|
|
74
1926
|
|
|
75
1927
|
${help}`);
|
|
@@ -81,6 +1933,10 @@ function pageUrls(base, id, version) {
|
|
|
81
1933
|
const root = `${base.replace(/\/+$/, "")}/drafts/${id}/`;
|
|
82
1934
|
return { current: root, version: `${root}v${version}/` };
|
|
83
1935
|
}
|
|
1936
|
+
function htmlTitle(html) {
|
|
1937
|
+
const title = /<title\b[^>]*>([\s\S]*?)<\/title>/i.exec(html)?.[1] ?? "Untitled draft";
|
|
1938
|
+
return title.replace(/&#(\d+);|&#x([\da-f]+);|&(amp|lt|gt|quot|apos);/gi, (_, decimal, hex, named) => decimal ? String.fromCodePoint(Number(decimal)) : hex ? String.fromCodePoint(Number.parseInt(hex, 16)) : { amp: "&", lt: "<", gt: ">", quot: '"', apos: "'" }[named.toLowerCase()] ?? "").replace(/[\u0000-\u001f\u007f]+/g, " ").replace(/\s+/g, " ").trim() || "Untitled draft";
|
|
1939
|
+
}
|
|
84
1940
|
function validateRepo(repo) {
|
|
85
1941
|
if (!/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(repo)) {
|
|
86
1942
|
throw new Error("Repository must look like OWNER/REPO");
|
|
@@ -112,26 +1968,26 @@ async function succeeds(command, args, cwd) {
|
|
|
112
1968
|
return false;
|
|
113
1969
|
}
|
|
114
1970
|
}
|
|
115
|
-
async function exists(
|
|
1971
|
+
async function exists(path2) {
|
|
116
1972
|
try {
|
|
117
|
-
await access(
|
|
1973
|
+
await access(path2, constants.F_OK);
|
|
118
1974
|
return true;
|
|
119
1975
|
} catch {
|
|
120
1976
|
return false;
|
|
121
1977
|
}
|
|
122
1978
|
}
|
|
123
|
-
async function readJson(
|
|
1979
|
+
async function readJson(path2, fallback) {
|
|
124
1980
|
try {
|
|
125
|
-
return JSON.parse(await readFile(
|
|
1981
|
+
return JSON.parse(await readFile(path2, "utf8"));
|
|
126
1982
|
} catch (error) {
|
|
127
1983
|
if (fallback !== undefined && error.code === "ENOENT")
|
|
128
1984
|
return fallback;
|
|
129
|
-
throw new Error(`Cannot read ${
|
|
1985
|
+
throw new Error(`Cannot read ${path2}: ${error.message}`);
|
|
130
1986
|
}
|
|
131
1987
|
}
|
|
132
|
-
async function writeJson(
|
|
133
|
-
await mkdir(dirname(
|
|
134
|
-
await writeFile(
|
|
1988
|
+
async function writeJson(path2, value) {
|
|
1989
|
+
await mkdir(dirname(path2), { recursive: true });
|
|
1990
|
+
await writeFile(path2, `${JSON.stringify(value, null, 2)}
|
|
135
1991
|
`);
|
|
136
1992
|
}
|
|
137
1993
|
async function checkTools() {
|
|
@@ -143,32 +1999,32 @@ function clonePath(repo) {
|
|
|
143
1999
|
return join(cacheDirectory, ...repo.split("/"));
|
|
144
2000
|
}
|
|
145
2001
|
async function cloneRepo(repo) {
|
|
146
|
-
const
|
|
147
|
-
if (await exists(join(
|
|
148
|
-
return
|
|
149
|
-
if (await exists(
|
|
150
|
-
throw new Error(`Cache path exists but is not a Git clone: ${
|
|
151
|
-
await mkdir(dirname(
|
|
152
|
-
await run("gh", ["repo", "clone", repo,
|
|
153
|
-
return
|
|
154
|
-
}
|
|
155
|
-
async function setGitIdentity(
|
|
2002
|
+
const path2 = clonePath(repo);
|
|
2003
|
+
if (await exists(join(path2, ".git")))
|
|
2004
|
+
return path2;
|
|
2005
|
+
if (await exists(path2))
|
|
2006
|
+
throw new Error(`Cache path exists but is not a Git clone: ${path2}`);
|
|
2007
|
+
await mkdir(dirname(path2), { recursive: true });
|
|
2008
|
+
await run("gh", ["repo", "clone", repo, path2]);
|
|
2009
|
+
return path2;
|
|
2010
|
+
}
|
|
2011
|
+
async function setGitIdentity(path2) {
|
|
156
2012
|
const user = JSON.parse(await run("gh", ["api", "user"]));
|
|
157
2013
|
if (!user.login || !user.id)
|
|
158
2014
|
throw new Error("GitHub did not return an account login and ID");
|
|
159
|
-
await run("git", ["config", "user.name", user.login],
|
|
160
|
-
await run("git", ["config", "user.email", `${user.id}+${user.login}@users.noreply.github.com`],
|
|
2015
|
+
await run("git", ["config", "user.name", user.login], path2);
|
|
2016
|
+
await run("git", ["config", "user.email", `${user.id}+${user.login}@users.noreply.github.com`], path2);
|
|
161
2017
|
}
|
|
162
|
-
async function switchToPagesBranch(
|
|
163
|
-
await run("git", ["fetch", "origin"],
|
|
164
|
-
const remoteExists = await succeeds("git", ["ls-remote", "--exit-code", "--heads", "origin", "gh-pages"],
|
|
2018
|
+
async function switchToPagesBranch(path2) {
|
|
2019
|
+
await run("git", ["fetch", "origin"], path2);
|
|
2020
|
+
const remoteExists = await succeeds("git", ["ls-remote", "--exit-code", "--heads", "origin", "gh-pages"], path2);
|
|
165
2021
|
if (!remoteExists) {
|
|
166
|
-
await run("git", ["switch", "--orphan", "gh-pages"],
|
|
2022
|
+
await run("git", ["switch", "--orphan", "gh-pages"], path2);
|
|
167
2023
|
return false;
|
|
168
2024
|
}
|
|
169
|
-
const localExists = await succeeds("git", ["show-ref", "--verify", "--quiet", "refs/heads/gh-pages"],
|
|
170
|
-
await run("git", localExists ? ["switch", "gh-pages"] : ["switch", "--track", "origin/gh-pages"],
|
|
171
|
-
await run("git", ["pull", "--ff-only", "origin", "gh-pages"],
|
|
2025
|
+
const localExists = await succeeds("git", ["show-ref", "--verify", "--quiet", "refs/heads/gh-pages"], path2);
|
|
2026
|
+
await run("git", localExists ? ["switch", "gh-pages"] : ["switch", "--track", "origin/gh-pages"], path2);
|
|
2027
|
+
await run("git", ["pull", "--ff-only", "origin", "gh-pages"], path2);
|
|
172
2028
|
return true;
|
|
173
2029
|
}
|
|
174
2030
|
async function configurePages(repo) {
|
|
@@ -208,19 +2064,19 @@ async function setup({ repo, create }) {
|
|
|
208
2064
|
} else {
|
|
209
2065
|
await run("gh", ["repo", "view", repo, "--json", "nameWithOwner"]);
|
|
210
2066
|
}
|
|
211
|
-
const
|
|
212
|
-
await setGitIdentity(
|
|
213
|
-
const hadRemoteBranch = await switchToPagesBranch(
|
|
214
|
-
const noJekyll = join(
|
|
2067
|
+
const path2 = await cloneRepo(repo);
|
|
2068
|
+
await setGitIdentity(path2);
|
|
2069
|
+
const hadRemoteBranch = await switchToPagesBranch(path2);
|
|
2070
|
+
const noJekyll = join(path2, ".nojekyll");
|
|
215
2071
|
if (!await exists(noJekyll))
|
|
216
2072
|
await writeFile(noJekyll, "");
|
|
217
|
-
await run("git", ["add", ".nojekyll"],
|
|
218
|
-
if (!await succeeds("git", ["diff", "--cached", "--quiet"],
|
|
219
|
-
await run("git", ["commit", "-m", "chore: initialize GitHub Pages"],
|
|
220
|
-
await run("git", ["push", ...hadRemoteBranch ? [] : ["-u"], "origin", "gh-pages"],
|
|
2073
|
+
await run("git", ["add", ".nojekyll"], path2);
|
|
2074
|
+
if (!await succeeds("git", ["diff", "--cached", "--quiet"], path2)) {
|
|
2075
|
+
await run("git", ["commit", "-m", "chore: initialize GitHub Pages"], path2);
|
|
2076
|
+
await run("git", ["push", ...hadRemoteBranch ? [] : ["-u"], "origin", "gh-pages"], path2);
|
|
221
2077
|
}
|
|
222
2078
|
const pages = await configurePages(repo);
|
|
223
|
-
await writeJson(configPath, { repo });
|
|
2079
|
+
await writeJson(configPath, { repo, pagesUrl: pages.html_url });
|
|
224
2080
|
process.stderr.write(`Configured ${repo}
|
|
225
2081
|
${pages.html_url}
|
|
226
2082
|
`);
|
|
@@ -232,20 +2088,20 @@ Repository ${repo} was created. Fix the issue, then run: gh-postplan setup ${rep
|
|
|
232
2088
|
}
|
|
233
2089
|
}
|
|
234
2090
|
async function syncClone(repo) {
|
|
235
|
-
let
|
|
236
|
-
await setGitIdentity(
|
|
237
|
-
if (!await succeeds("git", ["status", "--porcelain"],
|
|
238
|
-
throw new Error(`Cannot inspect cached clone: ${
|
|
239
|
-
await run("git", ["fetch", "origin"],
|
|
240
|
-
const status = await run("git", ["status", "--porcelain"],
|
|
241
|
-
const ahead = Number(await run("git", ["rev-list", "--count", "origin/gh-pages..HEAD"],
|
|
2091
|
+
let path2 = await cloneRepo(repo);
|
|
2092
|
+
await setGitIdentity(path2);
|
|
2093
|
+
if (!await succeeds("git", ["status", "--porcelain"], path2))
|
|
2094
|
+
throw new Error(`Cannot inspect cached clone: ${path2}`);
|
|
2095
|
+
await run("git", ["fetch", "origin"], path2);
|
|
2096
|
+
const status = await run("git", ["status", "--porcelain"], path2);
|
|
2097
|
+
const ahead = Number(await run("git", ["rev-list", "--count", "origin/gh-pages..HEAD"], path2) || 0);
|
|
242
2098
|
if (status || ahead > 0) {
|
|
243
|
-
await rm(
|
|
244
|
-
|
|
245
|
-
await setGitIdentity(
|
|
2099
|
+
await rm(path2, { recursive: true, force: true });
|
|
2100
|
+
path2 = await cloneRepo(repo);
|
|
2101
|
+
await setGitIdentity(path2);
|
|
246
2102
|
}
|
|
247
|
-
await switchToPagesBranch(
|
|
248
|
-
return
|
|
2103
|
+
await switchToPagesBranch(path2);
|
|
2104
|
+
return path2;
|
|
249
2105
|
}
|
|
250
2106
|
async function getRepo() {
|
|
251
2107
|
const repo = process.env.GH_POSTPLAN_REPO ?? (await readJson(configPath, {})).repo;
|
|
@@ -254,11 +2110,115 @@ async function getRepo() {
|
|
|
254
2110
|
validateRepo(repo);
|
|
255
2111
|
return repo;
|
|
256
2112
|
}
|
|
257
|
-
async function
|
|
2113
|
+
async function cachedPagesUrl(repo, path2) {
|
|
2114
|
+
const config = await readJson(configPath, {});
|
|
2115
|
+
if (config.repo === repo && config.pagesUrl)
|
|
2116
|
+
return config.pagesUrl;
|
|
2117
|
+
const customDomain = await readFile(join(path2, "CNAME"), "utf8").catch(() => "");
|
|
2118
|
+
if (customDomain.trim())
|
|
2119
|
+
return `https://${customDomain.trim()}/`;
|
|
2120
|
+
const [owner, name] = repo.split("/");
|
|
2121
|
+
return name.toLowerCase() === `${owner.toLowerCase()}.github.io` ? `https://${owner}.github.io/` : `https://${owner}.github.io/${name}/`;
|
|
2122
|
+
}
|
|
2123
|
+
async function readPublishedDrafts(repo) {
|
|
2124
|
+
const path2 = clonePath(repo);
|
|
2125
|
+
if (!await exists(join(path2, ".git")))
|
|
2126
|
+
throw new Error("No cached drafts. Publish one first.");
|
|
2127
|
+
const pagesUrl = await cachedPagesUrl(repo, path2);
|
|
2128
|
+
const directory = join(path2, "drafts");
|
|
2129
|
+
if (!await exists(directory))
|
|
2130
|
+
return [];
|
|
2131
|
+
const drafts = [];
|
|
2132
|
+
for (const id of await readdir(directory)) {
|
|
2133
|
+
const draftDirectory = join(directory, id);
|
|
2134
|
+
if (!(await stat(draftDirectory)).isDirectory() || !await exists(join(draftDirectory, "index.html")))
|
|
2135
|
+
continue;
|
|
2136
|
+
const versions = (await readdir(draftDirectory)).filter((entry) => /^v\d+$/.test(entry)).length;
|
|
2137
|
+
const title = htmlTitle(await readFile(join(draftDirectory, "index.html"), "utf8"));
|
|
2138
|
+
drafts.push({ id, versions, title, url: pageUrls(pagesUrl, id, 1).current });
|
|
2139
|
+
}
|
|
2140
|
+
return drafts.sort((a, b) => a.title.localeCompare(b.title));
|
|
2141
|
+
}
|
|
2142
|
+
async function list() {
|
|
2143
|
+
const repo = await getRepo();
|
|
2144
|
+
const drafts = await readPublishedDrafts(repo);
|
|
2145
|
+
if (drafts.length === 0)
|
|
2146
|
+
return void process.stdout.write(`No drafts published.
|
|
2147
|
+
`);
|
|
2148
|
+
const color = process.stdout.isTTY && !process.env.NO_COLOR;
|
|
2149
|
+
const paint = (format, text) => color ? styleText4(format, text) : text;
|
|
2150
|
+
const titleWidth = Math.min(40, Math.max("TITLE".length, ...drafts.map((draft) => draft.title.length)));
|
|
2151
|
+
const fitTitle = (title) => title.length > titleWidth ? `${title.slice(0, titleWidth - 1)}…` : title;
|
|
2152
|
+
const showUrls = (process.stdout.columns ?? 80) >= titleWidth + 31 + Math.max(...drafts.map((draft) => draft.url.length));
|
|
2153
|
+
const columns = (title, versions, id, url) => `${title.padEnd(titleWidth)} ${versions.padEnd(8)} ${id.padEnd(12)}${showUrls ? ` ${url}` : ""}`;
|
|
2154
|
+
process.stdout.write(`${paint("bold", `Drafts (${drafts.length})`)}
|
|
2155
|
+
|
|
2156
|
+
`);
|
|
2157
|
+
process.stdout.write(`${paint("bold", columns("TITLE", "VERSIONS", "DRAFT ID", "URL"))}
|
|
2158
|
+
`);
|
|
2159
|
+
process.stdout.write(`${paint("dim", columns("─".repeat(titleWidth), "────────", "────────────", "─".repeat(24)))}
|
|
2160
|
+
`);
|
|
2161
|
+
for (const draft of drafts) {
|
|
2162
|
+
const row = columns(fitTitle(draft.title), String(draft.versions), draft.id, draft.url);
|
|
2163
|
+
process.stdout.write(`${paint("cyan", row)}
|
|
2164
|
+
`);
|
|
2165
|
+
if (!showUrls)
|
|
2166
|
+
process.stdout.write(`${paint("blue", ` ${draft.url}`)}
|
|
2167
|
+
`);
|
|
2168
|
+
}
|
|
2169
|
+
}
|
|
2170
|
+
async function deleteDrafts() {
|
|
2171
|
+
if (!process.stdin.isTTY || !process.stdout.isTTY)
|
|
2172
|
+
throw new Error("delete requires an interactive terminal");
|
|
2173
|
+
const repo = await getRepo();
|
|
2174
|
+
const drafts = await readPublishedDrafts(repo);
|
|
2175
|
+
if (drafts.length === 0)
|
|
2176
|
+
return void process.stdout.write(`No drafts published.
|
|
2177
|
+
`);
|
|
2178
|
+
const titleWidth = Math.min(40, Math.max("TITLE".length, ...drafts.map((draft) => draft.title.length)));
|
|
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({
|
|
2183
|
+
message: "Select drafts to delete",
|
|
2184
|
+
choices: [
|
|
2185
|
+
new Separator(` ${styleText4("bold", columns("TITLE", "VERSIONS", "DRAFT ID", "URL"))}`),
|
|
2186
|
+
new Separator(` ${styleText4("dim", columns("─".repeat(titleWidth), "────────", "────────────", "─".repeat(24)))}`),
|
|
2187
|
+
...drafts.map((draft) => ({
|
|
2188
|
+
name: columns(fitTitle(draft.title), String(draft.versions), draft.id, draft.url),
|
|
2189
|
+
value: draft,
|
|
2190
|
+
short: draft.title,
|
|
2191
|
+
...!showUrls && { description: draft.url }
|
|
2192
|
+
}))
|
|
2193
|
+
],
|
|
2194
|
+
pageSize: 12,
|
|
2195
|
+
loop: false,
|
|
2196
|
+
theme: { icon: { checked: "◆", unchecked: "◇", cursor: "›" } }
|
|
2197
|
+
});
|
|
2198
|
+
if (selected.length === 0)
|
|
2199
|
+
return void process.stdout.write(`Cancelled.
|
|
2200
|
+
`);
|
|
2201
|
+
const path2 = clonePath(repo);
|
|
2202
|
+
const status = await run("git", ["status", "--porcelain"], path2);
|
|
2203
|
+
if (status)
|
|
2204
|
+
throw new Error("Cached drafts contain unfinished changes; publish again before deleting");
|
|
2205
|
+
await run("git", ["pull", "--ff-only", "origin", "gh-pages"], path2);
|
|
2206
|
+
for (const draft of selected)
|
|
2207
|
+
await rm(join(path2, "drafts", draft.id), { recursive: true });
|
|
2208
|
+
await run("git", ["add", "-A", ...selected.map((draft) => join("drafts", draft.id))], path2);
|
|
2209
|
+
await run("git", ["commit", "-m", `chore: delete ${selected.map((draft) => draft.id).join(", ")}`], path2);
|
|
2210
|
+
await run("git", ["push", "origin", "gh-pages"], path2);
|
|
2211
|
+
const localDrafts = await readJson(draftsPath, {});
|
|
2212
|
+
const deleted = new Set(selected.map((draft) => draft.id));
|
|
2213
|
+
await writeJson(draftsPath, Object.fromEntries(Object.entries(localDrafts).filter(([, draft]) => !deleted.has(draft.id))));
|
|
2214
|
+
process.stdout.write(`Deleted ${selected.length} draft${selected.length === 1 ? "" : "s"}.
|
|
2215
|
+
`);
|
|
2216
|
+
}
|
|
2217
|
+
async function makeDraftId(path2) {
|
|
258
2218
|
let id;
|
|
259
2219
|
do
|
|
260
2220
|
id = randomBytes(6).toString("hex");
|
|
261
|
-
while (await exists(join(
|
|
2221
|
+
while (await exists(join(path2, "drafts", id)));
|
|
262
2222
|
return id;
|
|
263
2223
|
}
|
|
264
2224
|
async function verifyPublished(url, expected) {
|
|
@@ -274,8 +2234,8 @@ async function verifyPublished(url, expected) {
|
|
|
274
2234
|
return false;
|
|
275
2235
|
}
|
|
276
2236
|
async function publishAttempt(repo, sourcePath, content, id, pages) {
|
|
277
|
-
const
|
|
278
|
-
const draftDirectory = join(
|
|
2237
|
+
const path2 = await syncClone(repo);
|
|
2238
|
+
const draftDirectory = join(path2, "drafts", id);
|
|
279
2239
|
const currentPath = join(draftDirectory, "index.html");
|
|
280
2240
|
const entries = await exists(draftDirectory) ? await readdir(draftDirectory) : [];
|
|
281
2241
|
const version = nextVersion(entries);
|
|
@@ -288,10 +2248,10 @@ async function publishAttempt(repo, sourcePath, content, id, pages) {
|
|
|
288
2248
|
await mkdir(versionDirectory, { recursive: true });
|
|
289
2249
|
await writeFile(join(versionDirectory, "index.html"), content);
|
|
290
2250
|
await writeFile(currentPath, content);
|
|
291
|
-
await run("git", ["add", join("drafts", id)],
|
|
292
|
-
await run("git", ["commit", "-m", `chore: publish ${id} v${version}`],
|
|
2251
|
+
await run("git", ["add", join("drafts", id)], path2);
|
|
2252
|
+
await run("git", ["commit", "-m", `chore: publish ${id} v${version}`], path2);
|
|
293
2253
|
try {
|
|
294
|
-
await run("git", ["push", "origin", "gh-pages"],
|
|
2254
|
+
await run("git", ["push", "origin", "gh-pages"], path2);
|
|
295
2255
|
} catch (error) {
|
|
296
2256
|
throw new PushError(error.message);
|
|
297
2257
|
}
|
|
@@ -356,8 +2316,12 @@ async function main(args = process.argv.slice(2)) {
|
|
|
356
2316
|
`);
|
|
357
2317
|
else if (command.kind === "setup")
|
|
358
2318
|
await setup(command);
|
|
359
|
-
else
|
|
2319
|
+
else if (command.kind === "publish")
|
|
360
2320
|
await publish(command);
|
|
2321
|
+
else if (command.kind === "list")
|
|
2322
|
+
await list();
|
|
2323
|
+
else
|
|
2324
|
+
await deleteDrafts();
|
|
361
2325
|
}
|
|
362
2326
|
var executablePath = process.argv[1] ? await realpath(process.argv[1]).catch(() => resolve(process.argv[1])) : undefined;
|
|
363
2327
|
if (executablePath === fileURLToPath(import.meta.url)) {
|
|
@@ -368,6 +2332,7 @@ if (executablePath === fileURLToPath(import.meta.url)) {
|
|
|
368
2332
|
});
|
|
369
2333
|
}
|
|
370
2334
|
export {
|
|
2335
|
+
htmlTitle,
|
|
371
2336
|
main,
|
|
372
2337
|
nextVersion,
|
|
373
2338
|
pageUrls,
|