11import Base from '../base'
22
3+ type StatusInfo = {
4+ version : string ,
5+ repoConfigPath : string ,
6+ repoConfigExists : boolean ,
7+ userConfigPath : string ,
8+ userConfigExists : boolean ,
9+ authConfigPath : string ,
10+ hasAccessToken : boolean ,
11+ organization ?: string ,
12+ a0UserId ?: string
13+ }
14+
315export default class ShowStatus extends Base {
416 static hidden = false
517 static description = 'Print CLI version information, configuration file locations and auth status.'
@@ -47,7 +59,7 @@ export default class ShowStatus extends Base {
4759
4860 async runHeadless ( ) : Promise < void > {
4961 const loggedInOrg = this . repoConfig ?. org || this . userConfig ?. org
50- this . writer . showResults ( {
62+ const result : StatusInfo = {
5163 version : this . config . version ,
5264 repoConfigPath : this . repoConfigPath ,
5365 repoConfigExists : ! ! this . repoConfig ,
@@ -56,6 +68,11 @@ export default class ShowStatus extends Base {
5668 authConfigPath : this . authPath ,
5769 hasAccessToken : this . hasToken ( ) ,
5870 organization : loggedInOrg ?. name
59- } )
71+ }
72+ if ( this . hasToken ( ) ) {
73+ const tokenJson = JSON . parse ( Buffer . from ( this . authToken . split ( '.' ) [ 1 ] , 'base64' ) . toString ( ) )
74+ result . a0UserId = tokenJson [ 'sub' ]
75+ }
76+ this . writer . showResults ( result )
6077 }
61- }
78+ }
0 commit comments