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
8 changes: 3 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
},
"dependencies": {
"@babel/core": "^7.0.0",
"@babel/plugin-proposal-class-properties": "^7.5.5",
"@babel/plugin-transform-modules-commonjs": "^7.2.0",
"@babel/plugin-transform-runtime": "^7.6.2",
"@babel/plugin-transform-strict-mode": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/preset-typescript": "^7.3.3",
Expand All @@ -34,6 +36,7 @@
"babel-jest": "^24.6.0",
"babel-plugin-module-resolver": "^3.2.0",
"chalk": "^2.4.2",
"chokidar": "^3.3.1",
"eslint": "^5.10.0",
"eslint-import-resolver-alias": "^1.1.2",
"eslint-import-resolver-typescript": "^1.1.1",
Expand All @@ -47,10 +50,5 @@
"mkdirp": "^0.5.1",
"string-length": "^2.0.0",
"typescript": "^3.8.0"
},
"devDependencies": {
"@babel/plugin-proposal-class-properties": "^7.5.5",
"@babel/plugin-transform-runtime": "^7.6.2",
"chokidar": "^3.3.1"
}
}
10 changes: 9 additions & 1 deletion packages/cli/src/commands/doctor/doctor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,15 @@ const printCategory = ({label, key}: {label: string; key: number}) => {
logger.log(chalk.dim(label));
};

const printVersions = ({version, versions, versionRange}) => {
const printVersions = ({
version,
versions,
versionRange,
}: {
version?: 'Not Found' | string;
versions?: [string] | string;
versionRange: string;
}) => {
if (versions) {
const versionsToShow = Array.isArray(versions)
? versions.join(', ')
Expand Down
33 changes: 17 additions & 16 deletions packages/cli/src/commands/doctor/healthchecks/androidSDK.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@ const getBuildToolsVersion = (): string => {
buildToolsVersionEntry,
);

const buildToolsVersion = gradleBuildFile
// Get only the portion of the declaration of `buildToolsVersion`
.substring(buildToolsVersionIndex)
.split('\n')[0]
// Get only the the value of `buildToolsVersion`
.match(/\d|\../g)
.join('');
const buildToolsVersion = (
gradleBuildFile
// Get only the portion of the declaration of `buildToolsVersion`
.substring(buildToolsVersionIndex)
.split('\n')[0]
// Get only the the value of `buildToolsVersion`
.match(/\d|\../g) || []
).join('');

return buildToolsVersion;
return buildToolsVersion || 'Not Found';
};

const installMessage = `Read more about how to update Android SDK at ${chalk.dim(
Expand All @@ -39,27 +40,27 @@ export default {
description: 'Required for building and installing your app on Android',
getDiagnostics: async ({SDKs}) => {
const requiredVersion = getBuildToolsVersion();
const buildTools =
typeof SDKs['Android SDK'] === 'string'
? SDKs['Android SDK']
: SDKs['Android SDK']['Build Tools'];

if (!requiredVersion) {
return {
versions: SDKs['Android SDK']['Build Tools'],
versions: buildTools,
versionRange: undefined,
needsToBeFixed: true,
};
}

const isAndroidSDKInstalled = Array.isArray(
SDKs['Android SDK']['Build Tools'],
);
const isAndroidSDKInstalled = Array.isArray(buildTools);

const isRequiredVersionInstalled = isAndroidSDKInstalled
? SDKs['Android SDK']['Build Tools'].includes(requiredVersion)
? buildTools.includes(requiredVersion)
: false;

return {
versions: isAndroidSDKInstalled
? SDKs['Android SDK']['Build Tools']
: SDKs['Android SDK'],
versions: isAndroidSDKInstalled ? buildTools : SDKs['Android SDK'],
versionRange: requiredVersion,
needsToBeFixed: !isRequiredVersionInstalled,
};
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/doctor/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export type Healthchecks = {

export type RunAutomaticFix = (args: {
loader: Ora;
environmentInfo?: EnvironmentInfo;
environmentInfo: EnvironmentInfo;
}) => Promise<void> | void;

export type HealthCheckInterface = {
Expand All @@ -88,7 +88,7 @@ export type HealthCheckInterface = {
isRequired?: boolean;
description?: string;
getDiagnostics: (
environmentInfo?: EnvironmentInfo,
environmentInfo: EnvironmentInfo,
) => Promise<{
version?: string;
versions?: [string];
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/server/eventsSocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ function attachToServer(
};

clientWs.onmessage = event => {
const message: Command = parseMessage(event.data.toString());
const message: Command | undefined = parseMessage(event.data.toString());
if (message == null) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ import {logger} from '@react-native-community/cli-tools';
import {exec} from 'child_process';
import launchDebugger from '../launchDebugger';

function launchDefaultDebugger(host: string, port: number, args = '') {
function launchDefaultDebugger(
host: string | undefined,
port: number,
args = '',
) {
const hostname = host || 'localhost';
const debuggerURL = `http://${hostname}:${port}/debugger-ui${args}`;
logger.info('Launching Dev Tools...');
Expand All @@ -22,7 +26,7 @@ function escapePath(pathname: string) {
}

type LaunchDevToolsOptions = {
host: string;
host?: string;
port: number;
watchFolders: Array<string>;
};
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import init from './commands/init/initCompat';
import assertRequiredOptions from './tools/assertRequiredOptions';
import loadConfig from './tools/config';

import pkgJson from '../package.json';
const pkgJson = require('../package.json');
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TS is able to resolve package.json, but with a require. This is the actual fix, rest is errors that accumulated since the bug started happening


commander
.option('--version', 'Print CLI version')
Expand Down Expand Up @@ -85,8 +85,8 @@ function printHelpInformation(
}

function printUnknownCommand(cmdName: string) {
const availableCommands = commander.commands.map(cmd => cmd._name);
const suggestion = availableCommands.find(cmd => {
const availableCommands = commander.commands.map((cmd: any) => cmd._name);
const suggestion = availableCommands.find((cmd: string) => {
return leven(cmd, cmdName) < cmd.length * 0.4;
});
let errorMsg = `Unrecognized command "${chalk.bold(cmdName)}".`;
Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/tools/config/readConfigFromDisk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ function readLegacyDependencyConfigFromDisk(
params: [],
},
commands: [],
// @ts-ignore
platforms: {},
};
}
Expand Down
16 changes: 8 additions & 8 deletions packages/cli/src/tools/generator/promptSync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ function create() {
const echo = opts.echo;
const masked = 'echo' in opts;

/*eslint-disable prettier/prettier*/
const fd =
process.platform === 'win32'
// @ts-ignore
? process.stdin.fd
: fs.openSync('/dev/tty', 'rs');
/*eslint-enable prettier/prettier*/
let fd;
if (process.platform === 'win32') {
// @ts-ignore
fd = process.stdin.fd;
} else {
fd = fs.openSync('/dev/tty', 'rs');
}

const wasRaw = process.stdin.isRaw;
if (!wasRaw && process.stdin.setRawMode) {
Expand Down Expand Up @@ -91,7 +91,7 @@ function create() {
fs.closeSync(fd);
process.exit(130);
if (process.stdin.setRawMode) {
process.stdin.setRawMode(!!wasRaw);
process.stdin.setRawMode!(!!wasRaw);
}
return null;
}
Expand Down
3 changes: 1 addition & 2 deletions packages/cli/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@
{"path": "../tools"},
{"path": "../cli-types"},
{"path": "../debugger-ui"}
],
"include": ["../package.json"]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this broke type defs

]
}