-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·82 lines (65 loc) · 2.16 KB
/
install.sh
File metadata and controls
executable file
·82 lines (65 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash
echo "🚀 Instalando RSFE - Rust Source File Encoding Fixer"
echo ""
# Verifica se o Rust está instalado
if ! command -v cargo &> /dev/null; then
echo "❌ Rust não está instalado. Por favor, instale o Rust primeiro:"
echo " curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh"
exit 1
fi
# Compila o projeto em modo release
echo "📦 Compilando o projeto..."
cargo build --release
if [ $? -ne 0 ]; then
echo "❌ Falha na compilação"
exit 1
fi
echo "✅ Compilação concluída com sucesso!"
echo ""
# Verifica se existe package.json (projeto Node.js)
if [ -f "package.json" ]; then
echo "📋 Projeto Node.js detectado"
# Verifica se o Husky está instalado
if command -v npx &> /dev/null; then
echo "🐕 Configurando Husky..."
# Instala o Husky se não estiver instalado
if ! npm list husky &> /dev/null; then
echo " Instalando Husky..."
npm install --save-dev husky
fi
# Inicializa o Husky
npx husky install
# Cria o hook de pre-commit
mkdir -p .husky
cat > .husky/pre-commit << 'EOF'
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
# Executa o rsfe (Rust Source File Encoding Fixer)
./target/release/rsfe
# Se o rsfe falhar, impede o commit
if [ $? -ne 0 ]; then
echo "❌ rsfe falhou. Corrija os erros antes de commitar."
exit 1
fi
# Re-adiciona os arquivos modificados ao stage
git add -u
exit 0
EOF
chmod +x .husky/pre-commit
echo "✅ Husky configurado com sucesso!"
else
echo "⚠️ npx não encontrado. Pulando configuração do Husky."
fi
else
echo "ℹ️ Projeto Node.js não detectado. Pulando configuração do Husky."
echo " Para usar com git hooks, adicione manualmente ao .git/hooks/pre-commit:"
echo " ./target/release/rsfe"
fi
echo ""
echo "✅ Instalação concluída!"
echo ""
echo "📝 Próximos passos:"
echo " 1. Copie 'rsfe.conf.example' para 'rsfe.conf' e ajuste conforme necessário"
echo " 2. Execute './target/release/rsfe' para processar os arquivos"
echo " 3. (Opcional) Se usar git, o hook de pre-commit já está configurado"
echo ""