@barcidev/ngx-autogen 0.1.12 → 0.1.14

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.12",
3
+ "version": "0.1.14",
4
4
  "description": "A collection of Angular schematics for essential functionalities.",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -32,21 +32,26 @@ function transloco(options) {
32
32
  if (!project) {
33
33
  throw new schematics_1.SchematicsException(`El proyecto "${options.project}" no existe.`);
34
34
  }
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"
35
+ // 3. Determinación de rutas para generación de archivos
40
36
  const fullPath = process.cwd();
41
- const relativeExecutionPath = (0, path_1.relative)(workspaceRoot, fullPath).replace(/\\/g, "/");
42
- console.log(`🔍 Buscando componente en el Tree: "${relativeExecutionPath}"`);
43
- const directory = tree.getDir((0, path_1.normalize)(relativeExecutionPath));
37
+ const srcIndex = fullPath.lastIndexOf("src");
38
+ const relativePath = srcIndex !== -1
39
+ ? fullPath.substring(srcIndex)
40
+ : (0, path_1.join)((0, path_1.normalize)("src"), "app");
41
+ options.path = (0, path_1.normalize)(relativePath);
42
+ const directory = tree.getDir((0, path_1.normalize)(options.path));
43
+ console.log(`🔍 Buscando componente en: ${options.path}`);
44
44
  const componentFile = directory.subfiles.find((file) => file.endsWith(".component.ts"));
45
45
  console.log(`📄 Componente detectado: ${componentFile || "Ninguno"}`);
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}`);
46
+ if (!componentFile && !options.name) {
47
+ throw new schematics_1.SchematicsException("❌ No se encontró un archivo *.component.ts en este directorio.");
48
+ }
49
+ const componentFileName = componentFile
50
+ ? componentFile.replace(".component.ts", "")
51
+ : options.name;
52
+ options.name = componentFileName;
53
+ console.log(`✅ Nombre del componente para i18n: ${options.name}`);
54
+ console.log(`📂 Ruta de generación de archivos i18n: ${options.path}`);
50
55
  const namePath = options.path; // Generamos archivos en la misma carpeta del componente detectado
51
56
  const rules = [];
52
57
  // 4. Verificación de instalación de Transloco (Idempotencia)