bdy 1.22.94-dev → 1.22.94-master
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/distTs/package.json
CHANGED
|
@@ -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 distro_1 = require("../../types/distro");
|
|
11
|
+
const commandDistroGet = (0, utils_1.newCommand)('get', texts_1.DESC_COMMAND_DISTRO_GET);
|
|
12
|
+
commandDistroGet.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
13
|
+
commandDistroGet.option('--scope <scope>', texts_1.OPT_COMMAND_SCOPE);
|
|
14
|
+
commandDistroGet.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
|
|
15
|
+
commandDistroGet.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
16
|
+
commandDistroGet.argument('<identifier>', texts_1.OPT_COMMAND_DISTRO_IDENTIFIER);
|
|
17
|
+
commandDistroGet.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_DISTRO_GET}`);
|
|
18
|
+
commandDistroGet.action(async (identifier, 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 data = await client.getDistributionByIdentifier(workspace, scope === distro_1.SCOPE.PROJECT ? project : null, identifier);
|
|
24
|
+
if (!data || !data.domain) {
|
|
25
|
+
output_1.default.exitError(texts_1.ERR_WORKSPACE_NOT_FOUND);
|
|
26
|
+
}
|
|
27
|
+
if (!data || !data.distribution_id) {
|
|
28
|
+
output_1.default.exitError(texts_1.ERR_COMMAND_DISTRO_NOT_FOUND);
|
|
29
|
+
}
|
|
30
|
+
const distro = await client.getDistribution(workspace, scope === distro_1.SCOPE.PROJECT ? project : null, data.distribution_id);
|
|
31
|
+
if (options.format === 'json') {
|
|
32
|
+
output_1.default.json(distro);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
const table = [
|
|
36
|
+
['Field', 'Value'],
|
|
37
|
+
['ID', String(distro.id || '-')],
|
|
38
|
+
['Identifier', distro.identifier || '-'],
|
|
39
|
+
['Name', distro.name || '-'],
|
|
40
|
+
['Note', distro.note || '-'],
|
|
41
|
+
['Agent note', distro.agent_note || '-'],
|
|
42
|
+
['Scope', distro.scope || '-'],
|
|
43
|
+
['Disabled', distro.disabled ? 'true' : 'false'],
|
|
44
|
+
['Project', distro.project?.name || '-'],
|
|
45
|
+
['Environment', distro.environment?.name || '-'],
|
|
46
|
+
['Routes', String((distro.routes || []).length)],
|
|
47
|
+
['URL', distro.html_url || '-'],
|
|
48
|
+
];
|
|
49
|
+
output_1.default.table(table);
|
|
50
|
+
}
|
|
51
|
+
output_1.default.exitNormal();
|
|
52
|
+
});
|
|
53
|
+
exports.default = commandDistroGet;
|
|
@@ -0,0 +1,71 @@
|
|
|
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 distro_1 = require("../../../types/distro");
|
|
11
|
+
const targetText = (target) => {
|
|
12
|
+
if (target.type === distro_1.ROUTE_TARGET_TYPE.ARTIFACT && target.artifact) {
|
|
13
|
+
return `artifact ${target.artifact.id}:${target.artifact.version_id}`;
|
|
14
|
+
}
|
|
15
|
+
if (target.type === distro_1.ROUTE_TARGET_TYPE.SANDBOX && target.sandbox) {
|
|
16
|
+
return `sandbox ${target.sandbox.id}:${target.sandbox.endpoint}`;
|
|
17
|
+
}
|
|
18
|
+
return target.external_url || '-';
|
|
19
|
+
};
|
|
20
|
+
const commandDistroRouteGet = (0, utils_1.newCommand)('get', texts_1.DESC_COMMAND_ROUTE_GET);
|
|
21
|
+
commandDistroRouteGet.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
22
|
+
commandDistroRouteGet.option('--scope <scope>', texts_1.OPT_COMMAND_SCOPE);
|
|
23
|
+
commandDistroRouteGet.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
|
|
24
|
+
commandDistroRouteGet.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
25
|
+
commandDistroRouteGet.argument('<identifier>', texts_1.OPT_COMMAND_DISTRO_IDENTIFIER);
|
|
26
|
+
commandDistroRouteGet.argument('<route-id>', texts_1.OPT_COMMAND_ROUTE_ID);
|
|
27
|
+
commandDistroRouteGet.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_ROUTE_GET}`);
|
|
28
|
+
commandDistroRouteGet.action(async (identifier, routeId, options) => {
|
|
29
|
+
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
30
|
+
const project = input_1.default.restApiProject(options.project, true);
|
|
31
|
+
const scope = input_1.default.scope(project, options.scope);
|
|
32
|
+
const client = input_1.default.restApiTokenClient();
|
|
33
|
+
const data = await client.getDistributionByIdentifier(workspace, scope === distro_1.SCOPE.PROJECT ? project : null, identifier);
|
|
34
|
+
if (!data?.domain) {
|
|
35
|
+
output_1.default.exitError(texts_1.ERR_WORKSPACE_NOT_FOUND);
|
|
36
|
+
}
|
|
37
|
+
if (!data?.distribution_id) {
|
|
38
|
+
output_1.default.exitError(texts_1.ERR_COMMAND_DISTRO_NOT_FOUND);
|
|
39
|
+
}
|
|
40
|
+
const route = await client.getRoute(workspace, scope === distro_1.SCOPE.PROJECT ? project : null, data.distribution_id, routeId);
|
|
41
|
+
if (options.format === 'json') {
|
|
42
|
+
output_1.default.json(route);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
const table = [
|
|
46
|
+
['Field', 'Value'],
|
|
47
|
+
['ID', String(route.id || '-')],
|
|
48
|
+
['Type', route.type || '-'],
|
|
49
|
+
['Note', route.note || '-'],
|
|
50
|
+
['Agent note', route.agent_note || '-'],
|
|
51
|
+
['Subdomain', route.subdomain || '-'],
|
|
52
|
+
['Domain', route.domain || '-'],
|
|
53
|
+
['Path', route.path || '-'],
|
|
54
|
+
['Zone type', route.zone_type || '-'],
|
|
55
|
+
['URL', route.html_url || '-'],
|
|
56
|
+
];
|
|
57
|
+
const targets = route.targets || {};
|
|
58
|
+
const regions = Object.keys(targets);
|
|
59
|
+
if (regions.length > 0) {
|
|
60
|
+
table.push([
|
|
61
|
+
'Targets',
|
|
62
|
+
regions
|
|
63
|
+
.map((region) => `${region}: ${targetText(targets[region])}`)
|
|
64
|
+
.join('\n'),
|
|
65
|
+
]);
|
|
66
|
+
}
|
|
67
|
+
output_1.default.table(table);
|
|
68
|
+
}
|
|
69
|
+
output_1.default.exitNormal();
|
|
70
|
+
});
|
|
71
|
+
exports.default = commandDistroRouteGet;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("../../utils");
|
|
7
|
+
const texts_1 = require("../../texts");
|
|
8
|
+
const input_1 = __importDefault(require("../../input"));
|
|
9
|
+
const output_1 = __importDefault(require("../../output"));
|
|
10
|
+
const distro_1 = require("../../types/distro");
|
|
11
|
+
const commandDistroUpdate = (0, utils_1.newCommand)('update', texts_1.DESC_COMMAND_DISTRO_UPDATE);
|
|
12
|
+
commandDistroUpdate.alias('edit');
|
|
13
|
+
commandDistroUpdate.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
14
|
+
commandDistroUpdate.option('--scope <scope>', texts_1.OPT_COMMAND_SCOPE);
|
|
15
|
+
commandDistroUpdate.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
|
|
16
|
+
commandDistroUpdate.option('-n, --name <name>', texts_1.OPT_COMMAND_DISTRO_NAME);
|
|
17
|
+
commandDistroUpdate.option('--note <note>', texts_1.OPT_COMMAND_DISTRO_NOTE);
|
|
18
|
+
commandDistroUpdate.option('--agent-note <note>', texts_1.OPT_COMMAND_DISTRO_AGENT_NOTE);
|
|
19
|
+
commandDistroUpdate.option('--enable', texts_1.OPT_COMMAND_DISTRO_ENABLE);
|
|
20
|
+
commandDistroUpdate.option('--disable', texts_1.OPT_COMMAND_DISTRO_DISABLE);
|
|
21
|
+
commandDistroUpdate.argument('<identifier>', texts_1.OPT_COMMAND_DISTRO_IDENTIFIER);
|
|
22
|
+
commandDistroUpdate.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_DISTRO_UPDATE}`);
|
|
23
|
+
commandDistroUpdate.action(async (identifier, options) => {
|
|
24
|
+
if (options.enable && options.disable) {
|
|
25
|
+
output_1.default.exitError(texts_1.ERR_COMMAND_DISTRO_ENABLE_DISABLE);
|
|
26
|
+
}
|
|
27
|
+
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
28
|
+
const project = input_1.default.restApiProject(options.project, true);
|
|
29
|
+
const scope = input_1.default.scope(project, options.scope);
|
|
30
|
+
const client = input_1.default.restApiTokenClient();
|
|
31
|
+
const data = await client.getDistributionByIdentifier(workspace, scope === distro_1.SCOPE.PROJECT ? project : null, identifier);
|
|
32
|
+
if (!data || !data.domain) {
|
|
33
|
+
output_1.default.exitError(texts_1.ERR_WORKSPACE_NOT_FOUND);
|
|
34
|
+
}
|
|
35
|
+
if (!data || !data.distribution_id) {
|
|
36
|
+
output_1.default.exitError(texts_1.ERR_COMMAND_DISTRO_NOT_FOUND);
|
|
37
|
+
}
|
|
38
|
+
const body = {};
|
|
39
|
+
let changed = false;
|
|
40
|
+
if (options.name) {
|
|
41
|
+
body.name = options.name;
|
|
42
|
+
changed = true;
|
|
43
|
+
}
|
|
44
|
+
if (options.note !== undefined) {
|
|
45
|
+
body.note = options.note;
|
|
46
|
+
changed = true;
|
|
47
|
+
}
|
|
48
|
+
if (options.agentNote !== undefined) {
|
|
49
|
+
body.agent_note = options.agentNote;
|
|
50
|
+
changed = true;
|
|
51
|
+
}
|
|
52
|
+
if (options.enable || options.disable) {
|
|
53
|
+
body.disabled = !!options.disable;
|
|
54
|
+
changed = true;
|
|
55
|
+
}
|
|
56
|
+
if (!changed) {
|
|
57
|
+
output_1.default.exitError(texts_1.ERR_COMMAND_DISTRO_NO_UPDATE);
|
|
58
|
+
}
|
|
59
|
+
const result = await client.updateDistribution(workspace, scope === distro_1.SCOPE.PROJECT ? project : null, data.distribution_id, body);
|
|
60
|
+
output_1.default.identifier(result.identifier);
|
|
61
|
+
output_1.default.cyan(result.html_url);
|
|
62
|
+
output_1.default.green(texts_1.TXT_COMMAND_DISTRO_UPDATED);
|
|
63
|
+
output_1.default.exitNormal();
|
|
64
|
+
});
|
|
65
|
+
exports.default = commandDistroUpdate;
|