5
5
* Use of this source code is governed by an MIT-style license that can be
6
6
* found in the LICENSE file at https://angular.io/license
7
7
*/
8
+ import { JsonParseMode , isJsonObject , parseJson } from '@angular-devkit/core' ;
8
9
import * as child_process from 'child_process' ;
9
10
import * as fs from 'fs' ;
10
11
import * as path from 'path' ;
@@ -21,7 +22,7 @@ export class VersionCommand extends Command<VersionCommandSchema> {
21
22
let projPkg ;
22
23
try {
23
24
projPkg = require ( path . resolve ( this . workspace . root , 'package.json' ) ) ;
24
- } catch ( exception ) {
25
+ } catch {
25
26
projPkg = undefined ;
26
27
}
27
28
@@ -137,6 +138,7 @@ export class VersionCommand extends Command<VersionCommandSchema> {
137
138
Angular CLI: ${ ngCliVersion }
138
139
Node: ${ process . versions . node }
139
140
OS: ${ process . platform } ${ process . arch }
141
+
140
142
Angular: ${ angularCoreVersion }
141
143
... ${ angularSameAsCore
142
144
. reduce < string [ ] > ( ( acc , name ) => {
@@ -154,6 +156,7 @@ export class VersionCommand extends Command<VersionCommandSchema> {
154
156
return acc ;
155
157
} , [ ] )
156
158
. join ( '\n... ' ) }
159
+ Ivy Workspace: ${ projPkg ? this . getIvyWorkspace ( ) : '' }
157
160
158
161
Package${ namePad . slice ( 7 ) } Version
159
162
-------${ namePad . replace ( / / g, '-' ) } ------------------
@@ -176,7 +179,7 @@ export class VersionCommand extends Command<VersionCommandSchema> {
176
179
177
180
return modulePkg . version ;
178
181
}
179
- } catch ( _ ) { }
182
+ } catch { }
180
183
181
184
try {
182
185
if ( cliNodeModules ) {
@@ -188,4 +191,22 @@ export class VersionCommand extends Command<VersionCommandSchema> {
188
191
189
192
return '<error>' ;
190
193
}
194
+
195
+ private getIvyWorkspace ( ) : string {
196
+ try {
197
+ const content = fs . readFileSync ( path . resolve ( this . workspace . root , 'tsconfig.json' ) , 'utf-8' ) ;
198
+ const tsConfig = parseJson ( content , JsonParseMode . Loose ) ;
199
+ if ( ! isJsonObject ( tsConfig ) ) {
200
+ return '<error>' ;
201
+ }
202
+
203
+ const { angularCompilerOptions } = tsConfig ;
204
+
205
+ return isJsonObject ( angularCompilerOptions ) && angularCompilerOptions . enableIvy === false
206
+ ? 'No'
207
+ : 'Yes' ;
208
+ } catch {
209
+ return '<error>' ;
210
+ }
211
+ }
191
212
}
0 commit comments