@intlayer/cli 6.1.6 → 7.0.0-canary.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (287) hide show
  1. package/dist/cjs/IntlayerEventListener.cjs +187 -239
  2. package/dist/cjs/IntlayerEventListener.cjs.map +1 -1
  3. package/dist/cjs/_virtual/_utils_asset.cjs +104 -0
  4. package/dist/cjs/_virtual/rolldown_runtime.cjs +25 -0
  5. package/dist/cjs/build.cjs +23 -42
  6. package/dist/cjs/build.cjs.map +1 -1
  7. package/dist/cjs/cli.cjs +370 -431
  8. package/dist/cjs/cli.cjs.map +1 -1
  9. package/dist/cjs/config.cjs +10 -35
  10. package/dist/cjs/config.cjs.map +1 -1
  11. package/dist/cjs/editor.cjs +51 -66
  12. package/dist/cjs/editor.cjs.map +1 -1
  13. package/dist/cjs/fill/fill.cjs +73 -301
  14. package/dist/cjs/fill/fill.cjs.map +1 -1
  15. package/dist/cjs/fill/formatAutoFillData.cjs +48 -106
  16. package/dist/cjs/fill/formatAutoFillData.cjs.map +1 -1
  17. package/dist/cjs/fill/formatAutoFilledFilePath.cjs +27 -43
  18. package/dist/cjs/fill/formatAutoFilledFilePath.cjs.map +1 -1
  19. package/dist/cjs/fill/formatFillData.cjs +50 -0
  20. package/dist/cjs/fill/formatFillData.cjs.map +1 -0
  21. package/dist/cjs/fill/groupLimiter.cjs +42 -0
  22. package/dist/cjs/fill/groupLimiter.cjs.map +1 -0
  23. package/dist/cjs/fill/index.cjs +5 -25
  24. package/dist/cjs/fill/listTranslationsTasks.cjs +77 -0
  25. package/dist/cjs/fill/listTranslationsTasks.cjs.map +1 -0
  26. package/dist/cjs/fill/test-original-case.cjs +10 -0
  27. package/dist/cjs/fill/test-original-case.cjs.map +1 -0
  28. package/dist/cjs/fill/translateDictionary.cjs +148 -0
  29. package/dist/cjs/fill/translateDictionary.cjs.map +1 -0
  30. package/dist/cjs/fill/writeAutoFill.cjs +48 -0
  31. package/dist/cjs/fill/writeAutoFill.cjs.map +1 -0
  32. package/dist/cjs/fill/writeFill.cjs +50 -0
  33. package/dist/cjs/fill/writeFill.cjs.map +1 -0
  34. package/dist/cjs/getTargetDictionary.cjs +36 -76
  35. package/dist/cjs/getTargetDictionary.cjs.map +1 -1
  36. package/dist/cjs/index.cjs +31 -45
  37. package/dist/cjs/listContentDeclaration.cjs +36 -64
  38. package/dist/cjs/listContentDeclaration.cjs.map +1 -1
  39. package/dist/cjs/liveSync.cjs +146 -221
  40. package/dist/cjs/liveSync.cjs.map +1 -1
  41. package/dist/cjs/pull.cjs +132 -195
  42. package/dist/cjs/pull.cjs.map +1 -1
  43. package/dist/cjs/push/pullLog.cjs +101 -144
  44. package/dist/cjs/push/pullLog.cjs.map +1 -1
  45. package/dist/cjs/push/push.cjs +159 -249
  46. package/dist/cjs/push/push.cjs.map +1 -1
  47. package/dist/cjs/pushConfig.cjs +18 -45
  48. package/dist/cjs/pushConfig.cjs.map +1 -1
  49. package/dist/cjs/pushLog.cjs +87 -128
  50. package/dist/cjs/pushLog.cjs.map +1 -1
  51. package/dist/cjs/reviewDoc.cjs +183 -291
  52. package/dist/cjs/reviewDoc.cjs.map +1 -1
  53. package/dist/cjs/test/index.cjs +52 -91
  54. package/dist/cjs/test/index.cjs.map +1 -1
  55. package/dist/cjs/test/listMissingTranslations.cjs +35 -62
  56. package/dist/cjs/test/listMissingTranslations.cjs.map +1 -1
  57. package/dist/cjs/translateDoc.cjs +127 -221
  58. package/dist/cjs/translateDoc.cjs.map +1 -1
  59. package/dist/cjs/utils/calculateChunks.cjs +85 -115
  60. package/dist/cjs/utils/calculateChunks.cjs.map +1 -1
  61. package/dist/cjs/utils/checkAccess.cjs +33 -72
  62. package/dist/cjs/utils/checkAccess.cjs.map +1 -1
  63. package/dist/cjs/utils/checkFileModifiedRange.cjs +75 -91
  64. package/dist/cjs/utils/checkFileModifiedRange.cjs.map +1 -1
  65. package/dist/cjs/utils/checkLastUpdateTime.cjs +17 -30
  66. package/dist/cjs/utils/checkLastUpdateTime.cjs.map +1 -1
  67. package/dist/cjs/utils/chunkInference.cjs +28 -47
  68. package/dist/cjs/utils/chunkInference.cjs.map +1 -1
  69. package/dist/cjs/utils/fixChunkStartEndChars.cjs +23 -42
  70. package/dist/cjs/utils/fixChunkStartEndChars.cjs.map +1 -1
  71. package/dist/cjs/utils/formatTimeDiff.cjs +17 -43
  72. package/dist/cjs/utils/formatTimeDiff.cjs.map +1 -1
  73. package/dist/cjs/utils/getIsFileUpdatedRecently.cjs +13 -32
  74. package/dist/cjs/utils/getIsFileUpdatedRecently.cjs.map +1 -1
  75. package/dist/cjs/utils/getOutputFilePath.cjs +71 -86
  76. package/dist/cjs/utils/getOutputFilePath.cjs.map +1 -1
  77. package/dist/cjs/utils/getParentPackageJSON.cjs +19 -44
  78. package/dist/cjs/utils/getParentPackageJSON.cjs.map +1 -1
  79. package/dist/cjs/utils/listSpecialChars.cjs +49 -73
  80. package/dist/cjs/utils/listSpecialChars.cjs.map +1 -1
  81. package/dist/cjs/utils/mapChunksBetweenFiles.cjs +90 -132
  82. package/dist/cjs/utils/mapChunksBetweenFiles.cjs.map +1 -1
  83. package/dist/cjs/utils/reorderParagraphs.cjs +86 -118
  84. package/dist/cjs/utils/reorderParagraphs.cjs.map +1 -1
  85. package/dist/cjs/watch.cjs +21 -39
  86. package/dist/cjs/watch.cjs.map +1 -1
  87. package/dist/esm/IntlayerEventListener.mjs +178 -201
  88. package/dist/esm/IntlayerEventListener.mjs.map +1 -1
  89. package/dist/esm/_virtual/_utils_asset.mjs +100 -0
  90. package/dist/esm/_virtual/rolldown_runtime.mjs +8 -0
  91. package/dist/esm/build.mjs +20 -23
  92. package/dist/esm/build.mjs.map +1 -1
  93. package/dist/esm/cli.mjs +349 -380
  94. package/dist/esm/cli.mjs.map +1 -1
  95. package/dist/esm/config.mjs +8 -14
  96. package/dist/esm/config.mjs.map +1 -1
  97. package/dist/esm/editor.mjs +47 -41
  98. package/dist/esm/editor.mjs.map +1 -1
  99. package/dist/esm/fill/fill.mjs +68 -300
  100. package/dist/esm/fill/fill.mjs.map +1 -1
  101. package/dist/esm/fill/formatAutoFillData.mjs +47 -81
  102. package/dist/esm/fill/formatAutoFillData.mjs.map +1 -1
  103. package/dist/esm/fill/formatAutoFilledFilePath.mjs +25 -19
  104. package/dist/esm/fill/formatAutoFilledFilePath.mjs.map +1 -1
  105. package/dist/esm/fill/formatFillData.mjs +50 -0
  106. package/dist/esm/fill/formatFillData.mjs.map +1 -0
  107. package/dist/esm/fill/groupLimiter.mjs +40 -0
  108. package/dist/esm/fill/groupLimiter.mjs.map +1 -0
  109. package/dist/esm/fill/index.mjs +4 -3
  110. package/dist/esm/fill/listTranslationsTasks.mjs +70 -0
  111. package/dist/esm/fill/listTranslationsTasks.mjs.map +1 -0
  112. package/dist/esm/fill/test-original-case.mjs +10 -0
  113. package/dist/esm/fill/test-original-case.mjs.map +1 -0
  114. package/dist/esm/fill/translateDictionary.mjs +141 -0
  115. package/dist/esm/fill/translateDictionary.mjs.map +1 -0
  116. package/dist/esm/fill/writeAutoFill.mjs +44 -0
  117. package/dist/esm/fill/writeAutoFill.mjs.map +1 -0
  118. package/dist/esm/fill/writeFill.mjs +45 -0
  119. package/dist/esm/fill/writeFill.mjs.map +1 -0
  120. package/dist/esm/getTargetDictionary.mjs +27 -48
  121. package/dist/esm/getTargetDictionary.mjs.map +1 -1
  122. package/dist/esm/index.mjs +15 -13
  123. package/dist/esm/listContentDeclaration.mjs +28 -43
  124. package/dist/esm/listContentDeclaration.mjs.map +1 -1
  125. package/dist/esm/liveSync.mjs +135 -187
  126. package/dist/esm/liveSync.mjs.map +1 -1
  127. package/dist/esm/pull.mjs +125 -178
  128. package/dist/esm/pull.mjs.map +1 -1
  129. package/dist/esm/push/pullLog.mjs +99 -125
  130. package/dist/esm/push/pullLog.mjs.map +1 -1
  131. package/dist/esm/push/push.mjs +149 -221
  132. package/dist/esm/push/push.mjs.map +1 -1
  133. package/dist/esm/pushConfig.mjs +14 -23
  134. package/dist/esm/pushConfig.mjs.map +1 -1
  135. package/dist/esm/pushLog.mjs +85 -109
  136. package/dist/esm/pushLog.mjs.map +1 -1
  137. package/dist/esm/reviewDoc.mjs +167 -264
  138. package/dist/esm/reviewDoc.mjs.map +1 -1
  139. package/dist/esm/test/index.mjs +47 -73
  140. package/dist/esm/test/index.mjs.map +1 -1
  141. package/dist/esm/test/listMissingTranslations.mjs +30 -41
  142. package/dist/esm/test/listMissingTranslations.mjs.map +1 -1
  143. package/dist/esm/translateDoc.mjs +114 -193
  144. package/dist/esm/translateDoc.mjs.map +1 -1
  145. package/dist/esm/utils/calculateChunks.mjs +83 -91
  146. package/dist/esm/utils/calculateChunks.mjs.map +1 -1
  147. package/dist/esm/utils/checkAccess.mjs +28 -46
  148. package/dist/esm/utils/checkAccess.mjs.map +1 -1
  149. package/dist/esm/utils/checkFileModifiedRange.mjs +73 -65
  150. package/dist/esm/utils/checkFileModifiedRange.mjs.map +1 -1
  151. package/dist/esm/utils/checkLastUpdateTime.mjs +15 -6
  152. package/dist/esm/utils/checkLastUpdateTime.mjs.map +1 -1
  153. package/dist/esm/utils/chunkInference.mjs +24 -24
  154. package/dist/esm/utils/chunkInference.mjs.map +1 -1
  155. package/dist/esm/utils/fixChunkStartEndChars.mjs +22 -18
  156. package/dist/esm/utils/fixChunkStartEndChars.mjs.map +1 -1
  157. package/dist/esm/utils/formatTimeDiff.mjs +16 -19
  158. package/dist/esm/utils/formatTimeDiff.mjs.map +1 -1
  159. package/dist/esm/utils/getIsFileUpdatedRecently.mjs +11 -8
  160. package/dist/esm/utils/getIsFileUpdatedRecently.mjs.map +1 -1
  161. package/dist/esm/utils/getOutputFilePath.mjs +70 -62
  162. package/dist/esm/utils/getOutputFilePath.mjs.map +1 -1
  163. package/dist/esm/utils/getParentPackageJSON.mjs +16 -20
  164. package/dist/esm/utils/getParentPackageJSON.mjs.map +1 -1
  165. package/dist/esm/utils/listSpecialChars.mjs +48 -49
  166. package/dist/esm/utils/listSpecialChars.mjs.map +1 -1
  167. package/dist/esm/utils/mapChunksBetweenFiles.mjs +87 -107
  168. package/dist/esm/utils/mapChunksBetweenFiles.mjs.map +1 -1
  169. package/dist/esm/utils/reorderParagraphs.mjs +85 -93
  170. package/dist/esm/utils/reorderParagraphs.mjs.map +1 -1
  171. package/dist/esm/watch.mjs +17 -17
  172. package/dist/esm/watch.mjs.map +1 -1
  173. package/dist/types/IntlayerEventListener.d.ts +63 -59
  174. package/dist/types/IntlayerEventListener.d.ts.map +1 -1
  175. package/dist/types/build.d.ts +10 -7
  176. package/dist/types/build.d.ts.map +1 -1
  177. package/dist/types/cli.d.ts +13 -10
  178. package/dist/types/cli.d.ts.map +1 -1
  179. package/dist/types/config.d.ts +7 -4
  180. package/dist/types/config.d.ts.map +1 -1
  181. package/dist/types/editor.d.ts +6 -4
  182. package/dist/types/editor.d.ts.map +1 -1
  183. package/dist/types/fill/fill.d.ts +20 -14
  184. package/dist/types/fill/fill.d.ts.map +1 -1
  185. package/dist/types/fill/formatAutoFillData.d.ts +10 -7
  186. package/dist/types/fill/formatAutoFillData.d.ts.map +1 -1
  187. package/dist/types/fill/formatAutoFilledFilePath.d.ts +6 -2
  188. package/dist/types/fill/formatAutoFilledFilePath.d.ts.map +1 -1
  189. package/dist/types/fill/formatFillData.d.ts +12 -0
  190. package/dist/types/fill/formatFillData.d.ts.map +1 -0
  191. package/dist/types/fill/groupLimiter.d.ts +15 -0
  192. package/dist/types/fill/groupLimiter.d.ts.map +1 -0
  193. package/dist/types/fill/index.d.ts +3 -3
  194. package/dist/types/fill/listTranslationsTasks.d.ts +15 -0
  195. package/dist/types/fill/listTranslationsTasks.d.ts.map +1 -0
  196. package/dist/types/fill/test-original-case.d.ts +1 -0
  197. package/dist/types/fill/translateDictionary.d.ts +19 -0
  198. package/dist/types/fill/translateDictionary.d.ts.map +1 -0
  199. package/dist/types/fill/writeAutoFill.d.ts +7 -0
  200. package/dist/types/fill/writeAutoFill.d.ts.map +1 -0
  201. package/dist/types/fill/writeFill.d.ts +7 -0
  202. package/dist/types/fill/writeFill.d.ts.map +1 -0
  203. package/dist/types/getTargetDictionary.d.ts +17 -13
  204. package/dist/types/getTargetDictionary.d.ts.map +1 -1
  205. package/dist/types/index.d.ts +15 -14
  206. package/dist/types/listContentDeclaration.d.ts +10 -7
  207. package/dist/types/listContentDeclaration.d.ts.map +1 -1
  208. package/dist/types/liveSync.d.ts +8 -3
  209. package/dist/types/liveSync.d.ts.map +1 -1
  210. package/dist/types/pull.d.ts +9 -6
  211. package/dist/types/pull.d.ts.map +1 -1
  212. package/dist/types/push/pullLog.d.ts +25 -21
  213. package/dist/types/push/pullLog.d.ts.map +1 -1
  214. package/dist/types/push/push.d.ts +13 -9
  215. package/dist/types/push/push.d.ts.map +1 -1
  216. package/dist/types/pushConfig.d.ts +7 -4
  217. package/dist/types/pushConfig.d.ts.map +1 -1
  218. package/dist/types/pushLog.d.ts +23 -20
  219. package/dist/types/pushLog.d.ts.map +1 -1
  220. package/dist/types/reviewDoc.d.ts +34 -17
  221. package/dist/types/reviewDoc.d.ts.map +1 -1
  222. package/dist/types/test/index.d.ts +9 -5
  223. package/dist/types/test/index.d.ts.map +1 -1
  224. package/dist/types/test/listMissingTranslations.d.ts +14 -10
  225. package/dist/types/test/listMissingTranslations.d.ts.map +1 -1
  226. package/dist/types/translateDoc.d.ts +34 -17
  227. package/dist/types/translateDoc.d.ts.map +1 -1
  228. package/dist/types/utils/calculateChunks.d.ts +10 -7
  229. package/dist/types/utils/calculateChunks.d.ts.map +1 -1
  230. package/dist/types/utils/checkAccess.d.ts +8 -4
  231. package/dist/types/utils/checkAccess.d.ts.map +1 -1
  232. package/dist/types/utils/checkFileModifiedRange.d.ts +8 -6
  233. package/dist/types/utils/checkFileModifiedRange.d.ts.map +1 -1
  234. package/dist/types/utils/checkLastUpdateTime.d.ts +4 -1
  235. package/dist/types/utils/checkLastUpdateTime.d.ts.map +1 -1
  236. package/dist/types/utils/chunkInference.d.ts +9 -6
  237. package/dist/types/utils/chunkInference.d.ts.map +1 -1
  238. package/dist/types/utils/fixChunkStartEndChars.d.ts +4 -1
  239. package/dist/types/utils/fixChunkStartEndChars.d.ts.map +1 -1
  240. package/dist/types/utils/formatTimeDiff.d.ts +4 -1
  241. package/dist/types/utils/formatTimeDiff.d.ts.map +1 -1
  242. package/dist/types/utils/getIsFileUpdatedRecently.d.ts +4 -1
  243. package/dist/types/utils/getIsFileUpdatedRecently.d.ts.map +1 -1
  244. package/dist/types/utils/getOutputFilePath.d.ts +7 -2
  245. package/dist/types/utils/getOutputFilePath.d.ts.map +1 -1
  246. package/dist/types/utils/getParentPackageJSON.d.ts +30 -28
  247. package/dist/types/utils/getParentPackageJSON.d.ts.map +1 -1
  248. package/dist/types/utils/listSpecialChars.d.ts +9 -7
  249. package/dist/types/utils/listSpecialChars.d.ts.map +1 -1
  250. package/dist/types/utils/mapChunksBetweenFiles.d.ts +10 -6
  251. package/dist/types/utils/mapChunksBetweenFiles.d.ts.map +1 -1
  252. package/dist/types/utils/reorderParagraphs.d.ts +4 -1
  253. package/dist/types/utils/reorderParagraphs.d.ts.map +1 -1
  254. package/dist/types/watch.d.ts +9 -6
  255. package/dist/types/watch.d.ts.map +1 -1
  256. package/package.json +42 -47
  257. package/LICENSE +0 -202
  258. package/dist/cjs/fill/autoFill.cjs +0 -105
  259. package/dist/cjs/fill/autoFill.cjs.map +0 -1
  260. package/dist/cjs/fill/index.cjs.map +0 -1
  261. package/dist/cjs/index.cjs.map +0 -1
  262. package/dist/cjs/utils/getChunk.cjs +0 -77
  263. package/dist/cjs/utils/getChunk.cjs.map +0 -1
  264. package/dist/cjs/utils/splitTextByLine.cjs +0 -35
  265. package/dist/cjs/utils/splitTextByLine.cjs.map +0 -1
  266. package/dist/esm/fill/autoFill.mjs +0 -92
  267. package/dist/esm/fill/autoFill.mjs.map +0 -1
  268. package/dist/esm/fill/index.mjs.map +0 -1
  269. package/dist/esm/index.mjs.map +0 -1
  270. package/dist/esm/prompts/REVIEW_PROMPT.md +0 -37
  271. package/dist/esm/prompts/TRANSLATE_PROMPT.md +0 -38
  272. package/dist/esm/utils/calculrateChunkTest.md +0 -9
  273. package/dist/esm/utils/getChunk.mjs +0 -53
  274. package/dist/esm/utils/getChunk.mjs.map +0 -1
  275. package/dist/esm/utils/splitTextByLine.mjs +0 -11
  276. package/dist/esm/utils/splitTextByLine.mjs.map +0 -1
  277. package/dist/types/fill/autoFill.d.ts +0 -4
  278. package/dist/types/fill/autoFill.d.ts.map +0 -1
  279. package/dist/types/fill/index.d.ts.map +0 -1
  280. package/dist/types/index.d.ts.map +0 -1
  281. package/dist/types/utils/getChunk.d.ts +0 -9
  282. package/dist/types/utils/getChunk.d.ts.map +0 -1
  283. package/dist/types/utils/splitTextByLine.d.ts +0 -2
  284. package/dist/types/utils/splitTextByLine.d.ts.map +0 -1
  285. /package/dist/{cjs → assets}/prompts/REVIEW_PROMPT.md +0 -0
  286. /package/dist/{cjs → assets}/prompts/TRANSLATE_PROMPT.md +0 -0
  287. /package/dist/{cjs/utils/calculrateChunkTest.md → assets/utils/_calculateChunkTest.md} +0 -0
package/dist/esm/cli.mjs CHANGED
@@ -1,7 +1,3 @@
1
- import configuration from "@intlayer/config/built";
2
- import { Command } from "commander";
3
- import { dirname as pathDirname } from "path";
4
- import { fileURLToPath } from "url";
5
1
  import { build } from "./build.mjs";
6
2
  import { getConfig } from "./config.mjs";
7
3
  import { startEditor } from "./editor.mjs";
@@ -16,405 +12,378 @@ import { testMissingTranslations } from "./test/index.mjs";
16
12
  import { translateDoc } from "./translateDoc.mjs";
17
13
  import { getParentPackageJSON } from "./utils/getParentPackageJSON.mjs";
18
14
  import { watchContentDeclaration } from "./watch.mjs";
19
- const isESModule = typeof import.meta.url === "string";
20
- const dirname = isESModule ? pathDirname(fileURLToPath(import.meta.url)) : __dirname;
15
+ import { getConfiguration } from "@intlayer/config";
16
+ import { dirname as dirname$1 } from "node:path";
17
+ import { fileURLToPath } from "node:url";
18
+ import { Command } from "commander";
19
+
20
+ //#region src/cli.ts
21
+ const isESModule$1 = typeof import.meta.url === "string";
22
+ const dirname = isESModule$1 ? dirname$1(fileURLToPath(import.meta.url)) : __dirname;
21
23
  const packageJson = getParentPackageJSON(dirname);
22
- const logOptions = [
23
- ["--verbose", "Verbose (default to true using CLI)"],
24
- ["--prefix [prefix]", "Prefix"]
25
- ];
26
24
  const configurationOptions = [
27
- ["--env-file [envFile]", "Environment file"],
28
- ["-e, --env [env]", "Environment"],
29
- ["--base-dir [baseDir]", "Base directory"],
30
- ...logOptions
25
+ ["--env-file [envFile]", "Environment file"],
26
+ ["-e, --env [env]", "Environment"],
27
+ ["--base-dir [baseDir]", "Base directory"],
28
+ ...[["--verbose", "Verbose (default to true using CLI)"], ["--prefix [prefix]", "Prefix"]]
31
29
  ];
32
30
  const aiOptions = [
33
- ["--provider [provider]", "Provider"],
34
- ["--temperature [temperature]", "Temperature"],
35
- ["--model [model]", "Model"],
36
- ["--api-key [apiKey]", "Provider API key"],
37
- ["--custom-prompt [prompt]", "Custom prompt"],
38
- ["--application-context [applicationContext]", "Application context"]
31
+ ["--provider [provider]", "Provider"],
32
+ ["--temperature [temperature]", "Temperature"],
33
+ ["--model [model]", "Model"],
34
+ ["--api-key [apiKey]", "Provider API key"],
35
+ ["--custom-prompt [prompt]", "Custom prompt"],
36
+ ["--application-context [applicationContext]", "Application context"]
39
37
  ];
40
38
  const gitOptions = [
41
- ["--git-diff [gitDiff]", "Git diff mode - Check git diff between two refs"],
42
- ["--git-diff-base [gitDiffBase]", "Git diff base ref"],
43
- ["--git-diff-current [gitDiffCurrent]", "Git diff current ref"],
44
- ["--uncommitted [uncommitted]", "Uncommitted"],
45
- ["--unpushed [unpushed]", "Unpushed"],
46
- ["--untracked [untracked]", "Untracked"]
39
+ ["--git-diff [gitDiff]", "Git diff mode - Check git diff between two refs"],
40
+ ["--git-diff-base [gitDiffBase]", "Git diff base ref"],
41
+ ["--git-diff-current [gitDiffCurrent]", "Git diff current ref"],
42
+ ["--uncommitted [uncommitted]", "Uncommitted"],
43
+ ["--unpushed [unpushed]", "Unpushed"],
44
+ ["--untracked [untracked]", "Untracked"]
47
45
  ];
48
46
  const extractKeysFromOptions = (options, keys) => keys.filter((key) => options[key]);
47
+ /**
48
+ * Helper functions to apply common options to commands
49
+ */
49
50
  const applyOptions = (command, options) => {
50
- options.forEach(([flag, description]) => command.option(flag, description));
51
- return command;
51
+ options.forEach(([flag, description]) => {
52
+ command.option(flag, description);
53
+ });
54
+ return command;
52
55
  };
53
- const removeUndefined = (obj) => Object.fromEntries(
54
- Object.entries(obj).filter(([_, value]) => value !== void 0)
55
- );
56
+ const removeUndefined = (obj) => Object.fromEntries(Object.entries(obj).filter(([_, value]) => value !== void 0));
56
57
  const applyConfigOptions = (command) => applyOptions(command, configurationOptions);
57
58
  const applyAIOptions = (command) => applyOptions(command, aiOptions);
58
59
  const applyGitOptions = (command) => applyOptions(command, gitOptions);
59
60
  const extractAiOptions = (options) => {
60
- const {
61
- apiKey,
62
- provider,
63
- model,
64
- temperature,
65
- applicationContext,
66
- customPrompt
67
- } = options;
68
- return removeUndefined({
69
- apiKey: apiKey ?? configuration.ai?.apiKey,
70
- provider: provider ?? configuration.ai?.provider,
71
- model: model ?? configuration.ai?.model,
72
- temperature: temperature ?? configuration.ai?.temperature,
73
- applicationContext: applicationContext ?? configuration.ai?.applicationContext,
74
- customPrompt: customPrompt ?? configuration.ai?.customPrompt
75
- });
61
+ const { apiKey, provider, model, temperature, applicationContext, customPrompt } = options;
62
+ const configuration = getConfiguration();
63
+ return removeUndefined({
64
+ apiKey: apiKey ?? configuration.ai?.apiKey,
65
+ provider: provider ?? configuration.ai?.provider,
66
+ model: model ?? configuration.ai?.model,
67
+ temperature: temperature ?? configuration.ai?.temperature,
68
+ applicationContext: applicationContext ?? configuration.ai?.applicationContext,
69
+ customPrompt: customPrompt ?? configuration.ai?.customPrompt
70
+ });
76
71
  };
77
72
  const gitOptionKeys = [
78
- "gitDiff",
79
- "gitDiffBase",
80
- "gitDiffCurrent",
81
- "uncommitted",
82
- "unpushed",
83
- "untracked"
73
+ "gitDiff",
74
+ "gitDiffBase",
75
+ "gitDiffCurrent",
76
+ "uncommitted",
77
+ "unpushed",
78
+ "untracked"
84
79
  ];
85
80
  const extractGitOptions = (options) => {
86
- const filteredOptions = extractKeysFromOptions(options, gitOptionKeys);
87
- const isOptionEmpty = !Object.values(filteredOptions).some(Boolean);
88
- if (isOptionEmpty) return void 0;
89
- const {
90
- gitDiff,
91
- gitDiffBase,
92
- gitDiffCurrent,
93
- uncommitted,
94
- unpushed,
95
- untracked
96
- } = options;
97
- const mode = [
98
- gitDiff && "gitDiff",
99
- uncommitted && "uncommitted",
100
- unpushed && "unpushed",
101
- untracked && "untracked"
102
- ].filter(Boolean);
103
- return removeUndefined({
104
- mode,
105
- baseRef: gitDiffBase,
106
- currentRef: gitDiffCurrent,
107
- absolute: true
108
- });
81
+ const filteredOptions = extractKeysFromOptions(options, gitOptionKeys);
82
+ if (!Object.values(filteredOptions).some(Boolean)) return void 0;
83
+ const { gitDiff, gitDiffBase, gitDiffCurrent, uncommitted, unpushed, untracked } = options;
84
+ return removeUndefined({
85
+ mode: [
86
+ gitDiff && "gitDiff",
87
+ uncommitted && "uncommitted",
88
+ unpushed && "unpushed",
89
+ untracked && "untracked"
90
+ ].filter(Boolean),
91
+ baseRef: gitDiffBase,
92
+ currentRef: gitDiffCurrent,
93
+ absolute: true
94
+ });
109
95
  };
110
96
  const configurationOptionKeys = [
111
- "baseDir",
112
- "env",
113
- "envFile",
114
- "verbose",
115
- "prefix"
97
+ "baseDir",
98
+ "env",
99
+ "envFile",
100
+ "verbose",
101
+ "prefix"
116
102
  ];
117
103
  const extractConfigOptions = (options) => {
118
- const filteredOptions = extractKeysFromOptions(
119
- options,
120
- configurationOptionKeys
121
- );
122
- const isOptionEmpty = !Object.values(filteredOptions).some(Boolean);
123
- if (isOptionEmpty) {
124
- return void 0;
125
- }
126
- const { baseDir, env, envFile, verbose, prefix } = options;
127
- const log = {
128
- prefix: prefix ?? "",
129
- // Should not consider the prefix set in the intlayer configuration file
130
- verbose: verbose ?? true
131
- };
132
- const override = {
133
- log
134
- };
135
- return removeUndefined({
136
- baseDir,
137
- env,
138
- envFile,
139
- override
140
- });
104
+ const configuration = getConfiguration(options);
105
+ const filteredOptions = extractKeysFromOptions(options, configurationOptionKeys);
106
+ if (!Object.values(filteredOptions).some(Boolean)) return;
107
+ const { baseDir, env, envFile, verbose, prefix } = options;
108
+ const addPrefix = Boolean(options.with);
109
+ return removeUndefined({
110
+ baseDir,
111
+ env,
112
+ envFile,
113
+ override: { log: {
114
+ prefix: prefix ?? addPrefix ? configuration.log.prefix : "",
115
+ verbose: verbose ?? true
116
+ } }
117
+ });
141
118
  };
119
+ /**
120
+ * Set the API for the CLI
121
+ *
122
+ * Example of commands:
123
+ *
124
+ * npm run intlayer build --watch
125
+ * npm run intlayer push --dictionaries id1 id2 id3 --deleteLocaleDir
126
+ */
142
127
  const setAPI = () => {
143
- const program = new Command();
144
- program.version(packageJson.version).description("Intlayer CLI");
145
- program.command("version").description("Print the Intlayer CLI version").action(() => {
146
- console.log(packageJson.version ?? "unknown");
147
- });
148
- const dictionariesProgram = program.command("dictionary").alias("dictionaries").alias("dic").description("Dictionaries operations");
149
- const buildOptions = {
150
- description: "Build the dictionaries",
151
- options: [
152
- ["-w, --watch", "Watch for changes"],
153
- ["--skip-prepare", "Skip the prepare step"],
154
- ["--with [with...]", "Start command in parallel with the build"]
155
- ]
156
- };
157
- const dictionariesBuildCmd = dictionariesProgram.command("build").description(buildOptions.description);
158
- applyOptions(dictionariesBuildCmd, buildOptions.options);
159
- applyConfigOptions(dictionariesBuildCmd);
160
- dictionariesBuildCmd.action((options) => {
161
- build({
162
- ...options,
163
- configOptions: extractConfigOptions(options)
164
- });
165
- });
166
- const rootBuildCmd = program.command("build").description(buildOptions.description);
167
- applyOptions(rootBuildCmd, buildOptions.options);
168
- applyConfigOptions(rootBuildCmd);
169
- rootBuildCmd.action((options) => {
170
- build({
171
- ...options,
172
- configOptions: extractConfigOptions(options)
173
- });
174
- });
175
- const watchOptions = {
176
- description: "Watch the dictionaries changes",
177
- options: [["--with [with...]", "Start command in parallel with the build"]]
178
- };
179
- const dictionariesWatchCmd = dictionariesProgram.command("watch").description(buildOptions.description);
180
- applyOptions(dictionariesWatchCmd, watchOptions.options);
181
- applyConfigOptions(dictionariesWatchCmd);
182
- dictionariesWatchCmd.action((options) => {
183
- watchContentDeclaration({
184
- ...options,
185
- configOptions: extractConfigOptions(options)
186
- });
187
- });
188
- const rootWatchCmd = program.command("watch").description(buildOptions.description);
189
- applyOptions(rootWatchCmd, watchOptions.options);
190
- applyConfigOptions(rootWatchCmd);
191
- rootWatchCmd.action((options) => {
192
- watchContentDeclaration({
193
- ...options,
194
- configOptions: extractConfigOptions(options)
195
- });
196
- });
197
- const pullOptions = {
198
- description: "Pull dictionaries from the server",
199
- options: [
200
- ["-d, --dictionaries [ids...]", "List of dictionary IDs to pull"],
201
- ["--new-dictionaries-path [path]", "Path to save the new dictionaries"],
202
- // Backward-compatibility for older tests/flags (camelCase)
203
- [
204
- "--newDictionariesPath [path]",
205
- "[alias] Path to save the new dictionaries"
206
- ]
207
- ]
208
- };
209
- const dictionariesPullCmd = dictionariesProgram.command("pull").description(pullOptions.description);
210
- applyOptions(dictionariesPullCmd, pullOptions.options);
211
- applyConfigOptions(dictionariesPullCmd);
212
- dictionariesPullCmd.action((options) => {
213
- pull({
214
- ...options,
215
- configOptions: {
216
- ...options.configOptions,
217
- baseDir: options.baseDir
218
- }
219
- });
220
- });
221
- const rootPullCmd = program.command("pull").description(pullOptions.description);
222
- applyOptions(rootPullCmd, pullOptions.options);
223
- applyConfigOptions(rootPullCmd);
224
- rootPullCmd.action((options) => {
225
- pull({
226
- ...options,
227
- configOptions: extractConfigOptions(options)
228
- });
229
- });
230
- const pushOptions = {
231
- description: "Push all dictionaries. Create or update the pushed dictionaries",
232
- options: [
233
- ["-d, --dictionaries [ids...]", "List of dictionary IDs to push"],
234
- [
235
- "-r, --delete-locale-dictionary",
236
- "Delete the local dictionaries after pushing"
237
- ],
238
- [
239
- "-k, --keep-locale-dictionary",
240
- "Keep the local dictionaries after pushing"
241
- ],
242
- // Backward-compatibility for older tests/flags (camelCase)
243
- [
244
- "--deleteLocaleDictionary",
245
- "[alias] Delete the local dictionaries after pushing"
246
- ],
247
- [
248
- "--keepLocaleDictionary",
249
- "[alias] Keep the local dictionaries after pushing"
250
- ]
251
- ]
252
- };
253
- const dictionariesPushCmd = dictionariesProgram.command("push").description(pushOptions.description);
254
- applyOptions(dictionariesPushCmd, pushOptions.options);
255
- applyConfigOptions(dictionariesPushCmd);
256
- applyGitOptions(dictionariesPushCmd);
257
- dictionariesPushCmd.action(
258
- (options) => push({
259
- ...options,
260
- gitOptions: extractGitOptions(options),
261
- configOptions: extractConfigOptions(options)
262
- })
263
- );
264
- const rootPushCmd = program.command("push").description(pushOptions.description);
265
- applyOptions(rootPushCmd, pushOptions.options);
266
- applyConfigOptions(rootPushCmd);
267
- applyGitOptions(rootPushCmd);
268
- rootPushCmd.action(
269
- (options) => push({
270
- ...options,
271
- gitOptions: extractGitOptions(options),
272
- configOptions: extractConfigOptions(options)
273
- })
274
- );
275
- const configurationProgram = program.command("configuration").alias("config").alias("conf").description("Configuration operations");
276
- const configGetCmd = configurationProgram.command("get").description("Get the configuration");
277
- applyConfigOptions(configGetCmd);
278
- configGetCmd.action((options) => {
279
- getConfig({
280
- ...options,
281
- configOptions: extractConfigOptions(options)
282
- });
283
- });
284
- const configPushCmd = configurationProgram.command("push").description("Push the configuration");
285
- applyConfigOptions(configPushCmd);
286
- configPushCmd.action((options) => {
287
- pushConfig({
288
- ...options,
289
- configOptions: extractConfigOptions(options)
290
- });
291
- });
292
- const contentProgram = program.command("content").description("Content declaration operations");
293
- contentProgram.command("list").description("List the content declaration files").action(listContentDeclaration);
294
- const testProgram = contentProgram.command("test").description("Test if there are missing translations");
295
- applyConfigOptions(testProgram);
296
- testProgram.action((options) => {
297
- testMissingTranslations({
298
- ...options,
299
- configOptions: extractConfigOptions(options)
300
- });
301
- });
302
- const fillProgram = program.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(
303
- "--output-locales [outputLocales...]",
304
- "Target locales to translate to"
305
- ).option(
306
- "--mode [mode]",
307
- "Fill mode: complete, review. Complete will fill all missing content, review will fill missing content and review existing keys",
308
- "complete"
309
- ).option("-k, --keys [keys...]", "Filter dictionaries based on keys").option(
310
- "--excluded-keys [excludedKeys...]",
311
- "Filter out dictionaries based on keys"
312
- ).option(
313
- "--path-filter [pathFilters...]",
314
- "Filter dictionaries based on glob pattern"
315
- ).option(
316
- "--build [build]",
317
- "Build the dictionaries before filling to ensure the content is up to date"
318
- );
319
- applyConfigOptions(fillProgram);
320
- applyAIOptions(fillProgram);
321
- applyGitOptions(fillProgram);
322
- fillProgram.action(
323
- (options) => fill({
324
- ...options,
325
- aiOptions: extractAiOptions(options),
326
- gitOptions: extractGitOptions(options),
327
- configOptions: extractConfigOptions(options)
328
- })
329
- );
330
- const docParams = [
331
- ["--doc-pattern [docPattern...]", "Documentation pattern"],
332
- [
333
- "--excluded-glob-pattern [excludedGlobPattern...]",
334
- "Excluded glob pattern"
335
- ],
336
- [
337
- "--nb-simultaneous-file-processed [nbSimultaneousFileProcessed]",
338
- "Number of simultaneous file processed"
339
- ],
340
- ["--locales [locales...]", "Locales"],
341
- ["--base-locale [baseLocale]", "Base locale"],
342
- [
343
- "--custom-instructions [customInstructions]",
344
- "Custom instructions added to the prompt. Usefull to apply specific rules regarding formatting, urls translation, etc."
345
- ],
346
- [
347
- "--skip-if-modified-before [skipIfModifiedBefore]",
348
- '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.'
349
- ],
350
- [
351
- "--skip-if-modified-after [skipIfModifiedAfter]",
352
- '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.'
353
- ]
354
- ];
355
- const docProgram = program.command("doc").description("Documentation operations");
356
- const translateProgram = docProgram.command("translate").description("Translate the documentation");
357
- applyConfigOptions(translateProgram);
358
- applyAIOptions(translateProgram);
359
- applyGitOptions(translateProgram);
360
- applyOptions(translateProgram, docParams);
361
- translateProgram.action(
362
- (options) => translateDoc({
363
- docPattern: options.docPattern,
364
- excludedGlobPattern: options.excludedGlobPattern,
365
- locales: options.locales,
366
- baseLocale: options.baseLocale,
367
- aiOptions: extractAiOptions(options),
368
- gitOptions: extractGitOptions(options),
369
- nbSimultaneousFileProcessed: options.nbSimultaneousFileProcessed,
370
- configOptions: extractConfigOptions(options),
371
- customInstructions: options.customInstructions,
372
- skipIfModifiedBefore: options.skipIfModifiedBefore,
373
- skipIfModifiedAfter: options.skipIfModifiedAfter
374
- })
375
- );
376
- const reviewProgram = docProgram.command("review").description("Review the documentation");
377
- applyConfigOptions(reviewProgram);
378
- applyAIOptions(reviewProgram);
379
- applyGitOptions(reviewProgram);
380
- applyOptions(reviewProgram, docParams);
381
- reviewProgram.action(
382
- (options) => reviewDoc({
383
- docPattern: options.docPattern,
384
- excludedGlobPattern: options.excludedGlobPattern,
385
- locales: options.locales,
386
- baseLocale: options.baseLocale,
387
- aiOptions: extractAiOptions(options),
388
- gitOptions: extractGitOptions(options),
389
- nbSimultaneousFileProcessed: options.nbSimultaneousFileProcessed,
390
- configOptions: extractConfigOptions(options),
391
- customInstructions: options.customInstructions,
392
- skipIfModifiedBefore: options.skipIfModifiedBefore,
393
- skipIfModifiedAfter: options.skipIfModifiedAfter
394
- })
395
- );
396
- const liveOptions = [
397
- ["--with [with...]", "Start command in parallel with the live sync"]
398
- ];
399
- const liveCmd = program.command("live").description(
400
- "Live sync - Watch for changes made on the CMS and update the application content accordingly"
401
- );
402
- applyOptions(liveCmd, liveOptions);
403
- liveCmd.action((options) => liveSync(options));
404
- const editorProgram = program.command("editor").description("Visual editor operations");
405
- const editorStartCmd = editorProgram.command("start").description("Start the Intlayer visual editor");
406
- applyConfigOptions(editorStartCmd);
407
- editorStartCmd.action((options) => {
408
- startEditor({
409
- env: options.env,
410
- envFile: options.envFile
411
- });
412
- });
413
- program.parse(process.argv);
414
- return program;
415
- };
416
- export {
417
- dirname,
418
- setAPI
128
+ const program = new Command();
129
+ program.version(packageJson.version).description("Intlayer CLI");
130
+ program.command("version").description("Print the Intlayer CLI version").action(() => {
131
+ console.log(packageJson.version ?? "unknown");
132
+ });
133
+ /**
134
+ * DICTIONARIES
135
+ */
136
+ const dictionariesProgram = program.command("dictionary").alias("dictionaries").alias("dic").description("Dictionaries operations");
137
+ const buildOptions = {
138
+ description: "Build the dictionaries",
139
+ options: [
140
+ ["-w, --watch", "Watch for changes"],
141
+ ["--skip-prepare", "Skip the prepare step"],
142
+ ["--with [with...]", "Start command in parallel with the build"]
143
+ ]
144
+ };
145
+ const dictionariesBuildCmd = dictionariesProgram.command("build").description(buildOptions.description);
146
+ applyOptions(dictionariesBuildCmd, buildOptions.options);
147
+ applyConfigOptions(dictionariesBuildCmd);
148
+ dictionariesBuildCmd.action((options) => {
149
+ build({
150
+ ...options,
151
+ configOptions: extractConfigOptions(options)
152
+ });
153
+ });
154
+ const rootBuildCmd = program.command("build").description(buildOptions.description);
155
+ applyOptions(rootBuildCmd, buildOptions.options);
156
+ applyConfigOptions(rootBuildCmd);
157
+ rootBuildCmd.action((options) => {
158
+ build({
159
+ ...options,
160
+ configOptions: extractConfigOptions(options)
161
+ });
162
+ });
163
+ const watchOptions = {
164
+ description: "Watch the dictionaries changes",
165
+ options: [["--with [with...]", "Start command in parallel with the build"]]
166
+ };
167
+ const dictionariesWatchCmd = dictionariesProgram.command("watch").description(buildOptions.description);
168
+ applyOptions(dictionariesWatchCmd, watchOptions.options);
169
+ applyConfigOptions(dictionariesWatchCmd);
170
+ dictionariesWatchCmd.action((options) => {
171
+ watchContentDeclaration({
172
+ ...options,
173
+ configOptions: extractConfigOptions(options)
174
+ });
175
+ });
176
+ const rootWatchCmd = program.command("watch").description(buildOptions.description);
177
+ applyOptions(rootWatchCmd, watchOptions.options);
178
+ applyConfigOptions(rootWatchCmd);
179
+ rootWatchCmd.action((options) => {
180
+ watchContentDeclaration({
181
+ ...options,
182
+ configOptions: extractConfigOptions(options)
183
+ });
184
+ });
185
+ const pullOptions = {
186
+ description: "Pull dictionaries from the server",
187
+ options: [
188
+ ["-d, --dictionaries [ids...]", "List of dictionary IDs to pull"],
189
+ ["--dictionary [ids...]", "List of dictionary IDs to pull (alias for --dictionaries)"],
190
+ ["--new-dictionaries-path [path]", "Path to save the new dictionaries"],
191
+ ["--newDictionariesPath [path]", "[alias] Path to save the new dictionaries"]
192
+ ]
193
+ };
194
+ const dictionariesPullCmd = dictionariesProgram.command("pull").description(pullOptions.description);
195
+ applyOptions(dictionariesPullCmd, pullOptions.options);
196
+ applyConfigOptions(dictionariesPullCmd);
197
+ dictionariesPullCmd.action((options) => {
198
+ const dictionaries = [...options.dictionaries ?? [], ...options.dictionary ?? []];
199
+ pull({
200
+ ...options,
201
+ dictionaries: dictionaries.length > 0 ? dictionaries : void 0,
202
+ configOptions: {
203
+ ...options.configOptions,
204
+ baseDir: options.baseDir
205
+ }
206
+ });
207
+ });
208
+ const rootPullCmd = program.command("pull").description(pullOptions.description);
209
+ applyOptions(rootPullCmd, pullOptions.options);
210
+ applyConfigOptions(rootPullCmd);
211
+ rootPullCmd.action((options) => {
212
+ const dictionaries = [...options.dictionaries ?? [], ...options.dictionary ?? []];
213
+ pull({
214
+ ...options,
215
+ dictionaries: dictionaries.length > 0 ? dictionaries : void 0,
216
+ configOptions: extractConfigOptions(options)
217
+ });
218
+ });
219
+ const pushOptions = {
220
+ description: "Push all dictionaries. Create or update the pushed dictionaries",
221
+ options: [
222
+ ["-d, --dictionaries [ids...]", "List of dictionary IDs to push"],
223
+ ["--dictionary [ids...]", "List of dictionary IDs to push (alias for --dictionaries)"],
224
+ ["-r, --delete-locale-dictionary", "Delete the local dictionaries after pushing"],
225
+ ["-k, --keep-locale-dictionary", "Keep the local dictionaries after pushing"],
226
+ ["--deleteLocaleDictionary", "[alias] Delete the local dictionaries after pushing"],
227
+ ["--keepLocaleDictionary", "[alias] Keep the local dictionaries after pushing"],
228
+ ["--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"]
229
+ ]
230
+ };
231
+ const dictionariesPushCmd = dictionariesProgram.command("push").description(pushOptions.description);
232
+ applyOptions(dictionariesPushCmd, pushOptions.options);
233
+ applyConfigOptions(dictionariesPushCmd);
234
+ applyGitOptions(dictionariesPushCmd);
235
+ dictionariesPushCmd.action((options) => {
236
+ const dictionaries = [...options.dictionaries || [], ...options.dictionary || []];
237
+ return push({
238
+ ...options,
239
+ dictionaries: dictionaries.length > 0 ? dictionaries : void 0,
240
+ gitOptions: extractGitOptions(options),
241
+ configOptions: extractConfigOptions(options)
242
+ });
243
+ });
244
+ const rootPushCmd = program.command("push").description(pushOptions.description);
245
+ applyOptions(rootPushCmd, pushOptions.options);
246
+ applyConfigOptions(rootPushCmd);
247
+ applyGitOptions(rootPushCmd);
248
+ rootPushCmd.action((options) => {
249
+ const dictionaries = [...options.dictionaries || [], ...options.dictionary || []];
250
+ return push({
251
+ ...options,
252
+ dictionaries: dictionaries.length > 0 ? dictionaries : void 0,
253
+ gitOptions: extractGitOptions(options),
254
+ configOptions: extractConfigOptions(options)
255
+ });
256
+ });
257
+ /**
258
+ * CONFIGURATION
259
+ */
260
+ const configurationProgram = program.command("configuration").alias("config").alias("conf").description("Configuration operations");
261
+ const configGetCmd = configurationProgram.command("get").description("Get the configuration");
262
+ applyConfigOptions(configGetCmd);
263
+ configGetCmd.action((options) => {
264
+ getConfig({
265
+ ...options,
266
+ configOptions: extractConfigOptions(options)
267
+ });
268
+ });
269
+ const configPushCmd = configurationProgram.command("push").description("Push the configuration");
270
+ applyConfigOptions(configPushCmd);
271
+ configPushCmd.action((options) => {
272
+ pushConfig({
273
+ ...options,
274
+ configOptions: extractConfigOptions(options)
275
+ });
276
+ });
277
+ /**
278
+ * CONTENT DECLARATION
279
+ */
280
+ const contentProgram = program.command("content").description("Content declaration operations");
281
+ contentProgram.command("list").description("List the content declaration files").action(listContentDeclaration);
282
+ program.command("list").description("List the content declaration files").action(listContentDeclaration);
283
+ const testProgram = contentProgram.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");
284
+ applyConfigOptions(testProgram);
285
+ testProgram.action((options) => {
286
+ testMissingTranslations({
287
+ ...options,
288
+ configOptions: extractConfigOptions(options)
289
+ });
290
+ });
291
+ const rootTestCmd = program.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");
292
+ applyConfigOptions(rootTestCmd);
293
+ rootTestCmd.action((options) => {
294
+ testMissingTranslations({
295
+ ...options,
296
+ configOptions: extractConfigOptions(options)
297
+ });
298
+ });
299
+ const fillProgram = program.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");
300
+ applyConfigOptions(fillProgram);
301
+ applyAIOptions(fillProgram);
302
+ applyGitOptions(fillProgram);
303
+ fillProgram.action((options) => {
304
+ const keys = [...options.keys ?? [], ...options.key ?? []];
305
+ const excludedKeys = [...options.excludedKeys ?? [], ...options.excludedKey ?? []];
306
+ const dictionaries = [...options.dictionaries ?? [], ...options.dictionary ?? []];
307
+ return fill({
308
+ ...options,
309
+ keys: keys.length > 0 ? keys : void 0,
310
+ excludedKeys: excludedKeys.length > 0 ? excludedKeys : void 0,
311
+ dictionaries: dictionaries.length > 0 ? dictionaries : void 0,
312
+ aiOptions: extractAiOptions(options),
313
+ gitOptions: extractGitOptions(options),
314
+ configOptions: extractConfigOptions(options)
315
+ });
316
+ });
317
+ /**
318
+ * DOCS
319
+ */
320
+ const docParams = [
321
+ ["--doc-pattern [docPattern...]", "Documentation pattern"],
322
+ ["--excluded-glob-pattern [excludedGlobPattern...]", "Excluded glob pattern"],
323
+ ["--nb-simultaneous-file-processed [nbSimultaneousFileProcessed]", "Number of simultaneous file processed"],
324
+ ["--locales [locales...]", "Locales"],
325
+ ["--base-locale [baseLocale]", "Base locale"],
326
+ ["--custom-instructions [customInstructions]", "Custom instructions added to the prompt. Usefull to apply specific rules regarding formatting, urls translation, etc."],
327
+ ["--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."],
328
+ ["--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."]
329
+ ];
330
+ const docProgram = program.command("doc").description("Documentation operations");
331
+ const translateProgram = docProgram.command("translate").description("Translate the documentation");
332
+ applyConfigOptions(translateProgram);
333
+ applyAIOptions(translateProgram);
334
+ applyGitOptions(translateProgram);
335
+ applyOptions(translateProgram, docParams);
336
+ translateProgram.action((options) => translateDoc({
337
+ docPattern: options.docPattern,
338
+ excludedGlobPattern: options.excludedGlobPattern,
339
+ locales: options.locales,
340
+ baseLocale: options.baseLocale,
341
+ aiOptions: extractAiOptions(options),
342
+ gitOptions: extractGitOptions(options),
343
+ nbSimultaneousFileProcessed: options.nbSimultaneousFileProcessed,
344
+ configOptions: extractConfigOptions(options),
345
+ customInstructions: options.customInstructions,
346
+ skipIfModifiedBefore: options.skipIfModifiedBefore,
347
+ skipIfModifiedAfter: options.skipIfModifiedAfter
348
+ }));
349
+ const reviewProgram = docProgram.command("review").description("Review the documentation");
350
+ applyConfigOptions(reviewProgram);
351
+ applyAIOptions(reviewProgram);
352
+ applyGitOptions(reviewProgram);
353
+ applyOptions(reviewProgram, docParams);
354
+ reviewProgram.action((options) => reviewDoc({
355
+ docPattern: options.docPattern,
356
+ excludedGlobPattern: options.excludedGlobPattern,
357
+ locales: options.locales,
358
+ baseLocale: options.baseLocale,
359
+ aiOptions: extractAiOptions(options),
360
+ gitOptions: extractGitOptions(options),
361
+ nbSimultaneousFileProcessed: options.nbSimultaneousFileProcessed,
362
+ configOptions: extractConfigOptions(options),
363
+ customInstructions: options.customInstructions,
364
+ skipIfModifiedBefore: options.skipIfModifiedBefore,
365
+ skipIfModifiedAfter: options.skipIfModifiedAfter
366
+ }));
367
+ /**
368
+ * LIVE SYNC
369
+ */
370
+ const liveOptions = [["--with [with...]", "Start command in parallel with the live sync"]];
371
+ const liveCmd = program.command("live").description("Live sync - Watch for changes made on the CMS and update the application content accordingly");
372
+ applyOptions(liveCmd, liveOptions);
373
+ applyConfigOptions(liveCmd);
374
+ liveCmd.action((options) => liveSync(options));
375
+ const editorStartCmd = program.command("editor").description("Visual editor operations").command("start").description("Start the Intlayer visual editor");
376
+ applyConfigOptions(editorStartCmd);
377
+ editorStartCmd.action((options) => {
378
+ startEditor({
379
+ env: options.env,
380
+ envFile: options.envFile
381
+ });
382
+ });
383
+ program.parse(process.argv);
384
+ return program;
419
385
  };
386
+
387
+ //#endregion
388
+ export { dirname, setAPI };
420
389
  //# sourceMappingURL=cli.mjs.map