@kaynooo/cli-workspace 0.9.0 → 0.10.1
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/README.md +2 -0
- package/dist/audit-cli.js +118 -290
- package/dist/cli.js +176 -329
- package/dist/repos-cli.js +120 -292
- package/dist/sweep-cli.js +162 -315
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -30,6 +30,8 @@ Without `--fetch` the ahead and behind counts are those of the last fetch. The w
|
|
|
30
30
|
{ "skip": ["archived-thing", "vendored-clone"] }
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
+
`concurrency` (a positive whole number, 8 by default) in the same file sets how many repositories are read at once. `audit` reads the same key from `~/.config/kaynooo-cli/audit.json` (4 by default, the repositories audited at once).
|
|
34
|
+
|
|
33
35
|
## sweep
|
|
34
36
|
|
|
35
37
|
`sweep` reclaims disk across many repos: it lists the regenerable folders and clean git worktrees under a root, largest first, and deletes them only on `--apply`.
|
package/dist/audit-cli.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#!/usr/bin/env -S bun --no-env-file
|
|
1
|
+
#!/usr/bin/env -S bun --no-env-file --config=/dev/null
|
|
2
2
|
// @bun
|
|
3
3
|
|
|
4
4
|
// src/audit-cli.ts
|
|
@@ -19,6 +19,24 @@ import { parseArgs } from "util";
|
|
|
19
19
|
// ../kit/src/format.ts
|
|
20
20
|
import process7 from "process";
|
|
21
21
|
|
|
22
|
+
// ../../node_modules/.bun/@kaynooo+utils@3.0.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-rxztfxgv.js
|
|
23
|
+
var N = new Map;
|
|
24
|
+
var Nt = /\s+\S*$/;
|
|
25
|
+
var Y = /\s/;
|
|
26
|
+
function ko(t, e, r = "...") {
|
|
27
|
+
let { suffix: n = "...", includeSuffix: s = false, wordBoundary: o = false } = typeof r === "string" ? { suffix: r } : r;
|
|
28
|
+
if (t.length <= e)
|
|
29
|
+
return t;
|
|
30
|
+
let l = Math.max(0, e), c = t.substring(0, Math.max(0, s ? l - n.length : l));
|
|
31
|
+
if (o && !Y.test(t[c.length] ?? " "))
|
|
32
|
+
c = c.replace(Nt, "") || c;
|
|
33
|
+
if (o)
|
|
34
|
+
c = c.trimEnd();
|
|
35
|
+
return s ? (c + n).slice(0, l) : c + n;
|
|
36
|
+
}
|
|
37
|
+
var be = new Map(["\u20AC", "", "\u201A", "\u0192", "\u201E", "\u2026", "\u2020", "\u2021", "\u02C6", "\u2030", "\u0160", "\u2039", "\u0152", "", "\u017D", "", "", "\u2018", "\u2019", "\u201C", "\u201D", "\u2022", "\u2013", "\u2014", "\u02DC", "\u2122", "\u0161", "\u203A", "\u0153", "", "\u017E", "\u0178"].map((t, e) => [t, 128 + e]).filter(([t]) => t));
|
|
38
|
+
var z = new Map;
|
|
39
|
+
|
|
22
40
|
// ../kit/src/mode.ts
|
|
23
41
|
import process2 from "process";
|
|
24
42
|
var MODES = new Set(["terminal", "ci", "agent", "pipe"]);
|
|
@@ -43,269 +61,63 @@ function isInteractive(streams = process2) {
|
|
|
43
61
|
// ../kit/src/style.ts
|
|
44
62
|
import process6 from "process";
|
|
45
63
|
|
|
46
|
-
// ../../node_modules/.bun/@kaynooo+utils@
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
64
|
+
// ../../node_modules/.bun/@kaynooo+utils@3.0.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-x450vn3m.js
|
|
65
|
+
var G2 = /^[a-f0-9]+$/i;
|
|
66
|
+
function b(r) {
|
|
67
|
+
let e = r.startsWith("#") ? r.slice(1) : r;
|
|
68
|
+
if (!G2.test(e))
|
|
50
69
|
return [0, 0, 0];
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
let
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
if (
|
|
66
|
-
return `#${(r << 24 | t << 16 | n << 8 | Math.round((a ?? 1) * 255)).toString(16).padStart(8, "0").toUpperCase()}`;
|
|
67
|
-
return `#${(r << 16 | t << 8 | n).toString(16).padStart(6, "0").toUpperCase()}`;
|
|
68
|
-
}
|
|
69
|
-
function R(s, r, t) {
|
|
70
|
-
s = (s % 360 + 360) % 360, t /= 100;
|
|
71
|
-
let n = r * Math.min(t, 1 - t) / 100, a = (b) => {
|
|
72
|
-
let o = (b + s / 30) % 12, y = t - n * Math.max(Math.min(o - 3, 9 - o, 1), -1);
|
|
73
|
-
return Math.round(255 * y);
|
|
74
|
-
};
|
|
75
|
-
return [a(0), a(8), a(4)];
|
|
76
|
-
}
|
|
77
|
-
function k(s) {
|
|
78
|
-
let [r, t, n] = s;
|
|
79
|
-
r /= 255, t /= 255, n /= 255;
|
|
80
|
-
let a = Math.max(r, t, n), b = Math.min(r, t, n), o = 0, y = 0, c = (a + b) / 2;
|
|
81
|
-
if (a !== b) {
|
|
82
|
-
let u = a - b;
|
|
83
|
-
if (y = c > 0 && c < 1 ? u / (1 - Math.abs(2 * c - 1)) : 0, a === r)
|
|
84
|
-
o = (t - n) / u + (t < n ? 6 : 0);
|
|
85
|
-
else if (a === t)
|
|
86
|
-
o = (n - r) / u + 2;
|
|
87
|
-
else
|
|
88
|
-
o = (r - t) / u + 4;
|
|
89
|
-
o /= 6;
|
|
90
|
-
}
|
|
91
|
-
return [Math.round(o * 360), Math.round(y * 100), Math.round(c * 100)];
|
|
92
|
-
}
|
|
93
|
-
function H(s, r, t) {
|
|
94
|
-
s = (s % 360 + 360) % 360, r /= 100, t /= 100;
|
|
95
|
-
let n = (a) => {
|
|
96
|
-
let b = (a + s / 60) % 6, o = t - t * r * Math.max(Math.min(b, 4 - b, 1), 0);
|
|
97
|
-
return Math.round(255 * o);
|
|
98
|
-
};
|
|
99
|
-
return [n(5), n(3), n(1)];
|
|
100
|
-
}
|
|
101
|
-
function f(s) {
|
|
102
|
-
let [r, t, n] = s;
|
|
103
|
-
r /= 255, t /= 255, n /= 255;
|
|
104
|
-
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;
|
|
105
|
-
if (o !== 0) {
|
|
106
|
-
if (a === r)
|
|
107
|
-
y = (t - n) / o + (t < n ? 6 : 0);
|
|
108
|
-
else if (a === t)
|
|
109
|
-
y = (n - r) / o + 2;
|
|
110
|
-
else
|
|
111
|
-
y = (r - t) / o + 4;
|
|
112
|
-
y /= 6;
|
|
113
|
-
}
|
|
114
|
-
return [Math.round(y * 360), Math.round(c * 100), Math.round(u * 100)];
|
|
115
|
-
}
|
|
116
|
-
function O(s) {
|
|
117
|
-
let r = s[0] / 255, t = s[1] / 255, n = s[2] / 255, a = 1 - Math.max(r, t, n);
|
|
118
|
-
if (a === 1)
|
|
119
|
-
return [0, 0, 0, 100];
|
|
120
|
-
let b = (1 - r - a) / (1 - a), o = (1 - t - a) / (1 - a), y = (1 - n - a) / (1 - a);
|
|
121
|
-
return [Math.round(b * 100), Math.round(o * 100), Math.round(y * 100), Math.round(a * 100)];
|
|
122
|
-
}
|
|
123
|
-
function v(s, r, t, n) {
|
|
124
|
-
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))];
|
|
125
|
-
}
|
|
126
|
-
var m = (s) => s <= 0.04045 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;
|
|
127
|
-
var p = (s) => s <= 0.0031308 ? 12.92 * s : 1.055 * s ** 0.4166666666666667 - 0.055;
|
|
128
|
-
var i = (s, r) => Math.round(s * 10 ** r) / 10 ** r;
|
|
129
|
-
function T(s) {
|
|
130
|
-
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);
|
|
131
|
-
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)];
|
|
132
|
-
}
|
|
133
|
-
function M(s, r, t) {
|
|
134
|
-
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)));
|
|
135
|
-
return [u(o), u(y), u(c)];
|
|
136
|
-
}
|
|
137
|
-
function d(s) {
|
|
138
|
-
let [r, t, n] = T(s), a = Math.sqrt(t * t + n * n), b = (Math.atan2(n, t) * 180 / Math.PI + 360) % 360;
|
|
139
|
-
return [i(r, 4), i(a, 4), i(b, 2)];
|
|
140
|
-
}
|
|
141
|
-
function C(s, r, t) {
|
|
142
|
-
let n = t * Math.PI / 180;
|
|
143
|
-
return M(s, r * Math.cos(n), r * Math.sin(n));
|
|
144
|
-
}
|
|
145
|
-
function l(s) {
|
|
146
|
-
let r = s / 255;
|
|
147
|
-
return r <= 0.03928 ? r / 12.92 : ((r + 0.055) / 1.055) ** 2.4;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
class e {
|
|
151
|
-
r;
|
|
152
|
-
g;
|
|
153
|
-
b;
|
|
154
|
-
a;
|
|
155
|
-
constructor(s, r, t, n = 1) {
|
|
156
|
-
this.r = s, this.g = r, this.b = t, this.a = n;
|
|
157
|
-
}
|
|
158
|
-
static from(s, r) {
|
|
159
|
-
if (s === "hex") {
|
|
160
|
-
let [t, n, a, b] = x(r);
|
|
161
|
-
return new e(t, n, a, b);
|
|
162
|
-
}
|
|
163
|
-
if (s === "rgb") {
|
|
164
|
-
if (Array.isArray(r)) {
|
|
165
|
-
let [o, y, c, u] = r;
|
|
166
|
-
return new e(o, y, c, u);
|
|
167
|
-
}
|
|
168
|
-
let { r: t, g: n, b: a, a: b } = r;
|
|
169
|
-
return new e(t, n, a, b);
|
|
170
|
-
}
|
|
171
|
-
if (s === "hsl") {
|
|
172
|
-
let t, n, a, b;
|
|
173
|
-
if (Array.isArray(r))
|
|
174
|
-
[t, n, a, b] = r;
|
|
175
|
-
else
|
|
176
|
-
({ h: t, s: n, l: a, a: b } = r);
|
|
177
|
-
let [o, y, c] = R(t, n, a);
|
|
178
|
-
return new e(o, y, c, b);
|
|
179
|
-
}
|
|
180
|
-
if (s === "hsv") {
|
|
181
|
-
let t, n, a, b;
|
|
182
|
-
if (Array.isArray(r))
|
|
183
|
-
[t, n, a, b] = r;
|
|
184
|
-
else
|
|
185
|
-
({ h: t, s: n, v: a, a: b } = r);
|
|
186
|
-
let [o, y, c] = H(t, n, a);
|
|
187
|
-
return new e(o, y, c, b);
|
|
188
|
-
}
|
|
189
|
-
if (s === "cmyk") {
|
|
190
|
-
let t, n, a, b, o;
|
|
191
|
-
if (Array.isArray(r))
|
|
192
|
-
[t, n, a, b, o] = r;
|
|
193
|
-
else
|
|
194
|
-
({ c: t, m: n, y: a, k: b, a: o } = r);
|
|
195
|
-
let [y, c, u] = v(t, n, a, b);
|
|
196
|
-
return new e(y, c, u, o);
|
|
197
|
-
}
|
|
198
|
-
if (s === "oklch") {
|
|
199
|
-
let t, n, a, b;
|
|
200
|
-
if (Array.isArray(r))
|
|
201
|
-
[t, n, a, b] = r;
|
|
202
|
-
else
|
|
203
|
-
({ l: t, c: n, h: a, a: b } = r);
|
|
204
|
-
let [o, y, c] = C(t, n, a);
|
|
205
|
-
return new e(o, y, c, b);
|
|
206
|
-
}
|
|
207
|
-
if (s === "oklab") {
|
|
208
|
-
let t, n, a, b;
|
|
209
|
-
if (Array.isArray(r))
|
|
210
|
-
[t, n, a, b] = r;
|
|
211
|
-
else
|
|
212
|
-
({ l: t, a: n, b: a, alpha: b } = r);
|
|
213
|
-
let [o, y, c] = M(t, n, a);
|
|
214
|
-
return new e(o, y, c, b);
|
|
215
|
-
}
|
|
216
|
-
throw Error("Invalid input");
|
|
217
|
-
}
|
|
218
|
-
to(s) {
|
|
219
|
-
switch (s) {
|
|
220
|
-
case "rgb":
|
|
221
|
-
return [this.r, this.g, this.b];
|
|
222
|
-
case "rgba":
|
|
223
|
-
return [this.r, this.g, this.b, this.a];
|
|
224
|
-
case "hex":
|
|
225
|
-
return A([this.r, this.g, this.b]);
|
|
226
|
-
case "hexa":
|
|
227
|
-
return A([this.r, this.g, this.b, this.a]);
|
|
228
|
-
case "hsl":
|
|
229
|
-
return k([this.r, this.g, this.b]);
|
|
230
|
-
case "hsla":
|
|
231
|
-
return [...k([this.r, this.g, this.b]), this.a];
|
|
232
|
-
case "hsv":
|
|
233
|
-
return f([this.r, this.g, this.b]);
|
|
234
|
-
case "hsva":
|
|
235
|
-
return [...f([this.r, this.g, this.b]), this.a];
|
|
236
|
-
case "cmyk":
|
|
237
|
-
return O([this.r, this.g, this.b]);
|
|
238
|
-
case "cmyka":
|
|
239
|
-
return [...O([this.r, this.g, this.b]), this.a];
|
|
240
|
-
case "oklch":
|
|
241
|
-
return d([this.r, this.g, this.b]);
|
|
242
|
-
case "oklcha":
|
|
243
|
-
return [...d([this.r, this.g, this.b]), this.a];
|
|
244
|
-
case "oklab":
|
|
245
|
-
return T([this.r, this.g, this.b]);
|
|
246
|
-
case "oklaba":
|
|
247
|
-
return [...T([this.r, this.g, this.b]), this.a];
|
|
248
|
-
default:
|
|
249
|
-
return [this.r, this.g, this.b];
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
getLuminance() {
|
|
253
|
-
let s = l(this.r), r = l(this.g), t = l(this.b);
|
|
254
|
-
return 0.2126 * s + 0.7152 * r + 0.0722 * t;
|
|
255
|
-
}
|
|
256
|
-
contrastRatio(s) {
|
|
257
|
-
let r = this.getLuminance(), t = s.getLuminance(), [n, a] = r >= t ? [r, t] : [t, r];
|
|
258
|
-
return (n + 0.05) / (a + 0.05);
|
|
259
|
-
}
|
|
260
|
-
bestContrastForeground() {
|
|
261
|
-
let s = new e(255, 255, 255, 1), r = new e(0, 0, 0, 1), t = this.contrastRatio(s), n = this.contrastRatio(r);
|
|
262
|
-
return t >= n ? s : r;
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
// ../../node_modules/.bun/@kaynooo+utils@2.31.2+d0769e28dc4dad16/node_modules/@kaynooo/utils/dist/chunk-y1msbssb.js
|
|
267
|
-
var r = 39;
|
|
268
|
-
var o = 49;
|
|
269
|
-
var f2 = "\x1B[";
|
|
270
|
-
var 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") => {
|
|
271
|
-
let [a, l, s] = e.from("hex", i).to("rgb");
|
|
272
|
-
return [`${n === "fg" ? 38 : 48};2;${a};${l};${s}`, n === "fg" ? r : o];
|
|
273
|
-
}, ansi256: (i, n = "fg") => [`${n === "fg" ? 38 : 48};5;${i}`, n === "fg" ? r : o] };
|
|
274
|
-
var b = new Set(["", "1", "2", "3", "true"]);
|
|
275
|
-
function h(i, n = globalThis.process?.env ?? {}) {
|
|
276
|
-
if (n.FORCE_COLOR !== undefined)
|
|
277
|
-
return b.has(n.FORCE_COLOR);
|
|
278
|
-
if (n.NO_COLOR !== undefined || n.NODE_DISABLE_COLORS !== undefined || n.TERM === "dumb")
|
|
70
|
+
if (e.length === 3 || e.length === 4)
|
|
71
|
+
return [Number.parseInt(e[0] + e[0], 16), Number.parseInt(e[1] + e[1], 16), Number.parseInt(e[2] + e[2], 16)];
|
|
72
|
+
if (e.length !== 6 && e.length !== 8)
|
|
73
|
+
throw Error(`Invalid hex color length: ${e.length}`);
|
|
74
|
+
return [Number.parseInt(e.slice(0, 2), 16), Number.parseInt(e.slice(2, 4), 16), Number.parseInt(e.slice(4, 6), 16)];
|
|
75
|
+
}
|
|
76
|
+
var B2 = { 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, 39], red: [31, 39], green: [32, 39], yellow: [33, 39], blue: [34, 39], magenta: [35, 39], cyan: [36, 39], white: [37, 39], gray: [90, 39], grey: [90, 39], blackBright: [90, 39], redBright: [91, 39], greenBright: [92, 39], yellowBright: [93, 39], blueBright: [94, 39], magentaBright: [95, 39], cyanBright: [96, 39], whiteBright: [97, 39], bgBlack: [40, 49], bgRed: [41, 49], bgGreen: [42, 49], bgYellow: [43, 49], bgBlue: [44, 49], bgMagenta: [45, 49], bgCyan: [46, 49], bgWhite: [47, 49], bgBlackBright: [100, 49], bgRedBright: [101, 49], bgGreenBright: [102, 49], bgYellowBright: [103, 49], bgBlueBright: [104, 49], bgMagentaBright: [105, 49], bgCyanBright: [106, 49], bgWhiteBright: [107, 49], rgb: (r, e, l, n = "fg") => [`${n === "fg" ? 38 : 48};2;${r};${e};${l}`, n === "fg" ? 39 : 49], hex: (r, e = "fg") => {
|
|
77
|
+
let [l, n, c] = b(r);
|
|
78
|
+
return [`${e === "fg" ? 38 : 48};2;${l};${n};${c}`, e === "fg" ? 39 : 49];
|
|
79
|
+
}, ansi256: (r, e = "fg") => [`${e === "fg" ? 38 : 48};5;${r}`, e === "fg" ? 39 : 49] };
|
|
80
|
+
var h = new Set(["", "1", "2", "3", "true"]);
|
|
81
|
+
function C(r, e = globalThis.process?.env ?? {}) {
|
|
82
|
+
if (e.FORCE_COLOR !== undefined)
|
|
83
|
+
return h.has(e.FORCE_COLOR);
|
|
84
|
+
if (e.NO_COLOR !== undefined || e.NODE_DISABLE_COLORS !== undefined || e.TERM === "dumb")
|
|
279
85
|
return false;
|
|
280
|
-
return
|
|
281
|
-
}
|
|
282
|
-
function
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
if (
|
|
296
|
-
return
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
86
|
+
return r?.isTTY === true;
|
|
87
|
+
}
|
|
88
|
+
function f(r, e = []) {
|
|
89
|
+
let l = "", n = "";
|
|
90
|
+
for (let t = 0, i = e.length;t < i; t++)
|
|
91
|
+
l += `\x1B[${e[t][0]}m`, n = `\x1B[${e[t][1]}m${n}`;
|
|
92
|
+
let c = (t) => C(r.stream ?? globalThis.process?.stdout, r.env) ? l + t + n : t, g = new Map;
|
|
93
|
+
return new Proxy(c, { get(t, i) {
|
|
94
|
+
let a = B2[i];
|
|
95
|
+
if (Array.isArray(a)) {
|
|
96
|
+
let s = g.get(i);
|
|
97
|
+
if (s === undefined)
|
|
98
|
+
s = f(r, [...e, a]), g.set(i, s);
|
|
99
|
+
return s;
|
|
100
|
+
}
|
|
101
|
+
if (typeof a === "function")
|
|
102
|
+
return (...s) => {
|
|
103
|
+
let y = `${i}:${s.join(",")}`, u = g.get(y);
|
|
104
|
+
if (u === undefined) {
|
|
105
|
+
if (g.size >= 64)
|
|
106
|
+
g.clear();
|
|
107
|
+
u = f(r, [...e, a(...s)]), g.set(y, u);
|
|
108
|
+
}
|
|
109
|
+
return u;
|
|
110
|
+
};
|
|
111
|
+
throw Error(`Unknown style: ${String(i)}`);
|
|
300
112
|
} });
|
|
301
113
|
}
|
|
302
|
-
function
|
|
303
|
-
return
|
|
114
|
+
function Fe(r = {}) {
|
|
115
|
+
return f(r);
|
|
304
116
|
}
|
|
305
|
-
var
|
|
117
|
+
var o = Fe();
|
|
306
118
|
|
|
307
119
|
// ../kit/src/theme.ts
|
|
308
|
-
import { existsSync as existsSync3, readFileSync, statSync } from "fs";
|
|
120
|
+
import { existsSync as existsSync3, readFileSync as readFileSync2, statSync } from "fs";
|
|
309
121
|
import { homedir as homedir2 } from "os";
|
|
310
122
|
import { join as join3, resolve as resolve2 } from "path";
|
|
311
123
|
import process5 from "process";
|
|
@@ -326,7 +138,7 @@ function findUp(names, from = process3.cwd(), stop = () => false) {
|
|
|
326
138
|
}
|
|
327
139
|
|
|
328
140
|
// ../kit/src/user-config.ts
|
|
329
|
-
import { existsSync as existsSync2 } from "fs";
|
|
141
|
+
import { existsSync as existsSync2, readFileSync } from "fs";
|
|
330
142
|
import { homedir } from "os";
|
|
331
143
|
import { join as join2 } from "path";
|
|
332
144
|
import process4 from "process";
|
|
@@ -344,21 +156,38 @@ function userConfigReadPath(bin, legacy = [], where = {}) {
|
|
|
344
156
|
const base = configBase(where);
|
|
345
157
|
return legacy.map((parts) => join2(base, ...parts)).find((path) => existsSync2(path)) ?? current;
|
|
346
158
|
}
|
|
159
|
+
function readUserConfig(bin, where = {}, legacy = []) {
|
|
160
|
+
const path = userConfigReadPath(bin, legacy, where);
|
|
161
|
+
if (!existsSync2(path))
|
|
162
|
+
return {};
|
|
163
|
+
try {
|
|
164
|
+
const parsed = Bun.JSONC.parse(readFileSync(path, "utf8"));
|
|
165
|
+
return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) ? parsed : {};
|
|
166
|
+
} catch {
|
|
167
|
+
return {};
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
function configuredNumber(bin, key, fallback, where = {}, legacy = []) {
|
|
171
|
+
const value = readUserConfig(bin, where, legacy)[key];
|
|
172
|
+
return typeof value === "number" && Number.isInteger(value) && value > 0 ? value : fallback;
|
|
173
|
+
}
|
|
347
174
|
|
|
348
175
|
// ../kit/src/theme.ts
|
|
176
|
+
var ENDS = new Map;
|
|
349
177
|
var DEFAULT = {
|
|
350
|
-
colors: { accent: "cyan", id: "yellow", path: "blue", label: "dim", value: "bold", ok: "green", warn: "yellow", problem: "red", note: "dim", passed: "green", failed: "red", running: "cyan", queued: "yellow", skipped: "dim" },
|
|
351
|
-
glyphs: { ok: "\u2713", warn: "\u25B2", problem: "\u2717", note: "\u203A", passed: "\u2713", failed: "\u2717", running: "\u25CF", queued: "\u25CB", skipped: "-", bar: "\u2501", rule: "\u2500", corner: "\u256D" },
|
|
178
|
+
colors: { accent: "cyan", id: "yellow", path: "blue", label: "dim", value: "bold", ok: "green", warn: "yellow", problem: "red", note: "dim", plan: "magenta", passed: "green", failed: "red", running: "cyan", queued: "yellow", skipped: "dim" },
|
|
179
|
+
glyphs: { ok: "\u2713", warn: "\u25B2", problem: "\u2717", note: "\u203A", plan: "\u25C7", passed: "\u2713", failed: "\u2717", running: "\u25CF", queued: "\u25CB", skipped: "-", bar: "\u2501", rule: "\u2500", corner: "\u256D", open: "\u2022", leaf: "\xB7", guide: "\u2502" },
|
|
352
180
|
accents: ["cyan", "magenta", "green", "blue", "yellow", "redBright"],
|
|
353
|
-
bins: {}
|
|
181
|
+
bins: {},
|
|
182
|
+
gradient: ["#c084fc", "#67e8f9"]
|
|
354
183
|
};
|
|
355
|
-
var BRIGHT = { accent: "cyanBright", id: "yellowBright", path: "blueBright", label: "white", value: "bold whiteBright", ok: "greenBright", warn: "yellowBright", problem: "redBright", note: "white", passed: "greenBright", failed: "redBright", running: "cyanBright", queued: "yellowBright", skipped: "white" };
|
|
356
|
-
var MONO = { accent: "bold", id: "bold", path: "underline", label: "dim", value: "bold", ok: "bold", warn: "bold", problem: "bold", note: "dim", passed: "bold", failed: "bold", running: "bold", queued: "dim", skipped: "dim" };
|
|
357
|
-
var ASCII = { ok: "+", warn: "!", problem: "x", note: ">", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#", rule: "-", corner: "+" };
|
|
184
|
+
var BRIGHT = { accent: "cyanBright", id: "yellowBright", path: "blueBright", label: "white", value: "bold whiteBright", ok: "greenBright", warn: "yellowBright", problem: "redBright", note: "white", plan: "magentaBright", passed: "greenBright", failed: "redBright", running: "cyanBright", queued: "yellowBright", skipped: "white" };
|
|
185
|
+
var MONO = { accent: "bold", id: "bold", path: "underline", label: "dim", value: "bold", ok: "bold", warn: "bold", problem: "bold", note: "dim", plan: "dim", passed: "bold", failed: "bold", running: "bold", queued: "dim", skipped: "dim" };
|
|
186
|
+
var ASCII = { ok: "+", warn: "!", problem: "x", note: ">", plan: "?", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#", rule: "-", corner: "+", open: "*", leaf: "-", guide: "|" };
|
|
358
187
|
var PRESETS = {
|
|
359
188
|
default: {},
|
|
360
|
-
"high-contrast": { colors: BRIGHT, accents: ["cyanBright", "magentaBright", "greenBright", "blueBright", "yellowBright", "redBright"] },
|
|
361
|
-
mono: { colors: MONO, accents: ["bold"] },
|
|
189
|
+
"high-contrast": { colors: BRIGHT, accents: ["cyanBright", "magentaBright", "greenBright", "blueBright", "yellowBright", "redBright"], gradient: ["#d8b4fe", "#a5f3fc"] },
|
|
190
|
+
mono: { colors: MONO, accents: ["bold"], gradient: undefined },
|
|
362
191
|
ascii: { glyphs: ASCII }
|
|
363
192
|
};
|
|
364
193
|
var STYLES = new Set(["bold", "dim", "italic", "underline", "inverse", "strikethrough", "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white", "gray", "grey", "blackBright", "redBright", "greenBright", "yellowBright", "blueBright", "magentaBright", "cyanBright", "whiteBright"]);
|
|
@@ -408,7 +237,7 @@ function readThemeFile(path, warn) {
|
|
|
408
237
|
warn(`${path} is not a regular file under ${MAX_FILE_BYTES / 1024} KiB, theme ignored`);
|
|
409
238
|
return;
|
|
410
239
|
}
|
|
411
|
-
const parsed = JSON.parse(
|
|
240
|
+
const parsed = JSON.parse(readFileSync2(path, "utf8"));
|
|
412
241
|
if (isRecord(parsed))
|
|
413
242
|
return parsed;
|
|
414
243
|
warn(`${path} is not a JSON object, theme ignored`);
|
|
@@ -429,6 +258,8 @@ function applyPreset(theme, name, warn, where) {
|
|
|
429
258
|
Object.assign(theme.glyphs, preset.glyphs);
|
|
430
259
|
if (preset.accents !== undefined)
|
|
431
260
|
theme.accents = [...preset.accents];
|
|
261
|
+
if (Object.hasOwn(preset, "gradient"))
|
|
262
|
+
theme.gradient = preset.gradient;
|
|
432
263
|
return name;
|
|
433
264
|
}
|
|
434
265
|
function applyFile(theme, file, where, warn) {
|
|
@@ -456,6 +287,12 @@ function applyFile(theme, file, where, warn) {
|
|
|
456
287
|
theme.accents = [...file.accents];
|
|
457
288
|
else if (file.accents !== undefined)
|
|
458
289
|
warn(`${where}: accents must be a non-empty list of colours`);
|
|
290
|
+
if (file.gradient === null)
|
|
291
|
+
theme.gradient = undefined;
|
|
292
|
+
else if (Array.isArray(file.gradient) && file.gradient.length === 2 && file.gradient.every((end) => typeof end === "string" && HEX.test(end)))
|
|
293
|
+
theme.gradient = [file.gradient[0], file.gradient[1]];
|
|
294
|
+
else if (file.gradient !== undefined)
|
|
295
|
+
warn(`${where}: gradient must be two \`#rrggbb\` colours, or null for none`);
|
|
459
296
|
if (isRecord(file.bins)) {
|
|
460
297
|
for (const [bin, value] of Object.entries(file.bins)) {
|
|
461
298
|
if (isColorSpec(value))
|
|
@@ -479,7 +316,7 @@ function isPath(chosen) {
|
|
|
479
316
|
return chosen.includes("/") || chosen.endsWith(".json");
|
|
480
317
|
}
|
|
481
318
|
function loadTheme({ env = process5.env, from = process5.cwd(), home = homedir2(), warn = warnOnce } = {}) {
|
|
482
|
-
const theme = { colors: { ...DEFAULT.colors }, glyphs: { ...DEFAULT.glyphs }, accents: [...DEFAULT.accents], bins: Object.create(null) };
|
|
319
|
+
const theme = { colors: { ...DEFAULT.colors }, glyphs: { ...DEFAULT.glyphs }, accents: [...DEFAULT.accents], bins: Object.create(null), gradient: DEFAULT.gradient };
|
|
483
320
|
const sources = [];
|
|
484
321
|
const chosen = env.KIT_THEME ?? "";
|
|
485
322
|
const wanted = chosen === "" ? [userConfigPath("theme", { home, xdg: env.XDG_CONFIG_HOME }), findUp(join3(".kaynooo", "theme.json"), from, endsWalk(home))] : [];
|
|
@@ -517,12 +354,12 @@ function activeTheme() {
|
|
|
517
354
|
}
|
|
518
355
|
|
|
519
356
|
// ../kit/src/style.ts
|
|
520
|
-
var MARK_WORDS = { ok: "ok:", warn: "warning:", problem: "error:", note: "note:" };
|
|
357
|
+
var MARK_WORDS = { ok: "ok:", warn: "warning:", problem: "error:", note: "note:", plan: "would:" };
|
|
521
358
|
function takesControlCodes(stream, env = process6.env) {
|
|
522
359
|
return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb" && outputMode(stream, env) === "terminal";
|
|
523
360
|
}
|
|
524
361
|
function paint(stream, env = process6.env) {
|
|
525
|
-
return
|
|
362
|
+
return Fe({ stream: { isTTY: takesControlCodes(stream, env) }, env });
|
|
526
363
|
}
|
|
527
364
|
function marked(mark, text, stream, detail, env = process6.env) {
|
|
528
365
|
const colors = paint(stream, env);
|
|
@@ -600,7 +437,7 @@ function formatAge(date, now = Date.now()) {
|
|
|
600
437
|
return seconds < 60 ? "just now" : `${upTo(formatSeconds(seconds), " ")} ago`;
|
|
601
438
|
}
|
|
602
439
|
function truncate(text, width) {
|
|
603
|
-
return text
|
|
440
|
+
return ko(text, width, { suffix: "\u2026", includeSuffix: true });
|
|
604
441
|
}
|
|
605
442
|
var LINE_BREAKS = /\s*\n\s*/g;
|
|
606
443
|
var ESCAPE = String.fromCharCode(27);
|
|
@@ -1096,7 +933,7 @@ async function runTool(label, argv, { timeoutMs, cwd, onStart } = {}) {
|
|
|
1096
933
|
return { code: ran.code, ...streams };
|
|
1097
934
|
}
|
|
1098
935
|
// ../kit/src/cli.ts
|
|
1099
|
-
import { readFileSync as
|
|
936
|
+
import { readFileSync as readFileSync3, realpathSync } from "fs";
|
|
1100
937
|
import { dirname as dirname3, join as join5 } from "path";
|
|
1101
938
|
import process13 from "process";
|
|
1102
939
|
|
|
@@ -1397,7 +1234,7 @@ async function printCandidates(found) {
|
|
|
1397
1234
|
function packageVersion(entry = Bun.main) {
|
|
1398
1235
|
for (let dir = dirname3(realpathSync(entry));; dir = dirname3(dir)) {
|
|
1399
1236
|
try {
|
|
1400
|
-
const { version } = JSON.parse(
|
|
1237
|
+
const { version } = JSON.parse(readFileSync3(join5(dir, "package.json"), "utf8"));
|
|
1401
1238
|
if (typeof version === "string")
|
|
1402
1239
|
return version;
|
|
1403
1240
|
} catch {}
|
|
@@ -1536,7 +1373,6 @@ async function watching(value, step, stream = process14.stdout, sleep = Bun.slee
|
|
|
1536
1373
|
return code;
|
|
1537
1374
|
}
|
|
1538
1375
|
// ../kit/src/workspace-root.ts
|
|
1539
|
-
import { existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync as readFileSync3, writeFileSync } from "fs";
|
|
1540
1376
|
import { homedir as homedir4 } from "os";
|
|
1541
1377
|
import { dirname as dirname4, join as join6, resolve as resolve3 } from "path";
|
|
1542
1378
|
import process15 from "process";
|
|
@@ -1546,29 +1382,21 @@ function expandHome(path, home) {
|
|
|
1546
1382
|
return path.startsWith("~/") ? join6(home, path.slice(2)) : path;
|
|
1547
1383
|
}
|
|
1548
1384
|
function configured(env, home) {
|
|
1549
|
-
const
|
|
1550
|
-
|
|
1551
|
-
return;
|
|
1552
|
-
try {
|
|
1553
|
-
const parsed = JSON.parse(readFileSync3(path, "utf8"));
|
|
1554
|
-
const folder = typeof parsed === "object" && parsed !== null ? parsed.workspace : undefined;
|
|
1555
|
-
return typeof folder === "string" && folder !== "" ? folder : undefined;
|
|
1556
|
-
} catch {
|
|
1557
|
-
return;
|
|
1558
|
-
}
|
|
1385
|
+
const folder = readUserConfig("config", { home, xdg: env.XDG_CONFIG_HOME }).workspace;
|
|
1386
|
+
return typeof folder === "string" && folder !== "" ? folder : undefined;
|
|
1559
1387
|
}
|
|
1560
1388
|
function workspaceRoot({ given, env = process15.env, home = homedir4() } = {}) {
|
|
1561
1389
|
const fromEnv = env.KAYNOOO_WORKSPACE === "" ? undefined : env.KAYNOOO_WORKSPACE;
|
|
1562
1390
|
return resolve3(expandHome(given ?? fromEnv ?? configured(env, home) ?? join6(home, "Workspace"), home));
|
|
1563
1391
|
}
|
|
1564
1392
|
// src/audit.ts
|
|
1565
|
-
import { existsSync as
|
|
1393
|
+
import { existsSync as existsSync5, readdirSync, readFileSync as readFileSync5, statSync as statSync2 } from "fs";
|
|
1566
1394
|
import { readdir } from "fs/promises";
|
|
1567
1395
|
import { join as join8, relative, resolve as resolve4 } from "path";
|
|
1568
1396
|
import process17 from "process";
|
|
1569
1397
|
|
|
1570
1398
|
// src/report.ts
|
|
1571
|
-
import { existsSync as
|
|
1399
|
+
import { existsSync as existsSync4, readFileSync as readFileSync4 } from "fs";
|
|
1572
1400
|
import { join as join7 } from "path";
|
|
1573
1401
|
var UPPER_BOUND = /<\s*(\d[\w.+-]*)/;
|
|
1574
1402
|
var DEPENDENCY_KINDS = ["dependencies", "devDependencies", "optionalDependencies", "peerDependencies"];
|
|
@@ -1652,7 +1480,7 @@ function reachedFrom(graph, direct, targets) {
|
|
|
1652
1480
|
}
|
|
1653
1481
|
function readManifest(path) {
|
|
1654
1482
|
try {
|
|
1655
|
-
return
|
|
1483
|
+
return existsSync4(path) ? JSON.parse(readFileSync4(path, "utf8")) : {};
|
|
1656
1484
|
} catch {
|
|
1657
1485
|
return {};
|
|
1658
1486
|
}
|
|
@@ -1705,7 +1533,7 @@ function countAdvisories(findings) {
|
|
|
1705
1533
|
return findings.reduce((sum, found) => sum + found.advisories.length, 0);
|
|
1706
1534
|
}
|
|
1707
1535
|
function holdsLock(dir) {
|
|
1708
|
-
return
|
|
1536
|
+
return existsSync5(join8(dir, "bun.lock")) || existsSync5(join8(dir, "bun.lockb"));
|
|
1709
1537
|
}
|
|
1710
1538
|
async function findRepos(root) {
|
|
1711
1539
|
if (holdsLock(root))
|
|
@@ -1795,13 +1623,13 @@ function rows(findings) {
|
|
|
1795
1623
|
async function audit(args) {
|
|
1796
1624
|
const { values, positionals } = parse(args, USAGE, OPTIONS, { positionals: ["[root]"], exits: EXITS, replaces: "a bun audit run in each repository and a read of every advisory to find what is worth fixing", examples: ["audit", "audit ~/Workspace --level high --prod"] });
|
|
1797
1625
|
const root = resolve4(positionals[0] ?? ".");
|
|
1798
|
-
if (!
|
|
1626
|
+
if (!existsSync5(root) || !statSync2(root).isDirectory())
|
|
1799
1627
|
fail(`no folder ${root}`);
|
|
1800
1628
|
const level = oneOf(values.level, "level", SEVERITIES);
|
|
1801
1629
|
const paths = await findRepos(root);
|
|
1802
1630
|
if (paths.length === 0)
|
|
1803
1631
|
fail(`no bun.lock under ${root}`);
|
|
1804
|
-
const audits = await pool(paths, CONCURRENCY, async (path) => audited(path, relative(root, path) || ".", level, values.ignore ?? []));
|
|
1632
|
+
const audits = await pool(paths, configuredNumber("audit", "concurrency", CONCURRENCY), async (path) => audited(path, relative(root, path) || ".", level, values.ignore ?? []));
|
|
1805
1633
|
const kept = audits.map((each) => ({ ...each, findings: values.prod === true ? each.findings.filter((found) => found.scope === "prod") : each.findings }));
|
|
1806
1634
|
if (values.json === true)
|
|
1807
1635
|
printJson(kept);
|