create-fleetbo-project 1.2.21 → 1.2.23

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 GARDIEN RÉSEAU (Version "White Label") ---
15
+ // --- LE CONTENU DU GARDIEN (CLI.JS) ---
16
16
  const CLI_SCRIPT_CONTENT = `#!/usr/bin/env node
17
17
 
18
18
  const { spawn, execSync } = require('child_process');
@@ -25,18 +25,20 @@ 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
- // Gestion des processus (Mac/Linux)
28
+ // Nettoyage des ports (Mac/Linux)
29
29
  function killProcessOnPort(port) {
30
30
  try {
31
31
  if (process.platform !== 'win32') {
32
32
  const pid = execSync(\`lsof -ti:\${port} 2>/dev/null\`).toString().trim();
33
- if (pid) execSync(\`kill -9 \${pid.split('\\n').join(' ')} 2>/dev/null\`);
33
+ if (pid) {
34
+ execSync(\`kill -9 \${pid.split('\\n').join(' ')} 2>/dev/null\`);
35
+ }
34
36
  }
35
37
  } catch (e) {}
36
38
  }
37
39
 
38
- // Gestion du connecteur réseau
39
- function killNetworkConnector() {
40
+ // Nettoyage spécifique Cloudflare
41
+ function killCloudflared() {
40
42
  try {
41
43
  const cmd = process.platform === 'win32' ? 'taskkill /IM cloudflared.exe /F' : 'pkill cloudflared';
42
44
  execSync(cmd + ' 2>/dev/null');
@@ -45,7 +47,7 @@ function killNetworkConnector() {
45
47
 
46
48
  async function cleanupAndExit(code = 0) {
47
49
  console.log('\\n[Fleetbo] 🛑 Stopping services...');
48
- killNetworkConnector();
50
+ killCloudflared();
49
51
  killProcessOnPort(PORT);
50
52
  process.exit(code);
51
53
  }
@@ -57,7 +59,7 @@ async function syncFirebase(keyApp, networkUrl) {
57
59
  try {
58
60
  await axios.post(UPDATE_NETWORK_URL, { keyApp, networkUrl });
59
61
  console.log('\\n[Fleetbo] ---------------------------------------------------');
60
- console.log(\`[Fleetbo] ✅ Network Ready: Active\`);
62
+ console.log(\`[Fleetbo] ✅ Tunnel Active: \${networkUrl}\`);
61
63
  console.log(\`[Fleetbo] 🚀 Simulator: https://fleetbo.io/studio/view/\${keyApp}\`);
62
64
  console.log('[Fleetbo] ---------------------------------------------------\\n');
63
65
  } catch (err) {
@@ -68,8 +70,8 @@ async function syncFirebase(keyApp, networkUrl) {
68
70
  async function runGuardian() {
69
71
  console.log(\`[Fleetbo] 🛡️ Starting Fleetbo Guardian on \${os.platform()}...\`);
70
72
 
71
- // 1. PRÉPARATION ENVIRONNEMENT
72
- killNetworkConnector();
73
+ // 1. NETTOYAGE PRÉVENTIF
74
+ killCloudflared();
73
75
  killProcessOnPort(PORT);
74
76
 
75
77
  const envPath = path.join(process.cwd(), '.env');
@@ -92,23 +94,26 @@ async function runGuardian() {
92
94
  devServer.stdout.pipe(process.stdout);
93
95
  devServer.stderr.pipe(process.stderr);
94
96
 
95
- let connectionStarted = false;
97
+ let tunnelStarted = false;
96
98
 
97
99
  devServer.stdout.on('data', (data) => {
98
100
  const output = data.toString();
99
101
 
100
- if (!connectionStarted && (output.includes('Local:') || output.includes('Compiled successfully'))) {
101
- connectionStarted = true;
102
- console.log(\`\\n[Fleetbo] 🔗 React is ready. Establishing Secure Link...\`);
102
+ if (!tunnelStarted && (output.includes('Local:') || output.includes('Compiled successfully'))) {
103
+ tunnelStarted = true;
104
+ console.log(\`\\n[Fleetbo] 🔗 React is ready. Establishing secure tunnel...\`);
103
105
 
104
- // 3. DÉMARRAGE LINK SÉCURISÉ
106
+ // 3. DÉMARRAGE TUNNEL CLOUDFLARE
105
107
  const npxCmd = process.platform === 'win32' ? 'npx.cmd' : 'npx';
106
- const connector = spawn(npxCmd, ['cloudflared', 'tunnel', '--url', \`http://localhost:\${PORT}\`]);
108
+ const tunnel = spawn(npxCmd, ['cloudflared', 'tunnel', '--url', \`http://localhost:\${PORT}\`]);
107
109
 
108
- // Capture de l'URL (Silencieux)
109
- connector.stderr.on('data', (chunk) => {
110
+ tunnel.stderr.on('data', (chunk) => {
110
111
  const log = chunk.toString();
111
- const match = log.match(/https:\/\/[a-zA-Z0-9-]+\.trycloudflare\.com/);
112
+
113
+ // --- REGEX CORRIGÉE AVEC DOUBLE ÉCHAPPEMENT ---
114
+ // Dans ce fichier générateur, on doit écrire \\ pour obtenir \ dans le fichier final
115
+ const match = log.match(/https:\\/\\/[a-zA-Z0-9-]+\\.trycloudflare\\.com/);
116
+
112
117
  if (match) {
113
118
  const url = match[0];
114
119
  if (global.currentUrl !== url) {
@@ -118,8 +123,8 @@ async function runGuardian() {
118
123
  }
119
124
  });
120
125
 
121
- connector.on('error', (err) => {
122
- console.error("[Fleetbo] ❌ Connection Error. Essential network components missing.");
126
+ tunnel.on('error', (err) => {
127
+ console.error("[Fleetbo] ❌ Tunnel Error. Ensure 'cloudflared' is installed.");
123
128
  });
124
129
  }
125
130
  });
@@ -214,7 +219,6 @@ async function setupProject() {
214
219
  if (!keys.enterpriseId) throw new Error("Invalid keys.");
215
220
 
216
221
  console.log(' [4/6] ⚙️ Configuring environment & CLI...');
217
- // On force le host check pour la compatibilité réseau
218
222
  const envContent = `REACT_APP_FLEETBO_DB_KEY=${keys.fleetboDBKey}\nREACT_APP_ENTERPRISE_ID=${keys.enterpriseId}\nREACT_KEY_APP=${projectName}\nDANGEROUSLY_DISABLE_HOST_CHECK=true\n`;
219
223
 
220
224
  fs.writeFileSync(path.join(projectDir, '.env'), envContent, 'utf8');
@@ -223,7 +227,7 @@ async function setupProject() {
223
227
  console.log(' [5/6] 📚 Installing dependencies...');
224
228
  execSync('npm install', { stdio: 'inherit' });
225
229
 
226
- // Installation des connecteurs réseaux (silencieux)
230
+ // Installation de cloudflared
227
231
  execSync('npm install cloudflared dotenv axios --save-dev', { stdio: 'ignore' });
228
232
 
229
233
  console.log(' [6/6] ✨ Finalizing setup...');
@@ -246,7 +250,8 @@ async function setupProject() {
246
250
  setupProject();
247
251
 
248
252
 
249
- {/*
253
+ {/*
254
+
250
255
  const { execSync } = require('child_process');
251
256
  const fs = require('fs');
252
257
  const path = require('path');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-fleetbo-project",
3
- "version": "1.2.21",
3
+ "version": "1.2.23",
4
4
  "description": "Creates a new Fleetbo project.",
5
5
  "main": "install-react-template.js",
6
6
  "bin": {