#!/usr/bin/env sh
# me-foundations-shadcn — pre-commit hook
# Instale: copie para .git/hooks/pre-commit (chmod +x) OU use husky/lefthook chamando este script.
# Bloqueia commit com valor fora dos foundations nos arquivos staged.
set -e

STAGED=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.(tsx|jsx|ts|js|mjs|cjs|css|scss|sass|less|html|astro|svelte|mdx)$' || true)
[ -z "$STAGED" ] && exit 0

# ajuste o caminho se o plugin estiver noutro lugar
LINT="${ME_SHADCN_LINT:-node_modules/.bin/../../scripts/shadcn-foundations-lint.mjs}"
[ -f "$LINT" ] || LINT="$(dirname "$0")/../ci/shadcn-foundations-lint.mjs"

node "$LINT" $STAGED
