bdy 1.25.13-stage → 1.25.15-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 +61 -50
- package/distTs/src/visualTest/browser.js +3 -2
- package/package.json +1 -1
package/distTs/package.json
CHANGED
|
@@ -55,7 +55,10 @@ class AgentManagerClass {
|
|
|
55
55
|
this.system = new system_1.default();
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
|
|
58
|
+
// quiet keeps stdout for a result printed by onStarted once load() is
|
|
59
|
+
// through: the retry notices go to stderr instead
|
|
60
|
+
quiet = false;
|
|
61
|
+
start(id, host, token, port, onProcessExit = () => { }, onStarted = () => { }) {
|
|
59
62
|
const onExit = () => {
|
|
60
63
|
onProcessExit();
|
|
61
64
|
this.shutdown();
|
|
@@ -66,7 +69,10 @@ class AgentManagerClass {
|
|
|
66
69
|
// Anything load() throws would otherwise be an unhandled rejection: no entry in the
|
|
67
70
|
// agent log, just a stack on stderr that a service swallows. Exit non-zero so the
|
|
68
71
|
// supervisor still retries, but say why first.
|
|
69
|
-
this.load(id, host, token, port).
|
|
72
|
+
this.load(id, host, token, port).then((started) => {
|
|
73
|
+
if (started)
|
|
74
|
+
onStarted();
|
|
75
|
+
}, (err) => {
|
|
70
76
|
try {
|
|
71
77
|
logger_1.default.error(err);
|
|
72
78
|
}
|
|
@@ -280,7 +286,11 @@ class AgentManagerClass {
|
|
|
280
286
|
const wait = Math.round(delay * (0.5 + Math.random() * 0.5));
|
|
281
287
|
this.status = tunnel_1.TUNNEL_AGENT_STATUS.FETCH_FAILED;
|
|
282
288
|
// One decimal, so the message never claims a delay it is not taking
|
|
283
|
-
|
|
289
|
+
const retry = (0, texts_1.AGENT_FETCH_RETRY)(Math.round(wait / 100) / 10);
|
|
290
|
+
if (this.quiet)
|
|
291
|
+
output_1.default.note(retry);
|
|
292
|
+
else
|
|
293
|
+
output_1.default.normal(retry);
|
|
284
294
|
await (0, utils_1.sleep)(wait);
|
|
285
295
|
delay = Math.min(delay * 2, utils_1.AGENT_FETCH_RETRY_MAX);
|
|
286
296
|
}
|
|
@@ -817,6 +827,8 @@ class AgentManagerClass {
|
|
|
817
827
|
return false;
|
|
818
828
|
}
|
|
819
829
|
}
|
|
830
|
+
// Resolves true once the agent is fetched and running, false when it is
|
|
831
|
+
// exiting instead (an update rollback, or a teardown that exits the process).
|
|
820
832
|
async load(id, host, token, port) {
|
|
821
833
|
this.status = tunnel_1.TUNNEL_AGENT_STATUS.INITIALIZING;
|
|
822
834
|
this.id = id;
|
|
@@ -825,21 +837,22 @@ class AgentManagerClass {
|
|
|
825
837
|
this.port = port;
|
|
826
838
|
if (!this.id || !this.token || !this.host || !this.port) {
|
|
827
839
|
await this.disableAgentAndExit(texts_1.ERR_AGENT_NOT_REGISTERED);
|
|
828
|
-
return;
|
|
840
|
+
return false;
|
|
829
841
|
}
|
|
830
842
|
const ok = this.resaveAgentConfig();
|
|
831
843
|
if (!ok) {
|
|
832
844
|
await this.disableAgentAndExit(texts_1.ERR_SAVING_AGENT_CONFIG);
|
|
833
|
-
return;
|
|
845
|
+
return false;
|
|
834
846
|
}
|
|
835
847
|
// A rolled back update leaves this process exiting: binding the port and opening
|
|
836
848
|
// tunnels on the binary we just replaced would be pointless at best, and a fetch
|
|
837
849
|
// that came back 'agent not found' in that window would unregister us for good.
|
|
838
850
|
if (!this.checkUpdateProbation())
|
|
839
|
-
return;
|
|
851
|
+
return false;
|
|
840
852
|
this.createServer();
|
|
841
853
|
await this.tryFetch();
|
|
842
854
|
logger_1.default.info(texts_1.LOG_AGENT_STARTED);
|
|
855
|
+
return true;
|
|
843
856
|
}
|
|
844
857
|
}
|
|
845
858
|
exports.AgentManagerClass = AgentManagerClass;
|
|
@@ -872,7 +872,9 @@ class AgentSystem {
|
|
|
872
872
|
}, 100);
|
|
873
873
|
});
|
|
874
874
|
}
|
|
875
|
-
|
|
875
|
+
// With quiet, stdout carries only what onStarted prints, and only once the
|
|
876
|
+
// agent is really running: a failure before that is the only output.
|
|
877
|
+
startStandaloneProc(quiet = false, onStarted = () => { }) {
|
|
876
878
|
let json;
|
|
877
879
|
try {
|
|
878
880
|
json = this.loadSystemConfig();
|
|
@@ -901,12 +903,15 @@ class AgentSystem {
|
|
|
901
903
|
}
|
|
902
904
|
logger_1.default.changeRootPath(this.getNewAgentConfigDir());
|
|
903
905
|
logger_1.default.info(texts_1.TXT_AGENT_STANDALONE_STARTED);
|
|
904
|
-
|
|
906
|
+
if (!quiet)
|
|
907
|
+
output_1.default.normal(texts_1.TXT_AGENT_STANDALONE_STARTED);
|
|
908
|
+
manager_1.default.quiet = quiet;
|
|
905
909
|
manager_1.default.start(json.id, json.host, json.token, json.port, () => {
|
|
906
910
|
logger_1.default.info(texts_1.TXT_AGENT_STANDALONE_EXITING);
|
|
907
|
-
|
|
911
|
+
if (!quiet)
|
|
912
|
+
output_1.default.normal(texts_1.TXT_AGENT_STANDALONE_EXITING);
|
|
908
913
|
this.clearStandaloneProcConfig();
|
|
909
|
-
});
|
|
914
|
+
}, onStarted);
|
|
910
915
|
}
|
|
911
916
|
clearStandaloneProcConfig() {
|
|
912
917
|
try {
|
package/distTs/src/api/client.js
CHANGED
|
@@ -305,12 +305,23 @@ class ApiClient {
|
|
|
305
305
|
});
|
|
306
306
|
}
|
|
307
307
|
async updatePipelineYml(workspace, project, pipelineId, body) {
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
308
|
+
try {
|
|
309
|
+
return await this.request({
|
|
310
|
+
method: 'PATCH',
|
|
311
|
+
path: `/workspaces/${encodeURIComponent(workspace)}/projects/${encodeURIComponent(project)}/pipelines/${encodeURIComponent(pipelineId)}/yaml`,
|
|
312
|
+
body,
|
|
313
|
+
parseResponseBody: true,
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
catch (err) {
|
|
317
|
+
// the API's YAML errors can be terse or leak server internals; the
|
|
318
|
+
// local validator explains the same problems
|
|
319
|
+
if (err instanceof cliError_1.default && err.code === 'usage_error' && !err.hint)
|
|
320
|
+
throw new cliError_1.default(err.code, err.message, texts_1.HINT_PIPELINE_YAML_VALIDATE, {
|
|
321
|
+
cause: err,
|
|
322
|
+
});
|
|
323
|
+
throw err;
|
|
324
|
+
}
|
|
314
325
|
}
|
|
315
326
|
async createPipeline(workspace, project, body) {
|
|
316
327
|
return await this.request({
|
|
@@ -928,6 +939,7 @@ class ApiClient {
|
|
|
928
939
|
on_owner_behalf: onOwnerBehalf,
|
|
929
940
|
auto_renew: autoRenew,
|
|
930
941
|
},
|
|
942
|
+
parseResponseBody: true,
|
|
931
943
|
});
|
|
932
944
|
}
|
|
933
945
|
async domainClaim(workspace, name, onOwnerBehalf = false) {
|
|
@@ -938,6 +950,7 @@ class ApiClient {
|
|
|
938
950
|
name,
|
|
939
951
|
on_owner_behalf: onOwnerBehalf,
|
|
940
952
|
},
|
|
953
|
+
parseResponseBody: true,
|
|
941
954
|
});
|
|
942
955
|
}
|
|
943
956
|
async domainSearch(workspace, domains) {
|
|
@@ -1297,7 +1310,7 @@ class ApiClient {
|
|
|
1297
1310
|
// answering for a different scope than asked (TARGET_API_REQUIREMENTS.md
|
|
1298
1311
|
// p6). project_identifier is present whenever the project exists.
|
|
1299
1312
|
if (params.project && !resolved.project_identifier) {
|
|
1300
|
-
throw new cliError_1.default('not_found', texts_1.ERR_PROJECT_NOT_FOUND);
|
|
1313
|
+
throw new cliError_1.default('not_found', texts_1.ERR_PROJECT_NOT_FOUND, texts_1.HINT_PROJECT_LIST);
|
|
1301
1314
|
}
|
|
1302
1315
|
return resolved;
|
|
1303
1316
|
}
|
package/distTs/src/cliCommand.js
CHANGED
|
@@ -40,6 +40,17 @@ const commander_1 = require("commander");
|
|
|
40
40
|
const output_1 = __importDefault(require("./output"));
|
|
41
41
|
const cliError_1 = __importStar(require("./cliError"));
|
|
42
42
|
const texts_1 = require("./texts");
|
|
43
|
+
// No command offers both json and jsonl, so the one it lacks is accepted as a
|
|
44
|
+
// silent alias for the one it has.
|
|
45
|
+
const normalizeFormat = (choices, value) => {
|
|
46
|
+
if (!choices || choices.includes(value))
|
|
47
|
+
return value;
|
|
48
|
+
if (value === 'json' && choices.includes('jsonl'))
|
|
49
|
+
return 'jsonl';
|
|
50
|
+
if (value === 'jsonl' && choices.includes('json'))
|
|
51
|
+
return 'json';
|
|
52
|
+
return value;
|
|
53
|
+
};
|
|
43
54
|
/** Command documentation shared by terminal help and machine discovery. */
|
|
44
55
|
class CliCommand extends commander_1.Command {
|
|
45
56
|
agentStatus;
|
|
@@ -71,6 +82,11 @@ class CliCommand extends commander_1.Command {
|
|
|
71
82
|
if (choices?.every((value) => ['text', 'json', 'jsonl'].includes(value)))
|
|
72
83
|
option.choices(choices);
|
|
73
84
|
}
|
|
85
|
+
const choices = option.argChoices;
|
|
86
|
+
if (option.long === '--format' && choices && option.parseArg) {
|
|
87
|
+
const parse = option.parseArg;
|
|
88
|
+
option.argParser((value, previous) => parse(normalizeFormat(choices, value), previous));
|
|
89
|
+
}
|
|
74
90
|
return super.addOption(option);
|
|
75
91
|
}
|
|
76
92
|
parseOptions(args) {
|
|
@@ -132,7 +148,7 @@ class CliCommand extends commander_1.Command {
|
|
|
132
148
|
if (!(err instanceof commander_1.CommanderError))
|
|
133
149
|
throw err;
|
|
134
150
|
}
|
|
135
|
-
const format = probe.opts().format;
|
|
151
|
+
const format = normalizeFormat(formatOption?.argChoices, probe.opts().format);
|
|
136
152
|
if (formatOption?.argChoices?.includes(format) &&
|
|
137
153
|
(format === 'json' || format === 'jsonl'))
|
|
138
154
|
output_1.default.errorFormat = format;
|
package/distTs/src/cliIndex.js
CHANGED
|
@@ -81,10 +81,20 @@ function cliIndex() {
|
|
|
81
81
|
// the action runs; let Commander report it as an unknown command instead,
|
|
82
82
|
// with the did-you-mean suggestion and the JSON error format
|
|
83
83
|
program.allowExcessArguments();
|
|
84
|
+
// the root has an action, so Commander would check options before commands
|
|
85
|
+
// and `bdy nope --format json` would fail on --format; defer the option
|
|
86
|
+
// check here so an unknown command is reported first
|
|
87
|
+
program.allowUnknownOption();
|
|
84
88
|
program.action(() => {
|
|
85
|
-
|
|
86
|
-
|
|
89
|
+
const root = program;
|
|
90
|
+
const [first] = program.args;
|
|
91
|
+
if (first?.startsWith('-')) {
|
|
92
|
+
// unknownOption is a no-op while unknown options are allowed
|
|
93
|
+
program.allowUnknownOption(false);
|
|
94
|
+
root.unknownOption(first);
|
|
87
95
|
}
|
|
96
|
+
if (first)
|
|
97
|
+
root.unknownCommand();
|
|
88
98
|
program.help();
|
|
89
99
|
});
|
|
90
100
|
return program;
|
|
@@ -6,9 +6,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const utils_1 = require("../../utils");
|
|
7
7
|
const texts_1 = require("../../texts");
|
|
8
8
|
const output_1 = __importDefault(require("../../output"));
|
|
9
|
-
const commandAgentDebug = (0, utils_1.newCommand)('debug', texts_1.DESC_COMMAND_AGENT_DEBUG);
|
|
9
|
+
const commandAgentDebug = (0, utils_1.newCommand)('debug', texts_1.DESC_COMMAND_AGENT_DEBUG, { requiredScopes: [] });
|
|
10
10
|
commandAgentDebug.argument('<on/off>');
|
|
11
|
-
commandAgentDebug.
|
|
11
|
+
commandAgentDebug.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
12
|
+
commandAgentDebug.action(async (debug, options) => {
|
|
12
13
|
const AgentManager = require('../../agent/manager').default;
|
|
13
14
|
const ApiAgent = require('../../tunnel/api/agent').default;
|
|
14
15
|
const hasRights = await AgentManager.system.hasRightsToManage();
|
|
@@ -27,7 +28,7 @@ commandAgentDebug.action(async (debug) => {
|
|
|
27
28
|
const api = new ApiAgent(json.port);
|
|
28
29
|
await api.debugChange(debugOn);
|
|
29
30
|
AgentManager.system.saveSystemConfig(json.id, json.host, json.token, json.port, !!json.standalone, debugOn);
|
|
30
|
-
output_1.default.
|
|
31
|
+
output_1.default.exitResult(options.format === 'json', { debug: debugOn }, debugOn ? texts_1.TXT_AGENT_DEBUG_ON : texts_1.TXT_AGENT_DEBUG_OFF);
|
|
31
32
|
}
|
|
32
33
|
catch (err) {
|
|
33
34
|
output_1.default.exitError(err);
|
|
@@ -6,8 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const utils_1 = require("../../utils");
|
|
7
7
|
const texts_1 = require("../../texts");
|
|
8
8
|
const output_1 = __importDefault(require("../../output"));
|
|
9
|
-
const commandAgentDisable = (0, utils_1.newCommand)('disable', texts_1.DESC_COMMAND_AGENT_DISABLE);
|
|
10
|
-
commandAgentDisable.
|
|
9
|
+
const commandAgentDisable = (0, utils_1.newCommand)('disable', texts_1.DESC_COMMAND_AGENT_DISABLE, { requiredScopes: [] });
|
|
10
|
+
commandAgentDisable.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
11
|
+
commandAgentDisable.action(async (options) => {
|
|
11
12
|
const ApiAgent = require('../../tunnel/api/agent').default;
|
|
12
13
|
if (!commandAgentDisable.agentInstalled) {
|
|
13
14
|
output_1.default.exitError(texts_1.ERR_AGENT_NOT_INSTALLED);
|
|
@@ -18,7 +19,7 @@ commandAgentDisable.action(async () => {
|
|
|
18
19
|
try {
|
|
19
20
|
const api = new ApiAgent(commandAgentDisable.agentPort || 0);
|
|
20
21
|
await api.disableAgent();
|
|
21
|
-
output_1.default.
|
|
22
|
+
output_1.default.exitResult(options.format === 'json', { enabled: false }, texts_1.TXT_AGENT_STOPPED);
|
|
22
23
|
}
|
|
23
24
|
catch (err) {
|
|
24
25
|
output_1.default.exitError(err);
|
|
@@ -6,8 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const utils_1 = require("../../utils");
|
|
7
7
|
const texts_1 = require("../../texts");
|
|
8
8
|
const output_1 = __importDefault(require("../../output"));
|
|
9
|
-
const commandAgentEnable = (0, utils_1.newCommand)('enable', texts_1.DESC_COMMAND_AGENT_ENABLE);
|
|
10
|
-
commandAgentEnable.
|
|
9
|
+
const commandAgentEnable = (0, utils_1.newCommand)('enable', texts_1.DESC_COMMAND_AGENT_ENABLE, { requiredScopes: [] });
|
|
10
|
+
commandAgentEnable.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
11
|
+
commandAgentEnable.action(async (options) => {
|
|
11
12
|
const ApiAgent = require('../../tunnel/api/agent').default;
|
|
12
13
|
if (!commandAgentEnable.agentInstalled) {
|
|
13
14
|
output_1.default.exitError(texts_1.ERR_AGENT_NOT_INSTALLED);
|
|
@@ -18,7 +19,7 @@ commandAgentEnable.action(async () => {
|
|
|
18
19
|
try {
|
|
19
20
|
const api = new ApiAgent(commandAgentEnable.agentPort || 0);
|
|
20
21
|
await api.enableAgent();
|
|
21
|
-
output_1.default.
|
|
22
|
+
output_1.default.exitResult(options.format === 'json', { enabled: true }, texts_1.TXT_AGENT_STARTED);
|
|
22
23
|
}
|
|
23
24
|
catch (err) {
|
|
24
25
|
output_1.default.exitError(err);
|
|
@@ -52,6 +52,13 @@ const isPortFree = (port) => new Promise((resolve) => {
|
|
|
52
52
|
srv.close(() => resolve(true));
|
|
53
53
|
});
|
|
54
54
|
});
|
|
55
|
+
// --format json result: the installed agent's identity, never its token
|
|
56
|
+
const installedResult = (options, id, port, standalone) => ({
|
|
57
|
+
id,
|
|
58
|
+
port,
|
|
59
|
+
standalone,
|
|
60
|
+
started: !!options.start,
|
|
61
|
+
});
|
|
55
62
|
const prepareTags = (tags) => {
|
|
56
63
|
const validTags = [];
|
|
57
64
|
if (tags) {
|
|
@@ -126,7 +133,8 @@ const installService = async (options) => {
|
|
|
126
133
|
catch {
|
|
127
134
|
// do nothing
|
|
128
135
|
}
|
|
129
|
-
|
|
136
|
+
if (options.format !== 'json')
|
|
137
|
+
await output_1.default.spinner(texts_1.TXT_ENABLING_AGENT);
|
|
130
138
|
try {
|
|
131
139
|
await AgentManager.system.install(id, host, agentToken, port, !!options.start, options.user, options.pass);
|
|
132
140
|
}
|
|
@@ -138,7 +146,7 @@ const installService = async (options) => {
|
|
|
138
146
|
await waitUntilAgentEnabled(api, 15000, () => {
|
|
139
147
|
removeAllAndExit(texts_1.ERR_SWW_AGENT_ENABLING, id, host, agentToken);
|
|
140
148
|
}, () => {
|
|
141
|
-
output_1.default.
|
|
149
|
+
output_1.default.exitResult(options.format === 'json', installedResult(options, id, port, false), texts_1.TXT_AGENT_INSTALLED);
|
|
142
150
|
});
|
|
143
151
|
}
|
|
144
152
|
else {
|
|
@@ -148,7 +156,7 @@ const installService = async (options) => {
|
|
|
148
156
|
catch {
|
|
149
157
|
// do nothing
|
|
150
158
|
}
|
|
151
|
-
output_1.default.
|
|
159
|
+
output_1.default.exitResult(options.format === 'json', installedResult(options, id, port, false), texts_1.TXT_AGENT_INSTALLED);
|
|
152
160
|
}
|
|
153
161
|
};
|
|
154
162
|
const installApp = async (options) => {
|
|
@@ -167,12 +175,13 @@ const installApp = async (options) => {
|
|
|
167
175
|
addToken = '';
|
|
168
176
|
}
|
|
169
177
|
const { token, host } = await input_1.default.tunnelToken(addToken);
|
|
178
|
+
const say = output_1.default.progress(options.format === 'json');
|
|
170
179
|
if (!id) {
|
|
171
180
|
const tags = prepareTags(options.tag);
|
|
172
181
|
const note = options.note;
|
|
173
182
|
const agentNote = options.agentNote;
|
|
174
183
|
try {
|
|
175
|
-
|
|
184
|
+
say(texts_1.TXT_AGENT_STANDALONE_AGENT_REGISTERING, false);
|
|
176
185
|
const agent = await ApiBuddy.register(true, !!options.target, !!options.tunnels, !!options.proxy, host, token, tags, (0, utils_1.getCurrentUser)(), {
|
|
177
186
|
note,
|
|
178
187
|
agentNote,
|
|
@@ -180,14 +189,14 @@ const installApp = async (options) => {
|
|
|
180
189
|
cfg_1.default.setRegionIfNotSet(region);
|
|
181
190
|
});
|
|
182
191
|
logger_1.default.info(texts_1.TXT_AGENT_STANDALONE_AGENT_REGISTERED);
|
|
183
|
-
|
|
192
|
+
say(texts_1.TXT_AGENT_STANDALONE_AGENT_REGISTERED);
|
|
184
193
|
id = agent.id;
|
|
185
194
|
agentToken = agent.token;
|
|
186
195
|
agent.destroy();
|
|
187
196
|
}
|
|
188
197
|
catch (err) {
|
|
189
198
|
logger_1.default.info(texts_1.TXT_AGENT_STANDALONE_AGENT_REGISTER_ERROR);
|
|
190
|
-
|
|
199
|
+
say(texts_1.TXT_AGENT_STANDALONE_AGENT_REGISTER_ERROR);
|
|
191
200
|
logger_1.default.error(err);
|
|
192
201
|
output_1.default.exitError(err);
|
|
193
202
|
}
|
|
@@ -195,15 +204,15 @@ const installApp = async (options) => {
|
|
|
195
204
|
else {
|
|
196
205
|
try {
|
|
197
206
|
logger_1.default.info(texts_1.TXT_AGENT_STANDALONE_AGENT_FETCHING);
|
|
198
|
-
|
|
207
|
+
say(texts_1.TXT_AGENT_STANDALONE_AGENT_FETCHING, false);
|
|
199
208
|
const agent = await ApiBuddy.fetchAgent(id, host, agentToken);
|
|
200
209
|
agent.destroy();
|
|
201
210
|
logger_1.default.info(texts_1.TXT_AGENT_STANDALONE_AGENT_FETCHED);
|
|
202
|
-
|
|
211
|
+
say(texts_1.TXT_AGENT_STANDALONE_AGENT_FETCHED);
|
|
203
212
|
}
|
|
204
213
|
catch (err) {
|
|
205
214
|
logger_1.default.info(texts_1.TXT_AGENT_STANDALONE_AGENT_FETCH_ERROR);
|
|
206
|
-
|
|
215
|
+
say(texts_1.TXT_AGENT_STANDALONE_AGENT_FETCH_ERROR);
|
|
207
216
|
logger_1.default.error(err);
|
|
208
217
|
output_1.default.exitError(err);
|
|
209
218
|
}
|
|
@@ -213,7 +222,13 @@ const installApp = async (options) => {
|
|
|
213
222
|
output_1.default.exitError(texts_1.ERR_SWW_AGENT_ENABLING);
|
|
214
223
|
}
|
|
215
224
|
if (options.start) {
|
|
216
|
-
|
|
225
|
+
// the standalone agent keeps running in this process: the result is
|
|
226
|
+
// printed once it is fetched and started, so a failure is the only output
|
|
227
|
+
const json = options.format === 'json';
|
|
228
|
+
AgentManager.system.startStandaloneProc(json, () => {
|
|
229
|
+
if (json)
|
|
230
|
+
output_1.default.json(installedResult(options, id, port, true));
|
|
231
|
+
});
|
|
217
232
|
}
|
|
218
233
|
else {
|
|
219
234
|
try {
|
|
@@ -222,10 +237,10 @@ const installApp = async (options) => {
|
|
|
222
237
|
catch {
|
|
223
238
|
// do nothing
|
|
224
239
|
}
|
|
225
|
-
output_1.default.
|
|
240
|
+
output_1.default.exitResult(options.format === 'json', installedResult(options, id, port, true), texts_1.TXT_AGENT_INSTALLED);
|
|
226
241
|
}
|
|
227
242
|
};
|
|
228
|
-
const commandAgentInstall = (0, utils_1.newCommand)('install', texts_1.DESC_COMMAND_AGENT_INSTALL);
|
|
243
|
+
const commandAgentInstall = (0, utils_1.newCommand)('install', texts_1.DESC_COMMAND_AGENT_INSTALL, { requiredScopes: [] });
|
|
229
244
|
commandAgentInstall.option('-s, --start [true|false]', texts_1.OPTION_AGENT_START, 'true');
|
|
230
245
|
commandAgentInstall.option('-i, --id <id>', texts_1.OPTION_AGENT_ID);
|
|
231
246
|
commandAgentInstall.option('-t, --token <token>', texts_1.OPTION_AGENT_TOKEN);
|
|
@@ -240,6 +255,7 @@ commandAgentInstall.option('--tag <tag...>', texts_1.OPTION_AGENT_TAG);
|
|
|
240
255
|
commandAgentInstall.option('-d, --debug', texts_1.OPTION_AGENT_DEBUG);
|
|
241
256
|
commandAgentInstall.option('--note <note>', texts_1.OPT_COMMAND_NOTE);
|
|
242
257
|
commandAgentInstall.option('--agent-note <note>', texts_1.OPT_COMMAND_AGENT_NOTE);
|
|
258
|
+
commandAgentInstall.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
243
259
|
commandAgentInstall.action(async (options) => {
|
|
244
260
|
const AgentManager = require('../../agent/manager').default;
|
|
245
261
|
options.start = options.start === 'true' || options.start === true;
|
|
@@ -6,8 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const utils_1 = require("../../../utils");
|
|
7
7
|
const texts_1 = require("../../../texts");
|
|
8
8
|
const output_1 = __importDefault(require("../../../output"));
|
|
9
|
-
const commandAgentProxyDisable = (0, utils_1.newCommand)('disable', texts_1.DESC_COMMAND_AGENT_PROXY_DISABLE);
|
|
10
|
-
commandAgentProxyDisable.
|
|
9
|
+
const commandAgentProxyDisable = (0, utils_1.newCommand)('disable', texts_1.DESC_COMMAND_AGENT_PROXY_DISABLE, { requiredScopes: [] });
|
|
10
|
+
commandAgentProxyDisable.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
11
|
+
commandAgentProxyDisable.action(async (options) => {
|
|
11
12
|
const ApiAgent = require('../../../tunnel/api/agent').default;
|
|
12
13
|
if (!commandAgentProxyDisable.agentInstalled) {
|
|
13
14
|
output_1.default.exitError(texts_1.ERR_AGENT_NOT_INSTALLED);
|
|
@@ -18,7 +19,7 @@ commandAgentProxyDisable.action(async () => {
|
|
|
18
19
|
try {
|
|
19
20
|
const api = new ApiAgent(commandAgentProxyDisable.agentPort || 0);
|
|
20
21
|
await api.disableAgentProxy();
|
|
21
|
-
output_1.default.
|
|
22
|
+
output_1.default.exitResult(options.format === 'json', { proxy: false }, texts_1.TXT_AGENT_PROXY_DISABLED);
|
|
22
23
|
}
|
|
23
24
|
catch (err) {
|
|
24
25
|
output_1.default.exitError(err);
|
|
@@ -6,8 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const utils_1 = require("../../../utils");
|
|
7
7
|
const texts_1 = require("../../../texts");
|
|
8
8
|
const output_1 = __importDefault(require("../../../output"));
|
|
9
|
-
const commandAgentProxyEnable = (0, utils_1.newCommand)('enable', texts_1.DESC_COMMAND_AGENT_PROXY_ENABLE);
|
|
10
|
-
commandAgentProxyEnable.
|
|
9
|
+
const commandAgentProxyEnable = (0, utils_1.newCommand)('enable', texts_1.DESC_COMMAND_AGENT_PROXY_ENABLE, { requiredScopes: [] });
|
|
10
|
+
commandAgentProxyEnable.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
11
|
+
commandAgentProxyEnable.action(async (options) => {
|
|
11
12
|
const ApiAgent = require('../../../tunnel/api/agent').default;
|
|
12
13
|
if (!commandAgentProxyEnable.agentInstalled) {
|
|
13
14
|
output_1.default.exitError(texts_1.ERR_AGENT_NOT_INSTALLED);
|
|
@@ -18,7 +19,7 @@ commandAgentProxyEnable.action(async () => {
|
|
|
18
19
|
try {
|
|
19
20
|
const api = new ApiAgent(commandAgentProxyEnable.agentPort || 0);
|
|
20
21
|
await api.enableAgentProxy();
|
|
21
|
-
output_1.default.
|
|
22
|
+
output_1.default.exitResult(options.format === 'json', { proxy: true }, texts_1.TXT_AGENT_PROXY_ENABLED);
|
|
22
23
|
}
|
|
23
24
|
catch (err) {
|
|
24
25
|
output_1.default.exitError(err);
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const utils_1 = require("../../../utils");
|
|
7
7
|
const texts_1 = require("../../../texts");
|
|
8
8
|
const output_1 = __importDefault(require("../../../output"));
|
|
9
|
-
const commandAgentProxyStatus = (0, utils_1.newCommand)('status', texts_1.DESC_COMMAND_AGENT_PROXY_STATUS, { examples: texts_1.EXAMPLE_AGENT_PROXY_STATUS });
|
|
9
|
+
const commandAgentProxyStatus = (0, utils_1.newCommand)('status', texts_1.DESC_COMMAND_AGENT_PROXY_STATUS, { requiredScopes: [], examples: texts_1.EXAMPLE_AGENT_PROXY_STATUS });
|
|
10
10
|
commandAgentProxyStatus.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
11
11
|
commandAgentProxyStatus.action(async (options) => {
|
|
12
12
|
const ApiAgent = require('../../../tunnel/api/agent').default;
|
|
@@ -7,8 +7,10 @@ const output_1 = __importDefault(require("../../output"));
|
|
|
7
7
|
const texts_1 = require("../../texts");
|
|
8
8
|
const utils_1 = require("../../utils");
|
|
9
9
|
const logger_1 = __importDefault(require("../../logger"));
|
|
10
|
-
const commandAgentRestart = (0, utils_1.newCommand)('restart', texts_1.DESC_COMMAND_AGENT_RESTART);
|
|
11
|
-
commandAgentRestart.
|
|
10
|
+
const commandAgentRestart = (0, utils_1.newCommand)('restart', texts_1.DESC_COMMAND_AGENT_RESTART, { requiredScopes: [] });
|
|
11
|
+
commandAgentRestart.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
12
|
+
commandAgentRestart.action(async (options) => {
|
|
13
|
+
const json = options.format === 'json';
|
|
12
14
|
const AgentManager = require('../../agent/manager').default;
|
|
13
15
|
const hasRights = await AgentManager.system.hasRightsToManage();
|
|
14
16
|
if (!hasRights) {
|
|
@@ -19,14 +21,20 @@ commandAgentRestart.action(async () => {
|
|
|
19
21
|
}
|
|
20
22
|
if (commandAgentRestart.agentStandalone) {
|
|
21
23
|
await AgentManager.system.killStandaloneProc();
|
|
22
|
-
|
|
24
|
+
// the standalone agent keeps running in this process: the result is
|
|
25
|
+
// printed once it is fetched and started, so a failure is the only output
|
|
26
|
+
AgentManager.system.startStandaloneProc(json, () => {
|
|
27
|
+
if (json)
|
|
28
|
+
output_1.default.json({ running: true });
|
|
29
|
+
});
|
|
23
30
|
}
|
|
24
31
|
else {
|
|
25
32
|
try {
|
|
26
33
|
await AgentManager.system.stop();
|
|
27
|
-
|
|
34
|
+
if (!json)
|
|
35
|
+
output_1.default.normal(texts_1.TXT_AGENT_STOPPED);
|
|
28
36
|
await AgentManager.system.start();
|
|
29
|
-
output_1.default.
|
|
37
|
+
output_1.default.exitResult(json, { running: true }, texts_1.TXT_AGENT_RESTARTED);
|
|
30
38
|
}
|
|
31
39
|
catch (err) {
|
|
32
40
|
logger_1.default.error(err);
|
|
@@ -6,8 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const output_1 = __importDefault(require("../../output"));
|
|
7
7
|
const texts_1 = require("../../texts");
|
|
8
8
|
const utils_1 = require("../../utils");
|
|
9
|
-
const commandAgentStart = (0, utils_1.newCommand)('start', texts_1.DESC_COMMAND_AGENT_START);
|
|
10
|
-
commandAgentStart.
|
|
9
|
+
const commandAgentStart = (0, utils_1.newCommand)('start', texts_1.DESC_COMMAND_AGENT_START, { requiredScopes: [] });
|
|
10
|
+
commandAgentStart.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
11
|
+
commandAgentStart.action(async (options) => {
|
|
11
12
|
const AgentManager = require('../../agent/manager').default;
|
|
12
13
|
const logger = require('../../logger').default;
|
|
13
14
|
const hasRights = await AgentManager.system.hasRightsToManage();
|
|
@@ -19,12 +20,18 @@ commandAgentStart.action(async () => {
|
|
|
19
20
|
}
|
|
20
21
|
if (commandAgentStart.agentStandalone) {
|
|
21
22
|
await AgentManager.system.killStandaloneProc();
|
|
22
|
-
|
|
23
|
+
// the standalone agent keeps running in this process: the result is
|
|
24
|
+
// printed once it is fetched and started, so a failure is the only output
|
|
25
|
+
const json = options.format === 'json';
|
|
26
|
+
AgentManager.system.startStandaloneProc(json, () => {
|
|
27
|
+
if (json)
|
|
28
|
+
output_1.default.json({ running: true });
|
|
29
|
+
});
|
|
23
30
|
}
|
|
24
31
|
else {
|
|
25
32
|
try {
|
|
26
33
|
await AgentManager.system.start();
|
|
27
|
-
output_1.default.
|
|
34
|
+
output_1.default.exitResult(options.format === 'json', { running: true }, texts_1.TXT_AGENT_STARTED);
|
|
28
35
|
}
|
|
29
36
|
catch (err) {
|
|
30
37
|
logger.error(err);
|
|
@@ -8,7 +8,7 @@ const node_fs_1 = require("node:fs");
|
|
|
8
8
|
const texts_1 = require("../../texts");
|
|
9
9
|
const utils_1 = require("../../utils");
|
|
10
10
|
const tunnel_1 = require("../../types/tunnel");
|
|
11
|
-
const commandAgentStatus = (0, utils_1.newCommand)('status', texts_1.DESC_COMMAND_AGENT_STATUS, { examples: texts_1.EXAMPLE_AGENT_STATUS, helpText: texts_1.HELP_AGENT_STATUS_JSON });
|
|
11
|
+
const commandAgentStatus = (0, utils_1.newCommand)('status', texts_1.DESC_COMMAND_AGENT_STATUS, { requiredScopes: [], examples: texts_1.EXAMPLE_AGENT_STATUS, helpText: texts_1.HELP_AGENT_STATUS_JSON });
|
|
12
12
|
const outputStatus = (installed, standalone, version, id, running, enabled, target, tunneling, proxy, status, json) => {
|
|
13
13
|
const AgentManager = require('../../agent/manager').default;
|
|
14
14
|
if (!installed) {
|
|
@@ -7,8 +7,9 @@ const utils_1 = require("../../utils");
|
|
|
7
7
|
const texts_1 = require("../../texts");
|
|
8
8
|
const output_1 = __importDefault(require("../../output"));
|
|
9
9
|
const logger_1 = __importDefault(require("../../logger"));
|
|
10
|
-
const commandAgentStop = (0, utils_1.newCommand)('stop', texts_1.DESC_COMMAND_AGENT_STOP);
|
|
11
|
-
commandAgentStop.
|
|
10
|
+
const commandAgentStop = (0, utils_1.newCommand)('stop', texts_1.DESC_COMMAND_AGENT_STOP, { requiredScopes: [] });
|
|
11
|
+
commandAgentStop.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
12
|
+
commandAgentStop.action(async (options) => {
|
|
12
13
|
const AgentManager = require('../../agent/manager').default;
|
|
13
14
|
const ApiAgent = require('../../tunnel/api/agent').default;
|
|
14
15
|
const hasRights = await AgentManager.system.hasRightsToManage();
|
|
@@ -27,12 +28,12 @@ commandAgentStop.action(async () => {
|
|
|
27
28
|
}
|
|
28
29
|
if (commandAgentStop.agentStandalone) {
|
|
29
30
|
await AgentManager.system.killStandaloneProc();
|
|
30
|
-
output_1.default.
|
|
31
|
+
output_1.default.exitResult(options.format === 'json', { running: false }, texts_1.TXT_AGENT_STOPPED);
|
|
31
32
|
}
|
|
32
33
|
else {
|
|
33
34
|
try {
|
|
34
35
|
await AgentManager.system.stop();
|
|
35
|
-
output_1.default.
|
|
36
|
+
output_1.default.exitResult(options.format === 'json', { running: false }, texts_1.TXT_AGENT_STOPPED);
|
|
36
37
|
}
|
|
37
38
|
catch (err) {
|
|
38
39
|
logger_1.default.error(err);
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const utils_1 = require("../../../utils");
|
|
7
7
|
const texts_1 = require("../../../texts");
|
|
8
8
|
const output_1 = __importDefault(require("../../../output"));
|
|
9
|
-
const commandAgentTagsGet = (0, utils_1.newCommand)('get', texts_1.DESC_COMMAND_AGENT_TAGS_GET, { examples: texts_1.EXAMPLE_AGENT_TAGS_GET });
|
|
9
|
+
const commandAgentTagsGet = (0, utils_1.newCommand)('get', texts_1.DESC_COMMAND_AGENT_TAGS_GET, { requiredScopes: [], examples: texts_1.EXAMPLE_AGENT_TAGS_GET });
|
|
10
10
|
commandAgentTagsGet.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
11
11
|
commandAgentTagsGet.action(async (options) => {
|
|
12
12
|
const ApiAgent = require('../../../tunnel/api/agent').default;
|
|
@@ -6,9 +6,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const utils_1 = require("../../../utils");
|
|
7
7
|
const texts_1 = require("../../../texts");
|
|
8
8
|
const output_1 = __importDefault(require("../../../output"));
|
|
9
|
-
const commandAgentTagsSet = (0, utils_1.newCommand)('set', texts_1.DESC_COMMAND_AGENT_TAGS_SET);
|
|
9
|
+
const commandAgentTagsSet = (0, utils_1.newCommand)('set', texts_1.DESC_COMMAND_AGENT_TAGS_SET, { requiredScopes: [] });
|
|
10
10
|
commandAgentTagsSet.argument('[tags...]', texts_1.OPT_COMMAND_AGENT_TAGS_SET);
|
|
11
|
-
commandAgentTagsSet.
|
|
11
|
+
commandAgentTagsSet.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
12
|
+
commandAgentTagsSet.action(async (tags, options) => {
|
|
12
13
|
const ApiAgent = require('../../../tunnel/api/agent').default;
|
|
13
14
|
if (!commandAgentTagsSet.agentInstalled) {
|
|
14
15
|
output_1.default.exitError(texts_1.ERR_AGENT_NOT_INSTALLED);
|
|
@@ -29,7 +30,7 @@ commandAgentTagsSet.action(async (tags) => {
|
|
|
29
30
|
try {
|
|
30
31
|
const api = new ApiAgent(commandAgentTagsSet.agentPort || 0);
|
|
31
32
|
await api.setAgentTags(validTags);
|
|
32
|
-
output_1.default.
|
|
33
|
+
output_1.default.exitResult(options.format === 'json', { tags: validTags }, texts_1.TXT_AGENT_TAGS_SET);
|
|
33
34
|
}
|
|
34
35
|
catch (err) {
|
|
35
36
|
output_1.default.exitError(err);
|
|
@@ -6,8 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const utils_1 = require("../../../utils");
|
|
7
7
|
const texts_1 = require("../../../texts");
|
|
8
8
|
const output_1 = __importDefault(require("../../../output"));
|
|
9
|
-
const commandAgentTargetDisable = (0, utils_1.newCommand)('disable', texts_1.DESC_COMMAND_AGENT_TARGET_DISABLE);
|
|
10
|
-
commandAgentTargetDisable.
|
|
9
|
+
const commandAgentTargetDisable = (0, utils_1.newCommand)('disable', texts_1.DESC_COMMAND_AGENT_TARGET_DISABLE, { requiredScopes: [] });
|
|
10
|
+
commandAgentTargetDisable.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
11
|
+
commandAgentTargetDisable.action(async (options) => {
|
|
11
12
|
const ApiAgent = require('../../../tunnel/api/agent').default;
|
|
12
13
|
if (!commandAgentTargetDisable.agentInstalled) {
|
|
13
14
|
output_1.default.exitError(texts_1.ERR_AGENT_NOT_INSTALLED);
|
|
@@ -18,7 +19,7 @@ commandAgentTargetDisable.action(async () => {
|
|
|
18
19
|
try {
|
|
19
20
|
const api = new ApiAgent(commandAgentTargetDisable.agentPort || 0);
|
|
20
21
|
await api.disableAgentTarget();
|
|
21
|
-
output_1.default.
|
|
22
|
+
output_1.default.exitResult(options.format === 'json', { target: false }, texts_1.TXT_AGENT_TARGET_DISABLED);
|
|
22
23
|
}
|
|
23
24
|
catch (err) {
|
|
24
25
|
output_1.default.exitError(err);
|