bdy 1.17.22-stage → 1.17.22
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/autocomplete.js +85 -0
- package/distTs/src/command/agent/proxy/disable.js +27 -0
- package/distTs/src/command/agent/proxy/enable.js +27 -0
- package/distTs/src/command/agent/proxy/status.js +32 -0
- package/distTs/src/command/agent/proxy.js +15 -0
- package/distTs/src/command/agent/tunnel/disable.js +27 -0
- package/distTs/src/command/agent/tunnel/enable.js +27 -0
- package/distTs/src/command/autocomplete/install.js +16 -0
- package/distTs/src/command/autocomplete/uninstall.js +16 -0
- package/distTs/src/command/autocomplete.js +14 -0
- package/package.json +1 -1
package/distTs/package.json
CHANGED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const tabtab_1 = __importDefault(require("tabtab"));
|
|
7
|
+
const logger_1 = __importDefault(require("./logger"));
|
|
8
|
+
class Autocomplete {
|
|
9
|
+
getCommandsMap(command) {
|
|
10
|
+
const commands = {};
|
|
11
|
+
command.commands.forEach((c) => {
|
|
12
|
+
const map = this.getCommandsMap(c);
|
|
13
|
+
const name = c.name() || 'bdy';
|
|
14
|
+
commands[name] = map;
|
|
15
|
+
c.aliases().forEach((a) => {
|
|
16
|
+
commands[a] = map;
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
command.options.forEach((o) => {
|
|
20
|
+
const name = `--${o.name()}`;
|
|
21
|
+
commands[name] = {};
|
|
22
|
+
});
|
|
23
|
+
let lastArg = commands;
|
|
24
|
+
command.registeredArguments.forEach((a) => {
|
|
25
|
+
logger_1.default.info(a);
|
|
26
|
+
let name;
|
|
27
|
+
if (a.required) {
|
|
28
|
+
name = `<${a.name()}>`;
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
name = `[${a.name()}]`;
|
|
32
|
+
}
|
|
33
|
+
name = name.replaceAll(':', '꞉'); // U+A789 MODIFIER LETTER COLON - looks like : but doesn't trigger tabtab delimiter
|
|
34
|
+
lastArg[name] = {};
|
|
35
|
+
lastArg = lastArg[name];
|
|
36
|
+
});
|
|
37
|
+
return commands;
|
|
38
|
+
}
|
|
39
|
+
init(rootCommand) {
|
|
40
|
+
const env = tabtab_1.default.parseEnv(process.env);
|
|
41
|
+
if (!env.complete)
|
|
42
|
+
return false;
|
|
43
|
+
let map = {
|
|
44
|
+
bdy: this.getCommandsMap(rootCommand)
|
|
45
|
+
};
|
|
46
|
+
const s = (env.partial || '').trim().split(' ').filter((n) => !n.startsWith('--'));
|
|
47
|
+
const last = s[s.length - 1];
|
|
48
|
+
for (let i = 0; i < s.length - 1; i += 1) {
|
|
49
|
+
const name = s[i];
|
|
50
|
+
if (!map[name]) {
|
|
51
|
+
const arg = Object.keys(map).find((k) => k.startsWith('<') || k.startsWith('['));
|
|
52
|
+
if (arg) {
|
|
53
|
+
map = map[arg];
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
map = map[name];
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (map[last])
|
|
64
|
+
map = map[last];
|
|
65
|
+
else {
|
|
66
|
+
const arg = Object.keys(map).find((k) => k.startsWith('<') || k.startsWith('['));
|
|
67
|
+
if (arg)
|
|
68
|
+
map = map[arg];
|
|
69
|
+
}
|
|
70
|
+
tabtab_1.default.log(Object.keys(map));
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
async install() {
|
|
74
|
+
await tabtab_1.default.install({
|
|
75
|
+
name: process.title,
|
|
76
|
+
completer: process.title
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
async uninstall() {
|
|
80
|
+
await tabtab_1.default.uninstall({
|
|
81
|
+
name: process.title
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
exports.default = new Autocomplete();
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("../../../utils");
|
|
7
|
+
const texts_1 = require("../../../texts");
|
|
8
|
+
const output_1 = __importDefault(require("../../../output"));
|
|
9
|
+
const agent_1 = __importDefault(require("../../../tunnel/api/agent"));
|
|
10
|
+
const commandAgentProxyDisable = (0, utils_1.newCommand)('disable', texts_1.DESC_COMMAND_AGENT_PROXY_DISABLE);
|
|
11
|
+
commandAgentProxyDisable.action(async () => {
|
|
12
|
+
if (!commandAgentProxyDisable.agentInstalled) {
|
|
13
|
+
output_1.default.exitError(texts_1.ERR_AGENT_NOT_INSTALLED);
|
|
14
|
+
}
|
|
15
|
+
if (!commandAgentProxyDisable.agentStatus) {
|
|
16
|
+
output_1.default.exitError(texts_1.ERR_AGENT_NOT_RUNNING);
|
|
17
|
+
}
|
|
18
|
+
try {
|
|
19
|
+
const api = new agent_1.default(commandAgentProxyDisable.agentPort || 0);
|
|
20
|
+
await api.disableAgentProxy();
|
|
21
|
+
output_1.default.exitSuccess(texts_1.TXT_AGENT_PROXY_DISABLED);
|
|
22
|
+
}
|
|
23
|
+
catch (err) {
|
|
24
|
+
output_1.default.exitError(err);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
exports.default = commandAgentProxyDisable;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("../../../utils");
|
|
7
|
+
const texts_1 = require("../../../texts");
|
|
8
|
+
const output_1 = __importDefault(require("../../../output"));
|
|
9
|
+
const agent_1 = __importDefault(require("../../../tunnel/api/agent"));
|
|
10
|
+
const commandAgentProxyEnable = (0, utils_1.newCommand)('enable', texts_1.DESC_COMMAND_AGENT_PROXY_ENABLE);
|
|
11
|
+
commandAgentProxyEnable.action(async () => {
|
|
12
|
+
if (!commandAgentProxyEnable.agentInstalled) {
|
|
13
|
+
output_1.default.exitError(texts_1.ERR_AGENT_NOT_INSTALLED);
|
|
14
|
+
}
|
|
15
|
+
if (!commandAgentProxyEnable.agentStatus) {
|
|
16
|
+
output_1.default.exitError(texts_1.ERR_AGENT_NOT_RUNNING);
|
|
17
|
+
}
|
|
18
|
+
try {
|
|
19
|
+
const api = new agent_1.default(commandAgentProxyEnable.agentPort || 0);
|
|
20
|
+
await api.enableAgentProxy();
|
|
21
|
+
output_1.default.exitSuccess(texts_1.TXT_AGENT_TARGET_ENABLED);
|
|
22
|
+
}
|
|
23
|
+
catch (err) {
|
|
24
|
+
output_1.default.exitError(err);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
exports.default = commandAgentProxyEnable;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("../../../utils");
|
|
7
|
+
const texts_1 = require("../../../texts");
|
|
8
|
+
const output_1 = __importDefault(require("../../../output"));
|
|
9
|
+
const agent_1 = __importDefault(require("../../../tunnel/api/agent"));
|
|
10
|
+
const commandAgentProxyStatus = (0, utils_1.newCommand)('status', texts_1.DESC_COMMAND_AGENT_PROXY_STATUS);
|
|
11
|
+
commandAgentProxyStatus.action(async () => {
|
|
12
|
+
if (!commandAgentProxyStatus.agentInstalled) {
|
|
13
|
+
output_1.default.exitError(texts_1.ERR_AGENT_NOT_INSTALLED);
|
|
14
|
+
}
|
|
15
|
+
if (!commandAgentProxyStatus.agentStatus) {
|
|
16
|
+
output_1.default.exitError(texts_1.ERR_AGENT_NOT_RUNNING);
|
|
17
|
+
}
|
|
18
|
+
try {
|
|
19
|
+
const api = new agent_1.default(commandAgentProxyStatus.agentPort || 0);
|
|
20
|
+
const data = await api.fetchAgentProxy();
|
|
21
|
+
if (data.proxy) {
|
|
22
|
+
output_1.default.exitSuccess(texts_1.TXT_AGENT_PROXY_ENABLED);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
output_1.default.exitError(texts_1.TXT_AGENT_PROXY_DISABLED);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
output_1.default.exitError(err);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
exports.default = commandAgentProxyStatus;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("../../utils");
|
|
7
|
+
const texts_1 = require("../../texts");
|
|
8
|
+
const status_1 = __importDefault(require("./proxy/status"));
|
|
9
|
+
const disable_1 = __importDefault(require("./proxy/disable"));
|
|
10
|
+
const enable_1 = __importDefault(require("./proxy/enable"));
|
|
11
|
+
const commandAgentProxy = (0, utils_1.newCommand)('proxy', texts_1.DESC_COMMAND_AGENT_PROXY);
|
|
12
|
+
commandAgentProxy.addCommand(status_1.default);
|
|
13
|
+
commandAgentProxy.addCommand(enable_1.default);
|
|
14
|
+
commandAgentProxy.addCommand(disable_1.default);
|
|
15
|
+
exports.default = commandAgentProxy;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("../../../utils");
|
|
7
|
+
const texts_1 = require("../../../texts");
|
|
8
|
+
const output_1 = __importDefault(require("../../../output"));
|
|
9
|
+
const agent_1 = __importDefault(require("../../../tunnel/api/agent"));
|
|
10
|
+
const commandAgentTunnelDisable = (0, utils_1.newCommand)('disable', texts_1.DESC_COMMAND_AGENT_TUNNELING_DISABLE);
|
|
11
|
+
commandAgentTunnelDisable.action(async () => {
|
|
12
|
+
if (!commandAgentTunnelDisable.agentInstalled) {
|
|
13
|
+
output_1.default.exitError(texts_1.ERR_AGENT_NOT_INSTALLED);
|
|
14
|
+
}
|
|
15
|
+
if (!commandAgentTunnelDisable.agentStatus) {
|
|
16
|
+
output_1.default.exitError(texts_1.ERR_AGENT_NOT_RUNNING);
|
|
17
|
+
}
|
|
18
|
+
try {
|
|
19
|
+
const api = new agent_1.default(commandAgentTunnelDisable.agentPort || 0);
|
|
20
|
+
await api.disableAgentTunneling();
|
|
21
|
+
output_1.default.exitSuccess(texts_1.TXT_AGENT_TUNNELING_DISABLED);
|
|
22
|
+
}
|
|
23
|
+
catch (err) {
|
|
24
|
+
output_1.default.exitError(err);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
exports.default = commandAgentTunnelDisable;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("../../../utils");
|
|
7
|
+
const texts_1 = require("../../../texts");
|
|
8
|
+
const output_1 = __importDefault(require("../../../output"));
|
|
9
|
+
const agent_1 = __importDefault(require("../../../tunnel/api/agent"));
|
|
10
|
+
const commandAgentTunnelEnable = (0, utils_1.newCommand)('enable', texts_1.DESC_COMMAND_AGENT_TUNNELING_ENABLE);
|
|
11
|
+
commandAgentTunnelEnable.action(async () => {
|
|
12
|
+
if (!commandAgentTunnelEnable.agentInstalled) {
|
|
13
|
+
output_1.default.exitError(texts_1.ERR_AGENT_NOT_INSTALLED);
|
|
14
|
+
}
|
|
15
|
+
if (!commandAgentTunnelEnable.agentStatus) {
|
|
16
|
+
output_1.default.exitError(texts_1.ERR_AGENT_NOT_RUNNING);
|
|
17
|
+
}
|
|
18
|
+
try {
|
|
19
|
+
const api = new agent_1.default(commandAgentTunnelEnable.agentPort || 0);
|
|
20
|
+
await api.enableAgentTunneling();
|
|
21
|
+
output_1.default.exitSuccess(texts_1.TXT_AGENT_TUNNELING_ENABLED);
|
|
22
|
+
}
|
|
23
|
+
catch (err) {
|
|
24
|
+
output_1.default.exitError(err);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
exports.default = commandAgentTunnelEnable;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("../../utils");
|
|
7
|
+
const autocomplete_1 = __importDefault(require("../../autocomplete"));
|
|
8
|
+
const texts_1 = require("../../texts");
|
|
9
|
+
const output_1 = __importDefault(require("../../output"));
|
|
10
|
+
const commandAutocompleteInstall = (0, utils_1.newCommand)('install', texts_1.DESC_COMMAND_AUTOCOMPLETE_INSTALL);
|
|
11
|
+
commandAutocompleteInstall.alias('i');
|
|
12
|
+
commandAutocompleteInstall.action(async () => {
|
|
13
|
+
await autocomplete_1.default.install();
|
|
14
|
+
output_1.default.exitSuccess(texts_1.TXT_AUTOCOMPLETE_INSTALLED);
|
|
15
|
+
});
|
|
16
|
+
exports.default = commandAutocompleteInstall;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("../../utils");
|
|
7
|
+
const autocomplete_1 = __importDefault(require("../../autocomplete"));
|
|
8
|
+
const texts_1 = require("../../texts");
|
|
9
|
+
const output_1 = __importDefault(require("../../output"));
|
|
10
|
+
const commandAutocompleteUninstall = (0, utils_1.newCommand)('uninstall', texts_1.DESC_COMMAND_AUTOCOMPLETE_UNINSTALL);
|
|
11
|
+
commandAutocompleteUninstall.alias('u');
|
|
12
|
+
commandAutocompleteUninstall.action(async () => {
|
|
13
|
+
await autocomplete_1.default.uninstall();
|
|
14
|
+
output_1.default.exitSuccess(texts_1.TXT_AUTOCOMPLETE_UNINSTALLED);
|
|
15
|
+
});
|
|
16
|
+
exports.default = commandAutocompleteUninstall;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("../utils");
|
|
7
|
+
const install_1 = __importDefault(require("./autocomplete/install"));
|
|
8
|
+
const uninstall_1 = __importDefault(require("./autocomplete/uninstall"));
|
|
9
|
+
const texts_1 = require("../texts");
|
|
10
|
+
const commandAutocomplete = (0, utils_1.newCommand)('autocomplete', texts_1.DESC_COMMAND_AUTOCOMPLETE);
|
|
11
|
+
commandAutocomplete.alias('ac');
|
|
12
|
+
commandAutocomplete.addCommand(install_1.default);
|
|
13
|
+
commandAutocomplete.addCommand(uninstall_1.default);
|
|
14
|
+
exports.default = commandAutocomplete;
|