fleetbo-cockpit-cli 1.0.174 → 1.0.175

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 +24 -39
  2. package/package.json +1 -1
package/cli.js CHANGED
@@ -1048,12 +1048,10 @@ else {
1048
1048
  }
1049
1049
 
1050
1050
  async function runDevEnvironment() {
1051
- console.log(`[Fleetbo] 🛡️ Initializing Dev Environment...`);
1052
-
1053
-
1051
+ console.log(`[Fleetbo] 🛡️ Initializing Universal Dev Environment...`);
1054
1052
 
1055
1053
  killNetworkService();
1056
- killProcessOnPort(PORT);
1054
+ killProcessOnPort(PORT); // On tue le 3000 par précaution, au cas où
1057
1055
 
1058
1056
  if (!testerEmail) {
1059
1057
  console.error('\x1b[31mError: FLEETBO_APP_TESTER_EMAIL missing in .env\x1b[0m');
@@ -1062,20 +1060,21 @@ else {
1062
1060
 
1063
1061
  const npmCmd = process.platform === 'win32' ? 'npm.cmd' : 'npm';
1064
1062
 
1065
- // On passe la chaîne complète, SANS tableau d'arguments du tout !
1063
+ // Lancement agnostique du serveur de dev (React, Vue, etc.)
1066
1064
  const devServer = spawn(`${npmCmd} run dev --silent`, {
1067
1065
  stdio: ['ignore', 'pipe', 'pipe'],
1068
1066
  shell: true,
1069
1067
  env: {
1070
1068
  ...process.env,
1071
- NODE_OPTIONS: '--no-deprecation',
1072
- PORT: PORT.toString(),
1069
+ NODE_OPTIONS: '--no-deprecation'
1070
+ // On a retiré le forçage du PORT ici pour laisser Vite choisir (souvent 5173 pour Vue)
1073
1071
  }
1074
1072
  });
1075
- //devServer.stdout.pipe(process.stdout);
1073
+
1076
1074
  devServer.stderr.pipe(process.stderr);
1077
1075
 
1078
1076
  let connectionStarted = false;
1077
+ let detectedPort = PORT; // 3000 par défaut
1079
1078
 
1080
1079
  devServer.stdout.on('data', (data) => {
1081
1080
  const output = data.toString();
@@ -1083,45 +1082,36 @@ else {
1083
1082
  // 🛡️ FILTRE ANTI-PLOMBERIE FLEETBO
1084
1083
  const lines = output.split('\n');
1085
1084
  const forbiddenTerms = [
1086
- 'Attempting to bind to HOST',
1087
- 'If this was unintentional',
1088
- 'Learn more here:',
1089
- 'Starting the development server',
1090
- 'You can now view',
1091
- 'vite v',
1092
- 'VITE v',
1093
- 'ready in',
1094
- 'Local:', // 👈 Plus simple et infaillible
1095
- 'Network:', // 👈 Plus simple et infaillible
1096
- 'press h + enter',
1097
- '> vite',
1098
- '> fleetbo',
1099
- '> npx fleetbo-cockpit-cli@latest'
1085
+ 'Attempting to bind to HOST', 'If this was unintentional', 'Learn more here:',
1086
+ 'Starting the development server', 'You can now view', 'vite v', 'VITE v',
1087
+ 'ready in', 'Local:', 'Network:', 'press h + enter', '> vite', '> fleetbo', '> npx fleetbo-cockpit-cli@latest'
1100
1088
  ];
1101
1089
 
1102
1090
  const filteredOutput = lines.filter(line => {
1103
- // On nettoie les codes couleurs invisibles avant de lire
1104
1091
  const cleanLine = line.replace(/\x1b\[[0-9;]*[a-zA-Z]/g, '');
1105
1092
  return !forbiddenTerms.some(term => cleanLine.includes(term));
1106
1093
  }).join('\n');
1107
1094
 
1108
- // S'il reste quelque chose d'utile (un console.log du dev, un warning, une vraie erreur), on l'affiche
1109
1095
  if (filteredOutput.trim() !== '') {
1110
1096
  process.stdout.write(filteredOutput + '\n');
1111
1097
  }
1112
1098
 
1113
- // 🚀 DÉTECTION DU DÉMARRAGE ET LANCEMENT DE L'UPLINK
1114
- if (!connectionStarted && (output.includes('localhost') || output.includes('ready in'))){
1099
+ // 🚀 MAGIE 1 : DÉTECTION DU PORT RÉEL (Vite/Vue ou React)
1100
+ // Cherche un pattern comme http://localhost:5173 ou http://127.0.0.1:3000
1101
+ const portMatch = output.match(/http:\/\/(?:localhost|127\.0\.0\.1):(\d+)/);
1102
+ if (portMatch) {
1103
+ detectedPort = portMatch[1]; // On capture le vrai port !
1104
+ }
1105
+
1106
+ // 🚀 MAGIE 2 : DÉTECTION DU DÉMARRAGE ET LANCEMENT DE L'UPLINK SUR LE BON PORT
1107
+ if (!connectionStarted && (output.includes('localhost') || output.includes('ready in') || output.includes('Local:'))){
1115
1108
  connectionStarted = true;
1116
1109
 
1117
1110
  console.log('\n\x1b[33mFleetbo OS ❯\x1b[0m ---------------------------------------------------');
1118
- console.log(`\x1b[33mFleetbo OS ❯\x1b[0m Establishing Secure Uplink...`);
1111
+ console.log(`\x1b[33mFleetbo OS ❯\x1b[0m Establishing Secure Uplink on port ${detectedPort}...`);
1119
1112
  console.log(`\x1b[33mFleetbo OS ❯\x1b[0m Please wait for the green message...`);
1120
1113
  console.log('\x1b[33mFleetbo OS ❯\x1b[0m ---------------------------------------------------');
1121
1114
 
1122
- // ============================================
1123
- // UPLINK avec auto-retry (Fleetbo OS Resilience)
1124
- // ============================================
1125
1115
  const MAX_UPLINK_RETRIES = 5;
1126
1116
  const RETRY_DELAYS = [0, 10, 20, 30, 45];
1127
1117
  let uplinkFound = false;
@@ -1135,8 +1125,8 @@ else {
1135
1125
  console.log(`\x1b[33m[Fleetbo] 🔄 Uplink reconnection ${attempt}/${MAX_UPLINK_RETRIES - 1}...\x1b[0m`);
1136
1126
  }
1137
1127
 
1138
- // ✅ La commande complète, SANS tableau !
1139
- const uplinkCommand = `${npxCmd} -y cloudflared tunnel --url http://127.0.0.1:${PORT} --http-host-header 127.0.0.1:${PORT}`;
1128
+ // ✅ LE TUNNEL CLOUDFLARE UTILISE LE PORT DÉTECTÉ DYNAMIQUEMENT !
1129
+ const uplinkCommand = `${npxCmd} -y cloudflared tunnel --url http://127.0.0.1:${detectedPort} --http-host-header 127.0.0.1:${detectedPort}`;
1140
1130
  uplinkProcess = spawn(uplinkCommand, { shell: true });
1141
1131
 
1142
1132
  const handleUplinkOutput = (chunk) => {
@@ -1145,7 +1135,6 @@ else {
1145
1135
  const match = text.match(/https:\/\/[a-zA-Z0-9-]+\.trycloudflare\.com/);
1146
1136
  if (match) {
1147
1137
  uplinkFound = true;
1148
- // ⚡ Stabilisation du noyau : on attend 1.5s
1149
1138
  setTimeout(() => {
1150
1139
  syncFirebase(process.env.VITE_FLEETBO_KEY_APP, match[0], process.env.VITE_FLEETBO_TESTER_EMAIL);
1151
1140
  }, 1500);
@@ -1155,14 +1144,13 @@ else {
1155
1144
  uplinkProcess.stdout.on('data', handleUplinkOutput);
1156
1145
  uplinkProcess.stderr.on('data', handleUplinkOutput);
1157
1146
 
1158
- uplinkProcess.on('error', (err) => {
1147
+ uplinkProcess.on('error', () => {
1159
1148
  if (uplinkFound) return;
1160
1149
  console.error(`\x1b[31m[Fleetbo] ⚠️ Uplink Connection failed to establish.\x1b[0m`);
1161
1150
  });
1162
1151
 
1163
- uplinkProcess.on('close', (code) => {
1152
+ uplinkProcess.on('close', () => {
1164
1153
  if (uplinkFound) return;
1165
-
1166
1154
  const nextAttempt = attempt + 1;
1167
1155
  if (nextAttempt < MAX_UPLINK_RETRIES) {
1168
1156
  const delay = RETRY_DELAYS[nextAttempt] || 30;
@@ -1170,9 +1158,6 @@ else {
1170
1158
  setTimeout(() => startUplink(nextAttempt), delay * 1000);
1171
1159
  } else {
1172
1160
  console.error(`\x1b[31m[Fleetbo] ❌ Secure Uplink could not be established.\x1b[0m`);
1173
- console.error(`\x1b[90m[Fleetbo] Fleetbo OS network is temporarily unavailable.\x1b[0m`);
1174
- console.error(`\x1b[90m[Fleetbo] Your dev server is still running on http://localhost:${PORT}\x1b[0m`);
1175
- console.error(`\x1b[90m[Fleetbo] Restart with "npm run fleetbo" when the network is back.\x1b[0m`);
1176
1161
  }
1177
1162
  });
1178
1163
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fleetbo-cockpit-cli",
3
- "version": "1.0.174",
3
+ "version": "1.0.175",
4
4
  "description": "Fleetbo CLI - Build native mobile apps with React",
5
5
  "author": "Fleetbo",
6
6
  "license": "MIT",