projax 1.0.0 → 1.0.1

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.
@@ -492,33 +492,56 @@ electron_1.ipcMain.handle('open-in-editor', async (_, projectPath) => {
492
492
  });
493
493
  // Get settings
494
494
  electron_1.ipcMain.handle('get-settings', async () => {
495
- // Try bundled path first (when bundled in CLI: dist/electron/main.js -> dist/core)
496
- // Then try local dev path (packages/electron/dist/main.js -> packages/core/dist)
497
- const bundledCorePath = path.join(__dirname, '..', 'core');
498
- const localCorePath = path.join(__dirname, '..', '..', '..', 'core', 'dist');
499
- let corePath;
500
- if (fs.existsSync(bundledCorePath)) {
501
- corePath = bundledCorePath;
495
+ try {
496
+ // Use the same import pattern as other handlers
497
+ let settingsModule;
498
+ try {
499
+ // Try relative import first (when bundled in CLI: dist/electron/main.js -> dist/core)
500
+ settingsModule = require('../core');
501
+ }
502
+ catch {
503
+ try {
504
+ // Try alternative path (local development: packages/electron/dist/main.js -> packages/cli/dist/core)
505
+ settingsModule = require('../../cli/dist/core');
506
+ }
507
+ catch {
508
+ // Fallback to package import
509
+ settingsModule = require('@projax/core');
510
+ }
511
+ }
512
+ const { getAppSettings } = settingsModule;
513
+ return getAppSettings();
502
514
  }
503
- else {
504
- corePath = localCorePath;
515
+ catch (error) {
516
+ console.error('Error getting settings:', error);
517
+ throw error;
505
518
  }
506
- const { getAppSettings } = await Promise.resolve(`${corePath}`).then(s => __importStar(require(s)));
507
- return getAppSettings();
508
519
  });
509
520
  // Save settings
510
521
  electron_1.ipcMain.handle('save-settings', async (_, settings) => {
511
- // Try bundled path first (when bundled in CLI: dist/electron/main.js -> dist/core)
512
- // Then try local dev path (packages/electron/dist/main.js -> packages/core/dist)
513
- const bundledCorePath = path.join(__dirname, '..', 'core');
514
- const localCorePath = path.join(__dirname, '..', '..', '..', 'core', 'dist');
515
- let corePath;
516
- if (fs.existsSync(bundledCorePath)) {
517
- corePath = bundledCorePath;
522
+ try {
523
+ // Use the same import pattern as other handlers
524
+ let settingsModule;
525
+ try {
526
+ // Try relative import first (when bundled in CLI: dist/electron/main.js -> dist/core)
527
+ settingsModule = require('../core');
528
+ }
529
+ catch {
530
+ try {
531
+ // Try alternative path (local development: packages/electron/dist/main.js -> packages/cli/dist/core)
532
+ settingsModule = require('../../cli/dist/core');
533
+ }
534
+ catch {
535
+ // Fallback to package import
536
+ settingsModule = require('@projax/core');
537
+ }
538
+ }
539
+ const { setAppSettings } = settingsModule;
540
+ setAppSettings(settings);
541
+ console.log('Settings saved successfully');
518
542
  }
519
- else {
520
- corePath = localCorePath;
543
+ catch (error) {
544
+ console.error('Error saving settings:', error);
545
+ throw error;
521
546
  }
522
- const { setAppSettings } = await Promise.resolve(`${corePath}`).then(s => __importStar(require(s)));
523
- setAppSettings(settings);
524
547
  });
@@ -577,39 +577,59 @@ function updateProcessUrls(pid, urls) {
577
577
  async function stopScript(pid) {
578
578
  try {
579
579
  const processes = loadProcesses();
580
- const process = processes.find(p => p.pid === pid);
581
- if (!process) {
580
+ const processInfo = processes.find(p => p.pid === pid);
581
+ if (!processInfo) {
582
582
  return false;
583
583
  }
584
- // Try to kill the process (cross-platform)
585
- // Use os.platform() since 'process' variable shadows Node's process
586
- if (os.platform() === 'win32') {
587
- try {
584
+ // Check if process is still running before trying to kill it
585
+ let processExists = false;
586
+ try {
587
+ if (os.platform() === 'win32') {
588
588
  const { exec } = require('child_process');
589
589
  const { promisify } = require('util');
590
590
  const execAsync = promisify(exec);
591
- await execAsync(`taskkill /F /PID ${pid}`);
592
- }
593
- catch {
594
- // Process may already be dead
591
+ await execAsync(`tasklist /FI "PID eq ${pid}" /FO CSV /NH`);
592
+ processExists = true;
595
593
  }
596
- }
597
- else {
598
- try {
594
+ else {
599
595
  const { exec } = require('child_process');
600
596
  const { promisify } = require('util');
601
597
  const execAsync = promisify(exec);
602
- await execAsync(`kill -9 ${pid}`);
598
+ await execAsync(`ps -p ${pid} -o pid=`);
599
+ processExists = true;
603
600
  }
604
- catch {
605
- // Process may already be dead
601
+ }
602
+ catch {
603
+ // Process doesn't exist anymore
604
+ processExists = false;
605
+ }
606
+ // Try to kill the process (cross-platform)
607
+ if (processExists) {
608
+ try {
609
+ if (os.platform() === 'win32') {
610
+ const { exec } = require('child_process');
611
+ const { promisify } = require('util');
612
+ const execAsync = promisify(exec);
613
+ await execAsync(`taskkill /F /PID ${pid}`);
614
+ }
615
+ else {
616
+ const { exec } = require('child_process');
617
+ const { promisify } = require('util');
618
+ const execAsync = promisify(exec);
619
+ await execAsync(`kill -9 ${pid}`);
620
+ }
621
+ }
622
+ catch (error) {
623
+ // Process may have already exited
624
+ console.error(`Error killing process ${pid}:`, error);
606
625
  }
607
626
  }
608
- // Remove from tracking
627
+ // Remove from tracking regardless of whether kill succeeded
609
628
  removeProcess(pid);
610
629
  return true;
611
630
  }
612
631
  catch (error) {
632
+ console.error(`Error stopping script ${pid}:`, error);
613
633
  return false;
614
634
  }
615
635
  }
package/dist/index.js CHANGED
@@ -47,12 +47,12 @@ function displayLogo() {
47
47
  return `
48
48
  ╔═══════════════════════════════════════╗
49
49
  ║ ║
50
- ║ ██████╗ ██████╗ ██████╗ ██╗ ██╗
51
- ██╔══██╗██╔══██╗██╔═══██╗╚██╗██╔╝
52
- ║ ██████╔╝██████╔╝██║ ██║ ╚███╔╝
53
- ║ ██╔═══╝ ██╔══██╗██║ ██║ ██╔██╗
54
- ║ ██║ ██║ ██║╚██████╔╝██╔╝ ██╗
55
- ║ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝
50
+ ║ ██████╗ ██████╗ ██████╗ ██╗ ║
51
+ ██╔══██╗██╔══██╗██╔═══██╗ ██║
52
+ ║ ██████╔╝██████╔╝██║ ██║ ██║
53
+ ║ ██╔═══╝ ██╔══██╗██║ ██║██ ██║
54
+ ║ ██║ ██║ ██║╚██████╔╝╚█████╔╝
55
+ ║ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚════╝
56
56
  ║ ║
57
57
  ║ Project Management CLI ║
58
58
  ║ ║
@@ -985,12 +985,6 @@ program
985
985
  }
986
986
  }
987
987
  // If we get here, proceed with normal command parsing
988
- // Check if no arguments provided - show help with logo
989
- if (args.length === 0) {
990
- console.log(displayLogo());
991
- program.help();
992
- }
993
- else {
994
- program.parse();
995
- }
988
+ // Don't show logo twice - it's already in addHelpText
989
+ program.parse();
996
990
  })();
@@ -577,39 +577,59 @@ function updateProcessUrls(pid, urls) {
577
577
  async function stopScript(pid) {
578
578
  try {
579
579
  const processes = loadProcesses();
580
- const process = processes.find(p => p.pid === pid);
581
- if (!process) {
580
+ const processInfo = processes.find(p => p.pid === pid);
581
+ if (!processInfo) {
582
582
  return false;
583
583
  }
584
- // Try to kill the process (cross-platform)
585
- // Use os.platform() since 'process' variable shadows Node's process
586
- if (os.platform() === 'win32') {
587
- try {
584
+ // Check if process is still running before trying to kill it
585
+ let processExists = false;
586
+ try {
587
+ if (os.platform() === 'win32') {
588
588
  const { exec } = require('child_process');
589
589
  const { promisify } = require('util');
590
590
  const execAsync = promisify(exec);
591
- await execAsync(`taskkill /F /PID ${pid}`);
592
- }
593
- catch {
594
- // Process may already be dead
591
+ await execAsync(`tasklist /FI "PID eq ${pid}" /FO CSV /NH`);
592
+ processExists = true;
595
593
  }
596
- }
597
- else {
598
- try {
594
+ else {
599
595
  const { exec } = require('child_process');
600
596
  const { promisify } = require('util');
601
597
  const execAsync = promisify(exec);
602
- await execAsync(`kill -9 ${pid}`);
598
+ await execAsync(`ps -p ${pid} -o pid=`);
599
+ processExists = true;
603
600
  }
604
- catch {
605
- // Process may already be dead
601
+ }
602
+ catch {
603
+ // Process doesn't exist anymore
604
+ processExists = false;
605
+ }
606
+ // Try to kill the process (cross-platform)
607
+ if (processExists) {
608
+ try {
609
+ if (os.platform() === 'win32') {
610
+ const { exec } = require('child_process');
611
+ const { promisify } = require('util');
612
+ const execAsync = promisify(exec);
613
+ await execAsync(`taskkill /F /PID ${pid}`);
614
+ }
615
+ else {
616
+ const { exec } = require('child_process');
617
+ const { promisify } = require('util');
618
+ const execAsync = promisify(exec);
619
+ await execAsync(`kill -9 ${pid}`);
620
+ }
621
+ }
622
+ catch (error) {
623
+ // Process may have already exited
624
+ console.error(`Error killing process ${pid}:`, error);
606
625
  }
607
626
  }
608
- // Remove from tracking
627
+ // Remove from tracking regardless of whether kill succeeded
609
628
  removeProcess(pid);
610
629
  return true;
611
630
  }
612
631
  catch (error) {
632
+ console.error(`Error stopping script ${pid}:`, error);
613
633
  return false;
614
634
  }
615
635
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "projax",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "CLI tool for managing local development projects",
5
5
  "main": "dist/index.js",
6
6
  "bin": {