Skip to content

Commit f3cbb02

Browse files
renovate[bot]renovate-botdevversion
committed
build: update angular shared dev-infra code to 932b9d5 (#25000)
* build: update angular shared dev-infra package Updates the shared dev-infra package. * build: use new release prechecks for validating release before publish Uses the new release precheck feature for validating release output and other inputs. Co-authored-by: Renovate Bot <[email protected]> Co-authored-by: Paul Gschwendtner <[email protected]> (cherry picked from commit 2740e98)
1 parent a930c59 commit f3cbb02

File tree

6 files changed

+344
-267
lines changed

6 files changed

+344
-267
lines changed

.ng-dev/release.ts

Lines changed: 10 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,8 @@
1-
import {
2-
BuiltPackage,
3-
ReleaseConfig,
4-
ReleaseAction as _ReleaseAction,
5-
FatalReleaseActionError,
6-
} from '@angular/dev-infra-private/ng-dev';
71
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';
85
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-
};
616

627
/**
638
* Packages that will be published as part of the project.
@@ -104,4 +49,11 @@ export const release: ReleaseConfig = {
10449
const {performNpmReleaseBuild} = await import('../scripts/build-packages-dist');
10550
return performNpmReleaseBuild();
10651
},
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+
},
10759
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
"@angular/bazel": "14.0.0-next.9",
7676
"@angular/cli": "13.3.0",
7777
"@angular/compiler-cli": "13.3.0",
78-
"@angular/dev-infra-private": "https://github.com/angular/dev-infra-private-builds.git#04424ec1cd38a1d12786ffdaa8005645e6640687",
78+
"@angular/dev-infra-private": "https://github.com/angular/dev-infra-private-builds.git#932b9d5f6227d1a2dfa2a416fa317c2e55584994",
7979
"@angular/localize": "13.3.0",
8080
"@angular/platform-browser-dynamic": "13.3.0",
8181
"@angular/platform-server": "13.3.0",

tools/release-checks/check-framework-peer-dependency.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {error, FatalReleaseActionError} from '@angular/dev-infra-private/ng-dev';
1+
import {error, ReleasePrecheckError} from '@angular/dev-infra-private/ng-dev';
22
import {SemVer} from 'semver';
33
import {join} from 'path';
44
import {existsSync, readFileSync} from 'fs';
@@ -29,7 +29,7 @@ export async function assertValidFrameworkPeerDependency(newVersion: SemVer) {
2929
),
3030
);
3131
error(chalk.red(` Please manually update the version range ` + `in: ${bzlConfigPath}`));
32-
throw new FatalReleaseActionError();
32+
throw new ReleasePrecheckError();
3333
}
3434
}
3535

@@ -45,7 +45,7 @@ function _extractAngularVersionPlaceholderOrThrow(): string {
4545
`the Angular peerDependency placeholder value. Looked for: ${bzlConfigPath}`,
4646
),
4747
);
48-
throw new FatalReleaseActionError();
48+
throw new ReleasePrecheckError();
4949
}
5050

5151
const configFileContent = readFileSync(bzlConfigPath, 'utf8');
@@ -58,7 +58,7 @@ function _extractAngularVersionPlaceholderOrThrow(): string {
5858
`Looked in: ${bzlConfigPath}`,
5959
),
6060
);
61-
throw new FatalReleaseActionError();
61+
throw new ReleasePrecheckError();
6262
}
6363
return matches[1];
6464
}

tools/release-checks/check-migration-collections.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import {error} from '@angular/dev-infra-private/ng-dev';
1+
import {error, ReleasePrecheckError} from '@angular/dev-infra-private/ng-dev';
2+
import {readFileSync} from 'fs';
23
import {dirname, join} from 'path';
3-
import chalk from 'chalk';
44
import {releasePackages} from '../../.ng-dev/release';
5-
import {readFileSync} from 'fs';
5+
import chalk from 'chalk';
66
import semver from 'semver';
77

88
/** Path to the directory containing all package sources. */
@@ -21,7 +21,7 @@ export async function assertValidUpdateMigrationCollections(newVersion: semver.S
2121
if (failures.length) {
2222
error(chalk.red(` ✘ Failures in ng-update migration collection detected:`));
2323
failures.forEach(f => error(f));
24-
process.exit(1);
24+
throw new ReleasePrecheckError();
2525
}
2626
}
2727

tools/release-checks/npm-package-output/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {SemVer} from 'semver';
22
import {checkReleasePackage} from './check-package';
3-
import {BuiltPackage, error} from '@angular/dev-infra-private/ng-dev';
3+
import {BuiltPackage, error, ReleasePrecheckError} from '@angular/dev-infra-private/ng-dev';
44
import chalk from 'chalk';
55

66
/** Asserts that the given built packages are valid for public consumption. */
@@ -16,6 +16,6 @@ export async function assertValidNpmPackageOutput(
1616

1717
if (!passing) {
1818
error(chalk.red(` ✘ NPM package output does not pass all release validations.`));
19-
process.exit(1);
19+
throw new ReleasePrecheckError();
2020
}
2121
}

0 commit comments

Comments
 (0)