bdy 1.23.11-dev → 1.23.13-dev-target-commands

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 (53) hide show
  1. package/distTs/detect-rules.json +351 -0
  2. package/distTs/package.json +3 -1
  3. package/distTs/src/api/client.js +222 -12
  4. package/distTs/src/cliIndex.js +4 -0
  5. package/distTs/src/command/artifact/list.js +2 -6
  6. package/distTs/src/command/distro/list.js +1 -0
  7. package/distTs/src/command/distro/route/update.js +1 -1
  8. package/distTs/src/command/distro/update.js +9 -9
  9. package/distTs/src/command/environment/create.js +70 -0
  10. package/distTs/src/command/environment/delete.js +29 -0
  11. package/distTs/src/command/environment/get.js +48 -0
  12. package/distTs/src/command/environment/list.js +45 -0
  13. package/distTs/src/command/environment/resolve.js +22 -0
  14. package/distTs/src/command/environment/update.js +59 -0
  15. package/distTs/src/command/environment.js +20 -0
  16. package/distTs/src/command/pipeline/run/apply.js +62 -0
  17. package/distTs/src/command/target/create.js +33 -0
  18. package/distTs/src/command/target/delete.js +30 -0
  19. package/distTs/src/command/target/exec/command.js +103 -0
  20. package/distTs/src/command/target/exec/kill.js +31 -0
  21. package/distTs/src/command/target/exec/list.js +53 -0
  22. package/distTs/src/command/target/exec/logs.js +27 -0
  23. package/distTs/src/command/target/exec/status.js +44 -0
  24. package/distTs/src/command/target/exec.js +24 -0
  25. package/distTs/src/command/target/get.js +63 -0
  26. package/distTs/src/command/target/list.js +49 -0
  27. package/distTs/src/command/target/scope.js +108 -0
  28. package/distTs/src/command/target/update.js +31 -0
  29. package/distTs/src/command/target.js +22 -0
  30. package/distTs/src/command/yaml/actions/detect.js +268 -0
  31. package/distTs/src/command/yaml/actions/info.js +56 -0
  32. package/distTs/src/command/yaml/actions/list.js +70 -0
  33. package/distTs/src/command/yaml/actions/schema.js +104 -0
  34. package/distTs/src/command/yaml/actions.js +13 -0
  35. package/distTs/src/command/yaml/agents.js +88 -0
  36. package/distTs/src/command/yaml/cache.js +98 -0
  37. package/distTs/src/command/yaml/init.js +110 -0
  38. package/distTs/src/command/yaml/pipeline.js +42 -0
  39. package/distTs/src/command/yaml/render.js +83 -0
  40. package/distTs/src/command/yaml/schemaUtils.js +139 -0
  41. package/distTs/src/command/yaml/validate.js +259 -0
  42. package/distTs/src/command/yaml.js +18 -0
  43. package/distTs/src/diskCache.js +82 -0
  44. package/distTs/src/input.js +65 -0
  45. package/distTs/src/output.js +21 -2
  46. package/distTs/src/texts.js +252 -27
  47. package/distTs/src/utils.js +18 -2
  48. package/package.json +3 -1
  49. package/distTs/README.md +0 -181
  50. package/distTs/src/command/project/get.js +0 -18
  51. package/distTs/src/command/project/set.js +0 -31
  52. package/distTs/src/command/sandbox/get/yaml.js +0 -30
  53. package/distTs/src/command/vt/scrape.js +0 -193
@@ -0,0 +1,53 @@
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 scope_1 = require("../scope");
11
+ const commandTargetExecList = (0, utils_1.newCommand)('list', texts_1.DESC_COMMAND_TARGET_EXEC_LIST);
12
+ commandTargetExecList.alias('ls');
13
+ commandTargetExecList.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
14
+ commandTargetExecList.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
15
+ commandTargetExecList.option('--pipeline <identifier>', texts_1.OPTION_TARGET_PIPELINE);
16
+ commandTargetExecList.option('--environment <identifier>', texts_1.OPTION_TARGET_ENVIRONMENT);
17
+ commandTargetExecList.option('--limit <n>', texts_1.OPTION_TARGET_EXEC_LIMIT);
18
+ commandTargetExecList.option('--format <text|json>', texts_1.OPTION_FORMAT);
19
+ commandTargetExecList.argument('<identifier>', texts_1.OPTION_TARGET_IDENTIFIER);
20
+ commandTargetExecList.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_TARGET_EXEC_LIST}`);
21
+ commandTargetExecList.action(async (identifier, options) => {
22
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
23
+ const client = input_1.default.restApiTokenClient();
24
+ const target_id = await (0, scope_1.resolveTargetId)(client, workspace, identifier, options);
25
+ const limit = options.limit ? parseInt(options.limit, 10) : undefined;
26
+ const execs = await client.getTargetExecs(workspace, target_id, limit);
27
+ if (options.format === 'json') {
28
+ output_1.default.json(execs);
29
+ }
30
+ else {
31
+ if (execs.length === 0) {
32
+ output_1.default.exitError(texts_1.ERR_TARGET_NO_EXECS);
33
+ }
34
+ const data = [
35
+ ['EXEC ID', 'STATUS', 'COMMAND', 'STARTED', 'FINISHED', 'EXIT CODE'],
36
+ ];
37
+ for (const exec of execs) {
38
+ data.push([
39
+ exec.execution_id || '-',
40
+ exec.failure_reason
41
+ ? `${exec.status} (${exec.failure_reason})`
42
+ : exec.status || '-',
43
+ (0, utils_1.truncate)(exec.command || '-', 40),
44
+ exec.started_at || '-',
45
+ exec.finished_at || '-',
46
+ exec.exit_code !== undefined ? String(exec.exit_code) : '-',
47
+ ]);
48
+ }
49
+ output_1.default.table(data);
50
+ }
51
+ output_1.default.exitNormal();
52
+ });
53
+ exports.default = commandTargetExecList;
@@ -0,0 +1,27 @@
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 scope_1 = require("../scope");
11
+ const commandTargetExecLogs = (0, utils_1.newCommand)('logs', texts_1.DESC_COMMAND_TARGET_EXEC_LOGS);
12
+ commandTargetExecLogs.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
13
+ commandTargetExecLogs.option('--offset <n>', texts_1.OPTION_TARGET_EXEC_LOG_OFFSET);
14
+ commandTargetExecLogs.option('--limit <n>', texts_1.OPTION_TARGET_EXEC_LOG_LIMIT);
15
+ commandTargetExecLogs.argument('<exec-id>', texts_1.OPTION_TARGET_EXEC_ID);
16
+ commandTargetExecLogs.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_TARGET_EXEC_LOGS}`);
17
+ commandTargetExecLogs.action(async (execId, options) => {
18
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
19
+ const client = input_1.default.restApiTokenClient();
20
+ const offset = options.offset ? parseInt(options.offset, 10) : 0;
21
+ const limit = options.limit ? parseInt(options.limit, 10) : undefined;
22
+ const { truncated } = await (0, scope_1.forwardExecLog)(client, workspace, execId, offset, undefined, limit);
23
+ if (truncated)
24
+ output_1.default.noteWarning(texts_1.WARN_TARGET_EXEC_TRUNCATED);
25
+ output_1.default.exitNormal();
26
+ });
27
+ exports.default = commandTargetExecLogs;
@@ -0,0 +1,44 @@
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 commandTargetExecStatus = (0, utils_1.newCommand)('status', texts_1.DESC_COMMAND_TARGET_EXEC_STATUS);
11
+ commandTargetExecStatus.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
12
+ commandTargetExecStatus.option('--format <text|json>', texts_1.OPTION_FORMAT);
13
+ commandTargetExecStatus.argument('<exec-id>', texts_1.OPTION_TARGET_EXEC_ID);
14
+ commandTargetExecStatus.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_TARGET_EXEC_STATUS}`);
15
+ commandTargetExecStatus.action(async (execId, options) => {
16
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
17
+ const client = input_1.default.restApiTokenClient();
18
+ const exec = await client.getTargetExec(workspace, execId);
19
+ if (options.format === 'json') {
20
+ output_1.default.json(exec);
21
+ }
22
+ else {
23
+ // The table renderer pads every Value cell to the widest one, so a long
24
+ // SQL command would blow the whole table up; the full text is available
25
+ // via --format json.
26
+ const data = [
27
+ ['Property', 'Value'],
28
+ ['Execution ID', exec.execution_id || '-'],
29
+ ['Command', (0, utils_1.truncate)(exec.command || '-', 100)],
30
+ ['Status', exec.status || '-'],
31
+ [
32
+ 'Exit Code',
33
+ exec.exit_code !== undefined ? String(exec.exit_code) : '-',
34
+ ],
35
+ ['Failure Reason', exec.failure_reason || '-'],
36
+ ['Error', exec.error_message || '-'],
37
+ ['Started', exec.started_at || '-'],
38
+ ['Finished', exec.finished_at || '-'],
39
+ ];
40
+ output_1.default.table(data);
41
+ }
42
+ output_1.default.exitNormal();
43
+ });
44
+ exports.default = commandTargetExecStatus;
@@ -0,0 +1,24 @@
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 command_1 = __importDefault(require("./exec/command"));
9
+ const status_1 = __importDefault(require("./exec/status"));
10
+ const kill_1 = __importDefault(require("./exec/kill"));
11
+ const list_1 = __importDefault(require("./exec/list"));
12
+ const logs_1 = __importDefault(require("./exec/logs"));
13
+ const commandTargetExec = (0, utils_1.newCommand)('exec', texts_1.DESC_COMMAND_TARGET_EXEC);
14
+ commandTargetExec.addCommand(command_1.default);
15
+ commandTargetExec.addCommand(status_1.default);
16
+ commandTargetExec.addCommand(kill_1.default);
17
+ commandTargetExec.addCommand(list_1.default);
18
+ commandTargetExec.addCommand(logs_1.default);
19
+ commandTargetExec.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_TARGET_EXEC_COMMAND}
20
+ ${texts_1.EXAMPLE_TARGET_EXEC_KILL}
21
+ ${texts_1.EXAMPLE_TARGET_EXEC_LIST}
22
+ ${texts_1.EXAMPLE_TARGET_EXEC_LOGS}
23
+ ${texts_1.EXAMPLE_TARGET_EXEC_STATUS}`);
24
+ exports.default = commandTargetExec;
@@ -0,0 +1,63 @@
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 scope_1 = require("./scope");
11
+ const commandTargetGet = (0, utils_1.newCommand)('get', texts_1.DESC_COMMAND_TARGET_GET);
12
+ commandTargetGet.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
13
+ commandTargetGet.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
14
+ commandTargetGet.option('--pipeline <identifier>', texts_1.OPTION_TARGET_PIPELINE);
15
+ commandTargetGet.option('--environment <identifier>', texts_1.OPTION_TARGET_ENVIRONMENT);
16
+ commandTargetGet.option('--format <text|json>', texts_1.OPTION_FORMAT);
17
+ commandTargetGet.argument('<identifier>', texts_1.OPTION_TARGET_IDENTIFIER);
18
+ commandTargetGet.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_TARGET_GET}`);
19
+ commandTargetGet.action(async (identifier, options) => {
20
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
21
+ const client = input_1.default.restApiTokenClient();
22
+ const target_id = await (0, scope_1.resolveTargetId)(client, workspace, identifier, options);
23
+ const target = await client.getTarget(workspace, target_id);
24
+ if (options.format === 'json') {
25
+ output_1.default.json(target);
26
+ }
27
+ else {
28
+ const data = [
29
+ ['Field', 'Value'],
30
+ ['ID', target.id || '-'],
31
+ ['Identifier', target.identifier || '-'],
32
+ ['Name', target.name || '-'],
33
+ ['Type', target.type || '-'],
34
+ ['Scope', (0, scope_1.targetScopeOf)(target)],
35
+ ['Address', (0, scope_1.targetAddressOf)(target)],
36
+ ['Tags', (target.tags || []).join(', ') || '-'],
37
+ ['Note', target.note || '-'],
38
+ ['Agent note', target.agent_note || '-'],
39
+ ['Disabled', target.disabled ? 'true' : 'false'],
40
+ ];
41
+ if (target.project) {
42
+ data.push(['Project', target.project.name || '-']);
43
+ }
44
+ if (target.pipeline) {
45
+ data.push([
46
+ 'Pipeline',
47
+ target.pipeline.identifier || String(target.pipeline.id) || '-',
48
+ ]);
49
+ }
50
+ if (target.environment) {
51
+ data.push([
52
+ 'Environment',
53
+ target.environment.identifier || target.environment.id || '-',
54
+ ]);
55
+ }
56
+ if (target.html_url) {
57
+ data.push(['URL', target.html_url]);
58
+ }
59
+ output_1.default.table(data);
60
+ }
61
+ output_1.default.exitNormal();
62
+ });
63
+ exports.default = commandTargetGet;
@@ -0,0 +1,49 @@
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 scope_1 = require("./scope");
11
+ const commandTargetList = (0, utils_1.newCommand)('list', texts_1.DESC_COMMAND_TARGET_LIST);
12
+ commandTargetList.alias('ls');
13
+ commandTargetList.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
14
+ commandTargetList.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
15
+ commandTargetList.option('--pipeline <identifier>', texts_1.OPTION_TARGET_PIPELINE);
16
+ commandTargetList.option('--environment <identifier>', texts_1.OPTION_TARGET_ENVIRONMENT);
17
+ commandTargetList.option('--scope <scope>', texts_1.OPT_COMMAND_TARGET_SCOPE);
18
+ commandTargetList.option('--format <text|json>', texts_1.OPTION_FORMAT);
19
+ commandTargetList.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_TARGET_LIST}`);
20
+ commandTargetList.action(async (options) => {
21
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
22
+ const project = input_1.default.restApiProject(options.project, true);
23
+ const scope = input_1.default.targetScope(project, options.pipeline, options.environment, options.scope);
24
+ input_1.default.projectScopeNote(options, project, scope, 'targets');
25
+ const client = input_1.default.restApiTokenClient();
26
+ const filters = await (0, scope_1.resolveTargetScope)(client, workspace, project, scope, options);
27
+ const result = await client.getTargets(workspace, filters);
28
+ const targets = result.targets || [];
29
+ if (options.format === 'json') {
30
+ output_1.default.json(targets);
31
+ }
32
+ else {
33
+ if (targets.length === 0) {
34
+ output_1.default.exitNormal(texts_1.TXT_TARGET_NOT_FOUND);
35
+ }
36
+ const data = [['NAME', 'IDENTIFIER', 'TYPE', 'SCOPE']];
37
+ for (const target of targets) {
38
+ data.push([
39
+ target.name || '-',
40
+ target.identifier || '-',
41
+ target.type || '-',
42
+ (0, scope_1.targetScopeOf)(target),
43
+ ]);
44
+ }
45
+ output_1.default.table(data);
46
+ }
47
+ output_1.default.exitNormal();
48
+ });
49
+ exports.default = commandTargetList;
@@ -0,0 +1,108 @@
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
+ exports.resolveTargetScope = exports.targetScopeOf = exports.targetAddressOf = exports.forwardExecLog = exports.resolveTargetId = void 0;
7
+ const utils_1 = require("../../utils");
8
+ const texts_1 = require("../../texts");
9
+ const output_1 = __importDefault(require("../../output"));
10
+ const input_1 = __importDefault(require("../../input"));
11
+ // Shared resolve preamble for commands taking a target identifier: line
12
+ // context from flags/env -> /identifiers -> hash id, exiting on a miss.
13
+ const resolveTargetId = async (client, workspace, identifier, options) => {
14
+ const project = input_1.default.restApiProject(options.project, true);
15
+ const line = input_1.default.targetLine(project, options.pipeline, options.environment);
16
+ const { target_id } = await client.getTargetByIdentifier(workspace, identifier, line);
17
+ if (!target_id) {
18
+ output_1.default.exitError(texts_1.ERR_TARGET_NOT_FOUND);
19
+ }
20
+ return target_id;
21
+ };
22
+ exports.resolveTargetId = resolveTargetId;
23
+ // Lines the CLI requests per log fetch.
24
+ const EXEC_LOG_PAGE = 1000;
25
+ // The exec log endpoint pages by line offset; its `truncated` field
26
+ // describes server-side output truncation, not pagination. `lines` may
27
+ // additionally include a trailing line that is still being written -
28
+ // `next_offset` only advances past committed lines - so exactly
29
+ // next_offset - offset lines are emitted to avoid re-printing the partial
30
+ // line on the next pass. A page shorter than requested means the committed
31
+ // log is drained, so the common case costs a single request.
32
+ const forwardExecLog = async (client, workspace, execId, startOffset, emitPage = (lines) => output_1.default.data(lines.join('\n')), maxLines) => {
33
+ let offset = startOffset;
34
+ let emitted = 0;
35
+ let truncated = false;
36
+ for (;;) {
37
+ const pageLimit = maxLines === undefined
38
+ ? EXEC_LOG_PAGE
39
+ : Math.min(EXEC_LOG_PAGE, maxLines - emitted);
40
+ if (pageLimit <= 0)
41
+ break;
42
+ const log = await client.getTargetExecLog(workspace, execId, offset, pageLimit);
43
+ truncated = truncated || !!log.truncated;
44
+ const next = log.next_offset ?? offset;
45
+ if (next <= offset)
46
+ break;
47
+ const lines = (log.lines || []).slice(0, next - offset);
48
+ if (lines.length)
49
+ emitPage(lines);
50
+ emitted += lines.length;
51
+ offset = next;
52
+ if (lines.length < pageLimit)
53
+ break;
54
+ }
55
+ return { offset, truncated };
56
+ };
57
+ exports.forwardExecLog = forwardExecLog;
58
+ // Connection info condensed to one host:port/database cell (auth is left
59
+ // out on purpose - the text view is a summary, credentials stay in json).
60
+ const targetAddressOf = (target) => {
61
+ if (!target.host)
62
+ return '-';
63
+ let address = target.host;
64
+ if (target.port)
65
+ address += `:${target.port}`;
66
+ if (target.database)
67
+ address += `/${target.database}`;
68
+ return address;
69
+ };
70
+ exports.targetAddressOf = targetAddressOf;
71
+ const targetScopeOf = (target) => {
72
+ if (target.pipeline)
73
+ return utils_1.TARGET_SCOPE.PIPELINE;
74
+ if (target.environment)
75
+ return utils_1.TARGET_SCOPE.ENVIRONMENT;
76
+ if (target.project)
77
+ return utils_1.TARGET_SCOPE.PROJECT;
78
+ return utils_1.TARGET_SCOPE.WORKSPACE;
79
+ };
80
+ exports.targetScopeOf = targetScopeOf;
81
+ // Input.targetScope guarantees project is set for the PIPELINE scope.
82
+ // Environments exist on both workspace and project level, so for the
83
+ // ENVIRONMENT scope project is optional and narrows the lookup when given.
84
+ const resolveTargetScope = async (client, workspace, project, scope, options) => {
85
+ const params = {};
86
+ if (scope === utils_1.TARGET_SCOPE.PIPELINE) {
87
+ const { pipeline_id } = await client.getPipelineByIdentifier(workspace, project, options.pipeline);
88
+ if (!pipeline_id)
89
+ output_1.default.exitError(texts_1.ERR_PIPELINE_NOT_FOUND);
90
+ params.pipelineId = pipeline_id;
91
+ }
92
+ else if (scope === utils_1.TARGET_SCOPE.ENVIRONMENT) {
93
+ const query = {
94
+ environment: options.environment,
95
+ };
96
+ if (project)
97
+ query.project = project;
98
+ const { environment_id } = await client.getResourceByIdentifier(workspace, query);
99
+ if (!environment_id)
100
+ output_1.default.exitError(texts_1.ERR_TARGET_ENVIRONMENT_NOT_FOUND);
101
+ params.environmentId = environment_id;
102
+ }
103
+ else if (scope === utils_1.TARGET_SCOPE.PROJECT) {
104
+ params.project = project;
105
+ }
106
+ return params;
107
+ };
108
+ exports.resolveTargetScope = resolveTargetScope;
@@ -0,0 +1,31 @@
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 scope_1 = require("./scope");
11
+ const commandTargetUpdate = (0, utils_1.newCommand)('update', texts_1.DESC_COMMAND_TARGET_UPDATE);
12
+ commandTargetUpdate.alias('edit');
13
+ commandTargetUpdate.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
14
+ commandTargetUpdate.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
15
+ commandTargetUpdate.option('--pipeline <identifier>', texts_1.OPTION_TARGET_PIPELINE);
16
+ commandTargetUpdate.option('--environment <identifier>', texts_1.OPTION_TARGET_ENVIRONMENT);
17
+ commandTargetUpdate.option('--yaml <content|@path>', texts_1.OPTION_TARGET_YAML);
18
+ commandTargetUpdate.argument('<identifier>', texts_1.OPTION_TARGET_IDENTIFIER);
19
+ commandTargetUpdate.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_TARGET_UPDATE}`);
20
+ commandTargetUpdate.action(async (identifier, options) => {
21
+ const yaml = input_1.default.restApiYaml(options.yaml);
22
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
23
+ const client = input_1.default.restApiTokenClient();
24
+ const target_id = await (0, scope_1.resolveTargetId)(client, workspace, identifier, options);
25
+ const body = {
26
+ yaml: Buffer.from(yaml, 'utf8').toString('base64'),
27
+ };
28
+ const result = await client.updateTargetByYaml(workspace, target_id, body);
29
+ output_1.default.exitSuccess((0, texts_1.TXT_TARGET_UPDATED)(result.identifier, result.html_url));
30
+ });
31
+ exports.default = commandTargetUpdate;
@@ -0,0 +1,22 @@
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 list_1 = __importDefault(require("./target/list"));
9
+ const get_1 = __importDefault(require("./target/get"));
10
+ const create_1 = __importDefault(require("./target/create"));
11
+ const update_1 = __importDefault(require("./target/update"));
12
+ const delete_1 = __importDefault(require("./target/delete"));
13
+ const exec_1 = __importDefault(require("./target/exec"));
14
+ const commandTarget = (0, utils_1.newCommand)('target', texts_1.DESC_COMMAND_TARGET);
15
+ commandTarget.alias('tg');
16
+ commandTarget.addCommand(list_1.default);
17
+ commandTarget.addCommand(get_1.default);
18
+ commandTarget.addCommand(create_1.default);
19
+ commandTarget.addCommand(update_1.default);
20
+ commandTarget.addCommand(delete_1.default);
21
+ commandTarget.addCommand(exec_1.default);
22
+ exports.default = commandTarget;