create-fleetbo-project 1.2.96 → 1.2.97
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 +47 -84
- package/package.json +2 -2
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
// 🥷 SILENCIEUX ABSOLU : S'exécute instantanément pour tuer la plomberie de NPX
|
|
4
3
|
process.stdout.write("\x1b[1A\x1b[2K".repeat(4));
|
|
5
4
|
console.clear();
|
|
6
5
|
|
|
@@ -9,55 +8,61 @@ const fs = require('fs');
|
|
|
9
8
|
const path = require('path');
|
|
10
9
|
const https = require('https');
|
|
11
10
|
|
|
12
|
-
const repoOwner = 'FleetFleetbo';
|
|
13
|
-
const repoName = 'dev.fleetbo.io';
|
|
14
|
-
const branchName = 'master';
|
|
15
|
-
const archiveUrl = `https://github.com/${repoOwner}/${repoName}/archive/refs/heads/${branchName}.tar.gz`;
|
|
16
11
|
const bootstrapUrl = 'https://us-central1-myapp-259bf.cloudfunctions.net/bootstrapProject';
|
|
17
12
|
|
|
18
13
|
const args = process.argv.slice(2);
|
|
19
14
|
const projectNameArg = args.find(arg => !arg.startsWith('--'));
|
|
20
15
|
const tokenArg = args.find(arg => arg.startsWith('--token='));
|
|
21
16
|
const emailArg = args.find(arg => arg.startsWith('--email='));
|
|
17
|
+
const frameworkArg = args.find(arg => arg.startsWith('--framework='));
|
|
18
|
+
|
|
22
19
|
const bootstrapTokenArg = tokenArg ? tokenArg.split('=')[1] : null;
|
|
23
20
|
const userEmailArg = emailArg ? emailArg.split('=')[1] : null;
|
|
21
|
+
const framework = frameworkArg ? frameworkArg.split('=')[1].toLowerCase() : 'react';
|
|
24
22
|
|
|
25
23
|
if (!projectNameArg || !bootstrapTokenArg || !userEmailArg) {
|
|
26
|
-
console.error('\n Usage: npx create-fleetbo-project <name> --token=<token> --email=<email>');
|
|
24
|
+
console.error('\n Usage: npx create-fleetbo-project <name> --token=<token> --email=<email> [--framework=react|vue]');
|
|
27
25
|
process.exit(1);
|
|
28
26
|
}
|
|
29
27
|
|
|
30
28
|
const projectName = projectNameArg;
|
|
31
29
|
const projectDir = path.join(process.cwd(), projectName);
|
|
32
30
|
|
|
31
|
+
// 🌐 SÉLECTION DYNAMIQUE DE LA SOURCE
|
|
32
|
+
let archiveUrl;
|
|
33
|
+
if (framework === 'vue') {
|
|
34
|
+
console.log(`\n 🔍 Resolving latest Vue template from npm registry...`);
|
|
35
|
+
try {
|
|
36
|
+
archiveUrl = execSync('npm view my-fleetbo-vue dist.tarball', { stdio: ['pipe', 'pipe', 'ignore'] }).toString().trim();
|
|
37
|
+
} catch (e) {
|
|
38
|
+
console.error('\n ❌ Error: Could not locate "my-fleetbo-vue" on npm.');
|
|
39
|
+
process.exit(1);
|
|
40
|
+
}
|
|
41
|
+
} else {
|
|
42
|
+
const repoOwner = 'FleetFleetbo';
|
|
43
|
+
const repoName = 'dev.fleetbo.io';
|
|
44
|
+
const branchName = 'master';
|
|
45
|
+
archiveUrl = `https://github.com/${repoOwner}/${repoName}/archive/refs/heads/${branchName}.tar.gz`;
|
|
46
|
+
}
|
|
47
|
+
|
|
33
48
|
function fetchProjectKeys(token) {
|
|
34
49
|
return new Promise((resolve, reject) => {
|
|
35
50
|
const postData = JSON.stringify({ token });
|
|
36
51
|
const uri = new URL(bootstrapUrl);
|
|
37
52
|
const options = {
|
|
38
|
-
hostname: uri.hostname,
|
|
39
|
-
|
|
40
|
-
method: 'POST',
|
|
41
|
-
headers: {
|
|
42
|
-
'Content-Type': 'application/json',
|
|
43
|
-
'Content-Length': Buffer.byteLength(postData)
|
|
44
|
-
}
|
|
53
|
+
hostname: uri.hostname, path: uri.pathname, method: 'POST',
|
|
54
|
+
headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(postData) }
|
|
45
55
|
};
|
|
46
56
|
const req = https.request(options, (res) => {
|
|
47
57
|
let data = '';
|
|
48
58
|
res.on('data', (chunk) => { data += chunk; });
|
|
49
59
|
res.on('end', () => {
|
|
50
60
|
if (res.statusCode >= 200 && res.statusCode < 300) {
|
|
51
|
-
try { resolve(JSON.parse(data)); }
|
|
52
|
-
|
|
53
|
-
} else {
|
|
54
|
-
reject(new Error(`Server error ${res.statusCode}`));
|
|
55
|
-
}
|
|
61
|
+
try { resolve(JSON.parse(data)); } catch (e) { reject(new Error('Invalid response')); }
|
|
62
|
+
} else { reject(new Error(`Server error ${res.statusCode}`)); }
|
|
56
63
|
});
|
|
57
64
|
});
|
|
58
|
-
req.on('error', (e) => reject(e));
|
|
59
|
-
req.write(postData);
|
|
60
|
-
req.end();
|
|
65
|
+
req.on('error', (e) => reject(e)); req.write(postData); req.end();
|
|
61
66
|
});
|
|
62
67
|
}
|
|
63
68
|
|
|
@@ -65,46 +70,30 @@ function downloadEngine(url, dest) {
|
|
|
65
70
|
return new Promise((resolve, reject) => {
|
|
66
71
|
const uri = new URL(url);
|
|
67
72
|
const options = {
|
|
68
|
-
hostname: uri.hostname,
|
|
69
|
-
|
|
70
|
-
method: 'GET',
|
|
71
|
-
headers: {
|
|
72
|
-
'User-Agent': 'Fleetbo-CLI-Installer',
|
|
73
|
-
'Accept': '*/*'
|
|
74
|
-
}
|
|
73
|
+
hostname: uri.hostname, path: uri.pathname + uri.search, method: 'GET',
|
|
74
|
+
headers: { 'User-Agent': 'Fleetbo-CLI-Installer', 'Accept': '*/*' }
|
|
75
75
|
};
|
|
76
76
|
const request = https.get(options, (response) => {
|
|
77
77
|
if (response.statusCode === 301 || response.statusCode === 302) {
|
|
78
|
-
if (!response.headers.location) {
|
|
79
|
-
reject(new Error("Redirect error"));
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
78
|
+
if (!response.headers.location) { reject(new Error("Redirect error")); return; }
|
|
82
79
|
downloadEngine(response.headers.location, dest).then(resolve).catch(reject);
|
|
83
80
|
return;
|
|
84
81
|
}
|
|
85
|
-
if (response.statusCode !== 200) {
|
|
86
|
-
reject(new Error(`Status: ${response.statusCode}`));
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
82
|
+
if (response.statusCode !== 200) { reject(new Error(`Status: ${response.statusCode}`)); return; }
|
|
89
83
|
const file = fs.createWriteStream(dest);
|
|
90
84
|
response.pipe(file);
|
|
91
85
|
file.on('finish', () => file.close(resolve));
|
|
92
|
-
file.on('error', (err) => {
|
|
93
|
-
fs.unlink(dest, () => {});
|
|
94
|
-
reject(err);
|
|
95
|
-
});
|
|
86
|
+
file.on('error', (err) => { fs.unlink(dest, () => {}); reject(err); });
|
|
96
87
|
});
|
|
97
88
|
request.on('error', (err) => reject(err));
|
|
98
89
|
});
|
|
99
90
|
}
|
|
100
91
|
|
|
101
92
|
async function setupProject() {
|
|
102
|
-
console.log(`\n ⚡ Initializing Fleetbo Framework for "${projectName}"...`);
|
|
93
|
+
console.log(`\n ⚡ Initializing Fleetbo Framework (\x1b[36m${framework.toUpperCase()}\x1b[0m) for "${projectName}"...`);
|
|
103
94
|
|
|
104
95
|
try {
|
|
105
|
-
if (fs.existsSync(projectDir)) {
|
|
106
|
-
throw new Error(`Directory "${projectName}" already exists.`);
|
|
107
|
-
}
|
|
96
|
+
if (fs.existsSync(projectDir)) { throw new Error(`Directory "${projectName}" already exists.`); }
|
|
108
97
|
fs.mkdirSync(projectDir);
|
|
109
98
|
|
|
110
99
|
console.log(' [1/8] Downloading Fleetbo Core Engine...');
|
|
@@ -115,19 +104,17 @@ async function setupProject() {
|
|
|
115
104
|
try {
|
|
116
105
|
execSync(`tar -xf "${archivePath}" -C "${projectDir}" --strip-components=1`, { stdio: 'ignore' });
|
|
117
106
|
fs.unlinkSync(archivePath);
|
|
118
|
-
} catch (e) {
|
|
119
|
-
throw new Error("Extract failed.");
|
|
120
|
-
}
|
|
107
|
+
} catch (e) { throw new Error("Extract failed."); }
|
|
121
108
|
|
|
122
109
|
process.chdir(projectDir);
|
|
123
110
|
|
|
124
|
-
console.log(' [3/8] Standardizing Architecture
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
111
|
+
console.log(' [3/8] Standardizing Architecture...');
|
|
112
|
+
if (framework === 'react') {
|
|
113
|
+
const oldPath = path.join(projectDir, 'src/pages');
|
|
114
|
+
const newPath = path.join(projectDir, 'src/app');
|
|
115
|
+
if (fs.existsSync(oldPath) && !fs.existsSync(newPath)) {
|
|
116
|
+
try { fs.renameSync(oldPath, newPath); } catch (err) {}
|
|
117
|
+
}
|
|
131
118
|
}
|
|
132
119
|
|
|
133
120
|
console.log(' [4/8] Authenticating with Fleetbo Cloud...');
|
|
@@ -145,17 +132,7 @@ WDS_SOCKET_PORT=0`;
|
|
|
145
132
|
fs.writeFileSync(path.join(projectDir, '.env'), envContent, 'utf8');
|
|
146
133
|
|
|
147
134
|
console.log(' [6/8] Securing environment (adding .gitignore)...');
|
|
148
|
-
const gitignoreContent = `# Fleetbo Security
|
|
149
|
-
.env
|
|
150
|
-
.env.local
|
|
151
|
-
node_modules/
|
|
152
|
-
dist/
|
|
153
|
-
build/
|
|
154
|
-
.DS_Store
|
|
155
|
-
npm-debug.log*
|
|
156
|
-
yarn-debug.log*
|
|
157
|
-
yarn-error.log*
|
|
158
|
-
`;
|
|
135
|
+
const gitignoreContent = `# Fleetbo Security\n.env\n.env.local\nnode_modules/\ndist/\nbuild/\n.DS_Store\nnpm-debug.log*\nyarn-debug.log*\nyarn-error.log*\n`;
|
|
159
136
|
fs.writeFileSync(path.join(projectDir, '.gitignore'), gitignoreContent, 'utf8');
|
|
160
137
|
|
|
161
138
|
const npmrcContent = `loglevel=silent\nupdate-notifier=false\n`;
|
|
@@ -163,7 +140,6 @@ yarn-error.log*
|
|
|
163
140
|
|
|
164
141
|
console.log(' [7/8] Installing dependencies...');
|
|
165
142
|
execSync('npm install --no-audit --no-fund --silent', { stdio: 'inherit' });
|
|
166
|
-
|
|
167
143
|
execSync('npm install cloudflared --save-dev --no-audit --no-fund --silent', { stdio: 'ignore' });
|
|
168
144
|
|
|
169
145
|
console.log(' [8/8] Finalizing setup...');
|
|
@@ -171,7 +147,6 @@ yarn-error.log*
|
|
|
171
147
|
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
172
148
|
packageJson.name = projectName;
|
|
173
149
|
|
|
174
|
-
// Configuration pour utiliser le package NPM centralisé
|
|
175
150
|
packageJson.scripts = {
|
|
176
151
|
...packageJson.scripts,
|
|
177
152
|
"fleetbo": "npx -y fleetbo-cockpit-cli@latest",
|
|
@@ -183,35 +158,23 @@ yarn-error.log*
|
|
|
183
158
|
|
|
184
159
|
const scriptsDir = path.join(projectDir, 'scripts');
|
|
185
160
|
if (fs.existsSync(scriptsDir)) {
|
|
186
|
-
try {
|
|
187
|
-
fs.rmSync(scriptsDir, { recursive: true, force: true });
|
|
188
|
-
} catch (e) {
|
|
189
|
-
// Ignore si ça échoue
|
|
190
|
-
}
|
|
161
|
+
try { fs.rmSync(scriptsDir, { recursive: true, force: true }); } catch (e) {}
|
|
191
162
|
}
|
|
192
163
|
|
|
193
|
-
// ==========================================
|
|
194
|
-
// 🎯 L'ANNONCE DE SUCCÈS ET LE MINI-TUTO
|
|
195
|
-
// ==========================================
|
|
196
164
|
console.log('\n \x1b[1;32m✓ [Fleetbo] Project successfully created!\x1b[0m');
|
|
197
165
|
console.log(`\n Installation path: \x1b[36m${projectDir}\x1b[0m\n`);
|
|
198
|
-
|
|
199
166
|
console.log(' \x1b[1;33m🚀 NEXT STEPS (Mini-Tutorial):\x1b[0m');
|
|
200
167
|
console.log(' --------------------------------------------------');
|
|
201
|
-
console.log(` 1️
|
|
202
|
-
console.log(' 2️
|
|
203
|
-
console.log(' 3️
|
|
168
|
+
console.log(` 1️ Navigate to your project : \x1b[36mcd ${projectName}\x1b[0m`);
|
|
169
|
+
console.log(' 2️ Launch the Fleetbo Engine : \x1b[36mnpm run fleetbo\x1b[0m');
|
|
170
|
+
console.log(' 3️ Summon Alex (AI Architect): \x1b[36mnpm run fleetbo alex\x1b[0m');
|
|
204
171
|
console.log(' --------------------------------------------------');
|
|
205
172
|
console.log('\n \x1b[2mHappy coding! Build something amazing without limits.\x1b[0m\n');
|
|
206
|
-
|
|
207
|
-
console.log('');
|
|
208
173
|
|
|
209
174
|
} catch (error) {
|
|
210
175
|
console.error('\n Setup failed:', error.message);
|
|
211
176
|
if (fs.existsSync(projectDir)) {
|
|
212
|
-
try {
|
|
213
|
-
fs.rmSync(projectDir, { recursive: true, force: true });
|
|
214
|
-
} catch(e) {}
|
|
177
|
+
try { fs.rmSync(projectDir, { recursive: true, force: true }); } catch(e) {}
|
|
215
178
|
}
|
|
216
179
|
process.exit(1);
|
|
217
180
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-fleetbo-project",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.97",
|
|
4
4
|
"description": "Creates a new Fleetbo project.",
|
|
5
5
|
"main": "install-react-template.js",
|
|
6
6
|
"bin": {
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"fullstack",
|
|
23
23
|
"OS",
|
|
24
24
|
"Cloud",
|
|
25
|
-
"
|
|
25
|
+
"Mobile"
|
|
26
26
|
],
|
|
27
27
|
"author": "Jean Aubain NOUCTI",
|
|
28
28
|
"license": "ISC"
|