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.
Files changed (39) hide show
  1. package/distTs/package.json +3 -2
  2. package/distTs/src/api/client.js +73 -2
  3. package/distTs/src/cliIndex.js +2 -0
  4. package/distTs/src/command/artifact/get.js +16 -9
  5. package/distTs/src/command/artifact/list.js +23 -8
  6. package/distTs/src/command/artifact/version/get.js +20 -13
  7. package/distTs/src/command/artifact/version/list.js +19 -12
  8. package/distTs/src/command/distro/create.js +40 -0
  9. package/distTs/src/command/distro/delete.js +38 -0
  10. package/distTs/src/command/distro/list.js +42 -0
  11. package/distTs/src/command/distro/route/create.js +50 -0
  12. package/distTs/src/command/distro/route/delete.js +39 -0
  13. package/distTs/src/command/distro/route/list.js +54 -0
  14. package/distTs/src/command/distro/route.js +18 -0
  15. package/distTs/src/command/distro.js +23 -0
  16. package/distTs/src/command/domain/buy.js +27 -8
  17. package/distTs/src/command/domain/get.js +17 -11
  18. package/distTs/src/command/domain/list.js +13 -6
  19. package/distTs/src/command/login.js +1 -0
  20. package/distTs/src/command/pipeline/list.js +1 -1
  21. package/distTs/src/command/project/list.js +13 -6
  22. package/distTs/src/command/sandbox/app/list.js +13 -7
  23. package/distTs/src/command/sandbox/app/status.js +10 -4
  24. package/distTs/src/command/sandbox/endpoint/get.js +61 -52
  25. package/distTs/src/command/sandbox/endpoint/list.js +18 -12
  26. package/distTs/src/command/sandbox/exec/list.js +22 -16
  27. package/distTs/src/command/sandbox/exec/status.js +18 -9
  28. package/distTs/src/command/sandbox/get.js +26 -18
  29. package/distTs/src/command/sandbox/list.js +21 -15
  30. package/distTs/src/command/sandbox/snapshot/get.js +19 -13
  31. package/distTs/src/command/sandbox/snapshot/list.js +17 -11
  32. package/distTs/src/command/sandbox/status.js +11 -5
  33. package/distTs/src/command/whoami.js +17 -8
  34. package/distTs/src/command/workspace/list.js +14 -8
  35. package/distTs/src/input.js +180 -1
  36. package/distTs/src/output.js +16 -6
  37. package/distTs/src/texts.js +86 -6
  38. package/distTs/src/types/distro.js +232 -0
  39. package/package.json +3 -2
@@ -43,20 +43,41 @@ commandDomainBuy.action(async (text, options) => {
43
43
  }
44
44
  output_1.default.exitNormal();
45
45
  });
46
+ const outputRouteExample = (domain) => {
47
+ output_1.default.normal('\nRoute this zone to an artifact:');
48
+ output_1.default.dim('bdy distro route create <distro-identifier> \\');
49
+ output_1.default.dim(` --domain="${domain}" \\`);
50
+ output_1.default.dim(' --target "artifact=<artifact-identifier>:<version>"');
51
+ output_1.default.normal(`\nRoute a NEW sub-name within the zone (e.g. api.${domain}):`);
52
+ output_1.default.dim('bdy distro route create <distro-identifier> \\');
53
+ output_1.default.dim(' --subdomain="api" \\');
54
+ output_1.default.dim(` --domain="${domain}" \\`);
55
+ output_1.default.dim(' --target "artifact=<artifact-identifier>:<version>"');
56
+ };
57
+ const outputClaimed = (domain) => {
58
+ output_1.default.okSign();
59
+ output_1.default.cyan(domain, false);
60
+ output_1.default.normal(' claimed');
61
+ outputRouteExample(domain);
62
+ };
63
+ const outputBought = (domain) => {
64
+ output_1.default.okSign();
65
+ output_1.default.cyan(domain, false);
66
+ output_1.default.normal(' bought');
67
+ outputRouteExample(domain);
68
+ };
46
69
  const claimNonInteractive = async (client, workspace, domain, onOwnerBehalf) => {
47
70
  output_1.default.arrowSign();
48
71
  output_1.default.normal(`Matched: ${output_1.default.formatDomainClaim(domain, true)}`);
49
72
  await client.domainClaim(workspace, domain, onOwnerBehalf);
50
- output_1.default.okSign();
51
- output_1.default.normal(`${domain} claimed`);
73
+ outputClaimed(domain);
52
74
  };
53
75
  const buyNonInteractive = async (client, workspace, domain, onOwnerBehalf) => {
54
76
  output_1.default.arrowSign();
55
77
  output_1.default.normal(`Matched: ${output_1.default.formatDomain(domain)}`);
56
78
  if (domain.available && !domain.premium) {
57
79
  await client.domainBuy(workspace, domain.name, onOwnerBehalf, true);
58
- output_1.default.okSign();
59
- output_1.default.normal(`${domain.name} bought`);
80
+ outputBought(domain.name);
60
81
  }
61
82
  };
62
83
  const interactive = async (client, workspace, prompt, tlds, onOwnerBehalf, onlyAvailable, sort) => {
@@ -235,13 +256,11 @@ const interactive = async (client, workspace, prompt, tlds, onOwnerBehalf, onlyA
235
256
  }
236
257
  else if (type === 'claim') {
237
258
  await client.domainClaim(workspace, name, onOwnerBehalf);
238
- output_1.default.okSign();
239
- output_1.default.normal(`${name} claimed`);
259
+ outputClaimed(name);
240
260
  }
241
261
  else {
242
262
  await client.domainBuy(workspace, name, onOwnerBehalf);
243
- output_1.default.okSign();
244
- output_1.default.normal(`${name} bought`);
263
+ outputBought(name);
245
264
  }
246
265
  };
247
266
  const nonInteractive = async (client, workspace, prompt, tlds, onOwnerBehalf) => {
@@ -9,6 +9,7 @@ const input_1 = __importDefault(require("../../input"));
9
9
  const output_1 = __importDefault(require("../../output"));
10
10
  const commandDomainGet = (0, utils_1.newCommand)('get', texts_1.DESC_COMMAND_DOMAIN_GET);
11
11
  commandDomainGet.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
12
+ commandDomainGet.option('--format <text|json>', texts_1.OPTION_FORMAT);
12
13
  commandDomainGet.argument('<id|name>', texts_1.OPTION_COMMAND_DOMAIN_IDENTIFIER);
13
14
  commandDomainGet.action(async (name, options) => {
14
15
  const workspace = input_1.default.restApiWorkspace(options.workspace);
@@ -27,19 +28,24 @@ commandDomainGet.action(async (name, options) => {
27
28
  if (!domain) {
28
29
  output_1.default.exitError(texts_1.ERR_COMMAND_DOMAIN_NOT_FOUND);
29
30
  }
30
- const props = {
31
- Name: domain.name,
32
- ID: domain.id,
33
- Type: domain.type,
34
- };
35
- if (domain.type === 'REGISTERED') {
36
- if (domain.expiry_date) {
37
- props.Expires = domain.expiry_date;
31
+ if (options.format === 'json') {
32
+ output_1.default.json(domain);
33
+ }
34
+ else {
35
+ const props = {
36
+ Name: domain.name,
37
+ ID: domain.id,
38
+ Type: domain.type,
39
+ };
40
+ if (domain.type === 'REGISTERED') {
41
+ if (domain.expiry_date) {
42
+ props.Expires = domain.expiry_date;
43
+ }
44
+ props.Renew = domain.auto_renew ? 'Auto' : 'Manual';
38
45
  }
39
- props.Renew = domain.auto_renew ? 'Auto' : 'Manual';
46
+ props.URL = domain.html_url;
47
+ output_1.default.object(props);
40
48
  }
41
- props.URL = domain.html_url;
42
- output_1.default.object(props);
43
49
  output_1.default.exitNormal();
44
50
  });
45
51
  exports.default = commandDomainGet;
@@ -10,18 +10,25 @@ const output_1 = __importDefault(require("../../output"));
10
10
  const commandDomainList = (0, utils_1.newCommand)('list', texts_1.DESC_COMMAND_DOMAIN_LIST);
11
11
  commandDomainList.alias('ls');
12
12
  commandDomainList.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
13
+ commandDomainList.option('--format <text|json>', texts_1.OPTION_FORMAT);
13
14
  commandDomainList.action(async (options) => {
14
15
  const workspace = input_1.default.restApiWorkspace(options.workspace);
15
16
  const client = input_1.default.restApiTokenClient();
16
17
  const response = await client.getDomains(workspace);
17
- if (!response.domains || response.domains.length === 0) {
18
- output_1.default.exitError(texts_1.ERR_COMMAND_DOMAIN_NO_DOMAINS);
18
+ const domains = response.domains || [];
19
+ if (options.format === 'json') {
20
+ output_1.default.json(domains);
19
21
  }
20
- const data = [['NAME', 'ID', 'URL']];
21
- for (const d of response.domains) {
22
- data.push([d.name, d.id, d.html_url]);
22
+ else {
23
+ if (domains.length === 0) {
24
+ output_1.default.exitError(texts_1.ERR_COMMAND_DOMAIN_NO_DOMAINS);
25
+ }
26
+ const data = [['NAME', 'ID', 'URL']];
27
+ for (const d of domains) {
28
+ data.push([d.name, d.id, d.html_url]);
29
+ }
30
+ output_1.default.table(data);
23
31
  }
24
- output_1.default.table(data);
25
32
  output_1.default.exitNormal();
26
33
  });
27
34
  exports.default = commandDomainList;
@@ -29,6 +29,7 @@ const OAUTH_CLIENT_APP_SCOPES = [
29
29
  'INTEGRATION_MANAGE',
30
30
  'SANDBOX_MANAGE',
31
31
  'ARTIFACT_MANAGE',
32
+ 'DISTRIBUTION_MANAGE',
32
33
  'TUNNEL_MANAGE',
33
34
  'UNIT_TEST_MANAGE',
34
35
  ];
@@ -23,7 +23,7 @@ commandPipelineList.action(async (options) => {
23
23
  const client = input_1.default.restApiTokenClient();
24
24
  const r = await client.getPipelines(workspace, project, page, perPage);
25
25
  if (!r.pipelines.length) {
26
- output_1.default.exitError(texts_1.ERR_PIPELINES_NOT_FOUND);
26
+ output_1.default.exitNormal(texts_1.TXT_PIPELINES_NOT_FOUND);
27
27
  }
28
28
  if (options.format === 'json') {
29
29
  output_1.default.json(r.pipelines);
@@ -10,18 +10,25 @@ const input_1 = __importDefault(require("../../input"));
10
10
  const commandProjectList = (0, utils_1.newCommand)('list', texts_1.DESC_COMMAND_PROJECT_LIST);
11
11
  commandProjectList.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
12
12
  commandProjectList.alias('ls');
13
+ commandProjectList.option('--format <text|json>', texts_1.OPTION_FORMAT);
13
14
  commandProjectList.action(async (options) => {
14
15
  const workspace = input_1.default.restApiWorkspace(options.workspace);
15
16
  const client = input_1.default.restApiTokenClient();
16
17
  const response = await client.getProjects(workspace);
17
- if (!response.projects || response.projects.length === 0) {
18
- output_1.default.exitError(texts_1.ERR_PROJECT_NO_PROJECTS);
18
+ const projects = response.projects || [];
19
+ if (options.format === 'json') {
20
+ output_1.default.json(projects);
19
21
  }
20
- const data = [['NAME', 'DISPLAY NAME', 'STATUS', 'URL']];
21
- for (const proj of response.projects) {
22
- data.push([proj.name, proj.display_name, proj.status, proj.html_url]);
22
+ else {
23
+ if (projects.length === 0) {
24
+ output_1.default.exitError(texts_1.ERR_PROJECT_NO_PROJECTS);
25
+ }
26
+ const data = [['NAME', 'DISPLAY NAME', 'STATUS', 'URL']];
27
+ for (const proj of projects) {
28
+ data.push([proj.name, proj.display_name, proj.status, proj.html_url]);
29
+ }
30
+ output_1.default.table(data);
23
31
  }
24
- output_1.default.table(data);
25
32
  output_1.default.exitNormal();
26
33
  });
27
34
  exports.default = commandProjectList;
@@ -11,6 +11,7 @@ const commandSandboxAppList = (0, utils_1.newCommand)('list', texts_1.DESC_COMMA
11
11
  commandSandboxAppList.alias('ls');
12
12
  commandSandboxAppList.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
13
13
  commandSandboxAppList.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
14
+ commandSandboxAppList.option('--format <text|json>', texts_1.OPTION_FORMAT);
14
15
  commandSandboxAppList.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
15
16
  commandSandboxAppList.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_SANDBOX_APP_LIST}`);
16
17
  commandSandboxAppList.action(async (identifier, options) => {
@@ -22,14 +23,19 @@ commandSandboxAppList.action(async (identifier, options) => {
22
23
  output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
23
24
  }
24
25
  const { apps } = await client.getSandbox(workspace, sandbox_id);
25
- const table = [['ID', 'COMMAND', 'STATUS']];
26
- for (const app of apps) {
27
- let command = app.command;
28
- if (command.length > 20)
29
- command = `${command.substring(0, 20)}...`;
30
- table.push([app.id, command, app.app_status]);
26
+ if (options.format === 'json') {
27
+ output_1.default.json(apps);
28
+ }
29
+ else {
30
+ const table = [['ID', 'COMMAND', 'STATUS']];
31
+ for (const app of apps) {
32
+ let command = app.command;
33
+ if (command.length > 20)
34
+ command = `${command.substring(0, 20)}...`;
35
+ table.push([app.id, command, app.app_status]);
36
+ }
37
+ output_1.default.table(table);
31
38
  }
32
- output_1.default.table(table);
33
39
  output_1.default.exitNormal();
34
40
  });
35
41
  exports.default = commandSandboxAppList;
@@ -10,6 +10,7 @@ const output_1 = __importDefault(require("../../../output"));
10
10
  const commandSandboxAppStatus = (0, utils_1.newCommand)('status', texts_1.DESC_COMMAND_SANDBOX_APP_STATUS);
11
11
  commandSandboxAppStatus.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
12
12
  commandSandboxAppStatus.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
13
+ commandSandboxAppStatus.option('--format <text|json>', texts_1.OPTION_FORMAT);
13
14
  commandSandboxAppStatus.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
14
15
  commandSandboxAppStatus.argument('<app-id>', texts_1.OPTION_SANDBOX_APP_ID);
15
16
  commandSandboxAppStatus.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_SANDBOX_APP_STATUS}`);
@@ -26,10 +27,15 @@ commandSandboxAppStatus.action(async (identifier, appId, options) => {
26
27
  if (!app) {
27
28
  output_1.default.exitError(texts_1.ERR_SANDBOX_APP_NOT_FOUND);
28
29
  }
29
- output_1.default.object({
30
- Command: app.command,
31
- Status: app.app_status,
32
- });
30
+ if (options.format === 'json') {
31
+ output_1.default.json(app);
32
+ }
33
+ else {
34
+ output_1.default.object({
35
+ Command: app.command,
36
+ Status: app.app_status,
37
+ });
38
+ }
33
39
  output_1.default.exitNormal();
34
40
  });
35
41
  exports.default = commandSandboxAppStatus;
@@ -10,6 +10,7 @@ const input_1 = __importDefault(require("../../../input"));
10
10
  const commandSandboxEndpointGet = (0, utils_1.newCommand)('get', texts_1.DESC_COMMAND_SANDBOX_ENDPOINT_GET);
11
11
  commandSandboxEndpointGet.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
12
12
  commandSandboxEndpointGet.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
13
+ commandSandboxEndpointGet.option('--format <text|json>', texts_1.OPTION_FORMAT);
13
14
  commandSandboxEndpointGet.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
14
15
  commandSandboxEndpointGet.argument('<endpoint-name>', texts_1.OPTION_SANDBOX_ENDPOINT_NAME_ARG);
15
16
  commandSandboxEndpointGet.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_SANDBOX_ENDPOINT_GET}`);
@@ -27,68 +28,76 @@ commandSandboxEndpointGet.action(async (identifier, endpointName, options) => {
27
28
  if (!endpoint) {
28
29
  output_1.default.exitError(texts_1.ERR_SANDBOX_ENDPOINT_NOT_FOUND);
29
30
  }
30
- const data = [
31
- ['Field', 'Value'],
32
- ['Name', endpoint.name || '-'],
33
- ['Endpoint', endpoint.endpoint || '-'],
34
- ['Type', endpoint.type || '-'],
35
- ['Region', endpoint.region || '-'],
36
- ['URL', endpoint.endpoint_url || '-'],
37
- ['Timeout', endpoint.timeout?.toString() || '-'],
38
- ];
39
- if (endpoint.whitelist?.length) {
40
- data.push(['Whitelist', endpoint.whitelist?.join(', ')]);
31
+ if (options.format === 'json') {
32
+ output_1.default.json(endpoint);
41
33
  }
42
- if (endpoint.http) {
43
- data.push(['HTTP2', endpoint.http.http2 ? 'TRUE' : 'FALSE']);
44
- data.push([
45
- 'Verify certificate',
46
- endpoint.http.verify_certificate ? 'TRUE' : 'FALSE',
47
- ]);
48
- data.push(['Compression', endpoint.http.compression ? 'TRUE' : 'FALSE']);
49
- data.push([
50
- 'Log requests',
51
- endpoint.http.log_requests ? 'TRUE' : 'FALSE',
52
- ]);
53
- data.push(['Auth type', endpoint.http.auth_type]);
54
- if (endpoint.http.serve_path) {
55
- data.push(['Serve path', endpoint.http.serve_path]);
34
+ else {
35
+ const data = [
36
+ ['Field', 'Value'],
37
+ ['Name', endpoint.name || '-'],
38
+ ['Endpoint', endpoint.endpoint || '-'],
39
+ ['Type', endpoint.type || '-'],
40
+ ['Region', endpoint.region || '-'],
41
+ ['URL', endpoint.endpoint_url || '-'],
42
+ ['Timeout', endpoint.timeout?.toString() || '-'],
43
+ ];
44
+ if (endpoint.whitelist?.length) {
45
+ data.push(['Whitelist', endpoint.whitelist?.join(', ')]);
56
46
  }
57
- if (endpoint.http.circuit_breaker) {
58
- data.push(['Circuit breaker', String(endpoint.http.circuit_breaker)]);
59
- }
60
- if (endpoint.http.whitelist_user_agents?.length) {
47
+ if (endpoint.http) {
48
+ data.push(['HTTP2', endpoint.http.http2 ? 'TRUE' : 'FALSE']);
61
49
  data.push([
62
- 'Whitelist user agents',
63
- endpoint.http.whitelist_user_agents.join('\n'),
50
+ 'Verify certificate',
51
+ endpoint.http.verify_certificate ? 'TRUE' : 'FALSE',
64
52
  ]);
65
- }
66
- if (endpoint.http.rewrite_host_header) {
67
- data.push(['Rewrite host header', endpoint.http.rewrite_host_header]);
68
- }
69
- let headers = Object.keys(endpoint.http.request_headers || {});
70
- if (headers.length) {
71
53
  data.push([
72
- 'Request headers',
73
- headers
74
- .map((key) => `${key}: ${endpoint.http.request_headers[key]}`)
75
- .join('\n '),
54
+ 'Compression',
55
+ endpoint.http.compression ? 'TRUE' : 'FALSE',
76
56
  ]);
77
- }
78
- headers = Object.keys(endpoint.http.response_headers || {});
79
- if (headers.length) {
80
57
  data.push([
81
- 'Request headers',
82
- headers
83
- .map((key) => `${key}: ${endpoint.http.response_headers[key]}`)
84
- .join('\n '),
58
+ 'Log requests',
59
+ endpoint.http.log_requests ? 'TRUE' : 'FALSE',
85
60
  ]);
61
+ data.push(['Auth type', endpoint.http.auth_type]);
62
+ if (endpoint.http.serve_path) {
63
+ data.push(['Serve path', endpoint.http.serve_path]);
64
+ }
65
+ if (endpoint.http.circuit_breaker) {
66
+ data.push(['Circuit breaker', String(endpoint.http.circuit_breaker)]);
67
+ }
68
+ if (endpoint.http.whitelist_user_agents?.length) {
69
+ data.push([
70
+ 'Whitelist user agents',
71
+ endpoint.http.whitelist_user_agents.join('\n'),
72
+ ]);
73
+ }
74
+ if (endpoint.http.rewrite_host_header) {
75
+ data.push(['Rewrite host header', endpoint.http.rewrite_host_header]);
76
+ }
77
+ let headers = Object.keys(endpoint.http.request_headers || {});
78
+ if (headers.length) {
79
+ data.push([
80
+ 'Request headers',
81
+ headers
82
+ .map((key) => `${key}: ${endpoint.http.request_headers[key]}`)
83
+ .join('\n '),
84
+ ]);
85
+ }
86
+ headers = Object.keys(endpoint.http.response_headers || {});
87
+ if (headers.length) {
88
+ data.push([
89
+ 'Request headers',
90
+ headers
91
+ .map((key) => `${key}: ${endpoint.http.response_headers[key]}`)
92
+ .join('\n '),
93
+ ]);
94
+ }
86
95
  }
96
+ else if (endpoint.tls) {
97
+ data.push(['Terminate at', endpoint.tls.terminate_at]);
98
+ }
99
+ output_1.default.table(data);
87
100
  }
88
- else if (endpoint.tls) {
89
- data.push(['Terminate at', endpoint.tls.terminate_at]);
90
- }
91
- output_1.default.table(data);
92
101
  output_1.default.exitNormal();
93
102
  });
94
103
  exports.default = commandSandboxEndpointGet;
@@ -11,6 +11,7 @@ const commandSandboxEndpointList = (0, utils_1.newCommand)('list', texts_1.DESC_
11
11
  commandSandboxEndpointList.alias('ls');
12
12
  commandSandboxEndpointList.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
13
13
  commandSandboxEndpointList.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
14
+ commandSandboxEndpointList.option('--format <text|json>', texts_1.OPTION_FORMAT);
14
15
  commandSandboxEndpointList.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
15
16
  commandSandboxEndpointList.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_SANDBOX_ENDPOINT_LIST}`);
16
17
  commandSandboxEndpointList.action(async (identifier, options) => {
@@ -23,20 +24,25 @@ commandSandboxEndpointList.action(async (identifier, options) => {
23
24
  }
24
25
  const sandbox = await client.getSandbox(workspace, sandbox_id);
25
26
  const endpoints = sandbox.endpoints || [];
26
- if (endpoints.length === 0) {
27
- output_1.default.exitError(texts_1.ERR_SANDBOX_ENDPOINTS_NOT_FOUND);
27
+ if (options.format === 'json') {
28
+ output_1.default.json(endpoints);
28
29
  }
29
- const data = [['Name', 'Endpoint', 'Type', 'Region', 'URL']];
30
- for (const ep of endpoints) {
31
- data.push([
32
- ep.name || '-',
33
- ep.endpoint || '-',
34
- ep.type || '-',
35
- ep.region || '-',
36
- ep.endpoint_url || '-',
37
- ]);
30
+ else {
31
+ if (endpoints.length === 0) {
32
+ output_1.default.exitError(texts_1.ERR_SANDBOX_ENDPOINTS_NOT_FOUND);
33
+ }
34
+ const data = [['Name', 'Endpoint', 'Type', 'Region', 'URL']];
35
+ for (const ep of endpoints) {
36
+ data.push([
37
+ ep.name || '-',
38
+ ep.endpoint || '-',
39
+ ep.type || '-',
40
+ ep.region || '-',
41
+ ep.endpoint_url || '-',
42
+ ]);
43
+ }
44
+ output_1.default.table(data);
38
45
  }
39
- output_1.default.table(data);
40
46
  output_1.default.exitNormal();
41
47
  });
42
48
  exports.default = commandSandboxEndpointList;
@@ -11,6 +11,7 @@ const commandSandboxExecList = (0, utils_1.newCommand)('list', texts_1.DESC_COMM
11
11
  commandSandboxExecList.alias('ls');
12
12
  commandSandboxExecList.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
13
13
  commandSandboxExecList.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
14
+ commandSandboxExecList.option('--format <text|json>', texts_1.OPTION_FORMAT);
14
15
  commandSandboxExecList.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
15
16
  commandSandboxExecList.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_SANDBOX_EXEC_LIST}`);
16
17
  commandSandboxExecList.action(async (identifier, options) => {
@@ -23,24 +24,29 @@ commandSandboxExecList.action(async (identifier, options) => {
23
24
  }
24
25
  const commandsResult = await client.listSandboxCommands(workspace, sandbox_id);
25
26
  const commands = commandsResult.commands || [];
26
- if (commands.length === 0) {
27
- output_1.default.exitError(texts_1.ERR_SANDBOX_NO_COMMANDS);
28
- }
29
27
  commands.sort((a, b) => (b.id || '').localeCompare(a.id || ''));
30
- const data = [
31
- ['ID', 'COMMAND', 'STATUS', 'EXIT CODE', 'RUNTIME'],
32
- ];
33
- for (const cmd of commands) {
34
- data.push([
35
- cmd.id || '-',
36
- (cmd.command || '-').substring(0, 40) +
37
- (cmd.command?.length > 40 ? '...' : ''),
38
- cmd.status || '-',
39
- cmd.exit_code !== undefined ? String(cmd.exit_code) : '-',
40
- cmd.runtime || 'BASH',
41
- ]);
28
+ if (options.format === 'json') {
29
+ output_1.default.json(commands);
30
+ }
31
+ else {
32
+ if (commands.length === 0) {
33
+ output_1.default.exitError(texts_1.ERR_SANDBOX_NO_COMMANDS);
34
+ }
35
+ const data = [
36
+ ['ID', 'COMMAND', 'STATUS', 'EXIT CODE', 'RUNTIME'],
37
+ ];
38
+ for (const cmd of commands) {
39
+ data.push([
40
+ cmd.id || '-',
41
+ (cmd.command || '-').substring(0, 40) +
42
+ (cmd.command?.length > 40 ? '...' : ''),
43
+ cmd.status || '-',
44
+ cmd.exit_code !== undefined ? String(cmd.exit_code) : '-',
45
+ cmd.runtime || 'BASH',
46
+ ]);
47
+ }
48
+ output_1.default.table(data);
42
49
  }
43
- output_1.default.table(data);
44
50
  output_1.default.exitNormal();
45
51
  });
46
52
  exports.default = commandSandboxExecList;
@@ -10,6 +10,7 @@ const output_1 = __importDefault(require("../../../output"));
10
10
  const commandSandboxExecStatus = (0, utils_1.newCommand)('status', texts_1.DESC_COMMAND_SANDBOX_EXEC_STATUS);
11
11
  commandSandboxExecStatus.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
12
12
  commandSandboxExecStatus.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
13
+ commandSandboxExecStatus.option('--format <text|json>', texts_1.OPTION_FORMAT);
13
14
  commandSandboxExecStatus.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
14
15
  commandSandboxExecStatus.argument('<command-id>', texts_1.OPTION_SANDBOX_COMMAND_ID);
15
16
  commandSandboxExecStatus.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_SANDBOX_EXEC_STATUS}`);
@@ -22,15 +23,23 @@ commandSandboxExecStatus.action(async (identifier, commandId, options) => {
22
23
  output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
23
24
  }
24
25
  const cmd = await client.getSandboxCommand(workspace, sandbox_id, commandId);
25
- const data = [
26
- ['Property', 'Value'],
27
- ['Command ID', cmd.id || '-'],
28
- ['Command', cmd.command || '-'],
29
- ['Runtime', cmd.runtime || 'BASH'],
30
- ['Status', cmd.status || '-'],
31
- ['Exit Code', cmd.exit_code !== undefined ? String(cmd.exit_code) : '-'],
32
- ];
33
- output_1.default.table(data);
26
+ if (options.format === 'json') {
27
+ output_1.default.json(cmd);
28
+ }
29
+ else {
30
+ const data = [
31
+ ['Property', 'Value'],
32
+ ['Command ID', cmd.id || '-'],
33
+ ['Command', cmd.command || '-'],
34
+ ['Runtime', cmd.runtime || 'BASH'],
35
+ ['Status', cmd.status || '-'],
36
+ [
37
+ 'Exit Code',
38
+ cmd.exit_code !== undefined ? String(cmd.exit_code) : '-',
39
+ ],
40
+ ];
41
+ output_1.default.table(data);
42
+ }
34
43
  output_1.default.exitNormal();
35
44
  });
36
45
  exports.default = commandSandboxExecStatus;
@@ -10,6 +10,7 @@ const input_1 = __importDefault(require("../../input"));
10
10
  const commandSandboxGet = (0, utils_1.newCommand)('get', texts_1.DESC_COMMAND_SANDBOX_GET);
11
11
  commandSandboxGet.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
12
12
  commandSandboxGet.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
13
+ commandSandboxGet.option('--format <text|json>', texts_1.OPTION_FORMAT);
13
14
  commandSandboxGet.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
14
15
  commandSandboxGet.action(async (identifier, options) => {
15
16
  const workspace = input_1.default.restApiWorkspace(options.workspace);
@@ -20,25 +21,32 @@ commandSandboxGet.action(async (identifier, options) => {
20
21
  output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
21
22
  }
22
23
  const sandbox = await client.getSandbox(workspace, sandbox_id);
23
- const data = [
24
- ['Field', 'Value'],
25
- ['ID', sandbox.id || '-'],
26
- ['Identifier', sandbox.identifier || '-'],
27
- ['Name', sandbox.name || '-'],
28
- ['Status', sandbox.status || '-'],
29
- ['Setup Status', sandbox.setup_status || '-'],
30
- ['OS', sandbox.os || '-'],
31
- ['Resources', sandbox.resources || '-'],
32
- ['Tags', (sandbox.tags || []).join(', ') || '-'],
33
- ['URL', sandbox.html_url || '-'],
34
- ];
35
- if (sandbox.endpoints && sandbox.endpoints.length > 0) {
36
- data.push([
37
- 'Endpoints',
38
- sandbox.endpoints.map((e) => `${e.name}: ${e.endpoint}`).join('\n'),
39
- ]);
24
+ if (options.format === 'json') {
25
+ output_1.default.json(sandbox);
26
+ }
27
+ else {
28
+ const data = [
29
+ ['Field', 'Value'],
30
+ ['ID', sandbox.id || '-'],
31
+ ['Identifier', sandbox.identifier || '-'],
32
+ ['Name', sandbox.name || '-'],
33
+ ['Status', sandbox.status || '-'],
34
+ ['Setup Status', sandbox.setup_status || '-'],
35
+ ['OS', sandbox.os || '-'],
36
+ ['Resources', sandbox.resources || '-'],
37
+ ['Tags', (sandbox.tags || []).join(', ') || '-'],
38
+ ['URL', sandbox.html_url || '-'],
39
+ ];
40
+ if (sandbox.endpoints && sandbox.endpoints.length > 0) {
41
+ data.push([
42
+ 'Endpoints',
43
+ sandbox.endpoints
44
+ .map((e) => `${e.name}: ${e.endpoint}`)
45
+ .join('\n'),
46
+ ]);
47
+ }
48
+ output_1.default.table(data);
40
49
  }
41
- output_1.default.table(data);
42
50
  output_1.default.exitNormal();
43
51
  });
44
52
  exports.default = commandSandboxGet;