create-fleetbo-project 1.2.34 → 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.
@@ -20,7 +20,6 @@ const axios = require('axios');
20
20
  const dotenv = require('dotenv');
21
21
  const os = require('os');
22
22
  const archiver = require('archiver');
23
- const FormData = require('form-data');
24
23
 
25
24
  const CLOUD_ENGINE_URL = "https://us-central1-myapp-259bf.cloudfunctions.net/uploadLogicBundle";
26
25
  const UPDATE_NETWORK_URL = 'https://us-central1-myapp-259bf.cloudfunctions.net/updateDeveloperNetwork';
@@ -36,12 +35,18 @@ if (!fs.existsSync(envPath)) {
36
35
  }
37
36
  dotenv.config({ path: envPath });
38
37
 
39
- const projectId = process.env.REACT_APP_ENTERPRISE_ID;
40
- const keyApp = process.env.REACT_KEY_APP;
38
+ const projectId = process.env.REACT_APP_ENTERPRISE_ID;
39
+ const keyApp = process.env.REACT_KEY_APP;
41
40
  const testerEmail = process.env.REACT_APP_TESTER_EMAIL;
42
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
+ }
48
+
43
49
  if (command === 'deploy') {
44
-
45
50
  (async () => {
46
51
  console.log('\\n\\x1b[36m%s\\x1b[0m', '⚔ FLEETBO CLOUD ENGINE v1.0');
47
52
  console.log('\\x1b[32m%s\\x1b[0m', 'Target Runtime:', keyApp);
@@ -68,21 +73,26 @@ if (command === 'deploy') {
68
73
  console.log('\\nšŸ“¦ \\x1b[33mProcessing Neural Logic...\\x1b[0m');
69
74
  console.log(\` Detected stack: React (\${buildDir})\`);
70
75
 
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();
76
+ try {
77
+ const zipBuffer = await new Promise((resolve, reject) => {
78
+ const chunks = [];
79
+ const archive = archiver('zip', { zlib: { level: 9 } });
77
80
 
78
- console.log('ā˜ļø \\x1b[33mEstablishing Uplink to Switch-Engine...\\x1b[0m');
81
+ archive.on('data', (chunk) => chunks.push(chunk));
82
+ archive.on('error', (err) => reject(err));
83
+ archive.on('end', () => resolve(Buffer.concat(chunks)));
79
84
 
80
- try {
81
- const response = await axios.post(CLOUD_ENGINE_URL, form, {
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, {
82
92
  headers: {
83
- ...form.getHeaders(),
93
+ 'Content-Type': 'application/zip',
84
94
  'x-project-id': projectId,
85
- 'Content-Length': form.getLengthSync()
95
+ 'Content-Length': zipBuffer.length
86
96
  },
87
97
  maxContentLength: Infinity,
88
98
  maxBodyLength: Infinity
@@ -91,21 +101,21 @@ if (command === 'deploy') {
91
101
  console.log('------------------------------------------------');
92
102
  console.log('āœ… \\x1b[1m\\x1b[32mDEPLOYMENT SUCCESSFUL\\x1b[0m');
93
103
  console.log(\` Build ID: \${response.data.buildId}\`);
94
- console.log(\` Payload: \${response.data.size}\`);
104
+ console.log(\` Payload: \${(zipBuffer.length / 1024 / 1024).toFixed(2)} MB\`);
95
105
  console.log('\\nšŸ“± \\x1b[36mNative Runtime has been hot-swapped.\\x1b[0m');
96
106
  console.log(' Your app is live.\\n');
97
107
 
98
108
  } catch (error) {
99
109
  console.error('\\nāŒ \\x1b[31mCRITICAL FAILURE\\x1b[0m');
100
110
  if (error.response) {
101
- console.error(\` Server responded with \${error.response.status}: \${JSON.stringify(error.response.data)}\`);
111
+ console.error(\` Server responded with \${error.response.status}: "\${error.response.statusText}".\`);
112
+ console.error(\` Details: \${JSON.stringify(error.response.data)}\`);
102
113
  } else {
103
114
  console.error(\` \${error.message}\`);
104
115
  }
105
116
  process.exit(1);
106
117
  }
107
118
  })();
108
-
109
119
  return;
110
120
  }
111
121
 
@@ -318,12 +328,13 @@ async function setupProject() {
318
328
  console.log(' [4/6] āš™ļø Configuring environment & CLI...');
319
329
 
320
330
  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 `;
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
+ `;
327
338
 
328
339
  fs.writeFileSync(path.join(projectDir, '.env'), envContent, 'utf8');
329
340
  const scriptsDir = path.join(projectDir, 'scripts');
@@ -336,7 +347,7 @@ async function setupProject() {
336
347
  console.log(' [5/6] šŸ“š Installing dependencies...');
337
348
  execSync('npm install', { stdio: 'inherit' });
338
349
 
339
- execSync('npm install cloudflared dotenv axios archiver form-data --save-dev', { stdio: 'ignore' });
350
+ execSync('npm install cloudflared dotenv axios archiver --save-dev', { stdio: 'ignore' });
340
351
 
341
352
  console.log(' [6/6] ✨ Finalizing setup...');
342
353
  const packageJsonPath = path.join(projectDir, 'package.json');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-fleetbo-project",
3
- "version": "1.2.34",
3
+ "version": "1.2.35",
4
4
  "description": "Creates a new Fleetbo project.",
5
5
  "main": "install-react-template.js",
6
6
  "bin": {