Skip to content

Commit

Permalink
[Feat] Add support for .xcode.env file in init and doctor commands
Browse files Browse the repository at this point in the history
  • Loading branch information
Riccardo Cipolleschi committed Apr 6, 2022
1 parent e044e7b commit 5d2ce3b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/cli-doctor/src/tools/healthchecks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import cocoaPods from './cocoaPods';
import iosDeploy from './iosDeploy';
import {Healthchecks, HealthCheckCategory} from '../../types';
import loadConfig from '@react-native-community/cli-config';
import xcodeEnv from './xcodeEnv';

export const HEALTHCHECK_TYPES = {
ERROR: 'ERROR',
Expand Down Expand Up @@ -55,7 +56,7 @@ export const getHealthchecks = ({contributor}: Options): Healthchecks => {
? {
ios: {
label: 'iOS',
healthchecks: [xcode, cocoaPods, iosDeploy],
healthchecks: [xcode, cocoaPods, iosDeploy, xcodeEnv],
},
}
: {}),
Expand Down
21 changes: 21 additions & 0 deletions packages/cli-doctor/src/tools/healthchecks/xcodeEnv.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import {HealthCheckInterface} from '../../types';
import fs from "fs";
import { promisify } from 'util';

export default {
label: '.xcode.env',
description: 'File to customize Xcode environment',
getDiagnostics: async () => {
return {
needsToBeFixed: fs.existsSync("./ios/.xcode.env")
};
},
runAutomaticFix: async () => {
const filePath = '/ios/.xcode.env';
const src = "./node_modules/react-native/template" + filePath;
const dest = "." + filePath;

const copyFileAsync = promisify(fs.copyFile);
await copyFileAsync(src, dest);
},
} as HealthCheckInterface;
1 change: 1 addition & 0 deletions packages/cli/src/commands/init/editTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const UNDERSCORED_DOTFILES = [
'editorconfig',
'bundle',
'ruby-version',
'xcode.env'
];

async function processDotfiles(filePath: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ function translateFilePath(filePath: string) {
.replace('_prettierrc.js', '.prettierrc.js')
.replace('_bundle', '.bundle')
.replace('_ruby-version', '.ruby-version')
.replace('_watchmanconfig', '.watchmanconfig');
.replace('_watchmanconfig', '.watchmanconfig')
.replace('_xcode.env', '.xcode.env');
}

function upgradeFileContentChangedCallback(
Expand Down

0 comments on commit 5d2ce3b

Please sign in to comment.