bdy 1.25.2-stage → 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 +20 -19
- package/distTs/src/agent/socket/tunnel.js +2 -0
- package/distTs/src/cliCommand.js +28 -0
- package/distTs/src/cliIndex.js +3 -1
- 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/http.js +4 -3
- package/distTs/src/command/agent/tunnel/list.js +7 -3
- package/distTs/src/command/agent/tunnel/remove.js +1 -2
- package/distTs/src/command/agent/tunnel/start.js +1 -2
- package/distTs/src/command/agent/tunnel/status.js +14 -3
- package/distTs/src/command/agent/tunnel/tcp.js +4 -3
- package/distTs/src/command/agent/tunnel/tls.js +4 -3
- package/distTs/src/command/agent/tunnel.js +11 -8
- 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/composer/publish.js +4 -2
- package/distTs/src/command/artifact/create.js +9 -2
- package/distTs/src/command/artifact/delete.js +4 -2
- package/distTs/src/command/artifact/docker.js +1 -1
- package/distTs/src/command/artifact/download.js +4 -2
- package/distTs/src/command/artifact/get.js +3 -1
- package/distTs/src/command/artifact/list.js +3 -1
- package/distTs/src/command/artifact/publish.js +24 -24
- package/distTs/src/command/artifact/version/create.js +9 -2
- package/distTs/src/command/artifact/version/delete.js +4 -2
- package/distTs/src/command/artifact/version/get.js +4 -2
- package/distTs/src/command/artifact/version/list.js +4 -2
- package/distTs/src/command/config/get/tunnel.js +8 -3
- package/distTs/src/command/config/get/tunnels.js +8 -3
- package/distTs/src/command/crawl/link.js +3 -2
- package/distTs/src/command/crawl/run.js +3 -2
- package/distTs/src/command/crawl.js +3 -4
- package/distTs/src/command/discover.js +34 -0
- package/distTs/src/command/distro/create.js +9 -2
- package/distTs/src/command/distro/delete.js +4 -2
- package/distTs/src/command/distro/get.js +4 -2
- package/distTs/src/command/distro/list.js +4 -2
- package/distTs/src/command/distro/route/create.js +9 -2
- package/distTs/src/command/distro/route/delete.js +4 -2
- package/distTs/src/command/distro/route/get.js +4 -2
- package/distTs/src/command/distro/route/list.js +4 -2
- package/distTs/src/command/distro/route/update.js +9 -2
- package/distTs/src/command/distro/route.js +9 -6
- package/distTs/src/command/distro/update.js +9 -2
- package/distTs/src/command/distro.js +14 -11
- package/distTs/src/command/domain/search.js +31 -10
- package/distTs/src/command/environment/create.js +6 -2
- package/distTs/src/command/environment/delete.js +1 -2
- package/distTs/src/command/environment/get.js +3 -2
- package/distTs/src/command/environment/list.js +1 -2
- package/distTs/src/command/environment/update.js +6 -2
- package/distTs/src/command/mcp.js +3 -2
- package/distTs/src/command/pipeline/create.js +4 -2
- package/distTs/src/command/pipeline/delete.js +4 -2
- package/distTs/src/command/pipeline/get.js +4 -2
- package/distTs/src/command/pipeline/list.js +4 -2
- package/distTs/src/command/pipeline/run/approve.js +5 -3
- package/distTs/src/command/pipeline/run/cancel.js +5 -3
- package/distTs/src/command/pipeline/run/list.js +4 -2
- package/distTs/src/command/pipeline/run/logs.js +5 -3
- package/distTs/src/command/pipeline/run/retry.js +5 -3
- package/distTs/src/command/pipeline/run/start.js +5 -3
- package/distTs/src/command/pipeline/run/status.js +5 -3
- package/distTs/src/command/pipeline/run.js +11 -9
- package/distTs/src/command/pipeline/update.js +4 -2
- package/distTs/src/command/pipeline/yaml.js +4 -2
- package/distTs/src/command/pipeline.js +17 -15
- package/distTs/src/command/pre.js +2 -1
- package/distTs/src/command/sandbox/app/add.js +10 -3
- package/distTs/src/command/sandbox/app/list.js +1 -2
- package/distTs/src/command/sandbox/app/logs.js +10 -6
- package/distTs/src/command/sandbox/app/remove.js +1 -2
- package/distTs/src/command/sandbox/app/start.js +1 -2
- package/distTs/src/command/sandbox/app/status.js +1 -2
- package/distTs/src/command/sandbox/app/stop.js +1 -2
- package/distTs/src/command/sandbox/app.js +11 -9
- package/distTs/src/command/sandbox/cp.js +3 -2
- package/distTs/src/command/sandbox/create.js +16 -7
- package/distTs/src/command/sandbox/endpoint/add.js +6 -2
- package/distTs/src/command/sandbox/endpoint/delete.js +1 -2
- package/distTs/src/command/sandbox/endpoint/get.js +1 -2
- package/distTs/src/command/sandbox/endpoint/list.js +1 -2
- package/distTs/src/command/sandbox/endpoint.js +8 -5
- package/distTs/src/command/sandbox/exec/command.js +15 -31
- package/distTs/src/command/sandbox/exec/kill.js +1 -2
- package/distTs/src/command/sandbox/exec/list.js +1 -2
- package/distTs/src/command/sandbox/exec/logs.js +4 -30
- package/distTs/src/command/sandbox/exec/status.js +1 -2
- package/distTs/src/command/sandbox/exec.js +9 -6
- 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 +10 -3
- package/distTs/src/command/sandbox/snapshot/delete.js +1 -2
- package/distTs/src/command/sandbox/snapshot/get.js +1 -2
- package/distTs/src/command/sandbox/snapshot/list.js +1 -2
- package/distTs/src/command/sandbox/snapshot.js +8 -5
- package/distTs/src/command/sandbox/ssh.js +3 -2
- package/distTs/src/command/target/create.js +8 -2
- package/distTs/src/command/target/delete.js +3 -2
- package/distTs/src/command/target/exec/command.js +1 -2
- package/distTs/src/command/target/exec/kill.js +1 -2
- package/distTs/src/command/target/exec/list.js +1 -2
- package/distTs/src/command/target/exec/logs.js +15 -3
- package/distTs/src/command/target/exec/status.js +1 -2
- package/distTs/src/command/target/exec.js +9 -6
- package/distTs/src/command/target/get.js +3 -2
- package/distTs/src/command/target/list.js +3 -2
- package/distTs/src/command/target/update.js +8 -2
- package/distTs/src/command/tests/capture.js +3 -2
- package/distTs/src/command/tests/unit/link.js +3 -2
- package/distTs/src/command/tests/unit/upload.js +3 -2
- package/distTs/src/command/tests/unit.js +3 -4
- package/distTs/src/command/tests/visual/link.js +3 -2
- package/distTs/src/command/tests/visual/session/close.js +3 -2
- package/distTs/src/command/tests/visual/session/create.js +3 -2
- package/distTs/src/command/tests/visual/session.js +6 -4
- package/distTs/src/command/tests/visual/setup.js +3 -2
- package/distTs/src/command/tests/visual/upload.js +3 -2
- package/distTs/src/command/tests/visual.js +9 -7
- package/distTs/src/command/tests.js +12 -10
- package/distTs/src/command/tunnel/http.js +3 -2
- package/distTs/src/command/tunnel/start.js +3 -2
- package/distTs/src/command/tunnel/tcp.js +1 -2
- package/distTs/src/command/tunnel/tls.js +1 -2
- package/distTs/src/command/tunnel.js +8 -5
- package/distTs/src/command/version.js +2 -1
- package/distTs/src/command/yaml/actions/info.js +1 -2
- package/distTs/src/command/yaml/actions/list.js +1 -2
- package/distTs/src/command/yaml/actions.js +3 -4
- package/distTs/src/command/yaml/pipeline.js +3 -2
- package/distTs/src/command/yaml/validate.js +114 -54
- package/distTs/src/command/yaml.js +8 -6
- package/distTs/src/discovery.js +119 -0
- package/distTs/src/openapi.js +8 -1
- package/distTs/src/output.js +39 -0
- package/distTs/src/texts.js +1570 -736
- package/distTs/src/utils.js +46 -17
- package/package.json +20 -19
package/distTs/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bdy",
|
|
3
3
|
"preferGlobal": false,
|
|
4
|
-
"version": "1.25.
|
|
4
|
+
"version": "1.25.4-dev",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://buddy.works/docs/cli",
|
|
@@ -13,24 +13,25 @@
|
|
|
13
13
|
"lint:types": "tsc --skipLibCheck --noEmit --project tsconfig.json && tsc --skipLibCheck --project test/tsconfig.json && tsc --skipLibCheck --project e2e/tsconfig.json",
|
|
14
14
|
"watch": "tsc --watch --project tsconfig.json & tsc --watch --project src/visualTest/utils/tsconfig.json",
|
|
15
15
|
"buildTs": "(tsc --project tsconfig.json & tsc --project src/visualTest/utils/tsconfig.json & wait) && cp package.json distTs/package.json && cp detect-rules.json distTs/detect-rules.json && curl -fsSL https://raw.githubusercontent.com/buddy/cli/main/README.md -o README.md",
|
|
16
|
-
"e2e": "npm run buildTs && vitest run --config e2e/vitest.config.
|
|
17
|
-
"e2e:version": "vitest run --config e2e/vitest.config.
|
|
18
|
-
"e2e:
|
|
19
|
-
"e2e:
|
|
20
|
-
"e2e:
|
|
21
|
-
"e2e:
|
|
22
|
-
"e2e:
|
|
23
|
-
"e2e:
|
|
24
|
-
"e2e:
|
|
25
|
-
"e2e:
|
|
26
|
-
"e2e:
|
|
27
|
-
"e2e:
|
|
28
|
-
"e2e:
|
|
29
|
-
"e2e:
|
|
30
|
-
"e2e:
|
|
31
|
-
"e2e:
|
|
32
|
-
"e2e:
|
|
33
|
-
"
|
|
16
|
+
"e2e": "npm run buildTs && vitest run --config e2e/vitest.config.mts",
|
|
17
|
+
"e2e:version": "vitest run --config e2e/vitest.config.mts e2e/modules/version/",
|
|
18
|
+
"e2e:discover": "vitest run --config e2e/vitest.discover.config.mts",
|
|
19
|
+
"e2e:tunnel-config": "vitest run --config e2e/vitest.config.mts e2e/modules/tunnel-config/",
|
|
20
|
+
"e2e:auth": "vitest run --config e2e/vitest.config.mts e2e/modules/auth/",
|
|
21
|
+
"e2e:workspace": "vitest run --config e2e/vitest.config.mts e2e/modules/workspace/",
|
|
22
|
+
"e2e:project": "vitest run --config e2e/vitest.config.mts e2e/modules/project/",
|
|
23
|
+
"e2e:artifact": "vitest run --config e2e/vitest.config.mts e2e/modules/artifact/",
|
|
24
|
+
"e2e:sandbox": "vitest run --config e2e/vitest.config.mts e2e/modules/sandbox/",
|
|
25
|
+
"e2e:api": "vitest run --config e2e/vitest.config.mts e2e/modules/api/",
|
|
26
|
+
"e2e:mcp": "vitest run --config e2e/vitest.config.mts e2e/modules/mcp/",
|
|
27
|
+
"e2e:pipeline": "vitest run --config e2e/vitest.config.mts e2e/modules/pipeline/",
|
|
28
|
+
"e2e:tunnel": "vitest run --config e2e/vitest.config.mts e2e/modules/tunnel/",
|
|
29
|
+
"e2e:agent": "vitest run --config e2e/vitest.config.mts e2e/modules/agent/",
|
|
30
|
+
"e2e:distro": "vitest run --config e2e/vitest.config.mts e2e/modules/distro/",
|
|
31
|
+
"e2e:target": "vitest run --config e2e/vitest.config.mts e2e/modules/target/",
|
|
32
|
+
"e2e:environment": "vitest run --config e2e/vitest.config.mts e2e/modules/environment/",
|
|
33
|
+
"e2e:yaml": "vitest run --config e2e/vitest.config.mts e2e/modules/yaml/",
|
|
34
|
+
"unit": "vitest run --config vitest.config.mts"
|
|
34
35
|
},
|
|
35
36
|
"files": [
|
|
36
37
|
"distTs"
|
|
@@ -30,6 +30,7 @@ class AgentSocketTunnel extends events_1.default {
|
|
|
30
30
|
totalConnections;
|
|
31
31
|
connections;
|
|
32
32
|
dns;
|
|
33
|
+
rawStatus;
|
|
33
34
|
constructor(socket, id) {
|
|
34
35
|
super();
|
|
35
36
|
this.id = id;
|
|
@@ -65,6 +66,7 @@ class AgentSocketTunnel extends events_1.default {
|
|
|
65
66
|
};
|
|
66
67
|
}
|
|
67
68
|
onTunnelData(data) {
|
|
69
|
+
this.rawStatus = data;
|
|
68
70
|
if (data.regionLatency)
|
|
69
71
|
this.regionLatency = data.regionLatency;
|
|
70
72
|
if (data.targetLatency)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const commander_1 = require("commander");
|
|
4
|
+
/** Command documentation shared by terminal help and machine discovery. */
|
|
5
|
+
class CliCommand extends commander_1.Command {
|
|
6
|
+
agentStatus;
|
|
7
|
+
agentInstalled;
|
|
8
|
+
agentId;
|
|
9
|
+
agentStandalone;
|
|
10
|
+
currentVersion;
|
|
11
|
+
latestVersion;
|
|
12
|
+
env;
|
|
13
|
+
hideVersionUpdate;
|
|
14
|
+
agentPort;
|
|
15
|
+
skipPre = false;
|
|
16
|
+
metadata;
|
|
17
|
+
constructor(name, metadata = {}) {
|
|
18
|
+
super(name);
|
|
19
|
+
this.metadata = metadata;
|
|
20
|
+
}
|
|
21
|
+
get requiredScopes() {
|
|
22
|
+
return this.metadata.requiredScopes ?? null;
|
|
23
|
+
}
|
|
24
|
+
get examples() {
|
|
25
|
+
return this.metadata.examples ?? [];
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.default = CliCommand;
|
package/distTs/src/cliIndex.js
CHANGED
|
@@ -29,8 +29,9 @@ const target_1 = __importDefault(require("./command/target"));
|
|
|
29
29
|
const environment_1 = __importDefault(require("./command/environment"));
|
|
30
30
|
const register_1 = __importDefault(require("./command/register"));
|
|
31
31
|
const mcp_1 = __importDefault(require("./command/mcp"));
|
|
32
|
+
const discover_1 = __importDefault(require("./command/discover"));
|
|
32
33
|
function cliIndex() {
|
|
33
|
-
const program = (0, utils_1.newCommand)('', texts_1.DESC_PROGRAM);
|
|
34
|
+
const program = (0, utils_1.newCommand)('bdy', texts_1.DESC_PROGRAM);
|
|
34
35
|
program.hook('preAction', pre_1.default);
|
|
35
36
|
program.configureHelp({
|
|
36
37
|
formatHelp: utils_1.formatHelp,
|
|
@@ -61,6 +62,7 @@ function cliIndex() {
|
|
|
61
62
|
program.addCommand(yaml_1.default);
|
|
62
63
|
program.addCommand(api_1.default);
|
|
63
64
|
program.addCommand(mcp_1.default);
|
|
65
|
+
program.addCommand(discover_1.default);
|
|
64
66
|
program.action((_, cmd) => {
|
|
65
67
|
if (cmd.args.length > 0) {
|
|
66
68
|
output_1.default.exitError((0, texts_1.ERR_COMMAND_NOT_FOUND)(cmd.args[0]));
|
|
@@ -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 commandAgentProxyStatus = (0, utils_1.newCommand)('status', texts_1.DESC_COMMAND_AGENT_PROXY_STATUS);
|
|
10
|
-
commandAgentProxyStatus.
|
|
9
|
+
const commandAgentProxyStatus = (0, utils_1.newCommand)('status', texts_1.DESC_COMMAND_AGENT_PROXY_STATUS, { examples: texts_1.EXAMPLE_AGENT_PROXY_STATUS });
|
|
10
|
+
commandAgentProxyStatus.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
11
|
+
commandAgentProxyStatus.action(async (options) => {
|
|
11
12
|
const ApiAgent = require('../../../tunnel/api/agent').default;
|
|
12
13
|
if (!commandAgentProxyStatus.agentInstalled) {
|
|
13
14
|
output_1.default.exitError(texts_1.ERR_AGENT_NOT_INSTALLED);
|
|
@@ -18,6 +19,12 @@ commandAgentProxyStatus.action(async () => {
|
|
|
18
19
|
try {
|
|
19
20
|
const api = new ApiAgent(commandAgentProxyStatus.agentPort || 0);
|
|
20
21
|
const data = await api.fetchAgentProxy();
|
|
22
|
+
if (options.format === 'json') {
|
|
23
|
+
output_1.default.json(data);
|
|
24
|
+
if (!data.proxy)
|
|
25
|
+
output_1.default.exitError(texts_1.TXT_AGENT_PROXY_DISABLED);
|
|
26
|
+
output_1.default.exitNormal();
|
|
27
|
+
}
|
|
21
28
|
if (data.proxy) {
|
|
22
29
|
output_1.default.exitSuccess(texts_1.TXT_AGENT_PROXY_ENABLED);
|
|
23
30
|
}
|
|
@@ -8,8 +8,8 @@ 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);
|
|
12
|
-
const outputStatus = (installed, standalone, version, id, running, enabled, target, tunneling, proxy, status) => {
|
|
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 });
|
|
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) {
|
|
15
15
|
// Nothing loaded, yet there is a file where the install would be - it is unreadable or not
|
|
@@ -22,6 +22,22 @@ const outputStatus = (installed, standalone, version, id, running, enabled, targ
|
|
|
22
22
|
}
|
|
23
23
|
output_1.default.exitError(texts_1.ERR_AGENT_NOT_INSTALLED);
|
|
24
24
|
}
|
|
25
|
+
const orphan = AgentManager.system.getStandaloneConfigPath();
|
|
26
|
+
const orphanedConfig = !AgentManager.system.isUserOwnedInstall() && (0, node_fs_1.existsSync)(orphan)
|
|
27
|
+
? orphan
|
|
28
|
+
: null;
|
|
29
|
+
if (json) {
|
|
30
|
+
output_1.default.json({
|
|
31
|
+
...commandAgentStatus.agentStatus,
|
|
32
|
+
installed,
|
|
33
|
+
standalone,
|
|
34
|
+
id: id ?? null,
|
|
35
|
+
version: version || null,
|
|
36
|
+
running,
|
|
37
|
+
orphaned_config: orphanedConfig,
|
|
38
|
+
});
|
|
39
|
+
output_1.default.exitNormal();
|
|
40
|
+
}
|
|
25
41
|
let txt = 'Installation: ';
|
|
26
42
|
if (standalone)
|
|
27
43
|
txt += 'App @ ';
|
|
@@ -66,13 +82,13 @@ const outputStatus = (installed, standalone, version, id, running, enabled, targ
|
|
|
66
82
|
// above: an install made before those files moved keeps its config in the system directory
|
|
67
83
|
// and reports itself as an app, and a leftover in the home is just as inert next to it.
|
|
68
84
|
// Inert, but only findable if it is said out loud.
|
|
69
|
-
|
|
70
|
-
if (!AgentManager.system.isUserOwnedInstall() && (0, node_fs_1.existsSync)(orphan)) {
|
|
85
|
+
if (orphanedConfig) {
|
|
71
86
|
output_1.default.error((0, texts_1.TXT_AGENT_APP_INSTALL_ORPHANED)(orphan));
|
|
72
87
|
}
|
|
73
88
|
output_1.default.exitNormal();
|
|
74
89
|
};
|
|
75
|
-
commandAgentStatus.
|
|
90
|
+
commandAgentStatus.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
91
|
+
commandAgentStatus.action((options) => {
|
|
76
92
|
let version = '';
|
|
77
93
|
const id = commandAgentStatus.agentId;
|
|
78
94
|
const running = !!commandAgentStatus.agentStatus;
|
|
@@ -89,6 +105,6 @@ commandAgentStatus.action(async () => {
|
|
|
89
105
|
tunneling = commandAgentStatus.agentStatus.tunneling;
|
|
90
106
|
proxy = commandAgentStatus.agentStatus.proxy;
|
|
91
107
|
}
|
|
92
|
-
outputStatus(!!commandAgentStatus.agentInstalled, !!commandAgentStatus.agentStandalone, version, id, running, enabled, target, tunneling, proxy, status);
|
|
108
|
+
outputStatus(!!commandAgentStatus.agentInstalled, !!commandAgentStatus.agentStandalone, version, id, running, enabled, target, tunneling, proxy, status, options.format === 'json');
|
|
93
109
|
});
|
|
94
110
|
exports.default = commandAgentStatus;
|
|
@@ -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 commandAgentTagsGet = (0, utils_1.newCommand)('get', texts_1.DESC_COMMAND_AGENT_TAGS_GET);
|
|
10
|
-
commandAgentTagsGet.
|
|
9
|
+
const commandAgentTagsGet = (0, utils_1.newCommand)('get', texts_1.DESC_COMMAND_AGENT_TAGS_GET, { examples: texts_1.EXAMPLE_AGENT_TAGS_GET });
|
|
10
|
+
commandAgentTagsGet.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
11
|
+
commandAgentTagsGet.action(async (options) => {
|
|
11
12
|
const ApiAgent = require('../../../tunnel/api/agent').default;
|
|
12
13
|
if (!commandAgentTagsGet.agentInstalled) {
|
|
13
14
|
output_1.default.exitError(texts_1.ERR_AGENT_NOT_INSTALLED);
|
|
@@ -18,6 +19,12 @@ commandAgentTagsGet.action(async () => {
|
|
|
18
19
|
try {
|
|
19
20
|
const api = new ApiAgent(commandAgentTagsGet.agentPort || 0);
|
|
20
21
|
const data = await api.fetchAgentTags();
|
|
22
|
+
if (options.format === 'json') {
|
|
23
|
+
output_1.default.json(data);
|
|
24
|
+
if (!data.tags?.length)
|
|
25
|
+
output_1.default.exitError(texts_1.TXT_AGENT_NO_TAGS);
|
|
26
|
+
output_1.default.exitNormal();
|
|
27
|
+
}
|
|
21
28
|
if (data.tags && data.tags.length > 0) {
|
|
22
29
|
output_1.default.exitNormal(data.tags.join(' '));
|
|
23
30
|
}
|
|
@@ -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 commandAgentTargetStatus = (0, utils_1.newCommand)('status', texts_1.DESC_COMMAND_AGENT_TARGET_STATUS);
|
|
10
|
-
commandAgentTargetStatus.
|
|
9
|
+
const commandAgentTargetStatus = (0, utils_1.newCommand)('status', texts_1.DESC_COMMAND_AGENT_TARGET_STATUS, { examples: texts_1.EXAMPLE_AGENT_TARGET_STATUS });
|
|
10
|
+
commandAgentTargetStatus.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
11
|
+
commandAgentTargetStatus.action(async (options) => {
|
|
11
12
|
const ApiAgent = require('../../../tunnel/api/agent').default;
|
|
12
13
|
if (!commandAgentTargetStatus.agentInstalled) {
|
|
13
14
|
output_1.default.exitError(texts_1.ERR_AGENT_NOT_INSTALLED);
|
|
@@ -18,6 +19,12 @@ commandAgentTargetStatus.action(async () => {
|
|
|
18
19
|
try {
|
|
19
20
|
const api = new ApiAgent(commandAgentTargetStatus.agentPort || 0);
|
|
20
21
|
const data = await api.fetchAgentTarget();
|
|
22
|
+
if (options.format === 'json') {
|
|
23
|
+
output_1.default.json(data);
|
|
24
|
+
if (!data.target)
|
|
25
|
+
output_1.default.exitError(texts_1.TXT_AGENT_TARGET_DISABLED);
|
|
26
|
+
output_1.default.exitNormal();
|
|
27
|
+
}
|
|
21
28
|
if (data.target) {
|
|
22
29
|
output_1.default.exitSuccess(texts_1.TXT_AGENT_TARGET_ENABLED);
|
|
23
30
|
}
|
|
@@ -7,11 +7,12 @@ const utils_1 = require("../../../utils");
|
|
|
7
7
|
const output_1 = __importDefault(require("../../../output"));
|
|
8
8
|
const texts_1 = require("../../../texts");
|
|
9
9
|
const tunnel_1 = require("../../../types/tunnel");
|
|
10
|
-
const commandAgentTunnelHttp = (0, utils_1.getBasicCommandHttp)(
|
|
11
|
-
|
|
10
|
+
const commandAgentTunnelHttp = (0, utils_1.getBasicCommandHttp)({
|
|
11
|
+
examples: (0, texts_1.EXAMPLE_TUNNEL_HTTP)(true),
|
|
12
|
+
});
|
|
13
|
+
commandAgentTunnelHttp.description(texts_1.DESC_COMMAND_AGENT_TUNNEL_HTTP);
|
|
12
14
|
commandAgentTunnelHttp.option('-f, --follow', texts_1.OPTION_FOLLOW);
|
|
13
15
|
commandAgentTunnelHttp.argument('[protocol://host:port]', texts_1.OPTION_TARGET);
|
|
14
|
-
commandAgentTunnelHttp.addHelpText('after', `\nEXAMPLES:${(0, texts_1.EXAMPLE_TUNNEL_HTTP)(true)}`);
|
|
15
16
|
commandAgentTunnelHttp.action(async (target, options) => {
|
|
16
17
|
const ApiAgent = require('../../../tunnel/api/agent').default;
|
|
17
18
|
const AgentSocketTunnel = require('../../../agent/socket/tunnel').default;
|
|
@@ -6,10 +6,10 @@ 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 commandAgentTunnelList = (0, utils_1.newCommand)('list', texts_1.DESC_COMMAND_AGENT_TUNNEL_LIST);
|
|
9
|
+
const commandAgentTunnelList = (0, utils_1.newCommand)('list', texts_1.DESC_COMMAND_AGENT_TUNNEL_LIST, { examples: texts_1.EXAMPLE_AGENT_TUNNEL_LIST });
|
|
10
10
|
commandAgentTunnelList.alias('ls');
|
|
11
|
-
commandAgentTunnelList.
|
|
12
|
-
commandAgentTunnelList.action(async () => {
|
|
11
|
+
commandAgentTunnelList.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
12
|
+
commandAgentTunnelList.action(async (options) => {
|
|
13
13
|
const ApiAgent = require('../../../tunnel/api/agent').default;
|
|
14
14
|
if (!commandAgentTunnelList.agentInstalled) {
|
|
15
15
|
output_1.default.exitError(texts_1.ERR_AGENT_NOT_INSTALLED);
|
|
@@ -20,6 +20,10 @@ commandAgentTunnelList.action(async () => {
|
|
|
20
20
|
try {
|
|
21
21
|
const api = new ApiAgent(commandAgentTunnelList.agentPort || 0);
|
|
22
22
|
const data = await api.fetchTunnels();
|
|
23
|
+
if (options.format === 'json') {
|
|
24
|
+
output_1.default.json(data);
|
|
25
|
+
output_1.default.exitNormal();
|
|
26
|
+
}
|
|
23
27
|
output_1.default.agentTunnels(data.tunnels);
|
|
24
28
|
}
|
|
25
29
|
catch (err) {
|
|
@@ -6,8 +6,7 @@ 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 commandAgentTunnelRemove = (0, utils_1.newCommand)('rm', texts_1.DESC_COMMAND_AGENT_TUNNEL_REMOVE);
|
|
10
|
-
commandAgentTunnelRemove.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_AGENT_TUNNEL_REMOVE}`);
|
|
9
|
+
const commandAgentTunnelRemove = (0, utils_1.newCommand)('rm', texts_1.DESC_COMMAND_AGENT_TUNNEL_REMOVE, { examples: texts_1.EXAMPLE_AGENT_TUNNEL_REMOVE });
|
|
11
10
|
commandAgentTunnelRemove.argument('<id>', texts_1.OPTION_ID);
|
|
12
11
|
commandAgentTunnelRemove.action(async (id) => {
|
|
13
12
|
const ApiAgent = require('../../../tunnel/api/agent').default;
|
|
@@ -6,8 +6,7 @@ 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 commandAgentTunnelStart = (0, utils_1.newCommand)('start', texts_1.
|
|
10
|
-
commandAgentTunnelStart.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_AGENT_TUNNEL_START}`);
|
|
9
|
+
const commandAgentTunnelStart = (0, utils_1.newCommand)('start', texts_1.DESC_COMMAND_AGENT_TUNNEL_START, { examples: texts_1.EXAMPLE_AGENT_TUNNEL_START });
|
|
11
10
|
commandAgentTunnelStart.argument('<name>', texts_1.OPTION_NAME);
|
|
12
11
|
commandAgentTunnelStart.action(async (name) => {
|
|
13
12
|
const ApiAgent = require('../../../tunnel/api/agent').default;
|
|
@@ -6,10 +6,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const texts_1 = require("../../../texts");
|
|
7
7
|
const output_1 = __importDefault(require("../../../output"));
|
|
8
8
|
const utils_1 = require("../../../utils");
|
|
9
|
-
const commandAgentTunnelStatus = (0, utils_1.newCommand)('status', texts_1.DESC_COMMAND_AGENT_TUNNEL_STATUS);
|
|
10
|
-
commandAgentTunnelStatus.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_AGENT_TUNNEL_STATUS}`);
|
|
9
|
+
const commandAgentTunnelStatus = (0, utils_1.newCommand)('status', texts_1.DESC_COMMAND_AGENT_TUNNEL_STATUS, { examples: texts_1.EXAMPLE_AGENT_TUNNEL_STATUS });
|
|
11
10
|
commandAgentTunnelStatus.argument('[id]', texts_1.OPTION_ID);
|
|
12
|
-
commandAgentTunnelStatus.
|
|
11
|
+
commandAgentTunnelStatus.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
12
|
+
commandAgentTunnelStatus.action(async (id, options) => {
|
|
13
13
|
const ApiAgent = require('../../../tunnel/api/agent').default;
|
|
14
14
|
const AgentSocketTunnel = require('../../../agent/socket/tunnel').default;
|
|
15
15
|
if (!commandAgentTunnelStatus.agentInstalled) {
|
|
@@ -22,6 +22,12 @@ commandAgentTunnelStatus.action(async (id) => {
|
|
|
22
22
|
const api = new ApiAgent(commandAgentTunnelStatus.agentPort || 0);
|
|
23
23
|
if (!id) {
|
|
24
24
|
const data = await api.fetchAgentTunneling();
|
|
25
|
+
if (options.format === 'json') {
|
|
26
|
+
output_1.default.json(data);
|
|
27
|
+
if (!data.tunneling)
|
|
28
|
+
output_1.default.exitError(texts_1.TXT_AGENT_TUNNELING_DISABLED);
|
|
29
|
+
output_1.default.exitNormal();
|
|
30
|
+
}
|
|
25
31
|
if (data.tunneling) {
|
|
26
32
|
output_1.default.exitSuccess(texts_1.TXT_AGENT_TUNNELING_ENABLED);
|
|
27
33
|
}
|
|
@@ -33,6 +39,11 @@ commandAgentTunnelStatus.action(async (id) => {
|
|
|
33
39
|
const ws = await api.socketTunnel(id);
|
|
34
40
|
const tunnel = new AgentSocketTunnel(ws, id);
|
|
35
41
|
await tunnel.waitForReady();
|
|
42
|
+
if (options.format === 'json') {
|
|
43
|
+
output_1.default.json(tunnel.rawStatus);
|
|
44
|
+
tunnel.close();
|
|
45
|
+
output_1.default.exitNormal();
|
|
46
|
+
}
|
|
36
47
|
output_1.default.tunnel(tunnel);
|
|
37
48
|
}
|
|
38
49
|
catch (err) {
|
|
@@ -7,11 +7,12 @@ const utils_1 = require("../../../utils");
|
|
|
7
7
|
const output_1 = __importDefault(require("../../../output"));
|
|
8
8
|
const texts_1 = require("../../../texts");
|
|
9
9
|
const tunnel_1 = require("../../../types/tunnel");
|
|
10
|
-
const commandAgentTunnelTcp = (0, utils_1.getBasicCommandTcp)(
|
|
11
|
-
|
|
10
|
+
const commandAgentTunnelTcp = (0, utils_1.getBasicCommandTcp)({
|
|
11
|
+
examples: (0, texts_1.EXAMPLE_TUNNEL_TCP)(true),
|
|
12
|
+
});
|
|
13
|
+
commandAgentTunnelTcp.description(texts_1.DESC_COMMAND_AGENT_TUNNEL_TCP);
|
|
12
14
|
commandAgentTunnelTcp.option('-f, --follow', texts_1.OPTION_FOLLOW);
|
|
13
15
|
commandAgentTunnelTcp.argument('[host:port]', texts_1.OPTION_TARGET);
|
|
14
|
-
commandAgentTunnelTcp.addHelpText('after', `\nEXAMPLES:${(0, texts_1.EXAMPLE_TUNNEL_TCP)(true)}`);
|
|
15
16
|
commandAgentTunnelTcp.action(async (target, options) => {
|
|
16
17
|
const ApiAgent = require('../../../tunnel/api/agent').default;
|
|
17
18
|
const AgentSocketTunnel = require('../../../agent/socket/tunnel').default;
|
|
@@ -7,11 +7,12 @@ const utils_1 = require("../../../utils");
|
|
|
7
7
|
const output_1 = __importDefault(require("../../../output"));
|
|
8
8
|
const texts_1 = require("../../../texts");
|
|
9
9
|
const tunnel_1 = require("../../../types/tunnel");
|
|
10
|
-
const commandAgentTunnelTls = (0, utils_1.getBasicCommandTls)(
|
|
11
|
-
|
|
10
|
+
const commandAgentTunnelTls = (0, utils_1.getBasicCommandTls)({
|
|
11
|
+
examples: (0, texts_1.EXAMPLE_TUNNEL_TLS)(true),
|
|
12
|
+
});
|
|
13
|
+
commandAgentTunnelTls.description(texts_1.DESC_COMMAND_AGENT_TUNNEL_TLS);
|
|
12
14
|
commandAgentTunnelTls.option('-f, --follow', texts_1.OPTION_FOLLOW);
|
|
13
15
|
commandAgentTunnelTls.argument('[host:port]', texts_1.OPTION_TARGET);
|
|
14
|
-
commandAgentTunnelTls.addHelpText('after', `\nEXAMPLES:${(0, texts_1.EXAMPLE_TUNNEL_TLS)(true)}`);
|
|
15
16
|
commandAgentTunnelTls.action(async (target, options) => {
|
|
16
17
|
const ApiAgent = require('../../../tunnel/api/agent').default;
|
|
17
18
|
const AgentSocketTunnel = require('../../../agent/socket/tunnel').default;
|
|
@@ -14,7 +14,17 @@ const status_1 = __importDefault(require("./tunnel/status"));
|
|
|
14
14
|
const utils_1 = require("../../utils");
|
|
15
15
|
const enable_1 = __importDefault(require("./tunnel/enable"));
|
|
16
16
|
const disable_1 = __importDefault(require("./tunnel/disable"));
|
|
17
|
-
const commandAgentTunnel = (0, utils_1.newCommand)('tunnel', texts_1.DESC_COMMAND_AGENT_TUNNEL
|
|
17
|
+
const commandAgentTunnel = (0, utils_1.newCommand)('tunnel', texts_1.DESC_COMMAND_AGENT_TUNNEL, {
|
|
18
|
+
examples: [
|
|
19
|
+
...(0, texts_1.EXAMPLE_TUNNEL_HTTP)(true),
|
|
20
|
+
...(0, texts_1.EXAMPLE_TUNNEL_TLS)(true),
|
|
21
|
+
...(0, texts_1.EXAMPLE_TUNNEL_TCP)(true),
|
|
22
|
+
...texts_1.EXAMPLE_AGENT_TUNNEL_START,
|
|
23
|
+
...texts_1.EXAMPLE_AGENT_TUNNEL_LIST,
|
|
24
|
+
...texts_1.EXAMPLE_AGENT_TUNNEL_STATUS,
|
|
25
|
+
...texts_1.EXAMPLE_AGENT_TUNNEL_REMOVE,
|
|
26
|
+
],
|
|
27
|
+
});
|
|
18
28
|
commandAgentTunnel.addCommand(tcp_1.default);
|
|
19
29
|
commandAgentTunnel.addCommand(tls_1.default);
|
|
20
30
|
commandAgentTunnel.addCommand(http_1.default);
|
|
@@ -24,11 +34,4 @@ commandAgentTunnel.addCommand(list_1.default);
|
|
|
24
34
|
commandAgentTunnel.addCommand(status_1.default);
|
|
25
35
|
commandAgentTunnel.addCommand(enable_1.default);
|
|
26
36
|
commandAgentTunnel.addCommand(disable_1.default);
|
|
27
|
-
commandAgentTunnel.addHelpText('after', `\nEXAMPLES:${(0, texts_1.EXAMPLE_TUNNEL_HTTP)(true)}
|
|
28
|
-
${(0, texts_1.EXAMPLE_TUNNEL_TLS)(true)}
|
|
29
|
-
${(0, texts_1.EXAMPLE_TUNNEL_TCP)(true)}
|
|
30
|
-
${texts_1.EXAMPLE_AGENT_TUNNEL_START}
|
|
31
|
-
${texts_1.EXAMPLE_AGENT_TUNNEL_LIST}
|
|
32
|
-
${texts_1.EXAMPLE_AGENT_TUNNEL_STATUS}
|
|
33
|
-
${texts_1.EXAMPLE_AGENT_TUNNEL_REMOVE}`);
|
|
34
37
|
exports.default = commandAgentTunnel;
|
|
@@ -6,14 +6,19 @@ 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 commandAgentVersion = (0, utils_1.newCommand)('version', texts_1.DESC_COMMAND_AGENT_VERSION);
|
|
10
|
-
commandAgentVersion.
|
|
9
|
+
const commandAgentVersion = (0, utils_1.newCommand)('version', texts_1.DESC_COMMAND_AGENT_VERSION, { examples: texts_1.EXAMPLE_AGENT_VERSION });
|
|
10
|
+
commandAgentVersion.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
11
|
+
commandAgentVersion.action(async (options) => {
|
|
11
12
|
if (!commandAgentVersion.agentInstalled) {
|
|
12
13
|
output_1.default.exitError(texts_1.ERR_AGENT_NOT_INSTALLED);
|
|
13
14
|
}
|
|
14
15
|
if (!commandAgentVersion.agentStatus) {
|
|
15
16
|
output_1.default.exitError(texts_1.ERR_AGENT_NOT_RUNNING);
|
|
16
17
|
}
|
|
18
|
+
if (options.format === 'json') {
|
|
19
|
+
output_1.default.json(commandAgentVersion.agentStatus);
|
|
20
|
+
output_1.default.exitNormal();
|
|
21
|
+
}
|
|
17
22
|
output_1.default.exitNormal(commandAgentVersion.agentStatus.version);
|
|
18
23
|
});
|
|
19
24
|
exports.default = commandAgentVersion;
|
|
@@ -9,6 +9,8 @@ const input_1 = __importDefault(require("../../input"));
|
|
|
9
9
|
const output_1 = __importDefault(require("../../output"));
|
|
10
10
|
/** `members` keeps declaration order, which numbers the listing; `values` does not. */
|
|
11
11
|
const orderedMembers = (body) => {
|
|
12
|
+
if (body.kind === 'array')
|
|
13
|
+
return orderedMembers(body.items);
|
|
12
14
|
if (body.kind !== 'union')
|
|
13
15
|
return [];
|
|
14
16
|
const members = body.discriminator?.members;
|
|
@@ -217,15 +219,19 @@ const chosen = (asked, names) => {
|
|
|
217
219
|
const position = Number(asked);
|
|
218
220
|
return Number.isInteger(position) && position >= 1 ? names[position - 1] : undefined;
|
|
219
221
|
};
|
|
220
|
-
const commandApiInfo = (0, utils_1.newCommand)('info', texts_1.DESC_COMMAND_API_INFO
|
|
222
|
+
const commandApiInfo = (0, utils_1.newCommand)('info', texts_1.DESC_COMMAND_API_INFO, {
|
|
223
|
+
helpText: texts_1.HELP_API_INFO_JSON,
|
|
224
|
+
examples: texts_1.EXAMPLE_API_INFO,
|
|
225
|
+
});
|
|
221
226
|
commandApiInfo.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
222
227
|
commandApiInfo.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
|
|
223
228
|
commandApiInfo.option('--request-schema <schema>', texts_1.OPT_COMMAND_API_INFO_SCHEMA);
|
|
224
229
|
commandApiInfo.option('--response-schema <schema>', texts_1.OPT_COMMAND_API_INFO_SCHEMA);
|
|
225
230
|
commandApiInfo.argument('<method>', texts_1.OPT_COMMAND_API_INFO_METHOD);
|
|
226
231
|
commandApiInfo.argument('<url>', texts_1.OPT_COMMAND_API_INFO_URL);
|
|
232
|
+
commandApiInfo.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
227
233
|
commandApiInfo.action(async (fm, filterUrl, options) => {
|
|
228
|
-
const { apiEndpoints } = require('../../openapi');
|
|
234
|
+
const { apiEndpoints, apiSpecification } = require('../../openapi');
|
|
229
235
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
230
236
|
const project = input_1.default.restApiProject(options.project, true);
|
|
231
237
|
const method = (input_1.default.restApiMethod(fm, false) ?? '').toLowerCase();
|
|
@@ -246,6 +252,48 @@ commandApiInfo.action(async (fm, filterUrl, options) => {
|
|
|
246
252
|
const namesOf = (bodies) => bodies.flatMap((body) => [...orderedMembers(body)]);
|
|
247
253
|
const request = chosen(options.requestSchema, namesOf((listed.request?.contents ?? []).map((content) => content.body)));
|
|
248
254
|
const response = chosen(options.responseSchema, namesOf(listed.responses.flatMap((one) => one.contents.map((content) => content.body))));
|
|
255
|
+
if (options.format === 'json') {
|
|
256
|
+
const raw = await apiSpecification(client.baseUrl);
|
|
257
|
+
const schema = (asked, selected, bodies) => {
|
|
258
|
+
const refs = [];
|
|
259
|
+
for (let body of bodies) {
|
|
260
|
+
while (body.kind === 'array')
|
|
261
|
+
body = body.items;
|
|
262
|
+
if (body.kind === 'union' && selected) {
|
|
263
|
+
const name = memberDef(body, selected);
|
|
264
|
+
if (name && raw.components?.schemas?.[name])
|
|
265
|
+
return raw.components.schemas[name];
|
|
266
|
+
}
|
|
267
|
+
if ('ref' in body && body.ref)
|
|
268
|
+
refs.push(body.ref.name);
|
|
269
|
+
}
|
|
270
|
+
// Union positions use the same member list as text output. Only bodies
|
|
271
|
+
// without unions use reference positions across response/content order.
|
|
272
|
+
const name = refs.includes(asked)
|
|
273
|
+
? asked
|
|
274
|
+
: namesOf(bodies).length === 0
|
|
275
|
+
? chosen(asked, refs)
|
|
276
|
+
: undefined;
|
|
277
|
+
if (name && raw.components?.schemas?.[name])
|
|
278
|
+
return raw.components.schemas[name];
|
|
279
|
+
output_1.default.exitError((0, texts_1.ERR_API_SCHEMA_NOT_FOUND)(asked));
|
|
280
|
+
};
|
|
281
|
+
const requestSchema = options.requestSchema
|
|
282
|
+
? schema(options.requestSchema, request, (listed.request?.contents ?? []).map((content) => content.body))
|
|
283
|
+
: undefined;
|
|
284
|
+
const responseSchema = options.responseSchema
|
|
285
|
+
? schema(options.responseSchema, response, listed.responses.flatMap((one) => one.contents.map((content) => content.body)))
|
|
286
|
+
: undefined;
|
|
287
|
+
output_1.default.json(requestSchema && responseSchema
|
|
288
|
+
? { request: requestSchema, response: responseSchema }
|
|
289
|
+
: (requestSchema ??
|
|
290
|
+
responseSchema ?? {
|
|
291
|
+
method: wanted.method.toUpperCase(),
|
|
292
|
+
path: (0, utils_1.openApiPrepareUrl)(wanted.path, workspace, project),
|
|
293
|
+
operation: raw.paths[wanted.path][method],
|
|
294
|
+
}));
|
|
295
|
+
output_1.default.exitNormal();
|
|
296
|
+
}
|
|
249
297
|
const member = request || response
|
|
250
298
|
? { ...(request ? { request } : {}), ...(response ? { response } : {}) }
|
|
251
299
|
: undefined;
|
|
@@ -25,12 +25,15 @@ const outputUrl = (operation, workspace, project) => {
|
|
|
25
25
|
if (operation.summary)
|
|
26
26
|
output_1.default.gray(operation.summary);
|
|
27
27
|
};
|
|
28
|
-
const commandApiList = (0, utils_1.newCommand)('list', texts_1.DESC_COMMAND_API_LIST
|
|
28
|
+
const commandApiList = (0, utils_1.newCommand)('list', texts_1.DESC_COMMAND_API_LIST, {
|
|
29
|
+
examples: texts_1.EXAMPLE_API_LIST,
|
|
30
|
+
});
|
|
29
31
|
commandApiList.alias('ls');
|
|
30
32
|
commandApiList.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
31
33
|
commandApiList.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
|
|
32
34
|
commandApiList.option('-m, --method <method>', texts_1.OPT_COMMAND_API_LIST_METHOD);
|
|
33
35
|
commandApiList.option('-s, --search <phrase>', texts_1.OPT_COMMAND_API_LIST_SEARCH);
|
|
36
|
+
commandApiList.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
34
37
|
commandApiList.action(async (options) => {
|
|
35
38
|
const { apiEndpoints } = require('../../openapi');
|
|
36
39
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
@@ -39,12 +42,25 @@ commandApiList.action(async (options) => {
|
|
|
39
42
|
const filter = options.search;
|
|
40
43
|
const client = input_1.default.restApiTokenClient(true);
|
|
41
44
|
const api = await apiEndpoints(client.baseUrl);
|
|
45
|
+
const operations = [];
|
|
42
46
|
for (const operation of await api.operations()) {
|
|
43
47
|
if (filter && !operation.path.includes(filter))
|
|
44
48
|
continue;
|
|
45
49
|
if (filterMethod && filterMethod !== operation.method.toLowerCase())
|
|
46
50
|
continue;
|
|
47
|
-
|
|
51
|
+
if (options.format === 'json') {
|
|
52
|
+
operations.push({
|
|
53
|
+
method: operation.method.toUpperCase(),
|
|
54
|
+
path: (0, utils_1.openApiPrepareUrl)(operation.path, workspace, project),
|
|
55
|
+
summary: operation.summary,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
outputUrl(operation, workspace, project);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (options.format === 'json') {
|
|
63
|
+
output_1.default.json(operations);
|
|
48
64
|
}
|
|
49
65
|
output_1.default.exitNormal();
|
|
50
66
|
});
|
|
@@ -12,7 +12,10 @@ const logger_1 = __importDefault(require("../../../logger"));
|
|
|
12
12
|
const fs_1 = __importDefault(require("fs"));
|
|
13
13
|
const path_1 = require("path");
|
|
14
14
|
const uuid_1 = require("uuid");
|
|
15
|
-
const commandArtifactComposerPublish = (0, utils_1.newCommand)('publish', texts_1.DESC_COMMAND_ARTIFACT_COMPOSER_PUBLISH
|
|
15
|
+
const commandArtifactComposerPublish = (0, utils_1.newCommand)('publish', texts_1.DESC_COMMAND_ARTIFACT_COMPOSER_PUBLISH, {
|
|
16
|
+
requiredScopes: [utils_1.REST_API_SCOPE.ARTIFACT_WRITE],
|
|
17
|
+
examples: texts_1.EXAMPLE_ARTIFACT_COMPOSER_PUBLISH,
|
|
18
|
+
});
|
|
16
19
|
commandArtifactComposerPublish.alias('pub');
|
|
17
20
|
commandArtifactComposerPublish.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
18
21
|
commandArtifactComposerPublish.option('--scope <scope>', texts_1.OPT_COMMAND_SCOPE);
|
|
@@ -23,7 +26,6 @@ commandArtifactComposerPublish.option('--agent-note <note>', texts_1.OPTION_ARTI
|
|
|
23
26
|
commandArtifactComposerPublish.option('--ignore <patterns>', texts_1.OPTION_ARTIFACT_IGNORE);
|
|
24
27
|
commandArtifactComposerPublish.argument('<identifier>', texts_1.OPTION_ARTIFACT_ID);
|
|
25
28
|
commandArtifactComposerPublish.argument('<directory>', texts_1.OPTION_ARTIFACT_COMPOSE_PUBLISH_PATH);
|
|
26
|
-
commandArtifactComposerPublish.addHelpText('after', texts_1.EXAMPLE_ARTIFACT_COMPOSER_PUBLISH);
|
|
27
29
|
commandArtifactComposerPublish.action(async (id, path, options) => {
|
|
28
30
|
const dirPath = input_1.default.resolvePath(path);
|
|
29
31
|
if (!fs_1.default.statSync(dirPath).isDirectory()) {
|
|
@@ -8,7 +8,10 @@ const texts_1 = require("../../texts");
|
|
|
8
8
|
const input_1 = __importDefault(require("../../input"));
|
|
9
9
|
const output_1 = __importDefault(require("../../output"));
|
|
10
10
|
const distro_1 = require("../../types/distro");
|
|
11
|
-
const commandArtifactCreate = (0, utils_1.newCommand)('create', texts_1.DESC_COMMAND_ARTIFACT_CREATE
|
|
11
|
+
const commandArtifactCreate = (0, utils_1.newCommand)('create', texts_1.DESC_COMMAND_ARTIFACT_CREATE, {
|
|
12
|
+
requiredScopes: [utils_1.REST_API_SCOPE.ARTIFACT_WRITE],
|
|
13
|
+
examples: texts_1.EXAMPLE_ARTIFACT_CREATE,
|
|
14
|
+
});
|
|
12
15
|
commandArtifactCreate.alias('add');
|
|
13
16
|
commandArtifactCreate.option('-i, --identifier <identifier>', texts_1.OPT_COMMAND_ARTIFACT_CREATE_IDENTIFIER);
|
|
14
17
|
commandArtifactCreate.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
@@ -20,7 +23,7 @@ commandArtifactCreate.option('-a, --auth <user:pass>', texts_1.OPTION_HTTP_AUTH)
|
|
|
20
23
|
commandArtifactCreate.option('--note <note>', texts_1.OPT_COMMAND_NOTE);
|
|
21
24
|
commandArtifactCreate.option('--agent-note <note>', texts_1.OPT_COMMAND_AGENT_NOTE);
|
|
22
25
|
commandArtifactCreate.argument('[name]', texts_1.OPT_COMMAND_ARTIFACT_NAME);
|
|
23
|
-
commandArtifactCreate.
|
|
26
|
+
commandArtifactCreate.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
24
27
|
commandArtifactCreate.action(async (name, options) => {
|
|
25
28
|
const humanId = require('human-id').default;
|
|
26
29
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
@@ -69,6 +72,10 @@ commandArtifactCreate.action(async (name, options) => {
|
|
|
69
72
|
};
|
|
70
73
|
}
|
|
71
74
|
const result = await client.createArtifact(workspace, data);
|
|
75
|
+
if (options.format === 'json') {
|
|
76
|
+
output_1.default.json(result);
|
|
77
|
+
output_1.default.exitNormal();
|
|
78
|
+
}
|
|
72
79
|
output_1.default.exitSuccess((0, texts_1.TXT_ARTIFACT_CREATED)(client.baseUrl, workspace, result));
|
|
73
80
|
});
|
|
74
81
|
exports.default = commandArtifactCreate;
|