UNPKG

casualos

Version:
1,481 lines (1,454 loc) 6.45 MB
#!/usr/bin/env node var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __esm = (fn, res) => function __init() { return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res; }; var __commonJS = (cb, mod) => function __require() { return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; }; var __export = (target, all5) => { for (var name in all5) __defProp(target, name, { get: all5[name], enumerable: true }); }; var __copyProps = (to, from2, except, desc) => { if (from2 && typeof from2 === "object" || typeof from2 === "function") { for (let key of __getOwnPropNames(from2)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from2[key], enumerable: !(desc = __getOwnPropDesc(from2, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var __decorateClass = (decorators, target, key, kind3) => { var result = kind3 > 1 ? void 0 : kind3 ? __getOwnPropDesc(target, key) : target; for (var i2 = decorators.length - 1, decorator; i2 >= 0; i2--) if (decorator = decorators[i2]) result = (kind3 ? decorator(target, key, result) : decorator(result)) || result; if (kind3 && result) __defProp(target, key, result); return result; }; // ../../node_modules/.pnpm/kleur@3.0.3/node_modules/kleur/index.js var require_kleur = __commonJS({ "../../node_modules/.pnpm/kleur@3.0.3/node_modules/kleur/index.js"(exports2, module2) { "use strict"; var { FORCE_COLOR, NODE_DISABLE_COLORS, TERM } = process.env; var $2 = { enabled: !NODE_DISABLE_COLORS && TERM !== "dumb" && FORCE_COLOR !== "0", // modifiers reset: init(0, 0), bold: init(1, 22), dim: init(2, 22), italic: init(3, 23), underline: init(4, 24), inverse: init(7, 27), hidden: init(8, 28), strikethrough: init(9, 29), // colors black: init(30, 39), red: init(31, 39), green: init(32, 39), yellow: init(33, 39), blue: init(34, 39), magenta: init(35, 39), cyan: init(36, 39), white: init(37, 39), gray: init(90, 39), grey: init(90, 39), // background colors bgBlack: init(40, 49), bgRed: init(41, 49), bgGreen: init(42, 49), bgYellow: init(43, 49), bgBlue: init(44, 49), bgMagenta: init(45, 49), bgCyan: init(46, 49), bgWhite: init(47, 49) }; function run(arr, str2) { let i2 = 0, tmp, beg = "", end = ""; for (; i2 < arr.length; i2++) { tmp = arr[i2]; beg += tmp.open; end += tmp.close; if (str2.includes(tmp.close)) { str2 = str2.replace(tmp.rgx, tmp.close + tmp.open); } } return beg + str2 + end; } function chain(has3, keys3) { let ctx = { has: has3, keys: keys3 }; ctx.reset = $2.reset.bind(ctx); ctx.bold = $2.bold.bind(ctx); ctx.dim = $2.dim.bind(ctx); ctx.italic = $2.italic.bind(ctx); ctx.underline = $2.underline.bind(ctx); ctx.inverse = $2.inverse.bind(ctx); ctx.hidden = $2.hidden.bind(ctx); ctx.strikethrough = $2.strikethrough.bind(ctx); ctx.black = $2.black.bind(ctx); ctx.red = $2.red.bind(ctx); ctx.green = $2.green.bind(ctx); ctx.yellow = $2.yellow.bind(ctx); ctx.blue = $2.blue.bind(ctx); ctx.magenta = $2.magenta.bind(ctx); ctx.cyan = $2.cyan.bind(ctx); ctx.white = $2.white.bind(ctx); ctx.gray = $2.gray.bind(ctx); ctx.grey = $2.grey.bind(ctx); ctx.bgBlack = $2.bgBlack.bind(ctx); ctx.bgRed = $2.bgRed.bind(ctx); ctx.bgGreen = $2.bgGreen.bind(ctx); ctx.bgYellow = $2.bgYellow.bind(ctx); ctx.bgBlue = $2.bgBlue.bind(ctx); ctx.bgMagenta = $2.bgMagenta.bind(ctx); ctx.bgCyan = $2.bgCyan.bind(ctx); ctx.bgWhite = $2.bgWhite.bind(ctx); return ctx; } function init(open, close) { let blk = { open: `\x1B[${open}m`, close: `\x1B[${close}m`, rgx: new RegExp(`\\x1b\\[${close}m`, "g") }; return function(txt) { if (this !== void 0 && this.has !== void 0) { this.has.includes(open) || (this.has.push(open), this.keys.push(blk)); return txt === void 0 ? this : $2.enabled ? run(this.keys, txt + "") : txt + ""; } return txt === void 0 ? chain([open], [blk]) : $2.enabled ? run([blk], txt + "") : txt + ""; }; } module2.exports = $2; } }); // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/util/action.js var require_action = __commonJS({ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/util/action.js"(exports2, module2) { "use strict"; module2.exports = (key, isSelect) => { if (key.meta && key.name !== "escape") return; if (key.ctrl) { if (key.name === "a") return "first"; if (key.name === "c") return "abort"; if (key.name === "d") return "abort"; if (key.name === "e") return "last"; if (key.name === "g") return "reset"; } if (isSelect) { if (key.name === "j") return "down"; if (key.name === "k") return "up"; } if (key.name === "return") return "submit"; if (key.name === "enter") return "submit"; if (key.name === "backspace") return "delete"; if (key.name === "delete") return "deleteForward"; if (key.name === "abort") return "abort"; if (key.name === "escape") return "exit"; if (key.name === "tab") return "next"; if (key.name === "pagedown") return "nextPage"; if (key.name === "pageup") return "prevPage"; if (key.name === "home") return "home"; if (key.name === "end") return "end"; if (key.name === "up") return "up"; if (key.name === "down") return "down"; if (key.name === "right") return "right"; if (key.name === "left") return "left"; return false; }; } }); // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/util/strip.js var require_strip = __commonJS({ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/util/strip.js"(exports2, module2) { "use strict"; module2.exports = (str2) => { const pattern = ["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)", "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))"].join("|"); const RGX = new RegExp(pattern, "g"); return typeof str2 === "string" ? str2.replace(RGX, "") : str2; }; } }); // ../../node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js var require_src = __commonJS({ "../../node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js"(exports2, module2) { "use strict"; var ESC = "\x1B"; var CSI = `${ESC}[`; var beep = "\x07"; var cursor = { to(x2, y2) { if (!y2) return `${CSI}${x2 + 1}G`; return `${CSI}${y2 + 1};${x2 + 1}H`; }, move(x2, y2) { let ret = ""; if (x2 < 0) ret += `${CSI}${-x2}D`; else if (x2 > 0) ret += `${CSI}${x2}C`; if (y2 < 0) ret += `${CSI}${-y2}A`; else if (y2 > 0) ret += `${CSI}${y2}B`; return ret; }, up: (count2 = 1) => `${CSI}${count2}A`, down: (count2 = 1) => `${CSI}${count2}B`, forward: (count2 = 1) => `${CSI}${count2}C`, backward: (count2 = 1) => `${CSI}${count2}D`, nextLine: (count2 = 1) => `${CSI}E`.repeat(count2), prevLine: (count2 = 1) => `${CSI}F`.repeat(count2), left: `${CSI}G`, hide: `${CSI}?25l`, show: `${CSI}?25h`, save: `${ESC}7`, restore: `${ESC}8` }; var scroll = { up: (count2 = 1) => `${CSI}S`.repeat(count2), down: (count2 = 1) => `${CSI}T`.repeat(count2) }; var erase = { screen: `${CSI}2J`, up: (count2 = 1) => `${CSI}1J`.repeat(count2), down: (count2 = 1) => `${CSI}J`.repeat(count2), line: `${CSI}2K`, lineEnd: `${CSI}K`, lineStart: `${CSI}1K`, lines(count2) { let clear = ""; for (let i2 = 0; i2 < count2; i2++) clear += this.line + (i2 < count2 - 1 ? cursor.up() : ""); if (count2) clear += cursor.left; return clear; } }; module2.exports = { cursor, scroll, erase, beep }; } }); // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/util/clear.js var require_clear = __commonJS({ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/util/clear.js"(exports2, module2) { "use strict"; function _createForOfIteratorHelper(o2, allowArrayLike) { var it2 = typeof Symbol !== "undefined" && o2[Symbol.iterator] || o2["@@iterator"]; if (!it2) { if (Array.isArray(o2) || (it2 = _unsupportedIterableToArray(o2)) || allowArrayLike && o2 && typeof o2.length === "number") { if (it2) o2 = it2; var i2 = 0; var F2 = function F3() { }; return { s: F2, n: function n3() { if (i2 >= o2.length) return { done: true }; return { done: false, value: o2[i2++] }; }, e: function e2(_e2) { throw _e2; }, f: F2 }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s3() { it2 = it2.call(o2); }, n: function n3() { var step = it2.next(); normalCompletion = step.done; return step; }, e: function e2(_e2) { didErr = true; err = _e2; }, f: function f2() { try { if (!normalCompletion && it2.return != null) it2.return(); } finally { if (didErr) throw err; } } }; } function _unsupportedIterableToArray(o2, minLen) { if (!o2) return; if (typeof o2 === "string") return _arrayLikeToArray(o2, minLen); var n3 = Object.prototype.toString.call(o2).slice(8, -1); if (n3 === "Object" && o2.constructor) n3 = o2.constructor.name; if (n3 === "Map" || n3 === "Set") return Array.from(o2); if (n3 === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n3)) return _arrayLikeToArray(o2, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i2 = 0, arr2 = new Array(len); i2 < len; i2++) arr2[i2] = arr[i2]; return arr2; } var strip2 = require_strip(); var _require = require_src(); var erase = _require.erase; var cursor = _require.cursor; var width = (str2) => [...strip2(str2)].length; module2.exports = function(prompt, perLine) { if (!perLine) return erase.line + cursor.to(0); let rows = 0; const lines = prompt.split(/\r?\n/); var _iterator = _createForOfIteratorHelper(lines), _step; try { for (_iterator.s(); !(_step = _iterator.n()).done; ) { let line = _step.value; rows += 1 + Math.floor(Math.max(width(line) - 1, 0) / perLine); } } catch (err) { _iterator.e(err); } finally { _iterator.f(); } return erase.lines(rows); }; } }); // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/util/figures.js var require_figures = __commonJS({ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/util/figures.js"(exports2, module2) { "use strict"; var main2 = { arrowUp: "\u2191", arrowDown: "\u2193", arrowLeft: "\u2190", arrowRight: "\u2192", radioOn: "\u25C9", radioOff: "\u25EF", tick: "\u2714", cross: "\u2716", ellipsis: "\u2026", pointerSmall: "\u203A", line: "\u2500", pointer: "\u276F" }; var win = { arrowUp: main2.arrowUp, arrowDown: main2.arrowDown, arrowLeft: main2.arrowLeft, arrowRight: main2.arrowRight, radioOn: "(*)", radioOff: "( )", tick: "\u221A", cross: "\xD7", ellipsis: "...", pointerSmall: "\xBB", line: "\u2500", pointer: ">" }; var figures = process.platform === "win32" ? win : main2; module2.exports = figures; } }); // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/util/style.js var require_style = __commonJS({ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/util/style.js"(exports2, module2) { "use strict"; var c2 = require_kleur(); var figures = require_figures(); var styles = Object.freeze({ password: { scale: 1, render: (input) => "*".repeat(input.length) }, emoji: { scale: 2, render: (input) => "\u{1F603}".repeat(input.length) }, invisible: { scale: 0, render: (input) => "" }, default: { scale: 1, render: (input) => `${input}` } }); var render = (type) => styles[type] || styles.default; var symbols = Object.freeze({ aborted: c2.red(figures.cross), done: c2.green(figures.tick), exited: c2.yellow(figures.cross), default: c2.cyan("?") }); var symbol2 = (done, aborted2, exited) => aborted2 ? symbols.aborted : exited ? symbols.exited : done ? symbols.done : symbols.default; var delimiter = (completing) => c2.gray(completing ? figures.ellipsis : figures.pointerSmall); var item = (expandable, expanded) => c2.gray(expandable ? expanded ? figures.pointerSmall : "+" : figures.line); module2.exports = { styles, render, symbols, symbol: symbol2, delimiter, item }; } }); // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/util/lines.js var require_lines = __commonJS({ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/util/lines.js"(exports2, module2) { "use strict"; var strip2 = require_strip(); module2.exports = function(msg, perLine) { let lines = String(strip2(msg) || "").split(/\r?\n/); if (!perLine) return lines.length; return lines.map((l3) => Math.ceil(l3.length / perLine)).reduce((a3, b2) => a3 + b2); }; } }); // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/util/wrap.js var require_wrap = __commonJS({ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/util/wrap.js"(exports2, module2) { "use strict"; module2.exports = (msg, opts = {}) => { const tab = Number.isSafeInteger(parseInt(opts.margin)) ? new Array(parseInt(opts.margin)).fill(" ").join("") : opts.margin || ""; const width = opts.width; return (msg || "").split(/\r?\n/g).map((line) => line.split(/\s+/g).reduce((arr, w2) => { if (w2.length + tab.length >= width || arr[arr.length - 1].length + w2.length + 1 < width) arr[arr.length - 1] += ` ${w2}`; else arr.push(`${tab}${w2}`); return arr; }, [tab]).join("\n")).join("\n"); }; } }); // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/util/entriesToDisplay.js var require_entriesToDisplay = __commonJS({ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/util/entriesToDisplay.js"(exports2, module2) { "use strict"; module2.exports = (cursor, total, maxVisible) => { maxVisible = maxVisible || total; let startIndex = Math.min(total - maxVisible, cursor - Math.floor(maxVisible / 2)); if (startIndex < 0) startIndex = 0; let endIndex = Math.min(startIndex + maxVisible, total); return { startIndex, endIndex }; }; } }); // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/util/index.js var require_util = __commonJS({ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/util/index.js"(exports2, module2) { "use strict"; module2.exports = { action: require_action(), clear: require_clear(), style: require_style(), strip: require_strip(), figures: require_figures(), lines: require_lines(), wrap: require_wrap(), entriesToDisplay: require_entriesToDisplay() }; } }); // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/prompt.js var require_prompt = __commonJS({ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/prompt.js"(exports2, module2) { "use strict"; var readline = require("readline"); var _require = require_util(); var action2 = _require.action; var EventEmitter3 = require("events"); var _require2 = require_src(); var beep = _require2.beep; var cursor = _require2.cursor; var color = require_kleur(); var Prompt = class extends EventEmitter3 { constructor(opts = {}) { super(); this.firstRender = true; this.in = opts.stdin || process.stdin; this.out = opts.stdout || process.stdout; this.onRender = (opts.onRender || (() => void 0)).bind(this); const rl = readline.createInterface({ input: this.in, escapeCodeTimeout: 50 }); readline.emitKeypressEvents(this.in, rl); if (this.in.isTTY) this.in.setRawMode(true); const isSelect = ["SelectPrompt", "MultiselectPrompt"].indexOf(this.constructor.name) > -1; const keypress = (str2, key) => { let a3 = action2(key, isSelect); if (a3 === false) { this._ && this._(str2, key); } else if (typeof this[a3] === "function") { this[a3](key); } else { this.bell(); } }; this.close = () => { this.out.write(cursor.show); this.in.removeListener("keypress", keypress); if (this.in.isTTY) this.in.setRawMode(false); rl.close(); this.emit(this.aborted ? "abort" : this.exited ? "exit" : "submit", this.value); this.closed = true; }; this.in.on("keypress", keypress); } fire() { this.emit("state", { value: this.value, aborted: !!this.aborted, exited: !!this.exited }); } bell() { this.out.write(beep); } render() { this.onRender(color); if (this.firstRender) this.firstRender = false; } }; module2.exports = Prompt; } }); // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/text.js var require_text = __commonJS({ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/text.js"(exports2, module2) { "use strict"; function asyncGeneratorStep(gen, resolve2, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error46) { reject(error46); return; } if (info.done) { resolve2(value); } else { Promise.resolve(value).then(_next, _throw); } } function _asyncToGenerator(fn) { return function() { var self2 = this, args2 = arguments; return new Promise(function(resolve2, reject) { var gen = fn.apply(self2, args2); function _next(value) { asyncGeneratorStep(gen, resolve2, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve2, reject, _next, _throw, "throw", err); } _next(void 0); }); }; } var color = require_kleur(); var Prompt = require_prompt(); var _require = require_src(); var erase = _require.erase; var cursor = _require.cursor; var _require2 = require_util(); var style = _require2.style; var clear = _require2.clear; var lines = _require2.lines; var figures = _require2.figures; var TextPrompt = class extends Prompt { constructor(opts = {}) { super(opts); this.transform = style.render(opts.style); this.scale = this.transform.scale; this.msg = opts.message; this.initial = opts.initial || ``; this.validator = opts.validate || (() => true); this.value = ``; this.errorMsg = opts.error || `Please Enter A Valid Value`; this.cursor = Number(!!this.initial); this.cursorOffset = 0; this.clear = clear(``, this.out.columns); this.render(); } set value(v2) { if (!v2 && this.initial) { this.placeholder = true; this.rendered = color.gray(this.transform.render(this.initial)); } else { this.placeholder = false; this.rendered = this.transform.render(v2); } this._value = v2; this.fire(); } get value() { return this._value; } reset() { this.value = ``; this.cursor = Number(!!this.initial); this.cursorOffset = 0; this.fire(); this.render(); } exit() { this.abort(); } abort() { this.value = this.value || this.initial; this.done = this.aborted = true; this.error = false; this.red = false; this.fire(); this.render(); this.out.write("\n"); this.close(); } validate() { var _this = this; return _asyncToGenerator(function* () { let valid = yield _this.validator(_this.value); if (typeof valid === `string`) { _this.errorMsg = valid; valid = false; } _this.error = !valid; })(); } submit() { var _this2 = this; return _asyncToGenerator(function* () { _this2.value = _this2.value || _this2.initial; _this2.cursorOffset = 0; _this2.cursor = _this2.rendered.length; yield _this2.validate(); if (_this2.error) { _this2.red = true; _this2.fire(); _this2.render(); return; } _this2.done = true; _this2.aborted = false; _this2.fire(); _this2.render(); _this2.out.write("\n"); _this2.close(); })(); } next() { if (!this.placeholder) return this.bell(); this.value = this.initial; this.cursor = this.rendered.length; this.fire(); this.render(); } moveCursor(n3) { if (this.placeholder) return; this.cursor = this.cursor + n3; this.cursorOffset += n3; } _(c2, key) { let s1 = this.value.slice(0, this.cursor); let s22 = this.value.slice(this.cursor); this.value = `${s1}${c2}${s22}`; this.red = false; this.cursor = this.placeholder ? 0 : s1.length + 1; this.render(); } delete() { if (this.isCursorAtStart()) return this.bell(); let s1 = this.value.slice(0, this.cursor - 1); let s22 = this.value.slice(this.cursor); this.value = `${s1}${s22}`; this.red = false; if (this.isCursorAtStart()) { this.cursorOffset = 0; } else { this.cursorOffset++; this.moveCursor(-1); } this.render(); } deleteForward() { if (this.cursor * this.scale >= this.rendered.length || this.placeholder) return this.bell(); let s1 = this.value.slice(0, this.cursor); let s22 = this.value.slice(this.cursor + 1); this.value = `${s1}${s22}`; this.red = false; if (this.isCursorAtEnd()) { this.cursorOffset = 0; } else { this.cursorOffset++; } this.render(); } first() { this.cursor = 0; this.render(); } last() { this.cursor = this.value.length; this.render(); } left() { if (this.cursor <= 0 || this.placeholder) return this.bell(); this.moveCursor(-1); this.render(); } right() { if (this.cursor * this.scale >= this.rendered.length || this.placeholder) return this.bell(); this.moveCursor(1); this.render(); } isCursorAtStart() { return this.cursor === 0 || this.placeholder && this.cursor === 1; } isCursorAtEnd() { return this.cursor === this.rendered.length || this.placeholder && this.cursor === this.rendered.length + 1; } render() { if (this.closed) return; if (!this.firstRender) { if (this.outputError) this.out.write(cursor.down(lines(this.outputError, this.out.columns) - 1) + clear(this.outputError, this.out.columns)); this.out.write(clear(this.outputText, this.out.columns)); } super.render(); this.outputError = ""; this.outputText = [style.symbol(this.done, this.aborted), color.bold(this.msg), style.delimiter(this.done), this.red ? color.red(this.rendered) : this.rendered].join(` `); if (this.error) { this.outputError += this.errorMsg.split(` `).reduce((a3, l3, i2) => a3 + ` ${i2 ? " " : figures.pointerSmall} ${color.red().italic(l3)}`, ``); } this.out.write(erase.line + cursor.to(0) + this.outputText + cursor.save + this.outputError + cursor.restore + cursor.move(this.cursorOffset, 0)); } }; module2.exports = TextPrompt; } }); // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/select.js var require_select = __commonJS({ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/select.js"(exports2, module2) { "use strict"; var color = require_kleur(); var Prompt = require_prompt(); var _require = require_util(); var style = _require.style; var clear = _require.clear; var figures = _require.figures; var wrap4 = _require.wrap; var entriesToDisplay = _require.entriesToDisplay; var _require2 = require_src(); var cursor = _require2.cursor; var SelectPrompt = class extends Prompt { constructor(opts = {}) { super(opts); this.msg = opts.message; this.hint = opts.hint || "- Use arrow-keys. Return to submit."; this.warn = opts.warn || "- This option is disabled"; this.cursor = opts.initial || 0; this.choices = opts.choices.map((ch, idx) => { if (typeof ch === "string") ch = { title: ch, value: idx }; return { title: ch && (ch.title || ch.value || ch), value: ch && (ch.value === void 0 ? idx : ch.value), description: ch && ch.description, selected: ch && ch.selected, disabled: ch && ch.disabled }; }); this.optionsPerPage = opts.optionsPerPage || 10; this.value = (this.choices[this.cursor] || {}).value; this.clear = clear("", this.out.columns); this.render(); } moveCursor(n3) { this.cursor = n3; this.value = this.choices[n3].value; this.fire(); } reset() { this.moveCursor(0); this.fire(); this.render(); } exit() { this.abort(); } abort() { this.done = this.aborted = true; this.fire(); this.render(); this.out.write("\n"); this.close(); } submit() { if (!this.selection.disabled) { this.done = true; this.aborted = false; this.fire(); this.render(); this.out.write("\n"); this.close(); } else this.bell(); } first() { this.moveCursor(0); this.render(); } last() { this.moveCursor(this.choices.length - 1); this.render(); } up() { if (this.cursor === 0) { this.moveCursor(this.choices.length - 1); } else { this.moveCursor(this.cursor - 1); } this.render(); } down() { if (this.cursor === this.choices.length - 1) { this.moveCursor(0); } else { this.moveCursor(this.cursor + 1); } this.render(); } next() { this.moveCursor((this.cursor + 1) % this.choices.length); this.render(); } _(c2, key) { if (c2 === " ") return this.submit(); } get selection() { return this.choices[this.cursor]; } render() { if (this.closed) return; if (this.firstRender) this.out.write(cursor.hide); else this.out.write(clear(this.outputText, this.out.columns)); super.render(); let _entriesToDisplay = entriesToDisplay(this.cursor, this.choices.length, this.optionsPerPage), startIndex = _entriesToDisplay.startIndex, endIndex = _entriesToDisplay.endIndex; this.outputText = [style.symbol(this.done, this.aborted), color.bold(this.msg), style.delimiter(false), this.done ? this.selection.title : this.selection.disabled ? color.yellow(this.warn) : color.gray(this.hint)].join(" "); if (!this.done) { this.outputText += "\n"; for (let i2 = startIndex; i2 < endIndex; i2++) { let title, prefix, desc = "", v2 = this.choices[i2]; if (i2 === startIndex && startIndex > 0) { prefix = figures.arrowUp; } else if (i2 === endIndex - 1 && endIndex < this.choices.length) { prefix = figures.arrowDown; } else { prefix = " "; } if (v2.disabled) { title = this.cursor === i2 ? color.gray().underline(v2.title) : color.strikethrough().gray(v2.title); prefix = (this.cursor === i2 ? color.bold().gray(figures.pointer) + " " : " ") + prefix; } else { title = this.cursor === i2 ? color.cyan().underline(v2.title) : v2.title; prefix = (this.cursor === i2 ? color.cyan(figures.pointer) + " " : " ") + prefix; if (v2.description && this.cursor === i2) { desc = ` - ${v2.description}`; if (prefix.length + title.length + desc.length >= this.out.columns || v2.description.split(/\r?\n/).length > 1) { desc = "\n" + wrap4(v2.description, { margin: 3, width: this.out.columns }); } } } this.outputText += `${prefix} ${title}${color.gray(desc)} `; } } this.out.write(this.outputText); } }; module2.exports = SelectPrompt; } }); // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/toggle.js var require_toggle = __commonJS({ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/toggle.js"(exports2, module2) { "use strict"; var color = require_kleur(); var Prompt = require_prompt(); var _require = require_util(); var style = _require.style; var clear = _require.clear; var _require2 = require_src(); var cursor = _require2.cursor; var erase = _require2.erase; var TogglePrompt = class extends Prompt { constructor(opts = {}) { super(opts); this.msg = opts.message; this.value = !!opts.initial; this.active = opts.active || "on"; this.inactive = opts.inactive || "off"; this.initialValue = this.value; this.render(); } reset() { this.value = this.initialValue; this.fire(); this.render(); } exit() { this.abort(); } abort() { this.done = this.aborted = true; this.fire(); this.render(); this.out.write("\n"); this.close(); } submit() { this.done = true; this.aborted = false; this.fire(); this.render(); this.out.write("\n"); this.close(); } deactivate() { if (this.value === false) return this.bell(); this.value = false; this.render(); } activate() { if (this.value === true) return this.bell(); this.value = true; this.render(); } delete() { this.deactivate(); } left() { this.deactivate(); } right() { this.activate(); } down() { this.deactivate(); } up() { this.activate(); } next() { this.value = !this.value; this.fire(); this.render(); } _(c2, key) { if (c2 === " ") { this.value = !this.value; } else if (c2 === "1") { this.value = true; } else if (c2 === "0") { this.value = false; } else return this.bell(); this.render(); } render() { if (this.closed) return; if (this.firstRender) this.out.write(cursor.hide); else this.out.write(clear(this.outputText, this.out.columns)); super.render(); this.outputText = [style.symbol(this.done, this.aborted), color.bold(this.msg), style.delimiter(this.done), this.value ? this.inactive : color.cyan().underline(this.inactive), color.gray("/"), this.value ? color.cyan().underline(this.active) : this.active].join(" "); this.out.write(erase.line + cursor.to(0) + this.outputText); } }; module2.exports = TogglePrompt; } }); // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/datepart.js var require_datepart = __commonJS({ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/datepart.js"(exports2, module2) { "use strict"; var DatePart = class _DatePart { constructor({ token, date: date5, parts, locales }) { this.token = token; this.date = date5 || /* @__PURE__ */ new Date(); this.parts = parts || [this]; this.locales = locales || {}; } up() { } down() { } next() { const currentIdx = this.parts.indexOf(this); return this.parts.find((part, idx) => idx > currentIdx && part instanceof _DatePart); } setTo(val) { } prev() { let parts = [].concat(this.parts).reverse(); const currentIdx = parts.indexOf(this); return parts.find((part, idx) => idx > currentIdx && part instanceof _DatePart); } toString() { return String(this.date); } }; module2.exports = DatePart; } }); // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/meridiem.js var require_meridiem = __commonJS({ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/meridiem.js"(exports2, module2) { "use strict"; var DatePart = require_datepart(); var Meridiem = class extends DatePart { constructor(opts = {}) { super(opts); } up() { this.date.setHours((this.date.getHours() + 12) % 24); } down() { this.up(); } toString() { let meridiem = this.date.getHours() > 12 ? "pm" : "am"; return /\A/.test(this.token) ? meridiem.toUpperCase() : meridiem; } }; module2.exports = Meridiem; } }); // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/day.js var require_day = __commonJS({ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/day.js"(exports2, module2) { "use strict"; var DatePart = require_datepart(); var pos = (n3) => { n3 = n3 % 10; return n3 === 1 ? "st" : n3 === 2 ? "nd" : n3 === 3 ? "rd" : "th"; }; var Day = class extends DatePart { constructor(opts = {}) { super(opts); } up() { this.date.setDate(this.date.getDate() + 1); } down() { this.date.setDate(this.date.getDate() - 1); } setTo(val) { this.date.setDate(parseInt(val.substr(-2))); } toString() { let date5 = this.date.getDate(); let day2 = this.date.getDay(); return this.token === "DD" ? String(date5).padStart(2, "0") : this.token === "Do" ? date5 + pos(date5) : this.token === "d" ? day2 + 1 : this.token === "ddd" ? this.locales.weekdaysShort[day2] : this.token === "dddd" ? this.locales.weekdays[day2] : date5; } }; module2.exports = Day; } }); // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/hours.js var require_hours = __commonJS({ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/hours.js"(exports2, module2) { "use strict"; var DatePart = require_datepart(); var Hours = class extends DatePart { constructor(opts = {}) { super(opts); } up() { this.date.setHours(this.date.getHours() + 1); } down() { this.date.setHours(this.date.getHours() - 1); } setTo(val) { this.date.setHours(parseInt(val.substr(-2))); } toString() { let hours = this.date.getHours(); if (/h/.test(this.token)) hours = hours % 12 || 12; return this.token.length > 1 ? String(hours).padStart(2, "0") : hours; } }; module2.exports = Hours; } }); // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/milliseconds.js var require_milliseconds = __commonJS({ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/milliseconds.js"(exports2, module2) { "use strict"; var DatePart = require_datepart(); var Milliseconds = class extends DatePart { constructor(opts = {}) { super(opts); } up() { this.date.setMilliseconds(this.date.getMilliseconds() + 1); } down() { this.date.setMilliseconds(this.date.getMilliseconds() - 1); } setTo(val) { this.date.setMilliseconds(parseInt(val.substr(-this.token.length))); } toString() { return String(this.date.getMilliseconds()).padStart(4, "0").substr(0, this.token.length); } }; module2.exports = Milliseconds; } }); // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/minutes.js var require_minutes = __commonJS({ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/minutes.js"(exports2, module2) { "use strict"; var DatePart = require_datepart(); var Minutes = class extends DatePart { constructor(opts = {}) { super(opts); } up() { this.date.setMinutes(this.date.getMinutes() + 1); } down() { this.date.setMinutes(this.date.getMinutes() - 1); } setTo(val) { this.date.setMinutes(parseInt(val.substr(-2))); } toString() { let m2 = this.date.getMinutes(); return this.token.length > 1 ? String(m2).padStart(2, "0") : m2; } }; module2.exports = Minutes; } }); // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/month.js var require_month = __commonJS({ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/month.js"(exports2, module2) { "use strict"; var DatePart = require_datepart(); var Month = class extends DatePart { constructor(opts = {}) { super(opts); } up() { this.date.setMonth(this.date.getMonth() + 1); } down() { this.date.setMonth(this.date.getMonth() - 1); } setTo(val) { val = parseInt(val.substr(-2)) - 1; this.date.setMonth(val < 0 ? 0 : val); } toString() { let month = this.date.getMonth(); let tl = this.token.length; return tl === 2 ? String(month + 1).padStart(2, "0") : tl === 3 ? this.locales.monthsShort[month] : tl === 4 ? this.locales.months[month] : String(month + 1); } }; module2.exports = Month; } }); // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/seconds.js var require_seconds = __commonJS({ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/seconds.js"(exports2, module2) { "use strict"; var DatePart = require_datepart(); var Seconds = class extends DatePart { constructor(opts = {}) { super(opts); } up() { this.date.setSeconds(this.date.getSeconds() + 1); } down() { this.date.setSeconds(this.date.getSeconds() - 1); } setTo(val) { this.date.setSeconds(parseInt(val.substr(-2))); } toString() { let s3 = this.date.getSeconds(); return this.token.length > 1 ? String(s3).padStart(2, "0") : s3; } }; module2.exports = Seconds; } }); // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/year.js var require_year = __commonJS({ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/year.js"(exports2, module2) { "use strict"; var DatePart = require_datepart(); var Year = class extends DatePart { constructor(opts = {}) { super(opts); } up() { this.date.setFullYear(this.date.getFullYear() + 1); } down() { this.date.setFullYear(this.date.getFullYear() - 1); } setTo(val) { this.date.setFullYear(val.substr(-4)); } toString() { let year2 = String(this.date.getFullYear()).padStart(4, "0"); return this.token.length === 2 ? year2.substr(-2) : year2; } }; module2.exports = Year; } }); // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/index.js var require_dateparts = __commonJS({ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/dateparts/index.js"(exports2, module2) { "use strict"; module2.exports = { DatePart: require_datepart(), Meridiem: require_meridiem(), Day: require_day(), Hours: require_hours(), Milliseconds: require_milliseconds(), Minutes: require_minutes(), Month: require_month(), Seconds: require_seconds(), Year: require_year() }; } }); // ../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/date.js var require_date = __commonJS({ "../../node_modules/.pnpm/prompts@2.4.2/node_modules/prompts/dist/elements/date.js"(exports2, module2) { "use strict"; function asyncGeneratorStep(gen, resolve2, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error46) { reject(error46); return; } if (info.done) { resolve2(value); } else { Promise.resolve(value).then(_next, _throw); } } function _asyncToGenerator(fn) { return function() { var self2 = this, args2 = arguments; return new Promise(function(resolve2, reject) { var gen = fn.apply(self2, args2); function _next(value) { asyncGeneratorStep(gen, resolve2, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve2, reject, _next, _throw, "throw", err); } _next(void 0); }); }; } var color = require_kleur(); var Prompt = require_prompt(); var _require = require_util(); var style = _require.style; var clear = _require.clear; var figures = _require.figures; var _require2 = require_src(); var erase = _require2.erase; var cursor = _require2.cursor; var _require3 = require_dateparts(); var DatePart = _require3.DatePart; var Meridiem = _require3.Meridiem; var Day = _require3.Day; var Hours = _require3.Hours; var Milliseconds = _require3.Milliseconds; var Minutes = _require3.Minutes; var Month = _require3.Month; var Seconds = _require3.Seconds; var Year = _require3.Year; var regex2 = /\\(.)|"((?:\\["\\]|[^"])+)"|(D[Do]?|d{3,4}|d)|(M{1,4})|(YY(?:YY)?)|([aA])|([Hh]{1,2})|(m{1,2})|(s{1,2})|(S{1,4})|./g; var regexGroups = { 1: ({ token }) => token.replace(/\\(.)/g, "$1"), 2: (opts) => new Day(opts), // Day // TODO 3: (opts) => new Month(opts), // Month 4: (opts) => new Year(opts), // Year 5: (opts) => new Meridiem(opts), // AM/PM // TODO (special) 6: (opts) => new Hours(opts), // Hours 7: (opts) => new Minutes(opts), // Minutes 8: (opts) => new Seconds(opts), // Seconds 9: (opts) => new Milliseconds(opts) // Fractional seconds }; var dfltLocales = { months: "January,February,March,April,May,June,July,August,September,October,November,December".split(","), monthsShort: "Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec".split(","), weekdays: "Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday".split(","), weekdaysShort: "Sun,Mon,Tue,Wed,Thu,Fri,Sat".split(",") }; var DatePrompt = class extends Prompt { constructor(opts = {}) { super(opts); this.msg = opts.message; this.cursor = 0; this.typed = ""; this.locales = Object.assign(dfltLocales, opts.locales); this._date = opts.initial || /* @__PURE__ */ new Date(); this.errorMsg = opts.error || "Please Enter A Valid Value"; this.validator = opts.validate || (() => true); this.mask = opts.mask || "YYYY-MM-DD HH:mm:ss"; this.clear = clear("", this.out.columns); this.render(); } get value() { return this.date; } get date() { return this._date; } set date(date5) { if (date5) this._date.setTime(date5.getTime()); } set mask(mask) { let result; this.parts = []; while (result = regex2.exec(mask)) { let match2 = result.shift(); let idx = result.findIndex((gr2) => gr2 != null); this.parts.push(idx in regexGroups ? regexGroups[idx]({ token: result[idx] || match2, date: this.date, parts: this.parts, locales: this.locales }) : result[idx] || match2); } let parts = this.parts.reduce((arr, i2) => { if (typeof i2 === "string" && typeof arr[arr.length - 1] === "string") arr[arr.length - 1] += i2; else arr.push(i2); return arr; }, []); this.parts.splice(0); this.parts.push(...parts); this.reset(); } moveCursor(n3) { this.typed = ""; this.cursor = n3; this.fire(); } reset() { this.moveCursor(this.parts.findIndex((p2) => p2 instanceof DatePart)); this.fire(); this.render(); } exit() { this.abort(); } abort() { this.done = this.aborted = true; this.error = false; this.fire(); this.render(); this.out.write("\n"); this.close(); } validate() { var _this = this; return _asyncToGenerator(function* () { let valid = yield _this.validator(_this.value); if (typeof valid === "string") { _this.errorMsg = valid; valid = false; } _this.error = !valid; })(); } submit() { var _this2 = this; return _asyncToGenerator(function* () { yield _this2.validate(); if (_this2.error) { _this2.color = "red"; _this2.fire(); _this2.render(); return; } _this2.done = true; _this2.aborted = false; _this2.fire(); _this2.render(); _this2.out.write("\n"); _this2.close(); })(); } up() { this.typed = ""; this.parts[this.cursor].up(); this.render(); } down() { this.typed = ""; this.parts[this.cursor].down(); this.render(); } left() { let prev = this.parts[this.cursor].prev(); if (prev == null) return this.bell(); this.moveCursor(this.parts.indexOf(prev)); this.render(); } right() { let next = this.parts[this.cursor].next(); if (next == null) return this.bell(); this.moveCursor(this.parts.indexOf(next)); this.render(); } next() { let next = this.parts[this.cursor].next(); this.moveCursor(next ? this.parts.indexOf(next) : this.parts.findIndex((part) => part instanceof DatePart)); this.render(); } _(c2) { if (/\d/.test(c2)) { this.typed += c2; this.parts[this.cursor].setTo(this.typed); this.render(); } }