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
18 changes: 16 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,26 @@ Repository is splitted into two packages:

## Testing your changes

You can test your changes by calling `cli.js` directly from the cloned repository. You need to make sure the version of React Native matches the one present in devDependencies of the CLI. Otherwise, you may get unexpected errors.
> Please make sure the version of React Native matches the one present in devDependencies of the CLI. Otherwise, you may get unexpected errors.

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:

```sh
node /path/to/cloned/project/packages/cli/build/index.js
cd /path/to/cloned/project/
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-types" "@react-native-community/cli-tools"

npx react-native run-android
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can see this gets pretty complicated and only affects a single package. We need an npm-script that would cd to every package and run yarn link there, so that folks can then run:

yarn link @react-native-community/cli-tools @react-native-community/cli-platform-ios  @react-native-community/cli-platform-android @react-native-community/cli @react-native-community/cli-types

Then we could write something like:

Using yarn link

CLI is a monorepo with multiple packages interacting with each-other. In order to effortlessly test your changes you'll need to "link" them using yarn link for every package. You can do so with this command:

yarn link-packages

And then, in your test project, run:

yarn link @react-native-community/cli-tools @react-native-community/cli-platform-ios  @react-native-community/cli-platform-android @react-native-community/cli @react-native-community/cli-types

From now on, your test project will transparently use the CLI from symlinked packages.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I remember running into it when I did link/cli and ended up not seeing my Android changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I'll work on that !


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`.

## Testing `init` command

You can test your changes by installing local npm proxy - `verdaccio`, and publishing custom versions of `@react-native-community/cli` and `react-native`.
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ _Note: CLI has been extracted from core `react-native` as a part of "[Lean Core]
- [Using global CLI (_legacy_)](#using-global-cli-legacy)
- [Usage in an existing React Native project](#usage-in-an-existing-react-native-project)
- [Updating the CLI](#updating-the-cli)
- [Contributing](./CONTRIBUTING.md)
- [Maintainers](#maintainers)
- [License](#license)

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"lint": "eslint --ext .js,.ts . --cache --report-unused-disable-directives",
"test:ci:cocoapods": "ruby packages/platform-ios/native_modules.rb",
"postinstall": "yarn build",
"link-packages": "PACKAGES=('tools' 'platform-ios' 'platform-android' 'cli' 'cli-types' 'global-cli') && cd packages && for PACKAGE in \"${PACKAGES[@]}\"; do cd $PACKAGE && yarn link && cd ..; done",
"publish": "yarn build-clean-all && yarn install && lerna publish"
},
"dependencies": {
Expand Down