@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barcidev/ngx-autogen",
3
- "version": "0.1.11",
3
+ "version": "0.1.12",
4
4
  "description": "A collection of Angular schematics for essential functionalities.",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -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
- // 2. Detección automática del componente en la ruta actual
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
- // Obtenemos la ruta relativa desde la raíz del proyecto hasta donde estás parado
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
- if (!componentFile && !options.name) {
48
- throw new schematics_1.SchematicsException("❌ No se encontró un archivo *.component.ts en este directorio.");
49
- }
50
- const componentFileName = componentFile
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)