create-fleetbo-project 1.2.33 → 1.2.35
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 +120 -40
- package/package.json +1 -1
|
@@ -11,7 +11,6 @@ const branchName = 'master';
|
|
|
11
11
|
const archiveUrl = `https://github.com/${repoOwner}/${repoName}/archive/refs/heads/${branchName}.tar.gz`;
|
|
12
12
|
const bootstrapUrl = 'https://us-central1-myapp-259bf.cloudfunctions.net/bootstrapProject';
|
|
13
13
|
|
|
14
|
-
// --- CONTENU DU CLI INJECTÉ (MISE À JOUR) ---
|
|
15
14
|
const CLI_SCRIPT_CONTENT = `#!/usr/bin/env node
|
|
16
15
|
|
|
17
16
|
const { spawn, execSync } = require('child_process');
|
|
@@ -20,10 +19,105 @@ const path = require('path');
|
|
|
20
19
|
const axios = require('axios');
|
|
21
20
|
const dotenv = require('dotenv');
|
|
22
21
|
const os = require('os');
|
|
22
|
+
const archiver = require('archiver');
|
|
23
23
|
|
|
24
|
-
const
|
|
25
|
-
const
|
|
24
|
+
const CLOUD_ENGINE_URL = "https://us-central1-myapp-259bf.cloudfunctions.net/uploadLogicBundle";
|
|
25
|
+
const UPDATE_NETWORK_URL = 'https://us-central1-myapp-259bf.cloudfunctions.net/updateDeveloperNetwork';
|
|
26
|
+
const PORT = 3000;
|
|
27
|
+
|
|
28
|
+
const args = process.argv.slice(2);
|
|
29
|
+
const command = args[0];
|
|
30
|
+
|
|
31
|
+
const envPath = path.join(process.cwd(), '.env');
|
|
32
|
+
if (!fs.existsSync(envPath)) {
|
|
33
|
+
console.error('❌ Error: Configuration file (.env) not found.');
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
36
|
+
dotenv.config({ path: envPath });
|
|
37
|
+
|
|
38
|
+
const projectId = process.env.REACT_APP_ENTERPRISE_ID;
|
|
39
|
+
const keyApp = process.env.REACT_KEY_APP;
|
|
40
|
+
const testerEmail = process.env.REACT_APP_TESTER_EMAIL;
|
|
41
|
+
|
|
42
|
+
if (!projectId) {
|
|
43
|
+
console.error('\\n❌ Error: Project ID is missing.');
|
|
44
|
+
console.error('👉 Please check your .env file.');
|
|
45
|
+
console.error(' It must contain: REACT_APP_ENTERPRISE_ID=your_project_id\\n');
|
|
46
|
+
process.exit(1);
|
|
47
|
+
}
|
|
26
48
|
|
|
49
|
+
if (command === 'deploy') {
|
|
50
|
+
(async () => {
|
|
51
|
+
console.log('\\n\\x1b[36m%s\\x1b[0m', '⚡ FLEETBO CLOUD ENGINE v1.0');
|
|
52
|
+
console.log('\\x1b[32m%s\\x1b[0m', 'Target Runtime:', keyApp);
|
|
53
|
+
console.log('------------------------------------------------');
|
|
54
|
+
|
|
55
|
+
console.log('🔨 \\x1b[33mCompiling local assets...\\x1b[0m');
|
|
56
|
+
try {
|
|
57
|
+
execSync('npm run build', { stdio: 'inherit' });
|
|
58
|
+
} catch (e) {
|
|
59
|
+
console.error('\\n❌ Build failed. Fix errors and try again.');
|
|
60
|
+
process.exit(1);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
let buildDir = 'dist';
|
|
64
|
+
if (!fs.existsSync(path.join(process.cwd(), 'dist')) && fs.existsSync(path.join(process.cwd(), 'build'))) {
|
|
65
|
+
buildDir = 'build';
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (!fs.existsSync(path.join(process.cwd(), buildDir))) {
|
|
69
|
+
console.error(\`\\n❌ Error: Build folder '\${buildDir}' not found.\`);
|
|
70
|
+
process.exit(1);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
console.log('\\n📦 \\x1b[33mProcessing Neural Logic...\\x1b[0m');
|
|
74
|
+
console.log(\` Detected stack: React (\${buildDir})\`);
|
|
75
|
+
|
|
76
|
+
try {
|
|
77
|
+
const zipBuffer = await new Promise((resolve, reject) => {
|
|
78
|
+
const chunks = [];
|
|
79
|
+
const archive = archiver('zip', { zlib: { level: 9 } });
|
|
80
|
+
|
|
81
|
+
archive.on('data', (chunk) => chunks.push(chunk));
|
|
82
|
+
archive.on('error', (err) => reject(err));
|
|
83
|
+
archive.on('end', () => resolve(Buffer.concat(chunks)));
|
|
84
|
+
|
|
85
|
+
archive.directory(path.join(process.cwd(), buildDir), false);
|
|
86
|
+
archive.finalize();
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
console.log('☁️ \\x1b[33mEstablishing Uplink to Switch-Engine...\\x1b[0m');
|
|
90
|
+
|
|
91
|
+
const response = await axios.post(CLOUD_ENGINE_URL, zipBuffer, {
|
|
92
|
+
headers: {
|
|
93
|
+
'Content-Type': 'application/zip',
|
|
94
|
+
'x-project-id': projectId,
|
|
95
|
+
'Content-Length': zipBuffer.length
|
|
96
|
+
},
|
|
97
|
+
maxContentLength: Infinity,
|
|
98
|
+
maxBodyLength: Infinity
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
console.log('------------------------------------------------');
|
|
102
|
+
console.log('✅ \\x1b[1m\\x1b[32mDEPLOYMENT SUCCESSFUL\\x1b[0m');
|
|
103
|
+
console.log(\` Build ID: \${response.data.buildId}\`);
|
|
104
|
+
console.log(\` Payload: \${(zipBuffer.length / 1024 / 1024).toFixed(2)} MB\`);
|
|
105
|
+
console.log('\\n📱 \\x1b[36mNative Runtime has been hot-swapped.\\x1b[0m');
|
|
106
|
+
console.log(' Your app is live.\\n');
|
|
107
|
+
|
|
108
|
+
} catch (error) {
|
|
109
|
+
console.error('\\n❌ \\x1b[31mCRITICAL FAILURE\\x1b[0m');
|
|
110
|
+
if (error.response) {
|
|
111
|
+
console.error(\` Server responded with \${error.response.status}: "\${error.response.statusText}".\`);
|
|
112
|
+
console.error(\` Details: \${JSON.stringify(error.response.data)}\`);
|
|
113
|
+
} else {
|
|
114
|
+
console.error(\` \${error.message}\`);
|
|
115
|
+
}
|
|
116
|
+
process.exit(1);
|
|
117
|
+
}
|
|
118
|
+
})();
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
27
121
|
|
|
28
122
|
const GENERATOR_COMMANDS = ['page', 'g', 'generate', 'android', 'ios'];
|
|
29
123
|
|
|
@@ -32,21 +126,12 @@ if (GENERATOR_COMMANDS.includes(command)) {
|
|
|
32
126
|
require('./page.js');
|
|
33
127
|
} catch (error) {
|
|
34
128
|
console.error('\\x1b[31m%s\\x1b[0m', ' CRITICAL ERROR in Fleetbo Generator:');
|
|
35
|
-
|
|
36
|
-
console.error(". The generator script (scripts/page.js) is missing.");
|
|
37
|
-
console.error(" Please update your Fleetbo SDK.");
|
|
38
|
-
} else {
|
|
39
|
-
console.error(error.message);
|
|
40
|
-
}
|
|
129
|
+
console.error(error.message);
|
|
41
130
|
process.exit(1);
|
|
42
131
|
}
|
|
43
132
|
return;
|
|
44
133
|
}
|
|
45
134
|
|
|
46
|
-
const UPDATE_NETWORK_URL = 'https://us-central1-myapp-259bf.cloudfunctions.net/updateDeveloperNetwork';
|
|
47
|
-
const PORT = 3000;
|
|
48
|
-
|
|
49
|
-
// Définir la redirection nulle selon l'OS
|
|
50
135
|
const NULL_DEV = process.platform === 'win32' ? '>nul 2>&1' : '2>/dev/null';
|
|
51
136
|
|
|
52
137
|
function killProcessOnPort(port) {
|
|
@@ -84,7 +169,7 @@ async function syncFirebase(keyApp, networkUrl, testerEmail) {
|
|
|
84
169
|
networkUrl,
|
|
85
170
|
tester: testerEmail
|
|
86
171
|
});
|
|
87
|
-
console.log('\\n[Fleetbo]
|
|
172
|
+
console.log('\\n[Fleetbo] ---------------------------------------------------\\n');
|
|
88
173
|
console.log(\`[Fleetbo] ✅ Uplink Status: Online for \${testerEmail}\`);
|
|
89
174
|
console.log(\`[Fleetbo] 🚀 Simulator: https://fleetbo.io/studio/view/\${keyApp}\`);
|
|
90
175
|
console.log(\'[Fleetbo] 👉 Your studio is ready. You can now open the link above.\n');
|
|
@@ -97,25 +182,14 @@ async function syncFirebase(keyApp, networkUrl, testerEmail) {
|
|
|
97
182
|
async function runDevEnvironment() {
|
|
98
183
|
console.log(\`[Fleetbo] 🛡️ Initializing Developer Environment on \${os.platform()}...\`);
|
|
99
184
|
|
|
100
|
-
// 1. NETTOYAGE PRÉVENTIF
|
|
101
185
|
killNetworkService();
|
|
102
186
|
killProcessOnPort(PORT);
|
|
103
187
|
|
|
104
|
-
const envPath = path.join(process.cwd(), '.env');
|
|
105
|
-
if (!fs.existsSync(envPath)) {
|
|
106
|
-
console.error('Error: Configuration file not found.');
|
|
107
|
-
process.exit(1);
|
|
108
|
-
}
|
|
109
|
-
dotenv.config({ path: envPath });
|
|
110
|
-
const keyApp = process.env.REACT_KEY_APP;
|
|
111
|
-
const testerEmail = process.env.REACT_APP_TESTER_EMAIL;
|
|
112
|
-
|
|
113
188
|
if (!testerEmail) {
|
|
114
189
|
console.error('Error: REACT_APP_TESTER_EMAIL missing in .env');
|
|
115
190
|
process.exit(1);
|
|
116
191
|
}
|
|
117
192
|
|
|
118
|
-
// 2. DÉMARRAGE DU SERVEUR LOCAL
|
|
119
193
|
console.log(\`[Fleetbo] 📦 Starting Local Server...\`);
|
|
120
194
|
const npmCmd = process.platform === 'win32' ? 'npm.cmd' : 'npm';
|
|
121
195
|
|
|
@@ -139,15 +213,12 @@ async function runDevEnvironment() {
|
|
|
139
213
|
console.log(\`\\n[Fleetbo] 🛑 STOP! DO NOT open the Studio yet.\`);
|
|
140
214
|
console.log(\`\\n[Fleetbo] ⏳ Establishing Secure Uplink... Please wait...\`);
|
|
141
215
|
|
|
142
|
-
|
|
216
|
+
|
|
143
217
|
const npxCmd = process.platform === 'win32' ? 'npx.cmd' : 'npx';
|
|
144
218
|
|
|
145
|
-
// --- MODIFICATION : Ajout de { shell: true } pour Windows ---
|
|
146
219
|
const uplink = spawn(npxCmd, ['cloudflared', 'tunnel', '--url', \`http://localhost:\${PORT}\`], { shell: true });
|
|
147
|
-
|
|
148
220
|
uplink.stderr.on('data', (chunk) => {
|
|
149
221
|
const log = chunk.toString();
|
|
150
|
-
|
|
151
222
|
const match = log.match(/https:\\/\\/[a-zA-Z0-9-]+\\.trycloudflare\\.com/);
|
|
152
223
|
|
|
153
224
|
if (match) {
|
|
@@ -169,7 +240,6 @@ async function runDevEnvironment() {
|
|
|
169
240
|
runDevEnvironment();
|
|
170
241
|
`;
|
|
171
242
|
|
|
172
|
-
// --- LOGIQUE D'INSTALLATION (INCHANGÉE) ---
|
|
173
243
|
const args = process.argv.slice(2);
|
|
174
244
|
const projectNameArg = args.find(arg => !arg.startsWith('--'));
|
|
175
245
|
const tokenArg = args.find(arg => arg.startsWith('--token='));
|
|
@@ -257,13 +327,14 @@ async function setupProject() {
|
|
|
257
327
|
|
|
258
328
|
console.log(' [4/6] ⚙️ Configuring environment & CLI...');
|
|
259
329
|
|
|
260
|
-
const envContent =
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
330
|
+
const envContent =
|
|
331
|
+
`REACT_APP_FLEETBO_DB_KEY=${keys.fleetboDBKey}
|
|
332
|
+
REACT_APP_ENTERPRISE_ID=${keys.enterpriseId}
|
|
333
|
+
REACT_KEY_APP=${projectName}
|
|
334
|
+
REACT_APP_TESTER_EMAIL=${userEmailArg}
|
|
335
|
+
DANGEROUSLY_DISABLE_HOST_CHECK=true
|
|
336
|
+
WDS_SOCKET_PORT=0
|
|
337
|
+
`;
|
|
267
338
|
|
|
268
339
|
fs.writeFileSync(path.join(projectDir, '.env'), envContent, 'utf8');
|
|
269
340
|
const scriptsDir = path.join(projectDir, 'scripts');
|
|
@@ -276,17 +347,26 @@ async function setupProject() {
|
|
|
276
347
|
console.log(' [5/6] 📚 Installing dependencies...');
|
|
277
348
|
execSync('npm install', { stdio: 'inherit' });
|
|
278
349
|
|
|
279
|
-
execSync('npm install cloudflared dotenv axios --save-dev', { stdio: 'ignore' });
|
|
350
|
+
execSync('npm install cloudflared dotenv axios archiver --save-dev', { stdio: 'ignore' });
|
|
280
351
|
|
|
281
352
|
console.log(' [6/6] ✨ Finalizing setup...');
|
|
282
353
|
const packageJsonPath = path.join(projectDir, 'package.json');
|
|
283
354
|
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
355
|
+
|
|
284
356
|
packageJson.name = projectName;
|
|
285
|
-
|
|
357
|
+
|
|
358
|
+
packageJson.scripts = {
|
|
359
|
+
...packageJson.scripts,
|
|
360
|
+
"fleetbo": "node scripts/cli.js",
|
|
361
|
+
"dev": "node scripts/cli.js"
|
|
362
|
+
};
|
|
363
|
+
|
|
286
364
|
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), 'utf8');
|
|
287
365
|
|
|
288
366
|
console.log('\n [Fleetbo] ✅ Project successfully created!');
|
|
289
|
-
console.log(`\n👉 Run: cd ${projectName}
|
|
367
|
+
console.log(`\n👉 Run: cd ${projectName}`);
|
|
368
|
+
console.log(`👉 Start Dev: npm run fleetbo`);
|
|
369
|
+
console.log(`👉 Deploy App: npm run fleetbo deploy`);
|
|
290
370
|
|
|
291
371
|
} catch (error) {
|
|
292
372
|
console.error('\n❌ Setup failed:', error.message);
|