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