import { executeCommand, versionBumpThemes, getChangedThemes, } from './deploy-utils.mjs'; /* Version bump and update the changelog for all changed themes in a PR. Accepts the PR title to use in the theme changelog. */ export async function versionBumpInPr( prTitle ) { const changedThemes = await getChangedThemes( 'in-pr' ); if ( ! changedThemes || changedThemes.length === 0 ) { console.log( 'No changes were detected, so a version bump is not required.' ); return; } if ( ! prTitle ) { // Default PR title if one is not provided prTitle = 'Theme version bump'; } // Make sure PR title is a string prTitle = prTitle ? String( prTitle ) : ''; if ( changedThemes.length > 0 ) { const mergeBaseHash = await executeCommand( 'git merge-base trunk HEAD' ); const changesWereMade = await versionBumpThemes( changedThemes, false, mergeBaseHash, prTitle ); if ( changesWereMade ) { console.log( 'Changes were made. They need to be committed manually.' ); } else { console.log( 'No themes required a version bump. Either there were no changes found or the changed themes have already been version bumped.' ); } } }