@bobfrankston/npmglobalize 1.0.29 → 1.0.31

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 (2) hide show
  1. package/lib.js +30 -3
  2. package/package.json +1 -1
package/lib.js CHANGED
@@ -1520,11 +1520,35 @@ export async function globalize(cwd, options = {}) {
1520
1520
  // Version bump
1521
1521
  console.log(`Bumping version (${bump})...`);
1522
1522
  if (!dryRun) {
1523
+ // Temporarily disable postversion hook to prevent double-publishing
1524
+ const pkg = readPackageJson(cwd);
1525
+ const originalPostversion = pkg.scripts?.postversion;
1526
+ let postversDisabled = false;
1527
+ if (originalPostversion && originalPostversion.includes('npm publish')) {
1528
+ if (verbose) {
1529
+ console.log('Temporarily disabling postversion hook to prevent double-publish...');
1530
+ }
1531
+ delete pkg.scripts.postversion;
1532
+ writePackageJson(cwd, pkg);
1533
+ postversDisabled = true;
1534
+ }
1523
1535
  try {
1524
1536
  // Use libnpmversion - it will create commit and tag automatically
1525
1537
  const newVersion = await libversion(bump, {
1526
- path: cwd
1538
+ path: cwd,
1539
+ 'git-tag-version': true
1527
1540
  });
1541
+ // Restore postversion hook
1542
+ if (postversDisabled && originalPostversion) {
1543
+ const updatedPkg = readPackageJson(cwd);
1544
+ if (!updatedPkg.scripts)
1545
+ updatedPkg.scripts = {};
1546
+ updatedPkg.scripts.postversion = originalPostversion;
1547
+ writePackageJson(cwd, updatedPkg);
1548
+ if (verbose) {
1549
+ console.log('Restored postversion hook');
1550
+ }
1551
+ }
1528
1552
  console.log(colors.green(`Version bumped to ${newVersion}`));
1529
1553
  }
1530
1554
  catch (error) {
@@ -1726,11 +1750,11 @@ export async function globalize(cwd, options = {}) {
1726
1750
  console.error(colors.green('Solution: Wait a few more minutes and try again'));
1727
1751
  console.error('');
1728
1752
  }
1729
- else if (output.includes('403') || output.includes('forbidden')) {
1753
+ else if (output.includes('403') || output.includes('forbidden') || output.includes('cannot publish over')) {
1730
1754
  // Check if it's the "version already published" case
1731
1755
  if (output.includes('cannot publish over') || output.includes('previously published')) {
1732
1756
  // Extract the version number from the error if possible
1733
- const versionMatch = output.match(/versions?:\s*(\d+\.\d+\.\d+)/);
1757
+ const versionMatch = output.match(/versions?[:\s]+(\d+\.\d+\.\d+)/);
1734
1758
  const failedVersion = versionMatch ? versionMatch[1] : null;
1735
1759
  // Check if this is the version we just bumped to
1736
1760
  const currentPkgVersion = readPackageJson(cwd).version;
@@ -1745,6 +1769,9 @@ export async function globalize(cwd, options = {}) {
1745
1769
  console.error('');
1746
1770
  console.error('Verify with: ' + colors.yellow(`npm view ${pkg.name}@${currentPkgVersion}`));
1747
1771
  console.error('');
1772
+ console.error(colors.yellow('Note: You may have a postversion script that auto-publishes.'));
1773
+ console.error(colors.yellow('npmglobalize will now skip that hook to prevent this issue.'));
1774
+ console.error('');
1748
1775
  // Treat as success and continue
1749
1776
  console.log(colors.green('✓ Treating as successful publish'));
1750
1777
  // Don't return false - let it continue to push git tags
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobfrankston/npmglobalize",
3
- "version": "1.0.29",
3
+ "version": "1.0.31",
4
4
  "description": "Transform file: dependencies to npm versions for publishing",
5
5
  "main": "index.js",
6
6
  "type": "module",