Skip to content

Commit 95e3a0e

Browse files
committed
feat(ng-dev): re-add support for updating and committing Bazel Aspect lock files
This is needed to release Angular version 19 LTS.
1 parent e901344 commit 95e3a0e

File tree

3 files changed

+44
-2
lines changed

3 files changed

+44
-2
lines changed

ng-dev/release/publish/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ ts_project(
1414
"//ng-dev:node_modules/@types/semver",
1515
"//ng-dev:node_modules/@types/yargs",
1616
"//ng-dev:node_modules/ejs",
17+
"//ng-dev:node_modules/fast-glob",
1718
"//ng-dev:node_modules/folder-hash",
1819
"//ng-dev:node_modules/semver",
1920
"//ng-dev:node_modules/typed-graphqlify",

ng-dev/release/publish/actions.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {promises as fs} from 'fs';
9+
import {existsSync, promises as fs} from 'fs';
1010
import {join} from 'path';
1111
import semver from 'semver';
12+
import glob from 'fast-glob';
1213

1314
import {workspaceRelativePackageJsonPath} from '../../utils/constants.js';
1415
import {AuthenticatedGitClient} from '../../utils/git/authenticated-git-client.js';
@@ -133,6 +134,21 @@ export abstract class ReleaseAction {
133134
// to avoid unnecessary diff. IDEs usually add a trailing new line.
134135
await fs.writeFile(pkgJsonPath, `${JSON.stringify(pkgJson, null, 2)}\n`);
135136
Log.info(green(` ✓ Updated project version to ${pkgJson.version}`));
137+
138+
// TODO: remove when Angular version 19 is no longer in LTS.
139+
if (existsSync(join(this.projectDir, '.aspect'))) {
140+
await ExternalCommands.invokeBazelUpdateAspectLockFiles(this.projectDir);
141+
}
142+
}
143+
144+
/*
145+
* Get the modified Aspect lock files if `rulesJsInteropMode` is enabled.
146+
*/
147+
protected getAspectLockFiles(): string[] {
148+
// TODO: remove when Angular version 19 is no longer in LTS.
149+
return existsSync(join(this.projectDir, '.aspect'))
150+
? [...glob.sync('.aspect/**', {cwd: this.projectDir}), 'pnpm-lock.yaml']
151+
: [];
136152
}
137153

138154
/** Gets the most recent commit of a specified branch. */
@@ -202,7 +218,11 @@ export abstract class ReleaseAction {
202218
}
203219

204220
// Commit message for the release point.
205-
const filesToCommit = [workspaceRelativePackageJsonPath, workspaceRelativeChangelogPath];
221+
const filesToCommit = [
222+
workspaceRelativePackageJsonPath,
223+
workspaceRelativeChangelogPath,
224+
...this.getAspectLockFiles(),
225+
];
206226

207227
const commitMessage = getCommitMessageForRelease(newVersion);
208228

ng-dev/release/publish/external-commands.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {ReleasePrecheckJsonStdin} from '../precheck/cli.js';
1919
import {BuiltPackageWithInfo} from '../config/index.js';
2020
import {green, Log} from '../../utils/logging.js';
2121
import {PnpmVersioning} from './pnpm-versioning.js';
22+
import {getBazelBin} from '../../utils/bazel-bin.js';
2223

2324
/*
2425
* ###############################################################
@@ -288,4 +289,24 @@ export abstract class ExternalCommands {
288289
});
289290
}
290291
}
292+
293+
/**
294+
* Invokes the `yarn bazel sync --only=repo` command in order
295+
* to refresh Aspect lock files.
296+
*/
297+
static async invokeBazelUpdateAspectLockFiles(projectDir: string): Promise<void> {
298+
// TODO: remove when Angular version 19 is no longer in LTS.
299+
const spinner = new Spinner('Updating Aspect lock files');
300+
try {
301+
await ChildProcess.spawn(getBazelBin(), ['sync', '--only=repo'], {
302+
cwd: projectDir,
303+
mode: 'silent',
304+
});
305+
} catch (e) {
306+
// Note: Gracefully handling these errors because `sync` command
307+
// exits with a non-zero exit code when pnpm-lock.yaml file is updated.
308+
Log.debug(e);
309+
}
310+
spinner.success(green(' Updated Aspect `rules_js` lock files.'));
311+
}
291312
}

0 commit comments

Comments
 (0)