gitarsenal-cli 1.8.6 → 1.8.8

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 CHANGED
@@ -11,12 +11,53 @@ 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();
17
59
 
18
60
  // Display banner
19
- const fs = require('fs');
20
61
 
21
62
  try {
22
63
  const bannerPath = path.join(__dirname, '..', 'ascii_banner.txt');
@@ -302,11 +343,10 @@ async function handleKeysAdd(options) {
302
343
  }
303
344
 
304
345
  // Call Python script to add the key
305
- const { spawn } = require('child_process');
306
- const path = require('path');
307
346
  const scriptPath = path.join(__dirname, '..', 'python', 'gitarsenal_keys.py');
347
+ const pythonExecutable = process.env.PYTHON_EXECUTABLE || 'python';
308
348
 
309
- const pythonProcess = spawn('python', [
349
+ const pythonProcess = spawn(pythonExecutable, [
310
350
  scriptPath,
311
351
  'add',
312
352
  '--service', service,
@@ -341,11 +381,10 @@ async function handleKeysList() {
341
381
  const spinner = ora('Fetching API keys...').start();
342
382
 
343
383
  // Call Python script to list keys
344
- const { spawn } = require('child_process');
345
- const path = require('path');
346
384
  const scriptPath = path.join(__dirname, '..', 'python', 'gitarsenal_keys.py');
385
+ const pythonExecutable = process.env.PYTHON_EXECUTABLE || 'python';
347
386
 
348
- const pythonProcess = spawn('python', [
387
+ const pythonProcess = spawn(pythonExecutable, [
349
388
  scriptPath,
350
389
  'list'
351
390
  ], { stdio: 'inherit' });
@@ -384,11 +423,10 @@ async function handleKeysView(options) {
384
423
  }
385
424
 
386
425
  // Call Python script to view the key
387
- const { spawn } = require('child_process');
388
- const path = require('path');
389
426
  const scriptPath = path.join(__dirname, '..', 'python', 'gitarsenal_keys.py');
427
+ const pythonExecutable = process.env.PYTHON_EXECUTABLE || 'python';
390
428
 
391
- const pythonProcess = spawn('python', [
429
+ const pythonProcess = spawn(pythonExecutable, [
392
430
  scriptPath,
393
431
  'view',
394
432
  '--service', service
@@ -446,11 +484,10 @@ async function handleKeysDelete(options) {
446
484
  spinner.start();
447
485
 
448
486
  // Call Python script to delete the key
449
- const { spawn } = require('child_process');
450
- const path = require('path');
451
487
  const scriptPath = path.join(__dirname, '..', 'python', 'gitarsenal_keys.py');
488
+ const pythonExecutable = process.env.PYTHON_EXECUTABLE || 'python';
452
489
 
453
- const pythonProcess = spawn('python', [
490
+ const pythonProcess = spawn(pythonExecutable, [
454
491
  scriptPath,
455
492
  'delete',
456
493
  '--service', service
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gitarsenal-cli",
3
- "version": "1.8.6",
3
+ "version": "1.8.8",
4
4
  "description": "CLI tool for creating Modal sandboxes with GitHub repositories",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -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}`));