cli icon indicating copy to clipboard operation
cli copied to clipboard

feat: add `link-assets` command

Open fabioh8010 opened this issue 1 year ago • 11 comments

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:

  1. Original issue in Expensify repo
  2. CK proposal to implement the new feature in react-native-asset library
  3. PR with the new feature
  4. Issue about lack of maintenance and offer to help
  5. Decision to create a separate package under CK org, and proposal to move the feature to CLI
  6. 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

fabioh8010 avatar Jan 23 '24 22:01 fabioh8010

Started code review and left some comments, gonna continue reviewing tomorrow :)

TMisiukiewicz avatar Jan 25 '24 09:01 TMisiukiewicz

Just updated the code to handle Kotlin templates, tested it with freshly built app on 0.73 and seems to work well!

image

TMisiukiewicz avatar Feb 02 '24 12:02 TMisiukiewicz

Awesome! @TMisiukiewicz @fabioh8010 is it now ready for getting out of the draft state?

thymikee avatar Feb 19 '24 14:02 thymikee

@thymikee I will push one more last test today, add documentation and that should be good for opening to review!

fabioh8010 avatar Feb 20 '24 12:02 fabioh8010

Cool, take your time :)

thymikee avatar Feb 20 '24 14:02 thymikee

did another round of review and tested it on both platforms, looks solid! 👍 some small conflicts need to be resolved before opening

TMisiukiewicz avatar Feb 21 '24 08:02 TMisiukiewicz

@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.

fabioh8010 avatar Feb 21 '24 11:02 fabioh8010

@TMisiukiewicz @thymikee I've addressed the review comments, simplified some tests, refactored code and improved logic to handle android resource file names

fabioh8010 avatar Feb 26 '24 19:02 fabioh8010

@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?

TMisiukiewicz avatar Feb 29 '24 13:02 TMisiukiewicz

Thanks @TMisiukiewicz I will make these adjustments!

fabioh8010 avatar Mar 01 '24 11:03 fabioh8010

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.

thymikee avatar Mar 18 '24 09:03 thymikee

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 avatar Mar 25 '24 13:03 thymikee

@thymikee Could you run the E2E workflow tests again? Thanks!

fabioh8010 avatar Mar 27 '24 19:03 fabioh8010

why do I need to approve the pipeline twice, geez GitHub cmon

thymikee avatar Mar 28 '24 11:03 thymikee

The CI passed 🎉

thymikee avatar Mar 29 '24 13:03 thymikee