bonfire-networks / mess

Simple, file-based dependency management with git and local overrides.
4 stars 0 forks source link

Avoid the need to commit mess in every repository where it is needed #2

Open fishinthecalculator opened 1 week ago

fishinthecalculator commented 1 week ago

Currently mess is heavily used in Bonfire, almost all extension in my experience use it. I think it would be useful to at least evaluate whether it is possible to ship it through mix itself as a mix task. Ideally Mix would have some way to load its plugins before processing the mix.exs, until that is a reality the only way I see this as feasible is to serialize Mess.deps output (which is what extension appear to call in their mix.exs, probably this is not the case for the umbrella app but I would consider that problem later if there is consensus) to a separate file.

My proposal would be: serialize (somehow, more on this later) Mess.deps output, read it back in the mix.exs, pass the result of deserialization to Mix dependency facilities. The build process would go something like:

mix mess # mess.lock or similar is created
mix deps.get # mess.lock is loaded
mix compile # mess.lock is loaded

Now the question becomes: how to best serialize Mess.deps output to a file. The format should be so simple that can be deserialized with plain Elixir and it should require as little code as possible to be converted to something acceptable by Mix, to minimize the code that would have to be copypasted on all mix.exs to be able to load mess.lock.

I'm not really sure of this but the two formats I came up with are:

What do you think? Do you see any other way to solve bootstrapping for mess?

mayel commented 1 week ago

To be quite honest I don't really see the need/value in spending time/energy on this. The script after all is only 49 LOC and hasn't had the need to change in years, since it's a very simple and well defined task (reading text files and parsing a simple syntax, and returning an elixir data structure). I also don't see it as feasible to implement as described due to how mix works, though it'd probably be possible if you ran deps.get first to fetch mess, then ran a special mess command (which would have to edit mix.exs to load a mess script in a similar way it does now, though it could probably load it from the deps directory instead), then you'd have to run deps.get again to actually fetch the ones defined using mess. IMO that adds complexity and also takes us off the beaten bath even more without giving much back (especially since we can easily use other approaches to update the mess script if needed, such as the script I suggested in the other issue, triggered through a just command). Which reminds me we kinda have the same issue with copying a justfile into every repo as well (which is actually likely to need updating more often), so better a solution that works for both, no?

mayel commented 1 week ago

Edit: and in terms of DX, most extensions would be created using a generator or by forking an existing one, so there isn't much copy pasting to do in any case: https://docs.bonfirenetworks.org/create-a-new-extension.html

mayel commented 1 week ago

This is the template extension that the generator uses: https://github.com/bonfire-networks/bonfire_extension_template