@kaynooo/cli-code 0.10.0 → 0.11.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/dist/cli.js +111 -67
- package/dist/hotspots-cli.js +101 -57
- package/dist/peek-cli.js +105 -61
- package/dist/todo-scan-cli.js +99 -55
- package/package.json +2 -2
package/dist/hotspots-cli.js
CHANGED
|
@@ -2,16 +2,34 @@
|
|
|
2
2
|
// @bun
|
|
3
3
|
|
|
4
4
|
// src/hotspots-cli.ts
|
|
5
|
-
import
|
|
5
|
+
import process15 from "process";
|
|
6
6
|
// ../kit/src/args.ts
|
|
7
|
-
import
|
|
7
|
+
import process9 from "process";
|
|
8
8
|
import { parseArgs } from "util";
|
|
9
9
|
|
|
10
10
|
// ../kit/src/format.ts
|
|
11
|
-
import
|
|
11
|
+
import process7 from "process";
|
|
12
|
+
|
|
13
|
+
// ../kit/src/mode.ts
|
|
14
|
+
import process2 from "process";
|
|
15
|
+
var MODES = new Set(["terminal", "ci", "agent", "pipe"]);
|
|
16
|
+
var AGENT_VARIABLES = ["CLAUDECODE", "AI_AGENT"];
|
|
17
|
+
function isSet(value) {
|
|
18
|
+
return value !== undefined && value !== "" && value !== "0" && value.toLowerCase() !== "false";
|
|
19
|
+
}
|
|
20
|
+
function outputMode(stream = process2.stdout, env = process2.env) {
|
|
21
|
+
const chosen = env.KIT_MODE;
|
|
22
|
+
if (chosen !== undefined && MODES.has(chosen))
|
|
23
|
+
return chosen;
|
|
24
|
+
if (AGENT_VARIABLES.some((name) => isSet(env[name])))
|
|
25
|
+
return "agent";
|
|
26
|
+
if (stream.isTTY === true)
|
|
27
|
+
return "terminal";
|
|
28
|
+
return isSet(env.CI) ? "ci" : "pipe";
|
|
29
|
+
}
|
|
12
30
|
|
|
13
31
|
// ../kit/src/style.ts
|
|
14
|
-
import
|
|
32
|
+
import process6 from "process";
|
|
15
33
|
|
|
16
34
|
// ../../node_modules/.bun/@kaynooo+utils@2.31.2+d0769e28dc4dad16/node_modules/@kaynooo/utils/dist/chunk-mtetydvc.js
|
|
17
35
|
function x(s) {
|
|
@@ -278,13 +296,13 @@ var t = le();
|
|
|
278
296
|
import { existsSync as existsSync2, readFileSync, statSync } from "fs";
|
|
279
297
|
import { homedir as homedir2 } from "os";
|
|
280
298
|
import { join as join3, resolve as resolve2 } from "path";
|
|
281
|
-
import
|
|
299
|
+
import process5 from "process";
|
|
282
300
|
|
|
283
301
|
// ../kit/src/config.ts
|
|
284
302
|
import { existsSync } from "fs";
|
|
285
303
|
import { dirname, join, resolve } from "path";
|
|
286
|
-
import
|
|
287
|
-
function findUp(names, from =
|
|
304
|
+
import process3 from "process";
|
|
305
|
+
function findUp(names, from = process3.cwd(), stop = () => false) {
|
|
288
306
|
const wanted = typeof names === "string" ? [names] : names;
|
|
289
307
|
for (let dir = resolve(from);; dir = dirname(dir)) {
|
|
290
308
|
const found = wanted.map((name) => join(dir, name)).find((path) => existsSync(path));
|
|
@@ -298,9 +316,9 @@ function findUp(names, from = process2.cwd(), stop = () => false) {
|
|
|
298
316
|
// ../kit/src/user-config.ts
|
|
299
317
|
import { homedir } from "os";
|
|
300
318
|
import { join as join2 } from "path";
|
|
301
|
-
import
|
|
319
|
+
import process4 from "process";
|
|
302
320
|
function configBase(where = {}) {
|
|
303
|
-
const xdg = where.xdg ?? (where.home === undefined ?
|
|
321
|
+
const xdg = where.xdg ?? (where.home === undefined ? process4.env.XDG_CONFIG_HOME : undefined);
|
|
304
322
|
return xdg !== undefined && xdg !== "" ? xdg : join2(where.home ?? homedir(), ".config");
|
|
305
323
|
}
|
|
306
324
|
function userConfigPath(bin, where = {}) {
|
|
@@ -333,10 +351,30 @@ function isColorSpec(spec) {
|
|
|
333
351
|
return Number.isInteger(spec) && spec >= 0 && spec <= 255;
|
|
334
352
|
return typeof spec === "string" && spec.trim() !== "" && spec.trim().split(SPACES).every((token) => STYLES.has(token) || HEX.test(token));
|
|
335
353
|
}
|
|
336
|
-
|
|
354
|
+
var CUBE = [0, 95, 135, 175, 215, 255];
|
|
355
|
+
function cubeLevel(channel) {
|
|
356
|
+
return CUBE.reduce((best, value, level) => Math.abs(value - channel) < Math.abs(CUBE[best] - channel) ? level : best, 0);
|
|
357
|
+
}
|
|
358
|
+
function nearest256(hex) {
|
|
359
|
+
const rgb = [1, 3, 5].map((at) => Number.parseInt(hex.slice(at, at + 2), 16));
|
|
360
|
+
const levels = rgb.map(cubeLevel);
|
|
361
|
+
const cube = levels.map((level) => CUBE[level]);
|
|
362
|
+
const grey = Math.min(23, Math.max(0, Math.round((rgb.reduce((sum, channel) => sum + channel, 0) / 3 - 8) / 10)));
|
|
363
|
+
const greyValue = 8 + grey * 10;
|
|
364
|
+
const distance = (colour) => colour.reduce((sum, channel, at) => sum + (channel - rgb[at]) ** 2, 0);
|
|
365
|
+
return distance([greyValue, greyValue, greyValue]) < distance(cube) ? 232 + grey : 16 + 36 * levels[0] + 6 * levels[1] + levels[2];
|
|
366
|
+
}
|
|
367
|
+
function hasTrueColor(env) {
|
|
368
|
+
return env.COLORTERM === "truecolor" || env.COLORTERM === "24bit";
|
|
369
|
+
}
|
|
370
|
+
function tinted(colors, spec, env = process5.env) {
|
|
337
371
|
if (typeof spec === "number")
|
|
338
372
|
return colors.ansi256(spec);
|
|
339
|
-
return spec.trim().split(SPACES).reduce((chain, token) =>
|
|
373
|
+
return spec.trim().split(SPACES).reduce((chain, token) => {
|
|
374
|
+
if (HEX.test(token))
|
|
375
|
+
return hasTrueColor(env) ? chain.hex(token) : chain.ansi256(nearest256(token));
|
|
376
|
+
return chain[token] ?? chain;
|
|
377
|
+
}, colors);
|
|
340
378
|
}
|
|
341
379
|
function isRecord(value) {
|
|
342
380
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -420,7 +458,7 @@ function warnOnce(message) {
|
|
|
420
458
|
function isPath(chosen) {
|
|
421
459
|
return chosen.includes("/") || chosen.endsWith(".json");
|
|
422
460
|
}
|
|
423
|
-
function loadTheme({ env =
|
|
461
|
+
function loadTheme({ env = process5.env, from = process5.cwd(), home = homedir2(), warn = warnOnce } = {}) {
|
|
424
462
|
const theme = { colors: { ...DEFAULT.colors }, glyphs: { ...DEFAULT.glyphs }, accents: [...DEFAULT.accents], bins: Object.create(null) };
|
|
425
463
|
const sources = [];
|
|
426
464
|
const chosen = env.KIT_THEME ?? "";
|
|
@@ -450,7 +488,7 @@ function loadTheme({ env = process4.env, from = process4.cwd(), home = homedir2(
|
|
|
450
488
|
var current;
|
|
451
489
|
var currentKey = "";
|
|
452
490
|
function activeTheme() {
|
|
453
|
-
const key = `${
|
|
491
|
+
const key = `${process5.cwd()}\x00${process5.env.KIT_THEME ?? ""}\x00${process5.env.XDG_CONFIG_HOME ?? ""}`;
|
|
454
492
|
if (current === undefined || key !== currentKey) {
|
|
455
493
|
current = loadTheme();
|
|
456
494
|
currentKey = key;
|
|
@@ -460,32 +498,32 @@ function activeTheme() {
|
|
|
460
498
|
|
|
461
499
|
// ../kit/src/style.ts
|
|
462
500
|
var MARK_WORDS = { ok: "ok:", warn: "warning:", problem: "error:", note: "note:" };
|
|
463
|
-
function takesControlCodes(stream, env =
|
|
464
|
-
return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb";
|
|
501
|
+
function takesControlCodes(stream, env = process6.env) {
|
|
502
|
+
return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb" && outputMode(stream, env) === "terminal";
|
|
465
503
|
}
|
|
466
|
-
function paint(stream, env =
|
|
504
|
+
function paint(stream, env = process6.env) {
|
|
467
505
|
return le({ stream: { isTTY: takesControlCodes(stream, env) }, env });
|
|
468
506
|
}
|
|
469
|
-
function marked(mark, text, stream, detail, env =
|
|
507
|
+
function marked(mark, text, stream, detail, env = process6.env) {
|
|
470
508
|
const colors = paint(stream, env);
|
|
471
509
|
let head = MARK_WORDS[mark];
|
|
472
510
|
if (takesControlCodes(stream, env)) {
|
|
473
511
|
const { theme } = activeTheme();
|
|
474
|
-
head = tinted(colors.bold, theme.colors[mark])(theme.glyphs[mark]);
|
|
512
|
+
head = tinted(colors.bold, theme.colors[mark], env)(theme.glyphs[mark]);
|
|
475
513
|
}
|
|
476
514
|
return `${head} ${text}${detail === undefined ? "" : ` ${colors.dim(detail)}`}`;
|
|
477
515
|
}
|
|
478
516
|
function warn(text, detail) {
|
|
479
|
-
console.error(marked("warn", text,
|
|
517
|
+
console.error(marked("warn", text, process6.stderr, detail));
|
|
480
518
|
}
|
|
481
|
-
function role(name, stream, env =
|
|
519
|
+
function role(name, stream, env = process6.env) {
|
|
482
520
|
const colors = paint(stream, env);
|
|
483
|
-
return takesControlCodes(stream, env) ? tinted(colors, activeTheme().theme.colors[name]) : colors;
|
|
521
|
+
return takesControlCodes(stream, env) ? tinted(colors, activeTheme().theme.colors[name], env) : colors;
|
|
484
522
|
}
|
|
485
523
|
var STATUS_WORDS = {
|
|
486
524
|
passed: ["passed", "success", "succeeded", "ok"],
|
|
487
525
|
failed: ["failed", "failure", "error", "errored"],
|
|
488
|
-
running: ["running", "in_progress", "started"],
|
|
526
|
+
running: ["running", "in_progress", "started", "holding"],
|
|
489
527
|
queued: ["queued", "waiting", "pending", "created", "blocked", "scheduled"],
|
|
490
528
|
skipped: ["skipped", "cancelled", "canceled", "manual"]
|
|
491
529
|
};
|
|
@@ -504,8 +542,11 @@ var ESCAPE = String.fromCharCode(27);
|
|
|
504
542
|
function textWidth(text) {
|
|
505
543
|
return Bun.stringWidth(text);
|
|
506
544
|
}
|
|
507
|
-
function table(rows, { cellWidth, header = false, align = [], fit, stream =
|
|
545
|
+
function table(rows, { cellWidth, header = false, align = [], fit, stream = process7.stdout, env = process7.env } = {}) {
|
|
508
546
|
const cells = cellWidth === undefined ? rows : rows.map((row) => row.map((cell) => truncate(cell.replaceAll(LINE_BREAKS, " "), cellWidth)));
|
|
547
|
+
if (outputMode(stream, env) === "agent")
|
|
548
|
+
return cells.map((row) => row.map((cell) => Bun.stripANSI(cell).replaceAll(/[\t\r\n]+/g, " ")).join("\t")).join(`
|
|
549
|
+
`);
|
|
509
550
|
const widths = [];
|
|
510
551
|
for (const row of cells) {
|
|
511
552
|
for (const [index, cell] of row.entries())
|
|
@@ -540,32 +581,35 @@ function narrow(rows, widths, limit) {
|
|
|
540
581
|
}
|
|
541
582
|
return rows.map((row) => row.map((cell, index) => textWidth(cell) > (widths[index] ?? 0) ? truncate(cell, widths[index] ?? 0) : cell));
|
|
542
583
|
}
|
|
584
|
+
function jsonText(value, replacer, { stream = process7.stdout, env = process7.env } = {}) {
|
|
585
|
+
return JSON.stringify(value, replacer, outputMode(stream, env) === "agent" ? undefined : 2);
|
|
586
|
+
}
|
|
543
587
|
function printJson(value) {
|
|
544
|
-
console.log(
|
|
588
|
+
console.log(jsonText(value));
|
|
545
589
|
}
|
|
546
590
|
|
|
547
591
|
// ../kit/src/help.ts
|
|
548
|
-
import
|
|
592
|
+
import process8 from "process";
|
|
549
593
|
var OPTIONAL = /\[[^\]]+\]/g;
|
|
550
594
|
var USAGE_PREFIX = /^usage:\s*/i;
|
|
551
595
|
var FULL_STOP = /\.$/;
|
|
552
|
-
function usageLine(usage, colors = paint(
|
|
596
|
+
function usageLine(usage, colors = paint(process8.stdout)) {
|
|
553
597
|
return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
|
|
554
598
|
}
|
|
555
|
-
function helpText(usage, options, colors = paint(
|
|
599
|
+
function helpText(usage, options, colors = paint(process8.stdout), { examples = [], replaces, exits = [] } = {}) {
|
|
556
600
|
return [usageLine(usage, colors), ...replacesRows(replaces, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
|
|
557
601
|
`);
|
|
558
602
|
}
|
|
559
|
-
function exitRows(exits, colors = paint(
|
|
603
|
+
function exitRows(exits, colors = paint(process8.stdout)) {
|
|
560
604
|
if (exits.length === 0)
|
|
561
605
|
return [];
|
|
562
606
|
const width = Math.max(...exits.map(([code]) => String(code).length));
|
|
563
607
|
return ["", colors.bold("Exits:"), ...exits.map(([code, meaning]) => ` ${colors.cyan(String(code).padEnd(width))} ${meaning}`)];
|
|
564
608
|
}
|
|
565
|
-
function replacesRows(replaces, colors = paint(
|
|
566
|
-
return replaces === undefined ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
|
|
609
|
+
function replacesRows(replaces, colors = paint(process8.stdout)) {
|
|
610
|
+
return replaces === undefined || outputMode() === "agent" ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
|
|
567
611
|
}
|
|
568
|
-
function wantsHelpJson(env =
|
|
612
|
+
function wantsHelpJson(env = process8.env) {
|
|
569
613
|
return env.KIT_HELP === "json";
|
|
570
614
|
}
|
|
571
615
|
function description(usage, { examples = [], replaces, exits } = {}, options) {
|
|
@@ -584,12 +628,12 @@ function description(usage, { examples = [], replaces, exits } = {}, options) {
|
|
|
584
628
|
...options === undefined ? {} : { options: Object.entries(options).map(([name, { short, description }]) => ({ name, ...short === undefined ? {} : { short }, ...description === undefined ? {} : { description } })) }
|
|
585
629
|
};
|
|
586
630
|
}
|
|
587
|
-
function exampleRows(examples, colors = paint(
|
|
588
|
-
if (examples.length === 0)
|
|
631
|
+
function exampleRows(examples, colors = paint(process8.stdout)) {
|
|
632
|
+
if (examples.length === 0 || outputMode() === "agent")
|
|
589
633
|
return [];
|
|
590
634
|
return ["", colors.bold("Examples:"), ...examples.map((example) => typeof example === "string" ? ` ${example}` : ` ${example[0]} ${colors.dim(`# ${example[1]}`)}`)];
|
|
591
635
|
}
|
|
592
|
-
function optionRows(options, colors = paint(
|
|
636
|
+
function optionRows(options, colors = paint(process8.stdout)) {
|
|
593
637
|
const rows = Object.entries(options).map(([name, option]) => {
|
|
594
638
|
const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
|
|
595
639
|
const named = option.choices === undefined ? "<value>" : `<${option.choices.join("|")}>`;
|
|
@@ -652,7 +696,6 @@ var DASHES = /^-+/;
|
|
|
652
696
|
function jsonOption(holds) {
|
|
653
697
|
return { type: "boolean", description: holds === undefined ? "print JSON" : `print JSON: ${holds}` };
|
|
654
698
|
}
|
|
655
|
-
|
|
656
699
|
class Exit extends Error {
|
|
657
700
|
code;
|
|
658
701
|
hint;
|
|
@@ -696,7 +739,7 @@ var OUTPUT_OPTIONS = {
|
|
|
696
739
|
color: { type: "string", description: "auto (on a terminal alone), always or never" },
|
|
697
740
|
plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
|
|
698
741
|
};
|
|
699
|
-
function applyOutput(color, plain, env =
|
|
742
|
+
function applyOutput(color, plain, env = process9.env) {
|
|
700
743
|
const when = plain === true ? "never" : color ?? "auto";
|
|
701
744
|
if (when === "auto")
|
|
702
745
|
return;
|
|
@@ -867,7 +910,7 @@ function nearestOption(message, options, allowNegative) {
|
|
|
867
910
|
}
|
|
868
911
|
// ../kit/src/process.ts
|
|
869
912
|
import { constants } from "os";
|
|
870
|
-
import
|
|
913
|
+
import process10 from "process";
|
|
871
914
|
var KILL_GRACE_MS = 2000;
|
|
872
915
|
function exitCodeOf(code, signal) {
|
|
873
916
|
if (code !== null)
|
|
@@ -887,7 +930,7 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
|
|
|
887
930
|
return;
|
|
888
931
|
try {
|
|
889
932
|
if (grouped)
|
|
890
|
-
|
|
933
|
+
process10.kill(-proc.pid, killing);
|
|
891
934
|
else
|
|
892
935
|
proc.kill(killing);
|
|
893
936
|
} catch {}
|
|
@@ -963,13 +1006,13 @@ var CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
|
|
|
963
1006
|
// ../kit/src/cli.ts
|
|
964
1007
|
import { readFileSync as readFileSync2, realpathSync } from "fs";
|
|
965
1008
|
import { dirname as dirname3, join as join5 } from "path";
|
|
966
|
-
import
|
|
1009
|
+
import process12 from "process";
|
|
967
1010
|
|
|
968
1011
|
// ../kit/src/usage.ts
|
|
969
1012
|
import { appendFileSync, mkdirSync } from "fs";
|
|
970
1013
|
import { homedir as homedir3 } from "os";
|
|
971
1014
|
import { dirname as dirname2, isAbsolute, join as join4 } from "path";
|
|
972
|
-
import
|
|
1015
|
+
import process11 from "process";
|
|
973
1016
|
|
|
974
1017
|
// ../kit/src/logs.ts
|
|
975
1018
|
var DAY_MS = 24 * 60 * 60 * 1000;
|
|
@@ -983,14 +1026,14 @@ var usageError;
|
|
|
983
1026
|
function noteUsageError(message) {
|
|
984
1027
|
usageError = message;
|
|
985
1028
|
}
|
|
986
|
-
function stateHome(env =
|
|
1029
|
+
function stateHome(env = process11.env) {
|
|
987
1030
|
const dir = env.XDG_STATE_HOME;
|
|
988
1031
|
return dir !== undefined && isAbsolute(dir) ? dir : join4(homedir3(), ".local", "state");
|
|
989
1032
|
}
|
|
990
|
-
function usagePath(env =
|
|
1033
|
+
function usagePath(env = process11.env) {
|
|
991
1034
|
return join4(stateHome(env), CLI_FOLDER, "usage.jsonl");
|
|
992
1035
|
}
|
|
993
|
-
function usageRecorded(env =
|
|
1036
|
+
function usageRecorded(env = process11.env) {
|
|
994
1037
|
const off = env.KAYNOOO_CLI_NO_USAGE;
|
|
995
1038
|
return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
|
|
996
1039
|
}
|
|
@@ -1004,7 +1047,7 @@ function usageEntry(bin, command, argv, code, now = new Date) {
|
|
|
1004
1047
|
usageError = undefined;
|
|
1005
1048
|
return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
|
|
1006
1049
|
}
|
|
1007
|
-
function recordUsage(entry, env =
|
|
1050
|
+
function recordUsage(entry, env = process11.env) {
|
|
1008
1051
|
if (!usageRecorded(env))
|
|
1009
1052
|
return;
|
|
1010
1053
|
try {
|
|
@@ -1095,8 +1138,8 @@ async function help2({ path, header, summary: lazySummary, commands, defaultComm
|
|
|
1095
1138
|
`);
|
|
1096
1139
|
}
|
|
1097
1140
|
function printError(prefix, message, hint, cause) {
|
|
1098
|
-
const colors = paint(
|
|
1099
|
-
const styled = takesControlCodes(
|
|
1141
|
+
const colors = paint(process12.stderr);
|
|
1142
|
+
const styled = takesControlCodes(process12.stderr);
|
|
1100
1143
|
const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
|
|
1101
1144
|
const under = (label, text, tint) => text === undefined ? "" : `
|
|
1102
1145
|
${styled ? tint(label) : `${label}:`} ${text}`;
|
|
@@ -1139,11 +1182,11 @@ async function dispatch(level, typed, { version, redact }) {
|
|
|
1139
1182
|
}
|
|
1140
1183
|
}
|
|
1141
1184
|
if (name === undefined && level.path.length > 1) {
|
|
1142
|
-
console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]),
|
|
1185
|
+
console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]), process12.stderr));
|
|
1143
1186
|
return 2;
|
|
1144
1187
|
}
|
|
1145
1188
|
if (name === undefined || name === "help" || name === "--help" || name === "-h") {
|
|
1146
|
-
console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]),
|
|
1189
|
+
console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]), process12.stdout));
|
|
1147
1190
|
return 0;
|
|
1148
1191
|
}
|
|
1149
1192
|
if (level.path.length === 1 && (name === "--version" || name === "-v")) {
|
|
@@ -1270,7 +1313,7 @@ function packageVersion(entry = Bun.main) {
|
|
|
1270
1313
|
return "0.0.0";
|
|
1271
1314
|
}
|
|
1272
1315
|
}
|
|
1273
|
-
async function runCli(cli, argv =
|
|
1316
|
+
async function runCli(cli, argv = process12.argv.slice(2)) {
|
|
1274
1317
|
const version = cli.version ?? packageVersion();
|
|
1275
1318
|
if (argv[0] === COMPLETE)
|
|
1276
1319
|
return printCandidates(candidates(scopeOf(cli.commands, cli.extraCommands, cli.aliases), cli.defaultCommand, argv.slice(1)));
|
|
@@ -1297,7 +1340,7 @@ function commandPath(scope, argv) {
|
|
|
1297
1340
|
}
|
|
1298
1341
|
return path.length === 0 ? undefined : path.join(" ");
|
|
1299
1342
|
}
|
|
1300
|
-
async function runMain({ name, version, run, redact, usage }, argv =
|
|
1343
|
+
async function runMain({ name, version, run, redact, usage }, argv = process12.argv.slice(2)) {
|
|
1301
1344
|
if (argv[0] === COMPLETE)
|
|
1302
1345
|
return printCandidates(leafCandidates(run, argv.slice(1)));
|
|
1303
1346
|
if (argv.length === 1 && (argv[0] === "--version" || argv[0] === "-v")) {
|
|
@@ -1317,6 +1360,8 @@ async function runMain({ name, version, run, redact, usage }, argv = process11.a
|
|
|
1317
1360
|
}
|
|
1318
1361
|
return code;
|
|
1319
1362
|
}
|
|
1363
|
+
// ../kit/src/folders.ts
|
|
1364
|
+
var SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
|
|
1320
1365
|
// ../kit/src/limit.ts
|
|
1321
1366
|
function limitOptions(fallback) {
|
|
1322
1367
|
return {
|
|
@@ -1346,7 +1391,7 @@ var SESSION_FILES = new Glob("*.json");
|
|
|
1346
1391
|
var ACCOUNT_DIRS = new Glob("*/sessions");
|
|
1347
1392
|
// src/hotspots.ts
|
|
1348
1393
|
import { join as join7 } from "path";
|
|
1349
|
-
import
|
|
1394
|
+
import process14 from "process";
|
|
1350
1395
|
|
|
1351
1396
|
// src/churn.ts
|
|
1352
1397
|
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)$/;
|
|
@@ -1391,7 +1436,6 @@ import { existsSync as existsSync3, readdirSync, statSync as statSync2 } from "f
|
|
|
1391
1436
|
import { join as join6, relative } from "path";
|
|
1392
1437
|
var MAX_BYTES = 2000000;
|
|
1393
1438
|
var SNIFF_BYTES = 8000;
|
|
1394
|
-
var SKIPPED = new Set(["node_modules", "dist", "build", "vendor", "target", "coverage"]);
|
|
1395
1439
|
function walk(dir, found) {
|
|
1396
1440
|
let entries;
|
|
1397
1441
|
try {
|
|
@@ -1400,7 +1444,7 @@ function walk(dir, found) {
|
|
|
1400
1444
|
return found;
|
|
1401
1445
|
}
|
|
1402
1446
|
for (const entry of entries) {
|
|
1403
|
-
if (entry.name.startsWith(".") ||
|
|
1447
|
+
if (entry.name.startsWith(".") || SKIPPED_FOLDERS.has(entry.name))
|
|
1404
1448
|
continue;
|
|
1405
1449
|
if (entry.isDirectory())
|
|
1406
1450
|
walk(join6(dir, entry.name), found);
|
|
@@ -1504,7 +1548,7 @@ async function hotspots(args) {
|
|
|
1504
1548
|
if (positionals.length > 1)
|
|
1505
1549
|
badUsage("give one folder");
|
|
1506
1550
|
const count = limitOf(values, DEFAULT_COUNT);
|
|
1507
|
-
const cwd =
|
|
1551
|
+
const cwd = process14.cwd();
|
|
1508
1552
|
const bulk = Number(values.bulk ?? DEFAULT_BULK);
|
|
1509
1553
|
if (!Number.isInteger(bulk) || bulk < 1)
|
|
1510
1554
|
badUsage(`--bulk takes a number of files, not ${values.bulk}`);
|
|
@@ -1535,8 +1579,8 @@ async function hotspots(args) {
|
|
|
1535
1579
|
printJson(shown);
|
|
1536
1580
|
return 0;
|
|
1537
1581
|
}
|
|
1538
|
-
const colors = paint(
|
|
1539
|
-
const path = role("path",
|
|
1582
|
+
const colors = paint(process14.stdout);
|
|
1583
|
+
const path = role("path", process14.stdout);
|
|
1540
1584
|
const top = shown.reduce((highest, row) => Math.max(highest, row.score), 0);
|
|
1541
1585
|
const heat = (score, text) => {
|
|
1542
1586
|
if (top > 0 && score >= top * HOT)
|
|
@@ -1550,4 +1594,4 @@ async function hotspots(args) {
|
|
|
1550
1594
|
}
|
|
1551
1595
|
|
|
1552
1596
|
// src/hotspots-cli.ts
|
|
1553
|
-
|
|
1597
|
+
process15.exitCode = await runMain({ name: "hotspots", run: hotspots });
|