@intlayer/cli 7.0.0-canary.2 → 7.0.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 (38) hide show
  1. package/dist/cjs/fill/formatAutoFilledFilePath.cjs.map +1 -1
  2. package/dist/cjs/fill/listTranslationsTasks.cjs +1 -1
  3. package/dist/cjs/fill/listTranslationsTasks.cjs.map +1 -1
  4. package/dist/cjs/fill/writeFill.cjs +1 -1
  5. package/dist/cjs/fill/writeFill.cjs.map +1 -1
  6. package/dist/esm/fill/formatAutoFilledFilePath.mjs.map +1 -1
  7. package/dist/esm/fill/listTranslationsTasks.mjs +1 -1
  8. package/dist/esm/fill/listTranslationsTasks.mjs.map +1 -1
  9. package/dist/esm/fill/writeFill.mjs +1 -1
  10. package/dist/esm/fill/writeFill.mjs.map +1 -1
  11. package/dist/types/config.d.ts.map +1 -1
  12. package/dist/types/fill/formatAutoFillData.d.ts +7 -10
  13. package/dist/types/fill/formatAutoFillData.d.ts.map +1 -1
  14. package/dist/types/fill/formatAutoFilledFilePath.d.ts.map +1 -1
  15. package/dist/types/fill/index.d.ts.map +1 -0
  16. package/dist/types/fill/writeAutoFill.d.ts +3 -6
  17. package/dist/types/fill/writeAutoFill.d.ts.map +1 -1
  18. package/dist/types/index.d.ts.map +1 -0
  19. package/package.json +19 -19
  20. package/dist/cjs/fill/formatAutoFillData.cjs +0 -50
  21. package/dist/cjs/fill/formatAutoFillData.cjs.map +0 -1
  22. package/dist/cjs/fill/groupLimiter.cjs +0 -42
  23. package/dist/cjs/fill/groupLimiter.cjs.map +0 -1
  24. package/dist/cjs/fill/test-original-case.cjs +0 -10
  25. package/dist/cjs/fill/test-original-case.cjs.map +0 -1
  26. package/dist/cjs/fill/writeAutoFill.cjs +0 -48
  27. package/dist/cjs/fill/writeAutoFill.cjs.map +0 -1
  28. package/dist/esm/fill/formatAutoFillData.mjs +0 -50
  29. package/dist/esm/fill/formatAutoFillData.mjs.map +0 -1
  30. package/dist/esm/fill/groupLimiter.mjs +0 -40
  31. package/dist/esm/fill/groupLimiter.mjs.map +0 -1
  32. package/dist/esm/fill/test-original-case.mjs +0 -10
  33. package/dist/esm/fill/test-original-case.mjs.map +0 -1
  34. package/dist/esm/fill/writeAutoFill.mjs +0 -44
  35. package/dist/esm/fill/writeAutoFill.mjs.map +0 -1
  36. package/dist/types/fill/groupLimiter.d.ts +0 -15
  37. package/dist/types/fill/groupLimiter.d.ts.map +0 -1
  38. package/dist/types/fill/test-original-case.d.ts +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"formatAutoFilledFilePath.cjs","names":["result: string"],"sources":["../../../src/fill/formatAutoFilledFilePath.ts"],"sourcesContent":["import {\n basename,\n dirname,\n isAbsolute,\n normalize,\n relative,\n resolve,\n} from 'node:path';\nimport type { LocalesValues } from '@intlayer/types';\n\nexport const formatAutoFilledFilePath = (\n autoFillField: string,\n dictionaryKey: string,\n dictionaryFilePath: string,\n baseDir: string,\n locale?: LocalesValues\n): string => {\n // Validate inputs\n if (!autoFillField || typeof autoFillField !== 'string') {\n throw new Error('autoFillField must be a non-empty string');\n }\n if (!dictionaryKey || typeof dictionaryKey !== 'string') {\n throw new Error('dictionaryKey must be a non-empty string');\n }\n if (!dictionaryFilePath || typeof dictionaryFilePath !== 'string') {\n throw new Error('dictionaryFilePath must be a non-empty string');\n }\n if (!baseDir || typeof baseDir !== 'string') {\n throw new Error('baseDir must be a non-empty string');\n }\n\n // Extract the original filename without extensions (.content.ts -> dictionaryFieldEditor)\n const originalFileName = basename(dictionaryFilePath)\n .split('.')\n .slice(0, -2) // Remove last 2 extensions (.content.tsx)\n .join('.');\n\n // Replace placeholders in autoFillField\n let result: string = autoFillField\n .replace(/\\{\\{key\\}\\}/g, originalFileName) // Use original filename, not dictionaryKey\n .replace(/\\{\\{fileName\\}\\}/g, originalFileName);\n\n if (locale) {\n result = result.replace(/\\{\\{locale\\}\\}/g, locale);\n }\n\n // Normalize the dictionary file path - if it's relative, make it absolute relative to baseDir\n const absoluteDictionaryPath = isAbsolute(dictionaryFilePath)\n ? dictionaryFilePath\n : resolve(baseDir, dictionaryFilePath);\n\n // Handle relative paths (starting with ./ or ../)\n if (result.startsWith('./') || result.startsWith('../')) {\n const fileDir = dirname(absoluteDictionaryPath);\n const resolvedPath = resolve(fileDir, result);\n\n return resolvedPath;\n }\n\n // Handle absolute paths\n if (isAbsolute(result)) {\n const normalizedResult = normalize(result);\n const normalizedBaseDir = normalize(baseDir);\n\n // Check if it's relative to baseDir (starts with /)\n // but not a system path (like /usr/local)\n if (\n result.startsWith('/') &&\n !normalizedResult.startsWith(normalizedBaseDir)\n ) {\n // Try to resolve it relative to baseDir first\n const relativeToBase = resolve(baseDir, result.substring(1));\n\n // If the path doesn't exist in common system directories, treat as relative to baseDir\n if (\n !result.startsWith('/usr/') &&\n !result.startsWith('/etc/') &&\n !result.startsWith('/var/') &&\n !result.startsWith('/home/') &&\n !result.startsWith('/Users/')\n ) {\n return relativeToBase;\n }\n }\n\n // It's a true system absolute path\n return normalizedResult;\n }\n\n // Default case: treat as relative to baseDir\n return normalize(result);\n};\n"],"mappings":";;;;;AAUA,MAAa,4BACX,eACA,eACA,oBACA,SACA,WACW;AAEX,KAAI,CAAC,iBAAiB,OAAO,kBAAkB,SAC7C,OAAM,IAAI,MAAM,2CAA2C;AAE7D,KAAI,CAAC,iBAAiB,OAAO,kBAAkB,SAC7C,OAAM,IAAI,MAAM,2CAA2C;AAE7D,KAAI,CAAC,sBAAsB,OAAO,uBAAuB,SACvD,OAAM,IAAI,MAAM,gDAAgD;AAElE,KAAI,CAAC,WAAW,OAAO,YAAY,SACjC,OAAM,IAAI,MAAM,qCAAqC;CAIvD,MAAM,2CAA4B,mBAAmB,CAClD,MAAM,IAAI,CACV,MAAM,GAAG,GAAG,CACZ,KAAK,IAAI;CAGZ,IAAIA,SAAiB,cAClB,QAAQ,gBAAgB,iBAAiB,CACzC,QAAQ,qBAAqB,iBAAiB;AAEjD,KAAI,OACF,UAAS,OAAO,QAAQ,mBAAmB,OAAO;CAIpD,MAAM,mDAAoC,mBAAmB,GACzD,4CACQ,SAAS,mBAAmB;AAGxC,KAAI,OAAO,WAAW,KAAK,IAAI,OAAO,WAAW,MAAM,CAIrD,sDAHwB,uBAAuB,EACT,OAAO;AAM/C,+BAAe,OAAO,EAAE;EACtB,MAAM,4CAA6B,OAAO;EAC1C,MAAM,6CAA8B,QAAQ;AAI5C,MACE,OAAO,WAAW,IAAI,IACtB,CAAC,iBAAiB,WAAW,kBAAkB,EAC/C;GAEA,MAAM,wCAAyB,SAAS,OAAO,UAAU,EAAE,CAAC;AAG5D,OACE,CAAC,OAAO,WAAW,QAAQ,IAC3B,CAAC,OAAO,WAAW,QAAQ,IAC3B,CAAC,OAAO,WAAW,QAAQ,IAC3B,CAAC,OAAO,WAAW,SAAS,IAC5B,CAAC,OAAO,WAAW,UAAU,CAE7B,QAAO;;AAKX,SAAO;;AAIT,iCAAiB,OAAO"}
1
+ {"version":3,"file":"formatAutoFilledFilePath.cjs","names":["result: string"],"sources":["../../../src/fill/formatAutoFilledFilePath.ts"],"sourcesContent":["import { basename, dirname, isAbsolute, normalize, resolve } from 'node:path';\nimport type { LocalesValues } from '@intlayer/types';\n\nexport const formatAutoFilledFilePath = (\n autoFillField: string,\n dictionaryKey: string,\n dictionaryFilePath: string,\n baseDir: string,\n locale?: LocalesValues\n): string => {\n // Validate inputs\n if (!autoFillField || typeof autoFillField !== 'string') {\n throw new Error('autoFillField must be a non-empty string');\n }\n if (!dictionaryKey || typeof dictionaryKey !== 'string') {\n throw new Error('dictionaryKey must be a non-empty string');\n }\n if (!dictionaryFilePath || typeof dictionaryFilePath !== 'string') {\n throw new Error('dictionaryFilePath must be a non-empty string');\n }\n if (!baseDir || typeof baseDir !== 'string') {\n throw new Error('baseDir must be a non-empty string');\n }\n\n // Extract the original filename without extensions (.content.ts -> dictionaryFieldEditor)\n const originalFileName = basename(dictionaryFilePath)\n .split('.')\n .slice(0, -2) // Remove last 2 extensions (.content.tsx)\n .join('.');\n\n // Replace placeholders in autoFillField\n let result: string = autoFillField\n .replace(/\\{\\{key\\}\\}/g, originalFileName) // Use original filename, not dictionaryKey\n .replace(/\\{\\{fileName\\}\\}/g, originalFileName);\n\n if (locale) {\n result = result.replace(/\\{\\{locale\\}\\}/g, locale);\n }\n\n // Normalize the dictionary file path - if it's relative, make it absolute relative to baseDir\n const absoluteDictionaryPath = isAbsolute(dictionaryFilePath)\n ? dictionaryFilePath\n : resolve(baseDir, dictionaryFilePath);\n\n // Handle relative paths (starting with ./ or ../)\n if (result.startsWith('./') || result.startsWith('../')) {\n const fileDir = dirname(absoluteDictionaryPath);\n const resolvedPath = resolve(fileDir, result);\n\n return resolvedPath;\n }\n\n // Handle absolute paths\n if (isAbsolute(result)) {\n const normalizedResult = normalize(result);\n const normalizedBaseDir = normalize(baseDir);\n\n // Check if it's relative to baseDir (starts with /)\n // but not a system path (like /usr/local)\n if (\n result.startsWith('/') &&\n !normalizedResult.startsWith(normalizedBaseDir)\n ) {\n // Try to resolve it relative to baseDir first\n const relativeToBase = resolve(baseDir, result.substring(1));\n\n // If the path doesn't exist in common system directories, treat as relative to baseDir\n if (\n !result.startsWith('/usr/') &&\n !result.startsWith('/etc/') &&\n !result.startsWith('/var/') &&\n !result.startsWith('/home/') &&\n !result.startsWith('/Users/')\n ) {\n return relativeToBase;\n }\n }\n\n // It's a true system absolute path\n return normalizedResult;\n }\n\n // Default case: treat as relative to baseDir\n return normalize(result);\n};\n"],"mappings":";;;;;AAGA,MAAa,4BACX,eACA,eACA,oBACA,SACA,WACW;AAEX,KAAI,CAAC,iBAAiB,OAAO,kBAAkB,SAC7C,OAAM,IAAI,MAAM,2CAA2C;AAE7D,KAAI,CAAC,iBAAiB,OAAO,kBAAkB,SAC7C,OAAM,IAAI,MAAM,2CAA2C;AAE7D,KAAI,CAAC,sBAAsB,OAAO,uBAAuB,SACvD,OAAM,IAAI,MAAM,gDAAgD;AAElE,KAAI,CAAC,WAAW,OAAO,YAAY,SACjC,OAAM,IAAI,MAAM,qCAAqC;CAIvD,MAAM,2CAA4B,mBAAmB,CAClD,MAAM,IAAI,CACV,MAAM,GAAG,GAAG,CACZ,KAAK,IAAI;CAGZ,IAAIA,SAAiB,cAClB,QAAQ,gBAAgB,iBAAiB,CACzC,QAAQ,qBAAqB,iBAAiB;AAEjD,KAAI,OACF,UAAS,OAAO,QAAQ,mBAAmB,OAAO;CAIpD,MAAM,mDAAoC,mBAAmB,GACzD,4CACQ,SAAS,mBAAmB;AAGxC,KAAI,OAAO,WAAW,KAAK,IAAI,OAAO,WAAW,MAAM,CAIrD,sDAHwB,uBAAuB,EACT,OAAO;AAM/C,+BAAe,OAAO,EAAE;EACtB,MAAM,4CAA6B,OAAO;EAC1C,MAAM,6CAA8B,QAAQ;AAI5C,MACE,OAAO,WAAW,IAAI,IACtB,CAAC,iBAAiB,WAAW,kBAAkB,EAC/C;GAEA,MAAM,wCAAyB,SAAS,OAAO,UAAU,EAAE,CAAC;AAG5D,OACE,CAAC,OAAO,WAAW,QAAQ,IAC3B,CAAC,OAAO,WAAW,QAAQ,IAC3B,CAAC,OAAO,WAAW,QAAQ,IAC3B,CAAC,OAAO,WAAW,SAAS,IAC5B,CAAC,OAAO,WAAW,UAAU,CAE7B,QAAO;;AAKX,SAAO;;AAIT,iCAAiB,OAAO"}
@@ -30,7 +30,7 @@ const listTranslationsTasks = (localIds, outputLocales, mode, baseLocale, config
30
30
  const dictionaryKey = targetUnmergedDictionary.key;
31
31
  const dictionaryLocalId = targetUnmergedDictionary.localId;
32
32
  const mainDictionaryToProcess = mergedDictionariesRecord[dictionaryKey];
33
- if ((targetUnmergedDictionary.fill ?? configuration.content.fill) === false) continue;
33
+ if ((targetUnmergedDictionary.fill ?? configuration.dictionary?.fill ?? false) === false) continue;
34
34
  const sourceLocale = targetUnmergedDictionary.locale ?? baseLocale;
35
35
  if (!mainDictionaryToProcess) {
36
36
  appLogger(`${dictionaryPreset} Dictionary not found in dictionariesRecord. Skipping.`, { level: "warn" });
@@ -1 +1 @@
1
- {"version":3,"file":"listTranslationsTasks.cjs","names":["translationTasks: TranslationTask[]","ANSIColors","mainDictionaryToProcess: Dictionary","sourceLocale: Locale","outputLocalesList: Locale[]"],"sources":["../../../src/fill/listTranslationsTasks.ts"],"sourcesContent":["import { basename } from 'node:path';\nimport { formatLocale } from '@intlayer/chokidar';\nimport {\n ANSIColors,\n colon,\n colorize,\n colorizeKey,\n colorizePath,\n getAppLogger,\n} from '@intlayer/config';\nimport {\n getFilterTranslationsOnlyDictionary,\n getMissingLocalesContent,\n} from '@intlayer/core';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport type {\n ContentNode,\n Dictionary,\n IntlayerConfig,\n LocalDictionaryId,\n Locale,\n} from '@intlayer/types';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\n\nexport type TranslationTask = {\n dictionaryKey: string;\n dictionaryLocalId: LocalDictionaryId;\n sourceLocale: Locale;\n targetLocales: Locale[];\n dictionaryPreset: string;\n dictionaryFilePath: string;\n};\n\nexport const listTranslationsTasks = (\n localIds: LocalDictionaryId[],\n outputLocales: Locale[],\n mode: 'complete' | 'review',\n baseLocale: Locale,\n configuration: IntlayerConfig\n): TranslationTask[] => {\n const appLogger = getAppLogger(configuration);\n\n const mergedDictionariesRecord = getDictionaries(configuration);\n const unmergedDictionariesRecord = getUnmergedDictionaries(configuration);\n\n const allFlatDictionaries = Object.values(unmergedDictionariesRecord).flat();\n const dictionariesToProcess = allFlatDictionaries.filter((dictionary) =>\n localIds.includes(dictionary.localId!)\n );\n\n const maxKeyLength = Math.max(\n ...dictionariesToProcess.map((dict) => dict.key.length)\n );\n\n const translationTasks: TranslationTask[] = [];\n\n for (const targetUnmergedDictionary of dictionariesToProcess) {\n const dictionaryPreset = colon(\n [\n ' - ',\n colorize('[', ANSIColors.GREY_DARK),\n colorizeKey(targetUnmergedDictionary.key),\n colorize(']', ANSIColors.GREY_DARK),\n ].join(''),\n { colSize: maxKeyLength + 6 }\n );\n\n const dictionaryKey = targetUnmergedDictionary.key;\n const dictionaryLocalId = targetUnmergedDictionary.localId!;\n const mainDictionaryToProcess: Dictionary =\n mergedDictionariesRecord[dictionaryKey];\n const dictionaryFill =\n targetUnmergedDictionary.fill ?? configuration.content.fill;\n\n if (dictionaryFill === false) continue;\n\n const sourceLocale: Locale = (targetUnmergedDictionary.locale ??\n baseLocale) as Locale;\n\n if (!mainDictionaryToProcess) {\n appLogger(\n `${dictionaryPreset} Dictionary not found in dictionariesRecord. Skipping.`,\n {\n level: 'warn',\n }\n );\n continue;\n }\n\n if (!targetUnmergedDictionary.filePath) {\n appLogger(`${dictionaryPreset} Dictionary has no file path. Skipping.`, {\n level: 'warn',\n });\n continue;\n }\n\n const sourceLocaleContent = getFilterTranslationsOnlyDictionary(\n mainDictionaryToProcess,\n sourceLocale\n );\n\n if (\n Object.keys(sourceLocaleContent as Record<string, unknown>).length === 0\n ) {\n appLogger(\n `${dictionaryPreset} No content found for dictionary in source locale ${formatLocale(sourceLocale)}. Skipping translation for this dictionary.`,\n {\n level: 'warn',\n }\n );\n continue;\n }\n\n /**\n * In 'complete' mode, filter only the missing locales to translate\n *\n * Skip the dictionary if there are no missing locales to translate\n */\n let outputLocalesList: Locale[] = outputLocales as Locale[];\n\n if (mode === 'complete') {\n const missingLocales = getMissingLocalesContent(\n targetUnmergedDictionary as unknown as ContentNode,\n outputLocales,\n {\n dictionaryKey: targetUnmergedDictionary.key,\n keyPath: [],\n plugins: [],\n }\n );\n\n outputLocalesList = missingLocales;\n }\n\n if (outputLocalesList.length === 0) {\n appLogger(\n `${dictionaryPreset} No locales to fill, Skipping ${colorizePath(basename(targetUnmergedDictionary.filePath))}`,\n {\n level: 'warn',\n }\n );\n continue;\n }\n\n translationTasks.push({\n dictionaryKey,\n dictionaryLocalId,\n sourceLocale,\n targetLocales: outputLocalesList,\n dictionaryPreset,\n dictionaryFilePath: targetUnmergedDictionary.filePath,\n });\n }\n\n return translationTasks;\n};\n"],"mappings":";;;;;;;;;;;;;;;AAiCA,MAAa,yBACX,UACA,eACA,MACA,YACA,kBACsB;CACtB,MAAM,gDAAyB,cAAc;CAE7C,MAAM,8EAA2C,cAAc;CAC/D,MAAM,iGAAqD,cAAc;CAGzE,MAAM,wBADsB,OAAO,OAAO,2BAA2B,CAAC,MAAM,CAC1B,QAAQ,eACxD,SAAS,SAAS,WAAW,QAAS,CACvC;CAED,MAAM,eAAe,KAAK,IACxB,GAAG,sBAAsB,KAAK,SAAS,KAAK,IAAI,OAAO,CACxD;CAED,MAAMA,mBAAsC,EAAE;AAE9C,MAAK,MAAM,4BAA4B,uBAAuB;EAC5D,MAAM,gDACJ;GACE;mCACS,KAAKC,6BAAW,UAAU;sCACvB,yBAAyB,IAAI;mCAChC,KAAKA,6BAAW,UAAU;GACpC,CAAC,KAAK,GAAG,EACV,EAAE,SAAS,eAAe,GAAG,CAC9B;EAED,MAAM,gBAAgB,yBAAyB;EAC/C,MAAM,oBAAoB,yBAAyB;EACnD,MAAMC,0BACJ,yBAAyB;AAI3B,OAFE,yBAAyB,QAAQ,cAAc,QAAQ,UAElC,MAAO;EAE9B,MAAMC,eAAwB,yBAAyB,UACrD;AAEF,MAAI,CAAC,yBAAyB;AAC5B,aACE,GAAG,iBAAiB,yDACpB,EACE,OAAO,QACR,CACF;AACD;;AAGF,MAAI,CAAC,yBAAyB,UAAU;AACtC,aAAU,GAAG,iBAAiB,0CAA0C,EACtE,OAAO,QACR,CAAC;AACF;;EAGF,MAAM,+EACJ,yBACA,aACD;AAED,MACE,OAAO,KAAK,oBAA+C,CAAC,WAAW,GACvE;AACA,aACE,GAAG,iBAAiB,0FAAiE,aAAa,CAAC,8CACnG,EACE,OAAO,QACR,CACF;AACD;;;;;;;EAQF,IAAIC,oBAA8B;AAElC,MAAI,SAAS,WAWX,mEATE,0BACA,eACA;GACE,eAAe,yBAAyB;GACxC,SAAS,EAAE;GACX,SAAS,EAAE;GACZ,CACF;AAKH,MAAI,kBAAkB,WAAW,GAAG;AAClC,aACE,GAAG,iBAAiB,4FAAsD,yBAAyB,SAAS,CAAC,IAC7G,EACE,OAAO,QACR,CACF;AACD;;AAGF,mBAAiB,KAAK;GACpB;GACA;GACA;GACA,eAAe;GACf;GACA,oBAAoB,yBAAyB;GAC9C,CAAC;;AAGJ,QAAO"}
1
+ {"version":3,"file":"listTranslationsTasks.cjs","names":["translationTasks: TranslationTask[]","ANSIColors","mainDictionaryToProcess: Dictionary","sourceLocale: Locale","outputLocalesList: Locale[]"],"sources":["../../../src/fill/listTranslationsTasks.ts"],"sourcesContent":["import { basename } from 'node:path';\nimport { formatLocale } from '@intlayer/chokidar';\nimport {\n ANSIColors,\n colon,\n colorize,\n colorizeKey,\n colorizePath,\n getAppLogger,\n} from '@intlayer/config';\nimport {\n getFilterTranslationsOnlyDictionary,\n getMissingLocalesContent,\n} from '@intlayer/core';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport type {\n ContentNode,\n Dictionary,\n IntlayerConfig,\n LocalDictionaryId,\n Locale,\n} from '@intlayer/types';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\n\nexport type TranslationTask = {\n dictionaryKey: string;\n dictionaryLocalId: LocalDictionaryId;\n sourceLocale: Locale;\n targetLocales: Locale[];\n dictionaryPreset: string;\n dictionaryFilePath: string;\n};\n\nexport const listTranslationsTasks = (\n localIds: LocalDictionaryId[],\n outputLocales: Locale[],\n mode: 'complete' | 'review',\n baseLocale: Locale,\n configuration: IntlayerConfig\n): TranslationTask[] => {\n const appLogger = getAppLogger(configuration);\n\n const mergedDictionariesRecord = getDictionaries(configuration);\n const unmergedDictionariesRecord = getUnmergedDictionaries(configuration);\n\n const allFlatDictionaries = Object.values(unmergedDictionariesRecord).flat();\n const dictionariesToProcess = allFlatDictionaries.filter((dictionary) =>\n localIds.includes(dictionary.localId!)\n );\n\n const maxKeyLength = Math.max(\n ...dictionariesToProcess.map((dict) => dict.key.length)\n );\n\n const translationTasks: TranslationTask[] = [];\n\n for (const targetUnmergedDictionary of dictionariesToProcess) {\n const dictionaryPreset = colon(\n [\n ' - ',\n colorize('[', ANSIColors.GREY_DARK),\n colorizeKey(targetUnmergedDictionary.key),\n colorize(']', ANSIColors.GREY_DARK),\n ].join(''),\n { colSize: maxKeyLength + 6 }\n );\n\n const dictionaryKey = targetUnmergedDictionary.key;\n const dictionaryLocalId = targetUnmergedDictionary.localId!;\n const mainDictionaryToProcess: Dictionary =\n mergedDictionariesRecord[dictionaryKey];\n const dictionaryFill =\n targetUnmergedDictionary.fill ?? configuration.dictionary?.fill ?? false;\n\n if (dictionaryFill === false) continue;\n\n const sourceLocale: Locale = (targetUnmergedDictionary.locale ??\n baseLocale) as Locale;\n\n if (!mainDictionaryToProcess) {\n appLogger(\n `${dictionaryPreset} Dictionary not found in dictionariesRecord. Skipping.`,\n {\n level: 'warn',\n }\n );\n continue;\n }\n\n if (!targetUnmergedDictionary.filePath) {\n appLogger(`${dictionaryPreset} Dictionary has no file path. Skipping.`, {\n level: 'warn',\n });\n continue;\n }\n\n const sourceLocaleContent = getFilterTranslationsOnlyDictionary(\n mainDictionaryToProcess,\n sourceLocale\n );\n\n if (\n Object.keys(sourceLocaleContent as Record<string, unknown>).length === 0\n ) {\n appLogger(\n `${dictionaryPreset} No content found for dictionary in source locale ${formatLocale(sourceLocale)}. Skipping translation for this dictionary.`,\n {\n level: 'warn',\n }\n );\n continue;\n }\n\n /**\n * In 'complete' mode, filter only the missing locales to translate\n *\n * Skip the dictionary if there are no missing locales to translate\n */\n let outputLocalesList: Locale[] = outputLocales as Locale[];\n\n if (mode === 'complete') {\n const missingLocales = getMissingLocalesContent(\n targetUnmergedDictionary as unknown as ContentNode,\n outputLocales,\n {\n dictionaryKey: targetUnmergedDictionary.key,\n keyPath: [],\n plugins: [],\n }\n );\n\n outputLocalesList = missingLocales;\n }\n\n if (outputLocalesList.length === 0) {\n appLogger(\n `${dictionaryPreset} No locales to fill, Skipping ${colorizePath(basename(targetUnmergedDictionary.filePath))}`,\n {\n level: 'warn',\n }\n );\n continue;\n }\n\n translationTasks.push({\n dictionaryKey,\n dictionaryLocalId,\n sourceLocale,\n targetLocales: outputLocalesList,\n dictionaryPreset,\n dictionaryFilePath: targetUnmergedDictionary.filePath,\n });\n }\n\n return translationTasks;\n};\n"],"mappings":";;;;;;;;;;;;;;;AAiCA,MAAa,yBACX,UACA,eACA,MACA,YACA,kBACsB;CACtB,MAAM,gDAAyB,cAAc;CAE7C,MAAM,8EAA2C,cAAc;CAC/D,MAAM,iGAAqD,cAAc;CAGzE,MAAM,wBADsB,OAAO,OAAO,2BAA2B,CAAC,MAAM,CAC1B,QAAQ,eACxD,SAAS,SAAS,WAAW,QAAS,CACvC;CAED,MAAM,eAAe,KAAK,IACxB,GAAG,sBAAsB,KAAK,SAAS,KAAK,IAAI,OAAO,CACxD;CAED,MAAMA,mBAAsC,EAAE;AAE9C,MAAK,MAAM,4BAA4B,uBAAuB;EAC5D,MAAM,gDACJ;GACE;mCACS,KAAKC,6BAAW,UAAU;sCACvB,yBAAyB,IAAI;mCAChC,KAAKA,6BAAW,UAAU;GACpC,CAAC,KAAK,GAAG,EACV,EAAE,SAAS,eAAe,GAAG,CAC9B;EAED,MAAM,gBAAgB,yBAAyB;EAC/C,MAAM,oBAAoB,yBAAyB;EACnD,MAAMC,0BACJ,yBAAyB;AAI3B,OAFE,yBAAyB,QAAQ,cAAc,YAAY,QAAQ,WAE9C,MAAO;EAE9B,MAAMC,eAAwB,yBAAyB,UACrD;AAEF,MAAI,CAAC,yBAAyB;AAC5B,aACE,GAAG,iBAAiB,yDACpB,EACE,OAAO,QACR,CACF;AACD;;AAGF,MAAI,CAAC,yBAAyB,UAAU;AACtC,aAAU,GAAG,iBAAiB,0CAA0C,EACtE,OAAO,QACR,CAAC;AACF;;EAGF,MAAM,+EACJ,yBACA,aACD;AAED,MACE,OAAO,KAAK,oBAA+C,CAAC,WAAW,GACvE;AACA,aACE,GAAG,iBAAiB,0FAAiE,aAAa,CAAC,8CACnG,EACE,OAAO,QACR,CACF;AACD;;;;;;;EAQF,IAAIC,oBAA8B;AAElC,MAAI,SAAS,WAWX,mEATE,0BACA,eACA;GACE,eAAe,yBAAyB;GACxC,SAAS,EAAE;GACX,SAAS,EAAE;GACZ,CACF;AAKH,MAAI,kBAAkB,WAAW,GAAG;AAClC,aACE,GAAG,iBAAiB,4FAAsD,yBAAyB,SAAS,CAAC,IAC7G,EACE,OAAO,QACR,CACF;AACD;;AAGF,mBAAiB,KAAK;GACpB;GACA;GACA;GACA,eAAe;GACf;GACA,oBAAoB,yBAAyB;GAC9C,CAAC;;AAGJ,QAAO"}
@@ -18,7 +18,7 @@ const writeFill = async (contentDeclarationFile, outputLocales, parentLocales, c
18
18
  appLogger("No file path found for dictionary", { level: "error" });
19
19
  return;
20
20
  }
21
- const autoFillOptions = contentDeclarationFile.fill ?? configuration.content.fill;
21
+ const autoFillOptions = contentDeclarationFile.fill ?? configuration.dictionary?.fill ?? false;
22
22
  if (typeof autoFillOptions === "boolean" && autoFillOptions === false) {
23
23
  appLogger(`Auto fill is disabled for '${(0, __intlayer_config.colorizeKey)(fullDictionary.key)}'`, { level: "info" });
24
24
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"writeFill.cjs","names":["autoFillData: FillData[]","formatFillData"],"sources":["../../../src/fill/writeFill.ts"],"sourcesContent":["import { relative } from 'node:path';\nimport {\n formatLocale,\n formatPath,\n writeContentDeclaration,\n} from '@intlayer/chokidar';\nimport { colorizeKey, getAppLogger } from '@intlayer/config';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport type { Dictionary, Fill, IntlayerConfig, Locale } from '@intlayer/types';\nimport { type FillData, formatFillData } from './formatFillData';\n\nexport const writeFill = async (\n contentDeclarationFile: Dictionary,\n outputLocales: Locale[],\n parentLocales: Locale[],\n configuration: IntlayerConfig\n) => {\n const appLogger = getAppLogger(configuration);\n const dictionaries = getDictionaries(configuration);\n\n const fullDictionary = dictionaries[contentDeclarationFile.key];\n\n const { filePath } = contentDeclarationFile;\n\n if (!filePath) {\n appLogger('No file path found for dictionary', {\n level: 'error',\n });\n return;\n }\n\n const autoFillOptions =\n contentDeclarationFile.fill ?? configuration.content.fill;\n\n if (\n typeof autoFillOptions === 'boolean' &&\n (autoFillOptions as boolean) === false\n ) {\n appLogger(\n `Auto fill is disabled for '${colorizeKey(fullDictionary.key)}'`,\n {\n level: 'info',\n }\n );\n return;\n }\n\n const localeList: Locale[] = (\n outputLocales ?? configuration.internationalization.locales\n ).filter((locale) => !parentLocales?.includes(locale));\n\n const autoFillData: FillData[] = formatFillData(\n autoFillOptions as Fill,\n localeList,\n filePath,\n fullDictionary.key,\n configuration\n );\n\n for await (const output of autoFillData) {\n if (!output.filePath) {\n appLogger(\n `No file path found for auto filled content declaration for '${colorizeKey(fullDictionary.key)}'`,\n {\n level: 'error',\n }\n );\n continue;\n }\n\n // biome-ignore lint/correctness/noUnusedVariables: Just filtering out the fill property\n const { fill, ...rest } = contentDeclarationFile;\n\n const relativeFilePath = relative(\n configuration.content.baseDir,\n output.filePath\n );\n\n // write file\n await writeContentDeclaration(\n {\n ...rest,\n filled: true,\n locale: output.isPerLocale ? output.localeList[0] : undefined,\n localId: `${contentDeclarationFile.key}::local::${relativeFilePath}`,\n filePath: relativeFilePath,\n },\n configuration,\n {\n localeList: output.localeList,\n }\n );\n\n if (output.isPerLocale) {\n const sourceLocale = output.localeList[0];\n\n appLogger(\n `Auto filled per-locale content declaration for '${colorizeKey(fullDictionary.key)}' written to ${formatPath(output.filePath)} for locale ${formatLocale(sourceLocale)}`,\n {\n level: 'info',\n }\n );\n } else {\n appLogger(\n `Auto filled content declaration for '${colorizeKey(fullDictionary.key)}' written to ${formatPath(output.filePath)}`,\n {\n level: 'info',\n }\n );\n }\n }\n};\n"],"mappings":";;;;;;;;;;;;AAWA,MAAa,YAAY,OACvB,wBACA,eACA,eACA,kBACG;CACH,MAAM,gDAAyB,cAAc;CAG7C,MAAM,oEAF+B,cAAc,CAEf,uBAAuB;CAE3D,MAAM,EAAE,aAAa;AAErB,KAAI,CAAC,UAAU;AACb,YAAU,qCAAqC,EAC7C,OAAO,SACR,CAAC;AACF;;CAGF,MAAM,kBACJ,uBAAuB,QAAQ,cAAc,QAAQ;AAEvD,KACE,OAAO,oBAAoB,aAC1B,oBAAgC,OACjC;AACA,YACE,iEAA0C,eAAe,IAAI,CAAC,IAC9D,EACE,OAAO,QACR,CACF;AACD;;CAOF,MAAMA,eAA2BC,2CAC/B,kBAJA,iBAAiB,cAAc,qBAAqB,SACpD,QAAQ,WAAW,CAAC,eAAe,SAAS,OAAO,CAAC,EAKpD,UACA,eAAe,KACf,cACD;AAED,YAAW,MAAM,UAAU,cAAc;AACvC,MAAI,CAAC,OAAO,UAAU;AACpB,aACE,kGAA2E,eAAe,IAAI,CAAC,IAC/F,EACE,OAAO,SACR,CACF;AACD;;EAIF,MAAM,EAAE,KAAM,GAAG,SAAS;EAE1B,MAAM,2CACJ,cAAc,QAAQ,SACtB,OAAO,SACR;AAGD,yDACE;GACE,GAAG;GACH,QAAQ;GACR,QAAQ,OAAO,cAAc,OAAO,WAAW,KAAK;GACpD,SAAS,GAAG,uBAAuB,IAAI,WAAW;GAClD,UAAU;GACX,EACD,eACA,EACE,YAAY,OAAO,YACpB,CACF;AAED,MAAI,OAAO,aAAa;GACtB,MAAM,eAAe,OAAO,WAAW;AAEvC,aACE,sFAA+D,eAAe,IAAI,CAAC,mDAA0B,OAAO,SAAS,CAAC,oDAA2B,aAAa,IACtK,EACE,OAAO,QACR,CACF;QAED,WACE,2EAAoD,eAAe,IAAI,CAAC,mDAA0B,OAAO,SAAS,IAClH,EACE,OAAO,QACR,CACF"}
1
+ {"version":3,"file":"writeFill.cjs","names":["autoFillData: FillData[]","formatFillData"],"sources":["../../../src/fill/writeFill.ts"],"sourcesContent":["import { relative } from 'node:path';\nimport {\n formatLocale,\n formatPath,\n writeContentDeclaration,\n} from '@intlayer/chokidar';\nimport { colorizeKey, getAppLogger } from '@intlayer/config';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport type { Dictionary, Fill, IntlayerConfig, Locale } from '@intlayer/types';\nimport { type FillData, formatFillData } from './formatFillData';\n\nexport const writeFill = async (\n contentDeclarationFile: Dictionary,\n outputLocales: Locale[],\n parentLocales: Locale[],\n configuration: IntlayerConfig\n) => {\n const appLogger = getAppLogger(configuration);\n const dictionaries = getDictionaries(configuration);\n\n const fullDictionary = dictionaries[contentDeclarationFile.key];\n\n const { filePath } = contentDeclarationFile;\n\n if (!filePath) {\n appLogger('No file path found for dictionary', {\n level: 'error',\n });\n return;\n }\n\n const autoFillOptions =\n contentDeclarationFile.fill ?? configuration.dictionary?.fill ?? false;\n\n if (\n typeof autoFillOptions === 'boolean' &&\n (autoFillOptions as boolean) === false\n ) {\n appLogger(\n `Auto fill is disabled for '${colorizeKey(fullDictionary.key)}'`,\n {\n level: 'info',\n }\n );\n return;\n }\n\n const localeList: Locale[] = (\n outputLocales ?? configuration.internationalization.locales\n ).filter((locale) => !parentLocales?.includes(locale));\n\n const autoFillData: FillData[] = formatFillData(\n autoFillOptions as Fill,\n localeList,\n filePath,\n fullDictionary.key,\n configuration\n );\n\n for await (const output of autoFillData) {\n if (!output.filePath) {\n appLogger(\n `No file path found for auto filled content declaration for '${colorizeKey(fullDictionary.key)}'`,\n {\n level: 'error',\n }\n );\n continue;\n }\n\n // biome-ignore lint/correctness/noUnusedVariables: Just filtering out the fill property\n const { fill, ...rest } = contentDeclarationFile;\n\n const relativeFilePath = relative(\n configuration.content.baseDir,\n output.filePath\n );\n\n // write file\n await writeContentDeclaration(\n {\n ...rest,\n filled: true,\n locale: output.isPerLocale ? output.localeList[0] : undefined,\n localId: `${contentDeclarationFile.key}::local::${relativeFilePath}`,\n filePath: relativeFilePath,\n },\n configuration,\n {\n localeList: output.localeList,\n }\n );\n\n if (output.isPerLocale) {\n const sourceLocale = output.localeList[0];\n\n appLogger(\n `Auto filled per-locale content declaration for '${colorizeKey(fullDictionary.key)}' written to ${formatPath(output.filePath)} for locale ${formatLocale(sourceLocale)}`,\n {\n level: 'info',\n }\n );\n } else {\n appLogger(\n `Auto filled content declaration for '${colorizeKey(fullDictionary.key)}' written to ${formatPath(output.filePath)}`,\n {\n level: 'info',\n }\n );\n }\n }\n};\n"],"mappings":";;;;;;;;;;;;AAWA,MAAa,YAAY,OACvB,wBACA,eACA,eACA,kBACG;CACH,MAAM,gDAAyB,cAAc;CAG7C,MAAM,oEAF+B,cAAc,CAEf,uBAAuB;CAE3D,MAAM,EAAE,aAAa;AAErB,KAAI,CAAC,UAAU;AACb,YAAU,qCAAqC,EAC7C,OAAO,SACR,CAAC;AACF;;CAGF,MAAM,kBACJ,uBAAuB,QAAQ,cAAc,YAAY,QAAQ;AAEnE,KACE,OAAO,oBAAoB,aAC1B,oBAAgC,OACjC;AACA,YACE,iEAA0C,eAAe,IAAI,CAAC,IAC9D,EACE,OAAO,QACR,CACF;AACD;;CAOF,MAAMA,eAA2BC,2CAC/B,kBAJA,iBAAiB,cAAc,qBAAqB,SACpD,QAAQ,WAAW,CAAC,eAAe,SAAS,OAAO,CAAC,EAKpD,UACA,eAAe,KACf,cACD;AAED,YAAW,MAAM,UAAU,cAAc;AACvC,MAAI,CAAC,OAAO,UAAU;AACpB,aACE,kGAA2E,eAAe,IAAI,CAAC,IAC/F,EACE,OAAO,SACR,CACF;AACD;;EAIF,MAAM,EAAE,KAAM,GAAG,SAAS;EAE1B,MAAM,2CACJ,cAAc,QAAQ,SACtB,OAAO,SACR;AAGD,yDACE;GACE,GAAG;GACH,QAAQ;GACR,QAAQ,OAAO,cAAc,OAAO,WAAW,KAAK;GACpD,SAAS,GAAG,uBAAuB,IAAI,WAAW;GAClD,UAAU;GACX,EACD,eACA,EACE,YAAY,OAAO,YACpB,CACF;AAED,MAAI,OAAO,aAAa;GACtB,MAAM,eAAe,OAAO,WAAW;AAEvC,aACE,sFAA+D,eAAe,IAAI,CAAC,mDAA0B,OAAO,SAAS,CAAC,oDAA2B,aAAa,IACtK,EACE,OAAO,QACR,CACF;QAED,WACE,2EAAoD,eAAe,IAAI,CAAC,mDAA0B,OAAO,SAAS,IAClH,EACE,OAAO,QACR,CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"formatAutoFilledFilePath.mjs","names":["result: string"],"sources":["../../../src/fill/formatAutoFilledFilePath.ts"],"sourcesContent":["import {\n basename,\n dirname,\n isAbsolute,\n normalize,\n relative,\n resolve,\n} from 'node:path';\nimport type { LocalesValues } from '@intlayer/types';\n\nexport const formatAutoFilledFilePath = (\n autoFillField: string,\n dictionaryKey: string,\n dictionaryFilePath: string,\n baseDir: string,\n locale?: LocalesValues\n): string => {\n // Validate inputs\n if (!autoFillField || typeof autoFillField !== 'string') {\n throw new Error('autoFillField must be a non-empty string');\n }\n if (!dictionaryKey || typeof dictionaryKey !== 'string') {\n throw new Error('dictionaryKey must be a non-empty string');\n }\n if (!dictionaryFilePath || typeof dictionaryFilePath !== 'string') {\n throw new Error('dictionaryFilePath must be a non-empty string');\n }\n if (!baseDir || typeof baseDir !== 'string') {\n throw new Error('baseDir must be a non-empty string');\n }\n\n // Extract the original filename without extensions (.content.ts -> dictionaryFieldEditor)\n const originalFileName = basename(dictionaryFilePath)\n .split('.')\n .slice(0, -2) // Remove last 2 extensions (.content.tsx)\n .join('.');\n\n // Replace placeholders in autoFillField\n let result: string = autoFillField\n .replace(/\\{\\{key\\}\\}/g, originalFileName) // Use original filename, not dictionaryKey\n .replace(/\\{\\{fileName\\}\\}/g, originalFileName);\n\n if (locale) {\n result = result.replace(/\\{\\{locale\\}\\}/g, locale);\n }\n\n // Normalize the dictionary file path - if it's relative, make it absolute relative to baseDir\n const absoluteDictionaryPath = isAbsolute(dictionaryFilePath)\n ? dictionaryFilePath\n : resolve(baseDir, dictionaryFilePath);\n\n // Handle relative paths (starting with ./ or ../)\n if (result.startsWith('./') || result.startsWith('../')) {\n const fileDir = dirname(absoluteDictionaryPath);\n const resolvedPath = resolve(fileDir, result);\n\n return resolvedPath;\n }\n\n // Handle absolute paths\n if (isAbsolute(result)) {\n const normalizedResult = normalize(result);\n const normalizedBaseDir = normalize(baseDir);\n\n // Check if it's relative to baseDir (starts with /)\n // but not a system path (like /usr/local)\n if (\n result.startsWith('/') &&\n !normalizedResult.startsWith(normalizedBaseDir)\n ) {\n // Try to resolve it relative to baseDir first\n const relativeToBase = resolve(baseDir, result.substring(1));\n\n // If the path doesn't exist in common system directories, treat as relative to baseDir\n if (\n !result.startsWith('/usr/') &&\n !result.startsWith('/etc/') &&\n !result.startsWith('/var/') &&\n !result.startsWith('/home/') &&\n !result.startsWith('/Users/')\n ) {\n return relativeToBase;\n }\n }\n\n // It's a true system absolute path\n return normalizedResult;\n }\n\n // Default case: treat as relative to baseDir\n return normalize(result);\n};\n"],"mappings":";;;AAUA,MAAa,4BACX,eACA,eACA,oBACA,SACA,WACW;AAEX,KAAI,CAAC,iBAAiB,OAAO,kBAAkB,SAC7C,OAAM,IAAI,MAAM,2CAA2C;AAE7D,KAAI,CAAC,iBAAiB,OAAO,kBAAkB,SAC7C,OAAM,IAAI,MAAM,2CAA2C;AAE7D,KAAI,CAAC,sBAAsB,OAAO,uBAAuB,SACvD,OAAM,IAAI,MAAM,gDAAgD;AAElE,KAAI,CAAC,WAAW,OAAO,YAAY,SACjC,OAAM,IAAI,MAAM,qCAAqC;CAIvD,MAAM,mBAAmB,SAAS,mBAAmB,CAClD,MAAM,IAAI,CACV,MAAM,GAAG,GAAG,CACZ,KAAK,IAAI;CAGZ,IAAIA,SAAiB,cAClB,QAAQ,gBAAgB,iBAAiB,CACzC,QAAQ,qBAAqB,iBAAiB;AAEjD,KAAI,OACF,UAAS,OAAO,QAAQ,mBAAmB,OAAO;CAIpD,MAAM,yBAAyB,WAAW,mBAAmB,GACzD,qBACA,QAAQ,SAAS,mBAAmB;AAGxC,KAAI,OAAO,WAAW,KAAK,IAAI,OAAO,WAAW,MAAM,CAIrD,QAFqB,QADL,QAAQ,uBAAuB,EACT,OAAO;AAM/C,KAAI,WAAW,OAAO,EAAE;EACtB,MAAM,mBAAmB,UAAU,OAAO;EAC1C,MAAM,oBAAoB,UAAU,QAAQ;AAI5C,MACE,OAAO,WAAW,IAAI,IACtB,CAAC,iBAAiB,WAAW,kBAAkB,EAC/C;GAEA,MAAM,iBAAiB,QAAQ,SAAS,OAAO,UAAU,EAAE,CAAC;AAG5D,OACE,CAAC,OAAO,WAAW,QAAQ,IAC3B,CAAC,OAAO,WAAW,QAAQ,IAC3B,CAAC,OAAO,WAAW,QAAQ,IAC3B,CAAC,OAAO,WAAW,SAAS,IAC5B,CAAC,OAAO,WAAW,UAAU,CAE7B,QAAO;;AAKX,SAAO;;AAIT,QAAO,UAAU,OAAO"}
1
+ {"version":3,"file":"formatAutoFilledFilePath.mjs","names":["result: string"],"sources":["../../../src/fill/formatAutoFilledFilePath.ts"],"sourcesContent":["import { basename, dirname, isAbsolute, normalize, resolve } from 'node:path';\nimport type { LocalesValues } from '@intlayer/types';\n\nexport const formatAutoFilledFilePath = (\n autoFillField: string,\n dictionaryKey: string,\n dictionaryFilePath: string,\n baseDir: string,\n locale?: LocalesValues\n): string => {\n // Validate inputs\n if (!autoFillField || typeof autoFillField !== 'string') {\n throw new Error('autoFillField must be a non-empty string');\n }\n if (!dictionaryKey || typeof dictionaryKey !== 'string') {\n throw new Error('dictionaryKey must be a non-empty string');\n }\n if (!dictionaryFilePath || typeof dictionaryFilePath !== 'string') {\n throw new Error('dictionaryFilePath must be a non-empty string');\n }\n if (!baseDir || typeof baseDir !== 'string') {\n throw new Error('baseDir must be a non-empty string');\n }\n\n // Extract the original filename without extensions (.content.ts -> dictionaryFieldEditor)\n const originalFileName = basename(dictionaryFilePath)\n .split('.')\n .slice(0, -2) // Remove last 2 extensions (.content.tsx)\n .join('.');\n\n // Replace placeholders in autoFillField\n let result: string = autoFillField\n .replace(/\\{\\{key\\}\\}/g, originalFileName) // Use original filename, not dictionaryKey\n .replace(/\\{\\{fileName\\}\\}/g, originalFileName);\n\n if (locale) {\n result = result.replace(/\\{\\{locale\\}\\}/g, locale);\n }\n\n // Normalize the dictionary file path - if it's relative, make it absolute relative to baseDir\n const absoluteDictionaryPath = isAbsolute(dictionaryFilePath)\n ? dictionaryFilePath\n : resolve(baseDir, dictionaryFilePath);\n\n // Handle relative paths (starting with ./ or ../)\n if (result.startsWith('./') || result.startsWith('../')) {\n const fileDir = dirname(absoluteDictionaryPath);\n const resolvedPath = resolve(fileDir, result);\n\n return resolvedPath;\n }\n\n // Handle absolute paths\n if (isAbsolute(result)) {\n const normalizedResult = normalize(result);\n const normalizedBaseDir = normalize(baseDir);\n\n // Check if it's relative to baseDir (starts with /)\n // but not a system path (like /usr/local)\n if (\n result.startsWith('/') &&\n !normalizedResult.startsWith(normalizedBaseDir)\n ) {\n // Try to resolve it relative to baseDir first\n const relativeToBase = resolve(baseDir, result.substring(1));\n\n // If the path doesn't exist in common system directories, treat as relative to baseDir\n if (\n !result.startsWith('/usr/') &&\n !result.startsWith('/etc/') &&\n !result.startsWith('/var/') &&\n !result.startsWith('/home/') &&\n !result.startsWith('/Users/')\n ) {\n return relativeToBase;\n }\n }\n\n // It's a true system absolute path\n return normalizedResult;\n }\n\n // Default case: treat as relative to baseDir\n return normalize(result);\n};\n"],"mappings":";;;AAGA,MAAa,4BACX,eACA,eACA,oBACA,SACA,WACW;AAEX,KAAI,CAAC,iBAAiB,OAAO,kBAAkB,SAC7C,OAAM,IAAI,MAAM,2CAA2C;AAE7D,KAAI,CAAC,iBAAiB,OAAO,kBAAkB,SAC7C,OAAM,IAAI,MAAM,2CAA2C;AAE7D,KAAI,CAAC,sBAAsB,OAAO,uBAAuB,SACvD,OAAM,IAAI,MAAM,gDAAgD;AAElE,KAAI,CAAC,WAAW,OAAO,YAAY,SACjC,OAAM,IAAI,MAAM,qCAAqC;CAIvD,MAAM,mBAAmB,SAAS,mBAAmB,CAClD,MAAM,IAAI,CACV,MAAM,GAAG,GAAG,CACZ,KAAK,IAAI;CAGZ,IAAIA,SAAiB,cAClB,QAAQ,gBAAgB,iBAAiB,CACzC,QAAQ,qBAAqB,iBAAiB;AAEjD,KAAI,OACF,UAAS,OAAO,QAAQ,mBAAmB,OAAO;CAIpD,MAAM,yBAAyB,WAAW,mBAAmB,GACzD,qBACA,QAAQ,SAAS,mBAAmB;AAGxC,KAAI,OAAO,WAAW,KAAK,IAAI,OAAO,WAAW,MAAM,CAIrD,QAFqB,QADL,QAAQ,uBAAuB,EACT,OAAO;AAM/C,KAAI,WAAW,OAAO,EAAE;EACtB,MAAM,mBAAmB,UAAU,OAAO;EAC1C,MAAM,oBAAoB,UAAU,QAAQ;AAI5C,MACE,OAAO,WAAW,IAAI,IACtB,CAAC,iBAAiB,WAAW,kBAAkB,EAC/C;GAEA,MAAM,iBAAiB,QAAQ,SAAS,OAAO,UAAU,EAAE,CAAC;AAG5D,OACE,CAAC,OAAO,WAAW,QAAQ,IAC3B,CAAC,OAAO,WAAW,QAAQ,IAC3B,CAAC,OAAO,WAAW,QAAQ,IAC3B,CAAC,OAAO,WAAW,SAAS,IAC5B,CAAC,OAAO,WAAW,UAAU,CAE7B,QAAO;;AAKX,SAAO;;AAIT,QAAO,UAAU,OAAO"}
@@ -23,7 +23,7 @@ const listTranslationsTasks = (localIds, outputLocales, mode, baseLocale, config
23
23
  const dictionaryKey = targetUnmergedDictionary.key;
24
24
  const dictionaryLocalId = targetUnmergedDictionary.localId;
25
25
  const mainDictionaryToProcess = mergedDictionariesRecord[dictionaryKey];
26
- if ((targetUnmergedDictionary.fill ?? configuration.content.fill) === false) continue;
26
+ if ((targetUnmergedDictionary.fill ?? configuration.dictionary?.fill ?? false) === false) continue;
27
27
  const sourceLocale = targetUnmergedDictionary.locale ?? baseLocale;
28
28
  if (!mainDictionaryToProcess) {
29
29
  appLogger(`${dictionaryPreset} Dictionary not found in dictionariesRecord. Skipping.`, { level: "warn" });
@@ -1 +1 @@
1
- {"version":3,"file":"listTranslationsTasks.mjs","names":["translationTasks: TranslationTask[]","mainDictionaryToProcess: Dictionary","sourceLocale: Locale","outputLocalesList: Locale[]"],"sources":["../../../src/fill/listTranslationsTasks.ts"],"sourcesContent":["import { basename } from 'node:path';\nimport { formatLocale } from '@intlayer/chokidar';\nimport {\n ANSIColors,\n colon,\n colorize,\n colorizeKey,\n colorizePath,\n getAppLogger,\n} from '@intlayer/config';\nimport {\n getFilterTranslationsOnlyDictionary,\n getMissingLocalesContent,\n} from '@intlayer/core';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport type {\n ContentNode,\n Dictionary,\n IntlayerConfig,\n LocalDictionaryId,\n Locale,\n} from '@intlayer/types';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\n\nexport type TranslationTask = {\n dictionaryKey: string;\n dictionaryLocalId: LocalDictionaryId;\n sourceLocale: Locale;\n targetLocales: Locale[];\n dictionaryPreset: string;\n dictionaryFilePath: string;\n};\n\nexport const listTranslationsTasks = (\n localIds: LocalDictionaryId[],\n outputLocales: Locale[],\n mode: 'complete' | 'review',\n baseLocale: Locale,\n configuration: IntlayerConfig\n): TranslationTask[] => {\n const appLogger = getAppLogger(configuration);\n\n const mergedDictionariesRecord = getDictionaries(configuration);\n const unmergedDictionariesRecord = getUnmergedDictionaries(configuration);\n\n const allFlatDictionaries = Object.values(unmergedDictionariesRecord).flat();\n const dictionariesToProcess = allFlatDictionaries.filter((dictionary) =>\n localIds.includes(dictionary.localId!)\n );\n\n const maxKeyLength = Math.max(\n ...dictionariesToProcess.map((dict) => dict.key.length)\n );\n\n const translationTasks: TranslationTask[] = [];\n\n for (const targetUnmergedDictionary of dictionariesToProcess) {\n const dictionaryPreset = colon(\n [\n ' - ',\n colorize('[', ANSIColors.GREY_DARK),\n colorizeKey(targetUnmergedDictionary.key),\n colorize(']', ANSIColors.GREY_DARK),\n ].join(''),\n { colSize: maxKeyLength + 6 }\n );\n\n const dictionaryKey = targetUnmergedDictionary.key;\n const dictionaryLocalId = targetUnmergedDictionary.localId!;\n const mainDictionaryToProcess: Dictionary =\n mergedDictionariesRecord[dictionaryKey];\n const dictionaryFill =\n targetUnmergedDictionary.fill ?? configuration.content.fill;\n\n if (dictionaryFill === false) continue;\n\n const sourceLocale: Locale = (targetUnmergedDictionary.locale ??\n baseLocale) as Locale;\n\n if (!mainDictionaryToProcess) {\n appLogger(\n `${dictionaryPreset} Dictionary not found in dictionariesRecord. Skipping.`,\n {\n level: 'warn',\n }\n );\n continue;\n }\n\n if (!targetUnmergedDictionary.filePath) {\n appLogger(`${dictionaryPreset} Dictionary has no file path. Skipping.`, {\n level: 'warn',\n });\n continue;\n }\n\n const sourceLocaleContent = getFilterTranslationsOnlyDictionary(\n mainDictionaryToProcess,\n sourceLocale\n );\n\n if (\n Object.keys(sourceLocaleContent as Record<string, unknown>).length === 0\n ) {\n appLogger(\n `${dictionaryPreset} No content found for dictionary in source locale ${formatLocale(sourceLocale)}. Skipping translation for this dictionary.`,\n {\n level: 'warn',\n }\n );\n continue;\n }\n\n /**\n * In 'complete' mode, filter only the missing locales to translate\n *\n * Skip the dictionary if there are no missing locales to translate\n */\n let outputLocalesList: Locale[] = outputLocales as Locale[];\n\n if (mode === 'complete') {\n const missingLocales = getMissingLocalesContent(\n targetUnmergedDictionary as unknown as ContentNode,\n outputLocales,\n {\n dictionaryKey: targetUnmergedDictionary.key,\n keyPath: [],\n plugins: [],\n }\n );\n\n outputLocalesList = missingLocales;\n }\n\n if (outputLocalesList.length === 0) {\n appLogger(\n `${dictionaryPreset} No locales to fill, Skipping ${colorizePath(basename(targetUnmergedDictionary.filePath))}`,\n {\n level: 'warn',\n }\n );\n continue;\n }\n\n translationTasks.push({\n dictionaryKey,\n dictionaryLocalId,\n sourceLocale,\n targetLocales: outputLocalesList,\n dictionaryPreset,\n dictionaryFilePath: targetUnmergedDictionary.filePath,\n });\n }\n\n return translationTasks;\n};\n"],"mappings":";;;;;;;;AAiCA,MAAa,yBACX,UACA,eACA,MACA,YACA,kBACsB;CACtB,MAAM,YAAY,aAAa,cAAc;CAE7C,MAAM,2BAA2B,gBAAgB,cAAc;CAC/D,MAAM,6BAA6B,wBAAwB,cAAc;CAGzE,MAAM,wBADsB,OAAO,OAAO,2BAA2B,CAAC,MAAM,CAC1B,QAAQ,eACxD,SAAS,SAAS,WAAW,QAAS,CACvC;CAED,MAAM,eAAe,KAAK,IACxB,GAAG,sBAAsB,KAAK,SAAS,KAAK,IAAI,OAAO,CACxD;CAED,MAAMA,mBAAsC,EAAE;AAE9C,MAAK,MAAM,4BAA4B,uBAAuB;EAC5D,MAAM,mBAAmB,MACvB;GACE;GACA,SAAS,KAAK,WAAW,UAAU;GACnC,YAAY,yBAAyB,IAAI;GACzC,SAAS,KAAK,WAAW,UAAU;GACpC,CAAC,KAAK,GAAG,EACV,EAAE,SAAS,eAAe,GAAG,CAC9B;EAED,MAAM,gBAAgB,yBAAyB;EAC/C,MAAM,oBAAoB,yBAAyB;EACnD,MAAMC,0BACJ,yBAAyB;AAI3B,OAFE,yBAAyB,QAAQ,cAAc,QAAQ,UAElC,MAAO;EAE9B,MAAMC,eAAwB,yBAAyB,UACrD;AAEF,MAAI,CAAC,yBAAyB;AAC5B,aACE,GAAG,iBAAiB,yDACpB,EACE,OAAO,QACR,CACF;AACD;;AAGF,MAAI,CAAC,yBAAyB,UAAU;AACtC,aAAU,GAAG,iBAAiB,0CAA0C,EACtE,OAAO,QACR,CAAC;AACF;;EAGF,MAAM,sBAAsB,oCAC1B,yBACA,aACD;AAED,MACE,OAAO,KAAK,oBAA+C,CAAC,WAAW,GACvE;AACA,aACE,GAAG,iBAAiB,oDAAoD,aAAa,aAAa,CAAC,8CACnG,EACE,OAAO,QACR,CACF;AACD;;;;;;;EAQF,IAAIC,oBAA8B;AAElC,MAAI,SAAS,WAWX,qBAVuB,yBACrB,0BACA,eACA;GACE,eAAe,yBAAyB;GACxC,SAAS,EAAE;GACX,SAAS,EAAE;GACZ,CACF;AAKH,MAAI,kBAAkB,WAAW,GAAG;AAClC,aACE,GAAG,iBAAiB,gCAAgC,aAAa,SAAS,yBAAyB,SAAS,CAAC,IAC7G,EACE,OAAO,QACR,CACF;AACD;;AAGF,mBAAiB,KAAK;GACpB;GACA;GACA;GACA,eAAe;GACf;GACA,oBAAoB,yBAAyB;GAC9C,CAAC;;AAGJ,QAAO"}
1
+ {"version":3,"file":"listTranslationsTasks.mjs","names":["translationTasks: TranslationTask[]","mainDictionaryToProcess: Dictionary","sourceLocale: Locale","outputLocalesList: Locale[]"],"sources":["../../../src/fill/listTranslationsTasks.ts"],"sourcesContent":["import { basename } from 'node:path';\nimport { formatLocale } from '@intlayer/chokidar';\nimport {\n ANSIColors,\n colon,\n colorize,\n colorizeKey,\n colorizePath,\n getAppLogger,\n} from '@intlayer/config';\nimport {\n getFilterTranslationsOnlyDictionary,\n getMissingLocalesContent,\n} from '@intlayer/core';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport type {\n ContentNode,\n Dictionary,\n IntlayerConfig,\n LocalDictionaryId,\n Locale,\n} from '@intlayer/types';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\n\nexport type TranslationTask = {\n dictionaryKey: string;\n dictionaryLocalId: LocalDictionaryId;\n sourceLocale: Locale;\n targetLocales: Locale[];\n dictionaryPreset: string;\n dictionaryFilePath: string;\n};\n\nexport const listTranslationsTasks = (\n localIds: LocalDictionaryId[],\n outputLocales: Locale[],\n mode: 'complete' | 'review',\n baseLocale: Locale,\n configuration: IntlayerConfig\n): TranslationTask[] => {\n const appLogger = getAppLogger(configuration);\n\n const mergedDictionariesRecord = getDictionaries(configuration);\n const unmergedDictionariesRecord = getUnmergedDictionaries(configuration);\n\n const allFlatDictionaries = Object.values(unmergedDictionariesRecord).flat();\n const dictionariesToProcess = allFlatDictionaries.filter((dictionary) =>\n localIds.includes(dictionary.localId!)\n );\n\n const maxKeyLength = Math.max(\n ...dictionariesToProcess.map((dict) => dict.key.length)\n );\n\n const translationTasks: TranslationTask[] = [];\n\n for (const targetUnmergedDictionary of dictionariesToProcess) {\n const dictionaryPreset = colon(\n [\n ' - ',\n colorize('[', ANSIColors.GREY_DARK),\n colorizeKey(targetUnmergedDictionary.key),\n colorize(']', ANSIColors.GREY_DARK),\n ].join(''),\n { colSize: maxKeyLength + 6 }\n );\n\n const dictionaryKey = targetUnmergedDictionary.key;\n const dictionaryLocalId = targetUnmergedDictionary.localId!;\n const mainDictionaryToProcess: Dictionary =\n mergedDictionariesRecord[dictionaryKey];\n const dictionaryFill =\n targetUnmergedDictionary.fill ?? configuration.dictionary?.fill ?? false;\n\n if (dictionaryFill === false) continue;\n\n const sourceLocale: Locale = (targetUnmergedDictionary.locale ??\n baseLocale) as Locale;\n\n if (!mainDictionaryToProcess) {\n appLogger(\n `${dictionaryPreset} Dictionary not found in dictionariesRecord. Skipping.`,\n {\n level: 'warn',\n }\n );\n continue;\n }\n\n if (!targetUnmergedDictionary.filePath) {\n appLogger(`${dictionaryPreset} Dictionary has no file path. Skipping.`, {\n level: 'warn',\n });\n continue;\n }\n\n const sourceLocaleContent = getFilterTranslationsOnlyDictionary(\n mainDictionaryToProcess,\n sourceLocale\n );\n\n if (\n Object.keys(sourceLocaleContent as Record<string, unknown>).length === 0\n ) {\n appLogger(\n `${dictionaryPreset} No content found for dictionary in source locale ${formatLocale(sourceLocale)}. Skipping translation for this dictionary.`,\n {\n level: 'warn',\n }\n );\n continue;\n }\n\n /**\n * In 'complete' mode, filter only the missing locales to translate\n *\n * Skip the dictionary if there are no missing locales to translate\n */\n let outputLocalesList: Locale[] = outputLocales as Locale[];\n\n if (mode === 'complete') {\n const missingLocales = getMissingLocalesContent(\n targetUnmergedDictionary as unknown as ContentNode,\n outputLocales,\n {\n dictionaryKey: targetUnmergedDictionary.key,\n keyPath: [],\n plugins: [],\n }\n );\n\n outputLocalesList = missingLocales;\n }\n\n if (outputLocalesList.length === 0) {\n appLogger(\n `${dictionaryPreset} No locales to fill, Skipping ${colorizePath(basename(targetUnmergedDictionary.filePath))}`,\n {\n level: 'warn',\n }\n );\n continue;\n }\n\n translationTasks.push({\n dictionaryKey,\n dictionaryLocalId,\n sourceLocale,\n targetLocales: outputLocalesList,\n dictionaryPreset,\n dictionaryFilePath: targetUnmergedDictionary.filePath,\n });\n }\n\n return translationTasks;\n};\n"],"mappings":";;;;;;;;AAiCA,MAAa,yBACX,UACA,eACA,MACA,YACA,kBACsB;CACtB,MAAM,YAAY,aAAa,cAAc;CAE7C,MAAM,2BAA2B,gBAAgB,cAAc;CAC/D,MAAM,6BAA6B,wBAAwB,cAAc;CAGzE,MAAM,wBADsB,OAAO,OAAO,2BAA2B,CAAC,MAAM,CAC1B,QAAQ,eACxD,SAAS,SAAS,WAAW,QAAS,CACvC;CAED,MAAM,eAAe,KAAK,IACxB,GAAG,sBAAsB,KAAK,SAAS,KAAK,IAAI,OAAO,CACxD;CAED,MAAMA,mBAAsC,EAAE;AAE9C,MAAK,MAAM,4BAA4B,uBAAuB;EAC5D,MAAM,mBAAmB,MACvB;GACE;GACA,SAAS,KAAK,WAAW,UAAU;GACnC,YAAY,yBAAyB,IAAI;GACzC,SAAS,KAAK,WAAW,UAAU;GACpC,CAAC,KAAK,GAAG,EACV,EAAE,SAAS,eAAe,GAAG,CAC9B;EAED,MAAM,gBAAgB,yBAAyB;EAC/C,MAAM,oBAAoB,yBAAyB;EACnD,MAAMC,0BACJ,yBAAyB;AAI3B,OAFE,yBAAyB,QAAQ,cAAc,YAAY,QAAQ,WAE9C,MAAO;EAE9B,MAAMC,eAAwB,yBAAyB,UACrD;AAEF,MAAI,CAAC,yBAAyB;AAC5B,aACE,GAAG,iBAAiB,yDACpB,EACE,OAAO,QACR,CACF;AACD;;AAGF,MAAI,CAAC,yBAAyB,UAAU;AACtC,aAAU,GAAG,iBAAiB,0CAA0C,EACtE,OAAO,QACR,CAAC;AACF;;EAGF,MAAM,sBAAsB,oCAC1B,yBACA,aACD;AAED,MACE,OAAO,KAAK,oBAA+C,CAAC,WAAW,GACvE;AACA,aACE,GAAG,iBAAiB,oDAAoD,aAAa,aAAa,CAAC,8CACnG,EACE,OAAO,QACR,CACF;AACD;;;;;;;EAQF,IAAIC,oBAA8B;AAElC,MAAI,SAAS,WAWX,qBAVuB,yBACrB,0BACA,eACA;GACE,eAAe,yBAAyB;GACxC,SAAS,EAAE;GACX,SAAS,EAAE;GACZ,CACF;AAKH,MAAI,kBAAkB,WAAW,GAAG;AAClC,aACE,GAAG,iBAAiB,gCAAgC,aAAa,SAAS,yBAAyB,SAAS,CAAC,IAC7G,EACE,OAAO,QACR,CACF;AACD;;AAGF,mBAAiB,KAAK;GACpB;GACA;GACA;GACA,eAAe;GACf;GACA,oBAAoB,yBAAyB;GAC9C,CAAC;;AAGJ,QAAO"}
@@ -13,7 +13,7 @@ const writeFill = async (contentDeclarationFile, outputLocales, parentLocales, c
13
13
  appLogger("No file path found for dictionary", { level: "error" });
14
14
  return;
15
15
  }
16
- const autoFillOptions = contentDeclarationFile.fill ?? configuration.content.fill;
16
+ const autoFillOptions = contentDeclarationFile.fill ?? configuration.dictionary?.fill ?? false;
17
17
  if (typeof autoFillOptions === "boolean" && autoFillOptions === false) {
18
18
  appLogger(`Auto fill is disabled for '${colorizeKey(fullDictionary.key)}'`, { level: "info" });
19
19
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"writeFill.mjs","names":["autoFillData: FillData[]"],"sources":["../../../src/fill/writeFill.ts"],"sourcesContent":["import { relative } from 'node:path';\nimport {\n formatLocale,\n formatPath,\n writeContentDeclaration,\n} from '@intlayer/chokidar';\nimport { colorizeKey, getAppLogger } from '@intlayer/config';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport type { Dictionary, Fill, IntlayerConfig, Locale } from '@intlayer/types';\nimport { type FillData, formatFillData } from './formatFillData';\n\nexport const writeFill = async (\n contentDeclarationFile: Dictionary,\n outputLocales: Locale[],\n parentLocales: Locale[],\n configuration: IntlayerConfig\n) => {\n const appLogger = getAppLogger(configuration);\n const dictionaries = getDictionaries(configuration);\n\n const fullDictionary = dictionaries[contentDeclarationFile.key];\n\n const { filePath } = contentDeclarationFile;\n\n if (!filePath) {\n appLogger('No file path found for dictionary', {\n level: 'error',\n });\n return;\n }\n\n const autoFillOptions =\n contentDeclarationFile.fill ?? configuration.content.fill;\n\n if (\n typeof autoFillOptions === 'boolean' &&\n (autoFillOptions as boolean) === false\n ) {\n appLogger(\n `Auto fill is disabled for '${colorizeKey(fullDictionary.key)}'`,\n {\n level: 'info',\n }\n );\n return;\n }\n\n const localeList: Locale[] = (\n outputLocales ?? configuration.internationalization.locales\n ).filter((locale) => !parentLocales?.includes(locale));\n\n const autoFillData: FillData[] = formatFillData(\n autoFillOptions as Fill,\n localeList,\n filePath,\n fullDictionary.key,\n configuration\n );\n\n for await (const output of autoFillData) {\n if (!output.filePath) {\n appLogger(\n `No file path found for auto filled content declaration for '${colorizeKey(fullDictionary.key)}'`,\n {\n level: 'error',\n }\n );\n continue;\n }\n\n // biome-ignore lint/correctness/noUnusedVariables: Just filtering out the fill property\n const { fill, ...rest } = contentDeclarationFile;\n\n const relativeFilePath = relative(\n configuration.content.baseDir,\n output.filePath\n );\n\n // write file\n await writeContentDeclaration(\n {\n ...rest,\n filled: true,\n locale: output.isPerLocale ? output.localeList[0] : undefined,\n localId: `${contentDeclarationFile.key}::local::${relativeFilePath}`,\n filePath: relativeFilePath,\n },\n configuration,\n {\n localeList: output.localeList,\n }\n );\n\n if (output.isPerLocale) {\n const sourceLocale = output.localeList[0];\n\n appLogger(\n `Auto filled per-locale content declaration for '${colorizeKey(fullDictionary.key)}' written to ${formatPath(output.filePath)} for locale ${formatLocale(sourceLocale)}`,\n {\n level: 'info',\n }\n );\n } else {\n appLogger(\n `Auto filled content declaration for '${colorizeKey(fullDictionary.key)}' written to ${formatPath(output.filePath)}`,\n {\n level: 'info',\n }\n );\n }\n }\n};\n"],"mappings":";;;;;;;AAWA,MAAa,YAAY,OACvB,wBACA,eACA,eACA,kBACG;CACH,MAAM,YAAY,aAAa,cAAc;CAG7C,MAAM,iBAFe,gBAAgB,cAAc,CAEf,uBAAuB;CAE3D,MAAM,EAAE,aAAa;AAErB,KAAI,CAAC,UAAU;AACb,YAAU,qCAAqC,EAC7C,OAAO,SACR,CAAC;AACF;;CAGF,MAAM,kBACJ,uBAAuB,QAAQ,cAAc,QAAQ;AAEvD,KACE,OAAO,oBAAoB,aAC1B,oBAAgC,OACjC;AACA,YACE,8BAA8B,YAAY,eAAe,IAAI,CAAC,IAC9D,EACE,OAAO,QACR,CACF;AACD;;CAOF,MAAMA,eAA2B,eAC/B,kBAJA,iBAAiB,cAAc,qBAAqB,SACpD,QAAQ,WAAW,CAAC,eAAe,SAAS,OAAO,CAAC,EAKpD,UACA,eAAe,KACf,cACD;AAED,YAAW,MAAM,UAAU,cAAc;AACvC,MAAI,CAAC,OAAO,UAAU;AACpB,aACE,+DAA+D,YAAY,eAAe,IAAI,CAAC,IAC/F,EACE,OAAO,SACR,CACF;AACD;;EAIF,MAAM,EAAE,KAAM,GAAG,SAAS;EAE1B,MAAM,mBAAmB,SACvB,cAAc,QAAQ,SACtB,OAAO,SACR;AAGD,QAAM,wBACJ;GACE,GAAG;GACH,QAAQ;GACR,QAAQ,OAAO,cAAc,OAAO,WAAW,KAAK;GACpD,SAAS,GAAG,uBAAuB,IAAI,WAAW;GAClD,UAAU;GACX,EACD,eACA,EACE,YAAY,OAAO,YACpB,CACF;AAED,MAAI,OAAO,aAAa;GACtB,MAAM,eAAe,OAAO,WAAW;AAEvC,aACE,mDAAmD,YAAY,eAAe,IAAI,CAAC,eAAe,WAAW,OAAO,SAAS,CAAC,cAAc,aAAa,aAAa,IACtK,EACE,OAAO,QACR,CACF;QAED,WACE,wCAAwC,YAAY,eAAe,IAAI,CAAC,eAAe,WAAW,OAAO,SAAS,IAClH,EACE,OAAO,QACR,CACF"}
1
+ {"version":3,"file":"writeFill.mjs","names":["autoFillData: FillData[]"],"sources":["../../../src/fill/writeFill.ts"],"sourcesContent":["import { relative } from 'node:path';\nimport {\n formatLocale,\n formatPath,\n writeContentDeclaration,\n} from '@intlayer/chokidar';\nimport { colorizeKey, getAppLogger } from '@intlayer/config';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport type { Dictionary, Fill, IntlayerConfig, Locale } from '@intlayer/types';\nimport { type FillData, formatFillData } from './formatFillData';\n\nexport const writeFill = async (\n contentDeclarationFile: Dictionary,\n outputLocales: Locale[],\n parentLocales: Locale[],\n configuration: IntlayerConfig\n) => {\n const appLogger = getAppLogger(configuration);\n const dictionaries = getDictionaries(configuration);\n\n const fullDictionary = dictionaries[contentDeclarationFile.key];\n\n const { filePath } = contentDeclarationFile;\n\n if (!filePath) {\n appLogger('No file path found for dictionary', {\n level: 'error',\n });\n return;\n }\n\n const autoFillOptions =\n contentDeclarationFile.fill ?? configuration.dictionary?.fill ?? false;\n\n if (\n typeof autoFillOptions === 'boolean' &&\n (autoFillOptions as boolean) === false\n ) {\n appLogger(\n `Auto fill is disabled for '${colorizeKey(fullDictionary.key)}'`,\n {\n level: 'info',\n }\n );\n return;\n }\n\n const localeList: Locale[] = (\n outputLocales ?? configuration.internationalization.locales\n ).filter((locale) => !parentLocales?.includes(locale));\n\n const autoFillData: FillData[] = formatFillData(\n autoFillOptions as Fill,\n localeList,\n filePath,\n fullDictionary.key,\n configuration\n );\n\n for await (const output of autoFillData) {\n if (!output.filePath) {\n appLogger(\n `No file path found for auto filled content declaration for '${colorizeKey(fullDictionary.key)}'`,\n {\n level: 'error',\n }\n );\n continue;\n }\n\n // biome-ignore lint/correctness/noUnusedVariables: Just filtering out the fill property\n const { fill, ...rest } = contentDeclarationFile;\n\n const relativeFilePath = relative(\n configuration.content.baseDir,\n output.filePath\n );\n\n // write file\n await writeContentDeclaration(\n {\n ...rest,\n filled: true,\n locale: output.isPerLocale ? output.localeList[0] : undefined,\n localId: `${contentDeclarationFile.key}::local::${relativeFilePath}`,\n filePath: relativeFilePath,\n },\n configuration,\n {\n localeList: output.localeList,\n }\n );\n\n if (output.isPerLocale) {\n const sourceLocale = output.localeList[0];\n\n appLogger(\n `Auto filled per-locale content declaration for '${colorizeKey(fullDictionary.key)}' written to ${formatPath(output.filePath)} for locale ${formatLocale(sourceLocale)}`,\n {\n level: 'info',\n }\n );\n } else {\n appLogger(\n `Auto filled content declaration for '${colorizeKey(fullDictionary.key)}' written to ${formatPath(output.filePath)}`,\n {\n level: 'info',\n }\n );\n }\n }\n};\n"],"mappings":";;;;;;;AAWA,MAAa,YAAY,OACvB,wBACA,eACA,eACA,kBACG;CACH,MAAM,YAAY,aAAa,cAAc;CAG7C,MAAM,iBAFe,gBAAgB,cAAc,CAEf,uBAAuB;CAE3D,MAAM,EAAE,aAAa;AAErB,KAAI,CAAC,UAAU;AACb,YAAU,qCAAqC,EAC7C,OAAO,SACR,CAAC;AACF;;CAGF,MAAM,kBACJ,uBAAuB,QAAQ,cAAc,YAAY,QAAQ;AAEnE,KACE,OAAO,oBAAoB,aAC1B,oBAAgC,OACjC;AACA,YACE,8BAA8B,YAAY,eAAe,IAAI,CAAC,IAC9D,EACE,OAAO,QACR,CACF;AACD;;CAOF,MAAMA,eAA2B,eAC/B,kBAJA,iBAAiB,cAAc,qBAAqB,SACpD,QAAQ,WAAW,CAAC,eAAe,SAAS,OAAO,CAAC,EAKpD,UACA,eAAe,KACf,cACD;AAED,YAAW,MAAM,UAAU,cAAc;AACvC,MAAI,CAAC,OAAO,UAAU;AACpB,aACE,+DAA+D,YAAY,eAAe,IAAI,CAAC,IAC/F,EACE,OAAO,SACR,CACF;AACD;;EAIF,MAAM,EAAE,KAAM,GAAG,SAAS;EAE1B,MAAM,mBAAmB,SACvB,cAAc,QAAQ,SACtB,OAAO,SACR;AAGD,QAAM,wBACJ;GACE,GAAG;GACH,QAAQ;GACR,QAAQ,OAAO,cAAc,OAAO,WAAW,KAAK;GACpD,SAAS,GAAG,uBAAuB,IAAI,WAAW;GAClD,UAAU;GACX,EACD,eACA,EACE,YAAY,OAAO,YACpB,CACF;AAED,MAAI,OAAO,aAAa;GACtB,MAAM,eAAe,OAAO,WAAW;AAEvC,aACE,mDAAmD,YAAY,eAAe,IAAI,CAAC,eAAe,WAAW,OAAO,SAAS,CAAC,cAAc,aAAa,aAAa,IACtK,EACE,OAAO,QACR,CACF;QAED,WACE,wCAAwC,YAAY,eAAe,IAAI,CAAC,eAAe,WAAW,OAAO,SAAS,IAClH,EACE,OAAO,QACR,CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","names":[],"sources":["../../src/config.ts"],"sourcesContent":[],"mappings":";;;KAMK,aAAA;kBACa;AAHQ,CAAA;AAMb,cAAA,SAAuB,EAAA,CAAA,OAAa,CAAb,EAAA,aAAa,EAAA,GAAA,IAAA"}
1
+ {"version":3,"file":"config.d.ts","names":[],"sources":["../../src/config.ts"],"sourcesContent":[],"mappings":";;;KAMK,aAAA;kBACa;AAHQ,CAAA;AAMb,cAAA,SAAuB,EAAA,CAAA,OAAa,CAAA,EAAb,aAAa,EAAA,GAAA,IAAA"}
@@ -1,12 +1,9 @@
1
- import { Fill, IntlayerConfig, LocalesValues } from "@intlayer/types";
2
-
3
- //#region src/fill/formatAutoFillData.d.ts
4
- type FillData = {
5
- localeList: LocalesValues[];
6
- filePath: string;
7
- isPerLocale: boolean;
1
+ import type { IntlayerConfig, Locales } from '@intlayer/config';
2
+ import type { AutoFill } from '@intlayer/core';
3
+ export type AutoFillData = {
4
+ localeList: Locales[];
5
+ filePath: string;
6
+ isPerLocale: boolean;
8
7
  };
9
- declare const formatFillData: (autoFillField: Fill, localeList: LocalesValues[], filePath: string, dictionaryKey: string, configuration: IntlayerConfig) => FillData[];
10
- //#endregion
11
- export { FillData, formatFillData };
8
+ export declare const formatAutoFillData: (autoFillField: AutoFill, localeList: Locales[], filePath: string, dictionaryKey: string, configuration: IntlayerConfig) => AutoFillData[];
12
9
  //# sourceMappingURL=formatAutoFillData.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"formatAutoFillData.d.ts","names":[],"sources":["../../../src/fill/formatAutoFillData.ts"],"sourcesContent":[],"mappings":";;;KAIY,QAAA;cACE;EADF,QAAA,EAAA,MAAQ;EAMP,WAAA,EAAA,OA2FZ;CA1FgB;AACH,cAFD,cAEC,EAAA,CAAA,aAAA,EADG,IACH,EAAA,UAAA,EAAA,aAAA,EAAA,EAAA,QAAA,EAAA,MAAA,EAAA,aAAA,EAAA,MAAA,EAAA,aAAA,EAGG,cAHH,EAAA,GAIX,QAJW,EAAA"}
1
+ {"version":3,"file":"formatAutoFillData.d.ts","sourceRoot":"","sources":["../../../src/fill/formatAutoFillData.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAG/C,MAAM,MAAM,YAAY,GAAG;IACzB,UAAU,EAAE,OAAO,EAAE,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAC7B,eAAe,QAAQ,EACvB,YAAY,OAAO,EAAE,EACrB,UAAU,MAAM,EAChB,eAAe,MAAM,EACrB,eAAe,cAAc,KAC5B,YAAY,EAmGd,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"formatAutoFilledFilePath.d.ts","names":[],"sources":["../../../src/fill/formatAutoFilledFilePath.ts"],"sourcesContent":[],"mappings":";;;cAUa,+HAKF"}
1
+ {"version":3,"file":"formatAutoFilledFilePath.d.ts","names":[],"sources":["../../../src/fill/formatAutoFilledFilePath.ts"],"sourcesContent":[],"mappings":";;;cAGa,+HAKF"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fill/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,iBAAiB,CAAC"}
@@ -1,7 +1,4 @@
1
- import { Dictionary, IntlayerConfig, Locale } from "@intlayer/types";
2
-
3
- //#region src/fill/writeAutoFill.d.ts
4
- declare const writeFill: (contentDeclarationFile: Dictionary, outputLocales: Locale[], parentLocales: Locale[], configuration: IntlayerConfig) => Promise<void>;
5
- //#endregion
6
- export { writeFill };
1
+ import { type IntlayerConfig, type Locales } from '@intlayer/config';
2
+ import type { AutoFill, Dictionary } from '@intlayer/core';
3
+ export declare const writeAutoFill: (fullDictionary: Dictionary, contentDeclarationFile: Dictionary, autoFillOptions: AutoFill, outputLocales: Locales[], parentLocales: Locales[], configuration: IntlayerConfig) => Promise<void>;
7
4
  //# sourceMappingURL=writeAutoFill.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"writeAutoFill.d.ts","names":[],"sources":["../../../src/fill/writeAutoFill.ts"],"sourcesContent":[],"mappings":";;;cAWa,oCACa,2BACT,yBACA,yBACA,mBAAc"}
1
+ {"version":3,"file":"writeAutoFill.d.ts","sourceRoot":"","sources":["../../../src/fill/writeAutoFill.ts"],"names":[],"mappings":"AAMA,OAAO,EAGL,KAAK,cAAc,EACnB,KAAK,OAAO,EACb,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAG3D,eAAO,MAAM,aAAa,GACxB,gBAAgB,UAAU,EAC1B,wBAAwB,UAAU,EAClC,iBAAiB,QAAQ,EACzB,eAAe,OAAO,EAAE,EACxB,eAAe,OAAO,EAAE,EACxB,eAAe,cAAc,kBAoE9B,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,oBAAoB,CAAC;AACxC,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,0BAA0B,CAAC;AACzC,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intlayer/cli",
3
- "version": "7.0.0-canary.2",
3
+ "version": "7.0.0",
4
4
  "private": false,
5
5
  "description": "Provides uniform command-line interface scripts for Intlayer, used in packages like intlayer-cli and intlayer.",
6
6
  "keywords": [
@@ -63,36 +63,36 @@
63
63
  "typecheck": "tsc --noEmit --project tsconfig.types.json"
64
64
  },
65
65
  "dependencies": {
66
- "@intlayer/api": "7.0.0-canary.2",
67
- "@intlayer/chokidar": "7.0.0-canary.2",
68
- "@intlayer/config": "7.0.0-canary.2",
69
- "@intlayer/dictionaries-entry": "7.0.0-canary.2",
70
- "@intlayer/remote-dictionaries-entry": "7.0.0-canary.2",
71
- "@intlayer/types": "7.0.0-canary.2",
72
- "@intlayer/unmerged-dictionaries-entry": "7.0.0-canary.2",
66
+ "@intlayer/api": "7.0.0",
67
+ "@intlayer/chokidar": "7.0.0",
68
+ "@intlayer/config": "7.0.0",
69
+ "@intlayer/dictionaries-entry": "7.0.0",
70
+ "@intlayer/remote-dictionaries-entry": "7.0.0",
71
+ "@intlayer/types": "7.0.0",
72
+ "@intlayer/unmerged-dictionaries-entry": "7.0.0",
73
73
  "commander": "14.0.1",
74
74
  "eventsource": "3.0.7",
75
75
  "fast-glob": "3.3.3"
76
76
  },
77
77
  "devDependencies": {
78
- "@intlayer/core": "7.0.0-canary.2",
78
+ "@intlayer/core": "7.0.0",
79
79
  "@types/node": "24.9.1",
80
- "@utils/ts-config": "7.0.0-canary.2",
81
- "@utils/ts-config-types": "7.0.0-canary.2",
82
- "@utils/tsdown-config": "7.0.0-canary.2",
80
+ "@utils/ts-config": "7.0.0",
81
+ "@utils/ts-config-types": "7.0.0",
82
+ "@utils/tsdown-config": "7.0.0",
83
83
  "rimraf": "6.0.1",
84
84
  "tsdown": "0.15.9",
85
85
  "typescript": "5.9.3",
86
86
  "vitest": "4.0.3"
87
87
  },
88
88
  "peerDependencies": {
89
- "@intlayer/api": "7.0.0-canary.2",
90
- "@intlayer/chokidar": "7.0.0-canary.2",
91
- "@intlayer/config": "7.0.0-canary.2",
92
- "@intlayer/dictionaries-entry": "7.0.0-canary.2",
93
- "@intlayer/remote-dictionaries-entry": "7.0.0-canary.2",
94
- "@intlayer/types": "7.0.0-canary.2",
95
- "@intlayer/unmerged-dictionaries-entry": "7.0.0-canary.2"
89
+ "@intlayer/api": "7.0.0",
90
+ "@intlayer/chokidar": "7.0.0",
91
+ "@intlayer/config": "7.0.0",
92
+ "@intlayer/dictionaries-entry": "7.0.0",
93
+ "@intlayer/remote-dictionaries-entry": "7.0.0",
94
+ "@intlayer/types": "7.0.0",
95
+ "@intlayer/unmerged-dictionaries-entry": "7.0.0"
96
96
  },
97
97
  "bug": {
98
98
  "url": "https://github.com/aymericzip/intlayer/issues"
@@ -1,50 +0,0 @@
1
- const require_fill_formatAutoFilledFilePath = require('./formatAutoFilledFilePath.cjs');
2
-
3
- //#region src/fill/formatAutoFillData.ts
4
- const formatFillData = (autoFillField, localeList, filePath, dictionaryKey, configuration) => {
5
- const outputContentDeclarationFile = [];
6
- const baseDir = configuration.content.baseDir;
7
- if (!autoFillField) return outputContentDeclarationFile;
8
- if (typeof autoFillField === "string") {
9
- if (autoFillField.includes("{{locale}}")) {
10
- const output = localeList.map((locale) => {
11
- const formattedFilePath = require_fill_formatAutoFilledFilePath.formatAutoFilledFilePath(autoFillField, dictionaryKey, filePath, baseDir, locale);
12
- return {
13
- localeList: [locale],
14
- filePath: formattedFilePath,
15
- isPerLocale: true
16
- };
17
- });
18
- outputContentDeclarationFile.push(...output);
19
- } else {
20
- const formattedFilePath = require_fill_formatAutoFilledFilePath.formatAutoFilledFilePath(autoFillField, dictionaryKey, filePath, baseDir);
21
- outputContentDeclarationFile.push({
22
- localeList,
23
- filePath: formattedFilePath,
24
- isPerLocale: false
25
- });
26
- }
27
- return outputContentDeclarationFile;
28
- }
29
- if (typeof autoFillField === "object") {
30
- const groupedByFilePath = Object.keys(autoFillField).filter((locale) => typeof autoFillField[locale] === "string").filter((locale) => Boolean(autoFillField[locale])).map((locale) => {
31
- const formattedFilePath = require_fill_formatAutoFilledFilePath.formatAutoFilledFilePath(autoFillField[locale], dictionaryKey, filePath, baseDir, locale);
32
- return {
33
- localeList: [locale],
34
- filePath: formattedFilePath,
35
- isPerLocale: true
36
- };
37
- }).reduce((acc, curr) => {
38
- const existing = acc.find((item) => item.filePath === curr.filePath);
39
- if (existing) existing.localeList.push(...curr.localeList);
40
- else acc.push(curr);
41
- return acc;
42
- }, []);
43
- outputContentDeclarationFile.push(...groupedByFilePath);
44
- }
45
- return outputContentDeclarationFile;
46
- };
47
-
48
- //#endregion
49
- exports.formatFillData = formatFillData;
50
- //# sourceMappingURL=formatAutoFillData.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"formatAutoFillData.cjs","names":["outputContentDeclarationFile: FillData[]","formatAutoFilledFilePath"],"sources":["../../../src/fill/formatAutoFillData.ts"],"sourcesContent":["import { extname } from 'node:path';\nimport type { Fill, IntlayerConfig, LocalesValues } from '@intlayer/types';\nimport { formatAutoFilledFilePath } from './formatAutoFilledFilePath';\n\nexport type FillData = {\n localeList: LocalesValues[];\n filePath: string;\n isPerLocale: boolean;\n};\n\nexport const formatFillData = (\n autoFillField: Fill,\n localeList: LocalesValues[],\n filePath: string,\n dictionaryKey: string,\n configuration: IntlayerConfig\n): FillData[] => {\n const outputContentDeclarationFile: FillData[] = [];\n\n const baseDir = configuration.content.baseDir;\n\n if (!autoFillField) return outputContentDeclarationFile;\n\n if (typeof autoFillField === 'string') {\n if (autoFillField.includes('{{locale}}')) {\n const output = localeList.map((locale) => {\n const formattedFilePath = formatAutoFilledFilePath(\n autoFillField,\n dictionaryKey,\n filePath,\n baseDir,\n locale\n );\n\n return {\n localeList: [locale],\n filePath: formattedFilePath,\n isPerLocale: true,\n };\n });\n\n outputContentDeclarationFile.push(...output);\n } else {\n const formattedFilePath = formatAutoFilledFilePath(\n autoFillField,\n dictionaryKey,\n filePath,\n baseDir\n );\n\n outputContentDeclarationFile.push({\n localeList,\n filePath: formattedFilePath,\n isPerLocale: false,\n });\n }\n\n return outputContentDeclarationFile;\n }\n\n if (typeof autoFillField === 'object') {\n const localeList = Object.keys(autoFillField).filter(\n (locale) =>\n typeof autoFillField[locale as keyof typeof autoFillField] === 'string'\n ) as LocalesValues[];\n\n const output: FillData[] = localeList\n .filter((locale) =>\n Boolean(autoFillField[locale as keyof typeof autoFillField])\n )\n .map((locale) => {\n const formattedFilePath = formatAutoFilledFilePath(\n autoFillField[locale as keyof typeof autoFillField] as string,\n dictionaryKey,\n filePath,\n baseDir,\n locale\n );\n\n return {\n localeList: [locale],\n filePath: formattedFilePath,\n isPerLocale: true,\n };\n });\n\n // Group by filePath and merge localeList\n const groupedByFilePath = output.reduce((acc, curr) => {\n const existing = acc.find((item) => item.filePath === curr.filePath);\n if (existing) {\n existing.localeList.push(...curr.localeList);\n } else {\n acc.push(curr);\n }\n return acc;\n }, [] as FillData[]);\n\n outputContentDeclarationFile.push(...groupedByFilePath);\n }\n\n return outputContentDeclarationFile;\n};\n"],"mappings":";;;AAUA,MAAa,kBACX,eACA,YACA,UACA,eACA,kBACe;CACf,MAAMA,+BAA2C,EAAE;CAEnD,MAAM,UAAU,cAAc,QAAQ;AAEtC,KAAI,CAAC,cAAe,QAAO;AAE3B,KAAI,OAAO,kBAAkB,UAAU;AACrC,MAAI,cAAc,SAAS,aAAa,EAAE;GACxC,MAAM,SAAS,WAAW,KAAK,WAAW;IACxC,MAAM,oBAAoBC,+DACxB,eACA,eACA,UACA,SACA,OACD;AAED,WAAO;KACL,YAAY,CAAC,OAAO;KACpB,UAAU;KACV,aAAa;KACd;KACD;AAEF,gCAA6B,KAAK,GAAG,OAAO;SACvC;GACL,MAAM,oBAAoBA,+DACxB,eACA,eACA,UACA,QACD;AAED,gCAA6B,KAAK;IAChC;IACA,UAAU;IACV,aAAa;IACd,CAAC;;AAGJ,SAAO;;AAGT,KAAI,OAAO,kBAAkB,UAAU;EA2BrC,MAAM,oBA1Ba,OAAO,KAAK,cAAc,CAAC,QAC3C,WACC,OAAO,cAAc,YAA0C,SAClE,CAGE,QAAQ,WACP,QAAQ,cAAc,QAAsC,CAC7D,CACA,KAAK,WAAW;GACf,MAAM,oBAAoBA,+DACxB,cAAc,SACd,eACA,UACA,SACA,OACD;AAED,UAAO;IACL,YAAY,CAAC,OAAO;IACpB,UAAU;IACV,aAAa;IACd;IACD,CAG6B,QAAQ,KAAK,SAAS;GACrD,MAAM,WAAW,IAAI,MAAM,SAAS,KAAK,aAAa,KAAK,SAAS;AACpE,OAAI,SACF,UAAS,WAAW,KAAK,GAAG,KAAK,WAAW;OAE5C,KAAI,KAAK,KAAK;AAEhB,UAAO;KACN,EAAE,CAAe;AAEpB,+BAA6B,KAAK,GAAG,kBAAkB;;AAGzD,QAAO"}
@@ -1,42 +0,0 @@
1
- const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
- let __intlayer_chokidar = require("@intlayer/chokidar");
3
- __intlayer_chokidar = require_rolldown_runtime.__toESM(__intlayer_chokidar);
4
-
5
- //#region src/fill/groupLimiter.ts
6
- /**
7
- * Creates a group limiter that controls concurrency and provides a sync point
8
- * to wait for all scheduled tasks to complete.
9
- */
10
- const makeGroupLimiter = (concurrency) => {
11
- const limit = (0, __intlayer_chokidar.pLimit)(concurrency);
12
- let inflight = 0;
13
- let resolveDone;
14
- const donePromise = new Promise((r) => {
15
- resolveDone = r;
16
- });
17
- let doneResolved = false;
18
- const schedule = (fn) => {
19
- inflight++;
20
- limit(async () => {
21
- await fn();
22
- inflight--;
23
- if (inflight === 0 && !doneResolved && limit.pendingCount === 0 && limit.activeCount === 0) {
24
- doneResolved = true;
25
- resolveDone();
26
- }
27
- });
28
- };
29
- const done = () => donePromise;
30
- const activeCount = () => limit.activeCount;
31
- const pendingCount = () => limit.pendingCount;
32
- return {
33
- schedule,
34
- done,
35
- activeCount,
36
- pendingCount
37
- };
38
- };
39
-
40
- //#endregion
41
- exports.makeGroupLimiter = makeGroupLimiter;
42
- //# sourceMappingURL=groupLimiter.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"groupLimiter.cjs","names":["resolveDone!: () => void"],"sources":["../../../src/fill/groupLimiter.ts"],"sourcesContent":["import { pLimit } from '@intlayer/chokidar';\n\nexport type GroupLimiter = {\n schedule: <T>(fn: () => Promise<T>) => void;\n done: () => Promise<void>;\n activeCount: () => number;\n pendingCount: () => number;\n};\n\ntype PLimitFunction = {\n (...args: any[]): Promise<any>;\n activeCount: number;\n pendingCount: number;\n clearQueue: () => void;\n concurrency: number;\n};\n\n/**\n * Creates a group limiter that controls concurrency and provides a sync point\n * to wait for all scheduled tasks to complete.\n */\nexport const makeGroupLimiter = (concurrency: number): GroupLimiter => {\n const limit = pLimit(concurrency) as PLimitFunction;\n let inflight = 0;\n let resolveDone!: () => void;\n const donePromise = new Promise<void>((r) => {\n resolveDone = r;\n });\n let doneResolved = false;\n\n const schedule = <T>(fn: () => Promise<T>): void => {\n inflight++;\n limit(async () => {\n await fn();\n\n inflight--;\n if (\n inflight === 0 &&\n !doneResolved &&\n limit.pendingCount === 0 &&\n limit.activeCount === 0\n ) {\n doneResolved = true;\n resolveDone();\n }\n });\n };\n\n const done = (): Promise<void> => donePromise;\n\n const activeCount = (): number => limit.activeCount;\n const pendingCount = (): number => limit.pendingCount;\n\n return { schedule, done, activeCount, pendingCount };\n};\n"],"mappings":";;;;;;;;;AAqBA,MAAa,oBAAoB,gBAAsC;CACrE,MAAM,wCAAe,YAAY;CACjC,IAAI,WAAW;CACf,IAAIA;CACJ,MAAM,cAAc,IAAI,SAAe,MAAM;AAC3C,gBAAc;GACd;CACF,IAAI,eAAe;CAEnB,MAAM,YAAe,OAA+B;AAClD;AACA,QAAM,YAAY;AAChB,SAAM,IAAI;AAEV;AACA,OACE,aAAa,KACb,CAAC,gBACD,MAAM,iBAAiB,KACvB,MAAM,gBAAgB,GACtB;AACA,mBAAe;AACf,iBAAa;;IAEf;;CAGJ,MAAM,aAA4B;CAElC,MAAM,oBAA4B,MAAM;CACxC,MAAM,qBAA6B,MAAM;AAEzC,QAAO;EAAE;EAAU;EAAM;EAAa;EAAc"}
@@ -1,10 +0,0 @@
1
- const require_fill_formatAutoFilledFilePath = require('./formatAutoFilledFilePath.cjs');
2
-
3
- //#region src/fill/test-original-case.ts
4
- const result = require_fill_formatAutoFilledFilePath.formatAutoFilledFilePath("./{{key}}.content.json", "dictionary-field-editor", "../../packages/@intlayer/design-system/src/components/DictionaryFieldEditor/dictionaryFieldEditor.content.ts", "/Users/aymericpineau/Documents/intlayer/apps/website");
5
- console.log("Result:", result);
6
- console.log("Expected: ../../packages/@intlayer/design-system/src/components/DictionaryFieldEditor/dictionaryFieldEditor.content.json");
7
- console.log("Match:", result === "../../packages/@intlayer/design-system/src/components/DictionaryFieldEditor/dictionaryFieldEditor.content.json");
8
-
9
- //#endregion
10
- //# sourceMappingURL=test-original-case.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"test-original-case.cjs","names":["formatAutoFilledFilePath"],"sources":["../../../src/fill/test-original-case.ts"],"sourcesContent":["import { formatAutoFilledFilePath } from './formatAutoFilledFilePath';\n\n// Original use case from the user\nconst result = formatAutoFilledFilePath(\n './{{key}}.content.json',\n 'dictionary-field-editor',\n '../../packages/@intlayer/design-system/src/components/DictionaryFieldEditor/dictionaryFieldEditor.content.ts',\n '/Users/aymericpineau/Documents/intlayer/apps/website'\n);\n\nconsole.log('Result:', result);\nconsole.log('Expected: ../../packages/@intlayer/design-system/src/components/DictionaryFieldEditor/dictionaryFieldEditor.content.json');\nconsole.log('Match:', result === '../../packages/@intlayer/design-system/src/components/DictionaryFieldEditor/dictionaryFieldEditor.content.json');\n\n"],"mappings":";;;AAGA,MAAM,SAASA,+DACb,0BACA,2BACA,gHACA,uDACD;AAED,QAAQ,IAAI,WAAW,OAAO;AAC9B,QAAQ,IAAI,2HAA2H;AACvI,QAAQ,IAAI,UAAU,WAAW,iHAAiH"}
@@ -1,48 +0,0 @@
1
- const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
- const require_fill_formatFillData = require('./formatFillData.cjs');
3
- let __intlayer_chokidar = require("@intlayer/chokidar");
4
- __intlayer_chokidar = require_rolldown_runtime.__toESM(__intlayer_chokidar);
5
- let __intlayer_config = require("@intlayer/config");
6
- __intlayer_config = require_rolldown_runtime.__toESM(__intlayer_config);
7
- let __intlayer_dictionaries_entry = require("@intlayer/dictionaries-entry");
8
- __intlayer_dictionaries_entry = require_rolldown_runtime.__toESM(__intlayer_dictionaries_entry);
9
-
10
- //#region src/fill/writeAutoFill.ts
11
- const writeFill = async (contentDeclarationFile, outputLocales, parentLocales, configuration) => {
12
- const appLogger = (0, __intlayer_config.getAppLogger)(configuration);
13
- const fullDictionary = (0, __intlayer_dictionaries_entry.getDictionaries)(configuration)[contentDeclarationFile.key];
14
- const filePath = contentDeclarationFile.filePath;
15
- if (!filePath) {
16
- appLogger("No file path found for dictionary", { level: "error" });
17
- return;
18
- }
19
- const autoFillOptions = fullDictionary.fill ?? configuration.content.fill;
20
- if (typeof autoFillOptions === "boolean" && autoFillOptions === false) {
21
- appLogger(`Auto fill is disabled for '${(0, __intlayer_config.colorizeKey)(fullDictionary.key)}'`, { level: "info" });
22
- return;
23
- }
24
- const autoFillData = require_fill_formatFillData.formatFillData(autoFillOptions, (outputLocales ?? configuration.internationalization.locales).filter((locale) => !parentLocales?.includes(locale)), filePath, fullDictionary.key, configuration);
25
- for await (const output of autoFillData) {
26
- if (!output.filePath) {
27
- appLogger(`No file path found for auto filled content declaration for '${(0, __intlayer_config.colorizeKey)(fullDictionary.key)}'`, { level: "error" });
28
- continue;
29
- }
30
- const reducedDictionaryContent = (0, __intlayer_chokidar.reduceDictionaryContent)(fullDictionary, contentDeclarationFile);
31
- await (0, __intlayer_chokidar.writeContentDeclaration)({
32
- ...fullDictionary,
33
- fill: void 0,
34
- filled: true,
35
- locale: output.isPerLocale ? output.localeList[0] : void 0,
36
- content: reducedDictionaryContent.content,
37
- filePath: output.filePath
38
- }, configuration);
39
- if (output.isPerLocale) {
40
- const sourceLocale = output.localeList[0];
41
- appLogger(`Auto filled per-locale content declaration for '${(0, __intlayer_config.colorizeKey)(fullDictionary.key)}' written to ${(0, __intlayer_chokidar.formatPath)(output.filePath)} for locale ${(0, __intlayer_chokidar.formatLocale)(sourceLocale)}`, { level: "info" });
42
- } else appLogger(`Auto filled content declaration for '${(0, __intlayer_config.colorizeKey)(fullDictionary.key)}' written to ${(0, __intlayer_chokidar.formatPath)(output.filePath)}`, { level: "info" });
43
- }
44
- };
45
-
46
- //#endregion
47
- exports.writeFill = writeFill;
48
- //# sourceMappingURL=writeAutoFill.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"writeAutoFill.cjs","names":["autoFillData: FillData[]","formatFillData"],"sources":["../../../src/fill/writeAutoFill.ts"],"sourcesContent":["import {\n formatLocale,\n formatPath,\n reduceDictionaryContent,\n writeContentDeclaration,\n} from '@intlayer/chokidar';\nimport { colorizeKey, getAppLogger } from '@intlayer/config';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport type { Dictionary, Fill, IntlayerConfig, Locale } from '@intlayer/types';\nimport { type FillData, formatFillData } from './formatFillData';\n\nexport const writeFill = async (\n contentDeclarationFile: Dictionary,\n outputLocales: Locale[],\n parentLocales: Locale[],\n configuration: IntlayerConfig\n) => {\n const appLogger = getAppLogger(configuration);\n const dictionaries = getDictionaries(configuration);\n\n const fullDictionary = dictionaries[contentDeclarationFile.key];\n\n const filePath = contentDeclarationFile.filePath;\n\n if (!filePath) {\n appLogger('No file path found for dictionary', {\n level: 'error',\n });\n return;\n }\n\n const autoFillOptions = fullDictionary.fill ?? configuration.content.fill;\n\n if (\n typeof autoFillOptions === 'boolean' &&\n (autoFillOptions as boolean) === false\n ) {\n appLogger(\n `Auto fill is disabled for '${colorizeKey(fullDictionary.key)}'`,\n {\n level: 'info',\n }\n );\n return;\n }\n\n const localeList: Locale[] = (\n outputLocales ?? configuration.internationalization.locales\n ).filter((locale) => !parentLocales?.includes(locale));\n\n const autoFillData: FillData[] = formatFillData(\n autoFillOptions as Fill,\n localeList,\n filePath,\n fullDictionary.key,\n configuration\n );\n\n for await (const output of autoFillData) {\n if (!output.filePath) {\n appLogger(\n `No file path found for auto filled content declaration for '${colorizeKey(fullDictionary.key)}'`,\n {\n level: 'error',\n }\n );\n continue;\n }\n\n const reducedDictionaryContent = reduceDictionaryContent(\n fullDictionary,\n contentDeclarationFile\n );\n\n // write file\n await writeContentDeclaration(\n {\n ...fullDictionary,\n fill: undefined,\n filled: true,\n locale: output.isPerLocale ? output.localeList[0] : undefined,\n content: reducedDictionaryContent.content,\n filePath: output.filePath,\n },\n configuration\n );\n\n if (output.isPerLocale) {\n const sourceLocale = output.localeList[0];\n\n appLogger(\n `Auto filled per-locale content declaration for '${colorizeKey(fullDictionary.key)}' written to ${formatPath(output.filePath)} for locale ${formatLocale(sourceLocale)}`,\n {\n level: 'info',\n }\n );\n } else {\n appLogger(\n `Auto filled content declaration for '${colorizeKey(fullDictionary.key)}' written to ${formatPath(output.filePath)}`,\n {\n level: 'info',\n }\n );\n }\n }\n};\n"],"mappings":";;;;;;;;;;AAWA,MAAa,YAAY,OACvB,wBACA,eACA,eACA,kBACG;CACH,MAAM,gDAAyB,cAAc;CAG7C,MAAM,oEAF+B,cAAc,CAEf,uBAAuB;CAE3D,MAAM,WAAW,uBAAuB;AAExC,KAAI,CAAC,UAAU;AACb,YAAU,qCAAqC,EAC7C,OAAO,SACR,CAAC;AACF;;CAGF,MAAM,kBAAkB,eAAe,QAAQ,cAAc,QAAQ;AAErE,KACE,OAAO,oBAAoB,aAC1B,oBAAgC,OACjC;AACA,YACE,iEAA0C,eAAe,IAAI,CAAC,IAC9D,EACE,OAAO,QACR,CACF;AACD;;CAOF,MAAMA,eAA2BC,2CAC/B,kBAJA,iBAAiB,cAAc,qBAAqB,SACpD,QAAQ,WAAW,CAAC,eAAe,SAAS,OAAO,CAAC,EAKpD,UACA,eAAe,KACf,cACD;AAED,YAAW,MAAM,UAAU,cAAc;AACvC,MAAI,CAAC,OAAO,UAAU;AACpB,aACE,kGAA2E,eAAe,IAAI,CAAC,IAC/F,EACE,OAAO,SACR,CACF;AACD;;EAGF,MAAM,4EACJ,gBACA,uBACD;AAGD,yDACE;GACE,GAAG;GACH,MAAM;GACN,QAAQ;GACR,QAAQ,OAAO,cAAc,OAAO,WAAW,KAAK;GACpD,SAAS,yBAAyB;GAClC,UAAU,OAAO;GAClB,EACD,cACD;AAED,MAAI,OAAO,aAAa;GACtB,MAAM,eAAe,OAAO,WAAW;AAEvC,aACE,sFAA+D,eAAe,IAAI,CAAC,mDAA0B,OAAO,SAAS,CAAC,oDAA2B,aAAa,IACtK,EACE,OAAO,QACR,CACF;QAED,WACE,2EAAoD,eAAe,IAAI,CAAC,mDAA0B,OAAO,SAAS,IAClH,EACE,OAAO,QACR,CACF"}
@@ -1,50 +0,0 @@
1
- import { formatAutoFilledFilePath } from "./formatAutoFilledFilePath.mjs";
2
-
3
- //#region src/fill/formatAutoFillData.ts
4
- const formatFillData = (autoFillField, localeList, filePath, dictionaryKey, configuration) => {
5
- const outputContentDeclarationFile = [];
6
- const baseDir = configuration.content.baseDir;
7
- if (!autoFillField) return outputContentDeclarationFile;
8
- if (typeof autoFillField === "string") {
9
- if (autoFillField.includes("{{locale}}")) {
10
- const output = localeList.map((locale) => {
11
- const formattedFilePath = formatAutoFilledFilePath(autoFillField, dictionaryKey, filePath, baseDir, locale);
12
- return {
13
- localeList: [locale],
14
- filePath: formattedFilePath,
15
- isPerLocale: true
16
- };
17
- });
18
- outputContentDeclarationFile.push(...output);
19
- } else {
20
- const formattedFilePath = formatAutoFilledFilePath(autoFillField, dictionaryKey, filePath, baseDir);
21
- outputContentDeclarationFile.push({
22
- localeList,
23
- filePath: formattedFilePath,
24
- isPerLocale: false
25
- });
26
- }
27
- return outputContentDeclarationFile;
28
- }
29
- if (typeof autoFillField === "object") {
30
- const groupedByFilePath = Object.keys(autoFillField).filter((locale) => typeof autoFillField[locale] === "string").filter((locale) => Boolean(autoFillField[locale])).map((locale) => {
31
- const formattedFilePath = formatAutoFilledFilePath(autoFillField[locale], dictionaryKey, filePath, baseDir, locale);
32
- return {
33
- localeList: [locale],
34
- filePath: formattedFilePath,
35
- isPerLocale: true
36
- };
37
- }).reduce((acc, curr) => {
38
- const existing = acc.find((item) => item.filePath === curr.filePath);
39
- if (existing) existing.localeList.push(...curr.localeList);
40
- else acc.push(curr);
41
- return acc;
42
- }, []);
43
- outputContentDeclarationFile.push(...groupedByFilePath);
44
- }
45
- return outputContentDeclarationFile;
46
- };
47
-
48
- //#endregion
49
- export { formatFillData };
50
- //# sourceMappingURL=formatAutoFillData.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"formatAutoFillData.mjs","names":["outputContentDeclarationFile: FillData[]"],"sources":["../../../src/fill/formatAutoFillData.ts"],"sourcesContent":["import { extname } from 'node:path';\nimport type { Fill, IntlayerConfig, LocalesValues } from '@intlayer/types';\nimport { formatAutoFilledFilePath } from './formatAutoFilledFilePath';\n\nexport type FillData = {\n localeList: LocalesValues[];\n filePath: string;\n isPerLocale: boolean;\n};\n\nexport const formatFillData = (\n autoFillField: Fill,\n localeList: LocalesValues[],\n filePath: string,\n dictionaryKey: string,\n configuration: IntlayerConfig\n): FillData[] => {\n const outputContentDeclarationFile: FillData[] = [];\n\n const baseDir = configuration.content.baseDir;\n\n if (!autoFillField) return outputContentDeclarationFile;\n\n if (typeof autoFillField === 'string') {\n if (autoFillField.includes('{{locale}}')) {\n const output = localeList.map((locale) => {\n const formattedFilePath = formatAutoFilledFilePath(\n autoFillField,\n dictionaryKey,\n filePath,\n baseDir,\n locale\n );\n\n return {\n localeList: [locale],\n filePath: formattedFilePath,\n isPerLocale: true,\n };\n });\n\n outputContentDeclarationFile.push(...output);\n } else {\n const formattedFilePath = formatAutoFilledFilePath(\n autoFillField,\n dictionaryKey,\n filePath,\n baseDir\n );\n\n outputContentDeclarationFile.push({\n localeList,\n filePath: formattedFilePath,\n isPerLocale: false,\n });\n }\n\n return outputContentDeclarationFile;\n }\n\n if (typeof autoFillField === 'object') {\n const localeList = Object.keys(autoFillField).filter(\n (locale) =>\n typeof autoFillField[locale as keyof typeof autoFillField] === 'string'\n ) as LocalesValues[];\n\n const output: FillData[] = localeList\n .filter((locale) =>\n Boolean(autoFillField[locale as keyof typeof autoFillField])\n )\n .map((locale) => {\n const formattedFilePath = formatAutoFilledFilePath(\n autoFillField[locale as keyof typeof autoFillField] as string,\n dictionaryKey,\n filePath,\n baseDir,\n locale\n );\n\n return {\n localeList: [locale],\n filePath: formattedFilePath,\n isPerLocale: true,\n };\n });\n\n // Group by filePath and merge localeList\n const groupedByFilePath = output.reduce((acc, curr) => {\n const existing = acc.find((item) => item.filePath === curr.filePath);\n if (existing) {\n existing.localeList.push(...curr.localeList);\n } else {\n acc.push(curr);\n }\n return acc;\n }, [] as FillData[]);\n\n outputContentDeclarationFile.push(...groupedByFilePath);\n }\n\n return outputContentDeclarationFile;\n};\n"],"mappings":";;;AAUA,MAAa,kBACX,eACA,YACA,UACA,eACA,kBACe;CACf,MAAMA,+BAA2C,EAAE;CAEnD,MAAM,UAAU,cAAc,QAAQ;AAEtC,KAAI,CAAC,cAAe,QAAO;AAE3B,KAAI,OAAO,kBAAkB,UAAU;AACrC,MAAI,cAAc,SAAS,aAAa,EAAE;GACxC,MAAM,SAAS,WAAW,KAAK,WAAW;IACxC,MAAM,oBAAoB,yBACxB,eACA,eACA,UACA,SACA,OACD;AAED,WAAO;KACL,YAAY,CAAC,OAAO;KACpB,UAAU;KACV,aAAa;KACd;KACD;AAEF,gCAA6B,KAAK,GAAG,OAAO;SACvC;GACL,MAAM,oBAAoB,yBACxB,eACA,eACA,UACA,QACD;AAED,gCAA6B,KAAK;IAChC;IACA,UAAU;IACV,aAAa;IACd,CAAC;;AAGJ,SAAO;;AAGT,KAAI,OAAO,kBAAkB,UAAU;EA2BrC,MAAM,oBA1Ba,OAAO,KAAK,cAAc,CAAC,QAC3C,WACC,OAAO,cAAc,YAA0C,SAClE,CAGE,QAAQ,WACP,QAAQ,cAAc,QAAsC,CAC7D,CACA,KAAK,WAAW;GACf,MAAM,oBAAoB,yBACxB,cAAc,SACd,eACA,UACA,SACA,OACD;AAED,UAAO;IACL,YAAY,CAAC,OAAO;IACpB,UAAU;IACV,aAAa;IACd;IACD,CAG6B,QAAQ,KAAK,SAAS;GACrD,MAAM,WAAW,IAAI,MAAM,SAAS,KAAK,aAAa,KAAK,SAAS;AACpE,OAAI,SACF,UAAS,WAAW,KAAK,GAAG,KAAK,WAAW;OAE5C,KAAI,KAAK,KAAK;AAEhB,UAAO;KACN,EAAE,CAAe;AAEpB,+BAA6B,KAAK,GAAG,kBAAkB;;AAGzD,QAAO"}
@@ -1,40 +0,0 @@
1
- import { pLimit } from "@intlayer/chokidar";
2
-
3
- //#region src/fill/groupLimiter.ts
4
- /**
5
- * Creates a group limiter that controls concurrency and provides a sync point
6
- * to wait for all scheduled tasks to complete.
7
- */
8
- const makeGroupLimiter = (concurrency) => {
9
- const limit = pLimit(concurrency);
10
- let inflight = 0;
11
- let resolveDone;
12
- const donePromise = new Promise((r) => {
13
- resolveDone = r;
14
- });
15
- let doneResolved = false;
16
- const schedule = (fn) => {
17
- inflight++;
18
- limit(async () => {
19
- await fn();
20
- inflight--;
21
- if (inflight === 0 && !doneResolved && limit.pendingCount === 0 && limit.activeCount === 0) {
22
- doneResolved = true;
23
- resolveDone();
24
- }
25
- });
26
- };
27
- const done = () => donePromise;
28
- const activeCount = () => limit.activeCount;
29
- const pendingCount = () => limit.pendingCount;
30
- return {
31
- schedule,
32
- done,
33
- activeCount,
34
- pendingCount
35
- };
36
- };
37
-
38
- //#endregion
39
- export { makeGroupLimiter };
40
- //# sourceMappingURL=groupLimiter.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"groupLimiter.mjs","names":["resolveDone!: () => void"],"sources":["../../../src/fill/groupLimiter.ts"],"sourcesContent":["import { pLimit } from '@intlayer/chokidar';\n\nexport type GroupLimiter = {\n schedule: <T>(fn: () => Promise<T>) => void;\n done: () => Promise<void>;\n activeCount: () => number;\n pendingCount: () => number;\n};\n\ntype PLimitFunction = {\n (...args: any[]): Promise<any>;\n activeCount: number;\n pendingCount: number;\n clearQueue: () => void;\n concurrency: number;\n};\n\n/**\n * Creates a group limiter that controls concurrency and provides a sync point\n * to wait for all scheduled tasks to complete.\n */\nexport const makeGroupLimiter = (concurrency: number): GroupLimiter => {\n const limit = pLimit(concurrency) as PLimitFunction;\n let inflight = 0;\n let resolveDone!: () => void;\n const donePromise = new Promise<void>((r) => {\n resolveDone = r;\n });\n let doneResolved = false;\n\n const schedule = <T>(fn: () => Promise<T>): void => {\n inflight++;\n limit(async () => {\n await fn();\n\n inflight--;\n if (\n inflight === 0 &&\n !doneResolved &&\n limit.pendingCount === 0 &&\n limit.activeCount === 0\n ) {\n doneResolved = true;\n resolveDone();\n }\n });\n };\n\n const done = (): Promise<void> => donePromise;\n\n const activeCount = (): number => limit.activeCount;\n const pendingCount = (): number => limit.pendingCount;\n\n return { schedule, done, activeCount, pendingCount };\n};\n"],"mappings":";;;;;;;AAqBA,MAAa,oBAAoB,gBAAsC;CACrE,MAAM,QAAQ,OAAO,YAAY;CACjC,IAAI,WAAW;CACf,IAAIA;CACJ,MAAM,cAAc,IAAI,SAAe,MAAM;AAC3C,gBAAc;GACd;CACF,IAAI,eAAe;CAEnB,MAAM,YAAe,OAA+B;AAClD;AACA,QAAM,YAAY;AAChB,SAAM,IAAI;AAEV;AACA,OACE,aAAa,KACb,CAAC,gBACD,MAAM,iBAAiB,KACvB,MAAM,gBAAgB,GACtB;AACA,mBAAe;AACf,iBAAa;;IAEf;;CAGJ,MAAM,aAA4B;CAElC,MAAM,oBAA4B,MAAM;CACxC,MAAM,qBAA6B,MAAM;AAEzC,QAAO;EAAE;EAAU;EAAM;EAAa;EAAc"}
@@ -1,10 +0,0 @@
1
- import { formatAutoFilledFilePath } from "./formatAutoFilledFilePath.mjs";
2
-
3
- //#region src/fill/test-original-case.ts
4
- const result = formatAutoFilledFilePath("./{{key}}.content.json", "dictionary-field-editor", "../../packages/@intlayer/design-system/src/components/DictionaryFieldEditor/dictionaryFieldEditor.content.ts", "/Users/aymericpineau/Documents/intlayer/apps/website");
5
- console.log("Result:", result);
6
- console.log("Expected: ../../packages/@intlayer/design-system/src/components/DictionaryFieldEditor/dictionaryFieldEditor.content.json");
7
- console.log("Match:", result === "../../packages/@intlayer/design-system/src/components/DictionaryFieldEditor/dictionaryFieldEditor.content.json");
8
-
9
- //#endregion
10
- //# sourceMappingURL=test-original-case.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"test-original-case.mjs","names":[],"sources":["../../../src/fill/test-original-case.ts"],"sourcesContent":["import { formatAutoFilledFilePath } from './formatAutoFilledFilePath';\n\n// Original use case from the user\nconst result = formatAutoFilledFilePath(\n './{{key}}.content.json',\n 'dictionary-field-editor',\n '../../packages/@intlayer/design-system/src/components/DictionaryFieldEditor/dictionaryFieldEditor.content.ts',\n '/Users/aymericpineau/Documents/intlayer/apps/website'\n);\n\nconsole.log('Result:', result);\nconsole.log('Expected: ../../packages/@intlayer/design-system/src/components/DictionaryFieldEditor/dictionaryFieldEditor.content.json');\nconsole.log('Match:', result === '../../packages/@intlayer/design-system/src/components/DictionaryFieldEditor/dictionaryFieldEditor.content.json');\n\n"],"mappings":";;;AAGA,MAAM,SAAS,yBACb,0BACA,2BACA,gHACA,uDACD;AAED,QAAQ,IAAI,WAAW,OAAO;AAC9B,QAAQ,IAAI,2HAA2H;AACvI,QAAQ,IAAI,UAAU,WAAW,iHAAiH"}
@@ -1,44 +0,0 @@
1
- import { formatFillData } from "./formatFillData.mjs";
2
- import { formatLocale, formatPath, reduceDictionaryContent, writeContentDeclaration } from "@intlayer/chokidar";
3
- import { colorizeKey, getAppLogger } from "@intlayer/config";
4
- import { getDictionaries } from "@intlayer/dictionaries-entry";
5
-
6
- //#region src/fill/writeAutoFill.ts
7
- const writeFill = async (contentDeclarationFile, outputLocales, parentLocales, configuration) => {
8
- const appLogger = getAppLogger(configuration);
9
- const fullDictionary = getDictionaries(configuration)[contentDeclarationFile.key];
10
- const filePath = contentDeclarationFile.filePath;
11
- if (!filePath) {
12
- appLogger("No file path found for dictionary", { level: "error" });
13
- return;
14
- }
15
- const autoFillOptions = fullDictionary.fill ?? configuration.content.fill;
16
- if (typeof autoFillOptions === "boolean" && autoFillOptions === false) {
17
- appLogger(`Auto fill is disabled for '${colorizeKey(fullDictionary.key)}'`, { level: "info" });
18
- return;
19
- }
20
- const autoFillData = formatFillData(autoFillOptions, (outputLocales ?? configuration.internationalization.locales).filter((locale) => !parentLocales?.includes(locale)), filePath, fullDictionary.key, configuration);
21
- for await (const output of autoFillData) {
22
- if (!output.filePath) {
23
- appLogger(`No file path found for auto filled content declaration for '${colorizeKey(fullDictionary.key)}'`, { level: "error" });
24
- continue;
25
- }
26
- const reducedDictionaryContent = reduceDictionaryContent(fullDictionary, contentDeclarationFile);
27
- await writeContentDeclaration({
28
- ...fullDictionary,
29
- fill: void 0,
30
- filled: true,
31
- locale: output.isPerLocale ? output.localeList[0] : void 0,
32
- content: reducedDictionaryContent.content,
33
- filePath: output.filePath
34
- }, configuration);
35
- if (output.isPerLocale) {
36
- const sourceLocale = output.localeList[0];
37
- appLogger(`Auto filled per-locale content declaration for '${colorizeKey(fullDictionary.key)}' written to ${formatPath(output.filePath)} for locale ${formatLocale(sourceLocale)}`, { level: "info" });
38
- } else appLogger(`Auto filled content declaration for '${colorizeKey(fullDictionary.key)}' written to ${formatPath(output.filePath)}`, { level: "info" });
39
- }
40
- };
41
-
42
- //#endregion
43
- export { writeFill };
44
- //# sourceMappingURL=writeAutoFill.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"writeAutoFill.mjs","names":["autoFillData: FillData[]"],"sources":["../../../src/fill/writeAutoFill.ts"],"sourcesContent":["import {\n formatLocale,\n formatPath,\n reduceDictionaryContent,\n writeContentDeclaration,\n} from '@intlayer/chokidar';\nimport { colorizeKey, getAppLogger } from '@intlayer/config';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport type { Dictionary, Fill, IntlayerConfig, Locale } from '@intlayer/types';\nimport { type FillData, formatFillData } from './formatFillData';\n\nexport const writeFill = async (\n contentDeclarationFile: Dictionary,\n outputLocales: Locale[],\n parentLocales: Locale[],\n configuration: IntlayerConfig\n) => {\n const appLogger = getAppLogger(configuration);\n const dictionaries = getDictionaries(configuration);\n\n const fullDictionary = dictionaries[contentDeclarationFile.key];\n\n const filePath = contentDeclarationFile.filePath;\n\n if (!filePath) {\n appLogger('No file path found for dictionary', {\n level: 'error',\n });\n return;\n }\n\n const autoFillOptions = fullDictionary.fill ?? configuration.content.fill;\n\n if (\n typeof autoFillOptions === 'boolean' &&\n (autoFillOptions as boolean) === false\n ) {\n appLogger(\n `Auto fill is disabled for '${colorizeKey(fullDictionary.key)}'`,\n {\n level: 'info',\n }\n );\n return;\n }\n\n const localeList: Locale[] = (\n outputLocales ?? configuration.internationalization.locales\n ).filter((locale) => !parentLocales?.includes(locale));\n\n const autoFillData: FillData[] = formatFillData(\n autoFillOptions as Fill,\n localeList,\n filePath,\n fullDictionary.key,\n configuration\n );\n\n for await (const output of autoFillData) {\n if (!output.filePath) {\n appLogger(\n `No file path found for auto filled content declaration for '${colorizeKey(fullDictionary.key)}'`,\n {\n level: 'error',\n }\n );\n continue;\n }\n\n const reducedDictionaryContent = reduceDictionaryContent(\n fullDictionary,\n contentDeclarationFile\n );\n\n // write file\n await writeContentDeclaration(\n {\n ...fullDictionary,\n fill: undefined,\n filled: true,\n locale: output.isPerLocale ? output.localeList[0] : undefined,\n content: reducedDictionaryContent.content,\n filePath: output.filePath,\n },\n configuration\n );\n\n if (output.isPerLocale) {\n const sourceLocale = output.localeList[0];\n\n appLogger(\n `Auto filled per-locale content declaration for '${colorizeKey(fullDictionary.key)}' written to ${formatPath(output.filePath)} for locale ${formatLocale(sourceLocale)}`,\n {\n level: 'info',\n }\n );\n } else {\n appLogger(\n `Auto filled content declaration for '${colorizeKey(fullDictionary.key)}' written to ${formatPath(output.filePath)}`,\n {\n level: 'info',\n }\n );\n }\n }\n};\n"],"mappings":";;;;;;AAWA,MAAa,YAAY,OACvB,wBACA,eACA,eACA,kBACG;CACH,MAAM,YAAY,aAAa,cAAc;CAG7C,MAAM,iBAFe,gBAAgB,cAAc,CAEf,uBAAuB;CAE3D,MAAM,WAAW,uBAAuB;AAExC,KAAI,CAAC,UAAU;AACb,YAAU,qCAAqC,EAC7C,OAAO,SACR,CAAC;AACF;;CAGF,MAAM,kBAAkB,eAAe,QAAQ,cAAc,QAAQ;AAErE,KACE,OAAO,oBAAoB,aAC1B,oBAAgC,OACjC;AACA,YACE,8BAA8B,YAAY,eAAe,IAAI,CAAC,IAC9D,EACE,OAAO,QACR,CACF;AACD;;CAOF,MAAMA,eAA2B,eAC/B,kBAJA,iBAAiB,cAAc,qBAAqB,SACpD,QAAQ,WAAW,CAAC,eAAe,SAAS,OAAO,CAAC,EAKpD,UACA,eAAe,KACf,cACD;AAED,YAAW,MAAM,UAAU,cAAc;AACvC,MAAI,CAAC,OAAO,UAAU;AACpB,aACE,+DAA+D,YAAY,eAAe,IAAI,CAAC,IAC/F,EACE,OAAO,SACR,CACF;AACD;;EAGF,MAAM,2BAA2B,wBAC/B,gBACA,uBACD;AAGD,QAAM,wBACJ;GACE,GAAG;GACH,MAAM;GACN,QAAQ;GACR,QAAQ,OAAO,cAAc,OAAO,WAAW,KAAK;GACpD,SAAS,yBAAyB;GAClC,UAAU,OAAO;GAClB,EACD,cACD;AAED,MAAI,OAAO,aAAa;GACtB,MAAM,eAAe,OAAO,WAAW;AAEvC,aACE,mDAAmD,YAAY,eAAe,IAAI,CAAC,eAAe,WAAW,OAAO,SAAS,CAAC,cAAc,aAAa,aAAa,IACtK,EACE,OAAO,QACR,CACF;QAED,WACE,wCAAwC,YAAY,eAAe,IAAI,CAAC,eAAe,WAAW,OAAO,SAAS,IAClH,EACE,OAAO,QACR,CACF"}
@@ -1,15 +0,0 @@
1
- //#region src/fill/groupLimiter.d.ts
2
- type GroupLimiter = {
3
- schedule: <T>(fn: () => Promise<T>) => void;
4
- done: () => Promise<void>;
5
- activeCount: () => number;
6
- pendingCount: () => number;
7
- };
8
- /**
9
- * Creates a group limiter that controls concurrency and provides a sync point
10
- * to wait for all scheduled tasks to complete.
11
- */
12
- declare const makeGroupLimiter: (concurrency: number) => GroupLimiter;
13
- //#endregion
14
- export { GroupLimiter, makeGroupLimiter };
15
- //# sourceMappingURL=groupLimiter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"groupLimiter.d.ts","names":[],"sources":["../../../src/fill/groupLimiter.ts"],"sourcesContent":[],"mappings":";KAEY,YAAA;EAAA,QAAA,EAAA,CAAA,CAAA,CAAA,CAAA,EAAY,EAAA,GAAA,GACE,OADF,CACU,CADV,CAAA,EAAA,GAAA,IAAA;EACU,IAAA,EAAA,GAAA,GACpB,OADoB,CAAA,IAAA,CAAA;EAAR,WAAA,EAAA,GAAA,GAAA,MAAA;EACZ,YAAA,EAAA,GAAA,GAAA,MAAA;CAAO;AAiBrB;;;;cAAa,2CAA0C"}
@@ -1 +0,0 @@
1
- export { };