@_linked/cli 1.46.0 → 1.46.2

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
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.46.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#262](https://github.com/linked-fw/cli/pull/262) [`e6b2a18`](https://github.com/linked-fw/cli/commit/e6b2a18506dc3fceaa8381bff21fdd5774bf6fee) Thanks [@flyon](https://github.com/flyon)! - `linked localize`'s prune no longer removes a checkout's own copy of a package that ships its own types while the checkout also holds an `@types/` stub for it. With the copy gone, TypeScript resolved the package to that stub instead of the app's copy — measured as `@_linked/cli`'s own build failing with `TS2724 '"minimatch"' has no exported member named 'minimatch'` once the app's `minimatch` moved into the checkout's range while the checkout kept `@types/minimatch@3` (depcheck → multimatch). The copy is kept and reported (`linked localize --list` names the stub), and a checkout an earlier prune left in that state counts as missing the package, so `--relink` reinstalls it.
8
+
9
+ ## 1.46.1
10
+
11
+ ### Patch Changes
12
+
13
+ - [#260](https://github.com/linked-fw/cli/pull/260) [`011395a`](https://github.com/linked-fw/cli/commit/011395a668641ea9fa41d80802eca1b156fe114f) Thanks [@flyon](https://github.com/flyon)! - `linked build-all` now builds `@_linked/cli` first and alone when it is one of the packages to build (a localized checkout). Every other package's build runs `linked build` from that checkout's `lib/`, so building it in parallel with them pulled `lib/` out from under their builds (`ENOENT …/lib/esm/installed-packages.js`) and left their dependents unbuilt, and anything built before it used a stale cli. If the cli fails to build, `build-all` now stops with a clear message instead of building the rest with a broken cli. `--from` a later package skips the cli as before; `--from @_linked/cli` builds it and then everything; `--sync` is unaffected.
14
+
15
+ - [#260](https://github.com/linked-fw/cli/pull/260) [`8e2e54a`](https://github.com/linked-fw/cli/commit/8e2e54ab03319c74d4382944eeeca048c272d242) Thanks [@flyon](https://github.com/flyon)! - `linked build-all`'s end-of-run summary now shows, under each package that failed to build, a short excerpt of why: the lines of its output that look like errors (`error TS…` with file and line, `Error: …` with its first stack frame, `npm ERR!` lines that say something), without npm's lifecycle boilerplate, de-duplicated, truncated and capped at 8 lines, falling back to the last lines of output when nothing looks like an error. The full output is still printed inline when the failure happens; the excerpt makes the cause visible at the end without scrolling back through the interleaved parallel builds.
16
+
3
17
  ## 1.46.0
4
18
 
5
19
  ### Minor Changes
@@ -11,7 +11,7 @@
11
11
  "test:integration": "jest -c jest.integration.config.js --runInBand"
12
12
  },
13
13
  "dependencies": {
14
- "@_linked/core": "2.28.1",
14
+ "@_linked/core": "2.28.3",
15
15
  "@_linked/react": "2.0.1",
16
16
  "@_linked/schema": "1.5.0",
17
17
  "@_linked/server": "2.24.8",
@@ -16,9 +16,9 @@
16
16
  "build": "linked build"
17
17
  },
18
18
  "dependencies": {
19
- "@_linked/core": "2.28.1"
19
+ "@_linked/core": "2.28.3"
20
20
  },
21
21
  "devDependencies": {
22
- "@_linked/cli": "1.45.6"
22
+ "@_linked/cli": "1.46.0"
23
23
  }
24
24
  }
@@ -14,7 +14,7 @@
14
14
  "test": "node --experimental-strip-types --no-warnings=ExperimentalWarning --test test/*.test.mjs"
15
15
  },
16
16
  "dependencies": {
17
- "@_linked/core": "2.28.1",
17
+ "@_linked/core": "2.28.3",
18
18
  "@_linked/fuseki": "3.4.2",
19
19
  "@_linked/s3": "1.6.2",
20
20
  "@_linked/schema": "1.5.0",
@@ -25,7 +25,7 @@
25
25
  "react-dom": "19.2.3"
26
26
  },
27
27
  "devDependencies": {
28
- "@_linked/cli": "1.45.6",
28
+ "@_linked/cli": "1.46.0",
29
29
  "@types/node": "22.20.5",
30
30
  "typescript": "6.0.3"
31
31
  }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Pick the few lines of a failed build's output that show why it failed.
3
+ *
4
+ * `build-all` builds packages in parallel, so a failure's full output is
5
+ * printed inline, interleaved with everything else. Its end-of-run summary
6
+ * repeats a short excerpt under each failed package so the cause is visible
7
+ * without scrolling back. This is that excerpt: lines that look like errors
8
+ * (`error TS…`, `Error:`, `npm ERR!`, …) with the first stack frame after
9
+ * each, without npm's lifecycle boilerplate, de-duplicated and truncated. When
10
+ * nothing looks like an error, the last meaningful lines are used instead.
11
+ */
12
+ export declare function excerptBuildError(output: string, maxLines?: number, maxWidth?: number): string[];
13
+ //# sourceMappingURL=build-error-excerpt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-error-excerpt.d.ts","sourceRoot":"","sources":["../../src/build-error-excerpt.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,EACd,QAAQ,SAAI,EACZ,QAAQ,SAAM,GACb,MAAM,EAAE,CA+CV"}
@@ -0,0 +1,97 @@
1
+ import { stripVTControlCharacters } from 'util';
2
+ /**
3
+ * Pick the few lines of a failed build's output that show why it failed.
4
+ *
5
+ * `build-all` builds packages in parallel, so a failure's full output is
6
+ * printed inline, interleaved with everything else. Its end-of-run summary
7
+ * repeats a short excerpt under each failed package so the cause is visible
8
+ * without scrolling back. This is that excerpt: lines that look like errors
9
+ * (`error TS…`, `Error:`, `npm ERR!`, …) with the first stack frame after
10
+ * each, without npm's lifecycle boilerplate, de-duplicated and truncated. When
11
+ * nothing looks like an error, the last meaningful lines are used instead.
12
+ */
13
+ export function excerptBuildError(output, maxLines = 8, maxWidth = 160) {
14
+ const lines = stripVTControlCharacters(output || '')
15
+ .split(/\r?\n/)
16
+ .map((l) => l.replace(/\s+$/, ''));
17
+ const picked = [];
18
+ let errorLines = 0;
19
+ for (let i = 0; i < lines.length; i++) {
20
+ const line = lines[i];
21
+ if (isNoise(line) || !isErrorLine(line))
22
+ continue;
23
+ picked.push(line.trim());
24
+ errorLines++;
25
+ // Keep the first stack frame of a thrown error: where it came from.
26
+ const next = lines[i + 1];
27
+ if (next !== undefined && isStackFrame(next))
28
+ picked.push(next);
29
+ }
30
+ let chosen;
31
+ if (errorLines > 0) {
32
+ chosen = picked;
33
+ }
34
+ else {
35
+ // Nothing looks like an error: show how the output ended.
36
+ let seenFrame = false;
37
+ chosen = lines.filter((line) => {
38
+ if (isNoise(line))
39
+ return false;
40
+ if (isStackFrame(line)) {
41
+ if (seenFrame)
42
+ return false;
43
+ seenFrame = true;
44
+ }
45
+ return true;
46
+ });
47
+ chosen = chosen.slice(-maxLines);
48
+ }
49
+ const unique = [];
50
+ const seen = new Set();
51
+ for (const line of chosen) {
52
+ const key = line.trim();
53
+ if (seen.has(key))
54
+ continue;
55
+ seen.add(key);
56
+ unique.push(truncate(line, maxWidth));
57
+ }
58
+ if (unique.length <= maxLines)
59
+ return unique;
60
+ const shown = unique.slice(0, maxLines - 1);
61
+ shown.push(`… ${unique.length - shown.length} more`);
62
+ return shown;
63
+ }
64
+ function truncate(line, maxWidth) {
65
+ return line.length > maxWidth ? line.slice(0, maxWidth - 1) + '…' : line;
66
+ }
67
+ function isStackFrame(line) {
68
+ return /^\s+at\s/.test(line);
69
+ }
70
+ /** Error-looking lines worth showing first. */
71
+ function isErrorLine(line) {
72
+ return (/\berror TS\d+\b/.test(line) ||
73
+ /^\s*(Uncaught\s+)?([A-Z]\w*)?(Error|Exception)\b(\s*\[[^\]]*\])?:/.test(line) ||
74
+ /^\s*(npm ERR!|npm error)\s/.test(line) ||
75
+ /^\s*(error|ERROR|✘ \[ERROR\])\b:?\s/.test(line) ||
76
+ /^\s*\S+:\d+(:\d+)?\s*-?\s*error\b/i.test(line) ||
77
+ /\bERR_[A-Z_]+\b/.test(line) ||
78
+ /\b(Cannot find (module|name)|Module not found|Could not resolve)\b/.test(line));
79
+ }
80
+ /** Lines that never explain a failure: npm lifecycle chatter and Node's throw site. */
81
+ function isNoise(line) {
82
+ const t = line.trim();
83
+ if (t === '')
84
+ return true;
85
+ return (/^npm (notice|warn|WARN|info|timing|verb|http)\b/.test(t) ||
86
+ // npm's own report that the script failed, and where its log went.
87
+ /^(npm ERR!|npm error)\s+(code\b|errno\b|path\b|workspace\b|location\b|command\b|syscall\b|signal\b|A complete log|Lifecycle script|Failed at|This is probably|Exit status|Tell the author|You can get|Make sure|Check the|\S+@\S+ build:|$)/.test(t) ||
88
+ /^(npm ERR!|npm error)$/.test(t) ||
89
+ /^>\s/.test(t) ||
90
+ /^node:internal\//.test(t) ||
91
+ /^triggerUncaughtException\(/.test(t) ||
92
+ /^\^+$/.test(t) ||
93
+ /^Node\.js v\d/.test(t) ||
94
+ /^(error )?Command failed with exit code \d+\.?$/.test(t) ||
95
+ /^info Visit https:\/\/yarnpkg\.com/.test(t));
96
+ }
97
+ //# sourceMappingURL=build-error-excerpt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-error-excerpt.js","sourceRoot":"","sources":["../../src/build-error-excerpt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,wBAAwB,EAAC,MAAM,MAAM,CAAC;AAE9C;;;;;;;;;;GAUG;AACH,MAAM,UAAU,iBAAiB,CAC/B,MAAc,EACd,QAAQ,GAAG,CAAC,EACZ,QAAQ,GAAG,GAAG;IAEd,MAAM,KAAK,GAAG,wBAAwB,CAAC,MAAM,IAAI,EAAE,CAAC;SACjD,KAAK,CAAC,OAAO,CAAC;SACd,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC;IAErC,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,IAAI,UAAU,GAAG,CAAC,CAAC;IACnB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACtB,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;YAAE,SAAS;QAClD,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;QACzB,UAAU,EA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CAAC,CAAC;QAChC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QACd,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC;QAC1B,6BAA6B,CAAC,IAAI,CAAC,CAAC,CAAC;QACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QACf,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC;QACvB,iDAAiD,CAAC,IAAI,CAAC,CAAC,CAAC;QACzD,oCAAoC,CAAC,IAAI,CAAC,CAAC,CAAC,CAC7C,CAAC;AACJ,CAAC","sourcesContent":["import {stripVTControlCharacters} from 'util';\n\n/**\n * Pick the few lines of a failed build's output that show why it failed.\n *\n * `build-all` builds packages in parallel, so a failure's full output is\n * printed inline, interleaved with everything else. Its end-of-run summary\n * repeats a short excerpt under each failed package so the cause is visible\n * without scrolling back. This is that excerpt: lines that look like errors\n * (`error TS…`, `Error:`, `npm ERR!`, …) with the first stack frame after\n * each, without npm's lifecycle boilerplate, de-duplicated and truncated. When\n * nothing looks like an error, the last meaningful lines are used instead.\n */\nexport function excerptBuildError(\n output: string,\n maxLines = 8,\n maxWidth = 160,\n): string[] {\n const lines = stripVTControlCharacters(output || '')\n .split(/\\r?\\n/)\n .map((l) => l.replace(/\\s+$/, ''));\n\n const picked: string[] = [];\n let errorLines = 0;\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i];\n if (isNoise(line) || !isErrorLine(line)) continue;\n picked.push(line.trim());\n errorLines++;\n // Keep the first stack frame of a thrown error: where it came from.\n const next = lines[i + 1];\n if (next !== undefined && isStackFrame(next)) picked.push(next);\n }\n\n let chosen: string[];\n if (errorLines > 0) {\n chosen = picked;\n } else {\n // Nothing looks like an error: show how the output ended.\n let seenFrame = false;\n chosen = lines.filter((line) => {\n if (isNoise(line)) return false;\n if (isStackFrame(line)) {\n if (seenFrame) return false;\n seenFrame = true;\n }\n return true;\n });\n chosen = chosen.slice(-maxLines);\n }\n\n const unique: string[] = [];\n const seen = new Set<string>();\n for (const line of chosen) {\n const key = line.trim();\n if (seen.has(key)) continue;\n seen.add(key);\n unique.push(truncate(line, maxWidth));\n }\n\n if (unique.length <= maxLines) return unique;\n const shown = unique.slice(0, maxLines - 1);\n shown.push(`… ${unique.length - shown.length} more`);\n return shown;\n}\n\nfunction truncate(line: string, maxWidth: number): string {\n return line.length > maxWidth ? line.slice(0, maxWidth - 1) + '…' : line;\n}\n\nfunction isStackFrame(line: string): boolean {\n return /^\\s+at\\s/.test(line);\n}\n\n/** Error-looking lines worth showing first. */\nfunction isErrorLine(line: string): boolean {\n return (\n /\\berror TS\\d+\\b/.test(line) ||\n /^\\s*(Uncaught\\s+)?([A-Z]\\w*)?(Error|Exception)\\b(\\s*\\[[^\\]]*\\])?:/.test(line) ||\n /^\\s*(npm ERR!|npm error)\\s/.test(line) ||\n /^\\s*(error|ERROR|✘ \\[ERROR\\])\\b:?\\s/.test(line) ||\n /^\\s*\\S+:\\d+(:\\d+)?\\s*-?\\s*error\\b/i.test(line) ||\n /\\bERR_[A-Z_]+\\b/.test(line) ||\n /\\b(Cannot find (module|name)|Module not found|Could not resolve)\\b/.test(\n line,\n )\n );\n}\n\n/** Lines that never explain a failure: npm lifecycle chatter and Node's throw site. */\nfunction isNoise(line: string): boolean {\n const t = line.trim();\n if (t === '') return true;\n return (\n /^npm (notice|warn|WARN|info|timing|verb|http)\\b/.test(t) ||\n // npm's own report that the script failed, and where its log went.\n /^(npm ERR!|npm error)\\s+(code\\b|errno\\b|path\\b|workspace\\b|location\\b|command\\b|syscall\\b|signal\\b|A complete log|Lifecycle script|Failed at|This is probably|Exit status|Tell the author|You can get|Make sure|Check the|\\S+@\\S+ build:|$)/.test(\n t,\n ) ||\n /^(npm ERR!|npm error)$/.test(t) ||\n /^>\\s/.test(t) ||\n /^node:internal\\//.test(t) ||\n /^triggerUncaughtException\\(/.test(t) ||\n /^\\^+$/.test(t) ||\n /^Node\\.js v\\d/.test(t) ||\n /^(error )?Command failed with exit code \\d+\\.?$/.test(t) ||\n /^info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,eAAO,IAAI,wBAAwB,GAAa,gBAAW,EAAE,YAAO,SAsCnE,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,cAAc,GAAU,gBAAW,qBA8B/C,CAAC"}
@@ -76,7 +76,8 @@ function assertInsidePackage(sourceFolder, command) {
76
76
  // have to graph-walk the rest of cli-methods.ts (which contains many
77
77
  // dynamic imports Vite can't analyze). We import for internal callers
78
78
  // AND re-export so external consumers can keep importing from here.
79
- import { ensureEnvironmentLoaded, loadBackendStorageConfig, getLincdPackages, discoverLocalPackages, planBuildAll, } from './lifecycle.js';
79
+ import { ensureEnvironmentLoaded, loadBackendStorageConfig, getLincdPackages, discoverLocalPackages, planBuildAll, orderBuildToolFirst, } from './lifecycle.js';
80
+ import { excerptBuildError } from './build-error-excerpt.js';
80
81
  export { ensureEnvironmentLoaded, loadBackendStorageConfig, getLincdPackages, discoverLocalPackages, planBuildAll, };
81
82
  var variables = {};
82
83
  /**
@@ -762,62 +763,115 @@ function printBuildAllPlan(plan) {
762
763
  console.log(chalk.yellow(` - ${skip.packageName}: ${skip.reason}`));
763
764
  }
764
765
  }
766
+ /**
767
+ * Run one package's own `build` script. Resolves to true when it built, false
768
+ * when it built with warnings, and undefined when it failed (the failure has
769
+ * been printed, and its output is kept in `failureOutput` when given, for the
770
+ * summary).
771
+ */
772
+ function runBuildScript(pkg, failureOutput) {
773
+ var _a;
774
+ // Invoke the package's own `build` script. This lets each package
775
+ // own its build pipeline — e.g. @_linked/core uses direct tsc, pure-CSS
776
+ // packages may have no-op builds, and linkedPackage: true packages
777
+ // typically call `linked build` internally.
778
+ //
779
+ // npm is the default; the package manager is detected per package so
780
+ // packages inside an existing yarn workspace still build with yarn.
781
+ const pkgDir = path.join(process.cwd(), pkg.path);
782
+ const pkgJson = getPackageJSON(pkgDir);
783
+ if (!((_a = pkgJson === null || pkgJson === void 0 ? void 0 : pkgJson.scripts) === null || _a === void 0 ? void 0 : _a.build)) {
784
+ // No build script — skip gracefully (e.g. a pure-assets package).
785
+ return Promise.resolve(true);
786
+ }
787
+ const buildCmd = runScriptCommand(detectPackageManager(pkgDir), 'build');
788
+ return execPromise(buildCmd, false, false, { cwd: pkgDir })
789
+ .then((res) => res === '' || typeof res === 'string')
790
+ .catch((err) => {
791
+ // A non-zero exit is a failed build. Report it and resolve to
792
+ // undefined, which is what the callers read as failure. Resolving to an
793
+ // error object would count as built.
794
+ const output = [err === null || err === void 0 ? void 0 : err.stdout, err === null || err === void 0 ? void 0 : err.stderr].filter(Boolean).join('\n');
795
+ failureOutput === null || failureOutput === void 0 ? void 0 : failureOutput.set(pkg.packageName, output);
796
+ console.error(chalk.red(pkg.packageName + ' build failed') +
797
+ (output ? '\n' + output : ''));
798
+ return undefined;
799
+ });
800
+ }
765
801
  export function buildAll(options) {
766
802
  console.log('Building all linked packages of this repository in order of dependencies');
767
803
  const plan = planBuildAll('./', findAppRoot() || undefined);
768
804
  printBuildAllPlan(plan);
769
- let lincdPackages = plan.build;
770
- if (lincdPackages.size === 0) {
805
+ if (plan.build.size === 0) {
771
806
  console.log(chalk.yellow('Nothing to build.'));
772
807
  return;
773
808
  }
809
+ // The build tool goes first and alone: every other build runs it.
810
+ const order = orderBuildToolFirst(plan.build, options === null || options === void 0 ? void 0 : options.from);
811
+ const sync = (options === null || options === void 0 ? void 0 : options.sync) || false;
812
+ // Successfully built (or deliberately passed over by --from).
813
+ const done = new Set();
814
+ if (!order.tool) {
815
+ return buildInDependencyOrder(order.rest, order.from, sync, done);
816
+ }
817
+ const tool = order.tool;
818
+ if (!order.buildToolFirst) {
819
+ log(chalk.blue('skipping ' + tool.packageName));
820
+ done.add(tool);
821
+ return buildInDependencyOrder(order.rest, order.from, sync, done);
822
+ }
823
+ // This process has already loaded every module `build-all` uses (the
824
+ // command's code is imported statically), so the tool's `rimraf ./lib`
825
+ // cannot pull anything out from under it.
826
+ console.log(chalk.blue(`Building ${tool.packageName} first: the other packages build with it.`));
827
+ return runBuildScript(tool).then((res) => {
828
+ if (typeof res === 'undefined') {
829
+ const others = order.rest.size;
830
+ console.error(chalk.red(`${tool.packageName} failed to build, so build-all stopped before ` +
831
+ `the other ${others} package${others === 1 ? '' : 's'}: they build with it. ` +
832
+ `Fix ${tool.packageName} and run build-all again.`));
833
+ process.exit(1);
834
+ return;
835
+ }
836
+ log(chalk.green('Built ' + tool.packageName) +
837
+ (res === false ? chalk.redBright(' (with warnings)') : ''));
838
+ done.add(tool);
839
+ if (order.rest.size === 0) {
840
+ printBuildAllSummary(done, new Set(), new Map(), [], new Map());
841
+ return;
842
+ }
843
+ return buildInDependencyOrder(order.rest, order.from, sync, done);
844
+ });
845
+ }
846
+ function buildInDependencyOrder(lincdPackages, from, sync, done) {
774
847
  let startFrom;
775
848
  //by default start building
776
849
  let building = true;
777
- let from = options === null || options === void 0 ? void 0 : options.from;
778
- let sync = (options === null || options === void 0 ? void 0 : options.sync) || false;
779
- // console.log('from', from);
780
- // console.log('sync', sync);
781
- // process.exit();
782
850
  //option to start from a specific package in the stack
783
851
  if (from) {
784
852
  startFrom = from;
785
853
  //if we have a startFrom, then we havnt started the build process yet
786
- building = startFrom ? false : true;
787
- //clear targets
788
- // target = '';
789
- // target2 = '';
854
+ building = false;
790
855
  console.log(chalk.blue('Will skip builds until ' + startFrom));
791
- // return async (pkg) => {};
792
856
  }
793
- // if (target2 == 'from') {
794
- // startFrom = target3;
795
- // //if we have a startFrom, then we havnt started the build process yet
796
- // building = startFrom ? false : true;
797
- //
798
- // //clear targets
799
- // target2 = '';
800
- // target3 = '';
801
- // console.log(chalk.blue('Will skip builds until ' + startFrom));
802
- //
803
- // // return async (pkg) => {};
804
- // }
805
- // Successfully built (or deliberately passed over by --from).
806
- let done = new Set();
807
857
  // Packages whose own build script failed.
808
858
  let failed = new Set();
809
859
  // Packages not built because a dependency failed or was itself not built,
810
860
  // mapped to the failed package(s) at the root of that chain.
811
861
  let notBuilt = new Map();
862
+ // The output of each failed build, by package name, for the summary.
863
+ const failureOutput = new Map();
812
864
  progressUpdate(lincdPackages.size + ' packages left');
813
865
  let packagesLeft = lincdPackages.size;
866
+ // `done` may already hold the build tool, built before this ran.
867
+ const doneBefore = done.size;
814
868
  const finished = runOnPackagesGroupedByDependencies(lincdPackages, (packageGroup, dependencies) => {
815
- if (done.size > 0) {
869
+ if (done.size > doneBefore) {
816
870
  debugInfo(chalk.magenta('\n-------\nThese packages are next, since all their dependencies have now been build:'));
817
871
  }
818
872
  debugInfo('Now building: ' + chalk.blue(packageGroup.map((i) => i.packageName)));
819
873
  return (pkg) => __awaiter(this, void 0, void 0, function* () {
820
- var _a, _b;
874
+ var _a;
821
875
  // A package whose dependency failed (directly or further down the
822
876
  // chain) cannot be built against it. Report it instead of building it,
823
877
  // and keep building everything else.
@@ -853,38 +907,7 @@ export function buildAll(options) {
853
907
  }
854
908
  //unless told otherwise, build the package
855
909
  if (!command) {
856
- // Invoke the package's own `build` script. This lets each package
857
- // own its build pipeline — e.g. @_linked/core uses direct tsc, pure-CSS
858
- // packages may have no-op builds, and linkedPackage: true packages
859
- // typically call `linked build` internally.
860
- //
861
- // npm is the default; the package manager is detected per package so
862
- // packages inside an existing yarn workspace still build with yarn.
863
- const pkgDir = path.join(process.cwd(), pkg.path);
864
- const pkgJson = getPackageJSON(pkgDir);
865
- const hasBuildScript = !!((_b = pkgJson === null || pkgJson === void 0 ? void 0 : pkgJson.scripts) === null || _b === void 0 ? void 0 : _b.build);
866
- if (!hasBuildScript) {
867
- // No build script — skip gracefully (e.g. a pure-assets package).
868
- command = Promise.resolve(true);
869
- }
870
- else {
871
- const buildCmd = runScriptCommand(detectPackageManager(pkgDir), 'build');
872
- command = execPromise(buildCmd, false, false, {
873
- cwd: pkgDir,
874
- })
875
- .then((res) => res === '' || typeof res === 'string')
876
- .catch((err) => {
877
- // A non-zero exit is a failed build. Report it and resolve to
878
- // undefined, which is what the result handler below reads as
879
- // failure. Resolving to an error object would count as built.
880
- const output = [err === null || err === void 0 ? void 0 : err.stdout, err === null || err === void 0 ? void 0 : err.stderr]
881
- .filter(Boolean)
882
- .join('\n');
883
- console.error(chalk.red(pkg.packageName + ' build failed') +
884
- (output ? '\n' + output : ''));
885
- return undefined;
886
- });
887
- }
910
+ command = runBuildScript(pkg, failureOutput);
888
911
  log(chalk.cyan('Building ' + pkg.packageName));
889
912
  process.stdout.write(packagesLeft + ' packages left\r');
890
913
  }
@@ -933,7 +956,7 @@ export function buildAll(options) {
933
956
  }
934
957
  }
935
958
  }
936
- printBuildAllSummary(done, failed, notBuilt, unscheduled);
959
+ printBuildAllSummary(done, failed, notBuilt, unscheduled, failureOutput);
937
960
  if (failed.size > 0 || notBuilt.size > 0 || unscheduled.length > 0) {
938
961
  process.exit(1);
939
962
  }
@@ -942,10 +965,21 @@ export function buildAll(options) {
942
965
  }
943
966
  /**
944
967
  * The end-of-run report of `build-all`: what was built, every package whose
945
- * build failed, and every package that was not built because of one.
968
+ * build failed with a few lines of why, and every package that was not built
969
+ * because of one.
946
970
  */
947
- function printBuildAllSummary(done, failed, notBuilt, unscheduled) {
971
+ function printBuildAllSummary(done, failed, notBuilt, unscheduled, failureOutput) {
948
972
  printBuildResults([...failed].map((p) => p.packageName), done);
973
+ for (const pkg of failed) {
974
+ const excerpt = excerptBuildError(failureOutput.get(pkg.packageName) || '');
975
+ console.warn(chalk.red(` ${pkg.packageName}:`) +
976
+ '\n' +
977
+ (excerpt.length > 0 ? excerpt : ['(no output)'])
978
+ .map((line) => chalk.gray(' | ') + line)
979
+ .join('\n'));
980
+ }
981
+ if (failed.size > 0)
982
+ console.warn('');
949
983
  if (notBuilt.size > 0) {
950
984
  warn(`Not built (${notBuilt.size}) because a dependency failed:\n` +
951
985
  [...notBuilt]