@kaynooo/cli-workspace 0.11.0 → 0.12.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/README.md CHANGED
@@ -1,24 +1,24 @@
1
1
  # @kaynooo/cli-workspace
2
2
 
3
- Three helpers for the repositories under a root, also reachable as `ws repos|sweep|audit`: `repos` lists the ones needing attention, `sweep` reclaims disk, `audit` lists known vulnerabilities.
3
+ `ws` helps with the repositories under a root: `ws repos` lists the ones needing attention, `ws sweep` reclaims disk, `ws audit` lists known vulnerabilities.
4
4
 
5
5
  ```sh
6
6
  bun add -g @kaynooo/cli-workspace
7
7
  ```
8
8
 
9
- ## repos
9
+ ## ws repos
10
10
 
11
- `repos` lists the git repositories under a workspace folder (the configured workspace folder, `~/Workspace` by default) that need attention: dirty files, commits not pushed, an upstream ahead of the branch, commits since the latest tag.
11
+ `ws repos` lists the git repositories under a workspace folder (the configured workspace folder, `~/Workspace` by default) that need attention: dirty files, commits not pushed, an upstream ahead of the branch, commits since the latest tag.
12
12
 
13
13
  | Command | What it does |
14
14
  | --- | --- |
15
- | `repos [root]` | one row per repository with something to report: branch, dirty files, ahead/behind its upstream, linked worktrees, commits since its latest tag |
16
- | `repos --all` | the clean repositories too |
17
- | `repos --only dirty\|unpushed\|unreleased\|behind` | only the repositories with that reason |
18
- | `repos --fetch` | refreshes each upstream first; it reaches the remote, so it is never done without the flag |
19
- | `repos --pull` | fetches, then fast-forwards the repositories listed that are clean, on a branch and only behind their upstream; each is reported as `pulled` or `skipped` with the reason (dirty, diverged and ahead, no upstream, detached HEAD, fetch failed), and nothing but a fast-forward is ever attempted. A repository pulled is listed again as it now stands. Combine with `--only behind` to touch only those |
20
- | `repos --path` | only the paths of the repositories listed, one per line, for `xargs -d '\n'` (the pull report, if any, goes to stderr) |
21
- | `repos --json` | the same data as JSON |
15
+ | `ws repos [root]` | one row per repository with something to report: branch, dirty files, ahead/behind its upstream, linked worktrees, commits since its latest tag |
16
+ | `ws repos --all` | the clean repositories too |
17
+ | `ws repos --only dirty\|unpushed\|unreleased\|behind` | only the repositories with that reason |
18
+ | `ws repos --fetch` | refreshes each upstream first; it reaches the remote, so it is never done without the flag |
19
+ | `ws repos --pull` | fetches, then fast-forwards the repositories listed that are clean, on a branch and only behind their upstream; each is reported as `pulled` or `skipped` with the reason (dirty, diverged and ahead, no upstream, detached HEAD, fetch failed), and nothing but a fast-forward is ever attempted. A repository pulled is listed again as it now stands. Combine with `--only behind` to touch only those |
20
+ | `ws repos --path` | only the paths of the repositories listed, one per line, for `xargs -d '\n'` (the pull report, if any, goes to stderr) |
21
+ | `ws repos --json` | the same data as JSON |
22
22
 
23
23
  Exits 0 when it listed the repositories, 1 when a fast-forward `--pull` attempted failed, 2 on a usage error.
24
24
 
@@ -30,16 +30,16 @@ Without `--fetch` the ahead and behind counts are those of the last fetch. The w
30
30
  { "skip": ["archived-thing", "vendored-clone"] }
31
31
  ```
32
32
 
33
- `concurrency` (a positive whole number, 8 by default) in the same file sets how many repositories are read at once. `audit` reads the same key from `~/.config/kaynooo-cli/audit.json` (4 by default, the repositories audited at once).
33
+ `concurrency` (a positive whole number, 8 by default) in the same file sets how many repositories are read at once. `ws audit` reads the same key from `~/.config/kaynooo-cli/audit.json` (4 by default, the repositories audited at once).
34
34
 
35
- ## sweep
35
+ ## ws sweep
36
36
 
37
- `sweep` reclaims disk across many repos: it lists the regenerable folders and clean git worktrees under a root, largest first, and deletes them only on `--apply`.
37
+ `ws sweep` reclaims disk across many repos: it lists the regenerable folders and clean git worktrees under a root, largest first, and deletes them only on `--apply`.
38
38
 
39
39
  | Command | What it does |
40
40
  | --- | --- |
41
- | `sweep [root]` | lists `node_modules`, `.output`, `dist`, `build`, `target` (beside a `Cargo.toml`), the caches (per project `.nuxt`, `.next`, `.turbo`, `.svelte-kit`, `node_modules/.cache`, listed only when `node_modules` is not; global `~/.bun/install/cache`, `~/.npm/_cacache`, `~/.cache/{pip,uv,ms-playwright,puppeteer,go-build,typescript}`, `~/.cargo/registry`, exact paths only, listed only when no root is given or with `--only caches`; a root narrows the scan to its own projects) and `.worktrees/*` and `.claude/worktrees/*` under root (the configured workspace folder, `~/Workspace` by default, three levels down) with size and the age of the repo's last commit; deletes nothing |
42
- | `sweep --apply` | deletes what is listed as removable after a confirm showing the total, read from the terminal |
41
+ | `ws sweep [root]` | lists `node_modules`, `.output`, `dist`, `build`, `target` (beside a `Cargo.toml`), the caches (per project `.nuxt`, `.next`, `.turbo`, `.svelte-kit`, `node_modules/.cache`, listed only when `node_modules` is not; global `~/.bun/install/cache`, `~/.npm/_cacache`, `~/.cache/{pip,uv,ms-playwright,puppeteer,go-build,typescript}`, `~/.cargo/registry`, exact paths only, listed only when no root is given or with `--only caches`; a root narrows the scan to its own projects) and `.worktrees/*` and `.claude/worktrees/*` under root (the configured workspace folder, `~/Workspace` by default, three levels down) with size and the age of the repo's last commit; deletes nothing |
42
+ | `ws sweep --apply` | deletes what is listed as removable after a confirm showing the total, read from the terminal |
43
43
  | `--yes` | with `--apply`, skip the confirm; without it, `--apply` refuses off a terminal |
44
44
  | `--older <duration>`, `--min <size>` | only the entries whose repo last committed longer ago (`30d`) or that weigh at least this much (`500K`, `10M`, `1G`) |
45
45
  | `--only worktrees\|folders\|caches` | keep one kind and leave the others out; `.nuxt`, `.next`, `.turbo` and `.svelte-kit` are caches, so `folders` does not list them |
@@ -47,20 +47,20 @@ Without `--fetch` the ahead and behind counts are those of the last fetch. The w
47
47
 
48
48
  Safety rules: a symlink is skipped and never followed, a folder git tracks files in is skipped, a build folder git does not ignore is skipped, and nothing outside the listed names is deleted. A folder is deleted for good (not trashed, which would not free the space). 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 are left out of the total. With `--docker` the Docker usage is shown, never acted on.
49
49
 
50
- ## audit
50
+ ## ws audit
51
51
 
52
- `audit` lists the known vulnerabilities of the Bun repositories under a folder (the current one by default), one table per repository.
52
+ `ws audit` lists the known vulnerabilities of the Bun repositories under a folder (the current one by default), one table per repository.
53
53
 
54
54
  | Command | What it does |
55
55
  | --- | --- |
56
- | `audit [root]` | one row per package with an advisory: its worst severity, how many advisories, `prod` when a production dependency needs it and `dev` when only a development one does, `direct` when the repository's package.json asks for it and `via` when a dependency does (the `origin` column), and the version that fixes every advisory at once |
57
- | `audit --level high` | only the advisories at least that severe: `low`, `moderate` (the default), `high` or `critical` |
58
- | `audit --prod` | only the packages a production dependency needs |
59
- | `audit --ignore GHSA-xxxx` | skip an advisory by GHSA or numeric id, repeatable, so an accepted advisory stops failing the run |
60
- | `audit --json` | `[{repo, path, findings: [{package, severity, scope, direct, fix, advisories: [{id, ghsa, url, title, severity, fixed}]}], error}]` |
56
+ | `ws audit [root]` | one row per package with an advisory: its worst severity, how many advisories, `prod` when a production dependency needs it and `dev` when only a development one does, `direct` when the repository's package.json asks for it and `via` when a dependency does (the `origin` column), and the version that fixes every advisory at once |
57
+ | `ws audit --level high` | only the advisories at least that severe: `low`, `moderate` (the default), `high` or `critical` |
58
+ | `ws audit --prod` | only the packages a production dependency needs |
59
+ | `ws audit --ignore GHSA-xxxx` | skip an advisory by GHSA or numeric id, repeatable, so an accepted advisory stops failing the run |
60
+ | `ws audit --json` | `[{repo, path, findings: [{package, severity, scope, direct, fix, advisories: [{id, ghsa, url, title, severity, fixed}]}], error}]` |
61
61
 
62
62
  It runs `bun audit --json` (and once more with `--prod`, which tells what reaches production) in each folder holding a `bun.lock`, so it reaches the registry. The walk goes three levels deep, stops at a `bun.lock` and skips `node_modules` and hidden folders. The worst rows and the production ones come first; a fix of `-` means an advisory names no fixed version, and a package with ranges for several majors is given the highest fix, which may be a major jump. A repository's workspaces are read as folders or `dir/*`; other globs are not, and their dependencies then show as `via`.
63
63
 
64
64
  It exits 1 when a repository has an advisory at the level asked, so it can gate a script; it exits 2 when a repository's audit failed, no `bun.lock` sits under the root, on a usage error or a root that is no folder.
65
65
 
66
- `audit` sweeps many repositories for advisories only. To vet one repository in depth (package age, install scripts, licences and advisories), use `pkg audit`, which shares `--level`, `--prod` and `--ignore` and nests the same advisory rows in a flat array.
66
+ `ws audit` sweeps many repositories for advisories only. To vet one repository in depth (package age, install scripts, licences and advisories), use `pkg audit`, which shares `--level`, `--prod` and `--ignore` and nests the same advisory rows in a flat array.
package/dist/cli.js CHANGED
@@ -656,7 +656,7 @@ class Completing {
656
656
  }
657
657
  var completion = { active: false };
658
658
  var OUTPUT_OPTIONS = {
659
- color: { type: "string", description: "auto (on a terminal alone), always or never" },
659
+ color: { type: "string", choices: ["auto", "always", "never"], description: "auto (the default) colours on a terminal alone" },
660
660
  plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
661
661
  };
662
662
  function applyOutput(color, plain, env = process9.env) {
@@ -993,6 +993,66 @@ import { readFileSync as readFileSync4, realpathSync as realpathSync2 } from "fs
993
993
  import { dirname as dirname3, join as join5 } from "path";
994
994
  import process15 from "process";
995
995
 
996
+ // ../kit/src/completions.ts
997
+ var COMPLETION_SHELLS = ["fish", "bash", "zsh"];
998
+ var FISH_FUNCTION = `functions -q __kaynooo_cli_complete; or function __kaynooo_cli_complete --argument-names bin --description 'what a @kaynooo/cli-kit bin offers for the word being typed'
999
+ set -l tokens (commandline -xpc 2>/dev/null; or commandline -opc)
1000
+ set -l current (commandline -ct)
1001
+ for line in ($bin __complete $tokens[2..-1] $current 2>/dev/null)
1002
+ if test "$line" = __files__
1003
+ __fish_complete_path $current
1004
+ else
1005
+ echo $line
1006
+ end
1007
+ end
1008
+ end`;
1009
+ var BASH_FUNCTION = `__kaynooo_cli_complete() {
1010
+ local IFS=$'\\n' cur=\${COMP_WORDS[COMP_CWORD]} line words=
1011
+ local -a lines
1012
+ COMPREPLY=()
1013
+ lines=($("\${COMP_WORDS[0]}" __complete "\${COMP_WORDS[@]:1:COMP_CWORD}" 2>/dev/null))
1014
+ for line in "\${lines[@]}"; do
1015
+ if [[ $line == __files__ ]]; then
1016
+ COMPREPLY+=($(compgen -f -- "$cur"))
1017
+ else
1018
+ words+="\${line%%$'\\t'*}"$'\\n'
1019
+ fi
1020
+ done
1021
+ COMPREPLY+=($(compgen -W "$words" -- "$cur"))
1022
+ }`;
1023
+ var ZSH_FUNCTION = `__kaynooo_cli_complete() {
1024
+ local line
1025
+ local -a described plain
1026
+ for line in \${(f)"$("\${words[1]}" __complete "\${(@)words[2,CURRENT]}" 2>/dev/null)"}; do
1027
+ if [[ $line == __files__ ]]; then
1028
+ _files
1029
+ elif [[ $line == *$'\\t'* ]]; then
1030
+ described+=("\${\${line%%$'\\t'*}//:/\\\\:}:\${line#*$'\\t'}")
1031
+ else
1032
+ plain+=("$line")
1033
+ fi
1034
+ done
1035
+ (( \${#described} )) && _describe -V value described
1036
+ (( \${#plain} )) && compadd -- "\${plain[@]}"
1037
+ return 0
1038
+ }`;
1039
+ function completionScript(shell, bins, header = `# Generated by \`${bins[0]} --completions ${shell}\``) {
1040
+ if (shell === "fish")
1041
+ return `${header}
1042
+ ${FISH_FUNCTION}
1043
+ ${bins.map((bin) => `complete -c ${bin} -f -a '(__kaynooo_cli_complete ${bin})'
1044
+ `).join("")}`;
1045
+ if (shell === "bash")
1046
+ return `${header}
1047
+ ${BASH_FUNCTION}
1048
+ complete -F __kaynooo_cli_complete ${bins.join(" ")}
1049
+ `;
1050
+ return `${header}
1051
+ ${ZSH_FUNCTION}
1052
+ compdef __kaynooo_cli_complete ${bins.join(" ")}
1053
+ `;
1054
+ }
1055
+
996
1056
  // ../kit/src/notify.ts
997
1057
  import process13 from "process";
998
1058
  var NOTIFY_AFTER_MS = 1e4;
@@ -1066,7 +1126,11 @@ var LEVEL_OPTIONS = {
1066
1126
  ...OUTPUT_OPTIONS,
1067
1127
  help: { type: "boolean", short: "h", description: "show this help" }
1068
1128
  };
1069
- var TOP_OPTIONS = { ...LEVEL_OPTIONS, version: { type: "boolean", short: "v", description: "print the version" } };
1129
+ var TOP_OPTIONS = {
1130
+ ...LEVEL_OPTIONS,
1131
+ version: { type: "boolean", short: "v", description: "print the version" },
1132
+ completions: { type: "string", choices: COMPLETION_SHELLS, description: "print the shell completion script" }
1133
+ };
1070
1134
  async function commandRows(all, colors) {
1071
1135
  const commands = shown(all);
1072
1136
  const width = Math.max(0, ...Object.keys(commands).map((name) => name.length));
@@ -1299,6 +1363,19 @@ async function candidates(scope, defaultCommand, words, before = []) {
1299
1363
  }
1300
1364
  return "commands" in command ? candidates(scopeOf(command.commands, command.extraCommands, command.aliases), undefined, rest, [...before, word]) : leafCandidates(command.run, rest);
1301
1365
  }
1366
+ var COMPLETIONS = "--completions";
1367
+ function flagValue([flag = "", ...rest]) {
1368
+ return flag.includes("=") ? [flag.slice(flag.indexOf("=") + 1), ...rest] : rest;
1369
+ }
1370
+ function printCompletionScript(name, args) {
1371
+ const shell = COMPLETION_SHELLS.find((each) => each === args[0]);
1372
+ if (shell === undefined || args.length !== 1) {
1373
+ printError(name, `${COMPLETIONS} takes one of ${COMPLETION_SHELLS.join(", ")}`, `${name} ${COMPLETIONS} fish`);
1374
+ return 2;
1375
+ }
1376
+ console.log(completionScript(shell, [name]).trimEnd());
1377
+ return 0;
1378
+ }
1302
1379
  async function printCandidates(found) {
1303
1380
  for (const line of await found)
1304
1381
  console.log(line);
@@ -1323,6 +1400,8 @@ async function runCli(cli, argv = scriptArgs()) {
1323
1400
  const version = cli.version ?? packageVersion();
1324
1401
  if (argv[0] === COMPLETE)
1325
1402
  return printCandidates(candidates(scopeOf(cli.commands, cli.extraCommands, cli.aliases), cli.defaultCommand, argv.slice(1)));
1403
+ if (argv[0] === COMPLETIONS || argv[0]?.startsWith(`${COMPLETIONS}=`) === true)
1404
+ return printCompletionScript(cli.name, flagValue(argv));
1326
1405
  const started = performance.now();
1327
1406
  const code = await dispatch({ path: [cli.name], header: (colors, about) => `${colors.bold(cli.name)} ${colors.dim(version)} ${about}`, summary: cli.about, ...scopeOf(cli.commands, cli.extraCommands, cli.aliases), defaultCommand: cli.defaultCommand, runBare: cli.runBare === true, examples: cli.examples, replaces: cli.replaces }, argv, { version, redact: cli.redact });
1328
1407
  const command = commandPath(scopeOf(cli.commands, cli.extraCommands, cli.aliases), argv);
@@ -1349,28 +1428,6 @@ function commandPath(scope, argv) {
1349
1428
  }
1350
1429
  return path.length === 0 ? undefined : path.join(" ");
1351
1430
  }
1352
- async function runMain({ name, version, run, redact, usage }, argv = scriptArgs()) {
1353
- if (argv[0] === COMPLETE)
1354
- return printCandidates(leafCandidates(run, argv.slice(1)));
1355
- if (argv.length === 1 && (argv[0] === "--version" || argv[0] === "-v")) {
1356
- console.log(version ?? packageVersion());
1357
- return 0;
1358
- }
1359
- let code;
1360
- const started = performance.now();
1361
- try {
1362
- code = await run(argv);
1363
- } catch (error) {
1364
- code = reportThrown(name, error, redact, wantsJson(argv));
1365
- }
1366
- notifyEnd(name, code, performance.now() - started);
1367
- if (usage !== false) {
1368
- try {
1369
- recordUsage(usageEntry(name, undefined, argv, code));
1370
- } catch {}
1371
- }
1372
- return code;
1373
- }
1374
1431
  // ../kit/src/folders.ts
1375
1432
  var SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
1376
1433
  // ../kit/src/pool.ts
@@ -1704,7 +1761,7 @@ async function osvAudit(dir, level, ignore, fetcher = fetch) {
1704
1761
  }
1705
1762
 
1706
1763
  // src/audit.ts
1707
- var USAGE = `audit [options] [root]: the known vulnerabilities of the Bun, Composer, Cargo and uv repositories under root (the current folder by default), one table per repository
1764
+ var USAGE = `ws audit [options] [root]: the known vulnerabilities of the Bun, Composer, Cargo and uv repositories under root (the current folder by default), one table per repository
1708
1765
 
1709
1766
  Each package with an advisory is one row: its worst severity, how many advisories, whether a production dependency needs it (prod) or only a development one (dev), whether the repository asks for it itself (direct) or a dependency does (the row then says via and the direct dependencies leading to it, upgrading one of which is what fixes it), and the version that fixes every advisory at once, "-" when an advisory names none. The worst and the production ones come first.
1710
1767
  Advisories under --level (moderate by default) are counted under the table, and what \`bun audit\` warned about, such as a private registry that would not audit its packages, is repeated there. It runs \`bun audit --json\` in each repository holding a bun.lock, which reaches the registry, and asks osv.dev about the packages of a composer.lock, Cargo.lock or uv.lock (a severity the source leaves out reads as moderate, and only composer's manifest tells direct from pulled in); the walk goes three levels deep, stops at a lockfile and skips node_modules and hidden folders.
@@ -1828,7 +1885,7 @@ function rows(findings) {
1828
1885
  ]);
1829
1886
  }
1830
1887
  async function audit(args) {
1831
- 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"] });
1888
+ 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: ["ws audit", "ws audit ~/Workspace --level high --prod"] });
1832
1889
  const root = resolve5(positionals[0] ?? ".");
1833
1890
  if (!existsSync6(root) || !statSync2(root).isDirectory())
1834
1891
  fail(`no folder ${root}`);
@@ -2010,7 +2067,7 @@ async function fastForward(path) {
2010
2067
  }
2011
2068
 
2012
2069
  // src/repos.ts
2013
- var USAGE2 = `repos [options] [root]: the git repositories under root (the configured workspace, ~/Workspace by default) that need attention, with their branch, dirty files, ahead/behind their upstream, linked worktrees and commits since their latest tag
2070
+ var USAGE2 = `ws repos [options] [root]: the git repositories under root (the configured workspace, ~/Workspace by default) that need attention, with their branch, dirty files, ahead/behind their upstream, linked worktrees and commits since their latest tag
2014
2071
 
2015
2072
  A repository with nothing to report is left out unless --all. A monorepo tagging its packages <folder>-v<version> counts the unreleased commits per package folder. The walk goes ${MAX_DEPTH2} levels deep, stops at a .git and skips node_modules, hidden folders and the names in "skip" of ~/.config/kaynooo-cli/repos.json.
2016
2073
 
@@ -2076,13 +2133,13 @@ function row(repo, shown) {
2076
2133
  ];
2077
2134
  }
2078
2135
  async function repos(args) {
2079
- const { values, positionals } = parse(args, USAGE2, OPTIONS2, { positionals: ["[root]"], exits: EXITS2, replaces: "a cd, git status, git log and git tag loop over each repository of the workspace", examples: ["repos", "repos ~/Workspace --only unreleased --fetch", ["repos --only behind --pull", "fast-forward what is behind and clean"], ["repos --only dirty --path", "the paths, for xargs"]] });
2136
+ const { values, positionals } = parse(args, USAGE2, OPTIONS2, { positionals: ["[root]"], exits: EXITS2, replaces: "a cd, git status, git log and git tag loop over each repository of the workspace", examples: ["ws repos", "ws repos ~/Workspace --only unreleased --fetch", ["ws repos --only behind --pull", "fast-forward what is behind and clean"], ["ws repos --only dirty --path", "the paths, for xargs"]] });
2080
2137
  if (values.watch !== undefined)
2081
2138
  return watching(values.watch, async () => repos(withoutWatch(args)));
2082
2139
  const root = workspaceRoot({ given: positionals[0] });
2083
2140
  if (!existsSync8(root) || !statSync3(root).isDirectory())
2084
2141
  fail(`no folder ${root}`);
2085
- const only = values.only === undefined ? undefined : oneOf(values.only, "only", REASONS);
2142
+ const only = values.only;
2086
2143
  const paths = await findRepos2(root, await skipped());
2087
2144
  const states = await pool(paths, configuredNumber("repos", "concurrency", CONCURRENCY2), async (path) => inspect(path, values.fetch === true || values.pull === true));
2088
2145
  const keeps = (repo) => {
@@ -2664,7 +2721,7 @@ async function applyAll(entries, done) {
2664
2721
  // src/sweep.ts
2665
2722
  var LARGE = 100 * 1024 ** 2;
2666
2723
  var BIG = 1024 ** 3;
2667
- var USAGE3 = `sweep [options] [root]: lists the regenerable folders (node_modules, .output, dist, build, .venv, target beside a Cargo.toml, vendor beside a composer.json or composer.lock), the caches (.nuxt, .next, .turbo, .svelte-kit, __pycache__, .gradle 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
2724
+ var USAGE3 = `ws sweep [options] [root]: lists the regenerable folders (node_modules, .output, dist, build, .venv, target beside a Cargo.toml, vendor beside a composer.json or composer.lock), the caches (.nuxt, .next, .turbo, .svelte-kit, __pycache__, .gradle 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
2668
2725
 
2669
2726
  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.`;
2670
2727
  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"]];
@@ -2674,7 +2731,7 @@ var OPTIONS3 = {
2674
2731
  yes: { type: "boolean", short: "y", description: "with --apply, skip the confirm" },
2675
2732
  older: { type: "string", description: "only the entries whose repo last committed longer ago than this (30d, 12h)" },
2676
2733
  min: { type: "string", description: "only the entries of at least this size (500K, 10M, 1G)" },
2677
- only: { type: "string", description: "worktrees, folders or caches: leave the other kinds out (.nuxt, .next, .turbo, .svelte-kit, __pycache__ and .gradle are caches; the global caches are listed with no root or with caches)" },
2734
+ only: { type: "string", choices: Object.keys(ONLY_KINDS), description: "leave the other kinds out (.nuxt, .next, .turbo, .svelte-kit, __pycache__ and .gradle are caches; the global caches are listed with no root or with caches)" },
2678
2735
  docker: { type: "boolean", description: "add the docker system df output, which alone takes about ten seconds" },
2679
2736
  json: jsonOption("{root, entries: [{path, kind (folder, worktree or cache), bytes, committedAt, action (remove or keep), reason}], skipped: [{path, reason}], reclaimable, docker, removed?}")
2680
2737
  };
@@ -2689,14 +2746,12 @@ async function dockerUsage() {
2689
2746
  }
2690
2747
  }
2691
2748
  async function sweep(args) {
2692
- 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"] });
2749
+ 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: ["ws sweep", "ws sweep ~/Workspace --older 30d --min 100M --apply", "ws sweep --only worktrees --apply"] });
2693
2750
  if (positionals.length > 1)
2694
2751
  badUsage("give one root");
2695
2752
  const root = workspaceRoot({ given: positionals[0] });
2696
2753
  if (!existsSync11(root) || !statSync4(root).isDirectory())
2697
2754
  fail(`${root} is not a folder`);
2698
- if (values.only !== undefined && !Object.hasOwn(ONLY_KINDS, values.only))
2699
- badUsage(`--only takes worktrees, folders or caches, not ${values.only}`);
2700
2755
  const olderMs = values.older === undefined ? undefined : duration(values.older, "older", 0);
2701
2756
  const minBytes = values.min === undefined ? 0 : parseSize(values.min);
2702
2757
  if (minBytes === undefined)
package/package.json CHANGED
@@ -1,23 +1,20 @@
1
1
  {
2
2
  "name": "@kaynooo/cli-workspace",
3
3
  "type": "module",
4
- "version": "0.11.0",
5
- "description": "ws, repos, sweep, audit: the repositories of the workspace that need attention, the folders worth reclaiming and their known vulnerabilities.",
4
+ "version": "0.12.0",
5
+ "description": "ws: 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",
8
- "homepage": "https://git.kaynooo.fr/kaynooo/cli/src/branch/main/packages/workspace#readme",
8
+ "homepage": "https://github.com/Kayno0o/cli/tree/main/packages/workspace#readme",
9
9
  "repository": {
10
10
  "type": "git",
11
- "url": "git+https://git.kaynooo.fr/kaynooo/cli.git",
11
+ "url": "git+https://github.com/Kayno0o/cli.git",
12
12
  "directory": "packages/workspace"
13
13
  },
14
- "bugs": "https://git.kaynooo.fr/kaynooo/cli/issues",
14
+ "bugs": "https://github.com/Kayno0o/cli/issues",
15
15
  "keywords": ["cli", "git", "workspace", "monorepo", "audit", "disk"],
16
16
  "bin": {
17
- "ws": "./dist/cli.js",
18
- "repos": "./dist/repos-cli.js",
19
- "sweep": "./dist/sweep-cli.js",
20
- "audit": "./dist/audit-cli.js"
17
+ "ws": "./dist/cli.js"
21
18
  },
22
19
  "files": ["dist"],
23
20
  "engines": {
@@ -27,13 +24,10 @@
27
24
  "registry": "https://git.kaynooo.fr/api/packages/kaynooo/npm/"
28
25
  },
29
26
  "scripts": {
30
- "build": "$npm_execpath build src/cli.ts src/repos-cli.ts src/sweep-cli.ts src/audit-cli.ts --target bun --outdir dist",
31
- "ws": "$npm_execpath src/cli.ts",
32
- "repos": "$npm_execpath src/repos-cli.ts",
33
- "sweep": "$npm_execpath src/sweep-cli.ts",
34
- "audit": "$npm_execpath src/audit-cli.ts"
27
+ "build": "$npm_execpath build src/cli.ts --target bun --outdir dist",
28
+ "ws": "$npm_execpath src/cli.ts"
35
29
  },
36
30
  "devDependencies": {
37
- "@kaynooo/cli-kit": "0.40.0"
31
+ "@kaynooo/cli-kit": "0.41.1"
38
32
  }
39
33
  }