@@ -7,7 +7,8 @@ const archiver = require("../helpers/archiver"),
7
7
capabilityHelper = require ( "../helpers/capabilityHelper" ) ,
8
8
Constants = require ( "../helpers/constants" ) ,
9
9
utils = require ( "../helpers/utils" ) ,
10
- fileHelpers = require ( "../helpers/fileHelpers" ) ;
10
+ fileHelpers = require ( "../helpers/fileHelpers" ) ,
11
+ syncRunner = require ( "../helpers/syncRunner" ) ;
11
12
12
13
module . exports = function run ( args ) {
13
14
let bsConfigPath = utils . getConfigPath ( args . cf ) ;
@@ -17,8 +18,7 @@ module.exports = function run(args) {
17
18
return utils . validateBstackJson ( bsConfigPath ) . then ( function ( bsConfig ) {
18
19
utils . setUsageReportingFlag ( bsConfig , args . disableUsageReporting ) ;
19
20
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 ) ;
22
22
23
23
// accept the username from command line or env variable if provided
24
24
utils . setUsername ( bsConfig , args ) ;
@@ -45,22 +45,23 @@ module.exports = function run(args) {
45
45
utils . setLocalIdentifier ( bsConfig ) ;
46
46
47
47
// 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 ) ;
50
52
51
53
// accept the number of parallels
52
- utils . setParallels ( bsConfig , args ) ;
54
+ utils . setParallels ( bsConfig , args , specFiles . length ) ;
53
55
54
56
// Archive the spec files
55
57
return archiver . archive ( bsConfig . run_settings , config . fileName , args . exclude ) . then ( function ( data ) {
56
58
57
59
// Uploaded zip file
58
60
return zipUploader . zipUpload ( bsConfig , config . fileName ) . then ( function ( zip ) {
59
-
60
61
// Create build
61
62
return build . createBuild ( bsConfig , zip ) . then ( function ( data ) {
62
63
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 } ` ;
64
65
utils . exportResults ( data . build_id , `${ config . dashboardUrl } ${ data . build_id } ` ) ;
65
66
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 ) ) {
66
67
logger . warn ( Constants . userMessages . NO_PARALLELS ) ;
@@ -70,10 +71,21 @@ module.exports = function run(args) {
70
71
logger . warn ( Constants . userMessages . CYPRESS_VERSION_CHANGED ) ;
71
72
}
72
73
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
+ }
74
85
75
86
logger . info ( message ) ;
76
87
logger . info ( dashboardLink ) ;
88
+ if ( ! args . sync ) logger . info ( Constants . userMessages . EXIT_SYNC_CLI_MESSAGE . replace ( "<build-id>" , data . build_id ) ) ;
77
89
utils . sendUsageReport ( bsConfig , args , `${ message } \n${ dashboardLink } ` , Constants . messageTypes . SUCCESS , null ) ;
78
90
return ;
79
91
} ) . catch ( function ( err ) {
@@ -85,9 +97,8 @@ module.exports = function run(args) {
85
97
// Zip Upload failed
86
98
logger . error ( err ) ;
87
99
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 ( ) {
90
100
fileHelpers . deleteZip ( ) ;
101
+ utils . sendUsageReport ( bsConfig , args , `${ err } \n${ Constants . userMessages . ZIP_UPLOAD_FAILED } ` , Constants . messageTypes . ERROR , 'zip_upload_failed' ) ;
91
102
} ) ;
92
103
} ) . catch ( function ( err ) {
93
104
// Zipping failed
0 commit comments