Skip to content

Contributing to the CLI

Jon Thysell edited this page Nov 11, 2024 · 34 revisions

Where stuff lives

Parts of the CLI:

  1. CLI Package: The commands that run with react-native <command> are here:
    [Root]\packages\@react-native-windows\cli
  2. Template files used with react-native init-windows can be found here:
    [Root]\vnext\templates

Testing local changes to RNW or its CLI commands on existing in-repo projects

If you've made local changes to your RNW repo, or to one of the CLI commands (such as react-native run-windows, react-native autolink-windows, etc.), the easiest way to do so is to test one of the many RNW apps already existing in the repo, such as packages/e2e-test-app or packages/sample-app-fabric.

If you want to debug a CLI command as it runs, you can do so by running the command in a new "JavaScript Debug Terminal" in VSCode.

Testing local changes to RNW or its CLI commands on a new project

See Creating new projects to test specific RNW versions, specifically Using your local RNW repo.

Again, if you want to debug a CLI command as it runs, you can do so by running the command in a new "JavaScript Debug Terminal" in VSCode.

Testing react-native-windows-init on older projects (RNW < 0.75)

If you are making local changes to the old react-native-windows-init code, you can build and run it locally:

  1. Build the react-native-windows-init package (packages/react-native-windows-init) locally using yarn build`
  2. Manually call into the CLI by using node <root>\packages\react-native-windows-init\bin.js [...] rather than calling npx react-native-windows-init [...]

Note, you can pass parameters to that as usual, or use node --inspect-brk ... to allow you to attach to the call using VSCode.

Also note that this will only test the changes made directly to the react-native-windows-init package. The other packages will be downloaded from npmjs.org (according to the version you specified with --version) during the process.

Note: If you want to test local changes to RNW or its CLI commands on projects you want to create using react-native-windows-init, you'll need to use the --devMode option when running that command. Since react-native-windows-init takes responsibility for calling yarn add react-native-windows, the --devMode option will tell the script to also call yarn link on your behalf too. Note this only works for classic Yarn and still requires you to register your repo with yarn link in your vnext folder.