fleetbo-cockpit-cli 1.0.10 β 1.0.11
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 +52 -80
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -318,71 +318,72 @@ if (command === 'alex') {
|
|
|
318
318
|
// COMMAND: android / ios (PROPULSION BUILD)
|
|
319
319
|
// ============================================
|
|
320
320
|
else if (command === 'android' || command === 'ios') {
|
|
321
|
-
// π INTERCEPTION IOS : BLOQUAGE NET (MAINTENANCE/BETA)
|
|
322
|
-
if (command === 'ios') {
|
|
323
|
-
console.log(`\n\x1b[36mβ‘ FLEETBO IOS PROPULSION\x1b[0m`);
|
|
324
|
-
console.log(`\x1b[33m[0/3] Initializing Neural Uplink...\x1b[0m`);
|
|
325
|
-
|
|
326
|
-
// Simulation d'un petit temps de chargement pour l'effet "OS"
|
|
327
|
-
await new Promise(r => setTimeout(r, 800));
|
|
328
321
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
console.log(`\x1b[90m Please engage propulsion on Android frequency for now.\x1b[0m\n`);
|
|
332
|
-
|
|
333
|
-
process.exit(1); // ArrΓͺt propre du processus
|
|
334
|
-
}
|
|
335
|
-
checkGitSecurity();
|
|
336
|
-
const platform = command;
|
|
337
|
-
const nativeDir = platform === 'android' ? 'public/native/android/' : 'public/native/ios/';
|
|
338
|
-
const extension = platform === 'android' ? '.kt' : '.swift';
|
|
339
|
-
const nativePath = path.join(process.cwd(), nativeDir);
|
|
340
|
-
|
|
341
|
-
// VΓ©rification des modules natifs
|
|
342
|
-
let hasNativeFiles = false;
|
|
343
|
-
let nativeFileCount = 0;
|
|
344
|
-
if (fs.existsSync(nativePath)) {
|
|
345
|
-
const files = fs.readdirSync(nativePath);
|
|
346
|
-
const nativeFiles = files.filter(file => file.endsWith(extension));
|
|
347
|
-
hasNativeFiles = nativeFiles.length > 0;
|
|
348
|
-
nativeFileCount = nativeFiles.length;
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
if (!hasNativeFiles) {
|
|
352
|
-
console.log(`\n\x1b[31mβ οΈ ENGINE INCOMPLETE:\x1b[0m No native blueprints detected for \x1b[1m${platform.toUpperCase()}\x1b[0m.`);
|
|
353
|
-
console.log(`\x1b[90mAlex must architect at least one ${extension} module before deployment.\x1b[0m`);
|
|
354
|
-
console.log(`\x1b[90mRun: npm run fleetbo alex\x1b[0m\n`);
|
|
355
|
-
process.exit(1);
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
const targetUrl = platform === 'android' ? ANDROID_BUILD_URL : IOS_BUILD_URL;
|
|
359
|
-
|
|
322
|
+
// π’ DΓBUT DE LA PROTECTION (Fonction Async ImmΓ©diate)
|
|
323
|
+
// Cela garantit que le code fonctionne partout, mΓͺme via 'require()'
|
|
360
324
|
(async () => {
|
|
325
|
+
|
|
326
|
+
// π INTERCEPTION IOS : BLOQUAGE NET (MAINTENANCE/BETA)
|
|
327
|
+
if (command === 'ios') {
|
|
328
|
+
console.log(`\n\x1b[36mβ‘ FLEETBO IOS PROPULSION\x1b[0m`);
|
|
329
|
+
console.log(`\x1b[33m[0/3] Initializing Neural Uplink...\x1b[0m`);
|
|
330
|
+
|
|
331
|
+
// β
Ce 'await' est maintenant sΓ©curisΓ©
|
|
332
|
+
await new Promise(r => setTimeout(r, 800));
|
|
333
|
+
|
|
334
|
+
console.log(`\n\x1b[31mβ PROPULSION ABORTED: iOS Frequency Restricted.\x1b[0m`);
|
|
335
|
+
console.log(`\x1b[90m This module is currently reserved for Vanguard Pilots (Closed Beta).\x1b[0m`);
|
|
336
|
+
console.log(`\x1b[90m Please engage propulsion on Android frequency for now.\x1b[0m\n`);
|
|
337
|
+
|
|
338
|
+
process.exit(1);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
checkGitSecurity();
|
|
342
|
+
const platform = command;
|
|
343
|
+
const nativeDir = platform === 'android' ? 'public/native/android/' : 'public/native/ios/';
|
|
344
|
+
const extension = platform === 'android' ? '.kt' : '.swift';
|
|
345
|
+
const nativePath = path.join(process.cwd(), nativeDir);
|
|
346
|
+
|
|
347
|
+
// VΓ©rification des modules natifs
|
|
348
|
+
let hasNativeFiles = false;
|
|
349
|
+
let nativeFileCount = 0;
|
|
350
|
+
if (fs.existsSync(nativePath)) {
|
|
351
|
+
const files = fs.readdirSync(nativePath);
|
|
352
|
+
const nativeFiles = files.filter(file => file.endsWith(extension));
|
|
353
|
+
hasNativeFiles = nativeFiles.length > 0;
|
|
354
|
+
nativeFileCount = nativeFiles.length;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
if (!hasNativeFiles) {
|
|
358
|
+
console.log(`\n\x1b[31mβ οΈ ENGINE INCOMPLETE:\x1b[0m No native blueprints detected for \x1b[1m${platform.toUpperCase()}\x1b[0m.`);
|
|
359
|
+
console.log(`\x1b[90mAlex must architect at least one ${extension} module before deployment.\x1b[0m`);
|
|
360
|
+
console.log(`\x1b[90mRun: npm run fleetbo alex\x1b[0m\n`);
|
|
361
|
+
process.exit(1);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
const targetUrl = platform === 'android' ? ANDROID_BUILD_URL : IOS_BUILD_URL;
|
|
365
|
+
|
|
361
366
|
console.log(`\n\x1b[36mβ‘ FLEETBO ${platform.toUpperCase()} PROPULSION\x1b[0m`);
|
|
362
367
|
console.log(`\x1b[90m ${nativeFileCount} native module(s) detected\x1b[0m\n`);
|
|
363
368
|
|
|
364
369
|
try {
|
|
365
370
|
// ==========================================================
|
|
366
|
-
//
|
|
371
|
+
// PRE-FLIGHT CHECK QUOTAS
|
|
367
372
|
// ==========================================================
|
|
368
373
|
process.stdout.write(`\x1b[33m[0/3]\x1b[0m Checking Propulsion Quotas... `);
|
|
369
374
|
try {
|
|
370
375
|
await axios.post(targetUrl, {}, {
|
|
371
376
|
headers: {
|
|
372
377
|
'x-project-id': projectId,
|
|
373
|
-
'x-preflight': 'true'
|
|
378
|
+
'x-preflight': 'true'
|
|
374
379
|
}
|
|
375
380
|
});
|
|
376
381
|
process.stdout.write(`\x1b[32mOK\x1b[0m\n\n`);
|
|
377
382
|
} catch (preflightError) {
|
|
378
383
|
process.stdout.write(`\x1b[31mDENIED\x1b[0m\n`);
|
|
379
|
-
|
|
380
|
-
// π’ AJOUT CRITIQUE : On capture le message d'erreur du Cloud (JSON)
|
|
381
384
|
if (preflightError.response && preflightError.response.data && preflightError.response.data.error) {
|
|
382
|
-
// On remplace l'erreur technique Axios par le message mΓ©tier clair
|
|
383
385
|
throw new Error(preflightError.response.data.error);
|
|
384
386
|
}
|
|
385
|
-
// Fait sauter le code directement au "catch" global du bas sans jamais builder
|
|
386
387
|
throw preflightError;
|
|
387
388
|
}
|
|
388
389
|
|
|
@@ -390,7 +391,6 @@ else if (command === 'android' || command === 'ios') {
|
|
|
390
391
|
console.log(`\x1b[33m[1/3]\x1b[0m Building React bundle...`);
|
|
391
392
|
execSync('npm run build', { stdio: 'inherit' });
|
|
392
393
|
|
|
393
|
-
// DΓ©terminer le dossier de build
|
|
394
394
|
let buildDir = fs.existsSync(path.join(process.cwd(), 'dist')) ? 'dist' : 'build';
|
|
395
395
|
const buildPath = path.join(process.cwd(), buildDir);
|
|
396
396
|
|
|
@@ -398,7 +398,7 @@ else if (command === 'android' || command === 'ios') {
|
|
|
398
398
|
throw new Error(`Build directory not found: ${buildDir}`);
|
|
399
399
|
}
|
|
400
400
|
|
|
401
|
-
// Γtape 2: CrΓ©er le ZIP
|
|
401
|
+
// Γtape 2: CrΓ©er le ZIP
|
|
402
402
|
console.log(`\n\x1b[33m[2/3]\x1b[0m Packaging bundle + native modules...`);
|
|
403
403
|
|
|
404
404
|
const zipBuffer = await new Promise((resolve, reject) => {
|
|
@@ -412,41 +412,20 @@ else if (command === 'android' || command === 'ios') {
|
|
|
412
412
|
if (err.code !== 'ENOENT') reject(err);
|
|
413
413
|
});
|
|
414
414
|
|
|
415
|
-
// ============================================================
|
|
416
|
-
// π¦ STRUCTURE DU ZIP (Compatible Fastfile + Cloud Function)
|
|
417
|
-
// ============================================================
|
|
418
|
-
// build.zip
|
|
419
|
-
// βββ build/
|
|
420
|
-
// βββ index.html β Pour assets/ (WebView)
|
|
421
|
-
// βββ static/
|
|
422
|
-
// βββ native/
|
|
423
|
-
// βββ android/ β Pour modules/ (.kt)
|
|
424
|
-
// βββ CameraModule.kt
|
|
425
|
-
// ============================================================
|
|
426
|
-
|
|
427
|
-
// 1. Ajouter le bundle React (dans build/)
|
|
428
415
|
archive.directory(buildPath, 'build');
|
|
429
|
-
console.log(` \x1b[32mβ\x1b[0m React bundle included`);
|
|
430
|
-
|
|
431
|
-
// 2. Ajouter les modules natifs (dans build/native/android/ ou build/native/ios/)
|
|
432
|
-
// Le Fastfile cherche: temp/build/native/android/*.kt
|
|
433
|
-
// La Cloud Function cherche: native/android/*.kt (dans le ZIP)
|
|
434
416
|
if (fs.existsSync(nativePath)) {
|
|
435
417
|
archive.directory(nativePath, `build/native/${platform}`);
|
|
436
|
-
console.log(` \x1b[32mβ\x1b[0m Native modules included (${nativeFileCount} files)`);
|
|
437
418
|
}
|
|
438
|
-
|
|
439
419
|
archive.finalize();
|
|
440
420
|
});
|
|
441
421
|
|
|
442
422
|
const sizeMB = (zipBuffer.length / 1024 / 1024).toFixed(2);
|
|
443
423
|
console.log(` \x1b[32mβ\x1b[0m Bundle ready: ${sizeMB} MB`);
|
|
444
424
|
|
|
445
|
-
// Γtape 3: Upload
|
|
425
|
+
// Γtape 3: Upload
|
|
446
426
|
console.log(`\n\x1b[33m[3/3]\x1b[0m Uploading to Fleetbo OS...`);
|
|
447
427
|
await showEnergyTransfer();
|
|
448
428
|
|
|
449
|
-
// π’ ON UTILISE UNE VARIABLE LOCALE POUR LA RΓPONSE
|
|
450
429
|
let uploadResponse;
|
|
451
430
|
try {
|
|
452
431
|
uploadResponse = await axios.post(targetUrl, zipBuffer, {
|
|
@@ -456,40 +435,33 @@ else if (command === 'android' || command === 'ios') {
|
|
|
456
435
|
},
|
|
457
436
|
maxContentLength: Infinity,
|
|
458
437
|
maxBodyLength: Infinity,
|
|
459
|
-
timeout: 120000
|
|
438
|
+
timeout: 120000
|
|
460
439
|
});
|
|
461
440
|
} catch (axiosError) {
|
|
462
|
-
// π SI AXIOS PLANTE (400, 403, 500), ON LANCE UNE ERREUR CLAIRE POUR LE CATCH GLOBAL
|
|
463
|
-
// axiosError.response.data contient le JSON renvoyΓ© par FandroidBuild
|
|
464
441
|
if (axiosError.response && axiosError.response.data && axiosError.response.data.error) {
|
|
465
442
|
throw new Error(axiosError.response.data.error);
|
|
466
443
|
} else {
|
|
467
|
-
// Timeout ou erreur rΓ©seau pure
|
|
468
444
|
throw new Error(`Connection to OS failed: ${axiosError.message}`);
|
|
469
445
|
}
|
|
470
446
|
}
|
|
471
447
|
|
|
472
|
-
// π’ SI AXIOS RΓUSSIT MAIS QUE LA RΓPONSE N'EST PAS UN SUCCΓS LOGIQUE
|
|
473
448
|
if (uploadResponse.data && uploadResponse.data.success) {
|
|
474
449
|
console.log(`\n\x1b[32mββββββββββββββββββββββββββββββββββββββββββββββββββββββββ\x1b[0m`);
|
|
475
450
|
console.log(`\x1b[32mβ ${platform.toUpperCase()} PROPULSION SUCCESSFUL\x1b[0m`);
|
|
476
451
|
console.log(`\x1b[32mββββββββββββββββββββββββββββββββββββββββββββββββββββββββ\x1b[0m`);
|
|
477
452
|
console.log(`\x1b[90m Deployment ID: ${uploadResponse.data.deploymentId || 'N/A'}\x1b[0m`);
|
|
478
|
-
console.log(`\x1b[90m
|
|
453
|
+
console.log(`\x1b[90m ${uploadResponse.data.message || 'Complete.'}\x1b[0m\n`);
|
|
479
454
|
} else {
|
|
480
|
-
// Ce cas ne devrait pas arriver si le backend est bien codΓ© (il renverrait une erreur HTTP), mais au cas oΓΉ :
|
|
481
455
|
throw new Error(uploadResponse.data?.error || 'Unknown logical error from Factory');
|
|
482
456
|
}
|
|
483
457
|
|
|
484
|
-
} catch (error) {
|
|
458
|
+
} catch (error) {
|
|
485
459
|
console.log(`\n\x1b[31mββββββββββββββββββββββββββββββββββββββββββββββββββββββββ\x1b[0m`);
|
|
486
460
|
console.log(`\x1b[31mβ PROPULSION FAILED\x1b[0m`);
|
|
487
461
|
console.log(`\x1b[31mββββββββββββββββββββββββββββββββββββββββββββββββββββββββ\x1b[0m`);
|
|
488
462
|
|
|
489
|
-
// L'erreur est maintenant propre, on l'affiche directement
|
|
490
463
|
console.error(`\x1b[31m Error:\x1b[0m ${error.message}`);
|
|
491
464
|
|
|
492
|
-
// Messages d'aide selon l'erreur
|
|
493
465
|
if (error.message.includes('Limit') || error.message.includes('Quota')) {
|
|
494
466
|
console.log(`\n\x1b[33m π‘ Tip:\x1b[0m Upgrade to Senior Pilot for more builds.`);
|
|
495
467
|
} else if (error.message.includes('No native module')) {
|
|
@@ -497,11 +469,11 @@ else if (command === 'android' || command === 'ios') {
|
|
|
497
469
|
} else if (error.message.includes('Trial Period Ended')) {
|
|
498
470
|
console.log(`\n\x1b[33m π‘ Tip:\x1b[0m Your free sprint is over. Upgrade to Senior Pilot on fleetbo.io.`);
|
|
499
471
|
}
|
|
500
|
-
|
|
501
472
|
console.log('');
|
|
502
473
|
process.exit(1);
|
|
503
474
|
}
|
|
504
|
-
|
|
475
|
+
|
|
476
|
+
})(); // π’ FIN DE LA PROTECTION
|
|
505
477
|
}
|
|
506
478
|
// ============================================
|
|
507
479
|
// COMMAND: page / g / generate
|