bdy 1.22.9-dev → 1.22.12-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.9-dev",
4
+ "version": "1.22.12-dev",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",
7
7
  "scripts": {
@@ -214,7 +214,7 @@ class Agent extends events_1.default {
214
214
  catch {
215
215
  // do nothing
216
216
  }
217
- process.exit(0);
217
+ output_1.default.exitNormal();
218
218
  }
219
219
  refreshIn15(fetch = true, counter = 1) {
220
220
  setTimeout(async () => {
@@ -63,10 +63,10 @@ class AgentManagerClass {
63
63
  this.connections.forEach((socket) => socket.resetAndDestroy());
64
64
  }
65
65
  this.server.close(() => {
66
- process.exit(0);
66
+ output_1.default.exitNormal();
67
67
  });
68
68
  }
69
- setTimeout(() => process.exit(0), 1000);
69
+ setTimeout(() => output_1.default.exitNormal(), 1000);
70
70
  };
71
71
  process.on('SIGINT', onExit);
72
72
  process.on('SIGTERM', onExit);
@@ -51,7 +51,7 @@ const outputStatus = (installed, standalone, version, id, running, enabled, targ
51
51
  output_1.default.normal('Problems: ');
52
52
  output_1.default.error(status);
53
53
  }
54
- process.exit(0);
54
+ output_1.default.exitNormal();
55
55
  };
56
56
  commandAgentStatus.action(async () => {
57
57
  let version = '';
@@ -28,7 +28,7 @@ commandArtifactDownload.action(async (id, path, options) => {
28
28
  const workspace = input_1.default.restApiWorkspace(options.workspace);
29
29
  const project = input_1.default.restApiProject(options.project, true);
30
30
  // eslint-disable-next-line prefer-const
31
- let { identifier, version } = input_1.default.artifactSplitIdentifier(id);
31
+ let { identifier, version } = input_1.default.artifactSplitIdentifier(id, false);
32
32
  const data = await client.getArtifactVersionByIdentifier(workspace, project, identifier, version);
33
33
  if (!data || !data.domain) {
34
34
  output_1.default.exitError(texts_1.ERR_WORKSPACE_NOT_FOUND);
@@ -24,10 +24,7 @@ commandArtifactPublish.action(async (id, path, options) => {
24
24
  let dirPath = input_1.default.resolvePath(path);
25
25
  const workspace = input_1.default.restApiWorkspace(options.workspace);
26
26
  const project = input_1.default.restApiProject(options.project, true);
27
- // eslint-disable-next-line prefer-const
28
- let { identifier, version } = input_1.default.artifactSplitIdentifier(id);
29
- if (!version)
30
- version = v4();
27
+ const { identifier, version } = input_1.default.artifactSplitIdentifier(id, true);
31
28
  const client = input_1.default.restApiTokenClient();
32
29
  const data = await client.getArtifactVersionByIdentifier(workspace, project, identifier, version);
33
30
  if (!data || !data.domain) {
@@ -25,8 +25,7 @@ commandSessionCreate.action(async (command, options) => {
25
25
  const ctx = createVtContext();
26
26
  applyExecOptions(ctx, options);
27
27
  try {
28
- const browserPath = await getBrowserPath();
29
- ctx.browserPath = browserPath;
28
+ ctx.browserPath = await getBrowserPath();
30
29
  }
31
30
  catch (error) {
32
31
  output_1.default.exitError(`${error}`);
@@ -76,7 +75,7 @@ commandSessionCreate.action(async (command, options) => {
76
75
  const t2 = performance.now();
77
76
  output_1.default.normal((0, texts_1.DEBUG_EXEC_COMMAND)(t2 - t1));
78
77
  }
79
- process.exit(spawnedProcessExitCode);
78
+ output_1.default.exitCode(spawnedProcessExitCode);
80
79
  }
81
80
  catch (error) {
82
81
  await app.close();
@@ -47,6 +47,7 @@ const texts_1 = require("./texts");
47
47
  const tunnel_1 = require("./types/tunnel");
48
48
  const node_path_1 = __importStar(require("node:path"));
49
49
  const cfg_1 = __importDefault(require("./tunnel/cfg"));
50
+ const uuid_1 = require("uuid");
50
51
  class Input {
51
52
  static timeout(timeout) {
52
53
  const t = parseInt(timeout, 10);
@@ -524,16 +525,27 @@ class Input {
524
525
  }
525
526
  return w;
526
527
  }
527
- static artifactSplitIdentifier(identifier) {
528
- const s = (identifier || '').split('@');
529
- if (s.length >= 2) {
530
- return {
531
- identifier: s[0],
532
- version: s[1],
533
- };
528
+ static artifactSplitIdentifier(identifierWithVersion, generateVersion) {
529
+ let identifier;
530
+ let version;
531
+ if (identifierWithVersion.includes(':')) {
532
+ const s = identifierWithVersion.split(':');
533
+ identifier = s.shift();
534
+ version = s.join(':');
534
535
  }
536
+ else if (identifierWithVersion.includes('@')) {
537
+ const s = identifierWithVersion.split('@');
538
+ identifier = s.shift();
539
+ version = s.join('@');
540
+ }
541
+ else {
542
+ identifier = identifierWithVersion;
543
+ }
544
+ if (!version && generateVersion)
545
+ version = (0, uuid_1.v4)();
535
546
  return {
536
- identifier: s[0],
547
+ identifier,
548
+ version
537
549
  };
538
550
  }
539
551
  static restApiSandboxIsUpload(destPath) {
@@ -76,11 +76,15 @@ class Output {
76
76
  this.exitNormal(this.getGreenColor(msg));
77
77
  }
78
78
  static exitNormal(msg) {
79
- this.killSpinner();
79
+ this.clearTerminal();
80
80
  if (msg)
81
81
  terminal(`${msg}\n`);
82
82
  process.exit(0);
83
83
  }
84
+ static exitCode(code) {
85
+ this.clearTerminal();
86
+ process.exit(code);
87
+ }
84
88
  static newline() {
85
89
  terminal('\n');
86
90
  }
@@ -238,11 +242,7 @@ class Output {
238
242
  static handleSignals() {
239
243
  terminal.on('key', (key) => {
240
244
  if (key === 'CTRL_C' || key === 'ESCAPE') {
241
- terminal.fullscreen(false);
242
- terminal.hideCursor(false);
243
- terminal.grabInput(false);
244
- terminal('\nCanceled\n');
245
- process.exit(0);
245
+ Output.exitNormal('\nCanceled\n');
246
246
  }
247
247
  });
248
248
  }
@@ -398,11 +398,22 @@ class Output {
398
398
  return utils_1.REST_API_REGION.AS;
399
399
  return utils_1.REST_API_REGION.ONPREM;
400
400
  }
401
- static exitError(err) {
401
+ static clearTerminal() {
402
402
  this.killSpinner();
403
+ terminal.styleReset();
403
404
  terminal.fullscreen(false);
404
405
  terminal.hideCursor(false);
405
406
  terminal.grabInput(false);
407
+ try {
408
+ const { getGlobalDispatcher } = require('undici');
409
+ getGlobalDispatcher().close();
410
+ }
411
+ catch {
412
+ // undici not available
413
+ }
414
+ }
415
+ static exitError(err) {
416
+ this.clearTerminal();
406
417
  const isDebug = process.env.DEBUG === '1';
407
418
  let msg;
408
419
  if (err instanceof Error) {
@@ -366,9 +366,9 @@ exports.OPTION_PIPELINE_RUN_PRIORITY = 'Run priority. Can be one of "LOW", "NORM
366
366
  exports.OPTION_PIPELINE_RUN_VAR = 'Variable key:value. Can be passed multiple times to pass multiple variables';
367
367
  exports.OPTION_PIPELINE_RUN_DELAY = 'The date when the execution should be run. Should be set in the format: 2016-11-18T12:38:16.000Z or 30s, 10m, 3h10m30s';
368
368
  exports.OPTION_PIPELINE_RUN_ARGUMENT = 'Human-readable ID of the pipeline';
369
- exports.OPTION_ARTIFACT_PUBLISH_PATH = 'Path to the directory or file';
370
- exports.OPTION_ARTIFACT_DOWNLOAD_PATH = 'Path to the directory or file';
371
- exports.OPTION_ARTIFACT_ID = 'Human-readable ID of the artifact and optionally version: artifact@version';
369
+ exports.OPTION_ARTIFACT_PUBLISH_PATH = 'Path to the directory or file which will be published';
370
+ exports.OPTION_ARTIFACT_DOWNLOAD_PATH = 'Path to the directory where version will be downloaded';
371
+ exports.OPTION_ARTIFACT_ID = 'Human-readable ID of the artifact and optionally version: artifact:version or artifact@version';
372
372
  exports.OPTION_ARTIFACT_PUBLISH_CREATE = 'Create artifact if not exists';
373
373
  exports.OPTION_ARTIFACT_PUBLISH_OVERWRITE_VERSION = 'Allow overwriting existing version';
374
374
  exports.OPTION_ARTIFACT_DOWNLOAD_MERGE = 'Merge contents of the directory with artifact';
@@ -20,7 +20,7 @@ const openSocket = (port, path) => {
20
20
  };
21
21
  const makeRequest = async (port, path, body) => {
22
22
  const c = new AbortController();
23
- setTimeout(() => {
23
+ const timer = setTimeout(() => {
24
24
  c.abort();
25
25
  }, TIMEOUT);
26
26
  logger_1.default.debug(`TUNNEL API AGENT REQUEST: :${port}${path}`);
@@ -31,6 +31,7 @@ const makeRequest = async (port, path, body) => {
31
31
  method: 'POST',
32
32
  signal: c.signal,
33
33
  });
34
+ clearTimeout(timer);
34
35
  logger_1.default.debug(`TUNNEL API AGENT RESPONSE: ${response.status}`);
35
36
  if (response.status === 404) {
36
37
  throw new Error(texts_1.ERR_NOT_FOUND);
@@ -9,6 +9,7 @@ const termkit_no_lazy_require_1 = __importDefault(require("terminal-kit/lib/term
9
9
  const isbinaryfile_1 = require("isbinaryfile");
10
10
  const format_1 = __importDefault(require("../../../format"));
11
11
  const tunnel_1 = require("../../../types/tunnel");
12
+ const output_1 = __importDefault(require("../../../output"));
12
13
  const COLOR_CYAN = 6;
13
14
  const COLOR_LIGHT_GRAY = 7;
14
15
  const COLOR_RED = 9;
@@ -848,10 +849,7 @@ class OutputInteractiveTunnel {
848
849
  });
849
850
  }
850
851
  terminate() {
851
- this.terminal.fullscreen(false);
852
- this.terminal.hideCursor(false);
853
- this.terminal.grabInput(false);
854
- process.exit();
852
+ output_1.default.exitNormal();
855
853
  }
856
854
  animate() {
857
855
  this.draw();
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const format_1 = __importDefault(require("../../../format"));
7
7
  const tunnel_1 = require("../../../types/tunnel");
8
+ const output_1 = __importDefault(require("../../../output"));
8
9
  class OutputNoninteractiveTunnel {
9
10
  tunnel;
10
11
  terminal;
@@ -43,7 +44,7 @@ class OutputNoninteractiveTunnel {
43
44
  this.status(t, `Response ${logRequest.method} ${logRequest.url} ${logRequest.status} in ${logRequest.time}ms`);
44
45
  }
45
46
  onStopped() {
46
- process.exit();
47
+ output_1.default.exitNormal();
47
48
  }
48
49
  start() {
49
50
  this.tunnel.on(tunnel_1.TUNNEL_EVENT.OPEN, (t) => this.onOpen(t));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bdy",
3
3
  "preferGlobal": false,
4
- "version": "1.22.9-dev",
4
+ "version": "1.22.12-dev",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",
7
7
  "scripts": {