@bobfrankston/npmglobalize 1.0.108 → 1.0.109

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.
@@ -20,7 +20,6 @@
20
20
  recommended: [
21
21
  "node_modules/",
22
22
  ".globalize.json5",
23
- ".globalize.jsonc",
24
23
  "*.log",
25
24
  ".DS_Store",
26
25
  "Thumbs.db"
package/lib.js CHANGED
@@ -2870,6 +2870,19 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
2870
2870
  console.log(' [dry-run] Would commit changes');
2871
2871
  }
2872
2872
  }
2873
+ // Pull latest from remote before version bump to avoid push rejection
2874
+ if (currentGitStatus.hasRemote && !dryRun) {
2875
+ const pullResult = runCommand('git', ['pull', '--rebase'], { cwd, silent: true });
2876
+ if (!pullResult.success) {
2877
+ console.error(colors.yellow('Warning: git pull --rebase failed before version bump'));
2878
+ if (verbose) {
2879
+ console.error(' ' + pullResult.stderr);
2880
+ }
2881
+ }
2882
+ else if (verbose) {
2883
+ console.log(' Pulled latest from remote');
2884
+ }
2885
+ }
2873
2886
  // Version bump
2874
2887
  console.log(`Bumping version (${bump})...`);
2875
2888
  if (!dryRun) {
@@ -2915,6 +2928,7 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
2915
2928
  console.log(colors.green(`Version bumped to ${newVersion}`));
2916
2929
  }
2917
2930
  catch (error) {
2931
+ let autoFixed = false;
2918
2932
  console.error(colors.red('ERROR: Version bump failed:'), error.message);
2919
2933
  // Show additional error details if available
2920
2934
  if (error.stderr || error.stdout || error.code) {
@@ -2933,16 +2947,41 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
2933
2947
  const stderrLower = (error.stderr || '').toLowerCase();
2934
2948
  const stdoutLower = (error.stdout || '').toLowerCase();
2935
2949
  const combinedOutput = stderrLower + ' ' + stdoutLower;
2936
- if (combinedOutput.includes('non-fast-forward') || combinedOutput.includes('rejected') && combinedOutput.includes('behind')) {
2937
- console.error(colors.yellow('\nYour local branch is behind the remote.'));
2938
- console.error(colors.yellow('This usually means changes were pushed from another location.'));
2939
- console.error(colors.yellow('\nTo fix this:'));
2940
- console.error(' 1. Pull remote changes: git pull --rebase');
2941
- console.error(' 2. Then run npmglobalize again');
2942
- console.error(colors.yellow('\nOr to force push (use with caution):'));
2943
- console.error(' git push --force-with-lease');
2944
- if (!force) {
2945
- return false;
2950
+ if (combinedOutput.includes('non-fast-forward') || (combinedOutput.includes('rejected') && combinedOutput.includes('behind'))) {
2951
+ // Version bump + tag succeeded locally; only the push failed.
2952
+ // Auto-pull --rebase and retry the push.
2953
+ console.log(colors.yellow('\nLocal branch is behind remote — pulling with rebase...'));
2954
+ const pullResult = runCommand('git', ['pull', '--rebase'], { cwd });
2955
+ if (pullResult.success) {
2956
+ console.log(colors.green(' Rebased onto remote'));
2957
+ const pushResult = runCommand('git', ['push'], { cwd });
2958
+ if (pushResult.success) {
2959
+ const tagPush = runCommand('git', ['push', '--tags'], { cwd, silent: true });
2960
+ if (tagPush.success) {
2961
+ console.log(colors.green(' ✓ Pushed with tags'));
2962
+ }
2963
+ else {
2964
+ console.log(colors.green(' ✓ Pushed (tags may need manual push)'));
2965
+ }
2966
+ // Re-read version after successful rebase+push
2967
+ const rebased = readPackageJson(cwd);
2968
+ console.log(colors.green(`Version bumped to ${rebased.version}`));
2969
+ autoFixed = true;
2970
+ }
2971
+ else {
2972
+ console.error(colors.red('Push still failed after rebase.'));
2973
+ console.error(' Try: git push --force-with-lease');
2974
+ if (!force) {
2975
+ return false;
2976
+ }
2977
+ }
2978
+ }
2979
+ else {
2980
+ console.error(colors.red('Auto-rebase failed (likely merge conflict).'));
2981
+ console.error(' Resolve conflicts, then: git rebase --continue && git push');
2982
+ if (!force) {
2983
+ return false;
2984
+ }
2946
2985
  }
2947
2986
  }
2948
2987
  else if (stderrLower.includes('tag') && stderrLower.includes('already exists')) {
@@ -3018,10 +3057,12 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
3018
3057
  console.error(' • Disk space or permissions issues');
3019
3058
  console.error(colors.yellow('\nTry running with --verbose or check git status manually'));
3020
3059
  }
3021
- if (!force) {
3022
- return false;
3060
+ if (!autoFixed) {
3061
+ if (!force) {
3062
+ return false;
3063
+ }
3064
+ console.log(colors.yellow('Continuing with --force...'));
3023
3065
  }
3024
- console.log(colors.yellow('Continuing with --force...'));
3025
3066
  }
3026
3067
  }
3027
3068
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobfrankston/npmglobalize",
3
- "version": "1.0.108",
3
+ "version": "1.0.109",
4
4
  "description": "Transform file: dependencies to npm versions for publishing",
5
5
  "main": "index.js",
6
6
  "type": "module",