ash-project / igniter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Check source for application module in `Igniter.Application.add_new_child/2`

zachdaniel opened this issue · comments

At the moment, we check the existing application, but this could be out of date due to some existing patch.

Here is where we check it:

    to_perform =
      case project.application()[:mod] do
        nil -> {:create_an_app, Igniter.Code.Module.module_name("Application")}
        {mod, _} -> {:modify, mod}
        mod -> {:modify, mod}
      end

This should pull from the source.

Does this mean, we should be able to check if our Mix.Project defines a custom application on the mix file by reading the mix file directly?

Yes, exactly.

The source code must always be the source of truth, whereas this is using the compiled code which will cause bugs down the line.

Can I pick this up @zachdaniel ?
I am currently thinking of using the AST from rewrite to check if inside our application function the config for mod is defined then return it otherwise return nil. I have no idea how to do this or if it is a good idea to in the first place.

What do you think?

Yes please, that would be excellent 🙇

I've assigned it to you. Take a look at some of the other functions in igniter to see how to traverse source code, and LMK if you hit any roadblocks.

Awesome, are there any hard timelines on this?

Nope :) but ideally in the next few weeks it would be done 👍