Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update react-native version in the template for versions >= 0.75. #2417

Merged
merged 3 commits into from
Jun 20, 2024

Conversation

blakef
Copy link
Contributor

@blakef blakef commented Jun 19, 2024

The new template handling in @react-native-community/template means that these are shipped with version 1000.0.0 for React Native. The CLI now owns having to update to the correct version.

NOTE: This will only apply if the template has a react-native@1000.0.0, i.e. is from @react-native-community/template.

Summary:

  1. Allow using --template and --version when --version is >= 0.75. Added a warning about doing this, but it's valid if the user gets into trouble or more advanced users want to do fun stuff.
  2. @react-native/ scoped dependencies must match the version of react-native. init now enforces this.
  3. Done some work to normalise tags into concrete versions. Going forward @react-native-community/template will release matching version for each React Native release. It's important to normalise version at the time of constructing the project otherwise the template will gradually become invalidate as react-native@latest (for example) moves.

For example, now running:

node ./packages/cli/build/bin.js init Test75RC0 --version next  --skip-install --verbose

Updated react-native version on template

CleanShot 2024-06-19 at 15 55 24@2x

Added some logs for the version update in the template

CleanShot 2024-06-19 at 15 49 03@2x

Scoped Version Matching

CleanShot 2024-06-19 at 18 04 38@2x

Test Plan:

  • additional unit test
  • built and run locally:
node ./packages/cli/build/bin.js init Test75RC0 --version next  --skip-install --verbose
node ./packages/cli/build/bin.js init Test75RC0  --skip-install --verbose

Checklist

  • Documentation is up to date to reflect these changes.
  • Follows commit message convention described in CONTRIBUTING.md

@blakef blakef requested review from szymonrybczak and removed request for thymikee and adamTrz June 19, 2024 14:57
@blakef blakef requested a review from cortinico June 19, 2024 14:57
Copy link
Contributor

@cipolleschi cipolleschi left a comment

Choose a reason for hiding this comment

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

LGTM

@blakef blakef force-pushed the fix/new-template-set-react-version branch 2 times, most recently from 2887f96 to 4e3eb5a Compare June 19, 2024 15:38
@cortinico
Copy link
Member

Discussed offline with @blakef:

We also need all the deps inside devDependencies to be updated as they can't be 0.75-main:
Screenshot 2024-06-19 at 17 22 16

@blakef
Copy link
Contributor Author

blakef commented Jun 19, 2024

Discussed offline with @blakef:

We also need all the deps inside devDependencies to be updated as they can't be 0.75-main: Screenshot 2024-06-19 at 17 22 16

Done.

@blakef blakef force-pushed the fix/new-template-set-react-version branch from 271bcc8 to eb3d337 Compare June 19, 2024 17:29
Copy link
Member

@cortinico cortinico left a comment

Choose a reason for hiding this comment

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

LGTM but left a couple of nits

@blakef blakef force-pushed the fix/new-template-set-react-version branch 2 times, most recently from bdf287d to 9e4131b Compare June 19, 2024 21:29
The new template handling in @react-native-community/template means that
these are shipped with version 1000.0.0 for React Native. The CLI now
owns this.
1. Allow using both of these, but only when the user specifies a version
   of react-native >= 0.75. Since templates are now detached there are
   valid use cases for developers and users to specify a template.
   Added a warning about this test(scope): title
2. Exit early for 0.75+ when we can't find a matching
   @react-native-community/template to the version of react-native.
   These should always be matching, but allow for users to remidy this
   by specifying a template. Clearly this should never happen though.

I've also gone to some effort to use concrete versions in the code when
tags are passed.  E.g. --version next, currently maps to 0.75.0-rc0. We
use the latter when looking up templates.
From 0.75 our @react-native/ dependencies must match the version of
react-native. Updated init to perform this on
@react-native-community/template.
@cortinico cortinico merged commit 45bc011 into main Jun 20, 2024
10 checks passed
@cortinico cortinico deleted the fix/new-template-set-react-version branch June 20, 2024 08:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants