create-fleetbo-project 1.2.33 → 1.2.34
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 +109 -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,95 @@ 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
|
+
const FormData = require('form-data');
|
|
23
24
|
|
|
24
|
-
const
|
|
25
|
-
const
|
|
25
|
+
const CLOUD_ENGINE_URL = "https://us-central1-myapp-259bf.cloudfunctions.net/uploadLogicBundle";
|
|
26
|
+
const UPDATE_NETWORK_URL = 'https://us-central1-myapp-259bf.cloudfunctions.net/updateDeveloperNetwork';
|
|
27
|
+
const PORT = 3000;
|
|
28
|
+
|
|
29
|
+
const args = process.argv.slice(2);
|
|
30
|
+
const command = args[0];
|
|
31
|
+
|
|
32
|
+
const envPath = path.join(process.cwd(), '.env');
|
|
33
|
+
if (!fs.existsSync(envPath)) {
|
|
34
|
+
console.error('❌ Error: Configuration file (.env) not found.');
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
dotenv.config({ path: envPath });
|
|
38
|
+
|
|
39
|
+
const projectId = process.env.REACT_APP_ENTERPRISE_ID;
|
|
40
|
+
const keyApp = process.env.REACT_KEY_APP;
|
|
41
|
+
const testerEmail = process.env.REACT_APP_TESTER_EMAIL;
|
|
42
|
+
|
|
43
|
+
if (command === 'deploy') {
|
|
44
|
+
|
|
45
|
+
(async () => {
|
|
46
|
+
console.log('\\n\\x1b[36m%s\\x1b[0m', '⚡ FLEETBO CLOUD ENGINE v1.0');
|
|
47
|
+
console.log('\\x1b[32m%s\\x1b[0m', 'Target Runtime:', keyApp);
|
|
48
|
+
console.log('------------------------------------------------');
|
|
49
|
+
|
|
50
|
+
console.log('🔨 \\x1b[33mCompiling local assets...\\x1b[0m');
|
|
51
|
+
try {
|
|
52
|
+
execSync('npm run build', { stdio: 'inherit' });
|
|
53
|
+
} catch (e) {
|
|
54
|
+
console.error('\\n❌ Build failed. Fix errors and try again.');
|
|
55
|
+
process.exit(1);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
let buildDir = 'dist';
|
|
59
|
+
if (!fs.existsSync(path.join(process.cwd(), 'dist')) && fs.existsSync(path.join(process.cwd(), 'build'))) {
|
|
60
|
+
buildDir = 'build';
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (!fs.existsSync(path.join(process.cwd(), buildDir))) {
|
|
64
|
+
console.error(\`\\n❌ Error: Build folder '\${buildDir}' not found.\`);
|
|
65
|
+
process.exit(1);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
console.log('\\n📦 \\x1b[33mProcessing Neural Logic...\\x1b[0m');
|
|
69
|
+
console.log(\` Detected stack: React (\${buildDir})\`);
|
|
70
|
+
|
|
71
|
+
const archive = archiver('zip', { zlib: { level: 9 } });
|
|
72
|
+
const form = new FormData();
|
|
73
|
+
|
|
74
|
+
form.append('file', archive, { filename: 'bundle.zip' });
|
|
75
|
+
archive.directory(path.join(process.cwd(), buildDir), false);
|
|
76
|
+
archive.finalize();
|
|
77
|
+
|
|
78
|
+
console.log('☁️ \\x1b[33mEstablishing Uplink to Switch-Engine...\\x1b[0m');
|
|
79
|
+
|
|
80
|
+
try {
|
|
81
|
+
const response = await axios.post(CLOUD_ENGINE_URL, form, {
|
|
82
|
+
headers: {
|
|
83
|
+
...form.getHeaders(),
|
|
84
|
+
'x-project-id': projectId,
|
|
85
|
+
'Content-Length': form.getLengthSync()
|
|
86
|
+
},
|
|
87
|
+
maxContentLength: Infinity,
|
|
88
|
+
maxBodyLength: Infinity
|
|
89
|
+
});
|
|
26
90
|
|
|
91
|
+
console.log('------------------------------------------------');
|
|
92
|
+
console.log('✅ \\x1b[1m\\x1b[32mDEPLOYMENT SUCCESSFUL\\x1b[0m');
|
|
93
|
+
console.log(\` Build ID: \${response.data.buildId}\`);
|
|
94
|
+
console.log(\` Payload: \${response.data.size}\`);
|
|
95
|
+
console.log('\\n📱 \\x1b[36mNative Runtime has been hot-swapped.\\x1b[0m');
|
|
96
|
+
console.log(' Your app is live.\\n');
|
|
97
|
+
|
|
98
|
+
} catch (error) {
|
|
99
|
+
console.error('\\n❌ \\x1b[31mCRITICAL FAILURE\\x1b[0m');
|
|
100
|
+
if (error.response) {
|
|
101
|
+
console.error(\` Server responded with \${error.response.status}: \${JSON.stringify(error.response.data)}\`);
|
|
102
|
+
} else {
|
|
103
|
+
console.error(\` \${error.message}\`);
|
|
104
|
+
}
|
|
105
|
+
process.exit(1);
|
|
106
|
+
}
|
|
107
|
+
})();
|
|
108
|
+
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
27
111
|
|
|
28
112
|
const GENERATOR_COMMANDS = ['page', 'g', 'generate', 'android', 'ios'];
|
|
29
113
|
|
|
@@ -32,21 +116,12 @@ if (GENERATOR_COMMANDS.includes(command)) {
|
|
|
32
116
|
require('./page.js');
|
|
33
117
|
} catch (error) {
|
|
34
118
|
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
|
-
}
|
|
119
|
+
console.error(error.message);
|
|
41
120
|
process.exit(1);
|
|
42
121
|
}
|
|
43
122
|
return;
|
|
44
123
|
}
|
|
45
124
|
|
|
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
125
|
const NULL_DEV = process.platform === 'win32' ? '>nul 2>&1' : '2>/dev/null';
|
|
51
126
|
|
|
52
127
|
function killProcessOnPort(port) {
|
|
@@ -84,7 +159,7 @@ async function syncFirebase(keyApp, networkUrl, testerEmail) {
|
|
|
84
159
|
networkUrl,
|
|
85
160
|
tester: testerEmail
|
|
86
161
|
});
|
|
87
|
-
console.log('\\n[Fleetbo]
|
|
162
|
+
console.log('\\n[Fleetbo] ---------------------------------------------------\\n');
|
|
88
163
|
console.log(\`[Fleetbo] ✅ Uplink Status: Online for \${testerEmail}\`);
|
|
89
164
|
console.log(\`[Fleetbo] 🚀 Simulator: https://fleetbo.io/studio/view/\${keyApp}\`);
|
|
90
165
|
console.log(\'[Fleetbo] 👉 Your studio is ready. You can now open the link above.\n');
|
|
@@ -97,25 +172,14 @@ async function syncFirebase(keyApp, networkUrl, testerEmail) {
|
|
|
97
172
|
async function runDevEnvironment() {
|
|
98
173
|
console.log(\`[Fleetbo] 🛡️ Initializing Developer Environment on \${os.platform()}...\`);
|
|
99
174
|
|
|
100
|
-
// 1. NETTOYAGE PRÉVENTIF
|
|
101
175
|
killNetworkService();
|
|
102
176
|
killProcessOnPort(PORT);
|
|
103
177
|
|
|
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
178
|
if (!testerEmail) {
|
|
114
179
|
console.error('Error: REACT_APP_TESTER_EMAIL missing in .env');
|
|
115
180
|
process.exit(1);
|
|
116
181
|
}
|
|
117
182
|
|
|
118
|
-
// 2. DÉMARRAGE DU SERVEUR LOCAL
|
|
119
183
|
console.log(\`[Fleetbo] 📦 Starting Local Server...\`);
|
|
120
184
|
const npmCmd = process.platform === 'win32' ? 'npm.cmd' : 'npm';
|
|
121
185
|
|
|
@@ -139,15 +203,12 @@ async function runDevEnvironment() {
|
|
|
139
203
|
console.log(\`\\n[Fleetbo] 🛑 STOP! DO NOT open the Studio yet.\`);
|
|
140
204
|
console.log(\`\\n[Fleetbo] ⏳ Establishing Secure Uplink... Please wait...\`);
|
|
141
205
|
|
|
142
|
-
|
|
206
|
+
|
|
143
207
|
const npxCmd = process.platform === 'win32' ? 'npx.cmd' : 'npx';
|
|
144
208
|
|
|
145
|
-
// --- MODIFICATION : Ajout de { shell: true } pour Windows ---
|
|
146
209
|
const uplink = spawn(npxCmd, ['cloudflared', 'tunnel', '--url', \`http://localhost:\${PORT}\`], { shell: true });
|
|
147
|
-
|
|
148
210
|
uplink.stderr.on('data', (chunk) => {
|
|
149
211
|
const log = chunk.toString();
|
|
150
|
-
|
|
151
212
|
const match = log.match(/https:\\/\\/[a-zA-Z0-9-]+\\.trycloudflare\\.com/);
|
|
152
213
|
|
|
153
214
|
if (match) {
|
|
@@ -169,7 +230,6 @@ async function runDevEnvironment() {
|
|
|
169
230
|
runDevEnvironment();
|
|
170
231
|
`;
|
|
171
232
|
|
|
172
|
-
// --- LOGIQUE D'INSTALLATION (INCHANGÉE) ---
|
|
173
233
|
const args = process.argv.slice(2);
|
|
174
234
|
const projectNameArg = args.find(arg => !arg.startsWith('--'));
|
|
175
235
|
const tokenArg = args.find(arg => arg.startsWith('--token='));
|
|
@@ -257,13 +317,13 @@ async function setupProject() {
|
|
|
257
317
|
|
|
258
318
|
console.log(' [4/6] ⚙️ Configuring environment & CLI...');
|
|
259
319
|
|
|
260
|
-
const envContent =
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
320
|
+
const envContent =
|
|
321
|
+
`REACT_APP_FLEETBO_DB_KEY=${keys.fleetboDBKey}
|
|
322
|
+
REACT_APP_ENTERPRISE_ID=${keys.enterpriseId}
|
|
323
|
+
REACT_KEY_APP=${projectName}
|
|
324
|
+
REACT_APP_TESTER_EMAIL=${userEmailArg}
|
|
325
|
+
DANGEROUSLY_DISABLE_HOST_CHECK=true
|
|
326
|
+
WDS_SOCKET_PORT=0 `;
|
|
267
327
|
|
|
268
328
|
fs.writeFileSync(path.join(projectDir, '.env'), envContent, 'utf8');
|
|
269
329
|
const scriptsDir = path.join(projectDir, 'scripts');
|
|
@@ -276,17 +336,26 @@ async function setupProject() {
|
|
|
276
336
|
console.log(' [5/6] 📚 Installing dependencies...');
|
|
277
337
|
execSync('npm install', { stdio: 'inherit' });
|
|
278
338
|
|
|
279
|
-
execSync('npm install cloudflared dotenv axios --save-dev', { stdio: 'ignore' });
|
|
339
|
+
execSync('npm install cloudflared dotenv axios archiver form-data --save-dev', { stdio: 'ignore' });
|
|
280
340
|
|
|
281
341
|
console.log(' [6/6] ✨ Finalizing setup...');
|
|
282
342
|
const packageJsonPath = path.join(projectDir, 'package.json');
|
|
283
343
|
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
344
|
+
|
|
284
345
|
packageJson.name = projectName;
|
|
285
|
-
|
|
346
|
+
|
|
347
|
+
packageJson.scripts = {
|
|
348
|
+
...packageJson.scripts,
|
|
349
|
+
"fleetbo": "node scripts/cli.js",
|
|
350
|
+
"dev": "node scripts/cli.js"
|
|
351
|
+
};
|
|
352
|
+
|
|
286
353
|
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), 'utf8');
|
|
287
354
|
|
|
288
355
|
console.log('\n [Fleetbo] ✅ Project successfully created!');
|
|
289
|
-
console.log(`\n👉 Run: cd ${projectName}
|
|
356
|
+
console.log(`\n👉 Run: cd ${projectName}`);
|
|
357
|
+
console.log(`👉 Start Dev: npm run fleetbo`);
|
|
358
|
+
console.log(`👉 Deploy App: npm run fleetbo deploy`);
|
|
290
359
|
|
|
291
360
|
} catch (error) {
|
|
292
361
|
console.error('\n❌ Setup failed:', error.message);
|