@koalarx/scrapping 2.0.0 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/@types/browser-config.d.ts +8 -0
- package/@types/browser-config.js +2 -0
- package/@types/dom-options.d.ts +4 -0
- package/@types/dom-options.js +2 -0
- package/@types/get-datatable-options.d.ts +9 -0
- package/@types/get-datatable-options.js +2 -0
- package/Browser.d.ts +11 -0
- package/Browser.js +65 -0
- package/Dom.d.ts +21 -0
- package/Dom.js +103 -0
- package/Frame.d.ts +5 -0
- package/Frame.js +10 -0
- package/Page.d.ts +8 -0
- package/Page.js +43 -0
- package/README.md +4 -4
- package/constants/args.d.ts +2 -0
- package/constants/args.js +42 -0
- package/package.json +7 -3
- package/.github/workflows/npm-publish.yml +0 -32
- package/.prettierrc.json +0 -9
- package/.vscode/launch.json +0 -13
- package/.vscode/mcp.json +0 -10
- package/.vscode/settings.json +0 -151
- package/.vscode/tasks.json +0 -17
- package/LICENSE +0 -21
- package/bun.lock +0 -749
- package/bunfig.toml +0 -7
- package/eslint.config.mts +0 -83
- package/lib/core/@types/browser-config.ts +0 -8
- package/lib/core/@types/dom-options.ts +0 -4
- package/lib/core/@types/get-datatable-options.ts +0 -9
- package/lib/core/Browser.ts +0 -81
- package/lib/core/Dom.ts +0 -144
- package/lib/core/Frame.ts +0 -8
- package/lib/core/Page.ts +0 -56
- package/lib/core/constants/args.ts +0 -40
- package/lib/test/download-file.spec.ts +0 -18
- package/lib/test/frame-interaction.spec.ts +0 -22
- package/lib/test/get-datatable-with-paginator.spec.ts +0 -31
- package/lib/test/search-wikipidea.spec.ts +0 -18
- package/lib/test/setup.ts +0 -14
- package/lib/test/vars.ts +0 -7
- package/scripts/README.md +0 -209
- package/scripts/create-version-tag.ps1 +0 -83
- package/scripts/create-version-tag.sh +0 -91
- package/scripts/hooks/post-commit +0 -118
- package/scripts/hooks/post-commit-windows.bat +0 -80
- package/scripts/hooks/post-commit.bat +0 -15
- package/scripts/hooks/post-commit.ps1 +0 -101
- package/scripts/hooks/post-merge +0 -66
- package/scripts/hooks/pre-commit +0 -82
- package/scripts/hooks/pre-commit-windows.bat +0 -68
- package/scripts/hooks/pre-commit.bat +0 -15
- package/scripts/setup-hooks.bat +0 -107
- package/scripts/setup-hooks.ps1 +0 -69
- package/scripts/setup-hooks.sh +0 -44
- package/scripts/test-linux-support.sh +0 -171
- package/scripts/version-dialog.ps1 +0 -137
- package/scripts/version-dialog.sh +0 -139
- package/tsconfig.build.json +0 -31
- package/tsconfig.json +0 -40
package/scripts/hooks/post-merge
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# Hook post-merge para criar tags automáticas após merge
|
|
4
|
-
# Similar ao post-commit mas para operações de merge
|
|
5
|
-
|
|
6
|
-
current_branch=$(git rev-parse --abbrev-ref HEAD)
|
|
7
|
-
|
|
8
|
-
# Executar apenas na branch develop
|
|
9
|
-
if [ "$current_branch" != "develop" ]; then
|
|
10
|
-
exit 0
|
|
11
|
-
fi
|
|
12
|
-
|
|
13
|
-
repo_root=$(git rev-parse --show-toplevel)
|
|
14
|
-
|
|
15
|
-
# Usar opção 4 (apenas enviar) por padrão em merges
|
|
16
|
-
# Não pedimos interação ao usuário em merges
|
|
17
|
-
option=4
|
|
18
|
-
prepare_script="prepare:only-tag"
|
|
19
|
-
|
|
20
|
-
cd "$repo_root" || exit 0
|
|
21
|
-
|
|
22
|
-
# Adicionar log para debug
|
|
23
|
-
{
|
|
24
|
-
echo "[post-merge] Branch: $current_branch"
|
|
25
|
-
echo "[post-merge] RepoRoot: $repo_root"
|
|
26
|
-
echo "[post-merge] Opção: $option (padrão em merges)"
|
|
27
|
-
echo "[post-merge] Executando: bun run $prepare_script"
|
|
28
|
-
date
|
|
29
|
-
} >> "$repo_root/.git/hooks/post-merge.log"
|
|
30
|
-
|
|
31
|
-
# Executar bun version
|
|
32
|
-
bun run "$prepare_script" >> "$repo_root/.git/hooks/post-merge.log" 2>&1
|
|
33
|
-
bun_exit=$?
|
|
34
|
-
|
|
35
|
-
echo "[post-merge] Exit code: $bun_exit" >> "$repo_root/.git/hooks/post-merge.log"
|
|
36
|
-
|
|
37
|
-
if [ $bun_exit -eq 0 ]; then
|
|
38
|
-
# Obter versão
|
|
39
|
-
version=$(grep -m 1 '"version"' package.json | cut -d'"' -f4)
|
|
40
|
-
|
|
41
|
-
# Para merge, não fazemos amend (não alteramos a versão)
|
|
42
|
-
|
|
43
|
-
# Obter hash
|
|
44
|
-
commit_id=$(git rev-parse --short HEAD)
|
|
45
|
-
tag_name="${version}-dev+${commit_id}"
|
|
46
|
-
|
|
47
|
-
echo "[post-merge] Tag name: $tag_name" >> "$repo_root/.git/hooks/post-merge.log"
|
|
48
|
-
|
|
49
|
-
# Criar tag (sobrescrever se existir)
|
|
50
|
-
git tag -f "$tag_name" 2>&1 | tee -a "$repo_root/.git/hooks/post-merge.log"
|
|
51
|
-
echo "[post-merge] Tag criada" >> "$repo_root/.git/hooks/post-merge.log"
|
|
52
|
-
|
|
53
|
-
# Push branch e tag em um ÚNICO comando
|
|
54
|
-
# (máximo 3 tentativas)
|
|
55
|
-
echo "[post-merge] Iniciando push único (branch + tag)..." >> "$repo_root/.git/hooks/post-merge.log"
|
|
56
|
-
for attempt in {1..3}; do
|
|
57
|
-
echo "[post-merge] Tentativa $attempt" >> "$repo_root/.git/hooks/post-merge.log"
|
|
58
|
-
if git push --force-with-lease origin refs/heads/develop:refs/heads/develop "refs/tags/$tag_name:refs/tags/$tag_name" 2>&1 | tee -a "$repo_root/.git/hooks/post-merge.log"; then
|
|
59
|
-
echo "[post-merge] Push bem-sucedido" >> "$repo_root/.git/hooks/post-merge.log"
|
|
60
|
-
break
|
|
61
|
-
fi
|
|
62
|
-
sleep 1
|
|
63
|
-
done
|
|
64
|
-
fi
|
|
65
|
-
|
|
66
|
-
exit 0
|
package/scripts/hooks/pre-commit
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
branch=$(git rev-parse --abbrev-ref HEAD)
|
|
3
|
-
|
|
4
|
-
# Se já está em processamento de versioning (via post-commit que chamou --amend)
|
|
5
|
-
# NÃO fazer nada
|
|
6
|
-
if [ "$GIT_VERSION_IN_PROGRESS" = "1" ]; then
|
|
7
|
-
exit 0
|
|
8
|
-
fi
|
|
9
|
-
|
|
10
|
-
# Se o arquivo NÃO existe, precisar pedir ao usuário qual tipo de change
|
|
11
|
-
if [ ! -f ".git/GIT_VERSION_TYPE" ]; then
|
|
12
|
-
# IMPORTANTE: Criar arquivo com marcador IMEDIATAMENTE para bloquear post-commit
|
|
13
|
-
# Isso garante que post-commit não rode antes do usuário confirmar a dialog
|
|
14
|
-
touch ".git/GIT_VERSION_WAITING"
|
|
15
|
-
|
|
16
|
-
if [ -t 0 ]; then
|
|
17
|
-
# Terminal interativo - usar prompt simples
|
|
18
|
-
echo "Qual tipo? 1=hotfix 2=feature 3=release 4=apenas enviar"
|
|
19
|
-
read -p "Escolha (padrão=4): " option
|
|
20
|
-
option=${option:-4}
|
|
21
|
-
echo "$option" > .git/GIT_VERSION_TYPE
|
|
22
|
-
rm -f ".git/GIT_VERSION_WAITING"
|
|
23
|
-
export GIT_VERSION_TYPE="$option"
|
|
24
|
-
else
|
|
25
|
-
# Não é terminal interativo - tentar usar diálogo gráfico
|
|
26
|
-
if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "win32" ]]; then
|
|
27
|
-
# Windows - usar PowerShell
|
|
28
|
-
SCRIPT_DIR=$(pwd)
|
|
29
|
-
GIT_DIR=$(cd .git 2>/dev/null && pwd || echo ".git")
|
|
30
|
-
|
|
31
|
-
# Executar dialog e capturar resultado
|
|
32
|
-
dialog_output=$(powershell -NoProfile -ExecutionPolicy Bypass -File "$SCRIPT_DIR/scripts/version-dialog.ps1" -GitDir "$GIT_DIR" 2>/dev/null)
|
|
33
|
-
ps_exit=$?
|
|
34
|
-
|
|
35
|
-
if [ $ps_exit -eq 1 ]; then
|
|
36
|
-
rm -f ".git/GIT_VERSION_WAITING"
|
|
37
|
-
exit 1
|
|
38
|
-
fi
|
|
39
|
-
|
|
40
|
-
# Esperar arquivo ser criado
|
|
41
|
-
for i in {1..10}; do
|
|
42
|
-
if [ -f ".git/GIT_VERSION_TYPE" ]; then
|
|
43
|
-
break
|
|
44
|
-
fi
|
|
45
|
-
sleep 0.2
|
|
46
|
-
done
|
|
47
|
-
|
|
48
|
-
if [ ! -f ".git/GIT_VERSION_TYPE" ]; then
|
|
49
|
-
echo "4" > .git/GIT_VERSION_TYPE
|
|
50
|
-
fi
|
|
51
|
-
rm -f ".git/GIT_VERSION_WAITING"
|
|
52
|
-
else
|
|
53
|
-
# Linux/Unix - usar script de diálogo bash
|
|
54
|
-
SCRIPT_DIR=$(pwd)
|
|
55
|
-
GIT_DIR=$(cd .git 2>/dev/null && pwd || echo ".git")
|
|
56
|
-
|
|
57
|
-
# Tentar executar o diálogo Linux
|
|
58
|
-
if [ -f "$SCRIPT_DIR/scripts/version-dialog.sh" ]; then
|
|
59
|
-
bash "$SCRIPT_DIR/scripts/version-dialog.sh" "$GIT_DIR" 2>/dev/null
|
|
60
|
-
dialog_exit=$?
|
|
61
|
-
|
|
62
|
-
if [ $dialog_exit -ne 0 ] && [ ! -f ".git/GIT_VERSION_TYPE" ]; then
|
|
63
|
-
# Se falhou e não criou o arquivo, usar padrão
|
|
64
|
-
echo "4" > .git/GIT_VERSION_TYPE
|
|
65
|
-
fi
|
|
66
|
-
else
|
|
67
|
-
# Script de diálogo não encontrado, usar padrão
|
|
68
|
-
echo "4" > .git/GIT_VERSION_TYPE
|
|
69
|
-
fi
|
|
70
|
-
rm -f ".git/GIT_VERSION_WAITING"
|
|
71
|
-
fi
|
|
72
|
-
fi
|
|
73
|
-
else
|
|
74
|
-
# Se GIT_VERSION_TYPE já existe e NÃO estamos em GIT_VERSION_IN_PROGRESS
|
|
75
|
-
# significa que o amend está chamando pre-commit novamente
|
|
76
|
-
# Neste caso, apenas manter o arquivo para post-commit usar
|
|
77
|
-
# Não fazer nada, deixar o arquivo lá
|
|
78
|
-
:
|
|
79
|
-
fi
|
|
80
|
-
|
|
81
|
-
export GIT_VERSION_TYPE=$(cat .git/GIT_VERSION_TYPE 2>/dev/null)
|
|
82
|
-
exit 0
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
@echo off
|
|
2
|
-
setlocal enabledelayedexpansion
|
|
3
|
-
|
|
4
|
-
for /f "tokens=*" %%i in ('git rev-parse --abbrev-ref HEAD 2^>nul') do set CURRENT_BRANCH=%%i
|
|
5
|
-
|
|
6
|
-
if NOT "%CURRENT_BRANCH%"=="develop" (
|
|
7
|
-
exit /b 0
|
|
8
|
-
)
|
|
9
|
-
|
|
10
|
-
for /f "tokens=*" %%i in ('git rev-parse --show-toplevel 2^>nul') do set REPO_ROOT=%%i
|
|
11
|
-
|
|
12
|
-
if exist "%REPO_ROOT%\.git\GIT_VERSION_TYPE" (
|
|
13
|
-
exit /b 0
|
|
14
|
-
)
|
|
15
|
-
|
|
16
|
-
REM Se está em processamento de versioning (amend), não fazer nada
|
|
17
|
-
if "%GIT_VERSION_IN_PROGRESS%"=="1" (
|
|
18
|
-
exit /b 0
|
|
19
|
-
)
|
|
20
|
-
|
|
21
|
-
REM Marcar que estamos aguardando input do usuário
|
|
22
|
-
echo. > "%REPO_ROOT%\.git\GIT_VERSION_WAITING"
|
|
23
|
-
|
|
24
|
-
REM Log para debug
|
|
25
|
-
echo [pre-commit] Branch: %CURRENT_BRANCH% >> "%REPO_ROOT%\.git\hooks\pre-commit.log"
|
|
26
|
-
echo [pre-commit] RepoRoot: %REPO_ROOT% >> "%REPO_ROOT%\.git\hooks\pre-commit.log"
|
|
27
|
-
|
|
28
|
-
REM Executar o PowerShell dialog se possível
|
|
29
|
-
set SCRIPT_DIR=%REPO_ROOT%\scripts
|
|
30
|
-
set PS_SCRIPT=%SCRIPT_DIR%\version-dialog.ps1
|
|
31
|
-
|
|
32
|
-
if exist "%PS_SCRIPT%" (
|
|
33
|
-
echo [pre-commit] Executando PowerShell dialog... >> "%REPO_ROOT%\.git\hooks\pre-commit.log"
|
|
34
|
-
REM Tentar executar com PowerShell
|
|
35
|
-
powershell -NoProfile -ExecutionPolicy Bypass -File "%PS_SCRIPT%" -GitDir "%REPO_ROOT%\.git" >> "%REPO_ROOT%\.git\hooks\pre-commit.log" 2>&1
|
|
36
|
-
|
|
37
|
-
echo [pre-commit] PowerShell exit code: !ERRORLEVEL! >> "%REPO_ROOT%\.git\hooks\pre-commit.log"
|
|
38
|
-
if !ERRORLEVEL! EQU 1 (
|
|
39
|
-
REM Usuário cancelou - remover arquivo de espera e sair com erro
|
|
40
|
-
echo [pre-commit] Usuário cancelou >> "%REPO_ROOT%\.git\hooks\pre-commit.log"
|
|
41
|
-
del "%REPO_ROOT%\.git\GIT_VERSION_WAITING" 2>nul
|
|
42
|
-
exit /b 1
|
|
43
|
-
)
|
|
44
|
-
) else (
|
|
45
|
-
REM Fallback: menu em linha de comando
|
|
46
|
-
cls
|
|
47
|
-
echo.
|
|
48
|
-
echo =====================================
|
|
49
|
-
echo Gerenciador de Versao
|
|
50
|
-
echo =====================================
|
|
51
|
-
echo.
|
|
52
|
-
echo Qual tipo de alteracao?
|
|
53
|
-
echo.
|
|
54
|
-
echo 1) hotfix - Correcao de bugs (patch)
|
|
55
|
-
echo 2) feature - Nova funcionalidade (minor)
|
|
56
|
-
echo 3) release - Release (major)
|
|
57
|
-
echo 4) apenas enviar - Sem alterar versao
|
|
58
|
-
echo.
|
|
59
|
-
set /p OPTION="Selecione a opcao (1/2/3/4 ou Enter=2): "
|
|
60
|
-
if "!OPTION!"=="" set OPTION=2
|
|
61
|
-
|
|
62
|
-
echo !OPTION! > "%REPO_ROOT%\.git\GIT_VERSION_TYPE"
|
|
63
|
-
)
|
|
64
|
-
|
|
65
|
-
REM Remover arquivo de espera se existir
|
|
66
|
-
del "%REPO_ROOT%\.git\GIT_VERSION_WAITING" 2>nul
|
|
67
|
-
|
|
68
|
-
exit /b 0
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
@echo off
|
|
2
|
-
REM Wrapper para pré-commit hook
|
|
3
|
-
REM Este arquivo chama o script batch do pré-commit
|
|
4
|
-
|
|
5
|
-
setlocal enabledelayedexpansion
|
|
6
|
-
|
|
7
|
-
for /f "tokens=*" %%i in ('git rev-parse --show-toplevel 2^>nul') do set REPO_ROOT=%%i
|
|
8
|
-
|
|
9
|
-
if exist "%REPO_ROOT%\scripts\hooks\pre-commit-windows.bat" (
|
|
10
|
-
call "%REPO_ROOT%\scripts\hooks\pre-commit-windows.bat"
|
|
11
|
-
exit /b !ERRORLEVEL!
|
|
12
|
-
) else (
|
|
13
|
-
REM Fallback para versão bash se batch não existir
|
|
14
|
-
exit /b 0
|
|
15
|
-
)
|
package/scripts/setup-hooks.bat
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
@echo off
|
|
2
|
-
REM Script para instalar os git hooks do projeto (Windows - CMD)
|
|
3
|
-
REM Uso: setup-hooks.bat
|
|
4
|
-
|
|
5
|
-
setlocal enabledelayedexpansion
|
|
6
|
-
|
|
7
|
-
REM Obter a raiz do repositório
|
|
8
|
-
for /f "tokens=*" %%i in ('git rev-parse --show-toplevel') do set REPO_ROOT=%%i
|
|
9
|
-
|
|
10
|
-
if errorlevel 1 (
|
|
11
|
-
echo Erro: Nao foi possivel obter a raiz do repositorio.
|
|
12
|
-
echo Certifique-se de que voce esta em um repositorio Git.
|
|
13
|
-
pause
|
|
14
|
-
exit /b 1
|
|
15
|
-
)
|
|
16
|
-
|
|
17
|
-
set HOOKS_DIR=%REPO_ROOT%\scripts\hooks
|
|
18
|
-
set GIT_HOOKS_DIR=%REPO_ROOT%\.git\hooks
|
|
19
|
-
|
|
20
|
-
echo.
|
|
21
|
-
echo =====================================
|
|
22
|
-
echo Instalando Git Hooks
|
|
23
|
-
echo =====================================
|
|
24
|
-
echo.
|
|
25
|
-
|
|
26
|
-
REM Verificar se o diretório de hooks existe
|
|
27
|
-
if not exist "%HOOKS_DIR%" (
|
|
28
|
-
echo Erro: Diretorio %HOOKS_DIR% nao encontrado
|
|
29
|
-
pause
|
|
30
|
-
exit /b 1
|
|
31
|
-
)
|
|
32
|
-
|
|
33
|
-
REM Verificar se o diretório .git existe
|
|
34
|
-
if not exist "%GIT_HOOKS_DIR%" (
|
|
35
|
-
echo Erro: Diretorio .git nao encontrado. Voce esta em um repositorio Git?
|
|
36
|
-
pause
|
|
37
|
-
exit /b 1
|
|
38
|
-
)
|
|
39
|
-
|
|
40
|
-
REM ========== INSTALAR HOOKS BASH ==========
|
|
41
|
-
REM Copiar hooks bash para .git/hooks
|
|
42
|
-
|
|
43
|
-
REM PRE-COMMIT
|
|
44
|
-
if exist "%HOOKS_DIR%\pre-commit" (
|
|
45
|
-
copy "%HOOKS_DIR%\pre-commit" "%GIT_HOOKS_DIR%\pre-commit" /Y >nul
|
|
46
|
-
if errorlevel 1 (
|
|
47
|
-
echo Erro: Nao foi possivel instalar o pre-commit hook
|
|
48
|
-
pause
|
|
49
|
-
exit /b 1
|
|
50
|
-
) else (
|
|
51
|
-
echo [OK] pre-commit hook instalado
|
|
52
|
-
)
|
|
53
|
-
) else (
|
|
54
|
-
echo Erro: pre-commit hook nao encontrado em %HOOKS_DIR%
|
|
55
|
-
pause
|
|
56
|
-
exit /b 1
|
|
57
|
-
)
|
|
58
|
-
|
|
59
|
-
REM POST-COMMIT
|
|
60
|
-
if exist "%HOOKS_DIR%\post-commit" (
|
|
61
|
-
copy "%HOOKS_DIR%\post-commit" "%GIT_HOOKS_DIR%\post-commit" /Y >nul
|
|
62
|
-
if errorlevel 1 (
|
|
63
|
-
echo Erro: Nao foi possivel instalar o post-commit hook
|
|
64
|
-
pause
|
|
65
|
-
exit /b 1
|
|
66
|
-
) else (
|
|
67
|
-
echo [OK] post-commit hook instalado
|
|
68
|
-
)
|
|
69
|
-
) else (
|
|
70
|
-
echo Erro: post-commit hook nao encontrado em %HOOKS_DIR%
|
|
71
|
-
pause
|
|
72
|
-
exit /b 1
|
|
73
|
-
)
|
|
74
|
-
|
|
75
|
-
REM POST-MERGE
|
|
76
|
-
if exist "%HOOKS_DIR%\post-merge" (
|
|
77
|
-
copy "%HOOKS_DIR%\post-merge" "%GIT_HOOKS_DIR%\post-merge" /Y >nul
|
|
78
|
-
if errorlevel 1 (
|
|
79
|
-
echo Erro: Nao foi possivel instalar o post-merge hook
|
|
80
|
-
pause
|
|
81
|
-
exit /b 1
|
|
82
|
-
) else (
|
|
83
|
-
echo [OK] post-merge hook instalado
|
|
84
|
-
)
|
|
85
|
-
) else (
|
|
86
|
-
echo Erro: post-merge hook nao encontrado em %HOOKS_DIR%
|
|
87
|
-
pause
|
|
88
|
-
exit /b 1
|
|
89
|
-
)
|
|
90
|
-
|
|
91
|
-
echo.
|
|
92
|
-
echo [OK] Todos os hooks foram instalados com sucesso!
|
|
93
|
-
echo.
|
|
94
|
-
echo Informacoes dos hooks instalados:
|
|
95
|
-
echo - pre-commit: Exibe dialogo para selecionar tipo de alteracao
|
|
96
|
-
echo - post-commit: Atualiza versao e cria tags automaticamente
|
|
97
|
-
echo - post-merge: Cria tags automaticamente apos merge (sem alterar versao)
|
|
98
|
-
echo.
|
|
99
|
-
echo Opcoes disponiveis:
|
|
100
|
-
echo 1) hotfix - Correcao de bugs (patch)
|
|
101
|
-
echo 2) feature - Nova funcionalidade (minor)
|
|
102
|
-
echo 3) release - Release (major)
|
|
103
|
-
echo 4) apenas enviar - Sem alterar versao
|
|
104
|
-
echo.
|
|
105
|
-
echo =====================================
|
|
106
|
-
echo.
|
|
107
|
-
pause
|
package/scripts/setup-hooks.ps1
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env powershell
|
|
2
|
-
|
|
3
|
-
# Script para instalar os git hooks do projeto (Windows - PowerShell)
|
|
4
|
-
|
|
5
|
-
$ErrorActionPreference = "Stop"
|
|
6
|
-
|
|
7
|
-
try {
|
|
8
|
-
$repoRoot = git rev-parse --show-toplevel
|
|
9
|
-
if ($LASTEXITCODE -ne 0) {
|
|
10
|
-
throw "Erro: Não foi possível obter a raiz do repositório. Certifique-se de que você está em um repositório Git."
|
|
11
|
-
}
|
|
12
|
-
} catch {
|
|
13
|
-
Write-Host "Erro ao executar git: $_" -ForegroundColor Red
|
|
14
|
-
exit 1
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
$hooksDir = Join-Path $repoRoot "scripts\hooks"
|
|
18
|
-
$gitHooksDir = Join-Path $repoRoot ".git\hooks"
|
|
19
|
-
|
|
20
|
-
Write-Host "`n=====================================" -ForegroundColor Blue
|
|
21
|
-
Write-Host "Instalando Git Hooks" -ForegroundColor Blue
|
|
22
|
-
Write-Host "=====================================" -ForegroundColor Blue
|
|
23
|
-
|
|
24
|
-
# Verificar se o diretório de hooks existe
|
|
25
|
-
if (-not (Test-Path $hooksDir)) {
|
|
26
|
-
Write-Host "Erro: Diretório $hooksDir não encontrado" -ForegroundColor Red
|
|
27
|
-
exit 1
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
# Verificar se o diretório .git existe
|
|
31
|
-
if (-not (Test-Path $gitHooksDir)) {
|
|
32
|
-
Write-Host "Erro: Diretório .git não encontrado. Você está em um repositório Git?" -ForegroundColor Red
|
|
33
|
-
exit 1
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
# Instalar post-commit hook
|
|
37
|
-
$postCommitSource = Join-Path $hooksDir "post-commit.ps1"
|
|
38
|
-
$postCommitDest = Join-Path $gitHooksDir "post-commit"
|
|
39
|
-
|
|
40
|
-
if (Test-Path $postCommitSource) {
|
|
41
|
-
try {
|
|
42
|
-
Copy-Item $postCommitSource $postCommitDest -Force
|
|
43
|
-
Write-Host "✓ post-commit hook instalado (PowerShell)" -ForegroundColor Green
|
|
44
|
-
} catch {
|
|
45
|
-
Write-Host "Erro ao instalar post-commit hook: $_" -ForegroundColor Red
|
|
46
|
-
exit 1
|
|
47
|
-
}
|
|
48
|
-
} else {
|
|
49
|
-
Write-Host "Aviso: post-commit.ps1 não encontrado em $hooksDir" -ForegroundColor Yellow
|
|
50
|
-
|
|
51
|
-
# Tentar usar versão Bash como fallback
|
|
52
|
-
$postCommitSourceBash = Join-Path $hooksDir "post-commit"
|
|
53
|
-
if (Test-Path $postCommitSourceBash) {
|
|
54
|
-
try {
|
|
55
|
-
Copy-Item $postCommitSourceBash $postCommitDest -Force
|
|
56
|
-
Write-Host "✓ post-commit hook instalado (Bash)" -ForegroundColor Green
|
|
57
|
-
} catch {
|
|
58
|
-
Write-Host "Erro ao instalar post-commit hook: $_" -ForegroundColor Red
|
|
59
|
-
exit 1
|
|
60
|
-
}
|
|
61
|
-
} else {
|
|
62
|
-
Write-Host "Erro: post-commit hook não encontrado em $hooksDir" -ForegroundColor Red
|
|
63
|
-
exit 1
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
Write-Host "`n✓ Todos os hooks foram instalados com sucesso!" -ForegroundColor Green
|
|
68
|
-
Write-Host "=====================================" -ForegroundColor Blue
|
|
69
|
-
Write-Host ""
|
package/scripts/setup-hooks.sh
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# Script para instalar os git hooks do projeto
|
|
4
|
-
|
|
5
|
-
REPO_ROOT=$(git rev-parse --show-toplevel)
|
|
6
|
-
HOOKS_DIR="$REPO_ROOT/scripts/hooks"
|
|
7
|
-
GIT_HOOKS_DIR="$REPO_ROOT/.git/hooks"
|
|
8
|
-
|
|
9
|
-
# Cores para output
|
|
10
|
-
GREEN='\033[0;32m'
|
|
11
|
-
BLUE='\033[0;34m'
|
|
12
|
-
NC='\033[0m' # No Color
|
|
13
|
-
|
|
14
|
-
echo -e "${BLUE}Instalando git hooks...${NC}"
|
|
15
|
-
|
|
16
|
-
# Instalar post-commit hook
|
|
17
|
-
if [ -f "$HOOKS_DIR/post-commit" ]; then
|
|
18
|
-
cp "$HOOKS_DIR/post-commit" "$GIT_HOOKS_DIR/post-commit"
|
|
19
|
-
chmod +x "$GIT_HOOKS_DIR/post-commit"
|
|
20
|
-
echo -e "${GREEN}✓ post-commit hook instalado${NC}"
|
|
21
|
-
else
|
|
22
|
-
echo "Erro: post-commit hook não encontrado em $HOOKS_DIR"
|
|
23
|
-
exit 1
|
|
24
|
-
fi
|
|
25
|
-
|
|
26
|
-
# Instalar pre-commit hook
|
|
27
|
-
if [ -f "$HOOKS_DIR/pre-commit" ]; then
|
|
28
|
-
cp "$HOOKS_DIR/pre-commit" "$GIT_HOOKS_DIR/pre-commit"
|
|
29
|
-
chmod +x "$GIT_HOOKS_DIR/pre-commit"
|
|
30
|
-
echo -e "${GREEN}✓ pre-commit hook instalado${NC}"
|
|
31
|
-
else
|
|
32
|
-
echo -e "${YELLOW}⚠ pre-commit hook não encontrado em $HOOKS_DIR${NC}"
|
|
33
|
-
fi
|
|
34
|
-
|
|
35
|
-
# Instalar post-merge hook
|
|
36
|
-
if [ -f "$HOOKS_DIR/post-merge" ]; then
|
|
37
|
-
cp "$HOOKS_DIR/post-merge" "$GIT_HOOKS_DIR/post-merge"
|
|
38
|
-
chmod +x "$GIT_HOOKS_DIR/post-merge"
|
|
39
|
-
echo -e "${GREEN}✓ post-merge hook instalado${NC}"
|
|
40
|
-
else
|
|
41
|
-
echo -e "${YELLOW}⚠ post-merge hook não encontrado em $HOOKS_DIR${NC}"
|
|
42
|
-
fi
|
|
43
|
-
|
|
44
|
-
echo -e "${GREEN}✓ Todos os hooks foram instalados com sucesso!${NC}"
|
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
# Script de teste para validar a instalação dos hooks no Linux
|
|
3
|
-
|
|
4
|
-
# Cores para output
|
|
5
|
-
RED='\033[0;31m'
|
|
6
|
-
GREEN='\033[0;32m'
|
|
7
|
-
YELLOW='\033[1;33m'
|
|
8
|
-
BLUE='\033[0;34m'
|
|
9
|
-
NC='\033[0m' # No Color
|
|
10
|
-
|
|
11
|
-
echo -e "${BLUE}================================================${NC}"
|
|
12
|
-
echo -e "${BLUE} Teste de Hooks Git - Suporte Linux${NC}"
|
|
13
|
-
echo -e "${BLUE}================================================${NC}"
|
|
14
|
-
echo ""
|
|
15
|
-
|
|
16
|
-
# Função para checar se um comando existe
|
|
17
|
-
command_exists() {
|
|
18
|
-
command -v "$1" >/dev/null 2>&1
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
# Variáveis de status
|
|
22
|
-
all_ok=true
|
|
23
|
-
|
|
24
|
-
# 1. Verificar se estamos em um repositório Git
|
|
25
|
-
echo -n "1. Verificando repositório Git... "
|
|
26
|
-
if git rev-parse --git-dir > /dev/null 2>&1; then
|
|
27
|
-
echo -e "${GREEN}✓${NC}"
|
|
28
|
-
else
|
|
29
|
-
echo -e "${RED}✗${NC}"
|
|
30
|
-
echo -e "${RED} Erro: Não está em um repositório Git${NC}"
|
|
31
|
-
all_ok=false
|
|
32
|
-
fi
|
|
33
|
-
|
|
34
|
-
# 2. Verificar scripts principais
|
|
35
|
-
echo -n "2. Verificando scripts principais... "
|
|
36
|
-
missing_scripts=()
|
|
37
|
-
for script in "scripts/setup-hooks.sh" "scripts/version-dialog.sh" "scripts/create-version-tag.sh"; do
|
|
38
|
-
if [ ! -f "$script" ]; then
|
|
39
|
-
missing_scripts+=("$script")
|
|
40
|
-
fi
|
|
41
|
-
done
|
|
42
|
-
|
|
43
|
-
if [ ${#missing_scripts[@]} -eq 0 ]; then
|
|
44
|
-
echo -e "${GREEN}✓${NC}"
|
|
45
|
-
else
|
|
46
|
-
echo -e "${RED}✗${NC}"
|
|
47
|
-
echo -e "${RED} Scripts faltando: ${missing_scripts[*]}${NC}"
|
|
48
|
-
all_ok=false
|
|
49
|
-
fi
|
|
50
|
-
|
|
51
|
-
# 3. Verificar permissões executáveis
|
|
52
|
-
echo -n "3. Verificando permissões executáveis... "
|
|
53
|
-
non_executable=()
|
|
54
|
-
for script in "scripts/setup-hooks.sh" "scripts/version-dialog.sh" "scripts/create-version-tag.sh"; do
|
|
55
|
-
if [ -f "$script" ] && [ ! -x "$script" ]; then
|
|
56
|
-
non_executable+=("$script")
|
|
57
|
-
fi
|
|
58
|
-
done
|
|
59
|
-
|
|
60
|
-
if [ ${#non_executable[@]} -eq 0 ]; then
|
|
61
|
-
echo -e "${GREEN}✓${NC}"
|
|
62
|
-
else
|
|
63
|
-
echo -e "${YELLOW}⚠${NC}"
|
|
64
|
-
echo -e "${YELLOW} Scripts sem permissão executável: ${non_executable[*]}${NC}"
|
|
65
|
-
echo -e "${YELLOW} Execute: chmod +x ${non_executable[*]}${NC}"
|
|
66
|
-
fi
|
|
67
|
-
|
|
68
|
-
# 4. Verificar hooks nos scripts/hooks/
|
|
69
|
-
echo -n "4. Verificando hooks de origem... "
|
|
70
|
-
missing_hooks=()
|
|
71
|
-
for hook in "scripts/hooks/pre-commit" "scripts/hooks/post-commit" "scripts/hooks/post-merge"; do
|
|
72
|
-
if [ ! -f "$hook" ]; then
|
|
73
|
-
missing_hooks+=("$hook")
|
|
74
|
-
fi
|
|
75
|
-
done
|
|
76
|
-
|
|
77
|
-
if [ ${#missing_hooks[@]} -eq 0 ]; then
|
|
78
|
-
echo -e "${GREEN}✓${NC}"
|
|
79
|
-
else
|
|
80
|
-
echo -e "${RED}✗${NC}"
|
|
81
|
-
echo -e "${RED} Hooks faltando: ${missing_hooks[*]}${NC}"
|
|
82
|
-
all_ok=false
|
|
83
|
-
fi
|
|
84
|
-
|
|
85
|
-
# 5. Verificar hooks instalados em .git/hooks/
|
|
86
|
-
echo -n "5. Verificando hooks instalados... "
|
|
87
|
-
if [ -d ".git/hooks" ]; then
|
|
88
|
-
installed=0
|
|
89
|
-
for hook in "pre-commit" "post-commit" "post-merge"; do
|
|
90
|
-
if [ -f ".git/hooks/$hook" ]; then
|
|
91
|
-
((installed++))
|
|
92
|
-
fi
|
|
93
|
-
done
|
|
94
|
-
|
|
95
|
-
if [ $installed -eq 3 ]; then
|
|
96
|
-
echo -e "${GREEN}✓ (todos instalados)${NC}"
|
|
97
|
-
elif [ $installed -gt 0 ]; then
|
|
98
|
-
echo -e "${YELLOW}⚠ ($installed de 3 instalados)${NC}"
|
|
99
|
-
echo -e "${YELLOW} Execute: bash scripts/setup-hooks.sh${NC}"
|
|
100
|
-
else
|
|
101
|
-
echo -e "${RED}✗ (nenhum instalado)${NC}"
|
|
102
|
-
echo -e "${RED} Execute: bash scripts/setup-hooks.sh${NC}"
|
|
103
|
-
fi
|
|
104
|
-
else
|
|
105
|
-
echo -e "${RED}✗${NC}"
|
|
106
|
-
echo -e "${RED} Diretório .git/hooks não encontrado${NC}"
|
|
107
|
-
all_ok=false
|
|
108
|
-
fi
|
|
109
|
-
|
|
110
|
-
# 6. Verificar ferramentas de diálogo disponíveis
|
|
111
|
-
echo ""
|
|
112
|
-
echo -e "${BLUE}Ferramentas de interface disponíveis:${NC}"
|
|
113
|
-
|
|
114
|
-
if command_exists zenity; then
|
|
115
|
-
echo -e " ${GREEN}✓${NC} zenity (interface gráfica GTK)"
|
|
116
|
-
else
|
|
117
|
-
echo -e " ${YELLOW}✗${NC} zenity (recomendado)"
|
|
118
|
-
echo -e " ${YELLOW}Instale: sudo apt install zenity${NC}"
|
|
119
|
-
fi
|
|
120
|
-
|
|
121
|
-
if command_exists whiptail; then
|
|
122
|
-
echo -e " ${GREEN}✓${NC} whiptail (interface ncurses)"
|
|
123
|
-
else
|
|
124
|
-
echo -e " ${YELLOW}✗${NC} whiptail"
|
|
125
|
-
fi
|
|
126
|
-
|
|
127
|
-
if command_exists dialog; then
|
|
128
|
-
echo -e " ${GREEN}✓${NC} dialog (interface ncurses)"
|
|
129
|
-
else
|
|
130
|
-
echo -e " ${YELLOW}✗${NC} dialog"
|
|
131
|
-
fi
|
|
132
|
-
|
|
133
|
-
echo -e " ${GREEN}✓${NC} terminal simples (fallback sempre disponível)"
|
|
134
|
-
|
|
135
|
-
# 7. Verificar variáveis de ambiente importantes
|
|
136
|
-
echo ""
|
|
137
|
-
echo -e "${BLUE}Ambiente:${NC}"
|
|
138
|
-
echo " Sistema: $(uname -s)"
|
|
139
|
-
echo " Arquitetura: $(uname -m)"
|
|
140
|
-
|
|
141
|
-
if [ -n "$DISPLAY" ]; then
|
|
142
|
-
echo -e " Display: ${GREEN}$DISPLAY${NC} (interface gráfica disponível)"
|
|
143
|
-
else
|
|
144
|
-
echo -e " Display: ${YELLOW}não configurado${NC} (usará interface de terminal)"
|
|
145
|
-
fi
|
|
146
|
-
|
|
147
|
-
# 8. Verificar branch atual
|
|
148
|
-
echo ""
|
|
149
|
-
current_branch=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)
|
|
150
|
-
if [ "$current_branch" = "develop" ]; then
|
|
151
|
-
echo -e "${GREEN}✓${NC} Branch atual: ${GREEN}develop${NC} (hooks ativos)"
|
|
152
|
-
else
|
|
153
|
-
echo -e "${YELLOW}⚠${NC} Branch atual: ${YELLOW}$current_branch${NC}"
|
|
154
|
-
echo -e " ${YELLOW}(hooks só criam tags na branch develop)${NC}"
|
|
155
|
-
fi
|
|
156
|
-
|
|
157
|
-
# Resumo final
|
|
158
|
-
echo ""
|
|
159
|
-
echo -e "${BLUE}================================================${NC}"
|
|
160
|
-
if [ "$all_ok" = true ]; then
|
|
161
|
-
echo -e "${GREEN}✓ Sistema de hooks está OK!${NC}"
|
|
162
|
-
echo ""
|
|
163
|
-
echo -e "${BLUE}Próximos passos:${NC}"
|
|
164
|
-
echo " 1. Se ainda não instalou: bash scripts/setup-hooks.sh"
|
|
165
|
-
echo " 2. Faça um commit para testar: git commit -m 'teste'"
|
|
166
|
-
echo " 3. Escolha o tipo de versão no diálogo"
|
|
167
|
-
else
|
|
168
|
-
echo -e "${RED}✗ Alguns problemas encontrados${NC}"
|
|
169
|
-
echo -e "${YELLOW}Execute: bash scripts/setup-hooks.sh${NC}"
|
|
170
|
-
fi
|
|
171
|
-
echo -e "${BLUE}================================================${NC}"
|