Skip to content

Commit 25f8d52

Browse files
committed
feat(doctor): select healthchecks based on where command was ran
1 parent 7165558 commit 25f8d52

3 files changed

Lines changed: 32 additions & 4 deletions

File tree

packages/cli-doctor/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"@react-native-community/cli-tools": "12.0.0-alpha.7",
1616
"chalk": "^4.1.2",
1717
"command-exists": "^1.2.8",
18+
"deepmerge": "^4.3.1",
1819
"envinfo": "^7.7.2",
1920
"execa": "^5.0.0",
2021
"hermes-profile-transformer": "^0.0.6",

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

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {Healthchecks, HealthCheckCategory} from '../../types';
1515
import loadConfig from '@react-native-community/cli-config';
1616
import xcodeEnv from './xcodeEnv';
1717
import packager from './packager';
18+
import deepmerge from 'deepmerge';
1819

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

33+
let projectSpecificHealthchecks = {};
34+
3235
// Doctor can run in a detached mode, where there isn't a config so this can fail
3336
try {
3437
let config = loadConfig();
3538
additionalChecks = config.healthChecks;
39+
40+
if (config) {
41+
projectSpecificHealthchecks = {
42+
common: {
43+
label: 'Common',
44+
healthchecks: [packager],
45+
},
46+
android: {
47+
label: 'Android',
48+
healthchecks: [androidSDK],
49+
},
50+
...(process.platform === 'darwin' && {
51+
ios: {
52+
label: 'iOS',
53+
healthchecks: [xcodeEnv],
54+
},
55+
}),
56+
};
57+
}
3658
} catch {}
3759

38-
return {
60+
const defaultHealthchecks = {
3961
common: {
4062
label: 'Common',
4163
healthchecks: [
4264
nodeJS,
4365
yarn,
4466
npm,
45-
packager,
4667
...(process.platform === 'darwin' ? [watchman] : []),
4768
],
4869
},
@@ -52,7 +73,6 @@ export const getHealthchecks = ({contributor}: Options): Healthchecks => {
5273
adb,
5374
jdk,
5475
androidStudio,
55-
androidSDK,
5676
androidHomeEnvVariable,
5777
...(contributor ? [androidNDK] : []),
5878
],
@@ -61,10 +81,12 @@ export const getHealthchecks = ({contributor}: Options): Healthchecks => {
6181
? {
6282
ios: {
6383
label: 'iOS',
64-
healthchecks: [xcode, ruby, cocoaPods, iosDeploy, xcodeEnv],
84+
healthchecks: [xcode, ruby, cocoaPods, iosDeploy],
6585
},
6686
}
6787
: {}),
6888
...additionalChecks,
6989
};
90+
91+
return deepmerge(defaultHealthchecks, projectSpecificHealthchecks);
7092
};

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5379,6 +5379,11 @@ deepmerge@^4.3.0:
53795379
resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-4.3.0.tgz#65491893ec47756d44719ae520e0e2609233b59b"
53805380
integrity sha512-z2wJZXrmeHdvYJp/Ux55wIjqo81G5Bp4c+oELTW+7ar6SogWHajt5a9gO3s3IDaGSAXjDk0vlQKN3rms8ab3og==
53815381

5382+
deepmerge@^4.3.1:
5383+
version "4.3.1"
5384+
resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-4.3.1.tgz#44b5f2147cd3b00d4b56137685966f26fd25dd4a"
5385+
integrity sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==
5386+
53825387
defaults@^1.0.3:
53835388
version "1.0.3"
53845389
resolved "https://registry.yarnpkg.com/defaults/-/defaults-1.0.3.tgz#c656051e9817d9ff08ed881477f3fe4019f3ef7d"

0 commit comments

Comments
 (0)