create-fleetbo-project 1.2.24 → 1.2.25

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 "Secure Uplink") ---
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
  }
@@ -59,7 +59,7 @@ async function syncFirebase(keyApp, networkUrl) {
59
59
  try {
60
60
  await axios.post(UPDATE_NETWORK_URL, { keyApp, networkUrl });
61
61
  console.log('\\n[Fleetbo] ---------------------------------------------------');
62
- console.log(\`[Fleetbo] ✅ Tunnel Active: \${networkUrl}\`);
62
+ console.log(\`[Fleetbo] ✅ Uplink Status: Online\`);
63
63
  console.log(\`[Fleetbo] 🚀 Simulator: https://fleetbo.io/studio/view/\${keyApp}\`);
64
64
  console.log('[Fleetbo] ---------------------------------------------------\\n');
65
65
  } catch (err) {
@@ -67,23 +67,23 @@ async function syncFirebase(keyApp, networkUrl) {
67
67
  }
68
68
  }
69
69
 
70
- async function runGuardian() {
71
- console.log(\`[Fleetbo] 🛡️ Starting Fleetbo Guardian on \${os.platform()}...\`);
70
+ async function runDevEnvironment() {
71
+ console.log(\`[Fleetbo] 🛡️ Initializing Developer Environment on \${os.platform()}...\`);
72
72
 
73
73
  // 1. NETTOYAGE PRÉVENTIF
74
- killCloudflared();
74
+ killNetworkService();
75
75
  killProcessOnPort(PORT);
76
76
 
77
77
  const envPath = path.join(process.cwd(), '.env');
78
78
  if (!fs.existsSync(envPath)) {
79
- console.error('Error: .env file not found.');
79
+ console.error('Error: Configuration file not found.');
80
80
  process.exit(1);
81
81
  }
82
82
  dotenv.config({ path: envPath });
83
83
  const keyApp = process.env.REACT_KEY_APP;
84
84
 
85
- // 2. DÉMARRAGE REACT
86
- console.log(\`[Fleetbo] 📦 Booting React Server...\`);
85
+ // 2. DÉMARRAGE DU SERVEUR LOCAL
86
+ console.log(\`[Fleetbo] 📦 Starting Local Server...\`);
87
87
  const npmCmd = process.platform === 'win32' ? 'npm.cmd' : 'npm';
88
88
 
89
89
  const devServer = spawn(npmCmd, ['start'], {
@@ -94,24 +94,23 @@ async function runGuardian() {
94
94
  devServer.stdout.pipe(process.stdout);
95
95
  devServer.stderr.pipe(process.stderr);
96
96
 
97
- let tunnelStarted = false;
97
+ let connectionStarted = false;
98
98
 
99
99
  devServer.stdout.on('data', (data) => {
100
100
  const output = data.toString();
101
101
 
102
- if (!tunnelStarted && (output.includes('Local:') || output.includes('Compiled successfully'))) {
103
- tunnelStarted = true;
104
- console.log(\`\\n[Fleetbo] 🔗 React is ready. Establishing secure tunnel...\`);
102
+ if (!connectionStarted && (output.includes('Local:') || output.includes('Compiled successfully'))) {
103
+ connectionStarted = true;
104
+ console.log(\`\\n[Fleetbo] 🔗 Local Server Ready. Establishing Secure Uplink...\`);
105
105
 
106
- // 3. DÉMARRAGE TUNNEL CLOUDFLARE (via npm exec)
106
+ // 3. DÉMARRAGE DE LA LIAISON (UPLINK)
107
107
  const npxCmd = process.platform === 'win32' ? 'npx.cmd' : 'npx';
108
- const tunnel = spawn(npxCmd, ['cloudflared', 'tunnel', '--url', \`http://localhost:\${PORT}\`]);
108
+ const uplink = spawn(npxCmd, ['cloudflared', 'tunnel', '--url', \`http://localhost:\${PORT}\`]);
109
109
 
110
- // Capture de l'URL dans les logs stderr
111
- tunnel.stderr.on('data', (chunk) => {
110
+ // Capture de l'URL (Silencieux)
111
+ uplink.stderr.on('data', (chunk) => {
112
112
  const log = chunk.toString();
113
113
 
114
- // --- REGEX VALIDÉE ---
115
114
  const match = log.match(/https:\\/\\/[a-zA-Z0-9-]+\\.trycloudflare\\.com/);
116
115
 
117
116
  if (match) {
@@ -123,14 +122,14 @@ async function runGuardian() {
123
122
  }
124
123
  });
125
124
 
126
- tunnel.on('error', (err) => {
127
- console.error("[Fleetbo] ❌ Tunnel Error. Ensure 'cloudflared' is installed.");
125
+ uplink.on('error', (err) => {
126
+ console.error("[Fleetbo] ❌ Uplink Error. Network component missing.");
128
127
  });
129
128
  }
130
129
  });
131
130
  }
132
131
 
133
- runGuardian();
132
+ runDevEnvironment();
134
133
  `;
135
134
 
136
135
  // --- Analyse des Arguments ---
@@ -220,7 +219,7 @@ async function setupProject() {
220
219
 
221
220
  console.log(' [4/6] ⚙️ Configuring environment & CLI...');
222
221
 
223
- // --- MISE À JOUR : Activation du Hot Reload avec WDS_SOCKET_PORT=0 ---
222
+ // Hot Reload activé via WDS_SOCKET_PORT=0
224
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`;
225
224
 
226
225
  fs.writeFileSync(path.join(projectDir, '.env'), envContent, 'utf8');
@@ -229,7 +228,7 @@ async function setupProject() {
229
228
  console.log(' [5/6] 📚 Installing dependencies...');
230
229
  execSync('npm install', { stdio: 'inherit' });
231
230
 
232
- // Installation de cloudflared
231
+ // Installation silencieuse
233
232
  execSync('npm install cloudflared dotenv axios --save-dev', { stdio: 'ignore' });
234
233
 
235
234
  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.25",
4
4
  "description": "Creates a new Fleetbo project.",
5
5
  "main": "install-react-template.js",
6
6
  "bin": {