fleetbo-cockpit-cli 1.0.242 → 1.0.245

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 +65 -55
  2. package/package.json +1 -1
package/cli.js CHANGED
@@ -469,9 +469,9 @@ if (command === 'alex') {
469
469
  }
470
470
 
471
471
  if (aiData.status === 'message') {
472
- rawMsg = "[Chat Mode] " + rawMsg;
472
+ rawMsg = "\x1b[33m[Chat Mode]\x1b[0m " + rawMsg;
473
473
  }
474
-
474
+
475
475
  process.stdout.write(`[ALEX_START]${rawMsg}[ALEX_END]`);
476
476
  }
477
477
 
@@ -973,13 +973,14 @@ else {
973
973
  killProcessOnPort(PORT);
974
974
 
975
975
  if (!testerEmail) {
976
- console.error('\x1b[31m[Error] FLEETBO_APP_TESTER_EMAIL missing in .env\x1b[0m');
976
+ console.error('\x1b[31m[Error] VITE_FLEETBO_TESTER_EMAIL missing in .env\x1b[0m');
977
977
  process.exit(1);
978
978
  }
979
979
 
980
980
  const npmCmd = process.platform === 'win32' ? 'npm.cmd' : 'npm';
981
981
 
982
- const devServer = spawn(`${npmCmd} run dev --silent -- --host 127.0.0.1 --port ${PORT}`, {
982
+ // 🟢 FIX 1 : On sépare les arguments dans un tableau pour éviter les crashs de processus sous Windows
983
+ const devServer = spawn(npmCmd, ['run', 'dev', '--silent', '--', '--host', '127.0.0.1', '--port', String(PORT)], {
983
984
  stdio: ['ignore', 'pipe', 'pipe'],
984
985
  shell: true,
985
986
  env: {
@@ -993,10 +994,14 @@ else {
993
994
  let connectionStarted = false;
994
995
  let detectedPort = PORT;
995
996
 
997
+ // 🟢 FIX 2 : Un Buffer mémoire pour ne pas rater les textes coupés en deux !
998
+ let viteBuffer = "";
999
+
996
1000
  devServer.stdout.on('data', (data) => {
997
- const output = data.toString();
1001
+ const chunkText = data.toString();
1002
+ viteBuffer += chunkText; // On accumule tout l'historique
998
1003
 
999
- const lines = output.split('\n');
1004
+ const lines = chunkText.split('\n');
1000
1005
  const forbiddenTerms = [
1001
1006
  'Attempting to bind to HOST', 'If this was unintentional', 'Learn more here:',
1002
1007
  'Starting the development server', 'You can now view', 'vite v', 'VITE v', 'Port', 'is in use',
@@ -1012,12 +1017,12 @@ else {
1012
1017
  process.stdout.write(filteredOutput + '\n');
1013
1018
  }
1014
1019
 
1015
- const portMatch = output.match(/http:\/\/(?:localhost|127\.0\.0\.1):(\d+)/);
1020
+ if (!connectionStarted) {
1021
+ // On cherche l'URL de Vite dans l'historique COMPLET
1022
+ const portMatch = viteBuffer.match(/http:\/\/(?:localhost|127\.0\.0\.1):(\d+)/);
1016
1023
 
1017
- if (portMatch) {
1018
- detectedPort = portMatch[1];
1019
-
1020
- if (!connectionStarted) {
1024
+ if (portMatch) {
1025
+ detectedPort = portMatch[1];
1021
1026
  connectionStarted = true;
1022
1027
 
1023
1028
  console.log('\x1b[33mFleetbo OS ❯\x1b[0m ---------------------------------------------------');
@@ -1025,57 +1030,62 @@ else {
1025
1030
  console.log(`\x1b[33mFleetbo OS ❯\x1b[0m Please wait for the green message...`);
1026
1031
  console.log('\x1b[33mFleetbo OS ❯\x1b[0m ---------------------------------------------------\n');
1027
1032
 
1028
- const MAX_UPLINK_RETRIES = 5;
1029
- const RETRY_DELAYS = [0, 10, 20, 30, 45];
1030
- let uplinkFound = false;
1031
-
1032
- const startUplink = (attempt) => {
1033
- if (uplinkFound) return;
1034
-
1035
- const npxCmd = process.platform === 'win32' ? 'npx.cmd' : 'npx';
1033
+ const MAX_UPLINK_RETRIES = 5;
1034
+ const RETRY_DELAYS = [0, 10, 20, 30, 45];
1035
+ let uplinkFound = false;
1036
1036
 
1037
- if (attempt > 0) {
1038
- console.log(`\x1b[33m[Fleetbo] Uplink reconnection ${attempt}/${MAX_UPLINK_RETRIES - 1}...\x1b[0m`);
1039
- }
1040
-
1041
- const uplinkCommand = `${npxCmd} -y cloudflared tunnel --url http://127.0.0.1:${detectedPort} --http-host-header 127.0.0.1:${detectedPort}`;
1042
- uplinkProcess = spawn(uplinkCommand, { shell: true });
1043
-
1044
- const handleUplinkOutput = (chunk) => {
1045
- const text = chunk.toString();
1037
+ const startUplink = (attempt) => {
1046
1038
  if (uplinkFound) return;
1047
- const match = text.match(/https:\/\/[a-zA-Z0-9-]+\.trycloudflare\.com/);
1048
- if (match) {
1049
- uplinkFound = true;
1050
- setTimeout(() => {
1051
- syncFirebase(process.env.VITE_FLEETBO_KEY_APP, match[0], process.env.VITE_FLEETBO_TESTER_EMAIL);
1052
- }, 1500);
1053
- }
1054
- };
1055
1039
 
1056
- uplinkProcess.stdout.on('data', handleUplinkOutput);
1057
- uplinkProcess.stderr.on('data', handleUplinkOutput);
1040
+ const npxCmd = process.platform === 'win32' ? 'npx.cmd' : 'npx';
1058
1041
 
1059
- uplinkProcess.on('error', () => {
1060
- if (uplinkFound) return;
1061
- console.error(`\x1b[31m[Fleetbo] Uplink Connection failed to establish.\x1b[0m`);
1062
- });
1063
-
1064
- uplinkProcess.on('close', () => {
1065
- if (uplinkFound) return;
1066
- const nextAttempt = attempt + 1;
1067
- if (nextAttempt < MAX_UPLINK_RETRIES) {
1068
- const delay = RETRY_DELAYS[nextAttempt] || 30;
1069
- console.log(`\x1b[33m[Fleetbo] Uplink interrupted. Fleetbo OS retrying in ${delay}s... (${nextAttempt}/${MAX_UPLINK_RETRIES - 1})\x1b[0m`);
1070
- setTimeout(() => startUplink(nextAttempt), delay * 1000);
1071
- } else {
1072
- console.error(`\x1b[31m[Fleetbo] Secure Uplink could not be established.\x1b[0m`);
1042
+ if (attempt > 0) {
1043
+ console.log(`\x1b[33m[Fleetbo] Uplink reconnection ${attempt}/${MAX_UPLINK_RETRIES - 1}...\x1b[0m`);
1073
1044
  }
1074
- });
1075
- };
1076
1045
 
1077
- startUplink(0);
1046
+ // 🟢 FIX 3 : Safe spawn array pour Cloudflared
1047
+ uplinkProcess = spawn(npxCmd, ['-y', 'cloudflared', 'tunnel', '--url', `http://127.0.0.1:${detectedPort}`, '--http-host-header', `127.0.0.1:${detectedPort}`], { shell: true });
1048
+
1049
+ // 🟢 FIX 4 : Buffer cumulatif pour l'URL Cloudflare
1050
+ let uplinkBuffer = "";
1051
+
1052
+ const handleUplinkOutput = (chunk) => {
1053
+ if (uplinkFound) return;
1054
+
1055
+ uplinkBuffer += chunk.toString(); // On accumule
1056
+
1057
+ // On cherche dans le buffer consolidé
1058
+ const match = uplinkBuffer.match(/https:\/\/[a-zA-Z0-9-]+\.trycloudflare\.com/i);
1059
+ if (match) {
1060
+ uplinkFound = true;
1061
+ setTimeout(() => {
1062
+ syncFirebase(process.env.VITE_FLEETBO_KEY_APP, match[0], process.env.VITE_FLEETBO_TESTER_EMAIL);
1063
+ }, 1500);
1064
+ }
1065
+ };
1066
+
1067
+ uplinkProcess.stdout.on('data', handleUplinkOutput);
1068
+ uplinkProcess.stderr.on('data', handleUplinkOutput);
1069
+
1070
+ uplinkProcess.on('error', () => {
1071
+ if (uplinkFound) return;
1072
+ console.error(`\x1b[31m[Fleetbo] Uplink Connection failed to establish.\x1b[0m`);
1073
+ });
1074
+
1075
+ uplinkProcess.on('close', () => {
1076
+ if (uplinkFound) return;
1077
+ const nextAttempt = attempt + 1;
1078
+ if (nextAttempt < MAX_UPLINK_RETRIES) {
1079
+ const delay = RETRY_DELAYS[nextAttempt] || 30;
1080
+ console.log(`\x1b[33m[Fleetbo] Uplink interrupted. Fleetbo OS retrying in ${delay}s... (${nextAttempt}/${MAX_UPLINK_RETRIES - 1})\x1b[0m`);
1081
+ setTimeout(() => startUplink(nextAttempt), delay * 1000);
1082
+ } else {
1083
+ console.error(`\x1b[31m[Fleetbo] Secure Uplink could not be established.\x1b[0m`);
1084
+ }
1085
+ });
1086
+ };
1078
1087
 
1088
+ startUplink(0);
1079
1089
  }
1080
1090
  }
1081
1091
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fleetbo-cockpit-cli",
3
- "version": "1.0.242",
3
+ "version": "1.0.245",
4
4
  "description": "Fleetbo CLI - Build native mobile apps with React",
5
5
  "author": "Fleetbo",
6
6
  "license": "MIT",