feat: add `link-assets` command
Summary:
This PR aims to implement a feature to help users link their assets in their projects in an automated and efficient way. This PR will basically bring functionality from react-native-asset package + this new feature to link Android assets using XML Fonts. Due to the lack of maintenance in the original repo, we've published a new version under CK organisation here, but after some discussions we decided to bring the feature to the CLI.
Relevant links/discussions in chronological order:
- Original issue in Expensify repo
- CK proposal to implement the new feature in react-native-asset library
- PR with the new feature
- Issue about lack of maintenance and offer to help
- Decision to create a separate package under CK org, and proposal to move the feature to CLI
- Approval to move the feature to CLI
Tasks
- [x] Implementation of initial integration and commands
- [x] Migration and refactoring of original codebase to TypeScript
- [x] Support to handle Kotlin files
- [x] Unit tests
- [x] Final documentation
Test Plan:
TODO
Checklist
- [x] Documentation is up to date to reflect these changes.
- [x] Follows commit message convention described in CONTRIBUTING.md
Started code review and left some comments, gonna continue reviewing tomorrow :)
Just updated the code to handle Kotlin templates, tested it with freshly built app on 0.73 and seems to work well!
Awesome! @TMisiukiewicz @fabioh8010 is it now ready for getting out of the draft state?
@thymikee I will push one more last test today, add documentation and that should be good for opening to review!
Cool, take your time :)
did another round of review and tested it on both platforms, looks solid! 👍 some small conflicts need to be resolved before opening
@thymikee @TMisiukiewicz I've added the final test and documentation. There are still some improvements in the tests @TMisiukiewicz suggested and I will do, but we are good enough here open the PR while I do the improvements.
@TMisiukiewicz @thymikee I've addressed the review comments, simplified some tests, refactored code and improved logic to handle android resource file names
@fabioh8010 when running link-assets without any linked assets and not having assets property in react-native.config.js file, there is no output from a command. Can we display a short instruction what to do to in order to use this command in this case?
Thanks @TMisiukiewicz I will make these adjustments!
Ok I got a look at this PR and I have doubts exposing it to users. This commands works in a legacy way of manually changing Xcode and Gradle files – even asking users to do so. I hoped it would leverage the autolinking mechanism so that DX is nicer.
Please take a look at how rnx-kit team achieves that: https://github.com/microsoft/react-native-test-app/pull/1828 in less than 200 lines of code.
If the time is pressure, I'm ok with merging that into the repository, but I'm not ok exposing this command to every user. It will add a lot of size to the package that's already pretty big. Therefore I'd suggest to document how one could use this package (npx @react-native-community/cli-link-assets instead of npx react-native link-assets) and iterate on a better solution that's aligned with autolinking and doesn't require developers to fiddle with native files.
Waiting for CI to be green and gonna merge it. Thanks so much for porting this code @fabioh8010, it's a great amount of effort to keep this library afloat and should be a good ground to iterate for a better, autolink-enabled solution in the future 👍🏼
@thymikee Could you run the E2E workflow tests again? Thanks!
why do I need to approve the pipeline twice, geez GitHub cmon
The CI passed 🎉