gitarsenal-cli 1.8.5 → 1.8.7
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/activate_venv.sh +1 -1
- package/bin/gitarsenal.js +50 -12
- package/package.json +1 -1
- package/scripts/postinstall.js +39 -46
package/activate_venv.sh
CHANGED
package/bin/gitarsenal.js
CHANGED
@@ -11,6 +11,48 @@ const { runContainer } = require('../lib/sandbox');
|
|
11
11
|
const updateNotifier = require('update-notifier');
|
12
12
|
const pkg = require('../package.json');
|
13
13
|
const boxen = require('boxen');
|
14
|
+
const { spawn } = require('child_process');
|
15
|
+
const fs = require('fs');
|
16
|
+
|
17
|
+
// Function to activate virtual environment
|
18
|
+
function activateVirtualEnvironment() {
|
19
|
+
const isWindows = process.platform === 'win32';
|
20
|
+
const venvPath = path.join(__dirname, '..', '.venv');
|
21
|
+
|
22
|
+
// Check if virtual environment exists
|
23
|
+
if (!fs.existsSync(venvPath)) {
|
24
|
+
console.log(chalk.yellow('⚠️ Virtual environment not found. Please run: npm install'));
|
25
|
+
return false;
|
26
|
+
}
|
27
|
+
|
28
|
+
// Set environment variables to use the virtual environment
|
29
|
+
const pythonPath = isWindows ?
|
30
|
+
path.join(venvPath, 'Scripts', 'python.exe') :
|
31
|
+
path.join(venvPath, 'bin', 'python');
|
32
|
+
|
33
|
+
const pipPath = isWindows ?
|
34
|
+
path.join(venvPath, 'Scripts', 'pip.exe') :
|
35
|
+
path.join(venvPath, 'bin', 'pip');
|
36
|
+
|
37
|
+
// Update PATH to prioritize virtual environment
|
38
|
+
const pathSeparator = isWindows ? ';' : ':';
|
39
|
+
const venvBinPath = isWindows ?
|
40
|
+
path.join(venvPath, 'Scripts') :
|
41
|
+
path.join(venvPath, 'bin');
|
42
|
+
|
43
|
+
process.env.PATH = `${venvBinPath}${pathSeparator}${process.env.PATH}`;
|
44
|
+
process.env.VIRTUAL_ENV = venvPath;
|
45
|
+
process.env.PYTHONPATH = venvPath;
|
46
|
+
|
47
|
+
// Set Python executable path for child processes
|
48
|
+
process.env.PYTHON_EXECUTABLE = pythonPath;
|
49
|
+
process.env.PIP_EXECUTABLE = pipPath;
|
50
|
+
|
51
|
+
return true;
|
52
|
+
}
|
53
|
+
|
54
|
+
// Activate virtual environment
|
55
|
+
activateVirtualEnvironment();
|
14
56
|
|
15
57
|
// Check for updates
|
16
58
|
updateNotifier({ pkg }).notify();
|
@@ -302,11 +344,10 @@ async function handleKeysAdd(options) {
|
|
302
344
|
}
|
303
345
|
|
304
346
|
// Call Python script to add the key
|
305
|
-
const { spawn } = require('child_process');
|
306
|
-
const path = require('path');
|
307
347
|
const scriptPath = path.join(__dirname, '..', 'python', 'gitarsenal_keys.py');
|
348
|
+
const pythonExecutable = process.env.PYTHON_EXECUTABLE || 'python';
|
308
349
|
|
309
|
-
const pythonProcess = spawn(
|
350
|
+
const pythonProcess = spawn(pythonExecutable, [
|
310
351
|
scriptPath,
|
311
352
|
'add',
|
312
353
|
'--service', service,
|
@@ -341,11 +382,10 @@ async function handleKeysList() {
|
|
341
382
|
const spinner = ora('Fetching API keys...').start();
|
342
383
|
|
343
384
|
// Call Python script to list keys
|
344
|
-
const { spawn } = require('child_process');
|
345
|
-
const path = require('path');
|
346
385
|
const scriptPath = path.join(__dirname, '..', 'python', 'gitarsenal_keys.py');
|
386
|
+
const pythonExecutable = process.env.PYTHON_EXECUTABLE || 'python';
|
347
387
|
|
348
|
-
const pythonProcess = spawn(
|
388
|
+
const pythonProcess = spawn(pythonExecutable, [
|
349
389
|
scriptPath,
|
350
390
|
'list'
|
351
391
|
], { stdio: 'inherit' });
|
@@ -384,11 +424,10 @@ async function handleKeysView(options) {
|
|
384
424
|
}
|
385
425
|
|
386
426
|
// Call Python script to view the key
|
387
|
-
const { spawn } = require('child_process');
|
388
|
-
const path = require('path');
|
389
427
|
const scriptPath = path.join(__dirname, '..', 'python', 'gitarsenal_keys.py');
|
428
|
+
const pythonExecutable = process.env.PYTHON_EXECUTABLE || 'python';
|
390
429
|
|
391
|
-
const pythonProcess = spawn(
|
430
|
+
const pythonProcess = spawn(pythonExecutable, [
|
392
431
|
scriptPath,
|
393
432
|
'view',
|
394
433
|
'--service', service
|
@@ -446,11 +485,10 @@ async function handleKeysDelete(options) {
|
|
446
485
|
spinner.start();
|
447
486
|
|
448
487
|
// Call Python script to delete the key
|
449
|
-
const { spawn } = require('child_process');
|
450
|
-
const path = require('path');
|
451
488
|
const scriptPath = path.join(__dirname, '..', 'python', 'gitarsenal_keys.py');
|
489
|
+
const pythonExecutable = process.env.PYTHON_EXECUTABLE || 'python';
|
452
490
|
|
453
|
-
const pythonProcess = spawn(
|
491
|
+
const pythonProcess = spawn(pythonExecutable, [
|
454
492
|
scriptPath,
|
455
493
|
'delete',
|
456
494
|
'--service', service
|
package/package.json
CHANGED
package/scripts/postinstall.js
CHANGED
@@ -32,7 +32,7 @@ async function checkAndInstallUv() {
|
|
32
32
|
'pip3 install uv',
|
33
33
|
'cargo install uv'
|
34
34
|
];
|
35
|
-
|
35
|
+
a
|
36
36
|
for (const method of installMethods) {
|
37
37
|
try {
|
38
38
|
console.log(chalk.gray(`🔄 Trying to install uv with: ${method}`));
|
@@ -65,74 +65,67 @@ async function checkAndInstallUv() {
|
|
65
65
|
}
|
66
66
|
}
|
67
67
|
|
68
|
-
// Function to create and activate virtual environment
|
68
|
+
// Function to create and activate virtual environment using uv
|
69
69
|
async function createVirtualEnvironment() {
|
70
|
-
const venvPath = path.join(__dirname, '..', 'venv');
|
71
70
|
const packages = ['modal', 'gitingest', 'requests'];
|
72
71
|
|
73
|
-
console.log(chalk.yellow(`📦 Creating virtual environment and installing packages: ${packages.join(', ')}`));
|
72
|
+
console.log(chalk.yellow(`📦 Creating virtual environment with uv and installing packages: ${packages.join(', ')}`));
|
74
73
|
|
75
74
|
try {
|
76
|
-
//
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
75
|
+
// First, ensure uv is available
|
76
|
+
let uvAvailable = false;
|
77
|
+
try {
|
78
|
+
await execAsync('uv --version');
|
79
|
+
uvAvailable = true;
|
80
|
+
} catch (error) {
|
81
|
+
console.log(chalk.yellow('⚠️ uv not found, attempting to install...'));
|
82
|
+
await checkAndInstallUv();
|
84
83
|
try {
|
85
|
-
await execAsync(
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
84
|
+
await execAsync('uv --version');
|
85
|
+
uvAvailable = true;
|
86
|
+
} catch (installError) {
|
87
|
+
console.log(chalk.red('❌ Failed to install uv'));
|
88
|
+
return false;
|
90
89
|
}
|
91
90
|
}
|
92
91
|
|
93
|
-
if (!
|
94
|
-
console.log(chalk.red('❌
|
92
|
+
if (!uvAvailable) {
|
93
|
+
console.log(chalk.red('❌ uv is required but not available'));
|
95
94
|
return false;
|
96
95
|
}
|
97
96
|
|
98
|
-
console.log(chalk.gray(`🔄 Creating virtual environment with
|
97
|
+
console.log(chalk.gray(`🔄 Creating virtual environment with uv...`));
|
99
98
|
|
100
|
-
// Create virtual environment
|
101
|
-
await execAsync(
|
99
|
+
// Create virtual environment using uv
|
100
|
+
await execAsync('uv venv', {
|
101
|
+
cwd: path.join(__dirname, '..'),
|
102
102
|
env: { ...process.env, PYTHONIOENCODING: 'utf-8' }
|
103
103
|
});
|
104
104
|
|
105
|
-
console.log(chalk.green('✅ Virtual environment created successfully!'));
|
105
|
+
console.log(chalk.green('✅ Virtual environment created successfully with uv!'));
|
106
106
|
|
107
|
-
|
108
|
-
const isWindows = process.platform === 'win32';
|
109
|
-
const pipPath = isWindows ? path.join(venvPath, 'Scripts', 'pip.exe') : path.join(venvPath, 'bin', 'pip');
|
110
|
-
const pythonPath = isWindows ? path.join(venvPath, 'Scripts', 'python.exe') : path.join(venvPath, 'bin', 'python');
|
111
|
-
|
112
|
-
// Verify virtual environment was created properly
|
113
|
-
if (!(await fs.pathExists(pipPath))) {
|
114
|
-
console.log(chalk.red('❌ Virtual environment pip not found'));
|
115
|
-
return false;
|
116
|
-
}
|
107
|
+
console.log(chalk.gray(`🔄 Installing packages in virtual environment with uv...`));
|
117
108
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
await execAsync(`"${pipPath}" install ${packages.join(' ')}`, {
|
109
|
+
// Install packages using uv pip
|
110
|
+
await execAsync(`uv pip install ${packages.join(' ')}`, {
|
111
|
+
cwd: path.join(__dirname, '..'),
|
122
112
|
env: { ...process.env, PYTHONIOENCODING: 'utf-8' }
|
123
113
|
});
|
124
114
|
|
125
115
|
console.log(chalk.green('✅ Python packages installed successfully in virtual environment!'));
|
126
116
|
|
127
117
|
// Create a script to activate the virtual environment
|
118
|
+
const isWindows = process.platform === 'win32';
|
119
|
+
const venvPath = path.join(__dirname, '..', '.venv');
|
120
|
+
|
128
121
|
const activateScript = isWindows ?
|
129
122
|
`@echo off
|
130
123
|
cd /d "%~dp0"
|
131
|
-
call "
|
124
|
+
call ".venv\\Scripts\\activate.bat"
|
132
125
|
%*` :
|
133
126
|
`#!/bin/bash
|
134
127
|
cd "$(dirname "$0")"
|
135
|
-
source "
|
128
|
+
source ".venv/bin/activate"
|
136
129
|
exec "$@"`;
|
137
130
|
|
138
131
|
const activateScriptPath = path.join(__dirname, '..', 'activate_venv' + (isWindows ? '.bat' : '.sh'));
|
@@ -146,12 +139,12 @@ exec "$@"`;
|
|
146
139
|
|
147
140
|
return true;
|
148
141
|
} catch (error) {
|
149
|
-
console.log(chalk.red(`❌ Error creating virtual environment: ${error.message}`));
|
142
|
+
console.log(chalk.red(`❌ Error creating virtual environment with uv: ${error.message}`));
|
150
143
|
console.log(chalk.yellow('💡 Please run manually:'));
|
151
|
-
console.log(chalk.yellow('
|
152
|
-
console.log(chalk.yellow('
|
153
|
-
console.log(chalk.yellow(' venv
|
154
|
-
console.log(chalk.yellow('
|
144
|
+
console.log(chalk.yellow(' uv venv'));
|
145
|
+
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'));
|
155
148
|
return false;
|
156
149
|
}
|
157
150
|
}
|
@@ -338,8 +331,8 @@ if __name__ == "__main__":
|
|
338
331
|
• Visit: https://gitarsenal.dev
|
339
332
|
|
340
333
|
💡 To activate the virtual environment:
|
341
|
-
• Unix/macOS: source venv/bin/activate
|
342
|
-
• Windows: venv\\Scripts\\activate.bat
|
334
|
+
• Unix/macOS: source .venv/bin/activate
|
335
|
+
• Windows: .venv\\Scripts\\activate.bat
|
343
336
|
• Or use: ./activate_venv.sh (Unix/macOS) or activate_venv.bat (Windows)
|
344
337
|
|
345
338
|
Having issues? Run: gitarsenal --debug
|