@barcidev/ngx-autogen 0.1.8 → 0.1.9
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 +35 -0
package/package.json
CHANGED
package/src/transloco/index.js
CHANGED
|
@@ -107,7 +107,42 @@ function transloco(options) {
|
|
|
107
107
|
}
|
|
108
108
|
// 7. Sincronización de archivos i18n comunes
|
|
109
109
|
rules.push((0, file_actions_1.mergeFilesSmart)("./files/i18n", "src/app/i18n", options, tree));
|
|
110
|
+
updateTsConfig(tree);
|
|
110
111
|
return (0, schematics_1.chain)(rules);
|
|
111
112
|
});
|
|
113
|
+
function updateTsConfig(tree) {
|
|
114
|
+
const tsConfigPath = "/tsconfig.json";
|
|
115
|
+
const path = tree.exists(tsConfigPath)
|
|
116
|
+
? tsConfigPath
|
|
117
|
+
: "/tsconfig.app.json";
|
|
118
|
+
const buffer = tree.read(path);
|
|
119
|
+
if (!buffer)
|
|
120
|
+
return;
|
|
121
|
+
let contentText = buffer.toString();
|
|
122
|
+
// Limpieza manual de comentarios para evitar que JSON.parse falle
|
|
123
|
+
const cleanJson = contentText.replace(/\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*$/gm, "$1");
|
|
124
|
+
let tsconfig;
|
|
125
|
+
try {
|
|
126
|
+
tsconfig = JSON.parse(cleanJson);
|
|
127
|
+
}
|
|
128
|
+
catch (e) {
|
|
129
|
+
// Si falla, intentamos parsearlo tal cual por si no tiene comentarios
|
|
130
|
+
try {
|
|
131
|
+
tsconfig = JSON.parse(contentText);
|
|
132
|
+
}
|
|
133
|
+
catch (innerError) {
|
|
134
|
+
throw new schematics_1.SchematicsException(`No se pudo parsear ${path}. Asegúrate de que es un JSON válido.`);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
// Configurar los paths
|
|
138
|
+
tsconfig.compilerOptions = tsconfig.compilerOptions || {};
|
|
139
|
+
tsconfig.compilerOptions.paths = tsconfig.compilerOptions.paths || {};
|
|
140
|
+
const sharedAlias = "@i18n/*";
|
|
141
|
+
const sharedPath = ["src/app/i18n/*"];
|
|
142
|
+
if (!tsconfig.compilerOptions.paths[sharedAlias]) {
|
|
143
|
+
tsconfig.compilerOptions.paths[sharedAlias] = sharedPath;
|
|
144
|
+
tree.overwrite(path, JSON.stringify(tsconfig, null, 2));
|
|
145
|
+
}
|
|
146
|
+
}
|
|
112
147
|
}
|
|
113
148
|
//# sourceMappingURL=index.js.map
|