bdy 1.17.21-dev → 1.17.22-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
|
@@ -33,37 +33,6 @@ const OAUTH_CLIENT_APP_SCOPES = [
|
|
|
33
33
|
'TUNNEL_MANAGE',
|
|
34
34
|
'UNIT_TEST_MANAGE',
|
|
35
35
|
];
|
|
36
|
-
function normalizeBaseUrl(url) {
|
|
37
|
-
let normalized = url.trim();
|
|
38
|
-
normalized = normalized.replace(/^https?:\/\//i, '');
|
|
39
|
-
normalized = normalized.replace(/\/+$/, '');
|
|
40
|
-
return normalized;
|
|
41
|
-
}
|
|
42
|
-
async function selectRegion() {
|
|
43
|
-
output_1.default.normal(texts_1.TXT_LOGIN_SELECT_REGION);
|
|
44
|
-
const index = await output_1.default.inputMenu([
|
|
45
|
-
'US (default)',
|
|
46
|
-
'EU',
|
|
47
|
-
'Asia',
|
|
48
|
-
'On-premises',
|
|
49
|
-
]);
|
|
50
|
-
if (index === 0)
|
|
51
|
-
return utils_1.REST_API_REGION.US;
|
|
52
|
-
if (index === 1)
|
|
53
|
-
return utils_1.REST_API_REGION.EU;
|
|
54
|
-
if (index === 2)
|
|
55
|
-
return utils_1.REST_API_REGION.AS;
|
|
56
|
-
return utils_1.REST_API_REGION.ONPREM;
|
|
57
|
-
}
|
|
58
|
-
async function restApiBaseUrl() {
|
|
59
|
-
output_1.default.normal(texts_1.TXT_LOGIN_ENTER_BASE_URL);
|
|
60
|
-
const str = await output_1.default.inputString();
|
|
61
|
-
const normalized = normalizeBaseUrl(str);
|
|
62
|
-
if (!normalized) {
|
|
63
|
-
output_1.default.exitError(texts_1.ERR_LOGIN_INVALID_BASE_URL);
|
|
64
|
-
}
|
|
65
|
-
return `${normalized}/api`;
|
|
66
|
-
}
|
|
67
36
|
async function oauthServer(api, clientId, clientSecret) {
|
|
68
37
|
return new Promise((resolve, reject) => {
|
|
69
38
|
const s = node_http_1.default.createServer(async (req, res) => {
|
|
@@ -182,11 +151,11 @@ commandLogin.action(async (options) => {
|
|
|
182
151
|
region = input_1.default.restApiRegion(region);
|
|
183
152
|
}
|
|
184
153
|
else {
|
|
185
|
-
region = await selectRegion();
|
|
154
|
+
region = await output_1.default.selectRegion();
|
|
186
155
|
}
|
|
187
156
|
if (!api) {
|
|
188
157
|
if (region === utils_1.REST_API_REGION.ONPREM) {
|
|
189
|
-
api = await
|
|
158
|
+
api = await output_1.default.inputApiBaseUrl();
|
|
190
159
|
}
|
|
191
160
|
else if (region === utils_1.REST_API_REGION.AS) {
|
|
192
161
|
api = utils_1.REST_API_ENDPOINT.AS;
|
|
@@ -8,8 +8,11 @@ const texts_1 = require("../../../texts");
|
|
|
8
8
|
const output_1 = __importDefault(require("../../../output"));
|
|
9
9
|
const input_1 = __importDefault(require("../../../input"));
|
|
10
10
|
const commandPackageDockerLogin = (0, utils_1.newCommand)('login', texts_1.DESC_COMMAND_PACKAGE_DOCKER_LOGIN);
|
|
11
|
-
commandPackageDockerLogin.
|
|
12
|
-
|
|
11
|
+
commandPackageDockerLogin.option('--token <token>', texts_1.OPTION_REST_API_TOKEN);
|
|
12
|
+
commandPackageDockerLogin.option('--api <url>', texts_1.OPTION_REST_API_ENDPOINT);
|
|
13
|
+
commandPackageDockerLogin.option('--region <region>', texts_1.OPTION_REST_API_REGION);
|
|
14
|
+
commandPackageDockerLogin.action(async (options) => {
|
|
15
|
+
const client = input_1.default.restApiTokenClient(false, options.api, options.region, options.token);
|
|
13
16
|
await client.getInvoker();
|
|
14
17
|
const host = (0, utils_1.getDockerRegistryHostByApiBaseUrl)(client.baseUrl);
|
|
15
18
|
const output = await (0, utils_1.execLocally)(`docker login ${host} -u buddy -p "${client.token}"`);
|
package/distTs/src/input.js
CHANGED
|
@@ -302,8 +302,8 @@ class Input {
|
|
|
302
302
|
}
|
|
303
303
|
return type;
|
|
304
304
|
}
|
|
305
|
-
static restApiToken(allowNoToken = false) {
|
|
306
|
-
let t = process.env.BUDDY_TOKEN;
|
|
305
|
+
static restApiToken(allowNoToken = false, token = '') {
|
|
306
|
+
let t = token || process.env.BUDDY_TOKEN;
|
|
307
307
|
let rf = '';
|
|
308
308
|
let cid = '';
|
|
309
309
|
let cs = '';
|
|
@@ -326,9 +326,9 @@ class Input {
|
|
|
326
326
|
clientToken: ct,
|
|
327
327
|
};
|
|
328
328
|
}
|
|
329
|
-
static restApiTokenClient(allowNoToken = false) {
|
|
330
|
-
const baseUrl = this.restApiBaseUrl();
|
|
331
|
-
const { token: t, refreshToken, clientId, clientToken, clientSecret, } = this.restApiToken(allowNoToken);
|
|
329
|
+
static restApiTokenClient(allowNoToken = false, api = '', region = '', token = '') {
|
|
330
|
+
const baseUrl = this.restApiBaseUrl(api, region);
|
|
331
|
+
const { token: t, refreshToken, clientId, clientToken, clientSecret, } = this.restApiToken(allowNoToken, token);
|
|
332
332
|
return new client_1.default(baseUrl, t, refreshToken, clientId, clientSecret, clientToken);
|
|
333
333
|
}
|
|
334
334
|
static packageType(type) {
|
|
@@ -424,12 +424,12 @@ class Input {
|
|
|
424
424
|
output_1.default.exitError(texts_1.ERR_REST_API_REGION);
|
|
425
425
|
}
|
|
426
426
|
}
|
|
427
|
-
static restApiBaseUrl() {
|
|
428
|
-
let u = process.env.BUDDY_API_ENDPOINT;
|
|
427
|
+
static restApiBaseUrl(api = '', region = '') {
|
|
428
|
+
let u = api || process.env.BUDDY_API_ENDPOINT;
|
|
429
429
|
if (!u)
|
|
430
430
|
u = cfg_1.default.getBaseUrl();
|
|
431
431
|
if (!u) {
|
|
432
|
-
const r = process.env.BUDDY_REGION;
|
|
432
|
+
const r = region || process.env.BUDDY_REGION;
|
|
433
433
|
if (r?.toLowerCase() === utils_1.REST_API_REGION.EU) {
|
|
434
434
|
u = utils_1.REST_API_ENDPOINT.EU;
|
|
435
435
|
}
|
package/distTs/src/output.js
CHANGED
|
@@ -12,6 +12,7 @@ const tunnels_1 = __importDefault(require("./tunnel/output/noninteractive/config
|
|
|
12
12
|
const texts_1 = require("./texts");
|
|
13
13
|
const tunnels_2 = __importDefault(require("./tunnel/output/noninteractive/agent/tunnels"));
|
|
14
14
|
const context_1 = require("./visualTest/context");
|
|
15
|
+
const utils_1 = require("./utils");
|
|
15
16
|
const terminal = termkit_no_lazy_require_1.default.terminal;
|
|
16
17
|
class Output {
|
|
17
18
|
static s;
|
|
@@ -257,6 +258,32 @@ class Output {
|
|
|
257
258
|
index += 1;
|
|
258
259
|
return projects[index - 1].name;
|
|
259
260
|
}
|
|
261
|
+
static async inputApiBaseUrl() {
|
|
262
|
+
Output.normal(texts_1.TXT_LOGIN_ENTER_BASE_URL);
|
|
263
|
+
const str = await Output.inputString();
|
|
264
|
+
let normalized = str.trim().replace(/^https?:\/\//i, '');
|
|
265
|
+
normalized = normalized.replace(/\/+$/, '');
|
|
266
|
+
if (!normalized) {
|
|
267
|
+
Output.exitError(texts_1.ERR_LOGIN_INVALID_BASE_URL);
|
|
268
|
+
}
|
|
269
|
+
return `${normalized}/api`;
|
|
270
|
+
}
|
|
271
|
+
static async selectRegion() {
|
|
272
|
+
Output.normal(texts_1.TXT_LOGIN_SELECT_REGION);
|
|
273
|
+
const index = await Output.inputMenu([
|
|
274
|
+
'US (default)',
|
|
275
|
+
'EU',
|
|
276
|
+
'Asia',
|
|
277
|
+
'On-premises',
|
|
278
|
+
]);
|
|
279
|
+
if (index === 0)
|
|
280
|
+
return utils_1.REST_API_REGION.US;
|
|
281
|
+
if (index === 1)
|
|
282
|
+
return utils_1.REST_API_REGION.EU;
|
|
283
|
+
if (index === 2)
|
|
284
|
+
return utils_1.REST_API_REGION.AS;
|
|
285
|
+
return utils_1.REST_API_REGION.ONPREM;
|
|
286
|
+
}
|
|
260
287
|
static exitError(err) {
|
|
261
288
|
this.killSpinner();
|
|
262
289
|
terminal.fullscreen(false);
|