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.
- package/install-react-template.js +26 -27
- package/package.json +1 -1
|
@@ -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
|
|
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
|
-
//
|
|
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
|
-
//
|
|
41
|
-
function
|
|
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
|
|
50
|
-
|
|
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] ✅
|
|
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
|
|
71
|
-
console.log(\`[Fleetbo] 🛡️
|
|
70
|
+
async function runDevEnvironment() {
|
|
71
|
+
console.log(\`[Fleetbo] 🛡️ Initializing Developer Environment on \${os.platform()}...\`);
|
|
72
72
|
|
|
73
73
|
// 1. NETTOYAGE PRÉVENTIF
|
|
74
|
-
|
|
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:
|
|
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
|
|
86
|
-
console.log(\`[Fleetbo] 📦
|
|
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
|
|
97
|
+
let connectionStarted = false;
|
|
98
98
|
|
|
99
99
|
devServer.stdout.on('data', (data) => {
|
|
100
100
|
const output = data.toString();
|
|
101
101
|
|
|
102
|
-
if (!
|
|
103
|
-
|
|
104
|
-
console.log(\`\\n[Fleetbo] 🔗
|
|
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
|
|
106
|
+
// 3. DÉMARRAGE DE LA LIAISON (UPLINK)
|
|
107
107
|
const npxCmd = process.platform === 'win32' ? 'npx.cmd' : 'npx';
|
|
108
|
-
const
|
|
108
|
+
const uplink = spawn(npxCmd, ['cloudflared', 'tunnel', '--url', \`http://localhost:\${PORT}\`]);
|
|
109
109
|
|
|
110
|
-
// Capture de l'URL
|
|
111
|
-
|
|
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
|
-
|
|
127
|
-
console.error("[Fleetbo] ❌
|
|
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
|
-
|
|
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
|
-
//
|
|
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
|
|
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...');
|