59 lines
1.4 KiB
Bash
Executable file
59 lines
1.4 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# check-vue-linhas.sh
|
|
# Garante que nenhum arquivo *.vue ultrapasse o limite de linhas definido.
|
|
#
|
|
# Arquivos listados em ISENTOS são legados em processo de refatoração —
|
|
# cada um deve ser quebrado em componentes menores antes de ser removido daqui.
|
|
|
|
set -euo pipefail
|
|
|
|
LIMITE=250
|
|
|
|
# Todos os arquivos *.vue devem respeitar o limite.
|
|
# Não existem isentos.
|
|
ISENTOS=()
|
|
|
|
RAIZ="$(cd "$(dirname "$0")/.." && pwd)"
|
|
ERROS=0
|
|
|
|
# Constrói padrão grep para os isentos
|
|
isentos_grep=""
|
|
for isento in "${ISENTOS[@]}"; do
|
|
if [ -n "$isentos_grep" ]; then
|
|
isentos_grep="${isentos_grep}\|${isento}"
|
|
else
|
|
isentos_grep="${isento}"
|
|
fi
|
|
done
|
|
|
|
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" -not -path "*/node_modules/*")
|
|
|
|
if [ "$ERROS" -gt 0 ]; then
|
|
echo ""
|
|
echo "⚠️ $ERROS arquivo(s) Vue ultrapassam o limite de $LIMITE linhas."
|
|
echo " Quebre em componentes menores antes de fazer build."
|
|
exit 1
|
|
fi
|
|
|
|
echo "✅ Todos os arquivos Vue estão dentro do limite de $LIMITE linhas."
|