Skip to content

Commit d53b586

Browse files
committed
refactor(@angular/build): remove outdated version checks
Cleaned up legacy version-checking logic.
1 parent 0ddf6aa commit d53b586

File tree

1 file changed

+9
-28
lines changed

1 file changed

+9
-28
lines changed

packages/angular/build/src/utils/version.ts

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -12,57 +12,38 @@ import { createRequire } from 'node:module';
1212
import { SemVer, satisfies } from 'semver';
1313

1414
export function assertCompatibleAngularVersion(projectRoot: string): void | never {
15-
let angularCliPkgJson;
1615
let angularPkgJson;
1716

1817
// Create a custom require function for ESM compliance.
1918
// NOTE: The trailing slash is significant.
2019
const projectRequire = createRequire(projectRoot + '/');
2120

2221
try {
23-
const angularPackagePath = projectRequire.resolve('@angular/core/package.json');
24-
25-
angularPkgJson = projectRequire(angularPackagePath);
22+
angularPkgJson = projectRequire('@angular/core/package.json');
2623
} catch {
27-
console.error('You seem to not be depending on "@angular/core". This is an error.');
24+
console.error(
25+
'Error: It appears that "@angular/core" is missing as a dependency. Please ensure it is included in your project.',
26+
);
2827

2928
process.exit(2);
3029
}
3130

32-
if (!(angularPkgJson && angularPkgJson['version'])) {
31+
if (!angularPkgJson?.['version']) {
3332
console.error(
34-
'Cannot determine versions of "@angular/core".\n' +
35-
'This likely means your local installation is broken. Please reinstall your packages.',
33+
'Error: Unable to determine the versions of "@angular/core".\n' +
34+
'This likely indicates a corrupted local installation. Please try reinstalling your packages.',
3635
);
3736

3837
process.exit(2);
3938
}
4039

41-
try {
42-
const angularCliPkgPath = projectRequire.resolve('@angular/cli/package.json');
43-
angularCliPkgJson = projectRequire(angularCliPkgPath);
44-
if (!(angularCliPkgJson && angularCliPkgJson['version'])) {
45-
return;
46-
}
47-
} catch {
48-
// Not using @angular-devkit/build-angular with @angular/cli is ok too.
49-
// In this case we don't provide as many version checks.
50-
return;
51-
}
52-
53-
if (angularCliPkgJson['version'] === '0.0.0' || angularPkgJson['version'] === '0.0.0') {
54-
// Internal CLI testing version or integration testing in the angular/angular
55-
// repository with the generated development @angular/core npm package which is versioned "0.0.0".
56-
return;
57-
}
58-
5940
const supportedAngularSemver = '0.0.0-ANGULAR-FW-PEER-DEP';
6041
const angularVersion = new SemVer(angularPkgJson['version']);
6142

6243
if (!satisfies(angularVersion, supportedAngularSemver, { includePrerelease: true })) {
6344
console.error(
64-
`This version of CLI is only compatible with Angular versions ${supportedAngularSemver},\n` +
65-
`but Angular version ${angularVersion} was found instead.\n` +
45+
`Error: The current version of "@angular/build" supports Angular versions ${supportedAngularSemver},\n` +
46+
`but detected Angular version ${angularVersion} instead.\n` +
6647
'Please visit the link below to find instructions on how to update Angular.\nhttps://update.angular.dev/',
6748
);
6849

0 commit comments

Comments
 (0)