browserstack-cypress-cli 1.31.9 → 1.32.0
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/bin/accessibility-automation/cypress/index.js +274 -276
- package/bin/accessibility-automation/helper.js +41 -27
- package/bin/accessibility-automation/plugin/index.js +2 -3
- package/bin/commands/generateReport.js +7 -8
- package/bin/commands/info.js +39 -38
- package/bin/commands/runs.js +9 -11
- package/bin/commands/stop.js +0 -1
- package/bin/helpers/atsHelper.js +48 -39
- package/bin/helpers/build.js +39 -31
- package/bin/helpers/buildArtifacts.js +91 -71
- package/bin/helpers/capabilityHelper.js +4 -0
- package/bin/helpers/checkUploaded.js +43 -33
- package/bin/helpers/downloadBuildStacktrace.js +23 -14
- package/bin/helpers/getInitialDetails.js +33 -22
- package/bin/helpers/helper.js +10 -2
- package/bin/helpers/reporterHTML.js +57 -39
- package/bin/helpers/sync/syncSpecsLogs.js +36 -23
- package/bin/helpers/usageReporting.js +52 -34
- package/bin/helpers/utils.js +96 -77
- package/bin/helpers/zipUpload.js +61 -85
- package/bin/testObservability/crashReporter/index.js +23 -14
- package/bin/testObservability/cypress/index.js +7 -7
- package/bin/testObservability/helper/helper.js +59 -43
- package/bin/testObservability/helper/requestQueueHandler.js +2 -2
- package/bin/testObservability/plugin/ipcServer.js +6 -6
- package/bin/testObservability/reporter/index.js +8 -10
- package/package.json +5 -4
|
@@ -8,9 +8,12 @@ const logger = require('./logger').winstonLogger,
|
|
|
8
8
|
Constants = require("./constants"),
|
|
9
9
|
config = require("./config");
|
|
10
10
|
|
|
11
|
-
const
|
|
11
|
+
const { default: axios } = require('axios');
|
|
12
|
+
const HttpsProxyAgent = require('https-proxy-agent');
|
|
13
|
+
const FormData = require('form-data');
|
|
12
14
|
const decompress = require('decompress');
|
|
13
15
|
const unzipper = require("unzipper");
|
|
16
|
+
const { setAxiosProxy } = require('./helper');
|
|
14
17
|
|
|
15
18
|
let BUILD_ARTIFACTS_TOTAL_COUNT = 0;
|
|
16
19
|
let BUILD_ARTIFACTS_FAIL_COUNT = 0;
|
|
@@ -107,18 +110,23 @@ const downloadAndUnzip = async (filePath, fileName, url) => {
|
|
|
107
110
|
|
|
108
111
|
logger.debug(`Downloading build artifact for: ${filePath}`)
|
|
109
112
|
return new Promise(async (resolve, reject) => {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
113
|
+
try {
|
|
114
|
+
const axiosConfig = {
|
|
115
|
+
responseType: 'stream',
|
|
116
|
+
validateStatus: status => (status >= 200 && status < 300) || status === 404
|
|
117
|
+
};
|
|
118
|
+
setAxiosProxy(axiosConfig);
|
|
119
|
+
const response = await axios.get(url, axiosConfig);
|
|
120
|
+
if(response.status != 200) {
|
|
121
|
+
if (response.status === 404) {
|
|
114
122
|
reject(Constants.userMessages.DOWNLOAD_BUILD_ARTIFACTS_NOT_FOUND);
|
|
115
123
|
}
|
|
116
|
-
const errorMsg = `Non 200 status code, got status code: ${response.
|
|
124
|
+
const errorMsg = `Non 200 status code, got status code: ${response.status}`;
|
|
117
125
|
reject(errorMsg);
|
|
118
126
|
} else {
|
|
119
127
|
//ensure that the user can call `then()` only when the file has
|
|
120
128
|
//been downloaded entirely.
|
|
121
|
-
response.pipe(writer);
|
|
129
|
+
response.data.pipe(writer);
|
|
122
130
|
let error = null;
|
|
123
131
|
writer.on('error', err => {
|
|
124
132
|
error = err;
|
|
@@ -137,7 +145,9 @@ const downloadAndUnzip = async (filePath, fileName, url) => {
|
|
|
137
145
|
resolve(true);
|
|
138
146
|
});
|
|
139
147
|
}
|
|
140
|
-
})
|
|
148
|
+
} catch (error) {
|
|
149
|
+
reject(error);
|
|
150
|
+
}
|
|
141
151
|
});
|
|
142
152
|
}
|
|
143
153
|
|
|
@@ -188,38 +198,50 @@ const sendUpdatesToBstack = async (bsConfig, buildId, args, options, rawArgs, bu
|
|
|
188
198
|
}
|
|
189
199
|
|
|
190
200
|
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
|
+
|
|
191
210
|
let responseData = null;
|
|
192
211
|
return new Promise (async (resolve, reject) => {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
responseData
|
|
203
|
-
|
|
204
|
-
if (resp.statusCode != 200) {
|
|
205
|
-
if (responseData && responseData["error"]) {
|
|
206
|
-
utils.sendUsageReport(bsConfig, args, responseData["error"], Constants.messageTypes.ERROR, 'api_failed_build_artifacts_status_update', buildReportData, rawArgs);
|
|
207
|
-
reject(responseData["error"])
|
|
208
|
-
}
|
|
212
|
+
try {
|
|
213
|
+
const response = await axios.post(options.url, data, axiosConfig);
|
|
214
|
+
try {
|
|
215
|
+
responseData = response.data;
|
|
216
|
+
} catch(e) {
|
|
217
|
+
responseData = {};
|
|
218
|
+
}
|
|
219
|
+
if (response.status != 200) {
|
|
220
|
+
if (responseData && responseData["error"]) {
|
|
221
|
+
utils.sendUsageReport(bsConfig, args, responseData["error"], Constants.messageTypes.ERROR, 'api_failed_build_artifacts_status_update', buildReportData, rawArgs);
|
|
222
|
+
reject(responseData["error"])
|
|
209
223
|
}
|
|
210
224
|
}
|
|
211
|
-
resolve()
|
|
212
|
-
})
|
|
225
|
+
resolve();
|
|
226
|
+
} catch (error) {
|
|
227
|
+
if(error.response) {
|
|
228
|
+
utils.sendUsageReport(bsConfig, args, error.response, Constants.messageTypes.ERROR, 'api_failed_build_artifacts_status_update', buildReportData, rawArgs);
|
|
229
|
+
logger.error(utils.formatRequest(error.response.statusText, error.response, error.response.data));
|
|
230
|
+
reject(errror.response.data.message);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
213
233
|
});
|
|
214
234
|
}
|
|
215
235
|
|
|
216
|
-
exports.downloadBuildArtifacts = async (bsConfig, buildId, args, rawArgs, buildReportData = null) => {
|
|
236
|
+
exports.downloadBuildArtifacts = async (bsConfig, buildId, args, rawArgs, buildReportData = null, isTurboScaleSession = false) => {
|
|
217
237
|
return new Promise ( async (resolve, reject) => {
|
|
218
238
|
BUILD_ARTIFACTS_FAIL_COUNT = 0;
|
|
219
239
|
BUILD_ARTIFACTS_TOTAL_COUNT = 0;
|
|
220
240
|
|
|
221
241
|
let options = {
|
|
222
|
-
url:
|
|
242
|
+
url: isTurboScaleSession
|
|
243
|
+
? `${config.turboScaleBuildsUrl}/${buildId}/build_artifacts`
|
|
244
|
+
: `${config.buildUrl}${buildId}/build_artifacts`,
|
|
223
245
|
auth: {
|
|
224
246
|
username: bsConfig.auth.username,
|
|
225
247
|
password: bsConfig.auth.access_key,
|
|
@@ -233,53 +255,51 @@ exports.downloadBuildArtifacts = async (bsConfig, buildId, args, rawArgs, buildR
|
|
|
233
255
|
let messageType = null;
|
|
234
256
|
let errorCode = null;
|
|
235
257
|
let buildDetails = null;
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
258
|
+
options.config = {
|
|
259
|
+
auth: options.auth,
|
|
260
|
+
headers: options.headers
|
|
261
|
+
}
|
|
262
|
+
setAxiosProxy(options.config);
|
|
263
|
+
let response;
|
|
264
|
+
try {
|
|
265
|
+
response = await axios.get(options.url, options.config);
|
|
266
|
+
buildDetails = response.data;
|
|
267
|
+
await createDirectories(buildId, buildDetails);
|
|
268
|
+
await parseAndDownloadArtifacts(buildId, buildDetails, bsConfig, args, rawArgs, buildReportData);
|
|
269
|
+
if (BUILD_ARTIFACTS_FAIL_COUNT > 0) {
|
|
270
|
+
messageType = Constants.messageTypes.ERROR;
|
|
271
|
+
message = Constants.userMessages.DOWNLOAD_BUILD_ARTIFACTS_FAILED.replace('<build-id>', buildId).replace('<machine-count>', BUILD_ARTIFACTS_FAIL_COUNT);
|
|
272
|
+
logger.error(message);
|
|
240
273
|
process.exitCode = Constants.ERROR_EXIT_CODE;
|
|
241
274
|
} else {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
} else {
|
|
259
|
-
messageType = Constants.messageTypes.SUCCESS;
|
|
260
|
-
message = Constants.userMessages.DOWNLOAD_BUILD_ARTIFACTS_SUCCESS.replace('<build-id>', buildId).replace('<user-path>', process.cwd());
|
|
261
|
-
logger.info(message);
|
|
262
|
-
}
|
|
263
|
-
await sendUpdatesToBstack(bsConfig, buildId, args, options, rawArgs, buildReportData)
|
|
264
|
-
utils.sendUsageReport(bsConfig, args, message, messageType, null, buildReportData, rawArgs);
|
|
265
|
-
}
|
|
266
|
-
} catch (err) {
|
|
275
|
+
messageType = Constants.messageTypes.SUCCESS;
|
|
276
|
+
message = Constants.userMessages.DOWNLOAD_BUILD_ARTIFACTS_SUCCESS.replace('<build-id>', buildId).replace('<user-path>', process.cwd());
|
|
277
|
+
logger.info(message);
|
|
278
|
+
}
|
|
279
|
+
await sendUpdatesToBstack(bsConfig, buildId, args, options, rawArgs, buildReportData)
|
|
280
|
+
utils.sendUsageReport(bsConfig, args, message, messageType, null, buildReportData, rawArgs);
|
|
281
|
+
} catch (err) {
|
|
282
|
+
messageType = Constants.messageTypes.ERROR;
|
|
283
|
+
errorCode = 'api_failed_build_artifacts';
|
|
284
|
+
if(err.response && err.response.status !== 200) {
|
|
285
|
+
logger.error('Downloading the build artifacts failed.');
|
|
286
|
+
logger.error(`Error: Request failed with status code ${err.response.status}`)
|
|
287
|
+
logger.error(utils.formatRequest(err.response.statusText, err.response, err.response.data));
|
|
288
|
+
utils.sendUsageReport(bsConfig, args, JSON.stringify(buildDetails), Constants.messageTypes.ERROR, 'api_failed_build_artifacts', buildReportData, rawArgs);
|
|
289
|
+
} else {
|
|
290
|
+
if (BUILD_ARTIFACTS_FAIL_COUNT > 0) {
|
|
267
291
|
messageType = Constants.messageTypes.ERROR;
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
logger.error(message);
|
|
273
|
-
} else {
|
|
274
|
-
logger.error('Downloading the build artifacts failed.');
|
|
275
|
-
}
|
|
276
|
-
utils.sendUsageReport(bsConfig, args, err, messageType, errorCode, buildReportData, rawArgs);
|
|
277
|
-
logger.error(`Error: Request failed with status code ${resp.statusCode}`)
|
|
278
|
-
logger.error(utils.formatRequest(err, resp, body));
|
|
279
|
-
process.exitCode = Constants.ERROR_EXIT_CODE;
|
|
292
|
+
message = Constants.userMessages.DOWNLOAD_BUILD_ARTIFACTS_FAILED.replace('<build-id>', buildId).replace('<machine-count>', BUILD_ARTIFACTS_FAIL_COUNT);
|
|
293
|
+
logger.error(message);
|
|
294
|
+
} else {
|
|
295
|
+
logger.error('Downloading the build artifacts failed.');
|
|
280
296
|
}
|
|
297
|
+
utils.sendUsageReport(bsConfig, args, err, messageType, errorCode, buildReportData, rawArgs);
|
|
298
|
+
logger.error(`Error: Request failed with status code ${resp.status}`)
|
|
299
|
+
logger.error(utils.formatRequest(err, resp, body));
|
|
281
300
|
}
|
|
282
|
-
|
|
283
|
-
}
|
|
301
|
+
process.exitCode = Constants.ERROR_EXIT_CODE;
|
|
302
|
+
}
|
|
303
|
+
resolve();
|
|
284
304
|
});
|
|
285
305
|
};
|
|
@@ -131,6 +131,10 @@ const caps = (bsConfig, zip) => {
|
|
|
131
131
|
obj.run_settings = JSON.stringify(bsConfig.run_settings);
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
+
obj.cypress_cli_user_agent = Utils.getUserAgent();
|
|
135
|
+
|
|
136
|
+
logger.info(`Cypress CLI User Agent: ${obj.cypress_cli_user_agent}`);
|
|
137
|
+
|
|
134
138
|
if(obj.parallels === Constants.cliMessages.RUN.DEFAULT_PARALLEL_MESSAGE) obj.parallels = undefined
|
|
135
139
|
|
|
136
140
|
if (obj.project) logger.info(`Project name is: ${obj.project}`);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
const
|
|
2
|
+
const { default: axios } = require('axios');
|
|
3
3
|
const { combineMacWinNpmDependencies } = require('./helper');
|
|
4
4
|
|
|
5
5
|
const crypto = require('crypto'),
|
|
@@ -11,6 +11,7 @@ const crypto = require('crypto'),
|
|
|
11
11
|
utils = require('./utils'),
|
|
12
12
|
logger = require('./logger').winstonLogger;
|
|
13
13
|
|
|
14
|
+
const { setAxiosProxy } = require('./helper');
|
|
14
15
|
|
|
15
16
|
const checkSpecsMd5 = (runSettings, args, instrumentBlocks) => {
|
|
16
17
|
return new Promise(function (resolve, reject) {
|
|
@@ -91,7 +92,7 @@ const checkUploadedMd5 = (bsConfig, args, instrumentBlocks) => {
|
|
|
91
92
|
}
|
|
92
93
|
|
|
93
94
|
instrumentBlocks.markBlockStart("checkAlreadyUploaded.md5Total");
|
|
94
|
-
checkSpecsMd5(bsConfig.run_settings, args, instrumentBlocks).then(function (zip_md5sum) {
|
|
95
|
+
checkSpecsMd5(bsConfig.run_settings, args, instrumentBlocks).then(async function (zip_md5sum) {
|
|
95
96
|
instrumentBlocks.markBlockStart("checkAlreadyUploaded.md5Package");
|
|
96
97
|
let npm_package_md5sum = checkPackageMd5(bsConfig.run_settings);
|
|
97
98
|
instrumentBlocks.markBlockEnd("checkAlreadyUploaded.md5Package");
|
|
@@ -116,7 +117,7 @@ const checkUploadedMd5 = (bsConfig, args, instrumentBlocks) => {
|
|
|
116
117
|
'Content-Type': 'application/json',
|
|
117
118
|
"User-Agent": utils.getUserAgent(),
|
|
118
119
|
},
|
|
119
|
-
body:
|
|
120
|
+
body: data
|
|
120
121
|
};
|
|
121
122
|
|
|
122
123
|
if (Constants.turboScaleObj.enabled) {
|
|
@@ -124,39 +125,48 @@ const checkUploadedMd5 = (bsConfig, args, instrumentBlocks) => {
|
|
|
124
125
|
}
|
|
125
126
|
|
|
126
127
|
instrumentBlocks.markBlockStart("checkAlreadyUploaded.railsCheck");
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
if (utils.
|
|
147
|
-
|
|
148
|
-
Object.assign(obj, {packageUrlPresent: false});
|
|
149
|
-
delete obj.npm_package_md5sum;
|
|
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
|
+
|
|
138
|
+
try {
|
|
139
|
+
const response = await axios.post(options.url, options.body, axiosConfig);
|
|
140
|
+
let zipData = null;
|
|
141
|
+
try {
|
|
142
|
+
zipData = response.data;
|
|
143
|
+
} catch (error) {
|
|
144
|
+
zipData = {};
|
|
145
|
+
}
|
|
146
|
+
if (response.status === 200) {
|
|
147
|
+
if (!utils.isUndefined(zipData.zipUrl)) {
|
|
148
|
+
Object.assign(obj, zipData, {zipUrlPresent: true});
|
|
150
149
|
}
|
|
151
|
-
if (utils.
|
|
152
|
-
|
|
153
|
-
Object.assign(obj, {zipUrlPresent: false});
|
|
154
|
-
delete obj.zip_md5sum;
|
|
150
|
+
if (!utils.isUndefined(zipData.npmPackageUrl)) {
|
|
151
|
+
Object.assign(obj, zipData, {packageUrlPresent: true});
|
|
155
152
|
}
|
|
156
|
-
instrumentBlocks.markBlockEnd("checkAlreadyUploaded.railsCheck");
|
|
157
|
-
resolve(obj);
|
|
158
153
|
}
|
|
159
|
-
|
|
154
|
+
if (utils.isTrueString(zipData.disableNpmSuiteCache)) {
|
|
155
|
+
bsConfig.run_settings.cache_dependencies = false;
|
|
156
|
+
Object.assign(obj, {packageUrlPresent: false});
|
|
157
|
+
delete obj.npm_package_md5sum;
|
|
158
|
+
}
|
|
159
|
+
if (utils.isTrueString(zipData.disableTestSuiteCache)) {
|
|
160
|
+
args["force-upload"] = true;
|
|
161
|
+
Object.assign(obj, {zipUrlPresent: false});
|
|
162
|
+
delete obj.zip_md5sum;
|
|
163
|
+
}
|
|
164
|
+
instrumentBlocks.markBlockEnd("checkAlreadyUploaded.railsCheck");
|
|
165
|
+
resolve(obj);
|
|
166
|
+
} catch (error) {
|
|
167
|
+
instrumentBlocks.markBlockEnd("checkAlreadyUploaded.railsCheck");
|
|
168
|
+
resolve(obj);
|
|
169
|
+
}
|
|
160
170
|
}).catch((err) => {
|
|
161
171
|
let errString = err.stack ? err.stack.toString().substring(0,100) : err.toString().substring(0,100);
|
|
162
172
|
resolve({zipUrlPresent: false, packageUrlPresent: false, error: errString});
|
|
@@ -1,28 +1,37 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
const
|
|
1
|
+
'use strict';
|
|
2
|
+
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);
|
|
3
14
|
|
|
4
|
-
const downloadBuildStacktrace = async (url) => {
|
|
5
15
|
return new Promise(async (resolve, reject) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
16
|
+
try {
|
|
17
|
+
const response = await axios.get(url, axiosConfig);
|
|
18
|
+
if (response.status === 200) {
|
|
19
|
+
response.data.pipe(process.stdout);
|
|
9
20
|
let error = null;
|
|
10
21
|
process.stdout.on('error', (err) => {
|
|
11
22
|
error = err;
|
|
12
23
|
process.stdout.close();
|
|
13
|
-
reject(response.
|
|
24
|
+
reject(response.status);
|
|
14
25
|
});
|
|
15
26
|
process.stdout.on('close', async () => {
|
|
16
|
-
if(!error) {
|
|
17
|
-
resolve(
|
|
27
|
+
if (!error) {
|
|
28
|
+
resolve('Build stacktrace downloaded successfully');
|
|
18
29
|
}
|
|
19
30
|
});
|
|
20
|
-
} else {
|
|
21
|
-
reject(response.statusCode);
|
|
22
31
|
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
}
|
|
32
|
+
} catch (error) {
|
|
33
|
+
reject(error.response.status);
|
|
34
|
+
}
|
|
26
35
|
});
|
|
27
36
|
};
|
|
28
37
|
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
1
|
+
const { default: axios } = require('axios');
|
|
2
|
+
|
|
3
|
+
const logger = require('./logger').winstonLogger,
|
|
3
4
|
utils = require('./utils'),
|
|
4
5
|
config = require("./config"),
|
|
5
6
|
Constants = require('./constants');
|
|
6
7
|
|
|
8
|
+
const { setAxiosProxy } = require('./helper');
|
|
9
|
+
|
|
7
10
|
exports.getInitialDetails = (bsConfig, args, rawArgs) => {
|
|
8
|
-
return new Promise((resolve, reject) => {
|
|
11
|
+
return new Promise(async (resolve, reject) => {
|
|
9
12
|
let options = {
|
|
10
13
|
url: config.getInitialDetails,
|
|
11
14
|
auth: {
|
|
@@ -17,28 +20,36 @@ exports.getInitialDetails = (bsConfig, args, rawArgs) => {
|
|
|
17
20
|
}
|
|
18
21
|
};
|
|
19
22
|
let responseData = {};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
|
|
24
|
+
const axiosConfig = {
|
|
25
|
+
auth: options.auth,
|
|
26
|
+
headers: options.headers,
|
|
27
|
+
}
|
|
28
|
+
setAxiosProxy(axiosConfig);
|
|
29
|
+
|
|
30
|
+
try {
|
|
31
|
+
const response = await axios.get(options.url, axiosConfig);
|
|
32
|
+
try {
|
|
33
|
+
responseData = response.data;
|
|
34
|
+
} catch (e) {
|
|
35
|
+
responseData = {};
|
|
36
|
+
}
|
|
37
|
+
if(response.status != 200) {
|
|
38
|
+
logger.warn(`Warn: Get Initial Details Request failed with status code ${response.status}`);
|
|
39
|
+
utils.sendUsageReport(bsConfig, args, responseData["error"], Constants.messageTypes.ERROR, 'get_initial_details_failed', null, rawArgs);
|
|
24
40
|
resolve({});
|
|
25
41
|
} else {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
} catch (e) {
|
|
29
|
-
responseData = {};
|
|
30
|
-
}
|
|
31
|
-
if(resp.statusCode != 200) {
|
|
32
|
-
logger.warn(`Warn: Get Initial Details Request failed with status code ${resp.statusCode}`);
|
|
33
|
-
utils.sendUsageReport(bsConfig, args, responseData["error"], Constants.messageTypes.ERROR, 'get_initial_details_failed', null, rawArgs);
|
|
34
|
-
resolve({});
|
|
35
|
-
} else {
|
|
36
|
-
if (!utils.isUndefined(responseData.grr) && responseData.grr.enabled && !utils.isUndefined(responseData.grr.urls)) {
|
|
37
|
-
config.uploadUrl = responseData.grr.urls.upload_url;
|
|
38
|
-
}
|
|
39
|
-
resolve(responseData);
|
|
42
|
+
if (!utils.isUndefined(responseData.grr) && responseData.grr.enabled && !utils.isUndefined(responseData.grr.urls)) {
|
|
43
|
+
config.uploadUrl = responseData.grr.urls.upload_url;
|
|
40
44
|
}
|
|
45
|
+
resolve(responseData);
|
|
46
|
+
}
|
|
47
|
+
} catch (error) {
|
|
48
|
+
if(error.response && error.response.status !== 200) {
|
|
49
|
+
logger.warn(`Warn: Get Initial Details Request failed with status code ${error.response.status}`);
|
|
50
|
+
utils.sendUsageReport(bsConfig, args, error.response.data["error"], Constants.messageTypes.ERROR, 'get_initial_details_failed', null, rawArgs);
|
|
41
51
|
}
|
|
42
|
-
|
|
52
|
+
resolve({});
|
|
53
|
+
}
|
|
43
54
|
});
|
|
44
55
|
};
|
package/bin/helpers/helper.js
CHANGED
|
@@ -6,7 +6,6 @@ const fs = require('fs');
|
|
|
6
6
|
const path = require('path');
|
|
7
7
|
const http = require('http');
|
|
8
8
|
const https = require('https');
|
|
9
|
-
const request = require('request');
|
|
10
9
|
const gitLastCommit = require('git-last-commit');
|
|
11
10
|
const { v4: uuidv4 } = require('uuid');
|
|
12
11
|
const os = require('os');
|
|
@@ -17,8 +16,9 @@ const { spawn, execSync } = require('child_process');
|
|
|
17
16
|
const glob = require('glob');
|
|
18
17
|
const pGitconfig = promisify(gitconfig);
|
|
19
18
|
const { readCypressConfigFile } = require('./readCypressConfigUtil');
|
|
20
|
-
const CrashReporter = require('../testObservability/crashReporter');
|
|
21
19
|
const { MAX_GIT_META_DATA_SIZE_IN_BYTES, GIT_META_DATA_TRUNCATED } = require('./constants')
|
|
20
|
+
const CrashReporter = require('../testObservability/crashReporter');
|
|
21
|
+
const HttpsProxyAgent = require('https-proxy-agent');
|
|
22
22
|
|
|
23
23
|
exports.debug = (text, shouldReport = false, throwable = null) => {
|
|
24
24
|
if (process.env.BROWSERSTACK_OBSERVABILITY_DEBUG === "true" || process.env.BROWSERSTACK_OBSERVABILITY_DEBUG === "1") {
|
|
@@ -442,6 +442,14 @@ exports.truncateString = (field, truncateSizeInBytes) => {
|
|
|
442
442
|
return field;
|
|
443
443
|
};
|
|
444
444
|
|
|
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.proxy = false;
|
|
449
|
+
axiosConfig.httpsAgent = new HttpsProxyAgent(httpProxy);
|
|
450
|
+
};
|
|
451
|
+
};
|
|
452
|
+
|
|
445
453
|
exports.combineMacWinNpmDependencies = (runSettings) => {
|
|
446
454
|
return Object.assign({}, runSettings.npm_dependencies, runSettings.win_npm_dependencies || {}, runSettings.mac_npm_dependencies || {})
|
|
447
455
|
};
|