@kaynooo/pkg-tools 0.0.0-stage → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +36 -2
- package/dist/cli.js +2022 -0
- package/package.json +33 -4
package/dist/cli.js
ADDED
|
@@ -0,0 +1,2022 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
// @bun
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __returnValue = (v) => v;
|
|
5
|
+
function __exportSetter(name, newValue) {
|
|
6
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
7
|
+
}
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, {
|
|
11
|
+
get: all[name],
|
|
12
|
+
enumerable: true,
|
|
13
|
+
configurable: true,
|
|
14
|
+
set: __exportSetter.bind(all, name)
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
var __esm = (fn, res, err) => () => {
|
|
18
|
+
if (fn)
|
|
19
|
+
try {
|
|
20
|
+
res = fn(fn = 0);
|
|
21
|
+
} catch (e) {
|
|
22
|
+
err = [e];
|
|
23
|
+
}
|
|
24
|
+
if (err)
|
|
25
|
+
throw err[0];
|
|
26
|
+
return res;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
// ../../node_modules/.bun/@kaynooo+utils@2.31.0+d0769e28dc4dad16/node_modules/@kaynooo/utils/dist/chunk-mtetydvc.js
|
|
30
|
+
function x(s) {
|
|
31
|
+
let r = s.startsWith("#") ? s.slice(1).toLowerCase() : s.toLowerCase();
|
|
32
|
+
if (!/^[a-f0-9]+$/.test(r))
|
|
33
|
+
return [0, 0, 0];
|
|
34
|
+
let t = r.length, n = (c) => Number.parseInt(c, 16);
|
|
35
|
+
if (t === 3 || t === 4) {
|
|
36
|
+
let c = n(r[0] + r[0]), u = n(r[1] + r[1]), h = n(r[2] + r[2]), g = t === 4 ? n(r[3] + r[3]) : undefined;
|
|
37
|
+
return g !== undefined ? [c, u, h, g] : [c, u, h];
|
|
38
|
+
}
|
|
39
|
+
if (t !== 6 && t !== 8)
|
|
40
|
+
throw Error(`Invalid hex color length: ${t}`);
|
|
41
|
+
let a = n(r.slice(0, 2)), b = n(r.slice(2, 4)), o = n(r.slice(4, 6)), y = t === 8 ? n(r.slice(6, 8)) : undefined;
|
|
42
|
+
if ([a, b, o].some(Number.isNaN) || y !== undefined && Number.isNaN(y))
|
|
43
|
+
throw Error(`Invalid hex color value: ${s}`);
|
|
44
|
+
return y !== undefined ? [a, b, o, y] : [a, b, o];
|
|
45
|
+
}
|
|
46
|
+
function A(s) {
|
|
47
|
+
let [r, t, n, a] = s;
|
|
48
|
+
if (a)
|
|
49
|
+
return `#${(r << 24 | t << 16 | n << 8 | Math.round((a ?? 1) * 255)).toString(16).padStart(8, "0").toUpperCase()}`;
|
|
50
|
+
return `#${(r << 16 | t << 8 | n).toString(16).padStart(6, "0").toUpperCase()}`;
|
|
51
|
+
}
|
|
52
|
+
function R(s, r, t) {
|
|
53
|
+
s = (s % 360 + 360) % 360, t /= 100;
|
|
54
|
+
let n = r * Math.min(t, 1 - t) / 100, a = (b) => {
|
|
55
|
+
let o = (b + s / 30) % 12, y = t - n * Math.max(Math.min(o - 3, 9 - o, 1), -1);
|
|
56
|
+
return Math.round(255 * y);
|
|
57
|
+
};
|
|
58
|
+
return [a(0), a(8), a(4)];
|
|
59
|
+
}
|
|
60
|
+
function k(s) {
|
|
61
|
+
let [r, t, n] = s;
|
|
62
|
+
r /= 255, t /= 255, n /= 255;
|
|
63
|
+
let a = Math.max(r, t, n), b = Math.min(r, t, n), o = 0, y = 0, c = (a + b) / 2;
|
|
64
|
+
if (a !== b) {
|
|
65
|
+
let u = a - b;
|
|
66
|
+
if (y = c > 0 && c < 1 ? u / (1 - Math.abs(2 * c - 1)) : 0, a === r)
|
|
67
|
+
o = (t - n) / u + (t < n ? 6 : 0);
|
|
68
|
+
else if (a === t)
|
|
69
|
+
o = (n - r) / u + 2;
|
|
70
|
+
else
|
|
71
|
+
o = (r - t) / u + 4;
|
|
72
|
+
o /= 6;
|
|
73
|
+
}
|
|
74
|
+
return [Math.round(o * 360), Math.round(y * 100), Math.round(c * 100)];
|
|
75
|
+
}
|
|
76
|
+
function H(s, r, t) {
|
|
77
|
+
s = (s % 360 + 360) % 360, r /= 100, t /= 100;
|
|
78
|
+
let n = (a) => {
|
|
79
|
+
let b = (a + s / 60) % 6, o = t - t * r * Math.max(Math.min(b, 4 - b, 1), 0);
|
|
80
|
+
return Math.round(255 * o);
|
|
81
|
+
};
|
|
82
|
+
return [n(5), n(3), n(1)];
|
|
83
|
+
}
|
|
84
|
+
function f(s) {
|
|
85
|
+
let [r, t, n] = s;
|
|
86
|
+
r /= 255, t /= 255, n /= 255;
|
|
87
|
+
let a = Math.max(r, t, n), b = Math.min(r, t, n), o = a - b, y = 0, c = a === 0 ? 0 : o / a, u = a;
|
|
88
|
+
if (o !== 0) {
|
|
89
|
+
if (a === r)
|
|
90
|
+
y = (t - n) / o + (t < n ? 6 : 0);
|
|
91
|
+
else if (a === t)
|
|
92
|
+
y = (n - r) / o + 2;
|
|
93
|
+
else
|
|
94
|
+
y = (r - t) / o + 4;
|
|
95
|
+
y /= 6;
|
|
96
|
+
}
|
|
97
|
+
return [Math.round(y * 360), Math.round(c * 100), Math.round(u * 100)];
|
|
98
|
+
}
|
|
99
|
+
function O(s) {
|
|
100
|
+
let r = s[0] / 255, t = s[1] / 255, n = s[2] / 255, a = 1 - Math.max(r, t, n);
|
|
101
|
+
if (a === 1)
|
|
102
|
+
return [0, 0, 0, 100];
|
|
103
|
+
let b = (1 - r - a) / (1 - a), o = (1 - t - a) / (1 - a), y = (1 - n - a) / (1 - a);
|
|
104
|
+
return [Math.round(b * 100), Math.round(o * 100), Math.round(y * 100), Math.round(a * 100)];
|
|
105
|
+
}
|
|
106
|
+
function v(s, r, t, n) {
|
|
107
|
+
return s /= 100, r /= 100, t /= 100, n /= 100, [Math.round(255 * (1 - s) * (1 - n)), Math.round(255 * (1 - r) * (1 - n)), Math.round(255 * (1 - t) * (1 - n))];
|
|
108
|
+
}
|
|
109
|
+
function T(s) {
|
|
110
|
+
let r = m(s[0] / 255), t = m(s[1] / 255), n = m(s[2] / 255), a = Math.cbrt(0.4122214708 * r + 0.5363325363 * t + 0.0514459929 * n), b = Math.cbrt(0.2119034982 * r + 0.6806995451 * t + 0.1073969566 * n), o = Math.cbrt(0.0883024619 * r + 0.2817188376 * t + 0.6299787005 * n);
|
|
111
|
+
return [i(0.2104542553 * a + 0.793617785 * b - 0.0040720468 * o, 4), i(1.9779984951 * a - 2.428592205 * b + 0.4505937099 * o, 4), i(0.0259040371 * a + 0.7827717662 * b - 0.808675766 * o, 4)];
|
|
112
|
+
}
|
|
113
|
+
function M(s, r, t) {
|
|
114
|
+
let n = (s + 0.3963377774 * r + 0.2158037573 * t) ** 3, a = (s - 0.1055613458 * r - 0.0638541728 * t) ** 3, b = (s - 0.0894841775 * r - 1.291485548 * t) ** 3, o = p(4.0767416621 * n - 3.3077115913 * a + 0.2309699292 * b), y = p(-1.2684380046 * n + 2.6097574011 * a - 0.3413193965 * b), c = p(-0.0041960863 * n - 0.7034186147 * a + 1.707614701 * b), u = (h) => Math.min(255, Math.max(0, Math.round(h * 255)));
|
|
115
|
+
return [u(o), u(y), u(c)];
|
|
116
|
+
}
|
|
117
|
+
function d(s) {
|
|
118
|
+
let [r, t, n] = T(s), a = Math.sqrt(t * t + n * n), b = (Math.atan2(n, t) * 180 / Math.PI + 360) % 360;
|
|
119
|
+
return [i(r, 4), i(a, 4), i(b, 2)];
|
|
120
|
+
}
|
|
121
|
+
function C(s, r, t) {
|
|
122
|
+
let n = t * Math.PI / 180;
|
|
123
|
+
return M(s, r * Math.cos(n), r * Math.sin(n));
|
|
124
|
+
}
|
|
125
|
+
function l(s) {
|
|
126
|
+
let r = s / 255;
|
|
127
|
+
return r <= 0.03928 ? r / 12.92 : ((r + 0.055) / 1.055) ** 2.4;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
class e {
|
|
131
|
+
r;
|
|
132
|
+
g;
|
|
133
|
+
b;
|
|
134
|
+
a;
|
|
135
|
+
constructor(s, r, t, n = 1) {
|
|
136
|
+
this.r = s, this.g = r, this.b = t, this.a = n;
|
|
137
|
+
}
|
|
138
|
+
static from(s, r) {
|
|
139
|
+
if (s === "hex") {
|
|
140
|
+
let [t, n, a, b] = x(r);
|
|
141
|
+
return new e(t, n, a, b);
|
|
142
|
+
}
|
|
143
|
+
if (s === "rgb") {
|
|
144
|
+
if (Array.isArray(r)) {
|
|
145
|
+
let [o, y, c, u] = r;
|
|
146
|
+
return new e(o, y, c, u);
|
|
147
|
+
}
|
|
148
|
+
let { r: t, g: n, b: a, a: b } = r;
|
|
149
|
+
return new e(t, n, a, b);
|
|
150
|
+
}
|
|
151
|
+
if (s === "hsl") {
|
|
152
|
+
let t, n, a, b;
|
|
153
|
+
if (Array.isArray(r))
|
|
154
|
+
[t, n, a, b] = r;
|
|
155
|
+
else
|
|
156
|
+
({ h: t, s: n, l: a, a: b } = r);
|
|
157
|
+
let [o, y, c] = R(t, n, a);
|
|
158
|
+
return new e(o, y, c, b);
|
|
159
|
+
}
|
|
160
|
+
if (s === "hsv") {
|
|
161
|
+
let t, n, a, b;
|
|
162
|
+
if (Array.isArray(r))
|
|
163
|
+
[t, n, a, b] = r;
|
|
164
|
+
else
|
|
165
|
+
({ h: t, s: n, v: a, a: b } = r);
|
|
166
|
+
let [o, y, c] = H(t, n, a);
|
|
167
|
+
return new e(o, y, c, b);
|
|
168
|
+
}
|
|
169
|
+
if (s === "cmyk") {
|
|
170
|
+
let t, n, a, b, o;
|
|
171
|
+
if (Array.isArray(r))
|
|
172
|
+
[t, n, a, b, o] = r;
|
|
173
|
+
else
|
|
174
|
+
({ c: t, m: n, y: a, k: b, a: o } = r);
|
|
175
|
+
let [y, c, u] = v(t, n, a, b);
|
|
176
|
+
return new e(y, c, u, o);
|
|
177
|
+
}
|
|
178
|
+
if (s === "oklch") {
|
|
179
|
+
let t, n, a, b;
|
|
180
|
+
if (Array.isArray(r))
|
|
181
|
+
[t, n, a, b] = r;
|
|
182
|
+
else
|
|
183
|
+
({ l: t, c: n, h: a, a: b } = r);
|
|
184
|
+
let [o, y, c] = C(t, n, a);
|
|
185
|
+
return new e(o, y, c, b);
|
|
186
|
+
}
|
|
187
|
+
if (s === "oklab") {
|
|
188
|
+
let t, n, a, b;
|
|
189
|
+
if (Array.isArray(r))
|
|
190
|
+
[t, n, a, b] = r;
|
|
191
|
+
else
|
|
192
|
+
({ l: t, a: n, b: a, alpha: b } = r);
|
|
193
|
+
let [o, y, c] = M(t, n, a);
|
|
194
|
+
return new e(o, y, c, b);
|
|
195
|
+
}
|
|
196
|
+
throw Error("Invalid input");
|
|
197
|
+
}
|
|
198
|
+
to(s) {
|
|
199
|
+
switch (s) {
|
|
200
|
+
case "rgb":
|
|
201
|
+
return [this.r, this.g, this.b];
|
|
202
|
+
case "rgba":
|
|
203
|
+
return [this.r, this.g, this.b, this.a];
|
|
204
|
+
case "hex":
|
|
205
|
+
return A([this.r, this.g, this.b]);
|
|
206
|
+
case "hexa":
|
|
207
|
+
return A([this.r, this.g, this.b, this.a]);
|
|
208
|
+
case "hsl":
|
|
209
|
+
return k([this.r, this.g, this.b]);
|
|
210
|
+
case "hsla":
|
|
211
|
+
return [...k([this.r, this.g, this.b]), this.a];
|
|
212
|
+
case "hsv":
|
|
213
|
+
return f([this.r, this.g, this.b]);
|
|
214
|
+
case "hsva":
|
|
215
|
+
return [...f([this.r, this.g, this.b]), this.a];
|
|
216
|
+
case "cmyk":
|
|
217
|
+
return O([this.r, this.g, this.b]);
|
|
218
|
+
case "cmyka":
|
|
219
|
+
return [...O([this.r, this.g, this.b]), this.a];
|
|
220
|
+
case "oklch":
|
|
221
|
+
return d([this.r, this.g, this.b]);
|
|
222
|
+
case "oklcha":
|
|
223
|
+
return [...d([this.r, this.g, this.b]), this.a];
|
|
224
|
+
case "oklab":
|
|
225
|
+
return T([this.r, this.g, this.b]);
|
|
226
|
+
case "oklaba":
|
|
227
|
+
return [...T([this.r, this.g, this.b]), this.a];
|
|
228
|
+
default:
|
|
229
|
+
return [this.r, this.g, this.b];
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
getLuminance() {
|
|
233
|
+
let s = l(this.r), r = l(this.g), t = l(this.b);
|
|
234
|
+
return 0.2126 * s + 0.7152 * r + 0.0722 * t;
|
|
235
|
+
}
|
|
236
|
+
contrastRatio(s) {
|
|
237
|
+
let r = this.getLuminance(), t = s.getLuminance(), [n, a] = r >= t ? [r, t] : [t, r];
|
|
238
|
+
return (n + 0.05) / (a + 0.05);
|
|
239
|
+
}
|
|
240
|
+
bestContrastForeground() {
|
|
241
|
+
let s = new e(255, 255, 255, 1), r = new e(0, 0, 0, 1), t = this.contrastRatio(s), n = this.contrastRatio(r);
|
|
242
|
+
return t >= n ? s : r;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
var m = (s) => s <= 0.04045 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4, p = (s) => s <= 0.0031308 ? 12.92 * s : 1.055 * s ** 0.4166666666666667 - 0.055, i = (s, r) => Math.round(s * 10 ** r) / 10 ** r;
|
|
246
|
+
var init_chunk_mtetydvc = () => {};
|
|
247
|
+
|
|
248
|
+
// ../../node_modules/.bun/@kaynooo+utils@2.31.0+d0769e28dc4dad16/node_modules/@kaynooo/utils/dist/chunk-y1msbssb.js
|
|
249
|
+
function h(i, n = globalThis.process?.env ?? {}) {
|
|
250
|
+
if (n.FORCE_COLOR !== undefined)
|
|
251
|
+
return b.has(n.FORCE_COLOR);
|
|
252
|
+
if (n.NO_COLOR !== undefined || n.NODE_DISABLE_COLORS !== undefined || n.TERM === "dumb")
|
|
253
|
+
return false;
|
|
254
|
+
return i?.isTTY === true;
|
|
255
|
+
}
|
|
256
|
+
function d2(i, n, a) {
|
|
257
|
+
if (!h(a.stream ?? globalThis.process?.stdout, a.env))
|
|
258
|
+
return n;
|
|
259
|
+
let l = "", s = "";
|
|
260
|
+
for (let g = 0, y = i.length;g < y; g++) {
|
|
261
|
+
let [c, p] = i[g];
|
|
262
|
+
l += `${f2}${c}m`, s = `${f2}${p}m${s}`;
|
|
263
|
+
}
|
|
264
|
+
return l + n + s;
|
|
265
|
+
}
|
|
266
|
+
function u(i, n = []) {
|
|
267
|
+
return new Proxy((l) => d2(n, l, i), { get(l, s) {
|
|
268
|
+
let g = C2[s];
|
|
269
|
+
if (Array.isArray(g))
|
|
270
|
+
return u(i, [...n, g]);
|
|
271
|
+
if (typeof g === "function")
|
|
272
|
+
return (...y) => u(i, [...n, g(...y)]);
|
|
273
|
+
throw Error(`Unknown style: ${String(s)}`);
|
|
274
|
+
} });
|
|
275
|
+
}
|
|
276
|
+
function le(i = {}) {
|
|
277
|
+
return u(i);
|
|
278
|
+
}
|
|
279
|
+
var r = 39, o = 49, f2 = "\x1B[", C2, b, t;
|
|
280
|
+
var init_chunk_y1msbssb = __esm(() => {
|
|
281
|
+
init_chunk_mtetydvc();
|
|
282
|
+
C2 = { reset: [0, 0], bold: [1, 22], dim: [2, 22], italic: [3, 23], underline: [4, 24], inverse: [7, 27], hidden: [8, 28], strikethrough: [9, 29], black: [30, r], red: [31, r], green: [32, r], yellow: [33, r], blue: [34, r], magenta: [35, r], cyan: [36, r], white: [37, r], gray: [90, r], grey: [90, r], blackBright: [90, r], redBright: [91, r], greenBright: [92, r], yellowBright: [93, r], blueBright: [94, r], magentaBright: [95, r], cyanBright: [96, r], whiteBright: [97, r], bgBlack: [40, o], bgRed: [41, o], bgGreen: [42, o], bgYellow: [43, o], bgBlue: [44, o], bgMagenta: [45, o], bgCyan: [46, o], bgWhite: [47, o], bgBlackBright: [100, o], bgRedBright: [101, o], bgGreenBright: [102, o], bgYellowBright: [103, o], bgBlueBright: [104, o], bgMagentaBright: [105, o], bgCyanBright: [106, o], bgWhiteBright: [107, o], rgb: (i, n, a, l = "fg") => [`${l === "fg" ? 38 : 48};2;${i};${n};${a}`, l === "fg" ? r : o], hex: (i, n = "fg") => {
|
|
283
|
+
let [a, l, s] = e.from("hex", i).to("rgb");
|
|
284
|
+
return [`${n === "fg" ? 38 : 48};2;${a};${l};${s}`, n === "fg" ? r : o];
|
|
285
|
+
}, ansi256: (i, n = "fg") => [`${n === "fg" ? 38 : 48};5;${i}`, n === "fg" ? r : o] };
|
|
286
|
+
b = new Set(["", "1", "2", "3", "true"]);
|
|
287
|
+
t = le();
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
// ../../node_modules/.bun/@kaynooo+utils@2.31.0+d0769e28dc4dad16/node_modules/@kaynooo/utils/dist/tools/colors.js
|
|
291
|
+
var init_colors = __esm(() => {
|
|
292
|
+
init_chunk_y1msbssb();
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
// ../kit/src/style.ts
|
|
296
|
+
import process from "process";
|
|
297
|
+
function takesControlCodes(stream, env = process.env) {
|
|
298
|
+
return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb";
|
|
299
|
+
}
|
|
300
|
+
function paint(stream, env = process.env) {
|
|
301
|
+
return le({ stream: { isTTY: takesControlCodes(stream, env) }, env });
|
|
302
|
+
}
|
|
303
|
+
function marked(mark, text, stream, detail, env = process.env) {
|
|
304
|
+
const colors = paint(stream, env);
|
|
305
|
+
const { symbol, word, paint: tint } = MARKS[mark];
|
|
306
|
+
const head = takesControlCodes(stream, env) ? tint(colors)(symbol) : word;
|
|
307
|
+
return `${head} ${text}${detail === undefined ? "" : ` ${colors.dim(detail)}`}`;
|
|
308
|
+
}
|
|
309
|
+
function ok(text, detail) {
|
|
310
|
+
console.log(marked("ok", text, process.stdout, detail));
|
|
311
|
+
}
|
|
312
|
+
function note(text, detail) {
|
|
313
|
+
console.log(marked("note", text, process.stdout, detail));
|
|
314
|
+
}
|
|
315
|
+
function warn(text, detail) {
|
|
316
|
+
console.error(marked("warn", text, process.stderr, detail));
|
|
317
|
+
}
|
|
318
|
+
function problem(text, detail) {
|
|
319
|
+
console.error(marked("problem", text, process.stderr, detail));
|
|
320
|
+
}
|
|
321
|
+
var MARKS, STATUSES, STATUS_OF;
|
|
322
|
+
var init_style = __esm(() => {
|
|
323
|
+
init_colors();
|
|
324
|
+
MARKS = {
|
|
325
|
+
ok: { symbol: "\u2713", word: "ok:", paint: (colors) => colors.green },
|
|
326
|
+
warn: { symbol: "!", word: "warning:", paint: (colors) => colors.yellow },
|
|
327
|
+
problem: { symbol: "\u2717", word: "error:", paint: (colors) => colors.red },
|
|
328
|
+
note: { symbol: "\xB7", word: "note:", paint: (colors) => colors.dim }
|
|
329
|
+
};
|
|
330
|
+
STATUSES = {
|
|
331
|
+
passed: { symbol: "\u2713", words: ["passed", "success", "succeeded", "ok"], paint: (colors) => colors.green },
|
|
332
|
+
failed: { symbol: "\u2717", words: ["failed", "failure", "error", "errored"], paint: (colors) => colors.red },
|
|
333
|
+
running: { symbol: "\u25CF", words: ["running", "in_progress", "started"], paint: (colors) => colors.cyan },
|
|
334
|
+
queued: { symbol: "\u25CB", words: ["queued", "waiting", "pending", "created", "blocked", "scheduled"], paint: (colors) => colors.yellow },
|
|
335
|
+
skipped: { symbol: "-", words: ["skipped", "cancelled", "canceled", "manual"], paint: (colors) => colors.dim }
|
|
336
|
+
};
|
|
337
|
+
STATUS_OF = new Map(Object.entries(STATUSES).flatMap(([status, { words }]) => words.map((word) => [word, status])));
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
// ../kit/src/format.ts
|
|
341
|
+
import process2 from "process";
|
|
342
|
+
function formatSeconds(total) {
|
|
343
|
+
let rest = Math.max(0, Math.round(total));
|
|
344
|
+
const amounts = UNITS.map(([unit, size]) => {
|
|
345
|
+
const amount = Math.floor(rest / size);
|
|
346
|
+
rest -= amount * size;
|
|
347
|
+
return `${amount}${unit}`;
|
|
348
|
+
});
|
|
349
|
+
const first = amounts.findIndex((amount) => !amount.startsWith("0"));
|
|
350
|
+
if (first === -1)
|
|
351
|
+
return "0s";
|
|
352
|
+
const next = amounts[first + 1];
|
|
353
|
+
return next === undefined || next.startsWith("0") ? amounts[first] ?? "0s" : `${amounts[first]} ${next}`;
|
|
354
|
+
}
|
|
355
|
+
function formatDuration(ms) {
|
|
356
|
+
return ms < 60000 ? `${(Math.max(0, ms) / 1000).toFixed(1)}s` : formatSeconds(ms / 1000);
|
|
357
|
+
}
|
|
358
|
+
function upTo(text, separator) {
|
|
359
|
+
const end = text.indexOf(separator);
|
|
360
|
+
return end === -1 ? text : text.slice(0, end);
|
|
361
|
+
}
|
|
362
|
+
function formatAge(date, now = Date.now()) {
|
|
363
|
+
const at = typeof date === "number" ? date : Date.parse(date);
|
|
364
|
+
if (Number.isNaN(at))
|
|
365
|
+
return "-";
|
|
366
|
+
const seconds = (now - at) / 1000;
|
|
367
|
+
return seconds < 60 ? "just now" : `${upTo(formatSeconds(seconds), " ")} ago`;
|
|
368
|
+
}
|
|
369
|
+
function truncate(text, width) {
|
|
370
|
+
return text.length <= width ? text : `${text.slice(0, Math.max(0, width - 1))}\u2026`;
|
|
371
|
+
}
|
|
372
|
+
function textWidth(text) {
|
|
373
|
+
return Bun.stringWidth(text);
|
|
374
|
+
}
|
|
375
|
+
function table(rows, { cellWidth, header = false, align = [], fit } = {}) {
|
|
376
|
+
const cells = cellWidth === undefined ? rows : rows.map((row) => row.map((cell) => truncate(cell.replaceAll(LINE_BREAKS, " "), cellWidth)));
|
|
377
|
+
const widths = [];
|
|
378
|
+
for (const row of cells) {
|
|
379
|
+
for (const [index, cell] of row.entries())
|
|
380
|
+
widths[index] = Math.max(widths[index] ?? 0, textWidth(cell));
|
|
381
|
+
}
|
|
382
|
+
const shown = fit === undefined ? cells : narrow(cells, widths, fit);
|
|
383
|
+
const colors = paint(process2.stdout);
|
|
384
|
+
const lines = shown.map((row) => row.map((cell, index) => {
|
|
385
|
+
const width = widths[index] ?? 0;
|
|
386
|
+
const gap = " ".repeat(Math.max(0, width - textWidth(cell)));
|
|
387
|
+
if (align[index] === "right")
|
|
388
|
+
return `${gap}${cell}`;
|
|
389
|
+
return index === row.length - 1 ? cell : `${cell}${gap}`;
|
|
390
|
+
}).join(" ").trimEnd());
|
|
391
|
+
return lines.map((line, index) => header && index === 0 ? colors.bold(line) : line).join(`
|
|
392
|
+
`);
|
|
393
|
+
}
|
|
394
|
+
function narrow(rows, widths, limit) {
|
|
395
|
+
const used = () => widths.reduce((sum, width) => sum + width, 0) + 2 * Math.max(0, widths.length - 1);
|
|
396
|
+
const cuttable = (index) => rows.every((row) => !(row[index] ?? "").includes(ESCAPE));
|
|
397
|
+
const floor = 8;
|
|
398
|
+
while (used() > limit) {
|
|
399
|
+
let widest = -1;
|
|
400
|
+
for (const [index, width] of widths.entries()) {
|
|
401
|
+
if (cuttable(index) && width > floor && width > (widths[widest] ?? 0))
|
|
402
|
+
widest = index;
|
|
403
|
+
}
|
|
404
|
+
if (widest === -1)
|
|
405
|
+
break;
|
|
406
|
+
widths[widest] = Math.max(floor, (widths[widest] ?? 0) - (used() - limit));
|
|
407
|
+
}
|
|
408
|
+
return rows.map((row) => row.map((cell, index) => textWidth(cell) > (widths[index] ?? 0) ? truncate(cell, widths[index] ?? 0) : cell));
|
|
409
|
+
}
|
|
410
|
+
function printJson(value) {
|
|
411
|
+
console.log(JSON.stringify(value, undefined, 2));
|
|
412
|
+
}
|
|
413
|
+
var UNITS, LINE_BREAKS, ESCAPE;
|
|
414
|
+
var init_format = __esm(() => {
|
|
415
|
+
init_style();
|
|
416
|
+
UNITS = [["d", 86400], ["h", 3600], ["m", 60], ["s", 1]];
|
|
417
|
+
LINE_BREAKS = /\s*\n\s*/g;
|
|
418
|
+
ESCAPE = String.fromCharCode(27);
|
|
419
|
+
});
|
|
420
|
+
|
|
421
|
+
// ../kit/src/args.ts
|
|
422
|
+
import process3 from "process";
|
|
423
|
+
import { parseArgs } from "util";
|
|
424
|
+
function jsonOption(holds) {
|
|
425
|
+
return { type: "boolean", description: holds === undefined ? "print JSON" : `print JSON: ${holds}` };
|
|
426
|
+
}
|
|
427
|
+
function fail(message, code = 2, hint) {
|
|
428
|
+
throw new Exit(message, code, hint);
|
|
429
|
+
}
|
|
430
|
+
function badUsage(message) {
|
|
431
|
+
throw new UsageError(message);
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
class Completing {
|
|
435
|
+
options;
|
|
436
|
+
constructor(options) {
|
|
437
|
+
this.options = options;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
function usageLine(usage, colors = paint(process3.stdout)) {
|
|
441
|
+
return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
|
|
442
|
+
}
|
|
443
|
+
function helpText(usage, options, colors = paint(process3.stdout), examples = []) {
|
|
444
|
+
return [usageLine(usage, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exampleRows(examples, colors)].join(`
|
|
445
|
+
`);
|
|
446
|
+
}
|
|
447
|
+
function exampleRows(examples, colors = paint(process3.stdout)) {
|
|
448
|
+
if (examples.length === 0)
|
|
449
|
+
return [];
|
|
450
|
+
return ["", colors.bold("Examples:"), ...examples.map((example) => typeof example === "string" ? ` ${example}` : ` ${example[0]} ${colors.dim(`# ${example[1]}`)}`)];
|
|
451
|
+
}
|
|
452
|
+
function optionRows(options, colors = paint(process3.stdout)) {
|
|
453
|
+
const rows = Object.entries(options).map(([name, option]) => {
|
|
454
|
+
const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
|
|
455
|
+
const value = option.type === "string" ? ` ${colors.dim("<value>")}` : "";
|
|
456
|
+
return { flag: `${short}${colors.cyan(`--${name}`)}${value}`, width: `-x, --${name}`.length + (option.type === "string" ? " <value>".length : 0), description: option.description };
|
|
457
|
+
});
|
|
458
|
+
const width = Math.max(0, ...rows.map((row) => row.width));
|
|
459
|
+
return rows.map((row) => ` ${row.flag}${" ".repeat(width - row.width)} ${colors.dim(row.description)}`);
|
|
460
|
+
}
|
|
461
|
+
function applyOutput(color, plain, env = process3.env) {
|
|
462
|
+
const when = plain === true ? "never" : color ?? "auto";
|
|
463
|
+
if (when === "auto")
|
|
464
|
+
return;
|
|
465
|
+
if (when !== "always" && when !== "never")
|
|
466
|
+
badUsage(`--color takes auto, always or never, not ${when}`);
|
|
467
|
+
if (when === "always") {
|
|
468
|
+
env.FORCE_COLOR = "1";
|
|
469
|
+
delete env.NO_COLOR;
|
|
470
|
+
} else {
|
|
471
|
+
env.NO_COLOR = "1";
|
|
472
|
+
delete env.FORCE_COLOR;
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
function parse(args, usage, options, settings = {}) {
|
|
476
|
+
const output = Object.fromEntries(Object.entries(OUTPUT_OPTIONS).filter(([name]) => !(name in options)));
|
|
477
|
+
const all = { ...options, ...output, help: { type: "boolean", short: "h", description: "show this help" } };
|
|
478
|
+
if (completion.active)
|
|
479
|
+
throw new Completing(all);
|
|
480
|
+
const separator = settings.rest === true ? args.indexOf("--") : -1;
|
|
481
|
+
const own = separator === -1 ? args : args.slice(0, separator);
|
|
482
|
+
const rest = separator === -1 ? undefined : args.slice(separator + 1);
|
|
483
|
+
let parsed;
|
|
484
|
+
try {
|
|
485
|
+
parsed = parseArgs({ args: own, options: all, allowPositionals: true, allowNegative: settings.allowNegative === true, strict: true });
|
|
486
|
+
} catch (error) {
|
|
487
|
+
badUsage(parseError(error));
|
|
488
|
+
}
|
|
489
|
+
const values = parsed.values;
|
|
490
|
+
applyOutput("color" in output ? values.color : undefined, "plain" in output ? values.plain : undefined);
|
|
491
|
+
if (values.help === true) {
|
|
492
|
+
console.log(helpText(usage, all, undefined, settings.examples));
|
|
493
|
+
throw new HelpShown;
|
|
494
|
+
}
|
|
495
|
+
if (settings.positionals !== undefined)
|
|
496
|
+
checkPositionals(parsed.positionals, settings.positionals);
|
|
497
|
+
return { ...parsed, positionals: parsed.positionals, rest };
|
|
498
|
+
}
|
|
499
|
+
function checkPositionals(given, names) {
|
|
500
|
+
const variadic = names.at(-1)?.replace("]", "").endsWith("...") === true;
|
|
501
|
+
const required = names.filter((name) => !name.startsWith("[")).length;
|
|
502
|
+
if (given.length < required)
|
|
503
|
+
badUsage(`missing ${names[given.length]}`);
|
|
504
|
+
if (!variadic && given.length > names.length)
|
|
505
|
+
badUsage(`unexpected argument ${given[names.length]}`);
|
|
506
|
+
}
|
|
507
|
+
function parseError(error) {
|
|
508
|
+
const message = upTo(error instanceof Error ? error.message : String(error), ". ");
|
|
509
|
+
return `${message.charAt(0).toLowerCase()}${message.slice(1)}`;
|
|
510
|
+
}
|
|
511
|
+
function wholeNumber(value, name, fallback, min = 1) {
|
|
512
|
+
if (value === undefined)
|
|
513
|
+
return fallback;
|
|
514
|
+
const number = Number(value);
|
|
515
|
+
if (!Number.isInteger(number) || number < min)
|
|
516
|
+
badUsage(`--${name} takes a whole number from ${min}, not ${value}`);
|
|
517
|
+
return number;
|
|
518
|
+
}
|
|
519
|
+
function duration(value, name, fallback, unit = "s") {
|
|
520
|
+
if (value === undefined)
|
|
521
|
+
return fallback;
|
|
522
|
+
const match = DURATION.exec(value.trim());
|
|
523
|
+
const ms = match === null ? 0 : Number(match[1]) * UNIT_MS[match[2] ?? unit];
|
|
524
|
+
if (ms < 1)
|
|
525
|
+
badUsage(`--${name} takes a duration such as 30s, 5m or 1h, not ${value}`);
|
|
526
|
+
return ms;
|
|
527
|
+
}
|
|
528
|
+
var Exit, UsageError, HelpShown, completion, OPTIONAL, USAGE_PREFIX, OUTPUT_OPTIONS, DURATION, UNIT_MS;
|
|
529
|
+
var init_args = __esm(() => {
|
|
530
|
+
init_format();
|
|
531
|
+
init_style();
|
|
532
|
+
Exit = class Exit extends Error {
|
|
533
|
+
code;
|
|
534
|
+
hint;
|
|
535
|
+
constructor(message, code, hint) {
|
|
536
|
+
super(message);
|
|
537
|
+
this.code = code;
|
|
538
|
+
this.hint = hint;
|
|
539
|
+
}
|
|
540
|
+
};
|
|
541
|
+
UsageError = class UsageError extends Exit {
|
|
542
|
+
constructor(message) {
|
|
543
|
+
super(message, 2);
|
|
544
|
+
}
|
|
545
|
+
};
|
|
546
|
+
HelpShown = class HelpShown extends Exit {
|
|
547
|
+
constructor() {
|
|
548
|
+
super("help shown", 0);
|
|
549
|
+
}
|
|
550
|
+
};
|
|
551
|
+
completion = { active: false };
|
|
552
|
+
OPTIONAL = /\[[^\]]+\]/g;
|
|
553
|
+
USAGE_PREFIX = /^usage:\s*/i;
|
|
554
|
+
OUTPUT_OPTIONS = {
|
|
555
|
+
color: { type: "string", description: "auto (on a terminal alone), always or never" },
|
|
556
|
+
plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
|
|
557
|
+
};
|
|
558
|
+
DURATION = /^(\d+(?:\.\d+)?)(ms|[smh])?$/;
|
|
559
|
+
UNIT_MS = { ms: 1, s: 1000, m: 60000, h: 3600000 };
|
|
560
|
+
});
|
|
561
|
+
|
|
562
|
+
// ../kit/src/chart.ts
|
|
563
|
+
var init_chart = __esm(() => {
|
|
564
|
+
init_format();
|
|
565
|
+
init_style();
|
|
566
|
+
});
|
|
567
|
+
|
|
568
|
+
// ../kit/src/text.ts
|
|
569
|
+
function distance(a, b) {
|
|
570
|
+
let previous = Array.from({ length: b.length + 1 }, (_, index) => index);
|
|
571
|
+
for (const [i, left] of [...a].entries()) {
|
|
572
|
+
const current = [i + 1];
|
|
573
|
+
for (const [j, right] of [...b].entries())
|
|
574
|
+
current.push(Math.min((previous[j + 1] ?? 0) + 1, (current[j] ?? 0) + 1, (previous[j] ?? 0) + (left === right ? 0 : 1)));
|
|
575
|
+
previous = current;
|
|
576
|
+
}
|
|
577
|
+
return previous[b.length] ?? 0;
|
|
578
|
+
}
|
|
579
|
+
var ANSI;
|
|
580
|
+
var init_text = __esm(() => {
|
|
581
|
+
ANSI = new RegExp(`${String.fromCharCode(27)}\\[[\\d;?]*[a-z]`, "gi");
|
|
582
|
+
});
|
|
583
|
+
|
|
584
|
+
// ../kit/src/cli.ts
|
|
585
|
+
import process4 from "process";
|
|
586
|
+
function commandRows(commands, colors) {
|
|
587
|
+
const width = Math.max(...Object.keys(commands).map((name) => name.length));
|
|
588
|
+
const groups = new Map([["Commands:", []]]);
|
|
589
|
+
for (const [name, { summary, group }] of Object.entries(commands)) {
|
|
590
|
+
const heading = group === undefined ? "Commands:" : `${group}:`;
|
|
591
|
+
const rows = groups.get(heading) ?? [];
|
|
592
|
+
rows.push(` ${colors.cyan(name.padEnd(width))} ${colors.dim(summary)}`);
|
|
593
|
+
groups.set(heading, rows);
|
|
594
|
+
}
|
|
595
|
+
return [...groups].filter(([, rows]) => rows.length > 0).flatMap(([heading, rows], index) => [...index === 0 ? [] : [""], colors.bold(heading), ...rows]);
|
|
596
|
+
}
|
|
597
|
+
function takeOutputFlags(argv) {
|
|
598
|
+
let index = 0;
|
|
599
|
+
for (;index < argv.length; index++) {
|
|
600
|
+
const word = argv[index];
|
|
601
|
+
if (word === "--plain")
|
|
602
|
+
applyOutput(undefined, true);
|
|
603
|
+
else if (word.startsWith("--color="))
|
|
604
|
+
applyOutput(word.slice("--color=".length), undefined);
|
|
605
|
+
else if (word === "--color" && argv[index + 1] !== undefined)
|
|
606
|
+
applyOutput(argv[++index], undefined);
|
|
607
|
+
else
|
|
608
|
+
break;
|
|
609
|
+
}
|
|
610
|
+
return argv.slice(index);
|
|
611
|
+
}
|
|
612
|
+
function closest(name, names) {
|
|
613
|
+
const started = names.find((known) => known.startsWith(name));
|
|
614
|
+
if (started !== undefined)
|
|
615
|
+
return started;
|
|
616
|
+
const [best] = names.map((known) => ({ known, far: distance(name, known) })).sort((a, b) => a.far - b.far);
|
|
617
|
+
return best !== undefined && best.far <= (name.length < 4 ? 1 : 2) ? best.known : undefined;
|
|
618
|
+
}
|
|
619
|
+
async function help({ path, header, commands, defaultCommand, examples }, stream) {
|
|
620
|
+
const colors = paint(stream);
|
|
621
|
+
const prefix = path.join(" ");
|
|
622
|
+
const fallback = defaultCommand === undefined ? undefined : commands[defaultCommand];
|
|
623
|
+
const options = fallback !== undefined && "run" in fallback ? await optionsOf(fallback.run) : undefined;
|
|
624
|
+
const own = Object.entries(options ?? {}).filter(([name]) => !(name in TOP_OPTIONS));
|
|
625
|
+
return [
|
|
626
|
+
header(colors),
|
|
627
|
+
"",
|
|
628
|
+
usageLine(`${prefix} ${defaultCommand === undefined ? colors.cyan("<command>") : `[${colors.cyan("<command>")}]`} [options]`, colors),
|
|
629
|
+
"",
|
|
630
|
+
...commandRows(commands, colors),
|
|
631
|
+
...own.length === 0 ? [] : ["", `${colors.bold(`Options of ${defaultCommand}:`)} ${colors.dim("the command run when none is named")}`, ...optionRows(Object.fromEntries(own), colors)],
|
|
632
|
+
"",
|
|
633
|
+
colors.bold("Options:"),
|
|
634
|
+
...optionRows(path.length === 1 ? TOP_OPTIONS : LEVEL_OPTIONS, colors),
|
|
635
|
+
...exampleRows(examples ?? [], colors),
|
|
636
|
+
"",
|
|
637
|
+
`${colors.dim("Run")} ${prefix} ${colors.cyan("<command>")} --help ${colors.dim("for its options.")}`
|
|
638
|
+
].join(`
|
|
639
|
+
`);
|
|
640
|
+
}
|
|
641
|
+
function printError(prefix, message, hint, cause) {
|
|
642
|
+
const colors = paint(process4.stderr);
|
|
643
|
+
const styled = takesControlCodes(process4.stderr);
|
|
644
|
+
const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
|
|
645
|
+
const under = (label, text, tint) => text === undefined ? "" : `
|
|
646
|
+
${styled ? tint(label) : `${label}:`} ${text}`;
|
|
647
|
+
console.error(`${head} ${message}${under("cause", cause, colors.dim)}${under("hint", hint, colors.yellow)}`);
|
|
648
|
+
}
|
|
649
|
+
function reportThrown(prefix, error, redact = (text) => text) {
|
|
650
|
+
if (error instanceof HelpShown)
|
|
651
|
+
return 0;
|
|
652
|
+
const help = error instanceof UsageError ? `run ${prefix} --help for its options` : undefined;
|
|
653
|
+
const named = error instanceof Error && !(error instanceof Exit) && error.name !== "Error" ? `${error.name}: ${error.message}` : undefined;
|
|
654
|
+
const cause = error instanceof Error && error.cause instanceof Error ? redact(error.cause.message) : undefined;
|
|
655
|
+
printError(prefix, redact(named ?? (error instanceof Error ? error.message : String(error))), error instanceof Exit ? error.hint ?? help : undefined, cause);
|
|
656
|
+
return error instanceof Exit ? error.code : 1;
|
|
657
|
+
}
|
|
658
|
+
async function dispatch(level, typed, { version, redact }) {
|
|
659
|
+
const prefix = level.path.join(" ");
|
|
660
|
+
let argv;
|
|
661
|
+
try {
|
|
662
|
+
argv = takeOutputFlags(typed);
|
|
663
|
+
} catch (error) {
|
|
664
|
+
return reportThrown(prefix, error);
|
|
665
|
+
}
|
|
666
|
+
const [name, ...args] = argv;
|
|
667
|
+
if (name === undefined && level.path.length > 1) {
|
|
668
|
+
console.error(await help(level, process4.stderr));
|
|
669
|
+
return 2;
|
|
670
|
+
}
|
|
671
|
+
if (name === undefined || name === "help" || name === "--help" || name === "-h") {
|
|
672
|
+
console.log(await help(level, process4.stdout));
|
|
673
|
+
return 0;
|
|
674
|
+
}
|
|
675
|
+
if (level.path.length === 1 && (name === "--version" || name === "-v")) {
|
|
676
|
+
console.log(version);
|
|
677
|
+
return 0;
|
|
678
|
+
}
|
|
679
|
+
let command = level.commands[level.aliases?.[name] ?? name];
|
|
680
|
+
let rest = args;
|
|
681
|
+
if (command === undefined && level.defaultCommand !== undefined) {
|
|
682
|
+
command = level.commands[level.defaultCommand];
|
|
683
|
+
rest = argv;
|
|
684
|
+
}
|
|
685
|
+
if (command === undefined) {
|
|
686
|
+
const meant = closest(name, Object.keys(level.commands));
|
|
687
|
+
printError(prefix, `no command ${name}`, meant === undefined ? `run ${prefix} --help for its commands` : `did you mean ${meant}?`);
|
|
688
|
+
return 2;
|
|
689
|
+
}
|
|
690
|
+
if ("commands" in command) {
|
|
691
|
+
const { summary } = command;
|
|
692
|
+
return dispatch({ path: [...level.path, name], header: (colors) => `${colors.bold(`${prefix} ${name}`)} ${summary}`, commands: command.commands, aliases: command.aliases, defaultCommand: undefined, examples: command.examples }, rest, { version, redact });
|
|
693
|
+
}
|
|
694
|
+
try {
|
|
695
|
+
return await command.run(rest);
|
|
696
|
+
} catch (error) {
|
|
697
|
+
return reportThrown(`${prefix} ${name}`, error, redact);
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
async function optionsOf(run) {
|
|
701
|
+
completion.active = true;
|
|
702
|
+
try {
|
|
703
|
+
await run([]);
|
|
704
|
+
} catch (error) {
|
|
705
|
+
if (error instanceof Completing)
|
|
706
|
+
return error.options;
|
|
707
|
+
} finally {
|
|
708
|
+
completion.active = false;
|
|
709
|
+
}
|
|
710
|
+
return {};
|
|
711
|
+
}
|
|
712
|
+
async function leafCandidates(run, words) {
|
|
713
|
+
if (!(words.at(-1) ?? "").startsWith("-"))
|
|
714
|
+
return [FILES];
|
|
715
|
+
return Object.entries(await optionsOf(run)).map(([name, option]) => `--${name} ${option.description}`);
|
|
716
|
+
}
|
|
717
|
+
async function candidates(commands, aliases, defaultCommand, words) {
|
|
718
|
+
const [word = "", ...rest] = words;
|
|
719
|
+
const command = commands[aliases?.[word] ?? word];
|
|
720
|
+
if (rest.length === 0 && !word.startsWith("-"))
|
|
721
|
+
return Object.entries(commands).map(([name, { summary }]) => `${name} ${summary}`);
|
|
722
|
+
if (command === undefined) {
|
|
723
|
+
const fallback = defaultCommand === undefined ? undefined : commands[defaultCommand];
|
|
724
|
+
return fallback !== undefined && "run" in fallback ? leafCandidates(fallback.run, words) : [];
|
|
725
|
+
}
|
|
726
|
+
return "commands" in command ? candidates(command.commands, command.aliases, undefined, rest) : leafCandidates(command.run, rest);
|
|
727
|
+
}
|
|
728
|
+
async function printCandidates(found) {
|
|
729
|
+
for (const line of await found)
|
|
730
|
+
console.log(line);
|
|
731
|
+
return 0;
|
|
732
|
+
}
|
|
733
|
+
async function runCli(cli, argv = process4.argv.slice(2)) {
|
|
734
|
+
if (argv[0] === COMPLETE)
|
|
735
|
+
return printCandidates(candidates(cli.commands, cli.aliases, cli.defaultCommand, argv.slice(1)));
|
|
736
|
+
return dispatch({ path: [cli.name], header: (colors) => `${colors.bold(cli.name)} ${colors.dim(cli.version)} ${cli.about}`, commands: cli.commands, aliases: cli.aliases, defaultCommand: cli.defaultCommand, examples: cli.examples }, argv, { version: cli.version, redact: cli.redact });
|
|
737
|
+
}
|
|
738
|
+
var LEVEL_OPTIONS, TOP_OPTIONS, COMPLETE = "__complete", FILES = "__files__";
|
|
739
|
+
var init_cli = __esm(() => {
|
|
740
|
+
init_args();
|
|
741
|
+
init_style();
|
|
742
|
+
init_text();
|
|
743
|
+
LEVEL_OPTIONS = {
|
|
744
|
+
...OUTPUT_OPTIONS,
|
|
745
|
+
help: { type: "boolean", short: "h", description: "show this help" }
|
|
746
|
+
};
|
|
747
|
+
TOP_OPTIONS = { ...LEVEL_OPTIONS, version: { type: "boolean", short: "v", description: "print the version" } };
|
|
748
|
+
});
|
|
749
|
+
|
|
750
|
+
// ../kit/src/config.ts
|
|
751
|
+
var init_config = __esm(() => {
|
|
752
|
+
init_args();
|
|
753
|
+
});
|
|
754
|
+
|
|
755
|
+
// ../kit/src/process.ts
|
|
756
|
+
import { constants } from "os";
|
|
757
|
+
import process5 from "process";
|
|
758
|
+
async function collect(stream, name, chunks) {
|
|
759
|
+
for await (const data of stream)
|
|
760
|
+
chunks.push({ stream: name, data });
|
|
761
|
+
}
|
|
762
|
+
function exitCodeOf(code, signal) {
|
|
763
|
+
if (code !== null)
|
|
764
|
+
return code;
|
|
765
|
+
if (typeof signal === "number")
|
|
766
|
+
return 128 + signal;
|
|
767
|
+
return signal === null ? 129 : 128 + constants.signals[signal];
|
|
768
|
+
}
|
|
769
|
+
function holdSignals(cleanup) {
|
|
770
|
+
let received;
|
|
771
|
+
let child;
|
|
772
|
+
const held = {
|
|
773
|
+
get signal() {
|
|
774
|
+
return received;
|
|
775
|
+
},
|
|
776
|
+
forward: (to) => {
|
|
777
|
+
child = to;
|
|
778
|
+
},
|
|
779
|
+
release: () => {
|
|
780
|
+
for (const signal of SIGNALS)
|
|
781
|
+
process5.off(signal, onSignal);
|
|
782
|
+
}
|
|
783
|
+
};
|
|
784
|
+
function onSignal(signal) {
|
|
785
|
+
received = signal;
|
|
786
|
+
if (child !== undefined) {
|
|
787
|
+
child.kill(signal);
|
|
788
|
+
return;
|
|
789
|
+
}
|
|
790
|
+
if (cleanup === undefined)
|
|
791
|
+
return;
|
|
792
|
+
held.release();
|
|
793
|
+
cleanup(signal);
|
|
794
|
+
process5.kill(process5.pid, signal);
|
|
795
|
+
}
|
|
796
|
+
for (const signal of SIGNALS)
|
|
797
|
+
process5.on(signal, onSignal);
|
|
798
|
+
return held;
|
|
799
|
+
}
|
|
800
|
+
async function runCommand(argv, { cwd, env, stdin = "ignore" } = {}) {
|
|
801
|
+
const chunks = [];
|
|
802
|
+
const proc = Bun.spawn(argv, { ...cwd === undefined ? {} : { cwd }, ...env === undefined ? {} : { env }, stdin, stdout: "pipe", stderr: "pipe" });
|
|
803
|
+
await Promise.all([collect(proc.stdout, "stdout", chunks), collect(proc.stderr, "stderr", chunks)]);
|
|
804
|
+
await proc.exited;
|
|
805
|
+
const output = Buffer.concat(chunks.map(({ data }) => data));
|
|
806
|
+
return { code: exitCodeOf(proc.exitCode, proc.signalCode), chunks, output, text: output.toString() };
|
|
807
|
+
}
|
|
808
|
+
var SIGNALS;
|
|
809
|
+
var init_process = __esm(() => {
|
|
810
|
+
SIGNALS = ["SIGINT", "SIGTERM", "SIGHUP"];
|
|
811
|
+
});
|
|
812
|
+
|
|
813
|
+
// ../kit/src/index.ts
|
|
814
|
+
var init_src = __esm(() => {
|
|
815
|
+
init_args();
|
|
816
|
+
init_chart();
|
|
817
|
+
init_cli();
|
|
818
|
+
init_config();
|
|
819
|
+
init_format();
|
|
820
|
+
init_process();
|
|
821
|
+
init_style();
|
|
822
|
+
init_text();
|
|
823
|
+
});
|
|
824
|
+
|
|
825
|
+
// src/popular.json
|
|
826
|
+
var popular_default;
|
|
827
|
+
var init_popular = __esm(() => {
|
|
828
|
+
popular_default = [
|
|
829
|
+
"semver",
|
|
830
|
+
"minimatch",
|
|
831
|
+
"debug",
|
|
832
|
+
"ansi-styles",
|
|
833
|
+
"brace-expansion",
|
|
834
|
+
"strip-ansi",
|
|
835
|
+
"ansi-regex",
|
|
836
|
+
"ms",
|
|
837
|
+
"supports-color",
|
|
838
|
+
"chalk",
|
|
839
|
+
"commander",
|
|
840
|
+
"lru-cache",
|
|
841
|
+
"string-width",
|
|
842
|
+
"wrap-ansi",
|
|
843
|
+
"tslib",
|
|
844
|
+
"picomatch",
|
|
845
|
+
"emoji-regex",
|
|
846
|
+
"glob",
|
|
847
|
+
"type-fest",
|
|
848
|
+
"color-name",
|
|
849
|
+
"eslint-visitor-keys",
|
|
850
|
+
"color-convert",
|
|
851
|
+
"ajv",
|
|
852
|
+
"minipass",
|
|
853
|
+
"source-map",
|
|
854
|
+
"balanced-match",
|
|
855
|
+
"readable-stream",
|
|
856
|
+
"which",
|
|
857
|
+
"glob-parent",
|
|
858
|
+
"escape-string-regexp",
|
|
859
|
+
"has-flag",
|
|
860
|
+
"find-up",
|
|
861
|
+
"locate-path",
|
|
862
|
+
"json-schema-traverse",
|
|
863
|
+
"p-limit",
|
|
864
|
+
"yallist",
|
|
865
|
+
"safe-buffer",
|
|
866
|
+
"uuid",
|
|
867
|
+
"p-locate",
|
|
868
|
+
"undici-types",
|
|
869
|
+
"ignore",
|
|
870
|
+
"iconv-lite",
|
|
871
|
+
"signal-exit",
|
|
872
|
+
"esbuild",
|
|
873
|
+
"is-fullwidth-code-point",
|
|
874
|
+
"js-yaml",
|
|
875
|
+
"entities",
|
|
876
|
+
"globals",
|
|
877
|
+
"postcss",
|
|
878
|
+
"isexe",
|
|
879
|
+
"isarray",
|
|
880
|
+
"path-key",
|
|
881
|
+
"string_decoder",
|
|
882
|
+
"argparse",
|
|
883
|
+
"ws",
|
|
884
|
+
"mime-db",
|
|
885
|
+
"resolve",
|
|
886
|
+
"agent-base",
|
|
887
|
+
"@esbuild/linux-x64",
|
|
888
|
+
"yargs-parser",
|
|
889
|
+
"mime-types",
|
|
890
|
+
"acorn",
|
|
891
|
+
"estraverse",
|
|
892
|
+
"cross-spawn",
|
|
893
|
+
"react-is",
|
|
894
|
+
"picocolors",
|
|
895
|
+
"fs-extra",
|
|
896
|
+
"hasown",
|
|
897
|
+
"nanoid",
|
|
898
|
+
"yargs",
|
|
899
|
+
"resolve-from",
|
|
900
|
+
"shebang-command",
|
|
901
|
+
"pretty-format",
|
|
902
|
+
"json5",
|
|
903
|
+
"https-proxy-agent",
|
|
904
|
+
"path-to-regexp",
|
|
905
|
+
"path-exists",
|
|
906
|
+
"punycode",
|
|
907
|
+
"js-tokens",
|
|
908
|
+
"cliui",
|
|
909
|
+
"shebang-regex",
|
|
910
|
+
"@babel/types",
|
|
911
|
+
"chokidar",
|
|
912
|
+
"strip-json-comments",
|
|
913
|
+
"inherits",
|
|
914
|
+
"webidl-conversions",
|
|
915
|
+
"get-stream",
|
|
916
|
+
"eslint-scope",
|
|
917
|
+
"cookie",
|
|
918
|
+
"@babel/parser",
|
|
919
|
+
"qs",
|
|
920
|
+
"is-number",
|
|
921
|
+
"whatwg-url",
|
|
922
|
+
"@types/estree",
|
|
923
|
+
"tr46",
|
|
924
|
+
"convert-source-map",
|
|
925
|
+
"is-glob",
|
|
926
|
+
"braces",
|
|
927
|
+
"fast-deep-equal",
|
|
928
|
+
"form-data",
|
|
929
|
+
"lodash",
|
|
930
|
+
"@babel/helper-validator-identifier",
|
|
931
|
+
"electron-to-chromium",
|
|
932
|
+
"fill-range",
|
|
933
|
+
"function-bind",
|
|
934
|
+
"readdirp",
|
|
935
|
+
"escalade",
|
|
936
|
+
"graceful-fs",
|
|
937
|
+
"negotiator",
|
|
938
|
+
"is-stream",
|
|
939
|
+
"camelcase",
|
|
940
|
+
"@babel/runtime",
|
|
941
|
+
"yocto-queue",
|
|
942
|
+
"to-regex-range",
|
|
943
|
+
"node-fetch",
|
|
944
|
+
"micromatch",
|
|
945
|
+
"node-releases",
|
|
946
|
+
"get-intrinsic",
|
|
947
|
+
"universalify",
|
|
948
|
+
"path-scurry",
|
|
949
|
+
"jsesc",
|
|
950
|
+
"browserslist",
|
|
951
|
+
"es-errors",
|
|
952
|
+
"statuses",
|
|
953
|
+
"@radix-ui/react-primitive",
|
|
954
|
+
"magic-string",
|
|
955
|
+
"rimraf",
|
|
956
|
+
"is-extglob",
|
|
957
|
+
"@jridgewell/trace-mapping",
|
|
958
|
+
"@jridgewell/resolve-uri",
|
|
959
|
+
"http-errors",
|
|
960
|
+
"onetime",
|
|
961
|
+
"has-symbols",
|
|
962
|
+
"es-define-property",
|
|
963
|
+
"gopd",
|
|
964
|
+
"util-deprecate",
|
|
965
|
+
"object-assign",
|
|
966
|
+
"jiti",
|
|
967
|
+
"yaml",
|
|
968
|
+
"dotenv",
|
|
969
|
+
"@babel/generator",
|
|
970
|
+
"@babel/template",
|
|
971
|
+
"imurmurhash",
|
|
972
|
+
"postcss-selector-parser",
|
|
973
|
+
"fast-glob",
|
|
974
|
+
"update-browserslist-db",
|
|
975
|
+
"@types/node",
|
|
976
|
+
"@babel/compat-data",
|
|
977
|
+
"eventemitter3",
|
|
978
|
+
"callsites",
|
|
979
|
+
"http-proxy-agent",
|
|
980
|
+
"detect-libc",
|
|
981
|
+
"espree",
|
|
982
|
+
"execa",
|
|
983
|
+
"@babel/core",
|
|
984
|
+
"@babel/helpers",
|
|
985
|
+
"concat-map",
|
|
986
|
+
"source-map-js",
|
|
987
|
+
"tinyglobby",
|
|
988
|
+
"call-bind-apply-helpers",
|
|
989
|
+
"flat-cache",
|
|
990
|
+
"fdir",
|
|
991
|
+
"pify",
|
|
992
|
+
"@jest/types",
|
|
993
|
+
"normalize-path",
|
|
994
|
+
"is-core-module",
|
|
995
|
+
"eslint",
|
|
996
|
+
"minimist",
|
|
997
|
+
"estree-walker",
|
|
998
|
+
"file-entry-cache",
|
|
999
|
+
"object-inspect",
|
|
1000
|
+
"buffer",
|
|
1001
|
+
"uri-js",
|
|
1002
|
+
"import-fresh",
|
|
1003
|
+
"@babel/helper-module-transforms",
|
|
1004
|
+
"optionator",
|
|
1005
|
+
"flatted",
|
|
1006
|
+
"math-intrinsics",
|
|
1007
|
+
"safer-buffer",
|
|
1008
|
+
"y18n",
|
|
1009
|
+
"@babel/helper-module-imports",
|
|
1010
|
+
"mkdirp",
|
|
1011
|
+
"dunder-proto",
|
|
1012
|
+
"path-parse",
|
|
1013
|
+
"fastq",
|
|
1014
|
+
"levn",
|
|
1015
|
+
"@babel/helper-compilation-targets",
|
|
1016
|
+
"@babel/helper-string-parser",
|
|
1017
|
+
"keyv",
|
|
1018
|
+
"get-proto",
|
|
1019
|
+
"csstype",
|
|
1020
|
+
"npm-run-path",
|
|
1021
|
+
"fast-json-stable-stringify",
|
|
1022
|
+
"reusify",
|
|
1023
|
+
"@babel/helper-plugin-utils",
|
|
1024
|
+
"kind-of",
|
|
1025
|
+
"mime",
|
|
1026
|
+
"caniuse-lite",
|
|
1027
|
+
"lines-and-columns",
|
|
1028
|
+
"fast-levenshtein",
|
|
1029
|
+
"supports-preserve-symlinks-flag",
|
|
1030
|
+
"make-dir",
|
|
1031
|
+
"slash",
|
|
1032
|
+
"prelude-ls",
|
|
1033
|
+
"typescript",
|
|
1034
|
+
"strip-bom",
|
|
1035
|
+
"parent-module",
|
|
1036
|
+
"esutils",
|
|
1037
|
+
"ci-info",
|
|
1038
|
+
"@smithy/util-utf8",
|
|
1039
|
+
"type-check",
|
|
1040
|
+
"mimic-fn",
|
|
1041
|
+
"@babel/helper-validator-option",
|
|
1042
|
+
"@types/json-schema",
|
|
1043
|
+
"@rolldown/pluginutils",
|
|
1044
|
+
"side-channel-list",
|
|
1045
|
+
"json-buffer",
|
|
1046
|
+
"raw-body",
|
|
1047
|
+
"has-tostringtag",
|
|
1048
|
+
"wrappy",
|
|
1049
|
+
"diff",
|
|
1050
|
+
"jackspeak",
|
|
1051
|
+
"baseline-browser-mapping",
|
|
1052
|
+
"deep-is",
|
|
1053
|
+
"foreground-child",
|
|
1054
|
+
"@eslint/js",
|
|
1055
|
+
"anymatch",
|
|
1056
|
+
"natural-compare",
|
|
1057
|
+
"esquery",
|
|
1058
|
+
"@eslint-community/regexpp",
|
|
1059
|
+
"es-set-tostringtag",
|
|
1060
|
+
"acorn-jsx",
|
|
1061
|
+
"parse5",
|
|
1062
|
+
"finalhandler",
|
|
1063
|
+
"parse-json",
|
|
1064
|
+
"depd",
|
|
1065
|
+
"axios",
|
|
1066
|
+
"run-parallel",
|
|
1067
|
+
"source-map-support",
|
|
1068
|
+
"esrecurse",
|
|
1069
|
+
"call-bound",
|
|
1070
|
+
"content-disposition",
|
|
1071
|
+
"human-signals",
|
|
1072
|
+
"ts-api-utils",
|
|
1073
|
+
"ansi-escapes",
|
|
1074
|
+
"jest-util",
|
|
1075
|
+
"send",
|
|
1076
|
+
"@opentelemetry/core",
|
|
1077
|
+
"type-is",
|
|
1078
|
+
"encodeurl",
|
|
1079
|
+
"once",
|
|
1080
|
+
"cosmiconfig",
|
|
1081
|
+
"lodash.merge",
|
|
1082
|
+
"json-stable-stringify-without-jsonify",
|
|
1083
|
+
"open",
|
|
1084
|
+
"prettier",
|
|
1085
|
+
"@eslint/eslintrc",
|
|
1086
|
+
"is-arrayish",
|
|
1087
|
+
"@jridgewell/sourcemap-codec",
|
|
1088
|
+
"gensync",
|
|
1089
|
+
"word-wrap",
|
|
1090
|
+
"express",
|
|
1091
|
+
"arg",
|
|
1092
|
+
"jsonfile",
|
|
1093
|
+
"schema-utils",
|
|
1094
|
+
"@smithy/is-array-buffer",
|
|
1095
|
+
"@typescript-eslint/types",
|
|
1096
|
+
"chownr",
|
|
1097
|
+
"delayed-stream",
|
|
1098
|
+
"@smithy/util-buffer-from",
|
|
1099
|
+
"asynckit",
|
|
1100
|
+
"tapable",
|
|
1101
|
+
"enhanced-resolve",
|
|
1102
|
+
"aria-query",
|
|
1103
|
+
"indent-string",
|
|
1104
|
+
"bytes",
|
|
1105
|
+
"binary-extensions",
|
|
1106
|
+
"ini",
|
|
1107
|
+
"@radix-ui/react-context",
|
|
1108
|
+
"doctrine",
|
|
1109
|
+
"queue-microtask",
|
|
1110
|
+
"accepts",
|
|
1111
|
+
"merge2",
|
|
1112
|
+
"get-caller-file",
|
|
1113
|
+
"@humanwhocodes/retry",
|
|
1114
|
+
"@jridgewell/gen-mapping",
|
|
1115
|
+
"@typescript-eslint/typescript-estree",
|
|
1116
|
+
"jest-worker",
|
|
1117
|
+
"proxy-from-env",
|
|
1118
|
+
"clsx",
|
|
1119
|
+
"side-channel-map",
|
|
1120
|
+
"@typescript-eslint/visitor-keys",
|
|
1121
|
+
"fresh",
|
|
1122
|
+
"restore-cursor",
|
|
1123
|
+
"on-finished",
|
|
1124
|
+
"is-plain-obj",
|
|
1125
|
+
"ipaddr.js",
|
|
1126
|
+
"pathe",
|
|
1127
|
+
"@jest/schemas",
|
|
1128
|
+
"base64-js",
|
|
1129
|
+
"@smithy/types",
|
|
1130
|
+
"require-directory",
|
|
1131
|
+
"tough-cookie",
|
|
1132
|
+
"is-binary-path",
|
|
1133
|
+
"body-parser",
|
|
1134
|
+
"postcss-value-parser",
|
|
1135
|
+
"media-typer",
|
|
1136
|
+
"setprototypeof",
|
|
1137
|
+
"side-channel-weakmap",
|
|
1138
|
+
"@typescript-eslint/tsconfig-utils",
|
|
1139
|
+
"@isaacs/cliui",
|
|
1140
|
+
"@rollup/rollup-linux-x64-gnu",
|
|
1141
|
+
"is-wsl",
|
|
1142
|
+
"retry",
|
|
1143
|
+
"@aws-sdk/types",
|
|
1144
|
+
"@types/react-dom",
|
|
1145
|
+
"combined-stream",
|
|
1146
|
+
"es-object-atoms",
|
|
1147
|
+
"@eslint/core",
|
|
1148
|
+
"whatwg-mimetype",
|
|
1149
|
+
"domutils",
|
|
1150
|
+
"@rollup/rollup-linux-x64-musl",
|
|
1151
|
+
"core-util-is",
|
|
1152
|
+
"@typescript-eslint/scope-manager",
|
|
1153
|
+
"esprima",
|
|
1154
|
+
"loose-envify",
|
|
1155
|
+
"cookie-signature",
|
|
1156
|
+
"follow-redirects",
|
|
1157
|
+
"cli-cursor",
|
|
1158
|
+
"strip-final-newline",
|
|
1159
|
+
"@typescript-eslint/project-service",
|
|
1160
|
+
"eastasianwidth",
|
|
1161
|
+
"json-parse-even-better-errors",
|
|
1162
|
+
"sprintf-js",
|
|
1163
|
+
"path-type",
|
|
1164
|
+
"content-type",
|
|
1165
|
+
"es-module-lexer",
|
|
1166
|
+
"@nodelib/fs.scandir",
|
|
1167
|
+
"write-file-atomic",
|
|
1168
|
+
"@eslint/plugin-kit",
|
|
1169
|
+
"ieee754",
|
|
1170
|
+
"prop-types",
|
|
1171
|
+
"require-from-string",
|
|
1172
|
+
"dom-serializer",
|
|
1173
|
+
"call-bind",
|
|
1174
|
+
"@eslint/config-array",
|
|
1175
|
+
"has-property-descriptors",
|
|
1176
|
+
"@nodelib/fs.stat",
|
|
1177
|
+
"merge-descriptors",
|
|
1178
|
+
"slice-ansi",
|
|
1179
|
+
"rxjs",
|
|
1180
|
+
"p-map",
|
|
1181
|
+
"toidentifier",
|
|
1182
|
+
"globby",
|
|
1183
|
+
"domhandler",
|
|
1184
|
+
"async",
|
|
1185
|
+
"@babel/helper-globals",
|
|
1186
|
+
"pirates",
|
|
1187
|
+
"@opentelemetry/semantic-conventions",
|
|
1188
|
+
"@typescript-eslint/utils",
|
|
1189
|
+
"date-fns",
|
|
1190
|
+
"is-docker",
|
|
1191
|
+
"tar",
|
|
1192
|
+
"which-typed-array",
|
|
1193
|
+
"ajv-formats",
|
|
1194
|
+
"@opentelemetry/api-logs",
|
|
1195
|
+
"@opentelemetry/resources",
|
|
1196
|
+
"side-channel",
|
|
1197
|
+
"cjs-module-lexer",
|
|
1198
|
+
"range-parser",
|
|
1199
|
+
"@humanfs/node",
|
|
1200
|
+
"define-data-property",
|
|
1201
|
+
"node-addon-api",
|
|
1202
|
+
"pako",
|
|
1203
|
+
"lilconfig",
|
|
1204
|
+
"fast-uri",
|
|
1205
|
+
"ip-address",
|
|
1206
|
+
"fs.realpath",
|
|
1207
|
+
"@img/sharp-libvips-linuxmusl-x64",
|
|
1208
|
+
"cssesc",
|
|
1209
|
+
"@opentelemetry/instrumentation",
|
|
1210
|
+
"domelementtype",
|
|
1211
|
+
"hosted-git-info",
|
|
1212
|
+
"@eslint/object-schema",
|
|
1213
|
+
"etag",
|
|
1214
|
+
"@eslint/config-helpers",
|
|
1215
|
+
"package-json-from-dist",
|
|
1216
|
+
"@humanfs/core",
|
|
1217
|
+
"htmlparser2",
|
|
1218
|
+
"jest-message-util",
|
|
1219
|
+
"for-each",
|
|
1220
|
+
"pkg-dir",
|
|
1221
|
+
"unpipe",
|
|
1222
|
+
"buffer-from",
|
|
1223
|
+
"es-abstract",
|
|
1224
|
+
"is-unicode-supported",
|
|
1225
|
+
"@types/yargs",
|
|
1226
|
+
"is-callable",
|
|
1227
|
+
"fast-xml-parser",
|
|
1228
|
+
"istanbul-lib-instrument",
|
|
1229
|
+
"escape-html",
|
|
1230
|
+
"is-regex",
|
|
1231
|
+
"dom-accessibility-api",
|
|
1232
|
+
"css-tree",
|
|
1233
|
+
"error-ex",
|
|
1234
|
+
"ee-first",
|
|
1235
|
+
"@types/unist",
|
|
1236
|
+
"log-symbols",
|
|
1237
|
+
"path-is-absolute",
|
|
1238
|
+
"end-of-stream",
|
|
1239
|
+
"@vitest/utils",
|
|
1240
|
+
"object.assign",
|
|
1241
|
+
"object-keys",
|
|
1242
|
+
"tinyexec",
|
|
1243
|
+
"scheduler",
|
|
1244
|
+
"p-try",
|
|
1245
|
+
"process-nextick-args",
|
|
1246
|
+
"vary",
|
|
1247
|
+
"@babel/traverse",
|
|
1248
|
+
"@pkgjs/parseargs",
|
|
1249
|
+
"@types/babel__generator",
|
|
1250
|
+
"kleur",
|
|
1251
|
+
"zod",
|
|
1252
|
+
"merge-stream",
|
|
1253
|
+
"available-typed-arrays",
|
|
1254
|
+
"mute-stream",
|
|
1255
|
+
"is-typed-array",
|
|
1256
|
+
"safe-regex-test",
|
|
1257
|
+
"tsconfig-paths",
|
|
1258
|
+
"minizlib",
|
|
1259
|
+
"tar-stream",
|
|
1260
|
+
"@floating-ui/core",
|
|
1261
|
+
"jose",
|
|
1262
|
+
"deepmerge",
|
|
1263
|
+
"get-tsconfig",
|
|
1264
|
+
"set-function-length",
|
|
1265
|
+
"@vitest/spy",
|
|
1266
|
+
"css-select",
|
|
1267
|
+
"@types/babel__core",
|
|
1268
|
+
"forwarded",
|
|
1269
|
+
"react",
|
|
1270
|
+
"@typescript-eslint/parser",
|
|
1271
|
+
"ajv-keywords",
|
|
1272
|
+
"define-properties",
|
|
1273
|
+
"is-generator-function",
|
|
1274
|
+
"regexp.prototype.flags",
|
|
1275
|
+
"acorn-walk",
|
|
1276
|
+
"pump",
|
|
1277
|
+
"data-uri-to-buffer",
|
|
1278
|
+
"object-hash",
|
|
1279
|
+
"jsdom",
|
|
1280
|
+
"nopt",
|
|
1281
|
+
"@babel/plugin-syntax-jsx",
|
|
1282
|
+
"@floating-ui/dom",
|
|
1283
|
+
"tiny-invariant",
|
|
1284
|
+
"strip-indent",
|
|
1285
|
+
"d3-array",
|
|
1286
|
+
"chai",
|
|
1287
|
+
"@babel/code-frame",
|
|
1288
|
+
"@typescript-eslint/eslint-plugin",
|
|
1289
|
+
"proxy-addr",
|
|
1290
|
+
"parseurl",
|
|
1291
|
+
"@floating-ui/utils",
|
|
1292
|
+
"ora",
|
|
1293
|
+
"html-encoding-sniffer",
|
|
1294
|
+
"pnpm",
|
|
1295
|
+
"whatwg-encoding",
|
|
1296
|
+
"events",
|
|
1297
|
+
"@typescript-eslint/type-utils",
|
|
1298
|
+
"env-paths",
|
|
1299
|
+
"internal-slot",
|
|
1300
|
+
"string.prototype.trimend",
|
|
1301
|
+
"extend",
|
|
1302
|
+
"resolve-pkg-maps",
|
|
1303
|
+
"istanbul-lib-coverage",
|
|
1304
|
+
"react-dom",
|
|
1305
|
+
"is-number-object",
|
|
1306
|
+
"@radix-ui/primitive",
|
|
1307
|
+
"is-plain-object",
|
|
1308
|
+
"string.prototype.trimstart",
|
|
1309
|
+
"@babel/plugin-syntax-typescript",
|
|
1310
|
+
"jest-diff",
|
|
1311
|
+
"define-lazy-prop",
|
|
1312
|
+
"globalthis",
|
|
1313
|
+
"which-boxed-primitive",
|
|
1314
|
+
"@vitest/expect",
|
|
1315
|
+
"sax",
|
|
1316
|
+
"@floating-ui/react-dom",
|
|
1317
|
+
"@vitest/pretty-format",
|
|
1318
|
+
"internmap",
|
|
1319
|
+
"@radix-ui/react-compose-refs",
|
|
1320
|
+
"is-symbol",
|
|
1321
|
+
"@eslint-community/eslint-utils",
|
|
1322
|
+
"bl",
|
|
1323
|
+
"serve-static",
|
|
1324
|
+
"get-symbol-description",
|
|
1325
|
+
"is-shared-array-buffer",
|
|
1326
|
+
"functions-have-names",
|
|
1327
|
+
"array-buffer-byte-length",
|
|
1328
|
+
"socks-proxy-agent"
|
|
1329
|
+
];
|
|
1330
|
+
});
|
|
1331
|
+
|
|
1332
|
+
// src/nearmiss.ts
|
|
1333
|
+
function baseName(name) {
|
|
1334
|
+
return name.slice(name.indexOf("/") + 1);
|
|
1335
|
+
}
|
|
1336
|
+
function scopeOf(name) {
|
|
1337
|
+
return name.startsWith("@") ? name.slice(0, name.indexOf("/")) : "";
|
|
1338
|
+
}
|
|
1339
|
+
function squash(name) {
|
|
1340
|
+
return name.toLowerCase().replace(SEPARATORS, "");
|
|
1341
|
+
}
|
|
1342
|
+
function resemblance(name, popular) {
|
|
1343
|
+
if (scopeOf(name) !== scopeOf(popular) && baseName(name) === baseName(popular) && baseName(name).length >= MIN_LENGTH)
|
|
1344
|
+
return `${popular} under another scope`;
|
|
1345
|
+
if (squash(name) === squash(popular))
|
|
1346
|
+
return `${popular} spelled with other separators or case`;
|
|
1347
|
+
const edits = distance(name, popular);
|
|
1348
|
+
const allowed = Math.min(name.length, popular.length) >= MIN_LENGTH * 2 ? 2 : 1;
|
|
1349
|
+
return Math.min(name.length, popular.length) >= MIN_LENGTH && edits <= allowed ? `${popular}, ${edits} ${edits === 1 ? "edit" : "edits"} away` : undefined;
|
|
1350
|
+
}
|
|
1351
|
+
function nearMisses(name, popular = popular_default) {
|
|
1352
|
+
if (popular.includes(name))
|
|
1353
|
+
return [];
|
|
1354
|
+
const found = [];
|
|
1355
|
+
for (const other of popular) {
|
|
1356
|
+
const text = resemblance(name, other);
|
|
1357
|
+
if (text !== undefined)
|
|
1358
|
+
found.push({ text, edits: distance(name, other) });
|
|
1359
|
+
}
|
|
1360
|
+
return found.sort((a, b) => a.edits - b.edits).slice(0, 3).map((match) => match.text);
|
|
1361
|
+
}
|
|
1362
|
+
var SEPARATORS, MIN_LENGTH = 5;
|
|
1363
|
+
var init_nearmiss = __esm(() => {
|
|
1364
|
+
init_src();
|
|
1365
|
+
init_popular();
|
|
1366
|
+
SEPARATORS = /[-_.]/g;
|
|
1367
|
+
});
|
|
1368
|
+
|
|
1369
|
+
// src/analyze.ts
|
|
1370
|
+
function parseSpec(text) {
|
|
1371
|
+
const at = text.search(VERSION_SEPARATOR);
|
|
1372
|
+
return at === -1 ? { name: text } : { name: text.slice(0, at), request: text.slice(at + 1) };
|
|
1373
|
+
}
|
|
1374
|
+
function isStable(version) {
|
|
1375
|
+
return !version.includes("-");
|
|
1376
|
+
}
|
|
1377
|
+
function resolve(packument, request) {
|
|
1378
|
+
const tags = packument["dist-tags"] ?? {};
|
|
1379
|
+
const versions = Object.keys(packument.versions ?? {});
|
|
1380
|
+
const wanted = request === undefined || request === "" ? "latest" : request;
|
|
1381
|
+
if (tags[wanted] !== undefined)
|
|
1382
|
+
return tags[wanted];
|
|
1383
|
+
if (versions.includes(wanted))
|
|
1384
|
+
return wanted;
|
|
1385
|
+
return versions.filter((version) => Bun.semver.satisfies(version, wanted)).sort(Bun.semver.order).at(-1);
|
|
1386
|
+
}
|
|
1387
|
+
function licenseOf(license) {
|
|
1388
|
+
return typeof license === "string" ? license : license?.type;
|
|
1389
|
+
}
|
|
1390
|
+
function repositoryOf(packument) {
|
|
1391
|
+
const repository = typeof packument.repository === "string" ? packument.repository : packument.repository?.url;
|
|
1392
|
+
return repository?.replace(GIT_PREFIX, "") ?? packument.homepage;
|
|
1393
|
+
}
|
|
1394
|
+
function ageDays(published, now) {
|
|
1395
|
+
const at = Date.parse(published ?? "");
|
|
1396
|
+
return Number.isNaN(at) ? undefined : (now - at) / DAY;
|
|
1397
|
+
}
|
|
1398
|
+
function installScriptsOf(version) {
|
|
1399
|
+
return Object.fromEntries(INSTALL_SCRIPTS.flatMap((name) => version?.scripts?.[name] === undefined ? [] : [[name, version.scripts[name]]]));
|
|
1400
|
+
}
|
|
1401
|
+
function safeRelease(packument, now, minAgeDays) {
|
|
1402
|
+
const old = Object.keys(packument.versions ?? {}).filter((version) => isStable(version) && (ageDays(packument.time?.[version], now) ?? 0) >= minAgeDays && packument.time?.[version] !== undefined);
|
|
1403
|
+
const version = old.sort(Bun.semver.order).at(-1);
|
|
1404
|
+
return version === undefined ? undefined : { version, published: packument.time?.[version] };
|
|
1405
|
+
}
|
|
1406
|
+
function analyze(input) {
|
|
1407
|
+
const { spec, packument, registry, now = Date.now(), minAgeDays = DEFAULT_MIN_AGE_DAYS } = input;
|
|
1408
|
+
const report = { name: spec.name, registry, exists: packument !== undefined, requested: spec.request, installScripts: {}, nearMisses: nearMisses(spec.name), warnings: [], blocked: false, downloads: input.downloads };
|
|
1409
|
+
if (report.nearMisses.length > 0)
|
|
1410
|
+
report.warnings.push(`name looks like ${report.nearMisses.join("; ")}, check it is the package meant`);
|
|
1411
|
+
if (packument === undefined) {
|
|
1412
|
+
report.blocked = true;
|
|
1413
|
+
report.warnings.unshift(`${spec.name} is not on ${registry}, the name may be guessed`);
|
|
1414
|
+
return report;
|
|
1415
|
+
}
|
|
1416
|
+
const latest = packument["dist-tags"]?.latest;
|
|
1417
|
+
const version = resolve(packument, spec.request);
|
|
1418
|
+
const entry = version === undefined ? undefined : packument.versions?.[version];
|
|
1419
|
+
report.description = packument.description;
|
|
1420
|
+
report.license = licenseOf(entry?.license) ?? licenseOf(packument.license);
|
|
1421
|
+
report.repository = repositoryOf(packument);
|
|
1422
|
+
report.latest = latest === undefined ? undefined : { version: latest, published: packument.time?.[latest] };
|
|
1423
|
+
report.safe = safeRelease(packument, now, minAgeDays);
|
|
1424
|
+
report.version = version;
|
|
1425
|
+
report.published = version === undefined ? undefined : packument.time?.[version];
|
|
1426
|
+
report.installScripts = installScriptsOf(entry);
|
|
1427
|
+
report.deprecated = entry?.deprecated;
|
|
1428
|
+
if (version === undefined) {
|
|
1429
|
+
report.blocked = true;
|
|
1430
|
+
report.warnings.push(`no version of ${spec.name} matches ${spec.request}`);
|
|
1431
|
+
return report;
|
|
1432
|
+
}
|
|
1433
|
+
const age = ageDays(report.published, now);
|
|
1434
|
+
if (age === undefined) {
|
|
1435
|
+
report.warnings.push(`${registry} gives no publish date for ${version}, its age cannot be checked`);
|
|
1436
|
+
} else if (age < minAgeDays) {
|
|
1437
|
+
report.blocked = true;
|
|
1438
|
+
report.warnings.push(`${version} was published ${age < 1 ? "less than a day" : `${Math.floor(age)} day${Math.floor(age) === 1 ? "" : "s"}`} ago, under ${minAgeDays} days${report.safe === undefined ? ", and no older stable version exists" : `, use ${spec.name}@${report.safe.version}`}`);
|
|
1439
|
+
}
|
|
1440
|
+
const scripts = Object.keys(report.installScripts);
|
|
1441
|
+
if (scripts.length > 0)
|
|
1442
|
+
report.warnings.push(`${version} runs ${scripts.join(", ")} at install`);
|
|
1443
|
+
if (report.deprecated !== undefined)
|
|
1444
|
+
report.warnings.push(`${version} is deprecated: ${report.deprecated}`);
|
|
1445
|
+
return report;
|
|
1446
|
+
}
|
|
1447
|
+
var DEFAULT_MIN_AGE_DAYS = 14, DAY = 86400000, INSTALL_SCRIPTS, GIT_PREFIX, VERSION_SEPARATOR;
|
|
1448
|
+
var init_analyze = __esm(() => {
|
|
1449
|
+
init_nearmiss();
|
|
1450
|
+
INSTALL_SCRIPTS = ["preinstall", "install", "postinstall"];
|
|
1451
|
+
GIT_PREFIX = /^git\+/;
|
|
1452
|
+
VERSION_SEPARATOR = /(?<=.)@/;
|
|
1453
|
+
});
|
|
1454
|
+
|
|
1455
|
+
// src/registry.ts
|
|
1456
|
+
function isPublic(registry) {
|
|
1457
|
+
return registry.url.replace(TRAILING_SLASHES, "") === PUBLIC_REGISTRY;
|
|
1458
|
+
}
|
|
1459
|
+
async function get(fetcher, url, token) {
|
|
1460
|
+
try {
|
|
1461
|
+
return await fetcher(url, { headers: { accept: "application/json", ...token === undefined ? {} : { authorization: `Bearer ${token}` } } });
|
|
1462
|
+
} catch (error) {
|
|
1463
|
+
return fail(`cannot reach ${new URL(url).host}: ${error instanceof Error ? error.message : String(error)}`, 1);
|
|
1464
|
+
}
|
|
1465
|
+
}
|
|
1466
|
+
async function fetchPackument(name, registry, fetcher = fetch) {
|
|
1467
|
+
const response = await get(fetcher, `${registry.url.replace(TRAILING_SLASHES, "")}/${name.replace("/", "%2f")}`, registry.token);
|
|
1468
|
+
if (response.status === 404)
|
|
1469
|
+
return;
|
|
1470
|
+
if (!response.ok)
|
|
1471
|
+
fail(`${new URL(registry.url).host} answered ${response.status} for ${name}`, 1);
|
|
1472
|
+
return await response.json();
|
|
1473
|
+
}
|
|
1474
|
+
async function fetchDownloads(name, fetcher = fetch) {
|
|
1475
|
+
const response = await get(fetcher, `${DOWNLOADS_API}/${name}`);
|
|
1476
|
+
if (!response.ok)
|
|
1477
|
+
return;
|
|
1478
|
+
const body = await response.json();
|
|
1479
|
+
return body.downloads;
|
|
1480
|
+
}
|
|
1481
|
+
var PUBLIC_REGISTRY = "https://registry.npmjs.org", DOWNLOADS_API = "https://api.npmjs.org/downloads/point/last-week", TRAILING_SLASHES;
|
|
1482
|
+
var init_registry = __esm(() => {
|
|
1483
|
+
init_src();
|
|
1484
|
+
TRAILING_SLASHES = /\/+$/;
|
|
1485
|
+
});
|
|
1486
|
+
|
|
1487
|
+
// src/config.ts
|
|
1488
|
+
import { homedir } from "os";
|
|
1489
|
+
import { dirname, join } from "path";
|
|
1490
|
+
import process7 from "process";
|
|
1491
|
+
function expand(value, env) {
|
|
1492
|
+
let missing = false;
|
|
1493
|
+
const expanded = value.replace(ENV_REFERENCE, (_, braced, bare) => {
|
|
1494
|
+
const found = env[braced ?? bare ?? ""];
|
|
1495
|
+
missing ||= found === undefined;
|
|
1496
|
+
return found ?? "";
|
|
1497
|
+
});
|
|
1498
|
+
return missing ? undefined : expanded;
|
|
1499
|
+
}
|
|
1500
|
+
function parseNpmrc(text, env) {
|
|
1501
|
+
const config = { scopes: {}, tokens: {}, scopeTokens: {} };
|
|
1502
|
+
for (const line of text.split(`
|
|
1503
|
+
`)) {
|
|
1504
|
+
const at = line.indexOf("=");
|
|
1505
|
+
if (at === -1 || COMMENT.test(line))
|
|
1506
|
+
continue;
|
|
1507
|
+
const key = line.slice(0, at).trim();
|
|
1508
|
+
const value = expand(line.slice(at + 1).trim().replace(QUOTES, "$2"), env);
|
|
1509
|
+
if (value === undefined || value === "")
|
|
1510
|
+
continue;
|
|
1511
|
+
const scope = SCOPE_REGISTRY.exec(key)?.[1];
|
|
1512
|
+
const tokenFor = AUTH_TOKEN.exec(key)?.[1];
|
|
1513
|
+
if (scope !== undefined)
|
|
1514
|
+
config.scopes[scope] = value;
|
|
1515
|
+
else if (tokenFor !== undefined)
|
|
1516
|
+
config.tokens[tokenFor] = value;
|
|
1517
|
+
else if (key === "registry")
|
|
1518
|
+
config.registry = value;
|
|
1519
|
+
}
|
|
1520
|
+
return config;
|
|
1521
|
+
}
|
|
1522
|
+
function bunEntry(entry, env) {
|
|
1523
|
+
const url = typeof entry === "string" ? entry : entry.url;
|
|
1524
|
+
const token = typeof entry === "string" || entry.token === undefined ? undefined : expand(entry.token, env);
|
|
1525
|
+
return { ...url === undefined ? {} : { url: expand(url, env) ?? url }, ...token === undefined ? {} : { token } };
|
|
1526
|
+
}
|
|
1527
|
+
function parseBunfig(text, env) {
|
|
1528
|
+
const config = { scopes: {}, tokens: {}, scopeTokens: {} };
|
|
1529
|
+
const install = Bun.TOML.parse(text).install;
|
|
1530
|
+
if (install?.registry !== undefined) {
|
|
1531
|
+
const { url, token } = bunEntry(install.registry, env);
|
|
1532
|
+
if (url !== undefined)
|
|
1533
|
+
config.registry = url;
|
|
1534
|
+
if (url !== undefined && token !== undefined)
|
|
1535
|
+
config.tokens[url.replace(PROTOCOL, "")] = token;
|
|
1536
|
+
}
|
|
1537
|
+
for (const [scope, entry] of Object.entries(install?.scopes ?? {})) {
|
|
1538
|
+
const { url, token } = bunEntry(entry, env);
|
|
1539
|
+
if (url !== undefined)
|
|
1540
|
+
config.scopes[scope.startsWith("@") ? scope : `@${scope}`] = url;
|
|
1541
|
+
if (token !== undefined)
|
|
1542
|
+
config.scopeTokens[scope.startsWith("@") ? scope : `@${scope}`] = token;
|
|
1543
|
+
}
|
|
1544
|
+
return config;
|
|
1545
|
+
}
|
|
1546
|
+
function tokenFor(config, url) {
|
|
1547
|
+
const address = url.replace(PROTOCOL, "");
|
|
1548
|
+
const best = Object.keys(config.tokens).filter((key) => address.startsWith(key)).sort((a, b) => b.length - a.length)[0];
|
|
1549
|
+
return best === undefined ? undefined : config.tokens[best];
|
|
1550
|
+
}
|
|
1551
|
+
function registryFor(name, configs) {
|
|
1552
|
+
const scope = name.startsWith("@") ? name.slice(0, name.indexOf("/")) : undefined;
|
|
1553
|
+
for (const config of configs) {
|
|
1554
|
+
const url = scope === undefined ? config.registry : config.scopes[scope] ?? config.registry;
|
|
1555
|
+
if (url === undefined)
|
|
1556
|
+
continue;
|
|
1557
|
+
const token = (scope === undefined ? undefined : config.scopeTokens[scope]) ?? tokenFor(config, url) ?? configs.map((other) => tokenFor(other, url)).find((found) => found !== undefined);
|
|
1558
|
+
return { url, token };
|
|
1559
|
+
}
|
|
1560
|
+
return { url: PUBLIC_REGISTRY };
|
|
1561
|
+
}
|
|
1562
|
+
async function readIfThere(path) {
|
|
1563
|
+
const file = Bun.file(path);
|
|
1564
|
+
return await file.exists() ? file.text() : undefined;
|
|
1565
|
+
}
|
|
1566
|
+
async function loadConfigs(cwd = process7.cwd(), env = process7.env, home = homedir()) {
|
|
1567
|
+
const directories = [];
|
|
1568
|
+
for (let dir = cwd;!directories.includes(dir); dir = dirname(dir))
|
|
1569
|
+
directories.push(dir);
|
|
1570
|
+
if (!directories.includes(home))
|
|
1571
|
+
directories.push(home);
|
|
1572
|
+
const configs = [];
|
|
1573
|
+
for (const dir of directories) {
|
|
1574
|
+
const bunfig = await readIfThere(join(dir, "bunfig.toml"));
|
|
1575
|
+
const npmrc = await readIfThere(join(dir, ".npmrc"));
|
|
1576
|
+
if (bunfig !== undefined)
|
|
1577
|
+
configs.push(parseBunfig(bunfig, env));
|
|
1578
|
+
if (npmrc !== undefined)
|
|
1579
|
+
configs.push(parseNpmrc(npmrc, env));
|
|
1580
|
+
}
|
|
1581
|
+
return configs;
|
|
1582
|
+
}
|
|
1583
|
+
var ENV_REFERENCE, COMMENT, SCOPE_REGISTRY, AUTH_TOKEN, PROTOCOL, QUOTES;
|
|
1584
|
+
var init_config2 = __esm(() => {
|
|
1585
|
+
init_registry();
|
|
1586
|
+
ENV_REFERENCE = /\$\{(\w+)\}|\$(\w+)/g;
|
|
1587
|
+
COMMENT = /^\s*[#;]/;
|
|
1588
|
+
SCOPE_REGISTRY = /^(@[^:]+):registry$/;
|
|
1589
|
+
AUTH_TOKEN = /^(\/\/.+?):_authToken$/;
|
|
1590
|
+
PROTOCOL = /^\w+:/;
|
|
1591
|
+
QUOTES = /^(["'])(.*)\1$/;
|
|
1592
|
+
});
|
|
1593
|
+
|
|
1594
|
+
// src/commands/check.ts
|
|
1595
|
+
var exports_check = {};
|
|
1596
|
+
__export(exports_check, {
|
|
1597
|
+
check: () => check
|
|
1598
|
+
});
|
|
1599
|
+
async function checkPackage(text, context) {
|
|
1600
|
+
const spec = parseSpec(text);
|
|
1601
|
+
const registry = registryFor(spec.name, context.configs);
|
|
1602
|
+
const packument = await fetchPackument(spec.name, registry, context.fetcher);
|
|
1603
|
+
const downloads = packument !== undefined && isPublic(registry) ? await fetchDownloads(spec.name, context.fetcher) : undefined;
|
|
1604
|
+
return analyze({ spec, packument, downloads, registry: new URL(registry.url).host, now: context.now, minAgeDays: context.minAgeDays });
|
|
1605
|
+
}
|
|
1606
|
+
function when(release, now) {
|
|
1607
|
+
return release?.published === undefined ? "" : `, published ${formatAge(release.published, now)} (${release.published.slice(0, 10)})`;
|
|
1608
|
+
}
|
|
1609
|
+
function render(report, now = Date.now()) {
|
|
1610
|
+
if (!report.exists)
|
|
1611
|
+
return [report.name, ...report.warnings.map((warning) => ` warning: ${warning}`)].join(`
|
|
1612
|
+
`);
|
|
1613
|
+
const asked = report.requested === undefined ? "" : ` (asked for ${report.requested})`;
|
|
1614
|
+
const rows = [
|
|
1615
|
+
["version", report.version === undefined ? `none${asked}` : `${report.version}${asked}${when(report, now)}`],
|
|
1616
|
+
["latest", report.latest === undefined ? "-" : `${report.latest.version}${when(report.latest, now)}`],
|
|
1617
|
+
["safe", report.safe === undefined ? "-" : `${report.safe.version}${when(report.safe, now)}`],
|
|
1618
|
+
["downloads", report.downloads === undefined ? "-" : `${report.downloads.toLocaleString("en-US")} last week`],
|
|
1619
|
+
["license", report.license ?? "-"],
|
|
1620
|
+
["repository", report.repository ?? "-"],
|
|
1621
|
+
...Object.entries(report.installScripts).map(([name, command]) => [name, command])
|
|
1622
|
+
];
|
|
1623
|
+
return [
|
|
1624
|
+
`${report.name}${report.description === undefined ? "" : `: ${report.description}`}`,
|
|
1625
|
+
table(rows.map(([key, value]) => [` ${key}`, value ?? ""])),
|
|
1626
|
+
...report.warnings.map((warning) => ` warning: ${warning}`)
|
|
1627
|
+
].join(`
|
|
1628
|
+
`);
|
|
1629
|
+
}
|
|
1630
|
+
async function check(args) {
|
|
1631
|
+
const parsed = parse(args, usage, options);
|
|
1632
|
+
const { values, positionals } = parsed;
|
|
1633
|
+
if (positionals.length === 0)
|
|
1634
|
+
fail(`a package name is needed
|
|
1635
|
+
|
|
1636
|
+
${usage}`);
|
|
1637
|
+
const context = { configs: await loadConfigs(), minAgeDays: wholeNumber(values["min-age"], "min-age", DEFAULT_MIN_AGE_DAYS, 0) };
|
|
1638
|
+
const reports = await Promise.all(positionals.map(async (text) => checkPackage(text, context)));
|
|
1639
|
+
if (values.json === true)
|
|
1640
|
+
printJson(reports.length === 1 ? reports[0] : reports);
|
|
1641
|
+
else
|
|
1642
|
+
console.log(reports.map((report) => render(report)).join(`
|
|
1643
|
+
|
|
1644
|
+
`));
|
|
1645
|
+
return reports.some((report) => report.blocked) ? 1 : 0;
|
|
1646
|
+
}
|
|
1647
|
+
var usage = `pkg [check] <name>[@version]...
|
|
1648
|
+
|
|
1649
|
+
Checks npm packages before they are added: whether the name exists, the latest and the newest version at least two weeks old, weekly downloads, licence, repository, install scripts and a near miss of a popular name.
|
|
1650
|
+
Exits 1 when a package is missing or the version asked for is under the minimum age.`, options;
|
|
1651
|
+
var init_check = __esm(() => {
|
|
1652
|
+
init_src();
|
|
1653
|
+
init_analyze();
|
|
1654
|
+
init_config2();
|
|
1655
|
+
init_registry();
|
|
1656
|
+
options = {
|
|
1657
|
+
json: jsonOption(),
|
|
1658
|
+
"min-age": { type: "string", description: `days a version must be old (${DEFAULT_MIN_AGE_DAYS})` }
|
|
1659
|
+
};
|
|
1660
|
+
});
|
|
1661
|
+
|
|
1662
|
+
// ../kit/src/progress.ts
|
|
1663
|
+
import process8 from "process";
|
|
1664
|
+
function liveRegion(render, stream = process8.stderr, env = process8.env) {
|
|
1665
|
+
if (!takesControlCodes(stream, env))
|
|
1666
|
+
return { redraw: () => {
|
|
1667
|
+
return;
|
|
1668
|
+
}, print: (text) => void stream.write(`${text}
|
|
1669
|
+
`), stop: () => {
|
|
1670
|
+
return;
|
|
1671
|
+
} };
|
|
1672
|
+
const write = stream.write.bind(stream);
|
|
1673
|
+
let frame = 0;
|
|
1674
|
+
let drawn = 0;
|
|
1675
|
+
const clear = () => {
|
|
1676
|
+
if (drawn > 0)
|
|
1677
|
+
write(`${CLEAR_LINE}${LINE_UP.repeat(drawn - 1)}`);
|
|
1678
|
+
drawn = 0;
|
|
1679
|
+
};
|
|
1680
|
+
const draw = () => {
|
|
1681
|
+
const width = (stream.columns === undefined || stream.columns === 0 ? 80 : stream.columns) - 1;
|
|
1682
|
+
const height = stream.rows === undefined || stream.rows === 0 ? 24 : stream.rows;
|
|
1683
|
+
const lines = render(FRAMES[frame++ % FRAMES.length]).slice(0, Math.max(1, height - 1)).map((line) => cutToWidth(line, width));
|
|
1684
|
+
if (lines.length === 0) {
|
|
1685
|
+
clear();
|
|
1686
|
+
return;
|
|
1687
|
+
}
|
|
1688
|
+
write(`${drawn > 0 ? `${CLEAR_LINE}${LINE_UP.repeat(drawn - 1)}` : CLEAR_LINE}${lines.join(`
|
|
1689
|
+
`)}`);
|
|
1690
|
+
drawn = lines.length;
|
|
1691
|
+
};
|
|
1692
|
+
const timer = setInterval(draw, FRAME_MS);
|
|
1693
|
+
const restore = interceptOutput(clear);
|
|
1694
|
+
const onExit = () => clear();
|
|
1695
|
+
const signals = holdSignals(stop);
|
|
1696
|
+
function stop() {
|
|
1697
|
+
clearInterval(timer);
|
|
1698
|
+
clear();
|
|
1699
|
+
restore();
|
|
1700
|
+
process8.off("exit", onExit);
|
|
1701
|
+
signals.release();
|
|
1702
|
+
}
|
|
1703
|
+
timer.unref();
|
|
1704
|
+
process8.on("exit", onExit);
|
|
1705
|
+
return {
|
|
1706
|
+
redraw: draw,
|
|
1707
|
+
print: (text) => {
|
|
1708
|
+
clear();
|
|
1709
|
+
write(`${text}
|
|
1710
|
+
`);
|
|
1711
|
+
draw();
|
|
1712
|
+
},
|
|
1713
|
+
stop
|
|
1714
|
+
};
|
|
1715
|
+
}
|
|
1716
|
+
function cutToWidth(line, width) {
|
|
1717
|
+
if (Bun.stringWidth(line) <= width)
|
|
1718
|
+
return line;
|
|
1719
|
+
let room = width;
|
|
1720
|
+
let kept = "";
|
|
1721
|
+
let index = 0;
|
|
1722
|
+
let linked = false;
|
|
1723
|
+
while (index < line.length) {
|
|
1724
|
+
ESCAPE_CODE.lastIndex = index;
|
|
1725
|
+
const escape = ESCAPE_CODE.exec(line);
|
|
1726
|
+
if (escape !== null) {
|
|
1727
|
+
kept += escape[0];
|
|
1728
|
+
linked ||= escape[0].startsWith(`${ESC}]`);
|
|
1729
|
+
index = ESCAPE_CODE.lastIndex;
|
|
1730
|
+
continue;
|
|
1731
|
+
}
|
|
1732
|
+
const char = String.fromCodePoint(line.codePointAt(index));
|
|
1733
|
+
const columns = Bun.stringWidth(char);
|
|
1734
|
+
if (columns > room)
|
|
1735
|
+
break;
|
|
1736
|
+
kept += char;
|
|
1737
|
+
room -= columns;
|
|
1738
|
+
index += char.length;
|
|
1739
|
+
}
|
|
1740
|
+
return `${kept}${RESET_STYLE}${linked ? CLOSE_LINK : ""}`;
|
|
1741
|
+
}
|
|
1742
|
+
function interceptOutput(clear) {
|
|
1743
|
+
const targets = [...CONSOLE_METHODS.map((name) => [console, name]), [process8.stdout, "write"], [process8.stderr, "write"]];
|
|
1744
|
+
const wrapped = targets.map(([target, name]) => {
|
|
1745
|
+
const original = Reflect.get(target, name);
|
|
1746
|
+
const wrapper = (...args) => {
|
|
1747
|
+
clear();
|
|
1748
|
+
return original.apply(target, args);
|
|
1749
|
+
};
|
|
1750
|
+
Reflect.set(target, name, wrapper);
|
|
1751
|
+
return { target, name, original, wrapper };
|
|
1752
|
+
});
|
|
1753
|
+
return () => {
|
|
1754
|
+
for (const { target, name, original, wrapper } of wrapped) {
|
|
1755
|
+
if (Reflect.get(target, name) === wrapper)
|
|
1756
|
+
Reflect.set(target, name, original);
|
|
1757
|
+
}
|
|
1758
|
+
};
|
|
1759
|
+
}
|
|
1760
|
+
var FRAMES, FRAME_MS = 80, CLEAR_LINE = "\r\x1B[2K", LINE_UP = "\x1B[1A\x1B[2K", ESC, ESCAPE_CODE, RESET_STYLE, CLOSE_LINK, CONSOLE_METHODS;
|
|
1761
|
+
var init_progress = __esm(() => {
|
|
1762
|
+
init_format();
|
|
1763
|
+
init_process();
|
|
1764
|
+
init_style();
|
|
1765
|
+
FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
|
|
1766
|
+
ESC = String.fromCharCode(27);
|
|
1767
|
+
ESCAPE_CODE = new RegExp(`${ESC}(?:\\[[\\x30-\\x3F]*[\\x20-\\x2F]*[\\x40-\\x7E]|\\][^\\u0007${ESC}]*(?:\\u0007|${ESC}\\\\))`, "y");
|
|
1768
|
+
RESET_STYLE = `${ESC}[0m`;
|
|
1769
|
+
CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
|
|
1770
|
+
CONSOLE_METHODS = ["log", "info", "warn", "error", "debug", "dir", "dirxml", "table", "trace", "group", "groupCollapsed", "count", "timeEnd", "timeLog", "assert"];
|
|
1771
|
+
});
|
|
1772
|
+
|
|
1773
|
+
// ../kit/src/shell.ts
|
|
1774
|
+
var SEPARATORS2, PLAIN_BREAKERS, DOUBLE_QUOTED_ESCAPES, WRAPPERS;
|
|
1775
|
+
var init_shell = __esm(() => {
|
|
1776
|
+
SEPARATORS2 = new Set([`
|
|
1777
|
+
`, ";", "|"]);
|
|
1778
|
+
PLAIN_BREAKERS = new Set(["<", ">", "(", ")", "&", "|"]);
|
|
1779
|
+
DOUBLE_QUOTED_ESCAPES = new Set(["$", "`", '"', "\\"]);
|
|
1780
|
+
WRAPPERS = new Set(["command", "env", "sudo", "exec", "nohup", "time"]);
|
|
1781
|
+
});
|
|
1782
|
+
|
|
1783
|
+
// src/pin.ts
|
|
1784
|
+
function actions(byAction) {
|
|
1785
|
+
return new Map(Object.entries(byAction).flatMap(([action, names]) => names.map((name) => [name, action])));
|
|
1786
|
+
}
|
|
1787
|
+
var LOCKFILES, ACTIONS, OPTION_FLAGS, DIR_FLAGS, VALUE_FLAGS;
|
|
1788
|
+
var init_pin = __esm(() => {
|
|
1789
|
+
init_shell();
|
|
1790
|
+
LOCKFILES = [
|
|
1791
|
+
["bun.lock", "bun"],
|
|
1792
|
+
["bun.lockb", "bun"],
|
|
1793
|
+
["pnpm-lock.yaml", "pnpm"],
|
|
1794
|
+
["yarn.lock", "yarn"],
|
|
1795
|
+
["package-lock.json", "npm"]
|
|
1796
|
+
];
|
|
1797
|
+
ACTIONS = {
|
|
1798
|
+
bun: actions({ install: ["install", "i"], add: ["add", "a"], remove: ["remove", "rm"], update: ["update"] }),
|
|
1799
|
+
pnpm: actions({ install: ["install", "i"], add: ["add"], remove: ["remove", "rm"], update: ["update", "up"] }),
|
|
1800
|
+
yarn: new Map([...actions({ install: ["", "install"], add: ["add"], remove: ["remove"], update: ["upgrade"] }), ["upgrade-interactive", null], ["import", null]]),
|
|
1801
|
+
npm: actions({
|
|
1802
|
+
install: ["install", "i", "in", "ins", "inst", "insta", "instal", "isnt", "isnta", "isntal", "isntall"],
|
|
1803
|
+
add: ["add"],
|
|
1804
|
+
frozen: ["ci", "clean-install", "ic", "install-clean", "isntall-clean"],
|
|
1805
|
+
remove: ["uninstall", "unlink", "remove", "rm", "r", "un"],
|
|
1806
|
+
update: ["update", "u", "up", "upgrade", "udpate"]
|
|
1807
|
+
})
|
|
1808
|
+
};
|
|
1809
|
+
OPTION_FLAGS = new Map([
|
|
1810
|
+
["-D", "dev"],
|
|
1811
|
+
["--save-dev", "dev"],
|
|
1812
|
+
["--dev", "dev"],
|
|
1813
|
+
["-E", "exact"],
|
|
1814
|
+
["--save-exact", "exact"],
|
|
1815
|
+
["--exact", "exact"]
|
|
1816
|
+
]);
|
|
1817
|
+
DIR_FLAGS = new Set(["--cwd", "-C", "--dir", "--prefix"]);
|
|
1818
|
+
VALUE_FLAGS = new Set([...DIR_FLAGS, "--filter", "-F"]);
|
|
1819
|
+
});
|
|
1820
|
+
|
|
1821
|
+
// src/consumers.ts
|
|
1822
|
+
import { existsSync, readdirSync, readFileSync } from "fs";
|
|
1823
|
+
import { dirname as dirname2, join as join2, relative } from "path";
|
|
1824
|
+
function packageFiles(dir, depth, found) {
|
|
1825
|
+
let entries;
|
|
1826
|
+
try {
|
|
1827
|
+
entries = readdirSync(dir, { withFileTypes: true });
|
|
1828
|
+
} catch {
|
|
1829
|
+
return found;
|
|
1830
|
+
}
|
|
1831
|
+
for (const entry of entries) {
|
|
1832
|
+
if (entry.isFile() && entry.name === "package.json")
|
|
1833
|
+
found.push(join2(dir, entry.name));
|
|
1834
|
+
else if (entry.isDirectory() && depth < MAX_DEPTH && !entry.name.startsWith(".") && !SKIPPED.has(entry.name))
|
|
1835
|
+
packageFiles(join2(dir, entry.name), depth + 1, found);
|
|
1836
|
+
}
|
|
1837
|
+
return found;
|
|
1838
|
+
}
|
|
1839
|
+
function managerFor(dir, root) {
|
|
1840
|
+
for (let at = dir;; at = dirname2(at)) {
|
|
1841
|
+
const lockfile = LOCKFILES.find(([file]) => existsSync(join2(at, file)));
|
|
1842
|
+
if (lockfile !== undefined)
|
|
1843
|
+
return lockfile[1];
|
|
1844
|
+
if (at === root || at === dirname2(at))
|
|
1845
|
+
return "bun";
|
|
1846
|
+
}
|
|
1847
|
+
}
|
|
1848
|
+
function findConsumers(name, root) {
|
|
1849
|
+
const consumers = [];
|
|
1850
|
+
for (const path of packageFiles(root, 0, []).sort()) {
|
|
1851
|
+
let manifest;
|
|
1852
|
+
try {
|
|
1853
|
+
manifest = JSON.parse(readFileSync(path, "utf8"));
|
|
1854
|
+
} catch {
|
|
1855
|
+
continue;
|
|
1856
|
+
}
|
|
1857
|
+
const kind = KINDS.find((each) => typeof manifest[each]?.[name] === "string");
|
|
1858
|
+
const spec = kind === undefined ? undefined : manifest[kind]?.[name];
|
|
1859
|
+
if (kind !== undefined && spec !== undefined)
|
|
1860
|
+
consumers.push({ dir: relative(root, dirname2(path)) || ".", path, kind, spec, manager: managerFor(dirname2(path), root) });
|
|
1861
|
+
}
|
|
1862
|
+
return consumers;
|
|
1863
|
+
}
|
|
1864
|
+
function isLocal(consumer) {
|
|
1865
|
+
return LOCAL_SPEC.test(consumer.spec);
|
|
1866
|
+
}
|
|
1867
|
+
function addCommand(consumer, name, version) {
|
|
1868
|
+
return ["bun", "add", ...KIND_FLAGS[consumer.kind], "--exact", "--no-cache", `${name}@${version}`];
|
|
1869
|
+
}
|
|
1870
|
+
var KINDS, SKIPPED, MAX_DEPTH = 5, LOCAL_SPEC, KIND_FLAGS;
|
|
1871
|
+
var init_consumers = __esm(() => {
|
|
1872
|
+
init_pin();
|
|
1873
|
+
KINDS = ["dependencies", "devDependencies", "optionalDependencies", "peerDependencies"];
|
|
1874
|
+
SKIPPED = new Set(["node_modules", "dist", "build", "vendor", "target", "coverage"]);
|
|
1875
|
+
LOCAL_SPEC = /^(?:workspace|link|file|portal):/;
|
|
1876
|
+
KIND_FLAGS = { dependencies: [], devDependencies: ["--dev"], optionalDependencies: ["--optional"], peerDependencies: ["--peer"] };
|
|
1877
|
+
});
|
|
1878
|
+
|
|
1879
|
+
// src/commands/bump.ts
|
|
1880
|
+
var exports_bump = {};
|
|
1881
|
+
__export(exports_bump, {
|
|
1882
|
+
ROOT_OPTION: () => ROOT_OPTION,
|
|
1883
|
+
bump: () => bump
|
|
1884
|
+
});
|
|
1885
|
+
import { homedir as homedir2 } from "os";
|
|
1886
|
+
import { join as join3 } from "path";
|
|
1887
|
+
async function servedVersion(name, version, settings) {
|
|
1888
|
+
const registry = registryFor(name, settings.configs);
|
|
1889
|
+
const host = new URL(registry.url).host;
|
|
1890
|
+
const started = Date.now();
|
|
1891
|
+
const region = liveRegion((spinner) => [`${spinner} waiting for ${host} to serve ${name}@${version} ${formatDuration(Date.now() - started)}`]);
|
|
1892
|
+
try {
|
|
1893
|
+
for (;; ) {
|
|
1894
|
+
const packument = await fetchPackument(name, registry, settings.fetcher);
|
|
1895
|
+
const latest = packument?.["dist-tags"]?.latest;
|
|
1896
|
+
if (version === undefined && latest !== undefined)
|
|
1897
|
+
return latest;
|
|
1898
|
+
if (version === undefined)
|
|
1899
|
+
fail(`${host} has no ${name}`, 1);
|
|
1900
|
+
if (packument?.versions?.[version] !== undefined)
|
|
1901
|
+
return version;
|
|
1902
|
+
if (Date.now() - started >= settings.timeout)
|
|
1903
|
+
fail(`${host} does not serve ${name}@${version} after ${formatDuration(settings.timeout)}`, 1);
|
|
1904
|
+
region.redraw();
|
|
1905
|
+
await Bun.sleep(settings.poll ?? POLL);
|
|
1906
|
+
}
|
|
1907
|
+
} finally {
|
|
1908
|
+
region.stop();
|
|
1909
|
+
}
|
|
1910
|
+
}
|
|
1911
|
+
async function bumpConsumers(name, version, settings) {
|
|
1912
|
+
const found = findConsumers(name, settings.root);
|
|
1913
|
+
const consumers = found.filter((each) => !isLocal(each));
|
|
1914
|
+
const local = found.length - consumers.length;
|
|
1915
|
+
const run = settings.run ?? (async (argv, cwd) => runCommand(argv, { cwd }));
|
|
1916
|
+
let isClean = true;
|
|
1917
|
+
if (found.length === 0)
|
|
1918
|
+
note(`nothing under ${settings.root} depends on ${name}`);
|
|
1919
|
+
if (local > 0)
|
|
1920
|
+
note(`${local} workspace:, link: or file: dependenc${local === 1 ? "y" : "ies"}`, "left as they are");
|
|
1921
|
+
for (const consumer of consumers) {
|
|
1922
|
+
const argv = addCommand(consumer, name, version);
|
|
1923
|
+
const where = join3(settings.root, consumer.dir);
|
|
1924
|
+
if (consumer.spec === version) {
|
|
1925
|
+
note(consumer.dir, `already on ${version}`);
|
|
1926
|
+
} else if (consumer.manager !== "bun") {
|
|
1927
|
+
warn(consumer.dir, `${consumer.spec}, its lockfile pins ${consumer.manager}: put ${version} in by hand`);
|
|
1928
|
+
} else if (settings.isDryRun === true) {
|
|
1929
|
+
note(consumer.dir, `would run ${argv.join(" ")}`);
|
|
1930
|
+
} else {
|
|
1931
|
+
const ran = await run(argv, where);
|
|
1932
|
+
if (ran.code === 0) {
|
|
1933
|
+
ok(consumer.dir, `${consumer.spec} -> ${version}`);
|
|
1934
|
+
} else {
|
|
1935
|
+
isClean = false;
|
|
1936
|
+
problem(consumer.dir, `${argv.join(" ")} exited ${ran.code}: ${ran.text.trim().split(`
|
|
1937
|
+
`).at(-1) ?? ""}`);
|
|
1938
|
+
}
|
|
1939
|
+
}
|
|
1940
|
+
}
|
|
1941
|
+
return isClean;
|
|
1942
|
+
}
|
|
1943
|
+
async function bump(args) {
|
|
1944
|
+
const { values, positionals: [name, asked] } = parse(args, usage2, options2, { positionals: ["<name>", "[version]"] });
|
|
1945
|
+
const settings = {
|
|
1946
|
+
root: values.root ?? join3(homedir2(), "Workspace"),
|
|
1947
|
+
configs: await loadConfigs(),
|
|
1948
|
+
timeout: duration(values.timeout, "timeout", 10 * 60000),
|
|
1949
|
+
isDryRun: values["dry-run"] === true
|
|
1950
|
+
};
|
|
1951
|
+
const version = await servedVersion(name, asked, settings);
|
|
1952
|
+
return await bumpConsumers(name, version, settings) ? 0 : 1;
|
|
1953
|
+
}
|
|
1954
|
+
var usage2 = `pkg bump <name> [version]
|
|
1955
|
+
|
|
1956
|
+
Waits until the registry serves the version (the latest when none is given), then runs \`bun add --exact --no-cache\` in each folder under --root whose package.json depends on the package, the kind of dependency kept, a line per folder.
|
|
1957
|
+
A workspace:, link: or file: dependency, a folder already on the version and one whose lockfile pins another manager are left as they are, each said so.
|
|
1958
|
+
Exits 1 when an install fails or the version never shows, 2 on a usage error.`, ROOT_OPTION, options2, POLL = 5000;
|
|
1959
|
+
var init_bump = __esm(() => {
|
|
1960
|
+
init_src();
|
|
1961
|
+
init_progress();
|
|
1962
|
+
init_config2();
|
|
1963
|
+
init_consumers();
|
|
1964
|
+
init_registry();
|
|
1965
|
+
ROOT_OPTION = { type: "string", description: "the folder holding the repositories (~/Workspace)" };
|
|
1966
|
+
options2 = {
|
|
1967
|
+
root: ROOT_OPTION,
|
|
1968
|
+
timeout: { type: "string", short: "t", description: "how long to wait for the registry (10m): 30s, 5m, 1h" },
|
|
1969
|
+
"dry-run": { type: "boolean", description: "print what would run, changing nothing" }
|
|
1970
|
+
};
|
|
1971
|
+
});
|
|
1972
|
+
|
|
1973
|
+
// src/commands/consumers.ts
|
|
1974
|
+
var exports_consumers = {};
|
|
1975
|
+
__export(exports_consumers, {
|
|
1976
|
+
consumers: () => consumers
|
|
1977
|
+
});
|
|
1978
|
+
import { homedir as homedir3 } from "os";
|
|
1979
|
+
import { join as join4 } from "path";
|
|
1980
|
+
function consumers(args) {
|
|
1981
|
+
const { values, positionals: [name] } = parse(args, usage3, options3, { positionals: ["<name>"] });
|
|
1982
|
+
const root = values.root ?? join4(homedir3(), "Workspace");
|
|
1983
|
+
const found = findConsumers(name, root);
|
|
1984
|
+
if (values.json === true)
|
|
1985
|
+
printJson(found);
|
|
1986
|
+
else if (found.length === 0)
|
|
1987
|
+
console.log(`nothing under ${root} depends on ${name}`);
|
|
1988
|
+
else
|
|
1989
|
+
console.log(table([["FOLDER", "KIND", "VERSION", "MANAGER"], ...found.map((each) => [each.dir, each.kind, each.spec, each.manager])], { header: true }));
|
|
1990
|
+
return 0;
|
|
1991
|
+
}
|
|
1992
|
+
var usage3 = `pkg consumers <name>
|
|
1993
|
+
|
|
1994
|
+
Lists the folders under --root whose package.json depends on the package: the folder, the kind of dependency, the version it asks for and the manager its lockfile pins.`, options3;
|
|
1995
|
+
var init_consumers2 = __esm(() => {
|
|
1996
|
+
init_src();
|
|
1997
|
+
init_consumers();
|
|
1998
|
+
init_bump();
|
|
1999
|
+
options3 = {
|
|
2000
|
+
root: ROOT_OPTION,
|
|
2001
|
+
json: jsonOption("[{dir, path, kind, spec, manager}]")
|
|
2002
|
+
};
|
|
2003
|
+
});
|
|
2004
|
+
|
|
2005
|
+
// src/cli.ts
|
|
2006
|
+
init_src();
|
|
2007
|
+
import process9 from "process";
|
|
2008
|
+
// package.json
|
|
2009
|
+
var version = "0.3.0";
|
|
2010
|
+
|
|
2011
|
+
// src/cli.ts
|
|
2012
|
+
process9.exitCode = await runCli({
|
|
2013
|
+
name: "pkg",
|
|
2014
|
+
version,
|
|
2015
|
+
about: "checks npm packages before they are added, and moves a lib's consumers onto a new release",
|
|
2016
|
+
defaultCommand: "check",
|
|
2017
|
+
commands: {
|
|
2018
|
+
check: { summary: "check packages before they are added (`pkg <name>` alone runs it)", run: async (args) => (await Promise.resolve().then(() => (init_check(), exports_check))).check(args) },
|
|
2019
|
+
bump: { summary: "wait for a release on the registry, then bun add it in every consumer", run: async (args) => (await Promise.resolve().then(() => (init_bump(), exports_bump))).bump(args) },
|
|
2020
|
+
consumers: { summary: "list the folders depending on a package, with the version each asks for", run: async (args) => (await Promise.resolve().then(() => (init_consumers2(), exports_consumers))).consumers(args) }
|
|
2021
|
+
}
|
|
2022
|
+
});
|