create-fleetbo-project 1.0.3 → 1.0.4
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 +58 -34
- package/package.json +11 -8
|
@@ -1,43 +1,67 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
// Fichier : install-react-template.js (Version améliorée)
|
|
2
3
|
|
|
3
4
|
const { execSync } = require('child_process');
|
|
4
|
-
const fs
|
|
5
|
-
const path
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
// Générer le contenu du fichier .env
|
|
10
|
-
const envContent = `REACT_APP_PROJECT_NAME="${packageInfo.name}"\n`;
|
|
11
|
-
|
|
12
|
-
// Écrire dans le fichier .env
|
|
13
|
-
fs.writeFileSync('.env', envContent, 'utf8');
|
|
14
|
-
console.log('.env file has been updated with project name!');
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const path = require('path');
|
|
7
|
+
const https = require('https');
|
|
8
|
+
const unzipper = require('unzipper'); // Une librairie pour décompresser les archives
|
|
15
9
|
|
|
10
|
+
// --- Configuration ---
|
|
11
|
+
const projectName = process.argv[2];
|
|
12
|
+
const repoOwner = 'FleetFleetbo';
|
|
13
|
+
const repoName = 'dev.fleetbo.io';
|
|
14
|
+
const repoUrl = `https://github.com/${repoOwner}/${repoName}/archive/refs/heads/main.zip`;
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
// --- Validation de l'entrée ---
|
|
17
|
+
if (!projectName) {
|
|
18
|
+
console.error('Erreur : Veuillez spécifier un nom pour votre projet.');
|
|
19
|
+
console.log('Usage: npx create-fleetbo-project <nom-du-projet>');
|
|
19
20
|
process.exit(1);
|
|
20
21
|
}
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
23
|
+
// --- Fonction Principale Asynchrone ---
|
|
24
|
+
async function setupProject() {
|
|
25
|
+
console.log(`Création de votre projet Fleetbo "${projectName}"...`);
|
|
26
|
+
|
|
27
|
+
try {
|
|
28
|
+
// 1. Télécharger le template depuis GitHub
|
|
29
|
+
console.log('Téléchargement du template...');
|
|
30
|
+
const response = await new Promise((resolve, reject) => {
|
|
31
|
+
https.get(repoUrl, res => resolve(res)).on('error', err => reject(err));
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
// 2. Décompresser l'archive dans le dossier du projet
|
|
35
|
+
// Le contenu du zip est dans un sous-dossier (ex: dev.fleetbo.io-main), on le gère avec .pipe()
|
|
36
|
+
await new Promise((resolve, reject) => {
|
|
37
|
+
response.pipe(unzipper.Extract({ path: '.' }))
|
|
38
|
+
.on('finish', resolve)
|
|
39
|
+
.on('error', reject);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// Le dossier décompressé aura un nom comme "repoName-main", on le renomme
|
|
43
|
+
fs.renameSync(`${repoName}-main`, projectName);
|
|
44
|
+
|
|
45
|
+
// 3. Se déplacer dans le nouveau dossier et installer les dépendances
|
|
46
|
+
process.chdir(projectName);
|
|
47
|
+
console.log('Installation des dépendances (cela peut prendre quelques minutes)...');
|
|
48
|
+
execSync('npm install', { stdio: 'inherit' });
|
|
49
|
+
|
|
50
|
+
// 4. Mettre à jour le package.json avec le nom du projet
|
|
51
|
+
const packageJsonPath = path.join(process.cwd(), 'package.json');
|
|
52
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
53
|
+
packageJson.name = projectName;
|
|
54
|
+
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), 'utf8');
|
|
55
|
+
|
|
56
|
+
console.log('\n🚀 Votre projet Fleetbo est prêt !');
|
|
57
|
+
console.log(`\nPour commencer, exécutez les commandes suivantes :`);
|
|
58
|
+
console.log(` cd ${projectName}`);
|
|
59
|
+
console.log(` npm start`);
|
|
60
|
+
|
|
61
|
+
} catch (error) {
|
|
62
|
+
console.error('\n❌ Une erreur est survenue lors de la création du projet :', error);
|
|
63
|
+
process.exit(1);
|
|
64
|
+
}
|
|
43
65
|
}
|
|
66
|
+
|
|
67
|
+
setupProject();
|
package/package.json
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-fleetbo-project",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "",
|
|
5
|
-
"scripts": {
|
|
6
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
7
|
-
},
|
|
3
|
+
"version": "1.0.4",
|
|
4
|
+
"description": "Crée une nouvelle application mobile avec le framework Fleetbo.",
|
|
8
5
|
"main": "install-react-template.js",
|
|
9
6
|
"bin": {
|
|
10
7
|
"create-fleetbo-project": "install-react-template.js"
|
|
11
8
|
},
|
|
12
9
|
"dependencies": {
|
|
13
|
-
|
|
10
|
+
"unzipper": "^0.10.14",
|
|
11
|
+
"yargs-parser": "^21.1.1"
|
|
14
12
|
},
|
|
15
|
-
"keywords": [
|
|
16
|
-
|
|
13
|
+
"keywords": [
|
|
14
|
+
"react",
|
|
15
|
+
"mobile",
|
|
16
|
+
"fullstack",
|
|
17
|
+
"fleetbo"
|
|
18
|
+
],
|
|
19
|
+
"author": "Fleetbo",
|
|
17
20
|
"license": "ISC"
|
|
18
21
|
}
|