@bobfrankston/npmglobalize 1.0.229 → 1.0.230

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.
Files changed (4) hide show
  1. package/README.md +7 -0
  2. package/lib.d.ts +5 -0
  3. package/lib.js +34 -6
  4. package/package.json +1 -1
package/README.md CHANGED
@@ -586,6 +586,13 @@ Workspace mode is auto-detected when run from a root with `"private": true` and
586
586
  migration automatically when a build hits a TS7 deprecation
587
587
  error, so day-to-day you never need this flag.
588
588
  npmglobalize <path> -tsfix
589
+ If the automatic migration breaks a build (usually relative
590
+ imports missing their .js extension, TS2835), the tsconfig is
591
+ put back so the build keeps working and EVERY error from the
592
+ nodenext attempt is listed, file(line,col) and the suggested
593
+ fix, for fixing by hand. Nothing in the source is rewritten.
594
+ The migration reruns on the next build once the imports are
595
+ fixed. (2026-09-14)
589
596
  -show Show package.json dependency changes
590
597
  -package, -pkg Update package.json scripts to use npmglobalize (see below)
591
598
  -h, -help Show help
package/lib.d.ts CHANGED
@@ -25,6 +25,11 @@ export declare function clearBuildIssues(): void;
25
25
  /** Extract the first TypeScript error line from build output for the summary.
26
26
  * Returns a short string like "file.ts(42,5): error TS2339: Property 'foo' ..." */
27
27
  export declare function extractFirstTscError(output: string): string | null;
28
+ /** Every TypeScript error line in build output — `file.ts(line,col): error TSnnnn: message`
29
+ * — in order, deduplicated, untruncated. For reports where the reader will act on each
30
+ * line (the imports a nodenext migration surfaces), as opposed to the one-line summary
31
+ * extractFirstTscError gives. (2026-09-14) */
32
+ export declare function extractTscErrors(output: string): string[];
28
33
  /** A TS7016 — "Could not find a declaration file for module 'X'" — that tsc blames
29
34
  * on the file being compiled is frequently not that file's fault: the copy of X in
30
35
  * node_modules carries no `.d.ts` whatsoever. That happens when X was published at
package/lib.js CHANGED
@@ -78,6 +78,24 @@ export function extractFirstTscError(output) {
78
78
  }
79
79
  return null;
80
80
  }
81
+ /** Every TypeScript error line in build output — `file.ts(line,col): error TSnnnn: message`
82
+ * — in order, deduplicated, untruncated. For reports where the reader will act on each
83
+ * line (the imports a nodenext migration surfaces), as opposed to the one-line summary
84
+ * extractFirstTscError gives. (2026-09-14) */
85
+ export function extractTscErrors(output) {
86
+ if (!output)
87
+ return [];
88
+ const seen = new Set();
89
+ const lines = [];
90
+ for (const m of output.matchAll(/^(.+?\(\d+,\d+\): error TS\d+: .+)$/gm)) {
91
+ const line = m[1].trimEnd();
92
+ if (seen.has(line))
93
+ continue;
94
+ seen.add(line);
95
+ lines.push(line);
96
+ }
97
+ return lines;
98
+ }
81
99
  /** Does `dir` contain any `.d.ts` at all? Bounded, and never descends into a
82
100
  * nested `node_modules` — we are asking about this package's own output. */
83
101
  function hasDeclarationFiles(dir, depth = 3) {
@@ -3753,13 +3771,23 @@ export async function buildProject(cwd, opts = {}) {
3753
3771
  const retry = await runCommandAsync('npm', ['run', 'build'], { cwd, silent: true });
3754
3772
  if (retry.success) {
3755
3773
  dropBuildIssuesFrom(issueMark); // the migration was undone; its warnings no longer apply
3756
- const firstErr = extractFirstTscError(migratedOutput);
3757
3774
  const label = pkg.name || path.basename(cwd);
3758
- console.log(colors.yellow(` Reverted the tsconfig TS7 migration in ${label} it broke the build:`));
3759
- if (firstErr)
3760
- console.log(colors.yellow(` ${firstErr}`));
3761
- console.log(colors.yellow(` Deprecated settings left in place. Fix with: npmglobalize ${cwd} -tsfix`));
3762
- recordBuildIssue(label, 'warning', `tsconfig still uses settings TypeScript 7 removes: migrating to "nodenext" broke the build (${firstErr || 'see build output'}). Run \`npmglobalize ${cwd} -tsfix\` and fix the surfaced imports.`);
3775
+ // List EVERY error the migrated build produced, not just the first: these
3776
+ // are the imports (usually relative specifiers missing their .js extension)
3777
+ // that have to be fixed by hand before nodenext can stay. The tsconfig is
3778
+ // left on the deprecated settings so the build keeps working meanwhile;
3779
+ // the next build after the imports are fixed migrates again on its own.
3780
+ // 2026-09-14 18:30 EDT — Claude Code (Fable 5.1), at Bob's direction:
3781
+ // "Rather than doing the rewrite of the imports, flag them so I can
3782
+ // manually fix them since I expect most cases have already been fixed."
3783
+ const errs = extractTscErrors(migratedOutput);
3784
+ console.log(colors.yellow(` Reverted the tsconfig TS7 migration in ${label} — under "nodenext" the build fails on ${errs.length || 'these'} error(s):`));
3785
+ for (const e of errs)
3786
+ console.log(colors.yellow(` ${e}`));
3787
+ if (!errs.length)
3788
+ console.log(colors.yellow(` ${extractFirstTscError(migratedOutput) || '(no tsc error line found — rerun with -verbose)'}`));
3789
+ console.log(colors.yellow(` Deprecated settings left in place so the build still works. Fix the imports above; the migration reruns on the next build.`));
3790
+ recordBuildIssue(label, 'warning', `tsconfig still uses settings TypeScript 7 removes: under "nodenext" the build fails on ${errs.length} error(s) (first: ${errs[0] || extractFirstTscError(migratedOutput) || 'see build output'}). Fix the listed imports; the migration reruns on the next build.`);
3763
3791
  buildResult = retry;
3764
3792
  }
3765
3793
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobfrankston/npmglobalize",
3
- "version": "1.0.229",
3
+ "version": "1.0.230",
4
4
  "description": "Transform file: dependencies to npm versions for publishing",
5
5
  "main": "index.js",
6
6
  "type": "module",