Open indigoviolet opened 1 year ago
The most straightforward way to do this is probably to just add a new recipe that recursively invokes just
with the other recipes you need, in the order they should be invoked in. e.g. something like:
install_dependency_a:
...
install_dependency_b:
...
bootstrap:
@just install_dependency_b
@just install_dependency_a
This requires a bit of manual setup, but it means you can be explicit about what recipes you run, while still having the freedom to add additional recipes to the justfile
that won't interfere with the bootstrap process.
I also encountered this. I am building a plugin integrating just
into neovim, and the fact that the order of recipes is not preserved with --dump-format=json
forces me to manually parse just --unsorted --summary
.
It's a bit of a challenge to preserve recipe order in --dump
. Also, sometimes JSON libraries make it hard to preserve the order of maps.
One idea is making just --unsorted --summary
respect --dump-format=json
, and return a JSON list of recipes. You'd still have to make a second call to just
, but you would get JSON back, instead of manually parsing.
Recipes in --dump-format=json
would actually be lists of lists, because each recipe might be a path to a recipe in a submodule.
@chrisgrieser What do you think?
It's a bit of a challenge to preserve recipe order in --dump. Also, sometimes JSON libraries make it hard to preserve the order of maps.
What about simply adding a key order
to the json? That way we can just sort the recipes by it to get the original recipe order.
I am not sure I follow what you mean in the second and third paragraph. Wouldn't having --summary
super json output simply replicate the same problem?
What about simply adding a key order to the json? That way we can just sort the recipes by it to get the original recipe order.
just
uses Serde
for serialization, so the serialization code is automatically derived, not hand written, so it's hard to add additional fields which aren't present on the struct.
Also, there isn't actually a single key which gives the order. It's determined by a weird combination of recipe.import_offsets
and recipe.name.offset
, which bases order both on the order in which the files were imported, and the order of the recipe in those imported source file. This is the sort which puts them in justfile
order:
recipes.sort_by_key(|recipe| (&recipe.import_offsets, recipe.name.offset));
So there isn't a pre-existing order
field that we can serialize.
I am not sure I follow what you mean in the second and third paragraph. Wouldn't having --summary super json output simply replicate the same problem?
It depends on what the problem is. It doesn't fix having to call just
twice, but it does fix having to manually parse the output of --summary
, if it returns JSON and you already have a JSON parser.
I was hoping to write something that ran the recipes in a justfile in order (lots of individual set up steps to bootstrap a new machine). I can use
just --summary --unsorted
, but it would be cleaner to usejust --dump --dump-format=json
and sort by some recipe order info.