gitarsenal-cli 1.9.0 → 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 +37 -103
- 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
@@ -15,116 +15,38 @@ 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
|
+
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
|
-
console.log(chalk.
|
25
|
-
|
28
|
+
console.log(chalk.red('❌ Virtual environment not found. Please reinstall the package:'));
|
29
|
+
console.log(chalk.yellow(' npm uninstall -g gitarsenal-cli'));
|
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'));
|
35
|
+
return false;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Check if status file exists (indicates successful installation)
|
39
|
+
if (fs.existsSync(statusFile)) {
|
26
40
|
try {
|
27
|
-
|
28
|
-
|
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
|
-
|
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(', ')}`));
|
117
44
|
} catch (error) {
|
118
|
-
console.log(chalk.
|
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;
|
45
|
+
console.log(chalk.gray('✅ Virtual environment found'));
|
124
46
|
}
|
125
47
|
}
|
126
48
|
|
127
|
-
//
|
49
|
+
// Verify virtual environment structure
|
128
50
|
const pythonPath = isWindows ?
|
129
51
|
path.join(venvPath, 'Scripts', 'python.exe') :
|
130
52
|
path.join(venvPath, 'bin', 'python');
|
@@ -133,6 +55,18 @@ async function activateVirtualEnvironment() {
|
|
133
55
|
path.join(venvPath, 'Scripts', 'pip.exe') :
|
134
56
|
path.join(venvPath, 'bin', 'pip');
|
135
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
|
+
|
136
70
|
// Update PATH to prioritize virtual environment
|
137
71
|
const pathSeparator = isWindows ? ';' : ':';
|
138
72
|
const venvBinPath = isWindows ?
|
@@ -147,13 +81,13 @@ async function activateVirtualEnvironment() {
|
|
147
81
|
process.env.PYTHON_EXECUTABLE = pythonPath;
|
148
82
|
process.env.PIP_EXECUTABLE = pipPath;
|
149
83
|
|
84
|
+
console.log(chalk.green('✅ Virtual environment activated successfully'));
|
85
|
+
|
150
86
|
return true;
|
151
87
|
}
|
152
88
|
|
153
89
|
// Activate virtual environment
|
154
|
-
(
|
155
|
-
await activateVirtualEnvironment();
|
156
|
-
})();
|
90
|
+
activateVirtualEnvironment();
|
157
91
|
|
158
92
|
// Check for updates
|
159
93
|
updateNotifier({ pkg }).notify();
|
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
|
|