From ad50bd21ead861752f6d0a7e4d5f60e7cca2a543 Mon Sep 17 00:00:00 2001 From: Admin Date: Sat, 4 Apr 2026 12:11:42 +0500 Subject: [PATCH] chore: add .githooks/pre-commit to auto-recompile paraglide on JSON changes Committed hooks directory (.githooks/pre-commit) auto-runs `npm run paraglide` and force-stages the generated JS output whenever ui/messages/*.json files are staged, preventing svelte-check CI failures from stale paraglide output. Added `just setup` recipe to configure core.hooksPath for new contributors. --- .githooks/pre-commit | 14 ++++++++++++++ justfile | 7 +++++++ 2 files changed, 21 insertions(+) create mode 100755 .githooks/pre-commit diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100755 index 0000000..2432eda --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +# Auto-recompile paraglide messages when ui/messages/*.json files are staged. +# Prevents svelte-check / CI failures caused by stale generated JS files. + +set -euo pipefail + +STAGED=$(git diff --cached --name-only) + +if echo "$STAGED" | grep -q '^ui/messages/'; then + echo "[pre-commit] ui/messages/*.json changed — recompiling paraglide..." + (cd ui && npm run paraglide --silent) + git add -f ui/src/lib/paraglide/messages/ + echo "[pre-commit] paraglide output re-staged." +fi diff --git a/justfile b/justfile index aa57f1f..4f0e62a 100644 --- a/justfile +++ b/justfile @@ -122,6 +122,13 @@ secrets-env: secrets-dashboard: doppler open dashboard +# ── Developer setup ─────────────────────────────────────────────────────────── + +# One-time dev setup: configure git to use committed hooks in .githooks/ +setup: + git config core.hooksPath .githooks + @echo "Git hooks configured (.githooks/pre-commit active)." + # ── Gitea CI ────────────────────────────────────────────────────────────────── # Validate workflow files