diff --git a/ng-dev/release/publish/BUILD.bazel b/ng-dev/release/publish/BUILD.bazel index 044884e07..24fdc914c 100644 --- a/ng-dev/release/publish/BUILD.bazel +++ b/ng-dev/release/publish/BUILD.bazel @@ -14,6 +14,7 @@ ts_project( "//ng-dev:node_modules/@types/semver", "//ng-dev:node_modules/@types/yargs", "//ng-dev:node_modules/ejs", + "//ng-dev:node_modules/fast-glob", "//ng-dev:node_modules/folder-hash", "//ng-dev:node_modules/semver", "//ng-dev:node_modules/typed-graphqlify", diff --git a/ng-dev/release/publish/actions.ts b/ng-dev/release/publish/actions.ts index 31cacda08..78a907cb0 100644 --- a/ng-dev/release/publish/actions.ts +++ b/ng-dev/release/publish/actions.ts @@ -6,9 +6,10 @@ * found in the LICENSE file at https://angular.io/license */ -import {promises as fs} from 'fs'; +import {existsSync, promises as fs} from 'fs'; import {join} from 'path'; import semver from 'semver'; +import glob from 'fast-glob'; import {workspaceRelativePackageJsonPath} from '../../utils/constants.js'; import {AuthenticatedGitClient} from '../../utils/git/authenticated-git-client.js'; @@ -133,6 +134,21 @@ export abstract class ReleaseAction { // to avoid unnecessary diff. IDEs usually add a trailing new line. await fs.writeFile(pkgJsonPath, `${JSON.stringify(pkgJson, null, 2)}\n`); Log.info(green(` ✓ Updated project version to ${pkgJson.version}`)); + + // TODO: remove when Angular version 19 is no longer in LTS. + if (existsSync(join(this.projectDir, '.aspect'))) { + await ExternalCommands.invokeBazelUpdateAspectLockFiles(this.projectDir); + } + } + + /* + * Get the modified Aspect lock files if `rulesJsInteropMode` is enabled. + */ + protected getAspectLockFiles(): string[] { + // TODO: remove when Angular version 19 is no longer in LTS. + return existsSync(join(this.projectDir, '.aspect')) + ? [...glob.sync('.aspect/**', {cwd: this.projectDir}), 'pnpm-lock.yaml'] + : []; } /** Gets the most recent commit of a specified branch. */ @@ -202,7 +218,11 @@ export abstract class ReleaseAction { } // Commit message for the release point. - const filesToCommit = [workspaceRelativePackageJsonPath, workspaceRelativeChangelogPath]; + const filesToCommit = [ + workspaceRelativePackageJsonPath, + workspaceRelativeChangelogPath, + ...this.getAspectLockFiles(), + ]; const commitMessage = getCommitMessageForRelease(newVersion); diff --git a/ng-dev/release/publish/external-commands.ts b/ng-dev/release/publish/external-commands.ts index e618ecc7f..49aceaa49 100644 --- a/ng-dev/release/publish/external-commands.ts +++ b/ng-dev/release/publish/external-commands.ts @@ -19,6 +19,7 @@ import {ReleasePrecheckJsonStdin} from '../precheck/cli.js'; import {BuiltPackageWithInfo} from '../config/index.js'; import {green, Log} from '../../utils/logging.js'; import {PnpmVersioning} from './pnpm-versioning.js'; +import {getBazelBin} from '../../utils/bazel-bin.js'; /* * ############################################################### @@ -288,4 +289,24 @@ export abstract class ExternalCommands { }); } } + + /** + * Invokes the `yarn bazel sync --only=repo` command in order + * to refresh Aspect lock files. + */ + static async invokeBazelUpdateAspectLockFiles(projectDir: string): Promise { + // TODO: remove when Angular version 19 is no longer in LTS. + const spinner = new Spinner('Updating Aspect lock files'); + try { + await ChildProcess.spawn(getBazelBin(), ['sync', '--only=repo'], { + cwd: projectDir, + mode: 'silent', + }); + } catch (e) { + // Note: Gracefully handling these errors because `sync` command + // exits with a non-zero exit code when pnpm-lock.yaml file is updated. + Log.debug(e); + } + spinner.success(green(' Updated Aspect `rules_js` lock files.')); + } }