@intlayer/cli 7.2.3 → 7.3.0-canary.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/cjs/cli.cjs +7 -5
- package/dist/cjs/cli.cjs.map +1 -1
- package/dist/cjs/fill/fill.cjs +9 -10
- package/dist/cjs/fill/fill.cjs.map +1 -1
- package/dist/cjs/fill/formatFillData.cjs +9 -9
- package/dist/cjs/fill/formatFillData.cjs.map +1 -1
- package/dist/cjs/fill/listTranslationsTasks.cjs +4 -10
- package/dist/cjs/fill/listTranslationsTasks.cjs.map +1 -1
- package/dist/cjs/fill/translateDictionary.cjs +58 -19
- package/dist/cjs/fill/translateDictionary.cjs.map +1 -1
- package/dist/cjs/fill/writeFill.cjs +7 -4
- package/dist/cjs/fill/writeFill.cjs.map +1 -1
- package/dist/cjs/index.cjs +4 -3
- package/dist/cjs/reviewDoc.cjs +5 -3
- package/dist/cjs/reviewDoc.cjs.map +1 -1
- package/dist/cjs/reviewDocBlockAware.cjs +2 -2
- package/dist/cjs/reviewDocBlockAware.cjs.map +1 -1
- package/dist/cjs/test/index.cjs +3 -49
- package/dist/cjs/test/listMissingTranslations.cjs +5 -2
- package/dist/cjs/test/listMissingTranslations.cjs.map +1 -1
- package/dist/cjs/test/test.cjs +51 -0
- package/dist/cjs/test/test.cjs.map +1 -0
- package/dist/cjs/transform.cjs +3 -1
- package/dist/cjs/transform.cjs.map +1 -1
- package/dist/cjs/translateDoc.cjs +7 -5
- package/dist/cjs/translateDoc.cjs.map +1 -1
- package/dist/cjs/utils/checkAccess.cjs +12 -1
- package/dist/cjs/utils/checkAccess.cjs.map +1 -1
- package/dist/cjs/utils/chunkInference.cjs +18 -2
- package/dist/cjs/utils/chunkInference.cjs.map +1 -1
- package/dist/cjs/utils/setupAI.cjs +39 -0
- package/dist/cjs/utils/setupAI.cjs.map +1 -0
- package/dist/esm/cli.mjs +5 -3
- package/dist/esm/cli.mjs.map +1 -1
- package/dist/esm/fill/fill.mjs +10 -11
- package/dist/esm/fill/fill.mjs.map +1 -1
- package/dist/esm/fill/formatFillData.mjs +9 -9
- package/dist/esm/fill/formatFillData.mjs.map +1 -1
- package/dist/esm/fill/listTranslationsTasks.mjs +5 -11
- package/dist/esm/fill/listTranslationsTasks.mjs.map +1 -1
- package/dist/esm/fill/translateDictionary.mjs +59 -20
- package/dist/esm/fill/translateDictionary.mjs.map +1 -1
- package/dist/esm/fill/writeFill.mjs +7 -4
- package/dist/esm/fill/writeFill.mjs.map +1 -1
- package/dist/esm/index.mjs +3 -3
- package/dist/esm/reviewDoc.mjs +5 -3
- package/dist/esm/reviewDoc.mjs.map +1 -1
- package/dist/esm/reviewDocBlockAware.mjs +2 -2
- package/dist/esm/reviewDocBlockAware.mjs.map +1 -1
- package/dist/esm/test/index.mjs +3 -49
- package/dist/esm/test/listMissingTranslations.mjs +5 -3
- package/dist/esm/test/listMissingTranslations.mjs.map +1 -1
- package/dist/esm/test/test.mjs +50 -0
- package/dist/esm/test/test.mjs.map +1 -0
- package/dist/esm/transform.mjs +3 -1
- package/dist/esm/transform.mjs.map +1 -1
- package/dist/esm/translateDoc.mjs +7 -5
- package/dist/esm/translateDoc.mjs.map +1 -1
- package/dist/esm/utils/checkAccess.mjs +13 -2
- package/dist/esm/utils/checkAccess.mjs.map +1 -1
- package/dist/esm/utils/chunkInference.mjs +18 -2
- package/dist/esm/utils/chunkInference.mjs.map +1 -1
- package/dist/esm/utils/setupAI.mjs +38 -0
- package/dist/esm/utils/setupAI.mjs.map +1 -0
- package/dist/types/cli.d.ts.map +1 -1
- package/dist/types/fill/fill.d.ts.map +1 -1
- package/dist/types/fill/formatFillData.d.ts +1 -1
- package/dist/types/fill/formatFillData.d.ts.map +1 -1
- package/dist/types/fill/listTranslationsTasks.d.ts.map +1 -1
- package/dist/types/fill/translateDictionary.d.ts +4 -0
- package/dist/types/fill/translateDictionary.d.ts.map +1 -1
- package/dist/types/index.d.ts +4 -3
- package/dist/types/reviewDoc.d.ts.map +1 -1
- package/dist/types/reviewDocBlockAware.d.ts +3 -1
- package/dist/types/reviewDocBlockAware.d.ts.map +1 -1
- package/dist/types/test/index.d.ts +3 -12
- package/dist/types/test/listMissingTranslations.d.ts +12 -2
- package/dist/types/test/listMissingTranslations.d.ts.map +1 -1
- package/dist/types/test/test.d.ts +11 -0
- package/dist/types/test/test.d.ts.map +1 -0
- package/dist/types/transform.d.ts +2 -0
- package/dist/types/transform.d.ts.map +1 -1
- package/dist/types/translateDoc.d.ts +3 -2
- package/dist/types/translateDoc.d.ts.map +1 -1
- package/dist/types/utils/checkAccess.d.ts.map +1 -1
- package/dist/types/utils/chunkInference.d.ts +4 -2
- package/dist/types/utils/chunkInference.d.ts.map +1 -1
- package/dist/types/utils/setupAI.d.ts +21 -0
- package/dist/types/utils/setupAI.d.ts.map +1 -0
- package/package.json +11 -10
- package/dist/cjs/test/index.cjs.map +0 -1
- package/dist/esm/test/index.mjs.map +0 -1
- package/dist/types/test/index.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translateDoc.cjs","names":["readAsset","ANSIColors","chunkText","chunkInference","fixChunkStartEndChars","docList: string[]","checkAIAccess","getOutputFilePath","checkFileModifiedRange"],"sources":["../../src/translateDoc.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from 'node:fs';\nimport { readFile } from 'node:fs/promises';\nimport { dirname, join, relative } from 'node:path';\nimport { readAsset } from 'utils:asset';\nimport type { AIOptions } from '@intlayer/api';\nimport {\n formatLocale,\n formatPath,\n getChunk,\n type ListGitFilesOptions,\n listGitFiles,\n parallelize,\n} 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 type { IntlayerConfig, Locale } from '@intlayer/types';\nimport fg from 'fast-glob';\nimport { chunkText } from './utils/calculateChunks';\nimport { checkAIAccess } from './utils/checkAccess';\nimport { checkFileModifiedRange } from './utils/checkFileModifiedRange';\nimport { chunkInference } from './utils/chunkInference';\nimport { fixChunkStartEndChars } from './utils/fixChunkStartEndChars';\nimport { getOutputFilePath } from './utils/getOutputFilePath';\n\n/**\n * Translate a single file for a given locale\n */\nexport const translateFile = async (\n baseFilePath: string,\n outputFilePath: string,\n locale: Locale,\n baseLocale: Locale,\n configuration: IntlayerConfig,\n aiOptions?: AIOptions,\n customInstructions?: string\n) => {\n try {\n const appLogger = getAppLogger(configuration, {\n config: {\n prefix: '',\n },\n });\n\n // Determine the target locale file path\n const fileContent = await readFile(baseFilePath, 'utf-8');\n\n let fileResultContent = fileContent;\n\n // Prepare the base prompt for ChatGPT\n const basePrompt = readAsset('./prompts/TRANSLATE_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\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 // 1. Chunk the file by number of lines instead of characters\n const chunks = chunkText(fileContent);\n appLogger(\n `${filePrefix}Base file splitted into ${colorizeNumber(chunks.length)} chunks`\n );\n\n for await (const [i, chunk] of chunks.entries()) {\n const isFirstChunk = i === 0;\n\n // Build the chunk-specific prompt\n const getPrevChunkPrompt = () =>\n `**CHUNK ${i} of ${chunks.length}** that has been translated in ${formatLocale(locale)}:\\n` +\n `///chunkStart///` +\n getChunk(fileResultContent, chunks[i - 1]) +\n `///chunkEnd///`;\n\n const getBaseChunkContextPrompt = () =>\n `**CHUNK ${i + 1} to ${Math.min(i + 3, chunks.length)} of ${chunks.length}** is the base chunk in ${formatLocale(baseLocale, false)} as reference.\\n` +\n `///chunksStart///` +\n (chunks[i - 1]?.content ?? '') +\n chunks[i].content +\n (chunks[i + 1]?.content ?? '') +\n `///chunksEnd///`;\n\n const fileToTranslateCurrentChunk = chunk.content;\n\n // Make the actual translation call\n const chunkTranslation = await retryManager(async () => {\n const result = await chunkInference(\n [\n { role: 'system', content: basePrompt },\n\n { role: 'system', content: getBaseChunkContextPrompt() },\n ...(isFirstChunk\n ? []\n : [{ role: 'system', content: getPrevChunkPrompt() } as const]),\n {\n role: 'system',\n content: `The next user message will be the **CHUNK ${colorizeNumber(i + 1)} of ${colorizeNumber(chunks.length)}** in ${formatLocale(baseLocale, false)} to translate in ${formatLocale(locale, false)}:`,\n },\n { role: 'user', content: fileToTranslateCurrentChunk },\n ],\n aiOptions,\n configuration\n );\n\n appLogger(\n [\n `${prefix}`,\n `${ANSIColors.GREY_DARK}[Chunk `,\n colorizeNumber(i + 1),\n `${ANSIColors.GREY_DARK} of `,\n colorizeNumber(chunks.length),\n `${ANSIColors.GREY_DARK}] →${ANSIColors.RESET} `,\n `${colorizeNumber(result.tokenUsed)} tokens used`,\n ].join('')\n );\n\n const fixedTranslatedChunkResult = fixChunkStartEndChars(\n result?.fileContent,\n fileToTranslateCurrentChunk\n );\n\n return fixedTranslatedChunkResult;\n })();\n\n // Replace the chunk in the file content\n fileResultContent = fileResultContent.replace(\n fileToTranslateCurrentChunk,\n chunkTranslation\n );\n }\n\n // 4. Write the final translation to the appropriate file path\n mkdirSync(dirname(outputFilePath), { recursive: true });\n writeFileSync(outputFilePath, fileResultContent);\n\n const relativePath = relative(\n configuration.content.baseDir,\n outputFilePath\n );\n\n appLogger(\n `${colorize('✔', ANSIColors.GREEN)} File ${formatPath(relativePath)} created/updated successfully.`\n );\n } catch (error) {\n console.error(error);\n }\n};\n\ntype TranslateDocOptions = {\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 translate function: scans all .md files in \"en/\" (unless you specified DOC_LIST),\n * then translates them to each locale in LOCALE_LIST.\n */\nexport const translateDoc = 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}: TranslateDocOptions) => {\n const configuration = getConfiguration(configOptions);\n const appLogger = getAppLogger(configuration);\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 const hasCMSAuth = await checkAIAccess(configuration, aiOptions);\n\n if (!hasCMSAuth) return;\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 `Translating ${colorizeNumber(locales.length)} locales: [ ${formatLocale(locales)} ]`\n );\n\n appLogger(`Translating ${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 `Translating 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 // check if the file exist, otherwise create it\n if (!existsSync(outputFilePath)) {\n appLogger(`File ${outputFilePath} does not exist, creating it...`);\n mkdirSync(dirname(outputFilePath), { recursive: true });\n writeFileSync(outputFilePath, '');\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 await translateFile(\n absoluteBaseFilePath,\n outputFilePath,\n locale as Locale,\n baseLocale,\n configuration,\n aiOptions,\n customInstructions\n );\n })\n );\n\n await parallelize(\n allTasks,\n (task) => task(),\n nbSimultaneousFileProcessed ?? 3\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAmCA,MAAa,gBAAgB,OAC3B,cACA,gBACA,QACA,YACA,eACA,WACA,uBACG;AACH,KAAI;EACF,MAAM,gDAAyB,eAAe,EAC5C,QAAQ,EACN,QAAQ,IACT,EACF,CAAC;EAGF,MAAM,cAAc,qCAAe,cAAc,QAAQ;EAEzD,IAAI,oBAAoB;EAGxB,MAAM,aAAaA,+BAAU,iCAAiC,QAAQ,CACnE,WAAW,kBAAkB,yCAAgB,QAAQ,MAAM,GAAG,CAC9D,WAAW,sBAA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ACzE;;AAML,WAAU,wDAA+B,WAAW,GAAG;AACvD,WACE,qDAA8B,QAAQ,OAAO,CAAC,oDAA2B,QAAQ,CAAC,IACnF;AAED,WAAU,qDAA8B,QAAQ,OAAO,CAAC,SAAS;AACjE,WAAU,QAAQ,KAAK,SAAS,0CAAiB,KAAK,CAAC,IAAI,CAAC;AAyD5D,4CAtDiB,QAAQ,SAAS,YAChC,QAAQ,KAAK,WAAW,YAAY;AAClC,YACE,yDAAgC,QAAQ,CAAC,4CAAmB,OAAO,GACpE;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,KAAKN,6BAAW,OAAO,CAAC,4CAAmB,aAAa,CAAC,4BACtE;AACD;;AAIF,MAAI,yBAAY,eAAe,EAAE;AAC/B,aAAU,QAAQ,eAAe,iCAAiC;AAClE,iDAAkB,eAAe,EAAE,EAAE,WAAW,MAAM,CAAC;AACvD,8BAAc,gBAAgB,GAAG;;EAGnC,MAAM,uBAAuBO,4DAAuB,gBAAgB;GAClE;GACA;GACD,CAAC;AAEF,MAAI,qBAAqB,WAAW;AAClC,aAAU,qBAAqB,QAAQ;AACvC;;AAGF,QAAM,cACJ,sBACA,gBACA,QACA,YACA,eACA,WACA,mBACD;GACD,CACH,GAIE,SAAS,MAAM,EAChB,+BAA+B,EAChC"}
|
|
1
|
+
{"version":3,"file":"translateDoc.cjs","names":["readAsset","ANSIColors","chunkText","chunkInference","fixChunkStartEndChars","docList: string[]","setupAI","getOutputFilePath","checkFileModifiedRange"],"sources":["../../src/translateDoc.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from 'node:fs';\nimport { readFile } from 'node:fs/promises';\nimport { dirname, join, relative } from 'node:path';\nimport { readAsset } from 'utils:asset';\nimport type { AIConfig, AIOptions } from '@intlayer/ai';\nimport {\n formatLocale,\n formatPath,\n getChunk,\n type ListGitFilesOptions,\n listGitFiles,\n parallelize,\n} 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 type { IntlayerConfig, Locale } from '@intlayer/types';\nimport fg from 'fast-glob';\nimport { chunkText } from './utils/calculateChunks';\nimport { checkFileModifiedRange } from './utils/checkFileModifiedRange';\nimport { chunkInference } from './utils/chunkInference';\nimport { fixChunkStartEndChars } from './utils/fixChunkStartEndChars';\nimport { getOutputFilePath } from './utils/getOutputFilePath';\nimport { type AIClient, setupAI } from './utils/setupAI';\n\n/**\n * Translate a single file for a given locale\n */\nexport const translateFile = async (\n baseFilePath: string,\n outputFilePath: string,\n locale: Locale,\n baseLocale: Locale,\n configuration: IntlayerConfig,\n aiOptions?: AIOptions,\n customInstructions?: string,\n aiClient?: AIClient,\n aiConfig?: AIConfig\n) => {\n try {\n const appLogger = getAppLogger(configuration, {\n config: {\n prefix: '',\n },\n });\n\n // Determine the target locale file path\n const fileContent = await readFile(baseFilePath, 'utf-8');\n\n let fileResultContent = fileContent;\n\n // Prepare the base prompt for ChatGPT\n const basePrompt = readAsset('./prompts/TRANSLATE_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\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 // 1. Chunk the file by number of lines instead of characters\n const chunks = chunkText(fileContent);\n appLogger(\n `${filePrefix}Base file splitted into ${colorizeNumber(chunks.length)} chunks`\n );\n\n for await (const [i, chunk] of chunks.entries()) {\n const isFirstChunk = i === 0;\n\n // Build the chunk-specific prompt\n const getPrevChunkPrompt = () =>\n `**CHUNK ${i} of ${chunks.length}** that has been translated in ${formatLocale(locale)}:\\n` +\n `///chunkStart///` +\n getChunk(fileResultContent, chunks[i - 1]) +\n `///chunkEnd///`;\n\n const getBaseChunkContextPrompt = () =>\n `**CHUNK ${i + 1} to ${Math.min(i + 3, chunks.length)} of ${chunks.length}** is the base chunk in ${formatLocale(baseLocale, false)} as reference.\\n` +\n `///chunksStart///` +\n (chunks[i - 1]?.content ?? '') +\n chunks[i].content +\n (chunks[i + 1]?.content ?? '') +\n `///chunksEnd///`;\n\n const fileToTranslateCurrentChunk = chunk.content;\n\n // Make the actual translation call\n const chunkTranslation = await retryManager(async () => {\n const result = await chunkInference(\n [\n { role: 'system', content: basePrompt },\n\n { role: 'system', content: getBaseChunkContextPrompt() },\n ...(isFirstChunk\n ? []\n : [{ role: 'system', content: getPrevChunkPrompt() } as const]),\n {\n role: 'system',\n content: `The next user message will be the **CHUNK ${colorizeNumber(i + 1)} of ${colorizeNumber(chunks.length)}** in ${formatLocale(baseLocale, false)} to translate in ${formatLocale(locale, false)}:`,\n },\n { role: 'user', content: fileToTranslateCurrentChunk },\n ],\n aiOptions,\n configuration,\n aiClient,\n aiConfig\n );\n\n appLogger(\n [\n `${prefix}`,\n `${ANSIColors.GREY_DARK}[Chunk `,\n colorizeNumber(i + 1),\n `${ANSIColors.GREY_DARK} of `,\n colorizeNumber(chunks.length),\n `${ANSIColors.GREY_DARK}] →${ANSIColors.RESET} `,\n `${colorizeNumber(result.tokenUsed)} tokens used`,\n ].join('')\n );\n\n const fixedTranslatedChunkResult = fixChunkStartEndChars(\n result?.fileContent,\n fileToTranslateCurrentChunk\n );\n\n return fixedTranslatedChunkResult;\n })();\n\n // Replace the chunk in the file content\n fileResultContent = fileResultContent.replace(\n fileToTranslateCurrentChunk,\n chunkTranslation\n );\n }\n\n // 4. Write the final translation to the appropriate file path\n mkdirSync(dirname(outputFilePath), { recursive: true });\n writeFileSync(outputFilePath, fileResultContent);\n\n const relativePath = relative(\n configuration.content.baseDir,\n outputFilePath\n );\n\n appLogger(\n `${colorize('✔', ANSIColors.GREEN)} File ${formatPath(relativePath)} created/updated successfully.`\n );\n } catch (error) {\n console.error(error);\n }\n};\n\ntype TranslateDocOptions = {\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 translate function: scans all .md files in \"en/\" (unless you specified DOC_LIST),\n * then translates them to each locale in LOCALE_LIST.\n */\nexport const translateDoc = 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}: TranslateDocOptions) => {\n const configuration = getConfiguration(configOptions);\n const appLogger = getAppLogger(configuration);\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 const aiResult = await setupAI(configuration, aiOptions);\n\n if (!aiResult?.hasAIAccess) return;\n\n const { aiClient, aiConfig } = aiResult;\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 `Translating ${colorizeNumber(locales.length)} locales: [ ${formatLocale(locales)} ]`\n );\n\n appLogger(`Translating ${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 `Translating 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 // check if the file exist, otherwise create it\n if (!existsSync(outputFilePath)) {\n appLogger(`File ${outputFilePath} does not exist, creating it...`);\n mkdirSync(dirname(outputFilePath), { recursive: true });\n writeFileSync(outputFilePath, '');\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 await translateFile(\n absoluteBaseFilePath,\n outputFilePath,\n locale as Locale,\n baseLocale,\n configuration,\n aiOptions,\n customInstructions,\n aiClient,\n aiConfig\n );\n })\n );\n\n await parallelize(\n allTasks,\n (task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,CAAC;AAEF,MAAI,qBAAqB,WAAW;AAClC,aAAU,qBAAqB,QAAQ;AACvC;;AAGF,QAAM,cACJ,sBACA,gBACA,QACA,YACA,eACA,WACA,oBACA,UACA,SACD;GACD,CACH,GAIE,SAAS,MAAM,EAChB,+BAA+B,EAChC"}
|
|
@@ -23,7 +23,18 @@ const checkAIAccess = async (configuration, aiOptions) => {
|
|
|
23
23
|
const hasCMSAuth = Boolean(configuration.editor.clientId && configuration.editor.clientSecret);
|
|
24
24
|
if (Boolean(configuration.ai?.apiKey || aiOptions?.apiKey)) return true;
|
|
25
25
|
if (!hasCMSAuth) {
|
|
26
|
-
appLogger(
|
|
26
|
+
appLogger([
|
|
27
|
+
"AI options or API key not provided. You can either retreive the CMS access key on",
|
|
28
|
+
(0, __intlayer_config.colorize)("https://intlayer.org/dahboard", __intlayer_config.ANSIColors.GREY),
|
|
29
|
+
(0, __intlayer_config.colorize)("(see doc:", __intlayer_config.ANSIColors.GREY_DARK),
|
|
30
|
+
(0, __intlayer_config.colorize)("https://intlayer.org/doc/concept/cms", __intlayer_config.ANSIColors.GREY),
|
|
31
|
+
(0, __intlayer_config.colorize)(")", __intlayer_config.ANSIColors.GREY_DARK),
|
|
32
|
+
". Alternatively, you can add your own OpenAI API key in the settings",
|
|
33
|
+
(0, __intlayer_config.colorize)("(see doc:", __intlayer_config.ANSIColors.GREY_DARK),
|
|
34
|
+
(0, __intlayer_config.colorize)("https://intlayer.org/doc/concept/configuration", __intlayer_config.ANSIColors.GREY),
|
|
35
|
+
(0, __intlayer_config.colorize)(")", __intlayer_config.ANSIColors.GREY_DARK),
|
|
36
|
+
"."
|
|
37
|
+
], { level: "error" });
|
|
27
38
|
return false;
|
|
28
39
|
}
|
|
29
40
|
return await checkCMSAuth(configuration);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkAccess.cjs","names":[],"sources":["../../../src/utils/checkAccess.ts"],"sourcesContent":["import type { AIOptions } from '@intlayer/api';\nimport { getIntlayerAPIProxy } from '@intlayer/api';\nimport {
|
|
1
|
+
{"version":3,"file":"checkAccess.cjs","names":["ANSIColors"],"sources":["../../../src/utils/checkAccess.ts"],"sourcesContent":["import type { AIOptions } from '@intlayer/api';\nimport { getIntlayerAPIProxy } from '@intlayer/api';\nimport {\n ANSIColors,\n colorize,\n extractErrorMessage,\n getAppLogger,\n} from '@intlayer/config';\nimport type { IntlayerConfig } from '@intlayer/types';\n\nexport const checkCMSAuth = async (\n configuration: IntlayerConfig\n): Promise<boolean> => {\n const appLogger = getAppLogger(configuration, {\n config: {\n prefix: '',\n },\n });\n\n const hasCMSAuth =\n configuration.editor.clientId && configuration.editor.clientSecret;\n if (!hasCMSAuth) {\n appLogger('CMS auth not provided.', {\n level: 'error',\n });\n\n return false;\n }\n const intlayerAPI = getIntlayerAPIProxy(undefined, configuration);\n\n try {\n await intlayerAPI.oAuth.getOAuth2AccessToken();\n } catch (error) {\n const message = extractErrorMessage(error);\n\n appLogger(message, {\n level: 'error',\n });\n return false;\n }\n\n return true;\n};\n\nexport const checkAIAccess = async (\n configuration: IntlayerConfig,\n aiOptions?: AIOptions\n): Promise<boolean> => {\n const appLogger = getAppLogger(configuration);\n\n const hasCMSAuth = Boolean(\n configuration.editor.clientId && configuration.editor.clientSecret\n );\n const hasHisOwnAIAPIKey = Boolean(\n configuration.ai?.apiKey || aiOptions?.apiKey\n );\n\n if (hasHisOwnAIAPIKey) {\n return true;\n }\n\n // User need to provide either his own AI API key or the CMS auth\n if (!hasCMSAuth) {\n appLogger(\n [\n 'AI options or API key not provided. You can either retreive the CMS access key on',\n colorize('https://intlayer.org/dahboard', ANSIColors.GREY),\n colorize('(see doc:', ANSIColors.GREY_DARK),\n colorize('https://intlayer.org/doc/concept/cms', ANSIColors.GREY),\n colorize(')', ANSIColors.GREY_DARK),\n '. Alternatively, you can add your own OpenAI API key in the settings',\n colorize('(see doc:', ANSIColors.GREY_DARK),\n colorize(\n 'https://intlayer.org/doc/concept/configuration',\n ANSIColors.GREY\n ),\n colorize(')', ANSIColors.GREY_DARK),\n '.',\n ],\n {\n level: 'error',\n }\n );\n\n return false;\n }\n\n // If the user do not have his own AI API key, we need to check the CMS auth\n return await checkCMSAuth(configuration);\n};\n"],"mappings":";;;;;AAUA,MAAa,eAAe,OAC1B,kBACqB;CACrB,MAAM,gDAAyB,eAAe,EAC5C,QAAQ,EACN,QAAQ,IACT,EACF,CAAC;AAIF,KAAI,EADF,cAAc,OAAO,YAAY,cAAc,OAAO,eACvC;AACf,YAAU,0BAA0B,EAClC,OAAO,SACR,CAAC;AAEF,SAAO;;CAET,MAAM,sDAAkC,QAAW,cAAc;AAEjE,KAAI;AACF,QAAM,YAAY,MAAM,sBAAsB;UACvC,OAAO;AAGd,uDAFoC,MAAM,EAEvB,EACjB,OAAO,SACR,CAAC;AACF,SAAO;;AAGT,QAAO;;AAGT,MAAa,gBAAgB,OAC3B,eACA,cACqB;CACrB,MAAM,gDAAyB,cAAc;CAE7C,MAAM,aAAa,QACjB,cAAc,OAAO,YAAY,cAAc,OAAO,aACvD;AAKD,KAJ0B,QACxB,cAAc,IAAI,UAAU,WAAW,OACxC,CAGC,QAAO;AAIT,KAAI,CAAC,YAAY;AACf,YACE;GACE;mCACS,iCAAiCA,6BAAW,KAAK;mCACjD,aAAaA,6BAAW,UAAU;mCAClC,wCAAwCA,6BAAW,KAAK;mCACxD,KAAKA,6BAAW,UAAU;GACnC;mCACS,aAAaA,6BAAW,UAAU;mCAEzC,kDACAA,6BAAW,KACZ;mCACQ,KAAKA,6BAAW,UAAU;GACnC;GACD,EACD,EACE,OAAO,SACR,CACF;AAED,SAAO;;AAIT,QAAO,MAAM,aAAa,cAAc"}
|
|
@@ -7,9 +7,22 @@ let __intlayer_config = require("@intlayer/config");
|
|
|
7
7
|
* Translates a single chunk via the OpenAI API.
|
|
8
8
|
* Includes retry logic if the call fails.
|
|
9
9
|
*/
|
|
10
|
-
const chunkInference = async (messages, aiOptions, configuration) => {
|
|
10
|
+
const chunkInference = async (messages, aiOptions, configuration, aiClient, aiConfig) => {
|
|
11
11
|
let lastResult;
|
|
12
12
|
await (0, __intlayer_config.retryManager)(async () => {
|
|
13
|
+
if (aiClient && aiConfig) {
|
|
14
|
+
const response$1 = await aiClient.customQuery({
|
|
15
|
+
aiConfig,
|
|
16
|
+
messages
|
|
17
|
+
});
|
|
18
|
+
if (!response$1) throw new Error("No response from AI API");
|
|
19
|
+
const { fileContent: fileContent$1, tokenUsed: tokenUsed$1 } = response$1;
|
|
20
|
+
lastResult = {
|
|
21
|
+
fileContent: processContent(fileContent$1),
|
|
22
|
+
tokenUsed: tokenUsed$1
|
|
23
|
+
};
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
13
26
|
const response = await (0, __intlayer_api.getIntlayerAPIProxy)(void 0, configuration).ai.customQuery({
|
|
14
27
|
aiOptions,
|
|
15
28
|
messages
|
|
@@ -17,12 +30,15 @@ const chunkInference = async (messages, aiOptions, configuration) => {
|
|
|
17
30
|
if (!response.data) throw new Error("No response from AI API");
|
|
18
31
|
const { fileContent, tokenUsed } = response.data;
|
|
19
32
|
lastResult = {
|
|
20
|
-
fileContent: fileContent
|
|
33
|
+
fileContent: processContent(fileContent),
|
|
21
34
|
tokenUsed
|
|
22
35
|
};
|
|
23
36
|
})();
|
|
24
37
|
return lastResult;
|
|
25
38
|
};
|
|
39
|
+
const processContent = (content) => {
|
|
40
|
+
return content.replaceAll("///chunksStart///", "").replaceAll("///chunkStart///", "").replaceAll("///chunksEnd///", "").replaceAll("///chunkEnd///", "").replaceAll("///chunksStart///", "").replaceAll("chunkStart///", "").replaceAll("chunksEnd///", "").replaceAll("chunkEnd///", "").replaceAll("///chunksStart", "").replaceAll("///chunkStart", "").replaceAll("///chunksEnd", "").replaceAll("///chunkEnd", "").replaceAll("chunksStart", "").replaceAll("chunkStart", "").replaceAll("chunksEnd", "").replaceAll("chunkEnd", "");
|
|
41
|
+
};
|
|
26
42
|
|
|
27
43
|
//#endregion
|
|
28
44
|
exports.chunkInference = chunkInference;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chunkInference.cjs","names":["lastResult: ChunkInferenceResult"],"sources":["../../../src/utils/chunkInference.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"chunkInference.cjs","names":["lastResult: ChunkInferenceResult","response","fileContent"],"sources":["../../../src/utils/chunkInference.ts"],"sourcesContent":["import type { AIConfig, AIOptions } from '@intlayer/ai';\nimport { getIntlayerAPIProxy, type Messages } from '@intlayer/api';\nimport { retryManager } from '@intlayer/config';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport type { AIClient } from './setupAI';\n\ntype ChunkInferenceResult = {\n fileContent: string;\n tokenUsed: number;\n};\n\n/**\n * Translates a single chunk via the OpenAI API.\n * Includes retry logic if the call fails.\n */\nexport const chunkInference = async (\n messages: Messages,\n aiOptions?: AIOptions,\n configuration?: IntlayerConfig,\n aiClient?: AIClient,\n aiConfig?: AIConfig\n): Promise<ChunkInferenceResult> => {\n let lastResult: ChunkInferenceResult;\n\n await retryManager(async () => {\n if (aiClient && aiConfig) {\n const response = await aiClient.customQuery({\n aiConfig,\n messages,\n });\n\n if (!response) {\n throw new Error('No response from AI API');\n }\n\n const { fileContent, tokenUsed } = response;\n\n lastResult = {\n fileContent: processContent(fileContent),\n tokenUsed,\n };\n\n return;\n }\n\n const api = getIntlayerAPIProxy(undefined, configuration);\n\n const response = await api.ai.customQuery({\n aiOptions,\n messages,\n });\n\n if (!response.data) {\n throw new Error('No response from AI API');\n }\n\n const { fileContent, tokenUsed } = response.data;\n\n lastResult = {\n fileContent: processContent(fileContent),\n tokenUsed,\n };\n })();\n\n return lastResult!;\n};\n\nconst processContent = (content: string) => {\n return content\n .replaceAll('///chunksStart///', '')\n .replaceAll('///chunkStart///', '')\n .replaceAll('///chunksEnd///', '')\n .replaceAll('///chunkEnd///', '')\n .replaceAll('///chunksStart///', '')\n .replaceAll('chunkStart///', '')\n .replaceAll('chunksEnd///', '')\n .replaceAll('chunkEnd///', '')\n .replaceAll('///chunksStart', '')\n .replaceAll('///chunkStart', '')\n .replaceAll('///chunksEnd', '')\n .replaceAll('///chunkEnd', '')\n .replaceAll('chunksStart', '')\n .replaceAll('chunkStart', '')\n .replaceAll('chunksEnd', '')\n .replaceAll('chunkEnd', '');\n};\n"],"mappings":";;;;;;;;;AAeA,MAAa,iBAAiB,OAC5B,UACA,WACA,eACA,UACA,aACkC;CAClC,IAAIA;AAEJ,2CAAmB,YAAY;AAC7B,MAAI,YAAY,UAAU;GACxB,MAAMC,aAAW,MAAM,SAAS,YAAY;IAC1C;IACA;IACD,CAAC;AAEF,OAAI,CAACA,WACH,OAAM,IAAI,MAAM,0BAA0B;GAG5C,MAAM,EAAE,4BAAa,2BAAcA;AAEnC,gBAAa;IACX,aAAa,eAAeC,cAAY;IACxC;IACD;AAED;;EAKF,MAAM,WAAW,8CAFe,QAAW,cAAc,CAE9B,GAAG,YAAY;GACxC;GACA;GACD,CAAC;AAEF,MAAI,CAAC,SAAS,KACZ,OAAM,IAAI,MAAM,0BAA0B;EAG5C,MAAM,EAAE,aAAa,cAAc,SAAS;AAE5C,eAAa;GACX,aAAa,eAAe,YAAY;GACxC;GACD;GACD,EAAE;AAEJ,QAAO;;AAGT,MAAM,kBAAkB,YAAoB;AAC1C,QAAO,QACJ,WAAW,qBAAqB,GAAG,CACnC,WAAW,oBAAoB,GAAG,CAClC,WAAW,mBAAmB,GAAG,CACjC,WAAW,kBAAkB,GAAG,CAChC,WAAW,qBAAqB,GAAG,CACnC,WAAW,iBAAiB,GAAG,CAC/B,WAAW,gBAAgB,GAAG,CAC9B,WAAW,eAAe,GAAG,CAC7B,WAAW,kBAAkB,GAAG,CAChC,WAAW,iBAAiB,GAAG,CAC/B,WAAW,gBAAgB,GAAG,CAC9B,WAAW,eAAe,GAAG,CAC7B,WAAW,eAAe,GAAG,CAC7B,WAAW,cAAc,GAAG,CAC5B,WAAW,aAAa,GAAG,CAC3B,WAAW,YAAY,GAAG"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_utils_checkAccess = require('./checkAccess.cjs');
|
|
3
|
+
let __intlayer_config = require("@intlayer/config");
|
|
4
|
+
|
|
5
|
+
//#region src/utils/setupAI.ts
|
|
6
|
+
/**
|
|
7
|
+
* Checks if the @intlayer/ai package is available and configured when an API key is provided.
|
|
8
|
+
* If API key is present but package is missing, logs a warning.
|
|
9
|
+
* Also checks if the user has access to AI (either via local key or CMS auth).
|
|
10
|
+
*/
|
|
11
|
+
const setupAI = async (configuration, aiOptions) => {
|
|
12
|
+
const appLogger = (0, __intlayer_config.getAppLogger)(configuration);
|
|
13
|
+
const hasAIAccess = await require_utils_checkAccess.checkAIAccess(configuration, aiOptions);
|
|
14
|
+
if (aiOptions?.apiKey) try {
|
|
15
|
+
const aiClient = await import("@intlayer/ai");
|
|
16
|
+
const aiConfig = await aiClient.getAIConfig({ userOptions: aiOptions });
|
|
17
|
+
if (!aiConfig) throw new Error("AI configuration is missing");
|
|
18
|
+
return {
|
|
19
|
+
aiClient,
|
|
20
|
+
aiConfig,
|
|
21
|
+
isCustomAI: true,
|
|
22
|
+
hasAIAccess
|
|
23
|
+
};
|
|
24
|
+
} catch {
|
|
25
|
+
appLogger([
|
|
26
|
+
(0, __intlayer_config.colorize)("Using your API key, you can install the", __intlayer_config.ANSIColors.GREY),
|
|
27
|
+
(0, __intlayer_config.colorize)("@intlayer/ai", __intlayer_config.ANSIColors.GREY_LIGHT),
|
|
28
|
+
(0, __intlayer_config.colorize)("package to run the process locally, with no dependency of the Intlayer server", __intlayer_config.ANSIColors.GREY)
|
|
29
|
+
], { level: "warn" });
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
isCustomAI: false,
|
|
33
|
+
hasAIAccess
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
//#endregion
|
|
38
|
+
exports.setupAI = setupAI;
|
|
39
|
+
//# sourceMappingURL=setupAI.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setupAI.cjs","names":["checkAIAccess","ANSIColors"],"sources":["../../../src/utils/setupAI.ts"],"sourcesContent":["import type { AIConfig, AIOptions } from '@intlayer/ai';\nimport { ANSIColors, colorize, getAppLogger } from '@intlayer/config';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport { checkAIAccess } from './checkAccess';\n\nexport type AIClient = typeof import('@intlayer/ai');\n\ntype SetupAIResult = {\n aiClient?: AIClient;\n aiConfig?: AIConfig;\n isCustomAI: boolean;\n hasAIAccess: boolean;\n};\n\n/**\n * Checks if the @intlayer/ai package is available and configured when an API key is provided.\n * If API key is present but package is missing, logs a warning.\n * Also checks if the user has access to AI (either via local key or CMS auth).\n */\nexport const setupAI = async (\n configuration: IntlayerConfig,\n aiOptions?: AIOptions\n): Promise<SetupAIResult | undefined> => {\n const appLogger = getAppLogger(configuration);\n\n const hasAIAccess = await checkAIAccess(configuration, aiOptions);\n\n if (aiOptions?.apiKey) {\n try {\n // Dynamically import the AI package if an API key is provided\n const aiClient = await import('@intlayer/ai');\n\n const aiConfig = await aiClient.getAIConfig({\n userOptions: aiOptions,\n });\n\n if (!aiConfig) {\n throw new Error('AI configuration is missing');\n }\n\n return {\n aiClient,\n aiConfig,\n isCustomAI: true,\n hasAIAccess,\n };\n } catch {\n appLogger(\n [\n colorize('Using your API key, you can install the', ANSIColors.GREY),\n colorize('@intlayer/ai', ANSIColors.GREY_LIGHT),\n colorize(\n 'package to run the process locally, with no dependency of the Intlayer server',\n ANSIColors.GREY\n ),\n ],\n {\n level: 'warn',\n }\n );\n }\n }\n\n return {\n isCustomAI: false,\n hasAIAccess,\n };\n};\n"],"mappings":";;;;;;;;;;AAmBA,MAAa,UAAU,OACrB,eACA,cACuC;CACvC,MAAM,gDAAyB,cAAc;CAE7C,MAAM,cAAc,MAAMA,wCAAc,eAAe,UAAU;AAEjE,KAAI,WAAW,OACb,KAAI;EAEF,MAAM,WAAW,MAAM,OAAO;EAE9B,MAAM,WAAW,MAAM,SAAS,YAAY,EAC1C,aAAa,WACd,CAAC;AAEF,MAAI,CAAC,SACH,OAAM,IAAI,MAAM,8BAA8B;AAGhD,SAAO;GACL;GACA;GACA,YAAY;GACZ;GACD;SACK;AACN,YACE;mCACW,2CAA2CC,6BAAW,KAAK;mCAC3D,gBAAgBA,6BAAW,WAAW;mCAE7C,iFACAA,6BAAW,KACZ;GACF,EACD,EACE,OAAO,QACR,CACF;;AAIL,QAAO;EACL,YAAY;EACZ;EACD"}
|
package/dist/esm/cli.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { build } from "./build.mjs";
|
|
2
2
|
import { getConfig } from "./config.mjs";
|
|
3
3
|
import { startEditor } from "./editor.mjs";
|
|
4
|
+
import { testMissingTranslations } from "./test/test.mjs";
|
|
4
5
|
import { fill } from "./fill/fill.mjs";
|
|
5
6
|
import { listContentDeclaration } from "./listContentDeclaration.mjs";
|
|
6
7
|
import { liveSync } from "./liveSync.mjs";
|
|
@@ -8,7 +9,6 @@ import { pull } from "./pull.mjs";
|
|
|
8
9
|
import { push } from "./push/push.mjs";
|
|
9
10
|
import { pushConfig } from "./pushConfig.mjs";
|
|
10
11
|
import { reviewDoc } from "./reviewDoc.mjs";
|
|
11
|
-
import { testMissingTranslations } from "./test/index.mjs";
|
|
12
12
|
import { transform } from "./transform.mjs";
|
|
13
13
|
import { translateDoc } from "./translateDoc.mjs";
|
|
14
14
|
import { getParentPackageJSON } from "./utils/getParentPackageJSON.mjs";
|
|
@@ -390,11 +390,13 @@ const setAPI = () => {
|
|
|
390
390
|
* TRANSFORM
|
|
391
391
|
*/
|
|
392
392
|
const transformProgram = program.command("transform").alias("trans").description("Transform components to use Intlayer");
|
|
393
|
-
transformProgram.option("-f, --file [files...]", "List of files to transform").option("-o, --output-content-declarations [outputContentDeclarations]", "Path to output content declaration files").action((options) => {
|
|
393
|
+
transformProgram.option("-f, --file [files...]", "List of files to transform").option("-o, --output-content-declarations [outputContentDeclarations]", "Path to output content declaration files").option("--code-only", "Only transform the component code", false).option("--declaration-only", "Only generate content declaration", false).action((options) => {
|
|
394
394
|
transform({
|
|
395
395
|
files: options.file,
|
|
396
396
|
outputContentDeclarations: options.outputContentDeclarations,
|
|
397
|
-
configOptions: extractConfigOptions(options)
|
|
397
|
+
configOptions: extractConfigOptions(options),
|
|
398
|
+
codeOnly: options.codeOnly,
|
|
399
|
+
declarationOnly: options.declarationOnly
|
|
398
400
|
});
|
|
399
401
|
});
|
|
400
402
|
applyConfigOptions(transformProgram);
|
package/dist/esm/cli.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.mjs","names":["isESModule","pathDirname","gitOptionKeys: (keyof GitOptions)[]","configurationOptionKeys: (keyof ConfigurationOptions)[]","addPrefix: boolean"],"sources":["../../src/cli.ts"],"sourcesContent":["import { dirname as pathDirname } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport type { AIOptions as BaseAIOptions } from '@intlayer/api';\nimport type { GetConfigurationOptions } from '@intlayer/config';\nimport { getConfiguration } from '@intlayer/config';\nimport { Command } from 'commander';\nimport type {\n DiffMode,\n ListGitFilesOptions,\n} from '../../chokidar/dist/types/listGitFiles';\nimport { build } from './build';\nimport { getConfig } from './config';\nimport { startEditor } from './editor';\nimport { type FillOptions, fill } from './fill/fill';\nimport { listContentDeclaration } from './listContentDeclaration';\nimport { liveSync } from './liveSync';\nimport { pull } from './pull';\nimport { push } from './push/push';\nimport { pushConfig } from './pushConfig';\nimport { reviewDoc } from './reviewDoc';\nimport { testMissingTranslations } from './test';\nimport { transform } from './transform';\nimport { translateDoc } from './translateDoc';\nimport { getParentPackageJSON } from './utils/getParentPackageJSON';\nimport { watchContentDeclaration } from './watch';\n\n// Extended AI options to include customPrompt\ntype AIOptions = BaseAIOptions & {\n customPrompt?: string;\n};\n\nconst isESModule = typeof import.meta.url === 'string';\n\nexport const dirname = isESModule\n ? pathDirname(fileURLToPath(import.meta.url))\n : __dirname;\n\nconst packageJson = getParentPackageJSON(dirname);\n\nconst logOptions = [\n ['--verbose', 'Verbose (default to true using CLI)'],\n ['--prefix [prefix]', 'Prefix'],\n];\n\nconst configurationOptions = [\n ['--env-file [envFile]', 'Environment file'],\n ['-e, --env [env]', 'Environment'],\n ['--base-dir [baseDir]', 'Base directory'],\n ['--no-cache [noCache]', 'No cache'],\n ...logOptions,\n];\n\nconst aiOptions = [\n ['--provider [provider]', 'Provider'],\n ['--temperature [temperature]', 'Temperature'],\n ['--model [model]', 'Model'],\n ['--api-key [apiKey]', 'Provider API key'],\n ['--custom-prompt [prompt]', 'Custom prompt'],\n ['--application-context [applicationContext]', 'Application context'],\n];\n\nconst gitOptions = [\n ['--git-diff [gitDiff]', 'Git diff mode - Check git diff between two refs'],\n ['--git-diff-base [gitDiffBase]', 'Git diff base ref'],\n ['--git-diff-current [gitDiffCurrent]', 'Git diff current ref'],\n ['--uncommitted [uncommitted]', 'Uncommitted'],\n ['--unpushed [unpushed]', 'Unpushed'],\n ['--untracked [untracked]', 'Untracked'],\n];\n\nconst extractKeysFromOptions = (options: object, keys: string[]) =>\n keys.filter((key) => options[key as keyof typeof options]);\n\n/**\n * Helper functions to apply common options to commands\n */\nconst applyOptions = (command: Command, options: string[][]) => {\n options.forEach(([flag, description]) => {\n command.option(flag, description);\n });\n return command;\n};\n\nconst removeUndefined = <T extends Record<string, any>>(obj: T): T =>\n Object.fromEntries(\n Object.entries(obj).filter(([_, value]) => value !== undefined)\n ) as T;\n\nconst applyConfigOptions = (command: Command) =>\n applyOptions(command, configurationOptions);\nconst applyAIOptions = (command: Command) => applyOptions(command, aiOptions);\nconst applyGitOptions = (command: Command) => applyOptions(command, gitOptions);\n\nconst extractAiOptions = (options: AIOptions): AIOptions | undefined => {\n const {\n apiKey,\n provider,\n model,\n temperature,\n applicationContext,\n customPrompt,\n } = options;\n\n const configuration = getConfiguration();\n\n return removeUndefined({\n apiKey: apiKey ?? configuration.ai?.apiKey,\n provider: provider ?? (configuration.ai?.provider as AIOptions['provider']),\n model: model ?? configuration.ai?.model,\n temperature: temperature ?? configuration.ai?.temperature,\n applicationContext:\n applicationContext ?? configuration.ai?.applicationContext,\n customPrompt: customPrompt ?? (configuration.ai as any)?.customPrompt,\n });\n};\n\ntype GitOptions = {\n gitDiff?: boolean;\n gitDiffBase?: string;\n gitDiffCurrent?: string;\n uncommitted?: boolean;\n unpushed?: boolean;\n untracked?: boolean;\n};\n\nconst gitOptionKeys: (keyof GitOptions)[] = [\n 'gitDiff',\n 'gitDiffBase',\n 'gitDiffCurrent',\n 'uncommitted',\n 'unpushed',\n 'untracked',\n];\n\nconst extractGitOptions = (\n options: GitOptions\n): ListGitFilesOptions | undefined => {\n const filteredOptions = extractKeysFromOptions(options, gitOptionKeys);\n\n const isOptionEmpty = !Object.values(filteredOptions).some(Boolean);\n\n if (isOptionEmpty) return undefined;\n\n const {\n gitDiff,\n gitDiffBase,\n gitDiffCurrent,\n uncommitted,\n unpushed,\n untracked,\n } = options;\n\n const mode = [\n gitDiff && 'gitDiff',\n uncommitted && 'uncommitted',\n unpushed && 'unpushed',\n untracked && 'untracked',\n ].filter(Boolean) as DiffMode[];\n\n return removeUndefined({\n mode,\n baseRef: gitDiffBase,\n currentRef: gitDiffCurrent,\n absolute: true,\n });\n};\n\ntype LogOptions = {\n prefix?: string;\n verbose?: boolean;\n};\n\nexport type ConfigurationOptions = {\n baseDir?: string;\n env?: string;\n envFile?: string;\n noCache?: boolean;\n} & LogOptions;\n\nconst configurationOptionKeys: (keyof ConfigurationOptions)[] = [\n 'baseDir',\n 'env',\n 'envFile',\n 'verbose',\n 'prefix',\n];\n\nconst extractConfigOptions = (\n options: ConfigurationOptions\n): GetConfigurationOptions | undefined => {\n const configuration = getConfiguration(options);\n const filteredOptions = extractKeysFromOptions(\n options,\n configurationOptionKeys\n );\n\n const isOptionEmpty = !Object.values(filteredOptions).some(Boolean);\n\n if (isOptionEmpty) {\n return undefined;\n }\n\n const { baseDir, env, envFile, verbose, prefix, noCache } = options;\n\n const addPrefix: boolean = Boolean((options as any).with); // Hack to add the prefix when the command is run in parallel\n const log = {\n prefix: (prefix ?? addPrefix) ? configuration.log.prefix : '', // Should not consider the prefix set in the intlayer configuration file\n verbose: verbose ?? true,\n };\n\n const override = {\n log,\n };\n\n return removeUndefined({\n baseDir,\n env,\n envFile,\n override,\n cache: !noCache,\n });\n};\n\n/**\n * Set the API for the CLI\n *\n * Example of commands:\n *\n * npm run intlayer build --watch\n * npm run intlayer push --dictionaries id1 id2 id3 --deleteLocaleDir\n */\nexport const setAPI = (): Command => {\n const program = new Command();\n\n program.version(packageJson.version!).description('Intlayer CLI');\n\n // Explicit version subcommand for convenience: `npx intlayer version`\n program\n .command('version')\n .description('Print the Intlayer CLI version')\n .action(() => {\n // Prefer the resolved package.json version; fallback to unknown\n // Keeping output minimal to align with common CLI behavior\n console.log(packageJson.version ?? 'unknown');\n });\n\n /**\n * DICTIONARIES\n */\n\n const dictionariesProgram = program\n .command('dictionary')\n .alias('dictionaries')\n .alias('dic')\n .description('Dictionaries operations');\n\n // Dictionary build command\n const buildOptions = {\n description: 'Build the dictionaries',\n options: [\n ['-w, --watch', 'Watch for changes'],\n ['--skip-prepare', 'Skip the prepare step'],\n ['--with [with...]', 'Start command in parallel with the build'],\n ],\n };\n\n // Add build command to dictionaries program\n const dictionariesBuildCmd = dictionariesProgram\n .command('build')\n .description(buildOptions.description);\n\n applyOptions(dictionariesBuildCmd, buildOptions.options);\n applyConfigOptions(dictionariesBuildCmd);\n dictionariesBuildCmd.action((options) => {\n build({\n ...options,\n configOptions: extractConfigOptions(options),\n });\n });\n\n // Add build command to root program as well\n const rootBuildCmd = program\n .command('build')\n .description(buildOptions.description);\n\n applyOptions(rootBuildCmd, buildOptions.options);\n applyConfigOptions(rootBuildCmd);\n rootBuildCmd.action((options) => {\n build({\n ...options,\n configOptions: extractConfigOptions(options),\n });\n });\n\n const watchOptions = {\n description: 'Watch the dictionaries changes',\n options: [['--with [with...]', 'Start command in parallel with the build']],\n };\n\n // Add build command to dictionaries program\n const dictionariesWatchCmd = dictionariesProgram\n .command('watch')\n .description(buildOptions.description);\n\n applyOptions(dictionariesWatchCmd, watchOptions.options);\n applyConfigOptions(dictionariesWatchCmd);\n dictionariesWatchCmd.action((options) => {\n watchContentDeclaration({\n ...options,\n configOptions: extractConfigOptions(options),\n });\n });\n\n // Add build command to root program as well\n const rootWatchCmd = program\n .command('watch')\n .description(buildOptions.description);\n\n applyOptions(rootWatchCmd, watchOptions.options);\n applyConfigOptions(rootWatchCmd);\n rootWatchCmd.action((options) => {\n watchContentDeclaration({\n ...options,\n configOptions: extractConfigOptions(options),\n });\n });\n\n // Dictionary pull command\n const pullOptions = {\n description: 'Pull dictionaries from the server',\n options: [\n ['-d, --dictionaries [ids...]', 'List of dictionary IDs to pull'],\n [\n '--dictionary [ids...]',\n 'List of dictionary IDs to pull (alias for --dictionaries)',\n ],\n ['--new-dictionaries-path [path]', 'Path to save the new dictionaries'],\n // Backward-compatibility for older tests/flags (camelCase)\n [\n '--newDictionariesPath [path]',\n '[alias] Path to save the new dictionaries',\n ],\n ],\n };\n\n // Add pull command to dictionaries program\n const dictionariesPullCmd = dictionariesProgram\n .command('pull')\n .description(pullOptions.description);\n\n applyOptions(dictionariesPullCmd, pullOptions.options);\n applyConfigOptions(dictionariesPullCmd);\n dictionariesPullCmd.action((options) => {\n // Merge dictionary aliases\n const dictionaries = [\n ...(options.dictionaries ?? []),\n ...(options.dictionary ?? []),\n ];\n\n pull({\n ...options,\n dictionaries: dictionaries.length > 0 ? dictionaries : undefined,\n configOptions: {\n ...options.configOptions,\n baseDir: options.baseDir,\n },\n });\n });\n\n // Add pull command to root program as well\n const rootPullCmd = program\n .command('pull')\n .description(pullOptions.description);\n\n applyOptions(rootPullCmd, pullOptions.options);\n applyConfigOptions(rootPullCmd);\n rootPullCmd.action((options) => {\n // Merge dictionary aliases\n const dictionaries = [\n ...(options.dictionaries ?? []),\n ...(options.dictionary ?? []),\n ];\n\n pull({\n ...options,\n dictionaries: dictionaries.length > 0 ? dictionaries : undefined,\n configOptions: extractConfigOptions(options),\n });\n });\n\n // Dictionary push command\n const pushOptions = {\n description:\n 'Push all dictionaries. Create or update the pushed dictionaries',\n options: [\n ['-d, --dictionaries [ids...]', 'List of dictionary IDs to push'],\n [\n '--dictionary [ids...]',\n 'List of dictionary IDs to push (alias for --dictionaries)',\n ],\n [\n '-r, --delete-locale-dictionary',\n 'Delete the local dictionaries after pushing',\n ],\n [\n '-k, --keep-locale-dictionary',\n 'Keep the local dictionaries after pushing',\n ],\n // Backward-compatibility for older tests/flags (camelCase)\n [\n '--deleteLocaleDictionary',\n '[alias] Delete the local dictionaries after pushing',\n ],\n [\n '--keepLocaleDictionary',\n '[alias] Keep the local dictionaries after pushing',\n ],\n [\n '--build [build]',\n 'Build the dictionaries before pushing to ensure the content is up to date. True will force the build, false will skip the build, undefined will allow using the cache of the build',\n ],\n ],\n };\n\n // Add push command to dictionaries program\n const dictionariesPushCmd = dictionariesProgram\n .command('push')\n .description(pushOptions.description);\n\n applyOptions(dictionariesPushCmd, pushOptions.options);\n applyConfigOptions(dictionariesPushCmd);\n applyGitOptions(dictionariesPushCmd);\n\n dictionariesPushCmd.action((options) => {\n // Merge dictionary aliases\n const dictionaries = [\n ...(options.dictionaries || []),\n ...(options.dictionary || []),\n ];\n\n return push({\n ...options,\n dictionaries: dictionaries.length > 0 ? dictionaries : undefined,\n gitOptions: extractGitOptions(options),\n configOptions: extractConfigOptions(options),\n } as FillOptions);\n });\n\n // Add push command to root program as well\n const rootPushCmd = program\n .command('push')\n .description(pushOptions.description);\n\n applyOptions(rootPushCmd, pushOptions.options);\n applyConfigOptions(rootPushCmd);\n applyGitOptions(rootPushCmd);\n\n rootPushCmd.action((options) => {\n // Merge dictionary aliases\n const dictionaries = [\n ...(options.dictionaries || []),\n ...(options.dictionary || []),\n ];\n\n return push({\n ...options,\n dictionaries: dictionaries.length > 0 ? dictionaries : undefined,\n gitOptions: extractGitOptions(options),\n configOptions: extractConfigOptions(options),\n } as FillOptions);\n });\n\n /**\n * CONFIGURATION\n */\n\n // Define the parent command\n const configurationProgram = program\n .command('configuration')\n .alias('config')\n .alias('conf')\n .description('Configuration operations');\n\n const configGetCmd = configurationProgram\n .command('get')\n .description('Get the configuration');\n\n applyConfigOptions(configGetCmd);\n configGetCmd.action((options) => {\n getConfig({\n ...options,\n configOptions: extractConfigOptions(options),\n });\n });\n\n // Define the `push config` subcommand and add it to the `push` command\n const configPushCmd = configurationProgram\n .command('push')\n .description('Push the configuration');\n\n applyConfigOptions(configPushCmd);\n configPushCmd.action((options) => {\n pushConfig({\n ...options,\n configOptions: extractConfigOptions(options),\n });\n });\n\n /**\n * CONTENT DECLARATION\n */\n\n const contentProgram = program\n .command('content')\n .description('Content declaration operations');\n\n contentProgram\n .command('list')\n .description('List the content declaration files')\n .action(listContentDeclaration);\n\n // Add alias for content list command\n program\n .command('list')\n .description('List the content declaration files')\n .action(listContentDeclaration);\n\n const testProgram = contentProgram\n .command('test')\n .description('Test if there are missing translations')\n .option(\n '--build [build]',\n 'Build the dictionaries before testing to ensure the content is up to date. True will force the build, false will skip the build, undefined will allow using the cache of the build'\n );\n\n applyConfigOptions(testProgram);\n testProgram.action((options) => {\n testMissingTranslations({\n ...options,\n configOptions: extractConfigOptions(options),\n });\n });\n\n // Add alias for content test command\n const rootTestCmd = program\n .command('test')\n .description('Test if there are missing translations')\n .option(\n '--build [build]',\n 'Build the dictionaries before testing to ensure the content is up to date. True will force the build, false will skip the build, undefined will allow using the cache of the build'\n );\n\n applyConfigOptions(rootTestCmd);\n rootTestCmd.action((options) => {\n testMissingTranslations({\n ...options,\n configOptions: extractConfigOptions(options),\n });\n });\n\n const fillProgram = program\n .command('fill')\n .description('Fill the dictionaries')\n .option('-f, --file [files...]', 'List of Dictionary files to fill')\n .option('--source-locale [sourceLocale]', 'Source locale to translate from')\n .option(\n '--output-locales [outputLocales...]',\n 'Target locales to translate to'\n )\n .option(\n '--mode [mode]',\n 'Fill mode: complete, review. Complete will fill all missing content, review will fill missing content and review existing keys',\n 'complete'\n )\n .option('-k, --keys [keys...]', 'Filter dictionaries based on keys')\n .option(\n '--key [keys...]',\n 'Filter dictionaries based on keys (alias for --keys)'\n )\n .option(\n '--excluded-keys [excludedKeys...]',\n 'Filter out dictionaries based on keys'\n )\n .option(\n '--excluded-key [excludedKeys...]',\n 'Filter out dictionaries based on keys (alias for --excluded-keys)'\n )\n .option(\n '--path-filter [pathFilters...]',\n 'Filter dictionaries based on glob pattern'\n )\n .option(\n '--build [build]',\n 'Build the dictionaries before filling to ensure the content is up to date. True will force the build, false will skip the build, undefined will allow using the cache of the build'\n )\n .option(\n '--skip-metadata',\n 'Skip filling missing metadata (description, title, tags) for dictionaries'\n );\n\n applyConfigOptions(fillProgram);\n applyAIOptions(fillProgram);\n applyGitOptions(fillProgram);\n\n fillProgram.action((options) => {\n // Merge key aliases\n const keys = [...(options.keys ?? []), ...(options.key ?? [])];\n const excludedKeys = [\n ...(options.excludedKeys ?? []),\n ...(options.excludedKey ?? []),\n ];\n // Merge dictionary aliases\n const dictionaries = [\n ...(options.dictionaries ?? []),\n ...(options.dictionary ?? []),\n ];\n\n return fill({\n ...options,\n keys: keys.length > 0 ? keys : undefined,\n excludedKeys: excludedKeys.length > 0 ? excludedKeys : undefined,\n dictionaries: dictionaries.length > 0 ? dictionaries : undefined,\n aiOptions: extractAiOptions(options),\n gitOptions: extractGitOptions(options),\n configOptions: extractConfigOptions(options),\n } as FillOptions);\n });\n\n /**\n * DOCS\n */\n\n const docParams = [\n ['--doc-pattern [docPattern...]', 'Documentation pattern'],\n [\n '--excluded-glob-pattern [excludedGlobPattern...]',\n 'Excluded glob pattern',\n ],\n [\n '--nb-simultaneous-file-processed [nbSimultaneousFileProcessed]',\n 'Number of simultaneous file processed',\n ],\n ['--locales [locales...]', 'Locales'],\n ['--base-locale [baseLocale]', 'Base locale'],\n [\n '--custom-instructions [customInstructions]',\n 'Custom instructions added to the prompt. Usefull to apply specific rules regarding formatting, urls translation, etc.',\n ],\n [\n '--skip-if-modified-before [skipIfModifiedBefore]',\n 'Skip the file if it has been modified before the given time. Can be an absolute time as \"2025-12-05\" (string or Date) or a relative time in ms `1 * 60 * 60 * 1000` (1 hour). This option check update time of the file using the `fs.stat` method. So it could be impacted by Git or other tools that modify the file.',\n ],\n [\n '--skip-if-modified-after [skipIfModifiedAfter]',\n 'Skip the file if it has been modified within the given time. Can be an absolute time as \"2025-12-05\" (string or Date) or a relative time in ms `1 * 60 * 60 * 1000` (1 hour). This option check update time of the file using the `fs.stat` method. So it could be impacted by Git or other tools that modify the file.',\n ],\n ['--skip-if-exists', 'Skip the file if it already exists'],\n ];\n\n const docProgram = program\n .command('doc')\n .description('Documentation operations');\n\n const translateProgram = docProgram\n .command('translate')\n .description('Translate the documentation');\n\n applyConfigOptions(translateProgram);\n applyAIOptions(translateProgram);\n applyGitOptions(translateProgram);\n applyOptions(translateProgram, docParams);\n\n translateProgram.action((options) =>\n translateDoc({\n docPattern: options.docPattern,\n excludedGlobPattern: options.excludedGlobPattern,\n locales: options.locales,\n baseLocale: options.baseLocale,\n aiOptions: extractAiOptions(options),\n gitOptions: extractGitOptions(options),\n nbSimultaneousFileProcessed: options.nbSimultaneousFileProcessed,\n configOptions: extractConfigOptions(options),\n customInstructions: options.customInstructions,\n skipIfModifiedBefore: options.skipIfModifiedBefore,\n skipIfModifiedAfter: options.skipIfModifiedAfter,\n skipIfExists: options.skipIfExists,\n })\n );\n\n const reviewProgram = docProgram\n .command('review')\n .description('Review the documentation');\n\n applyConfigOptions(reviewProgram);\n applyAIOptions(reviewProgram);\n applyGitOptions(reviewProgram);\n applyOptions(reviewProgram, docParams);\n\n reviewProgram.action((options) =>\n reviewDoc({\n docPattern: options.docPattern,\n excludedGlobPattern: options.excludedGlobPattern,\n locales: options.locales,\n baseLocale: options.baseLocale,\n aiOptions: extractAiOptions(options),\n gitOptions: extractGitOptions(options),\n nbSimultaneousFileProcessed: options.nbSimultaneousFileProcessed,\n configOptions: extractConfigOptions(options),\n customInstructions: options.customInstructions,\n skipIfModifiedBefore: options.skipIfModifiedBefore,\n skipIfModifiedAfter: options.skipIfModifiedAfter,\n skipIfExists: options.skipIfExists,\n })\n );\n\n /**\n * LIVE SYNC\n */\n\n const liveOptions = [\n ['--with [with...]', 'Start command in parallel with the live sync'],\n ];\n\n const liveCmd = program\n .command('live')\n .description(\n 'Live sync - Watch for changes made on the CMS and update the application content accordingly'\n );\n\n applyOptions(liveCmd, liveOptions);\n applyConfigOptions(liveCmd);\n\n liveCmd.action((options) => liveSync(options));\n\n /**\n * EDITOR\n */\n\n const editorProgram = program\n .command('editor')\n .description('Visual editor operations');\n\n const editorStartCmd = editorProgram\n .command('start')\n .description('Start the Intlayer visual editor');\n\n applyConfigOptions(editorStartCmd);\n\n editorStartCmd.action((options) => {\n startEditor({\n env: options.env,\n envFile: options.envFile,\n });\n });\n\n /**\n * TRANSFORM\n */\n const transformProgram = program\n .command('transform')\n .alias('trans')\n .description('Transform components to use Intlayer');\n\n transformProgram\n .option('-f, --file [files...]', 'List of files to transform')\n .option(\n '-o, --output-content-declarations [outputContentDeclarations]',\n 'Path to output content declaration files'\n )\n .action((options) => {\n transform({\n files: options.file,\n outputContentDeclarations: options.outputContentDeclarations,\n configOptions: extractConfigOptions(options),\n });\n });\n\n applyConfigOptions(transformProgram);\n\n program.parse(process.argv);\n\n return program;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA+BA,MAAMA,eAAa,OAAO,OAAO,KAAK,QAAQ;AAE9C,MAAa,UAAUA,eACnBC,UAAY,cAAc,OAAO,KAAK,IAAI,CAAC,GAC3C;AAEJ,MAAM,cAAc,qBAAqB,QAAQ;AAOjD,MAAM,uBAAuB;CAC3B,CAAC,wBAAwB,mBAAmB;CAC5C,CAAC,mBAAmB,cAAc;CAClC,CAAC,wBAAwB,iBAAiB;CAC1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MD,MAAM,cAAc,CAClB,CAAC,oBAAoB,+CAA+C,CACrE;CAED,MAAM,UAAU,QACb,QAAQ,OAAO,CACf,YACC,+FACD;AAEH,cAAa,SAAS,YAAY;AAClC,oBAAmB,QAAQ;AAE3B,SAAQ,QAAQ,YAAY,SAAS,QAAQ,CAAC;CAU9C,MAAM,iBAJgB,QACnB,QAAQ,SAAS,CACjB,YAAY,2BAA2B,CAGvC,QAAQ,QAAQ,CAChB,YAAY,mCAAmC;AAElD,oBAAmB,eAAe;AAElC,gBAAe,QAAQ,YAAY;AACjC,cAAY;GACV,KAAK,QAAQ;GACb,SAAS,QAAQ;GAClB,CAAC;GACF;;;;CAKF,MAAM,mBAAmB,QACtB,QAAQ,YAAY,CACpB,MAAM,QAAQ,CACd,YAAY,uCAAuC;AAEtD,kBACG,OAAO,yBAAyB,6BAA6B,CAC7D,OACC,iEACA,2CACD,CACA,QAAQ,YAAY;AACnB,YAAU;GACR,OAAO,QAAQ;GACf,2BAA2B,QAAQ;GACnC,eAAe,qBAAqB,QAAQ;GAC7C,CAAC;GACF;AAEJ,oBAAmB,iBAAiB;AAEpC,SAAQ,MAAM,QAAQ,KAAK;AAE3B,QAAO"}
|
|
1
|
+
{"version":3,"file":"cli.mjs","names":["isESModule","pathDirname","gitOptionKeys: (keyof GitOptions)[]","configurationOptionKeys: (keyof ConfigurationOptions)[]","addPrefix: boolean"],"sources":["../../src/cli.ts"],"sourcesContent":["import { dirname as pathDirname } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport type { AIOptions as BaseAIOptions } from '@intlayer/api';\nimport type { GetConfigurationOptions } from '@intlayer/config';\nimport { getConfiguration } from '@intlayer/config';\nimport { Command } from 'commander';\nimport type {\n DiffMode,\n ListGitFilesOptions,\n} from '../../chokidar/dist/types/listGitFiles';\nimport { build } from './build';\nimport { getConfig } from './config';\nimport { startEditor } from './editor';\nimport { type FillOptions, fill } from './fill/fill';\nimport { listContentDeclaration } from './listContentDeclaration';\nimport { liveSync } from './liveSync';\nimport { pull } from './pull';\nimport { push } from './push/push';\nimport { pushConfig } from './pushConfig';\nimport { reviewDoc } from './reviewDoc';\nimport { testMissingTranslations } from './test';\nimport { transform } from './transform';\nimport { translateDoc } from './translateDoc';\nimport { getParentPackageJSON } from './utils/getParentPackageJSON';\nimport { watchContentDeclaration } from './watch';\n\n// Extended AI options to include customPrompt\ntype AIOptions = BaseAIOptions & {\n customPrompt?: string;\n};\n\nconst isESModule = typeof import.meta.url === 'string';\n\nexport const dirname = isESModule\n ? pathDirname(fileURLToPath(import.meta.url))\n : __dirname;\n\nconst packageJson = getParentPackageJSON(dirname);\n\nconst logOptions = [\n ['--verbose', 'Verbose (default to true using CLI)'],\n ['--prefix [prefix]', 'Prefix'],\n];\n\nconst configurationOptions = [\n ['--env-file [envFile]', 'Environment file'],\n ['-e, --env [env]', 'Environment'],\n ['--base-dir [baseDir]', 'Base directory'],\n ['--no-cache [noCache]', 'No cache'],\n ...logOptions,\n];\n\nconst aiOptions = [\n ['--provider [provider]', 'Provider'],\n ['--temperature [temperature]', 'Temperature'],\n ['--model [model]', 'Model'],\n ['--api-key [apiKey]', 'Provider API key'],\n ['--custom-prompt [prompt]', 'Custom prompt'],\n ['--application-context [applicationContext]', 'Application context'],\n];\n\nconst gitOptions = [\n ['--git-diff [gitDiff]', 'Git diff mode - Check git diff between two refs'],\n ['--git-diff-base [gitDiffBase]', 'Git diff base ref'],\n ['--git-diff-current [gitDiffCurrent]', 'Git diff current ref'],\n ['--uncommitted [uncommitted]', 'Uncommitted'],\n ['--unpushed [unpushed]', 'Unpushed'],\n ['--untracked [untracked]', 'Untracked'],\n];\n\nconst extractKeysFromOptions = (options: object, keys: string[]) =>\n keys.filter((key) => options[key as keyof typeof options]);\n\n/**\n * Helper functions to apply common options to commands\n */\nconst applyOptions = (command: Command, options: string[][]) => {\n options.forEach(([flag, description]) => {\n command.option(flag, description);\n });\n return command;\n};\n\nconst removeUndefined = <T extends Record<string, any>>(obj: T): T =>\n Object.fromEntries(\n Object.entries(obj).filter(([_, value]) => value !== undefined)\n ) as T;\n\nconst applyConfigOptions = (command: Command) =>\n applyOptions(command, configurationOptions);\nconst applyAIOptions = (command: Command) => applyOptions(command, aiOptions);\nconst applyGitOptions = (command: Command) => applyOptions(command, gitOptions);\n\nconst extractAiOptions = (options: AIOptions): AIOptions | undefined => {\n const {\n apiKey,\n provider,\n model,\n temperature,\n applicationContext,\n customPrompt,\n } = options;\n\n const configuration = getConfiguration();\n\n return removeUndefined({\n apiKey: apiKey ?? configuration.ai?.apiKey,\n provider: provider ?? (configuration.ai?.provider as AIOptions['provider']),\n model: model ?? configuration.ai?.model,\n temperature: temperature ?? configuration.ai?.temperature,\n applicationContext:\n applicationContext ?? configuration.ai?.applicationContext,\n customPrompt: customPrompt ?? (configuration.ai as any)?.customPrompt,\n });\n};\n\ntype GitOptions = {\n gitDiff?: boolean;\n gitDiffBase?: string;\n gitDiffCurrent?: string;\n uncommitted?: boolean;\n unpushed?: boolean;\n untracked?: boolean;\n};\n\nconst gitOptionKeys: (keyof GitOptions)[] = [\n 'gitDiff',\n 'gitDiffBase',\n 'gitDiffCurrent',\n 'uncommitted',\n 'unpushed',\n 'untracked',\n];\n\nconst extractGitOptions = (\n options: GitOptions\n): ListGitFilesOptions | undefined => {\n const filteredOptions = extractKeysFromOptions(options, gitOptionKeys);\n\n const isOptionEmpty = !Object.values(filteredOptions).some(Boolean);\n\n if (isOptionEmpty) return undefined;\n\n const {\n gitDiff,\n gitDiffBase,\n gitDiffCurrent,\n uncommitted,\n unpushed,\n untracked,\n } = options;\n\n const mode = [\n gitDiff && 'gitDiff',\n uncommitted && 'uncommitted',\n unpushed && 'unpushed',\n untracked && 'untracked',\n ].filter(Boolean) as DiffMode[];\n\n return removeUndefined({\n mode,\n baseRef: gitDiffBase,\n currentRef: gitDiffCurrent,\n absolute: true,\n });\n};\n\ntype LogOptions = {\n prefix?: string;\n verbose?: boolean;\n};\n\nexport type ConfigurationOptions = {\n baseDir?: string;\n env?: string;\n envFile?: string;\n noCache?: boolean;\n} & LogOptions;\n\nconst configurationOptionKeys: (keyof ConfigurationOptions)[] = [\n 'baseDir',\n 'env',\n 'envFile',\n 'verbose',\n 'prefix',\n];\n\nconst extractConfigOptions = (\n options: ConfigurationOptions\n): GetConfigurationOptions | undefined => {\n const configuration = getConfiguration(options);\n const filteredOptions = extractKeysFromOptions(\n options,\n configurationOptionKeys\n );\n\n const isOptionEmpty = !Object.values(filteredOptions).some(Boolean);\n\n if (isOptionEmpty) {\n return undefined;\n }\n\n const { baseDir, env, envFile, verbose, prefix, noCache } = options;\n\n const addPrefix: boolean = Boolean((options as any).with); // Hack to add the prefix when the command is run in parallel\n const log = {\n prefix: (prefix ?? addPrefix) ? configuration.log.prefix : '', // Should not consider the prefix set in the intlayer configuration file\n verbose: verbose ?? true,\n };\n\n const override = {\n log,\n };\n\n return removeUndefined({\n baseDir,\n env,\n envFile,\n override,\n cache: !noCache,\n });\n};\n\n/**\n * Set the API for the CLI\n *\n * Example of commands:\n *\n * npm run intlayer build --watch\n * npm run intlayer push --dictionaries id1 id2 id3 --deleteLocaleDir\n */\nexport const setAPI = (): Command => {\n const program = new Command();\n\n program.version(packageJson.version!).description('Intlayer CLI');\n\n // Explicit version subcommand for convenience: `npx intlayer version`\n program\n .command('version')\n .description('Print the Intlayer CLI version')\n .action(() => {\n // Prefer the resolved package.json version; fallback to unknown\n // Keeping output minimal to align with common CLI behavior\n console.log(packageJson.version ?? 'unknown');\n });\n\n /**\n * DICTIONARIES\n */\n\n const dictionariesProgram = program\n .command('dictionary')\n .alias('dictionaries')\n .alias('dic')\n .description('Dictionaries operations');\n\n // Dictionary build command\n const buildOptions = {\n description: 'Build the dictionaries',\n options: [\n ['-w, --watch', 'Watch for changes'],\n ['--skip-prepare', 'Skip the prepare step'],\n ['--with [with...]', 'Start command in parallel with the build'],\n ],\n };\n\n // Add build command to dictionaries program\n const dictionariesBuildCmd = dictionariesProgram\n .command('build')\n .description(buildOptions.description);\n\n applyOptions(dictionariesBuildCmd, buildOptions.options);\n applyConfigOptions(dictionariesBuildCmd);\n dictionariesBuildCmd.action((options) => {\n build({\n ...options,\n configOptions: extractConfigOptions(options),\n });\n });\n\n // Add build command to root program as well\n const rootBuildCmd = program\n .command('build')\n .description(buildOptions.description);\n\n applyOptions(rootBuildCmd, buildOptions.options);\n applyConfigOptions(rootBuildCmd);\n rootBuildCmd.action((options) => {\n build({\n ...options,\n configOptions: extractConfigOptions(options),\n });\n });\n\n const watchOptions = {\n description: 'Watch the dictionaries changes',\n options: [['--with [with...]', 'Start command in parallel with the build']],\n };\n\n // Add build command to dictionaries program\n const dictionariesWatchCmd = dictionariesProgram\n .command('watch')\n .description(buildOptions.description);\n\n applyOptions(dictionariesWatchCmd, watchOptions.options);\n applyConfigOptions(dictionariesWatchCmd);\n dictionariesWatchCmd.action((options) => {\n watchContentDeclaration({\n ...options,\n configOptions: extractConfigOptions(options),\n });\n });\n\n // Add build command to root program as well\n const rootWatchCmd = program\n .command('watch')\n .description(buildOptions.description);\n\n applyOptions(rootWatchCmd, watchOptions.options);\n applyConfigOptions(rootWatchCmd);\n rootWatchCmd.action((options) => {\n watchContentDeclaration({\n ...options,\n configOptions: extractConfigOptions(options),\n });\n });\n\n // Dictionary pull command\n const pullOptions = {\n description: 'Pull dictionaries from the server',\n options: [\n ['-d, --dictionaries [ids...]', 'List of dictionary IDs to pull'],\n [\n '--dictionary [ids...]',\n 'List of dictionary IDs to pull (alias for --dictionaries)',\n ],\n ['--new-dictionaries-path [path]', 'Path to save the new dictionaries'],\n // Backward-compatibility for older tests/flags (camelCase)\n [\n '--newDictionariesPath [path]',\n '[alias] Path to save the new dictionaries',\n ],\n ],\n };\n\n // Add pull command to dictionaries program\n const dictionariesPullCmd = dictionariesProgram\n .command('pull')\n .description(pullOptions.description);\n\n applyOptions(dictionariesPullCmd, pullOptions.options);\n applyConfigOptions(dictionariesPullCmd);\n dictionariesPullCmd.action((options) => {\n // Merge dictionary aliases\n const dictionaries = [\n ...(options.dictionaries ?? []),\n ...(options.dictionary ?? []),\n ];\n\n pull({\n ...options,\n dictionaries: dictionaries.length > 0 ? dictionaries : undefined,\n configOptions: {\n ...options.configOptions,\n baseDir: options.baseDir,\n },\n });\n });\n\n // Add pull command to root program as well\n const rootPullCmd = program\n .command('pull')\n .description(pullOptions.description);\n\n applyOptions(rootPullCmd, pullOptions.options);\n applyConfigOptions(rootPullCmd);\n rootPullCmd.action((options) => {\n // Merge dictionary aliases\n const dictionaries = [\n ...(options.dictionaries ?? []),\n ...(options.dictionary ?? []),\n ];\n\n pull({\n ...options,\n dictionaries: dictionaries.length > 0 ? dictionaries : undefined,\n configOptions: extractConfigOptions(options),\n });\n });\n\n // Dictionary push command\n const pushOptions = {\n description:\n 'Push all dictionaries. Create or update the pushed dictionaries',\n options: [\n ['-d, --dictionaries [ids...]', 'List of dictionary IDs to push'],\n [\n '--dictionary [ids...]',\n 'List of dictionary IDs to push (alias for --dictionaries)',\n ],\n [\n '-r, --delete-locale-dictionary',\n 'Delete the local dictionaries after pushing',\n ],\n [\n '-k, --keep-locale-dictionary',\n 'Keep the local dictionaries after pushing',\n ],\n // Backward-compatibility for older tests/flags (camelCase)\n [\n '--deleteLocaleDictionary',\n '[alias] Delete the local dictionaries after pushing',\n ],\n [\n '--keepLocaleDictionary',\n '[alias] Keep the local dictionaries after pushing',\n ],\n [\n '--build [build]',\n 'Build the dictionaries before pushing to ensure the content is up to date. True will force the build, false will skip the build, undefined will allow using the cache of the build',\n ],\n ],\n };\n\n // Add push command to dictionaries program\n const dictionariesPushCmd = dictionariesProgram\n .command('push')\n .description(pushOptions.description);\n\n applyOptions(dictionariesPushCmd, pushOptions.options);\n applyConfigOptions(dictionariesPushCmd);\n applyGitOptions(dictionariesPushCmd);\n\n dictionariesPushCmd.action((options) => {\n // Merge dictionary aliases\n const dictionaries = [\n ...(options.dictionaries || []),\n ...(options.dictionary || []),\n ];\n\n return push({\n ...options,\n dictionaries: dictionaries.length > 0 ? dictionaries : undefined,\n gitOptions: extractGitOptions(options),\n configOptions: extractConfigOptions(options),\n } as FillOptions);\n });\n\n // Add push command to root program as well\n const rootPushCmd = program\n .command('push')\n .description(pushOptions.description);\n\n applyOptions(rootPushCmd, pushOptions.options);\n applyConfigOptions(rootPushCmd);\n applyGitOptions(rootPushCmd);\n\n rootPushCmd.action((options) => {\n // Merge dictionary aliases\n const dictionaries = [\n ...(options.dictionaries || []),\n ...(options.dictionary || []),\n ];\n\n return push({\n ...options,\n dictionaries: dictionaries.length > 0 ? dictionaries : undefined,\n gitOptions: extractGitOptions(options),\n configOptions: extractConfigOptions(options),\n } as FillOptions);\n });\n\n /**\n * CONFIGURATION\n */\n\n // Define the parent command\n const configurationProgram = program\n .command('configuration')\n .alias('config')\n .alias('conf')\n .description('Configuration operations');\n\n const configGetCmd = configurationProgram\n .command('get')\n .description('Get the configuration');\n\n applyConfigOptions(configGetCmd);\n configGetCmd.action((options) => {\n getConfig({\n ...options,\n configOptions: extractConfigOptions(options),\n });\n });\n\n // Define the `push config` subcommand and add it to the `push` command\n const configPushCmd = configurationProgram\n .command('push')\n .description('Push the configuration');\n\n applyConfigOptions(configPushCmd);\n configPushCmd.action((options) => {\n pushConfig({\n ...options,\n configOptions: extractConfigOptions(options),\n });\n });\n\n /**\n * CONTENT DECLARATION\n */\n\n const contentProgram = program\n .command('content')\n .description('Content declaration operations');\n\n contentProgram\n .command('list')\n .description('List the content declaration files')\n .action(listContentDeclaration);\n\n // Add alias for content list command\n program\n .command('list')\n .description('List the content declaration files')\n .action(listContentDeclaration);\n\n const testProgram = contentProgram\n .command('test')\n .description('Test if there are missing translations')\n .option(\n '--build [build]',\n 'Build the dictionaries before testing to ensure the content is up to date. True will force the build, false will skip the build, undefined will allow using the cache of the build'\n );\n\n applyConfigOptions(testProgram);\n testProgram.action((options) => {\n testMissingTranslations({\n ...options,\n configOptions: extractConfigOptions(options),\n });\n });\n\n // Add alias for content test command\n const rootTestCmd = program\n .command('test')\n .description('Test if there are missing translations')\n .option(\n '--build [build]',\n 'Build the dictionaries before testing to ensure the content is up to date. True will force the build, false will skip the build, undefined will allow using the cache of the build'\n );\n\n applyConfigOptions(rootTestCmd);\n rootTestCmd.action((options) => {\n testMissingTranslations({\n ...options,\n configOptions: extractConfigOptions(options),\n });\n });\n\n const fillProgram = program\n .command('fill')\n .description('Fill the dictionaries')\n .option('-f, --file [files...]', 'List of Dictionary files to fill')\n .option('--source-locale [sourceLocale]', 'Source locale to translate from')\n .option(\n '--output-locales [outputLocales...]',\n 'Target locales to translate to'\n )\n .option(\n '--mode [mode]',\n 'Fill mode: complete, review. Complete will fill all missing content, review will fill missing content and review existing keys',\n 'complete'\n )\n .option('-k, --keys [keys...]', 'Filter dictionaries based on keys')\n .option(\n '--key [keys...]',\n 'Filter dictionaries based on keys (alias for --keys)'\n )\n .option(\n '--excluded-keys [excludedKeys...]',\n 'Filter out dictionaries based on keys'\n )\n .option(\n '--excluded-key [excludedKeys...]',\n 'Filter out dictionaries based on keys (alias for --excluded-keys)'\n )\n .option(\n '--path-filter [pathFilters...]',\n 'Filter dictionaries based on glob pattern'\n )\n .option(\n '--build [build]',\n 'Build the dictionaries before filling to ensure the content is up to date. True will force the build, false will skip the build, undefined will allow using the cache of the build'\n )\n .option(\n '--skip-metadata',\n 'Skip filling missing metadata (description, title, tags) for dictionaries'\n );\n\n applyConfigOptions(fillProgram);\n applyAIOptions(fillProgram);\n applyGitOptions(fillProgram);\n\n fillProgram.action((options) => {\n // Merge key aliases\n const keys = [...(options.keys ?? []), ...(options.key ?? [])];\n const excludedKeys = [\n ...(options.excludedKeys ?? []),\n ...(options.excludedKey ?? []),\n ];\n // Merge dictionary aliases\n const dictionaries = [\n ...(options.dictionaries ?? []),\n ...(options.dictionary ?? []),\n ];\n\n return fill({\n ...options,\n keys: keys.length > 0 ? keys : undefined,\n excludedKeys: excludedKeys.length > 0 ? excludedKeys : undefined,\n dictionaries: dictionaries.length > 0 ? dictionaries : undefined,\n aiOptions: extractAiOptions(options),\n gitOptions: extractGitOptions(options),\n configOptions: extractConfigOptions(options),\n } as FillOptions);\n });\n\n /**\n * DOCS\n */\n\n const docParams = [\n ['--doc-pattern [docPattern...]', 'Documentation pattern'],\n [\n '--excluded-glob-pattern [excludedGlobPattern...]',\n 'Excluded glob pattern',\n ],\n [\n '--nb-simultaneous-file-processed [nbSimultaneousFileProcessed]',\n 'Number of simultaneous file processed',\n ],\n ['--locales [locales...]', 'Locales'],\n ['--base-locale [baseLocale]', 'Base locale'],\n [\n '--custom-instructions [customInstructions]',\n 'Custom instructions added to the prompt. Usefull to apply specific rules regarding formatting, urls translation, etc.',\n ],\n [\n '--skip-if-modified-before [skipIfModifiedBefore]',\n 'Skip the file if it has been modified before the given time. Can be an absolute time as \"2025-12-05\" (string or Date) or a relative time in ms `1 * 60 * 60 * 1000` (1 hour). This option check update time of the file using the `fs.stat` method. So it could be impacted by Git or other tools that modify the file.',\n ],\n [\n '--skip-if-modified-after [skipIfModifiedAfter]',\n 'Skip the file if it has been modified within the given time. Can be an absolute time as \"2025-12-05\" (string or Date) or a relative time in ms `1 * 60 * 60 * 1000` (1 hour). This option check update time of the file using the `fs.stat` method. So it could be impacted by Git or other tools that modify the file.',\n ],\n ['--skip-if-exists', 'Skip the file if it already exists'],\n ];\n\n const docProgram = program\n .command('doc')\n .description('Documentation operations');\n\n const translateProgram = docProgram\n .command('translate')\n .description('Translate the documentation');\n\n applyConfigOptions(translateProgram);\n applyAIOptions(translateProgram);\n applyGitOptions(translateProgram);\n applyOptions(translateProgram, docParams);\n\n translateProgram.action((options) =>\n translateDoc({\n docPattern: options.docPattern,\n excludedGlobPattern: options.excludedGlobPattern,\n locales: options.locales,\n baseLocale: options.baseLocale,\n aiOptions: extractAiOptions(options),\n gitOptions: extractGitOptions(options),\n nbSimultaneousFileProcessed: options.nbSimultaneousFileProcessed,\n configOptions: extractConfigOptions(options),\n customInstructions: options.customInstructions,\n skipIfModifiedBefore: options.skipIfModifiedBefore,\n skipIfModifiedAfter: options.skipIfModifiedAfter,\n skipIfExists: options.skipIfExists,\n })\n );\n\n const reviewProgram = docProgram\n .command('review')\n .description('Review the documentation');\n\n applyConfigOptions(reviewProgram);\n applyAIOptions(reviewProgram);\n applyGitOptions(reviewProgram);\n applyOptions(reviewProgram, docParams);\n\n reviewProgram.action((options) =>\n reviewDoc({\n docPattern: options.docPattern,\n excludedGlobPattern: options.excludedGlobPattern,\n locales: options.locales,\n baseLocale: options.baseLocale,\n aiOptions: extractAiOptions(options),\n gitOptions: extractGitOptions(options),\n nbSimultaneousFileProcessed: options.nbSimultaneousFileProcessed,\n configOptions: extractConfigOptions(options),\n customInstructions: options.customInstructions,\n skipIfModifiedBefore: options.skipIfModifiedBefore,\n skipIfModifiedAfter: options.skipIfModifiedAfter,\n skipIfExists: options.skipIfExists,\n })\n );\n\n /**\n * LIVE SYNC\n */\n\n const liveOptions = [\n ['--with [with...]', 'Start command in parallel with the live sync'],\n ];\n\n const liveCmd = program\n .command('live')\n .description(\n 'Live sync - Watch for changes made on the CMS and update the application content accordingly'\n );\n\n applyOptions(liveCmd, liveOptions);\n applyConfigOptions(liveCmd);\n\n liveCmd.action((options) => liveSync(options));\n\n /**\n * EDITOR\n */\n\n const editorProgram = program\n .command('editor')\n .description('Visual editor operations');\n\n const editorStartCmd = editorProgram\n .command('start')\n .description('Start the Intlayer visual editor');\n\n applyConfigOptions(editorStartCmd);\n\n editorStartCmd.action((options) => {\n startEditor({\n env: options.env,\n envFile: options.envFile,\n });\n });\n\n /**\n * TRANSFORM\n */\n const transformProgram = program\n .command('transform')\n .alias('trans')\n .description('Transform components to use Intlayer');\n\n transformProgram\n .option('-f, --file [files...]', 'List of files to transform')\n .option(\n '-o, --output-content-declarations [outputContentDeclarations]',\n 'Path to output content declaration files'\n )\n .option('--code-only', 'Only transform the component code', false)\n .option('--declaration-only', 'Only generate content declaration', false)\n .action((options) => {\n transform({\n files: options.file,\n outputContentDeclarations: options.outputContentDeclarations,\n configOptions: extractConfigOptions(options),\n codeOnly: options.codeOnly,\n declarationOnly: options.declarationOnly,\n });\n });\n\n applyConfigOptions(transformProgram);\n\n program.parse(process.argv);\n\n return program;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA+BA,MAAMA,eAAa,OAAO,OAAO,KAAK,QAAQ;AAE9C,MAAa,UAAUA,eACnBC,UAAY,cAAc,OAAO,KAAK,IAAI,CAAC,GAC3C;AAEJ,MAAM,cAAc,qBAAqB,QAAQ;AAOjD,MAAM,uBAAuB;CAC3B,CAAC,wBAAwB,mBAAmB;CAC5C,CAAC,mBAAmB,cAAc;CAClC,CAAC,wBAAwB,iBAAiB;CAC1C,CAAC,wBAAwB,WAAW;CACpC,GAViB,CACjB,CAAC,aAAa,sCAAsC,EACpD,CAAC,qBAAqB,SAAS,CAChC;CAQA;AAED,MAAM,YAAY;CAChB,CAAC,yBAAyB,WAAW;CACrC,CAAC,+BAA+B,cAAc;CAC9C,CAAC,mBAAmB,QAAQ;CAC5B,CAAC,sBAAsB,mBAAmB;CAC1C,CAAC,4BAA4B,gBAAgB;CAC7C,CAAC,8CAA8C,sBAAsB;CACtE;AAED,MAAM,aAAa;CACjB,CAAC,wBAAwB,kDAAkD;CAC3E,CAAC,iCAAiC,oBAAoB;CACtD,CAAC,uCAAuC,uBAAuB;CAC/D,CAAC,+BAA+B,cAAc;CAC9C,CAAC,yBAAyB,WAAW;CACrC,CAAC,2BAA2B,YAAY;CACzC;AAED,MAAM,0BAA0B,SAAiB,SAC/C,KAAK,QAAQ,QAAQ,QAAQ,KAA6B;;;;AAK5D,MAAM,gBAAgB,SAAkB,YAAwB;AAC9D,SAAQ,SAAS,CAAC,MAAM,iBAAiB;AACvC,UAAQ,OAAO,MAAM,YAAY;GACjC;AACF,QAAO;;AAGT,MAAM,mBAAkD,QACtD,OAAO,YACL,OAAO,QAAQ,IAAI,CAAC,QAAQ,CAAC,GAAG,WAAW,UAAU,OAAU,CAChE;AAEH,MAAM,sBAAsB,YAC1B,aAAa,SAAS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K;AAE3B,QAAO"}
|
package/dist/esm/fill/fill.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ensureArray, getTargetUnmergedDictionaries } from "../getTargetDictionary.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { setupAI } from "../utils/setupAI.mjs";
|
|
3
3
|
import { listTranslationsTasks } from "./listTranslationsTasks.mjs";
|
|
4
4
|
import { translateDictionary } from "./translateDictionary.mjs";
|
|
5
5
|
import { writeFill } from "./writeFill.mjs";
|
|
6
6
|
import { formatPath, getGlobalLimiter, getTaskLimiter, prepareIntlayer, writeContentDeclaration } from "@intlayer/chokidar";
|
|
7
|
-
import { ANSIColors,
|
|
7
|
+
import { ANSIColors, colorize, colorizeKey, colorizePath, getAppLogger, getConfiguration } from "@intlayer/config";
|
|
8
8
|
import { basename, relative } from "node:path";
|
|
9
9
|
|
|
10
10
|
//#region src/fill/fill.ts
|
|
@@ -21,7 +21,9 @@ const fill = async (options) => {
|
|
|
21
21
|
const mode = options?.mode ?? "complete";
|
|
22
22
|
const baseLocale = options?.sourceLocale ?? defaultLocale;
|
|
23
23
|
const outputLocales = options?.outputLocales ? ensureArray(options.outputLocales) : locales;
|
|
24
|
-
|
|
24
|
+
const aiResult = await setupAI(configuration, options?.aiOptions);
|
|
25
|
+
if (!aiResult?.hasAIAccess) return;
|
|
26
|
+
const { aiClient, aiConfig } = aiResult;
|
|
25
27
|
const targetUnmergedDictionaries = await getTargetUnmergedDictionaries(options);
|
|
26
28
|
const affectedDictionaryKeys = /* @__PURE__ */ new Set();
|
|
27
29
|
targetUnmergedDictionaries.forEach((dict) => {
|
|
@@ -48,19 +50,16 @@ const fill = async (options) => {
|
|
|
48
50
|
mode,
|
|
49
51
|
aiOptions: options?.aiOptions,
|
|
50
52
|
fillMetadata: !options?.skipMetadata,
|
|
51
|
-
onHandle: globalLimiter
|
|
53
|
+
onHandle: globalLimiter,
|
|
54
|
+
aiClient,
|
|
55
|
+
aiConfig
|
|
52
56
|
});
|
|
53
57
|
if (!translationTaskResult?.dictionaryOutput) return;
|
|
54
58
|
const { dictionaryOutput, sourceLocale } = translationTaskResult;
|
|
55
|
-
if (typeof dictionaryOutput.fill === "string" || typeof dictionaryOutput.fill === "object") await writeFill(dictionaryOutput, outputLocales, [sourceLocale], configuration);
|
|
59
|
+
if (typeof dictionaryOutput.fill === "string" || typeof dictionaryOutput.fill === "object" || typeof dictionaryOutput.locale === "string" && dictionaryOutput.fill !== false) await writeFill(dictionaryOutput, outputLocales, [sourceLocale], configuration);
|
|
56
60
|
else {
|
|
57
61
|
await writeContentDeclaration(dictionaryOutput, configuration);
|
|
58
|
-
if (dictionaryOutput.filePath) appLogger(`${
|
|
59
|
-
" - ",
|
|
60
|
-
colorize("[", ANSIColors.GREY_DARK),
|
|
61
|
-
colorizeKey(dictionaryOutput.key),
|
|
62
|
-
colorize("]", ANSIColors.GREY_DARK)
|
|
63
|
-
].join(""), { colSize: 15 })} Content declaration written to ${formatPath(basename(dictionaryOutput.filePath))}`, { level: "info" });
|
|
62
|
+
if (dictionaryOutput.filePath) appLogger(`${task.dictionaryPreset} Content declaration written to ${formatPath(basename(dictionaryOutput.filePath))}`, { level: "info" });
|
|
64
63
|
}
|
|
65
64
|
}));
|
|
66
65
|
await Promise.all(runners);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fill.mjs","names":["translationTasks: TranslationTask[]"],"sources":["../../../src/fill/fill.ts"],"sourcesContent":["import { basename, relative } from 'node:path';\nimport type { AIOptions } from '@intlayer/api';\nimport {\n formatPath,\n getGlobalLimiter,\n getTaskLimiter,\n type ListGitFilesOptions,\n prepareIntlayer,\n writeContentDeclaration,\n} from '@intlayer/chokidar';\nimport {\n ANSIColors,\n
|
|
1
|
+
{"version":3,"file":"fill.mjs","names":["translationTasks: TranslationTask[]"],"sources":["../../../src/fill/fill.ts"],"sourcesContent":["import { basename, relative } from 'node:path';\nimport type { AIOptions } from '@intlayer/api';\nimport {\n formatPath,\n getGlobalLimiter,\n getTaskLimiter,\n type ListGitFilesOptions,\n prepareIntlayer,\n writeContentDeclaration,\n} from '@intlayer/chokidar';\nimport {\n ANSIColors,\n colorize,\n colorizeKey,\n colorizePath,\n getAppLogger,\n getConfiguration,\n} from '@intlayer/config';\nimport type { Locale } from '@intlayer/types';\nimport {\n ensureArray,\n type GetTargetDictionaryOptions,\n getTargetUnmergedDictionaries,\n} from '../getTargetDictionary';\nimport { setupAI } from '../utils/setupAI';\nimport {\n listTranslationsTasks,\n type TranslationTask,\n} from './listTranslationsTasks';\nimport { translateDictionary } from './translateDictionary';\nimport { writeFill } from './writeFill';\n\nconst NB_CONCURRENT_TRANSLATIONS = 7;\n\n// Arguments for the fill function\nexport type FillOptions = {\n sourceLocale?: Locale;\n outputLocales?: Locale | Locale[];\n mode?: 'complete' | 'review';\n gitOptions?: ListGitFilesOptions;\n aiOptions?: AIOptions; // Added aiOptions to be passed to translateJSON\n verbose?: boolean;\n nbConcurrentTranslations?: number;\n nbConcurrentTasks?: number; // NEW: number of tasks that may run at once\n build?: boolean;\n skipMetadata?: boolean;\n} & GetTargetDictionaryOptions;\n\n/**\n * Fill translations based on the provided options.\n */\nexport const fill = async (options?: FillOptions): Promise<void> => {\n const configuration = getConfiguration(options?.configOptions);\n const appLogger = getAppLogger(configuration);\n\n if (options?.build === true) {\n await prepareIntlayer(configuration, { forceRun: true });\n } else if (typeof options?.build === 'undefined') {\n await prepareIntlayer(configuration);\n }\n\n const { defaultLocale, locales } = configuration.internationalization;\n const mode = options?.mode ?? 'complete';\n const baseLocale = options?.sourceLocale ?? defaultLocale;\n\n const outputLocales = options?.outputLocales\n ? ensureArray(options.outputLocales)\n : locales;\n\n const aiResult = await setupAI(configuration, options?.aiOptions);\n\n if (!aiResult?.hasAIAccess) return;\n\n const { aiClient, aiConfig } = aiResult;\n\n const targetUnmergedDictionaries =\n await getTargetUnmergedDictionaries(options);\n\n const affectedDictionaryKeys = new Set<string>();\n targetUnmergedDictionaries.forEach((dict) => {\n affectedDictionaryKeys.add(dict.key);\n });\n\n const keysToProcess = Array.from(affectedDictionaryKeys);\n\n appLogger([\n 'Affected dictionary keys for processing:',\n keysToProcess.length > 0\n ? keysToProcess.map((key) => colorizeKey(key)).join(', ')\n : colorize('No keys found', ANSIColors.YELLOW),\n ]);\n\n if (keysToProcess.length === 0) return;\n\n /**\n * List the translations tasks\n *\n * Create a list of per-locale dictionaries to translate\n *\n * In 'complete' mode, filter only the missing locales to translate\n */\n const translationTasks: TranslationTask[] = listTranslationsTasks(\n targetUnmergedDictionaries.map((dictionary) => dictionary.localId!),\n outputLocales,\n mode,\n baseLocale,\n configuration\n );\n\n // AI calls in flight at once (translateJSON + metadata audit)\n const nbConcurrentTranslations =\n options?.nbConcurrentTranslations ?? NB_CONCURRENT_TRANSLATIONS;\n const globalLimiter = getGlobalLimiter(nbConcurrentTranslations);\n\n // NEW: number of *tasks* that may run at once (start/prepare/log/write)\n const nbConcurrentTasks = Math.max(\n 1,\n Math.min(\n options?.nbConcurrentTasks ?? nbConcurrentTranslations,\n translationTasks.length\n )\n );\n\n const taskLimiter = getTaskLimiter(nbConcurrentTasks);\n\n const runners = translationTasks.map((task) =>\n taskLimiter(async () => {\n const relativePath = relative(\n configuration?.content?.baseDir ?? process.cwd(),\n task?.dictionaryFilePath ?? ''\n );\n\n // log AFTER acquiring a task slot\n appLogger(\n `${task.dictionaryPreset} Processing ${colorizePath(basename(relativePath))}`,\n { level: 'info' }\n );\n\n const translationTaskResult = await translateDictionary(\n task,\n configuration,\n {\n mode,\n aiOptions: options?.aiOptions,\n fillMetadata: !options?.skipMetadata,\n onHandle: globalLimiter, // <= AI calls go through here\n aiClient,\n aiConfig,\n }\n );\n\n if (!translationTaskResult?.dictionaryOutput) return;\n\n const { dictionaryOutput, sourceLocale } = translationTaskResult;\n\n const isFillOtherFile =\n typeof dictionaryOutput.fill === 'string' ||\n typeof dictionaryOutput.fill === 'object' ||\n (typeof dictionaryOutput.locale === 'string' &&\n dictionaryOutput.fill !== false);\n\n if (isFillOtherFile) {\n await writeFill(\n dictionaryOutput,\n outputLocales,\n [sourceLocale],\n configuration\n );\n } else {\n await writeContentDeclaration(dictionaryOutput, configuration);\n\n if (dictionaryOutput.filePath) {\n appLogger(\n `${task.dictionaryPreset} Content declaration written to ${formatPath(basename(dictionaryOutput.filePath))}`,\n { level: 'info' }\n );\n }\n }\n })\n );\n\n await Promise.all(runners);\n await (globalLimiter as any).onIdle();\n};\n"],"mappings":";;;;;;;;;;AAgCA,MAAM,6BAA6B;;;;AAmBnC,MAAa,OAAO,OAAO,YAAyC;CAClE,MAAM,gBAAgB,iBAAiB,SAAS,cAAc;CAC9D,MAAM,YAAY,aAAa,cAAc;AAE7C,KAAI,SAAS,UAAU,KACrB,OAAM,gBAAgB,eAAe,EAAE,UAAU,MAAM,CAAC;UAC/C,OAAO,SAAS,UAAU,YACnC,OAAM,gBAAgB,cAAc;CAGtC,MAAM,EAAE,eAAe,YAAY,cAAc;CACjD,MAAM,OAAO,SAAS,QAAQ;CAC9B,MAAM,aAAa,SAAS,gBAAgB;CAE5C,MAAM,gBAAgB,SAAS,gBAC3B,YAAY,QAAQ,cAAc,GAClC;CAEJ,MAAM,WAAW,MAAM,QAAQ,eAAe,SAAS,UAAU;AAEjE,KAAI,CAAC,UAAU,YAAa;CAE5B,MAAM,EAAE,UAAU,aAAa;CAE/B,MAAM,6BACJ,MAAM,8BAA8B,QAAQ;CAE9C,MAAM,yCAAyB,IAAI,KAAa;AAChD,4BAA2B,SAAS,SAAS;AAC3C,yBAAuB,IAAI,KAAK,IAAI;GACpC;CAEF,MAAM,gBAAgB,MAAM,KAAK,uBAAuB;AAExD,WAAU,CACR,4CACA,cAAc,SAAS,IACnB,cAAc,KAAK,QAAQ,YAAY,IAAI,CAAC,CAAC,KAAK,KAAK,GACvD,SAAS,iBAAiB,WAAW,OAAO,CACjD,CAAC;AAEF,KAAI,cAAc,WAAW,EAAG;;;;;;;;CAShC,MAAMA,mBAAsC,sBAC1C,2BAA2B,KAAK,eAAe,WAAW,QAAS,EACnE,eACA,MACA,YACA,cACD;CAGD,MAAM,2BACJ,SAAS,4BAA4B;CACvC,MAAM,gBAAgB,iBAAiB,yBAAyB;CAWhE,MAAM,cAAc,eARM,KAAK,IAC7B,GACA,KAAK,IACH,SAAS,qBAAqB,0BAC9B,iBAAiB,OAClB,CACF,CAEoD;CAErD,MAAM,UAAU,iBAAiB,KAAK,SACpC,YAAY,YAAY;EACtB,MAAM,eAAe,SACnB,eAAe,SAAS,WAAW,QAAQ,KAAK,EAChD,MAAM,sBAAsB,GAC7B;AAGD,YACE,GAAG,KAAK,iBAAiB,cAAc,aAAa,SAAS,aAAa,CAAC,IAC3E,EAAE,OAAO,QAAQ,CAClB;EAED,MAAM,wBAAwB,MAAM,oBAClC,MACA,eACA;GACE;GACA,WAAW,SAAS;GACpB,cAAc,CAAC,SAAS;GACxB,UAAU;GACV;GACA;GACD,CACF;AAED,MAAI,CAAC,uBAAuB,iBAAkB;EAE9C,MAAM,EAAE,kBAAkB,iBAAiB;AAQ3C,MALE,OAAO,iBAAiB,SAAS,YACjC,OAAO,iBAAiB,SAAS,YAChC,OAAO,iBAAiB,WAAW,YAClC,iBAAiB,SAAS,MAG5B,OAAM,UACJ,kBACA,eACA,CAAC,aAAa,EACd,cACD;OACI;AACL,SAAM,wBAAwB,kBAAkB,cAAc;AAE9D,OAAI,iBAAiB,SACnB,WACE,GAAG,KAAK,iBAAiB,kCAAkC,WAAW,SAAS,iBAAiB,SAAS,CAAC,IAC1G,EAAE,OAAO,QAAQ,CAClB;;GAGL,CACH;AAED,OAAM,QAAQ,IAAI,QAAQ;AAC1B,OAAO,cAAsB,QAAQ"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { formatAutoFilledFilePath } from "./formatAutoFilledFilePath.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/fill/formatFillData.ts
|
|
4
|
-
const formatFillData = (
|
|
4
|
+
const formatFillData = (fillField, localeList, filePath, dictionaryKey, configuration) => {
|
|
5
5
|
const outputContentDeclarationFile = [];
|
|
6
6
|
const baseDir = configuration.content.baseDir;
|
|
7
|
-
if (!
|
|
8
|
-
if (typeof
|
|
9
|
-
if (
|
|
7
|
+
if (!fillField) return outputContentDeclarationFile;
|
|
8
|
+
if (typeof fillField === "string") {
|
|
9
|
+
if (fillField.includes("{{locale}}")) {
|
|
10
10
|
const output = localeList.map((locale) => {
|
|
11
|
-
const formattedFilePath = formatAutoFilledFilePath(
|
|
11
|
+
const formattedFilePath = formatAutoFilledFilePath(fillField, dictionaryKey, filePath, baseDir, locale);
|
|
12
12
|
return {
|
|
13
13
|
localeList: [locale],
|
|
14
14
|
filePath: formattedFilePath,
|
|
@@ -17,7 +17,7 @@ const formatFillData = (autoFillField, localeList, filePath, dictionaryKey, conf
|
|
|
17
17
|
});
|
|
18
18
|
outputContentDeclarationFile.push(...output);
|
|
19
19
|
} else {
|
|
20
|
-
const formattedFilePath = formatAutoFilledFilePath(
|
|
20
|
+
const formattedFilePath = formatAutoFilledFilePath(fillField, dictionaryKey, filePath, baseDir);
|
|
21
21
|
outputContentDeclarationFile.push({
|
|
22
22
|
localeList,
|
|
23
23
|
filePath: formattedFilePath,
|
|
@@ -26,9 +26,9 @@ const formatFillData = (autoFillField, localeList, filePath, dictionaryKey, conf
|
|
|
26
26
|
}
|
|
27
27
|
return outputContentDeclarationFile;
|
|
28
28
|
}
|
|
29
|
-
if (typeof
|
|
30
|
-
const groupedByFilePath = Object.keys(
|
|
31
|
-
const formattedFilePath = formatAutoFilledFilePath(
|
|
29
|
+
if (typeof fillField === "object") {
|
|
30
|
+
const groupedByFilePath = Object.keys(fillField).filter((locale) => typeof fillField[locale] === "string").filter((locale) => Boolean(fillField[locale])).map((locale) => {
|
|
31
|
+
const formattedFilePath = formatAutoFilledFilePath(fillField[locale], dictionaryKey, filePath, baseDir, locale);
|
|
32
32
|
return {
|
|
33
33
|
localeList: [locale],
|
|
34
34
|
filePath: formattedFilePath,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatFillData.mjs","names":["outputContentDeclarationFile: FillData[]"],"sources":["../../../src/fill/formatFillData.ts"],"sourcesContent":["import type { Fill, IntlayerConfig, LocalesValues } from '@intlayer/types';\nimport { formatAutoFilledFilePath } from './formatAutoFilledFilePath';\n\nexport type FillData = {\n localeList: LocalesValues[];\n filePath: string;\n isPerLocale: boolean;\n};\n\nexport const formatFillData = (\n
|
|
1
|
+
{"version":3,"file":"formatFillData.mjs","names":["outputContentDeclarationFile: FillData[]"],"sources":["../../../src/fill/formatFillData.ts"],"sourcesContent":["import type { Fill, IntlayerConfig, LocalesValues } from '@intlayer/types';\nimport { formatAutoFilledFilePath } from './formatAutoFilledFilePath';\n\nexport type FillData = {\n localeList: LocalesValues[];\n filePath: string;\n isPerLocale: boolean;\n};\n\nexport const formatFillData = (\n fillField: Fill,\n localeList: LocalesValues[],\n filePath: string,\n dictionaryKey: string,\n configuration: IntlayerConfig\n): FillData[] => {\n const outputContentDeclarationFile: FillData[] = [];\n\n const baseDir = configuration.content.baseDir;\n\n if (!fillField) return outputContentDeclarationFile;\n\n if (typeof fillField === 'string') {\n if (fillField.includes('{{locale}}')) {\n const output = localeList.map((locale) => {\n const formattedFilePath = formatAutoFilledFilePath(\n fillField,\n dictionaryKey,\n filePath,\n baseDir,\n locale\n );\n\n return {\n localeList: [locale],\n filePath: formattedFilePath,\n isPerLocale: true,\n };\n });\n\n outputContentDeclarationFile.push(...output);\n } else {\n const formattedFilePath = formatAutoFilledFilePath(\n fillField,\n dictionaryKey,\n filePath,\n baseDir\n );\n\n outputContentDeclarationFile.push({\n localeList,\n filePath: formattedFilePath,\n isPerLocale: false,\n });\n }\n\n return outputContentDeclarationFile;\n }\n\n if (typeof fillField === 'object') {\n const localeList = Object.keys(fillField).filter(\n (locale) =>\n typeof fillField[locale as keyof typeof fillField] === 'string'\n ) as LocalesValues[];\n\n const output: FillData[] = localeList\n .filter((locale) => Boolean(fillField[locale as keyof typeof fillField]))\n .map((locale) => {\n const formattedFilePath = formatAutoFilledFilePath(\n fillField[locale as keyof typeof fillField] as string,\n dictionaryKey,\n filePath,\n baseDir,\n locale\n );\n\n return {\n localeList: [locale],\n filePath: formattedFilePath,\n isPerLocale: true,\n };\n });\n\n // Group by filePath and merge localeList\n const groupedByFilePath = output.reduce((acc, curr) => {\n const existing = acc.find((item) => item.filePath === curr.filePath);\n if (existing) {\n existing.localeList.push(...curr.localeList);\n } else {\n acc.push(curr);\n }\n return acc;\n }, [] as FillData[]);\n\n outputContentDeclarationFile.push(...groupedByFilePath);\n }\n\n return outputContentDeclarationFile;\n};\n"],"mappings":";;;AASA,MAAa,kBACX,WACA,YACA,UACA,eACA,kBACe;CACf,MAAMA,+BAA2C,EAAE;CAEnD,MAAM,UAAU,cAAc,QAAQ;AAEtC,KAAI,CAAC,UAAW,QAAO;AAEvB,KAAI,OAAO,cAAc,UAAU;AACjC,MAAI,UAAU,SAAS,aAAa,EAAE;GACpC,MAAM,SAAS,WAAW,KAAK,WAAW;IACxC,MAAM,oBAAoB,yBACxB,WACA,eACA,UACA,SACA,OACD;AAED,WAAO;KACL,YAAY,CAAC,OAAO;KACpB,UAAU;KACV,aAAa;KACd;KACD;AAEF,gCAA6B,KAAK,GAAG,OAAO;SACvC;GACL,MAAM,oBAAoB,yBACxB,WACA,eACA,UACA,QACD;AAED,gCAA6B,KAAK;IAChC;IACA,UAAU;IACV,aAAa;IACd,CAAC;;AAGJ,SAAO;;AAGT,KAAI,OAAO,cAAc,UAAU;EAyBjC,MAAM,oBAxBa,OAAO,KAAK,UAAU,CAAC,QACvC,WACC,OAAO,UAAU,YAAsC,SAC1D,CAGE,QAAQ,WAAW,QAAQ,UAAU,QAAkC,CAAC,CACxE,KAAK,WAAW;GACf,MAAM,oBAAoB,yBACxB,UAAU,SACV,eACA,UACA,SACA,OACD;AAED,UAAO;IACL,YAAY,CAAC,OAAO;IACpB,UAAU;IACV,aAAa;IACd;IACD,CAG6B,QAAQ,KAAK,SAAS;GACrD,MAAM,WAAW,IAAI,MAAM,SAAS,KAAK,aAAa,KAAK,SAAS;AACpE,OAAI,SACF,UAAS,WAAW,KAAK,GAAG,KAAK,WAAW;OAE5C,KAAI,KAAK,KAAK;AAEhB,UAAO;KACN,EAAE,CAAe;AAEpB,+BAA6B,KAAK,GAAG,kBAAkB;;AAGzD,QAAO"}
|