-
Notifications
You must be signed in to change notification settings - Fork 899
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
feat: determine react-native → template from npm registry data #2475
Conversation
Looking into the E2E test failures. |
Does this mean we still need to publish a version of the template for each version of react-native though? |
df0647c
to
a5cfebe
Compare
Yes, but because you still need a template with the version of What this change means is that if we release Other changes needed:
|
These failures are because the android autolinking calls Otherwise I've updated snapshots. |
This feature needs to be released with react-native-community/cli#2475, which decouples the 1:1 release model we have for templates and react-native. Switching users to this is going to be difficult, and should only be rolled asap before 0.76. If we have to release a template fix, then only users with the latest CLI will be able to use that and subsequent versions. I'm not sure of how to clearly communicate that to users.
@@ -4,9 +4,29 @@ exports[`shows up current config without unnecessary output 1`] = ` | |||
{ | |||
"root": "<<REPLACED_ROOT>>/TestProject", | |||
"reactNativePath": "<<REPLACED_ROOT>>/TestProject/node_modules/react-native", | |||
"reactNativeVersion": "0.74", | |||
"reactNativeVersion": "0.75", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After rebasing CI should be green.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙏 Thanks for also adding tests!
7eaeb5e
to
800ccc2
Compare
When we trigger a release of the template, we capture the version of react-native it's built with in the scripts.version field. This is accessible for all version of the template. We use this store from the CLI to figure out which template to install from when running `init`. Why? This means that we can effectively decouple our package version from the react-native package version. The 1:1 version mapping was done as a stop-gap in the 0.74 release, because of problems with release candiates and semver ordering. E.g. 0.75.0, 0.75.0-rc1, 0.75.0-rc2, etc... don't order sanely. What does this do? For example, if we discover a bug in the template for 0.75.0, previously we'd have to: - get react-native to run another release (very expensive), or - change the init logic (see 0.75.0-rc1.1 as an example). Now we just release another version of the template with the fix. As long as react-native@0.75.0 is still set as the version, the cli will pick the latest published version of the template with a matching version. See the commit for more details about exactly how version are picked. [0] https://github.com/react-native-community/template/blob/main/scripts/updateReactNativeVersion.js#L66-L93
800ccc2
to
096dfc2
Compare
This feature needs to be released with react-native-community/cli#2475, which decouples the 1:1 release model we have for templates and react-native. Switching users to this is going to be difficult, and should only be rolled asap before 0.76. If we have to release a template fix, then only users with the latest CLI will be able to use that and subsequent versions. I'm not sure of how to clearly communicate that to users. - Added tests - Set dry_run to default
…43) This feature needs to be released with react-native-community/cli#2475, which decouples the 1:1 release model we have for templates and react-native. Switching users to this is going to be difficult, and should only be rolled asap before 0.76. If we have to release a template fix, then only users with the latest CLI will be able to use that and subsequent versions. I'm not sure of how to clearly communicate that to users. - Added tests - Set dry_run to default
…43) This feature needs to be released with react-native-community/cli#2475, which decouples the 1:1 release model we have for templates and react-native. Switching users to this is going to be difficult, and should only be rolled asap before 0.76. If we have to release a template fix, then only users with the latest CLI will be able to use that and subsequent versions. I'm not sure of how to clearly communicate that to users. - Added tests - Set dry_run to default
Summary:
How?
When we trigger a release of the template, we capture the version of react-native it's built with in the
scripts.version
field. This is accessible for all version of the template:$ curl --silent https://registry.npmjs.org/@react-native-community%2ftemplate | jq '.versions[] | {scripts: .scripts,version: .version}'
and
$ curl --silent https://registry.npmjs.org/@react-native-community%2ftemplate | jq '.time'
We use this data from the CLI to figure out which template to install when running
npx @react-native-community/init
.Why?
This means that we decouple our package version from the react-native package version. The 1:1 version mapping was done as a stop-gap in the 0.74 release, because of problems with release candidates and semver ordering. E.g. 0.75.0, 0.75.0-rc1, 0.75.0-rc2, etc... don't order sanely.
What does this do?
For example, if we discover a bug in the template for
0.75.0
, previously we'd have to:0.75.0-rc1.1
as an example).Now we release another version of the template with the fix. As long as
react-native@0.75.0
is still set as the version, the cli will pick the latest published version of the template with a matching version.See the commit for more details about exactly how version are picked.
[0] https://github.com/react-native-community/template/blob/main/scripts/updateReactNativeVersion.js#L66-L93
Example
If you run
npx @react-native-community/cli init Foobar
where the latest version points to the React Native version on the bottom line. On:0.75.0
from template0.75.0
.0.75.1
from template0.75.1
but after publishing a new release of the template this will be from template0.75.2
. Similarly from (B) the version of the template bumps a PATCH for a patch release, but still pointing to react-native0.75.1
.Test Plan:
I've created further unit tests as well as pulling out the important template version selection code and creating unit tests for that, reflecting semantics only captured in comments.
Checklist