@dbcube/cli 1.1.3 → 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/.lh/.lhignore +6 -6
- package/.lh/package.json.json +25 -25
- package/package.json +3 -3
- package/pnpm-workspace.yaml +3 -0
- package/src/commands/help.js +75 -0
- package/src/commands/run/trigger/fresh.js +75 -75
- package/src/commands/version.js +29 -0
- package/src/index.js +13 -27
- package/src/utils/FileUtils.js +1 -1
package/.lh/.lhignore
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# list file to not track by the local-history extension. comment line starts with a '#' character
|
|
2
|
-
# each line describe a regular expression pattern (search for 'Javascript regex')
|
|
3
|
-
# it will relate to the workspace directory root. for example:
|
|
4
|
-
# '.*\.txt' ignores any file with 'txt' extension
|
|
5
|
-
# '/test/.*' ignores all the files under the 'test' directory
|
|
6
|
-
# '.*/test/.*' ignores all the files under any 'test' directory (even under sub-folders)
|
|
1
|
+
# list file to not track by the local-history extension. comment line starts with a '#' character
|
|
2
|
+
# each line describe a regular expression pattern (search for 'Javascript regex')
|
|
3
|
+
# it will relate to the workspace directory root. for example:
|
|
4
|
+
# '.*\.txt' ignores any file with 'txt' extension
|
|
5
|
+
# '/test/.*' ignores all the files under the 'test' directory
|
|
6
|
+
# '.*/test/.*' ignores all the files under any 'test' directory (even under sub-folders)
|
package/.lh/package.json.json
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
{
|
|
2
|
-
"sourceFile": "package.json",
|
|
3
|
-
"activeCommit": 0,
|
|
4
|
-
"commits": [
|
|
5
|
-
{
|
|
6
|
-
"activePatchIndex": 2,
|
|
7
|
-
"patches": [
|
|
8
|
-
{
|
|
9
|
-
"date": 1756705588331,
|
|
10
|
-
"content": "Index: \n===================================================================\n--- \n+++ \n"
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
"date": 1756705654448,
|
|
14
|
-
"content": "Index: \n===================================================================\n--- \n+++ \n@@ -13,9 +13,8 @@\n \"author\": \"\",\n \"license\": \"ISC\",\n \"description\": \"\",\n \"dependencies\": {\n- \"@dbcube/schema-builder\": \"^1.0.0\",\n \"@inquirer/prompts\": \"^7.4.1\",\n \"alwait\": \"^1.0.0\",\n \"chalk\": \"^5.4.1\",\n \"dotenv\": \"^17.0.1\",\n"
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
"date": 1756706224795,
|
|
18
|
-
"content": "Index: \n===================================================================\n--- \n+++ \n@@ -2,9 +2,8 @@\n \"name\": \"dbcube\",\n \"version\": \"1.0.1\",\n \"main\": \"index.js\",\n \"scripts\": {\n- \"start\": \"node example.js\",\n \"dbcube\": \"node src/index.js\"\n },\n \"bin\": {\n \"dbcube\": \"./src/index.js\"\n"
|
|
19
|
-
}
|
|
20
|
-
],
|
|
21
|
-
"date": 1756705588331,
|
|
22
|
-
"name": "Commit-0",
|
|
23
|
-
"content": "{\n \"name\": \"dbcube\",\n \"version\": \"1.0.0\",\n \"main\": \"index.js\",\n \"scripts\": {\n \"start\": \"node example.js\",\n \"dbcube\": \"node src/index.js\"\n },\n \"bin\": {\n \"dbcube\": \"./src/index.js\"\n },\n \"keywords\": [],\n \"author\": \"\",\n \"license\": \"ISC\",\n \"description\": \"\",\n \"dependencies\": {\n \"@inquirer/prompts\": \"^7.4.1\",\n \"alwait\": \"^1.0.0\",\n \"chalk\": \"^5.4.1\",\n \"dotenv\": \"^17.0.1\",\n \"fs-extra\": \"^11.3.0\",\n \"glob\": \"^11.0.1\",\n \"ora\": \"^8.2.0\"\n }\n}\n"
|
|
24
|
-
}
|
|
25
|
-
]
|
|
1
|
+
{
|
|
2
|
+
"sourceFile": "package.json",
|
|
3
|
+
"activeCommit": 0,
|
|
4
|
+
"commits": [
|
|
5
|
+
{
|
|
6
|
+
"activePatchIndex": 2,
|
|
7
|
+
"patches": [
|
|
8
|
+
{
|
|
9
|
+
"date": 1756705588331,
|
|
10
|
+
"content": "Index: \n===================================================================\n--- \n+++ \n"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"date": 1756705654448,
|
|
14
|
+
"content": "Index: \n===================================================================\n--- \n+++ \n@@ -13,9 +13,8 @@\n \"author\": \"\",\n \"license\": \"ISC\",\n \"description\": \"\",\n \"dependencies\": {\n- \"@dbcube/schema-builder\": \"^1.0.0\",\n \"@inquirer/prompts\": \"^7.4.1\",\n \"alwait\": \"^1.0.0\",\n \"chalk\": \"^5.4.1\",\n \"dotenv\": \"^17.0.1\",\n"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"date": 1756706224795,
|
|
18
|
+
"content": "Index: \n===================================================================\n--- \n+++ \n@@ -2,9 +2,8 @@\n \"name\": \"dbcube\",\n \"version\": \"1.0.1\",\n \"main\": \"index.js\",\n \"scripts\": {\n- \"start\": \"node example.js\",\n \"dbcube\": \"node src/index.js\"\n },\n \"bin\": {\n \"dbcube\": \"./src/index.js\"\n"
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"date": 1756705588331,
|
|
22
|
+
"name": "Commit-0",
|
|
23
|
+
"content": "{\n \"name\": \"dbcube\",\n \"version\": \"1.0.0\",\n \"main\": \"index.js\",\n \"scripts\": {\n \"start\": \"node example.js\",\n \"dbcube\": \"node src/index.js\"\n },\n \"bin\": {\n \"dbcube\": \"./src/index.js\"\n },\n \"keywords\": [],\n \"author\": \"\",\n \"license\": \"ISC\",\n \"description\": \"\",\n \"dependencies\": {\n \"@inquirer/prompts\": \"^7.4.1\",\n \"alwait\": \"^1.0.0\",\n \"chalk\": \"^5.4.1\",\n \"dotenv\": \"^17.0.1\",\n \"fs-extra\": \"^11.3.0\",\n \"glob\": \"^11.0.1\",\n \"ora\": \"^8.2.0\"\n }\n}\n"
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
26
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dbcube/cli",
|
|
3
|
-
"version": "1.1.
|
|
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.
|
|
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",
|
|
@@ -22,4 +22,4 @@
|
|
|
22
22
|
"glob": "^11.0.3",
|
|
23
23
|
"ora": "^8.2.0"
|
|
24
24
|
}
|
|
25
|
-
}
|
|
25
|
+
}
|
|
@@ -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
|
+
});
|
|
@@ -1,76 +1,76 @@
|
|
|
1
|
-
const { default: Schema } = require('@dbcube/schema-builder');
|
|
2
|
-
const ConfigFileUtils = require('./../../../utils/ConfigFileUtils');
|
|
3
|
-
const fs = require('fs');
|
|
4
|
-
const path = require('path');
|
|
5
|
-
const FileUtils = require('./../../../utils/FileUtils');
|
|
6
|
-
const { default: chalk } = require('chalk');
|
|
7
|
-
const { default: ora } = require('ora');
|
|
8
|
-
const { default: alwait } = require('alwait');
|
|
9
|
-
|
|
10
|
-
async function main() {
|
|
11
|
-
// Suprimir logs de dotenv
|
|
12
|
-
process.env.DOTENV_SILENT = 'true';
|
|
13
|
-
|
|
14
|
-
console.clear();
|
|
15
|
-
console.log(`\n⚡ ${chalk.green("Ejecutando triggers...")}`);
|
|
16
|
-
try {
|
|
17
|
-
// Verificar y leer archivos de la carpeta cubes
|
|
18
|
-
const spinner = ora('Preparando ejecución de triggers...').start();
|
|
19
|
-
await alwait(500);
|
|
20
|
-
const cubesDir = path.join(process.cwd(), 'dbcube', 'cubes');
|
|
21
|
-
|
|
22
|
-
// Verificar si la carpeta existe
|
|
23
|
-
if (!fs.existsSync(cubesDir)) {
|
|
24
|
-
spinner.fail('Carpeta de cubes no encontrada');
|
|
25
|
-
throw new Error('❌ The cubes folder does not exist');
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// Leer todos los archivos en la carpeta
|
|
29
|
-
const cubeFiles = FileUtils.getCubeFilesRecursively('dbcube', 'table.cube')
|
|
30
|
-
|
|
31
|
-
if (cubeFiles.length === 0) {
|
|
32
|
-
spinner.fail('No hay cubes para ejecutar');
|
|
33
|
-
throw new Error('❌ There are no cubes to execute');
|
|
34
|
-
} else {
|
|
35
|
-
spinner.succeed('Cubes encontrados correctamente');
|
|
36
|
-
|
|
37
|
-
const loadingSpinner = ora('Cargando configuraciones de base de datos...').start();
|
|
38
|
-
let countTableCreated = 0;
|
|
39
|
-
const configuredDatabases = await ConfigFileUtils.getConfiguredDatabases();
|
|
40
|
-
loadingSpinner.succeed(`Configuraciones cargadas (${configuredDatabases.length} bases de datos)`);
|
|
41
|
-
|
|
42
|
-
// Recorrer cada archivo y mostrar su contenido
|
|
43
|
-
for (const config of configuredDatabases) {
|
|
44
|
-
const triggerSpinner = ora(`Ejecutando triggers para: ${config.name} (${config.type})...`).start();
|
|
45
|
-
const schema = new Schema(config.name);
|
|
46
|
-
await schema.executeTriggers();
|
|
47
|
-
triggerSpinner.succeed(`Triggers ejecutados para: ${config.name}`);
|
|
48
|
-
countTableCreated++;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if(countTableCreated==0) {
|
|
52
|
-
console.log(`\n⚠️ ${chalk.yellow('No hay triggers para ejecutar.')}`);
|
|
53
|
-
} else {
|
|
54
|
-
console.log(`\n🎉 ${chalk.green(`Triggers ejecutados exitosamente en ${countTableCreated} base(s) de datos!`)}`);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
} catch (error) {
|
|
59
|
-
if(error.message.includes("reading 'init'")){
|
|
60
|
-
console.error('❌ Configuracion de base de datos no encontrada\n');
|
|
61
|
-
console.error('Ejecute el comando para crear una nueva base de datos:');
|
|
62
|
-
console.error(`\tdbcube run create:database`);
|
|
63
|
-
console.error('\nO verifique que la base de datos este configurada en el archivo dbcube.config.js\n');
|
|
64
|
-
process.exit(1);
|
|
65
|
-
} else if(error.message.includes("reading 'getDatabase'")){
|
|
66
|
-
console.error('- Se sugiere cambiar el linea o crear la base de datos a la que se hace referencia.');
|
|
67
|
-
}else{
|
|
68
|
-
console.error('Error aqui:', error);
|
|
69
|
-
console.error('Error aqui:', error.message);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
console.log('\n');
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// Ejecutar el ejemplo
|
|
1
|
+
const { default: Schema } = require('@dbcube/schema-builder');
|
|
2
|
+
const ConfigFileUtils = require('./../../../utils/ConfigFileUtils');
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const FileUtils = require('./../../../utils/FileUtils');
|
|
6
|
+
const { default: chalk } = require('chalk');
|
|
7
|
+
const { default: ora } = require('ora');
|
|
8
|
+
const { default: alwait } = require('alwait');
|
|
9
|
+
|
|
10
|
+
async function main() {
|
|
11
|
+
// Suprimir logs de dotenv
|
|
12
|
+
process.env.DOTENV_SILENT = 'true';
|
|
13
|
+
|
|
14
|
+
console.clear();
|
|
15
|
+
console.log(`\n⚡ ${chalk.green("Ejecutando triggers...")}`);
|
|
16
|
+
try {
|
|
17
|
+
// Verificar y leer archivos de la carpeta cubes
|
|
18
|
+
const spinner = ora('Preparando ejecución de triggers...').start();
|
|
19
|
+
await alwait(500);
|
|
20
|
+
const cubesDir = path.join(process.cwd(), 'dbcube', 'cubes');
|
|
21
|
+
|
|
22
|
+
// Verificar si la carpeta existe
|
|
23
|
+
if (!fs.existsSync(cubesDir)) {
|
|
24
|
+
spinner.fail('Carpeta de cubes no encontrada');
|
|
25
|
+
throw new Error('❌ The cubes folder does not exist');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Leer todos los archivos en la carpeta
|
|
29
|
+
const cubeFiles = FileUtils.getCubeFilesRecursively('dbcube', 'table.cube')
|
|
30
|
+
|
|
31
|
+
if (cubeFiles.length === 0) {
|
|
32
|
+
spinner.fail('No hay cubes para ejecutar');
|
|
33
|
+
throw new Error('❌ There are no cubes to execute');
|
|
34
|
+
} else {
|
|
35
|
+
spinner.succeed('Cubes encontrados correctamente');
|
|
36
|
+
|
|
37
|
+
const loadingSpinner = ora('Cargando configuraciones de base de datos...').start();
|
|
38
|
+
let countTableCreated = 0;
|
|
39
|
+
const configuredDatabases = await ConfigFileUtils.getConfiguredDatabases();
|
|
40
|
+
loadingSpinner.succeed(`Configuraciones cargadas (${configuredDatabases.length} bases de datos)`);
|
|
41
|
+
|
|
42
|
+
// Recorrer cada archivo y mostrar su contenido
|
|
43
|
+
for (const config of configuredDatabases) {
|
|
44
|
+
const triggerSpinner = ora(`Ejecutando triggers para: ${config.name} (${config.type})...`).start();
|
|
45
|
+
const schema = new Schema(config.name);
|
|
46
|
+
await schema.executeTriggers();
|
|
47
|
+
triggerSpinner.succeed(`Triggers ejecutados para: ${config.name}`);
|
|
48
|
+
countTableCreated++;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if(countTableCreated==0) {
|
|
52
|
+
console.log(`\n⚠️ ${chalk.yellow('No hay triggers para ejecutar.')}`);
|
|
53
|
+
} else {
|
|
54
|
+
console.log(`\n🎉 ${chalk.green(`Triggers ejecutados exitosamente en ${countTableCreated} base(s) de datos!`)}`);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
}
|
|
58
|
+
} catch (error) {
|
|
59
|
+
if(error.message.includes("reading 'init'")){
|
|
60
|
+
console.error('❌ Configuracion de base de datos no encontrada\n');
|
|
61
|
+
console.error('Ejecute el comando para crear una nueva base de datos:');
|
|
62
|
+
console.error(`\tdbcube run create:database`);
|
|
63
|
+
console.error('\nO verifique que la base de datos este configurada en el archivo dbcube.config.js\n');
|
|
64
|
+
process.exit(1);
|
|
65
|
+
} else if(error.message.includes("reading 'getDatabase'")){
|
|
66
|
+
console.error('- Se sugiere cambiar el linea o crear la base de datos a la que se hace referencia.');
|
|
67
|
+
}else{
|
|
68
|
+
console.error('Error aqui:', error);
|
|
69
|
+
console.error('Error aqui:', error.message);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
console.log('\n');
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Ejecutar el ejemplo
|
|
76
76
|
main().catch(console.error);
|
|
@@ -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
|
-
|
|
70
|
-
console.log('
|
|
71
|
-
|
|
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
|
}
|
package/src/utils/FileUtils.js
CHANGED
|
@@ -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
|
}
|