create-fleetbo-project 1.2.54 → 1.2.57
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 +60 -16
- package/package.json +1 -1
|
@@ -18,7 +18,8 @@ const dotenv = require('dotenv');
|
|
|
18
18
|
const os = require('os');
|
|
19
19
|
const archiver = require('archiver');
|
|
20
20
|
const readline = require('readline');
|
|
21
|
-
const
|
|
21
|
+
const ANDROID_BUILD_URL = "https://us-central1-myapp-259bf.cloudfunctions.net/FandroidBuild";
|
|
22
|
+
const IOS_BUILD_URL = "https://us-central1-myapp-259bf.cloudfunctions.net/FiosBuild";
|
|
22
23
|
const UPDATE_NETWORK_URL = 'https://us-central1-myapp-259bf.cloudfunctions.net/updateDeveloperNetwork';
|
|
23
24
|
const ALEX_ENGINE_URL = "https://us-central1-myapp-259bf.cloudfunctions.net/generateNativeModule";
|
|
24
25
|
const APP_JS_PATH = path.join(process.cwd(), 'src/App.js');
|
|
@@ -63,7 +64,6 @@ const injectRouteIntoAppJs = (pageName, subPath = '') => {
|
|
|
63
64
|
// Chemin dynamique selon si c'est une page ou un mock
|
|
64
65
|
const pathPrefix = subPath ? \`\${subPath}/\` : '';
|
|
65
66
|
const importLine = \`import \${pageName} from './pages/\${pathPrefix}\${pageName}';\`;
|
|
66
|
-
// CORRECTION ICI : Syntax React Router valide element={<PageName />}
|
|
67
67
|
const routeLine = \`<Route path="/\${pathPrefix.toLowerCase()}\${pageName.toLowerCase()}" element={<\${pageName} />} />\`;
|
|
68
68
|
let injected = false;
|
|
69
69
|
if (!content.includes(importLine)) {
|
|
@@ -117,7 +117,6 @@ if (command === 'alex') {
|
|
|
117
117
|
if (aiData.status === 'success' || aiData.status === 'message') {
|
|
118
118
|
console.log('');
|
|
119
119
|
console.log(\`\\x1b[32mAlex ❯\\x1b[0m \${aiData.message || "I'm ready."}\`);
|
|
120
|
-
|
|
121
120
|
if (aiData.remainingTokens !== undefined) {
|
|
122
121
|
const remaining = aiData.remainingTokens;
|
|
123
122
|
const limit = aiData.limit; // Récupération dynamique de la limite
|
|
@@ -127,25 +126,40 @@ if (command === 'alex') {
|
|
|
127
126
|
console.log(\`\\x1b[36m Energy:\\x1b[0m \${energyColor}\${percent}%\\x1b[0m (\${remaining}/\${limit} tokens left)\`);
|
|
128
127
|
}
|
|
129
128
|
}
|
|
130
|
-
|
|
131
129
|
if (aiData.status === 'success' && aiData.moduleData) {
|
|
132
|
-
|
|
133
|
-
|
|
130
|
+
// 1. AJOUT de 'instructions' ici pour éviter l'erreur de variable indéfinie
|
|
131
|
+
const { fileName, code, mockFileName, mockCode, moduleName, instructions } = aiData.moduleData;
|
|
132
|
+
console.log(\` \\x1b[90m⚙️ Architecting: \${moduleName}\x1b[0m\`);
|
|
134
133
|
const writeFile = (dir, name, content) => {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
134
|
+
const fullPath = path.join(process.cwd(), dir);
|
|
135
|
+
const filePath = path.join(fullPath, name);
|
|
136
|
+
if (!fs.existsSync(fullPath)) fs.mkdirSync(fullPath, { recursive: true });
|
|
138
137
|
fs.writeFileSync(filePath, content);
|
|
139
|
-
console.log(\`
|
|
138
|
+
console.log(\` \x1b[32m[Written]\x1b[0m \${dir}\${name}\`);
|
|
140
139
|
};
|
|
140
|
+
if (instructions && Array.isArray(instructions) && instructions.length > 0) {
|
|
141
|
+
console.log('\n\x1b[33m--- GUIDE DE PILOTAGE (MCI) ---\x1b[0m');
|
|
142
|
+
instructions.forEach(line => {
|
|
143
|
+
if (typeof line === 'string') {
|
|
144
|
+
const formattedLine = line.replace(/ACTION|CAPTURE|PERSPECTIVE/g, '\x1b[1m$&\x1b[0m');
|
|
145
|
+
console.log(\` \${formattedLine}\`);
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
console.log('\x1b[33m-------------------------------\x1b[0m');
|
|
149
|
+
}
|
|
141
150
|
if (code && fileName) {
|
|
142
151
|
const folder = fileName.endsWith('.kt') ? 'public/native/android/' : 'src/pages/';
|
|
143
152
|
writeFile(folder, fileName, code);
|
|
144
153
|
if (fileName.endsWith('.jsx')) injectRouteIntoAppJs(fileName.replace('.jsx', ''));
|
|
145
154
|
}
|
|
146
155
|
if (mockCode && mockFileName) {
|
|
156
|
+
const pageName = mockFileName.replace('.jsx', '');
|
|
147
157
|
writeFile('src/pages/mocks/', mockFileName, mockCode);
|
|
148
158
|
writeFile('src/pages/mocks/', 'Quick.jsx', mockCode);
|
|
159
|
+
const injected = injectRouteIntoAppJs(pageName, 'mocks');
|
|
160
|
+
if (injected) {
|
|
161
|
+
console.log(\` \\x1b[32m[Routed]\x1b[0m App.js -> /mocks/\${pageName.toLowerCase()}\`);
|
|
162
|
+
}
|
|
149
163
|
}
|
|
150
164
|
}
|
|
151
165
|
} catch (error) {
|
|
@@ -210,10 +224,30 @@ if (command === 'alex') {
|
|
|
210
224
|
else processAlexRequest(initialPrompt);
|
|
211
225
|
return;
|
|
212
226
|
}
|
|
213
|
-
if (command === '
|
|
227
|
+
if (command === 'android' || command === 'ios') {
|
|
214
228
|
checkGitSecurity();
|
|
229
|
+
const platform = command;
|
|
230
|
+
|
|
231
|
+
// --- NOUVEAU VERROU DE SÉCURITÉ ---
|
|
232
|
+
const nativeDir = platform === 'android' ? 'public/native/android/' : 'public/native/ios/'; //
|
|
233
|
+
const extension = platform === 'android' ? '.kt' : '.swift';
|
|
234
|
+
const fullPath = path.join(process.cwd(), nativeDir);
|
|
235
|
+
let hasNativeFiles = false;
|
|
236
|
+
if (fs.existsSync(fullPath)) {
|
|
237
|
+
const files = fs.readdirSync(fullPath);
|
|
238
|
+
hasNativeFiles = files.some(file => file.endsWith(extension));
|
|
239
|
+
}
|
|
240
|
+
if (!hasNativeFiles) {
|
|
241
|
+
console.log(\`\n\x1b[31m⚠️ ENGINE INCOMPLETE:\x1b[0m No native blueprints detected for \x1b[1m\${platform.toUpperCase()}\x1b[0m.\`);
|
|
242
|
+
console.log(\`\x1b[90mAlex must architect at least one \${extension} module before deployment.\x1b[0m\n\`);
|
|
243
|
+
process.exit(1);
|
|
244
|
+
}
|
|
245
|
+
// ----------------------------------
|
|
246
|
+
|
|
247
|
+
// Sélection automatique de l'URL selon la plateforme saisie après "fleetbo"
|
|
248
|
+
const targetUrl = platform === 'android' ? ANDROID_BUILD_URL : IOS_BUILD_URL;
|
|
215
249
|
(async () => {
|
|
216
|
-
console.log(
|
|
250
|
+
console.log(\`\n\x1b[36m⚡ FLEETBO \${platform.toUpperCase()} UPLINK\x1b[0m\`);
|
|
217
251
|
try {
|
|
218
252
|
execSync('npm run build', { stdio: 'inherit' });
|
|
219
253
|
let buildDir = fs.existsSync(path.join(process.cwd(), 'dist')) ? 'dist' : 'build';
|
|
@@ -224,11 +258,21 @@ if (command === 'deploy') {
|
|
|
224
258
|
archive.directory(path.join(process.cwd(), buildDir), false);
|
|
225
259
|
archive.finalize();
|
|
226
260
|
});
|
|
227
|
-
console.log(
|
|
261
|
+
console.log(\`\n \x1b[33mSyncing \${platform} logic bundle...\x1b[0m\`);
|
|
228
262
|
await showEnergyTransfer();
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
263
|
+
|
|
264
|
+
// Envoi vers la fonction cloud spécifique (FandroidBuild ou FiosBuild)
|
|
265
|
+
const res = await axios.post(targetUrl, zipBuffer, {
|
|
266
|
+
headers: { 'Content-Type': 'application/zip', 'x-project-id': projectId }
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
if (res.data.success) {
|
|
270
|
+
console.log(\`\n \x1b[1m$\{platform.toUpperCase()} DEPLOYED\x1b[0m | \x1b[32mAlex ❯\x1b[0m Runtime updated.\`);
|
|
271
|
+
}
|
|
272
|
+
} catch (error) {
|
|
273
|
+
console.error('\n\x1b[31m Build Error:\x1b[0m ' + (error.response?.data?.error || error.message));
|
|
274
|
+
process.exit(1);
|
|
275
|
+
}
|
|
232
276
|
})();
|
|
233
277
|
return;
|
|
234
278
|
}
|