gitarsenal-cli 1.8.8 → 1.8.9
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 +66 -4
- package/package.json +1 -1
package/bin/gitarsenal.js
CHANGED
@@ -15,14 +15,74 @@ const { spawn } = require('child_process');
|
|
15
15
|
const fs = require('fs');
|
16
16
|
|
17
17
|
// Function to activate virtual environment
|
18
|
-
function activateVirtualEnvironment() {
|
18
|
+
async 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.yellow('⚠️ Virtual environment not found.
|
25
|
-
|
24
|
+
console.log(chalk.yellow('⚠️ Virtual environment not found. Creating it automatically...'));
|
25
|
+
|
26
|
+
try {
|
27
|
+
// Try to create virtual environment with uv first
|
28
|
+
const { execSync } = require('child_process');
|
29
|
+
|
30
|
+
// Check if uv is available
|
31
|
+
try {
|
32
|
+
execSync('uv --version', { stdio: 'pipe' });
|
33
|
+
console.log(chalk.gray('🔄 Creating virtual environment with uv...'));
|
34
|
+
|
35
|
+
// Create virtual environment with uv
|
36
|
+
execSync('uv venv', {
|
37
|
+
cwd: path.join(__dirname, '..'),
|
38
|
+
stdio: 'inherit'
|
39
|
+
});
|
40
|
+
|
41
|
+
console.log(chalk.green('✅ Virtual environment created with uv!'));
|
42
|
+
|
43
|
+
// Install packages with uv
|
44
|
+
console.log(chalk.gray('🔄 Installing Python packages with uv...'));
|
45
|
+
execSync('uv pip install modal gitingest requests', {
|
46
|
+
cwd: path.join(__dirname, '..'),
|
47
|
+
stdio: 'inherit'
|
48
|
+
});
|
49
|
+
|
50
|
+
console.log(chalk.green('✅ Python packages installed successfully!'));
|
51
|
+
|
52
|
+
} catch (uvError) {
|
53
|
+
console.log(chalk.gray('⚠️ uv not available, trying Python venv...'));
|
54
|
+
|
55
|
+
// Fallback to Python venv
|
56
|
+
const pythonCmd = isWindows ? 'python' : 'python3';
|
57
|
+
|
58
|
+
// Create virtual environment
|
59
|
+
execSync(`${pythonCmd} -m venv "${venvPath}"`, {
|
60
|
+
stdio: 'inherit'
|
61
|
+
});
|
62
|
+
|
63
|
+
console.log(chalk.green('✅ Virtual environment created with Python venv!'));
|
64
|
+
|
65
|
+
// Install packages
|
66
|
+
const pipPath = isWindows ?
|
67
|
+
path.join(venvPath, 'Scripts', 'pip.exe') :
|
68
|
+
path.join(venvPath, 'bin', 'pip');
|
69
|
+
|
70
|
+
console.log(chalk.gray('🔄 Installing Python packages...'));
|
71
|
+
execSync(`"${pipPath}" install modal gitingest requests`, {
|
72
|
+
stdio: 'inherit'
|
73
|
+
});
|
74
|
+
|
75
|
+
console.log(chalk.green('✅ Python packages installed successfully!'));
|
76
|
+
}
|
77
|
+
|
78
|
+
} catch (error) {
|
79
|
+
console.log(chalk.red(`❌ Failed to create virtual environment: ${error.message}`));
|
80
|
+
console.log(chalk.yellow('💡 Please run manually:'));
|
81
|
+
console.log(chalk.yellow(' cd /root/.nvm/versions/node/v22.18.0/lib/node_modules/gitarsenal-cli'));
|
82
|
+
console.log(chalk.yellow(' uv venv'));
|
83
|
+
console.log(chalk.yellow(' uv pip install modal gitingest requests'));
|
84
|
+
return false;
|
85
|
+
}
|
26
86
|
}
|
27
87
|
|
28
88
|
// Set environment variables to use the virtual environment
|
@@ -52,7 +112,9 @@ function activateVirtualEnvironment() {
|
|
52
112
|
}
|
53
113
|
|
54
114
|
// Activate virtual environment
|
55
|
-
|
115
|
+
(async () => {
|
116
|
+
await activateVirtualEnvironment();
|
117
|
+
})();
|
56
118
|
|
57
119
|
// Check for updates
|
58
120
|
updateNotifier({ pkg }).notify();
|