1+ // @flow
12import chalk from 'chalk' ;
23import envinfo from 'envinfo' ;
34import { logger } from '@react-native-community/cli-tools' ;
45import { getHealthchecks , HEALTHCHECK_TYPES } from './healthchecks' ;
56import { getLoader } from '../../tools/loader' ;
67import printFixOptions , { KEYS } from './printFixOptions' ;
78import runAutomaticFix , { AUTOMATIC_FIX_LEVELS } from './runAutomaticFix' ;
9+ import type { ConfigT } from 'types' ;
10+ import type { HealthCheckInterface } from './types' ;
811
912const printCategory = ( { label, key} ) => {
1013 if ( key > 0 ) {
@@ -14,7 +17,15 @@ const printCategory = ({label, key}) => {
1417 logger . log ( chalk . dim ( label ) ) ;
1518} ;
1619
17- const printIssue = ( { label, needsToBeFixed, isRequired} ) => {
20+ const printIssue = ( {
21+ label,
22+ needsToBeFixed,
23+ isRequired,
24+ } : {
25+ label : string ,
26+ needsToBeFixed : boolean ,
27+ isRequired : boolean ,
28+ } ) => {
1829 const symbol = needsToBeFixed
1930 ? isRequired
2031 ? chalk . red ( '✖' )
@@ -29,7 +40,16 @@ const printOverallStats = ({errors, warnings}) => {
2940 logger . log ( `${ chalk . bold ( 'Warnings:' ) } ${ warnings } ` ) ;
3041} ;
3142
32- export default ( async function runDoctor ( argv , ctx , options ) {
43+ type FlagsT = {
44+ fix : boolean | void ,
45+ contributor : boolean | void ,
46+ } ;
47+
48+ export default ( async function runDoctor (
49+ argv : Array < string > ,
50+ ctx : ConfigT ,
51+ options : FlagsT ,
52+ ) {
3353 const Loader = getLoader ( ) ;
3454 const loader = new Loader ( ) ;
3555
@@ -48,25 +68,31 @@ export default (async function runDoctor(argv, ctx, options) {
4868 ) ,
4969 ) ;
5070
51- const iterateOverHealthChecks = async ( { label, healthchecks} ) => ( {
71+ const iterateOverHealthChecks = async ( {
72+ label,
73+ healthchecks,
74+ } : {
75+ label : string ,
76+ healthchecks : Array < HealthCheckInterface > ,
77+ } ) => ( {
5278 label,
5379 healthchecks : ( await Promise . all (
5480 healthchecks . map ( async healthcheck => {
5581 if ( healthcheck . visible === false ) {
5682 return ;
5783 }
5884
59- const { needsToBeFixed} = healthcheck . getDiagnostics
60- ? healthcheck . getDiagnostics ( environmentInfo )
61- : await healthcheck . getDiagnosticsAsync ( environmentInfo ) ;
85+ const { needsToBeFixed} = await healthcheck . getDiagnostics (
86+ environmentInfo ,
87+ ) ;
6288
6389 // Assume that it's required unless specified otherwise
6490 const isRequired = healthcheck . isRequired !== false ;
6591 const isWarning = needsToBeFixed && ! isRequired ;
6692
6793 return {
6894 label : healthcheck . label ,
69- needsToBeFixed,
95+ needsToBeFixed : Boolean ( needsToBeFixed ) ,
7096 runAutomaticFix : healthcheck . runAutomaticFix ,
7197 isRequired,
7298 type : needsToBeFixed
@@ -87,6 +113,7 @@ export default (async function runDoctor(argv, ctx, options) {
87113 ) ;
88114
89115 const iterateOverCategories = categories =>
116+ // $FlowFixMe - bad Object.values typings
90117 Promise . all ( categories . map ( iterateOverHealthChecks ) ) ;
91118
92119 const healthchecksPerCategory = await iterateOverCategories (
@@ -129,6 +156,7 @@ export default (async function runDoctor(argv, ctx, options) {
129156 }
130157
131158 const onKeyPress = async key => {
159+ // $FlowFixMe
132160 process . stdin . setRawMode ( false ) ;
133161 process . stdin . removeAllListeners ( 'data' ) ;
134162
0 commit comments