@kaynooo/cli-workspace 0.11.1 → 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
@@ -1428,30 +1428,6 @@ function commandPath(scope, argv) {
1428
1428
  }
1429
1429
  return path.length === 0 ? undefined : path.join(" ");
1430
1430
  }
1431
- async function runMain({ name, version, run, redact, usage }, argv = scriptArgs()) {
1432
- if (argv[0] === COMPLETE)
1433
- return printCandidates(leafCandidates(run, argv.slice(1)));
1434
- if (argv[0] === COMPLETIONS || argv[0]?.startsWith(`${COMPLETIONS}=`) === true)
1435
- return printCompletionScript(name, flagValue(argv));
1436
- if (argv.length === 1 && (argv[0] === "--version" || argv[0] === "-v")) {
1437
- console.log(version ?? packageVersion());
1438
- return 0;
1439
- }
1440
- let code;
1441
- const started = performance.now();
1442
- try {
1443
- code = await run(argv);
1444
- } catch (error) {
1445
- code = reportThrown(name, error, redact, wantsJson(argv));
1446
- }
1447
- notifyEnd(name, code, performance.now() - started);
1448
- if (usage !== false) {
1449
- try {
1450
- recordUsage(usageEntry(name, undefined, argv, code));
1451
- } catch {}
1452
- }
1453
- return code;
1454
- }
1455
1431
  // ../kit/src/folders.ts
1456
1432
  var SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
1457
1433
  // ../kit/src/pool.ts
@@ -1785,7 +1761,7 @@ async function osvAudit(dir, level, ignore, fetcher = fetch) {
1785
1761
  }
1786
1762
 
1787
1763
  // src/audit.ts
1788
- 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
1789
1765
 
1790
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.
1791
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.
@@ -1909,7 +1885,7 @@ function rows(findings) {
1909
1885
  ]);
1910
1886
  }
1911
1887
  async function audit(args) {
1912
- 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"] });
1913
1889
  const root = resolve5(positionals[0] ?? ".");
1914
1890
  if (!existsSync6(root) || !statSync2(root).isDirectory())
1915
1891
  fail(`no folder ${root}`);
@@ -2091,7 +2067,7 @@ async function fastForward(path) {
2091
2067
  }
2092
2068
 
2093
2069
  // src/repos.ts
2094
- 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
2095
2071
 
2096
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.
2097
2073
 
@@ -2157,7 +2133,7 @@ function row(repo, shown) {
2157
2133
  ];
2158
2134
  }
2159
2135
  async function repos(args) {
2160
- 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"]] });
2161
2137
  if (values.watch !== undefined)
2162
2138
  return watching(values.watch, async () => repos(withoutWatch(args)));
2163
2139
  const root = workspaceRoot({ given: positionals[0] });
@@ -2745,7 +2721,7 @@ async function applyAll(entries, done) {
2745
2721
  // src/sweep.ts
2746
2722
  var LARGE = 100 * 1024 ** 2;
2747
2723
  var BIG = 1024 ** 3;
2748
- 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
2749
2725
 
2750
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.`;
2751
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"]];
@@ -2770,7 +2746,7 @@ async function dockerUsage() {
2770
2746
  }
2771
2747
  }
2772
2748
  async function sweep(args) {
2773
- 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"] });
2774
2750
  if (positionals.length > 1)
2775
2751
  badUsage("give one root");
2776
2752
  const root = workspaceRoot({ given: positionals[0] });
package/package.json CHANGED
@@ -1,23 +1,20 @@
1
1
  {
2
2
  "name": "@kaynooo/cli-workspace",
3
3
  "type": "module",
4
- "version": "0.11.1",
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.41.0"
31
+ "@kaynooo/cli-kit": "0.41.1"
38
32
  }
39
33
  }