Skip to content

Commit 4a20703

Browse files
committed
build: patch @angular/build to allow CI to build adev
See /angular/angular-cli/pull/32553
1 parent c7dc705 commit 4a20703

2 files changed

Lines changed: 54 additions & 1 deletion

File tree

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,9 @@
208208
"typescript": "6.0.0-beta"
209209
},
210210
"pnpm": {
211-
"patchedDependencies": {},
211+
"patchedDependencies": {
212+
"@angular/build": "patches/@angular__build.patch"
213+
},
212214
"packageExtensions": {
213215
"grpc-gcp": {
214216
"peerDependencies": {

patches/@angular__build.patch

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
diff --git a/src/utils/version.js b/src/utils/version.js
2+
index 4a2fe8ac8e57fc0c0d3c58000346887d5072f712..36763de8d510be182807c2035833c6a6eaa3cffa 100755
3+
--- a/src/utils/version.js
4+
+++ b/src/utils/version.js
5+
@@ -11,9 +11,6 @@ exports.assertCompatibleAngularVersion = assertCompatibleAngularVersion;
6+
/* eslint-disable no-console */
7+
const node_module_1 = require("node:module");
8+
const semver_1 = require("semver");
9+
-// Matches exactly '0.0.0' or any string ending in '.0.0-next.0'
10+
-// This allows FW to bump the package.json to a new major version without requiring a new CLI version.
11+
-const angularVersionRegex = /^0\.0\.0$|\.0\.0-next\.0$/;
12+
function assertCompatibleAngularVersion(projectRoot) {
13+
let angularPkgJson;
14+
// Create a custom require function for ESM compliance.
15+
@@ -31,16 +28,31 @@ function assertCompatibleAngularVersion(projectRoot) {
16+
'This likely indicates a corrupted local installation. Please try reinstalling your packages.');
17+
process.exit(2);
18+
}
19+
+ const angularCoreSemVer = new SemVer(angularPkgJson['version']);
20+
+ const { version, build, raw } = angularCoreSemVer;
21+
const supportedAngularSemver = '^21.0.0 || ^21.2.0-next.0';
22+
- if (angularVersionRegex.test(angularPkgJson['version']) ||
23+
- supportedAngularSemver.startsWith('0.0.0')) {
24+
+ if (version.startsWith('0.0.0') || supportedAngularSemver.startsWith('0.0.0')) {
25+
// Internal CLI and FW testing version.
26+
return;
27+
}
28+
- const angularVersion = new semver_1.SemVer(angularPkgJson['version']);
29+
- if (!(0, semver_1.satisfies)(angularVersion, supportedAngularSemver, { includePrerelease: true })) {
30+
+ if (build.length && version.endsWith('.0.0-next.0')) {
31+
+ // Special handle for local builds only when it's prerelease of major version and it's the 0th version.
32+
+ // This happends when we are bumping to a new major version. and the cli has not releated a verion.
33+
+
34+
+ // Example:
35+
+ // raw: '22.0.0-next.0+sha-c7dc705-with-local-changes',
36+
+ // major: 22,
37+
+ // minor: 0,
38+
+ // patch: 0,
39+
+ // prerelease: [ 'next', 0 ],
40+
+ // build: [ 'sha-c7dc705-with-local-changes' ],
41+
+ // version: '22.0.0-next.0'
42+
+
43+
+ return;
44+
+ }
45+
+ if (!(0, semver_1.satisfies)(angularCoreSemVer, supportedAngularSemver, { includePrerelease: true })) {
46+
console.error(`Error: The current version of "@angular/build" supports Angular versions ${supportedAngularSemver},\n` +
47+
- `but detected Angular version ${angularVersion} instead.\n` +
48+
+ `but detected Angular version ${raw} instead.\n` +
49+
'Please visit the link below to find instructions on how to update Angular.\nhttps://update.angular.dev/');
50+
process.exit(3);
51+
}

0 commit comments

Comments
 (0)