bdy 1.25.13-dev → 1.25.14-dev
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/distTs/package.json +1 -1
- package/distTs/src/agent/manager.js +19 -6
- package/distTs/src/agent/system.js +9 -4
- package/distTs/src/api/client.js +20 -7
- package/distTs/src/cliCommand.js +17 -1
- package/distTs/src/cliIndex.js +12 -2
- package/distTs/src/command/agent/debug.js +4 -3
- package/distTs/src/command/agent/disable.js +4 -3
- package/distTs/src/command/agent/enable.js +4 -3
- package/distTs/src/command/agent/install.js +28 -12
- package/distTs/src/command/agent/proxy/disable.js +4 -3
- package/distTs/src/command/agent/proxy/enable.js +4 -3
- package/distTs/src/command/agent/proxy/status.js +1 -1
- package/distTs/src/command/agent/restart.js +13 -5
- package/distTs/src/command/agent/start.js +11 -4
- package/distTs/src/command/agent/status.js +1 -1
- package/distTs/src/command/agent/stop.js +5 -4
- package/distTs/src/command/agent/tags/get.js +1 -1
- package/distTs/src/command/agent/tags/set.js +4 -3
- package/distTs/src/command/agent/target/disable.js +4 -3
- package/distTs/src/command/agent/target/enable.js +4 -3
- package/distTs/src/command/agent/target/status.js +1 -1
- package/distTs/src/command/agent/tunnel/disable.js +4 -3
- package/distTs/src/command/agent/tunnel/enable.js +4 -3
- package/distTs/src/command/agent/tunnel/http.js +10 -2
- package/distTs/src/command/agent/tunnel/list.js +1 -1
- package/distTs/src/command/agent/tunnel/remove.js +4 -3
- package/distTs/src/command/agent/tunnel/start.js +9 -5
- package/distTs/src/command/agent/tunnel/status.js +1 -1
- package/distTs/src/command/agent/tunnel/tcp.js +10 -2
- package/distTs/src/command/agent/tunnel/tls.js +10 -2
- package/distTs/src/command/agent/uninstall.js +6 -4
- package/distTs/src/command/agent/update.js +13 -5
- package/distTs/src/command/agent/user.js +4 -3
- package/distTs/src/command/agent/version.js +1 -1
- package/distTs/src/command/api/info.js +5 -3
- package/distTs/src/command/api/list.js +1 -0
- package/distTs/src/command/artifact/composer/publish.js +21 -16
- package/distTs/src/command/artifact/delete.js +8 -5
- package/distTs/src/command/artifact/docker/login.js +22 -5
- package/distTs/src/command/artifact/download.js +16 -15
- package/distTs/src/command/artifact/get.js +3 -2
- package/distTs/src/command/artifact/open.js +3 -2
- package/distTs/src/command/artifact/publish.js +3 -2
- package/distTs/src/command/artifact/version/create.js +3 -2
- package/distTs/src/command/artifact/version/delete.js +9 -6
- package/distTs/src/command/artifact/version/get.js +4 -3
- package/distTs/src/command/artifact/version/list.js +3 -2
- package/distTs/src/command/artifact/version/open.js +7 -6
- package/distTs/src/command/config/add/http.js +3 -2
- package/distTs/src/command/config/add/tcp.js +3 -2
- package/distTs/src/command/config/add/tls.js +3 -2
- package/distTs/src/command/config/get/region.js +5 -2
- package/distTs/src/command/config/get/timeout.js +5 -2
- package/distTs/src/command/config/get/token.js +5 -2
- package/distTs/src/command/config/get/tunnel.js +3 -2
- package/distTs/src/command/config/get/tunnels.js +1 -1
- package/distTs/src/command/config/get/whitelist.js +5 -2
- package/distTs/src/command/config/remove/token.js +4 -3
- package/distTs/src/command/config/remove/tunnel.js +6 -4
- package/distTs/src/command/config/set/region.js +4 -3
- package/distTs/src/command/config/set/timeout.js +4 -3
- package/distTs/src/command/config/set/token.js +5 -3
- package/distTs/src/command/config/set/whitelist.js +4 -3
- package/distTs/src/command/crawl/link.js +10 -4
- package/distTs/src/command/crawl/run.js +30 -18
- package/distTs/src/command/distro/delete.js +8 -5
- package/distTs/src/command/distro/get.js +3 -2
- package/distTs/src/command/distro/open.js +3 -2
- package/distTs/src/command/distro/route/create.js +3 -2
- package/distTs/src/command/distro/route/delete.js +8 -5
- package/distTs/src/command/distro/route/get.js +3 -2
- package/distTs/src/command/distro/route/list.js +3 -2
- package/distTs/src/command/distro/route/open.js +3 -2
- package/distTs/src/command/distro/route/update.js +3 -2
- package/distTs/src/command/distro/update.js +3 -2
- package/distTs/src/command/domain/buy.js +36 -17
- package/distTs/src/command/domain/get.js +3 -2
- package/distTs/src/command/domain/list.js +1 -1
- package/distTs/src/command/domain/open.js +4 -2
- package/distTs/src/command/domain/search.js +1 -0
- package/distTs/src/command/environment/create.js +1 -1
- package/distTs/src/command/environment/delete.js +6 -4
- package/distTs/src/command/environment/get.js +1 -0
- package/distTs/src/command/environment/list.js +1 -1
- package/distTs/src/command/environment/open.js +3 -1
- package/distTs/src/command/environment/update.js +1 -1
- package/distTs/src/command/login.js +29 -17
- package/distTs/src/command/logout.js +4 -3
- package/distTs/src/command/pipeline/create.js +13 -3
- package/distTs/src/command/pipeline/delete.js +9 -6
- package/distTs/src/command/pipeline/get.js +4 -3
- package/distTs/src/command/pipeline/open.js +2 -1
- package/distTs/src/command/pipeline/run/execution.js +3 -3
- package/distTs/src/command/pipeline/run/list.js +4 -3
- package/distTs/src/command/pipeline/run/open.js +2 -1
- package/distTs/src/command/pipeline/update.js +4 -3
- package/distTs/src/command/pipeline/yaml.js +4 -3
- package/distTs/src/command/project/link.js +74 -36
- package/distTs/src/command/project/list.js +1 -0
- package/distTs/src/command/project/open.js +3 -1
- package/distTs/src/command/register.js +2 -1
- package/distTs/src/command/sandbox/app/add.js +1 -0
- package/distTs/src/command/sandbox/app/list.js +1 -1
- package/distTs/src/command/sandbox/app/logs.js +1 -1
- package/distTs/src/command/sandbox/app/remove.js +4 -3
- package/distTs/src/command/sandbox/app/start.js +4 -3
- package/distTs/src/command/sandbox/app/status.js +3 -2
- package/distTs/src/command/sandbox/app/stop.js +4 -3
- package/distTs/src/command/sandbox/cp.js +23 -23
- package/distTs/src/command/sandbox/create.js +3 -1
- package/distTs/src/command/sandbox/destroy.js +6 -4
- package/distTs/src/command/sandbox/endpoint/add.js +1 -1
- package/distTs/src/command/sandbox/endpoint/delete.js +9 -6
- package/distTs/src/command/sandbox/endpoint/get.js +3 -2
- package/distTs/src/command/sandbox/endpoint/list.js +1 -1
- package/distTs/src/command/sandbox/exec/command.js +1 -0
- package/distTs/src/command/sandbox/exec/kill.js +7 -5
- package/distTs/src/command/sandbox/exec/list.js +1 -1
- package/distTs/src/command/sandbox/exec/logs.js +1 -1
- package/distTs/src/command/sandbox/exec/status.js +1 -1
- package/distTs/src/command/sandbox/get.js +1 -1
- package/distTs/src/command/sandbox/list.js +1 -1
- package/distTs/src/command/sandbox/logs.js +1 -1
- package/distTs/src/command/sandbox/open.js +3 -1
- package/distTs/src/command/sandbox/restart.js +9 -4
- package/distTs/src/command/sandbox/snapshot/create.js +1 -1
- package/distTs/src/command/sandbox/snapshot/delete.js +8 -5
- package/distTs/src/command/sandbox/snapshot/get.js +3 -2
- package/distTs/src/command/sandbox/snapshot/list.js +1 -1
- package/distTs/src/command/sandbox/snapshot/open.js +4 -2
- package/distTs/src/command/sandbox/ssh.js +1 -0
- package/distTs/src/command/sandbox/start.js +9 -4
- package/distTs/src/command/sandbox/status.js +1 -1
- package/distTs/src/command/sandbox/stop.js +9 -4
- package/distTs/src/command/sandbox/update.js +12 -6
- package/distTs/src/command/sandbox/yaml.js +1 -1
- package/distTs/src/command/target/create.js +1 -0
- package/distTs/src/command/target/delete.js +6 -3
- package/distTs/src/command/target/exec/command.js +1 -1
- package/distTs/src/command/target/exec/kill.js +6 -4
- package/distTs/src/command/target/exec/list.js +1 -1
- package/distTs/src/command/target/exec/logs.js +1 -1
- package/distTs/src/command/target/exec/status.js +1 -1
- package/distTs/src/command/target/get.js +1 -0
- package/distTs/src/command/target/list.js +1 -0
- package/distTs/src/command/target/open.js +3 -1
- package/distTs/src/command/target/scope.js +4 -4
- package/distTs/src/command/target/update.js +1 -0
- package/distTs/src/command/tests/capture.js +10 -7
- package/distTs/src/command/tests/unit/link.js +10 -4
- package/distTs/src/command/tests/visual/link.js +10 -4
- package/distTs/src/command/tests/visual/session/close.js +8 -3
- package/distTs/src/command/tests/visual/setup.js +6 -3
- package/distTs/src/command/tests/visual/upload.js +11 -8
- package/distTs/src/command/tunnel/http.js +6 -2
- package/distTs/src/command/tunnel/start.js +8 -3
- package/distTs/src/command/tunnel/tcp.js +6 -3
- package/distTs/src/command/tunnel/tls.js +6 -3
- package/distTs/src/command/version.js +24 -2
- package/distTs/src/command/whoami.js +1 -1
- package/distTs/src/command/workspace/get.js +7 -2
- package/distTs/src/command/workspace/list.js +1 -1
- package/distTs/src/command/workspace/open.js +4 -2
- package/distTs/src/command/workspace/set.js +4 -3
- package/distTs/src/command/yaml/actions/info.js +1 -1
- package/distTs/src/command/yaml/actions/list.js +1 -1
- package/distTs/src/command/yaml/pipeline.js +1 -0
- package/distTs/src/command/yaml/validate.js +1 -0
- package/distTs/src/discovery.js +169 -50
- package/distTs/src/input.js +6 -6
- package/distTs/src/output.js +72 -33
- package/distTs/src/texts.js +103 -42
- package/distTs/src/tunnel/output/noninteractive/tunnelJsonl.js +62 -0
- package/distTs/src/utils.js +19 -0
- package/distTs/src/visualTest/browser.js +3 -2
- package/package.json +1 -1
|
@@ -9,23 +9,34 @@ const input_1 = __importDefault(require("../../input"));
|
|
|
9
9
|
const output_1 = __importDefault(require("../../output"));
|
|
10
10
|
const node_path_1 = require("node:path");
|
|
11
11
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
12
|
-
|
|
12
|
+
// With --format json the narration below is skipped and prompts go to
|
|
13
|
+
// stderr, so stdout carries only the linked project.
|
|
14
|
+
let json = false;
|
|
15
|
+
const commandProjectLink = (0, utils_1.newCommand)('link', texts_1.DESC_COMMAND_PROJECT_LINK, { requiredScopes: [utils_1.REST_API_SCOPE.PROJECT_WRITE] });
|
|
13
16
|
commandProjectLink.usesDefaultContext = true;
|
|
14
17
|
commandProjectLink.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
15
18
|
commandProjectLink.option('-r, --relink', texts_1.OPT_COMMAND_PROJECT_LINK_RELINK);
|
|
16
19
|
commandProjectLink.option('-g, --git', texts_1.OPT_COMMAND_PROJECT_LINK_GIT);
|
|
17
20
|
commandProjectLink.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
|
|
21
|
+
commandProjectLink.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
18
22
|
commandProjectLink.argument('[directory]', texts_1.OPT_COMMAND_PROJECT_LINK_DIRECTORY);
|
|
19
23
|
commandProjectLink.action(async (dir, options) => {
|
|
20
24
|
const ProjectCfg = require('../../project/cfg').default;
|
|
25
|
+
json = options.format === 'json';
|
|
21
26
|
output_1.default.handleSignals();
|
|
22
27
|
const { path, git } = await checkPath(dir, options);
|
|
23
28
|
const { workspace, project, url } = await createOrGetProject(path, options);
|
|
24
29
|
ProjectCfg.init(path, workspace, project);
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
30
|
+
if (!json) {
|
|
31
|
+
output_1.default.okSign();
|
|
32
|
+
output_1.default.normal(texts_1.TXT_COMMAND_PROJECT_LINK_TO, false);
|
|
33
|
+
output_1.default.cyan(` ${url}`);
|
|
34
|
+
}
|
|
35
|
+
const data = await initRepo(workspace, project, path, git, options);
|
|
36
|
+
if (json) {
|
|
37
|
+
output_1.default.json(data);
|
|
38
|
+
output_1.default.exitNormal();
|
|
39
|
+
}
|
|
29
40
|
tryNow();
|
|
30
41
|
output_1.default.exitNormal();
|
|
31
42
|
});
|
|
@@ -70,15 +81,17 @@ const initRepo = async (workspace, project, path, git, options) => {
|
|
|
70
81
|
const { remote } = getProjectRemote(data);
|
|
71
82
|
let repo = options.git;
|
|
72
83
|
if (!repo)
|
|
73
|
-
repo = await output_1.default.confirm(texts_1.TXT_COMMAND_PROJECT_LINK_GIT_REPO);
|
|
84
|
+
repo = await output_1.default.confirm(texts_1.TXT_COMMAND_PROJECT_LINK_GIT_REPO, json);
|
|
74
85
|
if (!repo)
|
|
75
|
-
return;
|
|
86
|
+
return data;
|
|
76
87
|
if (!git) {
|
|
77
88
|
await (0, utils_1.execLocally)('git init', {
|
|
78
89
|
cwd: path,
|
|
79
90
|
});
|
|
80
|
-
|
|
81
|
-
|
|
91
|
+
if (!json) {
|
|
92
|
+
output_1.default.okSign();
|
|
93
|
+
output_1.default.normal(texts_1.TXT_COMMAND_PROJECT_LINK_GIT_REPO_INITIALIZED);
|
|
94
|
+
}
|
|
82
95
|
}
|
|
83
96
|
const str = await (0, utils_1.execLocally)('git remote -v', {
|
|
84
97
|
cwd: path,
|
|
@@ -88,18 +101,27 @@ const initRepo = async (workspace, project, path, git, options) => {
|
|
|
88
101
|
await (0, utils_1.execLocally)(`git remote add origin ${remote}`, {
|
|
89
102
|
cwd: path,
|
|
90
103
|
});
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
104
|
+
if (!json) {
|
|
105
|
+
output_1.default.okSign();
|
|
106
|
+
output_1.default.normal('Remote ', false);
|
|
107
|
+
output_1.default.cyan('origin ', false);
|
|
108
|
+
output_1.default.normal('set to ', false);
|
|
109
|
+
output_1.default.cyan(remote);
|
|
110
|
+
}
|
|
96
111
|
}
|
|
97
112
|
else if (remotes.origin !== remote) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
113
|
+
if (json) {
|
|
114
|
+
output_1.default.noteWarning(texts_1.OPT_COMMAND_PROJECT_LINK_HAS_REMOTE);
|
|
115
|
+
output_1.default.note(`Current origin: ${remotes.origin}`);
|
|
116
|
+
output_1.default.note(`Buddy project: ${remote}`);
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
output_1.default.yellow(texts_1.OPT_COMMAND_PROJECT_LINK_HAS_REMOTE);
|
|
120
|
+
output_1.default.normal('Current origin: ', false);
|
|
121
|
+
output_1.default.cyan(remotes.origin);
|
|
122
|
+
output_1.default.normal('Buddy project: ', false);
|
|
123
|
+
output_1.default.cyan(remote);
|
|
124
|
+
}
|
|
103
125
|
const opt = await output_1.default.inputMenuAdv(texts_1.OPT_COMMAND_PROJECT_LINK_SET_GIT_REMOTE, [
|
|
104
126
|
{
|
|
105
127
|
name: 'Add buddy remote',
|
|
@@ -126,11 +148,13 @@ const initRepo = async (workspace, project, path, git, options) => {
|
|
|
126
148
|
await (0, utils_1.execLocally)(`git remote add buddy ${remote}`, {
|
|
127
149
|
cwd: path,
|
|
128
150
|
});
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
151
|
+
if (!json) {
|
|
152
|
+
output_1.default.okSign();
|
|
153
|
+
output_1.default.normal('Remote ', false);
|
|
154
|
+
output_1.default.cyan('buddy ', false);
|
|
155
|
+
output_1.default.normal('set to ', false);
|
|
156
|
+
output_1.default.cyan(remote);
|
|
157
|
+
}
|
|
134
158
|
}
|
|
135
159
|
else if (opt === 'origin') {
|
|
136
160
|
await (0, utils_1.execLocally)(`git remote rm origin`, {
|
|
@@ -139,12 +163,14 @@ const initRepo = async (workspace, project, path, git, options) => {
|
|
|
139
163
|
await (0, utils_1.execLocally)(`git remote add origin ${remote}`, {
|
|
140
164
|
cwd: path,
|
|
141
165
|
});
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
166
|
+
if (!json) {
|
|
167
|
+
output_1.default.okSign();
|
|
168
|
+
output_1.default.normal('Origin replaced with ', false);
|
|
169
|
+
output_1.default.cyan(remote);
|
|
170
|
+
}
|
|
145
171
|
}
|
|
146
172
|
else {
|
|
147
|
-
return;
|
|
173
|
+
return data;
|
|
148
174
|
}
|
|
149
175
|
}
|
|
150
176
|
await (0, utils_1.execLocally)('git config --replace-all credential.helper ""', {
|
|
@@ -153,6 +179,7 @@ const initRepo = async (workspace, project, path, git, options) => {
|
|
|
153
179
|
await (0, utils_1.execLocally)("git config --add credential.helper '!bdy project git credential'", {
|
|
154
180
|
cwd: path,
|
|
155
181
|
});
|
|
182
|
+
return data;
|
|
156
183
|
};
|
|
157
184
|
const checkPath = async (dir, options) => {
|
|
158
185
|
const ProjectCfg = require('../../project/cfg').default;
|
|
@@ -176,13 +203,17 @@ const checkPath = async (dir, options) => {
|
|
|
176
203
|
}
|
|
177
204
|
}
|
|
178
205
|
if (ProjectCfg.exists(path)) {
|
|
179
|
-
|
|
206
|
+
if (json)
|
|
207
|
+
output_1.default.noteWarning(texts_1.TXT_COMMAND_PROJECT_LINK_DIR_LINKED);
|
|
208
|
+
else
|
|
209
|
+
output_1.default.yellow(texts_1.TXT_COMMAND_PROJECT_LINK_DIR_LINKED);
|
|
180
210
|
let relink = options.relink;
|
|
181
211
|
if (!relink) {
|
|
182
|
-
relink = await output_1.default.confirm(texts_1.TXT_COMMAND_PROJECT_LINK_DIR_CONFIRM);
|
|
212
|
+
relink = await output_1.default.confirm(texts_1.TXT_COMMAND_PROJECT_LINK_DIR_CONFIRM, json);
|
|
183
213
|
}
|
|
214
|
+
// declined: nothing was linked
|
|
184
215
|
if (!relink)
|
|
185
|
-
output_1.default.
|
|
216
|
+
output_1.default.exitResult(json, null);
|
|
186
217
|
}
|
|
187
218
|
const children = await node_fs_1.default.promises.readdir(path);
|
|
188
219
|
const git = !!children.find((name) => name === '.git');
|
|
@@ -199,12 +230,17 @@ const createOrGetProject = async (path, options) => {
|
|
|
199
230
|
url = String(response.html_url || '');
|
|
200
231
|
}
|
|
201
232
|
catch {
|
|
202
|
-
|
|
233
|
+
if (json)
|
|
234
|
+
output_1.default.noteWarning((0, texts_1.TXT_COMMAND_PROJECT_LINK_NOT_FOUND)(project));
|
|
235
|
+
else
|
|
236
|
+
output_1.default.yellow((0, texts_1.TXT_COMMAND_PROJECT_LINK_NOT_FOUND)(project));
|
|
203
237
|
const response = await client.createProject(workspace, {
|
|
204
238
|
display_name: project,
|
|
205
239
|
});
|
|
206
|
-
|
|
207
|
-
|
|
240
|
+
if (!json) {
|
|
241
|
+
output_1.default.okSign();
|
|
242
|
+
output_1.default.normal(texts_1.TXT_COMMAND_PROJECT_CREATED);
|
|
243
|
+
}
|
|
208
244
|
project = String(response.name || '');
|
|
209
245
|
url = String(response.html_url || '');
|
|
210
246
|
}
|
|
@@ -227,8 +263,10 @@ const createOrGetProject = async (path, options) => {
|
|
|
227
263
|
const response = await client.createProject(workspace, {
|
|
228
264
|
display_name: name,
|
|
229
265
|
});
|
|
230
|
-
|
|
231
|
-
|
|
266
|
+
if (!json) {
|
|
267
|
+
output_1.default.okSign();
|
|
268
|
+
output_1.default.normal(texts_1.TXT_COMMAND_PROJECT_CREATED);
|
|
269
|
+
}
|
|
232
270
|
project = String(response.name || '');
|
|
233
271
|
url = String(response.html_url || '');
|
|
234
272
|
}
|
|
@@ -8,6 +8,7 @@ const texts_1 = require("../../texts");
|
|
|
8
8
|
const utils_1 = require("../../utils");
|
|
9
9
|
const input_1 = __importDefault(require("../../input"));
|
|
10
10
|
const commandProjectList = (0, utils_1.newCommand)('list', texts_1.DESC_COMMAND_PROJECT_LIST, {
|
|
11
|
+
requiredScopes: [utils_1.REST_API_SCOPE.PROJECT_READ],
|
|
11
12
|
helpText: texts_1.HELP_PROJECT_LIST_PAGINATION,
|
|
12
13
|
});
|
|
13
14
|
commandProjectList.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
@@ -8,14 +8,16 @@ const texts_1 = require("../../texts");
|
|
|
8
8
|
const input_1 = __importDefault(require("../../input"));
|
|
9
9
|
const output_1 = __importDefault(require("../../output"));
|
|
10
10
|
const commandProjectOpen = (0, utils_1.newCommand)('open', texts_1.DESC_COMMAND_RESOURCE_OPEN, {
|
|
11
|
+
requiredScopes: [utils_1.REST_API_SCOPE.PROJECT_READ],
|
|
11
12
|
examples: [{ description: 'Open a project in Buddy', command: 'bdy project open my-project' }],
|
|
12
13
|
});
|
|
13
14
|
commandProjectOpen.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
15
|
+
commandProjectOpen.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
14
16
|
commandProjectOpen.argument('<name>', texts_1.OPTION_REST_API_PROJECT);
|
|
15
17
|
commandProjectOpen.action(async (name, options) => {
|
|
16
18
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
17
19
|
const client = input_1.default.restApiTokenClient();
|
|
18
20
|
const project = await client.getProject(workspace, name);
|
|
19
|
-
await output_1.default.openUrl(project.html_url);
|
|
21
|
+
await output_1.default.openUrl(project.html_url, options.format === 'json');
|
|
20
22
|
});
|
|
21
23
|
exports.default = commandProjectOpen;
|
|
@@ -7,13 +7,14 @@ const utils_1 = require("../utils");
|
|
|
7
7
|
const texts_1 = require("../texts");
|
|
8
8
|
const output_1 = __importDefault(require("../output"));
|
|
9
9
|
const login_1 = require("./login");
|
|
10
|
-
const commandRegister = (0, utils_1.newCommand)('register', texts_1.DESC_COMMAND_REGISTER);
|
|
10
|
+
const commandRegister = (0, utils_1.newCommand)('register', texts_1.DESC_COMMAND_REGISTER, { requiredScopes: [] });
|
|
11
11
|
commandRegister.usesDefaultContext = true;
|
|
12
12
|
commandRegister.alias('sign-up');
|
|
13
13
|
commandRegister.option('--api <url>', texts_1.OPTION_REST_API_ENDPOINT);
|
|
14
14
|
commandRegister.option('--region <region>', texts_1.OPTION_REST_API_REGION);
|
|
15
15
|
commandRegister.option('-e, --email <email>', texts_1.OPT_COMMAND_REGISTER_EMAIL);
|
|
16
16
|
commandRegister.option('-n, --name <name>', texts_1.OPT_COMMAND_REGISTER_NAME);
|
|
17
|
+
commandRegister.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
17
18
|
commandRegister.action(async (options) => {
|
|
18
19
|
output_1.default.handleSignals();
|
|
19
20
|
let email = options.email;
|
|
@@ -8,6 +8,7 @@ const texts_1 = require("../../../texts");
|
|
|
8
8
|
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
|
+
requiredScopes: [utils_1.REST_API_SCOPE.SANDBOX_WRITE],
|
|
11
12
|
examples: texts_1.EXAMPLE_SANDBOX_APP_ADD,
|
|
12
13
|
helpText: texts_1.HELP_SANDBOX_APP_ADD_JSON,
|
|
13
14
|
});
|
|
@@ -7,7 +7,7 @@ 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 commandSandboxAppList = (0, utils_1.newCommand)('list', texts_1.DESC_COMMAND_SANDBOX_APP_LIST, { examples: texts_1.EXAMPLE_SANDBOX_APP_LIST });
|
|
10
|
+
const commandSandboxAppList = (0, utils_1.newCommand)('list', texts_1.DESC_COMMAND_SANDBOX_APP_LIST, { requiredScopes: [utils_1.REST_API_SCOPE.SANDBOX_READ], examples: texts_1.EXAMPLE_SANDBOX_APP_LIST });
|
|
11
11
|
commandSandboxAppList.alias('ls');
|
|
12
12
|
(0, utils_1.sandboxScopeOptions)(commandSandboxAppList);
|
|
13
13
|
commandSandboxAppList.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
@@ -7,7 +7,7 @@ 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 commandSandboxAppLogs = (0, utils_1.newCommand)('logs', texts_1.DESC_COMMAND_SANDBOX_APP_LOGS, { examples: texts_1.EXAMPLE_SANDBOX_APP_LOGS });
|
|
10
|
+
const commandSandboxAppLogs = (0, utils_1.newCommand)('logs', texts_1.DESC_COMMAND_SANDBOX_APP_LOGS, { requiredScopes: [utils_1.REST_API_SCOPE.SANDBOX_READ], examples: texts_1.EXAMPLE_SANDBOX_APP_LOGS });
|
|
11
11
|
commandSandboxAppLogs.hideVersionUpdate = true;
|
|
12
12
|
(0, utils_1.sandboxScopeOptions)(commandSandboxAppLogs);
|
|
13
13
|
commandSandboxAppLogs.option('-l, --limit <lines>', texts_1.OPTION_SANDBOX_LOGS_LIMIT);
|
|
@@ -7,20 +7,21 @@ 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 commandSandboxAppRemove = (0, utils_1.newCommand)('remove', texts_1.DESC_COMMAND_SANDBOX_APP_REMOVE, { examples: texts_1.EXAMPLE_SANDBOX_APP_REMOVE });
|
|
10
|
+
const commandSandboxAppRemove = (0, utils_1.newCommand)('remove', texts_1.DESC_COMMAND_SANDBOX_APP_REMOVE, { requiredScopes: [utils_1.REST_API_SCOPE.SANDBOX_WRITE], examples: texts_1.EXAMPLE_SANDBOX_APP_REMOVE });
|
|
11
11
|
commandSandboxAppRemove.alias('rm');
|
|
12
12
|
(0, utils_1.sandboxScopeOptions)(commandSandboxAppRemove);
|
|
13
13
|
commandSandboxAppRemove.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
|
|
14
14
|
commandSandboxAppRemove.argument('<app-id>', texts_1.OPTION_SANDBOX_APP_ID);
|
|
15
|
+
commandSandboxAppRemove.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
15
16
|
commandSandboxAppRemove.action(async (identifier, appId, options) => {
|
|
16
17
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
17
18
|
const client = input_1.default.restApiTokenClient();
|
|
18
19
|
const sandboxId = await input_1.default.sandboxId(client, workspace, options, identifier);
|
|
19
20
|
const sandbox = await client.getSandbox(workspace, sandboxId);
|
|
20
21
|
const apps = (sandbox.apps || []).filter((app) => app.id !== appId);
|
|
21
|
-
await client.updateSandbox(workspace, sandboxId, {
|
|
22
|
+
const result = await client.updateSandbox(workspace, sandboxId, {
|
|
22
23
|
apps,
|
|
23
24
|
});
|
|
24
|
-
output_1.default.
|
|
25
|
+
output_1.default.exitResult(options.format === 'json', result, texts_1.TXT_SANDBOX_APP_REMOVED);
|
|
25
26
|
});
|
|
26
27
|
exports.default = commandSandboxAppRemove;
|
|
@@ -7,15 +7,16 @@ 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 commandSandboxAppStart = (0, utils_1.newCommand)('start', texts_1.DESC_COMMAND_SANDBOX_APP_START, { examples: texts_1.EXAMPLE_SANDBOX_APP_START });
|
|
10
|
+
const commandSandboxAppStart = (0, utils_1.newCommand)('start', texts_1.DESC_COMMAND_SANDBOX_APP_START, { requiredScopes: [utils_1.REST_API_SCOPE.SANDBOX_WRITE], examples: texts_1.EXAMPLE_SANDBOX_APP_START });
|
|
11
11
|
(0, utils_1.sandboxScopeOptions)(commandSandboxAppStart);
|
|
12
12
|
commandSandboxAppStart.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
|
|
13
13
|
commandSandboxAppStart.argument('<app-id>', texts_1.OPTION_SANDBOX_APP_ID);
|
|
14
|
+
commandSandboxAppStart.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
14
15
|
commandSandboxAppStart.action(async (identifier, appId, 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
|
-
await client.startSandboxApp(workspace, sandboxId, appId);
|
|
19
|
-
output_1.default.
|
|
19
|
+
const result = await client.startSandboxApp(workspace, sandboxId, appId);
|
|
20
|
+
output_1.default.exitResult(options.format === 'json', result, texts_1.TXT_SANDBOX_APP_STARTED);
|
|
20
21
|
});
|
|
21
22
|
exports.default = commandSandboxAppStart;
|
|
@@ -3,11 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const cliError_1 = __importDefault(require("../../../cliError"));
|
|
6
7
|
const utils_1 = require("../../../utils");
|
|
7
8
|
const texts_1 = require("../../../texts");
|
|
8
9
|
const input_1 = __importDefault(require("../../../input"));
|
|
9
10
|
const output_1 = __importDefault(require("../../../output"));
|
|
10
|
-
const commandSandboxAppStatus = (0, utils_1.newCommand)('status', texts_1.DESC_COMMAND_SANDBOX_APP_STATUS, { examples: texts_1.EXAMPLE_SANDBOX_APP_STATUS });
|
|
11
|
+
const commandSandboxAppStatus = (0, utils_1.newCommand)('status', texts_1.DESC_COMMAND_SANDBOX_APP_STATUS, { requiredScopes: [utils_1.REST_API_SCOPE.SANDBOX_READ], examples: texts_1.EXAMPLE_SANDBOX_APP_STATUS });
|
|
11
12
|
(0, utils_1.sandboxScopeOptions)(commandSandboxAppStatus);
|
|
12
13
|
commandSandboxAppStatus.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
13
14
|
commandSandboxAppStatus.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
|
|
@@ -19,7 +20,7 @@ commandSandboxAppStatus.action(async (identifier, appId, options) => {
|
|
|
19
20
|
const { apps, } = await client.getSandbox(workspace, sandboxId);
|
|
20
21
|
const app = (apps || []).find((app) => app.id === appId);
|
|
21
22
|
if (!app) {
|
|
22
|
-
output_1.default.exitError(texts_1.ERR_SANDBOX_APP_NOT_FOUND);
|
|
23
|
+
output_1.default.exitError(new cliError_1.default('not_found', texts_1.ERR_SANDBOX_APP_NOT_FOUND, texts_1.HINT_SANDBOX_APP_LIST));
|
|
23
24
|
}
|
|
24
25
|
if (options.format === 'json') {
|
|
25
26
|
output_1.default.json(app);
|
|
@@ -7,15 +7,16 @@ 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 commandSandboxAppStop = (0, utils_1.newCommand)('stop', texts_1.DESC_COMMAND_SANDBOX_APP_STOP, { examples: texts_1.EXAMPLE_SANDBOX_APP_STOP });
|
|
10
|
+
const commandSandboxAppStop = (0, utils_1.newCommand)('stop', texts_1.DESC_COMMAND_SANDBOX_APP_STOP, { requiredScopes: [utils_1.REST_API_SCOPE.SANDBOX_WRITE], examples: texts_1.EXAMPLE_SANDBOX_APP_STOP });
|
|
11
11
|
(0, utils_1.sandboxScopeOptions)(commandSandboxAppStop);
|
|
12
12
|
commandSandboxAppStop.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
|
|
13
13
|
commandSandboxAppStop.argument('<app-id>', texts_1.OPTION_SANDBOX_APP_ID);
|
|
14
|
+
commandSandboxAppStop.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
14
15
|
commandSandboxAppStop.action(async (identifier, appId, 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
|
-
await client.stopSandboxApp(workspace, sandboxId, appId);
|
|
19
|
-
output_1.default.
|
|
19
|
+
const result = await client.stopSandboxApp(workspace, sandboxId, appId);
|
|
20
|
+
output_1.default.exitResult(options.format === 'json', result, texts_1.TXT_SANDBOX_APP_STOPPED);
|
|
20
21
|
});
|
|
21
22
|
exports.default = commandSandboxAppStop;
|
|
@@ -12,6 +12,7 @@ const node_fs_1 = __importDefault(require("node:fs"));
|
|
|
12
12
|
const promises_1 = __importDefault(require("node:stream/promises"));
|
|
13
13
|
const picomatch_1 = __importDefault(require("picomatch"));
|
|
14
14
|
const commandSandboxCp = (0, utils_1.newCommand)('cp', texts_1.DESC_COMMAND_SANDBOX_CP, {
|
|
15
|
+
requiredScopes: [utils_1.REST_API_SCOPE.SANDBOX_READ, utils_1.REST_API_SCOPE.SANDBOX_WRITE],
|
|
15
16
|
examples: texts_1.EXAMPLE_SANDBOX_CP,
|
|
16
17
|
});
|
|
17
18
|
(0, utils_1.sandboxScopeOptions)(commandSandboxCp);
|
|
@@ -19,9 +20,12 @@ commandSandboxCp.option('-m, --merge', texts_1.OPTION_SANDBOX_CP_DOWNLOAD_MERGE)
|
|
|
19
20
|
commandSandboxCp.option('-r, --replace', texts_1.OPTION_SANDBOX_CP_DOWNLOAD_REPLACE);
|
|
20
21
|
commandSandboxCp.option('-u, --user <user>', texts_1.OPTION_SANDBOX_CP_USER);
|
|
21
22
|
commandSandboxCp.option('--ignore <patterns...>', texts_1.OPTION_SANDBOX_CP_IGNORE);
|
|
23
|
+
commandSandboxCp.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
22
24
|
commandSandboxCp.argument('<source>', texts_1.OPTION_SANDBOX_CP_SOURCE);
|
|
23
25
|
commandSandboxCp.argument('<destination>', texts_1.OPTION_SANDBOX_CP_DEST);
|
|
24
|
-
const
|
|
26
|
+
const exitCopied = (json, files, source, destination) => output_1.default.exitResult(json, { files, source, destination }, (0, texts_1.TXT_SANDBOX_CP_DONE)(files));
|
|
27
|
+
const upload = async (client, workspace, options, source, destination, ignore, json, userName) => {
|
|
28
|
+
const say = output_1.default.progress(json);
|
|
25
29
|
const { fdir } = require('fdir');
|
|
26
30
|
const { sourcePath, sourceStats } = input_1.default.restApiSandboxUploadSourcePath(source);
|
|
27
31
|
const { identifier, remotePath, isRemoteDir } = input_1.default.restApiSandboxUploadDestinationPath(destination);
|
|
@@ -30,10 +34,10 @@ const upload = async (client, workspace, options, source, destination, ignore, u
|
|
|
30
34
|
if (sourceStats.isFile()) {
|
|
31
35
|
// Single file copy
|
|
32
36
|
const name = (0, path_1.basename)(sourcePath);
|
|
33
|
-
|
|
37
|
+
say((0, texts_1.TXT_SANDBOX_CP_PROGRESS)(1, 1, name));
|
|
34
38
|
const remoteFile = isRemoteDir ? (0, path_1.join)(remotePath, name) : remotePath;
|
|
35
39
|
await client.sandboxUploadFile(workspace, sandboxId, remoteFile, sourcePath, userName);
|
|
36
|
-
|
|
40
|
+
exitCopied(json, 1, source, destination);
|
|
37
41
|
}
|
|
38
42
|
else if (sourceStats.isDirectory()) {
|
|
39
43
|
// Directory copy - get all files recursively
|
|
@@ -42,9 +46,9 @@ const upload = async (client, workspace, options, source, destination, ignore, u
|
|
|
42
46
|
? all.filter((p) => !isIgnored((0, path_1.relative)(sourcePath, p).replace(/\\/g, '/')))
|
|
43
47
|
: all;
|
|
44
48
|
if (files.length === 0) {
|
|
45
|
-
|
|
49
|
+
exitCopied(json, 0, source, destination);
|
|
46
50
|
}
|
|
47
|
-
|
|
51
|
+
say('');
|
|
48
52
|
const baseRemoteDir = isRemoteDir
|
|
49
53
|
? (0, path_1.join)(remotePath, (0, path_1.basename)(sourcePath))
|
|
50
54
|
: remotePath;
|
|
@@ -52,33 +56,32 @@ const upload = async (client, workspace, options, source, destination, ignore, u
|
|
|
52
56
|
const localFile = files[i];
|
|
53
57
|
const relativePath = (0, path_1.relative)(sourcePath, localFile);
|
|
54
58
|
const remoteFile = (0, path_1.join)(baseRemoteDir, relativePath).replace(/\\/g, '/');
|
|
55
|
-
|
|
56
|
-
output_1.default.normal((0, texts_1.TXT_SANDBOX_CP_PROGRESS)(i + 1, files.length, relativePath));
|
|
59
|
+
say((0, texts_1.TXT_SANDBOX_CP_PROGRESS)(i + 1, files.length, relativePath), true, true);
|
|
57
60
|
await client.sandboxUploadFile(workspace, sandboxId, remoteFile, localFile, userName);
|
|
58
61
|
}
|
|
59
|
-
|
|
62
|
+
exitCopied(json, files.length, source, destination);
|
|
60
63
|
}
|
|
61
64
|
else {
|
|
62
65
|
output_1.default.exitError((0, texts_1.ERR_SANDBOX_CP_SOURCE_NOT_FOUND)(source));
|
|
63
66
|
}
|
|
64
67
|
};
|
|
65
|
-
const download = async (client, workspace, options, source, destination, merge, replace) => {
|
|
68
|
+
const download = async (client, workspace, options, source, destination, merge, replace, json) => {
|
|
69
|
+
const say = output_1.default.progress(json);
|
|
66
70
|
const { v4 } = require('uuid');
|
|
67
71
|
const ArchiverExtract = require('../../unzipper').default;
|
|
68
72
|
const { UNZIPPER_FORMAT } = require('../../unzipper');
|
|
69
73
|
const { destPath, isDestPathDir } = input_1.default.restApiSandboxDownloadDestinationPath(destination, merge, replace);
|
|
70
74
|
const { sourcePath, identifier } = input_1.default.restApiSandboxDownloadSourcePath(source);
|
|
71
75
|
const sandboxId = await input_1.default.sandboxId(client, workspace, options, identifier);
|
|
72
|
-
|
|
76
|
+
say(texts_1.TXT_SANDBOX_CP_DOWNLOAD, false);
|
|
73
77
|
const { body, headers } = await client.sandboxDownloadFile(workspace, sandboxId, sourcePath);
|
|
74
78
|
const isFile = headers['content-type'] === 'application/octet-stream';
|
|
75
79
|
const name = (0, path_1.basename)(sourcePath);
|
|
76
80
|
if (isFile) {
|
|
77
81
|
const destFilePath = isDestPathDir ? (0, path_1.join)(destPath, name) : destPath;
|
|
78
82
|
await node_fs_1.default.promises.writeFile(destFilePath, body);
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
output_1.default.exitSuccess((0, texts_1.TXT_SANDBOX_CP_DONE)(1));
|
|
83
|
+
say(texts_1.TXT_SANDBOX_CP_DOWNLOAD_DONE, true, true);
|
|
84
|
+
exitCopied(json, 1, source, destination);
|
|
82
85
|
}
|
|
83
86
|
else {
|
|
84
87
|
const destDirPath = isDestPathDir ? (0, path_1.join)(destPath, name) : destPath;
|
|
@@ -93,19 +96,16 @@ const download = async (client, workspace, options, source, destination, merge,
|
|
|
93
96
|
};
|
|
94
97
|
try {
|
|
95
98
|
await promises_1.default.pipeline(body, node_fs_1.default.createWriteStream(zipPath));
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
output_1.default.normal(texts_1.TXT_SANDBOX_UNZIP);
|
|
99
|
+
say(texts_1.TXT_SANDBOX_CP_DOWNLOAD_DONE, true, true);
|
|
100
|
+
say(texts_1.TXT_SANDBOX_UNZIP);
|
|
99
101
|
let count = 0;
|
|
100
102
|
await ArchiverExtract.extract(UNZIPPER_FORMAT.TAR_GZ, zipPath, destDirPath, async () => {
|
|
101
103
|
count += 1;
|
|
102
|
-
|
|
103
|
-
output_1.default.normal((0, texts_1.TXT_SANDBOX_UNZIPPING_COUNT)(count));
|
|
104
|
+
say((0, texts_1.TXT_SANDBOX_UNZIPPING_COUNT)(count), true, true);
|
|
104
105
|
});
|
|
105
106
|
clearZip();
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
output_1.default.exitSuccess((0, texts_1.TXT_SANDBOX_CP_DONE)(count));
|
|
107
|
+
say(texts_1.TXT_SANDBOX_UNZIP_DONE, true, true);
|
|
108
|
+
exitCopied(json, count, source, destination);
|
|
109
109
|
}
|
|
110
110
|
catch {
|
|
111
111
|
clearZip();
|
|
@@ -118,10 +118,10 @@ commandSandboxCp.action(async (source, destination, options) => {
|
|
|
118
118
|
const client = input_1.default.restApiTokenClient();
|
|
119
119
|
const isUpload = input_1.default.restApiSandboxIsUpload(destination);
|
|
120
120
|
if (isUpload) {
|
|
121
|
-
await upload(client, workspace, options, source, destination, options.ignore || [], options.user);
|
|
121
|
+
await upload(client, workspace, options, source, destination, options.ignore || [], options.format === 'json', options.user);
|
|
122
122
|
}
|
|
123
123
|
else {
|
|
124
|
-
await download(client, workspace, options, source, destination, !!options.merge, !!options.replace);
|
|
124
|
+
await download(client, workspace, options, source, destination, !!options.merge, !!options.replace, options.format === 'json');
|
|
125
125
|
}
|
|
126
126
|
});
|
|
127
127
|
exports.default = commandSandboxCp;
|
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const cliError_1 = __importDefault(require("../../cliError"));
|
|
6
7
|
const utils_1 = require("../../utils");
|
|
7
8
|
const texts_1 = require("../../texts");
|
|
8
9
|
const output_1 = __importDefault(require("../../output"));
|
|
@@ -23,6 +24,7 @@ const VALID_RESOURCES = [
|
|
|
23
24
|
'12x24',
|
|
24
25
|
];
|
|
25
26
|
const commandSandboxCreate = (0, utils_1.newCommand)('create', texts_1.DESC_COMMAND_SANDBOX_CREATE, {
|
|
27
|
+
requiredScopes: [utils_1.REST_API_SCOPE.SANDBOX_WRITE],
|
|
26
28
|
examples: [...texts_1.EXAMPLE_SANDBOX_CREATE, ...texts_1.EXAMPLE_SANDBOX_ENDPOINT_CREATE],
|
|
27
29
|
});
|
|
28
30
|
commandSandboxCreate.alias('add');
|
|
@@ -107,7 +109,7 @@ commandSandboxCreate.action(async (options) => {
|
|
|
107
109
|
const snapshots = snapshotsResult.snapshots || [];
|
|
108
110
|
const foundSnapshot = snapshots.find((s) => s.name === options.snapshot);
|
|
109
111
|
if (!foundSnapshot) {
|
|
110
|
-
output_1.default.exitError(texts_1.ERR_SANDBOX_SNAPSHOT_NOT_FOUND);
|
|
112
|
+
output_1.default.exitError(new cliError_1.default('not_found', texts_1.ERR_SANDBOX_SNAPSHOT_NOT_FOUND, texts_1.HINT_SANDBOX_SNAPSHOT_LIST));
|
|
111
113
|
}
|
|
112
114
|
body.snapshot_id = foundSnapshot.id;
|
|
113
115
|
}
|
|
@@ -7,19 +7,21 @@ 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 commandSandboxDestroy = (0, utils_1.newCommand)('destroy', texts_1.DESC_COMMAND_SANDBOX_DESTROY);
|
|
10
|
+
const commandSandboxDestroy = (0, utils_1.newCommand)('destroy', texts_1.DESC_COMMAND_SANDBOX_DESTROY, { requiredScopes: [utils_1.REST_API_SCOPE.SANDBOX_MANAGE] });
|
|
11
11
|
commandSandboxDestroy.aliases(['delete', 'rm']);
|
|
12
12
|
(0, utils_1.sandboxScopeOptions)(commandSandboxDestroy);
|
|
13
13
|
commandSandboxDestroy.option('-f, --force', texts_1.OPTION_CONFIRM_FORCE);
|
|
14
|
+
commandSandboxDestroy.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
14
15
|
commandSandboxDestroy.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
|
|
15
16
|
commandSandboxDestroy.action(async (identifier, options) => {
|
|
16
17
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
17
18
|
const client = input_1.default.restApiTokenClient();
|
|
18
19
|
const sandboxId = await input_1.default.sandboxId(client, workspace, options, identifier);
|
|
19
|
-
const
|
|
20
|
+
const json = options.format === 'json';
|
|
21
|
+
const confirmed = await output_1.default.confirmDestructive(options.force, (0, texts_1.TXT_SANDBOX_DESTROY_CONFIRM)(identifier), json);
|
|
20
22
|
if (!confirmed)
|
|
21
|
-
output_1.default.
|
|
23
|
+
output_1.default.exitResult(json, { deleted: null });
|
|
22
24
|
await client.deleteSandbox(workspace, sandboxId);
|
|
23
|
-
output_1.default.
|
|
25
|
+
output_1.default.exitResult(json, { deleted: identifier }, (0, texts_1.TXT_SANDBOX_DESTROYED)(identifier));
|
|
24
26
|
});
|
|
25
27
|
exports.default = commandSandboxDestroy;
|
|
@@ -8,7 +8,7 @@ const texts_1 = require("../../../texts");
|
|
|
8
8
|
const output_1 = __importDefault(require("../../../output"));
|
|
9
9
|
const input_1 = __importDefault(require("../../../input"));
|
|
10
10
|
const tunnel_1 = require("../../../types/tunnel");
|
|
11
|
-
const commandSandboxEndpointAdd = (0, utils_1.getBasicCommandSandboxEndpoint)('add', texts_1.DESC_COMMAND_SANDBOX_ENDPOINT_ADD, { examples: texts_1.EXAMPLE_SANDBOX_ENDPOINT_CREATE });
|
|
11
|
+
const commandSandboxEndpointAdd = (0, utils_1.getBasicCommandSandboxEndpoint)('add', texts_1.DESC_COMMAND_SANDBOX_ENDPOINT_ADD, { requiredScopes: [utils_1.REST_API_SCOPE.SANDBOX_WRITE], examples: texts_1.EXAMPLE_SANDBOX_ENDPOINT_CREATE });
|
|
12
12
|
commandSandboxEndpointAdd.alias('create');
|
|
13
13
|
commandSandboxEndpointAdd.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
14
14
|
commandSandboxEndpointAdd.action(async (identifier, options) => {
|
|
@@ -3,14 +3,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const cliError_1 = __importDefault(require("../../../cliError"));
|
|
6
7
|
const utils_1 = require("../../../utils");
|
|
7
8
|
const texts_1 = require("../../../texts");
|
|
8
9
|
const output_1 = __importDefault(require("../../../output"));
|
|
9
10
|
const input_1 = __importDefault(require("../../../input"));
|
|
10
|
-
const commandSandboxEndpointDelete = (0, utils_1.newCommand)('delete', texts_1.DESC_COMMAND_SANDBOX_ENDPOINT_DELETE, { examples: texts_1.EXAMPLE_SANDBOX_ENDPOINT_DELETE });
|
|
11
|
+
const commandSandboxEndpointDelete = (0, utils_1.newCommand)('delete', texts_1.DESC_COMMAND_SANDBOX_ENDPOINT_DELETE, { requiredScopes: [utils_1.REST_API_SCOPE.SANDBOX_WRITE], examples: texts_1.EXAMPLE_SANDBOX_ENDPOINT_DELETE });
|
|
11
12
|
commandSandboxEndpointDelete.alias('rm');
|
|
12
13
|
(0, utils_1.sandboxScopeOptions)(commandSandboxEndpointDelete);
|
|
13
14
|
commandSandboxEndpointDelete.option('-f, --force', texts_1.OPTION_CONFIRM_FORCE);
|
|
15
|
+
commandSandboxEndpointDelete.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
14
16
|
commandSandboxEndpointDelete.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
|
|
15
17
|
commandSandboxEndpointDelete.argument('<endpoint-name>', texts_1.OPTION_SANDBOX_ENDPOINT_NAME_ARG);
|
|
16
18
|
commandSandboxEndpointDelete.action(async (identifier, endpointName, options) => {
|
|
@@ -21,15 +23,16 @@ commandSandboxEndpointDelete.action(async (identifier, endpointName, options) =>
|
|
|
21
23
|
const endpoints = sandbox.endpoints || [];
|
|
22
24
|
const endpointIndex = endpoints.findIndex((ep) => ep.name === endpointName);
|
|
23
25
|
if (endpointIndex === -1) {
|
|
24
|
-
output_1.default.exitError(texts_1.ERR_SANDBOX_ENDPOINT_NOT_FOUND);
|
|
26
|
+
output_1.default.exitError(new cliError_1.default('not_found', texts_1.ERR_SANDBOX_ENDPOINT_NOT_FOUND, texts_1.HINT_SANDBOX_ENDPOINT_LIST));
|
|
25
27
|
}
|
|
26
28
|
const updatedEndpoints = endpoints.filter((ep) => ep.name !== endpointName);
|
|
27
|
-
const
|
|
29
|
+
const json = options.format === 'json';
|
|
30
|
+
const confirmed = await output_1.default.confirmDestructive(options.force, (0, texts_1.TXT_SANDBOX_ENDPOINT_DELETE_CONFIRM)(identifier, endpointName), json);
|
|
28
31
|
if (!confirmed)
|
|
29
|
-
output_1.default.
|
|
30
|
-
await client.updateSandbox(workspace, sandboxId, {
|
|
32
|
+
output_1.default.exitResult(json, { deleted: null });
|
|
33
|
+
const result = await client.updateSandbox(workspace, sandboxId, {
|
|
31
34
|
endpoints: updatedEndpoints,
|
|
32
35
|
});
|
|
33
|
-
output_1.default.
|
|
36
|
+
output_1.default.exitResult(json, result, (0, texts_1.TXT_SANDBOX_ENDPOINT_DELETED)(endpointName));
|
|
34
37
|
});
|
|
35
38
|
exports.default = commandSandboxEndpointDelete;
|
|
@@ -3,11 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const cliError_1 = __importDefault(require("../../../cliError"));
|
|
6
7
|
const utils_1 = require("../../../utils");
|
|
7
8
|
const texts_1 = require("../../../texts");
|
|
8
9
|
const output_1 = __importDefault(require("../../../output"));
|
|
9
10
|
const input_1 = __importDefault(require("../../../input"));
|
|
10
|
-
const commandSandboxEndpointGet = (0, utils_1.newCommand)('get', texts_1.DESC_COMMAND_SANDBOX_ENDPOINT_GET, { examples: texts_1.EXAMPLE_SANDBOX_ENDPOINT_GET });
|
|
11
|
+
const commandSandboxEndpointGet = (0, utils_1.newCommand)('get', texts_1.DESC_COMMAND_SANDBOX_ENDPOINT_GET, { requiredScopes: [utils_1.REST_API_SCOPE.SANDBOX_READ], examples: texts_1.EXAMPLE_SANDBOX_ENDPOINT_GET });
|
|
11
12
|
(0, utils_1.sandboxScopeOptions)(commandSandboxEndpointGet);
|
|
12
13
|
commandSandboxEndpointGet.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
13
14
|
commandSandboxEndpointGet.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
|
|
@@ -20,7 +21,7 @@ commandSandboxEndpointGet.action(async (identifier, endpointName, options) => {
|
|
|
20
21
|
const endpoints = sandbox.endpoints || [];
|
|
21
22
|
const endpoint = endpoints.find((ep) => ep.name === endpointName);
|
|
22
23
|
if (!endpoint) {
|
|
23
|
-
output_1.default.exitError(texts_1.ERR_SANDBOX_ENDPOINT_NOT_FOUND);
|
|
24
|
+
output_1.default.exitError(new cliError_1.default('not_found', texts_1.ERR_SANDBOX_ENDPOINT_NOT_FOUND, texts_1.HINT_SANDBOX_ENDPOINT_LIST));
|
|
24
25
|
}
|
|
25
26
|
if (options.format === 'json') {
|
|
26
27
|
output_1.default.json(endpoint);
|