|
1 |
| -import { |
2 |
| - BuiltPackage, |
3 |
| - ReleaseConfig, |
4 |
| - ReleaseAction as _ReleaseAction, |
5 |
| - FatalReleaseActionError, |
6 |
| -} from '@angular/dev-infra-private/ng-dev'; |
7 | 1 | import {SemVer} from 'semver';
|
| 2 | +import {ReleaseConfig} from '@angular/dev-infra-private/ng-dev'; |
| 3 | +import {assertValidFrameworkPeerDependency} from '../tools/release-checks/check-framework-peer-dependency'; |
| 4 | +import {assertValidUpdateMigrationCollections} from '../tools/release-checks/check-migration-collections'; |
8 | 5 | import {assertValidNpmPackageOutput} from '../tools/release-checks/npm-package-output';
|
9 |
| -import {fork} from 'child_process'; |
10 |
| -import {join} from 'path'; |
11 |
| - |
12 |
| -// The `ng-dev` release tool exposes the `ReleaseAction` instance through `global`, |
13 |
| -// allowing it to be monkey-patched for our release checks. This can be removed |
14 |
| -// when the release tool has a public API for release checks. |
15 |
| -const actionProto = ((global as any).ReleaseAction ?? _ReleaseAction).prototype; |
16 |
| -const _origStageFn = actionProto.stageVersionForBranchAndCreatePullRequest; |
17 |
| -const _origVerifyFn = actionProto._verifyPackageVersions; |
18 |
| - |
19 |
| -/** Runs the staging sanity release checks for the given new version. */ |
20 |
| -async function runStagingReleaseChecks(newVersion: SemVer) { |
21 |
| - return new Promise<void>((resolve, reject) => { |
22 |
| - // Note: We run the staging release checks in a new node process. This is necessary |
23 |
| - // because before staging, the correct publish branch is checked out. If we'd |
24 |
| - // directly call into the release checks, the `.ng-dev/release` config would be |
25 |
| - // cached by NodeJS and release checks would potentially check for packages which |
26 |
| - // no longer exist in the publish branch (or the other way around). |
27 |
| - const releaseChecksProcess = fork(join(__dirname, '../tools/release-checks/index.js'), [ |
28 |
| - newVersion.format(), |
29 |
| - ]); |
30 |
| - |
31 |
| - releaseChecksProcess.on('close', code => { |
32 |
| - if (code !== 0) { |
33 |
| - reject(new FatalReleaseActionError()); |
34 |
| - } else { |
35 |
| - resolve(); |
36 |
| - } |
37 |
| - }); |
38 |
| - }); |
39 |
| -} |
40 |
| - |
41 |
| -// Patches the `@angular/dev-infra-private` release tool to perform sanity checks |
42 |
| -// before staging a release. This is temporary until the dev-infra team has implemented |
43 |
| -// a more generic solution to running sanity checks before releasing (potentially building |
44 |
| -// some of the checks we have in the components repository into the release tool). |
45 |
| -actionProto.stageVersionForBranchAndCreatePullRequest = async function (newVersion: SemVer) { |
46 |
| - await runStagingReleaseChecks(newVersion); |
47 |
| - |
48 |
| - return await _origStageFn.apply(this, arguments); |
49 |
| -}; |
50 |
| - |
51 |
| -// Patches the `@angular/dev-infra-private` release tool to perform sanity |
52 |
| -// checks of the NPM package output, before publishing to NPM. |
53 |
| -actionProto._verifyPackageVersions = async function ( |
54 |
| - newVersion: SemVer, |
55 |
| - builtPackages: BuiltPackage[], |
56 |
| -) { |
57 |
| - await assertValidNpmPackageOutput(builtPackages, newVersion); |
58 |
| - |
59 |
| - return await _origVerifyFn.apply(this, arguments); |
60 |
| -}; |
61 | 6 |
|
62 | 7 | /**
|
63 | 8 | * Packages that will be published as part of the project.
|
@@ -104,4 +49,11 @@ export const release: ReleaseConfig = {
|
104 | 49 | const {performNpmReleaseBuild} = await import('../scripts/build-packages-dist');
|
105 | 50 | return performNpmReleaseBuild();
|
106 | 51 | },
|
| 52 | + prereleaseCheck: async (newVersionStr, builtPackagesWithInfo) => { |
| 53 | + const newVersion = new SemVer(newVersionStr); |
| 54 | + |
| 55 | + await assertValidFrameworkPeerDependency(newVersion); |
| 56 | + await assertValidUpdateMigrationCollections(newVersion); |
| 57 | + await assertValidNpmPackageOutput(builtPackagesWithInfo, newVersion); |
| 58 | + }, |
107 | 59 | };
|
0 commit comments