@@ -10,7 +10,7 @@ import type { Argv } from 'yargs';
1010import  {  CommandModule ,  CommandModuleImplementation  }  from  '../../command-builder/command-module' ; 
1111import  {  colors  }  from  '../../utilities/color' ; 
1212import  {  RootCommands  }  from  '../command-config' ; 
13- import  {  gatherVersionInfo  }  from  './version-info' ; 
13+ import  {  PackageVersionInfo ,   gatherVersionInfo  }  from  './version-info' ; 
1414
1515/** 
1616 * The Angular CLI logo, displayed as ASCII art. 
@@ -67,6 +67,7 @@ export default class VersionCommandModule
6767
6868    const  { 
6969      cli : {  version : ngCliVersion  } , 
70+       framework, 
7071      system : { 
7172        node : {  version : nodeVersion ,  unsupported : unsupportedNodeVersion  } , 
7273        os : {  platform : os ,  architecture : arch  } , 
@@ -75,8 +76,13 @@ export default class VersionCommandModule
7576      packages, 
7677    }  =  versionInfo ; 
7778
78-     const  headerInfo  =  [ 
79-       {  label : 'Angular CLI' ,  value : ngCliVersion  } , 
79+     const  headerInfo  =  [ {  label : 'Angular CLI' ,  value : ngCliVersion  } ] ; 
80+ 
81+     if  ( framework . version )  { 
82+       headerInfo . push ( {  label : 'Angular' ,  value : framework . version  } ) ; 
83+     } 
84+ 
85+     headerInfo . push ( 
8086      { 
8187        label : 'Node.js' , 
8288        value : `${ nodeVersion } ${ unsupportedNodeVersion  ? colors . yellow ( ' (Unsupported)' )  : '' }  ` , 
@@ -86,7 +92,7 @@ export default class VersionCommandModule
8692        value : `${ packageManagerName }   ${ packageManagerVersion  ??  '<error>' }  ` , 
8793      } , 
8894      {  label : 'Operating System' ,  value : `${ os }   ${ arch }  `  } , 
89-     ] ; 
95+     ) ; 
9096
9197    const  maxHeaderLabelLength  =  Math . max ( ...headerInfo . map ( ( l )  =>  l . label . length ) ) ; 
9298
@@ -113,38 +119,56 @@ export default class VersionCommandModule
113119   * @param  versions A map of package names to their versions. 
114120   * @returns  A string containing the formatted package table. 
115121   */ 
116-   private  formatPackageTable ( versions : Record < string ,  string > ) : string  { 
122+   private  formatPackageTable ( versions : Record < string ,  PackageVersionInfo > ) : string  { 
117123    const  versionKeys  =  Object . keys ( versions ) ; 
118124    if  ( versionKeys . length  ===  0 )  { 
119125      return  '' ; 
120126    } 
121127
122-     const  nameHeader  =  'Package' ; 
123-     const  versionHeader  =  'Version' ; 
128+     const  headers  =  { 
129+       name : 'Package' , 
130+       installed : 'Installed Version' , 
131+       requested : 'Requested Version' , 
132+     } ; 
124133
125-     const  maxNameLength  =  Math . max ( nameHeader . length ,  ...versionKeys . map ( ( key )  =>  key . length ) ) ; 
126-     const  maxVersionLength  =  Math . max ( 
127-       versionHeader . length , 
128-       ...versionKeys . map ( ( key )  =>  versions [ key ] . length ) , 
134+     const  maxNameLength  =  Math . max ( headers . name . length ,  ...versionKeys . map ( ( key )  =>  key . length ) ) ; 
135+     const  maxInstalledLength  =  Math . max ( 
136+       headers . installed . length , 
137+       ...versionKeys . map ( ( key )  =>  versions [ key ] . installed . length ) , 
138+     ) ; 
139+     const  maxRequestedLength  =  Math . max ( 
140+       headers . requested . length , 
141+       ...versionKeys . map ( ( key )  =>  versions [ key ] . requested . length ) , 
129142    ) ; 
130143
131144    const  tableRows  =  versionKeys 
132145      . map ( ( module )  =>  { 
146+         const  {  requested,  installed }  =  versions [ module ] ; 
133147        const  name  =  module . padEnd ( maxNameLength ) ; 
134-         const  version  =  versions [ module ] ; 
135-         const  coloredVersion  =  version  ===  '<error>'  ? colors . red ( version )  : colors . cyan ( version ) ; 
136-         const  padding  =  ' ' . repeat ( maxVersionLength  -  version . length ) ; 
137148
138-         return  `│ ${ name }   │ ${ coloredVersion } ${ padding }   │` ; 
149+         const  coloredInstalled  = 
150+           installed  ===  '<error>'  ? colors . red ( installed )  : colors . cyan ( installed ) ; 
151+         const  installedPadding  =  ' ' . repeat ( maxInstalledLength  -  installed . length ) ; 
152+ 
153+         return  `│ ${ name }   │ ${ coloredInstalled } ${ installedPadding }   │ ${ requested . padEnd (  
154+           maxRequestedLength ,  
155+         ) }   │`; 
139156      } ) 
140157      . sort ( ) ; 
141158
142-     const  top  =  `┌─${ '─' . repeat ( maxNameLength ) }  ─┬─${ '─' . repeat ( maxVersionLength ) }  ─┐` ; 
143-     const  header  =  `│ ${ nameHeader . padEnd ( maxNameLength ) }   │ ${ versionHeader . padEnd (  
144-       maxVersionLength ,  
145-     ) }   │`; 
146-     const  separator  =  `├─${ '─' . repeat ( maxNameLength ) }  ─┼─${ '─' . repeat ( maxVersionLength ) }  ─┤` ; 
147-     const  bottom  =  `└─${ '─' . repeat ( maxNameLength ) }  ─┴─${ '─' . repeat ( maxVersionLength ) }  ─┘` ; 
159+     const  top  =  `┌─${ '─' . repeat ( maxNameLength ) }  ─┬─${ '─' . repeat (  
160+       maxInstalledLength ,  
161+     ) }  ─┬─${ '─' . repeat ( maxRequestedLength ) }  ─┐`; 
162+     const  header  = 
163+       `│ ${ headers . name . padEnd ( maxNameLength ) }   │ `  + 
164+       `${ headers . installed . padEnd ( maxInstalledLength ) }   │ `  + 
165+       `${ headers . requested . padEnd ( maxRequestedLength ) }   │` ; 
166+     const  separator  =  `├─${ '─' . repeat ( maxNameLength ) }  ─┼─${ '─' . repeat (  
167+       maxInstalledLength ,  
168+     ) }  ─┼─${ '─' . repeat ( maxRequestedLength ) }  ─┤`; 
169+     const  bottom  =  `└─${ '─' . repeat ( maxNameLength ) }  ─┴─${ '─' . repeat (  
170+       maxInstalledLength ,  
171+     ) }  ─┴─${ '─' . repeat ( maxRequestedLength ) }  ─┘`; 
148172
149173    return  [ top ,  header ,  separator ,  ...tableRows ,  bottom ] . join ( '\n' ) ; 
150174  } 
0 commit comments