create-fleetbo-project 1.0.22 → 1.0.24
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 +27 -13
- package/package.json +1 -1
|
@@ -7,11 +7,11 @@ const https = require('https');
|
|
|
7
7
|
const unzipper = require('unzipper');
|
|
8
8
|
|
|
9
9
|
// --- Configuration ---
|
|
10
|
-
// !!! VÉRIFIEZ ET CORRIGEZ CES DEUX LIGNES !!!
|
|
11
10
|
const repoOwner = 'FleetFleetbo'; // Assurez-vous que c'est le bon nom d'utilisateur GitHub
|
|
12
11
|
const repoName = 'dev.fleetbo.io'; // Assurez-vous que c'est le bon nom de dépôt
|
|
12
|
+
const branchName = 'master'; // Le nom de la branche est maintenant configurable
|
|
13
13
|
|
|
14
|
-
const repoUrl = `https://github.com/${repoOwner}/${repoName}/archive/refs/heads
|
|
14
|
+
const repoUrl = `https://github.com/${repoOwner}/${repoName}/archive/refs/heads/${branchName}.zip`;
|
|
15
15
|
|
|
16
16
|
// URL de votre Cloud Function.
|
|
17
17
|
const bootstrapUrl = 'https://us-central1-myapp-259bf.cloudfunctions.net/bootstrapProject';
|
|
@@ -63,7 +63,7 @@ function fetchProjectKeys(token) {
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
/**
|
|
66
|
-
* Fonction Principale Asynchrone (Version avec
|
|
66
|
+
* Fonction Principale Asynchrone (Version avec gestion des sous-dossiers)
|
|
67
67
|
*/
|
|
68
68
|
async function setupProject() {
|
|
69
69
|
console.log(`\nCréation de votre projet Fleetbo "${projectName}"...`);
|
|
@@ -74,7 +74,6 @@ async function setupProject() {
|
|
|
74
74
|
https.get(repoUrl, (response) => {
|
|
75
75
|
if (response.statusCode === 301 || response.statusCode === 302) {
|
|
76
76
|
const redirectUrl = response.headers.location;
|
|
77
|
-
// Log de l'URL pour faciliter le débogage
|
|
78
77
|
console.log(` -> Redirection détectée, suivi du lien : ${redirectUrl}`);
|
|
79
78
|
https.get(redirectUrl, (redirectResponse) => {
|
|
80
79
|
if (redirectResponse.statusCode !== 200) {
|
|
@@ -97,18 +96,32 @@ async function setupProject() {
|
|
|
97
96
|
|
|
98
97
|
}).on('error', (err) => reject(new Error(`Erreur réseau lors du téléchargement: ${err.message}`)));
|
|
99
98
|
});
|
|
100
|
-
|
|
101
|
-
// La suite du script a été omise pour la brièveté mais reste identique...
|
|
102
|
-
// ...
|
|
103
|
-
// Le renommage et le reste de la logique doit être ici
|
|
104
|
-
// ...
|
|
105
99
|
|
|
106
100
|
console.log(' [2/5] ✅ Template téléchargé et décompressé.');
|
|
107
101
|
|
|
108
|
-
|
|
109
|
-
|
|
102
|
+
const tempDir = `${repoName}-${branchName}`;
|
|
103
|
+
const projectDir = path.join(process.cwd(), projectName);
|
|
104
|
+
fs.renameSync(tempDir, projectDir);
|
|
105
|
+
|
|
106
|
+
// *** DÉBUT DE LA CORRECTION POUR GÉRER LES PROJETS IMBRIQUÉS ***
|
|
107
|
+
const files = fs.readdirSync(projectDir);
|
|
108
|
+
const significantContent = files.filter(f => !f.startsWith('.'));
|
|
109
|
+
|
|
110
|
+
if (significantContent.length === 1 && fs.statSync(path.join(projectDir, significantContent[0])).isDirectory()) {
|
|
111
|
+
const nestedProjectDir = path.join(projectDir, significantContent[0]);
|
|
112
|
+
console.log(` -> Structure imbriquée détectée. Déplacement du contenu de "${significantContent[0]}"...`);
|
|
113
|
+
|
|
114
|
+
const nestedDirContents = fs.readdirSync(nestedProjectDir);
|
|
115
|
+
for (const item of nestedDirContents) {
|
|
116
|
+
fs.renameSync(path.join(nestedProjectDir, item), path.join(projectDir, item));
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
fs.rmdirSync(nestedProjectDir);
|
|
120
|
+
console.log(' -> Déplacement terminé.');
|
|
121
|
+
}
|
|
122
|
+
// *** FIN DE LA CORRECTION ***
|
|
110
123
|
|
|
111
|
-
process.chdir(
|
|
124
|
+
process.chdir(projectDir);
|
|
112
125
|
console.log(' [3/5] 🔑 Récupération des clés de projet...');
|
|
113
126
|
const keys = await fetchProjectKeys(bootstrapToken);
|
|
114
127
|
if (!keys.enterpriseId || !keys.fleetboDBKey) {
|
|
@@ -139,7 +152,7 @@ async function setupProject() {
|
|
|
139
152
|
console.log(' Nettoyage du répertoire du projet...');
|
|
140
153
|
fs.rmSync(dirToDelete, { recursive: true, force: true });
|
|
141
154
|
}
|
|
142
|
-
const extractedDir = path.join(process.cwd(), `${repoName}
|
|
155
|
+
const extractedDir = path.join(process.cwd(), `${repoName}-${branchName}`);
|
|
143
156
|
if (fs.existsSync(extractedDir)) {
|
|
144
157
|
console.log(' Nettoyage du répertoire temporaire...');
|
|
145
158
|
fs.rmSync(extractedDir, { recursive: true, force: true });
|
|
@@ -149,3 +162,4 @@ async function setupProject() {
|
|
|
149
162
|
}
|
|
150
163
|
|
|
151
164
|
setupProject();
|
|
165
|
+
|