create-fleetbo-project 1.2.84 → 1.2.85
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/install-react-template.js +55 -38
- package/package.json +1 -1
|
@@ -91,17 +91,22 @@ const injectRouteIntoAppJs = (moduleName, subPath = '') => {
|
|
|
91
91
|
console.error(\` \\x1b[31m[Safety Stop]\\x1b[0m App.js missing.\`);
|
|
92
92
|
return false;
|
|
93
93
|
}
|
|
94
|
-
|
|
94
|
+
|
|
95
|
+
let content = fs.readFileSync(appJsPath, 'utf8');
|
|
95
96
|
const importAnchor = '// FLEETBO_MORE_IMPORTS';
|
|
96
|
-
const routeAnchor
|
|
97
|
+
const routeAnchor = '{/* FLEETBO_DYNAMIC ROUTES */}';
|
|
98
|
+
|
|
97
99
|
if (!content.includes(importAnchor) || !content.includes(routeAnchor)) {
|
|
98
|
-
console.log(\` \\x1b[33m[Skipped]\\x1b[0m Anchors missing in App.js.\`);
|
|
100
|
+
console.log(\` \\x1b[33m[Skipped]\\x1b[0m Anchors missing in App.js. Manual injection required.\`);
|
|
99
101
|
return false;
|
|
100
102
|
}
|
|
103
|
+
|
|
101
104
|
const cleanSubPath = subPath ? \`\${subPath}/\` : '';
|
|
102
105
|
const importLine = \`import \${moduleName} from './app/\${cleanSubPath}\${moduleName}';\`;
|
|
103
106
|
const routeLine = \`<Route path="/\${cleanSubPath}\${moduleName.toLowerCase()}" element={<\${moduleName} />} />\`;
|
|
107
|
+
|
|
104
108
|
let modified = false;
|
|
109
|
+
|
|
105
110
|
if (!content.includes(importLine)) {
|
|
106
111
|
content = content.replace(importAnchor, \`\${importLine}\\n\${importAnchor}\`);
|
|
107
112
|
modified = true;
|
|
@@ -114,6 +119,7 @@ const injectRouteIntoAppJs = (moduleName, subPath = '') => {
|
|
|
114
119
|
fs.writeFileSync(appJsPath, content);
|
|
115
120
|
console.log(\` \\x1b[32m[Routed]\\x1b[0m \${moduleName} injected into App.js safely.\`);
|
|
116
121
|
}
|
|
122
|
+
|
|
117
123
|
return modified;
|
|
118
124
|
};
|
|
119
125
|
const showEnergyTransfer = async () => {
|
|
@@ -157,20 +163,29 @@ if (command === 'alex') {
|
|
|
157
163
|
const tierLabel = aiData.tier === 'senior' ? 'SENIOR' : aiData.tier === 'expert' ? 'EXPERT' : 'JUNIOR';
|
|
158
164
|
const percent = Math.round((remaining / limit) * 100);
|
|
159
165
|
const energyColor = percent > 20 ? '\\x1b[32m' : '\\x1b[31m';
|
|
160
|
-
console.log(\`\\x1b[36m⚡ Architect Fuel:\\x1b[0m \${energyColor}\${percent}
|
|
166
|
+
console.log(\`\\x1b[36m⚡ Architect Fuel:\\x1b[0m \${energyColor}\${percent}%\\x1b[0m (\${remaining}/\${limit} instructions left) [\${tierLabel}]\`);
|
|
161
167
|
console.log('');
|
|
162
168
|
}
|
|
163
169
|
}
|
|
164
170
|
if (aiData.status === 'success' && aiData.moduleData) {
|
|
165
|
-
const { fileName, code, mockFileName, mockCode, moduleName, instructions } = aiData.moduleData;
|
|
166
|
-
console.log(\` \\x1b[90m Architecting: \${moduleName}
|
|
171
|
+
const { fileName, code, mockFileName, mockCode, moduleName, instructions, config_offload } = aiData.moduleData;
|
|
172
|
+
console.log(\` \\x1b[90m Architecting: \${moduleName}\\x1b[0m\`);
|
|
167
173
|
const writeFile = (dir, name, content) => {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
174
|
+
const fullPath = path.join(process.cwd(), dir);
|
|
175
|
+
const filePath = path.join(fullPath, name);
|
|
176
|
+
if (!fs.existsSync(fullPath)) fs.mkdirSync(fullPath, { recursive: true });
|
|
171
177
|
fs.writeFileSync(filePath, content);
|
|
172
|
-
console.log(\`
|
|
178
|
+
console.log(\` \\x1b[32m[Written]\\x1b[0m \${dir}\${name}\`);
|
|
173
179
|
};
|
|
180
|
+
if (instructions && Array.isArray(instructions) && instructions.length > 0) {
|
|
181
|
+
console.log('\\n\\x1b[33m--- GUIDE (MCI) ---\\x1b[0m');
|
|
182
|
+
instructions.forEach(line => {
|
|
183
|
+
if (typeof line === 'string') {
|
|
184
|
+
const formattedLine = line.replace(/ACTION|CAPTURE|PERSPECTIVE/g, '\\x1b[1m$&\\x1b[0m');
|
|
185
|
+
console.log(\` \${formattedLine}\`);
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
}
|
|
174
189
|
if (code && fileName) {
|
|
175
190
|
const folder = fileName.endsWith('.kt') ? 'public/native/android/' : 'src/app/';
|
|
176
191
|
writeFile(folder, fileName, code);
|
|
@@ -181,11 +196,11 @@ if (command === 'alex') {
|
|
|
181
196
|
writeFile('src/app/mocks/', mockFileName, mockCode);
|
|
182
197
|
const injected = injectRouteIntoAppJs(pageName, 'mocks');
|
|
183
198
|
if (injected) {
|
|
184
|
-
console.log(\` \\x1b[32m[Routed]
|
|
199
|
+
console.log(\` \\x1b[32m[Routed]\\x1b[0m App.js -> /mocks/\${pageName.toLowerCase()}\`);
|
|
185
200
|
}
|
|
186
201
|
}
|
|
187
202
|
if (config_offload && (config_offload.dependencies?.length > 0 || config_offload.permissions?.length > 0)) {
|
|
188
|
-
process.stdout.write(\`
|
|
203
|
+
process.stdout.write(\` \\x1b[33m[Cloud Inject]\\x1b[0m Syncing \${config_offload.dependencies.length} libs to Factory...\`);
|
|
189
204
|
try {
|
|
190
205
|
await axios.post(INJECT_DEPS_URL, {
|
|
191
206
|
projectId: projectId,
|
|
@@ -194,21 +209,12 @@ if (command === 'alex') {
|
|
|
194
209
|
config_offload: config_offload
|
|
195
210
|
}
|
|
196
211
|
});
|
|
197
|
-
process.stdout.write(\` \\x1b[32mOK
|
|
212
|
+
process.stdout.write(\` \\x1b[32mOK\\x1b[0m\\n\`);
|
|
198
213
|
} catch (err) {
|
|
199
|
-
process.stdout.write(\` \\x1b[31mFAILED
|
|
200
|
-
console.error(\`
|
|
214
|
+
process.stdout.write(\` \\x1b[31mFAILED\\x1b[0m\\n\`);
|
|
215
|
+
console.error(\` ⚠️ Config sync failed: \${err.message}\`);
|
|
201
216
|
}
|
|
202
217
|
}
|
|
203
|
-
if (instructions && Array.isArray(instructions) && instructions.length > 0) {
|
|
204
|
-
console.log('\\n\\x1b[33m--- GUIDE (MCI) ---\\x1b[0m');
|
|
205
|
-
instructions.forEach(line => {
|
|
206
|
-
if (typeof line === 'string') {
|
|
207
|
-
const formattedLine = line.replace(/ACTION|CAPTURE|PERSPECTIVE/g, '\\x1b[1m$&\\x1b[0m');
|
|
208
|
-
console.log(\` \${formattedLine}\`);
|
|
209
|
-
}
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
218
|
}
|
|
213
219
|
} catch (error) {
|
|
214
220
|
process.stdout.write('\\r' + ' '.repeat(50) + '\\r');
|
|
@@ -275,7 +281,7 @@ if (command === 'alex') {
|
|
|
275
281
|
if (command === 'android' || command === 'ios') {
|
|
276
282
|
checkGitSecurity();
|
|
277
283
|
const platform = command;
|
|
278
|
-
const nativeDir = platform === 'android' ? 'public/native/android/' : 'public/native/ios/';
|
|
284
|
+
const nativeDir = platform === 'android' ? 'public/native/android/' : 'public/native/ios/';
|
|
279
285
|
const extension = platform === 'android' ? '.kt' : '.swift';
|
|
280
286
|
const fullPath = path.join(process.cwd(), nativeDir);
|
|
281
287
|
let hasNativeFiles = false;
|
|
@@ -301,7 +307,6 @@ if (command === 'android' || command === 'ios') {
|
|
|
301
307
|
archive.directory(path.join(process.cwd(), buildDir), false);
|
|
302
308
|
archive.finalize();
|
|
303
309
|
});
|
|
304
|
-
|
|
305
310
|
console.log(\`\\n\\x1b[33mSyncing \${platform} logic bundle...\\x1b[0m\`);
|
|
306
311
|
await showEnergyTransfer();
|
|
307
312
|
|
|
@@ -313,7 +318,6 @@ if (command === 'android' || command === 'ios') {
|
|
|
313
318
|
console.log(\`\\n\\x1b[1m\${platform.toUpperCase()} DEPLOYED\\x1b[0m | \\x1b[32mAlex ❯\\x1b[0m Runtime updated.\`);
|
|
314
319
|
}
|
|
315
320
|
} catch (error) {
|
|
316
|
-
// Correction de l'affichage d'erreur
|
|
317
321
|
console.error(\`\\n\\x1b[31m Build Error:\\x1b[0m \${error.response?.data?.error || error.message}\`);
|
|
318
322
|
process.exit(1);
|
|
319
323
|
}
|
|
@@ -337,14 +341,13 @@ function killProcessOnPort(port) {
|
|
|
337
341
|
const killNetworkService = () => {
|
|
338
342
|
if (uplinkProcess) {
|
|
339
343
|
try {
|
|
340
|
-
uplinkProcess.kill('SIGINT');
|
|
344
|
+
uplinkProcess.kill('SIGINT');
|
|
341
345
|
console.log('[Fleetbo] Engine closed.');
|
|
342
346
|
} catch (e) {
|
|
343
347
|
console.error('[Fleetbo] Error closing tunnel:', e.message);
|
|
344
348
|
}
|
|
345
349
|
}
|
|
346
350
|
};
|
|
347
|
-
|
|
348
351
|
let isExiting = false;
|
|
349
352
|
async function cleanupAndExit(code = 0) {
|
|
350
353
|
if (isExiting) return;
|
|
@@ -366,11 +369,12 @@ process.on('SIGTERM', () => cleanupAndExit(0));
|
|
|
366
369
|
async function syncFirebase(keyApp, networkUrl, testerEmail) {
|
|
367
370
|
try {
|
|
368
371
|
await axios.post(UPDATE_NETWORK_URL, { keyApp, networkUrl, tester: testerEmail });
|
|
369
|
-
console.log(
|
|
370
|
-
console.log(
|
|
371
|
-
console.log('\\x1b[32m[Fleetbo]
|
|
372
|
-
console.log(
|
|
373
|
-
console.log(
|
|
372
|
+
console.log('\\n\\x1b[32mEngine started successfully\\x1b[0m');
|
|
373
|
+
console.log(\`\\n\\x1b[32m[Fleetbo] \\x1b[0m -------------------------------------------------------------\`);
|
|
374
|
+
console.log('\\x1b[32m[Fleetbo] \\x1b[1mGO GO GO ! FLEETBO STUDIO IS READY\\x1b[0m');
|
|
375
|
+
console.log('\\x1b[32m[Fleetbo] You can now start coding and previewing in Studio. 🚀');
|
|
376
|
+
console.log(\`\\x1b[32m[Fleetbo] \\x1b[0m -------------------------------------------------------------\`);
|
|
377
|
+
console.log(\`\\x1b[34mPilot Instruction ❯\\x1b[0m Switch to your Fleetbo Cockpit tab to begin.\\n\`);
|
|
374
378
|
} catch (err) {
|
|
375
379
|
console.error(\`[Fleetbo] Sync Error: \${err.message}\`);
|
|
376
380
|
}
|
|
@@ -379,26 +383,37 @@ async function runDevEnvironment() {
|
|
|
379
383
|
console.log(\`[Fleetbo] 🛡️ Initializing Dev Environment...\`);
|
|
380
384
|
killNetworkService();
|
|
381
385
|
killProcessOnPort(PORT);
|
|
386
|
+
|
|
382
387
|
if (!testerEmail) { console.error('Error: REACT_APP_TESTER_EMAIL missing'); process.exit(1); }
|
|
383
388
|
|
|
384
389
|
const npmCmd = process.platform === 'win32' ? 'npm.cmd' : 'npm';
|
|
385
390
|
const devServer = spawn(npmCmd, ['start'], {
|
|
386
391
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
387
392
|
shell: true,
|
|
388
|
-
env: {
|
|
393
|
+
env: {
|
|
394
|
+
...process.env,
|
|
395
|
+
BROWSER: 'none',
|
|
396
|
+
PORT: PORT.toString(),
|
|
397
|
+
DANGEROUSLY_DISABLE_HOST_CHECK: 'true',
|
|
398
|
+
HOST: '0.0.0.0',
|
|
399
|
+
WDS_SOCKET_HOST: 'localhost',
|
|
400
|
+
WDS_SOCKET_PORT: PORT.toString()
|
|
401
|
+
}
|
|
389
402
|
});
|
|
403
|
+
|
|
390
404
|
devServer.stdout.pipe(process.stdout);
|
|
391
405
|
devServer.stderr.pipe(process.stderr);
|
|
406
|
+
|
|
392
407
|
let connectionStarted = false;
|
|
393
408
|
devServer.stdout.on('data', (data) => {
|
|
394
409
|
const output = data.toString();
|
|
410
|
+
|
|
395
411
|
if (!connectionStarted && (output.includes('Local:') || output.includes('Compiled successfully'))) {
|
|
396
412
|
connectionStarted = true;
|
|
397
413
|
|
|
398
414
|
console.log('\\n[Fleetbo] ---------------------------------------------------');
|
|
399
415
|
console.log(\`[Fleetbo] 🔗 Establishing Secure Uplink...\`);
|
|
400
|
-
console.log(\`[Fleetbo]
|
|
401
|
-
console.log(\`[Fleetbo] ⏳ Please wait green message...\`);
|
|
416
|
+
console.log(\`[Fleetbo] ⏳ Please wait for the green message...\`);
|
|
402
417
|
console.log('[Fleetbo] ---------------------------------------------------');
|
|
403
418
|
|
|
404
419
|
const npxCmd = process.platform === 'win32' ? 'npx.cmd' : 'npx';
|
|
@@ -406,8 +421,9 @@ async function runDevEnvironment() {
|
|
|
406
421
|
'cloudflared',
|
|
407
422
|
'tunnel',
|
|
408
423
|
'--url', \`http://127.0.0.1:\${PORT}\`,
|
|
409
|
-
'--http-host-header', \`127.0.0.1:\${PORT}\`
|
|
424
|
+
'--http-host-header', \`127.0.0.1:\${PORT}\`
|
|
410
425
|
], { shell: true });
|
|
426
|
+
|
|
411
427
|
uplinkProcess.stderr.on('data', (chunk) => {
|
|
412
428
|
const text = chunk.toString();
|
|
413
429
|
const match = text.match(/https:\\/\\/[a-zA-Z0-9-]+\\.trycloudflare\\.com/);
|
|
@@ -416,6 +432,7 @@ async function runDevEnvironment() {
|
|
|
416
432
|
}
|
|
417
433
|
});
|
|
418
434
|
}
|
|
435
|
+
|
|
419
436
|
runDevEnvironment();
|
|
420
437
|
`;
|
|
421
438
|
const args = process.argv.slice(2);
|