@@ -19,7 +19,7 @@ import {
1919 getListCommitsInBranchUrl ,
2020 getRepositoryGitUrl ,
2121} from '../../utils/git/github-urls.js' ;
22- import { green , Log } from '../../utils/logging.js' ;
22+ import { green , Log , yellow } from '../../utils/logging.js' ;
2323import { Spinner } from '../../utils/spinner.js' ;
2424import { BuiltPackage , BuiltPackageWithInfo , ReleaseConfig } from '../config/index.js' ;
2525import { ReleaseNotes , workspaceRelativeChangelogPath } from '../notes/release-notes.js' ;
@@ -140,6 +140,36 @@ export abstract class ReleaseAction {
140140 }
141141 }
142142
143+ /**
144+ * Updates the `renovate.json` configuration file to include a new base branch.
145+ *
146+ * This is used when `rulesJsInteropMode` is enabled to ensure the Renovate
147+ * tool considers both the main branch and a new feature or update branch.
148+ *
149+ * @param newBranchName - The name of the new branch to add to the base branches list.
150+ * @returns A promise that resolves to an string containing the path to the modified `renovate.json` file,
151+ * or null if config updating is disabled.
152+ */
153+ protected async updateRenovateConfig ( newBranchName : string ) : Promise < string | null > {
154+ const spinner = new Spinner ( 'Updating Renovate config' ) ;
155+ const renovateConfigPath = path . join ( this . projectDir , 'renovate.json' ) ;
156+ const config = await fs . readFile ( renovateConfigPath , 'utf-8' ) ;
157+ const configJson = JSON . parse ( config ) ;
158+ if ( configJson . baseBranches ?. length !== 2 ) {
159+ spinner . success (
160+ yellow ( 'Skipped updating Renovate config: "baseBranches" must contain exactly 2 branches.' ) ,
161+ ) ;
162+
163+ return null ;
164+ }
165+
166+ configJson . baseBranches = [ 'main' , newBranchName ] ;
167+ await fs . writeFile ( renovateConfigPath , JSON . stringify ( configJson , undefined , 2 ) ) ;
168+ spinner . success ( green ( ' Updated Renovate config' ) ) ;
169+
170+ return renovateConfigPath ;
171+ }
172+
143173 /*
144174 * Get the modified Aspect lock files if `rulesJsInteropMode` is enabled.
145175 */
0 commit comments