@@ -3,19 +3,19 @@ const fs = require('fs');
33const xcode = require ( 'xcode' ) ;
44
55async function initIos ( ) {
6- console . log ( 'Running iOS setup...' ) ;
6+ console . log ( 'log: Running iOS setup...' ) ;
77 const projectDir = path . join ( process . cwd ( ) , 'ios' ) ;
88 const files = fs . readdirSync ( projectDir ) ;
99 const xcodeprojFile = files . find ( file => file . endsWith ( '.xcodeproj' ) ) ;
1010 if ( ! xcodeprojFile ) {
11- console . log ( 'Could not find .xcodeproj file in ios directory' ) ;
11+ console . log ( 'log: Could not find .xcodeproj file in ios directory' ) ;
1212 return ;
1313 }
1414 const projectName = xcodeprojFile . replace ( '.xcodeproj' , '' ) ;
1515 const appDelegatePath = findAppDelegate ( path . join ( projectDir , projectName ) ) ;
1616
1717 if ( ! appDelegatePath ) {
18- console . log ( 'Could not find AppDelegate file' ) ;
18+ console . log ( 'log: Could not find AppDelegate file' ) ;
1919 return ;
2020 }
2121
@@ -25,7 +25,7 @@ async function initIos() {
2525 await setupObjectiveC ( appDelegatePath ) ;
2626 }
2727
28- console . log ( 'Please run `cd ios && pod install` to complete the setup.' ) ;
28+ console . log ( 'log: Please run `cd ios && pod install` to complete the setup.' ) ;
2929}
3030
3131function findAppDelegate ( searchPath ) {
@@ -38,7 +38,7 @@ function findAppDelegate(searchPath) {
3838function modifyObjectiveCAppDelegate ( appDelegateContent ) {
3939 const IMPORT_STATEMENT = '#import <CodePush/CodePush.h>' ;
4040 if ( appDelegateContent . includes ( IMPORT_STATEMENT ) ) {
41- console . log ( 'AppDelegate already has CodePush imported.' ) ;
41+ console . log ( 'log: AppDelegate already has CodePush imported.' ) ;
4242 return appDelegateContent ;
4343 }
4444
@@ -50,7 +50,7 @@ function modifyObjectiveCAppDelegate(appDelegateContent) {
5050function modifySwiftAppDelegate ( appDelegateContent ) {
5151 const CODEPUSH_CALL_STATEMENT = 'CodePush.bundleURL()' ;
5252 if ( appDelegateContent . includes ( CODEPUSH_CALL_STATEMENT ) ) {
53- console . log ( 'AppDelegate.swift already configured for CodePush.' ) ;
53+ console . log ( 'log: AppDelegate.swift already configured for CodePush.' ) ;
5454 return appDelegateContent ;
5555 }
5656
@@ -62,20 +62,20 @@ async function setupObjectiveC(appDelegatePath) {
6262 const appDelegateContent = fs . readFileSync ( appDelegatePath , 'utf-8' ) ;
6363 const newContent = modifyObjectiveCAppDelegate ( appDelegateContent ) ;
6464 fs . writeFileSync ( appDelegatePath , newContent ) ;
65- console . log ( 'Successfully updated AppDelegate.m/mm.' ) ;
65+ console . log ( 'log: Successfully updated AppDelegate.m/mm.' ) ;
6666}
6767
6868async function setupSwift ( appDelegatePath , projectDir , projectName ) {
6969 const bridgingHeaderPath = await ensureBridgingHeader ( projectDir , projectName ) ;
7070 if ( ! bridgingHeaderPath ) {
71- console . log ( 'Failed to create or find bridging header.' ) ;
71+ console . log ( 'log: Failed to create or find bridging header.' ) ;
7272 return ;
7373 }
7474
7575 const appDelegateContent = fs . readFileSync ( appDelegatePath , 'utf-8' ) ;
7676 const newContent = modifySwiftAppDelegate ( appDelegateContent ) ;
7777 fs . writeFileSync ( appDelegatePath , newContent ) ;
78- console . log ( 'Successfully updated AppDelegate.swift.' ) ;
78+ console . log ( 'log: Successfully updated AppDelegate.swift.' ) ;
7979}
8080
8181async function ensureBridgingHeader ( projectDir , projectName ) {
@@ -103,19 +103,19 @@ async function ensureBridgingHeader(projectDir, projectName) {
103103 if ( ! fs . existsSync ( bridgingHeaderAbsolutePath ) ) {
104104 fs . mkdirSync ( path . dirname ( bridgingHeaderAbsolutePath ) , { recursive : true } ) ;
105105 fs . writeFileSync ( bridgingHeaderAbsolutePath , '#import <CodePush/CodePush.h>\n' ) ;
106- console . log ( `Created bridging header at ${ bridgingHeaderAbsolutePath } ` ) ;
106+ console . log ( `log: Created bridging header at ${ bridgingHeaderAbsolutePath } ` ) ;
107107 const groupKey = myProj . findPBXGroupKey ( { name : projectName } ) ;
108108 myProj . addHeaderFile ( bridgingHeaderRelativePath , { public : true } , groupKey ) ;
109109 } else {
110110 const headerContent = fs . readFileSync ( bridgingHeaderAbsolutePath , 'utf-8' ) ;
111111 if ( ! headerContent . includes ( '#import <CodePush/CodePush.h>' ) ) {
112112 fs . appendFileSync ( bridgingHeaderAbsolutePath , '\n#import <CodePush/CodePush.h>\n' ) ;
113- console . log ( `Updated bridging header at ${ bridgingHeaderAbsolutePath } ` ) ;
113+ console . log ( `log: Updated bridging header at ${ bridgingHeaderAbsolutePath } ` ) ;
114114 }
115115 }
116116
117117 fs . writeFileSync ( projectPath , myProj . writeSync ( ) ) ;
118- console . log ( 'Updated Xcode project with bridging header path.' ) ;
118+ console . log ( 'log: Updated Xcode project with bridging header path.' ) ;
119119 resolve ( bridgingHeaderAbsolutePath ) ;
120120 } ) ;
121121 } ) ;
0 commit comments