create-fleetbo-project 1.0.23 → 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 +23 -5
- package/package.json +1 -1
|
@@ -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) {
|
|
@@ -100,10 +99,29 @@ async function setupProject() {
|
|
|
100
99
|
|
|
101
100
|
console.log(' [2/5] ✅ Template téléchargé et décompressé.');
|
|
102
101
|
|
|
103
|
-
|
|
104
|
-
|
|
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 ***
|
|
105
123
|
|
|
106
|
-
process.chdir(
|
|
124
|
+
process.chdir(projectDir);
|
|
107
125
|
console.log(' [3/5] 🔑 Récupération des clés de projet...');
|
|
108
126
|
const keys = await fetchProjectKeys(bootstrapToken);
|
|
109
127
|
if (!keys.enterpriseId || !keys.fleetboDBKey) {
|