feat(dev-infra): update package version verification to allow for experimental version (#42898)

The angular-cli repo publishes experimental versioned packages in addition to standard
versioned packages.  Both experimental and standard verions, based on the expected new
version provided are treated as valid and correct.

PR Close #42898
This commit is contained in:
Joey Perrott 2021-07-19 17:04:38 -07:00 committed by Alex Rickabaugh
parent 52dc65dd1b
commit 445fee4174
2 changed files with 15 additions and 4 deletions

View File

@ -6800,11 +6800,15 @@ class ReleaseAction {
/** Verify the version of each generated package exact matches the specified version. */
_verifyPackageVersions(version, packages) {
return tslib.__awaiter(this, void 0, void 0, function* () {
/** Experimental equivalent version for packages created with the provided version. */
const experimentalVersion = new semver.SemVer(`0.${version.major * 100 + version.minor}.${version.patch}`);
for (const pkg of packages) {
const { version: packageJsonVersion } = JSON.parse(yield fs.promises.readFile(path.join(pkg.outputPath, 'package.json'), 'utf8'));
if (version.compare(packageJsonVersion) !== 0) {
const mismatchesVersion = version.compare(packageJsonVersion) !== 0;
const mismatchesExperimental = experimentalVersion.compare(packageJsonVersion) !== 0;
if (mismatchesExperimental && mismatchesVersion) {
error(red('The built package version does not match the version being released.'));
error(` Release Version: ${version.version}`);
error(` Release Version: ${version.version} (${experimentalVersion.version})`);
error(` Generated Version: ${packageJsonVersion}`);
throw new FatalReleaseActionError();
}

View File

@ -508,13 +508,20 @@ export abstract class ReleaseAction {
/** Verify the version of each generated package exact matches the specified version. */
private async _verifyPackageVersions(version: semver.SemVer, packages: BuiltPackage[]) {
/** Experimental equivalent version for packages created with the provided version. */
const experimentalVersion =
new semver.SemVer(`0.${version.major * 100 + version.minor}.${version.patch}`);
for (const pkg of packages) {
const {version: packageJsonVersion} =
JSON.parse(await fs.readFile(join(pkg.outputPath, 'package.json'), 'utf8')) as
{version: string, [key: string]: any};
if (version.compare(packageJsonVersion) !== 0) {
const mismatchesVersion = version.compare(packageJsonVersion) !== 0;
const mismatchesExperimental = experimentalVersion.compare(packageJsonVersion) !== 0;
if (mismatchesExperimental && mismatchesVersion) {
error(red('The built package version does not match the version being released.'));
error(` Release Version: ${version.version}`);
error(` Release Version: ${version.version} (${experimentalVersion.version})`);
error(` Generated Version: ${packageJsonVersion}`);
throw new FatalReleaseActionError();
}