fleetbo-cockpit-cli 1.0.185 → 1.0.187
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 +15 -9
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -248,8 +248,6 @@ const removeRouteFromAppJs = (moduleName) => {
|
|
|
248
248
|
|
|
249
249
|
let content = fs.readFileSync(targetFile, 'utf8');
|
|
250
250
|
|
|
251
|
-
// 🟢 IMPORT UNIFIÉ — Vite résout l'extension automatiquement (React & Vue)
|
|
252
|
-
const importLine = `import ${moduleName} from './app/mocks/${moduleName}';`;
|
|
253
251
|
let routeLine;
|
|
254
252
|
if (JS_FRAMEWORK === 'vue') {
|
|
255
253
|
routeLine = `{ path: '/mocks/${moduleName.toLowerCase()}', component: ${moduleName} },`;
|
|
@@ -259,7 +257,11 @@ const removeRouteFromAppJs = (moduleName) => {
|
|
|
259
257
|
|
|
260
258
|
const originalContent = content;
|
|
261
259
|
|
|
262
|
-
|
|
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
|
+
);
|
|
263
265
|
content = content.replace(importRegex, '');
|
|
264
266
|
|
|
265
267
|
const routeRegex = new RegExp(`\\n?\\s*${routeLine.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}`, 'g');
|
|
@@ -784,8 +786,12 @@ else if (command === 'rm') {
|
|
|
784
786
|
console.log(`\n\x1b[33m🗑️ Annihilating module: ${moduleName}...\x1b[0m`);
|
|
785
787
|
|
|
786
788
|
// 1. Define physical paths
|
|
787
|
-
const ktPath
|
|
788
|
-
|
|
789
|
+
const ktPath = path.join(process.cwd(), 'public', 'native', 'android', `${moduleName}.kt`);
|
|
790
|
+
// 🟢 AGNOSTIQUE — cherche .jsx (React) puis .vue (Vue)
|
|
791
|
+
const jsxPath = path.join(process.cwd(), 'src', 'app', 'mocks', `${moduleName}.jsx`);
|
|
792
|
+
const vuePath = path.join(process.cwd(), 'src', 'app', 'mocks', `${moduleName}.vue`);
|
|
793
|
+
const mockPath = fs.existsSync(jsxPath) ? jsxPath : fs.existsSync(vuePath) ? vuePath : null;
|
|
794
|
+
const mockExt = mockPath ? path.extname(mockPath) : '';
|
|
789
795
|
|
|
790
796
|
let actionsDone = 0;
|
|
791
797
|
|
|
@@ -796,10 +802,10 @@ else if (command === 'rm') {
|
|
|
796
802
|
actionsDone++;
|
|
797
803
|
}
|
|
798
804
|
|
|
799
|
-
// 3. Eradicate Virtual Twin (Mock JSX)
|
|
800
|
-
if (
|
|
801
|
-
fs.unlinkSync(
|
|
802
|
-
console.log(` \x1b[32m[Deleted]\x1b[0m Virtual Twin (
|
|
805
|
+
// 3. Eradicate Virtual Twin (Mock JSX or Vue)
|
|
806
|
+
if (mockPath) {
|
|
807
|
+
fs.unlinkSync(mockPath);
|
|
808
|
+
console.log(` \x1b[32m[Deleted]\x1b[0m Virtual Twin (${mockExt}) eradicated.`);
|
|
803
809
|
actionsDone++;
|
|
804
810
|
}
|
|
805
811
|
|