@kaynooo/cli-code 0.15.1 → 0.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -21
- package/dist/cli.js +712 -226
- package/package.json +10 -16
- package/dist/hotspots-cli.js +0 -1661
- package/dist/peek-cli.js +0 -1885
- package/dist/todo-scan-cli.js +0 -1654
package/dist/cli.js
CHANGED
|
@@ -1,21 +1,19 @@
|
|
|
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
|
-
|
|
6
|
-
// ../kit/src/args.ts
|
|
7
|
-
import process9 from "process";
|
|
8
|
-
import { parseArgs } from "util";
|
|
9
|
-
|
|
10
|
-
// ../kit/src/format.ts
|
|
11
|
-
import process7 from "process";
|
|
12
|
-
|
|
13
|
-
// ../../node_modules/.bun/@kaynooo+utils@3.0.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-rxztfxgv.js
|
|
14
|
-
var ct = /[aeiou]y$/;
|
|
15
|
-
var N = new Map;
|
|
16
|
-
var Ot = /(?:leaf|loaf|thief|wolf|half|calf|elf|sheaf|scarf|dwarf|hoof|wharf)$/;
|
|
17
|
-
var Gt = /(?:knife|life|wife)$/;
|
|
18
|
-
function K(t, e, { plural: r, zero: n = "singular" } = {}) {
|
|
15
|
+
// ../../node_modules/.bun/@kaynooo+utils@3.1.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-rkhsft4a.js
|
|
16
|
+
function G(t, e, { plural: r, zero: n = "singular" } = {}) {
|
|
19
17
|
if (e === 1 || e === 0 && n === "singular")
|
|
20
18
|
return t;
|
|
21
19
|
if (r !== undefined)
|
|
@@ -28,12 +26,10 @@ function K(t, e, { plural: r, zero: n = "singular" } = {}) {
|
|
|
28
26
|
return `${t.slice(0, -1)}ves`;
|
|
29
27
|
return Gt.test(t) ? `${t.slice(0, -2)}ves` : `${t}s`;
|
|
30
28
|
}
|
|
31
|
-
function
|
|
32
|
-
return `${t} ${
|
|
29
|
+
function bo(t, e, { zero: r = "plural", ...n } = {}) {
|
|
30
|
+
return `${t} ${G(e, t, { ...n, zero: r })}`;
|
|
33
31
|
}
|
|
34
|
-
|
|
35
|
-
var Y = /\s/;
|
|
36
|
-
function ko(t, e, r = "...") {
|
|
32
|
+
function Ao(t, e, r = "...") {
|
|
37
33
|
let { suffix: n = "...", includeSuffix: s = false, wordBoundary: o = false } = typeof r === "string" ? { suffix: r } : r;
|
|
38
34
|
if (t.length <= e)
|
|
39
35
|
return t;
|
|
@@ -44,13 +40,25 @@ function ko(t, e, r = "...") {
|
|
|
44
40
|
c = c.trimEnd();
|
|
45
41
|
return s ? (c + n).slice(0, l) : c + n;
|
|
46
42
|
}
|
|
47
|
-
var
|
|
48
|
-
var
|
|
43
|
+
var ct, N, Ot, Gt, Nt, Y, be, W;
|
|
44
|
+
var init_chunk_rkhsft4a = __esm(() => {
|
|
45
|
+
ct = /[aeiou]y$/;
|
|
46
|
+
N = new Map;
|
|
47
|
+
Ot = /(?:leaf|loaf|thief|wolf|half|calf|elf|sheaf|scarf|dwarf|hoof|wharf)$/;
|
|
48
|
+
Gt = /(?:knife|life|wife)$/;
|
|
49
|
+
Nt = /\s+\S*$/;
|
|
50
|
+
Y = /\s/;
|
|
51
|
+
be = new Map(["\u20AC", "", "\u201A", "\u0192", "\u201E", "\u2026", "\u2020", "\u2021", "\u02C6", "\u2030", "\u0160", "\u2039", "\u0152", "", "\u017D", "", "", "\u2018", "\u2019", "\u201C", "\u201D", "\u2022", "\u2013", "\u2014", "\u02DC", "\u2122", "\u0161", "\u203A", "\u0153", "", "\u017E", "\u0178"].map((t, e) => [t, 128 + e]).filter(([t]) => t));
|
|
52
|
+
W = new Map;
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// ../../node_modules/.bun/@kaynooo+utils@3.1.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/text.js
|
|
56
|
+
var init_text = __esm(() => {
|
|
57
|
+
init_chunk_rkhsft4a();
|
|
58
|
+
});
|
|
49
59
|
|
|
50
60
|
// ../kit/src/mode.ts
|
|
51
61
|
import process2 from "process";
|
|
52
|
-
var MODES = new Set(["terminal", "ci", "agent", "pipe"]);
|
|
53
|
-
var AGENT_VARIABLES = ["CLAUDECODE", "AI_AGENT"];
|
|
54
62
|
function isSet(value) {
|
|
55
63
|
return value !== undefined && value !== "" && value !== "0" && value.toLowerCase() !== "false";
|
|
56
64
|
}
|
|
@@ -64,14 +72,13 @@ function outputMode(stream = process2.stdout, env = process2.env) {
|
|
|
64
72
|
return "terminal";
|
|
65
73
|
return isSet(env.CI) ? "ci" : "pipe";
|
|
66
74
|
}
|
|
75
|
+
var MODES, AGENT_VARIABLES;
|
|
76
|
+
var init_mode = __esm(() => {
|
|
77
|
+
MODES = new Set(["terminal", "ci", "agent", "pipe"]);
|
|
78
|
+
AGENT_VARIABLES = ["CLAUDECODE", "AI_AGENT"];
|
|
79
|
+
});
|
|
67
80
|
|
|
68
|
-
//
|
|
69
|
-
import { resolve as resolve3 } from "path";
|
|
70
|
-
import process6 from "process";
|
|
71
|
-
import { pathToFileURL } from "url";
|
|
72
|
-
|
|
73
|
-
// ../../node_modules/.bun/@kaynooo+utils@3.0.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-x450vn3m.js
|
|
74
|
-
var G2 = /^[a-f0-9]+$/i;
|
|
81
|
+
// ../../node_modules/.bun/@kaynooo+utils@3.1.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-x450vn3m.js
|
|
75
82
|
function b(r) {
|
|
76
83
|
let e = r.startsWith("#") ? r.slice(1) : r;
|
|
77
84
|
if (!G2.test(e))
|
|
@@ -82,11 +89,6 @@ function b(r) {
|
|
|
82
89
|
throw Error(`Invalid hex color length: ${e.length}`);
|
|
83
90
|
return [Number.parseInt(e.slice(0, 2), 16), Number.parseInt(e.slice(2, 4), 16), Number.parseInt(e.slice(4, 6), 16)];
|
|
84
91
|
}
|
|
85
|
-
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") => {
|
|
86
|
-
let [l, n, c] = b(r);
|
|
87
|
-
return [`${e === "fg" ? 38 : 48};2;${l};${n};${c}`, e === "fg" ? 39 : 49];
|
|
88
|
-
}, ansi256: (r, e = "fg") => [`${e === "fg" ? 38 : 48};5;${r}`, e === "fg" ? 39 : 49] };
|
|
89
|
-
var h = new Set(["", "1", "2", "3", "true"]);
|
|
90
92
|
function C(r, e = globalThis.process?.env ?? {}) {
|
|
91
93
|
if (e.FORCE_COLOR !== undefined)
|
|
92
94
|
return h.has(e.FORCE_COLOR);
|
|
@@ -100,7 +102,7 @@ function f(r, e = []) {
|
|
|
100
102
|
l += `\x1B[${e[t][0]}m`, n = `\x1B[${e[t][1]}m${n}`;
|
|
101
103
|
let c = (t) => C(r.stream ?? globalThis.process?.stdout, r.env) ? l + t + n : t, g = new Map;
|
|
102
104
|
return new Proxy(c, { get(t, i) {
|
|
103
|
-
let a =
|
|
105
|
+
let a = B[i];
|
|
104
106
|
if (Array.isArray(a)) {
|
|
105
107
|
let s = g.get(i);
|
|
106
108
|
if (s === undefined)
|
|
@@ -123,13 +125,21 @@ function f(r, e = []) {
|
|
|
123
125
|
function Fe(r = {}) {
|
|
124
126
|
return f(r);
|
|
125
127
|
}
|
|
126
|
-
var
|
|
128
|
+
var G2, B, h, o;
|
|
129
|
+
var init_chunk_x450vn3m = __esm(() => {
|
|
130
|
+
G2 = /^[a-f0-9]+$/i;
|
|
131
|
+
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") => {
|
|
132
|
+
let [l, n, c] = b(r);
|
|
133
|
+
return [`${e === "fg" ? 38 : 48};2;${l};${n};${c}`, e === "fg" ? 39 : 49];
|
|
134
|
+
}, ansi256: (r, e = "fg") => [`${e === "fg" ? 38 : 48};5;${r}`, e === "fg" ? 39 : 49] };
|
|
135
|
+
h = new Set(["", "1", "2", "3", "true"]);
|
|
136
|
+
o = Fe();
|
|
137
|
+
});
|
|
127
138
|
|
|
128
|
-
//
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
import process5 from "process";
|
|
139
|
+
// ../../node_modules/.bun/@kaynooo+utils@3.1.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/tools/colors.js
|
|
140
|
+
var init_colors = __esm(() => {
|
|
141
|
+
init_chunk_x450vn3m();
|
|
142
|
+
});
|
|
133
143
|
|
|
134
144
|
// ../kit/src/config.ts
|
|
135
145
|
import { existsSync } from "fs";
|
|
@@ -145,6 +155,9 @@ function findUp(names, from = process3.cwd(), stop = () => false) {
|
|
|
145
155
|
return;
|
|
146
156
|
}
|
|
147
157
|
}
|
|
158
|
+
var init_config = __esm(() => {
|
|
159
|
+
init_args();
|
|
160
|
+
});
|
|
148
161
|
|
|
149
162
|
// ../kit/src/user-config.ts
|
|
150
163
|
import { existsSync as existsSync2, readFileSync } from "fs";
|
|
@@ -180,36 +193,49 @@ function configuredNumber(bin, key, fallback, where = {}, legacy = []) {
|
|
|
180
193
|
const value = readUserConfig(bin, where, legacy)[key];
|
|
181
194
|
return typeof value === "number" && Number.isInteger(value) && value > 0 ? value : fallback;
|
|
182
195
|
}
|
|
196
|
+
var init_user_config = () => {};
|
|
183
197
|
|
|
184
198
|
// ../kit/src/theme.ts
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
199
|
+
import { existsSync as existsSync3, readFileSync as readFileSync2, statSync } from "fs";
|
|
200
|
+
import { homedir as homedir2 } from "os";
|
|
201
|
+
import { join as join3, resolve as resolve2 } from "path";
|
|
202
|
+
import process5 from "process";
|
|
203
|
+
function toLinear(channel) {
|
|
204
|
+
const value = channel / 255;
|
|
205
|
+
return value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4;
|
|
206
|
+
}
|
|
207
|
+
function toOklab(hex) {
|
|
208
|
+
const [r, g, b] = [1, 3, 5].map((at) => toLinear(Number.parseInt(hex.slice(at, at + 2), 16)));
|
|
209
|
+
const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b);
|
|
210
|
+
const m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b);
|
|
211
|
+
const s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b);
|
|
212
|
+
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];
|
|
213
|
+
}
|
|
214
|
+
function fromOklab([lightness, a, b]) {
|
|
215
|
+
const l = (lightness + 0.3963377774 * a + 0.2158037573 * b) ** 3;
|
|
216
|
+
const m = (lightness - 0.1055613458 * a - 0.0638541728 * b) ** 3;
|
|
217
|
+
const s = (lightness - 0.0894841775 * a - 1.291485548 * b) ** 3;
|
|
218
|
+
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];
|
|
219
|
+
return `#${channels.map((channel) => fromLinear(channel).toString(16).padStart(2, "0")).join("")}`;
|
|
220
|
+
}
|
|
221
|
+
function gradientAt(theme, ratio) {
|
|
222
|
+
if (theme.gradient === undefined)
|
|
223
|
+
return;
|
|
224
|
+
const key = theme.gradient.join();
|
|
225
|
+
let ends = ENDS.get(key);
|
|
226
|
+
if (ends === undefined) {
|
|
227
|
+
ends = [toOklab(theme.gradient[0]), toOklab(theme.gradient[1])];
|
|
228
|
+
ENDS.set(key, ends);
|
|
229
|
+
}
|
|
230
|
+
const at = Math.min(1, Math.max(0, ratio));
|
|
231
|
+
const [from, to] = ends;
|
|
232
|
+
return fromOklab(from.map((start, index) => start + (to[index] - start) * at));
|
|
233
|
+
}
|
|
207
234
|
function isColorSpec(spec) {
|
|
208
235
|
if (typeof spec === "number")
|
|
209
236
|
return Number.isInteger(spec) && spec >= 0 && spec <= 255;
|
|
210
237
|
return typeof spec === "string" && spec.trim() !== "" && spec.trim().split(SPACES).every((token) => STYLES.has(token) || HEX.test(token));
|
|
211
238
|
}
|
|
212
|
-
var CUBE = [0, 95, 135, 175, 215, 255];
|
|
213
239
|
function cubeLevel(channel) {
|
|
214
240
|
return CUBE.reduce((best, value, level) => Math.abs(value - channel) < Math.abs(CUBE[best] - channel) ? level : best, 0);
|
|
215
241
|
}
|
|
@@ -234,6 +260,9 @@ function tinted(colors, spec, env = process5.env) {
|
|
|
234
260
|
return chain[token] ?? chain;
|
|
235
261
|
}, colors);
|
|
236
262
|
}
|
|
263
|
+
function shaded(theme, colors, glyph, cells, width, env = process5.env) {
|
|
264
|
+
return Array.from({ length: cells }, (_, index) => tinted(colors, gradientAt(theme, width <= 1 ? 0 : index / (width - 1)) ?? theme.colors.accent, env)(glyph)).join("");
|
|
265
|
+
}
|
|
237
266
|
function isRecord(value) {
|
|
238
267
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
239
268
|
}
|
|
@@ -314,7 +343,6 @@ function applyFile(theme, file, where, warn) {
|
|
|
314
343
|
function endsWalk(home) {
|
|
315
344
|
return (dir) => dir === resolve2(home) || existsSync3(join3(dir, ".git"));
|
|
316
345
|
}
|
|
317
|
-
var warned = new Set;
|
|
318
346
|
function warnOnce(message) {
|
|
319
347
|
if (warned.has(message))
|
|
320
348
|
return;
|
|
@@ -351,8 +379,6 @@ function loadTheme({ env = process5.env, from = process5.cwd(), home = homedir2(
|
|
|
351
379
|
}
|
|
352
380
|
return { theme, sources, preset };
|
|
353
381
|
}
|
|
354
|
-
var current;
|
|
355
|
-
var currentKey = "";
|
|
356
382
|
function activeTheme() {
|
|
357
383
|
const key = `${process5.cwd()}\x00${process5.env.KIT_THEME ?? ""}\x00${process5.env.XDG_CONFIG_HOME ?? ""}`;
|
|
358
384
|
if (current === undefined || key !== currentKey) {
|
|
@@ -361,9 +387,40 @@ function activeTheme() {
|
|
|
361
387
|
}
|
|
362
388
|
return current;
|
|
363
389
|
}
|
|
390
|
+
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 = "";
|
|
391
|
+
var init_theme = __esm(() => {
|
|
392
|
+
init_config();
|
|
393
|
+
init_user_config();
|
|
394
|
+
ENDS = new Map;
|
|
395
|
+
DEFAULT = {
|
|
396
|
+
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" },
|
|
397
|
+
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" },
|
|
398
|
+
accents: ["cyan", "magenta", "green", "blue", "yellow", "redBright"],
|
|
399
|
+
bins: {},
|
|
400
|
+
gradient: ["#c084fc", "#67e8f9"]
|
|
401
|
+
};
|
|
402
|
+
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" };
|
|
403
|
+
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" };
|
|
404
|
+
ASCII = { ok: "+", warn: "!", problem: "x", note: ">", plan: "?", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#", rule: "-", corner: "+", open: "*", leaf: "-", guide: "|" };
|
|
405
|
+
PRESETS = {
|
|
406
|
+
default: {},
|
|
407
|
+
"high-contrast": { colors: BRIGHT, accents: ["cyanBright", "magentaBright", "greenBright", "blueBright", "yellowBright", "redBright"], gradient: ["#d8b4fe", "#a5f3fc"] },
|
|
408
|
+
mono: { colors: MONO, accents: ["bold"], gradient: undefined },
|
|
409
|
+
ascii: { glyphs: ASCII }
|
|
410
|
+
};
|
|
411
|
+
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"]);
|
|
412
|
+
HEX = /^#[0-9a-f]{6}$/i;
|
|
413
|
+
CONTROL = /\p{Cc}/u;
|
|
414
|
+
MAX_FILE_BYTES = 64 * 1024;
|
|
415
|
+
SPACES = /\s+/;
|
|
416
|
+
CUBE = [0, 95, 135, 175, 215, 255];
|
|
417
|
+
warned = new Set;
|
|
418
|
+
});
|
|
364
419
|
|
|
365
420
|
// ../kit/src/style.ts
|
|
366
|
-
|
|
421
|
+
import { resolve as resolve3 } from "path";
|
|
422
|
+
import process6 from "process";
|
|
423
|
+
import { pathToFileURL } from "url";
|
|
367
424
|
function takesControlCodes(stream, env = process6.env) {
|
|
368
425
|
return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb" && outputMode(stream, env) === "terminal";
|
|
369
426
|
}
|
|
@@ -386,14 +443,6 @@ function role(name, stream, env = process6.env) {
|
|
|
386
443
|
const colors = paint(stream, env);
|
|
387
444
|
return takesControlCodes(stream, env) ? tinted(colors, activeTheme().theme.colors[name], env) : colors;
|
|
388
445
|
}
|
|
389
|
-
var STATUS_WORDS = {
|
|
390
|
-
passed: ["passed", "success", "succeeded", "ok"],
|
|
391
|
-
failed: ["failed", "failure", "error", "errored"],
|
|
392
|
-
running: ["running", "in_progress", "started", "holding"],
|
|
393
|
-
queued: ["queued", "waiting", "pending", "created", "blocked", "scheduled"],
|
|
394
|
-
skipped: ["skipped", "cancelled", "canceled", "manual"]
|
|
395
|
-
};
|
|
396
|
-
var STATUS_OF = new Map(Object.entries(STATUS_WORDS).flatMap(([status, words]) => words.map((word) => [word, status])));
|
|
397
446
|
function header(bin, context, stream, env = process6.env) {
|
|
398
447
|
if (!takesControlCodes(stream, env))
|
|
399
448
|
return "";
|
|
@@ -420,9 +469,24 @@ function hyperlink(text, url, stream, env = process6.env) {
|
|
|
420
469
|
function fileLink(text, path, stream, from = process6.cwd(), env = process6.env) {
|
|
421
470
|
return hyperlink(text, pathToFileURL(resolve3(from, path)).href, stream, env);
|
|
422
471
|
}
|
|
472
|
+
var MARK_WORDS, STATUS_WORDS, STATUS_OF;
|
|
473
|
+
var init_style = __esm(() => {
|
|
474
|
+
init_colors();
|
|
475
|
+
init_mode();
|
|
476
|
+
init_theme();
|
|
477
|
+
MARK_WORDS = { ok: "ok:", warn: "warning:", problem: "error:", note: "note:", plan: "would:" };
|
|
478
|
+
STATUS_WORDS = {
|
|
479
|
+
passed: ["passed", "success", "succeeded", "ok"],
|
|
480
|
+
failed: ["failed", "failure", "error", "errored"],
|
|
481
|
+
running: ["running", "in_progress", "started", "holding"],
|
|
482
|
+
queued: ["queued", "waiting", "pending", "created", "blocked", "scheduled"],
|
|
483
|
+
skipped: ["skipped", "cancelled", "canceled", "manual"]
|
|
484
|
+
};
|
|
485
|
+
STATUS_OF = new Map(Object.entries(STATUS_WORDS).flatMap(([status, words]) => words.map((word) => [word, status])));
|
|
486
|
+
});
|
|
423
487
|
|
|
424
488
|
// ../kit/src/format.ts
|
|
425
|
-
|
|
489
|
+
import process7 from "process";
|
|
426
490
|
function formatSeconds(total) {
|
|
427
491
|
let rest = Math.max(0, Math.round(total));
|
|
428
492
|
const amounts = UNITS.map(([unit, size]) => {
|
|
@@ -439,15 +503,16 @@ function formatSeconds(total) {
|
|
|
439
503
|
function formatDuration(ms) {
|
|
440
504
|
return ms < 60000 ? `${(Math.max(0, ms) / 1000).toFixed(1)}s` : formatSeconds(ms / 1000);
|
|
441
505
|
}
|
|
506
|
+
function formatElapsed(ms) {
|
|
507
|
+
return formatSeconds(Math.floor(Math.max(0, ms) / 1000));
|
|
508
|
+
}
|
|
442
509
|
function upTo(text, separator) {
|
|
443
510
|
const end = text.indexOf(separator);
|
|
444
511
|
return end === -1 ? text : text.slice(0, end);
|
|
445
512
|
}
|
|
446
513
|
function truncate(text, width) {
|
|
447
|
-
return
|
|
514
|
+
return Ao(text, width, { suffix: "\u2026", includeSuffix: true });
|
|
448
515
|
}
|
|
449
|
-
var LINE_BREAKS = /\s*\n\s*/g;
|
|
450
|
-
var ESCAPE = String.fromCharCode(27);
|
|
451
516
|
function textWidth(text) {
|
|
452
517
|
return Bun.stringWidth(text);
|
|
453
518
|
}
|
|
@@ -496,14 +561,40 @@ function jsonText(value, replacer, { stream = process7.stdout, env = process7.en
|
|
|
496
561
|
function printJson(value) {
|
|
497
562
|
console.log(jsonText(value));
|
|
498
563
|
}
|
|
564
|
+
var UNITS, LINE_BREAKS, ESCAPE;
|
|
565
|
+
var init_format = __esm(() => {
|
|
566
|
+
init_text();
|
|
567
|
+
init_mode();
|
|
568
|
+
init_style();
|
|
569
|
+
UNITS = [["d", 86400], ["h", 3600], ["m", 60], ["s", 1]];
|
|
570
|
+
LINE_BREAKS = /\s*\n\s*/g;
|
|
571
|
+
ESCAPE = String.fromCharCode(27);
|
|
572
|
+
});
|
|
499
573
|
|
|
500
574
|
// ../kit/src/help.ts
|
|
501
575
|
import process8 from "process";
|
|
502
|
-
var OPTIONAL = /(?<!\x1B)\[[^\]]+\]/g;
|
|
503
|
-
var USAGE_PREFIX = /^usage:\s*/i;
|
|
504
|
-
var FULL_STOP = /\.$/;
|
|
505
576
|
function usageLine(usage, colors = paint(process8.stdout)) {
|
|
506
|
-
|
|
577
|
+
const lines = usage.replace(USAGE_PREFIX, "").split(`
|
|
578
|
+
`);
|
|
579
|
+
const blank = lines.indexOf("");
|
|
580
|
+
const synopses = blank === -1 ? lines : lines.slice(0, blank);
|
|
581
|
+
const details = blank === -1 ? [] : lines.slice(blank + 1);
|
|
582
|
+
const colon = synopses[0].indexOf(": ");
|
|
583
|
+
const inline = synopses[0].slice(colon + 2);
|
|
584
|
+
const summary = colon === -1 ? details.shift() : `${inline.charAt(0).toUpperCase()}${inline.slice(1)}`;
|
|
585
|
+
if (colon !== -1)
|
|
586
|
+
synopses[0] = synopses[0].slice(0, colon);
|
|
587
|
+
const head = `${colors.bold("Usage:")} ${synopses.map((line) => line.replaceAll(OPTIONAL, (part) => colors.dim(part))).join(`
|
|
588
|
+
`)}`;
|
|
589
|
+
const lead = summary === undefined ? [] : ["", colors.bold(prose(summary, colors))];
|
|
590
|
+
const rest = details.length === 0 ? [] : ["", ...details.map((line) => prose(line, colors))];
|
|
591
|
+
return [head, ...lead, ...rest].join(`
|
|
592
|
+
`);
|
|
593
|
+
}
|
|
594
|
+
function prose(line, colors) {
|
|
595
|
+
if (colors.cyan("x") === "x")
|
|
596
|
+
return line;
|
|
597
|
+
return line.replaceAll(PROSE_MARKS, (match, code, flag) => code === undefined ? colors.cyan(flag ?? match) : colors.bold(code));
|
|
507
598
|
}
|
|
508
599
|
function helpText(usage, options, colors = paint(process8.stdout), { examples = [], exits = [] } = {}) {
|
|
509
600
|
return [usageLine(usage, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
|
|
@@ -538,7 +629,6 @@ function exampleRows(examples, colors = paint(process8.stdout)) {
|
|
|
538
629
|
return [];
|
|
539
630
|
return ["", colors.bold("Examples:"), ...examples.map((example) => typeof example === "string" ? ` ${example}` : ` ${example[0]} ${colors.dim(`# ${example[1]}`)}`)];
|
|
540
631
|
}
|
|
541
|
-
var MAX_INLINE_CHOICES = 24;
|
|
542
632
|
function optionRows(options, colors = paint(process8.stdout)) {
|
|
543
633
|
const rows = Object.entries(options).map(([name, option]) => {
|
|
544
634
|
const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
|
|
@@ -553,6 +643,15 @@ function optionRows(options, colors = paint(process8.stdout)) {
|
|
|
553
643
|
const width = Math.max(0, ...rows.map((row) => row.width));
|
|
554
644
|
return rows.map((row) => row.description === "" ? ` ${row.flag}` : ` ${row.flag}${" ".repeat(width - row.width)} ${colors.dim(row.description)}`);
|
|
555
645
|
}
|
|
646
|
+
var OPTIONAL, USAGE_PREFIX, FULL_STOP, PROSE_MARKS, MAX_INLINE_CHOICES = 24;
|
|
647
|
+
var init_help = __esm(() => {
|
|
648
|
+
init_mode();
|
|
649
|
+
init_style();
|
|
650
|
+
OPTIONAL = /(?<!\x1B)\[[^\]]+\]/g;
|
|
651
|
+
USAGE_PREFIX = /^usage:\s*/i;
|
|
652
|
+
FULL_STOP = /\.$/;
|
|
653
|
+
PROSE_MARKS = /`([^`\n]+)`|(?<![\w-])(--[a-z][\w-]*|-[a-z](?![\w-]))/gi;
|
|
654
|
+
});
|
|
556
655
|
|
|
557
656
|
// ../kit/src/text.ts
|
|
558
657
|
function distance(a, b) {
|
|
@@ -580,9 +679,10 @@ function closest(name, names) {
|
|
|
580
679
|
const [best] = names.map((known) => ({ known, far: distance(name, known) })).sort((a, b) => a.far - b.far);
|
|
581
680
|
return best !== undefined && best.far <= (name.length < 4 ? 1 : 2) ? best.known : undefined;
|
|
582
681
|
}
|
|
682
|
+
var init_text2 = () => {};
|
|
683
|
+
|
|
583
684
|
// ../kit/src/input.ts
|
|
584
685
|
import { fstatSync } from "fs";
|
|
585
|
-
var WHOLE = /^\d+$/;
|
|
586
686
|
function wholeNumber(value, name, fallback, min = 1) {
|
|
587
687
|
if (value === undefined)
|
|
588
688
|
return fallback;
|
|
@@ -591,8 +691,6 @@ function wholeNumber(value, name, fallback, min = 1) {
|
|
|
591
691
|
badUsage(`${name.startsWith("<") ? name : `--${name}`} takes a whole number from ${min}, not ${value}`);
|
|
592
692
|
return number;
|
|
593
693
|
}
|
|
594
|
-
var DURATION = /^(\d+(?:\.\d+)?)(ms|[smhd])?$/;
|
|
595
|
-
var UNIT_MS = { ms: 1, s: 1000, m: 60000, h: 3600000, d: 86400000 };
|
|
596
694
|
function duration(value, name, fallback, unit = "s") {
|
|
597
695
|
if (value === undefined)
|
|
598
696
|
return fallback;
|
|
@@ -606,40 +704,27 @@ function isStdinPiped() {
|
|
|
606
704
|
const stat = fstatSync(0);
|
|
607
705
|
return stat.isFIFO() || stat.isFile();
|
|
608
706
|
}
|
|
707
|
+
var WHOLE, DURATION, UNIT_MS;
|
|
708
|
+
var init_input = __esm(() => {
|
|
709
|
+
init_args();
|
|
710
|
+
WHOLE = /^\d+$/;
|
|
711
|
+
DURATION = /^(\d+(?:\.\d+)?)(ms|[smhd])?$/;
|
|
712
|
+
UNIT_MS = { ms: 1, s: 1000, m: 60000, h: 3600000, d: 86400000 };
|
|
713
|
+
});
|
|
609
714
|
|
|
610
715
|
// ../kit/src/args.ts
|
|
611
|
-
|
|
716
|
+
import process9 from "process";
|
|
717
|
+
import { parseArgs } from "util";
|
|
612
718
|
function jsonOption(holds) {
|
|
613
719
|
return { type: "boolean", description: holds === undefined ? "print JSON" : `print JSON: ${holds}` };
|
|
614
720
|
}
|
|
615
|
-
class Exit extends Error {
|
|
616
|
-
code;
|
|
617
|
-
hint;
|
|
618
|
-
constructor(message, code, hint) {
|
|
619
|
-
super(message);
|
|
620
|
-
this.code = code;
|
|
621
|
-
this.hint = hint;
|
|
622
|
-
}
|
|
623
|
-
}
|
|
624
721
|
function fail(message, code = 2, hint) {
|
|
625
722
|
throw new Exit(message, code, hint);
|
|
626
723
|
}
|
|
627
|
-
|
|
628
|
-
class UsageError extends Exit {
|
|
629
|
-
constructor(message, hint) {
|
|
630
|
-
super(message, 2, hint);
|
|
631
|
-
}
|
|
632
|
-
}
|
|
633
724
|
function badUsage(message) {
|
|
634
725
|
throw new UsageError(message);
|
|
635
726
|
}
|
|
636
727
|
|
|
637
|
-
class HelpShown extends Exit {
|
|
638
|
-
constructor() {
|
|
639
|
-
super("help shown", 0);
|
|
640
|
-
}
|
|
641
|
-
}
|
|
642
|
-
|
|
643
728
|
class Completing {
|
|
644
729
|
options;
|
|
645
730
|
positionals;
|
|
@@ -650,11 +735,6 @@ class Completing {
|
|
|
650
735
|
this.candidates = candidates;
|
|
651
736
|
}
|
|
652
737
|
}
|
|
653
|
-
var completion = { active: false };
|
|
654
|
-
var OUTPUT_OPTIONS = {
|
|
655
|
-
color: { type: "string", choices: ["auto", "always", "never"], description: "auto (the default) colours on a terminal alone" },
|
|
656
|
-
plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
|
|
657
|
-
};
|
|
658
738
|
function applyOutput(color, plain, env = process9.env) {
|
|
659
739
|
const when = plain === true ? "never" : color ?? "auto";
|
|
660
740
|
if (when === "auto")
|
|
@@ -808,7 +888,6 @@ function parseError(error) {
|
|
|
808
888
|
const message = upTo(error instanceof Error ? error.message : String(error), ". ");
|
|
809
889
|
return `${message.charAt(0).toLowerCase()}${message.slice(1)}`;
|
|
810
890
|
}
|
|
811
|
-
var UNKNOWN_OPTION = /^unknown option '(-[^']+)'/;
|
|
812
891
|
function nearestOption(message, options, allowNegative) {
|
|
813
892
|
const typed = UNKNOWN_OPTION.exec(message)?.[1];
|
|
814
893
|
if (typed === undefined)
|
|
@@ -824,6 +903,66 @@ function nearestOption(message, options, allowNegative) {
|
|
|
824
903
|
const meant = closest(word, known.map((flag) => flag.replace(DASHES, "")));
|
|
825
904
|
return meant === undefined ? undefined : `did you mean ${known.find((flag) => flag.replace(DASHES, "") === meant)}?`;
|
|
826
905
|
}
|
|
906
|
+
var DASHES, EXIT, Exit, UsageError, HelpShown, completion, OUTPUT_OPTIONS, UNKNOWN_OPTION;
|
|
907
|
+
var init_args = __esm(() => {
|
|
908
|
+
init_format();
|
|
909
|
+
init_help();
|
|
910
|
+
init_text2();
|
|
911
|
+
init_help();
|
|
912
|
+
init_input();
|
|
913
|
+
DASHES = /^-+/;
|
|
914
|
+
EXIT = Symbol.for("@kaynooo/cli-kit/Exit");
|
|
915
|
+
Exit = class Exit extends Error {
|
|
916
|
+
code;
|
|
917
|
+
hint;
|
|
918
|
+
[EXIT] = true;
|
|
919
|
+
constructor(message, code, hint) {
|
|
920
|
+
super(message);
|
|
921
|
+
this.code = code;
|
|
922
|
+
this.hint = hint;
|
|
923
|
+
}
|
|
924
|
+
static [Symbol.hasInstance](value) {
|
|
925
|
+
if (this !== Exit)
|
|
926
|
+
return Function.prototype[Symbol.hasInstance].call(this, value);
|
|
927
|
+
return typeof value === "object" && value !== null && value[EXIT] === true;
|
|
928
|
+
}
|
|
929
|
+
};
|
|
930
|
+
UsageError = class UsageError extends Exit {
|
|
931
|
+
constructor(message, hint) {
|
|
932
|
+
super(message, 2, hint);
|
|
933
|
+
}
|
|
934
|
+
};
|
|
935
|
+
HelpShown = class HelpShown extends Exit {
|
|
936
|
+
constructor() {
|
|
937
|
+
super("help shown", 0);
|
|
938
|
+
}
|
|
939
|
+
};
|
|
940
|
+
completion = { active: false };
|
|
941
|
+
OUTPUT_OPTIONS = {
|
|
942
|
+
color: { type: "string", choices: ["auto", "always", "never"], description: "auto (the default) colours on a terminal alone" },
|
|
943
|
+
plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
|
|
944
|
+
};
|
|
945
|
+
UNKNOWN_OPTION = /^unknown option '(-[^']+)'/;
|
|
946
|
+
});
|
|
947
|
+
|
|
948
|
+
// ../kit/src/folders.ts
|
|
949
|
+
function ignoredFolders(extra = [], where = {}) {
|
|
950
|
+
const configured = readUserConfig("config", where).ignore;
|
|
951
|
+
const names = Array.isArray(configured) ? configured.filter((name) => typeof name === "string" && name !== "") : [];
|
|
952
|
+
return new Set([...SKIPPED_FOLDERS, ...extra, ...names]);
|
|
953
|
+
}
|
|
954
|
+
var SKIPPED_FOLDERS;
|
|
955
|
+
var init_folders = __esm(() => {
|
|
956
|
+
init_user_config();
|
|
957
|
+
SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
|
|
958
|
+
});
|
|
959
|
+
|
|
960
|
+
// src/cli.ts
|
|
961
|
+
import process21 from "process";
|
|
962
|
+
|
|
963
|
+
// ../kit/src/index.ts
|
|
964
|
+
init_args();
|
|
965
|
+
|
|
827
966
|
// ../kit/src/argv.ts
|
|
828
967
|
import { readFileSync as readFileSync3, realpathSync } from "fs";
|
|
829
968
|
import { resolve as resolve4 } from "path";
|
|
@@ -848,10 +987,24 @@ function scriptArgs(argv = process10.argv.slice(2), cmdline = commandLine(), scr
|
|
|
848
987
|
const after = at === -1 ? [] : cmdline.slice(at + 1);
|
|
849
988
|
return after[0] === "--" && after.length === argv.length + 1 && argv.every((word, index) => word === after[index + 1]) ? after : argv;
|
|
850
989
|
}
|
|
990
|
+
// ../kit/src/chart.ts
|
|
991
|
+
init_format();
|
|
992
|
+
init_mode();
|
|
993
|
+
init_style();
|
|
994
|
+
init_theme();
|
|
995
|
+
// ../kit/src/ci.ts
|
|
996
|
+
init_args();
|
|
997
|
+
init_format();
|
|
998
|
+
|
|
999
|
+
// ../kit/src/progress.ts
|
|
1000
|
+
init_format();
|
|
1001
|
+
import process12 from "process";
|
|
1002
|
+
|
|
851
1003
|
// ../kit/src/process.ts
|
|
852
1004
|
import { constants } from "os";
|
|
853
1005
|
import process11 from "process";
|
|
854
1006
|
var KILL_GRACE_MS = 2000;
|
|
1007
|
+
var SIGNALS = ["SIGINT", "SIGTERM", "SIGHUP"];
|
|
855
1008
|
function exitCodeOf(code, signal) {
|
|
856
1009
|
if (code !== null)
|
|
857
1010
|
return code;
|
|
@@ -859,10 +1012,41 @@ function exitCodeOf(code, signal) {
|
|
|
859
1012
|
return 128 + signal;
|
|
860
1013
|
return signal === null ? 129 : 128 + constants.signals[signal];
|
|
861
1014
|
}
|
|
862
|
-
|
|
1015
|
+
function holdSignals(cleanup) {
|
|
1016
|
+
let received;
|
|
1017
|
+
let child;
|
|
1018
|
+
const held = {
|
|
1019
|
+
get signal() {
|
|
1020
|
+
return received;
|
|
1021
|
+
},
|
|
1022
|
+
forward: (to) => {
|
|
1023
|
+
child = to;
|
|
1024
|
+
},
|
|
1025
|
+
release: () => {
|
|
1026
|
+
for (const signal of SIGNALS)
|
|
1027
|
+
process11.off(signal, onSignal);
|
|
1028
|
+
}
|
|
1029
|
+
};
|
|
1030
|
+
function onSignal(signal) {
|
|
1031
|
+
received = signal;
|
|
1032
|
+
if (child !== undefined) {
|
|
1033
|
+
child.kill(signal);
|
|
1034
|
+
return;
|
|
1035
|
+
}
|
|
1036
|
+
if (cleanup === undefined)
|
|
1037
|
+
return;
|
|
1038
|
+
held.release();
|
|
1039
|
+
cleanup(signal);
|
|
1040
|
+
process11.kill(process11.pid, signal);
|
|
1041
|
+
}
|
|
1042
|
+
for (const signal of SIGNALS)
|
|
1043
|
+
process11.on(signal, onSignal);
|
|
1044
|
+
return held;
|
|
1045
|
+
}
|
|
1046
|
+
async function runCommand(argv, { cwd, env, stdin = "ignore", input, timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
|
|
863
1047
|
const chunks = [];
|
|
864
1048
|
const grouped = timeoutMs !== undefined || signal !== undefined || onStart !== undefined || onChunk !== undefined;
|
|
865
|
-
const proc = Bun.spawn(argv, { ...cwd === undefined ? {} : { cwd }, ...env === undefined ? {} : { env }, stdin, stdout: "pipe", stderr: "pipe", ...grouped ? { detached: true } : {} });
|
|
1049
|
+
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 } : {} });
|
|
866
1050
|
const state = { kept: 0, truncated: false, timedOut: false, failure: undefined, done: false };
|
|
867
1051
|
const timers = [];
|
|
868
1052
|
const killGroup = (killing) => {
|
|
@@ -939,14 +1123,273 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
|
|
|
939
1123
|
}
|
|
940
1124
|
|
|
941
1125
|
// ../kit/src/progress.ts
|
|
1126
|
+
init_style();
|
|
1127
|
+
init_theme();
|
|
1128
|
+
var FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
|
|
1129
|
+
var FRAME_MS = 200;
|
|
1130
|
+
var BAR_WIDTH = 20;
|
|
1131
|
+
var CLEAR_BELOW = "\r\x1B[J";
|
|
942
1132
|
var ESC = String.fromCharCode(27);
|
|
943
1133
|
var ESCAPE_CODE = new RegExp(`${ESC}(?:\\[[\\x30-\\x3F]*[\\x20-\\x2F]*[\\x40-\\x7E]|\\][^\\u0007${ESC}]*(?:\\u0007|${ESC}\\\\))`, "y");
|
|
944
1134
|
var RESET_STYLE = `${ESC}[0m`;
|
|
1135
|
+
var CTRL_C = 3;
|
|
945
1136
|
var CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
|
|
1137
|
+
var CONSOLE_METHODS = ["log", "info", "warn", "error", "debug", "dir", "dirxml", "table", "trace", "group", "groupCollapsed", "count", "timeEnd", "timeLog", "assert"];
|
|
1138
|
+
function liveRegion(render, stream = process12.stderr, env = process12.env) {
|
|
1139
|
+
if (!takesControlCodes(stream, env))
|
|
1140
|
+
return { redraw: () => {
|
|
1141
|
+
return;
|
|
1142
|
+
}, print: (text) => void stream.write(`${text}
|
|
1143
|
+
`), stop: () => {
|
|
1144
|
+
return;
|
|
1145
|
+
}, pause: () => () => {
|
|
1146
|
+
return;
|
|
1147
|
+
} };
|
|
1148
|
+
const write = stream.write.bind(stream);
|
|
1149
|
+
let frame = 0;
|
|
1150
|
+
let drawn = false;
|
|
1151
|
+
let paused = false;
|
|
1152
|
+
let stopped = false;
|
|
1153
|
+
const columns = () => {
|
|
1154
|
+
const now = stream.getWindowSize?.()[0] ?? stream.columns;
|
|
1155
|
+
return now === undefined || now === 0 ? 80 : now;
|
|
1156
|
+
};
|
|
1157
|
+
const clear = () => {
|
|
1158
|
+
if (drawn)
|
|
1159
|
+
write(CLEAR_BELOW);
|
|
1160
|
+
drawn = false;
|
|
1161
|
+
};
|
|
1162
|
+
const draw = () => {
|
|
1163
|
+
if (paused)
|
|
1164
|
+
return;
|
|
1165
|
+
const width = columns() - 1;
|
|
1166
|
+
const height = stream.rows === undefined || stream.rows === 0 ? 24 : stream.rows;
|
|
1167
|
+
const lines = render(FRAMES[frame++ % FRAMES.length]).slice(0, Math.max(1, height - 1)).map((line) => cutToWidth(line, width));
|
|
1168
|
+
if (lines.length === 0) {
|
|
1169
|
+
clear();
|
|
1170
|
+
return;
|
|
1171
|
+
}
|
|
1172
|
+
write(`${CLEAR_BELOW}${lines.join(`
|
|
1173
|
+
`)}${lines.length > 1 ? `\x1B[${lines.length - 1}A` : ""}\r`);
|
|
1174
|
+
drawn = true;
|
|
1175
|
+
};
|
|
1176
|
+
let timer = setInterval(draw, FRAME_MS);
|
|
1177
|
+
stream.on?.("resize", draw);
|
|
1178
|
+
let restore = interceptOutput(clear);
|
|
1179
|
+
let release = swallowInput();
|
|
1180
|
+
const onExit = () => {
|
|
1181
|
+
clear();
|
|
1182
|
+
release();
|
|
1183
|
+
};
|
|
1184
|
+
const signals = holdSignals(stop);
|
|
1185
|
+
function stop() {
|
|
1186
|
+
stopped = true;
|
|
1187
|
+
clearInterval(timer);
|
|
1188
|
+
stream.off?.("resize", draw);
|
|
1189
|
+
clear();
|
|
1190
|
+
restore();
|
|
1191
|
+
release();
|
|
1192
|
+
process12.off("exit", onExit);
|
|
1193
|
+
signals.release();
|
|
1194
|
+
}
|
|
1195
|
+
function pause() {
|
|
1196
|
+
if (paused || stopped)
|
|
1197
|
+
return () => {
|
|
1198
|
+
return;
|
|
1199
|
+
};
|
|
1200
|
+
paused = true;
|
|
1201
|
+
clearInterval(timer);
|
|
1202
|
+
stream.off?.("resize", draw);
|
|
1203
|
+
clear();
|
|
1204
|
+
restore();
|
|
1205
|
+
release();
|
|
1206
|
+
return () => {
|
|
1207
|
+
if (!paused || stopped)
|
|
1208
|
+
return;
|
|
1209
|
+
paused = false;
|
|
1210
|
+
timer = setInterval(draw, FRAME_MS);
|
|
1211
|
+
timer.unref();
|
|
1212
|
+
stream.on?.("resize", draw);
|
|
1213
|
+
restore = interceptOutput(clear);
|
|
1214
|
+
release = swallowInput();
|
|
1215
|
+
draw();
|
|
1216
|
+
};
|
|
1217
|
+
}
|
|
1218
|
+
timer.unref();
|
|
1219
|
+
process12.on("exit", onExit);
|
|
1220
|
+
return {
|
|
1221
|
+
redraw: draw,
|
|
1222
|
+
print: (text) => {
|
|
1223
|
+
clear();
|
|
1224
|
+
write(`${text}
|
|
1225
|
+
`);
|
|
1226
|
+
draw();
|
|
1227
|
+
},
|
|
1228
|
+
stop,
|
|
1229
|
+
pause
|
|
1230
|
+
};
|
|
1231
|
+
}
|
|
1232
|
+
function progressLine(stream = process12.stderr, env = process12.env) {
|
|
1233
|
+
const colors = paint(stream, env);
|
|
1234
|
+
const write = stream.write.bind(stream);
|
|
1235
|
+
const begun = performance.now();
|
|
1236
|
+
let started = begun;
|
|
1237
|
+
let current;
|
|
1238
|
+
const region = liveRegion((spinner) => current === undefined ? [] : [tintedParts(progressParts(current, spinner, performance.now() - started), colors)], stream, env);
|
|
1239
|
+
const end = (line) => {
|
|
1240
|
+
region.stop();
|
|
1241
|
+
write(`${line}
|
|
1242
|
+
`);
|
|
1243
|
+
};
|
|
1244
|
+
return {
|
|
1245
|
+
update: (progress) => {
|
|
1246
|
+
const step = current?.step;
|
|
1247
|
+
current = progress;
|
|
1248
|
+
if (progress.step !== step) {
|
|
1249
|
+
started = performance.now();
|
|
1250
|
+
region.redraw();
|
|
1251
|
+
}
|
|
1252
|
+
},
|
|
1253
|
+
stop: region.stop,
|
|
1254
|
+
pause: region.pause,
|
|
1255
|
+
done: (text) => end(marked("ok", text, stream, formatDuration(performance.now() - begun), env)),
|
|
1256
|
+
failed: (text) => end(marked("problem", text, stream, undefined, env))
|
|
1257
|
+
};
|
|
1258
|
+
}
|
|
1259
|
+
function progressParts({ step, done, total, unit }, spinner, ms) {
|
|
1260
|
+
const { theme } = activeTheme();
|
|
1261
|
+
const parts = [{ text: spinner, tint: (colors) => tinted(colors, theme.colors.accent) }, { text: ` ${step}`, tint: () => plain }];
|
|
1262
|
+
if (total !== undefined && total > 0) {
|
|
1263
|
+
const counted = Math.min(done ?? 0, total);
|
|
1264
|
+
const filled = Math.round(counted / total * BAR_WIDTH);
|
|
1265
|
+
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 });
|
|
1266
|
+
}
|
|
1267
|
+
parts.push({ text: ` ${formatElapsed(ms)}`, tint: (colors) => colors.dim });
|
|
1268
|
+
return parts;
|
|
1269
|
+
}
|
|
1270
|
+
function plain(text) {
|
|
1271
|
+
return text;
|
|
1272
|
+
}
|
|
1273
|
+
function tintedParts(parts, colors) {
|
|
1274
|
+
return parts.map(({ text, tint }) => tint(colors)(text)).join("");
|
|
1275
|
+
}
|
|
1276
|
+
function cutToWidth(line, width) {
|
|
1277
|
+
if (Bun.stringWidth(line) <= width)
|
|
1278
|
+
return line;
|
|
1279
|
+
let room = width;
|
|
1280
|
+
let kept = "";
|
|
1281
|
+
let index = 0;
|
|
1282
|
+
let linked = false;
|
|
1283
|
+
while (index < line.length) {
|
|
1284
|
+
ESCAPE_CODE.lastIndex = index;
|
|
1285
|
+
const escape = ESCAPE_CODE.exec(line);
|
|
1286
|
+
if (escape !== null) {
|
|
1287
|
+
kept += escape[0];
|
|
1288
|
+
linked ||= escape[0].startsWith(`${ESC}]`);
|
|
1289
|
+
index = ESCAPE_CODE.lastIndex;
|
|
1290
|
+
continue;
|
|
1291
|
+
}
|
|
1292
|
+
const char = String.fromCodePoint(line.codePointAt(index));
|
|
1293
|
+
const columns = Bun.stringWidth(char);
|
|
1294
|
+
if (columns > room)
|
|
1295
|
+
break;
|
|
1296
|
+
kept += char;
|
|
1297
|
+
room -= columns;
|
|
1298
|
+
index += char.length;
|
|
1299
|
+
}
|
|
1300
|
+
return `${kept}${RESET_STYLE}${linked ? CLOSE_LINK : ""}`;
|
|
1301
|
+
}
|
|
1302
|
+
function swallowInput() {
|
|
1303
|
+
const input = process12.stdin;
|
|
1304
|
+
if (!input.isTTY)
|
|
1305
|
+
return () => {
|
|
1306
|
+
return;
|
|
1307
|
+
};
|
|
1308
|
+
const onData = (data) => {
|
|
1309
|
+
if (data.includes(CTRL_C))
|
|
1310
|
+
process12.kill(process12.pid, "SIGINT");
|
|
1311
|
+
};
|
|
1312
|
+
input.setRawMode(true);
|
|
1313
|
+
input.on("data", onData);
|
|
1314
|
+
input.resume();
|
|
1315
|
+
let released = false;
|
|
1316
|
+
return () => {
|
|
1317
|
+
if (released)
|
|
1318
|
+
return;
|
|
1319
|
+
released = true;
|
|
1320
|
+
input.off("data", onData);
|
|
1321
|
+
input.pause();
|
|
1322
|
+
input.setRawMode(false);
|
|
1323
|
+
};
|
|
1324
|
+
}
|
|
1325
|
+
function interceptOutput(clear) {
|
|
1326
|
+
const targets = [...CONSOLE_METHODS.map((name) => [console, name]), [process12.stdout, "write"], [process12.stderr, "write"]];
|
|
1327
|
+
const wrapped = targets.map(([target, name]) => {
|
|
1328
|
+
const original = Reflect.get(target, name);
|
|
1329
|
+
const wrapper = (...args) => {
|
|
1330
|
+
clear();
|
|
1331
|
+
return original.apply(target, args);
|
|
1332
|
+
};
|
|
1333
|
+
Reflect.set(target, name, wrapper);
|
|
1334
|
+
return { target, name, original, wrapper };
|
|
1335
|
+
});
|
|
1336
|
+
return () => {
|
|
1337
|
+
for (const { target, name, original, wrapper } of wrapped) {
|
|
1338
|
+
if (Reflect.get(target, name) === wrapper)
|
|
1339
|
+
Reflect.set(target, name, original);
|
|
1340
|
+
}
|
|
1341
|
+
};
|
|
1342
|
+
}
|
|
1343
|
+
|
|
1344
|
+
// ../kit/src/ci.ts
|
|
1345
|
+
init_style();
|
|
1346
|
+
|
|
1347
|
+
// ../kit/src/tool.ts
|
|
1348
|
+
init_format();
|
|
946
1349
|
// ../kit/src/cli.ts
|
|
1350
|
+
init_args();
|
|
947
1351
|
import { readFileSync as readFileSync4, realpathSync as realpathSync2 } from "fs";
|
|
948
1352
|
import { dirname as dirname3, join as join5 } from "path";
|
|
949
|
-
import
|
|
1353
|
+
import process16 from "process";
|
|
1354
|
+
|
|
1355
|
+
// ../kit/src/askpass.ts
|
|
1356
|
+
import process13 from "process";
|
|
1357
|
+
var SOCKET_VARIABLE = "KAYNOOO_ASKPASS_SOCKET";
|
|
1358
|
+
async function askpassClient(argv) {
|
|
1359
|
+
const socketPath = process13.env[SOCKET_VARIABLE];
|
|
1360
|
+
if (socketPath === undefined)
|
|
1361
|
+
return;
|
|
1362
|
+
const request = { prompt: argv[0] ?? "", ...process13.env.SSH_ASKPASS_PROMPT === "none" ? { notice: true } : {} };
|
|
1363
|
+
const { promise, resolve } = Promise.withResolvers();
|
|
1364
|
+
let received = "";
|
|
1365
|
+
try {
|
|
1366
|
+
await Bun.connect({
|
|
1367
|
+
unix: socketPath,
|
|
1368
|
+
socket: {
|
|
1369
|
+
open: (socket) => void socket.write(`${JSON.stringify(request)}
|
|
1370
|
+
`),
|
|
1371
|
+
data: (_, chunk) => {
|
|
1372
|
+
received += chunk.toString();
|
|
1373
|
+
},
|
|
1374
|
+
close: () => resolve(received),
|
|
1375
|
+
error: () => resolve("")
|
|
1376
|
+
}
|
|
1377
|
+
});
|
|
1378
|
+
} catch {
|
|
1379
|
+
return 1;
|
|
1380
|
+
}
|
|
1381
|
+
const reply = await promise;
|
|
1382
|
+
if (reply === "")
|
|
1383
|
+
return 1;
|
|
1384
|
+
const { answer } = JSON.parse(reply);
|
|
1385
|
+
if (request.notice === true)
|
|
1386
|
+
return 0;
|
|
1387
|
+
if (answer === undefined)
|
|
1388
|
+
return 1;
|
|
1389
|
+
process13.stdout.write(`${answer}
|
|
1390
|
+
`);
|
|
1391
|
+
return 0;
|
|
1392
|
+
}
|
|
950
1393
|
|
|
951
1394
|
// ../kit/src/completions.ts
|
|
952
1395
|
var COMPLETION_SHELLS = ["fish", "bash", "zsh"];
|
|
@@ -1009,28 +1452,34 @@ compdef __kaynooo_cli_complete ${bins.join(" ")}
|
|
|
1009
1452
|
}
|
|
1010
1453
|
|
|
1011
1454
|
// ../kit/src/notify.ts
|
|
1012
|
-
|
|
1455
|
+
init_format();
|
|
1456
|
+
init_mode();
|
|
1457
|
+
import process14 from "process";
|
|
1013
1458
|
var NOTIFY_AFTER_MS = 1e4;
|
|
1014
1459
|
var CANCELLED = 130;
|
|
1015
1460
|
function base64(text) {
|
|
1016
1461
|
return Buffer.from(text).toString("base64");
|
|
1017
1462
|
}
|
|
1018
|
-
function notification(title, body, env =
|
|
1019
|
-
const id = `kit${
|
|
1463
|
+
function notification(title, body, env = process14.env) {
|
|
1464
|
+
const id = `kit${process14.pid}`;
|
|
1020
1465
|
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\\`];
|
|
1021
1466
|
return codes.map((code) => env.TMUX === undefined || env.TMUX === "" ? code : `\x1BPtmux;${code.replaceAll("\x1B", "\x1B\x1B")}\x1B\\`).join("");
|
|
1022
1467
|
}
|
|
1023
|
-
function notifyEnd(command, code, ms, { stream =
|
|
1468
|
+
function notifyEnd(command, code, ms, { stream = process14.stderr, env = process14.env } = {}) {
|
|
1024
1469
|
if (ms < NOTIFY_AFTER_MS || code === CANCELLED || outputMode(stream, env) !== "terminal")
|
|
1025
1470
|
return;
|
|
1026
1471
|
stream.write(notification(command, code === 0 ? `done in ${formatDuration(ms)}` : `failed with exit ${code} after ${formatDuration(ms)}`, env));
|
|
1027
1472
|
}
|
|
1028
1473
|
|
|
1474
|
+
// ../kit/src/cli.ts
|
|
1475
|
+
init_style();
|
|
1476
|
+
init_text2();
|
|
1477
|
+
|
|
1029
1478
|
// ../kit/src/usage.ts
|
|
1030
1479
|
import { appendFileSync, mkdirSync } from "fs";
|
|
1031
1480
|
import { homedir as homedir3 } from "os";
|
|
1032
1481
|
import { dirname as dirname2, isAbsolute, join as join4 } from "path";
|
|
1033
|
-
import
|
|
1482
|
+
import process15 from "process";
|
|
1034
1483
|
|
|
1035
1484
|
// ../kit/src/logs.ts
|
|
1036
1485
|
var DAY_MS = 24 * 60 * 60 * 1000;
|
|
@@ -1044,14 +1493,14 @@ var usageError;
|
|
|
1044
1493
|
function noteUsageError(message) {
|
|
1045
1494
|
usageError = message;
|
|
1046
1495
|
}
|
|
1047
|
-
function stateHome(env =
|
|
1496
|
+
function stateHome(env = process15.env) {
|
|
1048
1497
|
const dir = env.XDG_STATE_HOME;
|
|
1049
1498
|
return dir !== undefined && isAbsolute(dir) ? dir : join4(homedir3(), ".local", "state");
|
|
1050
1499
|
}
|
|
1051
|
-
function usagePath(env =
|
|
1500
|
+
function usagePath(env = process15.env) {
|
|
1052
1501
|
return join4(stateHome(env), CLI_FOLDER, "usage.jsonl");
|
|
1053
1502
|
}
|
|
1054
|
-
function usageRecorded(env =
|
|
1503
|
+
function usageRecorded(env = process15.env) {
|
|
1055
1504
|
const off = env.KAYNOOO_CLI_NO_USAGE;
|
|
1056
1505
|
return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
|
|
1057
1506
|
}
|
|
@@ -1060,12 +1509,12 @@ function flagNames(argv) {
|
|
|
1060
1509
|
const names = (end === -1 ? argv : argv.slice(0, end)).filter((word) => word.startsWith("-") && word !== "-").map((word) => word.includes("=") ? word.slice(0, word.indexOf("=")) : word);
|
|
1061
1510
|
return [...new Set(names)].filter((name) => name.length <= LONGEST_NAME && FLAG_NAME.test(name));
|
|
1062
1511
|
}
|
|
1063
|
-
function usageEntry(bin, command, argv, code, now = new Date) {
|
|
1512
|
+
function usageEntry(bin, command, argv, code, { ms, now = new Date } = {}) {
|
|
1064
1513
|
const unknown = code === 2 && usageError !== undefined ? UNKNOWN_OPTION2.exec(usageError)?.[1] : undefined;
|
|
1065
1514
|
usageError = undefined;
|
|
1066
|
-
return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
|
|
1515
|
+
return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown }, ...ms === undefined ? {} : { ms: Math.round(ms) } };
|
|
1067
1516
|
}
|
|
1068
|
-
function recordUsage(entry, env =
|
|
1517
|
+
function recordUsage(entry, env = process15.env) {
|
|
1069
1518
|
if (!usageRecorded(env))
|
|
1070
1519
|
return;
|
|
1071
1520
|
try {
|
|
@@ -1159,8 +1608,8 @@ async function help2({ path, header, summary: lazySummary, commands, defaultComm
|
|
|
1159
1608
|
`);
|
|
1160
1609
|
}
|
|
1161
1610
|
function printError(prefix, message, hint, cause) {
|
|
1162
|
-
const colors = paint(
|
|
1163
|
-
const styled = takesControlCodes(
|
|
1611
|
+
const colors = paint(process16.stderr);
|
|
1612
|
+
const styled = takesControlCodes(process16.stderr);
|
|
1164
1613
|
const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
|
|
1165
1614
|
const under = (label, text, tint) => text === undefined ? "" : `
|
|
1166
1615
|
${styled ? tint(label) : `${label}:`} ${text}`;
|
|
@@ -1203,11 +1652,11 @@ async function dispatch(level, typed, { version, redact }) {
|
|
|
1203
1652
|
}
|
|
1204
1653
|
}
|
|
1205
1654
|
if (name === undefined && level.path.length > 1) {
|
|
1206
|
-
console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]),
|
|
1655
|
+
console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]), process16.stderr));
|
|
1207
1656
|
return 2;
|
|
1208
1657
|
}
|
|
1209
1658
|
if (name === undefined || name === "help" || name === "--help" || name === "-h") {
|
|
1210
|
-
console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]),
|
|
1659
|
+
console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]), process16.stdout));
|
|
1211
1660
|
return 0;
|
|
1212
1661
|
}
|
|
1213
1662
|
if (level.path.length === 1 && (name === "--version" || name === "-v")) {
|
|
@@ -1353,6 +1802,9 @@ function packageVersion(entry = Bun.main) {
|
|
|
1353
1802
|
}
|
|
1354
1803
|
async function runCli(cli, argv = scriptArgs()) {
|
|
1355
1804
|
const version = cli.version ?? packageVersion();
|
|
1805
|
+
const answered = await askpassClient(argv);
|
|
1806
|
+
if (answered !== undefined)
|
|
1807
|
+
return answered;
|
|
1356
1808
|
if (argv[0] === COMPLETE)
|
|
1357
1809
|
return printCandidates(candidates(scopeOf(cli.commands, cli.extraCommands, cli.aliases), cli.defaultCommand, argv.slice(1)));
|
|
1358
1810
|
if (argv[0] === COMPLETIONS || argv[0]?.startsWith(`${COMPLETIONS}=`) === true)
|
|
@@ -1363,7 +1815,7 @@ async function runCli(cli, argv = scriptArgs()) {
|
|
|
1363
1815
|
notifyEnd(command === undefined ? cli.name : `${cli.name} ${command}`, code, performance.now() - started);
|
|
1364
1816
|
if (cli.usage !== false) {
|
|
1365
1817
|
try {
|
|
1366
|
-
recordUsage(usageEntry(cli.name, command, argv, code));
|
|
1818
|
+
recordUsage(usageEntry(cli.name, command, argv, code, { ms: performance.now() - started }));
|
|
1367
1819
|
} catch {}
|
|
1368
1820
|
}
|
|
1369
1821
|
return code;
|
|
@@ -1383,38 +1835,21 @@ function commandPath(scope, argv) {
|
|
|
1383
1835
|
}
|
|
1384
1836
|
return path.length === 0 ? undefined : path.join(" ");
|
|
1385
1837
|
}
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
} catch (error) {
|
|
1400
|
-
code = reportThrown(name, error, redact, wantsJson(argv));
|
|
1401
|
-
}
|
|
1402
|
-
notifyEnd(name, code, performance.now() - started);
|
|
1403
|
-
if (usage !== false) {
|
|
1404
|
-
try {
|
|
1405
|
-
recordUsage(usageEntry(name, undefined, argv, code));
|
|
1406
|
-
} catch {}
|
|
1407
|
-
}
|
|
1408
|
-
return code;
|
|
1409
|
-
}
|
|
1410
|
-
// ../kit/src/folders.ts
|
|
1411
|
-
var SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
|
|
1412
|
-
function ignoredFolders(extra = [], where = {}) {
|
|
1413
|
-
const configured = readUserConfig("config", where).ignore;
|
|
1414
|
-
const names = Array.isArray(configured) ? configured.filter((name) => typeof name === "string" && name !== "") : [];
|
|
1415
|
-
return new Set([...SKIPPED_FOLDERS, ...extra, ...names]);
|
|
1416
|
-
}
|
|
1838
|
+
|
|
1839
|
+
// ../kit/src/index.ts
|
|
1840
|
+
init_config();
|
|
1841
|
+
|
|
1842
|
+
// ../kit/src/excerpt.ts
|
|
1843
|
+
init_text2();
|
|
1844
|
+
|
|
1845
|
+
// ../kit/src/index.ts
|
|
1846
|
+
init_folders();
|
|
1847
|
+
init_format();
|
|
1848
|
+
|
|
1849
|
+
// ../kit/src/git.ts
|
|
1850
|
+
init_args();
|
|
1417
1851
|
// ../kit/src/limit.ts
|
|
1852
|
+
init_args();
|
|
1418
1853
|
function limitOptions(fallback) {
|
|
1419
1854
|
return {
|
|
1420
1855
|
limit: { type: "string", short: "n", description: `show at most this many rows, the rest counted (${fallback})` },
|
|
@@ -1435,21 +1870,46 @@ function capped(rows, limit) {
|
|
|
1435
1870
|
const more = rows.length - limit;
|
|
1436
1871
|
return more > 0 ? { shown: rows.slice(0, limit), footer: moreFooter(more) } : { shown: [...rows], footer: undefined };
|
|
1437
1872
|
}
|
|
1873
|
+
|
|
1874
|
+
// ../kit/src/index.ts
|
|
1875
|
+
init_mode();
|
|
1876
|
+
|
|
1877
|
+
// ../kit/src/report.ts
|
|
1878
|
+
init_style();
|
|
1879
|
+
init_text2();
|
|
1438
1880
|
// ../kit/src/secrets.ts
|
|
1439
1881
|
var SECRET_WORDS = new Set(["key", "pass", "pwd", "auth", "salt", "cookie", "session", "jwt", "ssn", "iban", "card", "cvv", "otp"]);
|
|
1440
1882
|
// ../kit/src/sessions.ts
|
|
1441
1883
|
var {Glob } = globalThis.Bun;
|
|
1442
1884
|
var SESSION_FILES = new Glob("*.json");
|
|
1443
1885
|
var ACCOUNT_DIRS = new Glob("*/sessions");
|
|
1886
|
+
|
|
1887
|
+
// ../kit/src/index.ts
|
|
1888
|
+
init_style();
|
|
1889
|
+
init_text2();
|
|
1890
|
+
init_theme();
|
|
1891
|
+
init_user_config();
|
|
1892
|
+
|
|
1893
|
+
// ../kit/src/watch.ts
|
|
1894
|
+
init_args();
|
|
1895
|
+
init_input();
|
|
1896
|
+
init_style();
|
|
1897
|
+
// ../kit/src/workspace-root.ts
|
|
1898
|
+
init_user_config();
|
|
1444
1899
|
// src/hotspots.ts
|
|
1445
1900
|
import { basename, join as join7 } from "path";
|
|
1446
|
-
import
|
|
1901
|
+
import process18 from "process";
|
|
1447
1902
|
|
|
1448
1903
|
// src/churn.ts
|
|
1904
|
+
import { availableParallelism } from "os";
|
|
1449
1905
|
var SOURCE = /\.(?:[cm]?[jt]sx?|vue|svelte|astro|kay|py|go|rs|rb|php|java|kt|swift|cs|c|cc|cpp|h|hpp|scala|dart|lua|sh|zsh|fish)$/;
|
|
1450
1906
|
var TESTS = /(?:^|\/)(?:tests?|__tests__|spec|e2e|__mocks__|fixtures)\/|\.(?:test|spec|bench)\.[^/]+$|(?:^|\/)test_[^/]+$|_test\.(?:go|py)$/;
|
|
1451
1907
|
var GENERATED = /(?:^|\/)(?:dist|build|out|generated|\.nuxt|\.output|\.next)\/|\.min\.[cm]?js$|\.d\.ts$|\.(?:generated|gen)\.[^/]+$|\.pb\.go$|\.snap$/;
|
|
1452
1908
|
var LEADING_NEWLINE = /^\n/;
|
|
1909
|
+
var COMMITS_PER_RUN = 500;
|
|
1910
|
+
var MOST_RUNS = Math.max(1, Math.min(4, Math.floor(availableParallelism() / 2)));
|
|
1911
|
+
var COMMIT_START = 1;
|
|
1912
|
+
var LOG_FORMAT = ["--no-renames", "--numstat", "--format=%x01%ct%x02%ae", "-z"];
|
|
1453
1913
|
var GENERATED_HEADER = /@generated|generated by|do not edit/i;
|
|
1454
1914
|
var DECISION = /\b(?:if|elif|elsif|for|foreach|while|until|case|when|catch|except|rescue|match|guard|and|or)\b|&&|\|\||\?\?|\s\?(?![,):.?])/g;
|
|
1455
1915
|
var COMMENT_OR_STRING = /(\/\*[\s\S]*?\*\/|\/\/[^\n]*|^[ \t]*#[^\n]*)|'(?:\\.|[^'\\\n])*'|"(?:\\.|[^"\\\n])*"|`(?:\\.|[^`\\])*`/gm;
|
|
@@ -1462,14 +1922,40 @@ function isGenerated(text) {
|
|
|
1462
1922
|
function complexityOf(text) {
|
|
1463
1923
|
return 1 + (text.replace(COMMENT_OR_STRING, (_, comment) => comment === undefined ? '""' : "").match(DECISION)?.length ?? 0);
|
|
1464
1924
|
}
|
|
1465
|
-
async function
|
|
1466
|
-
const
|
|
1467
|
-
|
|
1925
|
+
async function readLog(cwd, commits, onProgress) {
|
|
1926
|
+
const runs = Math.min(MOST_RUNS, Math.ceil(commits.length / COMMITS_PER_RUN));
|
|
1927
|
+
const size = Math.ceil(commits.length / runs);
|
|
1928
|
+
let read = 0;
|
|
1929
|
+
const logs = await Promise.all(Array.from({ length: runs }, async (_, run) => runCommand(["git", "log", "--no-walk=unsorted", "--stdin", ...LOG_FORMAT], {
|
|
1930
|
+
cwd,
|
|
1931
|
+
input: `${commits.slice(run * size, (run + 1) * size).join(`
|
|
1932
|
+
`)}
|
|
1933
|
+
`,
|
|
1934
|
+
onChunk: ({ stream, data }) => {
|
|
1935
|
+
if (stream !== "stdout" || onProgress === undefined)
|
|
1936
|
+
return;
|
|
1937
|
+
for (const byte of data) {
|
|
1938
|
+
if (byte === COMMIT_START)
|
|
1939
|
+
read++;
|
|
1940
|
+
}
|
|
1941
|
+
onProgress(read, commits.length);
|
|
1942
|
+
}
|
|
1943
|
+
})));
|
|
1944
|
+
return logs.some((log) => log.code !== 0) ? undefined : logs.map((log) => log.text).join("");
|
|
1945
|
+
}
|
|
1946
|
+
async function churnSince(cwd, since, { bulk, halfLifeMs, now = Date.now(), onProgress }) {
|
|
1947
|
+
const [listed, top] = await Promise.all([runCommand(["git", "rev-list", `--since=${since}`, "HEAD"], { cwd }), runCommand(["git", "rev-parse", "--show-prefix"], { cwd })]);
|
|
1948
|
+
if (listed.code !== 0 || top.code !== 0)
|
|
1949
|
+
return;
|
|
1950
|
+
const commits = listed.text.split(`
|
|
1951
|
+
`).filter(Boolean);
|
|
1952
|
+
const log = commits.length === 0 ? "" : await readLog(cwd, commits, onProgress);
|
|
1953
|
+
if (log === undefined)
|
|
1468
1954
|
return;
|
|
1469
1955
|
const prefix = top.text.trim();
|
|
1470
1956
|
const churn = new Map;
|
|
1471
1957
|
const authors = new Map;
|
|
1472
|
-
for (const commit of log.
|
|
1958
|
+
for (const commit of log.split("\x01").slice(1)) {
|
|
1473
1959
|
const [head = "", ...entries] = commit.split("\x00");
|
|
1474
1960
|
const [stamp = "", author = ""] = head.split("\x02");
|
|
1475
1961
|
const all = entries.map((entry) => entry.replace(LEADING_NEWLINE, "")).filter((entry) => entry !== "").map((entry) => {
|
|
@@ -1589,11 +2075,9 @@ var DEFAULT_BULK = configuredNumber("hotspots", "bulk", 25);
|
|
|
1589
2075
|
var DAY_MS2 = 86400000;
|
|
1590
2076
|
var DEFAULT_HALF_LIFE = "90d";
|
|
1591
2077
|
var DEFAULT_COUNT = configuredNumber("hotspots", "limit", 20);
|
|
1592
|
-
var USAGE = `hotspots [options] [dir]: ranks the source files under dir (here by default) by complexity times churn, the ones both hard to read and often edited first, honouring .gitignore
|
|
2078
|
+
var USAGE = `src hotspots [options] [dir]: ranks the source files under dir (here by default) by complexity times churn, the ones both hard to read and often edited first, honouring .gitignore
|
|
1593
2079
|
|
|
1594
|
-
Complexity is the count of decision points in the file
|
|
1595
|
-
|
|
1596
|
-
Lists at most ${DEFAULT_COUNT} files, the count of the rest after them (--limit <n>, --full for all); --json is never cut unless --limit is given.`;
|
|
2080
|
+
Complexity is the count of decision points in the file plus one, churn the commits touching it since --since, score their product. A commit counts for less the older it is, and one touching more files than --bulk, a format or rename sweep, is left out. Each file also shows its lines changed, its author count ("solo" when one author wrote every change) and its most complex declaration. Test files and generated or built files are left out unless --all.`;
|
|
1597
2081
|
var EXITS = [[0, "it ranked the files"], [1, "no file has commits in the window"], [2, "a usage error or outside a git repository"]];
|
|
1598
2082
|
var OPTIONS = {
|
|
1599
2083
|
since: { type: "string", short: "s", description: `only count the commits since this date, as git reads it (${DEFAULT_SINCE})` },
|
|
@@ -1607,31 +2091,37 @@ var OPTIONS = {
|
|
|
1607
2091
|
var HOT = 0.66;
|
|
1608
2092
|
var WARM = 0.33;
|
|
1609
2093
|
async function hotspots(args) {
|
|
1610
|
-
const { values, positionals } = parse(args, USAGE, OPTIONS, { exits: EXITS, positionals: ["[dir]"], replaces: "guessing which files are worth splitting first", examples: ["hotspots", 'hotspots src --since "3 months ago" --limit 10'] });
|
|
2094
|
+
const { values, positionals } = parse(args, USAGE, OPTIONS, { exits: EXITS, positionals: ["[dir]"], replaces: "guessing which files are worth splitting first", examples: ["hotspots", 'src hotspots src --since "3 months ago" --limit 10'] });
|
|
1611
2095
|
if (positionals.length > 1)
|
|
1612
2096
|
badUsage("give one folder");
|
|
1613
2097
|
const count = limitOf(values, DEFAULT_COUNT);
|
|
1614
|
-
const cwd =
|
|
2098
|
+
const cwd = process18.cwd();
|
|
1615
2099
|
const bulk = Number(values.bulk ?? DEFAULT_BULK);
|
|
1616
2100
|
if (!Number.isInteger(bulk) || bulk < 1)
|
|
1617
2101
|
badUsage(`--bulk takes a number of files, not ${values.bulk}`);
|
|
1618
2102
|
const halfLifeMs = values["half-life"] === "0" ? 0 : duration(values["half-life"], "half-life", 90 * DAY_MS2);
|
|
1619
|
-
const
|
|
1620
|
-
if (churn === undefined)
|
|
1621
|
-
fail("not a git repository, churn comes from its log");
|
|
2103
|
+
const progress = progressLine();
|
|
1622
2104
|
const ranked = [];
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
2105
|
+
try {
|
|
2106
|
+
progress.update({ step: "reading the git log" });
|
|
2107
|
+
const churn = await churnSince(cwd, values.since ?? DEFAULT_SINCE, { bulk, halfLifeMs, onProgress: (done, total) => progress.update({ step: "reading the git log", done, total, unit: "commits" }) });
|
|
2108
|
+
if (churn === undefined)
|
|
2109
|
+
fail("not a git repository, churn comes from its log");
|
|
2110
|
+
const listed = (await listFiles(positionals[0] === undefined ? [] : [positionals[0]], cwd)).filter((path) => churn.has(path) && (values.all === true || isCandidate(path)));
|
|
2111
|
+
for (const [done, path] of listed.entries()) {
|
|
2112
|
+
progress.update({ step: "measuring the files", done, total: listed.length, unit: "files" });
|
|
2113
|
+
const touched = churn.get(path);
|
|
2114
|
+
const text = await readText(join7(cwd, path));
|
|
2115
|
+
if (text === undefined || values.all !== true && isGenerated(text))
|
|
2116
|
+
continue;
|
|
2117
|
+
const complexity = complexityOf(text);
|
|
2118
|
+
const worst = worstUnit(text, path);
|
|
2119
|
+
ranked.push({ path, score: Math.round(complexity * (values["by-lines"] === true ? touched.linesWeight : touched.weight)), churn: touched.commits, recent: Math.round(touched.weight * 10) / 10, changed: touched.lines, authors: touched.authors, solo: touched.authors === 1, complexity, worst: worst === undefined ? undefined : { name: worst.name, line: worst.line, complexity: worst.complexity }, lines: text.split(`
|
|
1633
2120
|
`).length - (text.endsWith(`
|
|
1634
2121
|
`) ? 1 : 0) });
|
|
2122
|
+
}
|
|
2123
|
+
} finally {
|
|
2124
|
+
progress.stop();
|
|
1635
2125
|
}
|
|
1636
2126
|
if (ranked.length === 0)
|
|
1637
2127
|
fail("no file with commits in that window", 1);
|
|
@@ -1642,8 +2132,8 @@ async function hotspots(args) {
|
|
|
1642
2132
|
printJson(shown);
|
|
1643
2133
|
return 0;
|
|
1644
2134
|
}
|
|
1645
|
-
const colors = paint(
|
|
1646
|
-
const path = role("path",
|
|
2135
|
+
const colors = paint(process18.stdout);
|
|
2136
|
+
const path = role("path", process18.stdout);
|
|
1647
2137
|
const top = shown.reduce((highest, row) => Math.max(highest, row.score), 0);
|
|
1648
2138
|
const heat = (score, text) => {
|
|
1649
2139
|
if (top > 0 && score >= top * HOT)
|
|
@@ -1651,7 +2141,7 @@ async function hotspots(args) {
|
|
|
1651
2141
|
return top > 0 && score >= top * WARM ? colors.yellow(text) : text;
|
|
1652
2142
|
};
|
|
1653
2143
|
printHeader("hotspots", `${basename(cwd)} \xB7 since ${values.since ?? DEFAULT_SINCE}`);
|
|
1654
|
-
console.log(table([["rank", "score", "churn", "recent", "changed", "authors", "complexity", "lines", "file", "most complex declaration"], ...shown.map((row) => [colors.dim(String(row.rank)), heat(row.score, String(row.score)), ...[row.churn, row.recent, row.changed].map(String), row.solo ? colors.dim("1 solo") : String(row.authors), ...[row.complexity, row.lines].map(String), fileLink(path(row.path), row.path,
|
|
2144
|
+
console.log(table([["rank", "score", "churn", "recent", "changed", "authors", "complexity", "lines", "file", "most complex declaration"], ...shown.map((row) => [colors.dim(String(row.rank)), heat(row.score, String(row.score)), ...[row.churn, row.recent, row.changed].map(String), row.solo ? colors.dim("1 solo") : String(row.authors), ...[row.complexity, row.lines].map(String), fileLink(path(row.path), row.path, process18.stdout, cwd), row.worst === undefined ? "" : `${row.worst.name} (${row.worst.complexity}, line ${row.worst.line})`])], { header: true, align: ["right", "right", "right", "right", "right", "right", "right", "right", "left", "left"] }));
|
|
1655
2145
|
if (footer !== undefined)
|
|
1656
2146
|
console.log(footer);
|
|
1657
2147
|
return 0;
|
|
@@ -1660,7 +2150,8 @@ async function hotspots(args) {
|
|
|
1660
2150
|
// src/peek.ts
|
|
1661
2151
|
import { realpathSync as realpathSync3 } from "fs";
|
|
1662
2152
|
import { isAbsolute as isAbsolute2, join as join8, relative as relative2, resolve as resolve5, sep } from "path";
|
|
1663
|
-
import
|
|
2153
|
+
import process19 from "process";
|
|
2154
|
+
init_text();
|
|
1664
2155
|
|
|
1665
2156
|
// src/source.ts
|
|
1666
2157
|
var LOCATION = /^(?:\.\/)?([^\s:()]+)(?::(\d+)(?::\d+)?|\((\d+),\d+\))(?=[:\s)]|$)/;
|
|
@@ -1837,17 +2328,15 @@ function locations(text) {
|
|
|
1837
2328
|
}
|
|
1838
2329
|
|
|
1839
2330
|
// src/peek.ts
|
|
1840
|
-
var USAGE2 = `peek [options] <file[:from-to]>...: prints files or line spans with their line numbers, several in one call
|
|
2331
|
+
var USAGE2 = `src peek [options] <file[:from-to]>...: prints files or line spans with their line numbers, several in one call
|
|
1841
2332
|
|
|
1842
|
-
peek src/a.ts:120-140 src/b.ts:1-40 the spans, src/a.ts:120 the one line, src/a.ts the whole file
|
|
1843
|
-
peek --def <symbol> [path...] the whole declaration of the symbol, its comments included, --def again for more symbols
|
|
1844
|
-
peek --refs <symbol> [path...] the lines naming the symbol, grouped by file, --defs-first printing its declarations before
|
|
1845
|
-
peek --outline <file>... the declarations and class members, a Markdown file's headings
|
|
1846
|
-
peek --around <regex> [-C 3] [path...] the lines around each match, overlapping ones merged
|
|
1847
|
-
<output> | peek [-C 3] the lines around each path:line the output opens a line with (errs, rg -n, grep -n, tsc, linters)
|
|
1848
|
-
The paths default to the files git keeps here (
|
|
1849
|
-
--refs lists at most 100 lines and --around prints at most 20 spans, the count of the rest after them (--limit <n>, --full for all).
|
|
1850
|
-
--json prints spans as [{path, from, to, lines}], --refs as [{path, line, text}] ({definitions, references} with --defs-first), --outline as [{path, line, depth, text}], the lines never cut and the rows never counted off unless --limit is given.`;
|
|
2333
|
+
src peek src/a.ts:120-140 src/b.ts:1-40 the spans, src/a.ts:120 the one line, src/a.ts the whole file
|
|
2334
|
+
src peek --def <symbol> [path...] the whole declaration of the symbol, its comments included, --def again for more symbols
|
|
2335
|
+
src peek --refs <symbol> [path...] the lines naming the symbol, grouped by file, --defs-first printing its declarations before
|
|
2336
|
+
src peek --outline <file>... the declarations and class members, a Markdown file's headings
|
|
2337
|
+
src peek --around <regex> [-C 3] [path...] the lines around each match, overlapping ones merged
|
|
2338
|
+
<output> | src peek [-C 3] the lines around each path:line the output opens a line with (errs, rg -n, grep -n, tsc, linters)
|
|
2339
|
+
The paths default to the files git keeps here (\`.gitignore\` holds).`;
|
|
1851
2340
|
var EXITS2 = [[0, "it printed something"], [1, "nothing is found, a file cannot be read or a span starts past the end"], [2, "a usage error or a path outside the repository"]];
|
|
1852
2341
|
var REFS_LIMIT = 100;
|
|
1853
2342
|
var AROUND_LIMIT = 20;
|
|
@@ -1860,7 +2349,7 @@ var OPTIONS2 = {
|
|
|
1860
2349
|
"defs-first": { type: "boolean", description: "with --refs, print the symbol's declarations before its lines" },
|
|
1861
2350
|
context: { type: "string", short: "C", description: "lines on each side of an --around match or a piped location (3)" },
|
|
1862
2351
|
...limitOptions(REFS_LIMIT),
|
|
1863
|
-
json: jsonOption()
|
|
2352
|
+
json: jsonOption("spans [{path, from, to, lines}], --refs [{path, line, text}] ({definitions, references} with --defs-first), --outline [{path, line, depth, text}]")
|
|
1864
2353
|
};
|
|
1865
2354
|
var TARGET = /^(.+?):(\d+)(?:-(\d+))?$/;
|
|
1866
2355
|
var LONGEST_LINE = 300;
|
|
@@ -1869,13 +2358,13 @@ function cut(text) {
|
|
|
1869
2358
|
return text.length > LONGEST_LINE ? `${text.slice(0, LONGEST_LINE - 1)}\u2026` : text;
|
|
1870
2359
|
}
|
|
1871
2360
|
async function readableRoot() {
|
|
1872
|
-
const ran = await runCommand(["git", "rev-parse", "--show-toplevel"], { cwd:
|
|
1873
|
-
return realpathSync3(ran.code === 0 ? ran.text.trim() :
|
|
2361
|
+
const ran = await runCommand(["git", "rev-parse", "--show-toplevel"], { cwd: process19.cwd() });
|
|
2362
|
+
return realpathSync3(ran.code === 0 ? ran.text.trim() : process19.cwd());
|
|
1874
2363
|
}
|
|
1875
2364
|
async function isOutside(path) {
|
|
1876
2365
|
let real;
|
|
1877
2366
|
try {
|
|
1878
|
-
real = realpathSync3(resolve5(
|
|
2367
|
+
real = realpathSync3(resolve5(process19.cwd(), path));
|
|
1879
2368
|
} catch {
|
|
1880
2369
|
return false;
|
|
1881
2370
|
}
|
|
@@ -1889,7 +2378,7 @@ async function checkInside(path) {
|
|
|
1889
2378
|
async function pipedSpans(text, context) {
|
|
1890
2379
|
const spans = [];
|
|
1891
2380
|
for (const [path, numbers] of locations(text)) {
|
|
1892
|
-
const source = await isOutside(path) ? undefined : await readText(resolve5(
|
|
2381
|
+
const source = await isOutside(path) ? undefined : await readText(resolve5(process19.cwd(), path));
|
|
1893
2382
|
if (source !== undefined)
|
|
1894
2383
|
spans.push(...spansAround(path, source.replace(TRAILING_NEWLINE2, "").split(`
|
|
1895
2384
|
`).length, numbers, context));
|
|
@@ -1898,7 +2387,7 @@ async function pipedSpans(text, context) {
|
|
|
1898
2387
|
}
|
|
1899
2388
|
async function textOf(path) {
|
|
1900
2389
|
await checkInside(path);
|
|
1901
|
-
const text = await readText(resolve5(
|
|
2390
|
+
const text = await readText(resolve5(process19.cwd(), path));
|
|
1902
2391
|
if (text === undefined)
|
|
1903
2392
|
fail(`cannot read ${path} (missing, binary or too large)`, 1);
|
|
1904
2393
|
return text;
|
|
@@ -1950,14 +2439,14 @@ async function spanOf(target) {
|
|
|
1950
2439
|
if (from < 1 || to < from)
|
|
1951
2440
|
badUsage(`${target}: a span reads <file>:<from>-<to>, from 1 and from <= to`);
|
|
1952
2441
|
if (from > count)
|
|
1953
|
-
fail(`${path} has ${
|
|
2442
|
+
fail(`${path} has ${bo(count, "line")}, ${target} starts past the end`, 1);
|
|
1954
2443
|
return { path, from, to: Math.min(to, count) };
|
|
1955
2444
|
}
|
|
1956
2445
|
async function* sources(paths) {
|
|
1957
2446
|
for (const path of paths)
|
|
1958
2447
|
await checkInside(path);
|
|
1959
|
-
for (const path of await listFiles(paths,
|
|
1960
|
-
const text = await readText(join8(
|
|
2448
|
+
for (const path of await listFiles(paths, process19.cwd())) {
|
|
2449
|
+
const text = await readText(join8(process19.cwd(), path));
|
|
1961
2450
|
if (text !== undefined)
|
|
1962
2451
|
yield { path, text };
|
|
1963
2452
|
}
|
|
@@ -1981,7 +2470,7 @@ async function definitionsOf(symbols, paths) {
|
|
|
1981
2470
|
return [...found.values()].flat();
|
|
1982
2471
|
}
|
|
1983
2472
|
async function peek(args) {
|
|
1984
|
-
const { values, positionals } = parse(args, USAGE2, OPTIONS2, { exits: EXITS2, positionals: ["[target...]"], replaces: "sed -n N,Mp, grep -n chains and whole-file reads", examples: [["peek src/a.ts:120-140 src/b.ts:1-40", "two spans in one call"], ["peek --def parseArgs src", "a whole declaration"]] });
|
|
2473
|
+
const { values, positionals } = parse(args, USAGE2, OPTIONS2, { exits: EXITS2, positionals: ["[target...]"], replaces: "sed -n N,Mp, grep -n chains and whole-file reads", examples: [["src peek src/a.ts:120-140 src/b.ts:1-40", "two spans in one call"], ["src peek --def parseArgs src", "a whole declaration"]] });
|
|
1985
2474
|
const modes = [values.def?.length === 0 ? undefined : values.def, values.refs, values.outline, values.around].filter((mode) => mode !== undefined && mode !== false);
|
|
1986
2475
|
const json = values.json === true;
|
|
1987
2476
|
if (values["defs-first"] === true && values.refs === undefined)
|
|
@@ -2058,7 +2547,7 @@ async function peek(args) {
|
|
|
2058
2547
|
|
|
2059
2548
|
// src/todo-scan.ts
|
|
2060
2549
|
import { join as join9 } from "path";
|
|
2061
|
-
import
|
|
2550
|
+
import process20 from "process";
|
|
2062
2551
|
|
|
2063
2552
|
// src/todo.ts
|
|
2064
2553
|
var COMMENT = /(?<![:\w/])\/\/|\/\*|<!--|(?:^|\s)(?:#|--)(?=\s)|^\s*\*(?=\s|$)/;
|
|
@@ -2163,13 +2652,10 @@ async function lookUp(refs, cwd) {
|
|
|
2163
2652
|
}
|
|
2164
2653
|
|
|
2165
2654
|
// src/todo-scan.ts
|
|
2166
|
-
var USAGE3 = `todo-scan [options] [path...]: lists the TODO, FIXME, HACK, XXX and owner/repo#N comments under the paths (here by default), each as <file>:<line>: <comment>, honouring .gitignore
|
|
2655
|
+
var USAGE3 = `src todo-scan [options] [path...]: lists the TODO, FIXME, HACK, XXX and owner/repo#N comments under the paths (here by default), each as <file>:<line>: <comment>, honouring .gitignore
|
|
2167
2656
|
|
|
2168
|
-
--older <duration> keeps
|
|
2169
|
-
|
|
2170
|
-
--stale keeps only the comments naming a closed issue, each issue's state looked up with ft, or gh for a GitHub repository, and exits 1 when it finds one.
|
|
2171
|
-
|
|
2172
|
-
Lists at most 100 comments, the count of the rest after them (--limit <n>, --full for all); --json is never cut unless --limit is given.`;
|
|
2657
|
+
--older <duration> keeps the comments whose line last changed longer ago than that (\`30d\`, \`12w\`, \`6m\`, dated by git blame) and shows each one's age.
|
|
2658
|
+
--stale keeps the comments naming a closed issue, looked up with \`ft\`, or \`gh\` for a GitHub repository, and exits 1 when it finds one.`;
|
|
2173
2659
|
var EXITS3 = [[0, "it listed the comments or found no stale one"], [1, "--stale finds one"], [2, "a usage error or when --stale could not look a repository up (ft and gh both failed)"]];
|
|
2174
2660
|
var LIST_LIMIT = 100;
|
|
2175
2661
|
var DAY_MS3 = 86400000;
|
|
@@ -2186,8 +2672,8 @@ function printLines(lines, footer) {
|
|
|
2186
2672
|
`));
|
|
2187
2673
|
}
|
|
2188
2674
|
async function todoScan(args) {
|
|
2189
|
-
const { values, positionals } = parse(args, USAGE3, OPTIONS3, { exits: EXITS3, positionals: ["[path...]"], replaces: "grep -rn TODO, then opening each issue it names", examples: ["todo-scan src", ["todo-scan --stale", "only the comments naming a closed issue"]] });
|
|
2190
|
-
const cwd =
|
|
2675
|
+
const { values, positionals } = parse(args, USAGE3, OPTIONS3, { exits: EXITS3, positionals: ["[path...]"], replaces: "grep -rn TODO, then opening each issue it names", examples: ["src todo-scan src", ["src todo-scan --stale", "only the comments naming a closed issue"]] });
|
|
2676
|
+
const cwd = process20.cwd();
|
|
2191
2677
|
const limit = limitOf(values, LIST_LIMIT);
|
|
2192
2678
|
const found = [];
|
|
2193
2679
|
for (const path of await listFiles(positionals, cwd)) {
|
|
@@ -2225,7 +2711,7 @@ async function todoScan(args) {
|
|
|
2225
2711
|
}
|
|
2226
2712
|
|
|
2227
2713
|
// src/cli.ts
|
|
2228
|
-
|
|
2714
|
+
process21.exitCode = await runCli({
|
|
2229
2715
|
name: "src",
|
|
2230
2716
|
about: "reads and ranks the source of a folder: line spans, TODO comments and the files worth splitting",
|
|
2231
2717
|
replaces: "sed -n N,Mp, grep -n chains and grep -rn TODO",
|