@intlayer/chokidar 5.7.7 → 5.8.0-canary.0

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.
Files changed (32) hide show
  1. package/dist/cjs/loadDictionaries/loadDictionaries.cjs +2 -1
  2. package/dist/cjs/loadDictionaries/loadDictionaries.cjs.map +1 -1
  3. package/dist/cjs/mergeDictionaries.cjs +67 -3
  4. package/dist/cjs/mergeDictionaries.cjs.map +1 -1
  5. package/dist/cjs/reduceDictionaryContent/applyMask.cjs +16 -2
  6. package/dist/cjs/reduceDictionaryContent/applyMask.cjs.map +1 -1
  7. package/dist/cjs/writeContentDeclaration/formatCode.cjs +3 -1
  8. package/dist/cjs/writeContentDeclaration/formatCode.cjs.map +1 -1
  9. package/dist/cjs/writeContentDeclaration/writeJSFile.cjs +101 -148
  10. package/dist/cjs/writeContentDeclaration/writeJSFile.cjs.map +1 -1
  11. package/dist/esm/loadDictionaries/loadDictionaries.mjs +2 -1
  12. package/dist/esm/loadDictionaries/loadDictionaries.mjs.map +1 -1
  13. package/dist/esm/mergeDictionaries.mjs +67 -3
  14. package/dist/esm/mergeDictionaries.mjs.map +1 -1
  15. package/dist/esm/reduceDictionaryContent/applyMask.mjs +16 -2
  16. package/dist/esm/reduceDictionaryContent/applyMask.mjs.map +1 -1
  17. package/dist/esm/writeContentDeclaration/formatCode.mjs +3 -1
  18. package/dist/esm/writeContentDeclaration/formatCode.mjs.map +1 -1
  19. package/dist/esm/writeContentDeclaration/writeJSFile.mjs +101 -148
  20. package/dist/esm/writeContentDeclaration/writeJSFile.mjs.map +1 -1
  21. package/dist/types/loadDictionaries/loadDictionaries.d.ts.map +1 -1
  22. package/dist/types/mergeDictionaries.d.ts.map +1 -1
  23. package/dist/types/reduceDictionaryContent/applyMask.d.ts.map +1 -1
  24. package/dist/types/writeContentDeclaration/formatCode.d.ts.map +1 -1
  25. package/dist/types/writeContentDeclaration/writeJSFile.d.ts.map +1 -1
  26. package/package.json +17 -17
  27. package/dist/cjs/utils/resolveObjectPromises.test.cjs +0 -107
  28. package/dist/cjs/utils/resolveObjectPromises.test.cjs.map +0 -1
  29. package/dist/esm/utils/resolveObjectPromises.test.mjs +0 -106
  30. package/dist/esm/utils/resolveObjectPromises.test.mjs.map +0 -1
  31. package/dist/types/utils/resolveObjectPromises.test.d.ts +0 -2
  32. package/dist/types/utils/resolveObjectPromises.test.d.ts.map +0 -1
@@ -155,167 +155,120 @@ const writeJSFile = async (filePath, dictionary) => {
155
155
  const contentObjectPath = contentPropertyPath.get(
156
156
  "value"
157
157
  );
158
- for (const [entryKeyToUpdate, newEntryData] of Object.entries(
159
- updatesToApply
160
- )) {
161
- const targetPropertyPath = contentObjectPath.get("properties").find((propPath) => {
158
+ const buildValueNodeFromData = (data) => {
159
+ if (data?.nodeType === NodeType.Translation) {
160
+ const translationContent = data;
161
+ if (isPerLocaleDeclarationFile && typeof locale === "string" && translationContent?.[NodeType.Translation]?.[locale] !== void 0) {
162
+ return buildValueNodeFromData(
163
+ translationContent[NodeType.Translation][locale]
164
+ );
165
+ }
166
+ const translationsObj = t.objectExpression(
167
+ Object.entries(translationContent?.[NodeType.Translation] ?? {}).map(
168
+ ([langKey, langValue]) => {
169
+ const keyNode = t.isValidIdentifier(langKey) ? t.identifier(langKey) : t.stringLiteral(langKey);
170
+ return t.objectProperty(keyNode, buildValueNodeFromData(langValue));
171
+ }
172
+ )
173
+ );
174
+ return t.callExpression(t.identifier("t"), [translationsObj]);
175
+ }
176
+ if (Array.isArray(data)) {
177
+ return t.arrayExpression(data.map((el) => buildValueNodeFromData(el)));
178
+ }
179
+ if (data && typeof data === "object") {
180
+ const props = Object.entries(data).map(([k, v]) => {
181
+ const key = t.isValidIdentifier(k) ? t.identifier(k) : t.stringLiteral(k);
182
+ return t.objectProperty(key, buildValueNodeFromData(v));
183
+ });
184
+ return t.objectExpression(props);
185
+ }
186
+ switch (typeof data) {
187
+ case "string":
188
+ return t.stringLiteral(data);
189
+ case "number":
190
+ return t.numericLiteral(data);
191
+ case "boolean":
192
+ return t.booleanLiteral(data);
193
+ default:
194
+ return t.nullLiteral();
195
+ }
196
+ };
197
+ const ensureObjectProperty = (objPath, key) => {
198
+ const existing = objPath.get("properties").find((propPath) => {
162
199
  if (!propPath.isObjectProperty()) return false;
163
200
  const propNode = propPath.node;
164
201
  const keyName = t.isIdentifier(propNode.key) ? propNode.key.name : t.isStringLiteral(propNode.key) ? propNode.key.value : null;
165
- return keyName === entryKeyToUpdate;
202
+ return keyName === key;
166
203
  });
167
- if (!targetPropertyPath || !targetPropertyPath.isObjectProperty()) {
168
- appLogger(
169
- `Key '${entryKeyToUpdate}' not found in content object of ${filePath}. Adding the missing key.`,
170
- {
171
- level: "info",
172
- isVerbose: true
173
- }
174
- );
175
- let valueNode;
176
- if (newEntryData?.nodeType === NodeType.Translation) {
177
- const translationContent = newEntryData;
178
- if (isPerLocaleDeclarationFile && typeof locale === "string" && translationContent?.[NodeType.Translation]?.[locale]) {
179
- valueNode = t.stringLiteral(
180
- String(translationContent[NodeType.Translation][locale])
181
- );
182
- } else {
183
- const translationsObj = t.objectExpression(
184
- Object.entries(translationContent?.[NodeType.Translation]).map(
185
- ([langKey, langValue]) => {
186
- const keyNode2 = t.isValidIdentifier(langKey) ? t.identifier(langKey) : t.stringLiteral(langKey);
187
- return t.objectProperty(
188
- keyNode2,
189
- t.stringLiteral(String(langValue))
190
- );
191
- }
204
+ if (existing) return existing;
205
+ const keyNode = t.isValidIdentifier(key) ? t.identifier(key) : t.stringLiteral(key);
206
+ const newProp = t.objectProperty(keyNode, t.objectExpression([]));
207
+ objPath.node.properties.push(newProp);
208
+ const props = objPath.get("properties");
209
+ return props[props.length - 1];
210
+ };
211
+ const mergeValueIntoProperty = (propPath, value, propKeyForLogs) => {
212
+ const valuePath = propPath.get("value");
213
+ if (value?.nodeType === NodeType.Translation) {
214
+ const translationContent = value;
215
+ if (valuePath.isCallExpression() && t.isIdentifier(valuePath.node.callee) && valuePath.node.callee.name === "t") {
216
+ const translationsObj = t.objectExpression(
217
+ Object.entries(translationContent?.[NodeType.Translation] ?? {}).map(
218
+ ([langKey, langValue]) => t.objectProperty(
219
+ t.isValidIdentifier(langKey) ? t.identifier(langKey) : t.stringLiteral(langKey),
220
+ buildValueNodeFromData(langValue)
192
221
  )
193
- );
194
- valueNode = t.callExpression(t.identifier("t"), [translationsObj]);
195
- }
196
- } else if (typeof newEntryData === "string") {
197
- valueNode = t.stringLiteral(newEntryData);
198
- } else {
199
- appLogger(
200
- `Unsupported data type for new key '${entryKeyToUpdate}'. Using empty string.`,
201
- { level: "warn", isVerbose: true }
222
+ )
202
223
  );
203
- valueNode = t.stringLiteral("");
204
- }
205
- const keyNode = t.isValidIdentifier(entryKeyToUpdate) ? t.identifier(entryKeyToUpdate) : t.stringLiteral(entryKeyToUpdate);
206
- const newProperty = t.objectProperty(keyNode, valueNode);
207
- contentObjectPath.node.properties.push(newProperty);
208
- continue;
209
- }
210
- const callExpressionPath = targetPropertyPath.get("value");
211
- if (callExpressionPath.isCallExpression()) {
212
- const calleeNode = callExpressionPath.node.callee;
213
- const calleeName = t.isIdentifier(calleeNode) ? calleeNode.name : null;
214
- if (newEntryData?.nodeType === "translation" && calleeName === "t") {
215
- const args = callExpressionPath.node.arguments;
216
- if (args.length === 0 || !t.isObjectExpression(args[0])) {
217
- appLogger(
218
- `'t' call for '${entryKeyToUpdate}' in ${filePath} does not have an object literal as its first argument. Skipping.`,
219
- {
220
- level: "warn",
221
- isVerbose: true
222
- }
223
- );
224
- continue;
225
- }
226
224
  if (isPerLocaleDeclarationFile && typeof locale === "string") {
227
- const translations = newEntryData?.[NodeType.Translation];
228
- if (translations[locale]) {
229
- targetPropertyPath.get("value").replaceWith(t.stringLiteral(String(translations[locale])));
230
- } else {
231
- appLogger(
232
- `Missing translation for locale '${locale}' in '${entryKeyToUpdate}'. Using first available translation.`,
233
- { level: "warn", isVerbose: true }
234
- );
235
- const firstValue = Object.values(translations)[0];
236
- if (firstValue) {
237
- targetPropertyPath.get("value").replaceWith(t.stringLiteral(String(firstValue)));
238
- }
239
- }
240
- continue;
241
- }
242
- const translationsObjectAstNode = args[0];
243
- const processedLangKeysInJsonUpdate = /* @__PURE__ */ new Set();
244
- translationsObjectAstNode.properties.forEach((prop) => {
245
- if (t.isObjectProperty(prop)) {
246
- const langKeyNode = prop.key;
247
- const astLangKeyName = t.isIdentifier(langKeyNode) ? langKeyNode.name : t.isStringLiteral(langKeyNode) ? langKeyNode.value : null;
248
- if (astLangKeyName && newEntryData?.[NodeType.Translation].hasOwnProperty(astLangKeyName)) {
249
- prop.value = t.stringLiteral(
250
- String(
251
- newEntryData?.[NodeType.Translation]?.[astLangKeyName]
252
- )
253
- );
254
- processedLangKeysInJsonUpdate.add(astLangKeyName);
255
- }
256
- }
257
- });
258
- for (const [jsonLangKey, jsonLangValue] of Object.entries(
259
- newEntryData?.[NodeType.Translation]
260
- )) {
261
- if (!processedLangKeysInJsonUpdate.has(jsonLangKey)) {
262
- const newKeyNode = t.isValidIdentifier(jsonLangKey) ? t.identifier(jsonLangKey) : t.stringLiteral(jsonLangKey);
263
- translationsObjectAstNode.properties.push(
264
- t.objectProperty(
265
- newKeyNode,
266
- t.stringLiteral(String(jsonLangValue))
267
- )
268
- );
225
+ const localized = translationContent?.[NodeType.Translation]?.[locale];
226
+ if (localized !== void 0) {
227
+ valuePath.replaceWith(buildValueNodeFromData(localized));
228
+ return;
269
229
  }
270
230
  }
271
- } else {
272
- appLogger(
273
- `Unhandled callee '${calleeName || "unknown"}' for key '${entryKeyToUpdate}' in ${filePath}.`,
274
- { level: "warn", isVerbose: true }
275
- );
231
+ valuePath.node.arguments = [translationsObj];
232
+ return;
276
233
  }
277
- } else if (callExpressionPath.isStringLiteral()) {
278
- if (typeof newEntryData === "string") {
279
- targetPropertyPath.get("value").replaceWith(t.stringLiteral(newEntryData));
280
- } else if (newEntryData?.[NodeType.Translation]) {
281
- const translations = newEntryData[NodeType.Translation];
282
- const firstValue = Object.values(translations)[0];
283
- if (firstValue) {
284
- targetPropertyPath.get("value").replaceWith(t.stringLiteral(String(firstValue)));
285
- }
286
- } else {
287
- appLogger(
288
- `Unhandled data structure for string replacement at '${entryKeyToUpdate}' in ${filePath}.`,
289
- { level: "warn", isVerbose: true }
290
- );
234
+ valuePath.replaceWith(buildValueNodeFromData(value));
235
+ return;
236
+ }
237
+ if (Array.isArray(value)) {
238
+ valuePath.replaceWith(buildValueNodeFromData(value));
239
+ return;
240
+ }
241
+ if (value && typeof value === "object") {
242
+ if (!valuePath.isObjectExpression()) {
243
+ valuePath.replaceWith(t.objectExpression([]));
291
244
  }
292
- } else {
293
- const valueType = callExpressionPath.node.type;
294
- appLogger(
295
- `Updating value of type ${valueType} for '${entryKeyToUpdate}' in ${filePath}`,
296
- { level: "info", isVerbose: true }
297
- );
298
- if (typeof newEntryData === "string") {
299
- targetPropertyPath.get("value").replaceWith(t.stringLiteral(newEntryData));
300
- } else if (newEntryData?.[NodeType.Translation]) {
301
- const translations = newEntryData[NodeType.Translation];
302
- const localeMatch = filePath.match(/\.([a-z]{2})\.content\.(ts|js)$/i);
303
- const locale2 = localeMatch ? localeMatch[1] : Object.keys(translations)[0];
304
- if (translations[locale2]) {
305
- targetPropertyPath.get("value").replaceWith(t.stringLiteral(String(translations[locale2])));
306
- } else {
307
- const firstValue = Object.values(translations)[0];
308
- if (firstValue) {
309
- targetPropertyPath.get("value").replaceWith(t.stringLiteral(String(firstValue)));
310
- }
311
- }
312
- } else {
313
- appLogger(
314
- `Cannot update value of type ${valueType} for '${entryKeyToUpdate}' in ${filePath}. Unsupported data structure.`,
315
- { level: "warn", isVerbose: true }
316
- );
245
+ const objPath = valuePath;
246
+ for (const [k, v] of Object.entries(value)) {
247
+ const childProp = ensureObjectProperty(objPath, k);
248
+ mergeValueIntoProperty(childProp, v, `${propKeyForLogs}.${k}`);
317
249
  }
250
+ return;
251
+ }
252
+ valuePath.replaceWith(buildValueNodeFromData(value));
253
+ return;
254
+ };
255
+ for (const [entryKeyToUpdate, newEntryData] of Object.entries(
256
+ updatesToApply
257
+ )) {
258
+ let targetPropertyPath = contentObjectPath.get("properties").find((propPath) => {
259
+ if (!propPath.isObjectProperty()) return false;
260
+ const propNode = propPath.node;
261
+ const keyName = t.isIdentifier(propNode.key) ? propNode.key.name : t.isStringLiteral(propNode.key) ? propNode.key.value : null;
262
+ return keyName === entryKeyToUpdate;
263
+ });
264
+ if (!targetPropertyPath) {
265
+ const keyNode = t.isValidIdentifier(entryKeyToUpdate) ? t.identifier(entryKeyToUpdate) : t.stringLiteral(entryKeyToUpdate);
266
+ const newProperty = t.objectProperty(keyNode, t.objectExpression([]));
267
+ contentObjectPath.node.properties.push(newProperty);
268
+ const props = contentObjectPath.get("properties");
269
+ targetPropertyPath = props[props.length - 1];
318
270
  }
271
+ mergeValueIntoProperty(targetPropertyPath, newEntryData, entryKeyToUpdate);
319
272
  }
320
273
  const generatedCode = generator(ast, {
321
274
  retainLines: true,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/writeContentDeclaration/writeJSFile.ts"],"sourcesContent":["import generator from '@babel/generator';\nimport * as babelParser from '@babel/parser';\nimport traverse, { NodePath } from '@babel/traverse';\nimport * as t from '@babel/types';\nimport { getAppLogger, logger } from '@intlayer/config';\nimport configuration from '@intlayer/config/built';\nimport {\n Dictionary,\n NodeType,\n TranslationContent,\n TypedNode,\n} from '@intlayer/core';\nimport { existsSync } from 'fs';\nimport { readFile, writeFile } from 'fs/promises';\nimport { extname } from 'path';\nimport { getContentDeclarationFileTemplate } from '../getContentDeclarationFileTemplate/getContentDeclarationFileTemplate';\nimport { formatCode } from './formatCode';\n\n/**\n * Updates a JavaScript/TypeScript file based on the provided JSON instructions.\n * It targets a specific dictionary object within the file (identified by its 'key' property)\n * and updates its 'content' entries. Currently, it focuses on modifying arguments\n * of 't' (translation) function calls.\n */\nexport const writeJSFile = async (\n filePath: string,\n dictionary: Dictionary\n): Promise<void> => {\n const appLogger = getAppLogger(configuration);\n\n const {\n key: dictionaryIdentifierKey,\n content: updatesToApply,\n locale,\n autoFilled,\n } = dictionary;\n const isPerLocaleDeclarationFile = typeof locale === 'string';\n\n // Check if the file exist\n if (!existsSync(filePath)) {\n const fileExtension = extname(filePath);\n\n let format = 'ts' as 'ts' | 'cjs' | 'esm';\n\n if (fileExtension === '.ts' || fileExtension === '.tsx') {\n format = 'ts';\n } else if (fileExtension === '.cjs' || fileExtension === '.cjsx') {\n format = 'cjs';\n } else {\n format = 'esm';\n }\n\n appLogger('File does not exist, creating it', {\n isVerbose: true,\n });\n const template = await getContentDeclarationFileTemplate(\n dictionaryIdentifierKey,\n format,\n { locale, autoFilled }\n );\n\n await writeFile(filePath, template, 'utf-8');\n }\n\n let sourceCode: string;\n try {\n sourceCode = await readFile(filePath, 'utf-8');\n } catch (error) {\n const err = error as Error;\n appLogger(`Failed to read file: ${filePath}`, {\n level: 'error',\n });\n throw new Error(`Failed to read file ${filePath}: ${err.message}`);\n }\n\n const ast = babelParser.parse(sourceCode, {\n sourceType: 'module',\n plugins: ['typescript', 'jsx'],\n tokens: true,\n });\n\n let dictionaryObjectPath: NodePath<t.ObjectExpression> | null = null;\n let dictionaryIdentifier: string | null = null;\n\n // First look for direct objects with the right key, regardless of variable assignments\n traverse(ast, {\n ObjectExpression(path) {\n if (dictionaryObjectPath) return; // Already found\n\n // Check if this object has a key property with the right value\n const keyProp = path.node.properties.find((prop) => {\n if (!t.isObjectProperty(prop)) return false;\n if (!t.isIdentifier(prop.key) && !t.isStringLiteral(prop.key))\n return false;\n\n const keyName = t.isIdentifier(prop.key)\n ? prop.key.name\n : prop.key.value;\n\n if (keyName !== 'key' || !t.isStringLiteral(prop.value)) return false;\n\n // Unescape the value for comparison\n const propValue = prop.value.value;\n // Compare actual string content, not just raw representation\n return propValue === dictionaryIdentifierKey;\n });\n\n if (keyProp) {\n dictionaryObjectPath = path;\n path.stop();\n }\n },\n });\n\n // If not found directly, look for variable declarations and exports\n if (!dictionaryObjectPath) {\n appLogger(`Looking for variable declarations`, {\n isVerbose: true,\n });\n\n // Collect all variable declarations with objects\n const candidateVars: { id: string; path: NodePath<t.ObjectExpression> }[] =\n [];\n\n traverse(ast, {\n VariableDeclarator(path) {\n const { node } = path;\n if (!t.isIdentifier(node.id)) return;\n\n let objPath: NodePath<t.ObjectExpression> | null = null;\n\n // Direct object assignment\n if (node.init && t.isObjectExpression(node.init)) {\n objPath = path.get('init') as NodePath<t.ObjectExpression>;\n }\n // Object with TS type assertion (satisfies/as)\n else if (\n node.init &&\n (t.isTSAsExpression(node.init) || t.isTSTypeAssertion(node.init)) &&\n t.isObjectExpression(node.init.expression)\n ) {\n objPath = path.get('init.expression') as NodePath<t.ObjectExpression>;\n }\n\n if (objPath) {\n candidateVars.push({ id: node.id.name, path: objPath });\n }\n },\n });\n\n appLogger(`Found ${candidateVars.length} candidate variables`, {\n isVerbose: true,\n });\n\n // Check each candidate for the key property\n for (const { id, path } of candidateVars) {\n const keyProp = path.node.properties.find((prop) => {\n if (!t.isObjectProperty(prop)) return false;\n if (!t.isIdentifier(prop.key) && !t.isStringLiteral(prop.key))\n return false;\n\n const keyName = t.isIdentifier(prop.key)\n ? prop.key.name\n : prop.key.value;\n return (\n keyName === 'key' &&\n t.isStringLiteral(prop.value) &&\n prop.value.value === dictionaryIdentifierKey\n );\n });\n\n if (keyProp) {\n appLogger(`Found match in variable: ${id}`);\n dictionaryObjectPath = path;\n dictionaryIdentifier = id;\n break;\n }\n }\n\n // If still not found, dump all object expressions for debugging\n if (!dictionaryObjectPath) {\n appLogger('Could not find dictionary object. Dumping all objects:', {\n isVerbose: true,\n });\n traverse(ast, {\n ObjectExpression(path) {\n const props = path.node.properties\n .map((prop) => {\n if (!t.isObjectProperty(prop)) return 'non-object-property';\n if (!t.isIdentifier(prop.key) && !t.isStringLiteral(prop.key))\n return 'complex-key';\n\n const keyName = t.isIdentifier(prop.key)\n ? prop.key.name\n : prop.key.value;\n let valueDesc = 'unknown-value';\n\n if (t.isStringLiteral(prop.value)) {\n valueDesc = `\"${prop.value.value}\"`;\n }\n\n return `${keyName}: ${valueDesc}`;\n })\n .join(', ');\n\n appLogger(`Object: { ${props} }`);\n },\n });\n }\n }\n\n if (!dictionaryObjectPath) {\n throw new Error(\n `Could not find dictionary object with key '${dictionaryIdentifierKey}' in ${filePath}`\n );\n }\n\n // Find the 'content' property within the identified dictionary object\n const contentPropertyPath = (\n (dictionaryObjectPath as any).get('properties') as NodePath<\n t.ObjectProperty | t.SpreadElement | t.ObjectMethod\n >[]\n ).find((propPath) => {\n if (!propPath.isObjectProperty()) return false;\n const propNode = propPath.node;\n const keyName = t.isIdentifier(propNode.key)\n ? propNode.key.name\n : t.isStringLiteral(propNode.key)\n ? propNode.key.value\n : null;\n return keyName === 'content';\n });\n\n if (\n !contentPropertyPath ||\n !contentPropertyPath.isObjectProperty() ||\n !(contentPropertyPath.get('value') as NodePath).isObjectExpression()\n ) {\n throw new Error(\n `Could not find 'content' object property, or it's not an object, in dictionary in ${filePath}`\n );\n }\n\n const contentObjectPath = contentPropertyPath.get(\n 'value'\n ) as NodePath<t.ObjectExpression>;\n\n // Apply updates to each entry specified in the JSON\n for (const [entryKeyToUpdate, newEntryData] of Object.entries(\n updatesToApply\n )) {\n const targetPropertyPath = (\n contentObjectPath.get('properties') as NodePath<\n t.ObjectProperty | t.SpreadElement | t.ObjectMethod\n >[]\n ).find((propPath) => {\n if (!propPath.isObjectProperty()) return false;\n const propNode = propPath.node;\n const keyName = t.isIdentifier(propNode.key)\n ? propNode.key.name\n : t.isStringLiteral(propNode.key)\n ? propNode.key.value\n : null;\n return keyName === entryKeyToUpdate;\n });\n\n if (!targetPropertyPath || !targetPropertyPath.isObjectProperty()) {\n appLogger(\n `Key '${entryKeyToUpdate}' not found in content object of ${filePath}. Adding the missing key.`,\n {\n level: 'info',\n isVerbose: true,\n }\n );\n\n // Create a new property for the missing key\n let valueNode: t.Expression;\n\n if ((newEntryData as TypedNode)?.nodeType === NodeType.Translation) {\n // Create a new t() call with the translations\n const translationContent = newEntryData as TranslationContent;\n\n if (\n isPerLocaleDeclarationFile &&\n typeof locale === 'string' &&\n translationContent?.[NodeType.Translation]?.[locale]\n ) {\n // For per-locale files, use the string value directly\n valueNode = t.stringLiteral(\n String(translationContent[NodeType.Translation][locale])\n );\n } else {\n // Otherwise create a t() call with translations object\n const translationsObj = t.objectExpression(\n Object.entries(translationContent?.[NodeType.Translation]).map(\n ([langKey, langValue]) => {\n const keyNode = t.isValidIdentifier(langKey)\n ? t.identifier(langKey)\n : t.stringLiteral(langKey);\n return t.objectProperty(\n keyNode,\n t.stringLiteral(String(langValue))\n );\n }\n )\n );\n valueNode = t.callExpression(t.identifier('t'), [translationsObj]);\n }\n } else if (typeof newEntryData === 'string') {\n // Create a string literal for string values\n valueNode = t.stringLiteral(newEntryData);\n } else {\n // Fallback to empty string if we don't know how to handle this type\n appLogger(\n `Unsupported data type for new key '${entryKeyToUpdate}'. Using empty string.`,\n { level: 'warn', isVerbose: true }\n );\n valueNode = t.stringLiteral('');\n }\n\n // Add the new property to the content object\n const keyNode = t.isValidIdentifier(entryKeyToUpdate)\n ? t.identifier(entryKeyToUpdate)\n : t.stringLiteral(entryKeyToUpdate);\n const newProperty = t.objectProperty(keyNode, valueNode);\n contentObjectPath.node.properties.push(newProperty);\n\n continue;\n }\n\n const callExpressionPath = targetPropertyPath.get('value') as NodePath; // Path to the value, e.g., t(...)\n\n // Handle different types of values\n if (callExpressionPath.isCallExpression()) {\n const calleeNode = (callExpressionPath.node as t.CallExpression).callee;\n const calleeName = t.isIdentifier(calleeNode) ? calleeNode.name : null;\n\n // Handle 't' function calls\n if (\n (newEntryData as TypedNode)?.nodeType === 'translation' &&\n calleeName === 't'\n ) {\n const args = (callExpressionPath.node as t.CallExpression).arguments;\n if (args.length === 0 || !t.isObjectExpression(args[0])) {\n appLogger(\n `'t' call for '${entryKeyToUpdate}' in ${filePath} does not have an object literal as its first argument. Skipping.`,\n {\n level: 'warn',\n isVerbose: true,\n }\n );\n continue;\n }\n\n if (isPerLocaleDeclarationFile && typeof locale === 'string') {\n // For per-locale files, replace t() call with direct string\n const translations = (newEntryData as TranslationContent)?.[\n NodeType.Translation\n ];\n\n if (translations[locale]) {\n targetPropertyPath\n .get('value')\n .replaceWith(t.stringLiteral(String(translations[locale])));\n } else {\n appLogger(\n `Missing translation for locale '${locale}' in '${entryKeyToUpdate}'. Using first available translation.`,\n { level: 'warn', isVerbose: true }\n );\n const firstValue = Object.values(translations)[0];\n if (firstValue) {\n targetPropertyPath\n .get('value')\n .replaceWith(t.stringLiteral(String(firstValue)));\n }\n }\n continue;\n }\n\n const translationsObjectAstNode = args[0] as t.ObjectExpression;\n const processedLangKeysInJsonUpdate = new Set<string>();\n\n // Update existing language properties in the AST node\n translationsObjectAstNode.properties.forEach((prop: any) => {\n if (t.isObjectProperty(prop)) {\n const langKeyNode = prop.key;\n const astLangKeyName = t.isIdentifier(langKeyNode)\n ? langKeyNode.name\n : t.isStringLiteral(langKeyNode)\n ? langKeyNode.value\n : null;\n\n if (\n astLangKeyName &&\n (newEntryData as TranslationContent)?.[\n NodeType.Translation\n ].hasOwnProperty(astLangKeyName)\n ) {\n prop.value = t.stringLiteral(\n String(\n (newEntryData as TranslationContent)?.[\n NodeType.Translation\n ]?.[astLangKeyName]\n )\n );\n processedLangKeysInJsonUpdate.add(astLangKeyName);\n }\n }\n });\n\n // Add new language properties from the JSON update that were not originally in the AST node\n for (const [jsonLangKey, jsonLangValue] of Object.entries(\n (newEntryData as TranslationContent)?.[NodeType.Translation]\n )) {\n if (!processedLangKeysInJsonUpdate.has(jsonLangKey)) {\n const newKeyNode = t.isValidIdentifier(jsonLangKey)\n ? t.identifier(jsonLangKey)\n : t.stringLiteral(jsonLangKey);\n translationsObjectAstNode.properties.push(\n t.objectProperty(\n newKeyNode,\n t.stringLiteral(String(jsonLangValue))\n )\n );\n }\n }\n }\n // Handle other function calls in the future\n else {\n appLogger(\n `Unhandled callee '${calleeName || 'unknown'}' for key '${entryKeyToUpdate}' in ${filePath}.`,\n { level: 'warn', isVerbose: true }\n );\n }\n }\n // Handle direct string literals\n else if (callExpressionPath.isStringLiteral()) {\n // For string literals, directly replace with the new value\n if (typeof newEntryData === 'string') {\n targetPropertyPath\n .get('value')\n .replaceWith(t.stringLiteral(newEntryData));\n } else if ((newEntryData as any)?.[NodeType.Translation]) {\n // Handle translation content (use first available translation)\n const translations = (newEntryData as TranslationContent)[\n NodeType.Translation\n ];\n const firstValue = Object.values(translations)[0];\n if (firstValue) {\n targetPropertyPath\n .get('value')\n .replaceWith(t.stringLiteral(String(firstValue)));\n }\n } else {\n appLogger(\n `Unhandled data structure for string replacement at '${entryKeyToUpdate}' in ${filePath}.`,\n { level: 'warn', isVerbose: true }\n );\n }\n }\n // Handle other value types (objects, arrays, etc.)\n else {\n const valueType = callExpressionPath.node.type;\n appLogger(\n `Updating value of type ${valueType} for '${entryKeyToUpdate}' in ${filePath}`,\n { level: 'info', isVerbose: true }\n );\n\n // For simple values like strings, use direct replacement\n if (typeof newEntryData === 'string') {\n targetPropertyPath\n .get('value')\n .replaceWith(t.stringLiteral(newEntryData));\n }\n // For translation content, use a smart approach\n else if ((newEntryData as any)?.[NodeType.Translation]) {\n // Extract just the value relevant to this file's locale\n const translations = (newEntryData as TranslationContent)[\n NodeType.Translation\n ];\n\n // Try to determine locale from file path (assuming a pattern like .fr.content.ts)\n const localeMatch = filePath.match(/\\.([a-z]{2})\\.content\\.(ts|js)$/i);\n const locale = localeMatch\n ? localeMatch[1]\n : Object.keys(translations)[0];\n\n if (translations[locale]) {\n targetPropertyPath\n .get('value')\n .replaceWith(t.stringLiteral(String(translations[locale])));\n } else {\n // Fallback to first translation\n const firstValue = Object.values(translations)[0];\n if (firstValue) {\n targetPropertyPath\n .get('value')\n .replaceWith(t.stringLiteral(String(firstValue)));\n }\n }\n } else {\n appLogger(\n `Cannot update value of type ${valueType} for '${entryKeyToUpdate}' in ${filePath}. Unsupported data structure.`,\n { level: 'warn', isVerbose: true }\n );\n }\n }\n }\n\n // Generate JavaScript/TypeScript code from the modified AST\n const generatedCode = generator(ast, {\n retainLines: true,\n comments: true,\n jsescOption: {\n minimal: true, // This ensures Unicode characters are not escaped\n },\n }).code;\n\n let finalCode = generatedCode;\n\n finalCode = await formatCode(filePath, finalCode);\n\n // Write the modified code back to the file\n try {\n await writeFile(filePath, finalCode, 'utf-8');\n logger(`Successfully updated ${filePath}`, {\n level: 'info',\n isVerbose: true,\n });\n } catch (error) {\n const err = error as Error;\n logger(`Failed to write updated file: ${filePath}`, {\n level: 'error',\n });\n throw new Error(`Failed to write updated file ${filePath}: ${err.message}`);\n }\n};\n"],"mappings":"AAAA,OAAO,eAAe;AACtB,YAAY,iBAAiB;AAC7B,OAAO,cAA4B;AACnC,YAAY,OAAO;AACnB,SAAS,cAAc,cAAc;AACrC,OAAO,mBAAmB;AAC1B;AAAA,EAEE;AAAA,OAGK;AACP,SAAS,kBAAkB;AAC3B,SAAS,UAAU,iBAAiB;AACpC,SAAS,eAAe;AACxB,SAAS,yCAAyC;AAClD,SAAS,kBAAkB;AAQpB,MAAM,cAAc,OACzB,UACA,eACkB;AAClB,QAAM,YAAY,aAAa,aAAa;AAE5C,QAAM;AAAA,IACJ,KAAK;AAAA,IACL,SAAS;AAAA,IACT;AAAA,IACA;AAAA,EACF,IAAI;AACJ,QAAM,6BAA6B,OAAO,WAAW;AAGrD,MAAI,CAAC,WAAW,QAAQ,GAAG;AACzB,UAAM,gBAAgB,QAAQ,QAAQ;AAEtC,QAAI,SAAS;AAEb,QAAI,kBAAkB,SAAS,kBAAkB,QAAQ;AACvD,eAAS;AAAA,IACX,WAAW,kBAAkB,UAAU,kBAAkB,SAAS;AAChE,eAAS;AAAA,IACX,OAAO;AACL,eAAS;AAAA,IACX;AAEA,cAAU,oCAAoC;AAAA,MAC5C,WAAW;AAAA,IACb,CAAC;AACD,UAAM,WAAW,MAAM;AAAA,MACrB;AAAA,MACA;AAAA,MACA,EAAE,QAAQ,WAAW;AA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AAA,IACX;AAAA,EACF,CAAC,EAAE;AAEH,MAAI,YAAY;AAEhB,cAAY,MAAM,WAAW,UAAU,SAAS;AAGhD,MAAI;AACF,UAAM,UAAU,UAAU,WAAW,OAAO;AAC5C,WAAO,wBAAwB,QAAQ,IAAI;AAAA,MACzC,OAAO;AAAA,MACP,WAAW;AAAA,IACb,CAAC;AAAA,EACH,SAAS,OAAO;AACd,UAAM,MAAM;AACZ,WAAO,iCAAiC,QAAQ,IAAI;AAAA,MAClD,OAAO;AAAA,IACT,CAAC;AACD,UAAM,IAAI,MAAM,gCAAgC,QAAQ,KAAK,IAAI,OAAO,EAAE;AAAA,EAC5E;AACF;","names":["keyNode","locale"]}
1
+ {"version":3,"sources":["../../../src/writeContentDeclaration/writeJSFile.ts"],"sourcesContent":["import generator from '@babel/generator';\nimport * as babelParser from '@babel/parser';\nimport traverse, { NodePath } from '@babel/traverse';\nimport * as t from '@babel/types';\nimport { getAppLogger, logger } from '@intlayer/config';\nimport configuration from '@intlayer/config/built';\nimport {\n Dictionary,\n NodeType,\n TranslationContent,\n TypedNode,\n} from '@intlayer/core';\nimport { existsSync } from 'fs';\nimport { readFile, writeFile } from 'fs/promises';\nimport { extname } from 'path';\nimport { getContentDeclarationFileTemplate } from '../getContentDeclarationFileTemplate/getContentDeclarationFileTemplate';\nimport { formatCode } from './formatCode';\n\n/**\n * Updates a JavaScript/TypeScript file based on the provided JSON instructions.\n * It targets a specific dictionary object within the file (identified by its 'key' property)\n * and updates its 'content' entries. Currently, it focuses on modifying arguments\n * of 't' (translation) function calls.\n */\nexport const writeJSFile = async (\n filePath: string,\n dictionary: Dictionary\n): Promise<void> => {\n const appLogger = getAppLogger(configuration);\n\n const {\n key: dictionaryIdentifierKey,\n content: updatesToApply,\n locale,\n autoFilled,\n } = dictionary;\n const isPerLocaleDeclarationFile = typeof locale === 'string';\n\n // Check if the file exist\n if (!existsSync(filePath)) {\n const fileExtension = extname(filePath);\n\n let format = 'ts' as 'ts' | 'cjs' | 'esm';\n\n if (fileExtension === '.ts' || fileExtension === '.tsx') {\n format = 'ts';\n } else if (fileExtension === '.cjs' || fileExtension === '.cjsx') {\n format = 'cjs';\n } else {\n format = 'esm';\n }\n\n appLogger('File does not exist, creating it', {\n isVerbose: true,\n });\n const template = await getContentDeclarationFileTemplate(\n dictionaryIdentifierKey,\n format,\n { locale, autoFilled }\n );\n\n await writeFile(filePath, template, 'utf-8');\n }\n\n let sourceCode: string;\n try {\n sourceCode = await readFile(filePath, 'utf-8');\n } catch (error) {\n const err = error as Error;\n appLogger(`Failed to read file: ${filePath}`, {\n level: 'error',\n });\n throw new Error(`Failed to read file ${filePath}: ${err.message}`);\n }\n\n const ast = babelParser.parse(sourceCode, {\n sourceType: 'module',\n plugins: ['typescript', 'jsx'],\n tokens: true,\n });\n\n let dictionaryObjectPath: NodePath<t.ObjectExpression> | null = null;\n let dictionaryIdentifier: string | null = null;\n\n // First look for direct objects with the right key, regardless of variable assignments\n traverse(ast, {\n ObjectExpression(path) {\n if (dictionaryObjectPath) return; // Already found\n\n // Check if this object has a key property with the right value\n const keyProp = path.node.properties.find((prop) => {\n if (!t.isObjectProperty(prop)) return false;\n if (!t.isIdentifier(prop.key) && !t.isStringLiteral(prop.key))\n return false;\n\n const keyName = t.isIdentifier(prop.key)\n ? prop.key.name\n : prop.key.value;\n\n if (keyName !== 'key' || !t.isStringLiteral(prop.value)) return false;\n\n // Unescape the value for comparison\n const propValue = prop.value.value;\n // Compare actual string content, not just raw representation\n return propValue === dictionaryIdentifierKey;\n });\n\n if (keyProp) {\n dictionaryObjectPath = path;\n path.stop();\n }\n },\n });\n\n // If not found directly, look for variable declarations and exports\n if (!dictionaryObjectPath) {\n appLogger(`Looking for variable declarations`, {\n isVerbose: true,\n });\n\n // Collect all variable declarations with objects\n const candidateVars: { id: string; path: NodePath<t.ObjectExpression> }[] =\n [];\n\n traverse(ast, {\n VariableDeclarator(path) {\n const { node } = path;\n if (!t.isIdentifier(node.id)) return;\n\n let objPath: NodePath<t.ObjectExpression> | null = null;\n\n // Direct object assignment\n if (node.init && t.isObjectExpression(node.init)) {\n objPath = path.get('init') as NodePath<t.ObjectExpression>;\n }\n // Object with TS type assertion (satisfies/as)\n else if (\n node.init &&\n (t.isTSAsExpression(node.init) || t.isTSTypeAssertion(node.init)) &&\n t.isObjectExpression(node.init.expression)\n ) {\n objPath = path.get('init.expression') as NodePath<t.ObjectExpression>;\n }\n\n if (objPath) {\n candidateVars.push({ id: node.id.name, path: objPath });\n }\n },\n });\n\n appLogger(`Found ${candidateVars.length} candidate variables`, {\n isVerbose: true,\n });\n\n // Check each candidate for the key property\n for (const { id, path } of candidateVars) {\n const keyProp = path.node.properties.find((prop) => {\n if (!t.isObjectProperty(prop)) return false;\n if (!t.isIdentifier(prop.key) && !t.isStringLiteral(prop.key))\n return false;\n\n const keyName = t.isIdentifier(prop.key)\n ? prop.key.name\n : prop.key.value;\n return (\n keyName === 'key' &&\n t.isStringLiteral(prop.value) &&\n prop.value.value === dictionaryIdentifierKey\n );\n });\n\n if (keyProp) {\n appLogger(`Found match in variable: ${id}`);\n dictionaryObjectPath = path;\n dictionaryIdentifier = id;\n break;\n }\n }\n\n // If still not found, dump all object expressions for debugging\n if (!dictionaryObjectPath) {\n appLogger('Could not find dictionary object. Dumping all objects:', {\n isVerbose: true,\n });\n traverse(ast, {\n ObjectExpression(path) {\n const props = path.node.properties\n .map((prop) => {\n if (!t.isObjectProperty(prop)) return 'non-object-property';\n if (!t.isIdentifier(prop.key) && !t.isStringLiteral(prop.key))\n return 'complex-key';\n\n const keyName = t.isIdentifier(prop.key)\n ? prop.key.name\n : prop.key.value;\n let valueDesc = 'unknown-value';\n\n if (t.isStringLiteral(prop.value)) {\n valueDesc = `\"${prop.value.value}\"`;\n }\n\n return `${keyName}: ${valueDesc}`;\n })\n .join(', ');\n\n appLogger(`Object: { ${props} }`);\n },\n });\n }\n }\n\n if (!dictionaryObjectPath) {\n throw new Error(\n `Could not find dictionary object with key '${dictionaryIdentifierKey}' in ${filePath}`\n );\n }\n\n // Find the 'content' property within the identified dictionary object\n const contentPropertyPath = (\n (dictionaryObjectPath as any).get('properties') as NodePath<\n t.ObjectProperty | t.SpreadElement | t.ObjectMethod\n >[]\n ).find((propPath) => {\n if (!propPath.isObjectProperty()) return false;\n const propNode = propPath.node;\n const keyName = t.isIdentifier(propNode.key)\n ? propNode.key.name\n : t.isStringLiteral(propNode.key)\n ? propNode.key.value\n : null;\n return keyName === 'content';\n });\n\n if (\n !contentPropertyPath ||\n !contentPropertyPath.isObjectProperty() ||\n !(contentPropertyPath.get('value') as NodePath).isObjectExpression()\n ) {\n throw new Error(\n `Could not find 'content' object property, or it's not an object, in dictionary in ${filePath}`\n );\n }\n\n const contentObjectPath = contentPropertyPath.get(\n 'value'\n ) as NodePath<t.ObjectExpression>;\n\n /**\n * Build a Babel Expression for any JSON-serializable value or TypedNode.\n * - Translation nodes become t({...}) or string literal in per-locale files\n * - Objects recurse to ObjectExpression\n * - Arrays recurse to ArrayExpression\n * - Strings/numbers/booleans/null to corresponding literals\n */\n const buildValueNodeFromData = (data: any): t.Expression => {\n // Translation typed node\n if ((data as TypedNode)?.nodeType === NodeType.Translation) {\n const translationContent = data as TranslationContent;\n if (\n isPerLocaleDeclarationFile &&\n typeof locale === 'string' &&\n translationContent?.[NodeType.Translation]?.[locale] !== undefined\n ) {\n return buildValueNodeFromData(\n translationContent[NodeType.Translation][locale]\n );\n }\n const translationsObj = t.objectExpression(\n Object.entries(translationContent?.[NodeType.Translation] ?? {}).map(\n ([langKey, langValue]) => {\n const keyNode = t.isValidIdentifier(langKey)\n ? t.identifier(langKey)\n : t.stringLiteral(langKey);\n return t.objectProperty(keyNode, buildValueNodeFromData(langValue));\n }\n )\n );\n return t.callExpression(t.identifier('t'), [translationsObj]);\n }\n\n // Arrays\n if (Array.isArray(data)) {\n return t.arrayExpression(data.map((el) => buildValueNodeFromData(el)));\n }\n\n // Objects (plain)\n if (data && typeof data === 'object') {\n const props = Object.entries(data).map(([k, v]) => {\n const key = t.isValidIdentifier(k)\n ? t.identifier(k)\n : t.stringLiteral(k);\n return t.objectProperty(key, buildValueNodeFromData(v));\n });\n return t.objectExpression(props);\n }\n\n // Primitives\n switch (typeof data) {\n case 'string':\n return t.stringLiteral(data);\n case 'number':\n return t.numericLiteral(data);\n case 'boolean':\n return t.booleanLiteral(data);\n default:\n return t.nullLiteral();\n }\n };\n\n /** Ensure an object property exists on a given object expression path. */\n const ensureObjectProperty = (\n objPath: NodePath<t.ObjectExpression>,\n key: string\n ): NodePath<t.ObjectProperty> => {\n const existing = (\n objPath.get('properties') as NodePath<\n t.ObjectProperty | t.SpreadElement | t.ObjectMethod\n >[]\n ).find((propPath) => {\n if (!propPath.isObjectProperty()) return false;\n const propNode = propPath.node;\n const keyName = t.isIdentifier(propNode.key)\n ? propNode.key.name\n : t.isStringLiteral(propNode.key)\n ? propNode.key.value\n : null;\n return keyName === key;\n }) as NodePath<t.ObjectProperty> | undefined;\n\n if (existing) return existing;\n\n const keyNode = t.isValidIdentifier(key)\n ? t.identifier(key)\n : t.stringLiteral(key);\n const newProp = t.objectProperty(keyNode, t.objectExpression([]));\n objPath.node.properties.push(newProp);\n\n // Return a fresh path for the newly pushed property\n const props = objPath.get('properties') as NodePath<\n t.ObjectProperty | t.SpreadElement | t.ObjectMethod\n >[];\n return props[props.length - 1] as NodePath<t.ObjectProperty>;\n };\n\n /** Recursively merge a JSON-like value into an ObjectExpression property path. */\n const mergeValueIntoProperty = (\n propPath: NodePath<t.ObjectProperty>,\n value: any,\n propKeyForLogs: string\n ) => {\n const valuePath = propPath.get('value') as NodePath;\n\n // Translation typed node → either update t() args or replace value\n if ((value as TypedNode)?.nodeType === NodeType.Translation) {\n const translationContent = value as TranslationContent;\n if (\n valuePath.isCallExpression() &&\n t.isIdentifier(valuePath.node.callee) &&\n valuePath.node.callee.name === 't'\n ) {\n // Replace argument with the full translations object (simpler and robust)\n const translationsObj = t.objectExpression(\n Object.entries(translationContent?.[NodeType.Translation] ?? {}).map(\n ([langKey, langValue]) =>\n t.objectProperty(\n t.isValidIdentifier(langKey)\n ? t.identifier(langKey)\n : t.stringLiteral(langKey),\n buildValueNodeFromData(langValue)\n )\n )\n );\n\n if (isPerLocaleDeclarationFile && typeof locale === 'string') {\n const localized =\n translationContent?.[NodeType.Translation]?.[locale];\n if (localized !== undefined) {\n valuePath.replaceWith(buildValueNodeFromData(localized));\n return;\n }\n }\n\n (valuePath.node as t.CallExpression).arguments = [translationsObj];\n return;\n }\n\n // Otherwise, replace with a fresh node\n valuePath.replaceWith(buildValueNodeFromData(value));\n return;\n }\n\n // Arrays → replace entirely\n if (Array.isArray(value)) {\n valuePath.replaceWith(buildValueNodeFromData(value));\n return;\n }\n\n // Objects → ensure object expression and recurse into each key\n if (value && typeof value === 'object') {\n if (!valuePath.isObjectExpression()) {\n valuePath.replaceWith(t.objectExpression([]));\n }\n const objPath = valuePath as NodePath<t.ObjectExpression>;\n for (const [k, v] of Object.entries(value)) {\n const childProp = ensureObjectProperty(objPath, k);\n mergeValueIntoProperty(childProp, v, `${propKeyForLogs}.${k}`);\n }\n return;\n }\n\n // Primitives → replace\n valuePath.replaceWith(buildValueNodeFromData(value));\n return;\n };\n\n // Apply updates to each entry specified in the JSON (now supports deep nesting)\n for (const [entryKeyToUpdate, newEntryData] of Object.entries(\n updatesToApply\n )) {\n let targetPropertyPath = (\n contentObjectPath.get('properties') as NodePath<\n t.ObjectProperty | t.SpreadElement | t.ObjectMethod\n >[]\n ).find((propPath) => {\n if (!propPath.isObjectProperty()) return false;\n const propNode = propPath.node;\n const keyName = t.isIdentifier(propNode.key)\n ? propNode.key.name\n : t.isStringLiteral(propNode.key)\n ? propNode.key.value\n : null;\n return keyName === entryKeyToUpdate;\n }) as NodePath<t.ObjectProperty> | undefined;\n\n if (!targetPropertyPath) {\n const keyNode = t.isValidIdentifier(entryKeyToUpdate)\n ? t.identifier(entryKeyToUpdate)\n : t.stringLiteral(entryKeyToUpdate);\n // By default create an empty object; merge will replace if needed\n const newProperty = t.objectProperty(keyNode, t.objectExpression([]));\n contentObjectPath.node.properties.push(newProperty);\n const props = contentObjectPath.get('properties') as NodePath<\n t.ObjectProperty | t.SpreadElement | t.ObjectMethod\n >[];\n targetPropertyPath = props[\n props.length - 1\n ] as NodePath<t.ObjectProperty>;\n }\n\n mergeValueIntoProperty(targetPropertyPath, newEntryData, entryKeyToUpdate);\n }\n\n // Generate JavaScript/TypeScript code from the modified AST\n const generatedCode = generator(ast, {\n retainLines: true,\n comments: true,\n jsescOption: {\n minimal: true, // This ensures Unicode characters are not escaped\n },\n }).code;\n\n let finalCode = generatedCode;\n\n finalCode = await formatCode(filePath, finalCode);\n\n // Write the modified code back to the file\n try {\n await writeFile(filePath, finalCode, 'utf-8');\n logger(`Successfully updated ${filePath}`, {\n level: 'info',\n isVerbose: true,\n });\n } catch (error) {\n const err = error as Error;\n logger(`Failed to write updated file: ${filePath}`, {\n level: 'error',\n });\n throw new Error(`Failed to write updated file ${filePath}: ${err.message}`);\n }\n};\n"],"mappings":"AAAA,OAAO,eAAe;AACtB,YAAY,iBAAiB;AAC7B,OAAO,cAA4B;AACnC,YAAY,OAAO;AACnB,SAAS,cAAc,cAAc;AACrC,OAAO,mBAAmB;AAC1B;AAAA,EAEE;AAAA,OAGK;AACP,SAAS,kBAAkB;AAC3B,SAAS,UAAU,iBAAiB;AACpC,SAAS,eAAe;AACxB,SAAS,yCAAyC;AAClD,SAAS,kBAAkB;AAQpB,MAAM,cAAc,OACzB,UACA,eACkB;AAClB,QAAM,YAAY,aAAa,aAAa;AAE5C,QAAM;AAAA,IACJ,KAAK;AAAA,IACL,SAAS;AAAA,IACT;AAAA,IACA;AAAA,EACF,IAAI;AACJ,QAAM,6BAA6B,OAAO,WAAW;AAGrD,MAAI,CAAC,WAAW,QAAQ,GAAG;AACzB,UAAM,gBAAgB,QAAQ,QAAQ;AAEtC,QAAI,SAAS;AAEb,QAAI,kBAAkB,SAAS,kBAAkB,QAAQ;AACvD,e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AO,YAAY;AAAA,IACrB,CAAC;AAED,QAAI,CAAC,oBAAoB;AACvB,YAAM,UAAU,EAAE,kBAAkB,gBAAgB,IAChD,EAAE,WAAW,gBAAgB,IAC7B,EAAE,cAAc,gBAAgB;AAEpC,YAAM,cAAc,EAAE,eAAe,SAAS,EAAE,iBAAiB,CAAC,CAAC,CAAC;AACpE,wBAAkB,KAAK,WAAW,KAAK,WAAW;AAClD,YAAM,QAAQ,kBAAkB,IAAI,YAAY;AAGhD,2BAAqB,MACnB,MAAM,SAAS,CACjB;AAAA,IACF;AAEA,2BAAuB,oBAAoB,cAAc,gBAAgB;AAAA,EAC3E;AAGA,QAAM,gBAAgB,UAAU,KAAK;AAAA,IACnC,aAAa;AAAA,IACb,UAAU;AAAA,IACV,aAAa;AAAA,MACX,SAAS;AAAA;AAAA,IACX;AAAA,EACF,CAAC,EAAE;AAEH,MAAI,YAAY;AAEhB,cAAY,MAAM,WAAW,UAAU,SAAS;AAGhD,MAAI;AACF,UAAM,UAAU,UAAU,WAAW,OAAO;AAC5C,WAAO,wBAAwB,QAAQ,IAAI;AAAA,MACzC,OAAO;AAAA,MACP,WAAW;AAAA,IACb,CAAC;AAAA,EACH,SAAS,OAAO;AACd,UAAM,MAAM;AACZ,WAAO,iCAAiC,QAAQ,IAAI;AAAA,MAClD,OAAO;AAAA,IACT,CAAC;AACD,UAAM,IAAI,MAAM,gCAAgC,QAAQ,KAAK,IAAI,OAAO,EAAE;AAAA,EAC5E;AACF;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"loadDictionaries.d.ts","sourceRoot":"","sources":["../../../src/loadDictionaries/loadDictionaries.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAOjD,eAAO,MAAM,gBAAgB,GAC3B,0BAA0B,MAAM,EAAE,GAAG,MAAM,EAC3C,yDAAkC,EAClC,+BAA+B,KAC9B,OAAO,CAAC,UAAU,EAAE,CAmFtB,CAAC"}
1
+ {"version":3,"file":"loadDictionaries.d.ts","sourceRoot":"","sources":["../../../src/loadDictionaries/loadDictionaries.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAQjD,eAAO,MAAM,gBAAgB,GAC3B,0BAA0B,MAAM,EAAE,GAAG,MAAM,EAC3C,yDAAkC,EAClC,+BAA+B,KAC9B,OAAO,CAAC,UAAU,EAAE,CAqFtB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"mergeDictionaries.d.ts","sourceRoot":"","sources":["../../src/mergeDictionaries.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAiCjD,eAAO,MAAM,iBAAiB,GAAI,cAAc,UAAU,EAAE,KAAG,UA0B9D,CAAC"}
1
+ {"version":3,"file":"mergeDictionaries.d.ts","sourceRoot":"","sources":["../../src/mergeDictionaries.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAuGjD,eAAO,MAAM,iBAAiB,GAAI,cAAc,UAAU,EAAE,KAAG,UAuC9D,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"applyMask.d.ts","sourceRoot":"","sources":["../../../src/reduceDictionaryContent/applyMask.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD,eAAO,MAAM,SAAS,GAAI,MAAM,UAAU,EAAE,MAAM,GAAG,KAAG,UA8BvD,CAAC"}
1
+ {"version":3,"file":"applyMask.d.ts","sourceRoot":"","sources":["../../../src/reduceDictionaryContent/applyMask.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD,eAAO,MAAM,SAAS,GAAI,MAAM,UAAU,EAAE,MAAM,GAAG,KAAG,UAoDvD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"formatCode.d.ts","sourceRoot":"","sources":["../../../src/writeContentDeclaration/formatCode.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,UAAU,GAAU,UAAU,MAAM,EAAE,MAAM,MAAM,iBA0C9D,CAAC"}
1
+ {"version":3,"file":"formatCode.d.ts","sourceRoot":"","sources":["../../../src/writeContentDeclaration/formatCode.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,UAAU,GAAU,UAAU,MAAM,EAAE,MAAM,MAAM,iBA4C9D,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"writeJSFile.d.ts","sourceRoot":"","sources":["../../../src/writeContentDeclaration/writeJSFile.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,UAAU,EAIX,MAAM,gBAAgB,CAAC;AAOxB;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GACtB,UAAU,MAAM,EAChB,YAAY,UAAU,KACrB,OAAO,CAAC,IAAI,CA6fd,CAAC"}
1
+ {"version":3,"file":"writeJSFile.d.ts","sourceRoot":"","sources":["../../../src/writeContentDeclaration/writeJSFile.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,UAAU,EAIX,MAAM,gBAAgB,CAAC;AAOxB;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GACtB,UAAU,MAAM,EAChB,YAAY,UAAU,KACrB,OAAO,CAAC,IAAI,CAocd,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intlayer/chokidar",
3
- "version": "5.7.7",
3
+ "version": "5.8.0-canary.0",
4
4
  "private": false,
5
5
  "description": "Uses chokidar to scan and build Intlayer declaration files into dictionaries based on Intlayer configuration.",
6
6
  "keywords": [
@@ -68,42 +68,42 @@
68
68
  "fast-glob": "^3.3.3",
69
69
  "p-limit": "^3.1.0",
70
70
  "simple-git": "^3.27.0",
71
- "@intlayer/api": "5.7.7",
72
- "@intlayer/core": "5.7.7",
73
- "intlayer": "5.7.7",
74
- "@intlayer/config": "5.7.7",
75
- "@intlayer/unmerged-dictionaries-entry": "5.7.7",
76
- "@intlayer/dictionaries-entry": "5.7.7"
71
+ "@intlayer/api": "5.8.0-canary.0",
72
+ "@intlayer/config": "5.8.0-canary.0",
73
+ "@intlayer/core": "5.8.0-canary.0",
74
+ "@intlayer/unmerged-dictionaries-entry": "5.8.0-canary.0",
75
+ "intlayer": "5.8.0-canary.0",
76
+ "@intlayer/dictionaries-entry": "5.8.0-canary.0"
77
77
  },
78
78
  "devDependencies": {
79
- "@changesets/cli": "2.29.4",
79
+ "@changesets/cli": "2.29.5",
80
80
  "@types/babel__generator": "^7.27.0",
81
81
  "@types/babel__traverse": "^7.20.7",
82
82
  "@types/crypto-js": "^4.2.2",
83
83
  "@types/deep-equal": "^1.0.4",
84
- "@types/node": "^22.15.30",
84
+ "@types/node": "^24.2.1",
85
85
  "@typescript-eslint/parser": "^8.33.1",
86
86
  "concurrently": "^9.1.2",
87
- "eslint": "^9.28.0",
87
+ "eslint": "^9.33.0",
88
88
  "prettier": "^3.5.3",
89
89
  "rimraf": "^6.0.1",
90
90
  "tsc-alias": "^1.8.16",
91
91
  "tsup": "^8.5.0",
92
- "typescript": "^5.8.3",
92
+ "typescript": "^5.9.2",
93
93
  "vitest": "^3.2.2",
94
94
  "@utils/eslint-config": "1.0.4",
95
95
  "@utils/ts-config-types": "1.0.4",
96
- "@utils/tsup-config": "1.0.4",
97
96
  "@utils/ts-config": "1.0.4",
98
- "@intlayer/backend": "5.7.7"
97
+ "@utils/tsup-config": "1.0.4",
98
+ "@intlayer/backend": "5.8.0-canary.0"
99
99
  },
100
100
  "peerDependencies": {
101
101
  "fast-glob": "^3.3.3",
102
102
  "react": ">=16.0.0",
103
- "@intlayer/api": "5.7.7",
104
- "@intlayer/config": "5.7.7",
105
- "@intlayer/core": "5.7.7",
106
- "intlayer": "5.7.7"
103
+ "@intlayer/config": "5.8.0-canary.0",
104
+ "intlayer": "5.8.0-canary.0",
105
+ "@intlayer/api": "5.8.0-canary.0",
106
+ "@intlayer/core": "5.8.0-canary.0"
107
107
  },
108
108
  "engines": {
109
109
  "node": ">=14.18"
@@ -1,107 +0,0 @@
1
- "use strict";
2
- var import_vitest = require("vitest");
3
- var import_resolveObjectPromises = require('./resolveObjectPromises.cjs');
4
- const getKeysInOrder = (obj) => {
5
- return Object.keys(obj);
6
- };
7
- const delay = async (ms) => {
8
- await new Promise((resolve) => setTimeout(resolve, ms));
9
- };
10
- const testCase = {
11
- test1: 1,
12
- test2: () => 2,
13
- test3: async () => 3,
14
- test4: [
15
- 41,
16
- () => 42,
17
- async () => {
18
- await delay(100);
19
- return 43;
20
- },
21
- [
22
- Promise.resolve(44),
23
- async () => {
24
- await delay(100);
25
- return 45;
26
- },
27
- 46
28
- ]
29
- ],
30
- test5: {
31
- test51: () => 51,
32
- test52: () => 52,
33
- test53: () => 53
34
- },
35
- test6: {
36
- test61: {
37
- test611: 611,
38
- test612: 612,
39
- test613: 613
40
- }
41
- },
42
- test7: {
43
- test71: async () => {
44
- await delay(100);
45
- return {
46
- test711: async () => 711,
47
- test712: async () => {
48
- await delay(100);
49
- return 712;
50
- },
51
- test713: async () => {
52
- await delay(100);
53
- return [
54
- 7131,
55
- async () => {
56
- await delay(100);
57
- return 7132;
58
- },
59
- async () => {
60
- await delay(100);
61
- return 7133;
62
- },
63
- 7134
64
- ];
65
- },
66
- test714: 714
67
- };
68
- }
69
- },
70
- test8: 8
71
- };
72
- const testCaseResolved = {
73
- test1: 1,
74
- test2: 2,
75
- test3: 3,
76
- test4: [41, 42, 43, [44, 45, 46]],
77
- test5: {
78
- test51: 51,
79
- test52: 52,
80
- test53: 53
81
- },
82
- test6: {
83
- test61: {
84
- test611: 611,
85
- test612: 612,
86
- test613: 613
87
- }
88
- },
89
- test7: {
90
- test71: {
91
- test711: 711,
92
- test712: 712,
93
- test713: [7131, 7132, 7133, 7134],
94
- test714: 714
95
- }
96
- },
97
- test8: 8
98
- };
99
- (0, import_vitest.describe)("resolveObjectPromises", () => {
100
- (0, import_vitest.it)("should the result be in the same order as the original object", async () => {
101
- const resolved = await (0, import_resolveObjectPromises.resolveObjectPromises)(testCase);
102
- (0, import_vitest.expect)(JSON.stringify(resolved)).toStrictEqual(
103
- JSON.stringify(testCaseResolved)
104
- );
105
- });
106
- });
107
- //# sourceMappingURL=resolveObjectPromises.test.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/utils/resolveObjectPromises.test.ts"],"sourcesContent":["import { describe, expect, it } from 'vitest';\nimport { resolveObjectPromises } from './resolveObjectPromises';\n\n// Helper to extract keys order of an object\nconst getKeysInOrder = (obj: Record<string, unknown>): string[] => {\n return Object.keys(obj);\n};\n\nconst delay = async (ms: number) => {\n await new Promise((resolve) => setTimeout(resolve, ms));\n};\n\nconst testCase = {\n test1: 1,\n test2: () => 2,\n test3: async () => 3,\n test4: [\n 41,\n () => 42,\n async () => {\n await delay(100);\n return 43;\n },\n [\n Promise.resolve(44),\n async () => {\n await delay(100);\n return 45;\n },\n 46,\n ],\n ],\n test5: {\n test51: () => 51,\n test52: () => 52,\n test53: () => 53,\n },\n test6: {\n test61: {\n test611: 611,\n test612: 612,\n test613: 613,\n },\n },\n test7: {\n test71: async () => {\n await delay(100);\n return {\n test711: async () => 711,\n test712: async () => {\n await delay(100);\n return 712;\n },\n test713: async () => {\n await delay(100);\n return [\n 7131,\n async () => {\n await delay(100);\n return 7132;\n },\n async () => {\n await delay(100);\n return 7133;\n },\n 7134,\n ];\n },\n test714: 714,\n };\n },\n },\n test8: 8,\n};\n\nconst testCaseResolved = {\n test1: 1,\n test2: 2,\n test3: 3,\n test4: [41, 42, 43, [44, 45, 46]],\n test5: {\n test51: 51,\n test52: 52,\n test53: 53,\n },\n test6: {\n test61: {\n test611: 611,\n test612: 612,\n test613: 613,\n },\n },\n test7: {\n test71: {\n test711: 711,\n test712: 712,\n test713: [7131, 7132, 7133, 7134],\n test714: 714,\n },\n },\n test8: 8,\n};\n\ndescribe('resolveObjectPromises', () => {\n it('should the result be in the same order as the original object', async () => {\n const resolved = await resolveObjectPromises<typeof testCase>(testCase);\n\n // Stringify the objects to ensure the order of the keys is the same\n expect(JSON.stringify(resolved)).toStrictEqual(\n JSON.stringify(testCaseResolved)\n );\n });\n});\n"],"mappings":";AAAA,oBAAqC;AACrC,mCAAsC;AAGtC,MAAM,iBAAiB,CAAC,QAA2C;AACjE,SAAO,OAAO,KAAK,GAAG;AACxB;AAEA,MAAM,QAAQ,OAAO,OAAe;AAClC,QAAM,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,EAAE,CAAC;AACxD;AAEA,MAAM,WAAW;AAAA,EACf,OAAO;AAAA,EACP,OAAO,MAAM;AAAA,EACb,OAAO,YAAY;AAAA,EACnB,OAAO;AAAA,IACL;AAAA,IACA,MAAM;AAAA,IACN,YAAY;AACV,YAAM,MAAM,GAAG;AACf,aAAO;AAAA,IACT;AAAA,IACA;AAAA,MACE,QAAQ,QAAQ,EAAE;AAAA,MAClB,YAAY;AACV,cAAM,MAAM,GAAG;AACf,eAAO;AAAA,MACT;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAAA,EACA,OAAO;AAAA,IACL,QAAQ,MAAM;AAAA,IACd,QAAQ,MAAM;AAAA,IACd,QAAQ,MAAM;AAAA,EAChB;AAAA,EACA,OAAO;AAAA,IACL,QAAQ;AAAA,MACN,SAAS;AAAA,MACT,SAAS;AAAA,MACT,SAAS;AAAA,IACX;AAAA,EACF;AAAA,EACA,OAAO;AAAA,IACL,QAAQ,YAAY;AAClB,YAAM,MAAM,GAAG;AACf,aAAO;AAAA,QACL,SAAS,YAAY;AAAA,QACrB,SAAS,YAAY;AACnB,gBAAM,MAAM,GAAG;AACf,iBAAO;AAAA,QACT;AAAA,QACA,SAAS,YAAY;AACnB,gBAAM,MAAM,GAAG;AACf,iBAAO;AAAA,YACL;AAAA,YACA,YAAY;AACV,oBAAM,MAAM,GAAG;AACf,qBAAO;AAAA,YACT;AAAA,YACA,YAAY;AACV,oBAAM,MAAM,GAAG;AACf,q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