@abyrd9/harbor-cli 2.3.1 → 2.3.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.
Files changed (2) hide show
  1. package/dist/index.js +44 -10
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -352,6 +352,7 @@ WHAT IT DOES:
352
352
  - Attaches your terminal to it
353
353
  - You can then switch between service tabs with Shift+Left/Right
354
354
  - Press Ctrl+q to kill session, or detach with Ctrl+b then d
355
+ - Runs any configured 'after' scripts if the session is killed
355
356
 
356
357
  PREREQUISITES: Services must be running (started with 'harbor launch').
357
358
 
@@ -383,7 +384,26 @@ EXAMPLES:
383
384
  const attach = spawn('tmux', ['attach-session', '-t', sessionName], {
384
385
  stdio: 'inherit',
385
386
  });
386
- attach.on('close', (code) => {
387
+ attach.on('close', async (code) => {
388
+ // Check if session was killed (vs just detached)
389
+ const checkAfter = spawn('tmux', ['has-session', '-t', sessionName], {
390
+ stdio: 'pipe',
391
+ });
392
+ const sessionStillExists = await new Promise((resolve) => {
393
+ checkAfter.on('close', (checkCode) => {
394
+ resolve(checkCode === 0);
395
+ });
396
+ });
397
+ // If session no longer exists, it was killed - run after scripts
398
+ if (!sessionStillExists && config.after && config.after.length > 0) {
399
+ try {
400
+ await execute(config.after, 'after');
401
+ }
402
+ catch {
403
+ console.error('❌ After scripts failed');
404
+ process.exit(1);
405
+ }
406
+ }
387
407
  process.exit(code || 0);
388
408
  });
389
409
  }
@@ -401,6 +421,7 @@ WHAT IT DOES:
401
421
  - Finds the running Harbor tmux session
402
422
  - Kills the entire session (all service windows)
403
423
  - All services stop immediately
424
+ - Runs any configured 'after' scripts
404
425
 
405
426
  SAFE TO RUN: If no session is running, it simply reports that and exits cleanly.
406
427
 
@@ -429,9 +450,19 @@ EXAMPLES:
429
450
  const killSession = spawn('tmux', ['kill-session', '-t', sessionName], {
430
451
  stdio: 'inherit',
431
452
  });
432
- killSession.on('close', (code) => {
453
+ killSession.on('close', async (code) => {
433
454
  if (code === 0) {
434
455
  console.log(`✅ Harbor session '${sessionName}' stopped`);
456
+ // Execute after scripts when session is killed
457
+ if (config.after && config.after.length > 0) {
458
+ try {
459
+ await execute(config.after, 'after');
460
+ }
461
+ catch {
462
+ console.error('❌ After scripts failed');
463
+ process.exit(1);
464
+ }
465
+ }
435
466
  }
436
467
  else {
437
468
  console.log('❌ Failed to stop Harbor session');
@@ -839,15 +870,18 @@ async function runServices(options = {}) {
839
870
  console.error(`dev.sh exited with code ${code}`);
840
871
  process.exit(1);
841
872
  }
842
- // Execute after scripts
843
- try {
844
- await execute(config.after || [], 'after');
845
- resolve();
846
- }
847
- catch {
848
- console.error('❌ After scripts failed');
849
- process.exit(1);
873
+ // Only execute after scripts in attached mode
874
+ // In headless mode, after scripts are run by 'scuttle' when session is killed
875
+ if (!options.detach) {
876
+ try {
877
+ await execute(config.after || [], 'after');
878
+ }
879
+ catch {
880
+ console.error('❌ After scripts failed');
881
+ process.exit(1);
882
+ }
850
883
  }
884
+ resolve();
851
885
  });
852
886
  });
853
887
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abyrd9/harbor-cli",
3
- "version": "2.3.1",
3
+ "version": "2.3.2",
4
4
  "description": "A CLI tool for orchestrating local development services in a tmux session. Perfect for microservices and polyglot projects with automatic service discovery and before/after script support.",
5
5
  "type": "module",
6
6
  "bin": {