Skip to content

Commit ba2dda0

Browse files
committed
chore(CLI): modify log messages
1 parent 791bc47 commit ba2dda0

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

cli/commands/initCommand/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ const { program } = require('commander');
44

55
program
66
.command('init')
7-
.description('Initialize CodePush project')
7+
.description('Automatically performs iOS/Android native configurations to initialize the CodePush project.')
88
.action(async () => {
9-
console.log('Start initializing CodePush...');
9+
console.log('log: Start initializing CodePush...');
1010
await initAndroid();
1111
await initIos();
12-
console.log('CodePush has been successfully initialized.');
12+
console.log('log: CodePush has been successfully initialized.');
1313
});
1414

cli/commands/initCommand/initAndroid.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const { EOL } = require('os');
44

55
function modifyMainApplicationKt(mainApplicationContent) {
66
if (mainApplicationContent.includes('CodePush.getJSBundleFile()')) {
7-
console.log('MainApplication.kt already has CodePush initialized.');
7+
console.log('log: MainApplication.kt already has CodePush initialized.');
88
return mainApplicationContent;
99
}
1010
return mainApplicationContent
@@ -13,26 +13,26 @@ function modifyMainApplicationKt(mainApplicationContent) {
1313
}
1414

1515
async function initAndroid() {
16-
console.log('Running Android setup...');
16+
console.log('log: Running Android setup...');
1717
await applyMainApplication();
1818
}
1919

2020
async function applyMainApplication() {
2121
const mainApplicationPath = await findMainApplication();
2222
if (!mainApplicationPath) {
23-
console.log('Could not find MainApplication.kt');
23+
console.log('log: Could not find MainApplication.kt');
2424
return;
2525
}
2626

2727
if (mainApplicationPath.endsWith('.java')) {
28-
console.log('MainApplication.java is not supported. Please migrate to MainApplication.kt.');
28+
console.log('log: MainApplication.java is not supported. Please migrate to MainApplication.kt.');
2929
return;
3030
}
3131

3232
const mainApplicationContent = fs.readFileSync(mainApplicationPath, 'utf-8');
3333
const newContent = modifyMainApplicationKt(mainApplicationContent);
3434
fs.writeFileSync(mainApplicationPath, newContent);
35-
console.log('Successfully updated MainApplication.kt.');
35+
console.log('log: Successfully updated MainApplication.kt.');
3636
}
3737

3838
async function findMainApplication() {

cli/commands/initCommand/initIos.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@ const fs = require('fs');
33
const xcode = require('xcode');
44

55
async 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

3131
function findAppDelegate(searchPath) {
@@ -38,7 +38,7 @@ function findAppDelegate(searchPath) {
3838
function 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) {
5050
function 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

6868
async 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

8181
async 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

Comments
 (0)