Skip to content

Commit 45cd7dc

Browse files
Merge pull request #123 from LambdaTest/stage
Stage
2 parents 6fc2070 + e603ba0 commit 45cd7dc

File tree

5 files changed

+27
-23
lines changed

5 files changed

+27
-23
lines changed

commands/utils/httpClient.js

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
const axios = require('axios');
22
const https = require('https');
3+
const { HttpsProxyAgent } = require('https-proxy-agent');
4+
const { HttpProxyAgent } = require('http-proxy-agent');
35

46
let proxyUrl = null;
57

6-
// Handle proxy URL configuration
78
try {
89
const SMARTUI_API_PROXY = process.env.SMARTUI_API_PROXY;
910
if (SMARTUI_API_PROXY) {
@@ -15,21 +16,18 @@ try {
1516
console.error('[smartui] Invalid proxy URL:', error.message);
1617
}
1718

18-
const axiosConfig = {
19-
proxy: proxyUrl ? {
20-
host: proxyUrl.hostname,
21-
port: proxyUrl.port ? Number(proxyUrl.port) : 80,
22-
...(proxyUrl.username && proxyUrl.password ? {
23-
auth: {
24-
username: proxyUrl.username,
25-
password: proxyUrl.password
26-
}
27-
} : {})
28-
} : false
29-
};
30-
31-
// Handle certificate verification skip
32-
if (process.env.SMARTUI_API_SKIP_CERTIFICATES) {
19+
const skipCertificates = process.env.SMARTUI_API_SKIP_CERTIFICATES === 'true';
20+
21+
const axiosConfig = {};
22+
23+
if (proxyUrl) {
24+
const agentOptions = {
25+
rejectUnauthorized: !skipCertificates
26+
};
27+
28+
axiosConfig.httpsAgent = new HttpsProxyAgent(proxyUrl, agentOptions);
29+
axiosConfig.httpAgent = new HttpProxyAgent(proxyUrl,agentOptions);
30+
} else if (skipCertificates) {
3331
axiosConfig.httpsAgent = new https.Agent({
3432
rejectUnauthorized: false
3533
});

commands/utils/package.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ function checkUpdate(version, options) {
1818
.catch(function (error) {
1919
if (error.response && error.response.data && error.response.data.error) {
2020
console.log('Cannot check for updates. Error: ' + error.response.data.error.message);
21+
} else if (error.code) {
22+
console.log('Cannot check for updates. Error: ' + error.code + (error.message ? ' - ' + error.message : ''));
2123
} else {
22-
console.log('Cannot check for updates. Error: ' + error.message);
24+
console.log('Cannot check for updates. Error: ' + (error.message || JSON.stringify(error)));
2325
}
2426
});
2527
};

commands/utils/validate.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@ function validateProjectToken(options) {
3030
if (error.response) {
3131
console.log('[smartui] Error: Invalid Project Token');
3232
} else if (error.request) {
33-
console.log('[smartui] Project Token not validated. Error: ', error.message);
33+
const errorMsg = error.code ? `${error.code}${error.message ? ' - ' + error.message : ''}` : (error.message || 'Unknown error');
34+
console.log('[smartui] Project Token not validated. Error: ', errorMsg);
3435
} else {
35-
console.log('[smartui] Project Token not validated. Error: ', error.message);
36+
const errorMsg = error.code ? `${error.code}${error.message ? ' - ' + error.message : ''}` : (error.message || 'Unknown error');
37+
console.log('[smartui] Project Token not validated. Error: ', errorMsg);
3638
}
3739
process.exit(constants.ERROR_CATCHALL);
3840
});

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@lambdatest/smartui-storybook",
3-
"version": "1.1.30",
3+
"version": "1.1.31",
44
"description": "LambdaTest's command-line interface (CLI) aimed to help you run your SmartUI tests on LambdaTest platform",
55
"main": "index.js",
66
"repository": {
@@ -25,13 +25,15 @@
2525
"license": "MIT",
2626
"dependencies": {
2727
"archiver": "^5.3.1",
28-
"axios": "^1.2.2",
28+
"axios": "^1.12.0",
2929
"browserless": "^9.8.0",
3030
"chalk": "^5.2.0",
3131
"cli-table3": "^0.6.3",
3232
"commander": "^9.5.0",
3333
"finalhandler": "^1.2.0",
3434
"form-data": "^4.0.0",
35+
"http-proxy-agent": "^7.0.0",
36+
"https-proxy-agent": "^7.0.0",
3537
"jsdom": "^21.1.0",
3638
"lodash": "^4.17.21",
3739
"puppeteer": "^19.5.2",

0 commit comments

Comments
 (0)