Skip to content

Commit

Permalink
docs: add linkage instructions for yarn v2 (#1237)
Browse files Browse the repository at this point in the history
* Add linkage instructions for `yarn` v2

* Restructure Testing Docs
  • Loading branch information
SConaway authored Aug 10, 2020
1 parent a94c044 commit 9c65949
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ All work on React Native CLI happens directly on GitHub. Contributors send pull

## Repository

Repository is splitted into two packages:
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.
Expand All @@ -22,26 +22,39 @@ Repository is splitted into two packages:

> Please make sure the version of React Native matches the one present in devDependencies of the CLI. Otherwise, you may get unexpected errors.
_Note: you must use the `--watchFolders` flag with the `start` command when testing the CLI with `yarn link` like this. Otherwise Metro can't find the symlinked folder and this may result in errors such as `ReferenceError: SHA-1 for file ... is not computed`._

### Setup
Because of a modular design of the CLI, we recommend developing using symbolic links to its packages. This way you can use it seamlessly in the tested project, as you'd use the locally installed CLI. Here's what you need to run in the terminal:

#### yarn v1

```sh
cd /path/to/cloned/cli/
yarn link-packages
```

And then:

```sh
cd /my/new/react-native/project/
yarn link "@react-native-community/cli-platform-ios" "@react-native-community/cli-platform-android" "@react-native-community/cli" "@react-native-community/cli-server-api" "@react-native-community/cli-types" "@react-native-community/cli-tools" "@react-native-community/cli-debugger-ui"
```

Once you're done with testing and you'd like to get back to regular setup, run `yarn unlink` instead of `yarn link` from above command. Then `yarn install --force`.

npx react-native start --watchFolders /path/to/cloned/cli/
npx react-native run-android
#### yarn v2

```sh
cd /my/new/react-native/project/
yarn link /path/to/cloned/cli/ --all
```

_Note: you must use the `--watchFolders` flag with the `start` command when testing the CLI with `yarn link` like this. Otherwise Metro can't find the symlinked folder and this may result in errors such as `ReferenceError: SHA-1 for file ... is not computed`._
When you'd like to revert to a regular setup, you will need to revert the changes made to the `resolutions` field of `package.json`.

Once you're done with testing and you'd like to get back to regular setup, run `yarn unlink` instead of `yarn link` from above command. Then `yarn install --force`.
### Running
```sh
yarn react-native start --watchFolders /path/to/cloned/cli/
yarn react-native run-android
```

## Testing `init` command

Expand Down

0 comments on commit 9c65949

Please sign in to comment.