bdy 1.16.12-stage → 1.16.14-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 (45) hide show
  1. package/distTs/package.json +4 -3
  2. package/distTs/src/api/client.js +173 -5
  3. package/distTs/src/command/login.js +130 -0
  4. package/distTs/src/command/logout.js +15 -0
  5. package/distTs/src/command/project/get.js +18 -0
  6. package/distTs/src/command/project/list.js +33 -0
  7. package/distTs/src/command/project/set.js +45 -0
  8. package/distTs/src/command/project.js +16 -0
  9. package/distTs/src/command/sandbox/cp.js +71 -0
  10. package/distTs/src/command/sandbox/create.js +147 -0
  11. package/distTs/src/command/sandbox/destroy.js +34 -0
  12. package/distTs/src/command/sandbox/endpoint/add.js +40 -0
  13. package/distTs/src/command/sandbox/endpoint/delete.js +41 -0
  14. package/distTs/src/command/sandbox/endpoint/get.js +101 -0
  15. package/distTs/src/command/sandbox/endpoint/list.js +48 -0
  16. package/distTs/src/command/sandbox/endpoint.js +18 -0
  17. package/distTs/src/command/sandbox/exec/command.js +72 -0
  18. package/distTs/src/command/sandbox/exec/kill.js +34 -0
  19. package/distTs/src/command/sandbox/exec/list.js +53 -0
  20. package/distTs/src/command/sandbox/exec/logs.js +59 -0
  21. package/distTs/src/command/sandbox/exec/status.js +43 -0
  22. package/distTs/src/command/sandbox/exec.js +19 -0
  23. package/distTs/src/command/sandbox/get.js +50 -0
  24. package/distTs/src/command/sandbox/list.js +41 -0
  25. package/distTs/src/command/sandbox/restart.js +48 -0
  26. package/distTs/src/command/sandbox/snapshot/create.js +56 -0
  27. package/distTs/src/command/sandbox/snapshot/delete.js +40 -0
  28. package/distTs/src/command/sandbox/snapshot/get.js +50 -0
  29. package/distTs/src/command/sandbox/snapshot/list.js +46 -0
  30. package/distTs/src/command/sandbox/snapshot.js +18 -0
  31. package/distTs/src/command/sandbox/start.js +48 -0
  32. package/distTs/src/command/sandbox/status.js +38 -0
  33. package/distTs/src/command/sandbox/stop.js +48 -0
  34. package/distTs/src/command/sandbox.js +34 -0
  35. package/distTs/src/command/workspace/get.js +18 -0
  36. package/distTs/src/command/workspace/list.js +32 -0
  37. package/distTs/src/command/workspace/set.js +40 -0
  38. package/distTs/src/command/workspace.js +16 -0
  39. package/distTs/src/index.js +10 -0
  40. package/distTs/src/input.js +142 -14
  41. package/distTs/src/output.js +44 -0
  42. package/distTs/src/texts.js +181 -8
  43. package/distTs/src/tunnel/cfg.js +47 -0
  44. package/distTs/src/utils.js +91 -3
  45. package/package.json +4 -3
@@ -0,0 +1,43 @@
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 client_1 = __importDefault(require("../../../api/client"));
10
+ const output_1 = __importDefault(require("../../../output"));
11
+ const commandSandboxExecStatus = (0, utils_1.newCommand)('status', texts_1.DESC_COMMAND_SANDBOX_EXEC_STATUS);
12
+ commandSandboxExecStatus.option('--token <token>', texts_1.OPTION_REST_API_TOKEN);
13
+ commandSandboxExecStatus.option('--api <url>', texts_1.OPTION_REST_API_ENDPOINT);
14
+ commandSandboxExecStatus.option('--region <region>', texts_1.OPTION_REST_API_REGION);
15
+ commandSandboxExecStatus.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
16
+ commandSandboxExecStatus.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
17
+ commandSandboxExecStatus.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
18
+ commandSandboxExecStatus.argument('<command-id>', texts_1.OPTION_SANDBOX_COMMAND_ID);
19
+ commandSandboxExecStatus.action(async (identifier, commandId, options) => {
20
+ const token = input_1.default.restApiToken(options.token);
21
+ const baseUrl = input_1.default.restApiBaseUrl(options.api, options.region);
22
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
23
+ const project = input_1.default.restApiProject(options.project);
24
+ const client = new client_1.default(baseUrl, token);
25
+ const result = await client.listSandboxes(workspace, project);
26
+ const sandboxes = result.sandboxes || [];
27
+ const found = sandboxes.find((s) => s.identifier === identifier);
28
+ if (!found) {
29
+ output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
30
+ }
31
+ const cmd = await client.getSandboxCommand(workspace, found.id, commandId);
32
+ const data = [
33
+ ['Property', 'Value'],
34
+ ['Command ID', cmd.id || '-'],
35
+ ['Command', cmd.command || '-'],
36
+ ['Runtime', cmd.runtime || 'BASH'],
37
+ ['Status', cmd.status || '-'],
38
+ ['Exit Code', cmd.exit_code !== undefined ? String(cmd.exit_code) : '-'],
39
+ ];
40
+ output_1.default.table(data);
41
+ output_1.default.exitNormal();
42
+ });
43
+ exports.default = commandSandboxExecStatus;
@@ -0,0 +1,19 @@
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 status_1 = __importDefault(require("./exec/status"));
9
+ const kill_1 = __importDefault(require("./exec/kill"));
10
+ const list_1 = __importDefault(require("./exec/list"));
11
+ const logs_1 = __importDefault(require("./exec/logs"));
12
+ const command_1 = __importDefault(require("./exec/command"));
13
+ const commandSandboxExec = (0, utils_1.newCommand)('exec', texts_1.DESC_COMMAND_SANDBOX_EXEC);
14
+ commandSandboxExec.addCommand(command_1.default);
15
+ commandSandboxExec.addCommand(status_1.default);
16
+ commandSandboxExec.addCommand(kill_1.default);
17
+ commandSandboxExec.addCommand(list_1.default);
18
+ commandSandboxExec.addCommand(logs_1.default);
19
+ exports.default = commandSandboxExec;
@@ -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 output_1 = __importDefault(require("../../output"));
9
+ const input_1 = __importDefault(require("../../input"));
10
+ const client_1 = __importDefault(require("../../api/client"));
11
+ const commandSandboxGet = (0, utils_1.newCommand)('get', texts_1.DESC_COMMAND_SANDBOX_GET);
12
+ commandSandboxGet.option('--token <token>', texts_1.OPTION_REST_API_TOKEN);
13
+ commandSandboxGet.option('--api <url>', texts_1.OPTION_REST_API_ENDPOINT);
14
+ commandSandboxGet.option('--region <region>', texts_1.OPTION_REST_API_REGION);
15
+ commandSandboxGet.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
16
+ commandSandboxGet.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
17
+ commandSandboxGet.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
18
+ commandSandboxGet.action(async (identifier, options) => {
19
+ const token = input_1.default.restApiToken(options.token);
20
+ const baseUrl = input_1.default.restApiBaseUrl(options.api, options.region);
21
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
22
+ const project = input_1.default.restApiProject(options.project);
23
+ const client = new client_1.default(baseUrl, token);
24
+ const result = await client.listSandboxes(workspace, project);
25
+ const sandboxes = result.sandboxes || [];
26
+ const found = sandboxes.find((s) => s.identifier === identifier);
27
+ if (!found) {
28
+ output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
29
+ }
30
+ const sandbox = await client.getSandbox(workspace, found.id);
31
+ const data = [
32
+ ['Property', 'Value'],
33
+ ['ID', sandbox.id || '-'],
34
+ ['Identifier', sandbox.identifier || '-'],
35
+ ['Name', sandbox.name || '-'],
36
+ ['Status', sandbox.status || '-'],
37
+ ['Setup Status', sandbox.setup_status || '-'],
38
+ ['App Status', sandbox.app_status || '-'],
39
+ ['OS', sandbox.os || '-'],
40
+ ['Resources', sandbox.resources || '-'],
41
+ ['Tags', (sandbox.tags || []).join(', ') || '-'],
42
+ ['URL', sandbox.html_url || '-'],
43
+ ];
44
+ if (sandbox.endpoints && sandbox.endpoints.length > 0) {
45
+ data.push(['Endpoints', sandbox.endpoints.map((e) => `${e.name}: ${e.endpoint}`).join('\n')]);
46
+ }
47
+ output_1.default.table(data);
48
+ output_1.default.exitNormal();
49
+ });
50
+ exports.default = commandSandboxGet;
@@ -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 output_1 = __importDefault(require("../../output"));
9
+ const input_1 = __importDefault(require("../../input"));
10
+ const client_1 = __importDefault(require("../../api/client"));
11
+ const commandSandboxList = (0, utils_1.newCommand)('list', texts_1.DESC_COMMAND_SANDBOX_LIST);
12
+ commandSandboxList.alias('ls');
13
+ commandSandboxList.option('--token <token>', texts_1.OPTION_REST_API_TOKEN);
14
+ commandSandboxList.option('--api <url>', texts_1.OPTION_REST_API_ENDPOINT);
15
+ commandSandboxList.option('--region <region>', texts_1.OPTION_REST_API_REGION);
16
+ commandSandboxList.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
17
+ commandSandboxList.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
18
+ commandSandboxList.action(async (options) => {
19
+ const token = input_1.default.restApiToken(options.token);
20
+ const baseUrl = input_1.default.restApiBaseUrl(options.api, options.region);
21
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
22
+ const project = input_1.default.restApiProject(options.project);
23
+ const client = new client_1.default(baseUrl, token);
24
+ const result = await client.listSandboxes(workspace, project);
25
+ const sandboxes = result.sandboxes || [];
26
+ if (sandboxes.length === 0) {
27
+ output_1.default.exitNormal('No sandboxes found');
28
+ }
29
+ const data = [['IDENTIFIER', 'NAME', 'STATUS', 'ID']];
30
+ for (const sandbox of sandboxes) {
31
+ data.push([
32
+ sandbox.identifier || '-',
33
+ sandbox.name || '-',
34
+ sandbox.status || '-',
35
+ sandbox.id || '-',
36
+ ]);
37
+ }
38
+ output_1.default.table(data);
39
+ output_1.default.exitNormal();
40
+ });
41
+ exports.default = commandSandboxList;
@@ -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 client_1 = __importDefault(require("../../api/client"));
11
+ const commandSandboxRestart = (0, utils_1.newCommand)('restart', texts_1.DESC_COMMAND_SANDBOX_RESTART);
12
+ commandSandboxRestart.option('--token <token>', texts_1.OPTION_REST_API_TOKEN);
13
+ commandSandboxRestart.option('--api <url>', texts_1.OPTION_REST_API_ENDPOINT);
14
+ commandSandboxRestart.option('--region <region>', texts_1.OPTION_REST_API_REGION);
15
+ commandSandboxRestart.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
16
+ commandSandboxRestart.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
17
+ commandSandboxRestart.option('--wait', texts_1.OPTION_SANDBOX_WAIT);
18
+ commandSandboxRestart.option('--wait-timeout <seconds>', texts_1.OPTION_SANDBOX_WAIT_TIMEOUT, '300');
19
+ commandSandboxRestart.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
20
+ commandSandboxRestart.action(async (identifier, options) => {
21
+ const token = input_1.default.restApiToken(options.token);
22
+ const baseUrl = input_1.default.restApiBaseUrl(options.api, options.region);
23
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
24
+ const project = input_1.default.restApiProject(options.project);
25
+ const client = new client_1.default(baseUrl, token);
26
+ const result = await client.listSandboxes(workspace, project);
27
+ const sandboxes = result.sandboxes || [];
28
+ const found = sandboxes.find((s) => s.identifier === identifier);
29
+ if (!found) {
30
+ output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
31
+ }
32
+ await client.restartSandbox(workspace, found.id);
33
+ if (options.wait) {
34
+ output_1.default.normal(texts_1.TXT_SANDBOX_WAITING_START);
35
+ const timeout = parseInt(options.waitTimeout, 10) || 300;
36
+ try {
37
+ const status = await client.sandboxWaitForRunning(workspace, found.id, timeout);
38
+ if (status !== utils_1.SANDBOX_STATUS.RUNNING) {
39
+ output_1.default.exitError(texts_1.ERR_SANDBOX_RUNNING_FAILED);
40
+ }
41
+ }
42
+ catch {
43
+ output_1.default.exitError(texts_1.ERR_SANDBOX_RUNNING_TIMEOUT);
44
+ }
45
+ }
46
+ output_1.default.exitSuccess((0, texts_1.TXT_SANDBOX_STARTED)(identifier));
47
+ });
48
+ exports.default = commandSandboxRestart;
@@ -0,0 +1,56 @@
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 client_1 = __importDefault(require("../../../api/client"));
11
+ const human_id_1 = __importDefault(require("human-id"));
12
+ const commandSandboxSnapshotCreate = (0, utils_1.newCommand)('create', texts_1.DESC_COMMAND_SANDBOX_SNAPSHOT_CREATE);
13
+ commandSandboxSnapshotCreate.option('--token <token>', texts_1.OPTION_REST_API_TOKEN);
14
+ commandSandboxSnapshotCreate.option('--api <url>', texts_1.OPTION_REST_API_ENDPOINT);
15
+ commandSandboxSnapshotCreate.option('--region <region>', texts_1.OPTION_REST_API_REGION);
16
+ commandSandboxSnapshotCreate.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
17
+ commandSandboxSnapshotCreate.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
18
+ commandSandboxSnapshotCreate.option('-n, --name <name>', texts_1.OPTION_SANDBOX_SNAPSHOT_NAME);
19
+ commandSandboxSnapshotCreate.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
20
+ commandSandboxSnapshotCreate.option('--wait', texts_1.OPTION_SANDBOX_WAIT);
21
+ commandSandboxSnapshotCreate.option('--wait-timeout <seconds>', texts_1.OPTION_SANDBOX_WAIT_TIMEOUT, '300');
22
+ commandSandboxSnapshotCreate.action(async (identifier, options) => {
23
+ const token = input_1.default.restApiToken(options.token);
24
+ const baseUrl = input_1.default.restApiBaseUrl(options.api, options.region);
25
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
26
+ const project = input_1.default.restApiProject(options.project);
27
+ const client = new client_1.default(baseUrl, token);
28
+ const result = await client.listSandboxes(workspace, project);
29
+ const sandboxes = result.sandboxes || [];
30
+ const found = sandboxes.find((s) => s.identifier === identifier);
31
+ if (!found) {
32
+ output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
33
+ }
34
+ const defaultName = 'snapshot-' + (0, human_id_1.default)({ separator: '-', capitalize: false });
35
+ const snapshotName = options.name || defaultName;
36
+ const body = {
37
+ name: snapshotName,
38
+ };
39
+ const snapshot = await client.createSandboxSnapshot(workspace, found.id, body);
40
+ const snapshotId = snapshot.id;
41
+ if (options.wait) {
42
+ output_1.default.normal(texts_1.TXT_SANDBOX_SNAPSHOT_WAITING);
43
+ const timeout = parseInt(options.waitTimeout, 10) || 300;
44
+ try {
45
+ const status = await client.sandboxWaitForSnapshot(workspace, found.id, snapshotId, timeout);
46
+ if (status !== utils_1.SANDBOX_SNAPSHOT_STATUS.CREATED) {
47
+ output_1.default.exitError(texts_1.ERR_SANDBOX_SNAPSHOT_FAILED);
48
+ }
49
+ }
50
+ catch {
51
+ output_1.default.exitError(texts_1.ERR_SANDBOX_SNAPSHOT_TIMEOUT);
52
+ }
53
+ }
54
+ output_1.default.exitSuccess((0, texts_1.TXT_SANDBOX_SNAPSHOT_CREATED)(snapshotName));
55
+ });
56
+ exports.default = commandSandboxSnapshotCreate;
@@ -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 output_1 = __importDefault(require("../../../output"));
9
+ const input_1 = __importDefault(require("../../../input"));
10
+ const client_1 = __importDefault(require("../../../api/client"));
11
+ const commandSandboxSnapshotDelete = (0, utils_1.newCommand)('delete', texts_1.DESC_COMMAND_SANDBOX_SNAPSHOT_DELETE);
12
+ commandSandboxSnapshotDelete.option('--token <token>', texts_1.OPTION_REST_API_TOKEN);
13
+ commandSandboxSnapshotDelete.option('--api <url>', texts_1.OPTION_REST_API_ENDPOINT);
14
+ commandSandboxSnapshotDelete.option('--region <region>', texts_1.OPTION_REST_API_REGION);
15
+ commandSandboxSnapshotDelete.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
16
+ commandSandboxSnapshotDelete.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
17
+ commandSandboxSnapshotDelete.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
18
+ commandSandboxSnapshotDelete.argument('<snapshot-name>', texts_1.OPTION_SANDBOX_SNAPSHOT_NAME_ARG);
19
+ commandSandboxSnapshotDelete.action(async (identifier, snapshotName, options) => {
20
+ const token = input_1.default.restApiToken(options.token);
21
+ const baseUrl = input_1.default.restApiBaseUrl(options.api, options.region);
22
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
23
+ const project = input_1.default.restApiProject(options.project);
24
+ const client = new client_1.default(baseUrl, token);
25
+ const result = await client.listSandboxes(workspace, project);
26
+ const sandboxes = result.sandboxes || [];
27
+ const found = sandboxes.find((s) => s.identifier === identifier);
28
+ if (!found) {
29
+ output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
30
+ }
31
+ const snapshotsResult = await client.listSandboxSnapshots(workspace, found.id);
32
+ const snapshots = snapshotsResult.snapshots || [];
33
+ const foundSnapshot = snapshots.find((s) => s.name === snapshotName);
34
+ if (!foundSnapshot) {
35
+ output_1.default.exitError(texts_1.ERR_SANDBOX_SNAPSHOT_NOT_FOUND);
36
+ }
37
+ await client.deleteSandboxSnapshot(workspace, found.id, foundSnapshot.id);
38
+ output_1.default.exitSuccess((0, texts_1.TXT_SANDBOX_SNAPSHOT_DELETED)(snapshotName));
39
+ });
40
+ exports.default = commandSandboxSnapshotDelete;
@@ -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 output_1 = __importDefault(require("../../../output"));
9
+ const input_1 = __importDefault(require("../../../input"));
10
+ const client_1 = __importDefault(require("../../../api/client"));
11
+ const commandSandboxSnapshotGet = (0, utils_1.newCommand)('get', texts_1.DESC_COMMAND_SANDBOX_SNAPSHOT_GET);
12
+ commandSandboxSnapshotGet.option('--token <token>', texts_1.OPTION_REST_API_TOKEN);
13
+ commandSandboxSnapshotGet.option('--api <url>', texts_1.OPTION_REST_API_ENDPOINT);
14
+ commandSandboxSnapshotGet.option('--region <region>', texts_1.OPTION_REST_API_REGION);
15
+ commandSandboxSnapshotGet.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
16
+ commandSandboxSnapshotGet.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
17
+ commandSandboxSnapshotGet.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
18
+ commandSandboxSnapshotGet.argument('<snapshot-name>', texts_1.OPTION_SANDBOX_SNAPSHOT_NAME_ARG);
19
+ commandSandboxSnapshotGet.action(async (identifier, snapshotName, options) => {
20
+ const token = input_1.default.restApiToken(options.token);
21
+ const baseUrl = input_1.default.restApiBaseUrl(options.api, options.region);
22
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
23
+ const project = input_1.default.restApiProject(options.project);
24
+ const client = new client_1.default(baseUrl, token);
25
+ const result = await client.listSandboxes(workspace, project);
26
+ const sandboxes = result.sandboxes || [];
27
+ const found = sandboxes.find((s) => s.identifier === identifier);
28
+ if (!found) {
29
+ output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
30
+ }
31
+ const snapshotsResult = await client.listSandboxSnapshots(workspace, found.id);
32
+ const snapshots = snapshotsResult.snapshots || [];
33
+ const foundSnapshot = snapshots.find((s) => s.name === snapshotName);
34
+ if (!foundSnapshot) {
35
+ output_1.default.exitError(texts_1.ERR_SANDBOX_SNAPSHOT_NOT_FOUND);
36
+ }
37
+ const snapshot = await client.getSandboxSnapshot(workspace, found.id, foundSnapshot.id);
38
+ const data = [
39
+ ['Property', 'Value'],
40
+ ['Name', snapshot.name || '-'],
41
+ ['Status', snapshot.status || '-'],
42
+ ['Created', snapshot.create_date || '-'],
43
+ ];
44
+ if (snapshot.creator) {
45
+ data.push(['Creator', snapshot.creator.name || snapshot.creator.email || '-']);
46
+ }
47
+ output_1.default.table(data);
48
+ output_1.default.exitNormal();
49
+ });
50
+ exports.default = commandSandboxSnapshotGet;
@@ -0,0 +1,46 @@
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 client_1 = __importDefault(require("../../../api/client"));
11
+ const commandSandboxSnapshotList = (0, utils_1.newCommand)('list', texts_1.DESC_COMMAND_SANDBOX_SNAPSHOT_LIST);
12
+ commandSandboxSnapshotList.option('--token <token>', texts_1.OPTION_REST_API_TOKEN);
13
+ commandSandboxSnapshotList.option('--api <url>', texts_1.OPTION_REST_API_ENDPOINT);
14
+ commandSandboxSnapshotList.option('--region <region>', texts_1.OPTION_REST_API_REGION);
15
+ commandSandboxSnapshotList.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
16
+ commandSandboxSnapshotList.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
17
+ commandSandboxSnapshotList.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
18
+ commandSandboxSnapshotList.action(async (identifier, options) => {
19
+ const token = input_1.default.restApiToken(options.token);
20
+ const baseUrl = input_1.default.restApiBaseUrl(options.api, options.region);
21
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
22
+ const project = input_1.default.restApiProject(options.project);
23
+ const client = new client_1.default(baseUrl, token);
24
+ const result = await client.listSandboxes(workspace, project);
25
+ const sandboxes = result.sandboxes || [];
26
+ const found = sandboxes.find((s) => s.identifier === identifier);
27
+ if (!found) {
28
+ output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
29
+ }
30
+ const snapshotsResult = await client.listSandboxSnapshots(workspace, found.id);
31
+ const snapshots = snapshotsResult.snapshots || [];
32
+ if (snapshots.length === 0) {
33
+ output_1.default.exitError(texts_1.ERR_SANDBOX_SNAPSHOTS_NOT_FOUND);
34
+ }
35
+ const data = [['Name', 'Status', 'Created']];
36
+ for (const snapshot of snapshots) {
37
+ data.push([
38
+ snapshot.name || '-',
39
+ snapshot.status || '-',
40
+ snapshot.create_date || '-',
41
+ ]);
42
+ }
43
+ output_1.default.table(data);
44
+ output_1.default.exitNormal();
45
+ });
46
+ exports.default = commandSandboxSnapshotList;
@@ -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 list_1 = __importDefault(require("./snapshot/list"));
9
+ const create_1 = __importDefault(require("./snapshot/create"));
10
+ const get_1 = __importDefault(require("./snapshot/get"));
11
+ const delete_1 = __importDefault(require("./snapshot/delete"));
12
+ const commandSandboxSnapshot = (0, utils_1.newCommand)('snapshot', texts_1.DESC_COMMAND_SANDBOX_SNAPSHOT);
13
+ commandSandboxSnapshot.alias('snap');
14
+ commandSandboxSnapshot.addCommand(list_1.default);
15
+ commandSandboxSnapshot.addCommand(create_1.default);
16
+ commandSandboxSnapshot.addCommand(get_1.default);
17
+ commandSandboxSnapshot.addCommand(delete_1.default);
18
+ exports.default = commandSandboxSnapshot;
@@ -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 client_1 = __importDefault(require("../../api/client"));
11
+ const commandSandboxStart = (0, utils_1.newCommand)('start', texts_1.DESC_COMMAND_SANDBOX_START);
12
+ commandSandboxStart.option('--token <token>', texts_1.OPTION_REST_API_TOKEN);
13
+ commandSandboxStart.option('--api <url>', texts_1.OPTION_REST_API_ENDPOINT);
14
+ commandSandboxStart.option('--region <region>', texts_1.OPTION_REST_API_REGION);
15
+ commandSandboxStart.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
16
+ commandSandboxStart.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
17
+ commandSandboxStart.option('--wait', texts_1.OPTION_SANDBOX_WAIT);
18
+ commandSandboxStart.option('--wait-timeout <seconds>', texts_1.OPTION_SANDBOX_WAIT_TIMEOUT, '300');
19
+ commandSandboxStart.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
20
+ commandSandboxStart.action(async (identifier, options) => {
21
+ const token = input_1.default.restApiToken(options.token);
22
+ const baseUrl = input_1.default.restApiBaseUrl(options.api, options.region);
23
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
24
+ const project = input_1.default.restApiProject(options.project);
25
+ const client = new client_1.default(baseUrl, token);
26
+ const result = await client.listSandboxes(workspace, project);
27
+ const sandboxes = result.sandboxes || [];
28
+ const found = sandboxes.find((s) => s.identifier === identifier);
29
+ if (!found) {
30
+ output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
31
+ }
32
+ await client.startSandbox(workspace, found.id);
33
+ if (options.wait) {
34
+ output_1.default.normal(texts_1.TXT_SANDBOX_WAITING_START);
35
+ const timeout = parseInt(options.waitTimeout, 10) || 300;
36
+ try {
37
+ const status = await client.sandboxWaitForRunning(workspace, found.id, timeout);
38
+ if (status !== utils_1.SANDBOX_STATUS.RUNNING) {
39
+ output_1.default.exitError(texts_1.ERR_SANDBOX_RUNNING_FAILED);
40
+ }
41
+ }
42
+ catch {
43
+ output_1.default.exitError(texts_1.ERR_SANDBOX_RUNNING_TIMEOUT);
44
+ }
45
+ }
46
+ output_1.default.exitSuccess((0, texts_1.TXT_SANDBOX_STARTED)(identifier));
47
+ });
48
+ exports.default = commandSandboxStart;
@@ -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 output_1 = __importDefault(require("../../output"));
9
+ const input_1 = __importDefault(require("../../input"));
10
+ const client_1 = __importDefault(require("../../api/client"));
11
+ const commandSandboxStatus = (0, utils_1.newCommand)('status', texts_1.DESC_COMMAND_SANDBOX_STATUS);
12
+ commandSandboxStatus.option('--token <token>', texts_1.OPTION_REST_API_TOKEN);
13
+ commandSandboxStatus.option('--api <url>', texts_1.OPTION_REST_API_ENDPOINT);
14
+ commandSandboxStatus.option('--region <region>', texts_1.OPTION_REST_API_REGION);
15
+ commandSandboxStatus.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
16
+ commandSandboxStatus.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
17
+ commandSandboxStatus.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
18
+ commandSandboxStatus.action(async (identifier, options) => {
19
+ const token = input_1.default.restApiToken(options.token);
20
+ const baseUrl = input_1.default.restApiBaseUrl(options.api, options.region);
21
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
22
+ const project = input_1.default.restApiProject(options.project);
23
+ const client = new client_1.default(baseUrl, token);
24
+ const result = await client.listSandboxes(workspace, project);
25
+ const sandboxes = result.sandboxes || [];
26
+ const found = sandboxes.find((s) => s.identifier === identifier);
27
+ if (!found) {
28
+ output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
29
+ }
30
+ const sandbox = await client.getSandbox(workspace, found.id);
31
+ output_1.default.table([
32
+ ['Status', sandbox.status || 'UNKNOWN'],
33
+ ['Setup', sandbox.setup_status || 'UNKNOWN'],
34
+ ['App', sandbox.app_status || 'UNKNOWN']
35
+ ]);
36
+ output_1.default.exitNormal();
37
+ });
38
+ exports.default = commandSandboxStatus;
@@ -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 client_1 = __importDefault(require("../../api/client"));
11
+ const commandSandboxStop = (0, utils_1.newCommand)('stop', texts_1.DESC_COMMAND_SANDBOX_STOP);
12
+ commandSandboxStop.option('--token <token>', texts_1.OPTION_REST_API_TOKEN);
13
+ commandSandboxStop.option('--api <url>', texts_1.OPTION_REST_API_ENDPOINT);
14
+ commandSandboxStop.option('--region <region>', texts_1.OPTION_REST_API_REGION);
15
+ commandSandboxStop.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
16
+ commandSandboxStop.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
17
+ commandSandboxStop.option('--wait', texts_1.OPTION_SANDBOX_WAIT);
18
+ commandSandboxStop.option('--wait-timeout <seconds>', texts_1.OPTION_SANDBOX_WAIT_TIMEOUT, '300');
19
+ commandSandboxStop.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
20
+ commandSandboxStop.action(async (identifier, options) => {
21
+ const token = input_1.default.restApiToken(options.token);
22
+ const baseUrl = input_1.default.restApiBaseUrl(options.api, options.region);
23
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
24
+ const project = input_1.default.restApiProject(options.project);
25
+ const client = new client_1.default(baseUrl, token);
26
+ const result = await client.listSandboxes(workspace, project);
27
+ const sandboxes = result.sandboxes || [];
28
+ const found = sandboxes.find((s) => s.identifier === identifier);
29
+ if (!found) {
30
+ output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
31
+ }
32
+ await client.stopSandbox(workspace, found.id);
33
+ if (options.wait) {
34
+ output_1.default.normal(texts_1.TXT_SANDBOX_WAITING_STOP);
35
+ const timeout = parseInt(options.waitTimeout, 10) || 300;
36
+ try {
37
+ const status = await client.sandboxWaitForRunning(workspace, found.id, timeout);
38
+ if (status !== utils_1.SANDBOX_STATUS.STOPPED) {
39
+ output_1.default.exitError(texts_1.ERR_SANDBOX_STOP_FAILED);
40
+ }
41
+ }
42
+ catch {
43
+ output_1.default.exitError(texts_1.ERR_SANDBOX_STOP_TIMEOUT);
44
+ }
45
+ }
46
+ output_1.default.exitSuccess((0, texts_1.TXT_SANDBOX_STOPPED)(identifier));
47
+ });
48
+ exports.default = commandSandboxStop;
@@ -0,0 +1,34 @@
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("./sandbox/create"));
9
+ const list_1 = __importDefault(require("./sandbox/list"));
10
+ const get_1 = __importDefault(require("./sandbox/get"));
11
+ const destroy_1 = __importDefault(require("./sandbox/destroy"));
12
+ const start_1 = __importDefault(require("./sandbox/start"));
13
+ const stop_1 = __importDefault(require("./sandbox/stop"));
14
+ const restart_1 = __importDefault(require("./sandbox/restart"));
15
+ const status_1 = __importDefault(require("./sandbox/status"));
16
+ const cp_1 = __importDefault(require("./sandbox/cp"));
17
+ const snapshot_1 = __importDefault(require("./sandbox/snapshot"));
18
+ const endpoint_1 = __importDefault(require("./sandbox/endpoint"));
19
+ const exec_1 = __importDefault(require("./sandbox/exec"));
20
+ const commandSandbox = (0, utils_1.newCommand)('sandbox', texts_1.DESC_COMMAND_SANDBOX);
21
+ commandSandbox.alias('sb');
22
+ commandSandbox.addCommand(create_1.default);
23
+ commandSandbox.addCommand(list_1.default);
24
+ commandSandbox.addCommand(get_1.default);
25
+ commandSandbox.addCommand(destroy_1.default);
26
+ commandSandbox.addCommand(start_1.default);
27
+ commandSandbox.addCommand(stop_1.default);
28
+ commandSandbox.addCommand(restart_1.default);
29
+ commandSandbox.addCommand(status_1.default);
30
+ commandSandbox.addCommand(cp_1.default);
31
+ commandSandbox.addCommand(exec_1.default);
32
+ commandSandbox.addCommand(snapshot_1.default);
33
+ commandSandbox.addCommand(endpoint_1.default);
34
+ exports.default = commandSandbox;
@@ -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 cfg_1 = __importDefault(require("../../tunnel/cfg"));
7
+ const output_1 = __importDefault(require("../../output"));
8
+ const texts_1 = require("../../texts");
9
+ const utils_1 = require("../../utils");
10
+ const commandWorkspaceGet = (0, utils_1.newCommand)('get', texts_1.DESC_COMMAND_WORKSPACE_GET);
11
+ commandWorkspaceGet.action(async () => {
12
+ const workspace = cfg_1.default.getWorkspace();
13
+ if (!workspace) {
14
+ output_1.default.exitError(texts_1.TXT_WORKSPACE_NONE);
15
+ }
16
+ output_1.default.exitNormal(workspace);
17
+ });
18
+ exports.default = commandWorkspaceGet;