create-fleetbo-project 1.2.82 → 1.2.83
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 +24 -18
- package/package.json +1 -1
|
@@ -85,28 +85,36 @@ if (!projectId) {
|
|
|
85
85
|
console.error('\\n Error: Project ID missing in .env.\\n');
|
|
86
86
|
process.exit(1);
|
|
87
87
|
}
|
|
88
|
-
const injectRouteIntoAppJs = (
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
const injectRouteIntoAppJs = (moduleName, subPath = '') => {
|
|
89
|
+
const appJsPath = path.join(process.cwd(), 'src', 'App.js');
|
|
90
|
+
if (!fs.existsSync(appJsPath)) {
|
|
91
|
+
console.error(\` \\x1b[31m[Safety Stop]\\x1b[0m App.js missing.\`);
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
let content = fs.readFileSync(appJsPath, 'utf8');
|
|
91
95
|
const importAnchor = '// FLEETBO_MORE_IMPORTS';
|
|
92
|
-
const
|
|
93
|
-
if (!content.includes(
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
const
|
|
98
|
-
|
|
96
|
+
const routeAnchor = '{/* FLEETBO_DYNAMIC ROUTES */}';
|
|
97
|
+
if (!content.includes(importAnchor) || !content.includes(routeAnchor)) {
|
|
98
|
+
console.log(\` \\x1b[33m[Skipped]\\x1b[0m Anchors missing in App.js.\`);
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
const cleanSubPath = subPath ? \`\${subPath}/\` : '';
|
|
102
|
+
const importLine = \`import \${moduleName} from './app/\${cleanSubPath}\${moduleName}';\`;
|
|
103
|
+
const routeLine = \`<Route path="/\${cleanSubPath}\${moduleName.toLowerCase()}" element={<\${moduleName} />} />\`;
|
|
104
|
+
let modified = false;
|
|
99
105
|
if (!content.includes(importLine)) {
|
|
100
106
|
content = content.replace(importAnchor, \`\${importLine}\\n\${importAnchor}\`);
|
|
101
|
-
|
|
107
|
+
modified = true;
|
|
102
108
|
}
|
|
103
109
|
if (!content.includes(routeLine)) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
110
|
+
content = content.replace(routeAnchor, \`\${routeLine}\\n \${routeAnchor}\`);
|
|
111
|
+
modified = true;
|
|
112
|
+
}
|
|
113
|
+
if (modified) {
|
|
114
|
+
fs.writeFileSync(appJsPath, content);
|
|
115
|
+
console.log(\` \\x1b[32m[Routed]\\x1b[0m \${moduleName} injected into App.js safely.\`);
|
|
107
116
|
}
|
|
108
|
-
|
|
109
|
-
return injected;
|
|
117
|
+
return modified;
|
|
110
118
|
};
|
|
111
119
|
const showEnergyTransfer = async () => {
|
|
112
120
|
const width = 30;
|
|
@@ -282,7 +290,6 @@ if (command === 'android' || command === 'ios') {
|
|
|
282
290
|
}
|
|
283
291
|
const targetUrl = platform === 'android' ? ANDROID_BUILD_URL : IOS_BUILD_URL;
|
|
284
292
|
(async () => {
|
|
285
|
-
// Utilisation de \\n et \\x1b pour que le texte reste intact dans cli.js
|
|
286
293
|
console.log(\`\\n\\x1b[36m⚡ FLEETBO \${platform.toUpperCase()} UPLINK\\x1b[0m\`);
|
|
287
294
|
try {
|
|
288
295
|
execSync('npm run build', { stdio: 'inherit' });
|
|
@@ -328,7 +335,6 @@ function killProcessOnPort(port) {
|
|
|
328
335
|
} catch (e) {}
|
|
329
336
|
}
|
|
330
337
|
const killNetworkService = () => {
|
|
331
|
-
// On tue UNIQUEMENT le processus enfant que nous avons lancé
|
|
332
338
|
if (uplinkProcess) {
|
|
333
339
|
try {
|
|
334
340
|
uplinkProcess.kill('SIGINT'); // On demande poliment de s'arrêter
|