bdy 1.17.28-dev → 1.17.29-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 +1 -1
- package/distTs/src/api/client.js +7 -0
- package/distTs/src/command/sandbox/cp.js +7 -11
- package/distTs/src/command/sandbox/destroy.js +3 -5
- package/distTs/src/command/sandbox/endpoint/add.js +4 -6
- package/distTs/src/command/sandbox/endpoint/delete.js +4 -6
- package/distTs/src/command/sandbox/endpoint/get.js +3 -5
- package/distTs/src/command/sandbox/endpoint/list.js +3 -5
- package/distTs/src/command/sandbox/exec/command.js +5 -7
- package/distTs/src/command/sandbox/exec/kill.js +3 -5
- package/distTs/src/command/sandbox/exec/list.js +3 -5
- package/distTs/src/command/sandbox/exec/logs.js +4 -6
- package/distTs/src/command/sandbox/exec/status.js +3 -5
- package/distTs/src/command/sandbox/get.js +3 -5
- package/distTs/src/command/sandbox/restart.js +4 -6
- package/distTs/src/command/sandbox/snapshot/create.js +4 -6
- package/distTs/src/command/sandbox/snapshot/delete.js +4 -6
- package/distTs/src/command/sandbox/snapshot/get.js +4 -6
- package/distTs/src/command/sandbox/snapshot/list.js +3 -5
- package/distTs/src/command/sandbox/start.js +4 -6
- package/distTs/src/command/sandbox/status.js +3 -5
- package/distTs/src/command/sandbox/stop.js +4 -6
- package/distTs/src/command/sandbox/update.js +5 -8
- package/distTs/src/command/sandbox/yaml.js +3 -6
- package/package.json +1 -1
package/distTs/package.json
CHANGED
package/distTs/src/api/client.js
CHANGED
|
@@ -623,6 +623,13 @@ class ApiClient {
|
|
|
623
623
|
opts.package_version = version;
|
|
624
624
|
return await this.getResourceByIdentifier(workspace, opts);
|
|
625
625
|
}
|
|
626
|
+
async getSandboxByIdentifier(workspace, project, sandbox) {
|
|
627
|
+
const opts = {
|
|
628
|
+
project,
|
|
629
|
+
sandbox
|
|
630
|
+
};
|
|
631
|
+
return await this.getResourceByIdentifier(workspace, opts);
|
|
632
|
+
}
|
|
626
633
|
async getPackageVersions(workspace, pkgId, page = 1, perPage = 10) {
|
|
627
634
|
return await this.request({
|
|
628
635
|
method: 'GET',
|
|
@@ -57,10 +57,8 @@ commandSandboxCp.addHelpText('after', texts_1.EXAMPLE_SANDBOX_CP);
|
|
|
57
57
|
const upload = async (client, workspace, project, source, destination) => {
|
|
58
58
|
const { sourcePath, sourceStats } = input_1.default.restApiSandboxUploadSourcePath(source);
|
|
59
59
|
const { identifier, remotePath, isRemoteDir } = input_1.default.restApiSandboxUploadDestinationPath(destination);
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
const found = sandboxes.find((s) => s.identifier === identifier);
|
|
63
|
-
if (!found) {
|
|
60
|
+
const { sandbox_id } = await client.getSandboxByIdentifier(workspace, project, identifier);
|
|
61
|
+
if (!sandbox_id) {
|
|
64
62
|
output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
|
|
65
63
|
}
|
|
66
64
|
if (sourceStats.isFile()) {
|
|
@@ -68,7 +66,7 @@ const upload = async (client, workspace, project, source, destination) => {
|
|
|
68
66
|
const name = (0, path_1.basename)(sourcePath);
|
|
69
67
|
output_1.default.normal((0, texts_1.TXT_SANDBOX_CP_PROGRESS)(1, 1, name));
|
|
70
68
|
const remoteFile = isRemoteDir ? (0, path_1.join)(remotePath, name) : remotePath;
|
|
71
|
-
await client.sandboxUploadFile(workspace,
|
|
69
|
+
await client.sandboxUploadFile(workspace, sandbox_id, remoteFile, sourcePath);
|
|
72
70
|
output_1.default.exitSuccess((0, texts_1.TXT_SANDBOX_CP_DONE)(1));
|
|
73
71
|
}
|
|
74
72
|
else if (sourceStats.isDirectory()) {
|
|
@@ -90,7 +88,7 @@ const upload = async (client, workspace, project, source, destination) => {
|
|
|
90
88
|
const remoteFile = (0, path_1.join)(baseRemoteDir, relativePath).replace(/\\/g, '/');
|
|
91
89
|
output_1.default.clearPreviousLine();
|
|
92
90
|
output_1.default.normal((0, texts_1.TXT_SANDBOX_CP_PROGRESS)(i + 1, files.length, relativePath));
|
|
93
|
-
await client.sandboxUploadFile(workspace,
|
|
91
|
+
await client.sandboxUploadFile(workspace, sandbox_id, remoteFile, localFile);
|
|
94
92
|
}
|
|
95
93
|
output_1.default.exitSuccess((0, texts_1.TXT_SANDBOX_CP_DONE)(files.length));
|
|
96
94
|
}
|
|
@@ -101,14 +99,12 @@ const upload = async (client, workspace, project, source, destination) => {
|
|
|
101
99
|
const download = async (client, workspace, project, source, destination, merge, replace) => {
|
|
102
100
|
const { destPath, isDestPathDir } = input_1.default.restApiSandboxDownloadDestinationPath(destination, merge, replace);
|
|
103
101
|
const { sourcePath, identifier } = input_1.default.restApiSandboxDownloadSourcePath(source);
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
const found = sandboxes.find((s) => s.identifier === identifier);
|
|
107
|
-
if (!found) {
|
|
102
|
+
const { sandbox_id } = await client.getSandboxByIdentifier(workspace, project, identifier);
|
|
103
|
+
if (!sandbox_id) {
|
|
108
104
|
output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
|
|
109
105
|
}
|
|
110
106
|
output_1.default.normal(texts_1.TXT_SANDBOX_CP_DOWNLOAD, false);
|
|
111
|
-
const { body, headers } = await client.sandboxDownloadFile(workspace,
|
|
107
|
+
const { body, headers } = await client.sandboxDownloadFile(workspace, sandbox_id, sourcePath);
|
|
112
108
|
const isFile = headers['content-type'] === 'application/octet-stream';
|
|
113
109
|
const name = (0, path_1.basename)(sourcePath);
|
|
114
110
|
if (isFile) {
|
|
@@ -17,17 +17,15 @@ commandSandboxDestroy.action(async (identifier, options) => {
|
|
|
17
17
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
18
18
|
const project = input_1.default.restApiProject(options.project);
|
|
19
19
|
const client = input_1.default.restApiTokenClient();
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
const found = sandboxes.find((s) => s.identifier === identifier);
|
|
23
|
-
if (!found) {
|
|
20
|
+
const { sandbox_id } = await client.getSandboxByIdentifier(workspace, project, identifier);
|
|
21
|
+
if (!sandbox_id) {
|
|
24
22
|
output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
|
|
25
23
|
}
|
|
26
24
|
const confirmed = options.force ||
|
|
27
25
|
(await output_1.default.confirm((0, texts_1.TXT_SANDBOX_DESTROY_CONFIRM)(identifier)));
|
|
28
26
|
if (!confirmed)
|
|
29
27
|
output_1.default.exitNormal();
|
|
30
|
-
await client.deleteSandbox(workspace,
|
|
28
|
+
await client.deleteSandbox(workspace, sandbox_id);
|
|
31
29
|
output_1.default.exitSuccess((0, texts_1.TXT_SANDBOX_DESTROYED)(identifier));
|
|
32
30
|
});
|
|
33
31
|
exports.default = commandSandboxDestroy;
|
|
@@ -15,13 +15,11 @@ commandSandboxEndpointAdd.action(async (identifier, options) => {
|
|
|
15
15
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
16
16
|
const project = input_1.default.restApiProject(options.project);
|
|
17
17
|
const client = input_1.default.restApiTokenClient();
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
const found = sandboxes.find((s) => s.identifier === identifier);
|
|
21
|
-
if (!found) {
|
|
18
|
+
const { sandbox_id } = await client.getSandboxByIdentifier(workspace, project, identifier);
|
|
19
|
+
if (!sandbox_id) {
|
|
22
20
|
output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
|
|
23
21
|
}
|
|
24
|
-
const sandbox = await client.getSandbox(workspace,
|
|
22
|
+
const sandbox = await client.getSandbox(workspace, sandbox_id);
|
|
25
23
|
const endpoints = sandbox.endpoints || [];
|
|
26
24
|
const existing = endpoints.find((ep) => ep.name === options.name);
|
|
27
25
|
if (existing) {
|
|
@@ -30,7 +28,7 @@ commandSandboxEndpointAdd.action(async (identifier, options) => {
|
|
|
30
28
|
const endpoint = input_1.default.prepareSandboxEndpoint(options);
|
|
31
29
|
logger_1.default.info(endpoint);
|
|
32
30
|
const updatedEndpoints = [...endpoints, endpoint];
|
|
33
|
-
const updatedSandbox = await client.updateSandbox(workspace,
|
|
31
|
+
const updatedSandbox = await client.updateSandbox(workspace, sandbox_id, {
|
|
34
32
|
endpoints: updatedEndpoints,
|
|
35
33
|
});
|
|
36
34
|
const addedEndpoint = (updatedSandbox.endpoints || []).find((ep) => ep.name === options.name);
|
|
@@ -19,13 +19,11 @@ commandSandboxEndpointDelete.action(async (identifier, endpointName, options) =>
|
|
|
19
19
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
20
20
|
const project = input_1.default.restApiProject(options.project);
|
|
21
21
|
const client = input_1.default.restApiTokenClient();
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
const found = sandboxes.find((s) => s.identifier === identifier);
|
|
25
|
-
if (!found) {
|
|
22
|
+
const { sandbox_id } = await client.getSandboxByIdentifier(workspace, project, identifier);
|
|
23
|
+
if (!sandbox_id) {
|
|
26
24
|
output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
|
|
27
25
|
}
|
|
28
|
-
const sandbox = await client.getSandbox(workspace,
|
|
26
|
+
const sandbox = await client.getSandbox(workspace, sandbox_id);
|
|
29
27
|
const endpoints = sandbox.endpoints || [];
|
|
30
28
|
const endpointIndex = endpoints.findIndex((ep) => ep.name === endpointName);
|
|
31
29
|
if (endpointIndex === -1) {
|
|
@@ -36,7 +34,7 @@ commandSandboxEndpointDelete.action(async (identifier, endpointName, options) =>
|
|
|
36
34
|
(await output_1.default.confirm((0, texts_1.TXT_SANDBOX_ENDPOINT_DELETE_CONFIRM)(identifier, endpointName)));
|
|
37
35
|
if (!confirmed)
|
|
38
36
|
output_1.default.exitNormal();
|
|
39
|
-
await client.updateSandbox(workspace,
|
|
37
|
+
await client.updateSandbox(workspace, sandbox_id, {
|
|
40
38
|
endpoints: updatedEndpoints,
|
|
41
39
|
});
|
|
42
40
|
output_1.default.exitSuccess((0, texts_1.TXT_SANDBOX_ENDPOINT_DELETED)(endpointName));
|
|
@@ -17,13 +17,11 @@ commandSandboxEndpointGet.action(async (identifier, endpointName, options) => {
|
|
|
17
17
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
18
18
|
const project = input_1.default.restApiProject(options.project);
|
|
19
19
|
const client = input_1.default.restApiTokenClient();
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
const found = sandboxes.find((s) => s.identifier === identifier);
|
|
23
|
-
if (!found) {
|
|
20
|
+
const { sandbox_id } = await client.getSandboxByIdentifier(workspace, project, identifier);
|
|
21
|
+
if (!sandbox_id) {
|
|
24
22
|
output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
|
|
25
23
|
}
|
|
26
|
-
const sandbox = await client.getSandbox(workspace,
|
|
24
|
+
const sandbox = await client.getSandbox(workspace, sandbox_id);
|
|
27
25
|
const endpoints = sandbox.endpoints || [];
|
|
28
26
|
const endpoint = endpoints.find((ep) => ep.name === endpointName);
|
|
29
27
|
if (!endpoint) {
|
|
@@ -17,13 +17,11 @@ commandSandboxEndpointList.action(async (identifier, options) => {
|
|
|
17
17
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
18
18
|
const project = input_1.default.restApiProject(options.project);
|
|
19
19
|
const client = input_1.default.restApiTokenClient();
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
const found = sandboxes.find((s) => s.identifier === identifier);
|
|
23
|
-
if (!found) {
|
|
20
|
+
const { sandbox_id } = await client.getSandboxByIdentifier(workspace, project, identifier);
|
|
21
|
+
if (!sandbox_id) {
|
|
24
22
|
output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
|
|
25
23
|
}
|
|
26
|
-
const sandbox = await client.getSandbox(workspace,
|
|
24
|
+
const sandbox = await client.getSandbox(workspace, sandbox_id);
|
|
27
25
|
const endpoints = sandbox.endpoints || [];
|
|
28
26
|
if (endpoints.length === 0) {
|
|
29
27
|
output_1.default.exitError(texts_1.ERR_SANDBOX_ENDPOINTS_NOT_FOUND);
|
|
@@ -22,13 +22,11 @@ commandSandboxExecCommand.action(async (identifier, command, options) => {
|
|
|
22
22
|
const project = input_1.default.restApiProject(options.project);
|
|
23
23
|
const client = input_1.default.restApiTokenClient();
|
|
24
24
|
const runtime = input_1.default.restApiSandboxExecRuntime(options.runtime);
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
const found = sandboxes.find((s) => s.identifier === identifier);
|
|
28
|
-
if (!found) {
|
|
25
|
+
const { sandbox_id } = await client.getSandboxByIdentifier(workspace, project, identifier);
|
|
26
|
+
if (!sandbox_id) {
|
|
29
27
|
output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
|
|
30
28
|
}
|
|
31
|
-
const cmdResult = await client.executeSandboxCommand(workspace,
|
|
29
|
+
const cmdResult = await client.executeSandboxCommand(workspace, sandbox_id, {
|
|
32
30
|
command,
|
|
33
31
|
runtime,
|
|
34
32
|
});
|
|
@@ -37,7 +35,7 @@ commandSandboxExecCommand.action(async (identifier, command, options) => {
|
|
|
37
35
|
output_1.default.exitSuccess((0, texts_1.TXT_SANDBOX_EXEC_BACKGROUND)(cmdResult.id));
|
|
38
36
|
}
|
|
39
37
|
else {
|
|
40
|
-
const body = await client.streamSandboxCommandLogs(workspace,
|
|
38
|
+
const body = await client.streamSandboxCommandLogs(workspace, sandbox_id, cmdResult.id);
|
|
41
39
|
body.on('data', (data) => {
|
|
42
40
|
if (data) {
|
|
43
41
|
try {
|
|
@@ -54,7 +52,7 @@ commandSandboxExecCommand.action(async (identifier, command, options) => {
|
|
|
54
52
|
}
|
|
55
53
|
});
|
|
56
54
|
body.on('close', async () => {
|
|
57
|
-
const cmdExit = await client.getSandboxCommand(workspace,
|
|
55
|
+
const cmdExit = await client.getSandboxCommand(workspace, sandbox_id, cmdResult.id);
|
|
58
56
|
if (cmdExit.status === utils_1.SANDBOX_EXEC_STATUS.SUCCESSFUL) {
|
|
59
57
|
output_1.default.exitSuccess((0, texts_1.TXT_SANDBOX_EXEC_SUCCESS)(cmdResult.id));
|
|
60
58
|
}
|
|
@@ -18,17 +18,15 @@ commandSandboxExecKill.action(async (identifier, commandId, options) => {
|
|
|
18
18
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
19
19
|
const project = input_1.default.restApiProject(options.project);
|
|
20
20
|
const client = input_1.default.restApiTokenClient();
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
const found = sandboxes.find((s) => s.identifier === identifier);
|
|
24
|
-
if (!found) {
|
|
21
|
+
const { sandbox_id } = await client.getSandboxByIdentifier(workspace, project, identifier);
|
|
22
|
+
if (!sandbox_id) {
|
|
25
23
|
output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
|
|
26
24
|
}
|
|
27
25
|
const confirmed = options.force ||
|
|
28
26
|
(await output_1.default.confirm((0, texts_1.OPTION_SANDBOX_COMMAND_KILL_CONFIRM)(identifier, commandId)));
|
|
29
27
|
if (!confirmed)
|
|
30
28
|
output_1.default.exitNormal();
|
|
31
|
-
await client.terminateSandboxCommand(workspace,
|
|
29
|
+
await client.terminateSandboxCommand(workspace, sandbox_id, commandId);
|
|
32
30
|
output_1.default.exitSuccess((0, texts_1.TXT_SANDBOX_COMMAND_KILLED)(commandId));
|
|
33
31
|
});
|
|
34
32
|
exports.default = commandSandboxExecKill;
|
|
@@ -17,13 +17,11 @@ commandSandboxExecList.action(async (identifier, options) => {
|
|
|
17
17
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
18
18
|
const project = input_1.default.restApiProject(options.project);
|
|
19
19
|
const client = input_1.default.restApiTokenClient();
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
const found = sandboxes.find((s) => s.identifier === identifier);
|
|
23
|
-
if (!found) {
|
|
20
|
+
const { sandbox_id } = await client.getSandboxByIdentifier(workspace, project, identifier);
|
|
21
|
+
if (!sandbox_id) {
|
|
24
22
|
output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
|
|
25
23
|
}
|
|
26
|
-
const commandsResult = await client.listSandboxCommands(workspace,
|
|
24
|
+
const commandsResult = await client.listSandboxCommands(workspace, sandbox_id);
|
|
27
25
|
const commands = commandsResult.commands || [];
|
|
28
26
|
if (commands.length === 0) {
|
|
29
27
|
output_1.default.exitError(texts_1.ERR_SANDBOX_NO_COMMANDS);
|
|
@@ -19,13 +19,11 @@ commandSandboxExecLogs.action(async (identifier, commandId, options) => {
|
|
|
19
19
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
20
20
|
const project = input_1.default.restApiProject(options.project);
|
|
21
21
|
const client = input_1.default.restApiTokenClient();
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
const found = sandboxes.find((s) => s.identifier === identifier);
|
|
25
|
-
if (!found) {
|
|
22
|
+
const { sandbox_id } = await client.getSandboxByIdentifier(workspace, project, identifier);
|
|
23
|
+
if (!sandbox_id) {
|
|
26
24
|
output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
|
|
27
25
|
}
|
|
28
|
-
const body = await client.streamSandboxCommandLogs(workspace,
|
|
26
|
+
const body = await client.streamSandboxCommandLogs(workspace, sandbox_id, commandId, !!options.wait);
|
|
29
27
|
body.on('data', (data) => {
|
|
30
28
|
if (data) {
|
|
31
29
|
try {
|
|
@@ -42,7 +40,7 @@ commandSandboxExecLogs.action(async (identifier, commandId, options) => {
|
|
|
42
40
|
}
|
|
43
41
|
});
|
|
44
42
|
body.on('close', async () => {
|
|
45
|
-
const cmdExit = await client.getSandboxCommand(workspace,
|
|
43
|
+
const cmdExit = await client.getSandboxCommand(workspace, sandbox_id, commandId);
|
|
46
44
|
if (cmdExit.status === utils_1.SANDBOX_EXEC_STATUS.SUCCESSFUL) {
|
|
47
45
|
output_1.default.exitSuccess((0, texts_1.TXT_SANDBOX_EXEC_SUCCESS)(commandId));
|
|
48
46
|
}
|
|
@@ -17,13 +17,11 @@ commandSandboxExecStatus.action(async (identifier, commandId, options) => {
|
|
|
17
17
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
18
18
|
const project = input_1.default.restApiProject(options.project);
|
|
19
19
|
const client = input_1.default.restApiTokenClient();
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
const found = sandboxes.find((s) => s.identifier === identifier);
|
|
23
|
-
if (!found) {
|
|
20
|
+
const { sandbox_id } = await client.getSandboxByIdentifier(workspace, project, identifier);
|
|
21
|
+
if (!sandbox_id) {
|
|
24
22
|
output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
|
|
25
23
|
}
|
|
26
|
-
const cmd = await client.getSandboxCommand(workspace,
|
|
24
|
+
const cmd = await client.getSandboxCommand(workspace, sandbox_id, commandId);
|
|
27
25
|
const data = [
|
|
28
26
|
['Property', 'Value'],
|
|
29
27
|
['Command ID', cmd.id || '-'],
|
|
@@ -15,13 +15,11 @@ commandSandboxGet.action(async (identifier, options) => {
|
|
|
15
15
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
16
16
|
const project = input_1.default.restApiProject(options.project);
|
|
17
17
|
const client = input_1.default.restApiTokenClient();
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
const found = sandboxes.find((s) => s.identifier === identifier);
|
|
21
|
-
if (!found) {
|
|
18
|
+
const { sandbox_id } = await client.getSandboxByIdentifier(workspace, project, identifier);
|
|
19
|
+
if (!sandbox_id) {
|
|
22
20
|
output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
|
|
23
21
|
}
|
|
24
|
-
const sandbox = await client.getSandbox(workspace,
|
|
22
|
+
const sandbox = await client.getSandbox(workspace, sandbox_id);
|
|
25
23
|
const data = [
|
|
26
24
|
['Field', 'Value'],
|
|
27
25
|
['ID', sandbox.id || '-'],
|
|
@@ -16,18 +16,16 @@ commandSandboxRestart.action(async (identifier, options) => {
|
|
|
16
16
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
17
17
|
const project = input_1.default.restApiProject(options.project);
|
|
18
18
|
const client = input_1.default.restApiTokenClient();
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
const found = sandboxes.find((s) => s.identifier === identifier);
|
|
22
|
-
if (!found) {
|
|
19
|
+
const { sandbox_id } = await client.getSandboxByIdentifier(workspace, project, identifier);
|
|
20
|
+
if (!sandbox_id) {
|
|
23
21
|
output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
|
|
24
22
|
}
|
|
25
|
-
await client.restartSandbox(workspace,
|
|
23
|
+
await client.restartSandbox(workspace, sandbox_id);
|
|
26
24
|
if (options.wait) {
|
|
27
25
|
output_1.default.normal(texts_1.TXT_SANDBOX_WAITING_START);
|
|
28
26
|
const timeout = parseInt(options.wait, 10) || 300;
|
|
29
27
|
try {
|
|
30
|
-
const status = await client.sandboxWaitForRunning(workspace,
|
|
28
|
+
const status = await client.sandboxWaitForRunning(workspace, sandbox_id, timeout);
|
|
31
29
|
if (status !== utils_1.SANDBOX_STATUS.RUNNING) {
|
|
32
30
|
output_1.default.exitError(texts_1.ERR_SANDBOX_RUNNING_FAILED);
|
|
33
31
|
}
|
|
@@ -20,10 +20,8 @@ commandSandboxSnapshotCreate.action(async (identifier, options) => {
|
|
|
20
20
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
21
21
|
const project = input_1.default.restApiProject(options.project);
|
|
22
22
|
const client = input_1.default.restApiTokenClient();
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
const found = sandboxes.find((s) => s.identifier === identifier);
|
|
26
|
-
if (!found) {
|
|
23
|
+
const { sandbox_id } = await client.getSandboxByIdentifier(workspace, project, identifier);
|
|
24
|
+
if (!sandbox_id) {
|
|
27
25
|
output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
|
|
28
26
|
}
|
|
29
27
|
const defaultName = 'snapshot-' + (0, human_id_1.default)({ separator: '-', capitalize: false });
|
|
@@ -31,13 +29,13 @@ commandSandboxSnapshotCreate.action(async (identifier, options) => {
|
|
|
31
29
|
const body = {
|
|
32
30
|
name: snapshotName,
|
|
33
31
|
};
|
|
34
|
-
const snapshot = await client.createSandboxSnapshot(workspace,
|
|
32
|
+
const snapshot = await client.createSandboxSnapshot(workspace, sandbox_id, body);
|
|
35
33
|
const snapshotId = snapshot.id;
|
|
36
34
|
if (options.wait) {
|
|
37
35
|
output_1.default.normal(texts_1.TXT_SANDBOX_SNAPSHOT_WAITING);
|
|
38
36
|
const timeout = parseInt(options.wait, 10) || 300;
|
|
39
37
|
try {
|
|
40
|
-
const status = await client.sandboxWaitForSnapshot(workspace,
|
|
38
|
+
const status = await client.sandboxWaitForSnapshot(workspace, sandbox_id, snapshotId, timeout);
|
|
41
39
|
if (status !== utils_1.SANDBOX_SNAPSHOT_STATUS.CREATED) {
|
|
42
40
|
output_1.default.exitError(texts_1.ERR_SANDBOX_SNAPSHOT_FAILED);
|
|
43
41
|
}
|
|
@@ -19,13 +19,11 @@ commandSandboxSnapshotDelete.action(async (identifier, snapshotName, options) =>
|
|
|
19
19
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
20
20
|
const project = input_1.default.restApiProject(options.project);
|
|
21
21
|
const client = input_1.default.restApiTokenClient();
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
const found = sandboxes.find((s) => s.identifier === identifier);
|
|
25
|
-
if (!found) {
|
|
22
|
+
const { sandbox_id } = await client.getSandboxByIdentifier(workspace, project, identifier);
|
|
23
|
+
if (!sandbox_id) {
|
|
26
24
|
output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
|
|
27
25
|
}
|
|
28
|
-
const snapshotsResult = await client.listSandboxSnapshots(workspace,
|
|
26
|
+
const snapshotsResult = await client.listSandboxSnapshots(workspace, sandbox_id);
|
|
29
27
|
const snapshots = snapshotsResult.snapshots || [];
|
|
30
28
|
const foundSnapshot = snapshots.find((s) => s.name === snapshotName);
|
|
31
29
|
if (!foundSnapshot) {
|
|
@@ -35,7 +33,7 @@ commandSandboxSnapshotDelete.action(async (identifier, snapshotName, options) =>
|
|
|
35
33
|
(await output_1.default.confirm((0, texts_1.TXT_SANDBOX_SNAPSHOT_DELETE_CONFIRM)(identifier, snapshotName)));
|
|
36
34
|
if (!confirmed)
|
|
37
35
|
output_1.default.exitNormal();
|
|
38
|
-
await client.deleteSandboxSnapshot(workspace,
|
|
36
|
+
await client.deleteSandboxSnapshot(workspace, sandbox_id, foundSnapshot.id);
|
|
39
37
|
output_1.default.exitSuccess((0, texts_1.TXT_SANDBOX_SNAPSHOT_DELETED)(snapshotName));
|
|
40
38
|
});
|
|
41
39
|
exports.default = commandSandboxSnapshotDelete;
|
|
@@ -17,19 +17,17 @@ commandSandboxSnapshotGet.action(async (identifier, snapshotName, options) => {
|
|
|
17
17
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
18
18
|
const project = input_1.default.restApiProject(options.project);
|
|
19
19
|
const client = input_1.default.restApiTokenClient();
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
const found = sandboxes.find((s) => s.identifier === identifier);
|
|
23
|
-
if (!found) {
|
|
20
|
+
const { sandbox_id } = await client.getSandboxByIdentifier(workspace, project, identifier);
|
|
21
|
+
if (!sandbox_id) {
|
|
24
22
|
output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
|
|
25
23
|
}
|
|
26
|
-
const snapshotsResult = await client.listSandboxSnapshots(workspace,
|
|
24
|
+
const snapshotsResult = await client.listSandboxSnapshots(workspace, sandbox_id);
|
|
27
25
|
const snapshots = snapshotsResult.snapshots || [];
|
|
28
26
|
const foundSnapshot = snapshots.find((s) => s.name === snapshotName);
|
|
29
27
|
if (!foundSnapshot) {
|
|
30
28
|
output_1.default.exitError(texts_1.ERR_SANDBOX_SNAPSHOT_NOT_FOUND);
|
|
31
29
|
}
|
|
32
|
-
const snapshot = await client.getSandboxSnapshot(workspace,
|
|
30
|
+
const snapshot = await client.getSandboxSnapshot(workspace, sandbox_id, foundSnapshot.id);
|
|
33
31
|
const data = [
|
|
34
32
|
['Field', 'Value'],
|
|
35
33
|
['Name', snapshot.name || '-'],
|
|
@@ -19,13 +19,11 @@ commandSandboxSnapshotList.action(async (identifier, options) => {
|
|
|
19
19
|
const client = input_1.default.restApiTokenClient();
|
|
20
20
|
let snapshots;
|
|
21
21
|
if (identifier) {
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
const found = sandboxes.find((s) => s.identifier === identifier);
|
|
25
|
-
if (!found) {
|
|
22
|
+
const { sandbox_id } = await client.getSandboxByIdentifier(workspace, project, identifier);
|
|
23
|
+
if (!sandbox_id) {
|
|
26
24
|
output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
|
|
27
25
|
}
|
|
28
|
-
const snapshotsResult = await client.listSandboxSnapshots(workspace,
|
|
26
|
+
const snapshotsResult = await client.listSandboxSnapshots(workspace, sandbox_id);
|
|
29
27
|
snapshots = snapshotsResult.snapshots || [];
|
|
30
28
|
}
|
|
31
29
|
else {
|
|
@@ -16,18 +16,16 @@ commandSandboxStart.action(async (identifier, options) => {
|
|
|
16
16
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
17
17
|
const project = input_1.default.restApiProject(options.project);
|
|
18
18
|
const client = input_1.default.restApiTokenClient();
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
const found = sandboxes.find((s) => s.identifier === identifier);
|
|
22
|
-
if (!found) {
|
|
19
|
+
const { sandbox_id } = await client.getSandboxByIdentifier(workspace, project, identifier);
|
|
20
|
+
if (!sandbox_id) {
|
|
23
21
|
output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
|
|
24
22
|
}
|
|
25
|
-
await client.startSandbox(workspace,
|
|
23
|
+
await client.startSandbox(workspace, sandbox_id);
|
|
26
24
|
if (options.wait) {
|
|
27
25
|
output_1.default.normal(texts_1.TXT_SANDBOX_WAITING_START);
|
|
28
26
|
const timeout = parseInt(options.wait, 10) || 300;
|
|
29
27
|
try {
|
|
30
|
-
const status = await client.sandboxWaitForRunning(workspace,
|
|
28
|
+
const status = await client.sandboxWaitForRunning(workspace, sandbox_id, timeout);
|
|
31
29
|
if (status !== utils_1.SANDBOX_STATUS.RUNNING) {
|
|
32
30
|
output_1.default.exitError(texts_1.ERR_SANDBOX_RUNNING_FAILED);
|
|
33
31
|
}
|
|
@@ -15,13 +15,11 @@ commandSandboxStatus.action(async (identifier, options) => {
|
|
|
15
15
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
16
16
|
const project = input_1.default.restApiProject(options.project);
|
|
17
17
|
const client = input_1.default.restApiTokenClient();
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
const found = sandboxes.find((s) => s.identifier === identifier);
|
|
21
|
-
if (!found) {
|
|
18
|
+
const { sandbox_id } = await client.getSandboxByIdentifier(workspace, project, identifier);
|
|
19
|
+
if (!sandbox_id) {
|
|
22
20
|
output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
|
|
23
21
|
}
|
|
24
|
-
const sandbox = await client.getSandbox(workspace,
|
|
22
|
+
const sandbox = await client.getSandbox(workspace, sandbox_id);
|
|
25
23
|
output_1.default.table([
|
|
26
24
|
['Type', 'Status'],
|
|
27
25
|
['Status', sandbox.status || 'UNKNOWN'],
|
|
@@ -16,18 +16,16 @@ commandSandboxStop.action(async (identifier, options) => {
|
|
|
16
16
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
17
17
|
const project = input_1.default.restApiProject(options.project);
|
|
18
18
|
const client = input_1.default.restApiTokenClient();
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
const found = sandboxes.find((s) => s.identifier === identifier);
|
|
22
|
-
if (!found) {
|
|
19
|
+
const { sandbox_id } = await client.getSandboxByIdentifier(workspace, project, identifier);
|
|
20
|
+
if (!sandbox_id) {
|
|
23
21
|
output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
|
|
24
22
|
}
|
|
25
|
-
await client.stopSandbox(workspace,
|
|
23
|
+
await client.stopSandbox(workspace, sandbox_id);
|
|
26
24
|
if (options.wait) {
|
|
27
25
|
output_1.default.normal(texts_1.TXT_SANDBOX_WAITING_STOP);
|
|
28
26
|
const timeout = parseInt(options.wait, 10) || 300;
|
|
29
27
|
try {
|
|
30
|
-
const status = await client.sandboxWaitForRunning(workspace,
|
|
28
|
+
const status = await client.sandboxWaitForRunning(workspace, sandbox_id, timeout);
|
|
31
29
|
if (status !== utils_1.SANDBOX_STATUS.STOPPED) {
|
|
32
30
|
output_1.default.exitError(texts_1.ERR_SANDBOX_STOP_FAILED);
|
|
33
31
|
}
|
|
@@ -21,22 +21,19 @@ commandSandboxUpdate.action(async (identifier, yamlFile, options) => {
|
|
|
21
21
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
22
22
|
const project = input_1.default.restApiProject(options.project);
|
|
23
23
|
const client = input_1.default.restApiTokenClient();
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const found = sandboxes.find((s) => s.identifier === identifier);
|
|
27
|
-
if (!found) {
|
|
24
|
+
const { sandbox_id } = await client.getSandboxByIdentifier(workspace, project, identifier);
|
|
25
|
+
if (!sandbox_id) {
|
|
28
26
|
output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
|
|
29
27
|
}
|
|
30
|
-
const sandboxId = found.id;
|
|
31
28
|
const body = {
|
|
32
29
|
yaml: Buffer.from(yaml, 'utf8').toString('base64'),
|
|
33
30
|
};
|
|
34
|
-
result = await client.updateSandboxByYaml(workspace,
|
|
31
|
+
const result = await client.updateSandboxByYaml(workspace, sandbox_id, body);
|
|
35
32
|
if (options.waitForRunning) {
|
|
36
33
|
output_1.default.normal(texts_1.TXT_SANDBOX_WAITING_RUNNING);
|
|
37
34
|
const timeout = parseInt(options.waitForRunning, 10) || 300;
|
|
38
35
|
try {
|
|
39
|
-
const status = await client.sandboxWaitForRunning(workspace,
|
|
36
|
+
const status = await client.sandboxWaitForRunning(workspace, sandbox_id, timeout);
|
|
40
37
|
if (status !== utils_1.SANDBOX_STATUS.RUNNING) {
|
|
41
38
|
output_1.default.exitError(texts_1.ERR_SANDBOX_RUNNING_FAILED);
|
|
42
39
|
}
|
|
@@ -49,7 +46,7 @@ commandSandboxUpdate.action(async (identifier, yamlFile, options) => {
|
|
|
49
46
|
output_1.default.normal(texts_1.TXT_SANDBOX_WAITING_SETUP);
|
|
50
47
|
const timeout = parseInt(options.waitForConfigured, 10) || 300;
|
|
51
48
|
try {
|
|
52
|
-
const status = await client.sandboxWaitForConfigured(workspace,
|
|
49
|
+
const status = await client.sandboxWaitForConfigured(workspace, sandbox_id, timeout);
|
|
53
50
|
if (status !== utils_1.SANDBOX_SETUP_STATUS.SUCCESS) {
|
|
54
51
|
output_1.default.exitError(texts_1.ERR_SANDBOX_SETUP_FAILED);
|
|
55
52
|
}
|
|
@@ -17,14 +17,11 @@ commandSandboxYaml.action(async (identifier, options) => {
|
|
|
17
17
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
18
18
|
const project = input_1.default.restApiProject(options.project);
|
|
19
19
|
const client = input_1.default.restApiTokenClient();
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const found = sandboxes.find((s) => s.identifier === identifier);
|
|
23
|
-
if (!found) {
|
|
20
|
+
const { sandbox_id } = await client.getSandboxByIdentifier(workspace, project, identifier);
|
|
21
|
+
if (!sandbox_id) {
|
|
24
22
|
output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
|
|
25
23
|
}
|
|
26
|
-
const
|
|
27
|
-
result = await client.getSandboxYaml(workspace, sandboxId);
|
|
24
|
+
const result = await client.getSandboxYaml(workspace, sandbox_id);
|
|
28
25
|
output_1.default.exitNormal(Buffer.from(result.yaml, 'base64').toString('utf8'));
|
|
29
26
|
});
|
|
30
27
|
exports.default = commandSandboxYaml;
|