@dbcube/cli 1.1.4 → 1.1.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dbcube/cli",
3
- "version": "1.1.4",
3
+ "version": "1.1.6",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "dbcube": "node src/index.js"
@@ -13,7 +13,7 @@
13
13
  "license": "ISC",
14
14
  "description": "",
15
15
  "dependencies": {
16
- "@dbcube/schema-builder": "^1.0.5",
16
+ "@dbcube/schema-builder": "^1.0.6",
17
17
  "@inquirer/prompts": "^7.8.4",
18
18
  "alwait": "^1.0.0",
19
19
  "chalk": "^5.6.0",
@@ -0,0 +1,3 @@
1
+ onlyBuiltDependencies:
2
+ - '@dbcube/core'
3
+ - better-sqlite3
@@ -0,0 +1,75 @@
1
+ const { default: chalk } = require('chalk');
2
+
3
+ /**
4
+ * Shows help information with all available DBCube CLI commands
5
+ */
6
+ async function showHelp() {
7
+ try {
8
+ console.log(`\n${chalk.green('🚀 DBCube CLI - Command Reference')}`);
9
+ console.log(`${chalk.gray('A powerful database toolkit for modern applications')}\n`);
10
+
11
+ console.log(`${chalk.cyan.bold('USAGE:')}`);
12
+ console.log(` ${chalk.white('npx dbcube')} ${chalk.yellow('<command>')} ${chalk.gray('[options]')}\n`);
13
+
14
+ console.log(`${chalk.cyan.bold('DATABASE COMMANDS:')}`);
15
+ console.log(` ${chalk.yellow('database:create')} ${chalk.white('Create a new database with interactive setup')}`);
16
+ console.log(` ${chalk.yellow('run database:create')} ${chalk.white('Alternative syntax for database creation')}`);
17
+ console.log(` ${chalk.yellow('run database:create:config')} ${chalk.white('Add database configuration only')}`);
18
+ console.log(` ${chalk.yellow('run database:create:physical')} ${chalk.white('Create physical database using existing config')}\n`);
19
+
20
+ console.log(`${chalk.cyan.bold('TABLE COMMANDS:')}`);
21
+ console.log(` ${chalk.yellow('run table:fresh')} ${chalk.white('Drop and recreate all tables from .cube files')}`);
22
+ console.log(` ${chalk.yellow('run table:refresh')} ${chalk.white('Refresh table structures without dropping data')}\n`);
23
+
24
+ console.log(`${chalk.cyan.bold('TRIGGER COMMANDS:')}`);
25
+ console.log(` ${chalk.yellow('run trigger:fresh')} ${chalk.white('Recreate all database triggers from .cube files')}\n`);
26
+
27
+ console.log(`${chalk.cyan.bold('SEEDER COMMANDS:')}`);
28
+ console.log(` ${chalk.yellow('run seeder:add')} ${chalk.white('Add test data from seeder .cube files')}\n`);
29
+
30
+ console.log(`${chalk.cyan.bold('UTILITY COMMANDS:')}`);
31
+ console.log(` ${chalk.yellow('version, --version, -v')} ${chalk.white('Show CLI version information')}`);
32
+ console.log(` ${chalk.yellow('help, --help, -h')} ${chalk.white('Show this help information')}\n`);
33
+
34
+ console.log(`${chalk.cyan.bold('FILE STRUCTURE:')}`);
35
+ console.log(` ${chalk.gray('dbcube/')}`);
36
+ console.log(` ${chalk.gray('├── *.table.cube')} ${chalk.white('Table schema definitions')}`);
37
+ console.log(` ${chalk.gray('├── *.seeder.cube')} ${chalk.white('Test data and seeders')}`);
38
+ console.log(` ${chalk.gray('├── *.trigger.cube')} ${chalk.white('Database triggers')}`);
39
+ console.log(` ${chalk.gray('└── dbcube.config.js')} ${chalk.white('Database configuration file')}\n`);
40
+
41
+ console.log(`${chalk.cyan.bold('EXAMPLES:')}`);
42
+ console.log(` ${chalk.gray('# Setup a new database')}`);
43
+ console.log(` ${chalk.white('npx dbcube database:create')}\n`);
44
+
45
+ console.log(` ${chalk.gray('# Recreate all tables')}`);
46
+ console.log(` ${chalk.white('npx dbcube run table:fresh')}\n`);
47
+
48
+ console.log(` ${chalk.gray('# Add seed data')}`);
49
+ console.log(` ${chalk.white('npx dbcube run seeder:add')}\n`);
50
+
51
+ console.log(`${chalk.cyan.bold('CONFIGURATION:')}`);
52
+ console.log(` ${chalk.white('Create a')} ${chalk.yellow('dbcube.config.js')} ${chalk.white('file in your project root:')}`);
53
+ console.log(` ${chalk.gray('module.exports = (config) => {')}`);
54
+ console.log(` ${chalk.gray(' config.addDatabase({')}`);
55
+ console.log(` ${chalk.gray(' name: "myapp",')}`);
56
+ console.log(` ${chalk.gray(' type: "sqlite", // mysql, postgres, sqlite, mongodb')}`);
57
+ console.log(` ${chalk.gray(' // ... connection settings')}`);
58
+ console.log(` ${chalk.gray(' });')}`);
59
+ console.log(` ${chalk.gray('};')}\n`);
60
+
61
+ console.log(`${chalk.cyan.bold('MORE INFO:')}`);
62
+ console.log(` ${chalk.white('Documentation:')} ${chalk.blue('https://github.com/Dbcube/query-builder')}`);
63
+ console.log(` ${chalk.white('Issues:')} ${chalk.blue('https://github.com/Dbcube/query-builder/issues')}\n`);
64
+
65
+ } catch (error) {
66
+ console.error('❌ Error showing help:', error.message);
67
+ process.exit(1);
68
+ }
69
+ }
70
+
71
+ // Ejecutar función
72
+ showHelp().catch(error => {
73
+ console.error('Error fatal:', error);
74
+ process.exit(1);
75
+ });
@@ -0,0 +1,29 @@
1
+ const path = require('path');
2
+ const fs = require('fs');
3
+ const { default: chalk } = require('chalk');
4
+
5
+ /**
6
+ * Muestra la versión actual del CLI de DBCube
7
+ */
8
+ async function showVersion() {
9
+ try {
10
+ // Leer el package.json del CLI
11
+ const packageJsonPath = path.join(__dirname, '../../package.json');
12
+ const packageData = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
13
+
14
+ console.log(`\n${chalk.green('🚀 DBCube CLI')}`);
15
+ console.log(`${chalk.cyan('Versión:')} ${chalk.bold(packageData.version)}`);
16
+ console.log(`${chalk.cyan('Nombre:')} ${packageData.name}`);
17
+ console.log(`${chalk.gray('Licencia:')} ${packageData.license}\n`);
18
+
19
+ } catch (error) {
20
+ console.error('❌ Error al obtener la versión:', error.message);
21
+ process.exit(1);
22
+ }
23
+ }
24
+
25
+ // Ejecutar función
26
+ showVersion().catch(error => {
27
+ console.error('Error fatal:', error);
28
+ process.exit(1);
29
+ });
package/src/index.js CHANGED
@@ -41,10 +41,16 @@ const commandMap = {
41
41
  'run:trigger:fresh': '../src/commands/run/trigger/fresh.js',
42
42
 
43
43
  'run:seeder:add': '../src/commands/run/seeder/add.js',
44
-
44
+
45
45
  'run:database:create': '../src/commands/run/database/create/index.js',
46
46
  'run:database:create:config': '../src/commands/run/database/create/addDatabaseConfig.js',
47
47
  'run:database:create:physical': '../src/commands/run/database/create/createDatabase.js',
48
+
49
+ '--version': '../src/commands/version.js',
50
+ '-v': '../src/commands/version.js',
51
+
52
+ '--help': '../src/commands/help.js',
53
+ '-h': '../src/commands/help.js',
48
54
  };
49
55
 
50
56
  // Función para ejecutar comandos basados en los argumentos
@@ -52,10 +58,10 @@ async function executeCommand(command, commandArgs) {
52
58
  // Verificar si el comando existe en el mapa
53
59
  if (commandMap[command]) {
54
60
  const examplePath = path.join(__dirname, commandMap[command]);
55
-
61
+
56
62
  // Guardamos los argumentos originales
57
63
  const originalArgv = process.argv;
58
-
64
+
59
65
  try {
60
66
  // Reemplazamos los argumentos con los que necesitamos pasar al script
61
67
  process.argv = [process.argv[0], process.argv[1], ...commandArgs];
@@ -65,30 +71,10 @@ async function executeCommand(command, commandArgs) {
65
71
  process.argv = originalArgv;
66
72
  }
67
73
  } else {
68
- // Comando desconocido
69
- console.log(`Comando desconocido: ${command} ${commandArgs.join(' ')}`);
70
- console.log('Comandos disponibles:');
71
- for (const cmd in commandMap) {
72
- let description = '';
73
- switch (cmd) {
74
- case 'run:cube:fresh':
75
- description = 'Ejecuta el ejemplo de migración';
76
- break;
77
- case 'run:create:database':
78
- case 'run:create:db':
79
- case 'create:database':
80
- case 'create:db':
81
- if (!description) description = 'Crea una base de datos [--name=<nombre> | -n <nombre>] [--motor=<motor> | -m <motor>]';
82
- break;
83
- case 'run:create:database:config':
84
- description = 'Agrega configuración de base de datos [--name=<nombre> | -n <nombre>] [--motor=<motor> | -m <motor>]';
85
- break;
86
- case 'run:create:database:physical':
87
- description = 'Crea la base de datos física [--name=<nombre> | -n <nombre>]';
88
- break;
89
- }
90
- if (description) console.log(` ${cmd} - ${description}`);
91
- }
74
+ // Comando desconocido - mostrar help
75
+ const chalk = require('chalk');
76
+ console.log(`\n${chalk.red(' Unknown command:')} ${command} ${commandArgs.join(' ')}\n`);
77
+ console.log(`${chalk.cyan('Run')} ${chalk.yellow('npx dbcube help')} ${chalk.cyan('to see all available commands.')}\n`);
92
78
  process.exit(1);
93
79
  }
94
80
  }
@@ -51,7 +51,7 @@ class FileUtils {
51
51
  const fullPath = path.join(currentDir, entry.name);
52
52
  if (entry.isDirectory()) {
53
53
  recurse(fullPath);
54
- } else if (entry.isFile() && entry.name.endsWith(suffix)) {
54
+ } else if (entry.isFile() && (entry.name.endsWith(suffix) || entry.name.includes(suffix))) {
55
55
  cubeFiles.push(fullPath); // Ya es absoluta
56
56
  }
57
57
  }