-
Notifications
You must be signed in to change notification settings - Fork 907
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate the rest of doctor command to TypeScript #722
Changes from all commits
7b650f3
89b0bf7
08bde8d
9e06778
d66b1a0
aac74ca
f0848fc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
// @flow | ||
import doctor from './doctor'; | ||
|
||
export default { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,49 @@ | ||
// @flow | ||
import chalk from 'chalk'; | ||
import ora from 'ora'; | ||
import ora, {Ora} from 'ora'; | ||
import {logger} from '@react-native-community/cli-tools'; | ||
// $FlowFixMe - converted to TS | ||
import {HEALTHCHECK_TYPES} from './healthchecks'; | ||
import type {EnvironmentInfo} from './types'; | ||
import {EnvironmentInfo, HealthCheckCategoryResult} from './types'; | ||
|
||
const AUTOMATIC_FIX_LEVELS = { | ||
ALL_ISSUES: 'ALL_ISSUES', | ||
ERRORS: 'ERRORS', | ||
WARNINGS: 'WARNINGS', | ||
}; | ||
export enum AUTOMATIC_FIX_LEVELS { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
ALL_ISSUES = 'ALL_ISSUES', | ||
ERRORS = 'ERRORS', | ||
WARNINGS = 'WARNINGS', | ||
} | ||
|
||
export {AUTOMATIC_FIX_LEVELS}; | ||
export default async ({ | ||
interface RunAutomaticFixArgs { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @thib92: small question, when do you use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's a small difference between the two, but to be fair I usually use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool, thanks for replying! |
||
healthchecks: HealthCheckCategoryResult[]; | ||
automaticFixLevel: AUTOMATIC_FIX_LEVELS; | ||
stats: { | ||
errors: number; | ||
warnings: number; | ||
}; | ||
loader: Ora; | ||
environmentInfo: EnvironmentInfo; | ||
} | ||
|
||
export default async function({ | ||
healthchecks, | ||
automaticFixLevel, | ||
stats, | ||
loader, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I saw here that this function doesn't use its There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if loader is unused, please remove it from the type def as well |
||
environmentInfo, | ||
}: { | ||
healthchecks: any, | ||
automaticFixLevel: $Values<typeof AUTOMATIC_FIX_LEVELS>, | ||
stats: {errors: any, warnings: any}, | ||
loader: typeof ora, | ||
environmentInfo: EnvironmentInfo, | ||
}) => { | ||
}: RunAutomaticFixArgs) { | ||
// Remove the fix options from screen | ||
// $FlowFixMe | ||
process.stdout.moveCursor(0, -6); | ||
// $FlowFixMe | ||
process.stdout.clearScreenDown(); | ||
if (process.stdout.isTTY) { | ||
// @ts-ignore | ||
process.stdout.moveCursor(0, -6); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Those should be part of I can change those later as there's no harm on ignoring this. |
||
// @ts-ignore | ||
process.stdout.clearScreenDown(); | ||
} | ||
|
||
const totalIssuesBasedOnFixLevel = { | ||
const totalIssuesBasedOnFixLevel: {[x in AUTOMATIC_FIX_LEVELS]: number} = { | ||
[AUTOMATIC_FIX_LEVELS.ALL_ISSUES]: stats.errors + stats.warnings, | ||
[AUTOMATIC_FIX_LEVELS.ERRORS]: stats.errors, | ||
[AUTOMATIC_FIX_LEVELS.WARNINGS]: stats.warnings, | ||
}; | ||
const issuesCount = totalIssuesBasedOnFixLevel[automaticFixLevel]; | ||
|
||
logger.log( | ||
`\nAttempting to fix ${chalk.bold(issuesCount)} issue${ | ||
`\nAttempting to fix ${chalk.bold(issuesCount.toString())} issue${ | ||
issuesCount > 1 ? 's' : '' | ||
}...`, | ||
); | ||
|
@@ -64,6 +67,8 @@ export default async ({ | |
healthcheck.type === HEALTHCHECK_TYPES.WARNING | ||
); | ||
} | ||
|
||
return; | ||
}); | ||
|
||
if (!healthchecksToRun.length) { | ||
|
@@ -88,4 +93,4 @@ export default async ({ | |
} | ||
} | ||
} | ||
}; | ||
} |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noobie question: shouldn't we type these instead of just adding it to ignore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep we should. I might give it a try, but there is a pending WIP PR on the repo. Would probably be worth being put on DefinitelyTyped