@@ -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,43 @@ 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+ if ( ! existsSync ( renovateConfigPath ) ) {
157+ spinner . success ( yellow ( 'Skipped updating Renovate config as it was not found.' ) ) ;
158+
159+ return null ;
160+ }
161+
162+ const config = await fs . readFile ( renovateConfigPath , 'utf-8' ) ;
163+ const configJson = JSON . parse ( config ) as Record < string , unknown > ;
164+ const baseBranches = configJson . baseBranches ;
165+ if ( ! Array . isArray ( baseBranches ) || baseBranches . length !== 2 ) {
166+ spinner . success (
167+ yellow ( 'Skipped updating Renovate config: "baseBranches" must contain exactly 2 branches.' ) ,
168+ ) ;
169+
170+ return null ;
171+ }
172+
173+ configJson . baseBranches = [ 'main' , newBranchName ] ;
174+ await fs . writeFile ( renovateConfigPath , JSON . stringify ( configJson , undefined , 2 ) ) ;
175+ spinner . success ( green ( ' Updated Renovate config' ) ) ;
176+
177+ return renovateConfigPath ;
178+ }
179+
143180 /*
144181 * Get the modified Aspect lock files if `rulesJsInteropMode` is enabled.
145182 */
0 commit comments