Skip to content

Commit 3f1ffcf

Browse files
committed
code review updates
1 parent a9b9966 commit 3f1ffcf

File tree

5 files changed

+16
-40
lines changed

5 files changed

+16
-40
lines changed

docs/projects.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ The list should contain the name of the components, as they're registered in the
103103

104104
#### project.ios.automaticPodsInstallation
105105

106-
A boolean value to determine if you want to automatically install CocoaPods when running `run-ios` or `build-ios` command and:
106+
A boolean value to determine if you want to automatically install CocoaPods when running `run-ios` or `build-ios` command when:
107107
- they are not yet installed
108108
- a new dependency visible for autolinking is installed
109109
- a version of existing native dependency has changed

packages/cli-platform-ios/src/commands/buildIOS/index.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,11 @@ import {getConfiguration} from './getConfiguration';
1313
import {getXcodeProjectAndDir} from './getXcodeProjectAndDir';
1414
import resolvePods from '../../tools/pods';
1515
import getArchitecture from '../../tools/getArchitecture';
16-
import forcePodsNoEffectLogger from '../../tools/forcePodsNoEffectLogger';
1716

1817
async function buildIOS(_: Array<string>, ctx: Config, args: BuildFlags) {
1918
const {xcodeProject, sourceDir} = getXcodeProjectAndDir(ctx.project.ios);
2019

21-
if (ctx.project.ios?.automaticPodsInstallation) {
20+
if (ctx.project.ios?.automaticPodsInstallation || args.forcePods) {
2221
const isAppRunningNewArchitecture = ctx.project.ios?.sourceDir
2322
? await getArchitecture(ctx.project.ios?.sourceDir)
2423
: undefined;
@@ -27,8 +26,6 @@ async function buildIOS(_: Array<string>, ctx: Config, args: BuildFlags) {
2726
forceInstall: args.forcePods,
2827
newArchEnabled: isAppRunningNewArchitecture,
2928
});
30-
} else if (args.forcePods) {
31-
forcePodsNoEffectLogger();
3229
}
3330

3431
process.chdir(sourceDir);

packages/cli-platform-ios/src/commands/runIOS/index.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import getSimulators from '../../tools/getSimulators';
3030
import {getXcodeProjectAndDir} from '../buildIOS/getXcodeProjectAndDir';
3131
import resolvePods from '../../tools/pods';
3232
import getArchitecture from '../../tools/getArchitecture';
33-
import forcePodsNoEffectLogger from '../../tools/forcePodsNoEffectLogger';
3433

3534
export interface FlagsT extends BuildFlags {
3635
simulator?: string;
@@ -49,7 +48,7 @@ async function runIOS(_: Array<string>, ctx: Config, args: FlagsT) {
4948
let {packager, port} = args;
5049

5150
// check if pods need to be installed
52-
if (ctx.project.ios?.automaticPodsInstallation) {
51+
if (ctx.project.ios?.automaticPodsInstallation || args.forcePods) {
5352
const isAppRunningNewArchitecture = ctx.project.ios?.sourceDir
5453
? await getArchitecture(ctx.project.ios?.sourceDir)
5554
: undefined;
@@ -58,8 +57,6 @@ async function runIOS(_: Array<string>, ctx: Config, args: FlagsT) {
5857
forceInstall: args.forcePods,
5958
newArchEnabled: isAppRunningNewArchitecture,
6059
});
61-
} else if (args.forcePods) {
62-
forcePodsNoEffectLogger();
6360
}
6461

6562
if (packager) {

packages/cli-platform-ios/src/tools/forcePodsNoEffectLogger.ts

Lines changed: 0 additions & 16 deletions
This file was deleted.

packages/cli/src/commands/init/init.ts

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,8 @@ async function createFromTemplate({
170170
packageName,
171171
});
172172

173-
createDefaultConfigFile(projectDirectory);
173+
createDefaultConfigFile(projectDirectory, loader);
174174

175-
loader.succeed();
176175
const {postInitScript} = templateConfig;
177176
if (postInitScript) {
178177
loader.info('Executing post init script ');
@@ -285,27 +284,25 @@ It's created by CLI rather than being a part of a template to avoid displaying t
285284
as it might bring confusion for existing projects where this change might not be applicable.
286285
For more details, see https://github.com/react-native-community/cli/blob/main/docs/projects.md#projectiosautomaticpodsinstallation
287286
*/
288-
function createDefaultConfigFile(directory: string) {
287+
function createDefaultConfigFile(directory: string, loader: Loader) {
289288
const cliConfigContent = {
290289
project: {
291290
ios: {
292291
automaticPodsInstallation: true,
293292
},
294293
},
295294
};
296-
295+
const configFileContent = `module.exports = ${JSON.stringify(
296+
cliConfigContent,
297+
null,
298+
2,
299+
)}`;
297300
const filepath = 'react-native.config.js';
298301
try {
299302
if (!doesDirectoryExist(path.join(directory, filepath))) {
300-
fs.writeFileSync(
301-
filepath,
302-
sanitizeConfigFile(
303-
`module.exports = ${JSON.stringify(cliConfigContent, null, 2)}`,
304-
),
305-
{
306-
encoding: 'utf-8',
307-
},
308-
);
303+
fs.writeFileSync(filepath, sanitizeConfigFile(configFileContent), {
304+
encoding: 'utf-8',
305+
});
309306
} else {
310307
const existingConfigFile = require(path.join(directory, filepath));
311308

@@ -320,11 +317,12 @@ function createDefaultConfigFile(directory: string) {
320317
encoding: 'utf-8',
321318
});
322319
}
320+
loader.succeed();
323321
} catch {
324-
logger.warn(
322+
loader.warn(
325323
`Could not create custom ${chalk.bold(
326324
'react-native.config.js',
327-
)} file. You can create it manually in your project's root folder.`,
325+
)} file. You can create it manually in your project's root folder with the following content: \n\n${configFileContent}`,
328326
);
329327
}
330328
}

0 commit comments

Comments
 (0)