gitarsenal-cli 1.9.1 → 1.9.2
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/.venv_status.json +1 -0
- package/bin/gitarsenal.js +34 -1
- package/package.json +1 -1
- package/scripts/postinstall.js +62 -27
@@ -0,0 +1 @@
|
|
1
|
+
{"created":"2025-08-02T15:39:55.524Z","packages":["modal","gitingest","requests"],"uv_version":"uv 0.8.3 (7e78f54e7 2025-07-24)"}
|
package/bin/gitarsenal.js
CHANGED
@@ -18,16 +18,35 @@ const fs = require('fs');
|
|
18
18
|
function activateVirtualEnvironment() {
|
19
19
|
const isWindows = process.platform === 'win32';
|
20
20
|
const venvPath = path.join(__dirname, '..', '.venv');
|
21
|
+
const statusFile = path.join(__dirname, '..', '.venv_status.json');
|
22
|
+
|
23
|
+
// Debug: Log the path we're looking for
|
24
|
+
console.log(chalk.gray(`🔍 Looking for virtual environment at: ${venvPath}`));
|
21
25
|
|
22
26
|
// Check if virtual environment exists
|
23
27
|
if (!fs.existsSync(venvPath)) {
|
24
28
|
console.log(chalk.red('❌ Virtual environment not found. Please reinstall the package:'));
|
25
29
|
console.log(chalk.yellow(' npm uninstall -g gitarsenal-cli'));
|
26
30
|
console.log(chalk.yellow(' npm install -g gitarsenal-cli'));
|
31
|
+
console.log(chalk.yellow(''));
|
32
|
+
console.log(chalk.yellow('💡 Or run the postinstall script manually:'));
|
33
|
+
console.log(chalk.yellow(' cd /root/.nvm/versions/node/v22.18.0/lib/node_modules/gitarsenal-cli'));
|
34
|
+
console.log(chalk.yellow(' node scripts/postinstall.js'));
|
27
35
|
return false;
|
28
36
|
}
|
29
37
|
|
30
|
-
//
|
38
|
+
// Check if status file exists (indicates successful installation)
|
39
|
+
if (fs.existsSync(statusFile)) {
|
40
|
+
try {
|
41
|
+
const status = JSON.parse(fs.readFileSync(statusFile, 'utf8'));
|
42
|
+
console.log(chalk.gray(`✅ Virtual environment created: ${status.created}`));
|
43
|
+
console.log(chalk.gray(`📦 Packages: ${status.packages.join(', ')}`));
|
44
|
+
} catch (error) {
|
45
|
+
console.log(chalk.gray('✅ Virtual environment found'));
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
// Verify virtual environment structure
|
31
50
|
const pythonPath = isWindows ?
|
32
51
|
path.join(venvPath, 'Scripts', 'python.exe') :
|
33
52
|
path.join(venvPath, 'bin', 'python');
|
@@ -36,6 +55,18 @@ function activateVirtualEnvironment() {
|
|
36
55
|
path.join(venvPath, 'Scripts', 'pip.exe') :
|
37
56
|
path.join(venvPath, 'bin', 'pip');
|
38
57
|
|
58
|
+
if (!fs.existsSync(pythonPath)) {
|
59
|
+
console.log(chalk.red('❌ Virtual environment is corrupted (Python not found)'));
|
60
|
+
console.log(chalk.yellow('💡 Please reinstall the package'));
|
61
|
+
return false;
|
62
|
+
}
|
63
|
+
|
64
|
+
if (!fs.existsSync(pipPath)) {
|
65
|
+
console.log(chalk.red('❌ Virtual environment is corrupted (pip not found)'));
|
66
|
+
console.log(chalk.yellow('💡 Please reinstall the package'));
|
67
|
+
return false;
|
68
|
+
}
|
69
|
+
|
39
70
|
// Update PATH to prioritize virtual environment
|
40
71
|
const pathSeparator = isWindows ? ';' : ':';
|
41
72
|
const venvBinPath = isWindows ?
|
@@ -50,6 +81,8 @@ function activateVirtualEnvironment() {
|
|
50
81
|
process.env.PYTHON_EXECUTABLE = pythonPath;
|
51
82
|
process.env.PIP_EXECUTABLE = pipPath;
|
52
83
|
|
84
|
+
console.log(chalk.green('✅ Virtual environment activated successfully'));
|
85
|
+
|
53
86
|
return true;
|
54
87
|
}
|
55
88
|
|
package/package.json
CHANGED
package/scripts/postinstall.js
CHANGED
@@ -19,8 +19,8 @@ const originalScriptPath = path.join(__dirname, '..', '..', '..', 'mcp-server',
|
|
19
19
|
async function checkAndInstallUv() {
|
20
20
|
try {
|
21
21
|
// Check if uv is already installed
|
22
|
-
await execAsync('uv --version');
|
23
|
-
console.log(chalk.green(
|
22
|
+
const { stdout } = await execAsync('uv --version');
|
23
|
+
console.log(chalk.green(`✅ uv is already installed: ${stdout.trim()}`));
|
24
24
|
return true;
|
25
25
|
} catch (error) {
|
26
26
|
console.log(chalk.yellow('⚠️ uv not found. Attempting to install...'));
|
@@ -32,7 +32,7 @@ async function checkAndInstallUv() {
|
|
32
32
|
'pip3 install uv',
|
33
33
|
'cargo install uv'
|
34
34
|
];
|
35
|
-
|
35
|
+
|
36
36
|
for (const method of installMethods) {
|
37
37
|
try {
|
38
38
|
console.log(chalk.gray(`🔄 Trying to install uv with: ${method}`));
|
@@ -44,15 +44,15 @@ async function checkAndInstallUv() {
|
|
44
44
|
stdio: 'inherit'
|
45
45
|
});
|
46
46
|
} else {
|
47
|
-
await execAsync(method);
|
47
|
+
await execAsync(method, { stdio: 'inherit' });
|
48
48
|
}
|
49
49
|
|
50
50
|
// Verify installation
|
51
|
-
await execAsync('uv --version');
|
52
|
-
console.log(chalk.green(
|
51
|
+
const { stdout } = await execAsync('uv --version');
|
52
|
+
console.log(chalk.green(`✅ uv installed successfully: ${stdout.trim()}`));
|
53
53
|
return true;
|
54
54
|
} catch (installError) {
|
55
|
-
console.log(chalk.gray(`⚠️ ${method} failed
|
55
|
+
console.log(chalk.gray(`⚠️ ${method} failed: ${installError.message}`));
|
56
56
|
}
|
57
57
|
}
|
58
58
|
|
@@ -68,25 +68,21 @@ async function checkAndInstallUv() {
|
|
68
68
|
// Function to create and activate virtual environment using uv
|
69
69
|
async function createVirtualEnvironment() {
|
70
70
|
const packages = ['modal', 'gitingest', 'requests'];
|
71
|
+
const packageDir = path.join(__dirname, '..');
|
71
72
|
|
72
73
|
console.log(chalk.yellow(`📦 Creating virtual environment with uv and installing packages: ${packages.join(', ')}`));
|
74
|
+
console.log(chalk.gray(`📁 Working directory: ${packageDir}`));
|
73
75
|
|
74
76
|
try {
|
75
77
|
// First, ensure uv is available
|
76
78
|
let uvAvailable = false;
|
77
79
|
try {
|
78
|
-
await execAsync('uv --version');
|
80
|
+
const { stdout } = await execAsync('uv --version');
|
81
|
+
console.log(chalk.green(`✅ uv found: ${stdout.trim()}`));
|
79
82
|
uvAvailable = true;
|
80
83
|
} catch (error) {
|
81
84
|
console.log(chalk.yellow('⚠️ uv not found, attempting to install...'));
|
82
|
-
await checkAndInstallUv();
|
83
|
-
try {
|
84
|
-
await execAsync('uv --version');
|
85
|
-
uvAvailable = true;
|
86
|
-
} catch (installError) {
|
87
|
-
console.log(chalk.red('❌ Failed to install uv'));
|
88
|
-
return false;
|
89
|
-
}
|
85
|
+
uvAvailable = await checkAndInstallUv();
|
90
86
|
}
|
91
87
|
|
92
88
|
if (!uvAvailable) {
|
@@ -94,29 +90,53 @@ async function createVirtualEnvironment() {
|
|
94
90
|
return false;
|
95
91
|
}
|
96
92
|
|
93
|
+
// Check if virtual environment already exists
|
94
|
+
const venvPath = path.join(packageDir, '.venv');
|
95
|
+
if (await fs.pathExists(venvPath)) {
|
96
|
+
console.log(chalk.yellow('⚠️ Virtual environment already exists, removing it...'));
|
97
|
+
await fs.remove(venvPath);
|
98
|
+
}
|
99
|
+
|
97
100
|
console.log(chalk.gray(`🔄 Creating virtual environment with uv...`));
|
98
101
|
|
99
102
|
// Create virtual environment using uv
|
100
103
|
await execAsync('uv venv', {
|
101
|
-
cwd:
|
102
|
-
env: { ...process.env, PYTHONIOENCODING: 'utf-8' }
|
104
|
+
cwd: packageDir,
|
105
|
+
env: { ...process.env, PYTHONIOENCODING: 'utf-8' },
|
106
|
+
stdio: 'inherit'
|
103
107
|
});
|
104
108
|
|
109
|
+
// Verify virtual environment was created
|
110
|
+
if (!(await fs.pathExists(venvPath))) {
|
111
|
+
throw new Error('Virtual environment was not created');
|
112
|
+
}
|
113
|
+
|
105
114
|
console.log(chalk.green('✅ Virtual environment created successfully with uv!'));
|
106
115
|
|
107
116
|
console.log(chalk.gray(`🔄 Installing packages in virtual environment with uv...`));
|
108
117
|
|
109
118
|
// Install packages using uv pip
|
110
119
|
await execAsync(`uv pip install ${packages.join(' ')}`, {
|
111
|
-
cwd:
|
112
|
-
env: { ...process.env, PYTHONIOENCODING: 'utf-8' }
|
120
|
+
cwd: packageDir,
|
121
|
+
env: { ...process.env, PYTHONIOENCODING: 'utf-8' },
|
122
|
+
stdio: 'inherit'
|
113
123
|
});
|
114
124
|
|
115
125
|
console.log(chalk.green('✅ Python packages installed successfully in virtual environment!'));
|
116
126
|
|
127
|
+
// Verify packages are installed
|
128
|
+
const pythonPath = path.join(venvPath, 'bin', 'python');
|
129
|
+
for (const pkg of packages) {
|
130
|
+
try {
|
131
|
+
await execAsync(`${pythonPath} -c "import ${pkg}; print('${pkg} imported successfully')"`);
|
132
|
+
console.log(chalk.green(`✅ ${pkg} verified`));
|
133
|
+
} catch (error) {
|
134
|
+
console.log(chalk.yellow(`⚠️ ${pkg} verification failed: ${error.message}`));
|
135
|
+
}
|
136
|
+
}
|
137
|
+
|
117
138
|
// Create a script to activate the virtual environment
|
118
139
|
const isWindows = process.platform === 'win32';
|
119
|
-
const venvPath = path.join(__dirname, '..', '.venv');
|
120
140
|
|
121
141
|
const activateScript = isWindows ?
|
122
142
|
`@echo off
|
@@ -128,7 +148,7 @@ cd "$(dirname "$0")"
|
|
128
148
|
source ".venv/bin/activate"
|
129
149
|
exec "$@"`;
|
130
150
|
|
131
|
-
const activateScriptPath = path.join(
|
151
|
+
const activateScriptPath = path.join(packageDir, 'activate_venv' + (isWindows ? '.bat' : '.sh'));
|
132
152
|
await fs.writeFile(activateScriptPath, activateScript);
|
133
153
|
|
134
154
|
if (!isWindows) {
|
@@ -137,14 +157,23 @@ exec "$@"`;
|
|
137
157
|
|
138
158
|
console.log(chalk.green(`✅ Virtual environment activation script created: ${activateScriptPath}`));
|
139
159
|
|
160
|
+
// Create a status file to indicate successful installation
|
161
|
+
const statusFile = path.join(packageDir, '.venv_status.json');
|
162
|
+
await fs.writeJson(statusFile, {
|
163
|
+
created: new Date().toISOString(),
|
164
|
+
packages: packages,
|
165
|
+
uv_version: (await execAsync('uv --version')).stdout.trim()
|
166
|
+
});
|
167
|
+
|
168
|
+
console.log(chalk.green('✅ Virtual environment setup completed successfully!'));
|
169
|
+
|
140
170
|
return true;
|
141
171
|
} catch (error) {
|
142
172
|
console.log(chalk.red(`❌ Error creating virtual environment with uv: ${error.message}`));
|
143
173
|
console.log(chalk.yellow('💡 Please run manually:'));
|
174
|
+
console.log(chalk.yellow(' cd /root/.nvm/versions/node/v22.18.0/lib/node_modules/gitarsenal-cli'));
|
144
175
|
console.log(chalk.yellow(' uv venv'));
|
145
176
|
console.log(chalk.yellow(' uv pip install modal gitingest requests'));
|
146
|
-
console.log(chalk.yellow(' source .venv/bin/activate # On Unix/macOS'));
|
147
|
-
console.log(chalk.yellow(' .venv\\Scripts\\activate.bat # On Windows'));
|
148
177
|
return false;
|
149
178
|
}
|
150
179
|
}
|
@@ -186,13 +215,14 @@ async function checkGit() {
|
|
186
215
|
async function postinstall() {
|
187
216
|
try {
|
188
217
|
console.log(chalk.blue('📦 Running GitArsenal CLI postinstall script...'));
|
218
|
+
console.log(chalk.gray(`📁 Package directory: ${path.join(__dirname, '..')}`));
|
189
219
|
|
190
220
|
// Check Python first
|
191
221
|
console.log(chalk.blue('🔍 Checking Python installation...'));
|
192
222
|
const pythonOk = await checkPython();
|
193
223
|
if (!pythonOk) {
|
194
224
|
console.log(chalk.red('❌ Python is required for GitArsenal CLI'));
|
195
|
-
|
225
|
+
process.exit(1);
|
196
226
|
}
|
197
227
|
|
198
228
|
// Check Git
|
@@ -205,7 +235,12 @@ async function postinstall() {
|
|
205
235
|
|
206
236
|
// Install Python packages in virtual environment
|
207
237
|
console.log(chalk.blue('🔍 Installing Python dependencies in virtual environment...'));
|
208
|
-
await createVirtualEnvironment();
|
238
|
+
const venvCreated = await createVirtualEnvironment();
|
239
|
+
|
240
|
+
if (!venvCreated) {
|
241
|
+
console.log(chalk.red('❌ Failed to create virtual environment'));
|
242
|
+
process.exit(1);
|
243
|
+
}
|
209
244
|
|
210
245
|
// Create the Python directory if it doesn't exist
|
211
246
|
await fs.ensureDir(pythonScriptDir);
|
@@ -340,7 +375,7 @@ if __name__ == "__main__":
|
|
340
375
|
|
341
376
|
} catch (error) {
|
342
377
|
console.error(chalk.red(`❌ Error during postinstall: ${error.message}`));
|
343
|
-
|
378
|
+
process.exit(1);
|
344
379
|
}
|
345
380
|
}
|
346
381
|
|