Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/cli-doctor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"@react-native-community/cli-tools": "12.0.0-alpha.7",
"chalk": "^4.1.2",
"command-exists": "^1.2.8",
"deepmerge": "^4.3.0",
"envinfo": "^7.7.2",
"execa": "^5.0.0",
"hermes-profile-transformer": "^0.0.6",
Expand Down
40 changes: 35 additions & 5 deletions packages/cli-doctor/src/tools/healthchecks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import {Healthchecks, HealthCheckCategory} from '../../types';
import loadConfig from '@react-native-community/cli-config';
import xcodeEnv from './xcodeEnv';
import packager from './packager';
import deepmerge from 'deepmerge';
import {logger} from '@react-native-community/cli-tools';

export const HEALTHCHECK_TYPES = {
ERROR: 'ERROR',
Expand All @@ -28,21 +30,48 @@ type Options = {

export const getHealthchecks = ({contributor}: Options): Healthchecks => {
let additionalChecks: HealthCheckCategory[] = [];
let projectSpecificHealthchecks = {};
let config;

// Doctor can run in a detached mode, where there isn't a config so this can fail
try {
let config = loadConfig();
config = loadConfig();
additionalChecks = config.healthChecks;

if (config.reactNativePath) {
projectSpecificHealthchecks = {
common: {
label: 'Common',
healthchecks: [packager],
},
android: {
label: 'Android',
healthchecks: [androidSDK],
},
...(process.platform === 'darwin' && {
ios: {
label: 'iOS',
healthchecks: [xcodeEnv],
},
}),
};
}
} catch {}

return {
if (!config) {
logger.log();
logger.info(
'Detected that command has been run outside of React Native project, running basic healthchecks.',
);
}

const defaultHealthchecks = {
common: {
label: 'Common',
healthchecks: [
nodeJS,
yarn,
npm,
packager,
...(process.platform === 'darwin' ? [watchman] : []),
],
},
Expand All @@ -52,7 +81,6 @@ export const getHealthchecks = ({contributor}: Options): Healthchecks => {
adb,
jdk,
androidStudio,
androidSDK,
androidHomeEnvVariable,
...(contributor ? [androidNDK] : []),
],
Expand All @@ -61,10 +89,12 @@ export const getHealthchecks = ({contributor}: Options): Healthchecks => {
? {
ios: {
label: 'iOS',
healthchecks: [xcode, ruby, cocoaPods, iosDeploy, xcodeEnv],
healthchecks: [xcode, ruby, cocoaPods, iosDeploy],
},
}
: {}),
...additionalChecks,
};

return deepmerge(defaultHealthchecks, projectSpecificHealthchecks);
};