49 lines
1.2 KiB
Bash
Executable file
49 lines
1.2 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# check-linhas.sh
|
|
# Garante que nenhum arquivo *.vue, *.ts ou *.tsx ultrapasse o limite de linhas definido.
|
|
# Executado automaticamente no prebuild via package.json.
|
|
|
|
set -euo pipefail
|
|
|
|
LIMITE=250
|
|
|
|
# Arquivos isentos permanentes (gerados, dados de teste, etc.)
|
|
# Formato: caminho relativo a partir da raiz do projeto
|
|
ISENTOS=(
|
|
|
|
)
|
|
|
|
RAIZ="$(cd "$(dirname "$0")/.." && pwd)"
|
|
ERROS=0
|
|
|
|
while IFS= read -r arquivo; do
|
|
relativo="${arquivo#$RAIZ/}"
|
|
|
|
# Verifica se está na lista de isentos
|
|
isento=false
|
|
for i in "${ISENTOS[@]}"; do
|
|
if [ "$relativo" = "$i" ]; then
|
|
isento=true
|
|
break
|
|
fi
|
|
done
|
|
|
|
if $isento; then
|
|
continue
|
|
fi
|
|
|
|
linhas=$(wc -l < "$arquivo")
|
|
if [ "$linhas" -gt "$LIMITE" ]; then
|
|
echo "❌ $relativo ($linhas linhas) — limite: $LIMITE"
|
|
ERROS=$((ERROS + 1))
|
|
fi
|
|
done < <(find "$RAIZ/src" \( -name "*.vue" -o -name "*.ts" -o -name "*.tsx" \) -not -path "*/node_modules/*")
|
|
|
|
if [ "$ERROS" -gt 0 ]; then
|
|
echo ""
|
|
echo "⚠️ $ERROS arquivo(s) ultrapassam o limite de $LIMITE linhas."
|
|
echo " Estratégias: subcomponentes, composables use*.ts, ou separar CSS."
|
|
exit 1
|
|
fi
|
|
|
|
echo "✅ Todos os arquivos (*.vue, *.ts, *.tsx) estão dentro do limite de $LIMITE linhas."
|