@barcidev/ngx-autogen 0.1.11 → 0.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.
- package/package.json +1 -1
- package/src/transloco/index.js +11 -20
package/package.json
CHANGED
package/src/transloco/index.js
CHANGED
|
@@ -32,30 +32,21 @@ function transloco(options) {
|
|
|
32
32
|
if (!project) {
|
|
33
33
|
throw new schematics_1.SchematicsException(`El proyecto "${options.project}" no existe.`);
|
|
34
34
|
}
|
|
35
|
-
//
|
|
35
|
+
// 1. Obtener la raíz del Workspace (donde está el angular.json)
|
|
36
|
+
const workspaceRoot = tree.root.path === "/" ? process.cwd() : tree.root.path;
|
|
37
|
+
// 2. Calcular la ruta relativa real
|
|
38
|
+
// Esto compara "C:/Proyectos/Angular/src/app" con "C:/Proyectos/Angular"
|
|
39
|
+
// Y te devuelve exactamente "src/app"
|
|
36
40
|
const fullPath = process.cwd();
|
|
37
|
-
|
|
38
|
-
// Si estás en /src/app/features/billing, esto devolverá exactamente esa cadena.
|
|
39
|
-
const relativeExecutionPath = fullPath
|
|
40
|
-
.replace((0, path_1.normalize)(process.env.PWD || process.cwd()), "")
|
|
41
|
-
.replace(/\\/g, "/")
|
|
42
|
-
.replace(/^\//, ""); // Quitamos la barra inicial si existe
|
|
43
|
-
const directory = tree.getDir((0, path_1.normalize)(relativeExecutionPath));
|
|
41
|
+
const relativeExecutionPath = (0, path_1.relative)(workspaceRoot, fullPath).replace(/\\/g, "/");
|
|
44
42
|
console.log(`🔍 Buscando componente en el Tree: "${relativeExecutionPath}"`);
|
|
43
|
+
const directory = tree.getDir((0, path_1.normalize)(relativeExecutionPath));
|
|
45
44
|
const componentFile = directory.subfiles.find((file) => file.endsWith(".component.ts"));
|
|
46
45
|
console.log(`📄 Componente detectado: ${componentFile || "Ninguno"}`);
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
? componentFile.replace(".component.ts", "")
|
|
52
|
-
: options.name;
|
|
53
|
-
options.name = componentFileName;
|
|
54
|
-
console.log(`✅ Nombre del componente para i18n: ${options.name}`);
|
|
55
|
-
// 3. Determinación de rutas para generación de archivos
|
|
56
|
-
// Simplemente usamos la ruta que ya validamos en el paso anterior.
|
|
57
|
-
options.path = (0, path_1.normalize)(relativeExecutionPath);
|
|
58
|
-
console.log(`📂 Ruta de generación de archivos i18n: ${options.path}`);
|
|
46
|
+
// 3. Asignar la ruta para el resto del proceso
|
|
47
|
+
// Si el usuario no pasó --path, usamos la carpeta donde está parado
|
|
48
|
+
options.path = options.path || (0, path_1.normalize)(relativeExecutionPath);
|
|
49
|
+
console.log(`📂 Ruta de generación final: ${options.path}`);
|
|
59
50
|
const namePath = options.path; // Generamos archivos en la misma carpeta del componente detectado
|
|
60
51
|
const rules = [];
|
|
61
52
|
// 4. Verificación de instalación de Transloco (Idempotencia)
|