bdy 1.25.3-dev → 1.25.4-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/agent/socket/tunnel.js +2 -0
- package/distTs/src/command/agent/proxy/status.js +9 -2
- package/distTs/src/command/agent/status.js +22 -6
- package/distTs/src/command/agent/tags/get.js +9 -2
- package/distTs/src/command/agent/target/status.js +9 -2
- package/distTs/src/command/agent/tunnel/list.js +6 -1
- package/distTs/src/command/agent/tunnel/status.js +13 -1
- package/distTs/src/command/agent/version.js +7 -2
- package/distTs/src/command/api/info.js +50 -2
- package/distTs/src/command/api/list.js +18 -2
- package/distTs/src/command/artifact/create.js +5 -0
- package/distTs/src/command/artifact/publish.js +20 -22
- package/distTs/src/command/artifact/version/create.js +5 -0
- package/distTs/src/command/config/get/tunnel.js +8 -3
- package/distTs/src/command/config/get/tunnels.js +8 -3
- package/distTs/src/command/distro/create.js +5 -0
- package/distTs/src/command/distro/route/create.js +5 -0
- package/distTs/src/command/distro/route/update.js +5 -0
- package/distTs/src/command/distro/update.js +5 -0
- package/distTs/src/command/domain/search.js +31 -10
- package/distTs/src/command/environment/create.js +5 -0
- package/distTs/src/command/environment/update.js +5 -0
- package/distTs/src/command/sandbox/app/add.js +7 -1
- package/distTs/src/command/sandbox/app/logs.js +9 -4
- package/distTs/src/command/sandbox/create.js +13 -5
- package/distTs/src/command/sandbox/endpoint/add.js +5 -0
- package/distTs/src/command/sandbox/exec/command.js +15 -30
- package/distTs/src/command/sandbox/exec/logs.js +4 -29
- package/distTs/src/command/sandbox/finishExec.js +33 -0
- package/distTs/src/command/sandbox/logs.js +14 -1
- package/distTs/src/command/sandbox/snapshot/create.js +9 -1
- package/distTs/src/command/target/create.js +5 -0
- package/distTs/src/command/target/exec/logs.js +15 -2
- package/distTs/src/command/target/update.js +5 -0
- package/distTs/src/command/yaml/validate.js +111 -52
- package/distTs/src/openapi.js +8 -1
- package/distTs/src/output.js +39 -0
- package/distTs/src/texts.js +206 -1
- package/package.json +1 -1
|
@@ -20,12 +20,16 @@ const sort = (arr, sort) => {
|
|
|
20
20
|
return 0;
|
|
21
21
|
});
|
|
22
22
|
};
|
|
23
|
-
const commandDomainSearch = (0, utils_1.newCommand)('search', texts_1.DESC_COMMAND_DOMAIN_SEARCH
|
|
23
|
+
const commandDomainSearch = (0, utils_1.newCommand)('search', texts_1.DESC_COMMAND_DOMAIN_SEARCH, {
|
|
24
|
+
helpText: texts_1.HELP_DOMAIN_SEARCH_JSON,
|
|
25
|
+
examples: texts_1.EXAMPLE_DOMAIN_SEARCH,
|
|
26
|
+
});
|
|
24
27
|
commandDomainSearch.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
25
28
|
commandDomainSearch.option('-d, --tld <tld...>', texts_1.OPT_COMMAND_DOMAIN_BUY_TLD);
|
|
26
29
|
commandDomainSearch.option('-s, --sort <name|price>', texts_1.OPT_COMMAND_DOMAIN_SORT);
|
|
27
30
|
commandDomainSearch.option('-a, --only-available', texts_1.OPT_COMMAND_DOMAIN_ONLY_AVAILABLE);
|
|
28
31
|
commandDomainSearch.argument('[domain|prompt]', texts_1.OPT_COMMAND_DOMAIN_PHRASE);
|
|
32
|
+
commandDomainSearch.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
29
33
|
commandDomainSearch.action(async (text, options) => {
|
|
30
34
|
const onlyAvailable = options.onlyAvailable;
|
|
31
35
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
@@ -38,12 +42,17 @@ commandDomainSearch.action(async (text, options) => {
|
|
|
38
42
|
if (!prompt) {
|
|
39
43
|
output_1.default.exitError(texts_1.TXT_COMMAND_DOMAIN_PROMPT_REQUIRED);
|
|
40
44
|
}
|
|
41
|
-
|
|
42
|
-
|
|
45
|
+
let searchResponse = null;
|
|
46
|
+
let claimsResponse = null;
|
|
47
|
+
if (options.format !== 'json') {
|
|
48
|
+
output_1.default.arrowSign();
|
|
49
|
+
output_1.default.normal(`Searching...`);
|
|
50
|
+
}
|
|
43
51
|
const matched = [];
|
|
44
52
|
if ((0, utils_1.isValidDomain)(prompt)) {
|
|
45
53
|
const subdomain = (0, utils_1.getSubdomain)(prompt);
|
|
46
54
|
const claims = await client.domainClaimable(workspace, subdomain);
|
|
55
|
+
claimsResponse = claims;
|
|
47
56
|
const claimable = claims.domains.find((c) => `${subdomain}.${c.domain}` === prompt);
|
|
48
57
|
if (claimable && (!onlyAvailable || claimable.available)) {
|
|
49
58
|
matched.push({
|
|
@@ -54,6 +63,7 @@ commandDomainSearch.action(async (text, options) => {
|
|
|
54
63
|
}
|
|
55
64
|
else {
|
|
56
65
|
const search = await client.domainSearch(workspace, [prompt]);
|
|
66
|
+
searchResponse = search;
|
|
57
67
|
const buyable = search.domains.find((d) => d.name === prompt);
|
|
58
68
|
if (buyable &&
|
|
59
69
|
(!onlyAvailable || buyable.available)) {
|
|
@@ -67,6 +77,7 @@ commandDomainSearch.action(async (text, options) => {
|
|
|
67
77
|
}
|
|
68
78
|
else if ((0, utils_1.isValidSubdomain)(prompt)) {
|
|
69
79
|
const claims = await client.domainClaimable(workspace, prompt);
|
|
80
|
+
claimsResponse = claims;
|
|
70
81
|
const domains = [];
|
|
71
82
|
const popularTlds = (0, utils_1.getPopularTlds)();
|
|
72
83
|
const searchTlds = tlds.length > 0 ? tlds : popularTlds;
|
|
@@ -74,13 +85,15 @@ commandDomainSearch.action(async (text, options) => {
|
|
|
74
85
|
domains.push(`${prompt}.${tld}`);
|
|
75
86
|
});
|
|
76
87
|
const search = await client.domainSearch(workspace, domains);
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
88
|
+
searchResponse = search;
|
|
89
|
+
if (options.format !== 'json')
|
|
90
|
+
search.domains = search.domains.sort((a, b) => {
|
|
91
|
+
const aTld = (0, utils_1.getDomainTld)(a.name);
|
|
92
|
+
const bTld = (0, utils_1.getDomainTld)(b.name);
|
|
93
|
+
const aIdx = popularTlds.indexOf(aTld);
|
|
94
|
+
const bIdx = popularTlds.indexOf(bTld);
|
|
95
|
+
return aIdx < bIdx ? -1 : 1;
|
|
96
|
+
});
|
|
84
97
|
claims.domains.forEach((c) => {
|
|
85
98
|
if (!onlyAvailable || c.available) {
|
|
86
99
|
const name = `${prompt}.${c.domain}`;
|
|
@@ -103,6 +116,14 @@ commandDomainSearch.action(async (text, options) => {
|
|
|
103
116
|
});
|
|
104
117
|
}
|
|
105
118
|
const result = await client.domainSuggest(workspace, prompt, tlds, 5);
|
|
119
|
+
if (options.format === 'json') {
|
|
120
|
+
output_1.default.json({
|
|
121
|
+
search: searchResponse,
|
|
122
|
+
claims: claimsResponse,
|
|
123
|
+
suggestions: result,
|
|
124
|
+
});
|
|
125
|
+
output_1.default.exitNormal();
|
|
126
|
+
}
|
|
106
127
|
output_1.default.clearPreviousLine();
|
|
107
128
|
let hasAny = false;
|
|
108
129
|
if (matched.length > 0) {
|
|
@@ -20,6 +20,7 @@ commandEnvironmentCreate.option('--icon <icon>', texts_1.OPTION_ENVIRONMENT_ICON
|
|
|
20
20
|
commandEnvironmentCreate.option('--note <note>', texts_1.OPT_COMMAND_NOTE);
|
|
21
21
|
commandEnvironmentCreate.option('--agent-note <note>', texts_1.OPT_COMMAND_AGENT_NOTE);
|
|
22
22
|
commandEnvironmentCreate.argument('[name]', texts_1.OPTION_ENVIRONMENT_NAME);
|
|
23
|
+
commandEnvironmentCreate.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
23
24
|
commandEnvironmentCreate.action(async (name, options) => {
|
|
24
25
|
const humanId = require('human-id').default;
|
|
25
26
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
@@ -64,6 +65,10 @@ commandEnvironmentCreate.action(async (name, options) => {
|
|
|
64
65
|
}
|
|
65
66
|
const client = input_1.default.restApiTokenClient();
|
|
66
67
|
const result = await client.createEnvironment(workspace, data);
|
|
68
|
+
if (options.format === 'json') {
|
|
69
|
+
output_1.default.json(result);
|
|
70
|
+
output_1.default.exitNormal();
|
|
71
|
+
}
|
|
67
72
|
output_1.default.exitSuccess((0, texts_1.TXT_ENVIRONMENT_CREATED)(result.identifier, result.html_url));
|
|
68
73
|
});
|
|
69
74
|
exports.default = commandEnvironmentCreate;
|
|
@@ -18,6 +18,7 @@ commandEnvironmentUpdate.option('--icon <icon>', texts_1.OPTION_ENVIRONMENT_ICON
|
|
|
18
18
|
commandEnvironmentUpdate.option('--note <note>', texts_1.OPT_COMMAND_NOTE);
|
|
19
19
|
commandEnvironmentUpdate.option('--agent-note <note>', texts_1.OPT_COMMAND_AGENT_NOTE);
|
|
20
20
|
commandEnvironmentUpdate.argument('<identifier>', texts_1.OPTION_ENVIRONMENT_IDENTIFIER);
|
|
21
|
+
commandEnvironmentUpdate.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
21
22
|
commandEnvironmentUpdate.action(async (identifier, options) => {
|
|
22
23
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
23
24
|
const body = {};
|
|
@@ -53,6 +54,10 @@ commandEnvironmentUpdate.action(async (identifier, options) => {
|
|
|
53
54
|
const environment_id = await input_1.default.environmentId(client, workspace, identifier, options,
|
|
54
55
|
/* strictProject */ true);
|
|
55
56
|
const result = await client.updateEnvironment(workspace, environment_id, body);
|
|
57
|
+
if (options.format === 'json') {
|
|
58
|
+
output_1.default.json(result);
|
|
59
|
+
output_1.default.exitNormal();
|
|
60
|
+
}
|
|
56
61
|
output_1.default.exitSuccess((0, texts_1.TXT_ENVIRONMENT_UPDATED)(result.identifier, result.html_url));
|
|
57
62
|
});
|
|
58
63
|
exports.default = commandEnvironmentUpdate;
|
|
@@ -9,10 +9,12 @@ const input_1 = __importDefault(require("../../../input"));
|
|
|
9
9
|
const output_1 = __importDefault(require("../../../output"));
|
|
10
10
|
const commandSandboxAppAdd = (0, utils_1.newCommand)('add', texts_1.DESC_COMMAND_SANDBOX_APP_ADD, {
|
|
11
11
|
examples: texts_1.EXAMPLE_SANDBOX_APP_ADD,
|
|
12
|
+
helpText: texts_1.HELP_SANDBOX_APP_ADD_JSON,
|
|
12
13
|
});
|
|
13
14
|
(0, utils_1.sandboxScopeOptions)(commandSandboxAppAdd);
|
|
14
15
|
commandSandboxAppAdd.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
|
|
15
16
|
commandSandboxAppAdd.argument('<app-command>', texts_1.OPTION_SANDBOX_APP_COMMAND);
|
|
17
|
+
commandSandboxAppAdd.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
16
18
|
commandSandboxAppAdd.action(async (identifier, app, options) => {
|
|
17
19
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
18
20
|
const client = input_1.default.restApiTokenClient();
|
|
@@ -20,9 +22,13 @@ commandSandboxAppAdd.action(async (identifier, app, options) => {
|
|
|
20
22
|
const sandbox = await client.getSandbox(workspace, sandboxId);
|
|
21
23
|
const apps = sandbox.apps || [];
|
|
22
24
|
apps.push(app);
|
|
23
|
-
await client.updateSandbox(workspace, sandboxId, {
|
|
25
|
+
const updated = await client.updateSandbox(workspace, sandboxId, {
|
|
24
26
|
apps,
|
|
25
27
|
});
|
|
28
|
+
if (options.format === 'json') {
|
|
29
|
+
output_1.default.json(updated);
|
|
30
|
+
output_1.default.exitNormal();
|
|
31
|
+
}
|
|
26
32
|
output_1.default.exitSuccess(texts_1.TXT_SANDBOX_APP_ADDED);
|
|
27
33
|
});
|
|
28
34
|
exports.default = commandSandboxAppAdd;
|
|
@@ -20,18 +20,23 @@ const fetchLogsWithLimit = async (client, workspace, sandboxId, appId, limit) =>
|
|
|
20
20
|
const { cursor, logs } = await client.getSandboxAppLogs(workspace, sandboxId, appId, c);
|
|
21
21
|
l = l.concat(logs);
|
|
22
22
|
if (l.length > limit)
|
|
23
|
-
return l.slice(0, limit)
|
|
23
|
+
return l.slice(0, limit);
|
|
24
24
|
if (!cursor || !logs.length)
|
|
25
|
-
return l
|
|
25
|
+
return l;
|
|
26
26
|
c = cursor;
|
|
27
27
|
} while (c != null);
|
|
28
|
-
return l
|
|
28
|
+
return l;
|
|
29
29
|
};
|
|
30
|
+
commandSandboxAppLogs.option('--format <text|jsonl>', texts_1.OPTION_FORMAT_JSONL);
|
|
30
31
|
commandSandboxAppLogs.action(async (identifier, appId, options) => {
|
|
31
32
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
32
33
|
const client = input_1.default.restApiTokenClient();
|
|
33
34
|
const sandboxId = await input_1.default.sandboxId(client, workspace, options, identifier);
|
|
34
35
|
const logs = await fetchLogsWithLimit(client, workspace, sandboxId, appId, options.limit || 100);
|
|
35
|
-
|
|
36
|
+
if (options.format === 'jsonl') {
|
|
37
|
+
logs.forEach((data) => output_1.default.json({ type: 'log', data }));
|
|
38
|
+
output_1.default.exitNormal();
|
|
39
|
+
}
|
|
40
|
+
output_1.default.exitNormal(logs.join('\n'));
|
|
36
41
|
});
|
|
37
42
|
exports.default = commandSandboxAppLogs;
|
|
@@ -51,8 +51,10 @@ commandSandboxCreate.option('--yaml <content|@path>', texts_1.OPTION_SANDBOX_YAM
|
|
|
51
51
|
commandSandboxCreate.option('--wait-for-running [seconds]', texts_1.OPTION_SANDBOX_WAIT_RUNNING);
|
|
52
52
|
commandSandboxCreate.option('--wait-for-configured [seconds]', texts_1.OPTION_SANDBOX_WAIT_CONFIGURED);
|
|
53
53
|
commandSandboxCreate.option('--wait-for-apps [seconds]', texts_1.OPTION_SANDBOX_WAIT_APPS);
|
|
54
|
+
commandSandboxCreate.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
54
55
|
commandSandboxCreate.action(async (options) => {
|
|
55
56
|
const humanId = require('human-id').default;
|
|
57
|
+
const say = output_1.default.progress(options.format === 'json');
|
|
56
58
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
57
59
|
const project = input_1.default.restApiProject(options.project, true);
|
|
58
60
|
const scope = input_1.default.scope(project, options.scope, options.environment, true);
|
|
@@ -78,7 +80,7 @@ commandSandboxCreate.action(async (options) => {
|
|
|
78
80
|
const body = {
|
|
79
81
|
yaml: Buffer.from(yaml, 'utf8').toString('base64'),
|
|
80
82
|
};
|
|
81
|
-
|
|
83
|
+
say((0, texts_1.TXT_SANDBOX_CREATING)());
|
|
82
84
|
result = await client.createSandboxByYaml(workspace, scope === distro_1.SCOPE.PROJECT ? project : null, body, environmentId);
|
|
83
85
|
}
|
|
84
86
|
else {
|
|
@@ -143,12 +145,12 @@ commandSandboxCreate.action(async (options) => {
|
|
|
143
145
|
if (options.appDir) {
|
|
144
146
|
body.app_dir = options.appDir;
|
|
145
147
|
}
|
|
146
|
-
|
|
148
|
+
say((0, texts_1.TXT_SANDBOX_CREATING)(body.name, body.identifier));
|
|
147
149
|
result = await client.createSandbox(workspace, scope === distro_1.SCOPE.PROJECT ? project : null, body);
|
|
148
150
|
}
|
|
149
151
|
const sandboxId = result.id;
|
|
150
152
|
if (options.waitForRunning) {
|
|
151
|
-
|
|
153
|
+
say(texts_1.TXT_SANDBOX_WAITING_RUNNING);
|
|
152
154
|
const timeout = parseInt(options.waitForRunning, 10) || 300;
|
|
153
155
|
try {
|
|
154
156
|
const status = await client.sandboxWaitForRunning(workspace, sandboxId, timeout);
|
|
@@ -161,7 +163,7 @@ commandSandboxCreate.action(async (options) => {
|
|
|
161
163
|
}
|
|
162
164
|
}
|
|
163
165
|
if (options.waitForConfigured) {
|
|
164
|
-
|
|
166
|
+
say(texts_1.TXT_SANDBOX_WAITING_SETUP);
|
|
165
167
|
const timeout = parseInt(options.waitForConfigured, 10) || 300;
|
|
166
168
|
try {
|
|
167
169
|
const status = await client.sandboxWaitForConfigured(workspace, sandboxId, timeout);
|
|
@@ -174,7 +176,7 @@ commandSandboxCreate.action(async (options) => {
|
|
|
174
176
|
}
|
|
175
177
|
}
|
|
176
178
|
if (options.waitForApps) {
|
|
177
|
-
|
|
179
|
+
say(texts_1.TXT_SANDBOX_WAITING_APPS);
|
|
178
180
|
const timeout = parseInt(options.waitForApps, 10) || 300;
|
|
179
181
|
try {
|
|
180
182
|
const status = await client.sandboxWaitForApps(workspace, sandboxId, timeout);
|
|
@@ -195,6 +197,12 @@ commandSandboxCreate.action(async (options) => {
|
|
|
195
197
|
output_1.default.exitError(texts_1.ERR_SANDBOX_RUNNING_TIMEOUT);
|
|
196
198
|
}
|
|
197
199
|
}
|
|
200
|
+
if (options.format === 'json') {
|
|
201
|
+
if (options.waitForRunning || options.waitForConfigured || options.waitForApps)
|
|
202
|
+
result = await client.getSandbox(workspace, sandboxId);
|
|
203
|
+
output_1.default.json(result);
|
|
204
|
+
output_1.default.exitNormal();
|
|
205
|
+
}
|
|
198
206
|
output_1.default.dim('Identifier: ', false);
|
|
199
207
|
output_1.default.cyan(result.identifier);
|
|
200
208
|
output_1.default.dim('SSH: ', false);
|
|
@@ -10,6 +10,7 @@ const input_1 = __importDefault(require("../../../input"));
|
|
|
10
10
|
const tunnel_1 = require("../../../types/tunnel");
|
|
11
11
|
const commandSandboxEndpointAdd = (0, utils_1.getBasicCommandSandboxEndpoint)('add', texts_1.DESC_COMMAND_SANDBOX_ENDPOINT_ADD, { examples: texts_1.EXAMPLE_SANDBOX_ENDPOINT_CREATE });
|
|
12
12
|
commandSandboxEndpointAdd.alias('create');
|
|
13
|
+
commandSandboxEndpointAdd.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
13
14
|
commandSandboxEndpointAdd.action(async (identifier, options) => {
|
|
14
15
|
const humanId = require('human-id').default;
|
|
15
16
|
let name = options.name;
|
|
@@ -32,6 +33,10 @@ commandSandboxEndpointAdd.action(async (identifier, options) => {
|
|
|
32
33
|
endpoints: updatedEndpoints,
|
|
33
34
|
});
|
|
34
35
|
const addedEndpoint = (updatedSandbox.endpoints || []).find((ep) => ep.name === name);
|
|
36
|
+
if (options.format === 'json') {
|
|
37
|
+
output_1.default.json(addedEndpoint);
|
|
38
|
+
output_1.default.exitNormal();
|
|
39
|
+
}
|
|
35
40
|
output_1.default.object({
|
|
36
41
|
Name: name,
|
|
37
42
|
Url: addedEndpoint.endpoint_url || '-',
|
|
@@ -7,13 +7,18 @@ const texts_1 = require("../../../texts");
|
|
|
7
7
|
const utils_1 = require("../../../utils");
|
|
8
8
|
const output_1 = __importDefault(require("../../../output"));
|
|
9
9
|
const input_1 = __importDefault(require("../../../input"));
|
|
10
|
-
const
|
|
10
|
+
const finishExec_1 = require("../finishExec");
|
|
11
|
+
const commandSandboxExecCommand = (0, utils_1.newCommand)('command', texts_1.DESC_COMMAND_SANDBOX_EXEC_COMMAND, {
|
|
12
|
+
helpText: texts_1.HELP_SANDBOX_EXEC_COMMAND_JSONL,
|
|
13
|
+
examples: texts_1.EXAMPLE_SANDBOX_EXEC_COMMAND,
|
|
14
|
+
});
|
|
11
15
|
commandSandboxExecCommand.alias('cmd');
|
|
12
16
|
(0, utils_1.sandboxScopeOptions)(commandSandboxExecCommand);
|
|
13
17
|
commandSandboxExecCommand.option('--runtime <runtime>', texts_1.OPTION_SANDBOX_RUNTIME);
|
|
14
18
|
commandSandboxExecCommand.option('--wait', texts_1.OPTION_SANDBOX_WAIT);
|
|
15
19
|
commandSandboxExecCommand.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
|
|
16
20
|
commandSandboxExecCommand.argument('<command>');
|
|
21
|
+
commandSandboxExecCommand.option('--format <text|jsonl>', texts_1.OPTION_FORMAT_JSONL);
|
|
17
22
|
commandSandboxExecCommand.action(async (identifier, command, options) => {
|
|
18
23
|
output_1.default.handleSignals();
|
|
19
24
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
@@ -24,39 +29,19 @@ commandSandboxExecCommand.action(async (identifier, command, options) => {
|
|
|
24
29
|
command,
|
|
25
30
|
runtime,
|
|
26
31
|
});
|
|
27
|
-
|
|
32
|
+
if (options.format === 'jsonl') {
|
|
33
|
+
output_1.default.json({ type: 'command', command: cmdResult });
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
output_1.default.gray((0, texts_1.TXT_SANDBOX_EXEC_ID)(cmdResult.id));
|
|
37
|
+
}
|
|
28
38
|
if (!options.wait) {
|
|
39
|
+
if (options.format === 'jsonl')
|
|
40
|
+
output_1.default.exitNormal();
|
|
29
41
|
output_1.default.exitSuccess((0, texts_1.TXT_SANDBOX_EXEC_BACKGROUND)(identifier, cmdResult.id));
|
|
30
42
|
}
|
|
31
43
|
else {
|
|
32
|
-
|
|
33
|
-
body.on('data', (data) => {
|
|
34
|
-
if (data) {
|
|
35
|
-
try {
|
|
36
|
-
const str = data.toString('utf8').split('\n');
|
|
37
|
-
str.forEach((s) => {
|
|
38
|
-
const json = JSON.parse(s);
|
|
39
|
-
if (json.data)
|
|
40
|
-
output_1.default.data(json.data);
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
catch {
|
|
44
|
-
// do nothing
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
body.on('close', async () => {
|
|
49
|
-
const cmdExit = await client.getSandboxCommand(workspace, sandboxId, cmdResult.id);
|
|
50
|
-
if (cmdExit.status === utils_1.SANDBOX_EXEC_STATUS.SUCCESSFUL) {
|
|
51
|
-
output_1.default.exitSuccess((0, texts_1.TXT_SANDBOX_EXEC_SUCCESS)(identifier, cmdResult.id));
|
|
52
|
-
}
|
|
53
|
-
else if (cmdExit.status === utils_1.SANDBOX_EXEC_STATUS.INPROGRESS) {
|
|
54
|
-
output_1.default.exitNormal((0, texts_1.TXT_SANDBOX_EXEC_INPROGRESS)(identifier, cmdResult.id));
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
output_1.default.exitError((0, texts_1.TXT_SANDBOX_EXEC_FAILED)(identifier, cmdResult.id));
|
|
58
|
-
}
|
|
59
|
-
});
|
|
44
|
+
await (0, finishExec_1.finishExec)(client, workspace, sandboxId, identifier, cmdResult.id, true, options.format === 'jsonl');
|
|
60
45
|
}
|
|
61
46
|
});
|
|
62
47
|
exports.default = commandSandboxExecCommand;
|
|
@@ -7,43 +7,18 @@ const utils_1 = require("../../../utils");
|
|
|
7
7
|
const texts_1 = require("../../../texts");
|
|
8
8
|
const output_1 = __importDefault(require("../../../output"));
|
|
9
9
|
const input_1 = __importDefault(require("../../../input"));
|
|
10
|
-
const
|
|
10
|
+
const finishExec_1 = require("../finishExec");
|
|
11
|
+
const commandSandboxExecLogs = (0, utils_1.newCommand)('logs', texts_1.DESC_COMMAND_SANDBOX_EXEC_LOGS, { helpText: texts_1.HELP_SANDBOX_EXEC_JSONL, examples: texts_1.EXAMPLE_SANDBOX_EXEC_LOGS });
|
|
11
12
|
(0, utils_1.sandboxScopeOptions)(commandSandboxExecLogs);
|
|
12
13
|
commandSandboxExecLogs.option('--wait', texts_1.OPTION_SANDBOX_WAIT);
|
|
13
14
|
commandSandboxExecLogs.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
|
|
14
15
|
commandSandboxExecLogs.argument('<command-id>', texts_1.OPTION_SANDBOX_COMMAND_ID);
|
|
16
|
+
commandSandboxExecLogs.option('--format <text|jsonl>', texts_1.OPTION_FORMAT_JSONL);
|
|
15
17
|
commandSandboxExecLogs.action(async (identifier, commandId, options) => {
|
|
16
18
|
output_1.default.handleSignals();
|
|
17
19
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
18
20
|
const client = input_1.default.restApiTokenClient();
|
|
19
21
|
const sandboxId = await input_1.default.sandboxId(client, workspace, options, identifier);
|
|
20
|
-
|
|
21
|
-
body.on('data', (data) => {
|
|
22
|
-
if (data) {
|
|
23
|
-
try {
|
|
24
|
-
const str = data.toString('utf8').split('\n');
|
|
25
|
-
str.forEach((s) => {
|
|
26
|
-
const json = JSON.parse(s);
|
|
27
|
-
if (json.data)
|
|
28
|
-
output_1.default.data(json.data);
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
catch {
|
|
32
|
-
// do nothing
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
body.on('close', async () => {
|
|
37
|
-
const cmdExit = await client.getSandboxCommand(workspace, sandboxId, commandId);
|
|
38
|
-
if (cmdExit.status === utils_1.SANDBOX_EXEC_STATUS.SUCCESSFUL) {
|
|
39
|
-
output_1.default.exitSuccess((0, texts_1.TXT_SANDBOX_EXEC_SUCCESS)(identifier, commandId));
|
|
40
|
-
}
|
|
41
|
-
else if (cmdExit.status === utils_1.SANDBOX_EXEC_STATUS.INPROGRESS) {
|
|
42
|
-
output_1.default.exitNormal((0, texts_1.TXT_SANDBOX_EXEC_INPROGRESS)(identifier, commandId));
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
output_1.default.exitError((0, texts_1.TXT_SANDBOX_EXEC_FAILED)(identifier, commandId));
|
|
46
|
-
}
|
|
47
|
-
});
|
|
22
|
+
await (0, finishExec_1.finishExec)(client, workspace, sandboxId, identifier, commandId, !!options.wait, options.format === 'jsonl');
|
|
48
23
|
});
|
|
49
24
|
exports.default = commandSandboxExecLogs;
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
exports.finishExec = finishExec;
|
|
7
|
+
const output_1 = __importDefault(require("../../output"));
|
|
8
|
+
const utils_1 = require("../../utils");
|
|
9
|
+
const texts_1 = require("../../texts");
|
|
10
|
+
async function finishExec(client, workspace, sandboxId, identifier, commandId, follow, jsonl) {
|
|
11
|
+
const body = await client.streamSandboxCommandLogs(workspace, sandboxId, commandId, follow);
|
|
12
|
+
await output_1.default.streamCommandLogs(body, jsonl);
|
|
13
|
+
const cmdExit = await client.getSandboxCommand(workspace, sandboxId, commandId);
|
|
14
|
+
if (jsonl) {
|
|
15
|
+
output_1.default.json({
|
|
16
|
+
type: 'exit',
|
|
17
|
+
status: cmdExit.status,
|
|
18
|
+
exit_code: cmdExit.exit_code ?? null,
|
|
19
|
+
});
|
|
20
|
+
if ([utils_1.SANDBOX_EXEC_STATUS.SUCCESSFUL, utils_1.SANDBOX_EXEC_STATUS.INPROGRESS].includes(cmdExit.status)) {
|
|
21
|
+
output_1.default.exitNormal();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (cmdExit.status === utils_1.SANDBOX_EXEC_STATUS.SUCCESSFUL) {
|
|
25
|
+
output_1.default.exitSuccess((0, texts_1.TXT_SANDBOX_EXEC_SUCCESS)(identifier, commandId));
|
|
26
|
+
}
|
|
27
|
+
else if (cmdExit.status === utils_1.SANDBOX_EXEC_STATUS.INPROGRESS) {
|
|
28
|
+
output_1.default.exitNormal((0, texts_1.TXT_SANDBOX_EXEC_INPROGRESS)(identifier, commandId));
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
output_1.default.exitError((0, texts_1.TXT_SANDBOX_EXEC_FAILED)(identifier, commandId));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -7,15 +7,28 @@ const utils_1 = require("../../utils");
|
|
|
7
7
|
const texts_1 = require("../../texts");
|
|
8
8
|
const input_1 = __importDefault(require("../../input"));
|
|
9
9
|
const output_1 = __importDefault(require("../../output"));
|
|
10
|
-
const commandSandboxLogs = (0, utils_1.newCommand)('logs', texts_1.DESC_COMMAND_SANDBOX_LOGS);
|
|
10
|
+
const commandSandboxLogs = (0, utils_1.newCommand)('logs', texts_1.DESC_COMMAND_SANDBOX_LOGS, { examples: texts_1.EXAMPLE_SANDBOX_LOGS });
|
|
11
11
|
commandSandboxLogs.hideVersionUpdate = true;
|
|
12
12
|
(0, utils_1.sandboxScopeOptions)(commandSandboxLogs);
|
|
13
13
|
commandSandboxLogs.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
|
|
14
|
+
commandSandboxLogs.option('--format <text|jsonl>', texts_1.OPTION_FORMAT_JSONL);
|
|
14
15
|
commandSandboxLogs.action(async (identifier, options) => {
|
|
15
16
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
16
17
|
const client = input_1.default.restApiTokenClient();
|
|
17
18
|
const sandboxId = await input_1.default.sandboxId(client, workspace, options, identifier);
|
|
18
19
|
const { boot_logs } = await client.getSandbox(workspace, sandboxId);
|
|
20
|
+
if (options.format === 'jsonl') {
|
|
21
|
+
for (const log of boot_logs || []) {
|
|
22
|
+
output_1.default.json(typeof log === 'string'
|
|
23
|
+
? { type: 'log', data: log }
|
|
24
|
+
: {
|
|
25
|
+
type: 'log',
|
|
26
|
+
data: log.data ?? JSON.stringify(log),
|
|
27
|
+
...(log.source ? { source: log.source } : {}),
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
output_1.default.exitNormal();
|
|
31
|
+
}
|
|
19
32
|
output_1.default.exitNormal((boot_logs || []).join('\n'));
|
|
20
33
|
});
|
|
21
34
|
exports.default = commandSandboxLogs;
|
|
@@ -13,6 +13,7 @@ commandSandboxSnapshotCreate.alias('add');
|
|
|
13
13
|
commandSandboxSnapshotCreate.option('-n, --name <name>', texts_1.OPTION_SANDBOX_SNAPSHOT_NAME);
|
|
14
14
|
commandSandboxSnapshotCreate.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
|
|
15
15
|
commandSandboxSnapshotCreate.option('--wait [seconds]', texts_1.OPTION_SANDBOX_WAIT);
|
|
16
|
+
commandSandboxSnapshotCreate.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
16
17
|
commandSandboxSnapshotCreate.action(async (identifier, options) => {
|
|
17
18
|
const humanId = require('human-id').default;
|
|
18
19
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
@@ -26,7 +27,8 @@ commandSandboxSnapshotCreate.action(async (identifier, options) => {
|
|
|
26
27
|
const snapshot = await client.createSandboxSnapshot(workspace, sandboxId, body);
|
|
27
28
|
const snapshotId = snapshot.id;
|
|
28
29
|
if (options.wait) {
|
|
29
|
-
|
|
30
|
+
if (options.format !== 'json')
|
|
31
|
+
output_1.default.normal(texts_1.TXT_SANDBOX_SNAPSHOT_WAITING);
|
|
30
32
|
const timeout = parseInt(options.wait, 10) || 300;
|
|
31
33
|
try {
|
|
32
34
|
const status = await client.sandboxWaitForSnapshot(workspace, sandboxId, snapshotId, timeout);
|
|
@@ -38,6 +40,12 @@ commandSandboxSnapshotCreate.action(async (identifier, options) => {
|
|
|
38
40
|
output_1.default.exitError(texts_1.ERR_SANDBOX_SNAPSHOT_TIMEOUT);
|
|
39
41
|
}
|
|
40
42
|
}
|
|
43
|
+
if (options.format === 'json') {
|
|
44
|
+
output_1.default.json(options.wait
|
|
45
|
+
? await client.getSandboxSnapshot(workspace, sandboxId, snapshotId)
|
|
46
|
+
: snapshot);
|
|
47
|
+
output_1.default.exitNormal();
|
|
48
|
+
}
|
|
41
49
|
output_1.default.exitSuccess((0, texts_1.TXT_SANDBOX_SNAPSHOT_CREATED)(snapshotName));
|
|
42
50
|
});
|
|
43
51
|
exports.default = commandSandboxSnapshotCreate;
|
|
@@ -18,6 +18,7 @@ commandTargetCreate.option('--pipeline <identifier>', texts_1.OPTION_TARGET_PIPE
|
|
|
18
18
|
commandTargetCreate.option('--environment <identifier>', texts_1.OPTION_TARGET_ENVIRONMENT);
|
|
19
19
|
commandTargetCreate.option('--scope <scope>', texts_1.OPT_COMMAND_TARGET_SCOPE);
|
|
20
20
|
commandTargetCreate.option('--yaml <content|@path>', texts_1.OPTION_TARGET_YAML);
|
|
21
|
+
commandTargetCreate.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
21
22
|
commandTargetCreate.action(async (options) => {
|
|
22
23
|
const yaml = input_1.default.restApiYaml(options.yaml);
|
|
23
24
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
@@ -29,6 +30,10 @@ commandTargetCreate.action(async (options) => {
|
|
|
29
30
|
yaml: Buffer.from(yaml, 'utf8').toString('base64'),
|
|
30
31
|
};
|
|
31
32
|
const result = await client.createTargetByYaml(workspace, scopeParams, body);
|
|
33
|
+
if (options.format === 'json') {
|
|
34
|
+
output_1.default.json(result);
|
|
35
|
+
output_1.default.exitNormal();
|
|
36
|
+
}
|
|
32
37
|
output_1.default.exitSuccess((0, texts_1.TXT_TARGET_CREATED)(result.identifier, result.html_url));
|
|
33
38
|
});
|
|
34
39
|
exports.default = commandTargetCreate;
|
|
@@ -8,19 +8,32 @@ const texts_1 = require("../../../texts");
|
|
|
8
8
|
const input_1 = __importDefault(require("../../../input"));
|
|
9
9
|
const output_1 = __importDefault(require("../../../output"));
|
|
10
10
|
const scope_1 = require("../scope");
|
|
11
|
-
const commandTargetExecLogs = (0, utils_1.newCommand)('logs', texts_1.DESC_COMMAND_TARGET_EXEC_LOGS, { examples: texts_1.EXAMPLE_TARGET_EXEC_LOGS });
|
|
11
|
+
const commandTargetExecLogs = (0, utils_1.newCommand)('logs', texts_1.DESC_COMMAND_TARGET_EXEC_LOGS, { helpText: texts_1.HELP_TARGET_EXEC_LOGS_JSONL, examples: texts_1.EXAMPLE_TARGET_EXEC_LOGS });
|
|
12
12
|
commandTargetExecLogs.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
13
13
|
commandTargetExecLogs.option('--offset <n>', texts_1.OPTION_TARGET_EXEC_LOG_OFFSET);
|
|
14
14
|
commandTargetExecLogs.option('--limit <n>', texts_1.OPTION_TARGET_EXEC_LOG_LIMIT);
|
|
15
15
|
commandTargetExecLogs.argument('<exec-id>', texts_1.OPTION_TARGET_EXEC_ID);
|
|
16
|
+
commandTargetExecLogs.option('--format <text|jsonl>', texts_1.OPTION_FORMAT_JSONL);
|
|
16
17
|
commandTargetExecLogs.action(async (execId, options) => {
|
|
17
18
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
18
19
|
const client = input_1.default.restApiTokenClient();
|
|
19
20
|
const offset = options.offset ? parseInt(options.offset, 10) : 0;
|
|
20
21
|
const limit = options.limit ? parseInt(options.limit, 10) : undefined;
|
|
21
|
-
const { truncated } = await (0, scope_1.forwardExecLog)(client, workspace, execId, offset,
|
|
22
|
+
const { truncated } = await (0, scope_1.forwardExecLog)(client, workspace, execId, offset, options.format === 'jsonl'
|
|
23
|
+
? (lines) => lines.forEach((data) => output_1.default.json({ type: 'log', data }))
|
|
24
|
+
: undefined, limit);
|
|
22
25
|
if (truncated)
|
|
23
26
|
output_1.default.noteWarning(texts_1.WARN_TARGET_EXEC_TRUNCATED);
|
|
27
|
+
if (options.format === 'jsonl') {
|
|
28
|
+
const exec = await client.getTargetExec(workspace, execId);
|
|
29
|
+
output_1.default.json({
|
|
30
|
+
type: 'exit',
|
|
31
|
+
status: exec.status,
|
|
32
|
+
exit_code: exec.exit_code ?? null,
|
|
33
|
+
truncated,
|
|
34
|
+
});
|
|
35
|
+
output_1.default.exitNormal();
|
|
36
|
+
}
|
|
24
37
|
output_1.default.exitNormal();
|
|
25
38
|
});
|
|
26
39
|
exports.default = commandTargetExecLogs;
|
|
@@ -18,6 +18,7 @@ commandTargetUpdate.option('--pipeline <identifier>', texts_1.OPTION_TARGET_PIPE
|
|
|
18
18
|
commandTargetUpdate.option('--environment <identifier>', texts_1.OPTION_TARGET_ENVIRONMENT);
|
|
19
19
|
commandTargetUpdate.option('--yaml <content|@path>', texts_1.OPTION_TARGET_YAML);
|
|
20
20
|
commandTargetUpdate.argument('<identifier>', texts_1.OPTION_TARGET_IDENTIFIER);
|
|
21
|
+
commandTargetUpdate.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
21
22
|
commandTargetUpdate.action(async (identifier, options) => {
|
|
22
23
|
const yaml = input_1.default.restApiYaml(options.yaml);
|
|
23
24
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
@@ -28,6 +29,10 @@ commandTargetUpdate.action(async (identifier, options) => {
|
|
|
28
29
|
yaml: Buffer.from(yaml, 'utf8').toString('base64'),
|
|
29
30
|
};
|
|
30
31
|
const result = await client.updateTargetByYaml(workspace, target_id, body);
|
|
32
|
+
if (options.format === 'json') {
|
|
33
|
+
output_1.default.json(result);
|
|
34
|
+
output_1.default.exitNormal();
|
|
35
|
+
}
|
|
31
36
|
output_1.default.exitSuccess((0, texts_1.TXT_TARGET_UPDATED)(result.identifier, result.html_url));
|
|
32
37
|
});
|
|
33
38
|
exports.default = commandTargetUpdate;
|