@intlayer/cli 7.5.0-canary.0 → 7.5.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 (81) hide show
  1. package/dist/cjs/IntlayerEventListener.cjs +8 -8
  2. package/dist/cjs/IntlayerEventListener.cjs.map +1 -1
  3. package/dist/cjs/auth/login.cjs +156 -0
  4. package/dist/cjs/auth/login.cjs.map +1 -0
  5. package/dist/cjs/build.cjs +5 -5
  6. package/dist/cjs/build.cjs.map +1 -1
  7. package/dist/cjs/cli.cjs +19 -3
  8. package/dist/cjs/cli.cjs.map +1 -1
  9. package/dist/cjs/config.cjs +3 -3
  10. package/dist/cjs/config.cjs.map +1 -1
  11. package/dist/cjs/editor.cjs +2 -2
  12. package/dist/cjs/editor.cjs.map +1 -1
  13. package/dist/cjs/fill/fill.cjs +12 -12
  14. package/dist/cjs/fill/fill.cjs.map +1 -1
  15. package/dist/cjs/fill/listTranslationsTasks.cjs +15 -15
  16. package/dist/cjs/fill/listTranslationsTasks.cjs.map +1 -1
  17. package/dist/cjs/fill/translateDictionary.cjs +36 -36
  18. package/dist/cjs/fill/translateDictionary.cjs.map +1 -1
  19. package/dist/cjs/fill/writeFill.cjs +11 -11
  20. package/dist/cjs/fill/writeFill.cjs.map +1 -1
  21. package/dist/cjs/getTargetDictionary.cjs +6 -6
  22. package/dist/cjs/getTargetDictionary.cjs.map +1 -1
  23. package/dist/cjs/listContentDeclaration.cjs +9 -9
  24. package/dist/cjs/listContentDeclaration.cjs.map +1 -1
  25. package/dist/cjs/liveSync.cjs +16 -16
  26. package/dist/cjs/liveSync.cjs.map +1 -1
  27. package/dist/cjs/pull.cjs +14 -14
  28. package/dist/cjs/pull.cjs.map +1 -1
  29. package/dist/cjs/push/pullLog.cjs +6 -6
  30. package/dist/cjs/push/pullLog.cjs.map +1 -1
  31. package/dist/cjs/push/push.cjs +23 -23
  32. package/dist/cjs/push/push.cjs.map +1 -1
  33. package/dist/cjs/pushConfig.cjs +5 -5
  34. package/dist/cjs/pushConfig.cjs.map +1 -1
  35. package/dist/cjs/pushLog.cjs +6 -6
  36. package/dist/cjs/pushLog.cjs.map +1 -1
  37. package/dist/cjs/reviewDoc.cjs +13 -13
  38. package/dist/cjs/reviewDoc.cjs.map +1 -1
  39. package/dist/cjs/reviewDocBlockAware.cjs +19 -19
  40. package/dist/cjs/reviewDocBlockAware.cjs.map +1 -1
  41. package/dist/cjs/test/listMissingTranslations.cjs +9 -9
  42. package/dist/cjs/test/listMissingTranslations.cjs.map +1 -1
  43. package/dist/cjs/test/test.cjs +22 -22
  44. package/dist/cjs/test/test.cjs.map +1 -1
  45. package/dist/cjs/transform.cjs +8 -8
  46. package/dist/cjs/transform.cjs.map +1 -1
  47. package/dist/cjs/translateDoc.cjs +29 -29
  48. package/dist/cjs/translateDoc.cjs.map +1 -1
  49. package/dist/cjs/utils/calculateChunks.cjs +4 -4
  50. package/dist/cjs/utils/calculateChunks.cjs.map +1 -1
  51. package/dist/cjs/utils/checkAccess.cjs +13 -13
  52. package/dist/cjs/utils/checkAccess.cjs.map +1 -1
  53. package/dist/cjs/utils/chunkInference.cjs +4 -4
  54. package/dist/cjs/utils/chunkInference.cjs.map +1 -1
  55. package/dist/cjs/utils/mapChunksBetweenFiles.cjs +4 -4
  56. package/dist/cjs/utils/mapChunksBetweenFiles.cjs.map +1 -1
  57. package/dist/cjs/utils/openBrowser.cjs +19 -0
  58. package/dist/cjs/utils/openBrowser.cjs.map +1 -0
  59. package/dist/cjs/utils/setupAI.cjs +5 -5
  60. package/dist/cjs/utils/setupAI.cjs.map +1 -1
  61. package/dist/cjs/watch.cjs +26 -5
  62. package/dist/cjs/watch.cjs.map +1 -1
  63. package/dist/esm/auth/login.mjs +154 -0
  64. package/dist/esm/auth/login.mjs.map +1 -0
  65. package/dist/esm/cli.mjs +16 -0
  66. package/dist/esm/cli.mjs.map +1 -1
  67. package/dist/esm/liveSync.mjs +1 -1
  68. package/dist/esm/translateDoc.mjs +1 -1
  69. package/dist/esm/translateDoc.mjs.map +1 -1
  70. package/dist/esm/utils/openBrowser.mjs +18 -0
  71. package/dist/esm/utils/openBrowser.mjs.map +1 -0
  72. package/dist/esm/watch.mjs +23 -2
  73. package/dist/esm/watch.mjs.map +1 -1
  74. package/dist/types/auth/login.d.ts +11 -0
  75. package/dist/types/auth/login.d.ts.map +1 -0
  76. package/dist/types/cli.d.ts.map +1 -1
  77. package/dist/types/config.d.ts.map +1 -1
  78. package/dist/types/pull.d.ts.map +1 -1
  79. package/dist/types/utils/openBrowser.d.ts +5 -0
  80. package/dist/types/utils/openBrowser.d.ts.map +1 -0
  81. package/package.json +13 -13
@@ -1 +1 @@
1
- {"version":3,"file":"push.cjs","names":["ANSIColors","checkCMSAuth","dictionaries: Dictionary[]","existingDictionariesKeys: string[]","dictionariesStatuses: DictionariesStatus[]","PushLogger","successfullyPushedDictionaries: Dictionary[]","readline","filePathsSet: Set<string>","fsPromises"],"sources":["../../../src/push/push.ts"],"sourcesContent":["import * as fsPromises from 'node:fs/promises';\nimport { join } from 'node:path';\nimport * as readline from 'node:readline';\nimport { getIntlayerAPIProxy } from '@intlayer/api';\nimport {\n formatPath,\n type ListGitFilesOptions,\n listGitFiles,\n parallelize,\n prepareIntlayer,\n writeContentDeclaration,\n} from '@intlayer/chokidar';\nimport {\n ANSIColors,\n type GetConfigurationOptions,\n getAppLogger,\n getConfiguration,\n} from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/types';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\nimport { PushLogger, type PushStatus } from '../pushLog';\nimport { checkCMSAuth } from '../utils/checkAccess';\n\ntype PushOptions = {\n deleteLocaleDictionary?: boolean;\n keepLocaleDictionary?: boolean;\n dictionaries?: string[];\n gitOptions?: ListGitFilesOptions;\n configOptions?: GetConfigurationOptions;\n build?: boolean;\n};\n\ntype DictionariesStatus = {\n dictionary: Dictionary;\n status: 'pending' | 'pushing' | 'modified' | 'pushed' | 'unknown' | 'error';\n error?: Error;\n errorMessage?: string;\n};\n\n// Print per-dictionary summary similar to loadDictionaries\nconst statusIconsAndColors = {\n pushed: { icon: '✔', color: ANSIColors.GREEN },\n modified: { icon: '✔', color: ANSIColors.GREEN },\n error: { icon: '✖', color: ANSIColors.RED },\n default: { icon: '⏲', color: ANSIColors.BLUE },\n};\n\nconst getIconAndColor = (status: DictionariesStatus['status']) => {\n return (\n statusIconsAndColors[status as keyof typeof statusIconsAndColors] ??\n statusIconsAndColors.default\n );\n};\n\n/**\n * Get all local dictionaries and push them simultaneously.\n */\nexport const push = async (options?: PushOptions): Promise<void> => {\n const config = getConfiguration(options?.configOptions);\n const appLogger = getAppLogger(config, {\n config: {\n prefix: '',\n },\n });\n\n if (options?.build === true) {\n await prepareIntlayer(config, { forceRun: true });\n } else if (typeof options?.build === 'undefined') {\n await prepareIntlayer(config);\n }\n\n try {\n const hasCMSAuth = await checkCMSAuth(config);\n\n if (!hasCMSAuth) return;\n\n const intlayerAPI = getIntlayerAPIProxy(undefined, config);\n\n const unmergedDictionariesRecord = getUnmergedDictionaries(config);\n let dictionaries: Dictionary[] = Object.values(\n unmergedDictionariesRecord\n ).flat();\n const existingDictionariesKeys: string[] = Object.keys(\n unmergedDictionariesRecord\n );\n\n if (options?.dictionaries) {\n // Check if the provided dictionaries exist\n const noneExistingDictionariesOption = options.dictionaries.filter(\n (dictionaryId) => !existingDictionariesKeys.includes(dictionaryId)\n );\n\n if (noneExistingDictionariesOption.length > 0) {\n appLogger(\n `The following dictionaries do not exist: ${noneExistingDictionariesOption.join(\n ', '\n )} and have been ignored.`,\n {\n level: 'error',\n }\n );\n }\n\n // Filter the dictionaries from the provided list of IDs\n dictionaries = dictionaries.filter((dictionary) =>\n options.dictionaries?.includes(dictionary.key)\n );\n }\n\n if (options?.gitOptions) {\n const gitFiles = await listGitFiles(options.gitOptions);\n\n dictionaries = dictionaries.filter((dictionary) =>\n gitFiles.includes(\n join(config.content.baseDir, dictionary.filePath ?? '')\n )\n );\n }\n\n // Check if the dictionaries list is empty\n if (dictionaries.length === 0) {\n appLogger('No local dictionaries found', {\n level: 'error',\n });\n return;\n }\n\n appLogger('Pushing dictionaries:');\n\n // Prepare dictionaries statuses\n const dictionariesStatuses: DictionariesStatus[] = dictionaries.map(\n (dictionary) => ({\n dictionary,\n status: 'pending',\n })\n );\n\n // Initialize aggregated logger similar to loadDictionaries\n const logger = new PushLogger();\n logger.update(\n dictionariesStatuses.map<PushStatus>((s) => ({\n dictionaryKey: s.dictionary.key,\n status: 'pending',\n }))\n );\n\n const successfullyPushedDictionaries: Dictionary[] = [];\n\n const processDictionary = async (\n statusObj: DictionariesStatus\n ): Promise<void> => {\n statusObj.status = 'pushing';\n logger.update([\n { dictionaryKey: statusObj.dictionary.key, status: 'pushing' },\n ]);\n\n try {\n const pushResult = await intlayerAPI.dictionary.pushDictionaries([\n statusObj.dictionary,\n ]);\n\n const updatedDictionaries = pushResult.data?.updatedDictionaries ?? [];\n const newDictionaries = pushResult.data?.newDictionaries ?? [];\n\n const allDictionaries = [...updatedDictionaries, ...newDictionaries];\n\n for (const remoteDictionaryData of allDictionaries) {\n const localDictionary = unmergedDictionariesRecord[\n remoteDictionaryData.key\n ]?.find(\n (dictionary) => dictionary.localId === remoteDictionaryData.localId\n );\n\n if (!localDictionary) continue;\n\n await writeContentDeclaration(\n { ...localDictionary, id: remoteDictionaryData.id },\n config\n );\n }\n\n if (\n updatedDictionaries.some(\n (dictionary) => dictionary.key === statusObj.dictionary.key\n )\n ) {\n statusObj.status = 'modified';\n successfullyPushedDictionaries.push(statusObj.dictionary);\n logger.update([\n { dictionaryKey: statusObj.dictionary.key, status: 'modified' },\n ]);\n } else if (\n newDictionaries.some(\n (dictionary) => dictionary.key === statusObj.dictionary.key\n )\n ) {\n statusObj.status = 'pushed';\n successfullyPushedDictionaries.push(statusObj.dictionary);\n logger.update([\n { dictionaryKey: statusObj.dictionary.key, status: 'pushed' },\n ]);\n } else {\n statusObj.status = 'unknown';\n }\n } catch (error) {\n statusObj.status = 'error';\n statusObj.error = error as Error;\n statusObj.errorMessage = `Error pushing dictionary ${statusObj.dictionary.key}: ${error}`;\n logger.update([\n { dictionaryKey: statusObj.dictionary.key, status: 'error' },\n ]);\n }\n };\n\n // Process dictionaries in parallel with a concurrency limit (reuse parallelize)\n await parallelize(dictionariesStatuses, processDictionary, 5);\n\n // Stop the logger and render final state\n logger.finish();\n\n for (const dictionaryStatus of dictionariesStatuses) {\n const { icon, color } = getIconAndColor(dictionaryStatus.status);\n appLogger(\n ` - ${dictionaryStatus.dictionary.key} ${ANSIColors.GREY}[${color}${icon} ${dictionaryStatus.status}${ANSIColors.GREY}]${ANSIColors.RESET}`\n );\n }\n\n // Output any error messages\n for (const statusObj of dictionariesStatuses) {\n if (statusObj.errorMessage) {\n appLogger(statusObj.errorMessage, {\n level: 'error',\n });\n }\n }\n\n // Handle delete or keep options\n const deleteOption = options?.deleteLocaleDictionary;\n const keepOption = options?.keepLocaleDictionary;\n\n if (deleteOption && keepOption) {\n throw new Error(\n 'Cannot specify both --deleteLocaleDictionary and --keepLocaleDictionary options.'\n );\n }\n\n if (deleteOption) {\n // Delete only the successfully pushed dictionaries\n await deleteLocalDictionaries(successfullyPushedDictionaries, options);\n } else if (keepOption) {\n // Do nothing, keep the local dictionaries\n } else {\n // Ask the user\n const answer = await askUser(\n 'Do you want to delete the local dictionaries that were successfully pushed? (yes/no): '\n );\n if (answer.toLowerCase() === 'yes' || answer.toLowerCase() === 'y') {\n await deleteLocalDictionaries(successfullyPushedDictionaries, options);\n }\n }\n } catch (error) {\n appLogger(error, {\n level: 'error',\n });\n }\n};\n\nconst askUser = (question: string): Promise<string> => {\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n return new Promise((resolve) => {\n rl.question(question, (answer: string) => {\n rl.close();\n resolve(answer);\n });\n });\n};\n\nconst deleteLocalDictionaries = async (\n dictionariesToDelete: Dictionary[],\n options?: PushOptions\n): Promise<void> => {\n const config = getConfiguration(options?.configOptions);\n const appLogger = getAppLogger(config, {\n config: {\n prefix: '',\n },\n });\n\n // Use a Set to collect all unique file paths\n const filePathsSet: Set<string> = new Set();\n\n for (const dictionary of dictionariesToDelete) {\n const { filePath } = dictionary;\n\n if (!filePath) {\n appLogger(`Dictionary ${dictionary.key} does not have a file path`, {\n level: 'error',\n });\n continue;\n }\n\n filePathsSet.add(filePath);\n }\n\n for (const filePath of filePathsSet) {\n try {\n const stats = await fsPromises.lstat(filePath);\n\n if (stats.isFile()) {\n await fsPromises.unlink(filePath);\n appLogger(`Deleted file ${formatPath(filePath)}`, {});\n } else if (stats.isDirectory()) {\n appLogger(`Path is a directory ${formatPath(filePath)}, skipping.`, {});\n } else {\n appLogger(\n `Unknown file type for ${formatPath(filePath)}, skipping.`,\n {}\n );\n }\n } catch (err) {\n appLogger(`Error deleting ${formatPath(filePath)}: ${err}`, {\n level: 'error',\n });\n }\n }\n};\n"],"mappings":";;;;;;;;;;;;;;AAwCA,MAAM,uBAAuB;CAC3B,QAAQ;EAAE,MAAM;EAAK,OAAOA,6BAAW;EAAO;CAC9C,UAAU;EAAE,MAAM;EAAK,OAAOA,6BAAW;EAAO;CAChD,OAAO;EAAE,MAAM;EAAK,OAAOA,6BAAW;EAAK;CAC3C,SAAS;EAAE,MAAM;EAAK,OAAOA,6BAAW;EAAM;CAC/C;AAED,MAAM,mBAAmB,WAAyC;AAChE,QACE,qBAAqB,WACrB,qBAAqB;;;;;AAOzB,MAAa,OAAO,OAAO,YAAyC;CAClE,MAAM,iDAA0B,SAAS,cAAc;CACvD,MAAM,gDAAyB,QAAQ,EACrC,QAAQ,EACN,QAAQ,IACT,EACF,CAAC;AAEF,KAAI,SAAS,UAAU,KACrB,gDAAsB,QAAQ,EAAE,UAAU,MAAM,CAAC;UACxC,OAAO,SAAS,UAAU,YACnC,gDAAsB,OAAO;AAG/B,KAAI;AAGF,MAAI,CAFe,MAAMC,uCAAa,OAAO,CAE5B;EAEjB,MAAM,sDAAkC,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,CAAC"}
1
+ {"version":3,"file":"push.cjs","names":["ANSIColors","checkCMSAuth","dictionaries: Dictionary[]","existingDictionariesKeys: string[]","dictionariesStatuses: DictionariesStatus[]","PushLogger","successfullyPushedDictionaries: Dictionary[]","readline","filePathsSet: Set<string>","fsPromises"],"sources":["../../../src/push/push.ts"],"sourcesContent":["import * as fsPromises from 'node:fs/promises';\nimport { join } from 'node:path';\nimport * as readline from 'node:readline';\nimport { getIntlayerAPIProxy } from '@intlayer/api';\nimport {\n formatPath,\n type ListGitFilesOptions,\n listGitFiles,\n parallelize,\n prepareIntlayer,\n writeContentDeclaration,\n} from '@intlayer/chokidar';\nimport {\n ANSIColors,\n type GetConfigurationOptions,\n getAppLogger,\n getConfiguration,\n} from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/types';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\nimport { PushLogger, type PushStatus } from '../pushLog';\nimport { checkCMSAuth } from '../utils/checkAccess';\n\ntype PushOptions = {\n deleteLocaleDictionary?: boolean;\n keepLocaleDictionary?: boolean;\n dictionaries?: string[];\n gitOptions?: ListGitFilesOptions;\n configOptions?: GetConfigurationOptions;\n build?: boolean;\n};\n\ntype DictionariesStatus = {\n dictionary: Dictionary;\n status: 'pending' | 'pushing' | 'modified' | 'pushed' | 'unknown' | 'error';\n error?: Error;\n errorMessage?: string;\n};\n\n// Print per-dictionary summary similar to loadDictionaries\nconst statusIconsAndColors = {\n pushed: { icon: '✔', color: ANSIColors.GREEN },\n modified: { icon: '✔', color: ANSIColors.GREEN },\n error: { icon: '✖', color: ANSIColors.RED },\n default: { icon: '⏲', color: ANSIColors.BLUE },\n};\n\nconst getIconAndColor = (status: DictionariesStatus['status']) => {\n return (\n statusIconsAndColors[status as keyof typeof statusIconsAndColors] ??\n statusIconsAndColors.default\n );\n};\n\n/**\n * Get all local dictionaries and push them simultaneously.\n */\nexport const push = async (options?: PushOptions): Promise<void> => {\n const config = getConfiguration(options?.configOptions);\n const appLogger = getAppLogger(config, {\n config: {\n prefix: '',\n },\n });\n\n if (options?.build === true) {\n await prepareIntlayer(config, { forceRun: true });\n } else if (typeof options?.build === 'undefined') {\n await prepareIntlayer(config);\n }\n\n try {\n const hasCMSAuth = await checkCMSAuth(config);\n\n if (!hasCMSAuth) return;\n\n const intlayerAPI = getIntlayerAPIProxy(undefined, config);\n\n const unmergedDictionariesRecord = getUnmergedDictionaries(config);\n let dictionaries: Dictionary[] = Object.values(\n unmergedDictionariesRecord\n ).flat();\n const existingDictionariesKeys: string[] = Object.keys(\n unmergedDictionariesRecord\n );\n\n if (options?.dictionaries) {\n // Check if the provided dictionaries exist\n const noneExistingDictionariesOption = options.dictionaries.filter(\n (dictionaryId) => !existingDictionariesKeys.includes(dictionaryId)\n );\n\n if (noneExistingDictionariesOption.length > 0) {\n appLogger(\n `The following dictionaries do not exist: ${noneExistingDictionariesOption.join(\n ', '\n )} and have been ignored.`,\n {\n level: 'error',\n }\n );\n }\n\n // Filter the dictionaries from the provided list of IDs\n dictionaries = dictionaries.filter((dictionary) =>\n options.dictionaries?.includes(dictionary.key)\n );\n }\n\n if (options?.gitOptions) {\n const gitFiles = await listGitFiles(options.gitOptions);\n\n dictionaries = dictionaries.filter((dictionary) =>\n gitFiles.includes(\n join(config.content.baseDir, dictionary.filePath ?? '')\n )\n );\n }\n\n // Check if the dictionaries list is empty\n if (dictionaries.length === 0) {\n appLogger('No local dictionaries found', {\n level: 'error',\n });\n return;\n }\n\n appLogger('Pushing dictionaries:');\n\n // Prepare dictionaries statuses\n const dictionariesStatuses: DictionariesStatus[] = dictionaries.map(\n (dictionary) => ({\n dictionary,\n status: 'pending',\n })\n );\n\n // Initialize aggregated logger similar to loadDictionaries\n const logger = new PushLogger();\n logger.update(\n dictionariesStatuses.map<PushStatus>((s) => ({\n dictionaryKey: s.dictionary.key,\n status: 'pending',\n }))\n );\n\n const successfullyPushedDictionaries: Dictionary[] = [];\n\n const processDictionary = async (\n statusObj: DictionariesStatus\n ): Promise<void> => {\n statusObj.status = 'pushing';\n logger.update([\n { dictionaryKey: statusObj.dictionary.key, status: 'pushing' },\n ]);\n\n try {\n const pushResult = await intlayerAPI.dictionary.pushDictionaries([\n statusObj.dictionary,\n ]);\n\n const updatedDictionaries = pushResult.data?.updatedDictionaries ?? [];\n const newDictionaries = pushResult.data?.newDictionaries ?? [];\n\n const allDictionaries = [...updatedDictionaries, ...newDictionaries];\n\n for (const remoteDictionaryData of allDictionaries) {\n const localDictionary = unmergedDictionariesRecord[\n remoteDictionaryData.key\n ]?.find(\n (dictionary) => dictionary.localId === remoteDictionaryData.localId\n );\n\n if (!localDictionary) continue;\n\n await writeContentDeclaration(\n { ...localDictionary, id: remoteDictionaryData.id },\n config\n );\n }\n\n if (\n updatedDictionaries.some(\n (dictionary) => dictionary.key === statusObj.dictionary.key\n )\n ) {\n statusObj.status = 'modified';\n successfullyPushedDictionaries.push(statusObj.dictionary);\n logger.update([\n { dictionaryKey: statusObj.dictionary.key, status: 'modified' },\n ]);\n } else if (\n newDictionaries.some(\n (dictionary) => dictionary.key === statusObj.dictionary.key\n )\n ) {\n statusObj.status = 'pushed';\n successfullyPushedDictionaries.push(statusObj.dictionary);\n logger.update([\n { dictionaryKey: statusObj.dictionary.key, status: 'pushed' },\n ]);\n } else {\n statusObj.status = 'unknown';\n }\n } catch (error) {\n statusObj.status = 'error';\n statusObj.error = error as Error;\n statusObj.errorMessage = `Error pushing dictionary ${statusObj.dictionary.key}: ${error}`;\n logger.update([\n { dictionaryKey: statusObj.dictionary.key, status: 'error' },\n ]);\n }\n };\n\n // Process dictionaries in parallel with a concurrency limit (reuse parallelize)\n await parallelize(dictionariesStatuses, processDictionary, 5);\n\n // Stop the logger and render final state\n logger.finish();\n\n for (const dictionaryStatus of dictionariesStatuses) {\n const { icon, color } = getIconAndColor(dictionaryStatus.status);\n appLogger(\n ` - ${dictionaryStatus.dictionary.key} ${ANSIColors.GREY}[${color}${icon} ${dictionaryStatus.status}${ANSIColors.GREY}]${ANSIColors.RESET}`\n );\n }\n\n // Output any error messages\n for (const statusObj of dictionariesStatuses) {\n if (statusObj.errorMessage) {\n appLogger(statusObj.errorMessage, {\n level: 'error',\n });\n }\n }\n\n // Handle delete or keep options\n const deleteOption = options?.deleteLocaleDictionary;\n const keepOption = options?.keepLocaleDictionary;\n\n if (deleteOption && keepOption) {\n throw new Error(\n 'Cannot specify both --deleteLocaleDictionary and --keepLocaleDictionary options.'\n );\n }\n\n if (deleteOption) {\n // Delete only the successfully pushed dictionaries\n await deleteLocalDictionaries(successfullyPushedDictionaries, options);\n } else if (keepOption) {\n // Do nothing, keep the local dictionaries\n } else {\n // Ask the user\n const answer = await askUser(\n 'Do you want to delete the local dictionaries that were successfully pushed? (yes/no): '\n );\n if (answer.toLowerCase() === 'yes' || answer.toLowerCase() === 'y') {\n await deleteLocalDictionaries(successfullyPushedDictionaries, options);\n }\n }\n } catch (error) {\n appLogger(error, {\n level: 'error',\n });\n }\n};\n\nconst askUser = (question: string): Promise<string> => {\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n return new Promise((resolve) => {\n rl.question(question, (answer: string) => {\n rl.close();\n resolve(answer);\n });\n });\n};\n\nconst deleteLocalDictionaries = async (\n dictionariesToDelete: Dictionary[],\n options?: PushOptions\n): Promise<void> => {\n const config = getConfiguration(options?.configOptions);\n const appLogger = getAppLogger(config, {\n config: {\n prefix: '',\n },\n });\n\n // Use a Set to collect all unique file paths\n const filePathsSet: Set<string> = new Set();\n\n for (const dictionary of dictionariesToDelete) {\n const { filePath } = dictionary;\n\n if (!filePath) {\n appLogger(`Dictionary ${dictionary.key} does not have a file path`, {\n level: 'error',\n });\n continue;\n }\n\n filePathsSet.add(filePath);\n }\n\n for (const filePath of filePathsSet) {\n try {\n const stats = await fsPromises.lstat(filePath);\n\n if (stats.isFile()) {\n await fsPromises.unlink(filePath);\n appLogger(`Deleted file ${formatPath(filePath)}`, {});\n } else if (stats.isDirectory()) {\n appLogger(`Path is a directory ${formatPath(filePath)}, skipping.`, {});\n } else {\n appLogger(\n `Unknown file type for ${formatPath(filePath)}, skipping.`,\n {}\n );\n }\n } catch (err) {\n appLogger(`Error deleting ${formatPath(filePath)}: ${err}`, {\n level: 'error',\n });\n }\n }\n};\n"],"mappings":";;;;;;;;;;;;;;AAwCA,MAAM,uBAAuB;CAC3B,QAAQ;EAAE,MAAM;EAAK,OAAOA,4BAAW;EAAO;CAC9C,UAAU;EAAE,MAAM;EAAK,OAAOA,4BAAW;EAAO;CAChD,OAAO;EAAE,MAAM;EAAK,OAAOA,4BAAW;EAAK;CAC3C,SAAS;EAAE,MAAM;EAAK,OAAOA,4BAAW;EAAM;CAC/C;AAED,MAAM,mBAAmB,WAAyC;AAChE,QACE,qBAAqB,WACrB,qBAAqB;;;;;AAOzB,MAAa,OAAO,OAAO,YAAyC;CAClE,MAAM,gDAA0B,SAAS,cAAc;CACvD,MAAM,+CAAyB,QAAQ,EACrC,QAAQ,EACN,QAAQ,IACT,EACF,CAAC;AAEF,KAAI,SAAS,UAAU,KACrB,+CAAsB,QAAQ,EAAE,UAAU,MAAM,CAAC;UACxC,OAAO,SAAS,UAAU,YACnC,+CAAsB,OAAO;AAG/B,KAAI;AAGF,MAAI,CAFe,MAAMC,uCAAa,OAAO,CAE5B;EAEjB,MAAM,qDAAkC,QAAW,OAAO;EAE1D,MAAM,gGAAqD,OAAO;EAClE,IAAIC,eAA6B,OAAO,OACtC,2BACD,CAAC,MAAM;EACR,MAAMC,2BAAqC,OAAO,KAChD,2BACD;AAED,MAAI,SAAS,cAAc;GAEzB,MAAM,iCAAiC,QAAQ,aAAa,QACzD,iBAAiB,CAAC,yBAAyB,SAAS,aAAa,CACnE;AAED,OAAI,+BAA+B,SAAS,EAC1C,WACE,4CAA4C,+BAA+B,KACzE,KACD,CAAC,0BACF,EACE,OAAO,SACR,CACF;AAIH,kBAAe,aAAa,QAAQ,eAClC,QAAQ,cAAc,SAAS,WAAW,IAAI,CAC/C;;AAGH,MAAI,S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AO,IAAI,SAAS,YAAY;AAC9B,KAAG,SAAS,WAAW,WAAmB;AACxC,MAAG,OAAO;AACV,WAAQ,OAAO;IACf;GACF;;AAGJ,MAAM,0BAA0B,OAC9B,sBACA,YACkB;CAElB,MAAM,sFAD0B,SAAS,cAAc,EAChB,EACrC,QAAQ,EACN,QAAQ,IACT,EACF,CAAC;CAGF,MAAMC,+BAA4B,IAAI,KAAK;AAE3C,MAAK,MAAM,cAAc,sBAAsB;EAC7C,MAAM,EAAE,aAAa;AAErB,MAAI,CAAC,UAAU;AACb,aAAU,cAAc,WAAW,IAAI,6BAA6B,EAClE,OAAO,SACR,CAAC;AACF;;AAGF,eAAa,IAAI,SAAS;;AAG5B,MAAK,MAAM,YAAY,aACrB,KAAI;EACF,MAAM,QAAQ,MAAMC,iBAAW,MAAM,SAAS;AAE9C,MAAI,MAAM,QAAQ,EAAE;AAClB,SAAMA,iBAAW,OAAO,SAAS;AACjC,aAAU,mDAA2B,SAAS,IAAI,EAAE,CAAC;aAC5C,MAAM,aAAa,CAC5B,WAAU,0DAAkC,SAAS,CAAC,cAAc,EAAE,CAAC;MAEvE,WACE,4DAAoC,SAAS,CAAC,cAC9C,EAAE,CACH;UAEI,KAAK;AACZ,YAAU,qDAA6B,SAAS,CAAC,IAAI,OAAO,EAC1D,OAAO,SACR,CAAC"}
@@ -1,14 +1,14 @@
1
1
  const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
2
  const require_utils_checkAccess = require('./utils/checkAccess.cjs');
3
- let __intlayer_api = require("@intlayer/api");
4
- let __intlayer_config = require("@intlayer/config");
3
+ let _intlayer_api = require("@intlayer/api");
4
+ let _intlayer_config = require("@intlayer/config");
5
5
 
6
6
  //#region src/pushConfig.ts
7
7
  const pushConfig = async (options) => {
8
- const config = (0, __intlayer_config.getConfiguration)(options?.configOptions);
9
- const appLogger = (0, __intlayer_config.getAppLogger)(config, { config: { prefix: "" } });
8
+ const config = (0, _intlayer_config.getConfiguration)(options?.configOptions);
9
+ const appLogger = (0, _intlayer_config.getAppLogger)(config, { config: { prefix: "" } });
10
10
  if (!await require_utils_checkAccess.checkCMSAuth(config)) return;
11
- const getDictionariesKeysResult = await (0, __intlayer_api.getIntlayerAPIProxy)(void 0, config).project.pushProjectConfiguration(config);
11
+ const getDictionariesKeysResult = await (0, _intlayer_api.getIntlayerAPIProxy)(void 0, config).project.pushProjectConfiguration(config);
12
12
  if (!getDictionariesKeysResult.data) throw new Error("Error pushing project configuration");
13
13
  appLogger("Project configuration pushed successfully");
14
14
  appLogger(JSON.stringify(getDictionariesKeysResult.data, null, 2));
@@ -1 +1 @@
1
- {"version":3,"file":"pushConfig.cjs","names":["checkCMSAuth"],"sources":["../../src/pushConfig.ts"],"sourcesContent":["import { getIntlayerAPIProxy } from '@intlayer/api';\nimport {\n type GetConfigurationOptions,\n getAppLogger,\n getConfiguration,\n} from '@intlayer/config';\nimport { checkCMSAuth } from './utils/checkAccess';\n\ntype PushOptions = {\n configOptions?: GetConfigurationOptions;\n};\n\nexport const pushConfig = async (options?: PushOptions) => {\n const config = getConfiguration(options?.configOptions);\n const appLogger = getAppLogger(config, {\n config: {\n prefix: '',\n },\n });\n\n const hasCMSAuth = await checkCMSAuth(config);\n\n if (!hasCMSAuth) return;\n\n const intlayerAPI = getIntlayerAPIProxy(undefined, config);\n\n // Push the project configuration\n const getDictionariesKeysResult =\n await intlayerAPI.project.pushProjectConfiguration(config);\n\n if (!getDictionariesKeysResult.data) {\n throw new Error('Error pushing project configuration');\n }\n\n appLogger('Project configuration pushed successfully');\n\n appLogger(JSON.stringify(getDictionariesKeysResult.data, null, 2));\n};\n"],"mappings":";;;;;;AAYA,MAAa,aAAa,OAAO,YAA0B;CACzD,MAAM,iDAA0B,SAAS,cAAc;CACvD,MAAM,gDAAyB,QAAQ,EACrC,QAAQ,EACN,QAAQ,IACT,EACF,CAAC;AAIF,KAAI,CAFe,MAAMA,uCAAa,OAAO,CAE5B;CAKjB,MAAM,4BACJ,8CAJsC,QAAW,OAAO,CAItC,QAAQ,yBAAyB,OAAO;AAE5D,KAAI,CAAC,0BAA0B,KAC7B,OAAM,IAAI,MAAM,sCAAsC;AAGxD,WAAU,4CAA4C;AAEtD,WAAU,KAAK,UAAU,0BAA0B,MAAM,MAAM,EAAE,CAAC"}
1
+ {"version":3,"file":"pushConfig.cjs","names":["checkCMSAuth"],"sources":["../../src/pushConfig.ts"],"sourcesContent":["import { getIntlayerAPIProxy } from '@intlayer/api';\nimport {\n type GetConfigurationOptions,\n getAppLogger,\n getConfiguration,\n} from '@intlayer/config';\nimport { checkCMSAuth } from './utils/checkAccess';\n\ntype PushOptions = {\n configOptions?: GetConfigurationOptions;\n};\n\nexport const pushConfig = async (options?: PushOptions) => {\n const config = getConfiguration(options?.configOptions);\n const appLogger = getAppLogger(config, {\n config: {\n prefix: '',\n },\n });\n\n const hasCMSAuth = await checkCMSAuth(config);\n\n if (!hasCMSAuth) return;\n\n const intlayerAPI = getIntlayerAPIProxy(undefined, config);\n\n // Push the project configuration\n const getDictionariesKeysResult =\n await intlayerAPI.project.pushProjectConfiguration(config);\n\n if (!getDictionariesKeysResult.data) {\n throw new Error('Error pushing project configuration');\n }\n\n appLogger('Project configuration pushed successfully');\n\n appLogger(JSON.stringify(getDictionariesKeysResult.data, null, 2));\n};\n"],"mappings":";;;;;;AAYA,MAAa,aAAa,OAAO,YAA0B;CACzD,MAAM,gDAA0B,SAAS,cAAc;CACvD,MAAM,+CAAyB,QAAQ,EACrC,QAAQ,EACN,QAAQ,IACT,EACF,CAAC;AAIF,KAAI,CAFe,MAAMA,uCAAa,OAAO,CAE5B;CAKjB,MAAM,4BACJ,6CAJsC,QAAW,OAAO,CAItC,QAAQ,yBAAyB,OAAO;AAE5D,KAAI,CAAC,0BAA0B,KAC7B,OAAM,IAAI,MAAM,sCAAsC;AAGxD,WAAU,4CAA4C;AAEtD,WAAU,KAAK,UAAU,0BAA0B,MAAM,MAAM,EAAE,CAAC"}
@@ -1,5 +1,5 @@
1
1
  const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
- let __intlayer_config = require("@intlayer/config");
2
+ let _intlayer_config = require("@intlayer/config");
3
3
 
4
4
  //#region src/pushLog.ts
5
5
  var PushLogger = class {
@@ -7,12 +7,12 @@ var PushLogger = class {
7
7
  spinnerTimer = null;
8
8
  spinnerIndex = 0;
9
9
  renderedLines = 0;
10
- spinnerFrames = __intlayer_config.spinnerFrames;
10
+ spinnerFrames = _intlayer_config.spinnerFrames;
11
11
  isFinished = false;
12
12
  prefix;
13
13
  lastRenderedState = "";
14
14
  constructor() {
15
- this.prefix = (0, __intlayer_config.getConfiguration)().log.prefix;
15
+ this.prefix = (0, _intlayer_config.getConfiguration)().log.prefix;
16
16
  }
17
17
  update(newStatuses) {
18
18
  if (this.isFinished) return;
@@ -50,10 +50,10 @@ var PushLogger = class {
50
50
  const details = [];
51
51
  if (pushed > 0) details.push(`new: ${pushed}`);
52
52
  if (modified > 0) details.push(`modified: ${modified}`);
53
- if (errors > 0) details.push((0, __intlayer_config.colorize)(`errors: ${errors}`, __intlayer_config.ANSIColors.RED));
53
+ if (errors > 0) details.push((0, _intlayer_config.colorize)(`errors: ${errors}`, _intlayer_config.ANSIColors.RED));
54
54
  const suffix = details.length > 0 ? ` (${details.join(", ")})` : "";
55
- if (isDone) lines.push(`${this.prefix} ${(0, __intlayer_config.colorize)("✔", __intlayer_config.ANSIColors.GREEN)} pushed ${progressLabel}${suffix}`);
56
- else lines.push(`${this.prefix} ${(0, __intlayer_config.colorize)(frame, __intlayer_config.ANSIColors.BLUE)} pushing ${progressLabel}${suffix}`);
55
+ if (isDone) lines.push(`${this.prefix} ${(0, _intlayer_config.colorize)("✔", _intlayer_config.ANSIColors.GREEN)} pushed ${progressLabel}${suffix}`);
56
+ else lines.push(`${this.prefix} ${(0, _intlayer_config.colorize)(frame, _intlayer_config.ANSIColors.BLUE)} pushing ${progressLabel}${suffix}`);
57
57
  const currentState = lines.join("\n");
58
58
  if (currentState === this.lastRenderedState) return;
59
59
  this.lastRenderedState = currentState;
@@ -1 +1 @@
1
- {"version":3,"file":"pushLog.cjs","names":["spinnerFrames","lines: string[]","details: string[]","ANSIColors"],"sources":["../../src/pushLog.ts"],"sourcesContent":["import {\n ANSIColors,\n colorize,\n getConfiguration,\n spinnerFrames,\n} from '@intlayer/config';\n\nexport type PushStatus = {\n dictionaryKey: string;\n status: 'pending' | 'pushing' | 'pushed' | 'modified' | 'error';\n errorMessage?: string;\n};\n\nexport class PushLogger {\n private statuses: PushStatus[] = [];\n private spinnerTimer: NodeJS.Timeout | null = null;\n private spinnerIndex = 0;\n private renderedLines = 0;\n private readonly spinnerFrames = spinnerFrames;\n private isFinished = false;\n private readonly prefix: string;\n private lastRenderedState: string = '';\n\n constructor() {\n const configuration = getConfiguration();\n this.prefix = configuration.log.prefix;\n }\n\n update(newStatuses: PushStatus[]) {\n if (this.isFinished) return;\n for (const status of newStatuses) {\n const index = this.statuses.findIndex(\n (s) => s.dictionaryKey === status.dictionaryKey\n );\n if (index >= 0) {\n this.statuses[index] = status;\n } else {\n this.statuses.push(status);\n }\n }\n\n this.startSpinner();\n this.render();\n }\n\n finish() {\n this.isFinished = true;\n this.stopSpinner();\n this.render();\n }\n\n private startSpinner() {\n if (this.spinnerTimer || this.isFinished) return;\n this.spinnerTimer = setInterval(() => {\n this.spinnerIndex = (this.spinnerIndex + 1) % this.spinnerFrames.length;\n this.render();\n }, 100);\n }\n\n private stopSpinner() {\n if (!this.spinnerTimer) return;\n clearInterval(this.spinnerTimer);\n this.spinnerTimer = null;\n }\n\n private render() {\n const { total, done, pushed, modified, errors } = this.computeProgress();\n\n const frame = this.spinnerFrames[this.spinnerIndex];\n const lines: string[] = [];\n\n const isDone = done === total;\n\n const progressLabel = `dictionaries: ${done}/${total}`;\n const details: string[] = [];\n if (pushed > 0) details.push(`new: ${pushed}`);\n if (modified > 0) details.push(`modified: ${modified}`);\n if (errors > 0) details.push(colorize(`errors: ${errors}`, ANSIColors.RED));\n\n const suffix = details.length > 0 ? ` (${details.join(', ')})` : '';\n\n if (isDone) {\n lines.push(\n `${this.prefix} ${colorize('✔', ANSIColors.GREEN)} pushed ${progressLabel}${suffix}`\n );\n } else {\n lines.push(\n `${this.prefix} ${colorize(frame, ANSIColors.BLUE)} pushing ${progressLabel}${suffix}`\n );\n }\n\n const currentState = lines.join('\\n');\n if (currentState === this.lastRenderedState) {\n return;\n }\n this.lastRenderedState = currentState;\n\n if (this.renderedLines > 0) {\n process.stdout.write(`\\x1b[${this.renderedLines}F`);\n }\n\n const totalLinesToClear = Math.max(this.renderedLines, lines.length);\n for (let i = 0; i < totalLinesToClear; i++) {\n process.stdout.write('\\x1b[2K');\n const line = lines[i];\n if (line !== undefined) {\n process.stdout.write(line);\n }\n process.stdout.write('\\n');\n }\n\n this.renderedLines = lines.length;\n }\n\n private computeProgress() {\n const keys = new Set(this.statuses.map((s) => s.dictionaryKey));\n\n const pushed = this.statuses.filter((s) => s.status === 'pushed').length;\n const modified = this.statuses.filter(\n (s) => s.status === 'modified'\n ).length;\n const errors = this.statuses.filter((s) => s.status === 'error').length;\n const done = pushed + modified + errors;\n\n return {\n total: keys.size,\n done,\n pushed,\n modified,\n errors,\n } as const;\n }\n}\n"],"mappings":";;;;AAaA,IAAa,aAAb,MAAwB;CACtB,AAAQ,WAAyB,EAAE;CACnC,AAAQ,eAAsC;CAC9C,AAAQ,eAAe;CACvB,AAAQ,gBAAgB;CACxB,AAAiB,gBAAgBA;CACjC,AAAQ,aAAa;CACrB,AAAiB;CACjB,AAAQ,oBAA4B;CAEpC,cAAc;AAEZ,OAAK,kDADmC,CACZ,IAAI;;CAGlC,OAAO,aAA2B;AAChC,MAAI,KAAK,WAAY;AACrB,OAAK,MAAM,UAAU,aAAa;GAChC,MAAM,QAAQ,KAAK,SAAS,WACzB,MAAM,EAAE,kBAAkB,OAAO,cACnC;AACD,OAAI,SAAS,EACX,MAAK,SAAS,SAAS;OAEvB,MAAK,SAAS,KAAK,OAAO;;AAI9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AAoB,KAAK,IAAI,KAAK,eAAe,MAAM,OAAO;AACpE,OAAK,IAAI,IAAI,GAAG,IAAI,mBAAmB,KAAK;AAC1C,WAAQ,OAAO,MAAM,UAAU;GAC/B,MAAM,OAAO,MAAM;AACnB,OAAI,SAAS,OACX,SAAQ,OAAO,MAAM,KAAK;AAE5B,WAAQ,OAAO,MAAM,KAAK;;AAG5B,OAAK,gBAAgB,MAAM;;CAG7B,AAAQ,kBAAkB;EACxB,MAAM,OAAO,IAAI,IAAI,KAAK,SAAS,KAAK,MAAM,EAAE,cAAc,CAAC;EAE/D,MAAM,SAAS,KAAK,SAAS,QAAQ,MAAM,EAAE,WAAW,SAAS,CAAC;EAClE,MAAM,WAAW,KAAK,SAAS,QAC5B,MAAM,EAAE,WAAW,WACrB,CAAC;EACF,MAAM,SAAS,KAAK,SAAS,QAAQ,MAAM,EAAE,WAAW,QAAQ,CAAC;EACjE,MAAM,OAAO,SAAS,WAAW;AAEjC,SAAO;GACL,OAAO,KAAK;GACZ;GACA;GACA;GACA;GACD"}
1
+ {"version":3,"file":"pushLog.cjs","names":["spinnerFrames","lines: string[]","details: string[]","ANSIColors"],"sources":["../../src/pushLog.ts"],"sourcesContent":["import {\n ANSIColors,\n colorize,\n getConfiguration,\n spinnerFrames,\n} from '@intlayer/config';\n\nexport type PushStatus = {\n dictionaryKey: string;\n status: 'pending' | 'pushing' | 'pushed' | 'modified' | 'error';\n errorMessage?: string;\n};\n\nexport class PushLogger {\n private statuses: PushStatus[] = [];\n private spinnerTimer: NodeJS.Timeout | null = null;\n private spinnerIndex = 0;\n private renderedLines = 0;\n private readonly spinnerFrames = spinnerFrames;\n private isFinished = false;\n private readonly prefix: string;\n private lastRenderedState: string = '';\n\n constructor() {\n const configuration = getConfiguration();\n this.prefix = configuration.log.prefix;\n }\n\n update(newStatuses: PushStatus[]) {\n if (this.isFinished) return;\n for (const status of newStatuses) {\n const index = this.statuses.findIndex(\n (s) => s.dictionaryKey === status.dictionaryKey\n );\n if (index >= 0) {\n this.statuses[index] = status;\n } else {\n this.statuses.push(status);\n }\n }\n\n this.startSpinner();\n this.render();\n }\n\n finish() {\n this.isFinished = true;\n this.stopSpinner();\n this.render();\n }\n\n private startSpinner() {\n if (this.spinnerTimer || this.isFinished) return;\n this.spinnerTimer = setInterval(() => {\n this.spinnerIndex = (this.spinnerIndex + 1) % this.spinnerFrames.length;\n this.render();\n }, 100);\n }\n\n private stopSpinner() {\n if (!this.spinnerTimer) return;\n clearInterval(this.spinnerTimer);\n this.spinnerTimer = null;\n }\n\n private render() {\n const { total, done, pushed, modified, errors } = this.computeProgress();\n\n const frame = this.spinnerFrames[this.spinnerIndex];\n const lines: string[] = [];\n\n const isDone = done === total;\n\n const progressLabel = `dictionaries: ${done}/${total}`;\n const details: string[] = [];\n if (pushed > 0) details.push(`new: ${pushed}`);\n if (modified > 0) details.push(`modified: ${modified}`);\n if (errors > 0) details.push(colorize(`errors: ${errors}`, ANSIColors.RED));\n\n const suffix = details.length > 0 ? ` (${details.join(', ')})` : '';\n\n if (isDone) {\n lines.push(\n `${this.prefix} ${colorize('✔', ANSIColors.GREEN)} pushed ${progressLabel}${suffix}`\n );\n } else {\n lines.push(\n `${this.prefix} ${colorize(frame, ANSIColors.BLUE)} pushing ${progressLabel}${suffix}`\n );\n }\n\n const currentState = lines.join('\\n');\n if (currentState === this.lastRenderedState) {\n return;\n }\n this.lastRenderedState = currentState;\n\n if (this.renderedLines > 0) {\n process.stdout.write(`\\x1b[${this.renderedLines}F`);\n }\n\n const totalLinesToClear = Math.max(this.renderedLines, lines.length);\n for (let i = 0; i < totalLinesToClear; i++) {\n process.stdout.write('\\x1b[2K');\n const line = lines[i];\n if (line !== undefined) {\n process.stdout.write(line);\n }\n process.stdout.write('\\n');\n }\n\n this.renderedLines = lines.length;\n }\n\n private computeProgress() {\n const keys = new Set(this.statuses.map((s) => s.dictionaryKey));\n\n const pushed = this.statuses.filter((s) => s.status === 'pushed').length;\n const modified = this.statuses.filter(\n (s) => s.status === 'modified'\n ).length;\n const errors = this.statuses.filter((s) => s.status === 'error').length;\n const done = pushed + modified + errors;\n\n return {\n total: keys.size,\n done,\n pushed,\n modified,\n errors,\n } as const;\n }\n}\n"],"mappings":";;;;AAaA,IAAa,aAAb,MAAwB;CACtB,AAAQ,WAAyB,EAAE;CACnC,AAAQ,eAAsC;CAC9C,AAAQ,eAAe;CACvB,AAAQ,gBAAgB;CACxB,AAAiB,gBAAgBA;CACjC,AAAQ,aAAa;CACrB,AAAiB;CACjB,AAAQ,oBAA4B;CAEpC,cAAc;AAEZ,OAAK,iDADmC,CACZ,IAAI;;CAGlC,OAAO,aAA2B;AAChC,MAAI,KAAK,WAAY;AACrB,OAAK,MAAM,UAAU,aAAa;GAChC,MAAM,QAAQ,KAAK,SAAS,WACzB,MAAM,EAAE,kBAAkB,OAAO,cACnC;AACD,OAAI,SAAS,EACX,MAAK,SAAS,SAAS;OAEvB,MAAK,SAAS,KAAK,OAAO;;AAI9B,OAAK,cAAc;AACnB,OAAK,QAAQ;;CAGf,SAAS;AACP,OAAK,aAAa;AAClB,OAAK,aAAa;AAClB,OAAK,QAAQ;;CAGf,AAAQ,eAAe;AACrB,MAAI,KAAK,gBAAgB,KAAK,WAAY;AAC1C,OAAK,eAAe,kBAAkB;AACpC,QAAK,gBAAgB,KAAK,eAAe,KAAK,KAAK,cAAc;AACjE,QAAK,QAAQ;KACZ,IAAI;;CAGT,AAAQ,cAAc;AACpB,MAAI,CAAC,KAAK,aAAc;AACxB,gBAAc,KAAK,aAAa;AAChC,OAAK,eAAe;;CAGtB,AAAQ,SAAS;EACf,MAAM,EAAE,OAAO,MAAM,QAAQ,UAAU,WAAW,KAAK,iBAAiB;EAExE,MAAM,QAAQ,KAAK,cAAc,KAAK;EACtC,MAAMC,QAAkB,EAAE;EAE1B,MAAM,SAAS,SAAS;EAExB,MAAM,gBAAgB,iBAAiB,KAAK,GAAG;EAC/C,MAAMC,UAAoB,EAAE;AAC5B,MAAI,SAAS,EAAG,S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ACA;GACA;GACD"}
@@ -3,8 +3,8 @@ const require_utils_setupAI = require('./utils/setupAI.cjs');
3
3
  const require_reviewDocBlockAware = require('./reviewDocBlockAware.cjs');
4
4
  const require_utils_checkFileModifiedRange = require('./utils/checkFileModifiedRange.cjs');
5
5
  const require_utils_getOutputFilePath = require('./utils/getOutputFilePath.cjs');
6
- let __intlayer_chokidar = require("@intlayer/chokidar");
7
- let __intlayer_config = require("@intlayer/config");
6
+ let _intlayer_chokidar = require("@intlayer/chokidar");
7
+ let _intlayer_config = require("@intlayer/config");
8
8
  let node_path = require("node:path");
9
9
  let node_fs = require("node:fs");
10
10
  let fast_glob = require("fast-glob");
@@ -16,8 +16,8 @@ fast_glob = require_rolldown_runtime.__toESM(fast_glob);
16
16
  * then audits them to each locale in LOCALE_LIST.
17
17
  */
18
18
  const reviewDoc = async ({ docPattern, locales, excludedGlobPattern, baseLocale, aiOptions, nbSimultaneousFileProcessed, configOptions, customInstructions, skipIfModifiedBefore, skipIfModifiedAfter, skipIfExists, gitOptions }) => {
19
- const configuration = (0, __intlayer_config.getConfiguration)(configOptions);
20
- const appLogger = (0, __intlayer_config.getAppLogger)(configuration);
19
+ const configuration = (0, _intlayer_config.getConfiguration)(configOptions);
20
+ const appLogger = (0, _intlayer_config.getAppLogger)(configuration);
21
21
  const aiResult = await require_utils_setupAI.setupAI(configuration, aiOptions);
22
22
  if (!aiResult?.hasAIAccess) return;
23
23
  const { aiClient, aiConfig } = aiResult;
@@ -27,20 +27,20 @@ const reviewDoc = async ({ docPattern, locales, excludedGlobPattern, baseLocale,
27
27
  }
28
28
  let docList = await (0, fast_glob.default)(docPattern, { ignore: excludedGlobPattern });
29
29
  if (gitOptions) {
30
- const gitChangedFiles = await (0, __intlayer_chokidar.listGitFiles)(gitOptions);
30
+ const gitChangedFiles = await (0, _intlayer_chokidar.listGitFiles)(gitOptions);
31
31
  if (gitChangedFiles) docList = docList.filter((path) => gitChangedFiles.some((gitFile) => (0, node_path.join)(process.cwd(), path) === gitFile));
32
32
  }
33
- appLogger(`Base locale is ${(0, __intlayer_chokidar.formatLocale)(baseLocale)}`);
34
- appLogger(`Reviewing ${(0, __intlayer_config.colorizeNumber)(locales.length)} locales: [ ${(0, __intlayer_chokidar.formatLocale)(locales)} ]`);
35
- appLogger(`Reviewing ${(0, __intlayer_config.colorizeNumber)(docList.length)} files:`);
36
- appLogger(docList.map((path) => ` - ${(0, __intlayer_chokidar.formatPath)(path)}\n`));
37
- await (0, __intlayer_chokidar.parallelize)(docList.flatMap((docPath) => locales.map((locale) => async () => {
38
- appLogger(`Reviewing file: ${(0, __intlayer_chokidar.formatPath)(docPath)} to ${(0, __intlayer_chokidar.formatLocale)(locale)}`);
33
+ appLogger(`Base locale is ${(0, _intlayer_chokidar.formatLocale)(baseLocale)}`);
34
+ appLogger(`Reviewing ${(0, _intlayer_config.colorizeNumber)(locales.length)} locales: [ ${(0, _intlayer_chokidar.formatLocale)(locales)} ]`);
35
+ appLogger(`Reviewing ${(0, _intlayer_config.colorizeNumber)(docList.length)} files:`);
36
+ appLogger(docList.map((path) => ` - ${(0, _intlayer_chokidar.formatPath)(path)}\n`));
37
+ await (0, _intlayer_chokidar.parallelize)(docList.flatMap((docPath) => locales.map((locale) => async () => {
38
+ appLogger(`Reviewing file: ${(0, _intlayer_chokidar.formatPath)(docPath)} to ${(0, _intlayer_chokidar.formatLocale)(locale)}`);
39
39
  const absoluteBaseFilePath = (0, node_path.join)(configuration.content.baseDir, docPath);
40
40
  const outputFilePath = require_utils_getOutputFilePath.getOutputFilePath(absoluteBaseFilePath, locale, baseLocale);
41
41
  if (skipIfExists && (0, node_fs.existsSync)(outputFilePath)) {
42
42
  const relativePath = (0, node_path.relative)(configuration.content.baseDir, outputFilePath);
43
- appLogger(`${(0, __intlayer_config.colorize)("⊘", __intlayer_config.ANSIColors.YELLOW)} File ${(0, __intlayer_chokidar.formatPath)(relativePath)} already exists, skipping.`);
43
+ appLogger(`${(0, _intlayer_config.colorize)("⊘", _intlayer_config.ANSIColors.YELLOW)} File ${(0, _intlayer_chokidar.formatPath)(relativePath)} already exists, skipping.`);
44
44
  return;
45
45
  }
46
46
  const fileModificationData = require_utils_checkFileModifiedRange.checkFileModifiedRange(outputFilePath, {
@@ -53,7 +53,7 @@ const reviewDoc = async ({ docPattern, locales, excludedGlobPattern, baseLocale,
53
53
  }
54
54
  let changedLines;
55
55
  if (gitOptions) {
56
- const gitChangedLines = await (0, __intlayer_chokidar.listGitLines)(absoluteBaseFilePath, gitOptions);
56
+ const gitChangedLines = await (0, _intlayer_chokidar.listGitLines)(absoluteBaseFilePath, gitOptions);
57
57
  appLogger(`Git changed lines: ${gitChangedLines.join(", ")}`);
58
58
  changedLines = gitChangedLines;
59
59
  }
@@ -1 +1 @@
1
- {"version":3,"file":"reviewDoc.cjs","names":["setupAI","docList: string[]","getOutputFilePath","ANSIColors","checkFileModifiedRange","changedLines: number[] | undefined","reviewFileBlockAware"],"sources":["../../src/reviewDoc.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { join, relative } from 'node:path';\nimport type { AIOptions } from '@intlayer/api'; // OAuth handled by API proxy\nimport {\n formatLocale,\n formatPath,\n type ListGitFilesOptions,\n listGitFiles,\n listGitLines,\n parallelize,\n} from '@intlayer/chokidar';\nimport {\n ANSIColors,\n colorize,\n colorizeNumber,\n type GetConfigurationOptions,\n getAppLogger,\n getConfiguration,\n} from '@intlayer/config';\nimport type { Locale } from '@intlayer/types';\nimport fg from 'fast-glob';\nimport { reviewFileBlockAware } from './reviewDocBlockAware';\nimport { checkFileModifiedRange } from './utils/checkFileModifiedRange';\nimport { getOutputFilePath } from './utils/getOutputFilePath';\nimport { setupAI } from './utils/setupAI';\n\ntype ReviewDocOptions = {\n docPattern: string[];\n locales: Locale[];\n excludedGlobPattern: string[];\n baseLocale: Locale;\n aiOptions?: AIOptions;\n nbSimultaneousFileProcessed?: number;\n configOptions?: GetConfigurationOptions;\n customInstructions?: string;\n skipIfModifiedBefore?: number | string | Date;\n skipIfModifiedAfter?: number | string | Date;\n skipIfExists?: boolean;\n gitOptions?: ListGitFilesOptions;\n};\n\n/**\n * Main audit function: scans all .md files in \"en/\" (unless you specified DOC_LIST),\n * then audits them to each locale in LOCALE_LIST.\n */\nexport const reviewDoc = async ({\n docPattern,\n locales,\n excludedGlobPattern,\n baseLocale,\n aiOptions,\n nbSimultaneousFileProcessed,\n configOptions,\n customInstructions,\n skipIfModifiedBefore,\n skipIfModifiedAfter,\n skipIfExists,\n gitOptions,\n}: ReviewDocOptions) => {\n const configuration = getConfiguration(configOptions);\n const appLogger = getAppLogger(configuration);\n\n const aiResult = await setupAI(configuration, aiOptions);\n\n if (!aiResult?.hasAIAccess) return;\n\n const { aiClient, aiConfig } = aiResult;\n\n if (nbSimultaneousFileProcessed && nbSimultaneousFileProcessed > 10) {\n appLogger(\n `Warning: nbSimultaneousFileProcessed is set to ${nbSimultaneousFileProcessed}, which is greater than 10. Setting it to 10.`\n );\n nbSimultaneousFileProcessed = 10; // Limit the number of simultaneous file processed to 10\n }\n\n let docList: string[] = await fg(docPattern, {\n ignore: excludedGlobPattern,\n });\n\n if (gitOptions) {\n const gitChangedFiles = await listGitFiles(gitOptions);\n\n if (gitChangedFiles) {\n // Convert dictionary file paths to be relative to git root for comparison\n\n // Filter dictionaries based on git changed files\n docList = docList.filter((path) =>\n gitChangedFiles.some((gitFile) => join(process.cwd(), path) === gitFile)\n );\n }\n }\n\n // OAuth handled by API proxy internally\n\n appLogger(`Base locale is ${formatLocale(baseLocale)}`);\n appLogger(\n `Reviewing ${colorizeNumber(locales.length)} locales: [ ${formatLocale(locales)} ]`\n );\n\n appLogger(`Reviewing ${colorizeNumber(docList.length)} files:`);\n appLogger(docList.map((path) => ` - ${formatPath(path)}\\n`));\n\n // Create all tasks to be processed\n const allTasks = docList.flatMap((docPath) =>\n locales.map((locale) => async () => {\n appLogger(\n `Reviewing file: ${formatPath(docPath)} to ${formatLocale(locale)}`\n );\n\n const absoluteBaseFilePath = join(configuration.content.baseDir, docPath);\n const outputFilePath = getOutputFilePath(\n absoluteBaseFilePath,\n locale,\n baseLocale\n );\n\n // Skip if file exists and skipIfExists option is enabled\n if (skipIfExists && existsSync(outputFilePath)) {\n const relativePath = relative(\n configuration.content.baseDir,\n outputFilePath\n );\n appLogger(\n `${colorize('⊘', ANSIColors.YELLOW)} File ${formatPath(relativePath)} already exists, skipping.`\n );\n return;\n }\n\n const fileModificationData = checkFileModifiedRange(outputFilePath, {\n skipIfModifiedBefore,\n skipIfModifiedAfter,\n });\n\n if (fileModificationData.isSkipped) {\n appLogger(fileModificationData.message);\n return;\n }\n\n let changedLines: number[] | undefined;\n // FIXED: Enable git optimization that was previously commented out\n if (gitOptions) {\n const gitChangedLines = await listGitLines(\n absoluteBaseFilePath,\n gitOptions\n );\n\n appLogger(`Git changed lines: ${gitChangedLines.join(', ')}`);\n changedLines = gitChangedLines;\n }\n\n await reviewFileBlockAware(\n absoluteBaseFilePath,\n outputFilePath,\n locale as Locale,\n baseLocale,\n aiOptions,\n configOptions,\n customInstructions,\n changedLines,\n aiClient,\n aiConfig\n );\n })\n );\n\n await parallelize(\n allTasks,\n (task) => task(),\n nbSimultaneousFileProcessed ?? 3\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AA6CA,MAAa,YAAY,OAAO,EAC9B,YACA,SACA,qBACA,YACA,WACA,6BACA,eACA,oBACA,sBACA,qBACA,cACA,iBACsB;CACtB,MAAM,wDAAiC,cAAc;CACrD,MAAM,gDAAyB,cAAc;CAE7C,MAAM,WAAW,MAAMA,8BAAQ,eAAe,UAAU;AAExD,KAAI,CAAC,UAAU,YAAa;CAE5B,MAAM,EAAE,UAAU,aAAa;AAE/B,KAAI,+BAA+B,8BAA8B,IAAI;AACnE,YACE,kDAAkD,4BAA4B,+CAC/E;AACD,gCAA8B;;CAGhC,IAAIC,UAAoB,6BAAS,YAAY,EAC3C,QAAQ,qBACT,CAAC;AAEF,KAAI,YAAY;EACd,MAAM,kBAAkB,4CAAmB,WAAW;AAEtD,MAAI,gBAIF,WAAU,QAAQ,QAAQ,SACxB,gBAAgB,MAAM,gCAAiB,QAAQ,KAAK,EAAE,KAAK,KAAK,QAAQ,CACzE;;AAML,WAAU,wDAA+B,WAAW,GAAG;AACvD,WACE,mDAA4B,QAAQ,OAAO,CAAC,oDAA2B,QAAQ,CAAC,IACjF;AAED,WAAU,mDAA4B,QAAQ,OAAO,CAAC,SAAS;AAC/D,WAAU,QAAQ,KAAK,SAAS,0CAAiB,KAAK,CAAC,IAAI,CAAC;AAiE5D,4CA9DiB,QAAQ,SAAS,YAChC,QAAQ,KAAK,WAAW,YAAY;AAClC,YACE,uDAA8B,QAAQ,CAAC,4CAAmB,OAAO,GAClE;EAED,MAAM,2CAA4B,cAAc,QAAQ,SAAS,QAAQ;EACzE,MAAM,iBAAiBC,kDACrB,sBACA,QACA,WACD;AAGD,MAAI,wCAA2B,eAAe,EAAE;GAC9C,MAAM,uCACJ,cAAc,QAAQ,SACtB,eACD;AACD,aACE,mCAAY,KAAKC,6BAAW,OAAO,CAAC,4CAAmB,aAAa,CAAC,4BACtE;AACD;;EAGF,MAAM,uBAAuBC,4DAAuB,gBAAgB;GAClE;GACA;GACD,CAAC;AAEF,MAAI,qBAAqB,WAAW;AAClC,aAAU,qBAAqB,QAAQ;AACvC;;EAGF,IAAIC;AAEJ,MAAI,YAAY;GACd,MAAM,kBAAkB,4CACtB,sBACA,WACD;AAED,aAAU,sBAAsB,gBAAgB,KAAK,KAAK,GAAG;AAC7D,kBAAe;;AAGjB,QAAMC,iDACJ,sBACA,gBACA,QACA,YACA,WACA,eACA,oBACA,cACA,UACA,SACD;GACD,CACH,GAIE,SAAS,MAAM,EAChB,+BAA+B,EAChC"}
1
+ {"version":3,"file":"reviewDoc.cjs","names":["setupAI","docList: string[]","getOutputFilePath","ANSIColors","checkFileModifiedRange","changedLines: number[] | undefined","reviewFileBlockAware"],"sources":["../../src/reviewDoc.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { join, relative } from 'node:path';\nimport type { AIOptions } from '@intlayer/api'; // OAuth handled by API proxy\nimport {\n formatLocale,\n formatPath,\n type ListGitFilesOptions,\n listGitFiles,\n listGitLines,\n parallelize,\n} from '@intlayer/chokidar';\nimport {\n ANSIColors,\n colorize,\n colorizeNumber,\n type GetConfigurationOptions,\n getAppLogger,\n getConfiguration,\n} from '@intlayer/config';\nimport type { Locale } from '@intlayer/types';\nimport fg from 'fast-glob';\nimport { reviewFileBlockAware } from './reviewDocBlockAware';\nimport { checkFileModifiedRange } from './utils/checkFileModifiedRange';\nimport { getOutputFilePath } from './utils/getOutputFilePath';\nimport { setupAI } from './utils/setupAI';\n\ntype ReviewDocOptions = {\n docPattern: string[];\n locales: Locale[];\n excludedGlobPattern: string[];\n baseLocale: Locale;\n aiOptions?: AIOptions;\n nbSimultaneousFileProcessed?: number;\n configOptions?: GetConfigurationOptions;\n customInstructions?: string;\n skipIfModifiedBefore?: number | string | Date;\n skipIfModifiedAfter?: number | string | Date;\n skipIfExists?: boolean;\n gitOptions?: ListGitFilesOptions;\n};\n\n/**\n * Main audit function: scans all .md files in \"en/\" (unless you specified DOC_LIST),\n * then audits them to each locale in LOCALE_LIST.\n */\nexport const reviewDoc = async ({\n docPattern,\n locales,\n excludedGlobPattern,\n baseLocale,\n aiOptions,\n nbSimultaneousFileProcessed,\n configOptions,\n customInstructions,\n skipIfModifiedBefore,\n skipIfModifiedAfter,\n skipIfExists,\n gitOptions,\n}: ReviewDocOptions) => {\n const configuration = getConfiguration(configOptions);\n const appLogger = getAppLogger(configuration);\n\n const aiResult = await setupAI(configuration, aiOptions);\n\n if (!aiResult?.hasAIAccess) return;\n\n const { aiClient, aiConfig } = aiResult;\n\n if (nbSimultaneousFileProcessed && nbSimultaneousFileProcessed > 10) {\n appLogger(\n `Warning: nbSimultaneousFileProcessed is set to ${nbSimultaneousFileProcessed}, which is greater than 10. Setting it to 10.`\n );\n nbSimultaneousFileProcessed = 10; // Limit the number of simultaneous file processed to 10\n }\n\n let docList: string[] = await fg(docPattern, {\n ignore: excludedGlobPattern,\n });\n\n if (gitOptions) {\n const gitChangedFiles = await listGitFiles(gitOptions);\n\n if (gitChangedFiles) {\n // Convert dictionary file paths to be relative to git root for comparison\n\n // Filter dictionaries based on git changed files\n docList = docList.filter((path) =>\n gitChangedFiles.some((gitFile) => join(process.cwd(), path) === gitFile)\n );\n }\n }\n\n // OAuth handled by API proxy internally\n\n appLogger(`Base locale is ${formatLocale(baseLocale)}`);\n appLogger(\n `Reviewing ${colorizeNumber(locales.length)} locales: [ ${formatLocale(locales)} ]`\n );\n\n appLogger(`Reviewing ${colorizeNumber(docList.length)} files:`);\n appLogger(docList.map((path) => ` - ${formatPath(path)}\\n`));\n\n // Create all tasks to be processed\n const allTasks = docList.flatMap((docPath) =>\n locales.map((locale) => async () => {\n appLogger(\n `Reviewing file: ${formatPath(docPath)} to ${formatLocale(locale)}`\n );\n\n const absoluteBaseFilePath = join(configuration.content.baseDir, docPath);\n const outputFilePath = getOutputFilePath(\n absoluteBaseFilePath,\n locale,\n baseLocale\n );\n\n // Skip if file exists and skipIfExists option is enabled\n if (skipIfExists && existsSync(outputFilePath)) {\n const relativePath = relative(\n configuration.content.baseDir,\n outputFilePath\n );\n appLogger(\n `${colorize('⊘', ANSIColors.YELLOW)} File ${formatPath(relativePath)} already exists, skipping.`\n );\n return;\n }\n\n const fileModificationData = checkFileModifiedRange(outputFilePath, {\n skipIfModifiedBefore,\n skipIfModifiedAfter,\n });\n\n if (fileModificationData.isSkipped) {\n appLogger(fileModificationData.message);\n return;\n }\n\n let changedLines: number[] | undefined;\n // FIXED: Enable git optimization that was previously commented out\n if (gitOptions) {\n const gitChangedLines = await listGitLines(\n absoluteBaseFilePath,\n gitOptions\n );\n\n appLogger(`Git changed lines: ${gitChangedLines.join(', ')}`);\n changedLines = gitChangedLines;\n }\n\n await reviewFileBlockAware(\n absoluteBaseFilePath,\n outputFilePath,\n locale as Locale,\n baseLocale,\n aiOptions,\n configOptions,\n customInstructions,\n changedLines,\n aiClient,\n aiConfig\n );\n })\n );\n\n await parallelize(\n allTasks,\n (task) => task(),\n nbSimultaneousFileProcessed ?? 3\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AA6CA,MAAa,YAAY,OAAO,EAC9B,YACA,SACA,qBACA,YACA,WACA,6BACA,eACA,oBACA,sBACA,qBACA,cACA,iBACsB;CACtB,MAAM,uDAAiC,cAAc;CACrD,MAAM,+CAAyB,cAAc;CAE7C,MAAM,WAAW,MAAMA,8BAAQ,eAAe,UAAU;AAExD,KAAI,CAAC,UAAU,YAAa;CAE5B,MAAM,EAAE,UAAU,aAAa;AAE/B,KAAI,+BAA+B,8BAA8B,IAAI;AACnE,YACE,kDAAkD,4BAA4B,+CAC/E;AACD,gCAA8B;;CAGhC,IAAIC,UAAoB,6BAAS,YAAY,EAC3C,QAAQ,qBACT,CAAC;AAEF,KAAI,YAAY;EACd,MAAM,kBAAkB,2CAAmB,WAAW;AAEtD,MAAI,gBAIF,WAAU,QAAQ,QAAQ,SACxB,gBAAgB,MAAM,gCAAiB,QAAQ,KAAK,EAAE,KAAK,KAAK,QAAQ,CACzE;;AAML,WAAU,uDAA+B,WAAW,GAAG;AACvD,WACE,kDAA4B,QAAQ,OAAO,CAAC,mDAA2B,QAAQ,CAAC,IACjF;AAED,WAAU,kDAA4B,QAAQ,OAAO,CAAC,SAAS;AAC/D,WAAU,QAAQ,KAAK,SAAS,yCAAiB,KAAK,CAAC,IAAI,CAAC;AAiE5D,2CA9DiB,QAAQ,SAAS,YAChC,QAAQ,KAAK,WAAW,YAAY;AAClC,YACE,sDAA8B,QAAQ,CAAC,2CAAmB,OAAO,GAClE;EAED,MAAM,2CAA4B,cAAc,QAAQ,SAAS,QAAQ;EACzE,MAAM,iBAAiBC,kDACrB,sBACA,QACA,WACD;AAGD,MAAI,wCAA2B,eAAe,EAAE;GAC9C,MAAM,uCACJ,cAAc,QAAQ,SACtB,eACD;AACD,aACE,kCAAY,KAAKC,4BAAW,OAAO,CAAC,2CAAmB,aAAa,CAAC,4BACtE;AACD;;EAGF,MAAM,uBAAuBC,4DAAuB,gBAAgB;GAClE;GACA;GACD,CAAC;AAEF,MAAI,qBAAqB,WAAW;AAClC,aAAU,qBAAqB,QAAQ;AACvC;;EAGF,IAAIC;AAEJ,MAAI,YAAY;GACd,MAAM,kBAAkB,2CACtB,sBACA,WACD;AAED,aAAU,sBAAsB,gBAAgB,KAAK,KAAK,GAAG;AAC7D,kBAAe;;AAGjB,QAAMC,iDACJ,sBACA,gBACA,QACA,YACA,WACA,eACA,oBACA,cACA,UACA,SACD;GACD,CACH,GAIE,SAAS,MAAM,EAChB,+BAA+B,EAChC"}
@@ -4,13 +4,13 @@ const require_translation_alignment_rebuildDocument = require('./translation-ali
4
4
  const require_translation_alignment_pipeline = require('./translation-alignment/pipeline.cjs');
5
5
  const require_utils_chunkInference = require('./utils/chunkInference.cjs');
6
6
  const require_utils_fixChunkStartEndChars = require('./utils/fixChunkStartEndChars.cjs');
7
- let __intlayer_chokidar = require("@intlayer/chokidar");
8
- let __intlayer_config = require("@intlayer/config");
7
+ let _intlayer_chokidar = require("@intlayer/chokidar");
8
+ let _intlayer_config = require("@intlayer/config");
9
9
  let node_path = require("node:path");
10
- let __intlayer_core = require("@intlayer/core");
10
+ let _intlayer_core = require("@intlayer/core");
11
11
  let node_fs = require("node:fs");
12
12
  let node_fs_promises = require("node:fs/promises");
13
- let __intlayer_types = require("@intlayer/types");
13
+ let _intlayer_types = require("@intlayer/types");
14
14
 
15
15
  //#region src/reviewDocBlockAware.ts
16
16
  /**
@@ -23,35 +23,35 @@ let __intlayer_types = require("@intlayer/types");
23
23
  * 5. Handles reordering automatically
24
24
  */
25
25
  const reviewFileBlockAware = async (baseFilePath, outputFilePath, locale, baseLocale, aiOptions, configOptions, customInstructions, changedLines, aiClient, aiConfig) => {
26
- const configuration = (0, __intlayer_config.getConfiguration)(configOptions);
27
- const applicationLogger = (0, __intlayer_config.getAppLogger)(configuration);
26
+ const configuration = (0, _intlayer_config.getConfiguration)(configOptions);
27
+ const applicationLogger = (0, _intlayer_config.getAppLogger)(configuration);
28
28
  const englishText = await (0, node_fs_promises.readFile)(baseFilePath, "utf-8");
29
29
  const frenchText = await (0, node_fs_promises.readFile)(outputFilePath, "utf-8").catch(() => "");
30
- const basePrompt = require__utils_asset.readAsset("./prompts/REVIEW_PROMPT.md", "utf-8").replaceAll("{{localeName}}", `${(0, __intlayer_chokidar.formatLocale)(locale, false)}`).replaceAll("{{baseLocaleName}}", `${(0, __intlayer_chokidar.formatLocale)(baseLocale, false)}`).replace("{{applicationContext}}", aiOptions?.applicationContext ?? "-").replace("{{customInstructions}}", customInstructions ?? "-");
31
- const filePrefix = [(0, __intlayer_config.colon)(`${__intlayer_config.ANSIColors.GREY_DARK}[${(0, __intlayer_chokidar.formatPath)(baseFilePath)}${__intlayer_config.ANSIColors.GREY_DARK}] `, { colSize: 40 }), `→ ${__intlayer_config.ANSIColors.RESET}`].join("");
32
- const prefix = [(0, __intlayer_config.colon)(`${__intlayer_config.ANSIColors.GREY_DARK}[${(0, __intlayer_chokidar.formatPath)(baseFilePath)}${__intlayer_config.ANSIColors.GREY_DARK}][${(0, __intlayer_chokidar.formatLocale)(locale)}${__intlayer_config.ANSIColors.GREY_DARK}] `, { colSize: 40 }), `→ ${__intlayer_config.ANSIColors.RESET}`].join("");
30
+ const basePrompt = require__utils_asset.readAsset("./prompts/REVIEW_PROMPT.md", "utf-8").replaceAll("{{localeName}}", `${(0, _intlayer_chokidar.formatLocale)(locale, false)}`).replaceAll("{{baseLocaleName}}", `${(0, _intlayer_chokidar.formatLocale)(baseLocale, false)}`).replace("{{applicationContext}}", aiOptions?.applicationContext ?? "-").replace("{{customInstructions}}", customInstructions ?? "-");
31
+ const filePrefix = [(0, _intlayer_config.colon)(`${_intlayer_config.ANSIColors.GREY_DARK}[${(0, _intlayer_chokidar.formatPath)(baseFilePath)}${_intlayer_config.ANSIColors.GREY_DARK}] `, { colSize: 40 }), `→ ${_intlayer_config.ANSIColors.RESET}`].join("");
32
+ const prefix = [(0, _intlayer_config.colon)(`${_intlayer_config.ANSIColors.GREY_DARK}[${(0, _intlayer_chokidar.formatPath)(baseFilePath)}${_intlayer_config.ANSIColors.GREY_DARK}][${(0, _intlayer_chokidar.formatLocale)(locale)}${_intlayer_config.ANSIColors.GREY_DARK}] `, { colSize: 40 }), `→ ${_intlayer_config.ANSIColors.RESET}`].join("");
33
33
  const { englishBlocks, frenchBlocks, plan, segmentsToReview } = require_translation_alignment_pipeline.buildAlignmentPlan({
34
34
  englishText,
35
35
  frenchText,
36
36
  changedLines
37
37
  });
38
- applicationLogger(`${filePrefix}Block-aware alignment complete. Total blocks: EN=${(0, __intlayer_config.colorizeNumber)(englishBlocks.length)}, FR=${(0, __intlayer_config.colorizeNumber)(frenchBlocks.length)}`);
39
- applicationLogger(`${filePrefix}Actions: reuse=${(0, __intlayer_config.colorizeNumber)(plan.actions.filter((a) => a.kind === "reuse").length)}, review=${(0, __intlayer_config.colorizeNumber)(plan.actions.filter((a) => a.kind === "review").length)}, new=${(0, __intlayer_config.colorizeNumber)(plan.actions.filter((a) => a.kind === "insert_new").length)}, delete=${(0, __intlayer_config.colorizeNumber)(plan.actions.filter((a) => a.kind === "delete").length)}`);
38
+ applicationLogger(`${filePrefix}Block-aware alignment complete. Total blocks: EN=${(0, _intlayer_config.colorizeNumber)(englishBlocks.length)}, FR=${(0, _intlayer_config.colorizeNumber)(frenchBlocks.length)}`);
39
+ applicationLogger(`${filePrefix}Actions: reuse=${(0, _intlayer_config.colorizeNumber)(plan.actions.filter((a) => a.kind === "reuse").length)}, review=${(0, _intlayer_config.colorizeNumber)(plan.actions.filter((a) => a.kind === "review").length)}, new=${(0, _intlayer_config.colorizeNumber)(plan.actions.filter((a) => a.kind === "insert_new").length)}, delete=${(0, _intlayer_config.colorizeNumber)(plan.actions.filter((a) => a.kind === "delete").length)}`);
40
40
  if (segmentsToReview.length === 0) {
41
41
  applicationLogger(`${filePrefix}No segments need review, reusing existing translation`);
42
42
  (0, node_fs.mkdirSync)((0, node_path.dirname)(outputFilePath), { recursive: true });
43
43
  (0, node_fs.writeFileSync)(outputFilePath, require_translation_alignment_rebuildDocument.mergeReviewedSegments(plan, frenchBlocks, /* @__PURE__ */ new Map()));
44
- applicationLogger(`${(0, __intlayer_config.colorize)("✔", __intlayer_config.ANSIColors.GREEN)} File ${(0, __intlayer_chokidar.formatPath)(outputFilePath)} updated successfully (no changes needed).`);
44
+ applicationLogger(`${(0, _intlayer_config.colorize)("✔", _intlayer_config.ANSIColors.GREEN)} File ${(0, _intlayer_chokidar.formatPath)(outputFilePath)} updated successfully (no changes needed).`);
45
45
  return;
46
46
  }
47
- applicationLogger(`${filePrefix}Segments to review: ${(0, __intlayer_config.colorizeNumber)(segmentsToReview.length)}`);
47
+ applicationLogger(`${filePrefix}Segments to review: ${(0, _intlayer_config.colorizeNumber)(segmentsToReview.length)}`);
48
48
  const reviewedSegmentsMap = /* @__PURE__ */ new Map();
49
49
  for (const segment of segmentsToReview) {
50
50
  const segmentNumber = segmentsToReview.indexOf(segment) + 1;
51
51
  const englishBlock = segment.englishBlock;
52
- const getBaseChunkContextPrompt = () => `**BLOCK ${segmentNumber} of ${segmentsToReview.length}** is the base block in ${(0, __intlayer_chokidar.formatLocale)(baseLocale, false)} as reference.\n///chunksStart///\n` + englishBlock.content + `///chunksEnd///`;
53
- const getFrenchChunkPrompt = () => `**BLOCK ${segmentNumber} of ${segmentsToReview.length}** is the current block to review in ${(0, __intlayer_chokidar.formatLocale)(locale, false)}.\n///chunksStart///\n` + (segment.frenchBlockText ?? "") + `///chunksEnd///`;
54
- const reviewedChunkResult = await (0, __intlayer_config.retryManager)(async () => {
52
+ const getBaseChunkContextPrompt = () => `**BLOCK ${segmentNumber} of ${segmentsToReview.length}** is the base block in ${(0, _intlayer_chokidar.formatLocale)(baseLocale, false)} as reference.\n///chunksStart///\n` + englishBlock.content + `///chunksEnd///`;
53
+ const getFrenchChunkPrompt = () => `**BLOCK ${segmentNumber} of ${segmentsToReview.length}** is the current block to review in ${(0, _intlayer_chokidar.formatLocale)(locale, false)}.\n///chunksStart///\n` + (segment.frenchBlockText ?? "") + `///chunksEnd///`;
54
+ const reviewedChunkResult = await (0, _intlayer_config.retryManager)(async () => {
55
55
  const result = await require_utils_chunkInference.chunkInference([
56
56
  {
57
57
  role: "system",
@@ -67,14 +67,14 @@ const reviewFileBlockAware = async (baseFilePath, outputFilePath, locale, baseLo
67
67
  },
68
68
  {
69
69
  role: "system",
70
- content: `The next user message will be the **BLOCK ${(0, __intlayer_config.colorizeNumber)(segmentNumber)} of ${(0, __intlayer_config.colorizeNumber)(segmentsToReview.length)}** that should be translated in ${(0, __intlayer_core.getLocaleName)(locale, __intlayer_types.Locales.ENGLISH)} (${locale}).`
70
+ content: `The next user message will be the **BLOCK ${(0, _intlayer_config.colorizeNumber)(segmentNumber)} of ${(0, _intlayer_config.colorizeNumber)(segmentsToReview.length)}** that should be translated in ${(0, _intlayer_core.getLocaleName)(locale, _intlayer_types.Locales.ENGLISH)} (${locale}).`
71
71
  },
72
72
  {
73
73
  role: "user",
74
74
  content: englishBlock.content
75
75
  }
76
76
  ], aiOptions, configuration, aiClient, aiConfig);
77
- applicationLogger(`${prefix}${(0, __intlayer_config.colorizeNumber)(result.tokenUsed)} tokens used - Block ${(0, __intlayer_config.colorizeNumber)(segmentNumber)} of ${(0, __intlayer_config.colorizeNumber)(segmentsToReview.length)}`);
77
+ applicationLogger(`${prefix}${(0, _intlayer_config.colorizeNumber)(result.tokenUsed)} tokens used - Block ${(0, _intlayer_config.colorizeNumber)(segmentNumber)} of ${(0, _intlayer_config.colorizeNumber)(segmentsToReview.length)}`);
78
78
  return require_utils_fixChunkStartEndChars.fixChunkStartEndChars(result?.fileContent, englishBlock.content);
79
79
  })();
80
80
  reviewedSegmentsMap.set(segment.actionIndex, reviewedChunkResult);
@@ -82,7 +82,7 @@ const reviewFileBlockAware = async (baseFilePath, outputFilePath, locale, baseLo
82
82
  const finalFrenchOutput = require_translation_alignment_rebuildDocument.mergeReviewedSegments(plan, frenchBlocks, reviewedSegmentsMap);
83
83
  (0, node_fs.mkdirSync)((0, node_path.dirname)(outputFilePath), { recursive: true });
84
84
  (0, node_fs.writeFileSync)(outputFilePath, finalFrenchOutput);
85
- applicationLogger(`${(0, __intlayer_config.colorize)("✔", __intlayer_config.ANSIColors.GREEN)} File ${(0, __intlayer_chokidar.formatPath)(outputFilePath)} created/updated successfully.`);
85
+ applicationLogger(`${(0, _intlayer_config.colorize)("✔", _intlayer_config.ANSIColors.GREEN)} File ${(0, _intlayer_chokidar.formatPath)(outputFilePath)} created/updated successfully.`);
86
86
  };
87
87
 
88
88
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"reviewDocBlockAware.cjs","names":["readAsset","ANSIColors","buildAlignmentPlan","mergeReviewedSegments","chunkInference","Locales","fixChunkStartEndChars"],"sources":["../../src/reviewDocBlockAware.ts"],"sourcesContent":["import { mkdirSync, writeFileSync } from 'node:fs';\nimport { readFile } from 'node:fs/promises';\nimport { dirname } from 'node:path';\nimport { readAsset } from 'utils:asset';\nimport type { AIConfig } from '@intlayer/ai';\nimport type { AIOptions } from '@intlayer/api';\nimport { formatLocale, formatPath } from '@intlayer/chokidar';\nimport {\n ANSIColors,\n colon,\n colorize,\n colorizeNumber,\n type GetConfigurationOptions,\n getAppLogger,\n getConfiguration,\n retryManager,\n} from '@intlayer/config';\nimport { getLocaleName } from '@intlayer/core';\nimport { type Locale, Locales } from '@intlayer/types';\nimport {\n buildAlignmentPlan,\n mergeReviewedSegments,\n} from './translation-alignment/pipeline';\nimport { chunkInference } from './utils/chunkInference';\nimport { fixChunkStartEndChars } from './utils/fixChunkStartEndChars';\nimport type { AIClient } from './utils/setupAI';\n\n/**\n * Review a file using block-aware alignment.\n * This approach:\n * 1. Segments both English and French documents into semantic blocks\n * 2. Aligns blocks using structure (special chars, numbers) and context\n * 3. Detects which blocks changed, were added, or deleted\n * 4. Only sends changed/new blocks to AI for translation\n * 5. Handles reordering automatically\n */\nexport const reviewFileBlockAware = async (\n baseFilePath: string,\n outputFilePath: string,\n locale: Locale,\n baseLocale: Locale,\n aiOptions?: AIOptions,\n configOptions?: GetConfigurationOptions,\n customInstructions?: string,\n changedLines?: number[],\n aiClient?: AIClient,\n aiConfig?: AIConfig\n) => {\n const configuration = getConfiguration(configOptions);\n const applicationLogger = getAppLogger(configuration);\n\n const englishText = await readFile(baseFilePath, 'utf-8');\n const frenchText = await readFile(outputFilePath, 'utf-8').catch(() => '');\n\n const basePrompt = readAsset('./prompts/REVIEW_PROMPT.md', 'utf-8')\n .replaceAll('{{localeName}}', `${formatLocale(locale, false)}`)\n .replaceAll('{{baseLocaleName}}', `${formatLocale(baseLocale, false)}`)\n .replace('{{applicationContext}}', aiOptions?.applicationContext ?? '-')\n .replace('{{customInstructions}}', customInstructions ?? '-');\n\n const filePrefixText = `${ANSIColors.GREY_DARK}[${formatPath(baseFilePath)}${ANSIColors.GREY_DARK}] `;\n const filePrefix = [\n colon(filePrefixText, { colSize: 40 }),\n `→ ${ANSIColors.RESET}`,\n ].join('');\n const prefixText = `${ANSIColors.GREY_DARK}[${formatPath(baseFilePath)}${ANSIColors.GREY_DARK}][${formatLocale(locale)}${ANSIColors.GREY_DARK}] `;\n const prefix = [\n colon(prefixText, { colSize: 40 }),\n `→ ${ANSIColors.RESET}`,\n ].join('');\n\n // Build block-aware alignment and plan\n const { englishBlocks, frenchBlocks, plan, segmentsToReview } =\n buildAlignmentPlan({\n englishText,\n frenchText,\n changedLines,\n });\n\n applicationLogger(\n `${filePrefix}Block-aware alignment complete. Total blocks: EN=${colorizeNumber(englishBlocks.length)}, FR=${colorizeNumber(frenchBlocks.length)}`\n );\n applicationLogger(\n `${filePrefix}Actions: reuse=${colorizeNumber(plan.actions.filter((a) => a.kind === 'reuse').length)}, review=${colorizeNumber(plan.actions.filter((a) => a.kind === 'review').length)}, new=${colorizeNumber(plan.actions.filter((a) => a.kind === 'insert_new').length)}, delete=${colorizeNumber(plan.actions.filter((a) => a.kind === 'delete').length)}`\n );\n\n if (segmentsToReview.length === 0) {\n applicationLogger(\n `${filePrefix}No segments need review, reusing existing translation`\n );\n mkdirSync(dirname(outputFilePath), { recursive: true });\n writeFileSync(\n outputFilePath,\n mergeReviewedSegments(plan, frenchBlocks, new Map())\n );\n applicationLogger(\n `${colorize('✔', ANSIColors.GREEN)} File ${formatPath(outputFilePath)} updated successfully (no changes needed).`\n );\n return;\n }\n\n applicationLogger(\n `${filePrefix}Segments to review: ${colorizeNumber(segmentsToReview.length)}`\n );\n\n // Review segments that need AI translation\n const reviewedSegmentsMap = new Map<number, string>();\n\n for (const segment of segmentsToReview) {\n const segmentNumber = segmentsToReview.indexOf(segment) + 1;\n const englishBlock = segment.englishBlock;\n\n const getBaseChunkContextPrompt = () =>\n `**BLOCK ${segmentNumber} of ${segmentsToReview.length}** is the base block in ${formatLocale(baseLocale, false)} as reference.\\n` +\n `///chunksStart///\\n` +\n englishBlock.content +\n `///chunksEnd///`;\n\n const getFrenchChunkPrompt = () =>\n `**BLOCK ${segmentNumber} of ${segmentsToReview.length}** is the current block to review in ${formatLocale(locale, false)}.\\n` +\n `///chunksStart///\\n` +\n (segment.frenchBlockText ?? '') +\n `///chunksEnd///`;\n\n const reviewedChunkResult = await retryManager(async () => {\n const result = await chunkInference(\n [\n { role: 'system', content: basePrompt },\n { role: 'system', content: getBaseChunkContextPrompt() },\n { role: 'system', content: getFrenchChunkPrompt() },\n {\n role: 'system',\n content: `The next user message will be the **BLOCK ${colorizeNumber(segmentNumber)} of ${colorizeNumber(segmentsToReview.length)}** that should be translated in ${getLocaleName(locale, Locales.ENGLISH)} (${locale}).`,\n },\n { role: 'user', content: englishBlock.content },\n ],\n aiOptions,\n configuration,\n aiClient,\n aiConfig\n );\n\n applicationLogger(\n `${prefix}${colorizeNumber(result.tokenUsed)} tokens used - Block ${colorizeNumber(segmentNumber)} of ${colorizeNumber(segmentsToReview.length)}`\n );\n\n const fixed = fixChunkStartEndChars(\n result?.fileContent,\n englishBlock.content\n );\n return fixed;\n })();\n\n reviewedSegmentsMap.set(segment.actionIndex, reviewedChunkResult);\n }\n\n // Merge reviewed segments back into final document\n const finalFrenchOutput = mergeReviewedSegments(\n plan,\n frenchBlocks,\n reviewedSegmentsMap\n );\n\n mkdirSync(dirname(outputFilePath), { recursive: true });\n writeFileSync(outputFilePath, finalFrenchOutput);\n\n applicationLogger(\n `${colorize('✔', ANSIColors.GREEN)} File ${formatPath(outputFilePath)} created/updated successfully.`\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAa,uBAAuB,OAClC,cACA,gBACA,QACA,YACA,WACA,eACA,oBACA,cACA,UACA,aACG;CACH,MAAM,wDAAiC,cAAc;CACrD,MAAM,wDAAiC,cAAc;CAErD,MAAM,cAAc,qCAAe,cAAc,QAAQ;CACzD,MAAM,aAAa,qCAAe,gBAAgB,QAAQ,CAAC,YAAY,GAAG;CAE1E,MAAM,aAAaA,+BAAU,8BAA8B,QAAQ,CAChE,WAAW,kBAAkB,yCAAgB,QAAQ,MAAM,GAAG,CAC9D,WAAW,sBAAsB,yCAAgB,YAAY,MAAM,GAAG,CACtE,QAAQ,0BAA0B,WAAW,sBAAsB,IAAI,CACvE,QAAQ,0BAA0B,sBAAsB,IAAI;CAG/D,MAAM,aAAa,8BADI,GAAGC,6BAAW,UAAU,uCAAc,aAAa,GAAGA,6BAAW,UAAU,KAE1E,EAAE,SAAS,IAAI,CAAC,EACtC,KAAKA,6BAAW,QACjB,CAAC,KAAK,GAAG;CAEV,MAAM,SAAS,8BADI,GAAGA,6BAAW,UAAU,uCAAc,aAAa,GAAGA,6BAAW,UAAU,0CAAiB,OAAO,GAAGA,6BAAW,UAAU,KAE1H,EAAE,SAAS,IAAI,CAAC,EAClC,KAAKA,6BAAW,QACjB,CAAC,KAAK,GAAG;CAGV,MAAM,EAAE,eAAe,cAAc,MAAM,qBACzCC,0DA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KAAE,MAAM;KAAU,SAAS,sBAAsB;KAAE;IACnD;KACE,MAAM;KACN,SAAS,mFAA4D,cAAc,CAAC,4CAAqB,iBAAiB,OAAO,CAAC,qEAAgD,QAAQC,yBAAQ,QAAQ,CAAC,IAAI,OAAO;KACvN;IACD;KAAE,MAAM;KAAQ,SAAS,aAAa;KAAS;IAChD,EACD,WACA,eACA,UACA,SACD;AAED,qBACE,GAAG,+CAAwB,OAAO,UAAU,CAAC,6DAAsC,cAAc,CAAC,4CAAqB,iBAAiB,OAAO,GAChJ;AAMD,UAJcC,0DACZ,QAAQ,aACR,aAAa,QACd;IAED,EAAE;AAEJ,sBAAoB,IAAI,QAAQ,aAAa,oBAAoB;;CAInE,MAAM,oBAAoBH,oEACxB,MACA,cACA,oBACD;AAED,+CAAkB,eAAe,EAAE,EAAE,WAAW,MAAM,CAAC;AACvD,4BAAc,gBAAgB,kBAAkB;AAEhD,mBACE,mCAAY,KAAKF,6BAAW,MAAM,CAAC,4CAAmB,eAAe,CAAC,gCACvE"}
1
+ {"version":3,"file":"reviewDocBlockAware.cjs","names":["readAsset","ANSIColors","buildAlignmentPlan","mergeReviewedSegments","chunkInference","Locales","fixChunkStartEndChars"],"sources":["../../src/reviewDocBlockAware.ts"],"sourcesContent":["import { mkdirSync, writeFileSync } from 'node:fs';\nimport { readFile } from 'node:fs/promises';\nimport { dirname } from 'node:path';\nimport { readAsset } from 'utils:asset';\nimport type { AIConfig } from '@intlayer/ai';\nimport type { AIOptions } from '@intlayer/api';\nimport { formatLocale, formatPath } from '@intlayer/chokidar';\nimport {\n ANSIColors,\n colon,\n colorize,\n colorizeNumber,\n type GetConfigurationOptions,\n getAppLogger,\n getConfiguration,\n retryManager,\n} from '@intlayer/config';\nimport { getLocaleName } from '@intlayer/core';\nimport { type Locale, Locales } from '@intlayer/types';\nimport {\n buildAlignmentPlan,\n mergeReviewedSegments,\n} from './translation-alignment/pipeline';\nimport { chunkInference } from './utils/chunkInference';\nimport { fixChunkStartEndChars } from './utils/fixChunkStartEndChars';\nimport type { AIClient } from './utils/setupAI';\n\n/**\n * Review a file using block-aware alignment.\n * This approach:\n * 1. Segments both English and French documents into semantic blocks\n * 2. Aligns blocks using structure (special chars, numbers) and context\n * 3. Detects which blocks changed, were added, or deleted\n * 4. Only sends changed/new blocks to AI for translation\n * 5. Handles reordering automatically\n */\nexport const reviewFileBlockAware = async (\n baseFilePath: string,\n outputFilePath: string,\n locale: Locale,\n baseLocale: Locale,\n aiOptions?: AIOptions,\n configOptions?: GetConfigurationOptions,\n customInstructions?: string,\n changedLines?: number[],\n aiClient?: AIClient,\n aiConfig?: AIConfig\n) => {\n const configuration = getConfiguration(configOptions);\n const applicationLogger = getAppLogger(configuration);\n\n const englishText = await readFile(baseFilePath, 'utf-8');\n const frenchText = await readFile(outputFilePath, 'utf-8').catch(() => '');\n\n const basePrompt = readAsset('./prompts/REVIEW_PROMPT.md', 'utf-8')\n .replaceAll('{{localeName}}', `${formatLocale(locale, false)}`)\n .replaceAll('{{baseLocaleName}}', `${formatLocale(baseLocale, false)}`)\n .replace('{{applicationContext}}', aiOptions?.applicationContext ?? '-')\n .replace('{{customInstructions}}', customInstructions ?? '-');\n\n const filePrefixText = `${ANSIColors.GREY_DARK}[${formatPath(baseFilePath)}${ANSIColors.GREY_DARK}] `;\n const filePrefix = [\n colon(filePrefixText, { colSize: 40 }),\n `→ ${ANSIColors.RESET}`,\n ].join('');\n const prefixText = `${ANSIColors.GREY_DARK}[${formatPath(baseFilePath)}${ANSIColors.GREY_DARK}][${formatLocale(locale)}${ANSIColors.GREY_DARK}] `;\n const prefix = [\n colon(prefixText, { colSize: 40 }),\n `→ ${ANSIColors.RESET}`,\n ].join('');\n\n // Build block-aware alignment and plan\n const { englishBlocks, frenchBlocks, plan, segmentsToReview } =\n buildAlignmentPlan({\n englishText,\n frenchText,\n changedLines,\n });\n\n applicationLogger(\n `${filePrefix}Block-aware alignment complete. Total blocks: EN=${colorizeNumber(englishBlocks.length)}, FR=${colorizeNumber(frenchBlocks.length)}`\n );\n applicationLogger(\n `${filePrefix}Actions: reuse=${colorizeNumber(plan.actions.filter((a) => a.kind === 'reuse').length)}, review=${colorizeNumber(plan.actions.filter((a) => a.kind === 'review').length)}, new=${colorizeNumber(plan.actions.filter((a) => a.kind === 'insert_new').length)}, delete=${colorizeNumber(plan.actions.filter((a) => a.kind === 'delete').length)}`\n );\n\n if (segmentsToReview.length === 0) {\n applicationLogger(\n `${filePrefix}No segments need review, reusing existing translation`\n );\n mkdirSync(dirname(outputFilePath), { recursive: true });\n writeFileSync(\n outputFilePath,\n mergeReviewedSegments(plan, frenchBlocks, new Map())\n );\n applicationLogger(\n `${colorize('✔', ANSIColors.GREEN)} File ${formatPath(outputFilePath)} updated successfully (no changes needed).`\n );\n return;\n }\n\n applicationLogger(\n `${filePrefix}Segments to review: ${colorizeNumber(segmentsToReview.length)}`\n );\n\n // Review segments that need AI translation\n const reviewedSegmentsMap = new Map<number, string>();\n\n for (const segment of segmentsToReview) {\n const segmentNumber = segmentsToReview.indexOf(segment) + 1;\n const englishBlock = segment.englishBlock;\n\n const getBaseChunkContextPrompt = () =>\n `**BLOCK ${segmentNumber} of ${segmentsToReview.length}** is the base block in ${formatLocale(baseLocale, false)} as reference.\\n` +\n `///chunksStart///\\n` +\n englishBlock.content +\n `///chunksEnd///`;\n\n const getFrenchChunkPrompt = () =>\n `**BLOCK ${segmentNumber} of ${segmentsToReview.length}** is the current block to review in ${formatLocale(locale, false)}.\\n` +\n `///chunksStart///\\n` +\n (segment.frenchBlockText ?? '') +\n `///chunksEnd///`;\n\n const reviewedChunkResult = await retryManager(async () => {\n const result = await chunkInference(\n [\n { role: 'system', content: basePrompt },\n { role: 'system', content: getBaseChunkContextPrompt() },\n { role: 'system', content: getFrenchChunkPrompt() },\n {\n role: 'system',\n content: `The next user message will be the **BLOCK ${colorizeNumber(segmentNumber)} of ${colorizeNumber(segmentsToReview.length)}** that should be translated in ${getLocaleName(locale, Locales.ENGLISH)} (${locale}).`,\n },\n { role: 'user', content: englishBlock.content },\n ],\n aiOptions,\n configuration,\n aiClient,\n aiConfig\n );\n\n applicationLogger(\n `${prefix}${colorizeNumber(result.tokenUsed)} tokens used - Block ${colorizeNumber(segmentNumber)} of ${colorizeNumber(segmentsToReview.length)}`\n );\n\n const fixed = fixChunkStartEndChars(\n result?.fileContent,\n englishBlock.content\n );\n return fixed;\n })();\n\n reviewedSegmentsMap.set(segment.actionIndex, reviewedChunkResult);\n }\n\n // Merge reviewed segments back into final document\n const finalFrenchOutput = mergeReviewedSegments(\n plan,\n frenchBlocks,\n reviewedSegmentsMap\n );\n\n mkdirSync(dirname(outputFilePath), { recursive: true });\n writeFileSync(outputFilePath, finalFrenchOutput);\n\n applicationLogger(\n `${colorize('✔', ANSIColors.GREEN)} File ${formatPath(outputFilePath)} created/updated successfully.`\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAa,uBAAuB,OAClC,cACA,gBACA,QACA,YACA,WACA,eACA,oBACA,cACA,UACA,aACG;CACH,MAAM,uDAAiC,cAAc;CACrD,MAAM,uDAAiC,cAAc;CAErD,MAAM,cAAc,qCAAe,cAAc,QAAQ;CACzD,MAAM,aAAa,qCAAe,gBAAgB,QAAQ,CAAC,YAAY,GAAG;CAE1E,MAAM,aAAaA,+BAAU,8BAA8B,QAAQ,CAChE,WAAW,kBAAkB,wCAAgB,QAAQ,MAAM,GAAG,CAC9D,WAAW,sBAAsB,wCAAgB,YAAY,MAAM,GAAG,CACtE,QAAQ,0BAA0B,WAAW,sBAAsB,IAAI,CACvE,QAAQ,0BAA0B,sBAAsB,IAAI;CAG/D,MAAM,aAAa,6BADI,GAAGC,4BAAW,UAAU,sCAAc,aAAa,GAAGA,4BAAW,UAAU,KAE1E,EAAE,SAAS,IAAI,CAAC,EACtC,KAAKA,4BAAW,QACjB,CAAC,KAAK,GAAG;CAEV,MAAM,SAAS,6BADI,GAAGA,4BAAW,UAAU,sCAAc,aAAa,GAAGA,4B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,mBAAmB,MAC5B;EAEF,MAAM,sBAAsB,yCAAmB,YAAY;GACzD,MAAM,SAAS,MAAMG,4CACnB;IACE;KAAE,MAAM;KAAU,SAAS;KAAY;IACvC;KAAE,MAAM;KAAU,SAAS,2BAA2B;KAAE;IACxD;KAAE,MAAM;KAAU,SAAS,sBAAsB;KAAE;IACnD;KACE,MAAM;KACN,SAAS,kFAA4D,cAAc,CAAC,2CAAqB,iBAAiB,OAAO,CAAC,oEAAgD,QAAQC,wBAAQ,QAAQ,CAAC,IAAI,OAAO;KACvN;IACD;KAAE,MAAM;KAAQ,SAAS,aAAa;KAAS;IAChD,EACD,WACA,eACA,UACA,SACD;AAED,qBACE,GAAG,8CAAwB,OAAO,UAAU,CAAC,4DAAsC,cAAc,CAAC,2CAAqB,iBAAiB,OAAO,GAChJ;AAMD,UAJcC,0DACZ,QAAQ,aACR,aAAa,QACd;IAED,EAAE;AAEJ,sBAAoB,IAAI,QAAQ,aAAa,oBAAoB;;CAInE,MAAM,oBAAoBH,oEACxB,MACA,cACA,oBACD;AAED,+CAAkB,eAAe,EAAE,EAAE,WAAW,MAAM,CAAC;AACvD,4BAAc,gBAAgB,kBAAkB;AAEhD,mBACE,kCAAY,KAAKF,4BAAW,MAAM,CAAC,2CAAmB,eAAe,CAAC,gCACvE"}
@@ -1,13 +1,13 @@
1
1
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
- let __intlayer_config = require("@intlayer/config");
3
- let __intlayer_unmerged_dictionaries_entry = require("@intlayer/unmerged-dictionaries-entry");
4
- let __intlayer_core = require("@intlayer/core");
5
- let __intlayer_dictionaries_entry = require("@intlayer/dictionaries-entry");
2
+ let _intlayer_config = require("@intlayer/config");
3
+ let _intlayer_unmerged_dictionaries_entry = require("@intlayer/unmerged-dictionaries-entry");
4
+ let _intlayer_core = require("@intlayer/core");
5
+ let _intlayer_dictionaries_entry = require("@intlayer/dictionaries-entry");
6
6
 
7
7
  //#region src/test/listMissingTranslations.ts
8
8
  const listMissingTranslationsWithConfig = (configuration) => {
9
- const unmergedDictionariesRecord = (0, __intlayer_unmerged_dictionaries_entry.getUnmergedDictionaries)(configuration);
10
- const mergedDictionaries = (0, __intlayer_dictionaries_entry.getDictionaries)(configuration);
9
+ const unmergedDictionariesRecord = (0, _intlayer_unmerged_dictionaries_entry.getUnmergedDictionaries)(configuration);
10
+ const mergedDictionaries = (0, _intlayer_dictionaries_entry.getDictionaries)(configuration);
11
11
  const missingTranslations = [];
12
12
  const { locales, requiredLocales } = configuration.internationalization;
13
13
  const dictionariesKeys = Object.keys(unmergedDictionariesRecord);
@@ -15,7 +15,7 @@ const listMissingTranslationsWithConfig = (configuration) => {
15
15
  const dictionaries = unmergedDictionariesRecord[dictionaryKey];
16
16
  const multilingualDictionary = dictionaries.filter((dictionary) => !dictionary.locale);
17
17
  for (const dictionary of multilingualDictionary) {
18
- const missingLocales$2 = (0, __intlayer_core.getMissingLocalesContentFromDictionary)(dictionary, locales);
18
+ const missingLocales$2 = (0, _intlayer_core.getMissingLocalesContentFromDictionary)(dictionary, locales);
19
19
  if (missingLocales$2.length > 0) missingTranslations.push({
20
20
  key: dictionaryKey,
21
21
  id: dictionary.id,
@@ -25,7 +25,7 @@ const listMissingTranslationsWithConfig = (configuration) => {
25
25
  }
26
26
  if (dictionaries.filter((dictionary) => dictionary.locale).length === 0) continue;
27
27
  const mergedDictionary = mergedDictionaries[dictionaryKey];
28
- const missingLocales$1 = (0, __intlayer_core.getMissingLocalesContentFromDictionary)(mergedDictionary, locales);
28
+ const missingLocales$1 = (0, _intlayer_core.getMissingLocalesContentFromDictionary)(mergedDictionary, locales);
29
29
  if (missingLocales$1.length > 0) missingTranslations.push({
30
30
  key: dictionaryKey,
31
31
  locales: missingLocales$1
@@ -40,7 +40,7 @@ const listMissingTranslationsWithConfig = (configuration) => {
40
40
  };
41
41
  };
42
42
  const listMissingTranslations = (configurationOptions) => {
43
- return listMissingTranslationsWithConfig((0, __intlayer_config.getConfiguration)(configurationOptions));
43
+ return listMissingTranslationsWithConfig((0, _intlayer_config.getConfiguration)(configurationOptions));
44
44
  };
45
45
 
46
46
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"listMissingTranslations.cjs","names":["missingTranslations: {\n key: string;\n filePath?: string;\n id?: string;\n locales: Locale[];\n }[]","dictionaries: Dictionary[]","multilingualDictionary: Dictionary[]","missingLocales"],"sources":["../../../src/test/listMissingTranslations.ts"],"sourcesContent":["import {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config';\nimport { getMissingLocalesContentFromDictionary } from '@intlayer/core';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport type { Dictionary, IntlayerConfig, Locale } from '@intlayer/types';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\n\nexport const listMissingTranslationsWithConfig = (\n configuration: IntlayerConfig\n) => {\n const unmergedDictionariesRecord = getUnmergedDictionaries(configuration);\n const mergedDictionaries = getDictionaries(configuration);\n\n const missingTranslations: {\n key: string;\n filePath?: string;\n id?: string;\n locales: Locale[];\n }[] = [];\n\n const { locales, requiredLocales } = configuration.internationalization;\n\n const dictionariesKeys = Object.keys(unmergedDictionariesRecord);\n\n for (const dictionaryKey of dictionariesKeys) {\n const dictionaries: Dictionary[] =\n unmergedDictionariesRecord[dictionaryKey];\n\n const multilingualDictionary: Dictionary[] = dictionaries.filter(\n (dictionary) => !dictionary.locale\n );\n\n // Test all by merging all dictionaries to ensure no per-locale dictionary is missing\n for (const dictionary of multilingualDictionary) {\n const missingLocales = getMissingLocalesContentFromDictionary(\n dictionary,\n locales\n );\n\n if (missingLocales.length > 0) {\n missingTranslations.push({\n key: dictionaryKey,\n id: dictionary.id,\n filePath: dictionary.filePath,\n locales: missingLocales,\n });\n }\n }\n\n const perLocaleDictionary: Dictionary[] = dictionaries.filter(\n (dictionary) => dictionary.locale\n );\n\n if (perLocaleDictionary.length === 0) {\n continue;\n }\n\n const mergedDictionary = mergedDictionaries[dictionaryKey];\n\n const missingLocales = getMissingLocalesContentFromDictionary(\n mergedDictionary,\n locales\n );\n\n if (missingLocales.length > 0) {\n missingTranslations.push({\n key: dictionaryKey,\n locales: missingLocales,\n });\n }\n }\n\n const missingLocalesSet = new Set(\n missingTranslations.flatMap((t) => t.locales)\n );\n const missingLocales = Array.from(missingLocalesSet);\n\n const missingRequiredLocales = missingLocales.filter((locale) =>\n (requiredLocales ?? locales).includes(locale)\n );\n\n return { missingTranslations, missingLocales, missingRequiredLocales };\n};\n\nexport const listMissingTranslations = (\n configurationOptions?: GetConfigurationOptions\n) => {\n const configuration = getConfiguration(configurationOptions);\n\n return listMissingTranslationsWithConfig(configuration);\n};\n"],"mappings":";;;;;;;AASA,MAAa,qCACX,kBACG;CACH,MAAM,iGAAqD,cAAc;CACzE,MAAM,wEAAqC,cAAc;CAEzD,MAAMA,sBAKA,EAAE;CAER,MAAM,EAAE,SAAS,oBAAoB,cAAc;CAEnD,MAAM,mBAAmB,OAAO,KAAK,2BAA2B;AAEhE,MAAK,MAAM,iBAAiB,kBAAkB;EAC5C,MAAMC,eACJ,2BAA2B;EAE7B,MAAMC,yBAAuC,aAAa,QACvD,eAAe,CAAC,WAAW,OAC7B;AAGD,OAAK,MAAM,cAAc,wBAAwB;GAC/C,MAAMC,+EACJ,YACA,QACD;AAED,OAAIA,iBAAe,SAAS,EAC1B,qBAAoB,KAAK;IACvB,KAAK;IACL,IAAI,WAAW;IACf,UAAU,WAAW;IACrB,SAASA;IACV,CAAC;;AAQN,MAJ0C,aAAa,QACpD,eAAe,WAAW,OAC5B,CAEuB,WAAW,EACjC;EAGF,MAAM,mBAAmB,mBAAmB;EAE5C,MAAMA,+EACJ,kBACA,QACD;AAED,MAAIA,iBAAe,SAAS,EAC1B,qBAAoB,KAAK;GACvB,KAAK;GACL,SAASA;GACV,CAAC;;CAIN,MAAM,oBAAoB,IAAI,IAC5B,oBAAoB,SAAS,MAAM,EAAE,QAAQ,CAC9C;CACD,MAAM,iBAAiB,MAAM,KAAK,kBAAkB;AAMpD,QAAO;EAAE;EAAqB;EAAgB,wBAJf,eAAe,QAAQ,YACnD,mBAAmB,SAAS,SAAS,OAAO,CAC9C;EAEqE;;AAGxE,MAAa,2BACX,yBACG;AAGH,QAAO,0EAFgC,qBAAqB,CAEL"}
1
+ {"version":3,"file":"listMissingTranslations.cjs","names":["missingTranslations: {\n key: string;\n filePath?: string;\n id?: string;\n locales: Locale[];\n }[]","dictionaries: Dictionary[]","multilingualDictionary: Dictionary[]","missingLocales"],"sources":["../../../src/test/listMissingTranslations.ts"],"sourcesContent":["import {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config';\nimport { getMissingLocalesContentFromDictionary } from '@intlayer/core';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport type { Dictionary, IntlayerConfig, Locale } from '@intlayer/types';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\n\nexport const listMissingTranslationsWithConfig = (\n configuration: IntlayerConfig\n) => {\n const unmergedDictionariesRecord = getUnmergedDictionaries(configuration);\n const mergedDictionaries = getDictionaries(configuration);\n\n const missingTranslations: {\n key: string;\n filePath?: string;\n id?: string;\n locales: Locale[];\n }[] = [];\n\n const { locales, requiredLocales } = configuration.internationalization;\n\n const dictionariesKeys = Object.keys(unmergedDictionariesRecord);\n\n for (const dictionaryKey of dictionariesKeys) {\n const dictionaries: Dictionary[] =\n unmergedDictionariesRecord[dictionaryKey];\n\n const multilingualDictionary: Dictionary[] = dictionaries.filter(\n (dictionary) => !dictionary.locale\n );\n\n // Test all by merging all dictionaries to ensure no per-locale dictionary is missing\n for (const dictionary of multilingualDictionary) {\n const missingLocales = getMissingLocalesContentFromDictionary(\n dictionary,\n locales\n );\n\n if (missingLocales.length > 0) {\n missingTranslations.push({\n key: dictionaryKey,\n id: dictionary.id,\n filePath: dictionary.filePath,\n locales: missingLocales,\n });\n }\n }\n\n const perLocaleDictionary: Dictionary[] = dictionaries.filter(\n (dictionary) => dictionary.locale\n );\n\n if (perLocaleDictionary.length === 0) {\n continue;\n }\n\n const mergedDictionary = mergedDictionaries[dictionaryKey];\n\n const missingLocales = getMissingLocalesContentFromDictionary(\n mergedDictionary,\n locales\n );\n\n if (missingLocales.length > 0) {\n missingTranslations.push({\n key: dictionaryKey,\n locales: missingLocales,\n });\n }\n }\n\n const missingLocalesSet = new Set(\n missingTranslations.flatMap((t) => t.locales)\n );\n const missingLocales = Array.from(missingLocalesSet);\n\n const missingRequiredLocales = missingLocales.filter((locale) =>\n (requiredLocales ?? locales).includes(locale)\n );\n\n return { missingTranslations, missingLocales, missingRequiredLocales };\n};\n\nexport const listMissingTranslations = (\n configurationOptions?: GetConfigurationOptions\n) => {\n const configuration = getConfiguration(configurationOptions);\n\n return listMissingTranslationsWithConfig(configuration);\n};\n"],"mappings":";;;;;;;AASA,MAAa,qCACX,kBACG;CACH,MAAM,gGAAqD,cAAc;CACzE,MAAM,uEAAqC,cAAc;CAEzD,MAAMA,sBAKA,EAAE;CAER,MAAM,EAAE,SAAS,oBAAoB,cAAc;CAEnD,MAAM,mBAAmB,OAAO,KAAK,2BAA2B;AAEhE,MAAK,MAAM,iBAAiB,kBAAkB;EAC5C,MAAMC,eACJ,2BAA2B;EAE7B,MAAMC,yBAAuC,aAAa,QACvD,eAAe,CAAC,WAAW,OAC7B;AAGD,OAAK,MAAM,cAAc,wBAAwB;GAC/C,MAAMC,8EACJ,YACA,QACD;AAED,OAAIA,iBAAe,SAAS,EAC1B,qBAAoB,KAAK;IACvB,KAAK;IACL,IAAI,WAAW;IACf,UAAU,WAAW;IACrB,SAASA;IACV,CAAC;;AAQN,MAJ0C,aAAa,QACpD,eAAe,WAAW,OAC5B,CAEuB,WAAW,EACjC;EAGF,MAAM,mBAAmB,mBAAmB;EAE5C,MAAMA,8EACJ,kBACA,QACD;AAED,MAAIA,iBAAe,SAAS,EAC1B,qBAAoB,KAAK;GACvB,KAAK;GACL,SAASA;GACV,CAAC;;CAIN,MAAM,oBAAoB,IAAI,IAC5B,oBAAoB,SAAS,MAAM,EAAE,QAAQ,CAC9C;CACD,MAAM,iBAAiB,MAAM,KAAK,kBAAkB;AAMpD,QAAO;EAAE;EAAqB;EAAgB,wBAJf,eAAe,QAAQ,YACnD,mBAAmB,SAAS,SAAS,OAAO,CAC9C;EAEqE;;AAGxE,MAAa,2BACX,yBACG;AAGH,QAAO,yEAFgC,qBAAqB,CAEL"}
@@ -1,48 +1,48 @@
1
1
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
2
  const require_test_listMissingTranslations = require('./listMissingTranslations.cjs');
3
- let __intlayer_chokidar = require("@intlayer/chokidar");
4
- let __intlayer_config = require("@intlayer/config");
3
+ let _intlayer_chokidar = require("@intlayer/chokidar");
4
+ let _intlayer_config = require("@intlayer/config");
5
5
 
6
6
  //#region src/test/test.ts
7
7
  const testMissingTranslations = async (options) => {
8
- const config = (0, __intlayer_config.getConfiguration)(options?.configOptions);
8
+ const config = (0, _intlayer_config.getConfiguration)(options?.configOptions);
9
9
  const { locales, requiredLocales } = config.internationalization;
10
- const appLogger = (0, __intlayer_config.getAppLogger)(config, { config: { prefix: "" } });
11
- if (options?.build === true) await (0, __intlayer_chokidar.prepareIntlayer)(config, { forceRun: true });
12
- else if (typeof options?.build === "undefined") await (0, __intlayer_chokidar.prepareIntlayer)(config);
10
+ const appLogger = (0, _intlayer_config.getAppLogger)(config, { config: { prefix: "" } });
11
+ if (options?.build === true) await (0, _intlayer_chokidar.prepareIntlayer)(config, { forceRun: true });
12
+ else if (typeof options?.build === "undefined") await (0, _intlayer_chokidar.prepareIntlayer)(config);
13
13
  const result = require_test_listMissingTranslations.listMissingTranslations(options?.configOptions);
14
14
  const maxKeyColSize = result.missingTranslations.map((t) => ` - ${t.key}`).reduce((max, t) => Math.max(max, t.length), 0);
15
- const maxLocalesColSize = result.missingTranslations.map((t) => (0, __intlayer_chokidar.formatLocale)(t.locales, false)).reduce((max, t) => Math.max(max, t.length), 0);
15
+ const maxLocalesColSize = result.missingTranslations.map((t) => (0, _intlayer_chokidar.formatLocale)(t.locales, false)).reduce((max, t) => Math.max(max, t.length), 0);
16
16
  const formattedMissingTranslations = result.missingTranslations.map((translation) => [
17
- (0, __intlayer_config.colon)(` - ${(0, __intlayer_config.colorizeKey)(translation.key)}`, {
17
+ (0, _intlayer_config.colon)(` - ${(0, _intlayer_config.colorizeKey)(translation.key)}`, {
18
18
  colSize: maxKeyColSize,
19
19
  maxSize: 40
20
20
  }),
21
21
  " - ",
22
- (0, __intlayer_config.colon)((0, __intlayer_chokidar.formatLocale)(translation.locales, __intlayer_config.ANSIColors.RED), {
22
+ (0, _intlayer_config.colon)((0, _intlayer_chokidar.formatLocale)(translation.locales, _intlayer_config.ANSIColors.RED), {
23
23
  colSize: maxLocalesColSize,
24
24
  maxSize: 40
25
25
  }),
26
- translation.filePath ? ` - ${(0, __intlayer_chokidar.formatPath)(translation.filePath)}` : "",
26
+ translation.filePath ? ` - ${(0, _intlayer_chokidar.formatPath)(translation.filePath)}` : "",
27
27
  translation.id ? " - remote" : ""
28
28
  ].join(""));
29
29
  appLogger(`Missing translations:`, { level: "info" });
30
30
  formattedMissingTranslations.forEach((t) => {
31
31
  appLogger(t, { level: "info" });
32
32
  });
33
- appLogger(`Locales: ${(0, __intlayer_chokidar.formatLocale)(locales)}`);
34
- appLogger(`Required locales: ${(0, __intlayer_chokidar.formatLocale)(requiredLocales ?? locales)}`);
35
- appLogger(`Missing locales: ${result.missingLocales.length === 0 ? (0, __intlayer_config.colorize)("-", __intlayer_config.ANSIColors.GREEN) : (0, __intlayer_chokidar.formatLocale)(result.missingLocales, __intlayer_config.ANSIColors.RED)}`);
36
- appLogger(`Missing required locales: ${result.missingRequiredLocales.length === 0 ? (0, __intlayer_config.colorize)("-", __intlayer_config.ANSIColors.GREEN) : (0, __intlayer_chokidar.formatLocale)(result.missingRequiredLocales, __intlayer_config.ANSIColors.RED)}`);
37
- appLogger(`Total missing locales: ${(0, __intlayer_config.colorizeNumber)(result.missingLocales.length, {
38
- one: __intlayer_config.ANSIColors.RED,
39
- other: __intlayer_config.ANSIColors.RED,
40
- zero: __intlayer_config.ANSIColors.GREEN
33
+ appLogger(`Locales: ${(0, _intlayer_chokidar.formatLocale)(locales)}`);
34
+ appLogger(`Required locales: ${(0, _intlayer_chokidar.formatLocale)(requiredLocales ?? locales)}`);
35
+ appLogger(`Missing locales: ${result.missingLocales.length === 0 ? (0, _intlayer_config.colorize)("-", _intlayer_config.ANSIColors.GREEN) : (0, _intlayer_chokidar.formatLocale)(result.missingLocales, _intlayer_config.ANSIColors.RED)}`);
36
+ appLogger(`Missing required locales: ${result.missingRequiredLocales.length === 0 ? (0, _intlayer_config.colorize)("-", _intlayer_config.ANSIColors.GREEN) : (0, _intlayer_chokidar.formatLocale)(result.missingRequiredLocales, _intlayer_config.ANSIColors.RED)}`);
37
+ appLogger(`Total missing locales: ${(0, _intlayer_config.colorizeNumber)(result.missingLocales.length, {
38
+ one: _intlayer_config.ANSIColors.RED,
39
+ other: _intlayer_config.ANSIColors.RED,
40
+ zero: _intlayer_config.ANSIColors.GREEN
41
41
  })}`);
42
- appLogger(`Total missing required locales: ${(0, __intlayer_config.colorizeNumber)(result.missingRequiredLocales.length, {
43
- one: __intlayer_config.ANSIColors.RED,
44
- other: __intlayer_config.ANSIColors.RED,
45
- zero: __intlayer_config.ANSIColors.GREEN
42
+ appLogger(`Total missing required locales: ${(0, _intlayer_config.colorizeNumber)(result.missingRequiredLocales.length, {
43
+ one: _intlayer_config.ANSIColors.RED,
44
+ other: _intlayer_config.ANSIColors.RED,
45
+ zero: _intlayer_config.ANSIColors.GREEN
46
46
  })}`);
47
47
  };
48
48
 
@@ -1 +1 @@
1
- {"version":3,"file":"test.cjs","names":["listMissingTranslations","ANSIColors"],"sources":["../../../src/test/test.ts"],"sourcesContent":["import { formatLocale, formatPath, prepareIntlayer } from '@intlayer/chokidar';\nimport {\n ANSIColors,\n colon,\n colorize,\n colorizeKey,\n colorizeNumber,\n type GetConfigurationOptions,\n getAppLogger,\n getConfiguration,\n} from '@intlayer/config';\nimport { listMissingTranslations } from './listMissingTranslations';\n\ntype ListMissingTranslationsOptions = {\n configOptions?: GetConfigurationOptions;\n build?: boolean;\n};\n\nexport const testMissingTranslations = async (\n options?: ListMissingTranslationsOptions\n) => {\n const config = getConfiguration(options?.configOptions);\n const { locales, requiredLocales } = config.internationalization;\n\n const appLogger = getAppLogger(config, {\n config: {\n prefix: '',\n },\n });\n\n if (options?.build === true) {\n await prepareIntlayer(config, { forceRun: true });\n } else if (typeof options?.build === 'undefined') {\n await prepareIntlayer(config);\n }\n\n const result = listMissingTranslations(options?.configOptions);\n\n const maxKeyColSize = result.missingTranslations\n .map((t) => ` - ${t.key}`)\n .reduce((max, t) => Math.max(max, t.length), 0);\n const maxLocalesColSize = result.missingTranslations\n .map((t) => formatLocale(t.locales, false))\n .reduce((max, t) => Math.max(max, t.length), 0);\n\n const formattedMissingTranslations = result.missingTranslations.map(\n (translation) =>\n [\n colon(` - ${colorizeKey(translation.key)}`, {\n colSize: maxKeyColSize,\n maxSize: 40,\n }),\n ' - ',\n colon(formatLocale(translation.locales, ANSIColors.RED), {\n colSize: maxLocalesColSize,\n maxSize: 40,\n }),\n\n translation.filePath ? ` - ${formatPath(translation.filePath)}` : '',\n translation.id ? ' - remote' : '',\n ].join('')\n );\n\n appLogger(`Missing translations:`, {\n level: 'info',\n });\n\n formattedMissingTranslations.forEach((t) => {\n appLogger(t, {\n level: 'info',\n });\n });\n\n appLogger(`Locales: ${formatLocale(locales)}`);\n appLogger(`Required locales: ${formatLocale(requiredLocales ?? locales)}`);\n appLogger(\n `Missing locales: ${result.missingLocales.length === 0 ? colorize('-', ANSIColors.GREEN) : formatLocale(result.missingLocales, ANSIColors.RED)}`\n );\n\n appLogger(\n `Missing required locales: ${result.missingRequiredLocales.length === 0 ? colorize('-', ANSIColors.GREEN) : formatLocale(result.missingRequiredLocales, ANSIColors.RED)}`\n );\n appLogger(\n `Total missing locales: ${colorizeNumber(result.missingLocales.length, {\n one: ANSIColors.RED,\n other: ANSIColors.RED,\n zero: ANSIColors.GREEN,\n })}`\n );\n appLogger(\n `Total missing required locales: ${colorizeNumber(\n result.missingRequiredLocales.length,\n {\n one: ANSIColors.RED,\n other: ANSIColors.RED,\n zero: ANSIColors.GREEN,\n }\n )}`\n );\n};\n"],"mappings":";;;;;;AAkBA,MAAa,0BAA0B,OACrC,YACG;CACH,MAAM,iDAA0B,SAAS,cAAc;CACvD,MAAM,EAAE,SAAS,oBAAoB,OAAO;CAE5C,MAAM,gDAAyB,QAAQ,EACrC,QAAQ,EACN,QAAQ,IACT,EACF,CAAC;AAEF,KAAI,SAAS,UAAU,KACrB,gDAAsB,QAAQ,EAAE,UAAU,MAAM,CAAC;UACxC,OAAO,SAAS,UAAU,YACnC,gDAAsB,OAAO;CAG/B,MAAM,SAASA,6DAAwB,SAAS,cAAc;CAE9D,MAAM,gBAAgB,OAAO,oBAC1B,KAAK,MAAM,MAAM,EAAE,MAAM,CACzB,QAAQ,KAAK,MAAM,KAAK,IAAI,KAAK,EAAE,OAAO,EAAE,EAAE;CACjD,MAAM,oBAAoB,OAAO,oBAC9B,KAAK,4CAAmB,EAAE,SAAS,MAAM,CAAC,CAC1C,QAAQ,KAAK,MAAM,KAAK,IAAI,KAAK,EAAE,OAAO,EAAE,EAAE;CAEjD,MAAM,+BAA+B,OAAO,oBAAoB,KAC7D,gBACC;+BACQ,yCAAkB,YAAY,IAAI,IAAI;GAC1C,SAAS;GACT,SAAS;GACV,CAAC;EACF;qEACmB,YAAY,SAASC,6BAAW,IAAI,EAAE;GACvD,SAAS;GACT,SAAS;GACV,CAAC;EAEF,YAAY,WAAW,0CAAiB,YAAY,SAAS,KAAK;EAClE,YAAY,KAAK,cAAc;EAChC,CAAC,KAAK,GAAG,CACb;AAED,WAAU,yBAAyB,EACjC,OAAO,QACR,CAAC;AAEF,8BAA6B,SAAS,MAAM;AAC1C,YAAU,GAAG,EACX,OAAO,QACR,CAAC;GACF;AAEF,WAAU,kDAAyB,QAAQ,GAAG;AAC9C,WAAU,2DAAkC,mBAAmB,QAAQ,GAAG;AAC1E,WACE,oBAAoB,OAAO,eAAe,WAAW,oCAAa,KAAKA,6BAAW,MAAM,yCAAgB,OAAO,gBAAgBA,6BAAW,IAAI,GAC/I;AAED,WACE,6BAA6B,OAAO,uBAAuB,WAAW,oCAAa,KAAKA,6BAAW,MAAM,yCAAgB,OAAO,wBAAwBA,6BAAW,IAAI,GACxK;AACD,WACE,gEAAyC,OAAO,eAAe,QAAQ;EACrE,KAAKA,6BAAW;EAChB,OAAOA,6BAAW;EAClB,MAAMA,6BAAW;EAClB,CAAC,GACH;AACD,WACE,yEACE,OAAO,uBAAuB,QAC9B;EACE,KAAKA,6BAAW;EAChB,OAAOA,6BAAW;EAClB,MAAMA,6BAAW;EAClB,CACF,GACF"}
1
+ {"version":3,"file":"test.cjs","names":["listMissingTranslations","ANSIColors"],"sources":["../../../src/test/test.ts"],"sourcesContent":["import { formatLocale, formatPath, prepareIntlayer } from '@intlayer/chokidar';\nimport {\n ANSIColors,\n colon,\n colorize,\n colorizeKey,\n colorizeNumber,\n type GetConfigurationOptions,\n getAppLogger,\n getConfiguration,\n} from '@intlayer/config';\nimport { listMissingTranslations } from './listMissingTranslations';\n\ntype ListMissingTranslationsOptions = {\n configOptions?: GetConfigurationOptions;\n build?: boolean;\n};\n\nexport const testMissingTranslations = async (\n options?: ListMissingTranslationsOptions\n) => {\n const config = getConfiguration(options?.configOptions);\n const { locales, requiredLocales } = config.internationalization;\n\n const appLogger = getAppLogger(config, {\n config: {\n prefix: '',\n },\n });\n\n if (options?.build === true) {\n await prepareIntlayer(config, { forceRun: true });\n } else if (typeof options?.build === 'undefined') {\n await prepareIntlayer(config);\n }\n\n const result = listMissingTranslations(options?.configOptions);\n\n const maxKeyColSize = result.missingTranslations\n .map((t) => ` - ${t.key}`)\n .reduce((max, t) => Math.max(max, t.length), 0);\n const maxLocalesColSize = result.missingTranslations\n .map((t) => formatLocale(t.locales, false))\n .reduce((max, t) => Math.max(max, t.length), 0);\n\n const formattedMissingTranslations = result.missingTranslations.map(\n (translation) =>\n [\n colon(` - ${colorizeKey(translation.key)}`, {\n colSize: maxKeyColSize,\n maxSize: 40,\n }),\n ' - ',\n colon(formatLocale(translation.locales, ANSIColors.RED), {\n colSize: maxLocalesColSize,\n maxSize: 40,\n }),\n\n translation.filePath ? ` - ${formatPath(translation.filePath)}` : '',\n translation.id ? ' - remote' : '',\n ].join('')\n );\n\n appLogger(`Missing translations:`, {\n level: 'info',\n });\n\n formattedMissingTranslations.forEach((t) => {\n appLogger(t, {\n level: 'info',\n });\n });\n\n appLogger(`Locales: ${formatLocale(locales)}`);\n appLogger(`Required locales: ${formatLocale(requiredLocales ?? locales)}`);\n appLogger(\n `Missing locales: ${result.missingLocales.length === 0 ? colorize('-', ANSIColors.GREEN) : formatLocale(result.missingLocales, ANSIColors.RED)}`\n );\n\n appLogger(\n `Missing required locales: ${result.missingRequiredLocales.length === 0 ? colorize('-', ANSIColors.GREEN) : formatLocale(result.missingRequiredLocales, ANSIColors.RED)}`\n );\n appLogger(\n `Total missing locales: ${colorizeNumber(result.missingLocales.length, {\n one: ANSIColors.RED,\n other: ANSIColors.RED,\n zero: ANSIColors.GREEN,\n })}`\n );\n appLogger(\n `Total missing required locales: ${colorizeNumber(\n result.missingRequiredLocales.length,\n {\n one: ANSIColors.RED,\n other: ANSIColors.RED,\n zero: ANSIColors.GREEN,\n }\n )}`\n );\n};\n"],"mappings":";;;;;;AAkBA,MAAa,0BAA0B,OACrC,YACG;CACH,MAAM,gDAA0B,SAAS,cAAc;CACvD,MAAM,EAAE,SAAS,oBAAoB,OAAO;CAE5C,MAAM,+CAAyB,QAAQ,EACrC,QAAQ,EACN,QAAQ,IACT,EACF,CAAC;AAEF,KAAI,SAAS,UAAU,KACrB,+CAAsB,QAAQ,EAAE,UAAU,MAAM,CAAC;UACxC,OAAO,SAAS,UAAU,YACnC,+CAAsB,OAAO;CAG/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