Skip to content

Commit 05c63d5

Browse files
Chore: Master Merge and Conflict resolution
2 parents fc30d6f + 295c7a9 commit 05c63d5

13 files changed

+143
-71
lines changed

bin/commands/info.js

+13-8
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ const config = require("../helpers/config"),
66
utils = require("../helpers/utils"),
77
getInitialDetails = require('../helpers/getInitialDetails').getInitialDetails;
88

9+
const { setAxiosProxy } = require('../helpers/helper');
10+
911
module.exports = function info(args, rawArgs) {
1012
let bsConfigPath = utils.getConfigPath(args.cf);
1113

@@ -45,15 +47,18 @@ module.exports = function info(args, rawArgs) {
4547
let message = null;
4648
let messageType = null;
4749
let errorCode = null;
48-
50+
51+
options.config = {
52+
auth: {
53+
username: bsConfig.auth.username,
54+
password: bsConfig.auth.access_key
55+
},
56+
headers: options.headers
57+
};
58+
setAxiosProxy(options.config);
59+
4960
try {
50-
const response = await axios.get(options.url, {
51-
auth: {
52-
username: bsConfig.auth.username,
53-
password: bsConfig.auth.access_key
54-
},
55-
headers: options.headers
56-
});
61+
const response = await axios.get(options.url, options.config);
5762
let build = null;
5863
try {
5964
build = response.data;

bin/commands/runs.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ module.exports = function run(args, rawArgs) {
377377
});
378378
} else if(!turboScaleSession){
379379
let stacktraceUrl = getStackTraceUrl();
380-
downloadBuildStacktrace(stacktraceUrl).then((message) => {
380+
downloadBuildStacktrace(stacktraceUrl, bsConfig).then((message) => {
381381
utils.sendUsageReport(bsConfig, args, message, Constants.messageTypes.SUCCESS, null, buildReportData, rawArgs);
382382
}).catch((err) => {
383383
let message = `Downloading build stacktrace failed with statuscode: ${err}. Please visit ${data.dashboard_url} for additional details.`;

bin/helpers/build.js

+12-7
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ const config = require('./config'),
77
utils = require('../helpers/utils'),
88
logger = require('../helpers/logger').winstonLogger;
99

10+
const { setAxiosProxy } = require('./helper');
11+
1012
const createBuild = (bsConfig, zip) => {
1113
return new Promise(function (resolve, reject) {
1214
capabilityHelper.caps(bsConfig, zip).then(async function(data){
@@ -26,14 +28,17 @@ const createBuild = (bsConfig, zip) => {
2628
options.url = Constants.turboScaleObj.buildUrl;
2729
}
2830

31+
const axiosConfig = {
32+
auth: {
33+
username: options.auth.user,
34+
password: options.auth.password
35+
},
36+
headers: options.headers
37+
}
38+
setAxiosProxy(axiosConfig);
39+
2940
try {
30-
const response = await axios.post(options.url, data, {
31-
auth: {
32-
username: options.auth.user,
33-
password: options.auth.password
34-
},
35-
headers: options.headers
36-
});
41+
const response = await axios.post(options.url, data, axiosConfig);
3742
let build = null;
3843
try {
3944
build = response.data;

bin/helpers/buildArtifacts.js

+16-16
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const HttpsProxyAgent = require('https-proxy-agent');
1313
const FormData = require('form-data');
1414
const decompress = require('decompress');
1515
const unzipper = require("unzipper");
16+
const { setAxiosProxy } = require('./helper');
1617

1718
let BUILD_ARTIFACTS_TOTAL_COUNT = 0;
1819
let BUILD_ARTIFACTS_FAIL_COUNT = 0;
@@ -110,10 +111,12 @@ const downloadAndUnzip = async (filePath, fileName, url) => {
110111
logger.debug(`Downloading build artifact for: ${filePath}`)
111112
return new Promise(async (resolve, reject) => {
112113
try {
113-
const response = await axios.get(url, {
114+
const axiosConfig = {
114115
responseType: 'stream',
115116
validateStatus: status => (status >= 200 && status < 300) || status === 404
116-
});
117+
};
118+
setAxiosProxy(axiosConfig);
119+
const response = await axios.get(url, axiosConfig);
117120
if(response.status != 200) {
118121
if (response.status === 404) {
119122
reject(Constants.userMessages.DOWNLOAD_BUILD_ARTIFACTS_NOT_FOUND);
@@ -195,16 +198,19 @@ const sendUpdatesToBstack = async (bsConfig, buildId, args, options, rawArgs, bu
195198
}
196199

197200
options.formData = data.toString();
201+
const axiosConfig = {
202+
auth: {
203+
username: options.auth.username,
204+
password: options.auth.password
205+
},
206+
headers: options.headers
207+
};
208+
setAxiosProxy(axiosConfig);
209+
198210
let responseData = null;
199211
return new Promise (async (resolve, reject) => {
200212
try {
201-
const response = await axios.post(options.url, data, {
202-
auth: {
203-
username: options.auth.username,
204-
password: options.auth.password
205-
},
206-
headers: options.headers
207-
});
213+
const response = await axios.post(options.url, data, axiosConfig);
208214
try {
209215
responseData = response.data;
210216
} catch(e) {
@@ -253,13 +259,7 @@ exports.downloadBuildArtifacts = async (bsConfig, buildId, args, rawArgs, buildR
253259
auth: options.auth,
254260
headers: options.headers
255261
}
256-
if(process.env.HTTP_PROXY){
257-
options.config.proxy = false;
258-
options.config.httpAgent = new HttpsProxyAgent(process.env.HTTP_PROXY);
259-
} else if (process.env.HTTPS_PROXY){
260-
options.config.proxy = false;
261-
options.config.httpAgent = new HttpsProxyAgent(process.env.HTTPS_PROXY);
262-
}
262+
setAxiosProxy(options.config);
263263
let response;
264264
try {
265265
response = await axios.get(options.url, options.config);

bin/helpers/checkUploaded.js

+12-7
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const crypto = require('crypto'),
1111
utils = require('./utils'),
1212
logger = require('./logger').winstonLogger;
1313

14+
const { setAxiosProxy } = require('./helper');
1415

1516
const checkSpecsMd5 = (runSettings, args, instrumentBlocks) => {
1617
return new Promise(function (resolve, reject) {
@@ -124,14 +125,18 @@ const checkUploadedMd5 = (bsConfig, args, instrumentBlocks) => {
124125
}
125126

126127
instrumentBlocks.markBlockStart("checkAlreadyUploaded.railsCheck");
128+
129+
const axiosConfig = {
130+
auth: {
131+
username: options.auth.user,
132+
password: options.auth.password
133+
},
134+
headers: options.headers
135+
};
136+
setAxiosProxy(axiosConfig);
137+
127138
try {
128-
const response = await axios.post(options.url, options.body, {
129-
auth: {
130-
username: options.auth.user,
131-
password: options.auth.password
132-
},
133-
headers: options.headers
134-
})
139+
const response = await axios.post(options.url, options.body, axiosConfig);
135140
let zipData = null;
136141
try {
137142
zipData = response.data;

bin/helpers/downloadBuildStacktrace.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
'use strict';
22
const { default: axios } = require('axios');
3+
const { setAxiosProxy } = require('./helper');
4+
5+
const downloadBuildStacktrace = async (url, bsConfig) => {
6+
const axiosConfig = {
7+
auth: {
8+
username: bsConfig.auth.username,
9+
password: bsConfig.auth.access_key
10+
},
11+
responseType: 'stream',
12+
};
13+
setAxiosProxy(axiosConfig);
314

4-
const downloadBuildStacktrace = async (url) => {
515
return new Promise(async (resolve, reject) => {
616
try {
7-
const response = await axios.get(url, { responseType: 'stream' });
17+
const response = await axios.get(url, axiosConfig);
818
if (response.status === 200) {
919
response.data.pipe(process.stdout);
1020
let error = null;

bin/helpers/getInitialDetails.js

+10-4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ const logger = require('./logger').winstonLogger,
55
config = require("./config"),
66
Constants = require('./constants');
77

8+
const { setAxiosProxy } = require('./helper');
9+
810
exports.getInitialDetails = (bsConfig, args, rawArgs) => {
911
return new Promise(async (resolve, reject) => {
1012
let options = {
@@ -18,11 +20,15 @@ exports.getInitialDetails = (bsConfig, args, rawArgs) => {
1820
}
1921
};
2022
let responseData = {};
23+
24+
const axiosConfig = {
25+
auth: options.auth,
26+
headers: options.headers,
27+
}
28+
setAxiosProxy(axiosConfig);
29+
2130
try {
22-
const response = await axios.get(options.url, {
23-
auth: options.auth,
24-
headers: options.headers,
25-
});
31+
const response = await axios.get(options.url, axiosConfig);
2632
try {
2733
responseData = response.data;
2834
} catch (e) {

bin/helpers/helper.js

+8
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const pGitconfig = promisify(gitconfig);
1818
const { readCypressConfigFile } = require('./readCypressConfigUtil');
1919
const { MAX_GIT_META_DATA_SIZE_IN_BYTES, GIT_META_DATA_TRUNCATED } = require('./constants')
2020
const CrashReporter = require('../testObservability/crashReporter');
21+
const HttpsProxyAgent = require('https-proxy-agent');
2122

2223
exports.debug = (text, shouldReport = false, throwable = null) => {
2324
if (process.env.BROWSERSTACK_OBSERVABILITY_DEBUG === "true" || process.env.BROWSERSTACK_OBSERVABILITY_DEBUG === "1") {
@@ -441,6 +442,13 @@ exports.truncateString = (field, truncateSizeInBytes) => {
441442
return field;
442443
};
443444

445+
exports.setAxiosProxy = (axiosConfig) => {
446+
if (process.env.HTTP_PROXY || process.env.HTTPS_PROXY) {
447+
const httpProxy = process.env.HTTP_PROXY || process.env.HTTPS_PROXY
448+
axiosConfig.httpsAgent = new HttpsProxyAgent(httpProxy);
449+
};
450+
};
451+
444452
exports.combineMacWinNpmDependencies = (runSettings) => {
445453
return Object.assign({}, runSettings.npm_dependencies, runSettings.win_npm_dependencies || {}, runSettings.mac_npm_dependencies || {})
446454
};

bin/helpers/reporterHTML.js

+18-8
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ const fs = require('fs'),
99
decompress = require('decompress');
1010
const { isTurboScaleSession } = require('../helpers/atsHelper');
1111

12+
const { setAxiosProxy } = require('./helper');
13+
1214
let reportGenerator = async (bsConfig, buildId, args, rawArgs, buildReportData, cb) => {
1315
let options = {
1416
url: `${config.buildUrl}${buildId}/custom_report`,
@@ -31,14 +33,18 @@ let reportGenerator = async (bsConfig, buildId, args, rawArgs, buildReportData,
3133
let messageType = null;
3234
let errorCode = null;
3335
let build;
36+
37+
const axiosConfig = {
38+
auth: {
39+
username: options.auth.user,
40+
password: options.auth.password
41+
},
42+
headers: options.headers
43+
}
44+
setAxiosProxy(axiosConfig);
45+
3446
try {
35-
const response = await axios.get(options.url, {
36-
auth: {
37-
username: options.auth.user,
38-
password: options.auth.password
39-
},
40-
headers: options.headers
41-
});
47+
const response = await axios.get(options.url, axiosConfig);
4248
logger.debug('Received reports data from upstream.');
4349
try {
4450
build = response.data;
@@ -120,7 +126,11 @@ function getReportResponse(filePath, fileName, reportJsonUrl) {
120126
logger.debug(`Fetching build reports zip.`)
121127
return new Promise(async (resolve, reject) => {
122128
try {
123-
const response = await axios.get(reportJsonUrl, {responseType: 'stream'});
129+
const axiosConfig = {
130+
responseType: 'stream',
131+
};
132+
setAxiosProxy(axiosConfig);
133+
const response = await axios.get(reportJsonUrl, axiosConfig);
124134
if(response.status === 200) {
125135
//ensure that the user can call `then()` only when the file has
126136
//been downloaded entirely.

bin/helpers/sync/syncSpecsLogs.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ const config = require("../config"),
1111
tableStream = require('table').createStream,
1212
chalk = require('chalk');
1313

14+
const { setAxiosProxy } = require('../helper');
15+
1416
let whileLoop = true, whileTries = config.retries, options, timeout = 3000, n = 2, tableConfig, stream, endTime, startTime = Date.now(), buildStarted = false;
1517
let specSummary = {
1618
"buildError": null,
@@ -139,13 +141,16 @@ let printSpecsStatus = (bsConfig, buildDetails, rawArgs, buildReportData) => {
139141

140142
let whileProcess = async (whilstCallback) => {
141143
try {
142-
const response = await axios.post(options.url, {}, {
144+
const axiosConfig = {
143145
auth: {
144146
username: options.auth.user,
145147
password: options.auth.password
146148
},
147149
headers: options.headers
148-
});
150+
};
151+
setAxiosProxy(axiosConfig);
152+
153+
const response = await axios.post(options.url, {}, axiosConfig);
149154
whileTries = config.retries; // reset to default after every successful request
150155
switch (response.status) {
151156
case 202: // get data here and print it

bin/helpers/usageReporting.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ const { default: axios } = require("axios");
1313
const axiosRetry = require("axios-retry");
1414
const { isTurboScaleSession } = require("./atsHelper");
1515

16+
const { setAxiosProxy } = require('./helper');
17+
1618
function get_version(package_name) {
1719
try {
1820
let options = { stdio: 'pipe' };
@@ -325,6 +327,11 @@ async function send(args) {
325327
retryDelay: 2000, // (default) wait for 2s before trying again
326328
};
327329

330+
const axiosConfig = {
331+
headers: options.headers,
332+
};
333+
setAxiosProxy(axiosConfig);
334+
328335
fileLogger.info(`Sending ${JSON.stringify(payload)} to ${config.usageReportingUrl}`);
329336
axiosRetry(axios,
330337
{
@@ -335,9 +342,7 @@ async function send(args) {
335342
}
336343
});
337344
try {
338-
const response = await axios.post(options.url, options.body, {
339-
headers: options.headers,
340-
});
345+
const response = await axios.post(options.url, options.body, axiosConfig);
341346
let result = {
342347
statusText: response.statusText,
343348
statusCode: response.status,

0 commit comments

Comments
 (0)