@bobfrankston/npmglobalize 1.0.181 → 1.0.183
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/lib.js +40 -12
- package/package.json +1 -1
package/lib.js
CHANGED
|
@@ -3883,10 +3883,10 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
|
|
|
3883
3883
|
if (adoptable) {
|
|
3884
3884
|
choice = await promptChoice('How would you like to set up git?\n'
|
|
3885
3885
|
+ ' 1) Adopt history from existing remote (recommended)\n'
|
|
3886
|
-
+ ' 2) Initialize fresh git repository\n'
|
|
3887
3886
|
+ ' a) Adopt ALL (don\'t ask again for remaining deps)\n'
|
|
3887
|
+
+ ' 2) Initialize fresh git repository\n'
|
|
3888
3888
|
+ ' 3) Use local install only (skip git/publish)\n'
|
|
3889
|
-
+ ' 4) Abort\nChoice:', ['1', '
|
|
3889
|
+
+ ' 4) Abort\nChoice:', ['1', 'a', '2', '3', '4', '']);
|
|
3890
3890
|
if (choice === '3') {
|
|
3891
3891
|
console.log(colors.dim('Switching to local-only mode...'));
|
|
3892
3892
|
writeConfig(cwd, { ...configOptions, local: true }, new Set(['local']));
|
|
@@ -5463,6 +5463,27 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
|
|
|
5463
5463
|
// before any subsequent install -g symlinks to these dep targets.
|
|
5464
5464
|
if (stashedDepModules.length > 0)
|
|
5465
5465
|
restoreNestedDepModules(stashedDepModules, verbose);
|
|
5466
|
+
// Auto-retry on arborist crash if -clean-nested-modules wasn't already
|
|
5467
|
+
// tried. The crash is the canonical sibling-junctions-in-junctions
|
|
5468
|
+
// failure mode; the fix is mechanical (wipe nested node_modules in
|
|
5469
|
+
// file: targets, pack, restore), so there's no reason to make the user
|
|
5470
|
+
// re-run with the flag they'd pick 100% of the time anyway.
|
|
5471
|
+
if (!packResult.success && !options.cleanNestedModules) {
|
|
5472
|
+
const probe = diagnoseNpmPackFailure(cwd, packResult.output, packResult.stderr, pkg);
|
|
5473
|
+
if (probe.summary.includes('arborist')) {
|
|
5474
|
+
console.error(colors.yellow(` Detected arborist crash — auto-retrying with --clean-nested-modules...`));
|
|
5475
|
+
const autoStash = cleanNestedDepModules(pkg, cwd, verbose);
|
|
5476
|
+
if (autoStash.length > 0) {
|
|
5477
|
+
console.log(colors.yellow(` Cleaned node_modules in ${autoStash.length} file: dep target(s): ${autoStash.map(s => s.name).join(', ')}`));
|
|
5478
|
+
}
|
|
5479
|
+
packResult = await runCommandAsync('npm', ['pack'], { cwd, silent: true });
|
|
5480
|
+
if (autoStash.length > 0)
|
|
5481
|
+
restoreNestedDepModules(autoStash, verbose);
|
|
5482
|
+
if (packResult.success) {
|
|
5483
|
+
console.log(colors.green(' ✓ Auto-retry succeeded after cleaning nested node_modules.'));
|
|
5484
|
+
}
|
|
5485
|
+
}
|
|
5486
|
+
}
|
|
5466
5487
|
if (!packResult.success) {
|
|
5467
5488
|
const d = diagnoseNpmPackFailure(cwd, packResult.output, packResult.stderr, pkg);
|
|
5468
5489
|
console.error(colors.red(`ERROR: ${d.summary}`));
|
|
@@ -5472,8 +5493,8 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
|
|
|
5472
5493
|
console.error(colors.yellow(` Caused by referenced module: ${d.referencedModule}`));
|
|
5473
5494
|
if (d.hint)
|
|
5474
5495
|
console.error(colors.yellow(` Hint: ${d.hint}`));
|
|
5475
|
-
if (d.summary.includes('arborist') &&
|
|
5476
|
-
console.error(colors.yellow(`
|
|
5496
|
+
if (d.summary.includes('arborist') && options.cleanNestedModules) {
|
|
5497
|
+
console.error(colors.yellow(` Already used --clean-nested-modules; the crash is from a deeper sibling. Try running in WSL or wiping nested node_modules manually.`));
|
|
5477
5498
|
}
|
|
5478
5499
|
recordBuildIssue(pkg.name || path.basename(cwd), 'error', d.referencedModule ? `${d.summary} (via ${d.referencedModule})` : d.summary);
|
|
5479
5500
|
return false;
|
|
@@ -5570,11 +5591,13 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
|
|
|
5570
5591
|
if (!publishResult.success) {
|
|
5571
5592
|
// Check for specific error types before recording
|
|
5572
5593
|
const output = (publishResult.output + '\n' + publishResult.stderr).toLowerCase();
|
|
5594
|
+
let alreadyPublished = false;
|
|
5573
5595
|
// "Already published" is benign — don't record as error
|
|
5574
5596
|
if (output.includes('cannot publish over') || output.includes('previously published')) {
|
|
5575
5597
|
const currentPkgVersion = readPackageJson(cwd).version;
|
|
5576
5598
|
if (output.includes(currentPkgVersion)) {
|
|
5577
5599
|
console.log(colors.green('✓ Already published — continuing'));
|
|
5600
|
+
alreadyPublished = true;
|
|
5578
5601
|
}
|
|
5579
5602
|
else {
|
|
5580
5603
|
console.error(colors.red('\nERROR: npm publish failed\n'));
|
|
@@ -5623,15 +5646,20 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
|
|
|
5623
5646
|
recordBuildIssue(pkg.name || path.basename(cwd), 'error', 'npm publish failed');
|
|
5624
5647
|
console.error(colors.yellow('Publish failed — run npm login or check npm whoami'));
|
|
5625
5648
|
}
|
|
5626
|
-
if (
|
|
5627
|
-
|
|
5628
|
-
|
|
5629
|
-
|
|
5630
|
-
|
|
5631
|
-
|
|
5632
|
-
|
|
5649
|
+
if (alreadyPublished) {
|
|
5650
|
+
// Treat as success — fall through to post-publish steps (push, tags, .commitmsg)
|
|
5651
|
+
}
|
|
5652
|
+
else {
|
|
5653
|
+
if (transformResult.transformed) {
|
|
5654
|
+
console.log('Restoring file: dependencies...');
|
|
5655
|
+
const failPkg = readPackageJson(cwd);
|
|
5656
|
+
restoreDeps(failPkg, verbose);
|
|
5657
|
+
writePackageJson(cwd, failPkg);
|
|
5658
|
+
runCommand('git', ['add', 'package.json'], { cwd, silent: true });
|
|
5659
|
+
gitCommit('Restore file: dependencies', cwd);
|
|
5660
|
+
}
|
|
5661
|
+
return false;
|
|
5633
5662
|
}
|
|
5634
|
-
return false;
|
|
5635
5663
|
}
|
|
5636
5664
|
// Determine what was published
|
|
5637
5665
|
const finalAccess = effectiveNpmVisibility || currentAccess || (isScoped ? 'restricted' : 'public');
|