utn-cli 2.1.5 → 2.1.7

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.
@@ -42,7 +42,7 @@ export async function initFrontend() {
42
42
 
43
43
  export async function updateFrontend(opciones = { cerrarAlFinalizar: true }) {
44
44
  console.log('Actualizando el proyecto de frontend...');
45
- const archivosAExcluir = ['app.routes.ts', 'contenedor-principal.component.ts', '.vscode', 'dist', 'Manual.md'];
45
+ const archivosAExcluir = ['app.routes.ts', '.vscode', 'dist', 'Manual.md'];
46
46
  const directoriodePlantillas = path.join(__dirname, '../templates/frontend');
47
47
  const directorioDestino = process.cwd();
48
48
 
@@ -387,47 +387,47 @@ function actualizarArchivosConfiguracion(nombreClase, nombreRuta, titulo, descri
387
387
  }
388
388
  }
389
389
 
390
- // --- Modificar contenedor-principal.component.ts ---
391
- console.log('Actualizando contenedor-principal.component.ts...');
392
- const rutaTs = path.join(process.cwd(), 'src', 'app', 'Paginas', 'contenedor-principal', 'contenedor-principal.component.ts');
393
- if (fs.existsSync(rutaTs)) {
394
- let contenidoTs = fs.readFileSync(rutaTs, 'utf-8');
395
- if (!contenidoTs.includes(`rutaASeguir: '${nombreRuta}'`)) {
396
- // Encontrar el array baseTarjetas y su contenido
397
- const regexBaseTarjetas = /let baseTarjetas: AnyTarjetaConfig\[\] = \[([\s\S]*?)\];/;
398
- const match = contenidoTs.match(regexBaseTarjetas);
390
+ // // --- Modificar contenedor-principal.component.ts ---
391
+ // console.log('Actualizando contenedor-principal.component.ts...');
392
+ // const rutaTs = path.join(process.cwd(), 'src', 'app', 'Paginas', 'contenedor-principal', 'contenedor-principal.component.ts');
393
+ // if (fs.existsSync(rutaTs)) {
394
+ // let contenidoTs = fs.readFileSync(rutaTs, 'utf-8');
395
+ // if (!contenidoTs.includes(`rutaASeguir: '${nombreRuta}'`)) {
396
+ // // Encontrar el array baseTarjetas y su contenido
397
+ // const regexBaseTarjetas = /let baseTarjetas: AnyTarjetaConfig\[\] = \[([\s\S]*?)\];/;
398
+ // const match = contenidoTs.match(regexBaseTarjetas);
399
399
 
400
- if (match) {
401
- const contenidoArray = match[1];
402
- // Buscar la última posición para incrementar
403
- const regexPosiciones = /position: (\d+)/g;
404
- let ultimaPosicion = 0;
405
- let m;
406
- while ((m = regexPosiciones.exec(contenidoArray)) !== null) {
407
- const pos = parseInt(m[1]);
408
- if (pos > ultimaPosicion) ultimaPosicion = pos;
409
- }
410
- const nuevaPosicion = ultimaPosicion + 10;
411
-
412
- const nuevaTarjeta = `,
413
- {
414
- type: 'single',
415
- position: ${nuevaPosicion},
416
- rutaASeguir: '${nombreRuta}',
417
- titulo: '${titulo}',
418
- descripcion: '${descripcion}',
419
- icono: 'table_chart'
420
- }`;
421
-
422
- // Insertar antes del cierre del array (el ]; que sigue al contenidoArray)
423
- const indiceCierre = contenidoTs.indexOf('];', match.index);
424
- if (indiceCierre !== -1) {
425
- contenidoTs = contenidoTs.slice(0, indiceCierre).trimEnd() + nuevaTarjeta + '\n ' + contenidoTs.slice(indiceCierre);
426
- fs.writeFileSync(rutaTs, contenidoTs);
427
- }
428
- }
429
- }
430
- }
400
+ // if (match) {
401
+ // const contenidoArray = match[1];
402
+ // // Buscar la última posición para incrementar
403
+ // const regexPosiciones = /position: (\d+)/g;
404
+ // let ultimaPosicion = 0;
405
+ // let m;
406
+ // while ((m = regexPosiciones.exec(contenidoArray)) !== null) {
407
+ // const pos = parseInt(m[1]);
408
+ // if (pos > ultimaPosicion) ultimaPosicion = pos;
409
+ // }
410
+ // const nuevaPosicion = ultimaPosicion + 10;
411
+
412
+ // const nuevaTarjeta = `,
413
+ // {
414
+ // type: 'single',
415
+ // position: ${nuevaPosicion},
416
+ // rutaASeguir: '${nombreRuta}',
417
+ // titulo: '${titulo}',
418
+ // descripcion: '${descripcion}',
419
+ // icono: 'table_chart'
420
+ // }`;
421
+
422
+ // // Insertar antes del cierre del array (el ]; que sigue al contenidoArray)
423
+ // const indiceCierre = contenidoTs.indexOf('];', match.index);
424
+ // if (indiceCierre !== -1) {
425
+ // contenidoTs = contenidoTs.slice(0, indiceCierre).trimEnd() + nuevaTarjeta + '\n ' + contenidoTs.slice(indiceCierre);
426
+ // fs.writeFileSync(rutaTs, contenidoTs);
427
+ // }
428
+ // }
429
+ // }
430
+ // }
431
431
  }
432
432
 
433
433
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "utn-cli",
3
- "version": "2.1.5",
3
+ "version": "2.1.7",
4
4
  "description": "Herramienta CLI unificada para la gestión de plantillas en SIGU.",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -2528,18 +2528,16 @@ class Miscelaneo {
2528
2528
 
2529
2529
  async obtenerTarjetasDelContenedor(token) {
2530
2530
  const ConfiguracionDeTarjetas = require('./ConfiguracionDeTarjetas.js');
2531
- // const Personas = require('../Personas.js');
2532
2531
  const path = require('path');
2533
2532
  const serviciosDir = path.join(__dirname, '..');
2534
2533
 
2535
2534
  const usuario = await this.obtenerDatosDelUsuario(token);
2536
- const [tarjetas, configuracion, tienePermisoExtra] = await Promise.all([
2535
+ const [tarjetas, configuracion] = await Promise.all([
2537
2536
  this.obtenerTarjetas(),
2538
- ConfiguracionDeTarjetas.obtener({ Identificador: usuario.uid }),
2539
- // Personas.PermisoExtra(token)
2537
+ ConfiguracionDeTarjetas.obtener({ Identificador: usuario.uid })
2540
2538
  ]);
2541
2539
 
2542
- const cantidadesEntradas = await Promise.all(
2540
+ const datosDeServicio = await Promise.all(
2543
2541
  tarjetas
2544
2542
  .filter(t => t.Archivo)
2545
2543
  .map(async t => {
@@ -2547,23 +2545,25 @@ class Miscelaneo {
2547
2545
  const rutaArchivo = this._buscarArchivoRecursivo(serviciosDir, t.Archivo);
2548
2546
  if (!rutaArchivo) return null;
2549
2547
  const servicio = require(rutaArchivo);
2550
- if (typeof servicio.Cantidades !== 'function') return null;
2551
- const cantidades = await servicio.Cantidades(token);
2552
- return [t['Título'], cantidades];
2548
+ const [cantidades, tienePermisoExtra] = await Promise.all([
2549
+ typeof servicio.Cantidades === 'function' ? servicio.Cantidades(token) : null,
2550
+ typeof servicio.PermisoExtra === 'function' ? servicio.PermisoExtra(token) : null
2551
+ ]);
2552
+ return [t['Título'], { cantidades, tienePermisoExtra }];
2553
2553
  } catch { return null; }
2554
2554
  })
2555
2555
  );
2556
2556
 
2557
- const cantidadesPorTitulo = Object.fromEntries(cantidadesEntradas.filter(Boolean));
2557
+ const datosPorTitulo = Object.fromEntries(datosDeServicio.filter(Boolean));
2558
2558
 
2559
2559
  const titulosAExcluir = new Set(
2560
- Object.entries(cantidadesPorTitulo)
2561
- .filter(([, c]) => !(c.cantidadMaxima > 0))
2560
+ Object.entries(datosPorTitulo)
2561
+ .filter(([, { cantidades }]) => cantidades && !(cantidades.cantidadMaxima > 0))
2562
2562
  .map(([titulo]) => titulo)
2563
2563
  );
2564
2564
 
2565
2565
  return tarjetas
2566
- .filter(t => !t.RequierePermisoExtra || tienePermisoExtra)
2566
+ .filter(t => !t.RequierePermisoExtra || datosPorTitulo[t['Título']]?.tienePermisoExtra)
2567
2567
  .filter(t => !titulosAExcluir.has(t['Título']))
2568
2568
  .map(t => {
2569
2569
  const config = configuracion.find(c => c.Titulo === t['Título']);
@@ -2571,10 +2571,10 @@ class Miscelaneo {
2571
2571
  t['Posición'] = config.Posicion;
2572
2572
  if (config.ColorDeBorde) t.ColorDeBorde = config.ColorDeBorde;
2573
2573
  }
2574
- const cantidades = cantidadesPorTitulo[t['Título']];
2575
- if (cantidades) {
2576
- t['Cantidad'] = cantidades.cantidad;
2577
- t['CantidadMaxima'] = cantidades.cantidadMaxima;
2574
+ const datos = datosPorTitulo[t['Título']];
2575
+ if (datos?.cantidades) {
2576
+ t['Cantidad'] = datos.cantidades.cantidad;
2577
+ t['CantidadMaxima'] = datos.cantidades.cantidadMaxima;
2578
2578
  }
2579
2579
  return t;
2580
2580
  })