@intlayer/cli 7.5.11 → 7.5.12
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/dist/cjs/cli.cjs +4 -4
- package/dist/cjs/cli.cjs.map +1 -1
- package/dist/cjs/index.cjs +4 -5
- package/dist/cjs/{reviewDoc.cjs → reviewDoc/reviewDoc.cjs} +17 -15
- package/dist/cjs/reviewDoc/reviewDoc.cjs.map +1 -0
- package/dist/cjs/{reviewDocBlockAware.cjs → reviewDoc/reviewDocBlockAware.cjs} +12 -8
- package/dist/cjs/reviewDoc/reviewDocBlockAware.cjs.map +1 -0
- package/dist/cjs/translateDoc/index.cjs +8 -0
- package/dist/cjs/translateDoc/translateDoc.cjs +74 -0
- package/dist/cjs/translateDoc/translateDoc.cjs.map +1 -0
- package/dist/cjs/translateDoc/translateFile.cjs +103 -0
- package/dist/cjs/translateDoc/translateFile.cjs.map +1 -0
- package/dist/cjs/translateDoc/types.cjs +0 -0
- package/dist/cjs/translateDoc/validation.cjs +49 -0
- package/dist/cjs/translateDoc/validation.cjs.map +1 -0
- package/dist/cjs/translation-alignment/planActions.cjs +2 -4
- package/dist/cjs/translation-alignment/planActions.cjs.map +1 -1
- package/dist/cjs/translation-alignment/segmentDocument.cjs +35 -101
- package/dist/cjs/translation-alignment/segmentDocument.cjs.map +1 -1
- package/dist/esm/cli.mjs +2 -2
- package/dist/esm/cli.mjs.map +1 -1
- package/dist/esm/index.mjs +3 -3
- package/dist/esm/{reviewDoc.mjs → reviewDoc/reviewDoc.mjs} +14 -12
- package/dist/esm/reviewDoc/reviewDoc.mjs.map +1 -0
- package/dist/esm/{reviewDocBlockAware.mjs → reviewDoc/reviewDocBlockAware.mjs} +11 -7
- package/dist/esm/reviewDoc/reviewDocBlockAware.mjs.map +1 -0
- package/dist/esm/translateDoc/index.mjs +5 -0
- package/dist/esm/translateDoc/translateDoc.mjs +72 -0
- package/dist/esm/translateDoc/translateDoc.mjs.map +1 -0
- package/dist/esm/translateDoc/translateFile.mjs +102 -0
- package/dist/esm/translateDoc/translateFile.mjs.map +1 -0
- package/dist/esm/translateDoc/types.mjs +0 -0
- package/dist/esm/translateDoc/validation.mjs +47 -0
- package/dist/esm/translateDoc/validation.mjs.map +1 -0
- package/dist/esm/translation-alignment/planActions.mjs +2 -4
- package/dist/esm/translation-alignment/planActions.mjs.map +1 -1
- package/dist/esm/translation-alignment/segmentDocument.mjs +35 -101
- package/dist/esm/translation-alignment/segmentDocument.mjs.map +1 -1
- package/dist/types/index.d.ts +3 -3
- package/dist/types/pull.d.ts.map +1 -1
- package/dist/types/pushConfig.d.ts.map +1 -1
- package/dist/types/{reviewDoc.d.ts → reviewDoc/reviewDoc.d.ts} +1 -1
- package/dist/types/reviewDoc/reviewDoc.d.ts.map +1 -0
- package/dist/types/{reviewDocBlockAware.d.ts → reviewDoc/reviewDocBlockAware.d.ts} +2 -2
- package/dist/types/reviewDoc/reviewDocBlockAware.d.ts.map +1 -0
- package/dist/types/translateDoc/index.d.ts +5 -0
- package/dist/types/translateDoc/translateDoc.d.ts +21 -0
- package/dist/types/translateDoc/translateDoc.d.ts.map +1 -0
- package/dist/types/translateDoc/translateFile.d.ts +21 -0
- package/dist/types/translateDoc/translateFile.d.ts.map +1 -0
- package/dist/types/translateDoc/types.d.ts +47 -0
- package/dist/types/translateDoc/types.d.ts.map +1 -0
- package/dist/types/translateDoc/validation.d.ts +16 -0
- package/dist/types/translateDoc/validation.d.ts.map +1 -0
- package/dist/types/translation-alignment/planActions.d.ts +2 -2
- package/dist/types/translation-alignment/planActions.d.ts.map +1 -1
- package/dist/types/translation-alignment/rebuildDocument.d.ts.map +1 -1
- package/dist/types/translation-alignment/segmentDocument.d.ts.map +1 -1
- package/package.json +11 -11
- package/dist/cjs/reviewDoc.cjs.map +0 -1
- package/dist/cjs/reviewDocBlockAware.cjs.map +0 -1
- package/dist/cjs/translateDoc.cjs +0 -163
- package/dist/cjs/translateDoc.cjs.map +0 -1
- package/dist/esm/reviewDoc.mjs.map +0 -1
- package/dist/esm/reviewDocBlockAware.mjs.map +0 -1
- package/dist/esm/translateDoc.mjs +0 -160
- package/dist/esm/translateDoc.mjs.map +0 -1
- package/dist/types/reviewDoc.d.ts.map +0 -1
- package/dist/types/reviewDocBlockAware.d.ts.map +0 -1
- package/dist/types/translateDoc.d.ts +0 -56
- package/dist/types/translateDoc.d.ts.map +0 -1
package/dist/cjs/cli.cjs
CHANGED
|
@@ -13,9 +13,9 @@ const require_liveSync = require('./liveSync.cjs');
|
|
|
13
13
|
const require_pull = require('./pull.cjs');
|
|
14
14
|
const require_push_push = require('./push/push.cjs');
|
|
15
15
|
const require_pushConfig = require('./pushConfig.cjs');
|
|
16
|
-
const
|
|
16
|
+
const require_reviewDoc_reviewDoc = require('./reviewDoc/reviewDoc.cjs');
|
|
17
17
|
const require_transform = require('./transform.cjs');
|
|
18
|
-
const
|
|
18
|
+
const require_translateDoc_translateDoc = require('./translateDoc/translateDoc.cjs');
|
|
19
19
|
const require_utils_getParentPackageJSON = require('./utils/getParentPackageJSON.cjs');
|
|
20
20
|
const require_watch = require('./watch.cjs');
|
|
21
21
|
let _intlayer_config = require("@intlayer/config");
|
|
@@ -388,7 +388,7 @@ const setAPI = () => {
|
|
|
388
388
|
applyAIOptions(translateProgram);
|
|
389
389
|
applyGitOptions(translateProgram);
|
|
390
390
|
applyOptions(translateProgram, docParams);
|
|
391
|
-
translateProgram.action((options) =>
|
|
391
|
+
translateProgram.action((options) => require_translateDoc_translateDoc.translateDoc({
|
|
392
392
|
docPattern: options.docPattern,
|
|
393
393
|
excludedGlobPattern: options.excludedGlobPattern,
|
|
394
394
|
locales: options.locales,
|
|
@@ -407,7 +407,7 @@ const setAPI = () => {
|
|
|
407
407
|
applyAIOptions(reviewProgram);
|
|
408
408
|
applyGitOptions(reviewProgram);
|
|
409
409
|
applyOptions(reviewProgram, docParams);
|
|
410
|
-
reviewProgram.action((options) =>
|
|
410
|
+
reviewProgram.action((options) => require_reviewDoc_reviewDoc.reviewDoc({
|
|
411
411
|
docPattern: options.docPattern,
|
|
412
412
|
excludedGlobPattern: options.excludedGlobPattern,
|
|
413
413
|
locales: options.locales,
|
package/dist/cjs/cli.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.cjs","names":["getParentPackageJSON","gitOptionKeys: (keyof GitOptions)[]","configurationOptionKeys: (keyof ConfigurationOptions)[]","addPrefix: boolean","Command","login","init","push","fill","translateDoc","reviewDoc","liveSync"],"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 { login } from './auth/login';\nimport { build } from './build';\nimport { runCI } from './ci';\nimport { getConfig } from './config';\nimport { startEditor } from './editor';\nimport { type FillOptions, fill } from './fill/fill';\nimport { init } from './init';\nimport { listContentDeclaration } from './listContentDeclaration';\nimport { listProjectsCommand } from './listProjects';\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 const { ai } = configuration;\n\n return removeUndefined({\n ...ai,\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 * AUTH\n */\n const loginCmd = program\n .command('login')\n .description('Login to Intlayer')\n .option('--cms-url [cmsUrl]', 'CMS URL');\n\n applyConfigOptions(loginCmd);\n\n loginCmd.action((options) => {\n const configOptions = extractConfigOptions(options) ?? {\n override: {\n log: {\n prefix: '',\n verbose: true,\n },\n },\n };\n\n return login({\n cmsUrl: options.cmsUrl,\n configOptions,\n });\n });\n\n /**\n * INIT\n */\n program\n .command('init')\n .description('Initialize Intlayer in the project')\n .option('--project-root [projectRoot]', 'Project root directory')\n .action((options) => init(options.projectRoot));\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 * PROJECTS\n */\n\n const projectsProgram = program\n .command('projects')\n .alias('project')\n .description('List Intlayer projects');\n\n const projectsListCmd = projectsProgram\n .command('list')\n .description('List all Intlayer projects in the directory')\n .option('--base-dir [baseDir]', 'Base directory to search from')\n .option(\n '--git-root',\n 'Search from the git root directory instead of the base directory'\n )\n .option('--json', 'Output the results as JSON');\n\n projectsListCmd.action((options) => {\n listProjectsCommand({\n baseDir: options.baseDir,\n gitRoot: options.gitRoot,\n json: options.json,\n });\n });\n\n // Add alias for projects list command at root level\n const rootProjectsListCmd = program\n .command('projects-list')\n .alias('pl')\n .description('List all Intlayer projects in the directory')\n .option('--base-dir [baseDir]', 'Base directory to search from')\n .option(\n '--git-root',\n 'Search from the git root directory instead of the base directory'\n )\n .option('--absolute', 'Output the results as absolute paths')\n .option('--json', 'Output the results as JSON');\n\n rootProjectsListCmd.action((options) => {\n listProjectsCommand({\n baseDir: options.baseDir,\n gitRoot: options.gitRoot,\n json: options.json,\n absolute: options.absolute,\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 .option('--json', 'Output the results as JSON')\n .option('--absolute', 'Output the results as absolute paths')\n .action((options) => {\n listContentDeclaration({\n json: options.json,\n absolute: options.absolute,\n });\n });\n\n // Add alias for content list command\n program\n .command('list')\n .description('List the content declaration files')\n .option('--json', 'Output the results as JSON')\n .option('--absolute', 'Output the results as absolute paths')\n .action((options) => {\n listContentDeclaration({\n json: options.json,\n absolute: options.absolute,\n });\n });\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 /**\n * CI / AUTOMATION\n *\n * Used to iterate over all projects in a monorepo, and help to parse secrets\n */\n program\n .command('ci')\n .description(\n 'Run Intlayer commands with auto-injected credentials from INTLAYER_PROJECT_CREDENTIALS. Detects current project or iterates over all projects.'\n )\n .argument(\n '<command...>',\n 'The intlayer command to execute (e.g., \"fill\", \"push\")'\n )\n .allowUnknownOption() // Allows passing flags like --verbose to the subcommand\n .action((args) => {\n runCI(args);\n });\n\n return program;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,MAAM,aAAa,yDAA2B;AAE9C,MAAa,UAAU,8GACuB,CAAC,GAC3C;AAEJ,MAAM,cAAcA,wDAAqB,QA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Keys: (keyof GitOptions)[]","configurationOptionKeys: (keyof ConfigurationOptions)[]","addPrefix: boolean","Command","login","init","push","fill","translateDoc","reviewDoc","liveSync"],"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 { login } from './auth/login';\nimport { build } from './build';\nimport { runCI } from './ci';\nimport { getConfig } from './config';\nimport { startEditor } from './editor';\nimport { type FillOptions, fill } from './fill/fill';\nimport { init } from './init';\nimport { listContentDeclaration } from './listContentDeclaration';\nimport { listProjectsCommand } from './listProjects';\nimport { liveSync } from './liveSync';\nimport { pull } from './pull';\nimport { push } from './push/push';\nimport { pushConfig } from './pushConfig';\nimport { reviewDoc } from './reviewDoc/reviewDoc';\nimport { testMissingTranslations } from './test';\nimport { transform } from './transform';\nimport { translateDoc } from './translateDoc/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 const { ai } = configuration;\n\n return removeUndefined({\n ...ai,\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 * AUTH\n */\n const loginCmd = program\n .command('login')\n .description('Login to Intlayer')\n .option('--cms-url [cmsUrl]', 'CMS URL');\n\n applyConfigOptions(loginCmd);\n\n loginCmd.action((options) => {\n const configOptions = extractConfigOptions(options) ?? {\n override: {\n log: {\n prefix: '',\n verbose: true,\n },\n },\n };\n\n return login({\n cmsUrl: options.cmsUrl,\n configOptions,\n });\n });\n\n /**\n * INIT\n */\n program\n .command('init')\n .description('Initialize Intlayer in the project')\n .option('--project-root [projectRoot]', 'Project root directory')\n .action((options) => init(options.projectRoot));\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 * PROJECTS\n */\n\n const projectsProgram = program\n .command('projects')\n .alias('project')\n .description('List Intlayer projects');\n\n const projectsListCmd = projectsProgram\n .command('list')\n .description('List all Intlayer projects in the directory')\n .option('--base-dir [baseDir]', 'Base directory to search from')\n .option(\n '--git-root',\n 'Search from the git root directory instead of the base directory'\n )\n .option('--json', 'Output the results as JSON');\n\n projectsListCmd.action((options) => {\n listProjectsCommand({\n baseDir: options.baseDir,\n gitRoot: options.gitRoot,\n json: options.json,\n });\n });\n\n // Add alias for projects list command at root level\n const rootProjectsListCmd = program\n .command('projects-list')\n .alias('pl')\n .description('List all Intlayer projects in the directory')\n .option('--base-dir [baseDir]', 'Base directory to search from')\n .option(\n '--git-root',\n 'Search from the git root directory instead of the base directory'\n )\n .option('--absolute', 'Output the results as absolute paths')\n .option('--json', 'Output the results as JSON');\n\n rootProjectsListCmd.action((options) => {\n listProjectsCommand({\n baseDir: options.baseDir,\n gitRoot: options.gitRoot,\n json: options.json,\n absolute: options.absolute,\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 .option('--json', 'Output the results as JSON')\n .option('--absolute', 'Output the results as absolute paths')\n .action((options) => {\n listContentDeclaration({\n json: options.json,\n absolute: options.absolute,\n });\n });\n\n // Add alias for content list command\n program\n .command('list')\n .description('List the content declaration files')\n .option('--json', 'Output the results as JSON')\n .option('--absolute', 'Output the results as absolute paths')\n .action((options) => {\n listContentDeclaration({\n json: options.json,\n absolute: options.absolute,\n });\n });\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 /**\n * CI / AUTOMATION\n *\n * Used to iterate over all projects in a monorepo, and help to parse secrets\n */\n program\n .command('ci')\n .description(\n 'Run Intlayer commands with auto-injected credentials from INTLAYER_PROJECT_CREDENTIALS. Detects current project or iterates over all projects.'\n )\n .argument(\n '<command...>',\n 'The intlayer command to execute (e.g., \"fill\", \"push\")'\n )\n .allowUnknownOption() // Allows passing flags like --verbose to the subcommand\n .action((args) => {\n runCI(args);\n });\n\n return program;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,MAAM,aAAa,yDAA2B;AAE9C,MAAa,UAAU,8GACuB,CAAC,GAC3C;AAEJ,MAAM,cAAcA,wDAAqB,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,SA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,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,YAAYC,0BAAS,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,6BAAY;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,OAAO,eAAe,qCAAqC,MAAM,CACjE,OAAO,sBAAsB,qCAAqC,MAAM,CACxE,QAAQ,YAAY;AACnB,8BAAU;GACR,OAAO,QAAQ;GACf,2BAA2B,QAAQ;GACnC,eAAe,qBAAqB,QAAQ;GAC5C,UAAU,QAAQ;GAClB,iBAAiB,QAAQ;GAC1B,CAAC;GACF;AAEJ,oBAAmB,iBAAiB;AAEpC,SAAQ,MAAM,QAAQ,KAAK;;;;;;AAO3B,SACG,QAAQ,KAAK,CACb,YACC,iJACD,CACA,SACC,gBACA,6DACD,CACA,oBAAoB,CACpB,QAAQ,SAAS;AAChB,mBAAM,KAAK;GACX;AAEJ,QAAO"}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -8,9 +8,9 @@ const require_liveSync = require('./liveSync.cjs');
|
|
|
8
8
|
const require_pull = require('./pull.cjs');
|
|
9
9
|
const require_push_push = require('./push/push.cjs');
|
|
10
10
|
const require_pushConfig = require('./pushConfig.cjs');
|
|
11
|
-
const
|
|
11
|
+
const require_reviewDoc_reviewDoc = require('./reviewDoc/reviewDoc.cjs');
|
|
12
12
|
const require_transform = require('./transform.cjs');
|
|
13
|
-
const
|
|
13
|
+
const require_translateDoc_translateDoc = require('./translateDoc/translateDoc.cjs');
|
|
14
14
|
const require_cli = require('./cli.cjs');
|
|
15
15
|
|
|
16
16
|
exports.build = require_build.build;
|
|
@@ -24,10 +24,9 @@ exports.liveSync = require_liveSync.liveSync;
|
|
|
24
24
|
exports.pull = require_pull.pull;
|
|
25
25
|
exports.push = require_push_push.push;
|
|
26
26
|
exports.pushConfig = require_pushConfig.pushConfig;
|
|
27
|
-
exports.reviewDoc =
|
|
27
|
+
exports.reviewDoc = require_reviewDoc_reviewDoc.reviewDoc;
|
|
28
28
|
exports.setAPI = require_cli.setAPI;
|
|
29
29
|
exports.startEditor = require_editor.startEditor;
|
|
30
30
|
exports.testMissingTranslations = require_test_test.testMissingTranslations;
|
|
31
31
|
exports.transform = require_transform.transform;
|
|
32
|
-
exports.translateDoc =
|
|
33
|
-
exports.translateFile = require_translateDoc.translateFile;
|
|
32
|
+
exports.translateDoc = require_translateDoc_translateDoc.translateDoc;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const require_rolldown_runtime = require('
|
|
2
|
-
const require_utils_setupAI = require('
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_utils_setupAI = require('../utils/setupAI.cjs');
|
|
3
|
+
const require_utils_checkFileModifiedRange = require('../utils/checkFileModifiedRange.cjs');
|
|
4
|
+
const require_utils_getOutputFilePath = require('../utils/getOutputFilePath.cjs');
|
|
5
|
+
const require_reviewDoc_reviewDocBlockAware = require('./reviewDocBlockAware.cjs');
|
|
6
6
|
let _intlayer_chokidar = require("@intlayer/chokidar");
|
|
7
7
|
let _intlayer_config = require("@intlayer/config");
|
|
8
8
|
let node_path = require("node:path");
|
|
@@ -10,7 +10,7 @@ let node_fs = require("node:fs");
|
|
|
10
10
|
let fast_glob = require("fast-glob");
|
|
11
11
|
fast_glob = require_rolldown_runtime.__toESM(fast_glob);
|
|
12
12
|
|
|
13
|
-
//#region src/reviewDoc.ts
|
|
13
|
+
//#region src/reviewDoc/reviewDoc.ts
|
|
14
14
|
/**
|
|
15
15
|
* Main audit function: scans all .md files in "en/" (unless you specified DOC_LIST),
|
|
16
16
|
* then audits them to each locale in LOCALE_LIST.
|
|
@@ -43,21 +43,23 @@ const reviewDoc = async ({ docPattern, locales, excludedGlobPattern, baseLocale,
|
|
|
43
43
|
appLogger(`${(0, _intlayer_config.colorize)("⊘", _intlayer_config.ANSIColors.YELLOW)} File ${(0, _intlayer_chokidar.formatPath)(relativePath)} already exists, skipping.`);
|
|
44
44
|
return;
|
|
45
45
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
46
|
+
if ((0, node_fs.existsSync)(outputFilePath)) {
|
|
47
|
+
const fileModificationData = require_utils_checkFileModifiedRange.checkFileModifiedRange(outputFilePath, {
|
|
48
|
+
skipIfModifiedBefore,
|
|
49
|
+
skipIfModifiedAfter
|
|
50
|
+
});
|
|
51
|
+
if (fileModificationData.isSkipped) {
|
|
52
|
+
appLogger(fileModificationData.message);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
} else if (skipIfModifiedBefore || skipIfModifiedAfter) appLogger(`${(0, _intlayer_config.colorize)("!", _intlayer_config.ANSIColors.YELLOW)} File ${(0, _intlayer_chokidar.formatPath)(outputFilePath)} does not exist, skipping modification date check.`);
|
|
54
56
|
let changedLines;
|
|
55
57
|
if (gitOptions) {
|
|
56
58
|
const gitChangedLines = await (0, _intlayer_chokidar.listGitLines)(absoluteBaseFilePath, gitOptions);
|
|
57
59
|
appLogger(`Git changed lines: ${gitChangedLines.join(", ")}`);
|
|
58
60
|
changedLines = gitChangedLines;
|
|
59
61
|
}
|
|
60
|
-
await
|
|
62
|
+
await require_reviewDoc_reviewDocBlockAware.reviewFileBlockAware(absoluteBaseFilePath, outputFilePath, locale, baseLocale, aiOptions, configOptions, customInstructions, changedLines, aiClient, aiConfig);
|
|
61
63
|
})), (task) => task(), nbSimultaneousFileProcessed ?? 3);
|
|
62
64
|
};
|
|
63
65
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reviewDoc.cjs","names":["setupAI","docList: string[]","getOutputFilePath","ANSIColors","checkFileModifiedRange","changedLines: number[] | undefined","reviewFileBlockAware"],"sources":["../../../src/reviewDoc/reviewDoc.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { join, relative } from 'node:path';\nimport type { AIOptions } from '@intlayer/api';\nimport {\n formatLocale,\n formatPath,\n type ListGitFilesOptions,\n listGitFiles,\n listGitLines,\n parallelize,\n} from '@intlayer/chokidar';\nimport {\n ANSIColors,\n colorize,\n colorizeNumber,\n type GetConfigurationOptions,\n getAppLogger,\n getConfiguration,\n} from '@intlayer/config';\nimport type { Locale } from '@intlayer/types';\nimport fg from 'fast-glob';\nimport { checkFileModifiedRange } from '../utils/checkFileModifiedRange';\nimport { getOutputFilePath } from '../utils/getOutputFilePath';\nimport { setupAI } from '../utils/setupAI';\nimport { reviewFileBlockAware } from './reviewDocBlockAware';\n\ntype ReviewDocOptions = {\n docPattern: string[];\n locales: Locale[];\n excludedGlobPattern: string[];\n baseLocale: Locale;\n aiOptions?: AIOptions;\n nbSimultaneousFileProcessed?: number;\n configOptions?: GetConfigurationOptions;\n customInstructions?: string;\n skipIfModifiedBefore?: number | string | Date;\n skipIfModifiedAfter?: number | string | Date;\n skipIfExists?: boolean;\n gitOptions?: ListGitFilesOptions;\n};\n\n/**\n * Main audit function: scans all .md files in \"en/\" (unless you specified DOC_LIST),\n * then audits them to each locale in LOCALE_LIST.\n */\nexport const reviewDoc = async ({\n docPattern,\n locales,\n excludedGlobPattern,\n baseLocale,\n aiOptions,\n nbSimultaneousFileProcessed,\n configOptions,\n customInstructions,\n skipIfModifiedBefore,\n skipIfModifiedAfter,\n skipIfExists,\n gitOptions,\n}: ReviewDocOptions) => {\n const configuration = getConfiguration(configOptions);\n const appLogger = getAppLogger(configuration);\n\n const aiResult = await setupAI(configuration, aiOptions);\n\n if (!aiResult?.hasAIAccess) return;\n\n const { aiClient, aiConfig } = aiResult;\n\n if (nbSimultaneousFileProcessed && nbSimultaneousFileProcessed > 10) {\n appLogger(\n `Warning: nbSimultaneousFileProcessed is set to ${nbSimultaneousFileProcessed}, which is greater than 10. Setting it to 10.`\n );\n nbSimultaneousFileProcessed = 10; // Limit the number of simultaneous file processed to 10\n }\n\n let docList: string[] = await fg(docPattern, {\n ignore: excludedGlobPattern,\n });\n\n if (gitOptions) {\n const gitChangedFiles = await listGitFiles(gitOptions);\n\n if (gitChangedFiles) {\n // Convert dictionary file paths to be relative to git root for comparison\n\n // Filter dictionaries based on git changed files\n docList = docList.filter((path) =>\n gitChangedFiles.some((gitFile) => join(process.cwd(), path) === gitFile)\n );\n }\n }\n\n // OAuth handled by API proxy internally\n\n appLogger(`Base locale is ${formatLocale(baseLocale)}`);\n appLogger(\n `Reviewing ${colorizeNumber(locales.length)} locales: [ ${formatLocale(locales)} ]`\n );\n\n appLogger(`Reviewing ${colorizeNumber(docList.length)} files:`);\n appLogger(docList.map((path) => ` - ${formatPath(path)}\\n`));\n\n // Create all tasks to be processed\n const allTasks = docList.flatMap((docPath) =>\n locales.map((locale) => async () => {\n appLogger(\n `Reviewing file: ${formatPath(docPath)} to ${formatLocale(locale)}`\n );\n\n const absoluteBaseFilePath = join(configuration.content.baseDir, docPath);\n const outputFilePath = getOutputFilePath(\n absoluteBaseFilePath,\n locale,\n baseLocale\n );\n\n // Skip if file exists and skipIfExists option is enabled\n if (skipIfExists && existsSync(outputFilePath)) {\n const relativePath = relative(\n configuration.content.baseDir,\n outputFilePath\n );\n appLogger(\n `${colorize('⊘', ANSIColors.YELLOW)} File ${formatPath(relativePath)} already exists, skipping.`\n );\n return;\n }\n\n // Check modification range only if the file exists\n if (existsSync(outputFilePath)) {\n const fileModificationData = checkFileModifiedRange(outputFilePath, {\n skipIfModifiedBefore,\n skipIfModifiedAfter,\n });\n\n if (fileModificationData.isSkipped) {\n appLogger(fileModificationData.message);\n return;\n }\n } else if (skipIfModifiedBefore || skipIfModifiedAfter) {\n // Log if we intended to check modification time but couldn't because the file doesn't exist\n appLogger(\n `${colorize('!', ANSIColors.YELLOW)} File ${formatPath(outputFilePath)} does not exist, skipping modification date check.`\n );\n }\n\n let changedLines: number[] | undefined;\n // FIXED: Enable git optimization that was previously commented out\n if (gitOptions) {\n const gitChangedLines = await listGitLines(\n absoluteBaseFilePath,\n gitOptions\n );\n\n appLogger(`Git changed lines: ${gitChangedLines.join(', ')}`);\n changedLines = gitChangedLines;\n }\n\n await reviewFileBlockAware(\n absoluteBaseFilePath,\n outputFilePath,\n locale as Locale,\n baseLocale,\n aiOptions,\n configOptions,\n customInstructions,\n changedLines,\n aiClient,\n aiConfig\n );\n })\n );\n\n await parallelize(\n allTasks,\n (task) => task(),\n nbSimultaneousFileProcessed ?? 3\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AA6CA,MAAa,YAAY,OAAO,EAC9B,YACA,SACA,qBACA,YACA,WACA,6BACA,eACA,oBACA,sBACA,qBACA,cACA,iBACsB;CACtB,MAAM,uDAAiC,cAAc;CACrD,MAAM,+CAAyB,cAAc;CAE7C,MAAM,WAAW,MAAMA,8BAAQ,eAAe,UAAU;AAExD,KAAI,CAAC,UAAU,YAAa;CAE5B,MAAM,EAAE,UAAU,aAAa;AAE/B,KAAI,+BAA+B,8BAA8B,IAAI;AACnE,YACE,kDAAkD,4BAA4B,+CAC/E;AACD,gCAA8B;;CAGhC,IAAIC,UAAoB,6BAAS,YAAY,EAC3C,QAAQ,qBACT,CAAC;AAEF,KAAI,YAAY;EACd,MAAM,kBAAkB,2CAAmB,WAAW;AAEtD,MAAI,gBAIF,WAAU,QAAQ,QAAQ,SACxB,gBAAgB,MAAM,gCAA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const
|
|
6
|
-
const
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require__utils_asset = require('../_virtual/_utils_asset.cjs');
|
|
3
|
+
const require_translateDoc_validation = require('../translateDoc/validation.cjs');
|
|
4
|
+
const require_translation_alignment_rebuildDocument = require('../translation-alignment/rebuildDocument.cjs');
|
|
5
|
+
const require_translation_alignment_pipeline = require('../translation-alignment/pipeline.cjs');
|
|
6
|
+
const require_utils_chunkInference = require('../utils/chunkInference.cjs');
|
|
7
|
+
const require_utils_fixChunkStartEndChars = require('../utils/fixChunkStartEndChars.cjs');
|
|
7
8
|
let _intlayer_chokidar = require("@intlayer/chokidar");
|
|
8
9
|
let _intlayer_config = require("@intlayer/config");
|
|
9
10
|
let node_path = require("node:path");
|
|
@@ -12,7 +13,7 @@ let node_fs = require("node:fs");
|
|
|
12
13
|
let node_fs_promises = require("node:fs/promises");
|
|
13
14
|
let _intlayer_types = require("@intlayer/types");
|
|
14
15
|
|
|
15
|
-
//#region src/reviewDocBlockAware.ts
|
|
16
|
+
//#region src/reviewDoc/reviewDocBlockAware.ts
|
|
16
17
|
/**
|
|
17
18
|
* Review a file using block-aware alignment.
|
|
18
19
|
* This approach:
|
|
@@ -75,7 +76,10 @@ const reviewFileBlockAware = async (baseFilePath, outputFilePath, locale, baseLo
|
|
|
75
76
|
}
|
|
76
77
|
], aiOptions, configuration, aiClient, aiConfig);
|
|
77
78
|
applicationLogger(`${prefix}${(0, _intlayer_config.colorizeNumber)(result.tokenUsed)} tokens used - Block ${(0, _intlayer_config.colorizeNumber)(segmentNumber)} of ${(0, _intlayer_config.colorizeNumber)(segmentsToReview.length)}`);
|
|
78
|
-
|
|
79
|
+
let processedChunk = require_translateDoc_validation.sanitizeChunk(result?.fileContent, englishBlock.content);
|
|
80
|
+
processedChunk = require_utils_fixChunkStartEndChars.fixChunkStartEndChars(processedChunk, englishBlock.content);
|
|
81
|
+
if (!require_translateDoc_validation.validateTranslation(englishBlock.content, processedChunk, applicationLogger)) throw new Error("Validation failed for chunk (structure or length mismatch). Retrying...");
|
|
82
|
+
return processedChunk;
|
|
79
83
|
})();
|
|
80
84
|
reviewedSegmentsMap.set(segment.actionIndex, reviewedChunkResult);
|
|
81
85
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reviewDocBlockAware.cjs","names":["readAsset","ANSIColors","buildAlignmentPlan","mergeReviewedSegments","chunkInference","Locales","sanitizeChunk","fixChunkStartEndChars","validateTranslation"],"sources":["../../../src/reviewDoc/reviewDocBlockAware.ts"],"sourcesContent":["import { mkdirSync, writeFileSync } from 'node:fs';\nimport { readFile } from 'node:fs/promises';\nimport { dirname } from 'node:path';\nimport { readAsset } from 'utils:asset';\nimport type { AIConfig } from '@intlayer/ai';\nimport type { AIOptions } from '@intlayer/api';\nimport { formatLocale, formatPath } from '@intlayer/chokidar';\nimport {\n ANSIColors,\n colon,\n colorize,\n colorizeNumber,\n type GetConfigurationOptions,\n getAppLogger,\n getConfiguration,\n retryManager,\n} from '@intlayer/config';\nimport { getLocaleName } from '@intlayer/core';\nimport { type Locale, Locales } from '@intlayer/types';\nimport { sanitizeChunk, validateTranslation } from '../translateDoc/validation';\nimport {\n buildAlignmentPlan,\n mergeReviewedSegments,\n} from '../translation-alignment/pipeline';\nimport { chunkInference } from '../utils/chunkInference';\nimport { fixChunkStartEndChars } from '../utils/fixChunkStartEndChars';\nimport type { AIClient } from '../utils/setupAI';\n\n/**\n * Review a file using block-aware alignment.\n * This approach:\n * 1. Segments both English and French documents into semantic blocks\n * 2. Aligns blocks using structure (special chars, numbers) and context\n * 3. Detects which blocks changed, were added, or deleted\n * 4. Only sends changed/new blocks to AI for translation\n * 5. Handles reordering automatically\n */\nexport const reviewFileBlockAware = async (\n baseFilePath: string,\n outputFilePath: string,\n locale: Locale,\n baseLocale: Locale,\n aiOptions?: AIOptions,\n configOptions?: GetConfigurationOptions,\n customInstructions?: string,\n changedLines?: number[],\n aiClient?: AIClient,\n aiConfig?: AIConfig\n) => {\n const configuration = getConfiguration(configOptions);\n const applicationLogger = getAppLogger(configuration);\n\n const englishText = await readFile(baseFilePath, 'utf-8');\n const frenchText = await readFile(outputFilePath, 'utf-8').catch(() => '');\n\n const basePrompt = readAsset('./prompts/REVIEW_PROMPT.md', 'utf-8')\n .replaceAll('{{localeName}}', `${formatLocale(locale, false)}`)\n .replaceAll('{{baseLocaleName}}', `${formatLocale(baseLocale, false)}`)\n .replace('{{applicationContext}}', aiOptions?.applicationContext ?? '-')\n .replace('{{customInstructions}}', customInstructions ?? '-');\n\n const filePrefixText = `${ANSIColors.GREY_DARK}[${formatPath(baseFilePath)}${ANSIColors.GREY_DARK}] `;\n const filePrefix = [\n colon(filePrefixText, { colSize: 40 }),\n `→ ${ANSIColors.RESET}`,\n ].join('');\n const prefixText = `${ANSIColors.GREY_DARK}[${formatPath(baseFilePath)}${ANSIColors.GREY_DARK}][${formatLocale(locale)}${ANSIColors.GREY_DARK}] `;\n const prefix = [\n colon(prefixText, { colSize: 40 }),\n `→ ${ANSIColors.RESET}`,\n ].join('');\n\n // Build block-aware alignment and plan\n const { englishBlocks, frenchBlocks, plan, segmentsToReview } =\n buildAlignmentPlan({\n englishText,\n frenchText,\n changedLines,\n });\n\n applicationLogger(\n `${filePrefix}Block-aware alignment complete. Total blocks: EN=${colorizeNumber(englishBlocks.length)}, FR=${colorizeNumber(frenchBlocks.length)}`\n );\n applicationLogger(\n `${filePrefix}Actions: reuse=${colorizeNumber(plan.actions.filter((a) => a.kind === 'reuse').length)}, review=${colorizeNumber(plan.actions.filter((a) => a.kind === 'review').length)}, new=${colorizeNumber(plan.actions.filter((a) => a.kind === 'insert_new').length)}, delete=${colorizeNumber(plan.actions.filter((a) => a.kind === 'delete').length)}`\n );\n\n if (segmentsToReview.length === 0) {\n applicationLogger(\n `${filePrefix}No segments need review, reusing existing translation`\n );\n mkdirSync(dirname(outputFilePath), { recursive: true });\n writeFileSync(\n outputFilePath,\n mergeReviewedSegments(plan, frenchBlocks, new Map())\n );\n applicationLogger(\n `${colorize('✔', ANSIColors.GREEN)} File ${formatPath(outputFilePath)} updated successfully (no changes needed).`\n );\n return;\n }\n\n applicationLogger(\n `${filePrefix}Segments to review: ${colorizeNumber(segmentsToReview.length)}`\n );\n\n // Review segments that need AI translation\n const reviewedSegmentsMap = new Map<number, string>();\n\n for (const segment of segmentsToReview) {\n const segmentNumber = segmentsToReview.indexOf(segment) + 1;\n const englishBlock = segment.englishBlock;\n\n const getBaseChunkContextPrompt = () =>\n `**BLOCK ${segmentNumber} of ${segmentsToReview.length}** is the base block in ${formatLocale(baseLocale, false)} as reference.\\n` +\n `///chunksStart///\\n` +\n englishBlock.content +\n `///chunksEnd///`;\n\n const getFrenchChunkPrompt = () =>\n `**BLOCK ${segmentNumber} of ${segmentsToReview.length}** is the current block to review in ${formatLocale(locale, false)}.\\n` +\n `///chunksStart///\\n` +\n (segment.frenchBlockText ?? '') +\n `///chunksEnd///`;\n\n const reviewedChunkResult = await retryManager(async () => {\n const result = await chunkInference(\n [\n { role: 'system', content: basePrompt },\n { role: 'system', content: getBaseChunkContextPrompt() },\n { role: 'system', content: getFrenchChunkPrompt() },\n {\n role: 'system',\n content: `The next user message will be the **BLOCK ${colorizeNumber(segmentNumber)} of ${colorizeNumber(segmentsToReview.length)}** that should be translated in ${getLocaleName(locale, Locales.ENGLISH)} (${locale}).`,\n },\n { role: 'user', content: englishBlock.content },\n ],\n aiOptions,\n configuration,\n aiClient,\n aiConfig\n );\n\n applicationLogger(\n `${prefix}${colorizeNumber(result.tokenUsed)} tokens used - Block ${colorizeNumber(segmentNumber)} of ${colorizeNumber(segmentsToReview.length)}`\n );\n\n // Sanitize artifacts (e.g. Markdown code block wrappers)\n let processedChunk = sanitizeChunk(\n result?.fileContent,\n englishBlock.content\n );\n\n // Fix start/end characters\n processedChunk = fixChunkStartEndChars(\n processedChunk,\n englishBlock.content\n );\n\n // Validate Translation (YAML, Code fences, Length ratio)\n const isValid = validateTranslation(\n englishBlock.content,\n processedChunk,\n applicationLogger\n );\n\n if (!isValid) {\n throw new Error(\n 'Validation failed for chunk (structure or length mismatch). Retrying...'\n );\n }\n\n return processedChunk;\n })();\n\n reviewedSegmentsMap.set(segment.actionIndex, reviewedChunkResult);\n }\n\n // Merge reviewed segments back into final document\n const finalFrenchOutput = mergeReviewedSegments(\n plan,\n frenchBlocks,\n reviewedSegmentsMap\n );\n\n mkdirSync(dirname(outputFilePath), { recursive: true });\n writeFileSync(outputFilePath, finalFrenchOutput);\n\n applicationLogger(\n `${colorize('✔', ANSIColors.GREEN)} File ${formatPath(outputFilePath)} created/updated successfully.`\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,MAAa,uBAAuB,OAClC,cACA,gBACA,QACA,YACA,WACA,eACA,oBACA,cACA,UACA,aACG;CACH,MAAM,uDAAiC,cAAc;CACrD,MAAM,uDAAiC,cAAc;CAErD,MAAM,cAAc,qCAAe,cAAc,QAAQ;CACzD,MAAM,aAAa,qCAAe,gBAAgB,QAAQ,CAAC,YAAY,GAAG;CAE1E,MAAM,aAAaA,+BAAU,8BAA8B,QAAQ,CAChE,WAAW,kBAAkB,wCAAgB,QAAQ,MAAM,GAAG,CAC9D,WAAW,sBAAsB,wCAAgB,YAAY,MAAM,GAAG,CACtE,QAAQ,0BAA0B,WAAW,sBAAsB,IAAI,CACvE,QAAQ,0BAA0B,sBAAsB,IAAI;CAG/D,MAAM,aAAa,6BADI,GAAGC,4BAAW,UAAU,sCAAc,aAAa,GAAGA,4BAAW,UAAU,KAE1E,EAAE,SAAS,IAAI,CAAC,EACtC,KAAKA,4BAAW,QACjB,CAAC,KAAK,GAAG;CAEV,MAAM,SAAS,6BADI,GAAGA,4BAAW,UAAU,sCAAc,aAAa,GAAGA,4BAAW,UAAU,yCAAiB,OAAO,GAAGA,4BAAW,UAAU,KAE1H,EAAE,SAAS,IAAI,CAAC,EAClC,KAAKA,4BAAW,QACjB,CAAC,KAA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KAAY;IACvC;KAAE,MAAM;KAAU,SAAS,2BAA2B;KAAE;IACxD;KAAE,MAAM;KAAU,SAAS,sBAAsB;KAAE;IACnD;KACE,MAAM;KACN,SAAS,kFAA4D,cAAc,CAAC,2CAAqB,iBAAiB,OAAO,CAAC,oEAAgD,QAAQC,wBAAQ,QAAQ,CAAC,IAAI,OAAO;KACvN;IACD;KAAE,MAAM;KAAQ,SAAS,aAAa;KAAS;IAChD,EACD,WACA,eACA,UACA,SACD;AAED,qBACE,GAAG,8CAAwB,OAAO,UAAU,CAAC,4DAAsC,cAAc,CAAC,2CAAqB,iBAAiB,OAAO,GAChJ;GAGD,IAAI,iBAAiBC,8CACnB,QAAQ,aACR,aAAa,QACd;AAGD,oBAAiBC,0DACf,gBACA,aAAa,QACd;AASD,OAAI,CANYC,oDACd,aAAa,SACb,gBACA,kBACD,CAGC,OAAM,IAAI,MACR,0EACD;AAGH,UAAO;IACP,EAAE;AAEJ,sBAAoB,IAAI,QAAQ,aAAa,oBAAoB;;CAInE,MAAM,oBAAoBL,oEACxB,MACA,cACA,oBACD;AAED,+CAAkB,eAAe,EAAE,EAAE,WAAW,MAAM,CAAC;AACvD,4BAAc,gBAAgB,kBAAkB;AAEhD,mBACE,kCAAY,KAAKF,4BAAW,MAAM,CAAC,2CAAmB,eAAe,CAAC,gCACvE"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const require_translateDoc_validation = require('./validation.cjs');
|
|
2
|
+
const require_translateDoc_translateFile = require('./translateFile.cjs');
|
|
3
|
+
const require_translateDoc_translateDoc = require('./translateDoc.cjs');
|
|
4
|
+
|
|
5
|
+
exports.sanitizeChunk = require_translateDoc_validation.sanitizeChunk;
|
|
6
|
+
exports.translateDoc = require_translateDoc_translateDoc.translateDoc;
|
|
7
|
+
exports.translateFile = require_translateDoc_translateFile.translateFile;
|
|
8
|
+
exports.validateTranslation = require_translateDoc_validation.validateTranslation;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_utils_setupAI = require('../utils/setupAI.cjs');
|
|
3
|
+
const require_utils_checkFileModifiedRange = require('../utils/checkFileModifiedRange.cjs');
|
|
4
|
+
const require_utils_getOutputFilePath = require('../utils/getOutputFilePath.cjs');
|
|
5
|
+
const require_translateDoc_translateFile = require('./translateFile.cjs');
|
|
6
|
+
let _intlayer_chokidar = require("@intlayer/chokidar");
|
|
7
|
+
let _intlayer_config = require("@intlayer/config");
|
|
8
|
+
let node_path = require("node:path");
|
|
9
|
+
let node_fs = require("node:fs");
|
|
10
|
+
let fast_glob = require("fast-glob");
|
|
11
|
+
fast_glob = require_rolldown_runtime.__toESM(fast_glob);
|
|
12
|
+
let node_perf_hooks = require("node:perf_hooks");
|
|
13
|
+
|
|
14
|
+
//#region src/translateDoc/translateDoc.ts
|
|
15
|
+
const translateDoc = async ({ docPattern, locales, excludedGlobPattern, baseLocale, aiOptions, nbSimultaneousFileProcessed = 20, configOptions, customInstructions, skipIfModifiedBefore, skipIfModifiedAfter, skipIfExists, gitOptions, flushStrategy = "incremental" }) => {
|
|
16
|
+
const configuration = (0, _intlayer_config.getConfiguration)(configOptions);
|
|
17
|
+
const appLogger = (0, _intlayer_config.getAppLogger)(configuration);
|
|
18
|
+
const maxConcurrentChunks = nbSimultaneousFileProcessed;
|
|
19
|
+
const globalChunkLimiter = (0, _intlayer_chokidar.pLimit)(maxConcurrentChunks);
|
|
20
|
+
let docList = await (0, fast_glob.default)(docPattern, { ignore: excludedGlobPattern });
|
|
21
|
+
const aiResult = await require_utils_setupAI.setupAI(configuration, aiOptions);
|
|
22
|
+
if (!aiResult?.hasAIAccess) return;
|
|
23
|
+
const { aiClient, aiConfig } = aiResult;
|
|
24
|
+
if (gitOptions) {
|
|
25
|
+
const gitChangedFiles = await (0, _intlayer_chokidar.listGitFiles)(gitOptions);
|
|
26
|
+
if (gitChangedFiles) docList = docList.filter((path) => gitChangedFiles.some((gitFile) => (0, node_path.join)(process.cwd(), path) === gitFile));
|
|
27
|
+
}
|
|
28
|
+
const batchStartTime = node_perf_hooks.performance.now();
|
|
29
|
+
appLogger(`Translating ${(0, _intlayer_config.colorizeNumber)(docList.length)} files to ${(0, _intlayer_config.colorizeNumber)(locales.length)} locales. \nGlobal Concurrency: ${(0, _intlayer_config.colorizeNumber)(maxConcurrentChunks)} chunks in parallel.`);
|
|
30
|
+
const errorState = {
|
|
31
|
+
count: 0,
|
|
32
|
+
maxErrors: 5,
|
|
33
|
+
shouldStop: false
|
|
34
|
+
};
|
|
35
|
+
await (0, _intlayer_chokidar.parallelize)(docList.flatMap((docPath) => locales.map((locale) => async () => {
|
|
36
|
+
if (errorState.shouldStop) return;
|
|
37
|
+
const absoluteBaseFilePath = (0, node_path.join)(configuration.content.baseDir, docPath);
|
|
38
|
+
const outputFilePath = require_utils_getOutputFilePath.getOutputFilePath(absoluteBaseFilePath, locale, baseLocale);
|
|
39
|
+
if (skipIfExists && (0, node_fs.existsSync)(outputFilePath)) return;
|
|
40
|
+
if (flushStrategy === "incremental" && !(0, node_fs.existsSync)(outputFilePath)) {
|
|
41
|
+
(0, node_fs.mkdirSync)((0, node_path.dirname)(outputFilePath), { recursive: true });
|
|
42
|
+
(0, node_fs.writeFileSync)(outputFilePath, "");
|
|
43
|
+
}
|
|
44
|
+
const fileModificationData = require_utils_checkFileModifiedRange.checkFileModifiedRange(outputFilePath, {
|
|
45
|
+
skipIfModifiedBefore,
|
|
46
|
+
skipIfModifiedAfter
|
|
47
|
+
});
|
|
48
|
+
if (fileModificationData.isSkipped) {
|
|
49
|
+
appLogger(fileModificationData.message);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
await require_translateDoc_translateFile.translateFile({
|
|
53
|
+
baseFilePath: absoluteBaseFilePath,
|
|
54
|
+
outputFilePath,
|
|
55
|
+
locale,
|
|
56
|
+
baseLocale,
|
|
57
|
+
configuration,
|
|
58
|
+
errorState,
|
|
59
|
+
aiOptions,
|
|
60
|
+
customInstructions,
|
|
61
|
+
aiClient,
|
|
62
|
+
aiConfig,
|
|
63
|
+
flushStrategy,
|
|
64
|
+
limit: globalChunkLimiter
|
|
65
|
+
});
|
|
66
|
+
})), (task) => task(), 50);
|
|
67
|
+
const batchDuration = ((node_perf_hooks.performance.now() - batchStartTime) / 1e3).toFixed(2);
|
|
68
|
+
if (errorState.count > 0) appLogger(`Finished with ${errorState.count} errors in ${batchDuration}s.`);
|
|
69
|
+
else appLogger(`${(0, _intlayer_config.colorize)("✔", _intlayer_config.ANSIColors.GREEN)} Batch completed successfully in ${(0, _intlayer_config.colorizeNumber)(batchDuration)}s.`);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
//#endregion
|
|
73
|
+
exports.translateDoc = translateDoc;
|
|
74
|
+
//# sourceMappingURL=translateDoc.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"translateDoc.cjs","names":["docList: string[]","setupAI","performance","errorState: ErrorState","getOutputFilePath","checkFileModifiedRange","translateFile","ANSIColors"],"sources":["../../../src/translateDoc/translateDoc.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { performance } from 'node:perf_hooks';\nimport { listGitFiles, parallelize, pLimit } from '@intlayer/chokidar';\nimport {\n ANSIColors,\n colorize,\n colorizeNumber,\n getAppLogger,\n getConfiguration,\n} from '@intlayer/config';\nimport type { Locale } from '@intlayer/types';\nimport fg from 'fast-glob';\nimport { checkFileModifiedRange } from '../utils/checkFileModifiedRange';\nimport { getOutputFilePath } from '../utils/getOutputFilePath';\nimport { setupAI } from '../utils/setupAI';\nimport { translateFile } from './translateFile';\nimport type { ErrorState, TranslateDocOptions } from './types';\n\nexport const translateDoc = async ({\n docPattern,\n locales,\n excludedGlobPattern,\n baseLocale,\n aiOptions,\n nbSimultaneousFileProcessed = 20, // Default to a higher concurrency for chunks\n configOptions,\n customInstructions,\n skipIfModifiedBefore,\n skipIfModifiedAfter,\n skipIfExists,\n gitOptions,\n flushStrategy = 'incremental',\n}: TranslateDocOptions) => {\n const configuration = getConfiguration(configOptions);\n const appLogger = getAppLogger(configuration);\n\n // 1. GLOBAL QUEUE SETUP\n // We use pLimit to create a single bottleneck for AI requests.\n // This queue is shared across all files and locales.\n const maxConcurrentChunks = nbSimultaneousFileProcessed;\n const globalChunkLimiter = pLimit(maxConcurrentChunks);\n\n let docList: string[] = await fg(docPattern, {\n ignore: excludedGlobPattern,\n });\n\n const aiResult = await setupAI(configuration, aiOptions);\n if (!aiResult?.hasAIAccess) return;\n const { aiClient, aiConfig } = aiResult;\n\n if (gitOptions) {\n const gitChangedFiles = await listGitFiles(gitOptions);\n if (gitChangedFiles) {\n docList = docList.filter((path) =>\n gitChangedFiles.some((gitFile) => join(process.cwd(), path) === gitFile)\n );\n }\n }\n\n const batchStartTime = performance.now();\n\n appLogger(\n `Translating ${colorizeNumber(docList.length)} files to ${colorizeNumber(locales.length)} locales. \\n` +\n `Global Concurrency: ${colorizeNumber(maxConcurrentChunks)} chunks in parallel.`\n );\n\n const errorState: ErrorState = {\n count: 0,\n maxErrors: 5,\n shouldStop: false,\n };\n\n // 2. FLATTENED TASK LIST\n // We create a task for every File x Locale combination.\n const allTasks = docList.flatMap((docPath) =>\n locales.map((locale) => async () => {\n if (errorState.shouldStop) return;\n\n const absoluteBaseFilePath = join(configuration.content.baseDir, docPath);\n const outputFilePath = getOutputFilePath(\n absoluteBaseFilePath,\n locale,\n baseLocale\n );\n\n // Skip logic\n if (skipIfExists && existsSync(outputFilePath)) return;\n\n if (flushStrategy === 'incremental' && !existsSync(outputFilePath)) {\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 // Execute translation using the SHARED limiter\n await translateFile({\n baseFilePath: absoluteBaseFilePath,\n outputFilePath,\n locale: locale as Locale,\n baseLocale,\n configuration,\n errorState,\n aiOptions,\n customInstructions,\n aiClient,\n aiConfig,\n flushStrategy,\n limit: globalChunkLimiter, // Pass the global queue\n });\n })\n );\n\n // 3. HIGH-THROUGHPUT FILE OPENER\n // We open many files simultaneously (e.g., 50) to ensure the global chunk queue\n // is always saturated with work.\n // If we open too few files, the chunk queue might drain faster than we can read new files.\n const FILE_OPEN_LIMIT = 50;\n\n await parallelize(allTasks, (task) => task(), FILE_OPEN_LIMIT);\n\n const batchEndTime = performance.now();\n const batchDuration = ((batchEndTime - batchStartTime) / 1000).toFixed(2);\n\n if (errorState.count > 0) {\n appLogger(`Finished with ${errorState.count} errors in ${batchDuration}s.`);\n } else {\n appLogger(\n `${colorize('✔', ANSIColors.GREEN)} Batch completed successfully in ${colorizeNumber(batchDuration)}s.`\n );\n }\n};\n"],"mappings":";;;;;;;;;;;;;;AAmBA,MAAa,eAAe,OAAO,EACjC,YACA,SACA,qBACA,YACA,WACA,8BAA8B,IAC9B,eACA,oBACA,sBACA,qBACA,cACA,YACA,gBAAgB,oBACS;CACzB,MAAM,uDAAiC,cAAc;CACrD,MAAM,+CAAyB,cAAc;CAK7C,MAAM,sBAAsB;CAC5B,MAAM,oDAA4B,oBAAoB;CAEtD,IAAIA,UAAoB,6BAAS,YAAY,EAC3C,QAAQ,qBACT,CAAC;CAEF,MAAM,WAAW,MAAMC,8BAAQ,eAAe,UAAU;AACxD,KAAI,CAAC,UAAU,YAAa;CAC5B,MAAM,EAAE,UAAU,aAAa;AAE/B,KAAI,YAAY;EACd,MAAM,kBAAkB,2CAAmB,WAAW;AACtD,MAAI,gBACF,WAAU,QAAQ,QAAQ,SACxB,gBAAgB,MAAM,gCAAiB,QAAQ,KAAK,EAAE,KAAK,KAAK,QAAQ,CACzE;;CAIL,MAAM,iBAAiBC,4BAAY,KAAK;AAExC,WACE,oDAA8B,QAAQ,OAAO,CAAC,iDAA2B,QAAQ,OAAO,CAAC,uEACjD,oBAAoB,CAAC,sBAC9D;CAED,MAAMC,aAAyB;EAC7B,OAAO;EACP,WAAW;EACX,YAAY;EACb;AAyDD,2CArDiB,QAAQ,SAAS,YAChC,QAAQ,KAAK,WAAW,YAAY;AAClC,MAAI,WAAW,WAAY;EAE3B,MAAM,2CAA4B,cAAc,QAAQ,SAAS,QAAQ;EACzE,MAAM,iBAAiBC,kDACrB,sBACA,QACA,WACD;AAGD,MAAI,wCAA2B,eAAe,CAAE;AAEhD,MAAI,kBAAkB,iBAAiB,yBAAY,eAAe,EAAE;AAClE,iDAAkB,eAAe,EAAE,EAAE,WAAW,MAAM,CAAC;AACvD,8BAAc,gBAAgB,GAAG;;EAGnC,MAAM,uBAAuBC,4DAAuB,gBAAgB;GAClE;GACA;GACD,CAAC;AAEF,MAAI,qBAAqB,WAAW;AAClC,aAAU,qBAAqB,QAAQ;AACvC;;AAIF,QAAMC,iDAAc;GAClB,cAAc;GACd;GACQ;GACR;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA,OAAO;GACR,CAAC;GACF,CACH,GAQ4B,SAAS,MAAM,EAFpB,GAEsC;CAG9D,MAAM,kBADeJ,4BAAY,KAAK,GACC,kBAAkB,KAAM,QAAQ,EAAE;AAEzE,KAAI,WAAW,QAAQ,EACrB,WAAU,iBAAiB,WAAW,MAAM,aAAa,cAAc,IAAI;KAE3E,WACE,kCAAY,KAAKK,4BAAW,MAAM,CAAC,wEAAkD,cAAc,CAAC,IACrG"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require__utils_asset = require('../_virtual/_utils_asset.cjs');
|
|
3
|
+
const require_translateDoc_validation = require('./validation.cjs');
|
|
4
|
+
const require_utils_chunkInference = require('../utils/chunkInference.cjs');
|
|
5
|
+
const require_utils_fixChunkStartEndChars = require('../utils/fixChunkStartEndChars.cjs');
|
|
6
|
+
const require_utils_calculateChunks = require('../utils/calculateChunks.cjs');
|
|
7
|
+
let _intlayer_chokidar = require("@intlayer/chokidar");
|
|
8
|
+
let _intlayer_config = require("@intlayer/config");
|
|
9
|
+
let node_path = require("node:path");
|
|
10
|
+
let node_fs = require("node:fs");
|
|
11
|
+
let node_fs_promises = require("node:fs/promises");
|
|
12
|
+
let node_perf_hooks = require("node:perf_hooks");
|
|
13
|
+
|
|
14
|
+
//#region src/translateDoc/translateFile.ts
|
|
15
|
+
const translateFile = async ({ baseFilePath, outputFilePath, locale, baseLocale, configuration, errorState, aiOptions, customInstructions, aiClient, aiConfig, flushStrategy = "incremental", onChunkReceive, limit }) => {
|
|
16
|
+
if (errorState.shouldStop) return null;
|
|
17
|
+
const appLogger = (0, _intlayer_config.getAppLogger)(configuration, { config: { prefix: "" } });
|
|
18
|
+
const fileStartTime = node_perf_hooks.performance.now();
|
|
19
|
+
try {
|
|
20
|
+
const chunks = require_utils_calculateChunks.chunkText(await (0, node_fs_promises.readFile)(baseFilePath, "utf-8"));
|
|
21
|
+
const totalChunks = chunks.length;
|
|
22
|
+
const filePrefix = `${(0, _intlayer_config.colon)(`${_intlayer_config.ANSIColors.GREY_DARK}[${(0, _intlayer_chokidar.formatPath)(baseFilePath)}${_intlayer_config.ANSIColors.GREY_DARK}] `, { colSize: 40 })}${_intlayer_config.ANSIColors.RESET}`;
|
|
23
|
+
const prefix = `${(0, _intlayer_config.colon)(`${_intlayer_config.ANSIColors.GREY_DARK}[${(0, _intlayer_chokidar.formatPath)(baseFilePath)}${_intlayer_config.ANSIColors.GREY_DARK}][${(0, _intlayer_chokidar.formatLocale)(locale)}${_intlayer_config.ANSIColors.GREY_DARK}] `, { colSize: 40 })}${_intlayer_config.ANSIColors.RESET}`;
|
|
24
|
+
appLogger(`${filePrefix}Split into ${(0, _intlayer_config.colorizeNumber)(totalChunks)} chunks. Queuing...`);
|
|
25
|
+
const basePrompt = require__utils_asset.readAsset("./prompts/TRANSLATE_PROMPT.md", "utf-8").replaceAll("{{localeName}}", `${(0, _intlayer_chokidar.formatLocale)(locale, false)}`).replaceAll("{{baseLocaleName}}", `${(0, _intlayer_chokidar.formatLocale)(baseLocale, false)}`).replace("{{applicationContext}}", aiOptions?.applicationContext ?? "-").replace("{{customInstructions}}", customInstructions ?? "-");
|
|
26
|
+
const translatedParts = new Array(totalChunks).fill("");
|
|
27
|
+
const runTask = limit ?? ((fn) => fn());
|
|
28
|
+
const tasks = chunks.map((chunk, i) => runTask(async () => {
|
|
29
|
+
if (errorState.shouldStop) return null;
|
|
30
|
+
const chunkLogger = (0, _intlayer_config.getAppLogger)(configuration, { config: { prefix: `${prefix} ${_intlayer_config.ANSIColors.GREY_DARK}[${i + 1}/${totalChunks}] ${_intlayer_config.ANSIColors.RESET}` } });
|
|
31
|
+
const chunkStartTime = node_perf_hooks.performance.now();
|
|
32
|
+
const isFirstChunk = i === 0;
|
|
33
|
+
const fileToTranslateCurrentChunk = chunk.content;
|
|
34
|
+
const getPrevChunkPrompt = () => `>>> CONTEXT: PREVIOUS SOURCE CONTENT <<<\n\`\`\`\n` + (chunks[i - 1]?.content ?? "") + `\n\`\`\`\n>>> END PREVIOUS CONTEXT <<<`;
|
|
35
|
+
const getBaseChunkContextPrompt = () => `>>> CONTEXT: NEXT CONTENT <<<\n\`\`\`\n` + (chunks[i + 1]?.content ?? "") + `\n\`\`\`\n>>> END NEXT CONTEXT <<<`;
|
|
36
|
+
chunkLogger("Process started");
|
|
37
|
+
const { content: translatedChunk, tokens } = await (0, _intlayer_config.retryManager)(async () => {
|
|
38
|
+
const result = await require_utils_chunkInference.chunkInference([
|
|
39
|
+
{
|
|
40
|
+
role: "system",
|
|
41
|
+
content: basePrompt
|
|
42
|
+
},
|
|
43
|
+
...chunks[i + 1] ? [{
|
|
44
|
+
role: "system",
|
|
45
|
+
content: getBaseChunkContextPrompt()
|
|
46
|
+
}] : [],
|
|
47
|
+
...isFirstChunk ? [] : [{
|
|
48
|
+
role: "system",
|
|
49
|
+
content: getPrevChunkPrompt()
|
|
50
|
+
}],
|
|
51
|
+
{
|
|
52
|
+
role: "system",
|
|
53
|
+
content: [`You are translating TARGET CHUNK (${i + 1}/${totalChunks}).`, `Translate ONLY the target chunk. Preserve frontmatter/code exactly.`].join("\n")
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
role: "user",
|
|
57
|
+
content: `>>> TARGET CHUNK START <<<\n${fileToTranslateCurrentChunk}\n>>> TARGET CHUNK END <<<`
|
|
58
|
+
}
|
|
59
|
+
], aiOptions, configuration, aiClient, aiConfig);
|
|
60
|
+
let processedChunk = require_translateDoc_validation.sanitizeChunk(result?.fileContent, fileToTranslateCurrentChunk);
|
|
61
|
+
processedChunk = require_utils_fixChunkStartEndChars.fixChunkStartEndChars(processedChunk, fileToTranslateCurrentChunk);
|
|
62
|
+
if (!require_translateDoc_validation.validateTranslation(fileToTranslateCurrentChunk, processedChunk, chunkLogger)) throw new Error(`Validation failed for chunk ${i + 1}/${totalChunks}`);
|
|
63
|
+
return {
|
|
64
|
+
content: processedChunk,
|
|
65
|
+
tokens: result.tokenUsed
|
|
66
|
+
};
|
|
67
|
+
})();
|
|
68
|
+
const chunkDuration = (node_perf_hooks.performance.now() - chunkStartTime).toFixed(0);
|
|
69
|
+
translatedParts[i] = translatedChunk;
|
|
70
|
+
if (onChunkReceive) onChunkReceive(translatedChunk, i, totalChunks);
|
|
71
|
+
if (flushStrategy === "incremental") {
|
|
72
|
+
if (translatedParts.slice(0, i + 1).every((p) => p && p !== "")) {
|
|
73
|
+
let endIdx = 0;
|
|
74
|
+
while (endIdx < totalChunks && translatedParts[endIdx] && translatedParts[endIdx] !== "") endIdx++;
|
|
75
|
+
const currentContent = translatedParts.slice(0, endIdx).join("");
|
|
76
|
+
(0, node_fs.mkdirSync)((0, node_path.dirname)(outputFilePath), { recursive: true });
|
|
77
|
+
(0, node_fs.writeFileSync)(outputFilePath, currentContent);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
chunkLogger([`${(0, _intlayer_config.colorizeNumber)(tokens)} tokens used `, `${_intlayer_config.ANSIColors.GREY_DARK}in ${(0, _intlayer_config.colorizeNumber)(chunkDuration)}ms${_intlayer_config.ANSIColors.RESET}`].join(""));
|
|
81
|
+
}));
|
|
82
|
+
await Promise.all(tasks);
|
|
83
|
+
const fullContent = translatedParts.join("");
|
|
84
|
+
if (flushStrategy === "end" || flushStrategy === "incremental") {
|
|
85
|
+
(0, node_fs.mkdirSync)((0, node_path.dirname)(outputFilePath), { recursive: true });
|
|
86
|
+
(0, node_fs.writeFileSync)(outputFilePath, fullContent);
|
|
87
|
+
}
|
|
88
|
+
const totalDuration = ((node_perf_hooks.performance.now() - fileStartTime) / 1e3).toFixed(2);
|
|
89
|
+
const relativePath = (0, node_path.relative)(configuration.content.baseDir, outputFilePath);
|
|
90
|
+
appLogger(`${(0, _intlayer_config.colorize)("✔", _intlayer_config.ANSIColors.GREEN)} File ${(0, _intlayer_chokidar.formatPath)(relativePath)} completed in ${(0, _intlayer_config.colorizeNumber)(totalDuration)}s.`);
|
|
91
|
+
return fullContent;
|
|
92
|
+
} catch (error) {
|
|
93
|
+
errorState.count++;
|
|
94
|
+
const errorMessage = error?.message ?? JSON.stringify(error);
|
|
95
|
+
appLogger(`${(0, _intlayer_config.colorize)("✖", _intlayer_config.ANSIColors.RED)} Error: ${errorMessage}`);
|
|
96
|
+
if (errorState.count >= errorState.maxErrors) errorState.shouldStop = true;
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
//#endregion
|
|
102
|
+
exports.translateFile = translateFile;
|
|
103
|
+
//# sourceMappingURL=translateFile.cjs.map
|