utn-cli 2.0.27 → 2.0.28
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 +3 -3
- package/commands/db.js +3 -3
- package/commands/frontend.js +48 -48
- package/package.json +1 -1
package/commands/backend.js
CHANGED
|
@@ -46,8 +46,8 @@ async function inicializarProyectoBackend() {
|
|
|
46
46
|
const oldFileName = path.join(process.cwd(), 'NOMBRE_DEL_CANONICO_DEL_PROYECTO.rest');
|
|
47
47
|
const newFileName = path.join(process.cwd(), `${val}.rest`);
|
|
48
48
|
if (fs.existsSync(newFileName)) {
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
// If the new file name already exists, do nothing.
|
|
50
|
+
return;
|
|
51
51
|
}
|
|
52
52
|
if (fs.existsSync(oldFileName)) {
|
|
53
53
|
fs.renameSync(oldFileName, newFileName);
|
|
@@ -124,7 +124,7 @@ async function inicializarProyectoBackend() {
|
|
|
124
124
|
|
|
125
125
|
export async function initBackend() {
|
|
126
126
|
console.log('Limpiando directorio actual...');
|
|
127
|
-
limpiarDirectorioActual(['commit-message.txt']);
|
|
127
|
+
limpiarDirectorioActual(['commit-message.txt', '.git']);
|
|
128
128
|
console.log('Inicializando el proyecto de backend...');
|
|
129
129
|
|
|
130
130
|
const directoriodePlantillas = path.join(__dirname, '../templates/backend');
|
package/commands/db.js
CHANGED
|
@@ -8,7 +8,7 @@ const __dirname = path.dirname(__filename);
|
|
|
8
8
|
|
|
9
9
|
export async function initDb() {
|
|
10
10
|
console.log('Limpiando directorio actual...');
|
|
11
|
-
limpiarDirectorioActual(['commit-message.txt']); // Assuming this is still relevant for DB
|
|
11
|
+
limpiarDirectorioActual(['commit-message.txt', '.git']); // Assuming this is still relevant for DB
|
|
12
12
|
console.log('Inicializando el proyecto de base de datos...');
|
|
13
13
|
|
|
14
14
|
const directoriodePlantillas = path.join(__dirname, '../templates/bd');
|
|
@@ -19,9 +19,9 @@ export async function initDb() {
|
|
|
19
19
|
closeReadLine();
|
|
20
20
|
process.exit(1);
|
|
21
21
|
}
|
|
22
|
-
|
|
22
|
+
|
|
23
23
|
copiarDirectorios(directoriodePlantillas, directorioDestino);
|
|
24
|
-
|
|
24
|
+
|
|
25
25
|
// Specific renames for DB
|
|
26
26
|
// This needs to be handled carefully, as original was 'cumulodb-scripts/gitignore' to 'cumulodb-scripts/.gitignore'
|
|
27
27
|
// and now templates are nested.
|
package/commands/frontend.js
CHANGED
|
@@ -9,7 +9,7 @@ const __dirname = path.dirname(__filename);
|
|
|
9
9
|
|
|
10
10
|
export async function initFrontend() {
|
|
11
11
|
console.log('Limpiando directorio actual...');
|
|
12
|
-
limpiarDirectorioActual(['commit-message.txt']);
|
|
12
|
+
limpiarDirectorioActual(['commit-message.txt', '.git']);
|
|
13
13
|
console.log('Inicializando el proyecto de frontend...');
|
|
14
14
|
const directoriodePlantillas = path.join(__dirname, '../templates/frontend');
|
|
15
15
|
const directorioDestino = process.cwd();
|
|
@@ -21,7 +21,7 @@ export async function initFrontend() {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
copiarDirectorios(directoriodePlantillas, directorioDestino);
|
|
24
|
-
|
|
24
|
+
|
|
25
25
|
// Specific renames for Frontend
|
|
26
26
|
const gitignorePath = path.join(directorioDestino, 'gitignore');
|
|
27
27
|
if (fs.existsSync(gitignorePath)) {
|
|
@@ -67,7 +67,7 @@ export async function cloneFrontendComponent() {
|
|
|
67
67
|
closeReadLine();
|
|
68
68
|
process.exit(1);
|
|
69
69
|
}
|
|
70
|
-
|
|
70
|
+
|
|
71
71
|
const titulo = await hacerPreguntaTrim('Ingrese el título para la tarjeta: ');
|
|
72
72
|
const descripcion = await hacerPreguntaTrim('Ingrese la descripción para la tarjeta: ');
|
|
73
73
|
|
|
@@ -75,7 +75,7 @@ export async function cloneFrontendComponent() {
|
|
|
75
75
|
const nombreCapitalizado = nombre.charAt(0).toUpperCase() + nombre.slice(1);
|
|
76
76
|
const nombreClase = `GestionTabla${nombreCapitalizado}Component`;
|
|
77
77
|
const nombreRuta = `gestion-tabla-${nombreLower}`;
|
|
78
|
-
|
|
78
|
+
|
|
79
79
|
const rutaFuente = path.join(__dirname, '../templates/frontend', 'src', 'app', 'Paginas', 'gestion-tabla-XYZ');
|
|
80
80
|
const rutaDestino = path.join(process.cwd(), 'src', 'app', 'Paginas', nombreRuta);
|
|
81
81
|
|
|
@@ -99,19 +99,19 @@ export async function cloneFrontendComponent() {
|
|
|
99
99
|
}
|
|
100
100
|
const entradas = fs.readdirSync(fuente, { withFileTypes: true });
|
|
101
101
|
entradas.forEach((entrada) => {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
102
|
+
const nombreOriginal = entrada.name;
|
|
103
|
+
const nombreNuevo = nombreOriginal.replace(/XYZ/g, nombreLower);
|
|
104
|
+
const rutaFuente = path.join(fuente, nombreOriginal);
|
|
105
|
+
const rutaDestino = path.join(destino, nombreNuevo);
|
|
106
|
+
|
|
107
|
+
if (entrada.isDirectory()) {
|
|
108
|
+
copiarYReemplazar(rutaFuente, rutaDestino);
|
|
109
|
+
} else if (entrada.isFile()) {
|
|
110
|
+
let contenido = fs.readFileSync(rutaFuente, 'utf-8');
|
|
111
|
+
contenido = contenido.replace(/GestionTablaXYZComponent/g, nombreClase);
|
|
112
|
+
contenido = contenido.replace(/XYZ/g, nombreLower);
|
|
113
|
+
fs.writeFileSync(rutaDestino, contenido);
|
|
114
|
+
}
|
|
115
115
|
});
|
|
116
116
|
}
|
|
117
117
|
|
|
@@ -123,56 +123,56 @@ export async function cloneFrontendComponent() {
|
|
|
123
123
|
const rutaRoutes = path.join(process.cwd(), 'src', 'app', 'app.routes.ts');
|
|
124
124
|
if (fs.existsSync(rutaRoutes)) {
|
|
125
125
|
let contenidoRoutes = fs.readFileSync(rutaRoutes, 'utf-8');
|
|
126
|
-
|
|
126
|
+
|
|
127
127
|
const lineaImport = `import { ${nombreClase} } from './Paginas/${nombreRuta}/${nombreRuta}.component';`;
|
|
128
128
|
const ultimoImportIndex = contenidoRoutes.lastIndexOf('import {');
|
|
129
129
|
const finUltimoImport = contenidoRoutes.indexOf(';', ultimoImportIndex);
|
|
130
|
-
|
|
130
|
+
|
|
131
131
|
if (finUltimoImport !== -1) {
|
|
132
|
-
|
|
132
|
+
contenidoRoutes = contenidoRoutes.slice(0, finUltimoImport + 1) + '\n' + lineaImport + contenidoRoutes.slice(finUltimoImport + 1);
|
|
133
133
|
} else {
|
|
134
|
-
|
|
134
|
+
contenidoRoutes = lineaImport + '\n' + contenidoRoutes;
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
const cierreArray = contenidoRoutes.lastIndexOf('];');
|
|
138
138
|
if (cierreArray !== -1) {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
139
|
+
const nuevaRuta = ` { path: '${nombreRuta}', component: ${nombreClase} },`;
|
|
140
|
+
const textoAntesDeCierre = contenidoRoutes.slice(0, cierreArray).trimEnd();
|
|
141
|
+
const necesitaComa = !textoAntesDeCierre.endsWith(',') && !textoAntesDeCierre.endsWith('[');
|
|
142
|
+
|
|
143
|
+
contenidoRoutes = contenidoRoutes.slice(0, cierreArray) +
|
|
144
|
+
(necesitaComa ? ',' : '') + '\n' +
|
|
145
|
+
nuevaRuta + '\n' +
|
|
146
|
+
contenidoRoutes.slice(cierreArray);
|
|
147
|
+
|
|
148
|
+
fs.writeFileSync(rutaRoutes, contenidoRoutes);
|
|
149
|
+
console.log('Ruta agregada exitosamente.');
|
|
150
150
|
} else {
|
|
151
|
-
|
|
151
|
+
console.error('No se pudo encontrar el array de rutas en app.routes.ts');
|
|
152
152
|
}
|
|
153
153
|
} else {
|
|
154
|
-
|
|
154
|
+
console.error(`No se encontró el archivo de rutas en: ${rutaRoutes}`);
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
// --- Modificar contenedor-principal.component.html ---
|
|
158
158
|
console.log('Actualizando contenedor-principal.component.html...');
|
|
159
159
|
const rutaHtml = path.join(process.cwd(), 'src', 'app', 'Paginas', 'contenedor-principal', 'contenedor-principal.component.html');
|
|
160
160
|
if (fs.existsSync(rutaHtml)) {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
161
|
+
let contenidoHtml = fs.readFileSync(rutaHtml, 'utf-8');
|
|
162
|
+
|
|
163
|
+
const nuevaTarjeta = ` <app-tarjeta [rutaASeguir]="'${nombreRuta}'" titulo="${titulo}" descripcion="${descripcion}" icono="table_chart"></app-tarjeta>`;
|
|
164
|
+
|
|
165
|
+
const ultimoDiv = contenidoHtml.lastIndexOf('</div>');
|
|
166
|
+
|
|
167
|
+
if (ultimoDiv !== -1) {
|
|
168
|
+
contenidoHtml = contenidoHtml.slice(0, ultimoDiv) + '\n' + nuevaTarjeta + '\n' + contenidoHtml.slice(ultimoDiv);
|
|
169
|
+
fs.writeFileSync(rutaHtml, contenidoHtml);
|
|
170
|
+
console.log('Tarjeta agregada exitosamente.');
|
|
171
|
+
} else {
|
|
172
|
+
console.error('No se encontró un </div> de cierre en el HTML del contenedor principal.');
|
|
173
|
+
}
|
|
174
174
|
} else {
|
|
175
|
-
|
|
175
|
+
console.error(`No se encontró el archivo HTML en: ${rutaHtml}`);
|
|
176
176
|
}
|
|
177
177
|
closeReadLine();
|
|
178
178
|
}
|