Skip to content

Contributing to the CLI

kmelmon edited this page Feb 27, 2020 · 34 revisions

Where stuff lives

The CLI is divided into two parts:

  1. Shared code: Some of the code is shared between 'current' and 'vnext'. This code is mostly responsible for installing RNW. It lives here:
    [Root]\packages\rnpm-plugin-windows
  2. vnext code: The rest of the CLI specific to vnext lives here:
    [Root]\vnext\local-cli

How to test local changes to the CLI:

  1. If you are making changes to the shared code, you can install from your local enlistment during the yarn add rnpm-plugin-windows step by supplying an @file suffix. For example, if your enlistment root was d:\rnw:
    yarn add rnpm-plugin-windows@file:d:\rnw\packages\rnpm-plugin-windows
  2. If you are making changes to the vnext part of the CLI, you can install RNW from your local enlistment by supplying the --windowsVersion parameter to the react-native windows command. For example:
    react-native windows --template vnext --windowsVersion file:d:\rnw\vnext

Note: before using the react-native windows command against your local package, 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

How to debug the CLI:

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": ["windows", "--template", "vnext", "--windowsVersion", "file:../rnw/vnext"],
          "stopOnEntry": true
        }
      ],
      "compounds": []
    }