@bobfrankston/npmglobalize 1.0.98 → 1.0.99

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 +13 -3
  2. package/package.json +1 -1
package/lib.js CHANGED
@@ -878,7 +878,7 @@ export function fixVersionTagMismatch(cwd, pkg, verbose = false) {
878
878
  return deletedAny;
879
879
  }
880
880
  /** Wait for a package version to appear on the npm registry */
881
- function waitForNpmVersion(pkgName, version, maxWaitMs = 60000) {
881
+ function waitForNpmVersion(pkgName, version, maxWaitMs = 90000) {
882
882
  const interval = 3000;
883
883
  const maxAttempts = Math.ceil(maxWaitMs / interval);
884
884
  process.stdout.write(`Waiting for ${pkgName}@${version} on npm registry`);
@@ -898,6 +898,16 @@ function waitForNpmVersion(pkgName, version, maxWaitMs = 60000) {
898
898
  process.stdout.write(' timed out\n');
899
899
  return false;
900
900
  }
901
+ /** Run npm install -g with retries for registry propagation delay */
902
+ function installGlobalWithRetry(pkgSpec, cwd, maxRetries = 3) {
903
+ let result = runCommand('npm', ['install', '-g', pkgSpec], { cwd, silent: false });
904
+ for (let attempt = 1; attempt < maxRetries && !result.success; attempt++) {
905
+ console.log(colors.yellow(` Retrying install (attempt ${attempt + 1}/${maxRetries}) in 10 seconds...`));
906
+ spawnSafe(process.platform === 'win32' ? 'timeout' : 'sleep', process.platform === 'win32' ? ['/t', '10', '/nobreak'] : ['10'], { stdio: 'pipe', shell: process.platform === 'win32' });
907
+ result = runCommand('npm', ['install', '-g', pkgSpec], { cwd, silent: false });
908
+ }
909
+ return result;
910
+ }
901
911
  /** Run a command and return success status */
902
912
  export function runCommand(cmd, args, options = {}) {
903
913
  const { silent = false, cwd } = options;
@@ -2537,7 +2547,7 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
2537
2547
  else if (install) {
2538
2548
  waitForNpmVersion(pkgName, pkgVersion);
2539
2549
  console.log(`Installing ${pkgName}@${pkgVersion} globally from registry...`);
2540
- const registryInstallResult = runCommand('npm', ['install', '-g', `${pkgName}@${pkgVersion}`], { cwd, silent: false });
2550
+ const registryInstallResult = installGlobalWithRetry(`${pkgName}@${pkgVersion}`, cwd);
2541
2551
  if (registryInstallResult.success) {
2542
2552
  console.log(colors.green(`✓ Installed globally: ${pkgName}@${pkgVersion}`));
2543
2553
  }
@@ -3008,7 +3018,7 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
3008
3018
  console.log(`Installing globally from registry: ${pkgName}@${pkgVersion}...`);
3009
3019
  if (!dryRun) {
3010
3020
  waitForNpmVersion(pkgName, pkgVersion);
3011
- const installResult = runCommand('npm', ['install', '-g', `${pkgName}@${pkgVersion}`], { cwd, silent: false });
3021
+ const installResult = installGlobalWithRetry(`${pkgName}@${pkgVersion}`, cwd);
3012
3022
  if (installResult.success) {
3013
3023
  console.log(colors.green(`✓ Installed globally: ${pkgName}@${pkgVersion}`));
3014
3024
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobfrankston/npmglobalize",
3
- "version": "1.0.98",
3
+ "version": "1.0.99",
4
4
  "description": "Transform file: dependencies to npm versions for publishing",
5
5
  "main": "index.js",
6
6
  "type": "module",