create-fleetbo-project 1.2.104 → 1.2.105
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 +37 -48
- package/package.json +1 -1
|
@@ -28,35 +28,15 @@ if (!projectNameArg || !bootstrapTokenArg || !userEmailArg) {
|
|
|
28
28
|
// 🌐 RÉSOLUTION UNIFIÉE DEPUIS NPM
|
|
29
29
|
// React : my-fleetbo-react | Vue : my-fleetbo-vue
|
|
30
30
|
// NPM = CDN industriel, SemVer, zéro rate limit GitHub
|
|
31
|
-
// 🌐 RÉSOLUTION UNIFIÉE DEPUIS NPM (Via API HTTP directe, sans execSync)
|
|
32
31
|
const getArchiveUrl = () => {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (res.statusCode === 200) {
|
|
42
|
-
try {
|
|
43
|
-
const json = JSON.parse(data);
|
|
44
|
-
if (json.dist && json.dist.tarball) {
|
|
45
|
-
resolve(json.dist.tarball);
|
|
46
|
-
} else {
|
|
47
|
-
reject(new Error('Tarball URL not found.'));
|
|
48
|
-
}
|
|
49
|
-
} catch (e) {
|
|
50
|
-
reject(new Error('Invalid JSON from NPM registry.'));
|
|
51
|
-
}
|
|
52
|
-
} else {
|
|
53
|
-
reject(new Error(`NPM registry returned status ${res.statusCode}`));
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
}).on('error', (err) => {
|
|
57
|
-
reject(new Error(`Network error when contacting NPM: ${err.message}`));
|
|
58
|
-
});
|
|
59
|
-
});
|
|
32
|
+
const templatePackage = jsFramework === 'vue' ? 'my-fleetbo-vue' : 'my-fleetbo-react';
|
|
33
|
+
try {
|
|
34
|
+
const tarball = execSync(`npm view ${templatePackage} dist.tarball`, { stdio: ['pipe', 'pipe', 'ignore'] }).toString().trim();
|
|
35
|
+
if (!tarball) throw new Error('Empty response');
|
|
36
|
+
return Promise.resolve(tarball);
|
|
37
|
+
} catch (e) {
|
|
38
|
+
return Promise.reject(new Error(`Could not locate "${templatePackage}" on npm. Is it published?`));
|
|
39
|
+
}
|
|
60
40
|
};
|
|
61
41
|
|
|
62
42
|
const projectName = projectNameArg;
|
|
@@ -131,12 +111,7 @@ function downloadEngine(url, dest) {
|
|
|
131
111
|
}
|
|
132
112
|
|
|
133
113
|
async function setupProject() {
|
|
134
|
-
|
|
135
|
-
const logStep = (text) => {
|
|
136
|
-
process.stdout.write(text + '\n');
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
logStep(`\n ⚡ Initializing Fleetbo Frontend for "${projectName}"...`);
|
|
114
|
+
console.log(`\n ⚡ Initializing Fleetbo Frontend for "${projectName}"...`);
|
|
140
115
|
|
|
141
116
|
try {
|
|
142
117
|
if (fs.existsSync(projectDir)) {
|
|
@@ -145,13 +120,12 @@ async function setupProject() {
|
|
|
145
120
|
fs.mkdirSync(projectDir);
|
|
146
121
|
|
|
147
122
|
const frameworkLabel = jsFramework === 'vue' ? 'Vue' : 'React';
|
|
148
|
-
|
|
149
|
-
logStep(` [1/8] Downloading Fleetbo ${frameworkLabel} Engine...`);
|
|
123
|
+
console.log(` [1/8] Downloading Fleetbo ${frameworkLabel} Engine...`);
|
|
150
124
|
const archiveUrl = await getArchiveUrl();
|
|
151
125
|
const archivePath = path.join(projectDir, 'engine.tar.gz');
|
|
152
126
|
await downloadEngine(archiveUrl, archivePath);
|
|
153
127
|
|
|
154
|
-
|
|
128
|
+
console.log(' [2/8] Scaffolding project structure...');
|
|
155
129
|
try {
|
|
156
130
|
execSync(`tar -xf "${archivePath}" -C "${projectDir}" --strip-components=1`, { stdio: 'ignore' });
|
|
157
131
|
fs.unlinkSync(archivePath);
|
|
@@ -161,7 +135,7 @@ async function setupProject() {
|
|
|
161
135
|
|
|
162
136
|
process.chdir(projectDir);
|
|
163
137
|
|
|
164
|
-
|
|
138
|
+
console.log(' [3/8] Standardizing Architecture (Vite)...');
|
|
165
139
|
// Pour Vite, on s'assure juste que l'arborescence de base est correcte.
|
|
166
140
|
// On retire les vieux renommages CRA (App.js) pour éviter de casser App.jsx
|
|
167
141
|
const oldPath = path.join(projectDir, 'src/pages');
|
|
@@ -170,28 +144,43 @@ async function setupProject() {
|
|
|
170
144
|
try { fs.renameSync(oldPath, newPath); } catch (err) {}
|
|
171
145
|
}
|
|
172
146
|
|
|
173
|
-
|
|
147
|
+
console.log(' [4/8] Authenticating with Fleetbo Cloud...');
|
|
174
148
|
const keys = await fetchProjectKeys(bootstrapTokenArg);
|
|
175
149
|
if (!keys.enterpriseId) throw new Error("Invalid keys.");
|
|
176
150
|
|
|
177
|
-
|
|
178
|
-
const envContent = `VITE_FLEETBO_DB_KEY=${keys.fleetboDBKey}
|
|
151
|
+
console.log(' [5/8] Configuring environment...');
|
|
152
|
+
const envContent = `VITE_FLEETBO_DB_KEY=${keys.fleetboDBKey}
|
|
153
|
+
VITE_FLEETBO_ENTERPRISE_ID=${keys.enterpriseId}
|
|
154
|
+
VITE_FLEETBO_KEY_APP=${projectName}
|
|
155
|
+
VITE_FLEETBO_TESTER_EMAIL=${userEmailArg}
|
|
156
|
+
DANGEROUSLY_DISABLE_HOST_CHECK=true
|
|
157
|
+
WDS_SOCKET_PORT=0`;
|
|
179
158
|
|
|
180
159
|
fs.writeFileSync(path.join(projectDir, '.env'), envContent, 'utf8');
|
|
181
160
|
|
|
182
|
-
|
|
183
|
-
const gitignoreContent = `# Fleetbo Security
|
|
161
|
+
console.log(' [6/8] Securing environment (adding .gitignore)...');
|
|
162
|
+
const gitignoreContent = `# Fleetbo Security
|
|
163
|
+
.env
|
|
164
|
+
.env.local
|
|
165
|
+
node_modules/
|
|
166
|
+
dist/
|
|
167
|
+
build/
|
|
168
|
+
.DS_Store
|
|
169
|
+
npm-debug.log*
|
|
170
|
+
yarn-debug.log*
|
|
171
|
+
yarn-error.log*
|
|
172
|
+
`;
|
|
184
173
|
fs.writeFileSync(path.join(projectDir, '.gitignore'), gitignoreContent, 'utf8');
|
|
185
174
|
|
|
186
175
|
const npmrcContent = `loglevel=silent\nupdate-notifier=false\n`;
|
|
187
176
|
fs.writeFileSync(path.join(projectDir, '.npmrc'), npmrcContent, 'utf8');
|
|
188
177
|
|
|
189
|
-
|
|
178
|
+
console.log(' [7/8] Installing dependencies...');
|
|
190
179
|
execSync('npm install --no-audit --no-fund --silent', { stdio: 'inherit' });
|
|
191
180
|
|
|
192
181
|
execSync('npm install cloudflared --save-dev --no-audit --no-fund --silent', { stdio: 'ignore' });
|
|
193
182
|
|
|
194
|
-
|
|
183
|
+
console.log(' [8/8] Finalizing setup...');
|
|
195
184
|
|
|
196
185
|
// --- 1. CRÉATION DU DOSSIER CACHÉ ET DU SCRIPT RELAI ---
|
|
197
186
|
const fleetboDir = path.join(projectDir, '.fleetbo');
|
|
@@ -211,7 +200,7 @@ const result = spawnSync('npx', ['-y', 'fleetbo-cockpit-cli@latest', ...args], {
|
|
|
211
200
|
|
|
212
201
|
process.exit(result.status || 0);
|
|
213
202
|
`;
|
|
214
|
-
//
|
|
203
|
+
// 🟢 FIX : On utilise l'extension .cjs pour forcer le CommonJS
|
|
215
204
|
fs.writeFileSync(path.join(fleetboDir, 'engine.cjs'), engineScript, 'utf8');
|
|
216
205
|
|
|
217
206
|
// --- 2. MODIFICATION DU PACKAGE.JSON POUR MASQUER L'ARCHITECTURE ---
|
|
@@ -219,7 +208,7 @@ process.exit(result.status || 0);
|
|
|
219
208
|
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
220
209
|
packageJson.name = projectName;
|
|
221
210
|
|
|
222
|
-
// On appelle engine.cjs dans les scripts
|
|
211
|
+
// 🟢 FIX : On appelle engine.cjs dans les scripts
|
|
223
212
|
packageJson.scripts = {
|
|
224
213
|
"dev": "vite",
|
|
225
214
|
"build": "vite build",
|
|
@@ -244,7 +233,7 @@ process.exit(result.status || 0);
|
|
|
244
233
|
}
|
|
245
234
|
|
|
246
235
|
// ==========================================
|
|
247
|
-
//
|
|
236
|
+
// 🎯 L'ANNONCE DE SUCCÈS ET LE MINI-TUTO
|
|
248
237
|
// ==========================================
|
|
249
238
|
console.log('\n \x1b[1;32m✓ [Fleetbo] Project successfully created!\x1b[0m');
|
|
250
239
|
console.log(`\n Installation path: \x1b[36m${projectDir}\x1b[0m\n`);
|