.justfile
Recently I started using just to improve and simplify the organization and execution of various scripts in my projects. There is the official Just Programmer's Manual available online, which you may want to check out.
When building client-server applications (e.g. SPAs), I usually have a project structure like this:
root/
|- .env
|- .env.template
|- docker-compose.base.yml
|- docker-compose.dev.yml
|- docker-compose.prod.yml
|- docker-compose.ci.yml
|- ...
|- frontend/
|- package.json
...
|- backend/
|- pyproject.toml
...
And then I could run script like:
However, when projects grew, so did the number of available scripts but not the amount of documentation of said scripts. At work I often introduce and onboard new developers and having multiple scripts and different locations doesn't make this easier. Additionally, in our work environment we have both Windows and Linux machines, which leads to further cluttering.
Example
)
)
#!/usr/bin/env bash
if ; then
else
VENV_PATH=/virtualenvs/berichtstool/.venv
fi
)
)
# [private] hides this recipe from the `just --list` output.
# This is our helper for running commands within the venv.
)
&& && }}
)
#!/usr/bin/env bash
# Using a shebang ensures all lines run in the same shell,
# so the `source` command affects the subsequent lines.
# This incorporates your specific logic for native Linux vs. WSL
if ; then
else
fi
# Finally, execute the command that was passed as an argument
}}
)
)
)
)
)
)
)
)
)
)