fleetbo-cockpit-cli 1.0.186 → 1.0.188
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 +83 -6
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -289,6 +289,79 @@ if (command === 'alex') {
|
|
|
289
289
|
return;
|
|
290
290
|
}
|
|
291
291
|
|
|
292
|
+
/* =====================================================================
|
|
293
|
+
🟢 STRICT PATCH MANUAL COMMIT INTERCEPTION 🟢
|
|
294
|
+
===================================================================== */
|
|
295
|
+
|
|
296
|
+
// 1. Strict command detection (4 words required)
|
|
297
|
+
const patchMatch = prompt.match(/^patch\s+module\s+([a-zA-Z0-9_]+)\s+(android|ios)/i);
|
|
298
|
+
|
|
299
|
+
// 2. Capture human errors (missing platform)
|
|
300
|
+
const partialPatchMatch = prompt.match(/^patch\s+module\s+([a-zA-Z0-9_]+)$/i);
|
|
301
|
+
|
|
302
|
+
if (partialPatchMatch && !patchMatch) {
|
|
303
|
+
console.log(`\n\x1b[31m⛔ REJECTED: Ambiguous command.\x1b[0m The platform is mandatory to avoid any Metal corruption.`);
|
|
304
|
+
console.log(`\x1b[36m👉 Type:\x1b[0m patch module ${partialPatchMatch[1]} android`);
|
|
305
|
+
console.log(`\x1b[36m Or:\x1b[0m patch module ${partialPatchMatch[1]} ios`);
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
if (patchMatch) {
|
|
310
|
+
const modName = patchMatch[1];
|
|
311
|
+
const targetPlatform = patchMatch[2].toLowerCase(); // 'android' or 'ios'
|
|
312
|
+
|
|
313
|
+
console.log(`\n\x1b[33m🛡️ Checking integrity for ${modName} (${targetPlatform.toUpperCase()})...\x1b[0m`);
|
|
314
|
+
|
|
315
|
+
// Cloud Verification
|
|
316
|
+
const cacheRes = await getModuleCache({ projectId, moduleName: modName });
|
|
317
|
+
if (!cacheRes.found) {
|
|
318
|
+
console.log(`\x1b[31m⛔ REJECTED:\x1b[0m The module "${modName}" does not exist in the Cloud. The first draft must ALWAYS be forged by Alex.`);
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
// Strict and absolute paths
|
|
323
|
+
const nativeExt = targetPlatform === 'android' ? 'kt' : 'swift';
|
|
324
|
+
const nativeFileName = `${modName}.${nativeExt}`;
|
|
325
|
+
const nativePathAPI = `public/native/${targetPlatform}/${nativeFileName}`;
|
|
326
|
+
const nativePathFull = path.join(process.cwd(), 'public', 'native', targetPlatform, nativeFileName);
|
|
327
|
+
|
|
328
|
+
const mockExt = JS_FRAMEWORK === 'vue' ? 'vue' : 'jsx';
|
|
329
|
+
const mockPath = path.join(process.cwd(), 'src', 'app', 'mocks', `${modName}.${mockExt}`);
|
|
330
|
+
|
|
331
|
+
// Physical existence validation
|
|
332
|
+
if (!fs.existsSync(nativePathFull)) {
|
|
333
|
+
console.log(`\x1b[31m⛔ FATAL ERROR:\x1b[0m Target file not found on disk (${nativePathAPI}).`);
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
const localNativeCode = fs.readFileSync(nativePathFull, 'utf8');
|
|
338
|
+
const localMockCode = fs.existsSync(mockPath) ? fs.readFileSync(mockPath, 'utf8') : null;
|
|
339
|
+
|
|
340
|
+
// Pushing to Cloud
|
|
341
|
+
process.stdout.write(` \x1b[33m[Patch Sync]\x1b[0m Pushing ${targetPlatform.toUpperCase()} modifications to Cloud OS...`);
|
|
342
|
+
try {
|
|
343
|
+
await axios.post(INJECT_DEPS_URL, {
|
|
344
|
+
projectId: projectId,
|
|
345
|
+
fileData: {
|
|
346
|
+
moduleName: modName,
|
|
347
|
+
path: nativePathAPI,
|
|
348
|
+
fileName: nativeFileName,
|
|
349
|
+
code: localNativeCode,
|
|
350
|
+
mockFileName: `${modName}.${mockExt}`,
|
|
351
|
+
mockCode: localMockCode,
|
|
352
|
+
isPatch: true
|
|
353
|
+
}
|
|
354
|
+
});
|
|
355
|
+
process.stdout.write(` \x1b[32mOK\x1b[0m\n`);
|
|
356
|
+
console.log(`\x1b[32m✅ SUCCESS:\x1b[0m The local version of ${nativeFileName} is now the official reference in the Cloud.`);
|
|
357
|
+
} catch (err) {
|
|
358
|
+
process.stdout.write(` \x1b[31mFAILED\x1b[0m\n`);
|
|
359
|
+
console.error(` ⚠️ OS sync failed: ${err.message}`);
|
|
360
|
+
}
|
|
361
|
+
return; // Final circuit breaker
|
|
362
|
+
}
|
|
363
|
+
/* ===================================================================== */
|
|
364
|
+
|
|
292
365
|
// 📋 INTERCEPTION: LIST MODULES (Multilingue)
|
|
293
366
|
const isListingRequest = /^(liste|list|listar|lista|quels modules|montre les modules|affiche les modules|show modules|what modules|display modules|qu[eé] m[oó]dulos|muestra los m[oó]dulos|ver m[oó]dulos)/i.test(prompt);
|
|
294
367
|
if (isListingRequest) {
|
|
@@ -786,8 +859,12 @@ else if (command === 'rm') {
|
|
|
786
859
|
console.log(`\n\x1b[33m🗑️ Annihilating module: ${moduleName}...\x1b[0m`);
|
|
787
860
|
|
|
788
861
|
// 1. Define physical paths
|
|
789
|
-
const ktPath
|
|
790
|
-
|
|
862
|
+
const ktPath = path.join(process.cwd(), 'public', 'native', 'android', `${moduleName}.kt`);
|
|
863
|
+
// 🟢 AGNOSTIQUE — cherche .jsx (React) puis .vue (Vue)
|
|
864
|
+
const jsxPath = path.join(process.cwd(), 'src', 'app', 'mocks', `${moduleName}.jsx`);
|
|
865
|
+
const vuePath = path.join(process.cwd(), 'src', 'app', 'mocks', `${moduleName}.vue`);
|
|
866
|
+
const mockPath = fs.existsSync(jsxPath) ? jsxPath : fs.existsSync(vuePath) ? vuePath : null;
|
|
867
|
+
const mockExt = mockPath ? path.extname(mockPath) : '';
|
|
791
868
|
|
|
792
869
|
let actionsDone = 0;
|
|
793
870
|
|
|
@@ -798,10 +875,10 @@ else if (command === 'rm') {
|
|
|
798
875
|
actionsDone++;
|
|
799
876
|
}
|
|
800
877
|
|
|
801
|
-
// 3. Eradicate Virtual Twin (Mock JSX)
|
|
802
|
-
if (
|
|
803
|
-
fs.unlinkSync(
|
|
804
|
-
console.log(` \x1b[32m[Deleted]\x1b[0m Virtual Twin (
|
|
878
|
+
// 3. Eradicate Virtual Twin (Mock JSX or Vue)
|
|
879
|
+
if (mockPath) {
|
|
880
|
+
fs.unlinkSync(mockPath);
|
|
881
|
+
console.log(` \x1b[32m[Deleted]\x1b[0m Virtual Twin (${mockExt}) eradicated.`);
|
|
805
882
|
actionsDone++;
|
|
806
883
|
}
|
|
807
884
|
|