fleetbo-cockpit-cli 1.0.94 → 1.0.95

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 +24 -13
  2. package/package.json +1 -1
package/cli.js CHANGED
@@ -120,14 +120,22 @@ const injectRouteIntoAppJs = (moduleName, subPath = '') => {
120
120
 
121
121
  let modified = false;
122
122
 
123
+ // 1. Injection de l'import (Capture l'indentation d'origine)
123
124
  if (!content.includes(importLine)) {
124
- content = content.replace(importAnchor, `${importLine}\n${importAnchor}`);
125
+ const importMatch = content.match(new RegExp(`(\\n[ \\t]*)${importAnchor.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}`));
126
+ const importIndent = importMatch ? importMatch[1] : '\n';
127
+ content = content.replace(importAnchor, `${importLine}${importIndent}${importAnchor}`);
125
128
  modified = true;
126
129
  }
130
+
131
+ // 2. Injection de la route (Capture l'indentation d'origine, fini les espaces en dur !)
127
132
  if (!content.includes(routeLine)) {
128
- content = content.replace(routeAnchor, `${routeLine}\n ${routeAnchor}`);
133
+ const routeMatch = content.match(new RegExp(`(\\n[ \\t]*)${routeAnchor.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}`));
134
+ const routeIndent = routeMatch ? routeMatch[1] : '\n';
135
+ content = content.replace(routeAnchor, `${routeLine}${routeIndent}${routeAnchor}`);
129
136
  modified = true;
130
137
  }
138
+
131
139
  if (modified) {
132
140
  fs.writeFileSync(appJsPath, content);
133
141
  }
@@ -207,15 +215,18 @@ const removeRouteFromAppJs = (moduleName) => {
207
215
 
208
216
  let content = fs.readFileSync(appJsPath, 'utf8');
209
217
 
210
- // Pattern exact pour l'import et la route (gestion du sous-dossier mocks/)
211
218
  const importLine = `import ${moduleName} from './app/mocks/${moduleName}';`;
212
219
  const routeLine = `<Route path="/mocks/${moduleName.toLowerCase()}" element={<${moduleName} />} />`;
213
220
 
214
221
  const originalContent = content;
215
222
 
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'), '');
223
+ // On supprime l'import ET le saut de ligne qui le suit
224
+ const importRegex = new RegExp(`${importLine.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\n?`, 'g');
225
+ content = content.replace(importRegex, '');
226
+
227
+ // On supprime la route ET tous les espaces/sauts de ligne qui la PRÉCÈDENT
228
+ const routeRegex = new RegExp(`\\n?\\s*${routeLine.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}`, 'g');
229
+ content = content.replace(routeRegex, '');
219
230
 
220
231
  if (content !== originalContent) {
221
232
  fs.writeFileSync(appJsPath, content);
@@ -477,13 +488,13 @@ if (command === 'alex') {
477
488
  };
478
489
 
479
490
  // ============================================================
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
- // ============================================================
491
+ // CLI PATCH — startAlexSession (cli.js)
492
+ //
493
+ // Remplace le bloc ENTIER de startAlexSession, depuis :
494
+ // const startAlexSession = async () => {
495
+ // Jusqu'à (NON INCLUS) :
496
+ // const rl = readline.createInterface({
497
+ // ============================================================
487
498
 
488
499
  const startAlexSession = async () => {
489
500
  process.stdout.write('\x1b[33m🛡️ Alex is checking runtime state...\x1b[0m\r');
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.95",
4
4
  "description": "Fleetbo CLI - Build native mobile apps with React",
5
5
  "author": "Fleetbo",
6
6
  "license": "MIT",