File tree Expand file tree Collapse file tree 4 files changed +73
-1
lines changed Expand file tree Collapse file tree 4 files changed +73
-1
lines changed Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+ var config = require ( '../helpers/config' ) ;
3
+ var request = require ( 'request' )
4
+ var logger = require ( "../helpers/logger" ) ;
5
+ var Constants = require ( "../helpers/constants" )
6
+ var fileHelpers = require ( '../helpers/fileHelpers' ) ;
7
+ var capabilityHelper = require ( "../helpers/capabilityHelper" ) ;
8
+
9
+
10
+ let updateConfig = function ( args ) {
11
+ let bsConfigPath = process . cwd ( ) + args . cf ;
12
+ logger . log ( `Updating config from ${ args . cf } ` ) ;
13
+
14
+ var currentConfig = require ( bsConfigPath ) ;
15
+
16
+ var configTemplate = require ( '../templates/configTemplate' ) ( )
17
+ var newConfig = JSON . parse ( configTemplate ) ;
18
+
19
+ function allDone ( ) {
20
+ logger . log ( Constants . userMessages . CONFIG_FILE_CREATED ) ;
21
+ }
22
+
23
+ capabilityHelper . validate ( currentConfig ) . then ( function ( validatedConfig ) {
24
+ logger . log ( `${ currentConfig } ` ) ;
25
+
26
+ for ( const key in newConfig ) {
27
+ if ( currentConfig [ key ] === undefined ) {
28
+ currentConfig [ key ] = newConfig [ key ]
29
+ }
30
+ }
31
+
32
+ var EOL = require ( 'os' ) . EOL
33
+ var file = [
34
+ JSON . stringify ( currentConfig , null , 4 )
35
+ ] . join ( EOL )
36
+
37
+ var config = {
38
+ file : file ,
39
+ path : bsConfigPath
40
+ } ;
41
+
42
+ fileHelpers . write ( config , null , allDone ) ;
43
+ } ) ;
44
+ }
45
+
46
+ module . exports = updateConfig ;
Original file line number Diff line number Diff line change @@ -47,6 +47,11 @@ const cliMessages = {
47
47
INFO : "Run your tests on BrowserStack." ,
48
48
DESC : "Path to BrowserStack config" ,
49
49
CONFIG_DEMAND : "config file is required"
50
+ } ,
51
+ UPDATE_CONFIG : {
52
+ INFO : "Updates the browserstack.json with the latest version" ,
53
+ CONFIG_DEMAND_DESC : "Path to BrowserStack config" ,
54
+ CONFIG_DEMAND : "config file is required"
50
55
}
51
56
}
52
57
Original file line number Diff line number Diff line change @@ -37,6 +37,26 @@ var argv = yargs
37
37
return require ( './commands/init' ) ( argv ) ;
38
38
}
39
39
} )
40
+ . command ( 'update-config' , Constants . cliMessages . UPDATE_CONFIG . INFO , function ( yargs ) {
41
+ argv = yargs
42
+ . usage ( 'usage: $0 update-config' )
43
+ . options ( 'cf' , {
44
+ alias : 'config-file' ,
45
+ describe : Constants . cliMessages . UPDATE_CONFIG . CONFIG_DEMAND_DESC ,
46
+ default : '/browserstack.json' ,
47
+ type : 'string' ,
48
+ nargs : 1 ,
49
+ demand : true ,
50
+ demand : Constants . cliMessages . UPDATE_CONFIG . CONFIG_DEMAND
51
+ } )
52
+ . help ( 'help' )
53
+ . wrap ( null )
54
+ . argv
55
+
56
+ if ( checkCommands ( yargs , argv , 1 ) ) {
57
+ return require ( './commands/updateConfig' ) ( argv ) ;
58
+ }
59
+ } )
40
60
. command ( 'build-info' , Constants . cliMessages . BUILD . INFO , function ( yargs ) {
41
61
argv = yargs
42
62
. usage ( 'usage: $0 <buildId>' )
Original file line number Diff line number Diff line change @@ -12,14 +12,15 @@ module.exports = function () {
12
12
}
13
13
] ,
14
14
"run_settings" : {
15
- "package_json_path" : "/path/to/package.json" ,
16
15
"cypress_proj_dir" : "/dir/to/cypress.json" ,
17
16
"project" : "project-name" ,
18
17
"customBuildName" : "build-name"
19
18
} ,
20
19
"connection_settings" : {
21
20
"local" : false ,
22
21
"localIdentifier" : null
22
+ } ,
23
+ "cypress_dependencies" : {
23
24
}
24
25
}
25
26
var EOL = require ( 'os' ) . EOL
You can’t perform that action at this time.
0 commit comments