@kaynooo/cli-workspace 0.10.1 → 0.10.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/dist/audit-cli.js +81 -58
- package/dist/cli.js +107 -78
- package/dist/repos-cli.js +83 -60
- package/dist/sweep-cli.js +85 -56
- package/package.json +2 -2
package/dist/sweep-cli.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// @bun
|
|
3
3
|
|
|
4
4
|
// src/sweep-cli.ts
|
|
5
|
-
import
|
|
5
|
+
import process19 from "process";
|
|
6
6
|
|
|
7
7
|
// ../kit/src/advisory.ts
|
|
8
8
|
var SEVERITIES = ["low", "moderate", "high", "critical"];
|
|
@@ -523,18 +523,14 @@ var FULL_STOP = /\.$/;
|
|
|
523
523
|
function usageLine(usage, colors = paint(process8.stdout)) {
|
|
524
524
|
return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
|
|
525
525
|
}
|
|
526
|
-
function helpText(usage, options, colors = paint(process8.stdout), { examples = [],
|
|
527
|
-
return [usageLine(usage, colors),
|
|
526
|
+
function helpText(usage, options, colors = paint(process8.stdout), { examples = [], exits = [] } = {}) {
|
|
527
|
+
return [usageLine(usage, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
|
|
528
528
|
`);
|
|
529
529
|
}
|
|
530
530
|
function exitRows(exits, colors = paint(process8.stdout)) {
|
|
531
531
|
if (exits.length === 0)
|
|
532
532
|
return [];
|
|
533
|
-
|
|
534
|
-
return ["", colors.bold("Exits:"), ...exits.map(([code, meaning]) => ` ${colors.cyan(String(code).padEnd(width))} ${meaning}`)];
|
|
535
|
-
}
|
|
536
|
-
function replacesRows(replaces, colors = paint(process8.stdout)) {
|
|
537
|
-
return replaces === undefined || outputMode() === "agent" ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
|
|
533
|
+
return ["", `${colors.bold("Exit codes:")} ${exits.map(([code, meaning]) => `${colors.cyan(String(code))} ${meaning}`).join(", ")}`];
|
|
538
534
|
}
|
|
539
535
|
function wantsHelpJson(env = process8.env) {
|
|
540
536
|
return env.KIT_HELP === "json";
|
|
@@ -821,9 +817,33 @@ function nearestOption(message, options, allowNegative) {
|
|
|
821
817
|
const meant = closest(word, known.map((flag) => flag.replace(DASHES, "")));
|
|
822
818
|
return meant === undefined ? undefined : `did you mean ${known.find((flag) => flag.replace(DASHES, "") === meant)}?`;
|
|
823
819
|
}
|
|
820
|
+
// ../kit/src/argv.ts
|
|
821
|
+
import { readFileSync as readFileSync3, realpathSync } from "fs";
|
|
822
|
+
import { resolve as resolve3 } from "path";
|
|
823
|
+
import process10 from "process";
|
|
824
|
+
function commandLine() {
|
|
825
|
+
try {
|
|
826
|
+
return readFileSync3("/proc/self/cmdline", "utf8").split("\x00").slice(0, -1);
|
|
827
|
+
} catch {
|
|
828
|
+
return;
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
function realPath(word) {
|
|
832
|
+
try {
|
|
833
|
+
return realpathSync(resolve3(word));
|
|
834
|
+
} catch {
|
|
835
|
+
return;
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
function scriptArgs(argv = process10.argv.slice(2), cmdline = commandLine(), script = process10.argv[1]) {
|
|
839
|
+
const target = script === undefined ? undefined : realPath(script) ?? script;
|
|
840
|
+
const at = cmdline === undefined || target === undefined ? -1 : cmdline.findIndex((word, index) => index > 0 && (resolve3(word) === script || realPath(word) === target));
|
|
841
|
+
const after = at === -1 ? [] : cmdline.slice(at + 1);
|
|
842
|
+
return after[0] === "--" && after.length === argv.length + 1 && argv.every((word, index) => word === after[index + 1]) ? after : argv;
|
|
843
|
+
}
|
|
824
844
|
// ../kit/src/process.ts
|
|
825
845
|
import { constants } from "os";
|
|
826
|
-
import
|
|
846
|
+
import process11 from "process";
|
|
827
847
|
var KILL_GRACE_MS = 2000;
|
|
828
848
|
function exitCodeOf(code, signal) {
|
|
829
849
|
if (code !== null)
|
|
@@ -843,7 +863,7 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
|
|
|
843
863
|
return;
|
|
844
864
|
try {
|
|
845
865
|
if (grouped)
|
|
846
|
-
|
|
866
|
+
process11.kill(-proc.pid, killing);
|
|
847
867
|
else
|
|
848
868
|
proc.kill(killing);
|
|
849
869
|
} catch {}
|
|
@@ -918,10 +938,10 @@ var RESET_STYLE = `${ESC}[0m`;
|
|
|
918
938
|
var CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
|
|
919
939
|
|
|
920
940
|
// ../kit/src/tool.ts
|
|
921
|
-
import
|
|
941
|
+
import process12 from "process";
|
|
922
942
|
function cwdGone() {
|
|
923
943
|
try {
|
|
924
|
-
|
|
944
|
+
process12.cwd();
|
|
925
945
|
return false;
|
|
926
946
|
} catch {
|
|
927
947
|
return true;
|
|
@@ -943,7 +963,7 @@ function spawnFailure(command, error) {
|
|
|
943
963
|
async function runTool(label, argv, { timeoutMs, cwd, onStart } = {}) {
|
|
944
964
|
let ran;
|
|
945
965
|
try {
|
|
946
|
-
ran = await runCommand(argv, { env:
|
|
966
|
+
ran = await runCommand(argv, { env: process12.env, ...timeoutMs === undefined ? {} : { timeoutMs }, ...cwd === undefined ? {} : { cwd }, ...onStart === undefined ? {} : { onStart } });
|
|
947
967
|
} catch (error) {
|
|
948
968
|
throw spawnFailure(label, error);
|
|
949
969
|
}
|
|
@@ -958,15 +978,15 @@ async function runTool(label, argv, { timeoutMs, cwd, onStart } = {}) {
|
|
|
958
978
|
return { code: ran.code, ...streams };
|
|
959
979
|
}
|
|
960
980
|
// ../kit/src/cli.ts
|
|
961
|
-
import { readFileSync as
|
|
981
|
+
import { readFileSync as readFileSync4, realpathSync as realpathSync2 } from "fs";
|
|
962
982
|
import { dirname as dirname3, join as join5 } from "path";
|
|
963
|
-
import
|
|
983
|
+
import process14 from "process";
|
|
964
984
|
|
|
965
985
|
// ../kit/src/usage.ts
|
|
966
986
|
import { appendFileSync, mkdirSync } from "fs";
|
|
967
987
|
import { homedir as homedir3 } from "os";
|
|
968
988
|
import { dirname as dirname2, isAbsolute, join as join4 } from "path";
|
|
969
|
-
import
|
|
989
|
+
import process13 from "process";
|
|
970
990
|
|
|
971
991
|
// ../kit/src/logs.ts
|
|
972
992
|
var DAY_MS = 24 * 60 * 60 * 1000;
|
|
@@ -980,14 +1000,14 @@ var usageError;
|
|
|
980
1000
|
function noteUsageError(message) {
|
|
981
1001
|
usageError = message;
|
|
982
1002
|
}
|
|
983
|
-
function stateHome(env =
|
|
1003
|
+
function stateHome(env = process13.env) {
|
|
984
1004
|
const dir = env.XDG_STATE_HOME;
|
|
985
1005
|
return dir !== undefined && isAbsolute(dir) ? dir : join4(homedir3(), ".local", "state");
|
|
986
1006
|
}
|
|
987
|
-
function usagePath(env =
|
|
1007
|
+
function usagePath(env = process13.env) {
|
|
988
1008
|
return join4(stateHome(env), CLI_FOLDER, "usage.jsonl");
|
|
989
1009
|
}
|
|
990
|
-
function usageRecorded(env =
|
|
1010
|
+
function usageRecorded(env = process13.env) {
|
|
991
1011
|
const off = env.KAYNOOO_CLI_NO_USAGE;
|
|
992
1012
|
return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
|
|
993
1013
|
}
|
|
@@ -1001,7 +1021,7 @@ function usageEntry(bin, command, argv, code, now = new Date) {
|
|
|
1001
1021
|
usageError = undefined;
|
|
1002
1022
|
return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
|
|
1003
1023
|
}
|
|
1004
|
-
function recordUsage(entry, env =
|
|
1024
|
+
function recordUsage(entry, env = process13.env) {
|
|
1005
1025
|
if (!usageRecorded(env))
|
|
1006
1026
|
return;
|
|
1007
1027
|
try {
|
|
@@ -1078,7 +1098,6 @@ async function help2({ path, header, summary: lazySummary, commands, defaultComm
|
|
|
1078
1098
|
header(colors, summary),
|
|
1079
1099
|
"",
|
|
1080
1100
|
usageLine(`${prefix} ${defaultCommand === undefined ? colors.cyan("<command>") : `[${colors.cyan("<command>")}]`} [options]`, colors),
|
|
1081
|
-
...replacesRows(replaces, colors),
|
|
1082
1101
|
"",
|
|
1083
1102
|
...await commandRows(commands, colors),
|
|
1084
1103
|
...own.length === 0 ? [] : ["", `${colors.bold(`Options of ${defaultCommand}:`)} ${colors.dim("the command run when none is named")}`, ...optionRows(Object.fromEntries(own), colors)],
|
|
@@ -1092,8 +1111,8 @@ async function help2({ path, header, summary: lazySummary, commands, defaultComm
|
|
|
1092
1111
|
`);
|
|
1093
1112
|
}
|
|
1094
1113
|
function printError(prefix, message, hint, cause) {
|
|
1095
|
-
const colors = paint(
|
|
1096
|
-
const styled = takesControlCodes(
|
|
1114
|
+
const colors = paint(process14.stderr);
|
|
1115
|
+
const styled = takesControlCodes(process14.stderr);
|
|
1097
1116
|
const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
|
|
1098
1117
|
const under = (label, text, tint) => text === undefined ? "" : `
|
|
1099
1118
|
${styled ? tint(label) : `${label}:`} ${text}`;
|
|
@@ -1136,11 +1155,11 @@ async function dispatch(level, typed, { version, redact }) {
|
|
|
1136
1155
|
}
|
|
1137
1156
|
}
|
|
1138
1157
|
if (name === undefined && level.path.length > 1) {
|
|
1139
|
-
console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]),
|
|
1158
|
+
console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]), process14.stderr));
|
|
1140
1159
|
return 2;
|
|
1141
1160
|
}
|
|
1142
1161
|
if (name === undefined || name === "help" || name === "--help" || name === "-h") {
|
|
1143
|
-
console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]),
|
|
1162
|
+
console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]), process14.stdout));
|
|
1144
1163
|
return 0;
|
|
1145
1164
|
}
|
|
1146
1165
|
if (level.path.length === 1 && (name === "--version" || name === "-v")) {
|
|
@@ -1196,24 +1215,24 @@ function candidateLine(candidate) {
|
|
|
1196
1215
|
}
|
|
1197
1216
|
function positionalBeingTyped(before, { options, positionals }) {
|
|
1198
1217
|
const takesValue = (word) => !word.includes("=") && Object.entries(options).some(([name, { short, type }]) => type === "string" && (word === `--${name}` || word === `-${short}`));
|
|
1199
|
-
|
|
1218
|
+
const typed = [];
|
|
1200
1219
|
let at = 0;
|
|
1201
1220
|
while (at < before.length) {
|
|
1202
1221
|
const word = before[at];
|
|
1203
1222
|
if (word === "--") {
|
|
1204
|
-
|
|
1223
|
+
typed.push(...before.slice(at + 1));
|
|
1205
1224
|
break;
|
|
1206
1225
|
}
|
|
1207
1226
|
if (!word.startsWith("-"))
|
|
1208
|
-
|
|
1227
|
+
typed.push(word);
|
|
1209
1228
|
else if (takesValue(word))
|
|
1210
1229
|
at++;
|
|
1211
1230
|
at++;
|
|
1212
1231
|
}
|
|
1213
1232
|
const last = positionals.at(-1);
|
|
1214
|
-
if (
|
|
1215
|
-
return positionals[
|
|
1216
|
-
return last?.replace("]", "").endsWith("...") === true ? last : undefined;
|
|
1233
|
+
if (typed.length < positionals.length)
|
|
1234
|
+
return { name: positionals[typed.length], typed };
|
|
1235
|
+
return { name: last?.replace("]", "").endsWith("...") === true ? last : undefined, typed };
|
|
1217
1236
|
}
|
|
1218
1237
|
async function leafCandidates(run, words) {
|
|
1219
1238
|
const completing = await completingOf(run);
|
|
@@ -1221,12 +1240,12 @@ async function leafCandidates(run, words) {
|
|
|
1221
1240
|
return Object.entries(completing.options).map(([name, option]) => option.description === undefined ? `--${name}` : `--${name} ${option.description}`);
|
|
1222
1241
|
const flag = words.at(-2);
|
|
1223
1242
|
const option = flag?.startsWith("-") === true ? Object.entries(completing.options).find(([name, { short }]) => flag === `--${name}` || flag === `-${short}`)?.[1] : undefined;
|
|
1243
|
+
const { name, typed } = positionalBeingTyped(words.slice(0, -1), completing);
|
|
1224
1244
|
if (option?.type === "string") {
|
|
1225
|
-
const values = option.choices === undefined ? await option.candidates?.() : option.choices;
|
|
1245
|
+
const values = option.choices === undefined ? await option.candidates?.(typed) : option.choices;
|
|
1226
1246
|
return values === undefined ? [FILES] : values.map(candidateLine);
|
|
1227
1247
|
}
|
|
1228
|
-
const
|
|
1229
|
-
const values = name === undefined ? undefined : await completing.candidates[name]?.();
|
|
1248
|
+
const values = name === undefined ? undefined : await completing.candidates[name]?.(typed);
|
|
1230
1249
|
return values === undefined ? [FILES] : values.map(candidateLine);
|
|
1231
1250
|
}
|
|
1232
1251
|
async function candidates(scope, defaultCommand, words, before = []) {
|
|
@@ -1257,9 +1276,13 @@ async function printCandidates(found) {
|
|
|
1257
1276
|
return 0;
|
|
1258
1277
|
}
|
|
1259
1278
|
function packageVersion(entry = Bun.main) {
|
|
1260
|
-
|
|
1279
|
+
let resolved = entry;
|
|
1280
|
+
try {
|
|
1281
|
+
resolved = realpathSync2(entry);
|
|
1282
|
+
} catch {}
|
|
1283
|
+
for (let dir = dirname3(resolved);; dir = dirname3(dir)) {
|
|
1261
1284
|
try {
|
|
1262
|
-
const { version } = JSON.parse(
|
|
1285
|
+
const { version } = JSON.parse(readFileSync4(join5(dir, "package.json"), "utf8"));
|
|
1263
1286
|
if (typeof version === "string")
|
|
1264
1287
|
return version;
|
|
1265
1288
|
} catch {}
|
|
@@ -1267,7 +1290,7 @@ function packageVersion(entry = Bun.main) {
|
|
|
1267
1290
|
return "0.0.0";
|
|
1268
1291
|
}
|
|
1269
1292
|
}
|
|
1270
|
-
async function runCli(cli, argv =
|
|
1293
|
+
async function runCli(cli, argv = scriptArgs()) {
|
|
1271
1294
|
const version = cli.version ?? packageVersion();
|
|
1272
1295
|
if (argv[0] === COMPLETE)
|
|
1273
1296
|
return printCandidates(candidates(scopeOf(cli.commands, cli.extraCommands, cli.aliases), cli.defaultCommand, argv.slice(1)));
|
|
@@ -1294,7 +1317,7 @@ function commandPath(scope, argv) {
|
|
|
1294
1317
|
}
|
|
1295
1318
|
return path.length === 0 ? undefined : path.join(" ");
|
|
1296
1319
|
}
|
|
1297
|
-
async function runMain({ name, version, run, redact, usage }, argv =
|
|
1320
|
+
async function runMain({ name, version, run, redact, usage }, argv = scriptArgs()) {
|
|
1298
1321
|
if (argv[0] === COMPLETE)
|
|
1299
1322
|
return printCandidates(leafCandidates(run, argv.slice(1)));
|
|
1300
1323
|
if (argv.length === 1 && (argv[0] === "--version" || argv[0] === "-v")) {
|
|
@@ -1346,7 +1369,7 @@ function parseSize(text, bareUnit = 1) {
|
|
|
1346
1369
|
return Math.round(Number(match[1]) * (suffix === "" ? bareUnit : 1024 ** POWERS[suffix]));
|
|
1347
1370
|
}
|
|
1348
1371
|
// ../kit/src/watch.ts
|
|
1349
|
-
import
|
|
1372
|
+
import process15 from "process";
|
|
1350
1373
|
import { format } from "util";
|
|
1351
1374
|
var CLEAR_SCREEN = "\x1B[H\x1B[2J";
|
|
1352
1375
|
var DEFAULT_SECONDS = 2;
|
|
@@ -1368,7 +1391,7 @@ function withoutWatch(args) {
|
|
|
1368
1391
|
}
|
|
1369
1392
|
return rest;
|
|
1370
1393
|
}
|
|
1371
|
-
async function watching(value, step, stream =
|
|
1394
|
+
async function watching(value, step, stream = process15.stdout, sleep = Bun.sleep, rounds = Number.POSITIVE_INFINITY) {
|
|
1372
1395
|
const interval = value === "" ? DEFAULT_SECONDS * 1000 : duration(value, "watch", DEFAULT_SECONDS * 1000);
|
|
1373
1396
|
if (!takesControlCodes(stream))
|
|
1374
1397
|
badUsage("--watch redraws the screen, so it needs a terminal");
|
|
@@ -1376,12 +1399,12 @@ async function watching(value, step, stream = process14.stdout, sleep = Bun.slee
|
|
|
1376
1399
|
for (let round = 0;round < rounds; round++) {
|
|
1377
1400
|
const held = [];
|
|
1378
1401
|
const { log, info } = console;
|
|
1379
|
-
const write =
|
|
1402
|
+
const write = process15.stdout.write.bind(process15.stdout);
|
|
1380
1403
|
const hold = (...parts) => void held.push(`${format(...parts)}
|
|
1381
1404
|
`);
|
|
1382
1405
|
console.log = hold;
|
|
1383
1406
|
console.info = hold;
|
|
1384
|
-
|
|
1407
|
+
process15.stdout.write = (text) => {
|
|
1385
1408
|
held.push(typeof text === "string" ? text : Buffer.from(text).toString());
|
|
1386
1409
|
return true;
|
|
1387
1410
|
};
|
|
@@ -1390,7 +1413,7 @@ async function watching(value, step, stream = process14.stdout, sleep = Bun.slee
|
|
|
1390
1413
|
} finally {
|
|
1391
1414
|
console.log = log;
|
|
1392
1415
|
console.info = info;
|
|
1393
|
-
|
|
1416
|
+
process15.stdout.write = write;
|
|
1394
1417
|
}
|
|
1395
1418
|
stream.write(`${CLEAR_SCREEN}${held.join("")}`);
|
|
1396
1419
|
await sleep(interval);
|
|
@@ -1399,8 +1422,8 @@ async function watching(value, step, stream = process14.stdout, sleep = Bun.slee
|
|
|
1399
1422
|
}
|
|
1400
1423
|
// ../kit/src/workspace-root.ts
|
|
1401
1424
|
import { homedir as homedir4 } from "os";
|
|
1402
|
-
import { dirname as dirname4, join as join6, resolve as
|
|
1403
|
-
import
|
|
1425
|
+
import { dirname as dirname4, join as join6, resolve as resolve4 } from "path";
|
|
1426
|
+
import process16 from "process";
|
|
1404
1427
|
function expandHome(path, home) {
|
|
1405
1428
|
if (path === "~")
|
|
1406
1429
|
return home;
|
|
@@ -1410,9 +1433,9 @@ function configured(env, home) {
|
|
|
1410
1433
|
const folder = readUserConfig("config", { home, xdg: env.XDG_CONFIG_HOME }).workspace;
|
|
1411
1434
|
return typeof folder === "string" && folder !== "" ? folder : undefined;
|
|
1412
1435
|
}
|
|
1413
|
-
function workspaceRoot({ given, env =
|
|
1436
|
+
function workspaceRoot({ given, env = process16.env, home = homedir4() } = {}) {
|
|
1414
1437
|
const fromEnv = env.KAYNOOO_WORKSPACE === "" ? undefined : env.KAYNOOO_WORKSPACE;
|
|
1415
|
-
return
|
|
1438
|
+
return resolve4(expandHome(given ?? fromEnv ?? configured(env, home) ?? join6(home, "Workspace"), home));
|
|
1416
1439
|
}
|
|
1417
1440
|
// src/sweep.ts
|
|
1418
1441
|
import { existsSync as existsSync6, statSync as statSync2 } from "fs";
|
|
@@ -1420,7 +1443,7 @@ import { homedir as homedir6 } from "os";
|
|
|
1420
1443
|
import { relative } from "path";
|
|
1421
1444
|
|
|
1422
1445
|
// ../kit/src/prompt.ts
|
|
1423
|
-
import
|
|
1446
|
+
import process18 from "process";
|
|
1424
1447
|
|
|
1425
1448
|
// ../kit/src/picker/score.ts
|
|
1426
1449
|
var BOUNDARY_AFTER = new Set([" ", "/", "-", "_", ".", ":", "\\", "(", "[", ",", "\t"]);
|
|
@@ -1485,6 +1508,14 @@ function parseKeys(input, paste = { active: false }, ctrls = []) {
|
|
|
1485
1508
|
});
|
|
1486
1509
|
}
|
|
1487
1510
|
|
|
1511
|
+
// ../kit/src/redraw.ts
|
|
1512
|
+
var SYNC_START = "\x1B[?2026h";
|
|
1513
|
+
var SYNC_END = "\x1B[?2026l";
|
|
1514
|
+
function overwrite(lines, columns) {
|
|
1515
|
+
return lines.map((line) => textWidth(line) < columns ? `${line}\x1B[K` : `\x1B[2K${line}`).join(`
|
|
1516
|
+
`);
|
|
1517
|
+
}
|
|
1518
|
+
|
|
1488
1519
|
// ../kit/src/prompt.ts
|
|
1489
1520
|
var PROMPT_KEYS = new Set(["up", "down", "pageup", "pagedown", "home", "end", "enter", "cancel", "erase"]);
|
|
1490
1521
|
function readKeys(input, paste = { active: false }) {
|
|
@@ -1512,7 +1543,7 @@ function asking(colors, question, typed, keys) {
|
|
|
1512
1543
|
function answer(colors, question, state, picked) {
|
|
1513
1544
|
return state === "enter" ? `${colors.green("\u2713")} ${question} ${colors.cyan(picked)}` : `${colors.red("\u2717")} ${question} ${colors.dim("cancelled")}`;
|
|
1514
1545
|
}
|
|
1515
|
-
async function ask(question, { hint, terminal =
|
|
1546
|
+
async function ask(question, { hint, terminal = process18 }, render, press) {
|
|
1516
1547
|
const { stdin, stderr } = terminal;
|
|
1517
1548
|
if (!isInteractive(terminal))
|
|
1518
1549
|
fail(`cannot ask "${question}" off a terminal`, 2, hint);
|
|
@@ -1522,8 +1553,7 @@ async function ask(question, { hint, terminal = process17 }, render, press) {
|
|
|
1522
1553
|
const columns = () => stderr.columns || 80;
|
|
1523
1554
|
const draw = (state, last = false) => {
|
|
1524
1555
|
const frame = render(colors, state, { columns: columns(), rows: stderr.rows || 24 });
|
|
1525
|
-
stderr.write(
|
|
1526
|
-
`)}${last || frame.length < 2 ? "" : `\x1B[${frame.length - 1}A`}${last ? "" : "\r"}`);
|
|
1556
|
+
stderr.write(`${SYNC_START}\r${overwrite(frame, columns())}\x1B[0J${last || frame.length < 2 ? "" : `\x1B[${frame.length - 1}A`}${last ? "" : "\r"}${SYNC_END}`);
|
|
1527
1557
|
current = state;
|
|
1528
1558
|
};
|
|
1529
1559
|
const redraw = () => draw(current);
|
|
@@ -1888,9 +1918,8 @@ var LARGE = 100 * 1024 ** 2;
|
|
|
1888
1918
|
var BIG = 1024 ** 3;
|
|
1889
1919
|
var USAGE = `sweep [options] [root]: lists the regenerable folders (node_modules, .output, dist, build, target beside a Cargo.toml), the caches (.nuxt, .next, .turbo, .svelte-kit and node_modules/.cache per project; ~/.bun/install/cache, ~/.npm/_cacache, ~/.cache/{pip,uv,ms-playwright,puppeteer,go-build,typescript} and ~/.cargo/registry, exact paths only, listed only when no root is given or with --only caches) and the .worktrees/* and .claude/worktrees/* entries under root (the configured workspace, ~/Workspace by default, ${MAX_DEPTH} levels down), largest first with the age of the repo's last commit; --only worktrees, folders or caches keeps one kind
|
|
1890
1920
|
|
|
1891
|
-
Dry unless --apply, which deletes after a confirm showing the total (read from the terminal; off one, pass --yes). A folder is deleted for good, not trashed. Never touched: a symlink, a folder git tracks files in, a build folder git does not ignore. A worktree is removed with git worktree remove, never forced, and only when it is clean and every commit of its branch is on another branch or a remote; the others stay listed as kept and count for nothing in the total. With --docker the Docker usage comes after the list, left to dclean
|
|
1892
|
-
|
|
1893
|
-
Exits 0 when it listed, or removed every entry it was allowed to, 1 when a removal failed or the confirm was declined, 2 on a usage error, a missing root, or --apply off a terminal without --yes.`;
|
|
1921
|
+
Dry unless --apply, which deletes after a confirm showing the total (read from the terminal; off one, pass --yes). A folder is deleted for good, not trashed. Never touched: a symlink, a folder git tracks files in, a build folder git does not ignore. A worktree is removed with git worktree remove, never forced, and only when it is clean and every commit of its branch is on another branch or a remote; the others stay listed as kept and count for nothing in the total. With --docker the Docker usage comes after the list, left to dclean.`;
|
|
1922
|
+
var EXITS = [[0, "it listed, or removed every entry it was allowed to"], [1, "a removal failed or the confirm was declined"], [2, "a usage error, a missing root, or --apply off a terminal without --yes"]];
|
|
1894
1923
|
var ONLY_KINDS = { worktrees: "worktree", folders: "folder", caches: "cache" };
|
|
1895
1924
|
var OPTIONS = {
|
|
1896
1925
|
apply: { type: "boolean", description: "delete what is listed as removable, after the confirm" },
|
|
@@ -1912,7 +1941,7 @@ async function dockerUsage() {
|
|
|
1912
1941
|
}
|
|
1913
1942
|
}
|
|
1914
1943
|
async function sweep(args) {
|
|
1915
|
-
const { values, positionals } = parse(args, USAGE, OPTIONS, { positionals: ["[root]"], replaces: "find ~/Workspace -name node_modules, du -sh and rm -rf by hand", examples: ["sweep", "sweep ~/Workspace --older 30d --min 100M --apply", "sweep --only worktrees --apply"] });
|
|
1944
|
+
const { values, positionals } = parse(args, USAGE, OPTIONS, { exits: EXITS, positionals: ["[root]"], replaces: "find ~/Workspace -name node_modules, du -sh and rm -rf by hand", examples: ["sweep", "sweep ~/Workspace --older 30d --min 100M --apply", "sweep --only worktrees --apply"] });
|
|
1916
1945
|
if (positionals.length > 1)
|
|
1917
1946
|
badUsage("give one root");
|
|
1918
1947
|
const root = workspaceRoot({ given: positionals[0] });
|
|
@@ -1990,4 +2019,4 @@ ${tt(reclaimable)} reclaimable${skipped === 0 ? "" : `, ${skipped} skipped (syml
|
|
|
1990
2019
|
}
|
|
1991
2020
|
|
|
1992
2021
|
// src/sweep-cli.ts
|
|
1993
|
-
|
|
2022
|
+
process19.exitCode = await runMain({ name: "sweep", run: sweep });
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kaynooo/cli-workspace",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.10.
|
|
4
|
+
"version": "0.10.3",
|
|
5
5
|
"description": "ws, repos, sweep, audit: the repositories of the workspace that need attention, the folders worth reclaiming and their known vulnerabilities.",
|
|
6
6
|
"author": "Kaynooo <contact@kaynooo.fr>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -34,6 +34,6 @@
|
|
|
34
34
|
"audit": "$npm_execpath src/audit-cli.ts"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@kaynooo/cli-kit": "0.
|
|
37
|
+
"@kaynooo/cli-kit": "0.38.4"
|
|
38
38
|
}
|
|
39
39
|
}
|