gitarsenal-cli 1.8.6 → 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/bin/gitarsenal.js +50 -12
- package/package.json +1 -1
- package/scripts/postinstall.js +1 -1
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