@@ -12,24 +12,21 @@ import { createRequire } from 'node:module';
1212import { SemVer , satisfies } from 'semver' ;
1313
1414export 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 {
2724 console . error ( 'You seem to not be depending on "@angular/core". This is an error.' ) ;
2825
2926 process . exit ( 2 ) ;
3027 }
3128
32- if ( ! ( angularPkgJson && angularPkgJson [ 'version' ] ) ) {
29+ if ( ! angularPkgJson ?. [ 'version' ] ) {
3330 console . error (
3431 'Cannot determine versions of "@angular/core".\n' +
3532 'This likely means your local installation is broken. Please reinstall your packages.' ,
@@ -38,30 +35,12 @@ export function assertCompatibleAngularVersion(projectRoot: string): void | neve
3835 process . exit ( 2 ) ;
3936 }
4037
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-
5938 const supportedAngularSemver = '0.0.0-ANGULAR-FW-PEER-DEP' ;
6039 const angularVersion = new SemVer ( angularPkgJson [ 'version' ] ) ;
6140
6241 if ( ! satisfies ( angularVersion , supportedAngularSemver , { includePrerelease : true } ) ) {
6342 console . error (
64- `This version of CLI is only compatible with Angular versions ${ supportedAngularSemver } ,\n` +
43+ `This version of @angular/build is only compatible with Angular versions ${ supportedAngularSemver } ,\n` +
6544 `but Angular version ${ angularVersion } was found instead.\n` +
6645 'Please visit the link below to find instructions on how to update Angular.\nhttps://update.angular.dev/' ,
6746 ) ;
0 commit comments