fleetbo-cockpit-cli 1.0.187 → 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 +73 -0
- 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) {
|