fleetbo-cockpit-cli 1.0.94 → 1.0.96

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 +32 -14
  2. package/package.json +1 -1
package/cli.js CHANGED
@@ -1,4 +1,10 @@
1
1
  #!/usr/bin/env node
2
+
3
+ // 🥷 SILENCIEUX ABSOLU : S'exécute en 0.1ms pour tuer la plomberie de NPM
4
+ // \x1b[1A remonte d'une ligne, \x1b[2K efface la ligne. On le fait 4 fois pour écraser le bloc npm.
5
+ process.stdout.write("\x1b[1A\x1b[2K".repeat(4));
6
+ console.clear();
7
+
2
8
  const { spawn, execSync } = require('child_process');
3
9
  const fs = require('fs');
4
10
  const path = require('path');
@@ -120,14 +126,22 @@ const injectRouteIntoAppJs = (moduleName, subPath = '') => {
120
126
 
121
127
  let modified = false;
122
128
 
129
+ // 1. Injection de l'import (Capture l'indentation d'origine)
123
130
  if (!content.includes(importLine)) {
124
- content = content.replace(importAnchor, `${importLine}\n${importAnchor}`);
131
+ const importMatch = content.match(new RegExp(`(\\n[ \\t]*)${importAnchor.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}`));
132
+ const importIndent = importMatch ? importMatch[1] : '\n';
133
+ content = content.replace(importAnchor, `${importLine}${importIndent}${importAnchor}`);
125
134
  modified = true;
126
135
  }
136
+
137
+ // 2. Injection de la route (Capture l'indentation d'origine, fini les espaces en dur !)
127
138
  if (!content.includes(routeLine)) {
128
- content = content.replace(routeAnchor, `${routeLine}\n ${routeAnchor}`);
139
+ const routeMatch = content.match(new RegExp(`(\\n[ \\t]*)${routeAnchor.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}`));
140
+ const routeIndent = routeMatch ? routeMatch[1] : '\n';
141
+ content = content.replace(routeAnchor, `${routeLine}${routeIndent}${routeAnchor}`);
129
142
  modified = true;
130
143
  }
144
+
131
145
  if (modified) {
132
146
  fs.writeFileSync(appJsPath, content);
133
147
  }
@@ -207,15 +221,18 @@ const removeRouteFromAppJs = (moduleName) => {
207
221
 
208
222
  let content = fs.readFileSync(appJsPath, 'utf8');
209
223
 
210
- // Pattern exact pour l'import et la route (gestion du sous-dossier mocks/)
211
224
  const importLine = `import ${moduleName} from './app/mocks/${moduleName}';`;
212
225
  const routeLine = `<Route path="/mocks/${moduleName.toLowerCase()}" element={<${moduleName} />} />`;
213
226
 
214
227
  const originalContent = content;
215
228
 
216
- // On retire les lignes si elles existent (avec le retour à la ligne)
217
- content = content.replace(new RegExp(`${importLine.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\n?`, 'g'), '');
218
- content = content.replace(new RegExp(`\\s*${routeLine.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\n?`, 'g'), '');
229
+ // On supprime l'import ET le saut de ligne qui le suit
230
+ const importRegex = new RegExp(`${importLine.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\n?`, 'g');
231
+ content = content.replace(importRegex, '');
232
+
233
+ // On supprime la route ET tous les espaces/sauts de ligne qui la PRÉCÈDENT
234
+ const routeRegex = new RegExp(`\\n?\\s*${routeLine.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}`, 'g');
235
+ content = content.replace(routeRegex, '');
219
236
 
220
237
  if (content !== originalContent) {
221
238
  fs.writeFileSync(appJsPath, content);
@@ -477,13 +494,13 @@ if (command === 'alex') {
477
494
  };
478
495
 
479
496
  // ============================================================
480
- // CLI PATCH — startAlexSession (cli.js)
481
- //
482
- // Remplace le bloc ENTIER de startAlexSession, depuis :
483
- // const startAlexSession = async () => {
484
- // Jusqu'à (NON INCLUS) :
485
- // const rl = readline.createInterface({
486
- // ============================================================
497
+ // CLI PATCH — startAlexSession (cli.js)
498
+ //
499
+ // Remplace le bloc ENTIER de startAlexSession, depuis :
500
+ // const startAlexSession = async () => {
501
+ // Jusqu'à (NON INCLUS) :
502
+ // const rl = readline.createInterface({
503
+ // ============================================================
487
504
 
488
505
  const startAlexSession = async () => {
489
506
  process.stdout.write('\x1b[33m🛡️ Alex is checking runtime state...\x1b[0m\r');
@@ -1002,7 +1019,8 @@ else {
1002
1019
  '➜ Network', // Cache l'URL réseau
1003
1020
  'press h + enter',
1004
1021
  '> vite', // Au cas où npm force l'affichage
1005
- '> fleetbo'
1022
+ '> fleetbo',
1023
+ '> npx fleetbo-cockpit-cli@latest'
1006
1024
  ];
1007
1025
 
1008
1026
  // On filtre les lignes pour ne garder que le vrai code/debug
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fleetbo-cockpit-cli",
3
- "version": "1.0.94",
3
+ "version": "1.0.96",
4
4
  "description": "Fleetbo CLI - Build native mobile apps with React",
5
5
  "author": "Fleetbo",
6
6
  "license": "MIT",