dwyl / mvp

📲 simplest version of the @dwyl app
https://mvp.fly.dev
GNU General Public License v2.0
87 stars 2 forks source link

Format templates (heex files) #183

Closed SimonLab closed 2 years ago

SimonLab commented 2 years ago

LiveView 0.18 provide a formatter plugin for the heex files: Phoenix.LiveView.HTMLFormatter

I think it requires Elixir 1.3 to be able to work and we need to update the .formatter file as described in the setup section

I'm also tempted to add mix format --check-formatted action on the Github actions to make sure PRs are formatted, this shouldn't be too annoying as I think most of editors have the option to format the code when a file is saved.

nelsonic commented 2 years ago

@SimonLab thanks for opening this. 👌 Reviewing your PR #184 now 👀

nelsonic commented 2 years ago

Merged. ✅ But I think it's worth having this as a step in one of our tutorials e.g: https://github.com/dwyl/phoenix-liveview-chat-example So that we can remind ourselves of what needs to be added in future projects. 💭

SimonLab commented 2 years ago

I'm not sure if the future new version of Phoenix will add the heex formatter automatically in the .formatter file. I'll open an issue on the liveview-chat-example to remind me to add the step in the Readme :+1:

nelsonic commented 2 years ago

Yeah, will make perfect sense for future Phoenix to include this out-of-the-box. 👌

SimonLab commented 2 years ago

Arf, the main branch failed and didn't deployed the last PR as: image

So the liveView formatter module is still not found, however it looks like the router file is not formatted, I'll have a look at what could be wrong. However If this step becomes annoying with the Github CI, I think we could remove it for now

SimonLab commented 2 years ago

running mix compile before mix format seems to be the solution to be able to use the Phoenix.LiveView.Formatter plugin. see https://github.com/elixir-lang/elixir/issues/11915#issuecomment-1233077725

This might be fixed with Elixir 1.4. Might be worth updating the version of Elixir used with Github CI

SimonLab commented 2 years ago

Updating the version of elixir to 1.14 seems to work for running mix format on Github CI. It will automatically run mix compile before running mix format

I'm looking now at updating the Dockerfile to make sure the application can be deployed on Fly using the correct version. We can see which versions to select for Elixir OTP and debian at https://hub.docker.com/r/hexpm/elixir/tags?page=1&name=slim image

I've seen a couple of posts already on the Fly community where people had issue deploying with Elixir 1.14: https://community.fly.io/t/no-love-with-first-deployment-attempt-of-phoenix-app/7358/2

Hopfully selected the correct Debian and elixir/OTP version on the Dockerfile should also work for us.

nelsonic commented 2 years ago

Thanks for looking into this @SimonLab 👌

SimonLab commented 2 years ago

Just to make sure the application has been deployed with the correct versions:

see IEx Shell Into Your Running App