cli
cli copied to clipboard
feat: add `add-platform` command
Summary:
In this Pull Request I've added new command add-platform
which re-uses code from init
command to add a new OOT platform to existing React Native app. It gets React Native version from package.json
and it tries to find a matching platform's version from NPM registry. Then, if successful it reuses editTemplate
functions to replace placeholders.
https://github.com/react-native-community/cli/assets/63900941/6529cf35-f27a-4373-b843-1dc4bf66b4c7
For OOT platforms to add a compatibility with the new command:
- Add
platforms
insidetemplate.config.js
, which is an array in which OOT platform should provide names of folders containing native code. e.g.platforms: ["macos"]
- Add
postInitScript
(also undertemplate.config.js
) with e.g. installing Pods and printing run instructions. - Add platform's specific native code under
packages/react-native/template${platformName}
.
Checklist
- [x] Documentation is up to date to reflect these changes.
- [x] Follows commit message convention described in CONTRIBUTING.md