bdy 1.23.4-dev-target-commands → 1.23.4-dev

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 (54) hide show
  1. package/distTs/README.md +181 -0
  2. package/distTs/package.json +1 -3
  3. package/distTs/src/agent/agent.js +35 -2
  4. package/distTs/src/agent/manager.js +11 -0
  5. package/distTs/src/agent/system.js +6 -1
  6. package/distTs/src/api/client.js +0 -156
  7. package/distTs/src/cliIndex.js +0 -4
  8. package/distTs/src/command/artifact/list.js +6 -1
  9. package/distTs/src/command/distro/route/update.js +1 -1
  10. package/distTs/src/command/distro/update.js +9 -9
  11. package/distTs/src/command/project/get.js +18 -0
  12. package/distTs/src/command/project/set.js +31 -0
  13. package/distTs/src/command/sandbox/get/yaml.js +30 -0
  14. package/distTs/src/command/vt/scrape.js +193 -0
  15. package/distTs/src/input.js +0 -54
  16. package/distTs/src/texts.js +8 -196
  17. package/distTs/src/utils.js +7 -16
  18. package/package.json +1 -3
  19. package/distTs/detect-rules.json +0 -351
  20. package/distTs/src/command/environment/create.js +0 -70
  21. package/distTs/src/command/environment/delete.js +0 -29
  22. package/distTs/src/command/environment/get.js +0 -48
  23. package/distTs/src/command/environment/list.js +0 -44
  24. package/distTs/src/command/environment/resolve.js +0 -22
  25. package/distTs/src/command/environment/update.js +0 -59
  26. package/distTs/src/command/environment.js +0 -20
  27. package/distTs/src/command/pipeline/run/apply.js +0 -62
  28. package/distTs/src/command/target/create.js +0 -33
  29. package/distTs/src/command/target/delete.js +0 -30
  30. package/distTs/src/command/target/exec/command.js +0 -65
  31. package/distTs/src/command/target/exec/kill.js +0 -25
  32. package/distTs/src/command/target/exec/list.js +0 -54
  33. package/distTs/src/command/target/exec/logs.js +0 -25
  34. package/distTs/src/command/target/exec/status.js +0 -41
  35. package/distTs/src/command/target/exec.js +0 -24
  36. package/distTs/src/command/target/get.js +0 -62
  37. package/distTs/src/command/target/list.js +0 -48
  38. package/distTs/src/command/target/scope.js +0 -60
  39. package/distTs/src/command/target/update.js +0 -31
  40. package/distTs/src/command/target.js +0 -22
  41. package/distTs/src/command/yaml/actions/detect.js +0 -268
  42. package/distTs/src/command/yaml/actions/info.js +0 -56
  43. package/distTs/src/command/yaml/actions/list.js +0 -70
  44. package/distTs/src/command/yaml/actions/schema.js +0 -104
  45. package/distTs/src/command/yaml/actions.js +0 -13
  46. package/distTs/src/command/yaml/agents.js +0 -88
  47. package/distTs/src/command/yaml/cache.js +0 -98
  48. package/distTs/src/command/yaml/init.js +0 -110
  49. package/distTs/src/command/yaml/pipeline.js +0 -42
  50. package/distTs/src/command/yaml/render.js +0 -83
  51. package/distTs/src/command/yaml/schemaUtils.js +0 -139
  52. package/distTs/src/command/yaml/validate.js +0 -259
  53. package/distTs/src/command/yaml.js +0 -18
  54. package/distTs/src/diskCache.js +0 -82
@@ -1,62 +0,0 @@
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;
@@ -1,33 +0,0 @@
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 commandTargetCreate = (0, utils_1.newCommand)('create', texts_1.DESC_COMMAND_TARGET_CREATE);
12
- commandTargetCreate.alias('add');
13
- commandTargetCreate.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
14
- commandTargetCreate.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
15
- commandTargetCreate.option('--pipeline <identifier>', texts_1.OPTION_TARGET_PIPELINE);
16
- commandTargetCreate.option('--environment <identifier>', texts_1.OPTION_TARGET_ENVIRONMENT);
17
- commandTargetCreate.option('--scope <scope>', texts_1.OPT_COMMAND_TARGET_SCOPE);
18
- commandTargetCreate.option('--yaml <content|@path>', texts_1.OPTION_TARGET_YAML);
19
- commandTargetCreate.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_TARGET_CREATE}`);
20
- commandTargetCreate.action(async (options) => {
21
- const yaml = input_1.default.restApiYaml(options.yaml);
22
- const workspace = input_1.default.restApiWorkspace(options.workspace);
23
- const project = input_1.default.restApiProject(options.project, true);
24
- const scope = input_1.default.targetScope(project, options.pipeline, options.environment, options.scope);
25
- const client = input_1.default.restApiTokenClient();
26
- const scopeParams = await (0, scope_1.resolveTargetScope)(client, workspace, project, scope, options);
27
- const body = {
28
- yaml: Buffer.from(yaml, 'utf8').toString('base64'),
29
- };
30
- const result = await client.createTargetByYaml(workspace, scopeParams, body);
31
- output_1.default.exitSuccess((0, texts_1.TXT_TARGET_CREATED)(result.identifier, result.html_url));
32
- });
33
- exports.default = commandTargetCreate;
@@ -1,30 +0,0 @@
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 commandTargetDelete = (0, utils_1.newCommand)('delete', texts_1.DESC_COMMAND_TARGET_DELETE);
12
- commandTargetDelete.alias('rm');
13
- commandTargetDelete.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
14
- commandTargetDelete.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
15
- commandTargetDelete.option('--pipeline <identifier>', texts_1.OPTION_TARGET_PIPELINE);
16
- commandTargetDelete.option('--environment <identifier>', texts_1.OPTION_TARGET_ENVIRONMENT);
17
- commandTargetDelete.option('-f, --force', texts_1.OPTION_CONFIRM_FORCE);
18
- commandTargetDelete.argument('<identifier>', texts_1.OPTION_TARGET_IDENTIFIER);
19
- commandTargetDelete.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_TARGET_DELETE}`);
20
- commandTargetDelete.action(async (identifier, options) => {
21
- const workspace = input_1.default.restApiWorkspace(options.workspace);
22
- const client = input_1.default.restApiTokenClient();
23
- const target_id = await (0, scope_1.resolveTargetId)(client, workspace, identifier, options);
24
- const confirmed = options.force || (await output_1.default.confirm((0, texts_1.TXT_TARGET_DELETE_CONFIRM)(identifier)));
25
- if (!confirmed)
26
- output_1.default.exitNormal();
27
- await client.deleteTarget(workspace, target_id);
28
- output_1.default.exitSuccess((0, texts_1.TXT_TARGET_DELETED)(identifier));
29
- });
30
- exports.default = commandTargetDelete;
@@ -1,65 +0,0 @@
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 EXEC_WAIT_MS = 10000;
12
- const commandTargetExecCommand = (0, utils_1.newCommand)('command', texts_1.DESC_COMMAND_TARGET_EXEC);
13
- commandTargetExecCommand.alias('cmd');
14
- commandTargetExecCommand.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
15
- commandTargetExecCommand.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
16
- commandTargetExecCommand.option('--pipeline <identifier>', texts_1.OPTION_TARGET_PIPELINE);
17
- commandTargetExecCommand.option('--environment <identifier>', texts_1.OPTION_TARGET_ENVIRONMENT);
18
- commandTargetExecCommand.option('--wait', texts_1.OPTION_SANDBOX_WAIT);
19
- commandTargetExecCommand.argument('<identifier>', texts_1.OPTION_TARGET_IDENTIFIER);
20
- commandTargetExecCommand.argument('<command>');
21
- commandTargetExecCommand.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_TARGET_EXEC_COMMAND}`);
22
- commandTargetExecCommand.action(async (identifier, command, options) => {
23
- output_1.default.handleSignals();
24
- const workspace = input_1.default.restApiWorkspace(options.workspace);
25
- const client = input_1.default.restApiTokenClient();
26
- const target_id = await (0, scope_1.resolveTargetId)(client, workspace, identifier, options);
27
- let exec = await client.executeTargetCommand(workspace, target_id, {
28
- command,
29
- });
30
- const execId = exec.execution_id;
31
- output_1.default.gray((0, texts_1.TXT_TARGET_EXEC_ID)(execId));
32
- if (!options.wait) {
33
- output_1.default.exitSuccess((0, texts_1.TXT_TARGET_EXEC_BACKGROUND)(execId));
34
- }
35
- let offset = 0;
36
- const printLog = async () => {
37
- for (;;) {
38
- const log = await client.getTargetExecLog(workspace, execId, offset);
39
- (log.lines || []).forEach((line) => output_1.default.normal(line));
40
- const advanced = log.next_offset !== undefined && log.next_offset > offset;
41
- if (advanced)
42
- offset = log.next_offset;
43
- if (!log.truncated || !advanced)
44
- break;
45
- }
46
- };
47
- do {
48
- if (exec.status === utils_1.TARGET_EXEC_STATUS.INPROGRESS) {
49
- exec = await client.getTargetExec(workspace, execId, EXEC_WAIT_MS);
50
- }
51
- await printLog();
52
- } while (exec.status === utils_1.TARGET_EXEC_STATUS.INPROGRESS);
53
- if (exec.status === utils_1.TARGET_EXEC_STATUS.SUCCESSFUL) {
54
- output_1.default.exitSuccess((0, texts_1.TXT_TARGET_EXEC_SUCCESS)(execId));
55
- }
56
- else if (exec.status === utils_1.TARGET_EXEC_STATUS.CANCELLED) {
57
- output_1.default.exitError((0, texts_1.TXT_TARGET_EXEC_CANCELLED)(execId));
58
- }
59
- else {
60
- if (exec.error_message)
61
- output_1.default.gray(exec.error_message);
62
- output_1.default.exitError((0, texts_1.TXT_TARGET_EXEC_FAILED)(execId, exec.failure_reason));
63
- }
64
- });
65
- exports.default = commandTargetExecCommand;
@@ -1,25 +0,0 @@
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 commandTargetExecKill = (0, utils_1.newCommand)('kill', texts_1.DESC_COMMAND_TARGET_EXEC_KILL);
11
- commandTargetExecKill.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
12
- commandTargetExecKill.option('-f, --force', texts_1.OPTION_CONFIRM_FORCE);
13
- commandTargetExecKill.argument('<exec-id>', texts_1.OPTION_TARGET_EXEC_ID);
14
- commandTargetExecKill.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_TARGET_EXEC_KILL}`);
15
- commandTargetExecKill.action(async (execId, options) => {
16
- const workspace = input_1.default.restApiWorkspace(options.workspace);
17
- const client = input_1.default.restApiTokenClient();
18
- const confirmed = options.force ||
19
- (await output_1.default.confirm((0, texts_1.TXT_TARGET_EXEC_KILL_CONFIRM)(execId)));
20
- if (!confirmed)
21
- output_1.default.exitNormal();
22
- await client.cancelTargetExec(workspace, execId);
23
- output_1.default.exitSuccess((0, texts_1.TXT_TARGET_EXEC_KILLED)(execId));
24
- });
25
- exports.default = commandTargetExecKill;
@@ -1,54 +0,0 @@
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
- (exec.command || '-').substring(0, 40) +
44
- (exec.command?.length > 40 ? '...' : ''),
45
- exec.started_at || '-',
46
- exec.finished_at || '-',
47
- exec.exit_code !== undefined ? String(exec.exit_code) : '-',
48
- ]);
49
- }
50
- output_1.default.table(data);
51
- }
52
- output_1.default.exitNormal();
53
- });
54
- exports.default = commandTargetExecList;
@@ -1,25 +0,0 @@
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 commandTargetExecLogs = (0, utils_1.newCommand)('logs', texts_1.DESC_COMMAND_TARGET_EXEC_LOGS);
11
- commandTargetExecLogs.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
12
- commandTargetExecLogs.option('--offset <n>', texts_1.OPTION_TARGET_EXEC_LOG_OFFSET);
13
- commandTargetExecLogs.option('--limit <n>', texts_1.OPTION_TARGET_EXEC_LOG_LIMIT);
14
- commandTargetExecLogs.argument('<exec-id>', texts_1.OPTION_TARGET_EXEC_ID);
15
- commandTargetExecLogs.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_TARGET_EXEC_LOGS}`);
16
- commandTargetExecLogs.action(async (execId, options) => {
17
- const workspace = input_1.default.restApiWorkspace(options.workspace);
18
- const client = input_1.default.restApiTokenClient();
19
- const offset = options.offset ? parseInt(options.offset, 10) : undefined;
20
- const limit = options.limit ? parseInt(options.limit, 10) : undefined;
21
- const log = await client.getTargetExecLog(workspace, execId, offset, limit);
22
- (log.lines || []).forEach((line) => output_1.default.normal(line));
23
- output_1.default.exitNormal();
24
- });
25
- exports.default = commandTargetExecLogs;
@@ -1,41 +0,0 @@
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
- const data = [
24
- ['Property', 'Value'],
25
- ['Execution ID', exec.execution_id || '-'],
26
- ['Command', exec.command || '-'],
27
- ['Status', exec.status || '-'],
28
- [
29
- 'Exit Code',
30
- exec.exit_code !== undefined ? String(exec.exit_code) : '-',
31
- ],
32
- ['Failure Reason', exec.failure_reason || '-'],
33
- ['Error', exec.error_message || '-'],
34
- ['Started', exec.started_at || '-'],
35
- ['Finished', exec.finished_at || '-'],
36
- ];
37
- output_1.default.table(data);
38
- }
39
- output_1.default.exitNormal();
40
- });
41
- exports.default = commandTargetExecStatus;
@@ -1,24 +0,0 @@
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;
@@ -1,62 +0,0 @@
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
- ['Tags', (target.tags || []).join(', ') || '-'],
36
- ['Note', target.note || '-'],
37
- ['Agent note', target.agent_note || '-'],
38
- ['Disabled', target.disabled ? 'true' : 'false'],
39
- ];
40
- if (target.project) {
41
- data.push(['Project', target.project.name || '-']);
42
- }
43
- if (target.pipeline) {
44
- data.push([
45
- 'Pipeline',
46
- target.pipeline.identifier || String(target.pipeline.id) || '-',
47
- ]);
48
- }
49
- if (target.environment) {
50
- data.push([
51
- 'Environment',
52
- target.environment.identifier || target.environment.id || '-',
53
- ]);
54
- }
55
- if (target.html_url) {
56
- data.push(['URL', target.html_url]);
57
- }
58
- output_1.default.table(data);
59
- }
60
- output_1.default.exitNormal();
61
- });
62
- exports.default = commandTargetGet;
@@ -1,48 +0,0 @@
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
- const client = input_1.default.restApiTokenClient();
25
- const filters = await (0, scope_1.resolveTargetScope)(client, workspace, project, scope, options);
26
- const result = await client.getTargets(workspace, filters);
27
- const targets = result.targets || [];
28
- if (options.format === 'json') {
29
- output_1.default.json(targets);
30
- }
31
- else {
32
- if (targets.length === 0) {
33
- output_1.default.exitNormal(texts_1.TXT_TARGET_NOT_FOUND);
34
- }
35
- const data = [['NAME', 'IDENTIFIER', 'TYPE', 'SCOPE']];
36
- for (const target of targets) {
37
- data.push([
38
- target.name || '-',
39
- target.identifier || '-',
40
- target.type || '-',
41
- (0, scope_1.targetScopeOf)(target),
42
- ]);
43
- }
44
- output_1.default.table(data);
45
- }
46
- output_1.default.exitNormal();
47
- });
48
- exports.default = commandTargetList;
@@ -1,60 +0,0 @@
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.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
- const targetScopeOf = (target) => {
24
- if (target.pipeline)
25
- return utils_1.TARGET_SCOPE.PIPELINE;
26
- if (target.environment)
27
- return utils_1.TARGET_SCOPE.ENVIRONMENT;
28
- if (target.project)
29
- return utils_1.TARGET_SCOPE.PROJECT;
30
- return utils_1.TARGET_SCOPE.WORKSPACE;
31
- };
32
- exports.targetScopeOf = targetScopeOf;
33
- // Input.targetScope guarantees project is set for the PIPELINE scope.
34
- // Environments exist on both workspace and project level, so for the
35
- // ENVIRONMENT scope project is optional and narrows the lookup when given.
36
- const resolveTargetScope = async (client, workspace, project, scope, options) => {
37
- const params = {};
38
- if (scope === utils_1.TARGET_SCOPE.PIPELINE) {
39
- const { pipeline_id } = await client.getPipelineByIdentifier(workspace, project, options.pipeline);
40
- if (!pipeline_id)
41
- output_1.default.exitError(texts_1.ERR_PIPELINE_NOT_FOUND);
42
- params.pipelineId = pipeline_id;
43
- }
44
- else if (scope === utils_1.TARGET_SCOPE.ENVIRONMENT) {
45
- const query = {
46
- environment: options.environment,
47
- };
48
- if (project)
49
- query.project = project;
50
- const { environment_id } = await client.getResourceByIdentifier(workspace, query);
51
- if (!environment_id)
52
- output_1.default.exitError(texts_1.ERR_TARGET_ENVIRONMENT_NOT_FOUND);
53
- params.environmentId = environment_id;
54
- }
55
- else if (scope === utils_1.TARGET_SCOPE.PROJECT) {
56
- params.project = project;
57
- }
58
- return params;
59
- };
60
- exports.resolveTargetScope = resolveTargetScope;
@@ -1,31 +0,0 @@
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;
@@ -1,22 +0,0 @@
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;