sumlyzer 1.4.1 → 1.6.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/CHANGELOG.md CHANGED
@@ -6,6 +6,27 @@ follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [1.6.0] - 2026-11-27
10
+
11
+ ### Changed
12
+
13
+ - `--changed` also runs the workspaces that depend on a changed one, like `--watch`.
14
+
15
+ ## [1.5.0] - 2026-11-26
16
+
17
+ ### Added
18
+
19
+ - `-v, --version` prints the installed version.
20
+
21
+ ### Fixed
22
+
23
+ - Scripts and their `pre`/`post` hooks get the same `npm_package_*` and
24
+ `npm_lifecycle_*` variables as with `npm run`.
25
+ - A missing or invalid root `package.json` prints a one-line error instead
26
+ of a stack trace.
27
+ - Windows: `node:test` workspaces crashed, `--junit` paths lost their
28
+ separators, `--changed`/`--watch` matched no workspace.
29
+
9
30
  ## [1.4.1] - 2026-11-25
10
31
 
11
32
  ### Security
@@ -100,7 +121,9 @@ No release notes, see the [diff](https://github.com/ErwanRaulo/sumlyzer/compare/
100
121
  Earlier versions (`0.1.1` to `0.5.3`) have no release notes, see the
101
122
  [tags](https://github.com/ErwanRaulo/sumlyzer/tags).
102
123
 
103
- [Unreleased]: https://github.com/ErwanRaulo/sumlyzer/compare/v1.4.1...HEAD
124
+ [Unreleased]: https://github.com/ErwanRaulo/sumlyzer/compare/v1.6.0...HEAD
125
+ [1.6.0]: https://github.com/ErwanRaulo/sumlyzer/compare/v1.5.0...v1.6.0
126
+ [1.5.0]: https://github.com/ErwanRaulo/sumlyzer/compare/v1.4.1...v1.5.0
104
127
  [1.4.1]: https://github.com/ErwanRaulo/sumlyzer/compare/v1.4.0...v1.4.1
105
128
  [1.4.0]: https://github.com/ErwanRaulo/sumlyzer/compare/v1.3.1...v1.4.0
106
129
  [1.3.1]: https://github.com/ErwanRaulo/sumlyzer/compare/v1.3.0...v1.3.1
package/README.md CHANGED
@@ -20,7 +20,8 @@ output. Sumlyzer fixes that, and runs workspaces concurrently too (~3.5x
20
20
  faster, see [Benchmark](#benchmark)).
21
21
 
22
22
  Scope: **npm workspaces** running **`node:test`** only, for now. No
23
- pnpm/yarn, no Jest/Vitest/Mocha.
23
+ pnpm/yarn, no Jest/Vitest/Mocha. Tested on Linux, macOS and Windows, with
24
+ Node.js 22, 24 and 26.
24
25
 
25
26
  ## Install
26
27
 
@@ -45,6 +46,7 @@ Run from the root of an npm workspaces project.
45
46
  | `--junit <path>` | off | write an aggregated JUnit XML report |
46
47
  | `--ref <ref>` | auto-detect | git ref to diff against for `--changed` |
47
48
  | `-w, --watch` | off | re-run on file change (can't be combined with `--junit`) |
49
+ | `-v, --version` | | print the sumlyzer version |
48
50
  | `-h, --help` | | print usage |
49
51
 
50
52
  Exit code is `1` if any workspace fails, `0` otherwise — safe to drop straight into CI.
@@ -66,7 +68,7 @@ Exit code is `1` if any workspace fails, `0` otherwise — safe to drop straight
66
68
  - **JUnit** (`--junit <path>`): merges every workspace's `node:test` JUnit output into one file, each `<testsuite>` prefixed with its workspace name. A workspace whose script never produces one is left out, with a warning naming it.
67
69
  - **GitHub Actions**: on `GITHUB_ACTIONS=true`, each workspace's output is auto-wrapped in a collapsible `::group::` block. No other CI provider has folding support yet.
68
70
  - **Concurrency** (`--concurrency <n>`): workspaces finish in whatever order they complete, so output interleaves. With `--ff`, only workspaces that haven't started yet are skipped — in-flight ones run to completion.
69
- - **Changed workspaces** (`--changed`): maps changed files to the workspace directory containing them. Ref auto-detection: uncommitted changes → diff against `HEAD`; clean tree with upstream → merge-base with upstream; clean tree with no upstream → `HEAD`.
71
+ - **Changed workspaces** (`--changed`): maps changed files to the workspace directory containing them, then adds the workspaces that depend on those, transitively, like `--watch`. Ref auto-detection: uncommitted changes → diff against `HEAD`; clean tree with upstream → merge-base with upstream; clean tree with no upstream → `HEAD`.
70
72
  - **Watch mode** (`--watch`): runs once, then keeps watching the workspaces directories. Re-runs the workspace that changed, plus every workspace of the same project that depends on it, directly or transitively, through `dependencies`/`devDependencies`. `node_modules`, `.git`, `coverage`, and dotfiles are ignored. Stop with `Ctrl+C`. Not compatible with `--junit`.
71
73
  - Own `--test-reporter` in a workspace's script is detected ahead of time and that workspace is skipped, to avoid colliding with sumlyzer's own reporter.
72
74
 
package/bin/sumlyzer.mjs CHANGED
@@ -1,14 +1,15 @@
1
1
  #!/usr/bin/env node
2
+ import { readFileSync } from "node:fs";
2
3
  import { parseArgs } from "node:util";
3
4
  import path from "node:path";
4
5
  import { availableParallelism } from "node:os";
5
6
 
6
7
  import { main } from "../src/run.mjs";
7
- import { NoWorkspacesError, InvalidPackageJsonError, WorkspaceLaunchError, GitDiffError } from "../src/errors.mjs";
8
- import { red } from "../src/reporter.mjs";
8
+ import { NoWorkspacesError, InvalidPackageJsonError, RootPackageJsonError, WorkspaceLaunchError, GitDiffError } from "../src/errors.mjs";
9
+ import * as reporter from "../src/reporter.mjs";
9
10
 
10
11
  function printWorkspaceError(message) {
11
- console.error(red(message.split("\n").map((line) => `✗ ${line}`).join("\n")));
12
+ console.error(reporter.red(message.split("\n").map((line) => `✗ ${line}`).join("\n")));
12
13
  }
13
14
 
14
15
  let args;
@@ -22,7 +23,8 @@ try {
22
23
  changed: { type: "boolean", default: false },
23
24
  ref: { type: "string" },
24
25
  watch: { type: "boolean", short: "w", default: false },
25
- help: { type: "boolean", short: "h", default: false }
26
+ help: { type: "boolean", short: "h", default: false },
27
+ version: { type: "boolean", short: "v", default: false }
26
28
  }
27
29
  }));
28
30
  }
@@ -33,6 +35,12 @@ catch (error) {
33
35
  process.exit(1);
34
36
  }
35
37
 
38
+ if (args.version) {
39
+ const { version } = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
40
+ console.log(version);
41
+ process.exit(0);
42
+ }
43
+
36
44
  let concurrency = Number.parseInt(args.concurrency, 10);
37
45
  if (!Number.isInteger(concurrency) || concurrency < 1 || String(concurrency) !== args.concurrency) {
38
46
  console.info(`--concurrency must be a positive integer, got "${args.concurrency}". Run "sumlyzer --help" for usage.`);
@@ -72,13 +80,14 @@ Options:
72
80
  -w, --watch re-run on file change, only for changed workspaces
73
81
  and the ones that depend on them (can't be combined
74
82
  with --junit)
83
+ -v, --version print the sumlyzer version
75
84
  -h, --help show this help
76
85
  `);
77
86
  process.exit(0);
78
87
  }
79
88
 
80
89
  try {
81
- await main({
90
+ const { failed } = await main({
82
91
  root: path.resolve(process.cwd()),
83
92
  scriptName: args.script,
84
93
  ff: args.ff,
@@ -86,14 +95,18 @@ try {
86
95
  concurrency,
87
96
  changed: args.changed,
88
97
  ref: args.ref,
89
- watch: args.watch
98
+ watch: args.watch,
99
+ reporter
90
100
  });
101
+ if (failed) {
102
+ process.exitCode = 1;
103
+ }
91
104
  }
92
105
  catch (error) {
93
106
  if (error instanceof NoWorkspacesError) {
94
107
  console.info(error.message);
95
108
  }
96
- else if (error instanceof InvalidPackageJsonError || error instanceof WorkspaceLaunchError || error instanceof GitDiffError) {
109
+ else if (error instanceof RootPackageJsonError || error instanceof InvalidPackageJsonError || error instanceof WorkspaceLaunchError || error instanceof GitDiffError) {
97
110
  printWorkspaceError(error.message);
98
111
  }
99
112
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sumlyzer",
3
- "version": "1.4.1",
3
+ "version": "1.6.0",
4
4
  "description": "Run every npm workspace's test script, only show output for the ones that fail, and finish with an aggregated pass/fail summary.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -17,13 +17,14 @@
17
17
  "node": ">=22.0.0"
18
18
  },
19
19
  "scripts": {
20
- "test": "node --test \"./test/*.spec.mjs\"",
20
+ "test": "node --test --test-timeout=60000 \"./test/*.spec.mjs\"",
21
21
  "pretest:coverage": "mkdir -p coverage",
22
- "test:coverage": "node --no-warnings --experimental-test-coverage --test-coverage-lines=95 --test-coverage-functions=95 --test-coverage-branches=85 --test-reporter=spec --test-reporter-destination=stdout --test-reporter=lcov --test-reporter-destination=coverage/lcov.info --test \"./test/*.spec.mjs\"",
22
+ "test:coverage": "node --no-warnings --experimental-test-coverage --test-coverage-lines=95 --test-coverage-functions=95 --test-coverage-branches=85 --test-timeout=60000 --test-reporter=spec --test-reporter-destination=stdout --test-reporter=lcov --test-reporter-destination=coverage/lcov.info --test \"./test/*.spec.mjs\"",
23
23
  "security-scan": "node scripts/security-scan.mjs",
24
24
  "postversion": "git push && git push --tags",
25
25
  "prepublishOnly": "npm test",
26
- "release": "npm publish --dry-run"
26
+ "release": "npm publish --dry-run",
27
+ "typecheck": "tsc -p jsconfig.json"
27
28
  },
28
29
  "keywords": [
29
30
  "npm workspaces test output",
@@ -56,7 +57,8 @@
56
57
  "devDependencies": {
57
58
  "@nodesecure/js-x-ray": "^16.2.0",
58
59
  "@types/node": "^26.6.10",
59
- "fast-xml-parser": "^5.12.1"
60
+ "fast-xml-parser": "^5.12.1",
61
+ "typescript": "~6.0.3"
60
62
  },
61
63
  "dependencies": {
62
64
  "glob": "^14.0.6"
package/src/changed.mjs CHANGED
@@ -1,6 +1,7 @@
1
1
  import { spawnSync } from "node:child_process";
2
2
 
3
3
  import { GitDiffError } from "./errors.mjs";
4
+ import { buildDependentsGraph, expandWithDependents } from "./graph.mjs";
4
5
 
5
6
  function runGit(root, args, ref) {
6
7
  const result = spawnSync("git", args, { cwd: root, encoding: "utf8" });
@@ -21,8 +22,7 @@ function tryGit(root, args) {
21
22
  }
22
23
 
23
24
  export function getChangedFiles(root, ref) {
24
- // --end-of-options keeps a ref like "--output=<file>" from being parsed as an
25
- // option, the trailing "--" keeps it from being parsed as a pathspec.
25
+ // The ref can't be read as an option (--end-of-options) or a pathspec (--).
26
26
  const tracked = runGit(root, ["diff", "--name-only", "--end-of-options", ref, "--"], ref);
27
27
  const untracked = runGit(root, ["ls-files", "--others", "--exclude-standard"], ref);
28
28
 
@@ -48,8 +48,7 @@ export function resolveDefaultRef(root) {
48
48
  return { ref: upstream, label: upstream, reason: "no merge-base found" };
49
49
  }
50
50
 
51
- // Attributes each changed file to the resolved workspace whose directory contains
52
- // it. A file outside every workspace directory is reported as "rootChangeFiles"
51
+ // Maps each changed file to its innermost workspace; the rest are root changes.
53
52
  export function selectChangedWorkspaces(resolvedWorkspaces, changedFiles) {
54
53
  const sorted = [...resolvedWorkspaces].sort((a, b) => b.length - a.length);
55
54
  const workspaces = new Set();
@@ -67,3 +66,24 @@ export function selectChangedWorkspaces(resolvedWorkspaces, changedFiles) {
67
66
 
68
67
  return { workspaces, rootChangeFiles };
69
68
  }
69
+
70
+ export function resolveChangedRef(root, explicitRef) {
71
+ return explicitRef
72
+ ? { ref: explicitRef, label: explicitRef, reason: null, autoDetected: false }
73
+ : { ...resolveDefaultRef(root), autoDetected: true };
74
+ }
75
+
76
+ // The workspaces changed since `ref`, plus their dependents.
77
+ export function selectAffectedWorkspaces({ root, allPaths, workspaces, ref }) {
78
+ const changedFiles = getChangedFiles(root, ref);
79
+ const { workspaces: changedPaths, rootChangeFiles } = selectChangedWorkspaces(allPaths, changedFiles);
80
+ const affectedPaths = expandWithDependents(changedPaths, buildDependentsGraph(root, allPaths));
81
+ const affected = workspaces.filter((workspace) => affectedPaths.has(workspace.path));
82
+
83
+ return {
84
+ hasChanges: changedFiles.length > 0,
85
+ rootChangeFiles,
86
+ affected,
87
+ dependents: affected.filter((workspace) => !changedPaths.has(workspace.path)).map((workspace) => workspace.name)
88
+ };
89
+ }
package/src/errors.mjs CHANGED
@@ -1,5 +1,3 @@
1
- import { workspaceName } from "./reporter.mjs";
2
-
3
1
  export class NoWorkspacesError extends Error {
4
2
  constructor() {
5
3
  super("Your project does not have any workspaces.");
@@ -7,19 +5,28 @@ export class NoWorkspacesError extends Error {
7
5
  }
8
6
  }
9
7
 
8
+ export class RootPackageJsonError extends Error {
9
+ constructor(root, cause) {
10
+ super(cause.code === "ENOENT"
11
+ ? `No package.json found in ${root}. Run sumlyzer from the root of an npm workspaces project.`
12
+ : `could not read the root package.json (${cause.message})`, { cause });
13
+ this.name = "RootPackageJsonError";
14
+ }
15
+ }
16
+
10
17
  export class InvalidPackageJsonError extends Error {
11
18
  constructor(entries) {
12
- super(entries.map(({ wsPath, message }) => `${workspaceName(wsPath)}: could not read its package.json (${message})`).join("\n"));
19
+ super(entries.map(({ workspace, message }) => `${workspace.name}: could not read its package.json (${message})`).join("\n"));
13
20
  this.name = "InvalidPackageJsonError";
14
21
  this.entries = entries;
15
22
  }
16
23
  }
17
24
 
18
25
  export class WorkspaceLaunchError extends Error {
19
- constructor(wsPath, scriptName, cause) {
20
- super(`${workspaceName(wsPath)}: could not launch "${scriptName}" (${cause.message})`, { cause });
26
+ constructor(workspace, scriptName, cause) {
27
+ super(`${workspace.name}: could not launch "${scriptName}" (${cause.message})`, { cause });
21
28
  this.name = "WorkspaceLaunchError";
22
- this.wsPath = wsPath;
29
+ this.workspace = workspace;
23
30
  this.scriptName = scriptName;
24
31
  }
25
32
  }
@@ -0,0 +1,45 @@
1
+ import { readFile, stat, writeFile } from "node:fs/promises";
2
+ import path from "node:path";
3
+
4
+ import { buildJunitReport } from "./junit.mjs";
5
+
6
+ const DEFAULT_JUNIT_FILENAME = "junit.xml";
7
+
8
+ async function collectJunitEntries(results) {
9
+ const entries = [];
10
+ const missing = [];
11
+
12
+ for (const result of results) {
13
+ if (!result.junitDestPath) {
14
+ continue;
15
+ }
16
+ try {
17
+ entries.push({ name: result.workspace.name, xml: await readFile(result.junitDestPath, "utf8") });
18
+ }
19
+ catch {
20
+ missing.push(result.workspace.name);
21
+ }
22
+ }
23
+
24
+ return { entries, missing };
25
+ }
26
+
27
+ async function resolveDestination(root, junitPath) {
28
+ const destination = path.resolve(root, junitPath);
29
+ const isDirectory = await stat(destination).then((stats) => stats.isDirectory(), () => false);
30
+
31
+ return isDirectory ? path.join(destination, DEFAULT_JUNIT_FILENAME) : destination;
32
+ }
33
+
34
+ export async function writeJunitReport(root, junitPath, results) {
35
+ const { entries, missing } = await collectJunitEntries(results);
36
+ const destination = await resolveDestination(root, junitPath);
37
+
38
+ try {
39
+ await writeFile(destination, buildJunitReport(entries));
40
+ return { destination, missing, error: null };
41
+ }
42
+ catch (error) {
43
+ return { destination, missing, error };
44
+ }
45
+ }
@@ -0,0 +1,43 @@
1
+ import path from "node:path";
2
+
3
+ // Mirrors @npmcli/run-script: package fields flattened to npm_package_<path>,
4
+ // with arrays indexed, null/false as "" and undefined skipped.
5
+ function flattenPackageFields(fields, prefix, env = {}) {
6
+ for (const [key, value] of Object.entries(fields)) {
7
+ if (value === undefined) {
8
+ continue;
9
+ }
10
+ if (value === null || value === false) {
11
+ env[`${prefix}${key}`] = "";
12
+ }
13
+ else if (Array.isArray(value)) {
14
+ value.forEach((item, index) => flattenPackageFields({ [`${key}_${index}`]: item }, prefix, env));
15
+ }
16
+ else if (typeof value === "object") {
17
+ flattenPackageFields(value, `${prefix}${key}_`, env);
18
+ }
19
+ else {
20
+ env[`${prefix}${key}`] = String(value);
21
+ }
22
+ }
23
+
24
+ return env;
25
+ }
26
+
27
+ // The variables npm run sets for a lifecycle script, so a workspace script behaves
28
+ // the same under sumlyzer. Only the fields npm itself exposes (npm/rfcs#183).
29
+ export function npmScriptEnv({ pkg, pkgDir, event, script }) {
30
+ return {
31
+ ...flattenPackageFields({
32
+ name: pkg.name,
33
+ version: pkg.version,
34
+ config: pkg.config,
35
+ engines: pkg.engines,
36
+ // npm exposes nothing for a string "bin", only for the object form.
37
+ bin: typeof pkg.bin === "object" ? pkg.bin : undefined
38
+ }, "npm_package_"),
39
+ npm_package_json: path.resolve(pkgDir, "package.json"),
40
+ npm_lifecycle_event: event,
41
+ npm_lifecycle_script: script
42
+ };
43
+ }
@@ -0,0 +1,12 @@
1
+ // Windows env names are case-insensitive ("Path"): replace the key instead of adding a duplicate.
2
+ export function withPath(env, value, platform = process.platform) {
3
+ if (platform !== "win32") {
4
+ return { ...env, PATH: value };
5
+ }
6
+
7
+ const isPathKey = (key) => key.toUpperCase() === "PATH";
8
+ const key = Object.keys(env).find(isPathKey) ?? "Path";
9
+ const rest = Object.fromEntries(Object.entries(env).filter(([name]) => !isPathKey(name)));
10
+
11
+ return { ...rest, [key]: value };
12
+ }
package/src/reporter.mjs CHANGED
@@ -1,10 +1,12 @@
1
1
  import { styleText } from "node:util";
2
2
 
3
- export const green = (str) => styleText("green", str);
3
+ import { workspaceName } from "./workspaces.mjs";
4
+
5
+ const green = (str) => styleText("green", str);
4
6
  export const red = (str) => styleText("red", str);
5
- export const blue = (str) => styleText("blue", str);
6
- export const dim = (str) => styleText("dim", str);
7
- export const bold = (str) => styleText("bold", str);
7
+ const blue = (str) => styleText("blue", str);
8
+ const dim = (str) => styleText("dim", str);
9
+ const bold = (str) => styleText("bold", str);
8
10
 
9
11
  export function formatSeconds(ms) {
10
12
  const seconds = Number.isFinite(ms) ? ms / 1000 : 0;
@@ -22,10 +24,6 @@ export function githubGroupSyntax(env) {
22
24
  return null;
23
25
  }
24
26
 
25
- export function workspaceName(wsPath) {
26
- return (wsPath ?? "").replace(/^workspaces[\\/]/, "");
27
- }
28
-
29
27
  export function ciGroupTitle(name, result) {
30
28
  const seconds = formatSeconds(result.durationMs);
31
29
  const countsLabel = result.counts ? ` (${result.counts.pass}/${result.counts.tests} tests)` : "";
@@ -39,7 +37,7 @@ function printWorkspaceResultCi(name, result, ciGroup) {
39
37
  process.stdout.write(`${ciGroup.end()}\n`);
40
38
  }
41
39
 
42
- export function printWorkspaceResult(name, result, ciGroup) {
40
+ export function printWorkspaceResult(name, result, ciGroup = githubGroupSyntax(process.env)) {
43
41
  if (ciGroup) {
44
42
  printWorkspaceResultCi(name, result, ciGroup);
45
43
  return;
@@ -70,7 +68,7 @@ function summaryRow(status, duration, counts) {
70
68
  function extraCountsFootnote(results, key, label) {
71
69
  const entries = results
72
70
  .filter(({ counts }) => Number(counts?.[key]) > 0)
73
- .map(({ wsPath, counts }) => `${workspaceName(wsPath)} (${counts[key]})`);
71
+ .map(({ workspace, counts }) => `${workspace.name} (${counts[key]})`);
74
72
 
75
73
  return entries.length > 0 ? `${label}: ${entries.join(", ")}` : null;
76
74
  }
@@ -79,11 +77,11 @@ export function printSummary(results, skipped) {
79
77
  console.log(bold("\nSummary"));
80
78
 
81
79
  const rows = {};
82
- for (const { wsPath, exitCode, durationMs, counts } of results) {
83
- rows[workspaceName(wsPath)] = summaryRow(exitCode === 0 ? "PASS" : "FAIL", formatSeconds(durationMs), counts);
80
+ for (const { workspace, exitCode, durationMs, counts } of results) {
81
+ rows[workspace.name] = summaryRow(exitCode === 0 ? "PASS" : "FAIL", formatSeconds(durationMs), counts);
84
82
  }
85
- for (const wsPath of skipped) {
86
- rows[workspaceName(wsPath)] = summaryRow("SKIPPED", "-", null);
83
+ for (const workspace of skipped) {
84
+ rows[workspace.name] = summaryRow("SKIPPED", "-", null);
87
85
  }
88
86
 
89
87
  console.table(rows);
@@ -96,7 +94,7 @@ export function printSummary(results, skipped) {
96
94
  }
97
95
 
98
96
  if (skipped.length > 0) {
99
- console.log(dim(`${skipped.length} workspace(s) skipped (--ff): ${skipped.map(workspaceName).join(", ")}`));
97
+ console.log(dim(`${skipped.length} workspace(s) skipped (--ff): ${skipped.map((workspace) => workspace.name).join(", ")}`));
100
98
  }
101
99
  }
102
100
 
@@ -110,10 +108,74 @@ export function reportOutcome(results) {
110
108
 
111
109
  console.log(red(`${failed.length}/${results.length} workspace(s) failed:`));
112
110
  for (const result of failed) {
113
- console.log(red(` ${workspaceName(result.wsPath)}`));
111
+ console.log(red(` ${result.workspace.name}`));
114
112
  for (const testName of result.failingTests) {
115
113
  console.log(dim(` ✖ ${testName}`));
116
114
  }
117
115
  }
118
- process.exitCode = 1;
116
+ }
117
+
118
+ export function printWorkspaceStart(name) {
119
+ process.stdout.write(dim(`running ${name}\n`));
120
+ }
121
+
122
+ export function printChangedRef({ label, reason, autoDetected }) {
123
+ if (autoDetected) {
124
+ console.log(dim(`--changed: no --ref given, comparing against "${label}" (${reason})`));
125
+ }
126
+ }
127
+
128
+ export function printChangedSelection({ label, total, selection }) {
129
+ if (!selection.hasChanges) {
130
+ console.log(dim(`No changes detected against "${label}".`));
131
+ return;
132
+ }
133
+
134
+ const { rootChangeFiles, affected, dependents } = selection;
135
+ if (rootChangeFiles.length > 0) {
136
+ const suffix = rootChangeFiles.length > 1 ? ` (+${rootChangeFiles.length - 1} more)` : "";
137
+ console.log(dim(`--changed: "${rootChangeFiles[0]}"${suffix} is outside every workspace, ignoring`));
138
+ }
139
+
140
+ const dependentsNote = dependents.length > 0 ? ` (incl. dependents: ${dependents.join(", ")})` : "";
141
+ console.log(dim(`--changed: running ${affected.length}/${total} workspace(s) with changes since "${label}"${dependentsNote}`));
142
+
143
+ if (affected.length === 0) {
144
+ console.log(dim("No eligible workspace changed."));
145
+ }
146
+ }
147
+
148
+ export function printJunitReport({ destination, missing, error }) {
149
+ if (missing.length > 0) {
150
+ console.log(dim(`${missing.length} workspace(s) missing from the JUnit report: ${missing.join(", ")}`));
151
+ }
152
+ if (error) {
153
+ console.error(red(`Could not write JUnit report to "${destination}" (${error.message})`));
154
+ }
155
+ }
156
+
157
+ export function printWatchRerun(changedPaths, affected) {
158
+ const changedNames = [...changedPaths].map(workspaceName).join(", ");
159
+ const affectedNames = affected.map((workspace) => workspace.name).join(", ");
160
+ console.log(dim(`\n[watch] change detected in ${changedNames} → re-running: ${affectedNames}\n`));
161
+ }
162
+
163
+ export function printWatchStopping() {
164
+ console.log(dim("\n[watch] stopping.\n"));
165
+ }
166
+
167
+ export function printOwnReporterSkips(scriptName, workspaces) {
168
+ for (const workspace of workspaces) {
169
+ console.log(dim(`⊘ ${workspace.name}: skipped, own --test-reporter detected in its "${scriptName}" script`));
170
+ }
171
+ }
172
+
173
+ export function printNothingToRun(scriptName, ownReporterConflicts) {
174
+ console.log(dim(ownReporterConflicts.length > 0
175
+ ? `All workspaces with a "${scriptName}" script were skipped (own --test-reporter detected).`
176
+ : `No workspace has a "${scriptName}" script.`));
177
+ }
178
+
179
+ export function printNoJunitWritten(junitPath) {
180
+ console.log(dim(`--junit: no report written to "${junitPath}" (no workspace ran)`));
119
181
  }