create-fleetbo-project 1.0.25 → 1.0.26

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.
@@ -98,15 +98,23 @@ async function setupProject() {
98
98
 
99
99
  console.log(' [2/5] ✅ Template décompressé. Réorganisation des fichiers...');
100
100
 
101
- // *** DÉBUT DE LA NOUVELLE LOGIQUE DE DÉPLACEMENT DE FICHIERS ***
101
+ // *** DÉBUT DE LA LOGIQUE CORRIGÉE POUR TROUVER LA RACINE DU PROJET ***
102
102
  let sourceDir = tempDir;
103
- const tempDirContents = fs.readdirSync(tempDir);
104
- const significantContent = tempDirContents.filter(f => !f.startsWith('.'));
103
+ // Si package.json n'est pas à la racine du dossier temporaire...
104
+ if (!fs.existsSync(path.join(tempDir, 'package.json'))) {
105
+ const tempDirContents = fs.readdirSync(tempDir);
106
+ // ...on cherche le premier sous-dossier qui le contient.
107
+ const projectSubDir = tempDirContents.find(f => {
108
+ const fullPath = path.join(tempDir, f);
109
+ return fs.statSync(fullPath).isDirectory() && fs.existsSync(path.join(fullPath, 'package.json'));
110
+ });
105
111
 
106
- // Si le dossier décompressé ne contient qu'un seul dossier, c'est notre source
107
- if (significantContent.length === 1 && fs.statSync(path.join(tempDir, significantContent[0])).isDirectory()) {
108
- console.log(` -> Structure imbriquée détectée. Utilisation du sous-dossier "${significantContent[0]}".`);
109
- sourceDir = path.join(tempDir, significantContent[0]);
112
+ if (projectSubDir) {
113
+ console.log(` -> Structure imbriquée détectée. Utilisation du sous-dossier "${projectSubDir}".`);
114
+ sourceDir = path.join(tempDir, projectSubDir);
115
+ } else {
116
+ throw new Error('Impossible de localiser le fichier package.json dans le template. La structure du dépôt est peut-être incorrecte.');
117
+ }
110
118
  }
111
119
 
112
120
  // Crée le dossier final du projet
@@ -117,7 +125,7 @@ async function setupProject() {
117
125
  for (const item of sourceContents) {
118
126
  fs.renameSync(path.join(sourceDir, item), path.join(projectDir, item));
119
127
  }
120
- // *** FIN DE LA NOUVELLE LOGIQUE ***
128
+ // *** FIN DE LA LOGIQUE CORRIGÉE ***
121
129
 
122
130
  process.chdir(projectDir);
123
131
  console.log(' [3/5] 🔑 Récupération des clés de projet...');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-fleetbo-project",
3
- "version": "1.0.25",
3
+ "version": "1.0.26",
4
4
  "description": "Creates a new Fleetbo project.",
5
5
  "main": "install-react-template.js",
6
6
  "bin": {