fleetbo-cockpit-cli 1.0.29 → 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 +61 -14
  2. package/package.json +1 -1
package/cli.js CHANGED
@@ -761,20 +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
-
773
- uplinkProcess.stderr.on('data', (chunk) => {
774
- const text = chunk.toString();
775
- const match = text.match(/https:\/\/[a-zA-Z0-9-]+\.trycloudflare\.com/);
776
- if (match) syncFirebase(process.env.REACT_KEY_APP, match[0], process.env.REACT_APP_TESTER_EMAIL);
777
- });
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];
769
+ let uplinkFound = false;
770
+
771
+ const startUplink = (attempt) => {
772
+ if (uplinkFound) return;
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`);
778
+ }
779
+
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
+ };
797
+
798
+ // Écoute sur les deux flux (stdout + stderr)
799
+ uplinkProcess.stdout.on('data', handleUplinkOutput);
800
+ uplinkProcess.stderr.on('data', handleUplinkOutput);
801
+
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);
778
825
  }
779
826
  });
780
827
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fleetbo-cockpit-cli",
3
- "version": "1.0.29",
3
+ "version": "1.0.31",
4
4
  "description": "Fleetbo CLI - Build native mobile apps with React",
5
5
  "author": "Fleetbo",
6
6
  "license": "MIT",