@kaynooo/cli-code 0.14.1 → 0.14.3
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 +3 -1
- package/dist/cli.js +127 -77
- package/dist/hotspots-cli.js +109 -57
- package/dist/peek-cli.js +110 -59
- package/dist/todo-scan-cli.js +102 -51
- package/package.json +2 -2
package/dist/todo-scan-cli.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// @bun
|
|
3
3
|
|
|
4
4
|
// src/todo-scan-cli.ts
|
|
5
|
-
import
|
|
5
|
+
import process16 from "process";
|
|
6
6
|
// ../kit/src/args.ts
|
|
7
7
|
import process9 from "process";
|
|
8
8
|
import { parseArgs } from "util";
|
|
@@ -126,7 +126,7 @@ function Fe(r = {}) {
|
|
|
126
126
|
var o = Fe();
|
|
127
127
|
|
|
128
128
|
// ../kit/src/theme.ts
|
|
129
|
-
import { existsSync as
|
|
129
|
+
import { existsSync as existsSync3, readFileSync as readFileSync2, statSync } from "fs";
|
|
130
130
|
import { homedir as homedir2 } from "os";
|
|
131
131
|
import { join as join3, resolve as resolve2 } from "path";
|
|
132
132
|
import process5 from "process";
|
|
@@ -147,6 +147,7 @@ function findUp(names, from = process3.cwd(), stop = () => false) {
|
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
// ../kit/src/user-config.ts
|
|
150
|
+
import { existsSync as existsSync2, readFileSync } from "fs";
|
|
150
151
|
import { homedir } from "os";
|
|
151
152
|
import { join as join2 } from "path";
|
|
152
153
|
import process4 from "process";
|
|
@@ -157,6 +158,28 @@ function configBase(where = {}) {
|
|
|
157
158
|
function userConfigPath(bin, where = {}) {
|
|
158
159
|
return join2(configBase(where), "kaynooo-cli", `${bin}.json`);
|
|
159
160
|
}
|
|
161
|
+
function userConfigReadPath(bin, legacy = [], where = {}) {
|
|
162
|
+
const current = userConfigPath(bin, where);
|
|
163
|
+
if (existsSync2(current))
|
|
164
|
+
return current;
|
|
165
|
+
const base = configBase(where);
|
|
166
|
+
return legacy.map((parts) => join2(base, ...parts)).find((path) => existsSync2(path)) ?? current;
|
|
167
|
+
}
|
|
168
|
+
function readUserConfig(bin, where = {}, legacy = []) {
|
|
169
|
+
const path = userConfigReadPath(bin, legacy, where);
|
|
170
|
+
if (!existsSync2(path))
|
|
171
|
+
return {};
|
|
172
|
+
try {
|
|
173
|
+
const parsed = Bun.JSONC.parse(readFileSync(path, "utf8"));
|
|
174
|
+
return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) ? parsed : {};
|
|
175
|
+
} catch {
|
|
176
|
+
return {};
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
function configuredNumber(bin, key, fallback, where = {}, legacy = []) {
|
|
180
|
+
const value = readUserConfig(bin, where, legacy)[key];
|
|
181
|
+
return typeof value === "number" && Number.isInteger(value) && value > 0 ? value : fallback;
|
|
182
|
+
}
|
|
160
183
|
|
|
161
184
|
// ../kit/src/theme.ts
|
|
162
185
|
var ENDS = new Map;
|
|
@@ -223,7 +246,7 @@ function readThemeFile(path, warn) {
|
|
|
223
246
|
warn(`${path} is not a regular file under ${MAX_FILE_BYTES / 1024} KiB, theme ignored`);
|
|
224
247
|
return;
|
|
225
248
|
}
|
|
226
|
-
const parsed = JSON.parse(
|
|
249
|
+
const parsed = JSON.parse(readFileSync2(path, "utf8"));
|
|
227
250
|
if (isRecord(parsed))
|
|
228
251
|
return parsed;
|
|
229
252
|
warn(`${path} is not a JSON object, theme ignored`);
|
|
@@ -289,7 +312,7 @@ function applyFile(theme, file, where, warn) {
|
|
|
289
312
|
}
|
|
290
313
|
}
|
|
291
314
|
function endsWalk(home) {
|
|
292
|
-
return (dir) => dir === resolve2(home) ||
|
|
315
|
+
return (dir) => dir === resolve2(home) || existsSync3(join3(dir, ".git"));
|
|
293
316
|
}
|
|
294
317
|
var warned = new Set;
|
|
295
318
|
function warnOnce(message) {
|
|
@@ -465,18 +488,14 @@ var FULL_STOP = /\.$/;
|
|
|
465
488
|
function usageLine(usage, colors = paint(process8.stdout)) {
|
|
466
489
|
return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
|
|
467
490
|
}
|
|
468
|
-
function helpText(usage, options, colors = paint(process8.stdout), { examples = [],
|
|
469
|
-
return [usageLine(usage, colors),
|
|
491
|
+
function helpText(usage, options, colors = paint(process8.stdout), { examples = [], exits = [] } = {}) {
|
|
492
|
+
return [usageLine(usage, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
|
|
470
493
|
`);
|
|
471
494
|
}
|
|
472
495
|
function exitRows(exits, colors = paint(process8.stdout)) {
|
|
473
496
|
if (exits.length === 0)
|
|
474
497
|
return [];
|
|
475
|
-
|
|
476
|
-
return ["", colors.bold("Exits:"), ...exits.map(([code, meaning]) => ` ${colors.cyan(String(code).padEnd(width))} ${meaning}`)];
|
|
477
|
-
}
|
|
478
|
-
function replacesRows(replaces, colors = paint(process8.stdout)) {
|
|
479
|
-
return replaces === undefined || outputMode() === "agent" ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
|
|
498
|
+
return ["", `${colors.bold("Exit codes:")} ${exits.map(([code, meaning]) => `${colors.cyan(String(code))} ${meaning}`).join(", ")}`];
|
|
480
499
|
}
|
|
481
500
|
function wantsHelpJson(env = process8.env) {
|
|
482
501
|
return env.KIT_HELP === "json";
|
|
@@ -777,9 +796,33 @@ function nearestOption(message, options, allowNegative) {
|
|
|
777
796
|
const meant = closest(word, known.map((flag) => flag.replace(DASHES, "")));
|
|
778
797
|
return meant === undefined ? undefined : `did you mean ${known.find((flag) => flag.replace(DASHES, "") === meant)}?`;
|
|
779
798
|
}
|
|
799
|
+
// ../kit/src/argv.ts
|
|
800
|
+
import { readFileSync as readFileSync3, realpathSync } from "fs";
|
|
801
|
+
import { resolve as resolve4 } from "path";
|
|
802
|
+
import process10 from "process";
|
|
803
|
+
function commandLine() {
|
|
804
|
+
try {
|
|
805
|
+
return readFileSync3("/proc/self/cmdline", "utf8").split("\x00").slice(0, -1);
|
|
806
|
+
} catch {
|
|
807
|
+
return;
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
function realPath(word) {
|
|
811
|
+
try {
|
|
812
|
+
return realpathSync(resolve4(word));
|
|
813
|
+
} catch {
|
|
814
|
+
return;
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
function scriptArgs(argv = process10.argv.slice(2), cmdline = commandLine(), script = process10.argv[1]) {
|
|
818
|
+
const target = script === undefined ? undefined : realPath(script) ?? script;
|
|
819
|
+
const at = cmdline === undefined || target === undefined ? -1 : cmdline.findIndex((word, index) => index > 0 && (resolve4(word) === script || realPath(word) === target));
|
|
820
|
+
const after = at === -1 ? [] : cmdline.slice(at + 1);
|
|
821
|
+
return after[0] === "--" && after.length === argv.length + 1 && argv.every((word, index) => word === after[index + 1]) ? after : argv;
|
|
822
|
+
}
|
|
780
823
|
// ../kit/src/process.ts
|
|
781
824
|
import { constants } from "os";
|
|
782
|
-
import
|
|
825
|
+
import process11 from "process";
|
|
783
826
|
var KILL_GRACE_MS = 2000;
|
|
784
827
|
function exitCodeOf(code, signal) {
|
|
785
828
|
if (code !== null)
|
|
@@ -799,7 +842,7 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
|
|
|
799
842
|
return;
|
|
800
843
|
try {
|
|
801
844
|
if (grouped)
|
|
802
|
-
|
|
845
|
+
process11.kill(-proc.pid, killing);
|
|
803
846
|
else
|
|
804
847
|
proc.kill(killing);
|
|
805
848
|
} catch {}
|
|
@@ -873,15 +916,15 @@ var ESCAPE_CODE = new RegExp(`${ESC}(?:\\[[\\x30-\\x3F]*[\\x20-\\x2F]*[\\x40-\\x
|
|
|
873
916
|
var RESET_STYLE = `${ESC}[0m`;
|
|
874
917
|
var CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
|
|
875
918
|
// ../kit/src/cli.ts
|
|
876
|
-
import { readFileSync as
|
|
919
|
+
import { readFileSync as readFileSync4, realpathSync as realpathSync2 } from "fs";
|
|
877
920
|
import { dirname as dirname3, join as join5 } from "path";
|
|
878
|
-
import
|
|
921
|
+
import process13 from "process";
|
|
879
922
|
|
|
880
923
|
// ../kit/src/usage.ts
|
|
881
924
|
import { appendFileSync, mkdirSync } from "fs";
|
|
882
925
|
import { homedir as homedir3 } from "os";
|
|
883
926
|
import { dirname as dirname2, isAbsolute, join as join4 } from "path";
|
|
884
|
-
import
|
|
927
|
+
import process12 from "process";
|
|
885
928
|
|
|
886
929
|
// ../kit/src/logs.ts
|
|
887
930
|
var DAY_MS = 24 * 60 * 60 * 1000;
|
|
@@ -895,14 +938,14 @@ var usageError;
|
|
|
895
938
|
function noteUsageError(message) {
|
|
896
939
|
usageError = message;
|
|
897
940
|
}
|
|
898
|
-
function stateHome(env =
|
|
941
|
+
function stateHome(env = process12.env) {
|
|
899
942
|
const dir = env.XDG_STATE_HOME;
|
|
900
943
|
return dir !== undefined && isAbsolute(dir) ? dir : join4(homedir3(), ".local", "state");
|
|
901
944
|
}
|
|
902
|
-
function usagePath(env =
|
|
945
|
+
function usagePath(env = process12.env) {
|
|
903
946
|
return join4(stateHome(env), CLI_FOLDER, "usage.jsonl");
|
|
904
947
|
}
|
|
905
|
-
function usageRecorded(env =
|
|
948
|
+
function usageRecorded(env = process12.env) {
|
|
906
949
|
const off = env.KAYNOOO_CLI_NO_USAGE;
|
|
907
950
|
return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
|
|
908
951
|
}
|
|
@@ -916,7 +959,7 @@ function usageEntry(bin, command, argv, code, now = new Date) {
|
|
|
916
959
|
usageError = undefined;
|
|
917
960
|
return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
|
|
918
961
|
}
|
|
919
|
-
function recordUsage(entry, env =
|
|
962
|
+
function recordUsage(entry, env = process12.env) {
|
|
920
963
|
if (!usageRecorded(env))
|
|
921
964
|
return;
|
|
922
965
|
try {
|
|
@@ -993,7 +1036,6 @@ async function help2({ path, header, summary: lazySummary, commands, defaultComm
|
|
|
993
1036
|
header(colors, summary),
|
|
994
1037
|
"",
|
|
995
1038
|
usageLine(`${prefix} ${defaultCommand === undefined ? colors.cyan("<command>") : `[${colors.cyan("<command>")}]`} [options]`, colors),
|
|
996
|
-
...replacesRows(replaces, colors),
|
|
997
1039
|
"",
|
|
998
1040
|
...await commandRows(commands, colors),
|
|
999
1041
|
...own.length === 0 ? [] : ["", `${colors.bold(`Options of ${defaultCommand}:`)} ${colors.dim("the command run when none is named")}`, ...optionRows(Object.fromEntries(own), colors)],
|
|
@@ -1007,8 +1049,8 @@ async function help2({ path, header, summary: lazySummary, commands, defaultComm
|
|
|
1007
1049
|
`);
|
|
1008
1050
|
}
|
|
1009
1051
|
function printError(prefix, message, hint, cause) {
|
|
1010
|
-
const colors = paint(
|
|
1011
|
-
const styled = takesControlCodes(
|
|
1052
|
+
const colors = paint(process13.stderr);
|
|
1053
|
+
const styled = takesControlCodes(process13.stderr);
|
|
1012
1054
|
const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
|
|
1013
1055
|
const under = (label, text, tint) => text === undefined ? "" : `
|
|
1014
1056
|
${styled ? tint(label) : `${label}:`} ${text}`;
|
|
@@ -1051,11 +1093,11 @@ async function dispatch(level, typed, { version, redact }) {
|
|
|
1051
1093
|
}
|
|
1052
1094
|
}
|
|
1053
1095
|
if (name === undefined && level.path.length > 1) {
|
|
1054
|
-
console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]),
|
|
1096
|
+
console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]), process13.stderr));
|
|
1055
1097
|
return 2;
|
|
1056
1098
|
}
|
|
1057
1099
|
if (name === undefined || name === "help" || name === "--help" || name === "-h") {
|
|
1058
|
-
console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]),
|
|
1100
|
+
console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]), process13.stdout));
|
|
1059
1101
|
return 0;
|
|
1060
1102
|
}
|
|
1061
1103
|
if (level.path.length === 1 && (name === "--version" || name === "-v")) {
|
|
@@ -1111,24 +1153,24 @@ function candidateLine(candidate) {
|
|
|
1111
1153
|
}
|
|
1112
1154
|
function positionalBeingTyped(before, { options, positionals }) {
|
|
1113
1155
|
const takesValue = (word) => !word.includes("=") && Object.entries(options).some(([name, { short, type }]) => type === "string" && (word === `--${name}` || word === `-${short}`));
|
|
1114
|
-
|
|
1156
|
+
const typed = [];
|
|
1115
1157
|
let at = 0;
|
|
1116
1158
|
while (at < before.length) {
|
|
1117
1159
|
const word = before[at];
|
|
1118
1160
|
if (word === "--") {
|
|
1119
|
-
|
|
1161
|
+
typed.push(...before.slice(at + 1));
|
|
1120
1162
|
break;
|
|
1121
1163
|
}
|
|
1122
1164
|
if (!word.startsWith("-"))
|
|
1123
|
-
|
|
1165
|
+
typed.push(word);
|
|
1124
1166
|
else if (takesValue(word))
|
|
1125
1167
|
at++;
|
|
1126
1168
|
at++;
|
|
1127
1169
|
}
|
|
1128
1170
|
const last = positionals.at(-1);
|
|
1129
|
-
if (
|
|
1130
|
-
return positionals[
|
|
1131
|
-
return last?.replace("]", "").endsWith("...") === true ? last : undefined;
|
|
1171
|
+
if (typed.length < positionals.length)
|
|
1172
|
+
return { name: positionals[typed.length], typed };
|
|
1173
|
+
return { name: last?.replace("]", "").endsWith("...") === true ? last : undefined, typed };
|
|
1132
1174
|
}
|
|
1133
1175
|
async function leafCandidates(run, words) {
|
|
1134
1176
|
const completing = await completingOf(run);
|
|
@@ -1136,12 +1178,12 @@ async function leafCandidates(run, words) {
|
|
|
1136
1178
|
return Object.entries(completing.options).map(([name, option]) => option.description === undefined ? `--${name}` : `--${name} ${option.description}`);
|
|
1137
1179
|
const flag = words.at(-2);
|
|
1138
1180
|
const option = flag?.startsWith("-") === true ? Object.entries(completing.options).find(([name, { short }]) => flag === `--${name}` || flag === `-${short}`)?.[1] : undefined;
|
|
1181
|
+
const { name, typed } = positionalBeingTyped(words.slice(0, -1), completing);
|
|
1139
1182
|
if (option?.type === "string") {
|
|
1140
|
-
const values = option.choices === undefined ? await option.candidates?.() : option.choices;
|
|
1183
|
+
const values = option.choices === undefined ? await option.candidates?.(typed) : option.choices;
|
|
1141
1184
|
return values === undefined ? [FILES] : values.map(candidateLine);
|
|
1142
1185
|
}
|
|
1143
|
-
const
|
|
1144
|
-
const values = name === undefined ? undefined : await completing.candidates[name]?.();
|
|
1186
|
+
const values = name === undefined ? undefined : await completing.candidates[name]?.(typed);
|
|
1145
1187
|
return values === undefined ? [FILES] : values.map(candidateLine);
|
|
1146
1188
|
}
|
|
1147
1189
|
async function candidates(scope, defaultCommand, words, before = []) {
|
|
@@ -1172,9 +1214,13 @@ async function printCandidates(found) {
|
|
|
1172
1214
|
return 0;
|
|
1173
1215
|
}
|
|
1174
1216
|
function packageVersion(entry = Bun.main) {
|
|
1175
|
-
|
|
1217
|
+
let resolved = entry;
|
|
1218
|
+
try {
|
|
1219
|
+
resolved = realpathSync2(entry);
|
|
1220
|
+
} catch {}
|
|
1221
|
+
for (let dir = dirname3(resolved);; dir = dirname3(dir)) {
|
|
1176
1222
|
try {
|
|
1177
|
-
const { version } = JSON.parse(
|
|
1223
|
+
const { version } = JSON.parse(readFileSync4(join5(dir, "package.json"), "utf8"));
|
|
1178
1224
|
if (typeof version === "string")
|
|
1179
1225
|
return version;
|
|
1180
1226
|
} catch {}
|
|
@@ -1182,7 +1228,7 @@ function packageVersion(entry = Bun.main) {
|
|
|
1182
1228
|
return "0.0.0";
|
|
1183
1229
|
}
|
|
1184
1230
|
}
|
|
1185
|
-
async function runCli(cli, argv =
|
|
1231
|
+
async function runCli(cli, argv = scriptArgs()) {
|
|
1186
1232
|
const version = cli.version ?? packageVersion();
|
|
1187
1233
|
if (argv[0] === COMPLETE)
|
|
1188
1234
|
return printCandidates(candidates(scopeOf(cli.commands, cli.extraCommands, cli.aliases), cli.defaultCommand, argv.slice(1)));
|
|
@@ -1209,7 +1255,7 @@ function commandPath(scope, argv) {
|
|
|
1209
1255
|
}
|
|
1210
1256
|
return path.length === 0 ? undefined : path.join(" ");
|
|
1211
1257
|
}
|
|
1212
|
-
async function runMain({ name, version, run, redact, usage }, argv =
|
|
1258
|
+
async function runMain({ name, version, run, redact, usage }, argv = scriptArgs()) {
|
|
1213
1259
|
if (argv[0] === COMPLETE)
|
|
1214
1260
|
return printCandidates(leafCandidates(run, argv.slice(1)));
|
|
1215
1261
|
if (argv.length === 1 && (argv[0] === "--version" || argv[0] === "-v")) {
|
|
@@ -1231,6 +1277,11 @@ async function runMain({ name, version, run, redact, usage }, argv = process12.a
|
|
|
1231
1277
|
}
|
|
1232
1278
|
// ../kit/src/folders.ts
|
|
1233
1279
|
var SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
|
|
1280
|
+
function ignoredFolders(extra = [], where = {}) {
|
|
1281
|
+
const configured = readUserConfig("config", where).ignore;
|
|
1282
|
+
const names = Array.isArray(configured) ? configured.filter((name) => typeof name === "string" && name !== "") : [];
|
|
1283
|
+
return new Set([...SKIPPED_FOLDERS, ...extra, ...names]);
|
|
1284
|
+
}
|
|
1234
1285
|
// ../kit/src/limit.ts
|
|
1235
1286
|
function limitOptions(fallback) {
|
|
1236
1287
|
return {
|
|
@@ -1260,14 +1311,14 @@ var SESSION_FILES = new Glob("*.json");
|
|
|
1260
1311
|
var ACCOUNT_DIRS = new Glob("*/sessions");
|
|
1261
1312
|
// src/todo-scan.ts
|
|
1262
1313
|
import { join as join7 } from "path";
|
|
1263
|
-
import
|
|
1314
|
+
import process15 from "process";
|
|
1264
1315
|
|
|
1265
1316
|
// src/files.ts
|
|
1266
|
-
import { existsSync as
|
|
1317
|
+
import { existsSync as existsSync4, readdirSync, statSync as statSync2 } from "fs";
|
|
1267
1318
|
import { join as join6, relative } from "path";
|
|
1268
1319
|
var MAX_BYTES = 2000000;
|
|
1269
1320
|
var SNIFF_BYTES = 8000;
|
|
1270
|
-
function walk(dir, found) {
|
|
1321
|
+
function walk(dir, found, ignored) {
|
|
1271
1322
|
let entries;
|
|
1272
1323
|
try {
|
|
1273
1324
|
entries = readdirSync(dir, { withFileTypes: true });
|
|
@@ -1275,10 +1326,10 @@ function walk(dir, found) {
|
|
|
1275
1326
|
return found;
|
|
1276
1327
|
}
|
|
1277
1328
|
for (const entry of entries) {
|
|
1278
|
-
if (entry.name.startsWith(".") ||
|
|
1329
|
+
if (entry.name.startsWith(".") || ignored.has(entry.name))
|
|
1279
1330
|
continue;
|
|
1280
1331
|
if (entry.isDirectory())
|
|
1281
|
-
walk(join6(dir, entry.name), found);
|
|
1332
|
+
walk(join6(dir, entry.name), found, ignored);
|
|
1282
1333
|
else if (entry.isFile())
|
|
1283
1334
|
found.push(join6(dir, entry.name));
|
|
1284
1335
|
}
|
|
@@ -1287,9 +1338,10 @@ function walk(dir, found) {
|
|
|
1287
1338
|
async function listFiles(paths, cwd) {
|
|
1288
1339
|
const listed = await runCommand(["git", "ls-files", "-z", "--cached", "--others", "--exclude-standard", "--", ...paths], { cwd });
|
|
1289
1340
|
if (listed.code === 0)
|
|
1290
|
-
return [...new Set(listed.text.split("\x00"))].filter((path) => path !== "" &&
|
|
1341
|
+
return [...new Set(listed.text.split("\x00"))].filter((path) => path !== "" && existsSync4(join6(cwd, path))).sort();
|
|
1291
1342
|
const roots = paths.length === 0 ? [cwd] : paths.map((path) => join6(cwd, path));
|
|
1292
|
-
|
|
1343
|
+
const ignored = ignoredFolders();
|
|
1344
|
+
return roots.flatMap((root) => statSync2(root, { throwIfNoEntry: false })?.isFile() === true ? [root] : walk(root, [], ignored)).map((path) => relative(cwd, path)).sort();
|
|
1293
1345
|
}
|
|
1294
1346
|
async function readText(path) {
|
|
1295
1347
|
const file = Bun.file(path);
|
|
@@ -1375,9 +1427,8 @@ var USAGE = `todo-scan [options] [path...]: lists the TODO, FIXME and owner/repo
|
|
|
1375
1427
|
|
|
1376
1428
|
--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.
|
|
1377
1429
|
|
|
1378
|
-
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
|
|
1379
|
-
|
|
1380
|
-
Exits 0 when it listed the comments or found no stale one, 1 when --stale finds one, 2 on a usage error or when --stale could not look a repository up (ft and gh both failed), so a clean exit never hides an unchecked issue.`;
|
|
1430
|
+
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.`;
|
|
1431
|
+
var EXITS = [[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)"]];
|
|
1381
1432
|
var LIST_LIMIT = 100;
|
|
1382
1433
|
var OPTIONS = {
|
|
1383
1434
|
stale: { type: "boolean", description: "only the comments naming a closed issue, looked up with ft or gh" },
|
|
@@ -1391,8 +1442,8 @@ function printLines(lines, footer) {
|
|
|
1391
1442
|
`));
|
|
1392
1443
|
}
|
|
1393
1444
|
async function todoScan(args) {
|
|
1394
|
-
const { values, positionals } = parse(args, USAGE, OPTIONS, { 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"]] });
|
|
1395
|
-
const cwd =
|
|
1445
|
+
const { values, positionals } = parse(args, USAGE, OPTIONS, { exits: EXITS, 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"]] });
|
|
1446
|
+
const cwd = process15.cwd();
|
|
1396
1447
|
const limit = limitOf(values, LIST_LIMIT);
|
|
1397
1448
|
const marks = [];
|
|
1398
1449
|
for (const path of await listFiles(positionals, cwd)) {
|
|
@@ -1423,4 +1474,4 @@ async function todoScan(args) {
|
|
|
1423
1474
|
}
|
|
1424
1475
|
|
|
1425
1476
|
// src/todo-scan-cli.ts
|
|
1426
|
-
|
|
1477
|
+
process16.exitCode = await runMain({ name: "todo-scan", run: todoScan });
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kaynooo/cli-code",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.14.
|
|
4
|
+
"version": "0.14.3",
|
|
5
5
|
"description": "peek, todo-scan and hotspots: source read by spans, symbols and outlines in one call, the TODO and issue-reference comments of a repository with stale ones flagged, and the files ranked by complexity times git churn.",
|
|
6
6
|
"author": "Kaynooo <contact@kaynooo.fr>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -46,6 +46,6 @@
|
|
|
46
46
|
"@kaynooo/utils": "3.0.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@kaynooo/cli-kit": "0.
|
|
49
|
+
"@kaynooo/cli-kit": "0.38.2"
|
|
50
50
|
}
|
|
51
51
|
}
|