-
Notifications
You must be signed in to change notification settings - Fork 928
feat: add platform-name option to init for out of tree platforms init #2170
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: add platform-name option to init for out of tree platforms init #2170
Conversation
6e656a6
to
d40c8f6
Compare
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.
LGTM
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.
Ok, let's do it. This is explicit enough and doesn't require us to make any assumptions about the platform name based on binary name or some node module resolution.
One extra thing I would love to see would be to extend the #### Initializing project with custom template
section of docs/init.md
with an example or instruction on what to do if you're an OOT platform
Thinking about it in the context of your example, if we ported this small diff to the core, we wouldn't need to document it anywhere outside of the code comments |
@thymikee, @szymonrybczak, @TMisiukiewicz Thanks for review! I've updated the command description and added tests. Let's keep this as an undocumented flag - I will create PR to core after this will be released 👍🏻 That way normal users won't need to pass it |
{ | ||
name: '--platform-name <string>', | ||
description: | ||
'Name of out of tree platform to be used for ex. react-native-macos. This flag is optional as it should be passed automatically by out of tree platform. It needs to match the name of the platform declared in package.json', |
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.
FYI @Saadnajmi
Note that macOS and Windows both have separate init packages right now (with the windows one in particular growing quite complicated). I worry naming react-native-macOS here might be jumping ahead a bit, until that init flow has changed (unless it already has).
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.
The init flow stays the same. While working on a new platform (visionos) we want to make things right and easy for any other platform to follow. Today this particular flag is quite virtual, as it's passed from the programmatic CLI usage in core. It's still in flux and once we're more firm on the design, we'll likely contribute some PoC to macOS and hopefully Windows too.
Summary:
This PR adds
platform-name
option to allow for out of tree platforms to leverageinit
command without (almost) any changes in their repo.Problem
When initializing project (for OOT platform) with command similar to this:
@callstack/react-native-visionos init MyApp
current approach would be to pass--template
option to specify custom template for this platform. However this requires to maintain separate template (as RN-TvOS is doing: https://www.npmjs.com/package/react-native-template-typescript-tv).Also CLI has a hardcoded path to retrieve template URI (in
createTemplateUri
).Solution
Allow OOT platforms to pass it's name to
cli.run()
function call which doesn't require to pass any extra flags by user.Inside of
[OutOfTreePlatform]/packages/react-native/cli.js
we pass out of tree platform name from the package.jsonAs an extension of this we could later on detect if we are inside of a project and if so just add new platform to this project (instead of initializing new one)
Test Plan:
Checklist