@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/cli.js CHANGED
@@ -2,7 +2,7 @@
2
2
  // @bun
3
3
 
4
4
  // src/cli.ts
5
- import process21 from "process";
5
+ import process22 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 = [], replaces, exits = [] } = {}) {
527
- return [usageLine(usage, colors), ...replacesRows(replaces, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
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
- const width = Math.max(...exits.map(([code]) => String(code).length));
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 process10 from "process";
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
- process10.kill(-proc.pid, killing);
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 process11 from "process";
941
+ import process12 from "process";
922
942
  function cwdGone() {
923
943
  try {
924
- process11.cwd();
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: process11.env, ...timeoutMs === undefined ? {} : { timeoutMs }, ...cwd === undefined ? {} : { cwd }, ...onStart === undefined ? {} : { onStart } });
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 readFileSync3, realpathSync } from "fs";
981
+ import { readFileSync as readFileSync4, realpathSync as realpathSync2 } from "fs";
962
982
  import { dirname as dirname3, join as join5 } from "path";
963
- import process13 from "process";
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 process12 from "process";
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 = process12.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 = process12.env) {
1007
+ function usagePath(env = process13.env) {
988
1008
  return join4(stateHome(env), CLI_FOLDER, "usage.jsonl");
989
1009
  }
990
- function usageRecorded(env = process12.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 = process12.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(process13.stderr);
1096
- const styled = takesControlCodes(process13.stderr);
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]), process13.stderr));
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]), process13.stdout));
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
- let index = 0;
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
- index += before.length - at - 1;
1223
+ typed.push(...before.slice(at + 1));
1205
1224
  break;
1206
1225
  }
1207
1226
  if (!word.startsWith("-"))
1208
- index++;
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 (index < positionals.length)
1215
- return positionals[index];
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 name = positionalBeingTyped(words.slice(0, -1), completing);
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
- for (let dir = dirname3(realpathSync(entry));; dir = dirname3(dir)) {
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(readFileSync3(join5(dir, "package.json"), "utf8"));
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 = process13.argv.slice(2)) {
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 = process13.argv.slice(2)) {
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 process14 from "process";
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 = process14.stdout, sleep = Bun.sleep, rounds = Number.POSITIVE_INFINITY) {
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 = process14.stdout.write.bind(process14.stdout);
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
- process14.stdout.write = (text) => {
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
- process14.stdout.write = write;
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 resolve3 } from "path";
1403
- import process15 from "process";
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,18 +1433,18 @@ 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 = process15.env, home = homedir4() } = {}) {
1436
+ function workspaceRoot({ given, env = process16.env, home = homedir4() } = {}) {
1414
1437
  const fromEnv = env.KAYNOOO_WORKSPACE === "" ? undefined : env.KAYNOOO_WORKSPACE;
1415
- return resolve3(expandHome(given ?? fromEnv ?? configured(env, home) ?? join6(home, "Workspace"), home));
1438
+ return resolve4(expandHome(given ?? fromEnv ?? configured(env, home) ?? join6(home, "Workspace"), home));
1416
1439
  }
1417
1440
  // src/audit.ts
1418
- import { existsSync as existsSync5, readdirSync, readFileSync as readFileSync5, statSync as statSync2 } from "fs";
1441
+ import { existsSync as existsSync5, readdirSync, readFileSync as readFileSync6, statSync as statSync2 } from "fs";
1419
1442
  import { readdir } from "fs/promises";
1420
- import { join as join8, relative, resolve as resolve4 } from "path";
1421
- import process17 from "process";
1443
+ import { join as join8, relative, resolve as resolve5 } from "path";
1444
+ import process18 from "process";
1422
1445
 
1423
1446
  // src/report.ts
1424
- import { existsSync as existsSync4, readFileSync as readFileSync4 } from "fs";
1447
+ import { existsSync as existsSync4, readFileSync as readFileSync5 } from "fs";
1425
1448
  import { join as join7 } from "path";
1426
1449
  var UPPER_BOUND = /<\s*(\d[\w.+-]*)/;
1427
1450
  var DEPENDENCY_KINDS = ["dependencies", "devDependencies", "optionalDependencies", "peerDependencies"];
@@ -1505,7 +1528,7 @@ function reachedFrom(graph, direct, targets) {
1505
1528
  }
1506
1529
  function readManifest(path) {
1507
1530
  try {
1508
- return existsSync4(path) ? JSON.parse(readFileSync4(path, "utf8")) : {};
1531
+ return existsSync4(path) ? JSON.parse(readFileSync5(path, "utf8")) : {};
1509
1532
  } catch {
1510
1533
  return {};
1511
1534
  }
@@ -1610,7 +1633,7 @@ async function audited(path, shown, level, ignore) {
1610
1633
  }
1611
1634
  function lockText(path) {
1612
1635
  try {
1613
- return readFileSync5(join8(path, "bun.lock"), "utf8");
1636
+ return readFileSync6(join8(path, "bun.lock"), "utf8");
1614
1637
  } catch {
1615
1638
  return "";
1616
1639
  }
@@ -1630,7 +1653,7 @@ function failure(ran) {
1630
1653
  `).at(-1) ?? `exit ${ran.code}`;
1631
1654
  }
1632
1655
  function tint(severity) {
1633
- const colors = paint(process17.stdout);
1656
+ const colors = paint(process18.stdout);
1634
1657
  if (severity === "critical" || severity === "high")
1635
1658
  return colors.red;
1636
1659
  return severity === "moderate" ? colors.yellow : colors.dim;
@@ -1647,7 +1670,7 @@ function rows(findings) {
1647
1670
  }
1648
1671
  async function audit(args) {
1649
1672
  const { values, positionals } = parse(args, USAGE, OPTIONS, { positionals: ["[root]"], exits: EXITS, replaces: "a bun audit run in each repository and a read of every advisory to find what is worth fixing", examples: ["audit", "audit ~/Workspace --level high --prod"] });
1650
- const root = resolve4(positionals[0] ?? ".");
1673
+ const root = resolve5(positionals[0] ?? ".");
1651
1674
  if (!existsSync5(root) || !statSync2(root).isDirectory())
1652
1675
  fail(`no folder ${root}`);
1653
1676
  const level = oneOf(values.level, "level", SEVERITIES);
@@ -1665,8 +1688,8 @@ async function audit(args) {
1665
1688
  return kept.some((each) => each.findings.length > 0) ? 1 : 0;
1666
1689
  }
1667
1690
  function show(audits, total) {
1668
- const label = role("label", process17.stdout);
1669
- const path = role("path", process17.stdout);
1691
+ const label = role("label", process18.stdout);
1692
+ const path = role("path", process18.stdout);
1670
1693
  const flagged = audits.filter((each) => each.error !== undefined || each.findings.length > 0);
1671
1694
  if (flagged.length === 0) {
1672
1695
  console.log(label(`no advisory in ${total} ${total === 1 ? "repository" : "repositories"}`));
@@ -1688,13 +1711,13 @@ function show(audits, total) {
1688
1711
  // src/repos.ts
1689
1712
  import { existsSync as existsSync7, statSync as statSync3 } from "fs";
1690
1713
  import { basename as basename2, relative as relative2 } from "path";
1691
- import process19 from "process";
1714
+ import process20 from "process";
1692
1715
 
1693
1716
  // src/repos-scan.ts
1694
1717
  import { existsSync as existsSync6 } from "fs";
1695
1718
  import { readdir as readdir2 } from "fs/promises";
1696
1719
  import { basename, join as join9 } from "path";
1697
- import process18 from "process";
1720
+ import process19 from "process";
1698
1721
  var MAX_DEPTH2 = 3;
1699
1722
  var CONCURRENCY2 = 8;
1700
1723
  var PACKAGE_CONCURRENCY = 4;
@@ -1741,7 +1764,7 @@ async function findRepos2(root, skip) {
1741
1764
  }
1742
1765
  async function read(path, args, timeoutMs = GIT_MS) {
1743
1766
  try {
1744
- const ran = await runCommand(["git", "--no-optional-locks", ...args], { cwd: path, env: { ...process18.env, GIT_TERMINAL_PROMPT: "0" }, timeoutMs });
1767
+ const ran = await runCommand(["git", "--no-optional-locks", ...args], { cwd: path, env: { ...process19.env, GIT_TERMINAL_PROMPT: "0" }, timeoutMs });
1745
1768
  return ran.code === 0 && !ran.timedOut ? ran.text.trim() : undefined;
1746
1769
  } catch {
1747
1770
  return;
@@ -1818,7 +1841,7 @@ function firstLine(text) {
1818
1841
  }
1819
1842
  async function fastForward(path) {
1820
1843
  try {
1821
- const ran = await runCommand(["git", "--no-optional-locks", "merge", "--ff-only", "--quiet", "@{upstream}"], { cwd: path, env: { ...process18.env, GIT_TERMINAL_PROMPT: "0" }, timeoutMs: GIT_MS });
1844
+ const ran = await runCommand(["git", "--no-optional-locks", "merge", "--ff-only", "--quiet", "@{upstream}"], { cwd: path, env: { ...process19.env, GIT_TERMINAL_PROMPT: "0" }, timeoutMs: GIT_MS });
1822
1845
  if (ran.timedOut)
1823
1846
  return "timed out";
1824
1847
  return ran.code === 0 ? undefined : firstLine(ran.text.trim()) || `exit ${ran.code}`;
@@ -1861,7 +1884,7 @@ function releasedCell(repo) {
1861
1884
  return repo.packages.filter((release) => release.unreleased > 0).map((release) => `${release.name} ${release.unreleased}`).join(", ") || "-";
1862
1885
  return repo.tag === null || repo.unreleased === 0 ? "-" : `${repo.unreleased} since ${repo.tag}`;
1863
1886
  }
1864
- function syncCell(repo, stream = process19.stdout) {
1887
+ function syncCell(repo, stream = process20.stdout) {
1865
1888
  const colors = paint(stream);
1866
1889
  const ahead = repo.ahead ?? 0;
1867
1890
  const behind = repo.behind ?? 0;
@@ -1872,7 +1895,7 @@ function syncCell(repo, stream = process19.stdout) {
1872
1895
  return parts.length === 0 ? colors.dim("-") : `${parts.join(" ")}${diverged ? colors.yellow(" diverged") : ""}`;
1873
1896
  }
1874
1897
  var DEFAULT_BRANCHES = new Set(["main", "master"]);
1875
- function branchCell(repo, stream = process19.stdout) {
1898
+ function branchCell(repo, stream = process20.stdout) {
1876
1899
  const colors = paint(stream);
1877
1900
  if (repo.unreadable)
1878
1901
  return colors.red("? (unreadable)");
@@ -1881,8 +1904,8 @@ function branchCell(repo, stream = process19.stdout) {
1881
1904
  return DEFAULT_BRANCHES.has(repo.branch) ? repo.branch : role("accent", stream)(repo.branch);
1882
1905
  }
1883
1906
  function row(repo, shown) {
1884
- const colors = paint(process19.stdout);
1885
- const tint = role("path", process19.stdout);
1907
+ const colors = paint(process20.stdout);
1908
+ const tint = role("path", process20.stdout);
1886
1909
  const unreleased = releasedCell(repo);
1887
1910
  return [
1888
1911
  tint(shown),
@@ -1916,12 +1939,12 @@ async function repos(args) {
1916
1939
  const blocker = pullBlocker(repo);
1917
1940
  const refused = blocker === undefined ? await fastForward(repo.path) : undefined;
1918
1941
  if (blocker !== undefined) {
1919
- log(marked("note", `${repo.name} skipped`, process19.stdout, blocker));
1942
+ log(marked("note", `${repo.name} skipped`, process20.stdout, blocker));
1920
1943
  } else if (refused !== undefined) {
1921
1944
  failedPulls++;
1922
- log(marked("problem", `${repo.name} not pulled`, process19.stdout, refused));
1945
+ log(marked("problem", `${repo.name} not pulled`, process20.stdout, refused));
1923
1946
  } else {
1924
- log(marked("ok", `${repo.name} pulled`, process19.stdout, `${repo.behind} ${repo.behind === 1 ? "commit" : "commits"}`));
1947
+ log(marked("ok", `${repo.name} pulled`, process20.stdout, `${repo.behind} ${repo.behind === 1 ? "commit" : "commits"}`));
1925
1948
  states[index] = await inspect(repo.path, false);
1926
1949
  }
1927
1950
  }
@@ -1936,7 +1959,7 @@ async function repos(args) {
1936
1959
  printJson(kept.map((repo) => ({ ...repo, reasons: reasonsOf(repo) })));
1937
1960
  return failedPulls > 0 ? 1 : 0;
1938
1961
  }
1939
- const label = role("label", process19.stdout);
1962
+ const label = role("label", process20.stdout);
1940
1963
  printHeader("repos", `${basename2(root)} \xB7 ${states.length} ${states.length === 1 ? "repository" : "repositories"}`);
1941
1964
  if (kept.length === 0) {
1942
1965
  console.log(label(`nothing needs attention in ${states.length} repositories`));
@@ -1957,7 +1980,7 @@ import { homedir as homedir6 } from "os";
1957
1980
  import { relative as relative3 } from "path";
1958
1981
 
1959
1982
  // ../kit/src/prompt.ts
1960
- import process20 from "process";
1983
+ import process21 from "process";
1961
1984
 
1962
1985
  // ../kit/src/picker/score.ts
1963
1986
  var BOUNDARY_AFTER = new Set([" ", "/", "-", "_", ".", ":", "\\", "(", "[", ",", "\t"]);
@@ -2022,6 +2045,14 @@ function parseKeys(input, paste = { active: false }, ctrls = []) {
2022
2045
  });
2023
2046
  }
2024
2047
 
2048
+ // ../kit/src/redraw.ts
2049
+ var SYNC_START = "\x1B[?2026h";
2050
+ var SYNC_END = "\x1B[?2026l";
2051
+ function overwrite(lines, columns) {
2052
+ return lines.map((line) => textWidth(line) < columns ? `${line}\x1B[K` : `\x1B[2K${line}`).join(`
2053
+ `);
2054
+ }
2055
+
2025
2056
  // ../kit/src/prompt.ts
2026
2057
  var PROMPT_KEYS = new Set(["up", "down", "pageup", "pagedown", "home", "end", "enter", "cancel", "erase"]);
2027
2058
  function readKeys(input, paste = { active: false }) {
@@ -2049,7 +2080,7 @@ function asking(colors, question, typed, keys) {
2049
2080
  function answer(colors, question, state, picked) {
2050
2081
  return state === "enter" ? `${colors.green("\u2713")} ${question} ${colors.cyan(picked)}` : `${colors.red("\u2717")} ${question} ${colors.dim("cancelled")}`;
2051
2082
  }
2052
- async function ask(question, { hint, terminal = process20 }, render, press) {
2083
+ async function ask(question, { hint, terminal = process21 }, render, press) {
2053
2084
  const { stdin, stderr } = terminal;
2054
2085
  if (!isInteractive(terminal))
2055
2086
  fail(`cannot ask "${question}" off a terminal`, 2, hint);
@@ -2059,8 +2090,7 @@ async function ask(question, { hint, terminal = process20 }, render, press) {
2059
2090
  const columns = () => stderr.columns || 80;
2060
2091
  const draw = (state, last = false) => {
2061
2092
  const frame = render(colors, state, { columns: columns(), rows: stderr.rows || 24 });
2062
- stderr.write(`\r\x1B[0J${frame.join(`
2063
- `)}${last || frame.length < 2 ? "" : `\x1B[${frame.length - 1}A`}${last ? "" : "\r"}`);
2093
+ stderr.write(`${SYNC_START}\r${overwrite(frame, columns())}\x1B[0J${last || frame.length < 2 ? "" : `\x1B[${frame.length - 1}A`}${last ? "" : "\r"}${SYNC_END}`);
2064
2094
  current = state;
2065
2095
  };
2066
2096
  const redraw = () => draw(current);
@@ -2425,9 +2455,8 @@ var LARGE = 100 * 1024 ** 2;
2425
2455
  var BIG = 1024 ** 3;
2426
2456
  var USAGE3 = `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_DEPTH3} levels down), largest first with the age of the repo's last commit; --only worktrees, folders or caches keeps one kind
2427
2457
 
2428
- 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.
2429
-
2430
- 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.`;
2458
+ 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.`;
2459
+ var EXITS3 = [[0, "it listed, or removed every entry it was allowed to"], [1, "a removal failed or the confirm was declined"], [2, "a usage error, a missing root, or --apply off a terminal without --yes"]];
2431
2460
  var ONLY_KINDS = { worktrees: "worktree", folders: "folder", caches: "cache" };
2432
2461
  var OPTIONS3 = {
2433
2462
  apply: { type: "boolean", description: "delete what is listed as removable, after the confirm" },
@@ -2449,7 +2478,7 @@ async function dockerUsage() {
2449
2478
  }
2450
2479
  }
2451
2480
  async function sweep(args) {
2452
- const { values, positionals } = parse(args, USAGE3, OPTIONS3, { 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"] });
2481
+ const { values, positionals } = parse(args, USAGE3, OPTIONS3, { exits: EXITS3, positionals: ["[root]"], replaces: "find ~/Workspace -name node_modules, du -sh and rm -rf by hand", examples: ["sweep", "sweep ~/Workspace --older 30d --min 100M --apply", "sweep --only worktrees --apply"] });
2453
2482
  if (positionals.length > 1)
2454
2483
  badUsage("give one root");
2455
2484
  const root = workspaceRoot({ given: positionals[0] });
@@ -2527,7 +2556,7 @@ ${tt(reclaimable)} reclaimable${skipped === 0 ? "" : `, ${skipped} skipped (syml
2527
2556
  }
2528
2557
 
2529
2558
  // src/cli.ts
2530
- process21.exitCode = await runCli({
2559
+ process22.exitCode = await runCli({
2531
2560
  name: "ws",
2532
2561
  about: "the repositories under a root: the ones needing attention, the folders worth reclaiming and their known vulnerabilities",
2533
2562
  replaces: "a cd, git status and du loop over each repository of the workspace, and a bun audit run in each",