58 lines
1.7 KiB
Bash
Executable File
58 lines
1.7 KiB
Bash
Executable File
#!/usr/bin/env sh
|
|
set -eu
|
|
|
|
repo_dir=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
|
|
cd "$repo_dir"
|
|
|
|
if ! command -v uv >/dev/null 2>&1; then
|
|
echo "uv is required: https://docs.astral.sh/uv/" >&2
|
|
exit 1
|
|
fi
|
|
|
|
uv sync --frozen
|
|
uv run python tools/build.py "$@"
|
|
|
|
output_dir=build
|
|
expect_output_dir=0
|
|
list_themes=0
|
|
check=0
|
|
for argument in "$@"; do
|
|
if [ "$expect_output_dir" -eq 1 ]; then
|
|
output_dir=$argument
|
|
expect_output_dir=0
|
|
continue
|
|
fi
|
|
case "$argument" in
|
|
--output-dir) expect_output_dir=1 ;;
|
|
--output-dir=*) output_dir=${argument#--output-dir=} ;;
|
|
--list-themes) list_themes=1 ;;
|
|
--check) check=1 ;;
|
|
esac
|
|
done
|
|
|
|
[ "$list_themes" -eq 1 ] && exit 0
|
|
|
|
example="$output_dir/example-character.json"
|
|
craft_forge="$output_dir/example-craft-forge.json"
|
|
craft_alchemy="$output_dir/example-craft-alchemy.json"
|
|
if [ "$check" -eq 1 ]; then
|
|
temporary_dir=$(mktemp -d)
|
|
trap 'rm -rf "$temporary_dir"' EXIT HUP INT TERM
|
|
uv run python tools/generate_character.py --seed 20260919 --output "$temporary_dir/example-character.json" >/dev/null
|
|
uv run python tools/generate_crafts.py --output-dir "$temporary_dir" >/dev/null
|
|
if ! cmp -s "$temporary_dir/example-character.json" "$example"; then
|
|
echo "$example is missing or differs from the seeded character fixture" >&2
|
|
exit 1
|
|
fi
|
|
for craft in "$craft_forge" "$craft_alchemy"; do
|
|
name=${craft##*/}
|
|
if ! cmp -s "$temporary_dir/$name" "$craft"; then
|
|
echo "$craft is missing or differs from the generated craft fixture" >&2
|
|
exit 1
|
|
fi
|
|
done
|
|
else
|
|
uv run python tools/generate_character.py --seed 20260919 --output "$example"
|
|
uv run python tools/generate_crafts.py --output-dir "$output_dir"
|
|
fi
|