create-fleetbo-project 1.2.25 → 1.2.27

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.
@@ -12,7 +12,7 @@ const branchName = 'master';
12
12
  const archiveUrl = `https://github.com/${repoOwner}/${repoName}/archive/refs/heads/${branchName}.tar.gz`;
13
13
  const bootstrapUrl = 'https://us-central1-myapp-259bf.cloudfunctions.net/bootstrapProject';
14
14
 
15
- // --- LE CONTENU DU CLI (Version "Secure Uplink") ---
15
+ // --- LE CONTENU DU CLI (Version avec Email Dynamique) ---
16
16
  const CLI_SCRIPT_CONTENT = `#!/usr/bin/env node
17
17
 
18
18
  const { spawn, execSync } = require('child_process');
@@ -22,6 +22,25 @@ const axios = require('axios');
22
22
  const dotenv = require('dotenv');
23
23
  const os = require('os');
24
24
 
25
+ const args = process.argv.slice(2);
26
+ const command = args[0];
27
+ const GENERATOR_COMMANDS = ['page', 'g', 'generate'];
28
+ if (GENERATOR_COMMANDS.includes(command)) {
29
+ try {
30
+ require('./page.js');
31
+ } catch (error) {
32
+ console.error('\\x1b[31m%s\\x1b[0m', ' CRITICAL ERROR in Fleetbo Generator:');
33
+ if (error.code === 'MODULE_NOT_FOUND') {
34
+ console.error(". The generator script (scripts/page.js) is missing.");
35
+ console.error(" Please update your Fleetbo SDK.");
36
+ } else {
37
+ console.error(error.message);
38
+ }
39
+ process.exit(1);
40
+ }
41
+ return;
42
+ }
43
+
25
44
  const UPDATE_NETWORK_URL = 'https://us-central1-myapp-259bf.cloudfunctions.net/updateDeveloperNetwork';
26
45
  const PORT = 3000;
27
46
 
@@ -55,11 +74,15 @@ async function cleanupAndExit(code = 0) {
55
74
  process.on('SIGINT', () => cleanupAndExit(0));
56
75
  process.on('SIGTERM', () => cleanupAndExit(0));
57
76
 
58
- async function syncFirebase(keyApp, networkUrl) {
77
+ async function syncFirebase(keyApp, networkUrl, testerEmail) {
59
78
  try {
60
- await axios.post(UPDATE_NETWORK_URL, { keyApp, networkUrl });
79
+ await axios.post(UPDATE_NETWORK_URL, {
80
+ keyApp,
81
+ networkUrl,
82
+ tester: testerEmail
83
+ });
61
84
  console.log('\\n[Fleetbo] ---------------------------------------------------');
62
- console.log(\`[Fleetbo] ✅ Uplink Status: Online\`);
85
+ console.log(\`[Fleetbo] ✅ Uplink Status: Online for \${testerEmail}\`);
63
86
  console.log(\`[Fleetbo] 🚀 Simulator: https://fleetbo.io/studio/view/\${keyApp}\`);
64
87
  console.log('[Fleetbo] ---------------------------------------------------\\n');
65
88
  } catch (err) {
@@ -81,6 +104,12 @@ async function runDevEnvironment() {
81
104
  }
82
105
  dotenv.config({ path: envPath });
83
106
  const keyApp = process.env.REACT_KEY_APP;
107
+ const testerEmail = process.env.REACT_APP_TESTER_EMAIL;
108
+
109
+ if (!testerEmail) {
110
+ console.error('Error: REACT_APP_TESTER_EMAIL missing in .env');
111
+ process.exit(1);
112
+ }
84
113
 
85
114
  // 2. DÉMARRAGE DU SERVEUR LOCAL
86
115
  console.log(\`[Fleetbo] 📦 Starting Local Server...\`);
@@ -117,7 +146,7 @@ async function runDevEnvironment() {
117
146
  const url = match[0];
118
147
  if (global.currentUrl !== url) {
119
148
  global.currentUrl = url;
120
- syncFirebase(keyApp, url);
149
+ syncFirebase(keyApp, url, testerEmail);
121
150
  }
122
151
  }
123
152
  });
@@ -136,10 +165,13 @@ runDevEnvironment();
136
165
  const args = process.argv.slice(2);
137
166
  const projectNameArg = args.find(arg => !arg.startsWith('--'));
138
167
  const tokenArg = args.find(arg => arg.startsWith('--token='));
168
+ const emailArg = args.find(arg => arg.startsWith('--email='));
169
+
139
170
  const bootstrapTokenArg = tokenArg ? tokenArg.split('=')[1] : null;
171
+ const userEmailArg = emailArg ? emailArg.split('=')[1] : null;
140
172
 
141
- if (!projectNameArg || !bootstrapTokenArg) {
142
- console.error('\n ❌ Usage: npx create-fleetbo-project <name> --token=<token>');
173
+ if (!projectNameArg || !bootstrapTokenArg || !userEmailArg) {
174
+ console.error('\n ❌ Usage: npx create-fleetbo-project <name> --token=<token> --email=<email>');
143
175
  process.exit(1);
144
176
  }
145
177
 
@@ -219,11 +251,23 @@ async function setupProject() {
219
251
 
220
252
  console.log(' [4/6] ⚙️ Configuring environment & CLI...');
221
253
 
222
- // Hot Reload activé via WDS_SOCKET_PORT=0
223
- const envContent = `REACT_APP_FLEETBO_DB_KEY=${keys.fleetboDBKey}\nREACT_APP_ENTERPRISE_ID=${keys.enterpriseId}\nREACT_KEY_APP=${projectName}\nDANGEROUSLY_DISABLE_HOST_CHECK=true\nWDS_SOCKET_PORT=0\n`;
254
+ const envContent = `REACT_APP_FLEETBO_DB_KEY=${keys.fleetboDBKey}
255
+ REACT_APP_ENTERPRISE_ID=${keys.enterpriseId}
256
+ REACT_KEY_APP=${projectName}
257
+ REACT_APP_TESTER_EMAIL=${userEmailArg}
258
+ DANGEROUSLY_DISABLE_HOST_CHECK=true
259
+ WDS_SOCKET_PORT=0
260
+ `;
224
261
 
225
262
  fs.writeFileSync(path.join(projectDir, '.env'), envContent, 'utf8');
226
- fs.writeFileSync(path.join(projectDir, 'cli.js'), CLI_SCRIPT_CONTENT, 'utf8');
263
+ // On s'assure que le dossier scripts existe (normalement oui via le tar.gz, mais sécurité d'abord)
264
+ const scriptsDir = path.join(projectDir, 'scripts');
265
+ if (!fs.existsSync(scriptsDir)) {
266
+ fs.mkdirSync(scriptsDir, { recursive: true });
267
+ }
268
+ fs.writeFileSync(path.join(scriptsDir, 'cli.js'), CLI_SCRIPT_CONTENT, 'utf8');
269
+ // On rend le script exécutable (Optionnel mais propre sur Mac/Linux)
270
+ try { fs.chmodSync(path.join(scriptsDir, 'cli.js'), '755'); } catch (e) {}
227
271
 
228
272
  console.log(' [5/6] 📚 Installing dependencies...');
229
273
  execSync('npm install', { stdio: 'inherit' });
@@ -235,7 +279,7 @@ async function setupProject() {
235
279
  const packageJsonPath = path.join(projectDir, 'package.json');
236
280
  const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
237
281
  packageJson.name = projectName;
238
- packageJson.scripts = { ...packageJson.scripts, "fleetbo": "node cli.js", "dev": "node cli.js" };
282
+ packageJson.scripts = { ...packageJson.scripts, "fleetbo": "node scripts/cli.js", "dev": "node scripts/cli.js" };
239
283
  fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), 'utf8');
240
284
 
241
285
  console.log('\n [Fleetbo] ✅ Project successfully created!');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-fleetbo-project",
3
- "version": "1.2.25",
3
+ "version": "1.2.27",
4
4
  "description": "Creates a new Fleetbo project.",
5
5
  "main": "install-react-template.js",
6
6
  "bin": {