@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/dist/sweep-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/sweep-cli.ts
|
|
@@ -19,6 +19,38 @@ 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-n6z2kk96.js
|
|
23
|
+
var r = new Map;
|
|
24
|
+
var i = new Map;
|
|
25
|
+
var l = new Map;
|
|
26
|
+
function a(e, t, o) {
|
|
27
|
+
return JSON.stringify([e ?? null, t ?? null, o]);
|
|
28
|
+
}
|
|
29
|
+
function y(e, t) {
|
|
30
|
+
let o = a(e, t), n = i.get(o);
|
|
31
|
+
if (!n)
|
|
32
|
+
n = new Intl.NumberFormat(e, t), i.set(o, n);
|
|
33
|
+
return n;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// ../../node_modules/.bun/@kaynooo+utils@3.0.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-rxztfxgv.js
|
|
37
|
+
var N = new Map;
|
|
38
|
+
var Nt = /\s+\S*$/;
|
|
39
|
+
var Y = /\s/;
|
|
40
|
+
function ko(t, e, r = "...") {
|
|
41
|
+
let { suffix: n = "...", includeSuffix: s = false, wordBoundary: o = false } = typeof r === "string" ? { suffix: r } : r;
|
|
42
|
+
if (t.length <= e)
|
|
43
|
+
return t;
|
|
44
|
+
let l = Math.max(0, e), c = t.substring(0, Math.max(0, s ? l - n.length : l));
|
|
45
|
+
if (o && !Y.test(t[c.length] ?? " "))
|
|
46
|
+
c = c.replace(Nt, "") || c;
|
|
47
|
+
if (o)
|
|
48
|
+
c = c.trimEnd();
|
|
49
|
+
return s ? (c + n).slice(0, l) : c + n;
|
|
50
|
+
}
|
|
51
|
+
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));
|
|
52
|
+
var z = new Map;
|
|
53
|
+
|
|
22
54
|
// ../kit/src/mode.ts
|
|
23
55
|
import process2 from "process";
|
|
24
56
|
var MODES = new Set(["terminal", "ci", "agent", "pipe"]);
|
|
@@ -43,269 +75,63 @@ function isInteractive(streams = process2) {
|
|
|
43
75
|
// ../kit/src/style.ts
|
|
44
76
|
import process6 from "process";
|
|
45
77
|
|
|
46
|
-
// ../../node_modules/.bun/@kaynooo+utils@
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
78
|
+
// ../../node_modules/.bun/@kaynooo+utils@3.0.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-x450vn3m.js
|
|
79
|
+
var G2 = /^[a-f0-9]+$/i;
|
|
80
|
+
function b(r) {
|
|
81
|
+
let e = r.startsWith("#") ? r.slice(1) : r;
|
|
82
|
+
if (!G2.test(e))
|
|
50
83
|
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")
|
|
84
|
+
if (e.length === 3 || e.length === 4)
|
|
85
|
+
return [Number.parseInt(e[0] + e[0], 16), Number.parseInt(e[1] + e[1], 16), Number.parseInt(e[2] + e[2], 16)];
|
|
86
|
+
if (e.length !== 6 && e.length !== 8)
|
|
87
|
+
throw Error(`Invalid hex color length: ${e.length}`);
|
|
88
|
+
return [Number.parseInt(e.slice(0, 2), 16), Number.parseInt(e.slice(2, 4), 16), Number.parseInt(e.slice(4, 6), 16)];
|
|
89
|
+
}
|
|
90
|
+
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") => {
|
|
91
|
+
let [l, n, c] = b(r);
|
|
92
|
+
return [`${e === "fg" ? 38 : 48};2;${l};${n};${c}`, e === "fg" ? 39 : 49];
|
|
93
|
+
}, ansi256: (r, e = "fg") => [`${e === "fg" ? 38 : 48};5;${r}`, e === "fg" ? 39 : 49] };
|
|
94
|
+
var h = new Set(["", "1", "2", "3", "true"]);
|
|
95
|
+
function C(r, e = globalThis.process?.env ?? {}) {
|
|
96
|
+
if (e.FORCE_COLOR !== undefined)
|
|
97
|
+
return h.has(e.FORCE_COLOR);
|
|
98
|
+
if (e.NO_COLOR !== undefined || e.NODE_DISABLE_COLORS !== undefined || e.TERM === "dumb")
|
|
279
99
|
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
|
-
|
|
100
|
+
return r?.isTTY === true;
|
|
101
|
+
}
|
|
102
|
+
function f(r, e = []) {
|
|
103
|
+
let l = "", n = "";
|
|
104
|
+
for (let t = 0, i = e.length;t < i; t++)
|
|
105
|
+
l += `\x1B[${e[t][0]}m`, n = `\x1B[${e[t][1]}m${n}`;
|
|
106
|
+
let c = (t) => C(r.stream ?? globalThis.process?.stdout, r.env) ? l + t + n : t, g = new Map;
|
|
107
|
+
return new Proxy(c, { get(t, i) {
|
|
108
|
+
let a = B2[i];
|
|
109
|
+
if (Array.isArray(a)) {
|
|
110
|
+
let s = g.get(i);
|
|
111
|
+
if (s === undefined)
|
|
112
|
+
s = f(r, [...e, a]), g.set(i, s);
|
|
113
|
+
return s;
|
|
114
|
+
}
|
|
115
|
+
if (typeof a === "function")
|
|
116
|
+
return (...s) => {
|
|
117
|
+
let y = `${i}:${s.join(",")}`, u = g.get(y);
|
|
118
|
+
if (u === undefined) {
|
|
119
|
+
if (g.size >= 64)
|
|
120
|
+
g.clear();
|
|
121
|
+
u = f(r, [...e, a(...s)]), g.set(y, u);
|
|
122
|
+
}
|
|
123
|
+
return u;
|
|
124
|
+
};
|
|
125
|
+
throw Error(`Unknown style: ${String(i)}`);
|
|
300
126
|
} });
|
|
301
127
|
}
|
|
302
|
-
function
|
|
303
|
-
return
|
|
128
|
+
function Fe(r = {}) {
|
|
129
|
+
return f(r);
|
|
304
130
|
}
|
|
305
|
-
var
|
|
131
|
+
var o = Fe();
|
|
306
132
|
|
|
307
133
|
// ../kit/src/theme.ts
|
|
308
|
-
import { existsSync as existsSync3, readFileSync, statSync } from "fs";
|
|
134
|
+
import { existsSync as existsSync3, readFileSync as readFileSync2, statSync } from "fs";
|
|
309
135
|
import { homedir as homedir2 } from "os";
|
|
310
136
|
import { join as join3, resolve as resolve2 } from "path";
|
|
311
137
|
import process5 from "process";
|
|
@@ -326,7 +152,7 @@ function findUp(names, from = process3.cwd(), stop = () => false) {
|
|
|
326
152
|
}
|
|
327
153
|
|
|
328
154
|
// ../kit/src/user-config.ts
|
|
329
|
-
import { existsSync as existsSync2 } from "fs";
|
|
155
|
+
import { existsSync as existsSync2, readFileSync } from "fs";
|
|
330
156
|
import { homedir } from "os";
|
|
331
157
|
import { join as join2 } from "path";
|
|
332
158
|
import process4 from "process";
|
|
@@ -344,21 +170,38 @@ function userConfigReadPath(bin, legacy = [], where = {}) {
|
|
|
344
170
|
const base = configBase(where);
|
|
345
171
|
return legacy.map((parts) => join2(base, ...parts)).find((path) => existsSync2(path)) ?? current;
|
|
346
172
|
}
|
|
173
|
+
function readUserConfig(bin, where = {}, legacy = []) {
|
|
174
|
+
const path = userConfigReadPath(bin, legacy, where);
|
|
175
|
+
if (!existsSync2(path))
|
|
176
|
+
return {};
|
|
177
|
+
try {
|
|
178
|
+
const parsed = Bun.JSONC.parse(readFileSync(path, "utf8"));
|
|
179
|
+
return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) ? parsed : {};
|
|
180
|
+
} catch {
|
|
181
|
+
return {};
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
function configuredNumber(bin, key, fallback, where = {}, legacy = []) {
|
|
185
|
+
const value = readUserConfig(bin, where, legacy)[key];
|
|
186
|
+
return typeof value === "number" && Number.isInteger(value) && value > 0 ? value : fallback;
|
|
187
|
+
}
|
|
347
188
|
|
|
348
189
|
// ../kit/src/theme.ts
|
|
190
|
+
var ENDS = new Map;
|
|
349
191
|
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" },
|
|
192
|
+
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" },
|
|
193
|
+
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
194
|
accents: ["cyan", "magenta", "green", "blue", "yellow", "redBright"],
|
|
353
|
-
bins: {}
|
|
195
|
+
bins: {},
|
|
196
|
+
gradient: ["#c084fc", "#67e8f9"]
|
|
354
197
|
};
|
|
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: "+" };
|
|
198
|
+
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" };
|
|
199
|
+
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" };
|
|
200
|
+
var ASCII = { ok: "+", warn: "!", problem: "x", note: ">", plan: "?", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#", rule: "-", corner: "+", open: "*", leaf: "-", guide: "|" };
|
|
358
201
|
var PRESETS = {
|
|
359
202
|
default: {},
|
|
360
|
-
"high-contrast": { colors: BRIGHT, accents: ["cyanBright", "magentaBright", "greenBright", "blueBright", "yellowBright", "redBright"] },
|
|
361
|
-
mono: { colors: MONO, accents: ["bold"] },
|
|
203
|
+
"high-contrast": { colors: BRIGHT, accents: ["cyanBright", "magentaBright", "greenBright", "blueBright", "yellowBright", "redBright"], gradient: ["#d8b4fe", "#a5f3fc"] },
|
|
204
|
+
mono: { colors: MONO, accents: ["bold"], gradient: undefined },
|
|
362
205
|
ascii: { glyphs: ASCII }
|
|
363
206
|
};
|
|
364
207
|
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 +251,7 @@ function readThemeFile(path, warn) {
|
|
|
408
251
|
warn(`${path} is not a regular file under ${MAX_FILE_BYTES / 1024} KiB, theme ignored`);
|
|
409
252
|
return;
|
|
410
253
|
}
|
|
411
|
-
const parsed = JSON.parse(
|
|
254
|
+
const parsed = JSON.parse(readFileSync2(path, "utf8"));
|
|
412
255
|
if (isRecord(parsed))
|
|
413
256
|
return parsed;
|
|
414
257
|
warn(`${path} is not a JSON object, theme ignored`);
|
|
@@ -429,6 +272,8 @@ function applyPreset(theme, name, warn, where) {
|
|
|
429
272
|
Object.assign(theme.glyphs, preset.glyphs);
|
|
430
273
|
if (preset.accents !== undefined)
|
|
431
274
|
theme.accents = [...preset.accents];
|
|
275
|
+
if (Object.hasOwn(preset, "gradient"))
|
|
276
|
+
theme.gradient = preset.gradient;
|
|
432
277
|
return name;
|
|
433
278
|
}
|
|
434
279
|
function applyFile(theme, file, where, warn) {
|
|
@@ -456,6 +301,12 @@ function applyFile(theme, file, where, warn) {
|
|
|
456
301
|
theme.accents = [...file.accents];
|
|
457
302
|
else if (file.accents !== undefined)
|
|
458
303
|
warn(`${where}: accents must be a non-empty list of colours`);
|
|
304
|
+
if (file.gradient === null)
|
|
305
|
+
theme.gradient = undefined;
|
|
306
|
+
else if (Array.isArray(file.gradient) && file.gradient.length === 2 && file.gradient.every((end) => typeof end === "string" && HEX.test(end)))
|
|
307
|
+
theme.gradient = [file.gradient[0], file.gradient[1]];
|
|
308
|
+
else if (file.gradient !== undefined)
|
|
309
|
+
warn(`${where}: gradient must be two \`#rrggbb\` colours, or null for none`);
|
|
459
310
|
if (isRecord(file.bins)) {
|
|
460
311
|
for (const [bin, value] of Object.entries(file.bins)) {
|
|
461
312
|
if (isColorSpec(value))
|
|
@@ -479,7 +330,7 @@ function isPath(chosen) {
|
|
|
479
330
|
return chosen.includes("/") || chosen.endsWith(".json");
|
|
480
331
|
}
|
|
481
332
|
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) };
|
|
333
|
+
const theme = { colors: { ...DEFAULT.colors }, glyphs: { ...DEFAULT.glyphs }, accents: [...DEFAULT.accents], bins: Object.create(null), gradient: DEFAULT.gradient };
|
|
483
334
|
const sources = [];
|
|
484
335
|
const chosen = env.KIT_THEME ?? "";
|
|
485
336
|
const wanted = chosen === "" ? [userConfigPath("theme", { home, xdg: env.XDG_CONFIG_HOME }), findUp(join3(".kaynooo", "theme.json"), from, endsWalk(home))] : [];
|
|
@@ -517,12 +368,12 @@ function activeTheme() {
|
|
|
517
368
|
}
|
|
518
369
|
|
|
519
370
|
// ../kit/src/style.ts
|
|
520
|
-
var MARK_WORDS = { ok: "ok:", warn: "warning:", problem: "error:", note: "note:" };
|
|
371
|
+
var MARK_WORDS = { ok: "ok:", warn: "warning:", problem: "error:", note: "note:", plan: "would:" };
|
|
521
372
|
function takesControlCodes(stream, env = process6.env) {
|
|
522
373
|
return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb" && outputMode(stream, env) === "terminal";
|
|
523
374
|
}
|
|
524
375
|
function paint(stream, env = process6.env) {
|
|
525
|
-
return
|
|
376
|
+
return Fe({ stream: { isTTY: takesControlCodes(stream, env) }, env });
|
|
526
377
|
}
|
|
527
378
|
function marked(mark, text, stream, detail, env = process6.env) {
|
|
528
379
|
const colors = paint(stream, env);
|
|
@@ -569,16 +420,16 @@ function printHeader(bin, context, stream = process6.stdout, env = process6.env)
|
|
|
569
420
|
if (line !== "")
|
|
570
421
|
console.log(line);
|
|
571
422
|
}
|
|
572
|
-
// ../../node_modules/.bun/@kaynooo+utils@
|
|
573
|
-
function
|
|
574
|
-
let
|
|
575
|
-
if (Math.abs(
|
|
576
|
-
return `${
|
|
577
|
-
let
|
|
423
|
+
// ../../node_modules/.bun/@kaynooo+utils@3.0.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-knqbxp56.js
|
|
424
|
+
function tt(i, { units: r = "iec", dp: t = 1, locale: n } = {}) {
|
|
425
|
+
let e = r === "si" ? 1000 : 1024;
|
|
426
|
+
if (Math.abs(i) < e)
|
|
427
|
+
return `${i} B`;
|
|
428
|
+
let s = r === "iec" ? ["KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"] : ["kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"], o = -1, a = 10 ** t;
|
|
578
429
|
do
|
|
579
|
-
|
|
580
|
-
while (Math.round(Math.abs(
|
|
581
|
-
return `${t.toFixed(
|
|
430
|
+
i /= e, ++o;
|
|
431
|
+
while (Math.round(Math.abs(i) * a) / a >= e && o < s.length - 1);
|
|
432
|
+
return `${n ? y(n, { minimumFractionDigits: t, maximumFractionDigits: t }).format(i) : i.toFixed(t)} ${s[o]}`;
|
|
582
433
|
}
|
|
583
434
|
|
|
584
435
|
// ../kit/src/format.ts
|
|
@@ -611,7 +462,7 @@ function formatAge(date, now = Date.now()) {
|
|
|
611
462
|
return seconds < 60 ? "just now" : `${upTo(formatSeconds(seconds), " ")} ago`;
|
|
612
463
|
}
|
|
613
464
|
function truncate(text, width) {
|
|
614
|
-
return text
|
|
465
|
+
return ko(text, width, { suffix: "\u2026", includeSuffix: true });
|
|
615
466
|
}
|
|
616
467
|
var LINE_BREAKS = /\s*\n\s*/g;
|
|
617
468
|
var ESCAPE = String.fromCharCode(27);
|
|
@@ -1107,7 +958,7 @@ async function runTool(label, argv, { timeoutMs, cwd, onStart } = {}) {
|
|
|
1107
958
|
return { code: ran.code, ...streams };
|
|
1108
959
|
}
|
|
1109
960
|
// ../kit/src/cli.ts
|
|
1110
|
-
import { readFileSync as
|
|
961
|
+
import { readFileSync as readFileSync3, realpathSync } from "fs";
|
|
1111
962
|
import { dirname as dirname3, join as join5 } from "path";
|
|
1112
963
|
import process13 from "process";
|
|
1113
964
|
|
|
@@ -1408,7 +1259,7 @@ async function printCandidates(found) {
|
|
|
1408
1259
|
function packageVersion(entry = Bun.main) {
|
|
1409
1260
|
for (let dir = dirname3(realpathSync(entry));; dir = dirname3(dir)) {
|
|
1410
1261
|
try {
|
|
1411
|
-
const { version } = JSON.parse(
|
|
1262
|
+
const { version } = JSON.parse(readFileSync3(join5(dir, "package.json"), "utf8"));
|
|
1412
1263
|
if (typeof version === "string")
|
|
1413
1264
|
return version;
|
|
1414
1265
|
} catch {}
|
|
@@ -1547,7 +1398,6 @@ async function watching(value, step, stream = process14.stdout, sleep = Bun.slee
|
|
|
1547
1398
|
return code;
|
|
1548
1399
|
}
|
|
1549
1400
|
// ../kit/src/workspace-root.ts
|
|
1550
|
-
import { existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync as readFileSync3, writeFileSync } from "fs";
|
|
1551
1401
|
import { homedir as homedir4 } from "os";
|
|
1552
1402
|
import { dirname as dirname4, join as join6, resolve as resolve3 } from "path";
|
|
1553
1403
|
import process15 from "process";
|
|
@@ -1557,23 +1407,15 @@ function expandHome(path, home) {
|
|
|
1557
1407
|
return path.startsWith("~/") ? join6(home, path.slice(2)) : path;
|
|
1558
1408
|
}
|
|
1559
1409
|
function configured(env, home) {
|
|
1560
|
-
const
|
|
1561
|
-
|
|
1562
|
-
return;
|
|
1563
|
-
try {
|
|
1564
|
-
const parsed = JSON.parse(readFileSync3(path, "utf8"));
|
|
1565
|
-
const folder = typeof parsed === "object" && parsed !== null ? parsed.workspace : undefined;
|
|
1566
|
-
return typeof folder === "string" && folder !== "" ? folder : undefined;
|
|
1567
|
-
} catch {
|
|
1568
|
-
return;
|
|
1569
|
-
}
|
|
1410
|
+
const folder = readUserConfig("config", { home, xdg: env.XDG_CONFIG_HOME }).workspace;
|
|
1411
|
+
return typeof folder === "string" && folder !== "" ? folder : undefined;
|
|
1570
1412
|
}
|
|
1571
1413
|
function workspaceRoot({ given, env = process15.env, home = homedir4() } = {}) {
|
|
1572
1414
|
const fromEnv = env.KAYNOOO_WORKSPACE === "" ? undefined : env.KAYNOOO_WORKSPACE;
|
|
1573
1415
|
return resolve3(expandHome(given ?? fromEnv ?? configured(env, home) ?? join6(home, "Workspace"), home));
|
|
1574
1416
|
}
|
|
1575
1417
|
// src/sweep.ts
|
|
1576
|
-
import { existsSync as
|
|
1418
|
+
import { existsSync as existsSync6, statSync as statSync2 } from "fs";
|
|
1577
1419
|
import { homedir as homedir6 } from "os";
|
|
1578
1420
|
import { relative } from "path";
|
|
1579
1421
|
|
|
@@ -1588,7 +1430,9 @@ var NONE = Number.NEGATIVE_INFINITY;
|
|
|
1588
1430
|
var IS_CONTROL = /[\x00-\x1F\x7F-\x9F]/;
|
|
1589
1431
|
var PASTE_START = "\x1B[200~";
|
|
1590
1432
|
var PASTE_END = "\x1B[201~";
|
|
1591
|
-
var KEY_SEQUENCES = /\x1B\[[0-9;]*[A-Z~]|\x1BO[A-Z]|\x1B[\s\S]|[\s\S]/gu;
|
|
1433
|
+
var KEY_SEQUENCES = /\x1B\[<[0-9;]*[A-Za-z]|\x1B\[[0-9;]*[A-Z~]|\x1BO[A-Z]|\x1B[\s\S]|[\s\S]/gu;
|
|
1434
|
+
var MOUSE = /^\x1B\[<(\d+);\d+;\d+[a-z]$/i;
|
|
1435
|
+
var WHEEL_LINES = 3;
|
|
1592
1436
|
var KEYS = {
|
|
1593
1437
|
"\x1B[A": "up",
|
|
1594
1438
|
"\x1BOA": "up",
|
|
@@ -1617,9 +1461,15 @@ var KEYS = {
|
|
|
1617
1461
|
"\x1BOP": "help",
|
|
1618
1462
|
"\x1B[11~": "help"
|
|
1619
1463
|
};
|
|
1464
|
+
function repeat(value, count) {
|
|
1465
|
+
return Array.from({ length: count }).fill(value);
|
|
1466
|
+
}
|
|
1620
1467
|
function parseKeys(input, paste = { active: false }, ctrls = []) {
|
|
1621
1468
|
const codes = new Map(ctrls.map((name) => [String.fromCharCode(name.codePointAt(name.length - 1) - 96), name]));
|
|
1622
1469
|
return (input.match(KEY_SEQUENCES) ?? []).flatMap((sequence) => {
|
|
1470
|
+
const wheel = MOUSE.exec(sequence)?.[1];
|
|
1471
|
+
if (wheel !== undefined)
|
|
1472
|
+
return repeat(wheel === "64" ? "up" : "down", wheel === "64" || wheel === "65" ? WHEEL_LINES : 0);
|
|
1623
1473
|
const named = codes.get(sequence);
|
|
1624
1474
|
const key = named === undefined ? KEYS[sequence] : { ctrl: named };
|
|
1625
1475
|
if (sequence === PASTE_START || sequence === PASTE_END) {
|
|
@@ -1667,16 +1517,13 @@ async function ask(question, { hint, terminal = process17 }, render, press) {
|
|
|
1667
1517
|
if (!isInteractive(terminal))
|
|
1668
1518
|
fail(`cannot ask "${question}" off a terminal`, 2, hint);
|
|
1669
1519
|
const colors = paint(stderr);
|
|
1670
|
-
let drawn = [];
|
|
1671
1520
|
let current = "asking";
|
|
1672
1521
|
let outcome;
|
|
1673
1522
|
const columns = () => stderr.columns || 80;
|
|
1674
|
-
const draw = (state) => {
|
|
1523
|
+
const draw = (state, last = false) => {
|
|
1675
1524
|
const frame = render(colors, state, { columns: columns(), rows: stderr.rows || 24 });
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
`)}`);
|
|
1679
|
-
drawn = frame;
|
|
1525
|
+
stderr.write(`\r\x1B[0J${frame.join(`
|
|
1526
|
+
`)}${last || frame.length < 2 ? "" : `\x1B[${frame.length - 1}A`}${last ? "" : "\r"}`);
|
|
1680
1527
|
current = state;
|
|
1681
1528
|
};
|
|
1682
1529
|
const redraw = () => draw(current);
|
|
@@ -1712,7 +1559,7 @@ async function ask(question, { hint, terminal = process17 }, render, press) {
|
|
|
1712
1559
|
});
|
|
1713
1560
|
} finally {
|
|
1714
1561
|
stderr.off?.("resize", redraw);
|
|
1715
|
-
draw(outcome ?? "cancel");
|
|
1562
|
+
draw(outcome ?? "cancel", true);
|
|
1716
1563
|
stderr.write(`
|
|
1717
1564
|
\x1B[?25h\x1B[?2004l`);
|
|
1718
1565
|
stdin.setRawMode(false);
|
|
@@ -1721,12 +1568,12 @@ async function ask(question, { hint, terminal = process17 }, render, press) {
|
|
|
1721
1568
|
}
|
|
1722
1569
|
|
|
1723
1570
|
// src/apply.ts
|
|
1724
|
-
import { existsSync as
|
|
1571
|
+
import { existsSync as existsSync5 } from "fs";
|
|
1725
1572
|
import { lstat as lstat3, rm } from "fs/promises";
|
|
1726
1573
|
import { basename as basename2, join as join9 } from "path";
|
|
1727
1574
|
|
|
1728
1575
|
// src/sweep-scan.ts
|
|
1729
|
-
import { existsSync as
|
|
1576
|
+
import { existsSync as existsSync4 } from "fs";
|
|
1730
1577
|
import { lstat as lstat2, readdir as readdir2, realpath } from "fs/promises";
|
|
1731
1578
|
import { homedir as homedir5 } from "os";
|
|
1732
1579
|
import { basename, dirname as dirname5, join as join8 } from "path";
|
|
@@ -1852,7 +1699,7 @@ async function findCandidates(root, home = homedir5(), withGlobal = true) {
|
|
|
1852
1699
|
}
|
|
1853
1700
|
continue;
|
|
1854
1701
|
}
|
|
1855
|
-
if (FOLDER_NAMES.has(entry.name) && (entry.name !== "target" ||
|
|
1702
|
+
if (FOLDER_NAMES.has(entry.name) && (entry.name !== "target" || existsSync4(join8(dir, "Cargo.toml")))) {
|
|
1856
1703
|
if (entry.isSymbolicLink()) {
|
|
1857
1704
|
found.skipped.push({ path, reason: "symlink" });
|
|
1858
1705
|
} else if (entry.isDirectory()) {
|
|
@@ -1938,7 +1785,7 @@ async function judgeFolder(path, kind, inside) {
|
|
|
1938
1785
|
const located = await toplevelOf(parent);
|
|
1939
1786
|
if (located === "failed")
|
|
1940
1787
|
return { skip: "git failed" };
|
|
1941
|
-
if (
|
|
1788
|
+
if (existsSync4(join8(path, ".git")))
|
|
1942
1789
|
return { skip: "holds a git repository" };
|
|
1943
1790
|
if (located === "none")
|
|
1944
1791
|
return name === "node_modules" || inside !== undefined ? { entry: { path, kind, committedAt: undefined, action: "remove", inside } } : { skip: "not in a git repository" };
|
|
@@ -2006,7 +1853,7 @@ async function removeFolder(entry) {
|
|
|
2006
1853
|
const stat = await lstat3(entry.path);
|
|
2007
1854
|
if (stat.isSymbolicLink() || !stat.isDirectory() || !(FOLDER_NAMES.has(basename2(entry.path)) || entry.kind === "cache" && isCachePath(entry.path)))
|
|
2008
1855
|
return { path: entry.path, removed: false, error: "no longer a plain folder" };
|
|
2009
|
-
if (
|
|
1856
|
+
if (existsSync5(join9(entry.path, ".git")))
|
|
2010
1857
|
return { path: entry.path, removed: false, error: "holds a git repository" };
|
|
2011
1858
|
await rm(entry.path, { recursive: true, force: true });
|
|
2012
1859
|
return { path: entry.path, removed: true };
|
|
@@ -2069,7 +1916,7 @@ async function sweep(args) {
|
|
|
2069
1916
|
if (positionals.length > 1)
|
|
2070
1917
|
badUsage("give one root");
|
|
2071
1918
|
const root = workspaceRoot({ given: positionals[0] });
|
|
2072
|
-
if (!
|
|
1919
|
+
if (!existsSync6(root) || !statSync2(root).isDirectory())
|
|
2073
1920
|
fail(`${root} is not a folder`);
|
|
2074
1921
|
if (values.only !== undefined && !Object.hasOwn(ONLY_KINDS, values.only))
|
|
2075
1922
|
badUsage(`--only takes worktrees, folders or caches, not ${values.only}`);
|
|
@@ -2089,7 +1936,7 @@ async function sweep(args) {
|
|
|
2089
1936
|
if (values.apply === true && removable.length > 0 && values.yes !== true) {
|
|
2090
1937
|
if (!json)
|
|
2091
1938
|
print(root, entries, skipped.length, reclaimable, now);
|
|
2092
|
-
const agreed = await confirm(`Delete ${removable.length} ${removable.length === 1 ? "entry" : "entries"} (${
|
|
1939
|
+
const agreed = await confirm(`Delete ${removable.length} ${removable.length === 1 ? "entry" : "entries"} (${tt(reclaimable)})?`, { default: false, hint: "pass --yes to skip the confirm" });
|
|
2093
1940
|
if (agreed !== true) {
|
|
2094
1941
|
if (json)
|
|
2095
1942
|
fail("nothing deleted: the confirm was declined", 1, "pass --yes to skip the confirm");
|
|
@@ -2097,7 +1944,7 @@ async function sweep(args) {
|
|
|
2097
1944
|
return 1;
|
|
2098
1945
|
}
|
|
2099
1946
|
}
|
|
2100
|
-
const outcomes = values.apply === true ? await applyAll(removable, (outcome) =>
|
|
1947
|
+
const outcomes = values.apply === true ? await applyAll(removable, (outcome) => report2(root, outcome, json)) : undefined;
|
|
2101
1948
|
const failed = outcomes?.filter((outcome) => !outcome.removed).length ?? 0;
|
|
2102
1949
|
if (json) {
|
|
2103
1950
|
printJson({ root, entries: entries.map((entry) => ({ path: entry.path, kind: entry.kind, bytes: entry.bytes, committedAt: entry.committedAt === undefined ? null : new Date(entry.committedAt).toISOString(), action: entry.action, reason: entry.reason ?? null })), skipped, reclaimable, docker: docker ?? null, ...outcomes === undefined ? {} : { removed: outcomes } });
|
|
@@ -2109,7 +1956,7 @@ async function sweep(args) {
|
|
|
2109
1956
|
console.log("dry run, pass --apply to delete");
|
|
2110
1957
|
} else {
|
|
2111
1958
|
const bytes = new Map(removable.map((entry) => [entry.path, entry.bytes]));
|
|
2112
|
-
note(`freed ${
|
|
1959
|
+
note(`freed ${tt(outcomes.reduce((sum, outcome) => sum + (outcome.removed ? bytes.get(outcome.path) ?? 0 : 0), 0))}`);
|
|
2113
1960
|
}
|
|
2114
1961
|
if (docker !== undefined)
|
|
2115
1962
|
console.log(`
|
|
@@ -2117,7 +1964,7 @@ docker (left to dclean):
|
|
|
2117
1964
|
${docker}`);
|
|
2118
1965
|
return failed === 0 ? 0 : 1;
|
|
2119
1966
|
}
|
|
2120
|
-
function
|
|
1967
|
+
function report2(root, outcome, json) {
|
|
2121
1968
|
if (json)
|
|
2122
1969
|
return;
|
|
2123
1970
|
if (outcome.removed)
|
|
@@ -2134,12 +1981,12 @@ function print(root, entries, skipped, reclaimable, now) {
|
|
|
2134
1981
|
const path = role("path", process.stdout);
|
|
2135
1982
|
const sized = (bytes) => {
|
|
2136
1983
|
if (bytes >= BIG)
|
|
2137
|
-
return colors.red(
|
|
2138
|
-
return bytes >= LARGE ? colors.yellow(
|
|
1984
|
+
return colors.red(tt(bytes));
|
|
1985
|
+
return bytes >= LARGE ? colors.yellow(tt(bytes)) : tt(bytes);
|
|
2139
1986
|
};
|
|
2140
1987
|
console.log(table([["size", "age", "what", "path", "note"], ...entries.map((entry) => [sized(entry.bytes), entry.committedAt === undefined ? colors.dim("-") : colors.dim(formatAge(entry.committedAt, now)), entry.kind, path(relative(root, entry.path)), entry.action === "keep" ? colors.dim(`kept: ${entry.reason}`) : ""])], { header: true, align: ["right", "right", "left", "left", "left"] }));
|
|
2141
1988
|
console.log(`
|
|
2142
|
-
${
|
|
1989
|
+
${tt(reclaimable)} reclaimable${skipped === 0 ? "" : `, ${skipped} skipped (symlinks, tracked or not ignored by git)`}`);
|
|
2143
1990
|
}
|
|
2144
1991
|
|
|
2145
1992
|
// src/sweep-cli.ts
|