@intlayer/engine 9.5.9 → 9.5.11

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 (303) hide show
  1. package/dist/cjs/cli.cjs +7 -0
  2. package/dist/cjs/docReview/alignBlocks.cjs +53 -36
  3. package/dist/cjs/docReview/alignBlocks.cjs.map +1 -1
  4. package/dist/cjs/docReview/rebuildDocument.cjs +3 -1
  5. package/dist/cjs/docReview/rebuildDocument.cjs.map +1 -1
  6. package/dist/cjs/docReview/reviewReport.cjs.map +1 -1
  7. package/dist/cjs/docReview/segmentDocument.cjs +8 -5
  8. package/dist/cjs/docReview/segmentDocument.cjs.map +1 -1
  9. package/dist/cjs/init/cms.cjs +35 -0
  10. package/dist/cjs/init/cms.cjs.map +1 -1
  11. package/dist/cjs/init/documentationRouter.cjs +141 -0
  12. package/dist/cjs/init/documentationRouter.cjs.map +1 -0
  13. package/dist/cjs/init/frameworkSetup/backend/index.cjs +138 -0
  14. package/dist/cjs/init/frameworkSetup/backend/index.cjs.map +1 -0
  15. package/dist/cjs/init/frameworkSetup/backend/transforms.cjs +223 -0
  16. package/dist/cjs/init/frameworkSetup/backend/transforms.cjs.map +1 -0
  17. package/dist/cjs/init/frameworkSetup/index.cjs +9 -3
  18. package/dist/cjs/init/frameworkSetup/index.cjs.map +1 -1
  19. package/dist/cjs/init/frameworkSetup/localeRouting.cjs +13 -0
  20. package/dist/cjs/init/frameworkSetup/localeRouting.cjs.map +1 -0
  21. package/dist/cjs/init/frameworkSetup/nextAppRouter/index.cjs +34 -7
  22. package/dist/cjs/init/frameworkSetup/nextAppRouter/index.cjs.map +1 -1
  23. package/dist/cjs/init/frameworkSetup/nextAppRouter/templates.cjs +56 -0
  24. package/dist/cjs/init/frameworkSetup/nextAppRouter/templates.cjs.map +1 -1
  25. package/dist/cjs/init/frameworkSetup/nextAppRouter/transforms.cjs +6 -3
  26. package/dist/cjs/init/frameworkSetup/nextAppRouter/transforms.cjs.map +1 -1
  27. package/dist/cjs/init/frameworkSetup/tanstackStart/index.cjs +32 -3
  28. package/dist/cjs/init/frameworkSetup/tanstackStart/index.cjs.map +1 -1
  29. package/dist/cjs/init/frameworkSetup/tanstackStart/templates.cjs +58 -0
  30. package/dist/cjs/init/frameworkSetup/tanstackStart/templates.cjs.map +1 -1
  31. package/dist/cjs/init/frameworkSetup/tanstackStart/transforms.cjs +94 -14
  32. package/dist/cjs/init/frameworkSetup/tanstackStart/transforms.cjs.map +1 -1
  33. package/dist/cjs/init/index.cjs +46 -159
  34. package/dist/cjs/init/index.cjs.map +1 -1
  35. package/dist/cjs/init/utils/configManipulation.cjs +39 -0
  36. package/dist/cjs/init/utils/configManipulation.cjs.map +1 -1
  37. package/dist/cjs/init/utils/index.cjs +10 -0
  38. package/dist/cjs/init/utils/lintConfig.cjs +52 -0
  39. package/dist/cjs/init/utils/lintConfig.cjs.map +1 -0
  40. package/dist/cjs/init/utils/packageManager.cjs +62 -13
  41. package/dist/cjs/init/utils/packageManager.cjs.map +1 -1
  42. package/dist/cjs/init/utils/urlRoutingFramework.cjs +41 -0
  43. package/dist/cjs/init/utils/urlRoutingFramework.cjs.map +1 -0
  44. package/dist/cjs/initConfig/index.cjs +4 -1
  45. package/dist/cjs/initConfig/index.cjs.map +1 -1
  46. package/dist/cjs/installMCP/installMCP.cjs +1 -1
  47. package/dist/cjs/installMCP/installMCP.cjs.map +1 -1
  48. package/dist/cjs/loadDictionaries/loadLocalDictionaries.cjs +3 -1
  49. package/dist/cjs/loadDictionaries/loadLocalDictionaries.cjs.map +1 -1
  50. package/dist/cjs/loadDictionaries/loadRemoteDictionaries.cjs +1 -1
  51. package/dist/cjs/loadDictionaries/loadRemoteDictionaries.cjs.map +1 -1
  52. package/dist/cjs/loadDictionaries/log.cjs +1 -1
  53. package/dist/cjs/loadDictionaries/log.cjs.map +1 -1
  54. package/dist/cjs/loadDictionaries/logTypeScriptErrors.cjs +111 -43
  55. package/dist/cjs/loadDictionaries/logTypeScriptErrors.cjs.map +1 -1
  56. package/dist/cjs/scan/analyzeBundleContent.cjs +26 -12
  57. package/dist/cjs/scan/analyzeBundleContent.cjs.map +1 -1
  58. package/dist/cjs/scan/calculateScore.cjs +4 -1
  59. package/dist/cjs/scan/calculateScore.cjs.map +1 -1
  60. package/dist/cjs/scan/checks.cjs +394 -221
  61. package/dist/cjs/scan/checks.cjs.map +1 -1
  62. package/dist/cjs/scan/detection/checkDetails.cjs +56 -0
  63. package/dist/cjs/scan/detection/checkDetails.cjs.map +1 -0
  64. package/dist/cjs/scan/detection/classifyInternalLinks.cjs +47 -0
  65. package/dist/cjs/scan/detection/classifyInternalLinks.cjs.map +1 -0
  66. package/dist/cjs/scan/detection/detectRoutingStrategy.cjs +143 -0
  67. package/dist/cjs/scan/detection/detectRoutingStrategy.cjs.map +1 -0
  68. package/dist/cjs/scan/detection/detectTechnologies.cjs +89 -0
  69. package/dist/cjs/scan/detection/detectTechnologies.cjs.map +1 -0
  70. package/dist/cjs/scan/detection/index.cjs +36 -0
  71. package/dist/cjs/scan/detection/localeCode.cjs +118 -0
  72. package/dist/cjs/scan/detection/localeCode.cjs.map +1 -0
  73. package/dist/cjs/scan/detection/localizedPages.cjs +48 -0
  74. package/dist/cjs/scan/detection/localizedPages.cjs.map +1 -0
  75. package/dist/cjs/scan/detection/technologySignatures.cjs +564 -0
  76. package/dist/cjs/scan/detection/technologySignatures.cjs.map +1 -0
  77. package/dist/cjs/scan/detection/url.cjs +53 -0
  78. package/dist/cjs/scan/detection/url.cjs.map +1 -0
  79. package/dist/cjs/scan/fetchText.cjs +56 -0
  80. package/dist/cjs/scan/fetchText.cjs.map +1 -0
  81. package/dist/cjs/scan/index.cjs +59 -3
  82. package/dist/cjs/scan/parseHtml.cjs +55 -10
  83. package/dist/cjs/scan/parseHtml.cjs.map +1 -1
  84. package/dist/cjs/scan/robots.cjs +65 -0
  85. package/dist/cjs/scan/robots.cjs.map +1 -0
  86. package/dist/cjs/scan/runScanChecks.cjs +89 -0
  87. package/dist/cjs/scan/runScanChecks.cjs.map +1 -0
  88. package/dist/cjs/scan/scanWebsite.cjs +58 -52
  89. package/dist/cjs/scan/scanWebsite.cjs.map +1 -1
  90. package/dist/cjs/scan/sitemap.cjs +109 -0
  91. package/dist/cjs/scan/sitemap.cjs.map +1 -0
  92. package/dist/cjs/utils/chunkJSON.cjs +24 -9
  93. package/dist/cjs/utils/chunkJSON.cjs.map +1 -1
  94. package/dist/cjs/utils/getChunk.cjs +2 -2
  95. package/dist/cjs/utils/getChunk.cjs.map +1 -1
  96. package/dist/cjs/utils/runParallel/index.cjs +1 -1
  97. package/dist/cjs/utils/runParallel/index.cjs.map +1 -1
  98. package/dist/cjs/utils/runParallel/pidTree.cjs +23 -11
  99. package/dist/cjs/utils/runParallel/pidTree.cjs.map +1 -1
  100. package/dist/cjs/utils/runParallel/ps.cjs +8 -3
  101. package/dist/cjs/utils/runParallel/ps.cjs.map +1 -1
  102. package/dist/cjs/utils/runParallel/runTask.cjs +2 -1
  103. package/dist/cjs/utils/runParallel/runTask.cjs.map +1 -1
  104. package/dist/cjs/utils/runParallel/wmic.cjs +8 -3
  105. package/dist/cjs/utils/runParallel/wmic.cjs.map +1 -1
  106. package/dist/cjs/writeContentDeclaration/detectExportedComponentName.cjs +7 -4
  107. package/dist/cjs/writeContentDeclaration/detectExportedComponentName.cjs.map +1 -1
  108. package/dist/cjs/writeContentDeclaration/writeMarkdownFile.cjs +2 -2
  109. package/dist/cjs/writeContentDeclaration/writeMarkdownFile.cjs.map +1 -1
  110. package/dist/esm/cli.mjs +5 -3
  111. package/dist/esm/docReview/alignBlocks.mjs +53 -36
  112. package/dist/esm/docReview/alignBlocks.mjs.map +1 -1
  113. package/dist/esm/docReview/rebuildDocument.mjs +3 -1
  114. package/dist/esm/docReview/rebuildDocument.mjs.map +1 -1
  115. package/dist/esm/docReview/reviewReport.mjs.map +1 -1
  116. package/dist/esm/docReview/segmentDocument.mjs +8 -5
  117. package/dist/esm/docReview/segmentDocument.mjs.map +1 -1
  118. package/dist/esm/init/cms.mjs +35 -2
  119. package/dist/esm/init/cms.mjs.map +1 -1
  120. package/dist/esm/init/documentationRouter.mjs +139 -0
  121. package/dist/esm/init/documentationRouter.mjs.map +1 -0
  122. package/dist/esm/init/frameworkSetup/backend/index.mjs +130 -0
  123. package/dist/esm/init/frameworkSetup/backend/index.mjs.map +1 -0
  124. package/dist/esm/init/frameworkSetup/backend/transforms.mjs +216 -0
  125. package/dist/esm/init/frameworkSetup/backend/transforms.mjs.map +1 -0
  126. package/dist/esm/init/frameworkSetup/index.mjs +9 -3
  127. package/dist/esm/init/frameworkSetup/index.mjs.map +1 -1
  128. package/dist/esm/init/frameworkSetup/localeRouting.mjs +12 -0
  129. package/dist/esm/init/frameworkSetup/localeRouting.mjs.map +1 -0
  130. package/dist/esm/init/frameworkSetup/nextAppRouter/index.mjs +36 -9
  131. package/dist/esm/init/frameworkSetup/nextAppRouter/index.mjs.map +1 -1
  132. package/dist/esm/init/frameworkSetup/nextAppRouter/templates.mjs +54 -1
  133. package/dist/esm/init/frameworkSetup/nextAppRouter/templates.mjs.map +1 -1
  134. package/dist/esm/init/frameworkSetup/nextAppRouter/transforms.mjs +6 -3
  135. package/dist/esm/init/frameworkSetup/nextAppRouter/transforms.mjs.map +1 -1
  136. package/dist/esm/init/frameworkSetup/tanstackStart/index.mjs +35 -6
  137. package/dist/esm/init/frameworkSetup/tanstackStart/index.mjs.map +1 -1
  138. package/dist/esm/init/frameworkSetup/tanstackStart/templates.mjs +56 -1
  139. package/dist/esm/init/frameworkSetup/tanstackStart/templates.mjs.map +1 -1
  140. package/dist/esm/init/frameworkSetup/tanstackStart/transforms.mjs +94 -15
  141. package/dist/esm/init/frameworkSetup/tanstackStart/transforms.mjs.map +1 -1
  142. package/dist/esm/init/index.mjs +42 -158
  143. package/dist/esm/init/index.mjs.map +1 -1
  144. package/dist/esm/init/utils/configManipulation.mjs +38 -1
  145. package/dist/esm/init/utils/configManipulation.mjs.map +1 -1
  146. package/dist/esm/init/utils/index.mjs +5 -3
  147. package/dist/esm/init/utils/lintConfig.mjs +50 -0
  148. package/dist/esm/init/utils/lintConfig.mjs.map +1 -0
  149. package/dist/esm/init/utils/packageManager.mjs +60 -14
  150. package/dist/esm/init/utils/packageManager.mjs.map +1 -1
  151. package/dist/esm/init/utils/urlRoutingFramework.mjs +40 -0
  152. package/dist/esm/init/utils/urlRoutingFramework.mjs.map +1 -0
  153. package/dist/esm/initConfig/index.mjs +4 -1
  154. package/dist/esm/initConfig/index.mjs.map +1 -1
  155. package/dist/esm/installMCP/installMCP.mjs +1 -1
  156. package/dist/esm/installMCP/installMCP.mjs.map +1 -1
  157. package/dist/esm/loadDictionaries/loadLocalDictionaries.mjs +3 -1
  158. package/dist/esm/loadDictionaries/loadLocalDictionaries.mjs.map +1 -1
  159. package/dist/esm/loadDictionaries/loadRemoteDictionaries.mjs +1 -1
  160. package/dist/esm/loadDictionaries/loadRemoteDictionaries.mjs.map +1 -1
  161. package/dist/esm/loadDictionaries/log.mjs +1 -1
  162. package/dist/esm/loadDictionaries/log.mjs.map +1 -1
  163. package/dist/esm/loadDictionaries/logTypeScriptErrors.mjs +112 -44
  164. package/dist/esm/loadDictionaries/logTypeScriptErrors.mjs.map +1 -1
  165. package/dist/esm/scan/analyzeBundleContent.mjs +26 -12
  166. package/dist/esm/scan/analyzeBundleContent.mjs.map +1 -1
  167. package/dist/esm/scan/calculateScore.mjs +4 -1
  168. package/dist/esm/scan/calculateScore.mjs.map +1 -1
  169. package/dist/esm/scan/checks.mjs +387 -220
  170. package/dist/esm/scan/checks.mjs.map +1 -1
  171. package/dist/esm/scan/detection/checkDetails.mjs +54 -0
  172. package/dist/esm/scan/detection/checkDetails.mjs.map +1 -0
  173. package/dist/esm/scan/detection/classifyInternalLinks.mjs +46 -0
  174. package/dist/esm/scan/detection/classifyInternalLinks.mjs.map +1 -0
  175. package/dist/esm/scan/detection/detectRoutingStrategy.mjs +141 -0
  176. package/dist/esm/scan/detection/detectRoutingStrategy.mjs.map +1 -0
  177. package/dist/esm/scan/detection/detectTechnologies.mjs +87 -0
  178. package/dist/esm/scan/detection/detectTechnologies.mjs.map +1 -0
  179. package/dist/esm/scan/detection/index.mjs +10 -0
  180. package/dist/esm/scan/detection/localeCode.mjs +108 -0
  181. package/dist/esm/scan/detection/localeCode.mjs.map +1 -0
  182. package/dist/esm/scan/detection/localizedPages.mjs +46 -0
  183. package/dist/esm/scan/detection/localizedPages.mjs.map +1 -0
  184. package/dist/esm/scan/detection/technologySignatures.mjs +563 -0
  185. package/dist/esm/scan/detection/technologySignatures.mjs.map +1 -0
  186. package/dist/esm/scan/detection/url.mjs +47 -0
  187. package/dist/esm/scan/detection/url.mjs.map +1 -0
  188. package/dist/esm/scan/fetchText.mjs +55 -0
  189. package/dist/esm/scan/fetchText.mjs.map +1 -0
  190. package/dist/esm/scan/index.mjs +15 -3
  191. package/dist/esm/scan/parseHtml.mjs +52 -11
  192. package/dist/esm/scan/parseHtml.mjs.map +1 -1
  193. package/dist/esm/scan/robots.mjs +63 -0
  194. package/dist/esm/scan/robots.mjs.map +1 -0
  195. package/dist/esm/scan/runScanChecks.mjs +88 -0
  196. package/dist/esm/scan/runScanChecks.mjs.map +1 -0
  197. package/dist/esm/scan/scanWebsite.mjs +59 -53
  198. package/dist/esm/scan/scanWebsite.mjs.map +1 -1
  199. package/dist/esm/scan/sitemap.mjs +105 -0
  200. package/dist/esm/scan/sitemap.mjs.map +1 -0
  201. package/dist/esm/utils/chunkJSON.mjs +24 -9
  202. package/dist/esm/utils/chunkJSON.mjs.map +1 -1
  203. package/dist/esm/utils/getChunk.mjs +2 -2
  204. package/dist/esm/utils/getChunk.mjs.map +1 -1
  205. package/dist/esm/utils/runParallel/index.mjs +1 -1
  206. package/dist/esm/utils/runParallel/index.mjs.map +1 -1
  207. package/dist/esm/utils/runParallel/pidTree.mjs +23 -11
  208. package/dist/esm/utils/runParallel/pidTree.mjs.map +1 -1
  209. package/dist/esm/utils/runParallel/ps.mjs +8 -3
  210. package/dist/esm/utils/runParallel/ps.mjs.map +1 -1
  211. package/dist/esm/utils/runParallel/runTask.mjs +2 -1
  212. package/dist/esm/utils/runParallel/runTask.mjs.map +1 -1
  213. package/dist/esm/utils/runParallel/wmic.mjs +8 -3
  214. package/dist/esm/utils/runParallel/wmic.mjs.map +1 -1
  215. package/dist/esm/writeContentDeclaration/detectExportedComponentName.mjs +7 -4
  216. package/dist/esm/writeContentDeclaration/detectExportedComponentName.mjs.map +1 -1
  217. package/dist/esm/writeContentDeclaration/writeMarkdownFile.mjs +2 -2
  218. package/dist/esm/writeContentDeclaration/writeMarkdownFile.mjs.map +1 -1
  219. package/dist/types/cli.d.ts +5 -3
  220. package/dist/types/docReview/rebuildDocument.d.ts.map +1 -1
  221. package/dist/types/docReview/reviewReport.d.ts.map +1 -1
  222. package/dist/types/docReview/segmentDocument.d.ts.map +1 -1
  223. package/dist/types/formatDictionary.d.ts +2 -2
  224. package/dist/types/init/cms.d.ts +11 -0
  225. package/dist/types/init/cms.d.ts.map +1 -1
  226. package/dist/types/init/documentationRouter.d.ts +64 -0
  227. package/dist/types/init/documentationRouter.d.ts.map +1 -0
  228. package/dist/types/init/frameworkSetup/backend/index.d.ts +16 -0
  229. package/dist/types/init/frameworkSetup/backend/index.d.ts.map +1 -0
  230. package/dist/types/init/frameworkSetup/backend/transforms.d.ts +37 -0
  231. package/dist/types/init/frameworkSetup/backend/transforms.d.ts.map +1 -0
  232. package/dist/types/init/frameworkSetup/index.d.ts.map +1 -1
  233. package/dist/types/init/frameworkSetup/localeRouting.d.ts +11 -0
  234. package/dist/types/init/frameworkSetup/localeRouting.d.ts.map +1 -0
  235. package/dist/types/init/frameworkSetup/nextAppRouter/index.d.ts +5 -5
  236. package/dist/types/init/frameworkSetup/nextAppRouter/index.d.ts.map +1 -1
  237. package/dist/types/init/frameworkSetup/nextAppRouter/templates.d.ts +12 -0
  238. package/dist/types/init/frameworkSetup/nextAppRouter/templates.d.ts.map +1 -1
  239. package/dist/types/init/frameworkSetup/nextAppRouter/transforms.d.ts +10 -1
  240. package/dist/types/init/frameworkSetup/nextAppRouter/transforms.d.ts.map +1 -1
  241. package/dist/types/init/frameworkSetup/tanstackStart/index.d.ts +3 -2
  242. package/dist/types/init/frameworkSetup/tanstackStart/index.d.ts.map +1 -1
  243. package/dist/types/init/frameworkSetup/tanstackStart/templates.d.ts +10 -0
  244. package/dist/types/init/frameworkSetup/tanstackStart/templates.d.ts.map +1 -1
  245. package/dist/types/init/frameworkSetup/tanstackStart/transforms.d.ts +12 -0
  246. package/dist/types/init/frameworkSetup/tanstackStart/transforms.d.ts.map +1 -1
  247. package/dist/types/init/frameworkSetup/types.d.ts +6 -0
  248. package/dist/types/init/frameworkSetup/types.d.ts.map +1 -1
  249. package/dist/types/init/index.d.ts +15 -1
  250. package/dist/types/init/index.d.ts.map +1 -1
  251. package/dist/types/init/utils/configManipulation.d.ts +14 -0
  252. package/dist/types/init/utils/configManipulation.d.ts.map +1 -1
  253. package/dist/types/init/utils/index.d.ts +5 -3
  254. package/dist/types/init/utils/lintConfig.d.ts +28 -0
  255. package/dist/types/init/utils/lintConfig.d.ts.map +1 -0
  256. package/dist/types/init/utils/packageManager.d.ts +29 -6
  257. package/dist/types/init/utils/packageManager.d.ts.map +1 -1
  258. package/dist/types/init/utils/urlRoutingFramework.d.ts +9 -0
  259. package/dist/types/init/utils/urlRoutingFramework.d.ts.map +1 -0
  260. package/dist/types/initConfig/index.d.ts +3 -1
  261. package/dist/types/initConfig/index.d.ts.map +1 -1
  262. package/dist/types/loadDictionaries/logTypeScriptErrors.d.ts +4 -0
  263. package/dist/types/loadDictionaries/logTypeScriptErrors.d.ts.map +1 -1
  264. package/dist/types/scan/analyzeBundleContent.d.ts.map +1 -1
  265. package/dist/types/scan/calculateScore.d.ts +4 -1
  266. package/dist/types/scan/calculateScore.d.ts.map +1 -1
  267. package/dist/types/scan/checks.d.ts +114 -21
  268. package/dist/types/scan/checks.d.ts.map +1 -1
  269. package/dist/types/scan/detection/checkDetails.d.ts +29 -0
  270. package/dist/types/scan/detection/checkDetails.d.ts.map +1 -0
  271. package/dist/types/scan/detection/classifyInternalLinks.d.ts +44 -0
  272. package/dist/types/scan/detection/classifyInternalLinks.d.ts.map +1 -0
  273. package/dist/types/scan/detection/detectRoutingStrategy.d.ts +60 -0
  274. package/dist/types/scan/detection/detectRoutingStrategy.d.ts.map +1 -0
  275. package/dist/types/scan/detection/detectTechnologies.d.ts +60 -0
  276. package/dist/types/scan/detection/detectTechnologies.d.ts.map +1 -0
  277. package/dist/types/scan/detection/index.d.ts +9 -0
  278. package/dist/types/scan/detection/localeCode.d.ts +49 -0
  279. package/dist/types/scan/detection/localeCode.d.ts.map +1 -0
  280. package/dist/types/scan/detection/localizedPages.d.ts +40 -0
  281. package/dist/types/scan/detection/localizedPages.d.ts.map +1 -0
  282. package/dist/types/scan/detection/technologySignatures.d.ts +48 -0
  283. package/dist/types/scan/detection/technologySignatures.d.ts.map +1 -0
  284. package/dist/types/scan/detection/url.d.ts +27 -0
  285. package/dist/types/scan/detection/url.d.ts.map +1 -0
  286. package/dist/types/scan/fetchText.d.ts +30 -0
  287. package/dist/types/scan/fetchText.d.ts.map +1 -0
  288. package/dist/types/scan/index.d.ts +16 -4
  289. package/dist/types/scan/parseHtml.d.ts +17 -0
  290. package/dist/types/scan/parseHtml.d.ts.map +1 -1
  291. package/dist/types/scan/robots.d.ts +23 -0
  292. package/dist/types/scan/robots.d.ts.map +1 -0
  293. package/dist/types/scan/runScanChecks.d.ts +43 -0
  294. package/dist/types/scan/runScanChecks.d.ts.map +1 -0
  295. package/dist/types/scan/scanWebsite.d.ts.map +1 -1
  296. package/dist/types/scan/sitemap.d.ts +49 -0
  297. package/dist/types/scan/sitemap.d.ts.map +1 -0
  298. package/dist/types/scan/types.d.ts +15 -0
  299. package/dist/types/scan/types.d.ts.map +1 -1
  300. package/dist/types/utils/chunkJSON.d.ts.map +1 -1
  301. package/dist/types/utils/runParallel/pidTree.d.ts.map +1 -1
  302. package/dist/types/writeContentDeclaration/writeMarkdownFile.d.ts.map +1 -1
  303. package/package.json +16 -8
@@ -1 +1 @@
1
- {"version":3,"file":"packageManager.mjs","names":[],"sources":["../../../../src/init/utils/packageManager.ts"],"sourcesContent":["import { execSync } from 'node:child_process';\nimport { existsSync, readFileSync } from 'node:fs';\nimport { dirname, join, resolve } from 'node:path';\n\n/** Package managers supported for dependency installation. */\nexport type PackageManager = 'bun' | 'pnpm' | 'yarn' | 'npm';\n\n/**\n * Configuration for the syncJSON plugin injected into intlayer.config\n * when a compat i18n library is detected.\n */\nexport type CompatSyncConfig = {\n /**\n * Which sync plugin ingests the catalogs:\n * - `'json'` → `syncJSON` from `@intlayer/sync-json-plugin` (default).\n * - `'po'` → `syncPO` from `@intlayer/sync-po-plugin` (lingui's default\n * format).\n */\n plugin?: 'json' | 'po';\n /**\n * JSON format matching the compat library's conventions. Ignored when\n * `plugin` is `'po'` (PO catalogs are always serialized as gettext).\n */\n format: 'icu' | 'i18next' | 'vue-i18n';\n /**\n * Source path template using ${locale} and ${key} placeholders.\n * Rendered as a template literal in the generated config.\n */\n sourceTemplate: string;\n /**\n * Force `splitKeys: true` in the generated `syncJSON(...)` call so each\n * top-level key of a single per-locale file becomes its own dictionary.\n *\n * Set for libraries whose single `messages/${locale}.json` file groups\n * namespaces by its first-level keys (`next-intl` / `use-intl`, where\n * `useTranslations('Hero')` resolves to the `Hero` dictionary). Left\n * undefined for libraries whose top-level keys are plain message keys\n * (e.g. `i18next`, `react-intl`); for those, syncJSON's auto-detection\n * (split only when the source has no `${key}` segment) stays in control.\n *\n * Only meaningful for flat templates (no `${key}` segment); it is dropped\n * automatically when the resolved template addresses one namespace per file.\n */\n splitKeys?: boolean;\n};\n\n/**\n * Configuration for injecting a compat vite plugin into vite.config.\n * The plugin replaces the generic `intlayer` plugin for libraries that\n * require alias injection (e.g. `vue-i18n` → `@intlayer/vue-i18n`).\n */\nexport type CompatVitePluginConfig = {\n /** Exported function name from the plugin package, e.g. `'vueI18nVitePlugin'`. */\n pluginFunctionName: string;\n /** Import path for the plugin package, e.g. `'@intlayer/vue-i18n/plugin'`. */\n pluginPackageSource: string;\n /**\n * Set when the compat plugin is a drop-in replacement for an i18n library's\n * own Vite plugin (e.g. lingui ships `@lingui/vite-plugin`). When the original\n * import is present, init rewrites only that import's module source to\n * `pluginPackageSource` — keeping the binding and its call site — instead of\n * injecting a second import and appending another plugin to the array.\n */\n replacesVitePlugin?: {\n /** Imported binding to keep, e.g. `'lingui'`. */\n importName: string;\n /** Original package source to rewrite, e.g. `'@lingui/vite-plugin'`. */\n fromPackageSource: string;\n };\n};\n\n/** Result of analyzing project dependencies for intlayer package gaps. */\nexport type IntlayerPackageAnalysis = {\n /** Intlayer packages that are referenced but not yet installed. */\n packagesToInstall: string[];\n /** Intlayer dev packages that are referenced but not yet installed. */\n devPackagesToInstall: string[];\n /** Compat packages in dependencies that got replaced and should be moved to devDependencies. */\n packagesToMoveToDev: string[];\n /**\n * syncJSON plugin configuration to inject when a compat i18n library is\n * detected. Undefined when no compat library is present or format is not\n * yet implemented.\n */\n compatSyncConfig: CompatSyncConfig | undefined;\n /**\n * Vite config plugin to inject when a vite-based compat library is\n * detected. Undefined for Next.js/Nuxt-only compat libs or when no compat\n * library requires alias injection.\n */\n compatVitePluginConfig: CompatVitePluginConfig | undefined;\n};\n\n/** Lock files revealing the package manager, in detection priority order. */\nconst LOCK_FILE_PACKAGE_MANAGERS: ReadonlyArray<\n readonly [lockFile: string, packageManager: PackageManager]\n> = [\n ['bun.lock', 'bun'],\n ['bun.lockb', 'bun'],\n ['pnpm-lock.yaml', 'pnpm'],\n ['yarn.lock', 'yarn'],\n ['package-lock.json', 'npm'],\n];\n\n/** Package managers accepted in the `packageManager` field of `package.json`. */\nconst PACKAGE_MANAGERS: readonly PackageManager[] = [\n 'bun',\n 'pnpm',\n 'yarn',\n 'npm',\n];\n\n/**\n * Reads the package manager pinned by the `packageManager` field of the\n * `package.json` in `directory` (e.g. `\"pnpm@9.0.0\"`), if any.\n */\nconst readPackageManagerField = (directory: string): PackageManager | null => {\n try {\n const { packageManager } = JSON.parse(\n readFileSync(join(directory, 'package.json'), 'utf8')\n ) as { packageManager?: unknown };\n\n if (typeof packageManager !== 'string') return null;\n\n const name = packageManager.split('@')[0] as PackageManager;\n return PACKAGE_MANAGERS.includes(name) ? name : null;\n } catch {\n return null;\n }\n};\n\n/**\n * Detects the package manager in use by checking for lock files in the\n * project root, then the `packageManager` field of its `package.json`. Falls\n * back to npm when neither is found.\n */\nexport const detectPackageManager = (rootDir: string): PackageManager =>\n LOCK_FILE_PACKAGE_MANAGERS.find(([lockFile]) =>\n existsSync(join(rootDir, lockFile))\n )?.[1] ??\n readPackageManagerField(rootDir) ??\n 'npm';\n\n/**\n * Walks up from `startDir` to the nearest directory holding a lock file — the\n * workspace root an install must run from. Stops at the repository root\n * (`.git`) and returns `null` when no lock file is found.\n */\nexport const findLockFileDir = (startDir: string): string | null => {\n let currentDir = resolve(startDir);\n\n while (true) {\n const hasLockFile = LOCK_FILE_PACKAGE_MANAGERS.some(([lockFile]) =>\n existsSync(join(currentDir, lockFile))\n );\n if (hasLockFile) return currentDir;\n if (existsSync(join(currentDir, '.git'))) return null;\n\n const parentDir = dirname(currentDir);\n if (parentDir === currentDir) return null;\n currentDir = parentDir;\n }\n};\n\n/**\n * Returns the install command for the given package manager and package list.\n */\nconst buildInstallCommand = (\n packageManager: PackageManager,\n packages: string[],\n isDev: boolean = false\n): string => {\n const packageList = packages.join(' ');\n switch (packageManager) {\n case 'bun':\n return `bun add ${isDev ? '-d ' : ''}${packageList}`;\n case 'pnpm':\n return `pnpm add ${isDev ? '-D ' : ''}${packageList}`;\n case 'yarn':\n return `yarn add ${isDev ? '-D ' : ''}${packageList}`;\n case 'npm':\n return `npm install ${isDev ? '-D ' : ''}${packageList}`;\n }\n};\n\n/**\n * Analyzes existing project dependencies to determine which intlayer packages\n * are missing and what syncJSON configuration to inject when compat i18n\n * libraries are present.\n */\n/** Extra signals (from a filesystem scan) that refine compat detection. */\nexport type DetectMissingPackagesOptions = {\n /**\n * Catalog format detected for a lingui project (`'po'` or `'json'`), or\n * `null`/undefined when none was found. Decides which sync plugin + dev\n * dependency the lingui compat setup uses.\n */\n linguiCatalogFormat?: 'po' | 'json' | null;\n /**\n * The project's runtime dependencies (from `package.json` `dependencies`).\n * When provided, compat packages found here that are replaced by `@intlayer/*`\n * are reported in `packagesToMoveToDev`.\n */\n dependencies?: Record<string, string>;\n /**\n * The project's development dependencies (from `package.json` `devDependencies`).\n */\n devDependencies?: Record<string, string>;\n};\n\n/** An existing i18n library Intlayer ships a compat adapter for. */\nexport type CompatI18nLibrary = {\n /** Human-readable name, used to report the detection back to the user. */\n label: string;\n /**\n * Dependency names that reveal the library — both the upstream packages and\n * the Intlayer adapters, so a project that already ran `init` is still\n * recognized.\n */\n packages: readonly string[];\n /**\n * Upstream third-party packages replaced by Intlayer compat adapters at runtime,\n * mapped to their adapter package name.\n */\n replacements: Record<string, string>;\n};\n\n/**\n * Existing i18n libraries Intlayer can adapt, keyed by the dependencies that\n * reveal them. Mirrors the compat branches of\n * {@link detectMissingIntlayerPackages}: a library listed here is one that\n * detection will wire up on its own once its package is in `package.json`.\n */\nexport const COMPAT_I18N_LIBRARIES: readonly CompatI18nLibrary[] = [\n {\n label: 'i18next / react-i18next',\n packages: [\n 'i18next',\n 'react-i18next',\n '@intlayer/i18next',\n '@intlayer/react-i18next',\n ],\n replacements: {\n i18next: '@intlayer/i18next',\n 'react-i18next': '@intlayer/react-i18next',\n },\n },\n {\n label: 'next-intl / use-intl',\n packages: [\n 'next-intl',\n 'use-intl',\n '@intlayer/next-intl',\n '@intlayer/use-intl',\n ],\n replacements: {\n 'next-intl': '@intlayer/next-intl',\n 'use-intl': '@intlayer/use-intl',\n },\n },\n {\n label: 'vue-i18n',\n packages: ['vue-i18n', '@intlayer/vue-i18n'],\n replacements: {\n 'vue-i18n': '@intlayer/vue-i18n',\n },\n },\n {\n label: '@nuxtjs/i18n',\n packages: ['@nuxtjs/i18n', '@intlayer/nuxtjs-i18n'],\n replacements: {\n '@nuxtjs/i18n': '@intlayer/nuxtjs-i18n',\n },\n },\n {\n label: 'next-i18next',\n packages: ['next-i18next', '@intlayer/next-i18next'],\n replacements: {\n 'next-i18next': '@intlayer/next-i18next',\n },\n },\n {\n label: 'next-translate',\n packages: ['next-translate', '@intlayer/next-translate'],\n replacements: {\n 'next-translate': '@intlayer/next-translate',\n },\n },\n {\n label: 'react-intl',\n packages: ['react-intl', '@intlayer/react-intl'],\n replacements: {\n 'react-intl': '@intlayer/react-intl',\n },\n },\n {\n label: 'Lingui',\n packages: ['@lingui/core', '@lingui/react', '@intlayer/lingui'],\n replacements: {\n '@lingui/core': '@intlayer/lingui',\n '@lingui/react': '@intlayer/lingui',\n },\n },\n {\n label: 'svelte-i18n',\n packages: ['svelte-i18n', '@intlayer/svelte-i18n'],\n replacements: {\n 'svelte-i18n': '@intlayer/svelte-i18n',\n },\n },\n {\n label: '@ngneat/transloco',\n packages: ['@ngneat/transloco', '@intlayer/transloco'],\n replacements: {\n '@ngneat/transloco': '@intlayer/transloco',\n },\n },\n {\n label: '@ngx-translate/core',\n packages: ['@ngx-translate/core', '@intlayer/ngx-translate'],\n replacements: {\n '@ngx-translate/core': '@intlayer/ngx-translate',\n },\n },\n {\n label: 'node-polyglot',\n packages: ['node-polyglot', '@intlayer/polyglot'],\n replacements: {\n 'node-polyglot': '@intlayer/polyglot',\n },\n },\n {\n label: 'i18n-js',\n packages: ['i18n-js', '@intlayer/i18n-js'],\n replacements: {\n 'i18n-js': '@intlayer/i18n-js',\n },\n },\n];\n\n/**\n * Maps third-party i18n libraries to the Intlayer compat adapter that replaces\n * them at runtime, derived from {@link COMPAT_I18N_LIBRARIES}.\n */\nexport const COMPAT_PACKAGE_REPLACEMENTS: Record<string, string> =\n Object.fromEntries(\n COMPAT_I18N_LIBRARIES.flatMap((library) =>\n Object.entries(library.replacements)\n )\n );\n\n/**\n * When a project uses a compat i18n package (such as `next-intl`) that gets\n * replaced by an `@intlayer/*` adapter (e.g. `@intlayer/next-intl`), moves the\n * original package from `dependencies` to `devDependencies` in `package.json`.\n *\n * Returns the list of package names that were moved.\n */\nexport const moveCompatPackagesToDevDependencies = (\n packageJson: Record<string, any>\n): string[] => {\n const movedPackages: string[] = [];\n if (!packageJson.dependencies) return movedPackages;\n\n for (const compatPackage of Object.keys(COMPAT_PACKAGE_REPLACEMENTS)) {\n if (packageJson.dependencies[compatPackage]) {\n const version = packageJson.dependencies[compatPackage];\n delete packageJson.dependencies[compatPackage];\n\n packageJson.devDependencies = packageJson.devDependencies ?? {};\n if (!packageJson.devDependencies[compatPackage]) {\n packageJson.devDependencies[compatPackage] = version;\n }\n movedPackages.push(compatPackage);\n }\n }\n\n return movedPackages;\n};\n\n/**\n * Returns the labels of the compat i18n libraries present in `dependencies`.\n *\n * Lets the init flow report (and branch on) the libraries it found without\n * asking the user, since {@link detectMissingIntlayerPackages} already derives\n * the adapters, sync plugin and config from the very same dependency map.\n *\n * @param dependencies - Merged dependencies of the target project.\n */\nexport const detectCompatI18nLibraries = (\n dependencies: Record<string, string>\n): string[] =>\n COMPAT_I18N_LIBRARIES.filter((library) =>\n library.packages.some((packageName) => Boolean(dependencies[packageName]))\n ).map((library) => library.label);\n\n/**\n * True when the project already lints, and so has something to plug the\n * Intlayer lint rules into.\n *\n * `eslint-plugin-intlayer` loads in both ESLint and oxlint, so either linter is\n * enough. Shared with the init flow so that installing the plugin and wiring up\n * its configuration are gated on exactly the same condition — a project that\n * does not lint is left alone entirely.\n *\n * @param dependencies - Merged dependencies of the target project.\n */\nexport const hasLintTooling = (dependencies: Record<string, string>): boolean =>\n Boolean(dependencies.eslint) || Boolean(dependencies.oxlint);\n\nexport const detectMissingIntlayerPackages = (\n allDependencies: Record<string, string>,\n options: DetectMissingPackagesOptions = {}\n): IntlayerPackageAnalysis => {\n const packagesToInstall: string[] = [];\n const devPackagesToInstall: string[] = [];\n const packagesToMoveToDev: string[] = [];\n\n let compatSyncConfig: CompatSyncConfig | undefined;\n let compatVitePluginConfig: CompatVitePluginConfig | undefined;\n\n const isInstalled = (packageName: string): boolean =>\n Boolean(allDependencies[packageName]);\n\n const addIfMissing = (packageName: string): void => {\n if (!isInstalled(packageName)) {\n packagesToInstall.push(packageName);\n }\n };\n\n const addDevIfMissing = (packageName: string): void => {\n if (!isInstalled(packageName)) {\n devPackagesToInstall.push(packageName);\n }\n };\n\n const markCompatReplacement = (\n originalPackage: string,\n adapterPackage: string\n ): void => {\n addIfMissing(adapterPackage);\n addDevIfMissing(originalPackage);\n\n const isExplicitDev = Boolean(options.devDependencies?.[originalPackage]);\n const isExplicitProd = Boolean(options.dependencies?.[originalPackage]);\n const isImplicitProd =\n !options.dependencies &&\n !options.devDependencies &&\n Boolean(allDependencies[originalPackage]);\n\n if ((isExplicitProd || isImplicitProd) && !isExplicitDev) {\n if (!packagesToMoveToDev.includes(originalPackage)) {\n packagesToMoveToDev.push(originalPackage);\n }\n }\n };\n\n // Core package — always required\n addIfMissing('intlayer');\n\n const isReactNativeProject =\n isInstalled('react-native') || isInstalled('expo');\n\n // Framework-specific runtime integrations\n if (isInstalled('next')) {\n addIfMissing('next-intlayer');\n } else if (isReactNativeProject) {\n addIfMissing('react-native-intlayer');\n } else if (isInstalled('react')) {\n addIfMissing('react-intlayer');\n }\n\n if (isInstalled('svelte')) {\n addIfMissing('svelte-intlayer');\n }\n\n if (isInstalled('solid-js')) {\n addIfMissing('solid-intlayer');\n }\n\n if (isInstalled('@angular/core')) {\n addIfMissing('angular-intlayer');\n }\n\n if (isInstalled('vue')) {\n addIfMissing('vue-intlayer');\n }\n\n if (isInstalled('vite')) {\n addIfMissing('vite-intlayer');\n }\n\n // Lint rules — only when the project already lints.\n if (hasLintTooling(allDependencies)) {\n addDevIfMissing('eslint-plugin-intlayer');\n }\n\n // -------------------------------------------------------------------------\n // Compat adapters for existing i18n libraries.\n //\n // Detection order matters: more specific libraries are checked first so that\n // `compatSyncConfig ??=` and `compatVitePluginConfig ??=` capture the most\n // relevant match. Libraries that only affect the Next.js or Nuxt config do\n // not set `compatVitePluginConfig` (handled separately in init/index.ts).\n // Libraries whose JSON format is not yet supported leave `compatSyncConfig`\n // undefined so no syncJSON plugin is injected.\n // -------------------------------------------------------------------------\n\n // next-intl — next.js only, ICU format. Default layout is a single file per\n // locale (`messages/${locale}.json`) whose top-level keys are namespaces;\n // syncJSON `splitKeys` auto-detection (no `${key}` segment) turns each\n // top-level key into its own dictionary. The exact path is refined from\n // `i18n/request.ts` in init/index.ts when present.\n if (isInstalled('next-intl') || isInstalled('@intlayer/next-intl')) {\n markCompatReplacement('next-intl', '@intlayer/next-intl');\n compatSyncConfig ??= {\n format: 'icu',\n sourceTemplate: './messages/${locale}.json',\n // next-intl groups namespaces by the first-level keys of one file.\n splitKeys: true,\n };\n // next config handled via updateNextConfigForNextIntl in init/index.ts\n }\n\n // next-i18next — next.js only, i18next JSON format\n if (isInstalled('next-i18next') || isInstalled('@intlayer/next-i18next')) {\n markCompatReplacement('next-i18next', '@intlayer/next-i18next');\n compatSyncConfig ??= {\n format: 'i18next',\n sourceTemplate: './src/locales/${locale}/${key}.json',\n };\n // next config handled via updateNextConfigForNextI18next in init/index.ts\n }\n\n // next-translate — next.js only, i18next-style flat-namespace JSON\n if (\n isInstalled('next-translate') ||\n isInstalled('@intlayer/next-translate')\n ) {\n markCompatReplacement('next-translate', '@intlayer/next-translate');\n compatSyncConfig ??= {\n format: 'i18next',\n sourceTemplate: './locales/${locale}/${key}.json',\n };\n // next config handled via updateNextConfigForNextTranslate in init/index.ts\n }\n\n // i18next — vite alias injection (`i18next` → `@intlayer/i18next`) so existing\n // `import … from 'i18next'` is served by Intlayer without touching call sites.\n if (isInstalled('i18next') || isInstalled('@intlayer/i18next')) {\n markCompatReplacement('i18next', '@intlayer/i18next');\n compatSyncConfig ??= {\n format: 'i18next',\n sourceTemplate: './src/locales/${locale}/${key}.json',\n };\n // When react-i18next is also present, its wrapper plugin aliases both\n // `react-i18next` and `i18next`, so it must win — only inject the bare\n // i18next plugin when no React wrapper is installed.\n if (\n !isInstalled('react-i18next') &&\n !isInstalled('@intlayer/react-i18next')\n ) {\n compatVitePluginConfig ??= {\n pluginFunctionName: 'i18nextVitePlugin',\n pluginPackageSource: '@intlayer/i18next/plugin',\n };\n }\n }\n\n // react-i18next — vite alias injection (`react-i18next` → `@intlayer/react-i18next`\n // and `i18next` → `@intlayer/i18next`) so components keep importing from\n // `react-i18next` unchanged.\n if (isInstalled('react-i18next') || isInstalled('@intlayer/react-i18next')) {\n markCompatReplacement('react-i18next', '@intlayer/react-i18next');\n compatSyncConfig ??= {\n format: 'i18next',\n sourceTemplate: './src/locales/${locale}/${key}.json',\n };\n compatVitePluginConfig ??= {\n pluginFunctionName: 'reactI18nextVitePlugin',\n pluginPackageSource: '@intlayer/react-i18next/plugin',\n };\n }\n\n // vue-i18n — vite alias injection required\n if (isInstalled('vue-i18n') || isInstalled('@intlayer/vue-i18n')) {\n markCompatReplacement('vue-i18n', '@intlayer/vue-i18n');\n compatSyncConfig ??= {\n format: 'vue-i18n',\n sourceTemplate: './locales/${locale}/${key}.json',\n };\n compatVitePluginConfig ??= {\n pluginFunctionName: 'vueI18nVitePlugin',\n pluginPackageSource: '@intlayer/vue-i18n/plugin',\n };\n }\n\n // use-intl — framework-agnostic React core of next-intl; vite alias\n // injection required, ICU format. Commonly a single `messages/${locale}.json`\n // file whose top-level keys are namespaces, handled by syncJSON `splitKeys`\n // auto-detection (no `${key}` segment in the source template).\n if (isInstalled('use-intl') || isInstalled('@intlayer/use-intl')) {\n markCompatReplacement('use-intl', '@intlayer/use-intl');\n compatSyncConfig ??= {\n format: 'icu',\n sourceTemplate: './messages/${locale}.json',\n // use-intl (the core of next-intl) uses the same single-file namespace model.\n splitKeys: true,\n };\n compatVitePluginConfig ??= {\n pluginFunctionName: 'useIntlVitePlugin',\n pluginPackageSource: '@intlayer/use-intl/plugin',\n };\n }\n\n // react-intl — vite alias injection required, ICU format\n if (isInstalled('react-intl') || isInstalled('@intlayer/react-intl')) {\n markCompatReplacement('react-intl', '@intlayer/react-intl');\n compatSyncConfig ??= {\n format: 'icu',\n sourceTemplate: './src/i18n/${locale}.json',\n };\n compatVitePluginConfig ??= {\n pluginFunctionName: 'reactIntlVitePlugin',\n pluginPackageSource: '@intlayer/react-intl/plugin',\n };\n }\n\n // @ngneat/transloco — vite alias injection required\n // @todo syncJSON format not yet implemented for transloco\n if (isInstalled('@ngneat/transloco') || isInstalled('@intlayer/transloco')) {\n markCompatReplacement('@ngneat/transloco', '@intlayer/transloco');\n compatVitePluginConfig ??= {\n pluginFunctionName: 'translocoVitePlugin',\n pluginPackageSource: '@intlayer/transloco/plugin',\n };\n }\n\n // svelte-i18n — vite alias injection required, flat JSON (i18next-compatible)\n if (isInstalled('svelte-i18n') || isInstalled('@intlayer/svelte-i18n')) {\n markCompatReplacement('svelte-i18n', '@intlayer/svelte-i18n');\n compatSyncConfig ??= {\n format: 'i18next',\n sourceTemplate: './src/locales/${locale}.json',\n };\n compatVitePluginConfig ??= {\n pluginFunctionName: 'svelteI18nVitePlugin',\n pluginPackageSource: '@intlayer/svelte-i18n/plugin',\n };\n }\n\n // node-polyglot — vite alias injection required\n // @todo syncJSON format not yet implemented for polyglot\n if (isInstalled('node-polyglot') || isInstalled('@intlayer/polyglot')) {\n markCompatReplacement('node-polyglot', '@intlayer/polyglot');\n compatVitePluginConfig ??= {\n pluginFunctionName: 'polyglotVitePlugin',\n pluginPackageSource: '@intlayer/polyglot/plugin',\n };\n }\n\n // @nuxtjs/i18n — nuxt module (no vite plugin), vue-i18n JSON format\n if (isInstalled('@nuxtjs/i18n') || isInstalled('@intlayer/nuxtjs-i18n')) {\n markCompatReplacement('@nuxtjs/i18n', '@intlayer/nuxtjs-i18n');\n compatSyncConfig ??= {\n format: 'vue-i18n',\n sourceTemplate: './locales/${locale}/${key}.json',\n };\n // nuxt config handled via updateNuxtConfigForNuxtjsI18n in init/index.ts\n }\n\n // @ngx-translate/core — vite alias injection required, flat JSON (i18next)\n if (\n isInstalled('@ngx-translate/core') ||\n isInstalled('@intlayer/ngx-translate')\n ) {\n markCompatReplacement('@ngx-translate/core', '@intlayer/ngx-translate');\n compatSyncConfig ??= {\n format: 'i18next',\n sourceTemplate: './assets/i18n/${locale}.json',\n };\n compatVitePluginConfig ??= {\n pluginFunctionName: 'ngxTranslateVitePlugin',\n pluginPackageSource: '@intlayer/ngx-translate/plugin',\n };\n }\n\n // @lingui/core — vite alias injection required.\n // lingui keeps one catalog file per locale (default name `messages`), as\n // `.po` (its default) or `.json`. The catalog filename is captured by the\n // `${key}` segment so the produced dictionary key is `messages`, matching the\n // fixed `messages` namespace the lingui compat runtime reads from.\n if (\n isInstalled('@lingui/core') ||\n isInstalled('@lingui/react') ||\n isInstalled('@intlayer/lingui')\n ) {\n markCompatReplacement('@lingui/core', '@intlayer/lingui');\n\n if (isInstalled('@lingui/react')) {\n markCompatReplacement('@lingui/react', '@intlayer/lingui');\n }\n\n const linguiUsesPo = options.linguiCatalogFormat === 'po';\n compatSyncConfig ??= linguiUsesPo\n ? {\n plugin: 'po',\n format: 'icu',\n sourceTemplate: './src/locales/${locale}/${key}.po',\n }\n : {\n plugin: 'json',\n format: 'icu',\n sourceTemplate: './src/locales/${locale}/${key}.json',\n };\n\n compatVitePluginConfig ??= {\n // `@intlayer/lingui/plugin` exports `lingui` as a drop-in replacement for\n // `@lingui/vite-plugin`, so a fresh project gets `lingui()` injected and a\n // project already using `@lingui/vite-plugin` only has its import source\n // rewritten (see `replacesVitePlugin`).\n pluginFunctionName: 'lingui',\n pluginPackageSource: '@intlayer/lingui/plugin',\n replacesVitePlugin: {\n importName: 'lingui',\n fromPackageSource: '@lingui/vite-plugin',\n },\n };\n }\n\n // i18n-js — vite alias injection required\n // @todo syncJSON format not yet implemented for i18n-js\n if (isInstalled('i18n-js') || isInstalled('@intlayer/i18n-js')) {\n markCompatReplacement('i18n-js', '@intlayer/i18n-js');\n compatVitePluginConfig ??= {\n pluginFunctionName: 'i18nJsVitePlugin',\n pluginPackageSource: '@intlayer/i18n-js/plugin',\n };\n }\n\n if (compatSyncConfig) {\n addDevIfMissing(\n compatSyncConfig.plugin === 'po'\n ? '@intlayer/sync-po-plugin'\n : '@intlayer/sync-json-plugin'\n );\n }\n\n return {\n packagesToInstall,\n devPackagesToInstall,\n packagesToMoveToDev,\n compatSyncConfig,\n compatVitePluginConfig,\n };\n};\n\n/**\n * Runs the package install command synchronously.\n * Throws if the install process exits with a non-zero code.\n */\nexport const installPackages = (\n rootDir: string,\n packages: string[],\n packageManager: PackageManager,\n isDev: boolean = false\n): void => {\n const command = buildInstallCommand(packageManager, packages, isDev);\n execSync(command, { cwd: rootDir, stdio: 'inherit' });\n};\n\n/**\n * Determines whether a dependency name belongs to the Intlayer ecosystem.\n *\n * Matches the core `intlayer` package, every scoped `@intlayer/*` package\n * (including compat adapters such as `@intlayer/next-intl`) and the framework\n * runtime integrations that follow the `<framework>-intlayer` convention\n * (e.g. `next-intlayer`, `react-intlayer`, `express-intlayer`), as well as the\n * `intlayer-*` packages (e.g. `intlayer-editor`).\n */\nexport const isIntlayerPackageName = (packageName: string): boolean =>\n packageName === 'intlayer' ||\n packageName.startsWith('@intlayer/') ||\n packageName.startsWith('intlayer-') ||\n packageName.endsWith('-intlayer');\n\n/**\n * Reduces a semver range or full version to its `major.minor.patch` core,\n * stripping range prefixes (`^`, `~`), pre-release identifiers and build\n * metadata. Returns `null` when no `major.minor.patch` can be extracted.\n *\n * @example normalizeVersion('^9.0.0-canary.3') // '9.0.0'\n */\nexport const normalizeVersion = (version?: string): string | null => {\n if (!version || typeof version !== 'string') return null;\n\n const match = version.match(/(\\d+)\\.(\\d+)\\.(\\d+)/);\n\n return match ? `${match[1]}.${match[2]}.${match[3]}` : null;\n};\n\n/**\n * Runs the package manager install command synchronously, so edited\n * `package.json` ranges are resolved and the lock file updated. Throws if the\n * install process exits with a non-zero code.\n */\nexport const runPackageInstall = (\n rootDir: string,\n packageManager: PackageManager\n): void => {\n execSync(`${packageManager} install`, { cwd: rootDir, stdio: 'inherit' });\n};\n"],"mappings":";;;;;;AA8FA,MAAM,6BAEF;CACF,CAAC,YAAY,KAAK;CAClB,CAAC,aAAa,KAAK;CACnB,CAAC,kBAAkB,MAAM;CACzB,CAAC,aAAa,MAAM;CACpB,CAAC,qBAAqB,KAAK;AAC7B;;AAGA,MAAM,mBAA8C;CAClD;CACA;CACA;CACA;AACF;;;;;AAMA,MAAM,2BAA2B,cAA6C;CAC5E,IAAI;EACF,MAAM,EAAE,mBAAmB,KAAK,MAC9B,aAAa,KAAK,WAAW,cAAc,GAAG,MAAM,CACtD;EAEA,IAAI,OAAO,mBAAmB,UAAU,OAAO;EAE/C,MAAM,OAAO,eAAe,MAAM,GAAG,CAAC,CAAC;EACvC,OAAO,iBAAiB,SAAS,IAAI,IAAI,OAAO;CAClD,QAAQ;EACN,OAAO;CACT;AACF;;;;;;AAOA,MAAa,wBAAwB,YACnC,2BAA2B,MAAM,CAAC,cAChC,WAAW,KAAK,SAAS,QAAQ,CAAC,CACpC,CAAC,GAAG,MACJ,wBAAwB,OAAO,KAC/B;;;;;;AAOF,MAAa,mBAAmB,aAAoC;CAClE,IAAI,aAAa,QAAQ,QAAQ;CAEjC,OAAO,MAAM;EAIX,IAHoB,2BAA2B,MAAM,CAAC,cACpD,WAAW,KAAK,YAAY,QAAQ,CAAC,CAEzB,GAAG,OAAO;EACxB,IAAI,WAAW,KAAK,YAAY,MAAM,CAAC,GAAG,OAAO;EAEjD,MAAM,YAAY,QAAQ,UAAU;EACpC,IAAI,cAAc,YAAY,OAAO;EACrC,aAAa;CACf;AACF;;;;AAKA,MAAM,uBACJ,gBACA,UACA,QAAiB,UACN;CACX,MAAM,cAAc,SAAS,KAAK,GAAG;CACrC,QAAQ,gBAAR;EACE,KAAK,OACH,OAAO,WAAW,QAAQ,QAAQ,KAAK;EACzC,KAAK,QACH,OAAO,YAAY,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AAgB,UAAU,KAAK;CACnE,SAAS,SAAS;EAAE,KAAK;EAAS,OAAO;CAAU,CAAC;AACtD;;;;;;;;;;AAWA,MAAa,yBAAyB,gBACpC,gBAAgB,cAChB,YAAY,WAAW,YAAY,KACnC,YAAY,WAAW,WAAW,KAClC,YAAY,SAAS,WAAW;;;;;;;;AASlC,MAAa,oBAAoB,YAAoC;CACnE,IAAI,CAAC,WAAW,OAAO,YAAY,UAAU,OAAO;CAEpD,MAAM,QAAQ,QAAQ,MAAM,qBAAqB;CAEjD,OAAO,QAAQ,GAAG,MAAM,GAAG,GAAG,MAAM,GAAG,GAAG,MAAM,OAAO;AACzD;;;;;;AAOA,MAAa,qBACX,SACA,mBACS;CACT,SAAS,GAAG,eAAe,WAAW;EAAE,KAAK;EAAS,OAAO;CAAU,CAAC;AAC1E"}
1
+ {"version":3,"file":"packageManager.mjs","names":[],"sources":["../../../../src/init/utils/packageManager.ts"],"sourcesContent":["import { execSync } from 'node:child_process';\nimport { existsSync, readFileSync } from 'node:fs';\nimport { dirname, join, resolve } from 'node:path';\nimport { isVersionAtLeast } from './version';\n\n/** Package managers supported for dependency installation. */\nexport type PackageManager = 'bun' | 'pnpm' | 'yarn' | 'npm';\n\n/**\n * Configuration for the syncJSON plugin injected into intlayer.config\n * when a compat i18n library is detected.\n */\nexport type CompatSyncConfig = {\n /**\n * Which sync plugin ingests the catalogs:\n * - `'json'` → `syncJSON` from `@intlayer/sync-json-plugin` (default).\n * - `'po'` → `syncPO` from `@intlayer/sync-po-plugin` (lingui's default\n * format).\n */\n plugin?: 'json' | 'po';\n /**\n * JSON format matching the compat library's conventions. Ignored when\n * `plugin` is `'po'` (PO catalogs are always serialized as gettext).\n */\n format: 'icu' | 'i18next' | 'vue-i18n';\n /**\n * Source path template using ${locale} and ${key} placeholders.\n * Rendered as a template literal in the generated config.\n */\n sourceTemplate: string;\n /**\n * Force `splitKeys: true` in the generated `syncJSON(...)` call so each\n * top-level key of a single per-locale file becomes its own dictionary.\n *\n * Set for libraries whose single `messages/${locale}.json` file groups\n * namespaces by its first-level keys (`next-intl` / `use-intl`, where\n * `useTranslations('Hero')` resolves to the `Hero` dictionary). Left\n * undefined for libraries whose top-level keys are plain message keys\n * (e.g. `i18next`, `react-intl`); for those, syncJSON's auto-detection\n * (split only when the source has no `${key}` segment) stays in control.\n *\n * Only meaningful for flat templates (no `${key}` segment); it is dropped\n * automatically when the resolved template addresses one namespace per file.\n */\n splitKeys?: boolean;\n};\n\n/**\n * Configuration for injecting a compat vite plugin into vite.config.\n * The plugin replaces the generic `intlayer` plugin for libraries that\n * require alias injection (e.g. `vue-i18n` → `@intlayer/vue-i18n`).\n */\nexport type CompatVitePluginConfig = {\n /** Exported function name from the plugin package, e.g. `'vueI18nVitePlugin'`. */\n pluginFunctionName: string;\n /** Import path for the plugin package, e.g. `'@intlayer/vue-i18n/plugin'`. */\n pluginPackageSource: string;\n /**\n * Set when the compat plugin is a drop-in replacement for an i18n library's\n * own Vite plugin (e.g. lingui ships `@lingui/vite-plugin`). When the original\n * import is present, init rewrites only that import's module source to\n * `pluginPackageSource` — keeping the binding and its call site — instead of\n * injecting a second import and appending another plugin to the array.\n */\n replacesVitePlugin?: {\n /** Imported binding to keep, e.g. `'lingui'`. */\n importName: string;\n /** Original package source to rewrite, e.g. `'@lingui/vite-plugin'`. */\n fromPackageSource: string;\n };\n};\n\n/** Result of analyzing project dependencies for intlayer package gaps. */\nexport type IntlayerPackageAnalysis = {\n /** Intlayer packages that are referenced but not yet installed. */\n packagesToInstall: string[];\n /** Intlayer dev packages that are referenced but not yet installed. */\n devPackagesToInstall: string[];\n /** Compat packages in dependencies that got replaced and should be moved to devDependencies. */\n packagesToMoveToDev: string[];\n /**\n * syncJSON plugin configuration to inject when a compat i18n library is\n * detected. Undefined when no compat library is present or format is not\n * yet implemented.\n */\n compatSyncConfig: CompatSyncConfig | undefined;\n /**\n * Vite config plugin to inject when a vite-based compat library is\n * detected. Undefined for Next.js/Nuxt-only compat libs or when no compat\n * library requires alias injection.\n */\n compatVitePluginConfig: CompatVitePluginConfig | undefined;\n /**\n * Compat adapters the project would need but that are not published yet\n * (see {@link PENDING_COMPAT_ADAPTERS}). The original library is kept as is;\n * only its catalogs are synced.\n */\n pendingCompatAdapters: string[];\n};\n\n/**\n * Compat adapters that live in `compat-comming/` and are not published to npm\n * yet. Installing one fails the whole install command, so init keeps the\n * original library, skips the adapter and its bundler / framework wiring, and\n * only syncs the catalogs. Remove an entry once its package is released.\n */\nexport const PENDING_COMPAT_ADAPTERS: ReadonlySet<string> = new Set([\n '@intlayer/nuxtjs-i18n',\n '@intlayer/svelte-i18n',\n '@intlayer/ngx-translate',\n]);\n\n/** Lock files revealing the package manager, in detection priority order. */\nconst LOCK_FILE_PACKAGE_MANAGERS: ReadonlyArray<\n readonly [lockFile: string, packageManager: PackageManager]\n> = [\n ['bun.lock', 'bun'],\n ['bun.lockb', 'bun'],\n ['pnpm-lock.yaml', 'pnpm'],\n ['yarn.lock', 'yarn'],\n ['package-lock.json', 'npm'],\n];\n\n/** Package managers accepted in the `packageManager` field of `package.json`. */\nconst PACKAGE_MANAGERS: readonly PackageManager[] = [\n 'bun',\n 'pnpm',\n 'yarn',\n 'npm',\n];\n\n/**\n * Reads the package manager pinned by the `packageManager` field of the\n * `package.json` in `directory` (e.g. `\"pnpm@9.0.0\"`), if any.\n */\nconst readPackageManagerField = (directory: string): PackageManager | null => {\n try {\n const { packageManager } = JSON.parse(\n readFileSync(join(directory, 'package.json'), 'utf8')\n ) as { packageManager?: unknown };\n\n if (typeof packageManager !== 'string') return null;\n\n const name = packageManager.split('@')[0] as PackageManager;\n return PACKAGE_MANAGERS.includes(name) ? name : null;\n } catch {\n return null;\n }\n};\n\n/**\n * Detects the package manager in use by checking for lock files in the\n * project root, then the `packageManager` field of its `package.json`. Falls\n * back to npm when neither is found.\n */\nexport const detectPackageManager = (rootDir: string): PackageManager =>\n LOCK_FILE_PACKAGE_MANAGERS.find(([lockFile]) =>\n existsSync(join(rootDir, lockFile))\n )?.[1] ??\n readPackageManagerField(rootDir) ??\n 'npm';\n\n/**\n * Walks up from `startDir` to the nearest directory holding a lock file — the\n * workspace root an install must run from. Stops at the repository root\n * (`.git`) and returns `null` when no lock file is found.\n */\nexport const findLockFileDir = (startDir: string): string | null => {\n let currentDir = resolve(startDir);\n\n while (true) {\n const hasLockFile = LOCK_FILE_PACKAGE_MANAGERS.some(([lockFile]) =>\n existsSync(join(currentDir, lockFile))\n );\n if (hasLockFile) return currentDir;\n if (existsSync(join(currentDir, '.git'))) return null;\n\n const parentDir = dirname(currentDir);\n if (parentDir === currentDir) return null;\n currentDir = parentDir;\n }\n};\n\n/**\n * Returns the install command for the given package manager and package list.\n */\nconst buildInstallCommand = (\n packageManager: PackageManager,\n packages: string[],\n isDev: boolean = false\n): string => {\n const packageList = packages.join(' ');\n switch (packageManager) {\n case 'bun':\n return `bun add ${isDev ? '-d ' : ''}${packageList}`;\n case 'pnpm':\n return `pnpm add ${isDev ? '-D ' : ''}${packageList}`;\n case 'yarn':\n return `yarn add ${isDev ? '-D ' : ''}${packageList}`;\n case 'npm':\n return `npm install ${isDev ? '-D ' : ''}${packageList}`;\n }\n};\n\n/**\n * Analyzes existing project dependencies to determine which intlayer packages\n * are missing and what syncJSON configuration to inject when compat i18n\n * libraries are present.\n */\n/** Extra signals (from a filesystem scan) that refine compat detection. */\nexport type DetectMissingPackagesOptions = {\n /**\n * Catalog format detected for a lingui project (`'po'` or `'json'`), or\n * `null`/undefined when none was found. Decides which sync plugin + dev\n * dependency the lingui compat setup uses.\n */\n linguiCatalogFormat?: 'po' | 'json' | null;\n /**\n * The project's runtime dependencies (from `package.json` `dependencies`).\n * When provided, compat packages found here that are replaced by `@intlayer/*`\n * are reported in `packagesToMoveToDev`.\n */\n dependencies?: Record<string, string>;\n /**\n * The project's development dependencies (from `package.json` `devDependencies`).\n */\n devDependencies?: Record<string, string>;\n};\n\n/** An existing i18n library Intlayer ships a compat adapter for. */\nexport type CompatI18nLibrary = {\n /** Human-readable name, used to report the detection back to the user. */\n label: string;\n /**\n * Dependency names that reveal the library — both the upstream packages and\n * the Intlayer adapters, so a project that already ran `init` is still\n * recognized.\n */\n packages: readonly string[];\n /**\n * Upstream third-party packages replaced by Intlayer compat adapters at runtime,\n * mapped to their adapter package name.\n */\n replacements: Record<string, string>;\n};\n\n/**\n * Existing i18n libraries Intlayer can adapt, keyed by the dependencies that\n * reveal them. Mirrors the compat branches of\n * {@link detectMissingIntlayerPackages}: a library listed here is one that\n * detection will wire up on its own once its package is in `package.json`.\n */\nexport const COMPAT_I18N_LIBRARIES: readonly CompatI18nLibrary[] = [\n {\n label: 'i18next / react-i18next',\n packages: [\n 'i18next',\n 'react-i18next',\n '@intlayer/i18next',\n '@intlayer/react-i18next',\n ],\n replacements: {\n i18next: '@intlayer/i18next',\n 'react-i18next': '@intlayer/react-i18next',\n },\n },\n {\n label: 'next-intl / use-intl',\n packages: [\n 'next-intl',\n 'use-intl',\n '@intlayer/next-intl',\n '@intlayer/use-intl',\n ],\n replacements: {\n 'next-intl': '@intlayer/next-intl',\n 'use-intl': '@intlayer/use-intl',\n },\n },\n {\n label: 'vue-i18n',\n packages: ['vue-i18n', '@intlayer/vue-i18n'],\n replacements: {\n 'vue-i18n': '@intlayer/vue-i18n',\n },\n },\n {\n label: '@nuxtjs/i18n',\n packages: ['@nuxtjs/i18n', '@intlayer/nuxtjs-i18n'],\n replacements: {\n '@nuxtjs/i18n': '@intlayer/nuxtjs-i18n',\n },\n },\n {\n label: 'next-i18next',\n packages: ['next-i18next', '@intlayer/next-i18next'],\n replacements: {\n 'next-i18next': '@intlayer/next-i18next',\n },\n },\n {\n label: 'next-translate',\n packages: ['next-translate', '@intlayer/next-translate'],\n replacements: {\n 'next-translate': '@intlayer/next-translate',\n },\n },\n {\n label: 'react-intl',\n packages: ['react-intl', '@intlayer/react-intl'],\n replacements: {\n 'react-intl': '@intlayer/react-intl',\n },\n },\n {\n label: 'Lingui',\n packages: ['@lingui/core', '@lingui/react', '@intlayer/lingui'],\n replacements: {\n '@lingui/core': '@intlayer/lingui',\n '@lingui/react': '@intlayer/lingui',\n },\n },\n {\n label: 'svelte-i18n',\n packages: ['svelte-i18n', '@intlayer/svelte-i18n'],\n replacements: {\n 'svelte-i18n': '@intlayer/svelte-i18n',\n },\n },\n {\n label: '@ngneat/transloco',\n packages: ['@ngneat/transloco', '@intlayer/transloco'],\n replacements: {\n '@ngneat/transloco': '@intlayer/transloco',\n },\n },\n {\n label: '@ngx-translate/core',\n packages: ['@ngx-translate/core', '@intlayer/ngx-translate'],\n replacements: {\n '@ngx-translate/core': '@intlayer/ngx-translate',\n },\n },\n {\n label: 'node-polyglot',\n packages: ['node-polyglot', '@intlayer/polyglot'],\n replacements: {\n 'node-polyglot': '@intlayer/polyglot',\n },\n },\n {\n label: 'i18n-js',\n packages: ['i18n-js', '@intlayer/i18n-js'],\n replacements: {\n 'i18n-js': '@intlayer/i18n-js',\n },\n },\n];\n\n/**\n * Maps third-party i18n libraries to the Intlayer compat adapter that replaces\n * them at runtime, derived from {@link COMPAT_I18N_LIBRARIES}.\n */\nexport const COMPAT_PACKAGE_REPLACEMENTS: Record<string, string> =\n Object.fromEntries(\n COMPAT_I18N_LIBRARIES.flatMap((library) =>\n Object.entries(library.replacements)\n )\n );\n\n/**\n * When a project uses a compat i18n package (such as `next-intl`) that gets\n * replaced by an `@intlayer/*` adapter (e.g. `@intlayer/next-intl`), moves the\n * original package from `dependencies` to `devDependencies` in `package.json`.\n *\n * Returns the list of package names that were moved.\n */\nexport const moveCompatPackagesToDevDependencies = (\n packageJson: Record<string, any>\n): string[] => {\n const movedPackages: string[] = [];\n if (!packageJson.dependencies) return movedPackages;\n\n for (const compatPackage of Object.keys(COMPAT_PACKAGE_REPLACEMENTS)) {\n if (packageJson.dependencies[compatPackage]) {\n const version = packageJson.dependencies[compatPackage];\n delete packageJson.dependencies[compatPackage];\n\n packageJson.devDependencies = packageJson.devDependencies ?? {};\n if (!packageJson.devDependencies[compatPackage]) {\n packageJson.devDependencies[compatPackage] = version;\n }\n movedPackages.push(compatPackage);\n }\n }\n\n return movedPackages;\n};\n\n/**\n * Returns the labels of the compat i18n libraries present in `dependencies`.\n *\n * Lets the init flow report (and branch on) the libraries it found without\n * asking the user, since {@link detectMissingIntlayerPackages} already derives\n * the adapters, sync plugin and config from the very same dependency map.\n *\n * @param dependencies - Merged dependencies of the target project.\n */\nexport const detectCompatI18nLibraries = (\n dependencies: Record<string, string>\n): string[] =>\n COMPAT_I18N_LIBRARIES.filter((library) =>\n library.packages.some((packageName) => Boolean(dependencies[packageName]))\n ).map((library) => library.label);\n\n/** Lowest ESLint major `eslint-plugin-intlayer` supports (flat config). */\nexport const MINIMUM_ESLINT_MAJOR = 9;\n\n/**\n * True when the project pins ESLint below {@link MINIMUM_ESLINT_MAJOR}.\n * Installing the plugin there fails on its `eslint` peer range (and takes the\n * whole install command down with it). Ranges without a version number\n * (`latest`, `*`, `catalog:`) are assumed current.\n *\n * @param dependencies - Merged dependencies of the target project.\n */\nexport const hasLegacyEslint = (\n dependencies: Record<string, string>\n): boolean => {\n const eslintVersion = dependencies.eslint;\n if (!eslintVersion || !/\\d/.test(eslintVersion)) return false;\n return !isVersionAtLeast(eslintVersion, MINIMUM_ESLINT_MAJOR);\n};\n\n/**\n * True when the project already lints with a linter the Intlayer rules can\n * plug into: oxlint, or ESLint 9+.\n *\n * Shared with the init flow so that installing the plugin and wiring up its\n * configuration are gated on exactly the same condition — a project that does\n * not lint, or lints with ESLint 8, is left alone.\n *\n * @param dependencies - Merged dependencies of the target project.\n */\nexport const hasLintTooling = (dependencies: Record<string, string>): boolean =>\n !hasLegacyEslint(dependencies) &&\n (Boolean(dependencies.eslint) || Boolean(dependencies.oxlint));\n\nexport const detectMissingIntlayerPackages = (\n allDependencies: Record<string, string>,\n options: DetectMissingPackagesOptions = {}\n): IntlayerPackageAnalysis => {\n const packagesToInstall: string[] = [];\n const devPackagesToInstall: string[] = [];\n const packagesToMoveToDev: string[] = [];\n const pendingCompatAdapters: string[] = [];\n\n let compatSyncConfig: CompatSyncConfig | undefined;\n let compatVitePluginConfig: CompatVitePluginConfig | undefined;\n\n const isInstalled = (packageName: string): boolean =>\n Boolean(allDependencies[packageName]);\n\n const addIfMissing = (packageName: string): void => {\n if (!isInstalled(packageName)) {\n packagesToInstall.push(packageName);\n }\n };\n\n const addDevIfMissing = (packageName: string): void => {\n if (!isInstalled(packageName)) {\n devPackagesToInstall.push(packageName);\n }\n };\n\n /**\n * Whether an adapter can be used: published, or already installed by the\n * user (e.g. a local build).\n */\n const isAdapterAvailable = (adapterPackage: string): boolean =>\n !PENDING_COMPAT_ADAPTERS.has(adapterPackage) || isInstalled(adapterPackage);\n\n const markCompatReplacement = (\n originalPackage: string,\n adapterPackage: string\n ): void => {\n if (!isAdapterAvailable(adapterPackage)) {\n if (!pendingCompatAdapters.includes(adapterPackage)) {\n pendingCompatAdapters.push(adapterPackage);\n }\n return;\n }\n\n addIfMissing(adapterPackage);\n addDevIfMissing(originalPackage);\n\n const isExplicitDev = Boolean(options.devDependencies?.[originalPackage]);\n const isExplicitProd = Boolean(options.dependencies?.[originalPackage]);\n const isImplicitProd =\n !options.dependencies &&\n !options.devDependencies &&\n Boolean(allDependencies[originalPackage]);\n\n if ((isExplicitProd || isImplicitProd) && !isExplicitDev) {\n if (!packagesToMoveToDev.includes(originalPackage)) {\n packagesToMoveToDev.push(originalPackage);\n }\n }\n };\n\n // Core package — always required\n addIfMissing('intlayer');\n\n const isReactNativeProject =\n isInstalled('react-native') || isInstalled('expo');\n\n // Framework-specific runtime integrations\n if (isInstalled('next')) {\n addIfMissing('next-intlayer');\n } else if (isReactNativeProject) {\n addIfMissing('react-native-intlayer');\n } else if (isInstalled('react')) {\n addIfMissing('react-intlayer');\n }\n\n if (isInstalled('svelte')) {\n addIfMissing('svelte-intlayer');\n }\n\n if (isInstalled('solid-js')) {\n addIfMissing('solid-intlayer');\n }\n\n if (isInstalled('@angular/core')) {\n addIfMissing('angular-intlayer');\n }\n\n if (isInstalled('vue')) {\n addIfMissing('vue-intlayer');\n }\n\n if (isInstalled('vite')) {\n addIfMissing('vite-intlayer');\n }\n\n // Meta-frameworks whose config init wires the Intlayer module /\n // integration into. A `@nuxtjs/i18n` app keeps its own module instead.\n if (isInstalled('nuxt') && !isInstalled('@nuxtjs/i18n')) {\n addIfMissing('nuxt-intlayer');\n }\n\n if (isInstalled('astro')) {\n addIfMissing('astro-intlayer');\n }\n\n // Server frameworks. NestJS runs on Express unless the Fastify platform is\n // installed, so it gets the matching adapter.\n const isNestJsProject = isInstalled('@nestjs/core');\n const isNestJsOnFastify = isInstalled('@nestjs/platform-fastify');\n\n if (isInstalled('express') || (isNestJsProject && !isNestJsOnFastify)) {\n addIfMissing('express-intlayer');\n }\n\n if (isInstalled('fastify') || isNestJsOnFastify) {\n addIfMissing('fastify-intlayer');\n }\n\n if (isInstalled('hono')) {\n addIfMissing('hono-intlayer');\n }\n\n if (isInstalled('elysia')) {\n addIfMissing('elysia-intlayer');\n }\n\n if (isInstalled('@adonisjs/core')) {\n addIfMissing('adonis-intlayer');\n }\n\n // Lint rules — only when the project already lints.\n if (hasLintTooling(allDependencies)) {\n addDevIfMissing('eslint-plugin-intlayer');\n }\n\n // -------------------------------------------------------------------------\n // Compat adapters for existing i18n libraries.\n //\n // Detection order matters: more specific libraries are checked first so that\n // `compatSyncConfig ??=` and `compatVitePluginConfig ??=` capture the most\n // relevant match. Libraries that only affect the Next.js or Nuxt config do\n // not set `compatVitePluginConfig` (handled separately in init/index.ts).\n // Libraries whose JSON format is not yet supported leave `compatSyncConfig`\n // undefined so no syncJSON plugin is injected.\n // -------------------------------------------------------------------------\n\n // next-intl — next.js only, ICU format. Default layout is a single file per\n // locale (`messages/${locale}.json`) whose top-level keys are namespaces;\n // syncJSON `splitKeys` auto-detection (no `${key}` segment) turns each\n // top-level key into its own dictionary. The exact path is refined from\n // `i18n/request.ts` in init/index.ts when present.\n if (isInstalled('next-intl') || isInstalled('@intlayer/next-intl')) {\n markCompatReplacement('next-intl', '@intlayer/next-intl');\n compatSyncConfig ??= {\n format: 'icu',\n sourceTemplate: './messages/${locale}.json',\n // next-intl groups namespaces by the first-level keys of one file.\n splitKeys: true,\n };\n // next config handled via updateNextConfigForNextIntl in init/index.ts\n }\n\n // next-i18next — next.js only, i18next JSON format\n if (isInstalled('next-i18next') || isInstalled('@intlayer/next-i18next')) {\n markCompatReplacement('next-i18next', '@intlayer/next-i18next');\n compatSyncConfig ??= {\n format: 'i18next',\n sourceTemplate: './src/locales/${locale}/${key}.json',\n };\n // next config handled via updateNextConfigForNextI18next in init/index.ts\n }\n\n // next-translate — next.js only, i18next-style flat-namespace JSON\n if (\n isInstalled('next-translate') ||\n isInstalled('@intlayer/next-translate')\n ) {\n markCompatReplacement('next-translate', '@intlayer/next-translate');\n compatSyncConfig ??= {\n format: 'i18next',\n sourceTemplate: './locales/${locale}/${key}.json',\n };\n // next config handled via updateNextConfigForNextTranslate in init/index.ts\n }\n\n // i18next — vite alias injection (`i18next` → `@intlayer/i18next`) so existing\n // `import … from 'i18next'` is served by Intlayer without touching call sites.\n if (isInstalled('i18next') || isInstalled('@intlayer/i18next')) {\n markCompatReplacement('i18next', '@intlayer/i18next');\n compatSyncConfig ??= {\n format: 'i18next',\n sourceTemplate: './src/locales/${locale}/${key}.json',\n };\n // When react-i18next is also present, its wrapper plugin aliases both\n // `react-i18next` and `i18next`, so it must win — only inject the bare\n // i18next plugin when no React wrapper is installed.\n if (\n !isInstalled('react-i18next') &&\n !isInstalled('@intlayer/react-i18next')\n ) {\n compatVitePluginConfig ??= {\n pluginFunctionName: 'i18nextVitePlugin',\n pluginPackageSource: '@intlayer/i18next/plugin',\n };\n }\n }\n\n // react-i18next — vite alias injection (`react-i18next` → `@intlayer/react-i18next`\n // and `i18next` → `@intlayer/i18next`) so components keep importing from\n // `react-i18next` unchanged.\n if (isInstalled('react-i18next') || isInstalled('@intlayer/react-i18next')) {\n markCompatReplacement('react-i18next', '@intlayer/react-i18next');\n compatSyncConfig ??= {\n format: 'i18next',\n sourceTemplate: './src/locales/${locale}/${key}.json',\n };\n compatVitePluginConfig ??= {\n pluginFunctionName: 'reactI18nextVitePlugin',\n pluginPackageSource: '@intlayer/react-i18next/plugin',\n };\n }\n\n // vue-i18n — vite alias injection required\n if (isInstalled('vue-i18n') || isInstalled('@intlayer/vue-i18n')) {\n markCompatReplacement('vue-i18n', '@intlayer/vue-i18n');\n compatSyncConfig ??= {\n format: 'vue-i18n',\n sourceTemplate: './locales/${locale}/${key}.json',\n };\n compatVitePluginConfig ??= {\n pluginFunctionName: 'vueI18nVitePlugin',\n pluginPackageSource: '@intlayer/vue-i18n/plugin',\n };\n }\n\n // use-intl — framework-agnostic React core of next-intl; vite alias\n // injection required, ICU format. Commonly a single `messages/${locale}.json`\n // file whose top-level keys are namespaces, handled by syncJSON `splitKeys`\n // auto-detection (no `${key}` segment in the source template).\n if (isInstalled('use-intl') || isInstalled('@intlayer/use-intl')) {\n markCompatReplacement('use-intl', '@intlayer/use-intl');\n compatSyncConfig ??= {\n format: 'icu',\n sourceTemplate: './messages/${locale}.json',\n // use-intl (the core of next-intl) uses the same single-file namespace model.\n splitKeys: true,\n };\n compatVitePluginConfig ??= {\n pluginFunctionName: 'useIntlVitePlugin',\n pluginPackageSource: '@intlayer/use-intl/plugin',\n };\n }\n\n // react-intl — vite alias injection required, ICU format\n if (isInstalled('react-intl') || isInstalled('@intlayer/react-intl')) {\n markCompatReplacement('react-intl', '@intlayer/react-intl');\n compatSyncConfig ??= {\n format: 'icu',\n sourceTemplate: './src/i18n/${locale}.json',\n };\n compatVitePluginConfig ??= {\n pluginFunctionName: 'reactIntlVitePlugin',\n pluginPackageSource: '@intlayer/react-intl/plugin',\n };\n }\n\n // @ngneat/transloco — vite alias injection required\n // @todo syncJSON format not yet implemented for transloco\n if (isInstalled('@ngneat/transloco') || isInstalled('@intlayer/transloco')) {\n markCompatReplacement('@ngneat/transloco', '@intlayer/transloco');\n if (isAdapterAvailable('@intlayer/transloco')) {\n compatVitePluginConfig ??= {\n pluginFunctionName: 'translocoVitePlugin',\n pluginPackageSource: '@intlayer/transloco/plugin',\n };\n }\n }\n\n // svelte-i18n — vite alias injection required, flat JSON (i18next-compatible)\n if (isInstalled('svelte-i18n') || isInstalled('@intlayer/svelte-i18n')) {\n markCompatReplacement('svelte-i18n', '@intlayer/svelte-i18n');\n compatSyncConfig ??= {\n format: 'i18next',\n sourceTemplate: './src/locales/${locale}.json',\n };\n if (isAdapterAvailable('@intlayer/svelte-i18n')) {\n compatVitePluginConfig ??= {\n pluginFunctionName: 'svelteI18nVitePlugin',\n pluginPackageSource: '@intlayer/svelte-i18n/plugin',\n };\n }\n }\n\n // node-polyglot — vite alias injection required\n // @todo syncJSON format not yet implemented for polyglot\n if (isInstalled('node-polyglot') || isInstalled('@intlayer/polyglot')) {\n markCompatReplacement('node-polyglot', '@intlayer/polyglot');\n if (isAdapterAvailable('@intlayer/polyglot')) {\n compatVitePluginConfig ??= {\n pluginFunctionName: 'polyglotVitePlugin',\n pluginPackageSource: '@intlayer/polyglot/plugin',\n };\n }\n }\n\n // @nuxtjs/i18n — nuxt module (no vite plugin), vue-i18n JSON format\n if (isInstalled('@nuxtjs/i18n') || isInstalled('@intlayer/nuxtjs-i18n')) {\n markCompatReplacement('@nuxtjs/i18n', '@intlayer/nuxtjs-i18n');\n compatSyncConfig ??= {\n format: 'vue-i18n',\n sourceTemplate: './locales/${locale}/${key}.json',\n };\n // nuxt config handled via updateNuxtConfigForNuxtjsI18n in init/index.ts\n }\n\n // @ngx-translate/core — vite alias injection required, flat JSON (i18next)\n if (\n isInstalled('@ngx-translate/core') ||\n isInstalled('@intlayer/ngx-translate')\n ) {\n markCompatReplacement('@ngx-translate/core', '@intlayer/ngx-translate');\n compatSyncConfig ??= {\n format: 'i18next',\n sourceTemplate: './assets/i18n/${locale}.json',\n };\n if (isAdapterAvailable('@intlayer/ngx-translate')) {\n compatVitePluginConfig ??= {\n pluginFunctionName: 'ngxTranslateVitePlugin',\n pluginPackageSource: '@intlayer/ngx-translate/plugin',\n };\n }\n }\n\n // @lingui/core — vite alias injection required.\n // lingui keeps one catalog file per locale (default name `messages`), as\n // `.po` (its default) or `.json`. The catalog filename is captured by the\n // `${key}` segment so the produced dictionary key is `messages`, matching the\n // fixed `messages` namespace the lingui compat runtime reads from.\n if (\n isInstalled('@lingui/core') ||\n isInstalled('@lingui/react') ||\n isInstalled('@intlayer/lingui')\n ) {\n markCompatReplacement('@lingui/core', '@intlayer/lingui');\n\n if (isInstalled('@lingui/react')) {\n markCompatReplacement('@lingui/react', '@intlayer/lingui');\n }\n\n const linguiUsesPo = options.linguiCatalogFormat === 'po';\n compatSyncConfig ??= linguiUsesPo\n ? {\n plugin: 'po',\n format: 'icu',\n sourceTemplate: './src/locales/${locale}/${key}.po',\n }\n : {\n plugin: 'json',\n format: 'icu',\n sourceTemplate: './src/locales/${locale}/${key}.json',\n };\n\n compatVitePluginConfig ??= {\n // `@intlayer/lingui/plugin` exports `lingui` as a drop-in replacement for\n // `@lingui/vite-plugin`, so a fresh project gets `lingui()` injected and a\n // project already using `@lingui/vite-plugin` only has its import source\n // rewritten (see `replacesVitePlugin`).\n pluginFunctionName: 'lingui',\n pluginPackageSource: '@intlayer/lingui/plugin',\n replacesVitePlugin: {\n importName: 'lingui',\n fromPackageSource: '@lingui/vite-plugin',\n },\n };\n }\n\n // i18n-js — vite alias injection required\n // @todo syncJSON format not yet implemented for i18n-js\n if (isInstalled('i18n-js') || isInstalled('@intlayer/i18n-js')) {\n markCompatReplacement('i18n-js', '@intlayer/i18n-js');\n if (isAdapterAvailable('@intlayer/i18n-js')) {\n compatVitePluginConfig ??= {\n pluginFunctionName: 'i18nJsVitePlugin',\n pluginPackageSource: '@intlayer/i18n-js/plugin',\n };\n }\n }\n\n if (compatSyncConfig) {\n addDevIfMissing(\n compatSyncConfig.plugin === 'po'\n ? '@intlayer/sync-po-plugin'\n : '@intlayer/sync-json-plugin'\n );\n }\n\n return {\n packagesToInstall,\n devPackagesToInstall,\n packagesToMoveToDev,\n compatSyncConfig,\n compatVitePluginConfig,\n pendingCompatAdapters,\n };\n};\n\n/**\n * Runs the package install command synchronously.\n * Throws if the install process exits with a non-zero code.\n */\nexport const installPackages = (\n rootDir: string,\n packages: string[],\n packageManager: PackageManager,\n isDev: boolean = false\n): void => {\n const command = buildInstallCommand(packageManager, packages, isDev);\n execSync(command, { cwd: rootDir, stdio: 'inherit' });\n};\n\n/**\n * Determines whether a dependency name belongs to the Intlayer ecosystem.\n *\n * Matches the core `intlayer` package, every scoped `@intlayer/*` package\n * (including compat adapters such as `@intlayer/next-intl`) and the framework\n * runtime integrations that follow the `<framework>-intlayer` convention\n * (e.g. `next-intlayer`, `react-intlayer`, `express-intlayer`), as well as the\n * `intlayer-*` packages (e.g. `intlayer-editor`).\n */\nexport const isIntlayerPackageName = (packageName: string): boolean =>\n packageName === 'intlayer' ||\n packageName.startsWith('@intlayer/') ||\n packageName.startsWith('intlayer-') ||\n packageName.endsWith('-intlayer');\n\n/**\n * Reduces a semver range or full version to its `major.minor.patch` core,\n * stripping range prefixes (`^`, `~`), pre-release identifiers and build\n * metadata. Returns `null` when no `major.minor.patch` can be extracted.\n *\n * @example normalizeVersion('^9.0.0-canary.3') // '9.0.0'\n */\nexport const normalizeVersion = (version?: string): string | null => {\n if (!version || typeof version !== 'string') return null;\n\n const match = version.match(/(\\d+)\\.(\\d+)\\.(\\d+)/);\n\n return match ? `${match[1]}.${match[2]}.${match[3]}` : null;\n};\n\n/**\n * Runs the package manager install command synchronously, so edited\n * `package.json` ranges are resolved and the lock file updated. Throws if the\n * install process exits with a non-zero code.\n */\nexport const runPackageInstall = (\n rootDir: string,\n packageManager: PackageManager\n): void => {\n execSync(`${packageManager} install`, { cwd: rootDir, stdio: 'inherit' });\n};\n"],"mappings":";;;;;;;;;;;;AA0GA,MAAa,0CAA+C,IAAI,IAAI;CAClE;CACA;CACA;AACF,CAAC;;AAGD,MAAM,6B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BAAqB;CAEjD,OAAO,QAAQ,GAAG,MAAM,GAAG,GAAG,MAAM,GAAG,GAAG,MAAM,OAAO;AACzD;;;;;;AAOA,MAAa,qBACX,SACA,mBACS;CACT,SAAS,GAAG,eAAe,WAAW;EAAE,KAAK;EAAS,OAAO;CAAU,CAAC;AAC1E"}
@@ -0,0 +1,40 @@
1
+ //#region src/init/utils/urlRoutingFramework.ts
2
+ /**
3
+ * Frontend packages whose apps are served over URLs, so a locale routing
4
+ * strategy (`routing.mode`, the locale proxy) applies to them.
5
+ */
6
+ const URL_ROUTING_FRAMEWORK_PACKAGES = [
7
+ "next",
8
+ "react",
9
+ "react-dom",
10
+ "react-router",
11
+ "react-router-dom",
12
+ "@tanstack/react-router",
13
+ "@tanstack/react-start",
14
+ "@tanstack/solid-router",
15
+ "@tanstack/solid-start",
16
+ "vue",
17
+ "nuxt",
18
+ "svelte",
19
+ "@sveltejs/kit",
20
+ "solid-js",
21
+ "preact",
22
+ "@angular/core",
23
+ "astro",
24
+ "lit",
25
+ "@remix-run/react",
26
+ "vite"
27
+ ];
28
+ /**
29
+ * Returns true when the project is a web frontend for which locale routing is
30
+ * meaningful. React Native / Expo apps are excluded (no URL routing), as are
31
+ * backend-only and plain Node projects.
32
+ */
33
+ const hasUrlRoutingFramework = (dependencies) => {
34
+ if (dependencies["react-native"] || dependencies.expo) return false;
35
+ return URL_ROUTING_FRAMEWORK_PACKAGES.some((packageName) => packageName in dependencies);
36
+ };
37
+
38
+ //#endregion
39
+ export { hasUrlRoutingFramework };
40
+ //# sourceMappingURL=urlRoutingFramework.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"urlRoutingFramework.mjs","names":[],"sources":["../../../../src/init/utils/urlRoutingFramework.ts"],"sourcesContent":["/**\n * Frontend packages whose apps are served over URLs, so a locale routing\n * strategy (`routing.mode`, the locale proxy) applies to them.\n */\nconst URL_ROUTING_FRAMEWORK_PACKAGES = [\n 'next',\n 'react',\n 'react-dom',\n 'react-router',\n 'react-router-dom',\n '@tanstack/react-router',\n '@tanstack/react-start',\n '@tanstack/solid-router',\n '@tanstack/solid-start',\n 'vue',\n 'nuxt',\n 'svelte',\n '@sveltejs/kit',\n 'solid-js',\n 'preact',\n '@angular/core',\n 'astro',\n 'lit',\n '@remix-run/react',\n 'vite',\n] as const;\n\n/**\n * Returns true when the project is a web frontend for which locale routing is\n * meaningful. React Native / Expo apps are excluded (no URL routing), as are\n * backend-only and plain Node projects.\n */\nexport const hasUrlRoutingFramework = (\n dependencies: Record<string, string>\n): boolean => {\n if (dependencies['react-native'] || dependencies.expo) return false;\n\n return URL_ROUTING_FRAMEWORK_PACKAGES.some(\n (packageName) => packageName in dependencies\n );\n};\n"],"mappings":";;;;;AAIA,MAAM,iCAAiC;CACrC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;AAOA,MAAa,0BACX,iBACY;CACZ,IAAI,aAAa,mBAAmB,aAAa,MAAM,OAAO;CAE9D,OAAO,+BAA+B,MACnC,gBAAgB,eAAe,YAClC;AACF"}
@@ -18,13 +18,15 @@ const getTemplatePath = (format) => {
18
18
  /**
19
19
  * Initialize the Intlayer configuration file. No-ops when a configuration file
20
20
  * already exists at `baseDir`.
21
+ *
22
+ * @returns `true` when the file was created, `false` when one already existed.
21
23
  */
22
24
  const initConfig = async (format, baseDir, options) => {
23
25
  const { configurationFilePath } = searchConfigurationFile(baseDir);
24
26
  if (configurationFilePath) {
25
27
  const relativePath = relative(baseDir, configurationFilePath);
26
28
  logger(`${v} ${colorizePath(relativePath)} already exists`);
27
- return;
29
+ return false;
28
30
  }
29
31
  const extension = format.split(".").pop();
30
32
  const templatePath = getTemplatePath(extension);
@@ -42,6 +44,7 @@ const initConfig = async (format, baseDir, options) => {
42
44
  if (applicationURL) configContent = configContent.replace("http://localhost:3000", applicationURL);
43
45
  await writeFile(join(baseDir, format), configContent, "utf8");
44
46
  logger(`${v} Created ${colorizePath(format)}`);
47
+ return true;
45
48
  };
46
49
 
47
50
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/initConfig/index.ts"],"sourcesContent":["import { writeFile } from 'node:fs/promises';\nimport { join, relative } from 'node:path';\nimport { readAsset } from 'utils:asset';\nimport { colorizePath, logger, v } from '@intlayer/config/logger';\nimport {\n type configurationFilesCandidates,\n searchConfigurationFile,\n} from '@intlayer/config/node';\n\ntype ConfigFormat = 'ts' | 'cjs' | 'mjs' | 'js' | 'json';\n\nconst getTemplatePath = (format: ConfigFormat) => {\n switch (format) {\n case 'ts':\n return './templates/ts.txt';\n case 'cjs':\n return './templates/cjs.txt';\n case 'mjs':\n return './templates/mjs.txt';\n case 'js':\n return './templates/mjs.txt';\n case 'json':\n return './templates/json.txt';\n default:\n return './templates/ts.txt';\n }\n};\n\n/** Values injected into the configuration file template. */\nexport type InitConfigOptions = {\n /** Locales detected in the project, inserted into `internationalization.locales`. */\n locales?: string[];\n /**\n * Dev-server URL of the detected framework, inserted as\n * `editor.applicationURL` (the template defaults to `http://localhost:3000`).\n */\n applicationURL?: string;\n};\n\n/**\n * Initialize the Intlayer configuration file. No-ops when a configuration file\n * already exists at `baseDir`.\n */\nexport const initConfig = async (\n format: (typeof configurationFilesCandidates)[number],\n baseDir: string,\n options?: InitConfigOptions\n) => {\n // Search for configuration file\n const { configurationFilePath } = searchConfigurationFile(baseDir);\n\n // return if the configuration file is found\n if (configurationFilePath) {\n const relativePath = relative(baseDir, configurationFilePath);\n logger(`${v} ${colorizePath(relativePath)} already exists`);\n return;\n }\n\n // Extract the format from the filename (e.g. 'intlayer.config.ts' -> 'ts')\n const extension = format.split('.').pop() as ConfigFormat;\n\n const templatePath = getTemplatePath(extension);\n let configContent = readAsset(templatePath);\n\n const { locales, applicationURL } = options ?? {};\n\n if (locales && locales.length > 0) {\n if (extension === 'json') {\n const localesString = JSON.stringify(locales);\n configContent = configContent.replace('[\"en\"]', localesString);\n } else {\n const localesString = `[${locales.map((locale) => `'${locale}'`).join(', ')}]`;\n configContent = configContent.replace('[Locales.ENGLISH]', localesString);\n }\n }\n\n if (applicationURL) {\n configContent = configContent.replace(\n 'http://localhost:3000',\n applicationURL\n );\n }\n\n await writeFile(join(baseDir, format), configContent, 'utf8');\n logger(`${v} Created ${colorizePath(format)}`);\n};\n"],"mappings":";;;;;;;AAWA,MAAM,mBAAmB,WAAyB;CAChD,QAAQ,QAAR;EACE,KAAK,MACH,OAAO;EACT,KAAK,OACH,OAAO;EACT,KAAK,OACH,OAAO;EACT,KAAK,MACH,OAAO;EACT,KAAK,QACH,OAAO;EACT,SACE,OAAO;CACX;AACF;;;;;AAiBA,MAAa,aAAa,OACxB,QACA,SACA,YACG;CAEH,MAAM,EAAE,0BAA0B,wBAAwB,OAAO;CAGjE,IAAI,uBAAuB;EACzB,MAAM,eAAe,SAAS,SAAS,qBAAqB;EAC5D,OAAO,GAAG,EAAE,GAAG,aAAa,YAAY,EAAE,gBAAgB;EAC1D;CACF;CAGA,MAAM,YAAY,OAAO,MAAM,GAAG,CAAC,CAAC,IAAI;CAExC,MAAM,eAAe,gBAAgB,SAAS;CAC9C,IAAI,gBAAgB,UAAU,YAAY;CAE1C,MAAM,EAAE,SAAS,mBAAmB,WAAW,CAAC;CAEhD,IAAI,WAAW,QAAQ,SAAS,GAAG;EACjC,IAAI,cAAc,QAAQ;GACxB,MAAM,gBAAgB,KAAK,UAAU,OAAO;GAC5C,gBAAgB,cAAc,QAAQ,YAAU,aAAa;EAC/D,OAAO;GACL,MAAM,gBAAgB,IAAI,QAAQ,KAAK,WAAW,IAAI,OAAO,EAAE,CAAC,CAAC,KAAK,IAAI,EAAE;GAC5E,gBAAgB,cAAc,QAAQ,qBAAqB,aAAa;EAC1E;CACF;CAEA,IAAI,gBACF,gBAAgB,cAAc,QAC5B,yBACA,cACF;CAGF,MAAM,UAAU,KAAK,SAAS,MAAM,GAAG,eAAe,MAAM;CAC5D,OAAO,GAAG,EAAE,WAAW,aAAa,MAAM,GAAG;AAC/C"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/initConfig/index.ts"],"sourcesContent":["import { writeFile } from 'node:fs/promises';\nimport { join, relative } from 'node:path';\nimport { readAsset } from 'utils:asset';\nimport { colorizePath, logger, v } from '@intlayer/config/logger';\nimport {\n type configurationFilesCandidates,\n searchConfigurationFile,\n} from '@intlayer/config/node';\n\ntype ConfigFormat = 'ts' | 'cjs' | 'mjs' | 'js' | 'json';\n\nconst getTemplatePath = (format: ConfigFormat) => {\n switch (format) {\n case 'ts':\n return './templates/ts.txt';\n case 'cjs':\n return './templates/cjs.txt';\n case 'mjs':\n return './templates/mjs.txt';\n case 'js':\n return './templates/mjs.txt';\n case 'json':\n return './templates/json.txt';\n default:\n return './templates/ts.txt';\n }\n};\n\n/** Values injected into the configuration file template. */\nexport type InitConfigOptions = {\n /** Locales detected in the project, inserted into `internationalization.locales`. */\n locales?: string[];\n /**\n * Dev-server URL of the detected framework, inserted as\n * `editor.applicationURL` (the template defaults to `http://localhost:3000`).\n */\n applicationURL?: string;\n};\n\n/**\n * Initialize the Intlayer configuration file. No-ops when a configuration file\n * already exists at `baseDir`.\n *\n * @returns `true` when the file was created, `false` when one already existed.\n */\nexport const initConfig = async (\n format: (typeof configurationFilesCandidates)[number],\n baseDir: string,\n options?: InitConfigOptions\n): Promise<boolean> => {\n // Search for configuration file\n const { configurationFilePath } = searchConfigurationFile(baseDir);\n\n // return if the configuration file is found\n if (configurationFilePath) {\n const relativePath = relative(baseDir, configurationFilePath);\n logger(`${v} ${colorizePath(relativePath)} already exists`);\n return false;\n }\n\n // Extract the format from the filename (e.g. 'intlayer.config.ts' -> 'ts')\n const extension = format.split('.').pop() as ConfigFormat;\n\n const templatePath = getTemplatePath(extension);\n let configContent = readAsset(templatePath);\n\n const { locales, applicationURL } = options ?? {};\n\n if (locales && locales.length > 0) {\n if (extension === 'json') {\n const localesString = JSON.stringify(locales);\n configContent = configContent.replace('[\"en\"]', localesString);\n } else {\n const localesString = `[${locales.map((locale) => `'${locale}'`).join(', ')}]`;\n configContent = configContent.replace('[Locales.ENGLISH]', localesString);\n }\n }\n\n if (applicationURL) {\n configContent = configContent.replace(\n 'http://localhost:3000',\n applicationURL\n );\n }\n\n await writeFile(join(baseDir, format), configContent, 'utf8');\n logger(`${v} Created ${colorizePath(format)}`);\n return true;\n};\n"],"mappings":";;;;;;;AAWA,MAAM,mBAAmB,WAAyB;CAChD,QAAQ,QAAR;EACE,KAAK,MACH,OAAO;EACT,KAAK,OACH,OAAO;EACT,KAAK,OACH,OAAO;EACT,KAAK,MACH,OAAO;EACT,KAAK,QACH,OAAO;EACT,SACE,OAAO;CACX;AACF;;;;;;;AAmBA,MAAa,aAAa,OACxB,QACA,SACA,YACqB;CAErB,MAAM,EAAE,0BAA0B,wBAAwB,OAAO;CAGjE,IAAI,uBAAuB;EACzB,MAAM,eAAe,SAAS,SAAS,qBAAqB;EAC5D,OAAO,GAAG,EAAE,GAAG,aAAa,YAAY,EAAE,gBAAgB;EAC1D,OAAO;CACT;CAGA,MAAM,YAAY,OAAO,MAAM,GAAG,CAAC,CAAC,IAAI;CAExC,MAAM,eAAe,gBAAgB,SAAS;CAC9C,IAAI,gBAAgB,UAAU,YAAY;CAE1C,MAAM,EAAE,SAAS,mBAAmB,WAAW,CAAC;CAEhD,IAAI,WAAW,QAAQ,SAAS,GAAG;EACjC,IAAI,cAAc,QAAQ;GACxB,MAAM,gBAAgB,KAAK,UAAU,OAAO;GAC5C,gBAAgB,cAAc,QAAQ,YAAU,aAAa;EAC/D,OAAO;GACL,MAAM,gBAAgB,IAAI,QAAQ,KAAK,WAAW,IAAI,OAAO,EAAE,CAAC,CAAC,KAAK,IAAI,EAAE;GAC5E,gBAAgB,cAAc,QAAQ,qBAAqB,aAAa;EAC1E;CACF;CAEA,IAAI,gBACF,gBAAgB,cAAc,QAC5B,yBACA,cACF;CAGF,MAAM,UAAU,KAAK,SAAS,MAAM,GAAG,eAAe,MAAM;CAC5D,OAAO,GAAG,EAAE,WAAW,aAAa,MAAM,GAAG;CAC7C,OAAO;AACT"}
@@ -14,7 +14,7 @@ const installMCP = async (projectRoot, platform, transport) => {
14
14
  let configKey = "mcpServers";
15
15
  if (platform === "Claude") configPath = CLAUDE_DESKTOP_CONFIG_PATH;
16
16
  else {
17
- const relativeDir = path.dirname(PLATFORMS_METADATA[platform].dir);
17
+ const relativeDir = path.dirname(PLATFORMS_METADATA[platform]?.dir ?? ".");
18
18
  configPath = path.join(projectRoot, relativeDir, MCP_CONFIG_FILENAME);
19
19
  if (platform === "VSCode") configKey = "servers";
20
20
  }
@@ -1 +1 @@
1
- {"version":3,"file":"installMCP.mjs","names":["fs"],"sources":["../../../src/installMCP/installMCP.ts"],"sourcesContent":["import { promises as fs } from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\nimport { PLATFORMS_METADATA, type Platform } from '../installSkills';\n\nexport type MCPTransport = 'stdio' | 'sse';\n\nconst MCP_CONFIG_FILENAME = 'mcp.json';\n\nconst CLAUDE_DESKTOP_CONFIG_PATH =\n process.platform === 'win32'\n ? path.join(\n process.env.APPDATA || '',\n 'Claude',\n 'claude_desktop_config.json'\n )\n : path.join(\n os.homedir(),\n 'Library',\n 'Application Support',\n 'Claude',\n 'claude_desktop_config.json'\n );\n\n/**\n * Installs the Intlayer MCP server configuration for a specific platform.\n */\nexport const installMCP = async (\n projectRoot: string,\n platform: Platform,\n transport: MCPTransport\n): Promise<string> => {\n let configPath: string;\n let configKey = 'mcpServers';\n\n if (platform === 'Claude') {\n configPath = CLAUDE_DESKTOP_CONFIG_PATH;\n } else {\n const relativeDir = path.dirname(PLATFORMS_METADATA[platform].dir); // e.g. .cursor or .vscode\n configPath = path.join(projectRoot, relativeDir, MCP_CONFIG_FILENAME);\n\n if (platform === 'VSCode') {\n configKey = 'servers';\n }\n }\n\n // Ensure the configuration directory exists\n await fs.mkdir(path.dirname(configPath), { recursive: true });\n\n let config: any = {};\n try {\n const content = await fs.readFile(configPath, 'utf-8');\n config = JSON.parse(content);\n } catch {\n // File doesn't exist or is invalid JSON, start fresh\n }\n\n if (!config[configKey]) {\n config[configKey] = {};\n }\n\n if (transport === 'stdio') {\n const mcpConfig: any = {\n command: 'npx',\n args: ['-y', '@intlayer/mcp'],\n };\n\n if (platform === 'VSCode') {\n mcpConfig.type = 'stdio';\n }\n\n config[configKey].intlayer = mcpConfig;\n } else {\n const mcpConfig: any = {\n url: 'https://mcp.intlayer.org',\n };\n\n if (platform === 'VSCode') {\n mcpConfig.type = 'sse';\n } else {\n mcpConfig.transport = 'sse';\n }\n\n config[configKey].intlayer = mcpConfig;\n }\n\n await fs.writeFile(configPath, JSON.stringify(config, null, 2), 'utf-8');\n\n return `MCP server configuration updated in ${configPath}`;\n};\n"],"mappings":";;;;;;AAOA,MAAM,sBAAsB;AAE5B,MAAM,6BACJ,QAAQ,aAAa,UACjB,KAAK,KACH,QAAQ,IAAI,WAAW,IACvB,UACA,4BACF,IACA,KAAK,KACH,GAAG,QAAQ,GACX,WACA,uBACA,UACA,4BACF;;;;AAKN,MAAa,aAAa,OACxB,aACA,UACA,cACoB;CACpB,IAAI;CACJ,IAAI,YAAY;CAEhB,IAAI,aAAa,UACf,aAAa;MACR;EACL,MAAM,cAAc,KAAK,QAAQ,mBAAmB,SAAS,CAAC,GAAG;EACjE,aAAa,KAAK,KAAK,aAAa,aAAa,mBAAmB;EAEpE,IAAI,aAAa,UACf,YAAY;CAEhB;CAGA,MAAMA,SAAG,MAAM,KAAK,QAAQ,UAAU,GAAG,EAAE,WAAW,KAAK,CAAC;CAE5D,IAAI,SAAc,CAAC;CACnB,IAAI;EACF,MAAM,UAAU,MAAMA,SAAG,SAAS,YAAY,OAAO;EACrD,SAAS,KAAK,MAAM,OAAO;CAC7B,QAAQ,CAER;CAEA,IAAI,CAAC,OAAO,YACV,OAAO,aAAa,CAAC;CAGvB,IAAI,cAAc,SAAS;EACzB,MAAM,YAAiB;GACrB,SAAS;GACT,MAAM,CAAC,MAAM,eAAe;EAC9B;EAEA,IAAI,aAAa,UACf,UAAU,OAAO;EAGnB,OAAO,UAAU,CAAC,WAAW;CAC/B,OAAO;EACL,MAAM,YAAiB,EACrB,KAAK,2BACP;EAEA,IAAI,aAAa,UACf,UAAU,OAAO;OAEjB,UAAU,YAAY;EAGxB,OAAO,UAAU,CAAC,WAAW;CAC/B;CAEA,MAAMA,SAAG,UAAU,YAAY,KAAK,UAAU,QAAQ,MAAM,CAAC,GAAG,OAAO;CAEvE,OAAO,uCAAuC;AAChD"}
1
+ {"version":3,"file":"installMCP.mjs","names":["fs"],"sources":["../../../src/installMCP/installMCP.ts"],"sourcesContent":["import { promises as fs } from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\nimport { PLATFORMS_METADATA, type Platform } from '../installSkills';\n\nexport type MCPTransport = 'stdio' | 'sse';\n\nconst MCP_CONFIG_FILENAME = 'mcp.json';\n\nconst CLAUDE_DESKTOP_CONFIG_PATH =\n process.platform === 'win32'\n ? path.join(\n process.env.APPDATA || '',\n 'Claude',\n 'claude_desktop_config.json'\n )\n : path.join(\n os.homedir(),\n 'Library',\n 'Application Support',\n 'Claude',\n 'claude_desktop_config.json'\n );\n\n/**\n * Installs the Intlayer MCP server configuration for a specific platform.\n */\nexport const installMCP = async (\n projectRoot: string,\n platform: Platform,\n transport: MCPTransport\n): Promise<string> => {\n let configPath: string;\n let configKey = 'mcpServers';\n\n if (platform === 'Claude') {\n configPath = CLAUDE_DESKTOP_CONFIG_PATH;\n } else {\n const relativeDir = path.dirname(PLATFORMS_METADATA[platform]?.dir ?? '.'); // e.g. .cursor or .vscode\n configPath = path.join(projectRoot, relativeDir, MCP_CONFIG_FILENAME);\n\n if (platform === 'VSCode') {\n configKey = 'servers';\n }\n }\n\n // Ensure the configuration directory exists\n await fs.mkdir(path.dirname(configPath), { recursive: true });\n\n let config: any = {};\n try {\n const content = await fs.readFile(configPath, 'utf-8');\n config = JSON.parse(content);\n } catch {\n // File doesn't exist or is invalid JSON, start fresh\n }\n\n if (!config[configKey]) {\n config[configKey] = {};\n }\n\n if (transport === 'stdio') {\n const mcpConfig: any = {\n command: 'npx',\n args: ['-y', '@intlayer/mcp'],\n };\n\n if (platform === 'VSCode') {\n mcpConfig.type = 'stdio';\n }\n\n config[configKey].intlayer = mcpConfig;\n } else {\n const mcpConfig: any = {\n url: 'https://mcp.intlayer.org',\n };\n\n if (platform === 'VSCode') {\n mcpConfig.type = 'sse';\n } else {\n mcpConfig.transport = 'sse';\n }\n\n config[configKey].intlayer = mcpConfig;\n }\n\n await fs.writeFile(configPath, JSON.stringify(config, null, 2), 'utf-8');\n\n return `MCP server configuration updated in ${configPath}`;\n};\n"],"mappings":";;;;;;AAOA,MAAM,sBAAsB;AAE5B,MAAM,6BACJ,QAAQ,aAAa,UACjB,KAAK,KACH,QAAQ,IAAI,WAAW,IACvB,UACA,4BACF,IACA,KAAK,KACH,GAAG,QAAQ,GACX,WACA,uBACA,UACA,4BACF;;;;AAKN,MAAa,aAAa,OACxB,aACA,UACA,cACoB;CACpB,IAAI;CACJ,IAAI,YAAY;CAEhB,IAAI,aAAa,UACf,aAAa;MACR;EACL,MAAM,cAAc,KAAK,QAAQ,mBAAmB,SAAS,EAAE,OAAO,GAAG;EACzE,aAAa,KAAK,KAAK,aAAa,aAAa,mBAAmB;EAEpE,IAAI,aAAa,UACf,YAAY;CAEhB;CAGA,MAAMA,SAAG,MAAM,KAAK,QAAQ,UAAU,GAAG,EAAE,WAAW,KAAK,CAAC;CAE5D,IAAI,SAAc,CAAC;CACnB,IAAI;EACF,MAAM,UAAU,MAAMA,SAAG,SAAS,YAAY,OAAO;EACrD,SAAS,KAAK,MAAM,OAAO;CAC7B,QAAQ,CAER;CAEA,IAAI,CAAC,OAAO,YACV,OAAO,aAAa,CAAC;CAGvB,IAAI,cAAc,SAAS;EACzB,MAAM,YAAiB;GACrB,SAAS;GACT,MAAM,CAAC,MAAM,eAAe;EAC9B;EAEA,IAAI,aAAa,UACf,UAAU,OAAO;EAGnB,OAAO,UAAU,CAAC,WAAW;CAC/B,OAAO;EACL,MAAM,YAAiB,EACrB,KAAK,2BACP;EAEA,IAAI,aAAa,UACf,UAAU,OAAO;OAEjB,UAAU,YAAY;EAGxB,OAAO,UAAU,CAAC,WAAW;CAC/B;CAEA,MAAMA,SAAG,UAAU,YAAY,KAAK,UAAU,QAAQ,MAAM,CAAC,GAAG,OAAO;CAEvE,OAAO,uCAAuC;AAChD"}
@@ -12,8 +12,10 @@ const loadLocalDictionaries = async (contentDeclarationsPaths, configuration) =>
12
12
  for await (const contentDeclarationPath of contentDeclarationsPaths) {
13
13
  const dictionary = await loadContentDeclarations([contentDeclarationPath], configuration);
14
14
  const relativeFilePath = relative(baseDir, contentDeclarationPath);
15
+ const firstDict = dictionary[0];
16
+ if (!firstDict) continue;
15
17
  const dictionaryWithPath = {
16
- ...dictionary[0],
18
+ ...firstDict,
17
19
  filePath: relativeFilePath
18
20
  };
19
21
  result.push(dictionaryWithPath);
@@ -1 +1 @@
1
- {"version":3,"file":"loadLocalDictionaries.mjs","names":[],"sources":["../../../src/loadDictionaries/loadLocalDictionaries.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { relative, resolve } from 'node:path';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { loadContentDeclarations } from './loadContentDeclaration';\n\nexport const loadLocalDictionaries = async (\n contentDeclarationsPaths: string[] | string,\n configuration: IntlayerConfig\n): Promise<Dictionary[]> => {\n const { system } = configuration;\n const { dictionariesDir, baseDir } = system;\n\n if (typeof contentDeclarationsPaths === 'string') {\n contentDeclarationsPaths = [contentDeclarationsPaths];\n }\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resolve(dictionariesDir), { recursive: true });\n\n const result: Dictionary[] = [];\n\n for await (const contentDeclarationPath of contentDeclarationsPaths) {\n const dictionary = await loadContentDeclarations(\n [contentDeclarationPath],\n configuration\n );\n\n const relativeFilePath = relative(baseDir, contentDeclarationPath);\n\n const dictionaryWithPath: Dictionary = {\n ...dictionary[0],\n filePath: relativeFilePath,\n };\n\n result.push(dictionaryWithPath);\n }\n\n return result;\n};\n"],"mappings":";;;;;AAMA,MAAa,wBAAwB,OACnC,0BACA,kBAC0B;CAC1B,MAAM,EAAE,WAAW;CACnB,MAAM,EAAE,iBAAiB,YAAY;CAErC,IAAI,OAAO,6BAA6B,UACtC,2BAA2B,CAAC,wBAAwB;CAItD,MAAM,MAAM,QAAQ,eAAe,GAAG,EAAE,WAAW,KAAK,CAAC;CAEzD,MAAM,SAAuB,CAAC;CAE9B,WAAW,MAAM,0BAA0B,0BAA0B;EACnE,MAAM,aAAa,MAAM,wBACvB,CAAC,sBAAsB,GACvB,aACF;EAEA,MAAM,mBAAmB,SAAS,SAAS,sBAAsB;EAEjE,MAAM,qBAAiC;GACrC,GAAG,WAAW;GACd,UAAU;EACZ;EAEA,OAAO,KAAK,kBAAkB;CAChC;CAEA,OAAO;AACT"}
1
+ {"version":3,"file":"loadLocalDictionaries.mjs","names":[],"sources":["../../../src/loadDictionaries/loadLocalDictionaries.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { relative, resolve } from 'node:path';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { loadContentDeclarations } from './loadContentDeclaration';\n\nexport const loadLocalDictionaries = async (\n contentDeclarationsPaths: string[] | string,\n configuration: IntlayerConfig\n): Promise<Dictionary[]> => {\n const { system } = configuration;\n const { dictionariesDir, baseDir } = system;\n\n if (typeof contentDeclarationsPaths === 'string') {\n contentDeclarationsPaths = [contentDeclarationsPaths];\n }\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resolve(dictionariesDir), { recursive: true });\n\n const result: Dictionary[] = [];\n\n for await (const contentDeclarationPath of contentDeclarationsPaths) {\n const dictionary = await loadContentDeclarations(\n [contentDeclarationPath],\n configuration\n );\n\n const relativeFilePath = relative(baseDir, contentDeclarationPath);\n\n const firstDict = dictionary[0];\n if (!firstDict) continue;\n\n const dictionaryWithPath: Dictionary = {\n ...firstDict,\n filePath: relativeFilePath,\n };\n\n result.push(dictionaryWithPath);\n }\n\n return result;\n};\n"],"mappings":";;;;;AAMA,MAAa,wBAAwB,OACnC,0BACA,kBAC0B;CAC1B,MAAM,EAAE,WAAW;CACnB,MAAM,EAAE,iBAAiB,YAAY;CAErC,IAAI,OAAO,6BAA6B,UACtC,2BAA2B,CAAC,wBAAwB;CAItD,MAAM,MAAM,QAAQ,eAAe,GAAG,EAAE,WAAW,KAAK,CAAC;CAEzD,MAAM,SAAuB,CAAC;CAE9B,WAAW,MAAM,0BAA0B,0BAA0B;EACnE,MAAM,aAAa,MAAM,wBACvB,CAAC,sBAAsB,GACvB,aACF;EAEA,MAAM,mBAAmB,SAAS,SAAS,sBAAsB;EAEjE,MAAM,YAAY,WAAW;EAC7B,IAAI,CAAC,WAAW;EAEhB,MAAM,qBAAiC;GACrC,GAAG;GACH,UAAU;EACZ;EAEA,OAAO,KAAK,kBAAkB;CAChC;CAEA,OAAO;AACT"}
@@ -29,7 +29,7 @@ const loadRemoteDictionaries = async (configuration = getConfiguration(), onStat
29
29
  return data.updatedAt > localUpdatedAt;
30
30
  });
31
31
  const cachedDictionaries = Object.values(remoteDictionariesRecord).flat().filter((dictionary) => {
32
- const remoteUpdatedAt = distantDictionaryUpdateTimeStamp[dictionary.id].updatedAt;
32
+ const remoteUpdatedAt = dictionary.id ? distantDictionaryUpdateTimeStamp[dictionary.id]?.updatedAt : void 0;
33
33
  const localUpdatedAtRaw = dictionary.updatedAt;
34
34
  const localUpdatedAt = typeof localUpdatedAtRaw === "number" ? localUpdatedAtRaw : localUpdatedAtRaw ? new Date(localUpdatedAtRaw).getTime() : void 0;
35
35
  return typeof localUpdatedAt === "number" && typeof remoteUpdatedAt === "number" && localUpdatedAt >= remoteUpdatedAt;
@@ -1 +1 @@
1
- {"version":3,"file":"loadRemoteDictionaries.mjs","names":[],"sources":["../../../src/loadDictionaries/loadRemoteDictionaries.ts"],"sourcesContent":["import { createIntlayerCMS } from '@intlayer/api';\nimport { dictionaryEndpoint } from '@intlayer/api/dictionary';\n// @ts-ignore @intlayer/backend is not build yet\nimport type { DictionaryAPI } from '@intlayer/backend';\nimport { getConfiguration } from '@intlayer/config/node';\nimport { getRemoteDictionaries } from '@intlayer/dictionaries-entry/remote';\nimport type {\n Dictionary,\n DictionaryId,\n DictionaryKey,\n} from '@intlayer/types/dictionary';\nimport { fetchDistantDictionaries } from '../fetchDistantDictionaries';\nimport { sortAlphabetically } from '../utils/sortAlphabetically';\nimport type { DictionariesStatus } from './loadDictionaries';\n\nexport const formatDistantDictionaries = (\n dictionaries: (DictionaryAPI | Dictionary)[]\n): Dictionary[] =>\n dictionaries.map((dict) => ({\n ...dict,\n localId: `${dict.key}::remote::${dict.id}`,\n location: 'remote' as const,\n }));\n\nexport const loadRemoteDictionaries = async (\n configuration = getConfiguration(),\n onStatusUpdate?: (status: DictionariesStatus[]) => void,\n options?: {\n onStartRemoteCheck?: () => void;\n onStopRemoteCheck?: () => void;\n onError?: (error: Error) => void;\n }\n): Promise<Dictionary[]> => {\n const { editor } = configuration;\n const remoteDictionariesRecord = getRemoteDictionaries(configuration);\n\n const hasRemoteDictionaries = Boolean(editor.clientId && editor.clientSecret);\n\n if (!hasRemoteDictionaries) return [];\n\n try {\n options?.onStartRemoteCheck?.();\n\n const dictionary = dictionaryEndpoint(createIntlayerCMS(configuration));\n\n // Get the list of dictionary keys\n const getDictionariesKeysResult =\n await dictionary.getDictionariesUpdateTimestamp();\n\n const distantDictionaryUpdateTimeStamp: Record<\n DictionaryId,\n { key: DictionaryKey; updatedAt: number }\n > | null = getDictionariesKeysResult.data;\n\n if (!distantDictionaryUpdateTimeStamp) {\n throw new Error('No distant dictionaries found');\n }\n\n const dictionariesIdToFetch = Object.entries(\n distantDictionaryUpdateTimeStamp\n ).filter(([dictionaryId, data]) => {\n // If remote doesn't provide updatedAt, fetch to be safe\n if (!data.updatedAt) return true;\n\n // If no local cache exists, fetch\n const local: Dictionary | undefined = remoteDictionariesRecord[\n data.key\n ]?.find((dictionary) => dictionary.id === dictionaryId);\n if (!local) return true;\n\n const localUpdatedAtRaw = (local as any)?.updatedAt as\n | number\n | string\n | undefined;\n\n const localUpdatedAt =\n typeof localUpdatedAtRaw === 'number'\n ? localUpdatedAtRaw\n : localUpdatedAtRaw\n ? new Date(localUpdatedAtRaw).getTime()\n : undefined;\n\n // If local timestamp missing or older than remote, fetch\n if (typeof localUpdatedAt !== 'number') return true;\n\n return data.updatedAt > localUpdatedAt;\n });\n\n const flatRemoteDictionariesRecord: DictionaryAPI[] = Object.values(\n remoteDictionariesRecord\n ).flat();\n\n const cachedDictionaries: Dictionary[] =\n flatRemoteDictionariesRecord.filter((dictionary) => {\n const remoteUpdatedAt =\n distantDictionaryUpdateTimeStamp[dictionary.id!].updatedAt;\n\n const localUpdatedAtRaw = dictionary.updatedAt;\n\n const localUpdatedAt =\n typeof localUpdatedAtRaw === 'number'\n ? localUpdatedAtRaw\n : localUpdatedAtRaw\n ? new Date(localUpdatedAtRaw).getTime()\n : undefined;\n\n // Consider as cached/imported when local exists and is up-to-date or newer\n return (\n typeof localUpdatedAt === 'number' &&\n typeof remoteUpdatedAt === 'number' &&\n localUpdatedAt >= remoteUpdatedAt\n );\n });\n\n // Report cached as already imported\n if (cachedDictionaries.length > 0) {\n onStatusUpdate?.(\n cachedDictionaries.map((dictionary) => ({\n dictionaryKey: dictionary.key,\n type: 'remote',\n status: 'imported',\n }))\n );\n }\n\n // Several qualified dictionaries can share a key, so keys are deduplicated:\n // one request per key already returns all of its siblings.\n const orderedDistantDictionaryKeys = [\n ...new Set(dictionariesIdToFetch.map(([, data]) => data.key)),\n ].sort(sortAlphabetically);\n\n // Report pending for keys to be fetched so totals are visible immediately\n if (orderedDistantDictionaryKeys.length > 0) {\n onStatusUpdate?.(\n orderedDistantDictionaryKeys.map((key) => ({\n dictionaryKey: key,\n type: 'remote',\n status: 'pending',\n }))\n );\n }\n\n const distantDictionariesData = await fetchDistantDictionaries(\n {\n dictionaryKeys: orderedDistantDictionaryKeys,\n },\n onStatusUpdate\n );\n\n const distantDictionaries: Dictionary[] = formatDistantDictionaries(\n distantDictionariesData\n );\n\n // Fetching by key also returns the up-to-date siblings of a stale\n // dictionary, so drop the cached copies the remote just sent back.\n const fetchedDictionaryIds = new Set(\n distantDictionaries.map((dictionary) => dictionary.id)\n );\n\n const notRefetchedCachedDictionaries = cachedDictionaries.filter(\n (dictionary) => !fetchedDictionaryIds.has(dictionary.id)\n );\n\n return [...notRefetchedCachedDictionaries, ...distantDictionaries];\n } catch (error) {\n options?.onError?.(error as Error);\n return [];\n } finally {\n options?.onStopRemoteCheck?.();\n }\n};\n"],"mappings":";;;;;;;;AAeA,MAAa,6BACX,iBAEA,aAAa,KAAK,UAAU;CAC1B,GAAG;CACH,SAAS,GAAG,KAAK,IAAI,YAAY,KAAK;CACtC,UAAU;AACZ,EAAE;AAEJ,MAAa,yBAAyB,OACpC,gBAAgB,iBAAiB,GACjC,gBACA,YAK0B;CAC1B,MAAM,EAAE,WAAW;CACnB,MAAM,2BAA2B,sBAAsB,aAAa;CAIpE,IAAI,CAF0B,QAAQ,OAAO,YAAY,OAAO,YAEvC,GAAG,OAAO,CAAC;CAEpC,IAAI;EACF,SAAS,qBAAqB;EAQ9B,MAAM,oCAGK,MATQ,mBAAmB,kBAAkB,aAAa,CAIpD,CAAC,CAAC,+BAA+B,EAKd,CAAC;EAErC,IAAI,CAAC,kCACH,MAAM,IAAI,MAAM,+BAA+B;EAGjD,MAAM,wBAAwB,OAAO,QACnC,gCACF,CAAC,CAAC,QAAQ,CAAC,cAAc,UAAU;GAEjC,IAAI,CAAC,KAAK,WAAW,OAAO;GAG5B,MAAM,QAAgC,yBACpC,KAAK,IACN,EAAE,MAAM,eAAe,WAAW,OAAO,YAAY;GACtD,IAAI,CAAC,OAAO,OAAO;GAE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U;EACR,SAAS,oBAAoB;CAC/B;AACF"}
1
+ {"version":3,"file":"loadRemoteDictionaries.mjs","names":[],"sources":["../../../src/loadDictionaries/loadRemoteDictionaries.ts"],"sourcesContent":["import { createIntlayerCMS } from '@intlayer/api';\nimport { dictionaryEndpoint } from '@intlayer/api/dictionary';\n// @ts-ignore @intlayer/backend is not build yet\nimport type { DictionaryAPI } from '@intlayer/backend';\nimport { getConfiguration } from '@intlayer/config/node';\nimport { getRemoteDictionaries } from '@intlayer/dictionaries-entry/remote';\nimport type {\n Dictionary,\n DictionaryId,\n DictionaryKey,\n} from '@intlayer/types/dictionary';\nimport { fetchDistantDictionaries } from '../fetchDistantDictionaries';\nimport { sortAlphabetically } from '../utils/sortAlphabetically';\nimport type { DictionariesStatus } from './loadDictionaries';\n\nexport const formatDistantDictionaries = (\n dictionaries: (DictionaryAPI | Dictionary)[]\n): Dictionary[] =>\n dictionaries.map((dict) => ({\n ...dict,\n localId: `${dict.key}::remote::${dict.id}`,\n location: 'remote' as const,\n }));\n\nexport const loadRemoteDictionaries = async (\n configuration = getConfiguration(),\n onStatusUpdate?: (status: DictionariesStatus[]) => void,\n options?: {\n onStartRemoteCheck?: () => void;\n onStopRemoteCheck?: () => void;\n onError?: (error: Error) => void;\n }\n): Promise<Dictionary[]> => {\n const { editor } = configuration;\n const remoteDictionariesRecord = getRemoteDictionaries(configuration);\n\n const hasRemoteDictionaries = Boolean(editor.clientId && editor.clientSecret);\n\n if (!hasRemoteDictionaries) return [];\n\n try {\n options?.onStartRemoteCheck?.();\n\n const dictionary = dictionaryEndpoint(createIntlayerCMS(configuration));\n\n // Get the list of dictionary keys\n const getDictionariesKeysResult =\n await dictionary.getDictionariesUpdateTimestamp();\n\n const distantDictionaryUpdateTimeStamp: Record<\n DictionaryId,\n { key: DictionaryKey; updatedAt: number }\n > | null = getDictionariesKeysResult.data;\n\n if (!distantDictionaryUpdateTimeStamp) {\n throw new Error('No distant dictionaries found');\n }\n\n const dictionariesIdToFetch = Object.entries(\n distantDictionaryUpdateTimeStamp\n ).filter(([dictionaryId, data]) => {\n // If remote doesn't provide updatedAt, fetch to be safe\n if (!data.updatedAt) return true;\n\n // If no local cache exists, fetch\n const local: Dictionary | undefined = remoteDictionariesRecord[\n data.key\n ]?.find((dictionary) => dictionary.id === dictionaryId);\n if (!local) return true;\n\n const localUpdatedAtRaw = (local as any)?.updatedAt as\n | number\n | string\n | undefined;\n\n const localUpdatedAt =\n typeof localUpdatedAtRaw === 'number'\n ? localUpdatedAtRaw\n : localUpdatedAtRaw\n ? new Date(localUpdatedAtRaw).getTime()\n : undefined;\n\n // If local timestamp missing or older than remote, fetch\n if (typeof localUpdatedAt !== 'number') return true;\n\n return data.updatedAt > localUpdatedAt;\n });\n\n const flatRemoteDictionariesRecord: DictionaryAPI[] = Object.values(\n remoteDictionariesRecord\n ).flat();\n\n const cachedDictionaries: Dictionary[] =\n flatRemoteDictionariesRecord.filter((dictionary) => {\n const remoteUpdatedAt = dictionary.id\n ? distantDictionaryUpdateTimeStamp[dictionary.id]?.updatedAt\n : undefined;\n\n const localUpdatedAtRaw = dictionary.updatedAt;\n\n const localUpdatedAt =\n typeof localUpdatedAtRaw === 'number'\n ? localUpdatedAtRaw\n : localUpdatedAtRaw\n ? new Date(localUpdatedAtRaw).getTime()\n : undefined;\n\n // Consider as cached/imported when local exists and is up-to-date or newer\n return (\n typeof localUpdatedAt === 'number' &&\n typeof remoteUpdatedAt === 'number' &&\n localUpdatedAt >= remoteUpdatedAt\n );\n });\n\n // Report cached as already imported\n if (cachedDictionaries.length > 0) {\n onStatusUpdate?.(\n cachedDictionaries.map((dictionary) => ({\n dictionaryKey: dictionary.key,\n type: 'remote',\n status: 'imported',\n }))\n );\n }\n\n // Several qualified dictionaries can share a key, so keys are deduplicated:\n // one request per key already returns all of its siblings.\n const orderedDistantDictionaryKeys = [\n ...new Set(dictionariesIdToFetch.map(([, data]) => data.key)),\n ].sort(sortAlphabetically);\n\n // Report pending for keys to be fetched so totals are visible immediately\n if (orderedDistantDictionaryKeys.length > 0) {\n onStatusUpdate?.(\n orderedDistantDictionaryKeys.map((key) => ({\n dictionaryKey: key,\n type: 'remote',\n status: 'pending',\n }))\n );\n }\n\n const distantDictionariesData = await fetchDistantDictionaries(\n {\n dictionaryKeys: orderedDistantDictionaryKeys,\n },\n onStatusUpdate\n );\n\n const distantDictionaries: Dictionary[] = formatDistantDictionaries(\n distantDictionariesData\n );\n\n // Fetching by key also returns the up-to-date siblings of a stale\n // dictionary, so drop the cached copies the remote just sent back.\n const fetchedDictionaryIds = new Set(\n distantDictionaries.map((dictionary) => dictionary.id)\n );\n\n const notRefetchedCachedDictionaries = cachedDictionaries.filter(\n (dictionary) => !fetchedDictionaryIds.has(dictionary.id)\n );\n\n return [...notRefetchedCachedDictionaries, ...distantDictionaries];\n } catch (error) {\n options?.onError?.(error as Error);\n return [];\n } finally {\n options?.onStopRemoteCheck?.();\n }\n};\n"],"mappings":";;;;;;;;AAeA,MAAa,6BACX,iBAEA,aAAa,KAAK,UAAU;CAC1B,GAAG;CACH,SAAS,GAAG,KAAK,IAAI,YAAY,KAAK;CACtC,UAAU;AACZ,EAAE;AAEJ,MAAa,yBAAyB,OACpC,gBAAgB,iBAAiB,GACjC,gBACA,YAK0B;CAC1B,MAAM,EAAE,WAAW;CACnB,MAAM,2BAA2B,sBAAsB,aAAa;CAIpE,IAAI,CAF0B,QAAQ,OAAO,YAAY,OAAO,YAEvC,GAAG,OAAO,CAAC;CAEpC,IAAI;EACF,SAAS,qBAAqB;EAQ9B,MAAM,oCAGK,MATQ,mBAAmB,kBAAkB,aAAa,CAIpD,CAAC,CAAC,+BAA+B,EAKd,CAAC;EAErC,IAAI,CAAC,kCACH,MAAM,IAAI,MAAM,+BAA+B;EAGjD,MAAM,wBAAwB,OAAO,QACnC,gCACF,CAAC,CAAC,QAAQ,CAAC,cAAc,UAAU;GAEjC,IAAI,CAAC,KAAK,WAAW,OAAO;GAG5B,MAAM,QAAgC,yBACpC,KAAK,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CAGjB,GAAG,GAAG,mBAAmB;CACnE,SAAS,OAAO;EACd,SAAS,UAAU,KAAc;EACjC,OAAO,CAAC;CACV,UAAU;EACR,SAAS,oBAAoB;CAC/B;AACF"}
@@ -106,7 +106,7 @@ var DictionariesLogger = class {
106
106
  }
107
107
  render() {
108
108
  const { localTotal, localDone, remoteTotal, remoteDone, pluginTotal, pluginDone } = this.computeProgress();
109
- const frame = this.spinnerFrames[this.spinnerIndex];
109
+ const frame = this.spinnerFrames[this.spinnerIndex] ?? "";
110
110
  const clock = colorize(frame, ANSIColors.BLUE);
111
111
  const lines = [];
112
112
  const isLocalDone = localDone === localTotal;
@@ -1 +1 @@
1
- {"version":3,"file":"log.mjs","names":[],"sources":["../../../src/loadDictionaries/log.ts"],"sourcesContent":["import { log } from '@intlayer/config/built';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport {\n colorize,\n getPrefix,\n spinnerFrames,\n v,\n x,\n} from '@intlayer/config/logger';\nimport { extractErrorMessage } from '@intlayer/config/utils';\nimport type { DictionariesStatus } from './loadDictionaries';\n\nexport class DictionariesLogger {\n private statuses: DictionariesStatus[] = [];\n private spinnerTimer: NodeJS.Timeout | null = null;\n private spinnerIndex = 0;\n private renderedLines = 0;\n private readonly spinnerFrames = spinnerFrames;\n private isFinished = false;\n private readonly prefix: string;\n private lastRenderedState: string = '';\n private remoteCheckInProgress = false;\n private expectRemote = false;\n private remoteError: string | undefined;\n private pluginTotal = 0;\n private pluginDone = 0;\n private pluginNames: string[] = [];\n private pluginError: string | undefined;\n\n constructor() {\n this.prefix = getPrefix(log?.prefix) ?? '';\n }\n\n setExpectRemote(expect: boolean) {\n this.expectRemote = expect;\n }\n\n startRemoteCheck() {\n if (this.isFinished) return;\n this.remoteCheckInProgress = true;\n this.startSpinner();\n this.render();\n }\n\n stopRemoteCheck() {\n this.remoteCheckInProgress = false;\n }\n\n update(newStatuses: DictionariesStatus[]) {\n if (this.isFinished) return;\n for (const status of newStatuses) {\n const index = this.statuses.findIndex(\n (s) =>\n s.dictionaryKey === status.dictionaryKey && s.type === status.type\n );\n if (index >= 0) {\n this.statuses[index] = status;\n } else {\n this.statuses.push(status);\n }\n }\n\n // If we expect remote fetch later, avoid rendering a local-only line first\n const { remoteTotal } = this.computeProgress();\n if (this.expectRemote && !this.remoteCheckInProgress && remoteTotal === 0) {\n // Do not start spinner or render yet; wait until remote check starts\n return;\n }\n\n this.startSpinner();\n this.render();\n }\n\n finish() {\n this.isFinished = true;\n this.stopSpinner();\n // Render final state and keep it visible\n this.render();\n }\n\n private startSpinner() {\n if (this.spinnerTimer || this.isFinished) return;\n this.spinnerTimer = setInterval(() => {\n this.spinnerIndex = (this.spinnerIndex + 1) % this.spinnerFrames.length;\n this.render();\n }, 100);\n }\n\n private stopSpinner() {\n if (!this.spinnerTimer) return;\n clearInterval(this.spinnerTimer);\n this.spinnerTimer = null;\n }\n\n public setRemoteError = (error?: Error) => {\n this.remoteError = extractErrorMessage(error);\n // Avoid rendering a transient remote-only line while the remote check flag is still true\n // Ensure local + remote are rendered together after a failure\n this.stopRemoteCheck();\n this.render();\n };\n\n /**\n * Register the names of the plugins providing dictionaries.\n * They are displayed next to the plugin progress counters, e.g.\n * `Plugin content: 6/6 (sync-json, load-po)`.\n *\n * @param names - Names of the plugins exposing a `loadDictionaries` hook\n */\n setPluginNames(names: string[]) {\n if (this.isFinished) return;\n // Guard against plugins declared without a name at runtime\n this.pluginNames = names.filter((name) => Boolean(name));\n this.render();\n }\n\n setPluginTotal(total: number) {\n if (this.isFinished) return;\n this.pluginTotal = total;\n if (total > 0) {\n this.startSpinner();\n }\n this.render();\n }\n\n setPluginDone(done: number) {\n if (this.isFinished) return;\n this.pluginDone = done;\n this.render();\n }\n\n /**\n * Flag the plugin line as errored.\n *\n * @param error - Error thrown while loading the plugin dictionaries\n * @param pluginName - Name of the plugin that threw, prefixed to the message\n */\n setPluginError(error?: Error, pluginName?: string) {\n if (this.isFinished) return;\n const errorMessage = extractErrorMessage(error);\n this.pluginError = pluginName\n ? `${pluginName}: ${errorMessage}`\n : errorMessage;\n this.render();\n }\n\n private render() {\n const {\n localTotal,\n localDone,\n remoteTotal,\n remoteDone,\n pluginTotal,\n pluginDone,\n } = this.computeProgress();\n\n const frame = this.spinnerFrames[this.spinnerIndex];\n const clock = colorize(frame, ANSIColors.BLUE);\n const lines: string[] = [];\n\n const isLocalDone = localDone === localTotal;\n const isRemoteDone = remoteDone === remoteTotal;\n const isPluginDone = pluginDone === pluginTotal;\n\n const suppressLocalWhileCheckingRemote =\n this.expectRemote && this.remoteCheckInProgress && remoteTotal === 0;\n\n if (!suppressLocalWhileCheckingRemote) {\n if (isLocalDone) {\n lines.push(\n `${this.prefix} ${v} Local content: ${colorize(`${localDone}`, ANSIColors.GREEN)}${colorize(`/${localTotal}`, ANSIColors.GREY)}`\n );\n } else {\n lines.push(\n `${this.prefix} ${clock} Local content: ${colorize(`${localDone}`, ANSIColors.BLUE)}${colorize(`/${localTotal}`, ANSIColors.GREY)}`\n );\n }\n }\n\n // Single remote line: show error, check, or progress counts\n if (remoteTotal > 0 || this.remoteCheckInProgress || this.remoteError) {\n if (this.remoteError) {\n lines.push(\n `${this.prefix} ${x} Remote content: ${colorize(\n this.remoteError,\n ANSIColors.RED\n )}`\n );\n } else if (remoteTotal === 0) {\n lines.push(\n `${this.prefix} ${clock} Remote content: ${colorize('Check server', ANSIColors.BLUE)}`\n );\n } else if (isRemoteDone) {\n lines.push(\n `${this.prefix} ${v} Remote content: ${colorize(`${remoteDone}`, ANSIColors.GREEN)}${colorize(`/${remoteTotal}`, ANSIColors.GREY)}`\n );\n } else {\n lines.push(\n `${this.prefix} ${clock} Remote content: ${colorize(`${remoteDone}`, ANSIColors.BLUE)}${colorize(`/${remoteTotal}`, ANSIColors.GREY)}`\n );\n }\n }\n\n // Plugin line: show error or progress counts, suffixed by the plugin names\n if (pluginTotal > 0 || this.pluginError) {\n const pluginNamesSuffix =\n this.pluginNames.length > 0\n ? colorize(` (${this.pluginNames.join(', ')})`, ANSIColors.GREY)\n : '';\n\n if (this.pluginError) {\n lines.push(\n `${this.prefix} ${x} Plugin content: ${colorize(\n this.pluginError,\n ANSIColors.RED\n )}`\n );\n } else if (isPluginDone) {\n lines.push(\n `${this.prefix} ${v} Plugin content: ${colorize(`${pluginDone}`, ANSIColors.GREEN)}${colorize(`/${pluginTotal}`, ANSIColors.GREY)}${pluginNamesSuffix}`\n );\n } else {\n lines.push(\n `${this.prefix} ${clock} Plugin content: ${colorize(`${pluginDone}`, ANSIColors.BLUE)}${colorize(`/${pluginTotal}`, ANSIColors.GREY)}${pluginNamesSuffix}`\n );\n }\n }\n\n // Check if the state has changed to avoid duplicate rendering\n const currentState = lines.join('\\n');\n if (currentState === this.lastRenderedState) {\n return;\n }\n this.lastRenderedState = currentState;\n\n if (this.renderedLines > 0) {\n process.stdout.write(`\\x1b[${this.renderedLines}F`);\n }\n\n const totalLinesToClear = Math.max(this.renderedLines, lines.length);\n for (let i = 0; i < totalLinesToClear; i++) {\n process.stdout.write('\\x1b[2K');\n const line = lines[i];\n if (line !== undefined) {\n process.stdout.write(line);\n }\n process.stdout.write('\\n');\n }\n\n this.renderedLines = lines.length;\n }\n\n private computeProgress() {\n const localKeys = new Set(\n this.statuses\n .filter((s) => s.type === 'local')\n .map((s) => s.dictionaryKey)\n );\n\n const localDoneKeys = new Set(\n this.statuses\n .filter(\n (s) =>\n s.type === 'local' && (s.status === 'built' || s.status === 'error')\n )\n .map((s) => s.dictionaryKey)\n );\n\n const remoteKeys = new Set(\n this.statuses\n .filter((s) => s.type === 'remote')\n .map((s) => s.dictionaryKey)\n );\n\n const remoteDoneKeys = new Set(\n this.statuses\n .filter(\n (s) =>\n s.type === 'remote' &&\n (s.status === 'fetched' ||\n s.status === 'imported' ||\n s.status === 'error')\n )\n .map((s) => s.dictionaryKey)\n );\n\n return {\n localTotal: localKeys.size,\n localDone: localDoneKeys.size,\n remoteTotal: remoteKeys.size,\n remoteDone: remoteDoneKeys.size,\n pluginTotal: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EACpC,IAAI,iBAAiB,KAAK,mBACxB;EAEF,KAAK,oBAAoB;EAEzB,IAAI,KAAK,gBAAgB,GACvB,QAAQ,OAAO,MAAM,QAAQ,KAAK,cAAc,EAAE;EAGpD,MAAM,oBAAoB,KAAK,IAAI,KAAK,eAAe,MAAM,MAAM;EACnE,KAAK,IAAI,IAAI,GAAG,IAAI,mBAAmB,KAAK;GAC1C,QAAQ,OAAO,MAAM,SAAS;GAC9B,MAAM,OAAO,MAAM;GACnB,IAAI,SAAS,QACX,QAAQ,OAAO,MAAM,IAAI;GAE3B,QAAQ,OAAO,MAAM,IAAI;EAC3B;EAEA,KAAK,gBAAgB,MAAM;CAC7B;CAEA,AAAQ,kBAAkB;EACxB,MAAM,YAAY,IAAI,IACpB,KAAK,SACF,QAAQ,MAAM,EAAE,SAAS,OAAO,CAAC,CACjC,KAAK,MAAM,EAAE,aAAa,CAC/B;EAEA,MAAM,gBAAgB,IAAI,IACxB,KAAK,SACF,QACE,MACC,EAAE,SAAS,YAAY,EAAE,WAAW,WAAW,EAAE,WAAW,QAChE,CAAC,CACA,KAAK,MAAM,EAAE,aAAa,CAC/B;EAEA,MAAM,aAAa,IAAI,IACrB,KAAK,SACF,QAAQ,MAAM,EAAE,SAAS,QAAQ,CAAC,CAClC,KAAK,MAAM,EAAE,aAAa,CAC/B;EAEA,MAAM,iBAAiB,IAAI,IACzB,KAAK,SACF,QACE,MACC,EAAE,SAAS,aACV,EAAE,WAAW,aACZ,EAAE,WAAW,cACb,EAAE,WAAW,QACnB,CAAC,CACA,KAAK,MAAM,EAAE,aAAa,CAC/B;EAEA,OAAO;GACL,YAAY,UAAU;GACtB,WAAW,cAAc;GACzB,aAAa,WAAW;GACxB,YAAY,eAAe;GAC3B,aAAa,KAAK;GAClB,YAAY,KAAK;EACnB;CACF;AACF"}
1
+ {"version":3,"file":"log.mjs","names":[],"sources":["../../../src/loadDictionaries/log.ts"],"sourcesContent":["import { log } from '@intlayer/config/built';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport {\n colorize,\n getPrefix,\n spinnerFrames,\n v,\n x,\n} from '@intlayer/config/logger';\nimport { extractErrorMessage } from '@intlayer/config/utils';\nimport type { DictionariesStatus } from './loadDictionaries';\n\nexport class DictionariesLogger {\n private statuses: DictionariesStatus[] = [];\n private spinnerTimer: NodeJS.Timeout | null = null;\n private spinnerIndex = 0;\n private renderedLines = 0;\n private readonly spinnerFrames = spinnerFrames;\n private isFinished = false;\n private readonly prefix: string;\n private lastRenderedState: string = '';\n private remoteCheckInProgress = false;\n private expectRemote = false;\n private remoteError: string | undefined;\n private pluginTotal = 0;\n private pluginDone = 0;\n private pluginNames: string[] = [];\n private pluginError: string | undefined;\n\n constructor() {\n this.prefix = getPrefix(log?.prefix) ?? '';\n }\n\n setExpectRemote(expect: boolean) {\n this.expectRemote = expect;\n }\n\n startRemoteCheck() {\n if (this.isFinished) return;\n this.remoteCheckInProgress = true;\n this.startSpinner();\n this.render();\n }\n\n stopRemoteCheck() {\n this.remoteCheckInProgress = false;\n }\n\n update(newStatuses: DictionariesStatus[]) {\n if (this.isFinished) return;\n for (const status of newStatuses) {\n const index = this.statuses.findIndex(\n (s) =>\n s.dictionaryKey === status.dictionaryKey && s.type === status.type\n );\n if (index >= 0) {\n this.statuses[index] = status;\n } else {\n this.statuses.push(status);\n }\n }\n\n // If we expect remote fetch later, avoid rendering a local-only line first\n const { remoteTotal } = this.computeProgress();\n if (this.expectRemote && !this.remoteCheckInProgress && remoteTotal === 0) {\n // Do not start spinner or render yet; wait until remote check starts\n return;\n }\n\n this.startSpinner();\n this.render();\n }\n\n finish() {\n this.isFinished = true;\n this.stopSpinner();\n // Render final state and keep it visible\n this.render();\n }\n\n private startSpinner() {\n if (this.spinnerTimer || this.isFinished) return;\n this.spinnerTimer = setInterval(() => {\n this.spinnerIndex = (this.spinnerIndex + 1) % this.spinnerFrames.length;\n this.render();\n }, 100);\n }\n\n private stopSpinner() {\n if (!this.spinnerTimer) return;\n clearInterval(this.spinnerTimer);\n this.spinnerTimer = null;\n }\n\n public setRemoteError = (error?: Error) => {\n this.remoteError = extractErrorMessage(error);\n // Avoid rendering a transient remote-only line while the remote check flag is still true\n // Ensure local + remote are rendered together after a failure\n this.stopRemoteCheck();\n this.render();\n };\n\n /**\n * Register the names of the plugins providing dictionaries.\n * They are displayed next to the plugin progress counters, e.g.\n * `Plugin content: 6/6 (sync-json, load-po)`.\n *\n * @param names - Names of the plugins exposing a `loadDictionaries` hook\n */\n setPluginNames(names: string[]) {\n if (this.isFinished) return;\n // Guard against plugins declared without a name at runtime\n this.pluginNames = names.filter((name) => Boolean(name));\n this.render();\n }\n\n setPluginTotal(total: number) {\n if (this.isFinished) return;\n this.pluginTotal = total;\n if (total > 0) {\n this.startSpinner();\n }\n this.render();\n }\n\n setPluginDone(done: number) {\n if (this.isFinished) return;\n this.pluginDone = done;\n this.render();\n }\n\n /**\n * Flag the plugin line as errored.\n *\n * @param error - Error thrown while loading the plugin dictionaries\n * @param pluginName - Name of the plugin that threw, prefixed to the message\n */\n setPluginError(error?: Error, pluginName?: string) {\n if (this.isFinished) return;\n const errorMessage = extractErrorMessage(error);\n this.pluginError = pluginName\n ? `${pluginName}: ${errorMessage}`\n : errorMessage;\n this.render();\n }\n\n private render() {\n const {\n localTotal,\n localDone,\n remoteTotal,\n remoteDone,\n pluginTotal,\n pluginDone,\n } = this.computeProgress();\n\n const frame = this.spinnerFrames[this.spinnerIndex] ?? '';\n const clock = colorize(frame, ANSIColors.BLUE);\n const lines: string[] = [];\n\n const isLocalDone = localDone === localTotal;\n const isRemoteDone = remoteDone === remoteTotal;\n const isPluginDone = pluginDone === pluginTotal;\n\n const suppressLocalWhileCheckingRemote =\n this.expectRemote && this.remoteCheckInProgress && remoteTotal === 0;\n\n if (!suppressLocalWhileCheckingRemote) {\n if (isLocalDone) {\n lines.push(\n `${this.prefix} ${v} Local content: ${colorize(`${localDone}`, ANSIColors.GREEN)}${colorize(`/${localTotal}`, ANSIColors.GREY)}`\n );\n } else {\n lines.push(\n `${this.prefix} ${clock} Local content: ${colorize(`${localDone}`, ANSIColors.BLUE)}${colorize(`/${localTotal}`, ANSIColors.GREY)}`\n );\n }\n }\n\n // Single remote line: show error, check, or progress counts\n if (remoteTotal > 0 || this.remoteCheckInProgress || this.remoteError) {\n if (this.remoteError) {\n lines.push(\n `${this.prefix} ${x} Remote content: ${colorize(\n this.remoteError,\n ANSIColors.RED\n )}`\n );\n } else if (remoteTotal === 0) {\n lines.push(\n `${this.prefix} ${clock} Remote content: ${colorize('Check server', ANSIColors.BLUE)}`\n );\n } else if (isRemoteDone) {\n lines.push(\n `${this.prefix} ${v} Remote content: ${colorize(`${remoteDone}`, ANSIColors.GREEN)}${colorize(`/${remoteTotal}`, ANSIColors.GREY)}`\n );\n } else {\n lines.push(\n `${this.prefix} ${clock} Remote content: ${colorize(`${remoteDone}`, ANSIColors.BLUE)}${colorize(`/${remoteTotal}`, ANSIColors.GREY)}`\n );\n }\n }\n\n // Plugin line: show error or progress counts, suffixed by the plugin names\n if (pluginTotal > 0 || this.pluginError) {\n const pluginNamesSuffix =\n this.pluginNames.length > 0\n ? colorize(` (${this.pluginNames.join(', ')})`, ANSIColors.GREY)\n : '';\n\n if (this.pluginError) {\n lines.push(\n `${this.prefix} ${x} Plugin content: ${colorize(\n this.pluginError,\n ANSIColors.RED\n )}`\n );\n } else if (isPluginDone) {\n lines.push(\n `${this.prefix} ${v} Plugin content: ${colorize(`${pluginDone}`, ANSIColors.GREEN)}${colorize(`/${pluginTotal}`, ANSIColors.GREY)}${pluginNamesSuffix}`\n );\n } else {\n lines.push(\n `${this.prefix} ${clock} Plugin content: ${colorize(`${pluginDone}`, ANSIColors.BLUE)}${colorize(`/${pluginTotal}`, ANSIColors.GREY)}${pluginNamesSuffix}`\n );\n }\n }\n\n // Check if the state has changed to avoid duplicate rendering\n const currentState = lines.join('\\n');\n if (currentState === this.lastRenderedState) {\n return;\n }\n this.lastRenderedState = currentState;\n\n if (this.renderedLines > 0) {\n process.stdout.write(`\\x1b[${this.renderedLines}F`);\n }\n\n const totalLinesToClear = Math.max(this.renderedLines, lines.length);\n for (let i = 0; i < totalLinesToClear; i++) {\n process.stdout.write('\\x1b[2K');\n const line = lines[i];\n if (line !== undefined) {\n process.stdout.write(line);\n }\n process.stdout.write('\\n');\n }\n\n this.renderedLines = lines.length;\n }\n\n private computeProgress() {\n const localKeys = new Set(\n this.statuses\n .filter((s) => s.type === 'local')\n .map((s) => s.dictionaryKey)\n );\n\n const localDoneKeys = new Set(\n this.statuses\n .filter(\n (s) =>\n s.type === 'local' && (s.status === 'built' || s.status === 'error')\n )\n .map((s) => s.dictionaryKey)\n );\n\n const remoteKeys = new Set(\n this.statuses\n .filter((s) => s.type === 'remote')\n .map((s) => s.dictionaryKey)\n );\n\n const remoteDoneKeys = new Set(\n this.statuses\n .filter(\n (s) =>\n s.type === 'remote' &&\n (s.status === 'fetched' ||\n s.status === 'imported' ||\n s.status === 'error')\n )\n .map((s) => s.dictionaryKey)\n );\n\n return {\n localTotal: localKeys.size,\n localDone: localDoneKeys.size,\n remoteTotal: remoteKeys.size,\n remoteDone: remoteDoneKeys.size,\n pluginTotal: this.pluginTotal,\n pluginDone: this.pluginDone,\n } as const;\n }\n}\n"],"mappings":";;;;;;AAYA,IAAa,qBAAb,MAAgC;CAC9B,AAAQ,WAAiC,CAAC;CAC1C,AAAQ,eAAsC;CAC9C,AAAQ,eAAe;CACvB,AAAQ,gBAAgB;CACxB,AAAiB,gBAAgB;CACjC,AAAQ,aAAa;CACrB,AAAiB;CACjB,AAAQ,oBAA4B;CACpC,AAAQ,wBAAwB;CAChC,AAAQ,eAAe;CACvB,AAAQ;CACR,AAAQ,cAAc;CACtB,AAAQ,aAAa;CACrB,AAAQ,cAAwB,CAAC;CACjC,AAAQ;CAER,cAAc;EACZ,KAAK,SAAS,UAAU,KAAK,MAAM,KAAK;CAC1C;CAEA,gBAAgB,QAAiB;EAC/B,KAAK,eAAe;CACtB;CAEA,mBAAmB;EACj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