fleetbo-cockpit-cli 1.0.184 → 1.0.186

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 +10 -11
  2. package/package.json +1 -1
package/cli.js CHANGED
@@ -142,15 +142,12 @@ const injectRouteIntoAppJs = (moduleName, subPath = '') => {
142
142
  }
143
143
 
144
144
  const cleanSubPath = subPath ? `${subPath}/` : '';
145
- let importLine, routeLine;
146
-
145
+ // 🟢 IMPORT UNIFIÉ — Vite résout l'extension automatiquement (React & Vue)
146
+ const importLine = `import ${moduleName} from './app/${cleanSubPath}${moduleName}';`;
147
+ let routeLine;
147
148
  if (JS_FRAMEWORK === 'vue') {
148
- // 🟢 SYNTAXE VUE
149
- importLine = `import ${moduleName} from './app/${cleanSubPath}${moduleName}.vue';`;
150
149
  routeLine = `{ path: '/${cleanSubPath}${moduleName.toLowerCase()}', component: ${moduleName} },`;
151
150
  } else {
152
- // 🔵 SYNTAXE REACT
153
- importLine = `import ${moduleName} from './app/${cleanSubPath}${moduleName}';`;
154
151
  routeLine = `<Route path="/${cleanSubPath}${moduleName.toLowerCase()}" element={<${moduleName} />} />`;
155
152
  }
156
153
 
@@ -251,18 +248,20 @@ const removeRouteFromAppJs = (moduleName) => {
251
248
 
252
249
  let content = fs.readFileSync(targetFile, 'utf8');
253
250
 
254
- let importLine, routeLine;
251
+ let routeLine;
255
252
  if (JS_FRAMEWORK === 'vue') {
256
- importLine = `import ${moduleName} from './app/mocks/${moduleName}.vue';`;
257
253
  routeLine = `{ path: '/mocks/${moduleName.toLowerCase()}', component: ${moduleName} },`;
258
254
  } else {
259
- importLine = `import ${moduleName} from './app/mocks/${moduleName}';`;
260
255
  routeLine = `<Route path="/mocks/${moduleName.toLowerCase()}" element={<${moduleName} />} />`;
261
256
  }
262
257
 
263
258
  const originalContent = content;
264
259
 
265
- const importRegex = new RegExp(`${importLine.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\n?`, 'g');
260
+ // 🟢 REGEX INTELLIGENTE — supprime l'import peu importe l'extension (.vue, .jsx, ou aucune)
261
+ const importRegex = new RegExp(
262
+ `import\\s+${moduleName}\\s+from\\s+['"]\\./app/mocks/${moduleName}(?:\\.jsx|\\.vue)?['"];?\\n?`,
263
+ 'g'
264
+ );
266
265
  content = content.replace(importRegex, '');
267
266
 
268
267
  const routeRegex = new RegExp(`\\n?\\s*${routeLine.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}`, 'g');
@@ -496,7 +495,7 @@ if (command === 'alex') {
496
495
  }
497
496
 
498
497
  if (mockCode && mockFileName) {
499
- const pageName = mockFileName.replace('.jsx', '');
498
+ const pageName = mockFileName.replace(/\.(jsx|vue)$/, '');
500
499
  writeFile('src/app/mocks/', mockFileName, mockCode);
501
500
  const injected = injectRouteIntoAppJs(pageName, 'mocks');
502
501
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fleetbo-cockpit-cli",
3
- "version": "1.0.184",
3
+ "version": "1.0.186",
4
4
  "description": "Fleetbo CLI - Build native mobile apps with React",
5
5
  "author": "Fleetbo",
6
6
  "license": "MIT",