Skip to content

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

Closed
byCedric wants to merge 1 commit into
react:mainfrom
byCedric:@bycedric/react-native-init/warn-users
Closed

feat(cli): warn underlying command when using npx react-native init#43127
byCedric wants to merge 1 commit into
react:mainfrom
byCedric:@bycedric/react-native-init/warn-users

Conversation

@byCedric

@byCedricbyCedric commented Feb 21, 2024

Copy link
Copy Markdown
Contributor

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

@facebook-github-botfacebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Expo Partner: Expo Partner labels Feb 21, 2024
@byCedric

Copy link
Copy Markdown
ContributorAuthor

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.

@facebook-github-botfacebook-github-bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Feb 21, 2024
@byCedricbyCedric changed the title feat(cli): warn underlying command using npx react-native initfeat(cli): warn underlying command when using npx react-native initFeb 21, 2024

/**
* Warn when users are using `npx react-native init`, to raise awareness of the changes from RFC 0759.
* @see https://github.com/react-native-community/discussions-and-proposals/tree/main/proposals/0759-react-native-frameworks.md

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note, this is pointing to the merged path, which is currently unavailable. The RFC is scheduled to be merged on the 26th of Feb.

@facebook-github-bot

Copy link
Copy Markdown
Contributor

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

@facebook-github-botfacebook-github-bot added the Merged This PR has been merged. label Feb 24, 2024
@facebook-github-bot

Copy link
Copy Markdown
Contributor

@cortinico merged this pull request in a6397af.

cortinico pushed a commit that referenced this pull request Feb 26, 2024
…#43127)
Summary:
This adds a new warning for React Native 0.74, implementing the [RFC 0759](https://github.com/react-native-community/discussions-and-proposals/blob/nc/rnf/proposals/0759-react-native-frameworks.md#the-init-command) 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`
Pull Request resolved: #43127
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](https://github.com/facebook/react-native/assets/1203991/a3f5e3d2-7b59-41fe-9a53-bc9ce5a21fd1)
- `$ node ./path/to/react-native/cli.js --help`
- Must not warn
![image](https://github.com/facebook/react-native/assets/1203991/97679429-db35-47f8-bdeb-33187bb167cf)
Reviewed By: cipolleschi
Differential Revision: D54063131
Pulled By: cortinico
fbshipit-source-id: c60b8b6034087b584e98b51f5bedf68a46caf44c
This was referenced Jun 28, 2024
@cipolleschicipolleschi mentioned this pull request Jul 22, 2024
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA SignedThis label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.MergedThis PR has been merged.p: ExpoPartner: ExpoPartnerShared with MetaApplied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@byCedric@facebook-github-bot@cortinico