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:
parent
812591ac42
commit
8dbb025959
|
@ -18,7 +18,8 @@ const writeSourceMap = require('./write-sourcemap');
|
||||||
|
|
||||||
const {joinModules} = require('./util');
|
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';
|
const MODULES_DIR = 'js-modules';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -55,7 +55,10 @@ function library(argv, config, args) {
|
||||||
console.log('Created library in', libraryDest);
|
console.log('Created library in', libraryDest);
|
||||||
console.log('Next Steps:');
|
console.log('Next Steps:');
|
||||||
console.log(' Link your library in Xcode:');
|
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 = {
|
module.exports = {
|
||||||
|
|
|
@ -95,8 +95,10 @@ function buildAndRun(args) {
|
||||||
gradleArgs.push('install');
|
gradleArgs.push('install');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Append the build type to the current gradle install configuration. By default it will generate `installDebug`.
|
// Append the build type to the current gradle install configuration.
|
||||||
gradleArgs[0] = gradleArgs[0] + args.configuration[0].toUpperCase() + args.configuration.slice(1);
|
// By default it will generate `installDebug`.
|
||||||
|
gradleArgs[0] =
|
||||||
|
gradleArgs[0] + args.configuration[0].toUpperCase() + args.configuration.slice(1);
|
||||||
|
|
||||||
// Get the Android project directory.
|
// Get the Android project directory.
|
||||||
const androidProjectDir = path.join(args.root, 'android');
|
const androidProjectDir = path.join(args.root, 'android');
|
||||||
|
@ -106,9 +108,17 @@ function buildAndRun(args) {
|
||||||
'Generating the bundle for the release build...'
|
'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/`, {
|
child_process.execSync(
|
||||||
stdio: [process.stdin, process.stdout, process.stderr]
|
'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.
|
// Change to the Android directory.
|
||||||
|
@ -120,7 +130,8 @@ function buildAndRun(args) {
|
||||||
: './gradlew';
|
: './gradlew';
|
||||||
|
|
||||||
console.log(chalk.bold(
|
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, {
|
child_process.execFileSync(cmd, gradleArgs, {
|
||||||
|
@ -152,7 +163,8 @@ function buildAndRun(args) {
|
||||||
if (devices && devices.length > 0) {
|
if (devices && devices.length > 0) {
|
||||||
devices.forEach((device) => {
|
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(
|
console.log(chalk.bold(
|
||||||
`Starting the app on ${device} (${adbPath} ${adbArgs.join(' ')})...`
|
`Starting the app on ${device} (${adbPath} ${adbArgs.join(' ')})...`
|
||||||
|
@ -194,7 +206,9 @@ function startServerInNewWindow() {
|
||||||
|
|
||||||
if (process.platform === 'darwin') {
|
if (process.platform === 'darwin') {
|
||||||
if (yargV.open) {
|
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);
|
return child_process.spawnSync('open', [launchPackagerScript], procConfig);
|
||||||
|
|
||||||
|
@ -220,14 +234,20 @@ module.exports = {
|
||||||
func: runAndroid,
|
func: runAndroid,
|
||||||
options: [{
|
options: [{
|
||||||
command: '--root [string]',
|
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: '',
|
default: '',
|
||||||
}, {
|
}, {
|
||||||
command: '--flavor [string]',
|
command: '--flavor [string]',
|
||||||
description: '--flavor has been deprecated. Use --variant instead',
|
description: '--flavor has been deprecated. Use --variant instead',
|
||||||
}, {
|
}, {
|
||||||
command: '--configuration [string]',
|
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'
|
default: 'Debug'
|
||||||
}, {
|
}, {
|
||||||
command: '--variant [string]',
|
command: '--variant [string]',
|
||||||
|
|
|
@ -35,8 +35,8 @@ function validateAndUpgrade() {
|
||||||
const projectName = packageJSON.name;
|
const projectName = packageJSON.name;
|
||||||
if (!projectName) {
|
if (!projectName) {
|
||||||
warn(
|
warn(
|
||||||
"Your project needs to have a name, declared in package.json, " +
|
'Your project needs to have a name, declared in package.json, ' +
|
||||||
"such as \"name\": \"AwesomeApp\". Please add a project name. Aborting."
|
'such as "name": "AwesomeApp". Please add a project name. Aborting.'
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -44,17 +44,17 @@ function validateAndUpgrade() {
|
||||||
const version = packageJSON.dependencies['react-native'];
|
const version = packageJSON.dependencies['react-native'];
|
||||||
if (!version) {
|
if (!version) {
|
||||||
warn(
|
warn(
|
||||||
"Your 'package.json' file doesn't seem to declare 'react-native' as " +
|
'Your "package.json" file doesn\'t seem to declare "react-native" as ' +
|
||||||
"a dependency. Nothing to upgrade. Aborting."
|
'a dependency. Nothing to upgrade. Aborting.'
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (version === 'latest' || version === '*') {
|
if (version === 'latest' || version === '*') {
|
||||||
warn(
|
warn(
|
||||||
"Some major releases introduce breaking changes.\n" +
|
'Some major releases introduce breaking changes.\n' +
|
||||||
"Please use a caret version number in your 'package.json' file \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."
|
'to avoid breakage. Use e.g. react-native: ^0.38.0. Aborting.'
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -68,8 +68,9 @@ function validateAndUpgrade() {
|
||||||
|
|
||||||
if (!semver.satisfies(installed.version, version)) {
|
if (!semver.satisfies(installed.version, version)) {
|
||||||
warn(
|
warn(
|
||||||
"react-native version in 'package.json' doesn't match the installed version in 'node_modules'.\n" +
|
'react-native version in "package.json" doesn\'t match ' +
|
||||||
"Try running 'npm install' to fix this. Aborting."
|
'the installed version in "node_modules".\n' +
|
||||||
|
'Try running "npm install" to fix this. Aborting.'
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -87,26 +88,29 @@ function validateAndUpgrade() {
|
||||||
console.log(
|
console.log(
|
||||||
'Upgrading project to react-native v' + installed.version + '\n' +
|
'Upgrading project to react-native v' + installed.version + '\n' +
|
||||||
'Check out the release notes and breaking changes: ' +
|
'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
|
// >= v0.21.0, we require react to be a peer dependency
|
||||||
if (semver.gte(v, '0.21.0') && !packageJSON.dependencies.react) {
|
if (semver.gte(v, '0.21.0') && !packageJSON.dependencies.react) {
|
||||||
warn(
|
warn(
|
||||||
"Your 'package.json' file doesn't seem to have 'react' as a dependency.\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" +
|
'"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" +
|
'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"
|
'Please run "npm install --save react", then re-run "react-native upgrade".\n'
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (semver.satisfies(v, '~0.26.0')) {
|
if (semver.satisfies(v, '~0.26.0')) {
|
||||||
warn(
|
warn(
|
||||||
"React Native 0.26 introduced some breaking changes to the native files on iOS. You can\n" +
|
'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" +
|
'perform them manually by checking the release notes or use "rnpm" ' +
|
||||||
"Just run:\n" +
|
'to do it automatically.\n' +
|
||||||
"\'npm install -g rnpm && npm install rnpm-plugin-upgrade@0.26 --save-dev\', then run \'rnpm upgrade\'"
|
'Just run:\n' +
|
||||||
|
'"npm install -g rnpm && npm install rnpm-plugin-upgrade@0.26 --save-dev", ' +
|
||||||
|
'then run "rnpm upgrade".'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue