@followthecode/cli 1.2.26 → 1.2.29

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/bin/ftc CHANGED
@@ -1,99 +1,121 @@
1
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 copiar arquivo de configuração
42
- copy_config_file() {
43
- local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
44
- local current_dir="$(pwd)"
45
- local config_dest="$current_dir/appsettings.json"
46
-
47
- # Se já existe no diretório atual, não copia
48
- if [ -f "$config_dest" ]; then
49
- return
50
- fi
51
-
52
- # Tenta diferentes locais para o arquivo de configuração
53
- local possible_sources=(
54
- "$script_dir/linux-x64/appsettings.json"
55
- "$script_dir/win-x64/appsettings.json"
56
- "$script_dir/osx-x64/appsettings.json"
57
- "$script_dir/../appsettings.json"
58
- )
59
-
60
- for source in "${possible_sources[@]}"; do
61
- if [ -f "$source" ]; then
62
- cp "$source" "$config_dest" 2>/dev/null || true
63
- break
64
- fi
65
- done
66
- }
67
-
68
- # Função para verificar se o executável existe
69
- check_executable() {
70
- local exec_path=$1
71
-
72
- if [ ! -f "$exec_path" ]; then
73
- echo "❌ Executável FTC CLI não encontrado!" >&2
74
- echo " Procurado em: $exec_path" >&2
75
- echo "💡 Execute 'npm run build' para compilar o projeto." >&2
76
- exit 1
77
- fi
78
-
79
- # Define permissões de execução
80
- chmod +x "$exec_path" 2>/dev/null || true
81
- }
82
-
83
- # Função principal
84
- main() {
85
- local platform=$(detect_platform)
86
- local exec_path=$(get_executable_path "$platform")
87
-
88
- # Verifica se o executável existe
89
- check_executable "$exec_path"
90
-
91
- # Copia arquivo de configuração para o diretório atual
92
- copy_config_file
93
-
94
- # Executa o CLI
95
- exec "$exec_path" "$@"
96
- }
97
-
98
- # Executa a função principal com todos os argumentos
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 copiar arquivo de configuração
42
+ copy_config_file() {
43
+ local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
44
+ local current_dir="$(pwd)"
45
+ local config_dest="$current_dir/appsettings.json"
46
+
47
+ # Se já existe no diretório atual, não copia
48
+ if [ -f "$config_dest" ]; then
49
+ return
50
+ fi
51
+
52
+ # Tenta diferentes locais para o arquivo de configuração
53
+ local possible_sources=(
54
+ "$script_dir/linux-x64/appsettings.json"
55
+ "$script_dir/win-x64/appsettings.json"
56
+ "$script_dir/osx-x64/appsettings.json"
57
+ "$script_dir/../appsettings.json"
58
+ )
59
+
60
+ for source in "${possible_sources[@]}"; do
61
+ if [ -f "$source" ]; then
62
+ cp "$source" "$config_dest" 2>/dev/null || true
63
+ break
64
+ fi
65
+ done
66
+ }
67
+
68
+ # Função para verificar se o executável existe
69
+ check_executable() {
70
+ local exec_path=$1
71
+
72
+ if [ ! -f "$exec_path" ]; then
73
+ echo "❌ Executável FTC CLI não encontrado!" >&2
74
+ echo " Procurado em: $exec_path" >&2
75
+ echo "💡 Execute 'npm run build' para compilar o projeto." >&2
76
+ exit 1
77
+ fi
78
+
79
+ # Define permissões de execução
80
+ chmod +x "$exec_path" 2>/dev/null || true
81
+ }
82
+
83
+ # Função principal
84
+ main() {
85
+ local platform=$(detect_platform)
86
+ local exec_path=$(get_executable_path "$platform")
87
+
88
+ # Verifica se o executável existe
89
+ check_executable "$exec_path"
90
+
91
+ # Copia arquivo de configuração para o diretório atual
92
+ copy_config_file
93
+
94
+ # Configura LD_LIBRARY_PATH para Linux
95
+ if [ "$platform" = "linux" ]; then
96
+ local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
97
+ local lib_dir="$script_dir/linux-x64"
98
+
99
+ if [ -d "$lib_dir" ]; then
100
+ export LD_LIBRARY_PATH="$lib_dir:$LD_LIBRARY_PATH"
101
+ echo "🔧 Configurando LD_LIBRARY_PATH: $lib_dir" >&2
102
+
103
+ # Verifica se as dependências básicas estão disponíveis
104
+ if ! ldconfig -p | grep -q "libssl" 2>/dev/null; then
105
+ echo "⚠️ libssl não encontrado. Execute: sudo apt-get install -y libssl-dev" >&2
106
+ fi
107
+ if ! ldconfig -p | grep -q "libcurl" 2>/dev/null; then
108
+ echo "⚠️ libcurl não encontrado. Execute: sudo apt-get install -y libcurl4-openssl-dev" >&2
109
+ fi
110
+ if ! ldconfig -p | grep -q "libz" 2>/dev/null; then
111
+ echo "⚠️ libz não encontrado. Execute: sudo apt-get install -y zlib1g-dev" >&2
112
+ fi
113
+ fi
114
+ fi
115
+
116
+ # Executa o CLI
117
+ exec "$exec_path" "$@"
118
+ }
119
+
120
+ # Executa a função principal com todos os argumentos
99
121
  main "$@"
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.26",
3
+ "version": "1.2.29",
4
4
  "description": "CLI tool for Git repository analysis and data collection",
5
5
  "main": "index.js",
6
6
  "license": "UNLICENSED",
@@ -2,9 +2,83 @@
2
2
 
3
3
  const fs = require('fs');
4
4
  const path = require('path');
5
+ const { execSync, spawn } = require('child_process');
5
6
 
6
7
  console.log('🔧 Configurando FTC CLI após instalação...');
7
8
 
9
+ // Função para verificar e instalar dependências nativas no Linux
10
+ function checkAndInstallNativeDependencies() {
11
+ if (process.platform !== 'linux') {
12
+ console.log('📋 Sistema não é Linux, pulando verificação de dependências nativas');
13
+ return true;
14
+ }
15
+
16
+ console.log('🔍 Verificando dependências nativas...');
17
+
18
+ try {
19
+ // Verifica se as bibliotecas necessárias estão disponíveis
20
+ const requiredLibs = ['libssl', 'libcurl', 'libz'];
21
+ const missingLibs = [];
22
+
23
+ for (const lib of requiredLibs) {
24
+ try {
25
+ execSync(`ldconfig -p | grep -q "${lib}"`, { stdio: 'pipe' });
26
+ console.log(`✅ ${lib} encontrado`);
27
+ } catch (error) {
28
+ missingLibs.push(lib);
29
+ console.log(`❌ ${lib} não encontrado`);
30
+ }
31
+ }
32
+
33
+ // Verifica se a biblioteca do LibGit2Sharp está presente
34
+ const libgit2Path = path.join(__dirname, '..', 'bin', 'linux-x64', 'libgit2-3f4182d.so');
35
+ if (fs.existsSync(libgit2Path)) {
36
+ console.log('✅ Biblioteca LibGit2Sharp encontrada');
37
+
38
+ // Tenta definir LD_LIBRARY_PATH para incluir o diretório da biblioteca
39
+ const libDir = path.join(__dirname, '..', 'bin', 'linux-x64');
40
+ const currentLdPath = process.env.LD_LIBRARY_PATH || '';
41
+ const newLdPath = currentLdPath ? `${libDir}:${currentLdPath}` : libDir;
42
+
43
+ console.log(`📋 Configurando LD_LIBRARY_PATH: ${newLdPath}`);
44
+
45
+ // Salva a configuração em um arquivo para ser carregado pelo wrapper
46
+ const wrapperConfig = `#!/bin/bash
47
+ export LD_LIBRARY_PATH="${newLdPath}:\$LD_LIBRARY_PATH"
48
+ exec "$@"
49
+ `;
50
+
51
+ const wrapperPath = path.join(__dirname, '..', 'bin', 'ftc-wrapper.sh');
52
+ fs.writeFileSync(wrapperPath, wrapperConfig);
53
+ fs.chmodSync(wrapperPath, 0o755);
54
+ console.log('✅ Wrapper de biblioteca criado');
55
+ } else {
56
+ console.log('❌ Biblioteca LibGit2Sharp não encontrada');
57
+ }
58
+
59
+ if (missingLibs.length > 0) {
60
+ console.log('⚠️ Algumas dependências nativas estão faltando. Tentando instalar...');
61
+
62
+ try {
63
+ // Tenta instalar as dependências
64
+ execSync('sudo apt-get update', { stdio: 'inherit' });
65
+ execSync('sudo apt-get install -y libssl-dev libcurl4-openssl-dev zlib1g-dev', { stdio: 'inherit' });
66
+ console.log('✅ Dependências nativas instaladas com sucesso!');
67
+ return true;
68
+ } catch (installError) {
69
+ console.warn('⚠️ Não foi possível instalar dependências automaticamente:', installError.message);
70
+ console.log('💡 Execute manualmente: sudo apt-get install -y libssl-dev libcurl4-openssl-dev zlib1g-dev');
71
+ return false;
72
+ }
73
+ }
74
+
75
+ return true;
76
+ } catch (error) {
77
+ console.warn('⚠️ Erro ao verificar dependências nativas:', error.message);
78
+ return false;
79
+ }
80
+ }
81
+
8
82
  // Função para copiar arquivo de configuração
9
83
  function copyConfigFile() {
10
84
  try {
@@ -67,12 +141,17 @@ function setPermissions() {
67
141
  }
68
142
 
69
143
  // Executa as configurações
144
+ const nativeDepsSuccess = checkAndInstallNativeDependencies();
70
145
  const configSuccess = copyConfigFile();
71
146
  const permissionsSuccess = setPermissions();
72
147
 
73
148
  if (configSuccess && permissionsSuccess) {
74
149
  console.log('🎉 FTC CLI configurado com sucesso!');
75
150
  console.log('💡 Execute: ftc --help');
151
+
152
+ if (!nativeDepsSuccess) {
153
+ console.log('⚠️ Dependências nativas podem precisar de instalação manual');
154
+ }
76
155
  } else {
77
156
  console.error('❌ Alguns problemas foram encontrados durante a configuração.');
78
157
  process.exit(1);