From 7b650f3cafcc5bc8ef9ec945955b6642bb6614e6 Mon Sep 17 00:00:00 2001 From: thib92 Date: Sat, 14 Sep 2019 16:22:03 +0200 Subject: [PATCH 1/7] Migrate the rest of doctor command to TypeScript Unify type definitions for the command Remove Flow typings --- .../commands/doctor/{doctor.js => doctor.ts} | 77 +++++++++--------- .../src/commands/doctor/healthchecks/index.ts | 3 +- .../commands/doctor/{index.js => index.ts} | 1 - ...{runAutomaticFix.js => runAutomaticFix.ts} | 47 +++++------ packages/cli/src/commands/doctor/types.js | 79 ------------------- packages/cli/src/commands/doctor/types.ts | 35 +++++++- 6 files changed, 98 insertions(+), 144 deletions(-) rename packages/cli/src/commands/doctor/{doctor.js => doctor.ts} (76%) rename packages/cli/src/commands/doctor/{index.js => index.ts} (98%) rename packages/cli/src/commands/doctor/{runAutomaticFix.js => runAutomaticFix.ts} (75%) delete mode 100644 packages/cli/src/commands/doctor/types.js diff --git a/packages/cli/src/commands/doctor/doctor.js b/packages/cli/src/commands/doctor/doctor.ts similarity index 76% rename from packages/cli/src/commands/doctor/doctor.js rename to packages/cli/src/commands/doctor/doctor.ts index dfc11c47b..0dcc56fa2 100644 --- a/packages/cli/src/commands/doctor/doctor.js +++ b/packages/cli/src/commands/doctor/doctor.ts @@ -1,18 +1,19 @@ -// @flow import chalk from 'chalk'; +// @ts-ignore import envinfo from 'envinfo'; import {logger} from '@react-native-community/cli-tools'; -// $FlowFixMe - converted to TS import {getHealthchecks, HEALTHCHECK_TYPES} from './healthchecks'; -// $FlowFixMe - converted to TS import {getLoader} from '../../tools/loader'; -// $FlowFixMe - converted to TS import printFixOptions, {KEYS} from './printFixOptions'; import runAutomaticFix, {AUTOMATIC_FIX_LEVELS} from './runAutomaticFix'; -import type {ConfigT} from 'types'; -import type {HealthCheckInterface} from './types'; - -const printCategory = ({label, key}) => { +import {Config} from '@react-native-community/cli-types'; +import { + HealthcheckCategory, + HealthCheckCategoryResult, + HealthCheckResult, +} from './types'; + +const printCategory = ({label, key}: {label: string; key: number}) => { if (key > 0) { logger.log(); } @@ -25,12 +26,7 @@ const printIssue = ({ needsToBeFixed, isRequired, description, -}: { - label: string, - needsToBeFixed: boolean, - isRequired: boolean, - description: string, -}) => { +}: HealthCheckResult) => { const symbol = needsToBeFixed ? isRequired ? chalk.red('✖') @@ -40,19 +36,25 @@ const printIssue = ({ logger.log(` ${symbol} ${label}${needsToBeFixed ? ': ' + description : ''}`); }; -const printOverallStats = ({errors, warnings}) => { +const printOverallStats = ({ + errors, + warnings, +}: { + errors: number; + warnings: number; +}) => { logger.log(`\n${chalk.bold('Errors:')} ${errors}`); logger.log(`${chalk.bold('Warnings:')} ${warnings}`); }; type FlagsT = { - fix: boolean | void, - contributor: boolean | void, + fix: boolean | void; + contributor: boolean | void; }; export default (async function runDoctor( - argv: Array, - ctx: ConfigT, + argv: string[], + ctx: Config, options: FlagsT, ) { const Loader = getLoader(); @@ -76,10 +78,7 @@ export default (async function runDoctor( const iterateOverHealthChecks = async ({ label, healthchecks, - }: { - label: string, - healthchecks: Array, - }) => ({ + }: HealthcheckCategory): Promise => ({ label, healthchecks: (await Promise.all( healthchecks.map(async healthcheck => { @@ -108,23 +107,24 @@ export default (async function runDoctor( : undefined, }; }), - )).filter(Boolean), + )).filter(healthcheck => healthcheck !== undefined) as HealthCheckResult[], }); // Remove all the categories that don't have any healthcheck with `needsToBeFixed` // so they don't show when the user taps to fix encountered issues - const removeFixedCategories = categories => + const removeFixedCategories = (categories: HealthCheckCategoryResult[]) => categories.filter(category => - category.healthchecks.some(healthcheck => healthcheck.needsToBeFixed), + category.healthchecks.some( + healthcheck => healthcheck && healthcheck.needsToBeFixed, + ), ); - const iterateOverCategories = categories => - // $FlowFixMe - bad Object.values typings + const iterateOverCategories = (categories: HealthcheckCategory[]) => Promise.all(categories.map(iterateOverHealthChecks)); - const healthchecksPerCategory = await iterateOverCategories( - Object.values(getHealthchecks(options)), - ); + const healthchecksPerCategory = await iterateOverCategories(Object.values( + getHealthchecks(options), + ).filter(category => category !== undefined) as HealthcheckCategory[]); loader.stop(); @@ -136,15 +136,17 @@ export default (async function runDoctor( healthchecksPerCategory.forEach((issueCategory, key) => { printCategory({...issueCategory, key}); - issueCategory.healthchecks.map(healthcheck => { + issueCategory.healthchecks.forEach(healthcheck => { printIssue(healthcheck); if (healthcheck.type === HEALTHCHECK_TYPES.WARNING) { - return stats.warnings++; + stats.warnings++; + return; } if (healthcheck.type === HEALTHCHECK_TYPES.ERROR) { - return stats.errors++; + stats.errors++; + return; } }); }); @@ -161,13 +163,14 @@ export default (async function runDoctor( }); } - const onKeyPress = async key => { - // $FlowFixMe + const onKeyPress = async (key: string) => { + // @ts-ignore process.stdin.setRawMode(false); process.stdin.removeAllListeners('data'); if (key === KEYS.EXIT || key === '\u0003') { - return process.exit(0); + process.exit(0); + return; } if ( diff --git a/packages/cli/src/commands/doctor/healthchecks/index.ts b/packages/cli/src/commands/doctor/healthchecks/index.ts index b439dfd2d..1b213097b 100644 --- a/packages/cli/src/commands/doctor/healthchecks/index.ts +++ b/packages/cli/src/commands/doctor/healthchecks/index.ts @@ -7,6 +7,7 @@ import androidNDK from './androidNDK'; import xcode from './xcode'; import cocoaPods from './cocoaPods'; import iosDeploy from './iosDeploy'; +import {Healthchecks} from '../types'; export const HEALTHCHECK_TYPES = { ERROR: 'ERROR', @@ -18,7 +19,7 @@ type Options = { contributor: boolean | void; }; -export const getHealthchecks = ({contributor}: Options) => ({ +export const getHealthchecks = ({contributor}: Options): Healthchecks => ({ common: { label: 'Common', healthchecks: [ diff --git a/packages/cli/src/commands/doctor/index.js b/packages/cli/src/commands/doctor/index.ts similarity index 98% rename from packages/cli/src/commands/doctor/index.js rename to packages/cli/src/commands/doctor/index.ts index b1539f635..41ba25b8a 100644 --- a/packages/cli/src/commands/doctor/index.js +++ b/packages/cli/src/commands/doctor/index.ts @@ -1,4 +1,3 @@ -// @flow import doctor from './doctor'; export default { diff --git a/packages/cli/src/commands/doctor/runAutomaticFix.js b/packages/cli/src/commands/doctor/runAutomaticFix.ts similarity index 75% rename from packages/cli/src/commands/doctor/runAutomaticFix.js rename to packages/cli/src/commands/doctor/runAutomaticFix.ts index fbf14ad59..5b491dd87 100644 --- a/packages/cli/src/commands/doctor/runAutomaticFix.js +++ b/packages/cli/src/commands/doctor/runAutomaticFix.ts @@ -1,38 +1,41 @@ -// @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', -}; +enum AUTOMATIC_FIX_LEVELS { + ALL_ISSUES = 'ALL_ISSUES', + ERRORS = 'ERRORS', + WARNINGS = 'WARNINGS', +} export {AUTOMATIC_FIX_LEVELS}; -export default async ({ + +interface RunAutomaticFixArgs { + healthchecks: HealthCheckCategoryResult[]; + automaticFixLevel: AUTOMATIC_FIX_LEVELS; + stats: { + errors: number; + warnings: number; + }; + loader: Ora; + environmentInfo: EnvironmentInfo; +} + +export default async function({ healthchecks, automaticFixLevel, stats, - loader, environmentInfo, -}: { - healthchecks: any, - automaticFixLevel: $Values, - stats: {errors: any, warnings: any}, - loader: typeof ora, - environmentInfo: EnvironmentInfo, -}) => { +}: RunAutomaticFixArgs) { // Remove the fix options from screen - // $FlowFixMe + // @ts-ignore process.stdout.moveCursor(0, -6); - // $FlowFixMe + // @ts-ignore process.stdout.clearScreenDown(); - const totalIssuesBasedOnFixLevel = { + const totalIssuesBasedOnFixLevel: {[x in AUTOMATIC_FIX_LEVELS]: any} = { [AUTOMATIC_FIX_LEVELS.ALL_ISSUES]: stats.errors + stats.warnings, [AUTOMATIC_FIX_LEVELS.ERRORS]: stats.errors, [AUTOMATIC_FIX_LEVELS.WARNINGS]: stats.warnings, @@ -88,4 +91,4 @@ export default async ({ } } } -}; +} diff --git a/packages/cli/src/commands/doctor/types.js b/packages/cli/src/commands/doctor/types.js deleted file mode 100644 index 3793e8d9b..000000000 --- a/packages/cli/src/commands/doctor/types.js +++ /dev/null @@ -1,79 +0,0 @@ -// @flow -import Ora from 'ora'; - -export type EnvironmentInfo = { - System: { - OS: string, - CPU: string, - Memory: string, - Shell: { - version: string, - path: string, - }, - }, - Binaries: { - Node: { - version: string, - path: string, - }, - Yarn: { - version: string, - path: string, - }, - npm: { - version: string, - path: string, - }, - Watchman: { - version: string, - path: string, - }, - }, - SDKs: { - 'iOS SDK': { - Platforms: string[], - }, - 'Android SDK': { - 'API Levels': string[], - 'Build Tools': string[], - 'System Images': string[], - 'Android NDK': string, - }, - }, - IDEs: { - 'Android Studio': string, - Emacs: { - version: string, - path: string, - }, - Nano: { - version: string, - path: string, - }, - VSCode: { - version: string, - path: string, - }, - Vim: { - version: string, - path: string, - }, - Xcode: { - version: string, - path: string, - }, - }, -}; - -export type HealthCheckInterface = { - label: string, - visible?: boolean | void, - isRequired?: boolean, - getDiagnostics: ( - environmentInfo: EnvironmentInfo, - ) => Promise<{version?: string, needsToBeFixed: boolean | string}>, - runAutomaticFix: (args: { - loader: typeof Ora, - environmentInfo: EnvironmentInfo, - }) => Promise | void, -}; diff --git a/packages/cli/src/commands/doctor/types.ts b/packages/cli/src/commands/doctor/types.ts index 07ed78a84..8f88e65e7 100644 --- a/packages/cli/src/commands/doctor/types.ts +++ b/packages/cli/src/commands/doctor/types.ts @@ -66,6 +66,22 @@ export type EnvironmentInfo = { }; }; +export type HealthcheckCategory = { + label: string; + healthchecks: HealthCheckInterface[]; +}; + +export type Healthchecks = { + common: HealthcheckCategory; + android: HealthcheckCategory; + ios?: HealthcheckCategory; +}; + +export type RunAutomaticFix = (args: { + loader: Ora; + environmentInfo: EnvironmentInfo; +}) => Promise | void; + export type HealthCheckInterface = { label: string; visible?: boolean | void; @@ -73,8 +89,19 @@ export type HealthCheckInterface = { getDiagnostics: ( environmentInfo: EnvironmentInfo, ) => Promise<{version?: string; needsToBeFixed: boolean | string}>; - runAutomaticFix: (args: { - loader: Ora; - environmentInfo: EnvironmentInfo; - }) => Promise | void; + runAutomaticFix: RunAutomaticFix; +}; + +export type HealthCheckResult = { + label: string; + needsToBeFixed: boolean; + description: string; + runAutomaticFix: RunAutomaticFix; + isRequired: boolean; + type?: string; +}; + +export type HealthCheckCategoryResult = { + label: string; + healthchecks: HealthCheckResult[]; }; From 89b0bf7b64b73db4f8f09ba27bacaa5c0a46c7dd Mon Sep 17 00:00:00 2001 From: thib92 Date: Sat, 14 Sep 2019 16:26:45 +0200 Subject: [PATCH 2/7] Remove useless falsy condition --- packages/cli/src/commands/doctor/doctor.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/cli/src/commands/doctor/doctor.ts b/packages/cli/src/commands/doctor/doctor.ts index 0dcc56fa2..332a71742 100644 --- a/packages/cli/src/commands/doctor/doctor.ts +++ b/packages/cli/src/commands/doctor/doctor.ts @@ -114,9 +114,7 @@ export default (async function runDoctor( // so they don't show when the user taps to fix encountered issues const removeFixedCategories = (categories: HealthCheckCategoryResult[]) => categories.filter(category => - category.healthchecks.some( - healthcheck => healthcheck && healthcheck.needsToBeFixed, - ), + category.healthchecks.some(healthcheck => healthcheck.needsToBeFixed), ); const iterateOverCategories = (categories: HealthcheckCategory[]) => From 08bde8d03126711e8bb8bc732ad9b5cfbb862d23 Mon Sep 17 00:00:00 2001 From: thib92 Date: Sat, 14 Sep 2019 16:29:10 +0200 Subject: [PATCH 3/7] Change `any` type to `number` --- packages/cli/src/commands/doctor/runAutomaticFix.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/commands/doctor/runAutomaticFix.ts b/packages/cli/src/commands/doctor/runAutomaticFix.ts index 5b491dd87..c5b30b414 100644 --- a/packages/cli/src/commands/doctor/runAutomaticFix.ts +++ b/packages/cli/src/commands/doctor/runAutomaticFix.ts @@ -35,7 +35,7 @@ export default async function({ // @ts-ignore process.stdout.clearScreenDown(); - const totalIssuesBasedOnFixLevel: {[x in AUTOMATIC_FIX_LEVELS]: any} = { + 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, @@ -43,7 +43,7 @@ export default async function({ const issuesCount = totalIssuesBasedOnFixLevel[automaticFixLevel]; logger.log( - `\nAttempting to fix ${chalk.bold(issuesCount)} issue${ + `\nAttempting to fix ${chalk.bold(issuesCount.toString())} issue${ issuesCount > 1 ? 's' : '' }...`, ); From 9e0677870acbd770066b6589d01f4298d676ca2e Mon Sep 17 00:00:00 2001 From: thib92 Date: Sat, 14 Sep 2019 16:40:16 +0200 Subject: [PATCH 4/7] Use CommandFunction type Remove useless arguments --- packages/cli-types/src/index.ts | 12 +++++++----- packages/cli/src/commands/doctor/doctor.ts | 10 +++------- packages/cli/src/commands/doctor/runAutomaticFix.ts | 2 ++ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/cli-types/src/index.ts b/packages/cli-types/src/index.ts index 15eca2521..3c7729f33 100644 --- a/packages/cli-types/src/index.ts +++ b/packages/cli-types/src/index.ts @@ -13,14 +13,16 @@ import { export type InquirerPrompt = any; +export type CommandFunction = ( + argv: Array, + ctx: Config, + args: Object, +) => Promise | void; + export interface Command { name: string; description?: string; - func: ( - argv: Array, - ctx: Config, - args: Object, - ) => Promise | void; + func: CommandFunction; options?: Array<{ name: string; description?: string; diff --git a/packages/cli/src/commands/doctor/doctor.ts b/packages/cli/src/commands/doctor/doctor.ts index 332a71742..b5614c8a5 100644 --- a/packages/cli/src/commands/doctor/doctor.ts +++ b/packages/cli/src/commands/doctor/doctor.ts @@ -6,7 +6,7 @@ import {getHealthchecks, HEALTHCHECK_TYPES} from './healthchecks'; import {getLoader} from '../../tools/loader'; import printFixOptions, {KEYS} from './printFixOptions'; import runAutomaticFix, {AUTOMATIC_FIX_LEVELS} from './runAutomaticFix'; -import {Config} from '@react-native-community/cli-types'; +import {CommandFunction} from '@react-native-community/cli-types'; import { HealthcheckCategory, HealthCheckCategoryResult, @@ -52,11 +52,7 @@ type FlagsT = { contributor: boolean | void; }; -export default (async function runDoctor( - argv: string[], - ctx: Config, - options: FlagsT, -) { +export default (async (_, __, options: FlagsT) => { const Loader = getLoader(); const loader = new Loader(); @@ -198,4 +194,4 @@ export default (async function runDoctor( }; printFixOptions({onKeyPress}); -}); +}) as CommandFunction; diff --git a/packages/cli/src/commands/doctor/runAutomaticFix.ts b/packages/cli/src/commands/doctor/runAutomaticFix.ts index c5b30b414..cad858056 100644 --- a/packages/cli/src/commands/doctor/runAutomaticFix.ts +++ b/packages/cli/src/commands/doctor/runAutomaticFix.ts @@ -67,6 +67,8 @@ export default async function({ healthcheck.type === HEALTHCHECK_TYPES.WARNING ); } + + return; }); if (!healthchecksToRun.length) { From d66b1a04f8ef8c7a442fd54e43b6e824cf4056ad Mon Sep 17 00:00:00 2001 From: thib92 Date: Sat, 14 Sep 2019 16:42:12 +0200 Subject: [PATCH 5/7] Export enum syntax --- packages/cli/src/commands/doctor/runAutomaticFix.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/cli/src/commands/doctor/runAutomaticFix.ts b/packages/cli/src/commands/doctor/runAutomaticFix.ts index cad858056..91d31f879 100644 --- a/packages/cli/src/commands/doctor/runAutomaticFix.ts +++ b/packages/cli/src/commands/doctor/runAutomaticFix.ts @@ -4,14 +4,12 @@ import {logger} from '@react-native-community/cli-tools'; import {HEALTHCHECK_TYPES} from './healthchecks'; import {EnvironmentInfo, HealthCheckCategoryResult} from './types'; -enum AUTOMATIC_FIX_LEVELS { +export enum AUTOMATIC_FIX_LEVELS { ALL_ISSUES = 'ALL_ISSUES', ERRORS = 'ERRORS', WARNINGS = 'WARNINGS', } -export {AUTOMATIC_FIX_LEVELS}; - interface RunAutomaticFixArgs { healthchecks: HealthCheckCategoryResult[]; automaticFixLevel: AUTOMATIC_FIX_LEVELS; From aac74ca38a2ceed8751e41dea6c5a14bd3320fee Mon Sep 17 00:00:00 2001 From: Thibault HENRY Date: Mon, 16 Sep 2019 11:10:17 +0200 Subject: [PATCH 6/7] Update packages/cli/src/commands/doctor/doctor.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Michał Pierzchała --- packages/cli/src/commands/doctor/doctor.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/src/commands/doctor/doctor.ts b/packages/cli/src/commands/doctor/doctor.ts index b5614c8a5..3bf634ec4 100644 --- a/packages/cli/src/commands/doctor/doctor.ts +++ b/packages/cli/src/commands/doctor/doctor.ts @@ -8,7 +8,7 @@ import printFixOptions, {KEYS} from './printFixOptions'; import runAutomaticFix, {AUTOMATIC_FIX_LEVELS} from './runAutomaticFix'; import {CommandFunction} from '@react-native-community/cli-types'; import { - HealthcheckCategory, + HealthCheckCategory, HealthCheckCategoryResult, HealthCheckResult, } from './types'; From f0848fcbdec9eeb0024341ee8298dae5d66e5088 Mon Sep 17 00:00:00 2001 From: thib92 Date: Mon, 16 Sep 2019 11:14:13 +0200 Subject: [PATCH 7/7] PR comments @thymikee --- packages/cli-types/src/index.ts | 8 ++++---- packages/cli/src/commands/doctor/doctor.ts | 15 ++++++++------- .../cli/src/commands/doctor/runAutomaticFix.ts | 10 ++++++---- packages/cli/src/commands/doctor/types.ts | 8 ++++---- 4 files changed, 22 insertions(+), 19 deletions(-) diff --git a/packages/cli-types/src/index.ts b/packages/cli-types/src/index.ts index 3c7729f33..1839f151d 100644 --- a/packages/cli-types/src/index.ts +++ b/packages/cli-types/src/index.ts @@ -13,16 +13,16 @@ import { export type InquirerPrompt = any; -export type CommandFunction = ( +export type CommandFunction = ( argv: Array, ctx: Config, - args: Object, + args: Args, ) => Promise | void; -export interface Command { +export interface Command { name: string; description?: string; - func: CommandFunction; + func: CommandFunction; options?: Array<{ name: string; description?: string; diff --git a/packages/cli/src/commands/doctor/doctor.ts b/packages/cli/src/commands/doctor/doctor.ts index 3bf634ec4..ec28c6bbf 100644 --- a/packages/cli/src/commands/doctor/doctor.ts +++ b/packages/cli/src/commands/doctor/doctor.ts @@ -52,7 +52,7 @@ type FlagsT = { contributor: boolean | void; }; -export default (async (_, __, options: FlagsT) => { +export default (async (_, __, options) => { const Loader = getLoader(); const loader = new Loader(); @@ -74,7 +74,7 @@ export default (async (_, __, options: FlagsT) => { const iterateOverHealthChecks = async ({ label, healthchecks, - }: HealthcheckCategory): Promise => ({ + }: HealthCheckCategory): Promise => ({ label, healthchecks: (await Promise.all( healthchecks.map(async healthcheck => { @@ -113,12 +113,12 @@ export default (async (_, __, options: FlagsT) => { category.healthchecks.some(healthcheck => healthcheck.needsToBeFixed), ); - const iterateOverCategories = (categories: HealthcheckCategory[]) => + const iterateOverCategories = (categories: HealthCheckCategory[]) => Promise.all(categories.map(iterateOverHealthChecks)); const healthchecksPerCategory = await iterateOverCategories(Object.values( getHealthchecks(options), - ).filter(category => category !== undefined) as HealthcheckCategory[]); + ).filter(category => category !== undefined) as HealthCheckCategory[]); loader.stop(); @@ -158,8 +158,9 @@ export default (async (_, __, options: FlagsT) => { } const onKeyPress = async (key: string) => { - // @ts-ignore - process.stdin.setRawMode(false); + if (typeof process.stdin.setRawMode === 'function') { + process.stdin.setRawMode(false); + } process.stdin.removeAllListeners('data'); if (key === KEYS.EXIT || key === '\u0003') { @@ -194,4 +195,4 @@ export default (async (_, __, options: FlagsT) => { }; printFixOptions({onKeyPress}); -}) as CommandFunction; +}) as CommandFunction; diff --git a/packages/cli/src/commands/doctor/runAutomaticFix.ts b/packages/cli/src/commands/doctor/runAutomaticFix.ts index 91d31f879..f58a25000 100644 --- a/packages/cli/src/commands/doctor/runAutomaticFix.ts +++ b/packages/cli/src/commands/doctor/runAutomaticFix.ts @@ -28,10 +28,12 @@ export default async function({ environmentInfo, }: RunAutomaticFixArgs) { // Remove the fix options from screen - // @ts-ignore - process.stdout.moveCursor(0, -6); - // @ts-ignore - process.stdout.clearScreenDown(); + if (process.stdout.isTTY) { + // @ts-ignore + process.stdout.moveCursor(0, -6); + // @ts-ignore + process.stdout.clearScreenDown(); + } const totalIssuesBasedOnFixLevel: {[x in AUTOMATIC_FIX_LEVELS]: number} = { [AUTOMATIC_FIX_LEVELS.ALL_ISSUES]: stats.errors + stats.warnings, diff --git a/packages/cli/src/commands/doctor/types.ts b/packages/cli/src/commands/doctor/types.ts index 8f88e65e7..b710eaa17 100644 --- a/packages/cli/src/commands/doctor/types.ts +++ b/packages/cli/src/commands/doctor/types.ts @@ -66,15 +66,15 @@ export type EnvironmentInfo = { }; }; -export type HealthcheckCategory = { +export type HealthCheckCategory = { label: string; healthchecks: HealthCheckInterface[]; }; export type Healthchecks = { - common: HealthcheckCategory; - android: HealthcheckCategory; - ios?: HealthcheckCategory; + common: HealthCheckCategory; + android: HealthCheckCategory; + ios?: HealthCheckCategory; }; export type RunAutomaticFix = (args: {