bdy 1.23.2-dev → 1.23.4-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.
- package/distTs/detect-rules.json +351 -0
- package/distTs/package.json +3 -1
- package/distTs/src/api/client.js +156 -0
- package/distTs/src/cliIndex.js +4 -0
- package/distTs/src/command/artifact/list.js +1 -6
- package/distTs/src/command/distro/route/update.js +1 -1
- package/distTs/src/command/distro/update.js +9 -9
- package/distTs/src/command/environment/create.js +70 -0
- package/distTs/src/command/environment/delete.js +29 -0
- package/distTs/src/command/environment/get.js +48 -0
- package/distTs/src/command/environment/list.js +44 -0
- package/distTs/src/command/environment/resolve.js +22 -0
- package/distTs/src/command/environment/update.js +59 -0
- package/distTs/src/command/environment.js +20 -0
- package/distTs/src/command/pipeline/run/apply.js +62 -0
- package/distTs/src/command/target/create.js +33 -0
- package/distTs/src/command/target/delete.js +30 -0
- package/distTs/src/command/target/exec/command.js +65 -0
- package/distTs/src/command/target/exec/kill.js +25 -0
- package/distTs/src/command/target/exec/list.js +54 -0
- package/distTs/src/command/target/exec/logs.js +25 -0
- package/distTs/src/command/target/exec/status.js +41 -0
- package/distTs/src/command/target/exec.js +24 -0
- package/distTs/src/command/target/get.js +62 -0
- package/distTs/src/command/target/list.js +48 -0
- package/distTs/src/command/target/scope.js +60 -0
- package/distTs/src/command/target/update.js +31 -0
- package/distTs/src/command/target.js +22 -0
- package/distTs/src/command/yaml/actions/detect.js +268 -0
- package/distTs/src/command/yaml/actions/info.js +56 -0
- package/distTs/src/command/yaml/actions/list.js +70 -0
- package/distTs/src/command/yaml/actions/schema.js +104 -0
- package/distTs/src/command/yaml/actions.js +13 -0
- package/distTs/src/command/yaml/agents.js +88 -0
- package/distTs/src/command/yaml/cache.js +98 -0
- package/distTs/src/command/yaml/init.js +110 -0
- package/distTs/src/command/yaml/pipeline.js +42 -0
- package/distTs/src/command/yaml/render.js +83 -0
- package/distTs/src/command/yaml/schemaUtils.js +139 -0
- package/distTs/src/command/yaml/validate.js +259 -0
- package/distTs/src/command/yaml.js +18 -0
- package/distTs/src/diskCache.js +82 -0
- package/distTs/src/input.js +54 -0
- package/distTs/src/texts.js +196 -8
- package/distTs/src/utils.js +16 -2
- package/package.json +3 -1
- package/distTs/README.md +0 -181
- package/distTs/src/command/project/get.js +0 -18
- package/distTs/src/command/project/set.js +0 -31
- package/distTs/src/command/sandbox/get/yaml.js +0 -30
- package/distTs/src/command/vt/scrape.js +0 -193
|
@@ -0,0 +1,29 @@
|
|
|
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 resolve_1 = require("./resolve");
|
|
11
|
+
const commandEnvironmentDelete = (0, utils_1.newCommand)('delete', texts_1.DESC_COMMAND_ENVIRONMENT_DELETE);
|
|
12
|
+
commandEnvironmentDelete.alias('rm');
|
|
13
|
+
commandEnvironmentDelete.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
14
|
+
commandEnvironmentDelete.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
|
|
15
|
+
commandEnvironmentDelete.option('-f, --force', texts_1.OPTION_CONFIRM_FORCE);
|
|
16
|
+
commandEnvironmentDelete.argument('<identifier>', texts_1.OPTION_ENVIRONMENT_IDENTIFIER);
|
|
17
|
+
commandEnvironmentDelete.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_ENVIRONMENT_DELETE}`);
|
|
18
|
+
commandEnvironmentDelete.action(async (identifier, options) => {
|
|
19
|
+
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
20
|
+
const client = input_1.default.restApiTokenClient();
|
|
21
|
+
const environment_id = await (0, resolve_1.resolveEnvironmentId)(client, workspace, identifier, options);
|
|
22
|
+
const confirmed = options.force ||
|
|
23
|
+
(await output_1.default.confirm((0, texts_1.TXT_ENVIRONMENT_DELETE_CONFIRM)(identifier)));
|
|
24
|
+
if (!confirmed)
|
|
25
|
+
output_1.default.exitNormal();
|
|
26
|
+
await client.deleteEnvironment(workspace, environment_id);
|
|
27
|
+
output_1.default.exitSuccess((0, texts_1.TXT_ENVIRONMENT_DELETED)(identifier));
|
|
28
|
+
});
|
|
29
|
+
exports.default = commandEnvironmentDelete;
|
|
@@ -0,0 +1,48 @@
|
|
|
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 resolve_1 = require("./resolve");
|
|
11
|
+
const commandEnvironmentGet = (0, utils_1.newCommand)('get', texts_1.DESC_COMMAND_ENVIRONMENT_GET);
|
|
12
|
+
commandEnvironmentGet.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
13
|
+
commandEnvironmentGet.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
|
|
14
|
+
commandEnvironmentGet.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
15
|
+
commandEnvironmentGet.argument('<identifier>', texts_1.OPTION_ENVIRONMENT_IDENTIFIER);
|
|
16
|
+
commandEnvironmentGet.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_ENVIRONMENT_GET}`);
|
|
17
|
+
commandEnvironmentGet.action(async (identifier, options) => {
|
|
18
|
+
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
19
|
+
const client = input_1.default.restApiTokenClient();
|
|
20
|
+
const environment_id = await (0, resolve_1.resolveEnvironmentId)(client, workspace, identifier, options);
|
|
21
|
+
const environment = await client.getEnvironment(workspace, environment_id);
|
|
22
|
+
if (options.format === 'json') {
|
|
23
|
+
output_1.default.json(environment);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
const data = [
|
|
27
|
+
['Field', 'Value'],
|
|
28
|
+
['ID', environment.id || '-'],
|
|
29
|
+
['Identifier', environment.identifier || '-'],
|
|
30
|
+
['Name', environment.name || '-'],
|
|
31
|
+
['Scope', environment.scope || '-'],
|
|
32
|
+
['Tags', (environment.tags || []).join(', ') || '-'],
|
|
33
|
+
['Public URL', environment.public_url || '-'],
|
|
34
|
+
['Icon', environment.icon || '-'],
|
|
35
|
+
['Note', environment.note || '-'],
|
|
36
|
+
['Agent note', environment.agent_note || '-'],
|
|
37
|
+
];
|
|
38
|
+
if (environment.project) {
|
|
39
|
+
data.push(['Project', environment.project.name || '-']);
|
|
40
|
+
}
|
|
41
|
+
if (environment.html_url) {
|
|
42
|
+
data.push(['URL', environment.html_url]);
|
|
43
|
+
}
|
|
44
|
+
output_1.default.table(data);
|
|
45
|
+
}
|
|
46
|
+
output_1.default.exitNormal();
|
|
47
|
+
});
|
|
48
|
+
exports.default = commandEnvironmentGet;
|
|
@@ -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 output_1 = __importDefault(require("../../output"));
|
|
9
|
+
const input_1 = __importDefault(require("../../input"));
|
|
10
|
+
const distro_1 = require("../../types/distro");
|
|
11
|
+
const commandEnvironmentList = (0, utils_1.newCommand)('list', texts_1.DESC_COMMAND_ENVIRONMENT_LIST);
|
|
12
|
+
commandEnvironmentList.alias('ls');
|
|
13
|
+
commandEnvironmentList.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
14
|
+
commandEnvironmentList.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
|
|
15
|
+
commandEnvironmentList.option('--scope <scope>', texts_1.OPT_COMMAND_SCOPE);
|
|
16
|
+
commandEnvironmentList.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
17
|
+
commandEnvironmentList.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_ENVIRONMENT_LIST}`);
|
|
18
|
+
commandEnvironmentList.action(async (options) => {
|
|
19
|
+
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
20
|
+
const project = input_1.default.restApiProject(options.project, true);
|
|
21
|
+
const scope = input_1.default.scope(project, options.scope);
|
|
22
|
+
const client = input_1.default.restApiTokenClient();
|
|
23
|
+
const result = await client.getEnvironments(workspace, scope === distro_1.SCOPE.PROJECT ? project : null);
|
|
24
|
+
const environments = result.environments || [];
|
|
25
|
+
if (options.format === 'json') {
|
|
26
|
+
output_1.default.json(environments);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
if (environments.length === 0) {
|
|
30
|
+
output_1.default.exitNormal(texts_1.TXT_ENVIRONMENT_NOT_FOUND);
|
|
31
|
+
}
|
|
32
|
+
const data = [['NAME', 'IDENTIFIER', 'SCOPE']];
|
|
33
|
+
for (const environment of environments) {
|
|
34
|
+
data.push([
|
|
35
|
+
environment.name || '-',
|
|
36
|
+
environment.identifier || '-',
|
|
37
|
+
environment.scope || '-',
|
|
38
|
+
]);
|
|
39
|
+
}
|
|
40
|
+
output_1.default.table(data);
|
|
41
|
+
}
|
|
42
|
+
output_1.default.exitNormal();
|
|
43
|
+
});
|
|
44
|
+
exports.default = commandEnvironmentList;
|
|
@@ -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
|
+
exports.resolveEnvironmentId = void 0;
|
|
7
|
+
const texts_1 = require("../../texts");
|
|
8
|
+
const output_1 = __importDefault(require("../../output"));
|
|
9
|
+
const input_1 = __importDefault(require("../../input"));
|
|
10
|
+
// Shared resolve preamble for commands taking an environment identifier:
|
|
11
|
+
// project context from flags/env -> /identifiers -> hash id, exiting on a
|
|
12
|
+
// miss. Without a project the identifier resolves as a workspace
|
|
13
|
+
// environment; with one, along the project line.
|
|
14
|
+
const resolveEnvironmentId = async (client, workspace, identifier, options) => {
|
|
15
|
+
const project = input_1.default.restApiProject(options.project, true);
|
|
16
|
+
const { environment_id } = await client.getEnvironmentByIdentifier(workspace, identifier, project);
|
|
17
|
+
if (!environment_id) {
|
|
18
|
+
output_1.default.exitError(texts_1.ERR_ENVIRONMENT_NOT_FOUND);
|
|
19
|
+
}
|
|
20
|
+
return environment_id;
|
|
21
|
+
};
|
|
22
|
+
exports.resolveEnvironmentId = resolveEnvironmentId;
|
|
@@ -0,0 +1,59 @@
|
|
|
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 resolve_1 = require("./resolve");
|
|
11
|
+
const commandEnvironmentUpdate = (0, utils_1.newCommand)('update', texts_1.DESC_COMMAND_ENVIRONMENT_UPDATE);
|
|
12
|
+
commandEnvironmentUpdate.alias('edit');
|
|
13
|
+
commandEnvironmentUpdate.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
14
|
+
commandEnvironmentUpdate.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
|
|
15
|
+
commandEnvironmentUpdate.option('-n, --name <name>', texts_1.OPTION_ENVIRONMENT_NAME);
|
|
16
|
+
commandEnvironmentUpdate.option('--tags <tags>', texts_1.OPTION_ENVIRONMENT_TAGS);
|
|
17
|
+
commandEnvironmentUpdate.option('--public-url <url>', texts_1.OPTION_ENVIRONMENT_PUBLIC_URL);
|
|
18
|
+
commandEnvironmentUpdate.option('--icon <icon>', texts_1.OPTION_ENVIRONMENT_ICON);
|
|
19
|
+
commandEnvironmentUpdate.option('--note <note>', texts_1.OPT_COMMAND_NOTE);
|
|
20
|
+
commandEnvironmentUpdate.option('--agent-note <note>', texts_1.OPT_COMMAND_AGENT_NOTE);
|
|
21
|
+
commandEnvironmentUpdate.argument('<identifier>', texts_1.OPTION_ENVIRONMENT_IDENTIFIER);
|
|
22
|
+
commandEnvironmentUpdate.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_ENVIRONMENT_UPDATE}`);
|
|
23
|
+
commandEnvironmentUpdate.action(async (identifier, options) => {
|
|
24
|
+
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
25
|
+
const body = {};
|
|
26
|
+
let changed = false;
|
|
27
|
+
if (options.name) {
|
|
28
|
+
body.name = options.name;
|
|
29
|
+
changed = true;
|
|
30
|
+
}
|
|
31
|
+
if (options.tags !== undefined) {
|
|
32
|
+
body.tags = input_1.default.tags(options.tags);
|
|
33
|
+
changed = true;
|
|
34
|
+
}
|
|
35
|
+
if (options.publicUrl !== undefined) {
|
|
36
|
+
body.public_url = options.publicUrl;
|
|
37
|
+
changed = true;
|
|
38
|
+
}
|
|
39
|
+
if (options.icon) {
|
|
40
|
+
body.icon = options.icon;
|
|
41
|
+
changed = true;
|
|
42
|
+
}
|
|
43
|
+
if (options.note !== undefined) {
|
|
44
|
+
body.note = options.note;
|
|
45
|
+
changed = true;
|
|
46
|
+
}
|
|
47
|
+
if (options.agentNote !== undefined) {
|
|
48
|
+
body.agent_note = options.agentNote;
|
|
49
|
+
changed = true;
|
|
50
|
+
}
|
|
51
|
+
if (!changed) {
|
|
52
|
+
output_1.default.exitError(texts_1.ERR_COMMAND_NO_UPDATE);
|
|
53
|
+
}
|
|
54
|
+
const client = input_1.default.restApiTokenClient();
|
|
55
|
+
const environment_id = await (0, resolve_1.resolveEnvironmentId)(client, workspace, identifier, options);
|
|
56
|
+
const result = await client.updateEnvironment(workspace, environment_id, body);
|
|
57
|
+
output_1.default.exitSuccess((0, texts_1.TXT_ENVIRONMENT_UPDATED)(result.identifier, result.html_url));
|
|
58
|
+
});
|
|
59
|
+
exports.default = commandEnvironmentUpdate;
|
|
@@ -0,0 +1,20 @@
|
|
|
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("./environment/list"));
|
|
9
|
+
const get_1 = __importDefault(require("./environment/get"));
|
|
10
|
+
const create_1 = __importDefault(require("./environment/create"));
|
|
11
|
+
const update_1 = __importDefault(require("./environment/update"));
|
|
12
|
+
const delete_1 = __importDefault(require("./environment/delete"));
|
|
13
|
+
const commandEnvironment = (0, utils_1.newCommand)('environment', texts_1.DESC_COMMAND_ENVIRONMENT);
|
|
14
|
+
commandEnvironment.alias('env');
|
|
15
|
+
commandEnvironment.addCommand(list_1.default);
|
|
16
|
+
commandEnvironment.addCommand(get_1.default);
|
|
17
|
+
commandEnvironment.addCommand(create_1.default);
|
|
18
|
+
commandEnvironment.addCommand(update_1.default);
|
|
19
|
+
commandEnvironment.addCommand(delete_1.default);
|
|
20
|
+
exports.default = commandEnvironment;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("../../../utils");
|
|
7
|
+
const texts_1 = require("../../../texts");
|
|
8
|
+
const input_1 = __importDefault(require("../../../input"));
|
|
9
|
+
const output_1 = __importDefault(require("../../../output"));
|
|
10
|
+
const pipeline_1 = require("../../../types/pipeline");
|
|
11
|
+
const commandPipelineRunApply = (0, utils_1.newCommand)('apply', texts_1.DESC_COMMAND_PIPELINE_RUN_APPLY);
|
|
12
|
+
commandPipelineRunApply.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
13
|
+
commandPipelineRunApply.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
|
|
14
|
+
commandPipelineRunApply.option('-n, --no-wait', texts_1.OPTION_PIPELINE_RUN_NO_WAIT);
|
|
15
|
+
commandPipelineRunApply.argument('<identifier>', texts_1.OPTION_PIPELINE_RUN_ARGUMENT);
|
|
16
|
+
commandPipelineRunApply.argument('<run-id>', texts_1.OPTION_PIPELINE_RUN_ID);
|
|
17
|
+
commandPipelineRunApply.argument('<run-action-id>', texts_1.OPTION_PIPELINE_RUN_ACTION_ID);
|
|
18
|
+
commandPipelineRunApply.option('-v,--variable <variables...>', texts_1.OPTION_PIPELINE_RUN_VAR);
|
|
19
|
+
commandPipelineRunApply.addHelpText('after', texts_1.EXAMPLE_PIPELINE_RUN_APPLY);
|
|
20
|
+
commandPipelineRunApply.action(async (identifier, runId, runActionId, options) => {
|
|
21
|
+
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
22
|
+
const project = input_1.default.restApiProject(options.project);
|
|
23
|
+
const rid = input_1.default.pipelineRunId(runId);
|
|
24
|
+
const variables = input_1.default.pipelineRunVariable(options.variable || [], false);
|
|
25
|
+
const client = input_1.default.restApiTokenClient();
|
|
26
|
+
const data = await client.getPipelineByIdentifier(workspace, project, identifier);
|
|
27
|
+
if (!data || !data.domain) {
|
|
28
|
+
output_1.default.exitError(texts_1.ERR_WORKSPACE_NOT_FOUND);
|
|
29
|
+
}
|
|
30
|
+
if (!data.project_identifier) {
|
|
31
|
+
output_1.default.exitError(texts_1.ERR_PROJECT_NOT_FOUND);
|
|
32
|
+
}
|
|
33
|
+
if (!data.pipeline_id) {
|
|
34
|
+
output_1.default.exitError(texts_1.ERR_PIPELINE_NOT_FOUND);
|
|
35
|
+
}
|
|
36
|
+
const a = await client.getPipelineRunActionExecution(workspace, project, data.pipeline_id, rid, runActionId);
|
|
37
|
+
let type;
|
|
38
|
+
if (a.status === pipeline_1.PIPELINE_RUN_STATUS.WAITING_FOR_APPLY) {
|
|
39
|
+
type = 'APPLY';
|
|
40
|
+
}
|
|
41
|
+
else if (a.status === pipeline_1.PIPELINE_RUN_STATUS.WAITING_FOR_VT_SESSION) {
|
|
42
|
+
type = 'APPROVE_VT';
|
|
43
|
+
}
|
|
44
|
+
else if (a.status === pipeline_1.PIPELINE_RUN_STATUS.WAITING_FOR_VARIABLES) {
|
|
45
|
+
type = 'APPLY_VARIABLES';
|
|
46
|
+
}
|
|
47
|
+
else if (a.status === pipeline_1.PIPELINE_RUN_STATUS.WAITING_FOR_SETTABLE_VARIABLES) {
|
|
48
|
+
type = 'SET_VARIABLES';
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
output_1.default.exitError(texts_1.ERR_CANT_APPLY_ACTION_EXECUTION);
|
|
52
|
+
}
|
|
53
|
+
const body = {
|
|
54
|
+
operation: type,
|
|
55
|
+
approve_action_id: runActionId,
|
|
56
|
+
variables,
|
|
57
|
+
};
|
|
58
|
+
await client.pipelineRunApply(workspace, project, data.pipeline_id, rid, body);
|
|
59
|
+
const OutputPipeline = require('../../../output/pipeline').default;
|
|
60
|
+
await OutputPipeline.runStatus(client, workspace, project, data.pipeline_id, rid, !options.wait);
|
|
61
|
+
});
|
|
62
|
+
exports.default = commandPipelineRunApply;
|
|
@@ -0,0 +1,33 @@
|
|
|
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;
|
|
@@ -0,0 +1,30 @@
|
|
|
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;
|
|
@@ -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 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;
|
|
@@ -0,0 +1,25 @@
|
|
|
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;
|
|
@@ -0,0 +1,54 @@
|
|
|
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;
|
|
@@ -0,0 +1,25 @@
|
|
|
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;
|
|
@@ -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 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;
|
|
@@ -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;
|