File tree Expand file tree Collapse file tree 4 files changed +82
-0
lines changed Expand file tree Collapse file tree 4 files changed +82
-0
lines changed Original file line number Diff line number Diff line change
1
+ ( function ( ) {
2
+ // properties
3
+
4
+ const fs = require ( "fs" ) ;
5
+ const path = require ( "path" ) ;
6
+
7
+ // entry
8
+ module . exports = {
9
+ addBranchJson : addBranchJson
10
+ } ;
11
+
12
+ // updates the platforms/ios/*.xcodeproj/project.pbxproj file and adds branch.json file
13
+ function addBranchJson ( context , preferences ) {
14
+ if ( preferences . branchJson . exists ) {
15
+ const destination = path . join (
16
+ context . opts . projectRoot ,
17
+ "platforms" ,
18
+ "android" ,
19
+ "app" ,
20
+ "src" ,
21
+ "main" ,
22
+ "assets" ,
23
+ "branch.json"
24
+ ) ;
25
+ fs . copyFileSync ( preferences . branchJson . path , destination ) ;
26
+ }
27
+ }
28
+ } ) ( ) ;
Original file line number Diff line number Diff line change 5
5
const iosPlist = require ( "../ios/updatePlist.js" ) ;
6
6
const iosAssociatedDomains = require ( "../ios/updateAssociatedDomains.js" ) ;
7
7
const iosHeaderPaths = require ( "../ios/updateHeaderPaths.js" ) ;
8
+ const iosPbxproj = require ( "../ios/updatePbxproj.js" ) ;
9
+ const androidAssets = require ( "../android/updateAssets.js" ) ;
8
10
const IOS = "ios" ;
11
+ const ANDROID = "android" ;
9
12
10
13
// entry
11
14
module . exports = run ;
16
19
const platforms = context . opts . cordova . platforms ;
17
20
18
21
platforms . forEach ( platform => {
22
+ if ( platform === ANDROID ) {
23
+ androidAssets . addBranchJson ( context , preferences ) ;
24
+ }
25
+
19
26
if ( platform === IOS ) {
20
27
iosPlist . addBranchSettings ( preferences ) ;
21
28
iosAssociatedDomains . addAssociatedDomains ( preferences ) ;
22
29
iosHeaderPaths . addHeaderPaths ( ) ;
30
+ iosPbxproj . addBranchJson ( context , preferences ) ;
23
31
}
24
32
} ) ;
25
33
}
Original file line number Diff line number Diff line change
1
+ ( function ( ) {
2
+ // properties
3
+
4
+ const fs = require ( "fs" ) ;
5
+ const path = require ( "path" ) ;
6
+
7
+ // entry
8
+ module . exports = {
9
+ addBranchJson : addBranchJson
10
+ } ;
11
+
12
+ // updates the platforms/ios/*.xcodeproj/project.pbxproj file and adds branch.json file
13
+ function addBranchJson ( context , preferences ) {
14
+ if ( preferences . branchJson . exists && preferences . iosProjectModule . xcode ) {
15
+ const destination = path . join (
16
+ context . opts . projectRoot ,
17
+ "platforms" ,
18
+ "ios" ,
19
+ "branch.json"
20
+ ) ;
21
+ fs . copyFileSync ( preferences . branchJson . path , destination ) ;
22
+ preferences . iosProjectModule . xcode . addResourceFile ( destination ) ;
23
+ preferences . iosProjectModule . write ( ) ;
24
+ }
25
+ }
26
+ } ) ( ) ;
Original file line number Diff line number Diff line change 1
1
( function ( ) {
2
2
// properties
3
3
4
+ const fs = require ( "fs" ) ;
4
5
const path = require ( "path" ) ;
5
6
const xmlHelper = require ( "../lib/xmlHelper.js" ) ;
6
7
57
58
return {
58
59
projectRoot : getProjectRoot ( context ) ,
59
60
projectName : getProjectName ( configXml ) ,
61
+ branchJson : getBranchJson ( context ) ,
60
62
branchKey : getBranchKey ( branchXml , "branch-key-live" ) ,
61
63
branchKeyTest : getBranchValue ( branchXml , "branch-key-test" ) ,
62
64
branchTestMode : getBranchValue ( branchXml , "branch-test-mode" ) ,
96
98
return output ;
97
99
}
98
100
101
+ // Checks if branch.json exists in projectRoot and returns its path
102
+ function getBranchJson ( context ) {
103
+ const pathToBranchJson = path . join ( context . opts . projectRoot , "branch.json" ) ;
104
+ let exists ;
105
+
106
+ try {
107
+ fs . existsSync ( pathToBranchJson ) ;
108
+ exists = true ;
109
+ } catch ( err ) {
110
+ exists = false ;
111
+ }
112
+
113
+ return {
114
+ exists : exists ,
115
+ path : pathToBranchJson
116
+ } ;
117
+ }
118
+
99
119
// read branch value from <branch-config>
100
120
function getBranchValue ( branchXml , key ) {
101
121
return branchXml . hasOwnProperty ( key ) ? branchXml [ key ] [ 0 ] . $ . value : null ;
You can’t perform that action at this time.
0 commit comments