browserstack-cypress-cli 1.11.2 → 1.13.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/commands/info.js +3 -0
- package/bin/commands/runs.js +56 -15
- package/bin/helpers/archiver.js +16 -6
- package/bin/helpers/build.js +5 -1
- package/bin/helpers/buildArtifacts.js +4 -0
- package/bin/helpers/capabilityHelper.js +73 -16
- package/bin/helpers/checkUploaded.js +7 -2
- package/bin/helpers/constants.js +25 -2
- package/bin/helpers/downloadBuildStacktrace.js +29 -0
- package/bin/helpers/packageInstaller.js +1 -1
- package/bin/helpers/reporterHTML.js +4 -4
- package/bin/helpers/sync/syncSpecsLogs.js +24 -5
- package/bin/helpers/utils.js +98 -40
- package/bin/helpers/zipUpload.js +50 -30
- package/bin/runner.js +18 -6
- package/bin/templates/configTemplate.js +1 -1
- package/package.json +25 -25
package/bin/commands/info.js
CHANGED
|
@@ -47,6 +47,7 @@ module.exports = function info(args, rawArgs) {
|
|
|
47
47
|
errorCode = 'api_failed_build_info';
|
|
48
48
|
|
|
49
49
|
logger.info(message);
|
|
50
|
+
logger.error(utils.formatRequest(err, resp, body));
|
|
50
51
|
} else {
|
|
51
52
|
let build = null;
|
|
52
53
|
try {
|
|
@@ -66,6 +67,7 @@ module.exports = function info(args, rawArgs) {
|
|
|
66
67
|
message = Constants.userMessages.API_DEPRECATED;
|
|
67
68
|
logger.info(message);
|
|
68
69
|
}
|
|
70
|
+
logger.info(utils.formatRequest(err, resp, body));
|
|
69
71
|
} else if (resp.statusCode != 200) {
|
|
70
72
|
messageType = Constants.messageTypes.ERROR;
|
|
71
73
|
errorCode = 'api_failed_build_info';
|
|
@@ -80,6 +82,7 @@ module.exports = function info(args, rawArgs) {
|
|
|
80
82
|
message = Constants.userMessages.BUILD_INFO_FAILED;
|
|
81
83
|
logger.error(message);
|
|
82
84
|
}
|
|
85
|
+
logger.error(utils.formatRequest(err, resp, body));
|
|
83
86
|
} else {
|
|
84
87
|
messageType = Constants.messageTypes.SUCCESS;
|
|
85
88
|
message = `Build info for build id: \n ${JSON.stringify(
|
package/bin/commands/runs.js
CHANGED
|
@@ -16,8 +16,10 @@ const archiver = require("../helpers/archiver"),
|
|
|
16
16
|
reportGenerator = require('../helpers/reporterHTML').reportGenerator,
|
|
17
17
|
{initTimeComponents, instrumentEventTime, markBlockStart, markBlockEnd, getTimeComponents} = require('../helpers/timeComponents'),
|
|
18
18
|
downloadBuildArtifacts = require('../helpers/buildArtifacts').downloadBuildArtifacts,
|
|
19
|
+
downloadBuildStacktrace = require('../helpers/downloadBuildStacktrace').downloadBuildStacktrace,
|
|
19
20
|
updateNotifier = require('update-notifier'),
|
|
20
21
|
pkg = require('../../package.json');
|
|
22
|
+
const { getStackTraceUrl } = require('../helpers/sync/syncSpecsLogs');
|
|
21
23
|
|
|
22
24
|
module.exports = function run(args, rawArgs) {
|
|
23
25
|
let bsConfigPath = utils.getConfigPath(args.cf);
|
|
@@ -48,6 +50,12 @@ module.exports = function run(args, rawArgs) {
|
|
|
48
50
|
// set cypress config filename
|
|
49
51
|
utils.setCypressConfigFilename(bsConfig, args);
|
|
50
52
|
|
|
53
|
+
// set cypress geo location
|
|
54
|
+
utils.setGeolocation(bsConfig, args);
|
|
55
|
+
|
|
56
|
+
// set spec timeout
|
|
57
|
+
utils.setSpecTimeout(bsConfig, args);
|
|
58
|
+
|
|
51
59
|
// accept the specs list from command line if provided
|
|
52
60
|
utils.setUserSpecs(bsConfig, args);
|
|
53
61
|
|
|
@@ -107,16 +115,16 @@ module.exports = function run(args, rawArgs) {
|
|
|
107
115
|
// warn if specFiles cross our limit
|
|
108
116
|
utils.warnSpecLimit(bsConfig, args, specFiles, rawArgs);
|
|
109
117
|
markBlockEnd('preArchiveSteps');
|
|
110
|
-
markBlockStart('
|
|
118
|
+
markBlockStart('zip');
|
|
119
|
+
markBlockStart('zip.checkAlreadyUploaded');
|
|
111
120
|
return checkUploaded.checkUploadedMd5(bsConfig, args, {markBlockStart, markBlockEnd}).then(function (md5data) {
|
|
112
|
-
markBlockEnd('checkAlreadyUploaded');
|
|
121
|
+
markBlockEnd('zip.checkAlreadyUploaded');
|
|
113
122
|
|
|
114
|
-
markBlockStart('packageInstaller');
|
|
123
|
+
markBlockStart('zip.packageInstaller');
|
|
115
124
|
return packageInstaller.packageWrapper(bsConfig, config.packageDirName, config.packageFileName, md5data, {markBlockStart, markBlockEnd}).then(function (packageData) {
|
|
116
|
-
markBlockEnd('packageInstaller');
|
|
125
|
+
markBlockEnd('zip.packageInstaller');
|
|
117
126
|
|
|
118
127
|
// Archive the spec files
|
|
119
|
-
markBlockStart('zip');
|
|
120
128
|
markBlockStart('zip.archive');
|
|
121
129
|
return archiver.archive(bsConfig.run_settings, config.fileName, args.exclude, md5data).then(function (data) {
|
|
122
130
|
markBlockEnd('zip.archive');
|
|
@@ -178,15 +186,31 @@ module.exports = function run(args, rawArgs) {
|
|
|
178
186
|
await new Promise(resolve => setTimeout(resolve, 5000));
|
|
179
187
|
|
|
180
188
|
// download build artifacts
|
|
181
|
-
if (
|
|
182
|
-
|
|
189
|
+
if (exitCode != Constants.BUILD_FAILED_EXIT_CODE) {
|
|
190
|
+
if (utils.nonEmptyArray(bsConfig.run_settings.downloads)) {
|
|
191
|
+
await downloadBuildArtifacts(bsConfig, data.build_id, args, rawArgs);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// Generate custom report!
|
|
195
|
+
reportGenerator(bsConfig, data.build_id, args, rawArgs, function(){
|
|
196
|
+
utils.sendUsageReport(bsConfig, args, `${message}\n${dashboardLink}`, Constants.messageTypes.SUCCESS, null, buildReportData, rawArgs);
|
|
197
|
+
utils.handleSyncExit(exitCode, data.dashboard_url);
|
|
198
|
+
});
|
|
199
|
+
} else {
|
|
200
|
+
let stacktraceUrl = getStackTraceUrl();
|
|
201
|
+
downloadBuildStacktrace(stacktraceUrl).then((message) => {
|
|
202
|
+
utils.sendUsageReport(bsConfig, args, message, Constants.messageTypes.SUCCESS, null, buildReportData, rawArgs);
|
|
203
|
+
}).catch((err) => {
|
|
204
|
+
let message = `Downloading build stacktrace failed with statuscode: ${err}. Please visit ${data.dashboard_url} for additional details.`;
|
|
205
|
+
logger.error(message);
|
|
206
|
+
utils.sendUsageReport(bsConfig, args, message, Constants.messageTypes.ERROR, null, buildReportData, rawArgs);
|
|
207
|
+
}).finally(() =>{
|
|
208
|
+
let terminalWidth = (process.stdout.columns) * 0.9;
|
|
209
|
+
let lineSeparator = "\n" + "-".repeat(terminalWidth);
|
|
210
|
+
logger.info(Constants.userMessages.BUILD_FAILED_ERROR)
|
|
211
|
+
process.exitCode = Constants.BUILD_FAILED_EXIT_CODE;
|
|
212
|
+
});
|
|
183
213
|
}
|
|
184
|
-
|
|
185
|
-
// Generate custom report!
|
|
186
|
-
reportGenerator(bsConfig, data.build_id, args, rawArgs, function(){
|
|
187
|
-
utils.sendUsageReport(bsConfig, args, `${message}\n${dashboardLink}`, Constants.messageTypes.SUCCESS, null, buildReportData, rawArgs);
|
|
188
|
-
utils.handleSyncExit(exitCode, data.dashboard_url);
|
|
189
|
-
});
|
|
190
214
|
});
|
|
191
215
|
} else if (utils.nonEmptyArray(bsConfig.run_settings.downloads)) {
|
|
192
216
|
logger.info(Constants.userMessages.ASYNC_DOWNLOADS.replace('<build-id>', data.build_id));
|
|
@@ -236,6 +260,9 @@ module.exports = function run(args, rawArgs) {
|
|
|
236
260
|
utils.sendUsageReport(bsConfig, args, `${message}\n${dashboardLink}`, Constants.messageTypes.SUCCESS, null, buildReportData, rawArgs);
|
|
237
261
|
return;
|
|
238
262
|
}).catch(async function (err) {
|
|
263
|
+
if (err && err.toString().includes('browserstack.geoLocation')) {
|
|
264
|
+
err = err.replace(/browserstack.geoLocation/g, 'geolocation');
|
|
265
|
+
}
|
|
239
266
|
// Build creation failed
|
|
240
267
|
logger.error(err);
|
|
241
268
|
// stop the Local instance
|
|
@@ -318,9 +345,23 @@ module.exports = function run(args, rawArgs) {
|
|
|
318
345
|
utils.sendUsageReport(bsJsonData, args, err.message, Constants.messageTypes.ERROR, utils.getErrorCodeFromErr(err), null, rawArgs);
|
|
319
346
|
process.exitCode = Constants.ERROR_EXIT_CODE;
|
|
320
347
|
}).finally(function(){
|
|
321
|
-
updateNotifier({
|
|
348
|
+
const notifier = updateNotifier({
|
|
322
349
|
pkg,
|
|
323
350
|
updateCheckInterval: 1000 * 60 * 60 * 24 * 7,
|
|
324
|
-
})
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
// Checks for update on first run.
|
|
354
|
+
// Set lastUpdateCheck to 0 to spawn the check update process as notifier sets this to Date.now() for preventing
|
|
355
|
+
// the check untill one interval period. It runs once.
|
|
356
|
+
if (!notifier.disabled && Date.now() - notifier.config.get('lastUpdateCheck') < 50) {
|
|
357
|
+
notifier.config.set('lastUpdateCheck', 0);
|
|
358
|
+
notifier.check();
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
// Set the config update as notifier clears this after reading.
|
|
362
|
+
if (notifier.update && notifier.update.current !== notifier.update.latest) {
|
|
363
|
+
notifier.config.set('update', notifier.update);
|
|
364
|
+
notifier.notify({isGlobal: true});
|
|
365
|
+
}
|
|
325
366
|
});
|
|
326
367
|
}
|
package/bin/helpers/archiver.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
const fs = require("fs")
|
|
2
|
+
const fs = require("fs"),
|
|
3
|
+
path = require("path");
|
|
3
4
|
|
|
4
5
|
const archiver = require("archiver"),
|
|
5
6
|
Constants = require('../helpers/constants'),
|
|
6
7
|
logger = require("./logger").winstonLogger,
|
|
7
|
-
utils = require('../helpers/utils')
|
|
8
|
-
path = require('path');
|
|
8
|
+
utils = require('../helpers/utils');
|
|
9
9
|
|
|
10
10
|
const archiveSpecs = (runSettings, filePath, excludeFiles, md5data) => {
|
|
11
11
|
return new Promise(function (resolve, reject) {
|
|
@@ -14,7 +14,17 @@ const archiveSpecs = (runSettings, filePath, excludeFiles, md5data) => {
|
|
|
14
14
|
}
|
|
15
15
|
var output = fs.createWriteStream(filePath);
|
|
16
16
|
|
|
17
|
-
var cypressFolderPath =
|
|
17
|
+
var cypressFolderPath = '';
|
|
18
|
+
let cypressAppendFilesZipLocation = '';
|
|
19
|
+
if (runSettings.home_directory) {
|
|
20
|
+
cypressFolderPath = runSettings.home_directory;
|
|
21
|
+
cypressAppendFilesZipLocation = runSettings.cypressZipStartLocation;
|
|
22
|
+
if (cypressAppendFilesZipLocation !== '') {
|
|
23
|
+
cypressAppendFilesZipLocation += '/';
|
|
24
|
+
}
|
|
25
|
+
} else {
|
|
26
|
+
cypressFolderPath = path.dirname(runSettings.cypressConfigFilePath);
|
|
27
|
+
}
|
|
18
28
|
|
|
19
29
|
logger.info(`Creating tests.zip with files in ${cypressFolderPath}`);
|
|
20
30
|
|
|
@@ -61,7 +71,7 @@ const archiveSpecs = (runSettings, filePath, excludeFiles, md5data) => {
|
|
|
61
71
|
|
|
62
72
|
if (Object.keys(packageJSON).length > 0) {
|
|
63
73
|
let packageJSONString = JSON.stringify(packageJSON, null, 4);
|
|
64
|
-
archive.append(packageJSONString, {name:
|
|
74
|
+
archive.append(packageJSONString, {name: `${cypressAppendFilesZipLocation}browserstack-package.json`});
|
|
65
75
|
}
|
|
66
76
|
|
|
67
77
|
// do not add cypress.json if arg provided is false
|
|
@@ -73,7 +83,7 @@ const archiveSpecs = (runSettings, filePath, excludeFiles, md5data) => {
|
|
|
73
83
|
fs.readFileSync(runSettings.cypressConfigFilePath)
|
|
74
84
|
);
|
|
75
85
|
let cypressJSONString = JSON.stringify(cypressJSON, null, 4);
|
|
76
|
-
archive.append(cypressJSONString, {name:
|
|
86
|
+
archive.append(cypressJSONString, {name: `${cypressAppendFilesZipLocation}cypress.json`});
|
|
77
87
|
}
|
|
78
88
|
|
|
79
89
|
archive.finalize();
|
package/bin/helpers/build.js
CHANGED
|
@@ -4,7 +4,8 @@ const request = require('request');
|
|
|
4
4
|
const config = require('./config'),
|
|
5
5
|
capabilityHelper = require("../helpers/capabilityHelper"),
|
|
6
6
|
Constants = require('../helpers/constants'),
|
|
7
|
-
utils = require('../helpers/utils')
|
|
7
|
+
utils = require('../helpers/utils'),
|
|
8
|
+
logger = require('../helpers/logger').winstonLogger;
|
|
8
9
|
|
|
9
10
|
const createBuild = (bsConfig, zip) => {
|
|
10
11
|
return new Promise(function (resolve, reject) {
|
|
@@ -24,6 +25,7 @@ const createBuild = (bsConfig, zip) => {
|
|
|
24
25
|
|
|
25
26
|
request.post(options, function (err, resp, body) {
|
|
26
27
|
if (err) {
|
|
28
|
+
logger.error(utils.formatRequest(err, resp, body));
|
|
27
29
|
reject(err);
|
|
28
30
|
} else {
|
|
29
31
|
let build = null;
|
|
@@ -37,9 +39,11 @@ const createBuild = (bsConfig, zip) => {
|
|
|
37
39
|
if (build) {
|
|
38
40
|
resolve(build.message);
|
|
39
41
|
} else {
|
|
42
|
+
logger.error(utils.formatRequest(err, resp, body));
|
|
40
43
|
reject(Constants.userMessages.API_DEPRECATED);
|
|
41
44
|
}
|
|
42
45
|
} else if (resp.statusCode != 201) {
|
|
46
|
+
logger.error(utils.formatRequest(err, resp, body));
|
|
43
47
|
if (build) {
|
|
44
48
|
reject(`${Constants.userMessages.BUILD_FAILED} Error: ${build.message}`);
|
|
45
49
|
} else {
|
|
@@ -162,6 +162,7 @@ const sendUpdatesToBstack = async (bsConfig, buildId, args, options, rawArgs) =>
|
|
|
162
162
|
request.post(options, function (err, resp, data) {
|
|
163
163
|
if(err) {
|
|
164
164
|
utils.sendUsageReport(bsConfig, args, err, Constants.messageTypes.ERROR, 'api_failed_build_artifacts_status_update', null, rawArgs);
|
|
165
|
+
logger.error(utils.formatRequest(err, resp, body));
|
|
165
166
|
reject(err);
|
|
166
167
|
} else {
|
|
167
168
|
try {
|
|
@@ -203,6 +204,7 @@ exports.downloadBuildArtifacts = async (bsConfig, buildId, args, rawArgs) => {
|
|
|
203
204
|
let buildDetails = null;
|
|
204
205
|
request.get(options, async function (err, resp, body) {
|
|
205
206
|
if(err) {
|
|
207
|
+
logger.error(utils.formatRequest(err, resp, body));
|
|
206
208
|
utils.sendUsageReport(bsConfig, args, err, Constants.messageTypes.ERROR, 'api_failed_build_artifacts', null, rawArgs);
|
|
207
209
|
process.exitCode = Constants.ERROR_EXIT_CODE;
|
|
208
210
|
} else {
|
|
@@ -211,6 +213,7 @@ exports.downloadBuildArtifacts = async (bsConfig, buildId, args, rawArgs) => {
|
|
|
211
213
|
if(resp.statusCode != 200) {
|
|
212
214
|
logger.error('Downloading the build artifacts failed.');
|
|
213
215
|
logger.error(`Error: Request failed with status code ${resp.statusCode}`)
|
|
216
|
+
logger.error(utils.formatRequest(err, resp, body));
|
|
214
217
|
utils.sendUsageReport(bsConfig, args, buildDetails, Constants.messageTypes.ERROR, 'api_failed_build_artifacts', null, rawArgs);
|
|
215
218
|
process.exitCode = Constants.ERROR_EXIT_CODE;
|
|
216
219
|
} else {
|
|
@@ -241,6 +244,7 @@ exports.downloadBuildArtifacts = async (bsConfig, buildId, args, rawArgs) => {
|
|
|
241
244
|
}
|
|
242
245
|
utils.sendUsageReport(bsConfig, args, err, messageType, errorCode, null, rawArgs);
|
|
243
246
|
logger.error(`Error: Request failed with status code ${resp.statusCode}`)
|
|
247
|
+
logger.error(utils.formatRequest(err, resp, body));
|
|
244
248
|
process.exitCode = Constants.ERROR_EXIT_CODE;
|
|
245
249
|
}
|
|
246
250
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
const fs = require('fs'),
|
|
2
|
+
path = require('path');
|
|
3
|
+
|
|
1
4
|
const logger = require("./logger").winstonLogger,
|
|
2
5
|
Constants = require("./constants"),
|
|
3
|
-
Utils = require("./utils")
|
|
4
|
-
fs = require('fs');
|
|
6
|
+
Utils = require("./utils");
|
|
5
7
|
|
|
6
8
|
const caps = (bsConfig, zip) => {
|
|
7
9
|
return new Promise(function (resolve, reject) {
|
|
@@ -69,21 +71,31 @@ const caps = (bsConfig, zip) => {
|
|
|
69
71
|
obj.local = true;
|
|
70
72
|
}
|
|
71
73
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
74
|
+
// binary was spawned locally
|
|
75
|
+
if(obj.local === true) {
|
|
76
|
+
if (!Utils.isUndefined(process.env.BSTACK_CYPRESS_LOCAL_BINARY_RUNNING) && process.env.BSTACK_CYPRESS_LOCAL_BINARY_RUNNING == "true") {
|
|
77
|
+
obj.localMode = null;
|
|
78
|
+
|
|
79
|
+
// Local Mode
|
|
80
|
+
if (bsConfig.connection_settings.local_mode) {
|
|
81
|
+
obj.localMode = bsConfig.connection_settings.local_mode;
|
|
82
|
+
if (bsConfig.connection_settings.user_defined_local_mode_warning) {
|
|
83
|
+
logger.warn(Constants.userMessages.INVALID_LOCAL_MODE_WARNING);
|
|
84
|
+
}
|
|
85
|
+
logger.info(`Local testing set up in ${obj.localMode} mode.`);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Local Identifier
|
|
89
|
+
obj.localIdentifier = null;
|
|
90
|
+
if (bsConfig.connection_settings.localIdentifier || bsConfig.connection_settings.local_identifier) {
|
|
91
|
+
obj.localIdentifier = bsConfig.connection_settings.localIdentifier || bsConfig.connection_settings.local_identifier;
|
|
92
|
+
logger.info(`Local testing identifier: ${obj.localIdentifier}`);
|
|
93
|
+
}
|
|
78
94
|
}
|
|
79
|
-
logger.info(`Local testing set up in ${obj.localMode} mode.`);
|
|
80
95
|
}
|
|
81
96
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
if (obj.local === true && (bsConfig.connection_settings.localIdentifier || bsConfig.connection_settings.local_identifier)) {
|
|
85
|
-
obj.localIdentifier = bsConfig.connection_settings.localIdentifier || bsConfig.connection_settings.local_identifier;
|
|
86
|
-
logger.info(`Local testing identifier: ${obj.localIdentifier}`);
|
|
97
|
+
if (!Utils.isUndefined(process.env.BSTACK_CYPRESS_LOCAL_BINARY_ALREADY_RUNNING) && process.env.BSTACK_CYPRESS_LOCAL_BINARY_ALREADY_RUNNING == "true") {
|
|
98
|
+
logger.info(Constants.userMessages.LOCAL_BINARY_ALREADY_RUNNING);
|
|
87
99
|
}
|
|
88
100
|
|
|
89
101
|
logger.info(`Local is set to: ${obj.local} (${obj.local ? Constants.userMessages.LOCAL_TRUE : Constants.userMessages.LOCAL_FALSE})`);
|
|
@@ -129,6 +141,13 @@ const caps = (bsConfig, zip) => {
|
|
|
129
141
|
})
|
|
130
142
|
}
|
|
131
143
|
|
|
144
|
+
const addCypressZipStartLocation = (runSettings) => {
|
|
145
|
+
let resolvedHomeDirectoryPath = path.resolve(runSettings.home_directory);
|
|
146
|
+
let resolvedCypressConfigFilePath = path.resolve(runSettings.cypressConfigFilePath);
|
|
147
|
+
runSettings.cypressZipStartLocation = path.dirname(resolvedCypressConfigFilePath.split(resolvedHomeDirectoryPath)[1]);
|
|
148
|
+
runSettings.cypressZipStartLocation = runSettings.cypressZipStartLocation.substring(1);
|
|
149
|
+
}
|
|
150
|
+
|
|
132
151
|
const validate = (bsConfig, args) => {
|
|
133
152
|
return new Promise(function (resolve, reject) {
|
|
134
153
|
logger.info(Constants.userMessages.VALIDATING_CONFIG);
|
|
@@ -155,8 +174,6 @@ const validate = (bsConfig, args) => {
|
|
|
155
174
|
// validate local args i.e --local-mode and --local-identifier
|
|
156
175
|
|
|
157
176
|
if( Utils.searchForOption('--local-identifier') && (Utils.isUndefined(args.localIdentifier) || (!Utils.isUndefined(args.localIdentifier) && !args.localIdentifier.trim()))) reject(Constants.validationMessages.INVALID_CLI_LOCAL_IDENTIFIER);
|
|
158
|
-
|
|
159
|
-
if( Utils.getLocalFlag(bsConfig.connection_settings) && (Utils.isUndefined(bsConfig["connection_settings"]["local_identifier"]) || ( !Utils.isUndefined(bsConfig["connection_settings"]["local_identifier"]) && !bsConfig["connection_settings"]["local_identifier"].trim()))) reject(Constants.validationMessages.INVALID_LOCAL_IDENTIFIER);
|
|
160
177
|
|
|
161
178
|
if( Utils.searchForOption('--local-mode') && ( Utils.isUndefined(args.localMode) || (!Utils.isUndefined(args.localMode) && !["always-on","on-demand"].includes(args.localMode)))) reject(Constants.validationMessages.INVALID_LOCAL_MODE);
|
|
162
179
|
|
|
@@ -164,6 +181,10 @@ const validate = (bsConfig, args) => {
|
|
|
164
181
|
|
|
165
182
|
if( Utils.searchForOption('--async') && ( !Utils.isUndefined(args.async) && bsConfig["connection_settings"]["local"])) reject(Constants.validationMessages.INVALID_LOCAL_ASYNC_ARGS);
|
|
166
183
|
|
|
184
|
+
if (bsConfig.run_settings.userProvidedGeolocation && !bsConfig.run_settings.geolocation.match(/^[A-Z]{2}$/g)) reject(Constants.validationMessages.INVALID_GEO_LOCATION);
|
|
185
|
+
|
|
186
|
+
if (bsConfig["connection_settings"]["local"] && bsConfig.run_settings.userProvidedGeolocation) reject(Constants.validationMessages.NOT_ALLOWED_GEO_LOCATION_AND_LOCAL_MODE);
|
|
187
|
+
|
|
167
188
|
// validate if config file provided exists or not when cypress_config_file provided
|
|
168
189
|
// validate the cypressProjectDir key otherwise.
|
|
169
190
|
let cypressConfigFilePath = bsConfig.run_settings.cypressConfigFilePath;
|
|
@@ -185,11 +206,47 @@ const validate = (bsConfig, args) => {
|
|
|
185
206
|
} catch(error){
|
|
186
207
|
reject(Constants.validationMessages.INVALID_CYPRESS_JSON)
|
|
187
208
|
}
|
|
209
|
+
|
|
210
|
+
//check if home_directory is present or not in user run_settings
|
|
211
|
+
if (!Utils.isUndefined(bsConfig.run_settings.home_directory)) {
|
|
212
|
+
// check if home_directory exists or not
|
|
213
|
+
if (!fs.existsSync(bsConfig.run_settings.home_directory)) {
|
|
214
|
+
reject(Constants.validationMessages.HOME_DIRECTORY_NOT_FOUND);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// check if home_directory is a directory or not
|
|
218
|
+
if (!fs.statSync(bsConfig.run_settings.home_directory).isDirectory()) {
|
|
219
|
+
reject(Constants.validationMessages.HOME_DIRECTORY_NOT_A_DIRECTORY);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// check if cypress config file (cypress.json) is a part of home_directory or not
|
|
223
|
+
if (!path.resolve(bsConfig.run_settings.cypressConfigFilePath).includes(path.resolve(bsConfig.run_settings.home_directory))) {
|
|
224
|
+
reject(Constants.validationMessages.CYPRESS_CONFIG_FILE_NOT_PART_OF_HOME_DIRECTORY);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
addCypressZipStartLocation(bsConfig.run_settings);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
if(!Utils.isUndefined(bsConfig.run_settings.spec_timeout)) {
|
|
231
|
+
if(Utils.isPositiveInteger(bsConfig.run_settings.spec_timeout.toString().trim())) {
|
|
232
|
+
if(Number(bsConfig.run_settings.spec_timeout) > Constants.SPEC_TIMEOUT_LIMIT) {
|
|
233
|
+
reject(Constants.validationMessages.SPEC_TIMEOUT_LIMIT_ERROR)
|
|
234
|
+
} else {
|
|
235
|
+
logger.info(Constants.userMessages.SPEC_LIMIT_SUCCESS_MESSAGE.replace("<x>", bsConfig.run_settings.spec_timeout));
|
|
236
|
+
}
|
|
237
|
+
} else {
|
|
238
|
+
logger.warn(Constants.userMessages.SPEC_TIMEOUT_LIMIT_WARNING)
|
|
239
|
+
}
|
|
240
|
+
} else {
|
|
241
|
+
logger.warn(Constants.validationMessages.SPEC_TIMEOUT_NOT_PASSED_ERROR);
|
|
242
|
+
}
|
|
243
|
+
|
|
188
244
|
resolve(cypressJson);
|
|
189
245
|
});
|
|
190
246
|
}
|
|
191
247
|
|
|
192
248
|
module.exports = {
|
|
193
249
|
caps,
|
|
250
|
+
addCypressZipStartLocation,
|
|
194
251
|
validate
|
|
195
252
|
}
|
|
@@ -15,7 +15,12 @@ const checkSpecsMd5 = (runSettings, args, instrumentBlocks) => {
|
|
|
15
15
|
if (args["force-upload"]) {
|
|
16
16
|
return resolve("force-upload");
|
|
17
17
|
}
|
|
18
|
-
let cypressFolderPath =
|
|
18
|
+
let cypressFolderPath = undefined;
|
|
19
|
+
if (runSettings.home_directory) {
|
|
20
|
+
cypressFolderPath = runSettings.home_directory;
|
|
21
|
+
} else {
|
|
22
|
+
cypressFolderPath = path.dirname(runSettings.cypressConfigFilePath);
|
|
23
|
+
}
|
|
19
24
|
let ignoreFiles = utils.getFilesToIgnore(runSettings, args.exclude, false);
|
|
20
25
|
let options = {
|
|
21
26
|
cwd: cypressFolderPath,
|
|
@@ -77,7 +82,7 @@ const checkUploadedMd5 = (bsConfig, args, instrumentBlocks) => {
|
|
|
77
82
|
zipUrlPresent: false,
|
|
78
83
|
packageUrlPresent: false,
|
|
79
84
|
};
|
|
80
|
-
if (args["force-upload"]
|
|
85
|
+
if (args["force-upload"]) {
|
|
81
86
|
return resolve(obj);
|
|
82
87
|
}
|
|
83
88
|
|
package/bin/helpers/constants.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
let config = require("./config");
|
|
2
|
+
let chalk = require('chalk');
|
|
2
3
|
|
|
3
4
|
const syncCLI = {
|
|
4
5
|
FAILED_SPEC_DETAILS_COL_HEADER: ['Spec', 'Status', 'Browser', 'BrowserStack Session ID'],
|
|
@@ -55,12 +56,16 @@ const userMessages = {
|
|
|
55
56
|
LOCAL_START_FAILED: "Local Testing setup failed.",
|
|
56
57
|
LOCAL_STOP_FAILED: "Local Binary stop failed.",
|
|
57
58
|
INVALID_LOCAL_MODE_WARNING: "Invalid value specified for local_mode. local_mode: (\"always-on\" | \"on-demand\"). For more info, check out https://www.browserstack.com/docs/automate/cypress/cli-reference",
|
|
59
|
+
LOCAL_BINARY_ALREADY_RUNNING: "We found an existing BrowserStack Local connection running from your account. Using the existing connection for this build. If you wish to use a new Local connection for your build, please specify a value for 'local_identifier' within 'connection_settings' in your browserstack.json config.",
|
|
58
60
|
SPEC_LIMIT_WARNING: "You might not see all your results on the dashboard because of high spec count, please consider reducing the number of spec files in this folder.",
|
|
59
61
|
DOWNLOAD_BUILD_ARTIFACTS_FAILED: "Downloading build artifacts for the build <build-id> failed for <machine-count> machines.",
|
|
60
62
|
ASYNC_DOWNLOADS: "Test artifacts as specified under 'downloads' can be downloaded after the build has completed its run, using 'browserstack-cypress generate-downloads <build-id>'",
|
|
61
63
|
DOWNLOAD_BUILD_ARTIFACTS_SUCCESS: "Your build artifact(s) have been successfully downloaded in '<user-path>/build_artifacts/<build-id>' directory",
|
|
62
64
|
LATEST_SYNTAX_TO_ACTUAL_VERSION_MESSAGE: "Your build will run using Cypress <actualVersion> as you had specified <latestSyntaxVersion>.<frameworkUpgradeMessage> Read more about supported versions here: http://browserstack.com/docs/automate/cypress/supported-versions",
|
|
63
65
|
PROCESS_KILL_MESSAGE: "Stopping the CLI and the execution of the build on BrowserStack",
|
|
66
|
+
BUILD_FAILED_ERROR: "The above stacktrace has been thrown by Cypress when we tried to run your build. If your test suite requires npm dependencies then please specify them on browserstack.json. Read more at " + chalk.blueBright("https://www.browserstack.com/docs/automate/cypress/npm-packages") + ". Also, we recommend you to try running the build locally using ‘cypress run’ and if it works fine then please reach out to support at " + chalk.blueBright("https://www.browserstack.com/contact#technical-support"),
|
|
67
|
+
SPEC_TIMEOUT_LIMIT_WARNING: "Value for the 'spec_timeout' key not in the 1-120 range. Going ahead with 30 mins as the default spec timeout. Read more about how to specify the option in https://browserstack.com/docs/automate/cypress/spec-timeout",
|
|
68
|
+
SPEC_LIMIT_SUCCESS_MESSAGE: "Spec timeout specified as <x> minutes. If any of your specs exceed the specified time limit, it would be forcibly killed by BrowserStack"
|
|
64
69
|
};
|
|
65
70
|
|
|
66
71
|
const validationMessages = {
|
|
@@ -87,6 +92,16 @@ const validationMessages = {
|
|
|
87
92
|
INVALID_LOCAL_IDENTIFIER: "Invalid value specified for local_identifier. For more info, check out https://www.browserstack.com/docs/automate/cypress/cli-reference",
|
|
88
93
|
INVALID_BROWSER_ARGS: "Aborting as an unacceptable value was passed for --browser. Read more at https://www.browserstack.com/docs/automate/cypress/cli-reference",
|
|
89
94
|
INVALID_LOCAL_ASYNC_ARGS: "Cannot run in --async mode when local is set to true. Please run the build after removing --async",
|
|
95
|
+
INVALID_GEO_LOCATION: "[BROWSERSTACK_INVALID_COUNTRY_CODE] The country code specified for 'geolocation' is invalid. For list of supported countries, refer to - https://www.browserstack.com/ip-geolocation",
|
|
96
|
+
NOT_SUPPORTED_GEO_LOCATION: "The country code you have passed for IP Geolocation is currently not supported. Please refer the link https://www.browserstack.com/ip-geolocation for a list of supported countries.",
|
|
97
|
+
NOT_AVAILABLE_GEO_LOCATION: "The country code you have passed for IP Geolocation is not available at the moment. Please try again in a few hours.",
|
|
98
|
+
ACCESS_DENIED_GEO_LOCATION: "'geolocation' (IP Geolocation feature) capability is not supported in your account. It is only available under Enterprise plans, refer https://www.browserstack.com/ip-geolocation for more details.",
|
|
99
|
+
NOT_ALLOWED_GEO_LOCATION_AND_LOCAL_MODE: "IP Geolocation feature is not available in conjunction with BrowserStack Local.",
|
|
100
|
+
HOME_DIRECTORY_NOT_FOUND: "Specified home directory could not be found. Please make sure the path of the home directory is correct.",
|
|
101
|
+
HOME_DIRECTORY_NOT_A_DIRECTORY: "Specified home directory is not a directory. The home directory can only be a directory and not a file.",
|
|
102
|
+
CYPRESS_CONFIG_FILE_NOT_PART_OF_HOME_DIRECTORY: "Could not find cypress.json within the specified home directory. Please make sure cypress.json resides within the home directory.",
|
|
103
|
+
SPEC_TIMEOUT_LIMIT_ERROR: "The maximum allowed value of 'spec_timeout' is 120. Read more on https://browserstack.com/docs/automate/cypress/spec-timeout ",
|
|
104
|
+
SPEC_TIMEOUT_NOT_PASSED_ERROR: "'spec_timeout' key not specified. Going ahead with 30 mins as the default spec timeout. Read more about how to specify the option in https://browserstack.com/docs/automate/cypress/spec-timeout "
|
|
90
105
|
};
|
|
91
106
|
|
|
92
107
|
const cliMessages = {
|
|
@@ -129,6 +144,8 @@ const cliMessages = {
|
|
|
129
144
|
CONFIG_DESCRIPTION: "Set configuration values. Separate multiple values with a comma. The values set here override any values set in your configuration file.",
|
|
130
145
|
REPORTER: "Specify the custom reporter to use",
|
|
131
146
|
REPORTER_OPTIONS: "Specify reporter options for custom reporter",
|
|
147
|
+
CYPRESS_GEO_LOCATION: "Enterprise feature to simulate website and mobile behavior from different locations.",
|
|
148
|
+
SPEC_TIMEOUT: "Specify a value for a hard timeout for each spec execution in the 1-120 mins range. Read https://browserstack.com/docs/automate/cypress/spec-timeout for more details."
|
|
132
149
|
},
|
|
133
150
|
COMMON: {
|
|
134
151
|
DISABLE_USAGE_REPORTING: "Disable usage reporting",
|
|
@@ -156,7 +173,7 @@ const messageTypes = {
|
|
|
156
173
|
NULL: null
|
|
157
174
|
}
|
|
158
175
|
|
|
159
|
-
const allowedFileTypes = ['js', 'json', 'txt', 'ts', 'feature', 'features', 'pdf', 'jpg', 'jpeg', 'png', 'zip', 'npmrc', 'xml', 'doc', 'docx', 'ppt', 'pptx', 'xls', 'xlsx', 'jsx', 'coffee', 'cjsx', 'csv', 'tsv', 'yml', 'yaml', 'env', 'mov', 'mp4', 'mp3', 'wav'];
|
|
176
|
+
const allowedFileTypes = ['js', 'json', 'txt', 'ts', 'feature', 'features', 'pdf', 'jpg', 'jpeg', 'png', 'zip', 'npmrc', 'xml', 'doc', 'docx', 'ppt', 'pptx', 'xls', 'xlsx', 'jsx', 'coffee', 'cjsx', 'csv', 'tsv', 'yml', 'yaml', 'env', 'mov', 'mp4', 'mp3', 'wav', 'gz', 'tgz', 'tiff', 'bmp', 'msg', 'gif', 'sql'];
|
|
160
177
|
|
|
161
178
|
const filesToIgnoreWhileUploading = [
|
|
162
179
|
'**/node_modules/**',
|
|
@@ -216,10 +233,14 @@ const AUTH_REGEX = /"auth" *: *{[\s\S]*?}/g
|
|
|
216
233
|
|
|
217
234
|
const ERROR_EXIT_CODE = 1;
|
|
218
235
|
|
|
236
|
+
const BUILD_FAILED_EXIT_CODE = 3;
|
|
237
|
+
|
|
219
238
|
const REDACTED = "[REDACTED]";
|
|
220
239
|
|
|
221
240
|
const REDACTED_AUTH =`auth: { "username": ${REDACTED}, "access_key": ${REDACTED} }`;
|
|
222
241
|
|
|
242
|
+
const SPEC_TIMEOUT_LIMIT = 120 // IN MINS
|
|
243
|
+
|
|
223
244
|
module.exports = Object.freeze({
|
|
224
245
|
syncCLI,
|
|
225
246
|
userMessages,
|
|
@@ -239,5 +260,7 @@ module.exports = Object.freeze({
|
|
|
239
260
|
LATEST_VERSION_SYNTAX_REGEX,
|
|
240
261
|
ERROR_EXIT_CODE,
|
|
241
262
|
AUTH_REGEX,
|
|
242
|
-
REDACTED_AUTH
|
|
263
|
+
REDACTED_AUTH,
|
|
264
|
+
BUILD_FAILED_EXIT_CODE,
|
|
265
|
+
SPEC_TIMEOUT_LIMIT
|
|
243
266
|
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
const request = require('request');
|
|
3
|
+
|
|
4
|
+
const downloadBuildStacktrace = async (url) => {
|
|
5
|
+
return new Promise(async (resolve, reject) => {
|
|
6
|
+
request.get(url).on('response', function (response) {
|
|
7
|
+
if(response.statusCode == 200) {
|
|
8
|
+
response.pipe(process.stdout);
|
|
9
|
+
let error = null;
|
|
10
|
+
process.stdout.on('error', (err) => {
|
|
11
|
+
error = err;
|
|
12
|
+
process.stdout.close();
|
|
13
|
+
reject(response.statusCode);
|
|
14
|
+
});
|
|
15
|
+
process.stdout.on('close', async () => {
|
|
16
|
+
if(!error) {
|
|
17
|
+
resolve("Build stacktrace downloaded successfully");
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
} else {
|
|
21
|
+
reject(response.statusCode);
|
|
22
|
+
}
|
|
23
|
+
}).on('end', () => {
|
|
24
|
+
resolve("Build stacktrace downloaded successfully");
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
exports.downloadBuildStacktrace = downloadBuildStacktrace;
|
|
@@ -63,7 +63,7 @@ const packageInstall = (packageDir) => {
|
|
|
63
63
|
logger.error(`Some error occurred while installing packages: ${error}`);
|
|
64
64
|
reject(`Packages were not installed successfully.`);
|
|
65
65
|
};
|
|
66
|
-
nodeProcess = spawn('npm', ['install'], {cwd: packageDir});
|
|
66
|
+
nodeProcess = spawn(/^win/.test(process.platform) ? 'npm.cmd' : 'npm', ['install'], {cwd: packageDir});
|
|
67
67
|
nodeProcess.on('close', nodeProcessCloseCallback);
|
|
68
68
|
nodeProcess.on('error', nodeProcessErrorCallback);
|
|
69
69
|
});
|
|
@@ -105,14 +105,14 @@ let reportGenerator = (bsConfig, buildId, args, rawArgs, cb) => {
|
|
|
105
105
|
let messageType = null;
|
|
106
106
|
let errorCode = null;
|
|
107
107
|
let build;
|
|
108
|
-
|
|
108
|
+
|
|
109
109
|
if (err) {
|
|
110
110
|
message = err;
|
|
111
111
|
messageType = Constants.messageTypes.ERROR;
|
|
112
112
|
errorCode = 'api_failed_build_report';
|
|
113
113
|
|
|
114
114
|
logger.error('Generating the build report failed.');
|
|
115
|
-
logger.error(
|
|
115
|
+
logger.error(utils.formatRequest(err, resp, body));
|
|
116
116
|
|
|
117
117
|
utils.sendUsageReport(bsConfig, args, message, messageType, errorCode, null, rawArgs);
|
|
118
118
|
return;
|
|
@@ -145,7 +145,7 @@ let reportGenerator = (bsConfig, buildId, args, rawArgs, cb) => {
|
|
|
145
145
|
logger.error(`Error generating the report: ${error}`);
|
|
146
146
|
response = {message: message};
|
|
147
147
|
}
|
|
148
|
-
logger.error(
|
|
148
|
+
logger.error(utils.formatRequest(err, resp, body));
|
|
149
149
|
} else if (resp.statusCode != 200) {
|
|
150
150
|
messageType = Constants.messageTypes.ERROR;
|
|
151
151
|
errorCode = 'api_failed_build_generate_report';
|
|
@@ -158,7 +158,7 @@ let reportGenerator = (bsConfig, buildId, args, rawArgs, cb) => {
|
|
|
158
158
|
if (build.message === 'Unauthorized') errorCode = 'api_auth_failed';
|
|
159
159
|
} else {
|
|
160
160
|
message = Constants.userMessages.BUILD_GENERATE_REPORT_FAILED.replace('<build-id>', buildId);
|
|
161
|
-
logger.error(
|
|
161
|
+
logger.error(utils.formatRequest(err, resp, body));
|
|
162
162
|
}
|
|
163
163
|
} else {
|
|
164
164
|
messageType = Constants.messageTypes.SUCCESS;
|
|
@@ -9,8 +9,9 @@ const request = require("request"),
|
|
|
9
9
|
tableStream = require('table').createStream,
|
|
10
10
|
chalk = require('chalk');
|
|
11
11
|
|
|
12
|
-
let whileLoop = true, whileTries = config.retries, options, timeout = 3000, n = 2, tableConfig, stream, endTime, startTime = Date.now();
|
|
12
|
+
let whileLoop = true, whileTries = config.retries, options, timeout = 3000, n = 2, tableConfig, stream, endTime, startTime = Date.now(), buildStarted = false;
|
|
13
13
|
let specSummary = {
|
|
14
|
+
"buildError": null,
|
|
14
15
|
"specs": [],
|
|
15
16
|
"duration": null
|
|
16
17
|
}
|
|
@@ -106,11 +107,15 @@ let printSpecsStatus = (bsConfig, buildDetails, rawArgs) => {
|
|
|
106
107
|
},
|
|
107
108
|
function(err, result) { // when loop ends
|
|
108
109
|
if (err) {
|
|
110
|
+
if(err.status == 204) {
|
|
111
|
+
reject(specSummary.exitCode);
|
|
112
|
+
} else {
|
|
109
113
|
utils.sendUsageReport(bsConfig, {}, `buildId: ${buildDetails.build_id}`, 'error', 'sync_cli_error', err, rawArgs);
|
|
114
|
+
}
|
|
110
115
|
}
|
|
111
116
|
logger.info(lineSeparator);
|
|
112
117
|
specSummary.duration = endTime - startTime
|
|
113
|
-
resolve(specSummary)
|
|
118
|
+
resolve(specSummary);
|
|
114
119
|
}
|
|
115
120
|
);
|
|
116
121
|
});
|
|
@@ -145,7 +150,8 @@ let whileProcess = (whilstCallback) => {
|
|
|
145
150
|
whileLoop = false;
|
|
146
151
|
endTime = Date.now();
|
|
147
152
|
showSpecsStatus(body);
|
|
148
|
-
return
|
|
153
|
+
return specSummary.exitCode == Constants.BUILD_FAILED_EXIT_CODE ?
|
|
154
|
+
whilstCallback({ status: 204, message: "No specs ran in the build"} ) : whilstCallback(null, body);
|
|
149
155
|
default:
|
|
150
156
|
whileLoop = false;
|
|
151
157
|
return whilstCallback({ status: response.statusCode, message: body });
|
|
@@ -153,13 +159,25 @@ let whileProcess = (whilstCallback) => {
|
|
|
153
159
|
});
|
|
154
160
|
}
|
|
155
161
|
|
|
162
|
+
let getStackTraceUrl = () => {
|
|
163
|
+
return specSummary.buildError
|
|
164
|
+
}
|
|
165
|
+
|
|
156
166
|
let showSpecsStatus = (data) => {
|
|
157
167
|
let specData = JSON.parse(data);
|
|
158
168
|
specData.forEach(specDetails => {
|
|
159
169
|
if (specDetails == "created") {
|
|
160
|
-
|
|
170
|
+
return;
|
|
171
|
+
} else if (specDetails["stacktrace_url"]) {
|
|
172
|
+
specSummary.exitCode = Constants.BUILD_FAILED_EXIT_CODE;
|
|
173
|
+
specSummary.buildError = specDetails["stacktrace_url"]
|
|
174
|
+
winstonLogger.error(chalk.red(specDetails["message"]));
|
|
161
175
|
} else {
|
|
162
|
-
|
|
176
|
+
if(!buildStarted) {
|
|
177
|
+
buildStarted = true
|
|
178
|
+
printInitialLog();
|
|
179
|
+
}
|
|
180
|
+
printSpecData(JSON.parse(specDetails));
|
|
163
181
|
}
|
|
164
182
|
});
|
|
165
183
|
}
|
|
@@ -208,3 +226,4 @@ let getStatus = (status) => {
|
|
|
208
226
|
}
|
|
209
227
|
|
|
210
228
|
exports.printSpecsStatus = printSpecsStatus;
|
|
229
|
+
exports.getStackTraceUrl = getStackTraceUrl;
|
package/bin/helpers/utils.js
CHANGED
|
@@ -7,6 +7,7 @@ const getmac = require('getmac').default;
|
|
|
7
7
|
const { v4: uuidv4 } = require('uuid');
|
|
8
8
|
const browserstack = require('browserstack-local');
|
|
9
9
|
const crypto = require('crypto');
|
|
10
|
+
const util = require('util');
|
|
10
11
|
|
|
11
12
|
const usageReporting = require("./usageReporting"),
|
|
12
13
|
logger = require("./logger").winstonLogger,
|
|
@@ -85,6 +86,21 @@ exports.getErrorCodeFromMsg = (errMsg) => {
|
|
|
85
86
|
case Constants.validationMessages.INVALID_LOCAL_ASYNC_ARGS:
|
|
86
87
|
errorCode = 'invalid_local_async_args';
|
|
87
88
|
break;
|
|
89
|
+
case Constants.validationMessages.INVALID_GEO_LOCATION:
|
|
90
|
+
errorCode = 'invalid_geo_location';
|
|
91
|
+
break;
|
|
92
|
+
case Constants.validationMessages.NOT_ALLOWED_GEO_LOCATION_AND_LOCAL_MODE:
|
|
93
|
+
errorCode = 'not_allowed_geo_location_and_local_mode';
|
|
94
|
+
break;
|
|
95
|
+
case Constants.validationMessages.HOME_DIRECTORY_NOT_FOUND:
|
|
96
|
+
errorCode = 'home_directory_not_found';
|
|
97
|
+
break;
|
|
98
|
+
case Constants.validationMessages.HOME_DIRECTORY_NOT_A_DIRECTORY:
|
|
99
|
+
errorCode = 'home_directory_not_a_directory';
|
|
100
|
+
break;
|
|
101
|
+
case Constants.validationMessages.CYPRESS_CONFIG_FILE_NOT_PART_OF_HOME_DIRECTORY:
|
|
102
|
+
errorCode = 'cypress_config_file_not_part_of_home_directory';
|
|
103
|
+
break;
|
|
88
104
|
}
|
|
89
105
|
if (
|
|
90
106
|
errMsg.includes("Please use --config-file <path to browserstack.json>.")
|
|
@@ -272,6 +288,45 @@ exports.setCypressConfigFilename = (bsConfig, args) => {
|
|
|
272
288
|
}
|
|
273
289
|
}
|
|
274
290
|
|
|
291
|
+
exports.verifyGeolocationOption = () => {
|
|
292
|
+
let glOptionsSet = (this.searchForOption('-gl') || this.searchForOption('--gl'));
|
|
293
|
+
let geoHyphenLocationOptionsSet = (this.searchForOption('-geo-location') || this.searchForOption('--geo-location'));
|
|
294
|
+
let geoLocationOptionsSet = (this.searchForOption('-geolocation') || this.searchForOption('--geolocation'));
|
|
295
|
+
return (glOptionsSet || geoHyphenLocationOptionsSet || geoLocationOptionsSet);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
exports.setGeolocation = (bsConfig, args) => {
|
|
299
|
+
let userProvidedGeolocation = this.verifyGeolocationOption();
|
|
300
|
+
bsConfig.run_settings.userProvidedGeolocation = (userProvidedGeolocation || (!this.isUndefined(bsConfig.run_settings.geolocation)));
|
|
301
|
+
|
|
302
|
+
if (userProvidedGeolocation && !this.isUndefined(args.geolocation)) {
|
|
303
|
+
bsConfig.run_settings.geolocation = args.geolocation;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
if (this.isUndefined(bsConfig.run_settings.geolocation)){
|
|
307
|
+
bsConfig.run_settings.geolocation = null;
|
|
308
|
+
} else {
|
|
309
|
+
bsConfig.run_settings.geolocation = bsConfig.run_settings.geolocation.toUpperCase();
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
exports.isSpecTimeoutArgPassed = () => {
|
|
314
|
+
return this.searchForOption('--spec-timeout') || this.searchForOption('-t');
|
|
315
|
+
}
|
|
316
|
+
exports.setSpecTimeout = (bsConfig, args) => {
|
|
317
|
+
let specTimeout = null;
|
|
318
|
+
if(this.isSpecTimeoutArgPassed()) {
|
|
319
|
+
if(!this.isUndefined(args.specTimeout)) {
|
|
320
|
+
specTimeout = args.specTimeout;
|
|
321
|
+
} else {
|
|
322
|
+
specTimeout = 'undefined'
|
|
323
|
+
}
|
|
324
|
+
} else if (!this.isUndefined(bsConfig.run_settings.spec_timeout)) {
|
|
325
|
+
specTimeout = bsConfig.run_settings.spec_timeout;
|
|
326
|
+
}
|
|
327
|
+
bsConfig.run_settings.spec_timeout = specTimeout;
|
|
328
|
+
}
|
|
329
|
+
|
|
275
330
|
// specs can be passed from bstack configuration file
|
|
276
331
|
// specs can be passed via command line args as a string
|
|
277
332
|
// command line args takes precedence over config
|
|
@@ -352,10 +407,26 @@ exports.fixCommaSeparatedString = (string) => {
|
|
|
352
407
|
|
|
353
408
|
exports.isUndefined = value => (value === undefined || value === null);
|
|
354
409
|
|
|
410
|
+
exports.isPositiveInteger = (str) => {
|
|
411
|
+
if (typeof str !== 'string') {
|
|
412
|
+
return false;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
const num = Number(str);
|
|
416
|
+
|
|
417
|
+
if (this.isInteger(num) && num > 0) {
|
|
418
|
+
return true;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
return false;
|
|
422
|
+
}
|
|
423
|
+
|
|
355
424
|
exports.isTrueString = value => (!this.isUndefined(value) && value.toString().toLowerCase() === 'true');
|
|
356
425
|
|
|
357
426
|
exports.isFloat = (value) => Number(value) && Number(value) % 1 !== 0;
|
|
358
427
|
|
|
428
|
+
exports.isInteger = (value) => Number.isInteger(value);
|
|
429
|
+
|
|
359
430
|
exports.nonEmptyArray = (value) => {
|
|
360
431
|
if(!this.isUndefined(value) && value && value.length) {
|
|
361
432
|
return true;
|
|
@@ -556,11 +627,6 @@ exports.setLocalIdentifier = (bsConfig, args) => {
|
|
|
556
627
|
!this.isUndefined(bsConfig["connection_settings"]["local_identifier"])
|
|
557
628
|
){
|
|
558
629
|
bsConfig['connection_settings']['local_mode'] = 'always-on';
|
|
559
|
-
} else if (
|
|
560
|
-
bsConfig['connection_settings']['local'] &&
|
|
561
|
-
this.isUndefined(bsConfig["connection_settings"]["local_identifier"])
|
|
562
|
-
){
|
|
563
|
-
bsConfig["connection_settings"]["local_identifier"] = this.generateLocalIdentifier(bsConfig['connection_settings']['local_mode']);
|
|
564
630
|
}
|
|
565
631
|
};
|
|
566
632
|
|
|
@@ -600,9 +666,18 @@ exports.setLocalMode = (bsConfig, args) => {
|
|
|
600
666
|
exports.setupLocalTesting = (bsConfig, args, rawArgs) => {
|
|
601
667
|
return new Promise(async (resolve, reject) => {
|
|
602
668
|
if( bsConfig['connection_settings'] && bsConfig['connection_settings']['local'] && String(bsConfig['connection_settings']['local']) === "true" ){
|
|
603
|
-
let
|
|
604
|
-
|
|
605
|
-
)
|
|
669
|
+
let localBinaryRunning = await this.checkLocalBinaryRunning(bsConfig, bsConfig['connection_settings']['local_identifier']);
|
|
670
|
+
let localIdentifierRunning;
|
|
671
|
+
if (localBinaryRunning['should_spawn_binary'] == true) {
|
|
672
|
+
localIdentifierRunning = false;
|
|
673
|
+
if(this.isUndefined(bsConfig["connection_settings"]["local_identifier"])) {
|
|
674
|
+
bsConfig["connection_settings"]["local_identifier"] = this.generateLocalIdentifier(bsConfig['connection_settings']['local_mode']);
|
|
675
|
+
}
|
|
676
|
+
} else {
|
|
677
|
+
localIdentifierRunning = true;
|
|
678
|
+
process.env.BSTACK_CYPRESS_LOCAL_BINARY_ALREADY_RUNNING = "true"; // shows message when binary is not spawned by the CLI process
|
|
679
|
+
process.env.BSTACK_CYPRESS_LOCAL_BINARY_RUNNING = "true";
|
|
680
|
+
}
|
|
606
681
|
if (!localIdentifierRunning){
|
|
607
682
|
bsConfig.connection_settings.usedAutoLocal = true;
|
|
608
683
|
var bs_local = this.getLocalBinary();
|
|
@@ -611,6 +686,7 @@ exports.setupLocalTesting = (bsConfig, args, rawArgs) => {
|
|
|
611
686
|
logger.info('Setting up Local testing...');
|
|
612
687
|
bs_local.start(bs_local_args, function (localStartError) {
|
|
613
688
|
if (that.isUndefined(localStartError)) {
|
|
689
|
+
process.env.BSTACK_CYPRESS_LOCAL_BINARY_RUNNING = "true";
|
|
614
690
|
resolve(bs_local);
|
|
615
691
|
} else {
|
|
616
692
|
let message = `name: ${localStartError.name}, message: ${localStartError.message}, extra: ${localStartError.extra}`,
|
|
@@ -638,22 +714,6 @@ exports.setupLocalTesting = (bsConfig, args, rawArgs) => {
|
|
|
638
714
|
|
|
639
715
|
exports.stopLocalBinary = (bsConfig, bs_local, args, rawArgs) => {
|
|
640
716
|
return new Promise(async (resolve, reject) => {
|
|
641
|
-
if(bsConfig['connection_settings'] && bsConfig['connection_settings']['local']){
|
|
642
|
-
let localIdentifierRunning = await this.checkLocalIdentifierRunning(bsConfig,bsConfig["connection_settings"]["local_identifier"]);
|
|
643
|
-
if(!localIdentifierRunning){
|
|
644
|
-
let message = `Local Binary not running.`,
|
|
645
|
-
errorCode = 'local_identifier_error';
|
|
646
|
-
this.sendUsageReport(
|
|
647
|
-
bsConfig,
|
|
648
|
-
args,
|
|
649
|
-
message,
|
|
650
|
-
Constants.messageTypes.ERROR,
|
|
651
|
-
errorCode,
|
|
652
|
-
null,
|
|
653
|
-
rawArgs
|
|
654
|
-
);
|
|
655
|
-
}
|
|
656
|
-
}
|
|
657
717
|
if (!this.isUndefined(bs_local) && bs_local.isRunning() && bsConfig['connection_settings'] && bsConfig['connection_settings']['local_mode'].toLowerCase() != "always-on") {
|
|
658
718
|
let that = this;
|
|
659
719
|
bs_local.stop(function (localStopError) {
|
|
@@ -707,35 +767,26 @@ exports.generateLocalIdentifier = (mode) => {
|
|
|
707
767
|
return Buffer.from(local_identifier).toString("base64");
|
|
708
768
|
};
|
|
709
769
|
|
|
710
|
-
exports.
|
|
770
|
+
exports.checkLocalBinaryRunning = (bsConfig, localIdentifier) => {
|
|
711
771
|
let options = {
|
|
712
|
-
url: `${config.
|
|
772
|
+
url: `${config.cypress_v1}/local_binary_running_check`,
|
|
713
773
|
auth: {
|
|
714
774
|
user: bsConfig.auth.username,
|
|
715
775
|
password: bsConfig.auth.access_key,
|
|
716
776
|
},
|
|
717
777
|
headers: {
|
|
778
|
+
'Content-Type': 'application/json',
|
|
718
779
|
'User-Agent': this.getUserAgent(),
|
|
719
780
|
},
|
|
781
|
+
body: JSON.stringify({ localIdentifier: localIdentifier}),
|
|
720
782
|
};
|
|
721
|
-
let that = this;
|
|
722
783
|
return new Promise ( function(resolve, reject) {
|
|
723
|
-
request.
|
|
784
|
+
request.post(options, function (err, resp, body) {
|
|
724
785
|
if(err){
|
|
725
786
|
reject(err);
|
|
726
787
|
}
|
|
727
788
|
let response = JSON.parse(body);
|
|
728
|
-
|
|
729
|
-
if(!that.isUndefined(response['instances'])){
|
|
730
|
-
localInstances = response['instances'];
|
|
731
|
-
}
|
|
732
|
-
let localIdentifiers = [];
|
|
733
|
-
|
|
734
|
-
localInstances.forEach(function(instance){
|
|
735
|
-
localIdentifiers.push(instance['localIdentifier']);
|
|
736
|
-
});
|
|
737
|
-
|
|
738
|
-
resolve(localIdentifiers.includes(localIdentifier));
|
|
789
|
+
resolve(response);
|
|
739
790
|
});
|
|
740
791
|
});
|
|
741
792
|
};
|
|
@@ -952,6 +1003,14 @@ exports.setCLIMode = (bsConfig, args) => {
|
|
|
952
1003
|
}
|
|
953
1004
|
}
|
|
954
1005
|
|
|
1006
|
+
exports.formatRequest = (err, resp, body) => {
|
|
1007
|
+
return {
|
|
1008
|
+
err,
|
|
1009
|
+
status: resp ? resp.statusCode : null,
|
|
1010
|
+
body: body ? util.format('%j', body) : null
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
|
|
955
1014
|
exports.stopBrowserStackBuild = async (bsConfig, args, buildId, rawArgs) => {
|
|
956
1015
|
let that = this;
|
|
957
1016
|
return new Promise(function (resolve, reject) {
|
|
@@ -1010,7 +1069,6 @@ exports.stopBrowserStackBuild = async (bsConfig, args, buildId, rawArgs) => {
|
|
|
1010
1069
|
logger.info(message);
|
|
1011
1070
|
}
|
|
1012
1071
|
} catch(err) {
|
|
1013
|
-
console.log(err);
|
|
1014
1072
|
message = Constants.userMessages.BUILD_STOP_FAILED;
|
|
1015
1073
|
messageType = Constants.messageTypes.ERROR;
|
|
1016
1074
|
errorCode = 'api_failed_build_stop';
|
package/bin/helpers/zipUpload.js
CHANGED
|
@@ -10,9 +10,18 @@ const config = require("./config"),
|
|
|
10
10
|
Constants = require("./constants"),
|
|
11
11
|
utils = require("./utils");
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
|
|
14
|
+
const purgeUploadBar = (obj) => {
|
|
15
|
+
obj.bar1.update(100, {
|
|
16
|
+
speed: ((obj.size / (Date.now() - obj.startTime)) / 125).toFixed(2) //kbits per sec
|
|
17
|
+
});
|
|
18
|
+
obj.bar1.stop();
|
|
19
|
+
clearInterval(obj.zipInterval);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const uploadSuits = (bsConfig, filePath, opts, obj) => {
|
|
14
23
|
return new Promise(function (resolve, reject) {
|
|
15
|
-
|
|
24
|
+
obj.startTime = Date.now();
|
|
16
25
|
|
|
17
26
|
if (opts.urlPresent) {
|
|
18
27
|
return resolve({ [opts.md5ReturnKey]: opts.url });
|
|
@@ -21,31 +30,29 @@ const uploadSuits = (bsConfig, filePath, opts) => {
|
|
|
21
30
|
return resolve({});
|
|
22
31
|
}
|
|
23
32
|
|
|
24
|
-
let size =
|
|
33
|
+
let size = obj.size;
|
|
25
34
|
|
|
26
35
|
// create new progress bar
|
|
27
|
-
|
|
28
|
-
format: `${filePath} [{bar}] {percentage}% | ETA: {eta}s | Speed: {speed} kbps | Duration: {duration}s [${(size / 1000000).toFixed(2)} MB]
|
|
29
|
-
hideCursor: true,
|
|
36
|
+
obj.bar1 = new cliProgress.SingleBar({
|
|
37
|
+
format: `${filePath} [{bar}] {percentage}% | ETA: {eta}s | Speed: {speed} kbps | Duration: {duration}s [${(size / 1000000).toFixed(2)} MB]`
|
|
30
38
|
});
|
|
31
39
|
|
|
32
|
-
bar1.start(100, 0, {
|
|
40
|
+
obj.bar1.start(100, 0, {
|
|
33
41
|
speed: "N/A"
|
|
34
42
|
});
|
|
35
43
|
|
|
36
|
-
bar1.on('start', () => {
|
|
44
|
+
obj.bar1.on('start', () => {
|
|
37
45
|
});
|
|
38
46
|
|
|
39
|
-
bar1.on('stop', () => {
|
|
47
|
+
obj.bar1.on('stop', () => {
|
|
40
48
|
});
|
|
41
49
|
|
|
42
50
|
let options = utils.generateUploadParams(bsConfig, filePath, opts.md5Data, opts.fileDetails)
|
|
43
51
|
let responseData = null;
|
|
44
52
|
var r = request.post(options, function (err, resp, body) {
|
|
45
|
-
clearInterval(q);
|
|
46
53
|
|
|
47
54
|
if (err) {
|
|
48
|
-
reject(err);
|
|
55
|
+
reject({message: err, stacktrace: utils.formatRequest(err, resp, body)});
|
|
49
56
|
} else {
|
|
50
57
|
try {
|
|
51
58
|
responseData = JSON.parse(body);
|
|
@@ -55,50 +62,46 @@ const uploadSuits = (bsConfig, filePath, opts) => {
|
|
|
55
62
|
if (resp.statusCode != 200) {
|
|
56
63
|
if (resp.statusCode == 401) {
|
|
57
64
|
if (responseData && responseData["error"]) {
|
|
58
|
-
responseData["time"] = Date.now() - startTime;
|
|
59
|
-
return reject(responseData["error"]);
|
|
65
|
+
responseData["time"] = Date.now() - obj.startTime;
|
|
66
|
+
return reject({message: responseData["error"], stacktrace: utils.formatRequest(err, resp, body)});
|
|
60
67
|
} else {
|
|
61
|
-
return reject(Constants.validationMessages.INVALID_DEFAULT_AUTH_PARAMS);
|
|
68
|
+
return reject({message: Constants.validationMessages.INVALID_DEFAULT_AUTH_PARAMS, stacktrace: utils.formatRequest(err, resp, body)});
|
|
62
69
|
}
|
|
63
70
|
}
|
|
64
71
|
if (!opts.propogateError){
|
|
65
72
|
return resolve({});
|
|
66
73
|
}
|
|
67
74
|
if(responseData && responseData["error"]){
|
|
68
|
-
responseData["time"] = Date.now() - startTime;
|
|
69
|
-
reject(responseData["error"]);
|
|
75
|
+
responseData["time"] = Date.now() - obj.startTime;
|
|
76
|
+
reject({message: responseData["error"], stacktrace: utils.formatRequest(err, resp, body)});
|
|
70
77
|
} else {
|
|
71
78
|
if (resp.statusCode == 413) {
|
|
72
|
-
reject(Constants.userMessages.ZIP_UPLOAD_LIMIT_EXCEEDED);
|
|
79
|
+
reject({message: Constants.userMessages.ZIP_UPLOAD_LIMIT_EXCEEDED, stacktrace: utils.formatRequest(err, resp, body)});
|
|
73
80
|
} else {
|
|
74
|
-
reject(Constants.userMessages.ZIP_UPLOADER_NOT_REACHABLE);
|
|
81
|
+
reject({message: Constants.userMessages.ZIP_UPLOADER_NOT_REACHABLE, stacktrace: utils.formatRequest(err, resp, body)});
|
|
75
82
|
}
|
|
76
83
|
}
|
|
77
84
|
} else {
|
|
78
|
-
|
|
79
|
-
speed: ((size / (Date.now() - startTime)) / 125).toFixed(2) //kbits per sec
|
|
80
|
-
});
|
|
81
|
-
bar1.stop();
|
|
85
|
+
purgeUploadBar(obj);
|
|
82
86
|
logger.info(`${opts.messages.uploadingSuccess} (${responseData[opts.md5ReturnKey]})`);
|
|
83
87
|
opts.cleanupMethod();
|
|
84
|
-
responseData["time"] = Date.now() - startTime;
|
|
88
|
+
responseData["time"] = Date.now() - obj.startTime;
|
|
85
89
|
resolve(responseData);
|
|
86
90
|
}
|
|
87
91
|
}
|
|
88
92
|
});
|
|
89
93
|
|
|
90
|
-
|
|
94
|
+
obj.zipInterval = setInterval(function () {
|
|
91
95
|
let dispatched = r.req.connection._bytesDispatched;
|
|
92
96
|
let percent = dispatched * 100.0 / size;
|
|
93
|
-
bar1.update(percent, {
|
|
94
|
-
speed: ((dispatched / (Date.now() - startTime)) / 125).toFixed(2) //kbits per sec
|
|
97
|
+
obj.bar1.update(percent, {
|
|
98
|
+
speed: ((dispatched / (Date.now() - obj.startTime)) / 125).toFixed(2) //kbits per sec
|
|
95
99
|
});
|
|
96
100
|
}, 150);
|
|
97
101
|
|
|
98
102
|
});
|
|
99
103
|
}
|
|
100
104
|
|
|
101
|
-
|
|
102
105
|
const uploadCypressZip = (bsConfig, md5data, packageData) => {
|
|
103
106
|
return new Promise(function (resolve, reject) {
|
|
104
107
|
let obj = {}
|
|
@@ -116,8 +119,22 @@ const uploadCypressZip = (bsConfig, md5data, packageData) => {
|
|
|
116
119
|
logger.info(npmOptions.messages.uploading);
|
|
117
120
|
}
|
|
118
121
|
|
|
119
|
-
|
|
120
|
-
|
|
122
|
+
var testZipUploadObj = {
|
|
123
|
+
bar1: null,
|
|
124
|
+
zipInterval: null,
|
|
125
|
+
size: fs.existsSync(config.fileName) ? fs.lstatSync(config.fileName).size : 0,
|
|
126
|
+
startTime: null
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
var npmPackageZipUploadObj = {
|
|
130
|
+
bar1: null,
|
|
131
|
+
zipInterval: null,
|
|
132
|
+
size: fs.existsSync(config.packageFileName) ? fs.lstatSync(config.packageFileName).size : 0,
|
|
133
|
+
startTime: null
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
let zipUpload = uploadSuits(bsConfig, config.fileName, zipOptions, testZipUploadObj);
|
|
137
|
+
let npmPackageUpload = uploadSuits(bsConfig, config.packageFileName, npmOptions, npmPackageZipUploadObj);
|
|
121
138
|
Promise.all([zipUpload, npmPackageUpload]).then(function (uploads) {
|
|
122
139
|
uploads.forEach(upload => {
|
|
123
140
|
if(upload.zip_url && upload.time) {
|
|
@@ -130,7 +147,10 @@ const uploadCypressZip = (bsConfig, md5data, packageData) => {
|
|
|
130
147
|
});
|
|
131
148
|
return resolve(obj);
|
|
132
149
|
}).catch((error) => {
|
|
133
|
-
|
|
150
|
+
testZipUploadObj.bar1 && purgeUploadBar(testZipUploadObj);
|
|
151
|
+
npmPackageZipUploadObj.bar1 && purgeUploadBar(npmPackageZipUploadObj);
|
|
152
|
+
logger.error(error.stacktrace)
|
|
153
|
+
return reject(error.message);
|
|
134
154
|
})
|
|
135
155
|
})
|
|
136
156
|
}
|
package/bin/runner.js
CHANGED
|
@@ -67,7 +67,7 @@ var argv = yargs
|
|
|
67
67
|
.showHelpOnFail(false, Constants.cliMessages.VERSION.HELP)
|
|
68
68
|
.demand(1, Constants.cliMessages.VERSION.DEMAND)
|
|
69
69
|
.command('init', Constants.cliMessages.INIT.INFO, function(yargs) {
|
|
70
|
-
let rawArgv =
|
|
70
|
+
let rawArgv = process.argv.slice(2);
|
|
71
71
|
argv = yargs
|
|
72
72
|
.usage("usage: $0 init [filename] [options]")
|
|
73
73
|
.options({
|
|
@@ -87,7 +87,7 @@ var argv = yargs
|
|
|
87
87
|
}
|
|
88
88
|
})
|
|
89
89
|
.command('build-info', Constants.cliMessages.BUILD.INFO, function(yargs) {
|
|
90
|
-
let rawArgv =
|
|
90
|
+
let rawArgv = process.argv.slice(2);
|
|
91
91
|
argv = yargs
|
|
92
92
|
.usage('usage: $0 <buildId>')
|
|
93
93
|
.demand(1, Constants.cliMessages.BUILD.DEMAND)
|
|
@@ -103,7 +103,7 @@ var argv = yargs
|
|
|
103
103
|
}
|
|
104
104
|
})
|
|
105
105
|
.command('build-stop', Constants.cliMessages.BUILD.STOP, function (yargs) {
|
|
106
|
-
let rawArgv =
|
|
106
|
+
let rawArgv = process.argv.slice(2);
|
|
107
107
|
argv = yargs
|
|
108
108
|
.usage('usage: $0 <buildId>')
|
|
109
109
|
.demand(1, Constants.cliMessages.BUILD.DEMAND)
|
|
@@ -119,7 +119,7 @@ var argv = yargs
|
|
|
119
119
|
}
|
|
120
120
|
})
|
|
121
121
|
.command('run', Constants.cliMessages.RUN.INFO, function(yargs) {
|
|
122
|
-
let rawArgv =
|
|
122
|
+
let rawArgv = process.argv.slice(2);
|
|
123
123
|
argv = yargs
|
|
124
124
|
.usage('usage: $0 run <options>')
|
|
125
125
|
.options({
|
|
@@ -133,6 +133,12 @@ var argv = yargs
|
|
|
133
133
|
demand: true,
|
|
134
134
|
demand: Constants.cliMessages.RUN.CYPRESS_CONFIG_DEMAND
|
|
135
135
|
},
|
|
136
|
+
'gl': {
|
|
137
|
+
alias: 'geolocation',
|
|
138
|
+
describe: Constants.cliMessages.RUN.CYPRESS_GEO_LOCATION,
|
|
139
|
+
default: undefined,
|
|
140
|
+
type: 'string'
|
|
141
|
+
},
|
|
136
142
|
'p': {
|
|
137
143
|
alias: ['parallels', 'parallel'],
|
|
138
144
|
describe: Constants.cliMessages.RUN.PARALLEL_DESC,
|
|
@@ -162,6 +168,12 @@ var argv = yargs
|
|
|
162
168
|
type: "string",
|
|
163
169
|
default: undefined
|
|
164
170
|
},
|
|
171
|
+
't': {
|
|
172
|
+
alias: ['specTimeout'],
|
|
173
|
+
default: undefined,
|
|
174
|
+
describe: Constants.cliMessages.RUN.SPEC_TIMEOUT,
|
|
175
|
+
type: "string"
|
|
176
|
+
},
|
|
165
177
|
'disable-npm-warning': {
|
|
166
178
|
default: false,
|
|
167
179
|
description: Constants.cliMessages.COMMON.NO_NPM_WARNING,
|
|
@@ -240,7 +252,7 @@ var argv = yargs
|
|
|
240
252
|
}
|
|
241
253
|
})
|
|
242
254
|
.command('generate-report', Constants.cliMessages.GENERATE_REPORT.INFO, function(yargs) {
|
|
243
|
-
let rawArgv =
|
|
255
|
+
let rawArgv = process.argv.slice(2);
|
|
244
256
|
argv = yargs
|
|
245
257
|
.usage('usage: $0 generate-report <buildId>')
|
|
246
258
|
.demand(1, Constants.cliMessages.BUILD.DEMAND)
|
|
@@ -256,7 +268,7 @@ var argv = yargs
|
|
|
256
268
|
}
|
|
257
269
|
})
|
|
258
270
|
.command('generate-downloads', Constants.cliMessages.GENERATE_DOWNLOADS.INFO, function(yargs) {
|
|
259
|
-
let rawArgv =
|
|
271
|
+
let rawArgv = process.argv.slice(2);
|
|
260
272
|
argv = yargs
|
|
261
273
|
.usage('usage: $0 generate-downloads <buildId>')
|
|
262
274
|
.demand(1, Constants.cliMessages.BUILD.DEMAND)
|
|
@@ -56,7 +56,7 @@ module.exports = function () {
|
|
|
56
56
|
"project_name": "project-name",
|
|
57
57
|
"build_name": "build-name",
|
|
58
58
|
"exclude": [],
|
|
59
|
-
"parallels": "
|
|
59
|
+
"parallels": "Number of parallels you want to run",
|
|
60
60
|
"npm_dependencies": {
|
|
61
61
|
},
|
|
62
62
|
"package_config_options": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "browserstack-cypress-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.0",
|
|
4
4
|
"description": "BrowserStack Cypress CLI for Cypress integration with BrowserStack's remote devices.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -12,23 +12,23 @@
|
|
|
12
12
|
"browserstack-cypress": "bin/runner.js"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"archiver": "
|
|
16
|
-
"async": "
|
|
17
|
-
"browserstack-local": "
|
|
18
|
-
"chalk": "
|
|
19
|
-
"cli-progress": "
|
|
20
|
-
"fs-extra": "
|
|
21
|
-
"getmac": "
|
|
22
|
-
"glob": "
|
|
23
|
-
"mkdirp": "
|
|
24
|
-
"request": "
|
|
25
|
-
"requestretry": "
|
|
26
|
-
"table": "
|
|
27
|
-
"unzipper": "
|
|
28
|
-
"update-notifier": "
|
|
29
|
-
"uuid": "
|
|
15
|
+
"archiver": "5.3.0",
|
|
16
|
+
"async": "3.2.3",
|
|
17
|
+
"browserstack-local": "1.4.8",
|
|
18
|
+
"chalk": "4.1.2",
|
|
19
|
+
"cli-progress": "3.10.0",
|
|
20
|
+
"fs-extra": "8.1.0",
|
|
21
|
+
"getmac": "5.20.0",
|
|
22
|
+
"glob": "7.2.0",
|
|
23
|
+
"mkdirp": "1.0.4",
|
|
24
|
+
"request": "2.88.2",
|
|
25
|
+
"requestretry": "4.1.2",
|
|
26
|
+
"table": "5.4.6",
|
|
27
|
+
"unzipper": "0.10.11",
|
|
28
|
+
"update-notifier": "5.1.0",
|
|
29
|
+
"uuid": "8.3.2",
|
|
30
30
|
"winston": "2.4.4",
|
|
31
|
-
"yargs": "
|
|
31
|
+
"yargs": "14.2.3"
|
|
32
32
|
},
|
|
33
33
|
"repository": {
|
|
34
34
|
"type": "git",
|
|
@@ -39,13 +39,13 @@
|
|
|
39
39
|
"url": "https://github.com/browserstack/browserstack-cypress-cli/issues"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"chai": "
|
|
43
|
-
"chai-as-promised": "
|
|
44
|
-
"custom-env": "
|
|
45
|
-
"mocha": "
|
|
46
|
-
"nyc": "
|
|
47
|
-
"proxyquire": "
|
|
48
|
-
"rewire": "
|
|
49
|
-
"sinon": "
|
|
42
|
+
"chai": "4.3.6",
|
|
43
|
+
"chai-as-promised": "7.1.1",
|
|
44
|
+
"custom-env": "2.0.1",
|
|
45
|
+
"mocha": "7.2.0",
|
|
46
|
+
"nyc": "15.1.0",
|
|
47
|
+
"proxyquire": "2.1.3",
|
|
48
|
+
"rewire": "5.0.0",
|
|
49
|
+
"sinon": "9.2.4"
|
|
50
50
|
}
|
|
51
51
|
}
|