fleetbo-cockpit-cli 1.0.30 → 1.0.31

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 +54 -29
  2. package/package.json +1 -1
package/cli.js CHANGED
@@ -761,42 +761,67 @@ else {
761
761
  console.log(`[Fleetbo] ⏳ Please wait for the green message...`);
762
762
  console.log('[Fleetbo] ---------------------------------------------------');
763
763
 
764
- const npxCmd = process.platform === 'win32' ? 'npx.cmd' : 'npx';
765
- uplinkProcess = spawn(npxCmd, [
766
- '-y',
767
- 'cloudflared',
768
- 'tunnel',
769
- '--url', `http://127.0.0.1:${PORT}`,
770
- '--http-host-header', `127.0.0.1:${PORT}`
771
- ], { shell: true });
772
-
764
+ // ============================================
765
+ // UPLINK avec auto-retry (Fleetbo OS Resilience)
766
+ // ============================================
767
+ const MAX_UPLINK_RETRIES = 5;
768
+ const RETRY_DELAYS = [0, 10, 20, 30, 45];
773
769
  let uplinkFound = false;
774
770
 
775
- const handleUplinkOutput = (chunk) => {
776
- const text = chunk.toString();
771
+ const startUplink = (attempt) => {
777
772
  if (uplinkFound) return;
778
- const match = text.match(/https:\/\/[a-zA-Z0-9-]+\.trycloudflare\.com/);
779
- if (match) {
780
- uplinkFound = true;
781
- syncFirebase(process.env.REACT_KEY_APP, match[0], process.env.REACT_APP_TESTER_EMAIL);
773
+
774
+ const npxCmd = process.platform === 'win32' ? 'npx.cmd' : 'npx';
775
+
776
+ if (attempt > 0) {
777
+ console.log(`\x1b[33m[Fleetbo] 🔄 Uplink reconnection ${attempt}/${MAX_UPLINK_RETRIES - 1}...\x1b[0m`);
782
778
  }
783
- };
784
779
 
785
- // Cloudflared peut écrire l'URL sur stdout OU stderr selon la version
786
- uplinkProcess.stdout.on('data', handleUplinkOutput);
787
- uplinkProcess.stderr.on('data', handleUplinkOutput);
780
+ uplinkProcess = spawn(npxCmd, [
781
+ '-y',
782
+ 'cloudflared',
783
+ 'tunnel',
784
+ '--url', `http://127.0.0.1:${PORT}`,
785
+ '--http-host-header', `127.0.0.1:${PORT}`
786
+ ], { shell: true });
787
+
788
+ const handleUplinkOutput = (chunk) => {
789
+ const text = chunk.toString();
790
+ if (uplinkFound) return;
791
+ const match = text.match(/https:\/\/[a-zA-Z0-9-]+\.trycloudflare\.com/);
792
+ if (match) {
793
+ uplinkFound = true;
794
+ syncFirebase(process.env.REACT_KEY_APP, match[0], process.env.REACT_APP_TESTER_EMAIL);
795
+ }
796
+ };
788
797
 
789
- uplinkProcess.on('error', (err) => {
790
- console.error(`\x1b[31m[Fleetbo] ⚠️ Cloudflared failed to start: ${err.message}\x1b[0m`);
791
- console.error(`\x1b[90m[Fleetbo] Try installing cloudflared manually: npm install -g cloudflared\x1b[0m`);
792
- });
798
+ // Écoute sur les deux flux (stdout + stderr)
799
+ uplinkProcess.stdout.on('data', handleUplinkOutput);
800
+ uplinkProcess.stderr.on('data', handleUplinkOutput);
793
801
 
794
- uplinkProcess.on('close', (code) => {
795
- if (!uplinkFound && code !== 0) {
796
- console.error(`\x1b[31m[Fleetbo] ⚠️ Uplink process exited with code ${code} without establishing a tunnel.\x1b[0m`);
797
- console.error(`\x1b[90m[Fleetbo] Try running manually: npx cloudflared tunnel --url http://127.0.0.1:${PORT}\x1b[0m`);
798
- }
799
- });
802
+ uplinkProcess.on('error', (err) => {
803
+ if (uplinkFound) return;
804
+ console.error(`\x1b[31m[Fleetbo] ⚠️ Uplink Connection failed to establish.\x1b[0m`);
805
+ });
806
+
807
+ uplinkProcess.on('close', (code) => {
808
+ if (uplinkFound) return;
809
+
810
+ const nextAttempt = attempt + 1;
811
+ if (nextAttempt < MAX_UPLINK_RETRIES) {
812
+ const delay = RETRY_DELAYS[nextAttempt] || 30;
813
+ console.log(`\x1b[33m[Fleetbo] ⚠️ Uplink interrupted. Fleetbo OS retrying in ${delay}s... (${nextAttempt}/${MAX_UPLINK_RETRIES - 1})\x1b[0m`);
814
+ setTimeout(() => startUplink(nextAttempt), delay * 1000);
815
+ } else {
816
+ console.error(`\x1b[31m[Fleetbo] ❌ Secure Uplink could not be established.\x1b[0m`);
817
+ console.error(`\x1b[90m[Fleetbo] Fleetbo OS network is temporarily unavailable.\x1b[0m`);
818
+ console.error(`\x1b[90m[Fleetbo] Your dev server is still running on http://localhost:${PORT}\x1b[0m`);
819
+ console.error(`\x1b[90m[Fleetbo] Restart with "npm run fleetbo" when the network is back.\x1b[0m`);
820
+ }
821
+ });
822
+ };
823
+
824
+ startUplink(0);
800
825
  }
801
826
  });
802
827
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fleetbo-cockpit-cli",
3
- "version": "1.0.30",
3
+ "version": "1.0.31",
4
4
  "description": "Fleetbo CLI - Build native mobile apps with React",
5
5
  "author": "Fleetbo",
6
6
  "license": "MIT",