utn-cli 2.0.17 → 2.0.19
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 +58 -54
- package/package.json +1 -1
- package/templates/backend/servicios/Nucleo/Miscelaneas.js +3 -2
- package/templates/frontend/src/app/Componentes/Nucleo/mensaje-confirmacion/mensaje-confirmacion.ts +1 -0
- package/templates/frontend/src/app/Componentes/Nucleo/mensaje-confirmacion-html/mensaje-confirmacion-html.ts +1 -0
- package/templates/frontend/src/app/Componentes/Nucleo/mensaje-informacion/mensaje-informacion.ts +1 -0
package/commands/backend.js
CHANGED
|
@@ -17,62 +17,66 @@ async function inicializarProyectoBackend() {
|
|
|
17
17
|
const rutaDeInformacionDelModuloJson = path.join(process.cwd(), 'InformacionDelModulo.json');
|
|
18
18
|
// Check if InformacionDelModulo.json exists, if not, it's an init scenario.
|
|
19
19
|
if (!fs.existsSync(rutaDeInformacionDelModuloJson)) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
console.error('InformacionDelModulo.json not found. This should be present after copying templates.');
|
|
21
|
+
closeReadLine();
|
|
22
|
+
process.exit(1);
|
|
23
23
|
}
|
|
24
24
|
let informacionDelModuloJson = JSON.parse(fs.readFileSync(rutaDeInformacionDelModuloJson, 'utf-8'));
|
|
25
25
|
const rutaDeInformacionDelModulo = path.join(process.cwd(), 'servicios/InformacionDelModulo.js');
|
|
26
26
|
|
|
27
27
|
// Helper to ask and replace
|
|
28
28
|
async function askAndReplace(prop, promptText, fileToReplace, placeholder, specialHandler = null) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
29
|
+
let value = informacionDelModuloJson[prop];
|
|
30
|
+
if (value === placeholder) {
|
|
31
|
+
value = await hacerPreguntaTrim(promptText);
|
|
32
|
+
informacionDelModuloJson[prop] = value;
|
|
33
|
+
}
|
|
34
|
+
if (specialHandler) {
|
|
35
|
+
specialHandler(value);
|
|
36
|
+
}
|
|
37
|
+
reemplazarContenidoEnArchivo(fileToReplace, placeholder, value);
|
|
38
|
+
return value;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
const NOMBRE_DEL_PROYECTO = await askAndReplace('NOMBRE_DEL_PROYECTO', '¿Cuál es el nombre del proyecto?: ', rutaDeInformacionDelModulo, 'NOMBRE_DEL_PROYECTO');
|
|
42
42
|
await askAndReplace('DESCRIPCION_DEL_PROYECTO', '¿Cuál es la descripción del proyecto?: ', rutaDeInformacionDelModulo, 'DESCRIPCION_DEL_PROYECTO');
|
|
43
43
|
await askAndReplace('DETALLE_DEL_PROYECTO', '¿Cuál es detalle del proyecto?: ', rutaDeInformacionDelModulo, 'DETALLE_DEL_PROYECTO');
|
|
44
|
-
|
|
44
|
+
|
|
45
45
|
const NOMBRE_DEL_CANONICO_DEL_PROYECTO = await askAndReplace('NOMBRE_DEL_CANONICO_DEL_PROYECTO', '¿Cuál es el nombre canónico del proyecto?: ', rutaDeInformacionDelModulo, 'NOMBRE_DEL_CANONICO_DEL_PROYECTO', (val) => {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
46
|
+
const oldFileName = path.join(process.cwd(), 'NOMBRE_DEL_CANONICO_DEL_PROYECTO.rest');
|
|
47
|
+
const newFileName = path.join(process.cwd(), `${val}.rest`);
|
|
48
|
+
if (fs.existsSync(newFileName)) {
|
|
49
|
+
// If the new file name already exists, do nothing.
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (fs.existsSync(oldFileName)) {
|
|
53
|
+
fs.renameSync(oldFileName, newFileName);
|
|
54
|
+
} else {
|
|
55
|
+
// If the old file doesn't exist and the new one doesn't exist, it might be an update scenario where it was already renamed.
|
|
56
|
+
// Or a fresh init where the file might not be present always. Log for now.
|
|
57
|
+
console.log(`Warning: ${oldFileName} not found during canonical project name rename.`);
|
|
58
|
+
}
|
|
55
59
|
});
|
|
56
60
|
|
|
57
61
|
await askAndReplace('TIPO_DE_TARJETA', '¿Cuál es tipo de tarjeta? Posibles valores: Área, Proceso, Servicio: ', rutaDeInformacionDelModulo, 'TIPO_DE_TARJETA');
|
|
58
62
|
await askAndReplace('NOMBRE_DEL_ROL', '¿Cuál es el nombre del rol?: ', rutaDeInformacionDelModulo, 'NOMBRE_DEL_ROL');
|
|
59
|
-
|
|
63
|
+
|
|
60
64
|
const NOMBRE_DEL_REPOSITORIO_DE_BASE_DE_DATOS = await askAndReplace('NOMBRE_DEL_REPOSITORIO_DE_BASE_DE_DATOS', '¿Cuál es el nombre del repositorio de base de datos?: ', rutaDeInformacionDelModulo, 'NOMBRE_DEL_REPOSITORIO_DE_BASE_DE_DATOS', (val) => {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
const rutaDeVariablesDeCalidad = path.join(process.cwd(), 'variables-calidad.env');
|
|
66
|
+
reemplazarContenidoEnArchivo(rutaDeVariablesDeCalidad, 'NOMBRE_DEL_REPOSITORIO_DE_BASE_DE_DATOS', val);
|
|
67
|
+
const rutaDeVariablesDeDesarrollo = path.join(process.cwd(), 'variables-desarrollo.env');
|
|
68
|
+
reemplazarContenidoEnArchivo(rutaDeVariablesDeDesarrollo, 'NOMBRE_DEL_REPOSITORIO_DE_BASE_DE_DATOS', val);
|
|
69
|
+
const rutaDeVariablesDePruebas = path.join(process.cwd(), 'variables-pruebas.env');
|
|
70
|
+
reemplazarContenidoEnArchivo(rutaDeVariablesDePruebas, 'NOMBRE_DEL_REPOSITORIO_DE_BASE_DE_DATOS', val);
|
|
71
|
+
const rutaDeDB = path.join(process.cwd(), 'servicios/Nucleo/db.js');
|
|
72
|
+
reemplazarContenidoEnArchivo(rutaDeDB, 'NOMBRE_DEL_REPOSITORIO_DE_BASE_DE_DATOS', val.slice(0, -3));
|
|
69
73
|
});
|
|
70
74
|
|
|
71
75
|
const NOMBRE_DEL_REPOSITORIO_DE_BACKEND = await askAndReplace('NOMBRE_DEL_REPOSITORIO_DE_BACKEND', '¿Cuál es el nombre del repositorio de backend?: ', rutaDeInformacionDelModulo, 'NOMBRE_DEL_REPOSITORIO_DE_BACKEND', (val) => {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
+
const rutaPackage = path.join(process.cwd(), 'package.json');
|
|
77
|
+
reemplazarContenidoEnArchivo(rutaPackage, 'nombre_del_repositorio_backend', val);
|
|
78
|
+
const rutaDeserver = path.join(process.cwd(), 'server.js');
|
|
79
|
+
reemplazarContenidoEnArchivo(rutaDeserver, 'NOMBRE_DEL_REPOSITORIO_DE_BACKEND', `${val} corriendo en el puerto 80.`);
|
|
76
80
|
});
|
|
77
81
|
|
|
78
82
|
await askAndReplace('NOMBRE_DEL_REPOSITORIO_DE_FRONTEND', '¿Cuál es el nombre del repositorio de frontend?: ', rutaDeInformacionDelModulo, 'NOMBRE_DEL_REPOSITORIO_DE_FRONTEND');
|
|
@@ -81,15 +85,15 @@ async function inicializarProyectoBackend() {
|
|
|
81
85
|
await askAndReplace('MENU_PADRE', '¿Cuál es nombre canónico del menú padre?: ', rutaDeInformacionDelModulo, 'MENU_PADRE');
|
|
82
86
|
await askAndReplace('COLOR_DEL_MODULO', '¿Cuál es el color del módulo?: ', rutaDeInformacionDelModulo, 'COLOR_DEL_MODULO');
|
|
83
87
|
await askAndReplace('CORRECO_PARA_REPORTES', '¿Cuál es correo para reportes?: ', rutaDeInformacionDelModulo, 'CORRECO_PARA_REPORTES');
|
|
84
|
-
|
|
88
|
+
|
|
85
89
|
const nombre_de_desarrollador = await askAndReplace('nombre_de_desarrollador', '¿Cuál es el nombre de desarrollador?: ', path.join(process.cwd(), 'package.json'), 'nombre_de_desarrollador', (val) => {
|
|
86
|
-
|
|
90
|
+
reemplazarContenidoEnArchivo(path.join(process.cwd(), 'package.json'), 'nombre_de_desarrollador', `Para la Universidad Técnica Nacional por: ${val}`);
|
|
87
91
|
});
|
|
88
92
|
|
|
89
93
|
await askAndReplace('CEDULA_DEL_DESARROLLADOR', '¿Cuál es el número de cédula del desarrollador?: ', rutaDeInformacionDelModulo, 'CEDULA_DEL_DESARROLLADOR');
|
|
90
|
-
|
|
94
|
+
|
|
91
95
|
const url_del_grupo = await askAndReplace('url_del_grupo', '¿Cuál es el URL del grupo en el git?: ', path.join(process.cwd(), 'package.json'), 'url_del_grupo', (val) => {
|
|
92
|
-
|
|
96
|
+
reemplazarContenidoEnArchivo(path.join(process.cwd(), 'package.json'), 'url_del_grupo', val);
|
|
93
97
|
});
|
|
94
98
|
|
|
95
99
|
let BACKENDS_QUE_CONSUME_ESTE_MODULO = informacionDelModuloJson.BACKENDS_QUE_CONSUME_ESTE_MODULO;
|
|
@@ -104,7 +108,7 @@ async function inicializarProyectoBackend() {
|
|
|
104
108
|
} else {
|
|
105
109
|
// Already set, but needs formatting for replacement if not empty
|
|
106
110
|
if (BACKENDS_QUE_CONSUME_ESTE_MODULO.trim().length > 0 && !BACKENDS_QUE_CONSUME_ESTE_MODULO.startsWith("'")) {
|
|
107
|
-
|
|
111
|
+
BACKENDS_QUE_CONSUME_ESTE_MODULO = BACKENDS_QUE_CONSUME_ESTE_MODULO.split(",").map((x) => "'" + x.trim() + "'").toString();
|
|
108
112
|
}
|
|
109
113
|
}
|
|
110
114
|
if (BACKENDS_QUE_CONSUME_ESTE_MODULO.trim().length > 2) {
|
|
@@ -122,7 +126,7 @@ export async function initBackend() {
|
|
|
122
126
|
console.log('Limpiando directorio actual...');
|
|
123
127
|
limpiarDirectorioActual(['commit-message.txt']);
|
|
124
128
|
console.log('Inicializando el proyecto de backend...');
|
|
125
|
-
|
|
129
|
+
|
|
126
130
|
const directoriodePlantillas = path.join(__dirname, '../templates/backend');
|
|
127
131
|
const directorioDestino = process.cwd();
|
|
128
132
|
|
|
@@ -133,7 +137,7 @@ export async function initBackend() {
|
|
|
133
137
|
}
|
|
134
138
|
|
|
135
139
|
copiarDirectorios(directoriodePlantillas, directorioDestino);
|
|
136
|
-
|
|
140
|
+
|
|
137
141
|
// Specific renames for Backend
|
|
138
142
|
const gitignorePath = path.join(directorioDestino, 'gitignore');
|
|
139
143
|
if (fs.existsSync(gitignorePath)) {
|
|
@@ -175,21 +179,21 @@ export async function addServiceBackend() {
|
|
|
175
179
|
const templateServicioPath = path.join(rutaServicioDir, 'Servicio1.js');
|
|
176
180
|
const newServicioPath = path.join(rutaServicioDir, Servicio + '.js');
|
|
177
181
|
if (fs.existsSync(templateServicioPath)) { // Ensure template exists
|
|
178
|
-
|
|
182
|
+
fs.copyFileSync(templateServicioPath, newServicioPath);
|
|
179
183
|
} else {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
184
|
+
console.error(`Error: Template Servicio1.js not found in ${rutaServicioDir}`);
|
|
185
|
+
closeReadLine();
|
|
186
|
+
process.exit(1);
|
|
183
187
|
}
|
|
184
188
|
|
|
185
189
|
const templateRutaPath = path.join(rutaRutaDir, 'Servicio1.js');
|
|
186
190
|
const newRutaPath = path.join(rutaRutaDir, Servicio + '.js');
|
|
187
191
|
if (fs.existsSync(templateRutaPath)) { // Ensure template exists
|
|
188
|
-
|
|
192
|
+
fs.copyFileSync(templateRutaPath, newRutaPath);
|
|
189
193
|
} else {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
194
|
+
console.error(`Error: Template Servicio1.js not found in ${rutaRutaDir}`);
|
|
195
|
+
closeReadLine();
|
|
196
|
+
process.exit(1);
|
|
193
197
|
}
|
|
194
198
|
|
|
195
199
|
// Update rutas.js
|
|
@@ -205,9 +209,9 @@ function asignarRutasAExpress(app) {`);
|
|
|
205
209
|
app.use('/${Servicio}', rutasDel${Servicio});`);
|
|
206
210
|
fs.writeFileSync(rutaRutasJs, contenidoRutasJs);
|
|
207
211
|
} else {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
212
|
+
console.error(`Error: rutas.js not found in ${rutaRutaDir}`);
|
|
213
|
+
closeReadLine();
|
|
214
|
+
process.exit(1);
|
|
211
215
|
}
|
|
212
216
|
|
|
213
217
|
reemplazarContenidoEnArchivo(newServicioPath, 'Servicio1', Servicio);
|
package/package.json
CHANGED
|
@@ -595,12 +595,13 @@ class Miscelaneo {
|
|
|
595
595
|
}
|
|
596
596
|
|
|
597
597
|
async registroDelModuloEnSIGUV2() {
|
|
598
|
+
const Version = this.Version + "$$" + this.versionDelNucleo().split(' ')[0];
|
|
598
599
|
await ejecutarConsultaSIGU("INSERT INTO `SIGU`.`SIGU_ModulosV2` VALUES\
|
|
599
600
|
(?, ?, ?, ?, ?, ?, ?, ?, ?, NOW(4), ?, 'DiccionarioDeDatos'\
|
|
600
601
|
, ?, '-', '-', 'Activo', NOW(4), USER()) ON DUPLICATE KEY UPDATE `Version` = ?"
|
|
601
602
|
, [this.NombreCanonicoDelModulo, this.MenuPadre, this.DescripcionDelModulo, this.DetalleDelModulo
|
|
602
|
-
, this.TipoDeCard, this.IconoDelModulo, this.ColorDelModulo, this.CorreoParaReportes,
|
|
603
|
-
,
|
|
603
|
+
, this.TipoDeCard, this.IconoDelModulo, this.ColorDelModulo, this.CorreoParaReportes, Version, this.versionDelNucleo().split(' ')[0], this.Repositorios
|
|
604
|
+
, Version]);
|
|
604
605
|
await ejecutarConsultaSIGU("SELECT IFNULL(MAX(`PermisoId`), 0) + 1 INTO @`SiguientePermisoId` FROM `SIGU`.`SIGU_PermisosV2`;\
|
|
605
606
|
INSERT INTO `SIGU`.`SIGU_PermisosV2` VALUES\
|
|
606
607
|
(@`SiguientePermisoId`, ?, ?, ?, NOW(4), USER()) ON DUPLICATE KEY UPDATE `LastUser` = USER(), `Nombre` = ?, `Descripcion` = ?;"
|
package/templates/frontend/src/app/Componentes/Nucleo/mensaje-confirmacion/mensaje-confirmacion.ts
CHANGED
|
@@ -45,6 +45,7 @@ export class MensajeConfirmacionComponent {
|
|
|
45
45
|
public dialogRef: MatDialogRef<MensajeConfirmacionComponent>,
|
|
46
46
|
@Inject(MAT_DIALOG_DATA) public data: DialogData
|
|
47
47
|
) {
|
|
48
|
+
this.dialogRef.disableClose = true;
|
|
48
49
|
this.SolicitaMensaje = this.data.SolicitaMensaje;
|
|
49
50
|
}
|
|
50
51
|
|
|
@@ -45,6 +45,7 @@ export class MensajeConfirmacionHTMLComponent {
|
|
|
45
45
|
public dialogRef: MatDialogRef<MensajeConfirmacionHTMLComponent>,
|
|
46
46
|
@Inject(MAT_DIALOG_DATA) public data: DialogData
|
|
47
47
|
) {
|
|
48
|
+
this.dialogRef.disableClose = true;
|
|
48
49
|
this.SolicitaMensaje = this.data.SolicitaMensaje;
|
|
49
50
|
}
|
|
50
51
|
|
package/templates/frontend/src/app/Componentes/Nucleo/mensaje-informacion/mensaje-informacion.ts
CHANGED
|
@@ -34,6 +34,7 @@ export class MensajeInformacionComponent {
|
|
|
34
34
|
, @Inject(MAT_DIALOG_DATA) public data: DialogData
|
|
35
35
|
, private sanitizer: DomSanitizer
|
|
36
36
|
) {
|
|
37
|
+
this.dialogRef.disableClose = true;
|
|
37
38
|
this.arregloDeDatos = Object.entries(this.data).map(([llave, valor]) => ({
|
|
38
39
|
llave,
|
|
39
40
|
valor: this.sanitizer.bypassSecurityTrustHtml(valor?.toString() ?? '')
|