|
1 | 1 | import {BuiltPackage, ReleaseConfig} from '@angular/dev-infra-private/release/config';
|
2 | 2 | import {ReleaseAction} from '@angular/dev-infra-private/release/publish/actions';
|
3 | 3 | import {SemVer} from 'semver';
|
4 |
| - |
5 |
| -import { |
6 |
| - assertValidFrameworkPeerDependency |
7 |
| -} from '../tools/release-checks/check-framework-peer-dependency'; |
8 |
| -import { |
9 |
| - assertValidUpdateMigrationCollections |
10 |
| -} from '../tools/release-checks/check-migration-collections'; |
11 | 4 | import {assertValidNpmPackageOutput} from '../tools/release-checks/npm-package-output';
|
| 5 | +import {fork} from 'child_process'; |
| 6 | +import {join} from 'path'; |
| 7 | +import {FatalReleaseActionError} from '@angular/dev-infra-private/release/publish/actions-error'; |
12 | 8 |
|
13 | 9 | const actionProto = ReleaseAction.prototype as any;
|
14 | 10 | const _origStageFn = actionProto.stageVersionForBranchAndCreatePullRequest;
|
15 | 11 | const _origVerifyFn = actionProto._verifyPackageVersions;
|
16 | 12 |
|
| 13 | +/** Runs the staging sanity release checks for the given new version. */ |
| 14 | +async function runStagingReleaseChecks(newVersion: SemVer) { |
| 15 | + return new Promise<void>((resolve, reject) => { |
| 16 | + // Note: We run the staging release checks in a new node process. This is necessary |
| 17 | + // because before staging, the correct publish branch is checked out. If we'd |
| 18 | + // directly call into the release checks, the `.ng-dev/release` config would be |
| 19 | + // cached by NodeJS and release checks would potentially check for packages which |
| 20 | + // no longer exist in the publish branch (or the other way around). |
| 21 | + const releaseChecksProcess = fork( |
| 22 | + join(__dirname, '../tools/release-checks/index.js'), [newVersion.format()]); |
| 23 | + |
| 24 | + releaseChecksProcess.on('close', code => { |
| 25 | + if (code !== 0) { |
| 26 | + reject(new FatalReleaseActionError()); |
| 27 | + } else { |
| 28 | + resolve(); |
| 29 | + } |
| 30 | + }); |
| 31 | + }); |
| 32 | +} |
| 33 | + |
17 | 34 | // Patches the `@angular/dev-infra-private` release tool to perform sanity checks
|
18 | 35 | // before staging a release. This is temporary until the dev-infra team has implemented
|
19 | 36 | // a more generic solution to running sanity checks before releasing (potentially building
|
20 | 37 | // some of the checks we have in the components repository into the release tool).
|
21 | 38 | actionProto.stageVersionForBranchAndCreatePullRequest = async function(newVersion: SemVer) {
|
22 |
| - await assertValidFrameworkPeerDependency(newVersion); |
23 |
| - await assertValidUpdateMigrationCollections(newVersion); |
| 39 | + await runStagingReleaseChecks(newVersion); |
24 | 40 |
|
25 | 41 | return await _origStageFn.apply(this, arguments);
|
26 | 42 | };
|
|
0 commit comments