Skip to content

Commit

Permalink
feat(doctor): adjust healthchecks based on where command was ran
Browse files Browse the repository at this point in the history
  • Loading branch information
szymonrybczak committed Aug 14, 2023
1 parent 7165558 commit a9c05a1
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions packages/cli-doctor/src/tools/healthchecks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {Healthchecks, HealthCheckCategory} from '../../types';
import loadConfig from '@react-native-community/cli-config';
import xcodeEnv from './xcodeEnv';
import packager from './packager';
import {merge} from 'lodash';

export const HEALTHCHECK_TYPES = {
ERROR: 'ERROR',
Expand All @@ -29,20 +30,40 @@ type Options = {
export const getHealthchecks = ({contributor}: Options): Healthchecks => {
let additionalChecks: HealthCheckCategory[] = [];

let projectSpecificHealthchecks = {};

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

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

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

return merge(defaultHealthchecks, projectSpecificHealthchecks);
};

0 comments on commit a9c05a1

Please sign in to comment.