bdy 1.22.24-stage → 1.22.25-master
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 +1 -1
- package/distTs/src/command/pipeline/create.js +51 -0
- package/distTs/src/command/pipeline/delete.js +41 -0
- package/distTs/src/command/pipeline/get.js +51 -0
- package/distTs/src/command/pipeline/list.js +47 -0
- package/distTs/src/command/pipeline/run/approve.js +65 -0
- package/distTs/src/command/pipeline/run/cancel.js +39 -0
- package/distTs/src/command/pipeline/run/list.js +58 -0
- package/distTs/src/command/pipeline/run/logs.js +39 -0
- package/distTs/src/command/pipeline/run/retry.js +39 -0
- package/distTs/src/command/pipeline/run/start.js +115 -0
- package/distTs/src/command/pipeline/run/status.js +38 -0
- package/distTs/src/command/pipeline/update.js +47 -0
- package/distTs/src/command/pipeline/yaml.js +38 -0
- package/distTs/src/output/pipeline.js +1710 -0
- package/distTs/src/tunnel/server/sftp.js +38 -9
- package/distTs/src/tunnel/tunnel.js +0 -24
- package/distTs/src/types/pipeline.js +424 -0
- package/package.json +1 -1
package/distTs/package.json
CHANGED
|
@@ -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,65 @@
|
|
|
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|jsonl>', texts_1.OPTION_FORMAT_JSONL);
|
|
17
|
+
commandPipelineRunApprove.argument('<identifier>', texts_1.OPTION_PIPELINE_IDENTIFIER);
|
|
18
|
+
commandPipelineRunApprove.argument('<run-id>', texts_1.OPTION_PIPELINE_RUN_ID);
|
|
19
|
+
commandPipelineRunApprove.argument('<action-run-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
|
+
${texts_1.EXAMPLE_PIPELINE_RUN_JSONL}`);
|
|
23
|
+
commandPipelineRunApprove.action(async (identifier, runId, runActionId, options) => {
|
|
24
|
+
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
25
|
+
const project = input_1.default.restApiProject(options.project);
|
|
26
|
+
const rid = input_1.default.pipelineRunId(runId);
|
|
27
|
+
const variables = input_1.default.pipelineRunVariable(options.variable || [], false);
|
|
28
|
+
const client = input_1.default.restApiTokenClient();
|
|
29
|
+
const data = await client.getPipelineByIdentifier(workspace, project, identifier);
|
|
30
|
+
if (!data || !data.domain) {
|
|
31
|
+
output_1.default.exitError(texts_1.ERR_WORKSPACE_NOT_FOUND);
|
|
32
|
+
}
|
|
33
|
+
if (!data.project_identifier) {
|
|
34
|
+
output_1.default.exitError(texts_1.ERR_PROJECT_NOT_FOUND);
|
|
35
|
+
}
|
|
36
|
+
if (!data.pipeline_id) {
|
|
37
|
+
output_1.default.exitError(texts_1.ERR_PIPELINE_NOT_FOUND);
|
|
38
|
+
}
|
|
39
|
+
const a = await client.getPipelineRunActionExecution(workspace, project, data.pipeline_id, rid, runActionId);
|
|
40
|
+
let type;
|
|
41
|
+
if (a.status === pipeline_1.PIPELINE_RUN_STATUS.WAITING_FOR_APPLY) {
|
|
42
|
+
type = 'APPLY';
|
|
43
|
+
}
|
|
44
|
+
else if (a.status === pipeline_1.PIPELINE_RUN_STATUS.WAITING_FOR_VT_SESSION) {
|
|
45
|
+
type = 'APPROVE_VT';
|
|
46
|
+
}
|
|
47
|
+
else if (a.status === pipeline_1.PIPELINE_RUN_STATUS.WAITING_FOR_VARIABLES) {
|
|
48
|
+
type = 'APPLY_VARIABLES';
|
|
49
|
+
}
|
|
50
|
+
else if (a.status === pipeline_1.PIPELINE_RUN_STATUS.WAITING_FOR_SETTABLE_VARIABLES) {
|
|
51
|
+
type = 'SET_VARIABLES';
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
output_1.default.exitError(texts_1.ERR_CANT_APPLY_ACTION_EXECUTION);
|
|
55
|
+
}
|
|
56
|
+
const body = {
|
|
57
|
+
operation: type,
|
|
58
|
+
approve_action_id: runActionId,
|
|
59
|
+
variables,
|
|
60
|
+
};
|
|
61
|
+
await client.pipelineRunApply(workspace, project, data.pipeline_id, rid, body);
|
|
62
|
+
const OutputPipeline = require('../../../output/pipeline').default;
|
|
63
|
+
await OutputPipeline.runStatus(client, workspace, project, identifier, data.pipeline_id, rid, !options.wait, !options.follow, options.format === 'jsonl');
|
|
64
|
+
});
|
|
65
|
+
exports.default = commandPipelineRunApprove;
|
|
@@ -0,0 +1,39 @@
|
|
|
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|jsonl>', texts_1.OPTION_FORMAT_JSONL);
|
|
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
|
+
${texts_1.EXAMPLE_PIPELINE_RUN_JSONL}`);
|
|
20
|
+
commandPipelineRunCancel.action(async (identifier, runId, options) => {
|
|
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 rid = input_1.default.pipelineRunId(runId);
|
|
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
|
+
await client.pipelineRunCancel(workspace, project, data.pipeline_id, rid);
|
|
36
|
+
const OutputPipeline = require('../../../output/pipeline').default;
|
|
37
|
+
await OutputPipeline.runStatus(client, workspace, project, identifier, data.pipeline_id, rid, !options.wait, !options.follow, options.format === 'jsonl');
|
|
38
|
+
});
|
|
39
|
+
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,39 @@
|
|
|
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|jsonl>', texts_1.OPTION_FORMAT_JSONL);
|
|
15
|
+
commandPipelineRunLogs.argument('<identifier>', texts_1.OPTION_PIPELINE_IDENTIFIER);
|
|
16
|
+
commandPipelineRunLogs.argument('<run-id>', texts_1.OPTION_PIPELINE_RUN_ID);
|
|
17
|
+
commandPipelineRunLogs.argument('<action-run-id>', texts_1.OPTION_PIPELINE_RUN_ACTION_ID);
|
|
18
|
+
commandPipelineRunLogs.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_PIPELINE_RUN_LOGS}
|
|
19
|
+
${texts_1.EXAMPLE_PIPELINE_RUN_JSONL}`);
|
|
20
|
+
commandPipelineRunLogs.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 client = input_1.default.restApiTokenClient();
|
|
24
|
+
const rid = input_1.default.pipelineRunId(runId);
|
|
25
|
+
const raid = input_1.default.pipelineRunActionId(runActionId);
|
|
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 OutputPipeline = require('../../../output/pipeline').default;
|
|
37
|
+
await OutputPipeline.runLogs(client, workspace, project, identifier, data.pipeline_id, rid, raid, !options.wait, options.format === 'jsonl');
|
|
38
|
+
});
|
|
39
|
+
exports.default = commandPipelineRunLogs;
|
|
@@ -0,0 +1,39 @@
|
|
|
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|jsonl>', texts_1.OPTION_FORMAT_JSONL);
|
|
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
|
+
${texts_1.EXAMPLE_PIPELINE_RUN_JSONL}`);
|
|
20
|
+
commandPipelineRunRetry.action(async (identifier, runId, options) => {
|
|
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 rid = input_1.default.pipelineRunId(runId);
|
|
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
|
+
await client.pipelineRunRetry(workspace, project, data.pipeline_id, rid);
|
|
36
|
+
const OutputPipeline = require('../../../output/pipeline').default;
|
|
37
|
+
await OutputPipeline.runStatus(client, workspace, project, identifier, data.pipeline_id, rid, !options.wait, !options.follow, options.format === 'jsonl');
|
|
38
|
+
});
|
|
39
|
+
exports.default = commandPipelineRunRetry;
|
|
@@ -0,0 +1,115 @@
|
|
|
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('-vf, --variables-from-file <filepath>', texts_1.OPTION_PIPELINE_RUN_VAR_FILE);
|
|
23
|
+
commandPipelineRunStart.option('-vff, --variable-from-file <variables...>', texts_1.OPTION_PIPELINE_RUN_SINGLE_VAR_FILE);
|
|
24
|
+
commandPipelineRunStart.option('-vm, --variable-masked <variables...>', texts_1.OPTION_PIPELINE_RUN_VAR);
|
|
25
|
+
commandPipelineRunStart.option('-vmf, --variables-masked-from-file <filepath>', texts_1.OPTION_PIPELINE_RUN_VAR_FILE);
|
|
26
|
+
commandPipelineRunStart.option('-vmff, --variable-masked-from-file <variables...>', texts_1.OPTION_PIPELINE_RUN_SINGLE_VAR_FILE);
|
|
27
|
+
commandPipelineRunStart.option('--schedule <date>', texts_1.OPTION_PIPELINE_RUN_DELAY);
|
|
28
|
+
commandPipelineRunStart.option('--action <actions...>', texts_1.OPTION_PIPELINE_RUN_ACTION);
|
|
29
|
+
commandPipelineRunStart.option('-n,--no-wait', texts_1.OPTION_PIPELINE_RUN_NO_WAIT);
|
|
30
|
+
commandPipelineRunStart.option('--no-follow', texts_1.OPTION_PIPELINE_RUN_NO_FOLLOW);
|
|
31
|
+
commandPipelineRunStart.option('--format <text|jsonl>', texts_1.OPTION_FORMAT_JSONL);
|
|
32
|
+
commandPipelineRunStart.argument('<identifier>', texts_1.OPTION_PIPELINE_IDENTIFIER);
|
|
33
|
+
commandPipelineRunStart.usage('<identifier> [options]');
|
|
34
|
+
commandPipelineRunStart.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_PIPELINE_RUN_START}
|
|
35
|
+
${texts_1.EXAMPLE_PIPELINE_RUN_JSONL}`);
|
|
36
|
+
commandPipelineRunStart.action(async (identifier, options) => {
|
|
37
|
+
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
38
|
+
const project = input_1.default.restApiProject(options.project);
|
|
39
|
+
const client = input_1.default.restApiTokenClient();
|
|
40
|
+
const data = await client.getPipelineByIdentifier(workspace, project, identifier);
|
|
41
|
+
if (!data || !data.domain) {
|
|
42
|
+
output_1.default.exitError(texts_1.ERR_WORKSPACE_NOT_FOUND);
|
|
43
|
+
}
|
|
44
|
+
if (!data.project_identifier) {
|
|
45
|
+
output_1.default.exitError(texts_1.ERR_PROJECT_NOT_FOUND);
|
|
46
|
+
}
|
|
47
|
+
if (!data.pipeline_id) {
|
|
48
|
+
output_1.default.exitError(texts_1.ERR_PIPELINE_NOT_FOUND);
|
|
49
|
+
}
|
|
50
|
+
const body = {};
|
|
51
|
+
if (options.branch) {
|
|
52
|
+
body.branch = {
|
|
53
|
+
name: options.branch,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
if (options.tag) {
|
|
57
|
+
body.tag = {
|
|
58
|
+
name: options.tag,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
if (options.pullRequest) {
|
|
62
|
+
body.pull_request = {
|
|
63
|
+
name: `pull/${options.pullRequest}`,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
if (options.revision) {
|
|
67
|
+
body.to_revision = {
|
|
68
|
+
revision: options.revision,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
if (options.comment) {
|
|
72
|
+
body.comment = options.comment;
|
|
73
|
+
}
|
|
74
|
+
if (options.refresh) {
|
|
75
|
+
body.refresh = true;
|
|
76
|
+
}
|
|
77
|
+
if (options.clearCache) {
|
|
78
|
+
body.clear_cache = true;
|
|
79
|
+
}
|
|
80
|
+
const priority = input_1.default.pipelineRunPriority(options.priority);
|
|
81
|
+
if (priority) {
|
|
82
|
+
body.priority = priority;
|
|
83
|
+
}
|
|
84
|
+
body.variables = [];
|
|
85
|
+
if (options.variablesFromFile) {
|
|
86
|
+
body.variables = body.variables.concat(input_1.default.pipelineRunVariablesFromFile(options.variablesFromFile, false));
|
|
87
|
+
}
|
|
88
|
+
if (options.variablesMaskedFromFile) {
|
|
89
|
+
body.variables = body.variables.concat(input_1.default.pipelineRunVariablesFromFile(options.variablesMaskedFromFile, true));
|
|
90
|
+
}
|
|
91
|
+
if (options.variableFromFile) {
|
|
92
|
+
body.variables = body.variables.concat(input_1.default.pipelineRunVariableFromFile(options.variableFromFile, false));
|
|
93
|
+
}
|
|
94
|
+
if (options.variableMaskedFromFile) {
|
|
95
|
+
body.variables = body.variables.concat(input_1.default.pipelineRunVariableFromFile(options.variableMaskedFromFile, true));
|
|
96
|
+
}
|
|
97
|
+
if (options.variable) {
|
|
98
|
+
body.variables = body.variables.concat(input_1.default.pipelineRunVariable(options.variable, false));
|
|
99
|
+
}
|
|
100
|
+
if (options.variableMasked) {
|
|
101
|
+
body.variables = body.variables.concat(input_1.default.pipelineRunVariable(options.variableMasked, true));
|
|
102
|
+
}
|
|
103
|
+
const delay = input_1.default.pipelineRunDelay(options.schedule);
|
|
104
|
+
if (delay) {
|
|
105
|
+
body.delay_until = delay;
|
|
106
|
+
}
|
|
107
|
+
const actions = input_1.default.pipelineRunAction(options.action);
|
|
108
|
+
if (actions) {
|
|
109
|
+
body.actions_to_run = actions;
|
|
110
|
+
}
|
|
111
|
+
const result = await client.pipelineRun(workspace, project, data.pipeline_id, body);
|
|
112
|
+
const OutputPipeline = require('../../../output/pipeline').default;
|
|
113
|
+
await OutputPipeline.runStatus(client, workspace, project, identifier, data.pipeline_id, result.id, !options.wait, !options.follow, options.format === 'jsonl');
|
|
114
|
+
});
|
|
115
|
+
exports.default = commandPipelineRunStart;
|
|
@@ -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 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.option('--no-follow', texts_1.OPTION_PIPELINE_RUN_NO_FOLLOW);
|
|
15
|
+
commandPipelineRunStatus.option('--format <text|jsonl>', texts_1.OPTION_FORMAT_JSONL);
|
|
16
|
+
commandPipelineRunStatus.argument('<identifier>', texts_1.OPTION_PIPELINE_IDENTIFIER);
|
|
17
|
+
commandPipelineRunStatus.argument('<run-id>', texts_1.OPTION_PIPELINE_RUN_ID);
|
|
18
|
+
commandPipelineRunStatus.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_PIPELINE_RUN_STATUS}
|
|
19
|
+
${texts_1.EXAMPLE_PIPELINE_RUN_JSONL}`);
|
|
20
|
+
commandPipelineRunStatus.action(async (identifier, runId, options) => {
|
|
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 rid = input_1.default.pipelineRunId(runId);
|
|
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.runStatus(client, workspace, project, identifier, data.pipeline_id, rid, !options.wait, !options.follow, options.format === 'jsonl');
|
|
37
|
+
});
|
|
38
|
+
exports.default = commandPipelineRunStatus;
|
|
@@ -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 commandPipelineUpdate = (0, utils_1.newCommand)('update', texts_1.DESC_COMMAND_PIPELINE_UPDATE);
|
|
11
|
+
commandPipelineUpdate.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
12
|
+
commandPipelineUpdate.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
|
|
13
|
+
commandPipelineUpdate.argument('<identifier>', texts_1.OPTION_PIPELINE_IDENTIFIER);
|
|
14
|
+
commandPipelineUpdate.argument('<yaml|@path>', texts_1.OPTION_PIPELINE_YAML);
|
|
15
|
+
commandPipelineUpdate.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
16
|
+
commandPipelineUpdate.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_PIPELINE_UPDATE}`);
|
|
17
|
+
commandPipelineUpdate.action(async (identifier, y, options) => {
|
|
18
|
+
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
19
|
+
const project = input_1.default.restApiProject(options.project);
|
|
20
|
+
const yaml = input_1.default.restApiYaml(y);
|
|
21
|
+
const client = input_1.default.restApiTokenClient();
|
|
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.updatePipelineYml(workspace, project, data.pipeline_id, {
|
|
33
|
+
yaml: Buffer.from(yaml, 'utf8').toString('base64'),
|
|
34
|
+
});
|
|
35
|
+
const result = await client.getPipeline(workspace, project, data.pipeline_id);
|
|
36
|
+
if (options.format === 'json') {
|
|
37
|
+
output_1.default.json(result);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
output_1.default.dim('Identifier: ', false);
|
|
41
|
+
output_1.default.cyan(result.identifier);
|
|
42
|
+
output_1.default.cyan(result.html_url);
|
|
43
|
+
output_1.default.green(texts_1.TXT_PIPELINE_UPDATED);
|
|
44
|
+
}
|
|
45
|
+
output_1.default.exitNormal();
|
|
46
|
+
});
|
|
47
|
+
exports.default = commandPipelineUpdate;
|