react-native
react-native copied to clipboard
feat(cli): warn underlying command when using `npx react-native init`
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.jsto avoid warning users when actually executingnpx @react-native-community/clicommands. - 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.warnto 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
- Should warn with
-
$ node ./path/to/react-native/cli.js --help- Must not warn
- Must not warn
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.
@cortinico has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.
@cortinico merged this pull request in facebook/react-native@a6397afb7f4279e70afa025fe6f9fa0b8e3de3fd.