@intlayer/cli 8.1.3 → 8.1.5

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 CHANGED
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./_virtual/_rolldown/runtime.cjs`);const e=require(`./build.cjs`),t=require(`./ci.cjs`),n=require(`./auth/login.cjs`),r=require(`./config.cjs`),i=require(`./editor.cjs`),a=require(`./extract.cjs`),o=require(`./test/test.cjs`),s=require(`./fill/fill.cjs`),c=require(`./init.cjs`),l=require(`./initSkills.cjs`),u=require(`./listContentDeclaration.cjs`),d=require(`./listProjects.cjs`),ee=require(`./liveSync.cjs`),f=require(`./pull.cjs`),p=require(`./push/push.cjs`),te=require(`./pushConfig.cjs`),ne=require(`./reviewDoc/reviewDoc.cjs`),re=require(`./searchDoc.cjs`),ie=require(`./translateDoc/translateDoc.cjs`),m=require(`./utils/getParentPackageJSON.cjs`),h=require(`./watch.cjs`);let g=require(`@intlayer/config/node`),_=require(`node:path`),v=require(`@intlayer/config/logger`),y=require(`node:url`),ae=require(`commander`);const b=typeof require(`url`).pathToFileURL(__filename).href==`string`?(0,_.dirname)((0,y.fileURLToPath)(require(`url`).pathToFileURL(__filename).href)):__dirname,x=m.getParentPackageJSON(b),S=[[`--env-file [envFile]`,`Environment file`],[`-e, --env [env]`,`Environment`],[`--base-dir [baseDir]`,`Base directory`],[`--no-cache [noCache]`,`No cache`],...[[`--verbose`,`Verbose (default to true using CLI)`],[`--prefix [prefix]`,`Prefix`]]],C=[[`--provider [provider]`,`Provider`],[`--temperature [temperature]`,`Temperature`],[`--model [model]`,`Model`],[`--api-key [apiKey]`,`Provider API key`],[`--custom-prompt [prompt]`,`Custom prompt`],[`--application-context [applicationContext]`,`Application context`],[`--data-serialization [dataSerialization]`,`Data serialization`]],w=[[`--git-diff [gitDiff]`,`Git diff mode - Check git diff between two refs`],[`--git-diff-base [gitDiffBase]`,`Git diff base ref`],[`--git-diff-current [gitDiffCurrent]`,`Git diff current ref`],[`--uncommitted [uncommitted]`,`Uncommitted`],[`--unpushed [unpushed]`,`Unpushed`],[`--untracked [untracked]`,`Untracked`]],T=(e,t)=>t.filter(t=>e[t]),E=(e,t)=>(t.forEach(([t,n])=>{e.option(t,n)}),e),D=e=>Object.fromEntries(Object.entries(e).filter(([e,t])=>t!==void 0)),O=e=>E(e,S),k=e=>E(e,C),A=e=>E(e,w),j=e=>{let{apiKey:t,provider:n,model:r,temperature:i,applicationContext:a,customPrompt:o,dataSerialization:s}=e,c=(0,g.getConfiguration)(),{ai:l}=c;return D({...l,apiKey:t??c.ai?.apiKey,provider:n??c.ai?.provider,model:r??c.ai?.model,temperature:i??c.ai?.temperature,applicationContext:a??c.ai?.applicationContext,customPrompt:o??c.ai?.customPrompt,dataSerialization:s??c.ai?.dataSerialization})},M=[`gitDiff`,`gitDiffBase`,`gitDiffCurrent`,`uncommitted`,`unpushed`,`untracked`],N=e=>{let t=T(e,M);if(!Object.values(t).some(Boolean))return;let{gitDiff:n,gitDiffBase:r,gitDiffCurrent:i,uncommitted:a,unpushed:o,untracked:s}=e;return D({mode:[n&&`gitDiff`,a&&`uncommitted`,o&&`unpushed`,s&&`untracked`].filter(Boolean),baseRef:r,currentRef:i,absolute:!0})},P=[`baseDir`,`env`,`envFile`,`verbose`,`prefix`],F=e=>{let t=(0,g.getConfiguration)(e),n=T(e,P);if(!Object.values(n).some(Boolean))return;let{baseDir:r,env:i,envFile:a,verbose:o,prefix:s,noCache:c}=e,l=!!e.with;return typeof s==`string`?(0,v.setPrefix)(s):l&&(0,v.setPrefix)(t.log.prefix),D({baseDir:r,env:i,envFile:a,override:{log:{verbose:o??!0}},cache:!c})},I=()=>{(0,v.setPrefix)(``);let m=new ae.Command;m.version(x.version).description(`Intlayer CLI`),m.command(`version`).description(`Print the Intlayer CLI version`).action(()=>{console.log(x.version??`unknown`)});let g=m.command(`login`).description(`Login to Intlayer`).option(`--cms-url [cmsUrl]`,`CMS URL`);O(g),g.action(e=>{let t=F(e)??{override:{log:{prefix:``,verbose:!0}}};return n.login({cmsUrl:e.cmsUrl,configOptions:t})}),m.command(`init`).description(`Initialize Intlayer in the project`).option(`--project-root [projectRoot]`,`Project root directory`).action(e=>c.init(e.projectRoot)).command(`skills`).description(`Initialize Intlayer skills in the project`).option(`--project-root [projectRoot]`,`Project root directory`).action(e=>l.initSkills(e.projectRoot));let _=m.command(`dictionary`).alias(`dictionaries`).alias(`dic`).description(`Dictionaries operations`),y={description:`Build the dictionaries`,options:[[`-w, --watch`,`Watch for changes`],[`--skip-prepare`,`Skip the prepare step`],[`--with [with...]`,`Start command in parallel with the build`]]},b=_.command(`build`).description(y.description);E(b,y.options),O(b),b.action(t=>{e.build({...t,configOptions:F(t)})});let S=m.command(`build`).description(y.description);E(S,y.options),O(S),S.action(t=>{e.build({...t,configOptions:F(t)})});let C={description:`Watch the dictionaries changes`,options:[[`--with [with...]`,`Start command in parallel with the build`]]},w=_.command(`watch`).description(y.description);E(w,C.options),O(w),w.action(e=>{h.watchContentDeclaration({...e,configOptions:F(e)})});let T=m.command(`watch`).description(y.description);E(T,C.options),O(T),T.action(e=>{h.watchContentDeclaration({...e,configOptions:F(e)})});let D={description:`Pull dictionaries from the server`,options:[[`-d, --dictionaries [ids...]`,`List of dictionary IDs to pull`],[`--dictionary [ids...]`,`List of dictionary IDs to pull (alias for --dictionaries)`],[`--new-dictionaries-path [path]`,`Path to save the new dictionaries`],[`--newDictionariesPath [path]`,`[alias] Path to save the new dictionaries`]]},M=_.command(`pull`).description(D.description);E(M,D.options),O(M),M.action(e=>{let t=[...e.dictionaries??[],...e.dictionary??[]];f.pull({...e,dictionaries:t.length>0?t:void 0,configOptions:{...e.configOptions,baseDir:e.baseDir}})});let P=m.command(`pull`).description(D.description);E(P,D.options),O(P),P.action(e=>{let t=[...e.dictionaries??[],...e.dictionary??[]];f.pull({...e,dictionaries:t.length>0?t:void 0,configOptions:F(e)})});let I={description:`Push all dictionaries. Create or update the pushed dictionaries`,options:[[`-d, --dictionaries [ids...]`,`List of dictionary IDs to push`],[`--dictionary [ids...]`,`List of dictionary IDs to push (alias for --dictionaries)`],[`-r, --delete-locale-dictionary`,`Delete the local dictionaries after pushing`],[`-k, --keep-locale-dictionary`,`Keep the local dictionaries after pushing`],[`--deleteLocaleDictionary`,`[alias] Delete the local dictionaries after pushing`],[`--keepLocaleDictionary`,`[alias] Keep the local dictionaries after pushing`],[`--build [build]`,`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`]]},L=_.command(`push`).description(I.description);E(L,I.options),O(L),A(L),L.action(e=>{let t=[...e.dictionaries||[],...e.dictionary||[]];return p.push({...e,dictionaries:t.length>0?t:void 0,gitOptions:N(e),configOptions:F(e)})});let R=m.command(`push`).description(I.description);E(R,I.options),O(R),A(R),R.action(e=>{let t=[...e.dictionaries||[],...e.dictionary||[]];return p.push({...e,dictionaries:t.length>0?t:void 0,gitOptions:N(e),configOptions:F(e)})});let z=m.command(`configuration`).alias(`config`).alias(`conf`).description(`Configuration operations`),B=z.command(`get`).description(`Get the configuration`);O(B),B.action(e=>{r.getConfig({...e,configOptions:F(e)})});let V=z.command(`push`).description(`Push the configuration`);O(V),V.action(e=>{te.pushConfig({...e,configOptions:F(e)})}),m.command(`projects`).alias(`project`).description(`List Intlayer projects`).command(`list`).description(`List all Intlayer projects in the directory`).option(`--base-dir [baseDir]`,`Base directory to search from`).option(`--git-root`,`Search from the git root directory instead of the base directory`).option(`--json`,`Output the results as JSON`).action(e=>{d.listProjectsCommand({baseDir:e.baseDir,gitRoot:e.gitRoot,json:e.json})}),m.command(`projects-list`).alias(`pl`).description(`List all Intlayer projects in the directory`).option(`--base-dir [baseDir]`,`Base directory to search from`).option(`--git-root`,`Search from the git root directory instead of the base directory`).option(`--absolute`,`Output the results as absolute paths`).option(`--json`,`Output the results as JSON`).action(e=>{d.listProjectsCommand({baseDir:e.baseDir,gitRoot:e.gitRoot,json:e.json,absolute:e.absolute})});let H=m.command(`content`).description(`Content declaration operations`);H.command(`list`).description(`List the content declaration files`).option(`--json`,`Output the results as JSON`).option(`--absolute`,`Output the results as absolute paths`).action(e=>{u.listContentDeclaration({json:e.json,absolute:e.absolute})}),m.command(`list`).description(`List the content declaration files`).option(`--json`,`Output the results as JSON`).option(`--absolute`,`Output the results as absolute paths`).action(e=>{u.listContentDeclaration({json:e.json,absolute:e.absolute})});let U=H.command(`test`).description(`Test if there are missing translations`).option(`--build [build]`,`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`);O(U),U.action(e=>{o.testMissingTranslations({...e,configOptions:F(e)})});let W=m.command(`test`).description(`Test if there are missing translations`).option(`--build [build]`,`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`);O(W),W.action(e=>{o.testMissingTranslations({...e,configOptions:F(e)})});let G=m.command(`fill`).description(`Fill the dictionaries`).option(`-f, --file [files...]`,`List of Dictionary files to fill`).option(`--source-locale [sourceLocale]`,`Source locale to translate from`).option(`--output-locales [outputLocales...]`,`Target locales to translate to`).option(`--mode [mode]`,`Fill mode: complete, review. Complete will fill all missing content, review will fill missing content and review existing keys`,`complete`).option(`-k, --keys [keys...]`,`Filter dictionaries based on keys`).option(`--key [keys...]`,`Filter dictionaries based on keys (alias for --keys)`).option(`--excluded-keys [excludedKeys...]`,`Filter out dictionaries based on keys`).option(`--excluded-key [excludedKeys...]`,`Filter out dictionaries based on keys (alias for --excluded-keys)`).option(`--path-filter [pathFilters...]`,`Filter dictionaries based on glob pattern`).option(`--build [build]`,`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`).option(`--skip-metadata`,`Skip filling missing metadata (description, title, tags) for dictionaries`);O(G),k(G),A(G),G.action(e=>{let t=[...e.keys??[],...e.key??[]],n=[...e.excludedKeys??[],...e.excludedKey??[]],r=[...e.dictionaries??[],...e.dictionary??[]];return s.fill({...e,keys:t.length>0?t:void 0,excludedKeys:n.length>0?n:void 0,dictionaries:r.length>0?r:void 0,aiOptions:j(e),gitOptions:N(e),configOptions:F(e)})});let K=[[`--doc-pattern [docPattern...]`,`Documentation pattern`],[`--excluded-glob-pattern [excludedGlobPattern...]`,`Excluded glob pattern`],[`--nb-simultaneous-file-processed [nbSimultaneousFileProcessed]`,`Number of simultaneous file processed`],[`--locales [locales...]`,`Locales`],[`--base-locale [baseLocale]`,`Base locale`],[`--custom-instructions [customInstructions]`,`Custom instructions added to the prompt. Usefull to apply specific rules regarding formatting, urls translation, etc.`],[`--skip-if-modified-before [skipIfModifiedBefore]`,'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.'],[`--skip-if-modified-after [skipIfModifiedAfter]`,'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.'],[`--skip-if-exists`,`Skip the file if it already exists`]],q=m.command(`doc`).description(`Documentation operations`),J=q.command(`translate`).description(`Translate the documentation`);O(J),k(J),A(J),E(J,K),J.action(e=>ie.translateDoc({docPattern:e.docPattern,excludedGlobPattern:e.excludedGlobPattern,locales:e.locales,baseLocale:e.baseLocale,aiOptions:j(e),gitOptions:N(e),nbSimultaneousFileProcessed:e.nbSimultaneousFileProcessed,configOptions:F(e),customInstructions:e.customInstructions,skipIfModifiedBefore:e.skipIfModifiedBefore,skipIfModifiedAfter:e.skipIfModifiedAfter,skipIfExists:e.skipIfExists}));let Y=q.command(`review`).description(`Review the documentation`);O(Y),k(Y),A(Y),E(Y,K),Y.action(e=>ne.reviewDoc({docPattern:e.docPattern,excludedGlobPattern:e.excludedGlobPattern,locales:e.locales,baseLocale:e.baseLocale,aiOptions:j(e),gitOptions:N(e),nbSimultaneousFileProcessed:e.nbSimultaneousFileProcessed,configOptions:F(e),customInstructions:e.customInstructions,skipIfModifiedBefore:e.skipIfModifiedBefore,skipIfModifiedAfter:e.skipIfModifiedAfter,skipIfExists:e.skipIfExists}));let X=q.command(`search`).description(`Search the documentation`).argument(`<query>`,`Search query`).option(`--limit [limit]`,`Limit the number of results`,`10`);O(X),X.action((e,t)=>re.searchDoc({query:e,limit:t.limit?parseInt(t.limit,10):10,configOptions:F(t)}));let oe=[[`--with [with...]`,`Start command in parallel with the live sync`]],Z=m.command(`live`).description(`Live sync - Watch for changes made on the CMS and update the application content accordingly`);E(Z,oe),O(Z),Z.action(e=>ee.liveSync(e));let Q=m.command(`editor`).description(`Visual editor operations`).command(`start`).description(`Start the Intlayer visual editor`);O(Q),Q.action(e=>{i.startEditor({env:e.env,envFile:e.envFile})});let $=m.command(`extract`).alias(`ext`).description(`Extract strings from components to be placed in a .content file close to the component`);return $.option(`-f, --file [files...]`,`List of files to extract`).option(`-o, --output-content-declarations [outputContentDeclarations]`,`Path to output content declaration files`).option(`--code-only`,`Only extract the component code`,!1).option(`--declaration-only`,`Only generate content declaration`,!1).action(e=>{a.extract({files:e.file,outputContentDeclarations:e.outputContentDeclarations,configOptions:F(e),codeOnly:e.codeOnly,declarationOnly:e.declarationOnly})}),O($),m.parse(process.argv),m.command(`ci`).description(`Run Intlayer commands with auto-injected credentials from INTLAYER_PROJECT_CREDENTIALS. Detects current project or iterates over all projects.`).argument(`<command...>`,`The intlayer command to execute (e.g., "fill", "push")`).allowUnknownOption().action(e=>{t.runCI(e)}),m};exports.dirname=b,exports.setAPI=I;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./_virtual/_rolldown/runtime.cjs`);const e=require(`./build.cjs`),t=require(`./ci.cjs`),n=require(`./auth/login.cjs`),r=require(`./config.cjs`),i=require(`./editor.cjs`),a=require(`./extract.cjs`),o=require(`./test/test.cjs`),s=require(`./fill/fill.cjs`),c=require(`./init.cjs`),l=require(`./initSkills.cjs`),u=require(`./listContentDeclaration.cjs`),d=require(`./listProjects.cjs`),ee=require(`./liveSync.cjs`),f=require(`./pull.cjs`),p=require(`./push/push.cjs`),te=require(`./pushConfig.cjs`),ne=require(`./reviewDoc/reviewDoc.cjs`),re=require(`./searchDoc.cjs`),ie=require(`./translateDoc/translateDoc.cjs`),m=require(`./utils/getParentPackageJSON.cjs`),h=require(`./watch.cjs`);let g=require(`@intlayer/config/node`),_=require(`node:path`),v=require(`@intlayer/config/logger`),y=require(`node:url`),ae=require(`commander`);const b=typeof require(`url`).pathToFileURL(__filename).href==`string`?(0,_.dirname)((0,y.fileURLToPath)(require(`url`).pathToFileURL(__filename).href)):__dirname,x=m.getParentPackageJSON(b),S=[[`--env-file [envFile]`,`Environment file`],[`-e, --env [env]`,`Environment`],[`--base-dir [baseDir]`,`Base directory`],[`--no-cache [noCache]`,`No cache`],...[[`--verbose`,`Verbose (default to true using CLI)`],[`--prefix [prefix]`,`Prefix`]]],C=[[`--provider [provider]`,`Provider`],[`--temperature [temperature]`,`Temperature`],[`--model [model]`,`Model`],[`--api-key [apiKey]`,`Provider API key`],[`--custom-prompt [prompt]`,`Custom prompt`],[`--application-context [applicationContext]`,`Application context`],[`--data-serialization [dataSerialization]`,`Data serialization`]],w=[[`--git-diff [gitDiff]`,`Git diff mode - Check git diff between two refs`],[`--git-diff-base [gitDiffBase]`,`Git diff base ref`],[`--git-diff-current [gitDiffCurrent]`,`Git diff current ref`],[`--uncommitted [uncommitted]`,`Uncommitted`],[`--unpushed [unpushed]`,`Unpushed`],[`--untracked [untracked]`,`Untracked`]],T=(e,t)=>t.filter(t=>e[t]!==void 0),E=(e,t)=>(t.forEach(([t,n])=>{e.option(t,n)}),e),D=e=>Object.fromEntries(Object.entries(e).filter(([e,t])=>t!==void 0)),O=e=>E(e,S),k=e=>E(e,C),A=e=>E(e,w),j=e=>{let{apiKey:t,provider:n,model:r,temperature:i,applicationContext:a,customPrompt:o,dataSerialization:s}=e,c=(0,g.getConfiguration)(),{ai:l}=c;return D({...l,apiKey:t??c.ai?.apiKey,provider:n??c.ai?.provider,model:r??c.ai?.model,temperature:i??c.ai?.temperature,applicationContext:a??c.ai?.applicationContext,customPrompt:o??c.ai?.customPrompt,dataSerialization:s??c.ai?.dataSerialization})},M=[`gitDiff`,`gitDiffBase`,`gitDiffCurrent`,`uncommitted`,`unpushed`,`untracked`],N=e=>{if(T(e,M).length===0)return;let{gitDiff:t,gitDiffBase:n,gitDiffCurrent:r,uncommitted:i,unpushed:a,untracked:o}=e;return D({mode:[t&&`gitDiff`,i&&`uncommitted`,a&&`unpushed`,o&&`untracked`].filter(Boolean),baseRef:n,currentRef:r,absolute:!0})},P=[`baseDir`,`env`,`envFile`,`verbose`,`prefix`,`checkTypes`],F=e=>{if(T(e,P).length===0)return;e.with===void 0&&(0,v.setPrefix)(``);let{baseDir:t,env:n,envFile:r,verbose:i,noCache:a,checkTypes:o}=e,s=D({mode:i===void 0?void 0:i?`verbose`:`default`}),c=D({checkTypes:o}),l=D({log:Object.keys(s).length>0?s:void 0,build:Object.keys(c).length>0?c:void 0});return D({baseDir:t,env:n,envFile:r,override:Object.keys(l).length>0?l:void 0,cache:a===void 0?void 0:!a})},I=()=>{process.argv.includes(`--with`)||(0,v.setPrefix)(``);let m=new ae.Command;m.version(x.version).description(`Intlayer CLI`),m.command(`version`).description(`Print the Intlayer CLI version`).action(()=>{console.log(x.version??`unknown`)});let g=m.command(`login`).description(`Login to Intlayer`).option(`--cms-url [cmsUrl]`,`CMS URL`);O(g),g.action(e=>{let t=F(e)??{override:{log:{prefix:``,mode:`verbose`}}};return n.login({cmsUrl:e.cmsUrl,configOptions:t})}),m.command(`init`).description(`Initialize Intlayer in the project`).option(`--project-root [projectRoot]`,`Project root directory`).action(e=>c.init(e.projectRoot)).command(`skills`).description(`Initialize Intlayer skills in the project`).option(`--project-root [projectRoot]`,`Project root directory`).action(e=>l.initSkills(e.projectRoot));let _=m.command(`dictionary`).alias(`dictionaries`).alias(`dic`).description(`Dictionaries operations`),y={description:`Build the dictionaries`,options:[[`-w, --watch`,`Watch for changes`],[`--skip-prepare`,`Skip the prepare step`],[`--with [with...]`,`Start command in parallel with the build`],[`--check-types`,`Check TypeScript type and log errors`]]},b=_.command(`build`).description(y.description);E(b,y.options),O(b),b.action(t=>{e.build({...t,configOptions:F(t)})});let S=m.command(`build`).description(y.description);E(S,y.options),O(S),S.action(t=>{e.build({...t,configOptions:F(t)})});let C={description:`Watch the dictionaries changes`,options:[[`--with [with...]`,`Start command in parallel with the build`]]},w=_.command(`watch`).description(y.description);E(w,C.options),O(w),w.action(e=>{h.watchContentDeclaration({...e,configOptions:F(e)})});let T=m.command(`watch`).description(y.description);E(T,C.options),O(T),T.action(e=>{h.watchContentDeclaration({...e,configOptions:F(e)})});let D={description:`Pull dictionaries from the server`,options:[[`-d, --dictionaries [ids...]`,`List of dictionary IDs to pull`],[`--dictionary [ids...]`,`List of dictionary IDs to pull (alias for --dictionaries)`],[`--new-dictionaries-path [path]`,`Path to save the new dictionaries`],[`--newDictionariesPath [path]`,`[alias] Path to save the new dictionaries`]]},M=_.command(`pull`).description(D.description);E(M,D.options),O(M),M.action(e=>{let t=[...e.dictionaries??[],...e.dictionary??[]];f.pull({...e,dictionaries:t.length>0?t:void 0,configOptions:{...e.configOptions,baseDir:e.baseDir}})});let P=m.command(`pull`).description(D.description);E(P,D.options),O(P),P.action(e=>{let t=[...e.dictionaries??[],...e.dictionary??[]];f.pull({...e,dictionaries:t.length>0?t:void 0,configOptions:F(e)})});let I={description:`Push all dictionaries. Create or update the pushed dictionaries`,options:[[`-d, --dictionaries [ids...]`,`List of dictionary IDs to push`],[`--dictionary [ids...]`,`List of dictionary IDs to push (alias for --dictionaries)`],[`-r, --delete-locale-dictionary`,`Delete the local dictionaries after pushing`],[`-k, --keep-locale-dictionary`,`Keep the local dictionaries after pushing`],[`--deleteLocaleDictionary`,`[alias] Delete the local dictionaries after pushing`],[`--keepLocaleDictionary`,`[alias] Keep the local dictionaries after pushing`],[`--build [build]`,`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`]]},L=_.command(`push`).description(I.description);E(L,I.options),O(L),A(L),L.action(e=>{let t=[...e.dictionaries||[],...e.dictionary||[]];return p.push({...e,dictionaries:t.length>0?t:void 0,gitOptions:N(e),configOptions:F(e)})});let R=m.command(`push`).description(I.description);E(R,I.options),O(R),A(R),R.action(e=>{let t=[...e.dictionaries||[],...e.dictionary||[]];return p.push({...e,dictionaries:t.length>0?t:void 0,gitOptions:N(e),configOptions:F(e)})});let z=m.command(`configuration`).alias(`config`).alias(`conf`).description(`Configuration operations`),B=z.command(`get`).description(`Get the configuration`);O(B),B.action(e=>{r.getConfig({...e,configOptions:F(e)})});let V=z.command(`push`).description(`Push the configuration`);O(V),V.action(e=>{te.pushConfig({...e,configOptions:F(e)})}),m.command(`projects`).alias(`project`).description(`List Intlayer projects`).command(`list`).description(`List all Intlayer projects in the directory`).option(`--base-dir [baseDir]`,`Base directory to search from`).option(`--git-root`,`Search from the git root directory instead of the base directory`).option(`--json`,`Output the results as JSON`).action(e=>{d.listProjectsCommand({baseDir:e.baseDir,gitRoot:e.gitRoot,json:e.json})}),m.command(`projects-list`).alias(`pl`).description(`List all Intlayer projects in the directory`).option(`--base-dir [baseDir]`,`Base directory to search from`).option(`--git-root`,`Search from the git root directory instead of the base directory`).option(`--absolute`,`Output the results as absolute paths`).option(`--json`,`Output the results as JSON`).action(e=>{d.listProjectsCommand({baseDir:e.baseDir,gitRoot:e.gitRoot,json:e.json,absolute:e.absolute})});let H=m.command(`content`).description(`Content declaration operations`);H.command(`list`).description(`List the content declaration files`).option(`--json`,`Output the results as JSON`).option(`--absolute`,`Output the results as absolute paths`).action(e=>{u.listContentDeclaration({json:e.json,absolute:e.absolute})}),m.command(`list`).description(`List the content declaration files`).option(`--json`,`Output the results as JSON`).option(`--absolute`,`Output the results as absolute paths`).action(e=>{u.listContentDeclaration({json:e.json,absolute:e.absolute})});let U=H.command(`test`).description(`Test if there are missing translations`).option(`--build [build]`,`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`);O(U),U.action(e=>{o.testMissingTranslations({...e,configOptions:F(e)})});let W=m.command(`test`).description(`Test if there are missing translations`).option(`--build [build]`,`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`);O(W),W.action(e=>{o.testMissingTranslations({...e,configOptions:F(e)})});let G=m.command(`fill`).description(`Fill the dictionaries`).option(`-f, --file [files...]`,`List of Dictionary files to fill`).option(`--source-locale [sourceLocale]`,`Source locale to translate from`).option(`--output-locales [outputLocales...]`,`Target locales to translate to`).option(`--mode [mode]`,`Fill mode: complete, review. Complete will fill all missing content, review will fill missing content and review existing keys`,`complete`).option(`-k, --keys [keys...]`,`Filter dictionaries based on keys`).option(`--key [keys...]`,`Filter dictionaries based on keys (alias for --keys)`).option(`--excluded-keys [excludedKeys...]`,`Filter out dictionaries based on keys`).option(`--excluded-key [excludedKeys...]`,`Filter out dictionaries based on keys (alias for --excluded-keys)`).option(`--path-filter [pathFilters...]`,`Filter dictionaries based on glob pattern`).option(`--build [build]`,`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`).option(`--skip-metadata`,`Skip filling missing metadata (description, title, tags) for dictionaries`);O(G),k(G),A(G),G.action(e=>{let t=[...e.keys??[],...e.key??[]],n=[...e.excludedKeys??[],...e.excludedKey??[]],r=[...e.dictionaries??[],...e.dictionary??[]];return s.fill({...e,keys:t.length>0?t:void 0,excludedKeys:n.length>0?n:void 0,dictionaries:r.length>0?r:void 0,aiOptions:j(e),gitOptions:N(e),configOptions:F(e)})});let K=[[`--doc-pattern [docPattern...]`,`Documentation pattern`],[`--excluded-glob-pattern [excludedGlobPattern...]`,`Excluded glob pattern`],[`--nb-simultaneous-file-processed [nbSimultaneousFileProcessed]`,`Number of simultaneous file processed`],[`--locales [locales...]`,`Locales`],[`--base-locale [baseLocale]`,`Base locale`],[`--custom-instructions [customInstructions]`,`Custom instructions added to the prompt. Usefull to apply specific rules regarding formatting, urls translation, etc.`],[`--skip-if-modified-before [skipIfModifiedBefore]`,'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.'],[`--skip-if-modified-after [skipIfModifiedAfter]`,'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.'],[`--skip-if-exists`,`Skip the file if it already exists`]],q=m.command(`doc`).description(`Documentation operations`),J=q.command(`translate`).description(`Translate the documentation`);O(J),k(J),A(J),E(J,K),J.action(e=>ie.translateDoc({docPattern:e.docPattern,excludedGlobPattern:e.excludedGlobPattern,locales:e.locales,baseLocale:e.baseLocale,aiOptions:j(e),gitOptions:N(e),nbSimultaneousFileProcessed:e.nbSimultaneousFileProcessed,configOptions:F(e),customInstructions:e.customInstructions,skipIfModifiedBefore:e.skipIfModifiedBefore,skipIfModifiedAfter:e.skipIfModifiedAfter,skipIfExists:e.skipIfExists}));let Y=q.command(`review`).description(`Review the documentation`);O(Y),k(Y),A(Y),E(Y,K),Y.action(e=>ne.reviewDoc({docPattern:e.docPattern,excludedGlobPattern:e.excludedGlobPattern,locales:e.locales,baseLocale:e.baseLocale,aiOptions:j(e),gitOptions:N(e),nbSimultaneousFileProcessed:e.nbSimultaneousFileProcessed,configOptions:F(e),customInstructions:e.customInstructions,skipIfModifiedBefore:e.skipIfModifiedBefore,skipIfModifiedAfter:e.skipIfModifiedAfter,skipIfExists:e.skipIfExists}));let X=q.command(`search`).description(`Search the documentation`).argument(`<query>`,`Search query`).option(`--limit [limit]`,`Limit the number of results`,`10`);O(X),X.action((e,t)=>re.searchDoc({query:e,limit:t.limit?parseInt(t.limit,10):10,configOptions:F(t)}));let oe=[[`--with [with...]`,`Start command in parallel with the live sync`]],Z=m.command(`live`).description(`Live sync - Watch for changes made on the CMS and update the application content accordingly`);E(Z,oe),O(Z),Z.action(e=>ee.liveSync(e));let Q=m.command(`editor`).description(`Visual editor operations`).command(`start`).description(`Start the Intlayer visual editor`);O(Q),Q.action(e=>{i.startEditor({env:e.env,envFile:e.envFile})});let $=m.command(`extract`).alias(`ext`).description(`Extract strings from components to be placed in a .content file close to the component`);return $.option(`-f, --file [files...]`,`List of files to extract`).option(`-o, --output-content-declarations [outputContentDeclarations]`,`Path to output content declaration files`).option(`--code-only`,`Only extract the component code`,!1).option(`--declaration-only`,`Only generate content declaration`,!1).action(e=>{a.extract({files:e.file,outputContentDeclarations:e.outputContentDeclarations,configOptions:F(e),codeOnly:e.codeOnly,declarationOnly:e.declarationOnly})}),O($),m.parse(process.argv),m.command(`ci`).description(`Run Intlayer commands with auto-injected credentials from INTLAYER_PROJECT_CREDENTIALS. Detects current project or iterates over all projects.`).argument(`<command...>`,`The intlayer command to execute (e.g., "fill", "push")`).allowUnknownOption().action(e=>{t.runCI(e)}),m};exports.dirname=b,exports.setAPI=I;
2
2
  //# sourceMappingURL=cli.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"cli.cjs","names":["getParentPackageJSON","Command","login","init","initSkills","push","fill","translateDoc","reviewDoc","searchDoc","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 { DiffMode, ListGitFilesOptions } from '@intlayer/chokidar/cli';\nimport { setPrefix } from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport { Command } from 'commander';\nimport { login } from './auth/login';\nimport { build } from './build';\nimport { runCI } from './ci';\nimport { getConfig } from './config';\nimport { startEditor } from './editor';\nimport { extract } from './extract';\nimport { type FillOptions, fill } from './fill/fill';\nimport { init } from './init';\nimport { initSkills } from './initSkills';\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 { searchDoc } from './searchDoc';\nimport { testMissingTranslations } from './test';\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 ['--data-serialization [dataSerialization]', 'Data serialization'],\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 dataSerialization,\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 dataSerialization: dataSerialization ?? configuration.ai?.dataSerialization,\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\n if (typeof prefix === 'string') {\n setPrefix(prefix);\n } else if (addPrefix) {\n setPrefix(configuration.log.prefix);\n }\n\n const log = {\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 setPrefix('');\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 const initCmd = 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 initCmd\n .command('skills')\n .description('Initialize Intlayer skills in the project')\n .option('--project-root [projectRoot]', 'Project root directory')\n .action((options) => initSkills(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 const searchProgram = docProgram\n .command('search')\n .description('Search the documentation')\n .argument('<query>', 'Search query')\n .option('--limit [limit]', 'Limit the number of results', '10');\n\n applyConfigOptions(searchProgram);\n\n searchProgram.action((query, options) =>\n searchDoc({\n query,\n limit: options.limit ? parseInt(options.limit, 10) : 10,\n configOptions: extractConfigOptions(options),\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 * EXTRACT\n */\n const extractProgram = program\n .command('extract')\n .alias('ext')\n .description(\n 'Extract strings from components to be placed in a .content file close to the component'\n );\n\n extractProgram\n .option('-f, --file [files...]', 'List of files to extract')\n .option(\n '-o, --output-content-declarations [outputContentDeclarations]',\n 'Path to output content declaration files'\n )\n .option('--code-only', 'Only extract the component code', false)\n .option('--declaration-only', 'Only generate content declaration', false)\n .action((options) => {\n extract({\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(extractProgram);\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":"w4BAuCA,MAAa,EAFM,OAAA,QAAA,MAAA,CAAA,cAAA,WAAA,CAAA,MAA2B,UAEvB,EAAA,EAAA,UAAA,EAAA,EAAA,eAAA,QAAA,MAAA,CAAA,cAAA,WAAA,CAAA,KACuB,CAAC,CAC3C,UAEE,EAAcA,EAAAA,qBAAqB,EAAQ,CAO3C,EAAuB,CAC3B,CAAC,uBAAwB,mBAAmB,CA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0BACnC,cAAe,EAAqB,EAAQ,CAC5C,SAAU,EAAQ,SAClB,gBAAiB,EAAQ,gBAC1B,CAAC,EACF,CAEJ,EAAmB,EAAe,CAElC,EAAQ,MAAM,QAAQ,KAAK,CAO3B,EACG,QAAQ,KAAK,CACb,YACC,iJACD,CACA,SACC,eACA,yDACD,CACA,oBAAoB,CACpB,OAAQ,GAAS,CAChB,EAAA,MAAM,EAAK,EACX,CAEG"}
1
+ {"version":3,"file":"cli.cjs","names":["getParentPackageJSON","Command","login","init","initSkills","push","fill","translateDoc","reviewDoc","searchDoc","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 { DiffMode, ListGitFilesOptions } from '@intlayer/chokidar/cli';\nimport { setPrefix } from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport type { CustomIntlayerConfig } from '@intlayer/types';\nimport { Command } from 'commander';\nimport { login } from './auth/login';\nimport { build } from './build';\nimport { runCI } from './ci';\nimport { getConfig } from './config';\nimport { startEditor } from './editor';\nimport { extract } from './extract';\nimport { type FillOptions, fill } from './fill/fill';\nimport { init } from './init';\nimport { initSkills } from './initSkills';\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 { searchDoc } from './searchDoc';\nimport { testMissingTranslations } from './test';\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 ['--data-serialization [dataSerialization]', 'Data serialization'],\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] !== undefined);\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 dataSerialization,\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 dataSerialization: dataSerialization ?? configuration.ai?.dataSerialization,\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 = filteredOptions.length === 0;\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 checkTypes?: boolean;\n} & LogOptions;\n\nconst configurationOptionKeys: (keyof ConfigurationOptions)[] = [\n 'baseDir',\n 'env',\n 'envFile',\n 'verbose',\n 'prefix',\n 'checkTypes',\n];\n\nconst extractConfigOptions = (\n options: ConfigurationOptions & { with?: string }\n): GetConfigurationOptions | undefined => {\n const filteredOptions = extractKeysFromOptions(\n options,\n configurationOptionKeys\n );\n\n const isOptionEmpty = filteredOptions.length === 0;\n\n if (isOptionEmpty) {\n return undefined;\n }\n\n if (typeof options.with === 'undefined') {\n setPrefix('');\n }\n\n const { baseDir, env, envFile, verbose, noCache, checkTypes } = options;\n\n const log = removeUndefined({\n mode:\n typeof verbose !== 'undefined'\n ? verbose\n ? 'verbose'\n : 'default'\n : undefined,\n });\n\n const build = removeUndefined({\n checkTypes,\n });\n\n const override: CustomIntlayerConfig = removeUndefined({\n log:\n Object.keys(log).length > 0\n ? (log as CustomIntlayerConfig['log'])\n : undefined,\n build: Object.keys(build).length > 0 ? build : undefined,\n });\n\n return removeUndefined({\n baseDir,\n env,\n envFile,\n override: Object.keys(override).length > 0 ? override : undefined,\n cache: typeof noCache !== 'undefined' ? !noCache : undefined,\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 isWithCommand = process.argv.includes('--with');\n\n if (!isWithCommand) {\n setPrefix('');\n }\n\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 mode: 'verbose',\n },\n },\n };\n\n return login({\n cmsUrl: options.cmsUrl,\n configOptions,\n });\n });\n\n /**\n * INIT\n */\n const initCmd = 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 initCmd\n .command('skills')\n .description('Initialize Intlayer skills in the project')\n .option('--project-root [projectRoot]', 'Project root directory')\n .action((options) => initSkills(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 ['--check-types', 'Check TypeScript type and log errors'],\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 const searchProgram = docProgram\n .command('search')\n .description('Search the documentation')\n .argument('<query>', 'Search query')\n .option('--limit [limit]', 'Limit the number of results', '10');\n\n applyConfigOptions(searchProgram);\n\n searchProgram.action((query, options) =>\n searchDoc({\n query,\n limit: options.limit ? parseInt(options.limit, 10) : 10,\n configOptions: extractConfigOptions(options),\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 * EXTRACT\n */\n const extractProgram = program\n .command('extract')\n .alias('ext')\n .description(\n 'Extract strings from components to be placed in a .content file close to the component'\n );\n\n extractProgram\n .option('-f, --file [files...]', 'List of files to extract')\n .option(\n '-o, --output-content-declarations [outputContentDeclarations]',\n 'Path to output content declaration files'\n )\n .option('--code-only', 'Only extract the component code', false)\n .option('--declaration-only', 'Only generate content declaration', false)\n .action((options) => {\n extract({\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(extractProgram);\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":"w4BAwCA,MAAa,EAFM,OAAA,QAAA,MAAA,CAAA,cAAA,WAAA,CAAA,MAA2B,UAEvB,EAAA,EAAA,UAAA,EAAA,EAAA,eAAA,QAAA,MAAA,CAAA,cAAA,WAAA,CAAA,KACuB,CAAC,CAC3C,UAEE,EAAcA,EAAAA,qBAAqB,EAAQ,CAO3C,EAAuB,CAC3B,CAAC,uBAAwB,mBAAmB,CAC5C,CAAC,kBAAmB,cAAc,CAClC,CAAC,uBAAwB,iBAAiB,CAC1C,CAAC,uBAAwB,WAAW,CACpC,GAViB,CACjB,CAAC,YAAa,sCAAsC,CACpD,CAAC,oBAAqB,SAAS,CAChC,CAQA,CAEK,EAAY,CAChB,CAAC,wBAAyB,WAAW,CACrC,CAAC,8BAA+B,cAAc,CAC9C,CAAC,kBAAmB,QAAQ,CAC5B,CAAC,qBAAsB,mBAAmB,CA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C,EAAQ,MAAM,QAAQ,KAAK,CAO3B,EACG,QAAQ,KAAK,CACb,YACC,iJACD,CACA,SACC,eACA,yDACD,CACA,oBAAoB,CACpB,OAAQ,GAAS,CAChB,EAAA,MAAM,EAAK,EACX,CAEG"}
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`./deepMergeContent.cjs`),t=require(`./getFilterMissingContentPerLocale.cjs`),n=require(`./mergeChunks.cjs`);let r=require(`@intlayer/api`),i=require(`@intlayer/chokidar/utils`),a=require(`node:path`),o=require(`@intlayer/config/logger`),s=require(`@intlayer/config/utils`),c=require(`@intlayer/unmerged-dictionaries-entry`),l=require(`@intlayer/core/plugins`);const u=e=>!e.description||!e.title||!e.tags,d=1e3*10;let f=0;const p=async(p,m,h)=>{let g=(0,o.getAppLogger)(m),_=(0,r.getIntlayerAPIProxy)(void 0,m),{mode:v,aiOptions:y,fillMetadata:b,aiClient:x,aiConfig:S}={mode:`complete`,fillMetadata:!0,...h},C=()=>{f=0,h?.onSuccess?.()};return await(0,s.retryManager)(async()=>{let r=(0,c.getUnmergedDictionaries)(m),w=r[p.dictionaryKey].find(e=>e.localId===p.dictionaryLocalId);if(!w)return g(`${p.dictionaryPreset}Dictionary not found in unmergedDictionariesRecord. Skipping.`,{level:`warn`}),{...p,dictionaryOutput:null};let T;if(b&&(u(w)||v===`review`)){let e=(0,l.getPerLocaleDictionary)(w,m.internationalization.defaultLocale);g(`${p.dictionaryPreset} Filling missing metadata for ${(0,o.colorizePath)((0,a.basename)(w.filePath))}`,{level:`info`});let t=async()=>x&&S?{data:await x.auditDictionaryMetadata({fileContent:JSON.stringify(e),aiConfig:S})}:await _.ai.auditContentDeclarationMetadata({fileContent:JSON.stringify(e),aiOptions:y});T=(h?.onHandle?await h.onHandle(t):await t()).data?.fileContent}let E=await Promise.all(p.targetLocales.map(async c=>{let u=structuredClone(w),m;if(typeof w.locale==`string`){let e=w.filePath?.replace(RegExp(`/${p.sourceLocale}/`,`g`),`/${c}/`),n=e?r[p.dictionaryKey]?.find(t=>t.filePath===e&&t.locale===c):void 0;m=n??{key:w.key,content:{},filePath:e,locale:c},v===`complete`&&(u=t.getFilterMissingContentPerLocale(u,n))}else v===`complete`&&(u=(0,l.getFilterMissingTranslationsDictionary)(u,c)),u=(0,l.getPerLocaleDictionary)(u,p.sourceLocale),m=(0,l.getPerLocaleDictionary)(w,c);let b=(0,o.colon)([(0,o.colorize)(`[`,o.ANSIColors.GREY_DARK),(0,i.formatLocale)(c),(0,o.colorize)(`]`,o.ANSIColors.GREY_DARK)].join(``),{colSize:18}),E=(e,t)=>t<=1?``:(0,o.colon)([(0,o.colorize)(`[`,o.ANSIColors.GREY_DARK),(0,o.colorizeNumber)(e+1),(0,o.colorize)(`/${t}`,o.ANSIColors.GREY_DARK),(0,o.colorize)(`]`,o.ANSIColors.GREY_DARK)].join(``),{colSize:5});g(`${p.dictionaryPreset}${b} Preparing ${(0,o.colorizePath)((0,a.basename)(m.filePath))}`,{level:`info`});let D=typeof u.content==`object`&&u.content!==null||Array.isArray(u.content),O=(0,i.chunkJSON)(D?u.content:{__INTLAYER_ROOT_PRIMITIVE_CONTENT__:u.content},7e3),k=O.length;k>1&&g(`${p.dictionaryPreset}${b} Split into ${(0,o.colorizeNumber)(k)} chunks for translation`,{level:`info`});let A=[],j=O.map(e=>{let t=E(e.index,e.total);k>1&&g(`${p.dictionaryPreset}${b}${t} Translating chunk`,{level:`info`});let n=(0,i.reconstructFromSingleChunk)(e),r=(0,i.reduceObjectFormat)(D?m.content:{__INTLAYER_ROOT_PRIMITIVE_CONTENT__:m.content},n),a=async()=>await(0,s.retryManager)(async()=>{let e;if(e=x&&S?await x.translateJSON({entryFileContent:n,presetOutputContent:r,dictionaryDescription:u.description??T?.description??``,entryLocale:p.sourceLocale,outputLocale:c,mode:v,aiConfig:S}):await _.ai.translateJSON({entryFileContent:n,presetOutputContent:r,dictionaryDescription:u.description??T?.description??``,entryLocale:p.sourceLocale,outputLocale:c,mode:v,aiOptions:y}).then(e=>e.data),!e?.fileContent)throw Error(`No content result`);let{isIdentic:t}=(0,i.verifyIdenticObjectFormat)(e.fileContent,n);if(!t)throw Error(`Translation result does not match expected format`);return C(),e.fileContent},{maxRetry:3,delay:d,onError:({error:t,attempt:n,maxRetry:r})=>{let i=E(e.index,e.total);g(`${p.dictionaryPreset}${b}${i} ${(0,o.colorize)(`Error filling:`,o.ANSIColors.RED)} ${(0,o.colorize)(typeof t==`string`?t:JSON.stringify(t),o.ANSIColors.GREY_DARK)} - Attempt ${(0,o.colorizeNumber)(n+1)} of ${(0,o.colorizeNumber)(r)}`,{level:`error`}),f+=1,f>=10&&(g(`There is something wrong.`,{level:`error`}),process.exit(1))}})();return(h?.onHandle?h.onHandle(a):a()).then(t=>({chunk:e,result:t}))});(await Promise.all(j)).sort((e,t)=>e.chunk.index-t.chunk.index).forEach(({result:e})=>{A.push(e)});let M=n.mergeChunks(A),N={...u,content:M}.content;return D||(N=N?.__INTLAYER_ROOT_PRIMITIVE_CONTENT__),typeof w.locale==`string`&&(N=e.deepMergeContent(m.content??{},N)),[c,N]})),D=Object.fromEntries(E),O={...(0,l.getMultilingualDictionary)(w.locale?{...w,key:w.key,content:{}}:w),locale:void 0,...T};for(let e of p.targetLocales)D[e]&&(O=(0,l.insertContentInDictionary)(O,D[e],e));if(g(`${p.dictionaryPreset} ${(0,o.colorize)(`Translation completed successfully`,o.ANSIColors.GREEN)} for ${(0,o.colorizePath)((0,a.basename)(O.filePath))}`,{level:`info`}),w.locale&&(w.fill===!0||w.fill===void 0)&&w.location===`local`){let e=w.filePath.split(`.`).slice(0,-1),t=e[e.length-1];return JSON.parse(JSON.stringify({...p,dictionaryOutput:{...O,fill:void 0,filled:!0}}).replaceAll(RegExp(`\\.${t}\\.[a-zA-Z0-9]+`,`g`),`.filled.${t}.json`))}return{...p,dictionaryOutput:O}},{maxRetry:2,delay:d,onError:({error:e,attempt:t,maxRetry:n})=>g(`${p.dictionaryPreset} ${(0,o.colorize)(`Error:`,o.ANSIColors.RED)} ${(0,o.colorize)(typeof e==`string`?e:JSON.stringify(e),o.ANSIColors.GREY_DARK)} - Attempt ${(0,o.colorizeNumber)(t+1)} of ${(0,o.colorizeNumber)(n)}`,{level:`error`}),onMaxTryReached:({error:e})=>g(`${p.dictionaryPreset} ${(0,o.colorize)(`Maximum number of retries reached:`,o.ANSIColors.RED)} ${(0,o.colorize)(typeof e==`string`?e:JSON.stringify(e),o.ANSIColors.GREY_DARK)}`,{level:`error`})})()};exports.translateDictionary=p;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`./deepMergeContent.cjs`),t=require(`./getFilterMissingContentPerLocale.cjs`);let n=require(`@intlayer/api`),r=require(`@intlayer/chokidar/utils`),i=require(`node:path`),a=require(`@intlayer/config/logger`),o=require(`@intlayer/config/utils`),s=require(`@intlayer/unmerged-dictionaries-entry`),c=require(`@intlayer/core/plugins`);const l=e=>!e.description||!e.title||!e.tags,u=1e3*10;let d=0;const f=async(f,p,m)=>{let h=(0,a.getAppLogger)(p),g=(0,n.getIntlayerAPIProxy)(void 0,p),{mode:_,aiOptions:v,fillMetadata:y,aiClient:b,aiConfig:x}={mode:`complete`,fillMetadata:!0,...m},S=()=>{d=0,m?.onSuccess?.()};return await(0,o.retryManager)(async()=>{let n=(0,s.getUnmergedDictionaries)(p),C=n[f.dictionaryKey].find(e=>e.localId===f.dictionaryLocalId);if(!C)return h(`${f.dictionaryPreset}Dictionary not found in unmergedDictionariesRecord. Skipping.`,{level:`warn`}),{...f,dictionaryOutput:null};let w;if(y&&(l(C)||_===`review`)){let e=(0,c.getPerLocaleDictionary)(C,p.internationalization.defaultLocale);h(`${f.dictionaryPreset} Filling missing metadata for ${(0,a.colorizePath)((0,i.basename)(C.filePath))}`,{level:`info`});let t=async()=>b&&x?{data:await b.auditDictionaryMetadata({fileContent:JSON.stringify(e),aiConfig:x})}:await g.ai.auditContentDeclarationMetadata({fileContent:JSON.stringify(e),aiOptions:v});w=(m?.onHandle?await m.onHandle(t):await t()).data?.fileContent}let T=await Promise.all(f.targetLocales.map(async s=>{let l=structuredClone(C),p;if(typeof C.locale==`string`){let e=C.filePath?.replace(RegExp(`/${f.sourceLocale}/`,`g`),`/${s}/`),r=e?n[f.dictionaryKey]?.find(t=>t.filePath===e&&t.locale===s):void 0;p=r??{key:C.key,content:{},filePath:e,locale:s},_===`complete`&&(l=t.getFilterMissingContentPerLocale(l,r))}else _===`complete`&&(l=(0,c.getFilterMissingTranslationsDictionary)(l,s)),l=(0,c.getPerLocaleDictionary)(l,f.sourceLocale),p=(0,c.getPerLocaleDictionary)(C,s);let y=(0,a.colon)([(0,a.colorize)(`[`,a.ANSIColors.GREY_DARK),(0,r.formatLocale)(s),(0,a.colorize)(`]`,a.ANSIColors.GREY_DARK)].join(``),{colSize:18}),T=(e,t)=>t<=1?``:(0,a.colon)([(0,a.colorize)(`[`,a.ANSIColors.GREY_DARK),(0,a.colorizeNumber)(e+1),(0,a.colorize)(`/${t}`,a.ANSIColors.GREY_DARK),(0,a.colorize)(`]`,a.ANSIColors.GREY_DARK)].join(``),{colSize:5});h(`${f.dictionaryPreset}${y} Preparing ${(0,a.colorizePath)((0,i.basename)(p.filePath))}`,{level:`info`});let E=typeof l.content==`object`&&l.content!==null||Array.isArray(l.content),D=(0,r.chunkJSON)(E?l.content:{__INTLAYER_ROOT_PRIMITIVE_CONTENT__:l.content},7e3),O=D.length;O>1&&h(`${f.dictionaryPreset}${y} Split into ${(0,a.colorizeNumber)(O)} chunks for translation`,{level:`info`});let k=[],A=D.map(e=>{let t=T(e.index,e.total);O>1&&h(`${f.dictionaryPreset}${y}${t} Translating chunk`,{level:`info`});let n=(0,r.reconstructFromSingleChunk)(e),i=(0,r.reduceObjectFormat)(E?p.content:{__INTLAYER_ROOT_PRIMITIVE_CONTENT__:p.content},n),c=async()=>await(0,o.retryManager)(async()=>{let e;if(e=b&&x?await b.translateJSON({entryFileContent:n,presetOutputContent:i,dictionaryDescription:l.description??w?.description??``,entryLocale:f.sourceLocale,outputLocale:s,mode:_,aiConfig:x}):await g.ai.translateJSON({entryFileContent:n,presetOutputContent:i,dictionaryDescription:l.description??w?.description??``,entryLocale:f.sourceLocale,outputLocale:s,mode:_,aiOptions:v}).then(e=>e.data),!e?.fileContent)throw Error(`No content result`);let{isIdentic:t}=(0,r.verifyIdenticObjectFormat)(e.fileContent,n);if(!t)throw Error(`Translation result does not match expected format`);return S(),e.fileContent},{maxRetry:3,delay:u,onError:({error:t,attempt:n,maxRetry:r})=>{let i=T(e.index,e.total);h(`${f.dictionaryPreset}${y}${i} ${(0,a.colorize)(`Error filling:`,a.ANSIColors.RED)} ${(0,a.colorize)(typeof t==`string`?t:JSON.stringify(t),a.ANSIColors.GREY_DARK)} - Attempt ${(0,a.colorizeNumber)(n+1)} of ${(0,a.colorizeNumber)(r)}`,{level:`error`}),d+=1,d>=10&&(h(`There is something wrong.`,{level:`error`}),process.exit(1))}})();return(m?.onHandle?m.onHandle(c):c()).then(t=>({chunk:e,result:t}))});(await Promise.all(A)).sort((e,t)=>e.chunk.index-t.chunk.index).forEach(({result:e})=>{k.push(e)});let j=(0,r.mergeChunks)(k),M={...l,content:j}.content;return E||(M=M?.__INTLAYER_ROOT_PRIMITIVE_CONTENT__),typeof C.locale==`string`&&(M=e.deepMergeContent(p.content??{},M)),[s,M]})),E=Object.fromEntries(T),D={...(0,c.getMultilingualDictionary)(C.locale?{...C,key:C.key,content:{}}:C),locale:void 0,...w};for(let e of f.targetLocales)E[e]&&(D=(0,c.insertContentInDictionary)(D,E[e],e));if(h(`${f.dictionaryPreset} ${(0,a.colorize)(`Translation completed successfully`,a.ANSIColors.GREEN)} for ${(0,a.colorizePath)((0,i.basename)(D.filePath))}`,{level:`info`}),C.locale&&(C.fill===!0||C.fill===void 0)&&C.location===`local`){let e=C.filePath.split(`.`).slice(0,-1),t=e[e.length-1];return JSON.parse(JSON.stringify({...f,dictionaryOutput:{...D,fill:void 0,filled:!0}}).replaceAll(RegExp(`\\.${t}\\.[a-zA-Z0-9]+`,`g`),`.filled.${t}.json`))}return{...f,dictionaryOutput:D}},{maxRetry:2,delay:u,onError:({error:e,attempt:t,maxRetry:n})=>h(`${f.dictionaryPreset} ${(0,a.colorize)(`Error:`,a.ANSIColors.RED)} ${(0,a.colorize)(typeof e==`string`?e:JSON.stringify(e),a.ANSIColors.GREY_DARK)} - Attempt ${(0,a.colorizeNumber)(t+1)} of ${(0,a.colorizeNumber)(n)}`,{level:`error`}),onMaxTryReached:({error:e})=>h(`${f.dictionaryPreset} ${(0,a.colorize)(`Maximum number of retries reached:`,a.ANSIColors.RED)} ${(0,a.colorize)(typeof e==`string`?e:JSON.stringify(e),a.ANSIColors.GREY_DARK)}`,{level:`error`})})()};exports.translateDictionary=f;
2
2
  //# sourceMappingURL=translateDictionary.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"translateDictionary.cjs","names":["getFilterMissingContentPerLocale","ANSIColors","mergeChunks","deepMergeContent"],"sources":["../../../src/fill/translateDictionary.ts"],"sourcesContent":["import { basename } from 'node:path';\nimport type { AIConfig } from '@intlayer/ai';\nimport { type AIOptions, getIntlayerAPIProxy } from '@intlayer/api';\nimport {\n chunkJSON,\n formatLocale,\n type JsonChunk,\n reconstructFromSingleChunk,\n reduceObjectFormat,\n verifyIdenticObjectFormat,\n} from '@intlayer/chokidar/utils';\nimport {\n ANSIColors,\n colon,\n colorize,\n colorizeNumber,\n colorizePath,\n getAppLogger,\n} from '@intlayer/config/logger';\nimport { retryManager } from '@intlayer/config/utils';\nimport {\n getFilterMissingTranslationsDictionary,\n getMultilingualDictionary,\n getPerLocaleDictionary,\n insertContentInDictionary,\n} from '@intlayer/core/plugins';\nimport type { Dictionary, IntlayerConfig, Locale } from '@intlayer/types';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\nimport type { AIClient } from '../utils/setupAI';\nimport { deepMergeContent } from './deepMergeContent';\nimport { getFilterMissingContentPerLocale } from './getFilterMissingContentPerLocale';\nimport type { TranslationTask } from './listTranslationsTasks';\nimport { mergeChunks } from './mergeChunks';\n\ntype TranslateDictionaryResult = TranslationTask & {\n dictionaryOutput: Dictionary | null;\n};\n\ntype TranslateDictionaryOptions = {\n mode: 'complete' | 'review';\n aiOptions?: AIOptions;\n fillMetadata?: boolean;\n onHandle?: ReturnType<\n typeof import('@intlayer/chokidar/utils').getGlobalLimiter\n >;\n onSuccess?: () => void;\n onError?: (error: unknown) => void;\n getAbortError?: () => Error | null;\n aiClient?: AIClient;\n aiConfig?: AIConfig;\n};\n\nconst hasMissingMetadata = (dictionary: Dictionary) =>\n !dictionary.description || !dictionary.title || !dictionary.tags;\n\nconst CHUNK_SIZE = 7000; // GPT-5 Mini safe input size\nconst GROUP_MAX_RETRY = 2;\nconst MAX_RETRY = 3;\nconst RETRY_DELAY = 1000 * 10; // 10 seconds\n\nconst MAX_FOLLOWING_ERRORS = 10; // 10 errors in a row, hard exit the process\nlet followingErrors = 0;\n\nexport const translateDictionary = async (\n task: TranslationTask,\n configuration: IntlayerConfig,\n options?: TranslateDictionaryOptions\n): Promise<TranslateDictionaryResult> => {\n const appLogger = getAppLogger(configuration);\n const intlayerAPI = getIntlayerAPIProxy(undefined, configuration);\n\n const { mode, aiOptions, fillMetadata, aiClient, aiConfig } = {\n mode: 'complete',\n fillMetadata: true,\n ...options,\n } as const;\n\n const notifySuccess = () => {\n followingErrors = 0;\n options?.onSuccess?.();\n };\n\n const result = await retryManager(\n async () => {\n const unmergedDictionariesRecord = getUnmergedDictionaries(configuration);\n\n const baseUnmergedDictionary: Dictionary | undefined =\n unmergedDictionariesRecord[task.dictionaryKey].find(\n (dict) => dict.localId === task.dictionaryLocalId\n );\n\n if (!baseUnmergedDictionary) {\n appLogger(\n `${task.dictionaryPreset}Dictionary not found in unmergedDictionariesRecord. Skipping.`,\n {\n level: 'warn',\n }\n );\n return { ...task, dictionaryOutput: null };\n }\n\n let metadata:\n | Pick<Dictionary, 'description' | 'title' | 'tags'>\n | undefined;\n\n if (\n fillMetadata &&\n (hasMissingMetadata(baseUnmergedDictionary) || mode === 'review')\n ) {\n const defaultLocaleDictionary = getPerLocaleDictionary(\n baseUnmergedDictionary,\n configuration.internationalization.defaultLocale\n );\n\n appLogger(\n `${task.dictionaryPreset} Filling missing metadata for ${colorizePath(basename(baseUnmergedDictionary.filePath!))}`,\n {\n level: 'info',\n }\n );\n\n const runAudit = async () => {\n if (aiClient && aiConfig) {\n const result = await aiClient.auditDictionaryMetadata({\n fileContent: JSON.stringify(defaultLocaleDictionary),\n aiConfig,\n });\n\n return {\n data: result,\n };\n }\n\n return await intlayerAPI.ai.auditContentDeclarationMetadata({\n fileContent: JSON.stringify(defaultLocaleDictionary),\n aiOptions,\n });\n };\n\n const metadataResult = options?.onHandle\n ? await options.onHandle(runAudit)\n : await runAudit();\n\n metadata = metadataResult.data?.fileContent;\n }\n\n const translatedContentResults = await Promise.all(\n task.targetLocales.map(async (targetLocale) => {\n /**\n * In complete mode, for large dictionaries, we want to filter all content that is already translated\n *\n * targetLocale: fr\n *\n * { test1: t({ ar: 'Hello', en: 'Hello', fr: 'Bonjour' } }) -> {}\n * { test2: t({ ar: 'Hello', en: 'Hello' }) } -> { test2: t({ ar: 'Hello', en: 'Hello' }) }\n *\n */\n // Reset to base dictionary for each locale to ensure we filter from the original\n let dictionaryToProcess = structuredClone(baseUnmergedDictionary);\n\n let targetLocaleDictionary: Dictionary;\n\n if (typeof baseUnmergedDictionary.locale === 'string') {\n // For per-locale files, the content is already in simple JSON format (not translation nodes)\n // The base dictionary is already the source locale content\n\n // Load the existing target locale dictionary\n const targetLocaleFilePath =\n baseUnmergedDictionary.filePath?.replace(\n new RegExp(`/${task.sourceLocale}/`, 'g'),\n `/${targetLocale}/`\n );\n\n // Find the target locale dictionary in unmerged dictionaries\n const targetUnmergedDictionary = targetLocaleFilePath\n ? unmergedDictionariesRecord[task.dictionaryKey]?.find(\n (dict) =>\n dict.filePath === targetLocaleFilePath &&\n dict.locale === targetLocale\n )\n : undefined;\n\n targetLocaleDictionary = targetUnmergedDictionary ?? {\n key: baseUnmergedDictionary.key,\n content: {},\n filePath: targetLocaleFilePath,\n locale: targetLocale,\n };\n\n // In complete mode, filter out already translated content\n if (mode === 'complete') {\n dictionaryToProcess = getFilterMissingContentPerLocale(\n dictionaryToProcess,\n targetUnmergedDictionary\n );\n }\n } else {\n // For multilingual dictionaries\n if (mode === 'complete') {\n // Remove all nodes that don't have any content to translate\n dictionaryToProcess = getFilterMissingTranslationsDictionary(\n dictionaryToProcess,\n targetLocale\n );\n }\n\n dictionaryToProcess = getPerLocaleDictionary(\n dictionaryToProcess,\n task.sourceLocale\n );\n\n targetLocaleDictionary = getPerLocaleDictionary(\n baseUnmergedDictionary,\n targetLocale\n );\n }\n\n const localePreset = colon(\n [\n colorize('[', ANSIColors.GREY_DARK),\n formatLocale(targetLocale),\n colorize(']', ANSIColors.GREY_DARK),\n ].join(''),\n { colSize: 18 }\n );\n\n const createChunkPreset = (\n chunkIndex: number,\n totalChunks: number\n ) => {\n if (totalChunks <= 1) return '';\n return colon(\n [\n colorize('[', ANSIColors.GREY_DARK),\n colorizeNumber(chunkIndex + 1),\n colorize(`/${totalChunks}`, ANSIColors.GREY_DARK),\n colorize(']', ANSIColors.GREY_DARK),\n ].join(''),\n { colSize: 5 }\n );\n };\n\n appLogger(\n `${task.dictionaryPreset}${localePreset} Preparing ${colorizePath(basename(targetLocaleDictionary.filePath!))}`,\n {\n level: 'info',\n }\n );\n\n const isContentStructured =\n (typeof dictionaryToProcess.content === 'object' &&\n dictionaryToProcess.content !== null) ||\n Array.isArray(dictionaryToProcess.content);\n\n const contentToProcess = isContentStructured\n ? dictionaryToProcess.content\n : {\n __INTLAYER_ROOT_PRIMITIVE_CONTENT__:\n dictionaryToProcess.content,\n };\n\n const chunkedJsonContent: JsonChunk[] = chunkJSON(\n contentToProcess as unknown as Record<string, any>,\n CHUNK_SIZE\n );\n\n const nbOfChunks = chunkedJsonContent.length;\n\n if (nbOfChunks > 1) {\n appLogger(\n `${task.dictionaryPreset}${localePreset} Split into ${colorizeNumber(nbOfChunks)} chunks for translation`,\n {\n level: 'info',\n }\n );\n }\n\n const chunkResult: JsonChunk[] = [];\n\n // Process chunks in parallel (globally throttled) to allow concurrent translation\n const chunkPromises = chunkedJsonContent.map((chunk) => {\n const chunkPreset = createChunkPreset(chunk.index, chunk.total);\n\n if (nbOfChunks > 1) {\n appLogger(\n `${task.dictionaryPreset}${localePreset}${chunkPreset} Translating chunk`,\n {\n level: 'info',\n }\n );\n }\n\n // Reconstruct partial JSON content from this chunk's patches\n const chunkContent = reconstructFromSingleChunk(chunk);\n const presetOutputContent = reduceObjectFormat(\n isContentStructured\n ? targetLocaleDictionary.content\n : {\n __INTLAYER_ROOT_PRIMITIVE_CONTENT__:\n targetLocaleDictionary.content,\n },\n chunkContent\n ) as unknown as JSON;\n\n const executeTranslation = async () => {\n return await retryManager(\n async () => {\n let translationResult: any;\n\n if (aiClient && aiConfig) {\n translationResult = await aiClient.translateJSON({\n entryFileContent: chunkContent as unknown as JSON,\n presetOutputContent,\n dictionaryDescription:\n dictionaryToProcess.description ??\n metadata?.description ??\n '',\n entryLocale: task.sourceLocale,\n outputLocale: targetLocale,\n mode,\n aiConfig,\n });\n } else {\n translationResult = await intlayerAPI.ai\n .translateJSON({\n entryFileContent: chunkContent as unknown as JSON,\n presetOutputContent,\n dictionaryDescription:\n dictionaryToProcess.description ??\n metadata?.description ??\n '',\n entryLocale: task.sourceLocale,\n outputLocale: targetLocale,\n mode,\n aiOptions,\n })\n .then((result) => result.data);\n }\n\n if (!translationResult?.fileContent) {\n throw new Error('No content result');\n }\n\n const { isIdentic } = verifyIdenticObjectFormat(\n translationResult.fileContent,\n chunkContent\n );\n\n if (!isIdentic) {\n throw new Error(\n 'Translation result does not match expected format'\n );\n }\n\n notifySuccess();\n return translationResult.fileContent;\n },\n {\n maxRetry: MAX_RETRY,\n delay: RETRY_DELAY,\n onError: ({ error, attempt, maxRetry }) => {\n const chunkPreset = createChunkPreset(\n chunk.index,\n chunk.total\n );\n appLogger(\n `${task.dictionaryPreset}${localePreset}${chunkPreset} ${colorize('Error filling:', ANSIColors.RED)} ${colorize(typeof error === 'string' ? error : JSON.stringify(error), ANSIColors.GREY_DARK)} - Attempt ${colorizeNumber(attempt + 1)} of ${colorizeNumber(maxRetry)}`,\n {\n level: 'error',\n }\n );\n\n followingErrors += 1;\n\n if (followingErrors >= MAX_FOLLOWING_ERRORS) {\n appLogger(`There is something wrong.`, {\n level: 'error',\n });\n process.exit(1); // 1 for error\n }\n },\n }\n )();\n };\n\n const wrapped = options?.onHandle\n ? options.onHandle(executeTranslation) // queued in global limiter\n : executeTranslation(); // no global limiter\n\n return wrapped.then((result) => ({ chunk, result }));\n });\n\n // Wait for all chunks for this locale in parallel (still capped by global limiter)\n const chunkResults = await Promise.all(chunkPromises);\n\n // Maintain order\n chunkResults\n .sort((chunkA, chunkB) => chunkA.chunk.index - chunkB.chunk.index)\n .forEach(({ result }) => {\n chunkResult.push(result);\n });\n\n // Merge partial JSON objects produced from each chunk into a single object\n const mergedContent = mergeChunks(chunkResult);\n\n const merged = {\n ...dictionaryToProcess,\n content: mergedContent,\n };\n\n // For per-locale files, merge the newly translated content with existing target content\n let finalContent = merged.content;\n\n if (!isContentStructured) {\n finalContent = (finalContent as any)\n ?.__INTLAYER_ROOT_PRIMITIVE_CONTENT__;\n }\n\n if (typeof baseUnmergedDictionary.locale === 'string') {\n // Deep merge: existing content + newly translated content\n finalContent = deepMergeContent(\n targetLocaleDictionary.content ?? {},\n finalContent\n );\n }\n\n return [targetLocale, finalContent] as const;\n })\n );\n\n const translatedContent: Partial<Record<Locale, Dictionary['content']>> =\n Object.fromEntries(translatedContentResults);\n\n const baseDictionary = baseUnmergedDictionary.locale\n ? {\n ...baseUnmergedDictionary,\n key: baseUnmergedDictionary.key!,\n content: {},\n }\n : baseUnmergedDictionary;\n\n let dictionaryOutput: Dictionary = {\n ...getMultilingualDictionary(baseDictionary),\n locale: undefined, // Ensure the dictionary is multilingual\n ...metadata,\n };\n\n for (const targetLocale of task.targetLocales) {\n if (translatedContent[targetLocale]) {\n dictionaryOutput = insertContentInDictionary(\n dictionaryOutput,\n translatedContent[targetLocale],\n targetLocale\n );\n }\n }\n\n appLogger(\n `${task.dictionaryPreset} ${colorize('Translation completed successfully', ANSIColors.GREEN)} for ${colorizePath(basename(dictionaryOutput.filePath!))}`,\n {\n level: 'info',\n }\n );\n\n if (\n baseUnmergedDictionary.locale &&\n (baseUnmergedDictionary.fill === true ||\n baseUnmergedDictionary.fill === undefined) &&\n baseUnmergedDictionary.location === 'local'\n ) {\n const dictionaryFilePath = baseUnmergedDictionary\n .filePath!.split('.')\n .slice(0, -1);\n\n const contentIndex = dictionaryFilePath[dictionaryFilePath.length - 1];\n\n return JSON.parse(\n JSON.stringify({\n ...task,\n dictionaryOutput: {\n ...dictionaryOutput,\n fill: undefined,\n filled: true,\n },\n }).replaceAll(\n new RegExp(`\\\\.${contentIndex}\\\\.[a-zA-Z0-9]+`, 'g'),\n `.filled.${contentIndex}.json`\n )\n );\n }\n\n return {\n ...task,\n dictionaryOutput,\n };\n },\n {\n maxRetry: GROUP_MAX_RETRY,\n delay: RETRY_DELAY,\n onError: ({ error, attempt, maxRetry }) =>\n appLogger(\n `${task.dictionaryPreset} ${colorize('Error:', ANSIColors.RED)} ${colorize(typeof error === 'string' ? error : JSON.stringify(error), ANSIColors.GREY_DARK)} - Attempt ${colorizeNumber(attempt + 1)} of ${colorizeNumber(maxRetry)}`,\n {\n level: 'error',\n }\n ),\n onMaxTryReached: ({ error }) =>\n appLogger(\n `${task.dictionaryPreset} ${colorize('Maximum number of retries reached:', ANSIColors.RED)} ${colorize(typeof error === 'string' ? error : JSON.stringify(error), ANSIColors.GREY_DARK)}`,\n {\n level: 'error',\n }\n ),\n }\n )();\n\n return result as Translate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A,UAAY,qCAAsCF,EAAAA,WAAW,MAAM,CAAC,QAAA,EAAA,EAAA,eAAA,EAAA,EAAA,UAA6B,EAAiB,SAAU,CAAC,GACtJ,CACE,MAAO,OACR,CACF,CAGC,EAAuB,SACtB,EAAuB,OAAS,IAC/B,EAAuB,OAAS,IAAA,KAClC,EAAuB,WAAa,QACpC,CACA,IAAM,EAAqB,EACxB,SAAU,MAAM,IAAI,CACpB,MAAM,EAAG,GAAG,CAET,EAAe,EAAmB,EAAmB,OAAS,GAEpE,OAAO,KAAK,MACV,KAAK,UAAU,CACb,GAAG,EACH,iBAAkB,CAChB,GAAG,EACH,KAAM,IAAA,GACN,OAAQ,GACT,CACF,CAAC,CAAC,WACG,OAAO,MAAM,EAAa,iBAAkB,IAAI,CACpD,WAAW,EAAa,OACzB,CACF,CAGH,MAAO,CACL,GAAG,EACH,mBACD,EAEH,CACE,SAAU,EACV,MAAO,EACP,SAAU,CAAE,QAAO,UAAS,cAC1B,EACE,GAAG,EAAK,iBAAiB,IAAA,EAAA,EAAA,UAAY,SAAUA,EAAAA,WAAW,IAAI,CAAC,IAAA,EAAA,EAAA,UAAY,OAAO,GAAU,SAAW,EAAQ,KAAK,UAAU,EAAM,CAAEA,EAAAA,WAAW,UAAU,CAAC,cAAA,EAAA,EAAA,gBAA4B,EAAU,EAAE,CAAC,OAAA,EAAA,EAAA,gBAAqB,EAAS,GACnO,CACE,MAAO,QACR,CACF,CACH,iBAAkB,CAAE,WAClB,EACE,GAAG,EAAK,iBAAiB,IAAA,EAAA,EAAA,UAAY,qCAAsCA,EAAAA,WAAW,IAAI,CAAC,IAAA,EAAA,EAAA,UAAY,OAAO,GAAU,SAAW,EAAQ,KAAK,UAAU,EAAM,CAAEA,EAAAA,WAAW,UAAU,GACvL,CACE,MAAO,QACR,CACF,CACJ,CACF,EAAE"}
1
+ {"version":3,"file":"translateDictionary.cjs","names":["getFilterMissingContentPerLocale","ANSIColors","deepMergeContent"],"sources":["../../../src/fill/translateDictionary.ts"],"sourcesContent":["import { basename } from 'node:path';\nimport type { AIConfig } from '@intlayer/ai';\nimport { type AIOptions, getIntlayerAPIProxy } from '@intlayer/api';\nimport {\n chunkJSON,\n formatLocale,\n type JsonChunk,\n mergeChunks,\n reconstructFromSingleChunk,\n reduceObjectFormat,\n verifyIdenticObjectFormat,\n} from '@intlayer/chokidar/utils';\nimport {\n ANSIColors,\n colon,\n colorize,\n colorizeNumber,\n colorizePath,\n getAppLogger,\n} from '@intlayer/config/logger';\nimport { retryManager } from '@intlayer/config/utils';\nimport {\n getFilterMissingTranslationsDictionary,\n getMultilingualDictionary,\n getPerLocaleDictionary,\n insertContentInDictionary,\n} from '@intlayer/core/plugins';\nimport type { Dictionary, IntlayerConfig, Locale } from '@intlayer/types';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\nimport type { AIClient } from '../utils/setupAI';\nimport { deepMergeContent } from './deepMergeContent';\nimport { getFilterMissingContentPerLocale } from './getFilterMissingContentPerLocale';\nimport type { TranslationTask } from './listTranslationsTasks';\n\ntype TranslateDictionaryResult = TranslationTask & {\n dictionaryOutput: Dictionary | null;\n};\n\ntype TranslateDictionaryOptions = {\n mode: 'complete' | 'review';\n aiOptions?: AIOptions;\n fillMetadata?: boolean;\n onHandle?: ReturnType<\n typeof import('@intlayer/chokidar/utils').getGlobalLimiter\n >;\n onSuccess?: () => void;\n onError?: (error: unknown) => void;\n getAbortError?: () => Error | null;\n aiClient?: AIClient;\n aiConfig?: AIConfig;\n};\n\nconst hasMissingMetadata = (dictionary: Dictionary) =>\n !dictionary.description || !dictionary.title || !dictionary.tags;\n\nconst CHUNK_SIZE = 7000; // GPT-5 Mini safe input size\nconst GROUP_MAX_RETRY = 2;\nconst MAX_RETRY = 3;\nconst RETRY_DELAY = 1000 * 10; // 10 seconds\n\nconst MAX_FOLLOWING_ERRORS = 10; // 10 errors in a row, hard exit the process\nlet followingErrors = 0;\n\nexport const translateDictionary = async (\n task: TranslationTask,\n configuration: IntlayerConfig,\n options?: TranslateDictionaryOptions\n): Promise<TranslateDictionaryResult> => {\n const appLogger = getAppLogger(configuration);\n const intlayerAPI = getIntlayerAPIProxy(undefined, configuration);\n\n const { mode, aiOptions, fillMetadata, aiClient, aiConfig } = {\n mode: 'complete',\n fillMetadata: true,\n ...options,\n } as const;\n\n const notifySuccess = () => {\n followingErrors = 0;\n options?.onSuccess?.();\n };\n\n const result = await retryManager(\n async () => {\n const unmergedDictionariesRecord = getUnmergedDictionaries(configuration);\n\n const baseUnmergedDictionary: Dictionary | undefined =\n unmergedDictionariesRecord[task.dictionaryKey].find(\n (dict) => dict.localId === task.dictionaryLocalId\n );\n\n if (!baseUnmergedDictionary) {\n appLogger(\n `${task.dictionaryPreset}Dictionary not found in unmergedDictionariesRecord. Skipping.`,\n {\n level: 'warn',\n }\n );\n return { ...task, dictionaryOutput: null };\n }\n\n let metadata:\n | Pick<Dictionary, 'description' | 'title' | 'tags'>\n | undefined;\n\n if (\n fillMetadata &&\n (hasMissingMetadata(baseUnmergedDictionary) || mode === 'review')\n ) {\n const defaultLocaleDictionary = getPerLocaleDictionary(\n baseUnmergedDictionary,\n configuration.internationalization.defaultLocale\n );\n\n appLogger(\n `${task.dictionaryPreset} Filling missing metadata for ${colorizePath(basename(baseUnmergedDictionary.filePath!))}`,\n {\n level: 'info',\n }\n );\n\n const runAudit = async () => {\n if (aiClient && aiConfig) {\n const result = await aiClient.auditDictionaryMetadata({\n fileContent: JSON.stringify(defaultLocaleDictionary),\n aiConfig,\n });\n\n return {\n data: result,\n };\n }\n\n return await intlayerAPI.ai.auditContentDeclarationMetadata({\n fileContent: JSON.stringify(defaultLocaleDictionary),\n aiOptions,\n });\n };\n\n const metadataResult = options?.onHandle\n ? await options.onHandle(runAudit)\n : await runAudit();\n\n metadata = metadataResult.data?.fileContent;\n }\n\n const translatedContentResults = await Promise.all(\n task.targetLocales.map(async (targetLocale) => {\n /**\n * In complete mode, for large dictionaries, we want to filter all content that is already translated\n *\n * targetLocale: fr\n *\n * { test1: t({ ar: 'Hello', en: 'Hello', fr: 'Bonjour' } }) -> {}\n * { test2: t({ ar: 'Hello', en: 'Hello' }) } -> { test2: t({ ar: 'Hello', en: 'Hello' }) }\n *\n */\n // Reset to base dictionary for each locale to ensure we filter from the original\n let dictionaryToProcess = structuredClone(baseUnmergedDictionary);\n\n let targetLocaleDictionary: Dictionary;\n\n if (typeof baseUnmergedDictionary.locale === 'string') {\n // For per-locale files, the content is already in simple JSON format (not translation nodes)\n // The base dictionary is already the source locale content\n\n // Load the existing target locale dictionary\n const targetLocaleFilePath =\n baseUnmergedDictionary.filePath?.replace(\n new RegExp(`/${task.sourceLocale}/`, 'g'),\n `/${targetLocale}/`\n );\n\n // Find the target locale dictionary in unmerged dictionaries\n const targetUnmergedDictionary = targetLocaleFilePath\n ? unmergedDictionariesRecord[task.dictionaryKey]?.find(\n (dict) =>\n dict.filePath === targetLocaleFilePath &&\n dict.locale === targetLocale\n )\n : undefined;\n\n targetLocaleDictionary = targetUnmergedDictionary ?? {\n key: baseUnmergedDictionary.key,\n content: {},\n filePath: targetLocaleFilePath,\n locale: targetLocale,\n };\n\n // In complete mode, filter out already translated content\n if (mode === 'complete') {\n dictionaryToProcess = getFilterMissingContentPerLocale(\n dictionaryToProcess,\n targetUnmergedDictionary\n );\n }\n } else {\n // For multilingual dictionaries\n if (mode === 'complete') {\n // Remove all nodes that don't have any content to translate\n dictionaryToProcess = getFilterMissingTranslationsDictionary(\n dictionaryToProcess,\n targetLocale\n );\n }\n\n dictionaryToProcess = getPerLocaleDictionary(\n dictionaryToProcess,\n task.sourceLocale\n );\n\n targetLocaleDictionary = getPerLocaleDictionary(\n baseUnmergedDictionary,\n targetLocale\n );\n }\n\n const localePreset = colon(\n [\n colorize('[', ANSIColors.GREY_DARK),\n formatLocale(targetLocale),\n colorize(']', ANSIColors.GREY_DARK),\n ].join(''),\n { colSize: 18 }\n );\n\n const createChunkPreset = (\n chunkIndex: number,\n totalChunks: number\n ) => {\n if (totalChunks <= 1) return '';\n return colon(\n [\n colorize('[', ANSIColors.GREY_DARK),\n colorizeNumber(chunkIndex + 1),\n colorize(`/${totalChunks}`, ANSIColors.GREY_DARK),\n colorize(']', ANSIColors.GREY_DARK),\n ].join(''),\n { colSize: 5 }\n );\n };\n\n appLogger(\n `${task.dictionaryPreset}${localePreset} Preparing ${colorizePath(basename(targetLocaleDictionary.filePath!))}`,\n {\n level: 'info',\n }\n );\n\n const isContentStructured =\n (typeof dictionaryToProcess.content === 'object' &&\n dictionaryToProcess.content !== null) ||\n Array.isArray(dictionaryToProcess.content);\n\n const contentToProcess = isContentStructured\n ? dictionaryToProcess.content\n : {\n __INTLAYER_ROOT_PRIMITIVE_CONTENT__:\n dictionaryToProcess.content,\n };\n\n const chunkedJsonContent: JsonChunk[] = chunkJSON(\n contentToProcess as unknown as Record<string, any>,\n CHUNK_SIZE\n );\n\n const nbOfChunks = chunkedJsonContent.length;\n\n if (nbOfChunks > 1) {\n appLogger(\n `${task.dictionaryPreset}${localePreset} Split into ${colorizeNumber(nbOfChunks)} chunks for translation`,\n {\n level: 'info',\n }\n );\n }\n\n const chunkResult: JsonChunk[] = [];\n\n // Process chunks in parallel (globally throttled) to allow concurrent translation\n const chunkPromises = chunkedJsonContent.map((chunk) => {\n const chunkPreset = createChunkPreset(chunk.index, chunk.total);\n\n if (nbOfChunks > 1) {\n appLogger(\n `${task.dictionaryPreset}${localePreset}${chunkPreset} Translating chunk`,\n {\n level: 'info',\n }\n );\n }\n\n // Reconstruct partial JSON content from this chunk's patches\n const chunkContent = reconstructFromSingleChunk(chunk);\n const presetOutputContent = reduceObjectFormat(\n isContentStructured\n ? targetLocaleDictionary.content\n : {\n __INTLAYER_ROOT_PRIMITIVE_CONTENT__:\n targetLocaleDictionary.content,\n },\n chunkContent\n ) as unknown as JSON;\n\n const executeTranslation = async () => {\n return await retryManager(\n async () => {\n let translationResult: any;\n\n if (aiClient && aiConfig) {\n translationResult = await aiClient.translateJSON({\n entryFileContent: chunkContent as unknown as JSON,\n presetOutputContent,\n dictionaryDescription:\n dictionaryToProcess.description ??\n metadata?.description ??\n '',\n entryLocale: task.sourceLocale,\n outputLocale: targetLocale,\n mode,\n aiConfig,\n });\n } else {\n translationResult = await intlayerAPI.ai\n .translateJSON({\n entryFileContent: chunkContent as unknown as JSON,\n presetOutputContent,\n dictionaryDescription:\n dictionaryToProcess.description ??\n metadata?.description ??\n '',\n entryLocale: task.sourceLocale,\n outputLocale: targetLocale,\n mode,\n aiOptions,\n })\n .then((result) => result.data);\n }\n\n if (!translationResult?.fileContent) {\n throw new Error('No content result');\n }\n\n const { isIdentic } = verifyIdenticObjectFormat(\n translationResult.fileContent,\n chunkContent\n );\n\n if (!isIdentic) {\n throw new Error(\n 'Translation result does not match expected format'\n );\n }\n\n notifySuccess();\n return translationResult.fileContent;\n },\n {\n maxRetry: MAX_RETRY,\n delay: RETRY_DELAY,\n onError: ({ error, attempt, maxRetry }) => {\n const chunkPreset = createChunkPreset(\n chunk.index,\n chunk.total\n );\n appLogger(\n `${task.dictionaryPreset}${localePreset}${chunkPreset} ${colorize('Error filling:', ANSIColors.RED)} ${colorize(typeof error === 'string' ? error : JSON.stringify(error), ANSIColors.GREY_DARK)} - Attempt ${colorizeNumber(attempt + 1)} of ${colorizeNumber(maxRetry)}`,\n {\n level: 'error',\n }\n );\n\n followingErrors += 1;\n\n if (followingErrors >= MAX_FOLLOWING_ERRORS) {\n appLogger(`There is something wrong.`, {\n level: 'error',\n });\n process.exit(1); // 1 for error\n }\n },\n }\n )();\n };\n\n const wrapped = options?.onHandle\n ? options.onHandle(executeTranslation) // queued in global limiter\n : executeTranslation(); // no global limiter\n\n return wrapped.then((result) => ({ chunk, result }));\n });\n\n // Wait for all chunks for this locale in parallel (still capped by global limiter)\n const chunkResults = await Promise.all(chunkPromises);\n\n // Maintain order\n chunkResults\n .sort((chunkA, chunkB) => chunkA.chunk.index - chunkB.chunk.index)\n .forEach(({ result }) => {\n chunkResult.push(result);\n });\n\n // Merge partial JSON objects produced from each chunk into a single object\n const mergedContent = mergeChunks(chunkResult);\n\n const merged = {\n ...dictionaryToProcess,\n content: mergedContent,\n };\n\n // For per-locale files, merge the newly translated content with existing target content\n let finalContent = merged.content;\n\n if (!isContentStructured) {\n finalContent = (finalContent as any)\n ?.__INTLAYER_ROOT_PRIMITIVE_CONTENT__;\n }\n\n if (typeof baseUnmergedDictionary.locale === 'string') {\n // Deep merge: existing content + newly translated content\n finalContent = deepMergeContent(\n targetLocaleDictionary.content ?? {},\n finalContent\n );\n }\n\n return [targetLocale, finalContent] as const;\n })\n );\n\n const translatedContent: Partial<Record<Locale, Dictionary['content']>> =\n Object.fromEntries(translatedContentResults);\n\n const baseDictionary = baseUnmergedDictionary.locale\n ? {\n ...baseUnmergedDictionary,\n key: baseUnmergedDictionary.key!,\n content: {},\n }\n : baseUnmergedDictionary;\n\n let dictionaryOutput: Dictionary = {\n ...getMultilingualDictionary(baseDictionary),\n locale: undefined, // Ensure the dictionary is multilingual\n ...metadata,\n };\n\n for (const targetLocale of task.targetLocales) {\n if (translatedContent[targetLocale]) {\n dictionaryOutput = insertContentInDictionary(\n dictionaryOutput,\n translatedContent[targetLocale],\n targetLocale\n );\n }\n }\n\n appLogger(\n `${task.dictionaryPreset} ${colorize('Translation completed successfully', ANSIColors.GREEN)} for ${colorizePath(basename(dictionaryOutput.filePath!))}`,\n {\n level: 'info',\n }\n );\n\n if (\n baseUnmergedDictionary.locale &&\n (baseUnmergedDictionary.fill === true ||\n baseUnmergedDictionary.fill === undefined) &&\n baseUnmergedDictionary.location === 'local'\n ) {\n const dictionaryFilePath = baseUnmergedDictionary\n .filePath!.split('.')\n .slice(0, -1);\n\n const contentIndex = dictionaryFilePath[dictionaryFilePath.length - 1];\n\n return JSON.parse(\n JSON.stringify({\n ...task,\n dictionaryOutput: {\n ...dictionaryOutput,\n fill: undefined,\n filled: true,\n },\n }).replaceAll(\n new RegExp(`\\\\.${contentIndex}\\\\.[a-zA-Z0-9]+`, 'g'),\n `.filled.${contentIndex}.json`\n )\n );\n }\n\n return {\n ...task,\n dictionaryOutput,\n };\n },\n {\n maxRetry: GROUP_MAX_RETRY,\n delay: RETRY_DELAY,\n onError: ({ error, attempt, maxRetry }) =>\n appLogger(\n `${task.dictionaryPreset} ${colorize('Error:', ANSIColors.RED)} ${colorize(typeof error === 'string' ? error : JSON.stringify(error), ANSIColors.GREY_DARK)} - Attempt ${colorizeNumber(attempt + 1)} of ${colorizeNumber(maxRetry)}`,\n {\n level: 'error',\n }\n ),\n onMaxTryReached: ({ error }) =>\n appLogger(\n `${task.dictionaryPreset} ${colorize('Maximum number of retries reached:', ANSIColors.RED)} ${colorize(typeof error === 'string' ? error : JSON.stringify(error), ANSIColors.GREY_DARK)}`,\n {\n level: 'error',\n }\n ),\n }\n )();\n\n return result as TranslateDictionaryResult;\n};\n"],"mappings":"0cAoDA,MAAM,EAAsB,GAC1B,CAAC,EAAW,aAAe,CAAC,EAAW,OAAS,CAAC,EAAW,KAKxD,EAAc,IAAO,GAG3B,IAAI,EAAkB,EAEtB,MAAa,EAAsB,MACjC,EACA,EACA,IACuC,CACvC,IAAM,GAAA,EAAA,EAAA,cAAyB,EAAc,CACvC,GAAA,EAAA,EAAA,qBAAkC,IAAA,GAAW,EAAc,CAE3D,CAAE,OAAM,YAAW,eAAc,WAAU,YAAa,CAC5D,KAAM,WACN,aAAc,GACd,GAAG,EACJ,CAEK,MAAsB,CAC1B,EAAkB,EAClB,GAAS,aAAa,EAqbxB,OAlbe,MAAA,EAAA,EAAA,cACb,SAAY,CACV,IAAM,GAAA,EAAA,EAAA,yBAAqD,EAAc,CAEnE,EACJ,EAA2B,EAAK,eAAe,KAC5C,GAAS,EAAK,UAAY,EAAK,kBACjC,CAEH,GAAI,CAAC,EAOH,OANA,EACE,GAAG,EAAK,iBAAiB,+DACzB,CACE,MAAO,OACR,CACF,CACM,CAAE,GAAG,EAAM,iBAAkB,KAAM,CAG5C,IAAI,EAIJ,GACE,IACC,EAAmB,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SAAW,EAAQ,KAAK,UAAU,EAAM,CAAEA,EAAAA,WAAW,UAAU,CAAC,cAAA,EAAA,EAAA,gBAA4B,EAAU,EAAE,CAAC,OAAA,EAAA,EAAA,gBAAqB,EAAS,GACnO,CACE,MAAO,QACR,CACF,CACH,iBAAkB,CAAE,WAClB,EACE,GAAG,EAAK,iBAAiB,IAAA,EAAA,EAAA,UAAY,qCAAsCA,EAAAA,WAAW,IAAI,CAAC,IAAA,EAAA,EAAA,UAAY,OAAO,GAAU,SAAW,EAAQ,KAAK,UAAU,EAAM,CAAEA,EAAAA,WAAW,UAAU,GACvL,CACE,MAAO,QACR,CACF,CACJ,CACF,EAAE"}
package/dist/esm/cli.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import{build as e}from"./build.mjs";import{runCI as t}from"./ci.mjs";import{login as n}from"./auth/login.mjs";import{getConfig as r}from"./config.mjs";import{startEditor as i}from"./editor.mjs";import{extract as a}from"./extract.mjs";import{testMissingTranslations as o}from"./test/test.mjs";import{fill as s}from"./fill/fill.mjs";import{init as c}from"./init.mjs";import{initSkills as l}from"./initSkills.mjs";import{listContentDeclaration as u}from"./listContentDeclaration.mjs";import{listProjectsCommand as d}from"./listProjects.mjs";import{liveSync as ee}from"./liveSync.mjs";import{pull as f}from"./pull.mjs";import{push as p}from"./push/push.mjs";import{pushConfig as te}from"./pushConfig.mjs";import{reviewDoc as ne}from"./reviewDoc/reviewDoc.mjs";import{searchDoc as re}from"./searchDoc.mjs";import{translateDoc as ie}from"./translateDoc/translateDoc.mjs";import{getParentPackageJSON as m}from"./utils/getParentPackageJSON.mjs";import{watchContentDeclaration as h}from"./watch.mjs";import{getConfiguration as g}from"@intlayer/config/node";import{dirname as _}from"node:path";import{setPrefix as v}from"@intlayer/config/logger";import{fileURLToPath as y}from"node:url";import{Command as ae}from"commander";const b=typeof import.meta.url==`string`?_(y(import.meta.url)):__dirname,x=m(b),S=[[`--env-file [envFile]`,`Environment file`],[`-e, --env [env]`,`Environment`],[`--base-dir [baseDir]`,`Base directory`],[`--no-cache [noCache]`,`No cache`],...[[`--verbose`,`Verbose (default to true using CLI)`],[`--prefix [prefix]`,`Prefix`]]],C=[[`--provider [provider]`,`Provider`],[`--temperature [temperature]`,`Temperature`],[`--model [model]`,`Model`],[`--api-key [apiKey]`,`Provider API key`],[`--custom-prompt [prompt]`,`Custom prompt`],[`--application-context [applicationContext]`,`Application context`],[`--data-serialization [dataSerialization]`,`Data serialization`]],w=[[`--git-diff [gitDiff]`,`Git diff mode - Check git diff between two refs`],[`--git-diff-base [gitDiffBase]`,`Git diff base ref`],[`--git-diff-current [gitDiffCurrent]`,`Git diff current ref`],[`--uncommitted [uncommitted]`,`Uncommitted`],[`--unpushed [unpushed]`,`Unpushed`],[`--untracked [untracked]`,`Untracked`]],T=(e,t)=>t.filter(t=>e[t]),E=(e,t)=>(t.forEach(([t,n])=>{e.option(t,n)}),e),D=e=>Object.fromEntries(Object.entries(e).filter(([e,t])=>t!==void 0)),O=e=>E(e,S),k=e=>E(e,C),A=e=>E(e,w),j=e=>{let{apiKey:t,provider:n,model:r,temperature:i,applicationContext:a,customPrompt:o,dataSerialization:s}=e,c=g(),{ai:l}=c;return D({...l,apiKey:t??c.ai?.apiKey,provider:n??c.ai?.provider,model:r??c.ai?.model,temperature:i??c.ai?.temperature,applicationContext:a??c.ai?.applicationContext,customPrompt:o??c.ai?.customPrompt,dataSerialization:s??c.ai?.dataSerialization})},M=[`gitDiff`,`gitDiffBase`,`gitDiffCurrent`,`uncommitted`,`unpushed`,`untracked`],N=e=>{let t=T(e,M);if(!Object.values(t).some(Boolean))return;let{gitDiff:n,gitDiffBase:r,gitDiffCurrent:i,uncommitted:a,unpushed:o,untracked:s}=e;return D({mode:[n&&`gitDiff`,a&&`uncommitted`,o&&`unpushed`,s&&`untracked`].filter(Boolean),baseRef:r,currentRef:i,absolute:!0})},P=[`baseDir`,`env`,`envFile`,`verbose`,`prefix`],F=e=>{let t=g(e),n=T(e,P);if(!Object.values(n).some(Boolean))return;let{baseDir:r,env:i,envFile:a,verbose:o,prefix:s,noCache:c}=e,l=!!e.with;return typeof s==`string`?v(s):l&&v(t.log.prefix),D({baseDir:r,env:i,envFile:a,override:{log:{verbose:o??!0}},cache:!c})},I=()=>{v(``);let m=new ae;m.version(x.version).description(`Intlayer CLI`),m.command(`version`).description(`Print the Intlayer CLI version`).action(()=>{console.log(x.version??`unknown`)});let g=m.command(`login`).description(`Login to Intlayer`).option(`--cms-url [cmsUrl]`,`CMS URL`);O(g),g.action(e=>{let t=F(e)??{override:{log:{prefix:``,verbose:!0}}};return n({cmsUrl:e.cmsUrl,configOptions:t})}),m.command(`init`).description(`Initialize Intlayer in the project`).option(`--project-root [projectRoot]`,`Project root directory`).action(e=>c(e.projectRoot)).command(`skills`).description(`Initialize Intlayer skills in the project`).option(`--project-root [projectRoot]`,`Project root directory`).action(e=>l(e.projectRoot));let _=m.command(`dictionary`).alias(`dictionaries`).alias(`dic`).description(`Dictionaries operations`),y={description:`Build the dictionaries`,options:[[`-w, --watch`,`Watch for changes`],[`--skip-prepare`,`Skip the prepare step`],[`--with [with...]`,`Start command in parallel with the build`]]},b=_.command(`build`).description(y.description);E(b,y.options),O(b),b.action(t=>{e({...t,configOptions:F(t)})});let S=m.command(`build`).description(y.description);E(S,y.options),O(S),S.action(t=>{e({...t,configOptions:F(t)})});let C={description:`Watch the dictionaries changes`,options:[[`--with [with...]`,`Start command in parallel with the build`]]},w=_.command(`watch`).description(y.description);E(w,C.options),O(w),w.action(e=>{h({...e,configOptions:F(e)})});let T=m.command(`watch`).description(y.description);E(T,C.options),O(T),T.action(e=>{h({...e,configOptions:F(e)})});let D={description:`Pull dictionaries from the server`,options:[[`-d, --dictionaries [ids...]`,`List of dictionary IDs to pull`],[`--dictionary [ids...]`,`List of dictionary IDs to pull (alias for --dictionaries)`],[`--new-dictionaries-path [path]`,`Path to save the new dictionaries`],[`--newDictionariesPath [path]`,`[alias] Path to save the new dictionaries`]]},M=_.command(`pull`).description(D.description);E(M,D.options),O(M),M.action(e=>{let t=[...e.dictionaries??[],...e.dictionary??[]];f({...e,dictionaries:t.length>0?t:void 0,configOptions:{...e.configOptions,baseDir:e.baseDir}})});let P=m.command(`pull`).description(D.description);E(P,D.options),O(P),P.action(e=>{let t=[...e.dictionaries??[],...e.dictionary??[]];f({...e,dictionaries:t.length>0?t:void 0,configOptions:F(e)})});let I={description:`Push all dictionaries. Create or update the pushed dictionaries`,options:[[`-d, --dictionaries [ids...]`,`List of dictionary IDs to push`],[`--dictionary [ids...]`,`List of dictionary IDs to push (alias for --dictionaries)`],[`-r, --delete-locale-dictionary`,`Delete the local dictionaries after pushing`],[`-k, --keep-locale-dictionary`,`Keep the local dictionaries after pushing`],[`--deleteLocaleDictionary`,`[alias] Delete the local dictionaries after pushing`],[`--keepLocaleDictionary`,`[alias] Keep the local dictionaries after pushing`],[`--build [build]`,`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`]]},L=_.command(`push`).description(I.description);E(L,I.options),O(L),A(L),L.action(e=>{let t=[...e.dictionaries||[],...e.dictionary||[]];return p({...e,dictionaries:t.length>0?t:void 0,gitOptions:N(e),configOptions:F(e)})});let R=m.command(`push`).description(I.description);E(R,I.options),O(R),A(R),R.action(e=>{let t=[...e.dictionaries||[],...e.dictionary||[]];return p({...e,dictionaries:t.length>0?t:void 0,gitOptions:N(e),configOptions:F(e)})});let z=m.command(`configuration`).alias(`config`).alias(`conf`).description(`Configuration operations`),B=z.command(`get`).description(`Get the configuration`);O(B),B.action(e=>{r({...e,configOptions:F(e)})});let V=z.command(`push`).description(`Push the configuration`);O(V),V.action(e=>{te({...e,configOptions:F(e)})}),m.command(`projects`).alias(`project`).description(`List Intlayer projects`).command(`list`).description(`List all Intlayer projects in the directory`).option(`--base-dir [baseDir]`,`Base directory to search from`).option(`--git-root`,`Search from the git root directory instead of the base directory`).option(`--json`,`Output the results as JSON`).action(e=>{d({baseDir:e.baseDir,gitRoot:e.gitRoot,json:e.json})}),m.command(`projects-list`).alias(`pl`).description(`List all Intlayer projects in the directory`).option(`--base-dir [baseDir]`,`Base directory to search from`).option(`--git-root`,`Search from the git root directory instead of the base directory`).option(`--absolute`,`Output the results as absolute paths`).option(`--json`,`Output the results as JSON`).action(e=>{d({baseDir:e.baseDir,gitRoot:e.gitRoot,json:e.json,absolute:e.absolute})});let H=m.command(`content`).description(`Content declaration operations`);H.command(`list`).description(`List the content declaration files`).option(`--json`,`Output the results as JSON`).option(`--absolute`,`Output the results as absolute paths`).action(e=>{u({json:e.json,absolute:e.absolute})}),m.command(`list`).description(`List the content declaration files`).option(`--json`,`Output the results as JSON`).option(`--absolute`,`Output the results as absolute paths`).action(e=>{u({json:e.json,absolute:e.absolute})});let U=H.command(`test`).description(`Test if there are missing translations`).option(`--build [build]`,`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`);O(U),U.action(e=>{o({...e,configOptions:F(e)})});let W=m.command(`test`).description(`Test if there are missing translations`).option(`--build [build]`,`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`);O(W),W.action(e=>{o({...e,configOptions:F(e)})});let G=m.command(`fill`).description(`Fill the dictionaries`).option(`-f, --file [files...]`,`List of Dictionary files to fill`).option(`--source-locale [sourceLocale]`,`Source locale to translate from`).option(`--output-locales [outputLocales...]`,`Target locales to translate to`).option(`--mode [mode]`,`Fill mode: complete, review. Complete will fill all missing content, review will fill missing content and review existing keys`,`complete`).option(`-k, --keys [keys...]`,`Filter dictionaries based on keys`).option(`--key [keys...]`,`Filter dictionaries based on keys (alias for --keys)`).option(`--excluded-keys [excludedKeys...]`,`Filter out dictionaries based on keys`).option(`--excluded-key [excludedKeys...]`,`Filter out dictionaries based on keys (alias for --excluded-keys)`).option(`--path-filter [pathFilters...]`,`Filter dictionaries based on glob pattern`).option(`--build [build]`,`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`).option(`--skip-metadata`,`Skip filling missing metadata (description, title, tags) for dictionaries`);O(G),k(G),A(G),G.action(e=>{let t=[...e.keys??[],...e.key??[]],n=[...e.excludedKeys??[],...e.excludedKey??[]],r=[...e.dictionaries??[],...e.dictionary??[]];return s({...e,keys:t.length>0?t:void 0,excludedKeys:n.length>0?n:void 0,dictionaries:r.length>0?r:void 0,aiOptions:j(e),gitOptions:N(e),configOptions:F(e)})});let K=[[`--doc-pattern [docPattern...]`,`Documentation pattern`],[`--excluded-glob-pattern [excludedGlobPattern...]`,`Excluded glob pattern`],[`--nb-simultaneous-file-processed [nbSimultaneousFileProcessed]`,`Number of simultaneous file processed`],[`--locales [locales...]`,`Locales`],[`--base-locale [baseLocale]`,`Base locale`],[`--custom-instructions [customInstructions]`,`Custom instructions added to the prompt. Usefull to apply specific rules regarding formatting, urls translation, etc.`],[`--skip-if-modified-before [skipIfModifiedBefore]`,'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.'],[`--skip-if-modified-after [skipIfModifiedAfter]`,'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.'],[`--skip-if-exists`,`Skip the file if it already exists`]],q=m.command(`doc`).description(`Documentation operations`),J=q.command(`translate`).description(`Translate the documentation`);O(J),k(J),A(J),E(J,K),J.action(e=>ie({docPattern:e.docPattern,excludedGlobPattern:e.excludedGlobPattern,locales:e.locales,baseLocale:e.baseLocale,aiOptions:j(e),gitOptions:N(e),nbSimultaneousFileProcessed:e.nbSimultaneousFileProcessed,configOptions:F(e),customInstructions:e.customInstructions,skipIfModifiedBefore:e.skipIfModifiedBefore,skipIfModifiedAfter:e.skipIfModifiedAfter,skipIfExists:e.skipIfExists}));let Y=q.command(`review`).description(`Review the documentation`);O(Y),k(Y),A(Y),E(Y,K),Y.action(e=>ne({docPattern:e.docPattern,excludedGlobPattern:e.excludedGlobPattern,locales:e.locales,baseLocale:e.baseLocale,aiOptions:j(e),gitOptions:N(e),nbSimultaneousFileProcessed:e.nbSimultaneousFileProcessed,configOptions:F(e),customInstructions:e.customInstructions,skipIfModifiedBefore:e.skipIfModifiedBefore,skipIfModifiedAfter:e.skipIfModifiedAfter,skipIfExists:e.skipIfExists}));let X=q.command(`search`).description(`Search the documentation`).argument(`<query>`,`Search query`).option(`--limit [limit]`,`Limit the number of results`,`10`);O(X),X.action((e,t)=>re({query:e,limit:t.limit?parseInt(t.limit,10):10,configOptions:F(t)}));let oe=[[`--with [with...]`,`Start command in parallel with the live sync`]],Z=m.command(`live`).description(`Live sync - Watch for changes made on the CMS and update the application content accordingly`);E(Z,oe),O(Z),Z.action(e=>ee(e));let Q=m.command(`editor`).description(`Visual editor operations`).command(`start`).description(`Start the Intlayer visual editor`);O(Q),Q.action(e=>{i({env:e.env,envFile:e.envFile})});let $=m.command(`extract`).alias(`ext`).description(`Extract strings from components to be placed in a .content file close to the component`);return $.option(`-f, --file [files...]`,`List of files to extract`).option(`-o, --output-content-declarations [outputContentDeclarations]`,`Path to output content declaration files`).option(`--code-only`,`Only extract the component code`,!1).option(`--declaration-only`,`Only generate content declaration`,!1).action(e=>{a({files:e.file,outputContentDeclarations:e.outputContentDeclarations,configOptions:F(e),codeOnly:e.codeOnly,declarationOnly:e.declarationOnly})}),O($),m.parse(process.argv),m.command(`ci`).description(`Run Intlayer commands with auto-injected credentials from INTLAYER_PROJECT_CREDENTIALS. Detects current project or iterates over all projects.`).argument(`<command...>`,`The intlayer command to execute (e.g., "fill", "push")`).allowUnknownOption().action(e=>{t(e)}),m};export{b as dirname,I as setAPI};
1
+ import{build as e}from"./build.mjs";import{runCI as t}from"./ci.mjs";import{login as n}from"./auth/login.mjs";import{getConfig as r}from"./config.mjs";import{startEditor as i}from"./editor.mjs";import{extract as a}from"./extract.mjs";import{testMissingTranslations as o}from"./test/test.mjs";import{fill as s}from"./fill/fill.mjs";import{init as c}from"./init.mjs";import{initSkills as l}from"./initSkills.mjs";import{listContentDeclaration as u}from"./listContentDeclaration.mjs";import{listProjectsCommand as d}from"./listProjects.mjs";import{liveSync as ee}from"./liveSync.mjs";import{pull as f}from"./pull.mjs";import{push as p}from"./push/push.mjs";import{pushConfig as te}from"./pushConfig.mjs";import{reviewDoc as ne}from"./reviewDoc/reviewDoc.mjs";import{searchDoc as re}from"./searchDoc.mjs";import{translateDoc as ie}from"./translateDoc/translateDoc.mjs";import{getParentPackageJSON as m}from"./utils/getParentPackageJSON.mjs";import{watchContentDeclaration as h}from"./watch.mjs";import{getConfiguration as g}from"@intlayer/config/node";import{dirname as _}from"node:path";import{setPrefix as v}from"@intlayer/config/logger";import{fileURLToPath as y}from"node:url";import{Command as ae}from"commander";const b=typeof import.meta.url==`string`?_(y(import.meta.url)):__dirname,x=m(b),S=[[`--env-file [envFile]`,`Environment file`],[`-e, --env [env]`,`Environment`],[`--base-dir [baseDir]`,`Base directory`],[`--no-cache [noCache]`,`No cache`],...[[`--verbose`,`Verbose (default to true using CLI)`],[`--prefix [prefix]`,`Prefix`]]],C=[[`--provider [provider]`,`Provider`],[`--temperature [temperature]`,`Temperature`],[`--model [model]`,`Model`],[`--api-key [apiKey]`,`Provider API key`],[`--custom-prompt [prompt]`,`Custom prompt`],[`--application-context [applicationContext]`,`Application context`],[`--data-serialization [dataSerialization]`,`Data serialization`]],w=[[`--git-diff [gitDiff]`,`Git diff mode - Check git diff between two refs`],[`--git-diff-base [gitDiffBase]`,`Git diff base ref`],[`--git-diff-current [gitDiffCurrent]`,`Git diff current ref`],[`--uncommitted [uncommitted]`,`Uncommitted`],[`--unpushed [unpushed]`,`Unpushed`],[`--untracked [untracked]`,`Untracked`]],T=(e,t)=>t.filter(t=>e[t]!==void 0),E=(e,t)=>(t.forEach(([t,n])=>{e.option(t,n)}),e),D=e=>Object.fromEntries(Object.entries(e).filter(([e,t])=>t!==void 0)),O=e=>E(e,S),k=e=>E(e,C),A=e=>E(e,w),j=e=>{let{apiKey:t,provider:n,model:r,temperature:i,applicationContext:a,customPrompt:o,dataSerialization:s}=e,c=g(),{ai:l}=c;return D({...l,apiKey:t??c.ai?.apiKey,provider:n??c.ai?.provider,model:r??c.ai?.model,temperature:i??c.ai?.temperature,applicationContext:a??c.ai?.applicationContext,customPrompt:o??c.ai?.customPrompt,dataSerialization:s??c.ai?.dataSerialization})},M=[`gitDiff`,`gitDiffBase`,`gitDiffCurrent`,`uncommitted`,`unpushed`,`untracked`],N=e=>{if(T(e,M).length===0)return;let{gitDiff:t,gitDiffBase:n,gitDiffCurrent:r,uncommitted:i,unpushed:a,untracked:o}=e;return D({mode:[t&&`gitDiff`,i&&`uncommitted`,a&&`unpushed`,o&&`untracked`].filter(Boolean),baseRef:n,currentRef:r,absolute:!0})},P=[`baseDir`,`env`,`envFile`,`verbose`,`prefix`,`checkTypes`],F=e=>{if(T(e,P).length===0)return;e.with===void 0&&v(``);let{baseDir:t,env:n,envFile:r,verbose:i,noCache:a,checkTypes:o}=e,s=D({mode:i===void 0?void 0:i?`verbose`:`default`}),c=D({checkTypes:o}),l=D({log:Object.keys(s).length>0?s:void 0,build:Object.keys(c).length>0?c:void 0});return D({baseDir:t,env:n,envFile:r,override:Object.keys(l).length>0?l:void 0,cache:a===void 0?void 0:!a})},I=()=>{process.argv.includes(`--with`)||v(``);let m=new ae;m.version(x.version).description(`Intlayer CLI`),m.command(`version`).description(`Print the Intlayer CLI version`).action(()=>{console.log(x.version??`unknown`)});let g=m.command(`login`).description(`Login to Intlayer`).option(`--cms-url [cmsUrl]`,`CMS URL`);O(g),g.action(e=>{let t=F(e)??{override:{log:{prefix:``,mode:`verbose`}}};return n({cmsUrl:e.cmsUrl,configOptions:t})}),m.command(`init`).description(`Initialize Intlayer in the project`).option(`--project-root [projectRoot]`,`Project root directory`).action(e=>c(e.projectRoot)).command(`skills`).description(`Initialize Intlayer skills in the project`).option(`--project-root [projectRoot]`,`Project root directory`).action(e=>l(e.projectRoot));let _=m.command(`dictionary`).alias(`dictionaries`).alias(`dic`).description(`Dictionaries operations`),y={description:`Build the dictionaries`,options:[[`-w, --watch`,`Watch for changes`],[`--skip-prepare`,`Skip the prepare step`],[`--with [with...]`,`Start command in parallel with the build`],[`--check-types`,`Check TypeScript type and log errors`]]},b=_.command(`build`).description(y.description);E(b,y.options),O(b),b.action(t=>{e({...t,configOptions:F(t)})});let S=m.command(`build`).description(y.description);E(S,y.options),O(S),S.action(t=>{e({...t,configOptions:F(t)})});let C={description:`Watch the dictionaries changes`,options:[[`--with [with...]`,`Start command in parallel with the build`]]},w=_.command(`watch`).description(y.description);E(w,C.options),O(w),w.action(e=>{h({...e,configOptions:F(e)})});let T=m.command(`watch`).description(y.description);E(T,C.options),O(T),T.action(e=>{h({...e,configOptions:F(e)})});let D={description:`Pull dictionaries from the server`,options:[[`-d, --dictionaries [ids...]`,`List of dictionary IDs to pull`],[`--dictionary [ids...]`,`List of dictionary IDs to pull (alias for --dictionaries)`],[`--new-dictionaries-path [path]`,`Path to save the new dictionaries`],[`--newDictionariesPath [path]`,`[alias] Path to save the new dictionaries`]]},M=_.command(`pull`).description(D.description);E(M,D.options),O(M),M.action(e=>{let t=[...e.dictionaries??[],...e.dictionary??[]];f({...e,dictionaries:t.length>0?t:void 0,configOptions:{...e.configOptions,baseDir:e.baseDir}})});let P=m.command(`pull`).description(D.description);E(P,D.options),O(P),P.action(e=>{let t=[...e.dictionaries??[],...e.dictionary??[]];f({...e,dictionaries:t.length>0?t:void 0,configOptions:F(e)})});let I={description:`Push all dictionaries. Create or update the pushed dictionaries`,options:[[`-d, --dictionaries [ids...]`,`List of dictionary IDs to push`],[`--dictionary [ids...]`,`List of dictionary IDs to push (alias for --dictionaries)`],[`-r, --delete-locale-dictionary`,`Delete the local dictionaries after pushing`],[`-k, --keep-locale-dictionary`,`Keep the local dictionaries after pushing`],[`--deleteLocaleDictionary`,`[alias] Delete the local dictionaries after pushing`],[`--keepLocaleDictionary`,`[alias] Keep the local dictionaries after pushing`],[`--build [build]`,`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`]]},L=_.command(`push`).description(I.description);E(L,I.options),O(L),A(L),L.action(e=>{let t=[...e.dictionaries||[],...e.dictionary||[]];return p({...e,dictionaries:t.length>0?t:void 0,gitOptions:N(e),configOptions:F(e)})});let R=m.command(`push`).description(I.description);E(R,I.options),O(R),A(R),R.action(e=>{let t=[...e.dictionaries||[],...e.dictionary||[]];return p({...e,dictionaries:t.length>0?t:void 0,gitOptions:N(e),configOptions:F(e)})});let z=m.command(`configuration`).alias(`config`).alias(`conf`).description(`Configuration operations`),B=z.command(`get`).description(`Get the configuration`);O(B),B.action(e=>{r({...e,configOptions:F(e)})});let V=z.command(`push`).description(`Push the configuration`);O(V),V.action(e=>{te({...e,configOptions:F(e)})}),m.command(`projects`).alias(`project`).description(`List Intlayer projects`).command(`list`).description(`List all Intlayer projects in the directory`).option(`--base-dir [baseDir]`,`Base directory to search from`).option(`--git-root`,`Search from the git root directory instead of the base directory`).option(`--json`,`Output the results as JSON`).action(e=>{d({baseDir:e.baseDir,gitRoot:e.gitRoot,json:e.json})}),m.command(`projects-list`).alias(`pl`).description(`List all Intlayer projects in the directory`).option(`--base-dir [baseDir]`,`Base directory to search from`).option(`--git-root`,`Search from the git root directory instead of the base directory`).option(`--absolute`,`Output the results as absolute paths`).option(`--json`,`Output the results as JSON`).action(e=>{d({baseDir:e.baseDir,gitRoot:e.gitRoot,json:e.json,absolute:e.absolute})});let H=m.command(`content`).description(`Content declaration operations`);H.command(`list`).description(`List the content declaration files`).option(`--json`,`Output the results as JSON`).option(`--absolute`,`Output the results as absolute paths`).action(e=>{u({json:e.json,absolute:e.absolute})}),m.command(`list`).description(`List the content declaration files`).option(`--json`,`Output the results as JSON`).option(`--absolute`,`Output the results as absolute paths`).action(e=>{u({json:e.json,absolute:e.absolute})});let U=H.command(`test`).description(`Test if there are missing translations`).option(`--build [build]`,`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`);O(U),U.action(e=>{o({...e,configOptions:F(e)})});let W=m.command(`test`).description(`Test if there are missing translations`).option(`--build [build]`,`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`);O(W),W.action(e=>{o({...e,configOptions:F(e)})});let G=m.command(`fill`).description(`Fill the dictionaries`).option(`-f, --file [files...]`,`List of Dictionary files to fill`).option(`--source-locale [sourceLocale]`,`Source locale to translate from`).option(`--output-locales [outputLocales...]`,`Target locales to translate to`).option(`--mode [mode]`,`Fill mode: complete, review. Complete will fill all missing content, review will fill missing content and review existing keys`,`complete`).option(`-k, --keys [keys...]`,`Filter dictionaries based on keys`).option(`--key [keys...]`,`Filter dictionaries based on keys (alias for --keys)`).option(`--excluded-keys [excludedKeys...]`,`Filter out dictionaries based on keys`).option(`--excluded-key [excludedKeys...]`,`Filter out dictionaries based on keys (alias for --excluded-keys)`).option(`--path-filter [pathFilters...]`,`Filter dictionaries based on glob pattern`).option(`--build [build]`,`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`).option(`--skip-metadata`,`Skip filling missing metadata (description, title, tags) for dictionaries`);O(G),k(G),A(G),G.action(e=>{let t=[...e.keys??[],...e.key??[]],n=[...e.excludedKeys??[],...e.excludedKey??[]],r=[...e.dictionaries??[],...e.dictionary??[]];return s({...e,keys:t.length>0?t:void 0,excludedKeys:n.length>0?n:void 0,dictionaries:r.length>0?r:void 0,aiOptions:j(e),gitOptions:N(e),configOptions:F(e)})});let K=[[`--doc-pattern [docPattern...]`,`Documentation pattern`],[`--excluded-glob-pattern [excludedGlobPattern...]`,`Excluded glob pattern`],[`--nb-simultaneous-file-processed [nbSimultaneousFileProcessed]`,`Number of simultaneous file processed`],[`--locales [locales...]`,`Locales`],[`--base-locale [baseLocale]`,`Base locale`],[`--custom-instructions [customInstructions]`,`Custom instructions added to the prompt. Usefull to apply specific rules regarding formatting, urls translation, etc.`],[`--skip-if-modified-before [skipIfModifiedBefore]`,'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.'],[`--skip-if-modified-after [skipIfModifiedAfter]`,'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.'],[`--skip-if-exists`,`Skip the file if it already exists`]],q=m.command(`doc`).description(`Documentation operations`),J=q.command(`translate`).description(`Translate the documentation`);O(J),k(J),A(J),E(J,K),J.action(e=>ie({docPattern:e.docPattern,excludedGlobPattern:e.excludedGlobPattern,locales:e.locales,baseLocale:e.baseLocale,aiOptions:j(e),gitOptions:N(e),nbSimultaneousFileProcessed:e.nbSimultaneousFileProcessed,configOptions:F(e),customInstructions:e.customInstructions,skipIfModifiedBefore:e.skipIfModifiedBefore,skipIfModifiedAfter:e.skipIfModifiedAfter,skipIfExists:e.skipIfExists}));let Y=q.command(`review`).description(`Review the documentation`);O(Y),k(Y),A(Y),E(Y,K),Y.action(e=>ne({docPattern:e.docPattern,excludedGlobPattern:e.excludedGlobPattern,locales:e.locales,baseLocale:e.baseLocale,aiOptions:j(e),gitOptions:N(e),nbSimultaneousFileProcessed:e.nbSimultaneousFileProcessed,configOptions:F(e),customInstructions:e.customInstructions,skipIfModifiedBefore:e.skipIfModifiedBefore,skipIfModifiedAfter:e.skipIfModifiedAfter,skipIfExists:e.skipIfExists}));let X=q.command(`search`).description(`Search the documentation`).argument(`<query>`,`Search query`).option(`--limit [limit]`,`Limit the number of results`,`10`);O(X),X.action((e,t)=>re({query:e,limit:t.limit?parseInt(t.limit,10):10,configOptions:F(t)}));let oe=[[`--with [with...]`,`Start command in parallel with the live sync`]],Z=m.command(`live`).description(`Live sync - Watch for changes made on the CMS and update the application content accordingly`);E(Z,oe),O(Z),Z.action(e=>ee(e));let Q=m.command(`editor`).description(`Visual editor operations`).command(`start`).description(`Start the Intlayer visual editor`);O(Q),Q.action(e=>{i({env:e.env,envFile:e.envFile})});let $=m.command(`extract`).alias(`ext`).description(`Extract strings from components to be placed in a .content file close to the component`);return $.option(`-f, --file [files...]`,`List of files to extract`).option(`-o, --output-content-declarations [outputContentDeclarations]`,`Path to output content declaration files`).option(`--code-only`,`Only extract the component code`,!1).option(`--declaration-only`,`Only generate content declaration`,!1).action(e=>{a({files:e.file,outputContentDeclarations:e.outputContentDeclarations,configOptions:F(e),codeOnly:e.codeOnly,declarationOnly:e.declarationOnly})}),O($),m.parse(process.argv),m.command(`ci`).description(`Run Intlayer commands with auto-injected credentials from INTLAYER_PROJECT_CREDENTIALS. Detects current project or iterates over all projects.`).argument(`<command...>`,`The intlayer command to execute (e.g., "fill", "push")`).allowUnknownOption().action(e=>{t(e)}),m};export{b as dirname,I as setAPI};
2
2
  //# sourceMappingURL=cli.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"cli.mjs","names":["pathDirname"],"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 { DiffMode, ListGitFilesOptions } from '@intlayer/chokidar/cli';\nimport { setPrefix } from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport { Command } from 'commander';\nimport { login } from './auth/login';\nimport { build } from './build';\nimport { runCI } from './ci';\nimport { getConfig } from './config';\nimport { startEditor } from './editor';\nimport { extract } from './extract';\nimport { type FillOptions, fill } from './fill/fill';\nimport { init } from './init';\nimport { initSkills } from './initSkills';\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 { searchDoc } from './searchDoc';\nimport { testMissingTranslations } from './test';\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 ['--data-serialization [dataSerialization]', 'Data serialization'],\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 dataSerialization,\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 dataSerialization: dataSerialization ?? configuration.ai?.dataSerialization,\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\n if (typeof prefix === 'string') {\n setPrefix(prefix);\n } else if (addPrefix) {\n setPrefix(configuration.log.prefix);\n }\n\n const log = {\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 setPrefix('');\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 const initCmd = 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 initCmd\n .command('skills')\n .description('Initialize Intlayer skills in the project')\n .option('--project-root [projectRoot]', 'Project root directory')\n .action((options) => initSkills(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 const searchProgram = docProgram\n .command('search')\n .description('Search the documentation')\n .argument('<query>', 'Search query')\n .option('--limit [limit]', 'Limit the number of results', '10');\n\n applyConfigOptions(searchProgram);\n\n searchProgram.action((query, options) =>\n searchDoc({\n query,\n limit: options.limit ? parseInt(options.limit, 10) : 10,\n configOptions: extractConfigOptions(options),\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 * EXTRACT\n */\n const extractProgram = program\n .command('extract')\n .alias('ext')\n .description(\n 'Extract strings from components to be placed in a .content file close to the component'\n );\n\n extractProgram\n .option('-f, --file [files...]', 'List of files to extract')\n .option(\n '-o, --output-content-declarations [outputContentDeclarations]',\n 'Path to output content declaration files'\n )\n .option('--code-only', 'Only extract the component code', false)\n .option('--declaration-only', 'Only generate content declaration', false)\n .action((options) => {\n extract({\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(extractProgram);\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":"8rCAuCA,MAAa,EAFM,OAAO,OAAO,KAAK,KAAQ,SAG1CA,EAAY,EAAc,OAAO,KAAK,IAAI,CAAC,CAC3C,UAEE,EAAc,EAAqB,EAAQ,CAO3C,EAAuB,CAC3B,CAAC,uBAAwB,mBAAmB,CAC5C,CAAC,kBAAmB,cAAc,CAClC,CAAC,uBAAwB,iBAAiB,CAC1C,CAAC,uBAAwB,WAAW,CACpC,GAViB,CACjB,CAAC,YAAa,sCAAsC,CACpD,CAAC,oBAAqB,SAAS,CAChC,CAQA,CAEK,EAAY,CAChB,CAAC,wBAAyB,WAAW,CACrC,CAAC,8BAA+B,cAAc,CAC9C,CA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AO,GAAG,CAAG,GACrD,cAAe,EAAqB,EAAQ,CAC7C,CAAC,CACH,CAMD,IAAM,GAAc,CAClB,CAAC,mBAAoB,+CAA+C,CACrE,CAEK,EAAU,EACb,QAAQ,OAAO,CACf,YACC,+FACD,CAEH,EAAa,EAAS,GAAY,CAClC,EAAmB,EAAQ,CAE3B,EAAQ,OAAQ,GAAY,GAAS,EAAQ,CAAC,CAU9C,IAAM,EAJgB,EACnB,QAAQ,SAAS,CACjB,YAAY,2BAA2B,CAGvC,QAAQ,QAAQ,CAChB,YAAY,mCAAmC,CAElD,EAAmB,EAAe,CAElC,EAAe,OAAQ,GAAY,CACjC,EAAY,CACV,IAAK,EAAQ,IACb,QAAS,EAAQ,QAClB,CAAC,EACF,CAKF,IAAM,EAAiB,EACpB,QAAQ,UAAU,CAClB,MAAM,MAAM,CACZ,YACC,yFACD,CA2CH,OAzCA,EACG,OAAO,wBAAyB,2BAA2B,CAC3D,OACC,gEACA,2CACD,CACA,OAAO,cAAe,kCAAmC,GAAM,CAC/D,OAAO,qBAAsB,oCAAqC,GAAM,CACxE,OAAQ,GAAY,CACnB,EAAQ,CACN,MAAO,EAAQ,KACf,0BAA2B,EAAQ,0BACnC,cAAe,EAAqB,EAAQ,CAC5C,SAAU,EAAQ,SAClB,gBAAiB,EAAQ,gBAC1B,CAAC,EACF,CAEJ,EAAmB,EAAe,CAElC,EAAQ,MAAM,QAAQ,KAAK,CAO3B,EACG,QAAQ,KAAK,CACb,YACC,iJACD,CACA,SACC,eACA,yDACD,CACA,oBAAoB,CACpB,OAAQ,GAAS,CAChB,EAAM,EAAK,EACX,CAEG"}
1
+ {"version":3,"file":"cli.mjs","names":["pathDirname"],"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 { DiffMode, ListGitFilesOptions } from '@intlayer/chokidar/cli';\nimport { setPrefix } from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport type { CustomIntlayerConfig } from '@intlayer/types';\nimport { Command } from 'commander';\nimport { login } from './auth/login';\nimport { build } from './build';\nimport { runCI } from './ci';\nimport { getConfig } from './config';\nimport { startEditor } from './editor';\nimport { extract } from './extract';\nimport { type FillOptions, fill } from './fill/fill';\nimport { init } from './init';\nimport { initSkills } from './initSkills';\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 { searchDoc } from './searchDoc';\nimport { testMissingTranslations } from './test';\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 ['--data-serialization [dataSerialization]', 'Data serialization'],\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] !== undefined);\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 dataSerialization,\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 dataSerialization: dataSerialization ?? configuration.ai?.dataSerialization,\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 = filteredOptions.length === 0;\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 checkTypes?: boolean;\n} & LogOptions;\n\nconst configurationOptionKeys: (keyof ConfigurationOptions)[] = [\n 'baseDir',\n 'env',\n 'envFile',\n 'verbose',\n 'prefix',\n 'checkTypes',\n];\n\nconst extractConfigOptions = (\n options: ConfigurationOptions & { with?: string }\n): GetConfigurationOptions | undefined => {\n const filteredOptions = extractKeysFromOptions(\n options,\n configurationOptionKeys\n );\n\n const isOptionEmpty = filteredOptions.length === 0;\n\n if (isOptionEmpty) {\n return undefined;\n }\n\n if (typeof options.with === 'undefined') {\n setPrefix('');\n }\n\n const { baseDir, env, envFile, verbose, noCache, checkTypes } = options;\n\n const log = removeUndefined({\n mode:\n typeof verbose !== 'undefined'\n ? verbose\n ? 'verbose'\n : 'default'\n : undefined,\n });\n\n const build = removeUndefined({\n checkTypes,\n });\n\n const override: CustomIntlayerConfig = removeUndefined({\n log:\n Object.keys(log).length > 0\n ? (log as CustomIntlayerConfig['log'])\n : undefined,\n build: Object.keys(build).length > 0 ? build : undefined,\n });\n\n return removeUndefined({\n baseDir,\n env,\n envFile,\n override: Object.keys(override).length > 0 ? override : undefined,\n cache: typeof noCache !== 'undefined' ? !noCache : undefined,\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 isWithCommand = process.argv.includes('--with');\n\n if (!isWithCommand) {\n setPrefix('');\n }\n\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 mode: 'verbose',\n },\n },\n };\n\n return login({\n cmsUrl: options.cmsUrl,\n configOptions,\n });\n });\n\n /**\n * INIT\n */\n const initCmd = 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 initCmd\n .command('skills')\n .description('Initialize Intlayer skills in the project')\n .option('--project-root [projectRoot]', 'Project root directory')\n .action((options) => initSkills(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 ['--check-types', 'Check TypeScript type and log errors'],\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 const searchProgram = docProgram\n .command('search')\n .description('Search the documentation')\n .argument('<query>', 'Search query')\n .option('--limit [limit]', 'Limit the number of results', '10');\n\n applyConfigOptions(searchProgram);\n\n searchProgram.action((query, options) =>\n searchDoc({\n query,\n limit: options.limit ? parseInt(options.limit, 10) : 10,\n configOptions: extractConfigOptions(options),\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 * EXTRACT\n */\n const extractProgram = program\n .command('extract')\n .alias('ext')\n .description(\n 'Extract strings from components to be placed in a .content file close to the component'\n );\n\n extractProgram\n .option('-f, --file [files...]', 'List of files to extract')\n .option(\n '-o, --output-content-declarations [outputContentDeclarations]',\n 'Path to output content declaration files'\n )\n .option('--code-only', 'Only extract the component code', false)\n .option('--declaration-only', 'Only generate content declaration', false)\n .action((options) => {\n extract({\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(extractProgram);\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":"8rCAwCA,MAAa,EAFM,OAAO,OAAO,KAAK,KAAQ,SAG1CA,EAAY,EAAc,OAAO,KAAK,IAAI,CAAC,CAC3C,UAEE,EAAc,EAAqB,EAAQ,CAO3C,EAAuB,CAC3B,CAAC,uBAAwB,mBAAmB,CAC5C,CAAC,kBAAmB,cAAc,CAClC,CAAC,uBAAwB,iBAAiB,CAC1C,CAAC,uBAAwB,WAAW,CACpC,GAViB,CACjB,CAAC,YAAa,sCAAsC,CACpD,CAAC,oBAAqB,SAAS,CAChC,CAQA,CAEK,EAAY,CAChB,CAAC,wBAAyB,WAAW,CACrC,CAAC,8BAA+B,cAAc,CAC9C,CAAC,kBAAmB,QAAQ,CAC5B,CAAC,qBAAsB,mBAAmB,CAC1C,CAAC,2BAA4B,gBAAgB,CAC7C,CAAC,6CAA8C,sBAAsB,CACrE,CAAC,2CAA4C,qBAAqB,CACnE,CAEK,EAAa,CACjB,CAAC,uBAAwB,kDAAkD,CAC3E,CAAC,gCAAiC,oBAAoB,CACtD,CAAC,sCAAuC,uBAAuB,CAC/D,CAAC,8BAA+B,cAAc,CAC9C,CAAC,wBAAyB,WAAW,CACrC,CAAC,0BAA2B,YAAY,CACzC,CAEK,GAA0B,EAAiB,IAC/C,EAAK,OAAQ,GAAQ,EAAQ,KAAiC,IAAA,GAAU,CAKpE,GAAgB,EAAkB,KACtC,EAAQ,SAAS,CAAC,EAAM,KAAiB,CACvC,EAAQ,OAAO,EAAM,EAAY,EACjC,CACK,GAGH,EAAkD,GACtD,OAAO,YACL,OAAO,QAAQ,EAAI,CAAC,QAAQ,CAAC,EAAG,KAAW,IAAU,IAAA,GAAU,CAChE,CAEG,EAAsB,GAC1B,EAAa,EAAS,EAAqB,CACvC,EAAkB,GAAqB,EAAa,EAAS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AAQ,UAAU,CAClB,MAAM,MAAM,CACZ,YACC,yFACD,CA2CH,OAzCA,EACG,OAAO,wBAAyB,2BAA2B,CAC3D,OACC,gEACA,2CACD,CACA,OAAO,cAAe,kCAAmC,GAAM,CAC/D,OAAO,qBAAsB,oCAAqC,GAAM,CACxE,OAAQ,GAAY,CACnB,EAAQ,CACN,MAAO,EAAQ,KACf,0BAA2B,EAAQ,0BACnC,cAAe,EAAqB,EAAQ,CAC5C,SAAU,EAAQ,SAClB,gBAAiB,EAAQ,gBAC1B,CAAC,EACF,CAEJ,EAAmB,EAAe,CAElC,EAAQ,MAAM,QAAQ,KAAK,CAO3B,EACG,QAAQ,KAAK,CACb,YACC,iJACD,CACA,SACC,eACA,yDACD,CACA,oBAAoB,CACpB,OAAQ,GAAS,CAChB,EAAM,EAAK,EACX,CAEG"}
@@ -1,2 +1,2 @@
1
- import{deepMergeContent as e}from"./deepMergeContent.mjs";import{getFilterMissingContentPerLocale as t}from"./getFilterMissingContentPerLocale.mjs";import{mergeChunks as n}from"./mergeChunks.mjs";import{getIntlayerAPIProxy as r}from"@intlayer/api";import{chunkJSON as i,formatLocale as a,reconstructFromSingleChunk as o,reduceObjectFormat as s,verifyIdenticObjectFormat as c}from"@intlayer/chokidar/utils";import{basename as l}from"node:path";import{ANSIColors as u,colon as d,colorize as f,colorizeNumber as p,colorizePath as m,getAppLogger as h}from"@intlayer/config/logger";import{retryManager as g}from"@intlayer/config/utils";import{getUnmergedDictionaries as _}from"@intlayer/unmerged-dictionaries-entry";import{getFilterMissingTranslationsDictionary as v,getMultilingualDictionary as y,getPerLocaleDictionary as b,insertContentInDictionary as x}from"@intlayer/core/plugins";const S=e=>!e.description||!e.title||!e.tags,C=1e3*10;let w=0;const T=async(T,E,D)=>{let O=h(E),k=r(void 0,E),{mode:A,aiOptions:j,fillMetadata:M,aiClient:N,aiConfig:P}={mode:`complete`,fillMetadata:!0,...D},F=()=>{w=0,D?.onSuccess?.()};return await g(async()=>{let r=_(E),h=r[T.dictionaryKey].find(e=>e.localId===T.dictionaryLocalId);if(!h)return O(`${T.dictionaryPreset}Dictionary not found in unmergedDictionariesRecord. Skipping.`,{level:`warn`}),{...T,dictionaryOutput:null};let I;if(M&&(S(h)||A===`review`)){let e=b(h,E.internationalization.defaultLocale);O(`${T.dictionaryPreset} Filling missing metadata for ${m(l(h.filePath))}`,{level:`info`});let t=async()=>N&&P?{data:await N.auditDictionaryMetadata({fileContent:JSON.stringify(e),aiConfig:P})}:await k.ai.auditContentDeclarationMetadata({fileContent:JSON.stringify(e),aiOptions:j});I=(D?.onHandle?await D.onHandle(t):await t()).data?.fileContent}let L=await Promise.all(T.targetLocales.map(async _=>{let y=structuredClone(h),x;if(typeof h.locale==`string`){let e=h.filePath?.replace(RegExp(`/${T.sourceLocale}/`,`g`),`/${_}/`),n=e?r[T.dictionaryKey]?.find(t=>t.filePath===e&&t.locale===_):void 0;x=n??{key:h.key,content:{},filePath:e,locale:_},A===`complete`&&(y=t(y,n))}else A===`complete`&&(y=v(y,_)),y=b(y,T.sourceLocale),x=b(h,_);let S=d([f(`[`,u.GREY_DARK),a(_),f(`]`,u.GREY_DARK)].join(``),{colSize:18}),E=(e,t)=>t<=1?``:d([f(`[`,u.GREY_DARK),p(e+1),f(`/${t}`,u.GREY_DARK),f(`]`,u.GREY_DARK)].join(``),{colSize:5});O(`${T.dictionaryPreset}${S} Preparing ${m(l(x.filePath))}`,{level:`info`});let M=typeof y.content==`object`&&y.content!==null||Array.isArray(y.content),L=i(M?y.content:{__INTLAYER_ROOT_PRIMITIVE_CONTENT__:y.content},7e3),R=L.length;R>1&&O(`${T.dictionaryPreset}${S} Split into ${p(R)} chunks for translation`,{level:`info`});let z=[],B=L.map(e=>{let t=E(e.index,e.total);R>1&&O(`${T.dictionaryPreset}${S}${t} Translating chunk`,{level:`info`});let n=o(e),r=s(M?x.content:{__INTLAYER_ROOT_PRIMITIVE_CONTENT__:x.content},n),i=async()=>await g(async()=>{let e;if(e=N&&P?await N.translateJSON({entryFileContent:n,presetOutputContent:r,dictionaryDescription:y.description??I?.description??``,entryLocale:T.sourceLocale,outputLocale:_,mode:A,aiConfig:P}):await k.ai.translateJSON({entryFileContent:n,presetOutputContent:r,dictionaryDescription:y.description??I?.description??``,entryLocale:T.sourceLocale,outputLocale:_,mode:A,aiOptions:j}).then(e=>e.data),!e?.fileContent)throw Error(`No content result`);let{isIdentic:t}=c(e.fileContent,n);if(!t)throw Error(`Translation result does not match expected format`);return F(),e.fileContent},{maxRetry:3,delay:C,onError:({error:t,attempt:n,maxRetry:r})=>{let i=E(e.index,e.total);O(`${T.dictionaryPreset}${S}${i} ${f(`Error filling:`,u.RED)} ${f(typeof t==`string`?t:JSON.stringify(t),u.GREY_DARK)} - Attempt ${p(n+1)} of ${p(r)}`,{level:`error`}),w+=1,w>=10&&(O(`There is something wrong.`,{level:`error`}),process.exit(1))}})();return(D?.onHandle?D.onHandle(i):i()).then(t=>({chunk:e,result:t}))});(await Promise.all(B)).sort((e,t)=>e.chunk.index-t.chunk.index).forEach(({result:e})=>{z.push(e)});let V=n(z),H={...y,content:V}.content;return M||(H=H?.__INTLAYER_ROOT_PRIMITIVE_CONTENT__),typeof h.locale==`string`&&(H=e(x.content??{},H)),[_,H]})),R=Object.fromEntries(L),z={...y(h.locale?{...h,key:h.key,content:{}}:h),locale:void 0,...I};for(let e of T.targetLocales)R[e]&&(z=x(z,R[e],e));if(O(`${T.dictionaryPreset} ${f(`Translation completed successfully`,u.GREEN)} for ${m(l(z.filePath))}`,{level:`info`}),h.locale&&(h.fill===!0||h.fill===void 0)&&h.location===`local`){let e=h.filePath.split(`.`).slice(0,-1),t=e[e.length-1];return JSON.parse(JSON.stringify({...T,dictionaryOutput:{...z,fill:void 0,filled:!0}}).replaceAll(RegExp(`\\.${t}\\.[a-zA-Z0-9]+`,`g`),`.filled.${t}.json`))}return{...T,dictionaryOutput:z}},{maxRetry:2,delay:C,onError:({error:e,attempt:t,maxRetry:n})=>O(`${T.dictionaryPreset} ${f(`Error:`,u.RED)} ${f(typeof e==`string`?e:JSON.stringify(e),u.GREY_DARK)} - Attempt ${p(t+1)} of ${p(n)}`,{level:`error`}),onMaxTryReached:({error:e})=>O(`${T.dictionaryPreset} ${f(`Maximum number of retries reached:`,u.RED)} ${f(typeof e==`string`?e:JSON.stringify(e),u.GREY_DARK)}`,{level:`error`})})()};export{T as translateDictionary};
1
+ import{deepMergeContent as e}from"./deepMergeContent.mjs";import{getFilterMissingContentPerLocale as t}from"./getFilterMissingContentPerLocale.mjs";import{getIntlayerAPIProxy as n}from"@intlayer/api";import{chunkJSON as r,formatLocale as i,mergeChunks as a,reconstructFromSingleChunk as o,reduceObjectFormat as s,verifyIdenticObjectFormat as c}from"@intlayer/chokidar/utils";import{basename as l}from"node:path";import{ANSIColors as u,colon as d,colorize as f,colorizeNumber as p,colorizePath as m,getAppLogger as h}from"@intlayer/config/logger";import{retryManager as g}from"@intlayer/config/utils";import{getUnmergedDictionaries as _}from"@intlayer/unmerged-dictionaries-entry";import{getFilterMissingTranslationsDictionary as v,getMultilingualDictionary as y,getPerLocaleDictionary as b,insertContentInDictionary as x}from"@intlayer/core/plugins";const S=e=>!e.description||!e.title||!e.tags,C=1e3*10;let w=0;const T=async(T,E,D)=>{let O=h(E),k=n(void 0,E),{mode:A,aiOptions:j,fillMetadata:M,aiClient:N,aiConfig:P}={mode:`complete`,fillMetadata:!0,...D},F=()=>{w=0,D?.onSuccess?.()};return await g(async()=>{let n=_(E),h=n[T.dictionaryKey].find(e=>e.localId===T.dictionaryLocalId);if(!h)return O(`${T.dictionaryPreset}Dictionary not found in unmergedDictionariesRecord. Skipping.`,{level:`warn`}),{...T,dictionaryOutput:null};let I;if(M&&(S(h)||A===`review`)){let e=b(h,E.internationalization.defaultLocale);O(`${T.dictionaryPreset} Filling missing metadata for ${m(l(h.filePath))}`,{level:`info`});let t=async()=>N&&P?{data:await N.auditDictionaryMetadata({fileContent:JSON.stringify(e),aiConfig:P})}:await k.ai.auditContentDeclarationMetadata({fileContent:JSON.stringify(e),aiOptions:j});I=(D?.onHandle?await D.onHandle(t):await t()).data?.fileContent}let L=await Promise.all(T.targetLocales.map(async _=>{let y=structuredClone(h),x;if(typeof h.locale==`string`){let e=h.filePath?.replace(RegExp(`/${T.sourceLocale}/`,`g`),`/${_}/`),r=e?n[T.dictionaryKey]?.find(t=>t.filePath===e&&t.locale===_):void 0;x=r??{key:h.key,content:{},filePath:e,locale:_},A===`complete`&&(y=t(y,r))}else A===`complete`&&(y=v(y,_)),y=b(y,T.sourceLocale),x=b(h,_);let S=d([f(`[`,u.GREY_DARK),i(_),f(`]`,u.GREY_DARK)].join(``),{colSize:18}),E=(e,t)=>t<=1?``:d([f(`[`,u.GREY_DARK),p(e+1),f(`/${t}`,u.GREY_DARK),f(`]`,u.GREY_DARK)].join(``),{colSize:5});O(`${T.dictionaryPreset}${S} Preparing ${m(l(x.filePath))}`,{level:`info`});let M=typeof y.content==`object`&&y.content!==null||Array.isArray(y.content),L=r(M?y.content:{__INTLAYER_ROOT_PRIMITIVE_CONTENT__:y.content},7e3),R=L.length;R>1&&O(`${T.dictionaryPreset}${S} Split into ${p(R)} chunks for translation`,{level:`info`});let z=[],B=L.map(e=>{let t=E(e.index,e.total);R>1&&O(`${T.dictionaryPreset}${S}${t} Translating chunk`,{level:`info`});let n=o(e),r=s(M?x.content:{__INTLAYER_ROOT_PRIMITIVE_CONTENT__:x.content},n),i=async()=>await g(async()=>{let e;if(e=N&&P?await N.translateJSON({entryFileContent:n,presetOutputContent:r,dictionaryDescription:y.description??I?.description??``,entryLocale:T.sourceLocale,outputLocale:_,mode:A,aiConfig:P}):await k.ai.translateJSON({entryFileContent:n,presetOutputContent:r,dictionaryDescription:y.description??I?.description??``,entryLocale:T.sourceLocale,outputLocale:_,mode:A,aiOptions:j}).then(e=>e.data),!e?.fileContent)throw Error(`No content result`);let{isIdentic:t}=c(e.fileContent,n);if(!t)throw Error(`Translation result does not match expected format`);return F(),e.fileContent},{maxRetry:3,delay:C,onError:({error:t,attempt:n,maxRetry:r})=>{let i=E(e.index,e.total);O(`${T.dictionaryPreset}${S}${i} ${f(`Error filling:`,u.RED)} ${f(typeof t==`string`?t:JSON.stringify(t),u.GREY_DARK)} - Attempt ${p(n+1)} of ${p(r)}`,{level:`error`}),w+=1,w>=10&&(O(`There is something wrong.`,{level:`error`}),process.exit(1))}})();return(D?.onHandle?D.onHandle(i):i()).then(t=>({chunk:e,result:t}))});(await Promise.all(B)).sort((e,t)=>e.chunk.index-t.chunk.index).forEach(({result:e})=>{z.push(e)});let V=a(z),H={...y,content:V}.content;return M||(H=H?.__INTLAYER_ROOT_PRIMITIVE_CONTENT__),typeof h.locale==`string`&&(H=e(x.content??{},H)),[_,H]})),R=Object.fromEntries(L),z={...y(h.locale?{...h,key:h.key,content:{}}:h),locale:void 0,...I};for(let e of T.targetLocales)R[e]&&(z=x(z,R[e],e));if(O(`${T.dictionaryPreset} ${f(`Translation completed successfully`,u.GREEN)} for ${m(l(z.filePath))}`,{level:`info`}),h.locale&&(h.fill===!0||h.fill===void 0)&&h.location===`local`){let e=h.filePath.split(`.`).slice(0,-1),t=e[e.length-1];return JSON.parse(JSON.stringify({...T,dictionaryOutput:{...z,fill:void 0,filled:!0}}).replaceAll(RegExp(`\\.${t}\\.[a-zA-Z0-9]+`,`g`),`.filled.${t}.json`))}return{...T,dictionaryOutput:z}},{maxRetry:2,delay:C,onError:({error:e,attempt:t,maxRetry:n})=>O(`${T.dictionaryPreset} ${f(`Error:`,u.RED)} ${f(typeof e==`string`?e:JSON.stringify(e),u.GREY_DARK)} - Attempt ${p(t+1)} of ${p(n)}`,{level:`error`}),onMaxTryReached:({error:e})=>O(`${T.dictionaryPreset} ${f(`Maximum number of retries reached:`,u.RED)} ${f(typeof e==`string`?e:JSON.stringify(e),u.GREY_DARK)}`,{level:`error`})})()};export{T as translateDictionary};
2
2
  //# sourceMappingURL=translateDictionary.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"translateDictionary.mjs","names":[],"sources":["../../../src/fill/translateDictionary.ts"],"sourcesContent":["import { basename } from 'node:path';\nimport type { AIConfig } from '@intlayer/ai';\nimport { type AIOptions, getIntlayerAPIProxy } from '@intlayer/api';\nimport {\n chunkJSON,\n formatLocale,\n type JsonChunk,\n reconstructFromSingleChunk,\n reduceObjectFormat,\n verifyIdenticObjectFormat,\n} from '@intlayer/chokidar/utils';\nimport {\n ANSIColors,\n colon,\n colorize,\n colorizeNumber,\n colorizePath,\n getAppLogger,\n} from '@intlayer/config/logger';\nimport { retryManager } from '@intlayer/config/utils';\nimport {\n getFilterMissingTranslationsDictionary,\n getMultilingualDictionary,\n getPerLocaleDictionary,\n insertContentInDictionary,\n} from '@intlayer/core/plugins';\nimport type { Dictionary, IntlayerConfig, Locale } from '@intlayer/types';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\nimport type { AIClient } from '../utils/setupAI';\nimport { deepMergeContent } from './deepMergeContent';\nimport { getFilterMissingContentPerLocale } from './getFilterMissingContentPerLocale';\nimport type { TranslationTask } from './listTranslationsTasks';\nimport { mergeChunks } from './mergeChunks';\n\ntype TranslateDictionaryResult = TranslationTask & {\n dictionaryOutput: Dictionary | null;\n};\n\ntype TranslateDictionaryOptions = {\n mode: 'complete' | 'review';\n aiOptions?: AIOptions;\n fillMetadata?: boolean;\n onHandle?: ReturnType<\n typeof import('@intlayer/chokidar/utils').getGlobalLimiter\n >;\n onSuccess?: () => void;\n onError?: (error: unknown) => void;\n getAbortError?: () => Error | null;\n aiClient?: AIClient;\n aiConfig?: AIConfig;\n};\n\nconst hasMissingMetadata = (dictionary: Dictionary) =>\n !dictionary.description || !dictionary.title || !dictionary.tags;\n\nconst CHUNK_SIZE = 7000; // GPT-5 Mini safe input size\nconst GROUP_MAX_RETRY = 2;\nconst MAX_RETRY = 3;\nconst RETRY_DELAY = 1000 * 10; // 10 seconds\n\nconst MAX_FOLLOWING_ERRORS = 10; // 10 errors in a row, hard exit the process\nlet followingErrors = 0;\n\nexport const translateDictionary = async (\n task: TranslationTask,\n configuration: IntlayerConfig,\n options?: TranslateDictionaryOptions\n): Promise<TranslateDictionaryResult> => {\n const appLogger = getAppLogger(configuration);\n const intlayerAPI = getIntlayerAPIProxy(undefined, configuration);\n\n const { mode, aiOptions, fillMetadata, aiClient, aiConfig } = {\n mode: 'complete',\n fillMetadata: true,\n ...options,\n } as const;\n\n const notifySuccess = () => {\n followingErrors = 0;\n options?.onSuccess?.();\n };\n\n const result = await retryManager(\n async () => {\n const unmergedDictionariesRecord = getUnmergedDictionaries(configuration);\n\n const baseUnmergedDictionary: Dictionary | undefined =\n unmergedDictionariesRecord[task.dictionaryKey].find(\n (dict) => dict.localId === task.dictionaryLocalId\n );\n\n if (!baseUnmergedDictionary) {\n appLogger(\n `${task.dictionaryPreset}Dictionary not found in unmergedDictionariesRecord. Skipping.`,\n {\n level: 'warn',\n }\n );\n return { ...task, dictionaryOutput: null };\n }\n\n let metadata:\n | Pick<Dictionary, 'description' | 'title' | 'tags'>\n | undefined;\n\n if (\n fillMetadata &&\n (hasMissingMetadata(baseUnmergedDictionary) || mode === 'review')\n ) {\n const defaultLocaleDictionary = getPerLocaleDictionary(\n baseUnmergedDictionary,\n configuration.internationalization.defaultLocale\n );\n\n appLogger(\n `${task.dictionaryPreset} Filling missing metadata for ${colorizePath(basename(baseUnmergedDictionary.filePath!))}`,\n {\n level: 'info',\n }\n );\n\n const runAudit = async () => {\n if (aiClient && aiConfig) {\n const result = await aiClient.auditDictionaryMetadata({\n fileContent: JSON.stringify(defaultLocaleDictionary),\n aiConfig,\n });\n\n return {\n data: result,\n };\n }\n\n return await intlayerAPI.ai.auditContentDeclarationMetadata({\n fileContent: JSON.stringify(defaultLocaleDictionary),\n aiOptions,\n });\n };\n\n const metadataResult = options?.onHandle\n ? await options.onHandle(runAudit)\n : await runAudit();\n\n metadata = metadataResult.data?.fileContent;\n }\n\n const translatedContentResults = await Promise.all(\n task.targetLocales.map(async (targetLocale) => {\n /**\n * In complete mode, for large dictionaries, we want to filter all content that is already translated\n *\n * targetLocale: fr\n *\n * { test1: t({ ar: 'Hello', en: 'Hello', fr: 'Bonjour' } }) -> {}\n * { test2: t({ ar: 'Hello', en: 'Hello' }) } -> { test2: t({ ar: 'Hello', en: 'Hello' }) }\n *\n */\n // Reset to base dictionary for each locale to ensure we filter from the original\n let dictionaryToProcess = structuredClone(baseUnmergedDictionary);\n\n let targetLocaleDictionary: Dictionary;\n\n if (typeof baseUnmergedDictionary.locale === 'string') {\n // For per-locale files, the content is already in simple JSON format (not translation nodes)\n // The base dictionary is already the source locale content\n\n // Load the existing target locale dictionary\n const targetLocaleFilePath =\n baseUnmergedDictionary.filePath?.replace(\n new RegExp(`/${task.sourceLocale}/`, 'g'),\n `/${targetLocale}/`\n );\n\n // Find the target locale dictionary in unmerged dictionaries\n const targetUnmergedDictionary = targetLocaleFilePath\n ? unmergedDictionariesRecord[task.dictionaryKey]?.find(\n (dict) =>\n dict.filePath === targetLocaleFilePath &&\n dict.locale === targetLocale\n )\n : undefined;\n\n targetLocaleDictionary = targetUnmergedDictionary ?? {\n key: baseUnmergedDictionary.key,\n content: {},\n filePath: targetLocaleFilePath,\n locale: targetLocale,\n };\n\n // In complete mode, filter out already translated content\n if (mode === 'complete') {\n dictionaryToProcess = getFilterMissingContentPerLocale(\n dictionaryToProcess,\n targetUnmergedDictionary\n );\n }\n } else {\n // For multilingual dictionaries\n if (mode === 'complete') {\n // Remove all nodes that don't have any content to translate\n dictionaryToProcess = getFilterMissingTranslationsDictionary(\n dictionaryToProcess,\n targetLocale\n );\n }\n\n dictionaryToProcess = getPerLocaleDictionary(\n dictionaryToProcess,\n task.sourceLocale\n );\n\n targetLocaleDictionary = getPerLocaleDictionary(\n baseUnmergedDictionary,\n targetLocale\n );\n }\n\n const localePreset = colon(\n [\n colorize('[', ANSIColors.GREY_DARK),\n formatLocale(targetLocale),\n colorize(']', ANSIColors.GREY_DARK),\n ].join(''),\n { colSize: 18 }\n );\n\n const createChunkPreset = (\n chunkIndex: number,\n totalChunks: number\n ) => {\n if (totalChunks <= 1) return '';\n return colon(\n [\n colorize('[', ANSIColors.GREY_DARK),\n colorizeNumber(chunkIndex + 1),\n colorize(`/${totalChunks}`, ANSIColors.GREY_DARK),\n colorize(']', ANSIColors.GREY_DARK),\n ].join(''),\n { colSize: 5 }\n );\n };\n\n appLogger(\n `${task.dictionaryPreset}${localePreset} Preparing ${colorizePath(basename(targetLocaleDictionary.filePath!))}`,\n {\n level: 'info',\n }\n );\n\n const isContentStructured =\n (typeof dictionaryToProcess.content === 'object' &&\n dictionaryToProcess.content !== null) ||\n Array.isArray(dictionaryToProcess.content);\n\n const contentToProcess = isContentStructured\n ? dictionaryToProcess.content\n : {\n __INTLAYER_ROOT_PRIMITIVE_CONTENT__:\n dictionaryToProcess.content,\n };\n\n const chunkedJsonContent: JsonChunk[] = chunkJSON(\n contentToProcess as unknown as Record<string, any>,\n CHUNK_SIZE\n );\n\n const nbOfChunks = chunkedJsonContent.length;\n\n if (nbOfChunks > 1) {\n appLogger(\n `${task.dictionaryPreset}${localePreset} Split into ${colorizeNumber(nbOfChunks)} chunks for translation`,\n {\n level: 'info',\n }\n );\n }\n\n const chunkResult: JsonChunk[] = [];\n\n // Process chunks in parallel (globally throttled) to allow concurrent translation\n const chunkPromises = chunkedJsonContent.map((chunk) => {\n const chunkPreset = createChunkPreset(chunk.index, chunk.total);\n\n if (nbOfChunks > 1) {\n appLogger(\n `${task.dictionaryPreset}${localePreset}${chunkPreset} Translating chunk`,\n {\n level: 'info',\n }\n );\n }\n\n // Reconstruct partial JSON content from this chunk's patches\n const chunkContent = reconstructFromSingleChunk(chunk);\n const presetOutputContent = reduceObjectFormat(\n isContentStructured\n ? targetLocaleDictionary.content\n : {\n __INTLAYER_ROOT_PRIMITIVE_CONTENT__:\n targetLocaleDictionary.content,\n },\n chunkContent\n ) as unknown as JSON;\n\n const executeTranslation = async () => {\n return await retryManager(\n async () => {\n let translationResult: any;\n\n if (aiClient && aiConfig) {\n translationResult = await aiClient.translateJSON({\n entryFileContent: chunkContent as unknown as JSON,\n presetOutputContent,\n dictionaryDescription:\n dictionaryToProcess.description ??\n metadata?.description ??\n '',\n entryLocale: task.sourceLocale,\n outputLocale: targetLocale,\n mode,\n aiConfig,\n });\n } else {\n translationResult = await intlayerAPI.ai\n .translateJSON({\n entryFileContent: chunkContent as unknown as JSON,\n presetOutputContent,\n dictionaryDescription:\n dictionaryToProcess.description ??\n metadata?.description ??\n '',\n entryLocale: task.sourceLocale,\n outputLocale: targetLocale,\n mode,\n aiOptions,\n })\n .then((result) => result.data);\n }\n\n if (!translationResult?.fileContent) {\n throw new Error('No content result');\n }\n\n const { isIdentic } = verifyIdenticObjectFormat(\n translationResult.fileContent,\n chunkContent\n );\n\n if (!isIdentic) {\n throw new Error(\n 'Translation result does not match expected format'\n );\n }\n\n notifySuccess();\n return translationResult.fileContent;\n },\n {\n maxRetry: MAX_RETRY,\n delay: RETRY_DELAY,\n onError: ({ error, attempt, maxRetry }) => {\n const chunkPreset = createChunkPreset(\n chunk.index,\n chunk.total\n );\n appLogger(\n `${task.dictionaryPreset}${localePreset}${chunkPreset} ${colorize('Error filling:', ANSIColors.RED)} ${colorize(typeof error === 'string' ? error : JSON.stringify(error), ANSIColors.GREY_DARK)} - Attempt ${colorizeNumber(attempt + 1)} of ${colorizeNumber(maxRetry)}`,\n {\n level: 'error',\n }\n );\n\n followingErrors += 1;\n\n if (followingErrors >= MAX_FOLLOWING_ERRORS) {\n appLogger(`There is something wrong.`, {\n level: 'error',\n });\n process.exit(1); // 1 for error\n }\n },\n }\n )();\n };\n\n const wrapped = options?.onHandle\n ? options.onHandle(executeTranslation) // queued in global limiter\n : executeTranslation(); // no global limiter\n\n return wrapped.then((result) => ({ chunk, result }));\n });\n\n // Wait for all chunks for this locale in parallel (still capped by global limiter)\n const chunkResults = await Promise.all(chunkPromises);\n\n // Maintain order\n chunkResults\n .sort((chunkA, chunkB) => chunkA.chunk.index - chunkB.chunk.index)\n .forEach(({ result }) => {\n chunkResult.push(result);\n });\n\n // Merge partial JSON objects produced from each chunk into a single object\n const mergedContent = mergeChunks(chunkResult);\n\n const merged = {\n ...dictionaryToProcess,\n content: mergedContent,\n };\n\n // For per-locale files, merge the newly translated content with existing target content\n let finalContent = merged.content;\n\n if (!isContentStructured) {\n finalContent = (finalContent as any)\n ?.__INTLAYER_ROOT_PRIMITIVE_CONTENT__;\n }\n\n if (typeof baseUnmergedDictionary.locale === 'string') {\n // Deep merge: existing content + newly translated content\n finalContent = deepMergeContent(\n targetLocaleDictionary.content ?? {},\n finalContent\n );\n }\n\n return [targetLocale, finalContent] as const;\n })\n );\n\n const translatedContent: Partial<Record<Locale, Dictionary['content']>> =\n Object.fromEntries(translatedContentResults);\n\n const baseDictionary = baseUnmergedDictionary.locale\n ? {\n ...baseUnmergedDictionary,\n key: baseUnmergedDictionary.key!,\n content: {},\n }\n : baseUnmergedDictionary;\n\n let dictionaryOutput: Dictionary = {\n ...getMultilingualDictionary(baseDictionary),\n locale: undefined, // Ensure the dictionary is multilingual\n ...metadata,\n };\n\n for (const targetLocale of task.targetLocales) {\n if (translatedContent[targetLocale]) {\n dictionaryOutput = insertContentInDictionary(\n dictionaryOutput,\n translatedContent[targetLocale],\n targetLocale\n );\n }\n }\n\n appLogger(\n `${task.dictionaryPreset} ${colorize('Translation completed successfully', ANSIColors.GREEN)} for ${colorizePath(basename(dictionaryOutput.filePath!))}`,\n {\n level: 'info',\n }\n );\n\n if (\n baseUnmergedDictionary.locale &&\n (baseUnmergedDictionary.fill === true ||\n baseUnmergedDictionary.fill === undefined) &&\n baseUnmergedDictionary.location === 'local'\n ) {\n const dictionaryFilePath = baseUnmergedDictionary\n .filePath!.split('.')\n .slice(0, -1);\n\n const contentIndex = dictionaryFilePath[dictionaryFilePath.length - 1];\n\n return JSON.parse(\n JSON.stringify({\n ...task,\n dictionaryOutput: {\n ...dictionaryOutput,\n fill: undefined,\n filled: true,\n },\n }).replaceAll(\n new RegExp(`\\\\.${contentIndex}\\\\.[a-zA-Z0-9]+`, 'g'),\n `.filled.${contentIndex}.json`\n )\n );\n }\n\n return {\n ...task,\n dictionaryOutput,\n };\n },\n {\n maxRetry: GROUP_MAX_RETRY,\n delay: RETRY_DELAY,\n onError: ({ error, attempt, maxRetry }) =>\n appLogger(\n `${task.dictionaryPreset} ${colorize('Error:', ANSIColors.RED)} ${colorize(typeof error === 'string' ? error : JSON.stringify(error), ANSIColors.GREY_DARK)} - Attempt ${colorizeNumber(attempt + 1)} of ${colorizeNumber(maxRetry)}`,\n {\n level: 'error',\n }\n ),\n onMaxTryReached: ({ error }) =>\n appLogger(\n `${task.dictionaryPreset} ${colorize('Maximum number of retries reached:', ANSIColors.RED)} ${colorize(typeof error === 'string' ? error : JSON.stringify(error), ANSIColors.GREY_DARK)}`,\n {\n level: 'error',\n }\n ),\n }\n )();\n\n return result as TranslateDictionaryResult;\n};\n"],"mappings":"i3BAoDA,MAAM,EAAsB,GAC1B,CAAC,EAAW,aAAe,CAAC,EAAW,OAAS,CAAC,EAAW,KAKxD,EAAc,IAAO,GAG3B,IAAI,EAAkB,EAEtB,MAAa,EAAsB,MACjC,EACA,EACA,IACuC,CACvC,IAAM,EAAY,EAAa,EAAc,CACvC,EAAc,EAAoB,IAAA,GAAW,EAAc,CAE3D,CAAE,OAAM,YAAW,eAAc,WAAU,YAAa,CAC5D,KAAM,WACN,aAAc,GACd,GAAG,EACJ,CAEK,MAAsB,CAC1B,EAAkB,EAClB,GAAS,aAAa,EAqbxB,OAlbe,MAAM,EACnB,SAAY,CACV,IAAM,EAA6B,EAAwB,EAAc,CAEnE,EACJ,EAA2B,EAAK,eAAe,KAC5C,GAAS,EAAK,UAAY,EAAK,kBACjC,CAEH,GAAI,CAAC,EAOH,OANA,EACE,GAAG,EAAK,iBAAiB,+DACzB,CACE,MAAO,OACR,CACF,CACM,CAAE,GAAG,EAAM,iBAAkB,KAAM,CAG5C,IAAI,EAIJ,GACE,IACC,EAAmB,EA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D,EAG0C,CAC5C,OAAQ,IAAA,GACR,GAAG,EACJ,CAED,IAAK,IAAM,KAAgB,EAAK,cAC1B,EAAkB,KACpB,EAAmB,EACjB,EACA,EAAkB,GAClB,EACD,EAWL,GAPA,EACE,GAAG,EAAK,iBAAiB,GAAG,EAAS,qCAAsC,EAAW,MAAM,CAAC,OAAO,EAAa,EAAS,EAAiB,SAAU,CAAC,GACtJ,CACE,MAAO,OACR,CACF,CAGC,EAAuB,SACtB,EAAuB,OAAS,IAC/B,EAAuB,OAAS,IAAA,KAClC,EAAuB,WAAa,QACpC,CACA,IAAM,EAAqB,EACxB,SAAU,MAAM,IAAI,CACpB,MAAM,EAAG,GAAG,CAET,EAAe,EAAmB,EAAmB,OAAS,GAEpE,OAAO,KAAK,MACV,KAAK,UAAU,CACb,GAAG,EACH,iBAAkB,CAChB,GAAG,EACH,KAAM,IAAA,GACN,OAAQ,GACT,CACF,CAAC,CAAC,WACG,OAAO,MAAM,EAAa,iBAAkB,IAAI,CACpD,WAAW,EAAa,OACzB,CACF,CAGH,MAAO,CACL,GAAG,EACH,mBACD,EAEH,CACE,SAAU,EACV,MAAO,EACP,SAAU,CAAE,QAAO,UAAS,cAC1B,EACE,GAAG,EAAK,iBAAiB,GAAG,EAAS,SAAU,EAAW,IAAI,CAAC,GAAG,EAAS,OAAO,GAAU,SAAW,EAAQ,KAAK,UAAU,EAAM,CAAE,EAAW,UAAU,CAAC,aAAa,EAAe,EAAU,EAAE,CAAC,MAAM,EAAe,EAAS,GACnO,CACE,MAAO,QACR,CACF,CACH,iBAAkB,CAAE,WAClB,EACE,GAAG,EAAK,iBAAiB,GAAG,EAAS,qCAAsC,EAAW,IAAI,CAAC,GAAG,EAAS,OAAO,GAAU,SAAW,EAAQ,KAAK,UAAU,EAAM,CAAE,EAAW,UAAU,GACvL,CACE,MAAO,QACR,CACF,CACJ,CACF,EAAE"}
1
+ {"version":3,"file":"translateDictionary.mjs","names":[],"sources":["../../../src/fill/translateDictionary.ts"],"sourcesContent":["import { basename } from 'node:path';\nimport type { AIConfig } from '@intlayer/ai';\nimport { type AIOptions, getIntlayerAPIProxy } from '@intlayer/api';\nimport {\n chunkJSON,\n formatLocale,\n type JsonChunk,\n mergeChunks,\n reconstructFromSingleChunk,\n reduceObjectFormat,\n verifyIdenticObjectFormat,\n} from '@intlayer/chokidar/utils';\nimport {\n ANSIColors,\n colon,\n colorize,\n colorizeNumber,\n colorizePath,\n getAppLogger,\n} from '@intlayer/config/logger';\nimport { retryManager } from '@intlayer/config/utils';\nimport {\n getFilterMissingTranslationsDictionary,\n getMultilingualDictionary,\n getPerLocaleDictionary,\n insertContentInDictionary,\n} from '@intlayer/core/plugins';\nimport type { Dictionary, IntlayerConfig, Locale } from '@intlayer/types';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\nimport type { AIClient } from '../utils/setupAI';\nimport { deepMergeContent } from './deepMergeContent';\nimport { getFilterMissingContentPerLocale } from './getFilterMissingContentPerLocale';\nimport type { TranslationTask } from './listTranslationsTasks';\n\ntype TranslateDictionaryResult = TranslationTask & {\n dictionaryOutput: Dictionary | null;\n};\n\ntype TranslateDictionaryOptions = {\n mode: 'complete' | 'review';\n aiOptions?: AIOptions;\n fillMetadata?: boolean;\n onHandle?: ReturnType<\n typeof import('@intlayer/chokidar/utils').getGlobalLimiter\n >;\n onSuccess?: () => void;\n onError?: (error: unknown) => void;\n getAbortError?: () => Error | null;\n aiClient?: AIClient;\n aiConfig?: AIConfig;\n};\n\nconst hasMissingMetadata = (dictionary: Dictionary) =>\n !dictionary.description || !dictionary.title || !dictionary.tags;\n\nconst CHUNK_SIZE = 7000; // GPT-5 Mini safe input size\nconst GROUP_MAX_RETRY = 2;\nconst MAX_RETRY = 3;\nconst RETRY_DELAY = 1000 * 10; // 10 seconds\n\nconst MAX_FOLLOWING_ERRORS = 10; // 10 errors in a row, hard exit the process\nlet followingErrors = 0;\n\nexport const translateDictionary = async (\n task: TranslationTask,\n configuration: IntlayerConfig,\n options?: TranslateDictionaryOptions\n): Promise<TranslateDictionaryResult> => {\n const appLogger = getAppLogger(configuration);\n const intlayerAPI = getIntlayerAPIProxy(undefined, configuration);\n\n const { mode, aiOptions, fillMetadata, aiClient, aiConfig } = {\n mode: 'complete',\n fillMetadata: true,\n ...options,\n } as const;\n\n const notifySuccess = () => {\n followingErrors = 0;\n options?.onSuccess?.();\n };\n\n const result = await retryManager(\n async () => {\n const unmergedDictionariesRecord = getUnmergedDictionaries(configuration);\n\n const baseUnmergedDictionary: Dictionary | undefined =\n unmergedDictionariesRecord[task.dictionaryKey].find(\n (dict) => dict.localId === task.dictionaryLocalId\n );\n\n if (!baseUnmergedDictionary) {\n appLogger(\n `${task.dictionaryPreset}Dictionary not found in unmergedDictionariesRecord. Skipping.`,\n {\n level: 'warn',\n }\n );\n return { ...task, dictionaryOutput: null };\n }\n\n let metadata:\n | Pick<Dictionary, 'description' | 'title' | 'tags'>\n | undefined;\n\n if (\n fillMetadata &&\n (hasMissingMetadata(baseUnmergedDictionary) || mode === 'review')\n ) {\n const defaultLocaleDictionary = getPerLocaleDictionary(\n baseUnmergedDictionary,\n configuration.internationalization.defaultLocale\n );\n\n appLogger(\n `${task.dictionaryPreset} Filling missing metadata for ${colorizePath(basename(baseUnmergedDictionary.filePath!))}`,\n {\n level: 'info',\n }\n );\n\n const runAudit = async () => {\n if (aiClient && aiConfig) {\n const result = await aiClient.auditDictionaryMetadata({\n fileContent: JSON.stringify(defaultLocaleDictionary),\n aiConfig,\n });\n\n return {\n data: result,\n };\n }\n\n return await intlayerAPI.ai.auditContentDeclarationMetadata({\n fileContent: JSON.stringify(defaultLocaleDictionary),\n aiOptions,\n });\n };\n\n const metadataResult = options?.onHandle\n ? await options.onHandle(runAudit)\n : await runAudit();\n\n metadata = metadataResult.data?.fileContent;\n }\n\n const translatedContentResults = await Promise.all(\n task.targetLocales.map(async (targetLocale) => {\n /**\n * In complete mode, for large dictionaries, we want to filter all content that is already translated\n *\n * targetLocale: fr\n *\n * { test1: t({ ar: 'Hello', en: 'Hello', fr: 'Bonjour' } }) -> {}\n * { test2: t({ ar: 'Hello', en: 'Hello' }) } -> { test2: t({ ar: 'Hello', en: 'Hello' }) }\n *\n */\n // Reset to base dictionary for each locale to ensure we filter from the original\n let dictionaryToProcess = structuredClone(baseUnmergedDictionary);\n\n let targetLocaleDictionary: Dictionary;\n\n if (typeof baseUnmergedDictionary.locale === 'string') {\n // For per-locale files, the content is already in simple JSON format (not translation nodes)\n // The base dictionary is already the source locale content\n\n // Load the existing target locale dictionary\n const targetLocaleFilePath =\n baseUnmergedDictionary.filePath?.replace(\n new RegExp(`/${task.sourceLocale}/`, 'g'),\n `/${targetLocale}/`\n );\n\n // Find the target locale dictionary in unmerged dictionaries\n const targetUnmergedDictionary = targetLocaleFilePath\n ? unmergedDictionariesRecord[task.dictionaryKey]?.find(\n (dict) =>\n dict.filePath === targetLocaleFilePath &&\n dict.locale === targetLocale\n )\n : undefined;\n\n targetLocaleDictionary = targetUnmergedDictionary ?? {\n key: baseUnmergedDictionary.key,\n content: {},\n filePath: targetLocaleFilePath,\n locale: targetLocale,\n };\n\n // In complete mode, filter out already translated content\n if (mode === 'complete') {\n dictionaryToProcess = getFilterMissingContentPerLocale(\n dictionaryToProcess,\n targetUnmergedDictionary\n );\n }\n } else {\n // For multilingual dictionaries\n if (mode === 'complete') {\n // Remove all nodes that don't have any content to translate\n dictionaryToProcess = getFilterMissingTranslationsDictionary(\n dictionaryToProcess,\n targetLocale\n );\n }\n\n dictionaryToProcess = getPerLocaleDictionary(\n dictionaryToProcess,\n task.sourceLocale\n );\n\n targetLocaleDictionary = getPerLocaleDictionary(\n baseUnmergedDictionary,\n targetLocale\n );\n }\n\n const localePreset = colon(\n [\n colorize('[', ANSIColors.GREY_DARK),\n formatLocale(targetLocale),\n colorize(']', ANSIColors.GREY_DARK),\n ].join(''),\n { colSize: 18 }\n );\n\n const createChunkPreset = (\n chunkIndex: number,\n totalChunks: number\n ) => {\n if (totalChunks <= 1) return '';\n return colon(\n [\n colorize('[', ANSIColors.GREY_DARK),\n colorizeNumber(chunkIndex + 1),\n colorize(`/${totalChunks}`, ANSIColors.GREY_DARK),\n colorize(']', ANSIColors.GREY_DARK),\n ].join(''),\n { colSize: 5 }\n );\n };\n\n appLogger(\n `${task.dictionaryPreset}${localePreset} Preparing ${colorizePath(basename(targetLocaleDictionary.filePath!))}`,\n {\n level: 'info',\n }\n );\n\n const isContentStructured =\n (typeof dictionaryToProcess.content === 'object' &&\n dictionaryToProcess.content !== null) ||\n Array.isArray(dictionaryToProcess.content);\n\n const contentToProcess = isContentStructured\n ? dictionaryToProcess.content\n : {\n __INTLAYER_ROOT_PRIMITIVE_CONTENT__:\n dictionaryToProcess.content,\n };\n\n const chunkedJsonContent: JsonChunk[] = chunkJSON(\n contentToProcess as unknown as Record<string, any>,\n CHUNK_SIZE\n );\n\n const nbOfChunks = chunkedJsonContent.length;\n\n if (nbOfChunks > 1) {\n appLogger(\n `${task.dictionaryPreset}${localePreset} Split into ${colorizeNumber(nbOfChunks)} chunks for translation`,\n {\n level: 'info',\n }\n );\n }\n\n const chunkResult: JsonChunk[] = [];\n\n // Process chunks in parallel (globally throttled) to allow concurrent translation\n const chunkPromises = chunkedJsonContent.map((chunk) => {\n const chunkPreset = createChunkPreset(chunk.index, chunk.total);\n\n if (nbOfChunks > 1) {\n appLogger(\n `${task.dictionaryPreset}${localePreset}${chunkPreset} Translating chunk`,\n {\n level: 'info',\n }\n );\n }\n\n // Reconstruct partial JSON content from this chunk's patches\n const chunkContent = reconstructFromSingleChunk(chunk);\n const presetOutputContent = reduceObjectFormat(\n isContentStructured\n ? targetLocaleDictionary.content\n : {\n __INTLAYER_ROOT_PRIMITIVE_CONTENT__:\n targetLocaleDictionary.content,\n },\n chunkContent\n ) as unknown as JSON;\n\n const executeTranslation = async () => {\n return await retryManager(\n async () => {\n let translationResult: any;\n\n if (aiClient && aiConfig) {\n translationResult = await aiClient.translateJSON({\n entryFileContent: chunkContent as unknown as JSON,\n presetOutputContent,\n dictionaryDescription:\n dictionaryToProcess.description ??\n metadata?.description ??\n '',\n entryLocale: task.sourceLocale,\n outputLocale: targetLocale,\n mode,\n aiConfig,\n });\n } else {\n translationResult = await intlayerAPI.ai\n .translateJSON({\n entryFileContent: chunkContent as unknown as JSON,\n presetOutputContent,\n dictionaryDescription:\n dictionaryToProcess.description ??\n metadata?.description ??\n '',\n entryLocale: task.sourceLocale,\n outputLocale: targetLocale,\n mode,\n aiOptions,\n })\n .then((result) => result.data);\n }\n\n if (!translationResult?.fileContent) {\n throw new Error('No content result');\n }\n\n const { isIdentic } = verifyIdenticObjectFormat(\n translationResult.fileContent,\n chunkContent\n );\n\n if (!isIdentic) {\n throw new Error(\n 'Translation result does not match expected format'\n );\n }\n\n notifySuccess();\n return translationResult.fileContent;\n },\n {\n maxRetry: MAX_RETRY,\n delay: RETRY_DELAY,\n onError: ({ error, attempt, maxRetry }) => {\n const chunkPreset = createChunkPreset(\n chunk.index,\n chunk.total\n );\n appLogger(\n `${task.dictionaryPreset}${localePreset}${chunkPreset} ${colorize('Error filling:', ANSIColors.RED)} ${colorize(typeof error === 'string' ? error : JSON.stringify(error), ANSIColors.GREY_DARK)} - Attempt ${colorizeNumber(attempt + 1)} of ${colorizeNumber(maxRetry)}`,\n {\n level: 'error',\n }\n );\n\n followingErrors += 1;\n\n if (followingErrors >= MAX_FOLLOWING_ERRORS) {\n appLogger(`There is something wrong.`, {\n level: 'error',\n });\n process.exit(1); // 1 for error\n }\n },\n }\n )();\n };\n\n const wrapped = options?.onHandle\n ? options.onHandle(executeTranslation) // queued in global limiter\n : executeTranslation(); // no global limiter\n\n return wrapped.then((result) => ({ chunk, result }));\n });\n\n // Wait for all chunks for this locale in parallel (still capped by global limiter)\n const chunkResults = await Promise.all(chunkPromises);\n\n // Maintain order\n chunkResults\n .sort((chunkA, chunkB) => chunkA.chunk.index - chunkB.chunk.index)\n .forEach(({ result }) => {\n chunkResult.push(result);\n });\n\n // Merge partial JSON objects produced from each chunk into a single object\n const mergedContent = mergeChunks(chunkResult);\n\n const merged = {\n ...dictionaryToProcess,\n content: mergedContent,\n };\n\n // For per-locale files, merge the newly translated content with existing target content\n let finalContent = merged.content;\n\n if (!isContentStructured) {\n finalContent = (finalContent as any)\n ?.__INTLAYER_ROOT_PRIMITIVE_CONTENT__;\n }\n\n if (typeof baseUnmergedDictionary.locale === 'string') {\n // Deep merge: existing content + newly translated content\n finalContent = deepMergeContent(\n targetLocaleDictionary.content ?? {},\n finalContent\n );\n }\n\n return [targetLocale, finalContent] as const;\n })\n );\n\n const translatedContent: Partial<Record<Locale, Dictionary['content']>> =\n Object.fromEntries(translatedContentResults);\n\n const baseDictionary = baseUnmergedDictionary.locale\n ? {\n ...baseUnmergedDictionary,\n key: baseUnmergedDictionary.key!,\n content: {},\n }\n : baseUnmergedDictionary;\n\n let dictionaryOutput: Dictionary = {\n ...getMultilingualDictionary(baseDictionary),\n locale: undefined, // Ensure the dictionary is multilingual\n ...metadata,\n };\n\n for (const targetLocale of task.targetLocales) {\n if (translatedContent[targetLocale]) {\n dictionaryOutput = insertContentInDictionary(\n dictionaryOutput,\n translatedContent[targetLocale],\n targetLocale\n );\n }\n }\n\n appLogger(\n `${task.dictionaryPreset} ${colorize('Translation completed successfully', ANSIColors.GREEN)} for ${colorizePath(basename(dictionaryOutput.filePath!))}`,\n {\n level: 'info',\n }\n );\n\n if (\n baseUnmergedDictionary.locale &&\n (baseUnmergedDictionary.fill === true ||\n baseUnmergedDictionary.fill === undefined) &&\n baseUnmergedDictionary.location === 'local'\n ) {\n const dictionaryFilePath = baseUnmergedDictionary\n .filePath!.split('.')\n .slice(0, -1);\n\n const contentIndex = dictionaryFilePath[dictionaryFilePath.length - 1];\n\n return JSON.parse(\n JSON.stringify({\n ...task,\n dictionaryOutput: {\n ...dictionaryOutput,\n fill: undefined,\n filled: true,\n },\n }).replaceAll(\n new RegExp(`\\\\.${contentIndex}\\\\.[a-zA-Z0-9]+`, 'g'),\n `.filled.${contentIndex}.json`\n )\n );\n }\n\n return {\n ...task,\n dictionaryOutput,\n };\n },\n {\n maxRetry: GROUP_MAX_RETRY,\n delay: RETRY_DELAY,\n onError: ({ error, attempt, maxRetry }) =>\n appLogger(\n `${task.dictionaryPreset} ${colorize('Error:', ANSIColors.RED)} ${colorize(typeof error === 'string' ? error : JSON.stringify(error), ANSIColors.GREY_DARK)} - Attempt ${colorizeNumber(attempt + 1)} of ${colorizeNumber(maxRetry)}`,\n {\n level: 'error',\n }\n ),\n onMaxTryReached: ({ error }) =>\n appLogger(\n `${task.dictionaryPreset} ${colorize('Maximum number of retries reached:', ANSIColors.RED)} ${colorize(typeof error === 'string' ? error : JSON.stringify(error), ANSIColors.GREY_DARK)}`,\n {\n level: 'error',\n }\n ),\n }\n )();\n\n return result as TranslateDictionaryResult;\n};\n"],"mappings":"k1BAoDA,MAAM,EAAsB,GAC1B,CAAC,EAAW,aAAe,CAAC,EAAW,OAAS,CAAC,EAAW,KAKxD,EAAc,IAAO,GAG3B,IAAI,EAAkB,EAEtB,MAAa,EAAsB,MACjC,EACA,EACA,IACuC,CACvC,IAAM,EAAY,EAAa,EAAc,CACvC,EAAc,EAAoB,IAAA,GAAW,EAAc,CAE3D,CAAE,OAAM,YAAW,eAAc,WAAU,YAAa,CAC5D,KAAM,WACN,aAAc,GACd,GAAG,EACJ,CAEK,MAAsB,CAC1B,EAAkB,EAClB,GAAS,aAAa,EAqbxB,OAlbe,MAAM,EACnB,SAAY,CACV,IAAM,EAA6B,EAAwB,EAAc,CAEnE,EACJ,EAA2B,EAAK,eAAe,KAC5C,GAAS,EAAK,UAAY,EAAK,kBACjC,CAEH,GAAI,CAAC,EAOH,OANA,EACE,GAAG,EAAK,iBAAiB,+DACzB,CACE,MAAO,OACR,CACF,CACM,CAAE,GAAG,EAAM,iBAAkB,KAAM,CAG5C,IAAI,EAIJ,GACE,IACC,EAAmB,EAAuB,EAAI,IAAS,UACxD,CACA,IAAM,EAA0B,EAC9B,EACA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IAAK,IAAM,KAAgB,EAAK,cAC1B,EAAkB,KACpB,EAAmB,EACjB,EACA,EAAkB,GAClB,EACD,EAWL,GAPA,EACE,GAAG,EAAK,iBAAiB,GAAG,EAAS,qCAAsC,EAAW,MAAM,CAAC,OAAO,EAAa,EAAS,EAAiB,SAAU,CAAC,GACtJ,CACE,MAAO,OACR,CACF,CAGC,EAAuB,SACtB,EAAuB,OAAS,IAC/B,EAAuB,OAAS,IAAA,KAClC,EAAuB,WAAa,QACpC,CACA,IAAM,EAAqB,EACxB,SAAU,MAAM,IAAI,CACpB,MAAM,EAAG,GAAG,CAET,EAAe,EAAmB,EAAmB,OAAS,GAEpE,OAAO,KAAK,MACV,KAAK,UAAU,CACb,GAAG,EACH,iBAAkB,CAChB,GAAG,EACH,KAAM,IAAA,GACN,OAAQ,GACT,CACF,CAAC,CAAC,WACG,OAAO,MAAM,EAAa,iBAAkB,IAAI,CACpD,WAAW,EAAa,OACzB,CACF,CAGH,MAAO,CACL,GAAG,EACH,mBACD,EAEH,CACE,SAAU,EACV,MAAO,EACP,SAAU,CAAE,QAAO,UAAS,cAC1B,EACE,GAAG,EAAK,iBAAiB,GAAG,EAAS,SAAU,EAAW,IAAI,CAAC,GAAG,EAAS,OAAO,GAAU,SAAW,EAAQ,KAAK,UAAU,EAAM,CAAE,EAAW,UAAU,CAAC,aAAa,EAAe,EAAU,EAAE,CAAC,MAAM,EAAe,EAAS,GACnO,CACE,MAAO,QACR,CACF,CACH,iBAAkB,CAAE,WAClB,EACE,GAAG,EAAK,iBAAiB,GAAG,EAAS,qCAAsC,EAAW,IAAI,CAAC,GAAG,EAAS,OAAO,GAAU,SAAW,EAAQ,KAAK,UAAU,EAAM,CAAE,EAAW,UAAU,GACvL,CACE,MAAO,QACR,CACF,CACJ,CACF,EAAE"}
@@ -11,6 +11,7 @@ type ConfigurationOptions = {
11
11
  env?: string;
12
12
  envFile?: string;
13
13
  noCache?: boolean;
14
+ checkTypes?: boolean;
14
15
  } & LogOptions;
15
16
  /**
16
17
  * Set the API for the CLI
@@ -1 +1 @@
1
- {"version":3,"file":"cli.d.ts","names":[],"sources":["../../src/cli.ts"],"mappings":";;;cAuCa,OAAA;AAAA,KA2IR,UAAA;EACH,MAAA;EACA,OAAA;AAAA;AAAA,KAGU,oBAAA;EACV,OAAA;EACA,GAAA;EACA,OAAA;EACA,OAAA;AAAA,IACE,UAAA;;AALJ;;;;;;;cAiEa,MAAA,QAAa,OAAA"}
1
+ {"version":3,"file":"cli.d.ts","names":[],"sources":["../../src/cli.ts"],"mappings":";;;cAwCa,OAAA;AAAA,KA2IR,UAAA;EACH,MAAA;EACA,OAAA;AAAA;AAAA,KAGU,oBAAA;EACV,OAAA;EACA,GAAA;EACA,OAAA;EACA,OAAA;EACA,UAAA;AAAA,IACE,UAAA;AANJ;;;;;;;;AAAA,cA2Ea,MAAA,QAAa,OAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intlayer/cli",
3
- "version": "8.1.3",
3
+ "version": "8.1.5",
4
4
  "private": false,
5
5
  "description": "Provides uniform command-line interface scripts for Intlayer, used in packages like intlayer-cli and intlayer.",
6
6
  "keywords": [
@@ -68,22 +68,22 @@
68
68
  },
69
69
  "dependencies": {
70
70
  "@clack/prompts": "0.11.0",
71
- "@intlayer/ai": "8.1.3",
72
- "@intlayer/api": "8.1.3",
73
- "@intlayer/chokidar": "8.1.3",
74
- "@intlayer/config": "8.1.3",
75
- "@intlayer/core": "8.1.3",
76
- "@intlayer/dictionaries-entry": "8.1.3",
77
- "@intlayer/remote-dictionaries-entry": "8.1.3",
78
- "@intlayer/types": "8.1.3",
79
- "@intlayer/unmerged-dictionaries-entry": "8.1.3",
71
+ "@intlayer/ai": "8.1.5",
72
+ "@intlayer/api": "8.1.5",
73
+ "@intlayer/chokidar": "8.1.5",
74
+ "@intlayer/config": "8.1.4",
75
+ "@intlayer/core": "8.1.4",
76
+ "@intlayer/dictionaries-entry": "8.1.5",
77
+ "@intlayer/remote-dictionaries-entry": "8.1.5",
78
+ "@intlayer/types": "8.1.4",
79
+ "@intlayer/unmerged-dictionaries-entry": "8.1.4",
80
80
  "commander": "14.0.3",
81
81
  "enquirer": "^2.4.1",
82
82
  "eventsource": "4.1.0",
83
83
  "fast-glob": "3.3.3"
84
84
  },
85
85
  "devDependencies": {
86
- "@types/node": "25.2.3",
86
+ "@types/node": "25.3.0",
87
87
  "@utils/ts-config": "1.0.4",
88
88
  "@utils/ts-config-types": "1.0.4",
89
89
  "@utils/tsdown-config": "1.0.4",
@@ -93,7 +93,7 @@
93
93
  "vitest": "4.0.18"
94
94
  },
95
95
  "peerDependencies": {
96
- "@intlayer/ai": "8.1.3"
96
+ "@intlayer/ai": "8.1.5"
97
97
  },
98
98
  "peerDependenciesMeta": {
99
99
  "@intlayer/ai": {
@@ -1,2 +0,0 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=e=>{if(e.length===0)return{};let n=e[0];for(let r=1;r<e.length;r++)n=t(n,e[r]);return n},t=(e,n)=>{if(e==null)return n;if(n==null)return e;if(Array.isArray(e)&&Array.isArray(n)){let r=Math.max(e.length,n.length),i=[];for(let a=0;a<r;a++)i[a]=t(e[a],n[a]);return i}if(typeof e==`object`&&typeof n==`object`){let r={...e};for(let e of Object.keys(n))r[e]=t(r[e],n[e]);return r}return e};exports.mergeChunks=e;
2
- //# sourceMappingURL=mergeChunks.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mergeChunks.cjs","names":[],"sources":["../../../src/fill/mergeChunks.ts"],"sourcesContent":["export const mergeChunks = (chunks: any[]): any => {\n if (chunks.length === 0) return {};\n\n let result = chunks[0];\n\n for (let i = 1; i < chunks.length; i++) {\n result = customChunkMerge(result, chunks[i]);\n }\n\n return result;\n};\n\nconst customChunkMerge = (dest: any, source: any): any => {\n if (dest === undefined || dest === null) return source;\n if (source === undefined || source === null) return dest;\n\n if (Array.isArray(dest) && Array.isArray(source)) {\n const maxLength = Math.max(dest.length, source.length);\n const result = [];\n for (let i = 0; i < maxLength; i++) {\n result[i] = customChunkMerge(dest[i], source[i]);\n }\n return result;\n }\n\n if (typeof dest === 'object' && typeof source === 'object') {\n const result: any = { ...dest };\n for (const key of Object.keys(source)) {\n result[key] = customChunkMerge(result[key], source[key]);\n }\n return result;\n }\n\n // Primitives: if we are here, both are not null.\n // Since chunks shouldn't overlap, we can return dest.\n return dest;\n};\n"],"mappings":"mEAAA,MAAa,EAAe,GAAuB,CACjD,GAAI,EAAO,SAAW,EAAG,MAAO,EAAE,CAElC,IAAI,EAAS,EAAO,GAEpB,IAAK,IAAI,EAAI,EAAG,EAAI,EAAO,OAAQ,IACjC,EAAS,EAAiB,EAAQ,EAAO,GAAG,CAG9C,OAAO,GAGH,GAAoB,EAAW,IAAqB,CACxD,GAAI,GAA+B,KAAM,OAAO,EAChD,GAAI,GAAmC,KAAM,OAAO,EAEpD,GAAI,MAAM,QAAQ,EAAK,EAAI,MAAM,QAAQ,EAAO,CAAE,CAChD,IAAM,EAAY,KAAK,IAAI,EAAK,OAAQ,EAAO,OAAO,CAChD,EAAS,EAAE,CACjB,IAAK,IAAI,EAAI,EAAG,EAAI,EAAW,IAC7B,EAAO,GAAK,EAAiB,EAAK,GAAI,EAAO,GAAG,CAElD,OAAO,EAGT,GAAI,OAAO,GAAS,UAAY,OAAO,GAAW,SAAU,CAC1D,IAAM,EAAc,CAAE,GAAG,EAAM,CAC/B,IAAK,IAAM,KAAO,OAAO,KAAK,EAAO,CACnC,EAAO,GAAO,EAAiB,EAAO,GAAM,EAAO,GAAK,CAE1D,OAAO,EAKT,OAAO"}
@@ -1,2 +0,0 @@
1
- const e=e=>{if(e.length===0)return{};let n=e[0];for(let r=1;r<e.length;r++)n=t(n,e[r]);return n},t=(e,n)=>{if(e==null)return n;if(n==null)return e;if(Array.isArray(e)&&Array.isArray(n)){let r=Math.max(e.length,n.length),i=[];for(let a=0;a<r;a++)i[a]=t(e[a],n[a]);return i}if(typeof e==`object`&&typeof n==`object`){let r={...e};for(let e of Object.keys(n))r[e]=t(r[e],n[e]);return r}return e};export{e as mergeChunks};
2
- //# sourceMappingURL=mergeChunks.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mergeChunks.mjs","names":[],"sources":["../../../src/fill/mergeChunks.ts"],"sourcesContent":["export const mergeChunks = (chunks: any[]): any => {\n if (chunks.length === 0) return {};\n\n let result = chunks[0];\n\n for (let i = 1; i < chunks.length; i++) {\n result = customChunkMerge(result, chunks[i]);\n }\n\n return result;\n};\n\nconst customChunkMerge = (dest: any, source: any): any => {\n if (dest === undefined || dest === null) return source;\n if (source === undefined || source === null) return dest;\n\n if (Array.isArray(dest) && Array.isArray(source)) {\n const maxLength = Math.max(dest.length, source.length);\n const result = [];\n for (let i = 0; i < maxLength; i++) {\n result[i] = customChunkMerge(dest[i], source[i]);\n }\n return result;\n }\n\n if (typeof dest === 'object' && typeof source === 'object') {\n const result: any = { ...dest };\n for (const key of Object.keys(source)) {\n result[key] = customChunkMerge(result[key], source[key]);\n }\n return result;\n }\n\n // Primitives: if we are here, both are not null.\n // Since chunks shouldn't overlap, we can return dest.\n return dest;\n};\n"],"mappings":"AAAA,MAAa,EAAe,GAAuB,CACjD,GAAI,EAAO,SAAW,EAAG,MAAO,EAAE,CAElC,IAAI,EAAS,EAAO,GAEpB,IAAK,IAAI,EAAI,EAAG,EAAI,EAAO,OAAQ,IACjC,EAAS,EAAiB,EAAQ,EAAO,GAAG,CAG9C,OAAO,GAGH,GAAoB,EAAW,IAAqB,CACxD,GAAI,GAA+B,KAAM,OAAO,EAChD,GAAI,GAAmC,KAAM,OAAO,EAEpD,GAAI,MAAM,QAAQ,EAAK,EAAI,MAAM,QAAQ,EAAO,CAAE,CAChD,IAAM,EAAY,KAAK,IAAI,EAAK,OAAQ,EAAO,OAAO,CAChD,EAAS,EAAE,CACjB,IAAK,IAAI,EAAI,EAAG,EAAI,EAAW,IAC7B,EAAO,GAAK,EAAiB,EAAK,GAAI,EAAO,GAAG,CAElD,OAAO,EAGT,GAAI,OAAO,GAAS,UAAY,OAAO,GAAW,SAAU,CAC1D,IAAM,EAAc,CAAE,GAAG,EAAM,CAC/B,IAAK,IAAM,KAAO,OAAO,KAAK,EAAO,CACnC,EAAO,GAAO,EAAiB,EAAO,GAAM,EAAO,GAAK,CAE1D,OAAO,EAKT,OAAO"}
@@ -1,5 +0,0 @@
1
- //#region src/fill/mergeChunks.d.ts
2
- declare const mergeChunks: (chunks: any[]) => any;
3
- //#endregion
4
- export { mergeChunks };
5
- //# sourceMappingURL=mergeChunks.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mergeChunks.d.ts","names":[],"sources":["../../../src/fill/mergeChunks.ts"],"mappings":";cAAa,WAAA,GAAe,MAAA"}