create-fleetbo-project 1.2.67 → 1.2.69
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 +38 -18
- package/package.json +1 -1
|
@@ -29,7 +29,7 @@ const command = args[0];
|
|
|
29
29
|
process.env.DOTENV_SILENT = 'true';
|
|
30
30
|
const envPath = path.join(process.cwd(), '.env');
|
|
31
31
|
if (!fs.existsSync(envPath)) {
|
|
32
|
-
console.error('\\x1b[31m%s\\x1b[0m', '
|
|
32
|
+
console.error('\\x1b[31m%s\\x1b[0m', ' Error: Configuration file (.env) not found.');
|
|
33
33
|
process.exit(1);
|
|
34
34
|
}
|
|
35
35
|
dotenv.config({ path: envPath, quiet: true });
|
|
@@ -80,7 +80,7 @@ const checkGitSecurity = () => {
|
|
|
80
80
|
}
|
|
81
81
|
};
|
|
82
82
|
if (!projectId) {
|
|
83
|
-
console.error('\\n
|
|
83
|
+
console.error('\\n Error: Project ID missing in .env.\\n');
|
|
84
84
|
process.exit(1);
|
|
85
85
|
}
|
|
86
86
|
const injectRouteIntoAppJs = (pageName, subPath = '') => {
|
|
@@ -91,7 +91,7 @@ const injectRouteIntoAppJs = (pageName, subPath = '') => {
|
|
|
91
91
|
if (!content.includes(alexRouteAnchor)) return false;
|
|
92
92
|
// Chemin dynamique selon si c'est une page ou un mock
|
|
93
93
|
const pathPrefix = subPath ? \`\${subPath}/\` : '';
|
|
94
|
-
const importLine = \`import \${pageName} from './
|
|
94
|
+
const importLine = \`import \${pageName} from './app/\${pathPrefix}\${pageName}';\`;
|
|
95
95
|
const routeLine = \`<Route path="/\${pathPrefix.toLowerCase()}\${pageName.toLowerCase()}" element={<\${pageName} />} />\`;
|
|
96
96
|
let injected = false;
|
|
97
97
|
if (!content.includes(importLine)) {
|
|
@@ -139,6 +139,7 @@ if (command === 'alex') {
|
|
|
139
139
|
console.log('');
|
|
140
140
|
const rawMsg = aiData.message || "I'm ready.";
|
|
141
141
|
const formattedMsg = wrapText(rawMsg, 85);
|
|
142
|
+
console.log(\`\\x1b[32mAlex ❯\\x1b[0m \\n \${formattedMsg}\`);
|
|
142
143
|
if (aiData.remainingConsultations !== undefined) {
|
|
143
144
|
const remaining = aiData.remainingConsultations;
|
|
144
145
|
const limit = aiData.consultationLimit || 50;
|
|
@@ -150,7 +151,7 @@ if (command === 'alex') {
|
|
|
150
151
|
}
|
|
151
152
|
if (aiData.status === 'success' && aiData.moduleData) {
|
|
152
153
|
const { fileName, code, mockFileName, mockCode, moduleName, instructions } = aiData.moduleData;
|
|
153
|
-
console.log(\` \\x1b[90m
|
|
154
|
+
console.log(\` \\x1b[90m Architecting: \${moduleName}\x1b[0m\`);
|
|
154
155
|
const writeFile = (dir, name, content) => {
|
|
155
156
|
const fullPath = path.join(process.cwd(), dir);
|
|
156
157
|
const filePath = path.join(fullPath, name);
|
|
@@ -168,13 +169,13 @@ if (command === 'alex') {
|
|
|
168
169
|
});
|
|
169
170
|
}
|
|
170
171
|
if (code && fileName) {
|
|
171
|
-
const folder = fileName.endsWith('.kt') ? 'public/native/android/' : 'src/
|
|
172
|
+
const folder = fileName.endsWith('.kt') ? 'public/native/android/' : 'src/app/';
|
|
172
173
|
writeFile(folder, fileName, code);
|
|
173
174
|
if (fileName.endsWith('.jsx')) injectRouteIntoAppJs(fileName.replace('.jsx', ''));
|
|
174
175
|
}
|
|
175
176
|
if (mockCode && mockFileName) {
|
|
176
177
|
const pageName = mockFileName.replace('.jsx', '');
|
|
177
|
-
writeFile('src/
|
|
178
|
+
writeFile('src/app/mocks/', mockFileName, mockCode);
|
|
178
179
|
const injected = injectRouteIntoAppJs(pageName, 'mocks');
|
|
179
180
|
if (injected) {
|
|
180
181
|
console.log(\` \\x1b[32m[Routed]\x1b[0m App.js -> /mocks/\${pageName.toLowerCase()}\`);
|
|
@@ -224,7 +225,7 @@ if (command === 'alex') {
|
|
|
224
225
|
rl.prompt();
|
|
225
226
|
rl.on('line', async (line) => {
|
|
226
227
|
if (['exit', 'quit'].includes(line.trim().toLowerCase())) {
|
|
227
|
-
console.log('\\n\\x1b[90m
|
|
228
|
+
console.log('\\n\\x1b[90m Alex session closed.\\x1b[0m');
|
|
228
229
|
rl.close();
|
|
229
230
|
return;
|
|
230
231
|
}
|
|
@@ -339,7 +340,7 @@ async function syncFirebase(keyApp, networkUrl, testerEmail) {
|
|
|
339
340
|
console.log('\\x1b[32m[Fleetbo] You can now start coding and previewing in Studio. 🚀\\x1b[0m');
|
|
340
341
|
console.log(\`\\x1b[32m[Fleetbo]\\x1b[0m -------------------------------------------------------------\`);
|
|
341
342
|
} catch (err) {
|
|
342
|
-
console.error(\`[Fleetbo]
|
|
343
|
+
console.error(\`[Fleetbo] Sync Error: \${err.message}\`);
|
|
343
344
|
}
|
|
344
345
|
}
|
|
345
346
|
async function runDevEnvironment() {
|
|
@@ -386,7 +387,7 @@ const emailArg = args.find(arg => arg.startsWith('--email='));
|
|
|
386
387
|
const bootstrapTokenArg = tokenArg ? tokenArg.split('=')[1] : null;
|
|
387
388
|
const userEmailArg = emailArg ? emailArg.split('=')[1] : null;
|
|
388
389
|
if (!projectNameArg || !bootstrapTokenArg || !userEmailArg) {
|
|
389
|
-
console.error('\n
|
|
390
|
+
console.error('\n Usage: npx create-fleetbo-project <name> --token=<token> --email=<email>');
|
|
390
391
|
process.exit(1);
|
|
391
392
|
}
|
|
392
393
|
const projectName = projectNameArg;
|
|
@@ -437,17 +438,17 @@ function downloadEngine(url, dest) {
|
|
|
437
438
|
});
|
|
438
439
|
}
|
|
439
440
|
async function setupProject() {
|
|
440
|
-
console.log(`\n⚡
|
|
441
|
+
console.log(`\n ⚡Initializing Fleetbo Framework for "${projectName}"...`);
|
|
441
442
|
|
|
442
443
|
try {
|
|
443
444
|
if (fs.existsSync(projectDir)) throw new Error(`Directory "${projectName}" already exists.`);
|
|
444
445
|
fs.mkdirSync(projectDir);
|
|
445
446
|
|
|
446
|
-
console.log('
|
|
447
|
+
console.log(' [1/7] Downloading Fleetbo Core Engine...');
|
|
447
448
|
const archivePath = path.join(projectDir, 'engine.tar.gz');
|
|
448
449
|
await downloadEngine(archiveUrl, archivePath);
|
|
449
450
|
|
|
450
|
-
console.log('
|
|
451
|
+
console.log(' [2/7] Scaffolding project structure...');
|
|
451
452
|
try {
|
|
452
453
|
execSync(`tar -xf "${archivePath}" -C "${projectDir}" --strip-components=1`, { stdio: 'ignore' });
|
|
453
454
|
fs.unlinkSync(archivePath);
|
|
@@ -455,11 +456,30 @@ async function setupProject() {
|
|
|
455
456
|
|
|
456
457
|
process.chdir(projectDir);
|
|
457
458
|
|
|
458
|
-
console.log(' [
|
|
459
|
+
console.log(' [2.5/7] Standardizing Architecture (src/app)...');
|
|
460
|
+
const oldPath = path.join(projectDir, 'src/pages');
|
|
461
|
+
const newPath = path.join(projectDir, 'src/app');
|
|
462
|
+
|
|
463
|
+
if (fs.existsSync(oldPath) && !fs.existsSync(newPath)) {
|
|
464
|
+
try {
|
|
465
|
+
fs.renameSync(oldPath, newPath);
|
|
466
|
+
const appJsPath = path.join(projectDir, 'src/App.js');
|
|
467
|
+
if (fs.existsSync(appJsPath)) {
|
|
468
|
+
let appContent = fs.readFileSync(appJsPath, 'utf8');
|
|
469
|
+
appContent = appContent.replace(/from "\.\/pages\//g, 'from "./app/');
|
|
470
|
+
appContent = appContent.replace(/from '\.\/pages\//g, "from './app/");
|
|
471
|
+
fs.writeFileSync(appJsPath, appContent);
|
|
472
|
+
}
|
|
473
|
+
} catch (err) {
|
|
474
|
+
console.warn(' Architecture migration warning:', err.message);
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
console.log(' [3/7] Authenticating with Fleetbo Cloud...');
|
|
459
479
|
const keys = await fetchProjectKeys(bootstrapTokenArg);
|
|
460
480
|
if (!keys.enterpriseId) throw new Error("Invalid keys.");
|
|
461
481
|
|
|
462
|
-
console.log('
|
|
482
|
+
console.log(' [4/7] Configuring environment & CLI...');
|
|
463
483
|
const envContent = `REACT_APP_FLEETBO_DB_KEY=${keys.fleetboDBKey}
|
|
464
484
|
REACT_APP_ENTERPRISE_ID=${keys.enterpriseId}
|
|
465
485
|
REACT_KEY_APP=${projectName}
|
|
@@ -468,17 +488,17 @@ async function setupProject() {
|
|
|
468
488
|
WDS_SOCKET_PORT=0`;
|
|
469
489
|
|
|
470
490
|
fs.writeFileSync(path.join(projectDir, '.env'), envContent, 'utf8');
|
|
471
|
-
console.log('
|
|
491
|
+
console.log(' [5/7] Securing environment (adding .gitignore)...');
|
|
472
492
|
const gitignoreContent = `# Fleetbo Security\n.env\n.env.local\nnode_modules/\ndist/\nbuild/\n.DS_Store\nnpm-debug.log*\nyarn-debug.log*\nyarn-error.log*\n`;
|
|
473
493
|
fs.writeFileSync(path.join(projectDir, '.gitignore'), gitignoreContent, 'utf8');
|
|
474
494
|
const scriptsDir = path.join(projectDir, 'scripts');
|
|
475
495
|
if (!fs.existsSync(scriptsDir)) fs.mkdirSync(scriptsDir, { recursive: true });
|
|
476
496
|
fs.writeFileSync(path.join(scriptsDir, 'cli.js'), CLI_SCRIPT_CONTENT, 'utf8');
|
|
477
497
|
try { fs.chmodSync(path.join(scriptsDir, 'cli.js'), '755'); } catch (e) {}
|
|
478
|
-
console.log('
|
|
498
|
+
console.log(' [6/7] Installing dependencies...');
|
|
479
499
|
execSync('npm install', { stdio: 'inherit' });
|
|
480
500
|
execSync('npm install cloudflared dotenv axios archiver --save-dev', { stdio: 'ignore' });
|
|
481
|
-
console.log('
|
|
501
|
+
console.log(' [7/7] Finalizing setup...');
|
|
482
502
|
const packageJsonPath = path.join(projectDir, 'package.json');
|
|
483
503
|
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
484
504
|
packageJson.name = projectName;
|
|
@@ -489,7 +509,7 @@ async function setupProject() {
|
|
|
489
509
|
console.log('\n \x1b[32m [Fleetbo] To start architecting with Alex, run: npm run fleetbo alex!\x1b[0m');
|
|
490
510
|
console.log('');
|
|
491
511
|
} catch (error) {
|
|
492
|
-
console.error('\n
|
|
512
|
+
console.error('\n Setup failed:', error.message);
|
|
493
513
|
if (fs.existsSync(projectDir)) try { fs.rmSync(projectDir, { recursive: true, force: true }); } catch(e){}
|
|
494
514
|
process.exit(1);
|
|
495
515
|
}
|