create-fleetbo-project 1.2.26 → 1.2.28
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 +44 -12
- package/package.json +1 -1
|
@@ -22,18 +22,42 @@ const axios = require('axios');
|
|
|
22
22
|
const dotenv = require('dotenv');
|
|
23
23
|
const os = require('os');
|
|
24
24
|
|
|
25
|
+
const args = process.argv.slice(2);
|
|
26
|
+
const command = args[0];
|
|
27
|
+
const GENERATOR_COMMANDS = ['page', 'g', 'generate'];
|
|
28
|
+
if (GENERATOR_COMMANDS.includes(command)) {
|
|
29
|
+
try {
|
|
30
|
+
require('./page.js');
|
|
31
|
+
} catch (error) {
|
|
32
|
+
console.error('\\x1b[31m%s\\x1b[0m', ' CRITICAL ERROR in Fleetbo Generator:');
|
|
33
|
+
if (error.code === 'MODULE_NOT_FOUND') {
|
|
34
|
+
console.error(". The generator script (scripts/page.js) is missing.");
|
|
35
|
+
console.error(" Please update your Fleetbo SDK.");
|
|
36
|
+
} else {
|
|
37
|
+
console.error(error.message);
|
|
38
|
+
}
|
|
39
|
+
process.exit(1);
|
|
40
|
+
}
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
25
44
|
const UPDATE_NETWORK_URL = 'https://us-central1-myapp-259bf.cloudfunctions.net/updateDeveloperNetwork';
|
|
26
45
|
const PORT = 3000;
|
|
27
46
|
|
|
28
|
-
//
|
|
47
|
+
// Définir la redirection nulle selon l'OS
|
|
48
|
+
const NULL_DEV = process.platform === 'win32' ? '>nul 2>&1' : '2>/dev/null';
|
|
49
|
+
|
|
50
|
+
// Gestion des processus système (Mac/Linux/Windows)
|
|
29
51
|
function killProcessOnPort(port) {
|
|
30
52
|
try {
|
|
31
53
|
if (process.platform !== 'win32') {
|
|
32
|
-
const pid = execSync(\`lsof -ti:\${port}
|
|
54
|
+
const pid = execSync(\`lsof -ti:\${port} \${NULL_DEV}\`).toString().trim();
|
|
33
55
|
if (pid) {
|
|
34
|
-
execSync(\`kill -9 \${pid.split('\\n').join(' ')}
|
|
56
|
+
execSync(\`kill -9 \${pid.split('\\n').join(' ')} \${NULL_DEV}\`);
|
|
35
57
|
}
|
|
36
58
|
}
|
|
59
|
+
// Pas de kill port spécifique Windows ici car géré par le kill global souvent,
|
|
60
|
+
// ou nécessiterait netstat complexe. On laisse faire pour l'instant.
|
|
37
61
|
} catch (e) {}
|
|
38
62
|
}
|
|
39
63
|
|
|
@@ -41,7 +65,7 @@ function killProcessOnPort(port) {
|
|
|
41
65
|
function killNetworkService() {
|
|
42
66
|
try {
|
|
43
67
|
const cmd = process.platform === 'win32' ? 'taskkill /IM cloudflared.exe /F' : 'pkill cloudflared';
|
|
44
|
-
execSync(cmd + '
|
|
68
|
+
execSync(cmd + ' ' + NULL_DEV); // Utilisation de la variable adaptée
|
|
45
69
|
} catch (e) {}
|
|
46
70
|
}
|
|
47
71
|
|
|
@@ -98,6 +122,7 @@ async function runDevEnvironment() {
|
|
|
98
122
|
|
|
99
123
|
const devServer = spawn(npmCmd, ['start'], {
|
|
100
124
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
125
|
+
shell: true,
|
|
101
126
|
env: { ...process.env, BROWSER: 'none', PORT: PORT.toString() }
|
|
102
127
|
});
|
|
103
128
|
|
|
@@ -233,15 +258,22 @@ async function setupProject() {
|
|
|
233
258
|
console.log(' [4/6] ⚙️ Configuring environment & CLI...');
|
|
234
259
|
|
|
235
260
|
const envContent = `REACT_APP_FLEETBO_DB_KEY=${keys.fleetboDBKey}
|
|
236
|
-
REACT_APP_ENTERPRISE_ID=${keys.enterpriseId}
|
|
237
|
-
REACT_KEY_APP=${projectName}
|
|
238
|
-
REACT_APP_TESTER_EMAIL=${userEmailArg}
|
|
239
|
-
DANGEROUSLY_DISABLE_HOST_CHECK=true
|
|
240
|
-
WDS_SOCKET_PORT=0
|
|
241
|
-
`;
|
|
261
|
+
REACT_APP_ENTERPRISE_ID=${keys.enterpriseId}
|
|
262
|
+
REACT_KEY_APP=${projectName}
|
|
263
|
+
REACT_APP_TESTER_EMAIL=${userEmailArg}
|
|
264
|
+
DANGEROUSLY_DISABLE_HOST_CHECK=true
|
|
265
|
+
WDS_SOCKET_PORT=0
|
|
266
|
+
`;
|
|
242
267
|
|
|
243
268
|
fs.writeFileSync(path.join(projectDir, '.env'), envContent, 'utf8');
|
|
244
|
-
|
|
269
|
+
// On s'assure que le dossier scripts existe (normalement oui via le tar.gz, mais sécurité d'abord)
|
|
270
|
+
const scriptsDir = path.join(projectDir, 'scripts');
|
|
271
|
+
if (!fs.existsSync(scriptsDir)) {
|
|
272
|
+
fs.mkdirSync(scriptsDir, { recursive: true });
|
|
273
|
+
}
|
|
274
|
+
fs.writeFileSync(path.join(scriptsDir, 'cli.js'), CLI_SCRIPT_CONTENT, 'utf8');
|
|
275
|
+
// On rend le script exécutable (Optionnel mais propre sur Mac/Linux)
|
|
276
|
+
try { fs.chmodSync(path.join(scriptsDir, 'cli.js'), '755'); } catch (e) {}
|
|
245
277
|
|
|
246
278
|
console.log(' [5/6] 📚 Installing dependencies...');
|
|
247
279
|
execSync('npm install', { stdio: 'inherit' });
|
|
@@ -253,7 +285,7 @@ WDS_SOCKET_PORT=0
|
|
|
253
285
|
const packageJsonPath = path.join(projectDir, 'package.json');
|
|
254
286
|
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
255
287
|
packageJson.name = projectName;
|
|
256
|
-
packageJson.scripts = { ...packageJson.scripts, "fleetbo": "node cli.js", "dev": "node cli.js" };
|
|
288
|
+
packageJson.scripts = { ...packageJson.scripts, "fleetbo": "node scripts/cli.js", "dev": "node scripts/cli.js" };
|
|
257
289
|
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), 'utf8');
|
|
258
290
|
|
|
259
291
|
console.log('\n [Fleetbo] ✅ Project successfully created!');
|