@@ -15,6 +15,8 @@ import {Healthchecks, HealthCheckCategory} from '../../types';
15
15
import loadConfig from '@react-native-community/cli-config' ;
16
16
import xcodeEnv from './xcodeEnv' ;
17
17
import packager from './packager' ;
18
+ import deepmerge from 'deepmerge' ;
19
+ import { logger } from '@react-native-community/cli-tools' ;
18
20
19
21
export const HEALTHCHECK_TYPES = {
20
22
ERROR : 'ERROR' ,
@@ -28,21 +30,48 @@ type Options = {
28
30
29
31
export const getHealthchecks = ( { contributor} : Options ) : Healthchecks => {
30
32
let additionalChecks : HealthCheckCategory [ ] = [ ] ;
33
+ let projectSpecificHealthchecks = { } ;
34
+ let config ;
31
35
32
36
// Doctor can run in a detached mode, where there isn't a config so this can fail
33
37
try {
34
- let config = loadConfig ( ) ;
38
+ config = loadConfig ( ) ;
35
39
additionalChecks = config . healthChecks ;
40
+
41
+ if ( config . reactNativePath ) {
42
+ projectSpecificHealthchecks = {
43
+ common : {
44
+ label : 'Common' ,
45
+ healthchecks : [ packager ] ,
46
+ } ,
47
+ android : {
48
+ label : 'Android' ,
49
+ healthchecks : [ androidSDK ] ,
50
+ } ,
51
+ ...( process . platform === 'darwin' && {
52
+ ios : {
53
+ label : 'iOS' ,
54
+ healthchecks : [ xcodeEnv ] ,
55
+ } ,
56
+ } ) ,
57
+ } ;
58
+ }
36
59
} catch { }
37
60
38
- return {
61
+ if ( ! config ) {
62
+ logger . log ( ) ;
63
+ logger . info (
64
+ 'Detected that command has been run outside of React Native project, running basic healthchecks.' ,
65
+ ) ;
66
+ }
67
+
68
+ const defaultHealthchecks = {
39
69
common : {
40
70
label : 'Common' ,
41
71
healthchecks : [
42
72
nodeJS ,
43
73
yarn ,
44
74
npm ,
45
- packager ,
46
75
...( process . platform === 'darwin' ? [ watchman ] : [ ] ) ,
47
76
] ,
48
77
} ,
@@ -52,7 +81,6 @@ export const getHealthchecks = ({contributor}: Options): Healthchecks => {
52
81
adb ,
53
82
jdk ,
54
83
androidStudio ,
55
- androidSDK ,
56
84
androidHomeEnvVariable ,
57
85
...( contributor ? [ androidNDK ] : [ ] ) ,
58
86
] ,
@@ -61,10 +89,12 @@ export const getHealthchecks = ({contributor}: Options): Healthchecks => {
61
89
? {
62
90
ios : {
63
91
label : 'iOS' ,
64
- healthchecks : [ xcode , ruby , cocoaPods , iosDeploy , xcodeEnv ] ,
92
+ healthchecks : [ xcode , ruby , cocoaPods , iosDeploy ] ,
65
93
} ,
66
94
}
67
95
: { } ) ,
68
96
...additionalChecks ,
69
97
} ;
98
+
99
+ return deepmerge ( defaultHealthchecks , projectSpecificHealthchecks ) ;
70
100
} ;
0 commit comments