Skip to content

Commit 9d6dcf3

Browse files
committed
feat: dvc status return user email and Id
1 parent 524c4ed commit 9d6dcf3

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

src/commands/base.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export default abstract class Base extends Command {
6565
'bitbucket.pr_insights',
6666
'bitbucket.code_usages',
6767
'cli',
68-
'vs_code_extension'
68+
'vscode_extension'
6969
],
7070
hidden: true
7171
}),

src/commands/status/index.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
import 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+
315
export 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

Comments
 (0)