Skip to content

Commit

Permalink
fix: pass Android manifest parse errors through; remove manual link w…
Browse files Browse the repository at this point in the history
…arnings
  • Loading branch information
thymikee committed Sep 17, 2020
1 parent c23e161 commit c4c8d06
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 121 deletions.
21 changes: 14 additions & 7 deletions packages/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import leven from 'leven';
import path from 'path';

import {Command, Config} from '@react-native-community/cli-types';
import {logger, CLIError} from '@react-native-community/cli-tools';
import {
logger,
CLIError,
inlineString,
} from '@react-native-community/cli-tools';

import {detachedCommands, projectCommands} from './commands';
import init from './commands/init/initCompat';
Expand All @@ -30,17 +34,20 @@ const handleError = (err: Error) => {
} else {
// Some error messages (esp. custom ones) might have `.` at the end already.
const message = err.message.replace(/\.$/, '');
logger.error(
`${message}. ${chalk.dim(
logger.error(`${message}.`);
}
if (err.stack) {
logger.log(err.stack);
}
if (!commander.verbose) {
logger.info(
chalk.dim(
`Run CLI with ${chalk.reset('--verbose')} ${chalk.dim(
'flag for more details.',
)}`,
)}`,
),
);
}
if (err.stack) {
logger.log(chalk.dim(err.stack));
}
process.exit(1);
};

Expand Down
6 changes: 2 additions & 4 deletions packages/platform-android/src/commands/runAndroid/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@ import {
getDefaultUserTerminal,
CLIError,
} from '@react-native-community/cli-tools';
import warnAboutManuallyLinkedLibs from '../../link/warnAboutManuallyLinkedLibs';
import {getAndroidProject, getPackageName} from '../../utils/getAndroidProject';

function displayWarnings(config: Config, args: Flags) {
warnAboutManuallyLinkedLibs(config);
function displayWarnings(args: Flags) {
if (args.appFolder) {
logger.warn(
'Using deprecated "--appFolder" flag. Use "project.android.appName" in react-native.config.js instead.',
Expand Down Expand Up @@ -59,7 +57,7 @@ type AndroidProject = NonNullable<Config['project']['android']>;
* Starts the app on a connected Android emulator or device.
*/
async function runAndroid(_argv: Array<string>, config: Config, args: Flags) {
displayWarnings(config, args);
displayWarnings(args);
const androidProject = getAndroidProject(config);

if (args.jetifier) {
Expand Down
11 changes: 9 additions & 2 deletions packages/platform-android/src/config/readManifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,17 @@
* LICENSE file in the root directory of this source tree.
*
*/

import fs from 'fs';
import xml from 'xmldoc';
import {CLIError} from '@react-native-community/cli-tools';

export default function readManifest(manifestPath: string) {
return new xml.XmlDocument(fs.readFileSync(manifestPath, 'utf8'));
try {
return new xml.XmlDocument(fs.readFileSync(manifestPath, 'utf8'));
} catch (error) {
throw new CLIError(
`Failed to parse Android Manifest file at ${manifestPath}`,
error,
);
}
}
53 changes: 0 additions & 53 deletions packages/platform-android/src/link/warnAboutManuallyLinkedLibs.ts

This file was deleted.

2 changes: 0 additions & 2 deletions packages/platform-ios/src/commands/runIOS/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {Config} from '@react-native-community/cli-types';
import findXcodeProject, {ProjectInfo} from './findXcodeProject';
import parseIOSDevicesList from './parseIOSDevicesList';
import findMatchingSimulator from './findMatchingSimulator';
import warnAboutManuallyLinkedLibs from '../../link/warnAboutManuallyLinkedLibs';
import warnAboutPodInstall from '../../link/warnAboutPodInstall';
import {
logger,
Expand Down Expand Up @@ -48,7 +47,6 @@ function runIOS(_: Array<string>, ctx: Config, args: FlagsT) {
);
}

warnAboutManuallyLinkedLibs(ctx);
warnAboutPodInstall(ctx);

process.chdir(args.projectPath);
Expand Down
53 changes: 0 additions & 53 deletions packages/platform-ios/src/link/warnAboutManuallyLinkedLibs.ts

This file was deleted.

0 comments on commit c4c8d06

Please sign in to comment.