bdy 1.20.0-dev → 1.20.0-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 (51) hide show
  1. package/distTs/package.json +1 -1
  2. package/distTs/src/api/client.js +110 -2
  3. package/distTs/src/command/crawl/link.js +61 -0
  4. package/distTs/src/command/crawl/run.js +147 -0
  5. package/distTs/src/command/crawl/validation.js +154 -0
  6. package/distTs/src/command/crawl.js +13 -0
  7. package/distTs/src/command/pipeline/create.js +45 -0
  8. package/distTs/src/command/pipeline/delete.js +41 -0
  9. package/distTs/src/command/pipeline/get.js +42 -0
  10. package/distTs/src/command/pipeline/list.js +43 -0
  11. package/distTs/src/command/pipeline/run/apply.js +62 -0
  12. package/distTs/src/command/pipeline/run/approve.js +62 -0
  13. package/distTs/src/command/pipeline/run/cancel.js +36 -0
  14. package/distTs/src/command/pipeline/run/list.js +52 -0
  15. package/distTs/src/command/pipeline/run/logs.js +37 -0
  16. package/distTs/src/command/pipeline/run/retry.js +36 -0
  17. package/distTs/src/command/pipeline/run/start.js +96 -0
  18. package/distTs/src/command/pipeline/run/status.js +35 -0
  19. package/distTs/src/command/pipeline/run.js +22 -125
  20. package/distTs/src/command/pipeline/update.js +41 -0
  21. package/distTs/src/command/pipeline/yaml.js +38 -0
  22. package/distTs/src/command/pipeline.js +26 -0
  23. package/distTs/src/command/project/link.js +11 -11
  24. package/distTs/src/command/tests/capture/validation.js +46 -0
  25. package/distTs/src/command/tests/capture.js +103 -0
  26. package/distTs/src/command/tests/unit/link.js +61 -0
  27. package/distTs/src/command/tests/unit/upload.js +91 -0
  28. package/distTs/src/command/tests/unit.js +13 -0
  29. package/distTs/src/command/tests/visual/link.js +61 -0
  30. package/distTs/src/command/tests/visual/session/close.js +32 -0
  31. package/distTs/src/command/tests/visual/session/create.js +86 -0
  32. package/distTs/src/command/tests/visual/session.js +13 -0
  33. package/distTs/src/command/tests/visual/setup.js +20 -0
  34. package/distTs/src/command/tests/visual/shared/validation.js +145 -0
  35. package/distTs/src/command/tests/visual/upload.js +141 -0
  36. package/distTs/src/command/tests/visual.js +17 -0
  37. package/distTs/src/command/tests.js +15 -0
  38. package/distTs/src/crawl/requests.js +141 -0
  39. package/distTs/src/input.js +11 -10
  40. package/distTs/src/output/pipeline.js +1565 -0
  41. package/distTs/src/output.js +149 -31
  42. package/distTs/src/texts.js +93 -34
  43. package/distTs/src/tunnel/output/interactive/tunnel.js +2 -2
  44. package/distTs/src/types/crawl.js +2 -0
  45. package/distTs/src/types/pipeline.js +424 -0
  46. package/distTs/src/unitTest/context.js +26 -0
  47. package/package.json +1 -1
  48. package/distTs/src/command/project/get.js +0 -18
  49. package/distTs/src/command/project/set.js +0 -31
  50. package/distTs/src/command/sandbox/get/yaml.js +0 -30
  51. package/distTs/src/command/vt/scrape.js +0 -193
@@ -0,0 +1,43 @@
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.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_PIPELINE_LIST}`);
17
+ commandPipelineList.action(async (options) => {
18
+ const page = input_1.default.restApiPage(options.page);
19
+ const perPage = input_1.default.restApiPerPage(options.perPage);
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 r = await client.getPipelines(workspace, project, page, perPage);
24
+ if (!r.pipelines.length) {
25
+ output_1.default.exitError(texts_1.ERR_PIPELINES_NOT_FOUND);
26
+ }
27
+ const data = [
28
+ ['NAME', 'STATUS', 'ID', 'IDENTIFIER', 'URL']
29
+ ];
30
+ const OutputPipeline = require('../../output/pipeline').default;
31
+ for (const pipeline of r.pipelines) {
32
+ data.push([
33
+ pipeline.name || '-',
34
+ OutputPipeline.runStatusText(pipeline.last_execution_status || '-'),
35
+ String(pipeline.id || '-'),
36
+ pipeline.identifier || '-',
37
+ pipeline.html_url || '-',
38
+ ]);
39
+ }
40
+ output_1.default.table(data);
41
+ output_1.default.exitNormal();
42
+ });
43
+ 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,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 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.argument('<identifier>', texts_1.OPTION_PIPELINE_IDENTIFIER);
16
+ commandPipelineRunApprove.argument('<run-id>', texts_1.OPTION_PIPELINE_RUN_ID);
17
+ commandPipelineRunApprove.argument('<run-action-id>', texts_1.OPTION_PIPELINE_RUN_ACTION_ID);
18
+ commandPipelineRunApprove.option('-v,--variable <variables...>', texts_1.OPTION_PIPELINE_RUN_VAR);
19
+ commandPipelineRunApprove.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_PIPELINE_RUN_APPLY}`);
20
+ commandPipelineRunApprove.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, identifier, data.pipeline_id, rid, !options.wait);
61
+ });
62
+ exports.default = commandPipelineRunApprove;
@@ -0,0 +1,36 @@
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.argument('<identifier>', texts_1.OPTION_PIPELINE_IDENTIFIER);
15
+ commandPipelineRunCancel.argument('<run-id>', texts_1.OPTION_PIPELINE_RUN_ID);
16
+ commandPipelineRunCancel.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_PIPELINE_RUN_CANCEL}`);
17
+ commandPipelineRunCancel.action(async (identifier, runId, 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 rid = input_1.default.pipelineRunId(runId);
22
+ const data = await client.getPipelineByIdentifier(workspace, project, identifier);
23
+ if (!data || !data.domain) {
24
+ output_1.default.exitError(texts_1.ERR_WORKSPACE_NOT_FOUND);
25
+ }
26
+ if (!data.project_identifier) {
27
+ output_1.default.exitError(texts_1.ERR_PROJECT_NOT_FOUND);
28
+ }
29
+ if (!data.pipeline_id) {
30
+ output_1.default.exitError(texts_1.ERR_PIPELINE_NOT_FOUND);
31
+ }
32
+ await client.pipelineRunCancel(workspace, project, data.pipeline_id, rid);
33
+ const OutputPipeline = require('../../../output/pipeline').default;
34
+ await OutputPipeline.runStatus(client, workspace, project, identifier, data.pipeline_id, rid, !options.wait);
35
+ });
36
+ exports.default = commandPipelineRunCancel;
@@ -0,0 +1,52 @@
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.argument('<identifier>', texts_1.OPTION_PIPELINE_IDENTIFIER);
17
+ commandPipelineRunList.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_PIPELINE_RUN_LIST}`);
18
+ commandPipelineRunList.action(async (identifier, 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 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
+ const result = await client.getPipelineRuns(workspace, project, data.pipeline_id, page, perPage);
35
+ if (!result.executions.length) {
36
+ output_1.default.exitError(texts_1.ERR_PIPELINE_RUNS_NOT_FOUND);
37
+ }
38
+ const OutputPipeline = require('../../../output/pipeline').default;
39
+ const table = [['ID', 'STATUS', 'STARTED', 'FINISHED', 'URL']];
40
+ for (const run of result.executions) {
41
+ table.push([
42
+ String(run.id),
43
+ OutputPipeline.runStatusText(run.status),
44
+ run.start_date || '-',
45
+ run.finish_date || '-',
46
+ run.html_url,
47
+ ]);
48
+ }
49
+ output_1.default.table(table);
50
+ output_1.default.exitNormal('');
51
+ });
52
+ exports.default = commandPipelineRunList;
@@ -0,0 +1,37 @@
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.argument('<identifier>', texts_1.OPTION_PIPELINE_IDENTIFIER);
15
+ commandPipelineRunLogs.argument('<run-id>', texts_1.OPTION_PIPELINE_RUN_ID);
16
+ commandPipelineRunLogs.argument('<run-action-id>', texts_1.OPTION_PIPELINE_RUN_ACTION_ID);
17
+ commandPipelineRunLogs.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_PIPELINE_RUN_LOGS}`);
18
+ commandPipelineRunLogs.action(async (identifier, runId, runActionId, options) => {
19
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
20
+ const project = input_1.default.restApiProject(options.project);
21
+ const client = input_1.default.restApiTokenClient();
22
+ const rid = input_1.default.pipelineRunId(runId);
23
+ const raid = input_1.default.pipelineRunActionId(runActionId);
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
+ const OutputPipeline = require('../../../output/pipeline').default;
35
+ await OutputPipeline.runLogs(client, workspace, project, data.pipeline_id, rid, raid, !options.wait);
36
+ });
37
+ exports.default = commandPipelineRunLogs;
@@ -0,0 +1,36 @@
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.argument('<identifier>', texts_1.OPTION_PIPELINE_IDENTIFIER);
15
+ commandPipelineRunRetry.argument('<run-id>', texts_1.OPTION_PIPELINE_RUN_ID);
16
+ commandPipelineRunRetry.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_PIPELINE_RUN_RETRY}`);
17
+ commandPipelineRunRetry.action(async (identifier, runId, 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 rid = input_1.default.pipelineRunId(runId);
22
+ const data = await client.getPipelineByIdentifier(workspace, project, identifier);
23
+ if (!data || !data.domain) {
24
+ output_1.default.exitError(texts_1.ERR_WORKSPACE_NOT_FOUND);
25
+ }
26
+ if (!data.project_identifier) {
27
+ output_1.default.exitError(texts_1.ERR_PROJECT_NOT_FOUND);
28
+ }
29
+ if (!data.pipeline_id) {
30
+ output_1.default.exitError(texts_1.ERR_PIPELINE_NOT_FOUND);
31
+ }
32
+ await client.pipelineRunRetry(workspace, project, data.pipeline_id, rid);
33
+ const OutputPipeline = require('../../../output/pipeline').default;
34
+ await OutputPipeline.runStatus(client, workspace, project, identifier, data.pipeline_id, rid, !options.wait);
35
+ });
36
+ exports.default = commandPipelineRunRetry;
@@ -0,0 +1,96 @@
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 output_1 = __importDefault(require("../../../output"));
9
+ const input_1 = __importDefault(require("../../../input"));
10
+ const commandPipelineRunStart = (0, utils_1.newCommand)('start', texts_1.DESC_COMMAND_PIPELINE_RUN_START);
11
+ commandPipelineRunStart.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
12
+ commandPipelineRunStart.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
13
+ commandPipelineRunStart.option('-b, --branch <branch>', texts_1.OPTION_PIPELINE_RUN_BRANCH);
14
+ commandPipelineRunStart.option('-t, --tag <tag>', texts_1.OPTION_PIPELINE_RUN_TAG);
15
+ commandPipelineRunStart.option('-pr, --pull-request <pull request>', texts_1.OPTION_PIPELINE_RUN_PULL_REQUEST);
16
+ commandPipelineRunStart.option('-r, --revision <revision>', texts_1.OPTION_PIPELINE_RUN_REVISION);
17
+ commandPipelineRunStart.option('--comment <comment>', texts_1.OPTION_PIPELINE_RUN_COMMENT);
18
+ commandPipelineRunStart.option('-f, --refresh', texts_1.OPTION_PIPELINE_RUN_REFRESH);
19
+ commandPipelineRunStart.option('-c, --clear-cache', texts_1.OPTION_PIPELINE_RUN_CLEAR_CACHE);
20
+ commandPipelineRunStart.option('--priority <priority>', texts_1.OPTION_PIPELINE_RUN_PRIORITY);
21
+ commandPipelineRunStart.option('-v, --variable <variables...>', texts_1.OPTION_PIPELINE_RUN_VAR);
22
+ commandPipelineRunStart.option('-vm, --variable-masked <variables...>', texts_1.OPTION_PIPELINE_RUN_VAR);
23
+ commandPipelineRunStart.option('--schedule <date>', texts_1.OPTION_PIPELINE_RUN_DELAY);
24
+ commandPipelineRunStart.option('--action <actions...>', texts_1.OPTION_PIPELINE_RUN_ACTION);
25
+ commandPipelineRunStart.option('--no-wait', texts_1.OPTION_PIPELINE_RUN_NO_WAIT);
26
+ commandPipelineRunStart.argument('<identifier>', texts_1.OPTION_PIPELINE_IDENTIFIER);
27
+ commandPipelineRunStart.usage('<identifier> [options]');
28
+ commandPipelineRunStart.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_PIPELINE_RUN_START}`);
29
+ commandPipelineRunStart.action(async (identifier, options) => {
30
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
31
+ const project = input_1.default.restApiProject(options.project);
32
+ const client = input_1.default.restApiTokenClient();
33
+ const data = await client.getPipelineByIdentifier(workspace, project, identifier);
34
+ if (!data || !data.domain) {
35
+ output_1.default.exitError(texts_1.ERR_WORKSPACE_NOT_FOUND);
36
+ }
37
+ if (!data.project_identifier) {
38
+ output_1.default.exitError(texts_1.ERR_PROJECT_NOT_FOUND);
39
+ }
40
+ if (!data.pipeline_id) {
41
+ output_1.default.exitError(texts_1.ERR_PIPELINE_NOT_FOUND);
42
+ }
43
+ const body = {};
44
+ if (options.branch) {
45
+ body.branch = {
46
+ name: options.branch,
47
+ };
48
+ }
49
+ if (options.tag) {
50
+ body.tag = {
51
+ name: options.tag,
52
+ };
53
+ }
54
+ if (options.pullRequest) {
55
+ body.pull_request = {
56
+ name: `pull/${options.pullRequest}`,
57
+ };
58
+ }
59
+ if (options.revision) {
60
+ body.to_revision = {
61
+ revision: options.revision,
62
+ };
63
+ }
64
+ if (options.comment) {
65
+ body.comment = options.comment;
66
+ }
67
+ if (options.refresh) {
68
+ body.refresh = true;
69
+ }
70
+ if (options.clearCache) {
71
+ body.clear_cache = true;
72
+ }
73
+ const priority = input_1.default.pipelineRunPriority(options.priority);
74
+ if (priority) {
75
+ body.priority = priority;
76
+ }
77
+ body.variables = [];
78
+ if (options.variable) {
79
+ body.variables = body.variables.concat(input_1.default.pipelineRunVariable(options.variable, false));
80
+ }
81
+ if (options.variableMasked) {
82
+ body.variables = body.variables.concat(input_1.default.pipelineRunVariable(options.variableMasked, true));
83
+ }
84
+ const delay = input_1.default.pipelineRunDelay(options.schedule);
85
+ if (delay) {
86
+ body.delay_until = delay;
87
+ }
88
+ const actions = input_1.default.pipelineRunAction(options.action);
89
+ if (actions) {
90
+ body.actions_to_run = actions;
91
+ }
92
+ const result = await client.pipelineRun(workspace, project, data.pipeline_id, body);
93
+ const OutputPipeline = require('../../../output/pipeline').default;
94
+ await OutputPipeline.runStatus(client, workspace, project, identifier, data.pipeline_id, result.id, !options.wait);
95
+ });
96
+ exports.default = commandPipelineRunStart;
@@ -0,0 +1,35 @@
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 commandPipelineRunStatus = (0, utils_1.newCommand)('status', texts_1.DESC_COMMAND_PIPELINE_RUN_STATUS);
11
+ commandPipelineRunStatus.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
12
+ commandPipelineRunStatus.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
13
+ commandPipelineRunStatus.option('-n, --no-wait', texts_1.OPTION_PIPELINE_RUN_NO_WAIT);
14
+ commandPipelineRunStatus.argument('<identifier>', texts_1.OPTION_PIPELINE_IDENTIFIER);
15
+ commandPipelineRunStatus.argument('<run-id>', texts_1.OPTION_PIPELINE_RUN_ID);
16
+ commandPipelineRunStatus.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_PIPELINE_RUN_STATUS}`);
17
+ commandPipelineRunStatus.action(async (identifier, runId, 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 rid = input_1.default.pipelineRunId(runId);
22
+ const data = await client.getPipelineByIdentifier(workspace, project, identifier);
23
+ if (!data || !data.domain) {
24
+ output_1.default.exitError(texts_1.ERR_WORKSPACE_NOT_FOUND);
25
+ }
26
+ if (!data.project_identifier) {
27
+ output_1.default.exitError(texts_1.ERR_PROJECT_NOT_FOUND);
28
+ }
29
+ if (!data.pipeline_id) {
30
+ output_1.default.exitError(texts_1.ERR_PIPELINE_NOT_FOUND);
31
+ }
32
+ const OutputPipeline = require('../../../output/pipeline').default;
33
+ await OutputPipeline.runStatus(client, workspace, project, identifier, data.pipeline_id, rid, !options.wait);
34
+ });
35
+ exports.default = commandPipelineRunStatus;
@@ -5,130 +5,27 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const utils_1 = require("../../utils");
7
7
  const texts_1 = require("../../texts");
8
- const output_1 = __importDefault(require("../../output"));
9
- const input_1 = __importDefault(require("../../input"));
10
- const format_1 = __importDefault(require("../../format"));
8
+ const status_1 = __importDefault(require("./run/status"));
9
+ const start_1 = __importDefault(require("./run/start"));
10
+ const logs_1 = __importDefault(require("./run/logs"));
11
+ const cancel_1 = __importDefault(require("./run/cancel"));
12
+ const retry_1 = __importDefault(require("./run/retry"));
13
+ const list_1 = __importDefault(require("./run/list"));
14
+ const approve_1 = __importDefault(require("./run/approve"));
11
15
  const commandPipelineRun = (0, utils_1.newCommand)('run', texts_1.DESC_COMMAND_PIPELINE_RUN);
12
- commandPipelineRun.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
13
- commandPipelineRun.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
14
- commandPipelineRun.option('-b, --branch <branch>', texts_1.OPTION_PIPELINE_RUN_BRANCH);
15
- commandPipelineRun.option('-t, --tag <tag>', texts_1.OPTION_PIPELINE_RUN_TAG);
16
- commandPipelineRun.option('-pr, --pull-request <pull request>', texts_1.OPTION_PIPELINE_RUN_PULL_REQUEST);
17
- commandPipelineRun.option('-r, --revision <revision>', texts_1.OPTION_PIPELINE_RUN_REVISION);
18
- commandPipelineRun.option('--comment <comment>', texts_1.OPTION_PIPELINE_RUN_COMMENT);
19
- commandPipelineRun.option('-f, --refresh', texts_1.OPTION_PIPELINE_RUN_REFRESH);
20
- commandPipelineRun.option('-c, --clear-cache', texts_1.OPTION_PIPELINE_RUN_CLEAR_CACHE);
21
- commandPipelineRun.option('--priority <priority>', texts_1.OPTION_PIPELINE_RUN_PRIORITY);
22
- commandPipelineRun.option('-v, --variable <variables...>', texts_1.OPTION_PIPELINE_RUN_VAR);
23
- commandPipelineRun.option('-vm, --variable-masked <variables...>', texts_1.OPTION_PIPELINE_RUN_VAR);
24
- commandPipelineRun.option('--schedule <date>', texts_1.OPTION_PIPELINE_RUN_DELAY);
25
- commandPipelineRun.option('--action <actions...>', texts_1.OPTION_PIPELINE_RUN_ACTION);
26
- commandPipelineRun.option('--wait [minutes]', texts_1.OPTION_PIPELINE_RUN_WAIT);
27
- commandPipelineRun.argument('<identifier>', texts_1.OPTION_PIPELINE_RUN_ARGUMENT);
28
- commandPipelineRun.usage('<identifier> [options]');
29
- commandPipelineRun.addHelpText('after', texts_1.EXAMPLE_PIPELINE_RUN);
30
- commandPipelineRun.action(async (identifier, options) => {
31
- const workspace = input_1.default.restApiWorkspace(options.workspace);
32
- const project = input_1.default.restApiProject(options.project);
33
- const client = input_1.default.restApiTokenClient();
34
- const data = await client.getPipelineByIdentifier(workspace, project, identifier);
35
- if (!data || !data.domain) {
36
- output_1.default.exitError(texts_1.ERR_WORKSPACE_NOT_FOUND);
37
- }
38
- if (!data.project_identifier) {
39
- output_1.default.exitError(texts_1.ERR_PROJECT_NOT_FOUND);
40
- }
41
- if (!data.pipeline_id) {
42
- output_1.default.exitError(texts_1.ERR_PIPELINE_NOT_FOUND);
43
- }
44
- const body = {};
45
- if (options.branch) {
46
- body.branch = {
47
- name: options.branch,
48
- };
49
- }
50
- if (options.tag) {
51
- body.tag = {
52
- name: options.tag,
53
- };
54
- }
55
- if (options.pullRequest) {
56
- body.pull_request = {
57
- name: `pull/${options.pullRequest}`,
58
- };
59
- }
60
- if (options.revision) {
61
- body.to_revision = {
62
- revision: options.revision,
63
- };
64
- }
65
- if (options.comment) {
66
- body.comment = options.comment;
67
- }
68
- if (options.refresh) {
69
- body.refresh = true;
70
- }
71
- if (options.clearCache) {
72
- body.clear_cache = true;
73
- }
74
- const priority = input_1.default.pipelineRunPriority(options.priority);
75
- if (priority) {
76
- body.priority = priority;
77
- }
78
- body.variables = [];
79
- if (options.variable) {
80
- body.variables = body.variables.concat(input_1.default.pipelineRunVariable(options.variable, false));
81
- }
82
- if (options.variableMasked) {
83
- body.variables = body.variables.concat(input_1.default.pipelineRunVariable(options.variableMasked, true));
84
- }
85
- const delay = input_1.default.pipelineRunDelay(options.schedule);
86
- if (delay) {
87
- body.delay_until = delay;
88
- }
89
- const actions = input_1.default.pipelineRunAction(options.action);
90
- if (actions) {
91
- body.actions_to_run = actions;
92
- }
93
- const result = await client.pipelineRun(workspace, project, data.pipeline_id, body);
94
- if (options.wait) {
95
- const minutes = input_1.default.pipelineRunWaitTime(options.wait);
96
- wait(minutes, workspace, project, data.pipeline_id, result.id, result.html_url, client);
97
- }
98
- else {
99
- output_1.default.exitSuccess((0, texts_1.TXT_PIPELINE_RUN_SUCCESS)(result.html_url));
100
- }
101
- });
102
- const wait = (minutes, workspace, project, pipelineId, runId, htmlUrl, client) => {
103
- const start = Date.now();
104
- output_1.default.normal((0, texts_1.TXT_PIPELINE_RUN_WAIT)(minutes));
105
- let fetchCounter = 1;
106
- const ts1 = setTimeout(() => {
107
- output_1.default.exitError(texts_1.ERR_RUN_PIPELINE_WAIT_TIMEOUT);
108
- }, minutes * 60 * 1000);
109
- const ts2 = setInterval(async () => {
110
- output_1.default.clearPreviousLine();
111
- output_1.default.normal((0, texts_1.TXT_PIPELINE_RUN_STILL_WAITING)(formatWaitTime(start)));
112
- if (fetchCounter >= 3) {
113
- const run = await client.getPipelineRun(workspace, project, pipelineId, runId);
114
- if (!['INPROGRESS', 'ENQUEUED', 'TERMINATING'].includes(run.status)) {
115
- clearTimeout(ts1);
116
- clearInterval(ts2);
117
- output_1.default.clearPreviousLine();
118
- if (run.status === 'SUCCESSFUL') {
119
- output_1.default.exitSuccess((0, texts_1.TXT_PIPELINE_RUN_FINISH_SUCCESSFULLY)(htmlUrl));
120
- }
121
- else {
122
- output_1.default.exitError((0, texts_1.TXT_PIPELINE_RUN_FINISH_FAILED)(run.status, htmlUrl));
123
- }
124
- }
125
- fetchCounter = 0;
126
- }
127
- fetchCounter += 1;
128
- }, 1000);
129
- };
130
- const formatWaitTime = (start) => {
131
- const elapsed = Math.floor((Date.now() - start) / 1000);
132
- return format_1.default.pipelineRunWaitTime(elapsed);
133
- };
16
+ commandPipelineRun.addCommand(start_1.default);
17
+ commandPipelineRun.addCommand(status_1.default);
18
+ commandPipelineRun.addCommand(logs_1.default);
19
+ commandPipelineRun.addCommand(cancel_1.default);
20
+ commandPipelineRun.addCommand(retry_1.default);
21
+ commandPipelineRun.addCommand(approve_1.default);
22
+ commandPipelineRun.addCommand(list_1.default);
23
+ commandPipelineRun.addHelpText('after', `
24
+ EXAMPLES:${texts_1.EXAMPLE_PIPELINE_RUN_START}
25
+ ${texts_1.EXAMPLE_PIPELINE_RUN_STATUS}
26
+ ${texts_1.EXAMPLE_PIPELINE_RUN_LOGS}
27
+ ${texts_1.EXAMPLE_PIPELINE_RUN_CANCEL}
28
+ ${texts_1.EXAMPLE_PIPELINE_RUN_RETRY}
29
+ ${texts_1.EXAMPLE_PIPELINE_RUN_APPLY}
30
+ ${texts_1.EXAMPLE_PIPELINE_RUN_LIST}`);
134
31
  exports.default = commandPipelineRun;