create-fleetbo-project 1.2.24 → 1.2.26

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 GARDIEN (CLI.JS) ---
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');
@@ -25,7 +25,7 @@ const os = require('os');
25
25
  const UPDATE_NETWORK_URL = 'https://us-central1-myapp-259bf.cloudfunctions.net/updateDeveloperNetwork';
26
26
  const PORT = 3000;
27
27
 
28
- // Nettoyage des ports (Mac/Linux)
28
+ // Gestion des processus système (Mac/Linux)
29
29
  function killProcessOnPort(port) {
30
30
  try {
31
31
  if (process.platform !== 'win32') {
@@ -37,8 +37,8 @@ function killProcessOnPort(port) {
37
37
  } catch (e) {}
38
38
  }
39
39
 
40
- // Nettoyage spécifique Cloudflare
41
- function killCloudflared() {
40
+ // Gestion du service réseau
41
+ function killNetworkService() {
42
42
  try {
43
43
  const cmd = process.platform === 'win32' ? 'taskkill /IM cloudflared.exe /F' : 'pkill cloudflared';
44
44
  execSync(cmd + ' 2>/dev/null');
@@ -46,8 +46,8 @@ function killCloudflared() {
46
46
  }
47
47
 
48
48
  async function cleanupAndExit(code = 0) {
49
- console.log('\\n[Fleetbo] 🛑 Stopping services...');
50
- killCloudflared();
49
+ console.log('\\n[Fleetbo] 🛑 Stopping development environment...');
50
+ killNetworkService();
51
51
  killProcessOnPort(PORT);
52
52
  process.exit(code);
53
53
  }
@@ -55,11 +55,15 @@ async function cleanupAndExit(code = 0) {
55
55
  process.on('SIGINT', () => cleanupAndExit(0));
56
56
  process.on('SIGTERM', () => cleanupAndExit(0));
57
57
 
58
- async function syncFirebase(keyApp, networkUrl) {
58
+ async function syncFirebase(keyApp, networkUrl, testerEmail) {
59
59
  try {
60
- await axios.post(UPDATE_NETWORK_URL, { keyApp, networkUrl });
60
+ await axios.post(UPDATE_NETWORK_URL, {
61
+ keyApp,
62
+ networkUrl,
63
+ tester: testerEmail
64
+ });
61
65
  console.log('\\n[Fleetbo] ---------------------------------------------------');
62
- console.log(\`[Fleetbo] ✅ Tunnel Active: \${networkUrl}\`);
66
+ console.log(\`[Fleetbo] ✅ Uplink Status: Online for \${testerEmail}\`);
63
67
  console.log(\`[Fleetbo] 🚀 Simulator: https://fleetbo.io/studio/view/\${keyApp}\`);
64
68
  console.log('[Fleetbo] ---------------------------------------------------\\n');
65
69
  } catch (err) {
@@ -67,23 +71,29 @@ async function syncFirebase(keyApp, networkUrl) {
67
71
  }
68
72
  }
69
73
 
70
- async function runGuardian() {
71
- console.log(\`[Fleetbo] 🛡️ Starting Fleetbo Guardian on \${os.platform()}...\`);
74
+ async function runDevEnvironment() {
75
+ console.log(\`[Fleetbo] 🛡️ Initializing Developer Environment on \${os.platform()}...\`);
72
76
 
73
77
  // 1. NETTOYAGE PRÉVENTIF
74
- killCloudflared();
78
+ killNetworkService();
75
79
  killProcessOnPort(PORT);
76
80
 
77
81
  const envPath = path.join(process.cwd(), '.env');
78
82
  if (!fs.existsSync(envPath)) {
79
- console.error('Error: .env file not found.');
83
+ console.error('Error: Configuration file not found.');
80
84
  process.exit(1);
81
85
  }
82
86
  dotenv.config({ path: envPath });
83
87
  const keyApp = process.env.REACT_KEY_APP;
88
+ const testerEmail = process.env.REACT_APP_TESTER_EMAIL;
89
+
90
+ if (!testerEmail) {
91
+ console.error('Error: REACT_APP_TESTER_EMAIL missing in .env');
92
+ process.exit(1);
93
+ }
84
94
 
85
- // 2. DÉMARRAGE REACT
86
- console.log(\`[Fleetbo] 📦 Booting React Server...\`);
95
+ // 2. DÉMARRAGE DU SERVEUR LOCAL
96
+ console.log(\`[Fleetbo] 📦 Starting Local Server...\`);
87
97
  const npmCmd = process.platform === 'win32' ? 'npm.cmd' : 'npm';
88
98
 
89
99
  const devServer = spawn(npmCmd, ['start'], {
@@ -94,53 +104,55 @@ async function runGuardian() {
94
104
  devServer.stdout.pipe(process.stdout);
95
105
  devServer.stderr.pipe(process.stderr);
96
106
 
97
- let tunnelStarted = false;
107
+ let connectionStarted = false;
98
108
 
99
109
  devServer.stdout.on('data', (data) => {
100
110
  const output = data.toString();
101
111
 
102
- if (!tunnelStarted && (output.includes('Local:') || output.includes('Compiled successfully'))) {
103
- tunnelStarted = true;
104
- console.log(\`\\n[Fleetbo] 🔗 React is ready. Establishing secure tunnel...\`);
112
+ if (!connectionStarted && (output.includes('Local:') || output.includes('Compiled successfully'))) {
113
+ connectionStarted = true;
114
+ console.log(\`\\n[Fleetbo] 🔗 Local Server Ready. Establishing Secure Uplink...\`);
105
115
 
106
- // 3. DÉMARRAGE TUNNEL CLOUDFLARE (via npm exec)
116
+ // 3. DÉMARRAGE DE LA LIAISON (UPLINK)
107
117
  const npxCmd = process.platform === 'win32' ? 'npx.cmd' : 'npx';
108
- const tunnel = spawn(npxCmd, ['cloudflared', 'tunnel', '--url', \`http://localhost:\${PORT}\`]);
118
+ const uplink = spawn(npxCmd, ['cloudflared', 'tunnel', '--url', \`http://localhost:\${PORT}\`]);
109
119
 
110
- // Capture de l'URL dans les logs stderr
111
- tunnel.stderr.on('data', (chunk) => {
120
+ // Capture de l'URL (Silencieux)
121
+ uplink.stderr.on('data', (chunk) => {
112
122
  const log = chunk.toString();
113
123
 
114
- // --- REGEX VALIDÉE ---
115
124
  const match = log.match(/https:\\/\\/[a-zA-Z0-9-]+\\.trycloudflare\\.com/);
116
125
 
117
126
  if (match) {
118
127
  const url = match[0];
119
128
  if (global.currentUrl !== url) {
120
129
  global.currentUrl = url;
121
- syncFirebase(keyApp, url);
130
+ syncFirebase(keyApp, url, testerEmail);
122
131
  }
123
132
  }
124
133
  });
125
134
 
126
- tunnel.on('error', (err) => {
127
- console.error("[Fleetbo] ❌ Tunnel Error. Ensure 'cloudflared' is installed.");
135
+ uplink.on('error', (err) => {
136
+ console.error("[Fleetbo] ❌ Uplink Error. Network component missing.");
128
137
  });
129
138
  }
130
139
  });
131
140
  }
132
141
 
133
- runGuardian();
142
+ runDevEnvironment();
134
143
  `;
135
144
 
136
145
  // --- Analyse des Arguments ---
137
146
  const args = process.argv.slice(2);
138
147
  const projectNameArg = args.find(arg => !arg.startsWith('--'));
139
148
  const tokenArg = args.find(arg => arg.startsWith('--token='));
149
+ const emailArg = args.find(arg => arg.startsWith('--email='));
150
+
140
151
  const bootstrapTokenArg = tokenArg ? tokenArg.split('=')[1] : null;
152
+ const userEmailArg = emailArg ? emailArg.split('=')[1] : null;
141
153
 
142
- if (!projectNameArg || !bootstrapTokenArg) {
143
- console.error('\n ❌ Usage: npx create-fleetbo-project <name> --token=<token>');
154
+ if (!projectNameArg || !bootstrapTokenArg || !userEmailArg) {
155
+ console.error('\n ❌ Usage: npx create-fleetbo-project <name> --token=<token> --email=<email>');
144
156
  process.exit(1);
145
157
  }
146
158
 
@@ -220,8 +232,13 @@ async function setupProject() {
220
232
 
221
233
  console.log(' [4/6] ⚙️ Configuring environment & CLI...');
222
234
 
223
- // --- MISE À JOUR : Activation du Hot Reload avec WDS_SOCKET_PORT=0 ---
224
- 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`;
235
+ const envContent = `REACT_APP_FLEETBO_DB_KEY=${keys.fleetboDBKey}
236
+ REACT_APP_ENTERPRISE_ID=${keys.enterpriseId}
237
+ REACT_KEY_APP=${projectName}
238
+ REACT_APP_TESTER_EMAIL=${userEmailArg}
239
+ DANGEROUSLY_DISABLE_HOST_CHECK=true
240
+ WDS_SOCKET_PORT=0
241
+ `;
225
242
 
226
243
  fs.writeFileSync(path.join(projectDir, '.env'), envContent, 'utf8');
227
244
  fs.writeFileSync(path.join(projectDir, 'cli.js'), CLI_SCRIPT_CONTENT, 'utf8');
@@ -229,7 +246,7 @@ async function setupProject() {
229
246
  console.log(' [5/6] 📚 Installing dependencies...');
230
247
  execSync('npm install', { stdio: 'inherit' });
231
248
 
232
- // Installation de cloudflared
249
+ // Installation silencieuse
233
250
  execSync('npm install cloudflared dotenv axios --save-dev', { stdio: 'ignore' });
234
251
 
235
252
  console.log(' [6/6] ✨ Finalizing setup...');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-fleetbo-project",
3
- "version": "1.2.24",
3
+ "version": "1.2.26",
4
4
  "description": "Creates a new Fleetbo project.",
5
5
  "main": "install-react-template.js",
6
6
  "bin": {