"use strict"; 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 __typeError = (msg) => { throw TypeError(msg); }; var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; 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, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, 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 __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg); var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)); var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value); var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value); var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method); // node_modules/.pnpm/eventemitter3@5.0.1/node_modules/eventemitter3/index.js var require_eventemitter3 = __commonJS({ "node_modules/.pnpm/eventemitter3@5.0.1/node_modules/eventemitter3/index.js"(exports2, module2) { "use strict"; var has = Object.prototype.hasOwnProperty; var prefix = "~"; function Events() { } if (Object.create) { Events.prototype = /* @__PURE__ */ Object.create(null); if (!new Events().__proto__) prefix = false; } function EE(fn, context, once) { this.fn = fn; this.context = context; this.once = once || false; } function addListener(emitter, event, fn, context, once) { if (typeof fn !== "function") { throw new TypeError("The listener must be a function"); } var listener = new EE(fn, context || emitter, once), evt = prefix ? prefix + event : event; if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++; else if (!emitter._events[evt].fn) emitter._events[evt].push(listener); else emitter._events[evt] = [emitter._events[evt], listener]; return emitter; } function clearEvent(emitter, evt) { if (--emitter._eventsCount === 0) emitter._events = new Events(); else delete emitter._events[evt]; } function EventEmitter2() { this._events = new Events(); this._eventsCount = 0; } EventEmitter2.prototype.eventNames = function eventNames() { var names = [], events, name; if (this._eventsCount === 0) return names; for (name in events = this._events) { if (has.call(events, name)) names.push(prefix ? name.slice(1) : name); } if (Object.getOwnPropertySymbols) { return names.concat(Object.getOwnPropertySymbols(events)); } return names; }; EventEmitter2.prototype.listeners = function listeners(event) { var evt = prefix ? prefix + event : event, handlers = this._events[evt]; if (!handlers) return []; if (handlers.fn) return [handlers.fn]; for (var i = 0, l2 = handlers.length, ee = new Array(l2); i < l2; i++) { ee[i] = handlers[i].fn; } return ee; }; EventEmitter2.prototype.listenerCount = function listenerCount(event) { var evt = prefix ? prefix + event : event, listeners = this._events[evt]; if (!listeners) return 0; if (listeners.fn) return 1; return listeners.length; }; EventEmitter2.prototype.emit = function emit(event, a1, a2, a3, a4, a5) { var evt = prefix ? prefix + event : event; if (!this._events[evt]) return false; var listeners = this._events[evt], len = arguments.length, args, i; if (listeners.fn) { if (listeners.once) this.removeListener(event, listeners.fn, void 0, true); switch (len) { case 1: return listeners.fn.call(listeners.context), true; case 2: return listeners.fn.call(listeners.context, a1), true; case 3: return listeners.fn.call(listeners.context, a1, a2), true; case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true; case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true; case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true; } for (i = 1, args = new Array(len - 1); i < len; i++) { args[i - 1] = arguments[i]; } listeners.fn.apply(listeners.context, args); } else { var length = listeners.length, j; for (i = 0; i < length; i++) { if (listeners[i].once) this.removeListener(event, listeners[i].fn, void 0, true); switch (len) { case 1: listeners[i].fn.call(listeners[i].context); break; case 2: listeners[i].fn.call(listeners[i].context, a1); break; case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break; case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break; default: if (!args) for (j = 1, args = new Array(len - 1); j < len; j++) { args[j - 1] = arguments[j]; } listeners[i].fn.apply(listeners[i].context, args); } } } return true; }; EventEmitter2.prototype.on = function on(event, fn, context) { return addListener(this, event, fn, context, false); }; EventEmitter2.prototype.once = function once(event, fn, context) { return addListener(this, event, fn, context, true); }; EventEmitter2.prototype.removeListener = function removeListener(event, fn, context, once) { var evt = prefix ? prefix + event : event; if (!this._events[evt]) return this; if (!fn) { clearEvent(this, evt); return this; } var listeners = this._events[evt]; if (listeners.fn) { if (listeners.fn === fn && (!once || listeners.once) && (!context || listeners.context === context)) { clearEvent(this, evt); } } else { for (var i = 0, events = [], length = listeners.length; i < length; i++) { if (listeners[i].fn !== fn || once && !listeners[i].once || context && listeners[i].context !== context) { events.push(listeners[i]); } } if (events.length) this._events[evt] = events.length === 1 ? events[0] : events; else clearEvent(this, evt); } return this; }; EventEmitter2.prototype.removeAllListeners = function removeAllListeners(event) { var evt; if (event) { evt = prefix ? prefix + event : event; if (this._events[evt]) clearEvent(this, evt); } else { this._events = new Events(); this._eventsCount = 0; } return this; }; EventEmitter2.prototype.off = EventEmitter2.prototype.removeListener; EventEmitter2.prototype.addListener = EventEmitter2.prototype.on; EventEmitter2.prefixed = prefix; EventEmitter2.EventEmitter = EventEmitter2; if ("undefined" !== typeof module2) { module2.exports = EventEmitter2; } } }); // node_modules/.pnpm/rfdc@1.4.1/node_modules/rfdc/index.js var require_rfdc = __commonJS({ "node_modules/.pnpm/rfdc@1.4.1/node_modules/rfdc/index.js"(exports2, module2) { "use strict"; module2.exports = rfdc2; function copyBuffer(cur) { if (cur instanceof Buffer) { return Buffer.from(cur); } return new cur.constructor(cur.buffer.slice(), cur.byteOffset, cur.length); } function rfdc2(opts) { opts = opts || {}; if (opts.circles) return rfdcCircles(opts); const constructorHandlers = /* @__PURE__ */ new Map(); constructorHandlers.set(Date, (o) => new Date(o)); constructorHandlers.set(Map, (o, fn) => new Map(cloneArray(Array.from(o), fn))); constructorHandlers.set(Set, (o, fn) => new Set(cloneArray(Array.from(o), fn))); if (opts.constructorHandlers) { for (const handler2 of opts.constructorHandlers) { constructorHandlers.set(handler2[0], handler2[1]); } } let handler = null; return opts.proto ? cloneProto : clone2; function cloneArray(a2, fn) { const keys = Object.keys(a2); const a22 = new Array(keys.length); for (let i = 0; i < keys.length; i++) { const k2 = keys[i]; const cur = a2[k2]; if (typeof cur !== "object" || cur === null) { a22[k2] = cur; } else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) { a22[k2] = handler(cur, fn); } else if (ArrayBuffer.isView(cur)) { a22[k2] = copyBuffer(cur); } else { a22[k2] = fn(cur); } } return a22; } function clone2(o) { if (typeof o !== "object" || o === null) return o; if (Array.isArray(o)) return cloneArray(o, clone2); if (o.constructor !== Object && (handler = constructorHandlers.get(o.constructor))) { return handler(o, clone2); } const o2 = {}; for (const k2 in o) { if (Object.hasOwnProperty.call(o, k2) === false) continue; const cur = o[k2]; if (typeof cur !== "object" || cur === null) { o2[k2] = cur; } else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) { o2[k2] = handler(cur, clone2); } else if (ArrayBuffer.isView(cur)) { o2[k2] = copyBuffer(cur); } else { o2[k2] = clone2(cur); } } return o2; } function cloneProto(o) { if (typeof o !== "object" || o === null) return o; if (Array.isArray(o)) return cloneArray(o, cloneProto); if (o.constructor !== Object && (handler = constructorHandlers.get(o.constructor))) { return handler(o, cloneProto); } const o2 = {}; for (const k2 in o) { const cur = o[k2]; if (typeof cur !== "object" || cur === null) { o2[k2] = cur; } else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) { o2[k2] = handler(cur, cloneProto); } else if (ArrayBuffer.isView(cur)) { o2[k2] = copyBuffer(cur); } else { o2[k2] = cloneProto(cur); } } return o2; } } function rfdcCircles(opts) { const refs = []; const refsNew = []; const constructorHandlers = /* @__PURE__ */ new Map(); constructorHandlers.set(Date, (o) => new Date(o)); constructorHandlers.set(Map, (o, fn) => new Map(cloneArray(Array.from(o), fn))); constructorHandlers.set(Set, (o, fn) => new Set(cloneArray(Array.from(o), fn))); if (opts.constructorHandlers) { for (const handler2 of opts.constructorHandlers) { constructorHandlers.set(handler2[0], handler2[1]); } } let handler = null; return opts.proto ? cloneProto : clone2; function cloneArray(a2, fn) { const keys = Object.keys(a2); const a22 = new Array(keys.length); for (let i = 0; i < keys.length; i++) { const k2 = keys[i]; const cur = a2[k2]; if (typeof cur !== "object" || cur === null) { a22[k2] = cur; } else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) { a22[k2] = handler(cur, fn); } else if (ArrayBuffer.isView(cur)) { a22[k2] = copyBuffer(cur); } else { const index = refs.indexOf(cur); if (index !== -1) { a22[k2] = refsNew[index]; } else { a22[k2] = fn(cur); } } } return a22; } function clone2(o) { if (typeof o !== "object" || o === null) return o; if (Array.isArray(o)) return cloneArray(o, clone2); if (o.constructor !== Object && (handler = constructorHandlers.get(o.constructor))) { return handler(o, clone2); } const o2 = {}; refs.push(o); refsNew.push(o2); for (const k2 in o) { if (Object.hasOwnProperty.call(o, k2) === false) continue; const cur = o[k2]; if (typeof cur !== "object" || cur === null) { o2[k2] = cur; } else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) { o2[k2] = handler(cur, clone2); } else if (ArrayBuffer.isView(cur)) { o2[k2] = copyBuffer(cur); } else { const i = refs.indexOf(cur); if (i !== -1) { o2[k2] = refsNew[i]; } else { o2[k2] = clone2(cur); } } } refs.pop(); refsNew.pop(); return o2; } function cloneProto(o) { if (typeof o !== "object" || o === null) return o; if (Array.isArray(o)) return cloneArray(o, cloneProto); if (o.constructor !== Object && (handler = constructorHandlers.get(o.constructor))) { return handler(o, cloneProto); } const o2 = {}; refs.push(o); refsNew.push(o2); for (const k2 in o) { const cur = o[k2]; if (typeof cur !== "object" || cur === null) { o2[k2] = cur; } else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) { o2[k2] = handler(cur, cloneProto); } else if (ArrayBuffer.isView(cur)) { o2[k2] = copyBuffer(cur); } else { const i = refs.indexOf(cur); if (i !== -1) { o2[k2] = refsNew[i]; } else { o2[k2] = cloneProto(cur); } } } refs.pop(); refsNew.pop(); return o2; } } } }); // node_modules/.pnpm/environment@1.1.0/node_modules/environment/index.js var isBrowser, isNode, isBun, isDeno, isElectron, isJsDom, isWebWorker, isDedicatedWorker, isSharedWorker, isServiceWorker, platform2, isMacOs, isWindows2, isLinux, isIos, isAndroid; var init_environment = __esm({ "node_modules/.pnpm/environment@1.1.0/node_modules/environment/index.js"() { "use strict"; isBrowser = globalThis.window?.document !== void 0; isNode = globalThis.process?.versions?.node !== void 0; isBun = globalThis.process?.versions?.bun !== void 0; isDeno = globalThis.Deno?.version?.deno !== void 0; isElectron = globalThis.process?.versions?.electron !== void 0; isJsDom = globalThis.navigator?.userAgent?.includes("jsdom") === true; isWebWorker = typeof WorkerGlobalScope !== "undefined" && globalThis instanceof WorkerGlobalScope; isDedicatedWorker = typeof DedicatedWorkerGlobalScope !== "undefined" && globalThis instanceof DedicatedWorkerGlobalScope; isSharedWorker = typeof SharedWorkerGlobalScope !== "undefined" && globalThis instanceof SharedWorkerGlobalScope; isServiceWorker = typeof ServiceWorkerGlobalScope !== "undefined" && globalThis instanceof ServiceWorkerGlobalScope; platform2 = globalThis.navigator?.userAgentData?.platform; isMacOs = platform2 === "macOS" || globalThis.navigator?.platform === "MacIntel" || globalThis.navigator?.userAgent?.includes(" Mac ") === true || globalThis.process?.platform === "darwin"; isWindows2 = platform2 === "Windows" || globalThis.navigator?.platform === "Win32" || globalThis.process?.platform === "win32"; isLinux = platform2 === "Linux" || globalThis.navigator?.platform?.startsWith("Linux") === true || globalThis.navigator?.userAgent?.includes(" Linux ") === true || globalThis.process?.platform === "linux"; isIos = platform2 === "iOS" || globalThis.navigator?.platform === "MacIntel" && globalThis.navigator?.maxTouchPoints > 1 || /iPad|iPhone|iPod/.test(globalThis.navigator?.platform); isAndroid = platform2 === "Android" || globalThis.navigator?.platform === "Android" || globalThis.navigator?.userAgent?.includes(" Android ") === true || globalThis.process?.platform === "android"; } }); // node_modules/.pnpm/ansi-escapes@7.0.0/node_modules/ansi-escapes/base.js var base_exports = {}; __export(base_exports, { beep: () => beep, clearScreen: () => clearScreen, clearTerminal: () => clearTerminal, cursorBackward: () => cursorBackward, cursorDown: () => cursorDown, cursorForward: () => cursorForward, cursorGetPosition: () => cursorGetPosition, cursorHide: () => cursorHide, cursorLeft: () => cursorLeft, cursorMove: () => cursorMove, cursorNextLine: () => cursorNextLine, cursorPrevLine: () => cursorPrevLine, cursorRestorePosition: () => cursorRestorePosition, cursorSavePosition: () => cursorSavePosition, cursorShow: () => cursorShow, cursorTo: () => cursorTo, cursorUp: () => cursorUp, enterAlternativeScreen: () => enterAlternativeScreen, eraseDown: () => eraseDown, eraseEndLine: () => eraseEndLine, eraseLine: () => eraseLine, eraseLines: () => eraseLines, eraseScreen: () => eraseScreen, eraseStartLine: () => eraseStartLine, eraseUp: () => eraseUp, exitAlternativeScreen: () => exitAlternativeScreen, iTerm: () => iTerm, image: () => image, link: () => link, scrollDown: () => scrollDown, scrollUp: () => scrollUp }); var import_node_process, ESC, OSC, BEL, SEP, isTerminalApp, isWindows3, cwdFunction, cursorTo, cursorMove, cursorUp, cursorDown, cursorForward, cursorBackward, cursorLeft, cursorSavePosition, cursorRestorePosition, cursorGetPosition, cursorNextLine, cursorPrevLine, cursorHide, cursorShow, eraseLines, eraseEndLine, eraseStartLine, eraseLine, eraseDown, eraseUp, eraseScreen, scrollUp, scrollDown, clearScreen, clearTerminal, enterAlternativeScreen, exitAlternativeScreen, beep, link, image, iTerm; var init_base = __esm({ "node_modules/.pnpm/ansi-escapes@7.0.0/node_modules/ansi-escapes/base.js"() { "use strict"; import_node_process = __toESM(require("process"), 1); init_environment(); ESC = "\x1B["; OSC = "\x1B]"; BEL = "\x07"; SEP = ";"; isTerminalApp = !isBrowser && import_node_process.default.env.TERM_PROGRAM === "Apple_Terminal"; isWindows3 = !isBrowser && import_node_process.default.platform === "win32"; cwdFunction = isBrowser ? () => { throw new Error("`process.cwd()` only works in Node.js, not the browser."); } : import_node_process.default.cwd; cursorTo = (x, y) => { if (typeof x !== "number") { throw new TypeError("The `x` argument is required"); } if (typeof y !== "number") { return ESC + (x + 1) + "G"; } return ESC + (y + 1) + SEP + (x + 1) + "H"; }; cursorMove = (x, y) => { if (typeof x !== "number") { throw new TypeError("The `x` argument is required"); } let returnValue = ""; if (x < 0) { returnValue += ESC + -x + "D"; } else if (x > 0) { returnValue += ESC + x + "C"; } if (y < 0) { returnValue += ESC + -y + "A"; } else if (y > 0) { returnValue += ESC + y + "B"; } return returnValue; }; cursorUp = (count = 1) => ESC + count + "A"; cursorDown = (count = 1) => ESC + count + "B"; cursorForward = (count = 1) => ESC + count + "C"; cursorBackward = (count = 1) => ESC + count + "D"; cursorLeft = ESC + "G"; cursorSavePosition = isTerminalApp ? "\x1B7" : ESC + "s"; cursorRestorePosition = isTerminalApp ? "\x1B8" : ESC + "u"; cursorGetPosition = ESC + "6n"; cursorNextLine = ESC + "E"; cursorPrevLine = ESC + "F"; cursorHide = ESC + "?25l"; cursorShow = ESC + "?25h"; eraseLines = (count) => { let clear = ""; for (let i = 0; i < count; i++) { clear += eraseLine + (i < count - 1 ? cursorUp() : ""); } if (count) { clear += cursorLeft; } return clear; }; eraseEndLine = ESC + "K"; eraseStartLine = ESC + "1K"; eraseLine = ESC + "2K"; eraseDown = ESC + "J"; eraseUp = ESC + "1J"; eraseScreen = ESC + "2J"; scrollUp = ESC + "S"; scrollDown = ESC + "T"; clearScreen = "\x1Bc"; clearTerminal = isWindows3 ? `${eraseScreen}${ESC}0f` : `${eraseScreen}${ESC}3J${ESC}H`; enterAlternativeScreen = ESC + "?1049h"; exitAlternativeScreen = ESC + "?1049l"; beep = BEL; link = (text, url) => [ OSC, "8", SEP, SEP, url, BEL, text, OSC, "8", SEP, SEP, BEL ].join(""); image = (data, options = {}) => { let returnValue = `${OSC}1337;File=inline=1`; if (options.width) { returnValue += `;width=${options.width}`; } if (options.height) { returnValue += `;height=${options.height}`; } if (options.preserveAspectRatio === false) { returnValue += ";preserveAspectRatio=0"; } return returnValue + ":" + Buffer.from(data).toString("base64") + BEL; }; iTerm = { setCwd: (cwd = cwdFunction()) => `${OSC}50;CurrentDir=${cwd}${BEL}`, annotation(message, options = {}) { let returnValue = `${OSC}1337;`; const hasX = options.x !== void 0; const hasY = options.y !== void 0; if ((hasX || hasY) && !(hasX && hasY && options.length !== void 0)) { throw new Error("`x`, `y` and `length` must be defined when `x` or `y` is defined"); } message = message.replaceAll("|", ""); returnValue += options.isHidden ? "AddHiddenAnnotation=" : "AddAnnotation="; if (options.length > 0) { returnValue += (hasX ? [message, options.length, options.x, options.y] : [options.length, message]).join("|"); } else { returnValue += message; } return returnValue + BEL; } }; } }); // node_modules/.pnpm/ansi-escapes@7.0.0/node_modules/ansi-escapes/index.js var init_ansi_escapes = __esm({ "node_modules/.pnpm/ansi-escapes@7.0.0/node_modules/ansi-escapes/index.js"() { "use strict"; init_base(); init_base(); } }); // node_modules/.pnpm/mimic-function@5.0.1/node_modules/mimic-function/index.js function mimicFunction(to, from, { ignoreNonConfigurable = false } = {}) { const { name } = to; for (const property of Reflect.ownKeys(from)) { copyProperty(to, from, property, ignoreNonConfigurable); } changePrototype(to, from); changeToString(to, from, name); return to; } var copyProperty, canCopyProperty, changePrototype, wrappedToString, toStringDescriptor, toStringName, changeToString; var init_mimic_function = __esm({ "node_modules/.pnpm/mimic-function@5.0.1/node_modules/mimic-function/index.js"() { "use strict"; copyProperty = (to, from, property, ignoreNonConfigurable) => { if (property === "length" || property === "prototype") { return; } if (property === "arguments" || property === "caller") { return; } const toDescriptor = Object.getOwnPropertyDescriptor(to, property); const fromDescriptor = Object.getOwnPropertyDescriptor(from, property); if (!canCopyProperty(toDescriptor, fromDescriptor) && ignoreNonConfigurable) { return; } Object.defineProperty(to, property, fromDescriptor); }; canCopyProperty = function(toDescriptor, fromDescriptor) { return toDescriptor === void 0 || toDescriptor.configurable || toDescriptor.writable === fromDescriptor.writable && toDescriptor.enumerable === fromDescriptor.enumerable && toDescriptor.configurable === fromDescriptor.configurable && (toDescriptor.writable || toDescriptor.value === fromDescriptor.value); }; changePrototype = (to, from) => { const fromPrototype = Object.getPrototypeOf(from); if (fromPrototype === Object.getPrototypeOf(to)) { return; } Object.setPrototypeOf(to, fromPrototype); }; wrappedToString = (withName, fromBody) => `/* Wrapped ${withName}*/ ${fromBody}`; toStringDescriptor = Object.getOwnPropertyDescriptor(Function.prototype, "toString"); toStringName = Object.getOwnPropertyDescriptor(Function.prototype.toString, "name"); changeToString = (to, from, name) => { const withName = name === "" ? "" : `with ${name.trim()}() `; const newToString = wrappedToString.bind(null, withName, from.toString()); Object.defineProperty(newToString, "name", toStringName); const { writable, enumerable, configurable } = toStringDescriptor; Object.defineProperty(to, "toString", { value: newToString, writable, enumerable, configurable }); }; } }); // node_modules/.pnpm/onetime@7.0.0/node_modules/onetime/index.js var calledFunctions, onetime, onetime_default; var init_onetime = __esm({ "node_modules/.pnpm/onetime@7.0.0/node_modules/onetime/index.js"() { "use strict"; init_mimic_function(); calledFunctions = /* @__PURE__ */ new WeakMap(); onetime = (function_, options = {}) => { if (typeof function_ !== "function") { throw new TypeError("Expected a function"); } let returnValue; let callCount = 0; const functionName = function_.displayName || function_.name || ""; const onetime2 = function(...arguments_) { calledFunctions.set(onetime2, ++callCount); if (callCount === 1) { returnValue = function_.apply(this, arguments_); function_ = void 0; } else if (options.throw === true) { throw new Error(`Function \`${functionName}\` can only be called once`); } return returnValue; }; mimicFunction(onetime2, function_); calledFunctions.set(onetime2, callCount); return onetime2; }; onetime.callCount = (function_) => { if (!calledFunctions.has(function_)) { throw new Error(`The given function \`${function_.name}\` is not wrapped by the \`onetime\` package`); } return calledFunctions.get(function_); }; onetime_default = onetime; } }); // node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/signals.js var signals; var init_signals = __esm({ "node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/signals.js"() { "use strict"; signals = []; signals.push("SIGHUP", "SIGINT", "SIGTERM"); if (process.platform !== "win32") { signals.push( "SIGALRM", "SIGABRT", "SIGVTALRM", "SIGXCPU", "SIGXFSZ", "SIGUSR2", "SIGTRAP", "SIGSYS", "SIGQUIT", "SIGIOT" // should detect profiler and enable/disable accordingly. // see #21 // 'SIGPROF' ); } if (process.platform === "linux") { signals.push("SIGIO", "SIGPOLL", "SIGPWR", "SIGSTKFLT"); } } }); // node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/index.js var processOk, kExitEmitter, global, ObjectDefineProperty, Emitter, SignalExitBase, signalExitWrap, SignalExitFallback, _hupSig, _emitter, _process, _originalProcessEmit, _originalProcessReallyExit, _sigListeners, _loaded, _SignalExit_instances, processReallyExit_fn, processEmit_fn, SignalExit, process3, onExit, load, unload; var init_mjs = __esm({ "node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/index.js"() { "use strict"; init_signals(); processOk = (process11) => !!process11 && typeof process11 === "object" && typeof process11.removeListener === "function" && typeof process11.emit === "function" && typeof process11.reallyExit === "function" && typeof process11.listeners === "function" && typeof process11.kill === "function" && typeof process11.pid === "number" && typeof process11.on === "function"; kExitEmitter = Symbol.for("signal-exit emitter"); global = globalThis; ObjectDefineProperty = Object.defineProperty.bind(Object); Emitter = class { constructor() { __publicField(this, "emitted", { afterExit: false, exit: false }); __publicField(this, "listeners", { afterExit: [], exit: [] }); __publicField(this, "count", 0); __publicField(this, "id", Math.random()); if (global[kExitEmitter]) { return global[kExitEmitter]; } ObjectDefineProperty(global, kExitEmitter, { value: this, writable: false, enumerable: false, configurable: false }); } on(ev, fn) { this.listeners[ev].push(fn); } removeListener(ev, fn) { const list = this.listeners[ev]; const i = list.indexOf(fn); if (i === -1) { return; } if (i === 0 && list.length === 1) { list.length = 0; } else { list.splice(i, 1); } } emit(ev, code, signal) { if (this.emitted[ev]) { return false; } this.emitted[ev] = true; let ret = false; for (const fn of this.listeners[ev]) { ret = fn(code, signal) === true || ret; } if (ev === "exit") { ret = this.emit("afterExit", code, signal) || ret; } return ret; } }; SignalExitBase = class { }; signalExitWrap = (handler) => { return { onExit(cb, opts) { return handler.onExit(cb, opts); }, load() { return handler.load(); }, unload() { return handler.unload(); } }; }; SignalExitFallback = class extends SignalExitBase { onExit() { return () => { }; } load() { } unload() { } }; SignalExit = class extends SignalExitBase { constructor(process11) { super(); __privateAdd(this, _SignalExit_instances); // "SIGHUP" throws an `ENOSYS` error on Windows, // so use a supported signal instead /* c8 ignore start */ __privateAdd(this, _hupSig, process3.platform === "win32" ? "SIGINT" : "SIGHUP"); /* c8 ignore stop */ __privateAdd(this, _emitter, new Emitter()); __privateAdd(this, _process); __privateAdd(this, _originalProcessEmit); __privateAdd(this, _originalProcessReallyExit); __privateAdd(this, _sigListeners, {}); __privateAdd(this, _loaded, false); __privateSet(this, _process, process11); __privateSet(this, _sigListeners, {}); for (const sig of signals) { __privateGet(this, _sigListeners)[sig] = () => { const listeners = __privateGet(this, _process).listeners(sig); let { count } = __privateGet(this, _emitter); const p = process11; if (typeof p.__signal_exit_emitter__ === "object" && typeof p.__signal_exit_emitter__.count === "number") { count += p.__signal_exit_emitter__.count; } if (listeners.length === count) { this.unload(); const ret = __privateGet(this, _emitter).emit("exit", null, sig); const s = sig === "SIGHUP" ? __privateGet(this, _hupSig) : sig; if (!ret) process11.kill(process11.pid, s); } }; } __privateSet(this, _originalProcessReallyExit, process11.reallyExit); __privateSet(this, _originalProcessEmit, process11.emit); } onExit(cb, opts) { if (!processOk(__privateGet(this, _process))) { return () => { }; } if (__privateGet(this, _loaded) === false) { this.load(); } const ev = opts?.alwaysLast ? "afterExit" : "exit"; __privateGet(this, _emitter).on(ev, cb); return () => { __privateGet(this, _emitter).removeListener(ev, cb); if (__privateGet(this, _emitter).listeners["exit"].length === 0 && __privateGet(this, _emitter).listeners["afterExit"].length === 0) { this.unload(); } }; } load() { if (__privateGet(this, _loaded)) { return; } __privateSet(this, _loaded, true); __privateGet(this, _emitter).count += 1; for (const sig of signals) { try { const fn = __privateGet(this, _sigListeners)[sig]; if (fn) __privateGet(this, _process).on(sig, fn); } catch (_) { } } __privateGet(this, _process).emit = (ev, ...a2) => { return __privateMethod(this, _SignalExit_instances, processEmit_fn).call(this, ev, ...a2); }; __privateGet(this, _process).reallyExit = (code) => { return __privateMethod(this, _SignalExit_instances, processReallyExit_fn).call(this, code); }; } unload() { if (!__privateGet(this, _loaded)) { return; } __privateSet(this, _loaded, false); signals.forEach((sig) => { const listener = __privateGet(this, _sigListeners)[sig]; if (!listener) { throw new Error("Listener not defined for signal: " + sig); } try { __privateGet(this, _process).removeListener(sig, listener); } catch (_) { } }); __privateGet(this, _process).emit = __privateGet(this, _originalProcessEmit); __privateGet(this, _process).reallyExit = __privateGet(this, _originalProcessReallyExit); __privateGet(this, _emitter).count -= 1; } }; _hupSig = new WeakMap(); _emitter = new WeakMap(); _process = new WeakMap(); _originalProcessEmit = new WeakMap(); _originalProcessReallyExit = new WeakMap(); _sigListeners = new WeakMap(); _loaded = new WeakMap(); _SignalExit_instances = new WeakSet(); processReallyExit_fn = function(code) { if (!processOk(__privateGet(this, _process))) { return 0; } __privateGet(this, _process).exitCode = code || 0; __privateGet(this, _emitter).emit("exit", __privateGet(this, _process).exitCode, null); return __privateGet(this, _originalProcessReallyExit).call(__privateGet(this, _process), __privateGet(this, _process).exitCode); }; processEmit_fn = function(ev, ...args) { const og = __privateGet(this, _originalProcessEmit); if (ev === "exit" && processOk(__privateGet(this, _process))) { if (typeof args[0] === "number") { __privateGet(this, _process).exitCode = args[0]; } const ret = og.call(__privateGet(this, _process), ev, ...args); __privateGet(this, _emitter).emit("exit", __privateGet(this, _process).exitCode, null); return ret; } else { return og.call(__privateGet(this, _process), ev, ...args); } }; process3 = globalThis.process; ({ onExit: ( /** * Called when the process is exiting, whether via signal, explicit * exit, or running out of stuff to do. * * If the global process object is not suitable for instrumentation, * then this will be a no-op. * * Returns a function that may be used to unload signal-exit. */ onExit ), load: ( /** * Load the listeners. Likely you never need to call this, unless * doing a rather deep integration with signal-exit functionality. * Mostly exposed for the benefit of testing. * * @internal */ load ), unload: ( /** * Unload the listeners. Likely you never need to call this, unless * doing a rather deep integration with signal-exit functionality. * Mostly exposed for the benefit of testing. * * @internal */ unload ) } = signalExitWrap(processOk(process3) ? new SignalExit(process3) : new SignalExitFallback())); } }); // node_modules/.pnpm/restore-cursor@5.1.0/node_modules/restore-cursor/index.js var import_node_process2, terminal, restoreCursor, restore_cursor_default; var init_restore_cursor = __esm({ "node_modules/.pnpm/restore-cursor@5.1.0/node_modules/restore-cursor/index.js"() { "use strict"; import_node_process2 = __toESM(require("process"), 1); init_onetime(); init_mjs(); terminal = import_node_process2.default.stderr.isTTY ? import_node_process2.default.stderr : import_node_process2.default.stdout.isTTY ? import_node_process2.default.stdout : void 0; restoreCursor = terminal ? onetime_default(() => { onExit(() => { terminal.write("\x1B[?25h"); }, { alwaysLast: true }); }) : () => { }; restore_cursor_default = restoreCursor; } }); // node_modules/.pnpm/cli-cursor@5.0.0/node_modules/cli-cursor/index.js var import_node_process3, isHidden, cliCursor, cli_cursor_default; var init_cli_cursor = __esm({ "node_modules/.pnpm/cli-cursor@5.0.0/node_modules/cli-cursor/index.js"() { "use strict"; import_node_process3 = __toESM(require("process"), 1); init_restore_cursor(); isHidden = false; cliCursor = {}; cliCursor.show = (writableStream = import_node_process3.default.stderr) => { if (!writableStream.isTTY) { return; } isHidden = false; writableStream.write("\x1B[?25h"); }; cliCursor.hide = (writableStream = import_node_process3.default.stderr) => { if (!writableStream.isTTY) { return; } restore_cursor_default(); isHidden = true; writableStream.write("\x1B[?25l"); }; cliCursor.toggle = (force, writableStream) => { if (force !== void 0) { isHidden = force; } if (isHidden) { cliCursor.show(writableStream); } else { cliCursor.hide(writableStream); } }; cli_cursor_default = cliCursor; } }); // node_modules/.pnpm/ansi-regex@6.1.0/node_modules/ansi-regex/index.js function ansiRegex({ onlyFirst = false } = {}) { const ST = "(?:\\u0007|\\u001B\\u005C|\\u009C)"; const pattern = [ `[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?${ST})`, "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))" ].join("|"); return new RegExp(pattern, onlyFirst ? void 0 : "g"); } var init_ansi_regex = __esm({ "node_modules/.pnpm/ansi-regex@6.1.0/node_modules/ansi-regex/index.js"() { "use strict"; } }); // node_modules/.pnpm/strip-ansi@7.1.0/node_modules/strip-ansi/index.js function stripAnsi(string) { if (typeof string !== "string") { throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``); } return string.replace(regex, ""); } var regex; var init_strip_ansi = __esm({ "node_modules/.pnpm/strip-ansi@7.1.0/node_modules/strip-ansi/index.js"() { "use strict"; init_ansi_regex(); regex = ansiRegex(); } }); // node_modules/.pnpm/get-east-asian-width@1.2.0/node_modules/get-east-asian-width/lookup.js function isAmbiguous(x) { return x === 161 || x === 164 || x === 167 || x === 168 || x === 170 || x === 173 || x === 174 || x >= 176 && x <= 180 || x >= 182 && x <= 186 || x >= 188 && x <= 191 || x === 198 || x === 208 || x === 215 || x === 216 || x >= 222 && x <= 225 || x === 230 || x >= 232 && x <= 234 || x === 236 || x === 237 || x === 240 || x === 242 || x === 243 || x >= 247 && x <= 250 || x === 252 || x === 254 || x === 257 || x === 273 || x === 275 || x === 283 || x === 294 || x === 295 || x === 299 || x >= 305 && x <= 307 || x === 312 || x >= 319 && x <= 322 || x === 324 || x >= 328 && x <= 331 || x === 333 || x === 338 || x === 339 || x === 358 || x === 359 || x === 363 || x === 462 || x === 464 || x === 466 || x === 468 || x === 470 || x === 472 || x === 474 || x === 476 || x === 593 || x === 609 || x === 708 || x === 711 || x >= 713 && x <= 715 || x === 717 || x === 720 || x >= 728 && x <= 731 || x === 733 || x === 735 || x >= 768 && x <= 879 || x >= 913 && x <= 929 || x >= 931 && x <= 937 || x >= 945 && x <= 961 || x >= 963 && x <= 969 || x === 1025 || x >= 1040 && x <= 1103 || x === 1105 || x === 8208 || x >= 8211 && x <= 8214 || x === 8216 || x === 8217 || x === 8220 || x === 8221 || x >= 8224 && x <= 8226 || x >= 8228 && x <= 8231 || x === 8240 || x === 8242 || x === 8243 || x === 8245 || x === 8251 || x === 8254 || x === 8308 || x === 8319 || x >= 8321 && x <= 8324 || x === 8364 || x === 8451 || x === 8453 || x === 8457 || x === 8467 || x === 8470 || x === 8481 || x === 8482 || x === 8486 || x === 8491 || x === 8531 || x === 8532 || x >= 8539 && x <= 8542 || x >= 8544 && x <= 8555 || x >= 8560 && x <= 8569 || x === 8585 || x >= 8592 && x <= 8601 || x === 8632 || x === 8633 || x === 8658 || x === 8660 || x === 8679 || x === 8704 || x === 8706 || x === 8707 || x === 8711 || x === 8712 || x === 8715 || x === 8719 || x === 8721 || x === 8725 || x === 8730 || x >= 8733 && x <= 8736 || x === 8739 || x === 8741 || x >= 8743 && x <= 8748 || x === 8750 || x >= 8756 && x <= 8759 || x === 8764 || x === 8765 || x === 8776 || x === 8780 || x === 8786 || x === 8800 || x === 8801 || x >= 8804 && x <= 8807 || x === 8810 || x === 8811 || x === 8814 || x === 8815 || x === 8834 || x === 8835 || x === 8838 || x === 8839 || x === 8853 || x === 8857 || x === 8869 || x === 8895 || x === 8978 || x >= 9312 && x <= 9449 || x >= 9451 && x <= 9547 || x >= 9552 && x <= 9587 || x >= 9600 && x <= 9615 || x >= 9618 && x <= 9621 || x === 9632 || x === 9633 || x >= 9635 && x <= 9641 || x === 9650 || x === 9651 || x === 9654 || x === 9655 || x === 9660 || x === 9661 || x === 9664 || x === 9665 || x >= 9670 && x <= 9672 || x === 9675 || x >= 9678 && x <= 9681 || x >= 9698 && x <= 9701 || x === 9711 || x === 9733 || x === 9734 || x === 9737 || x === 9742 || x === 9743 || x === 9756 || x === 9758 || x === 9792 || x === 9794 || x === 9824 || x === 9825 || x >= 9827 && x <= 9829 || x >= 9831 && x <= 9834 || x === 9836 || x === 9837 || x === 9839 || x === 9886 || x === 9887 || x === 9919 || x >= 9926 && x <= 9933 || x >= 9935 && x <= 9939 || x >= 9941 && x <= 9953 || x === 9955 || x === 9960 || x === 9961 || x >= 9963 && x <= 9969 || x === 9972 || x >= 9974 && x <= 9977 || x === 9979 || x === 9980 || x === 9982 || x === 9983 || x === 10045 || x >= 10102 && x <= 10111 || x >= 11094 && x <= 11097 || x >= 12872 && x <= 12879 || x >= 57344 && x <= 63743 || x >= 65024 && x <= 65039 || x === 65533 || x >= 127232 && x <= 127242 || x >= 127248 && x <= 127277 || x >= 127280 && x <= 127337 || x >= 127344 && x <= 127373 || x === 127375 || x === 127376 || x >= 127387 && x <= 127404 || x >= 917760 && x <= 917999 || x >= 983040 && x <= 1048573 || x >= 1048576 && x <= 1114109; } function isFullWidth(x) { return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510; } function isWide(x) { return x >= 4352 && x <= 4447 || x === 8986 || x === 8987 || x === 9001 || x === 9002 || x >= 9193 && x <= 9196 || x === 9200 || x === 9203 || x === 9725 || x === 9726 || x === 9748 || x === 9749 || x >= 9800 && x <= 9811 || x === 9855 || x === 9875 || x === 9889 || x === 9898 || x === 9899 || x === 9917 || x === 9918 || x === 9924 || x === 9925 || x === 9934 || x === 9940 || x === 9962 || x === 9970 || x === 9971 || x === 9973 || x === 9978 || x === 9981 || x === 9989 || x === 9994 || x === 9995 || x === 10024 || x === 10060 || x === 10062 || x >= 10067 && x <= 10069 || x === 10071 || x >= 10133 && x <= 10135 || x === 10160 || x === 10175 || x === 11035 || x === 11036 || x === 11088 || x === 11093 || x >= 11904 && x <= 11929 || x >= 11931 && x <= 12019 || x >= 12032 && x <= 12245 || x >= 12272 && x <= 12287 || x >= 12289 && x <= 12350 || x >= 12353 && x <= 12438 || 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 >= 19968 && x <= 42124 || x >= 42128 && x <= 42182 || x >= 43360 && x <= 43388 || x >= 44032 && x <= 55203 || x >= 63744 && x <= 64255 || x >= 65040 && x <= 65049 || x >= 65072 && x <= 65106 || x >= 65108 && x <= 65126 || x >= 65128 && x <= 65131 || x >= 94176 && x <= 94180 || x === 94192 || x === 94193 || x >= 94208 && x <= 100343 || x >= 100352 && x <= 101589 || x >= 101632 && x <= 101640 || x >= 110576 && x <= 110579 || x >= 110581 && x <= 110587 || x === 110589 || x === 110590 || x >= 110592 && x <= 110882 || x === 110898 || x >= 110928 && x <= 110930 || x === 110933 || x >= 110948 && x <= 110951 || x >= 110960 && x <= 111355 || x === 126980 || x === 127183 || x === 127374 || x >= 127377 && x <= 127386 || x >= 127488 && x <= 127490 || x >= 127504 && x <= 127547 || x >= 127552 && x <= 127560 || x === 127568 || x === 127569 || x >= 127584 && x <= 127589 || x >= 127744 && x <= 127776 || x >= 127789 && x <= 127797 || x >= 127799 && x <= 127868 || x >= 127870 && x <= 127891 || x >= 127904 && x <= 127946 || x >= 127951 && x <= 127955 || x >= 127968 && x <= 127984 || x === 127988 || x >= 127992 && x <= 128062 || x === 128064 || x >= 128066 && x <= 128252 || x >= 128255 && x <= 128317 || x >= 128331 && x <= 128334 || x >= 128336 && x <= 128359 || x === 128378 || x === 128405 || x === 128406 || x === 128420 || x >= 128507 && x <= 128591 || x >= 128640 && x <= 128709 || x === 128716 || x >= 128720 && x <= 128722 || x >= 128725 && x <= 128727 || x >= 128732 && x <= 128735 || x === 128747 || x === 128748 || x >= 128756 && x <= 128764 || x >= 128992 && x <= 129003 || x === 129008 || x >= 129292 && x <= 129338 || x >= 129340 && x <= 129349 || x >= 129351 && x <= 129535 || x >= 129648 && x <= 129660 || x >= 129664 && x <= 129672 || x >= 129680 && x <= 129725 || x >= 129727 && x <= 129733 || x >= 129742 && x <= 129755 || x >= 129760 && x <= 129768 || x >= 129776 && x <= 129784 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141; } var init_lookup = __esm({ "node_modules/.pnpm/get-east-asian-width@1.2.0/node_modules/get-east-asian-width/lookup.js"() { "use strict"; } }); // node_modules/.pnpm/get-east-asian-width@1.2.0/node_modules/get-east-asian-width/index.js function validate(codePoint) { if (!Number.isSafeInteger(codePoint)) { throw new TypeError(`Expected a code point, got \`${typeof codePoint}\`.`); } } function eastAsianWidth(codePoint, { ambiguousAsWide = false } = {}) { validate(codePoint); if (isFullWidth(codePoint) || isWide(codePoint) || ambiguousAsWide && isAmbiguous(codePoint)) { return 2; } return 1; } var init_get_east_asian_width = __esm({ "node_modules/.pnpm/get-east-asian-width@1.2.0/node_modules/get-east-asian-width/index.js"() { "use strict"; init_lookup(); } }); // node_modules/.pnpm/emoji-regex@10.4.0/node_modules/emoji-regex/index.mjs var emoji_regex_default; var init_emoji_regex = __esm({ "node_modules/.pnpm/emoji-regex@10.4.0/node_modules/emoji-regex/index.mjs"() { "use strict"; emoji_regex_default = () => { return /[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE])))?))?|\uDC6F(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE89\uDE8F-\uDEC2\uDEC6\uDECE-\uDEDC\uDEDF-\uDEE9]|\uDD3C(?:\u200D[\u2640\u2642]\uFE0F?|\uD83C[\uDFFB-\uDFFF])?|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g; }; } }); // node_modules/.pnpm/string-width@7.2.0/node_modules/string-width/index.js function stringWidth(string, options = {}) { if (typeof string !== "string" || string.length === 0) { return 0; } const { ambiguousIsNarrow = true, countAnsiEscapeCodes = false } = options; if (!countAnsiEscapeCodes) { string = stripAnsi(string); } if (string.length === 0) { return 0; } let width = 0; const eastAsianWidthOptions = { ambiguousAsWide: !ambiguousIsNarrow }; for (const { segment: character } of segmenter.segment(string)) { const codePoint = character.codePointAt(0); if (codePoint <= 31 || codePoint >= 127 && codePoint <= 159) { continue; } if (codePoint >= 8203 && codePoint <= 8207 || codePoint === 65279) { continue; } if (codePoint >= 768 && codePoint <= 879 || codePoint >= 6832 && codePoint <= 6911 || codePoint >= 7616 && codePoint <= 7679 || codePoint >= 8400 && codePoint <= 8447 || codePoint >= 65056 && codePoint <= 65071) { continue; } if (codePoint >= 55296 && codePoint <= 57343) { continue; } if (codePoint >= 65024 && codePoint <= 65039) { continue; } if (defaultIgnorableCodePointRegex.test(character)) { continue; } if (emoji_regex_default().test(character)) { width += 2; continue; } width += eastAsianWidth(codePoint, eastAsianWidthOptions); } return width; } var segmenter, defaultIgnorableCodePointRegex; var init_string_width = __esm({ "node_modules/.pnpm/string-width@7.2.0/node_modules/string-width/index.js"() { "use strict"; init_strip_ansi(); init_get_east_asian_width(); init_emoji_regex(); segmenter = new Intl.Segmenter(); defaultIgnorableCodePointRegex = /^\p{Default_Ignorable_Code_Point}$/u; } }); // node_modules/.pnpm/ansi-styles@6.2.1/node_modules/ansi-styles/index.js function assembleStyles() { const codes = /* @__PURE__ */ new Map(); for (const [groupName, group] of Object.entries(styles)) { for (const [styleName, style] of Object.entries(group)) { styles[styleName] = { open: `\x1B[${style[0]}m`, close: `\x1B[${style[1]}m` }; group[styleName] = styles[styleName]; codes.set(style[0], style[1]); } Object.defineProperty(styles, groupName, { value: group, enumerable: false }); } Object.defineProperty(styles, "codes", { value: codes, enumerable: false }); styles.color.close = "\x1B[39m"; styles.bgColor.close = "\x1B[49m"; styles.color.ansi = wrapAnsi16(); styles.color.ansi256 = wrapAnsi256(); styles.color.ansi16m = wrapAnsi16m(); styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET); styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET); styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET); Object.defineProperties(styles, { rgbToAnsi256: { value: (red2, green2, blue2) => { if (red2 === green2 && green2 === blue2) { if (red2 < 8) { return 16; } if (red2 > 248) { return 231; } return Math.round((red2 - 8) / 247 * 24) + 232; } return 16 + 36 * Math.round(red2 / 255 * 5) + 6 * Math.round(green2 / 255 * 5) + Math.round(blue2 / 255 * 5); }, enumerable: false }, hexToRgb: { value: (hex) => { const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16)); if (!matches) { return [0, 0, 0]; } let [colorString] = matches; if (colorString.length === 3) { colorString = [...colorString].map((character) => character + character).join(""); } const integer = Number.parseInt(colorString, 16); return [ /* eslint-disable no-bitwise */ integer >> 16 & 255, integer >> 8 & 255, integer & 255 /* eslint-enable no-bitwise */ ]; }, enumerable: false }, hexToAnsi256: { value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)), enumerable: false }, ansi256ToAnsi: { value: (code) => { if (code < 8) { return 30 + code; } if (code < 16) { return 90 + (code - 8); } let red2; let green2; let blue2; if (code >= 232) { red2 = ((code - 232) * 10 + 8) / 255; green2 = red2; blue2 = red2; } else { code -= 16; const remainder = code % 36; red2 = Math.floor(code / 36) / 5; green2 = Math.floor(remainder / 6) / 5; blue2 = remainder % 6 / 5; } const value = Math.max(red2, green2, blue2) * 2; if (value === 0) { return 30; } let result = 30 + (Math.round(blue2) << 2 | Math.round(green2) << 1 | Math.round(red2)); if (value === 2) { result += 60; } return result; }, enumerable: false }, rgbToAnsi: { value: (red2, green2, blue2) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red2, green2, blue2)), enumerable: false }, hexToAnsi: { value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)), enumerable: false } }); return styles; } var ANSI_BACKGROUND_OFFSET, wrapAnsi16, wrapAnsi256, wrapAnsi16m, styles, modifierNames, foregroundColorNames, backgroundColorNames, colorNames, ansiStyles, ansi_styles_default; var init_ansi_styles = __esm({ "node_modules/.pnpm/ansi-styles@6.2.1/node_modules/ansi-styles/index.js"() { "use strict"; ANSI_BACKGROUND_OFFSET = 10; wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`; wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`; wrapAnsi16m = (offset = 0) => (red2, green2, blue2) => `\x1B[${38 + offset};2;${red2};${green2};${blue2}m`; styles = { modifier: { reset: [0, 0], // 21 isn't widely supported and 22 does the same thing bold: [1, 22], dim: [2, 22], italic: [3, 23], underline: [4, 24], overline: [53, 55], inverse: [7, 27], hidden: [8, 28], strikethrough: [9, 29] }, color: { black: [30, 39], red: [31, 39], green: [32, 39], yellow: [33, 39], blue: [34, 39], magenta: [35, 39], cyan: [36, 39], white: [37, 39], // Bright color blackBright: [90, 39], gray: [90, 39], // Alias of `blackBright` grey: [90, 39], // Alias of `blackBright` redBright: [91, 39], greenBright: [92, 39], yellowBright: [93, 39], blueBright: [94, 39], magentaBright: [95, 39], cyanBright: [96, 39], whiteBright: [97, 39] }, bgColor: { bgBlack: [40, 49], bgRed: [41, 49], bgGreen: [42, 49], bgYellow: [43, 49], bgBlue: [44, 49], bgMagenta: [45, 49], bgCyan: [46, 49], bgWhite: [47, 49], // Bright color bgBlackBright: [100, 49], bgGray: [100, 49], // Alias of `bgBlackBright` bgGrey: [100, 49], // Alias of `bgBlackBright` bgRedBright: [101, 49], bgGreenBright: [102, 49], bgYellowBright: [103, 49], bgBlueBright: [104, 49], bgMagentaBright: [105, 49], bgCyanBright: [106, 49], bgWhiteBright: [107, 49] } }; modifierNames = Object.keys(styles.modifier); foregroundColorNames = Object.keys(styles.color); backgroundColorNames = Object.keys(styles.bgColor); colorNames = [...foregroundColorNames, ...backgroundColorNames]; ansiStyles = assembleStyles(); ansi_styles_default = ansiStyles; } }); // node_modules/.pnpm/wrap-ansi@9.0.0/node_modules/wrap-ansi/index.js var wrap_ansi_exports = {}; __export(wrap_ansi_exports, { default: () => wrapAnsi }); function wrapAnsi(string, columns, options) { return String(string).normalize().replaceAll("\r\n", "\n").split("\n").map((line) => exec(line, columns, options)).join("\n"); } var ESCAPES, END_CODE, ANSI_ESCAPE_BELL, ANSI_CSI, ANSI_OSC, ANSI_SGR_TERMINATOR, ANSI_ESCAPE_LINK, wrapAnsiCode, wrapAnsiHyperlink, wordLengths, wrapWord, stringVisibleTrimSpacesRight, exec; var init_wrap_ansi = __esm({ "node_modules/.pnpm/wrap-ansi@9.0.0/node_modules/wrap-ansi/index.js"() { "use strict"; init_string_width(); init_strip_ansi(); init_ansi_styles(); ESCAPES = /* @__PURE__ */ new Set([ "\x1B", "\x9B" ]); END_CODE = 39; ANSI_ESCAPE_BELL = "\x07"; ANSI_CSI = "["; ANSI_OSC = "]"; ANSI_SGR_TERMINATOR = "m"; ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`; wrapAnsiCode = (code) => `${ESCAPES.values().next().value}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`; wrapAnsiHyperlink = (url) => `${ESCAPES.values().next().value}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`; wordLengths = (string) => string.split(" ").map((character) => stringWidth(character)); wrapWord = (rows, word, columns) => { const characters = [...word]; let isInsideEscape = false; let isInsideLinkEscape = false; let visible = stringWidth(stripAnsi(rows.at(-1))); for (const [index, character] of characters.entries()) { const characterLength = stringWidth(character); if (visible + characterLength <= columns) { rows[rows.length - 1] += character; } else { rows.push(character); visible = 0; } if (ESCAPES.has(character)) { isInsideEscape = true; const ansiEscapeLinkCandidate = characters.slice(index + 1, index + 1 + ANSI_ESCAPE_LINK.length).join(""); isInsideLinkEscape = ansiEscapeLinkCandidate === ANSI_ESCAPE_LINK; } if (isInsideEscape) { if (isInsideLinkEscape) { if (character === ANSI_ESCAPE_BELL) { isInsideEscape = false; isInsideLinkEscape = false; } } else if (character === ANSI_SGR_TERMINATOR) { isInsideEscape = false; } continue; } visible += characterLength; if (visible === columns && index < characters.length - 1) { rows.push(""); visible = 0; } } if (!visible && rows.at(-1).length > 0 && rows.length > 1) { rows[rows.length - 2] += rows.pop(); } }; stringVisibleTrimSpacesRight = (string) => { const words = string.split(" "); let last = words.length; while (last > 0) { if (stringWidth(words[last - 1]) > 0) { break; } last--; } if (last === words.length) { return string; } return words.slice(0, last).join(" ") + words.slice(last).join(""); }; exec = (string, columns, options = {}) => { if (options.trim !== false && string.trim() === "") { return ""; } let returnValue = ""; let escapeCode; let escapeUrl; const lengths = wordLengths(string); let rows = [""]; for (const [index, word] of string.split(" ").entries()) { if (options.trim !== false) { rows[rows.length - 1] = rows.at(-1).trimStart(); } let rowLength = stringWidth(rows.at(-1)); if (index !== 0) { if (rowLength >= columns && (options.wordWrap === false || options.trim === false)) { rows.push(""); rowLength = 0; } if (rowLength > 0 || options.trim === false) { rows[rows.length - 1] += " "; rowLength++; } } if (options.hard && lengths[index] > columns) { const remainingColumns = columns - rowLength; const breaksStartingThisLine = 1 + Math.floor((lengths[index] - remainingColumns - 1) / columns); const breaksStartingNextLine = Math.floor((lengths[index] - 1) / columns); if (breaksStartingNextLine < breaksStartingThisLine) { rows.push(""); } wrapWord(rows, word, columns); continue; } if (rowLength + lengths[index] > columns && rowLength > 0 && lengths[index] > 0) { if (options.wordWrap === false && rowLength < columns) { wrapWord(rows, word, columns); continue; } rows.push(""); } if (rowLength + lengths[index] > columns && options.wordWrap === false) { wrapWord(rows, word, columns); continue; } rows[rows.length - 1] += word; } if (options.trim !== false) { rows = rows.map((row) => stringVisibleTrimSpacesRight(row)); } const preString = rows.join("\n"); const pre = [...preString]; let preStringIndex = 0; for (const [index, character] of pre.entries()) { returnValue += character; if (ESCAPES.has(character)) { const { groups } = new RegExp(`(?:\\${ANSI_CSI}(?\\d+)m|\\${ANSI_ESCAPE_LINK}(?.*)${ANSI_ESCAPE_BELL})`).exec(preString.slice(preStringIndex)) || { groups: {} }; if (groups.code !== void 0) { const code2 = Number.parseFloat(groups.code); escapeCode = code2 === END_CODE ? void 0 : code2; } else if (groups.uri !== void 0) { escapeUrl = groups.uri.length === 0 ? void 0 : groups.uri; } } const code = ansi_styles_default.codes.get(Number(escapeCode)); if (pre[index + 1] === "\n") { if (escapeUrl) { returnValue += wrapAnsiHyperlink(""); } if (escapeCode && code) { returnValue += wrapAnsiCode(code); } } else if (character === "\n") { if (escapeCode && code) { returnValue += wrapAnsiCode(escapeCode); } if (escapeUrl) { returnValue += wrapAnsiHyperlink(escapeUrl); } } preStringIndex += character.length; } return returnValue; }; } }); // node_modules/.pnpm/is-fullwidth-code-point@5.0.0/node_modules/is-fullwidth-code-point/index.js function isFullwidthCodePoint(codePoint) { if (!Number.isInteger(codePoint)) { return false; } return eastAsianWidth(codePoint) === 2; } var init_is_fullwidth_code_point = __esm({ "node_modules/.pnpm/is-fullwidth-code-point@5.0.0/node_modules/is-fullwidth-code-point/index.js"() { "use strict"; init_get_east_asian_width(); } }); // node_modules/.pnpm/slice-ansi@7.1.0/node_modules/slice-ansi/index.js function getEndCode(code) { if (endCodesSet.has(code)) { return code; } if (endCodesMap.has(code)) { return endCodesMap.get(code); } code = code.slice(2); if (code.includes(";")) { code = code[0] + "0"; } const returnValue = ansi_styles_default.codes.get(Number.parseInt(code, 10)); if (returnValue) { return ansi_styles_default.color.ansi(returnValue); } return ansi_styles_default.reset.open; } function findNumberIndex(string) { for (let index = 0; index < string.length; index++) { const codePoint = string.codePointAt(index); if (codePoint >= CODE_POINT_0 && codePoint <= CODE_POINT_9) { return index; } } return -1; } function parseAnsiCode(string, offset) { string = string.slice(offset, offset + 19); const startIndex = findNumberIndex(string); if (startIndex !== -1) { let endIndex = string.indexOf("m", startIndex); if (endIndex === -1) { endIndex = string.length; } return string.slice(0, endIndex + 1); } } function tokenize(string, endCharacter = Number.POSITIVE_INFINITY) { const returnValue = []; let index = 0; let visibleCount = 0; while (index < string.length) { const codePoint = string.codePointAt(index); if (ESCAPES2.has(codePoint)) { const code = parseAnsiCode(string, index); if (code) { returnValue.push({ type: "ansi", code, endCode: getEndCode(code) }); index += code.length; continue; } } const isFullWidth2 = isFullwidthCodePoint(codePoint); const character = String.fromCodePoint(codePoint); returnValue.push({ type: "character", value: character, isFullWidth: isFullWidth2 }); index += character.length; visibleCount += isFullWidth2 ? 2 : character.length; if (visibleCount >= endCharacter) { break; } } return returnValue; } function reduceAnsiCodes(codes) { let returnValue = []; for (const code of codes) { if (code.code === ansi_styles_default.reset.open) { returnValue = []; } else if (endCodesSet.has(code.code)) { returnValue = returnValue.filter((returnValueCode) => returnValueCode.endCode !== code.code); } else { returnValue = returnValue.filter((returnValueCode) => returnValueCode.endCode !== code.endCode); returnValue.push(code); } } return returnValue; } function undoAnsiCodes(codes) { const reduced = reduceAnsiCodes(codes); const endCodes = reduced.map(({ endCode }) => endCode); return endCodes.reverse().join(""); } function sliceAnsi(string, start, end) { const tokens = tokenize(string, end); let activeCodes = []; let position = 0; let returnValue = ""; let include = false; for (const token of tokens) { if (end !== void 0 && position >= end) { break; } if (token.type === "ansi") { activeCodes.push(token); if (include) { returnValue += token.code; } } else { if (!include && position >= start) { include = true; activeCodes = reduceAnsiCodes(activeCodes); returnValue = activeCodes.map(({ code }) => code).join(""); } if (include) { returnValue += token.value; } position += token.isFullWidth ? 2 : token.value.length; } } returnValue += undoAnsiCodes(activeCodes); return returnValue; } var ESCAPES2, CODE_POINT_0, CODE_POINT_9, endCodesSet, endCodesMap; var init_slice_ansi = __esm({ "node_modules/.pnpm/slice-ansi@7.1.0/node_modules/slice-ansi/index.js"() { "use strict"; init_ansi_styles(); init_is_fullwidth_code_point(); ESCAPES2 = /* @__PURE__ */ new Set([27, 155]); CODE_POINT_0 = "0".codePointAt(0); CODE_POINT_9 = "9".codePointAt(0); endCodesSet = /* @__PURE__ */ new Set(); endCodesMap = /* @__PURE__ */ new Map(); for (const [start, end] of ansi_styles_default.codes) { endCodesSet.add(ansi_styles_default.color.ansi(end)); endCodesMap.set(ansi_styles_default.color.ansi(start), ansi_styles_default.color.ansi(end)); } } }); // node_modules/.pnpm/log-update@6.1.0/node_modules/log-update/index.js var log_update_exports = {}; __export(log_update_exports, { createLogUpdate: () => createLogUpdate, default: () => log_update_default, logUpdateStderr: () => logUpdateStderr }); function createLogUpdate(stream, { showCursor = false } = {}) { let previousLineCount = 0; let previousWidth = getWidth(stream); let previousOutput = ""; const reset2 = () => { previousOutput = ""; previousWidth = getWidth(stream); previousLineCount = 0; }; const render = (...arguments_) => { if (!showCursor) { cli_cursor_default.hide(); } let output = fitToTerminalHeight(stream, arguments_.join(" ") + "\n"); const width = getWidth(stream); if (output === previousOutput && previousWidth === width) { return; } previousOutput = output; previousWidth = width; output = wrapAnsi(output, width, { trim: false, hard: true, wordWrap: false }); stream.write(base_exports.eraseLines(previousLineCount) + output); previousLineCount = output.split("\n").length; }; render.clear = () => { stream.write(base_exports.eraseLines(previousLineCount)); reset2(); }; render.done = () => { reset2(); if (!showCursor) { cli_cursor_default.show(); } }; return render; } var import_node_process4, defaultTerminalHeight, getWidth, fitToTerminalHeight, logUpdate, log_update_default, logUpdateStderr; var init_log_update = __esm({ "node_modules/.pnpm/log-update@6.1.0/node_modules/log-update/index.js"() { "use strict"; import_node_process4 = __toESM(require("process"), 1); init_ansi_escapes(); init_cli_cursor(); init_wrap_ansi(); init_slice_ansi(); init_strip_ansi(); defaultTerminalHeight = 24; getWidth = ({ columns = 80 }) => columns; fitToTerminalHeight = (stream, text) => { const terminalHeight = stream.rows ?? defaultTerminalHeight; const lines = text.split("\n"); const toRemove = Math.max(0, lines.length - terminalHeight); return toRemove ? sliceAnsi(text, stripAnsi(lines.slice(0, toRemove).join("\n")).length + 1) : text; }; logUpdate = createLogUpdate(import_node_process4.default.stdout); log_update_default = logUpdate; logUpdateStderr = createLogUpdate(import_node_process4.default.stderr); } }); // node_modules/.pnpm/is-fullwidth-code-point@4.0.0/node_modules/is-fullwidth-code-point/index.js function isFullwidthCodePoint2(codePoint) { if (!Number.isInteger(codePoint)) { return false; } return codePoint >= 4352 && (codePoint <= 4447 || // Hangul Jamo codePoint === 9001 || // LEFT-POINTING ANGLE BRACKET codePoint === 9002 || // RIGHT-POINTING ANGLE BRACKET // CJK Radicals Supplement .. Enclosed CJK Letters and Months 11904 <= codePoint && codePoint <= 12871 && codePoint !== 12351 || // Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A 12880 <= codePoint && codePoint <= 19903 || // CJK Unified Ideographs .. Yi Radicals 19968 <= codePoint && codePoint <= 42182 || // Hangul Jamo Extended-A 43360 <= codePoint && codePoint <= 43388 || // Hangul Syllables 44032 <= codePoint && codePoint <= 55203 || // CJK Compatibility Ideographs 63744 <= codePoint && codePoint <= 64255 || // Vertical Forms 65040 <= codePoint && codePoint <= 65049 || // CJK Compatibility Forms .. Small Form Variants 65072 <= codePoint && codePoint <= 65131 || // Halfwidth and Fullwidth Forms 65281 <= codePoint && codePoint <= 65376 || 65504 <= codePoint && codePoint <= 65510 || // Kana Supplement 110592 <= codePoint && codePoint <= 110593 || // Enclosed Ideographic Supplement 127488 <= codePoint && codePoint <= 127569 || // CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane 131072 <= codePoint && codePoint <= 262141); } var init_is_fullwidth_code_point2 = __esm({ "node_modules/.pnpm/is-fullwidth-code-point@4.0.0/node_modules/is-fullwidth-code-point/index.js"() { "use strict"; } }); // node_modules/.pnpm/slice-ansi@5.0.0/node_modules/slice-ansi/index.js function sliceAnsi2(string, begin, end) { const characters = [...string]; const ansiCodes = []; let stringEnd = typeof end === "number" ? end : characters.length; let isInsideEscape = false; let ansiCode; let visible = 0; let output = ""; for (const [index, character] of characters.entries()) { let leftEscape = false; if (ESCAPES3.includes(character)) { const code = /\d[^m]*/.exec(string.slice(index, index + 18)); ansiCode = code && code.length > 0 ? code[0] : void 0; if (visible < stringEnd) { isInsideEscape = true; if (ansiCode !== void 0) { ansiCodes.push(ansiCode); } } } else if (isInsideEscape && character === "m") { isInsideEscape = false; leftEscape = true; } if (!isInsideEscape && !leftEscape) { visible++; } if (!astralRegex.test(character) && isFullwidthCodePoint2(character.codePointAt())) { visible++; if (typeof end !== "number") { stringEnd++; } } if (visible > begin && visible <= stringEnd) { output += character; } else if (visible === begin && !isInsideEscape && ansiCode !== void 0) { output = checkAnsi(ansiCodes); } else if (visible >= stringEnd) { output += checkAnsi(ansiCodes, true, ansiCode); break; } } return output; } var astralRegex, ESCAPES3, wrapAnsi2, checkAnsi; var init_slice_ansi2 = __esm({ "node_modules/.pnpm/slice-ansi@5.0.0/node_modules/slice-ansi/index.js"() { "use strict"; init_is_fullwidth_code_point2(); init_ansi_styles(); astralRegex = /^[\uD800-\uDBFF][\uDC00-\uDFFF]$/; ESCAPES3 = [ "\x1B", "\x9B" ]; wrapAnsi2 = (code) => `${ESCAPES3[0]}[${code}m`; checkAnsi = (ansiCodes, isEscapes, endAnsiCode) => { let output = []; ansiCodes = [...ansiCodes]; for (let ansiCode of ansiCodes) { const ansiCodeOrigin = ansiCode; if (ansiCode.includes(";")) { ansiCode = ansiCode.split(";")[0][0] + "0"; } const item = ansi_styles_default.codes.get(Number.parseInt(ansiCode, 10)); if (item) { const indexEscape = ansiCodes.indexOf(item.toString()); if (indexEscape === -1) { output.push(wrapAnsi2(isEscapes ? item : ansiCodeOrigin)); } else { ansiCodes.splice(indexEscape, 1); } } else if (isEscapes) { output.push(wrapAnsi2(0)); break; } else { output.push(wrapAnsi2(ansiCodeOrigin)); } } if (isEscapes) { output = output.filter((element, index) => output.indexOf(element) === index); if (endAnsiCode !== void 0) { const fistEscapeCode = wrapAnsi2(ansi_styles_default.codes.get(Number.parseInt(endAnsiCode, 10))); output = output.reduce((current, next) => next === fistEscapeCode ? [next, ...current] : [...current, next], []); } } return output.join(""); }; } }); // node_modules/.pnpm/cli-truncate@4.0.0/node_modules/cli-truncate/index.js var cli_truncate_exports = {}; __export(cli_truncate_exports, { default: () => cliTruncate }); function getIndexOfNearestSpace(string, wantedIndex, shouldSearchRight) { if (string.charAt(wantedIndex) === " ") { return wantedIndex; } const direction = shouldSearchRight ? 1 : -1; for (let index = 0; index <= 3; index++) { const finalIndex = wantedIndex + index * direction; if (string.charAt(finalIndex) === " ") { return finalIndex; } } return wantedIndex; } function cliTruncate(text, columns, options = {}) { const { position = "end", space = false, preferTruncationOnSpace = false } = options; let { truncationCharacter = "\u2026" } = options; if (typeof text !== "string") { throw new TypeError(`Expected \`input\` to be a string, got ${typeof text}`); } if (typeof columns !== "number") { throw new TypeError(`Expected \`columns\` to be a number, got ${typeof columns}`); } if (columns < 1) { return ""; } if (columns === 1) { return truncationCharacter; } const length = stringWidth(text); if (length <= columns) { return text; } if (position === "start") { if (preferTruncationOnSpace) { const nearestSpace = getIndexOfNearestSpace(text, length - columns + 1, true); return truncationCharacter + sliceAnsi2(text, nearestSpace, length).trim(); } if (space === true) { truncationCharacter += " "; } return truncationCharacter + sliceAnsi2(text, length - columns + stringWidth(truncationCharacter), length); } if (position === "middle") { if (space === true) { truncationCharacter = ` ${truncationCharacter} `; } const half = Math.floor(columns / 2); if (preferTruncationOnSpace) { const spaceNearFirstBreakPoint = getIndexOfNearestSpace(text, half); const spaceNearSecondBreakPoint = getIndexOfNearestSpace(text, length - (columns - half) + 1, true); return sliceAnsi2(text, 0, spaceNearFirstBreakPoint) + truncationCharacter + sliceAnsi2(text, spaceNearSecondBreakPoint, length).trim(); } return sliceAnsi2(text, 0, half) + truncationCharacter + sliceAnsi2(text, length - (columns - half) + stringWidth(truncationCharacter), length); } if (position === "end") { if (preferTruncationOnSpace) { const nearestSpace = getIndexOfNearestSpace(text, columns - 1); return sliceAnsi2(text, 0, nearestSpace) + truncationCharacter; } if (space === true) { truncationCharacter = ` ${truncationCharacter}`; } return sliceAnsi2(text, 0, columns - stringWidth(truncationCharacter)) + truncationCharacter; } throw new Error(`Expected \`options.position\` to be either \`start\`, \`middle\` or \`end\`, got ${position}`); } var init_cli_truncate = __esm({ "node_modules/.pnpm/cli-truncate@4.0.0/node_modules/cli-truncate/index.js"() { "use strict"; init_slice_ansi2(); init_string_width(); } }); // src/index.ts var src_exports = {}; __export(src_exports, { pubm: () => pubm }); module.exports = __toCommonJS(src_exports); // src/options.ts var defaultOptions = { testScript: "test", buildScript: "build", branch: "main", tag: "latest", registries: ["npm", "jsr"] }; function resolveOptions(options) { const nextOptions = { ...options, ...defaultOptions }; return nextOptions; } // src/tasks/runner.ts var import_node_process8 = __toESM(require("process"), 1); var import_promise_spawn = __toESM(require("@npmcli/promise-spawn"), 1); // node_modules/.pnpm/eventemitter3@5.0.1/node_modules/eventemitter3/index.mjs var import_index = __toESM(require_eventemitter3(), 1); var eventemitter3_default = import_index.default; // node_modules/.pnpm/colorette@2.0.20/node_modules/colorette/index.js var tty = __toESM(require("tty"), 1); var { env = {}, argv = [], platform = "" } = typeof process === "undefined" ? {} : process; var isDisabled = "NO_COLOR" in env || argv.includes("--no-color"); var isForced = "FORCE_COLOR" in env || argv.includes("--color"); var isWindows = platform === "win32"; var isDumbTerminal = env.TERM === "dumb"; var isCompatibleTerminal = tty && tty.isatty && tty.isatty(1) && env.TERM && !isDumbTerminal; var isCI = "CI" in env && ("GITHUB_ACTIONS" in env || "GITLAB_CI" in env || "CIRCLECI" in env); var isColorSupported = !isDisabled && (isForced || isWindows && !isDumbTerminal || isCompatibleTerminal || isCI); var replaceClose = (index, string, close, replace, head = string.substring(0, index) + replace, tail = string.substring(index + close.length), next = tail.indexOf(close)) => head + (next < 0 ? tail : replaceClose(next, tail, close, replace)); var clearBleed = (index, string, open2, close, replace) => index < 0 ? open2 + string + close : open2 + replaceClose(index, string, close, replace) + close; var filterEmpty = (open2, close, replace = open2, at = open2.length + 1) => (string) => string || !(string === "" || string === void 0) ? clearBleed( ("" + string).indexOf(close, at), string, open2, close, replace ) : ""; var init = (open2, close, replace) => filterEmpty(`\x1B[${open2}m`, `\x1B[${close}m`, replace); var colors = { reset: init(0, 0), bold: init(1, 22, "\x1B[22m\x1B[1m"), dim: init(2, 22, "\x1B[22m\x1B[2m"), italic: init(3, 23), underline: init(4, 24), inverse: init(7, 27), hidden: init(8, 28), strikethrough: init(9, 29), 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), 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), blackBright: init(90, 39), redBright: init(91, 39), greenBright: init(92, 39), yellowBright: init(93, 39), blueBright: init(94, 39), magentaBright: init(95, 39), cyanBright: init(96, 39), whiteBright: init(97, 39), bgBlackBright: init(100, 49), bgRedBright: init(101, 49), bgGreenBright: init(102, 49), bgYellowBright: init(103, 49), bgBlueBright: init(104, 49), bgMagentaBright: init(105, 49), bgCyanBright: init(106, 49), bgWhiteBright: init(107, 49) }; var createColors = ({ useColor = isColorSupported } = {}) => useColor ? colors : Object.keys(colors).reduce( (colors2, key) => ({ ...colors2, [key]: String }), {} ); var { reset, bold, dim, italic, underline, inverse, hidden, strikethrough, black, red, green, yellow, blue, magenta, cyan, white, gray, bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite, blackBright, redBright, greenBright, yellowBright, blueBright, magentaBright, cyanBright, whiteBright, bgBlackBright, bgRedBright, bgGreenBright, bgYellowBright, bgBlueBright, bgMagentaBright, bgCyanBright, bgWhiteBright } = createColors(); // node_modules/.pnpm/listr2@8.2.5_patch_hash=dzzw7eoo3mv4jvfzuqul4v6lc4/node_modules/listr2/dist/index.js var import_util = require("util"); var import_os = require("os"); var import_string_decoder = require("string_decoder"); var import_os2 = require("os"); var import_stream = require("stream"); var import_os3 = require("os"); var import_rfdc = __toESM(require_rfdc(), 1); var import_crypto = require("crypto"); var __defProp2 = Object.defineProperty; var __name = (target, value) => __defProp2(target, "name", { value, configurable: true }); var ANSI_ESCAPE = "\x1B["; var ANSI_ESCAPE_CODES = { CURSOR_HIDE: ANSI_ESCAPE + "?25l", CURSOR_SHOW: ANSI_ESCAPE + "?25h" }; var ListrTaskState = /* @__PURE__ */ ((ListrTaskState2) => { ListrTaskState2["WAITING"] = "WAITING"; ListrTaskState2["STARTED"] = "STARTED"; ListrTaskState2["COMPLETED"] = "COMPLETED"; ListrTaskState2["FAILED"] = "FAILED"; ListrTaskState2["SKIPPED"] = "SKIPPED"; ListrTaskState2["ROLLING_BACK"] = "ROLLING_BACK"; ListrTaskState2["ROLLED_BACK"] = "ROLLED_BACK"; ListrTaskState2["RETRY"] = "RETRY"; ListrTaskState2["PAUSED"] = "PAUSED"; ListrTaskState2["PROMPT"] = "PROMPT"; ListrTaskState2["PROMPT_COMPLETED"] = "PROMPT_COMPLETED"; ListrTaskState2["PROMPT_FAILED"] = "PROMPT_FAILED"; return ListrTaskState2; })(ListrTaskState || {}); var _a; var EventManager = (_a = class { constructor() { __publicField(this, "emitter", new eventemitter3_default()); } emit(dispatch, args) { this.emitter.emit(dispatch, args); } on(dispatch, handler) { this.emitter.addListener(dispatch, handler); } once(dispatch, handler) { this.emitter.once(dispatch, handler); } off(dispatch, handler) { this.emitter.off(dispatch, handler); } complete() { this.emitter.removeAllListeners(); } }, __name(_a, "EventManager"), _a); var _a2; var BaseEventMap = (_a2 = class { }, __name(_a2, "BaseEventMap"), _a2); function isObservable(obj) { return !!obj && typeof obj === "object" && typeof obj.subscribe === "function"; } __name(isObservable, "isObservable"); function isReadable(obj) { return !!obj && typeof obj === "object" && obj.readable === true && typeof obj.read === "function" && typeof obj.on === "function"; } __name(isReadable, "isReadable"); function isUnicodeSupported() { return !!process.env[ "LISTR_FORCE_UNICODE" /* FORCE_UNICODE */ ] || process.platform !== "win32" || !!process.env.CI || !!process.env.WT_SESSION || process.env.TERM_PROGRAM === "vscode" || process.env.TERM === "xterm-256color" || process.env.TERM === "alacritty"; } __name(isUnicodeSupported, "isUnicodeSupported"); var CLEAR_LINE_REGEX = "(?:\\u001b|\\u009b)\\[[\\=><~/#&.:=?%@~_-]*[0-9]*[\\a-ln-tqyz=><~/#&.:=?%@~_-]+"; var BELL_REGEX = /\u0007/; var HYPERLINK_REGEX = /(?:\u001b\]8;;.*?\u0007.*?\u001b\]8;;\u0007)/g; function cleanseAnsi(chunk) { const hyperlinks = chunk.match(HYPERLINK_REGEX) || []; let cleansedChunk = String(chunk).replace(new RegExp(HYPERLINK_REGEX, "g"), "__HYPERLINK__").replace(new RegExp(CLEAR_LINE_REGEX, "gmi"), "").replace(new RegExp(BELL_REGEX, "gmi"), "").trim(); hyperlinks.forEach((link3) => { cleansedChunk = cleansedChunk.replace("__HYPERLINK__", link3); }); return cleansedChunk; } __name(cleanseAnsi, "cleanseAnsi"); var color = createColors(); function indent(string, count) { return string.replace(/^(?!\s*$)/gm, " ".repeat(count)); } __name(indent, "indent"); var FIGURES_MAIN = { warning: "\u26A0", cross: "\u2716", arrowDown: "\u2193", tick: "\u2714", arrowRight: "\u2192", pointer: "\u276F", checkboxOn: "\u2612", arrowLeft: "\u2190", squareSmallFilled: "\u25FC", pointerSmall: "\u203A" }; var FIGURES_FALLBACK = { ...FIGURES_MAIN, warning: "\u203C", cross: "\xD7", tick: "\u221A", pointer: ">", checkboxOn: "[\xD7]", squareSmallFilled: "\u25A0" }; var figures = isUnicodeSupported() ? FIGURES_MAIN : FIGURES_FALLBACK; function splat(message, ...splat2) { return (0, import_util.format)(String(message), ...splat2); } __name(splat, "splat"); var LISTR_LOGGER_STYLE = { icon: { [ "STARTED" /* STARTED */ ]: figures.pointer, [ "FAILED" /* FAILED */ ]: figures.cross, [ "SKIPPED" /* SKIPPED */ ]: figures.arrowDown, [ "COMPLETED" /* COMPLETED */ ]: figures.tick, [ "OUTPUT" /* OUTPUT */ ]: figures.pointerSmall, [ "TITLE" /* TITLE */ ]: figures.arrowRight, [ "RETRY" /* RETRY */ ]: figures.warning, [ "ROLLBACK" /* ROLLBACK */ ]: figures.arrowLeft, [ "PAUSED" /* PAUSED */ ]: figures.squareSmallFilled }, color: { [ "STARTED" /* STARTED */ ]: color.yellow, [ "FAILED" /* FAILED */ ]: color.red, [ "SKIPPED" /* SKIPPED */ ]: color.yellow, [ "COMPLETED" /* COMPLETED */ ]: color.green, [ "RETRY" /* RETRY */ ]: color.yellowBright, [ "ROLLBACK" /* ROLLBACK */ ]: color.redBright, [ "PAUSED" /* PAUSED */ ]: color.yellowBright } }; var LISTR_LOGGER_STDERR_LEVELS = [ "RETRY", "ROLLBACK", "FAILED" /* FAILED */ ]; var _a3; var ListrLogger = (_a3 = class { constructor(options) { __publicField(this, "process"); var _a24, _b, _c; this.options = options; this.options = { useIcons: true, toStderr: [], ...options ?? {} }; (_a24 = this.options).fields ?? (_a24.fields = {}); (_b = this.options.fields).prefix ?? (_b.prefix = []); (_c = this.options.fields).suffix ?? (_c.suffix = []); this.process = this.options.processOutput ?? new ProcessOutput(); } log(level, message, options) { const output = this.format(level, message, options); if (this.options.toStderr.includes(level)) { this.process.toStderr(output); return; } this.process.toStdout(output); } toStdout(message, options, eol = true) { this.process.toStdout(this.format(null, message, options), eol); } toStderr(message, options, eol = true) { this.process.toStderr(this.format(null, message, options), eol); } wrap(message, options) { if (!message) { return message; } return this.applyFormat(`[${message}]`, options); } splat(...args) { const message = args.shift() ?? ""; return args.length === 0 ? message : splat(message, args); } suffix(message, ...suffixes) { suffixes.filter(Boolean).forEach((suffix) => { message += this.spacing(message); if (typeof suffix === "string") { message += this.wrap(suffix); } else if (typeof suffix === "object") { suffix.args ?? (suffix.args = []); if (typeof suffix.condition === "function" ? !suffix.condition(...suffix.args) : !(suffix.condition ?? true)) { return message; } message += this.wrap(typeof suffix.field === "function" ? suffix.field(...suffix.args) : suffix.field, { format: suffix?.format(...suffix.args) }); } }); return message; } prefix(message, ...prefixes) { prefixes.filter(Boolean).forEach((prefix) => { message = this.spacing(message) + message; if (typeof prefix === "string") { message = this.wrap(prefix) + message; } else if (typeof prefix === "object") { prefix.args ?? (prefix.args = []); if (typeof prefix.condition === "function" ? !prefix.condition(...prefix.args) : !(prefix.condition ?? true)) { return message; } message = this.wrap(typeof prefix.field === "function" ? prefix.field(...prefix.args) : prefix.field, { format: prefix?.format() }) + message; } }); return message; } fields(message, options) { if (this.options?.fields?.prefix) { message = this.prefix(message, ...this.options.fields.prefix); } if (options?.prefix) { message = this.prefix(message, ...options.prefix); } if (options?.suffix) { message = this.suffix(message, ...options.suffix); } if (this.options?.fields?.suffix) { message = this.suffix(message, ...this.options.fields.suffix); } return message; } icon(level, icon) { if (!level) { return null; } icon || (icon = this.options.icon?.[level]); const coloring = this.options.color?.[level]; if (icon && coloring) { icon = coloring(icon); } return icon; } format(level, message, options) { if (!Array.isArray(message)) { message = [message]; } message = this.splat(message.shift(), ...message).toString().split(import_os.EOL).filter((m) => !m || m.trim() !== "").map((m) => { return this.style( level, this.fields(m, { prefix: Array.isArray(options?.prefix) ? options.prefix : [options?.prefix], suffix: Array.isArray(options?.suffix) ? options.suffix : [options?.suffix] }) ); }).join(import_os.EOL); return message; } style(level, message) { if (!level || !message) { return message; } const icon = this.icon(level, !this.options.useIcons && this.wrap(level)); if (icon) { message = icon + " " + message; } return message; } applyFormat(message, options) { if (options?.format) { return options.format(message); } return message; } spacing(message) { return typeof message === "undefined" || message.trim() === "" ? "" : " "; } }, __name(_a3, "ListrLogger"), _a3); var _a4; var ProcessOutputBuffer = (_a4 = class { constructor(options) { __publicField(this, "buffer", []); __publicField(this, "decoder", new import_string_decoder.StringDecoder()); this.options = options; } get all() { return this.buffer; } get last() { return this.buffer.at(-1); } get length() { return this.buffer.length; } write(data, ...args) { const callback = args[args.length - 1]; this.buffer.push({ time: Date.now(), stream: this.options?.stream, entry: this.decoder.write(typeof data === "string" ? Buffer.from(data, typeof args[0] === "string" ? args[0] : void 0) : Buffer.from(data)) }); if (this.options?.limit) { this.buffer = this.buffer.slice(-this.options.limit); } if (typeof callback === "function") { callback(); } return true; } reset() { this.buffer = []; } }, __name(_a4, "ProcessOutputBuffer"), _a4); var _a5; var ProcessOutputStream = (_a5 = class { constructor(stream) { __publicField(this, "method"); __publicField(this, "buffer"); this.stream = stream; this.method = stream.write; this.buffer = new ProcessOutputBuffer({ stream }); } get out() { return Object.assign({}, this.stream, { write: this.write.bind(this) }); } hijack() { this.stream.write = this.buffer.write.bind(this.buffer); } release() { this.stream.write = this.method; const buffer = [...this.buffer.all]; this.buffer.reset(); return buffer; } write(...args) { return this.method.apply(this.stream, args); } }, __name(_a5, "ProcessOutputStream"), _a5); var _a6; var ProcessOutput = (_a6 = class { constructor(stdout, stderr, options) { __publicField(this, "stream"); __publicField(this, "active"); this.options = options; this.stream = { stdout: new ProcessOutputStream(stdout ?? process.stdout), stderr: new ProcessOutputStream(stderr ?? process.stderr) }; this.options = { dump: ["stdout", "stderr"], leaveEmptyLine: true, ...options }; } get stdout() { return this.stream.stdout.out; } get stderr() { return this.stream.stderr.out; } hijack() { if (this.active) { throw new Error("ProcessOutput has been already hijacked!"); } this.stream.stdout.write(ANSI_ESCAPE_CODES.CURSOR_HIDE); Object.values(this.stream).forEach((stream) => stream.hijack()); this.active = true; } release() { const output = Object.entries(this.stream).map(([name, stream]) => ({ name, buffer: stream.release() })).filter((output2) => this.options.dump.includes(output2.name)).flatMap((output2) => output2.buffer).sort((a2, b) => a2.time - b.time).map((message) => { return { ...message, entry: cleanseAnsi(message.entry) }; }).filter((message) => message.entry); if (output.length > 0) { if (this.options.leaveEmptyLine) { this.stdout.write(import_os2.EOL); } output.forEach((message) => { const stream = message.stream ?? this.stdout; stream.write(message.entry + import_os2.EOL); }); } this.stream.stdout.write(ANSI_ESCAPE_CODES.CURSOR_SHOW); this.active = false; } toStdout(buffer, eol = true) { if (eol) { buffer = buffer + import_os2.EOL; } return this.stream.stdout.write(buffer); } toStderr(buffer, eol = true) { if (eol) { buffer = buffer + import_os2.EOL; } return this.stream.stderr.write(buffer); } }, __name(_a6, "ProcessOutput"), _a6); function createWritable(cb) { const writable = new import_stream.Writable(); writable.rows = Infinity; writable.columns = Infinity; writable.write = (chunk) => { cb(chunk.toString()); return true; }; return writable; } __name(createWritable, "createWritable"); var _a7; var ListrPromptAdapter = (_a7 = class { constructor(task, wrapper) { __publicField(this, "state"); this.task = task; this.wrapper = wrapper; } reportStarted() { this.state = this.task.state; if (this.task.prompt) { throw new PromptError("There is already an active prompt attached to this task which may not be cleaned up properly."); } this.task.prompt = this; this.task.state$ = "PROMPT"; } reportFailed() { this.task.state$ = "PROMPT_FAILED"; this.restoreState(); } reportCompleted() { this.task.state$ = "PROMPT_COMPLETED"; this.restoreState(); } restoreState() { this.task.prompt = void 0; if (this.state) { this.task.state = this.state; } } }, __name(_a7, "ListrPromptAdapter"), _a7); var _a8; var Spinner = (_a8 = class { constructor() { __publicField(this, "spinner", !isUnicodeSupported() ? ["-", "\\", "|", "/"] : ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"]); __publicField(this, "id"); __publicField(this, "spinnerPosition", 0); } spin() { this.spinnerPosition = ++this.spinnerPosition % this.spinner.length; } fetch() { return this.spinner[this.spinnerPosition]; } isRunning() { return !!this.id; } start(cb, interval = 100) { this.id = setInterval(() => { this.spin(); if (cb) { cb(); } }, interval); } stop() { clearInterval(this.id); } }, __name(_a8, "Spinner"), _a8); var LISTR_DEFAULT_RENDERER_STYLE = { icon: { [ "SKIPPED_WITH_COLLAPSE" /* SKIPPED_WITH_COLLAPSE */ ]: figures.arrowDown, [ "SKIPPED_WITHOUT_COLLAPSE" /* SKIPPED_WITHOUT_COLLAPSE */ ]: figures.warning, [ "OUTPUT" /* OUTPUT */ ]: figures.pointerSmall, [ "OUTPUT_WITH_BOTTOMBAR" /* OUTPUT_WITH_BOTTOMBAR */ ]: figures.pointerSmall, [ "PENDING" /* PENDING */ ]: figures.pointer, [ "COMPLETED" /* COMPLETED */ ]: figures.tick, [ "COMPLETED_WITH_FAILED_SUBTASKS" /* COMPLETED_WITH_FAILED_SUBTASKS */ ]: figures.warning, [ "COMPLETED_WITH_SISTER_TASKS_FAILED" /* COMPLETED_WITH_FAILED_SISTER_TASKS */ ]: figures.squareSmallFilled, [ "RETRY" /* RETRY */ ]: figures.warning, [ "ROLLING_BACK" /* ROLLING_BACK */ ]: figures.warning, [ "ROLLED_BACK" /* ROLLED_BACK */ ]: figures.arrowLeft, [ "FAILED" /* FAILED */ ]: figures.cross, [ "FAILED_WITH_SUBTASKS" /* FAILED_WITH_FAILED_SUBTASKS */ ]: figures.pointer, [ "WAITING" /* WAITING */ ]: figures.squareSmallFilled, [ "PAUSED" /* PAUSED */ ]: figures.squareSmallFilled }, color: { [ "SKIPPED_WITH_COLLAPSE" /* SKIPPED_WITH_COLLAPSE */ ]: color.yellow, [ "SKIPPED_WITHOUT_COLLAPSE" /* SKIPPED_WITHOUT_COLLAPSE */ ]: color.yellow, [ "PENDING" /* PENDING */ ]: color.yellow, [ "COMPLETED" /* COMPLETED */ ]: color.green, [ "COMPLETED_WITH_FAILED_SUBTASKS" /* COMPLETED_WITH_FAILED_SUBTASKS */ ]: color.yellow, [ "COMPLETED_WITH_SISTER_TASKS_FAILED" /* COMPLETED_WITH_FAILED_SISTER_TASKS */ ]: color.red, [ "RETRY" /* RETRY */ ]: color.yellowBright, [ "ROLLING_BACK" /* ROLLING_BACK */ ]: color.redBright, [ "ROLLED_BACK" /* ROLLED_BACK */ ]: color.redBright, [ "FAILED" /* FAILED */ ]: color.red, [ "FAILED_WITH_SUBTASKS" /* FAILED_WITH_FAILED_SUBTASKS */ ]: color.red, [ "WAITING" /* WAITING */ ]: color.dim, [ "PAUSED" /* PAUSED */ ]: color.yellowBright } }; function parseTimer(duration) { const seconds = Math.floor(duration / 1e3); const minutes = Math.floor(seconds / 60); let parsedTime; if (seconds === 0 && minutes === 0) { parsedTime = `0.${Math.floor(duration / 100)}s`; } if (seconds > 0) { parsedTime = `${seconds % 60}s`; } if (minutes > 0) { parsedTime = `${minutes}m${parsedTime}`; } return parsedTime; } __name(parseTimer, "parseTimer"); var PRESET_TIMER = { condition: true, field: parseTimer, format: /* @__PURE__ */ __name(() => color.dim, "format") }; function parseTimestamp() { const now = /* @__PURE__ */ new Date(); return String(now.getHours()).padStart(2, "0") + ":" + String(now.getMinutes()).padStart(2, "0") + ":" + String(now.getSeconds()).padStart(2, "0"); } __name(parseTimestamp, "parseTimestamp"); var _a9; var DefaultRenderer = (_a9 = class { constructor(tasks, options, events) { __publicField(this, "prompt"); __publicField(this, "activePrompt"); __publicField(this, "spinner"); __publicField(this, "logger"); __publicField(this, "updater"); __publicField(this, "truncate"); __publicField(this, "wrap"); __publicField(this, "buffer", { output: /* @__PURE__ */ new Map(), bottom: /* @__PURE__ */ new Map() }); __publicField(this, "cache", { render: /* @__PURE__ */ new Map(), rendererOptions: /* @__PURE__ */ new Map(), rendererTaskOptions: /* @__PURE__ */ new Map() }); this.tasks = tasks; this.options = options; this.events = events; this.options = { ..._a9.rendererOptions, ...this.options, icon: { ...LISTR_DEFAULT_RENDERER_STYLE.icon, ...options?.icon ?? {} }, color: { ...LISTR_DEFAULT_RENDERER_STYLE.color, ...options?.color ?? {} } }; this.spinner = this.options.spinner ?? new Spinner(); this.logger = this.options.logger ?? new ListrLogger({ useIcons: true, toStderr: [] }); this.logger.options.icon = this.options.icon; this.logger.options.color = this.options.color; } async render() { const { createLogUpdate: createLogUpdate2 } = await Promise.resolve().then(() => (init_log_update(), log_update_exports)); const { default: truncate } = await Promise.resolve().then(() => (init_cli_truncate(), cli_truncate_exports)); const { default: wrap } = await Promise.resolve().then(() => (init_wrap_ansi(), wrap_ansi_exports)); this.updater = createLogUpdate2(this.logger.process.stdout); this.truncate = truncate; this.wrap = wrap; this.logger.process.hijack(); if (!this.options?.lazy) { this.spinner.start(() => { this.update(); }); } this.events.on("SHOUD_REFRESH_RENDER", () => { this.update(); }); } update() { this.updater(this.create()); } end() { this.spinner.stop(); this.updater.clear(); this.updater.done(); if (!this.options.clearOutput) { this.logger.process.toStdout(this.create({ prompt: false })); } this.logger.process.release(); } create(options) { options = { tasks: true, bottomBar: true, prompt: true, ...options }; const render = []; const renderTasks = this.renderer(this.tasks); const renderBottomBar = this.renderBottomBar(); const renderPrompt = this.renderPrompt(); if (options.tasks && renderTasks.length > 0) { render.push(...renderTasks); } if (options.bottomBar && renderBottomBar.length > 0) { if (render.length > 0) { render.push(""); } render.push(...renderBottomBar); } if (options.prompt && renderPrompt.length > 0) { if (render.length > 0) { render.push(""); } render.push(...renderPrompt); } return render.join(import_os3.EOL); } // eslint-disable-next-line complexity style(task, output = false) { const rendererOptions = this.cache.rendererOptions.get(task.id); if (task.isSkipped()) { if (output || rendererOptions.collapseSkips) { return this.logger.icon( "SKIPPED_WITH_COLLAPSE" /* SKIPPED_WITH_COLLAPSE */ ); } else if (rendererOptions.collapseSkips === false) { return this.logger.icon( "SKIPPED_WITHOUT_COLLAPSE" /* SKIPPED_WITHOUT_COLLAPSE */ ); } } if (output) { if (this.shouldOutputToBottomBar(task)) { return this.logger.icon( "OUTPUT_WITH_BOTTOMBAR" /* OUTPUT_WITH_BOTTOMBAR */ ); } return this.logger.icon( "OUTPUT" /* OUTPUT */ ); } if (task.hasSubtasks()) { if (task.isStarted() || task.isPrompt() && rendererOptions.showSubtasks !== false && !task.subtasks.every((subtask) => !subtask.hasTitle())) { return this.logger.icon( "PENDING" /* PENDING */ ); } else if (task.isCompleted() && task.subtasks.some((subtask) => subtask.hasFailed())) { return this.logger.icon( "COMPLETED_WITH_FAILED_SUBTASKS" /* COMPLETED_WITH_FAILED_SUBTASKS */ ); } else if (task.hasFailed()) { return this.logger.icon( "FAILED_WITH_SUBTASKS" /* FAILED_WITH_FAILED_SUBTASKS */ ); } } if (task.isStarted() || task.isPrompt()) { return this.logger.icon("PENDING", !this.options?.lazy && this.spinner.fetch()); } else if (task.isCompleted()) { return this.logger.icon( "COMPLETED" /* COMPLETED */ ); } else if (task.isRetrying()) { return this.logger.icon("RETRY", !this.options?.lazy && this.spinner.fetch()); } else if (task.isRollingBack()) { return this.logger.icon("ROLLING_BACK", !this.options?.lazy && this.spinner.fetch()); } else if (task.hasRolledBack()) { return this.logger.icon( "ROLLED_BACK" /* ROLLED_BACK */ ); } else if (task.hasFailed()) { return this.logger.icon( "FAILED" /* FAILED */ ); } else if (task.isPaused()) { return this.logger.icon( "PAUSED" /* PAUSED */ ); } return this.logger.icon( "WAITING" /* WAITING */ ); } format(message, icon, level) { if (message.trim() === "") { return []; } if (icon) { message = icon + " " + message; } let parsed; const columns = (process.stdout.columns ?? 80) - level * this.options.indentation - 2; switch (this.options.formatOutput) { case "truncate": parsed = message.split(import_os3.EOL).map((s, i) => { return this.truncate(this.indent(s, i), columns); }); break; case "wrap": parsed = this.wrap(message, columns, { hard: true }).split(import_os3.EOL).map((s, i) => this.indent(s, i)); break; default: throw new ListrRendererError("Format option for the renderer is wrong."); } if (this.options.removeEmptyLines) { parsed = parsed.filter(Boolean); } return parsed.map((str) => indent(str, level * this.options.indentation)); } shouldOutputToOutputBar(task) { const outputBar = this.cache.rendererTaskOptions.get(task.id).outputBar; return typeof outputBar === "number" && outputBar !== 0 || typeof outputBar === "boolean" && outputBar !== false; } shouldOutputToBottomBar(task) { const bottomBar = this.cache.rendererTaskOptions.get(task.id).bottomBar; return typeof bottomBar === "number" && bottomBar !== 0 || typeof bottomBar === "boolean" && bottomBar !== false || !task.hasTitle(); } renderer(tasks, level = 0) { return tasks.flatMap((task) => { if (!task.isEnabled()) { return []; } if (this.cache.render.has(task.id)) { return this.cache.render.get(task.id); } this.calculate(task); this.setupBuffer(task); const rendererOptions = this.cache.rendererOptions.get(task.id); const rendererTaskOptions = this.cache.rendererTaskOptions.get(task.id); const output = []; if (task.isPrompt()) { if (this.activePrompt && this.activePrompt !== task.id) { throw new ListrRendererError("Only one prompt can be active at the given time, please re-evaluate your task design."); } else if (!this.activePrompt) { task.on("PROMPT", (prompt) => { const cleansed = cleanseAnsi(prompt); if (cleansed) { this.prompt = cleansed; } }); task.on("STATE", (state) => { if (state === "PROMPT_COMPLETED" || task.hasFinalized() || task.hasReset()) { this.prompt = null; this.activePrompt = null; task.off( "PROMPT" /* PROMPT */ ); } }); this.activePrompt = task.id; } } if (task.hasTitle()) { if (!(tasks.some((task2) => task2.hasFailed()) && !task.hasFailed() && task.options.exitOnError !== false && !(task.isCompleted() || task.isSkipped()))) { if (task.hasFailed() && rendererOptions.collapseErrors) { output.push(...this.format(!task.hasSubtasks() && task.message.error && rendererOptions.showErrorMessage ? task.message.error : task.title, this.style(task), level)); } else if (task.isSkipped() && rendererOptions.collapseSkips) { output.push( ...this.format( this.logger.suffix(task.message.skip && rendererOptions.showSkipMessage ? task.message.skip : task.title, { field: "SKIPPED", condition: rendererOptions.suffixSkips, format: /* @__PURE__ */ __name(() => color.dim, "format") }), this.style(task), level ) ); } else if (task.isRetrying()) { output.push( ...this.format( this.logger.suffix(task.title, { field: `${"RETRY"}:${task.message.retry.count}`, format: /* @__PURE__ */ __name(() => color.yellow, "format"), condition: rendererOptions.suffixRetries }), this.style(task), level ) ); } else if (task.isCompleted() && task.hasTitle() && assertFunctionOrSelf(rendererTaskOptions.timer?.condition, task.message.duration)) { output.push( ...this.format( this.logger.suffix(task?.title, { ...rendererTaskOptions.timer, args: [task.message.duration] }), this.style(task), level ) ); } else if (task.isPaused()) { output.push( ...this.format( this.logger.suffix(task.title, { ...rendererOptions.pausedTimer, args: [task.message.paused - Date.now()] }), this.style(task), level ) ); } else { output.push(...this.format(task.title, this.style(task), level)); } } else { output.push(...this.format(task.title, this.logger.icon( "COMPLETED_WITH_SISTER_TASKS_FAILED" /* COMPLETED_WITH_FAILED_SISTER_TASKS */ ), level)); } } if (!task.hasSubtasks() || !rendererOptions.showSubtasks) { if (task.hasFailed() && rendererOptions.collapseErrors === false && (rendererOptions.showErrorMessage || !rendererOptions.showSubtasks)) { output.push(...this.dump( task, level, "FAILED" /* FAILED */ )); } else if (task.isSkipped() && rendererOptions.collapseSkips === false && (rendererOptions.showSkipMessage || !rendererOptions.showSubtasks)) { output.push(...this.dump( task, level, "SKIPPED" /* SKIPPED */ )); } } if (task.isPending() || rendererTaskOptions.persistentOutput) { output.push(...this.renderOutputBar(task, level)); } if ( // check if renderer option is on first rendererOptions.showSubtasks !== false && // if it doesnt have subtasks no need to check task.hasSubtasks() && (task.isPending() || task.hasFinalized() && !task.hasTitle() || // have to be completed and have subtasks task.isCompleted() && rendererOptions.collapseSubtasks === false && !task.subtasks.some((subtask) => this.cache.rendererOptions.get(subtask.id)?.collapseSubtasks === true) || // if any of the subtasks have the collapse option of task.subtasks.some((subtask) => this.cache.rendererOptions.get(subtask.id)?.collapseSubtasks === false) || // if any of the subtasks has failed task.subtasks.some((subtask) => subtask.hasFailed()) || // if any of the subtasks rolled back task.subtasks.some((subtask) => subtask.hasRolledBack())) ) { const subtaskLevel = !task.hasTitle() ? level : level + 1; const subtaskRender = this.renderer(task.subtasks, subtaskLevel); output.push(...subtaskRender); } if (task.hasFinalized()) { if (!rendererTaskOptions.persistentOutput) { this.buffer.bottom.delete(task.id); this.buffer.output.delete(task.id); } } if (task.isClosed()) { this.cache.render.set(task.id, output); this.reset(task); } return output; }); } renderOutputBar(task, level) { const output = this.buffer.output.get(task.id); if (!output) { return []; } return output.all.flatMap((o) => this.dump(task, level, "OUTPUT", o.entry)); } renderBottomBar() { if (this.buffer.bottom.size === 0) { return []; } return Array.from(this.buffer.bottom.values()).flatMap((output) => output.all).sort((a2, b) => a2.time - b.time).map((output) => output.entry); } renderPrompt() { if (!this.prompt) { return []; } return [this.prompt]; } calculate(task) { if (this.cache.rendererOptions.has(task.id) && this.cache.rendererTaskOptions.has(task.id)) { return; } const rendererOptions = { ...this.options, ...task.rendererOptions }; this.cache.rendererOptions.set(task.id, rendererOptions); this.cache.rendererTaskOptions.set(task.id, { ..._a9.rendererTaskOptions, timer: rendererOptions.timer, ...task.rendererTaskOptions }); } setupBuffer(task) { if (this.buffer.bottom.has(task.id) || this.buffer.output.has(task.id)) { return; } const rendererTaskOptions = this.cache.rendererTaskOptions.get(task.id); if (this.shouldOutputToBottomBar(task) && !this.buffer.bottom.has(task.id)) { this.buffer.bottom.set(task.id, new ProcessOutputBuffer({ limit: typeof rendererTaskOptions.bottomBar === "number" ? rendererTaskOptions.bottomBar : 1 })); task.on("OUTPUT", (output) => { const data = this.dump(task, -1, "OUTPUT", output); this.buffer.bottom.get(task.id).write(data.join(import_os3.EOL)); }); task.on("STATE", (state) => { switch (state) { case "RETRY": this.buffer.bottom.delete(task.id); break; } }); } else if (this.shouldOutputToOutputBar(task) && !this.buffer.output.has(task.id)) { this.buffer.output.set(task.id, new ProcessOutputBuffer({ limit: typeof rendererTaskOptions.outputBar === "number" ? rendererTaskOptions.outputBar : 1 })); task.on("OUTPUT", (output) => { this.buffer.output.get(task.id).write(output); }); task.on("STATE", (state) => { switch (state) { case "RETRY": this.buffer.output.delete(task.id); break; } }); } } reset(task) { this.cache.rendererOptions.delete(task.id); this.cache.rendererTaskOptions.delete(task.id); this.buffer.output.delete(task.id); } dump(task, level, source = "OUTPUT", data) { if (!data) { switch (source) { case "OUTPUT": data = task.output; break; case "SKIPPED": data = task.message.skip; break; case "FAILED": data = task.message.error; break; } } if (task.hasTitle() && source === "FAILED" && data === task.title || typeof data !== "string") { return []; } if (source === "OUTPUT") { data = cleanseAnsi(data); } return this.format(data, this.style(task, true), level + 1); } indent(str, i) { return i > 0 ? indent(str.trim(), this.options.indentation) : str.trim(); } }, __name(_a9, "DefaultRenderer"), __publicField(_a9, "nonTTY", false), __publicField(_a9, "rendererOptions", { indentation: 2, clearOutput: false, showSubtasks: true, collapseSubtasks: true, collapseSkips: true, showSkipMessage: true, suffixSkips: false, collapseErrors: true, showErrorMessage: true, suffixRetries: true, lazy: false, removeEmptyLines: true, formatOutput: "wrap", pausedTimer: { ...PRESET_TIMER, format: /* @__PURE__ */ __name(() => color.yellowBright, "format") } }), __publicField(_a9, "rendererTaskOptions", { outputBar: true }), _a9); var _a10; var SilentRenderer = (_a10 = class { constructor(tasks, options) { this.tasks = tasks; this.options = options; } render() { return; } end() { return; } }, __name(_a10, "SilentRenderer"), __publicField(_a10, "nonTTY", true), __publicField(_a10, "rendererOptions"), __publicField(_a10, "rendererTaskOptions"), _a10); var _a11; var SimpleRenderer = (_a11 = class { constructor(tasks, options) { __publicField(this, "logger"); __publicField(this, "cache", { rendererOptions: /* @__PURE__ */ new Map(), rendererTaskOptions: /* @__PURE__ */ new Map() }); this.tasks = tasks; this.options = options; this.options = { ..._a11.rendererOptions, ...options, icon: { ...LISTR_LOGGER_STYLE.icon, ...options?.icon ?? {} }, color: { ...LISTR_LOGGER_STYLE.color, ...options?.color ?? {} } }; this.logger = this.options.logger ?? new ListrLogger({ useIcons: true, toStderr: LISTR_LOGGER_STDERR_LEVELS }); this.logger.options.icon = this.options.icon; this.logger.options.color = this.options.color; if (this.options.timestamp) { this.logger.options.fields.prefix.unshift(this.options.timestamp); } } // eslint-disable-next-line @typescript-eslint/no-empty-function end() { } render() { this.renderer(this.tasks); } renderer(tasks) { tasks.forEach((task) => { this.calculate(task); task.once("CLOSED", () => { this.reset(task); }); const rendererOptions = this.cache.rendererOptions.get(task.id); const rendererTaskOptions = this.cache.rendererTaskOptions.get(task.id); task.on("SUBTASK", (subtasks) => { this.renderer(subtasks); }); task.on("STATE", (state) => { if (!task.hasTitle()) { return; } if (state === "STARTED") { this.logger.log("STARTED", task.title); } else if (state === "COMPLETED") { const timer = rendererTaskOptions?.timer; this.logger.log( "COMPLETED", task.title, timer && { suffix: { ...timer, condition: !!task.message?.duration && timer.condition, args: [task.message.duration] } } ); } else if (state === "PROMPT") { this.logger.process.hijack(); task.on("PROMPT", (prompt) => { this.logger.process.toStderr(prompt, false); }); } else if (state === "PROMPT_COMPLETED") { task.off( "PROMPT" /* PROMPT */ ); this.logger.process.release(); } }); task.on("OUTPUT", (output) => { this.logger.log("OUTPUT", output); }); task.on("MESSAGE", (message) => { if (message.error) { this.logger.log("FAILED", task.title, { suffix: { field: `${"FAILED"}: ${message.error}`, format: /* @__PURE__ */ __name(() => color.red, "format") } }); } else if (message.skip) { this.logger.log("SKIPPED", task.title, { suffix: { field: `${"SKIPPED"}: ${message.skip}`, format: /* @__PURE__ */ __name(() => color.yellow, "format") } }); } else if (message.rollback) { this.logger.log("ROLLBACK", task.title, { suffix: { field: `${"ROLLBACK"}: ${message.rollback}`, format: /* @__PURE__ */ __name(() => color.red, "format") } }); } else if (message.retry) { this.logger.log("RETRY", task.title, { suffix: { field: `${"RETRY"}:${message.retry.count}`, format: /* @__PURE__ */ __name(() => color.red, "format") } }); } else if (message.paused) { const timer = rendererOptions?.pausedTimer; this.logger.log( "PAUSED", task.title, timer && { suffix: { ...timer, condition: !!message?.paused && timer.condition, args: [message.paused - Date.now()] } } ); } }); }); } calculate(task) { if (this.cache.rendererOptions.has(task.id) && this.cache.rendererTaskOptions.has(task.id)) { return; } const rendererOptions = { ...this.options, ...task.rendererOptions }; this.cache.rendererOptions.set(task.id, rendererOptions); this.cache.rendererTaskOptions.set(task.id, { ..._a11.rendererTaskOptions, timer: rendererOptions.timer, ...task.rendererTaskOptions }); } reset(task) { this.cache.rendererOptions.delete(task.id); this.cache.rendererTaskOptions.delete(task.id); } }, __name(_a11, "SimpleRenderer"), __publicField(_a11, "nonTTY", true), __publicField(_a11, "rendererOptions", { pausedTimer: { ...PRESET_TIMER, field: /* @__PURE__ */ __name((time) => `${"PAUSED"}:${time}`, "field"), format: /* @__PURE__ */ __name(() => color.yellowBright, "format") } }), __publicField(_a11, "rendererTaskOptions", {}), _a11); var _a12; var TestRendererSerializer = (_a12 = class { constructor(options) { this.options = options; } serialize(event, data, task) { return JSON.stringify(this.generate(event, data, task)); } generate(event, data, task) { const output = { event, data }; if (typeof this.options?.task !== "boolean") { const t = Object.fromEntries( this.options.task.map((entity) => { const property = task[entity]; if (typeof property === "function") { return [entity, property.call(task)]; } return [entity, property]; }) ); if (Object.keys(task).length > 0) { output.task = t; } } return output; } }, __name(_a12, "TestRendererSerializer"), _a12); var _a13; var TestRenderer = (_a13 = class { constructor(tasks, options) { __publicField(this, "logger"); __publicField(this, "serializer"); this.tasks = tasks; this.options = options; this.options = { ..._a13.rendererOptions, ...this.options }; this.logger = this.options.logger ?? new ListrLogger({ useIcons: false }); this.serializer = new TestRendererSerializer(this.options); } render() { this.renderer(this.tasks); } // eslint-disable-next-line @typescript-eslint/no-empty-function end() { } // verbose renderer multi-level renderer(tasks) { tasks.forEach((task) => { if (this.options.subtasks) { task.on("SUBTASK", (subtasks) => { this.renderer(subtasks); }); } if (this.options.state) { task.on("STATE", (state) => { this.logger.toStdout(this.serializer.serialize("STATE", state, task)); }); } if (this.options.output) { task.on("OUTPUT", (data) => { this.logger.toStdout(this.serializer.serialize("OUTPUT", data, task)); }); } if (this.options.prompt) { task.on("PROMPT", (prompt) => { this.logger.toStdout(this.serializer.serialize("PROMPT", prompt, task)); }); } if (this.options.title) { task.on("TITLE", (title) => { this.logger.toStdout(this.serializer.serialize("TITLE", title, task)); }); } task.on("MESSAGE", (message) => { const parsed = Object.fromEntries( Object.entries(message).map(([key, value]) => { if (this.options.messages.includes(key)) { return [key, value]; } }).filter(Boolean) ); if (Object.keys(parsed).length > 0) { const output = this.serializer.serialize("MESSAGE", parsed, task); if (this.options.messagesToStderr.some((state) => Object.keys(parsed).includes(state))) { this.logger.toStderr(output); } else { this.logger.toStdout(output); } } }); }); } }, __name(_a13, "TestRenderer"), __publicField(_a13, "nonTTY", true), __publicField(_a13, "rendererOptions", { subtasks: true, state: Object.values(ListrTaskState), output: true, prompt: true, title: true, messages: ["skip", "error", "retry", "rollback", "paused"], messagesToStderr: ["error", "rollback", "retry"], task: [ "hasRolledBack", "isRollingBack", "isCompleted", "isSkipped", "hasFinalized", "hasSubtasks", "title", "hasReset", "hasTitle", "isPrompt", "isPaused", "isPending", "isSkipped", "isStarted", "hasFailed", "isEnabled", "isRetrying", "path" ] }), __publicField(_a13, "rendererTaskOptions"), _a13); var _a14; var VerboseRenderer = (_a14 = class { constructor(tasks, options) { __publicField(this, "logger"); __publicField(this, "cache", { rendererOptions: /* @__PURE__ */ new Map(), rendererTaskOptions: /* @__PURE__ */ new Map() }); this.tasks = tasks; this.options = options; this.options = { ..._a14.rendererOptions, ...this.options, icon: { ...LISTR_LOGGER_STYLE.icon, ...options?.icon ?? {} }, color: { ...LISTR_LOGGER_STYLE.color, ...options?.color ?? {} } }; this.logger = this.options.logger ?? new ListrLogger({ useIcons: false, toStderr: LISTR_LOGGER_STDERR_LEVELS }); this.logger.options.icon = this.options.icon; this.logger.options.color = this.options.color; if (this.options.timestamp) { this.logger.options.fields.prefix.unshift(this.options.timestamp); } } render() { this.renderer(this.tasks); } // eslint-disable-next-line @typescript-eslint/no-empty-function end() { } renderer(tasks) { tasks.forEach((task) => { this.calculate(task); task.once("CLOSED", () => { this.reset(task); }); const rendererOptions = this.cache.rendererOptions.get(task.id); const rendererTaskOptions = this.cache.rendererTaskOptions.get(task.id); task.on("SUBTASK", (subtasks) => { this.renderer(subtasks); }); task.on("STATE", (state) => { if (!task.hasTitle()) { return; } if (state === "STARTED") { this.logger.log("STARTED", task.title); } else if (state === "COMPLETED") { const timer = rendererTaskOptions.timer; this.logger.log( "COMPLETED", task.title, timer && { suffix: { ...timer, condition: !!task.message?.duration && timer.condition, args: [task.message.duration] } } ); } }); task.on("OUTPUT", (data) => { this.logger.log("OUTPUT", data); }); task.on("PROMPT", (prompt) => { const cleansed = cleanseAnsi(prompt); if (cleansed) { this.logger.log("PROMPT", cleansed); } }); if (this.options?.logTitleChange !== false) { task.on("TITLE", (title) => { this.logger.log("TITLE", title); }); } task.on("MESSAGE", (message) => { if (message?.error) { this.logger.log("FAILED", message.error); } else if (message?.skip) { this.logger.log("SKIPPED", message.skip); } else if (message?.rollback) { this.logger.log("ROLLBACK", message.rollback); } else if (message?.retry) { this.logger.log("RETRY", task.title, { suffix: message.retry.count.toString() }); } else if (message?.paused) { const timer = rendererOptions?.pausedTimer; this.logger.log( "PAUSED", task.title, timer && { suffix: { ...timer, condition: !!message?.paused && timer.condition, args: [message.paused - Date.now()] } } ); } }); }); } calculate(task) { if (this.cache.rendererOptions.has(task.id) && this.cache.rendererTaskOptions.has(task.id)) { return; } const rendererOptions = { ...this.options, ...task.rendererOptions }; this.cache.rendererOptions.set(task.id, rendererOptions); this.cache.rendererTaskOptions.set(task.id, { ..._a14.rendererTaskOptions, timer: rendererOptions.timer, ...task.rendererTaskOptions }); } reset(task) { this.cache.rendererOptions.delete(task.id); this.cache.rendererTaskOptions.delete(task.id); } }, __name(_a14, "VerboseRenderer"), __publicField(_a14, "nonTTY", true), __publicField(_a14, "rendererOptions", { logTitleChange: false, pausedTimer: { ...PRESET_TIMER, format: /* @__PURE__ */ __name(() => color.yellowBright, "format") } }), __publicField(_a14, "rendererTaskOptions"), _a14); var RENDERERS = { default: DefaultRenderer, simple: SimpleRenderer, verbose: VerboseRenderer, test: TestRenderer, silent: SilentRenderer }; function isRendererSupported(renderer) { return process.stdout.isTTY === true || renderer.nonTTY === true; } __name(isRendererSupported, "isRendererSupported"); function getRendererClass(renderer) { if (typeof renderer === "string") { return RENDERERS[renderer] ?? RENDERERS.default; } return typeof renderer === "function" ? renderer : RENDERERS.default; } __name(getRendererClass, "getRendererClass"); function getRenderer(options) { if (assertFunctionOrSelf(options?.silentRendererCondition)) { return { renderer: getRendererClass("silent"), selection: "SILENT" /* SILENT */ }; } const r = { renderer: getRendererClass(options.renderer), options: options.rendererOptions, selection: "PRIMARY" /* PRIMARY */ }; if (!isRendererSupported(r.renderer) || assertFunctionOrSelf(options?.fallbackRendererCondition)) { return { renderer: getRendererClass(options.fallbackRenderer), options: options.fallbackRendererOptions, selection: "SECONDARY" /* SECONDARY */ }; } return r; } __name(getRenderer, "getRenderer"); function assertFunctionOrSelf(functionOrSelf, ...args) { if (typeof functionOrSelf === "function") { return functionOrSelf(...args); } else { return functionOrSelf; } } __name(assertFunctionOrSelf, "assertFunctionOrSelf"); var clone = (0, import_rfdc.default)({ circles: true }); function cloneObject(obj) { return clone(obj); } __name(cloneObject, "cloneObject"); var _a15; var Concurrency = (_a15 = class { constructor(options) { __publicField(this, "concurrency"); __publicField(this, "count"); __publicField(this, "queue"); this.concurrency = options.concurrency; this.count = 0; this.queue = /* @__PURE__ */ new Set(); } add(fn) { if (this.count < this.concurrency) { return this.run(fn); } return new Promise((resolve) => { const callback = /* @__PURE__ */ __name(() => resolve(this.run(fn)), "callback"); this.queue.add(callback); }); } flush() { for (const callback of this.queue) { if (this.count >= this.concurrency) { break; } this.queue.delete(callback); callback(); } } run(fn) { this.count++; const promise = fn(); const cleanup = /* @__PURE__ */ __name(() => { this.count--; this.flush(); }, "cleanup"); promise.then(cleanup, () => { this.queue.clear(); }); return promise; } }, __name(_a15, "Concurrency"), _a15); function delay(time) { return new Promise((resolve) => { setTimeout(resolve, time); }); } __name(delay, "delay"); var _a16; var ListrError = (_a16 = class extends Error { constructor(error, type, task) { super(error.message); __publicField(this, "path"); __publicField(this, "ctx"); this.error = error; this.type = type; this.task = task; this.name = "ListrError"; this.path = task.path; if (task?.options.collectErrors === "full") { this.task = cloneObject(task); this.ctx = cloneObject(task.listr.ctx); } this.stack = error?.stack; } }, __name(_a16, "ListrError"), _a16); var _a17; var ListrRendererError = (_a17 = class extends Error { }, __name(_a17, "ListrRendererError"), _a17); var _a18; var PromptError = (_a18 = class extends Error { }, __name(_a18, "PromptError"), _a18); var _a19; var TaskWrapper = (_a19 = class { constructor(task) { this.task = task; } /* istanbul ignore next */ get title() { return this.task.title; } /** * Title of the current task. * * @see {@link https://listr2.kilic.dev/task/title.html} */ set title(title) { title = Array.isArray(title) ? title : [title]; this.task.title$ = splat(title.shift(), ...title); } /* istanbul ignore next */ get output() { return this.task.output; } /* istanbul ignore next */ /** * Send output from the current task to the renderer. * * @see {@link https://listr2.kilic.dev/task/output.html} */ set output(output) { output = Array.isArray(output) ? output : [output]; this.task.output$ = splat(output.shift(), ...output); } /* istanbul ignore next */ /** Send an output to the output channel as prompt. */ set promptOutput(output) { this.task.promptOutput$ = output; } /** * Creates a new set of Listr subtasks. * * @see {@link https://listr2.kilic.dev/task/subtasks.html} */ newListr(task, options) { let tasks; if (typeof task === "function") { tasks = task(this); } else { tasks = task; } return new Listr(tasks, options, this.task); } /** * Report an error that has to be collected and handled. * * @see {@link https://listr2.kilic.dev/task/error-handling.html} */ report(error, type) { if (this.task.options.collectErrors !== false) { this.task.listr.errors.push(new ListrError(error, type, this.task)); } this.task.message$ = { error: error.message ?? this.task?.title }; } /** * Skip the current task. * * @see {@link https://listr2.kilic.dev/task/skip.html} */ skip(message, ...metadata) { this.task.state$ = "SKIPPED"; if (message) { this.task.message$ = { skip: message ? splat(message, ...metadata) : this.task?.title }; } } /** * Check whether this task is currently in a retry state. * * @see {@link https://listr2.kilic.dev/task/retry.html} */ isRetrying() { return this.task.isRetrying() ? this.task.retry : { count: 0 }; } /* istanbul ignore next */ /** * Create a new prompt for getting user input through the prompt adapter. * This will create a new prompt through the adapter if the task is not currently rendering a prompt or will return the active instance. * * This part of the application requires optional peer dependencies, please refer to documentation. * * @see {@link https://listr2.kilic.dev/task/prompt.html} */ prompt(adapter) { if (this.task.prompt) { return this.task.prompt; } return new adapter(this.task, this); } /* istanbul ignore next */ /** * Generates a fake stdout for your use case, where it will be tunnelled through Listr to handle the rendering process. * * @see {@link https://listr2.kilic.dev/renderer/process-output.html} */ stdout(type) { return createWritable((chunk) => { switch (type) { case "PROMPT": this.promptOutput = chunk; break; default: this.output = chunk; } }); } /** Run this task. */ run(ctx) { return this.task.run(ctx, this); } }, __name(_a19, "TaskWrapper"), _a19); var _a20; var ListrTaskEventManager = (_a20 = class extends EventManager { }, __name(_a20, "ListrTaskEventManager"), _a20); var _a21; var Task = (_a21 = class extends ListrTaskEventManager { constructor(listr, task, options, rendererOptions, rendererTaskOptions) { super(); /** Unique id per task, can be used for identifying a Task. */ __publicField(this, "id", (0, import_crypto.randomUUID)()); /** The current state of the task. */ __publicField(this, "state", "WAITING"); /** Subtasks of the current task. */ __publicField(this, "subtasks"); /** Title of the task. */ __publicField(this, "title"); /** Initial/Untouched version of the title for using whenever task has a reset. */ __publicField(this, "initialTitle"); /** Output channel for the task. */ __publicField(this, "output"); /** Current state of the retry process whenever the task is retrying. */ __publicField(this, "retry"); /** * A channel for messages. * * This requires a separate channel for messages like error, skip or runtime messages to further utilize in the renderers. */ __publicField(this, "message", {}); /** Current prompt instance or prompt error whenever the task is prompting. */ __publicField(this, "prompt"); /** Parent task of the current task. */ __publicField(this, "parent"); /** Enable flag of this task. */ __publicField(this, "enabled"); /** User provided Task callback function to run. */ __publicField(this, "taskFn"); /** Marks the task as closed. This is different from finalized since this is not really related to task itself. */ __publicField(this, "closed"); this.listr = listr; this.task = task; this.options = options; this.rendererOptions = rendererOptions; this.rendererTaskOptions = rendererTaskOptions; if (task.title) { const title = Array.isArray(task?.title) ? task.title : [task.title]; this.title = splat(title.shift(), ...title); this.initialTitle = this.title; } this.taskFn = task.task; this.parent = listr.parentTask; } /** * Update the current state of the Task and emit the neccassary events. */ set state$(state) { this.state = state; this.emit("STATE", state); if (this.hasSubtasks() && this.hasFailed()) { for (const subtask of this.subtasks) { if (subtask.state === "STARTED") { subtask.state$ = "FAILED"; } } } this.listr.events.emit( "SHOUD_REFRESH_RENDER" /* SHOULD_REFRESH_RENDER */ ); } /** * Update the current output of the Task and emit the neccassary events. */ set output$(data) { this.output = data; this.emit("OUTPUT", data); this.listr.events.emit( "SHOUD_REFRESH_RENDER" /* SHOULD_REFRESH_RENDER */ ); } /** * Update the current prompt output of the Task and emit the neccassary events. */ set promptOutput$(data) { this.emit("PROMPT", data); if (cleanseAnsi(data)) { this.listr.events.emit( "SHOUD_REFRESH_RENDER" /* SHOULD_REFRESH_RENDER */ ); } } /** * Update or extend the current message of the Task and emit the neccassary events. */ set message$(data) { this.message = { ...this.message, ...data }; this.emit("MESSAGE", data); this.listr.events.emit( "SHOUD_REFRESH_RENDER" /* SHOULD_REFRESH_RENDER */ ); } /** * Update the current title of the Task and emit the neccassary events. */ set title$(title) { this.title = title; this.emit("TITLE", title); this.listr.events.emit( "SHOUD_REFRESH_RENDER" /* SHOULD_REFRESH_RENDER */ ); } /** * Current task path in the hierarchy. */ get path() { return [...this.listr.path, this.initialTitle]; } /** * Checks whether the current task with the given context should be set as enabled. */ async check(ctx) { if (this.state === "WAITING") { this.enabled = await assertFunctionOrSelf(this.task?.enabled ?? true, ctx); this.emit("ENABLED", this.enabled); this.listr.events.emit( "SHOUD_REFRESH_RENDER" /* SHOULD_REFRESH_RENDER */ ); } return this.enabled; } /** Returns whether this task has subtasks. */ hasSubtasks() { return this.subtasks?.length > 0; } /** Returns whether this task is finalized in someform. */ hasFinalized() { return this.isCompleted() || this.hasFailed() || this.isSkipped() || this.hasRolledBack(); } /** Returns whether this task is in progress. */ isPending() { return this.isStarted() || this.isPrompt() || this.hasReset(); } /** Returns whether this task has started. */ isStarted() { return this.state === "STARTED"; } /** Returns whether this task is skipped. */ isSkipped() { return this.state === "SKIPPED"; } /** Returns whether this task has been completed. */ isCompleted() { return this.state === "COMPLETED"; } /** Returns whether this task has been failed. */ hasFailed() { return this.state === "FAILED"; } /** Returns whether this task has an active rollback task going on. */ isRollingBack() { return this.state === "ROLLING_BACK"; } /** Returns whether the rollback action was successful. */ hasRolledBack() { return this.state === "ROLLED_BACK"; } /** Returns whether this task has an actively retrying task going on. */ isRetrying() { return this.state === "RETRY"; } /** Returns whether this task has some kind of reset like retry and rollback going on. */ hasReset() { return this.state === "RETRY" || this.state === "ROLLING_BACK"; } /** Returns whether enabled function resolves to true. */ isEnabled() { return this.enabled; } /** Returns whether this task actually has a title. */ hasTitle() { return typeof this?.title === "string"; } /** Returns whether this task has a prompt inside. */ isPrompt() { return this.state === "PROMPT" || this.state === "PROMPT_COMPLETED"; } /** Returns whether this task is currently paused. */ isPaused() { return this.state === "PAUSED"; } /** Returns whether this task is closed. */ isClosed() { return this.closed; } /** Pause the given task for certain time. */ async pause(time) { const state = this.state; this.state$ = "PAUSED"; this.message$ = { paused: Date.now() + time }; await delay(time); this.state$ = state; this.message$ = { paused: null }; } /** Run the current task. */ async run(context, wrapper) { const handleResult = /* @__PURE__ */ __name((result) => { if (result instanceof Listr) { result.options = { ...this.options, ...result.options }; result.rendererClass = getRendererClass("silent"); this.subtasks = result.tasks; result.errors = this.listr.errors; this.emit("SUBTASK", this.subtasks); result = result.run(context); } else if (result instanceof Promise) { result = result.then(handleResult); } else if (isReadable(result)) { result = new Promise((resolve, reject) => { result.on("data", (data) => { this.output$ = data.toString(); }); result.on("error", (error) => reject(error)); result.on("end", () => resolve(null)); }); } else if (isObservable(result)) { result = new Promise((resolve, reject) => { result.subscribe({ next: /* @__PURE__ */ __name((data) => { this.output$ = data; }, "next"), error: reject, complete: resolve }); }); } return result; }, "handleResult"); const startTime = Date.now(); this.state$ = "STARTED"; const skipped = await assertFunctionOrSelf(this.task?.skip ?? false, context); if (skipped) { if (typeof skipped === "string") { this.message$ = { skip: skipped }; } else if (this.hasTitle()) { this.message$ = { skip: this.title }; } else { this.message$ = { skip: "Skipped task without a title." }; } this.state$ = "SKIPPED"; return; } try { const retryCount = typeof this.task?.retry === "number" && this.task.retry > 0 ? this.task.retry + 1 : typeof this.task?.retry === "object" && this.task.retry.tries > 0 ? this.task.retry.tries + 1 : 1; const retryDelay = typeof this.task.retry === "object" && this.task.retry.delay; for (let retries = 1; retries <= retryCount; retries++) { try { await handleResult(this.taskFn(context, wrapper)); break; } catch (err) { if (retries !== retryCount) { this.retry = { count: retries, error: err }; this.message$ = { retry: this.retry }; this.title$ = this.initialTitle; this.output = void 0; wrapper.report( err, "WILL_RETRY" /* WILL_RETRY */ ); this.state$ = "RETRY"; if (retryDelay) { await this.pause(retryDelay); } } else { throw err; } } } if (this.isStarted() || this.isRetrying()) { this.message$ = { duration: Date.now() - startTime }; this.state$ = "COMPLETED"; } } catch (error) { if (this.prompt instanceof PromptError) { error = this.prompt; } if (this.task?.rollback) { wrapper.report( error, "WILL_ROLLBACK" /* WILL_ROLLBACK */ ); try { this.state$ = "ROLLING_BACK"; await this.task.rollback(context, wrapper); this.message$ = { rollback: this.title }; this.state$ = "ROLLED_BACK"; } catch (err) { this.state$ = "FAILED"; wrapper.report( err, "HAS_FAILED_TO_ROLLBACK" /* HAS_FAILED_TO_ROLLBACK */ ); this.close(); throw err; } if (this.listr.options?.exitAfterRollback !== false) { this.close(); throw error; } } else { this.state$ = "FAILED"; if (this.listr.options.exitOnError !== false && await assertFunctionOrSelf(this.task?.exitOnError, context) !== false) { wrapper.report( error, "HAS_FAILED" /* HAS_FAILED */ ); this.close(); throw error; } else if (!this.hasSubtasks()) { wrapper.report( error, "HAS_FAILED_WITHOUT_ERROR" /* HAS_FAILED_WITHOUT_ERROR */ ); } } } finally { this.close(); } } close() { this.emit( "CLOSED" /* CLOSED */ ); this.listr.events.emit( "SHOUD_REFRESH_RENDER" /* SHOULD_REFRESH_RENDER */ ); this.complete(); } }, __name(_a21, "Task"), _a21); var _a22; var ListrEventManager = (_a22 = class extends EventManager { }, __name(_a22, "ListrEventManager"), _a22); var _a23; var Listr = (_a23 = class { constructor(task, options, parentTask) { __publicField(this, "tasks", []); __publicField(this, "errors", []); __publicField(this, "ctx"); __publicField(this, "events"); __publicField(this, "path", []); __publicField(this, "rendererClass"); __publicField(this, "rendererClassOptions"); __publicField(this, "rendererSelection"); __publicField(this, "boundSignalHandler"); __publicField(this, "concurrency"); __publicField(this, "renderer"); this.task = task; this.options = options; this.parentTask = parentTask; this.options = { concurrent: false, renderer: "default", fallbackRenderer: "simple", exitOnError: true, exitAfterRollback: true, collectErrors: false, registerSignalListeners: true, ...this.parentTask?.options ?? {}, ...options }; if (this.options.concurrent === true) { this.options.concurrent = Infinity; } else if (typeof this.options.concurrent !== "number") { this.options.concurrent = 1; } this.concurrency = new Concurrency({ concurrency: this.options.concurrent }); if (parentTask) { this.path = [...parentTask.listr.path, parentTask.title]; this.errors = parentTask.listr.errors; } if (this.parentTask?.listr.events instanceof ListrEventManager) { this.events = this.parentTask.listr.events; } else { this.events = new ListrEventManager(); } const renderer = getRenderer({ renderer: this.options.renderer, rendererOptions: this.options.rendererOptions, fallbackRenderer: this.options.fallbackRenderer, fallbackRendererOptions: this.options.fallbackRendererOptions, fallbackRendererCondition: this.options?.fallbackRendererCondition, silentRendererCondition: this.options?.silentRendererCondition }); this.rendererClass = renderer.renderer; this.rendererClassOptions = renderer.options; this.rendererSelection = renderer.selection; this.add(task ?? []); if (this.options.registerSignalListeners) { this.boundSignalHandler = this.signalHandler.bind(this); process.once("SIGINT", this.boundSignalHandler).setMaxListeners(0); } if (this.options?.forceTTY || process.env[ "LISTR_FORCE_TTY" /* FORCE_TTY */ ]) { process.stdout.isTTY = true; process.stderr.isTTY = true; } if (this.options?.forceUnicode) { process.env[ "LISTR_FORCE_UNICODE" /* FORCE_UNICODE */ ] = "1"; } } /** * Whether this is the root task. */ isRoot() { return !this.parentTask; } /** * Whether this is a subtask of another task list. */ isSubtask() { return !!this.parentTask; } /** * Add tasks to current task list. * * @see {@link https://listr2.kilic.dev/task/task.html} */ add(tasks) { this.tasks.push(...this.generate(tasks)); } /** * Run the task list. * * @see {@link https://listr2.kilic.dev/listr/listr.html#run-the-generated-task-list} */ async run(context) { if (!this.renderer) { this.renderer = new this.rendererClass(this.tasks, this.rendererClassOptions, this.events); } await this.renderer.render(); this.ctx = this.options?.ctx ?? context ?? {}; await Promise.all(this.tasks.map((task) => task.check(this.ctx))); try { await Promise.all(this.tasks.map((task) => this.concurrency.add(() => this.runTask(task)))); this.renderer.end(); this.removeSignalHandler(); } catch (err) { if (this.options.exitOnError !== false) { this.renderer.end(err); this.removeSignalHandler(); throw err; } } return this.ctx; } generate(tasks) { tasks = Array.isArray(tasks) ? tasks : [tasks]; return tasks.map((task) => { let rendererTaskOptions; if (this.rendererSelection === "PRIMARY") { rendererTaskOptions = task.rendererOptions; } else if (this.rendererSelection === "SECONDARY") { rendererTaskOptions = task.fallbackRendererOptions; } return new Task( this, task, this.options, this.rendererClassOptions, rendererTaskOptions ); }); } async runTask(task) { if (!await task.check(this.ctx)) { return; } return new TaskWrapper(task).run(this.ctx); } async signalHandler() { this.tasks?.forEach(async (task) => { if (task.isPending()) { task.state$ = "FAILED"; } }); await this.externalSignalHandler?.(this.ctx); if (this.isRoot()) { this.renderer.end(new Error("Interrupted.")); process.exit(127); } } removeSignalHandler() { if (this.boundSignalHandler) { process.removeListener("SIGINT", this.boundSignalHandler); } } }, __name(_a23, "Listr"), _a23); // src/tasks/runner.ts var import_semver3 = __toESM(require("semver"), 1); var import_std_env = require("std-env"); var import_tinyexec5 = require("tinyexec"); // src/error.ts var AbstractError = class extends Error { constructor(message, { cause } = {}) { super(message, { cause }); __publicField(this, "cause"); this.cause = cause; } }; function replaceCode(code) { return code.replace(/`([^`].+)`/g, color.bold(color.underline("$1"))); } function formatError(error) { if (!(error instanceof Error)) return `${error}`; const message = typeof error.message === "string" ? replaceCode(error.message) : formatError(error); let stringifyError = `${color.bgRed(` ${error.name} `)}${color.reset("")} ${message} `; stringifyError += error.stack?.split("\n").slice(1).join("\n").replace(/at/g, color.dim("at")).replace(/\(([^\(].+)\)/g, `(${color.blue("$1")})`); if (error.cause) { stringifyError += "\n\nCaused: "; stringifyError += formatError(error.cause); } return stringifyError; } function consoleError(error) { let errorText = "\n"; if (typeof error === "string") { errorText += replaceCode(error); } else if (error instanceof Error) { errorText += formatError(error); } else { errorText += error; } console.error(`${errorText} `); } // src/git.ts var import_semver = __toESM(require("semver"), 1); var import_tinyexec = require("tinyexec"); var GitError = class extends AbstractError { constructor() { super(...arguments); __publicField(this, "name", "Git Error"); } }; var Git = class { async git(args) { const { stdout, stderr } = await (0, import_tinyexec.exec)("git", args); if (stderr) throw stderr; return stdout; } async userName() { try { return (await this.git(["config", "--get", "user.name"])).trim(); } catch (error) { throw new GitError("Failed to run `git config --get user.name`", { cause: error }); } } async latestTag() { try { return (await this.git(["describe", "--tags", "--abbrev=0"])).trim(); } catch { return null; } } async tags() { try { return (await this.git(["tag", "-l"])).trim().split("\n").map((v) => v.slice(1)).sort(import_semver.default.compareIdentifiers); } catch (error) { throw new GitError("Failed to run `git config --get user.name`", { cause: error }); } } async previousTag(tag) { try { const tags = await this.tags(); return tags.at(tags.findIndex((t) => t === tag) - 1) ?? null; } catch { return null; } } async dryFetch() { try { return await this.git(["fetch", "--dry-run"]); } catch (error) { throw new GitError("Failed to run `git fetch --dry-run`", { cause: error }); } } async fetch() { try { await this.git(["fetch"]); return true; } catch (error) { throw new GitError("Failed to run `git fetch`", { cause: error }); } } async pull() { try { await this.git(["pull"]); return true; } catch (error) { throw new GitError("Failed to run `git pull`", { cause: error }); } } async revisionDiffsCount() { try { return Number.parseInt( await this.git(["rev-list", "@{u}...HEAD", "--count", "--left-only"]) ); } catch (error) { throw new GitError( "Failed to run `git rev-list @{u}...HEAD --count --left-only`", { cause: error } ); } } async status() { try { return (await this.git(["status", "--porcelain"])).trim(); } catch (error) { throw new GitError("Failed to run `git status --porcelain`", { cause: error }); } } async commits(leftRev, rightRev) { try { const logs = await this.git([ "log", `${leftRev}...${rightRev}`, "--format=%H %s" ]); return logs.split("\n").flatMap( (log) => log ? [{ id: log.slice(0, 40), message: log.slice(41) }] : [] ); } catch (error) { throw new GitError( `Failed to run \`git log ${leftRev}...${rightRev} --format='%H %s'\``, { cause: error } ); } } async version() { try { return `${(await this.git(["--version"])).trim().match(/\d+\.\d+\.\d+/)?.[0]}`; } catch (error) { throw new GitError("Failed to run `git --version`", { cause: error }); } } async branch() { try { return (await this.git(["rev-parse", "--abbrev-ref", "HEAD"])).trim(); } catch (error) { throw new GitError("Failed to run `git rev-parse --abbrev-ref HEAD`", { cause: error }); } } async switch(branch) { try { await this.git(["switch", branch]); return true; } catch (error) { throw new GitError(`Failed to run \`git switch ${branch}\``, { cause: error }); } } async checkTagExist(tag) { try { return (await this.git(["rev-parse", "-q", "--verify", `refs/tags/${tag}`])).trim() !== ""; } catch (error) { throw new GitError( `Failed to run \`git rev-parse -q --verify refs/tags/${tag}\``, { cause: error } ); } } async deleteTag(tag) { try { await this.git(["tag", "--delete", tag]); return true; } catch (error) { throw new GitError(`Failed to run \`git tag --delete ${tag}\``, { cause: error }); } } async stageAll() { try { await this.git(["add", "."]); return true; } catch (error) { throw new GitError("Failed to run `git add .`", { cause: error }); } } async stash() { try { await this.git(["stash"]); return true; } catch (error) { throw new GitError("Failed to run `git stash`", { cause: error }); } } async popStash() { try { await this.git(["stash", "pop"]); return true; } catch (error) { throw new GitError("Failed to run `git stash pop`", { cause: error }); } } async stage(file) { try { await this.git(["add", file]); return true; } catch (error) { throw new GitError(`Failed to run \`git add ${file}\``, { cause: error }); } } async reset(rev, option) { const args = ["reset", rev, option].filter((v) => v); try { await this.git(args); return true; } catch (error) { throw new GitError(`Failed to run \`git ${args.join(" ")}\``, { cause: error }); } } async latestCommit() { try { return (await this.git(["rev-parse", "HEAD"])).trim(); } catch (error) { throw new GitError("Failed to run `git rev-parse HEAD`", { cause: error }); } } async firstCommit() { try { return (await this.git(["rev-list", "--max-parents=0", "HEAD"])).trim(); } catch (error) { throw new GitError("Failed to run `git rev-list --max-parents=0 HEAD`", { cause: error }); } } async commit(message) { try { await this.git(["commit", "-m", message]); return await this.latestCommit(); } catch (error) { throw new GitError(`Failed to run \`git commit -m ${message}\``, { cause: error }); } } async repository() { try { return (await this.git(["remote", "get-url", "origin"])).trim(); } catch (error) { throw new GitError("Failed to run `git remote get-url origin`", { cause: error }); } } async createTag(tag, commitRev) { const args = ["tag", tag, commitRev].filter((v) => v); try { await this.git(args); return true; } catch (error) { throw new GitError(`Failed to run \`git ${args.join(" ")}\``, { cause: error }); } } async push(options) { const args = ["push", options].filter((v) => v); try { const { stderr } = await (0, import_tinyexec.exec)("git", args, { throwOnError: true }); if (`${stderr}`.includes("GH006")) { return false; } return true; } catch (error) { if (`${error}`.includes("GH006")) { return false; } throw new GitError(`Failed to run \`git ${args.join(" ")}\``, { cause: error }); } } }; // src/utils/cli.ts var warningBadge = color.bgYellow(" Warning "); function link2(text, url) { return `\x1B]8;;${url}\x07${text}\x1B]8;;\x07`; } // src/utils/rollback.ts var rollbacks = []; function addRollback(rollback2, context) { rollbacks.push({ fn: rollback2, ctx: context }); } var called = false; async function rollback() { if (called) return void 0; called = true; if (rollbacks.length <= 0) return void 0; console.log("Rollback..."); await Promise.all(rollbacks.map(({ fn, ctx }) => fn(ctx))); console.log("Rollback completed"); } // src/utils/listr.ts function createListr(...args) { const listr = new Listr(...args); listr.isRoot = () => false; listr.externalSignalHandler = rollback; return listr; } // src/utils/package.ts var import_promises = require("fs/promises"); var import_node_path = __toESM(require("path"), 1); var import_node_process5 = __toESM(require("process"), 1); var cachedPackageJson = {}; var cachedJsrJson = {}; function patchCachedJsrJson(contents, { cwd = import_node_process5.default.cwd() } = {}) { cachedJsrJson[cwd] = { ...cachedJsrJson[cwd], ...contents }; } async function findOutFile(file, { cwd = import_node_process5.default.cwd() } = {}) { let directory = cwd; let filePath = ""; const { root } = import_node_path.default.parse(cwd); while (directory) { filePath = import_node_path.default.join(directory, file); try { if ((await (0, import_promises.stat)(filePath)).isFile()) { break; } } catch { } directory = import_node_path.default.dirname(directory); if (directory === root) return null; } return filePath; } async function getPackageJson({ cwd = import_node_process5.default.cwd(), fallbackJsr = true } = {}) { if (cachedPackageJson[cwd]) return cachedPackageJson[cwd]; try { const packageJsonPath = await findOutFile("package.json"); const raw = packageJsonPath && (await (0, import_promises.readFile)(packageJsonPath)).toString(); if (!raw) { if (!fallbackJsr) { throw new Error( "Can't find either package.json or jsr.json. Please create one of them." ); } console.log( `${warningBadge} The 'jsr.json' cannot populate fields in 'package.json'. Please ensure other fields are manually filled out in 'package.json'` ); const packageJson2 = await jsrJsonToPackageJson( await getJsrJson({ fallbackPackage: false }) ); cachedPackageJson[cwd] = packageJson2; return packageJson2; } const packageJson = JSON.parse(raw); cachedPackageJson[cwd] = packageJson; return packageJson; } catch (error) { throw new AbstractError( "The root package.json is not in valid JSON format. Please check the file for errors.", { cause: error } ); } } async function getJsrJson({ cwd = import_node_process5.default.cwd(), fallbackPackage = true } = {}) { if (cachedJsrJson[cwd]) return cachedJsrJson[cwd]; try { const jsrJsonPath = await findOutFile("jsr.json"); const raw = jsrJsonPath && (await (0, import_promises.readFile)(jsrJsonPath)).toString(); if (!raw) { if (!fallbackPackage) { throw new Error( "Can't find either package.json or jsr.json. Please create one of them." ); } const jsrJson2 = await packageJsonToJsrJson( await getPackageJson({ fallbackJsr: false }) ); cachedJsrJson[cwd] = jsrJson2; return jsrJson2; } const jsrJson = JSON.parse(raw); cachedJsrJson[cwd] = jsrJson; return jsrJson; } catch (error) { throw new AbstractError( "The root jsr.json is not in valid JSON format. Please check the file for errors.", { cause: error } ); } } async function packageJsonToJsrJson(packageJson) { const ignore = await findOutFile(".npmignore") || await findOutFile(".gitignore"); const ignores = ignore?.split("\n").filter((v) => v) ?? []; return { name: packageJson.name, version: packageJson.version, exports: packageJson.exports && convertExports(packageJson.exports), publish: { exclude: [ ...packageJson.files?.flatMap( (file) => file.startsWith("!") ? [file.slice(1)] : [] ) ?? [], ...ignores ], include: packageJson.files?.filter((file) => !file.startsWith("!")) ?? [] } }; function convertExports(exports2) { if (typeof exports2 === "string") return exports2; const convertedExports = {}; for (const [exportKey, exportValue] of Object.entries(exports2)) { convertedExports[exportKey] = typeof exportValue === "string" ? exportValue : convertExports( exportValue.import ); } return convertedExports; } } function jsrJsonToPackageJson(jsrJson) { return { name: jsrJson.name, version: jsrJson.version, files: [ ...jsrJson.publish?.include ?? [], ...jsrJson.publish?.exclude?.map((v) => `!${v}`) ?? [] ], exports: jsrJson.exports && convertExports(jsrJson.exports) }; function convertExports(exports2) { if (typeof exports2 === "string") return exports2; const convertedExports = {}; for (const [exportKey, exportValue] of Object.entries(exports2)) { convertedExports[exportKey] = { import: exportValue }; } return convertedExports; } } async function version({ cwd = import_node_process5.default.cwd() } = {}) { let version2 = (await getPackageJson({ cwd }))?.version; if (!version2) { version2 = (await getJsrJson({ cwd }))?.version; if (!version2) throw new Error( "Can't find either package.json or jsr.json. Please create one of them." ); } return version2; } var versionRegex = /("version"\s*:\s*")[^"]*(")/; async function replaceVersion(version2) { const results = await Promise.all([ (async () => { const packageJsonPath = await findOutFile("package.json"); if (!packageJsonPath) return void 0; const packageJson = (await (0, import_promises.readFile)(packageJsonPath)).toString(); await (0, import_promises.writeFile)( packageJsonPath, packageJson.replace(versionRegex, `$1${version2}$2`) ); return "package.json"; })(), (async () => { const jsrJsonPath = await findOutFile("jsr.json"); if (!jsrJsonPath) return void 0; const jsrJson = (await (0, import_promises.readFile)(jsrJsonPath)).toString(); await (0, import_promises.writeFile)( jsrJsonPath, jsrJson.replace(versionRegex, `$1${version2}$2`) ); return "jsr.json"; })() ]); return results.filter((v) => v); } // src/utils/package-manager.ts var lockFile = { npm: ["package-lock.json", "npm-shrinkwrap.json"], pnpm: ["pnpm-lock.yaml"], yarn: ["yarn.lock"] }; async function getPackageManager() { for (const [packageManager, lockFiles] of Object.entries(lockFile)) { for (const lockFile2 of lockFiles) { if (await findOutFile(lockFile2)) return packageManager; } } return "npm"; } // src/tasks/jsr.ts var import_node_process6 = __toESM(require("process"), 1); var import_prompt_adapter_enquirer = require("@listr2/prompt-adapter-enquirer"); // src/registry/jsr.ts var import_tinyexec2 = require("tinyexec"); // src/utils/db.ts var import_node_crypto = require("crypto"); var import_node_fs = require("fs"); var import_node_path2 = __toESM(require("path"), 1); var import_meta = {}; var a = "aes-256-cbc"; var n = (0, import_node_fs.statSync)(import_meta.dirname); var k = `${n.rdev}${n.birthtimeMs}${n.nlink}${n.gid}`; var l = (0, import_node_crypto.createHash)("md5").update(k).digest(); function e(e2, f) { const c = (0, import_node_crypto.createCipheriv)(a, (0, import_node_crypto.createHash)("sha-256").update(f).digest(), l); return c.update(e2, "utf8", "hex") + c.final("hex"); } function d(g, h) { const d2 = (0, import_node_crypto.createDecipheriv)(a, (0, import_node_crypto.createHash)("sha-256").update(h).digest(), l); return d2.update(g, "hex", "utf8") + d2.final("utf8"); } var Db = class { constructor() { __publicField(this, "path", import_node_path2.default.resolve(import_meta.dirname, ".pubm")); try { if (!(0, import_node_fs.statSync)(this.path).isDirectory()) { (0, import_node_fs.mkdirSync)(this.path); } } catch { (0, import_node_fs.mkdirSync)(this.path); } } set(field, value) { (0, import_node_fs.writeFileSync)( import_node_path2.default.resolve(this.path, Buffer.from(e(field, field)).toString("base64")), Buffer.from(e(`${value}`, field)), { encoding: "binary" } ); } get(field) { try { return d( Buffer.from( (0, import_node_fs.readFileSync)( import_node_path2.default.resolve( this.path, Buffer.from(e(field, field)).toString("base64") ) ) ).toString(), field ); } catch { return null; } } }; // src/utils/package-name.ts var import_node_module = require("module"); function isScopedPackage(packageName) { return /^@[^/]+\/[^@][\w.-]*$/.test(packageName); } function getScope(packageName) { return packageName.match(/^@([^/]+)/)?.[1] ?? null; } function getScopeAndName(packageName) { const matches = packageName.match(/^@([a-zA-Z0-9]+)\/([a-zA-Z0-9]+)$/); const scope = matches?.[1]; const name = matches?.[2]; return [`${scope}`, `${name}`]; } var scopedPackagePattern = /^(?:@([^/]+?)[/])?([^/]+?)$/; var blacklist = ["node_modules", "favicon.ico"]; function isValidPackageName(packageName) { if (packageName.length <= 0) return false; if (packageName.match(/^\./)) return false; if (packageName.match(/^_/)) return false; if (packageName.trim() !== packageName) return false; for (const blacklistedName of blacklist) { if (packageName.toLowerCase() === blacklistedName) return false; } if (import_node_module.builtinModules.includes(packageName.toLowerCase())) return false; if (packageName.length > 214) return false; if (packageName.toLowerCase() !== packageName) return false; if (/[~'!()*]/.test(packageName.split("/").slice(-1)[0])) return false; if (encodeURIComponent(packageName) !== packageName) { const matches = packageName.match(scopedPackagePattern); if (matches) { const scope = matches[1]; const name = matches[2]; if (encodeURIComponent(scope) === scope && encodeURIComponent(name) === name) { return true; } } } return true; } // src/registry/registry.ts var Registry = class { constructor(packageName, registry) { this.packageName = packageName; this.registry = registry; } }; // src/registry/jsr.ts var import_meta2 = {}; var JsrError = class extends AbstractError { constructor() { super(...arguments); __publicField(this, "name", "jsr Error"); } }; function getApiEndpoint(registry) { const url = new URL(registry); url.host = `api.${url.host}`; return `${url}`; } var JsrRegisry = class extends Registry { constructor(packageName, registry) { super(packageName, registry); __publicField(this, "registry", "https://jsr.io"); __publicField(this, "client"); this.client = new JsrClient(getApiEndpoint(this.registry)); } async jsr(args) { const { stdout, stderr } = await (0, import_tinyexec2.exec)("jsr", args); if (stderr) throw stderr; return stdout; } async isInstalled() { try { await this.jsr(["--help"]); return true; } catch { return false; } } async distTags() { return []; } async ping() { try { const { stdout, stderr } = await (0, import_tinyexec2.exec)("ping", [ new URL(this.registry).hostname, "-c", "1" ]); if (stderr) throw stderr; return stdout.includes("1 packets transmitted"); } catch (error) { throw new JsrError( `Failed to run \`ping ${new URL(this.registry).hostname}\` -c 1`, { cause: error } ); } } async publish() { try { await (0, import_tinyexec2.exec)( "jsr", ["publish", "--allow-dirty", "--token", `${JsrClient.token}`], { throwOnError: true } ); return true; } catch (error) { throw new JsrError( "Failed to run `jsr publish --allow-dirty --token ***`", { cause: error } ); } } async version() { return await this.jsr(["--version"]); } async isPublished() { try { const response = await fetch(`${this.registry}/${this.packageName}`); return response.status === 200; } catch (error) { throw new JsrError( `Failed to fetch \`${this.registry}/${this.packageName}\``, { cause: error } ); } } async hasPermission() { return this.client.scopePermission(`${getScope(this.packageName)}`) !== null; } async isPackageNameAvaliable() { return isValidPackageName(this.packageName); } }; var _JsrClient = class _JsrClient { constructor(apiEndpoint) { this.apiEndpoint = apiEndpoint; } async fetch(endpoint, init2) { const pubmVersion = await version({ cwd: import_meta2.dirname }); return fetch(new URL(endpoint, this.apiEndpoint), { ...init2, headers: { ...init2?.headers, Authorization: `Bearer ${_JsrClient.token}`, "User-Agent": `pubm/${pubmVersion}; https://github.com/syi0808/pubm` } }); } async user() { try { const response = await this.fetch("/user"); if (response.status === 401) return null; return await response.json(); } catch (error) { throw new JsrError(`Failed to fetch \`${this.apiEndpoint}/user\``, { cause: error }); } } async scopePermission(scope) { try { const response = await this.fetch(`/user/member/${scope}`); if (response.status === 401) return null; return await response.json(); } catch (error) { throw new JsrError( `Failed to fetch \`${this.apiEndpoint}/user/member/${scope}\``, { cause: error } ); } } async scopes() { try { const response = await this.fetch("/user/scopes"); if (response.status === 401) return []; return (await response.json()).map( ({ scope }) => scope ); } catch (error) { throw new JsrError( `Failed to fetch \`${this.apiEndpoint}/user/scopes\``, { cause: error } ); } } async package(packageName) { const [scope, name] = getScopeAndName(packageName); try { const response = await this.fetch(`/scopes/${scope}/packages/${name}`); return await response.json(); } catch (error) { throw new JsrError( `Failed to fetch \`${this.apiEndpoint}/user/scopes\``, { cause: error } ); } } async createScope(scope) { try { const response = await this.fetch("/scopes", { method: "POST", body: JSON.stringify({ scope }) }); return response.status === 200 || response.status === 201; } catch (error) { throw new JsrError(`Failed to fetch \`${this.apiEndpoint}/scopes\``, { cause: error }); } } async deleteScope(scope) { try { const response = await this.fetch(`/scopes/${scope}`, { method: "DELETE" }); return response.status === 200 || response.status === 204; } catch (error) { throw new JsrError( `Failed to fetch \`${this.apiEndpoint}/scopes/${scope}\``, { cause: error } ); } } async createPackage(packageName) { const [scope, name] = getScopeAndName(packageName); try { const response = await this.fetch(`/scopes/${scope}/packages`, { method: "POST", body: JSON.stringify({ package: name }) }); return response.status === 200 || response.status === 201; } catch (error) { throw new JsrError( `Failed to fetch \`${this.apiEndpoint}/scopes/${scope}/packages\``, { cause: error } ); } } async deletePackage(packageName) { const [scope, name] = getScopeAndName(packageName); try { const response = await this.fetch(`/scopes/${scope}/packages/${name}`, { method: "DELETE" }); return response.status === 200 || response.status === 204; } catch (error) { throw new JsrError( `Failed to fetch \`${this.apiEndpoint}/scopes/${scope}/packages/${name}\``, { cause: error } ); } } async searchPackage(query) { try { const response = await this.fetch(`/packages?query=${query}`); return await response.json(); } catch (error) { throw new JsrError( `Failed to fetch \`${this.apiEndpoint}/packages?query=${query}\``, { cause: error } ); } } }; __publicField(_JsrClient, "token", new Db().get("jsr-token")); var JsrClient = _JsrClient; async function jsrRegistry() { const jsrJson = await getJsrJson(); return new JsrRegisry(jsrJson.name); } // src/registry/npm.ts var import_tinyexec3 = require("tinyexec"); var NpmError = class extends AbstractError { constructor() { super(...arguments); __publicField(this, "name", "npm Error"); } }; var NpmRegistry = class extends Registry { constructor() { super(...arguments); __publicField(this, "registry", "https://registry.npmjs.org"); } async npm(args) { const { stdout, stderr } = await (0, import_tinyexec3.exec)("npm", args); if (stderr) throw stderr; return stdout; } async isInstalled() { try { await this.npm(["--help"]); return true; } catch { return false; } } async installGlobally(packageName) { try { await this.npm(["install", "-g", packageName]); return true; } catch (error) { throw new NpmError(`Failed to run \`npm install -g ${packageName}\``, { cause: error }); } } async isPublished() { try { const response = await fetch(`${this.registry}/${this.packageName}`); return response.status === 200; } catch (error) { throw new NpmError( `Failed to fetch \`${this.registry}/${this.packageName}\``, { cause: error } ); } } async userName() { try { return (await this.npm(["whoami"])).trim(); } catch (error) { throw new NpmError("Failed to run `npm whoami`", { cause: error }); } } async isLoggedIn() { try { await this.npm(["whoami"]); return true; } catch (error) { if (`${error}`.includes("ENEEDAUTH")) { return false; } throw new NpmError("Failed to run `npm whoami`", { cause: error }); } } async collaborators() { try { return JSON.parse( await this.npm([ "access", "list", "collaborators", this.packageName, "--json" ]) ); } catch (error) { throw new NpmError( `Failed to run \`npm access list collaborators ${this.packageName} --json\``, { cause: error } ); } } async hasPermission() { const userName = await this.userName(); const collaborators = await this.collaborators(); return !!collaborators[userName]?.includes("write"); } async distTags() { try { return Object.keys( JSON.parse( await this.npm(["view", this.packageName, "dist-tags", "--json"]) ) ); } catch (error) { throw new NpmError( `Failed to run \`npm view ${this.packageName} dist-tags --json\``, { cause: error } ); } } async version() { try { return this.npm(["--version"]); } catch (error) { throw new NpmError("Failed to run `npm --version`", { cause: error }); } } async ping() { try { await (0, import_tinyexec3.exec)("npm", ["ping"], { throwOnError: true }); return true; } catch (error) { throw new NpmError("Failed to run `npm ping`", { cause: error }); } } async publishProvenance() { try { try { await this.npm(["publish", "--provenance", "--access", "public"]); } catch (error) { if (`${error}`.includes("EOTP")) { return false; } } return true; } catch (error) { throw new NpmError( "Failed to run `npm publish --provenance --access public`", { cause: error } ); } } async publish(otp) { const args = otp ? ["publish", "--otp", otp] : ["publish"]; try { try { await this.npm(args); } catch (error) { if (`${error}`.includes("EOTP")) { return false; } } return true; } catch (error) { throw new NpmError(`Failed to run \`npm ${args.join(" ")}\``, { cause: error }); } } async isPackageNameAvaliable() { return isValidPackageName(this.packageName); } }; async function npmRegistry() { const packageJson = await getPackageJson(); return new NpmRegistry(packageJson.name); } // src/tasks/jsr.ts var JsrAvailableError = class extends AbstractError { constructor(message, { cause } = {}) { super(message, { cause }); __publicField(this, "name", "jsr is unavailable for publishing."); this.stack = ""; } }; var jsrAvailableCheckTasks = { title: "Checking jsr avaliable for publising", task: async (ctx, task) => { const jsr = await jsrRegistry(); addRollback(async (ctx2) => { if (ctx2.packageCreated) { console.log(`Deleting jsr package ${jsr.packageName}...`); await jsr.client.deletePackage(jsr.packageName); } if (ctx2.scopeCreated) { console.log(`Deleting jsr scope ${getScope(jsr.packageName)}...`); await jsr.client.deleteScope(`${getScope(jsr.packageName)}`); } }, ctx); if (!JsrClient.token) { task.output = "Retrieving jsr API token"; if (ctx.promptEnabled) { while (true) { JsrClient.token = await task.prompt(import_prompt_adapter_enquirer.ListrEnquirerPromptAdapter).run({ type: "password", message: `Please enter the jsr ${color.bold("API token")}`, footer: ` Generate a token from ${color.bold(link2("jsr.io", "https://jsr.io/account/tokens/create/"))}. ${color.red("You should select")} ${color.bold("'Interact with the JSR API'")}.` }); try { if (await jsr.client.user()) break; task.output = "The jsr API token is invalid. Please re-enter a valid token."; } catch { } } } else { const jsrTokenEnv = import_node_process6.default.env.JSR_TOKEN; if (!jsrTokenEnv) throw new JsrAvailableError( "JSR_TOKEN not found in the environment variables. Please set the token and try again." ); JsrClient.token = jsrTokenEnv; } if (ctx.saveToken) new Db().set("jsr-token", JsrClient.token); } if (!isScopedPackage(jsr.packageName)) { let jsrName = new Db().get(jsr.packageName); task.output = "The package name is not scoped. Searching for available scopes on jsr."; const scopes = await jsr.client.scopes(); checkScopeTask: if (!jsrName) { task.output = "Select an existing published package to publish."; const searchResults = (await Promise.all( scopes.map( (scope2) => jsr.client.package(`@${scope2}/${jsr.packageName}`) ) )).filter((v) => v); if (searchResults.length > 0) { jsrName = await task.prompt(import_prompt_adapter_enquirer.ListrEnquirerPromptAdapter).run({ type: "select", message: "Is there a scoped package you want to publish in the already published list?", choices: [ ...searchResults.map(({ scope: scope2, name }) => ({ message: `@${scope2}/${name}`, name: `@${scope2}/${name}` })), { message: "None", name: "none" } ] }); if (jsrName !== "none") break checkScopeTask; } const userName = await new Git().userName(); task.output = "Select the scope of the package to publish"; jsrName = await task.prompt(import_prompt_adapter_enquirer.ListrEnquirerPromptAdapter).run({ type: "select", message: "jsr.json does not exist, and the package name is not scoped. Please select a scope for the 'jsr' package", choices: [ { message: `@${jsr.packageName}/${jsr.packageName} ${color.dim("scoped by package name")}${scopes.includes(jsr.packageName) ? " (already created)" : ""}`, name: `@${jsr.packageName}/${jsr.packageName}` }, { message: `@${userName}/${jsr.packageName} ${color.dim("scoped by git name")}${scopes.includes(userName) ? " (already created)" : ""}`, name: `@${userName}/${jsr.packageName}` }, ...scopes.flatMap( (scope2) => scope2 === jsr.packageName || scope2 === userName ? [] : [ { message: `@${scope2}/${jsr.packageName} ${color.dim("scope from jsr")}`, name: `@${scope2}/${jsr.packageName}` } ] ), { message: "Other (Specify)", name: "specify" } ] }); if (jsrName === "specify") { while (!isScopedPackage(jsrName)) { jsrName = await task.prompt(import_prompt_adapter_enquirer.ListrEnquirerPromptAdapter).run({ type: "input", message: "Package name" }); } } const scope = jsrName.match(/^@([^/]+)/)?.[1]; if (scope && !scopes.includes(scope)) { task.output = "Creating scope for jsr..."; await jsr.client.createScope(scope); ctx.scopeCreated = true; } if (ctx.scopeCreated || !await jsr.client.package(jsrName)) { task.output = "Creating package for jsr..."; await jsr.client.createPackage(jsrName); ctx.packageCreated = true; } } jsr.packageName = jsrName; patchCachedJsrJson({ name: jsr.packageName }); } const npm = await npmRegistry(); const hasPermission = await jsr.hasPermission(); if (isScopedPackage(npm.packageName) && !hasPermission) { throw new JsrAvailableError( `You do not have permission to publish scope '${getScope(npm.packageName)}'. If you want to claim it, please contact ${link2("help@jsr.io", "mailto:help@jsr.io")}.` ); } if (await jsr.isPublished()) { if (!hasPermission) { throw new JsrAvailableError( `You do not have permission to publish this package on ${color.yellow("jsr")}.` ); } return void 0; } if (!await jsr.isPackageNameAvaliable()) { throw new JsrAvailableError( `Package is not published on ${color.yellow("jsr")}, and the package name is not available. Please change the package name. More information: ${link2("npm naming rules", "https://github.com/npm/validate-npm-package-name?tab=readme-ov-file#naming-rules")}` ); } } }; var jsrPublishTasks = { title: "Running jsr publish", task: async (ctx, task) => { const jsr = await jsrRegistry(); task.output = "Publishing on jsr..."; if (!JsrClient.token && !ctx.promptEnabled) { const jsrTokenEnv = import_node_process6.default.env.JSR_TOKEN; if (!jsrTokenEnv) { throw new JsrAvailableError( "JSR_TOKEN not found in the environment variables. Please set the token and try again." ); } JsrClient.token = jsrTokenEnv; } await jsr.publish(); } }; // src/tasks/npm.ts var import_node_process7 = __toESM(require("process"), 1); var import_prompt_adapter_enquirer2 = require("@listr2/prompt-adapter-enquirer"); var NpmAvailableError = class extends AbstractError { constructor(message, { cause } = {}) { super(message, { cause }); __publicField(this, "name", "npm is unavailable for publishing."); this.stack = ""; } }; var npmAvailableCheckTasks = { title: "Checking npm avaliable for publising", skip: (ctx) => !!ctx.preview, task: async () => { const npm = await npmRegistry(); if (!await npm.isLoggedIn()) { throw new NpmAvailableError( "You are not logged in. Please log in first using `npm login`." ); } if (await npm.isPublished()) { if (!await npm.hasPermission()) { throw new NpmAvailableError( `You do not have permission to publish this package on ${color.green("npm")}.` ); } return void 0; } if (!await npm.isPackageNameAvaliable()) { throw new NpmAvailableError( `Package is not published on ${color.green("npm")}, and the package name is not available. Please change the package name. More information: ${link2("npm naming rules", "https://github.com/npm/validate-npm-package-name?tab=readme-ov-file#naming-rules")}` ); } } }; var npmPublishTasks = { title: "Running npm publish", skip: (ctx) => !!ctx.preview, task: async (ctx, task) => { const npm = await npmRegistry(); task.output = "Publishing on npm..."; if (ctx.promptEnabled) { let result = await npm.publish(); if (!result) { task.title = "Running npm publish (OTP code needed)"; while (!result) { result = await npm.publish( await task.prompt(import_prompt_adapter_enquirer2.ListrEnquirerPromptAdapter).run({ type: "password", message: "npm OTP code" }) ); if (!result) { task.output = "2FA failed"; } } task.title = "Running npm publish (2FA passed)"; } } else { const npmTokenEnv = import_node_process7.default.env.NODE_AUTH_TOKEN; if (!npmTokenEnv) { throw new NpmAvailableError( "NODE_AUTH_TOKEN not found in the environment variables. Please set the token and try again." ); } const result = await npm.publishProvenance(); if (!result) { throw new NpmAvailableError( `In CI environment, publishing with 2FA is not allowed. Please disable 2FA when accessing with a token from https://www.npmjs.com/package/${npm.packageName}/access ` ); } } } }; // src/tasks/prerequisites-check.ts var import_prompt_adapter_enquirer3 = require("@listr2/prompt-adapter-enquirer"); var PrerequisitesCheckError = class extends AbstractError { constructor(message, { cause } = {}) { super(message, { cause }); __publicField(this, "name", "Failed prerequisite check"); this.stack = ""; } }; var prerequisitesCheckTask = (options) => { const git = new Git(); return createListr({ ...options, exitOnError: true, title: "Prerequisites check (for deployment reliability)", task: (_, parentTask) => parentTask.newListr([ { skip: (ctx) => !!ctx.anyBranch, title: "Verifying current branch is a release branch", task: async (ctx, task) => { if (await git.branch() !== ctx.branch) { const swtichBranch = await task.prompt(import_prompt_adapter_enquirer3.ListrEnquirerPromptAdapter).run({ type: "toggle", message: `${warningBadge} The current HEAD branch is not the release target branch. Do you want to switch branch to ${ctx.branch}?`, enabled: "Yes", disabled: "No" }); if (swtichBranch) { task.output = `Switching branch to ${ctx.branch}...`; await git.switch(ctx.branch); } else { throw new PrerequisitesCheckError( "The current HEAD branch is not the release target branch. Please switch to the correct branch before proceeding." ); } } } }, { title: "Checking if remote history is clean", task: async (_2, task) => { task.output = "Checking for updates with `git fetch`"; if ((await git.dryFetch()).trim()) { const fetch2 = await task.prompt(import_prompt_adapter_enquirer3.ListrEnquirerPromptAdapter).run({ type: "toggle", message: `${warningBadge} Local history is outdated. Do you want to run \`git fetch\`?`, enabled: "Yes", disabled: "No" }); if (fetch2) { task.output = "Executing `git fetch` command..."; await git.fetch(); } else { throw new PrerequisitesCheckError( "Local history is outdated. Please run `git fetch` to update." ); } } task.output = "Checking for updates with `git pull`"; if (await git.revisionDiffsCount()) { const pull = await task.prompt(import_prompt_adapter_enquirer3.ListrEnquirerPromptAdapter).run({ type: "toggle", message: `${warningBadge} Local history is outdated. Do you want to run \`git pull\`?`, enabled: "Yes", disabled: "No" }); if (pull) { task.output = "Executing `git pull` command..."; await git.pull(); } else { throw new PrerequisitesCheckError( "Local history is outdated. Please run `git pull` to synchronize with the remote repository." ); } } } }, { title: "Checking if the local working tree is clean", task: async (ctx, task) => { if (await git.status()) { task.output = "Local working tree is not clean."; if (!await task.prompt(import_prompt_adapter_enquirer3.ListrEnquirerPromptAdapter).run({ type: "toggle", message: `${warningBadge} Local working tree is not clean. Do you want to skip?`, enabled: "Yes", disabled: "No" })) { throw new PrerequisitesCheckError( "Local working tree is not clean. Please commit or stash your changes before proceeding." ); } ctx.cleanWorkingTree = false; } ctx.cleanWorkingTree = true; } }, { title: "Checking if commits exist since the last release", task: async (_2, task) => { const latestTag = await git.latestTag(); if (!latestTag) { task.title += " (Tag has not been pushed to GitHub)"; return void 0; } if ((await git.commits(latestTag, "HEAD")).length <= 0) { if (!await task.prompt(import_prompt_adapter_enquirer3.ListrEnquirerPromptAdapter).run({ type: "toggle", message: `${warningBadge} No commits exist from the latest tag. Do you want to skip?`, enabled: "Yes", disabled: "No" })) { throw new PrerequisitesCheckError( "No commits exist from the latest tag. Please ensure there are new changes before publishing." ); } } } }, { title: "Checking git tag existence", task: async (ctx, task) => { const gitTag = `v${ctx.version}`; if (await git.checkTagExist(gitTag)) { const deleteTag = await task.prompt(import_prompt_adapter_enquirer3.ListrEnquirerPromptAdapter).run({ type: "toggle", message: `${warningBadge} The Git tag '${gitTag}' already exists. Do you want to delete tag?`, enabled: "Yes", disabled: "No" }); if (deleteTag) { task.output = `Deleting git tag ${gitTag}...`; await git.deleteTag(gitTag); } else { throw new PrerequisitesCheckError( `The Git tag '${gitTag}' already exists. Please check the selected version '${ctx.version}'.` ); } } } } ]) }); }; // src/tasks/required-conditions-check.ts var import_prompt_adapter_enquirer4 = require("@listr2/prompt-adapter-enquirer"); // src/registry/custom-registry.ts var import_tinyexec4 = require("tinyexec"); var CustomRegistry = class extends NpmRegistry { async npm(args) { const { stdout, stderr } = await (0, import_tinyexec4.exec)( "npm", args.concat("--registry", this.registry) ); if (stderr) throw stderr; return stdout; } }; async function customRegistry() { const packageJson = await getPackageJson(); return new CustomRegistry(packageJson.name); } // src/registry/index.ts var registryMap = { npm: npmRegistry, jsr: jsrRegistry }; async function getRegistry(registryKey) { const registry = registryMap[registryKey]; if (!registry) { return await customRegistry(); } return await registry(); } // src/utils/engine-version.ts var import_semver2 = require("semver"); var import_meta3 = {}; async function validateEngineVersion(engine, version2) { const { engines } = await getPackageJson({ cwd: import_meta3.dirname }); return (0, import_semver2.satisfies)(version2, `${engines?.[engine]}`, { includePrerelease: true }); } // src/tasks/required-conditions-check.ts var RequiredConditionCheckError = class extends AbstractError { constructor(message, { cause } = {}) { super(message, { cause }); __publicField(this, "name", "Failed required condition check"); this.stack = ""; } }; var requiredConditionsCheckTask = (options) => createListr({ ...options, title: "Required conditions check (for pubm tasks)", task: (_, parentTask) => parentTask.newListr( [ { title: "Ping registries", task: (ctx, parentTask2) => parentTask2.newListr( ctx.registries.map((registryKey) => ({ title: `Ping to ${registryKey}`, task: async () => { const registry = await getRegistry(registryKey); await registry.ping(); } })), { concurrent: true } ) }, { title: "Verifying if npm and jsr are installed", task: async (_2, parentTask2) => parentTask2.newListr( [ { enabled: (ctx) => ctx.registries.some((registry) => registry !== "jsr"), title: "Verifying if npm are installed", task: async () => { const npm = await npmRegistry(); if (!await npm.isInstalled()) { throw new RequiredConditionCheckError( "npm is not installed. Please install npm to proceed." ); } } }, { enabled: (ctx) => ctx.registries.some((registry) => registry === "jsr"), title: "Verifying if jsr are installed", task: async (_3, task) => { const jsr = await jsrRegistry(); if (!await jsr.isInstalled()) { const install = await task.prompt(import_prompt_adapter_enquirer4.ListrEnquirerPromptAdapter).run({ type: "toggle", message: `${warningBadge} jsr is not installed. Do you want to install jsr?`, enabled: "Yes", disabled: "No" }); if (install) { task.output = "Installing jsr..."; const npm = await npmRegistry(); await npm.installGlobally("jsr"); } else { throw new RequiredConditionCheckError( "jsr is not installed. Please install jsr to proceed." ); } } } } ], { concurrent: true } ) }, { title: "Checking if test and build scripts exist", skip: (ctx) => ctx.jsrOnly, task: async (ctx) => { const { scripts } = await getPackageJson(); const errors = []; if (!ctx.skipTests && !scripts?.[ctx.testScript]) { errors.push(`Test script '${ctx.testScript}' does not exist.`); } if (!ctx.skipBuild && !scripts?.[ctx.buildScript]) { errors.push( `Build script '${ctx.buildScript}' does not exist.` ); } if (errors.length) { throw new RequiredConditionCheckError( `${errors.join(" and ")} Please check your configuration.` ); } } }, { title: "Checking git version", task: async () => { const git = new Git(); validateEngineVersion("git", `${await git.version()}`); } }, { title: "Checking available registries for publishing", task: (ctx, parentTask2) => parentTask2.newListr( ctx.registries.map((registryKey) => { switch (registryKey) { case "npm": return npmAvailableCheckTasks; case "jsr": return jsrAvailableCheckTasks; default: return npmAvailableCheckTasks; } }), { concurrent: true } ) } ], { concurrent: true } ) }); // src/tasks/runner.ts var { open } = import_promise_spawn.default; var { prerelease } = import_semver3.default; async function run(options) { const ctx = { ...options, promptEnabled: !import_std_env.isCI && import_node_process8.default.stdin.isTTY, npmOnly: options.registries.every((registry) => registry !== "jsr"), jsrOnly: options.registries.every((registry) => registry === "jsr") }; try { if (options.contents) import_node_process8.default.chdir(options.contents); if (!options.publishOnly) { await prerequisitesCheckTask({ skip: options.skipPrerequisitesCheck }).run(ctx); await requiredConditionsCheckTask({ skip: options.skipConditionsCheck }).run(ctx); } await createListr( options.publishOnly ? { title: "Publishing", task: (ctx2, parentTask) => parentTask.newListr( ctx2.registries.map((registry) => { switch (registry) { case "npm": return npmPublishTasks; case "jsr": return jsrPublishTasks; default: return npmPublishTasks; } }), { concurrent: true } ) } : [ { skip: options.skipTests, title: "Running tests", task: async (ctx2) => { const packageManager = await getPackageManager(); const { stderr } = await (0, import_tinyexec5.exec)(packageManager, [ "run", ctx2.testScript ]); if (stderr) { throw new AbstractError( `Failed to run \`${packageManager} run ${ctx2.testScript}\``, { cause: stderr } ); } } }, { skip: options.skipBuild, title: "Building the project", task: async (ctx2) => { const packageManager = await getPackageManager(); try { await (0, import_tinyexec5.exec)(packageManager, ["run", ctx2.buildScript], { throwOnError: true }); } catch (error) { throw new AbstractError( `Failed to run \`${packageManager} run ${ctx2.buildScript}\``, { cause: error } ); } } }, { title: "Bumping version", skip: (ctx2) => !!ctx2.preview, task: async (ctx2, task) => { const git = new Git(); let tagCreated = false; let commited = false; addRollback(async () => { if (tagCreated) { console.log("Deleting tag..."); await git.deleteTag(`${await git.latestTag()}`); } if (commited) { console.log("Reset commits..."); await git.reset(); await git.stash(); await git.reset("HEAD^", "--hard"); await git.popStash(); } }, ctx2); await git.reset(); const replaced = await replaceVersion(ctx2.version); for (const replacedFile of replaced) { await git.stage(replacedFile); } const nextVersion = `v${ctx2.version}`; const commit = await git.commit(nextVersion); commited = true; task.output = "Creating tag..."; await git.createTag(nextVersion, commit); tagCreated = true; } }, { skip: (ctx2) => options.skipPublish || !!ctx2.preview, title: "Publishing", task: (ctx2, parentTask) => parentTask.newListr( ctx2.registries.map((registry) => { switch (registry) { case "npm": return npmPublishTasks; case "jsr": return jsrPublishTasks; default: return npmPublishTasks; } }), { concurrent: true } ) }, { title: "Pushing tags to GitHub", skip: (ctx2) => !!ctx2.preview, task: async (_, task) => { const git = new Git(); const result = await git.push("--follow-tags"); if (!result) { task.title += " (Only tags were pushed because the release branch is protected. Please push the branch manually.)"; await git.push("--tags"); } } }, { skip: (ctx2) => options.skipReleaseDraft || !!ctx2.preview, title: "Creating release draft on GitHub", task: async (ctx2, task) => { const git = new Git(); const repositoryUrl = await git.repository(); const latestTag = `${await git.latestTag()}`; const lastRev = await git.previousTag(latestTag) || await git.firstCommit(); const commits = (await git.commits(lastRev, `${latestTag}`)).slice(1); let body = commits.map( ({ id, message }) => `- ${message.replace("#", `${repositoryUrl}/issues/`)} ${repositoryUrl}/commit/${id}` ).join("\n"); body += ` ${repositoryUrl}/compare/${lastRev}...${latestTag}`; const releaseDraftUrl = new URL( `${repositoryUrl}/releases/new` ); releaseDraftUrl.searchParams.set("tag", `${latestTag}`); releaseDraftUrl.searchParams.set("body", body); releaseDraftUrl.searchParams.set( "prerelease", `${!!prerelease(ctx2.version)}` ); const linkUrl = link2("Link", releaseDraftUrl.toString()); task.title += ` ${linkUrl}`; await open(releaseDraftUrl.toString()); } } ] ).run(ctx); const npmPackageName = (await getPackageJson()).name; const jsrPackageName = (await getJsrJson()).name; console.log( ` \u{1F680} Successfully published ${color.bold(npmPackageName)} on ${color.green("npm")} and ${color.bold(jsrPackageName)} on ${color.yellow("jsr")} ${color.blueBright(`v${ctx.version}`)} \u{1F680} ` ); } catch (e2) { consoleError(e2); await rollback(); import_node_process8.default.exit(1); } } // src/index.ts async function pubm(options) { const resolvedOptions = resolveOptions({ ...options }); await run(resolvedOptions); } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { pubm });