fleetbo-cockpit-cli 1.0.214 → 1.0.215
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 +26 -17
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -496,44 +496,53 @@ if (command === 'alex') {
|
|
|
496
496
|
rawMsg = rawMsg.message || rawMsg.text || "Module generated.";
|
|
497
497
|
}
|
|
498
498
|
|
|
499
|
-
// LE SYSTÈME DE WRAP
|
|
500
|
-
|
|
501
|
-
const
|
|
499
|
+
// 🟢 LE SYSTÈME DE WRAP ANTI-COUPURE (Ultra Robuste)
|
|
500
|
+
// 1. On récupère la vraie largeur, ou 80 par défaut (standard des terminaux)
|
|
501
|
+
const termWidth = process.stdout.columns || 80;
|
|
502
|
+
// 2. On prend 85% de l'espace pour un confort de lecture optimal
|
|
503
|
+
const maxWidth = Math.max(40, Math.floor(termWidth * 0.85));
|
|
502
504
|
|
|
503
505
|
const wrapDynamic = (text, max) => {
|
|
504
506
|
return text.split('\n').map(line => {
|
|
505
|
-
// On
|
|
506
|
-
if (/^[\s]*[-*•\d]/.test(line) || line.startsWith(" ")
|
|
507
|
+
// On ignore les lignes de code, les listes, ou les lignes déjà courtes
|
|
508
|
+
if (/^[\s]*[-*•\d]/.test(line) || line.startsWith(" ") || line.length <= max) {
|
|
509
|
+
return line;
|
|
510
|
+
}
|
|
507
511
|
|
|
508
512
|
const words = line.split(' ');
|
|
509
513
|
let wrapped = [];
|
|
510
514
|
let currentLine = '';
|
|
511
515
|
|
|
512
|
-
words.
|
|
513
|
-
|
|
514
|
-
|
|
516
|
+
for (let i = 0; i < words.length; i++) {
|
|
517
|
+
const word = words[i];
|
|
518
|
+
|
|
519
|
+
// Sécurité : Si un mot est IMMENSE (ex: un long lien HTTP), on le force sur sa propre ligne
|
|
520
|
+
if (word.length > max) {
|
|
521
|
+
if (currentLine) wrapped.push(currentLine);
|
|
522
|
+
wrapped.push(word);
|
|
523
|
+
currentLine = '';
|
|
524
|
+
continue;
|
|
525
|
+
}
|
|
526
|
+
|
|
515
527
|
const spaceNeeded = currentLine.length > 0 ? 1 : 0;
|
|
516
528
|
|
|
529
|
+
// Est-ce que le mot rentre sur la ligne courante ?
|
|
517
530
|
if (currentLine.length + word.length + spaceNeeded > max) {
|
|
518
|
-
//
|
|
519
|
-
|
|
520
|
-
currentLine = word;
|
|
531
|
+
wrapped.push(currentLine); // Non -> on sauvegarde la ligne
|
|
532
|
+
currentLine = word; // On commence une nouvelle ligne avec ce mot
|
|
521
533
|
} else {
|
|
522
|
-
|
|
523
|
-
currentLine += (spaceNeeded ? ' ' : '') + word;
|
|
534
|
+
currentLine += (spaceNeeded ? ' ' : '') + word; // Oui -> on l'ajoute
|
|
524
535
|
}
|
|
525
|
-
}
|
|
536
|
+
}
|
|
526
537
|
|
|
527
|
-
// On n'oublie pas d'ajouter la toute dernière ligne
|
|
528
538
|
if (currentLine) wrapped.push(currentLine);
|
|
529
|
-
|
|
530
539
|
return wrapped.join('\n');
|
|
531
540
|
}).join('\n');
|
|
532
541
|
};
|
|
533
542
|
|
|
534
543
|
const formattedMsg = wrapDynamic(rawMsg, maxWidth);
|
|
535
544
|
|
|
536
|
-
console.log('\x1b[32mAlex ❯\x1b[0m
|
|
545
|
+
console.log('\x1b[32mAlex ❯\x1b[0m ' + formattedMsg);
|
|
537
546
|
}
|
|
538
547
|
|
|
539
548
|
// --- FILE CREATION LOGIC ---
|