fleetbo-cockpit-cli 1.0.245 → 1.0.246
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 +53 -63
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -973,14 +973,13 @@ else {
|
|
|
973
973
|
killProcessOnPort(PORT);
|
|
974
974
|
|
|
975
975
|
if (!testerEmail) {
|
|
976
|
-
console.error('\x1b[31m[Error]
|
|
976
|
+
console.error('\x1b[31m[Error] FLEETBO_APP_TESTER_EMAIL missing in .env\x1b[0m');
|
|
977
977
|
process.exit(1);
|
|
978
978
|
}
|
|
979
979
|
|
|
980
980
|
const npmCmd = process.platform === 'win32' ? 'npm.cmd' : 'npm';
|
|
981
981
|
|
|
982
|
-
|
|
983
|
-
const devServer = spawn(npmCmd, ['run', 'dev', '--silent', '--', '--host', '127.0.0.1', '--port', String(PORT)], {
|
|
982
|
+
const devServer = spawn(`${npmCmd} run dev --silent -- --host 127.0.0.1 --port ${PORT}`, {
|
|
984
983
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
985
984
|
shell: true,
|
|
986
985
|
env: {
|
|
@@ -994,14 +993,10 @@ else {
|
|
|
994
993
|
let connectionStarted = false;
|
|
995
994
|
let detectedPort = PORT;
|
|
996
995
|
|
|
997
|
-
// 🟢 FIX 2 : Un Buffer mémoire pour ne pas rater les textes coupés en deux !
|
|
998
|
-
let viteBuffer = "";
|
|
999
|
-
|
|
1000
996
|
devServer.stdout.on('data', (data) => {
|
|
1001
|
-
const
|
|
1002
|
-
viteBuffer += chunkText; // On accumule tout l'historique
|
|
997
|
+
const output = data.toString();
|
|
1003
998
|
|
|
1004
|
-
const lines =
|
|
999
|
+
const lines = output.split('\n');
|
|
1005
1000
|
const forbiddenTerms = [
|
|
1006
1001
|
'Attempting to bind to HOST', 'If this was unintentional', 'Learn more here:',
|
|
1007
1002
|
'Starting the development server', 'You can now view', 'vite v', 'VITE v', 'Port', 'is in use',
|
|
@@ -1017,12 +1012,12 @@ else {
|
|
|
1017
1012
|
process.stdout.write(filteredOutput + '\n');
|
|
1018
1013
|
}
|
|
1019
1014
|
|
|
1020
|
-
|
|
1021
|
-
// On cherche l'URL de Vite dans l'historique COMPLET
|
|
1022
|
-
const portMatch = viteBuffer.match(/http:\/\/(?:localhost|127\.0\.0\.1):(\d+)/);
|
|
1015
|
+
const portMatch = output.match(/http:\/\/(?:localhost|127\.0\.0\.1):(\d+)/);
|
|
1023
1016
|
|
|
1024
|
-
|
|
1025
|
-
|
|
1017
|
+
if (portMatch) {
|
|
1018
|
+
detectedPort = portMatch[1];
|
|
1019
|
+
|
|
1020
|
+
if (!connectionStarted) {
|
|
1026
1021
|
connectionStarted = true;
|
|
1027
1022
|
|
|
1028
1023
|
console.log('\x1b[33mFleetbo OS ❯\x1b[0m ---------------------------------------------------');
|
|
@@ -1030,62 +1025,57 @@ else {
|
|
|
1030
1025
|
console.log(`\x1b[33mFleetbo OS ❯\x1b[0m Please wait for the green message...`);
|
|
1031
1026
|
console.log('\x1b[33mFleetbo OS ❯\x1b[0m ---------------------------------------------------\n');
|
|
1032
1027
|
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1028
|
+
const MAX_UPLINK_RETRIES = 5;
|
|
1029
|
+
const RETRY_DELAYS = [0, 10, 20, 30, 45];
|
|
1030
|
+
let uplinkFound = false;
|
|
1031
|
+
|
|
1032
|
+
const startUplink = (attempt) => {
|
|
1033
|
+
if (uplinkFound) return;
|
|
1034
|
+
|
|
1035
|
+
const npxCmd = process.platform === 'win32' ? 'npx.cmd' : 'npx';
|
|
1036
|
+
|
|
1037
|
+
if (attempt > 0) {
|
|
1038
|
+
console.log(`\x1b[33m[Fleetbo] Uplink reconnection ${attempt}/${MAX_UPLINK_RETRIES - 1}...\x1b[0m`);
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
const uplinkCommand = `${npxCmd} -y cloudflared tunnel --url http://127.0.0.1:${detectedPort} --http-host-header 127.0.0.1:${detectedPort}`;
|
|
1042
|
+
uplinkProcess = spawn(uplinkCommand, { shell: true });
|
|
1036
1043
|
|
|
1037
|
-
const
|
|
1044
|
+
const handleUplinkOutput = (chunk) => {
|
|
1045
|
+
const text = chunk.toString();
|
|
1038
1046
|
if (uplinkFound) return;
|
|
1047
|
+
const match = text.match(/https:\/\/[a-zA-Z0-9-]+\.trycloudflare\.com/);
|
|
1048
|
+
if (match) {
|
|
1049
|
+
uplinkFound = true;
|
|
1050
|
+
setTimeout(() => {
|
|
1051
|
+
syncFirebase(process.env.VITE_FLEETBO_KEY_APP, match[0], process.env.VITE_FLEETBO_TESTER_EMAIL);
|
|
1052
|
+
}, 1500);
|
|
1053
|
+
}
|
|
1054
|
+
};
|
|
1039
1055
|
|
|
1040
|
-
|
|
1056
|
+
uplinkProcess.stdout.on('data', handleUplinkOutput);
|
|
1057
|
+
uplinkProcess.stderr.on('data', handleUplinkOutput);
|
|
1041
1058
|
|
|
1042
|
-
|
|
1043
|
-
|
|
1059
|
+
uplinkProcess.on('error', () => {
|
|
1060
|
+
if (uplinkFound) return;
|
|
1061
|
+
console.error(`\x1b[31m[Fleetbo] Uplink Connection failed to establish.\x1b[0m`);
|
|
1062
|
+
});
|
|
1063
|
+
|
|
1064
|
+
uplinkProcess.on('close', () => {
|
|
1065
|
+
if (uplinkFound) return;
|
|
1066
|
+
const nextAttempt = attempt + 1;
|
|
1067
|
+
if (nextAttempt < MAX_UPLINK_RETRIES) {
|
|
1068
|
+
const delay = RETRY_DELAYS[nextAttempt] || 30;
|
|
1069
|
+
console.log(`\x1b[33m[Fleetbo] Uplink interrupted. Fleetbo OS retrying in ${delay}s... (${nextAttempt}/${MAX_UPLINK_RETRIES - 1})\x1b[0m`);
|
|
1070
|
+
setTimeout(() => startUplink(nextAttempt), delay * 1000);
|
|
1071
|
+
} else {
|
|
1072
|
+
console.error(`\x1b[31m[Fleetbo] Secure Uplink could not be established.\x1b[0m`);
|
|
1044
1073
|
}
|
|
1074
|
+
});
|
|
1075
|
+
};
|
|
1045
1076
|
|
|
1046
|
-
|
|
1047
|
-
uplinkProcess = spawn(npxCmd, ['-y', 'cloudflared', 'tunnel', '--url', `http://127.0.0.1:${detectedPort}`, '--http-host-header', `127.0.0.1:${detectedPort}`], { shell: true });
|
|
1048
|
-
|
|
1049
|
-
// 🟢 FIX 4 : Buffer cumulatif pour l'URL Cloudflare
|
|
1050
|
-
let uplinkBuffer = "";
|
|
1051
|
-
|
|
1052
|
-
const handleUplinkOutput = (chunk) => {
|
|
1053
|
-
if (uplinkFound) return;
|
|
1054
|
-
|
|
1055
|
-
uplinkBuffer += chunk.toString(); // On accumule
|
|
1056
|
-
|
|
1057
|
-
// On cherche dans le buffer consolidé
|
|
1058
|
-
const match = uplinkBuffer.match(/https:\/\/[a-zA-Z0-9-]+\.trycloudflare\.com/i);
|
|
1059
|
-
if (match) {
|
|
1060
|
-
uplinkFound = true;
|
|
1061
|
-
setTimeout(() => {
|
|
1062
|
-
syncFirebase(process.env.VITE_FLEETBO_KEY_APP, match[0], process.env.VITE_FLEETBO_TESTER_EMAIL);
|
|
1063
|
-
}, 1500);
|
|
1064
|
-
}
|
|
1065
|
-
};
|
|
1066
|
-
|
|
1067
|
-
uplinkProcess.stdout.on('data', handleUplinkOutput);
|
|
1068
|
-
uplinkProcess.stderr.on('data', handleUplinkOutput);
|
|
1069
|
-
|
|
1070
|
-
uplinkProcess.on('error', () => {
|
|
1071
|
-
if (uplinkFound) return;
|
|
1072
|
-
console.error(`\x1b[31m[Fleetbo] Uplink Connection failed to establish.\x1b[0m`);
|
|
1073
|
-
});
|
|
1074
|
-
|
|
1075
|
-
uplinkProcess.on('close', () => {
|
|
1076
|
-
if (uplinkFound) return;
|
|
1077
|
-
const nextAttempt = attempt + 1;
|
|
1078
|
-
if (nextAttempt < MAX_UPLINK_RETRIES) {
|
|
1079
|
-
const delay = RETRY_DELAYS[nextAttempt] || 30;
|
|
1080
|
-
console.log(`\x1b[33m[Fleetbo] Uplink interrupted. Fleetbo OS retrying in ${delay}s... (${nextAttempt}/${MAX_UPLINK_RETRIES - 1})\x1b[0m`);
|
|
1081
|
-
setTimeout(() => startUplink(nextAttempt), delay * 1000);
|
|
1082
|
-
} else {
|
|
1083
|
-
console.error(`\x1b[31m[Fleetbo] Secure Uplink could not be established.\x1b[0m`);
|
|
1084
|
-
}
|
|
1085
|
-
});
|
|
1086
|
-
};
|
|
1077
|
+
startUplink(0);
|
|
1087
1078
|
|
|
1088
|
-
startUplink(0);
|
|
1089
1079
|
}
|
|
1090
1080
|
}
|
|
1091
1081
|
});
|