utn-cli 2.0.74 → 2.0.76
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/backend.js
CHANGED
|
@@ -190,25 +190,26 @@ function mergeRutasBackend(rutaDestino, rutaFuente) {
|
|
|
190
190
|
let contenidoDestino = fs.readFileSync(rutaDestino, 'utf-8');
|
|
191
191
|
const contenidoFuente = fs.readFileSync(rutaFuente, 'utf-8');
|
|
192
192
|
|
|
193
|
-
// Extraer requires de la fuente
|
|
194
|
-
const requiresFuente = contenidoFuente.match(
|
|
193
|
+
// Extraer requires de la fuente (solo líneas no comentadas)
|
|
194
|
+
const requiresFuente = contenidoFuente.match(/^\s*const .* = require\(.*\);/gm) || [];
|
|
195
195
|
requiresFuente.forEach(req => {
|
|
196
|
-
if (!contenidoDestino.includes(req)) {
|
|
196
|
+
if (!contenidoDestino.includes(req.trim())) {
|
|
197
197
|
// Insertar el nuevo require antes de la función asignarRutasAExpress
|
|
198
|
-
contenidoDestino = contenidoDestino.replace(/function asignarRutasAExpress/, `${req}\nfunction asignarRutasAExpress`);
|
|
198
|
+
contenidoDestino = contenidoDestino.replace(/function asignarRutasAExpress/, `${req.trim()}\nfunction asignarRutasAExpress`);
|
|
199
199
|
}
|
|
200
200
|
});
|
|
201
201
|
|
|
202
|
-
// Extraer app.use de la fuente
|
|
203
|
-
const usesFuente = contenidoFuente.match(
|
|
202
|
+
// Extraer app.use de la fuente (solo líneas no comentadas)
|
|
203
|
+
const usesFuente = contenidoFuente.match(/^\s*app\.use\(.*\);/gm) || [];
|
|
204
204
|
usesFuente.forEach(use => {
|
|
205
|
+
const useTrimmed = use.trim();
|
|
205
206
|
// Limpiar espacios para comparar
|
|
206
|
-
const useNormalizado =
|
|
207
|
+
const useNormalizado = useTrimmed.replace(/\s/g, '');
|
|
207
208
|
const contenidoDestinoNormalizado = contenidoDestino.replace(/\s/g, '');
|
|
208
209
|
|
|
209
210
|
if (!contenidoDestinoNormalizado.includes(useNormalizado)) {
|
|
210
211
|
// Insertar el nuevo app.use al final de la función asignarRutasAExpress
|
|
211
|
-
contenidoDestino = contenidoDestino.replace(/(function asignarRutasAExpress\(app\) \{[\s\S]*?)(\n\})/, `$1 ${
|
|
212
|
+
contenidoDestino = contenidoDestino.replace(/(function asignarRutasAExpress\(app\) \{[\s\S]*?)(\n\})/, `$1 ${useTrimmed}$2`);
|
|
212
213
|
}
|
|
213
214
|
});
|
|
214
215
|
|
package/commands/frontend.js
CHANGED
|
@@ -84,12 +84,13 @@ function mergeRoutesFrontend(rutaDestino, rutaFuente) {
|
|
|
84
84
|
let contenidoDestino = fs.readFileSync(rutaDestino, 'utf-8');
|
|
85
85
|
const contenidoFuente = fs.readFileSync(rutaFuente, 'utf-8');
|
|
86
86
|
|
|
87
|
-
// Extraer imports de la fuente
|
|
88
|
-
const importsFuente = contenidoFuente.match(
|
|
87
|
+
// Extraer imports de la fuente (solo líneas no comentadas)
|
|
88
|
+
const importsFuente = contenidoFuente.match(/^\s*import \{ .* \} from '.*';/gm) || [];
|
|
89
89
|
importsFuente.forEach(imp => {
|
|
90
|
-
|
|
90
|
+
const impTrimmed = imp.trim();
|
|
91
|
+
if (!contenidoDestino.includes(impTrimmed)) {
|
|
91
92
|
// Insertar el nuevo import al inicio del archivo
|
|
92
|
-
contenidoDestino =
|
|
93
|
+
contenidoDestino = impTrimmed + '\n' + contenidoDestino;
|
|
93
94
|
}
|
|
94
95
|
});
|
|
95
96
|
|
|
@@ -97,13 +98,21 @@ function mergeRoutesFrontend(rutaDestino, rutaFuente) {
|
|
|
97
98
|
const matchFuente = contenidoFuente.match(/export const routes: Routes = \[\s*([\s\S]*?)\s*\];/);
|
|
98
99
|
if (matchFuente) {
|
|
99
100
|
const rutasFuenteStr = matchFuente[1];
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
101
|
+
|
|
102
|
+
// Mejorar la separación de objetos de ruta, ignorando líneas comentadas
|
|
103
|
+
const rutasFuenteArray = rutasFuenteStr.split('\n')
|
|
104
|
+
.map(linea => linea.trim())
|
|
105
|
+
.filter(linea => linea.length > 0 && !linea.startsWith('//'))
|
|
106
|
+
.join('\n')
|
|
107
|
+
.split(/},\s*{/)
|
|
108
|
+
.map((r, i, a) => {
|
|
109
|
+
let res = r.trim();
|
|
110
|
+
if (!res.startsWith('{')) res = '{ ' + res;
|
|
111
|
+
if (!res.endsWith('}')) res = res + ' }';
|
|
112
|
+
// Quitar comas sobrantes al final de cada objeto individual si existen
|
|
113
|
+
if (res.endsWith('},')) res = res.slice(0, -1);
|
|
114
|
+
return res;
|
|
115
|
+
});
|
|
107
116
|
|
|
108
117
|
rutasFuenteArray.forEach(ruta => {
|
|
109
118
|
// Limpiar espacios para comparar
|
|
@@ -117,9 +126,9 @@ function mergeRoutesFrontend(rutaDestino, rutaFuente) {
|
|
|
117
126
|
const textoAntesDeCierre = contenidoDestino.slice(0, cierreArray).trimEnd();
|
|
118
127
|
const necesitaComa = !textoAntesDeCierre.endsWith(',') && !textoAntesDeCierre.endsWith('[');
|
|
119
128
|
|
|
120
|
-
contenidoDestino = contenidoDestino.slice(0, cierreArray) +
|
|
121
|
-
(necesitaComa ? '
|
|
122
|
-
ruta + '\n' +
|
|
129
|
+
contenidoDestino = contenidoDestino.slice(0, cierreArray).trimEnd() +
|
|
130
|
+
(necesitaComa ? ',\n' : '\n') +
|
|
131
|
+
' ' + ruta + '\n' +
|
|
123
132
|
contenidoDestino.slice(cierreArray);
|
|
124
133
|
}
|
|
125
134
|
}
|
|
@@ -364,13 +373,13 @@ function actualizarArchivosConfiguracion(nombreClase, nombreRuta, titulo, descri
|
|
|
364
373
|
if (!contenidoRoutes.includes(`path: '${nombreRuta}'`)) {
|
|
365
374
|
const cierreArray = contenidoRoutes.lastIndexOf('];');
|
|
366
375
|
if (cierreArray !== -1) {
|
|
367
|
-
const nuevaRuta = `
|
|
376
|
+
const nuevaRuta = `{ path: '${nombreRuta}', component: ${nombreClase} }`;
|
|
368
377
|
const textoAntesDeCierre = contenidoRoutes.slice(0, cierreArray).trimEnd();
|
|
369
378
|
const necesitaComa = !textoAntesDeCierre.endsWith(',') && !textoAntesDeCierre.endsWith('[');
|
|
370
379
|
|
|
371
|
-
contenidoRoutes = contenidoRoutes.slice(0, cierreArray) +
|
|
372
|
-
(necesitaComa ? '
|
|
373
|
-
nuevaRuta + '\n' +
|
|
380
|
+
contenidoRoutes = contenidoRoutes.slice(0, cierreArray).trimEnd() +
|
|
381
|
+
(necesitaComa ? ',\n' : '\n') +
|
|
382
|
+
' ' + nuevaRuta + '\n' +
|
|
374
383
|
contenidoRoutes.slice(cierreArray);
|
|
375
384
|
|
|
376
385
|
fs.writeFileSync(rutaRoutes, contenidoRoutes);
|
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 \
|