Skip to content

Commit 5d2ce3b

Browse files
author
Riccardo Cipolleschi
committed
[Feat] Add support for .xcode.env file in init and doctor commands
1 parent e044e7b commit 5d2ce3b

File tree

4 files changed

+26
-2
lines changed

4 files changed

+26
-2
lines changed

packages/cli-doctor/src/tools/healthchecks/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import cocoaPods from './cocoaPods';
1111
import iosDeploy from './iosDeploy';
1212
import {Healthchecks, HealthCheckCategory} from '../../types';
1313
import loadConfig from '@react-native-community/cli-config';
14+
import xcodeEnv from './xcodeEnv';
1415

1516
export const HEALTHCHECK_TYPES = {
1617
ERROR: 'ERROR',
@@ -55,7 +56,7 @@ export const getHealthchecks = ({contributor}: Options): Healthchecks => {
5556
? {
5657
ios: {
5758
label: 'iOS',
58-
healthchecks: [xcode, cocoaPods, iosDeploy],
59+
healthchecks: [xcode, cocoaPods, iosDeploy, xcodeEnv],
5960
},
6061
}
6162
: {}),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import {HealthCheckInterface} from '../../types';
2+
import fs from "fs";
3+
import { promisify } from 'util';
4+
5+
export default {
6+
label: '.xcode.env',
7+
description: 'File to customize Xcode environment',
8+
getDiagnostics: async () => {
9+
return {
10+
needsToBeFixed: fs.existsSync("./ios/.xcode.env")
11+
};
12+
},
13+
runAutomaticFix: async () => {
14+
const filePath = '/ios/.xcode.env';
15+
const src = "./node_modules/react-native/template" + filePath;
16+
const dest = "." + filePath;
17+
18+
const copyFileAsync = promisify(fs.copyFile);
19+
await copyFileAsync(src, dest);
20+
},
21+
} as HealthCheckInterface;

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

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ const UNDERSCORED_DOTFILES = [
6969
'editorconfig',
7070
'bundle',
7171
'ruby-version',
72+
'xcode.env'
7273
];
7374

7475
async function processDotfiles(filePath: string) {

packages/cli/src/tools/generator/copyProjectTemplateAndReplace.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ function translateFilePath(filePath: string) {
148148
.replace('_prettierrc.js', '.prettierrc.js')
149149
.replace('_bundle', '.bundle')
150150
.replace('_ruby-version', '.ruby-version')
151-
.replace('_watchmanconfig', '.watchmanconfig');
151+
.replace('_watchmanconfig', '.watchmanconfig')
152+
.replace('_xcode.env', '.xcode.env');
152153
}
153154

154155
function upgradeFileContentChangedCallback(

0 commit comments

Comments
 (0)