ninelands-reddit/scripts/sync-engine.sh
Lukas Müllner bf6bdf9c2d feat(client): Startbildschirm, Spielansicht und Ergebniskarte mit dem Brett aus Ninelands
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 16:37:40 +01:00

43 lines
2.2 KiB
Bash
Executable file
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
# Holt die Engine (src/core + die JSONs, die sie importiert, dazu die Brett-Darstellung src/app/board + env.ts) von einem festen Ninelands-Tag nach src/engine/,
# dazu Sprites (Tiles, Brett-Themen) und ausgewählte Musik nach public/.
# Die Kopie wird nie von Hand geändert – Änderungen gehören ins Hauptspiel, dann hier neu synchronisieren.
# Aufruf: scripts/sync-engine.sh <tag> [pfad-zum-hivedoku-repo]
set -euo pipefail
tag="${1:?Tag angeben, z. B. v0.11.0}"
repo="${2:-${HIVEDOKU_REPO:-/data/Documents/projects/hivedoku}}"
ziel="$(cd "$(dirname "$0")/.." && pwd)/src/engine"
# Nur lesen: git archive verändert das Hauptspiel-Repo nicht
commit="$(git -C "$repo" rev-parse --verify "$tag^{commit}")"
tmp="$(mktemp -d)"
trap 'rm -rf "$tmp"' EXIT
# Musik: wenige Titel, als MP3 mit 64 kbit/s (läuft überall, auch in iOS-Webviews; ≈ 1 MB je Titel).
# Quelle ist die Opus-Datei des Hauptspiels (bessere Vorlage als dessen 96-kbit/s-MP3); braucht ffmpeg.
musik=(peaceful-village)
musik_pfade=()
for titel in "${musik[@]}"; do musik_pfade+=("public/audio/music/$titel.webm"); done
git -C "$repo" archive "$commit" src/core src/campaign src/puzzles src/app/env.ts src/app/board/BoardView.ts \
src/app/board/atlas.ts src/app/board/geometry.ts src/app/board/board.css public/sprites/tiles public/sprites/themes \
"${musik_pfade[@]}" | tar -x -C "$tmp"
# Alte Kopie ersetzen, eigene Dateien (tsconfig.json, README.md) behalten
rm -rf "$ziel/core" "$ziel/campaign" "$ziel/puzzles" "$ziel/app"
mkdir -p "$ziel"
cp -r "$tmp/src/core" "$tmp/src/campaign" "$tmp/src/puzzles" "$tmp/src/app" "$ziel/"
find "$ziel" -name '*.test.ts' -delete
# Assets (Nachweise in CREDITS.md)
public="$(dirname "$ziel")/../public"
rm -rf "$public/sprites" "$public/audio"
mkdir -p "$public/sprites" "$public/audio"
cp -r "$tmp/public/sprites/tiles" "$tmp/public/sprites/themes" "$public/sprites/"
mkdir -p "$public/audio/music"
for titel in "${musik[@]}"; do
ffmpeg -v error -y -i "$tmp/public/audio/music/$titel.webm" -map_metadata -1 -c:a libmp3lame -b:a 64k -ar 44100 \
"$public/audio/music/$titel.mp3"
done
printf 'tag: %s\ncommit: %s\n' "$tag" "$commit" > "$ziel/VERSION"
echo "Engine synchronisiert: $tag ($commit)"