bdy 1.22.15-dev → 1.22.16-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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bdy",
3
3
  "preferGlobal": false,
4
- "version": "1.22.15-dev",
4
+ "version": "1.22.16-dev",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",
7
7
  "scripts": {
@@ -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
+ exports.default = agentIndex;
7
+ const run_1 = __importDefault(require("./command/agent/run"));
8
+ const utils_1 = require("./utils");
9
+ const texts_1 = require("./texts");
10
+ function agentIndex() {
11
+ const program = (0, utils_1.newCommand)('', texts_1.DESC_PROGRAM);
12
+ const commandAgent = (0, utils_1.newCommand)('agent', texts_1.DESC_COMMAND_AGENT);
13
+ commandAgent.addCommand(run_1.default, { hidden: true });
14
+ program.addCommand(commandAgent);
15
+ return program;
16
+ }
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.default = cliIndex;
7
+ const output_1 = __importDefault(require("./output"));
8
+ const agent_1 = __importDefault(require("./command/agent"));
9
+ const version_1 = __importDefault(require("./command/version"));
10
+ const pre_1 = __importDefault(require("./command/pre"));
11
+ const utils_1 = require("./utils");
12
+ const texts_1 = require("./texts");
13
+ const crawl_1 = __importDefault(require("./command/crawl"));
14
+ const tests_1 = __importDefault(require("./command/tests"));
15
+ const tunnel_1 = __importDefault(require("./command/tunnel"));
16
+ const pipeline_1 = __importDefault(require("./command/pipeline"));
17
+ const sandbox_1 = __importDefault(require("./command/sandbox"));
18
+ const login_1 = __importDefault(require("./command/login"));
19
+ const logout_1 = __importDefault(require("./command/logout"));
20
+ const workspace_1 = __importDefault(require("./command/workspace"));
21
+ const project_1 = __importDefault(require("./command/project"));
22
+ const whoami_1 = __importDefault(require("./command/whoami"));
23
+ const artifact_1 = __importDefault(require("./command/artifact"));
24
+ const api_1 = __importDefault(require("./command/api"));
25
+ const domain_1 = __importDefault(require("./command/domain"));
26
+ const main_1 = __importDefault(require("./main"));
27
+ function cliIndex() {
28
+ const program = (0, utils_1.newCommand)('', texts_1.DESC_PROGRAM);
29
+ program.hook('preAction', pre_1.default);
30
+ program.configureHelp({
31
+ formatHelp: utils_1.formatHelp,
32
+ });
33
+ program.addCommand(tunnel_1.default);
34
+ if (!(0, utils_1.isDocker)())
35
+ program.addCommand(agent_1.default);
36
+ program.addCommand(version_1.default);
37
+ program.addCommand(crawl_1.default);
38
+ program.addCommand(tests_1.default);
39
+ program.addCommand(pipeline_1.default);
40
+ program.addCommand(artifact_1.default);
41
+ program.addCommand(sandbox_1.default);
42
+ program.addCommand(domain_1.default);
43
+ program.addCommand(login_1.default);
44
+ program.addCommand(whoami_1.default);
45
+ program.addCommand(logout_1.default);
46
+ program.addCommand(workspace_1.default);
47
+ program.addCommand(project_1.default);
48
+ program.addCommand(api_1.default);
49
+ program.action(async (_, cmd) => {
50
+ if (cmd.args.length > 0) {
51
+ output_1.default.exitError((0, texts_1.ERR_COMMAND_NOT_FOUND)(cmd.args[0]));
52
+ }
53
+ await (0, main_1.default)(program);
54
+ });
55
+ return program;
56
+ }
@@ -4,58 +4,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const output_1 = __importDefault(require("./output"));
7
- const agent_1 = __importDefault(require("./command/agent"));
8
7
  const logger_1 = __importDefault(require("./logger"));
9
- const version_1 = __importDefault(require("./command/version"));
10
- const pre_1 = __importDefault(require("./command/pre"));
11
8
  const stream_1 = __importDefault(require("stream"));
12
- const utils_1 = require("./utils");
13
- const texts_1 = require("./texts");
14
- const crawl_1 = __importDefault(require("./command/crawl"));
15
- const tests_1 = __importDefault(require("./command/tests"));
16
- const tunnel_1 = __importDefault(require("./command/tunnel"));
17
- const pipeline_1 = __importDefault(require("./command/pipeline"));
18
- const sandbox_1 = __importDefault(require("./command/sandbox"));
19
- const login_1 = __importDefault(require("./command/login"));
20
- const logout_1 = __importDefault(require("./command/logout"));
21
- const workspace_1 = __importDefault(require("./command/workspace"));
22
- const project_1 = __importDefault(require("./command/project"));
23
- const whoami_1 = __importDefault(require("./command/whoami"));
24
- const artifact_1 = __importDefault(require("./command/artifact"));
25
- const api_1 = __importDefault(require("./command/api"));
26
- const domain_1 = __importDefault(require("./command/domain"));
27
- const main_1 = __importDefault(require("./main"));
28
- stream_1.default.setDefaultHighWaterMark(false, 67108864);
9
+ stream_1.default.setDefaultHighWaterMark(false, 65536);
29
10
  process.title = 'bdy';
30
11
  process.on('uncaughtException', (err) => {
31
12
  logger_1.default.fatal(err);
32
13
  output_1.default.exitError(err);
33
14
  });
34
- const program = (0, utils_1.newCommand)('', texts_1.DESC_PROGRAM);
35
- program.hook('preAction', pre_1.default);
36
- program.configureHelp({
37
- formatHelp: utils_1.formatHelp,
38
- });
39
- program.addCommand(tunnel_1.default);
40
- if (!(0, utils_1.isDocker)())
41
- program.addCommand(agent_1.default);
42
- program.addCommand(version_1.default);
43
- program.addCommand(crawl_1.default);
44
- program.addCommand(tests_1.default);
45
- program.addCommand(pipeline_1.default);
46
- program.addCommand(artifact_1.default);
47
- program.addCommand(sandbox_1.default);
48
- program.addCommand(domain_1.default);
49
- program.addCommand(login_1.default);
50
- program.addCommand(whoami_1.default);
51
- program.addCommand(logout_1.default);
52
- program.addCommand(workspace_1.default);
53
- program.addCommand(project_1.default);
54
- program.addCommand(api_1.default);
55
- program.action(async (_, cmd) => {
56
- if (cmd.args.length > 0) {
57
- output_1.default.exitError((0, texts_1.ERR_COMMAND_NOT_FOUND)(cmd.args[0]));
58
- }
59
- await (0, main_1.default)(program);
60
- });
15
+ const isAgentRun = process.argv[2] === 'agent' && process.argv[3] === 'run';
16
+ const program = isAgentRun
17
+ ? require('./agentIndex').default()
18
+ : require('./cliIndex').default();
61
19
  program.parse();
@@ -3,8 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- // @ts-ignore
7
- const termkit_no_lazy_require_1 = __importDefault(require("terminal-kit/lib/termkit-no-lazy-require"));
8
6
  const tunnel_1 = __importDefault(require("./tunnel/output/noninteractive/tunnel"));
9
7
  const tunnel_2 = __importDefault(require("./tunnel/output/noninteractive/config/tunnel"));
10
8
  const tunnels_1 = __importDefault(require("./tunnel/output/noninteractive/config/tunnels"));
@@ -13,7 +11,14 @@ const tunnels_2 = __importDefault(require("./tunnel/output/noninteractive/agent/
13
11
  const utils_1 = require("./utils");
14
12
  const chalk_1 = __importDefault(require("chalk"));
15
13
  const undici_1 = __importDefault(require("undici"));
16
- const terminal = termkit_no_lazy_require_1.default.terminal;
14
+ let _terminal = null;
15
+ function getTerminal() {
16
+ if (!_terminal) {
17
+ // @ts-ignore
18
+ _terminal = require('terminal-kit/lib/termkit-no-lazy-require').terminal;
19
+ }
20
+ return _terminal;
21
+ }
17
22
  class Output {
18
23
  static s;
19
24
  static _a;
@@ -81,7 +86,7 @@ class Output {
81
86
  this.clearUndici();
82
87
  this.clearTerminal();
83
88
  if (msg)
84
- terminal(`${msg}\n`);
89
+ getTerminal()(`${msg}\n`);
85
90
  process.exit(0);
86
91
  }
87
92
  static exitCode(code) {
@@ -90,7 +95,7 @@ class Output {
90
95
  process.exit(code);
91
96
  }
92
97
  static newline() {
93
- terminal('\n');
98
+ getTerminal()('\n');
94
99
  }
95
100
  static light(txt, newLine = true) {
96
101
  this.normal(this.getLightColor(txt), newLine);
@@ -102,7 +107,7 @@ class Output {
102
107
  let msg = txt;
103
108
  if (newLine)
104
109
  msg += '\n';
105
- terminal(msg);
110
+ getTerminal()(msg);
106
111
  }
107
112
  static gray(txt, newLine = true) {
108
113
  this.normal(this.getMutedColor(txt), newLine);
@@ -155,48 +160,48 @@ class Output {
155
160
  this.s.animate(0);
156
161
  this.s.destroy();
157
162
  this.s = null;
158
- terminal.eraseLine();
159
- terminal.left();
163
+ getTerminal().eraseLine();
164
+ getTerminal().left();
160
165
  }
161
166
  }
162
167
  static clearPreviousLine() {
163
168
  if (this.isStdOutTTY()) {
164
- terminal.previousLine();
165
- terminal.eraseLine();
169
+ getTerminal().previousLine();
170
+ getTerminal().eraseLine();
166
171
  }
167
172
  }
168
173
  static async spinner(txt) {
169
174
  if (!this.s && this.isStdOutTTY()) {
170
- this.s = await terminal.spinner();
175
+ this.s = await getTerminal().spinner();
171
176
  if (txt)
172
- terminal(` ${txt}`);
177
+ getTerminal()(` ${txt}`);
173
178
  }
174
179
  }
175
180
  static agentTunnels(tunnels) {
176
- const on = new tunnels_2.default(terminal, tunnels);
181
+ const on = new tunnels_2.default(getTerminal(), tunnels);
177
182
  on.start(this);
178
183
  }
179
184
  static tunnelInteractive(tunnel) {
180
185
  this.killSpinner();
181
186
  const OutputInteractiveTunnel = require('./tunnel/output/interactive/tunnel').default;
182
- const oi = new OutputInteractiveTunnel(terminal, tunnel);
187
+ const oi = new OutputInteractiveTunnel(getTerminal(), tunnel);
183
188
  oi.start();
184
189
  }
185
190
  static tunnelNonInteractive(tunnel) {
186
191
  this.killSpinner();
187
- const on = new tunnel_1.default(terminal, tunnel);
192
+ const on = new tunnel_1.default(getTerminal(), tunnel);
188
193
  on.start();
189
194
  }
190
195
  static newCliVersion(version) {
191
- terminal.gray(`New version available (${version}). Run `);
192
- terminal(' bdy version ');
193
- terminal.gray(`for details.\n\n`);
196
+ getTerminal().gray(`New version available (${version}). Run `);
197
+ getTerminal()(' bdy version ');
198
+ getTerminal().gray(`for details.\n\n`);
194
199
  }
195
200
  static newCliDockerVersion(version) {
196
- terminal.gray((0, texts_1.TXT_NEW_CLI_DOCKER_VERSION)(version));
201
+ getTerminal().gray((0, texts_1.TXT_NEW_CLI_DOCKER_VERSION)(version));
197
202
  }
198
203
  static newAgentVersion() {
199
- terminal.gray(texts_1.TXT_NEW_AGENT_VERSION);
204
+ getTerminal().gray(texts_1.TXT_NEW_AGENT_VERSION);
200
205
  }
201
206
  static isStdInTTY() {
202
207
  return process.stdin.isTTY;
@@ -229,22 +234,22 @@ class Output {
229
234
  data[i][j] = tmp.join('\n');
230
235
  }
231
236
  }
232
- terminal.table(data, {
237
+ getTerminal().table(data, {
233
238
  fit: false,
234
239
  hasBorder: false,
235
240
  firstRowTextAttr: { color: 'blue' },
236
241
  });
237
242
  }
238
243
  static configTunnels(tunnels) {
239
- const on = new tunnels_1.default(terminal, tunnels);
244
+ const on = new tunnels_1.default(getTerminal(), tunnels);
240
245
  on.start(this);
241
246
  }
242
247
  static configTunnel(tunnel) {
243
- const on = new tunnel_2.default(terminal, tunnel);
248
+ const on = new tunnel_2.default(getTerminal(), tunnel);
244
249
  on.start(this);
245
250
  }
246
251
  static handleSignals() {
247
- terminal.on('key', (key) => {
252
+ getTerminal().on('key', (key) => {
248
253
  if (key === 'CTRL_C' || key === 'ESCAPE') {
249
254
  Output.exitNormal('\nCanceled\n');
250
255
  }
@@ -419,10 +424,12 @@ class Output {
419
424
  }
420
425
  static clearTerminal() {
421
426
  this.killSpinner();
422
- terminal.styleReset();
423
- terminal.fullscreen(false);
424
- terminal.hideCursor(false);
425
- terminal.grabInput(false);
427
+ if (!_terminal)
428
+ return;
429
+ _terminal.styleReset();
430
+ _terminal.fullscreen(false);
431
+ _terminal.hideCursor(false);
432
+ _terminal.grabInput(false);
426
433
  }
427
434
  static exitError(err) {
428
435
  this.clearUndici();
@@ -440,7 +447,7 @@ class Output {
440
447
  if (isDebug)
441
448
  msg += `\n${e.stack}`;
442
449
  }
443
- terminal.red.error(`${msg}\n`);
450
+ getTerminal().red.error(`${msg}\n`);
444
451
  process.exit(1);
445
452
  }
446
453
  }
@@ -38,13 +38,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  const basic_auth_1 = __importDefault(require("basic-auth"));
40
40
  const utils_1 = require("../utils");
41
- const sshKeygen_1 = require("../sshKeygen");
42
41
  const latency_1 = __importDefault(require("./latency"));
43
- const client_1 = __importDefault(require("./ssh/client"));
44
42
  const events_1 = __importDefault(require("events"));
45
43
  const tcp_1 = __importDefault(require("./tcp"));
46
- const tls_1 = __importDefault(require("./server/tls"));
47
- const ssh_1 = __importDefault(require("./server/ssh"));
48
44
  const logger_1 = __importDefault(require("../logger"));
49
45
  const identification_1 = __importDefault(require("./identification"));
50
46
  const http_1 = __importDefault(require("./http"));
@@ -350,7 +346,7 @@ class Tunnel extends events_1.default {
350
346
  super();
351
347
  this.httpAuthClient = {};
352
348
  if (!sshHostKey)
353
- sshHostKey = (0, sshKeygen_1.createSshHostKey)();
349
+ sshHostKey = require('../sshKeygen').createSshHostKey();
354
350
  this.agent = agent;
355
351
  this.id = id;
356
352
  this.cipherKey = node_crypto_1.default
@@ -1203,8 +1199,10 @@ class Tunnel extends events_1.default {
1203
1199
  if (this.type === tunnel_1.TUNNEL_TYPE.TLS &&
1204
1200
  this.terminate === tunnel_1.TUNNEL_TERMINATE_AT.AGENT) {
1205
1201
  // tls
1206
- this.tls = new tls_1.default(this.key, this.cert, this.ca);
1207
- this.tls.on(tunnel_1.TUNNEL_EVENT.TLS_SOCKET, (socket) => this.tlsSocket(socket));
1202
+ const ServerTlsImpl = require('./server/tls').default;
1203
+ const tls = new ServerTlsImpl(this.key, this.cert, this.ca);
1204
+ tls.on(tunnel_1.TUNNEL_EVENT.TLS_SOCKET, (socket) => this.tlsSocket(socket));
1205
+ this.tls = tls;
1208
1206
  }
1209
1207
  else if (this.type === tunnel_1.TUNNEL_TYPE.HTTP) {
1210
1208
  // http
@@ -1225,18 +1223,21 @@ class Tunnel extends events_1.default {
1225
1223
  }
1226
1224
  else if (this.type === tunnel_1.TUNNEL_TYPE.SSH) {
1227
1225
  // ssh server
1228
- this.sshServer = new ssh_1.default(this.agent, this.sshClientUser || '', this.sshClientPassword || '', this.sshHostKey);
1226
+ const ServerSsh = require('./server/ssh').default;
1227
+ this.sshServer = new ServerSsh(this.agent, this.sshClientUser || '', this.sshClientPassword || '', this.sshHostKey);
1229
1228
  }
1230
1229
  // ssh
1231
- this.ssh = new client_1.default(this.sshIp, this.sshPort, this.sshUser, this.sshPassword);
1232
- this.ssh.on(tunnel_1.TUNNEL_SSH_EVENT.CONNECTED, () => this.sshConnected());
1233
- this.ssh.on(tunnel_1.TUNNEL_SSH_EVENT.DISCONNECTED, () => this.sshDisconnected());
1234
- this.ssh.on(tunnel_1.TUNNEL_SSH_EVENT.STREAM_TCP, (stream) => this.sshStreamTcp(stream));
1235
- this.ssh.on(tunnel_1.TUNNEL_SSH_EVENT.STREAM_TLS, (stream) => this.sshStreamTls(stream));
1236
- this.ssh.on(tunnel_1.TUNNEL_SSH_EVENT.STREAM_HTTP1, (stream, info, ip) => this.sshStreamHttp1(stream, info, ip));
1237
- this.ssh.on(tunnel_1.TUNNEL_SSH_EVENT.STREAM_HTTP2, (stream, info, ip) => this.sshStreamHttp2(stream, info, ip));
1238
- this.ssh.on(tunnel_1.TUNNEL_SSH_EVENT.STREAM_SSH, (stream) => this.sshStreamSsh(stream));
1239
- this.ssh.openKeepAlive();
1230
+ const SshClientImpl = require('./ssh/client').default;
1231
+ const ssh = new SshClientImpl(this.sshIp, this.sshPort, this.sshUser, this.sshPassword);
1232
+ ssh.on(tunnel_1.TUNNEL_SSH_EVENT.CONNECTED, () => this.sshConnected());
1233
+ ssh.on(tunnel_1.TUNNEL_SSH_EVENT.DISCONNECTED, () => this.sshDisconnected());
1234
+ ssh.on(tunnel_1.TUNNEL_SSH_EVENT.STREAM_TCP, (stream) => this.sshStreamTcp(stream));
1235
+ ssh.on(tunnel_1.TUNNEL_SSH_EVENT.STREAM_TLS, (stream) => this.sshStreamTls(stream));
1236
+ ssh.on(tunnel_1.TUNNEL_SSH_EVENT.STREAM_HTTP1, (stream, info, ip) => this.sshStreamHttp1(stream, info, ip));
1237
+ ssh.on(tunnel_1.TUNNEL_SSH_EVENT.STREAM_HTTP2, (stream, info, ip) => this.sshStreamHttp2(stream, info, ip));
1238
+ ssh.on(tunnel_1.TUNNEL_SSH_EVENT.STREAM_SSH, (stream) => this.sshStreamSsh(stream));
1239
+ ssh.openKeepAlive();
1240
+ this.ssh = ssh;
1240
1241
  }
1241
1242
  stop(emitEvent = true) {
1242
1243
  if (!this.started)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bdy",
3
3
  "preferGlobal": false,
4
- "version": "1.22.15-dev",
4
+ "version": "1.22.16-dev",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",
7
7
  "scripts": {