@barcidev/ngx-autogen 0.1.9 → 0.1.11

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.9",
3
+ "version": "0.1.11",
4
4
  "description": "A collection of Angular schematics for essential functionalities.",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -34,11 +34,16 @@ function transloco(options) {
34
34
  }
35
35
  // 2. Detección automática del componente en la ruta actual
36
36
  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.
37
39
  const relativeExecutionPath = fullPath
38
- .replace(process.cwd(), "")
39
- .replace(/\\/g, "/");
40
+ .replace((0, path_1.normalize)(process.env.PWD || process.cwd()), "")
41
+ .replace(/\\/g, "/")
42
+ .replace(/^\//, ""); // Quitamos la barra inicial si existe
40
43
  const directory = tree.getDir((0, path_1.normalize)(relativeExecutionPath));
44
+ console.log(`🔍 Buscando componente en el Tree: "${relativeExecutionPath}"`);
41
45
  const componentFile = directory.subfiles.find((file) => file.endsWith(".component.ts"));
46
+ console.log(`📄 Componente detectado: ${componentFile || "Ninguno"}`);
42
47
  if (!componentFile && !options.name) {
43
48
  throw new schematics_1.SchematicsException("❌ No se encontró un archivo *.component.ts en este directorio.");
44
49
  }
@@ -46,12 +51,11 @@ function transloco(options) {
46
51
  ? componentFile.replace(".component.ts", "")
47
52
  : options.name;
48
53
  options.name = componentFileName;
54
+ console.log(`✅ Nombre del componente para i18n: ${options.name}`);
49
55
  // 3. Determinación de rutas para generación de archivos
50
- const srcIndex = fullPath.lastIndexOf("src");
51
- const relativePath = srcIndex !== -1
52
- ? fullPath.substring(srcIndex)
53
- : (0, path_1.join)((0, path_1.normalize)("src"), "app");
54
- options.path = (0, path_1.normalize)(relativePath);
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}`);
55
59
  const namePath = options.path; // Generamos archivos en la misma carpeta del componente detectado
56
60
  const rules = [];
57
61
  // 4. Verificación de instalación de Transloco (Idempotencia)
@@ -94,6 +98,7 @@ function transloco(options) {
94
98
  if (componentFile) {
95
99
  const componentPath = (0, path_1.join)(namePath, componentFile);
96
100
  const i18nConstantName = `${schematics_1.strings.camelize(options.name)}I18n`;
101
+ console.log(`🔗 Registrando scope de Transloco en ${componentFile} con constante ${i18nConstantName}, este es el path: ${componentPath}`);
97
102
  rules.push((0, file_actions_1.addProviderToStandaloneComponent)(componentPath, `provideTranslocoScopeWrapper(${i18nConstantName})`, [
98
103
  {
99
104
  symbol: `provideTranslocoScopeWrapper`,