utn-cli 2.0.93 → 2.0.94

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.
@@ -11,15 +11,27 @@ async function confirmarPaso(pregunta) {
11
11
  }
12
12
 
13
13
  export async function runCommit() {
14
- if (!await confirmarPaso('¿Ya realizó la revisión ortográfica del proyecto?')) return closeReadLine();
15
- if (!await confirmarPaso('¿Todos los endpoints hacen uso de la estrategia de "Mensajes"?')) return closeReadLine();
16
- if (!await confirmarPaso('¿Ya realizó el registro de los servicios?')) return closeReadLine();
17
- if (!await confirmarPaso('¿Ya realizó la revisión con Gemini?')) return closeReadLine();
18
- if (!await confirmarPaso('¿Todos los endpoints están en el archivo rest?')) return closeReadLine();
19
- if (!await confirmarPaso('¿Ya realizó el build del frontend?')) return closeReadLine();
20
- if (!await confirmarPaso('¿Ya realizó el update de los módulos de UTN?')) return closeReadLine();
21
- if (!await confirmarPaso('¿Ya revisó la visualización en móvil?')) return closeReadLine();
22
- if (!await confirmarPaso('¿Ya hizo el stage de todos los cambios?')) return closeReadLine();
14
+ const preguntas = [
15
+ '¿Ya realizó la revisión ortográfica del proyecto?',
16
+ '¿Todos los endpoints hacen uso de la estrategia de "Mensajes"?',
17
+ '¿Ya realizó el registro de los servicios?',
18
+ '¿Todos los endpoints están en el archivo rest?',
19
+ '¿Ya realizó el build del frontend?',
20
+ '¿Ya realizó el update de los módulos de UTN?',
21
+ '¿Ya revisó la visualización en móvil?',
22
+ '¿Ya hizo el stage de todos los cambios?',
23
+ '¿El archivo app.routes.ts hace uso de la estrategia de "Lazy Loading"?'
24
+ ];
25
+
26
+ // Mezclar preguntas aleatoriamente
27
+ for (let i = preguntas.length - 1; i > 0; i--) {
28
+ const j = Math.floor(Math.random() * (i + 1));
29
+ [preguntas[i], preguntas[j]] = [preguntas[j], preguntas[i]];
30
+ }
31
+
32
+ for (const pregunta of preguntas) {
33
+ if (!await confirmarPaso(pregunta)) return closeReadLine();
34
+ }
23
35
 
24
36
  try {
25
37
  console.log('Ejecutando git commit...');
package/commands/db.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { fileURLToPath } from 'url';
2
- import { limpiarDirectorioActual, copiarDirectorios, hacerPregunta, reemplazarContenidoEnArchivo, closeReadLine, mostrarVersion } from '../utils/index.js';
2
+ import { limpiarDirectorioActual, copiarDirectorios, hacerPregunta, hacerPreguntaTrim, reemplazarContenidoEnArchivo, closeReadLine, mostrarVersion } from '../utils/index.js';
3
3
  import path from 'path';
4
- import fs from 'fs'; // Import fs here
4
+ import fs from 'fs';
5
5
 
6
6
  const __filename = fileURLToPath(import.meta.url);
7
7
  const __dirname = path.dirname(__filename);
@@ -99,24 +99,32 @@ export async function updateDb(opciones = { cerrarAlFinalizar: true }) {
99
99
 
100
100
  if (fs.existsSync(rutaCompose)) {
101
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];
102
+ const lineas = contenidoCompose.split('\n');
103
+ let enServices = false;
104
+ for (const linea of lineas) {
105
+ if (linea.trim() === 'services:') {
106
+ enServices = true;
107
+ continue;
108
+ }
109
+ if (enServices) {
110
+ // Encontrar la primera línea que parezca un servicio (ignorando comentarios y otros servicios conocidos)
111
+ const match = linea.match(/^ ([A-Za-z0-9_-]+):/);
112
+ if (match && match[1] !== 'CumuloDB' && match[1] !== 'SIGU' && match[1] !== 'NOMBRE_DEL_REPOSITORIO_DE_BASE_DE_DATOS') {
113
+ nombreRepositorio = match[1];
114
+ break;
115
+ }
116
+ }
105
117
  }
106
118
  }
107
119
 
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
- }
120
+ if (!nombreRepositorio || nombreRepositorio === 'NOMBRE_DEL_REPOSITORIO_DE_BASE_DE_DATOS') {
121
+ nombreRepositorio = await hacerPreguntaTrim('No se pudo detectar el nombre del repositorio. ¿Cuál es el nombre del repositorio de base de datos?: ');
114
122
  }
115
123
 
116
124
  // Copiar todos los archivos excepto la estructura base
117
125
  copiarDirectorios(directoriodePlantillas, directorioDestino, archivosAExcluir);
118
126
 
119
- if (nombreRepositorio) {
127
+ if (nombreRepositorio && nombreRepositorio !== 'NOMBRE_DEL_REPOSITORIO_DE_BASE_DE_DATOS') {
120
128
  reemplazarContenidoEnArchivo(rutaCompose, 'NOMBRE_DEL_REPOSITORIO_DE_BASE_DE_DATOS', nombreRepositorio);
121
129
  }
122
130
 
@@ -99,27 +99,35 @@ function mergeRoutesFrontend(rutaDestino, rutaFuente) {
99
99
  if (matchFuente) {
100
100
  const rutasFuenteStr = matchFuente[1];
101
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
- });
102
+ // Mejorar la separación de objetos de ruta para manejar lazy loading y anidamiento básico
103
+ const rutasFuenteArray = [];
104
+ let balance = 0;
105
+ let inicio = 0;
106
+ for (let i = 0; i < rutasFuenteStr.length; i++) {
107
+ if (rutasFuenteStr[i] === '{') balance++;
108
+ if (rutasFuenteStr[i] === '}') {
109
+ balance--;
110
+ if (balance === 0) {
111
+ rutasFuenteArray.push(rutasFuenteStr.slice(inicio, i + 1).trim());
112
+ // Buscar el inicio del siguiente objeto (saltar comas y espacios)
113
+ let j = i + 1;
114
+ while (j < rutasFuenteStr.length && (rutasFuenteStr[j] === ',' || /\s/.test(rutasFuenteStr[j]))) {
115
+ j++;
116
+ }
117
+ inicio = j;
118
+ i = j - 1;
119
+ }
120
+ }
121
+ }
116
122
 
117
123
  rutasFuenteArray.forEach(ruta => {
118
- // Limpiar espacios para comparar
119
- const rutaNormalizada = ruta.replace(/\s/g, '');
120
- const contenidoDestinoNormalizado = contenidoDestino.replace(/\s/g, '');
121
-
122
- if (!contenidoDestinoNormalizado.includes(rutaNormalizada)) {
124
+ // Extraer el path para comparar y evitar duplicados por path en lugar de por contenido exacto
125
+ const pathMatch = ruta.match(/path:\s*['"](.*?)['"]/);
126
+ if (!pathMatch) return;
127
+ const pathValue = pathMatch[1];
128
+
129
+ const regexPath = new RegExp(`path:\\s*['"]${pathValue}['"]`);
130
+ if (!contenidoDestino.match(regexPath)) {
123
131
  // Insertar la nueva ruta antes del cierre del array
124
132
  const cierreArray = contenidoDestino.lastIndexOf('];');
125
133
  if (cierreArray !== -1) {
@@ -358,22 +366,14 @@ function actualizarArchivosConfiguracion(nombreClase, nombreRuta, titulo, descri
358
366
  if (fs.existsSync(rutaRoutes)) {
359
367
  let contenidoRoutes = fs.readFileSync(rutaRoutes, 'utf-8');
360
368
 
361
- const lineaImport = `import { ${nombreClase} } from './Paginas/${nombreRuta}/${nombreRuta}.component';`;
362
- if (!contenidoRoutes.includes(lineaImport)) {
363
- const ultimoImportIndex = contenidoRoutes.lastIndexOf('import {');
364
- const finUltimoImport = contenidoRoutes.indexOf(';', ultimoImportIndex);
365
-
366
- if (finUltimoImport !== -1) {
367
- contenidoRoutes = contenidoRoutes.slice(0, finUltimoImport + 1) + '\n' + lineaImport + contenidoRoutes.slice(finUltimoImport + 1);
368
- } else {
369
- contenidoRoutes = lineaImport + '\n' + contenidoRoutes;
370
- }
371
- }
372
-
369
+ // No agregamos import estático, usamos lazy loading
373
370
  if (!contenidoRoutes.includes(`path: '${nombreRuta}'`)) {
374
371
  const cierreArray = contenidoRoutes.lastIndexOf('];');
375
372
  if (cierreArray !== -1) {
376
- const nuevaRuta = `{ path: '${nombreRuta}', component: ${nombreClase} }`;
373
+ const nuevaRuta = `{
374
+ path: '${nombreRuta}',
375
+ loadComponent: () => import('./Paginas/${nombreRuta}/${nombreRuta}.component').then(m => m.${nombreClase})
376
+ }`;
377
377
  const textoAntesDeCierre = contenidoRoutes.slice(0, cierreArray).trimEnd();
378
378
  const necesitaComa = !textoAntesDeCierre.endsWith(',') && !textoAntesDeCierre.endsWith('[');
379
379
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "utn-cli",
3
- "version": "2.0.93",
3
+ "version": "2.0.94",
4
4
  "description": "Herramienta CLI unificada para la gestión de plantillas en SIGU.",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -1,18 +1,32 @@
1
1
  import { Routes } from '@angular/router';
2
- import { GestionActividadComponent } from './Componentes/Nucleo/gestion-actividad/gestion-actividad.component';
3
- import { GestionTablaComponent } from './Paginas/gestion-tabla/gestion-tabla.component';
4
- import { ContenedorPrincipalComponent } from './Paginas/contenedor-principal/contenedor-principal.component';
5
- import { GestionTablaJefeComponent } from './Paginas/gestion-tabla-jefe/gestion-tabla-jefe.component';
6
- import { GestionGraficosComponent } from './Paginas/gestion-graficos/gestion-graficos.component';
7
- import { GestionDeReportesComponent } from './Paginas/gestion-de-reportes/gestion-de-reportes.component';
8
- import { GestionIframe1Component } from './Paginas/gestion-iframe1/gestion-iframe1.component';
9
2
 
10
3
  export const routes: Routes = [
11
- { path: 'Actividad', component: GestionActividadComponent },
12
- { path: '', component: ContenedorPrincipalComponent },
13
- { path: 'tabla', component: GestionTablaComponent },
14
- { path: 'aprobaciones', component: GestionTablaJefeComponent},
15
- { path: 'graficoDeModulos', component: GestionGraficosComponent },
16
- { path: 'parametros-reportes', component: GestionDeReportesComponent },
17
- { path: 'gestionIframe1', component: GestionIframe1Component }
18
- ];
4
+ {
5
+ path: '',
6
+ loadComponent: () => import('./Paginas/contenedor-principal/contenedor-principal.component').then(m => m.ContenedorPrincipalComponent)
7
+ },
8
+ {
9
+ path: 'Actividad',
10
+ loadComponent: () => import('./Componentes/Nucleo/gestion-actividad/gestion-actividad.component').then(m => m.GestionActividadComponent)
11
+ },
12
+ {
13
+ path: 'tabla',
14
+ loadComponent: () => import('./Paginas/gestion-tabla/gestion-tabla.component').then(m => m.GestionTablaComponent)
15
+ },
16
+ {
17
+ path: 'aprobaciones',
18
+ loadComponent: () => import('./Paginas/gestion-tabla-jefe/gestion-tabla-jefe.component').then(m => m.GestionTablaJefeComponent)
19
+ },
20
+ {
21
+ path: 'graficoDeModulos',
22
+ loadComponent: () => import('./Paginas/gestion-graficos/gestion-graficos.component').then(m => m.GestionGraficosComponent)
23
+ },
24
+ {
25
+ path: 'parametros-reportes',
26
+ loadComponent: () => import('./Paginas/gestion-de-reportes/gestion-de-reportes.component').then(m => m.GestionDeReportesComponent)
27
+ },
28
+ {
29
+ path: 'gestionIframe1',
30
+ loadComponent: () => import('./Paginas/gestion-iframe1/gestion-iframe1.component').then(m => m.GestionIframe1Component)
31
+ }
32
+ ];