react-native icon indicating copy to clipboard operation
react-native copied to clipboard

feat(cli): warn underlying command when using `npx react-native init`

Open byCedric opened this issue 2 years ago • 2 comments

Summary:

This adds a new warning for React Native 0.74, implementing the RFC 0759 init command changes.

  • It's added inside react-native/cli.js to avoid warning users when actually executing npx @react-native-community/cli commands.
  • The check is fairly simple: process.argv[2] === 'init'. The first two args are the Node bin and the actual script bin paths.
  • The message is sent over console.warn to avoid potentially mixing JSON with non-JSON output.

Changelog:

[GENERAL] [ADDED] - Warn with future command when using npx react-native init

Test Plan:

Any command other than init must not warn.

  • $ node ./path/to/react-native/cli.js init
  • $ node ./path/to/react-native/cli.js init --help
    • Should warn with Running: npx @react-native-community/cli init image
  • $ node ./path/to/react-native/cli.js --help
    • Must not warn image

byCedric avatar Feb 21 '24 13:02 byCedric

I'm not sure if there are tests for react-native/cli.js, but I would be happy to add a test to validate this. Just not sure where this is tested.

byCedric avatar Feb 21 '24 13:02 byCedric

@cortinico has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

facebook-github-bot avatar Feb 22 '24 11:02 facebook-github-bot

@cortinico merged this pull request in facebook/react-native@a6397afb7f4279e70afa025fe6f9fa0b8e3de3fd.

facebook-github-bot avatar Feb 24 '24 10:02 facebook-github-bot