Fix lint in local-cli

Summary: Fix more lint warnings in local-cli

Reviewed By: davidaurelio

Differential Revision: D4213265

fbshipit-source-id: a7f251f2af1e1de67a2b51908713e7a18faf6f18
This commit is contained in:
Ovidiu Viorel Iepure 2016-11-21 10:18:48 -08:00 committed by Facebook Github Bot
parent 812591ac42
commit 8dbb025959
4 changed files with 58 additions and 30 deletions

View File

@ -18,7 +18,8 @@ const writeSourceMap = require('./write-sourcemap');
const {joinModules} = require('./util');
const MAGIC_UNBUNDLE_FILENAME = 'UNBUNDLE'; // must not start with a dot, as that won't go into the apk
// must not start with a dot, as that won't go into the apk
const MAGIC_UNBUNDLE_FILENAME = 'UNBUNDLE';
const MODULES_DIR = 'js-modules';
/**

View File

@ -55,7 +55,10 @@ function library(argv, config, args) {
console.log('Created library in', libraryDest);
console.log('Next Steps:');
console.log(' Link your library in Xcode:');
console.log(' https://facebook.github.io/react-native/docs/linking-libraries-ios.html#content\n');
console.log(
' https://facebook.github.io/react-native/docs/' +
'linking-libraries-ios.html#content\n'
);
}
module.exports = {

View File

@ -95,8 +95,10 @@ function buildAndRun(args) {
gradleArgs.push('install');
}
// Append the build type to the current gradle install configuration. By default it will generate `installDebug`.
gradleArgs[0] = gradleArgs[0] + args.configuration[0].toUpperCase() + args.configuration.slice(1);
// Append the build type to the current gradle install configuration.
// By default it will generate `installDebug`.
gradleArgs[0] =
gradleArgs[0] + args.configuration[0].toUpperCase() + args.configuration.slice(1);
// Get the Android project directory.
const androidProjectDir = path.join(args.root, 'android');
@ -106,9 +108,17 @@ function buildAndRun(args) {
'Generating the bundle for the release build...'
));
child_process.execSync(`react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output ${androidProjectDir}/app/src/main/assets/index.android.bundle --assets-dest ${androidProjectDir}/app/src/main/res/`, {
stdio: [process.stdin, process.stdout, process.stderr]
});
child_process.execSync(
'react-native bundle ' +
'--platform android ' +
'--dev false ' +
'--entry-file index.android.js ' +
`--bundle-output ${androidProjectDir}/app/src/main/assets/index.android.bundle ` +
`--assets-dest ${androidProjectDir}/app/src/main/res/`,
{
stdio: [process.stdin, process.stdout, process.stderr],
}
);
}
// Change to the Android directory.
@ -120,7 +130,8 @@ function buildAndRun(args) {
: './gradlew';
console.log(chalk.bold(
`Building and installing the app on the device (cd android && ${cmd} ${gradleArgs.join(' ')})...`
'Building and installing the app on the device ' +
`(cd android && ${cmd} ${gradleArgs.join(' ')})...`
));
child_process.execFileSync(cmd, gradleArgs, {
@ -152,7 +163,8 @@ function buildAndRun(args) {
if (devices && devices.length > 0) {
devices.forEach((device) => {
const adbArgs = ['-s', device, 'shell', 'am', 'start', '-n', packageName + '/.MainActivity'];
const adbArgs =
['-s', device, 'shell', 'am', 'start', '-n', packageName + '/.MainActivity'];
console.log(chalk.bold(
`Starting the app on ${device} (${adbPath} ${adbArgs.join(' ')})...`
@ -194,7 +206,9 @@ function startServerInNewWindow() {
if (process.platform === 'darwin') {
if (yargV.open) {
return child_process.spawnSync('open', ['-a', yargV.open, launchPackagerScript], procConfig);
return (
child_process.spawnSync('open', ['-a', yargV.open, launchPackagerScript], procConfig)
);
}
return child_process.spawnSync('open', [launchPackagerScript], procConfig);
@ -220,14 +234,20 @@ module.exports = {
func: runAndroid,
options: [{
command: '--root [string]',
description: 'Override the root directory for the android build (which contains the android directory)',
description:
'Override the root directory for the android build ' +
'(which contains the android directory)',
default: '',
}, {
command: '--flavor [string]',
description: '--flavor has been deprecated. Use --variant instead',
}, {
command: '--configuration [string]',
description: 'You can use `Release` or `Debug`. This creates a build based on the selected configuration. If you want to use the `Release` configuration make sure you have the `signingConfig` configured at `app/build.gradle`.',
description:
'You can use `Release` or `Debug`. ' +
'This creates a build based on the selected configuration. ' +
'If you want to use the `Release` configuration make sure you have the ' +
'`signingConfig` configured at `app/build.gradle`.',
default: 'Debug'
}, {
command: '--variant [string]',

View File

@ -35,8 +35,8 @@ function validateAndUpgrade() {
const projectName = packageJSON.name;
if (!projectName) {
warn(
"Your project needs to have a name, declared in package.json, " +
"such as \"name\": \"AwesomeApp\". Please add a project name. Aborting."
'Your project needs to have a name, declared in package.json, ' +
'such as "name": "AwesomeApp". Please add a project name. Aborting.'
);
return;
}
@ -44,17 +44,17 @@ function validateAndUpgrade() {
const version = packageJSON.dependencies['react-native'];
if (!version) {
warn(
"Your 'package.json' file doesn't seem to declare 'react-native' as " +
"a dependency. Nothing to upgrade. Aborting."
'Your "package.json" file doesn\'t seem to declare "react-native" as ' +
'a dependency. Nothing to upgrade. Aborting.'
);
return;
}
if (version === 'latest' || version === '*') {
warn(
"Some major releases introduce breaking changes.\n" +
"Please use a caret version number in your 'package.json' file \n" +
"to avoid breakage. Use e.g. react-native: ^0.38.0. Aborting."
'Some major releases introduce breaking changes.\n' +
'Please use a caret version number in your "package.json" file \n' +
'to avoid breakage. Use e.g. react-native: ^0.38.0. Aborting.'
);
return;
}
@ -68,8 +68,9 @@ function validateAndUpgrade() {
if (!semver.satisfies(installed.version, version)) {
warn(
"react-native version in 'package.json' doesn't match the installed version in 'node_modules'.\n" +
"Try running 'npm install' to fix this. Aborting."
'react-native version in "package.json" doesn\'t match ' +
'the installed version in "node_modules".\n' +
'Try running "npm install" to fix this. Aborting.'
);
return;
}
@ -87,26 +88,29 @@ function validateAndUpgrade() {
console.log(
'Upgrading project to react-native v' + installed.version + '\n' +
'Check out the release notes and breaking changes: ' +
'https://github.com/facebook/react-native/releases/tag/v' + semver.major(v) + '.' + semver.minor(v) + '.0'
'https://github.com/facebook/react-native/releases/tag/v' +
semver.major(v) + '.' + semver.minor(v) + '.0'
);
// >= v0.21.0, we require react to be a peer dependency
if (semver.gte(v, '0.21.0') && !packageJSON.dependencies.react) {
warn(
"Your 'package.json' file doesn't seem to have 'react' as a dependency.\n" +
"'react' was changed from a dependency to a peer dependency in react-native v0.21.0.\n" +
"Therefore, it's necessary to include 'react' in your project's dependencies.\n" +
"Please run 'npm install --save react', then re-run 'react-native upgrade'.\n"
'Your "package.json" file doesn\'t seem to have "react" as a dependency.\n' +
'"react" was changed from a dependency to a peer dependency in react-native v0.21.0.\n' +
'Therefore, it\'s necessary to include "react" in your project\'s dependencies.\n' +
'Please run "npm install --save react", then re-run "react-native upgrade".\n'
);
return;
}
if (semver.satisfies(v, '~0.26.0')) {
warn(
"React Native 0.26 introduced some breaking changes to the native files on iOS. You can\n" +
"perform them manually by checking the release notes or use \'rnpm\' to do it automatically.\n" +
"Just run:\n" +
"\'npm install -g rnpm && npm install rnpm-plugin-upgrade@0.26 --save-dev\', then run \'rnpm upgrade\'"
'React Native 0.26 introduced some breaking changes to the native files on iOS. You can\n' +
'perform them manually by checking the release notes or use "rnpm" ' +
'to do it automatically.\n' +
'Just run:\n' +
'"npm install -g rnpm && npm install rnpm-plugin-upgrade@0.26 --save-dev", ' +
'then run "rnpm upgrade".'
);
}