Remove remaining references to local-cli

Summary: This removes the remaining references to `local-cli`. We already have a `cli.js` file on the root that was just forwarding to the local-cli folder, so I removed that. It also seems that `setupBabel.js` is no longer necessary in RN.

Reviewed By: TheSavior

Differential Revision: D13396218

fbshipit-source-id: a945cb91dae39c4b58c5cabcca6b0f0328fc4717
This commit is contained in:
Christoph Nakazawa
2018-12-10 19:04:56 -08:00
committed by Facebook Github Bot
parent eb413bc9e0
commit 63a6bb7637
16 changed files with 23 additions and 93 deletions

View File

@@ -236,7 +236,7 @@ aliases:
- &build-js-bundle
name: Build JavaScript Bundle
command: node local-cli/cli.js bundle --max-workers 2 --platform android --dev true --entry-file ReactAndroid/src/androidTest/js/TestBundle.js --bundle-output ReactAndroid/src/androidTest/assets/AndroidTestBundle.js
command: node cli.js bundle --max-workers 2 --platform android --dev true --entry-file ReactAndroid/src/androidTest/js/TestBundle.js --bundle-output ReactAndroid/src/androidTest/assets/AndroidTestBundle.js
- &compile-native-libs
name: Compile Native Libs for Unit and Integration Tests

View File

@@ -31,7 +31,7 @@ watchman shutdown-server
# integration tests
# build JS bundle for instrumentation tests
node local-cli/cli.js bundle --platform android --dev true --entry-file ReactAndroid/src/androidTest/js/TestBundle.js --bundle-output ReactAndroid/src/androidTest/assets/AndroidTestBundle.js
node cli.js bundle --platform android --dev true --entry-file ReactAndroid/src/androidTest/js/TestBundle.js --bundle-output ReactAndroid/src/androidTest/assets/AndroidTestBundle.js
# build test APK
# shellcheck disable=SC1091

View File

@@ -65,7 +65,7 @@ import com.android.build.OutputFile
*/
project.ext.react = [
cliPath: "$rootDir/local-cli/cli.js",
cliPath: "$rootDir/cli.js",
bundleAssetName: "RNTesterApp.android.bundle",
entryFile: file("../../js/RNTesterApp.android.js"),
root: "$rootDir",

View File

@@ -3,7 +3,7 @@ load("//tools/build_defs/oss:rn_defs.bzl", "KEYSTORE_TARGET", "react_native_dep"
# We are running instrumentation tests in simple mode: app code and instrumentation are in the same APK
# Currently you need to run these commands to execute tests:
#
# node local-cli/cli.js bundle --platform android --dev true --entry-file ReactAndroid/src/androidTest/js/TestBundle.js --bundle-output ReactAndroid/src/androidTest/assets/AndroidTestBundle.js
# node cli.js bundle --platform android --dev true --entry-file ReactAndroid/src/androidTest/js/TestBundle.js --bundle-output ReactAndroid/src/androidTest/assets/AndroidTestBundle.js
# gradle :ReactAndroid:packageReactNdkLibsForBuck
# buck install ReactAndroid/src/androidTest/buck-runner:instrumentation-tests
# ./scripts/run-android-instrumentation-tests.sh com.facebook.react.tests

8
cli.js
View File

@@ -9,4 +9,10 @@
'use strict';
module.exports = require('./local-cli/cli.js');
var cli = require('react-native-local-cli');
if (require.main === module) {
cli.run();
}
module.exports = cli;

View File

@@ -25,7 +25,6 @@ const generate = require('@babel/generator').default;
const nodeFiles = new RegExp(
[
'/local-cli/',
'/metro(?:-[^/]*)?/', // metro, metro-core, metro-source-map, metro-etc
].join('|'),
);

View File

@@ -7,10 +7,12 @@
* @format
*/
var cliEntry = require('react-native-local-cli');
'use strict';
var cli = require('react-native-local-cli');
if (require.main === module) {
cliEntry.run();
cli.run();
}
module.exports = cliEntry;
module.exports = cli;

View File

@@ -1,48 +0,0 @@
# App templates
This folder contains basic app templates. These get expanded by 'react-native init' when creating a new app to make it easier for anyone to get started.
# Chat Example
This is an example React Native app demonstrates ListViews, text input and
navigation between a few screens.
<img width="487" alt="screenshot 2017-01-13 17 24 37" src="https://cloud.githubusercontent.com/assets/346214/21950983/54d75cb4-d9b5-11e6-9d63-bd7edf51f4d4.png">
<img width="487" alt="screenshot 2017-01-13 17 24 40" src="https://cloud.githubusercontent.com/assets/346214/21950982/54d6797a-d9b5-11e6-829f-3e0f15dab0c1.png">
## Purpose
One problem with React Native is that it is not trivial to get started: `react-native init` creates a very simple app that renders some text. Everyone then has to figure out how to do very basic things such as adding a list of items fetched from a server, navigating to a screen when a list item is tapped, or handling text input.
This app is a template used by `react-native init` so it is easier for anyone to get up and running quickly by having an app with a few screens, a `ListView` and a `TextInput` that works well with the software keyboard.
## Best practices
Another purpose of this app is to define best practices such as:
- The folder structure of a standalone React Native app
- A style guide for JavaScript and React - for this we use the [AirBnb style guide](https://github.com/airbnb/javascript)
- Naming conventions
We need your feedback to settle on a good set of best practices. Have you built React Native apps? If so, please use the issues in the repo [mkonicek/ChatExample](https://github.com/mkonicek/ChatExample) to discuss what you think are the best practices that this example should be using.
## Running the app locally
```
cd ChatExample
yarn
react-native run-ios
react-native run-android
```
---
(In case you want to use react-navigation master):
```
# Install dependencies:
cd react-navigation
yarn
yarn pack --filename react-navigation-1.0.0-alpha.tgz
cd ChatExample
yarn
yarn add ~/code/react-navigation/react-navigation-1.0.0-alpha.tgz
```

View File

@@ -116,10 +116,8 @@
"jest",
"lib",
"rn-get-polyfills.js",
"setupBabel.js",
"Libraries",
"LICENSE",
"local-cli",
"packager",
"react.gradle",
"React.podspec",
@@ -130,7 +128,7 @@
"third-party-podspecs"
],
"scripts": {
"start": "node ./local-cli/cli.js start",
"start": "node cli.js start",
"test": "jest",
"test-ci": "JEST_JUNIT_OUTPUT=\"reports/junit/js-test-results.xml\" jest --maxWorkers=2 --ci --testResultsProcessor=\"jest-junit\"",
"flow": "flow",

View File

@@ -246,7 +246,7 @@ function createProject(name, options) {
version: '0.0.1',
private: true,
scripts: {
start: 'node node_modules/react-native/local-cli/cli.js start',
start: 'node node_modules/react-native/cli.js start',
ios: 'react-native run-ios',
android: 'react-native run-android',
},

View File

@@ -7,7 +7,7 @@ import org.apache.tools.ant.taskdefs.condition.Os
def config = project.hasProperty("react") ? project.react : [];
def cliPath = config.cliPath ?: "node_modules/react-native/local-cli/cli.js"
def cliPath = config.cliPath ?: "node_modules/react-native/cli.js"
def bundleAssetName = config.bundleAssetName ?: "index.android.bundle"
def entryFile = config.entryFile ?: "index.android.js"
def bundleCommand = config.bundleCommand ?: "bundle"

View File

@@ -6,6 +6,6 @@
@echo off
title Metro Bundler
call .packager.bat
node "%~dp0..\local-cli\cli.js" start
node "%~dp0..\cli.js" start
pause
exit

View File

@@ -7,4 +7,4 @@
THIS_DIR=$(cd -P "$(dirname "$(readlink "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}")")" && pwd)
source "${THIS_DIR}/.packager.env"
cd "$THIS_DIR/.."
node "./local-cli/cli.js" start "$@"
node "./cli.js" start "$@"

View File

@@ -84,7 +84,7 @@ fi
[ -z "$NODE_ARGS" ] && export NODE_ARGS=""
[ -z "$CLI_PATH" ] && export CLI_PATH="$REACT_NATIVE_DIR/local-cli/cli.js"
[ -z "$CLI_PATH" ] && export CLI_PATH="$REACT_NATIVE_DIR/cli.js"
[ -z "$BUNDLE_COMMAND" ] && BUNDLE_COMMAND="bundle"

View File

@@ -17,7 +17,7 @@ echo "Compiling native code..."
./gradlew :ReactAndroid:packageReactNdkLibsForBuck
echo "Building JS bundle..."
node local-cli/cli.js bundle --platform android --dev true --entry-file ReactAndroid/src/androidTest/js/TestBundle.js --bundle-output ReactAndroid/src/androidTest/assets/AndroidTestBundle.js
node cli.js bundle --platform android --dev true --entry-file ReactAndroid/src/androidTest/js/TestBundle.js --bundle-output ReactAndroid/src/androidTest/assets/AndroidTestBundle.js
echo "Installing test app on the device..."
buck fetch ReactAndroid/src/androidTest/buck-runner:instrumentation-tests

View File

@@ -1,27 +0,0 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
'use strict';
const babelRegisterOnly = require('metro-babel-register');
const BABEL_ENABLED_PATHS = ['local-cli'];
/**
* Centralized place to register all the directories that need a Babel
* transformation before being fed to Node.js. Notably, this is necessary to
* support Flow type annotations.
*/
function setupBabel() {
babelRegisterOnly(
babelRegisterOnly.buildRegExps(__dirname, BABEL_ENABLED_PATHS),
);
}
module.exports = setupBabel;