@barcidev/ngx-autogen 0.1.60 → 0.1.61

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.60",
3
+ "version": "0.1.61",
4
4
  "description": "A collection of Angular schematics for essential functionalities.",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -112,15 +112,23 @@ function updateAppI18nTypeRule(options) {
112
112
  const match = content.match(regex);
113
113
  if (match) {
114
114
  const oldObjectStr = match[1];
115
- const propertyKey = `[${i18nConstantName}.scope]`;
116
- const propertyValue = `${i18nConstantName}.translations['en-US']`;
117
- // Placeholder para evitar comillas de JSON
118
- const placeholder = `__REF__${i18nConstantName}`;
119
- const edits = (0, jsonc_parser_1.modify)(oldObjectStr, [propertyKey], placeholder, jsonOptions);
115
+ // 1. Definimos placeholders únicos para la llave y el valor
116
+ const keyPlaceholder = `__KEY_REF__${i18nConstantName}`;
117
+ const valuePlaceholder = `__VAL_REF__${i18nConstantName}`;
118
+ // 2. Aplicamos los cambios usando los placeholders
119
+ const edits = (0, jsonc_parser_1.modify)(oldObjectStr, [keyPlaceholder], // Usamos el placeholder como llave temporal
120
+ valuePlaceholder, // Usamos el placeholder como valor temporal
121
+ jsonOptions);
120
122
  let newObjectStr = (0, jsonc_parser_1.applyEdits)(oldObjectStr, edits);
121
- newObjectStr = newObjectStr.replace(`"${placeholder}"`, propertyValue);
123
+ // 3. Reemplazamos los placeholders por el código real (sin comillas)
124
+ const realKey = `[${i18nConstantName}.scope]`;
125
+ const realValue = `${i18nConstantName}.translations['en-US']`;
126
+ newObjectStr = newObjectStr
127
+ .replace(`"${keyPlaceholder}"`, realKey) // Limpia la llave
128
+ .replace(`"${valuePlaceholder}"`, realValue); // Limpia el valor
129
+ // 4. Escribimos en el archivo
122
130
  tree.overwrite(i18nFilePath, content.replace(oldObjectStr, newObjectStr));
123
- context.logger.info(`✅ Tipos actualizados para el scope: ${propertyKey}`);
131
+ context.logger.info(`✅ Tipos actualizados para el scope: ${realKey}`);
124
132
  }
125
133
  return tree;
126
134
  };