@lacymorrow/shipx 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +112 -0
  3. package/dist/cli.js +2077 -0
  4. package/package.json +58 -0
package/dist/cli.js ADDED
@@ -0,0 +1,2077 @@
1
+ #!/usr/bin/env node
2
+ var __create = Object.create;
3
+ var __getProtoOf = Object.getPrototypeOf;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ function __accessProp(key) {
8
+ return this[key];
9
+ }
10
+ var __toESMCache_node;
11
+ var __toESMCache_esm;
12
+ var __toESM = (mod, isNodeMode, target) => {
13
+ var canCache = mod != null && typeof mod === "object";
14
+ if (canCache) {
15
+ var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
16
+ var cached = cache.get(mod);
17
+ if (cached)
18
+ return cached;
19
+ }
20
+ target = mod != null ? __create(__getProtoOf(mod)) : {};
21
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
22
+ for (let key of __getOwnPropNames(mod))
23
+ if (!__hasOwnProp.call(to, key))
24
+ __defProp(to, key, {
25
+ get: __accessProp.bind(mod, key),
26
+ enumerable: true
27
+ });
28
+ if (canCache)
29
+ cache.set(mod, to);
30
+ return to;
31
+ };
32
+ var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
33
+
34
+ // node_modules/sisteransi/src/index.js
35
+ var require_src = __commonJS((exports, module) => {
36
+ var ESC2 = "\x1B";
37
+ var CSI2 = `${ESC2}[`;
38
+ var beep = "\x07";
39
+ var cursor = {
40
+ to(x, y) {
41
+ if (!y)
42
+ return `${CSI2}${x + 1}G`;
43
+ return `${CSI2}${y + 1};${x + 1}H`;
44
+ },
45
+ move(x, y) {
46
+ let ret = "";
47
+ if (x < 0)
48
+ ret += `${CSI2}${-x}D`;
49
+ else if (x > 0)
50
+ ret += `${CSI2}${x}C`;
51
+ if (y < 0)
52
+ ret += `${CSI2}${-y}A`;
53
+ else if (y > 0)
54
+ ret += `${CSI2}${y}B`;
55
+ return ret;
56
+ },
57
+ up: (count = 1) => `${CSI2}${count}A`,
58
+ down: (count = 1) => `${CSI2}${count}B`,
59
+ forward: (count = 1) => `${CSI2}${count}C`,
60
+ backward: (count = 1) => `${CSI2}${count}D`,
61
+ nextLine: (count = 1) => `${CSI2}E`.repeat(count),
62
+ prevLine: (count = 1) => `${CSI2}F`.repeat(count),
63
+ left: `${CSI2}G`,
64
+ hide: `${CSI2}?25l`,
65
+ show: `${CSI2}?25h`,
66
+ save: `${ESC2}7`,
67
+ restore: `${ESC2}8`
68
+ };
69
+ var scroll = {
70
+ up: (count = 1) => `${CSI2}S`.repeat(count),
71
+ down: (count = 1) => `${CSI2}T`.repeat(count)
72
+ };
73
+ var erase = {
74
+ screen: `${CSI2}2J`,
75
+ up: (count = 1) => `${CSI2}1J`.repeat(count),
76
+ down: (count = 1) => `${CSI2}J`.repeat(count),
77
+ line: `${CSI2}2K`,
78
+ lineEnd: `${CSI2}K`,
79
+ lineStart: `${CSI2}1K`,
80
+ lines(count) {
81
+ let clear = "";
82
+ for (let i = 0;i < count; i++)
83
+ clear += this.line + (i < count - 1 ? cursor.up() : "");
84
+ if (count)
85
+ clear += cursor.left;
86
+ return clear;
87
+ }
88
+ };
89
+ module.exports = { cursor, scroll, erase, beep };
90
+ });
91
+
92
+ // node_modules/picocolors/picocolors.js
93
+ var require_picocolors = __commonJS((exports, module) => {
94
+ var p2 = process || {};
95
+ var argv = p2.argv || [];
96
+ var env = p2.env || {};
97
+ var isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p2.platform === "win32" || (p2.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
98
+ var formatter = (open, close, replace = open) => (input) => {
99
+ let string = "" + input, index = string.indexOf(close, open.length);
100
+ return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
101
+ };
102
+ var replaceClose = (string, close, replace, index) => {
103
+ let result = "", cursor = 0;
104
+ do {
105
+ result += string.substring(cursor, index) + replace;
106
+ cursor = index + close.length;
107
+ index = string.indexOf(close, cursor);
108
+ } while (~index);
109
+ return result + string.substring(cursor);
110
+ };
111
+ var createColors = (enabled = isColorSupported) => {
112
+ let f = enabled ? formatter : () => String;
113
+ return {
114
+ isColorSupported: enabled,
115
+ reset: f("\x1B[0m", "\x1B[0m"),
116
+ bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
117
+ dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
118
+ italic: f("\x1B[3m", "\x1B[23m"),
119
+ underline: f("\x1B[4m", "\x1B[24m"),
120
+ inverse: f("\x1B[7m", "\x1B[27m"),
121
+ hidden: f("\x1B[8m", "\x1B[28m"),
122
+ strikethrough: f("\x1B[9m", "\x1B[29m"),
123
+ black: f("\x1B[30m", "\x1B[39m"),
124
+ red: f("\x1B[31m", "\x1B[39m"),
125
+ green: f("\x1B[32m", "\x1B[39m"),
126
+ yellow: f("\x1B[33m", "\x1B[39m"),
127
+ blue: f("\x1B[34m", "\x1B[39m"),
128
+ magenta: f("\x1B[35m", "\x1B[39m"),
129
+ cyan: f("\x1B[36m", "\x1B[39m"),
130
+ white: f("\x1B[37m", "\x1B[39m"),
131
+ gray: f("\x1B[90m", "\x1B[39m"),
132
+ bgBlack: f("\x1B[40m", "\x1B[49m"),
133
+ bgRed: f("\x1B[41m", "\x1B[49m"),
134
+ bgGreen: f("\x1B[42m", "\x1B[49m"),
135
+ bgYellow: f("\x1B[43m", "\x1B[49m"),
136
+ bgBlue: f("\x1B[44m", "\x1B[49m"),
137
+ bgMagenta: f("\x1B[45m", "\x1B[49m"),
138
+ bgCyan: f("\x1B[46m", "\x1B[49m"),
139
+ bgWhite: f("\x1B[47m", "\x1B[49m"),
140
+ blackBright: f("\x1B[90m", "\x1B[39m"),
141
+ redBright: f("\x1B[91m", "\x1B[39m"),
142
+ greenBright: f("\x1B[92m", "\x1B[39m"),
143
+ yellowBright: f("\x1B[93m", "\x1B[39m"),
144
+ blueBright: f("\x1B[94m", "\x1B[39m"),
145
+ magentaBright: f("\x1B[95m", "\x1B[39m"),
146
+ cyanBright: f("\x1B[96m", "\x1B[39m"),
147
+ whiteBright: f("\x1B[97m", "\x1B[39m"),
148
+ bgBlackBright: f("\x1B[100m", "\x1B[49m"),
149
+ bgRedBright: f("\x1B[101m", "\x1B[49m"),
150
+ bgGreenBright: f("\x1B[102m", "\x1B[49m"),
151
+ bgYellowBright: f("\x1B[103m", "\x1B[49m"),
152
+ bgBlueBright: f("\x1B[104m", "\x1B[49m"),
153
+ bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
154
+ bgCyanBright: f("\x1B[106m", "\x1B[49m"),
155
+ bgWhiteBright: f("\x1B[107m", "\x1B[49m")
156
+ };
157
+ };
158
+ module.exports = createColors();
159
+ module.exports.createColors = createColors;
160
+ });
161
+
162
+ // node_modules/@clack/core/dist/index.mjs
163
+ import { styleText as v } from "node:util";
164
+ import { stdout as S, stdin as D } from "node:process";
165
+ import * as b from "node:readline";
166
+ import E from "node:readline";
167
+
168
+ // node_modules/fast-string-truncated-width/dist/utils.js
169
+ var getCodePointsLength = (() => {
170
+ const SURROGATE_PAIR_RE = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
171
+ return (input) => {
172
+ let surrogatePairsNr = 0;
173
+ SURROGATE_PAIR_RE.lastIndex = 0;
174
+ while (SURROGATE_PAIR_RE.test(input)) {
175
+ surrogatePairsNr += 1;
176
+ }
177
+ return input.length - surrogatePairsNr;
178
+ };
179
+ })();
180
+ var isFullWidth = (x) => {
181
+ return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
182
+ };
183
+ var isWideNotCJKTNotEmoji = (x) => {
184
+ return x === 8987 || x === 9001 || x >= 12272 && x <= 12287 || x >= 12289 && x <= 12350 || x >= 12441 && x <= 12543 || x >= 12549 && x <= 12591 || x >= 12593 && x <= 12686 || x >= 12688 && x <= 12771 || x >= 12783 && x <= 12830 || x >= 12832 && x <= 12871 || x >= 12880 && x <= 19903 || x >= 65040 && x <= 65049 || x >= 65072 && x <= 65106 || x >= 65108 && x <= 65126 || x >= 65128 && x <= 65131 || x >= 127488 && x <= 127490 || x >= 127504 && x <= 127547 || x >= 127552 && x <= 127560 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
185
+ };
186
+
187
+ // node_modules/fast-string-truncated-width/dist/index.js
188
+ var ANSI_RE = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y;
189
+ var CONTROL_RE = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
190
+ var CJKT_WIDE_RE = /(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu;
191
+ var TAB_RE = /\t{1,1000}/y;
192
+ var EMOJI_RE = /[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu;
193
+ var LATIN_RE = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
194
+ var MODIFIER_RE = /\p{M}+/gu;
195
+ var NO_TRUNCATION = { limit: Infinity, ellipsis: "" };
196
+ var getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {}) => {
197
+ const LIMIT = truncationOptions.limit ?? Infinity;
198
+ const ELLIPSIS = truncationOptions.ellipsis ?? "";
199
+ const ELLIPSIS_WIDTH = truncationOptions?.ellipsisWidth ?? (ELLIPSIS ? getStringTruncatedWidth(ELLIPSIS, NO_TRUNCATION, widthOptions).width : 0);
200
+ const ANSI_WIDTH = 0;
201
+ const CONTROL_WIDTH = widthOptions.controlWidth ?? 0;
202
+ const TAB_WIDTH = widthOptions.tabWidth ?? 8;
203
+ const EMOJI_WIDTH = widthOptions.emojiWidth ?? 2;
204
+ const FULL_WIDTH_WIDTH = 2;
205
+ const REGULAR_WIDTH = widthOptions.regularWidth ?? 1;
206
+ const WIDE_WIDTH = widthOptions.wideWidth ?? FULL_WIDTH_WIDTH;
207
+ const PARSE_BLOCKS = [
208
+ [LATIN_RE, REGULAR_WIDTH],
209
+ [ANSI_RE, ANSI_WIDTH],
210
+ [CONTROL_RE, CONTROL_WIDTH],
211
+ [TAB_RE, TAB_WIDTH],
212
+ [EMOJI_RE, EMOJI_WIDTH],
213
+ [CJKT_WIDE_RE, WIDE_WIDTH]
214
+ ];
215
+ let indexPrev = 0;
216
+ let index = 0;
217
+ let length = input.length;
218
+ let lengthExtra = 0;
219
+ let truncationEnabled = false;
220
+ let truncationIndex = length;
221
+ let truncationLimit = Math.max(0, LIMIT - ELLIPSIS_WIDTH);
222
+ let unmatchedStart = 0;
223
+ let unmatchedEnd = 0;
224
+ let width = 0;
225
+ let widthExtra = 0;
226
+ outer:
227
+ while (true) {
228
+ if (unmatchedEnd > unmatchedStart || index >= length && index > indexPrev) {
229
+ const unmatched = input.slice(unmatchedStart, unmatchedEnd) || input.slice(indexPrev, index);
230
+ lengthExtra = 0;
231
+ for (const char of unmatched.replaceAll(MODIFIER_RE, "")) {
232
+ const codePoint = char.codePointAt(0) || 0;
233
+ if (isFullWidth(codePoint)) {
234
+ widthExtra = FULL_WIDTH_WIDTH;
235
+ } else if (isWideNotCJKTNotEmoji(codePoint)) {
236
+ widthExtra = WIDE_WIDTH;
237
+ } else {
238
+ widthExtra = REGULAR_WIDTH;
239
+ }
240
+ if (width + widthExtra > truncationLimit) {
241
+ truncationIndex = Math.min(truncationIndex, Math.max(unmatchedStart, indexPrev) + lengthExtra);
242
+ }
243
+ if (width + widthExtra > LIMIT) {
244
+ truncationEnabled = true;
245
+ break outer;
246
+ }
247
+ lengthExtra += char.length;
248
+ width += widthExtra;
249
+ }
250
+ unmatchedStart = unmatchedEnd = 0;
251
+ }
252
+ if (index >= length) {
253
+ break outer;
254
+ }
255
+ for (let i = 0, l = PARSE_BLOCKS.length;i < l; i++) {
256
+ const [BLOCK_RE, BLOCK_WIDTH] = PARSE_BLOCKS[i];
257
+ BLOCK_RE.lastIndex = index;
258
+ if (BLOCK_RE.test(input)) {
259
+ lengthExtra = BLOCK_RE === CJKT_WIDE_RE ? getCodePointsLength(input.slice(index, BLOCK_RE.lastIndex)) : BLOCK_RE === EMOJI_RE ? 1 : BLOCK_RE.lastIndex - index;
260
+ widthExtra = lengthExtra * BLOCK_WIDTH;
261
+ if (width + widthExtra > truncationLimit) {
262
+ truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / BLOCK_WIDTH));
263
+ }
264
+ if (width + widthExtra > LIMIT) {
265
+ truncationEnabled = true;
266
+ break outer;
267
+ }
268
+ width += widthExtra;
269
+ unmatchedStart = indexPrev;
270
+ unmatchedEnd = index;
271
+ index = indexPrev = BLOCK_RE.lastIndex;
272
+ continue outer;
273
+ }
274
+ }
275
+ index += 1;
276
+ }
277
+ return {
278
+ width: truncationEnabled ? truncationLimit : width,
279
+ index: truncationEnabled ? truncationIndex : length,
280
+ truncated: truncationEnabled,
281
+ ellipsed: truncationEnabled && LIMIT >= ELLIPSIS_WIDTH
282
+ };
283
+ };
284
+ var dist_default = getStringTruncatedWidth;
285
+
286
+ // node_modules/fast-string-width/dist/index.js
287
+ var NO_TRUNCATION2 = {
288
+ limit: Infinity,
289
+ ellipsis: "",
290
+ ellipsisWidth: 0
291
+ };
292
+ var fastStringWidth = (input, options = {}) => {
293
+ return dist_default(input, NO_TRUNCATION2, options).width;
294
+ };
295
+ var dist_default2 = fastStringWidth;
296
+
297
+ // node_modules/fast-wrap-ansi/lib/main.js
298
+ var ESC = "\x1B";
299
+ var CSI = "›";
300
+ var END_CODE = 39;
301
+ var ANSI_ESCAPE_BELL = "\x07";
302
+ var ANSI_CSI = "[";
303
+ var ANSI_OSC = "]";
304
+ var ANSI_SGR_TERMINATOR = "m";
305
+ var ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
306
+ var GROUP_REGEX = new RegExp(`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`, "y");
307
+ var getClosingCode = (openingCode) => {
308
+ if (openingCode >= 30 && openingCode <= 37)
309
+ return 39;
310
+ if (openingCode >= 90 && openingCode <= 97)
311
+ return 39;
312
+ if (openingCode >= 40 && openingCode <= 47)
313
+ return 49;
314
+ if (openingCode >= 100 && openingCode <= 107)
315
+ return 49;
316
+ if (openingCode === 1 || openingCode === 2)
317
+ return 22;
318
+ if (openingCode === 3)
319
+ return 23;
320
+ if (openingCode === 4)
321
+ return 24;
322
+ if (openingCode === 7)
323
+ return 27;
324
+ if (openingCode === 8)
325
+ return 28;
326
+ if (openingCode === 9)
327
+ return 29;
328
+ if (openingCode === 0)
329
+ return 0;
330
+ return;
331
+ };
332
+ var wrapAnsiCode = (code) => `${ESC}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
333
+ var wrapAnsiHyperlink = (url) => `${ESC}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`;
334
+ var wrapWord = (rows, word, columns) => {
335
+ const characters = word[Symbol.iterator]();
336
+ let isInsideEscape = false;
337
+ let isInsideLinkEscape = false;
338
+ let lastRow = rows.at(-1);
339
+ let visible = lastRow === undefined ? 0 : dist_default2(lastRow);
340
+ let currentCharacter = characters.next();
341
+ let nextCharacter = characters.next();
342
+ let rawCharacterIndex = 0;
343
+ while (!currentCharacter.done) {
344
+ const character = currentCharacter.value;
345
+ const characterLength = dist_default2(character);
346
+ if (visible + characterLength <= columns) {
347
+ rows[rows.length - 1] += character;
348
+ } else {
349
+ rows.push(character);
350
+ visible = 0;
351
+ }
352
+ if (character === ESC || character === CSI) {
353
+ isInsideEscape = true;
354
+ isInsideLinkEscape = word.startsWith(ANSI_ESCAPE_LINK, rawCharacterIndex + 1);
355
+ }
356
+ if (isInsideEscape) {
357
+ if (isInsideLinkEscape) {
358
+ if (character === ANSI_ESCAPE_BELL) {
359
+ isInsideEscape = false;
360
+ isInsideLinkEscape = false;
361
+ }
362
+ } else if (character === ANSI_SGR_TERMINATOR) {
363
+ isInsideEscape = false;
364
+ }
365
+ } else {
366
+ visible += characterLength;
367
+ if (visible === columns && !nextCharacter.done) {
368
+ rows.push("");
369
+ visible = 0;
370
+ }
371
+ }
372
+ currentCharacter = nextCharacter;
373
+ nextCharacter = characters.next();
374
+ rawCharacterIndex += character.length;
375
+ }
376
+ lastRow = rows.at(-1);
377
+ if (!visible && lastRow !== undefined && lastRow.length && rows.length > 1) {
378
+ rows[rows.length - 2] += rows.pop();
379
+ }
380
+ };
381
+ var stringVisibleTrimSpacesRight = (string) => {
382
+ const words = string.split(" ");
383
+ let last = words.length;
384
+ while (last) {
385
+ if (dist_default2(words[last - 1])) {
386
+ break;
387
+ }
388
+ last--;
389
+ }
390
+ if (last === words.length) {
391
+ return string;
392
+ }
393
+ return words.slice(0, last).join(" ") + words.slice(last).join("");
394
+ };
395
+ var exec = (string, columns, options = {}) => {
396
+ if (options.trim !== false && string.trim() === "") {
397
+ return "";
398
+ }
399
+ let returnValue = "";
400
+ let escapeCode;
401
+ let escapeUrl;
402
+ const words = string.split(" ");
403
+ let rows = [""];
404
+ let rowLength = 0;
405
+ for (let index = 0;index < words.length; index++) {
406
+ const word = words[index];
407
+ if (options.trim !== false) {
408
+ const row = rows.at(-1) ?? "";
409
+ const trimmed = row.trimStart();
410
+ if (row.length !== trimmed.length) {
411
+ rows[rows.length - 1] = trimmed;
412
+ rowLength = dist_default2(trimmed);
413
+ }
414
+ }
415
+ if (index !== 0) {
416
+ if (rowLength >= columns && (options.wordWrap === false || options.trim === false)) {
417
+ rows.push("");
418
+ rowLength = 0;
419
+ }
420
+ if (rowLength || options.trim === false) {
421
+ rows[rows.length - 1] += " ";
422
+ rowLength++;
423
+ }
424
+ }
425
+ const wordLength = dist_default2(word);
426
+ if (options.hard && wordLength > columns) {
427
+ const remainingColumns = columns - rowLength;
428
+ const breaksStartingThisLine = 1 + Math.floor((wordLength - remainingColumns - 1) / columns);
429
+ const breaksStartingNextLine = Math.floor((wordLength - 1) / columns);
430
+ if (breaksStartingNextLine < breaksStartingThisLine) {
431
+ rows.push("");
432
+ }
433
+ wrapWord(rows, word, columns);
434
+ rowLength = dist_default2(rows.at(-1) ?? "");
435
+ continue;
436
+ }
437
+ if (rowLength + wordLength > columns && rowLength && wordLength) {
438
+ if (options.wordWrap === false && rowLength < columns) {
439
+ wrapWord(rows, word, columns);
440
+ rowLength = dist_default2(rows.at(-1) ?? "");
441
+ continue;
442
+ }
443
+ rows.push("");
444
+ rowLength = 0;
445
+ }
446
+ if (rowLength + wordLength > columns && options.wordWrap === false) {
447
+ wrapWord(rows, word, columns);
448
+ rowLength = dist_default2(rows.at(-1) ?? "");
449
+ continue;
450
+ }
451
+ rows[rows.length - 1] += word;
452
+ rowLength += wordLength;
453
+ }
454
+ if (options.trim !== false) {
455
+ rows = rows.map((row) => stringVisibleTrimSpacesRight(row));
456
+ }
457
+ const preString = rows.join(`
458
+ `);
459
+ let inSurrogate = false;
460
+ for (let i = 0;i < preString.length; i++) {
461
+ const character = preString[i];
462
+ returnValue += character;
463
+ if (!inSurrogate) {
464
+ inSurrogate = character >= "\uD800" && character <= "\uDBFF";
465
+ if (inSurrogate) {
466
+ continue;
467
+ }
468
+ } else {
469
+ inSurrogate = false;
470
+ }
471
+ if (character === ESC || character === CSI) {
472
+ GROUP_REGEX.lastIndex = i + 1;
473
+ const groupsResult = GROUP_REGEX.exec(preString);
474
+ const groups = groupsResult?.groups;
475
+ if (groups?.code !== undefined) {
476
+ const code = Number.parseFloat(groups.code);
477
+ escapeCode = code === END_CODE ? undefined : code;
478
+ } else if (groups?.uri !== undefined) {
479
+ escapeUrl = groups.uri.length === 0 ? undefined : groups.uri;
480
+ }
481
+ }
482
+ if (preString[i + 1] === `
483
+ `) {
484
+ if (escapeUrl) {
485
+ returnValue += wrapAnsiHyperlink("");
486
+ }
487
+ const closingCode = escapeCode ? getClosingCode(escapeCode) : undefined;
488
+ if (escapeCode && closingCode) {
489
+ returnValue += wrapAnsiCode(closingCode);
490
+ }
491
+ } else if (character === `
492
+ `) {
493
+ if (escapeCode && getClosingCode(escapeCode)) {
494
+ returnValue += wrapAnsiCode(escapeCode);
495
+ }
496
+ if (escapeUrl) {
497
+ returnValue += wrapAnsiHyperlink(escapeUrl);
498
+ }
499
+ }
500
+ }
501
+ return returnValue;
502
+ };
503
+ var CRLF_OR_LF = /\r?\n/;
504
+ function wrapAnsi(string, columns, options) {
505
+ return String(string).normalize().split(CRLF_OR_LF).map((line) => exec(line, columns, options)).join(`
506
+ `);
507
+ }
508
+
509
+ // node_modules/@clack/core/dist/index.mjs
510
+ var import_sisteransi = __toESM(require_src(), 1);
511
+ import { ReadStream as O } from "node:tty";
512
+ function d(r, t, s) {
513
+ if (!s.some((o) => !o.disabled))
514
+ return r;
515
+ const e = r + t, i = Math.max(s.length - 1, 0), n = e < 0 ? i : e > i ? 0 : e;
516
+ return s[n].disabled ? d(n, t < 0 ? -1 : 1, s) : n;
517
+ }
518
+ function I(r, t, s, e) {
519
+ const i = e.split(`
520
+ `);
521
+ let n = 0, o = r;
522
+ for (const a of i) {
523
+ if (o <= a.length)
524
+ break;
525
+ o -= a.length + 1, n++;
526
+ }
527
+ for (n = Math.max(0, Math.min(i.length - 1, n + s)), o = Math.min(o, i[n].length) + t;o < 0 && n > 0; )
528
+ n--, o += i[n].length + 1;
529
+ for (;o > i[n].length && n < i.length - 1; )
530
+ o -= i[n].length + 1, n++;
531
+ o = Math.max(0, Math.min(i[n].length, o));
532
+ let u = 0;
533
+ for (let a = 0;a < n; a++)
534
+ u += i[a].length + 1;
535
+ return u + o;
536
+ }
537
+ var G = ["up", "down", "left", "right", "space", "enter", "cancel"];
538
+ var K = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
539
+ var h = { actions: new Set(G), aliases: new Map([["k", "up"], ["j", "down"], ["h", "left"], ["l", "right"], ["\x03", "cancel"], ["escape", "cancel"]]), messages: { cancel: "Canceled", error: "Something went wrong" }, withGuide: true, date: { monthNames: [...K], messages: { required: "Please enter a valid date", invalidMonth: "There are only 12 months in a year", invalidDay: (r, t) => `There are only ${r} days in ${t}`, afterMin: (r) => `Date must be on or after ${r.toISOString().slice(0, 10)}`, beforeMax: (r) => `Date must be on or before ${r.toISOString().slice(0, 10)}` } } };
540
+ function C(r, t) {
541
+ if (typeof r == "string")
542
+ return h.aliases.get(r) === t;
543
+ for (const s of r)
544
+ if (s !== undefined && C(s, t))
545
+ return true;
546
+ return false;
547
+ }
548
+ function z(r, t) {
549
+ if (r === t)
550
+ return;
551
+ const s = r.split(`
552
+ `), e = t.split(`
553
+ `), i = Math.max(s.length, e.length), n = [];
554
+ for (let o = 0;o < i; o++)
555
+ s[o] !== e[o] && n.push(o);
556
+ return { lines: n, numLinesBefore: s.length, numLinesAfter: e.length, numLines: i };
557
+ }
558
+ var Y = globalThis.process.platform.startsWith("win");
559
+ var k = Symbol("clack:cancel");
560
+ function q(r) {
561
+ return r === k;
562
+ }
563
+ function w(r, t) {
564
+ const s = r;
565
+ s.isTTY && s.setRawMode(t);
566
+ }
567
+ function R({ input: r = D, output: t = S, overwrite: s = true, hideCursor: e = true } = {}) {
568
+ const i = b.createInterface({ input: r, output: t, prompt: "", tabSize: 1 });
569
+ b.emitKeypressEvents(r, i), r instanceof O && r.isTTY && r.setRawMode(true);
570
+ const n = (o, { name: u, sequence: a }) => {
571
+ const l = String(o);
572
+ if (C([l, u, a], "cancel")) {
573
+ e && t.write(import_sisteransi.cursor.show), process.exit(0);
574
+ return;
575
+ }
576
+ if (!s)
577
+ return;
578
+ const f = u === "return" ? 0 : -1, y = u === "return" ? -1 : 0;
579
+ b.moveCursor(t, f, y, () => {
580
+ b.clearLine(t, 1, () => {
581
+ r.once("keypress", n);
582
+ });
583
+ });
584
+ };
585
+ return e && t.write(import_sisteransi.cursor.hide), r.once("keypress", n), () => {
586
+ r.off("keypress", n), e && t.write(import_sisteransi.cursor.show), r instanceof O && r.isTTY && !Y && r.setRawMode(false), i.terminal = false, i.close();
587
+ };
588
+ }
589
+ var A = (r) => ("columns" in r) && typeof r.columns == "number" ? r.columns : 80;
590
+ var L = (r) => ("rows" in r) && typeof r.rows == "number" ? r.rows : 20;
591
+ function W(r, t, s, e = s, i) {
592
+ const n = A(r ?? S);
593
+ return wrapAnsi(t, n - s.length, { hard: true, trim: false }).split(`
594
+ `).map((o, u) => {
595
+ const a = i ? i(o, u) : o;
596
+ return `${u === 0 ? e : s}${a}`;
597
+ }).join(`
598
+ `);
599
+ }
600
+ var p = class {
601
+ input;
602
+ output;
603
+ _abortSignal;
604
+ rl;
605
+ opts;
606
+ _render;
607
+ _track = false;
608
+ _prevFrame = "";
609
+ _subscribers = new Map;
610
+ _cursor = 0;
611
+ state = "initial";
612
+ error = "";
613
+ value;
614
+ userInput = "";
615
+ constructor(t, s = true) {
616
+ const { input: e = D, output: i = S, render: n, signal: o, ...u } = t;
617
+ this.opts = u, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = n.bind(this), this._track = s, this._abortSignal = o, this.input = e, this.output = i;
618
+ }
619
+ unsubscribe() {
620
+ this._subscribers.clear();
621
+ }
622
+ setSubscriber(t, s) {
623
+ const e = this._subscribers.get(t) ?? [];
624
+ e.push(s), this._subscribers.set(t, e);
625
+ }
626
+ on(t, s) {
627
+ this.setSubscriber(t, { cb: s });
628
+ }
629
+ once(t, s) {
630
+ this.setSubscriber(t, { cb: s, once: true });
631
+ }
632
+ emit(t, ...s) {
633
+ const e = this._subscribers.get(t) ?? [], i = [];
634
+ for (const n of e)
635
+ n.cb(...s), n.once && i.push(() => e.splice(e.indexOf(n), 1));
636
+ for (const n of i)
637
+ n();
638
+ }
639
+ prompt() {
640
+ return new Promise((t) => {
641
+ if (this._abortSignal) {
642
+ if (this._abortSignal.aborted)
643
+ return this.state = "cancel", this.close(), t(k);
644
+ this._abortSignal.addEventListener("abort", () => {
645
+ this.state = "cancel", this.close();
646
+ }, { once: true });
647
+ }
648
+ this.rl = E.createInterface({ input: this.input, tabSize: 2, prompt: "", escapeCodeTimeout: 50, terminal: true }), this.rl.prompt(), this.opts.initialUserInput !== undefined && this._setUserInput(this.opts.initialUserInput, true), this.input.on("keypress", this.onKeypress), w(this.input, true), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
649
+ this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), w(this.input, false), t(this.value);
650
+ }), this.once("cancel", () => {
651
+ this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), w(this.input, false), t(k);
652
+ });
653
+ });
654
+ }
655
+ _isActionKey(t, s) {
656
+ return t === "\t";
657
+ }
658
+ _shouldSubmit(t, s) {
659
+ return true;
660
+ }
661
+ _setValue(t) {
662
+ this.value = t, this.emit("value", this.value);
663
+ }
664
+ _setUserInput(t, s) {
665
+ this.userInput = t ?? "", this.emit("userInput", this.userInput), s && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
666
+ }
667
+ _clearUserInput() {
668
+ this.rl?.write(null, { ctrl: true, name: "u" }), this._setUserInput("");
669
+ }
670
+ onKeypress(t, s) {
671
+ if (this._track && s.name !== "return" && (s.name && this._isActionKey(t, s) && this.rl?.write(null, { ctrl: true, name: "h" }), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"), s?.name && (!this._track && h.aliases.has(s.name) && this.emit("cursor", h.aliases.get(s.name)), h.actions.has(s.name) && this.emit("cursor", s.name)), t && (t.toLowerCase() === "y" || t.toLowerCase() === "n") && this.emit("confirm", t.toLowerCase() === "y"), this.emit("key", t?.toLowerCase(), s), s?.name === "return" && this._shouldSubmit(t, s)) {
672
+ if (this.opts.validate) {
673
+ const e = this.opts.validate(this.value);
674
+ e && (this.error = e instanceof Error ? e.message : e, this.state = "error", this.rl?.write(this.userInput));
675
+ }
676
+ this.state !== "error" && (this.state = "submit");
677
+ }
678
+ C([t, s?.name, s?.sequence], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
679
+ }
680
+ close() {
681
+ this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
682
+ `), w(this.input, false), this.rl?.close(), this.rl = undefined, this.emit(`${this.state}`, this.value), this.unsubscribe();
683
+ }
684
+ restoreCursor() {
685
+ const t = wrapAnsi(this._prevFrame, process.stdout.columns, { hard: true, trim: false }).split(`
686
+ `).length - 1;
687
+ this.output.write(import_sisteransi.cursor.move(-999, t * -1));
688
+ }
689
+ render() {
690
+ const t = wrapAnsi(this._render(this) ?? "", process.stdout.columns, { hard: true, trim: false });
691
+ if (t !== this._prevFrame) {
692
+ if (this.state === "initial")
693
+ this.output.write(import_sisteransi.cursor.hide);
694
+ else {
695
+ const s = z(this._prevFrame, t), e = L(this.output);
696
+ if (this.restoreCursor(), s) {
697
+ const i = Math.max(0, s.numLinesAfter - e), n = Math.max(0, s.numLinesBefore - e);
698
+ let o = s.lines.find((u) => u >= i);
699
+ if (o === undefined) {
700
+ this._prevFrame = t;
701
+ return;
702
+ }
703
+ if (s.lines.length === 1) {
704
+ this.output.write(import_sisteransi.cursor.move(0, o - n)), this.output.write(import_sisteransi.erase.lines(1));
705
+ const u = t.split(`
706
+ `);
707
+ this.output.write(u[o]), this._prevFrame = t, this.output.write(import_sisteransi.cursor.move(0, u.length - o - 1));
708
+ return;
709
+ } else if (s.lines.length > 1) {
710
+ if (i < n)
711
+ o = i;
712
+ else {
713
+ const a = o - n;
714
+ a > 0 && this.output.write(import_sisteransi.cursor.move(0, a));
715
+ }
716
+ this.output.write(import_sisteransi.erase.down());
717
+ const u = t.split(`
718
+ `).slice(o);
719
+ this.output.write(u.join(`
720
+ `)), this._prevFrame = t;
721
+ return;
722
+ }
723
+ }
724
+ this.output.write(import_sisteransi.erase.down());
725
+ }
726
+ this.output.write(t), this.state === "initial" && (this.state = "active"), this._prevFrame = t;
727
+ }
728
+ }
729
+ };
730
+ function B(r, t) {
731
+ if (r === undefined || t.length === 0)
732
+ return 0;
733
+ const s = t.findIndex((e) => e.value === r);
734
+ return s !== -1 ? s : 0;
735
+ }
736
+ function J(r, t) {
737
+ return (t.label ?? String(t.value)).toLowerCase().includes(r.toLowerCase());
738
+ }
739
+ function H(r, t) {
740
+ if (t)
741
+ return r ? t : t[0];
742
+ }
743
+ var Q = class extends p {
744
+ filteredOptions;
745
+ multiple;
746
+ isNavigating = false;
747
+ selectedValues = [];
748
+ focusedValue;
749
+ #s = 0;
750
+ #r = "";
751
+ #t;
752
+ #n;
753
+ #u;
754
+ get cursor() {
755
+ return this.#s;
756
+ }
757
+ get userInputWithCursor() {
758
+ if (!this.userInput)
759
+ return v(["inverse", "hidden"], "_");
760
+ if (this._cursor >= this.userInput.length)
761
+ return `${this.userInput}█`;
762
+ const t = this.userInput.slice(0, this._cursor), [s, ...e] = this.userInput.slice(this._cursor);
763
+ return `${t}${v("inverse", s)}${e.join("")}`;
764
+ }
765
+ get options() {
766
+ return typeof this.#n == "function" ? this.#n() : this.#n;
767
+ }
768
+ constructor(t) {
769
+ super(t), this.#n = t.options, this.#u = t.placeholder;
770
+ const s = this.options;
771
+ this.filteredOptions = [...s], this.multiple = t.multiple === true, this.#t = typeof t.options == "function" ? t.filter : t.filter ?? J;
772
+ let e;
773
+ if (t.initialValue && Array.isArray(t.initialValue) ? this.multiple ? e = t.initialValue : e = t.initialValue.slice(0, 1) : !this.multiple && this.options.length > 0 && (e = [this.options[0].value]), e)
774
+ for (const i of e) {
775
+ const n = s.findIndex((o) => o.value === i);
776
+ n !== -1 && (this.toggleSelected(i), this.#s = n);
777
+ }
778
+ this.focusedValue = this.options[this.#s]?.value, this.on("key", (i, n) => this.#e(i, n)), this.on("userInput", (i) => this.#i(i));
779
+ }
780
+ _isActionKey(t, s) {
781
+ return t === "\t" || this.multiple && this.isNavigating && s.name === "space" && t !== undefined && t !== "";
782
+ }
783
+ #e(t, s) {
784
+ const e = s.name === "up", i = s.name === "down", n = s.name === "return", o = this.userInput === "" || this.userInput === "\t", u = this.#u, a = this.options, l = u !== undefined && u !== "" && a.some((f) => !f.disabled && (this.#t ? this.#t(u, f) : true));
785
+ if (s.name === "tab" && o && l) {
786
+ this.userInput === "\t" && this._clearUserInput(), this._setUserInput(u, true), this.isNavigating = false;
787
+ return;
788
+ }
789
+ e || i ? (this.#s = d(this.#s, e ? -1 : 1, this.filteredOptions), this.focusedValue = this.filteredOptions[this.#s]?.value, this.multiple || (this.selectedValues = [this.focusedValue]), this.isNavigating = true) : n ? this.value = H(this.multiple, this.selectedValues) : this.multiple ? this.focusedValue !== undefined && (s.name === "tab" || this.isNavigating && s.name === "space") ? this.toggleSelected(this.focusedValue) : this.isNavigating = false : (this.focusedValue && (this.selectedValues = [this.focusedValue]), this.isNavigating = false);
790
+ }
791
+ deselectAll() {
792
+ this.selectedValues = [];
793
+ }
794
+ toggleSelected(t) {
795
+ this.filteredOptions.length !== 0 && (this.multiple ? this.selectedValues.includes(t) ? this.selectedValues = this.selectedValues.filter((s) => s !== t) : this.selectedValues = [...this.selectedValues, t] : this.selectedValues = [t]);
796
+ }
797
+ #i(t) {
798
+ if (t !== this.#r) {
799
+ this.#r = t;
800
+ const s = this.options;
801
+ t && this.#t ? this.filteredOptions = s.filter((n) => this.#t?.(t, n)) : this.filteredOptions = [...s];
802
+ const e = B(this.focusedValue, this.filteredOptions);
803
+ this.#s = d(e, 0, this.filteredOptions);
804
+ const i = this.filteredOptions[this.#s];
805
+ i && !i.disabled ? this.focusedValue = i.value : this.focusedValue = undefined, this.multiple || (this.focusedValue !== undefined ? this.toggleSelected(this.focusedValue) : this.deselectAll());
806
+ }
807
+ }
808
+ };
809
+
810
+ class X extends p {
811
+ get cursor() {
812
+ return this.value ? 0 : 1;
813
+ }
814
+ get _value() {
815
+ return this.cursor === 0;
816
+ }
817
+ constructor(t) {
818
+ super(t, false), this.value = !!t.initialValue, this.on("userInput", () => {
819
+ this.value = this._value;
820
+ }), this.on("confirm", (s) => {
821
+ this.output.write(import_sisteransi.cursor.move(0, -1)), this.value = s, this.state = "submit", this.close();
822
+ }), this.on("cursor", () => {
823
+ this.value = !this.value;
824
+ });
825
+ }
826
+ }
827
+ var Z = { Y: { type: "year", len: 4 }, M: { type: "month", len: 2 }, D: { type: "day", len: 2 } };
828
+ function P(r) {
829
+ return [...r].map((t) => Z[t]);
830
+ }
831
+ function tt(r) {
832
+ const t = new Intl.DateTimeFormat(r, { year: "numeric", month: "2-digit", day: "2-digit" }).formatToParts(new Date(2000, 0, 15)), s = [];
833
+ let e = "/";
834
+ for (const i of t)
835
+ i.type === "literal" ? e = i.value.trim() || i.value : (i.type === "year" || i.type === "month" || i.type === "day") && s.push({ type: i.type, len: i.type === "year" ? 4 : 2 });
836
+ return { segments: s, separator: e };
837
+ }
838
+ function U(r) {
839
+ return Number.parseInt((r || "0").replace(/_/g, "0"), 10) || 0;
840
+ }
841
+ function x(r) {
842
+ return { year: U(r.year), month: U(r.month), day: U(r.day) };
843
+ }
844
+ function $(r, t) {
845
+ return new Date(r || 2001, t || 1, 0).getDate();
846
+ }
847
+ function F(r) {
848
+ const { year: t, month: s, day: e } = x(r);
849
+ if (!t || t < 0 || t > 9999 || !s || s < 1 || s > 12 || !e || e < 1)
850
+ return;
851
+ const i = new Date(Date.UTC(t, s - 1, e));
852
+ if (!(i.getUTCFullYear() !== t || i.getUTCMonth() !== s - 1 || i.getUTCDate() !== e))
853
+ return { year: t, month: s, day: e };
854
+ }
855
+ function N(r) {
856
+ const t = F(r);
857
+ return t ? new Date(Date.UTC(t.year, t.month - 1, t.day)) : undefined;
858
+ }
859
+ function st(r, t, s, e) {
860
+ const i = s ? { year: s.getUTCFullYear(), month: s.getUTCMonth() + 1, day: s.getUTCDate() } : null, n = e ? { year: e.getUTCFullYear(), month: e.getUTCMonth() + 1, day: e.getUTCDate() } : null;
861
+ return r === "year" ? { min: i?.year ?? 1, max: n?.year ?? 9999 } : r === "month" ? { min: i && t.year === i.year ? i.month : 1, max: n && t.year === n.year ? n.month : 12 } : { min: i && t.year === i.year && t.month === i.month ? i.day : 1, max: n && t.year === n.year && t.month === n.month ? n.day : $(t.year, t.month) };
862
+ }
863
+
864
+ class et extends p {
865
+ #s;
866
+ #r;
867
+ #t;
868
+ #n;
869
+ #u;
870
+ #e = { segmentIndex: 0, positionInSegment: 0 };
871
+ #i = true;
872
+ #o = null;
873
+ inlineError = "";
874
+ get segmentCursor() {
875
+ return { ...this.#e };
876
+ }
877
+ get segmentValues() {
878
+ return { ...this.#t };
879
+ }
880
+ get segments() {
881
+ return this.#s;
882
+ }
883
+ get separator() {
884
+ return this.#r;
885
+ }
886
+ get formattedValue() {
887
+ return this.#c(this.#t);
888
+ }
889
+ #c(t) {
890
+ return this.#s.map((s) => t[s.type]).join(this.#r);
891
+ }
892
+ #a() {
893
+ this._setUserInput(this.#c(this.#t)), this._setValue(N(this.#t) ?? undefined);
894
+ }
895
+ constructor(t) {
896
+ const s = t.format ? { segments: P(t.format), separator: t.separator ?? "/" } : tt(t.locale), e = t.separator ?? s.separator, i = t.format ? P(t.format) : s.segments, n = t.initialValue ?? t.defaultValue, o = n ? { year: String(n.getUTCFullYear()).padStart(4, "0"), month: String(n.getUTCMonth() + 1).padStart(2, "0"), day: String(n.getUTCDate()).padStart(2, "0") } : { year: "____", month: "__", day: "__" }, u = i.map((a) => o[a.type]).join(e);
897
+ super({ ...t, initialUserInput: u }, false), this.#s = i, this.#r = e, this.#t = o, this.#n = t.minDate, this.#u = t.maxDate, this.#a(), this.on("cursor", (a) => this.#d(a)), this.on("key", (a, l) => this.#f(a, l)), this.on("finalize", () => this.#g(t));
898
+ }
899
+ #h() {
900
+ const t = Math.max(0, Math.min(this.#e.segmentIndex, this.#s.length - 1)), s = this.#s[t];
901
+ if (s)
902
+ return this.#e.positionInSegment = Math.max(0, Math.min(this.#e.positionInSegment, s.len - 1)), { segment: s, index: t };
903
+ }
904
+ #l(t) {
905
+ this.inlineError = "", this.#o = null;
906
+ const s = this.#h();
907
+ s && (this.#e.segmentIndex = Math.max(0, Math.min(this.#s.length - 1, s.index + t)), this.#e.positionInSegment = 0, this.#i = true);
908
+ }
909
+ #p(t) {
910
+ const s = this.#h();
911
+ if (!s)
912
+ return;
913
+ const { segment: e } = s, i = this.#t[e.type], n = !i || i.replace(/_/g, "") === "", o = Number.parseInt((i || "0").replace(/_/g, "0"), 10) || 0, u = st(e.type, x(this.#t), this.#n, this.#u);
914
+ let a;
915
+ n ? a = t === 1 ? u.min : u.max : a = Math.max(Math.min(u.max, o + t), u.min), this.#t = { ...this.#t, [e.type]: a.toString().padStart(e.len, "0") }, this.#i = true, this.#o = null, this.#a();
916
+ }
917
+ #d(t) {
918
+ if (t)
919
+ switch (t) {
920
+ case "right":
921
+ return this.#l(1);
922
+ case "left":
923
+ return this.#l(-1);
924
+ case "up":
925
+ return this.#p(1);
926
+ case "down":
927
+ return this.#p(-1);
928
+ }
929
+ }
930
+ #f(t, s) {
931
+ if (s?.name === "backspace" || s?.sequence === "" || s?.sequence === "\b" || t === "" || t === "\b") {
932
+ this.inlineError = "";
933
+ const e = this.#h();
934
+ if (!e)
935
+ return;
936
+ if (!this.#t[e.segment.type].replace(/_/g, "")) {
937
+ this.#l(-1);
938
+ return;
939
+ }
940
+ this.#t[e.segment.type] = "_".repeat(e.segment.len), this.#i = true, this.#e.positionInSegment = 0, this.#a();
941
+ return;
942
+ }
943
+ if (s?.name === "tab") {
944
+ this.inlineError = "";
945
+ const e = this.#h();
946
+ if (!e)
947
+ return;
948
+ const i = s.shift ? -1 : 1, n = e.index + i;
949
+ n >= 0 && n < this.#s.length && (this.#e.segmentIndex = n, this.#e.positionInSegment = 0, this.#i = true);
950
+ return;
951
+ }
952
+ if (t && /^[0-9]$/.test(t)) {
953
+ const e = this.#h();
954
+ if (!e)
955
+ return;
956
+ const { segment: i } = e, n = !this.#t[i.type].replace(/_/g, "");
957
+ if (this.#i && this.#o !== null && !n) {
958
+ const m = this.#o + t, g = { ...this.#t, [i.type]: m }, _ = this.#m(g, i);
959
+ if (_) {
960
+ this.inlineError = _, this.#o = null, this.#i = false;
961
+ return;
962
+ }
963
+ this.inlineError = "", this.#t[i.type] = m, this.#o = null, this.#i = false, this.#a(), e.index < this.#s.length - 1 && (this.#e.segmentIndex = e.index + 1, this.#e.positionInSegment = 0, this.#i = true);
964
+ return;
965
+ }
966
+ this.#i && !n && (this.#t[i.type] = "_".repeat(i.len), this.#e.positionInSegment = 0), this.#i = false, this.#o = null;
967
+ const o = this.#t[i.type], u = o.indexOf("_"), a = u >= 0 ? u : Math.min(this.#e.positionInSegment, i.len - 1);
968
+ if (a < 0 || a >= i.len)
969
+ return;
970
+ let l = o.slice(0, a) + t + o.slice(a + 1), f = false;
971
+ if (a === 0 && o === "__" && (i.type === "month" || i.type === "day")) {
972
+ const m = Number.parseInt(t, 10);
973
+ l = `0${t}`, f = m <= (i.type === "month" ? 1 : 2);
974
+ }
975
+ if (i.type === "year" && (l = (o.replace(/_/g, "") + t).padStart(i.len, "_")), !l.includes("_")) {
976
+ const m = { ...this.#t, [i.type]: l }, g = this.#m(m, i);
977
+ if (g) {
978
+ this.inlineError = g;
979
+ return;
980
+ }
981
+ }
982
+ this.inlineError = "", this.#t[i.type] = l;
983
+ const y = l.includes("_") ? undefined : F(this.#t);
984
+ if (y) {
985
+ const { year: m, month: g } = y, _ = $(m, g);
986
+ this.#t = { year: String(Math.max(0, Math.min(9999, m))).padStart(4, "0"), month: String(Math.max(1, Math.min(12, g))).padStart(2, "0"), day: String(Math.max(1, Math.min(_, y.day))).padStart(2, "0") };
987
+ }
988
+ this.#a();
989
+ const T = l.indexOf("_");
990
+ f ? (this.#i = true, this.#o = t) : T >= 0 ? this.#e.positionInSegment = T : u >= 0 && e.index < this.#s.length - 1 ? (this.#e.segmentIndex = e.index + 1, this.#e.positionInSegment = 0, this.#i = true) : this.#e.positionInSegment = Math.min(a + 1, i.len - 1);
991
+ }
992
+ }
993
+ #m(t, s) {
994
+ const { month: e, day: i } = x(t);
995
+ if (s.type === "month" && (e < 0 || e > 12))
996
+ return h.date.messages.invalidMonth;
997
+ if (s.type === "day" && (i < 0 || i > 31))
998
+ return h.date.messages.invalidDay(31, "any month");
999
+ }
1000
+ #g(t) {
1001
+ const { year: s, month: e, day: i } = x(this.#t);
1002
+ if (s && e && i) {
1003
+ const n = $(s, e);
1004
+ this.#t = { ...this.#t, day: String(Math.min(i, n)).padStart(2, "0") };
1005
+ }
1006
+ this.value = N(this.#t) ?? t.defaultValue ?? undefined;
1007
+ }
1008
+ }
1009
+
1010
+ class it extends p {
1011
+ options;
1012
+ cursor = 0;
1013
+ #s;
1014
+ getGroupItems(t) {
1015
+ return this.options.filter((s) => s.group === t);
1016
+ }
1017
+ isGroupSelected(t) {
1018
+ const s = this.getGroupItems(t), e = this.value;
1019
+ return e === undefined ? false : s.every((i) => e.includes(i.value));
1020
+ }
1021
+ toggleValue() {
1022
+ const t = this.options[this.cursor];
1023
+ if (this.value === undefined && (this.value = []), t.group === true) {
1024
+ const s = t.value, e = this.getGroupItems(s);
1025
+ this.isGroupSelected(s) ? this.value = this.value.filter((i) => e.findIndex((n) => n.value === i) === -1) : this.value = [...this.value, ...e.map((i) => i.value)], this.value = Array.from(new Set(this.value));
1026
+ } else {
1027
+ const s = this.value.includes(t.value);
1028
+ this.value = s ? this.value.filter((e) => e !== t.value) : [...this.value, t.value];
1029
+ }
1030
+ }
1031
+ constructor(t) {
1032
+ super(t, false);
1033
+ const { options: s } = t;
1034
+ this.#s = t.selectableGroups !== false, this.options = Object.entries(s).flatMap(([e, i]) => [{ value: e, group: true, label: e }, ...i.map((n) => ({ ...n, group: e }))]), this.value = [...t.initialValues ?? []], this.cursor = Math.max(this.options.findIndex(({ value: e }) => e === t.cursorAt), this.#s ? 0 : 1), this.on("cursor", (e) => {
1035
+ switch (e) {
1036
+ case "left":
1037
+ case "up": {
1038
+ this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
1039
+ const i = this.options[this.cursor]?.group === true;
1040
+ !this.#s && i && (this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1);
1041
+ break;
1042
+ }
1043
+ case "down":
1044
+ case "right": {
1045
+ this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
1046
+ const i = this.options[this.cursor]?.group === true;
1047
+ !this.#s && i && (this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1);
1048
+ break;
1049
+ }
1050
+ case "space":
1051
+ this.toggleValue();
1052
+ break;
1053
+ }
1054
+ });
1055
+ }
1056
+ }
1057
+
1058
+ class rt extends p {
1059
+ #s = false;
1060
+ #r;
1061
+ focused = "editor";
1062
+ get userInputWithCursor() {
1063
+ if (this.state === "submit")
1064
+ return this.userInput;
1065
+ const t = this.userInput;
1066
+ if (this.cursor >= t.length)
1067
+ return `${t}█`;
1068
+ const s = t.slice(0, this.cursor), e = t[this.cursor], i = t.slice(this.cursor + 1);
1069
+ return e === `
1070
+ ` ? `${s}█
1071
+ ${i}` : `${s}${v("inverse", e)}${i}`;
1072
+ }
1073
+ get cursor() {
1074
+ return this._cursor;
1075
+ }
1076
+ #t(t) {
1077
+ if (this.userInput.length === 0) {
1078
+ this._setUserInput(t);
1079
+ return;
1080
+ }
1081
+ this._setUserInput(this.userInput.slice(0, this.cursor) + t + this.userInput.slice(this.cursor));
1082
+ }
1083
+ #n(t) {
1084
+ const s = this.value ?? "";
1085
+ switch (t) {
1086
+ case "up":
1087
+ this._cursor = I(this._cursor, 0, -1, s);
1088
+ return;
1089
+ case "down":
1090
+ this._cursor = I(this._cursor, 0, 1, s);
1091
+ return;
1092
+ case "left":
1093
+ this._cursor = I(this._cursor, -1, 0, s);
1094
+ return;
1095
+ case "right":
1096
+ this._cursor = I(this._cursor, 1, 0, s);
1097
+ return;
1098
+ }
1099
+ }
1100
+ _shouldSubmit(t, s) {
1101
+ if (this.#r)
1102
+ return this.focused === "submit" ? true : (this.#t(`
1103
+ `), this._cursor++, false);
1104
+ const e = this.#s;
1105
+ return this.#s = true, e ? (this.userInput[this.cursor - 1] === `
1106
+ ` && (this._setUserInput(this.userInput.slice(0, this.cursor - 1) + this.userInput.slice(this.cursor)), this._cursor--), true) : (this.#t(`
1107
+ `), this._cursor++, false);
1108
+ }
1109
+ constructor(t) {
1110
+ super(t, false), this.#r = t.showSubmit ?? false, this.on("key", (s, e) => {
1111
+ if (e?.name && h.actions.has(e.name)) {
1112
+ this.#n(e.name);
1113
+ return;
1114
+ }
1115
+ if (s === "\t" && this.#r) {
1116
+ this.focused = this.focused === "editor" ? "submit" : "editor";
1117
+ return;
1118
+ }
1119
+ if (e?.name !== "return") {
1120
+ if (this.#s = false, e?.name === "backspace" && this.cursor > 0) {
1121
+ this._setUserInput(this.userInput.slice(0, this.cursor - 1) + this.userInput.slice(this.cursor)), this._cursor--;
1122
+ return;
1123
+ }
1124
+ if (e?.name === "delete" && this.cursor < this.userInput.length) {
1125
+ this._setUserInput(this.userInput.slice(0, this.cursor) + this.userInput.slice(this.cursor + 1));
1126
+ return;
1127
+ }
1128
+ s && (this.#r && this.focused === "submit" && (this.focused = "editor"), this.#t(s ?? ""), this._cursor++);
1129
+ }
1130
+ }), this.on("userInput", (s) => {
1131
+ this._setValue(s);
1132
+ }), this.on("finalize", () => {
1133
+ this.value || (this.value = t.defaultValue), this.value === undefined && (this.value = "");
1134
+ });
1135
+ }
1136
+ }
1137
+ class ut extends p {
1138
+ options;
1139
+ cursor = 0;
1140
+ get _selectedValue() {
1141
+ return this.options[this.cursor];
1142
+ }
1143
+ changeValue() {
1144
+ this.value = this._selectedValue.value;
1145
+ }
1146
+ constructor(t) {
1147
+ super(t, false), this.options = t.options;
1148
+ const s = this.options.findIndex(({ value: i }) => i === t.initialValue), e = s === -1 ? 0 : s;
1149
+ this.cursor = this.options[e].disabled ? d(e, 1, this.options) : e, this.changeValue(), this.on("cursor", (i) => {
1150
+ switch (i) {
1151
+ case "left":
1152
+ case "up":
1153
+ this.cursor = d(this.cursor, -1, this.options);
1154
+ break;
1155
+ case "down":
1156
+ case "right":
1157
+ this.cursor = d(this.cursor, 1, this.options);
1158
+ break;
1159
+ }
1160
+ this.changeValue();
1161
+ });
1162
+ }
1163
+ }
1164
+ class ht extends p {
1165
+ get userInputWithCursor() {
1166
+ if (this.state === "submit")
1167
+ return this.userInput;
1168
+ const t = this.userInput;
1169
+ if (this.cursor >= t.length)
1170
+ return `${this.userInput}█`;
1171
+ const s = t.slice(0, this.cursor), [e, ...i] = t.slice(this.cursor);
1172
+ return `${s}${v("inverse", e)}${i.join("")}`;
1173
+ }
1174
+ get cursor() {
1175
+ return this._cursor;
1176
+ }
1177
+ constructor(t) {
1178
+ super({ ...t, initialUserInput: t.initialUserInput ?? t.initialValue }), this.on("userInput", (s) => {
1179
+ this._setValue(s);
1180
+ }), this.on("finalize", () => {
1181
+ this.value || (this.value = t.defaultValue), this.value === undefined && (this.value = "");
1182
+ });
1183
+ }
1184
+ }
1185
+
1186
+ // node_modules/@clack/prompts/dist/index.mjs
1187
+ import { styleText as e, stripVTControlCharacters as nt2 } from "node:util";
1188
+ import j2 from "node:process";
1189
+ var import_sisteransi2 = __toESM(require_src(), 1);
1190
+ function te() {
1191
+ return j2.platform !== "win32" ? j2.env.TERM !== "linux" : !!j2.env.CI || !!j2.env.WT_SESSION || !!j2.env.TERMINUS_SUBLIME || j2.env.ConEmuTask === "{cmd::Cmder}" || j2.env.TERM_PROGRAM === "Terminus-Sublime" || j2.env.TERM_PROGRAM === "vscode" || j2.env.TERM === "xterm-256color" || j2.env.TERM === "alacritty" || j2.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
1192
+ }
1193
+ var tt2 = te();
1194
+ var at2 = () => process.env.CI === "true";
1195
+ var w2 = (t, r) => tt2 ? t : r;
1196
+ var _t = w2("◆", "*");
1197
+ var ot2 = w2("■", "x");
1198
+ var ut2 = w2("▲", "x");
1199
+ var F2 = w2("◇", "o");
1200
+ var lt = w2("┌", "T");
1201
+ var $2 = w2("│", "|");
1202
+ var E2 = w2("└", "—");
1203
+ var It = w2("┐", "T");
1204
+ var Et = w2("┘", "—");
1205
+ var z2 = w2("●", ">");
1206
+ var H2 = w2("○", " ");
1207
+ var et2 = w2("◻", "[•]");
1208
+ var U2 = w2("◼", "[+]");
1209
+ var J2 = w2("◻", "[ ]");
1210
+ var Gt = w2("▪", "•");
1211
+ var st2 = w2("─", "-");
1212
+ var ct = w2("╮", "+");
1213
+ var xt = w2("├", "+");
1214
+ var $t = w2("╯", "+");
1215
+ var dt = w2("╰", "+");
1216
+ var Ot = w2("╭", "+");
1217
+ var ht2 = w2("●", "•");
1218
+ var pt = w2("◆", "*");
1219
+ var mt = w2("▲", "!");
1220
+ var gt = w2("■", "x");
1221
+ var M = (t) => {
1222
+ switch (t) {
1223
+ case "initial":
1224
+ case "active":
1225
+ return e("cyan", _t);
1226
+ case "cancel":
1227
+ return e("red", ot2);
1228
+ case "error":
1229
+ return e("yellow", ut2);
1230
+ case "submit":
1231
+ return e("green", F2);
1232
+ }
1233
+ };
1234
+ var yt = (t) => {
1235
+ switch (t) {
1236
+ case "initial":
1237
+ case "active":
1238
+ return e("cyan", $2);
1239
+ case "cancel":
1240
+ return e("red", $2);
1241
+ case "error":
1242
+ return e("yellow", $2);
1243
+ case "submit":
1244
+ return e("green", $2);
1245
+ }
1246
+ };
1247
+ var ee = (t, r, s, i, u) => {
1248
+ let n = r, o = 0;
1249
+ for (let c2 = s;c2 < i; c2++) {
1250
+ const a = t[c2];
1251
+ if (n = n - a.length, o++, n <= u)
1252
+ break;
1253
+ }
1254
+ return { lineCount: n, removals: o };
1255
+ };
1256
+ var Y2 = ({ cursor: t, options: r, style: s, output: i = process.stdout, maxItems: u = Number.POSITIVE_INFINITY, columnPadding: n = 0, rowPadding: o = 4 }) => {
1257
+ const c2 = A(i) - n, a = L(i), l = e("dim", "..."), d2 = Math.max(a - o, 0), y = Math.max(Math.min(u, d2), 5);
1258
+ let p2 = 0;
1259
+ t >= y - 3 && (p2 = Math.max(Math.min(t - y + 3, r.length - y), 0));
1260
+ let m = y < r.length && p2 > 0, g = y < r.length && p2 + y < r.length;
1261
+ const S2 = Math.min(p2 + y, r.length), h2 = [];
1262
+ let f = 0;
1263
+ m && f++, g && f++;
1264
+ const v2 = p2 + (m ? 1 : 0), T = S2 - (g ? 1 : 0);
1265
+ for (let b2 = v2;b2 < T; b2++) {
1266
+ const G2 = wrapAnsi(s(r[b2], b2 === t), c2, { hard: true, trim: false }).split(`
1267
+ `);
1268
+ h2.push(G2), f += G2.length;
1269
+ }
1270
+ if (f > d2) {
1271
+ let b2 = 0, G2 = 0, x2 = f;
1272
+ const A2 = t - v2, P2 = (N2, D2) => ee(h2, x2, N2, D2, d2);
1273
+ m ? ({ lineCount: x2, removals: b2 } = P2(0, A2), x2 > d2 && ({ lineCount: x2, removals: G2 } = P2(A2 + 1, h2.length))) : ({ lineCount: x2, removals: G2 } = P2(A2 + 1, h2.length), x2 > d2 && ({ lineCount: x2, removals: b2 } = P2(0, A2))), b2 > 0 && (m = true, h2.splice(0, b2)), G2 > 0 && (g = true, h2.splice(h2.length - G2, G2));
1274
+ }
1275
+ const C2 = [];
1276
+ m && C2.push(l);
1277
+ for (const b2 of h2)
1278
+ for (const G2 of b2)
1279
+ C2.push(G2);
1280
+ return g && C2.push(l), C2;
1281
+ };
1282
+ var ue = (t) => {
1283
+ const r = t.active ?? "Yes", s = t.inactive ?? "No";
1284
+ return new X({ active: r, inactive: s, signal: t.signal, input: t.input, output: t.output, initialValue: t.initialValue ?? true, render() {
1285
+ const i = t.withGuide ?? h.withGuide, u = `${M(this.state)} `, n = i ? `${e("gray", $2)} ` : "", o = W(t.output, t.message, n, u), c2 = `${i ? `${e("gray", $2)}
1286
+ ` : ""}${o}
1287
+ `, a = this.value ? r : s;
1288
+ switch (this.state) {
1289
+ case "submit": {
1290
+ const l = i ? `${e("gray", $2)} ` : "";
1291
+ return `${c2}${l}${e("dim", a)}`;
1292
+ }
1293
+ case "cancel": {
1294
+ const l = i ? `${e("gray", $2)} ` : "";
1295
+ return `${c2}${l}${e(["strikethrough", "dim"], a)}${i ? `
1296
+ ${e("gray", $2)}` : ""}`;
1297
+ }
1298
+ default: {
1299
+ const l = i ? `${e("cyan", $2)} ` : "", d2 = i ? e("cyan", E2) : "";
1300
+ return `${c2}${l}${this.value ? `${e("green", z2)} ${r}` : `${e("dim", H2)} ${e("dim", r)}`}${t.vertical ? i ? `
1301
+ ${e("cyan", $2)} ` : `
1302
+ ` : ` ${e("dim", "/")} `}${this.value ? `${e("dim", H2)} ${e("dim", s)}` : `${e("green", z2)} ${s}`}
1303
+ ${d2}
1304
+ `;
1305
+ }
1306
+ }
1307
+ } }).prompt();
1308
+ };
1309
+ var R2 = { message: (t = [], { symbol: r = e("gray", $2), secondarySymbol: s = e("gray", $2), output: i = process.stdout, spacing: u = 1, withGuide: n } = {}) => {
1310
+ const o = [], c2 = n ?? h.withGuide, a = c2 ? s : "", l = c2 ? `${r} ` : "", d2 = c2 ? `${s} ` : "";
1311
+ for (let p2 = 0;p2 < u; p2++)
1312
+ o.push(a);
1313
+ const y = Array.isArray(t) ? t : t.split(`
1314
+ `);
1315
+ if (y.length > 0) {
1316
+ const [p2, ...m] = y;
1317
+ p2.length > 0 ? o.push(`${l}${p2}`) : o.push(c2 ? r : "");
1318
+ for (const g of m)
1319
+ g.length > 0 ? o.push(`${d2}${g}`) : o.push(c2 ? s : "");
1320
+ }
1321
+ i.write(`${o.join(`
1322
+ `)}
1323
+ `);
1324
+ }, info: (t, r) => {
1325
+ R2.message(t, { ...r, symbol: e("blue", ht2) });
1326
+ }, success: (t, r) => {
1327
+ R2.message(t, { ...r, symbol: e("green", pt) });
1328
+ }, step: (t, r) => {
1329
+ R2.message(t, { ...r, symbol: e("green", F2) });
1330
+ }, warn: (t, r) => {
1331
+ R2.message(t, { ...r, symbol: e("yellow", mt) });
1332
+ }, warning: (t, r) => {
1333
+ R2.warn(t, r);
1334
+ }, error: (t, r) => {
1335
+ R2.message(t, { ...r, symbol: e("red", gt) });
1336
+ } };
1337
+ var me = (t = "", r) => {
1338
+ const s = r?.output ?? process.stdout, i = r?.withGuide ?? h.withGuide ? `${e("gray", E2)} ` : "";
1339
+ s.write(`${i}${e("red", t)}
1340
+
1341
+ `);
1342
+ };
1343
+ var ge = (t = "", r) => {
1344
+ const s = r?.output ?? process.stdout, i = r?.withGuide ?? h.withGuide ? `${e("gray", lt)} ` : "";
1345
+ s.write(`${i}${t}
1346
+ `);
1347
+ };
1348
+ var ye = (t = "", r) => {
1349
+ const s = r?.output ?? process.stdout, i = r?.withGuide ?? h.withGuide ? `${e("gray", $2)}
1350
+ ${e("gray", E2)} ` : "";
1351
+ s.write(`${i}${t}
1352
+
1353
+ `);
1354
+ };
1355
+ var we = (t) => e("dim", t);
1356
+ var be = (t, r, s) => {
1357
+ const i = { hard: true, trim: false }, u = wrapAnsi(t, r, i).split(`
1358
+ `), n = u.reduce((a, l) => Math.max(dist_default2(l), a), 0), o = u.map(s).reduce((a, l) => Math.max(dist_default2(l), a), 0), c2 = r - (o - n);
1359
+ return wrapAnsi(t, c2, i);
1360
+ };
1361
+ var Se = (t = "", r = "", s) => {
1362
+ const i = s?.output ?? j2.stdout, u = s?.withGuide ?? h.withGuide, n = s?.format ?? we, o = ["", ...be(t, A(i) - 6, n).split(`
1363
+ `).map(n), ""], c2 = dist_default2(r), a = Math.max(o.reduce((p2, m) => {
1364
+ const g = dist_default2(m);
1365
+ return g > p2 ? g : p2;
1366
+ }, 0), c2) + 2, l = o.map((p2) => `${e("gray", $2)} ${p2}${" ".repeat(a - dist_default2(p2))}${e("gray", $2)}`).join(`
1367
+ `), d2 = u ? `${e("gray", $2)}
1368
+ ` : "", y = u ? xt : dt;
1369
+ i.write(`${d2}${e("green", F2)} ${e("reset", r)} ${e("gray", st2.repeat(Math.max(a - c2 - 1, 1)) + ct)}
1370
+ ${l}
1371
+ ${e("gray", y + st2.repeat(a + 2) + $t)}
1372
+ `);
1373
+ };
1374
+ var _e = (t) => e("magenta", t);
1375
+ var ft = ({ indicator: t = "dots", onCancel: r, output: s = process.stdout, cancelMessage: i, errorMessage: u, frames: n = tt2 ? ["◒", "◐", "◓", "◑"] : ["•", "o", "O", "0"], delay: o = tt2 ? 80 : 120, signal: c2, ...a } = {}) => {
1376
+ const l = at2();
1377
+ let d2, y, p2 = false, m = false, g = "", S2, h2 = performance.now();
1378
+ const f = A(s), v2 = a?.styleFrame ?? _e, T = (I2) => {
1379
+ const V2 = I2 > 1 ? u ?? h.messages.error : i ?? h.messages.cancel;
1380
+ m = I2 === 1, p2 && (W2(V2, I2), m && typeof r == "function" && r());
1381
+ }, C2 = () => T(2), b2 = () => T(1), G2 = () => {
1382
+ process.on("uncaughtExceptionMonitor", C2), process.on("unhandledRejection", C2), process.on("SIGINT", b2), process.on("SIGTERM", b2), process.on("exit", T), c2 && c2.addEventListener("abort", b2);
1383
+ }, x2 = () => {
1384
+ process.removeListener("uncaughtExceptionMonitor", C2), process.removeListener("unhandledRejection", C2), process.removeListener("SIGINT", b2), process.removeListener("SIGTERM", b2), process.removeListener("exit", T), c2 && c2.removeEventListener("abort", b2);
1385
+ }, A2 = () => {
1386
+ if (S2 === undefined)
1387
+ return;
1388
+ l && s.write(`
1389
+ `);
1390
+ const I2 = wrapAnsi(S2, f, { hard: true, trim: false }).split(`
1391
+ `);
1392
+ I2.length > 1 && s.write(import_sisteransi2.cursor.up(I2.length - 1)), s.write(import_sisteransi2.cursor.to(0)), s.write(import_sisteransi2.erase.down());
1393
+ }, P2 = (I2) => I2.replace(/\.+$/, ""), N2 = (I2) => {
1394
+ const V2 = (performance.now() - I2) / 1000, B2 = Math.floor(V2 / 60), L2 = Math.floor(V2 % 60);
1395
+ return B2 > 0 ? `[${B2}m ${L2}s]` : `[${L2}s]`;
1396
+ }, D2 = a.withGuide ?? h.withGuide, rt2 = (I2 = "") => {
1397
+ p2 = true, d2 = R({ output: s }), g = P2(I2), h2 = performance.now(), D2 && s.write(`${e("gray", $2)}
1398
+ `);
1399
+ let V2 = 0, B2 = 0;
1400
+ G2(), y = setInterval(() => {
1401
+ if (l && g === S2)
1402
+ return;
1403
+ A2(), S2 = g;
1404
+ const L2 = v2(n[V2]);
1405
+ let Z2;
1406
+ if (l)
1407
+ Z2 = `${L2} ${g}...`;
1408
+ else if (t === "timer")
1409
+ Z2 = `${L2} ${g} ${N2(h2)}`;
1410
+ else {
1411
+ const kt = ".".repeat(Math.floor(B2)).slice(0, 3);
1412
+ Z2 = `${L2} ${g}${kt}`;
1413
+ }
1414
+ const Nt = wrapAnsi(Z2, f, { hard: true, trim: false });
1415
+ s.write(Nt), V2 = V2 + 1 < n.length ? V2 + 1 : 0, B2 = B2 < 4 ? B2 + 0.125 : 0;
1416
+ }, o);
1417
+ }, W2 = (I2 = "", V2 = 0, B2 = false) => {
1418
+ if (!p2)
1419
+ return;
1420
+ p2 = false, clearInterval(y), A2();
1421
+ const L2 = V2 === 0 ? e("green", F2) : V2 === 1 ? e("red", ot2) : e("red", ut2);
1422
+ g = I2 ?? g, B2 || (t === "timer" ? s.write(`${L2} ${g} ${N2(h2)}
1423
+ `) : s.write(`${L2} ${g}
1424
+ `)), x2(), d2();
1425
+ };
1426
+ return { start: rt2, stop: (I2 = "") => W2(I2, 0), message: (I2 = "") => {
1427
+ g = P2(I2 ?? g);
1428
+ }, cancel: (I2 = "") => W2(I2, 1), error: (I2 = "") => W2(I2, 2), clear: () => W2("", 0, true), get isCancelled() {
1429
+ return m;
1430
+ } };
1431
+ };
1432
+ var Vt = { light: w2("─", "-"), heavy: w2("━", "="), block: w2("█", "#") };
1433
+ var it2 = (t, r) => t.includes(`
1434
+ `) ? t.split(`
1435
+ `).map((s) => r(s)).join(`
1436
+ `) : r(t);
1437
+ var Ee = (t) => {
1438
+ const r = (s, i) => {
1439
+ const u = s.label ?? String(s.value);
1440
+ switch (i) {
1441
+ case "disabled":
1442
+ return `${e("gray", H2)} ${it2(u, (n) => e("gray", n))}${s.hint ? ` ${e("dim", `(${s.hint ?? "disabled"})`)}` : ""}`;
1443
+ case "selected":
1444
+ return `${it2(u, (n) => e("dim", n))}`;
1445
+ case "active":
1446
+ return `${e("green", z2)} ${u}${s.hint ? ` ${e("dim", `(${s.hint})`)}` : ""}`;
1447
+ case "cancelled":
1448
+ return `${it2(u, (n) => e(["strikethrough", "dim"], n))}`;
1449
+ default:
1450
+ return `${e("dim", H2)} ${it2(u, (n) => e("dim", n))}`;
1451
+ }
1452
+ };
1453
+ return new ut({ options: t.options, signal: t.signal, input: t.input, output: t.output, initialValue: t.initialValue, render() {
1454
+ const s = t.withGuide ?? h.withGuide, i = `${M(this.state)} `, u = `${yt(this.state)} `, n = W(t.output, t.message, u, i), o = `${s ? `${e("gray", $2)}
1455
+ ` : ""}${n}
1456
+ `;
1457
+ switch (this.state) {
1458
+ case "submit": {
1459
+ const c2 = s ? `${e("gray", $2)} ` : "", a = W(t.output, r(this.options[this.cursor], "selected"), c2);
1460
+ return `${o}${a}`;
1461
+ }
1462
+ case "cancel": {
1463
+ const c2 = s ? `${e("gray", $2)} ` : "", a = W(t.output, r(this.options[this.cursor], "cancelled"), c2);
1464
+ return `${o}${a}${s ? `
1465
+ ${e("gray", $2)}` : ""}`;
1466
+ }
1467
+ default: {
1468
+ const c2 = s ? `${e("cyan", $2)} ` : "", a = s ? e("cyan", E2) : "", l = o.split(`
1469
+ `).length, d2 = s ? 2 : 1;
1470
+ return `${o}${c2}${Y2({ output: t.output, cursor: this.cursor, options: this.options, maxItems: t.maxItems, columnPadding: c2.length, rowPadding: l + d2, style: (y, p2) => r(y, y.disabled ? "disabled" : p2 ? "active" : "inactive") }).join(`
1471
+ ${c2}`)}
1472
+ ${a}
1473
+ `;
1474
+ }
1475
+ }
1476
+ } }).prompt();
1477
+ };
1478
+ var jt = `${e("gray", $2)} `;
1479
+ var Re = (t) => new ht({ validate: t.validate, placeholder: t.placeholder, defaultValue: t.defaultValue, initialValue: t.initialValue, output: t.output, signal: t.signal, input: t.input, render() {
1480
+ const r = t?.withGuide ?? h.withGuide, s = `${`${r ? `${e("gray", $2)}
1481
+ ` : ""}${M(this.state)} `}${t.message}
1482
+ `, i = t.placeholder ? e("inverse", t.placeholder[0]) + e("dim", t.placeholder.slice(1)) : e(["inverse", "hidden"], "_"), u = this.userInput ? this.userInputWithCursor : i, n = this.value ?? "";
1483
+ switch (this.state) {
1484
+ case "error": {
1485
+ const o = this.error ? ` ${e("yellow", this.error)}` : "", c2 = r ? `${e("yellow", $2)} ` : "", a = r ? e("yellow", E2) : "";
1486
+ return `${s.trim()}
1487
+ ${c2}${u}
1488
+ ${a}${o}
1489
+ `;
1490
+ }
1491
+ case "submit": {
1492
+ const o = n ? ` ${e("dim", n)}` : "", c2 = r ? e("gray", $2) : "";
1493
+ return `${s}${c2}${o}`;
1494
+ }
1495
+ case "cancel": {
1496
+ const o = n ? ` ${e(["strikethrough", "dim"], n)}` : "", c2 = r ? e("gray", $2) : "";
1497
+ return `${s}${c2}${o}${n.trim() ? `
1498
+ ${c2}` : ""}`;
1499
+ }
1500
+ default: {
1501
+ const o = r ? `${e("cyan", $2)} ` : "", c2 = r ? e("cyan", E2) : "";
1502
+ return `${s}${o}${u}
1503
+ ${c2}
1504
+ `;
1505
+ }
1506
+ }
1507
+ } }).prompt();
1508
+
1509
+ // src/cli.ts
1510
+ var import_picocolors8 = __toESM(require_picocolors(), 1);
1511
+ import { resolve as resolve4 } from "node:path";
1512
+
1513
+ // src/config.ts
1514
+ import { existsSync, readFileSync as readFileSync2 } from "node:fs";
1515
+ import { resolve } from "node:path";
1516
+
1517
+ // src/utils.ts
1518
+ import { execFileSync, execSync } from "node:child_process";
1519
+ import { readFileSync, writeFileSync } from "node:fs";
1520
+ function exec2(file, args, opts) {
1521
+ return execFileSync(file, args, {
1522
+ cwd: opts?.cwd,
1523
+ stdio: opts?.stdio ?? "pipe",
1524
+ encoding: "utf-8"
1525
+ });
1526
+ }
1527
+ function readJson(path) {
1528
+ return JSON.parse(readFileSync(path, "utf-8"));
1529
+ }
1530
+ function writeJson(path, data) {
1531
+ writeFileSync(path, JSON.stringify(data, null, 2) + `
1532
+ `);
1533
+ }
1534
+ function errorText(err) {
1535
+ if (err instanceof Error) {
1536
+ if ("stderr" in err && typeof err.stderr === "string" && err.stderr.trim())
1537
+ return err.stderr.trim();
1538
+ return err.message;
1539
+ }
1540
+ return String(err);
1541
+ }
1542
+
1543
+ // src/config.ts
1544
+ var DEFAULTS = {
1545
+ packageJsonPaths: [],
1546
+ bumpFiles: [],
1547
+ steps: {
1548
+ preflight: true,
1549
+ changelog: true,
1550
+ bumpVersion: true,
1551
+ commit: true,
1552
+ tag: true,
1553
+ push: true,
1554
+ githubRelease: true,
1555
+ npm: true,
1556
+ homebrew: true
1557
+ },
1558
+ git: {
1559
+ releaseBranch: "main",
1560
+ tagPrefix: "v",
1561
+ commitMessage: "release: {tag}",
1562
+ commitFlags: "--no-verify",
1563
+ pushFlags: "--no-verify"
1564
+ },
1565
+ npm: {
1566
+ cwd: "",
1567
+ access: "public"
1568
+ },
1569
+ homebrew: {
1570
+ tapPath: "",
1571
+ formulaFile: "",
1572
+ repoSlug: "",
1573
+ commitMessage: "{formula}: update to {tag}"
1574
+ }
1575
+ };
1576
+ function mergeConfig(base, user) {
1577
+ return {
1578
+ packageJsonPaths: user.packageJsonPaths ?? base.packageJsonPaths,
1579
+ bumpFiles: user.bumpFiles ?? base.bumpFiles,
1580
+ steps: { ...base.steps, ...user.steps },
1581
+ git: { ...base.git, ...user.git },
1582
+ npm: { ...base.npm, ...user.npm },
1583
+ homebrew: { ...base.homebrew, ...user.homebrew }
1584
+ };
1585
+ }
1586
+ async function loadConfig(root) {
1587
+ let userConfig = {};
1588
+ const candidates = [
1589
+ resolve(root, "shipx.config.ts"),
1590
+ resolve(root, "shipx.config.js"),
1591
+ resolve(root, ".shipxrc.json"),
1592
+ resolve(root, ".shipxrc")
1593
+ ];
1594
+ for (const candidate of candidates) {
1595
+ if (existsSync(candidate)) {
1596
+ if (candidate.endsWith(".ts") || candidate.endsWith(".js")) {
1597
+ const mod = await import(candidate);
1598
+ userConfig = mod.default ?? mod;
1599
+ } else {
1600
+ userConfig = JSON.parse(readFileSync2(candidate, "utf-8"));
1601
+ }
1602
+ break;
1603
+ }
1604
+ }
1605
+ const pkgPath = resolve(root, "package.json");
1606
+ if (!Object.keys(userConfig).length && existsSync(pkgPath)) {
1607
+ const pkg = readJson(pkgPath);
1608
+ if (pkg.shipx && typeof pkg.shipx === "object") {
1609
+ userConfig = pkg.shipx;
1610
+ }
1611
+ }
1612
+ const merged = mergeConfig(DEFAULTS, userConfig);
1613
+ if (!merged.packageJsonPaths.length && existsSync(pkgPath)) {
1614
+ merged.packageJsonPaths = ["package.json"];
1615
+ }
1616
+ if (!merged.npm.cwd) {
1617
+ merged.npm.cwd = root;
1618
+ }
1619
+ if (!merged.homebrew.tapPath) {
1620
+ const siblingTap = resolve(root, "../homebrew-tap");
1621
+ if (existsSync(siblingTap)) {
1622
+ merged.homebrew.tapPath = siblingTap;
1623
+ }
1624
+ }
1625
+ if (merged.homebrew.tapPath && !merged.homebrew.formulaFile && !merged.homebrew.repoSlug) {
1626
+ try {
1627
+ const remote = exec2("git", ["remote", "get-url", "origin"], { cwd: root }).trim();
1628
+ const match = remote.match(/github\.com[:/]([^/]+)\/([^/.]+)/);
1629
+ if (match) {
1630
+ merged.homebrew.repoSlug = `${match[1]}/${match[2]}`;
1631
+ merged.homebrew.formulaFile = `Formula/${match[2]}.rb`;
1632
+ }
1633
+ } catch {}
1634
+ }
1635
+ return { ...merged, root };
1636
+ }
1637
+
1638
+ // src/steps/bump.ts
1639
+ var import_picocolors = __toESM(require_picocolors(), 1);
1640
+ import { existsSync as existsSync2, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "node:fs";
1641
+ import { resolve as resolve2 } from "node:path";
1642
+ function bumpVersionFiles(config, newVersion) {
1643
+ const spinner = ft();
1644
+ spinner.start("Bumping version files");
1645
+ const bumped = [];
1646
+ for (const rel of config.packageJsonPaths) {
1647
+ const abs = resolve2(config.root, rel);
1648
+ if (!existsSync2(abs)) {
1649
+ R2.warn(`package.json not found: ${abs}`);
1650
+ continue;
1651
+ }
1652
+ const pkg = readJson(abs);
1653
+ pkg.version = newVersion;
1654
+ writeJson(abs, pkg);
1655
+ bumped.push(rel);
1656
+ }
1657
+ for (const fileConfig of config.bumpFiles) {
1658
+ const abs = resolve2(config.root, fileConfig.path);
1659
+ if (!existsSync2(abs)) {
1660
+ R2.warn(`File not found: ${abs}`);
1661
+ continue;
1662
+ }
1663
+ const content = readFileSync3(abs, "utf-8");
1664
+ const updated = content.replace(fileConfig.pattern, fileConfig.replacement(newVersion));
1665
+ writeFileSync2(abs, updated);
1666
+ bumped.push(fileConfig.path);
1667
+ }
1668
+ const fileList = bumped.map((f) => import_picocolors.default.cyan(f)).join(", ");
1669
+ spinner.stop(`Bumped ${fileList} → ${import_picocolors.default.green(newVersion)}`);
1670
+ }
1671
+ function getFilesToStage(config) {
1672
+ const files = [...config.packageJsonPaths];
1673
+ for (const f of config.bumpFiles) {
1674
+ files.push(f.path);
1675
+ }
1676
+ return files;
1677
+ }
1678
+
1679
+ // src/steps/changelog.ts
1680
+ function generateChangelog(config, tag) {
1681
+ let lastTag = "";
1682
+ try {
1683
+ lastTag = exec2("git", ["describe", "--tags", "--abbrev=0"], { cwd: config.root }).trim();
1684
+ } catch {}
1685
+ let changelog = "";
1686
+ if (lastTag) {
1687
+ changelog = exec2("git", ["log", `${lastTag}..HEAD`, "--pretty=format:- %s (%h)", "--no-merges"], { cwd: config.root }).trim();
1688
+ }
1689
+ if (!changelog)
1690
+ changelog = `- Release ${tag}`;
1691
+ Se(changelog, "Changelog");
1692
+ return changelog;
1693
+ }
1694
+
1695
+ // src/steps/github.ts
1696
+ var import_picocolors2 = __toESM(require_picocolors(), 1);
1697
+ function createGithubRelease(config, tag, changelog, isBeta) {
1698
+ const spinner = ft();
1699
+ spinner.start("Creating GitHub release");
1700
+ const releaseNotes = `## Changes
1701
+
1702
+ ${changelog}`;
1703
+ try {
1704
+ exec2("gh", [
1705
+ "release",
1706
+ "create",
1707
+ tag,
1708
+ "--title",
1709
+ tag,
1710
+ "--notes",
1711
+ releaseNotes,
1712
+ ...isBeta ? ["--prerelease"] : []
1713
+ ], { cwd: config.root });
1714
+ spinner.stop("GitHub release created");
1715
+ } catch (err) {
1716
+ spinner.stop(import_picocolors2.default.red("GitHub release failed"));
1717
+ R2.error(errorText(err));
1718
+ }
1719
+ }
1720
+
1721
+ // src/steps/git.ts
1722
+ var import_picocolors3 = __toESM(require_picocolors(), 1);
1723
+ function splitFlags(flags) {
1724
+ return flags.split(/\s+/).filter(Boolean);
1725
+ }
1726
+ function commitAndTag(config, tag, filesToStage) {
1727
+ const spinner = ft();
1728
+ spinner.start("Committing and tagging");
1729
+ if (filesToStage.length > 0) {
1730
+ exec2("git", ["add", ...filesToStage], { cwd: config.root });
1731
+ }
1732
+ const message = config.git.commitMessage.replace(/\{tag\}/g, tag);
1733
+ exec2("git", ["commit", "-m", message, ...splitFlags(config.git.commitFlags)], { cwd: config.root });
1734
+ exec2("git", ["tag", tag], { cwd: config.root });
1735
+ spinner.stop(`Committed and tagged ${import_picocolors3.default.green(tag)}`);
1736
+ }
1737
+ function pushChanges(config, branch, tag) {
1738
+ const spinner = ft();
1739
+ spinner.start("Pushing to GitHub");
1740
+ exec2("git", ["push", "origin", branch, ...splitFlags(config.git.pushFlags)], { cwd: config.root });
1741
+ exec2("git", ["push", "origin", tag], { cwd: config.root });
1742
+ spinner.stop("Pushed to GitHub");
1743
+ }
1744
+
1745
+ // src/steps/homebrew.ts
1746
+ var import_picocolors4 = __toESM(require_picocolors(), 1);
1747
+ import { createHash } from "node:crypto";
1748
+ import { execFileSync as execFileSync2 } from "node:child_process";
1749
+ import { existsSync as existsSync3, readFileSync as readFileSync4, writeFileSync as writeFileSync3 } from "node:fs";
1750
+ import { resolve as resolve3 } from "node:path";
1751
+ async function publishHomebrew(config, tag) {
1752
+ const { tapPath, formulaFile, repoSlug, commitMessage } = config.homebrew;
1753
+ if (!tapPath || !formulaFile || !repoSlug) {
1754
+ R2.warn("Homebrew config incomplete (tapPath, formulaFile, repoSlug required). Skipping.");
1755
+ return;
1756
+ }
1757
+ const formulaPath = resolve3(tapPath, formulaFile);
1758
+ if (!existsSync3(formulaPath)) {
1759
+ R2.warn(`Homebrew formula not found at ${import_picocolors4.default.dim(formulaPath)}. Skipping.`);
1760
+ return;
1761
+ }
1762
+ const doHomebrew = await ue({
1763
+ message: "Update Homebrew formula?",
1764
+ initialValue: true
1765
+ });
1766
+ if (q(doHomebrew) || !doHomebrew) {
1767
+ R2.info("Skipping Homebrew");
1768
+ return;
1769
+ }
1770
+ const spinner = ft();
1771
+ spinner.start("Updating Homebrew formula");
1772
+ try {
1773
+ exec2("git", ["checkout", "main"], { cwd: tapPath });
1774
+ exec2("git", ["pull", "--rebase", "origin", "main"], { cwd: tapPath });
1775
+ const tarballUrl = `https://github.com/${repoSlug}/archive/refs/tags/${tag}.tar.gz`;
1776
+ const tarball = execFileSync2("curl", ["-sL", tarballUrl]);
1777
+ const sha256 = createHash("sha256").update(tarball).digest("hex");
1778
+ if (!sha256 || sha256.length !== 64) {
1779
+ spinner.stop(import_picocolors4.default.red("Failed to compute SHA256"));
1780
+ R2.error(`Got: ${sha256}`);
1781
+ return;
1782
+ }
1783
+ let formula = readFileSync4(formulaPath, "utf-8");
1784
+ formula = formula.replace(/url "https:\/\/github\.com\/[^/]+\/[^/]+\/archive\/refs\/tags\/[^"]+\.tar\.gz"/, `url "${tarballUrl}"`);
1785
+ formula = formula.replace(/sha256 "[a-f0-9]+"/, `sha256 "${sha256}"`);
1786
+ writeFileSync3(formulaPath, formula);
1787
+ const formulaName = formulaFile.replace(/^Formula\//, "").replace(/\.rb$/, "");
1788
+ exec2("git", ["add", formulaFile], { cwd: tapPath });
1789
+ const msg = commitMessage.replace(/\{tag\}/g, tag).replace(/\{formula\}/g, formulaName);
1790
+ exec2("git", ["commit", "-m", msg], { cwd: tapPath });
1791
+ exec2("git", ["push"], { cwd: tapPath });
1792
+ spinner.stop(`Homebrew formula updated to ${import_picocolors4.default.green(tag)}`);
1793
+ } catch (err) {
1794
+ spinner.stop(import_picocolors4.default.red("Homebrew update failed"));
1795
+ R2.error(errorText(err));
1796
+ R2.info(`Update manually: ${import_picocolors4.default.cyan(`edit ${formulaPath}`)}`);
1797
+ }
1798
+ }
1799
+
1800
+ // src/steps/npm.ts
1801
+ var import_picocolors5 = __toESM(require_picocolors(), 1);
1802
+ async function publishNpm(config, isBeta) {
1803
+ const { cwd, access } = config.npm;
1804
+ const baseArgs = ["publish", "--access", access, ...isBeta ? ["--tag", "beta"] : []];
1805
+ const spinner = ft();
1806
+ spinner.start(`Publishing to npm${isBeta ? " (beta)" : ""}`);
1807
+ try {
1808
+ exec2("npm", baseArgs, { cwd });
1809
+ spinner.stop(import_picocolors5.default.green(`Published to npm${isBeta ? " (beta)" : ""}`));
1810
+ return true;
1811
+ } catch (err) {
1812
+ spinner.stop(import_picocolors5.default.yellow("npm publish failed"));
1813
+ R2.message(import_picocolors5.default.dim(errorText(err)));
1814
+ }
1815
+ while (true) {
1816
+ const action = await Ee({
1817
+ message: "How would you like to proceed?",
1818
+ options: [
1819
+ { value: "otp", label: "Enter OTP", hint: "publish with one-time password" },
1820
+ { value: "login", label: "Log in to npm", hint: "run npm login, then retry" },
1821
+ { value: "retry", label: "Retry publish", hint: "try again without OTP" },
1822
+ { value: "skip", label: "Skip npm publish", hint: "continue to next step" }
1823
+ ]
1824
+ });
1825
+ if (q(action) || action === "skip") {
1826
+ R2.info("Skipping npm publish");
1827
+ return false;
1828
+ }
1829
+ if (action === "login") {
1830
+ R2.info("Running npm login...");
1831
+ try {
1832
+ exec2("npm", ["login"], { cwd, stdio: "inherit" });
1833
+ R2.success("Logged in to npm");
1834
+ } catch {
1835
+ R2.error("npm login failed");
1836
+ }
1837
+ continue;
1838
+ }
1839
+ const retryArgs = [...baseArgs];
1840
+ if (action === "otp") {
1841
+ const otp = await Re({
1842
+ message: "npm OTP",
1843
+ placeholder: "123456",
1844
+ validate: (v2) => {
1845
+ if (!v2 || !/^\d{6}$/.test(v2.trim()))
1846
+ return "OTP must be 6 digits";
1847
+ }
1848
+ });
1849
+ if (q(otp))
1850
+ continue;
1851
+ retryArgs.push("--otp", otp.trim());
1852
+ }
1853
+ const retrySpinner = ft();
1854
+ retrySpinner.start("Publishing to npm");
1855
+ try {
1856
+ exec2("npm", retryArgs, { cwd });
1857
+ retrySpinner.stop(import_picocolors5.default.green("Published to npm"));
1858
+ return true;
1859
+ } catch (err) {
1860
+ retrySpinner.stop(import_picocolors5.default.red("npm publish failed"));
1861
+ R2.message(import_picocolors5.default.dim(errorText(err)));
1862
+ }
1863
+ }
1864
+ }
1865
+
1866
+ // src/steps/preflight.ts
1867
+ var import_picocolors6 = __toESM(require_picocolors(), 1);
1868
+ function runPreflight(config, isBeta) {
1869
+ const spinner = ft();
1870
+ spinner.start("Running preflight checks");
1871
+ const status = exec2("git", ["status", "--porcelain"], { cwd: config.root }).trim();
1872
+ if (status) {
1873
+ spinner.stop(import_picocolors6.default.red("Working tree is not clean"));
1874
+ R2.error("Commit or stash changes first:");
1875
+ console.log(import_picocolors6.default.dim(status));
1876
+ process.exit(1);
1877
+ }
1878
+ const branch = exec2("git", ["branch", "--show-current"], { cwd: config.root }).trim();
1879
+ if (!isBeta && branch !== config.git.releaseBranch) {
1880
+ spinner.stop(import_picocolors6.default.red(`On branch '${branch}', not '${config.git.releaseBranch}'`));
1881
+ process.exit(1);
1882
+ }
1883
+ spinner.stop("Preflight OK");
1884
+ return branch;
1885
+ }
1886
+
1887
+ // src/steps/version.ts
1888
+ var import_picocolors7 = __toESM(require_picocolors(), 1);
1889
+ function bumpVersion(current, type) {
1890
+ const base = current.replace(/-.*$/, "");
1891
+ const [major, minor, patch] = base.split(".").map(Number);
1892
+ switch (type) {
1893
+ case "major":
1894
+ return `${major + 1}.0.0`;
1895
+ case "minor":
1896
+ return `${major}.${minor + 1}.0`;
1897
+ case "patch":
1898
+ return `${major}.${minor}.${patch + 1}`;
1899
+ }
1900
+ }
1901
+ function bumpBeta(current, bumpType) {
1902
+ const betaMatch = current.match(/^(.+)-beta\.(\d+)$/);
1903
+ if (betaMatch) {
1904
+ return `${betaMatch[1]}-beta.${Number(betaMatch[2]) + 1}`;
1905
+ }
1906
+ return `${bumpVersion(current, bumpType)}-beta.0`;
1907
+ }
1908
+ async function pickVersion(currentVersion, argVersion, isBeta) {
1909
+ if (isBeta) {
1910
+ return pickBetaVersion(currentVersion, argVersion);
1911
+ }
1912
+ if (argVersion === "patch" || argVersion === "minor" || argVersion === "major") {
1913
+ return bumpVersion(currentVersion, argVersion);
1914
+ }
1915
+ if (argVersion && /^\d+\.\d+\.\d+/.test(argVersion)) {
1916
+ return argVersion;
1917
+ }
1918
+ const selected = await Ee({
1919
+ message: `Current version: ${import_picocolors7.default.cyan(currentVersion)}. Bump type?`,
1920
+ options: [
1921
+ {
1922
+ value: "patch",
1923
+ label: "patch",
1924
+ hint: `${currentVersion} → ${bumpVersion(currentVersion, "patch")}`
1925
+ },
1926
+ {
1927
+ value: "minor",
1928
+ label: "minor",
1929
+ hint: `${currentVersion} → ${bumpVersion(currentVersion, "minor")}`
1930
+ },
1931
+ {
1932
+ value: "major",
1933
+ label: "major",
1934
+ hint: `${currentVersion} → ${bumpVersion(currentVersion, "major")}`
1935
+ }
1936
+ ]
1937
+ });
1938
+ if (q(selected)) {
1939
+ me("Release cancelled.");
1940
+ process.exit(0);
1941
+ }
1942
+ return bumpVersion(currentVersion, selected);
1943
+ }
1944
+ async function pickBetaVersion(currentVersion, argVersion) {
1945
+ const isAlreadyBeta = /-beta\.\d+$/.test(currentVersion);
1946
+ if (isAlreadyBeta) {
1947
+ const selected2 = await Ee({
1948
+ message: `Current version: ${import_picocolors7.default.cyan(currentVersion)}. Beta bump?`,
1949
+ options: [
1950
+ {
1951
+ value: "next",
1952
+ label: "next beta",
1953
+ hint: `${currentVersion} → ${bumpBeta(currentVersion, "patch")}`
1954
+ },
1955
+ {
1956
+ value: "patch",
1957
+ label: "new patch beta",
1958
+ hint: `${currentVersion} → ${bumpVersion(currentVersion, "patch")}-beta.0`
1959
+ },
1960
+ {
1961
+ value: "minor",
1962
+ label: "new minor beta",
1963
+ hint: `${currentVersion} → ${bumpVersion(currentVersion, "minor")}-beta.0`
1964
+ },
1965
+ {
1966
+ value: "major",
1967
+ label: "new major beta",
1968
+ hint: `${currentVersion} → ${bumpVersion(currentVersion, "major")}-beta.0`
1969
+ }
1970
+ ]
1971
+ });
1972
+ if (q(selected2)) {
1973
+ me("Release cancelled.");
1974
+ process.exit(0);
1975
+ }
1976
+ return selected2 === "next" ? bumpBeta(currentVersion, "patch") : `${bumpVersion(currentVersion, selected2)}-beta.0`;
1977
+ }
1978
+ if (argVersion === "patch" || argVersion === "minor" || argVersion === "major") {
1979
+ return bumpBeta(currentVersion, argVersion);
1980
+ }
1981
+ const selected = await Ee({
1982
+ message: `Current version: ${import_picocolors7.default.cyan(currentVersion)}. Bump type for beta?`,
1983
+ options: [
1984
+ {
1985
+ value: "patch",
1986
+ label: "patch",
1987
+ hint: `${currentVersion} → ${bumpBeta(currentVersion, "patch")}`
1988
+ },
1989
+ {
1990
+ value: "minor",
1991
+ label: "minor",
1992
+ hint: `${currentVersion} → ${bumpBeta(currentVersion, "minor")}`
1993
+ },
1994
+ {
1995
+ value: "major",
1996
+ label: "major",
1997
+ hint: `${currentVersion} → ${bumpBeta(currentVersion, "major")}`
1998
+ }
1999
+ ]
2000
+ });
2001
+ if (q(selected)) {
2002
+ me("Release cancelled.");
2003
+ process.exit(0);
2004
+ }
2005
+ return bumpBeta(currentVersion, selected);
2006
+ }
2007
+
2008
+ // src/cli.ts
2009
+ async function main(argv = process.argv.slice(2)) {
2010
+ const isBeta = argv.includes("--beta");
2011
+ const args = argv.filter((a) => a !== "--beta");
2012
+ const root = process.env.SHIPX_ROOT ?? process.cwd();
2013
+ const config = await loadConfig(root);
2014
+ if (process.stdout.isTTY) {
2015
+ console.clear();
2016
+ }
2017
+ ge(import_picocolors8.default.magenta(import_picocolors8.default.bold(isBeta ? " shipx — Beta Release " : " shipx — Release ")));
2018
+ let branch = "main";
2019
+ if (config.steps.preflight) {
2020
+ branch = runPreflight(config, isBeta);
2021
+ }
2022
+ const pkgJsonPaths = config.packageJsonPaths.map((rel) => resolve4(root, rel));
2023
+ if (!pkgJsonPaths.length) {
2024
+ R2.error("No packageJsonPaths configured. Add them to shipx.config.ts or package.json.");
2025
+ process.exit(1);
2026
+ }
2027
+ const rootPkg = readJson(pkgJsonPaths[0]);
2028
+ const currentVersion = rootPkg.version;
2029
+ const newVersion = await pickVersion(currentVersion, args[0], isBeta);
2030
+ const tag = `${config.git.tagPrefix}${newVersion}`;
2031
+ const proceed = await ue({
2032
+ message: `Release ${import_picocolors8.default.cyan(currentVersion)} → ${import_picocolors8.default.green(newVersion)} (${tag})?`
2033
+ });
2034
+ if (q(proceed) || !proceed) {
2035
+ me("Release cancelled.");
2036
+ process.exit(0);
2037
+ }
2038
+ if (config.steps.bumpVersion) {
2039
+ bumpVersionFiles(config, newVersion);
2040
+ }
2041
+ let changelog = `- Release ${tag}`;
2042
+ if (config.steps.changelog) {
2043
+ changelog = generateChangelog(config, tag);
2044
+ }
2045
+ if (config.steps.commit || config.steps.tag) {
2046
+ const filesToStage = getFilesToStage(config);
2047
+ commitAndTag(config, tag, filesToStage);
2048
+ }
2049
+ if (config.steps.push) {
2050
+ pushChanges(config, branch, tag);
2051
+ }
2052
+ if (config.steps.githubRelease) {
2053
+ createGithubRelease(config, tag, changelog, isBeta);
2054
+ }
2055
+ if (config.steps.npm) {
2056
+ await publishNpm(config, isBeta);
2057
+ }
2058
+ if (config.steps.homebrew && !isBeta) {
2059
+ await publishHomebrew(config, tag);
2060
+ } else if (isBeta && config.steps.homebrew) {
2061
+ R2.info("Skipping Homebrew for beta release");
2062
+ }
2063
+ let releaseUrl = `${tag}`;
2064
+ try {
2065
+ const remote = exec2("git", ["remote", "get-url", "origin"], { cwd: root }).trim();
2066
+ const match = remote.match(/github\.com[:/]([^/]+\/[^/.]+)/);
2067
+ if (match) {
2068
+ const slug = match[1].replace(/\.git$/, "");
2069
+ releaseUrl = `https://github.com/${slug}/releases/tag/${tag}`;
2070
+ }
2071
+ } catch {}
2072
+ ye(`${import_picocolors8.default.green("✓")} Released ${import_picocolors8.default.green(tag)} — ${import_picocolors8.default.cyan(releaseUrl)}`);
2073
+ }
2074
+ main().catch((err) => {
2075
+ console.error(err?.message ?? err);
2076
+ process.exit(1);
2077
+ });