@mablhq/mabl-cli 1.26.0 → 1.29.1

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/util/asyncUtil.js CHANGED
@@ -2,18 +2,20 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.filterAsync = exports.mapAsync = exports.TimeoutError = exports.promiseWithTimeout = void 0;
4
4
  const loggingProvider_1 = require("../providers/logging/loggingProvider");
5
- async function promiseWithTimeout(promise, timeoutMillis, description, timeoutType = 'mabl promise timeout') {
5
+ async function promiseWithTimeout(promise, timeoutMillis, description, timeoutType = 'mabl promise timeout', printToConsole = true) {
6
6
  const startTimeMillis = new Date().getTime();
7
- const { timer, cancelTimer } = startTimer(timeoutMillis, description, timeoutType);
7
+ const { timer, cancelTimer, errorMessage } = startTimer(timeoutMillis, description, timeoutType);
8
8
  try {
9
9
  const result = await Promise.race([timer, promise]);
10
- if (loggingProvider_1.logger.isDebugEnabled()) {
10
+ if (loggingProvider_1.logger.isDebugEnabled() && printToConsole) {
11
11
  loggingProvider_1.logger.debug(`"${description}" completed in ${new Date().getTime() - startTimeMillis}ms`);
12
12
  }
13
13
  return result;
14
14
  }
15
15
  catch (error) {
16
- if (error instanceof TimeoutError) {
16
+ if (error instanceof TimeoutError &&
17
+ printToConsole &&
18
+ error.message === errorMessage) {
17
19
  loggingProvider_1.logger.warn(error.message);
18
20
  }
19
21
  throw error;
@@ -35,13 +37,15 @@ class TimeoutError extends Error {
35
37
  exports.TimeoutError = TimeoutError;
36
38
  const startTimer = (timeoutMillis, description, timeoutType) => {
37
39
  let timeout;
40
+ const timeoutError = new TimeoutError(timeoutMillis, description, timeoutType);
38
41
  const promise = new Promise((_resolve, reject) => {
39
- timeout = global.setTimeout(() => reject(new TimeoutError(timeoutMillis, description, timeoutType)), timeoutMillis);
42
+ timeout = global.setTimeout(() => reject(timeoutError), timeoutMillis);
40
43
  timeout.unref();
41
44
  });
42
45
  return {
43
46
  timer: promise,
44
47
  cancelTimer: () => global.clearTimeout(timeout),
48
+ errorMessage: timeoutError.message,
45
49
  };
46
50
  };
47
51
  function mapAsync(array, callback) {
package/util/httpUtil.js CHANGED
@@ -28,6 +28,7 @@ const cliConfigProvider_1 = require("../providers/cliConfigProvider");
28
28
  const https = __importStar(require("https"));
29
29
  const pureUtil_1 = require("./pureUtil");
30
30
  const https_proxy_agent_1 = require("https-proxy-agent");
31
+ const hpagent_1 = require("hpagent");
31
32
  exports.USER_AGENT = `${(0, pureUtil_1.getCliName)()}@${(0, pureUtil_1.getCliVersion)()}`;
32
33
  exports.USER_AGENT_HEADER = 'User-Agent';
33
34
  exports.EXECUTION_ENGINE_SSL_VERIFY = false;
@@ -51,7 +52,7 @@ function axiosProxyConfig(httpConfig) {
51
52
  if ((_a = httpConfig.proxyHost) === null || _a === void 0 ? void 0 : _a.href) {
52
53
  config.proxy = proxyUrlToPortConfig(httpConfig.proxyHost);
53
54
  }
54
- return maybeGetModifiedAxiosConfigForHttpProxy(config, httpConfig.sslVerify);
55
+ return maybeGetModifiedAxiosConfigForHttpProxy(config, httpConfig.sslVerify, httpConfig.proxyType);
55
56
  }
56
57
  exports.axiosProxyConfig = axiosProxyConfig;
57
58
  function escapeRegexDots(input) {
@@ -80,7 +81,7 @@ function proxyUrlToPortConfig(proxyUrl) {
80
81
  return config;
81
82
  }
82
83
  exports.proxyUrlToPortConfig = proxyUrlToPortConfig;
83
- function maybeGetModifiedAxiosConfigForHttpProxy(config, sslVerify) {
84
+ function maybeGetModifiedAxiosConfigForHttpProxy(config, sslVerify, proxyType) {
84
85
  var _a, _b;
85
86
  if (config.proxy &&
86
87
  (((_a = config.proxy) === null || _a === void 0 ? void 0 : _a.protocol) === 'http:' || ((_b = config.proxy) === null || _b === void 0 ? void 0 : _b.protocol) === 'http')) {
@@ -89,16 +90,35 @@ function maybeGetModifiedAxiosConfigForHttpProxy(config, sslVerify) {
89
90
  };
90
91
  newConfig.proxy = false;
91
92
  const authConfig = config.proxy.auth;
92
- const configOptions = {
93
- host: config.proxy.host,
94
- port: config.proxy.port,
95
- auth: authConfig
96
- ? `${authConfig.username}:${authConfig.password}`
97
- : undefined,
98
- rejectUnauthorized: sslVerify !== false,
99
- };
100
- newConfig.httpsAgent = new https_proxy_agent_1.HttpsProxyAgent(configOptions);
101
- newConfig.httpAgent = new https_proxy_agent_1.HttpsProxyAgent(configOptions);
93
+ if (proxyType === 'current') {
94
+ let proxyString = 'http://';
95
+ if (authConfig !== undefined) {
96
+ proxyString += `${authConfig.username}:${authConfig.password}@`;
97
+ }
98
+ proxyString += `${config.proxy.host}:${config.proxy.port}`;
99
+ const agentConfig = {
100
+ keepAlive: true,
101
+ keepAliveMsecs: 1000,
102
+ maxSockets: 256,
103
+ maxFreeSockets: 256,
104
+ proxy: proxyString,
105
+ rejectUnauthorized: sslVerify !== false,
106
+ };
107
+ newConfig.httpsAgent = new hpagent_1.HttpsProxyAgent(agentConfig);
108
+ newConfig.httpAgent = new hpagent_1.HttpsProxyAgent(agentConfig);
109
+ }
110
+ else {
111
+ const configOptions = {
112
+ host: config.proxy.host,
113
+ port: config.proxy.port,
114
+ auth: authConfig
115
+ ? `${authConfig.username}:${authConfig.password}`
116
+ : undefined,
117
+ rejectUnauthorized: sslVerify !== false,
118
+ };
119
+ newConfig.httpsAgent = new https_proxy_agent_1.HttpsProxyAgent(configOptions);
120
+ newConfig.httpAgent = new https_proxy_agent_1.HttpsProxyAgent(configOptions);
121
+ }
102
122
  return newConfig;
103
123
  }
104
124
  return config;