bdy 1.19.3-dev-pipeline → 1.19.5-dev-pipeline

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bdy",
3
3
  "preferGlobal": false,
4
- "version": "1.19.3-dev-pipeline",
4
+ "version": "1.19.5-dev-pipeline",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",
7
7
  "scripts": {
@@ -334,8 +334,8 @@ class Input {
334
334
  }
335
335
  static restApiTokenClient(allowNoToken = false, api = '', region = '', token = '') {
336
336
  const ApiClient = require('./api/client').default;
337
- const baseUrl = this.restApiBaseUrl(api, region);
338
337
  const { token: t, refreshToken, clientId, clientToken, clientSecret, } = this.restApiToken(allowNoToken, token);
338
+ const baseUrl = this.restApiBaseUrl(api, region, t);
339
339
  return new ApiClient(baseUrl, t, refreshToken, clientId, clientSecret, clientToken);
340
340
  }
341
341
  static artifactType(type) {
@@ -442,8 +442,26 @@ class Input {
442
442
  output_1.default.exitError(texts_1.ERR_REST_API_REGION);
443
443
  }
444
444
  }
445
- static restApiBaseUrl(api = '', region = '') {
446
- let u = api || process.env.BUDDY_API_ENDPOINT;
445
+ static restApiBaseUrlFromToken(token) {
446
+ // bdy_sb_us_aHR0cHM6Ly9hcGkuc2Q1LmNvbQ_f92ml8f1p27nzo45806vczm6c78d0
447
+ const s = (token || '').split('_');
448
+ if (s.length > 1) {
449
+ const base = s[s.length - 2];
450
+ try {
451
+ return Buffer.from(base, 'base64').toString('utf8');
452
+ }
453
+ catch {
454
+ // do nothing
455
+ }
456
+ }
457
+ return null;
458
+ }
459
+ static restApiBaseUrl(api = '', region = '', token = '') {
460
+ let u = api;
461
+ if (!u)
462
+ u = this.restApiBaseUrlFromToken(token);
463
+ if (!u)
464
+ u = process.env.BUDDY_API_ENDPOINT || null;
447
465
  if (!u)
448
466
  u = cfg_1.default.getBaseUrl();
449
467
  if (!u) {
@@ -1069,6 +1069,14 @@ class OutputPipeline {
1069
1069
  draw();
1070
1070
  }, true);
1071
1071
  }
1072
+ static _exitByStatus(status) {
1073
+ if (status && [pipeline_1.PIPELINE_RUN_STATUS.FAILED, pipeline_1.PIPELINE_RUN_STATUS.TERMINATED].includes(status)) {
1074
+ process.exit(1);
1075
+ }
1076
+ else {
1077
+ process.exit(0);
1078
+ }
1079
+ }
1072
1080
  static async _runLogsNonInteractive(client, workspace, project, pipelineId, runId, runActionId, noWait) {
1073
1081
  let action = null;
1074
1082
  let actionLogsStart = 0;
@@ -1157,7 +1165,7 @@ class OutputPipeline {
1157
1165
  output_1.default.normal(finished);
1158
1166
  }
1159
1167
  }
1160
- output_1.default.exitNormal();
1168
+ this._exitByStatus(action?.status);
1161
1169
  }
1162
1170
  };
1163
1171
  this._actionLogsLoop(client, workspace, project, pipelineId, runId, runActionId, draw)
@@ -1210,7 +1218,7 @@ class OutputPipeline {
1210
1218
  totalFetchesCount += 1;
1211
1219
  draw(run);
1212
1220
  if (noWait) {
1213
- output_1.default.exitNormal();
1221
+ this._exitByStatus(run.status);
1214
1222
  }
1215
1223
  });
1216
1224
  if (totalFetchesCount > 1) {
@@ -1224,7 +1232,7 @@ class OutputPipeline {
1224
1232
  if (finished)
1225
1233
  output_1.default.normal(finished);
1226
1234
  }
1227
- output_1.default.exitNormal();
1235
+ this._exitByStatus(run.status);
1228
1236
  }
1229
1237
  static async _actionLogsLoop(client, workspace, project, pipelineId, runId, actionExecutionId, onChange) {
1230
1238
  let logs = [];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bdy",
3
3
  "preferGlobal": false,
4
- "version": "1.19.3-dev-pipeline",
4
+ "version": "1.19.5-dev-pipeline",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",
7
7
  "scripts": {