fleetbo-cockpit-cli 1.0.166 → 1.0.168

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/cli.js +23 -22
  2. package/package.json +1 -1
package/cli.js CHANGED
@@ -27,7 +27,6 @@ const CACHE_URL = "https://getmodulecache-jqycakhlxa-uc.a.run.app";
27
27
  const PORT = 3000;
28
28
 
29
29
  let uplinkProcess = null;
30
- let devServerProcess = null;
31
30
  const args = process.argv.slice(2);
32
31
  const command = args[0];
33
32
 
@@ -986,31 +985,25 @@ else {
986
985
 
987
986
  function killProcessOnPort(port) {
988
987
  try {
989
- if (process.platform === 'win32') {
990
- execSync(`for /f "tokens=5" %a in ('netstat -aon ^| find ":${port}"') do taskkill /F /PID %a`, { stdio: 'ignore', shell: true });
991
- } else {
988
+ if (process.platform !== 'win32') {
992
989
  const pid = execSync(`lsof -ti:${port} ${NULL_DEV}`).toString().trim();
993
990
  if (pid) execSync(`kill -9 ${pid.split('\n').join(' ')} ${NULL_DEV}`);
994
991
  }
995
992
  } catch (e) {}
996
993
  }
997
-
998
- function killDevServer() {
999
- if (!devServerProcess) return;
1000
- try {
1001
- if (process.platform === 'win32') {
1002
- execSync(`taskkill /pid ${devServerProcess.pid} /T /F`, { stdio: 'ignore' });
1003
- } else {
1004
- devServerProcess.kill('SIGKILL');
1005
- }
1006
- } catch (e) {}
1007
- devServerProcess = null;
1008
- }
1009
994
 
1010
995
  const killNetworkService = () => {
1011
996
  if (uplinkProcess) {
1012
997
  try {
1013
- uplinkProcess.kill('SIGINT');
998
+ if (process.platform === 'win32') {
999
+ // Windows ne supporte pas SIGINT sur les process enfants
1000
+ // On utilise taskkill pour forcer la fermeture propre
1001
+ try {
1002
+ execSync(`taskkill /pid ${uplinkProcess.pid} /T /F`, { stdio: 'ignore' });
1003
+ } catch (e) {}
1004
+ } else {
1005
+ uplinkProcess.kill('SIGINT');
1006
+ }
1014
1007
  console.log('[Fleetbo] Engine closed.');
1015
1008
  } catch (e) {
1016
1009
  console.error('[Fleetbo] Error closing tunnel:', e.message);
@@ -1019,7 +1012,7 @@ else {
1019
1012
  };
1020
1013
 
1021
1014
  let isExiting = false;
1022
-
1015
+
1023
1016
  async function cleanupAndExit(code = 0) {
1024
1017
  if (isExiting) return;
1025
1018
  isExiting = true;
@@ -1031,12 +1024,21 @@ else {
1031
1024
  console.error('[Fleetbo] Network cleanup warning:', e.message);
1032
1025
  }
1033
1026
  killNetworkService();
1034
- killDevServer();
1035
1027
  killProcessOnPort(PORT);
1036
1028
  console.log('[Fleetbo] Bye.');
1037
1029
  process.exit(code);
1038
1030
  }
1039
-
1031
+
1032
+ // 🪟 WINDOWS FIX : Ctrl+C est intercepté par cmd.exe avant Node.js
1033
+ // On capture le signal au niveau stdin pour éviter l'invite "O/N"
1034
+ if (process.platform === 'win32') {
1035
+ const rl = require('readline').createInterface({
1036
+ input: process.stdin,
1037
+ output: process.stdout
1038
+ });
1039
+ rl.on('SIGINT', () => cleanupAndExit(0));
1040
+ }
1041
+
1040
1042
  process.on('SIGINT', () => cleanupAndExit(0));
1041
1043
  process.on('SIGTERM', () => cleanupAndExit(0));
1042
1044
 
@@ -1070,7 +1072,7 @@ else {
1070
1072
  const npmCmd = process.platform === 'win32' ? 'npm.cmd' : 'npm';
1071
1073
 
1072
1074
  // ✅ On passe la chaîne complète, SANS tableau d'arguments du tout !
1073
- devServerProcess = spawn(`${npmCmd} run dev --silent`, {
1075
+ const devServer = spawn(`${npmCmd} run dev --silent`, {
1074
1076
  stdio: ['ignore', 'pipe', 'pipe'],
1075
1077
  shell: true,
1076
1078
  env: {
@@ -1079,7 +1081,6 @@ else {
1079
1081
  PORT: PORT.toString(),
1080
1082
  }
1081
1083
  });
1082
- const devServer = devServerProcess;
1083
1084
  //devServer.stdout.pipe(process.stdout);
1084
1085
  devServer.stderr.pipe(process.stderr);
1085
1086
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fleetbo-cockpit-cli",
3
- "version": "1.0.166",
3
+ "version": "1.0.168",
4
4
  "description": "Fleetbo CLI - Build native mobile apps with React",
5
5
  "author": "Fleetbo",
6
6
  "license": "MIT",