@barcidev/ngx-autogen 0.1.10 → 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
|
-
const relativeExecutionPath = fullPath
|
|
38
|
-
|
|
39
|
-
.replace(/\\/g, "/");
|
|
41
|
+
const relativeExecutionPath = (0, path_1.relative)(workspaceRoot, fullPath).replace(/\\/g, "/");
|
|
42
|
+
console.log(`🔍 Buscando componente en el Tree: "${relativeExecutionPath}"`);
|
|
40
43
|
const directory = tree.getDir((0, path_1.normalize)(relativeExecutionPath));
|
|
41
|
-
console.log(`🔍 Buscando componente en: ${relativeExecutionPath}`);
|
|
42
44
|
const componentFile = directory.subfiles.find((file) => file.endsWith(".component.ts"));
|
|
43
45
|
console.log(`📄 Componente detectado: ${componentFile || "Ninguno"}`);
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
? componentFile.replace(".component.ts", "")
|
|
49
|
-
: options.name;
|
|
50
|
-
options.name = componentFileName;
|
|
51
|
-
console.log(`✅ Nombre del componente para i18n: ${options.name}`);
|
|
52
|
-
// 3. Determinación de rutas para generación de archivos
|
|
53
|
-
const srcIndex = fullPath.lastIndexOf("src");
|
|
54
|
-
const relativePath = srcIndex !== -1
|
|
55
|
-
? fullPath.substring(srcIndex)
|
|
56
|
-
: (0, path_1.join)((0, path_1.normalize)("src"), "app");
|
|
57
|
-
options.path = (0, path_1.normalize)(relativePath);
|
|
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)
|