@kaynooo/cli-workspace 0.11.1 → 0.13.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/README.md +23 -23
- package/dist/cli.js +915 -421
- package/package.json +9 -15
- package/dist/audit-cli.js +0 -1927
- package/dist/repos-cli.js +0 -1797
- package/dist/sweep-cli.js +0 -2187
package/dist/cli.js
CHANGED
|
@@ -1,28 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env -S bun --no-env-file --config=/dev/null
|
|
2
2
|
// @bun
|
|
3
|
+
var __esm = (fn, res, err) => () => {
|
|
4
|
+
if (fn)
|
|
5
|
+
try {
|
|
6
|
+
res = fn(fn = 0);
|
|
7
|
+
} catch (e) {
|
|
8
|
+
err = [e];
|
|
9
|
+
}
|
|
10
|
+
if (err)
|
|
11
|
+
throw err[0];
|
|
12
|
+
return res;
|
|
13
|
+
};
|
|
3
14
|
|
|
4
|
-
//
|
|
5
|
-
import process24 from "process";
|
|
6
|
-
|
|
7
|
-
// ../kit/src/advisory.ts
|
|
8
|
-
var SEVERITIES = ["low", "moderate", "high", "critical"];
|
|
9
|
-
function severityRank(severity) {
|
|
10
|
-
return SEVERITIES.indexOf(severity);
|
|
11
|
-
}
|
|
12
|
-
function isIgnored(advisory, ignore) {
|
|
13
|
-
return ignore.includes(advisory.ghsa ?? "") || ignore.includes(String(advisory.id));
|
|
14
|
-
}
|
|
15
|
-
// ../kit/src/args.ts
|
|
16
|
-
import process9 from "process";
|
|
17
|
-
import { parseArgs } from "util";
|
|
18
|
-
|
|
19
|
-
// ../kit/src/format.ts
|
|
20
|
-
import process7 from "process";
|
|
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;
|
|
15
|
+
// ../../node_modules/.bun/@kaynooo+utils@3.1.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-n6z2kk96.js
|
|
26
16
|
function a(e, t, o) {
|
|
27
17
|
return JSON.stringify([e ?? null, t ?? null, o]);
|
|
28
18
|
}
|
|
@@ -32,12 +22,15 @@ function y(e, t) {
|
|
|
32
22
|
n = new Intl.NumberFormat(e, t), i.set(o, n);
|
|
33
23
|
return n;
|
|
34
24
|
}
|
|
25
|
+
var r, i, l;
|
|
26
|
+
var init_chunk_n6z2kk96 = __esm(() => {
|
|
27
|
+
r = new Map;
|
|
28
|
+
i = new Map;
|
|
29
|
+
l = new Map;
|
|
30
|
+
});
|
|
35
31
|
|
|
36
|
-
// ../../node_modules/.bun/@kaynooo+utils@3.
|
|
37
|
-
|
|
38
|
-
var Nt = /\s+\S*$/;
|
|
39
|
-
var Y = /\s/;
|
|
40
|
-
function ko(t, e, r = "...") {
|
|
32
|
+
// ../../node_modules/.bun/@kaynooo+utils@3.1.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-rkhsft4a.js
|
|
33
|
+
function Ao(t, e, r = "...") {
|
|
41
34
|
let { suffix: n = "...", includeSuffix: s = false, wordBoundary: o = false } = typeof r === "string" ? { suffix: r } : r;
|
|
42
35
|
if (t.length <= e)
|
|
43
36
|
return t;
|
|
@@ -48,13 +41,22 @@ function ko(t, e, r = "...") {
|
|
|
48
41
|
c = c.trimEnd();
|
|
49
42
|
return s ? (c + n).slice(0, l) : c + n;
|
|
50
43
|
}
|
|
51
|
-
var
|
|
52
|
-
var
|
|
44
|
+
var N, Nt, Y, be, W;
|
|
45
|
+
var init_chunk_rkhsft4a = __esm(() => {
|
|
46
|
+
N = new Map;
|
|
47
|
+
Nt = /\s+\S*$/;
|
|
48
|
+
Y = /\s/;
|
|
49
|
+
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));
|
|
50
|
+
W = new Map;
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// ../../node_modules/.bun/@kaynooo+utils@3.1.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/text.js
|
|
54
|
+
var init_text = __esm(() => {
|
|
55
|
+
init_chunk_rkhsft4a();
|
|
56
|
+
});
|
|
53
57
|
|
|
54
58
|
// ../kit/src/mode.ts
|
|
55
59
|
import process2 from "process";
|
|
56
|
-
var MODES = new Set(["terminal", "ci", "agent", "pipe"]);
|
|
57
|
-
var AGENT_VARIABLES = ["CLAUDECODE", "AI_AGENT"];
|
|
58
60
|
function isSet(value) {
|
|
59
61
|
return value !== undefined && value !== "" && value !== "0" && value.toLowerCase() !== "false";
|
|
60
62
|
}
|
|
@@ -71,12 +73,13 @@ function outputMode(stream = process2.stdout, env = process2.env) {
|
|
|
71
73
|
function isInteractive(streams = process2) {
|
|
72
74
|
return streams.stdin?.isTTY === true && streams.stderr?.isTTY === true;
|
|
73
75
|
}
|
|
76
|
+
var MODES, AGENT_VARIABLES;
|
|
77
|
+
var init_mode = __esm(() => {
|
|
78
|
+
MODES = new Set(["terminal", "ci", "agent", "pipe"]);
|
|
79
|
+
AGENT_VARIABLES = ["CLAUDECODE", "AI_AGENT"];
|
|
80
|
+
});
|
|
74
81
|
|
|
75
|
-
//
|
|
76
|
-
import process6 from "process";
|
|
77
|
-
|
|
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;
|
|
82
|
+
// ../../node_modules/.bun/@kaynooo+utils@3.1.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-x450vn3m.js
|
|
80
83
|
function b(r) {
|
|
81
84
|
let e = r.startsWith("#") ? r.slice(1) : r;
|
|
82
85
|
if (!G2.test(e))
|
|
@@ -87,11 +90,6 @@ function b(r) {
|
|
|
87
90
|
throw Error(`Invalid hex color length: ${e.length}`);
|
|
88
91
|
return [Number.parseInt(e.slice(0, 2), 16), Number.parseInt(e.slice(2, 4), 16), Number.parseInt(e.slice(4, 6), 16)];
|
|
89
92
|
}
|
|
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
93
|
function C(r, e = globalThis.process?.env ?? {}) {
|
|
96
94
|
if (e.FORCE_COLOR !== undefined)
|
|
97
95
|
return h.has(e.FORCE_COLOR);
|
|
@@ -105,7 +103,7 @@ function f(r, e = []) {
|
|
|
105
103
|
l += `\x1B[${e[t][0]}m`, n = `\x1B[${e[t][1]}m${n}`;
|
|
106
104
|
let c = (t) => C(r.stream ?? globalThis.process?.stdout, r.env) ? l + t + n : t, g = new Map;
|
|
107
105
|
return new Proxy(c, { get(t, i) {
|
|
108
|
-
let a =
|
|
106
|
+
let a = B[i];
|
|
109
107
|
if (Array.isArray(a)) {
|
|
110
108
|
let s = g.get(i);
|
|
111
109
|
if (s === undefined)
|
|
@@ -128,13 +126,21 @@ function f(r, e = []) {
|
|
|
128
126
|
function Fe(r = {}) {
|
|
129
127
|
return f(r);
|
|
130
128
|
}
|
|
131
|
-
var
|
|
129
|
+
var G2, B, h, o;
|
|
130
|
+
var init_chunk_x450vn3m = __esm(() => {
|
|
131
|
+
G2 = /^[a-f0-9]+$/i;
|
|
132
|
+
B = { 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") => {
|
|
133
|
+
let [l, n, c] = b(r);
|
|
134
|
+
return [`${e === "fg" ? 38 : 48};2;${l};${n};${c}`, e === "fg" ? 39 : 49];
|
|
135
|
+
}, ansi256: (r, e = "fg") => [`${e === "fg" ? 38 : 48};5;${r}`, e === "fg" ? 39 : 49] };
|
|
136
|
+
h = new Set(["", "1", "2", "3", "true"]);
|
|
137
|
+
o = Fe();
|
|
138
|
+
});
|
|
132
139
|
|
|
133
|
-
//
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
import process5 from "process";
|
|
140
|
+
// ../../node_modules/.bun/@kaynooo+utils@3.1.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/tools/colors.js
|
|
141
|
+
var init_colors = __esm(() => {
|
|
142
|
+
init_chunk_x450vn3m();
|
|
143
|
+
});
|
|
138
144
|
|
|
139
145
|
// ../kit/src/config.ts
|
|
140
146
|
import { existsSync } from "fs";
|
|
@@ -150,6 +156,9 @@ function findUp(names, from = process3.cwd(), stop = () => false) {
|
|
|
150
156
|
return;
|
|
151
157
|
}
|
|
152
158
|
}
|
|
159
|
+
var init_config = __esm(() => {
|
|
160
|
+
init_args();
|
|
161
|
+
});
|
|
153
162
|
|
|
154
163
|
// ../kit/src/user-config.ts
|
|
155
164
|
import { existsSync as existsSync2, readFileSync } from "fs";
|
|
@@ -185,36 +194,49 @@ function configuredNumber(bin, key, fallback, where = {}, legacy = []) {
|
|
|
185
194
|
const value = readUserConfig(bin, where, legacy)[key];
|
|
186
195
|
return typeof value === "number" && Number.isInteger(value) && value > 0 ? value : fallback;
|
|
187
196
|
}
|
|
197
|
+
var init_user_config = () => {};
|
|
188
198
|
|
|
189
199
|
// ../kit/src/theme.ts
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
200
|
+
import { existsSync as existsSync3, readFileSync as readFileSync2, statSync } from "fs";
|
|
201
|
+
import { homedir as homedir2 } from "os";
|
|
202
|
+
import { join as join3, resolve as resolve2 } from "path";
|
|
203
|
+
import process5 from "process";
|
|
204
|
+
function toLinear(channel) {
|
|
205
|
+
const value = channel / 255;
|
|
206
|
+
return value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4;
|
|
207
|
+
}
|
|
208
|
+
function toOklab(hex) {
|
|
209
|
+
const [r, g, b] = [1, 3, 5].map((at) => toLinear(Number.parseInt(hex.slice(at, at + 2), 16)));
|
|
210
|
+
const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b);
|
|
211
|
+
const m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b);
|
|
212
|
+
const s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b);
|
|
213
|
+
return [0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s, 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s, 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s];
|
|
214
|
+
}
|
|
215
|
+
function fromOklab([lightness, a, b]) {
|
|
216
|
+
const l = (lightness + 0.3963377774 * a + 0.2158037573 * b) ** 3;
|
|
217
|
+
const m = (lightness - 0.1055613458 * a - 0.0638541728 * b) ** 3;
|
|
218
|
+
const s = (lightness - 0.0894841775 * a - 1.291485548 * b) ** 3;
|
|
219
|
+
const channels = [4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s, -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s, -0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s];
|
|
220
|
+
return `#${channels.map((channel) => fromLinear(channel).toString(16).padStart(2, "0")).join("")}`;
|
|
221
|
+
}
|
|
222
|
+
function gradientAt(theme, ratio) {
|
|
223
|
+
if (theme.gradient === undefined)
|
|
224
|
+
return;
|
|
225
|
+
const key = theme.gradient.join();
|
|
226
|
+
let ends = ENDS.get(key);
|
|
227
|
+
if (ends === undefined) {
|
|
228
|
+
ends = [toOklab(theme.gradient[0]), toOklab(theme.gradient[1])];
|
|
229
|
+
ENDS.set(key, ends);
|
|
230
|
+
}
|
|
231
|
+
const at = Math.min(1, Math.max(0, ratio));
|
|
232
|
+
const [from, to] = ends;
|
|
233
|
+
return fromOklab(from.map((start, index) => start + (to[index] - start) * at));
|
|
234
|
+
}
|
|
212
235
|
function isColorSpec(spec) {
|
|
213
236
|
if (typeof spec === "number")
|
|
214
237
|
return Number.isInteger(spec) && spec >= 0 && spec <= 255;
|
|
215
238
|
return typeof spec === "string" && spec.trim() !== "" && spec.trim().split(SPACES).every((token) => STYLES.has(token) || HEX.test(token));
|
|
216
239
|
}
|
|
217
|
-
var CUBE = [0, 95, 135, 175, 215, 255];
|
|
218
240
|
function cubeLevel(channel) {
|
|
219
241
|
return CUBE.reduce((best, value, level) => Math.abs(value - channel) < Math.abs(CUBE[best] - channel) ? level : best, 0);
|
|
220
242
|
}
|
|
@@ -239,6 +261,9 @@ function tinted(colors, spec, env = process5.env) {
|
|
|
239
261
|
return chain[token] ?? chain;
|
|
240
262
|
}, colors);
|
|
241
263
|
}
|
|
264
|
+
function shaded(theme, colors, glyph, cells, width, env = process5.env) {
|
|
265
|
+
return Array.from({ length: cells }, (_, index) => tinted(colors, gradientAt(theme, width <= 1 ? 0 : index / (width - 1)) ?? theme.colors.accent, env)(glyph)).join("");
|
|
266
|
+
}
|
|
242
267
|
function isRecord(value) {
|
|
243
268
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
244
269
|
}
|
|
@@ -319,7 +344,6 @@ function applyFile(theme, file, where, warn) {
|
|
|
319
344
|
function endsWalk(home) {
|
|
320
345
|
return (dir) => dir === resolve2(home) || existsSync3(join3(dir, ".git"));
|
|
321
346
|
}
|
|
322
|
-
var warned = new Set;
|
|
323
347
|
function warnOnce(message) {
|
|
324
348
|
if (warned.has(message))
|
|
325
349
|
return;
|
|
@@ -356,8 +380,6 @@ function loadTheme({ env = process5.env, from = process5.cwd(), home = homedir2(
|
|
|
356
380
|
}
|
|
357
381
|
return { theme, sources, preset };
|
|
358
382
|
}
|
|
359
|
-
var current;
|
|
360
|
-
var currentKey = "";
|
|
361
383
|
function activeTheme() {
|
|
362
384
|
const key = `${process5.cwd()}\x00${process5.env.KIT_THEME ?? ""}\x00${process5.env.XDG_CONFIG_HOME ?? ""}`;
|
|
363
385
|
if (current === undefined || key !== currentKey) {
|
|
@@ -366,9 +388,38 @@ function activeTheme() {
|
|
|
366
388
|
}
|
|
367
389
|
return current;
|
|
368
390
|
}
|
|
391
|
+
var fromLinear = (value) => Math.round(255 * Math.min(1, Math.max(0, value <= 0.0031308 ? value * 12.92 : 1.055 * value ** (1 / 2.4) - 0.055))), ENDS, DEFAULT, BRIGHT, MONO, ASCII, PRESETS, STYLES, HEX, CONTROL, MAX_FILE_BYTES, SPACES, CUBE, warned, current, currentKey = "";
|
|
392
|
+
var init_theme = __esm(() => {
|
|
393
|
+
init_config();
|
|
394
|
+
init_user_config();
|
|
395
|
+
ENDS = new Map;
|
|
396
|
+
DEFAULT = {
|
|
397
|
+
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" },
|
|
398
|
+
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" },
|
|
399
|
+
accents: ["cyan", "magenta", "green", "blue", "yellow", "redBright"],
|
|
400
|
+
bins: {},
|
|
401
|
+
gradient: ["#c084fc", "#67e8f9"]
|
|
402
|
+
};
|
|
403
|
+
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" };
|
|
404
|
+
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" };
|
|
405
|
+
ASCII = { ok: "+", warn: "!", problem: "x", note: ">", plan: "?", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#", rule: "-", corner: "+", open: "*", leaf: "-", guide: "|" };
|
|
406
|
+
PRESETS = {
|
|
407
|
+
default: {},
|
|
408
|
+
"high-contrast": { colors: BRIGHT, accents: ["cyanBright", "magentaBright", "greenBright", "blueBright", "yellowBright", "redBright"], gradient: ["#d8b4fe", "#a5f3fc"] },
|
|
409
|
+
mono: { colors: MONO, accents: ["bold"], gradient: undefined },
|
|
410
|
+
ascii: { glyphs: ASCII }
|
|
411
|
+
};
|
|
412
|
+
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"]);
|
|
413
|
+
HEX = /^#[0-9a-f]{6}$/i;
|
|
414
|
+
CONTROL = /\p{Cc}/u;
|
|
415
|
+
MAX_FILE_BYTES = 64 * 1024;
|
|
416
|
+
SPACES = /\s+/;
|
|
417
|
+
CUBE = [0, 95, 135, 175, 215, 255];
|
|
418
|
+
warned = new Set;
|
|
419
|
+
});
|
|
369
420
|
|
|
370
421
|
// ../kit/src/style.ts
|
|
371
|
-
|
|
422
|
+
import process6 from "process";
|
|
372
423
|
function takesControlCodes(stream, env = process6.env) {
|
|
373
424
|
return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb" && outputMode(stream, env) === "terminal";
|
|
374
425
|
}
|
|
@@ -397,14 +448,6 @@ function role(name, stream, env = process6.env) {
|
|
|
397
448
|
const colors = paint(stream, env);
|
|
398
449
|
return takesControlCodes(stream, env) ? tinted(colors, activeTheme().theme.colors[name], env) : colors;
|
|
399
450
|
}
|
|
400
|
-
var STATUS_WORDS = {
|
|
401
|
-
passed: ["passed", "success", "succeeded", "ok"],
|
|
402
|
-
failed: ["failed", "failure", "error", "errored"],
|
|
403
|
-
running: ["running", "in_progress", "started", "holding"],
|
|
404
|
-
queued: ["queued", "waiting", "pending", "created", "blocked", "scheduled"],
|
|
405
|
-
skipped: ["skipped", "cancelled", "canceled", "manual"]
|
|
406
|
-
};
|
|
407
|
-
var STATUS_OF = new Map(Object.entries(STATUS_WORDS).flatMap(([status, words]) => words.map((word) => [word, status])));
|
|
408
451
|
function header(bin, context, stream, env = process6.env) {
|
|
409
452
|
if (!takesControlCodes(stream, env))
|
|
410
453
|
return "";
|
|
@@ -420,7 +463,23 @@ function printHeader(bin, context, stream = process6.stdout, env = process6.env)
|
|
|
420
463
|
if (line !== "")
|
|
421
464
|
console.log(line);
|
|
422
465
|
}
|
|
423
|
-
|
|
466
|
+
var MARK_WORDS, STATUS_WORDS, STATUS_OF;
|
|
467
|
+
var init_style = __esm(() => {
|
|
468
|
+
init_colors();
|
|
469
|
+
init_mode();
|
|
470
|
+
init_theme();
|
|
471
|
+
MARK_WORDS = { ok: "ok:", warn: "warning:", problem: "error:", note: "note:", plan: "would:" };
|
|
472
|
+
STATUS_WORDS = {
|
|
473
|
+
passed: ["passed", "success", "succeeded", "ok"],
|
|
474
|
+
failed: ["failed", "failure", "error", "errored"],
|
|
475
|
+
running: ["running", "in_progress", "started", "holding"],
|
|
476
|
+
queued: ["queued", "waiting", "pending", "created", "blocked", "scheduled"],
|
|
477
|
+
skipped: ["skipped", "cancelled", "canceled", "manual"]
|
|
478
|
+
};
|
|
479
|
+
STATUS_OF = new Map(Object.entries(STATUS_WORDS).flatMap(([status, words]) => words.map((word) => [word, status])));
|
|
480
|
+
});
|
|
481
|
+
|
|
482
|
+
// ../../node_modules/.bun/@kaynooo+utils@3.1.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-knqbxp56.js
|
|
424
483
|
function tt(i, { units: r = "iec", dp: t = 1, locale: n } = {}) {
|
|
425
484
|
let e = r === "si" ? 1000 : 1024;
|
|
426
485
|
if (Math.abs(i) < e)
|
|
@@ -431,9 +490,17 @@ function tt(i, { units: r = "iec", dp: t = 1, locale: n } = {}) {
|
|
|
431
490
|
while (Math.round(Math.abs(i) * a) / a >= e && o < s.length - 1);
|
|
432
491
|
return `${n ? y(n, { minimumFractionDigits: t, maximumFractionDigits: t }).format(i) : i.toFixed(t)} ${s[o]}`;
|
|
433
492
|
}
|
|
493
|
+
var init_chunk_knqbxp56 = __esm(() => {
|
|
494
|
+
init_chunk_n6z2kk96();
|
|
495
|
+
});
|
|
496
|
+
|
|
497
|
+
// ../../node_modules/.bun/@kaynooo+utils@3.1.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/format/index.js
|
|
498
|
+
var init_format = __esm(() => {
|
|
499
|
+
init_chunk_knqbxp56();
|
|
500
|
+
});
|
|
434
501
|
|
|
435
502
|
// ../kit/src/format.ts
|
|
436
|
-
|
|
503
|
+
import process7 from "process";
|
|
437
504
|
function formatSeconds(total) {
|
|
438
505
|
let rest = Math.max(0, Math.round(total));
|
|
439
506
|
const amounts = UNITS.map(([unit, size]) => {
|
|
@@ -450,6 +517,9 @@ function formatSeconds(total) {
|
|
|
450
517
|
function formatDuration(ms) {
|
|
451
518
|
return ms < 60000 ? `${(Math.max(0, ms) / 1000).toFixed(1)}s` : formatSeconds(ms / 1000);
|
|
452
519
|
}
|
|
520
|
+
function formatElapsed(ms) {
|
|
521
|
+
return formatSeconds(Math.floor(Math.max(0, ms) / 1000));
|
|
522
|
+
}
|
|
453
523
|
function upTo(text, separator) {
|
|
454
524
|
const end = text.indexOf(separator);
|
|
455
525
|
return end === -1 ? text : text.slice(0, end);
|
|
@@ -462,10 +532,8 @@ function formatAge(date, now = Date.now()) {
|
|
|
462
532
|
return seconds < 60 ? "just now" : `${upTo(formatSeconds(seconds), " ")} ago`;
|
|
463
533
|
}
|
|
464
534
|
function truncate(text, width) {
|
|
465
|
-
return
|
|
535
|
+
return Ao(text, width, { suffix: "\u2026", includeSuffix: true });
|
|
466
536
|
}
|
|
467
|
-
var LINE_BREAKS = /\s*\n\s*/g;
|
|
468
|
-
var ESCAPE = String.fromCharCode(27);
|
|
469
537
|
function textWidth(text) {
|
|
470
538
|
return Bun.stringWidth(text);
|
|
471
539
|
}
|
|
@@ -514,12 +582,19 @@ function jsonText(value, replacer, { stream = process7.stdout, env = process7.en
|
|
|
514
582
|
function printJson(value) {
|
|
515
583
|
console.log(jsonText(value));
|
|
516
584
|
}
|
|
585
|
+
var UNITS, LINE_BREAKS, ESCAPE;
|
|
586
|
+
var init_format2 = __esm(() => {
|
|
587
|
+
init_text();
|
|
588
|
+
init_mode();
|
|
589
|
+
init_style();
|
|
590
|
+
init_format();
|
|
591
|
+
UNITS = [["d", 86400], ["h", 3600], ["m", 60], ["s", 1]];
|
|
592
|
+
LINE_BREAKS = /\s*\n\s*/g;
|
|
593
|
+
ESCAPE = String.fromCharCode(27);
|
|
594
|
+
});
|
|
517
595
|
|
|
518
596
|
// ../kit/src/help.ts
|
|
519
597
|
import process8 from "process";
|
|
520
|
-
var OPTIONAL = /(?<!\x1B)\[[^\]]+\]/g;
|
|
521
|
-
var USAGE_PREFIX = /^usage:\s*/i;
|
|
522
|
-
var FULL_STOP = /\.$/;
|
|
523
598
|
function usageLine(usage, colors = paint(process8.stdout)) {
|
|
524
599
|
return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
|
|
525
600
|
}
|
|
@@ -556,7 +631,6 @@ function exampleRows(examples, colors = paint(process8.stdout)) {
|
|
|
556
631
|
return [];
|
|
557
632
|
return ["", colors.bold("Examples:"), ...examples.map((example) => typeof example === "string" ? ` ${example}` : ` ${example[0]} ${colors.dim(`# ${example[1]}`)}`)];
|
|
558
633
|
}
|
|
559
|
-
var MAX_INLINE_CHOICES = 24;
|
|
560
634
|
function optionRows(options, colors = paint(process8.stdout)) {
|
|
561
635
|
const rows = Object.entries(options).map(([name, option]) => {
|
|
562
636
|
const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
|
|
@@ -571,6 +645,14 @@ function optionRows(options, colors = paint(process8.stdout)) {
|
|
|
571
645
|
const width = Math.max(0, ...rows.map((row) => row.width));
|
|
572
646
|
return rows.map((row) => row.description === "" ? ` ${row.flag}` : ` ${row.flag}${" ".repeat(width - row.width)} ${colors.dim(row.description)}`);
|
|
573
647
|
}
|
|
648
|
+
var OPTIONAL, USAGE_PREFIX, FULL_STOP, MAX_INLINE_CHOICES = 24;
|
|
649
|
+
var init_help = __esm(() => {
|
|
650
|
+
init_mode();
|
|
651
|
+
init_style();
|
|
652
|
+
OPTIONAL = /(?<!\x1B)\[[^\]]+\]/g;
|
|
653
|
+
USAGE_PREFIX = /^usage:\s*/i;
|
|
654
|
+
FULL_STOP = /\.$/;
|
|
655
|
+
});
|
|
574
656
|
|
|
575
657
|
// ../kit/src/text.ts
|
|
576
658
|
function distance(a, b) {
|
|
@@ -598,9 +680,9 @@ function closest(name, names) {
|
|
|
598
680
|
const [best] = names.map((known) => ({ known, far: distance(name, known) })).sort((a, b) => a.far - b.far);
|
|
599
681
|
return best !== undefined && best.far <= (name.length < 4 ? 1 : 2) ? best.known : undefined;
|
|
600
682
|
}
|
|
683
|
+
var init_text2 = () => {};
|
|
684
|
+
|
|
601
685
|
// ../kit/src/input.ts
|
|
602
|
-
var DURATION = /^(\d+(?:\.\d+)?)(ms|[smhd])?$/;
|
|
603
|
-
var UNIT_MS = { ms: 1, s: 1000, m: 60000, h: 3600000, d: 86400000 };
|
|
604
686
|
function duration(value, name, fallback, unit = "s") {
|
|
605
687
|
if (value === undefined)
|
|
606
688
|
return fallback;
|
|
@@ -610,40 +692,26 @@ function duration(value, name, fallback, unit = "s") {
|
|
|
610
692
|
badUsage(`--${name} takes a duration such as 30s, 5m, 1h or 7d, not ${value}`);
|
|
611
693
|
return ms;
|
|
612
694
|
}
|
|
695
|
+
var DURATION, UNIT_MS;
|
|
696
|
+
var init_input = __esm(() => {
|
|
697
|
+
init_args();
|
|
698
|
+
DURATION = /^(\d+(?:\.\d+)?)(ms|[smhd])?$/;
|
|
699
|
+
UNIT_MS = { ms: 1, s: 1000, m: 60000, h: 3600000, d: 86400000 };
|
|
700
|
+
});
|
|
613
701
|
|
|
614
702
|
// ../kit/src/args.ts
|
|
615
|
-
|
|
703
|
+
import process9 from "process";
|
|
704
|
+
import { parseArgs } from "util";
|
|
616
705
|
function jsonOption(holds) {
|
|
617
706
|
return { type: "boolean", description: holds === undefined ? "print JSON" : `print JSON: ${holds}` };
|
|
618
707
|
}
|
|
619
|
-
class Exit extends Error {
|
|
620
|
-
code;
|
|
621
|
-
hint;
|
|
622
|
-
constructor(message, code, hint) {
|
|
623
|
-
super(message);
|
|
624
|
-
this.code = code;
|
|
625
|
-
this.hint = hint;
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
708
|
function fail(message, code = 2, hint) {
|
|
629
709
|
throw new Exit(message, code, hint);
|
|
630
710
|
}
|
|
631
|
-
|
|
632
|
-
class UsageError extends Exit {
|
|
633
|
-
constructor(message, hint) {
|
|
634
|
-
super(message, 2, hint);
|
|
635
|
-
}
|
|
636
|
-
}
|
|
637
711
|
function badUsage(message) {
|
|
638
712
|
throw new UsageError(message);
|
|
639
713
|
}
|
|
640
714
|
|
|
641
|
-
class HelpShown extends Exit {
|
|
642
|
-
constructor() {
|
|
643
|
-
super("help shown", 0);
|
|
644
|
-
}
|
|
645
|
-
}
|
|
646
|
-
|
|
647
715
|
class Completing {
|
|
648
716
|
options;
|
|
649
717
|
positionals;
|
|
@@ -654,11 +722,6 @@ class Completing {
|
|
|
654
722
|
this.candidates = candidates;
|
|
655
723
|
}
|
|
656
724
|
}
|
|
657
|
-
var completion = { active: false };
|
|
658
|
-
var OUTPUT_OPTIONS = {
|
|
659
|
-
color: { type: "string", choices: ["auto", "always", "never"], description: "auto (the default) colours on a terminal alone" },
|
|
660
|
-
plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
|
|
661
|
-
};
|
|
662
725
|
function applyOutput(color, plain, env = process9.env) {
|
|
663
726
|
const when = plain === true ? "never" : color ?? "auto";
|
|
664
727
|
if (when === "auto")
|
|
@@ -812,7 +875,6 @@ function parseError(error) {
|
|
|
812
875
|
const message = upTo(error instanceof Error ? error.message : String(error), ". ");
|
|
813
876
|
return `${message.charAt(0).toLowerCase()}${message.slice(1)}`;
|
|
814
877
|
}
|
|
815
|
-
var UNKNOWN_OPTION = /^unknown option '(-[^']+)'/;
|
|
816
878
|
function nearestOption(message, options, allowNegative) {
|
|
817
879
|
const typed = UNKNOWN_OPTION.exec(message)?.[1];
|
|
818
880
|
if (typed === undefined)
|
|
@@ -828,6 +890,296 @@ function nearestOption(message, options, allowNegative) {
|
|
|
828
890
|
const meant = closest(word, known.map((flag) => flag.replace(DASHES, "")));
|
|
829
891
|
return meant === undefined ? undefined : `did you mean ${known.find((flag) => flag.replace(DASHES, "") === meant)}?`;
|
|
830
892
|
}
|
|
893
|
+
var DASHES, Exit, UsageError, HelpShown, completion, OUTPUT_OPTIONS, UNKNOWN_OPTION;
|
|
894
|
+
var init_args = __esm(() => {
|
|
895
|
+
init_format2();
|
|
896
|
+
init_help();
|
|
897
|
+
init_text2();
|
|
898
|
+
init_help();
|
|
899
|
+
init_input();
|
|
900
|
+
DASHES = /^-+/;
|
|
901
|
+
Exit = class Exit extends Error {
|
|
902
|
+
code;
|
|
903
|
+
hint;
|
|
904
|
+
constructor(message, code, hint) {
|
|
905
|
+
super(message);
|
|
906
|
+
this.code = code;
|
|
907
|
+
this.hint = hint;
|
|
908
|
+
}
|
|
909
|
+
};
|
|
910
|
+
UsageError = class UsageError extends Exit {
|
|
911
|
+
constructor(message, hint) {
|
|
912
|
+
super(message, 2, hint);
|
|
913
|
+
}
|
|
914
|
+
};
|
|
915
|
+
HelpShown = class HelpShown extends Exit {
|
|
916
|
+
constructor() {
|
|
917
|
+
super("help shown", 0);
|
|
918
|
+
}
|
|
919
|
+
};
|
|
920
|
+
completion = { active: false };
|
|
921
|
+
OUTPUT_OPTIONS = {
|
|
922
|
+
color: { type: "string", choices: ["auto", "always", "never"], description: "auto (the default) colours on a terminal alone" },
|
|
923
|
+
plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
|
|
924
|
+
};
|
|
925
|
+
UNKNOWN_OPTION = /^unknown option '(-[^']+)'/;
|
|
926
|
+
});
|
|
927
|
+
|
|
928
|
+
// ../kit/src/folders.ts
|
|
929
|
+
var SKIPPED_FOLDERS;
|
|
930
|
+
var init_folders = __esm(() => {
|
|
931
|
+
init_user_config();
|
|
932
|
+
SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
|
|
933
|
+
});
|
|
934
|
+
|
|
935
|
+
// ../kit/src/answers.ts
|
|
936
|
+
var init_answers = __esm(() => {
|
|
937
|
+
init_folders();
|
|
938
|
+
});
|
|
939
|
+
|
|
940
|
+
// ../kit/src/job.ts
|
|
941
|
+
import process24 from "process";
|
|
942
|
+
function stopJob() {
|
|
943
|
+
process24.kill(0, "SIGTSTP");
|
|
944
|
+
}
|
|
945
|
+
var init_job = () => {};
|
|
946
|
+
|
|
947
|
+
// ../kit/src/picker/line.ts
|
|
948
|
+
function isEditKey(key) {
|
|
949
|
+
return EDIT_KEYS.has(key);
|
|
950
|
+
}
|
|
951
|
+
var EDIT_KEYS, BACKWARD_KILLS, FORWARD_KILLS;
|
|
952
|
+
var init_line = __esm(() => {
|
|
953
|
+
EDIT_KEYS = new Set(["left", "right", "wordleft", "wordright", "linestart", "lineend", "erase", "delete", "word", "killword", "killnext", "clear", "killend", "yank"]);
|
|
954
|
+
BACKWARD_KILLS = new Set(["word", "killword", "clear"]);
|
|
955
|
+
FORWARD_KILLS = new Set(["killnext", "killend"]);
|
|
956
|
+
});
|
|
957
|
+
|
|
958
|
+
// ../kit/src/picker/score.ts
|
|
959
|
+
var BOUNDARY_AFTER, NONE;
|
|
960
|
+
var init_score = __esm(() => {
|
|
961
|
+
BOUNDARY_AFTER = new Set([" ", "/", "-", "_", ".", ":", "\\", "(", "[", ",", "\t"]);
|
|
962
|
+
NONE = Number.NEGATIVE_INFINITY;
|
|
963
|
+
});
|
|
964
|
+
|
|
965
|
+
// ../kit/src/picker/state.ts
|
|
966
|
+
function repeat(value, count) {
|
|
967
|
+
return Array.from({ length: count }).fill(value);
|
|
968
|
+
}
|
|
969
|
+
function parseKeys(input, paste = { active: false }, ctrls = []) {
|
|
970
|
+
const codes = new Map(ctrls.map((name) => [String.fromCharCode(name.codePointAt(name.length - 1) - 96), name]));
|
|
971
|
+
return (input.match(KEY_SEQUENCES) ?? []).flatMap((sequence) => {
|
|
972
|
+
const wheel = MOUSE.exec(sequence)?.[1];
|
|
973
|
+
if (wheel !== undefined)
|
|
974
|
+
return repeat(wheel === "64" ? "up" : "down", wheel === "64" || wheel === "65" ? WHEEL_LINES : 0);
|
|
975
|
+
const named = codes.get(sequence);
|
|
976
|
+
const key = named === undefined ? KEYS[sequence] : { ctrl: named };
|
|
977
|
+
if (sequence === PASTE_START || sequence === PASTE_END) {
|
|
978
|
+
paste.active = sequence === PASTE_START;
|
|
979
|
+
return [];
|
|
980
|
+
}
|
|
981
|
+
if (paste.active && (sequence === "\r" || sequence === `
|
|
982
|
+
`))
|
|
983
|
+
return [];
|
|
984
|
+
if (key !== undefined)
|
|
985
|
+
return [key];
|
|
986
|
+
return IS_CONTROL.test(sequence) || sequence.startsWith("\x1B") ? [] : [{ text: sequence }];
|
|
987
|
+
});
|
|
988
|
+
}
|
|
989
|
+
var IS_CONTROL, PASTE_START = "\x1B[200~", PASTE_END = "\x1B[201~", KEY_SEQUENCES, MOUSE, WHEEL_LINES = 3, KEYS;
|
|
990
|
+
var init_state = __esm(() => {
|
|
991
|
+
init_text2();
|
|
992
|
+
init_line();
|
|
993
|
+
init_score();
|
|
994
|
+
IS_CONTROL = /[\x00-\x1F\x7F-\x9F]/;
|
|
995
|
+
KEY_SEQUENCES = /\x1B\[<[0-9;]*[A-Za-z]|\x1B\[[0-9;]*[A-Z~]|\x1BO[A-Z]|\x1B[\s\S]|[\s\S]/gu;
|
|
996
|
+
MOUSE = /^\x1B\[<(\d+);\d+;\d+[a-z]$/i;
|
|
997
|
+
KEYS = {
|
|
998
|
+
"\x1B[A": "up",
|
|
999
|
+
"\x1BOA": "up",
|
|
1000
|
+
"\x10": "up",
|
|
1001
|
+
"\x1B[B": "down",
|
|
1002
|
+
"\x1BOB": "down",
|
|
1003
|
+
"\x0E": "down",
|
|
1004
|
+
"\x1B[5~": "pageup",
|
|
1005
|
+
"\x1B[6~": "pagedown",
|
|
1006
|
+
"\x1B[H": "home",
|
|
1007
|
+
"\x1B[1~": "home",
|
|
1008
|
+
"\x1BOH": "home",
|
|
1009
|
+
"\x1B[F": "end",
|
|
1010
|
+
"\x1B[4~": "end",
|
|
1011
|
+
"\x1BOF": "end",
|
|
1012
|
+
"\r": "enter",
|
|
1013
|
+
"\n": "enter",
|
|
1014
|
+
"\x03": "cancel",
|
|
1015
|
+
"\x1B": "cancel",
|
|
1016
|
+
"\x1B[D": "left",
|
|
1017
|
+
"\x1BOD": "left",
|
|
1018
|
+
"\x1B[C": "right",
|
|
1019
|
+
"\x1BOC": "right",
|
|
1020
|
+
"\x1B[1;5D": "wordleft",
|
|
1021
|
+
"\x1B[1;3D": "wordleft",
|
|
1022
|
+
"\x1Bb": "wordleft",
|
|
1023
|
+
"\x1B[1;5C": "wordright",
|
|
1024
|
+
"\x1B[1;3C": "wordright",
|
|
1025
|
+
"\x1Bf": "wordright",
|
|
1026
|
+
"\x01": "linestart",
|
|
1027
|
+
"\x05": "lineend",
|
|
1028
|
+
"\x7F": "erase",
|
|
1029
|
+
"\x1B[3~": "delete",
|
|
1030
|
+
"\b": "killword",
|
|
1031
|
+
"\x1B\x7F": "killword",
|
|
1032
|
+
"\x1B[3;5~": "killnext",
|
|
1033
|
+
"\x1Bd": "killnext",
|
|
1034
|
+
"\x15": "clear",
|
|
1035
|
+
"\v": "killend",
|
|
1036
|
+
"\x17": "word",
|
|
1037
|
+
"\x19": "yank",
|
|
1038
|
+
"\x1A": "suspend",
|
|
1039
|
+
"\t": "tab",
|
|
1040
|
+
"\x1F": "help",
|
|
1041
|
+
"\x1BOP": "help",
|
|
1042
|
+
"\x1B[11~": "help"
|
|
1043
|
+
};
|
|
1044
|
+
});
|
|
1045
|
+
|
|
1046
|
+
// ../kit/src/redraw.ts
|
|
1047
|
+
function overwrite(lines, columns) {
|
|
1048
|
+
return lines.map((line) => textWidth(line) % columns === 0 ? `\x1B[2K${line}` : `${line}\x1B[K`).join(`
|
|
1049
|
+
`);
|
|
1050
|
+
}
|
|
1051
|
+
function rowsTaken(lines, columns) {
|
|
1052
|
+
return lines.reduce((rows, line) => rows + Math.max(1, Math.ceil(textWidth(line) / columns)), 0);
|
|
1053
|
+
}
|
|
1054
|
+
var SYNC_START = "\x1B[?2026h", SYNC_END = "\x1B[?2026l";
|
|
1055
|
+
var init_redraw = __esm(() => {
|
|
1056
|
+
init_format2();
|
|
1057
|
+
});
|
|
1058
|
+
|
|
1059
|
+
// ../kit/src/prompt.ts
|
|
1060
|
+
import process25 from "process";
|
|
1061
|
+
function readKeys(input, paste = { active: false }) {
|
|
1062
|
+
return parseKeys(input, paste).filter((key) => typeof key === "object" ? "text" in key : PROMPT_KEYS.has(key) || isEditKey(key));
|
|
1063
|
+
}
|
|
1064
|
+
async function confirm(question, { default: fallback, ...settings } = {}) {
|
|
1065
|
+
let answered = fallback;
|
|
1066
|
+
const choices = { true: "Y/n", false: "y/N", undefined: "y/n" }[String(fallback)];
|
|
1067
|
+
const accepted = await ask(question, settings, (colors, state) => [state === "asking" ? asking(colors, question, "", choices) : answer(colors, question, state, answered ? "yes" : "no")], (key) => {
|
|
1068
|
+
if (key === "cancel")
|
|
1069
|
+
return "cancel";
|
|
1070
|
+
if (key === "enter")
|
|
1071
|
+
return answered === undefined ? undefined : "enter";
|
|
1072
|
+
const letter = typeof key === "object" ? key.text.toLowerCase() : "";
|
|
1073
|
+
if (letter !== "y" && letter !== "n")
|
|
1074
|
+
return;
|
|
1075
|
+
answered = letter === "y";
|
|
1076
|
+
return "enter";
|
|
1077
|
+
});
|
|
1078
|
+
return accepted ? answered : undefined;
|
|
1079
|
+
}
|
|
1080
|
+
function asking(colors, question, typed, keys) {
|
|
1081
|
+
return `${colors.cyan("?")} ${question} ${typed === "" ? colors.dim(`(${keys})`) : typed}`;
|
|
1082
|
+
}
|
|
1083
|
+
function answer(colors, question, state, picked) {
|
|
1084
|
+
return state === "enter" ? `${colors.green("\u2713")} ${question} ${colors.cyan(picked)}` : `${colors.red("\u2717")} ${question} ${colors.dim("cancelled")}`;
|
|
1085
|
+
}
|
|
1086
|
+
async function ask(question, { hint, terminal = process25 }, render, press) {
|
|
1087
|
+
const { stdin, stderr } = terminal;
|
|
1088
|
+
if (!isInteractive(terminal))
|
|
1089
|
+
fail(`cannot ask "${question}" off a terminal`, 2, hint);
|
|
1090
|
+
const colors = paint(stderr);
|
|
1091
|
+
let current = "asking";
|
|
1092
|
+
let outcome;
|
|
1093
|
+
const columns = () => stderr.columns || 80;
|
|
1094
|
+
const draw = (state, last = false) => {
|
|
1095
|
+
const frame = render(colors, state, { columns: columns(), rows: stderr.rows || 24 });
|
|
1096
|
+
const rows = rowsTaken(frame, columns());
|
|
1097
|
+
stderr.write(`${SYNC_START}\r${overwrite(frame, columns())}\x1B[0J${last || rows < 2 ? "" : `\x1B[${rows - 1}A`}${last ? "" : "\r"}${SYNC_END}`);
|
|
1098
|
+
current = state;
|
|
1099
|
+
};
|
|
1100
|
+
const redraw = () => draw(current);
|
|
1101
|
+
const paste = { active: false };
|
|
1102
|
+
const stop = terminal.stop ?? (terminal === process25 ? stopJob : undefined);
|
|
1103
|
+
const suspend = () => {
|
|
1104
|
+
if (stop === undefined)
|
|
1105
|
+
return;
|
|
1106
|
+
stderr.write("\x1B[0J\x1B[?25h\x1B[?2004l");
|
|
1107
|
+
stdin.setRawMode(false);
|
|
1108
|
+
stop();
|
|
1109
|
+
stdin.setRawMode(true);
|
|
1110
|
+
stderr.write("\x1B[?25l\x1B[?2004h");
|
|
1111
|
+
};
|
|
1112
|
+
try {
|
|
1113
|
+
stderr.on?.("resize", redraw);
|
|
1114
|
+
stdin.setRawMode(true);
|
|
1115
|
+
stdin.resume();
|
|
1116
|
+
stderr.write("\x1B[?25l\x1B[?2004h");
|
|
1117
|
+
draw("asking");
|
|
1118
|
+
return await new Promise((resolve) => {
|
|
1119
|
+
function onData(data) {
|
|
1120
|
+
for (const key of readKeys(data.toString(), paste)) {
|
|
1121
|
+
if (key === "suspend") {
|
|
1122
|
+
suspend();
|
|
1123
|
+
continue;
|
|
1124
|
+
}
|
|
1125
|
+
const pressed = press(key);
|
|
1126
|
+
if (pressed !== undefined) {
|
|
1127
|
+
settle(pressed);
|
|
1128
|
+
return;
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
draw("asking");
|
|
1132
|
+
}
|
|
1133
|
+
function onEnd() {
|
|
1134
|
+
settle("cancel");
|
|
1135
|
+
}
|
|
1136
|
+
function settle(settled) {
|
|
1137
|
+
outcome = settled;
|
|
1138
|
+
stdin.off("data", onData);
|
|
1139
|
+
stdin.off("end", onEnd);
|
|
1140
|
+
resolve(settled === "enter");
|
|
1141
|
+
}
|
|
1142
|
+
stdin.on("data", onData);
|
|
1143
|
+
stdin.on("end", onEnd);
|
|
1144
|
+
});
|
|
1145
|
+
} finally {
|
|
1146
|
+
stderr.off?.("resize", redraw);
|
|
1147
|
+
draw(outcome ?? "cancel", true);
|
|
1148
|
+
stderr.write(`
|
|
1149
|
+
\x1B[?25h\x1B[?2004l`);
|
|
1150
|
+
stdin.setRawMode(false);
|
|
1151
|
+
stdin.pause();
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
var PROMPT_KEYS;
|
|
1155
|
+
var init_prompt = __esm(() => {
|
|
1156
|
+
init_answers();
|
|
1157
|
+
init_args();
|
|
1158
|
+
init_format2();
|
|
1159
|
+
init_job();
|
|
1160
|
+
init_mode();
|
|
1161
|
+
init_line();
|
|
1162
|
+
init_state();
|
|
1163
|
+
init_redraw();
|
|
1164
|
+
init_style();
|
|
1165
|
+
PROMPT_KEYS = new Set(["up", "down", "pageup", "pagedown", "home", "end", "enter", "cancel", "suspend", "tab"]);
|
|
1166
|
+
});
|
|
1167
|
+
|
|
1168
|
+
// src/cli.ts
|
|
1169
|
+
import process26 from "process";
|
|
1170
|
+
|
|
1171
|
+
// ../kit/src/advisory.ts
|
|
1172
|
+
var SEVERITIES = ["low", "moderate", "high", "critical"];
|
|
1173
|
+
function severityRank(severity) {
|
|
1174
|
+
return SEVERITIES.indexOf(severity);
|
|
1175
|
+
}
|
|
1176
|
+
function isIgnored(advisory, ignore) {
|
|
1177
|
+
return ignore.includes(advisory.ghsa ?? "") || ignore.includes(String(advisory.id));
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
// ../kit/src/index.ts
|
|
1181
|
+
init_args();
|
|
1182
|
+
|
|
831
1183
|
// ../kit/src/argv.ts
|
|
832
1184
|
import { readFileSync as readFileSync3, realpathSync } from "fs";
|
|
833
1185
|
import { resolve as resolve3 } from "path";
|
|
@@ -852,10 +1204,24 @@ function scriptArgs(argv = process10.argv.slice(2), cmdline = commandLine(), scr
|
|
|
852
1204
|
const after = at === -1 ? [] : cmdline.slice(at + 1);
|
|
853
1205
|
return after[0] === "--" && after.length === argv.length + 1 && argv.every((word, index) => word === after[index + 1]) ? after : argv;
|
|
854
1206
|
}
|
|
1207
|
+
// ../kit/src/chart.ts
|
|
1208
|
+
init_format2();
|
|
1209
|
+
init_mode();
|
|
1210
|
+
init_style();
|
|
1211
|
+
init_theme();
|
|
1212
|
+
// ../kit/src/ci.ts
|
|
1213
|
+
init_args();
|
|
1214
|
+
init_format2();
|
|
1215
|
+
|
|
1216
|
+
// ../kit/src/progress.ts
|
|
1217
|
+
init_format2();
|
|
1218
|
+
import process12 from "process";
|
|
1219
|
+
|
|
855
1220
|
// ../kit/src/process.ts
|
|
856
1221
|
import { constants } from "os";
|
|
857
1222
|
import process11 from "process";
|
|
858
1223
|
var KILL_GRACE_MS = 2000;
|
|
1224
|
+
var SIGNALS = ["SIGINT", "SIGTERM", "SIGHUP"];
|
|
859
1225
|
function exitCodeOf(code, signal) {
|
|
860
1226
|
if (code !== null)
|
|
861
1227
|
return code;
|
|
@@ -863,10 +1229,41 @@ function exitCodeOf(code, signal) {
|
|
|
863
1229
|
return 128 + signal;
|
|
864
1230
|
return signal === null ? 129 : 128 + constants.signals[signal];
|
|
865
1231
|
}
|
|
866
|
-
|
|
1232
|
+
function holdSignals(cleanup) {
|
|
1233
|
+
let received;
|
|
1234
|
+
let child;
|
|
1235
|
+
const held = {
|
|
1236
|
+
get signal() {
|
|
1237
|
+
return received;
|
|
1238
|
+
},
|
|
1239
|
+
forward: (to) => {
|
|
1240
|
+
child = to;
|
|
1241
|
+
},
|
|
1242
|
+
release: () => {
|
|
1243
|
+
for (const signal of SIGNALS)
|
|
1244
|
+
process11.off(signal, onSignal);
|
|
1245
|
+
}
|
|
1246
|
+
};
|
|
1247
|
+
function onSignal(signal) {
|
|
1248
|
+
received = signal;
|
|
1249
|
+
if (child !== undefined) {
|
|
1250
|
+
child.kill(signal);
|
|
1251
|
+
return;
|
|
1252
|
+
}
|
|
1253
|
+
if (cleanup === undefined)
|
|
1254
|
+
return;
|
|
1255
|
+
held.release();
|
|
1256
|
+
cleanup(signal);
|
|
1257
|
+
process11.kill(process11.pid, signal);
|
|
1258
|
+
}
|
|
1259
|
+
for (const signal of SIGNALS)
|
|
1260
|
+
process11.on(signal, onSignal);
|
|
1261
|
+
return held;
|
|
1262
|
+
}
|
|
1263
|
+
async function runCommand(argv, { cwd, env, stdin = "ignore", input, timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
|
|
867
1264
|
const chunks = [];
|
|
868
1265
|
const grouped = timeoutMs !== undefined || signal !== undefined || onStart !== undefined || onChunk !== undefined;
|
|
869
|
-
const proc = Bun.spawn(argv, { ...cwd === undefined ? {} : { cwd }, ...env === undefined ? {} : { env }, stdin, stdout: "pipe", stderr: "pipe", ...grouped ? { detached: true } : {} });
|
|
1266
|
+
const proc = Bun.spawn(argv, { ...cwd === undefined ? {} : { cwd }, ...env === undefined ? {} : { env }, stdin: input === undefined ? stdin : new TextEncoder().encode(input), stdout: "pipe", stderr: "pipe", ...grouped ? { detached: true } : {} });
|
|
870
1267
|
const state = { kept: 0, truncated: false, timedOut: false, failure: undefined, done: false };
|
|
871
1268
|
const timers = [];
|
|
872
1269
|
const killGroup = (killing) => {
|
|
@@ -943,16 +1340,233 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
|
|
|
943
1340
|
}
|
|
944
1341
|
|
|
945
1342
|
// ../kit/src/progress.ts
|
|
1343
|
+
init_style();
|
|
1344
|
+
init_theme();
|
|
1345
|
+
var FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
|
|
1346
|
+
var FRAME_MS = 200;
|
|
1347
|
+
var BAR_WIDTH = 20;
|
|
1348
|
+
var CLEAR_BELOW = "\r\x1B[J";
|
|
946
1349
|
var ESC = String.fromCharCode(27);
|
|
947
1350
|
var ESCAPE_CODE = new RegExp(`${ESC}(?:\\[[\\x30-\\x3F]*[\\x20-\\x2F]*[\\x40-\\x7E]|\\][^\\u0007${ESC}]*(?:\\u0007|${ESC}\\\\))`, "y");
|
|
948
1351
|
var RESET_STYLE = `${ESC}[0m`;
|
|
1352
|
+
var CTRL_C = 3;
|
|
949
1353
|
var CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
|
|
1354
|
+
var CONSOLE_METHODS = ["log", "info", "warn", "error", "debug", "dir", "dirxml", "table", "trace", "group", "groupCollapsed", "count", "timeEnd", "timeLog", "assert"];
|
|
1355
|
+
function liveRegion(render, stream = process12.stderr, env = process12.env) {
|
|
1356
|
+
if (!takesControlCodes(stream, env))
|
|
1357
|
+
return { redraw: () => {
|
|
1358
|
+
return;
|
|
1359
|
+
}, print: (text) => void stream.write(`${text}
|
|
1360
|
+
`), stop: () => {
|
|
1361
|
+
return;
|
|
1362
|
+
}, pause: () => () => {
|
|
1363
|
+
return;
|
|
1364
|
+
} };
|
|
1365
|
+
const write = stream.write.bind(stream);
|
|
1366
|
+
let frame = 0;
|
|
1367
|
+
let drawn = false;
|
|
1368
|
+
let paused = false;
|
|
1369
|
+
let stopped = false;
|
|
1370
|
+
const columns = () => {
|
|
1371
|
+
const now = stream.getWindowSize?.()[0] ?? stream.columns;
|
|
1372
|
+
return now === undefined || now === 0 ? 80 : now;
|
|
1373
|
+
};
|
|
1374
|
+
const clear = () => {
|
|
1375
|
+
if (drawn)
|
|
1376
|
+
write(CLEAR_BELOW);
|
|
1377
|
+
drawn = false;
|
|
1378
|
+
};
|
|
1379
|
+
const draw = () => {
|
|
1380
|
+
if (paused)
|
|
1381
|
+
return;
|
|
1382
|
+
const width = columns() - 1;
|
|
1383
|
+
const height = stream.rows === undefined || stream.rows === 0 ? 24 : stream.rows;
|
|
1384
|
+
const lines = render(FRAMES[frame++ % FRAMES.length]).slice(0, Math.max(1, height - 1)).map((line) => cutToWidth(line, width));
|
|
1385
|
+
if (lines.length === 0) {
|
|
1386
|
+
clear();
|
|
1387
|
+
return;
|
|
1388
|
+
}
|
|
1389
|
+
write(`${CLEAR_BELOW}${lines.join(`
|
|
1390
|
+
`)}${lines.length > 1 ? `\x1B[${lines.length - 1}A` : ""}\r`);
|
|
1391
|
+
drawn = true;
|
|
1392
|
+
};
|
|
1393
|
+
let timer = setInterval(draw, FRAME_MS);
|
|
1394
|
+
stream.on?.("resize", draw);
|
|
1395
|
+
let restore = interceptOutput(clear);
|
|
1396
|
+
let release = swallowInput();
|
|
1397
|
+
const onExit = () => {
|
|
1398
|
+
clear();
|
|
1399
|
+
release();
|
|
1400
|
+
};
|
|
1401
|
+
const signals = holdSignals(stop);
|
|
1402
|
+
function stop() {
|
|
1403
|
+
stopped = true;
|
|
1404
|
+
clearInterval(timer);
|
|
1405
|
+
stream.off?.("resize", draw);
|
|
1406
|
+
clear();
|
|
1407
|
+
restore();
|
|
1408
|
+
release();
|
|
1409
|
+
process12.off("exit", onExit);
|
|
1410
|
+
signals.release();
|
|
1411
|
+
}
|
|
1412
|
+
function pause() {
|
|
1413
|
+
if (paused || stopped)
|
|
1414
|
+
return () => {
|
|
1415
|
+
return;
|
|
1416
|
+
};
|
|
1417
|
+
paused = true;
|
|
1418
|
+
clearInterval(timer);
|
|
1419
|
+
stream.off?.("resize", draw);
|
|
1420
|
+
clear();
|
|
1421
|
+
restore();
|
|
1422
|
+
release();
|
|
1423
|
+
return () => {
|
|
1424
|
+
if (!paused || stopped)
|
|
1425
|
+
return;
|
|
1426
|
+
paused = false;
|
|
1427
|
+
timer = setInterval(draw, FRAME_MS);
|
|
1428
|
+
timer.unref();
|
|
1429
|
+
stream.on?.("resize", draw);
|
|
1430
|
+
restore = interceptOutput(clear);
|
|
1431
|
+
release = swallowInput();
|
|
1432
|
+
draw();
|
|
1433
|
+
};
|
|
1434
|
+
}
|
|
1435
|
+
timer.unref();
|
|
1436
|
+
process12.on("exit", onExit);
|
|
1437
|
+
return {
|
|
1438
|
+
redraw: draw,
|
|
1439
|
+
print: (text) => {
|
|
1440
|
+
clear();
|
|
1441
|
+
write(`${text}
|
|
1442
|
+
`);
|
|
1443
|
+
draw();
|
|
1444
|
+
},
|
|
1445
|
+
stop,
|
|
1446
|
+
pause
|
|
1447
|
+
};
|
|
1448
|
+
}
|
|
1449
|
+
function progressLine(stream = process12.stderr, env = process12.env) {
|
|
1450
|
+
const colors = paint(stream, env);
|
|
1451
|
+
const write = stream.write.bind(stream);
|
|
1452
|
+
const begun = performance.now();
|
|
1453
|
+
let started = begun;
|
|
1454
|
+
let current;
|
|
1455
|
+
const region = liveRegion((spinner) => current === undefined ? [] : [tintedParts(progressParts(current, spinner, performance.now() - started), colors)], stream, env);
|
|
1456
|
+
const end = (line) => {
|
|
1457
|
+
region.stop();
|
|
1458
|
+
write(`${line}
|
|
1459
|
+
`);
|
|
1460
|
+
};
|
|
1461
|
+
return {
|
|
1462
|
+
update: (progress) => {
|
|
1463
|
+
const step = current?.step;
|
|
1464
|
+
current = progress;
|
|
1465
|
+
if (progress.step !== step) {
|
|
1466
|
+
started = performance.now();
|
|
1467
|
+
region.redraw();
|
|
1468
|
+
}
|
|
1469
|
+
},
|
|
1470
|
+
stop: region.stop,
|
|
1471
|
+
pause: region.pause,
|
|
1472
|
+
done: (text) => end(marked("ok", text, stream, formatDuration(performance.now() - begun), env)),
|
|
1473
|
+
failed: (text) => end(marked("problem", text, stream, undefined, env))
|
|
1474
|
+
};
|
|
1475
|
+
}
|
|
1476
|
+
function progressParts({ step, done, total, unit }, spinner, ms) {
|
|
1477
|
+
const { theme } = activeTheme();
|
|
1478
|
+
const parts = [{ text: spinner, tint: (colors) => tinted(colors, theme.colors.accent) }, { text: ` ${step}`, tint: () => plain }];
|
|
1479
|
+
if (total !== undefined && total > 0) {
|
|
1480
|
+
const counted = Math.min(done ?? 0, total);
|
|
1481
|
+
const filled = Math.round(counted / total * BAR_WIDTH);
|
|
1482
|
+
parts.push({ text: " ", tint: () => plain }, { text: theme.glyphs.bar.repeat(filled), tint: (colors) => () => shaded(theme, colors, theme.glyphs.bar, filled, BAR_WIDTH) }, { text: theme.glyphs.bar.repeat(BAR_WIDTH - filled), tint: (colors) => colors.dim }, { text: ` ${counted}/${total}${unit === undefined ? "" : ` ${unit}`}`, tint: (colors) => colors.dim });
|
|
1483
|
+
}
|
|
1484
|
+
parts.push({ text: ` ${formatElapsed(ms)}`, tint: (colors) => colors.dim });
|
|
1485
|
+
return parts;
|
|
1486
|
+
}
|
|
1487
|
+
function plain(text) {
|
|
1488
|
+
return text;
|
|
1489
|
+
}
|
|
1490
|
+
function tintedParts(parts, colors) {
|
|
1491
|
+
return parts.map(({ text, tint }) => tint(colors)(text)).join("");
|
|
1492
|
+
}
|
|
1493
|
+
function cutToWidth(line, width) {
|
|
1494
|
+
if (Bun.stringWidth(line) <= width)
|
|
1495
|
+
return line;
|
|
1496
|
+
let room = width;
|
|
1497
|
+
let kept = "";
|
|
1498
|
+
let index = 0;
|
|
1499
|
+
let linked = false;
|
|
1500
|
+
while (index < line.length) {
|
|
1501
|
+
ESCAPE_CODE.lastIndex = index;
|
|
1502
|
+
const escape = ESCAPE_CODE.exec(line);
|
|
1503
|
+
if (escape !== null) {
|
|
1504
|
+
kept += escape[0];
|
|
1505
|
+
linked ||= escape[0].startsWith(`${ESC}]`);
|
|
1506
|
+
index = ESCAPE_CODE.lastIndex;
|
|
1507
|
+
continue;
|
|
1508
|
+
}
|
|
1509
|
+
const char = String.fromCodePoint(line.codePointAt(index));
|
|
1510
|
+
const columns = Bun.stringWidth(char);
|
|
1511
|
+
if (columns > room)
|
|
1512
|
+
break;
|
|
1513
|
+
kept += char;
|
|
1514
|
+
room -= columns;
|
|
1515
|
+
index += char.length;
|
|
1516
|
+
}
|
|
1517
|
+
return `${kept}${RESET_STYLE}${linked ? CLOSE_LINK : ""}`;
|
|
1518
|
+
}
|
|
1519
|
+
function swallowInput() {
|
|
1520
|
+
const input = process12.stdin;
|
|
1521
|
+
if (!input.isTTY)
|
|
1522
|
+
return () => {
|
|
1523
|
+
return;
|
|
1524
|
+
};
|
|
1525
|
+
const onData = (data) => {
|
|
1526
|
+
if (data.includes(CTRL_C))
|
|
1527
|
+
process12.kill(process12.pid, "SIGINT");
|
|
1528
|
+
};
|
|
1529
|
+
input.setRawMode(true);
|
|
1530
|
+
input.on("data", onData);
|
|
1531
|
+
input.resume();
|
|
1532
|
+
let released = false;
|
|
1533
|
+
return () => {
|
|
1534
|
+
if (released)
|
|
1535
|
+
return;
|
|
1536
|
+
released = true;
|
|
1537
|
+
input.off("data", onData);
|
|
1538
|
+
input.pause();
|
|
1539
|
+
input.setRawMode(false);
|
|
1540
|
+
};
|
|
1541
|
+
}
|
|
1542
|
+
function interceptOutput(clear) {
|
|
1543
|
+
const targets = [...CONSOLE_METHODS.map((name) => [console, name]), [process12.stdout, "write"], [process12.stderr, "write"]];
|
|
1544
|
+
const wrapped = targets.map(([target, name]) => {
|
|
1545
|
+
const original = Reflect.get(target, name);
|
|
1546
|
+
const wrapper = (...args) => {
|
|
1547
|
+
clear();
|
|
1548
|
+
return original.apply(target, args);
|
|
1549
|
+
};
|
|
1550
|
+
Reflect.set(target, name, wrapper);
|
|
1551
|
+
return { target, name, original, wrapper };
|
|
1552
|
+
});
|
|
1553
|
+
return () => {
|
|
1554
|
+
for (const { target, name, original, wrapper } of wrapped) {
|
|
1555
|
+
if (Reflect.get(target, name) === wrapper)
|
|
1556
|
+
Reflect.set(target, name, original);
|
|
1557
|
+
}
|
|
1558
|
+
};
|
|
1559
|
+
}
|
|
1560
|
+
|
|
1561
|
+
// ../kit/src/ci.ts
|
|
1562
|
+
init_style();
|
|
950
1563
|
|
|
951
1564
|
// ../kit/src/tool.ts
|
|
952
|
-
|
|
1565
|
+
init_format2();
|
|
1566
|
+
import process13 from "process";
|
|
953
1567
|
function cwdGone() {
|
|
954
1568
|
try {
|
|
955
|
-
|
|
1569
|
+
process13.cwd();
|
|
956
1570
|
return false;
|
|
957
1571
|
} catch {
|
|
958
1572
|
return true;
|
|
@@ -971,10 +1585,10 @@ function spawnFailure(command, error) {
|
|
|
971
1585
|
const missing = !gone && error?.code === "ENOENT";
|
|
972
1586
|
return new SpawnError(`${command}: ${error instanceof Error ? error.message : String(error)}${gone ? " (the working directory was removed)" : ""}`, missing);
|
|
973
1587
|
}
|
|
974
|
-
async function runTool(label, argv, { timeoutMs, cwd, onStart } = {}) {
|
|
1588
|
+
async function runTool(label, argv, { timeoutMs, cwd, onStart, env } = {}) {
|
|
975
1589
|
let ran;
|
|
976
1590
|
try {
|
|
977
|
-
ran = await runCommand(argv, { env:
|
|
1591
|
+
ran = await runCommand(argv, { env: { ...process13.env, ...env }, ...timeoutMs === undefined ? {} : { timeoutMs }, ...cwd === undefined ? {} : { cwd }, ...onStart === undefined ? {} : { onStart } });
|
|
978
1592
|
} catch (error) {
|
|
979
1593
|
throw spawnFailure(label, error);
|
|
980
1594
|
}
|
|
@@ -989,9 +1603,49 @@ async function runTool(label, argv, { timeoutMs, cwd, onStart } = {}) {
|
|
|
989
1603
|
return { code: ran.code, ...streams };
|
|
990
1604
|
}
|
|
991
1605
|
// ../kit/src/cli.ts
|
|
1606
|
+
init_args();
|
|
992
1607
|
import { readFileSync as readFileSync4, realpathSync as realpathSync2 } from "fs";
|
|
993
1608
|
import { dirname as dirname3, join as join5 } from "path";
|
|
994
|
-
import
|
|
1609
|
+
import process17 from "process";
|
|
1610
|
+
|
|
1611
|
+
// ../kit/src/askpass.ts
|
|
1612
|
+
import process14 from "process";
|
|
1613
|
+
var SOCKET_VARIABLE = "KAYNOOO_ASKPASS_SOCKET";
|
|
1614
|
+
async function askpassClient(argv) {
|
|
1615
|
+
const socketPath = process14.env[SOCKET_VARIABLE];
|
|
1616
|
+
if (socketPath === undefined)
|
|
1617
|
+
return;
|
|
1618
|
+
const request = { prompt: argv[0] ?? "", ...process14.env.SSH_ASKPASS_PROMPT === "none" ? { notice: true } : {} };
|
|
1619
|
+
const { promise, resolve } = Promise.withResolvers();
|
|
1620
|
+
let received = "";
|
|
1621
|
+
try {
|
|
1622
|
+
await Bun.connect({
|
|
1623
|
+
unix: socketPath,
|
|
1624
|
+
socket: {
|
|
1625
|
+
open: (socket) => void socket.write(`${JSON.stringify(request)}
|
|
1626
|
+
`),
|
|
1627
|
+
data: (_, chunk) => {
|
|
1628
|
+
received += chunk.toString();
|
|
1629
|
+
},
|
|
1630
|
+
close: () => resolve(received),
|
|
1631
|
+
error: () => resolve("")
|
|
1632
|
+
}
|
|
1633
|
+
});
|
|
1634
|
+
} catch {
|
|
1635
|
+
return 1;
|
|
1636
|
+
}
|
|
1637
|
+
const reply = await promise;
|
|
1638
|
+
if (reply === "")
|
|
1639
|
+
return 1;
|
|
1640
|
+
const { answer } = JSON.parse(reply);
|
|
1641
|
+
if (request.notice === true)
|
|
1642
|
+
return 0;
|
|
1643
|
+
if (answer === undefined)
|
|
1644
|
+
return 1;
|
|
1645
|
+
process14.stdout.write(`${answer}
|
|
1646
|
+
`);
|
|
1647
|
+
return 0;
|
|
1648
|
+
}
|
|
995
1649
|
|
|
996
1650
|
// ../kit/src/completions.ts
|
|
997
1651
|
var COMPLETION_SHELLS = ["fish", "bash", "zsh"];
|
|
@@ -1054,28 +1708,34 @@ compdef __kaynooo_cli_complete ${bins.join(" ")}
|
|
|
1054
1708
|
}
|
|
1055
1709
|
|
|
1056
1710
|
// ../kit/src/notify.ts
|
|
1057
|
-
|
|
1711
|
+
init_format2();
|
|
1712
|
+
init_mode();
|
|
1713
|
+
import process15 from "process";
|
|
1058
1714
|
var NOTIFY_AFTER_MS = 1e4;
|
|
1059
1715
|
var CANCELLED = 130;
|
|
1060
1716
|
function base64(text) {
|
|
1061
1717
|
return Buffer.from(text).toString("base64");
|
|
1062
1718
|
}
|
|
1063
|
-
function notification(title, body, env =
|
|
1064
|
-
const id = `kit${
|
|
1719
|
+
function notification(title, body, env = process15.env) {
|
|
1720
|
+
const id = `kit${process15.pid}`;
|
|
1065
1721
|
const codes = [`\x1B]99;i=${id}:d=0:o=unfocused:e=1;${base64(title)}\x1B\\`, `\x1B]99;i=${id}:p=body:e=1;${base64(body)}\x1B\\`];
|
|
1066
1722
|
return codes.map((code) => env.TMUX === undefined || env.TMUX === "" ? code : `\x1BPtmux;${code.replaceAll("\x1B", "\x1B\x1B")}\x1B\\`).join("");
|
|
1067
1723
|
}
|
|
1068
|
-
function notifyEnd(command, code, ms, { stream =
|
|
1724
|
+
function notifyEnd(command, code, ms, { stream = process15.stderr, env = process15.env } = {}) {
|
|
1069
1725
|
if (ms < NOTIFY_AFTER_MS || code === CANCELLED || outputMode(stream, env) !== "terminal")
|
|
1070
1726
|
return;
|
|
1071
1727
|
stream.write(notification(command, code === 0 ? `done in ${formatDuration(ms)}` : `failed with exit ${code} after ${formatDuration(ms)}`, env));
|
|
1072
1728
|
}
|
|
1073
1729
|
|
|
1730
|
+
// ../kit/src/cli.ts
|
|
1731
|
+
init_style();
|
|
1732
|
+
init_text2();
|
|
1733
|
+
|
|
1074
1734
|
// ../kit/src/usage.ts
|
|
1075
1735
|
import { appendFileSync, mkdirSync } from "fs";
|
|
1076
1736
|
import { homedir as homedir3 } from "os";
|
|
1077
1737
|
import { dirname as dirname2, isAbsolute, join as join4 } from "path";
|
|
1078
|
-
import
|
|
1738
|
+
import process16 from "process";
|
|
1079
1739
|
|
|
1080
1740
|
// ../kit/src/logs.ts
|
|
1081
1741
|
var DAY_MS = 24 * 60 * 60 * 1000;
|
|
@@ -1089,14 +1749,14 @@ var usageError;
|
|
|
1089
1749
|
function noteUsageError(message) {
|
|
1090
1750
|
usageError = message;
|
|
1091
1751
|
}
|
|
1092
|
-
function stateHome(env =
|
|
1752
|
+
function stateHome(env = process16.env) {
|
|
1093
1753
|
const dir = env.XDG_STATE_HOME;
|
|
1094
1754
|
return dir !== undefined && isAbsolute(dir) ? dir : join4(homedir3(), ".local", "state");
|
|
1095
1755
|
}
|
|
1096
|
-
function usagePath(env =
|
|
1756
|
+
function usagePath(env = process16.env) {
|
|
1097
1757
|
return join4(stateHome(env), CLI_FOLDER, "usage.jsonl");
|
|
1098
1758
|
}
|
|
1099
|
-
function usageRecorded(env =
|
|
1759
|
+
function usageRecorded(env = process16.env) {
|
|
1100
1760
|
const off = env.KAYNOOO_CLI_NO_USAGE;
|
|
1101
1761
|
return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
|
|
1102
1762
|
}
|
|
@@ -1105,12 +1765,12 @@ function flagNames(argv) {
|
|
|
1105
1765
|
const names = (end === -1 ? argv : argv.slice(0, end)).filter((word) => word.startsWith("-") && word !== "-").map((word) => word.includes("=") ? word.slice(0, word.indexOf("=")) : word);
|
|
1106
1766
|
return [...new Set(names)].filter((name) => name.length <= LONGEST_NAME && FLAG_NAME.test(name));
|
|
1107
1767
|
}
|
|
1108
|
-
function usageEntry(bin, command, argv, code, now = new Date) {
|
|
1768
|
+
function usageEntry(bin, command, argv, code, { ms, now = new Date } = {}) {
|
|
1109
1769
|
const unknown = code === 2 && usageError !== undefined ? UNKNOWN_OPTION2.exec(usageError)?.[1] : undefined;
|
|
1110
1770
|
usageError = undefined;
|
|
1111
|
-
return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
|
|
1771
|
+
return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown }, ...ms === undefined ? {} : { ms: Math.round(ms) } };
|
|
1112
1772
|
}
|
|
1113
|
-
function recordUsage(entry, env =
|
|
1773
|
+
function recordUsage(entry, env = process16.env) {
|
|
1114
1774
|
if (!usageRecorded(env))
|
|
1115
1775
|
return;
|
|
1116
1776
|
try {
|
|
@@ -1204,8 +1864,8 @@ async function help2({ path, header, summary: lazySummary, commands, defaultComm
|
|
|
1204
1864
|
`);
|
|
1205
1865
|
}
|
|
1206
1866
|
function printError(prefix, message, hint, cause) {
|
|
1207
|
-
const colors = paint(
|
|
1208
|
-
const styled = takesControlCodes(
|
|
1867
|
+
const colors = paint(process17.stderr);
|
|
1868
|
+
const styled = takesControlCodes(process17.stderr);
|
|
1209
1869
|
const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
|
|
1210
1870
|
const under = (label, text, tint) => text === undefined ? "" : `
|
|
1211
1871
|
${styled ? tint(label) : `${label}:`} ${text}`;
|
|
@@ -1248,11 +1908,11 @@ async function dispatch(level, typed, { version, redact }) {
|
|
|
1248
1908
|
}
|
|
1249
1909
|
}
|
|
1250
1910
|
if (name === undefined && level.path.length > 1) {
|
|
1251
|
-
console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]),
|
|
1911
|
+
console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]), process17.stderr));
|
|
1252
1912
|
return 2;
|
|
1253
1913
|
}
|
|
1254
1914
|
if (name === undefined || name === "help" || name === "--help" || name === "-h") {
|
|
1255
|
-
console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]),
|
|
1915
|
+
console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]), process17.stdout));
|
|
1256
1916
|
return 0;
|
|
1257
1917
|
}
|
|
1258
1918
|
if (level.path.length === 1 && (name === "--version" || name === "-v")) {
|
|
@@ -1398,6 +2058,9 @@ function packageVersion(entry = Bun.main) {
|
|
|
1398
2058
|
}
|
|
1399
2059
|
async function runCli(cli, argv = scriptArgs()) {
|
|
1400
2060
|
const version = cli.version ?? packageVersion();
|
|
2061
|
+
const answered = await askpassClient(argv);
|
|
2062
|
+
if (answered !== undefined)
|
|
2063
|
+
return answered;
|
|
1401
2064
|
if (argv[0] === COMPLETE)
|
|
1402
2065
|
return printCandidates(candidates(scopeOf(cli.commands, cli.extraCommands, cli.aliases), cli.defaultCommand, argv.slice(1)));
|
|
1403
2066
|
if (argv[0] === COMPLETIONS || argv[0]?.startsWith(`${COMPLETIONS}=`) === true)
|
|
@@ -1408,7 +2071,7 @@ async function runCli(cli, argv = scriptArgs()) {
|
|
|
1408
2071
|
notifyEnd(command === undefined ? cli.name : `${cli.name} ${command}`, code, performance.now() - started);
|
|
1409
2072
|
if (cli.usage !== false) {
|
|
1410
2073
|
try {
|
|
1411
|
-
recordUsage(usageEntry(cli.name, command, argv, code));
|
|
2074
|
+
recordUsage(usageEntry(cli.name, command, argv, code, { ms: performance.now() - started }));
|
|
1412
2075
|
} catch {}
|
|
1413
2076
|
}
|
|
1414
2077
|
return code;
|
|
@@ -1428,45 +2091,43 @@ function commandPath(scope, argv) {
|
|
|
1428
2091
|
}
|
|
1429
2092
|
return path.length === 0 ? undefined : path.join(" ");
|
|
1430
2093
|
}
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
recordUsage(usageEntry(name, undefined, argv, code));
|
|
1451
|
-
} catch {}
|
|
1452
|
-
}
|
|
1453
|
-
return code;
|
|
1454
|
-
}
|
|
1455
|
-
// ../kit/src/folders.ts
|
|
1456
|
-
var SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
|
|
2094
|
+
|
|
2095
|
+
// ../kit/src/index.ts
|
|
2096
|
+
init_config();
|
|
2097
|
+
|
|
2098
|
+
// ../kit/src/excerpt.ts
|
|
2099
|
+
init_text2();
|
|
2100
|
+
|
|
2101
|
+
// ../kit/src/index.ts
|
|
2102
|
+
init_folders();
|
|
2103
|
+
init_format2();
|
|
2104
|
+
|
|
2105
|
+
// ../kit/src/git.ts
|
|
2106
|
+
init_args();
|
|
2107
|
+
// ../kit/src/limit.ts
|
|
2108
|
+
init_args();
|
|
2109
|
+
|
|
2110
|
+
// ../kit/src/index.ts
|
|
2111
|
+
init_mode();
|
|
2112
|
+
|
|
1457
2113
|
// ../kit/src/pool.ts
|
|
1458
|
-
async function pool(items, limit, task) {
|
|
2114
|
+
async function pool(items, limit, task, onDone) {
|
|
1459
2115
|
const results = Array.from({ length: items.length });
|
|
1460
2116
|
let next = 0;
|
|
2117
|
+
let done = 0;
|
|
1461
2118
|
async function worker() {
|
|
1462
2119
|
while (next < items.length) {
|
|
1463
2120
|
const index = next++;
|
|
1464
2121
|
results[index] = await task(items[index]);
|
|
2122
|
+
onDone?.(++done, items.length);
|
|
1465
2123
|
}
|
|
1466
2124
|
}
|
|
1467
2125
|
await Promise.all(Array.from({ length: Math.min(limit, items.length) }, worker));
|
|
1468
2126
|
return results;
|
|
1469
2127
|
}
|
|
2128
|
+
// ../kit/src/report.ts
|
|
2129
|
+
init_style();
|
|
2130
|
+
init_text2();
|
|
1470
2131
|
// ../kit/src/secrets.ts
|
|
1471
2132
|
var SECRET_WORDS = new Set(["key", "pass", "pwd", "auth", "salt", "cookie", "session", "jwt", "ssn", "iban", "card", "cvv", "otp"]);
|
|
1472
2133
|
// ../kit/src/sessions.ts
|
|
@@ -1483,8 +2144,18 @@ function parseSize(text, bareUnit = 1) {
|
|
|
1483
2144
|
const suffix = match[2].toLowerCase();
|
|
1484
2145
|
return Math.round(Number(match[1]) * (suffix === "" ? bareUnit : 1024 ** POWERS[suffix]));
|
|
1485
2146
|
}
|
|
2147
|
+
|
|
2148
|
+
// ../kit/src/index.ts
|
|
2149
|
+
init_style();
|
|
2150
|
+
init_text2();
|
|
2151
|
+
init_theme();
|
|
2152
|
+
init_user_config();
|
|
2153
|
+
|
|
1486
2154
|
// ../kit/src/watch.ts
|
|
1487
|
-
|
|
2155
|
+
init_args();
|
|
2156
|
+
init_input();
|
|
2157
|
+
init_style();
|
|
2158
|
+
import process18 from "process";
|
|
1488
2159
|
import { format } from "util";
|
|
1489
2160
|
var CLEAR_SCREEN = "\x1B[H\x1B[2J";
|
|
1490
2161
|
var DEFAULT_SECONDS = 2;
|
|
@@ -1506,7 +2177,7 @@ function withoutWatch(args) {
|
|
|
1506
2177
|
}
|
|
1507
2178
|
return rest;
|
|
1508
2179
|
}
|
|
1509
|
-
async function watching(value, step, stream =
|
|
2180
|
+
async function watching(value, step, stream = process18.stdout, sleep = Bun.sleep, rounds = Number.POSITIVE_INFINITY) {
|
|
1510
2181
|
const interval = value === "" ? DEFAULT_SECONDS * 1000 : duration(value, "watch", DEFAULT_SECONDS * 1000);
|
|
1511
2182
|
if (!takesControlCodes(stream))
|
|
1512
2183
|
badUsage("--watch redraws the screen, so it needs a terminal");
|
|
@@ -1514,12 +2185,12 @@ async function watching(value, step, stream = process16.stdout, sleep = Bun.slee
|
|
|
1514
2185
|
for (let round = 0;round < rounds; round++) {
|
|
1515
2186
|
const held = [];
|
|
1516
2187
|
const { log, info } = console;
|
|
1517
|
-
const write =
|
|
2188
|
+
const write = process18.stdout.write.bind(process18.stdout);
|
|
1518
2189
|
const hold = (...parts) => void held.push(`${format(...parts)}
|
|
1519
2190
|
`);
|
|
1520
2191
|
console.log = hold;
|
|
1521
2192
|
console.info = hold;
|
|
1522
|
-
|
|
2193
|
+
process18.stdout.write = (text) => {
|
|
1523
2194
|
held.push(typeof text === "string" ? text : Buffer.from(text).toString());
|
|
1524
2195
|
return true;
|
|
1525
2196
|
};
|
|
@@ -1528,7 +2199,7 @@ async function watching(value, step, stream = process16.stdout, sleep = Bun.slee
|
|
|
1528
2199
|
} finally {
|
|
1529
2200
|
console.log = log;
|
|
1530
2201
|
console.info = info;
|
|
1531
|
-
|
|
2202
|
+
process18.stdout.write = write;
|
|
1532
2203
|
}
|
|
1533
2204
|
stream.write(`${CLEAR_SCREEN}${held.join("")}`);
|
|
1534
2205
|
await sleep(interval);
|
|
@@ -1536,9 +2207,10 @@ async function watching(value, step, stream = process16.stdout, sleep = Bun.slee
|
|
|
1536
2207
|
return code;
|
|
1537
2208
|
}
|
|
1538
2209
|
// ../kit/src/workspace-root.ts
|
|
2210
|
+
init_user_config();
|
|
1539
2211
|
import { homedir as homedir4 } from "os";
|
|
1540
2212
|
import { dirname as dirname4, join as join6, resolve as resolve4 } from "path";
|
|
1541
|
-
import
|
|
2213
|
+
import process19 from "process";
|
|
1542
2214
|
function expandHome(path, home) {
|
|
1543
2215
|
if (path === "~")
|
|
1544
2216
|
return home;
|
|
@@ -1548,7 +2220,7 @@ function configured(env, home) {
|
|
|
1548
2220
|
const folder = readUserConfig("config", { home, xdg: env.XDG_CONFIG_HOME }).workspace;
|
|
1549
2221
|
return typeof folder === "string" && folder !== "" ? folder : undefined;
|
|
1550
2222
|
}
|
|
1551
|
-
function workspaceRoot({ given, env =
|
|
2223
|
+
function workspaceRoot({ given, env = process19.env, home = homedir4() } = {}) {
|
|
1552
2224
|
const fromEnv = env.KAYNOOO_WORKSPACE === "" ? undefined : env.KAYNOOO_WORKSPACE;
|
|
1553
2225
|
return resolve4(expandHome(given ?? fromEnv ?? configured(env, home) ?? join6(home, "Workspace"), home));
|
|
1554
2226
|
}
|
|
@@ -1556,7 +2228,7 @@ function workspaceRoot({ given, env = process17.env, home = homedir4() } = {}) {
|
|
|
1556
2228
|
import { existsSync as existsSync6, readdirSync, readFileSync as readFileSync7, statSync as statSync2 } from "fs";
|
|
1557
2229
|
import { readdir } from "fs/promises";
|
|
1558
2230
|
import { join as join9, relative, resolve as resolve5 } from "path";
|
|
1559
|
-
import
|
|
2231
|
+
import process21 from "process";
|
|
1560
2232
|
|
|
1561
2233
|
// src/osv.ts
|
|
1562
2234
|
import { existsSync as existsSync5, readFileSync as readFileSync6 } from "fs";
|
|
@@ -1785,7 +2457,7 @@ async function osvAudit(dir, level, ignore, fetcher = fetch) {
|
|
|
1785
2457
|
}
|
|
1786
2458
|
|
|
1787
2459
|
// src/audit.ts
|
|
1788
|
-
var USAGE = `audit [options] [root]: the known vulnerabilities of the Bun, Composer, Cargo and uv repositories under root (the current folder by default), one table per repository
|
|
2460
|
+
var USAGE = `ws audit [options] [root]: the known vulnerabilities of the Bun, Composer, Cargo and uv repositories under root (the current folder by default), one table per repository
|
|
1789
2461
|
|
|
1790
2462
|
Each package with an advisory is one row: its worst severity, how many advisories, whether a production dependency needs it (prod) or only a development one (dev), whether the repository asks for it itself (direct) or a dependency does (the row then says via and the direct dependencies leading to it, upgrading one of which is what fixes it), and the version that fixes every advisory at once, "-" when an advisory names none. The worst and the production ones come first.
|
|
1791
2463
|
Advisories under --level (moderate by default) are counted under the table, and what \`bun audit\` warned about, such as a private registry that would not audit its packages, is repeated there. It runs \`bun audit --json\` in each repository holding a bun.lock, which reaches the registry, and asks osv.dev about the packages of a composer.lock, Cargo.lock or uv.lock (a severity the source leaves out reads as moderate, and only composer's manifest tells direct from pulled in); the walk goes three levels deep, stops at a lockfile and skips node_modules and hidden folders.
|
|
@@ -1893,7 +2565,7 @@ function failure(ran) {
|
|
|
1893
2565
|
`).at(-1) ?? `exit ${ran.code}`;
|
|
1894
2566
|
}
|
|
1895
2567
|
function tint(severity) {
|
|
1896
|
-
const colors = paint(
|
|
2568
|
+
const colors = paint(process21.stdout);
|
|
1897
2569
|
if (severity === "critical" || severity === "high")
|
|
1898
2570
|
return colors.red;
|
|
1899
2571
|
return severity === "moderate" ? colors.yellow : colors.dim;
|
|
@@ -1909,15 +2581,23 @@ function rows(findings) {
|
|
|
1909
2581
|
]);
|
|
1910
2582
|
}
|
|
1911
2583
|
async function audit(args) {
|
|
1912
|
-
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"] });
|
|
2584
|
+
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: ["ws audit", "ws audit ~/Workspace --level high --prod"] });
|
|
1913
2585
|
const root = resolve5(positionals[0] ?? ".");
|
|
1914
2586
|
if (!existsSync6(root) || !statSync2(root).isDirectory())
|
|
1915
2587
|
fail(`no folder ${root}`);
|
|
1916
2588
|
const level = oneOf(values.level, "level", SEVERITIES);
|
|
1917
|
-
const
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
2589
|
+
const progress = progressLine();
|
|
2590
|
+
let audits;
|
|
2591
|
+
try {
|
|
2592
|
+
progress.update({ step: "finding the repositories" });
|
|
2593
|
+
const paths = await findRepos(root);
|
|
2594
|
+
if (paths.length === 0)
|
|
2595
|
+
fail(`no bun.lock, composer.lock, Cargo.lock or uv.lock under ${root}`);
|
|
2596
|
+
progress.update({ step: "auditing", done: 0, total: paths.length, unit: "repositories" });
|
|
2597
|
+
audits = await pool(paths, configuredNumber("audit", "concurrency", CONCURRENCY), async (path) => audited(path, relative(root, path) || ".", level, values.ignore ?? []), (done, total) => progress.update({ step: "auditing", done, total, unit: "repositories" }));
|
|
2598
|
+
} finally {
|
|
2599
|
+
progress.stop();
|
|
2600
|
+
}
|
|
1921
2601
|
const kept = audits.map((each) => ({ ...each, findings: values.prod === true ? each.findings.filter((found) => found.scope === "prod") : each.findings }));
|
|
1922
2602
|
if (values.json === true)
|
|
1923
2603
|
printJson(kept);
|
|
@@ -1928,8 +2608,8 @@ async function audit(args) {
|
|
|
1928
2608
|
return kept.some((each) => each.findings.length > 0) ? 1 : 0;
|
|
1929
2609
|
}
|
|
1930
2610
|
function show(audits, total) {
|
|
1931
|
-
const label = role("label",
|
|
1932
|
-
const path = role("path",
|
|
2611
|
+
const label = role("label", process21.stdout);
|
|
2612
|
+
const path = role("path", process21.stdout);
|
|
1933
2613
|
const flagged = audits.filter((each) => each.error !== undefined || each.findings.length > 0);
|
|
1934
2614
|
if (flagged.length === 0) {
|
|
1935
2615
|
console.log(label(`no advisory in ${total} ${total === 1 ? "repository" : "repositories"}`));
|
|
@@ -1951,13 +2631,13 @@ function show(audits, total) {
|
|
|
1951
2631
|
// src/repos.ts
|
|
1952
2632
|
import { existsSync as existsSync8, statSync as statSync3 } from "fs";
|
|
1953
2633
|
import { basename as basename2, relative as relative2 } from "path";
|
|
1954
|
-
import
|
|
2634
|
+
import process23 from "process";
|
|
1955
2635
|
|
|
1956
2636
|
// src/repos-scan.ts
|
|
1957
2637
|
import { existsSync as existsSync7 } from "fs";
|
|
1958
2638
|
import { readdir as readdir2 } from "fs/promises";
|
|
1959
2639
|
import { basename, join as join10 } from "path";
|
|
1960
|
-
import
|
|
2640
|
+
import process22 from "process";
|
|
1961
2641
|
var MAX_DEPTH2 = 3;
|
|
1962
2642
|
var CONCURRENCY2 = 8;
|
|
1963
2643
|
var PACKAGE_CONCURRENCY = 4;
|
|
@@ -2004,7 +2684,7 @@ async function findRepos2(root, skip) {
|
|
|
2004
2684
|
}
|
|
2005
2685
|
async function read(path, args, timeoutMs = GIT_MS) {
|
|
2006
2686
|
try {
|
|
2007
|
-
const ran = await runCommand(["git", "--no-optional-locks", ...args], { cwd: path, env: { ...
|
|
2687
|
+
const ran = await runCommand(["git", "--no-optional-locks", ...args], { cwd: path, env: { ...process22.env, GIT_TERMINAL_PROMPT: "0" }, timeoutMs });
|
|
2008
2688
|
return ran.code === 0 && !ran.timedOut ? ran.text.trim() : undefined;
|
|
2009
2689
|
} catch {
|
|
2010
2690
|
return;
|
|
@@ -2081,7 +2761,7 @@ function firstLine(text) {
|
|
|
2081
2761
|
}
|
|
2082
2762
|
async function fastForward(path) {
|
|
2083
2763
|
try {
|
|
2084
|
-
const ran = await runCommand(["git", "--no-optional-locks", "merge", "--ff-only", "--quiet", "@{upstream}"], { cwd: path, env: { ...
|
|
2764
|
+
const ran = await runCommand(["git", "--no-optional-locks", "merge", "--ff-only", "--quiet", "@{upstream}"], { cwd: path, env: { ...process22.env, GIT_TERMINAL_PROMPT: "0" }, timeoutMs: GIT_MS });
|
|
2085
2765
|
if (ran.timedOut)
|
|
2086
2766
|
return "timed out";
|
|
2087
2767
|
return ran.code === 0 ? undefined : firstLine(ran.text.trim()) || `exit ${ran.code}`;
|
|
@@ -2091,7 +2771,7 @@ async function fastForward(path) {
|
|
|
2091
2771
|
}
|
|
2092
2772
|
|
|
2093
2773
|
// src/repos.ts
|
|
2094
|
-
var USAGE2 = `repos [options] [root]: the git repositories under root (the configured workspace, ~/Workspace by default) that need attention, with their branch, dirty files, ahead/behind their upstream, linked worktrees and commits since their latest tag
|
|
2774
|
+
var USAGE2 = `ws repos [options] [root]: the git repositories under root (the configured workspace, ~/Workspace by default) that need attention, with their branch, dirty files, ahead/behind their upstream, linked worktrees and commits since their latest tag
|
|
2095
2775
|
|
|
2096
2776
|
A repository with nothing to report is left out unless --all. A monorepo tagging its packages <folder>-v<version> counts the unreleased commits per package folder. The walk goes ${MAX_DEPTH2} levels deep, stops at a .git and skips node_modules, hidden folders and the names in "skip" of ~/.config/kaynooo-cli/repos.json.
|
|
2097
2777
|
|
|
@@ -2124,7 +2804,7 @@ function releasedCell(repo) {
|
|
|
2124
2804
|
return repo.packages.filter((release) => release.unreleased > 0).map((release) => `${release.name} ${release.unreleased}`).join(", ") || "-";
|
|
2125
2805
|
return repo.tag === null || repo.unreleased === 0 ? "-" : `${repo.unreleased} since ${repo.tag}`;
|
|
2126
2806
|
}
|
|
2127
|
-
function syncCell(repo, stream =
|
|
2807
|
+
function syncCell(repo, stream = process23.stdout) {
|
|
2128
2808
|
const colors = paint(stream);
|
|
2129
2809
|
const ahead = repo.ahead ?? 0;
|
|
2130
2810
|
const behind = repo.behind ?? 0;
|
|
@@ -2135,7 +2815,7 @@ function syncCell(repo, stream = process21.stdout) {
|
|
|
2135
2815
|
return parts.length === 0 ? colors.dim("-") : `${parts.join(" ")}${diverged ? colors.yellow(" diverged") : ""}`;
|
|
2136
2816
|
}
|
|
2137
2817
|
var DEFAULT_BRANCHES = new Set(["main", "master"]);
|
|
2138
|
-
function branchCell(repo, stream =
|
|
2818
|
+
function branchCell(repo, stream = process23.stdout) {
|
|
2139
2819
|
const colors = paint(stream);
|
|
2140
2820
|
if (repo.unreadable)
|
|
2141
2821
|
return colors.red("? (unreadable)");
|
|
@@ -2144,8 +2824,8 @@ function branchCell(repo, stream = process21.stdout) {
|
|
|
2144
2824
|
return DEFAULT_BRANCHES.has(repo.branch) ? repo.branch : role("accent", stream)(repo.branch);
|
|
2145
2825
|
}
|
|
2146
2826
|
function row(repo, shown) {
|
|
2147
|
-
const colors = paint(
|
|
2148
|
-
const tint = role("path",
|
|
2827
|
+
const colors = paint(process23.stdout);
|
|
2828
|
+
const tint = role("path", process23.stdout);
|
|
2149
2829
|
const unreleased = releasedCell(repo);
|
|
2150
2830
|
return [
|
|
2151
2831
|
tint(shown),
|
|
@@ -2156,16 +2836,26 @@ function row(repo, shown) {
|
|
|
2156
2836
|
unreleased === "-" ? colors.dim("-") : colors.cyan(unreleased)
|
|
2157
2837
|
];
|
|
2158
2838
|
}
|
|
2159
|
-
async function repos(args) {
|
|
2160
|
-
const { values, positionals } = parse(args, USAGE2, OPTIONS2, { positionals: ["[root]"], exits: EXITS2, replaces: "a cd, git status, git log and git tag loop over each repository of the workspace", examples: ["repos", "repos ~/Workspace --only unreleased --fetch", ["repos --only behind --pull", "fast-forward what is behind and clean"], ["repos --only dirty --path", "the paths, for xargs"]] });
|
|
2839
|
+
async function repos(args, watched = false) {
|
|
2840
|
+
const { values, positionals } = parse(args, USAGE2, OPTIONS2, { positionals: ["[root]"], exits: EXITS2, replaces: "a cd, git status, git log and git tag loop over each repository of the workspace", examples: ["ws repos", "ws repos ~/Workspace --only unreleased --fetch", ["ws repos --only behind --pull", "fast-forward what is behind and clean"], ["ws repos --only dirty --path", "the paths, for xargs"]] });
|
|
2161
2841
|
if (values.watch !== undefined)
|
|
2162
|
-
return watching(values.watch, async () => repos(withoutWatch(args)));
|
|
2842
|
+
return watching(values.watch, async () => repos(withoutWatch(args), true));
|
|
2163
2843
|
const root = workspaceRoot({ given: positionals[0] });
|
|
2164
2844
|
if (!existsSync8(root) || !statSync3(root).isDirectory())
|
|
2165
2845
|
fail(`no folder ${root}`);
|
|
2166
2846
|
const only = values.only;
|
|
2167
|
-
const
|
|
2168
|
-
const
|
|
2847
|
+
const progress = watched ? undefined : progressLine();
|
|
2848
|
+
const fetching = values.fetch === true || values.pull === true;
|
|
2849
|
+
const step = fetching ? "fetching" : "reading";
|
|
2850
|
+
let states;
|
|
2851
|
+
try {
|
|
2852
|
+
progress?.update({ step: "finding the repositories" });
|
|
2853
|
+
const paths = await findRepos2(root, await skipped());
|
|
2854
|
+
progress?.update({ step, done: 0, total: paths.length, unit: "repositories" });
|
|
2855
|
+
states = await pool(paths, configuredNumber("repos", "concurrency", CONCURRENCY2), async (path) => inspect(path, fetching), (done, total) => progress?.update({ step, done, total, unit: "repositories" }));
|
|
2856
|
+
} finally {
|
|
2857
|
+
progress?.stop();
|
|
2858
|
+
}
|
|
2169
2859
|
const keeps = (repo) => {
|
|
2170
2860
|
const reasons = reasonsOf(repo);
|
|
2171
2861
|
return only === undefined ? values.all === true || reasons.length > 0 || repo.unreadable : reasons.includes(only);
|
|
@@ -2179,12 +2869,12 @@ async function repos(args) {
|
|
|
2179
2869
|
const blocker = pullBlocker(repo);
|
|
2180
2870
|
const refused = blocker === undefined ? await fastForward(repo.path) : undefined;
|
|
2181
2871
|
if (blocker !== undefined) {
|
|
2182
|
-
log(marked("note", `${repo.name} skipped`,
|
|
2872
|
+
log(marked("note", `${repo.name} skipped`, process23.stdout, blocker));
|
|
2183
2873
|
} else if (refused !== undefined) {
|
|
2184
2874
|
failedPulls++;
|
|
2185
|
-
log(marked("problem", `${repo.name} not pulled`,
|
|
2875
|
+
log(marked("problem", `${repo.name} not pulled`, process23.stdout, refused));
|
|
2186
2876
|
} else {
|
|
2187
|
-
log(marked("ok", `${repo.name} pulled`,
|
|
2877
|
+
log(marked("ok", `${repo.name} pulled`, process23.stdout, `${repo.behind} ${repo.behind === 1 ? "commit" : "commits"}`));
|
|
2188
2878
|
states[index] = await inspect(repo.path, false);
|
|
2189
2879
|
}
|
|
2190
2880
|
}
|
|
@@ -2199,7 +2889,7 @@ async function repos(args) {
|
|
|
2199
2889
|
printJson(kept.map((repo) => ({ ...repo, reasons: reasonsOf(repo) })));
|
|
2200
2890
|
return failedPulls > 0 ? 1 : 0;
|
|
2201
2891
|
}
|
|
2202
|
-
const label = role("label",
|
|
2892
|
+
const label = role("label", process23.stdout);
|
|
2203
2893
|
printHeader("repos", `${basename2(root)} \xB7 ${states.length} ${states.length === 1 ? "repository" : "repositories"}`);
|
|
2204
2894
|
if (kept.length === 0) {
|
|
2205
2895
|
console.log(label(`nothing needs attention in ${states.length} repositories`));
|
|
@@ -2218,212 +2908,7 @@ async function repos(args) {
|
|
|
2218
2908
|
import { existsSync as existsSync11, statSync as statSync4 } from "fs";
|
|
2219
2909
|
import { homedir as homedir6 } from "os";
|
|
2220
2910
|
import { relative as relative3 } from "path";
|
|
2221
|
-
|
|
2222
|
-
// ../kit/src/prompt.ts
|
|
2223
|
-
import process23 from "process";
|
|
2224
|
-
|
|
2225
|
-
// ../kit/src/job.ts
|
|
2226
|
-
import process22 from "process";
|
|
2227
|
-
function stopJob() {
|
|
2228
|
-
process22.kill(0, "SIGTSTP");
|
|
2229
|
-
}
|
|
2230
|
-
|
|
2231
|
-
// ../kit/src/picker/line.ts
|
|
2232
|
-
var EDIT_KEYS = new Set(["left", "right", "wordleft", "wordright", "linestart", "lineend", "erase", "delete", "word", "killword", "killnext", "clear", "killend", "yank"]);
|
|
2233
|
-
var BACKWARD_KILLS = new Set(["word", "killword", "clear"]);
|
|
2234
|
-
var FORWARD_KILLS = new Set(["killnext", "killend"]);
|
|
2235
|
-
function isEditKey(key) {
|
|
2236
|
-
return EDIT_KEYS.has(key);
|
|
2237
|
-
}
|
|
2238
|
-
|
|
2239
|
-
// ../kit/src/picker/score.ts
|
|
2240
|
-
var BOUNDARY_AFTER = new Set([" ", "/", "-", "_", ".", ":", "\\", "(", "[", ",", "\t"]);
|
|
2241
|
-
var NONE = Number.NEGATIVE_INFINITY;
|
|
2242
|
-
|
|
2243
|
-
// ../kit/src/picker/state.ts
|
|
2244
|
-
var IS_CONTROL = /[\x00-\x1F\x7F-\x9F]/;
|
|
2245
|
-
var PASTE_START = "\x1B[200~";
|
|
2246
|
-
var PASTE_END = "\x1B[201~";
|
|
2247
|
-
var KEY_SEQUENCES = /\x1B\[<[0-9;]*[A-Za-z]|\x1B\[[0-9;]*[A-Z~]|\x1BO[A-Z]|\x1B[\s\S]|[\s\S]/gu;
|
|
2248
|
-
var MOUSE = /^\x1B\[<(\d+);\d+;\d+[a-z]$/i;
|
|
2249
|
-
var WHEEL_LINES = 3;
|
|
2250
|
-
var KEYS = {
|
|
2251
|
-
"\x1B[A": "up",
|
|
2252
|
-
"\x1BOA": "up",
|
|
2253
|
-
"\x10": "up",
|
|
2254
|
-
"\x1B[B": "down",
|
|
2255
|
-
"\x1BOB": "down",
|
|
2256
|
-
"\x0E": "down",
|
|
2257
|
-
"\x1B[5~": "pageup",
|
|
2258
|
-
"\x1B[6~": "pagedown",
|
|
2259
|
-
"\x1B[H": "home",
|
|
2260
|
-
"\x1B[1~": "home",
|
|
2261
|
-
"\x1BOH": "home",
|
|
2262
|
-
"\x1B[F": "end",
|
|
2263
|
-
"\x1B[4~": "end",
|
|
2264
|
-
"\x1BOF": "end",
|
|
2265
|
-
"\r": "enter",
|
|
2266
|
-
"\n": "enter",
|
|
2267
|
-
"\x03": "cancel",
|
|
2268
|
-
"\x1B": "cancel",
|
|
2269
|
-
"\x1B[D": "left",
|
|
2270
|
-
"\x1BOD": "left",
|
|
2271
|
-
"\x1B[C": "right",
|
|
2272
|
-
"\x1BOC": "right",
|
|
2273
|
-
"\x1B[1;5D": "wordleft",
|
|
2274
|
-
"\x1B[1;3D": "wordleft",
|
|
2275
|
-
"\x1Bb": "wordleft",
|
|
2276
|
-
"\x1B[1;5C": "wordright",
|
|
2277
|
-
"\x1B[1;3C": "wordright",
|
|
2278
|
-
"\x1Bf": "wordright",
|
|
2279
|
-
"\x01": "linestart",
|
|
2280
|
-
"\x05": "lineend",
|
|
2281
|
-
"\x7F": "erase",
|
|
2282
|
-
"\x1B[3~": "delete",
|
|
2283
|
-
"\b": "killword",
|
|
2284
|
-
"\x1B\x7F": "killword",
|
|
2285
|
-
"\x1B[3;5~": "killnext",
|
|
2286
|
-
"\x1Bd": "killnext",
|
|
2287
|
-
"\x15": "clear",
|
|
2288
|
-
"\v": "killend",
|
|
2289
|
-
"\x17": "word",
|
|
2290
|
-
"\x19": "yank",
|
|
2291
|
-
"\x1A": "suspend",
|
|
2292
|
-
"\t": "tab",
|
|
2293
|
-
"\x1F": "help",
|
|
2294
|
-
"\x1BOP": "help",
|
|
2295
|
-
"\x1B[11~": "help"
|
|
2296
|
-
};
|
|
2297
|
-
function repeat(value, count) {
|
|
2298
|
-
return Array.from({ length: count }).fill(value);
|
|
2299
|
-
}
|
|
2300
|
-
function parseKeys(input, paste = { active: false }, ctrls = []) {
|
|
2301
|
-
const codes = new Map(ctrls.map((name) => [String.fromCharCode(name.codePointAt(name.length - 1) - 96), name]));
|
|
2302
|
-
return (input.match(KEY_SEQUENCES) ?? []).flatMap((sequence) => {
|
|
2303
|
-
const wheel = MOUSE.exec(sequence)?.[1];
|
|
2304
|
-
if (wheel !== undefined)
|
|
2305
|
-
return repeat(wheel === "64" ? "up" : "down", wheel === "64" || wheel === "65" ? WHEEL_LINES : 0);
|
|
2306
|
-
const named = codes.get(sequence);
|
|
2307
|
-
const key = named === undefined ? KEYS[sequence] : { ctrl: named };
|
|
2308
|
-
if (sequence === PASTE_START || sequence === PASTE_END) {
|
|
2309
|
-
paste.active = sequence === PASTE_START;
|
|
2310
|
-
return [];
|
|
2311
|
-
}
|
|
2312
|
-
if (paste.active && (sequence === "\r" || sequence === `
|
|
2313
|
-
`))
|
|
2314
|
-
return [];
|
|
2315
|
-
if (key !== undefined)
|
|
2316
|
-
return [key];
|
|
2317
|
-
return IS_CONTROL.test(sequence) || sequence.startsWith("\x1B") ? [] : [{ text: sequence }];
|
|
2318
|
-
});
|
|
2319
|
-
}
|
|
2320
|
-
|
|
2321
|
-
// ../kit/src/redraw.ts
|
|
2322
|
-
var SYNC_START = "\x1B[?2026h";
|
|
2323
|
-
var SYNC_END = "\x1B[?2026l";
|
|
2324
|
-
function overwrite(lines, columns) {
|
|
2325
|
-
return lines.map((line) => textWidth(line) % columns === 0 ? `\x1B[2K${line}` : `${line}\x1B[K`).join(`
|
|
2326
|
-
`);
|
|
2327
|
-
}
|
|
2328
|
-
function rowsTaken(lines, columns) {
|
|
2329
|
-
return lines.reduce((rows, line) => rows + Math.max(1, Math.ceil(textWidth(line) / columns)), 0);
|
|
2330
|
-
}
|
|
2331
|
-
|
|
2332
|
-
// ../kit/src/prompt.ts
|
|
2333
|
-
var PROMPT_KEYS = new Set(["up", "down", "pageup", "pagedown", "home", "end", "enter", "cancel", "suspend", "tab"]);
|
|
2334
|
-
function readKeys(input, paste = { active: false }) {
|
|
2335
|
-
return parseKeys(input, paste).filter((key) => typeof key === "object" ? "text" in key : PROMPT_KEYS.has(key) || isEditKey(key));
|
|
2336
|
-
}
|
|
2337
|
-
async function confirm(question, { default: fallback, ...settings } = {}) {
|
|
2338
|
-
let answered = fallback;
|
|
2339
|
-
const choices = { true: "Y/n", false: "y/N", undefined: "y/n" }[String(fallback)];
|
|
2340
|
-
const accepted = await ask(question, settings, (colors, state) => [state === "asking" ? asking(colors, question, "", choices) : answer(colors, question, state, answered ? "yes" : "no")], (key) => {
|
|
2341
|
-
if (key === "cancel")
|
|
2342
|
-
return "cancel";
|
|
2343
|
-
if (key === "enter")
|
|
2344
|
-
return answered === undefined ? undefined : "enter";
|
|
2345
|
-
const letter = typeof key === "object" ? key.text.toLowerCase() : "";
|
|
2346
|
-
if (letter !== "y" && letter !== "n")
|
|
2347
|
-
return;
|
|
2348
|
-
answered = letter === "y";
|
|
2349
|
-
return "enter";
|
|
2350
|
-
});
|
|
2351
|
-
return accepted ? answered : undefined;
|
|
2352
|
-
}
|
|
2353
|
-
function asking(colors, question, typed, keys) {
|
|
2354
|
-
return `${colors.cyan("?")} ${question} ${typed === "" ? colors.dim(`(${keys})`) : typed}`;
|
|
2355
|
-
}
|
|
2356
|
-
function answer(colors, question, state, picked) {
|
|
2357
|
-
return state === "enter" ? `${colors.green("\u2713")} ${question} ${colors.cyan(picked)}` : `${colors.red("\u2717")} ${question} ${colors.dim("cancelled")}`;
|
|
2358
|
-
}
|
|
2359
|
-
async function ask(question, { hint, terminal = process23 }, render, press) {
|
|
2360
|
-
const { stdin, stderr } = terminal;
|
|
2361
|
-
if (!isInteractive(terminal))
|
|
2362
|
-
fail(`cannot ask "${question}" off a terminal`, 2, hint);
|
|
2363
|
-
const colors = paint(stderr);
|
|
2364
|
-
let current = "asking";
|
|
2365
|
-
let outcome;
|
|
2366
|
-
const columns = () => stderr.columns || 80;
|
|
2367
|
-
const draw = (state, last = false) => {
|
|
2368
|
-
const frame = render(colors, state, { columns: columns(), rows: stderr.rows || 24 });
|
|
2369
|
-
const rows = rowsTaken(frame, columns());
|
|
2370
|
-
stderr.write(`${SYNC_START}\r${overwrite(frame, columns())}\x1B[0J${last || rows < 2 ? "" : `\x1B[${rows - 1}A`}${last ? "" : "\r"}${SYNC_END}`);
|
|
2371
|
-
current = state;
|
|
2372
|
-
};
|
|
2373
|
-
const redraw = () => draw(current);
|
|
2374
|
-
const paste = { active: false };
|
|
2375
|
-
const stop = terminal.stop ?? (terminal === process23 ? stopJob : undefined);
|
|
2376
|
-
const suspend = () => {
|
|
2377
|
-
if (stop === undefined)
|
|
2378
|
-
return;
|
|
2379
|
-
stderr.write("\x1B[0J\x1B[?25h\x1B[?2004l");
|
|
2380
|
-
stdin.setRawMode(false);
|
|
2381
|
-
stop();
|
|
2382
|
-
stdin.setRawMode(true);
|
|
2383
|
-
stderr.write("\x1B[?25l\x1B[?2004h");
|
|
2384
|
-
};
|
|
2385
|
-
try {
|
|
2386
|
-
stderr.on?.("resize", redraw);
|
|
2387
|
-
stdin.setRawMode(true);
|
|
2388
|
-
stdin.resume();
|
|
2389
|
-
stderr.write("\x1B[?25l\x1B[?2004h");
|
|
2390
|
-
draw("asking");
|
|
2391
|
-
return await new Promise((resolve) => {
|
|
2392
|
-
function onData(data) {
|
|
2393
|
-
for (const key of readKeys(data.toString(), paste)) {
|
|
2394
|
-
if (key === "suspend") {
|
|
2395
|
-
suspend();
|
|
2396
|
-
continue;
|
|
2397
|
-
}
|
|
2398
|
-
const pressed = press(key);
|
|
2399
|
-
if (pressed !== undefined) {
|
|
2400
|
-
settle(pressed);
|
|
2401
|
-
return;
|
|
2402
|
-
}
|
|
2403
|
-
}
|
|
2404
|
-
draw("asking");
|
|
2405
|
-
}
|
|
2406
|
-
function onEnd() {
|
|
2407
|
-
settle("cancel");
|
|
2408
|
-
}
|
|
2409
|
-
function settle(settled) {
|
|
2410
|
-
outcome = settled;
|
|
2411
|
-
stdin.off("data", onData);
|
|
2412
|
-
stdin.off("end", onEnd);
|
|
2413
|
-
resolve(settled === "enter");
|
|
2414
|
-
}
|
|
2415
|
-
stdin.on("data", onData);
|
|
2416
|
-
stdin.on("end", onEnd);
|
|
2417
|
-
});
|
|
2418
|
-
} finally {
|
|
2419
|
-
stderr.off?.("resize", redraw);
|
|
2420
|
-
draw(outcome ?? "cancel", true);
|
|
2421
|
-
stderr.write(`
|
|
2422
|
-
\x1B[?25h\x1B[?2004l`);
|
|
2423
|
-
stdin.setRawMode(false);
|
|
2424
|
-
stdin.pause();
|
|
2425
|
-
}
|
|
2426
|
-
}
|
|
2911
|
+
init_prompt();
|
|
2427
2912
|
|
|
2428
2913
|
// src/apply.ts
|
|
2429
2914
|
import { existsSync as existsSync10 } from "fs";
|
|
@@ -2692,7 +3177,7 @@ async function judge(candidate) {
|
|
|
2692
3177
|
return { entry: { path: candidate.path, kind: candidate.kind, committedAt: undefined, action: "remove" } };
|
|
2693
3178
|
return candidate.kind === "worktree" ? judgeWorktree(candidate.path) : judgeFolder(candidate.path, candidate.kind, candidate.inside);
|
|
2694
3179
|
}
|
|
2695
|
-
async function inspect2({ candidates, skipped }) {
|
|
3180
|
+
async function inspect2({ candidates, skipped }, onDone) {
|
|
2696
3181
|
const entries = [];
|
|
2697
3182
|
const rejected = [...skipped];
|
|
2698
3183
|
await pool(candidates, 8, async (candidate) => {
|
|
@@ -2701,7 +3186,7 @@ async function inspect2({ candidates, skipped }) {
|
|
|
2701
3186
|
rejected.push({ path: candidate.path, reason: verdict.skip });
|
|
2702
3187
|
else
|
|
2703
3188
|
entries.push({ ...verdict.entry, bytes: await sizeOf(candidate.path) });
|
|
2704
|
-
});
|
|
3189
|
+
}, onDone);
|
|
2705
3190
|
const listed = new Set(entries.filter((entry) => entry.action === "remove").map((entry) => entry.path));
|
|
2706
3191
|
return { entries: entries.filter((entry) => entry.inside === undefined || !listed.has(entry.inside)), skipped: rejected };
|
|
2707
3192
|
}
|
|
@@ -2745,7 +3230,7 @@ async function applyAll(entries, done) {
|
|
|
2745
3230
|
// src/sweep.ts
|
|
2746
3231
|
var LARGE = 100 * 1024 ** 2;
|
|
2747
3232
|
var BIG = 1024 ** 3;
|
|
2748
|
-
var USAGE3 = `sweep [options] [root]: lists the regenerable folders (node_modules, .output, dist, build, .venv, target beside a Cargo.toml, vendor beside a composer.json or composer.lock), the caches (.nuxt, .next, .turbo, .svelte-kit, __pycache__, .gradle and node_modules/.cache per project; ~/.bun/install/cache, ~/.npm/_cacache, ~/.cache/{pip,uv,ms-playwright,puppeteer,go-build,typescript} and ~/.cargo/registry, exact paths only, listed only when no root is given or with --only caches) and the .worktrees/* and .claude/worktrees/* entries under root (the configured workspace, ~/Workspace by default, ${MAX_DEPTH3} levels down), largest first with the age of the repo's last commit; --only worktrees, folders or caches keeps one kind
|
|
3233
|
+
var USAGE3 = `ws sweep [options] [root]: lists the regenerable folders (node_modules, .output, dist, build, .venv, target beside a Cargo.toml, vendor beside a composer.json or composer.lock), the caches (.nuxt, .next, .turbo, .svelte-kit, __pycache__, .gradle and node_modules/.cache per project; ~/.bun/install/cache, ~/.npm/_cacache, ~/.cache/{pip,uv,ms-playwright,puppeteer,go-build,typescript} and ~/.cargo/registry, exact paths only, listed only when no root is given or with --only caches) and the .worktrees/* and .claude/worktrees/* entries under root (the configured workspace, ~/Workspace by default, ${MAX_DEPTH3} levels down), largest first with the age of the repo's last commit; --only worktrees, folders or caches keeps one kind
|
|
2749
3234
|
|
|
2750
3235
|
Dry unless --apply, which deletes after a confirm showing the total (read from the terminal; off one, pass --yes). A folder is deleted for good, not trashed. Never touched: a symlink, a folder git tracks files in, a build folder git does not ignore. A worktree is removed with git worktree remove, never forced, and only when it is clean and every commit of its branch is on another branch or a remote; the others stay listed as kept and count for nothing in the total. With --docker the Docker usage comes after the list, left to dclean.`;
|
|
2751
3236
|
var EXITS3 = [[0, "it listed, or removed every entry it was allowed to"], [1, "a removal failed or the confirm was declined"], [2, "a usage error, a missing root, or --apply off a terminal without --yes"]];
|
|
@@ -2770,7 +3255,7 @@ async function dockerUsage() {
|
|
|
2770
3255
|
}
|
|
2771
3256
|
}
|
|
2772
3257
|
async function sweep(args) {
|
|
2773
|
-
const { values, positionals } = parse(args, USAGE3, OPTIONS3, { exits: EXITS3, positionals: ["[root]"], replaces: "find ~/Workspace -name node_modules, du -sh and rm -rf by hand", examples: ["sweep", "sweep ~/Workspace --older 30d --min 100M --apply", "sweep --only worktrees --apply"] });
|
|
3258
|
+
const { values, positionals } = parse(args, USAGE3, OPTIONS3, { exits: EXITS3, positionals: ["[root]"], replaces: "find ~/Workspace -name node_modules, du -sh and rm -rf by hand", examples: ["ws sweep", "ws sweep ~/Workspace --older 30d --min 100M --apply", "ws sweep --only worktrees --apply"] });
|
|
2774
3259
|
if (positionals.length > 1)
|
|
2775
3260
|
badUsage("give one root");
|
|
2776
3261
|
const root = workspaceRoot({ given: positionals[0] });
|
|
@@ -2781,9 +3266,18 @@ async function sweep(args) {
|
|
|
2781
3266
|
if (minBytes === undefined)
|
|
2782
3267
|
badUsage(`--min takes a size such as 500K, 10M or 1G, not ${values.min}`);
|
|
2783
3268
|
const now = Date.now();
|
|
2784
|
-
const
|
|
2785
|
-
|
|
2786
|
-
|
|
3269
|
+
const progress = progressLine();
|
|
3270
|
+
let scanned;
|
|
3271
|
+
try {
|
|
3272
|
+
progress.update({ step: "finding the folders" });
|
|
3273
|
+
const found = await findCandidates(root, homedir6(), positionals.length === 0 || values.only === "caches");
|
|
3274
|
+
const wanted = values.only === undefined ? found.candidates : found.candidates.filter((candidate) => candidate.kind === ONLY_KINDS[values.only]);
|
|
3275
|
+
progress.update({ step: "sizing", done: 0, total: wanted.length, unit: "folders" });
|
|
3276
|
+
scanned = await inspect2({ candidates: wanted, skipped: found.skipped }, (done, total) => progress.update({ step: "sizing", done, total, unit: "folders" }));
|
|
3277
|
+
} finally {
|
|
3278
|
+
progress.stop();
|
|
3279
|
+
}
|
|
3280
|
+
const { entries: all, skipped } = scanned;
|
|
2787
3281
|
const entries = all.filter((entry) => entry.bytes >= minBytes && (olderMs === undefined || entry.committedAt !== undefined && now - entry.committedAt >= olderMs)).sort((a, b) => b.bytes - a.bytes || a.path.localeCompare(b.path));
|
|
2788
3282
|
const removable = entries.filter((entry) => entry.action === "remove");
|
|
2789
3283
|
const reclaimable = removable.reduce((sum, entry) => sum + entry.bytes, 0);
|
|
@@ -2846,7 +3340,7 @@ ${tt(reclaimable)} reclaimable${skipped === 0 ? "" : `, ${skipped} skipped (syml
|
|
|
2846
3340
|
}
|
|
2847
3341
|
|
|
2848
3342
|
// src/cli.ts
|
|
2849
|
-
|
|
3343
|
+
process26.exitCode = await runCli({
|
|
2850
3344
|
name: "ws",
|
|
2851
3345
|
about: "the repositories under a root: the ones needing attention, the folders worth reclaiming and their known vulnerabilities",
|
|
2852
3346
|
replaces: "a cd, git status and du loop over each repository of the workspace, and a bun audit run in each",
|