utn-cli 2.0.75 → 2.0.77
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/commands/db.js
CHANGED
|
@@ -92,16 +92,40 @@ export async function updateDb(opciones = { cerrarAlFinalizar: true }) {
|
|
|
92
92
|
process.exit(1);
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
+
// Intentar recuperar el nombre del repositorio/base de datos antes de sobrescribir docker-compose.yml
|
|
96
|
+
const rutaCompose = path.join(directorioDestino, 'docker-compose.yml');
|
|
97
|
+
const rutaEstructuraDestino = path.join(directorioDestino, 'docker-scripts/1-crear estructura.sql');
|
|
98
|
+
let nombreRepositorio = '';
|
|
99
|
+
|
|
100
|
+
if (fs.existsSync(rutaCompose)) {
|
|
101
|
+
const contenidoCompose = fs.readFileSync(rutaCompose, 'utf-8');
|
|
102
|
+
const matchCompose = contenidoCompose.match(/^\s*(\S+):\s*\n\s*image:\s*mariadb:lts/m);
|
|
103
|
+
if (matchCompose && matchCompose[1]) {
|
|
104
|
+
nombreRepositorio = matchCompose[1];
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (!nombreRepositorio && fs.existsSync(rutaEstructuraDestino)) {
|
|
109
|
+
const contenidoEstructura = fs.readFileSync(rutaEstructuraDestino, 'utf-8');
|
|
110
|
+
const matchDb = contenidoEstructura.match(/CREATE DATABASE `(.+?)`/);
|
|
111
|
+
if (matchDb && matchDb[1]) {
|
|
112
|
+
nombreRepositorio = matchDb[1];
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
95
116
|
// Copiar todos los archivos excepto la estructura base
|
|
96
117
|
copiarDirectorios(directoriodePlantillas, directorioDestino, archivosAExcluir);
|
|
97
118
|
|
|
119
|
+
if (nombreRepositorio) {
|
|
120
|
+
reemplazarContenidoEnArchivo(rutaCompose, 'NOMBRE_DEL_REPOSITORIO_DE_BASE_DE_DATOS', nombreRepositorio);
|
|
121
|
+
}
|
|
122
|
+
|
|
98
123
|
const gitignorePath = path.join(directorioDestino, 'cumulodb-scripts/gitignore');
|
|
99
124
|
if (fs.existsSync(gitignorePath)) {
|
|
100
125
|
fs.renameSync(gitignorePath, path.join(directorioDestino, 'cumulodb-scripts/.gitignore'));
|
|
101
126
|
}
|
|
102
127
|
|
|
103
128
|
// Lógica de merge para 1-crear estructura.sql
|
|
104
|
-
const rutaEstructuraDestino = path.join(directorioDestino, 'docker-scripts/1-crear estructura.sql');
|
|
105
129
|
const rutaEstructuraFuente = path.join(directoriodePlantillas, 'docker-scripts/1-crear estructura.sql');
|
|
106
130
|
|
|
107
131
|
if (fs.existsSync(rutaEstructuraDestino) && fs.existsSync(rutaEstructuraFuente)) {
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@ class ConfiguracionDeTarjetas {
|
|
|
7
7
|
|
|
8
8
|
async obtener(Datos) {
|
|
9
9
|
return await ejecutarConsulta(
|
|
10
|
-
"SELECT Titulo, Posicion, ColorDeBorde FROM `
|
|
10
|
+
"SELECT Titulo, Posicion, ColorDeBorde FROM `" + Miscelaneas.obtenerNombreLaBaseDeDatos() + "`.`ConfiguracionDeTarjetas` WHERE Identificador = ? ORDER BY Posicion",
|
|
11
11
|
[Datos.Identificador]
|
|
12
12
|
);
|
|
13
13
|
}
|
|
@@ -29,7 +29,7 @@ class ConfiguracionDeTarjetas {
|
|
|
29
29
|
});
|
|
30
30
|
|
|
31
31
|
const sql = "\
|
|
32
|
-
INSERT INTO `
|
|
32
|
+
INSERT INTO `" + Miscelaneas.obtenerNombreLaBaseDeDatos() + "`.`ConfiguracionDeTarjetas` \
|
|
33
33
|
(Identificador, Titulo, Posicion, ColorDeBorde, LastUpdate, LastUser) \
|
|
34
34
|
VALUES " + placeholders.join(', ') +
|
|
35
35
|
" ON DUPLICATE KEY UPDATE \
|