spawnpack 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.
- package/LICENSE +21 -0
- package/README.md +130 -0
- package/bin/spawnpack.js +3 -0
- package/dist/spawnpack.js +2724 -0
- package/package.json +55 -0
- package/templates/CLAUDE.md +802 -0
|
@@ -0,0 +1,2724 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
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 y } from "node:util";
|
|
164
|
+
import { stdout as S, stdin as $ } from "node:process";
|
|
165
|
+
import * as _ from "node:readline";
|
|
166
|
+
import P from "node:readline";
|
|
167
|
+
|
|
168
|
+
// node_modules/fast-string-truncated-width/dist/utils.js
|
|
169
|
+
var isAmbiguous = (x) => {
|
|
170
|
+
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;
|
|
171
|
+
};
|
|
172
|
+
var isFullWidth = (x) => {
|
|
173
|
+
return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
|
|
174
|
+
};
|
|
175
|
+
var isWide = (x) => {
|
|
176
|
+
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;
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
// node_modules/fast-string-truncated-width/dist/index.js
|
|
180
|
+
var ANSI_RE = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y;
|
|
181
|
+
var CONTROL_RE = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
|
|
182
|
+
var TAB_RE = /\t{1,1000}/y;
|
|
183
|
+
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;
|
|
184
|
+
var LATIN_RE = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
|
|
185
|
+
var MODIFIER_RE = /\p{M}+/gu;
|
|
186
|
+
var NO_TRUNCATION = { limit: Infinity, ellipsis: "" };
|
|
187
|
+
var getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {}) => {
|
|
188
|
+
const LIMIT = truncationOptions.limit ?? Infinity;
|
|
189
|
+
const ELLIPSIS = truncationOptions.ellipsis ?? "";
|
|
190
|
+
const ELLIPSIS_WIDTH = truncationOptions?.ellipsisWidth ?? (ELLIPSIS ? getStringTruncatedWidth(ELLIPSIS, NO_TRUNCATION, widthOptions).width : 0);
|
|
191
|
+
const ANSI_WIDTH = widthOptions.ansiWidth ?? 0;
|
|
192
|
+
const CONTROL_WIDTH = widthOptions.controlWidth ?? 0;
|
|
193
|
+
const TAB_WIDTH = widthOptions.tabWidth ?? 8;
|
|
194
|
+
const AMBIGUOUS_WIDTH = widthOptions.ambiguousWidth ?? 1;
|
|
195
|
+
const EMOJI_WIDTH = widthOptions.emojiWidth ?? 2;
|
|
196
|
+
const FULL_WIDTH_WIDTH = widthOptions.fullWidthWidth ?? 2;
|
|
197
|
+
const REGULAR_WIDTH = widthOptions.regularWidth ?? 1;
|
|
198
|
+
const WIDE_WIDTH = widthOptions.wideWidth ?? 2;
|
|
199
|
+
let indexPrev = 0;
|
|
200
|
+
let index = 0;
|
|
201
|
+
let length = input.length;
|
|
202
|
+
let lengthExtra = 0;
|
|
203
|
+
let truncationEnabled = false;
|
|
204
|
+
let truncationIndex = length;
|
|
205
|
+
let truncationLimit = Math.max(0, LIMIT - ELLIPSIS_WIDTH);
|
|
206
|
+
let unmatchedStart = 0;
|
|
207
|
+
let unmatchedEnd = 0;
|
|
208
|
+
let width = 0;
|
|
209
|
+
let widthExtra = 0;
|
|
210
|
+
outer:
|
|
211
|
+
while (true) {
|
|
212
|
+
if (unmatchedEnd > unmatchedStart || index >= length && index > indexPrev) {
|
|
213
|
+
const unmatched = input.slice(unmatchedStart, unmatchedEnd) || input.slice(indexPrev, index);
|
|
214
|
+
lengthExtra = 0;
|
|
215
|
+
for (const char of unmatched.replaceAll(MODIFIER_RE, "")) {
|
|
216
|
+
const codePoint = char.codePointAt(0) || 0;
|
|
217
|
+
if (isFullWidth(codePoint)) {
|
|
218
|
+
widthExtra = FULL_WIDTH_WIDTH;
|
|
219
|
+
} else if (isWide(codePoint)) {
|
|
220
|
+
widthExtra = WIDE_WIDTH;
|
|
221
|
+
} else if (AMBIGUOUS_WIDTH !== REGULAR_WIDTH && isAmbiguous(codePoint)) {
|
|
222
|
+
widthExtra = AMBIGUOUS_WIDTH;
|
|
223
|
+
} else {
|
|
224
|
+
widthExtra = REGULAR_WIDTH;
|
|
225
|
+
}
|
|
226
|
+
if (width + widthExtra > truncationLimit) {
|
|
227
|
+
truncationIndex = Math.min(truncationIndex, Math.max(unmatchedStart, indexPrev) + lengthExtra);
|
|
228
|
+
}
|
|
229
|
+
if (width + widthExtra > LIMIT) {
|
|
230
|
+
truncationEnabled = true;
|
|
231
|
+
break outer;
|
|
232
|
+
}
|
|
233
|
+
lengthExtra += char.length;
|
|
234
|
+
width += widthExtra;
|
|
235
|
+
}
|
|
236
|
+
unmatchedStart = unmatchedEnd = 0;
|
|
237
|
+
}
|
|
238
|
+
if (index >= length)
|
|
239
|
+
break;
|
|
240
|
+
LATIN_RE.lastIndex = index;
|
|
241
|
+
if (LATIN_RE.test(input)) {
|
|
242
|
+
lengthExtra = LATIN_RE.lastIndex - index;
|
|
243
|
+
widthExtra = lengthExtra * REGULAR_WIDTH;
|
|
244
|
+
if (width + widthExtra > truncationLimit) {
|
|
245
|
+
truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / REGULAR_WIDTH));
|
|
246
|
+
}
|
|
247
|
+
if (width + widthExtra > LIMIT) {
|
|
248
|
+
truncationEnabled = true;
|
|
249
|
+
break;
|
|
250
|
+
}
|
|
251
|
+
width += widthExtra;
|
|
252
|
+
unmatchedStart = indexPrev;
|
|
253
|
+
unmatchedEnd = index;
|
|
254
|
+
index = indexPrev = LATIN_RE.lastIndex;
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
257
|
+
ANSI_RE.lastIndex = index;
|
|
258
|
+
if (ANSI_RE.test(input)) {
|
|
259
|
+
if (width + ANSI_WIDTH > truncationLimit) {
|
|
260
|
+
truncationIndex = Math.min(truncationIndex, index);
|
|
261
|
+
}
|
|
262
|
+
if (width + ANSI_WIDTH > LIMIT) {
|
|
263
|
+
truncationEnabled = true;
|
|
264
|
+
break;
|
|
265
|
+
}
|
|
266
|
+
width += ANSI_WIDTH;
|
|
267
|
+
unmatchedStart = indexPrev;
|
|
268
|
+
unmatchedEnd = index;
|
|
269
|
+
index = indexPrev = ANSI_RE.lastIndex;
|
|
270
|
+
continue;
|
|
271
|
+
}
|
|
272
|
+
CONTROL_RE.lastIndex = index;
|
|
273
|
+
if (CONTROL_RE.test(input)) {
|
|
274
|
+
lengthExtra = CONTROL_RE.lastIndex - index;
|
|
275
|
+
widthExtra = lengthExtra * CONTROL_WIDTH;
|
|
276
|
+
if (width + widthExtra > truncationLimit) {
|
|
277
|
+
truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / CONTROL_WIDTH));
|
|
278
|
+
}
|
|
279
|
+
if (width + widthExtra > LIMIT) {
|
|
280
|
+
truncationEnabled = true;
|
|
281
|
+
break;
|
|
282
|
+
}
|
|
283
|
+
width += widthExtra;
|
|
284
|
+
unmatchedStart = indexPrev;
|
|
285
|
+
unmatchedEnd = index;
|
|
286
|
+
index = indexPrev = CONTROL_RE.lastIndex;
|
|
287
|
+
continue;
|
|
288
|
+
}
|
|
289
|
+
TAB_RE.lastIndex = index;
|
|
290
|
+
if (TAB_RE.test(input)) {
|
|
291
|
+
lengthExtra = TAB_RE.lastIndex - index;
|
|
292
|
+
widthExtra = lengthExtra * TAB_WIDTH;
|
|
293
|
+
if (width + widthExtra > truncationLimit) {
|
|
294
|
+
truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / TAB_WIDTH));
|
|
295
|
+
}
|
|
296
|
+
if (width + widthExtra > LIMIT) {
|
|
297
|
+
truncationEnabled = true;
|
|
298
|
+
break;
|
|
299
|
+
}
|
|
300
|
+
width += widthExtra;
|
|
301
|
+
unmatchedStart = indexPrev;
|
|
302
|
+
unmatchedEnd = index;
|
|
303
|
+
index = indexPrev = TAB_RE.lastIndex;
|
|
304
|
+
continue;
|
|
305
|
+
}
|
|
306
|
+
EMOJI_RE.lastIndex = index;
|
|
307
|
+
if (EMOJI_RE.test(input)) {
|
|
308
|
+
if (width + EMOJI_WIDTH > truncationLimit) {
|
|
309
|
+
truncationIndex = Math.min(truncationIndex, index);
|
|
310
|
+
}
|
|
311
|
+
if (width + EMOJI_WIDTH > LIMIT) {
|
|
312
|
+
truncationEnabled = true;
|
|
313
|
+
break;
|
|
314
|
+
}
|
|
315
|
+
width += EMOJI_WIDTH;
|
|
316
|
+
unmatchedStart = indexPrev;
|
|
317
|
+
unmatchedEnd = index;
|
|
318
|
+
index = indexPrev = EMOJI_RE.lastIndex;
|
|
319
|
+
continue;
|
|
320
|
+
}
|
|
321
|
+
index += 1;
|
|
322
|
+
}
|
|
323
|
+
return {
|
|
324
|
+
width: truncationEnabled ? truncationLimit : width,
|
|
325
|
+
index: truncationEnabled ? truncationIndex : length,
|
|
326
|
+
truncated: truncationEnabled,
|
|
327
|
+
ellipsed: truncationEnabled && LIMIT >= ELLIPSIS_WIDTH
|
|
328
|
+
};
|
|
329
|
+
};
|
|
330
|
+
var dist_default = getStringTruncatedWidth;
|
|
331
|
+
|
|
332
|
+
// node_modules/fast-string-width/dist/index.js
|
|
333
|
+
var NO_TRUNCATION2 = {
|
|
334
|
+
limit: Infinity,
|
|
335
|
+
ellipsis: "",
|
|
336
|
+
ellipsisWidth: 0
|
|
337
|
+
};
|
|
338
|
+
var fastStringWidth = (input, options = {}) => {
|
|
339
|
+
return dist_default(input, NO_TRUNCATION2, options).width;
|
|
340
|
+
};
|
|
341
|
+
var dist_default2 = fastStringWidth;
|
|
342
|
+
|
|
343
|
+
// node_modules/fast-wrap-ansi/lib/main.js
|
|
344
|
+
var ESC = "\x1B";
|
|
345
|
+
var CSI = "";
|
|
346
|
+
var END_CODE = 39;
|
|
347
|
+
var ANSI_ESCAPE_BELL = "\x07";
|
|
348
|
+
var ANSI_CSI = "[";
|
|
349
|
+
var ANSI_OSC = "]";
|
|
350
|
+
var ANSI_SGR_TERMINATOR = "m";
|
|
351
|
+
var ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
|
|
352
|
+
var GROUP_REGEX = new RegExp(`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`, "y");
|
|
353
|
+
var getClosingCode = (openingCode) => {
|
|
354
|
+
if (openingCode >= 30 && openingCode <= 37)
|
|
355
|
+
return 39;
|
|
356
|
+
if (openingCode >= 90 && openingCode <= 97)
|
|
357
|
+
return 39;
|
|
358
|
+
if (openingCode >= 40 && openingCode <= 47)
|
|
359
|
+
return 49;
|
|
360
|
+
if (openingCode >= 100 && openingCode <= 107)
|
|
361
|
+
return 49;
|
|
362
|
+
if (openingCode === 1 || openingCode === 2)
|
|
363
|
+
return 22;
|
|
364
|
+
if (openingCode === 3)
|
|
365
|
+
return 23;
|
|
366
|
+
if (openingCode === 4)
|
|
367
|
+
return 24;
|
|
368
|
+
if (openingCode === 7)
|
|
369
|
+
return 27;
|
|
370
|
+
if (openingCode === 8)
|
|
371
|
+
return 28;
|
|
372
|
+
if (openingCode === 9)
|
|
373
|
+
return 29;
|
|
374
|
+
if (openingCode === 0)
|
|
375
|
+
return 0;
|
|
376
|
+
return;
|
|
377
|
+
};
|
|
378
|
+
var wrapAnsiCode = (code) => `${ESC}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
|
|
379
|
+
var wrapAnsiHyperlink = (url) => `${ESC}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`;
|
|
380
|
+
var wrapWord = (rows, word, columns) => {
|
|
381
|
+
const characters = word[Symbol.iterator]();
|
|
382
|
+
let isInsideEscape = false;
|
|
383
|
+
let isInsideLinkEscape = false;
|
|
384
|
+
let lastRow = rows.at(-1);
|
|
385
|
+
let visible = lastRow === undefined ? 0 : dist_default2(lastRow);
|
|
386
|
+
let currentCharacter = characters.next();
|
|
387
|
+
let nextCharacter = characters.next();
|
|
388
|
+
let rawCharacterIndex = 0;
|
|
389
|
+
while (!currentCharacter.done) {
|
|
390
|
+
const character = currentCharacter.value;
|
|
391
|
+
const characterLength = dist_default2(character);
|
|
392
|
+
if (visible + characterLength <= columns) {
|
|
393
|
+
rows[rows.length - 1] += character;
|
|
394
|
+
} else {
|
|
395
|
+
rows.push(character);
|
|
396
|
+
visible = 0;
|
|
397
|
+
}
|
|
398
|
+
if (character === ESC || character === CSI) {
|
|
399
|
+
isInsideEscape = true;
|
|
400
|
+
isInsideLinkEscape = word.startsWith(ANSI_ESCAPE_LINK, rawCharacterIndex + 1);
|
|
401
|
+
}
|
|
402
|
+
if (isInsideEscape) {
|
|
403
|
+
if (isInsideLinkEscape) {
|
|
404
|
+
if (character === ANSI_ESCAPE_BELL) {
|
|
405
|
+
isInsideEscape = false;
|
|
406
|
+
isInsideLinkEscape = false;
|
|
407
|
+
}
|
|
408
|
+
} else if (character === ANSI_SGR_TERMINATOR) {
|
|
409
|
+
isInsideEscape = false;
|
|
410
|
+
}
|
|
411
|
+
} else {
|
|
412
|
+
visible += characterLength;
|
|
413
|
+
if (visible === columns && !nextCharacter.done) {
|
|
414
|
+
rows.push("");
|
|
415
|
+
visible = 0;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
currentCharacter = nextCharacter;
|
|
419
|
+
nextCharacter = characters.next();
|
|
420
|
+
rawCharacterIndex += character.length;
|
|
421
|
+
}
|
|
422
|
+
lastRow = rows.at(-1);
|
|
423
|
+
if (!visible && lastRow !== undefined && lastRow.length && rows.length > 1) {
|
|
424
|
+
rows[rows.length - 2] += rows.pop();
|
|
425
|
+
}
|
|
426
|
+
};
|
|
427
|
+
var stringVisibleTrimSpacesRight = (string) => {
|
|
428
|
+
const words = string.split(" ");
|
|
429
|
+
let last = words.length;
|
|
430
|
+
while (last) {
|
|
431
|
+
if (dist_default2(words[last - 1])) {
|
|
432
|
+
break;
|
|
433
|
+
}
|
|
434
|
+
last--;
|
|
435
|
+
}
|
|
436
|
+
if (last === words.length) {
|
|
437
|
+
return string;
|
|
438
|
+
}
|
|
439
|
+
return words.slice(0, last).join(" ") + words.slice(last).join("");
|
|
440
|
+
};
|
|
441
|
+
var exec = (string, columns, options = {}) => {
|
|
442
|
+
if (options.trim !== false && string.trim() === "") {
|
|
443
|
+
return "";
|
|
444
|
+
}
|
|
445
|
+
let returnValue = "";
|
|
446
|
+
let escapeCode;
|
|
447
|
+
let escapeUrl;
|
|
448
|
+
const words = string.split(" ");
|
|
449
|
+
let rows = [""];
|
|
450
|
+
let rowLength = 0;
|
|
451
|
+
for (let index = 0;index < words.length; index++) {
|
|
452
|
+
const word = words[index];
|
|
453
|
+
if (options.trim !== false) {
|
|
454
|
+
const row = rows.at(-1) ?? "";
|
|
455
|
+
const trimmed = row.trimStart();
|
|
456
|
+
if (row.length !== trimmed.length) {
|
|
457
|
+
rows[rows.length - 1] = trimmed;
|
|
458
|
+
rowLength = dist_default2(trimmed);
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
if (index !== 0) {
|
|
462
|
+
if (rowLength >= columns && (options.wordWrap === false || options.trim === false)) {
|
|
463
|
+
rows.push("");
|
|
464
|
+
rowLength = 0;
|
|
465
|
+
}
|
|
466
|
+
if (rowLength || options.trim === false) {
|
|
467
|
+
rows[rows.length - 1] += " ";
|
|
468
|
+
rowLength++;
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
const wordLength = dist_default2(word);
|
|
472
|
+
if (options.hard && wordLength > columns) {
|
|
473
|
+
const remainingColumns = columns - rowLength;
|
|
474
|
+
const breaksStartingThisLine = 1 + Math.floor((wordLength - remainingColumns - 1) / columns);
|
|
475
|
+
const breaksStartingNextLine = Math.floor((wordLength - 1) / columns);
|
|
476
|
+
if (breaksStartingNextLine < breaksStartingThisLine) {
|
|
477
|
+
rows.push("");
|
|
478
|
+
}
|
|
479
|
+
wrapWord(rows, word, columns);
|
|
480
|
+
rowLength = dist_default2(rows.at(-1) ?? "");
|
|
481
|
+
continue;
|
|
482
|
+
}
|
|
483
|
+
if (rowLength + wordLength > columns && rowLength && wordLength) {
|
|
484
|
+
if (options.wordWrap === false && rowLength < columns) {
|
|
485
|
+
wrapWord(rows, word, columns);
|
|
486
|
+
rowLength = dist_default2(rows.at(-1) ?? "");
|
|
487
|
+
continue;
|
|
488
|
+
}
|
|
489
|
+
rows.push("");
|
|
490
|
+
rowLength = 0;
|
|
491
|
+
}
|
|
492
|
+
if (rowLength + wordLength > columns && options.wordWrap === false) {
|
|
493
|
+
wrapWord(rows, word, columns);
|
|
494
|
+
rowLength = dist_default2(rows.at(-1) ?? "");
|
|
495
|
+
continue;
|
|
496
|
+
}
|
|
497
|
+
rows[rows.length - 1] += word;
|
|
498
|
+
rowLength += wordLength;
|
|
499
|
+
}
|
|
500
|
+
if (options.trim !== false) {
|
|
501
|
+
rows = rows.map((row) => stringVisibleTrimSpacesRight(row));
|
|
502
|
+
}
|
|
503
|
+
const preString = rows.join(`
|
|
504
|
+
`);
|
|
505
|
+
let inSurrogate = false;
|
|
506
|
+
for (let i = 0;i < preString.length; i++) {
|
|
507
|
+
const character = preString[i];
|
|
508
|
+
returnValue += character;
|
|
509
|
+
if (!inSurrogate) {
|
|
510
|
+
inSurrogate = character >= "\uD800" && character <= "\uDBFF";
|
|
511
|
+
} else {
|
|
512
|
+
continue;
|
|
513
|
+
}
|
|
514
|
+
if (character === ESC || character === CSI) {
|
|
515
|
+
GROUP_REGEX.lastIndex = i + 1;
|
|
516
|
+
const groupsResult = GROUP_REGEX.exec(preString);
|
|
517
|
+
const groups = groupsResult?.groups;
|
|
518
|
+
if (groups?.code !== undefined) {
|
|
519
|
+
const code = Number.parseFloat(groups.code);
|
|
520
|
+
escapeCode = code === END_CODE ? undefined : code;
|
|
521
|
+
} else if (groups?.uri !== undefined) {
|
|
522
|
+
escapeUrl = groups.uri.length === 0 ? undefined : groups.uri;
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
if (preString[i + 1] === `
|
|
526
|
+
`) {
|
|
527
|
+
if (escapeUrl) {
|
|
528
|
+
returnValue += wrapAnsiHyperlink("");
|
|
529
|
+
}
|
|
530
|
+
const closingCode = escapeCode ? getClosingCode(escapeCode) : undefined;
|
|
531
|
+
if (escapeCode && closingCode) {
|
|
532
|
+
returnValue += wrapAnsiCode(closingCode);
|
|
533
|
+
}
|
|
534
|
+
} else if (character === `
|
|
535
|
+
`) {
|
|
536
|
+
if (escapeCode && getClosingCode(escapeCode)) {
|
|
537
|
+
returnValue += wrapAnsiCode(escapeCode);
|
|
538
|
+
}
|
|
539
|
+
if (escapeUrl) {
|
|
540
|
+
returnValue += wrapAnsiHyperlink(escapeUrl);
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
return returnValue;
|
|
545
|
+
};
|
|
546
|
+
var CRLF_OR_LF = /\r?\n/;
|
|
547
|
+
function wrapAnsi(string, columns, options) {
|
|
548
|
+
return String(string).normalize().split(CRLF_OR_LF).map((line) => exec(line, columns, options)).join(`
|
|
549
|
+
`);
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
// node_modules/@clack/core/dist/index.mjs
|
|
553
|
+
var import_sisteransi = __toESM(require_src(), 1);
|
|
554
|
+
import { ReadStream as D } from "node:tty";
|
|
555
|
+
function d(r, t, e) {
|
|
556
|
+
if (!e.some((o) => !o.disabled))
|
|
557
|
+
return r;
|
|
558
|
+
const s = r + t, i = Math.max(e.length - 1, 0), n = s < 0 ? i : s > i ? 0 : s;
|
|
559
|
+
return e[n].disabled ? d(n, t < 0 ? -1 : 1, e) : n;
|
|
560
|
+
}
|
|
561
|
+
var E = ["up", "down", "left", "right", "space", "enter", "cancel"];
|
|
562
|
+
var G = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
|
|
563
|
+
var u = { actions: new Set(E), 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: [...G], 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)}` } } };
|
|
564
|
+
function V(r, t) {
|
|
565
|
+
if (typeof r == "string")
|
|
566
|
+
return u.aliases.get(r) === t;
|
|
567
|
+
for (const e of r)
|
|
568
|
+
if (e !== undefined && V(e, t))
|
|
569
|
+
return true;
|
|
570
|
+
return false;
|
|
571
|
+
}
|
|
572
|
+
function j(r, t) {
|
|
573
|
+
if (r === t)
|
|
574
|
+
return;
|
|
575
|
+
const e = r.split(`
|
|
576
|
+
`), s = t.split(`
|
|
577
|
+
`), i = Math.max(e.length, s.length), n = [];
|
|
578
|
+
for (let o = 0;o < i; o++)
|
|
579
|
+
e[o] !== s[o] && n.push(o);
|
|
580
|
+
return { lines: n, numLinesBefore: e.length, numLinesAfter: s.length, numLines: i };
|
|
581
|
+
}
|
|
582
|
+
var Y = globalThis.process.platform.startsWith("win");
|
|
583
|
+
var C = Symbol("clack:cancel");
|
|
584
|
+
function q(r) {
|
|
585
|
+
return r === C;
|
|
586
|
+
}
|
|
587
|
+
function w(r, t) {
|
|
588
|
+
const e = r;
|
|
589
|
+
e.isTTY && e.setRawMode(t);
|
|
590
|
+
}
|
|
591
|
+
function z({ input: r = $, output: t = S, overwrite: e = true, hideCursor: s = true } = {}) {
|
|
592
|
+
const i = _.createInterface({ input: r, output: t, prompt: "", tabSize: 1 });
|
|
593
|
+
_.emitKeypressEvents(r, i), r instanceof D && r.isTTY && r.setRawMode(true);
|
|
594
|
+
const n = (o, { name: a, sequence: h }) => {
|
|
595
|
+
const l = String(o);
|
|
596
|
+
if (V([l, a, h], "cancel")) {
|
|
597
|
+
s && t.write(import_sisteransi.cursor.show), process.exit(0);
|
|
598
|
+
return;
|
|
599
|
+
}
|
|
600
|
+
if (!e)
|
|
601
|
+
return;
|
|
602
|
+
const f = a === "return" ? 0 : -1, v = a === "return" ? -1 : 0;
|
|
603
|
+
_.moveCursor(t, f, v, () => {
|
|
604
|
+
_.clearLine(t, 1, () => {
|
|
605
|
+
r.once("keypress", n);
|
|
606
|
+
});
|
|
607
|
+
});
|
|
608
|
+
};
|
|
609
|
+
return s && t.write(import_sisteransi.cursor.hide), r.once("keypress", n), () => {
|
|
610
|
+
r.off("keypress", n), s && t.write(import_sisteransi.cursor.show), r instanceof D && r.isTTY && !Y && r.setRawMode(false), i.terminal = false, i.close();
|
|
611
|
+
};
|
|
612
|
+
}
|
|
613
|
+
var O = (r) => ("columns" in r) && typeof r.columns == "number" ? r.columns : 80;
|
|
614
|
+
var A = (r) => ("rows" in r) && typeof r.rows == "number" ? r.rows : 20;
|
|
615
|
+
function R(r, t, e, s = e) {
|
|
616
|
+
const i = O(r ?? S);
|
|
617
|
+
return wrapAnsi(t, i - e.length, { hard: true, trim: false }).split(`
|
|
618
|
+
`).map((n, o) => `${o === 0 ? s : e}${n}`).join(`
|
|
619
|
+
`);
|
|
620
|
+
}
|
|
621
|
+
var p = class {
|
|
622
|
+
input;
|
|
623
|
+
output;
|
|
624
|
+
_abortSignal;
|
|
625
|
+
rl;
|
|
626
|
+
opts;
|
|
627
|
+
_render;
|
|
628
|
+
_track = false;
|
|
629
|
+
_prevFrame = "";
|
|
630
|
+
_subscribers = new Map;
|
|
631
|
+
_cursor = 0;
|
|
632
|
+
state = "initial";
|
|
633
|
+
error = "";
|
|
634
|
+
value;
|
|
635
|
+
userInput = "";
|
|
636
|
+
constructor(t, e = true) {
|
|
637
|
+
const { input: s = $, output: i = S, render: n, signal: o, ...a } = t;
|
|
638
|
+
this.opts = a, 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 = e, this._abortSignal = o, this.input = s, this.output = i;
|
|
639
|
+
}
|
|
640
|
+
unsubscribe() {
|
|
641
|
+
this._subscribers.clear();
|
|
642
|
+
}
|
|
643
|
+
setSubscriber(t, e) {
|
|
644
|
+
const s = this._subscribers.get(t) ?? [];
|
|
645
|
+
s.push(e), this._subscribers.set(t, s);
|
|
646
|
+
}
|
|
647
|
+
on(t, e) {
|
|
648
|
+
this.setSubscriber(t, { cb: e });
|
|
649
|
+
}
|
|
650
|
+
once(t, e) {
|
|
651
|
+
this.setSubscriber(t, { cb: e, once: true });
|
|
652
|
+
}
|
|
653
|
+
emit(t, ...e) {
|
|
654
|
+
const s = this._subscribers.get(t) ?? [], i = [];
|
|
655
|
+
for (const n of s)
|
|
656
|
+
n.cb(...e), n.once && i.push(() => s.splice(s.indexOf(n), 1));
|
|
657
|
+
for (const n of i)
|
|
658
|
+
n();
|
|
659
|
+
}
|
|
660
|
+
prompt() {
|
|
661
|
+
return new Promise((t) => {
|
|
662
|
+
if (this._abortSignal) {
|
|
663
|
+
if (this._abortSignal.aborted)
|
|
664
|
+
return this.state = "cancel", this.close(), t(C);
|
|
665
|
+
this._abortSignal.addEventListener("abort", () => {
|
|
666
|
+
this.state = "cancel", this.close();
|
|
667
|
+
}, { once: true });
|
|
668
|
+
}
|
|
669
|
+
this.rl = P.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", () => {
|
|
670
|
+
this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), w(this.input, false), t(this.value);
|
|
671
|
+
}), this.once("cancel", () => {
|
|
672
|
+
this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), w(this.input, false), t(C);
|
|
673
|
+
});
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
_isActionKey(t, e) {
|
|
677
|
+
return t === "\t";
|
|
678
|
+
}
|
|
679
|
+
_setValue(t) {
|
|
680
|
+
this.value = t, this.emit("value", this.value);
|
|
681
|
+
}
|
|
682
|
+
_setUserInput(t, e) {
|
|
683
|
+
this.userInput = t ?? "", this.emit("userInput", this.userInput), e && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
|
|
684
|
+
}
|
|
685
|
+
_clearUserInput() {
|
|
686
|
+
this.rl?.write(null, { ctrl: true, name: "u" }), this._setUserInput("");
|
|
687
|
+
}
|
|
688
|
+
onKeypress(t, e) {
|
|
689
|
+
if (this._track && e.name !== "return" && (e.name && this._isActionKey(t, e) && this.rl?.write(null, { ctrl: true, name: "h" }), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"), e?.name && (!this._track && u.aliases.has(e.name) && this.emit("cursor", u.aliases.get(e.name)), u.actions.has(e.name) && this.emit("cursor", e.name)), t && (t.toLowerCase() === "y" || t.toLowerCase() === "n") && this.emit("confirm", t.toLowerCase() === "y"), this.emit("key", t?.toLowerCase(), e), e?.name === "return") {
|
|
690
|
+
if (this.opts.validate) {
|
|
691
|
+
const s = this.opts.validate(this.value);
|
|
692
|
+
s && (this.error = s instanceof Error ? s.message : s, this.state = "error", this.rl?.write(this.userInput));
|
|
693
|
+
}
|
|
694
|
+
this.state !== "error" && (this.state = "submit");
|
|
695
|
+
}
|
|
696
|
+
V([t, e?.name, e?.sequence], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
|
|
697
|
+
}
|
|
698
|
+
close() {
|
|
699
|
+
this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
|
|
700
|
+
`), w(this.input, false), this.rl?.close(), this.rl = undefined, this.emit(`${this.state}`, this.value), this.unsubscribe();
|
|
701
|
+
}
|
|
702
|
+
restoreCursor() {
|
|
703
|
+
const t = wrapAnsi(this._prevFrame, process.stdout.columns, { hard: true, trim: false }).split(`
|
|
704
|
+
`).length - 1;
|
|
705
|
+
this.output.write(import_sisteransi.cursor.move(-999, t * -1));
|
|
706
|
+
}
|
|
707
|
+
render() {
|
|
708
|
+
const t = wrapAnsi(this._render(this) ?? "", process.stdout.columns, { hard: true, trim: false });
|
|
709
|
+
if (t !== this._prevFrame) {
|
|
710
|
+
if (this.state === "initial")
|
|
711
|
+
this.output.write(import_sisteransi.cursor.hide);
|
|
712
|
+
else {
|
|
713
|
+
const e = j(this._prevFrame, t), s = A(this.output);
|
|
714
|
+
if (this.restoreCursor(), e) {
|
|
715
|
+
const i = Math.max(0, e.numLinesAfter - s), n = Math.max(0, e.numLinesBefore - s);
|
|
716
|
+
let o = e.lines.find((a) => a >= i);
|
|
717
|
+
if (o === undefined) {
|
|
718
|
+
this._prevFrame = t;
|
|
719
|
+
return;
|
|
720
|
+
}
|
|
721
|
+
if (e.lines.length === 1) {
|
|
722
|
+
this.output.write(import_sisteransi.cursor.move(0, o - n)), this.output.write(import_sisteransi.erase.lines(1));
|
|
723
|
+
const a = t.split(`
|
|
724
|
+
`);
|
|
725
|
+
this.output.write(a[o]), this._prevFrame = t, this.output.write(import_sisteransi.cursor.move(0, a.length - o - 1));
|
|
726
|
+
return;
|
|
727
|
+
} else if (e.lines.length > 1) {
|
|
728
|
+
if (i < n)
|
|
729
|
+
o = i;
|
|
730
|
+
else {
|
|
731
|
+
const h = o - n;
|
|
732
|
+
h > 0 && this.output.write(import_sisteransi.cursor.move(0, h));
|
|
733
|
+
}
|
|
734
|
+
this.output.write(import_sisteransi.erase.down());
|
|
735
|
+
const a = t.split(`
|
|
736
|
+
`).slice(o);
|
|
737
|
+
this.output.write(a.join(`
|
|
738
|
+
`)), this._prevFrame = t;
|
|
739
|
+
return;
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
this.output.write(import_sisteransi.erase.down());
|
|
743
|
+
}
|
|
744
|
+
this.output.write(t), this.state === "initial" && (this.state = "active"), this._prevFrame = t;
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
};
|
|
748
|
+
function W(r, t) {
|
|
749
|
+
if (r === undefined || t.length === 0)
|
|
750
|
+
return 0;
|
|
751
|
+
const e = t.findIndex((s) => s.value === r);
|
|
752
|
+
return e !== -1 ? e : 0;
|
|
753
|
+
}
|
|
754
|
+
function B(r, t) {
|
|
755
|
+
return (t.label ?? String(t.value)).toLowerCase().includes(r.toLowerCase());
|
|
756
|
+
}
|
|
757
|
+
function J(r, t) {
|
|
758
|
+
if (t)
|
|
759
|
+
return r ? t : t[0];
|
|
760
|
+
}
|
|
761
|
+
var H = class extends p {
|
|
762
|
+
filteredOptions;
|
|
763
|
+
multiple;
|
|
764
|
+
isNavigating = false;
|
|
765
|
+
selectedValues = [];
|
|
766
|
+
focusedValue;
|
|
767
|
+
#e = 0;
|
|
768
|
+
#o = "";
|
|
769
|
+
#t;
|
|
770
|
+
#n;
|
|
771
|
+
#a;
|
|
772
|
+
get cursor() {
|
|
773
|
+
return this.#e;
|
|
774
|
+
}
|
|
775
|
+
get userInputWithCursor() {
|
|
776
|
+
if (!this.userInput)
|
|
777
|
+
return y(["inverse", "hidden"], "_");
|
|
778
|
+
if (this._cursor >= this.userInput.length)
|
|
779
|
+
return `${this.userInput}█`;
|
|
780
|
+
const t = this.userInput.slice(0, this._cursor), [e, ...s] = this.userInput.slice(this._cursor);
|
|
781
|
+
return `${t}${y("inverse", e)}${s.join("")}`;
|
|
782
|
+
}
|
|
783
|
+
get options() {
|
|
784
|
+
return typeof this.#n == "function" ? this.#n() : this.#n;
|
|
785
|
+
}
|
|
786
|
+
constructor(t) {
|
|
787
|
+
super(t), this.#n = t.options, this.#a = t.placeholder;
|
|
788
|
+
const e = this.options;
|
|
789
|
+
this.filteredOptions = [...e], this.multiple = t.multiple === true, this.#t = typeof t.options == "function" ? t.filter : t.filter ?? B;
|
|
790
|
+
let s;
|
|
791
|
+
if (t.initialValue && Array.isArray(t.initialValue) ? this.multiple ? s = t.initialValue : s = t.initialValue.slice(0, 1) : !this.multiple && this.options.length > 0 && (s = [this.options[0].value]), s)
|
|
792
|
+
for (const i of s) {
|
|
793
|
+
const n = e.findIndex((o) => o.value === i);
|
|
794
|
+
n !== -1 && (this.toggleSelected(i), this.#e = n);
|
|
795
|
+
}
|
|
796
|
+
this.focusedValue = this.options[this.#e]?.value, this.on("key", (i, n) => this.#s(i, n)), this.on("userInput", (i) => this.#i(i));
|
|
797
|
+
}
|
|
798
|
+
_isActionKey(t, e) {
|
|
799
|
+
return t === "\t" || this.multiple && this.isNavigating && e.name === "space" && t !== undefined && t !== "";
|
|
800
|
+
}
|
|
801
|
+
#s(t, e) {
|
|
802
|
+
const s = e.name === "up", i = e.name === "down", n = e.name === "return", o = this.userInput === "" || this.userInput === "\t", a = this.#a, h = this.options, l = a !== undefined && a !== "" && h.some((f) => !f.disabled && (this.#t ? this.#t(a, f) : true));
|
|
803
|
+
if (e.name === "tab" && o && l) {
|
|
804
|
+
this.userInput === "\t" && this._clearUserInput(), this._setUserInput(a, true), this.isNavigating = false;
|
|
805
|
+
return;
|
|
806
|
+
}
|
|
807
|
+
s || i ? (this.#e = d(this.#e, s ? -1 : 1, this.filteredOptions), this.focusedValue = this.filteredOptions[this.#e]?.value, this.multiple || (this.selectedValues = [this.focusedValue]), this.isNavigating = true) : n ? this.value = J(this.multiple, this.selectedValues) : this.multiple ? this.focusedValue !== undefined && (e.name === "tab" || this.isNavigating && e.name === "space") ? this.toggleSelected(this.focusedValue) : this.isNavigating = false : (this.focusedValue && (this.selectedValues = [this.focusedValue]), this.isNavigating = false);
|
|
808
|
+
}
|
|
809
|
+
deselectAll() {
|
|
810
|
+
this.selectedValues = [];
|
|
811
|
+
}
|
|
812
|
+
toggleSelected(t) {
|
|
813
|
+
this.filteredOptions.length !== 0 && (this.multiple ? this.selectedValues.includes(t) ? this.selectedValues = this.selectedValues.filter((e) => e !== t) : this.selectedValues = [...this.selectedValues, t] : this.selectedValues = [t]);
|
|
814
|
+
}
|
|
815
|
+
#i(t) {
|
|
816
|
+
if (t !== this.#o) {
|
|
817
|
+
this.#o = t;
|
|
818
|
+
const e = this.options;
|
|
819
|
+
t && this.#t ? this.filteredOptions = e.filter((n) => this.#t?.(t, n)) : this.filteredOptions = [...e];
|
|
820
|
+
const s = W(this.focusedValue, this.filteredOptions);
|
|
821
|
+
this.#e = d(s, 0, this.filteredOptions);
|
|
822
|
+
const i = this.filteredOptions[this.#e];
|
|
823
|
+
i && !i.disabled ? this.focusedValue = i.value : this.focusedValue = undefined, this.multiple || (this.focusedValue !== undefined ? this.toggleSelected(this.focusedValue) : this.deselectAll());
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
};
|
|
827
|
+
|
|
828
|
+
class Q extends p {
|
|
829
|
+
get cursor() {
|
|
830
|
+
return this.value ? 0 : 1;
|
|
831
|
+
}
|
|
832
|
+
get _value() {
|
|
833
|
+
return this.cursor === 0;
|
|
834
|
+
}
|
|
835
|
+
constructor(t) {
|
|
836
|
+
super(t, false), this.value = !!t.initialValue, this.on("userInput", () => {
|
|
837
|
+
this.value = this._value;
|
|
838
|
+
}), this.on("confirm", (e) => {
|
|
839
|
+
this.output.write(import_sisteransi.cursor.move(0, -1)), this.value = e, this.state = "submit", this.close();
|
|
840
|
+
}), this.on("cursor", () => {
|
|
841
|
+
this.value = !this.value;
|
|
842
|
+
});
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
var X = { Y: { type: "year", len: 4 }, M: { type: "month", len: 2 }, D: { type: "day", len: 2 } };
|
|
846
|
+
function L(r) {
|
|
847
|
+
return [...r].map((t) => X[t]);
|
|
848
|
+
}
|
|
849
|
+
function Z(r) {
|
|
850
|
+
const t = new Intl.DateTimeFormat(r, { year: "numeric", month: "2-digit", day: "2-digit" }).formatToParts(new Date(2000, 0, 15)), e = [];
|
|
851
|
+
let s = "/";
|
|
852
|
+
for (const i of t)
|
|
853
|
+
i.type === "literal" ? s = i.value.trim() || i.value : (i.type === "year" || i.type === "month" || i.type === "day") && e.push({ type: i.type, len: i.type === "year" ? 4 : 2 });
|
|
854
|
+
return { segments: e, separator: s };
|
|
855
|
+
}
|
|
856
|
+
function k(r) {
|
|
857
|
+
return Number.parseInt((r || "0").replace(/_/g, "0"), 10) || 0;
|
|
858
|
+
}
|
|
859
|
+
function I(r) {
|
|
860
|
+
return { year: k(r.year), month: k(r.month), day: k(r.day) };
|
|
861
|
+
}
|
|
862
|
+
function T(r, t) {
|
|
863
|
+
return new Date(r || 2001, t || 1, 0).getDate();
|
|
864
|
+
}
|
|
865
|
+
function F(r) {
|
|
866
|
+
const { year: t, month: e, day: s } = I(r);
|
|
867
|
+
if (!t || t < 0 || t > 9999 || !e || e < 1 || e > 12 || !s || s < 1)
|
|
868
|
+
return;
|
|
869
|
+
const i = new Date(Date.UTC(t, e - 1, s));
|
|
870
|
+
if (!(i.getUTCFullYear() !== t || i.getUTCMonth() !== e - 1 || i.getUTCDate() !== s))
|
|
871
|
+
return { year: t, month: e, day: s };
|
|
872
|
+
}
|
|
873
|
+
function N(r) {
|
|
874
|
+
const t = F(r);
|
|
875
|
+
return t ? new Date(Date.UTC(t.year, t.month - 1, t.day)) : undefined;
|
|
876
|
+
}
|
|
877
|
+
function tt(r, t, e, s) {
|
|
878
|
+
const i = e ? { year: e.getUTCFullYear(), month: e.getUTCMonth() + 1, day: e.getUTCDate() } : null, n = s ? { year: s.getUTCFullYear(), month: s.getUTCMonth() + 1, day: s.getUTCDate() } : null;
|
|
879
|
+
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(t.year, t.month) };
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
class et extends p {
|
|
883
|
+
#e;
|
|
884
|
+
#o;
|
|
885
|
+
#t;
|
|
886
|
+
#n;
|
|
887
|
+
#a;
|
|
888
|
+
#s = { segmentIndex: 0, positionInSegment: 0 };
|
|
889
|
+
#i = true;
|
|
890
|
+
#r = null;
|
|
891
|
+
inlineError = "";
|
|
892
|
+
get segmentCursor() {
|
|
893
|
+
return { ...this.#s };
|
|
894
|
+
}
|
|
895
|
+
get segmentValues() {
|
|
896
|
+
return { ...this.#t };
|
|
897
|
+
}
|
|
898
|
+
get segments() {
|
|
899
|
+
return this.#e;
|
|
900
|
+
}
|
|
901
|
+
get separator() {
|
|
902
|
+
return this.#o;
|
|
903
|
+
}
|
|
904
|
+
get formattedValue() {
|
|
905
|
+
return this.#c(this.#t);
|
|
906
|
+
}
|
|
907
|
+
#c(t) {
|
|
908
|
+
return this.#e.map((e) => t[e.type]).join(this.#o);
|
|
909
|
+
}
|
|
910
|
+
#h() {
|
|
911
|
+
this._setUserInput(this.#c(this.#t)), this._setValue(N(this.#t) ?? undefined);
|
|
912
|
+
}
|
|
913
|
+
constructor(t) {
|
|
914
|
+
const e = t.format ? { segments: L(t.format), separator: t.separator ?? "/" } : Z(t.locale), s = t.separator ?? e.separator, i = t.format ? L(t.format) : e.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: "__" }, a = i.map((h) => o[h.type]).join(s);
|
|
915
|
+
super({ ...t, initialUserInput: a }, false), this.#e = i, this.#o = s, this.#t = o, this.#n = t.minDate, this.#a = t.maxDate, this.#h(), this.on("cursor", (h) => this.#d(h)), this.on("key", (h, l) => this.#f(h, l)), this.on("finalize", () => this.#g(t));
|
|
916
|
+
}
|
|
917
|
+
#u() {
|
|
918
|
+
const t = Math.max(0, Math.min(this.#s.segmentIndex, this.#e.length - 1)), e = this.#e[t];
|
|
919
|
+
if (e)
|
|
920
|
+
return this.#s.positionInSegment = Math.max(0, Math.min(this.#s.positionInSegment, e.len - 1)), { segment: e, index: t };
|
|
921
|
+
}
|
|
922
|
+
#l(t) {
|
|
923
|
+
this.inlineError = "", this.#r = null;
|
|
924
|
+
const e = this.#u();
|
|
925
|
+
e && (this.#s.segmentIndex = Math.max(0, Math.min(this.#e.length - 1, e.index + t)), this.#s.positionInSegment = 0, this.#i = true);
|
|
926
|
+
}
|
|
927
|
+
#p(t) {
|
|
928
|
+
const e = this.#u();
|
|
929
|
+
if (!e)
|
|
930
|
+
return;
|
|
931
|
+
const { segment: s } = e, i = this.#t[s.type], n = !i || i.replace(/_/g, "") === "", o = Number.parseInt((i || "0").replace(/_/g, "0"), 10) || 0, a = tt(s.type, I(this.#t), this.#n, this.#a);
|
|
932
|
+
let h;
|
|
933
|
+
n ? h = t === 1 ? a.min : a.max : h = Math.max(Math.min(a.max, o + t), a.min), this.#t = { ...this.#t, [s.type]: h.toString().padStart(s.len, "0") }, this.#i = true, this.#r = null, this.#h();
|
|
934
|
+
}
|
|
935
|
+
#d(t) {
|
|
936
|
+
if (t)
|
|
937
|
+
switch (t) {
|
|
938
|
+
case "right":
|
|
939
|
+
return this.#l(1);
|
|
940
|
+
case "left":
|
|
941
|
+
return this.#l(-1);
|
|
942
|
+
case "up":
|
|
943
|
+
return this.#p(1);
|
|
944
|
+
case "down":
|
|
945
|
+
return this.#p(-1);
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
#f(t, e) {
|
|
949
|
+
if (e?.name === "backspace" || e?.sequence === "" || e?.sequence === "\b" || t === "" || t === "\b") {
|
|
950
|
+
this.inlineError = "";
|
|
951
|
+
const s = this.#u();
|
|
952
|
+
if (!s)
|
|
953
|
+
return;
|
|
954
|
+
if (!this.#t[s.segment.type].replace(/_/g, "")) {
|
|
955
|
+
this.#l(-1);
|
|
956
|
+
return;
|
|
957
|
+
}
|
|
958
|
+
this.#t[s.segment.type] = "_".repeat(s.segment.len), this.#i = true, this.#s.positionInSegment = 0, this.#h();
|
|
959
|
+
return;
|
|
960
|
+
}
|
|
961
|
+
if (e?.name === "tab") {
|
|
962
|
+
this.inlineError = "";
|
|
963
|
+
const s = this.#u();
|
|
964
|
+
if (!s)
|
|
965
|
+
return;
|
|
966
|
+
const i = e.shift ? -1 : 1, n = s.index + i;
|
|
967
|
+
n >= 0 && n < this.#e.length && (this.#s.segmentIndex = n, this.#s.positionInSegment = 0, this.#i = true);
|
|
968
|
+
return;
|
|
969
|
+
}
|
|
970
|
+
if (t && /^[0-9]$/.test(t)) {
|
|
971
|
+
const s = this.#u();
|
|
972
|
+
if (!s)
|
|
973
|
+
return;
|
|
974
|
+
const { segment: i } = s, n = !this.#t[i.type].replace(/_/g, "");
|
|
975
|
+
if (this.#i && this.#r !== null && !n) {
|
|
976
|
+
const m = this.#r + t, g = { ...this.#t, [i.type]: m }, b = this.#m(g, i);
|
|
977
|
+
if (b) {
|
|
978
|
+
this.inlineError = b, this.#r = null, this.#i = false;
|
|
979
|
+
return;
|
|
980
|
+
}
|
|
981
|
+
this.inlineError = "", this.#t[i.type] = m, this.#r = null, this.#i = false, this.#h(), s.index < this.#e.length - 1 && (this.#s.segmentIndex = s.index + 1, this.#s.positionInSegment = 0, this.#i = true);
|
|
982
|
+
return;
|
|
983
|
+
}
|
|
984
|
+
this.#i && !n && (this.#t[i.type] = "_".repeat(i.len), this.#s.positionInSegment = 0), this.#i = false, this.#r = null;
|
|
985
|
+
const o = this.#t[i.type], a = o.indexOf("_"), h = a >= 0 ? a : Math.min(this.#s.positionInSegment, i.len - 1);
|
|
986
|
+
if (h < 0 || h >= i.len)
|
|
987
|
+
return;
|
|
988
|
+
let l = o.slice(0, h) + t + o.slice(h + 1), f = false;
|
|
989
|
+
if (h === 0 && o === "__" && (i.type === "month" || i.type === "day")) {
|
|
990
|
+
const m = Number.parseInt(t, 10);
|
|
991
|
+
l = `0${t}`, f = m <= (i.type === "month" ? 1 : 2);
|
|
992
|
+
}
|
|
993
|
+
if (i.type === "year" && (l = (o.replace(/_/g, "") + t).padStart(i.len, "_")), !l.includes("_")) {
|
|
994
|
+
const m = { ...this.#t, [i.type]: l }, g = this.#m(m, i);
|
|
995
|
+
if (g) {
|
|
996
|
+
this.inlineError = g;
|
|
997
|
+
return;
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
this.inlineError = "", this.#t[i.type] = l;
|
|
1001
|
+
const v = l.includes("_") ? undefined : F(this.#t);
|
|
1002
|
+
if (v) {
|
|
1003
|
+
const { year: m, month: g } = v, b = T(m, g);
|
|
1004
|
+
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(b, v.day))).padStart(2, "0") };
|
|
1005
|
+
}
|
|
1006
|
+
this.#h();
|
|
1007
|
+
const U = l.indexOf("_");
|
|
1008
|
+
f ? (this.#i = true, this.#r = t) : U >= 0 ? this.#s.positionInSegment = U : a >= 0 && s.index < this.#e.length - 1 ? (this.#s.segmentIndex = s.index + 1, this.#s.positionInSegment = 0, this.#i = true) : this.#s.positionInSegment = Math.min(h + 1, i.len - 1);
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
#m(t, e) {
|
|
1012
|
+
const { month: s, day: i } = I(t);
|
|
1013
|
+
if (e.type === "month" && (s < 0 || s > 12))
|
|
1014
|
+
return u.date.messages.invalidMonth;
|
|
1015
|
+
if (e.type === "day" && (i < 0 || i > 31))
|
|
1016
|
+
return u.date.messages.invalidDay(31, "any month");
|
|
1017
|
+
}
|
|
1018
|
+
#g(t) {
|
|
1019
|
+
const { year: e, month: s, day: i } = I(this.#t);
|
|
1020
|
+
if (e && s && i) {
|
|
1021
|
+
const n = T(e, s);
|
|
1022
|
+
this.#t = { ...this.#t, day: String(Math.min(i, n)).padStart(2, "0") };
|
|
1023
|
+
}
|
|
1024
|
+
this.value = N(this.#t) ?? t.defaultValue ?? undefined;
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
class st extends p {
|
|
1029
|
+
options;
|
|
1030
|
+
cursor = 0;
|
|
1031
|
+
#e;
|
|
1032
|
+
getGroupItems(t) {
|
|
1033
|
+
return this.options.filter((e) => e.group === t);
|
|
1034
|
+
}
|
|
1035
|
+
isGroupSelected(t) {
|
|
1036
|
+
const e = this.getGroupItems(t), s = this.value;
|
|
1037
|
+
return s === undefined ? false : e.every((i) => s.includes(i.value));
|
|
1038
|
+
}
|
|
1039
|
+
toggleValue() {
|
|
1040
|
+
const t = this.options[this.cursor];
|
|
1041
|
+
if (this.value === undefined && (this.value = []), t.group === true) {
|
|
1042
|
+
const e = t.value, s = this.getGroupItems(e);
|
|
1043
|
+
this.isGroupSelected(e) ? this.value = this.value.filter((i) => s.findIndex((n) => n.value === i) === -1) : this.value = [...this.value, ...s.map((i) => i.value)], this.value = Array.from(new Set(this.value));
|
|
1044
|
+
} else {
|
|
1045
|
+
const e = this.value.includes(t.value);
|
|
1046
|
+
this.value = e ? this.value.filter((s) => s !== t.value) : [...this.value, t.value];
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
constructor(t) {
|
|
1050
|
+
super(t, false);
|
|
1051
|
+
const { options: e } = t;
|
|
1052
|
+
this.#e = t.selectableGroups !== false, this.options = Object.entries(e).flatMap(([s, i]) => [{ value: s, group: true, label: s }, ...i.map((n) => ({ ...n, group: s }))]), this.value = [...t.initialValues ?? []], this.cursor = Math.max(this.options.findIndex(({ value: s }) => s === t.cursorAt), this.#e ? 0 : 1), this.on("cursor", (s) => {
|
|
1053
|
+
switch (s) {
|
|
1054
|
+
case "left":
|
|
1055
|
+
case "up": {
|
|
1056
|
+
this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
|
|
1057
|
+
const i = this.options[this.cursor]?.group === true;
|
|
1058
|
+
!this.#e && i && (this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1);
|
|
1059
|
+
break;
|
|
1060
|
+
}
|
|
1061
|
+
case "down":
|
|
1062
|
+
case "right": {
|
|
1063
|
+
this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
|
|
1064
|
+
const i = this.options[this.cursor]?.group === true;
|
|
1065
|
+
!this.#e && i && (this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1);
|
|
1066
|
+
break;
|
|
1067
|
+
}
|
|
1068
|
+
case "space":
|
|
1069
|
+
this.toggleValue();
|
|
1070
|
+
break;
|
|
1071
|
+
}
|
|
1072
|
+
});
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
var it = class extends p {
|
|
1076
|
+
options;
|
|
1077
|
+
cursor = 0;
|
|
1078
|
+
get _value() {
|
|
1079
|
+
return this.options[this.cursor].value;
|
|
1080
|
+
}
|
|
1081
|
+
get _enabledOptions() {
|
|
1082
|
+
return this.options.filter((t) => t.disabled !== true);
|
|
1083
|
+
}
|
|
1084
|
+
toggleAll() {
|
|
1085
|
+
const t = this._enabledOptions, e = this.value !== undefined && this.value.length === t.length;
|
|
1086
|
+
this.value = e ? [] : t.map((s) => s.value);
|
|
1087
|
+
}
|
|
1088
|
+
toggleInvert() {
|
|
1089
|
+
const t = this.value;
|
|
1090
|
+
if (!t)
|
|
1091
|
+
return;
|
|
1092
|
+
const e = this._enabledOptions.filter((s) => !t.includes(s.value));
|
|
1093
|
+
this.value = e.map((s) => s.value);
|
|
1094
|
+
}
|
|
1095
|
+
toggleValue() {
|
|
1096
|
+
this.value === undefined && (this.value = []);
|
|
1097
|
+
const t = this.value.includes(this._value);
|
|
1098
|
+
this.value = t ? this.value.filter((e) => e !== this._value) : [...this.value, this._value];
|
|
1099
|
+
}
|
|
1100
|
+
constructor(t) {
|
|
1101
|
+
super(t, false), this.options = t.options, this.value = [...t.initialValues ?? []];
|
|
1102
|
+
const e = Math.max(this.options.findIndex(({ value: s }) => s === t.cursorAt), 0);
|
|
1103
|
+
this.cursor = this.options[e].disabled ? d(e, 1, this.options) : e, this.on("key", (s) => {
|
|
1104
|
+
s === "a" && this.toggleAll(), s === "i" && this.toggleInvert();
|
|
1105
|
+
}), this.on("cursor", (s) => {
|
|
1106
|
+
switch (s) {
|
|
1107
|
+
case "left":
|
|
1108
|
+
case "up":
|
|
1109
|
+
this.cursor = d(this.cursor, -1, this.options);
|
|
1110
|
+
break;
|
|
1111
|
+
case "down":
|
|
1112
|
+
case "right":
|
|
1113
|
+
this.cursor = d(this.cursor, 1, this.options);
|
|
1114
|
+
break;
|
|
1115
|
+
case "space":
|
|
1116
|
+
this.toggleValue();
|
|
1117
|
+
break;
|
|
1118
|
+
}
|
|
1119
|
+
});
|
|
1120
|
+
}
|
|
1121
|
+
};
|
|
1122
|
+
class nt extends p {
|
|
1123
|
+
options;
|
|
1124
|
+
cursor = 0;
|
|
1125
|
+
get _selectedValue() {
|
|
1126
|
+
return this.options[this.cursor];
|
|
1127
|
+
}
|
|
1128
|
+
changeValue() {
|
|
1129
|
+
this.value = this._selectedValue.value;
|
|
1130
|
+
}
|
|
1131
|
+
constructor(t) {
|
|
1132
|
+
super(t, false), this.options = t.options;
|
|
1133
|
+
const e = this.options.findIndex(({ value: i }) => i === t.initialValue), s = e === -1 ? 0 : e;
|
|
1134
|
+
this.cursor = this.options[s].disabled ? d(s, 1, this.options) : s, this.changeValue(), this.on("cursor", (i) => {
|
|
1135
|
+
switch (i) {
|
|
1136
|
+
case "left":
|
|
1137
|
+
case "up":
|
|
1138
|
+
this.cursor = d(this.cursor, -1, this.options);
|
|
1139
|
+
break;
|
|
1140
|
+
case "down":
|
|
1141
|
+
case "right":
|
|
1142
|
+
this.cursor = d(this.cursor, 1, this.options);
|
|
1143
|
+
break;
|
|
1144
|
+
}
|
|
1145
|
+
this.changeValue();
|
|
1146
|
+
});
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
class at extends p {
|
|
1150
|
+
get userInputWithCursor() {
|
|
1151
|
+
if (this.state === "submit")
|
|
1152
|
+
return this.userInput;
|
|
1153
|
+
const t = this.userInput;
|
|
1154
|
+
if (this.cursor >= t.length)
|
|
1155
|
+
return `${this.userInput}█`;
|
|
1156
|
+
const e = t.slice(0, this.cursor), [s, ...i] = t.slice(this.cursor);
|
|
1157
|
+
return `${e}${y("inverse", s)}${i.join("")}`;
|
|
1158
|
+
}
|
|
1159
|
+
get cursor() {
|
|
1160
|
+
return this._cursor;
|
|
1161
|
+
}
|
|
1162
|
+
constructor(t) {
|
|
1163
|
+
super({ ...t, initialUserInput: t.initialUserInput ?? t.initialValue }), this.on("userInput", (e) => {
|
|
1164
|
+
this._setValue(e);
|
|
1165
|
+
}), this.on("finalize", () => {
|
|
1166
|
+
this.value || (this.value = t.defaultValue), this.value === undefined && (this.value = "");
|
|
1167
|
+
});
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
|
|
1171
|
+
// node_modules/@clack/prompts/dist/index.mjs
|
|
1172
|
+
import { styleText as t, stripVTControlCharacters as ne } from "node:util";
|
|
1173
|
+
import P2 from "node:process";
|
|
1174
|
+
var import_sisteransi2 = __toESM(require_src(), 1);
|
|
1175
|
+
function Ze() {
|
|
1176
|
+
return P2.platform !== "win32" ? P2.env.TERM !== "linux" : !!P2.env.CI || !!P2.env.WT_SESSION || !!P2.env.TERMINUS_SUBLIME || P2.env.ConEmuTask === "{cmd::Cmder}" || P2.env.TERM_PROGRAM === "Terminus-Sublime" || P2.env.TERM_PROGRAM === "vscode" || P2.env.TERM === "xterm-256color" || P2.env.TERM === "alacritty" || P2.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
1177
|
+
}
|
|
1178
|
+
var ee = Ze();
|
|
1179
|
+
var ae = () => process.env.CI === "true";
|
|
1180
|
+
var w2 = (e, i) => ee ? e : i;
|
|
1181
|
+
var _e = w2("◆", "*");
|
|
1182
|
+
var oe = w2("■", "x");
|
|
1183
|
+
var ue = w2("▲", "x");
|
|
1184
|
+
var F2 = w2("◇", "o");
|
|
1185
|
+
var le = w2("┌", "T");
|
|
1186
|
+
var d2 = w2("│", "|");
|
|
1187
|
+
var E2 = w2("└", "—");
|
|
1188
|
+
var Ie = w2("┐", "T");
|
|
1189
|
+
var Ee = w2("┘", "—");
|
|
1190
|
+
var z2 = w2("●", ">");
|
|
1191
|
+
var H2 = w2("○", " ");
|
|
1192
|
+
var te = w2("◻", "[•]");
|
|
1193
|
+
var U = w2("◼", "[+]");
|
|
1194
|
+
var J2 = w2("◻", "[ ]");
|
|
1195
|
+
var xe = w2("▪", "•");
|
|
1196
|
+
var se = w2("─", "-");
|
|
1197
|
+
var ce = w2("╮", "+");
|
|
1198
|
+
var Ge = w2("├", "+");
|
|
1199
|
+
var $e = w2("╯", "+");
|
|
1200
|
+
var de = w2("╰", "+");
|
|
1201
|
+
var Oe = w2("╭", "+");
|
|
1202
|
+
var he = w2("●", "•");
|
|
1203
|
+
var pe = w2("◆", "*");
|
|
1204
|
+
var me = w2("▲", "!");
|
|
1205
|
+
var ge = w2("■", "x");
|
|
1206
|
+
var V2 = (e) => {
|
|
1207
|
+
switch (e) {
|
|
1208
|
+
case "initial":
|
|
1209
|
+
case "active":
|
|
1210
|
+
return t("cyan", _e);
|
|
1211
|
+
case "cancel":
|
|
1212
|
+
return t("red", oe);
|
|
1213
|
+
case "error":
|
|
1214
|
+
return t("yellow", ue);
|
|
1215
|
+
case "submit":
|
|
1216
|
+
return t("green", F2);
|
|
1217
|
+
}
|
|
1218
|
+
};
|
|
1219
|
+
var ye = (e) => {
|
|
1220
|
+
switch (e) {
|
|
1221
|
+
case "initial":
|
|
1222
|
+
case "active":
|
|
1223
|
+
return t("cyan", d2);
|
|
1224
|
+
case "cancel":
|
|
1225
|
+
return t("red", d2);
|
|
1226
|
+
case "error":
|
|
1227
|
+
return t("yellow", d2);
|
|
1228
|
+
case "submit":
|
|
1229
|
+
return t("green", d2);
|
|
1230
|
+
}
|
|
1231
|
+
};
|
|
1232
|
+
var et2 = (e, i, s, r, u2) => {
|
|
1233
|
+
let n = i, o = 0;
|
|
1234
|
+
for (let c2 = s;c2 < r; c2++) {
|
|
1235
|
+
const a = e[c2];
|
|
1236
|
+
if (n = n - a.length, o++, n <= u2)
|
|
1237
|
+
break;
|
|
1238
|
+
}
|
|
1239
|
+
return { lineCount: n, removals: o };
|
|
1240
|
+
};
|
|
1241
|
+
var Y2 = ({ cursor: e, options: i, style: s, output: r = process.stdout, maxItems: u2 = Number.POSITIVE_INFINITY, columnPadding: n = 0, rowPadding: o = 4 }) => {
|
|
1242
|
+
const c2 = O(r) - n, a = A(r), l = t("dim", "..."), $2 = Math.max(a - o, 0), y2 = Math.max(Math.min(u2, $2), 5);
|
|
1243
|
+
let p2 = 0;
|
|
1244
|
+
e >= y2 - 3 && (p2 = Math.max(Math.min(e - y2 + 3, i.length - y2), 0));
|
|
1245
|
+
let m = y2 < i.length && p2 > 0, g = y2 < i.length && p2 + y2 < i.length;
|
|
1246
|
+
const S2 = Math.min(p2 + y2, i.length), h = [];
|
|
1247
|
+
let f = 0;
|
|
1248
|
+
m && f++, g && f++;
|
|
1249
|
+
const v = p2 + (m ? 1 : 0), T2 = S2 - (g ? 1 : 0);
|
|
1250
|
+
for (let b = v;b < T2; b++) {
|
|
1251
|
+
const x = wrapAnsi(s(i[b], b === e), c2, { hard: true, trim: false }).split(`
|
|
1252
|
+
`);
|
|
1253
|
+
h.push(x), f += x.length;
|
|
1254
|
+
}
|
|
1255
|
+
if (f > $2) {
|
|
1256
|
+
let b = 0, x = 0, G2 = f;
|
|
1257
|
+
const M2 = e - v, R2 = (j2, D2) => et2(h, G2, j2, D2, $2);
|
|
1258
|
+
m ? ({ lineCount: G2, removals: b } = R2(0, M2), G2 > $2 && ({ lineCount: G2, removals: x } = R2(M2 + 1, h.length))) : ({ lineCount: G2, removals: x } = R2(M2 + 1, h.length), G2 > $2 && ({ lineCount: G2, removals: b } = R2(0, M2))), b > 0 && (m = true, h.splice(0, b)), x > 0 && (g = true, h.splice(h.length - x, x));
|
|
1259
|
+
}
|
|
1260
|
+
const C2 = [];
|
|
1261
|
+
m && C2.push(l);
|
|
1262
|
+
for (const b of h)
|
|
1263
|
+
for (const x of b)
|
|
1264
|
+
C2.push(x);
|
|
1265
|
+
return g && C2.push(l), C2;
|
|
1266
|
+
};
|
|
1267
|
+
var ot2 = (e) => {
|
|
1268
|
+
const i = e.active ?? "Yes", s = e.inactive ?? "No";
|
|
1269
|
+
return new Q({ active: i, inactive: s, signal: e.signal, input: e.input, output: e.output, initialValue: e.initialValue ?? true, render() {
|
|
1270
|
+
const r = e.withGuide ?? u.withGuide, u2 = `${V2(this.state)} `, n = r ? `${t("gray", d2)} ` : "", o = R(e.output, e.message, n, u2), c2 = `${r ? `${t("gray", d2)}
|
|
1271
|
+
` : ""}${o}
|
|
1272
|
+
`, a = this.value ? i : s;
|
|
1273
|
+
switch (this.state) {
|
|
1274
|
+
case "submit": {
|
|
1275
|
+
const l = r ? `${t("gray", d2)} ` : "";
|
|
1276
|
+
return `${c2}${l}${t("dim", a)}`;
|
|
1277
|
+
}
|
|
1278
|
+
case "cancel": {
|
|
1279
|
+
const l = r ? `${t("gray", d2)} ` : "";
|
|
1280
|
+
return `${c2}${l}${t(["strikethrough", "dim"], a)}${r ? `
|
|
1281
|
+
${t("gray", d2)}` : ""}`;
|
|
1282
|
+
}
|
|
1283
|
+
default: {
|
|
1284
|
+
const l = r ? `${t("cyan", d2)} ` : "", $2 = r ? t("cyan", E2) : "";
|
|
1285
|
+
return `${c2}${l}${this.value ? `${t("green", z2)} ${i}` : `${t("dim", H2)} ${t("dim", i)}`}${e.vertical ? r ? `
|
|
1286
|
+
${t("cyan", d2)} ` : `
|
|
1287
|
+
` : ` ${t("dim", "/")} `}${this.value ? `${t("dim", H2)} ${t("dim", s)}` : `${t("green", z2)} ${s}`}
|
|
1288
|
+
${$2}
|
|
1289
|
+
`;
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
} }).prompt();
|
|
1293
|
+
};
|
|
1294
|
+
var O2 = { message: (e = [], { symbol: i = t("gray", d2), secondarySymbol: s = t("gray", d2), output: r = process.stdout, spacing: u2 = 1, withGuide: n } = {}) => {
|
|
1295
|
+
const o = [], c2 = n ?? u.withGuide, a = c2 ? s : "", l = c2 ? `${i} ` : "", $2 = c2 ? `${s} ` : "";
|
|
1296
|
+
for (let p2 = 0;p2 < u2; p2++)
|
|
1297
|
+
o.push(a);
|
|
1298
|
+
const y2 = Array.isArray(e) ? e : e.split(`
|
|
1299
|
+
`);
|
|
1300
|
+
if (y2.length > 0) {
|
|
1301
|
+
const [p2, ...m] = y2;
|
|
1302
|
+
p2.length > 0 ? o.push(`${l}${p2}`) : o.push(c2 ? i : "");
|
|
1303
|
+
for (const g of m)
|
|
1304
|
+
g.length > 0 ? o.push(`${$2}${g}`) : o.push(c2 ? s : "");
|
|
1305
|
+
}
|
|
1306
|
+
r.write(`${o.join(`
|
|
1307
|
+
`)}
|
|
1308
|
+
`);
|
|
1309
|
+
}, info: (e, i) => {
|
|
1310
|
+
O2.message(e, { ...i, symbol: t("blue", he) });
|
|
1311
|
+
}, success: (e, i) => {
|
|
1312
|
+
O2.message(e, { ...i, symbol: t("green", pe) });
|
|
1313
|
+
}, step: (e, i) => {
|
|
1314
|
+
O2.message(e, { ...i, symbol: t("green", F2) });
|
|
1315
|
+
}, warn: (e, i) => {
|
|
1316
|
+
O2.message(e, { ...i, symbol: t("yellow", me) });
|
|
1317
|
+
}, warning: (e, i) => {
|
|
1318
|
+
O2.warn(e, i);
|
|
1319
|
+
}, error: (e, i) => {
|
|
1320
|
+
O2.message(e, { ...i, symbol: t("red", ge) });
|
|
1321
|
+
} };
|
|
1322
|
+
var pt = (e = "", i) => {
|
|
1323
|
+
const s = i?.output ?? process.stdout, r = i?.withGuide ?? u.withGuide ? `${t("gray", E2)} ` : "";
|
|
1324
|
+
s.write(`${r}${t("red", e)}
|
|
1325
|
+
|
|
1326
|
+
`);
|
|
1327
|
+
};
|
|
1328
|
+
var mt = (e = "", i) => {
|
|
1329
|
+
const s = i?.output ?? process.stdout, r = i?.withGuide ?? u.withGuide ? `${t("gray", le)} ` : "";
|
|
1330
|
+
s.write(`${r}${e}
|
|
1331
|
+
`);
|
|
1332
|
+
};
|
|
1333
|
+
var gt = (e = "", i) => {
|
|
1334
|
+
const s = i?.output ?? process.stdout, r = i?.withGuide ?? u.withGuide ? `${t("gray", d2)}
|
|
1335
|
+
${t("gray", E2)} ` : "";
|
|
1336
|
+
s.write(`${r}${e}
|
|
1337
|
+
|
|
1338
|
+
`);
|
|
1339
|
+
};
|
|
1340
|
+
var Q2 = (e, i) => e.split(`
|
|
1341
|
+
`).map((s) => i(s)).join(`
|
|
1342
|
+
`);
|
|
1343
|
+
var yt = (e) => {
|
|
1344
|
+
const i = (r, u2) => {
|
|
1345
|
+
const n = r.label ?? String(r.value);
|
|
1346
|
+
return u2 === "disabled" ? `${t("gray", J2)} ${Q2(n, (o) => t(["strikethrough", "gray"], o))}${r.hint ? ` ${t("dim", `(${r.hint ?? "disabled"})`)}` : ""}` : u2 === "active" ? `${t("cyan", te)} ${n}${r.hint ? ` ${t("dim", `(${r.hint})`)}` : ""}` : u2 === "selected" ? `${t("green", U)} ${Q2(n, (o) => t("dim", o))}${r.hint ? ` ${t("dim", `(${r.hint})`)}` : ""}` : u2 === "cancelled" ? `${Q2(n, (o) => t(["strikethrough", "dim"], o))}` : u2 === "active-selected" ? `${t("green", U)} ${n}${r.hint ? ` ${t("dim", `(${r.hint})`)}` : ""}` : u2 === "submitted" ? `${Q2(n, (o) => t("dim", o))}` : `${t("dim", J2)} ${Q2(n, (o) => t("dim", o))}`;
|
|
1347
|
+
}, s = e.required ?? true;
|
|
1348
|
+
return new it({ options: e.options, signal: e.signal, input: e.input, output: e.output, initialValues: e.initialValues, required: s, cursorAt: e.cursorAt, validate(r) {
|
|
1349
|
+
if (s && (r === undefined || r.length === 0))
|
|
1350
|
+
return `Please select at least one option.
|
|
1351
|
+
${t("reset", t("dim", `Press ${t(["gray", "bgWhite", "inverse"], " space ")} to select, ${t("gray", t("bgWhite", t("inverse", " enter ")))} to submit`))}`;
|
|
1352
|
+
}, render() {
|
|
1353
|
+
const r = e.withGuide ?? u.withGuide, u2 = R(e.output, e.message, r ? `${ye(this.state)} ` : "", `${V2(this.state)} `), n = `${r ? `${t("gray", d2)}
|
|
1354
|
+
` : ""}${u2}
|
|
1355
|
+
`, o = this.value ?? [], c2 = (a, l) => {
|
|
1356
|
+
if (a.disabled)
|
|
1357
|
+
return i(a, "disabled");
|
|
1358
|
+
const $2 = o.includes(a.value);
|
|
1359
|
+
return l && $2 ? i(a, "active-selected") : $2 ? i(a, "selected") : i(a, l ? "active" : "inactive");
|
|
1360
|
+
};
|
|
1361
|
+
switch (this.state) {
|
|
1362
|
+
case "submit": {
|
|
1363
|
+
const a = this.options.filter(({ value: $2 }) => o.includes($2)).map(($2) => i($2, "submitted")).join(t("dim", ", ")) || t("dim", "none"), l = R(e.output, a, r ? `${t("gray", d2)} ` : "");
|
|
1364
|
+
return `${n}${l}`;
|
|
1365
|
+
}
|
|
1366
|
+
case "cancel": {
|
|
1367
|
+
const a = this.options.filter(({ value: $2 }) => o.includes($2)).map(($2) => i($2, "cancelled")).join(t("dim", ", "));
|
|
1368
|
+
if (a.trim() === "")
|
|
1369
|
+
return `${n}${t("gray", d2)}`;
|
|
1370
|
+
const l = R(e.output, a, r ? `${t("gray", d2)} ` : "");
|
|
1371
|
+
return `${n}${l}${r ? `
|
|
1372
|
+
${t("gray", d2)}` : ""}`;
|
|
1373
|
+
}
|
|
1374
|
+
case "error": {
|
|
1375
|
+
const a = r ? `${t("yellow", d2)} ` : "", l = this.error.split(`
|
|
1376
|
+
`).map((p2, m) => m === 0 ? `${r ? `${t("yellow", E2)} ` : ""}${t("yellow", p2)}` : ` ${p2}`).join(`
|
|
1377
|
+
`), $2 = n.split(`
|
|
1378
|
+
`).length, y2 = l.split(`
|
|
1379
|
+
`).length + 1;
|
|
1380
|
+
return `${n}${a}${Y2({ output: e.output, options: this.options, cursor: this.cursor, maxItems: e.maxItems, columnPadding: a.length, rowPadding: $2 + y2, style: c2 }).join(`
|
|
1381
|
+
${a}`)}
|
|
1382
|
+
${l}
|
|
1383
|
+
`;
|
|
1384
|
+
}
|
|
1385
|
+
default: {
|
|
1386
|
+
const a = r ? `${t("cyan", d2)} ` : "", l = n.split(`
|
|
1387
|
+
`).length, $2 = r ? 2 : 1;
|
|
1388
|
+
return `${n}${a}${Y2({ output: e.output, options: this.options, cursor: this.cursor, maxItems: e.maxItems, columnPadding: a.length, rowPadding: l + $2, style: c2 }).join(`
|
|
1389
|
+
${a}`)}
|
|
1390
|
+
${r ? t("cyan", E2) : ""}
|
|
1391
|
+
`;
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
} }).prompt();
|
|
1395
|
+
};
|
|
1396
|
+
var Ct = (e) => t("magenta", e);
|
|
1397
|
+
var fe = ({ indicator: e = "dots", onCancel: i, output: s = process.stdout, cancelMessage: r, errorMessage: u2, frames: n = ee ? ["◒", "◐", "◓", "◑"] : ["•", "o", "O", "0"], delay: o = ee ? 80 : 120, signal: c2, ...a } = {}) => {
|
|
1398
|
+
const l = ae();
|
|
1399
|
+
let $2, y2, p2 = false, m = false, g = "", S2, h = performance.now();
|
|
1400
|
+
const f = O(s), v = a?.styleFrame ?? Ct, T2 = (_2) => {
|
|
1401
|
+
const A2 = _2 > 1 ? u2 ?? u.messages.error : r ?? u.messages.cancel;
|
|
1402
|
+
m = _2 === 1, p2 && (W2(A2, _2), m && typeof i == "function" && i());
|
|
1403
|
+
}, C2 = () => T2(2), b = () => T2(1), x = () => {
|
|
1404
|
+
process.on("uncaughtExceptionMonitor", C2), process.on("unhandledRejection", C2), process.on("SIGINT", b), process.on("SIGTERM", b), process.on("exit", T2), c2 && c2.addEventListener("abort", b);
|
|
1405
|
+
}, G2 = () => {
|
|
1406
|
+
process.removeListener("uncaughtExceptionMonitor", C2), process.removeListener("unhandledRejection", C2), process.removeListener("SIGINT", b), process.removeListener("SIGTERM", b), process.removeListener("exit", T2), c2 && c2.removeEventListener("abort", b);
|
|
1407
|
+
}, M2 = () => {
|
|
1408
|
+
if (S2 === undefined)
|
|
1409
|
+
return;
|
|
1410
|
+
l && s.write(`
|
|
1411
|
+
`);
|
|
1412
|
+
const _2 = wrapAnsi(S2, f, { hard: true, trim: false }).split(`
|
|
1413
|
+
`);
|
|
1414
|
+
_2.length > 1 && s.write(import_sisteransi2.cursor.up(_2.length - 1)), s.write(import_sisteransi2.cursor.to(0)), s.write(import_sisteransi2.erase.down());
|
|
1415
|
+
}, R2 = (_2) => _2.replace(/\.+$/, ""), j2 = (_2) => {
|
|
1416
|
+
const A2 = (performance.now() - _2) / 1000, k2 = Math.floor(A2 / 60), L2 = Math.floor(A2 % 60);
|
|
1417
|
+
return k2 > 0 ? `[${k2}m ${L2}s]` : `[${L2}s]`;
|
|
1418
|
+
}, D2 = a.withGuide ?? u.withGuide, ie = (_2 = "") => {
|
|
1419
|
+
p2 = true, $2 = z({ output: s }), g = R2(_2), h = performance.now(), D2 && s.write(`${t("gray", d2)}
|
|
1420
|
+
`);
|
|
1421
|
+
let A2 = 0, k2 = 0;
|
|
1422
|
+
x(), y2 = setInterval(() => {
|
|
1423
|
+
if (l && g === S2)
|
|
1424
|
+
return;
|
|
1425
|
+
M2(), S2 = g;
|
|
1426
|
+
const L2 = v(n[A2]);
|
|
1427
|
+
let Z2;
|
|
1428
|
+
if (l)
|
|
1429
|
+
Z2 = `${L2} ${g}...`;
|
|
1430
|
+
else if (e === "timer")
|
|
1431
|
+
Z2 = `${L2} ${g} ${j2(h)}`;
|
|
1432
|
+
else {
|
|
1433
|
+
const Be = ".".repeat(Math.floor(k2)).slice(0, 3);
|
|
1434
|
+
Z2 = `${L2} ${g}${Be}`;
|
|
1435
|
+
}
|
|
1436
|
+
const Ne = wrapAnsi(Z2, f, { hard: true, trim: false });
|
|
1437
|
+
s.write(Ne), A2 = A2 + 1 < n.length ? A2 + 1 : 0, k2 = k2 < 4 ? k2 + 0.125 : 0;
|
|
1438
|
+
}, o);
|
|
1439
|
+
}, W2 = (_2 = "", A2 = 0, k2 = false) => {
|
|
1440
|
+
if (!p2)
|
|
1441
|
+
return;
|
|
1442
|
+
p2 = false, clearInterval(y2), M2();
|
|
1443
|
+
const L2 = A2 === 0 ? t("green", F2) : A2 === 1 ? t("red", oe) : t("red", ue);
|
|
1444
|
+
g = _2 ?? g, k2 || (e === "timer" ? s.write(`${L2} ${g} ${j2(h)}
|
|
1445
|
+
`) : s.write(`${L2} ${g}
|
|
1446
|
+
`)), G2(), $2();
|
|
1447
|
+
};
|
|
1448
|
+
return { start: ie, stop: (_2 = "") => W2(_2, 0), message: (_2 = "") => {
|
|
1449
|
+
g = R2(_2 ?? g);
|
|
1450
|
+
}, cancel: (_2 = "") => W2(_2, 1), error: (_2 = "") => W2(_2, 2), clear: () => W2("", 0, true), get isCancelled() {
|
|
1451
|
+
return m;
|
|
1452
|
+
} };
|
|
1453
|
+
};
|
|
1454
|
+
var Ve = { light: w2("─", "-"), heavy: w2("━", "="), block: w2("█", "#") };
|
|
1455
|
+
var re = (e, i) => e.includes(`
|
|
1456
|
+
`) ? e.split(`
|
|
1457
|
+
`).map((s) => i(s)).join(`
|
|
1458
|
+
`) : i(e);
|
|
1459
|
+
var _t = (e) => {
|
|
1460
|
+
const i = (s, r) => {
|
|
1461
|
+
const u2 = s.label ?? String(s.value);
|
|
1462
|
+
switch (r) {
|
|
1463
|
+
case "disabled":
|
|
1464
|
+
return `${t("gray", H2)} ${re(u2, (n) => t("gray", n))}${s.hint ? ` ${t("dim", `(${s.hint ?? "disabled"})`)}` : ""}`;
|
|
1465
|
+
case "selected":
|
|
1466
|
+
return `${re(u2, (n) => t("dim", n))}`;
|
|
1467
|
+
case "active":
|
|
1468
|
+
return `${t("green", z2)} ${u2}${s.hint ? ` ${t("dim", `(${s.hint})`)}` : ""}`;
|
|
1469
|
+
case "cancelled":
|
|
1470
|
+
return `${re(u2, (n) => t(["strikethrough", "dim"], n))}`;
|
|
1471
|
+
default:
|
|
1472
|
+
return `${t("dim", H2)} ${re(u2, (n) => t("dim", n))}`;
|
|
1473
|
+
}
|
|
1474
|
+
};
|
|
1475
|
+
return new nt({ options: e.options, signal: e.signal, input: e.input, output: e.output, initialValue: e.initialValue, render() {
|
|
1476
|
+
const s = e.withGuide ?? u.withGuide, r = `${V2(this.state)} `, u2 = `${ye(this.state)} `, n = R(e.output, e.message, u2, r), o = `${s ? `${t("gray", d2)}
|
|
1477
|
+
` : ""}${n}
|
|
1478
|
+
`;
|
|
1479
|
+
switch (this.state) {
|
|
1480
|
+
case "submit": {
|
|
1481
|
+
const c2 = s ? `${t("gray", d2)} ` : "", a = R(e.output, i(this.options[this.cursor], "selected"), c2);
|
|
1482
|
+
return `${o}${a}`;
|
|
1483
|
+
}
|
|
1484
|
+
case "cancel": {
|
|
1485
|
+
const c2 = s ? `${t("gray", d2)} ` : "", a = R(e.output, i(this.options[this.cursor], "cancelled"), c2);
|
|
1486
|
+
return `${o}${a}${s ? `
|
|
1487
|
+
${t("gray", d2)}` : ""}`;
|
|
1488
|
+
}
|
|
1489
|
+
default: {
|
|
1490
|
+
const c2 = s ? `${t("cyan", d2)} ` : "", a = s ? t("cyan", E2) : "", l = o.split(`
|
|
1491
|
+
`).length, $2 = s ? 2 : 1;
|
|
1492
|
+
return `${o}${c2}${Y2({ output: e.output, cursor: this.cursor, options: this.options, maxItems: e.maxItems, columnPadding: c2.length, rowPadding: l + $2, style: (y2, p2) => i(y2, y2.disabled ? "disabled" : p2 ? "active" : "inactive") }).join(`
|
|
1493
|
+
${c2}`)}
|
|
1494
|
+
${a}
|
|
1495
|
+
`;
|
|
1496
|
+
}
|
|
1497
|
+
}
|
|
1498
|
+
} }).prompt();
|
|
1499
|
+
};
|
|
1500
|
+
var je = `${t("gray", d2)} `;
|
|
1501
|
+
var Ot = (e) => new at({ validate: e.validate, placeholder: e.placeholder, defaultValue: e.defaultValue, initialValue: e.initialValue, output: e.output, signal: e.signal, input: e.input, render() {
|
|
1502
|
+
const i = e?.withGuide ?? u.withGuide, s = `${`${i ? `${t("gray", d2)}
|
|
1503
|
+
` : ""}${V2(this.state)} `}${e.message}
|
|
1504
|
+
`, r = e.placeholder ? t("inverse", e.placeholder[0]) + t("dim", e.placeholder.slice(1)) : t(["inverse", "hidden"], "_"), u2 = this.userInput ? this.userInputWithCursor : r, n = this.value ?? "";
|
|
1505
|
+
switch (this.state) {
|
|
1506
|
+
case "error": {
|
|
1507
|
+
const o = this.error ? ` ${t("yellow", this.error)}` : "", c2 = i ? `${t("yellow", d2)} ` : "", a = i ? t("yellow", E2) : "";
|
|
1508
|
+
return `${s.trim()}
|
|
1509
|
+
${c2}${u2}
|
|
1510
|
+
${a}${o}
|
|
1511
|
+
`;
|
|
1512
|
+
}
|
|
1513
|
+
case "submit": {
|
|
1514
|
+
const o = n ? ` ${t("dim", n)}` : "", c2 = i ? t("gray", d2) : "";
|
|
1515
|
+
return `${s}${c2}${o}`;
|
|
1516
|
+
}
|
|
1517
|
+
case "cancel": {
|
|
1518
|
+
const o = n ? ` ${t(["strikethrough", "dim"], n)}` : "", c2 = i ? t("gray", d2) : "";
|
|
1519
|
+
return `${s}${c2}${o}${n.trim() ? `
|
|
1520
|
+
${c2}` : ""}`;
|
|
1521
|
+
}
|
|
1522
|
+
default: {
|
|
1523
|
+
const o = i ? `${t("cyan", d2)} ` : "", c2 = i ? t("cyan", E2) : "";
|
|
1524
|
+
return `${s}${o}${u2}
|
|
1525
|
+
${c2}
|
|
1526
|
+
`;
|
|
1527
|
+
}
|
|
1528
|
+
}
|
|
1529
|
+
} }).prompt();
|
|
1530
|
+
|
|
1531
|
+
// src/index.ts
|
|
1532
|
+
var import_picocolors3 = __toESM(require_picocolors(), 1);
|
|
1533
|
+
|
|
1534
|
+
// src/engine/generator.ts
|
|
1535
|
+
import { mkdir, writeFile } from "node:fs/promises";
|
|
1536
|
+
import { join } from "node:path";
|
|
1537
|
+
|
|
1538
|
+
// src/config.ts
|
|
1539
|
+
var VERSIONS = {
|
|
1540
|
+
minEngineVersion: [1, 26, 0],
|
|
1541
|
+
manifestFormat: 2,
|
|
1542
|
+
esbuildFilter: "0.3.0"
|
|
1543
|
+
};
|
|
1544
|
+
var DEFAULT_MINECRAFT_DEPENDENCY_VERSIONS = {
|
|
1545
|
+
server: "2.6.0",
|
|
1546
|
+
serverUi: "2.0.0",
|
|
1547
|
+
vanillaData: "1.26.13",
|
|
1548
|
+
math: "2.4.0"
|
|
1549
|
+
};
|
|
1550
|
+
var DEFAULT_SCRIPT_PACKAGES = {
|
|
1551
|
+
server: true,
|
|
1552
|
+
serverUi: false,
|
|
1553
|
+
vanillaData: false,
|
|
1554
|
+
math: false
|
|
1555
|
+
};
|
|
1556
|
+
function generateProjectId(projectName) {
|
|
1557
|
+
return sanitizeIdentifier(projectName).slice(0, 10) || "sample";
|
|
1558
|
+
}
|
|
1559
|
+
function sanitizeIdentifier(name) {
|
|
1560
|
+
return name.toLowerCase().replace(/[^a-z0-9_-]/g, "_").replace(/_+/g, "_").replace(/^_|_$/g, "");
|
|
1561
|
+
}
|
|
1562
|
+
function getMarketplaceScopeSegments(config) {
|
|
1563
|
+
return config.useMarketplaceStructure ? [config.identifier, config.projectId] : [];
|
|
1564
|
+
}
|
|
1565
|
+
function getMarketplaceScopeLabel(config) {
|
|
1566
|
+
return `${config.identifier}/${config.projectId}`;
|
|
1567
|
+
}
|
|
1568
|
+
function getScriptDirectorySegments(config) {
|
|
1569
|
+
return ["scripts", config.identifier, config.projectId];
|
|
1570
|
+
}
|
|
1571
|
+
function getScriptEntryPath(config) {
|
|
1572
|
+
return [...getScriptDirectorySegments(config), "main.js"].join("/");
|
|
1573
|
+
}
|
|
1574
|
+
|
|
1575
|
+
// src/engine/manifests.ts
|
|
1576
|
+
var PACK_VERSION = [1, 0, 0];
|
|
1577
|
+
function getAuthors(author) {
|
|
1578
|
+
return author.trim() === "" ? [] : [author];
|
|
1579
|
+
}
|
|
1580
|
+
function getScriptDependencies(config, versions) {
|
|
1581
|
+
const dependencies = [];
|
|
1582
|
+
if (config.scriptPackages.server) {
|
|
1583
|
+
dependencies.push({ module_name: "@minecraft/server", version: versions.server });
|
|
1584
|
+
}
|
|
1585
|
+
if (config.scriptPackages.serverUi) {
|
|
1586
|
+
dependencies.push({ module_name: "@minecraft/server-ui", version: versions.serverUi });
|
|
1587
|
+
}
|
|
1588
|
+
if (config.scriptPackages.vanillaData) {
|
|
1589
|
+
dependencies.push({ module_name: "@minecraft/vanilla-data", version: versions.vanillaData });
|
|
1590
|
+
}
|
|
1591
|
+
if (config.scriptPackages.math) {
|
|
1592
|
+
dependencies.push({ module_name: "@minecraft/math", version: versions.math });
|
|
1593
|
+
}
|
|
1594
|
+
return dependencies;
|
|
1595
|
+
}
|
|
1596
|
+
function getBpModules(config) {
|
|
1597
|
+
const modules = [{ type: "data", uuid: crypto.randomUUID(), version: PACK_VERSION }];
|
|
1598
|
+
if (config.scripting !== "none") {
|
|
1599
|
+
modules.push({
|
|
1600
|
+
type: "script",
|
|
1601
|
+
uuid: crypto.randomUUID(),
|
|
1602
|
+
version: PACK_VERSION,
|
|
1603
|
+
language: "javascript",
|
|
1604
|
+
entry: getScriptEntryPath(config)
|
|
1605
|
+
});
|
|
1606
|
+
}
|
|
1607
|
+
return modules;
|
|
1608
|
+
}
|
|
1609
|
+
function generateBpManifest(config, bpUuid, rpUuid, versions) {
|
|
1610
|
+
const dependencies = [{ uuid: rpUuid, version: PACK_VERSION }];
|
|
1611
|
+
if (config.scripting !== "none") {
|
|
1612
|
+
dependencies.push(...getScriptDependencies(config, versions));
|
|
1613
|
+
}
|
|
1614
|
+
return {
|
|
1615
|
+
format_version: VERSIONS.manifestFormat,
|
|
1616
|
+
metadata: {
|
|
1617
|
+
authors: getAuthors(config.author),
|
|
1618
|
+
product_type: "addon"
|
|
1619
|
+
},
|
|
1620
|
+
header: {
|
|
1621
|
+
name: "pack.name",
|
|
1622
|
+
description: "pack.description",
|
|
1623
|
+
pack_scope: "world",
|
|
1624
|
+
uuid: bpUuid,
|
|
1625
|
+
version: PACK_VERSION,
|
|
1626
|
+
min_engine_version: VERSIONS.minEngineVersion
|
|
1627
|
+
},
|
|
1628
|
+
capabilities: ["pbr"],
|
|
1629
|
+
modules: getBpModules(config),
|
|
1630
|
+
dependencies
|
|
1631
|
+
};
|
|
1632
|
+
}
|
|
1633
|
+
function generateRpManifest(config, rpUuid, bpUuid) {
|
|
1634
|
+
return {
|
|
1635
|
+
format_version: VERSIONS.manifestFormat,
|
|
1636
|
+
metadata: {
|
|
1637
|
+
authors: getAuthors(config.author),
|
|
1638
|
+
product_type: "addon"
|
|
1639
|
+
},
|
|
1640
|
+
header: {
|
|
1641
|
+
name: "pack.name",
|
|
1642
|
+
description: "pack.description",
|
|
1643
|
+
pack_scope: "world",
|
|
1644
|
+
uuid: rpUuid,
|
|
1645
|
+
version: PACK_VERSION,
|
|
1646
|
+
min_engine_version: VERSIONS.minEngineVersion
|
|
1647
|
+
},
|
|
1648
|
+
capabilities: ["pbr"],
|
|
1649
|
+
modules: [{ type: "resources", uuid: crypto.randomUUID(), version: PACK_VERSION }],
|
|
1650
|
+
dependencies: [{ uuid: bpUuid, version: PACK_VERSION }]
|
|
1651
|
+
};
|
|
1652
|
+
}
|
|
1653
|
+
|
|
1654
|
+
// src/engine/minecraft-package-versions.ts
|
|
1655
|
+
var PACKAGE_NAMES = {
|
|
1656
|
+
server: "@minecraft/server",
|
|
1657
|
+
serverUi: "@minecraft/server-ui",
|
|
1658
|
+
vanillaData: "@minecraft/vanilla-data",
|
|
1659
|
+
math: "@minecraft/math"
|
|
1660
|
+
};
|
|
1661
|
+
var cachedVersionsPromise;
|
|
1662
|
+
function isStableVersion(version) {
|
|
1663
|
+
return !version.includes("-");
|
|
1664
|
+
}
|
|
1665
|
+
function compareVersions(left, right) {
|
|
1666
|
+
const leftParts = left.split(".").map(Number);
|
|
1667
|
+
const rightParts = right.split(".").map(Number);
|
|
1668
|
+
const length = Math.max(leftParts.length, rightParts.length);
|
|
1669
|
+
for (let index = 0;index < length; index += 1) {
|
|
1670
|
+
const leftPart = leftParts[index] ?? 0;
|
|
1671
|
+
const rightPart = rightParts[index] ?? 0;
|
|
1672
|
+
if (leftPart !== rightPart) {
|
|
1673
|
+
return leftPart - rightPart;
|
|
1674
|
+
}
|
|
1675
|
+
}
|
|
1676
|
+
return 0;
|
|
1677
|
+
}
|
|
1678
|
+
async function fetchLatestStablePackageVersion(packageName, fallbackVersion) {
|
|
1679
|
+
const response = await fetch(`https://registry.npmjs.org/${encodeURIComponent(packageName)}`, {
|
|
1680
|
+
headers: {
|
|
1681
|
+
accept: "application/json"
|
|
1682
|
+
}
|
|
1683
|
+
});
|
|
1684
|
+
if (!response.ok) {
|
|
1685
|
+
return fallbackVersion;
|
|
1686
|
+
}
|
|
1687
|
+
const packument = await response.json();
|
|
1688
|
+
const latestTag = packument["dist-tags"]?.latest;
|
|
1689
|
+
if (typeof latestTag === "string" && isStableVersion(latestTag)) {
|
|
1690
|
+
return latestTag;
|
|
1691
|
+
}
|
|
1692
|
+
const stableVersions = Object.keys(packument.versions ?? {}).filter(isStableVersion);
|
|
1693
|
+
if (stableVersions.length === 0) {
|
|
1694
|
+
return fallbackVersion;
|
|
1695
|
+
}
|
|
1696
|
+
stableVersions.sort(compareVersions);
|
|
1697
|
+
return stableVersions.at(-1) ?? fallbackVersion;
|
|
1698
|
+
}
|
|
1699
|
+
async function resolveLatestVersions() {
|
|
1700
|
+
const [server, serverUi, vanillaData, math] = await Promise.all(Object.entries(PACKAGE_NAMES).map(async ([key, packageName]) => {
|
|
1701
|
+
const fallbackVersion = DEFAULT_MINECRAFT_DEPENDENCY_VERSIONS[key];
|
|
1702
|
+
try {
|
|
1703
|
+
return await fetchLatestStablePackageVersion(packageName, fallbackVersion);
|
|
1704
|
+
} catch {
|
|
1705
|
+
return fallbackVersion;
|
|
1706
|
+
}
|
|
1707
|
+
}));
|
|
1708
|
+
return {
|
|
1709
|
+
server,
|
|
1710
|
+
serverUi,
|
|
1711
|
+
vanillaData,
|
|
1712
|
+
math
|
|
1713
|
+
};
|
|
1714
|
+
}
|
|
1715
|
+
async function getMinecraftDependencyVersions() {
|
|
1716
|
+
cachedVersionsPromise ??= resolveLatestVersions();
|
|
1717
|
+
return await cachedVersionsPromise;
|
|
1718
|
+
}
|
|
1719
|
+
|
|
1720
|
+
// src/engine/templates.ts
|
|
1721
|
+
var PACK_VERSION2 = "1.0.0";
|
|
1722
|
+
function getSelectedScriptDependencies(config, versions) {
|
|
1723
|
+
const dependencies = {};
|
|
1724
|
+
if (config.scriptPackages.server) {
|
|
1725
|
+
dependencies["@minecraft/server"] = versions.server;
|
|
1726
|
+
}
|
|
1727
|
+
if (config.scriptPackages.serverUi) {
|
|
1728
|
+
dependencies["@minecraft/server-ui"] = versions.serverUi;
|
|
1729
|
+
}
|
|
1730
|
+
if (config.scriptPackages.vanillaData) {
|
|
1731
|
+
dependencies["@minecraft/vanilla-data"] = versions.vanillaData;
|
|
1732
|
+
}
|
|
1733
|
+
if (config.scriptPackages.math) {
|
|
1734
|
+
dependencies["@minecraft/math"] = versions.math;
|
|
1735
|
+
}
|
|
1736
|
+
return dependencies;
|
|
1737
|
+
}
|
|
1738
|
+
function generatePackageJson(config, versions) {
|
|
1739
|
+
const scripts = {};
|
|
1740
|
+
if (config.scripting === "typescript") {
|
|
1741
|
+
if (!config.useRgl) {
|
|
1742
|
+
scripts.build = "tsc --project tsconfig.json";
|
|
1743
|
+
}
|
|
1744
|
+
scripts.typecheck = "tsc --project tsconfig.json --noEmit";
|
|
1745
|
+
scripts.format = "dprint fmt";
|
|
1746
|
+
}
|
|
1747
|
+
if (config.scripting === "javascript") {
|
|
1748
|
+
scripts.check = "bun --smol packs/BP/scripts";
|
|
1749
|
+
}
|
|
1750
|
+
const packageJson = {
|
|
1751
|
+
name: `${config.namespace}-${config.projectId}`,
|
|
1752
|
+
version: PACK_VERSION2,
|
|
1753
|
+
private: true,
|
|
1754
|
+
type: "module",
|
|
1755
|
+
scripts,
|
|
1756
|
+
dependencies: getSelectedScriptDependencies(config, versions)
|
|
1757
|
+
};
|
|
1758
|
+
if (config.scripting === "typescript") {
|
|
1759
|
+
packageJson.devDependencies = {
|
|
1760
|
+
dprint: "^0.49.1",
|
|
1761
|
+
typescript: "^5.7.3"
|
|
1762
|
+
};
|
|
1763
|
+
}
|
|
1764
|
+
return packageJson;
|
|
1765
|
+
}
|
|
1766
|
+
function generateTsConfig(config) {
|
|
1767
|
+
const compilerOptions = {
|
|
1768
|
+
target: "ES2020",
|
|
1769
|
+
module: "ES2020",
|
|
1770
|
+
moduleResolution: "bundler",
|
|
1771
|
+
strict: true,
|
|
1772
|
+
noImplicitAny: true,
|
|
1773
|
+
strictNullChecks: true,
|
|
1774
|
+
noImplicitReturns: true,
|
|
1775
|
+
noFallthroughCasesInSwitch: true,
|
|
1776
|
+
noUnusedLocals: true,
|
|
1777
|
+
noUnusedParameters: true,
|
|
1778
|
+
isolatedModules: true,
|
|
1779
|
+
skipLibCheck: true,
|
|
1780
|
+
forceConsistentCasingInFileNames: true,
|
|
1781
|
+
rootDir: "data/scripts",
|
|
1782
|
+
types: []
|
|
1783
|
+
};
|
|
1784
|
+
if (config.useRgl) {
|
|
1785
|
+
compilerOptions.noEmit = true;
|
|
1786
|
+
} else {
|
|
1787
|
+
compilerOptions.outDir = `packs/BP/${getScriptEntryPath(config).replace(/\/main\.js$/, "")}`;
|
|
1788
|
+
}
|
|
1789
|
+
return {
|
|
1790
|
+
compilerOptions,
|
|
1791
|
+
include: ["data/scripts/**/*.ts"]
|
|
1792
|
+
};
|
|
1793
|
+
}
|
|
1794
|
+
function generateDprintConfig() {
|
|
1795
|
+
return {
|
|
1796
|
+
indentWidth: 4,
|
|
1797
|
+
lineWidth: 160,
|
|
1798
|
+
typescript: {
|
|
1799
|
+
deno: true,
|
|
1800
|
+
indentWidth: 4,
|
|
1801
|
+
lineWidth: 160,
|
|
1802
|
+
"module.sortImportDeclarations": "caseSensitive",
|
|
1803
|
+
"importDeclaration.sortNamedImports": "caseSensitive"
|
|
1804
|
+
},
|
|
1805
|
+
excludes: ["**/node_modules", "**/*-lock.json"],
|
|
1806
|
+
plugins: [
|
|
1807
|
+
"https://plugins.dprint.dev/typescript-0.95.12.wasm",
|
|
1808
|
+
"https://plugins.dprint.dev/json-0.21.0.wasm",
|
|
1809
|
+
"https://plugins.dprint.dev/markdown-0.20.0.wasm"
|
|
1810
|
+
]
|
|
1811
|
+
};
|
|
1812
|
+
}
|
|
1813
|
+
function generateRglConfig(config) {
|
|
1814
|
+
return {
|
|
1815
|
+
$schema: "https://raw.githubusercontent.com/ink0rr/rgl-schemas/main/config/v1.0.json",
|
|
1816
|
+
author: config.author,
|
|
1817
|
+
name: config.projectName,
|
|
1818
|
+
packs: {
|
|
1819
|
+
behaviorPack: "./packs/BP",
|
|
1820
|
+
resourcePack: "./packs/RP"
|
|
1821
|
+
},
|
|
1822
|
+
regolith: {
|
|
1823
|
+
dataPath: "./data",
|
|
1824
|
+
filterDefinitions: {
|
|
1825
|
+
esbuild: {
|
|
1826
|
+
url: "github.com/ink0rr/regolith-filters",
|
|
1827
|
+
version: VERSIONS.esbuildFilter
|
|
1828
|
+
}
|
|
1829
|
+
},
|
|
1830
|
+
profiles: {
|
|
1831
|
+
default: {
|
|
1832
|
+
export: { target: "development" },
|
|
1833
|
+
filters: [
|
|
1834
|
+
{
|
|
1835
|
+
filter: "esbuild",
|
|
1836
|
+
settings: {
|
|
1837
|
+
outfile: `./BP/${getScriptEntryPath(config)}`,
|
|
1838
|
+
sourcemap: true,
|
|
1839
|
+
minify: false
|
|
1840
|
+
}
|
|
1841
|
+
}
|
|
1842
|
+
]
|
|
1843
|
+
},
|
|
1844
|
+
build: {
|
|
1845
|
+
export: { target: "local" },
|
|
1846
|
+
filters: [
|
|
1847
|
+
{
|
|
1848
|
+
filter: "esbuild",
|
|
1849
|
+
settings: {
|
|
1850
|
+
outfile: `./BP/${getScriptEntryPath(config)}`,
|
|
1851
|
+
minify: true
|
|
1852
|
+
}
|
|
1853
|
+
}
|
|
1854
|
+
]
|
|
1855
|
+
}
|
|
1856
|
+
}
|
|
1857
|
+
}
|
|
1858
|
+
};
|
|
1859
|
+
}
|
|
1860
|
+
function generateMainTs(config) {
|
|
1861
|
+
return `import { world } from "@minecraft/server";
|
|
1862
|
+
|
|
1863
|
+
world.afterEvents.worldLoad.subscribe(() => {
|
|
1864
|
+
console.warn("[${config.namespace}:${config.identifier}] Addon loaded!");
|
|
1865
|
+
});
|
|
1866
|
+
`;
|
|
1867
|
+
}
|
|
1868
|
+
function generateMainJs(config) {
|
|
1869
|
+
return `import { world } from "@minecraft/server";
|
|
1870
|
+
|
|
1871
|
+
world.afterEvents.worldLoad.subscribe(() => {
|
|
1872
|
+
console.warn("[${config.namespace}:${config.identifier}] Addon loaded!");
|
|
1873
|
+
});
|
|
1874
|
+
`;
|
|
1875
|
+
}
|
|
1876
|
+
function generateLangFile(projectName, packType) {
|
|
1877
|
+
const suffix = packType === "behavior" ? "Behavior Pack" : "Resource Pack";
|
|
1878
|
+
return `pack.name=${projectName} ${suffix}
|
|
1879
|
+
pack.description=Generated with Spawnpack
|
|
1880
|
+
`;
|
|
1881
|
+
}
|
|
1882
|
+
function generateGitignore() {
|
|
1883
|
+
return `node_modules/
|
|
1884
|
+
dist/
|
|
1885
|
+
.logs/
|
|
1886
|
+
*.zip
|
|
1887
|
+
`;
|
|
1888
|
+
}
|
|
1889
|
+
function generateReadme(config) {
|
|
1890
|
+
const scriptSource = config.scripting === "none" ? "None" : config.scripting === "typescript" ? "data/scripts/main.ts" : `packs/BP/${getScriptEntryPath(config)}`;
|
|
1891
|
+
const runtimeEntry = config.scripting === "none" ? "None" : `packs/BP/${getScriptEntryPath(config)}`;
|
|
1892
|
+
const installStep = config.scripting !== "none" ? "1. Install dependencies with `bun install` or `npm install`." : "1. No package install is required for this scaffold.";
|
|
1893
|
+
const buildSteps = config.scripting === "none" ? "2. Edit your BP/RP JSON files directly inside `packs/`." : config.useRgl ? "2. Run `rgl watch` while developing to rebuild and export your add-on automatically.\n3. Run `rgl run build` when you want a production build." : config.scripting === "typescript" ? "2. Write your gameplay scripts in `data/scripts/`.\n3. Run `bun run build` or `npm run build` to compile TypeScript into `packs/BP/scripts/`." : "2. Write your gameplay scripts in `packs/BP/scripts/` and let Minecraft copy the pack into `com.mojang`.";
|
|
1894
|
+
const aiSection = config.useAi ? `## AI Tooling
|
|
1895
|
+
|
|
1896
|
+
Spawnpack generated \`CLAUDE.md\` and \`.mcp.json\` for AI-assisted development.
|
|
1897
|
+
|
|
1898
|
+
Add your own API keys before using the MCP tools:
|
|
1899
|
+
|
|
1900
|
+
- Exa API keys: https://dashboard.exa.ai/api-keys
|
|
1901
|
+
- Exa API key docs: https://exa.ai/docs/reference/team-management/create-api-key
|
|
1902
|
+
- Hyperbrowser signup: https://app.hyperbrowser.ai/signup
|
|
1903
|
+
- Hyperbrowser quickstart: https://hyperbrowser.ai/docs/quickstart
|
|
1904
|
+
|
|
1905
|
+
Update the placeholder values in \`.mcp.json\` with your own tokens.
|
|
1906
|
+
|
|
1907
|
+
` : "";
|
|
1908
|
+
return `# ${config.projectName}
|
|
1909
|
+
|
|
1910
|
+
## Overview
|
|
1911
|
+
|
|
1912
|
+
- Behavior Pack: \`packs/BP\`
|
|
1913
|
+
- Resource Pack: \`packs/RP\`
|
|
1914
|
+
- Scripting: ${config.scripting}
|
|
1915
|
+
- Script source: ${scriptSource}
|
|
1916
|
+
- Runtime entry: ${runtimeEntry}
|
|
1917
|
+
|
|
1918
|
+
## Getting Started
|
|
1919
|
+
|
|
1920
|
+
${installStep}
|
|
1921
|
+
${buildSteps}
|
|
1922
|
+
|
|
1923
|
+
## Working with Scripts
|
|
1924
|
+
|
|
1925
|
+
${config.scripting === "none" ? "This project was generated without Script API support. Add scripting later if you need gameplay logic." : config.scripting === "typescript" ? `- Write your TypeScript entrypoint in \`data/scripts/main.ts\`.
|
|
1926
|
+
- Add more TypeScript files anywhere under \`data/scripts/\` and import them from \`main.ts\`.
|
|
1927
|
+
- rgl compiles your TypeScript from \`data/scripts/\` into \`${runtimeEntry}\`.` : `- Write your JavaScript entrypoint directly in \`${runtimeEntry}\`.
|
|
1928
|
+
- Add additional JavaScript files beside \`main.js\` and import them from there.
|
|
1929
|
+
- Minecraft copies the BP/RP content directly into \`com.mojang\`, so there is no TypeScript compile step.`}
|
|
1930
|
+
|
|
1931
|
+
${config.useRgl ? `## rgl Workflow
|
|
1932
|
+
|
|
1933
|
+
- \`rgl watch\` rebuilds your scripts and exports your add-on while you work.
|
|
1934
|
+
- \`rgl run\` builds a development export once.
|
|
1935
|
+
- \`rgl run build\` creates a production-ready build.
|
|
1936
|
+
|
|
1937
|
+
The generated \`config.json\` already points the script bundle to \`${runtimeEntry}\`.
|
|
1938
|
+
|
|
1939
|
+
` : ""}${aiSection}---
|
|
1940
|
+
|
|
1941
|
+
<sub>Generated with Spawnpack</sub>
|
|
1942
|
+
`;
|
|
1943
|
+
}
|
|
1944
|
+
function generateBlocksJson() {
|
|
1945
|
+
return {};
|
|
1946
|
+
}
|
|
1947
|
+
function generateSoundsJson() {
|
|
1948
|
+
return {};
|
|
1949
|
+
}
|
|
1950
|
+
function generateSoundDefinitions() {
|
|
1951
|
+
return { format_version: "1.14.0", sound_definitions: {} };
|
|
1952
|
+
}
|
|
1953
|
+
function generateItemTexture(config) {
|
|
1954
|
+
return {
|
|
1955
|
+
resource_pack_name: config.projectName,
|
|
1956
|
+
texture_name: "atlas.items",
|
|
1957
|
+
texture_data: {}
|
|
1958
|
+
};
|
|
1959
|
+
}
|
|
1960
|
+
function generateTerrainTexture(config) {
|
|
1961
|
+
return {
|
|
1962
|
+
resource_pack_name: config.projectName,
|
|
1963
|
+
texture_name: "atlas.terrain",
|
|
1964
|
+
texture_data: {},
|
|
1965
|
+
num_mip_levels: 4,
|
|
1966
|
+
padding: 8
|
|
1967
|
+
};
|
|
1968
|
+
}
|
|
1969
|
+
|
|
1970
|
+
// src/engine/generator.ts
|
|
1971
|
+
var BP_NAMESPACED_DIRECTORIES = [
|
|
1972
|
+
"animation_controllers",
|
|
1973
|
+
"animations",
|
|
1974
|
+
"blocks",
|
|
1975
|
+
"entities",
|
|
1976
|
+
"items",
|
|
1977
|
+
"loot_tables",
|
|
1978
|
+
"recipes",
|
|
1979
|
+
"spawn_rules",
|
|
1980
|
+
"structures",
|
|
1981
|
+
"trading"
|
|
1982
|
+
];
|
|
1983
|
+
var RP_NAMESPACED_DIRECTORIES = [
|
|
1984
|
+
"animation_controllers",
|
|
1985
|
+
"animations",
|
|
1986
|
+
"attachables",
|
|
1987
|
+
"entity",
|
|
1988
|
+
"fogs",
|
|
1989
|
+
"particles",
|
|
1990
|
+
"render_controllers",
|
|
1991
|
+
"sounds",
|
|
1992
|
+
"ui"
|
|
1993
|
+
];
|
|
1994
|
+
var RP_NAMESPACED_NESTED_DIRECTORIES = [
|
|
1995
|
+
["models", "entity"],
|
|
1996
|
+
["textures", "blocks"],
|
|
1997
|
+
["textures", "entity"],
|
|
1998
|
+
["textures", "items"]
|
|
1999
|
+
];
|
|
2000
|
+
function stringifyJson(value) {
|
|
2001
|
+
return `${JSON.stringify(value, null, 4)}
|
|
2002
|
+
`;
|
|
2003
|
+
}
|
|
2004
|
+
async function writeJsonFile(filePath, value) {
|
|
2005
|
+
await writeFile(filePath, stringifyJson(value), "utf8");
|
|
2006
|
+
}
|
|
2007
|
+
async function writeTextFile(filePath, value) {
|
|
2008
|
+
await writeFile(filePath, value, "utf8");
|
|
2009
|
+
}
|
|
2010
|
+
function getScopedContentDirectory(basePath, folder, config) {
|
|
2011
|
+
return join(basePath, folder, ...getMarketplaceScopeSegments(config));
|
|
2012
|
+
}
|
|
2013
|
+
function getScopedNestedContentDirectory(basePath, segments, config) {
|
|
2014
|
+
return join(basePath, ...segments, ...getMarketplaceScopeSegments(config));
|
|
2015
|
+
}
|
|
2016
|
+
async function generateProject(config) {
|
|
2017
|
+
const destination = config.destination;
|
|
2018
|
+
const bpPath = join(destination, "packs", "BP");
|
|
2019
|
+
const rpPath = join(destination, "packs", "RP");
|
|
2020
|
+
const bpScriptPath = join(bpPath, ...getScriptDirectorySegments(config));
|
|
2021
|
+
const dataScriptsPath = join(destination, "data", "scripts");
|
|
2022
|
+
const directories = [
|
|
2023
|
+
destination,
|
|
2024
|
+
join(destination, "packs"),
|
|
2025
|
+
bpPath,
|
|
2026
|
+
join(bpPath, "animation_controllers"),
|
|
2027
|
+
join(bpPath, "animations"),
|
|
2028
|
+
join(bpPath, "blocks"),
|
|
2029
|
+
join(bpPath, "entities"),
|
|
2030
|
+
join(bpPath, "items"),
|
|
2031
|
+
join(bpPath, "loot_tables"),
|
|
2032
|
+
join(bpPath, "recipes"),
|
|
2033
|
+
join(bpPath, "spawn_rules"),
|
|
2034
|
+
join(bpPath, "structures"),
|
|
2035
|
+
join(bpPath, "texts"),
|
|
2036
|
+
join(bpPath, "trading"),
|
|
2037
|
+
rpPath,
|
|
2038
|
+
join(rpPath, "animation_controllers"),
|
|
2039
|
+
join(rpPath, "animations"),
|
|
2040
|
+
join(rpPath, "attachables"),
|
|
2041
|
+
join(rpPath, "entity"),
|
|
2042
|
+
join(rpPath, "fogs"),
|
|
2043
|
+
join(rpPath, "models"),
|
|
2044
|
+
join(rpPath, "models", "entity"),
|
|
2045
|
+
join(rpPath, "particles"),
|
|
2046
|
+
join(rpPath, "render_controllers"),
|
|
2047
|
+
join(rpPath, "sounds"),
|
|
2048
|
+
join(rpPath, "texts"),
|
|
2049
|
+
join(rpPath, "textures"),
|
|
2050
|
+
join(rpPath, "textures", "blocks"),
|
|
2051
|
+
join(rpPath, "textures", "entity"),
|
|
2052
|
+
join(rpPath, "textures", "items"),
|
|
2053
|
+
join(rpPath, "ui")
|
|
2054
|
+
];
|
|
2055
|
+
if (config.useMarketplaceStructure) {
|
|
2056
|
+
directories.push(...BP_NAMESPACED_DIRECTORIES.map((folder) => getScopedContentDirectory(bpPath, folder, config)), ...RP_NAMESPACED_DIRECTORIES.map((folder) => getScopedContentDirectory(rpPath, folder, config)), ...RP_NAMESPACED_NESTED_DIRECTORIES.map((segments) => getScopedNestedContentDirectory(rpPath, segments, config)));
|
|
2057
|
+
}
|
|
2058
|
+
if (config.scripting === "javascript") {
|
|
2059
|
+
directories.push(join(bpPath, "scripts"), join(bpPath, "scripts", config.namespace), bpScriptPath);
|
|
2060
|
+
}
|
|
2061
|
+
if (config.scripting === "typescript") {
|
|
2062
|
+
directories.push(join(destination, "data"), dataScriptsPath);
|
|
2063
|
+
if (!config.useRgl) {
|
|
2064
|
+
directories.push(join(bpPath, "scripts"), join(bpPath, "scripts", config.namespace), bpScriptPath);
|
|
2065
|
+
}
|
|
2066
|
+
}
|
|
2067
|
+
await Promise.all(directories.map((directory) => mkdir(directory, { recursive: true })));
|
|
2068
|
+
const bpUuid = crypto.randomUUID();
|
|
2069
|
+
const rpUuid = crypto.randomUUID();
|
|
2070
|
+
const versions = await getMinecraftDependencyVersions();
|
|
2071
|
+
const writes = [
|
|
2072
|
+
writeJsonFile(join(bpPath, "manifest.json"), generateBpManifest(config, bpUuid, rpUuid, versions)),
|
|
2073
|
+
writeJsonFile(join(rpPath, "manifest.json"), generateRpManifest(config, rpUuid, bpUuid)),
|
|
2074
|
+
writeTextFile(join(bpPath, "texts", "en_US.lang"), generateLangFile(config.projectName, "behavior")),
|
|
2075
|
+
writeTextFile(join(rpPath, "texts", "en_US.lang"), generateLangFile(config.projectName, "resource")),
|
|
2076
|
+
writeJsonFile(join(rpPath, "blocks.json"), generateBlocksJson()),
|
|
2077
|
+
writeJsonFile(join(rpPath, "sounds.json"), generateSoundsJson()),
|
|
2078
|
+
writeJsonFile(join(rpPath, "sounds", "sound_definitions.json"), generateSoundDefinitions()),
|
|
2079
|
+
writeJsonFile(join(rpPath, "textures", "item_texture.json"), generateItemTexture(config)),
|
|
2080
|
+
writeJsonFile(join(rpPath, "textures", "terrain_texture.json"), generateTerrainTexture(config)),
|
|
2081
|
+
writeTextFile(join(rpPath, "textures", "flipbook_textures.json"), "[]"),
|
|
2082
|
+
writeTextFile(join(bpPath, "texts", "languages.json"), '["en_US"]'),
|
|
2083
|
+
writeTextFile(join(rpPath, "texts", "languages.json"), '["en_US"]'),
|
|
2084
|
+
writeTextFile(join(destination, ".gitignore"), generateGitignore()),
|
|
2085
|
+
writeTextFile(join(destination, "README.md"), generateReadme(config))
|
|
2086
|
+
];
|
|
2087
|
+
if (config.scripting !== "none") {
|
|
2088
|
+
writes.push(writeJsonFile(join(destination, "package.json"), generatePackageJson(config, versions)));
|
|
2089
|
+
}
|
|
2090
|
+
if (config.scripting === "javascript") {
|
|
2091
|
+
writes.push(writeTextFile(join(bpScriptPath, "main.js"), generateMainJs(config)));
|
|
2092
|
+
}
|
|
2093
|
+
if (config.scripting === "typescript") {
|
|
2094
|
+
writes.push(writeJsonFile(join(destination, "tsconfig.json"), generateTsConfig(config)), writeJsonFile(join(destination, "dprint.json"), generateDprintConfig()), writeTextFile(join(dataScriptsPath, "main.ts"), generateMainTs(config)));
|
|
2095
|
+
}
|
|
2096
|
+
if (config.scripting !== "none" && config.useRgl) {
|
|
2097
|
+
writes.push(writeJsonFile(join(destination, "config.json"), generateRglConfig(config)));
|
|
2098
|
+
}
|
|
2099
|
+
await Promise.all(writes);
|
|
2100
|
+
}
|
|
2101
|
+
|
|
2102
|
+
// src/provisioning/ai.ts
|
|
2103
|
+
import { mkdir as mkdir2 } from "node:fs/promises";
|
|
2104
|
+
import { join as join3 } from "node:path";
|
|
2105
|
+
|
|
2106
|
+
// src/provisioning/mcp.ts
|
|
2107
|
+
import { join as join2 } from "node:path";
|
|
2108
|
+
function buildMcpServers() {
|
|
2109
|
+
return {
|
|
2110
|
+
exa: {
|
|
2111
|
+
command: "npx",
|
|
2112
|
+
args: ["-y", "exa-mcp-server"],
|
|
2113
|
+
env: {
|
|
2114
|
+
EXA_API_KEY: "YOUR_EXA_API_KEY"
|
|
2115
|
+
}
|
|
2116
|
+
},
|
|
2117
|
+
hyperbrowser: {
|
|
2118
|
+
command: "npx",
|
|
2119
|
+
args: ["-y", "hyperbrowser-mcp"],
|
|
2120
|
+
env: {
|
|
2121
|
+
HYPERBROWSER_API_KEY: "YOUR_HYPERBROWSER_API_KEY"
|
|
2122
|
+
}
|
|
2123
|
+
},
|
|
2124
|
+
"sequential-thinking": {
|
|
2125
|
+
command: "npx",
|
|
2126
|
+
args: ["-y", "@modelcontextprotocol/server-sequential-thinking"]
|
|
2127
|
+
},
|
|
2128
|
+
serena: {
|
|
2129
|
+
command: "uvx",
|
|
2130
|
+
args: [
|
|
2131
|
+
"--from",
|
|
2132
|
+
"git+https://github.com/oraios/serena",
|
|
2133
|
+
"serena",
|
|
2134
|
+
"start-mcp-server",
|
|
2135
|
+
"--context",
|
|
2136
|
+
"ide-assistant"
|
|
2137
|
+
]
|
|
2138
|
+
},
|
|
2139
|
+
grep_app: {
|
|
2140
|
+
command: "npx",
|
|
2141
|
+
args: ["-y", "grep-mcp"]
|
|
2142
|
+
},
|
|
2143
|
+
context7: {
|
|
2144
|
+
command: "npx",
|
|
2145
|
+
args: ["-y", "@upstash/context7-mcp"]
|
|
2146
|
+
}
|
|
2147
|
+
};
|
|
2148
|
+
}
|
|
2149
|
+
async function generateMcpConfig(projectPath) {
|
|
2150
|
+
const mcpPath = join2(projectPath, ".mcp.json");
|
|
2151
|
+
const config = { mcpServers: buildMcpServers() };
|
|
2152
|
+
await Bun.write(mcpPath, JSON.stringify(config, null, 2) + `
|
|
2153
|
+
`).then(() => {
|
|
2154
|
+
return;
|
|
2155
|
+
}, () => {
|
|
2156
|
+
return;
|
|
2157
|
+
});
|
|
2158
|
+
}
|
|
2159
|
+
|
|
2160
|
+
// src/provisioning/ai.ts
|
|
2161
|
+
var AI_EXCLUDE_LINES = [
|
|
2162
|
+
"# AI tool files",
|
|
2163
|
+
"CLAUDE.md",
|
|
2164
|
+
"AGENTS.md",
|
|
2165
|
+
".mcp.json",
|
|
2166
|
+
".claude/",
|
|
2167
|
+
".serena/"
|
|
2168
|
+
];
|
|
2169
|
+
var CLAUDE_TEMPLATE_URLS = [
|
|
2170
|
+
new URL("../templates/CLAUDE.md", import.meta.url),
|
|
2171
|
+
new URL("../../templates/CLAUDE.md", import.meta.url)
|
|
2172
|
+
];
|
|
2173
|
+
async function createClaudeMdContent() {
|
|
2174
|
+
for (const templateUrl of CLAUDE_TEMPLATE_URLS) {
|
|
2175
|
+
const templateFile = Bun.file(templateUrl);
|
|
2176
|
+
const exists = await templateFile.exists().then((value) => value, () => false);
|
|
2177
|
+
if (exists) {
|
|
2178
|
+
return await templateFile.text();
|
|
2179
|
+
}
|
|
2180
|
+
}
|
|
2181
|
+
return await Bun.file(CLAUDE_TEMPLATE_URLS[0]).text();
|
|
2182
|
+
}
|
|
2183
|
+
async function generateClaudeMd(projectPath) {
|
|
2184
|
+
const claudePath = join3(projectPath, "CLAUDE.md");
|
|
2185
|
+
const content = await createClaudeMdContent();
|
|
2186
|
+
await Bun.write(claudePath, content).then(() => {
|
|
2187
|
+
return;
|
|
2188
|
+
}, () => {
|
|
2189
|
+
return;
|
|
2190
|
+
});
|
|
2191
|
+
}
|
|
2192
|
+
async function setupGitExcludes(projectPath) {
|
|
2193
|
+
const gitInfoPath = join3(projectPath, ".git", "info");
|
|
2194
|
+
const excludePath = join3(gitInfoPath, "exclude");
|
|
2195
|
+
const directoryReady = await mkdir2(gitInfoPath, { recursive: true }).then(() => true, () => false);
|
|
2196
|
+
if (!directoryReady) {
|
|
2197
|
+
return;
|
|
2198
|
+
}
|
|
2199
|
+
const excludeFile = Bun.file(excludePath);
|
|
2200
|
+
const excludeExists = await excludeFile.exists().then((exists) => exists, () => false);
|
|
2201
|
+
const existingContent = excludeExists ? await excludeFile.text().then((content) => content, () => "") : "";
|
|
2202
|
+
const existingLines = new Set(existingContent.split(/\r?\n/));
|
|
2203
|
+
const missingLines = AI_EXCLUDE_LINES.filter((line) => !existingLines.has(line));
|
|
2204
|
+
if (missingLines.length === 0) {
|
|
2205
|
+
return;
|
|
2206
|
+
}
|
|
2207
|
+
const separator = existingContent.length > 0 && !existingContent.endsWith(`
|
|
2208
|
+
`) ? `
|
|
2209
|
+
` : "";
|
|
2210
|
+
const nextContent = `${existingContent}${separator}${missingLines.join(`
|
|
2211
|
+
`)}
|
|
2212
|
+
`;
|
|
2213
|
+
await Bun.write(excludePath, nextContent).then(() => {
|
|
2214
|
+
return;
|
|
2215
|
+
}, () => {
|
|
2216
|
+
return;
|
|
2217
|
+
});
|
|
2218
|
+
}
|
|
2219
|
+
async function setupAi(projectPath) {
|
|
2220
|
+
await generateClaudeMd(projectPath);
|
|
2221
|
+
await setupGitExcludes(projectPath);
|
|
2222
|
+
await generateMcpConfig(projectPath);
|
|
2223
|
+
}
|
|
2224
|
+
|
|
2225
|
+
// src/provisioning/tools.ts
|
|
2226
|
+
import { join as join4 } from "node:path";
|
|
2227
|
+
function runCommand(command, cwd) {
|
|
2228
|
+
return Promise.resolve().then(() => Bun.spawn({
|
|
2229
|
+
cmd: command,
|
|
2230
|
+
cwd,
|
|
2231
|
+
stdout: "pipe",
|
|
2232
|
+
stderr: "pipe"
|
|
2233
|
+
})).then((process2) => process2.exited.then((code) => code === 0, () => false), () => false);
|
|
2234
|
+
}
|
|
2235
|
+
async function isCommandAvailable(command) {
|
|
2236
|
+
const lookupCommand = process.platform === "win32" ? ["where", command] : ["which", command];
|
|
2237
|
+
return runCommand(lookupCommand);
|
|
2238
|
+
}
|
|
2239
|
+
async function installRgl() {
|
|
2240
|
+
if (await isCommandAvailable("rgl")) {
|
|
2241
|
+
return true;
|
|
2242
|
+
}
|
|
2243
|
+
if (process.platform !== "win32") {
|
|
2244
|
+
return false;
|
|
2245
|
+
}
|
|
2246
|
+
const installed = await runCommand([
|
|
2247
|
+
"powershell",
|
|
2248
|
+
"-Command",
|
|
2249
|
+
"irm rgl.ink0rr.dev/install.ps1 | iex"
|
|
2250
|
+
]);
|
|
2251
|
+
if (!installed) {
|
|
2252
|
+
return false;
|
|
2253
|
+
}
|
|
2254
|
+
return isCommandAvailable("rgl");
|
|
2255
|
+
}
|
|
2256
|
+
async function installRockide() {
|
|
2257
|
+
if (await isCommandAvailable("code")) {
|
|
2258
|
+
return runCommand([
|
|
2259
|
+
"code",
|
|
2260
|
+
"--install-extension",
|
|
2261
|
+
"rockide.rockide-vscode"
|
|
2262
|
+
]);
|
|
2263
|
+
}
|
|
2264
|
+
if (await isCommandAvailable("cursor")) {
|
|
2265
|
+
return runCommand([
|
|
2266
|
+
"cursor",
|
|
2267
|
+
"--install-extension",
|
|
2268
|
+
"rockide.rockide-vscode"
|
|
2269
|
+
]);
|
|
2270
|
+
}
|
|
2271
|
+
return false;
|
|
2272
|
+
}
|
|
2273
|
+
async function installDependencies(projectPath) {
|
|
2274
|
+
const pkgPath = join4(projectPath, "package.json");
|
|
2275
|
+
const pkgExists = await Bun.file(pkgPath).exists();
|
|
2276
|
+
if (!pkgExists) {
|
|
2277
|
+
return true;
|
|
2278
|
+
}
|
|
2279
|
+
const command = await isCommandAvailable("bun") ? ["bun", "install"] : ["npm", "install"];
|
|
2280
|
+
return runCommand(command, projectPath);
|
|
2281
|
+
}
|
|
2282
|
+
async function runProvisioning(config) {
|
|
2283
|
+
const results = {
|
|
2284
|
+
rgl: null,
|
|
2285
|
+
rockide: null,
|
|
2286
|
+
dependencies: null
|
|
2287
|
+
};
|
|
2288
|
+
if (config.useRgl) {
|
|
2289
|
+
results.rgl = await installRgl();
|
|
2290
|
+
}
|
|
2291
|
+
if (config.installRockide) {
|
|
2292
|
+
results.rockide = await installRockide();
|
|
2293
|
+
}
|
|
2294
|
+
if (config.scripting !== "none") {
|
|
2295
|
+
results.dependencies = await installDependencies(config.destination);
|
|
2296
|
+
}
|
|
2297
|
+
return results;
|
|
2298
|
+
}
|
|
2299
|
+
|
|
2300
|
+
// src/tui/display.ts
|
|
2301
|
+
var import_picocolors = __toESM(require_picocolors(), 1);
|
|
2302
|
+
var teal = (value) => `\x1B[38;2;47;208;181m${value}\x1B[39m`;
|
|
2303
|
+
function bgTeal(value) {
|
|
2304
|
+
return `\x1B[48;2;47;208;181m${value}\x1B[49m`;
|
|
2305
|
+
}
|
|
2306
|
+
function whiteOnTeal(value) {
|
|
2307
|
+
return bgTeal(`\x1B[97m${value}\x1B[39m`);
|
|
2308
|
+
}
|
|
2309
|
+
function getScriptingLabel(choice) {
|
|
2310
|
+
if (choice === "typescript") {
|
|
2311
|
+
return "TypeScript";
|
|
2312
|
+
}
|
|
2313
|
+
if (choice === "javascript") {
|
|
2314
|
+
return "JavaScript";
|
|
2315
|
+
}
|
|
2316
|
+
return "None";
|
|
2317
|
+
}
|
|
2318
|
+
function getSelectedPackages(scriptPackages) {
|
|
2319
|
+
const packages = [];
|
|
2320
|
+
if (scriptPackages.server) {
|
|
2321
|
+
packages.push("@minecraft/server");
|
|
2322
|
+
}
|
|
2323
|
+
if (scriptPackages.serverUi) {
|
|
2324
|
+
packages.push("@minecraft/server-ui");
|
|
2325
|
+
}
|
|
2326
|
+
if (scriptPackages.vanillaData) {
|
|
2327
|
+
packages.push("@minecraft/vanilla-data");
|
|
2328
|
+
}
|
|
2329
|
+
if (scriptPackages.math) {
|
|
2330
|
+
packages.push("@minecraft/math");
|
|
2331
|
+
}
|
|
2332
|
+
return packages;
|
|
2333
|
+
}
|
|
2334
|
+
function formatValue(value) {
|
|
2335
|
+
return import_picocolors.default.bold(import_picocolors.default.white(value));
|
|
2336
|
+
}
|
|
2337
|
+
function formatToggle(enabled) {
|
|
2338
|
+
return enabled ? import_picocolors.default.green("Yes") : import_picocolors.default.dim("No");
|
|
2339
|
+
}
|
|
2340
|
+
function padLabel(label) {
|
|
2341
|
+
return label.padEnd(22, " ");
|
|
2342
|
+
}
|
|
2343
|
+
function getTreeRoot(config) {
|
|
2344
|
+
const destination = config.destination.trim();
|
|
2345
|
+
if (destination === "." || destination === "./") {
|
|
2346
|
+
return ".";
|
|
2347
|
+
}
|
|
2348
|
+
return destination.replace(/[\\/]+$/, "");
|
|
2349
|
+
}
|
|
2350
|
+
function pushScopedFolder(lines, prefix, folder, config) {
|
|
2351
|
+
lines.push(import_picocolors.default.dim(`${prefix}${folder}/`));
|
|
2352
|
+
if (config.useMarketplaceStructure) {
|
|
2353
|
+
lines.push(import_picocolors.default.dim(`${prefix}└─ ${getMarketplaceScopeLabel(config)}/`));
|
|
2354
|
+
}
|
|
2355
|
+
}
|
|
2356
|
+
function showFolderTree(config) {
|
|
2357
|
+
const lines = [import_picocolors.default.bold(import_picocolors.default.white(getTreeRoot(config)))];
|
|
2358
|
+
lines.push(import_picocolors.default.dim("├─ packs/"));
|
|
2359
|
+
lines.push(import_picocolors.default.dim("│ ├─ BP/"));
|
|
2360
|
+
pushScopedFolder(lines, "│ │ ├─ ", "animation_controllers", config);
|
|
2361
|
+
pushScopedFolder(lines, "│ │ ├─ ", "animations", config);
|
|
2362
|
+
pushScopedFolder(lines, "│ │ ├─ ", "blocks", config);
|
|
2363
|
+
pushScopedFolder(lines, "│ │ ├─ ", "entities", config);
|
|
2364
|
+
pushScopedFolder(lines, "│ │ ├─ ", "items", config);
|
|
2365
|
+
pushScopedFolder(lines, "│ │ ├─ ", "loot_tables", config);
|
|
2366
|
+
pushScopedFolder(lines, "│ │ ├─ ", "recipes", config);
|
|
2367
|
+
pushScopedFolder(lines, "│ │ ├─ ", "spawn_rules", config);
|
|
2368
|
+
pushScopedFolder(lines, "│ │ ├─ ", "structures", config);
|
|
2369
|
+
lines.push(import_picocolors.default.dim("│ │ ├─ texts/"));
|
|
2370
|
+
pushScopedFolder(lines, "│ │ ├─ ", "trading", config);
|
|
2371
|
+
if (config.scripting === "javascript" || config.scripting === "typescript" && !config.useRgl) {
|
|
2372
|
+
lines.push(import_picocolors.default.dim(`│ │ ├─ scripts/${config.namespace}/${config.projectId}/`));
|
|
2373
|
+
}
|
|
2374
|
+
lines.push(import_picocolors.default.dim("│ │ └─ manifest.json"));
|
|
2375
|
+
lines.push(import_picocolors.default.dim("│ └─ RP/"));
|
|
2376
|
+
pushScopedFolder(lines, "│ ├─ ", "animation_controllers", config);
|
|
2377
|
+
pushScopedFolder(lines, "│ ├─ ", "animations", config);
|
|
2378
|
+
pushScopedFolder(lines, "│ ├─ ", "attachables", config);
|
|
2379
|
+
pushScopedFolder(lines, "│ ├─ ", "entity", config);
|
|
2380
|
+
pushScopedFolder(lines, "│ ├─ ", "fogs", config);
|
|
2381
|
+
lines.push(import_picocolors.default.dim("│ ├─ models/entity/"));
|
|
2382
|
+
if (config.useMarketplaceStructure) {
|
|
2383
|
+
lines.push(import_picocolors.default.dim(`│ │ └─ ${getMarketplaceScopeLabel(config)}/`));
|
|
2384
|
+
}
|
|
2385
|
+
pushScopedFolder(lines, "│ ├─ ", "particles", config);
|
|
2386
|
+
pushScopedFolder(lines, "│ ├─ ", "render_controllers", config);
|
|
2387
|
+
pushScopedFolder(lines, "│ ├─ ", "sounds", config);
|
|
2388
|
+
lines.push(import_picocolors.default.dim("│ ├─ texts/"));
|
|
2389
|
+
lines.push(import_picocolors.default.dim("│ ├─ textures/blocks/"));
|
|
2390
|
+
if (config.useMarketplaceStructure) {
|
|
2391
|
+
lines.push(import_picocolors.default.dim(`│ │ └─ ${getMarketplaceScopeLabel(config)}/`));
|
|
2392
|
+
}
|
|
2393
|
+
lines.push(import_picocolors.default.dim("│ ├─ textures/entity/"));
|
|
2394
|
+
if (config.useMarketplaceStructure) {
|
|
2395
|
+
lines.push(import_picocolors.default.dim(`│ │ └─ ${getMarketplaceScopeLabel(config)}/`));
|
|
2396
|
+
}
|
|
2397
|
+
lines.push(import_picocolors.default.dim("│ ├─ textures/items/"));
|
|
2398
|
+
if (config.useMarketplaceStructure) {
|
|
2399
|
+
lines.push(import_picocolors.default.dim(`│ │ └─ ${getMarketplaceScopeLabel(config)}/`));
|
|
2400
|
+
}
|
|
2401
|
+
pushScopedFolder(lines, "│ ├─ ", "ui", config);
|
|
2402
|
+
lines.push(import_picocolors.default.dim("│ ├─ blocks.json"));
|
|
2403
|
+
lines.push(import_picocolors.default.dim("│ ├─ sounds.json"));
|
|
2404
|
+
lines.push(import_picocolors.default.dim("│ ├─ sound_definitions.json"));
|
|
2405
|
+
lines.push(import_picocolors.default.dim("│ ├─ item_texture.json"));
|
|
2406
|
+
lines.push(import_picocolors.default.dim("│ ├─ terrain_texture.json"));
|
|
2407
|
+
lines.push(import_picocolors.default.dim("│ ├─ flipbook_textures.json"));
|
|
2408
|
+
lines.push(import_picocolors.default.dim("│ └─ manifest.json"));
|
|
2409
|
+
if (config.scripting === "typescript") {
|
|
2410
|
+
lines.push(import_picocolors.default.dim("├─ data/scripts/"));
|
|
2411
|
+
lines.push(import_picocolors.default.dim("│ └─ main.ts"));
|
|
2412
|
+
lines.push(import_picocolors.default.dim("├─ tsconfig.json"));
|
|
2413
|
+
lines.push(import_picocolors.default.dim("├─ dprint.json"));
|
|
2414
|
+
}
|
|
2415
|
+
if (config.scripting === "javascript") {
|
|
2416
|
+
lines.push(import_picocolors.default.dim(`├─ packs/BP/scripts/${config.namespace}/${config.projectId}/main.js`));
|
|
2417
|
+
}
|
|
2418
|
+
if (config.scripting !== "none") {
|
|
2419
|
+
lines.push(import_picocolors.default.dim("├─ package.json"));
|
|
2420
|
+
}
|
|
2421
|
+
if (config.useRgl) {
|
|
2422
|
+
lines.push(import_picocolors.default.dim("├─ config.json"));
|
|
2423
|
+
}
|
|
2424
|
+
if (config.useAi) {
|
|
2425
|
+
lines.push(import_picocolors.default.dim("├─ CLAUDE.md"));
|
|
2426
|
+
lines.push(import_picocolors.default.dim("├─ .mcp.json"));
|
|
2427
|
+
}
|
|
2428
|
+
lines.push(import_picocolors.default.dim("├─ .gitignore"));
|
|
2429
|
+
lines.push(import_picocolors.default.dim("└─ README.md"));
|
|
2430
|
+
return lines.join(`
|
|
2431
|
+
`);
|
|
2432
|
+
}
|
|
2433
|
+
function showReview(config) {
|
|
2434
|
+
const border = teal("│");
|
|
2435
|
+
const packages = config.scripting === "none" ? import_picocolors.default.dim("None") : getSelectedPackages(config.scriptPackages).length > 0 ? formatValue(getSelectedPackages(config.scriptPackages).join(", ")) : import_picocolors.default.dim("None");
|
|
2436
|
+
const lines = [
|
|
2437
|
+
`${whiteOnTeal(" Spawnpack ")} ${import_picocolors.default.dim("Review your Bedrock addon scaffold")}`,
|
|
2438
|
+
"",
|
|
2439
|
+
`${border} ${import_picocolors.default.dim(padLabel("Project:"))} ${formatValue(config.projectName)}`,
|
|
2440
|
+
`${border} ${import_picocolors.default.dim(padLabel("Author:"))} ${config.author ? formatValue(config.author) : import_picocolors.default.dim("—")}`,
|
|
2441
|
+
`${border} ${import_picocolors.default.dim(padLabel("Namespace:"))} ${formatValue(config.namespace)}`,
|
|
2442
|
+
...config.useMarketplaceStructure ? [
|
|
2443
|
+
`${border} ${import_picocolors.default.dim(padLabel("Publisher ID:"))} ${formatValue(config.identifier)}`,
|
|
2444
|
+
`${border} ${import_picocolors.default.dim(padLabel("Project ID:"))} ${formatValue(config.projectId)}`,
|
|
2445
|
+
`${border} ${import_picocolors.default.dim(padLabel("Marketplace structure:"))} ${formatValue(getMarketplaceScopeLabel(config))}`
|
|
2446
|
+
] : [
|
|
2447
|
+
`${border} ${import_picocolors.default.dim(padLabel("Marketplace structure:"))} ${import_picocolors.default.dim("Disabled")}`
|
|
2448
|
+
],
|
|
2449
|
+
`${border} ${import_picocolors.default.dim(padLabel("Destination:"))} ${formatValue(config.destination)}`,
|
|
2450
|
+
`${border} ${import_picocolors.default.dim(padLabel("Scripting:"))} ${formatValue(getScriptingLabel(config.scripting))}`,
|
|
2451
|
+
`${border} ${import_picocolors.default.dim(padLabel("Packages:"))} ${packages}`,
|
|
2452
|
+
`${border} ${import_picocolors.default.dim(padLabel("rgl:"))} ${formatToggle(config.useRgl)}`,
|
|
2453
|
+
`${border} ${import_picocolors.default.dim(padLabel("Rockide:"))} ${formatToggle(config.installRockide)}`,
|
|
2454
|
+
`${border} ${import_picocolors.default.dim(padLabel("AI Setup:"))} ${formatToggle(config.useAi)}`,
|
|
2455
|
+
"",
|
|
2456
|
+
`${border} ${teal(import_picocolors.default.bold("Planned structure"))}`,
|
|
2457
|
+
...showFolderTree(config).split(`
|
|
2458
|
+
`).map((line) => `${border} ${line}`)
|
|
2459
|
+
];
|
|
2460
|
+
O2.message(lines.join(`
|
|
2461
|
+
`), { symbol: teal("◆") });
|
|
2462
|
+
}
|
|
2463
|
+
function showPostGeneration(config) {
|
|
2464
|
+
const nextSteps = [teal(import_picocolors.default.bold("Next steps"))];
|
|
2465
|
+
if (config.destination !== "." && config.destination !== "./") {
|
|
2466
|
+
nextSteps.push(` ${import_picocolors.default.cyan("cd")} ${formatValue(config.destination)}`);
|
|
2467
|
+
}
|
|
2468
|
+
if (config.scripting !== "none") {
|
|
2469
|
+
nextSteps.push(` ${import_picocolors.default.cyan("bun install")} ${import_picocolors.default.dim("or")} ${import_picocolors.default.cyan("npm install")} ${import_picocolors.default.dim("Install project dependencies")}`);
|
|
2470
|
+
}
|
|
2471
|
+
if (config.useRgl) {
|
|
2472
|
+
nextSteps.push(` ${import_picocolors.default.cyan("rgl watch")} ${import_picocolors.default.dim("Watch files and rebuild/export while you work")}`);
|
|
2473
|
+
}
|
|
2474
|
+
const usefulCommands = [teal(import_picocolors.default.bold("Useful commands"))];
|
|
2475
|
+
if (config.useRgl) {
|
|
2476
|
+
usefulCommands.push(` ${import_picocolors.default.cyan("rgl run")} ${import_picocolors.default.dim("Build for development")}`);
|
|
2477
|
+
usefulCommands.push(` ${import_picocolors.default.cyan("rgl run build")} ${import_picocolors.default.dim("Build for distribution")}`);
|
|
2478
|
+
}
|
|
2479
|
+
if (config.scripting === "typescript") {
|
|
2480
|
+
usefulCommands.push(` ${import_picocolors.default.cyan("bun run typecheck")} ${import_picocolors.default.dim("or")} ${import_picocolors.default.cyan("npm run typecheck")} ${import_picocolors.default.dim("Check TypeScript types")}`);
|
|
2481
|
+
}
|
|
2482
|
+
if (config.scripting === "none" && !config.useRgl) {
|
|
2483
|
+
usefulCommands.push(` ${import_picocolors.default.dim("No extra build commands needed for this scaffold")}`);
|
|
2484
|
+
}
|
|
2485
|
+
if (config.useAi) {
|
|
2486
|
+
usefulCommands.push("");
|
|
2487
|
+
usefulCommands.push(`${teal(import_picocolors.default.bold("Note"))} ${import_picocolors.default.dim("Add your own Exa and Hyperbrowser MCP API keys in .mcp.json before using the AI tooling.")}`);
|
|
2488
|
+
usefulCommands.push(` ${import_picocolors.default.dim("Exa:")} ${import_picocolors.default.cyan("https://dashboard.exa.ai/api-keys")}`);
|
|
2489
|
+
usefulCommands.push(` ${import_picocolors.default.dim("Hyperbrowser:")} ${import_picocolors.default.cyan("https://app.hyperbrowser.ai/signup")}`);
|
|
2490
|
+
}
|
|
2491
|
+
O2.message([...nextSteps, "", ...usefulCommands].join(`
|
|
2492
|
+
`), {
|
|
2493
|
+
symbol: teal("▲")
|
|
2494
|
+
});
|
|
2495
|
+
}
|
|
2496
|
+
|
|
2497
|
+
// src/tui/wizard.ts
|
|
2498
|
+
var import_picocolors2 = __toESM(require_picocolors(), 1);
|
|
2499
|
+
var teal2 = (value) => `\x1B[38;2;47;208;181m${value}\x1B[39m`;
|
|
2500
|
+
var bgTeal2 = (value) => `\x1B[48;2;47;208;181m${value}\x1B[49m`;
|
|
2501
|
+
function abortWizard() {
|
|
2502
|
+
pt(import_picocolors2.default.red("Spawnpack cancelled."));
|
|
2503
|
+
return null;
|
|
2504
|
+
}
|
|
2505
|
+
function toScriptPackages(selected) {
|
|
2506
|
+
return {
|
|
2507
|
+
server: selected.includes("server"),
|
|
2508
|
+
serverUi: selected.includes("serverUi"),
|
|
2509
|
+
vanillaData: selected.includes("vanillaData"),
|
|
2510
|
+
math: selected.includes("math")
|
|
2511
|
+
};
|
|
2512
|
+
}
|
|
2513
|
+
async function runWizard() {
|
|
2514
|
+
mt(`${bgTeal2(import_picocolors2.default.bold(import_picocolors2.default.white(" Spawnpack ")))} ${teal2("Initialize your Minecraft Bedrock addon")}`);
|
|
2515
|
+
const projectName = await Ot({
|
|
2516
|
+
message: import_picocolors2.default.bold("Project name"),
|
|
2517
|
+
placeholder: "My Cool Addon",
|
|
2518
|
+
validate(value) {
|
|
2519
|
+
const trimmed = (value ?? "").trim();
|
|
2520
|
+
if (trimmed.length === 0) {
|
|
2521
|
+
return "Project name is required.";
|
|
2522
|
+
}
|
|
2523
|
+
if (/[<>:"/\\|?*]/.test(trimmed)) {
|
|
2524
|
+
return 'Invalid characters in name (avoid < > : " / \\ | ? *).';
|
|
2525
|
+
}
|
|
2526
|
+
if (trimmed.length > 64) {
|
|
2527
|
+
return "Name is too long (max 64 characters).";
|
|
2528
|
+
}
|
|
2529
|
+
return;
|
|
2530
|
+
}
|
|
2531
|
+
});
|
|
2532
|
+
if (q(projectName)) {
|
|
2533
|
+
return abortWizard();
|
|
2534
|
+
}
|
|
2535
|
+
const trimmedProjectName = projectName.trim();
|
|
2536
|
+
const defaultNamespace = "sample";
|
|
2537
|
+
const suggestedProjectId = generateProjectId(trimmedProjectName);
|
|
2538
|
+
const author = await Ot({
|
|
2539
|
+
message: `${import_picocolors2.default.bold("Author")} ${import_picocolors2.default.dim("optional")}`,
|
|
2540
|
+
placeholder: "Your Name or Studio"
|
|
2541
|
+
});
|
|
2542
|
+
if (q(author)) {
|
|
2543
|
+
return abortWizard();
|
|
2544
|
+
}
|
|
2545
|
+
const namespace = await Ot({
|
|
2546
|
+
message: `${import_picocolors2.default.bold("Namespace")} ${import_picocolors2.default.dim("used in identifiers like namespace:item_name")}`,
|
|
2547
|
+
placeholder: defaultNamespace,
|
|
2548
|
+
initialValue: defaultNamespace,
|
|
2549
|
+
validate(value) {
|
|
2550
|
+
const trimmed = (value ?? "").trim();
|
|
2551
|
+
if (trimmed.length === 0) {
|
|
2552
|
+
return "Namespace is required.";
|
|
2553
|
+
}
|
|
2554
|
+
if (!/^[a-z0-9_]+$/.test(trimmed)) {
|
|
2555
|
+
return "Use lowercase letters, numbers, and underscores only.";
|
|
2556
|
+
}
|
|
2557
|
+
return;
|
|
2558
|
+
}
|
|
2559
|
+
});
|
|
2560
|
+
if (q(namespace)) {
|
|
2561
|
+
return abortWizard();
|
|
2562
|
+
}
|
|
2563
|
+
const namespaceValue = namespace.trim();
|
|
2564
|
+
const useMarketplaceStructure = await ot2({
|
|
2565
|
+
message: `${import_picocolors2.default.bold("Marketplace Add-On structure?")} ${import_picocolors2.default.dim("Nest BP/RP content under publisher_id/project_id for better coexistence")}`,
|
|
2566
|
+
initialValue: false
|
|
2567
|
+
});
|
|
2568
|
+
if (q(useMarketplaceStructure)) {
|
|
2569
|
+
return abortWizard();
|
|
2570
|
+
}
|
|
2571
|
+
let identifierValue = namespaceValue;
|
|
2572
|
+
let projectIdValue = suggestedProjectId;
|
|
2573
|
+
if (useMarketplaceStructure) {
|
|
2574
|
+
const publisherId = await Ot({
|
|
2575
|
+
message: `${import_picocolors2.default.bold("Publisher ID")} ${import_picocolors2.default.dim("used for scoped folders like publisher_id/project_id")}`,
|
|
2576
|
+
placeholder: namespaceValue,
|
|
2577
|
+
initialValue: namespaceValue,
|
|
2578
|
+
validate(value) {
|
|
2579
|
+
const trimmed = (value ?? "").trim();
|
|
2580
|
+
if (trimmed.length === 0) {
|
|
2581
|
+
return "Publisher ID is required.";
|
|
2582
|
+
}
|
|
2583
|
+
if (!/^[a-z0-9_]+$/.test(trimmed)) {
|
|
2584
|
+
return "Use lowercase letters, numbers, and underscores only.";
|
|
2585
|
+
}
|
|
2586
|
+
return;
|
|
2587
|
+
}
|
|
2588
|
+
});
|
|
2589
|
+
if (q(publisherId)) {
|
|
2590
|
+
return abortWizard();
|
|
2591
|
+
}
|
|
2592
|
+
identifierValue = publisherId.trim();
|
|
2593
|
+
const projectId = await Ot({
|
|
2594
|
+
message: `${import_picocolors2.default.bold("Project ID")} ${import_picocolors2.default.dim("1-10 lowercase letters, numbers, or underscores")}`,
|
|
2595
|
+
placeholder: suggestedProjectId,
|
|
2596
|
+
initialValue: suggestedProjectId,
|
|
2597
|
+
validate(value) {
|
|
2598
|
+
const trimmed = (value ?? "").trim();
|
|
2599
|
+
if (!/^[a-z0-9_]{1,10}$/.test(trimmed)) {
|
|
2600
|
+
return "Project ID must be 1-10 lowercase letters, numbers, or underscores.";
|
|
2601
|
+
}
|
|
2602
|
+
return;
|
|
2603
|
+
}
|
|
2604
|
+
});
|
|
2605
|
+
if (q(projectId)) {
|
|
2606
|
+
return abortWizard();
|
|
2607
|
+
}
|
|
2608
|
+
projectIdValue = projectId.trim();
|
|
2609
|
+
}
|
|
2610
|
+
const destination = await Ot({
|
|
2611
|
+
message: import_picocolors2.default.bold("Destination folder"),
|
|
2612
|
+
placeholder: ".",
|
|
2613
|
+
initialValue: ".",
|
|
2614
|
+
validate(value) {
|
|
2615
|
+
const trimmed = (value ?? "").trim();
|
|
2616
|
+
if (trimmed.length === 0) {
|
|
2617
|
+
return "Destination folder is required.";
|
|
2618
|
+
}
|
|
2619
|
+
if (/[<>"|?*]/.test(trimmed)) {
|
|
2620
|
+
return 'Invalid characters in path (avoid < > " | ? *).';
|
|
2621
|
+
}
|
|
2622
|
+
if (trimmed.length > 200) {
|
|
2623
|
+
return "Path is too long (max 200 characters).";
|
|
2624
|
+
}
|
|
2625
|
+
return;
|
|
2626
|
+
}
|
|
2627
|
+
});
|
|
2628
|
+
if (q(destination)) {
|
|
2629
|
+
return abortWizard();
|
|
2630
|
+
}
|
|
2631
|
+
const scripting = await _t({
|
|
2632
|
+
message: import_picocolors2.default.bold("Scripting API"),
|
|
2633
|
+
initialValue: "typescript",
|
|
2634
|
+
options: [
|
|
2635
|
+
{ value: "none", label: "None", hint: "manifest-only addon scaffold" },
|
|
2636
|
+
{ value: "javascript", label: "JavaScript", hint: "script entry with JS tooling" },
|
|
2637
|
+
{ value: "typescript", label: "TypeScript", hint: "recommended" }
|
|
2638
|
+
]
|
|
2639
|
+
});
|
|
2640
|
+
if (q(scripting)) {
|
|
2641
|
+
return abortWizard();
|
|
2642
|
+
}
|
|
2643
|
+
let scriptPackages = { ...DEFAULT_SCRIPT_PACKAGES };
|
|
2644
|
+
let useRgl = false;
|
|
2645
|
+
if (scripting !== "none") {
|
|
2646
|
+
const selectedPackages = await yt({
|
|
2647
|
+
message: import_picocolors2.default.bold("Script packages"),
|
|
2648
|
+
required: false,
|
|
2649
|
+
initialValues: Object.entries(DEFAULT_SCRIPT_PACKAGES).filter(([, enabled]) => enabled).map(([key]) => key),
|
|
2650
|
+
options: [
|
|
2651
|
+
{ value: "server", label: "@minecraft/server", hint: "core Bedrock Script API for gameplay, world, blocks, and entities" },
|
|
2652
|
+
{ value: "serverUi", label: "@minecraft/server-ui", hint: "UI forms and dialogs" },
|
|
2653
|
+
{ value: "vanillaData", label: "@minecraft/vanilla-data", hint: "built-in constants and enums" },
|
|
2654
|
+
{ value: "math", label: "@minecraft/math", hint: "vector and math helpers" }
|
|
2655
|
+
]
|
|
2656
|
+
});
|
|
2657
|
+
if (q(selectedPackages)) {
|
|
2658
|
+
return abortWizard();
|
|
2659
|
+
}
|
|
2660
|
+
scriptPackages = toScriptPackages(Array.from(new Set(["server", ...selectedPackages])));
|
|
2661
|
+
const rglChoice = await ot2({
|
|
2662
|
+
message: `${import_picocolors2.default.bold("Use rgl?")} ${import_picocolors2.default.dim("fast Bedrock addon compiler, 16x faster than Regolith")}`,
|
|
2663
|
+
initialValue: true
|
|
2664
|
+
});
|
|
2665
|
+
if (q(rglChoice)) {
|
|
2666
|
+
return abortWizard();
|
|
2667
|
+
}
|
|
2668
|
+
useRgl = rglChoice;
|
|
2669
|
+
}
|
|
2670
|
+
const installRockide2 = await ot2({
|
|
2671
|
+
message: `${import_picocolors2.default.bold("Install Rockide?")} ${import_picocolors2.default.dim("VSCode extension for Bedrock JSON autocompletion")}`,
|
|
2672
|
+
initialValue: true
|
|
2673
|
+
});
|
|
2674
|
+
if (q(installRockide2)) {
|
|
2675
|
+
return abortWizard();
|
|
2676
|
+
}
|
|
2677
|
+
const useAi = await ot2({
|
|
2678
|
+
message: `${import_picocolors2.default.bold("AI setup?")} ${import_picocolors2.default.dim("generate CLAUDE.md with Bedrock development rules")}`,
|
|
2679
|
+
initialValue: false
|
|
2680
|
+
});
|
|
2681
|
+
if (q(useAi)) {
|
|
2682
|
+
return abortWizard();
|
|
2683
|
+
}
|
|
2684
|
+
const config = {
|
|
2685
|
+
projectName: trimmedProjectName,
|
|
2686
|
+
author: author.trim(),
|
|
2687
|
+
namespace: namespaceValue,
|
|
2688
|
+
identifier: identifierValue,
|
|
2689
|
+
projectId: projectIdValue,
|
|
2690
|
+
destination: destination.trim(),
|
|
2691
|
+
scripting,
|
|
2692
|
+
scriptPackages: scripting === "none" ? { ...DEFAULT_SCRIPT_PACKAGES } : scriptPackages,
|
|
2693
|
+
useMarketplaceStructure,
|
|
2694
|
+
useRgl: scripting === "none" ? false : useRgl,
|
|
2695
|
+
useAi,
|
|
2696
|
+
installRockide: installRockide2
|
|
2697
|
+
};
|
|
2698
|
+
showReview(config);
|
|
2699
|
+
const shouldGenerate = await ot2({
|
|
2700
|
+
message: `${import_picocolors2.default.bold("Generate addon scaffold?")} ${import_picocolors2.default.dim("create the project files now")}`,
|
|
2701
|
+
initialValue: true
|
|
2702
|
+
});
|
|
2703
|
+
if (q(shouldGenerate) || !shouldGenerate) {
|
|
2704
|
+
return abortWizard();
|
|
2705
|
+
}
|
|
2706
|
+
return config;
|
|
2707
|
+
}
|
|
2708
|
+
|
|
2709
|
+
// src/index.ts
|
|
2710
|
+
var teal3 = (value) => `\x1B[38;2;47;208;181m${value}\x1B[39m`;
|
|
2711
|
+
var config = await runWizard();
|
|
2712
|
+
if (config === null) {
|
|
2713
|
+
process.exit(0);
|
|
2714
|
+
}
|
|
2715
|
+
var generation = fe();
|
|
2716
|
+
generation.start(teal3("Generating your Bedrock addon scaffold..."));
|
|
2717
|
+
await generateProject(config);
|
|
2718
|
+
if (config.useAi) {
|
|
2719
|
+
await setupAi(config.destination);
|
|
2720
|
+
}
|
|
2721
|
+
await runProvisioning(config);
|
|
2722
|
+
generation.stop(import_picocolors3.default.green("Spawnpack scaffold generated."));
|
|
2723
|
+
showPostGeneration(config);
|
|
2724
|
+
gt(teal3("Your addon is ready."));
|