@eldrforge/kodrdriv 1.2.12 → 1.2.14

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.
@@ -446,7 +446,7 @@ const execute = async (runConfig)=>{
446
446
  if (pr) {
447
447
  logger.info(`Found existing pull request for branch: ${pr.html_url}`);
448
448
  } else {
449
- var _runConfig_publish4, _runConfig_publish5, _runConfig_publish6, _runConfig_publish7;
449
+ var _runConfig_publish4, _runConfig_publish5, _runConfig_publish6, _runConfig_publish7, _runConfig_publish8, _runConfig_publish9, _runConfig_publish10, _runConfig_publish11;
450
450
  logger.info('No open pull request found, starting new release publishing process...');
451
451
  // STEP 1: Prepare for release (update dependencies and run prepublish checks) with NO version bump yet
452
452
  logger.verbose('Preparing for release: switching from workspace to remote dependencies.');
@@ -476,103 +476,108 @@ const execute = async (runConfig)=>{
476
476
  logger.verbose('No dependency changes to commit, skipping commit.');
477
477
  }
478
478
  }
479
- // STEP 3: Merge target branch into working branch to avoid conflicts
480
- logger.info(`Merging target branch '${targetBranch}' into current branch to avoid version conflicts...`);
481
- if (isDryRun) {
482
- logger.info(`Would merge ${targetBranch} into current branch`);
479
+ // STEP 3: Merge target branch into working branch (optional - now skipped by default since post-publish sync keeps branches in sync)
480
+ const skipPreMerge = ((_runConfig_publish5 = runConfig.publish) === null || _runConfig_publish5 === void 0 ? void 0 : _runConfig_publish5.skipPrePublishMerge) !== false; // Default to true (skip)
481
+ if (skipPreMerge) {
482
+ logger.verbose(`⏭️ Skipping pre-publish merge (post-publish sync will handle branch synchronization)`);
483
483
  } else {
484
- // Fetch the latest target branch
485
- try {
486
- await run(`git fetch origin ${targetBranch}:${targetBranch}`);
487
- logger.info(`✅ Fetched latest ${targetBranch}`);
488
- } catch (fetchError) {
489
- logger.warn(`⚠️ Could not fetch ${targetBranch}: ${fetchError.message}`);
490
- logger.warn('Continuing without merge - PR may have conflicts...');
491
- }
492
- // Check if merge is needed (avoid unnecessary merge commits)
493
- try {
494
- const { stdout: mergeBase } = await run(`git merge-base HEAD ${targetBranch}`);
495
- const { stdout: targetCommit } = await run(`git rev-parse ${targetBranch}`);
496
- if (mergeBase.trim() === targetCommit.trim()) {
497
- logger.info(`ℹ️ Already up-to-date with ${targetBranch}, no merge needed`);
498
- } else {
499
- // Try to merge target branch into current branch
500
- let mergeSucceeded = false;
501
- try {
502
- await run(`git merge ${targetBranch} --no-edit -m "Merge ${targetBranch} to sync before version bump"`);
503
- logger.info(`✅ Merged ${targetBranch} into current branch`);
504
- mergeSucceeded = true;
505
- } catch (mergeError) {
506
- // If merge conflicts occur, check if they're only in version-related files
507
- const errorText = [
508
- mergeError.message || '',
509
- mergeError.stdout || '',
510
- mergeError.stderr || ''
511
- ].join(' ');
512
- if (errorText.includes('CONFLICT')) {
513
- logger.warn(`⚠️ Merge conflicts detected, attempting automatic resolution...`);
514
- // Get list of conflicted files
515
- const { stdout: conflictedFiles } = await run('git diff --name-only --diff-filter=U');
516
- const conflicts = conflictedFiles.trim().split('\n').filter(Boolean);
517
- logger.verbose(`Conflicted files: ${conflicts.join(', ')}`);
518
- // Check if conflicts are only in package.json and package-lock.json
519
- const versionFiles = [
520
- 'package.json',
521
- 'package-lock.json'
522
- ];
523
- const nonVersionConflicts = conflicts.filter((f)=>!versionFiles.includes(f));
524
- if (nonVersionConflicts.length > 0) {
525
- logger.error(`❌ Cannot auto-resolve: conflicts in non-version files: ${nonVersionConflicts.join(', ')}`);
526
- logger.error('');
527
- logger.error('Please resolve conflicts manually:');
528
- logger.error(' 1. Resolve conflicts in the files listed above');
529
- logger.error(' 2. git add <resolved-files>');
530
- logger.error(' 3. git commit');
531
- logger.error(' 4. kodrdriv publish (to continue)');
532
- logger.error('');
533
- throw new Error(`Merge conflicts in non-version files. Please resolve manually.`);
534
- }
535
- // Auto-resolve version conflicts by accepting current branch versions
536
- // (keep our working branch's version, which is likely already updated)
537
- logger.info(`Auto-resolving version conflicts by keeping current branch versions...`);
538
- for (const file of conflicts){
539
- if (versionFiles.includes(file)) {
540
- await run(`git checkout --ours ${file}`);
541
- await run(`git add ${file}`);
542
- logger.verbose(`Resolved ${file} using current branch version`);
484
+ logger.info(`Merging target branch '${targetBranch}' into current branch to avoid version conflicts...`);
485
+ if (isDryRun) {
486
+ logger.info(`Would merge ${targetBranch} into current branch`);
487
+ } else {
488
+ // Fetch the latest target branch
489
+ try {
490
+ await run(`git fetch origin ${targetBranch}:${targetBranch}`);
491
+ logger.info(`✅ Fetched latest ${targetBranch}`);
492
+ } catch (fetchError) {
493
+ logger.warn(`⚠️ Could not fetch ${targetBranch}: ${fetchError.message}`);
494
+ logger.warn('Continuing without merge - PR may have conflicts...');
495
+ }
496
+ // Check if merge is needed (avoid unnecessary merge commits)
497
+ try {
498
+ const { stdout: mergeBase } = await run(`git merge-base HEAD ${targetBranch}`);
499
+ const { stdout: targetCommit } = await run(`git rev-parse ${targetBranch}`);
500
+ if (mergeBase.trim() === targetCommit.trim()) {
501
+ logger.info(`ℹ️ Already up-to-date with ${targetBranch}, no merge needed`);
502
+ } else {
503
+ // Try to merge target branch into current branch
504
+ let mergeSucceeded = false;
505
+ try {
506
+ await run(`git merge ${targetBranch} --no-edit -m "Merge ${targetBranch} to sync before version bump"`);
507
+ logger.info(`✅ Merged ${targetBranch} into current branch`);
508
+ mergeSucceeded = true;
509
+ } catch (mergeError) {
510
+ // If merge conflicts occur, check if they're only in version-related files
511
+ const errorText = [
512
+ mergeError.message || '',
513
+ mergeError.stdout || '',
514
+ mergeError.stderr || ''
515
+ ].join(' ');
516
+ if (errorText.includes('CONFLICT')) {
517
+ logger.warn(`⚠️ Merge conflicts detected, attempting automatic resolution...`);
518
+ // Get list of conflicted files
519
+ const { stdout: conflictedFiles } = await run('git diff --name-only --diff-filter=U');
520
+ const conflicts = conflictedFiles.trim().split('\n').filter(Boolean);
521
+ logger.verbose(`Conflicted files: ${conflicts.join(', ')}`);
522
+ // Check if conflicts are only in package.json and package-lock.json
523
+ const versionFiles = [
524
+ 'package.json',
525
+ 'package-lock.json'
526
+ ];
527
+ const nonVersionConflicts = conflicts.filter((f)=>!versionFiles.includes(f));
528
+ if (nonVersionConflicts.length > 0) {
529
+ logger.error(`❌ Cannot auto-resolve: conflicts in non-version files: ${nonVersionConflicts.join(', ')}`);
530
+ logger.error('');
531
+ logger.error('Please resolve conflicts manually:');
532
+ logger.error(' 1. Resolve conflicts in the files listed above');
533
+ logger.error(' 2. git add <resolved-files>');
534
+ logger.error(' 3. git commit');
535
+ logger.error(' 4. kodrdriv publish (to continue)');
536
+ logger.error('');
537
+ throw new Error(`Merge conflicts in non-version files. Please resolve manually.`);
538
+ }
539
+ // Auto-resolve version conflicts by accepting current branch versions
540
+ // (keep our working branch's version, which is likely already updated)
541
+ logger.info(`Auto-resolving version conflicts by keeping current branch versions...`);
542
+ for (const file of conflicts){
543
+ if (versionFiles.includes(file)) {
544
+ await run(`git checkout --ours ${file}`);
545
+ await run(`git add ${file}`);
546
+ logger.verbose(`Resolved ${file} using current branch version`);
547
+ }
543
548
  }
549
+ // Complete the merge
550
+ await run(`git commit --no-edit -m "Merge ${targetBranch} to sync before version bump (auto-resolved version conflicts)"`);
551
+ logger.info(`✅ Auto-resolved version conflicts and completed merge`);
552
+ mergeSucceeded = true;
553
+ } else {
554
+ // Not a conflict error, re-throw
555
+ throw mergeError;
544
556
  }
545
- // Complete the merge
546
- await run(`git commit --no-edit -m "Merge ${targetBranch} to sync before version bump (auto-resolved version conflicts)"`);
547
- logger.info(`✅ Auto-resolved version conflicts and completed merge`);
548
- mergeSucceeded = true;
549
- } else {
550
- // Not a conflict error, re-throw
551
- throw mergeError;
552
557
  }
553
- }
554
- // Only run npm install if merge actually happened
555
- if (mergeSucceeded) {
556
- // Run npm install to update package-lock.json based on merged package.json
557
- logger.info('Running npm install after merge...');
558
- await run('npm install');
559
- logger.info('✅ npm install completed');
560
- // Commit any changes from npm install (e.g., package-lock.json updates)
561
- const { stdout: mergeChangesStatus } = await run('git status --porcelain');
562
- if (mergeChangesStatus.trim()) {
563
- logger.verbose('Staging post-merge changes for commit');
564
- await run('git add package.json package-lock.json');
565
- if (await hasStagedChanges()) {
566
- logger.verbose('Committing post-merge changes...');
567
- await execute$1(runConfig);
558
+ // Only run npm install if merge actually happened
559
+ if (mergeSucceeded) {
560
+ // Run npm install to update package-lock.json based on merged package.json
561
+ logger.info('Running npm install after merge...');
562
+ await run('npm install');
563
+ logger.info('npm install completed');
564
+ // Commit any changes from npm install (e.g., package-lock.json updates)
565
+ const { stdout: mergeChangesStatus } = await run('git status --porcelain');
566
+ if (mergeChangesStatus.trim()) {
567
+ logger.verbose('Staging post-merge changes for commit');
568
+ await run('git add package.json package-lock.json');
569
+ if (await hasStagedChanges()) {
570
+ logger.verbose('Committing post-merge changes...');
571
+ await execute$1(runConfig);
572
+ }
568
573
  }
569
574
  }
570
575
  }
576
+ } catch (error) {
577
+ // Only catch truly unexpected errors here
578
+ logger.error(`❌ Unexpected error during merge: ${error.message}`);
579
+ throw error;
571
580
  }
572
- } catch (error) {
573
- // Only catch truly unexpected errors here
574
- logger.error(`❌ Unexpected error during merge: ${error.message}`);
575
- throw error;
576
581
  }
577
582
  }
578
583
  // STEP 4: Determine and set target version AFTER checks, dependency commit, and target branch merge
@@ -582,7 +587,7 @@ const execute = async (runConfig)=>{
582
587
  logger.info('Would determine target version and update package.json');
583
588
  newVersion = '1.0.0'; // Mock version for dry run
584
589
  } else {
585
- var _runConfig_publish8;
590
+ var _runConfig_publish12;
586
591
  const packageJsonContents = await storage.readFile('package.json', 'utf-8');
587
592
  const parsed = safeJsonParse(packageJsonContents, 'package.json');
588
593
  const packageJson = validatePackageJson(parsed, 'package.json');
@@ -599,9 +604,9 @@ const execute = async (runConfig)=>{
599
604
  // Update targetBranch for the rest of the function
600
605
  targetBranch = finalTargetBranch;
601
606
  } else {
602
- var _runConfig_publish9;
607
+ var _runConfig_publish13;
603
608
  // Use existing logic for backward compatibility
604
- const targetVersionInput = ((_runConfig_publish9 = runConfig.publish) === null || _runConfig_publish9 === void 0 ? void 0 : _runConfig_publish9.targetVersion) || 'patch';
609
+ const targetVersionInput = ((_runConfig_publish13 = runConfig.publish) === null || _runConfig_publish13 === void 0 ? void 0 : _runConfig_publish13.targetVersion) || 'patch';
605
610
  proposedVersion = calculateTargetVersion(currentVersion, targetVersionInput);
606
611
  }
607
612
  const targetTagName = `v${proposedVersion}`;
@@ -609,9 +614,9 @@ const execute = async (runConfig)=>{
609
614
  if (tagExists) {
610
615
  throw new Error(`Tag ${targetTagName} already exists. Please choose a different version or delete the existing tag.`);
611
616
  }
612
- if ((_runConfig_publish8 = runConfig.publish) === null || _runConfig_publish8 === void 0 ? void 0 : _runConfig_publish8.interactive) {
613
- var _runConfig_publish10;
614
- newVersion = await confirmVersionInteractively(currentVersion, proposedVersion, (_runConfig_publish10 = runConfig.publish) === null || _runConfig_publish10 === void 0 ? void 0 : _runConfig_publish10.targetVersion);
617
+ if ((_runConfig_publish12 = runConfig.publish) === null || _runConfig_publish12 === void 0 ? void 0 : _runConfig_publish12.interactive) {
618
+ var _runConfig_publish14;
619
+ newVersion = await confirmVersionInteractively(currentVersion, proposedVersion, (_runConfig_publish14 = runConfig.publish) === null || _runConfig_publish14 === void 0 ? void 0 : _runConfig_publish14.targetVersion);
615
620
  const confirmedTagName = `v${newVersion}`;
616
621
  const confirmedTagExists = await checkIfTagExists(confirmedTagName);
617
622
  if (confirmedTagExists) {
@@ -639,33 +644,33 @@ const execute = async (runConfig)=>{
639
644
  }
640
645
  }
641
646
  logger.info('Generating release notes...');
647
+ // Use the existing currentBranch variable for tag detection
648
+ logger.debug(`Current branch for release notes: ${currentBranch}`);
642
649
  // Create a modified config for release notes generation that includes the publish --from, --interactive, and --from-main options
643
650
  const releaseConfig = {
644
651
  ...runConfig
645
652
  };
646
- if (((_runConfig_publish5 = runConfig.publish) === null || _runConfig_publish5 === void 0 ? void 0 : _runConfig_publish5.from) || ((_runConfig_publish6 = runConfig.publish) === null || _runConfig_publish6 === void 0 ? void 0 : _runConfig_publish6.interactive) || ((_runConfig_publish7 = runConfig.publish) === null || _runConfig_publish7 === void 0 ? void 0 : _runConfig_publish7.fromMain)) {
647
- // Pass the publish options to the release config
648
- releaseConfig.release = {
649
- ...runConfig.release,
650
- ...runConfig.publish.from && {
651
- from: runConfig.publish.from
652
- },
653
- ...runConfig.publish.interactive && {
654
- interactive: runConfig.publish.interactive
655
- },
656
- ...runConfig.publish.fromMain && {
657
- fromMain: runConfig.publish.fromMain
658
- }
659
- };
660
- if (runConfig.publish.from) {
661
- logger.verbose(`Using custom 'from' reference for release notes: ${runConfig.publish.from}`);
662
- }
663
- if (runConfig.publish.interactive) {
664
- logger.verbose('Interactive mode enabled for release notes generation');
665
- }
666
- if (runConfig.publish.fromMain) {
667
- logger.verbose('Forcing comparison against main branch for release notes');
653
+ releaseConfig.release = {
654
+ ...runConfig.release,
655
+ currentBranch: currentBranch,
656
+ ...((_runConfig_publish6 = runConfig.publish) === null || _runConfig_publish6 === void 0 ? void 0 : _runConfig_publish6.from) && {
657
+ from: runConfig.publish.from
658
+ },
659
+ ...((_runConfig_publish7 = runConfig.publish) === null || _runConfig_publish7 === void 0 ? void 0 : _runConfig_publish7.interactive) && {
660
+ interactive: runConfig.publish.interactive
661
+ },
662
+ ...((_runConfig_publish8 = runConfig.publish) === null || _runConfig_publish8 === void 0 ? void 0 : _runConfig_publish8.fromMain) && {
663
+ fromMain: runConfig.publish.fromMain
668
664
  }
665
+ };
666
+ if ((_runConfig_publish9 = runConfig.publish) === null || _runConfig_publish9 === void 0 ? void 0 : _runConfig_publish9.from) {
667
+ logger.verbose(`Using custom 'from' reference for release notes: ${runConfig.publish.from}`);
668
+ }
669
+ if ((_runConfig_publish10 = runConfig.publish) === null || _runConfig_publish10 === void 0 ? void 0 : _runConfig_publish10.interactive) {
670
+ logger.verbose('Interactive mode enabled for release notes generation');
671
+ }
672
+ if ((_runConfig_publish11 = runConfig.publish) === null || _runConfig_publish11 === void 0 ? void 0 : _runConfig_publish11.fromMain) {
673
+ logger.verbose('Forcing comparison against main branch for release notes');
669
674
  }
670
675
  const releaseSummary = await execute$2(releaseConfig);
671
676
  if (isDryRun) {
@@ -702,12 +707,12 @@ const execute = async (runConfig)=>{
702
707
  }
703
708
  logger.info(`Waiting for PR #${pr.number} checks to complete...`);
704
709
  if (!isDryRun) {
705
- var _runConfig_publish11, _runConfig_publish12, _runConfig_publish13;
710
+ var _runConfig_publish15, _runConfig_publish16, _runConfig_publish17;
706
711
  // Configure timeout and user confirmation behavior
707
- const timeout = ((_runConfig_publish11 = runConfig.publish) === null || _runConfig_publish11 === void 0 ? void 0 : _runConfig_publish11.checksTimeout) || KODRDRIV_DEFAULTS.publish.checksTimeout;
708
- const senditMode = ((_runConfig_publish12 = runConfig.publish) === null || _runConfig_publish12 === void 0 ? void 0 : _runConfig_publish12.sendit) || false;
712
+ const timeout = ((_runConfig_publish15 = runConfig.publish) === null || _runConfig_publish15 === void 0 ? void 0 : _runConfig_publish15.checksTimeout) || KODRDRIV_DEFAULTS.publish.checksTimeout;
713
+ const senditMode = ((_runConfig_publish16 = runConfig.publish) === null || _runConfig_publish16 === void 0 ? void 0 : _runConfig_publish16.sendit) || false;
709
714
  // sendit flag overrides skipUserConfirmation - if sendit is true, skip confirmation
710
- const skipUserConfirmation = senditMode || ((_runConfig_publish13 = runConfig.publish) === null || _runConfig_publish13 === void 0 ? void 0 : _runConfig_publish13.skipUserConfirmation) || false;
715
+ const skipUserConfirmation = senditMode || ((_runConfig_publish17 = runConfig.publish) === null || _runConfig_publish17 === void 0 ? void 0 : _runConfig_publish17.skipUserConfirmation) || false;
711
716
  await waitForPullRequestChecks(pr.number, {
712
717
  timeout,
713
718
  skipUserConfirmation
@@ -908,9 +913,9 @@ const execute = async (runConfig)=>{
908
913
  }
909
914
  logger.info('Creating GitHub release...');
910
915
  if (isDryRun) {
911
- var _runConfig_publish14;
916
+ var _runConfig_publish18;
912
917
  logger.info('Would read package.json version and create GitHub release with retry logic');
913
- const milestonesEnabled = !((_runConfig_publish14 = runConfig.publish) === null || _runConfig_publish14 === void 0 ? void 0 : _runConfig_publish14.noMilestones);
918
+ const milestonesEnabled = !((_runConfig_publish18 = runConfig.publish) === null || _runConfig_publish18 === void 0 ? void 0 : _runConfig_publish18.noMilestones);
914
919
  if (milestonesEnabled) {
915
920
  logger.info('Would close milestone for released version');
916
921
  } else {
@@ -926,11 +931,11 @@ const execute = async (runConfig)=>{
926
931
  let retries = 3;
927
932
  while(retries > 0){
928
933
  try {
929
- var _runConfig_publish15;
934
+ var _runConfig_publish19;
930
935
  await createRelease(tagName, releaseTitle, releaseNotesContent);
931
936
  logger.info(`GitHub release created successfully for tag: ${tagName}`);
932
937
  // Close milestone for this version if enabled
933
- const milestonesEnabled = !((_runConfig_publish15 = runConfig.publish) === null || _runConfig_publish15 === void 0 ? void 0 : _runConfig_publish15.noMilestones);
938
+ const milestonesEnabled = !((_runConfig_publish19 = runConfig.publish) === null || _runConfig_publish19 === void 0 ? void 0 : _runConfig_publish19.noMilestones);
934
939
  if (milestonesEnabled) {
935
940
  logger.info('🏁 Closing milestone for released version...');
936
941
  const version = tagName.replace(/^v/, ''); // Remove 'v' prefix if present
@@ -963,12 +968,12 @@ const execute = async (runConfig)=>{
963
968
  if (isDryRun) {
964
969
  logger.info('Would monitor GitHub Actions workflows triggered by release');
965
970
  } else {
966
- var _runConfig_publish16, _runConfig_publish17, _runConfig_publish18, _runConfig_publish19;
967
- const workflowTimeout = ((_runConfig_publish16 = runConfig.publish) === null || _runConfig_publish16 === void 0 ? void 0 : _runConfig_publish16.releaseWorkflowsTimeout) || KODRDRIV_DEFAULTS.publish.releaseWorkflowsTimeout;
968
- const senditMode = ((_runConfig_publish17 = runConfig.publish) === null || _runConfig_publish17 === void 0 ? void 0 : _runConfig_publish17.sendit) || false;
969
- const skipUserConfirmation = senditMode || ((_runConfig_publish18 = runConfig.publish) === null || _runConfig_publish18 === void 0 ? void 0 : _runConfig_publish18.skipUserConfirmation) || false;
971
+ var _runConfig_publish20, _runConfig_publish21, _runConfig_publish22, _runConfig_publish23;
972
+ const workflowTimeout = ((_runConfig_publish20 = runConfig.publish) === null || _runConfig_publish20 === void 0 ? void 0 : _runConfig_publish20.releaseWorkflowsTimeout) || KODRDRIV_DEFAULTS.publish.releaseWorkflowsTimeout;
973
+ const senditMode = ((_runConfig_publish21 = runConfig.publish) === null || _runConfig_publish21 === void 0 ? void 0 : _runConfig_publish21.sendit) || false;
974
+ const skipUserConfirmation = senditMode || ((_runConfig_publish22 = runConfig.publish) === null || _runConfig_publish22 === void 0 ? void 0 : _runConfig_publish22.skipUserConfirmation) || false;
970
975
  // Get workflow names - either from config or auto-detect
971
- let workflowNames = (_runConfig_publish19 = runConfig.publish) === null || _runConfig_publish19 === void 0 ? void 0 : _runConfig_publish19.releaseWorkflowNames;
976
+ let workflowNames = (_runConfig_publish23 = runConfig.publish) === null || _runConfig_publish23 === void 0 ? void 0 : _runConfig_publish23.releaseWorkflowNames;
972
977
  if (!workflowNames || workflowNames.length === 0) {
973
978
  logger.info('No specific workflow names configured, auto-detecting workflows triggered by release events...');
974
979
  try {
@@ -992,10 +997,64 @@ const execute = async (runConfig)=>{
992
997
  } else {
993
998
  logger.verbose('Skipping waiting for release workflows (disabled in config).');
994
999
  }
995
- // Switch to target branch
996
- logger.info(`Switching to target branch: ${targetBranch}`);
997
- await runWithDryRunSupport(`git checkout ${targetBranch}`, isDryRun);
998
- logger.info('Publish process complete.');
1000
+ // Switch back to source branch and sync with target
1001
+ logger.info('');
1002
+ logger.info('🔄 Syncing source branch with target after publish...');
1003
+ await runWithDryRunSupport(`git checkout ${currentBranch}`, isDryRun);
1004
+ if (!isDryRun) {
1005
+ // Merge target into source (should be fast-forward since PR just merged)
1006
+ logger.info(`Merging ${targetBranch} into ${currentBranch}...`);
1007
+ try {
1008
+ await run(`git merge ${targetBranch} --ff-only`);
1009
+ logger.info(`✅ Merged ${targetBranch} into ${currentBranch}`);
1010
+ } catch (error) {
1011
+ // If ff-only fails, something is wrong - source diverged somehow
1012
+ logger.error(`❌ Failed to fast-forward merge ${targetBranch} into ${currentBranch}`);
1013
+ logger.error(' This suggests the source branch has commits not in target.');
1014
+ logger.error(' This should not happen after a successful PR merge.');
1015
+ logger.warn('⚠️ Attempting regular merge...');
1016
+ await run(`git merge ${targetBranch} --no-edit`);
1017
+ }
1018
+ // Determine version bump based on branch configuration
1019
+ let versionCommand = 'prepatch'; // Default
1020
+ let versionTag = 'dev'; // Default
1021
+ if (branchDependentVersioning && runConfig.branches) {
1022
+ const sourceBranchConfig = runConfig.branches[currentBranch];
1023
+ if (sourceBranchConfig === null || sourceBranchConfig === void 0 ? void 0 : sourceBranchConfig.version) {
1024
+ // Use configured version strategy for source branch
1025
+ if (sourceBranchConfig.version.increment) {
1026
+ versionCommand = `pre${sourceBranchConfig.version.increment}`;
1027
+ }
1028
+ if (sourceBranchConfig.version.tag) {
1029
+ versionTag = sourceBranchConfig.version.tag;
1030
+ }
1031
+ }
1032
+ }
1033
+ // Bump to next development version
1034
+ logger.info(`Bumping to next development version...`);
1035
+ try {
1036
+ const { stdout: newVersion } = await run(`npm version ${versionCommand} --preid=${versionTag}`);
1037
+ logger.info(`✅ Version bumped to: ${newVersion.trim()}`);
1038
+ } catch (versionError) {
1039
+ logger.warn(`⚠️ Failed to bump version: ${versionError.message}`);
1040
+ logger.warn(' You may need to manually bump the version for next development cycle.');
1041
+ }
1042
+ // Push updated source branch
1043
+ logger.info(`Pushing updated ${currentBranch} branch...`);
1044
+ try {
1045
+ await run(`git push origin ${currentBranch}`);
1046
+ logger.info(`✅ Pushed ${currentBranch} to origin`);
1047
+ } catch (pushError) {
1048
+ logger.warn(`⚠️ Failed to push ${currentBranch}: ${pushError.message}`);
1049
+ logger.warn(` Please push manually: git push origin ${currentBranch}`);
1050
+ }
1051
+ } else {
1052
+ logger.info(`Would merge ${targetBranch} into ${currentBranch} with --ff-only`);
1053
+ logger.info(`Would bump version to next development version`);
1054
+ logger.info(`Would push ${currentBranch} to origin`);
1055
+ }
1056
+ logger.info('');
1057
+ logger.info(`✅ Publish complete - on ${currentBranch} with next development version`);
999
1058
  };
1000
1059
 
1001
1060
  export { execute };