@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.
- package/ignorepatterns.json5 +0 -1
- package/lib.js +54 -13
- package/package.json +1 -1
package/ignorepatterns.json5
CHANGED
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
|
-
|
|
2938
|
-
|
|
2939
|
-
console.
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
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 (!
|
|
3022
|
-
|
|
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 {
|