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
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
node_modules/
debugger-ui/
templates/
global-cli/
build/
coverage/
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ build/
.cache
.watchmanconfig
coverage
!packages/platform-ios/src/config/__fixtures__/native_modules/node_modules
!packages/cli-platform-ios/src/config/__fixtures__/native_modules/node_modules
7 changes: 0 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@ All work on React Native CLI happens directly on GitHub. Contributors send pull
1. Run `yarn watch` to automatically build the changed files.
1. Now you are ready to do the changes.

## Repository

This repository is split into two packages:

- `cli` - Historically, it was included in `react-native` package. Contains all the commands code.
- `global-cli` - Historically, it was a `react-native-cli` package and the only reason this package existed was to initialize an empty project.

## Testing your changes

> Please make sure the version of React Native matches the one present in devDependencies of the CLI. Otherwise, you may get unexpected errors.
Expand Down
42 changes: 13 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,17 @@ _Note: CLI has been extracted from core `react-native` as a part of "[Lean Core]

Our release cycle is independent of `react-native`. We follow semver and here is the compatibility table:

| `@react-native-community/cli` | `react-native` |
| ---------------------------------------------------------------- | ----------------------- |
| [^8.0.0](https://github.com/react-native-community/cli/tree/8.x) | ^0.69.0 |
| [^7.0.0](https://github.com/react-native-community/cli/tree/7.x) | ^0.68.0 |
| [^6.0.0](https://github.com/react-native-community/cli/tree/6.x) | ^0.65.0,^0.66.0,^0.67.0 |
| [^5.0.0](https://github.com/react-native-community/cli/tree/5.x) | ^0.64.0 |
| [^4.0.0](https://github.com/react-native-community/cli/tree/4.x) | ^0.62.0,^0.63.0 |
| [^3.0.0](https://github.com/react-native-community/cli/tree/3.x) | ^0.61.0 |
| [^2.0.0](https://github.com/react-native-community/cli/tree/2.x) | ^0.60.0 |
| [^1.0.0](https://github.com/react-native-community/cli/tree/1.x) | ^0.59.0 |
| `@react-native-community/cli` | `react-native` |
| ----------------------------------------------------------------- | ----------------------- |
| [^9.0.0](https://github.com/react-native-community/cli/tree/main) | ^0.70.0 |
| [^8.0.0](https://github.com/react-native-community/cli/tree/8.x) | ^0.69.0 |
| [^7.0.0](https://github.com/react-native-community/cli/tree/7.x) | ^0.68.0 |
| [^6.0.0](https://github.com/react-native-community/cli/tree/6.x) | ^0.65.0,^0.66.0,^0.67.0 |
| [^5.0.0](https://github.com/react-native-community/cli/tree/5.x) | ^0.64.0 |
| [^4.0.0](https://github.com/react-native-community/cli/tree/4.x) | ^0.62.0,^0.63.0 |
| [^3.0.0](https://github.com/react-native-community/cli/tree/3.x) | ^0.61.0 |
| [^2.0.0](https://github.com/react-native-community/cli/tree/2.x) | ^0.60.0 |
| [^1.0.0](https://github.com/react-native-community/cli/tree/1.x) | ^0.59.0 |

## Documentation

Expand All @@ -46,26 +47,11 @@ Our release cycle is independent of `react-native`. We follow semver and here is

## About

This repository contains tools and helpers for React Native projects in form of a command line tool. There's been quite some confusion around that since the extraction from React Native core. Let's clear them up:

- There are currently two CLIs:
- [`@react-native-community/cli`](./packages/cli) – **the one used directly by `react-native`**. That makes it a transitive dependency of your project.
- [`react-native-cli`](./packages/global-cli) – an optional global convenience package, which is a proxy to [`@react-native-community/cli`](./packages/cli) and global installation helper. **Please consider it legacy, because it's not necessary anymore**.
- When we say "the CLI" we mean `@react-native-community/cli`.
- We update the CLI independently of React Native itself. Please see [how to use the latest version](#updating-the-cli).
- This is a monorepo to keep stuff organized.

We're actively working to make any indirections gone.
This monorepository contains tools and helpers for React Native projects in form of a Command Line Tool (or CLI). This CLI is used directly by the `react-native` package and is not intended for use directly. We update it independently of React Native itself.

## Creating a new React Native project

There are two ways to start a React Native project.

### Using `npx` (_recommended_)

> Available since `react-native@0.60`

This method is preferred if you don't want to install global packages.
Run the following command in your terminal prompt:

```sh
npx react-native init MyApp
Expand All @@ -81,8 +67,6 @@ Example running `start` command in terminal:
yarn react-native start
# or:
npx react-native start
# or
node ./node_modules/.bin/react-native start
```

You can also add npm scripts to call it with whichever package manager you use:
Expand Down
2 changes: 1 addition & 1 deletion packages/cli-clean/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"outDir": "build"
},
"references": [
{"path": "../tools"},
{"path": "../cli-tools"},
{"path": "../cli-types"},
{"path": "../cli-config"}
]
Expand Down
2 changes: 1 addition & 1 deletion packages/cli-config/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"rootDir": "src",
"outDir": "build"
},
"references": [{"path": "../tools"}, {"path": "../cli-types"}]
"references": [{"path": "../cli-tools"}, {"path": "../cli-types"}]
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
/* global __fbBatchedBridge, self, importScripts, postMessage, onmessage: true */
/* eslint no-unused-vars: 0 */

onmessage = (function() {
onmessage = (function () {
var visibilityState;
var showVisibilityWarning = (function() {
var showVisibilityWarning = (function () {
var hasWarned = false;
return function() {
return function () {
// Wait until `YellowBox` gets initialized before displaying the warning.
if (hasWarned || console.warn.toString().includes('[native code]')) {
return;
Expand All @@ -28,7 +28,7 @@ onmessage = (function() {
})();

var messageHandlers = {
executeApplicationScript: function(message, sendReply) {
executeApplicationScript: function (message, sendReply) {
for (var key in message.inject) {
self[key] = JSON.parse(message.inject[key]);
}
Expand All @@ -40,19 +40,19 @@ onmessage = (function() {
}
sendReply(null /* result */, error);
},
setDebuggerVisibility: function(message) {
setDebuggerVisibility: function (message) {
visibilityState = message.visibilityState;
},
};

return function(message) {
return function (message) {
if (visibilityState === 'hidden') {
showVisibilityWarning();
}

var object = message.data;

var sendReply = function(result, error) {
var sendReply = function (result, error) {
postMessage({replyID: object.id, result: result, error: error});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ import orangeIcon from './assets/orange-icon.png';

const isMacLike = /(Mac|iPhone|iPod|iPad)/i.test(navigator.platform);
const refreshShortcut = isMacLike ? '⌘R' : 'Ctrl R';
window.onload = function() {
window.onload = function () {
if (!isMacLike) {
document.getElementById('shortcut').innerHTML = 'Ctrl⇧J';
}
Page.render();
};

window.onReloadClicked = function() {
window.onReloadClicked = function () {
var xhr = new XMLHttpRequest();
xhr.open('GET', `${window.location.origin}/reload`, true);
xhr.send();
Expand Down Expand Up @@ -119,10 +119,10 @@ function connectToDebuggerProxy() {
// making sure that it's run in an environment without a global
// document, to make it consistent with the JSC executor environment.
worker = new Worker('./debuggerWorker.js');
worker.onmessage = function(message) {
worker.onmessage = function (message) {
ws.send(JSON.stringify(message.data));
};
window.onbeforeunload = function() {
window.onbeforeunload = function () {
return (
'If you reload this page, it is going to break the debugging session. ' +
'Press ' +
Expand Down Expand Up @@ -151,11 +151,11 @@ function connectToDebuggerProxy() {
Page.setState({visibilityState: document.visibilityState});
}

ws.onopen = function() {
ws.onopen = function () {
Page.setState({status: {type: 'connecting'}});
};

ws.onmessage = async function(message) {
ws.onmessage = async function (message) {
if (!message.data) {
return;
}
Expand Down Expand Up @@ -186,7 +186,7 @@ function connectToDebuggerProxy() {
}
};

ws.onclose = function(error) {
ws.onclose = function (error) {
shutdownJSRuntime();
Page.setState({status: {type: 'error', error}});
if (error.reason) {
Expand Down
4 changes: 2 additions & 2 deletions packages/cli-doctor/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"outDir": "build"
},
"references": [
{"path": "../tools"},
{"path": "../cli-tools"},
{"path": "../cli-types"},
{"path": "../cli-config"},
{"path": "../platform-ios"}
{"path": "../cli-platform-ios"}
]
}
4 changes: 2 additions & 2 deletions packages/cli-hermes/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"outDir": "build"
},
"references": [
{"path": "../tools"},
{"path": "../cli-tools"},
{"path": "../cli-types"},
{"path": "../platform-android"}
{"path": "../cli-platform-android"}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"rootDir": "src",
"outDir": "build"
},
"references": [{"path": "../tools"}, {"path": "../cli-types"}]
"references": [{"path": "../cli-tools"}, {"path": "../cli-types"}]
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"outDir": "build",
"typeRoots": ["definitions"]
},
"references": [{"path": "../tools"}, {"path": "../cli-types"}]
"references": [{"path": "../cli-tools"}, {"path": "../cli-types"}]
}
2 changes: 1 addition & 1 deletion packages/cli-plugin-metro/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
"references": [
{"path": "../cli-types"},
{"path": "../cli-server-api"},
{"path": "../tools"},
{"path": "../cli-tools"},
]
}
2 changes: 1 addition & 1 deletion packages/cli-server-api/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"rootDir": "src",
"outDir": "build"
},
"references": [{"path": "../tools"}, {"path": "../debugger-ui"}]
"references": [{"path": "../cli-tools"}, {"path": "../cli-debugger-ui"}]
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions packages/cli/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
{"path": "../cli-plugin-metro"},
{"path": "../cli-server-api"},
{"path": "../cli-types"},
{"path": "../debugger-ui"},
{"path": "../tools"}
{"path": "../cli-debugger-ui"},
{"path": "../cli-tools"}
]
}
5 changes: 1 addition & 4 deletions scripts/linkPackages.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ const chalk = require('chalk');
const path = require('path');
const glob = require('glob');

const projects = glob
.sync('packages/*/package.json')
// We don't want to deal with global-cli at the moment
.filter((name) => !name.includes('global-cli'));
const projects = glob.sync('packages/*/package.json');

projects.forEach((project) => {
const cwd = path.dirname(project);
Expand Down