77 */
88
99import { createRequire } from 'node:module' ;
10- import { resolve } from 'node:path ' ;
10+ import { VERSION } from '../../utilities/version ' ;
1111
1212/**
1313 * A subset of `package.json` fields that are relevant for the version command.
@@ -65,11 +65,9 @@ export function gatherVersionInfo(context: {
6565 packageManager : { name : string ; version : string | undefined } ;
6666 root : string ;
6767} ) : VersionInfo {
68- const localRequire = createRequire ( resolve ( __filename , '../../../' ) ) ;
6968 // Trailing slash is used to allow the path to be treated as a directory
7069 const workspaceRequire = createRequire ( context . root + '/' ) ;
7170
72- const cliPackage : PartialPackageInfo = localRequire ( './package.json' ) ;
7371 let workspacePackage : PartialPackageInfo | undefined ;
7472 try {
7573 workspacePackage = workspaceRequire ( './package.json' ) ;
@@ -80,8 +78,6 @@ export function gatherVersionInfo(context: {
8078
8179 const packageNames = new Set (
8280 Object . keys ( {
83- ...cliPackage . dependencies ,
84- ...cliPackage . devDependencies ,
8581 ...workspacePackage ?. dependencies ,
8682 ...workspacePackage ?. devDependencies ,
8783 } ) ,
@@ -90,11 +86,11 @@ export function gatherVersionInfo(context: {
9086 const versions : Record < string , string > = { } ;
9187 for ( const name of packageNames ) {
9288 if ( PACKAGE_PATTERNS . some ( ( p ) => p . test ( name ) ) ) {
93- versions [ name ] = getVersion ( name , workspaceRequire , localRequire ) ;
89+ versions [ name ] = getVersion ( name , workspaceRequire ) ;
9490 }
9591 }
9692
97- const ngCliVersion = cliPackage . version ;
93+ const ngCliVersion = VERSION . full ;
9894 let angularCoreVersion = '' ;
9995 const angularSameAsCore : string [ ] = [ ] ;
10096
@@ -135,32 +131,17 @@ export function gatherVersionInfo(context: {
135131 * @param localRequire A `require` function for the CLI.
136132 * @returns The version of the package, or `<error>` if it could not be found.
137133 */
138- function getVersion (
139- moduleName : string ,
140- workspaceRequire : NodeJS . Require ,
141- localRequire : NodeJS . Require ,
142- ) : string {
134+ function getVersion ( moduleName : string , workspaceRequire : NodeJS . Require ) : string {
143135 let packageInfo : PartialPackageInfo | undefined ;
144- let cliOnly = false ;
145136
146137 // Try to find the package in the workspace
147138 try {
148139 packageInfo = workspaceRequire ( `${ moduleName } /package.json` ) ;
149140 } catch { }
150141
151- // If not found, try to find within the CLI
152- if ( ! packageInfo ) {
153- try {
154- packageInfo = localRequire ( `${ moduleName } /package.json` ) ;
155- cliOnly = true ;
156- } catch { }
157- }
158-
159142 // If found, attempt to get the version
160143 if ( packageInfo ) {
161- try {
162- return packageInfo . version + ( cliOnly ? ' (cli-only)' : '' ) ;
163- } catch { }
144+ return packageInfo . version ;
164145 }
165146
166147 return '<error>' ;
0 commit comments