fleetbo-cockpit-cli 1.0.247 → 1.0.248

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 +64 -68
  2. package/package.json +1 -1
package/cli.js CHANGED
@@ -900,7 +900,7 @@ else if (['page', 'g', 'generate'].includes(command)) {
900
900
  else {
901
901
  const NULL_DEV = process.platform === 'win32' ? '>nul 2>&1' : '2>/dev/null';
902
902
 
903
- // 🟢 FIX 1 : On crée une variable pour garder la trace du serveur Vite
903
+ // 🟢 On crée une variable pour garder la trace du serveur Vite
904
904
  let devServerProcess = null;
905
905
 
906
906
  function killProcessOnPort(port) {
@@ -912,7 +912,7 @@ else {
912
912
  } catch (e) {}
913
913
  }
914
914
 
915
- // 🟢 FIX 2 : On tue TOUS les processus enfants (Cloudflare ET Vite) proprement
915
+ // 🟢 On tue TOUS les processus enfants (Cloudflare ET Vite) proprement
916
916
  const killAllServices = () => {
917
917
  const killProc = (proc) => {
918
918
  if (proc && proc.pid) {
@@ -936,18 +936,14 @@ else {
936
936
  async function cleanupAndExit(code = 0) {
937
937
  if (isExiting) return;
938
938
  isExiting = true;
939
- console.log('\x1b[33m[Fleetbo] Stopping environment & Cleaning Uplink...\x1b[0m');
940
- try {
941
- await axios.post(UPDATE_NETWORK_URL, { keyApp, networkUrl: '', tester: testerEmail });
942
- console.log('\x1b[32m[Fleetbo] Network status reset to offline.\x1b[0m');
943
- } catch (e) {
944
- console.error('[Fleetbo] Network cleanup warning:', e.message);
945
- }
946
- killNetworkService();
939
+ console.log('\n\x1b[33m[Fleetbo] Stopping environment...\x1b[0m');
940
+
941
+ // On tue instantanément les processus pour libérer le terminal
942
+ killAllServices();
947
943
  killProcessOnPort(PORT);
948
944
 
949
945
  try {
950
- // 🟢 FIX 3 : On met un timeout ultra-court (1s) pour ne jamais bloquer la sortie
946
+ // 🟢 Timeout ultra-court (1s) pour ne jamais bloquer la sortie
951
947
  await axios.post(UPDATE_NETWORK_URL, { keyApp, networkUrl: '', tester: testerEmail }, { timeout: 1000 });
952
948
  console.log('\x1b[32m[Fleetbo] Network status reset to offline.\x1b[0m');
953
949
  } catch (e) {
@@ -983,17 +979,16 @@ else {
983
979
  async function runDevEnvironment() {
984
980
  console.log(`[Fleetbo] Initializing Universal Dev Environment...\n`);
985
981
 
986
- killNetworkService();
982
+ killAllServices();
987
983
  killProcessOnPort(PORT);
988
984
 
989
985
  if (!testerEmail) {
990
- console.error('\x1b[31m[Error] FLEETBO_APP_TESTER_EMAIL missing in .env\x1b[0m');
986
+ console.error('\x1b[31m[Error] VITE_FLEETBO_TESTER_EMAIL missing in .env\x1b[0m');
991
987
  process.exit(1);
992
988
  }
993
989
 
994
990
  const npmCmd = process.platform === 'win32' ? 'npm.cmd' : 'npm';
995
991
 
996
- // 🟢 (Inclut la correction des arguments Arrays vue précédemment)
997
992
  devServerProcess = spawn(npmCmd, ['run', 'dev', '--silent', '--', '--host', '127.0.0.1', '--port', String(PORT)], {
998
993
  stdio: ['ignore', 'pipe', 'pipe'],
999
994
  shell: true,
@@ -1003,18 +998,18 @@ else {
1003
998
  }
1004
999
  });
1005
1000
 
1006
- devServer.stderr.pipe(process.stderr);
1001
+ devServerProcess.stderr.pipe(process.stderr);
1007
1002
 
1008
1003
  let connectionStarted = false;
1009
1004
  let detectedPort = PORT;
1010
1005
 
1011
- // 🟢 (Inclut la correction du Buffer de texte vue précédemment)
1012
1006
  let viteBuffer = "";
1013
1007
 
1014
- devServer.stdout.on('data', (data) => {
1015
- const output = data.toString();
1008
+ devServerProcess.stdout.on('data', (data) => {
1009
+ const chunkText = data.toString();
1010
+ viteBuffer += chunkText;
1016
1011
 
1017
- const lines = output.split('\n');
1012
+ const lines = chunkText.split('\n');
1018
1013
  const forbiddenTerms = [
1019
1014
  'Attempting to bind to HOST', 'If this was unintentional', 'Learn more here:',
1020
1015
  'Starting the development server', 'You can now view', 'vite v', 'VITE v', 'Port', 'is in use',
@@ -1030,12 +1025,11 @@ else {
1030
1025
  process.stdout.write(filteredOutput + '\n');
1031
1026
  }
1032
1027
 
1033
- const portMatch = output.match(/http:\/\/(?:localhost|127\.0\.0\.1):(\d+)/);
1028
+ if (!connectionStarted) {
1029
+ const portMatch = viteBuffer.match(/http:\/\/(?:localhost|127\.0\.0\.1):(\d+)/);
1034
1030
 
1035
- if (portMatch) {
1036
- detectedPort = portMatch[1];
1037
-
1038
- if (!connectionStarted) {
1031
+ if (portMatch) {
1032
+ detectedPort = portMatch[1];
1039
1033
  connectionStarted = true;
1040
1034
 
1041
1035
  console.log('\x1b[33mFleetbo OS ❯\x1b[0m ---------------------------------------------------');
@@ -1043,57 +1037,59 @@ else {
1043
1037
  console.log(`\x1b[33mFleetbo OS ❯\x1b[0m Please wait for the green message...`);
1044
1038
  console.log('\x1b[33mFleetbo OS ❯\x1b[0m ---------------------------------------------------\n');
1045
1039
 
1046
- const MAX_UPLINK_RETRIES = 5;
1047
- const RETRY_DELAYS = [0, 10, 20, 30, 45];
1048
- let uplinkFound = false;
1040
+ const MAX_UPLINK_RETRIES = 5;
1041
+ const RETRY_DELAYS = [0, 10, 20, 30, 45];
1042
+ let uplinkFound = false;
1049
1043
 
1050
- const startUplink = (attempt) => {
1051
- if (uplinkFound) return;
1052
-
1053
- const npxCmd = process.platform === 'win32' ? 'npx.cmd' : 'npx';
1054
-
1055
- if (attempt > 0) {
1056
- console.log(`\x1b[33m[Fleetbo] Uplink reconnection ${attempt}/${MAX_UPLINK_RETRIES - 1}...\x1b[0m`);
1057
- }
1058
-
1059
- const uplinkCommand = `${npxCmd} -y cloudflared tunnel --url http://127.0.0.1:${detectedPort} --http-host-header 127.0.0.1:${detectedPort}`;
1060
- uplinkProcess = spawn(uplinkCommand, { shell: true });
1061
-
1062
- const handleUplinkOutput = (chunk) => {
1063
- const text = chunk.toString();
1044
+ const startUplink = (attempt) => {
1064
1045
  if (uplinkFound) return;
1065
- const match = text.match(/https:\/\/[a-zA-Z0-9-]+\.trycloudflare\.com/);
1066
- if (match) {
1067
- uplinkFound = true;
1068
- setTimeout(() => {
1069
- syncFirebase(process.env.VITE_FLEETBO_KEY_APP, match[0], process.env.VITE_FLEETBO_TESTER_EMAIL);
1070
- }, 1500);
1071
- }
1072
- };
1073
-
1074
- uplinkProcess.stdout.on('data', handleUplinkOutput);
1075
- uplinkProcess.stderr.on('data', handleUplinkOutput);
1076
1046
 
1077
- uplinkProcess.on('error', () => {
1078
- if (uplinkFound) return;
1079
- console.error(`\x1b[31m[Fleetbo] Uplink Connection failed to establish.\x1b[0m`);
1080
- });
1047
+ const npxCmd = process.platform === 'win32' ? 'npx.cmd' : 'npx';
1081
1048
 
1082
- uplinkProcess.on('close', () => {
1083
- if (uplinkFound) return;
1084
- const nextAttempt = attempt + 1;
1085
- if (nextAttempt < MAX_UPLINK_RETRIES) {
1086
- const delay = RETRY_DELAYS[nextAttempt] || 30;
1087
- console.log(`\x1b[33m[Fleetbo] Uplink interrupted. Fleetbo OS retrying in ${delay}s... (${nextAttempt}/${MAX_UPLINK_RETRIES - 1})\x1b[0m`);
1088
- setTimeout(() => startUplink(nextAttempt), delay * 1000);
1089
- } else {
1090
- console.error(`\x1b[31m[Fleetbo] Secure Uplink could not be established.\x1b[0m`);
1049
+ if (attempt > 0) {
1050
+ console.log(`\x1b[33m[Fleetbo] Uplink reconnection ${attempt}/${MAX_UPLINK_RETRIES - 1}...\x1b[0m`);
1091
1051
  }
1092
- });
1093
- };
1094
1052
 
1095
- startUplink(0);
1053
+ uplinkProcess = spawn(npxCmd, ['-y', 'cloudflared', 'tunnel', '--url', `http://127.0.0.1:${detectedPort}`, '--http-host-header', `127.0.0.1:${detectedPort}`], { shell: true });
1054
+
1055
+ let uplinkBuffer = "";
1056
+
1057
+ const handleUplinkOutput = (chunk) => {
1058
+ if (uplinkFound) return;
1059
+
1060
+ uplinkBuffer += chunk.toString();
1061
+
1062
+ const match = uplinkBuffer.match(/https:\/\/[a-zA-Z0-9-]+\.trycloudflare\.com/i);
1063
+ if (match) {
1064
+ uplinkFound = true;
1065
+ setTimeout(() => {
1066
+ syncFirebase(process.env.VITE_FLEETBO_KEY_APP, match[0], process.env.VITE_FLEETBO_TESTER_EMAIL);
1067
+ }, 1500);
1068
+ }
1069
+ };
1070
+
1071
+ uplinkProcess.stdout.on('data', handleUplinkOutput);
1072
+ uplinkProcess.stderr.on('data', handleUplinkOutput);
1073
+
1074
+ uplinkProcess.on('error', () => {
1075
+ if (uplinkFound) return;
1076
+ console.error(`\x1b[31m[Fleetbo] Uplink Connection failed to establish.\x1b[0m`);
1077
+ });
1078
+
1079
+ uplinkProcess.on('close', () => {
1080
+ if (uplinkFound) return;
1081
+ const nextAttempt = attempt + 1;
1082
+ if (nextAttempt < MAX_UPLINK_RETRIES) {
1083
+ const delay = RETRY_DELAYS[nextAttempt] || 30;
1084
+ console.log(`\x1b[33m[Fleetbo] Uplink interrupted. Fleetbo OS retrying in ${delay}s... (${nextAttempt}/${MAX_UPLINK_RETRIES - 1})\x1b[0m`);
1085
+ setTimeout(() => startUplink(nextAttempt), delay * 1000);
1086
+ } else {
1087
+ console.error(`\x1b[31m[Fleetbo] Secure Uplink could not be established.\x1b[0m`);
1088
+ }
1089
+ });
1090
+ };
1096
1091
 
1092
+ startUplink(0);
1097
1093
  }
1098
1094
  }
1099
1095
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fleetbo-cockpit-cli",
3
- "version": "1.0.247",
3
+ "version": "1.0.248",
4
4
  "description": "Fleetbo CLI - Build native mobile apps with React",
5
5
  "author": "Fleetbo",
6
6
  "license": "MIT",