From a9c05a192c38745ad7ba9fac5cbde8bdb3d28b7b Mon Sep 17 00:00:00 2001 From: szymonrybczak Date: Mon, 14 Aug 2023 14:42:50 +0200 Subject: [PATCH] feat(doctor): adjust healthchecks based on where command was ran --- .../src/tools/healthchecks/index.ts | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/packages/cli-doctor/src/tools/healthchecks/index.ts b/packages/cli-doctor/src/tools/healthchecks/index.ts index d3566e7a82..fef4084dbb 100644 --- a/packages/cli-doctor/src/tools/healthchecks/index.ts +++ b/packages/cli-doctor/src/tools/healthchecks/index.ts @@ -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', @@ -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] : []), ], }, @@ -52,7 +73,6 @@ export const getHealthchecks = ({contributor}: Options): Healthchecks => { adb, jdk, androidStudio, - androidSDK, androidHomeEnvVariable, ...(contributor ? [androidNDK] : []), ], @@ -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); };