gitarsenal-cli 1.9.0 → 1.9.1
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/gitarsenal.js +6 -105
- package/package.json +1 -1
package/bin/gitarsenal.js
CHANGED
@@ -15,113 +15,16 @@ const { spawn } = require('child_process');
|
|
15
15
|
const fs = require('fs');
|
16
16
|
|
17
17
|
// Function to activate virtual environment
|
18
|
-
|
18
|
+
function activateVirtualEnvironment() {
|
19
19
|
const isWindows = process.platform === 'win32';
|
20
20
|
const venvPath = path.join(__dirname, '..', '.venv');
|
21
21
|
|
22
22
|
// Check if virtual environment exists
|
23
23
|
if (!fs.existsSync(venvPath)) {
|
24
|
-
console.log(chalk.
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
const { execSync } = require('child_process');
|
29
|
-
|
30
|
-
// Check if uv is available and install it if needed
|
31
|
-
let uvAvailable = false;
|
32
|
-
try {
|
33
|
-
execSync('uv --version', { stdio: 'pipe' });
|
34
|
-
uvAvailable = true;
|
35
|
-
} catch (error) {
|
36
|
-
console.log(chalk.yellow('⚠️ uv not found. Attempting to install...'));
|
37
|
-
|
38
|
-
// Try different methods to install uv
|
39
|
-
const installMethods = [
|
40
|
-
'curl -LsSf https://astral.sh/uv/install.sh | sh',
|
41
|
-
'pip install uv',
|
42
|
-
'pip3 install uv',
|
43
|
-
'cargo install uv'
|
44
|
-
];
|
45
|
-
|
46
|
-
for (const method of installMethods) {
|
47
|
-
try {
|
48
|
-
console.log(chalk.gray(`🔄 Trying to install uv with: ${method}`));
|
49
|
-
|
50
|
-
if (method.includes('curl')) {
|
51
|
-
// For curl installation, we need to handle the shell script
|
52
|
-
execSync(method, {
|
53
|
-
env: { ...process.env, SHELL: '/bin/bash' },
|
54
|
-
stdio: 'inherit'
|
55
|
-
});
|
56
|
-
} else {
|
57
|
-
execSync(method, { stdio: 'inherit' });
|
58
|
-
}
|
59
|
-
|
60
|
-
// Verify installation
|
61
|
-
execSync('uv --version', { stdio: 'pipe' });
|
62
|
-
console.log(chalk.green('✅ uv installed successfully!'));
|
63
|
-
uvAvailable = true;
|
64
|
-
break;
|
65
|
-
} catch (installError) {
|
66
|
-
console.log(chalk.gray(`⚠️ ${method} failed, trying next...`));
|
67
|
-
}
|
68
|
-
}
|
69
|
-
}
|
70
|
-
|
71
|
-
if (uvAvailable) {
|
72
|
-
console.log(chalk.gray('🔄 Creating virtual environment with uv...'));
|
73
|
-
|
74
|
-
// Create virtual environment with uv
|
75
|
-
execSync('uv venv', {
|
76
|
-
cwd: path.join(__dirname, '..'),
|
77
|
-
stdio: 'inherit'
|
78
|
-
});
|
79
|
-
|
80
|
-
console.log(chalk.green('✅ Virtual environment created with uv!'));
|
81
|
-
|
82
|
-
// Install packages with uv
|
83
|
-
console.log(chalk.gray('🔄 Installing Python packages with uv...'));
|
84
|
-
execSync('uv pip install modal gitingest requests', {
|
85
|
-
cwd: path.join(__dirname, '..'),
|
86
|
-
stdio: 'inherit'
|
87
|
-
});
|
88
|
-
|
89
|
-
console.log(chalk.green('✅ Python packages installed successfully!'));
|
90
|
-
|
91
|
-
} else {
|
92
|
-
console.log(chalk.gray('⚠️ uv not available, trying Python venv...'));
|
93
|
-
|
94
|
-
// Fallback to Python venv
|
95
|
-
const pythonCmd = isWindows ? 'python' : 'python3';
|
96
|
-
|
97
|
-
// Create virtual environment
|
98
|
-
execSync(`${pythonCmd} -m venv "${venvPath}"`, {
|
99
|
-
stdio: 'inherit'
|
100
|
-
});
|
101
|
-
|
102
|
-
console.log(chalk.green('✅ Virtual environment created with Python venv!'));
|
103
|
-
|
104
|
-
// Install packages
|
105
|
-
const pipPath = isWindows ?
|
106
|
-
path.join(venvPath, 'Scripts', 'pip.exe') :
|
107
|
-
path.join(venvPath, 'bin', 'pip');
|
108
|
-
|
109
|
-
console.log(chalk.gray('🔄 Installing Python packages...'));
|
110
|
-
execSync(`"${pipPath}" install modal gitingest requests`, {
|
111
|
-
stdio: 'inherit'
|
112
|
-
});
|
113
|
-
|
114
|
-
console.log(chalk.green('✅ Python packages installed successfully!'));
|
115
|
-
}
|
116
|
-
|
117
|
-
} catch (error) {
|
118
|
-
console.log(chalk.red(`❌ Failed to create virtual environment: ${error.message}`));
|
119
|
-
console.log(chalk.yellow('💡 Please run manually:'));
|
120
|
-
console.log(chalk.yellow(' cd /root/.nvm/versions/node/v22.18.0/lib/node_modules/gitarsenal-cli'));
|
121
|
-
console.log(chalk.yellow(' uv venv'));
|
122
|
-
console.log(chalk.yellow(' uv pip install modal gitingest requests'));
|
123
|
-
return false;
|
124
|
-
}
|
24
|
+
console.log(chalk.red('❌ Virtual environment not found. Please reinstall the package:'));
|
25
|
+
console.log(chalk.yellow(' npm uninstall -g gitarsenal-cli'));
|
26
|
+
console.log(chalk.yellow(' npm install -g gitarsenal-cli'));
|
27
|
+
return false;
|
125
28
|
}
|
126
29
|
|
127
30
|
// Set environment variables to use the virtual environment
|
@@ -151,9 +54,7 @@ async function activateVirtualEnvironment() {
|
|
151
54
|
}
|
152
55
|
|
153
56
|
// Activate virtual environment
|
154
|
-
(
|
155
|
-
await activateVirtualEnvironment();
|
156
|
-
})();
|
57
|
+
activateVirtualEnvironment();
|
157
58
|
|
158
59
|
// Check for updates
|
159
60
|
updateNotifier({ pkg }).notify();
|