create-fleetbo-project 1.0.7 → 1.0.8

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.
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env node
2
+ // Fichier : install-react-template.js (Version améliorée)
2
3
  const { execSync } = require('child_process');
3
4
  const fs = require('fs');
4
5
  const path = require('path');
@@ -13,142 +14,63 @@ const projectName = process.argv[2];
13
14
  const tokenArgIndex = process.argv.indexOf('--token');
14
15
  const bootstrapToken = tokenArgIndex !== -1 ? process.argv[tokenArgIndex + 1] : null;
15
16
  const repoUrl = 'https://github.com/FleetFleetbo/dev.fleetbo.io/archive/refs/heads/main.zip';
16
- const bootstrapUrl = 'https://us-central1-myapp-259bf.cloudfunctions.net/bootstrapProject';
17
+ // ⚠️ REMPLACEZ PAR L'URL DE VOTRE FONCTION bootstrapProject
18
+ const bootstrapUrl = 'https://us-central1-myapp-259bf.cloudfunctions.net/bootstrapProject';
17
19
 
18
20
  // --- Validation ---
19
21
  if (!projectName || !bootstrapToken) {
20
- console.error(chalk.red('Error: Missing project name or token.'));
21
- console.log('Usage: npx create-fleetbo-project <project-name> --token <your-token>');
22
+ console.error(chalk.red('Erreur : Nom du projet ou token manquant.'));
23
+ console.log('Usage: npx create-fleetbo-project <nom-du-projet> --token <votre-token>');
22
24
  process.exit(1);
23
25
  }
24
26
 
25
- // --- Main Function ---
27
+ // --- Fonction Principale ---
26
28
  async function setupProject() {
27
- console.log(chalk.blue(`Creating your Fleetbo project "${projectName}"...`));
29
+ console.log(chalk.blue(`Création de votre projet Fleetbo "${projectName}"...`));
28
30
  const spinner = ora();
29
-
31
+
30
32
  try {
31
- // 1. Fetch configuration
32
- spinner.start('Fetching secure configuration...');
33
+ spinner.start('Récupération de la configuration sécurisée...');
33
34
  const response = await axios.post(bootstrapUrl, { token: bootstrapToken });
34
35
  const projectSecrets = response.data;
35
- spinner.succeed(chalk.green('Configuration retrieved!'));
36
-
37
- console.log(chalk.dim('Config received:'), {
38
- fleetboDB: projectSecrets.fleetboDB ? '✓' : '✗',
39
- appId: projectSecrets.appId ? '✓' : '✗'
40
- });
36
+ spinner.succeed(chalk.green('Configuration récupérée !'));
41
37
 
42
- // 2. Download template
43
- spinner.start('Downloading template...');
44
- const responseStream = await new Promise((resolve, reject) =>
45
- https.get(repoUrl, res => resolve(res)).on('error', err => reject(err))
46
- );
47
- spinner.succeed(chalk.green('Template downloaded.'));
38
+ spinner.start('Téléchargement du template...');
39
+ const responseStream = await new Promise((resolve, reject) => https.get(repoUrl, res => resolve(res)).on('error', err => reject(err)));
40
+ spinner.succeed(chalk.green('Template téléchargé.'));
48
41
 
49
- // 3. Unzip files
50
- spinner.start('Unzipping files...');
42
+ spinner.start('Décompression des fichiers...');
51
43
  await new Promise((resolve, reject) => {
52
- responseStream.pipe(unzipper.Extract({ path: '.' }))
53
- .on('finish', resolve)
54
- .on('error', reject);
44
+ responseStream.pipe(unzipper.Extract({ path: '.' }))
45
+ .on('finish', resolve).on('error', reject);
55
46
  });
56
-
57
- // Rename directory
58
- const extractedDir = 'dev.fleetbo.io-main';
59
- if (fs.existsSync(extractedDir)) {
60
- fs.renameSync(extractedDir, projectName);
61
- spinner.succeed(chalk.green('Files unzipped.'));
62
- } else {
63
- throw new Error(`Extracted directory not found: ${extractedDir}`);
64
- }
47
+ fs.renameSync(`dev.fleetbo.io-main`, projectName);
48
+ spinner.succeed(chalk.green('Fichiers décompressés.'));
65
49
 
66
- // 4. Change to project directory
67
- const projectPath = path.resolve(projectName);
68
- process.chdir(projectPath);
69
- console.log(chalk.dim(`Working directory: ${process.cwd()}`));
50
+ process.chdir(projectName);
70
51
 
71
- // 5. Configure project
72
- spinner.start('Configuring project...');
52
+ spinner.start('Configuration du projet...');
53
+ const envContent = `REACT_APP_FLEETBO_DB_KEY="${projectSecrets.fleetboDB}"\nREACT_APP_ENTERPRISE_ID=${projectSecrets.appId}\n`;
54
+ fs.writeFileSync('.env', envContent, 'utf8');
73
55
 
74
- // Create .env file
75
- const envContent = `REACT_APP_FLEETBO_DB_KEY="${projectSecrets.fleetboDB}"
76
- REACT_APP_ENTERPRISE_ID=${projectSecrets.appId}
77
- `;
78
- const envPath = path.join(process.cwd(), '.env');
79
- fs.writeFileSync(envPath, envContent, 'utf8');
80
-
81
- // Verify .env was created
82
- if (fs.existsSync(envPath)) {
83
- console.log(chalk.green('✓ .env file created successfully'));
84
- console.log(chalk.dim(` Location: ${envPath}`));
85
- } else {
86
- throw new Error('.env file was not created');
87
- }
88
-
89
- // Update package.json
90
56
  const packageJsonPath = path.join(process.cwd(), 'package.json');
91
57
  const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
92
58
  packageJson.name = projectName;
93
59
  fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), 'utf8');
94
-
95
- spinner.succeed(chalk.green('Project configured.'));
60
+ spinner.succeed(chalk.green('Projet configuré.'));
96
61
 
97
- // 6. Create .env.example for reference
98
- const envExampleContent = `# Fleetbo Configuration
99
- # These values are automatically configured during project setup
100
- REACT_APP_FLEETBO_DB_KEY="your-fleetbo-db-key"
101
- REACT_APP_ENTERPRISE_ID=your-app-id
102
- `;
103
- fs.writeFileSync('.env.example', envExampleContent, 'utf8');
104
- console.log(chalk.dim('✓ .env.example created'));
105
-
106
- // 7. Ensure .gitignore includes .env
107
- const gitignorePath = path.join(process.cwd(), '.gitignore');
108
- if (fs.existsSync(gitignorePath)) {
109
- let gitignoreContent = fs.readFileSync(gitignorePath, 'utf8');
110
- if (!gitignoreContent.includes('.env')) {
111
- gitignoreContent += '\n# Environment variables\n.env\n.env.local\n';
112
- fs.writeFileSync(gitignorePath, gitignoreContent, 'utf8');
113
- console.log(chalk.dim('✓ .gitignore updated'));
114
- }
115
- }
116
-
117
- // 8. Install dependencies
118
- spinner.start('Installing dependencies (this may take a few minutes)...');
62
+ spinner.start('Installation des dépendances (cela peut prendre quelques minutes)...');
119
63
  execSync('npm install', { stdio: 'inherit' });
120
- spinner.succeed(chalk.green('Dependencies installed.'));
64
+ spinner.succeed(chalk.green('Dépendances installées.'));
121
65
 
122
- // 9. Final verification
123
- console.log(chalk.green.bold('\n🚀 Your Fleetbo project is ready!\n'));
124
-
125
- // Verify configuration
126
- if (fs.existsSync(envPath)) {
127
- console.log(chalk.green('✓ Configuration file verified'));
128
- } else {
129
- console.log(chalk.yellow('⚠️ Warning: .env file not found after setup'));
130
- }
131
-
132
- console.log(chalk.cyan('\nTo get started:'));
133
- console.log(chalk.cyan(` cd ${projectName}`));
134
- console.log(chalk.cyan(` npm start`));
135
-
136
- console.log(chalk.dim('\nNote: Your .env file contains sensitive credentials and is excluded from git.'));
66
+ console.log(chalk.green.bold('\n🚀 Votre projet Fleetbo est prêt !'));
67
+ console.log(`\nPour commencer :`);
68
+ console.log(chalk.cyan(` cd ${projectName}`));
69
+ console.log(chalk.cyan(` npm start`));
137
70
 
138
71
  } catch (error) {
139
72
  if (spinner.isSpinning) spinner.fail();
140
- console.error(chalk.red('\n❌ An error occurred:'));
141
-
142
- if (error.response) {
143
- console.error(chalk.red('API Error:'), error.response.data);
144
- } else if (error.code === 'ENOENT') {
145
- console.error(chalk.red('File Error:'), error.message);
146
- console.error(chalk.yellow('This might be a permissions issue.'));
147
- } else {
148
- console.error(chalk.red(error.message));
149
- }
150
-
151
- console.error(chalk.dim('\nStack trace:'), error.stack);
73
+ console.error(chalk.red('\n❌ Une erreur est survenue :'), error.response ? error.response.data : error.message);
152
74
  process.exit(1);
153
75
  }
154
76
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-fleetbo-project",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "Creates a new Fleetbo project.",
5
5
  "main": "install-react-template.js",
6
6
  "bin": {