@barcidev/ngx-autogen 0.1.11 → 0.1.13
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 +8 -8
package/package.json
CHANGED
package/src/transloco/index.js
CHANGED
|
@@ -34,14 +34,11 @@ 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.
|
|
39
37
|
const relativeExecutionPath = fullPath
|
|
40
|
-
.replace(
|
|
41
|
-
.replace(/\\/g, "/")
|
|
42
|
-
.replace(/^\//, ""); // Quitamos la barra inicial si existe
|
|
38
|
+
.replace(process.cwd(), "")
|
|
39
|
+
.replace(/\\/g, "/");
|
|
43
40
|
const directory = tree.getDir((0, path_1.normalize)(relativeExecutionPath));
|
|
44
|
-
console.log(`🔍 Buscando componente en
|
|
41
|
+
console.log(`🔍 Buscando componente en: ${relativeExecutionPath}`);
|
|
45
42
|
const componentFile = directory.subfiles.find((file) => file.endsWith(".component.ts"));
|
|
46
43
|
console.log(`📄 Componente detectado: ${componentFile || "Ninguno"}`);
|
|
47
44
|
if (!componentFile && !options.name) {
|
|
@@ -53,8 +50,11 @@ function transloco(options) {
|
|
|
53
50
|
options.name = componentFileName;
|
|
54
51
|
console.log(`✅ Nombre del componente para i18n: ${options.name}`);
|
|
55
52
|
// 3. Determinación de rutas para generación de archivos
|
|
56
|
-
|
|
57
|
-
|
|
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
58
|
console.log(`📂 Ruta de generación de archivos i18n: ${options.path}`);
|
|
59
59
|
const namePath = options.path; // Generamos archivos en la misma carpeta del componente detectado
|
|
60
60
|
const rules = [];
|