utn-cli 2.1.6 → 2.1.8

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.
@@ -0,0 +1,51 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import { closeReadLine } from '../utils/index.js';
4
+ import { execSync } from 'child_process';
5
+
6
+ export async function runGlobalPull() {
7
+ const currentDir = process.cwd();
8
+ const entries = fs.readdirSync(currentDir, { withFileTypes: true });
9
+ const directories = entries.filter(entry => entry.isDirectory());
10
+
11
+ if (directories.length === 0) {
12
+ console.log('No se encontraron directorios en la carpeta actual.');
13
+ closeReadLine();
14
+ return;
15
+ }
16
+
17
+ let encontroAlguno = false;
18
+
19
+ for (const dir of directories) {
20
+ const fullPath = path.join(currentDir, dir.name);
21
+
22
+ if (!fs.existsSync(path.join(fullPath, '.git'))) continue;
23
+
24
+ encontroAlguno = true;
25
+ process.chdir(fullPath);
26
+
27
+ console.log(`\n[${dir.name}] Asegurando rama 'desarrollo'...`);
28
+ try {
29
+ execSync('git checkout desarrollo', { stdio: 'inherit' });
30
+ } catch {
31
+ console.error(`[${dir.name}] Error al cambiar a la rama 'desarrollo'. Continuando...`);
32
+ }
33
+
34
+ console.log(`[${dir.name}] Ejecutando git pull...`);
35
+ try {
36
+ execSync('git pull', { stdio: 'inherit' });
37
+ } catch {
38
+ console.error(`[${dir.name}] Error al ejecutar git pull. Continuando...`);
39
+ }
40
+
41
+ process.chdir(currentDir);
42
+ }
43
+
44
+ if (!encontroAlguno) {
45
+ console.log('No se encontraron repositorios Git en los directorios actuales.');
46
+ } else {
47
+ console.log('\nPull finalizado en todos los repositorios.');
48
+ }
49
+
50
+ closeReadLine();
51
+ }
package/index.js CHANGED
@@ -8,6 +8,7 @@ import { initDb, addTableDb, showDbVersion, updateDb } from './commands/db.js';
8
8
  import { initBackend, updateBackend, addServiceBackend, showBackendVersion } from './commands/backend.js';
9
9
  import { initFrontend, updateFrontend, cloneFrontendComponent, showFrontendVersion } from './commands/frontend.js';
10
10
  import { runGlobalUpdate } from './commands/update.js';
11
+ import { runGlobalPull } from './commands/pull.js';
11
12
  import { createComponent } from './commands/createComponent.js';
12
13
  import { runCommit } from './commands/commit.js';
13
14
 
@@ -104,6 +105,13 @@ program.command('update')
104
105
  await runGlobalUpdate();
105
106
  });
106
107
 
108
+ // Define 'pull' command
109
+ program.command('pull')
110
+ .description('Recorre los directorios, cambia a la rama "desarrollo" y ejecuta git pull en cada repositorio Git.')
111
+ .action(async () => {
112
+ await runGlobalPull();
113
+ });
114
+
107
115
  // Define 'create-component' command
108
116
  program.command('create-component')
109
117
  .description('Crea un nuevo servicio en el backend y un componente en el frontend simultáneamente.')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "utn-cli",
3
- "version": "2.1.6",
3
+ "version": "2.1.8",
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
  })