Skip to content

Commit 5e8e6b8

Browse files
GantManFacebook Github Bot
authored and
Facebook Github Bot
committed
Add CLI basics in docs
Summary: Adding documentation for the CLI for 2 reasons: 1. It's not immediately clear to most how the CLI is part of `react-native` and not the node module they installed. This begins clarifying. 2. I plan on adding some additional documentation to this section pending an upcoming PR I've discussed with Mike. screen shot provided: ![image](https://cloud.githubusercontent.com/assets/997157/20574213/0640d026-b179-11e6-9bc1-4f507b2a195a.png) Closes #11097 Differential Revision: D4237028 Pulled By: mkonicek fbshipit-source-id: c1dc50fe1be7f6947a33ee6472b5862306888055
1 parent f2684e3 commit 5e8e6b8

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed

docs/Performance.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: Performance
44
layout: docs
55
category: Guides
66
permalink: docs/performance.html
7-
next: upgrading
7+
next: understanding-cli
88
previous: navigation
99
---
1010

docs/UnderstandingCLI.md

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
id: understanding-cli
3+
title: Understanding the CLI
4+
layout: docs
5+
category: Guides
6+
permalink: docs/understanding-cli.html
7+
next: upgrading
8+
previous: performance
9+
---
10+
11+
Though you may have installed the `react-native-cli` via npm as a separate module, it is a shell for accessing the CLI embedded
12+
in the React Native of each project. Your commands and their effects are dependent on the version of the module of `react-native`
13+
in context of the project. This guide will give a brief overview of the CLI in the module.
14+
15+
# The local CLI
16+
17+
React Native has a [`local-cli`](https://github.com/facebook/react-native/tree/master/local-cli) folder with a file named
18+
[`cliEntry.js`](https://github.com/facebook/react-native/blob/master/local-cli/cliEntry.js). Here, the commands are read
19+
from `commands.js` and added as possible CLI commands. _E.G._ the `react-native link` command, exists in the
20+
[`react-native/local-cli/link`](https://github.com/facebook/react-native/blob/master/local-cli/link/) folder, and is
21+
required in `commands.js`, which will register it as a documented command to be exposed to the CLI.
22+
23+
# Command definitions
24+
25+
At the end of each command entry is an export. The export is an object with a function to perform, description of the command, and the command name. The object structure for the `unlink` command looks like so:
26+
27+
```js
28+
module.exports = {
29+
func: link,
30+
description: 'links all native dependencies',
31+
name: 'link [packageName]',
32+
};
33+
```
34+
35+
### Parameters
36+
37+
The command name identifies the parameters that a command would expect. When the command parameter is surrounded by greater-than, less-than symbols `< >`, this indicates that the parameter is expected. When a parameter is surrounded by brackets `[ ]`, this indicates that the parameter is optional.
38+

docs/Upgrading.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ layout: docs
55
category: Guides
66
permalink: docs/upgrading.html
77
next: platform-specific-code
8-
previous: performance
8+
previous: understanding-cli
99
---
1010

1111
Upgrading to new versions of React Native will give you access to more APIs, views, developer tools

0 commit comments

Comments
 (0)