feat(astro): add justfile

This commit is contained in:
Oliver Davies 2023-09-24 23:13:43 +01:00
parent bfee1e8029
commit 88b92924fb
2 changed files with 63 additions and 0 deletions

View file

@ -31,6 +31,7 @@ final class CreateListOfFilesToGenerate
new TemplateFile(data: 'astro/.envrc', name: '.envrc'),
new TemplateFile(data: 'astro/.gitignore', name: '.gitignore'),
new TemplateFile(data: 'astro/flake.nix', name: 'flake.nix'),
new TemplateFile(data: 'astro/justfile', name: 'justfile'),
new TemplateFile(data: 'astro/tsconfig.json', name: 'tsconfig.json'),
]);
break;

View file

@ -0,0 +1,62 @@
# {{ managedText|raw }}
{% set isFlake = flake is defined %}
default:
@just --list
{% if not isFlake %}
# Start the project
start:
cp -v --no-clobber .env.example .env
docker compose up -d
# Stop the project
stop:
docker compose down
{% endif %}
yarn *args:
{% if isFlake %}
{{ "just _exec yarn {{ args }}" | raw }}
{% else %}
{{ "just _exec node yarn {{ args }}" | raw }}
{% endif %}
# Enable or disable Git hooks
git-hooks command:
#!/usr/bin/env bash
set -euo pipefail
case "{{ '{{ command }}'|raw }}" in
"on")
echo "Enabling Git hooks..."
git config core.hooksPath .githooks
;;
"off")
echo "Disabling Git hooks..."
git config --unset core.hooksPath
;;
*)
echo "Error: Invalid argument. Must be either 'on' or 'off'"
;;
esac
_exec +args:
{% if flake is defined %}
{{ "nix develop --command {{ args }}" | raw }}
{% else %}
{{ "docker compose exec -T {{ args }}" | raw }}
{% endif %}
{% if flake is not defined %}
_run service command *args:
docker compose run \
--entrypoint {{ "{{ command }}"|raw }} \
--no-deps \
--rm \
-T \
{{ "{{ service }} {{ args }}"|raw }}
{% endif %}
# vim: ft=just