create-fleetbo-project 1.2.66 → 1.2.68
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 +18 -19
- 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)) {
|
|
@@ -150,7 +150,7 @@ if (command === 'alex') {
|
|
|
150
150
|
}
|
|
151
151
|
if (aiData.status === 'success' && aiData.moduleData) {
|
|
152
152
|
const { fileName, code, mockFileName, mockCode, moduleName, instructions } = aiData.moduleData;
|
|
153
|
-
console.log(\` \\x1b[90m
|
|
153
|
+
console.log(\` \\x1b[90m Architecting: \${moduleName}\x1b[0m\`);
|
|
154
154
|
const writeFile = (dir, name, content) => {
|
|
155
155
|
const fullPath = path.join(process.cwd(), dir);
|
|
156
156
|
const filePath = path.join(fullPath, name);
|
|
@@ -168,14 +168,13 @@ if (command === 'alex') {
|
|
|
168
168
|
});
|
|
169
169
|
}
|
|
170
170
|
if (code && fileName) {
|
|
171
|
-
const folder = fileName.endsWith('.kt') ? 'public/native/android/' : 'src/
|
|
171
|
+
const folder = fileName.endsWith('.kt') ? 'public/native/android/' : 'src/app/';
|
|
172
172
|
writeFile(folder, fileName, code);
|
|
173
173
|
if (fileName.endsWith('.jsx')) injectRouteIntoAppJs(fileName.replace('.jsx', ''));
|
|
174
174
|
}
|
|
175
175
|
if (mockCode && mockFileName) {
|
|
176
176
|
const pageName = mockFileName.replace('.jsx', '');
|
|
177
|
-
writeFile('src/
|
|
178
|
-
writeFile('src/pages/mocks/', 'Quick.jsx', mockCode);
|
|
177
|
+
writeFile('src/app/mocks/', mockFileName, mockCode);
|
|
179
178
|
const injected = injectRouteIntoAppJs(pageName, 'mocks');
|
|
180
179
|
if (injected) {
|
|
181
180
|
console.log(\` \\x1b[32m[Routed]\x1b[0m App.js -> /mocks/\${pageName.toLowerCase()}\`);
|
|
@@ -225,7 +224,7 @@ if (command === 'alex') {
|
|
|
225
224
|
rl.prompt();
|
|
226
225
|
rl.on('line', async (line) => {
|
|
227
226
|
if (['exit', 'quit'].includes(line.trim().toLowerCase())) {
|
|
228
|
-
console.log('\\n\\x1b[90m
|
|
227
|
+
console.log('\\n\\x1b[90m Alex session closed.\\x1b[0m');
|
|
229
228
|
rl.close();
|
|
230
229
|
return;
|
|
231
230
|
}
|
|
@@ -340,7 +339,7 @@ async function syncFirebase(keyApp, networkUrl, testerEmail) {
|
|
|
340
339
|
console.log('\\x1b[32m[Fleetbo] You can now start coding and previewing in Studio. 🚀\\x1b[0m');
|
|
341
340
|
console.log(\`\\x1b[32m[Fleetbo]\\x1b[0m -------------------------------------------------------------\`);
|
|
342
341
|
} catch (err) {
|
|
343
|
-
console.error(\`[Fleetbo]
|
|
342
|
+
console.error(\`[Fleetbo] Sync Error: \${err.message}\`);
|
|
344
343
|
}
|
|
345
344
|
}
|
|
346
345
|
async function runDevEnvironment() {
|
|
@@ -387,7 +386,7 @@ const emailArg = args.find(arg => arg.startsWith('--email='));
|
|
|
387
386
|
const bootstrapTokenArg = tokenArg ? tokenArg.split('=')[1] : null;
|
|
388
387
|
const userEmailArg = emailArg ? emailArg.split('=')[1] : null;
|
|
389
388
|
if (!projectNameArg || !bootstrapTokenArg || !userEmailArg) {
|
|
390
|
-
console.error('\n
|
|
389
|
+
console.error('\n Usage: npx create-fleetbo-project <name> --token=<token> --email=<email>');
|
|
391
390
|
process.exit(1);
|
|
392
391
|
}
|
|
393
392
|
const projectName = projectNameArg;
|
|
@@ -438,17 +437,17 @@ function downloadEngine(url, dest) {
|
|
|
438
437
|
});
|
|
439
438
|
}
|
|
440
439
|
async function setupProject() {
|
|
441
|
-
console.log(`\n⚡
|
|
440
|
+
console.log(`\n ⚡Initializing Fleetbo Framework for "${projectName}"...`);
|
|
442
441
|
|
|
443
442
|
try {
|
|
444
443
|
if (fs.existsSync(projectDir)) throw new Error(`Directory "${projectName}" already exists.`);
|
|
445
444
|
fs.mkdirSync(projectDir);
|
|
446
445
|
|
|
447
|
-
console.log('
|
|
446
|
+
console.log(' [1/7] Downloading Fleetbo Core Engine...');
|
|
448
447
|
const archivePath = path.join(projectDir, 'engine.tar.gz');
|
|
449
448
|
await downloadEngine(archiveUrl, archivePath);
|
|
450
449
|
|
|
451
|
-
console.log('
|
|
450
|
+
console.log(' [2/7] Scaffolding project structure...');
|
|
452
451
|
try {
|
|
453
452
|
execSync(`tar -xf "${archivePath}" -C "${projectDir}" --strip-components=1`, { stdio: 'ignore' });
|
|
454
453
|
fs.unlinkSync(archivePath);
|
|
@@ -456,11 +455,11 @@ async function setupProject() {
|
|
|
456
455
|
|
|
457
456
|
process.chdir(projectDir);
|
|
458
457
|
|
|
459
|
-
console.log('
|
|
458
|
+
console.log(' [3/7] Authenticating with Fleetbo Cloud...');
|
|
460
459
|
const keys = await fetchProjectKeys(bootstrapTokenArg);
|
|
461
460
|
if (!keys.enterpriseId) throw new Error("Invalid keys.");
|
|
462
461
|
|
|
463
|
-
console.log('
|
|
462
|
+
console.log(' [4/7] Configuring environment & CLI...');
|
|
464
463
|
const envContent = `REACT_APP_FLEETBO_DB_KEY=${keys.fleetboDBKey}
|
|
465
464
|
REACT_APP_ENTERPRISE_ID=${keys.enterpriseId}
|
|
466
465
|
REACT_KEY_APP=${projectName}
|
|
@@ -469,17 +468,17 @@ async function setupProject() {
|
|
|
469
468
|
WDS_SOCKET_PORT=0`;
|
|
470
469
|
|
|
471
470
|
fs.writeFileSync(path.join(projectDir, '.env'), envContent, 'utf8');
|
|
472
|
-
console.log('
|
|
471
|
+
console.log(' [5/7] Securing environment (adding .gitignore)...');
|
|
473
472
|
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`;
|
|
474
473
|
fs.writeFileSync(path.join(projectDir, '.gitignore'), gitignoreContent, 'utf8');
|
|
475
474
|
const scriptsDir = path.join(projectDir, 'scripts');
|
|
476
475
|
if (!fs.existsSync(scriptsDir)) fs.mkdirSync(scriptsDir, { recursive: true });
|
|
477
476
|
fs.writeFileSync(path.join(scriptsDir, 'cli.js'), CLI_SCRIPT_CONTENT, 'utf8');
|
|
478
477
|
try { fs.chmodSync(path.join(scriptsDir, 'cli.js'), '755'); } catch (e) {}
|
|
479
|
-
console.log('
|
|
478
|
+
console.log(' [6/7] Installing dependencies...');
|
|
480
479
|
execSync('npm install', { stdio: 'inherit' });
|
|
481
480
|
execSync('npm install cloudflared dotenv axios archiver --save-dev', { stdio: 'ignore' });
|
|
482
|
-
console.log('
|
|
481
|
+
console.log(' [7/7] Finalizing setup...');
|
|
483
482
|
const packageJsonPath = path.join(projectDir, 'package.json');
|
|
484
483
|
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
485
484
|
packageJson.name = projectName;
|
|
@@ -490,7 +489,7 @@ async function setupProject() {
|
|
|
490
489
|
console.log('\n \x1b[32m [Fleetbo] To start architecting with Alex, run: npm run fleetbo alex!\x1b[0m');
|
|
491
490
|
console.log('');
|
|
492
491
|
} catch (error) {
|
|
493
|
-
console.error('\n
|
|
492
|
+
console.error('\n Setup failed:', error.message);
|
|
494
493
|
if (fs.existsSync(projectDir)) try { fs.rmSync(projectDir, { recursive: true, force: true }); } catch(e){}
|
|
495
494
|
process.exit(1);
|
|
496
495
|
}
|