bdy 1.16.11-master → 1.16.11-sbs-2
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 +4 -3
- package/distTs/src/api/client.js +78 -2
- package/distTs/src/command/agent/install.js +11 -17
- package/distTs/src/command/login.js +298 -0
- package/distTs/src/command/logout.js +15 -0
- package/distTs/src/command/package/download.js +259 -0
- package/distTs/src/command/package/publish.js +231 -0
- package/distTs/src/command/package.js +14 -0
- package/distTs/src/command/project/list.js +61 -0
- package/distTs/src/command/project/set.js +85 -0
- package/distTs/src/command/project.js +14 -0
- package/distTs/src/command/sandbox/command/kill.js +35 -0
- package/distTs/src/command/sandbox/command/list.js +54 -0
- package/distTs/src/command/sandbox/command/logs.js +133 -0
- package/distTs/src/command/sandbox/command/status.js +44 -0
- package/distTs/src/command/sandbox/command.js +18 -0
- package/distTs/src/command/sandbox/cp.js +123 -0
- package/distTs/src/command/sandbox/create.js +99 -0
- package/distTs/src/command/sandbox/destroy.js +35 -0
- package/distTs/src/command/sandbox/endpoint/add.js +91 -0
- package/distTs/src/command/sandbox/endpoint/delete.js +46 -0
- package/distTs/src/command/sandbox/endpoint/get.js +58 -0
- package/distTs/src/command/sandbox/endpoint/list.js +51 -0
- package/distTs/src/command/sandbox/endpoint/update.js +85 -0
- package/distTs/src/command/sandbox/endpoint.js +20 -0
- package/distTs/src/command/sandbox/exec.js +127 -0
- package/distTs/src/command/sandbox/get.js +51 -0
- package/distTs/src/command/sandbox/list.js +41 -0
- package/distTs/src/command/sandbox/restart.js +49 -0
- package/distTs/src/command/sandbox/snapshot/create.js +68 -0
- package/distTs/src/command/sandbox/snapshot/delete.js +42 -0
- package/distTs/src/command/sandbox/snapshot/get.js +54 -0
- package/distTs/src/command/sandbox/snapshot/list.js +48 -0
- package/distTs/src/command/sandbox/snapshot.js +18 -0
- package/distTs/src/command/sandbox/start.js +49 -0
- package/distTs/src/command/sandbox/status.js +35 -0
- package/distTs/src/command/sandbox/stop.js +49 -0
- package/distTs/src/command/sandbox.js +36 -0
- package/distTs/src/command/tunnel/http.js +4 -3
- package/distTs/src/command/tunnel/tcp.js +4 -3
- package/distTs/src/command/tunnel/tls.js +4 -3
- package/distTs/src/command/workspace/list.js +57 -0
- package/distTs/src/command/workspace/set.js +81 -0
- package/distTs/src/command/workspace.js +14 -0
- package/distTs/src/index.js +10 -0
- package/distTs/src/input.js +24 -4
- package/distTs/src/texts.js +164 -8
- package/distTs/src/tunnel/cfg.js +53 -4
- package/package.json +4 -3
- package/distTs/src/command/agent/standalone/kill.js +0 -22
- package/distTs/src/command/agent/standalone.js +0 -136
- package/distTs/src/command/vt/scrap.js +0 -193
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("../../../utils");
|
|
7
|
+
const texts_1 = require("../../../texts");
|
|
8
|
+
const 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
|
+
// Find sandbox by identifier
|
|
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
|
+
// Find snapshot by name
|
|
33
|
+
const snapshotsResult = await client.listSandboxSnapshots(workspace, found.id);
|
|
34
|
+
const snapshots = snapshotsResult.snapshots || [];
|
|
35
|
+
const foundSnapshot = snapshots.find((s) => s.name === snapshotName);
|
|
36
|
+
if (!foundSnapshot) {
|
|
37
|
+
output_1.default.exitError(texts_1.ERR_SANDBOX_SNAPSHOT_NOT_FOUND);
|
|
38
|
+
}
|
|
39
|
+
const snapshot = await client.getSandboxSnapshot(workspace, found.id, foundSnapshot.id);
|
|
40
|
+
const data = [
|
|
41
|
+
['Property', 'Value'],
|
|
42
|
+
['Name', snapshot.name || '-'],
|
|
43
|
+
['Status', snapshot.status || '-'],
|
|
44
|
+
['Description', snapshot.description || '-'],
|
|
45
|
+
['Created', snapshot.create_date || '-'],
|
|
46
|
+
['URL', snapshot.html_url || '-'],
|
|
47
|
+
];
|
|
48
|
+
if (snapshot.creator) {
|
|
49
|
+
data.push(['Creator', snapshot.creator.name || snapshot.creator.email || '-']);
|
|
50
|
+
}
|
|
51
|
+
output_1.default.table(data);
|
|
52
|
+
output_1.default.exitNormal();
|
|
53
|
+
});
|
|
54
|
+
exports.default = commandSandboxSnapshotGet;
|
|
@@ -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 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
|
+
// Find sandbox by identifier
|
|
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
|
+
if (snapshots.length === 0) {
|
|
34
|
+
output_1.default.normal('No snapshots found');
|
|
35
|
+
output_1.default.exitNormal();
|
|
36
|
+
}
|
|
37
|
+
const data = [['Name', 'Status', 'Created']];
|
|
38
|
+
for (const snapshot of snapshots) {
|
|
39
|
+
data.push([
|
|
40
|
+
snapshot.name || '-',
|
|
41
|
+
snapshot.status || '-',
|
|
42
|
+
snapshot.create_date || '-',
|
|
43
|
+
]);
|
|
44
|
+
}
|
|
45
|
+
output_1.default.table(data);
|
|
46
|
+
output_1.default.exitNormal();
|
|
47
|
+
});
|
|
48
|
+
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,49 @@
|
|
|
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.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
|
|
18
|
+
commandSandboxStart.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
|
+
// First list sandboxes to find by identifier
|
|
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
|
+
await client.startSandbox(workspace, found.id);
|
|
32
|
+
// Wait for sandbox to be running
|
|
33
|
+
const startTime = Date.now();
|
|
34
|
+
const maxWaitMs = 60000;
|
|
35
|
+
while (true) {
|
|
36
|
+
const sandbox = await client.getSandbox(workspace, found.id);
|
|
37
|
+
if (sandbox.status === 'RUNNING') {
|
|
38
|
+
output_1.default.exitSuccess((0, texts_1.TXT_SANDBOX_STARTED)(identifier));
|
|
39
|
+
}
|
|
40
|
+
if (sandbox.status === 'FAILED') {
|
|
41
|
+
output_1.default.exitError(texts_1.ERR_SANDBOX_START_TIMEOUT);
|
|
42
|
+
}
|
|
43
|
+
if (Date.now() - startTime > maxWaitMs) {
|
|
44
|
+
output_1.default.exitError(texts_1.ERR_SANDBOX_START_TIMEOUT);
|
|
45
|
+
}
|
|
46
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
exports.default = commandSandboxStart;
|
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
// First list sandboxes to find by identifier
|
|
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
|
+
// Get full sandbox details
|
|
32
|
+
const sandbox = await client.getSandbox(workspace, found.id);
|
|
33
|
+
output_1.default.exitNormal(sandbox.status || 'unknown');
|
|
34
|
+
});
|
|
35
|
+
exports.default = commandSandboxStatus;
|
|
@@ -0,0 +1,49 @@
|
|
|
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.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
|
|
18
|
+
commandSandboxStop.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
|
+
// First list sandboxes to find by identifier
|
|
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
|
+
await client.stopSandbox(workspace, found.id);
|
|
32
|
+
// Wait for sandbox to be stopped
|
|
33
|
+
const startTime = Date.now();
|
|
34
|
+
const maxWaitMs = 60000;
|
|
35
|
+
while (true) {
|
|
36
|
+
const sandbox = await client.getSandbox(workspace, found.id);
|
|
37
|
+
if (sandbox.status === 'STOPPED') {
|
|
38
|
+
output_1.default.exitSuccess((0, texts_1.TXT_SANDBOX_STOPPED)(identifier));
|
|
39
|
+
}
|
|
40
|
+
if (sandbox.status === 'FAILED') {
|
|
41
|
+
output_1.default.exitError(texts_1.ERR_SANDBOX_STOP_TIMEOUT);
|
|
42
|
+
}
|
|
43
|
+
if (Date.now() - startTime > maxWaitMs) {
|
|
44
|
+
output_1.default.exitError(texts_1.ERR_SANDBOX_STOP_TIMEOUT);
|
|
45
|
+
}
|
|
46
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
exports.default = commandSandboxStop;
|
|
@@ -0,0 +1,36 @@
|
|
|
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 exec_1 = __importDefault(require("./sandbox/exec"));
|
|
17
|
+
const cp_1 = __importDefault(require("./sandbox/cp"));
|
|
18
|
+
const command_1 = __importDefault(require("./sandbox/command"));
|
|
19
|
+
const snapshot_1 = __importDefault(require("./sandbox/snapshot"));
|
|
20
|
+
const endpoint_1 = __importDefault(require("./sandbox/endpoint"));
|
|
21
|
+
const commandSandbox = (0, utils_1.newCommand)('sandbox', texts_1.DESC_COMMAND_SANDBOX);
|
|
22
|
+
commandSandbox.alias('sb');
|
|
23
|
+
commandSandbox.addCommand(create_1.default);
|
|
24
|
+
commandSandbox.addCommand(list_1.default);
|
|
25
|
+
commandSandbox.addCommand(get_1.default);
|
|
26
|
+
commandSandbox.addCommand(destroy_1.default);
|
|
27
|
+
commandSandbox.addCommand(start_1.default);
|
|
28
|
+
commandSandbox.addCommand(stop_1.default);
|
|
29
|
+
commandSandbox.addCommand(restart_1.default);
|
|
30
|
+
commandSandbox.addCommand(status_1.default);
|
|
31
|
+
commandSandbox.addCommand(exec_1.default);
|
|
32
|
+
commandSandbox.addCommand(cp_1.default);
|
|
33
|
+
commandSandbox.addCommand(command_1.default);
|
|
34
|
+
commandSandbox.addCommand(snapshot_1.default);
|
|
35
|
+
commandSandbox.addCommand(endpoint_1.default);
|
|
36
|
+
exports.default = commandSandbox;
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const utils_1 = require("../../utils");
|
|
7
7
|
const cfg_1 = __importDefault(require("../../tunnel/cfg"));
|
|
8
8
|
const output_1 = __importDefault(require("../../output"));
|
|
9
|
+
const input_1 = __importDefault(require("../../input"));
|
|
9
10
|
const texts_1 = require("../../texts");
|
|
10
11
|
const buddy_1 = __importDefault(require("../../tunnel/api/buddy"));
|
|
11
12
|
const tunnel_1 = require("../../types/tunnel");
|
|
@@ -15,11 +16,11 @@ commandHttp.option('-s, --serve <directory>', texts_1.OPTION_SERVE);
|
|
|
15
16
|
commandHttp.option('--token <token>', texts_1.OPTION_TOKEN);
|
|
16
17
|
commandHttp.argument('[protocol://host:port]', texts_1.OPTION_TARGET);
|
|
17
18
|
commandHttp.action(async (target, options) => {
|
|
18
|
-
|
|
19
|
-
cfg_1.default.setToken(options.token);
|
|
19
|
+
const token = input_1.default.tunnelToken(options.token);
|
|
20
20
|
const prepared = await cfg_1.default.prepareTunnel(tunnel_1.TUNNEL_TYPE.HTTP, target, options, true);
|
|
21
21
|
await output_1.default.spinner(texts_1.TXT_OPENING_TUNNEL);
|
|
22
|
-
const
|
|
22
|
+
const host = cfg_1.default.getTokenHost(token);
|
|
23
|
+
const agent = await buddy_1.default.register(false, false, host, token, (region) => {
|
|
23
24
|
cfg_1.default.setRegionIfNotSet(region);
|
|
24
25
|
});
|
|
25
26
|
await agent.start();
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const utils_1 = require("../../utils");
|
|
7
7
|
const cfg_1 = __importDefault(require("../../tunnel/cfg"));
|
|
8
8
|
const output_1 = __importDefault(require("../../output"));
|
|
9
|
+
const input_1 = __importDefault(require("../../input"));
|
|
9
10
|
const texts_1 = require("../../texts");
|
|
10
11
|
const buddy_1 = __importDefault(require("../../tunnel/api/buddy"));
|
|
11
12
|
const tunnel_1 = require("../../types/tunnel");
|
|
@@ -14,11 +15,11 @@ commandTcp.description(texts_1.DESC_COMMAND_TCP);
|
|
|
14
15
|
commandTcp.option('--token <token>', texts_1.OPTION_TOKEN);
|
|
15
16
|
commandTcp.argument('[host:port]', texts_1.OPTION_TARGET);
|
|
16
17
|
commandTcp.action(async (target, options) => {
|
|
17
|
-
|
|
18
|
-
cfg_1.default.setToken(options.token);
|
|
18
|
+
const token = input_1.default.tunnelToken(options.token);
|
|
19
19
|
const prepared = await cfg_1.default.prepareTunnel(tunnel_1.TUNNEL_TYPE.TCP, target, options, true);
|
|
20
20
|
await output_1.default.spinner(texts_1.TXT_OPENING_TUNNEL);
|
|
21
|
-
const
|
|
21
|
+
const host = cfg_1.default.getTokenHost(token);
|
|
22
|
+
const agent = await buddy_1.default.register(false, false, host, token, (region) => {
|
|
22
23
|
cfg_1.default.setRegionIfNotSet(region);
|
|
23
24
|
});
|
|
24
25
|
await agent.start();
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const utils_1 = require("../../utils");
|
|
7
7
|
const cfg_1 = __importDefault(require("../../tunnel/cfg"));
|
|
8
8
|
const output_1 = __importDefault(require("../../output"));
|
|
9
|
+
const input_1 = __importDefault(require("../../input"));
|
|
9
10
|
const texts_1 = require("../../texts");
|
|
10
11
|
const buddy_1 = __importDefault(require("../../tunnel/api/buddy"));
|
|
11
12
|
const tunnel_1 = require("../../types/tunnel");
|
|
@@ -14,11 +15,11 @@ commandTls.description(texts_1.DESC_COMMAND_TLS);
|
|
|
14
15
|
commandTls.option('--token <token>', texts_1.OPTION_TOKEN);
|
|
15
16
|
commandTls.argument('[host:port]', texts_1.OPTION_TARGET);
|
|
16
17
|
commandTls.action(async (target, options) => {
|
|
17
|
-
|
|
18
|
-
cfg_1.default.setToken(options.token);
|
|
18
|
+
const token = input_1.default.tunnelToken(options.token);
|
|
19
19
|
const prepared = await cfg_1.default.prepareTunnel(tunnel_1.TUNNEL_TYPE.TLS, target, options, true);
|
|
20
20
|
await output_1.default.spinner(texts_1.TXT_OPENING_TUNNEL);
|
|
21
|
-
const
|
|
21
|
+
const host = cfg_1.default.getTokenHost(token);
|
|
22
|
+
const agent = await buddy_1.default.register(false, false, host, token, (region) => {
|
|
22
23
|
cfg_1.default.setRegionIfNotSet(region);
|
|
23
24
|
});
|
|
24
25
|
await agent.start();
|
|
@@ -0,0 +1,57 @@
|
|
|
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 client_1 = __importDefault(require("../../api/client"));
|
|
9
|
+
const texts_1 = require("../../texts");
|
|
10
|
+
const utils_1 = require("../../utils");
|
|
11
|
+
const commandWorkspaceList = (0, utils_1.newCommand)('list', texts_1.DESC_COMMAND_WORKSPACE_LIST);
|
|
12
|
+
commandWorkspaceList.alias('ls');
|
|
13
|
+
commandWorkspaceList.action(async () => {
|
|
14
|
+
const token = cfg_1.default.getToken();
|
|
15
|
+
if (!token) {
|
|
16
|
+
output_1.default.exitError(texts_1.ERR_WORKSPACE_NOT_LOGGED_IN);
|
|
17
|
+
}
|
|
18
|
+
const baseUrl = cfg_1.default.getBaseUrl();
|
|
19
|
+
const region = cfg_1.default.getRegion();
|
|
20
|
+
const currentWorkspace = cfg_1.default.getWorkspace();
|
|
21
|
+
let apiUrl;
|
|
22
|
+
if (baseUrl) {
|
|
23
|
+
apiUrl = baseUrl;
|
|
24
|
+
}
|
|
25
|
+
else if (region?.toLowerCase() === 'eu') {
|
|
26
|
+
apiUrl = 'api.eu.buddy.works';
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
apiUrl = 'api.buddy.works';
|
|
30
|
+
}
|
|
31
|
+
try {
|
|
32
|
+
const client = new client_1.default(new URL(`https://${apiUrl}`), token);
|
|
33
|
+
const response = await client.getWorkspaces();
|
|
34
|
+
if (!response.workspaces || response.workspaces.length === 0) {
|
|
35
|
+
output_1.default.normal('No workspaces found.');
|
|
36
|
+
process.exit(0);
|
|
37
|
+
}
|
|
38
|
+
const data = [['NAME', 'DOMAIN', '']];
|
|
39
|
+
for (const ws of response.workspaces) {
|
|
40
|
+
const isCurrent = ws.domain === currentWorkspace;
|
|
41
|
+
data.push([
|
|
42
|
+
ws.name,
|
|
43
|
+
ws.domain,
|
|
44
|
+
isCurrent ? '(current)' : '',
|
|
45
|
+
]);
|
|
46
|
+
}
|
|
47
|
+
output_1.default.table(data);
|
|
48
|
+
if (currentWorkspace) {
|
|
49
|
+
output_1.default.normal(`\n${(0, texts_1.TXT_WORKSPACE_CURRENT)(currentWorkspace)}`);
|
|
50
|
+
}
|
|
51
|
+
process.exit(0);
|
|
52
|
+
}
|
|
53
|
+
catch (err) {
|
|
54
|
+
output_1.default.exitError(err);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
exports.default = commandWorkspaceList;
|
|
@@ -0,0 +1,81 @@
|
|
|
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
|
+
// @ts-ignore
|
|
7
|
+
const termkit_no_lazy_require_1 = __importDefault(require("terminal-kit/lib/termkit-no-lazy-require"));
|
|
8
|
+
const cfg_1 = __importDefault(require("../../tunnel/cfg"));
|
|
9
|
+
const output_1 = __importDefault(require("../../output"));
|
|
10
|
+
const client_1 = __importDefault(require("../../api/client"));
|
|
11
|
+
const texts_1 = require("../../texts");
|
|
12
|
+
const utils_1 = require("../../utils");
|
|
13
|
+
const terminal = termkit_no_lazy_require_1.default.terminal;
|
|
14
|
+
// Handle Ctrl+C and ESC
|
|
15
|
+
terminal.on('key', (key) => {
|
|
16
|
+
if (key === 'CTRL_C' || key === 'ESCAPE') {
|
|
17
|
+
terminal.grabInput(false);
|
|
18
|
+
terminal('\nCanceled\n');
|
|
19
|
+
process.exit(0);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
async function selectWorkspace(workspaces, currentDomain) {
|
|
23
|
+
terminal(`${texts_1.TXT_LOGIN_SELECT_WORKSPACE}\n`);
|
|
24
|
+
const items = workspaces.map((w) => {
|
|
25
|
+
const isCurrent = w.domain === currentDomain;
|
|
26
|
+
return `${w.name} (${w.domain})${isCurrent ? ' (current)' : ''}`;
|
|
27
|
+
});
|
|
28
|
+
return new Promise((resolve) => {
|
|
29
|
+
terminal.singleColumnMenu(items, (error, response) => {
|
|
30
|
+
terminal('\n');
|
|
31
|
+
resolve(workspaces[response.selectedIndex]);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
const commandWorkspaceSet = (0, utils_1.newCommand)('set', texts_1.DESC_COMMAND_WORKSPACE_SET);
|
|
36
|
+
commandWorkspaceSet.argument('[workspace]', 'Workspace domain to set');
|
|
37
|
+
commandWorkspaceSet.action(async (workspaceDomain) => {
|
|
38
|
+
const token = cfg_1.default.getToken();
|
|
39
|
+
if (!token) {
|
|
40
|
+
output_1.default.exitError(texts_1.ERR_WORKSPACE_NOT_LOGGED_IN);
|
|
41
|
+
}
|
|
42
|
+
const baseUrl = cfg_1.default.getBaseUrl();
|
|
43
|
+
const region = cfg_1.default.getRegion();
|
|
44
|
+
const currentWorkspace = cfg_1.default.getWorkspace();
|
|
45
|
+
let apiUrl;
|
|
46
|
+
if (baseUrl) {
|
|
47
|
+
apiUrl = baseUrl;
|
|
48
|
+
}
|
|
49
|
+
else if (region?.toLowerCase() === 'eu') {
|
|
50
|
+
apiUrl = 'api.eu.buddy.works';
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
apiUrl = 'api.buddy.works';
|
|
54
|
+
}
|
|
55
|
+
try {
|
|
56
|
+
const client = new client_1.default(new URL(`https://${apiUrl}`), token);
|
|
57
|
+
const response = await client.getWorkspaces();
|
|
58
|
+
if (!response.workspaces || response.workspaces.length === 0) {
|
|
59
|
+
output_1.default.exitError(texts_1.ERR_LOGIN_NO_WORKSPACES);
|
|
60
|
+
}
|
|
61
|
+
let selectedWorkspace;
|
|
62
|
+
if (workspaceDomain) {
|
|
63
|
+
// Workspace provided as argument
|
|
64
|
+
const found = response.workspaces.find((w) => w.domain === workspaceDomain);
|
|
65
|
+
if (!found) {
|
|
66
|
+
output_1.default.exitError(`Workspace "${workspaceDomain}" not found`);
|
|
67
|
+
}
|
|
68
|
+
selectedWorkspace = found;
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
// Interactive selection
|
|
72
|
+
selectedWorkspace = await selectWorkspace(response.workspaces, currentWorkspace);
|
|
73
|
+
}
|
|
74
|
+
cfg_1.default.setWorkspace(selectedWorkspace.domain);
|
|
75
|
+
output_1.default.exitSuccess((0, texts_1.TXT_WORKSPACE_SET_SUCCESS)(selectedWorkspace.domain));
|
|
76
|
+
}
|
|
77
|
+
catch (err) {
|
|
78
|
+
output_1.default.exitError(err);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
exports.default = commandWorkspaceSet;
|
|
@@ -0,0 +1,14 @@
|
|
|
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 texts_1 = require("../texts");
|
|
7
|
+
const utils_1 = require("../utils");
|
|
8
|
+
const list_1 = __importDefault(require("./workspace/list"));
|
|
9
|
+
const set_1 = __importDefault(require("./workspace/set"));
|
|
10
|
+
const commandWorkspace = (0, utils_1.newCommand)('workspace', texts_1.DESC_COMMAND_WORKSPACE);
|
|
11
|
+
commandWorkspace.alias('ws');
|
|
12
|
+
commandWorkspace.addCommand(list_1.default);
|
|
13
|
+
commandWorkspace.addCommand(set_1.default);
|
|
14
|
+
exports.default = commandWorkspace;
|
package/distTs/src/index.js
CHANGED
|
@@ -15,6 +15,11 @@ const vt_1 = __importDefault(require("./command/vt"));
|
|
|
15
15
|
const ut_1 = __importDefault(require("./command/ut"));
|
|
16
16
|
const tunnel_1 = __importDefault(require("./command/tunnel"));
|
|
17
17
|
const pipeline_1 = __importDefault(require("./command/pipeline"));
|
|
18
|
+
const sandbox_1 = __importDefault(require("./command/sandbox"));
|
|
19
|
+
const login_1 = __importDefault(require("./command/login"));
|
|
20
|
+
const logout_1 = __importDefault(require("./command/logout"));
|
|
21
|
+
const workspace_1 = __importDefault(require("./command/workspace"));
|
|
22
|
+
const project_1 = __importDefault(require("./command/project"));
|
|
18
23
|
stream_1.default.setDefaultHighWaterMark(false, 67108864);
|
|
19
24
|
process.title = 'bdy';
|
|
20
25
|
process.on('uncaughtException', (err) => {
|
|
@@ -33,4 +38,9 @@ program.addCommand(version_1.default);
|
|
|
33
38
|
program.addCommand(vt_1.default);
|
|
34
39
|
program.addCommand(ut_1.default);
|
|
35
40
|
program.addCommand(pipeline_1.default);
|
|
41
|
+
program.addCommand(sandbox_1.default);
|
|
42
|
+
program.addCommand(login_1.default);
|
|
43
|
+
program.addCommand(logout_1.default);
|
|
44
|
+
program.addCommand(workspace_1.default);
|
|
45
|
+
program.addCommand(project_1.default);
|
|
36
46
|
program.parse();
|
package/distTs/src/input.js
CHANGED
|
@@ -45,6 +45,7 @@ const crypto_1 = __importDefault(require("crypto"));
|
|
|
45
45
|
const utils_1 = require("./utils");
|
|
46
46
|
const texts_1 = require("./texts");
|
|
47
47
|
const tunnel_1 = require("./types/tunnel");
|
|
48
|
+
const cfg_1 = __importDefault(require("./tunnel/cfg"));
|
|
48
49
|
class Input {
|
|
49
50
|
static timeout(timeout) {
|
|
50
51
|
const t = parseInt(timeout, 10);
|
|
@@ -229,11 +230,22 @@ class Input {
|
|
|
229
230
|
let t = process.env.BUDDY_TOKEN;
|
|
230
231
|
if (token)
|
|
231
232
|
t = token;
|
|
233
|
+
if (!t)
|
|
234
|
+
t = cfg_1.default.getToken();
|
|
232
235
|
if (!t) {
|
|
233
236
|
output_1.default.exitError(texts_1.ERR_REST_API_TOKEN);
|
|
234
237
|
}
|
|
235
238
|
return t;
|
|
236
239
|
}
|
|
240
|
+
static tunnelToken(token) {
|
|
241
|
+
let t = token;
|
|
242
|
+
if (!t)
|
|
243
|
+
t = cfg_1.default.getTunnelToken();
|
|
244
|
+
if (!t) {
|
|
245
|
+
output_1.default.exitError(texts_1.ERR_TUNNEL_TOKEN);
|
|
246
|
+
}
|
|
247
|
+
return t;
|
|
248
|
+
}
|
|
237
249
|
static pipelineRunPriority(priority) {
|
|
238
250
|
if (!priority)
|
|
239
251
|
return null;
|
|
@@ -310,15 +322,19 @@ class Input {
|
|
|
310
322
|
let u = process.env.BUDDY_API_ENDPOINT;
|
|
311
323
|
if (api)
|
|
312
324
|
u = api;
|
|
325
|
+
if (!u)
|
|
326
|
+
u = cfg_1.default.getBaseUrl();
|
|
313
327
|
if (!u) {
|
|
314
328
|
let r = process.env.BUDDY_REGION;
|
|
315
329
|
if (region)
|
|
316
330
|
r = region;
|
|
317
|
-
if (r
|
|
331
|
+
if (!r)
|
|
332
|
+
r = cfg_1.default.getRegion();
|
|
333
|
+
if (r?.toLowerCase() === 'eu')
|
|
318
334
|
u = 'api.eu.buddy.works';
|
|
319
|
-
else if (r === 'as')
|
|
320
|
-
u = 'api.
|
|
321
|
-
else if (r === 'us')
|
|
335
|
+
else if (r?.toLowerCase() === 'as')
|
|
336
|
+
u = 'api.asia.buddy.works';
|
|
337
|
+
else if (r?.toLowerCase() === 'us')
|
|
322
338
|
u = 'api.buddy.works';
|
|
323
339
|
}
|
|
324
340
|
if (!u)
|
|
@@ -345,6 +361,8 @@ class Input {
|
|
|
345
361
|
let w = process.env.BUDDY_WORKSPACE;
|
|
346
362
|
if (workspace)
|
|
347
363
|
w = workspace;
|
|
364
|
+
if (!w)
|
|
365
|
+
w = cfg_1.default.getWorkspace();
|
|
348
366
|
if (!w) {
|
|
349
367
|
output_1.default.exitError(texts_1.ERR_REST_API_WORKSPACE);
|
|
350
368
|
}
|
|
@@ -354,6 +372,8 @@ class Input {
|
|
|
354
372
|
let p = process.env.BUDDY_PROJECT;
|
|
355
373
|
if (project)
|
|
356
374
|
p = project;
|
|
375
|
+
if (!p)
|
|
376
|
+
p = cfg_1.default.getProject();
|
|
357
377
|
if (!p) {
|
|
358
378
|
output_1.default.exitError(texts_1.ERR_REST_API_PROJECT);
|
|
359
379
|
}
|