bdy 1.22.43-dev → 1.22.44-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.
- package/distTs/package.json +3 -2
- package/distTs/src/api/client.js +73 -2
- package/distTs/src/cliIndex.js +2 -0
- package/distTs/src/command/artifact/get.js +16 -9
- package/distTs/src/command/artifact/list.js +23 -8
- package/distTs/src/command/artifact/version/get.js +20 -13
- package/distTs/src/command/artifact/version/list.js +19 -12
- package/distTs/src/command/distro/create.js +40 -0
- package/distTs/src/command/distro/delete.js +38 -0
- package/distTs/src/command/distro/list.js +42 -0
- package/distTs/src/command/distro/route/create.js +50 -0
- package/distTs/src/command/distro/route/delete.js +39 -0
- package/distTs/src/command/distro/route/list.js +54 -0
- package/distTs/src/command/distro/route.js +18 -0
- package/distTs/src/command/distro.js +23 -0
- package/distTs/src/command/domain/buy.js +27 -8
- package/distTs/src/command/domain/get.js +17 -11
- package/distTs/src/command/domain/list.js +13 -6
- package/distTs/src/command/login.js +1 -0
- package/distTs/src/command/pipeline/list.js +1 -1
- package/distTs/src/command/project/list.js +13 -6
- package/distTs/src/command/sandbox/app/list.js +13 -7
- package/distTs/src/command/sandbox/app/status.js +10 -4
- package/distTs/src/command/sandbox/endpoint/get.js +61 -52
- package/distTs/src/command/sandbox/endpoint/list.js +18 -12
- package/distTs/src/command/sandbox/exec/list.js +22 -16
- package/distTs/src/command/sandbox/exec/status.js +18 -9
- package/distTs/src/command/sandbox/get.js +26 -18
- package/distTs/src/command/sandbox/list.js +21 -15
- package/distTs/src/command/sandbox/snapshot/get.js +19 -13
- package/distTs/src/command/sandbox/snapshot/list.js +17 -11
- package/distTs/src/command/sandbox/status.js +11 -5
- package/distTs/src/command/whoami.js +17 -8
- package/distTs/src/command/workspace/list.js +14 -8
- package/distTs/src/input.js +180 -1
- package/distTs/src/output.js +16 -6
- package/distTs/src/texts.js +86 -6
- package/distTs/src/types/distro.js +232 -0
- package/package.json +3 -2
package/distTs/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bdy",
|
|
3
3
|
"preferGlobal": false,
|
|
4
|
-
"version": "1.22.
|
|
4
|
+
"version": "1.22.44-dev",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"scripts": {
|
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
"e2e:api": "vitest run --config e2e/vitest.config.ts e2e/modules/api/",
|
|
21
21
|
"e2e:pipeline": "vitest run --config e2e/vitest.config.ts e2e/modules/pipeline/",
|
|
22
22
|
"e2e:tunnel": "vitest run --config e2e/vitest.config.ts e2e/modules/tunnel/",
|
|
23
|
-
"e2e:agent": "vitest run --config e2e/vitest.config.ts e2e/modules/agent/"
|
|
23
|
+
"e2e:agent": "vitest run --config e2e/vitest.config.ts e2e/modules/agent/",
|
|
24
|
+
"e2e:distro": "vitest run --config e2e/vitest.config.ts e2e/modules/distro/"
|
|
24
25
|
},
|
|
25
26
|
"files": [
|
|
26
27
|
"distTs"
|
package/distTs/src/api/client.js
CHANGED
|
@@ -240,7 +240,7 @@ class ApiClient {
|
|
|
240
240
|
method: 'PATCH',
|
|
241
241
|
path: `/workspaces/${encodeURIComponent(workspace)}/projects/${encodeURIComponent(project)}/pipelines/${encodeURIComponent(pipelineId)}/yaml`,
|
|
242
242
|
body,
|
|
243
|
-
parseResponseBody: true
|
|
243
|
+
parseResponseBody: true,
|
|
244
244
|
});
|
|
245
245
|
}
|
|
246
246
|
async createPipeline(workspace, project, body) {
|
|
@@ -248,7 +248,7 @@ class ApiClient {
|
|
|
248
248
|
method: 'POST',
|
|
249
249
|
path: `/workspaces/${encodeURIComponent(workspace)}/projects/${encodeURIComponent(project)}/pipelines`,
|
|
250
250
|
body,
|
|
251
|
-
parseResponseBody: true
|
|
251
|
+
parseResponseBody: true,
|
|
252
252
|
});
|
|
253
253
|
}
|
|
254
254
|
async getPipelines(workspace, project, page = 1, perPage = 10) {
|
|
@@ -438,6 +438,77 @@ class ApiClient {
|
|
|
438
438
|
parseResponseBody: false,
|
|
439
439
|
});
|
|
440
440
|
}
|
|
441
|
+
// Distro methods
|
|
442
|
+
async createDistro(workspace, body) {
|
|
443
|
+
return await this.request({
|
|
444
|
+
method: 'POST',
|
|
445
|
+
path: `/workspaces/${encodeURIComponent(workspace)}/distributions`,
|
|
446
|
+
body,
|
|
447
|
+
parseResponseBody: true,
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
async deleteRoute(workspace, project, distributionId, routeId) {
|
|
451
|
+
const query = {};
|
|
452
|
+
if (project)
|
|
453
|
+
query.project_name = project;
|
|
454
|
+
return await this.request({
|
|
455
|
+
method: 'DELETE',
|
|
456
|
+
path: `/workspaces/${encodeURIComponent(workspace)}/distributions/${encodeURIComponent(distributionId)}/routes/${encodeURIComponent(routeId)}`,
|
|
457
|
+
query
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
async listRoutes(workspace, project, distributionId) {
|
|
461
|
+
const query = {};
|
|
462
|
+
if (project)
|
|
463
|
+
query.project_name = project;
|
|
464
|
+
return await this.request({
|
|
465
|
+
method: 'GET',
|
|
466
|
+
path: `/workspaces/${encodeURIComponent(workspace)}/distributions/${encodeURIComponent(distributionId)}/routes`,
|
|
467
|
+
query,
|
|
468
|
+
parseResponseBody: true
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
async createRoute(workspace, project, distributionId, body) {
|
|
472
|
+
const query = {};
|
|
473
|
+
if (project)
|
|
474
|
+
query.project_name = project;
|
|
475
|
+
return await this.request({
|
|
476
|
+
method: 'POST',
|
|
477
|
+
path: `/workspaces/${encodeURIComponent(workspace)}/distributions/${encodeURIComponent(distributionId)}/routes`,
|
|
478
|
+
query,
|
|
479
|
+
body,
|
|
480
|
+
parseResponseBody: true,
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
async deleteDistribution(workspace, project, distributionId) {
|
|
484
|
+
const query = {};
|
|
485
|
+
if (project)
|
|
486
|
+
query.project_name = project;
|
|
487
|
+
return await this.request({
|
|
488
|
+
method: 'DELETE',
|
|
489
|
+
path: `/workspaces/${encodeURIComponent(workspace)}/distributions/${encodeURIComponent(distributionId)}`,
|
|
490
|
+
query,
|
|
491
|
+
});
|
|
492
|
+
}
|
|
493
|
+
async getDistributions(workspace, project) {
|
|
494
|
+
const query = {};
|
|
495
|
+
if (project)
|
|
496
|
+
query.project_name = project;
|
|
497
|
+
return await this.request({
|
|
498
|
+
method: 'GET',
|
|
499
|
+
path: `/workspaces/${encodeURIComponent(workspace)}/distributions`,
|
|
500
|
+
query,
|
|
501
|
+
parseResponseBody: true,
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
async getDistributionByIdentifier(workspace, project, identifier) {
|
|
505
|
+
const q = {
|
|
506
|
+
distribution: identifier,
|
|
507
|
+
};
|
|
508
|
+
if (project)
|
|
509
|
+
q.project = project;
|
|
510
|
+
return await this.getResourceByIdentifier(workspace, q);
|
|
511
|
+
}
|
|
441
512
|
// Sandbox methods
|
|
442
513
|
async createSandbox(workspace, project, body) {
|
|
443
514
|
return await this.request({
|
package/distTs/src/cliIndex.js
CHANGED
|
@@ -24,6 +24,7 @@ const artifact_1 = __importDefault(require("./command/artifact"));
|
|
|
24
24
|
const api_1 = __importDefault(require("./command/api"));
|
|
25
25
|
const domain_1 = __importDefault(require("./command/domain"));
|
|
26
26
|
const main_1 = __importDefault(require("./main"));
|
|
27
|
+
const distro_1 = __importDefault(require("./command/distro"));
|
|
27
28
|
function cliIndex() {
|
|
28
29
|
const program = (0, utils_1.newCommand)('', texts_1.DESC_PROGRAM);
|
|
29
30
|
program.hook('preAction', pre_1.default);
|
|
@@ -40,6 +41,7 @@ function cliIndex() {
|
|
|
40
41
|
program.addCommand(artifact_1.default);
|
|
41
42
|
program.addCommand(sandbox_1.default);
|
|
42
43
|
program.addCommand(domain_1.default);
|
|
44
|
+
program.addCommand(distro_1.default);
|
|
43
45
|
program.addCommand(login_1.default);
|
|
44
46
|
program.addCommand(whoami_1.default);
|
|
45
47
|
program.addCommand(logout_1.default);
|
|
@@ -10,6 +10,7 @@ const output_1 = __importDefault(require("../../output"));
|
|
|
10
10
|
const commandArtifactGet = (0, utils_1.newCommand)('get', texts_1.DESC_COMMAND_ARTIFACT_GET);
|
|
11
11
|
commandArtifactGet.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
12
12
|
commandArtifactGet.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
|
|
13
|
+
commandArtifactGet.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
13
14
|
commandArtifactGet.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
|
|
14
15
|
commandArtifactGet.action(async (identifier, options) => {
|
|
15
16
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
@@ -23,14 +24,20 @@ commandArtifactGet.action(async (identifier, options) => {
|
|
|
23
24
|
output_1.default.exitError(texts_1.ERR_ARTIFACT_NOT_FOUND);
|
|
24
25
|
}
|
|
25
26
|
const art = await client.getArtifact(workspace, data.artifact_id);
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
if (options.format === 'json') {
|
|
28
|
+
output_1.default.json(art);
|
|
29
|
+
output_1.default.exitNormal();
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
output_1.default.object({
|
|
33
|
+
Name: art.name,
|
|
34
|
+
Identifier: art.identifier,
|
|
35
|
+
Type: art.type,
|
|
36
|
+
Scope: art.scope,
|
|
37
|
+
Size: (0, utils_1.formatBytes)(art.size || 0),
|
|
38
|
+
Created: art.created_date,
|
|
39
|
+
});
|
|
40
|
+
output_1.default.exitNormal(`\n${(0, texts_1.TXT_ARTIFACT_PUBLISH)(client.baseUrl, workspace, art)}`);
|
|
41
|
+
}
|
|
35
42
|
});
|
|
36
43
|
exports.default = commandArtifactGet;
|
|
@@ -10,22 +10,37 @@ const input_1 = __importDefault(require("../../input"));
|
|
|
10
10
|
const commandArtifactList = (0, utils_1.newCommand)('list', texts_1.DESC_COMMAND_ARTIFACT_LIST);
|
|
11
11
|
commandArtifactList.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
12
12
|
commandArtifactList.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
|
|
13
|
+
commandArtifactList.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
13
14
|
commandArtifactList.alias('ls');
|
|
14
15
|
commandArtifactList.action(async (options) => {
|
|
15
16
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
16
17
|
const project = input_1.default.restApiProject(options.project, true);
|
|
17
18
|
const client = input_1.default.restApiTokenClient();
|
|
18
19
|
const response = await client.getArtifacts(workspace, project);
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
const artifacts = response.artifacts || [];
|
|
21
|
+
if (options.format === 'json') {
|
|
22
|
+
const filtered = project
|
|
23
|
+
? artifacts.filter((a) => a.scope !== utils_1.ARTIFACT_SCOPE.WORKSPACE)
|
|
24
|
+
: artifacts;
|
|
25
|
+
output_1.default.json(filtered);
|
|
21
26
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
data
|
|
27
|
+
else {
|
|
28
|
+
if (artifacts.length === 0) {
|
|
29
|
+
output_1.default.exitError(texts_1.ERR_COMMAND_ARTIFACT_NO_PROJECTS);
|
|
30
|
+
}
|
|
31
|
+
const data = [['NAME', 'IDENTIFIER', 'TYPE', 'URL']];
|
|
32
|
+
for (const artifact of artifacts) {
|
|
33
|
+
if (project && artifact.scope === utils_1.ARTIFACT_SCOPE.WORKSPACE)
|
|
34
|
+
continue;
|
|
35
|
+
data.push([
|
|
36
|
+
artifact.name,
|
|
37
|
+
artifact.identifier,
|
|
38
|
+
artifact.type,
|
|
39
|
+
artifact.html_url,
|
|
40
|
+
]);
|
|
41
|
+
}
|
|
42
|
+
output_1.default.table(data);
|
|
27
43
|
}
|
|
28
|
-
output_1.default.table(data);
|
|
29
44
|
output_1.default.exitNormal();
|
|
30
45
|
});
|
|
31
46
|
exports.default = commandArtifactList;
|
|
@@ -10,6 +10,7 @@ const output_1 = __importDefault(require("../../../output"));
|
|
|
10
10
|
const commandArtifactVersionGet = (0, utils_1.newCommand)('get', texts_1.DESC_COMMAND_ARTIFACT_VERSION_GET);
|
|
11
11
|
commandArtifactVersionGet.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
12
12
|
commandArtifactVersionGet.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
|
|
13
|
+
commandArtifactVersionGet.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
13
14
|
commandArtifactVersionGet.argument('<identifier>', texts_1.OPT_COMMAND_ARTIFACT_IDENTIFIER);
|
|
14
15
|
commandArtifactVersionGet.argument('<version>', texts_1.OPT_COMMAND_ARTIFACT_VERSION);
|
|
15
16
|
commandArtifactVersionGet.addHelpText('after', texts_1.EXAMPLE_ARTIFACT_VERSION_GET);
|
|
@@ -28,18 +29,24 @@ commandArtifactVersionGet.action(async (identifier, version, options) => {
|
|
|
28
29
|
output_1.default.exitError(texts_1.ERR_ARTIFACT_VERSION_NOT_FOUND);
|
|
29
30
|
}
|
|
30
31
|
const result = await client.getArtifactVersion(workspace, data.artifact_id, data.artifact_version_id);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
32
|
+
if (options.format === 'json') {
|
|
33
|
+
output_1.default.json(result);
|
|
34
|
+
output_1.default.exitNormal();
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
const obj = {
|
|
38
|
+
Version: result.version,
|
|
39
|
+
Size: (0, utils_1.formatBytes)(result.size),
|
|
40
|
+
Created: result.created_date,
|
|
41
|
+
'App url': result.html_url,
|
|
42
|
+
Url: result.version_url,
|
|
43
|
+
};
|
|
44
|
+
output_1.default.object(obj);
|
|
45
|
+
output_1.default.normal('');
|
|
46
|
+
const type = result.version_url.startsWith('https://')
|
|
47
|
+
? utils_1.ARTIFACT_TYPE.BUCKET
|
|
48
|
+
: utils_1.ARTIFACT_TYPE.CONTAINER;
|
|
49
|
+
output_1.default.exitNormal((0, texts_1.TXT_ARTIFACT_VERSION_DOWNLOAD)(type, identifier, version, result.version_url));
|
|
50
|
+
}
|
|
44
51
|
});
|
|
45
52
|
exports.default = commandArtifactVersionGet;
|
|
@@ -12,6 +12,7 @@ commandArtifactVersionList.option('-w, --workspace <domain>', texts_1.OPTION_RES
|
|
|
12
12
|
commandArtifactVersionList.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
|
|
13
13
|
commandArtifactVersionList.option('--page <number>', texts_1.OPTION_REST_API_PAGE, '1');
|
|
14
14
|
commandArtifactVersionList.option('--per-page <number>', texts_1.OPTION_REST_API_PER_PAGE, '10');
|
|
15
|
+
commandArtifactVersionList.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
15
16
|
commandArtifactVersionList.alias('ls');
|
|
16
17
|
commandArtifactVersionList.argument('<identifier>', texts_1.OPT_COMMAND_ARTIFACT_IDENTIFIER);
|
|
17
18
|
commandArtifactVersionList.addHelpText('after', texts_1.EXAMPLE_ARTIFACT_VERSION_LIST);
|
|
@@ -29,19 +30,25 @@ commandArtifactVersionList.action(async (identifier, options) => {
|
|
|
29
30
|
output_1.default.exitError(texts_1.ERR_ARTIFACT_NOT_FOUND);
|
|
30
31
|
}
|
|
31
32
|
const result = await client.getArtifactVersions(workspace, data.artifact_id, page, perPage);
|
|
32
|
-
const
|
|
33
|
-
if (
|
|
34
|
-
output_1.default.
|
|
33
|
+
const versions = result.versions || [];
|
|
34
|
+
if (options.format === 'json') {
|
|
35
|
+
output_1.default.json(versions);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
if (versions.length === 0) {
|
|
39
|
+
output_1.default.exitError(texts_1.ERR_ARTIFACT_VERSIONS_NOT_FOUND);
|
|
40
|
+
}
|
|
41
|
+
const table = [['VERSION', 'SIZE', 'CREATED', 'URL']];
|
|
42
|
+
versions.forEach((ver) => {
|
|
43
|
+
table.push([
|
|
44
|
+
ver.version,
|
|
45
|
+
(0, utils_1.formatBytes)(ver.size),
|
|
46
|
+
ver.created_date,
|
|
47
|
+
ver.version_url,
|
|
48
|
+
]);
|
|
49
|
+
});
|
|
50
|
+
output_1.default.table(table);
|
|
35
51
|
}
|
|
36
|
-
result.versions.forEach((ver) => {
|
|
37
|
-
table.push([
|
|
38
|
-
ver.version,
|
|
39
|
-
(0, utils_1.formatBytes)(ver.size),
|
|
40
|
-
ver.created_date,
|
|
41
|
-
ver.version_url,
|
|
42
|
-
]);
|
|
43
|
-
});
|
|
44
|
-
output_1.default.table(table);
|
|
45
52
|
output_1.default.exitNormal();
|
|
46
53
|
});
|
|
47
54
|
exports.default = commandArtifactVersionList;
|
|
@@ -0,0 +1,40 @@
|
|
|
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 commandDistroCreate = (0, utils_1.newCommand)('create', texts_1.DESC_COMMAND_DISTRO_CREATE);
|
|
11
|
+
commandDistroCreate.alias('add');
|
|
12
|
+
commandDistroCreate.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
13
|
+
commandDistroCreate.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
|
|
14
|
+
commandDistroCreate.option('-s, --scope <scope>', texts_1.OPT_COMMAND_DISTRO_SCOPE);
|
|
15
|
+
commandDistroCreate.option('-i, --identifier <identifier>', texts_1.OPT_COMMAND_DISTRO_IDENTIFIER);
|
|
16
|
+
commandDistroCreate.option('-n, --name <name>', texts_1.OPT_COMMAND_DISTRO_NAME);
|
|
17
|
+
commandDistroCreate.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_DISTRO_CREATE}`);
|
|
18
|
+
commandDistroCreate.action(async (options) => {
|
|
19
|
+
const humanId = require('human-id').default;
|
|
20
|
+
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
21
|
+
const project = input_1.default.restApiProject(options.project, true);
|
|
22
|
+
const client = input_1.default.restApiTokenClient();
|
|
23
|
+
const scope = input_1.default.distroScope(project, options.scope);
|
|
24
|
+
const timestamp = Date.now().toString(36);
|
|
25
|
+
const baseName = humanId({ separator: '-', capitalize: false });
|
|
26
|
+
const defaultIdentifier = `${baseName}-${timestamp}`;
|
|
27
|
+
const body = {
|
|
28
|
+
name: options.name || options.identifier || baseName,
|
|
29
|
+
identifier: options.identifier || defaultIdentifier,
|
|
30
|
+
scope,
|
|
31
|
+
};
|
|
32
|
+
if (project)
|
|
33
|
+
body.project_name = project;
|
|
34
|
+
const result = await client.createDistro(workspace, body);
|
|
35
|
+
output_1.default.identifier(result.identifier);
|
|
36
|
+
output_1.default.cyan(result.html_url);
|
|
37
|
+
output_1.default.green(texts_1.TXT_COMMAND_DISTRO_CREATED);
|
|
38
|
+
output_1.default.exitNormal();
|
|
39
|
+
});
|
|
40
|
+
exports.default = commandDistroCreate;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("../../utils");
|
|
7
|
+
const texts_1 = require("../../texts");
|
|
8
|
+
const input_1 = __importDefault(require("../../input"));
|
|
9
|
+
const output_1 = __importDefault(require("../../output"));
|
|
10
|
+
const commandDistroDelete = (0, utils_1.newCommand)('delete', texts_1.DESC_COMMAND_DISTRO_DELETE);
|
|
11
|
+
commandDistroDelete.alias('rm');
|
|
12
|
+
commandDistroDelete.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
13
|
+
commandDistroDelete.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
|
|
14
|
+
commandDistroDelete.option('-f, --force', texts_1.OPTION_CONFIRM_FORCE);
|
|
15
|
+
commandDistroDelete.argument('<identifier>', texts_1.OPT_COMMAND_DISTRO_IDENTIFIER);
|
|
16
|
+
commandDistroDelete.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_DISTRO_DELETE}`);
|
|
17
|
+
commandDistroDelete.action(async (identifier, options) => {
|
|
18
|
+
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
19
|
+
const project = input_1.default.restApiProject(options.project, true);
|
|
20
|
+
const client = input_1.default.restApiTokenClient();
|
|
21
|
+
const data = await client.getDistributionByIdentifier(workspace, project, identifier);
|
|
22
|
+
if (!data || !data.domain) {
|
|
23
|
+
output_1.default.exitError(texts_1.ERR_WORKSPACE_NOT_FOUND);
|
|
24
|
+
}
|
|
25
|
+
if (!data || !data.distribution_id) {
|
|
26
|
+
output_1.default.exitError(texts_1.ERR_COMMAND_DISTRO_NOT_FOUND);
|
|
27
|
+
}
|
|
28
|
+
const confirmed = options.force ||
|
|
29
|
+
(await output_1.default.confirm((0, texts_1.TXT_COMMAND_DISTRO_DELETE_CONFIRM)(identifier)));
|
|
30
|
+
if (confirmed) {
|
|
31
|
+
await client.deleteDistribution(workspace, project, data.distribution_id);
|
|
32
|
+
output_1.default.exitSuccess(texts_1.TXT_COMMAND_DISTRO_DELETED);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
output_1.default.exitNormal();
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
exports.default = commandDistroDelete;
|
|
@@ -0,0 +1,42 @@
|
|
|
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 commandDistroList = (0, utils_1.newCommand)('list', texts_1.DESC_COMMAND_DISTRO_LIST);
|
|
11
|
+
commandDistroList.alias('ls');
|
|
12
|
+
commandDistroList.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
13
|
+
commandDistroList.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
|
|
14
|
+
commandDistroList.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
15
|
+
commandDistroList.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_DISTRO_LIST}`);
|
|
16
|
+
commandDistroList.action(async (options) => {
|
|
17
|
+
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
18
|
+
const project = input_1.default.restApiProject(options.project, true);
|
|
19
|
+
const client = input_1.default.restApiTokenClient();
|
|
20
|
+
const r = await client.getDistributions(workspace, project);
|
|
21
|
+
const distributions = r.distributions || [];
|
|
22
|
+
if (options.format === 'json') {
|
|
23
|
+
output_1.default.json(distributions);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
if (distributions.length === 0) {
|
|
27
|
+
output_1.default.exitNormal(texts_1.TXT_COMMAND_DISTROS_NOT_FOUND);
|
|
28
|
+
}
|
|
29
|
+
const data = [['NAME', 'ID', 'IDENTIFIER', 'URL']];
|
|
30
|
+
for (const d of distributions) {
|
|
31
|
+
data.push([
|
|
32
|
+
d.name || '-',
|
|
33
|
+
String(d.id || '-'),
|
|
34
|
+
d.identifier || '-',
|
|
35
|
+
d.html_url || '-',
|
|
36
|
+
]);
|
|
37
|
+
}
|
|
38
|
+
output_1.default.table(data);
|
|
39
|
+
}
|
|
40
|
+
output_1.default.exitNormal();
|
|
41
|
+
});
|
|
42
|
+
exports.default = commandDistroList;
|
|
@@ -0,0 +1,50 @@
|
|
|
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 commandDistroRouteCreate = (0, utils_1.newCommand)('create', texts_1.DESC_COMMAND_ROUTE_CREATE);
|
|
11
|
+
commandDistroRouteCreate.alias('add');
|
|
12
|
+
commandDistroRouteCreate.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
13
|
+
commandDistroRouteCreate.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
|
|
14
|
+
commandDistroRouteCreate.option('-t, --type <type>', texts_1.OPT_COMMAND_ROUTE_TYPE);
|
|
15
|
+
commandDistroRouteCreate.option('-s, --subdomain <subdomain>', texts_1.OPT_COMMAND_ROUTE_SUBDOMAIN);
|
|
16
|
+
commandDistroRouteCreate.option('-d, --domain <domain>', texts_1.OPT_COMMAND_ROUTE_DOMAIN);
|
|
17
|
+
commandDistroRouteCreate.option('--path <path>', texts_1.OPT_COMMAND_ROUTE_PATH);
|
|
18
|
+
commandDistroRouteCreate.option('--target <targets...>', texts_1.OPT_COMMAND_ROUTE_TARGET);
|
|
19
|
+
commandDistroRouteCreate.argument('<identifier>', texts_1.OPT_COMMAND_DISTRO_IDENTIFIER);
|
|
20
|
+
commandDistroRouteCreate.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_ROUTE_CREATE}`);
|
|
21
|
+
commandDistroRouteCreate.action(async (identifier, options) => {
|
|
22
|
+
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
23
|
+
const project = input_1.default.restApiProject(options.project, true);
|
|
24
|
+
const client = input_1.default.restApiTokenClient();
|
|
25
|
+
const type = input_1.default.routeType(options.type);
|
|
26
|
+
const body = {
|
|
27
|
+
type,
|
|
28
|
+
targets: {}
|
|
29
|
+
};
|
|
30
|
+
if (options.subdomain)
|
|
31
|
+
body.subdomain = options.subdomain;
|
|
32
|
+
if (options.domain)
|
|
33
|
+
body.domain = options.domain;
|
|
34
|
+
if (options.path)
|
|
35
|
+
body.path = input_1.default.routePath(options.path);
|
|
36
|
+
const data = await client.getDistributionByIdentifier(workspace, project, identifier);
|
|
37
|
+
if (!data?.domain) {
|
|
38
|
+
output_1.default.exitError(texts_1.ERR_WORKSPACE_NOT_FOUND);
|
|
39
|
+
}
|
|
40
|
+
if (!data?.distribution_id) {
|
|
41
|
+
output_1.default.exitError(texts_1.ERR_COMMAND_DISTRO_NOT_FOUND);
|
|
42
|
+
}
|
|
43
|
+
body.targets = await input_1.default.routeTarget(client, workspace, project, options.target);
|
|
44
|
+
const result = await client.createRoute(workspace, project, data.distribution_id, body);
|
|
45
|
+
output_1.default.id(result.id);
|
|
46
|
+
output_1.default.cyan(result.html_url);
|
|
47
|
+
output_1.default.green(texts_1.TXT_COMMAND_ROUTE_CREATED);
|
|
48
|
+
output_1.default.exitNormal();
|
|
49
|
+
});
|
|
50
|
+
exports.default = commandDistroRouteCreate;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("../../../utils");
|
|
7
|
+
const texts_1 = require("../../../texts");
|
|
8
|
+
const input_1 = __importDefault(require("../../../input"));
|
|
9
|
+
const output_1 = __importDefault(require("../../../output"));
|
|
10
|
+
const commandDistroRouteDelete = (0, utils_1.newCommand)('delete', texts_1.DESC_COMMAND_ROUTE_DELETE);
|
|
11
|
+
commandDistroRouteDelete.alias('rm');
|
|
12
|
+
commandDistroRouteDelete.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
13
|
+
commandDistroRouteDelete.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
|
|
14
|
+
commandDistroRouteDelete.option('-f, --force', texts_1.OPTION_CONFIRM_FORCE);
|
|
15
|
+
commandDistroRouteDelete.argument('<identifier>', texts_1.OPT_COMMAND_DISTRO_IDENTIFIER);
|
|
16
|
+
commandDistroRouteDelete.argument('<route-id>', texts_1.OPT_COMMAND_ROUTE_ID);
|
|
17
|
+
commandDistroRouteDelete.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_ROUTE_DELETE}`);
|
|
18
|
+
commandDistroRouteDelete.action(async (identifier, routeId, options) => {
|
|
19
|
+
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
20
|
+
const project = input_1.default.restApiProject(options.project, true);
|
|
21
|
+
const client = input_1.default.restApiTokenClient();
|
|
22
|
+
const data = await client.getDistributionByIdentifier(workspace, project, identifier);
|
|
23
|
+
if (!data?.domain) {
|
|
24
|
+
output_1.default.exitError(texts_1.ERR_WORKSPACE_NOT_FOUND);
|
|
25
|
+
}
|
|
26
|
+
if (!data?.distribution_id) {
|
|
27
|
+
output_1.default.exitError(texts_1.ERR_COMMAND_DISTRO_NOT_FOUND);
|
|
28
|
+
}
|
|
29
|
+
const confirmed = options.force ||
|
|
30
|
+
(await output_1.default.confirm((0, texts_1.TXT_COMMAND_ROUTE_DELETE_CONFIRM)(identifier, routeId)));
|
|
31
|
+
if (confirmed) {
|
|
32
|
+
await client.deleteRoute(workspace, project, data.distribution_id, routeId);
|
|
33
|
+
output_1.default.exitSuccess(texts_1.TXT_COMMAND_ROUTE_DELETED);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
output_1.default.exitNormal();
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
exports.default = commandDistroRouteDelete;
|
|
@@ -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 commandDistroRouteList = (0, utils_1.newCommand)('list', texts_1.DESC_COMMAND_ROUTE_LIST);
|
|
11
|
+
commandDistroRouteList.alias('ls');
|
|
12
|
+
commandDistroRouteList.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
13
|
+
commandDistroRouteList.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
|
|
14
|
+
commandDistroRouteList.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
15
|
+
commandDistroRouteList.argument('<identifier>', texts_1.OPT_COMMAND_DISTRO_IDENTIFIER);
|
|
16
|
+
commandDistroRouteList.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_ROUTE_LIST}`);
|
|
17
|
+
commandDistroRouteList.action(async (identifier, options) => {
|
|
18
|
+
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
19
|
+
const project = input_1.default.restApiProject(options.project, true);
|
|
20
|
+
const client = input_1.default.restApiTokenClient();
|
|
21
|
+
const data = await client.getDistributionByIdentifier(workspace, project, identifier);
|
|
22
|
+
if (!data?.domain) {
|
|
23
|
+
output_1.default.exitError(texts_1.ERR_WORKSPACE_NOT_FOUND);
|
|
24
|
+
}
|
|
25
|
+
if (!data?.distribution_id) {
|
|
26
|
+
output_1.default.exitError(texts_1.ERR_COMMAND_DISTRO_NOT_FOUND);
|
|
27
|
+
}
|
|
28
|
+
const r = await client.listRoutes(workspace, project, data.distribution_id);
|
|
29
|
+
const routes = r.routes || [];
|
|
30
|
+
if (options.format === 'json') {
|
|
31
|
+
output_1.default.json(routes);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
if (routes.length === 0) {
|
|
35
|
+
output_1.default.exitNormal(texts_1.TXT_COMMAND_ROUTES_NOT_FOUND);
|
|
36
|
+
}
|
|
37
|
+
const table = [
|
|
38
|
+
['ID', 'TYPE', 'SUBDOMAIN', 'DOMAIN', 'PATH', 'URL'],
|
|
39
|
+
];
|
|
40
|
+
for (const route of routes) {
|
|
41
|
+
table.push([
|
|
42
|
+
route.id || '-',
|
|
43
|
+
route.type || '-',
|
|
44
|
+
route.subdomain || '-',
|
|
45
|
+
route.domain || '-',
|
|
46
|
+
route.path || '-',
|
|
47
|
+
route.html_url || '-',
|
|
48
|
+
]);
|
|
49
|
+
}
|
|
50
|
+
output_1.default.table(table);
|
|
51
|
+
}
|
|
52
|
+
output_1.default.exitNormal();
|
|
53
|
+
});
|
|
54
|
+
exports.default = commandDistroRouteList;
|
|
@@ -0,0 +1,18 @@
|
|
|
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 create_1 = __importDefault(require("./route/create"));
|
|
9
|
+
const list_1 = __importDefault(require("./route/list"));
|
|
10
|
+
const delete_1 = __importDefault(require("./route/delete"));
|
|
11
|
+
const commandDistroRoute = (0, utils_1.newCommand)('route', texts_1.DESC_COMMAND_ROUTE);
|
|
12
|
+
commandDistroRoute.addCommand(create_1.default);
|
|
13
|
+
commandDistroRoute.addCommand(list_1.default);
|
|
14
|
+
commandDistroRoute.addCommand(delete_1.default);
|
|
15
|
+
commandDistroRoute.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_ROUTE_CREATE}
|
|
16
|
+
${texts_1.EXAMPLE_ROUTE_LIST}
|
|
17
|
+
${texts_1.EXAMPLE_ROUTE_DELETE}`);
|
|
18
|
+
exports.default = commandDistroRoute;
|
|
@@ -0,0 +1,23 @@
|
|
|
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 create_1 = __importDefault(require("./distro/create"));
|
|
9
|
+
const delete_1 = __importDefault(require("./distro/delete"));
|
|
10
|
+
const list_1 = __importDefault(require("./distro/list"));
|
|
11
|
+
const route_1 = __importDefault(require("./distro/route"));
|
|
12
|
+
const commandDistro = (0, utils_1.newCommand)('distro', texts_1.DESC_COMMAND_DISTRO);
|
|
13
|
+
commandDistro.addCommand(create_1.default);
|
|
14
|
+
commandDistro.addCommand(list_1.default);
|
|
15
|
+
commandDistro.addCommand(delete_1.default);
|
|
16
|
+
commandDistro.addCommand(route_1.default);
|
|
17
|
+
commandDistro.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_DISTRO_CREATE}
|
|
18
|
+
${texts_1.EXAMPLE_DISTRO_LIST}
|
|
19
|
+
${texts_1.EXAMPLE_DISTRO_DELETE}
|
|
20
|
+
${texts_1.EXAMPLE_ROUTE_CREATE}
|
|
21
|
+
${texts_1.EXAMPLE_ROUTE_LIST}
|
|
22
|
+
${texts_1.EXAMPLE_ROUTE_DELETE}`);
|
|
23
|
+
exports.default = commandDistro;
|