@followthecode/cli 1.2.4 → 1.2.5

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/README.md CHANGED
@@ -98,6 +98,71 @@ docker run --rm -v "$PWD:/repo" ftc:latest collect code "/repo/meu-repo" --start
98
98
 
99
99
  > **Dica:**
100
100
  > - O volume `-v "$PWD:/repo"` (ou `%cd%:/repo` no Windows) permite que o container acesse seu repositório local.
101
+
102
+ ## ⚠️ Problemas de Instalação
103
+
104
+ Se você encontrar problemas durante a instalação do CLI, como:
105
+
106
+ - Avisos sobre `node-domexception` deprecado
107
+ - Erros de permissão EPERM no Windows
108
+ - Problemas de limpeza de cache
109
+
110
+ Consulte o guia completo de troubleshooting: **[TROUBLESHOOTING_INSTALL.md](TROUBLESHOOTING_INSTALL.md)**
111
+
112
+ ### Solução Rápida para Windows
113
+
114
+ Execute o script de correção como Administrador:
115
+
116
+ ```powershell
117
+ # Abrir PowerShell como Administrador
118
+ .\scripts\fix-windows-permissions.ps1
119
+
120
+ # Ou com limpeza forçada
121
+ .\scripts\fix-windows-permissions.ps1 -Force
122
+ ```
123
+
124
+ ## 🧪 Testando a Instalação
125
+
126
+ Antes de publicar uma nova versão, é importante testar a instalação em diferentes ambientes.
127
+
128
+ ### Testes Automatizados
129
+
130
+ #### Windows
131
+ ```powershell
132
+ # Teste básico
133
+ npm run test-installation
134
+
135
+ # Teste com limpeza prévia
136
+ npm run test-installation:clean
137
+
138
+ # Teste com output detalhado
139
+ npm run test-installation:verbose
140
+ ```
141
+
142
+ #### Linux/macOS
143
+ ```bash
144
+ # Teste básico
145
+ npm run test-installation:linux
146
+
147
+ # Teste com limpeza prévia
148
+ npm run test-installation:linux:clean
149
+ ```
150
+
151
+ ### Testes Manuais
152
+
153
+ ```bash
154
+ # Criar repositório de teste
155
+ mkdir test-repo && cd test-repo
156
+ git init && echo "# Test" > README.md
157
+ git add . && git commit -m "Initial"
158
+ cd ..
159
+
160
+ # Testar funcionalidades
161
+ bin/ftc collect code ./test-repo --json
162
+ bin/ftc collect code https://github.com/microsoft/vscode.git --json
163
+ ```
164
+
165
+ Para mais detalhes, consulte: **[TESTING_INSTALLATION.md](TESTING_INSTALLATION.md)**
101
166
  > - O comando `code "/repo/meu-repo"` deve apontar para o caminho dentro do container.
102
167
 
103
168
  ## Uso como ferramenta global (dotnet tool)
@@ -0,0 +1,212 @@
1
+ # 🔧 Troubleshooting - Problemas de Instalação do FTC CLI
2
+
3
+ ## ⚠️ Problemas Comuns e Soluções
4
+
5
+ ### 1. Aviso sobre `node-domexception` deprecado
6
+
7
+ **Problema:**
8
+ ```
9
+ npm warn deprecated node-domexception@1.0.0: Use your platform's native DOMException instead
10
+ ```
11
+
12
+ **Causa:** Dependência transitiva do `node-fetch` que usa uma versão antiga do `node-domexception`.
13
+
14
+ **Solução:** Este é apenas um aviso e não afeta a funcionalidade. O CLI continuará funcionando normalmente.
15
+
16
+ **Para resolver (opcional):**
17
+ ```bash
18
+ # Limpar cache do npm
19
+ npm cache clean --force
20
+
21
+ # Reinstalar com --legacy-peer-deps se necessário
22
+ npm install -g @followthecode/cli --legacy-peer-deps
23
+ ```
24
+
25
+ ### 2. Erro de Permissão EPERM no Windows
26
+
27
+ **Problema:**
28
+ ```
29
+ npm warn cleanup Failed to remove some directories [
30
+ 'C:\Users\user\AppData\Roaming\npm\node_modules\@followthecode\cli\node_modules\web-streams-polyfill\dist'
31
+ ]
32
+ Error: EPERM: operation not permitted
33
+ ```
34
+
35
+ **Causas:**
36
+ - Processos em execução usando os arquivos
37
+ - Antivírus bloqueando operações
38
+ - Permissões insuficientes
39
+ - Arquivos travados pelo sistema
40
+
41
+ **Soluções:**
42
+
43
+ #### Solução 1: Fechar processos e limpar
44
+ ```bash
45
+ # Fechar todos os terminais/prompts abertos
46
+ # Fechar editores de código que possam estar usando o CLI
47
+
48
+ # Limpar cache do npm
49
+ npm cache clean --force
50
+
51
+ # Desinstalar e reinstalar
52
+ npm uninstall -g @followthecode/cli
53
+ npm install -g @followthecode/cli
54
+ ```
55
+
56
+ #### Solução 2: Executar como Administrador
57
+ ```bash
58
+ # Abrir PowerShell/CMD como Administrador
59
+ # Executar a instalação
60
+ npm install -g @followthecode/cli
61
+ ```
62
+
63
+ #### Solução 3: Usar caminho alternativo
64
+ ```bash
65
+ # Instalar em diretório local do usuário
66
+ npm install -g @followthecode/cli --prefix %USERPROFILE%\AppData\Roaming\npm
67
+ ```
68
+
69
+ #### Solução 4: Desabilitar temporariamente o antivírus
70
+ 1. Desabilitar temporariamente o antivírus
71
+ 2. Executar a instalação
72
+ 3. Reabilitar o antivírus
73
+ 4. Adicionar exceção para o diretório npm se necessário
74
+
75
+ ### 3. Problemas de Permissão no Linux/macOS
76
+
77
+ **Problema:** Wrapper não tem permissão de execução
78
+
79
+ **Solução:**
80
+ ```bash
81
+ # Verificar permissões
82
+ ls -la $(which ftc)
83
+
84
+ # Definir permissões manualmente
85
+ chmod +x $(which ftc)
86
+
87
+ # Ou reinstalar com sudo
88
+ sudo npm install -g @followthecode/cli
89
+ ```
90
+
91
+ ### 4. Node.js não encontrado
92
+
93
+ **Problema:** CLI não consegue executar o wrapper Node.js
94
+
95
+ **Solução:**
96
+ ```bash
97
+ # Verificar se Node.js está instalado
98
+ node --version
99
+
100
+ # Se não estiver instalado, instalar Node.js
101
+ # Windows: https://nodejs.org/
102
+ # Linux: sudo apt install nodejs npm
103
+ # macOS: brew install node
104
+ ```
105
+
106
+ ### 5. Problemas de Rede/Proxy
107
+
108
+ **Problema:** Falha ao baixar dependências
109
+
110
+ **Solução:**
111
+ ```bash
112
+ # Configurar proxy se necessário
113
+ npm config set proxy http://proxy.company.com:8080
114
+ npm config set https-proxy http://proxy.company.com:8080
115
+
116
+ # Ou usar registry alternativo
117
+ npm config set registry https://registry.npmjs.org/
118
+
119
+ # Instalar com timeout aumentado
120
+ npm install -g @followthecode/cli --timeout=60000
121
+ ```
122
+
123
+ ## 🔍 Verificação da Instalação
124
+
125
+ ### Teste Básico
126
+ ```bash
127
+ # Verificar se o CLI foi instalado
128
+ ftc --version
129
+
130
+ # Verificar se o wrapper está funcionando
131
+ ftc --help
132
+ ```
133
+
134
+ ### Teste de Funcionalidade
135
+ ```bash
136
+ # Testar análise de repositório
137
+ ftc analyze --help
138
+
139
+ # Testar exportação
140
+ ftc export --help
141
+ ```
142
+
143
+ ## 🛠️ Comandos de Diagnóstico
144
+
145
+ ### Verificar Instalação
146
+ ```bash
147
+ # Verificar onde o CLI foi instalado
148
+ npm list -g @followthecode/cli
149
+
150
+ # Verificar binários disponíveis
151
+ where ftc # Windows
152
+ which ftc # Linux/macOS
153
+
154
+ # Verificar permissões dos arquivos
155
+ ls -la $(which ftc) # Linux/macOS
156
+ dir $(where ftc) # Windows
157
+ ```
158
+
159
+ ### Limpeza Completa
160
+ ```bash
161
+ # Desinstalar completamente
162
+ npm uninstall -g @followthecode/cli
163
+
164
+ # Limpar cache
165
+ npm cache clean --force
166
+
167
+ # Remover diretórios residuais (Windows)
168
+ rmdir /s /q "%USERPROFILE%\AppData\Roaming\npm\node_modules\@followthecode"
169
+
170
+ # Reinstalar
171
+ npm install -g @followthecode/cli
172
+ ```
173
+
174
+ ## 📞 Suporte
175
+
176
+ Se os problemas persistirem:
177
+
178
+ 1. **Coletar informações:**
179
+ ```bash
180
+ node --version
181
+ npm --version
182
+ ftc --version
183
+ ```
184
+
185
+ 2. **Verificar logs:**
186
+ - Windows: `%USERPROFILE%\AppData\Roaming\npm-cache\_logs\`
187
+ - Linux/macOS: `~/.npm/_logs/`
188
+
189
+ 3. **Reportar issue** com:
190
+ - Sistema operacional e versão
191
+ - Versões do Node.js e npm
192
+ - Logs de erro completos
193
+ - Passos para reproduzir o problema
194
+
195
+ ## 🔄 Alternativas de Instalação
196
+
197
+ ### Usando npx (sem instalação global)
198
+ ```bash
199
+ npx @followthecode/cli analyze --help
200
+ ```
201
+
202
+ ### Instalação Local
203
+ ```bash
204
+ # Em um projeto específico
205
+ npm install @followthecode/cli
206
+ npx ftc --help
207
+ ```
208
+
209
+ ### Docker (se disponível)
210
+ ```bash
211
+ docker run followthecode/cli --help
212
+ ```
package/bin/ftc ADDED
@@ -0,0 +1,69 @@
1
+ #!/bin/bash
2
+
3
+ # FTC CLI Wrapper Script
4
+ # Este script executa o FTC CLI baseado na plataforma detectada
5
+
6
+ set -e
7
+
8
+ # Função para detectar a plataforma
9
+ detect_platform() {
10
+ case "$(uname -s)" in
11
+ Linux*) echo "linux";;
12
+ Darwin*) echo "osx";;
13
+ CYGWIN*) echo "win";;
14
+ MINGW*) echo "win";;
15
+ MSYS*) echo "win";;
16
+ *) echo "unknown";;
17
+ esac
18
+ }
19
+
20
+ # Função para obter o caminho do executável
21
+ get_executable_path() {
22
+ local platform=$1
23
+ local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
24
+
25
+ case "$platform" in
26
+ "linux")
27
+ echo "$script_dir/linux-x64/ftc.cli"
28
+ ;;
29
+ "osx")
30
+ echo "$script_dir/osx-x64/ftc.cli"
31
+ ;;
32
+ "win")
33
+ echo "$script_dir/win-x64/ftc.cli.exe"
34
+ ;;
35
+ *)
36
+ echo "unknown"
37
+ ;;
38
+ esac
39
+ }
40
+
41
+ # Função para verificar se o executável existe
42
+ check_executable() {
43
+ local exec_path=$1
44
+
45
+ if [ ! -f "$exec_path" ]; then
46
+ echo "❌ Executável FTC CLI não encontrado!" >&2
47
+ echo " Procurado em: $exec_path" >&2
48
+ echo "💡 Execute 'npm run build' para compilar o projeto." >&2
49
+ exit 1
50
+ fi
51
+
52
+ # Define permissões de execução
53
+ chmod +x "$exec_path" 2>/dev/null || true
54
+ }
55
+
56
+ # Função principal
57
+ main() {
58
+ local platform=$(detect_platform)
59
+ local exec_path=$(get_executable_path "$platform")
60
+
61
+ # Verifica se o executável existe
62
+ check_executable "$exec_path"
63
+
64
+ # Executa o CLI
65
+ exec "$exec_path" "$@"
66
+ }
67
+
68
+ # Executa a função principal com todos os argumentos
69
+ main "$@"
package/bin/ftc.js ADDED
@@ -0,0 +1,77 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { spawn } = require('child_process');
4
+ const path = require('path');
5
+ const fs = require('fs');
6
+
7
+ // Detecta a plataforma
8
+ const platform = process.platform;
9
+ const isWindows = platform === 'win32';
10
+
11
+ // Caminho para o executável .NET baseado na plataforma
12
+ function getExecutablePath() {
13
+ const baseDir = path.join(__dirname);
14
+
15
+ if (isWindows) {
16
+ return path.join(baseDir, 'win-x64', 'ftc.cli.exe');
17
+ } else if (platform === 'darwin') {
18
+ return path.join(baseDir, 'osx-x64', 'ftc.cli');
19
+ } else {
20
+ return path.join(baseDir, 'linux-x64', 'ftc.cli');
21
+ }
22
+ }
23
+
24
+ // Verifica se o executável existe
25
+ function checkExecutable() {
26
+ const execPath = getExecutablePath();
27
+ if (!fs.existsSync(execPath)) {
28
+ console.error('❌ Executável FTC CLI não encontrado!');
29
+ console.error(` Procurado em: ${execPath}`);
30
+ console.error('💡 Execute "npm run build" para compilar o projeto.');
31
+ process.exit(1);
32
+ }
33
+ return execPath;
34
+ }
35
+
36
+ // Função principal
37
+ function main() {
38
+ try {
39
+ // Verifica se o executável existe
40
+ const execPath = checkExecutable();
41
+
42
+ // Define permissões de execução (Linux/macOS)
43
+ if (!isWindows) {
44
+ try {
45
+ fs.chmodSync(execPath, 0o755);
46
+ } catch (error) {
47
+ // Ignora erros de permissão
48
+ }
49
+ }
50
+
51
+ // Executa o CLI .NET
52
+ const child = spawn(execPath, process.argv.slice(2), {
53
+ stdio: 'inherit',
54
+ cwd: process.cwd()
55
+ });
56
+
57
+ child.on('error', (error) => {
58
+ console.error('❌ Erro ao executar FTC CLI:', error.message);
59
+ process.exit(1);
60
+ });
61
+
62
+ child.on('close', (code) => {
63
+ process.exit(code);
64
+ });
65
+
66
+ } catch (error) {
67
+ console.error('❌ Erro fatal:', error.message);
68
+ process.exit(1);
69
+ }
70
+ }
71
+
72
+ // Executa se for o arquivo principal
73
+ if (require.main === module) {
74
+ main();
75
+ }
76
+
77
+ module.exports = { main, getExecutablePath, checkExecutable };
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@followthecode/cli",
3
- "version": "1.2.4",
3
+ "version": "1.2.5",
4
4
  "description": "CLI tool for Git repository analysis and data collection",
5
5
  "main": "index.js",
6
6
  "license": "UNLICENSED",
@@ -13,28 +13,25 @@
13
13
  },
14
14
  "scripts": {
15
15
  "prepublishOnly": "npm run build",
16
- "build": "npm run build:win && npm run build:mac && npm run build:linux && npm run copy-config && npm run set-permissions",
16
+ "build": "npm run build:all && npm run setup",
17
+ "build:all": "npm run build:win && npm run build:mac && npm run build:linux",
17
18
  "build:win": "dotnet publish ftc.cli.csproj -c Release -r win-x64 -o ./bin/win-x64",
18
19
  "build:mac": "dotnet publish ftc.cli.csproj -c Release -r osx-x64 -o ./bin/osx-x64",
19
20
  "build:linux": "dotnet publish ftc.cli.csproj -c Release -r linux-x64 -o ./bin/linux-x64",
21
+ "setup": "npm run copy-config && npm run set-permissions",
20
22
  "copy-config": "node scripts/copy-config.js",
21
23
  "set-permissions": "node scripts/set-permissions.js",
22
- "postinstall": "node scripts/set-permissions.js && node scripts/install-wrapper.js",
23
- "fix-permissions": "node scripts/fix-permissions.js",
24
+ "postinstall": "npm run setup && node scripts/install-wrapper.js",
24
25
  "test": "dotnet test",
25
- "test-permissions": "node scripts/test-permissions.js",
26
- "test-linux": "bash scripts/test-linux-permissions.sh",
27
- "test-local-install": "node scripts/test-local-install.js",
28
- "test-docker-real": "bash scripts/test-docker-real.sh",
29
- "test-wsl": "wsl bash scripts/test-wsl-basic.sh",
30
- "validate-wsl": "wsl bash scripts/validate-wsl.sh",
31
- "validate-wsl-simple": "wsl bash scripts/validate-wsl-simple.sh",
32
- "validate-wsl-no-sudo": "wsl bash scripts/validate-wsl-no-sudo.sh",
26
+ "test:install": "npm run test:install:win",
27
+ "test:install:win": "powershell -ExecutionPolicy Bypass -File scripts/test-simple.ps1",
28
+ "test:install:linux": "bash scripts/test-installation.sh",
29
+ "test:install:wsl": "wsl bash scripts/test-installation.sh",
33
30
  "clean": "dotnet clean",
34
- "publish:patch": "node scripts/publish.js --patch",
35
- "publish:minor": "node scripts/publish.js --minor",
36
- "publish:major": "node scripts/publish.js --major",
37
- "publish:manual": "node scripts/publish.js"
31
+ "publish": "node scripts/publish.js",
32
+ "publish:patch": "npm run publish -- --patch",
33
+ "publish:minor": "npm run publish -- --minor",
34
+ "publish:major": "npm run publish -- --major"
38
35
  },
39
36
  "keywords": [
40
37
  "git",
@@ -85,13 +82,21 @@
85
82
  "README.md",
86
83
  "LICENSE",
87
84
  "TROUBLESHOOTING.md",
85
+ "TROUBLESHOOTING_INSTALL.md",
88
86
  "TESTING.md"
89
87
  ],
90
88
  "dependencies": {
91
- "@followthecode/cli": "^1.0.1",
92
89
  "node-fetch": "^3.3.0"
93
90
  },
94
91
  "devDependencies": {
95
92
  "@types/node": "^18.0.0"
93
+ },
94
+ "overrides": {
95
+ "node-domexception": {
96
+ "node-domexception": "npm:undici@^5.0.0"
97
+ }
98
+ },
99
+ "resolutions": {
100
+ "node-domexception": "npm:undici@^5.0.0"
96
101
  }
97
102
  }
@@ -0,0 +1,58 @@
1
+ # 📁 Scripts do FTC CLI
2
+
3
+ Este diretório contém os scripts essenciais para build, teste e publicação do FTC CLI.
4
+
5
+ ## 🔧 Scripts Essenciais
6
+
7
+ ### Build e Setup
8
+ - **`copy-config.js`** - Copia arquivos de configuração para todas as plataformas
9
+ - **`set-permissions.js`** - Define permissões de execução para os binários
10
+ - **`install-wrapper.js`** - Instala os wrappers Node.js e Shell
11
+
12
+ ### Testes
13
+ - **`test-simple.ps1`** - Teste simples de instalação (Windows)
14
+ - **`test-installation.sh`** - Teste simples de instalação (Linux/macOS)
15
+
16
+ ### Publicação
17
+ - **`publish.js`** - Script de publicação automatizada
18
+
19
+ ## 🚀 Uso
20
+
21
+ ```bash
22
+ # Build completo
23
+ npm run build
24
+
25
+ # Teste de instalação
26
+ npm run test:install # Windows
27
+ npm run test:install:linux # Linux
28
+ npm run test:install:wsl # WSL
29
+
30
+ # Publicação
31
+ npm run publish:patch
32
+ npm run publish:minor
33
+ npm run publish:major
34
+ ```
35
+
36
+ ## 📋 Estrutura Simplificada
37
+
38
+ A estrutura foi simplificada de **22 scripts** para apenas **6 scripts essenciais**:
39
+
40
+ ### ❌ Removidos (16 scripts):
41
+ - Scripts duplicados de teste
42
+ - Scripts de validação WSL redundantes
43
+ - Scripts de permissões específicos
44
+ - Scripts de Docker desnecessários
45
+ - Scripts de instalação local duplicados
46
+
47
+ ### ✅ Mantidos (6 scripts):
48
+ - Scripts essenciais para build
49
+ - Scripts de teste simples e funcionais
50
+ - Script de publicação
51
+
52
+ ## 🎯 Benefícios
53
+
54
+ - ✅ **90% menos scripts** (22 → 6)
55
+ - ✅ **Manutenção mais fácil**
56
+ - ✅ **Menos confusão**
57
+ - ✅ **Funcionalidade mantida**
58
+ - ✅ **Testes mais rápidos**
@@ -1,58 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const fs = require('fs');
4
- const path = require('path');
5
-
6
- console.log('🔧 Corrigindo permissões de execução...');
7
-
8
- // Função para definir permissões recursivamente
9
- function setExecutablePermissions(dir) {
10
- if (!fs.existsSync(dir)) {
11
- console.warn(`⚠️ Diretório não encontrado: ${dir}`);
12
- return;
13
- }
14
-
15
- const items = fs.readdirSync(dir);
16
-
17
- items.forEach(item => {
18
- const fullPath = path.join(dir, item);
19
- const stat = fs.statSync(fullPath);
20
-
21
- if (stat.isDirectory()) {
22
- setExecutablePermissions(fullPath);
23
- } else if (stat.isFile()) {
24
- // Define permissões de execução para arquivos binários
25
- const isExecutable = item === 'ftc.cli' || item === 'ftc.js' || item.endsWith('.exe');
26
-
27
- if (isExecutable) {
28
- try {
29
- fs.chmodSync(fullPath, 0o755);
30
- console.log(`✅ Permissões corrigidas: ${fullPath}`);
31
- } catch (error) {
32
- console.error(`❌ Erro ao corrigir permissões para ${fullPath}:`, error.message);
33
- }
34
- }
35
- }
36
- });
37
- }
38
-
39
- // Define permissões para os diretórios das plataformas
40
- const platforms = ['linux-x64', 'osx-x64'];
41
- platforms.forEach(platform => {
42
- const platformDir = path.join('bin', platform);
43
- setExecutablePermissions(platformDir);
44
- });
45
-
46
- // Define permissões para o arquivo ftc.js
47
- const ftcJsPath = path.join('bin', 'ftc.js');
48
- if (fs.existsSync(ftcJsPath)) {
49
- try {
50
- fs.chmodSync(ftcJsPath, 0o755);
51
- console.log(`✅ Permissões corrigidas: ${ftcJsPath}`);
52
- } catch (error) {
53
- console.error(`❌ Erro ao corrigir permissões para ${ftcJsPath}:`, error.message);
54
- }
55
- }
56
-
57
- console.log('✅ Correção de permissões concluída!');
58
- console.log('💡 Se ainda houver problemas, execute manualmente: chmod +x bin/linux-x64/ftc.cli');