fleetbo-cockpit-cli 1.0.30 → 1.0.32
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.
- package/cli.js +54 -29
- 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
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
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
|
|
776
|
-
const text = chunk.toString();
|
|
771
|
+
const startUplink = (attempt) => {
|
|
777
772
|
if (uplinkFound) return;
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
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
|
-
|
|
786
|
-
|
|
787
|
-
|
|
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
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
});
|
|
798
|
+
// Écoute sur les deux flux (stdout + stderr)
|
|
799
|
+
uplinkProcess.stdout.on('data', handleUplinkOutput);
|
|
800
|
+
uplinkProcess.stderr.on('data', handleUplinkOutput);
|
|
793
801
|
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
console.error(`\x1b[31m[Fleetbo] ⚠️ Uplink
|
|
797
|
-
|
|
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
|
}
|