mirror of
https://github.com/opdavies/build-configs.git
synced 2025-09-06 03:15:34 +01:00
chore(run): replace justfiles with run files
This commit is contained in:
parent
3a86b4813a
commit
f5a8c691f0
11 changed files with 386 additions and 263 deletions
|
@ -1,82 +0,0 @@
|
|||
# {{ managedText | raw }}
|
||||
|
||||
{% set isFlake = flake is defined %}
|
||||
|
||||
default:
|
||||
@just --list
|
||||
|
||||
# Start the project
|
||||
start:
|
||||
{% if not isFlake %}
|
||||
cp -v --no-clobber .env.example .env
|
||||
docker compose up -d
|
||||
{% else %}
|
||||
yarn dev
|
||||
{% endif %}
|
||||
|
||||
{% if not isFlake %}
|
||||
# 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 %}
|
||||
|
||||
fractal *args:
|
||||
{{ "just yarn fractal {{ args }}" | raw }}
|
||||
|
||||
clean:
|
||||
rm -fr build
|
||||
|
||||
build *args:
|
||||
{{ "just fractal build {{ args }}" | raw }}
|
||||
|
||||
sync: clean build
|
||||
#!/usr/bin/env bash
|
||||
set -eux
|
||||
aws s3 sync "build/." s3://"${BUCKET_NAME}" \
|
||||
--acl "public-read" \
|
||||
--cache-control max-age=3600
|
||||
|
||||
# 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 isFlake %}
|
||||
{{ "nix develop --command {{ args }}" | raw }}
|
||||
{% else %}
|
||||
{{ "docker compose exec -T {{ args }}" | raw }}
|
||||
{% endif %}
|
||||
|
||||
{% if not isFlake %}
|
||||
_run service command *args:
|
||||
docker compose run \
|
||||
--entrypoint {{ "{{ command }}"|raw }} \
|
||||
--no-deps \
|
||||
--rm \
|
||||
-T \
|
||||
{{ "{{ service }} {{ args }}"|raw }}
|
||||
{% endif %}
|
||||
|
||||
# vim: ft=just
|
113
templates/fractal/run.twig
Executable file
113
templates/fractal/run.twig
Executable file
|
@ -0,0 +1,113 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# {{ managedText | raw }}
|
||||
|
||||
set -eu
|
||||
|
||||
{% set isFlake = flake is defined %}
|
||||
|
||||
PATH="$PATH:./node_modules/.bin"
|
||||
|
||||
{% if not isFlake %}
|
||||
# If we're running in CI we need to disable TTY allocation for docker compose
|
||||
# commands that enable it by default, such as exec and run.
|
||||
TTY="${TTY:-}"
|
||||
if [[ ! -t 1 ]]; then
|
||||
TTY="-T"
|
||||
fi
|
||||
{% endif %}
|
||||
|
||||
# Remove and generated or temporary files.
|
||||
function build {
|
||||
fractal build "${@}"
|
||||
}
|
||||
|
||||
function ci:build {
|
||||
build
|
||||
}
|
||||
|
||||
# Remove and generated or temporary files.
|
||||
function clean {
|
||||
rm -fr build node_modules
|
||||
touch build/.keep
|
||||
}
|
||||
|
||||
# Disable Git hooks.
|
||||
function git-hooks:off {
|
||||
git config --unset core.hooksPath
|
||||
}
|
||||
|
||||
# Enable Git hooks.
|
||||
function git-hooks:on {
|
||||
git config core.hooksPath .githooks
|
||||
}
|
||||
|
||||
# Create a new Fractal component.
|
||||
function fractal:new {
|
||||
mkdir -p "components/${1}"
|
||||
|
||||
echo "name: ${1}" > "components/${1}/${1}.config.yml"
|
||||
echo "${1}" > "components/${1}/${1}.twig"
|
||||
}
|
||||
|
||||
# Display a list of all available commands.
|
||||
function help {
|
||||
printf "%s <task> [args]\n\nTasks:\n" "${0}"
|
||||
|
||||
compgen -A function | grep -v "^_" | cat -n
|
||||
|
||||
printf "\nExtended help:\n Each task has comments for general usage\n"
|
||||
}
|
||||
|
||||
# Start the project.
|
||||
function start {
|
||||
{% if not isFlake %}
|
||||
cp -v --no-clobber .env.example .env
|
||||
docker compose up -d
|
||||
{% else %}
|
||||
fractal start --sync
|
||||
{% endif %}
|
||||
}
|
||||
|
||||
function sync {
|
||||
clean
|
||||
fractal build
|
||||
|
||||
aws s3 sync "build/." s3://"${BUCKET_NAME}" \
|
||||
--acl "public-read" \
|
||||
--cache-control max-age=3600
|
||||
}
|
||||
|
||||
{% if not isFlake %}
|
||||
# Run a command within the node container.
|
||||
function cmd {
|
||||
docker compose exec node yarn "${@}"
|
||||
}
|
||||
|
||||
# Stop the project
|
||||
function stop {
|
||||
docker compose down
|
||||
}
|
||||
|
||||
# Execute yarn commands.
|
||||
function yarn {
|
||||
cmd node yarn "${@}"
|
||||
}
|
||||
|
||||
function _run {
|
||||
local service="${1}"
|
||||
local command="${2}"
|
||||
|
||||
docker compose run \
|
||||
--entrypoint "${command}" \
|
||||
--no-deps \
|
||||
--rm \
|
||||
-T \
|
||||
"${service}" "${@}"
|
||||
}
|
||||
{% endif %}
|
||||
|
||||
TIMEFORMAT=$'\nTask completed in %3lR'
|
||||
time "${@:-help}"
|
||||
|
||||
# vim: ft=bash
|
Loading…
Add table
Add a link
Reference in a new issue