@@ -7,7 +7,8 @@ const archiver = require("../helpers/archiver"),
77 capabilityHelper = require ( "../helpers/capabilityHelper" ) ,
88 Constants = require ( "../helpers/constants" ) ,
99 utils = require ( "../helpers/utils" ) ,
10- fileHelpers = require ( "../helpers/fileHelpers" ) ;
10+ fileHelpers = require ( "../helpers/fileHelpers" ) ,
11+ syncRunner = require ( "../helpers/syncRunner" ) ;
1112
1213module . exports = function run ( args ) {
1314 let bsConfigPath = utils . getConfigPath ( args . cf ) ;
@@ -17,8 +18,7 @@ module.exports = function run(args) {
1718 return utils . validateBstackJson ( bsConfigPath ) . then ( function ( bsConfig ) {
1819 utils . setUsageReportingFlag ( bsConfig , args . disableUsageReporting ) ;
1920
20- // setting setDefaultAuthHash to {} if not present and set via env variables or via args.
21- utils . setDefaultAuthHash ( bsConfig , args ) ;
21+ utils . setDefaults ( bsConfig , args ) ;
2222
2323 // accept the username from command line or env variable if provided
2424 utils . setUsername ( bsConfig , args ) ;
@@ -45,22 +45,23 @@ module.exports = function run(args) {
4545 utils . setLocalIdentifier ( bsConfig ) ;
4646
4747 // Validate browserstack.json values and parallels specified via arguments
48- return capabilityHelper . validate ( bsConfig , args ) . then ( function ( validated ) {
49- logger . info ( validated ) ;
48+ return capabilityHelper . validate ( bsConfig , args ) . then ( function ( cypressJson ) {
49+
50+ //get the number of spec files
51+ let specFiles = utils . getNumberOfSpecFiles ( bsConfig , args , cypressJson ) ;
5052
5153 // accept the number of parallels
52- utils . setParallels ( bsConfig , args ) ;
54+ utils . setParallels ( bsConfig , args , specFiles . length ) ;
5355
5456 // Archive the spec files
5557 return archiver . archive ( bsConfig . run_settings , config . fileName , args . exclude ) . then ( function ( data ) {
5658
5759 // Uploaded zip file
5860 return zipUploader . zipUpload ( bsConfig , config . fileName ) . then ( function ( zip ) {
59-
6061 // Create build
6162 return build . createBuild ( bsConfig , zip ) . then ( function ( data ) {
6263 let message = `${ data . message } ! ${ Constants . userMessages . BUILD_CREATED } with build id: ${ data . build_id } ` ;
63- let dashboardLink = `${ Constants . userMessages . VISIT_DASHBOARD } ${ config . dashboardUrl } ${ data . build_id } ` ;
64+ let dashboardLink = `${ Constants . userMessages . VISIT_DASHBOARD } ${ data . dashboard_url } ` ;
6465 utils . exportResults ( data . build_id , `${ config . dashboardUrl } ${ data . build_id } ` ) ;
6566 if ( ( utils . isUndefined ( bsConfig . run_settings . parallels ) && utils . isUndefined ( args . parallels ) ) || ( ! utils . isUndefined ( bsConfig . run_settings . parallels ) && bsConfig . run_settings . parallels == Constants . cliMessages . RUN . DEFAULT_PARALLEL_MESSAGE ) ) {
6667 logger . warn ( Constants . userMessages . NO_PARALLELS ) ;
@@ -70,10 +71,21 @@ module.exports = function run(args) {
7071 logger . warn ( Constants . userMessages . CYPRESS_VERSION_CHANGED ) ;
7172 }
7273
73- if ( ! args . disableNpmWarning && bsConfig . run_settings . npm_dependencies && Object . keys ( bsConfig . run_settings . npm_dependencies ) . length <= 0 ) logger . warn ( Constants . userMessages . NO_NPM_DEPENDENCIES ) ;
74+ if ( ! args . disableNpmWarning && bsConfig . run_settings . npm_dependencies && Object . keys ( bsConfig . run_settings . npm_dependencies ) . length <= 0 ) {
75+ logger . warn ( Constants . userMessages . NO_NPM_DEPENDENCIES ) ;
76+ logger . warn ( Constants . userMessages . NO_NPM_DEPENDENCIES_READ_MORE ) ;
77+ }
78+
79+ if ( args . sync ) {
80+ syncRunner . pollBuildStatus ( bsConfig , data ) . then ( ( exitCode ) => {
81+ utils . sendUsageReport ( bsConfig , args , `${ message } \n${ dashboardLink } ` , Constants . messageTypes . SUCCESS , null ) ;
82+ utils . handleSyncExit ( exitCode , data . dashboard_url )
83+ } ) ;
84+ }
7485
7586 logger . info ( message ) ;
7687 logger . info ( dashboardLink ) ;
88+ if ( ! args . sync ) logger . info ( Constants . userMessages . EXIT_SYNC_CLI_MESSAGE . replace ( "<build-id>" , data . build_id ) ) ;
7789 utils . sendUsageReport ( bsConfig , args , `${ message } \n${ dashboardLink } ` , Constants . messageTypes . SUCCESS , null ) ;
7890 return ;
7991 } ) . catch ( function ( err ) {
@@ -85,9 +97,8 @@ module.exports = function run(args) {
8597 // Zip Upload failed
8698 logger . error ( err ) ;
8799 logger . error ( Constants . userMessages . ZIP_UPLOAD_FAILED ) ;
88- utils . sendUsageReport ( bsConfig , args , `${ err } \n${ Constants . userMessages . ZIP_UPLOAD_FAILED } ` , Constants . messageTypes . ERROR , 'zip_upload_failed' ) ;
89- } ) . finally ( function ( ) {
90100 fileHelpers . deleteZip ( ) ;
101+ utils . sendUsageReport ( bsConfig , args , `${ err } \n${ Constants . userMessages . ZIP_UPLOAD_FAILED } ` , Constants . messageTypes . ERROR , 'zip_upload_failed' ) ;
91102 } ) ;
92103 } ) . catch ( function ( err ) {
93104 // Zipping failed
0 commit comments