bdy 1.22.23-beta → 1.22.23-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.
Files changed (31) hide show
  1. package/distTs/package.json +1 -1
  2. package/distTs/src/api/client.js +110 -2
  3. package/distTs/src/command/pipeline/create.js +51 -0
  4. package/distTs/src/command/pipeline/delete.js +41 -0
  5. package/distTs/src/command/pipeline/get.js +51 -0
  6. package/distTs/src/command/pipeline/list.js +47 -0
  7. package/distTs/src/command/pipeline/run/apply.js +62 -0
  8. package/distTs/src/command/pipeline/run/approve.js +64 -0
  9. package/distTs/src/command/pipeline/run/cancel.js +38 -0
  10. package/distTs/src/command/pipeline/run/list.js +58 -0
  11. package/distTs/src/command/pipeline/run/logs.js +38 -0
  12. package/distTs/src/command/pipeline/run/retry.js +38 -0
  13. package/distTs/src/command/pipeline/run/start.js +98 -0
  14. package/distTs/src/command/pipeline/run/status.js +37 -0
  15. package/distTs/src/command/pipeline/run.js +22 -125
  16. package/distTs/src/command/pipeline/update.js +47 -0
  17. package/distTs/src/command/pipeline/yaml.js +38 -0
  18. package/distTs/src/command/pipeline.js +26 -0
  19. package/distTs/src/command/pre.js +1 -1
  20. package/distTs/src/command/project/link.js +11 -11
  21. package/distTs/src/input.js +11 -10
  22. package/distTs/src/output/pipeline.js +1677 -0
  23. package/distTs/src/output.js +156 -32
  24. package/distTs/src/texts.js +203 -169
  25. package/distTs/src/tunnel/output/interactive/tunnel.js +2 -2
  26. package/distTs/src/types/pipeline.js +424 -0
  27. package/package.json +1 -1
  28. package/distTs/src/command/project/get.js +0 -18
  29. package/distTs/src/command/project/set.js +0 -31
  30. package/distTs/src/command/sandbox/get/yaml.js +0 -30
  31. package/distTs/src/command/vt/scrape.js +0 -193
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bdy",
3
3
  "preferGlobal": false,
4
- "version": "1.22.23-beta",
4
+ "version": "1.22.23-dev-pipeline",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",
7
7
  "scripts": {
@@ -216,6 +216,79 @@ class ApiClient {
216
216
  throw new Error(texts_1.ERR_REST_API_GENERAL_ERROR);
217
217
  }
218
218
  }
219
+ async getPipelineRunActionLogs(workspace, project, pipelineId, executionId, actionExecutionId, offset, limit) {
220
+ const query = {
221
+ offset: String(offset),
222
+ limit: String(limit),
223
+ };
224
+ return await this.request({
225
+ method: 'GET',
226
+ path: `/workspaces/${encodeURIComponent(workspace)}/projects/${encodeURIComponent(project)}/pipelines/${encodeURIComponent(pipelineId)}/executions/${encodeURIComponent(executionId)}/action_executions/${encodeURIComponent(actionExecutionId)}/logs`,
227
+ query,
228
+ parseResponseBody: true,
229
+ });
230
+ }
231
+ async getPipelineRunActionExecution(workspace, project, pipelineId, executionId, actionExecutionId) {
232
+ return await this.request({
233
+ method: 'GET',
234
+ path: `/workspaces/${encodeURIComponent(workspace)}/projects/${encodeURIComponent(project)}/pipelines/${encodeURIComponent(pipelineId)}/executions/${encodeURIComponent(executionId)}/action_executions/${encodeURIComponent(actionExecutionId)}`,
235
+ parseResponseBody: true,
236
+ });
237
+ }
238
+ async updatePipelineYml(workspace, project, pipelineId, body) {
239
+ return await this.request({
240
+ method: 'PATCH',
241
+ path: `/workspaces/${encodeURIComponent(workspace)}/projects/${encodeURIComponent(project)}/pipelines/${encodeURIComponent(pipelineId)}/yaml`,
242
+ body,
243
+ parseResponseBody: true
244
+ });
245
+ }
246
+ async createPipeline(workspace, project, body) {
247
+ return await this.request({
248
+ method: 'POST',
249
+ path: `/workspaces/${encodeURIComponent(workspace)}/projects/${encodeURIComponent(project)}/pipelines`,
250
+ body,
251
+ parseResponseBody: true
252
+ });
253
+ }
254
+ async getPipelines(workspace, project, page = 1, perPage = 10) {
255
+ const query = {
256
+ page: String(page),
257
+ per_page: String(perPage),
258
+ };
259
+ return await this.request({
260
+ method: 'GET',
261
+ path: `/workspaces/${encodeURIComponent(workspace)}/projects/${encodeURIComponent(project)}/pipelines`,
262
+ query,
263
+ parseResponseBody: true,
264
+ });
265
+ }
266
+ async getPipelineYml(workspace, project, pipelineId) {
267
+ return await this.request({
268
+ method: 'GET',
269
+ path: `/workspaces/${encodeURIComponent(workspace)}/projects/${encodeURIComponent(project)}/pipelines/${encodeURIComponent(pipelineId)}/yaml`,
270
+ parseResponseBody: true,
271
+ });
272
+ }
273
+ async getPipeline(workspace, project, pipelineId) {
274
+ return await this.request({
275
+ method: 'GET',
276
+ path: `/workspaces/${encodeURIComponent(workspace)}/projects/${encodeURIComponent(project)}/pipelines/${encodeURIComponent(pipelineId)}`,
277
+ parseResponseBody: true,
278
+ });
279
+ }
280
+ async getPipelineRuns(workspace, project, pipelineId, page = 1, perPage = 10) {
281
+ const query = {
282
+ page: String(page),
283
+ per_page: String(perPage),
284
+ };
285
+ return await this.request({
286
+ method: 'GET',
287
+ path: `/workspaces/${encodeURIComponent(workspace)}/projects/${encodeURIComponent(project)}/pipelines/${encodeURIComponent(pipelineId)}/executions`,
288
+ query,
289
+ parseResponseBody: true,
290
+ });
291
+ }
219
292
  async getPipelineRun(workspace, project, pipelineId, executionId) {
220
293
  return await this.request({
221
294
  method: 'GET',
@@ -322,6 +395,34 @@ class ApiClient {
322
395
  parseResponseBody: true,
323
396
  });
324
397
  }
398
+ async pipelineRunRetry(workspace, project, pipelineId, runId) {
399
+ return await this.request({
400
+ method: 'PATCH',
401
+ path: `/workspaces/${encodeURIComponent(workspace)}/projects/${encodeURIComponent(project)}/pipelines/${encodeURIComponent(pipelineId)}/executions/${encodeURIComponent(runId)}`,
402
+ body: {
403
+ operation: 'RETRY',
404
+ },
405
+ parseResponseBody: true,
406
+ });
407
+ }
408
+ async pipelineRunApply(workspace, project, pipelineId, runId, body) {
409
+ return await this.request({
410
+ method: 'PATCH',
411
+ path: `/workspaces/${encodeURIComponent(workspace)}/projects/${encodeURIComponent(project)}/pipelines/${encodeURIComponent(pipelineId)}/executions/${encodeURIComponent(runId)}`,
412
+ body,
413
+ parseResponseBody: true,
414
+ });
415
+ }
416
+ async pipelineRunCancel(workspace, project, pipelineId, runId) {
417
+ return await this.request({
418
+ method: 'PATCH',
419
+ path: `/workspaces/${encodeURIComponent(workspace)}/projects/${encodeURIComponent(project)}/pipelines/${encodeURIComponent(pipelineId)}/executions/${encodeURIComponent(runId)}`,
420
+ body: {
421
+ operation: 'CANCEL',
422
+ },
423
+ parseResponseBody: true,
424
+ });
425
+ }
325
426
  async pipelineRun(workspace, project, pipelineId, body) {
326
427
  return await this.request({
327
428
  method: 'POST',
@@ -330,6 +431,13 @@ class ApiClient {
330
431
  parseResponseBody: true,
331
432
  });
332
433
  }
434
+ async deletePipeline(workspace, project, pipelineId) {
435
+ return await this.request({
436
+ method: 'DELETE',
437
+ path: `/workspaces/${encodeURIComponent(workspace)}/projects/${encodeURIComponent(project)}/pipelines/${encodeURIComponent(pipelineId)}`,
438
+ parseResponseBody: false,
439
+ });
440
+ }
333
441
  // Sandbox methods
334
442
  async createSandbox(workspace, project, body) {
335
443
  return await this.request({
@@ -804,14 +912,14 @@ class ApiClient {
804
912
  return await this.request({
805
913
  method: 'POST',
806
914
  path: `/workspaces/${encodeURIComponent(workspace)}/sandboxes/${encodeURIComponent(sandboxId)}/apps/${encodeURIComponent(appId)}/stop`,
807
- parseResponseBody: true
915
+ parseResponseBody: true,
808
916
  });
809
917
  }
810
918
  async startSandboxApp(workspace, sandboxId, appId) {
811
919
  return await this.request({
812
920
  method: 'POST',
813
921
  path: `/workspaces/${encodeURIComponent(workspace)}/sandboxes/${encodeURIComponent(sandboxId)}/apps/${encodeURIComponent(appId)}/start`,
814
- parseResponseBody: true
922
+ parseResponseBody: true,
815
923
  });
816
924
  }
817
925
  async getSandboxAppLogs(workspace, sandboxId, appId, cursor) {
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const utils_1 = require("../../utils");
7
+ const texts_1 = require("../../texts");
8
+ const input_1 = __importDefault(require("../../input"));
9
+ const output_1 = __importDefault(require("../../output"));
10
+ const commandPipelineCreate = (0, utils_1.newCommand)('create', texts_1.DESC_COMMAND_PIPELINE_CREATE);
11
+ commandPipelineCreate.alias('add');
12
+ commandPipelineCreate.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
13
+ commandPipelineCreate.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
14
+ commandPipelineCreate.option('-n, --name <name>', texts_1.OPTION_PIPELINE_NAME);
15
+ commandPipelineCreate.option('-i, --identifier <identifier>', texts_1.OPTION_PIPELINE_IDENTIFIER);
16
+ commandPipelineCreate.option('--format <text|json>', texts_1.OPTION_FORMAT);
17
+ commandPipelineCreate.option('--yaml <content|@path>', texts_1.OPTION_PIPELINE_YAML);
18
+ commandPipelineCreate.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_PIPELINE_CREATE}`);
19
+ commandPipelineCreate.action(async (options) => {
20
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
21
+ const project = input_1.default.restApiProject(options.project);
22
+ const client = input_1.default.restApiTokenClient();
23
+ const humanId = require('human-id').default;
24
+ const timestamp = Date.now().toString(36);
25
+ const baseName = humanId({ separator: '-', capitalize: false });
26
+ const defaultIdentifier = `${baseName}-${timestamp}`;
27
+ let body = {
28
+ name: options.name || options.identifier || baseName,
29
+ identifier: options.identifier || defaultIdentifier,
30
+ };
31
+ let result = await client.createPipeline(workspace, project, body);
32
+ if (options.yaml) {
33
+ const yaml = input_1.default.restApiYaml(options.yaml);
34
+ body = {
35
+ yaml: Buffer.from(yaml, 'utf8').toString('base64'),
36
+ };
37
+ await client.updatePipelineYml(workspace, project, result.id, body);
38
+ }
39
+ result = await client.getPipeline(workspace, project, result.id);
40
+ if (options.format === 'json') {
41
+ output_1.default.json(result);
42
+ }
43
+ else {
44
+ output_1.default.dim('Identifier: ', false);
45
+ output_1.default.cyan(result.identifier);
46
+ output_1.default.cyan(result.html_url);
47
+ output_1.default.green(texts_1.TXT_PIPELINE_CREATED);
48
+ }
49
+ output_1.default.exitNormal();
50
+ });
51
+ exports.default = commandPipelineCreate;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const utils_1 = require("../../utils");
7
+ const texts_1 = require("../../texts");
8
+ const input_1 = __importDefault(require("../../input"));
9
+ const output_1 = __importDefault(require("../../output"));
10
+ const commandPipelineDelete = (0, utils_1.newCommand)('delete', texts_1.DESC_COMMAND_PIPELINE_DELETE);
11
+ commandPipelineDelete.alias('rm');
12
+ commandPipelineDelete.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
13
+ commandPipelineDelete.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
14
+ commandPipelineDelete.option('-f, --force', texts_1.OPTION_CONFIRM_FORCE);
15
+ commandPipelineDelete.argument('<identifier>', texts_1.OPTION_PIPELINE_IDENTIFIER);
16
+ commandPipelineDelete.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_PIPELINE_DELETE}`);
17
+ commandPipelineDelete.action(async (identifier, options) => {
18
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
19
+ const project = input_1.default.restApiProject(options.project);
20
+ const client = input_1.default.restApiTokenClient();
21
+ const data = await client.getPipelineByIdentifier(workspace, project, identifier);
22
+ if (!data || !data.domain) {
23
+ output_1.default.exitError(texts_1.ERR_WORKSPACE_NOT_FOUND);
24
+ }
25
+ if (!data.project_identifier) {
26
+ output_1.default.exitError(texts_1.ERR_PROJECT_NOT_FOUND);
27
+ }
28
+ if (!data.pipeline_id) {
29
+ output_1.default.exitError(texts_1.ERR_PIPELINE_NOT_FOUND);
30
+ }
31
+ const confirmed = options.force ||
32
+ (await output_1.default.confirm((0, texts_1.TXT_PIPELINE_DELETE_CONFIRM)(identifier)));
33
+ if (confirmed) {
34
+ await client.deletePipeline(workspace, project, data.pipeline_id);
35
+ output_1.default.exitSuccess(texts_1.TXT_PIPELINE_DELETED);
36
+ }
37
+ else {
38
+ output_1.default.exitNormal();
39
+ }
40
+ });
41
+ exports.default = commandPipelineDelete;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const utils_1 = require("../../utils");
7
+ const texts_1 = require("../../texts");
8
+ const input_1 = __importDefault(require("../../input"));
9
+ const output_1 = __importDefault(require("../../output"));
10
+ const commandPipelineGet = (0, utils_1.newCommand)('get', texts_1.DESC_COMMAND_PIPELINE_GET);
11
+ commandPipelineGet.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
12
+ commandPipelineGet.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
13
+ commandPipelineGet.option('--format <text|json>', texts_1.OPTION_FORMAT);
14
+ commandPipelineGet.argument('<identifier>', texts_1.OPTION_PIPELINE_IDENTIFIER);
15
+ commandPipelineGet.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_PIPELINE_GET}`);
16
+ commandPipelineGet.action(async (identifier, options) => {
17
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
18
+ const project = input_1.default.restApiProject(options.project);
19
+ const client = input_1.default.restApiTokenClient();
20
+ const data = await client.getPipelineByIdentifier(workspace, project, identifier);
21
+ if (!data || !data.domain) {
22
+ output_1.default.exitError(texts_1.ERR_WORKSPACE_NOT_FOUND);
23
+ }
24
+ if (!data.project_identifier) {
25
+ output_1.default.exitError(texts_1.ERR_PROJECT_NOT_FOUND);
26
+ }
27
+ if (!data.pipeline_id) {
28
+ output_1.default.exitError(texts_1.ERR_PIPELINE_NOT_FOUND);
29
+ }
30
+ const pipeline = await client.getPipeline(workspace, project, data.pipeline_id);
31
+ if (options.format === 'json') {
32
+ output_1.default.json(pipeline);
33
+ }
34
+ else {
35
+ const OutputPipeline = require('../../output/pipeline').default;
36
+ const table = [
37
+ ['Field', 'Value'],
38
+ ['Name', pipeline.name || '-'],
39
+ [
40
+ 'Status',
41
+ OutputPipeline.runStatusText(pipeline.last_execution_status || '-'),
42
+ ],
43
+ ['ID', String(pipeline.id || '-')],
44
+ ['Identifier', pipeline.identifier || '-'],
45
+ ['URL', pipeline.html_url || '-'],
46
+ ];
47
+ output_1.default.table(table);
48
+ }
49
+ output_1.default.exitNormal();
50
+ });
51
+ exports.default = commandPipelineGet;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const utils_1 = require("../../utils");
7
+ const texts_1 = require("../../texts");
8
+ const input_1 = __importDefault(require("../../input"));
9
+ const output_1 = __importDefault(require("../../output"));
10
+ const commandPipelineList = (0, utils_1.newCommand)('list', texts_1.DESC_COMMAND_PIPELINE_LIST);
11
+ commandPipelineList.alias('ls');
12
+ commandPipelineList.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
13
+ commandPipelineList.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
14
+ commandPipelineList.option('--page <number>', texts_1.OPTION_REST_API_PAGE, '1');
15
+ commandPipelineList.option('--per-page <number>', texts_1.OPTION_REST_API_PER_PAGE, '10');
16
+ commandPipelineList.option('--format <text|json>', texts_1.OPTION_FORMAT);
17
+ commandPipelineList.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_PIPELINE_LIST}`);
18
+ commandPipelineList.action(async (options) => {
19
+ const page = input_1.default.restApiPage(options.page);
20
+ const perPage = input_1.default.restApiPerPage(options.perPage);
21
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
22
+ const project = input_1.default.restApiProject(options.project);
23
+ const client = input_1.default.restApiTokenClient();
24
+ const r = await client.getPipelines(workspace, project, page, perPage);
25
+ if (!r.pipelines.length) {
26
+ output_1.default.exitError(texts_1.ERR_PIPELINES_NOT_FOUND);
27
+ }
28
+ if (options.format === 'json') {
29
+ output_1.default.json(r.pipelines);
30
+ }
31
+ else {
32
+ const data = [['NAME', 'STATUS', 'ID', 'IDENTIFIER', 'URL']];
33
+ const OutputPipeline = require('../../output/pipeline').default;
34
+ for (const pipeline of r.pipelines) {
35
+ data.push([
36
+ pipeline.name || '-',
37
+ OutputPipeline.runStatusText(pipeline.last_execution_status || '-'),
38
+ String(pipeline.id || '-'),
39
+ pipeline.identifier || '-',
40
+ pipeline.html_url || '-',
41
+ ]);
42
+ }
43
+ output_1.default.table(data);
44
+ }
45
+ output_1.default.exitNormal();
46
+ });
47
+ exports.default = commandPipelineList;
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const utils_1 = require("../../../utils");
7
+ const texts_1 = require("../../../texts");
8
+ const input_1 = __importDefault(require("../../../input"));
9
+ const output_1 = __importDefault(require("../../../output"));
10
+ const pipeline_1 = require("../../../types/pipeline");
11
+ const commandPipelineRunApply = (0, utils_1.newCommand)('apply', texts_1.DESC_COMMAND_PIPELINE_RUN_APPLY);
12
+ commandPipelineRunApply.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
13
+ commandPipelineRunApply.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
14
+ commandPipelineRunApply.option('-n, --no-wait', texts_1.OPTION_PIPELINE_RUN_NO_WAIT);
15
+ commandPipelineRunApply.argument('<identifier>', texts_1.OPTION_PIPELINE_RUN_ARGUMENT);
16
+ commandPipelineRunApply.argument('<run-id>', texts_1.OPTION_PIPELINE_RUN_ID);
17
+ commandPipelineRunApply.argument('<run-action-id>', texts_1.OPTION_PIPELINE_RUN_ACTION_ID);
18
+ commandPipelineRunApply.option('-v,--variable <variables...>', texts_1.OPTION_PIPELINE_RUN_VAR);
19
+ commandPipelineRunApply.addHelpText('after', texts_1.EXAMPLE_PIPELINE_RUN_APPLY);
20
+ commandPipelineRunApply.action(async (identifier, runId, runActionId, options) => {
21
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
22
+ const project = input_1.default.restApiProject(options.project);
23
+ const rid = input_1.default.pipelineRunId(runId);
24
+ const variables = input_1.default.pipelineRunVariable(options.variable || [], false);
25
+ const client = input_1.default.restApiTokenClient();
26
+ const data = await client.getPipelineByIdentifier(workspace, project, identifier);
27
+ if (!data || !data.domain) {
28
+ output_1.default.exitError(texts_1.ERR_WORKSPACE_NOT_FOUND);
29
+ }
30
+ if (!data.project_identifier) {
31
+ output_1.default.exitError(texts_1.ERR_PROJECT_NOT_FOUND);
32
+ }
33
+ if (!data.pipeline_id) {
34
+ output_1.default.exitError(texts_1.ERR_PIPELINE_NOT_FOUND);
35
+ }
36
+ const a = await client.getPipelineRunActionExecution(workspace, project, data.pipeline_id, rid, runActionId);
37
+ let type;
38
+ if (a.status === pipeline_1.PIPELINE_RUN_STATUS.WAITING_FOR_APPLY) {
39
+ type = 'APPLY';
40
+ }
41
+ else if (a.status === pipeline_1.PIPELINE_RUN_STATUS.WAITING_FOR_VT_SESSION) {
42
+ type = 'APPROVE_VT';
43
+ }
44
+ else if (a.status === pipeline_1.PIPELINE_RUN_STATUS.WAITING_FOR_VARIABLES) {
45
+ type = 'APPLY_VARIABLES';
46
+ }
47
+ else if (a.status === pipeline_1.PIPELINE_RUN_STATUS.WAITING_FOR_SETTABLE_VARIABLES) {
48
+ type = 'SET_VARIABLES';
49
+ }
50
+ else {
51
+ output_1.default.exitError(texts_1.ERR_CANT_APPLY_ACTION_EXECUTION);
52
+ }
53
+ const body = {
54
+ operation: type,
55
+ approve_action_id: runActionId,
56
+ variables,
57
+ };
58
+ await client.pipelineRunApply(workspace, project, data.pipeline_id, rid, body);
59
+ const OutputPipeline = require('../../../output/pipeline').default;
60
+ await OutputPipeline.runStatus(client, workspace, project, data.pipeline_id, rid, !options.wait);
61
+ });
62
+ exports.default = commandPipelineRunApply;
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const utils_1 = require("../../../utils");
7
+ const texts_1 = require("../../../texts");
8
+ const input_1 = __importDefault(require("../../../input"));
9
+ const output_1 = __importDefault(require("../../../output"));
10
+ const pipeline_1 = require("../../../types/pipeline");
11
+ const commandPipelineRunApprove = (0, utils_1.newCommand)('approve', texts_1.DESC_COMMAND_PIPELINE_RUN_APPLY);
12
+ commandPipelineRunApprove.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
13
+ commandPipelineRunApprove.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
14
+ commandPipelineRunApprove.option('-n, --no-wait', texts_1.OPTION_PIPELINE_RUN_NO_WAIT);
15
+ commandPipelineRunApprove.option('--no-follow', texts_1.OPTION_PIPELINE_RUN_NO_FOLLOW);
16
+ commandPipelineRunApprove.option('--format <text|json>', texts_1.OPTION_FORMAT);
17
+ commandPipelineRunApprove.argument('<identifier>', texts_1.OPTION_PIPELINE_IDENTIFIER);
18
+ commandPipelineRunApprove.argument('<run-id>', texts_1.OPTION_PIPELINE_RUN_ID);
19
+ commandPipelineRunApprove.argument('<run-action-id>', texts_1.OPTION_PIPELINE_RUN_ACTION_ID);
20
+ commandPipelineRunApprove.option('-v,--variable <variables...>', texts_1.OPTION_PIPELINE_RUN_VAR);
21
+ commandPipelineRunApprove.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_PIPELINE_RUN_APPLY}`);
22
+ commandPipelineRunApprove.action(async (identifier, runId, runActionId, options) => {
23
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
24
+ const project = input_1.default.restApiProject(options.project);
25
+ const rid = input_1.default.pipelineRunId(runId);
26
+ const variables = input_1.default.pipelineRunVariable(options.variable || [], false);
27
+ const client = input_1.default.restApiTokenClient();
28
+ const data = await client.getPipelineByIdentifier(workspace, project, identifier);
29
+ if (!data || !data.domain) {
30
+ output_1.default.exitError(texts_1.ERR_WORKSPACE_NOT_FOUND);
31
+ }
32
+ if (!data.project_identifier) {
33
+ output_1.default.exitError(texts_1.ERR_PROJECT_NOT_FOUND);
34
+ }
35
+ if (!data.pipeline_id) {
36
+ output_1.default.exitError(texts_1.ERR_PIPELINE_NOT_FOUND);
37
+ }
38
+ const a = await client.getPipelineRunActionExecution(workspace, project, data.pipeline_id, rid, runActionId);
39
+ let type;
40
+ if (a.status === pipeline_1.PIPELINE_RUN_STATUS.WAITING_FOR_APPLY) {
41
+ type = 'APPLY';
42
+ }
43
+ else if (a.status === pipeline_1.PIPELINE_RUN_STATUS.WAITING_FOR_VT_SESSION) {
44
+ type = 'APPROVE_VT';
45
+ }
46
+ else if (a.status === pipeline_1.PIPELINE_RUN_STATUS.WAITING_FOR_VARIABLES) {
47
+ type = 'APPLY_VARIABLES';
48
+ }
49
+ else if (a.status === pipeline_1.PIPELINE_RUN_STATUS.WAITING_FOR_SETTABLE_VARIABLES) {
50
+ type = 'SET_VARIABLES';
51
+ }
52
+ else {
53
+ output_1.default.exitError(texts_1.ERR_CANT_APPLY_ACTION_EXECUTION);
54
+ }
55
+ const body = {
56
+ operation: type,
57
+ approve_action_id: runActionId,
58
+ variables,
59
+ };
60
+ await client.pipelineRunApply(workspace, project, data.pipeline_id, rid, body);
61
+ const OutputPipeline = require('../../../output/pipeline').default;
62
+ await OutputPipeline.runStatus(client, workspace, project, identifier, data.pipeline_id, rid, !options.wait, !options.follow, options.format === 'json');
63
+ });
64
+ exports.default = commandPipelineRunApprove;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const utils_1 = require("../../../utils");
7
+ const texts_1 = require("../../../texts");
8
+ const input_1 = __importDefault(require("../../../input"));
9
+ const output_1 = __importDefault(require("../../../output"));
10
+ const commandPipelineRunCancel = (0, utils_1.newCommand)('cancel', texts_1.DESC_COMMAND_PIPELINE_RUN_CANCEL);
11
+ commandPipelineRunCancel.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
12
+ commandPipelineRunCancel.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
13
+ commandPipelineRunCancel.option('-n, --no-wait', texts_1.OPTION_PIPELINE_RUN_NO_WAIT);
14
+ commandPipelineRunCancel.option('--no-follow', texts_1.OPTION_PIPELINE_RUN_NO_FOLLOW);
15
+ commandPipelineRunCancel.option('--format <text|json>', texts_1.OPTION_FORMAT);
16
+ commandPipelineRunCancel.argument('<identifier>', texts_1.OPTION_PIPELINE_IDENTIFIER);
17
+ commandPipelineRunCancel.argument('<run-id>', texts_1.OPTION_PIPELINE_RUN_ID);
18
+ commandPipelineRunCancel.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_PIPELINE_RUN_CANCEL}`);
19
+ commandPipelineRunCancel.action(async (identifier, runId, options) => {
20
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
21
+ const project = input_1.default.restApiProject(options.project);
22
+ const client = input_1.default.restApiTokenClient();
23
+ const rid = input_1.default.pipelineRunId(runId);
24
+ const data = await client.getPipelineByIdentifier(workspace, project, identifier);
25
+ if (!data || !data.domain) {
26
+ output_1.default.exitError(texts_1.ERR_WORKSPACE_NOT_FOUND);
27
+ }
28
+ if (!data.project_identifier) {
29
+ output_1.default.exitError(texts_1.ERR_PROJECT_NOT_FOUND);
30
+ }
31
+ if (!data.pipeline_id) {
32
+ output_1.default.exitError(texts_1.ERR_PIPELINE_NOT_FOUND);
33
+ }
34
+ await client.pipelineRunCancel(workspace, project, data.pipeline_id, rid);
35
+ const OutputPipeline = require('../../../output/pipeline').default;
36
+ await OutputPipeline.runStatus(client, workspace, project, identifier, data.pipeline_id, rid, !options.wait, !options.follow, options.format === 'json');
37
+ });
38
+ exports.default = commandPipelineRunCancel;
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const utils_1 = require("../../../utils");
7
+ const texts_1 = require("../../../texts");
8
+ const input_1 = __importDefault(require("../../../input"));
9
+ const output_1 = __importDefault(require("../../../output"));
10
+ const commandPipelineRunList = (0, utils_1.newCommand)('list', texts_1.DESC_COMMAND_PIPELINE_RUN_LIST);
11
+ commandPipelineRunList.alias('ls');
12
+ commandPipelineRunList.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
13
+ commandPipelineRunList.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
14
+ commandPipelineRunList.option('--page <number>', texts_1.OPTION_REST_API_PAGE, '1');
15
+ commandPipelineRunList.option('--per-page <number>', texts_1.OPTION_REST_API_PER_PAGE, '10');
16
+ commandPipelineRunList.option('--format <text|json>', texts_1.OPTION_FORMAT);
17
+ commandPipelineRunList.argument('<identifier>', texts_1.OPTION_PIPELINE_IDENTIFIER);
18
+ commandPipelineRunList.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_PIPELINE_RUN_LIST}`);
19
+ commandPipelineRunList.action(async (identifier, options) => {
20
+ const page = input_1.default.restApiPage(options.page);
21
+ const perPage = input_1.default.restApiPerPage(options.perPage);
22
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
23
+ const project = input_1.default.restApiProject(options.project);
24
+ const client = input_1.default.restApiTokenClient();
25
+ const data = await client.getPipelineByIdentifier(workspace, project, identifier);
26
+ if (!data || !data.domain) {
27
+ output_1.default.exitError(texts_1.ERR_WORKSPACE_NOT_FOUND);
28
+ }
29
+ if (!data.project_identifier) {
30
+ output_1.default.exitError(texts_1.ERR_PROJECT_NOT_FOUND);
31
+ }
32
+ if (!data.pipeline_id) {
33
+ output_1.default.exitError(texts_1.ERR_PIPELINE_NOT_FOUND);
34
+ }
35
+ const result = await client.getPipelineRuns(workspace, project, data.pipeline_id, page, perPage);
36
+ if (!result.executions.length) {
37
+ output_1.default.exitError(texts_1.ERR_PIPELINE_RUNS_NOT_FOUND);
38
+ }
39
+ if (options.format === 'json') {
40
+ output_1.default.json(result.executions);
41
+ }
42
+ else {
43
+ const OutputPipeline = require('../../../output/pipeline').default;
44
+ const table = [['ID', 'STATUS', 'STARTED', 'FINISHED', 'URL']];
45
+ for (const run of result.executions) {
46
+ table.push([
47
+ String(run.id),
48
+ OutputPipeline.runStatusText(run.status),
49
+ run.start_date || '-',
50
+ run.finish_date || '-',
51
+ run.html_url,
52
+ ]);
53
+ }
54
+ output_1.default.table(table);
55
+ }
56
+ output_1.default.exitNormal('');
57
+ });
58
+ exports.default = commandPipelineRunList;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const utils_1 = require("../../../utils");
7
+ const texts_1 = require("../../../texts");
8
+ const input_1 = __importDefault(require("../../../input"));
9
+ const output_1 = __importDefault(require("../../../output"));
10
+ const commandPipelineRunLogs = (0, utils_1.newCommand)('logs', texts_1.DESC_COMMAND_PIPELINE_RUN_LOGS);
11
+ commandPipelineRunLogs.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
12
+ commandPipelineRunLogs.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
13
+ commandPipelineRunLogs.option('-n, --no-wait', texts_1.OPTION_PIPELINE_RUN_NO_WAIT);
14
+ commandPipelineRunLogs.option('--format <text|json>', texts_1.OPTION_FORMAT);
15
+ commandPipelineRunLogs.argument('<identifier>', texts_1.OPTION_PIPELINE_IDENTIFIER);
16
+ commandPipelineRunLogs.argument('<run-id>', texts_1.OPTION_PIPELINE_RUN_ID);
17
+ commandPipelineRunLogs.argument('<run-action-id>', texts_1.OPTION_PIPELINE_RUN_ACTION_ID);
18
+ commandPipelineRunLogs.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_PIPELINE_RUN_LOGS}`);
19
+ commandPipelineRunLogs.action(async (identifier, runId, runActionId, options) => {
20
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
21
+ const project = input_1.default.restApiProject(options.project);
22
+ const client = input_1.default.restApiTokenClient();
23
+ const rid = input_1.default.pipelineRunId(runId);
24
+ const raid = input_1.default.pipelineRunActionId(runActionId);
25
+ const data = await client.getPipelineByIdentifier(workspace, project, identifier);
26
+ if (!data || !data.domain) {
27
+ output_1.default.exitError(texts_1.ERR_WORKSPACE_NOT_FOUND);
28
+ }
29
+ if (!data.project_identifier) {
30
+ output_1.default.exitError(texts_1.ERR_PROJECT_NOT_FOUND);
31
+ }
32
+ if (!data.pipeline_id) {
33
+ output_1.default.exitError(texts_1.ERR_PIPELINE_NOT_FOUND);
34
+ }
35
+ const OutputPipeline = require('../../../output/pipeline').default;
36
+ await OutputPipeline.runLogs(client, workspace, project, data.pipeline_id, rid, raid, !options.wait, options.format === 'json');
37
+ });
38
+ exports.default = commandPipelineRunLogs;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const utils_1 = require("../../../utils");
7
+ const texts_1 = require("../../../texts");
8
+ const input_1 = __importDefault(require("../../../input"));
9
+ const output_1 = __importDefault(require("../../../output"));
10
+ const commandPipelineRunRetry = (0, utils_1.newCommand)('retry', texts_1.DESC_COMMAND_PIPELINE_RUN_RETRY);
11
+ commandPipelineRunRetry.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
12
+ commandPipelineRunRetry.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
13
+ commandPipelineRunRetry.option('-n, --no-wait', texts_1.OPTION_PIPELINE_RUN_NO_WAIT);
14
+ commandPipelineRunRetry.option('--no-follow', texts_1.OPTION_PIPELINE_RUN_NO_FOLLOW);
15
+ commandPipelineRunRetry.option('--format <text|json>', texts_1.OPTION_FORMAT);
16
+ commandPipelineRunRetry.argument('<identifier>', texts_1.OPTION_PIPELINE_IDENTIFIER);
17
+ commandPipelineRunRetry.argument('<run-id>', texts_1.OPTION_PIPELINE_RUN_ID);
18
+ commandPipelineRunRetry.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_PIPELINE_RUN_RETRY}`);
19
+ commandPipelineRunRetry.action(async (identifier, runId, options) => {
20
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
21
+ const project = input_1.default.restApiProject(options.project);
22
+ const client = input_1.default.restApiTokenClient();
23
+ const rid = input_1.default.pipelineRunId(runId);
24
+ const data = await client.getPipelineByIdentifier(workspace, project, identifier);
25
+ if (!data || !data.domain) {
26
+ output_1.default.exitError(texts_1.ERR_WORKSPACE_NOT_FOUND);
27
+ }
28
+ if (!data.project_identifier) {
29
+ output_1.default.exitError(texts_1.ERR_PROJECT_NOT_FOUND);
30
+ }
31
+ if (!data.pipeline_id) {
32
+ output_1.default.exitError(texts_1.ERR_PIPELINE_NOT_FOUND);
33
+ }
34
+ await client.pipelineRunRetry(workspace, project, data.pipeline_id, rid);
35
+ const OutputPipeline = require('../../../output/pipeline').default;
36
+ await OutputPipeline.runStatus(client, workspace, project, identifier, data.pipeline_id, rid, !options.wait, !options.follow, options.format === 'json');
37
+ });
38
+ exports.default = commandPipelineRunRetry;