@dbcube/cli 1.1.38 → 1.1.40
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.
|
|
3
|
+
"version": "1.1.40",
|
|
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.51",
|
|
17
17
|
"@inquirer/prompts": "^7.8.4",
|
|
18
18
|
"alwait": "^1.0.0",
|
|
19
19
|
"chalk": "^5.6.2",
|
|
@@ -1,75 +1,29 @@
|
|
|
1
1
|
const { default: Schema } = require('@dbcube/schema-builder');
|
|
2
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
3
|
|
|
10
4
|
async function main() {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
console.clear();
|
|
15
|
-
console.log(`\n🌱 ${chalk.green("Ejecutando seeders...")}`);
|
|
16
|
-
try {
|
|
17
|
-
// Verificar y leer archivos de la carpeta cubes
|
|
18
|
-
const spinner = ora('Preparando ejecución de seeders...').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 seederSpinner = ora(`Ejecutando seeders para: ${config.name} (${config.type})...`).start();
|
|
45
|
-
const schema = new Schema(config.name);
|
|
46
|
-
await schema.executeSeeders();
|
|
47
|
-
seederSpinner.succeed(`Seeders ejecutados para: ${config.name}`);
|
|
48
|
-
countTableCreated++;
|
|
49
|
-
}
|
|
5
|
+
try {
|
|
6
|
+
const configuredDatabases = await ConfigFileUtils.getConfiguredDatabases();
|
|
50
7
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
|
-
}
|
|
8
|
+
// Recorrer cada archivo y mostrar su contenido
|
|
9
|
+
for (const config of configuredDatabases) {
|
|
10
|
+
const schema = new Schema(config.name);
|
|
11
|
+
await schema.executeSeeders();
|
|
71
12
|
}
|
|
72
|
-
|
|
13
|
+
} catch (error) {
|
|
14
|
+
if (error.message.includes("reading 'init'")) {
|
|
15
|
+
console.error('❌ Configuracion de base de datos no encontrada\n');
|
|
16
|
+
console.error('Ejecute el comando para crear una nueva base de datos:');
|
|
17
|
+
console.error(`\tdbcube run create:database`);
|
|
18
|
+
console.error('\nO verifique que la base de datos este configurada en el archivo dbcube.config.js\n');
|
|
19
|
+
process.exit(1);
|
|
20
|
+
} else if (error.message.includes("reading 'getDatabase'")) {
|
|
21
|
+
console.error('- Se sugiere cambiar el linea o crear la base de datos a la que se hace referencia.');
|
|
22
|
+
} else {
|
|
23
|
+
console.error('Error aqui:', error);
|
|
24
|
+
console.error('Error aqui:', error.message);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
73
27
|
}
|
|
74
28
|
|
|
75
29
|
// Ejecutar el ejemplo
|
|
@@ -1,75 +1,30 @@
|
|
|
1
1
|
const { default: Schema } = require('@dbcube/schema-builder');
|
|
2
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
3
|
|
|
10
4
|
async function main() {
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
}
|
|
5
|
+
try {
|
|
6
|
+
const configuredDatabases = await ConfigFileUtils.getConfiguredDatabases();
|
|
50
7
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
|
-
}
|
|
8
|
+
// Recorrer cada archivo y mostrar su contenido
|
|
9
|
+
for (const config of configuredDatabases) {
|
|
10
|
+
const schema = new Schema(config.name);
|
|
11
|
+
await schema.executeTriggers();
|
|
71
12
|
}
|
|
72
|
-
|
|
13
|
+
} catch (error) {
|
|
14
|
+
if (error.message.includes("reading 'init'")) {
|
|
15
|
+
console.error('❌ Configuracion de base de datos no encontrada\n');
|
|
16
|
+
console.error('Ejecute el comando para crear una nueva base de datos:');
|
|
17
|
+
console.error(`\tdbcube run create:database`);
|
|
18
|
+
console.error('\nO verifique que la base de datos este configurada en el archivo dbcube.config.js\n');
|
|
19
|
+
process.exit(1);
|
|
20
|
+
} else if (error.message.includes("reading 'getDatabase'")) {
|
|
21
|
+
console.error('- Se sugiere cambiar el linea o crear la base de datos a la que se hace referencia.');
|
|
22
|
+
} else {
|
|
23
|
+
console.error('Error aqui:', error);
|
|
24
|
+
console.error('Error aqui:', error.message);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
console.log('\n');
|
|
73
28
|
}
|
|
74
29
|
|
|
75
30
|
// Ejecutar el ejemplo
|