Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"react-native": "^0.60.0"
},
"devDependencies": {
"@types/command-exists": "^1.2.0",
"@types/graceful-fs": "^4.1.3",
"@types/semver": "^6.0.2",
"slash": "^3.0.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @flow
import semver from 'semver';
import commandExists from 'command-exists';

Expand All @@ -21,11 +20,16 @@ const doesSoftwareNeedToBeFixed = ({
version,
versionRange,
}: {
version: string,
versionRange: string,
}) =>
(version === 'Not Found' ||
!semver.satisfies(semver.coerce(version), versionRange)) &&
`version ${versionRange} is required`;
version: string;
versionRange: string;
}) => {
const coercedVersion = semver.coerce(version);
return (
(version === 'Not Found' ||
coercedVersion === null ||
!semver.satisfies(coercedVersion, versionRange)) &&
`version ${versionRange} is required`
);
};

export {PACKAGE_MANAGERS, checkSoftwareInstalled, doesSoftwareNeedToBeFixed};
1 change: 1 addition & 0 deletions packages/cli/src/commands/doctor/doctor.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {logger} from '@react-native-community/cli-tools';
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';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// @flow
import chalk from 'chalk';
import Ora from 'ora';
// $FlowFixMe - converted to TS
import {logManualInstallation} from './common';
import type {HealthCheckInterface} from '../types';

Expand Down
3 changes: 3 additions & 0 deletions packages/cli/src/commands/doctor/healthchecks/androidNDK.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
// @flow
import chalk from 'chalk';
import Ora from 'ora';
// $FlowFixMe - converted to TS
import {logManualInstallation} from './common';
// $FlowFixMe - converted to TS
import versionRanges from '../versionRanges';
// $FlowFixMe - converted to TS
import {doesSoftwareNeedToBeFixed} from '../checkInstallation';
import type {EnvironmentInfo, HealthCheckInterface} from '../types';

Expand Down
3 changes: 3 additions & 0 deletions packages/cli/src/commands/doctor/healthchecks/androidSDK.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
// @flow
import chalk from 'chalk';
import Ora from 'ora';
// $FlowFixMe - converted to TS
import {logManualInstallation} from './common';
// $FlowFixMe - converted to TS
import versionRanges from '../versionRanges';
// $FlowFixMe - converted to TS
import {doesSoftwareNeedToBeFixed} from '../checkInstallation';
import execa from 'execa';
import type {EnvironmentInfo, HealthCheckInterface} from '../types';
Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/commands/doctor/healthchecks/cocoaPods.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// @flow
// $FlowFixMe - converted to TS
import {checkSoftwareInstalled} from '../checkInstallation';
// $FlowFixMe - converted to TS
import {installCocoaPods} from '../../../tools/installPods';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
// @flow
import {logger} from '@react-native-community/cli-tools';
import chalk from 'chalk';

// Space is necessary to keep correct ordering on screen
const logMessage = message => logger.log(` ${message}`);
const logMessage = (message: string) => logger.log(` ${message}`);

const logManualInstallation = ({
healthcheck = '',
url,
command,
message,
}: {
healthcheck?: string,
url?: string,
command?: string,
message?: string,
healthcheck?: string;
url?: string;
command?: string;
message?: string;
}) => {
if (message) {
return logMessage(message);
Expand Down
2 changes: 2 additions & 0 deletions packages/cli/src/commands/doctor/healthchecks/iosDeploy.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// @flow
import execa from 'execa';
import Ora from 'ora';
// $FlowFixMe - converted to TS
import {checkSoftwareInstalled, PACKAGE_MANAGERS} from '../checkInstallation';
import {packageManager} from './packageManagers';
// $FlowFixMe - converted to TS
import {logManualInstallation} from './common';
import type {HealthCheckInterface} from '../types';

Expand Down
3 changes: 3 additions & 0 deletions packages/cli/src/commands/doctor/healthchecks/nodeJS.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
// @flow
import Ora from 'ora';
// $FlowFixMe - converted to TS
import versionRanges from '../versionRanges';
// $FlowFixMe - converted to TS
import {doesSoftwareNeedToBeFixed} from '../checkInstallation';
// $FlowFixMe - converted to TS
import {logManualInstallation} from './common';
import type {EnvironmentInfo, HealthCheckInterface} from '../types';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// @flow
import fs from 'fs';
import Ora from 'ora';
// $FlowFixMe - converted to TS
import versionRanges from '../versionRanges';
import {
PACKAGE_MANAGERS,
doesSoftwareNeedToBeFixed,
// $FlowFixMe - converted to TS
} from '../checkInstallation';
// $FlowFixMe - converted to TS
import {install} from '../../../tools/install';
Expand Down
2 changes: 2 additions & 0 deletions packages/cli/src/commands/doctor/healthchecks/watchman.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// @flow
import Ora from 'ora';
// $FlowFixMe - converted to TS
import versionRanges from '../versionRanges';
// $FlowFixMe - converted to TS
import {doesSoftwareNeedToBeFixed} from '../checkInstallation';
// $FlowFixMe - converted to TS
import {install} from '../../../tools/install';
Expand Down
3 changes: 3 additions & 0 deletions packages/cli/src/commands/doctor/healthchecks/xcode.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
// @flow
import Ora from 'ora';
// $FlowFixMe - converted to TS
import versionRanges from '../versionRanges';
// $FlowFixMe - converted to TS
import {doesSoftwareNeedToBeFixed} from '../checkInstallation';
// $FlowFixMe - converted to TS
import {logManualInstallation} from './common';
import type {EnvironmentInfo, HealthCheckInterface} from '../types';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @flow
import chalk from 'chalk';
import {logger} from '@react-native-community/cli-tools';

Expand All @@ -9,7 +8,7 @@ const KEYS = {
EXIT: '\r',
};

const printOption = option => logger.log(` \u203A ${option}`);
const printOption = (option: string) => logger.log(` \u203A ${option}`);
const printOptions = () => {
logger.log();
logger.log(chalk.bold('Usage'));
Expand All @@ -30,11 +29,12 @@ const printOptions = () => {
};

export {KEYS};
export default ({onKeyPress}: {onKeyPress: any}) => {
export default ({onKeyPress}: {onKeyPress: (...args: any[]) => void}) => {
printOptions();

// $FlowFixMe
process.stdin.setRawMode(true);
if (process.stdin.setRawMode) {
process.stdin.setRawMode(true);
}
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', onKeyPress);
Expand Down
78 changes: 78 additions & 0 deletions packages/cli/src/commands/doctor/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
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> | void;
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @flow
export default {
// Common
NODE_JS: '>= 8.3',
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2027,6 +2027,11 @@
dependencies:
"@babel/types" "^7.3.0"

"@types/command-exists@^1.2.0":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@types/command-exists/-/command-exists-1.2.0.tgz#d97e0ed10097090e4ab0367ed425b0312fad86f3"
integrity sha512-ugsxEJfsCuqMLSuCD4PIJkp5Uk2z6TCMRCgYVuhRo5cYQY3+1xXTQkSlPtkpGHuvWMjS2KTeVQXxkXRACMbM6A==

"@types/events@*":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@types/events/-/events-3.0.0.tgz#2862f3f58a9a7f7c3e78d79f130dd4d71c25c2a7"
Expand Down