browserstack-cypress-cli 1.11.1 → 1.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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,9 @@ 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
+
51
56
  // accept the specs list from command line if provided
52
57
  utils.setUserSpecs(bsConfig, args);
53
58
 
@@ -96,6 +101,8 @@ module.exports = function run(args, rawArgs) {
96
101
  //get the number of spec files
97
102
  let specFiles = utils.getNumberOfSpecFiles(bsConfig, args, cypressJson);
98
103
 
104
+ bsConfig['run_settings']['video_config'] = utils.getVideoConfig(cypressJson);
105
+
99
106
  // return the number of parallels user specified
100
107
  let userSpecifiedParallels = utils.getParallels(bsConfig, args);
101
108
 
@@ -105,16 +112,16 @@ module.exports = function run(args, rawArgs) {
105
112
  // warn if specFiles cross our limit
106
113
  utils.warnSpecLimit(bsConfig, args, specFiles, rawArgs);
107
114
  markBlockEnd('preArchiveSteps');
108
- markBlockStart('checkAlreadyUploaded');
115
+ markBlockStart('zip');
116
+ markBlockStart('zip.checkAlreadyUploaded');
109
117
  return checkUploaded.checkUploadedMd5(bsConfig, args, {markBlockStart, markBlockEnd}).then(function (md5data) {
110
- markBlockEnd('checkAlreadyUploaded');
118
+ markBlockEnd('zip.checkAlreadyUploaded');
111
119
 
112
- markBlockStart('packageInstaller');
120
+ markBlockStart('zip.packageInstaller');
113
121
  return packageInstaller.packageWrapper(bsConfig, config.packageDirName, config.packageFileName, md5data, {markBlockStart, markBlockEnd}).then(function (packageData) {
114
- markBlockEnd('packageInstaller');
122
+ markBlockEnd('zip.packageInstaller');
115
123
 
116
124
  // Archive the spec files
117
- markBlockStart('zip');
118
125
  markBlockStart('zip.archive');
119
126
  return archiver.archive(bsConfig.run_settings, config.fileName, args.exclude, md5data).then(function (data) {
120
127
  markBlockEnd('zip.archive');
@@ -176,15 +183,31 @@ module.exports = function run(args, rawArgs) {
176
183
  await new Promise(resolve => setTimeout(resolve, 5000));
177
184
 
178
185
  // download build artifacts
179
- if (utils.nonEmptyArray(bsConfig.run_settings.downloads)) {
180
- await downloadBuildArtifacts(bsConfig, data.build_id, args, rawArgs);
186
+ if (exitCode != Constants.BUILD_FAILED_EXIT_CODE) {
187
+ if (utils.nonEmptyArray(bsConfig.run_settings.downloads)) {
188
+ await downloadBuildArtifacts(bsConfig, data.build_id, args, rawArgs);
189
+ }
190
+
191
+ // Generate custom report!
192
+ reportGenerator(bsConfig, data.build_id, args, rawArgs, function(){
193
+ utils.sendUsageReport(bsConfig, args, `${message}\n${dashboardLink}`, Constants.messageTypes.SUCCESS, null, buildReportData, rawArgs);
194
+ utils.handleSyncExit(exitCode, data.dashboard_url);
195
+ });
196
+ } else {
197
+ let stacktraceUrl = getStackTraceUrl();
198
+ downloadBuildStacktrace(stacktraceUrl).then((message) => {
199
+ utils.sendUsageReport(bsConfig, args, message, Constants.messageTypes.SUCCESS, null, buildReportData, rawArgs);
200
+ }).catch((err) => {
201
+ let message = `Downloading build stacktrace failed with statuscode: ${err}. Please visit ${data.dashboard_url} for additional details.`;
202
+ logger.error(message);
203
+ utils.sendUsageReport(bsConfig, args, message, Constants.messageTypes.ERROR, null, buildReportData, rawArgs);
204
+ }).finally(() =>{
205
+ let terminalWidth = (process.stdout.columns) * 0.9;
206
+ let lineSeparator = "\n" + "-".repeat(terminalWidth);
207
+ logger.info(Constants.userMessages.BUILD_FAILED_ERROR)
208
+ process.exitCode = Constants.BUILD_FAILED_EXIT_CODE;
209
+ });
181
210
  }
182
-
183
- // Generate custom report!
184
- reportGenerator(bsConfig, data.build_id, args, rawArgs, function(){
185
- utils.sendUsageReport(bsConfig, args, `${message}\n${dashboardLink}`, Constants.messageTypes.SUCCESS, null, buildReportData, rawArgs);
186
- utils.handleSyncExit(exitCode, data.dashboard_url);
187
- });
188
211
  });
189
212
  } else if (utils.nonEmptyArray(bsConfig.run_settings.downloads)) {
190
213
  logger.info(Constants.userMessages.ASYNC_DOWNLOADS.replace('<build-id>', data.build_id));
@@ -234,6 +257,9 @@ module.exports = function run(args, rawArgs) {
234
257
  utils.sendUsageReport(bsConfig, args, `${message}\n${dashboardLink}`, Constants.messageTypes.SUCCESS, null, buildReportData, rawArgs);
235
258
  return;
236
259
  }).catch(async function (err) {
260
+ if (err && err.toString().includes('browserstack.geoLocation')) {
261
+ err = err.replace(/browserstack.geoLocation/g, 'geolocation');
262
+ }
237
263
  // Build creation failed
238
264
  logger.error(err);
239
265
  // stop the Local instance
@@ -316,9 +342,23 @@ module.exports = function run(args, rawArgs) {
316
342
  utils.sendUsageReport(bsJsonData, args, err.message, Constants.messageTypes.ERROR, utils.getErrorCodeFromErr(err), null, rawArgs);
317
343
  process.exitCode = Constants.ERROR_EXIT_CODE;
318
344
  }).finally(function(){
319
- updateNotifier({
345
+ const notifier = updateNotifier({
320
346
  pkg,
321
347
  updateCheckInterval: 1000 * 60 * 60 * 24 * 7,
322
- }).notify({isGlobal: true});
348
+ });
349
+
350
+ // Checks for update on first run.
351
+ // Set lastUpdateCheck to 0 to spawn the check update process as notifier sets this to Date.now() for preventing
352
+ // the check untill one interval period. It runs once.
353
+ if (!notifier.disabled && Date.now() - notifier.config.get('lastUpdateCheck') < 50) {
354
+ notifier.config.set('lastUpdateCheck', 0);
355
+ notifier.check();
356
+ }
357
+
358
+ // Set the config update as notifier clears this after reading.
359
+ if (notifier.update && notifier.update.current !== notifier.update.latest) {
360
+ notifier.config.set('update', notifier.update);
361
+ notifier.notify({isGlobal: true});
362
+ }
323
363
  });
324
364
  }
@@ -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 = path.dirname(runSettings.cypressConfigFilePath);
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: 'browserstack-package.json'});
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: 'cypress.json'});
86
+ archive.append(cypressJSONString, {name: `${cypressAppendFilesZipLocation}cypress.json`});
77
87
  }
78
88
 
79
89
  archive.finalize();
@@ -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) {
@@ -23,7 +25,7 @@ const caps = (bsConfig, zip) => {
23
25
  if (bsConfig.browsers) {
24
26
  bsConfig.browsers.forEach((element) => {
25
27
  osBrowser = element.os + "-" + element.browser;
26
- osAndBrowser = element.os + " / " + Utils.capitalizeFirstLetter(element.browser);
28
+ osAndBrowser = (element.os) ? element.os : "Any OS" + " / " + Utils.capitalizeFirstLetter(element.browser);
27
29
  element.versions.forEach((version) => {
28
30
  osBrowserArray.push(osBrowser + version);
29
31
  browsersList.push(`${osAndBrowser} (${version})`);
@@ -69,21 +71,31 @@ const caps = (bsConfig, zip) => {
69
71
  obj.local = true;
70
72
  }
71
73
 
72
- obj.localMode = null;
73
- // Local Mode
74
- if (obj.local === true && bsConfig.connection_settings.local_mode) {
75
- obj.localMode = bsConfig.connection_settings.local_mode;
76
- if (bsConfig.connection_settings.user_defined_local_mode_warning) {
77
- logger.warn(Constants.userMessages.INVALID_LOCAL_MODE_WARNING);
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
- // Local Identifier
83
- obj.localIdentifier = null;
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,33 @@ 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
+
188
230
  resolve(cypressJson);
189
231
  });
190
232
  }
191
233
 
192
234
  module.exports = {
193
235
  caps,
236
+ addCypressZipStartLocation,
194
237
  validate
195
238
  }
@@ -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 = path.dirname(runSettings.cypressConfigFilePath);
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,
@@ -145,7 +150,8 @@ const checkUploadedMd5 = (bsConfig, args, instrumentBlocks) => {
145
150
  }
146
151
  });
147
152
  }).catch((err) => {
148
- resolve({zipUrlPresent: false, packageUrlPresent: false, error: err.stack.substring(0,100)});
153
+ let errString = err.stack ? err.stack.toString().substring(0,100) : err.toString().substring(0,100);
154
+ resolve({zipUrlPresent: false, packageUrlPresent: false, error: errString});
149
155
  });
150
156
  });
151
157
  };
@@ -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,14 @@ 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")
64
67
  };
65
68
 
66
69
  const validationMessages = {
@@ -87,6 +90,14 @@ const validationMessages = {
87
90
  INVALID_LOCAL_IDENTIFIER: "Invalid value specified for local_identifier. For more info, check out https://www.browserstack.com/docs/automate/cypress/cli-reference",
88
91
  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
92
  INVALID_LOCAL_ASYNC_ARGS: "Cannot run in --async mode when local is set to true. Please run the build after removing --async",
93
+ 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",
94
+ 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.",
95
+ 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.",
96
+ 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.",
97
+ NOT_ALLOWED_GEO_LOCATION_AND_LOCAL_MODE: "IP Geolocation feature is not available in conjunction with BrowserStack Local.",
98
+ HOME_DIRECTORY_NOT_FOUND: "Specified home directory could not be found. Please make sure the path of the home directory is correct.",
99
+ HOME_DIRECTORY_NOT_A_DIRECTORY: "Specified home directory is not a directory. The home directory can only be a directory and not a file.",
100
+ 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."
90
101
  };
91
102
 
92
103
  const cliMessages = {
@@ -129,6 +140,7 @@ const cliMessages = {
129
140
  CONFIG_DESCRIPTION: "Set configuration values. Separate multiple values with a comma. The values set here override any values set in your configuration file.",
130
141
  REPORTER: "Specify the custom reporter to use",
131
142
  REPORTER_OPTIONS: "Specify reporter options for custom reporter",
143
+ CYPRESS_GEO_LOCATION: "Enterprise feature to simulate website and mobile behavior from different locations."
132
144
  },
133
145
  COMMON: {
134
146
  DISABLE_USAGE_REPORTING: "Disable usage reporting",
@@ -216,6 +228,8 @@ const AUTH_REGEX = /"auth" *: *{[\s\S]*?}/g
216
228
 
217
229
  const ERROR_EXIT_CODE = 1;
218
230
 
231
+ const BUILD_FAILED_EXIT_CODE = 3;
232
+
219
233
  const REDACTED = "[REDACTED]";
220
234
 
221
235
  const REDACTED_AUTH =`auth: { "username": ${REDACTED}, "access_key": ${REDACTED} }`;
@@ -239,5 +253,6 @@ module.exports = Object.freeze({
239
253
  LATEST_VERSION_SYNTAX_REGEX,
240
254
  ERROR_EXIT_CODE,
241
255
  AUTH_REGEX,
242
- REDACTED_AUTH
256
+ REDACTED_AUTH,
257
+ BUILD_FAILED_EXIT_CODE
243
258
  });
@@ -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
  });
@@ -125,7 +125,7 @@ const packageWrapper = (bsConfig, packageDir, packageFile, md5data, instrumentBl
125
125
  Object.assign(obj, { packageArchieveCreated: true });
126
126
  return resolve(obj);
127
127
  }).catch((err) => {
128
- obj.error = err.stack.substring(0,100);
128
+ obj.error = err.stack ? err.stack.toString().substring(0,100) : err.toString().substring(0,100);
129
129
  return resolve(obj);
130
130
  })
131
131
  })
@@ -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 whilstCallback(null, body);
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
- printInitialLog();
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
- printSpecData(JSON.parse(specDetails))
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;
@@ -85,6 +85,21 @@ exports.getErrorCodeFromMsg = (errMsg) => {
85
85
  case Constants.validationMessages.INVALID_LOCAL_ASYNC_ARGS:
86
86
  errorCode = 'invalid_local_async_args';
87
87
  break;
88
+ case Constants.validationMessages.INVALID_GEO_LOCATION:
89
+ errorCode = 'invalid_geo_location';
90
+ break;
91
+ case Constants.validationMessages.NOT_ALLOWED_GEO_LOCATION_AND_LOCAL_MODE:
92
+ errorCode = 'not_allowed_geo_location_and_local_mode';
93
+ break;
94
+ case Constants.validationMessages.HOME_DIRECTORY_NOT_FOUND:
95
+ errorCode = 'home_directory_not_found';
96
+ break;
97
+ case Constants.validationMessages.HOME_DIRECTORY_NOT_A_DIRECTORY:
98
+ errorCode = 'home_directory_not_a_directory';
99
+ break;
100
+ case Constants.validationMessages.CYPRESS_CONFIG_FILE_NOT_PART_OF_HOME_DIRECTORY:
101
+ errorCode = 'cypress_config_file_not_part_of_home_directory';
102
+ break;
88
103
  }
89
104
  if (
90
105
  errMsg.includes("Please use --config-file <path to browserstack.json>.")
@@ -272,6 +287,28 @@ exports.setCypressConfigFilename = (bsConfig, args) => {
272
287
  }
273
288
  }
274
289
 
290
+ exports.verifyGeolocationOption = () => {
291
+ let glOptionsSet = (this.searchForOption('-gl') || this.searchForOption('--gl'));
292
+ let geoHyphenLocationOptionsSet = (this.searchForOption('-geo-location') || this.searchForOption('--geo-location'));
293
+ let geoLocationOptionsSet = (this.searchForOption('-geolocation') || this.searchForOption('--geolocation'));
294
+ return (glOptionsSet || geoHyphenLocationOptionsSet || geoLocationOptionsSet);
295
+ }
296
+
297
+ exports.setGeolocation = (bsConfig, args) => {
298
+ let userProvidedGeolocation = this.verifyGeolocationOption();
299
+ bsConfig.run_settings.userProvidedGeolocation = (userProvidedGeolocation || (!this.isUndefined(bsConfig.run_settings.geolocation)));
300
+
301
+ if (userProvidedGeolocation && !this.isUndefined(args.geolocation)) {
302
+ bsConfig.run_settings.geolocation = args.geolocation;
303
+ }
304
+
305
+ if (this.isUndefined(bsConfig.run_settings.geolocation)){
306
+ bsConfig.run_settings.geolocation = null;
307
+ } else {
308
+ bsConfig.run_settings.geolocation = bsConfig.run_settings.geolocation.toUpperCase();
309
+ }
310
+ }
311
+
275
312
  // specs can be passed from bstack configuration file
276
313
  // specs can be passed via command line args as a string
277
314
  // command line args takes precedence over config
@@ -556,11 +593,6 @@ exports.setLocalIdentifier = (bsConfig, args) => {
556
593
  !this.isUndefined(bsConfig["connection_settings"]["local_identifier"])
557
594
  ){
558
595
  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
596
  }
565
597
  };
566
598
 
@@ -600,9 +632,18 @@ exports.setLocalMode = (bsConfig, args) => {
600
632
  exports.setupLocalTesting = (bsConfig, args, rawArgs) => {
601
633
  return new Promise(async (resolve, reject) => {
602
634
  if( bsConfig['connection_settings'] && bsConfig['connection_settings']['local'] && String(bsConfig['connection_settings']['local']) === "true" ){
603
- let localIdentifierRunning = await this.checkLocalIdentifierRunning(
604
- bsConfig, bsConfig['connection_settings']['local_identifier']
605
- );
635
+ let localBinaryRunning = await this.checkLocalBinaryRunning(bsConfig, bsConfig['connection_settings']['local_identifier']);
636
+ let localIdentifierRunning;
637
+ if (localBinaryRunning['should_spawn_binary'] == true) {
638
+ localIdentifierRunning = false;
639
+ if(this.isUndefined(bsConfig["connection_settings"]["local_identifier"])) {
640
+ bsConfig["connection_settings"]["local_identifier"] = this.generateLocalIdentifier(bsConfig['connection_settings']['local_mode']);
641
+ }
642
+ } else {
643
+ localIdentifierRunning = true;
644
+ process.env.BSTACK_CYPRESS_LOCAL_BINARY_ALREADY_RUNNING = "true"; // shows message when binary is not spawned by the CLI process
645
+ process.env.BSTACK_CYPRESS_LOCAL_BINARY_RUNNING = "true";
646
+ }
606
647
  if (!localIdentifierRunning){
607
648
  bsConfig.connection_settings.usedAutoLocal = true;
608
649
  var bs_local = this.getLocalBinary();
@@ -611,6 +652,7 @@ exports.setupLocalTesting = (bsConfig, args, rawArgs) => {
611
652
  logger.info('Setting up Local testing...');
612
653
  bs_local.start(bs_local_args, function (localStartError) {
613
654
  if (that.isUndefined(localStartError)) {
655
+ process.env.BSTACK_CYPRESS_LOCAL_BINARY_RUNNING = "true";
614
656
  resolve(bs_local);
615
657
  } else {
616
658
  let message = `name: ${localStartError.name}, message: ${localStartError.message}, extra: ${localStartError.extra}`,
@@ -638,22 +680,6 @@ exports.setupLocalTesting = (bsConfig, args, rawArgs) => {
638
680
 
639
681
  exports.stopLocalBinary = (bsConfig, bs_local, args, rawArgs) => {
640
682
  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
683
  if (!this.isUndefined(bs_local) && bs_local.isRunning() && bsConfig['connection_settings'] && bsConfig['connection_settings']['local_mode'].toLowerCase() != "always-on") {
658
684
  let that = this;
659
685
  bs_local.stop(function (localStopError) {
@@ -707,35 +733,26 @@ exports.generateLocalIdentifier = (mode) => {
707
733
  return Buffer.from(local_identifier).toString("base64");
708
734
  };
709
735
 
710
- exports.checkLocalIdentifierRunning = (bsConfig, localIdentifier) => {
736
+ exports.checkLocalBinaryRunning = (bsConfig, localIdentifier) => {
711
737
  let options = {
712
- url: `${config.localTestingListUrl}?auth_token=${bsConfig.auth.access_key}&state=running`,
738
+ url: `${config.cypress_v1}/local_binary_running_check`,
713
739
  auth: {
714
740
  user: bsConfig.auth.username,
715
741
  password: bsConfig.auth.access_key,
716
742
  },
717
743
  headers: {
744
+ 'Content-Type': 'application/json',
718
745
  'User-Agent': this.getUserAgent(),
719
746
  },
747
+ body: JSON.stringify({ localIdentifier: localIdentifier}),
720
748
  };
721
- let that = this;
722
749
  return new Promise ( function(resolve, reject) {
723
- request.get(options, function (err, resp, body) {
750
+ request.post(options, function (err, resp, body) {
724
751
  if(err){
725
752
  reject(err);
726
753
  }
727
754
  let response = JSON.parse(body);
728
- let localInstances = [];
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));
755
+ resolve(response);
739
756
  });
740
757
  });
741
758
  };
@@ -891,7 +908,7 @@ exports.setBrowsers = async (bsConfig, args) => {
891
908
  browsersList.forEach((browser)=>{
892
909
  let browserHash = {}
893
910
  let osBrowserDetails = browser.split(':')
894
- browserHash['os'] = osBrowserDetails[1].trim()
911
+ if (!this.isUndefined(osBrowserDetails[1])) browserHash['os'] = osBrowserDetails[1].trim()
895
912
  let browserDetails = osBrowserDetails[0].split('@')
896
913
  browserHash['browser'] = browserDetails[0].trim()
897
914
  browserHash['versions'] = []
@@ -1010,7 +1027,6 @@ exports.stopBrowserStackBuild = async (bsConfig, args, buildId, rawArgs) => {
1010
1027
  logger.info(message);
1011
1028
  }
1012
1029
  } catch(err) {
1013
- console.log(err);
1014
1030
  message = Constants.userMessages.BUILD_STOP_FAILED;
1015
1031
  messageType = Constants.messageTypes.ERROR;
1016
1032
  errorCode = 'api_failed_build_stop';
@@ -1053,3 +1069,14 @@ exports.fetchZipSize = (fileName) => {
1053
1069
  return 0;
1054
1070
  }
1055
1071
  }
1072
+
1073
+ exports.getVideoConfig = (cypressJson) => {
1074
+ let conf = {
1075
+ video: true,
1076
+ videoUploadOnPasses: true
1077
+ }
1078
+ if (!this.isUndefined(cypressJson.video)) conf.video = cypressJson.video;
1079
+ if (!this.isUndefined(cypressJson.videoUploadOnPasses)) conf.videoUploadOnPasses = cypressJson.videoUploadOnPasses;
1080
+
1081
+ return conf;
1082
+ }
@@ -10,9 +10,18 @@ const config = require("./config"),
10
10
  Constants = require("./constants"),
11
11
  utils = require("./utils");
12
12
 
13
- const uploadSuits = (bsConfig, filePath, opts) => {
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
- let startTime = Date.now();
24
+ obj.startTime = Date.now();
16
25
 
17
26
  if (opts.urlPresent) {
18
27
  return resolve({ [opts.md5ReturnKey]: opts.url });
@@ -21,28 +30,26 @@ const uploadSuits = (bsConfig, filePath, opts) => {
21
30
  return resolve({});
22
31
  }
23
32
 
24
- let size = fs.lstatSync(filePath).size;
33
+ let size = obj.size;
25
34
 
26
35
  // create new progress bar
27
- let bar1 = new cliProgress.SingleBar({
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
55
  reject(err);
@@ -55,7 +62,7 @@ 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;
65
+ responseData["time"] = Date.now() - obj.startTime;
59
66
  return reject(responseData["error"]);
60
67
  } else {
61
68
  return reject(Constants.validationMessages.INVALID_DEFAULT_AUTH_PARAMS);
@@ -65,7 +72,7 @@ const uploadSuits = (bsConfig, filePath, opts) => {
65
72
  return resolve({});
66
73
  }
67
74
  if(responseData && responseData["error"]){
68
- responseData["time"] = Date.now() - startTime;
75
+ responseData["time"] = Date.now() - obj.startTime;
69
76
  reject(responseData["error"]);
70
77
  } else {
71
78
  if (resp.statusCode == 413) {
@@ -75,30 +82,26 @@ const uploadSuits = (bsConfig, filePath, opts) => {
75
82
  }
76
83
  }
77
84
  } else {
78
- bar1.update(100, {
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
- var q = setInterval(function () {
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
- let zipUpload = uploadSuits(bsConfig, config.fileName, zipOptions);
120
- let npmPackageUpload = uploadSuits(bsConfig, config.packageFileName, npmOptions);
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,6 +147,8 @@ const uploadCypressZip = (bsConfig, md5data, packageData) => {
130
147
  });
131
148
  return resolve(obj);
132
149
  }).catch((error) => {
150
+ purgeUploadBar(testZipUploadObj);
151
+ purgeUploadBar(npmPackageZipUploadObj);
133
152
  return reject(error);
134
153
  })
135
154
  })
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 = yargs.argv;
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 = yargs.argv;
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 = yargs.argv;
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 = yargs.argv;
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,
@@ -240,7 +246,7 @@ var argv = yargs
240
246
  }
241
247
  })
242
248
  .command('generate-report', Constants.cliMessages.GENERATE_REPORT.INFO, function(yargs) {
243
- let rawArgv = yargs.argv;
249
+ let rawArgv = process.argv.slice(2);
244
250
  argv = yargs
245
251
  .usage('usage: $0 generate-report <buildId>')
246
252
  .demand(1, Constants.cliMessages.BUILD.DEMAND)
@@ -256,7 +262,7 @@ var argv = yargs
256
262
  }
257
263
  })
258
264
  .command('generate-downloads', Constants.cliMessages.GENERATE_DOWNLOADS.INFO, function(yargs) {
259
- let rawArgv = yargs.argv;
265
+ let rawArgv = process.argv.slice(2);
260
266
  argv = yargs
261
267
  .usage('usage: $0 generate-downloads <buildId>')
262
268
  .demand(1, Constants.cliMessages.BUILD.DEMAND)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "browserstack-cypress-cli",
3
- "version": "1.11.1",
3
+ "version": "1.12.1",
4
4
  "description": "BrowserStack Cypress CLI for Cypress integration with BrowserStack's remote devices.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -27,7 +27,7 @@
27
27
  "unzipper": "^0.10.11",
28
28
  "update-notifier": "^5.1.0",
29
29
  "uuid": "^8.3.2",
30
- "winston": "^2.3.1",
30
+ "winston": "2.4.4",
31
31
  "yargs": "^14.2.3"
32
32
  },
33
33
  "repository": {