Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion ng-dev/release/publish/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import {promises as fs, existsSync} from 'fs';
import path, {join} from 'path';
import semver from 'semver';

import {workspaceRelativePackageJsonPath} from '../../utils/constants.js';
import {
workspaceRelativeBazelModuleLock,
workspaceRelativePackageJsonPath,
} from '../../utils/constants.js';
import {AuthenticatedGitClient} from '../../utils/git/authenticated-git-client.js';
import {isGithubApiError} from '../../utils/git/github.js';
import githubMacros from '../../utils/git/github-macros.js';
Expand Down Expand Up @@ -140,6 +143,10 @@ export abstract class ReleaseAction {
if (this.config.rulesJsInteropMode && existsSync(path.join(this.projectDir, '.aspect'))) {
await ExternalCommands.invokeBazelUpdateAspectLockFiles(this.projectDir);
}

if (existsSync(join(this.projectDir, workspaceRelativeBazelModuleLock))) {
await ExternalCommands.invokeBazelModDepsUpdate(this.projectDir);
}
}

/*
Expand All @@ -152,6 +159,15 @@ export abstract class ReleaseAction {
: [];
}

/*
* Get the modified "MODULE.bazel.lock" if bazel modules are enabled.
*/
protected getModuleBazelLockFile(): string | undefined {
return existsSync(join(this.projectDir, workspaceRelativeBazelModuleLock))
? workspaceRelativeBazelModuleLock
: undefined;
}

/** Gets the most recent commit of a specified branch. */
protected async getLatestCommitOfBranch(branchName: string): Promise<Commit> {
const {
Expand Down Expand Up @@ -225,6 +241,11 @@ export abstract class ReleaseAction {
...this.getAspectLockFiles(),
];

const bazelModuleLockFile = this.getModuleBazelLockFile();
if (bazelModuleLockFile) {
filesToCommit.push(bazelModuleLockFile);
}

const commitMessage = getCommitMessageForRelease(newVersion);

// Create a release staging commit including changelog and version bump.
Expand Down
12 changes: 10 additions & 2 deletions ng-dev/release/publish/actions/configure-next-as-major.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,18 @@ export class ConfigureNextAsMajorAction extends ReleaseAction {
await this.checkoutUpstreamBranch(branchName);
await this.updateProjectVersion(newVersion);

await this.createCommit(getCommitMessageForNextBranchMajorSwitch(newVersion), [
const filesToCommit: string[] = [
workspaceRelativePackageJsonPath,
...this.getAspectLockFiles(),
]);
];

const bazelModuleLockFile = this.getModuleBazelLockFile();
if (bazelModuleLockFile) {
filesToCommit.push(bazelModuleLockFile);
}

await this.createCommit(getCommitMessageForNextBranchMajorSwitch(newVersion), filesToCommit);

const pullRequest = await this.pushChangesToForkAndCreatePullRequest(
branchName,
`switch-next-to-major-${newVersion}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,20 @@ export class PrepareExceptionalMinorAction extends ReleaseAction {
pkgJson[exceptionalMinorPackageIndicator] = true;
});

await this.createCommit(`build: prepare exceptional minor branch: ${this._newBranch}`, [
const filesToCommit: string[] = [
workspaceRelativePackageJsonPath,
...this.getAspectLockFiles(),
]);
];

const bazelModuleLockFile = this.getModuleBazelLockFile();
if (bazelModuleLockFile) {
filesToCommit.push(bazelModuleLockFile);
}

await this.createCommit(
`build: prepare exceptional minor branch: ${this._newBranch}`,
filesToCommit,
);

await this.pushHeadToRemoteBranch(this._newBranch);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ export abstract class BranchOffNextBranchBaseAction extends CutNpmNextPrerelease
...this.getAspectLockFiles(),
];

const bazelModuleLockFile = this.getModuleBazelLockFile();
if (bazelModuleLockFile) {
filesToCommit.push(bazelModuleLockFile);
}

const renovateConfigPath = await updateRenovateConfig(
this.projectDir,
`${version.major}.${version.minor}.x`,
Expand Down
20 changes: 19 additions & 1 deletion ng-dev/release/publish/external-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
*/

import semver from 'semver';

import {ChildProcess, SpawnResult, SpawnOptions} from '../../utils/child-process.js';
import {Spinner} from '../../utils/spinner.js';
import {NpmDistTag} from '../versioning/index.js';
Expand Down Expand Up @@ -263,6 +262,25 @@ export abstract class ExternalCommands {
}
}

/**
* Invokes the `bazel mod deps --lockfile_mode=update` command in order
* to refresh `MODULE.bazel.lock` file.
*/
static async invokeBazelModDepsUpdate(projectDir: string): Promise<void> {
const spinner = new Spinner('Updating "MODULE.bazel.lock"');
try {
await ChildProcess.spawn(getBazelBin(), ['mod', 'deps', '--lockfile_mode=update'], {
cwd: projectDir,
mode: 'silent',
});
} catch (e) {
Log.error(e);
Log.error(' ✘ An error occurred while updating "MODULE.bazel.lock".');
throw new FatalReleaseActionError();
}
spinner.success(green(' Updated "MODULE.bazel.lock" file.'));
}

/**
* Invokes the `yarn bazel sync --only=repo` command in order
* to refresh Aspect lock files.
Expand Down
3 changes: 3 additions & 0 deletions ng-dev/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ export const ngDevNpmPackageName = '@angular/ng-dev';

/** Workspace-relative path for the "package.json" file. */
export const workspaceRelativePackageJsonPath = 'package.json';

/** Workspace-relative path for the "MODULE.bazel.lock" file. */
export const workspaceRelativeBazelModuleLock = 'MODULE.bazel.lock';