vako 1.3.0

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.
@@ -0,0 +1,75 @@
1
+ #!/usr/bin/env node
2
+
3
+ const chalk = require('chalk');
4
+ const { Command } = require('commander');
5
+ const SetupWizard = require('./commands/setup');
6
+ const QuickSetup = require('./commands/quick-setup');
7
+
8
+ const program = new Command();
9
+
10
+ program
11
+ .name('create-veko-app')
12
+ .description('Create a new Veko.js application')
13
+ .version('1.1.0')
14
+ .argument('[project-name]', 'Name of the project')
15
+ .option('--template <template>', 'Template to use')
16
+ .option('--quick', 'Quick setup with minimal questions')
17
+ .option('--wizard', 'Full interactive wizard')
18
+ .action(async (projectName, options) => {
19
+ console.log(chalk.blue.bold('🚀 Create Veko App\n'));
20
+
21
+ if (!projectName) {
22
+ console.log(chalk.red('❌ Project name is required'));
23
+ console.log(chalk.gray('Usage: npx create-veko-app my-app'));
24
+ process.exit(1);
25
+ }
26
+
27
+ try {
28
+ if (options.wizard) {
29
+ const wizard = new SetupWizard();
30
+ wizard.config.projectName = projectName;
31
+ await wizard.start();
32
+ } else if (options.quick || options.template) {
33
+ const quickSetup = new QuickSetup(projectName, options);
34
+ await quickSetup.start();
35
+ } else {
36
+ // Default: ask user preference
37
+ const { setupType } = await require('inquirer').prompt([{
38
+ type: 'list',
39
+ name: 'setupType',
40
+ message: '🎯 How would you like to set up your project?',
41
+ choices: [
42
+ { name: '⚡ Quick - Essential options only', value: 'quick' },
43
+ { name: '🧙‍♂️ Wizard - Full interactive setup', value: 'wizard' }
44
+ ]
45
+ }]);
46
+
47
+ if (setupType === 'wizard') {
48
+ const wizard = new SetupWizard();
49
+ wizard.config.projectName = projectName;
50
+ await wizard.start();
51
+ } else {
52
+ const quickSetup = new QuickSetup(projectName, options);
53
+ await quickSetup.start();
54
+ }
55
+ }
56
+ } catch (error) {
57
+ console.error(chalk.red('\n❌ Setup failed:'), error.message);
58
+ process.exit(1);
59
+ }
60
+ });
61
+
62
+ // Show help if no arguments
63
+ if (process.argv.length <= 2) {
64
+ console.log(chalk.blue.bold('🚀 Create Veko App\n'));
65
+ console.log(chalk.white('Usage:'));
66
+ console.log(chalk.gray(' npx create-veko-app my-app'));
67
+ console.log(chalk.gray(' npx create-veko-app my-app --template api'));
68
+ console.log(chalk.gray(' npx create-veko-app my-app --wizard'));
69
+ console.log(chalk.gray(' npx create-veko-app my-app --quick'));
70
+ console.log(chalk.white('\nTemplates:'));
71
+ console.log(chalk.gray(' default, api, blog, admin, ecommerce, portfolio\n'));
72
+ process.exit(0);
73
+ }
74
+
75
+ program.parse();
@@ -0,0 +1,205 @@
1
+ #!/usr/bin/env node
2
+
3
+ const path = require('path');
4
+ const fs = require('fs');
5
+
6
+ // Ajouter le chemin vers les modules lib
7
+ const libPath = path.join(__dirname, '..', 'lib');
8
+ process.env.NODE_PATH = `${process.env.NODE_PATH || ''}:${libPath}`;
9
+ require('module')._initPaths();
10
+
11
+ // Fonction d'urgence pour les cas critiques
12
+ function emergencyRepair() {
13
+ console.error('\n🔧 RÉPARATION D\'URGENCE DE L\'AUTO-UPDATER');
14
+ console.error('═'.repeat(50));
15
+
16
+ try {
17
+ const packageJsonPath = path.join(process.cwd(), 'package.json');
18
+
19
+ if (!fs.existsSync(packageJsonPath)) {
20
+ console.error('❌ package.json non trouvé. Impossible de continuer.');
21
+ console.error('Créez un fichier package.json ou naviguez vers un projet Node.js valide.');
22
+ return false;
23
+ }
24
+
25
+ console.error('✅ package.json trouvé');
26
+
27
+ // Vérifier l'installation de veko
28
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
29
+ const vekoVersion = packageJson.dependencies?.veko ||
30
+ packageJson.devDependencies?.veko ||
31
+ packageJson.peerDependencies?.veko;
32
+
33
+ if (!vekoVersion) {
34
+ console.error('⚠️ Veko non trouvé dans package.json');
35
+ console.error('🔧 Installation de veko...');
36
+
37
+ const { execSync } = require('child_process');
38
+ try {
39
+ execSync('npm install veko@latest', { stdio: 'inherit' });
40
+ console.error('✅ Veko installé avec succès');
41
+ return true;
42
+ } catch (error) {
43
+ console.error('❌ Échec de l\'installation:', error.message);
44
+ return false;
45
+ }
46
+ } else {
47
+ console.error(`✅ Veko v${vekoVersion.replace(/[\^~>=<]/g, '')} détecté`);
48
+ return true;
49
+ }
50
+
51
+ } catch (error) {
52
+ console.error('❌ Erreur critique lors de la réparation:', error.message);
53
+ return false;
54
+ }
55
+ }
56
+
57
+ // Importer l'auto-updater avec gestion des erreurs robuste
58
+ let AutoUpdater = null;
59
+ try {
60
+ AutoUpdater = require('../lib/core/auto-updater');
61
+
62
+ // Vérification que l'auto-updater a toutes les méthodes nécessaires
63
+ const requiredMethods = ['handleCLI', 'getCurrentVersion', 'checkForUpdates', 'log', 'init'];
64
+ const missingMethods = requiredMethods.filter(method => typeof AutoUpdater[method] !== 'function');
65
+
66
+ if (missingMethods.length > 0) {
67
+ console.error(`❌ L'auto-updater est incomplet. Méthodes manquantes: ${missingMethods.join(', ')}`);
68
+ throw new Error('Auto-updater incomplet');
69
+ }
70
+
71
+ } catch (error) {
72
+ console.error(`Erreur de chargement de l'auto-updater: ${error.message}`);
73
+
74
+ // Tentative de réparation d'urgence
75
+ if (emergencyRepair()) {
76
+ console.error('\n🔄 Tentative de rechargement après réparation...');
77
+ try {
78
+ // Nettoyer le cache des modules
79
+ delete require.cache[require.resolve('../lib/core/auto-updater')];
80
+ AutoUpdater = require('../lib/core/auto-updater');
81
+ console.error('✅ Auto-updater rechargé avec succès');
82
+ } catch (reloadError) {
83
+ console.error('❌ Échec du rechargement:', reloadError.message);
84
+ process.exit(1);
85
+ }
86
+ } else {
87
+ console.error('❌ Réparation d\'urgence échouée');
88
+ process.exit(1);
89
+ }
90
+ }
91
+
92
+ async function main() {
93
+ const args = process.argv.slice(2);
94
+
95
+ try {
96
+ // Vérification de la disponibilité avant l'exécution
97
+ if (!AutoUpdater) {
98
+ throw new Error("L'auto-updater n'est pas disponible");
99
+ }
100
+
101
+ if (typeof AutoUpdater.handleCLI !== 'function') {
102
+ throw new Error("La méthode handleCLI est manquante dans l'auto-updater");
103
+ }
104
+
105
+ // Initialisation avec timeout
106
+ const initPromise = Promise.race([
107
+ AutoUpdater.init(),
108
+ new Promise((_, reject) =>
109
+ setTimeout(() => reject(new Error('Timeout lors de l\'initialisation')), 10000)
110
+ )
111
+ ]);
112
+
113
+ try {
114
+ await initPromise;
115
+ } catch (initError) {
116
+ console.warn(`⚠️ Avertissement d'initialisation: ${initError.message}`);
117
+ // Continuer malgré l'erreur d'initialisation
118
+ }
119
+
120
+ // Passer tous les arguments à handleCLI avec timeout
121
+ const cliPromise = Promise.race([
122
+ AutoUpdater.handleCLI(args),
123
+ new Promise((_, reject) =>
124
+ setTimeout(() => reject(new Error('Timeout lors de l\'exécution de la commande')), 30000)
125
+ )
126
+ ]);
127
+
128
+ return await cliPromise;
129
+
130
+ } catch (error) {
131
+ console.error(`❌ Erreur: ${error.message}`);
132
+
133
+ // Diagnostics et suggestions
134
+ if (error.message.includes('not a function')) {
135
+ console.error('\n🔧 DIAGNOSTIC:');
136
+ console.error('L\'auto-updater semble être corrompu ou incompatible.');
137
+ console.error('\n💡 SOLUTIONS:');
138
+ console.error('1. Réinstallez veko: npm install veko@latest');
139
+ console.error('2. Nettoyez le cache npm: npm cache clean --force');
140
+ console.error('3. Supprimez node_modules et réinstallez: rm -rf node_modules && npm install');
141
+ } else if (error.message.includes('Timeout')) {
142
+ console.error('\n🔧 DIAGNOSTIC:');
143
+ console.error('L\'opération a pris trop de temps à s\'exécuter.');
144
+ console.error('\n💡 SOLUTIONS:');
145
+ console.error('1. Vérifiez votre connexion internet');
146
+ console.error('2. Essayez à nouveau dans quelques minutes');
147
+ console.error('3. Utilisez: veko update fix pour réparer');
148
+ } else {
149
+ console.error('\n💡 Pour réparer automatiquement l\'auto-updater:');
150
+ console.error('npm install veko@latest');
151
+ }
152
+
153
+ if (process.env.DEBUG) {
154
+ console.error('\n🐛 STACK TRACE:');
155
+ console.error(error.stack);
156
+ }
157
+
158
+ process.exit(1);
159
+ }
160
+ }
161
+
162
+ // Gestion gracieuse des signaux
163
+ process.on('SIGINT', () => {
164
+ console.log('\n👋 Au revoir!');
165
+ process.exit(0);
166
+ });
167
+
168
+ process.on('SIGTERM', () => {
169
+ console.log('\n🛑 Arrêt demandé');
170
+ process.exit(0);
171
+ });
172
+
173
+ // Gestion des erreurs non capturées
174
+ process.on('uncaughtException', (error) => {
175
+ console.error('❌ Erreur non gérée:', error.message);
176
+
177
+ if (error.message && error.message.includes('not a function')) {
178
+ console.error('\n🔧 L\'auto-updater est corrompu.');
179
+ console.error('Exécutez: npm install veko@latest');
180
+ }
181
+
182
+ if (process.env.DEBUG) {
183
+ console.error(error.stack);
184
+ }
185
+ process.exit(1);
186
+ });
187
+
188
+ process.on('unhandledRejection', (reason, promise) => {
189
+ console.error('❌ Promise rejetée:', reason);
190
+ if (process.env.DEBUG) {
191
+ console.error('Promise:', promise);
192
+ }
193
+ process.exit(1);
194
+ });
195
+
196
+ // Lancement de l'application avec gestion d'erreurs
197
+ main().then(result => {
198
+ process.exit(result ? 0 : 1);
199
+ }).catch((error) => {
200
+ console.error(`❌ Erreur fatale: ${error.message}`);
201
+ if (process.env.DEBUG) {
202
+ console.error(error.stack);
203
+ }
204
+ process.exit(1);
205
+ });
package/bin/veko.js ADDED
@@ -0,0 +1,188 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { Command } = require('commander');
4
+ const chalk = require('chalk');
5
+ const SetupWizard = require('./commands/setup');
6
+ const DevServer = require('../lib/dev/dev-server');
7
+ const path = require('path');
8
+ const fs = require('fs');
9
+
10
+ // Version du package
11
+ const packageJson = require('../package.json');
12
+ const version = packageJson.version;
13
+
14
+ // Ajouter le chemin vers les modules lib
15
+ const libPath = path.join(__dirname, '..', 'lib');
16
+ process.env.NODE_PATH = `${process.env.NODE_PATH || ''}:${libPath}`;
17
+ require('module')._initPaths();
18
+
19
+ const program = new Command();
20
+
21
+ program
22
+ .name('veko')
23
+ .description('Veko.js Framework CLI')
24
+ .version('1.1.0');
25
+
26
+ // ============= DEV COMMAND =============
27
+ program
28
+ .command('dev')
29
+ .description('Start development server')
30
+ .option('-p, --port <port>', 'Port number', '3000')
31
+ .option('-f, --file <file>', 'Entry file', 'app.js')
32
+ .option('-w, --watch <dirs>', 'Watch directories', 'views,routes,public')
33
+ .action(async (options) => {
34
+ try {
35
+ const devServer = new DevServer({
36
+ port: parseInt(options.port),
37
+ file: options.file,
38
+ watchDirs: options.watch.split(',')
39
+ });
40
+
41
+ await devServer.start();
42
+ } catch (error) {
43
+ console.error(chalk.red('❌ Error starting dev server:'), error.message);
44
+ process.exit(1);
45
+ }
46
+ });
47
+
48
+ // ============= BUILD COMMAND =============
49
+ program
50
+ .command('build')
51
+ .description('Build for production')
52
+ .action(() => {
53
+ console.log(chalk.blue('🔨 Building for production...'));
54
+ console.log(chalk.green('✅ Build completed!'));
55
+ });
56
+
57
+ // ============= START COMMAND =============
58
+ program
59
+ .command('start')
60
+ .description('Start production server')
61
+ .option('-f, --file <file>', 'Entry file', 'app.js')
62
+ .action((options) => {
63
+ try {
64
+ console.log(chalk.blue('🚀 Starting production server...'));
65
+ execSync(`node ${options.file}`, { stdio: 'inherit' });
66
+ } catch (error) {
67
+ console.error(chalk.red('❌ Error starting server:'), error.message);
68
+ process.exit(1);
69
+ }
70
+ });
71
+
72
+ // ============= SETUP COMMAND (UPDATED) =============
73
+ program
74
+ .command('setup [project-name]')
75
+ .description('🚀 Interactive project setup wizard')
76
+ .option('-q, --quick', 'Quick setup with defaults')
77
+ .option('--template <template>', 'Template (default, api, blog, admin, ecommerce, portfolio)')
78
+ .option('--features <features>', 'Comma-separated features list')
79
+ .option('--auth', 'Enable authentication system')
80
+ .option('--db <database>', 'Database type (sqlite, mysql, mongodb)')
81
+ .option('--styling <framework>', 'CSS framework (bootstrap, tailwind, material)')
82
+ .action(async (projectNameArg, options) => {
83
+ if (options.quick) {
84
+ const quickConfig = {
85
+ projectName: projectNameArg || 'veko-app',
86
+ template: options.template || 'default',
87
+ features: options.features ? options.features.split(',') : ['hotreload', 'layouts'],
88
+ database: options.db || 'sqlite',
89
+ auth: { enabled: options.auth || false },
90
+ styling: options.styling || 'bootstrap',
91
+ git: true,
92
+ install: true
93
+ };
94
+
95
+ const SetupExecutor = require('./commands/setup-executor');
96
+ const executor = new SetupExecutor(quickConfig);
97
+ await executor.execute();
98
+ } else {
99
+ const wizard = new SetupWizard();
100
+ await wizard.start();
101
+ }
102
+ });
103
+
104
+ // ============= NEW COMMANDS =============
105
+ program
106
+ .command('wizard')
107
+ .alias('w')
108
+ .description('🧙‍♂️ Full interactive setup wizard')
109
+ .action(async () => {
110
+ const wizard = new SetupWizard();
111
+ await wizard.start();
112
+ });
113
+
114
+ program
115
+ .command('create <project-name>')
116
+ .description('🎯 Quick project creation with prompts')
117
+ .option('--template <template>', 'Template to use')
118
+ .action(async (projectName, options) => {
119
+ const QuickSetup = require('./commands/quick-setup');
120
+ const quickSetup = new QuickSetup(projectName, options);
121
+ await quickSetup.start();
122
+ });
123
+
124
+ program
125
+ .command('templates')
126
+ .alias('t')
127
+ .description('📋 List available templates')
128
+ .action(() => {
129
+ const TemplateList = require('./commands/template-list');
130
+ const templateList = new TemplateList();
131
+ templateList.display();
132
+ });
133
+
134
+ program
135
+ .command('plugins')
136
+ .description('🔌 Plugin management')
137
+ .option('--list', 'List available plugins')
138
+ .option('--search <term>', 'Search plugins')
139
+ .action((options) => {
140
+ const PluginManager = require('./commands/plugin-manager-cli');
141
+ const pluginManager = new PluginManager();
142
+
143
+ if (options.list) {
144
+ pluginManager.listPlugins();
145
+ } else if (options.search) {
146
+ pluginManager.searchPlugins(options.search);
147
+ } else {
148
+ pluginManager.showMenu();
149
+ }
150
+ });
151
+
152
+ // Ajout de la commande update qui servira de passerelle vers veko-update
153
+ program
154
+ .command('update')
155
+ .description('Gestionnaire de mise à jour Veko')
156
+ .allowUnknownOption(true)
157
+ .action(() => {
158
+ // Exécuter veko-update avec les mêmes arguments
159
+ const updateBin = path.join(__dirname, 'veko-update.js');
160
+ if (fs.existsSync(updateBin)) {
161
+ const { execSync } = require('child_process');
162
+ try {
163
+ execSync(`node "${updateBin}" ${process.argv.slice(3).join(' ')}`, {
164
+ stdio: 'inherit'
165
+ });
166
+ } catch (error) {
167
+ console.error('Erreur lors du lancement de l\'auto-updater');
168
+ process.exit(1);
169
+ }
170
+ } else {
171
+ console.error('L\'auto-updater n\'est pas disponible');
172
+ process.exit(1);
173
+ }
174
+ });
175
+
176
+ program.parse(process.argv);
177
+
178
+ if (!process.argv.slice(2).length) {
179
+ console.log('\n🚀 Veko.js v' + version + ' - Ultra-modern Node.js framework\n');
180
+ console.log('Available commands:');
181
+ console.log(' dev Start development server with hot reload');
182
+ console.log(' setup Set up a new Veko.js project');
183
+ console.log(' verify Verify code quality and security');
184
+ console.log(' update Gestionnaire de mise à jour Veko');
185
+ console.log('\nRun `veko <command> --help` for more information on specific commands.');
186
+ console.log('\nDocumentation: https://veko.js.org');
187
+ process.exit(0);
188
+ }