rogerluan / arkana

Use dotenv files for Android and iOS projects.
BSD 2-Clause "Simplified" License
362 stars 18 forks source link

Add support to Android using Kotlin code generation #53

Closed husseinala closed 7 months ago

husseinala commented 7 months ago

Resolves #1

Description

Where I work, we've been using Arkana on our iOS projects and we're big fans of the project, so would like to adopt it for our Android projects too, which is why we thought it would be helpful to kick off the process of adding Kotlin support.

This PR adds a KotlinCodeGenerator and modifies the execution entry point to determine which generator to run based on the specified --lang argument flag.

The following changes have also been made:

Arkana Arguments

Arkana YAML config

Generated module structure

Screenshot 2023-12-05 at 11 14 59

Generated sources

{namespace}Environment.kt

Contains interface declaration for the environment-specific keys.

Screenshot 2023-12-05 at 11 17 53

{namespace}.kt

Contains the Keys object:

Screenshot 2023-12-05 at 11 19 58
rogerluan commented 7 months ago

Thank you soooo much for this PR, @husseinala !

I'm very excited to review it, test it and provide feedback! I'll only be able to take a look at this by the end of the week though, probably over the weekend!

I know there are many people interested in this, so I'll tag them here so they can follow the evolution of this new feature/PR as it happens and can also provide valuable feedback and maybe even help us test a bit in diverse projects/work environments 😊

@JARMourato @humblerookie @Shafichariri @houmie @mrea1 @yuukiw00w @AF-cgi @mrea1 @marceltex 🙇

Thanks a lot again @husseinala, and congrats on your first contribution here! ❤️

PS: Great PR description, thanks for the thorough explanation! 🤩

husseinala commented 7 months ago

Thank you @rogerluan! Looking forward to the feedback from everyone 😊

husseinala commented 7 months ago

Note

Partial review for now!

I left some minor comments so far, as I haven't reviewed the core logic of the PR. Some things I noticed (also piggy backing on some of the comments that were already left above by other reviewers):

  1. We should be updating the README as well to reflect all the changes (e.g. remove the "coming soon" section, adding proper usage documentation for the new kotlin features, perhaps add some more instructions on how to adequate your project for kotlin generation, etc).
  2. Kotlin unit tests are super valuable as they guarantee the actual encoding/decoding is working as expected, and that it doesn't regress in the future :) could you add those?
  3. Do the generated kotlin files pass a standard kotlin linter out-of-the-box? One with a "widely adopted" style guide 😇
  4. Last but not least, could you also implement an e2e test to be run in CI via Rakefile, like we're doing with Swift? These references will be helpful:

Looking forward to continue reviewing this PR when I have some extra time! It's looking promising! 🙌

Thanks @JARMourato, @marceltex & @rogerluan for taking the time to go through the PR 🙏🏼 , will work on addressing all the raised issues and push all the necessary changes, including making sure all the generated code passes Kotlin's official codeing conventions

watermelon-copilot-for-code-review[bot] commented 7 months ago

Watermelon AI Summary

AI Summary deactivated by husseinala

GitHub PRs

husseinala commented 7 months ago

Hi @rogerluan, sorry for the delay, I've been a bit busy the last two weeks, but I finally got around to making the requested changes which address the following points:

  1. The readme has been updated to include information about Android/Kotlin support.
  2. Updated the Kotlin code generator to generate Kotlin unit tests when should_generate_gradle_build_file is set to true.
  3. Updated the Rakefile to include a test_kotlin task. This required the addition of a couple of support files which I included inside spec/fixtures/kotlin to be able to run the Kotlin tests outside a normal Android project.
  4. Updated the Kotlin code template to ensure the generated code is in line with the official JetBrains Kotlin code style.
rogerluan commented 7 months ago

I made some changes to the Kotlin erb templates to adjust the code style/formatting, more specifically the line breaks 😊 I think they look better this way. Here's a visual diff of the changes if you're curious:

Click here to expand

image image image image

husseinala commented 7 months ago

Yaay 🎉 thank you for taking the time to review and clean up the PR @rogerluan. Really glad I was able to contribute to this project! ❤️