-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Contributing to the CLI
Andrew Coates edited this page May 5, 2020
·
34 revisions
Parts of the CLI:
- Code to identify the correct version of
react-native-windows
to install, and install it:
[Root]\packages\react-native-windows-init - Template code: The code that actually creates the files needed to to run a create and run react-native-windows app here:
[Root]\vnext\local-cli - Code for
run-windows
and other commands run throughreact-native <foo>
- If you are making changes to the
react-native-windows-init
code, you can build the code locally usingyarn build
, then manually call into the CLI by usingnode <root>\packages\react-native-windows-init\lib-commonjs\Cli.js
-- You can pass parameters to that as usual, or usenode --inspect-brk ...
to allow you to attach to the call using VSCode. - If you are making changes to the vnext part of the CLI, you can install RNW from your local enlistment by supplying the --version parameter to the react-native-windows-init command. For example:
npx react-native-windows-init --version file:d:\rnw\vnext
Note: that yarn does a copy of all the files under vnext to install react-native-windows. Unlike when the package has been published, this will include all the native built files which would normally be excluded by npmignore. You should delete the build, target and packages folder from vnext. Otherwise the command will have to copy GBs of data to install react-native-windows from your local path
The easiest way to to debug is using VS Code. You just need to create a configuration within your template app directory that tells VS Code to launch the CLI in an instance of node and debug node on startup. Here's an example launch.json with a single configuration:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "react-native windows",
"program": "${workspaceRoot}/node_modules/react-native/cli.js",
"args": ["run-windows"],
"stopOnEntry": true
}
],
"compounds": []
}