bdy 1.16.18-dev → 1.16.19-dev
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/distTs/package.json
CHANGED
package/distTs/src/api/client.js
CHANGED
|
@@ -144,6 +144,9 @@ class ApiClient {
|
|
|
144
144
|
async getInvoker() {
|
|
145
145
|
return await this.request('GET', '/user', null, true);
|
|
146
146
|
}
|
|
147
|
+
async getInvokerEmails() {
|
|
148
|
+
return await this.request('GET', '/user/emails', null, true);
|
|
149
|
+
}
|
|
147
150
|
async postPipelineRun(workspace, project, pipelineId, body) {
|
|
148
151
|
return await this.request('POST', `/workspaces/${encodeURIComponent(workspace)}/projects/${encodeURIComponent(project)}/pipelines/${encodeURIComponent(pipelineId)}/executions`, body, true);
|
|
149
152
|
}
|
|
@@ -14,7 +14,7 @@ const input_1 = __importDefault(require("../input"));
|
|
|
14
14
|
const OAUTH_CLIENT_APP_PORT = 7596;
|
|
15
15
|
const OAUTH_CLIENT_APP_HOST = 'localhost';
|
|
16
16
|
const OAUTH_CLIENT_APP_REDIRECT_URL = `http://localhost:${OAUTH_CLIENT_APP_PORT}`;
|
|
17
|
-
const OAUTH_CLIENT_APP_SCOPES = 'WORKSPACE USER_INFO EXECUTION_MANAGE SANDBOX_MANAGE PACKAGE_MANAGE';
|
|
17
|
+
const OAUTH_CLIENT_APP_SCOPES = 'WORKSPACE USER_INFO USER_EMAIL EXECUTION_MANAGE SANDBOX_MANAGE PACKAGE_MANAGE';
|
|
18
18
|
function normalizeBaseUrl(url) {
|
|
19
19
|
let normalized = url.trim();
|
|
20
20
|
normalized = normalized.replace(/^https?:\/\//i, '');
|
|
@@ -9,6 +9,21 @@ const cfg_1 = __importDefault(require("../tunnel/cfg"));
|
|
|
9
9
|
const output_1 = __importDefault(require("../output"));
|
|
10
10
|
const input_1 = __importDefault(require("../input"));
|
|
11
11
|
const client_1 = __importDefault(require("../api/client"));
|
|
12
|
+
const tryGetEmail = async (client) => {
|
|
13
|
+
try {
|
|
14
|
+
const result = await client.getInvokerEmails();
|
|
15
|
+
if (result && result.emails) {
|
|
16
|
+
const e = result.emails.find((e) => e.confirmed);
|
|
17
|
+
if (e) {
|
|
18
|
+
return e.email;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
// do nothing
|
|
24
|
+
}
|
|
25
|
+
return null;
|
|
26
|
+
};
|
|
12
27
|
const commandWhoami = (0, utils_1.newCommand)('whoami', texts_1.DESC_COMMAND_WHOAMI);
|
|
13
28
|
commandWhoami.action(async () => {
|
|
14
29
|
const token = cfg_1.default.getApiToken();
|
|
@@ -23,7 +38,11 @@ commandWhoami.action(async () => {
|
|
|
23
38
|
if (!user) {
|
|
24
39
|
output_1.default.exitError(texts_1.ERR_WHOAMI_LOGOUT);
|
|
25
40
|
}
|
|
26
|
-
|
|
41
|
+
const email = await tryGetEmail(client);
|
|
42
|
+
output_1.default.normal(`User: ${user.name}`);
|
|
43
|
+
if (email) {
|
|
44
|
+
output_1.default.normal(`Email: ${email}`);
|
|
45
|
+
}
|
|
27
46
|
output_1.default.normal(`Workspace: ${!workspace ? texts_1.TXT_WHOAMI_NO_WORKSPACE : workspace}`);
|
|
28
47
|
output_1.default.normal(`Project: ${!project ? texts_1.TXT_WHOAMI_NO_PROJECT : project}`);
|
|
29
48
|
output_1.default.exitNormal();
|