utn-cli 2.1.10 → 2.1.12
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,53 @@
|
|
|
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 runGlobalBackup() {
|
|
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}] Agregando cambios...`);
|
|
28
|
+
try {
|
|
29
|
+
execSync('git add .', { stdio: 'inherit' });
|
|
30
|
+
} catch {
|
|
31
|
+
console.error(`[${dir.name}] Error al ejecutar git add. Continuando...`);
|
|
32
|
+
process.chdir(currentDir);
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
console.log(`[${dir.name}] Realizando commit de respaldo...`);
|
|
37
|
+
try {
|
|
38
|
+
execSync('git commit -m "* NEW: Respaldo de código"', { stdio: 'inherit' });
|
|
39
|
+
} catch {
|
|
40
|
+
console.log(`[${dir.name}] Sin cambios para hacer commit o el commit falló.`);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
process.chdir(currentDir);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (!encontroAlguno) {
|
|
47
|
+
console.log('No se encontraron repositorios Git en los directorios actuales.');
|
|
48
|
+
} else {
|
|
49
|
+
console.log('\nRespaldo finalizado en todos los repositorios.');
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
closeReadLine();
|
|
53
|
+
}
|
package/index.js
CHANGED
|
@@ -9,6 +9,7 @@ import { initBackend, updateBackend, addServiceBackend, showBackendVersion } fro
|
|
|
9
9
|
import { initFrontend, updateFrontend, cloneFrontendComponent, showFrontendVersion } from './commands/frontend.js';
|
|
10
10
|
import { runGlobalUpdate } from './commands/update.js';
|
|
11
11
|
import { runGlobalPull } from './commands/pull.js';
|
|
12
|
+
import { runGlobalBackup } from './commands/backup.js';
|
|
12
13
|
import { createComponent } from './commands/createComponent.js';
|
|
13
14
|
import { runCommit } from './commands/commit.js';
|
|
14
15
|
|
|
@@ -112,6 +113,13 @@ program.command('pull')
|
|
|
112
113
|
await runGlobalPull();
|
|
113
114
|
});
|
|
114
115
|
|
|
116
|
+
// Define 'backup' command
|
|
117
|
+
program.command('backup')
|
|
118
|
+
.description('Recorre los directorios y realiza un commit de respaldo con el mensaje "* NEW: Respaldo de código" en cada repositorio Git.')
|
|
119
|
+
.action(async () => {
|
|
120
|
+
await runGlobalBackup();
|
|
121
|
+
});
|
|
122
|
+
|
|
115
123
|
// Define 'create-component' command
|
|
116
124
|
program.command('create-component')
|
|
117
125
|
.description('Crea un nuevo servicio en el backend y un componente en el frontend simultáneamente.')
|
package/package.json
CHANGED
|
@@ -268,7 +268,7 @@ class Miscelaneo {
|
|
|
268
268
|
try {
|
|
269
269
|
const titulo = tarjeta['Título'];
|
|
270
270
|
const existentes = await ejecutarConsultaSIGU(
|
|
271
|
-
`SELECT CAST(JSON_VALUE(\`Datos\`, '$."Posición"') AS UNSIGNED) AS Posicion, JSON_VALUE(\`Datos\`, '$."Título"') AS Titulo, JSON_VALUE(\`Datos\`, '$."Descripción"') AS Descripcion FROM \`SIGU\`.\`
|
|
271
|
+
`SELECT CAST(JSON_VALUE(\`Datos\`, '$."Posición"') AS UNSIGNED) AS Posicion, JSON_VALUE(\`Datos\`, '$."Título"') AS Titulo, JSON_VALUE(\`Datos\`, '$."Descripción"') AS Descripcion FROM \`SIGU\`.\`SIGU_ModulosV2Tarjetas\` WHERE \`Modulo\` = ? AND JSON_VALUE(\`Datos\`, '$."Título"') = ?`,
|
|
272
272
|
[this.NombreCanonicoDelModulo, titulo]
|
|
273
273
|
);
|
|
274
274
|
|
|
@@ -276,21 +276,21 @@ class Miscelaneo {
|
|
|
276
276
|
if (existentes.length > 0) {
|
|
277
277
|
datosFinales = { ...tarjeta, 'Posición': existentes[0].Posicion, 'Título': existentes[0].Titulo, 'Descripción': existentes[0].Descripcion, 'Archivo': archivo };
|
|
278
278
|
await ejecutarConsultaSIGU(
|
|
279
|
-
`UPDATE \`SIGU\`.\`
|
|
279
|
+
`UPDATE \`SIGU\`.\`SIGU_ModulosV2Tarjetas\` SET \`Datos\` = ?, \`LastUser\` = 'Sistema' WHERE \`Modulo\` = ? AND JSON_VALUE(\`Datos\`, '$."Título"') = ?`,
|
|
280
280
|
[JSON.stringify(datosFinales), this.NombreCanonicoDelModulo, titulo]
|
|
281
281
|
);
|
|
282
282
|
} else {
|
|
283
283
|
let posicion = tarjeta['Posición'];
|
|
284
284
|
if (posicion === undefined) {
|
|
285
285
|
const [{ NuevaPosicion }] = await ejecutarConsultaSIGU(
|
|
286
|
-
`SELECT COALESCE(MAX(CAST(JSON_VALUE(\`Datos\`, '$."Posición"') AS UNSIGNED)), 0) + 10 AS NuevaPosicion FROM \`SIGU\`.\`
|
|
286
|
+
`SELECT COALESCE(MAX(CAST(JSON_VALUE(\`Datos\`, '$."Posición"') AS UNSIGNED)), 0) + 10 AS NuevaPosicion FROM \`SIGU\`.\`SIGU_ModulosV2Tarjetas\` WHERE \`Modulo\` = ?`,
|
|
287
287
|
[this.NombreCanonicoDelModulo]
|
|
288
288
|
);
|
|
289
289
|
posicion = NuevaPosicion;
|
|
290
290
|
}
|
|
291
291
|
datosFinales = { ...tarjeta, 'Posición': posicion, 'Archivo': archivo };
|
|
292
292
|
await ejecutarConsultaSIGU(
|
|
293
|
-
`INSERT INTO \`SIGU\`.\`
|
|
293
|
+
`INSERT INTO \`SIGU\`.\`SIGU_ModulosV2Tarjetas\` (\`Modulo\`, \`Datos\`, \`LastUser\`) VALUES (?, ?, 'Sistema')`,
|
|
294
294
|
[this.NombreCanonicoDelModulo, JSON.stringify(datosFinales)]
|
|
295
295
|
);
|
|
296
296
|
}
|
|
@@ -2497,7 +2497,7 @@ class Miscelaneo {
|
|
|
2497
2497
|
|
|
2498
2498
|
async obtenerTarjetas() {
|
|
2499
2499
|
const resultados = await ejecutarConsultaSIGU(
|
|
2500
|
-
"SELECT `Datos` FROM `SIGU`.`
|
|
2500
|
+
"SELECT `Datos` FROM `SIGU`.`SIGU_ModulosV2Tarjetas` WHERE `Modulo` = ? AND JSON_EXTRACT(`Datos`, '$.Activa') = TRUE",
|
|
2501
2501
|
[this.NombreCanonicoDelModulo]
|
|
2502
2502
|
);
|
|
2503
2503
|
return resultados.map(fila => typeof fila.Datos === 'string' ? JSON.parse(fila.Datos) : fila.Datos);
|