fleetbo-cockpit-cli 1.0.244 → 1.0.245
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 +63 -53
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -973,13 +973,14 @@ else {
|
|
|
973
973
|
killProcessOnPort(PORT);
|
|
974
974
|
|
|
975
975
|
if (!testerEmail) {
|
|
976
|
-
console.error('\x1b[31m[Error]
|
|
976
|
+
console.error('\x1b[31m[Error] VITE_FLEETBO_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
|
-
|
|
982
|
+
// 🟢 FIX 1 : On sépare les arguments dans un tableau pour éviter les crashs de processus sous Windows
|
|
983
|
+
const devServer = spawn(npmCmd, ['run', 'dev', '--silent', '--', '--host', '127.0.0.1', '--port', String(PORT)], {
|
|
983
984
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
984
985
|
shell: true,
|
|
985
986
|
env: {
|
|
@@ -993,10 +994,14 @@ else {
|
|
|
993
994
|
let connectionStarted = false;
|
|
994
995
|
let detectedPort = PORT;
|
|
995
996
|
|
|
997
|
+
// 🟢 FIX 2 : Un Buffer mémoire pour ne pas rater les textes coupés en deux !
|
|
998
|
+
let viteBuffer = "";
|
|
999
|
+
|
|
996
1000
|
devServer.stdout.on('data', (data) => {
|
|
997
|
-
const
|
|
1001
|
+
const chunkText = data.toString();
|
|
1002
|
+
viteBuffer += chunkText; // On accumule tout l'historique
|
|
998
1003
|
|
|
999
|
-
const lines =
|
|
1004
|
+
const lines = chunkText.split('\n');
|
|
1000
1005
|
const forbiddenTerms = [
|
|
1001
1006
|
'Attempting to bind to HOST', 'If this was unintentional', 'Learn more here:',
|
|
1002
1007
|
'Starting the development server', 'You can now view', 'vite v', 'VITE v', 'Port', 'is in use',
|
|
@@ -1012,12 +1017,12 @@ else {
|
|
|
1012
1017
|
process.stdout.write(filteredOutput + '\n');
|
|
1013
1018
|
}
|
|
1014
1019
|
|
|
1015
|
-
|
|
1020
|
+
if (!connectionStarted) {
|
|
1021
|
+
// On cherche l'URL de Vite dans l'historique COMPLET
|
|
1022
|
+
const portMatch = viteBuffer.match(/http:\/\/(?:localhost|127\.0\.0\.1):(\d+)/);
|
|
1016
1023
|
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
if (!connectionStarted) {
|
|
1024
|
+
if (portMatch) {
|
|
1025
|
+
detectedPort = portMatch[1];
|
|
1021
1026
|
connectionStarted = true;
|
|
1022
1027
|
|
|
1023
1028
|
console.log('\x1b[33mFleetbo OS ❯\x1b[0m ---------------------------------------------------');
|
|
@@ -1025,57 +1030,62 @@ else {
|
|
|
1025
1030
|
console.log(`\x1b[33mFleetbo OS ❯\x1b[0m Please wait for the green message...`);
|
|
1026
1031
|
console.log('\x1b[33mFleetbo OS ❯\x1b[0m ---------------------------------------------------\n');
|
|
1027
1032
|
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
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 });
|
|
1033
|
+
const MAX_UPLINK_RETRIES = 5;
|
|
1034
|
+
const RETRY_DELAYS = [0, 10, 20, 30, 45];
|
|
1035
|
+
let uplinkFound = false;
|
|
1043
1036
|
|
|
1044
|
-
const
|
|
1045
|
-
const text = chunk.toString();
|
|
1037
|
+
const startUplink = (attempt) => {
|
|
1046
1038
|
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
|
-
};
|
|
1055
1039
|
|
|
1056
|
-
|
|
1057
|
-
uplinkProcess.stderr.on('data', handleUplinkOutput);
|
|
1040
|
+
const npxCmd = process.platform === 'win32' ? 'npx.cmd' : 'npx';
|
|
1058
1041
|
|
|
1059
|
-
|
|
1060
|
-
|
|
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`);
|
|
1042
|
+
if (attempt > 0) {
|
|
1043
|
+
console.log(`\x1b[33m[Fleetbo] Uplink reconnection ${attempt}/${MAX_UPLINK_RETRIES - 1}...\x1b[0m`);
|
|
1073
1044
|
}
|
|
1074
|
-
});
|
|
1075
|
-
};
|
|
1076
1045
|
|
|
1077
|
-
|
|
1046
|
+
// 🟢 FIX 3 : Safe spawn array pour Cloudflared
|
|
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
|
+
};
|
|
1078
1087
|
|
|
1088
|
+
startUplink(0);
|
|
1079
1089
|
}
|
|
1080
1090
|
}
|
|
1081
1091
|
});
|