@intlayer/chokidar 8.4.3 → 8.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (497) hide show
  1. package/dist/cjs/_virtual/_rolldown/runtime.cjs +29 -0
  2. package/dist/cjs/_virtual/_utils_asset.cjs +98 -0
  3. package/dist/cjs/build.cjs +58 -1
  4. package/dist/cjs/buildIntlayerDictionary/buildIntlayerDictionary.cjs +62 -1
  5. package/dist/cjs/buildIntlayerDictionary/buildIntlayerDictionary.cjs.map +1 -1
  6. package/dist/cjs/buildIntlayerDictionary/index.cjs +6 -1
  7. package/dist/cjs/buildIntlayerDictionary/processContentDeclaration.cjs +26 -1
  8. package/dist/cjs/buildIntlayerDictionary/processContentDeclaration.cjs.map +1 -1
  9. package/dist/cjs/buildIntlayerDictionary/writeDynamicDictionary.cjs +107 -4
  10. package/dist/cjs/buildIntlayerDictionary/writeDynamicDictionary.cjs.map +1 -1
  11. package/dist/cjs/buildIntlayerDictionary/writeFetchDictionary.cjs +81 -5
  12. package/dist/cjs/buildIntlayerDictionary/writeFetchDictionary.cjs.map +1 -1
  13. package/dist/cjs/buildIntlayerDictionary/writeMergedDictionary.cjs +46 -1
  14. package/dist/cjs/buildIntlayerDictionary/writeMergedDictionary.cjs.map +1 -1
  15. package/dist/cjs/buildIntlayerDictionary/writeRemoteDictionary.cjs +50 -1
  16. package/dist/cjs/buildIntlayerDictionary/writeRemoteDictionary.cjs.map +1 -1
  17. package/dist/cjs/buildIntlayerDictionary/writeUnmergedDictionary.cjs +59 -1
  18. package/dist/cjs/buildIntlayerDictionary/writeUnmergedDictionary.cjs.map +1 -1
  19. package/dist/cjs/cleanOutputDir.cjs +30 -1
  20. package/dist/cjs/cleanOutputDir.cjs.map +1 -1
  21. package/dist/cjs/cleanRemovedContentDeclaration.cjs +97 -1
  22. package/dist/cjs/cleanRemovedContentDeclaration.cjs.map +1 -1
  23. package/dist/cjs/cli.cjs +35 -1
  24. package/dist/cjs/createDictionaryEntryPoint/createDictionaryEntryPoint.cjs +70 -1
  25. package/dist/cjs/createDictionaryEntryPoint/createDictionaryEntryPoint.cjs.map +1 -1
  26. package/dist/cjs/createDictionaryEntryPoint/generateDictionaryListContent.cjs +42 -7
  27. package/dist/cjs/createDictionaryEntryPoint/generateDictionaryListContent.cjs.map +1 -1
  28. package/dist/cjs/createDictionaryEntryPoint/getBuiltDictionariesPath.cjs +23 -1
  29. package/dist/cjs/createDictionaryEntryPoint/getBuiltDictionariesPath.cjs.map +1 -1
  30. package/dist/cjs/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.cjs +24 -1
  31. package/dist/cjs/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.cjs.map +1 -1
  32. package/dist/cjs/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.cjs +24 -1
  33. package/dist/cjs/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.cjs.map +1 -1
  34. package/dist/cjs/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.cjs +23 -1
  35. package/dist/cjs/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.cjs.map +1 -1
  36. package/dist/cjs/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.cjs +23 -1
  37. package/dist/cjs/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.cjs.map +1 -1
  38. package/dist/cjs/createDictionaryEntryPoint/index.cjs +16 -1
  39. package/dist/cjs/createType/createModuleAugmentation.cjs +112 -9
  40. package/dist/cjs/createType/createModuleAugmentation.cjs.map +1 -1
  41. package/dist/cjs/createType/createType.cjs +29 -1
  42. package/dist/cjs/createType/createType.cjs.map +1 -1
  43. package/dist/cjs/createType/index.cjs +8 -1
  44. package/dist/cjs/detectFormatCommand.cjs +32 -1
  45. package/dist/cjs/detectFormatCommand.cjs.map +1 -1
  46. package/dist/cjs/fetchDistantDictionaries.cjs +51 -1
  47. package/dist/cjs/fetchDistantDictionaries.cjs.map +1 -1
  48. package/dist/cjs/filterInvalidDictionaries.cjs +52 -1
  49. package/dist/cjs/filterInvalidDictionaries.cjs.map +1 -1
  50. package/dist/cjs/formatDictionary.cjs +49 -1
  51. package/dist/cjs/formatDictionary.cjs.map +1 -1
  52. package/dist/cjs/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs +61 -7
  53. package/dist/cjs/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs.map +1 -1
  54. package/dist/cjs/getContentDeclarationFileTemplate/index.cjs +4 -1
  55. package/dist/cjs/handleAdditionalContentDeclarationFile.cjs +34 -1
  56. package/dist/cjs/handleAdditionalContentDeclarationFile.cjs.map +1 -1
  57. package/dist/cjs/handleContentDeclarationFileChange.cjs +49 -1
  58. package/dist/cjs/handleContentDeclarationFileChange.cjs.map +1 -1
  59. package/dist/cjs/handleContentDeclarationFileMoved.cjs +24 -1
  60. package/dist/cjs/handleContentDeclarationFileMoved.cjs.map +1 -1
  61. package/dist/cjs/handleUnlinkedContentDeclarationFile.cjs +37 -1
  62. package/dist/cjs/handleUnlinkedContentDeclarationFile.cjs.map +1 -1
  63. package/dist/cjs/init/index.cjs +284 -1
  64. package/dist/cjs/init/index.cjs.map +1 -1
  65. package/dist/cjs/init/utils/configManipulation.cjs +111 -1
  66. package/dist/cjs/init/utils/configManipulation.cjs.map +1 -1
  67. package/dist/cjs/init/utils/fileSystem.cjs +39 -1
  68. package/dist/cjs/init/utils/fileSystem.cjs.map +1 -1
  69. package/dist/cjs/init/utils/index.cjs +14 -1
  70. package/dist/cjs/init/utils/jsonParser.cjs +42 -3
  71. package/dist/cjs/init/utils/jsonParser.cjs.map +1 -1
  72. package/dist/cjs/init/utils/tsConfig.cjs +18 -1
  73. package/dist/cjs/init/utils/tsConfig.cjs.map +1 -1
  74. package/dist/cjs/initConfig/index.cjs +39 -1
  75. package/dist/cjs/initConfig/index.cjs.map +1 -1
  76. package/dist/cjs/installMCP/installMCP.cjs +50 -1
  77. package/dist/cjs/installMCP/installMCP.cjs.map +1 -1
  78. package/dist/cjs/installSkills/index.cjs +303 -1
  79. package/dist/cjs/installSkills/index.cjs.map +1 -1
  80. package/dist/cjs/listDictionariesPath.cjs +42 -1
  81. package/dist/cjs/listDictionariesPath.cjs.map +1 -1
  82. package/dist/cjs/listGitFiles.cjs +105 -5
  83. package/dist/cjs/listGitFiles.cjs.map +1 -1
  84. package/dist/cjs/listProjects.cjs +47 -1
  85. package/dist/cjs/listProjects.cjs.map +1 -1
  86. package/dist/cjs/loadDictionaries/getIntlayerBundle.cjs +68 -1
  87. package/dist/cjs/loadDictionaries/getIntlayerBundle.cjs.map +1 -1
  88. package/dist/cjs/loadDictionaries/index.cjs +14 -1
  89. package/dist/cjs/loadDictionaries/loadContentDeclaration.cjs +93 -2
  90. package/dist/cjs/loadDictionaries/loadContentDeclaration.cjs.map +1 -1
  91. package/dist/cjs/loadDictionaries/loadDictionaries.cjs +127 -1
  92. package/dist/cjs/loadDictionaries/loadDictionaries.cjs.map +1 -1
  93. package/dist/cjs/loadDictionaries/loadLocalDictionaries.cjs +27 -1
  94. package/dist/cjs/loadDictionaries/loadLocalDictionaries.cjs.map +1 -1
  95. package/dist/cjs/loadDictionaries/loadRemoteDictionaries.cjs +61 -1
  96. package/dist/cjs/loadDictionaries/loadRemoteDictionaries.cjs.map +1 -1
  97. package/dist/cjs/loadDictionaries/log.cjs +138 -3
  98. package/dist/cjs/loadDictionaries/log.cjs.map +1 -1
  99. package/dist/cjs/loadDictionaries/logTypeScriptErrors.cjs +63 -2
  100. package/dist/cjs/loadDictionaries/logTypeScriptErrors.cjs.map +1 -1
  101. package/dist/cjs/logConfigDetails.cjs +39 -2
  102. package/dist/cjs/logConfigDetails.cjs.map +1 -1
  103. package/dist/cjs/prepareIntlayer.cjs +103 -1
  104. package/dist/cjs/prepareIntlayer.cjs.map +1 -1
  105. package/dist/cjs/reduceDictionaryContent/applyMask.cjs +30 -1
  106. package/dist/cjs/reduceDictionaryContent/applyMask.cjs.map +1 -1
  107. package/dist/cjs/reduceDictionaryContent/reduceDictionaryContent.cjs +12 -1
  108. package/dist/cjs/reduceDictionaryContent/reduceDictionaryContent.cjs.map +1 -1
  109. package/dist/cjs/utils/autoDecorateContent.cjs +89 -1
  110. package/dist/cjs/utils/autoDecorateContent.cjs.map +1 -1
  111. package/dist/cjs/utils/buildComponentFilesList.cjs +67 -1
  112. package/dist/cjs/utils/buildComponentFilesList.cjs.map +1 -1
  113. package/dist/cjs/utils/buildFilesList.cjs +83 -1
  114. package/dist/cjs/utils/buildFilesList.cjs.map +1 -1
  115. package/dist/cjs/utils/chunkJSON.cjs +336 -1
  116. package/dist/cjs/utils/chunkJSON.cjs.map +1 -1
  117. package/dist/cjs/utils/formatter.cjs +18 -1
  118. package/dist/cjs/utils/formatter.cjs.map +1 -1
  119. package/dist/cjs/utils/getChunk.cjs +34 -1
  120. package/dist/cjs/utils/getChunk.cjs.map +1 -1
  121. package/dist/cjs/utils/getContentExtension.cjs +29 -1
  122. package/dist/cjs/utils/getContentExtension.cjs.map +1 -1
  123. package/dist/cjs/utils/getFormatFromExtension.cjs +34 -1
  124. package/dist/cjs/utils/getFormatFromExtension.cjs.map +1 -1
  125. package/dist/cjs/utils/getPathHash.cjs +10 -1
  126. package/dist/cjs/utils/getPathHash.cjs.map +1 -1
  127. package/dist/cjs/utils/index.cjs +49 -1
  128. package/dist/cjs/utils/mergeChunks.cjs +28 -1
  129. package/dist/cjs/utils/mergeChunks.cjs.map +1 -1
  130. package/dist/cjs/utils/pLimit.cjs +128 -1
  131. package/dist/cjs/utils/pLimit.cjs.map +1 -1
  132. package/dist/cjs/utils/parallelize.cjs +11 -1
  133. package/dist/cjs/utils/parallelize.cjs.map +1 -1
  134. package/dist/cjs/utils/parallelizeGlobal.cjs +29 -1
  135. package/dist/cjs/utils/parallelizeGlobal.cjs.map +1 -1
  136. package/dist/cjs/utils/reduceObjectFormat.cjs +31 -1
  137. package/dist/cjs/utils/reduceObjectFormat.cjs.map +1 -1
  138. package/dist/cjs/utils/resolveObjectPromises.cjs +21 -1
  139. package/dist/cjs/utils/resolveObjectPromises.cjs.map +1 -1
  140. package/dist/cjs/utils/resolveRelativePath.cjs +21 -1
  141. package/dist/cjs/utils/resolveRelativePath.cjs.map +1 -1
  142. package/dist/cjs/utils/runOnce.cjs +95 -1
  143. package/dist/cjs/utils/runOnce.cjs.map +1 -1
  144. package/dist/cjs/utils/runParallel/bin.cjs +54 -1
  145. package/dist/cjs/utils/runParallel/bin.cjs.map +1 -1
  146. package/dist/cjs/utils/runParallel/bootstrap.cjs +24 -1
  147. package/dist/cjs/utils/runParallel/bootstrap.cjs.map +1 -1
  148. package/dist/cjs/utils/runParallel/index.cjs +115 -1
  149. package/dist/cjs/utils/runParallel/index.cjs.map +1 -1
  150. package/dist/cjs/utils/runParallel/pidTree.cjs +145 -1
  151. package/dist/cjs/utils/runParallel/pidTree.cjs.map +1 -1
  152. package/dist/cjs/utils/runParallel/ps.cjs +49 -1
  153. package/dist/cjs/utils/runParallel/ps.cjs.map +1 -1
  154. package/dist/cjs/utils/runParallel/runTask.cjs +154 -1
  155. package/dist/cjs/utils/runParallel/runTask.cjs.map +1 -1
  156. package/dist/cjs/utils/runParallel/spawnPosix.cjs +59 -1
  157. package/dist/cjs/utils/runParallel/spawnPosix.cjs.map +1 -1
  158. package/dist/cjs/utils/runParallel/spawnWin32.cjs +43 -1
  159. package/dist/cjs/utils/runParallel/spawnWin32.cjs.map +1 -1
  160. package/dist/cjs/utils/runParallel/wmic.cjs +52 -1
  161. package/dist/cjs/utils/runParallel/wmic.cjs.map +1 -1
  162. package/dist/cjs/utils/sortAlphabetically.cjs +7 -1
  163. package/dist/cjs/utils/sortAlphabetically.cjs.map +1 -1
  164. package/dist/cjs/utils/splitTextByLine.cjs +11 -1
  165. package/dist/cjs/utils/splitTextByLine.cjs.map +1 -1
  166. package/dist/cjs/utils/verifyIdenticObjectFormat.cjs +60 -1
  167. package/dist/cjs/utils/verifyIdenticObjectFormat.cjs.map +1 -1
  168. package/dist/cjs/watcher.cjs +120 -1
  169. package/dist/cjs/watcher.cjs.map +1 -1
  170. package/dist/cjs/writeConfiguration/index.cjs +42 -1
  171. package/dist/cjs/writeConfiguration/index.cjs.map +1 -1
  172. package/dist/cjs/writeContentDeclaration/detectExportedComponentName.cjs +28 -1
  173. package/dist/cjs/writeContentDeclaration/detectExportedComponentName.cjs.map +1 -1
  174. package/dist/cjs/writeContentDeclaration/index.cjs +10 -1
  175. package/dist/cjs/writeContentDeclaration/processContentDeclarationContent.cjs +94 -1
  176. package/dist/cjs/writeContentDeclaration/processContentDeclarationContent.cjs.map +1 -1
  177. package/dist/cjs/writeContentDeclaration/transformJSFile.cjs +412 -3
  178. package/dist/cjs/writeContentDeclaration/transformJSFile.cjs.map +1 -1
  179. package/dist/cjs/writeContentDeclaration/transformJSONFile.cjs +127 -2
  180. package/dist/cjs/writeContentDeclaration/transformJSONFile.cjs.map +1 -1
  181. package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs +148 -1
  182. package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs.map +1 -1
  183. package/dist/cjs/writeContentDeclaration/writeJSFile.cjs +92 -1
  184. package/dist/cjs/writeContentDeclaration/writeJSFile.cjs.map +1 -1
  185. package/dist/cjs/writeFileIfChanged.cjs +50 -1
  186. package/dist/cjs/writeFileIfChanged.cjs.map +1 -1
  187. package/dist/cjs/writeJsonIfChanged.cjs +17 -1
  188. package/dist/cjs/writeJsonIfChanged.cjs.map +1 -1
  189. package/dist/esm/_virtual/_rolldown/runtime.mjs +8 -0
  190. package/dist/esm/_virtual/_utils_asset.mjs +97 -0
  191. package/dist/esm/build.mjs +25 -1
  192. package/dist/esm/buildIntlayerDictionary/buildIntlayerDictionary.mjs +60 -1
  193. package/dist/esm/buildIntlayerDictionary/buildIntlayerDictionary.mjs.map +1 -1
  194. package/dist/esm/buildIntlayerDictionary/index.mjs +4 -1
  195. package/dist/esm/buildIntlayerDictionary/processContentDeclaration.mjs +24 -1
  196. package/dist/esm/buildIntlayerDictionary/processContentDeclaration.mjs.map +1 -1
  197. package/dist/esm/buildIntlayerDictionary/writeDynamicDictionary.mjs +102 -4
  198. package/dist/esm/buildIntlayerDictionary/writeDynamicDictionary.mjs.map +1 -1
  199. package/dist/esm/buildIntlayerDictionary/writeFetchDictionary.mjs +77 -5
  200. package/dist/esm/buildIntlayerDictionary/writeFetchDictionary.mjs.map +1 -1
  201. package/dist/esm/buildIntlayerDictionary/writeMergedDictionary.mjs +44 -1
  202. package/dist/esm/buildIntlayerDictionary/writeMergedDictionary.mjs.map +1 -1
  203. package/dist/esm/buildIntlayerDictionary/writeRemoteDictionary.mjs +48 -1
  204. package/dist/esm/buildIntlayerDictionary/writeRemoteDictionary.mjs.map +1 -1
  205. package/dist/esm/buildIntlayerDictionary/writeUnmergedDictionary.mjs +56 -1
  206. package/dist/esm/buildIntlayerDictionary/writeUnmergedDictionary.mjs.map +1 -1
  207. package/dist/esm/cleanOutputDir.mjs +28 -1
  208. package/dist/esm/cleanOutputDir.mjs.map +1 -1
  209. package/dist/esm/cleanRemovedContentDeclaration.mjs +94 -1
  210. package/dist/esm/cleanRemovedContentDeclaration.mjs.map +1 -1
  211. package/dist/esm/cli.mjs +15 -1
  212. package/dist/esm/createDictionaryEntryPoint/createDictionaryEntryPoint.mjs +68 -1
  213. package/dist/esm/createDictionaryEntryPoint/createDictionaryEntryPoint.mjs.map +1 -1
  214. package/dist/esm/createDictionaryEntryPoint/generateDictionaryListContent.mjs +40 -7
  215. package/dist/esm/createDictionaryEntryPoint/generateDictionaryListContent.mjs.map +1 -1
  216. package/dist/esm/createDictionaryEntryPoint/getBuiltDictionariesPath.mjs +20 -1
  217. package/dist/esm/createDictionaryEntryPoint/getBuiltDictionariesPath.mjs.map +1 -1
  218. package/dist/esm/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.mjs +21 -1
  219. package/dist/esm/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.mjs.map +1 -1
  220. package/dist/esm/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.mjs +21 -1
  221. package/dist/esm/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.mjs.map +1 -1
  222. package/dist/esm/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.mjs +20 -1
  223. package/dist/esm/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.mjs.map +1 -1
  224. package/dist/esm/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.mjs +20 -1
  225. package/dist/esm/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.mjs.map +1 -1
  226. package/dist/esm/createDictionaryEntryPoint/index.mjs +9 -1
  227. package/dist/esm/createType/createModuleAugmentation.mjs +108 -9
  228. package/dist/esm/createType/createModuleAugmentation.mjs.map +1 -1
  229. package/dist/esm/createType/createType.mjs +26 -1
  230. package/dist/esm/createType/createType.mjs.map +1 -1
  231. package/dist/esm/createType/index.mjs +4 -1
  232. package/dist/esm/detectFormatCommand.mjs +30 -1
  233. package/dist/esm/detectFormatCommand.mjs.map +1 -1
  234. package/dist/esm/fetchDistantDictionaries.mjs +49 -1
  235. package/dist/esm/fetchDistantDictionaries.mjs.map +1 -1
  236. package/dist/esm/filterInvalidDictionaries.mjs +48 -1
  237. package/dist/esm/filterInvalidDictionaries.mjs.map +1 -1
  238. package/dist/esm/formatDictionary.mjs +44 -1
  239. package/dist/esm/formatDictionary.mjs.map +1 -1
  240. package/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs +59 -7
  241. package/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs.map +1 -1
  242. package/dist/esm/getContentDeclarationFileTemplate/index.mjs +3 -1
  243. package/dist/esm/handleAdditionalContentDeclarationFile.mjs +32 -1
  244. package/dist/esm/handleAdditionalContentDeclarationFile.mjs.map +1 -1
  245. package/dist/esm/handleContentDeclarationFileChange.mjs +47 -1
  246. package/dist/esm/handleContentDeclarationFileChange.mjs.map +1 -1
  247. package/dist/esm/handleContentDeclarationFileMoved.mjs +22 -1
  248. package/dist/esm/handleContentDeclarationFileMoved.mjs.map +1 -1
  249. package/dist/esm/handleUnlinkedContentDeclarationFile.mjs +35 -1
  250. package/dist/esm/handleUnlinkedContentDeclarationFile.mjs.map +1 -1
  251. package/dist/esm/init/index.mjs +281 -1
  252. package/dist/esm/init/index.mjs.map +1 -1
  253. package/dist/esm/init/utils/configManipulation.mjs +108 -1
  254. package/dist/esm/init/utils/configManipulation.mjs.map +1 -1
  255. package/dist/esm/init/utils/fileSystem.mjs +34 -1
  256. package/dist/esm/init/utils/fileSystem.mjs.map +1 -1
  257. package/dist/esm/init/utils/index.mjs +6 -1
  258. package/dist/esm/init/utils/jsonParser.mjs +40 -3
  259. package/dist/esm/init/utils/jsonParser.mjs.map +1 -1
  260. package/dist/esm/init/utils/tsConfig.mjs +16 -1
  261. package/dist/esm/init/utils/tsConfig.mjs.map +1 -1
  262. package/dist/esm/initConfig/index.mjs +37 -1
  263. package/dist/esm/initConfig/index.mjs.map +1 -1
  264. package/dist/esm/installMCP/installMCP.mjs +46 -1
  265. package/dist/esm/installMCP/installMCP.mjs.map +1 -1
  266. package/dist/esm/installSkills/index.mjs +295 -1
  267. package/dist/esm/installSkills/index.mjs.map +1 -1
  268. package/dist/esm/listDictionariesPath.mjs +38 -1
  269. package/dist/esm/listDictionariesPath.mjs.map +1 -1
  270. package/dist/esm/listGitFiles.mjs +100 -5
  271. package/dist/esm/listGitFiles.mjs.map +1 -1
  272. package/dist/esm/listProjects.mjs +43 -1
  273. package/dist/esm/listProjects.mjs.map +1 -1
  274. package/dist/esm/loadDictionaries/getIntlayerBundle.mjs +67 -1
  275. package/dist/esm/loadDictionaries/getIntlayerBundle.mjs.map +1 -1
  276. package/dist/esm/loadDictionaries/index.mjs +6 -1
  277. package/dist/esm/loadDictionaries/loadContentDeclaration.mjs +88 -2
  278. package/dist/esm/loadDictionaries/loadContentDeclaration.mjs.map +1 -1
  279. package/dist/esm/loadDictionaries/loadDictionaries.mjs +124 -1
  280. package/dist/esm/loadDictionaries/loadDictionaries.mjs.map +1 -1
  281. package/dist/esm/loadDictionaries/loadLocalDictionaries.mjs +25 -1
  282. package/dist/esm/loadDictionaries/loadLocalDictionaries.mjs.map +1 -1
  283. package/dist/esm/loadDictionaries/loadRemoteDictionaries.mjs +58 -1
  284. package/dist/esm/loadDictionaries/loadRemoteDictionaries.mjs.map +1 -1
  285. package/dist/esm/loadDictionaries/log.mjs +134 -3
  286. package/dist/esm/loadDictionaries/log.mjs.map +1 -1
  287. package/dist/esm/loadDictionaries/logTypeScriptErrors.mjs +61 -2
  288. package/dist/esm/loadDictionaries/logTypeScriptErrors.mjs.map +1 -1
  289. package/dist/esm/logConfigDetails.mjs +36 -2
  290. package/dist/esm/logConfigDetails.mjs.map +1 -1
  291. package/dist/esm/prepareIntlayer.mjs +99 -1
  292. package/dist/esm/prepareIntlayer.mjs.map +1 -1
  293. package/dist/esm/reduceDictionaryContent/applyMask.mjs +28 -1
  294. package/dist/esm/reduceDictionaryContent/applyMask.mjs.map +1 -1
  295. package/dist/esm/reduceDictionaryContent/reduceDictionaryContent.mjs +10 -1
  296. package/dist/esm/reduceDictionaryContent/reduceDictionaryContent.mjs.map +1 -1
  297. package/dist/esm/utils/autoDecorateContent.mjs +86 -1
  298. package/dist/esm/utils/autoDecorateContent.mjs.map +1 -1
  299. package/dist/esm/utils/buildComponentFilesList.mjs +64 -1
  300. package/dist/esm/utils/buildComponentFilesList.mjs.map +1 -1
  301. package/dist/esm/utils/buildFilesList.mjs +79 -1
  302. package/dist/esm/utils/buildFilesList.mjs.map +1 -1
  303. package/dist/esm/utils/chunkJSON.mjs +333 -1
  304. package/dist/esm/utils/chunkJSON.mjs.map +1 -1
  305. package/dist/esm/utils/formatter.mjs +13 -1
  306. package/dist/esm/utils/formatter.mjs.map +1 -1
  307. package/dist/esm/utils/getChunk.mjs +33 -1
  308. package/dist/esm/utils/getChunk.mjs.map +1 -1
  309. package/dist/esm/utils/getContentExtension.mjs +27 -1
  310. package/dist/esm/utils/getContentExtension.mjs.map +1 -1
  311. package/dist/esm/utils/getFormatFromExtension.mjs +31 -1
  312. package/dist/esm/utils/getFormatFromExtension.mjs.map +1 -1
  313. package/dist/esm/utils/getPathHash.mjs +7 -1
  314. package/dist/esm/utils/getPathHash.mjs.map +1 -1
  315. package/dist/esm/utils/index.mjs +22 -1
  316. package/dist/esm/utils/mergeChunks.mjs +26 -1
  317. package/dist/esm/utils/mergeChunks.mjs.map +1 -1
  318. package/dist/esm/utils/pLimit.mjs +125 -1
  319. package/dist/esm/utils/pLimit.mjs.map +1 -1
  320. package/dist/esm/utils/parallelize.mjs +10 -1
  321. package/dist/esm/utils/parallelize.mjs.map +1 -1
  322. package/dist/esm/utils/parallelizeGlobal.mjs +26 -1
  323. package/dist/esm/utils/parallelizeGlobal.mjs.map +1 -1
  324. package/dist/esm/utils/reduceObjectFormat.mjs +29 -1
  325. package/dist/esm/utils/reduceObjectFormat.mjs.map +1 -1
  326. package/dist/esm/utils/resolveObjectPromises.mjs +19 -1
  327. package/dist/esm/utils/resolveObjectPromises.mjs.map +1 -1
  328. package/dist/esm/utils/resolveRelativePath.mjs +19 -1
  329. package/dist/esm/utils/resolveRelativePath.mjs.map +1 -1
  330. package/dist/esm/utils/runOnce.mjs +92 -1
  331. package/dist/esm/utils/runOnce.mjs.map +1 -1
  332. package/dist/esm/utils/runParallel/bin.mjs +52 -1
  333. package/dist/esm/utils/runParallel/bin.mjs.map +1 -1
  334. package/dist/esm/utils/runParallel/bootstrap.mjs +22 -1
  335. package/dist/esm/utils/runParallel/bootstrap.mjs.map +1 -1
  336. package/dist/esm/utils/runParallel/index.mjs +113 -1
  337. package/dist/esm/utils/runParallel/index.mjs.map +1 -1
  338. package/dist/esm/utils/runParallel/pidTree.mjs +142 -1
  339. package/dist/esm/utils/runParallel/pidTree.mjs.map +1 -1
  340. package/dist/esm/utils/runParallel/ps.mjs +46 -1
  341. package/dist/esm/utils/runParallel/ps.mjs.map +1 -1
  342. package/dist/esm/utils/runParallel/runTask.mjs +152 -1
  343. package/dist/esm/utils/runParallel/runTask.mjs.map +1 -1
  344. package/dist/esm/utils/runParallel/spawnPosix.mjs +57 -1
  345. package/dist/esm/utils/runParallel/spawnPosix.mjs.map +1 -1
  346. package/dist/esm/utils/runParallel/spawnWin32.mjs +41 -1
  347. package/dist/esm/utils/runParallel/spawnWin32.mjs.map +1 -1
  348. package/dist/esm/utils/runParallel/wmic.mjs +49 -1
  349. package/dist/esm/utils/runParallel/wmic.mjs.map +1 -1
  350. package/dist/esm/utils/sortAlphabetically.mjs +5 -1
  351. package/dist/esm/utils/sortAlphabetically.mjs.map +1 -1
  352. package/dist/esm/utils/splitTextByLine.mjs +9 -1
  353. package/dist/esm/utils/splitTextByLine.mjs.map +1 -1
  354. package/dist/esm/utils/verifyIdenticObjectFormat.mjs +58 -1
  355. package/dist/esm/utils/verifyIdenticObjectFormat.mjs.map +1 -1
  356. package/dist/esm/watcher.mjs +117 -1
  357. package/dist/esm/watcher.mjs.map +1 -1
  358. package/dist/esm/writeConfiguration/index.mjs +39 -1
  359. package/dist/esm/writeConfiguration/index.mjs.map +1 -1
  360. package/dist/esm/writeContentDeclaration/detectExportedComponentName.mjs +26 -1
  361. package/dist/esm/writeContentDeclaration/detectExportedComponentName.mjs.map +1 -1
  362. package/dist/esm/writeContentDeclaration/index.mjs +6 -1
  363. package/dist/esm/writeContentDeclaration/processContentDeclarationContent.mjs +91 -1
  364. package/dist/esm/writeContentDeclaration/processContentDeclarationContent.mjs.map +1 -1
  365. package/dist/esm/writeContentDeclaration/transformJSFile.mjs +407 -3
  366. package/dist/esm/writeContentDeclaration/transformJSFile.mjs.map +1 -1
  367. package/dist/esm/writeContentDeclaration/transformJSONFile.mjs +124 -2
  368. package/dist/esm/writeContentDeclaration/transformJSONFile.mjs.map +1 -1
  369. package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs +146 -1
  370. package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs.map +1 -1
  371. package/dist/esm/writeContentDeclaration/writeJSFile.mjs +90 -1
  372. package/dist/esm/writeContentDeclaration/writeJSFile.mjs.map +1 -1
  373. package/dist/esm/writeFileIfChanged.mjs +48 -1
  374. package/dist/esm/writeFileIfChanged.mjs.map +1 -1
  375. package/dist/esm/writeJsonIfChanged.mjs +16 -1
  376. package/dist/esm/writeJsonIfChanged.mjs.map +1 -1
  377. package/dist/types/build.d.ts +20 -20
  378. package/dist/types/buildIntlayerDictionary/buildIntlayerDictionary.d.ts +25 -2
  379. package/dist/types/buildIntlayerDictionary/buildIntlayerDictionary.d.ts.map +1 -0
  380. package/dist/types/buildIntlayerDictionary/index.d.ts +2 -2
  381. package/dist/types/buildIntlayerDictionary/processContentDeclaration.d.ts +11 -2
  382. package/dist/types/buildIntlayerDictionary/processContentDeclaration.d.ts.map +1 -0
  383. package/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts +49 -2
  384. package/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts.map +1 -0
  385. package/dist/types/buildIntlayerDictionary/writeFetchDictionary.d.ts +7 -7
  386. package/dist/types/buildIntlayerDictionary/writeFetchDictionary.d.ts.map +1 -1
  387. package/dist/types/buildIntlayerDictionary/writeMergedDictionary.d.ts +30 -2
  388. package/dist/types/buildIntlayerDictionary/writeMergedDictionary.d.ts.map +1 -0
  389. package/dist/types/buildIntlayerDictionary/writeUnmergedDictionary.d.ts +34 -2
  390. package/dist/types/buildIntlayerDictionary/writeUnmergedDictionary.d.ts.map +1 -0
  391. package/dist/types/cli.d.ts +6 -6
  392. package/dist/types/createDictionaryEntryPoint/createDictionaryEntryPoint.d.ts +14 -2
  393. package/dist/types/createDictionaryEntryPoint/createDictionaryEntryPoint.d.ts.map +1 -0
  394. package/dist/types/createDictionaryEntryPoint/generateDictionaryListContent.d.ts +10 -2
  395. package/dist/types/createDictionaryEntryPoint/generateDictionaryListContent.d.ts.map +1 -0
  396. package/dist/types/createDictionaryEntryPoint/getBuiltDictionariesPath.d.ts +10 -2
  397. package/dist/types/createDictionaryEntryPoint/getBuiltDictionariesPath.d.ts.map +1 -0
  398. package/dist/types/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.d.ts +10 -2
  399. package/dist/types/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.d.ts.map +1 -0
  400. package/dist/types/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.d.ts +10 -2
  401. package/dist/types/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.d.ts.map +1 -0
  402. package/dist/types/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.d.ts +10 -2
  403. package/dist/types/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.d.ts.map +1 -0
  404. package/dist/types/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.d.ts +10 -2
  405. package/dist/types/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.d.ts.map +1 -0
  406. package/dist/types/createDictionaryEntryPoint/index.d.ts +7 -7
  407. package/dist/types/createType/createModuleAugmentation.d.ts +9 -2
  408. package/dist/types/createType/createModuleAugmentation.d.ts.map +1 -0
  409. package/dist/types/createType/createType.d.ts +12 -2
  410. package/dist/types/createType/createType.d.ts.map +1 -0
  411. package/dist/types/createType/index.d.ts +2 -2
  412. package/dist/types/fetchDistantDictionaries.d.ts +1 -1
  413. package/dist/types/fetchDistantDictionaries.d.ts.map +1 -1
  414. package/dist/types/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.d.ts +7 -2
  415. package/dist/types/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.d.ts.map +1 -0
  416. package/dist/types/getContentDeclarationFileTemplate/index.d.ts +1 -1
  417. package/dist/types/loadDictionaries/index.d.ts +4 -4
  418. package/dist/types/loadDictionaries/loadContentDeclaration.d.ts +12 -2
  419. package/dist/types/loadDictionaries/loadContentDeclaration.d.ts.map +1 -0
  420. package/dist/types/loadDictionaries/loadDictionaries.d.ts +23 -2
  421. package/dist/types/loadDictionaries/loadDictionaries.d.ts.map +1 -0
  422. package/dist/types/loadDictionaries/loadLocalDictionaries.d.ts +8 -2
  423. package/dist/types/loadDictionaries/loadLocalDictionaries.d.ts.map +1 -0
  424. package/dist/types/loadDictionaries/loadRemoteDictionaries.d.ts +15 -2
  425. package/dist/types/loadDictionaries/loadRemoteDictionaries.d.ts.map +1 -0
  426. package/dist/types/loadDictionaries/log.d.ts +1 -1
  427. package/dist/types/utils/getFormatFromExtension.d.ts +8 -2
  428. package/dist/types/utils/getFormatFromExtension.d.ts.map +1 -0
  429. package/dist/types/utils/index.d.ts +1 -1
  430. package/dist/types/writeConfiguration/index.d.ts.map +1 -1
  431. package/dist/types/writeContentDeclaration/detectExportedComponentName.d.ts +12 -2
  432. package/dist/types/writeContentDeclaration/detectExportedComponentName.d.ts.map +1 -0
  433. package/dist/types/writeContentDeclaration/dictionaryStatus.d.ts +5 -2
  434. package/dist/types/writeContentDeclaration/dictionaryStatus.d.ts.map +1 -0
  435. package/dist/types/writeContentDeclaration/index.d.ts +5 -5
  436. package/dist/types/writeContentDeclaration/processContentDeclarationContent.d.ts.map +1 -1
  437. package/dist/types/writeContentDeclaration/transformJSFile.d.ts +11 -2
  438. package/dist/types/writeContentDeclaration/transformJSFile.d.ts.map +1 -0
  439. package/dist/types/writeContentDeclaration/writeContentDeclaration.d.ts +19 -2
  440. package/dist/types/writeContentDeclaration/writeContentDeclaration.d.ts.map +1 -0
  441. package/dist/types/writeContentDeclaration/writeJSFile.d.ts +14 -2
  442. package/dist/types/writeContentDeclaration/writeJSFile.d.ts.map +1 -0
  443. package/package.json +8 -8
  444. package/dist/cjs/_utils_asset-SJVy1xMD.cjs +0 -2
  445. package/dist/cjs/chunk-Bmb41Sf3.cjs +0 -1
  446. package/dist/esm/_utils_asset-4w8dPH9r.mjs +0 -2
  447. package/dist/esm/chunk-DDgYwkfe.mjs +0 -1
  448. package/dist/types/buildIntlayerDictionary-_xrGjSmw.d.ts +0 -25
  449. package/dist/types/buildIntlayerDictionary-_xrGjSmw.d.ts.map +0 -1
  450. package/dist/types/createDictionaryEntryPoint-Bc5lHSiY.d.ts +0 -14
  451. package/dist/types/createDictionaryEntryPoint-Bc5lHSiY.d.ts.map +0 -1
  452. package/dist/types/createModuleAugmentation-D1eIVnjg.d.ts +0 -9
  453. package/dist/types/createModuleAugmentation-D1eIVnjg.d.ts.map +0 -1
  454. package/dist/types/createType--rDwdg2t.d.ts +0 -12
  455. package/dist/types/createType--rDwdg2t.d.ts.map +0 -1
  456. package/dist/types/detectExportedComponentName-DVXsp_FG.d.ts +0 -12
  457. package/dist/types/detectExportedComponentName-DVXsp_FG.d.ts.map +0 -1
  458. package/dist/types/dictionaryStatus-DPVO37qe.d.ts +0 -5
  459. package/dist/types/dictionaryStatus-DPVO37qe.d.ts.map +0 -1
  460. package/dist/types/generateDictionaryListContent-DAtHG6SR.d.ts +0 -10
  461. package/dist/types/generateDictionaryListContent-DAtHG6SR.d.ts.map +0 -1
  462. package/dist/types/getBuiltDictionariesPath-C4it65a1.d.ts +0 -10
  463. package/dist/types/getBuiltDictionariesPath-C4it65a1.d.ts.map +0 -1
  464. package/dist/types/getBuiltDynamicDictionariesPath-Cj9EWnjT.d.ts +0 -10
  465. package/dist/types/getBuiltDynamicDictionariesPath-Cj9EWnjT.d.ts.map +0 -1
  466. package/dist/types/getBuiltFetchDictionariesPath-1JleRhT3.d.ts +0 -10
  467. package/dist/types/getBuiltFetchDictionariesPath-1JleRhT3.d.ts.map +0 -1
  468. package/dist/types/getBuiltRemoteDictionariesPath-DHOmqNCr.d.ts +0 -10
  469. package/dist/types/getBuiltRemoteDictionariesPath-DHOmqNCr.d.ts.map +0 -1
  470. package/dist/types/getBuiltUnmergedDictionariesPath-GUmmLxTB.d.ts +0 -10
  471. package/dist/types/getBuiltUnmergedDictionariesPath-GUmmLxTB.d.ts.map +0 -1
  472. package/dist/types/getContentDeclarationFileTemplate-Dz3rnFy9.d.ts +0 -7
  473. package/dist/types/getContentDeclarationFileTemplate-Dz3rnFy9.d.ts.map +0 -1
  474. package/dist/types/getFormatFromExtension-SdXYWfPx.d.ts +0 -8
  475. package/dist/types/getFormatFromExtension-SdXYWfPx.d.ts.map +0 -1
  476. package/dist/types/loadContentDeclaration-CBMS4vkA.d.ts +0 -12
  477. package/dist/types/loadContentDeclaration-CBMS4vkA.d.ts.map +0 -1
  478. package/dist/types/loadDictionaries-BIqHwtYE.d.ts +0 -23
  479. package/dist/types/loadDictionaries-BIqHwtYE.d.ts.map +0 -1
  480. package/dist/types/loadLocalDictionaries-CNmVaw0c.d.ts +0 -8
  481. package/dist/types/loadLocalDictionaries-CNmVaw0c.d.ts.map +0 -1
  482. package/dist/types/loadRemoteDictionaries-MoITTb7W.d.ts +0 -15
  483. package/dist/types/loadRemoteDictionaries-MoITTb7W.d.ts.map +0 -1
  484. package/dist/types/processContentDeclaration-CAvrHaIT.d.ts +0 -11
  485. package/dist/types/processContentDeclaration-CAvrHaIT.d.ts.map +0 -1
  486. package/dist/types/transformJSFile-Cg0LkeLb.d.ts +0 -11
  487. package/dist/types/transformJSFile-Cg0LkeLb.d.ts.map +0 -1
  488. package/dist/types/writeContentDeclaration-XdGxj0KP.d.ts +0 -19
  489. package/dist/types/writeContentDeclaration-XdGxj0KP.d.ts.map +0 -1
  490. package/dist/types/writeDynamicDictionary-DO8f3FYl.d.ts +0 -48
  491. package/dist/types/writeDynamicDictionary-DO8f3FYl.d.ts.map +0 -1
  492. package/dist/types/writeJSFile-kK95jzg_.d.ts +0 -14
  493. package/dist/types/writeJSFile-kK95jzg_.d.ts.map +0 -1
  494. package/dist/types/writeMergedDictionary-CMeghcRI.d.ts +0 -30
  495. package/dist/types/writeMergedDictionary-CMeghcRI.d.ts.map +0 -1
  496. package/dist/types/writeUnmergedDictionary-Cxx51isz.d.ts +0 -34
  497. package/dist/types/writeUnmergedDictionary-Cxx51isz.d.ts.map +0 -1
@@ -1,2 +1,39 @@
1
- import{stat as e}from"node:fs/promises";import t from"fast-glob";import{normalizePath as n}from"@intlayer/config/utils";const r=async e=>{let{fileExtensions:r,contentDir:i,excludedPath:a}=e.content,o=r.flatMap(e=>i.map(t=>`${n(t)}/**/*${e}`.replace(`//`,`/`))).map(async e=>{let n=e.search(/[*?{}(]/),r=n>-1?e.slice(0,n):e;return t(e,{ignore:a.filter(e=>{let t=e.replace(/\*\*/g,``).replace(/\//g,``);return!(t&&r.includes(`/${t}/`))}),absolute:!0,dot:!0})}),s=await Promise.all(o);return Array.from(new Set(s.flat()))},i=async t=>{let n=await r(t);return Promise.all(n.map(async t=>({path:t,stats:await e(t)})))};export{r as listDictionaries,i as listDictionariesWithStats};
1
+ import { stat } from "node:fs/promises";
2
+ import fg from "fast-glob";
3
+ import { normalizePath } from "@intlayer/config/utils";
4
+
5
+ //#region src/listDictionariesPath.ts
6
+ /**
7
+ * List all dictionaries absolute paths in the project
8
+ * @param configuration - The configuration object
9
+ * @returns An array of dictionary paths
10
+ */
11
+ const listDictionaries = async (configuration) => {
12
+ const { fileExtensions, contentDir, excludedPath } = configuration.content;
13
+ const filePromises = fileExtensions.flatMap((ext) => contentDir.map((dir) => `${normalizePath(dir)}/**/*${ext}`.replace("//", "/"))).map(async (pattern) => {
14
+ const magicIndex = pattern.search(/[*?{}(]/);
15
+ const basePattern = magicIndex > -1 ? pattern.slice(0, magicIndex) : pattern;
16
+ return fg(pattern, {
17
+ ignore: excludedPath.filter((excludePattern) => {
18
+ const cleanName = excludePattern.replace(/\*\*/g, "").replace(/\//g, "");
19
+ if (cleanName && basePattern.includes(`/${cleanName}/`)) return false;
20
+ return true;
21
+ }),
22
+ absolute: true,
23
+ dot: true
24
+ });
25
+ });
26
+ const filesArrays = await Promise.all(filePromises);
27
+ return Array.from(new Set(filesArrays.flat()));
28
+ };
29
+ const listDictionariesWithStats = async (configuration) => {
30
+ const files = await listDictionaries(configuration);
31
+ return Promise.all(files.map(async (file) => ({
32
+ path: file,
33
+ stats: await stat(file)
34
+ })));
35
+ };
36
+
37
+ //#endregion
38
+ export { listDictionaries, listDictionariesWithStats };
2
39
  //# sourceMappingURL=listDictionariesPath.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"listDictionariesPath.mjs","names":[],"sources":["../../src/listDictionariesPath.ts"],"sourcesContent":["import { stat } from 'node:fs/promises';\nimport { normalizePath } from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport fg from 'fast-glob';\n\n/**\n * List all dictionaries absolute paths in the project\n * @param configuration - The configuration object\n * @returns An array of dictionary paths\n */\nexport const listDictionaries = async (\n configuration: IntlayerConfig\n): Promise<string[]> => {\n const { fileExtensions, contentDir, excludedPath } = configuration.content;\n\n const watchedFilesPatternWithPath = fileExtensions.flatMap((ext) =>\n contentDir.map((dir) =>\n `${normalizePath(dir)}/**/*${ext}`.replace('//', '/')\n )\n );\n\n const filePromises = watchedFilesPatternWithPath.map(async (pattern) => {\n // Identify the static part of the path (before any wildcards like *)\n // e.g. \"/Users/.../design-system/dist/esm/**/*.content.ts\" -> \"/Users/.../design-system/dist/esm/\"\n const magicIndex = pattern.search(/[*?{}(]/);\n const basePattern =\n magicIndex > -1 ? pattern.slice(0, magicIndex) : pattern;\n\n // Filter the global ignored list for this specific pattern\n const applicableIgnore = excludedPath.filter((excludePattern) => {\n // Heuristic: Extract the key directory name from the glob\n // e.g. \"**/dist/**\" -> \"dist\", \"**/node_modules/**\" -> \"node_modules\"\n const cleanName = excludePattern.replace(/\\*\\*/g, '').replace(/\\//g, '');\n\n // If the explicit base path contains the excluded directory (e.g. \".../dist/...\"),\n // we assume you explicitly want it, so we REMOVE it from the ignore list.\n // We check for `/${cleanName}/` to ensure we match whole folder names.\n if (cleanName && basePattern.includes(`/${cleanName}/`)) {\n return false; // Drop this exclude rule\n }\n\n return true; // Keep this exclude rule\n });\n\n // Run fast-glob with the customized ignore list\n return fg(pattern, {\n ignore: applicableIgnore,\n absolute: true,\n dot: true,\n });\n });\n\n const filesArrays = await Promise.all(filePromises);\n\n // Flatten and deduplicate\n const uniqueFiles = Array.from(new Set(filesArrays.flat()));\n\n return uniqueFiles;\n};\n\nexport const listDictionariesWithStats = async (\n configuration: IntlayerConfig\n) => {\n const files = await listDictionaries(configuration);\n\n return Promise.all(\n files.map(async (file) => ({ path: file, stats: await stat(file) }))\n );\n};\n"],"mappings":"wHAUA,MAAa,EAAmB,KAC9B,IACsB,CACtB,GAAM,CAAE,iBAAgB,aAAY,gBAAiB,EAAc,QAQ7D,EAN8B,EAAe,QAAS,GAC1D,EAAW,IAAK,GACd,GAAG,EAAc,EAAI,CAAC,OAAO,IAAM,QAAQ,KAAM,IAAI,CACtD,CACF,CAEgD,IAAI,KAAO,IAAY,CAGtE,IAAM,EAAa,EAAQ,OAAO,UAAU,CACtC,EACJ,EAAa,GAAK,EAAQ,MAAM,EAAG,EAAW,CAAG,EAmBnD,OAAO,EAAG,EAAS,CACjB,OAjBuB,EAAa,OAAQ,GAAmB,CAG/D,IAAM,EAAY,EAAe,QAAQ,QAAS,GAAG,CAAC,QAAQ,MAAO,GAAG,CASxE,MAJA,EAAI,GAAa,EAAY,SAAS,IAAI,EAAU,GAAG,GAKvD,CAKA,SAAU,GACV,IAAK,GACN,CAAC,EACF,CAEI,EAAc,MAAM,QAAQ,IAAI,EAAa,CAKnD,OAFoB,MAAM,KAAK,IAAI,IAAI,EAAY,MAAM,CAAC,CAAC,EAKhD,EAA4B,KACvC,IACG,CACH,IAAM,EAAQ,MAAM,EAAiB,EAAc,CAEnD,OAAO,QAAQ,IACb,EAAM,IAAI,KAAO,KAAU,CAAE,KAAM,EAAM,MAAO,MAAM,EAAK,EAAK,CAAE,EAAE,CACrE"}
1
+ {"version":3,"file":"listDictionariesPath.mjs","names":[],"sources":["../../src/listDictionariesPath.ts"],"sourcesContent":["import { stat } from 'node:fs/promises';\nimport { normalizePath } from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport fg from 'fast-glob';\n\n/**\n * List all dictionaries absolute paths in the project\n * @param configuration - The configuration object\n * @returns An array of dictionary paths\n */\nexport const listDictionaries = async (\n configuration: IntlayerConfig\n): Promise<string[]> => {\n const { fileExtensions, contentDir, excludedPath } = configuration.content;\n\n const watchedFilesPatternWithPath = fileExtensions.flatMap((ext) =>\n contentDir.map((dir) =>\n `${normalizePath(dir)}/**/*${ext}`.replace('//', '/')\n )\n );\n\n const filePromises = watchedFilesPatternWithPath.map(async (pattern) => {\n // Identify the static part of the path (before any wildcards like *)\n // e.g. \"/Users/.../design-system/dist/esm/**/*.content.ts\" -> \"/Users/.../design-system/dist/esm/\"\n const magicIndex = pattern.search(/[*?{}(]/);\n const basePattern =\n magicIndex > -1 ? pattern.slice(0, magicIndex) : pattern;\n\n // Filter the global ignored list for this specific pattern\n const applicableIgnore = excludedPath.filter((excludePattern) => {\n // Heuristic: Extract the key directory name from the glob\n // e.g. \"**/dist/**\" -> \"dist\", \"**/node_modules/**\" -> \"node_modules\"\n const cleanName = excludePattern.replace(/\\*\\*/g, '').replace(/\\//g, '');\n\n // If the explicit base path contains the excluded directory (e.g. \".../dist/...\"),\n // we assume you explicitly want it, so we REMOVE it from the ignore list.\n // We check for `/${cleanName}/` to ensure we match whole folder names.\n if (cleanName && basePattern.includes(`/${cleanName}/`)) {\n return false; // Drop this exclude rule\n }\n\n return true; // Keep this exclude rule\n });\n\n // Run fast-glob with the customized ignore list\n return fg(pattern, {\n ignore: applicableIgnore,\n absolute: true,\n dot: true,\n });\n });\n\n const filesArrays = await Promise.all(filePromises);\n\n // Flatten and deduplicate\n const uniqueFiles = Array.from(new Set(filesArrays.flat()));\n\n return uniqueFiles;\n};\n\nexport const listDictionariesWithStats = async (\n configuration: IntlayerConfig\n) => {\n const files = await listDictionaries(configuration);\n\n return Promise.all(\n files.map(async (file) => ({ path: file, stats: await stat(file) }))\n );\n};\n"],"mappings":";;;;;;;;;;AAUA,MAAa,mBAAmB,OAC9B,kBACsB;CACtB,MAAM,EAAE,gBAAgB,YAAY,iBAAiB,cAAc;CAQnE,MAAM,eAN8B,eAAe,SAAS,QAC1D,WAAW,KAAK,QACd,GAAG,cAAc,IAAI,CAAC,OAAO,MAAM,QAAQ,MAAM,IAAI,CACtD,CACF,CAEgD,IAAI,OAAO,YAAY;EAGtE,MAAM,aAAa,QAAQ,OAAO,UAAU;EAC5C,MAAM,cACJ,aAAa,KAAK,QAAQ,MAAM,GAAG,WAAW,GAAG;AAmBnD,SAAO,GAAG,SAAS;GACjB,QAjBuB,aAAa,QAAQ,mBAAmB;IAG/D,MAAM,YAAY,eAAe,QAAQ,SAAS,GAAG,CAAC,QAAQ,OAAO,GAAG;AAKxE,QAAI,aAAa,YAAY,SAAS,IAAI,UAAU,GAAG,CACrD,QAAO;AAGT,WAAO;KACP;GAKA,UAAU;GACV,KAAK;GACN,CAAC;GACF;CAEF,MAAM,cAAc,MAAM,QAAQ,IAAI,aAAa;AAKnD,QAFoB,MAAM,KAAK,IAAI,IAAI,YAAY,MAAM,CAAC,CAAC;;AAK7D,MAAa,4BAA4B,OACvC,kBACG;CACH,MAAM,QAAQ,MAAM,iBAAiB,cAAc;AAEnD,QAAO,QAAQ,IACb,MAAM,IAAI,OAAO,UAAU;EAAE,MAAM;EAAM,OAAO,MAAM,KAAK,KAAK;EAAE,EAAE,CACrE"}
@@ -1,6 +1,101 @@
1
- import{join as e}from"node:path";import{getAppLogger as t}from"@intlayer/config/logger";import{readFileSync as n}from"node:fs";import r from"simple-git";import i from"@intlayer/config/built";const a=async()=>{try{return(await r().revparse([`--show-toplevel`])).trim()}catch(e){return t(i)(`Error getting git root directory: ${e}`,{level:`error`}),null}},o=async({mode:t,baseRef:n=`origin/main`,currentRef:i=`HEAD`,absolute:o=!0})=>{try{let s=r(),c=new Set;if(t.includes(`untracked`)&&(await s.status()).not_added.forEach(e=>{c.add(e)}),t.includes(`uncommitted`)&&(await s.diff([`--name-only`,`HEAD`])).split(`
2
- `).filter(Boolean).forEach(e=>{c.add(e)}),t.includes(`unpushed`)&&(await s.diff([`--name-only`,`@{push}...HEAD`])).split(`
3
- `).filter(Boolean).forEach(e=>{c.add(e)}),t.includes(`gitDiff`)&&(await s.fetch(n),(await s.diff([`--name-only`,`${n}...${i}`])).split(`
4
- `).filter(Boolean).forEach(e=>{c.add(e)})),o){let t=await a();return t?Array.from(c).map(n=>e(t,n)):[]}return Array.from(c)}catch(e){console.warn(`Failed to get changes list:`,e)}},s=async(e,{mode:t,baseRef:i=`origin/main`,currentRef:a=`HEAD`})=>{let o=r(),s=new Set,c=e=>{let t=/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/g,n;for(;(n=t.exec(e))!==null;){let e=n[2]?Number(n[2]):1,t=Number(n[3]),r=n[4]?Number(n[4]):1;if(r>0)for(let e=0;e<r;e++)s.add(t+e);e>0&&r===0&&(t>1&&s.add(t-1),s.add(t))}};if(t.includes(`untracked`)&&(await o.status()).not_added.includes(e))try{n(e,`utf-8`).split(`
5
- `).forEach((e,t)=>{s.add(t+1)})}catch{}return t.includes(`uncommitted`)&&c(await o.diff([`--unified=0`,`HEAD`,`--`,e])),t.includes(`unpushed`)&&c(await o.diff([`--unified=0`,`@{push}...HEAD`,`--`,e])),t.includes(`gitDiff`)&&(await o.fetch(i),c(await o.diff([`--unified=0`,`${i}...${a}`,`--`,e]))),Array.from(s).sort((e,t)=>e-t)};export{o as listGitFiles,s as listGitLines};
1
+ import { join } from "node:path";
2
+ import { getAppLogger } from "@intlayer/config/logger";
3
+ import { readFileSync } from "node:fs";
4
+ import simpleGit from "simple-git";
5
+ import configuration from "@intlayer/config/built";
6
+
7
+ //#region src/listGitFiles.ts
8
+ const getGitRootDir = async () => {
9
+ try {
10
+ return (await simpleGit().revparse(["--show-toplevel"])).trim();
11
+ } catch (error) {
12
+ getAppLogger(configuration)(`Error getting git root directory: ${error}`, { level: "error" });
13
+ return null;
14
+ }
15
+ };
16
+ const listGitFiles = async ({ mode, baseRef = "origin/main", currentRef = "HEAD", absolute = true }) => {
17
+ try {
18
+ const git = simpleGit();
19
+ const diff = /* @__PURE__ */ new Set();
20
+ if (mode.includes("untracked")) (await git.status()).not_added.forEach((file) => {
21
+ diff.add(file);
22
+ });
23
+ if (mode.includes("uncommitted")) (await git.diff(["--name-only", "HEAD"])).split("\n").filter(Boolean).forEach((file) => {
24
+ diff.add(file);
25
+ });
26
+ if (mode.includes("unpushed")) (await git.diff(["--name-only", "@{push}...HEAD"])).split("\n").filter(Boolean).forEach((file) => {
27
+ diff.add(file);
28
+ });
29
+ if (mode.includes("gitDiff")) {
30
+ await git.fetch(baseRef);
31
+ (await git.diff(["--name-only", `${baseRef}...${currentRef}`])).split("\n").filter(Boolean).forEach((file) => {
32
+ diff.add(file);
33
+ });
34
+ }
35
+ if (absolute) {
36
+ const gitRootDir = await getGitRootDir();
37
+ if (!gitRootDir) return [];
38
+ return Array.from(diff).map((file) => join(gitRootDir, file));
39
+ }
40
+ return Array.from(diff);
41
+ } catch (error) {
42
+ console.warn("Failed to get changes list:", error);
43
+ }
44
+ };
45
+ const listGitLines = async (filePath, { mode, baseRef = "origin/main", currentRef = "HEAD" }) => {
46
+ const git = simpleGit();
47
+ const changedLines = /* @__PURE__ */ new Set();
48
+ /**
49
+ * Extracts line numbers from a diff generated with `--unified=0`.
50
+ * Each hunk header looks like: @@ -<oldStart>,<oldCount> +<newStart>,<newCount> @@
51
+ * We consider both the "+" (new) side for additions and the "-" (old) side for deletions.
52
+ * For deletions, we add the line before and after the deletion point in the current file.
53
+ */
54
+ const collectLinesFromDiff = (diffOutput) => {
55
+ const hunkRegex = /@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/g;
56
+ let match;
57
+ while ((match = hunkRegex.exec(diffOutput)) !== null) {
58
+ const oldCount = match[2] ? Number(match[2]) : 1;
59
+ const newStart = Number(match[3]);
60
+ const newCount = match[4] ? Number(match[4]) : 1;
61
+ if (newCount > 0) for (let i = 0; i < newCount; i++) changedLines.add(newStart + i);
62
+ if (oldCount > 0 && newCount === 0) {
63
+ if (newStart > 1) changedLines.add(newStart - 1);
64
+ changedLines.add(newStart);
65
+ }
66
+ }
67
+ };
68
+ if (mode.includes("untracked")) {
69
+ if ((await git.status()).not_added.includes(filePath)) try {
70
+ readFileSync(filePath, "utf-8").split("\n").forEach((_, idx) => {
71
+ changedLines.add(idx + 1);
72
+ });
73
+ } catch {}
74
+ }
75
+ if (mode.includes("uncommitted")) collectLinesFromDiff(await git.diff([
76
+ "--unified=0",
77
+ "HEAD",
78
+ "--",
79
+ filePath
80
+ ]));
81
+ if (mode.includes("unpushed")) collectLinesFromDiff(await git.diff([
82
+ "--unified=0",
83
+ "@{push}...HEAD",
84
+ "--",
85
+ filePath
86
+ ]));
87
+ if (mode.includes("gitDiff")) {
88
+ await git.fetch(baseRef);
89
+ collectLinesFromDiff(await git.diff([
90
+ "--unified=0",
91
+ `${baseRef}...${currentRef}`,
92
+ "--",
93
+ filePath
94
+ ]));
95
+ }
96
+ return Array.from(changedLines).sort((a, b) => a - b);
97
+ };
98
+
99
+ //#endregion
100
+ export { listGitFiles, listGitLines };
6
101
  //# sourceMappingURL=listGitFiles.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"listGitFiles.mjs","names":[],"sources":["../../src/listGitFiles.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport { join } from 'node:path';\nimport configuration from '@intlayer/config/built';\nimport { getAppLogger } from '@intlayer/config/logger';\nimport simpleGit from 'simple-git';\n\nexport type DiffMode = 'gitDiff' | 'uncommitted' | 'unpushed' | 'untracked';\n\nconst getGitRootDir = async (): Promise<string | null> => {\n try {\n const git = simpleGit();\n const rootDir = await git.revparse(['--show-toplevel']);\n return rootDir.trim();\n } catch (error) {\n const appLogger = getAppLogger(configuration);\n appLogger(`Error getting git root directory: ${error}`, {\n level: 'error',\n });\n return null;\n }\n};\n\nexport type ListGitFilesOptions = {\n mode: DiffMode[];\n baseRef?: string;\n currentRef?: string;\n absolute?: boolean;\n};\n\nexport const listGitFiles = async ({\n mode,\n baseRef = 'origin/main',\n currentRef = 'HEAD', // HEAD points to the current branch's latest commit\n absolute = true,\n}: ListGitFilesOptions) => {\n try {\n const git = simpleGit();\n const diff: Set<string> = new Set();\n\n if (mode.includes('untracked')) {\n const status = await git.status();\n status.not_added.forEach((file) => {\n diff.add(file);\n });\n }\n\n if (mode.includes('uncommitted')) {\n // Get uncommitted changes\n const uncommittedDiff = await git.diff(['--name-only', 'HEAD']);\n\n const uncommittedFiles = uncommittedDiff.split('\\n').filter(Boolean);\n\n uncommittedFiles.forEach((file) => {\n diff.add(file);\n });\n }\n\n if (mode.includes('unpushed')) {\n // Get unpushed commits\n const unpushedDiff = await git.diff(['--name-only', '@{push}...HEAD']);\n\n const unpushedFiles = unpushedDiff.split('\\n').filter(Boolean);\n\n unpushedFiles.forEach((file) => {\n diff.add(file);\n });\n }\n\n if (mode.includes('gitDiff')) {\n // Get the base branch (usually main/master) from CI environment\n\n await git.fetch(baseRef);\n\n const diffBranch = await git.diff([\n '--name-only',\n `${baseRef}...${currentRef}`,\n ]);\n\n const gitDiffFiles = diffBranch.split('\\n').filter(Boolean);\n\n gitDiffFiles.forEach((file) => {\n diff.add(file);\n });\n }\n\n if (absolute) {\n const gitRootDir = await getGitRootDir();\n if (!gitRootDir) {\n return [];\n }\n return Array.from(diff).map((file) => join(gitRootDir, file));\n }\n\n return Array.from(diff);\n } catch (error) {\n console.warn('Failed to get changes list:', error);\n }\n};\n\nexport type ListGitLinesOptions = {\n mode: DiffMode[];\n baseRef?: string;\n currentRef?: string;\n};\n\nexport const listGitLines = async (\n filePath: string,\n {\n mode,\n baseRef = 'origin/main',\n currentRef = 'HEAD', // HEAD points to the current branch's latest commit\n }: ListGitLinesOptions\n): Promise<number[]> => {\n const git = simpleGit();\n // We collect **line numbers** (1-based) that were modified/added by the diff.\n // Using a Set ensures uniqueness when the same line is reported by several modes.\n const changedLines: Set<number> = new Set();\n\n /**\n * Extracts line numbers from a diff generated with `--unified=0`.\n * Each hunk header looks like: @@ -<oldStart>,<oldCount> +<newStart>,<newCount> @@\n * We consider both the \"+\" (new) side for additions and the \"-\" (old) side for deletions.\n * For deletions, we add the line before and after the deletion point in the current file.\n */\n const collectLinesFromDiff = (diffOutput: string) => {\n const hunkRegex = /@@ -(\\d+)(?:,(\\d+))? \\+(\\d+)(?:,(\\d+))? @@/g;\n let match: RegExpExecArray | null;\n\n // biome-ignore lint/suspicious/noAssignInExpressions: Used in while loop condition\n while ((match = hunkRegex.exec(diffOutput)) !== null) {\n const oldCount = match[2] ? Number(match[2]) : 1;\n const newStart = Number(match[3]);\n const newCount = match[4] ? Number(match[4]) : 1;\n\n // Handle additions/modifications (+ side)\n if (newCount > 0) {\n for (let i = 0; i < newCount; i++) {\n changedLines.add(newStart + i);\n }\n }\n\n // Handle deletions (- side)\n if (oldCount > 0 && newCount === 0) {\n // For deletions, add the line before and after the deletion point\n // The deletion point in the new file is at newStart\n if (newStart > 1) {\n changedLines.add(newStart - 1); // Line before deletion\n }\n changedLines.add(newStart); // Line after deletion (if it exists)\n }\n }\n };\n\n // 1. Handle untracked files – when a file is untracked its entire content is new.\n if (mode.includes('untracked')) {\n const status = await git.status();\n const isUntracked = status.not_added.includes(filePath);\n if (isUntracked) {\n try {\n const content = readFileSync(filePath, 'utf-8');\n content.split('\\n').forEach((_, idx) => {\n changedLines.add(idx + 1);\n });\n } catch {\n // ignore read errors – file may have been deleted, etc.\n }\n }\n }\n\n // 2. Uncommitted changes (working tree vs HEAD)\n if (mode.includes('uncommitted')) {\n const diffOutput = await git.diff(['--unified=0', 'HEAD', '--', filePath]);\n collectLinesFromDiff(diffOutput);\n }\n\n // 3. Unpushed commits – compare local branch to its upstream\n if (mode.includes('unpushed')) {\n const diffOutput = await git.diff([\n '--unified=0',\n '@{push}...HEAD',\n '--',\n filePath,\n ]);\n collectLinesFromDiff(diffOutput);\n }\n\n // 4. Regular git diff between baseRef and currentRef (e.g., CI pull-request diff)\n if (mode.includes('gitDiff')) {\n await git.fetch(baseRef);\n const diffOutput = await git.diff([\n '--unified=0',\n `${baseRef}...${currentRef}`,\n '--',\n filePath,\n ]);\n collectLinesFromDiff(diffOutput);\n }\n\n // Return the list sorted for convenience\n return Array.from(changedLines).sort((a, b) => a - b);\n};\n"],"mappings":"+LAQA,MAAM,EAAgB,SAAoC,CACxD,GAAI,CAGF,OADgB,MADJ,GAAW,CACG,SAAS,CAAC,kBAAkB,CAAC,EACxC,MAAM,OACd,EAAO,CAKd,OAJkB,EAAa,EAAc,CACnC,qCAAqC,IAAS,CACtD,MAAO,QACR,CAAC,CACK,OAWE,EAAe,MAAO,CACjC,OACA,UAAU,cACV,aAAa,OACb,WAAW,MACc,CACzB,GAAI,CACF,IAAM,EAAM,GAAW,CACjB,EAAoB,IAAI,IAgD9B,GA9CI,EAAK,SAAS,YAAY,GACb,MAAM,EAAI,QAAQ,EAC1B,UAAU,QAAS,GAAS,CACjC,EAAK,IAAI,EAAK,EACd,CAGA,EAAK,SAAS,cAAc,GAEN,MAAM,EAAI,KAAK,CAAC,cAAe,OAAO,CAAC,EAEtB,MAAM;EAAK,CAAC,OAAO,QAAQ,CAEnD,QAAS,GAAS,CACjC,EAAK,IAAI,EAAK,EACd,CAGA,EAAK,SAAS,WAAW,GAEN,MAAM,EAAI,KAAK,CAAC,cAAe,iBAAiB,CAAC,EAEnC,MAAM;EAAK,CAAC,OAAO,QAAQ,CAEhD,QAAS,GAAS,CAC9B,EAAK,IAAI,EAAK,EACd,CAGA,EAAK,SAAS,UAAU,GAG1B,MAAM,EAAI,MAAM,EAAQ,EAEL,MAAM,EAAI,KAAK,CAChC,cACA,GAAG,EAAQ,KAAK,IACjB,CAAC,EAE8B,MAAM;EAAK,CAAC,OAAO,QAAQ,CAE9C,QAAS,GAAS,CAC7B,EAAK,IAAI,EAAK,EACd,EAGA,EAAU,CACZ,IAAM,EAAa,MAAM,GAAe,CAIxC,OAHK,EAGE,MAAM,KAAK,EAAK,CAAC,IAAK,GAAS,EAAK,EAAY,EAAK,CAAC,CAFpD,EAAE,CAKb,OAAO,MAAM,KAAK,EAAK,OAChB,EAAO,CACd,QAAQ,KAAK,8BAA+B,EAAM,GAUzC,EAAe,MAC1B,EACA,CACE,OACA,UAAU,cACV,aAAa,UAEO,CACtB,IAAM,EAAM,GAAW,CAGjB,EAA4B,IAAI,IAQhC,EAAwB,GAAuB,CACnD,IAAM,EAAY,8CACd,EAGJ,MAAQ,EAAQ,EAAU,KAAK,EAAW,IAAM,MAAM,CACpD,IAAM,EAAW,EAAM,GAAK,OAAO,EAAM,GAAG,CAAG,EACzC,EAAW,OAAO,EAAM,GAAG,CAC3B,EAAW,EAAM,GAAK,OAAO,EAAM,GAAG,CAAG,EAG/C,GAAI,EAAW,EACb,IAAK,IAAI,EAAI,EAAG,EAAI,EAAU,IAC5B,EAAa,IAAI,EAAW,EAAE,CAK9B,EAAW,GAAK,IAAa,IAG3B,EAAW,GACb,EAAa,IAAI,EAAW,EAAE,CAEhC,EAAa,IAAI,EAAS,IAMhC,GAAI,EAAK,SAAS,YAAY,GACb,MAAM,EAAI,QAAQ,EACN,UAAU,SAAS,EAAS,CAErD,GAAI,CACc,EAAa,EAAU,QAAQ,CACvC,MAAM;EAAK,CAAC,SAAS,EAAG,IAAQ,CACtC,EAAa,IAAI,EAAM,EAAE,EACzB,MACI,EAoCZ,OA7BI,EAAK,SAAS,cAAc,EAE9B,EADmB,MAAM,EAAI,KAAK,CAAC,cAAe,OAAQ,KAAM,EAAS,CAAC,CAC1C,CAI9B,EAAK,SAAS,WAAW,EAO3B,EANmB,MAAM,EAAI,KAAK,CAChC,cACA,iBACA,KACA,EACD,CAAC,CAC8B,CAI9B,EAAK,SAAS,UAAU,GAC1B,MAAM,EAAI,MAAM,EAAQ,CAOxB,EANmB,MAAM,EAAI,KAAK,CAChC,cACA,GAAG,EAAQ,KAAK,IAChB,KACA,EACD,CAAC,CAC8B,EAI3B,MAAM,KAAK,EAAa,CAAC,MAAM,EAAG,IAAM,EAAI,EAAE"}
1
+ {"version":3,"file":"listGitFiles.mjs","names":[],"sources":["../../src/listGitFiles.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport { join } from 'node:path';\nimport configuration from '@intlayer/config/built';\nimport { getAppLogger } from '@intlayer/config/logger';\nimport simpleGit from 'simple-git';\n\nexport type DiffMode = 'gitDiff' | 'uncommitted' | 'unpushed' | 'untracked';\n\nconst getGitRootDir = async (): Promise<string | null> => {\n try {\n const git = simpleGit();\n const rootDir = await git.revparse(['--show-toplevel']);\n return rootDir.trim();\n } catch (error) {\n const appLogger = getAppLogger(configuration);\n appLogger(`Error getting git root directory: ${error}`, {\n level: 'error',\n });\n return null;\n }\n};\n\nexport type ListGitFilesOptions = {\n mode: DiffMode[];\n baseRef?: string;\n currentRef?: string;\n absolute?: boolean;\n};\n\nexport const listGitFiles = async ({\n mode,\n baseRef = 'origin/main',\n currentRef = 'HEAD', // HEAD points to the current branch's latest commit\n absolute = true,\n}: ListGitFilesOptions) => {\n try {\n const git = simpleGit();\n const diff: Set<string> = new Set();\n\n if (mode.includes('untracked')) {\n const status = await git.status();\n status.not_added.forEach((file) => {\n diff.add(file);\n });\n }\n\n if (mode.includes('uncommitted')) {\n // Get uncommitted changes\n const uncommittedDiff = await git.diff(['--name-only', 'HEAD']);\n\n const uncommittedFiles = uncommittedDiff.split('\\n').filter(Boolean);\n\n uncommittedFiles.forEach((file) => {\n diff.add(file);\n });\n }\n\n if (mode.includes('unpushed')) {\n // Get unpushed commits\n const unpushedDiff = await git.diff(['--name-only', '@{push}...HEAD']);\n\n const unpushedFiles = unpushedDiff.split('\\n').filter(Boolean);\n\n unpushedFiles.forEach((file) => {\n diff.add(file);\n });\n }\n\n if (mode.includes('gitDiff')) {\n // Get the base branch (usually main/master) from CI environment\n\n await git.fetch(baseRef);\n\n const diffBranch = await git.diff([\n '--name-only',\n `${baseRef}...${currentRef}`,\n ]);\n\n const gitDiffFiles = diffBranch.split('\\n').filter(Boolean);\n\n gitDiffFiles.forEach((file) => {\n diff.add(file);\n });\n }\n\n if (absolute) {\n const gitRootDir = await getGitRootDir();\n if (!gitRootDir) {\n return [];\n }\n return Array.from(diff).map((file) => join(gitRootDir, file));\n }\n\n return Array.from(diff);\n } catch (error) {\n console.warn('Failed to get changes list:', error);\n }\n};\n\nexport type ListGitLinesOptions = {\n mode: DiffMode[];\n baseRef?: string;\n currentRef?: string;\n};\n\nexport const listGitLines = async (\n filePath: string,\n {\n mode,\n baseRef = 'origin/main',\n currentRef = 'HEAD', // HEAD points to the current branch's latest commit\n }: ListGitLinesOptions\n): Promise<number[]> => {\n const git = simpleGit();\n // We collect **line numbers** (1-based) that were modified/added by the diff.\n // Using a Set ensures uniqueness when the same line is reported by several modes.\n const changedLines: Set<number> = new Set();\n\n /**\n * Extracts line numbers from a diff generated with `--unified=0`.\n * Each hunk header looks like: @@ -<oldStart>,<oldCount> +<newStart>,<newCount> @@\n * We consider both the \"+\" (new) side for additions and the \"-\" (old) side for deletions.\n * For deletions, we add the line before and after the deletion point in the current file.\n */\n const collectLinesFromDiff = (diffOutput: string) => {\n const hunkRegex = /@@ -(\\d+)(?:,(\\d+))? \\+(\\d+)(?:,(\\d+))? @@/g;\n let match: RegExpExecArray | null;\n\n // biome-ignore lint/suspicious/noAssignInExpressions: Used in while loop condition\n while ((match = hunkRegex.exec(diffOutput)) !== null) {\n const oldCount = match[2] ? Number(match[2]) : 1;\n const newStart = Number(match[3]);\n const newCount = match[4] ? Number(match[4]) : 1;\n\n // Handle additions/modifications (+ side)\n if (newCount > 0) {\n for (let i = 0; i < newCount; i++) {\n changedLines.add(newStart + i);\n }\n }\n\n // Handle deletions (- side)\n if (oldCount > 0 && newCount === 0) {\n // For deletions, add the line before and after the deletion point\n // The deletion point in the new file is at newStart\n if (newStart > 1) {\n changedLines.add(newStart - 1); // Line before deletion\n }\n changedLines.add(newStart); // Line after deletion (if it exists)\n }\n }\n };\n\n // 1. Handle untracked files – when a file is untracked its entire content is new.\n if (mode.includes('untracked')) {\n const status = await git.status();\n const isUntracked = status.not_added.includes(filePath);\n if (isUntracked) {\n try {\n const content = readFileSync(filePath, 'utf-8');\n content.split('\\n').forEach((_, idx) => {\n changedLines.add(idx + 1);\n });\n } catch {\n // ignore read errors – file may have been deleted, etc.\n }\n }\n }\n\n // 2. Uncommitted changes (working tree vs HEAD)\n if (mode.includes('uncommitted')) {\n const diffOutput = await git.diff(['--unified=0', 'HEAD', '--', filePath]);\n collectLinesFromDiff(diffOutput);\n }\n\n // 3. Unpushed commits – compare local branch to its upstream\n if (mode.includes('unpushed')) {\n const diffOutput = await git.diff([\n '--unified=0',\n '@{push}...HEAD',\n '--',\n filePath,\n ]);\n collectLinesFromDiff(diffOutput);\n }\n\n // 4. Regular git diff between baseRef and currentRef (e.g., CI pull-request diff)\n if (mode.includes('gitDiff')) {\n await git.fetch(baseRef);\n const diffOutput = await git.diff([\n '--unified=0',\n `${baseRef}...${currentRef}`,\n '--',\n filePath,\n ]);\n collectLinesFromDiff(diffOutput);\n }\n\n // Return the list sorted for convenience\n return Array.from(changedLines).sort((a, b) => a - b);\n};\n"],"mappings":";;;;;;;AAQA,MAAM,gBAAgB,YAAoC;AACxD,KAAI;AAGF,UADgB,MADJ,WAAW,CACG,SAAS,CAAC,kBAAkB,CAAC,EACxC,MAAM;UACd,OAAO;AAEd,EADkB,aAAa,cAAc,CACnC,qCAAqC,SAAS,EACtD,OAAO,SACR,CAAC;AACF,SAAO;;;AAWX,MAAa,eAAe,OAAO,EACjC,MACA,UAAU,eACV,aAAa,QACb,WAAW,WACc;AACzB,KAAI;EACF,MAAM,MAAM,WAAW;EACvB,MAAM,uBAAoB,IAAI,KAAK;AAEnC,MAAI,KAAK,SAAS,YAAY,CAE5B,EADe,MAAM,IAAI,QAAQ,EAC1B,UAAU,SAAS,SAAS;AACjC,QAAK,IAAI,KAAK;IACd;AAGJ,MAAI,KAAK,SAAS,cAAc,CAM9B,EAJwB,MAAM,IAAI,KAAK,CAAC,eAAe,OAAO,CAAC,EAEtB,MAAM,KAAK,CAAC,OAAO,QAAQ,CAEnD,SAAS,SAAS;AACjC,QAAK,IAAI,KAAK;IACd;AAGJ,MAAI,KAAK,SAAS,WAAW,CAM3B,EAJqB,MAAM,IAAI,KAAK,CAAC,eAAe,iBAAiB,CAAC,EAEnC,MAAM,KAAK,CAAC,OAAO,QAAQ,CAEhD,SAAS,SAAS;AAC9B,QAAK,IAAI,KAAK;IACd;AAGJ,MAAI,KAAK,SAAS,UAAU,EAAE;AAG5B,SAAM,IAAI,MAAM,QAAQ;AASxB,IAPmB,MAAM,IAAI,KAAK,CAChC,eACA,GAAG,QAAQ,KAAK,aACjB,CAAC,EAE8B,MAAM,KAAK,CAAC,OAAO,QAAQ,CAE9C,SAAS,SAAS;AAC7B,SAAK,IAAI,KAAK;KACd;;AAGJ,MAAI,UAAU;GACZ,MAAM,aAAa,MAAM,eAAe;AACxC,OAAI,CAAC,WACH,QAAO,EAAE;AAEX,UAAO,MAAM,KAAK,KAAK,CAAC,KAAK,SAAS,KAAK,YAAY,KAAK,CAAC;;AAG/D,SAAO,MAAM,KAAK,KAAK;UAChB,OAAO;AACd,UAAQ,KAAK,+BAA+B,MAAM;;;AAUtD,MAAa,eAAe,OAC1B,UACA,EACE,MACA,UAAU,eACV,aAAa,aAEO;CACtB,MAAM,MAAM,WAAW;CAGvB,MAAM,+BAA4B,IAAI,KAAK;;;;;;;CAQ3C,MAAM,wBAAwB,eAAuB;EACnD,MAAM,YAAY;EAClB,IAAI;AAGJ,UAAQ,QAAQ,UAAU,KAAK,WAAW,MAAM,MAAM;GACpD,MAAM,WAAW,MAAM,KAAK,OAAO,MAAM,GAAG,GAAG;GAC/C,MAAM,WAAW,OAAO,MAAM,GAAG;GACjC,MAAM,WAAW,MAAM,KAAK,OAAO,MAAM,GAAG,GAAG;AAG/C,OAAI,WAAW,EACb,MAAK,IAAI,IAAI,GAAG,IAAI,UAAU,IAC5B,cAAa,IAAI,WAAW,EAAE;AAKlC,OAAI,WAAW,KAAK,aAAa,GAAG;AAGlC,QAAI,WAAW,EACb,cAAa,IAAI,WAAW,EAAE;AAEhC,iBAAa,IAAI,SAAS;;;;AAMhC,KAAI,KAAK,SAAS,YAAY,EAG5B;OAFe,MAAM,IAAI,QAAQ,EACN,UAAU,SAAS,SAAS,CAErD,KAAI;AAEF,GADgB,aAAa,UAAU,QAAQ,CACvC,MAAM,KAAK,CAAC,SAAS,GAAG,QAAQ;AACtC,iBAAa,IAAI,MAAM,EAAE;KACzB;UACI;;AAOZ,KAAI,KAAK,SAAS,cAAc,CAE9B,sBADmB,MAAM,IAAI,KAAK;EAAC;EAAe;EAAQ;EAAM;EAAS,CAAC,CAC1C;AAIlC,KAAI,KAAK,SAAS,WAAW,CAO3B,sBANmB,MAAM,IAAI,KAAK;EAChC;EACA;EACA;EACA;EACD,CAAC,CAC8B;AAIlC,KAAI,KAAK,SAAS,UAAU,EAAE;AAC5B,QAAM,IAAI,MAAM,QAAQ;AAOxB,uBANmB,MAAM,IAAI,KAAK;GAChC;GACA,GAAG,QAAQ,KAAK;GAChB;GACA;GACD,CAAC,CAC8B;;AAIlC,QAAO,MAAM,KAAK,aAAa,CAAC,MAAM,GAAG,MAAM,IAAI,EAAE"}
@@ -1,2 +1,44 @@
1
- import{dirname as e}from"node:path";import t from"fast-glob";import{configurationFilesCandidates as n}from"@intlayer/config/node";import r from"simple-git";const i=async e=>{try{return(await(e?r(e):r()).revparse([`--show-toplevel`])).trim()}catch{return null}},a=async r=>{let a=r?.baseDir??process.cwd();if(r?.gitRoot){let e=await i(a);e&&(a=e)}let o=await t(n.map(e=>`**/${e}`),{cwd:a,absolute:!0,ignore:[`**/node_modules/**`,`**/.git/**`],dot:!0}),s=[...new Set(o.map(t=>e(t)))];return{searchDir:a,projectsPath:s.sort()}};export{a as listProjects};
1
+ import { dirname } from "node:path";
2
+ import fg from "fast-glob";
3
+ import { configurationFilesCandidates } from "@intlayer/config/node";
4
+ import simpleGit from "simple-git";
5
+
6
+ //#region src/listProjects.ts
7
+ /**
8
+ * Get the git root directory
9
+ */
10
+ const getGitRootDir = async (cwd) => {
11
+ try {
12
+ return (await (cwd ? simpleGit(cwd) : simpleGit()).revparse(["--show-toplevel"])).trim();
13
+ } catch (_error) {
14
+ return null;
15
+ }
16
+ };
17
+ /**
18
+ * List all Intlayer projects by searching for configuration files
19
+ *
20
+ * @param options - Options for listing projects
21
+ * @returns Array of absolute paths to project directories containing Intlayer config
22
+ */
23
+ const listProjects = async (options) => {
24
+ let searchDir = options?.baseDir ?? process.cwd();
25
+ if (options?.gitRoot) {
26
+ const gitRootDir = await getGitRootDir(searchDir);
27
+ if (gitRootDir) searchDir = gitRootDir;
28
+ }
29
+ const configFiles = await fg(configurationFilesCandidates.map((fileName) => `**/${fileName}`), {
30
+ cwd: searchDir,
31
+ absolute: true,
32
+ ignore: ["**/node_modules/**", "**/.git/**"],
33
+ dot: true
34
+ });
35
+ const projectDirs = [...new Set(configFiles.map((file) => dirname(file)))];
36
+ return {
37
+ searchDir,
38
+ projectsPath: projectDirs.sort()
39
+ };
40
+ };
41
+
42
+ //#endregion
43
+ export { listProjects };
2
44
  //# sourceMappingURL=listProjects.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"listProjects.mjs","names":[],"sources":["../../src/listProjects.ts"],"sourcesContent":["import { dirname } from 'node:path';\nimport { configurationFilesCandidates } from '@intlayer/config/node';\nimport fg from 'fast-glob';\nimport simpleGit from 'simple-git';\n\nexport type ListProjectsOptions = {\n /**\n * Base directory to search from\n * @default process.cwd()\n */\n baseDir?: string;\n /**\n * If true, search from the git root directory instead of baseDir\n * @default false\n */\n gitRoot?: boolean;\n};\n\n/**\n * Get the git root directory\n */\nconst getGitRootDir = async (cwd?: string): Promise<string | null> => {\n try {\n const git = cwd ? simpleGit(cwd) : simpleGit();\n const rootDir = await git.revparse(['--show-toplevel']);\n return rootDir.trim();\n } catch (_error) {\n return null;\n }\n};\n\n/**\n * List all Intlayer projects by searching for configuration files\n *\n * @param options - Options for listing projects\n * @returns Array of absolute paths to project directories containing Intlayer config\n */\nexport const listProjects = async (\n options?: ListProjectsOptions\n): Promise<{ searchDir: string; projectsPath: string[] }> => {\n let searchDir = options?.baseDir ?? process.cwd();\n\n // If gitRoot option is enabled, try to get the git root directory\n if (options?.gitRoot) {\n const gitRootDir = await getGitRootDir(searchDir);\n if (gitRootDir) {\n searchDir = gitRootDir;\n }\n }\n\n // Build glob patterns for all config file candidates\n const configPatterns = configurationFilesCandidates.map(\n (fileName) => `**/${fileName}`\n );\n\n // Search for all config files\n const configFiles = await fg(configPatterns, {\n cwd: searchDir,\n absolute: true,\n ignore: ['**/node_modules/**', '**/.git/**'],\n dot: true, // Include dot files like .intlayerrc\n });\n\n // Extract unique directory paths from config files\n const projectDirs = [...new Set(configFiles.map((file) => dirname(file)))];\n\n // Sort alphabetically for consistent output\n return { searchDir, projectsPath: projectDirs.sort() };\n};\n"],"mappings":"4JAqBA,MAAM,EAAgB,KAAO,IAAyC,CACpE,GAAI,CAGF,OADgB,MADJ,EAAM,EAAU,EAAI,CAAG,GAAW,EACpB,SAAS,CAAC,kBAAkB,CAAC,EACxC,MAAM,MACN,CACf,OAAO,OAUE,EAAe,KAC1B,IAC2D,CAC3D,IAAI,EAAY,GAAS,SAAW,QAAQ,KAAK,CAGjD,GAAI,GAAS,QAAS,CACpB,IAAM,EAAa,MAAM,EAAc,EAAU,CAC7C,IACF,EAAY,GAUhB,IAAM,EAAc,MAAM,EALH,EAA6B,IACjD,GAAa,MAAM,IACrB,CAG4C,CAC3C,IAAK,EACL,SAAU,GACV,OAAQ,CAAC,qBAAsB,aAAa,CAC5C,IAAK,GACN,CAAC,CAGI,EAAc,CAAC,GAAG,IAAI,IAAI,EAAY,IAAK,GAAS,EAAQ,EAAK,CAAC,CAAC,CAAC,CAG1E,MAAO,CAAE,YAAW,aAAc,EAAY,MAAM,CAAE"}
1
+ {"version":3,"file":"listProjects.mjs","names":[],"sources":["../../src/listProjects.ts"],"sourcesContent":["import { dirname } from 'node:path';\nimport { configurationFilesCandidates } from '@intlayer/config/node';\nimport fg from 'fast-glob';\nimport simpleGit from 'simple-git';\n\nexport type ListProjectsOptions = {\n /**\n * Base directory to search from\n * @default process.cwd()\n */\n baseDir?: string;\n /**\n * If true, search from the git root directory instead of baseDir\n * @default false\n */\n gitRoot?: boolean;\n};\n\n/**\n * Get the git root directory\n */\nconst getGitRootDir = async (cwd?: string): Promise<string | null> => {\n try {\n const git = cwd ? simpleGit(cwd) : simpleGit();\n const rootDir = await git.revparse(['--show-toplevel']);\n return rootDir.trim();\n } catch (_error) {\n return null;\n }\n};\n\n/**\n * List all Intlayer projects by searching for configuration files\n *\n * @param options - Options for listing projects\n * @returns Array of absolute paths to project directories containing Intlayer config\n */\nexport const listProjects = async (\n options?: ListProjectsOptions\n): Promise<{ searchDir: string; projectsPath: string[] }> => {\n let searchDir = options?.baseDir ?? process.cwd();\n\n // If gitRoot option is enabled, try to get the git root directory\n if (options?.gitRoot) {\n const gitRootDir = await getGitRootDir(searchDir);\n if (gitRootDir) {\n searchDir = gitRootDir;\n }\n }\n\n // Build glob patterns for all config file candidates\n const configPatterns = configurationFilesCandidates.map(\n (fileName) => `**/${fileName}`\n );\n\n // Search for all config files\n const configFiles = await fg(configPatterns, {\n cwd: searchDir,\n absolute: true,\n ignore: ['**/node_modules/**', '**/.git/**'],\n dot: true, // Include dot files like .intlayerrc\n });\n\n // Extract unique directory paths from config files\n const projectDirs = [...new Set(configFiles.map((file) => dirname(file)))];\n\n // Sort alphabetically for consistent output\n return { searchDir, projectsPath: projectDirs.sort() };\n};\n"],"mappings":";;;;;;;;;AAqBA,MAAM,gBAAgB,OAAO,QAAyC;AACpE,KAAI;AAGF,UADgB,OADJ,MAAM,UAAU,IAAI,GAAG,WAAW,EACpB,SAAS,CAAC,kBAAkB,CAAC,EACxC,MAAM;UACd,QAAQ;AACf,SAAO;;;;;;;;;AAUX,MAAa,eAAe,OAC1B,YAC2D;CAC3D,IAAI,YAAY,SAAS,WAAW,QAAQ,KAAK;AAGjD,KAAI,SAAS,SAAS;EACpB,MAAM,aAAa,MAAM,cAAc,UAAU;AACjD,MAAI,WACF,aAAY;;CAUhB,MAAM,cAAc,MAAM,GALH,6BAA6B,KACjD,aAAa,MAAM,WACrB,EAG4C;EAC3C,KAAK;EACL,UAAU;EACV,QAAQ,CAAC,sBAAsB,aAAa;EAC5C,KAAK;EACN,CAAC;CAGF,MAAM,cAAc,CAAC,GAAG,IAAI,IAAI,YAAY,KAAK,SAAS,QAAQ,KAAK,CAAC,CAAC,CAAC;AAG1E,QAAO;EAAE;EAAW,cAAc,YAAY,MAAM;EAAE"}
@@ -1,2 +1,68 @@
1
- import{t as e}from"../chunk-DDgYwkfe.mjs";import{readFile as t}from"node:fs/promises";import{join as n}from"node:path";import{configESMxCJSRequire as r,getProjectRequire as i,isESModule as a}from"@intlayer/config/utils";import{bundleFile as o}from"@intlayer/config/file";import{builtinModules as s,createRequire as c}from"node:module";const l=(e,t)=>({name:`rewrite-paths`,setup(n){n.onResolve({filter:/.*/},n=>{let r=e[n.path];if(t?.includes(n.path))return null;if(r)return{path:r,namespace:`intlayer-replace-modules`,external:!0};for(let t of Object.keys(e))if(n.path===t||n.path.startsWith(`${t}/`)){let r=n.path.slice(t.length);return{path:e[t]+r,namespace:`intlayer-replace-modules`,external:!0}}})}}),u=async u=>{let d=i(u.system.baseDir),f=r,p=a?c(import.meta.url):e,m=n(u.system.configDir,`configuration.json`),h={defu:f.resolve(`defu`),esbuild:f.resolve(`esbuild`),"@intlayer/config/built":m,"@intlayer/config/utils":p.resolve(`@intlayer/config/utils`),"@intlayer/config/client":p.resolve(`@intlayer/config/client`),"@intlayer/config/logger":p.resolve(`@intlayer/config/logger`),"@intlayer/core/file":p.resolve(`@intlayer/core/file`)},g=d.resolve(`intlayer`);return await o(await t(g,`utf-8`),g,{external:[...s,...s.map(e=>`node:${e}`)],minify:!0,plugins:[l(h)]})??``};export{u as getIntlayerBundle};
1
+ import { __require } from "../_virtual/_rolldown/runtime.mjs";
2
+ import { readFile } from "node:fs/promises";
3
+ import { join } from "node:path";
4
+ import { configESMxCJSRequire, getProjectRequire, isESModule } from "@intlayer/config/utils";
5
+ import { bundleFile } from "@intlayer/config/file";
6
+ import { builtinModules, createRequire } from "node:module";
7
+
8
+ //#region src/loadDictionaries/getIntlayerBundle.ts
9
+ /**
10
+ * Rewrites selected bare specifiers (and any of their subpaths) to absolute file paths,
11
+ * using the provided localeRequire (either createRequire(import.meta.url) or require).
12
+ *
13
+ * Example:
14
+ * rewritePathsPlugin(["@intlayer/config", "@intlayer/core"], localeRequire)
15
+ * …will also rewrite "@intlayer/core/file" etc.
16
+ */
17
+ const rewritePathsPlugin = (replaceModules, excludeModules) => {
18
+ return {
19
+ name: "rewrite-paths",
20
+ setup(build) {
21
+ build.onResolve({ filter: /.*/ }, (args) => {
22
+ const exact = replaceModules[args.path];
23
+ if (excludeModules?.includes(args.path)) return null;
24
+ if (exact) return {
25
+ path: exact,
26
+ namespace: "intlayer-replace-modules",
27
+ external: true
28
+ };
29
+ for (const key of Object.keys(replaceModules)) if (args.path === key || args.path.startsWith(`${key}/`)) {
30
+ const sub = args.path.slice(key.length);
31
+ return {
32
+ path: replaceModules[key] + sub,
33
+ namespace: "intlayer-replace-modules",
34
+ external: true
35
+ };
36
+ }
37
+ });
38
+ }
39
+ };
40
+ };
41
+ /**
42
+ * Get the intlayer bundle to embed @intlayer/core and be able to mock @intlayer/config/built to mock the configuration file.
43
+ */
44
+ const getIntlayerBundle = async (configuration) => {
45
+ const rootRequire = getProjectRequire(configuration.system.baseDir);
46
+ const configPackageRequire = configESMxCJSRequire;
47
+ const localRequire = isESModule ? createRequire(import.meta.url) : __require;
48
+ const configurationPath = join(configuration.system.configDir, `configuration.json`);
49
+ const replaceModules = {
50
+ defu: configPackageRequire.resolve("defu"),
51
+ esbuild: configPackageRequire.resolve("esbuild"),
52
+ "@intlayer/config/built": configurationPath,
53
+ "@intlayer/config/utils": localRequire.resolve("@intlayer/config/utils"),
54
+ "@intlayer/config/client": localRequire.resolve("@intlayer/config/client"),
55
+ "@intlayer/config/logger": localRequire.resolve("@intlayer/config/logger"),
56
+ "@intlayer/core/file": localRequire.resolve("@intlayer/core/file")
57
+ };
58
+ const filePath = rootRequire.resolve("intlayer");
59
+ return await bundleFile(await readFile(filePath, "utf-8"), filePath, {
60
+ external: [...builtinModules, ...builtinModules.map((mod) => `node:${mod}`)],
61
+ minify: true,
62
+ plugins: [rewritePathsPlugin(replaceModules)]
63
+ }) ?? "";
64
+ };
65
+
66
+ //#endregion
67
+ export { getIntlayerBundle };
2
68
  //# sourceMappingURL=getIntlayerBundle.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"getIntlayerBundle.mjs","names":[],"sources":["../../../src/loadDictionaries/getIntlayerBundle.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises';\nimport { builtinModules, createRequire } from 'node:module';\nimport { join } from 'node:path';\nimport { bundleFile, type ESBuildPlugin } from '@intlayer/config/file';\nimport {\n configESMxCJSRequire,\n getProjectRequire,\n isESModule,\n} from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\n\n/**\n * Rewrites selected bare specifiers (and any of their subpaths) to absolute file paths,\n * using the provided localeRequire (either createRequire(import.meta.url) or require).\n *\n * Example:\n * rewritePathsPlugin([\"@intlayer/config\", \"@intlayer/core\"], localeRequire)\n * …will also rewrite \"@intlayer/core/file\" etc.\n */\nconst rewritePathsPlugin = (\n replaceModules: Record<string, string>,\n excludeModules?: string[]\n): ESBuildPlugin => {\n return {\n name: 'rewrite-paths',\n setup(build) {\n build.onResolve({ filter: /.*/ }, (args) => {\n const exact = replaceModules[args.path];\n\n if (excludeModules?.includes(args.path)) {\n return null;\n }\n\n if (exact) {\n return {\n path: exact,\n namespace: 'intlayer-replace-modules',\n external: true, // ← prevents onLoad requirement\n };\n }\n\n // Optional: support subpaths like \"@intlayer/core/xyz\"\n for (const key of Object.keys(replaceModules)) {\n if (args.path === key || args.path.startsWith(`${key}/`)) {\n const sub = args.path.slice(key.length); // '' or '/...'\n return {\n path: replaceModules[key] + sub,\n namespace: 'intlayer-replace-modules',\n external: true, // ← prevents onLoad requirement\n };\n }\n }\n });\n },\n };\n};\n\n/**\n * Get the intlayer bundle to embed @intlayer/core and be able to mock @intlayer/config/built to mock the configuration file.\n */\nexport const getIntlayerBundle = async (configuration: IntlayerConfig) => {\n const rootRequire = getProjectRequire(configuration.system.baseDir);\n const configPackageRequire = configESMxCJSRequire;\n const localRequire = isESModule ? createRequire(import.meta.url) : require;\n\n const configurationPath = join(\n configuration.system.configDir,\n `configuration.json`\n );\n\n const replaceModules = {\n defu: configPackageRequire.resolve('defu'),\n esbuild: configPackageRequire.resolve('esbuild'),\n '@intlayer/config/built': configurationPath,\n '@intlayer/config/utils': localRequire.resolve('@intlayer/config/utils'),\n '@intlayer/config/client': localRequire.resolve('@intlayer/config/client'),\n '@intlayer/config/logger': localRequire.resolve('@intlayer/config/logger'),\n '@intlayer/core/file': localRequire.resolve('@intlayer/core/file'),\n };\n\n const filePath = rootRequire.resolve('intlayer');\n const code = await readFile(filePath, 'utf-8');\n\n const output = await bundleFile(code, filePath, {\n external: [\n ...builtinModules,\n ...builtinModules.map((mod) => `node:${mod}`),\n ],\n minify: true,\n plugins: [rewritePathsPlugin(replaceModules)],\n });\n\n return output ?? '';\n};\n"],"mappings":"+UAmBA,MAAM,GACJ,EACA,KAEO,CACL,KAAM,gBACN,MAAM,EAAO,CACX,EAAM,UAAU,CAAE,OAAQ,KAAM,CAAG,GAAS,CAC1C,IAAM,EAAQ,EAAe,EAAK,MAElC,GAAI,GAAgB,SAAS,EAAK,KAAK,CACrC,OAAO,KAGT,GAAI,EACF,MAAO,CACL,KAAM,EACN,UAAW,2BACX,SAAU,GACX,CAIH,IAAK,IAAM,KAAO,OAAO,KAAK,EAAe,CAC3C,GAAI,EAAK,OAAS,GAAO,EAAK,KAAK,WAAW,GAAG,EAAI,GAAG,CAAE,CACxD,IAAM,EAAM,EAAK,KAAK,MAAM,EAAI,OAAO,CACvC,MAAO,CACL,KAAM,EAAe,GAAO,EAC5B,UAAW,2BACX,SAAU,GACX,GAGL,EAEL,EAMU,EAAoB,KAAO,IAAkC,CACxE,IAAM,EAAc,EAAkB,EAAc,OAAO,QAAQ,CAC7D,EAAuB,EACvB,EAAe,EAAa,EAAc,OAAO,KAAK,IAAI,CAAA,EAE1D,EAAoB,EACxB,EAAc,OAAO,UACrB,qBACD,CAEK,EAAiB,CACrB,KAAM,EAAqB,QAAQ,OAAO,CAC1C,QAAS,EAAqB,QAAQ,UAAU,CAChD,yBAA0B,EAC1B,yBAA0B,EAAa,QAAQ,yBAAyB,CACxE,0BAA2B,EAAa,QAAQ,0BAA0B,CAC1E,0BAA2B,EAAa,QAAQ,0BAA0B,CAC1E,sBAAuB,EAAa,QAAQ,sBAAsB,CACnE,CAEK,EAAW,EAAY,QAAQ,WAAW,CAYhD,OATe,MAAM,EAFR,MAAM,EAAS,EAAU,QAAQ,CAER,EAAU,CAC9C,SAAU,CACR,GAAG,EACH,GAAG,EAAe,IAAK,GAAQ,QAAQ,IAAM,CAC9C,CACD,OAAQ,GACR,QAAS,CAAC,EAAmB,EAAe,CAAC,CAC9C,CAAC,EAEe"}
1
+ {"version":3,"file":"getIntlayerBundle.mjs","names":[],"sources":["../../../src/loadDictionaries/getIntlayerBundle.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises';\nimport { builtinModules, createRequire } from 'node:module';\nimport { join } from 'node:path';\nimport { bundleFile, type ESBuildPlugin } from '@intlayer/config/file';\nimport {\n configESMxCJSRequire,\n getProjectRequire,\n isESModule,\n} from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\n\n/**\n * Rewrites selected bare specifiers (and any of their subpaths) to absolute file paths,\n * using the provided localeRequire (either createRequire(import.meta.url) or require).\n *\n * Example:\n * rewritePathsPlugin([\"@intlayer/config\", \"@intlayer/core\"], localeRequire)\n * …will also rewrite \"@intlayer/core/file\" etc.\n */\nconst rewritePathsPlugin = (\n replaceModules: Record<string, string>,\n excludeModules?: string[]\n): ESBuildPlugin => {\n return {\n name: 'rewrite-paths',\n setup(build) {\n build.onResolve({ filter: /.*/ }, (args) => {\n const exact = replaceModules[args.path];\n\n if (excludeModules?.includes(args.path)) {\n return null;\n }\n\n if (exact) {\n return {\n path: exact,\n namespace: 'intlayer-replace-modules',\n external: true, // ← prevents onLoad requirement\n };\n }\n\n // Optional: support subpaths like \"@intlayer/core/xyz\"\n for (const key of Object.keys(replaceModules)) {\n if (args.path === key || args.path.startsWith(`${key}/`)) {\n const sub = args.path.slice(key.length); // '' or '/...'\n return {\n path: replaceModules[key] + sub,\n namespace: 'intlayer-replace-modules',\n external: true, // ← prevents onLoad requirement\n };\n }\n }\n });\n },\n };\n};\n\n/**\n * Get the intlayer bundle to embed @intlayer/core and be able to mock @intlayer/config/built to mock the configuration file.\n */\nexport const getIntlayerBundle = async (configuration: IntlayerConfig) => {\n const rootRequire = getProjectRequire(configuration.system.baseDir);\n const configPackageRequire = configESMxCJSRequire;\n const localRequire = isESModule ? createRequire(import.meta.url) : require;\n\n const configurationPath = join(\n configuration.system.configDir,\n `configuration.json`\n );\n\n const replaceModules = {\n defu: configPackageRequire.resolve('defu'),\n esbuild: configPackageRequire.resolve('esbuild'),\n '@intlayer/config/built': configurationPath,\n '@intlayer/config/utils': localRequire.resolve('@intlayer/config/utils'),\n '@intlayer/config/client': localRequire.resolve('@intlayer/config/client'),\n '@intlayer/config/logger': localRequire.resolve('@intlayer/config/logger'),\n '@intlayer/core/file': localRequire.resolve('@intlayer/core/file'),\n };\n\n const filePath = rootRequire.resolve('intlayer');\n const code = await readFile(filePath, 'utf-8');\n\n const output = await bundleFile(code, filePath, {\n external: [\n ...builtinModules,\n ...builtinModules.map((mod) => `node:${mod}`),\n ],\n minify: true,\n plugins: [rewritePathsPlugin(replaceModules)],\n });\n\n return output ?? '';\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAmBA,MAAM,sBACJ,gBACA,mBACkB;AAClB,QAAO;EACL,MAAM;EACN,MAAM,OAAO;AACX,SAAM,UAAU,EAAE,QAAQ,MAAM,GAAG,SAAS;IAC1C,MAAM,QAAQ,eAAe,KAAK;AAElC,QAAI,gBAAgB,SAAS,KAAK,KAAK,CACrC,QAAO;AAGT,QAAI,MACF,QAAO;KACL,MAAM;KACN,WAAW;KACX,UAAU;KACX;AAIH,SAAK,MAAM,OAAO,OAAO,KAAK,eAAe,CAC3C,KAAI,KAAK,SAAS,OAAO,KAAK,KAAK,WAAW,GAAG,IAAI,GAAG,EAAE;KACxD,MAAM,MAAM,KAAK,KAAK,MAAM,IAAI,OAAO;AACvC,YAAO;MACL,MAAM,eAAe,OAAO;MAC5B,WAAW;MACX,UAAU;MACX;;KAGL;;EAEL;;;;;AAMH,MAAa,oBAAoB,OAAO,kBAAkC;CACxE,MAAM,cAAc,kBAAkB,cAAc,OAAO,QAAQ;CACnE,MAAM,uBAAuB;CAC7B,MAAM,eAAe,aAAa,cAAc,OAAO,KAAK,IAAI;CAEhE,MAAM,oBAAoB,KACxB,cAAc,OAAO,WACrB,qBACD;CAED,MAAM,iBAAiB;EACrB,MAAM,qBAAqB,QAAQ,OAAO;EAC1C,SAAS,qBAAqB,QAAQ,UAAU;EAChD,0BAA0B;EAC1B,0BAA0B,aAAa,QAAQ,yBAAyB;EACxE,2BAA2B,aAAa,QAAQ,0BAA0B;EAC1E,2BAA2B,aAAa,QAAQ,0BAA0B;EAC1E,uBAAuB,aAAa,QAAQ,sBAAsB;EACnE;CAED,MAAM,WAAW,YAAY,QAAQ,WAAW;AAYhD,QATe,MAAM,WAFR,MAAM,SAAS,UAAU,QAAQ,EAER,UAAU;EAC9C,UAAU,CACR,GAAG,gBACH,GAAG,eAAe,KAAK,QAAQ,QAAQ,MAAM,CAC9C;EACD,QAAQ;EACR,SAAS,CAAC,mBAAmB,eAAe,CAAC;EAC9C,CAAC,IAEe"}
@@ -1 +1,6 @@
1
- import{ensureIntlayerBundle as e,formatLocalDictionaries as t,loadContentDeclaration as n,loadContentDeclarations as r}from"./loadContentDeclaration.mjs";import{loadLocalDictionaries as i}from"./loadLocalDictionaries.mjs";import{formatDistantDictionaries as a,loadRemoteDictionaries as o}from"./loadRemoteDictionaries.mjs";import{loadDictionaries as s}from"./loadDictionaries.mjs";export{e as ensureIntlayerBundle,a as formatDistantDictionaries,t as formatLocalDictionaries,n as loadContentDeclaration,r as loadContentDeclarations,s as loadDictionaries,i as loadLocalDictionaries,o as loadRemoteDictionaries};
1
+ import { ensureIntlayerBundle, formatLocalDictionaries, loadContentDeclaration, loadContentDeclarations } from "./loadContentDeclaration.mjs";
2
+ import { loadLocalDictionaries } from "./loadLocalDictionaries.mjs";
3
+ import { formatDistantDictionaries, loadRemoteDictionaries } from "./loadRemoteDictionaries.mjs";
4
+ import { loadDictionaries } from "./loadDictionaries.mjs";
5
+
6
+ export { ensureIntlayerBundle, formatDistantDictionaries, formatLocalDictionaries, loadContentDeclaration, loadContentDeclarations, loadDictionaries, loadLocalDictionaries, loadRemoteDictionaries };
@@ -1,3 +1,89 @@
1
- import{parallelize as e}from"../utils/parallelize.mjs";import{filterInvalidDictionaries as t}from"../filterInvalidDictionaries.mjs";import{processContentDeclaration as n}from"../buildIntlayerDictionary/processContentDeclaration.mjs";import{getIntlayerBundle as r}from"./getIntlayerBundle.mjs";import{logTypeScriptErrors as i}from"./logTypeScriptErrors.mjs";import{writeFile as a}from"node:fs/promises";import{join as o,relative as s}from"node:path";import{cacheDisk as c,getProjectRequire as l}from"@intlayer/config/utils";import{loadExternalFile as u}from"@intlayer/config/file";const d=(e,t)=>Object.entries(e).map(([e,n])=>({...n,location:n.location??t.dictionary?.location??`local`,localId:`${n.key}::local::${e}`,filePath:e})),f=async e=>{let{system:t}=e,{set:n,isValid:i}=c(e,[`intlayer-bundle`],{ttlMs:1e3*60*60*24*5}),s=o(t.cacheDir,`intlayer-bundle.cjs`);return await i()||(await a(s,await r(e)),await n(`ok`)),s},p=async(e,t,n)=>{let{build:r}=t,i=n??await f(t);try{return await u(e,{projectRequire:r.require??l(),buildOptions:{banner:{js:[`globalThis.INTLAYER_FILE_PATH = '${e}';`,`globalThis.INTLAYER_BASE_DIR = '${t.system.baseDir}';`].join(`
2
- `)}},aliases:{intlayer:i}})}catch(t){console.error(`Error loading content declaration at ${e}:`,t);return}},m=async(r,a,o)=>{let{build:c,system:l}=a;c.checkTypes&&i(r,a).catch(e=>{console.error(`Error during TypeScript validation:`,e)});let u=await f(a);try{let i=r.map(async e=>({relativePath:s(a.system.baseDir,e),dictionary:await p(e,a,u)})),c=d((await Promise.all(i)).reduce((e,{relativePath:t,dictionary:n})=>(n&&(e[t]=n),e),{}),a).filter(e=>e.location!==`remote`),l=c.map(e=>({dictionaryKey:e.key,type:`local`,status:`found`}));return o?.(l),t(await e(c,async e=>{if(!e)return;o?.([{dictionaryKey:e.key,type:`local`,status:`building`}]);let t=await n(e,a);if(t)return o?.([{dictionaryKey:t.key,type:`local`,status:`built`}]),t}),a,{checkSchema:!1})}catch{console.error(`Error loading content declarations`)}return[]};export{f as ensureIntlayerBundle,d as formatLocalDictionaries,p as loadContentDeclaration,m as loadContentDeclarations};
1
+ import { parallelize } from "../utils/parallelize.mjs";
2
+ import { filterInvalidDictionaries } from "../filterInvalidDictionaries.mjs";
3
+ import { processContentDeclaration } from "../buildIntlayerDictionary/processContentDeclaration.mjs";
4
+ import { getIntlayerBundle } from "./getIntlayerBundle.mjs";
5
+ import { logTypeScriptErrors } from "./logTypeScriptErrors.mjs";
6
+ import { writeFile } from "node:fs/promises";
7
+ import { join, relative } from "node:path";
8
+ import { cacheDisk, getProjectRequire } from "@intlayer/config/utils";
9
+ import { loadExternalFile } from "@intlayer/config/file";
10
+
11
+ //#region src/loadDictionaries/loadContentDeclaration.ts
12
+ const formatLocalDictionaries = (dictionariesRecord, configuration) => Object.entries(dictionariesRecord).map(([relativePath, dict]) => ({
13
+ ...dict,
14
+ location: dict.location ?? configuration.dictionary?.location ?? "local",
15
+ localId: `${dict.key}::local::${relativePath}`,
16
+ filePath: relativePath
17
+ }));
18
+ const ensureIntlayerBundle = async (configuration) => {
19
+ const { system } = configuration;
20
+ const { set, isValid } = cacheDisk(configuration, ["intlayer-bundle"], { ttlMs: 1e3 * 60 * 60 * 24 * 5 });
21
+ const filePath = join(system.cacheDir, "intlayer-bundle.cjs");
22
+ if (!await isValid()) {
23
+ await writeFile(filePath, await getIntlayerBundle(configuration));
24
+ await set("ok");
25
+ }
26
+ return filePath;
27
+ };
28
+ const loadContentDeclaration = async (path, configuration, bundleFilePath) => {
29
+ const { build } = configuration;
30
+ const resolvedBundleFilePath = bundleFilePath ?? await ensureIntlayerBundle(configuration);
31
+ try {
32
+ return await loadExternalFile(path, {
33
+ projectRequire: build.require ?? getProjectRequire(),
34
+ buildOptions: { banner: { js: [`globalThis.INTLAYER_FILE_PATH = '${path}';`, `globalThis.INTLAYER_BASE_DIR = '${configuration.system.baseDir}';`].join("\n") } },
35
+ aliases: { intlayer: resolvedBundleFilePath }
36
+ });
37
+ } catch (error) {
38
+ console.error(`Error loading content declaration at ${path}:`, error);
39
+ return;
40
+ }
41
+ };
42
+ const loadContentDeclarations = async (contentDeclarationFilePath, configuration, onStatusUpdate) => {
43
+ const { build, system } = configuration;
44
+ if (build.checkTypes) logTypeScriptErrors(contentDeclarationFilePath, configuration).catch((e) => {
45
+ console.error("Error during TypeScript validation:", e);
46
+ });
47
+ const bundleFilePath = await ensureIntlayerBundle(configuration);
48
+ try {
49
+ const dictionariesPromises = contentDeclarationFilePath.map(async (path) => {
50
+ return {
51
+ relativePath: relative(configuration.system.baseDir, path),
52
+ dictionary: await loadContentDeclaration(path, configuration, bundleFilePath)
53
+ };
54
+ });
55
+ const contentDeclarations = formatLocalDictionaries((await Promise.all(dictionariesPromises)).reduce((acc, { relativePath, dictionary }) => {
56
+ if (dictionary) acc[relativePath] = dictionary;
57
+ return acc;
58
+ }, {}), configuration).filter((dictionary) => dictionary.location !== "remote");
59
+ const listFoundDictionaries = contentDeclarations.map((declaration) => ({
60
+ dictionaryKey: declaration.key,
61
+ type: "local",
62
+ status: "found"
63
+ }));
64
+ onStatusUpdate?.(listFoundDictionaries);
65
+ return filterInvalidDictionaries(await parallelize(contentDeclarations, async (contentDeclaration) => {
66
+ if (!contentDeclaration) return;
67
+ onStatusUpdate?.([{
68
+ dictionaryKey: contentDeclaration.key,
69
+ type: "local",
70
+ status: "building"
71
+ }]);
72
+ const processedContentDeclaration = await processContentDeclaration(contentDeclaration, configuration);
73
+ if (!processedContentDeclaration) return;
74
+ onStatusUpdate?.([{
75
+ dictionaryKey: processedContentDeclaration.key,
76
+ type: "local",
77
+ status: "built"
78
+ }]);
79
+ return processedContentDeclaration;
80
+ }), configuration, { checkSchema: false });
81
+ } catch {
82
+ console.error("Error loading content declarations");
83
+ }
84
+ return [];
85
+ };
86
+
87
+ //#endregion
88
+ export { ensureIntlayerBundle, formatLocalDictionaries, loadContentDeclaration, loadContentDeclarations };
3
89
  //# sourceMappingURL=loadContentDeclaration.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"loadContentDeclaration.mjs","names":[],"sources":["../../../src/loadDictionaries/loadContentDeclaration.ts"],"sourcesContent":["import { writeFile } from 'node:fs/promises';\nimport { join, relative } from 'node:path';\nimport { loadExternalFile } from '@intlayer/config/file';\nimport { cacheDisk, getProjectRequire } from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { processContentDeclaration } from '../buildIntlayerDictionary/processContentDeclaration';\nimport { filterInvalidDictionaries } from '../filterInvalidDictionaries';\nimport { parallelize } from '../utils/parallelize';\nimport { getIntlayerBundle } from './getIntlayerBundle';\nimport type { DictionariesStatus } from './loadDictionaries';\nimport { logTypeScriptErrors } from './logTypeScriptErrors';\n\nexport const formatLocalDictionaries = (\n dictionariesRecord: Record<string, Dictionary>,\n configuration: IntlayerConfig\n): Dictionary[] =>\n Object.entries(dictionariesRecord).map(([relativePath, dict]) => ({\n ...dict,\n location: dict.location ?? configuration.dictionary?.location ?? 'local',\n localId: `${dict.key}::local::${relativePath}`,\n filePath: relativePath,\n }));\n\nexport const ensureIntlayerBundle = async (\n configuration: IntlayerConfig\n): Promise<string> => {\n const { system } = configuration;\n\n const { set, isValid } = cacheDisk(configuration, ['intlayer-bundle'], {\n ttlMs: 1000 * 60 * 60 * 24 * 5, // 5 days\n });\n\n const filePath = join(system.cacheDir, 'intlayer-bundle.cjs');\n const hasIntlayerBundle = await isValid();\n\n if (!hasIntlayerBundle) {\n const intlayerBundle = await getIntlayerBundle(configuration);\n await writeFile(filePath, intlayerBundle);\n await set('ok');\n }\n\n return filePath;\n};\n\nexport const loadContentDeclaration = async (\n path: string,\n configuration: IntlayerConfig,\n bundleFilePath?: string\n): Promise<Dictionary | undefined> => {\n const { build } = configuration;\n\n const resolvedBundleFilePath =\n bundleFilePath ?? (await ensureIntlayerBundle(configuration));\n\n try {\n const dictionary = await loadExternalFile(path, {\n projectRequire: build.require ?? getProjectRequire(),\n buildOptions: {\n banner: {\n js: [\n `globalThis.INTLAYER_FILE_PATH = '${path}';`,\n `globalThis.INTLAYER_BASE_DIR = '${configuration.system.baseDir}';`,\n ].join('\\n'),\n },\n },\n aliases: {\n intlayer: resolvedBundleFilePath,\n },\n });\n\n return dictionary;\n } catch (error) {\n console.error(`Error loading content declaration at ${path}:`, error);\n return undefined;\n }\n};\n\nexport const loadContentDeclarations = async (\n contentDeclarationFilePath: string[],\n configuration: IntlayerConfig,\n onStatusUpdate?: (status: DictionariesStatus[]) => void\n): Promise<Dictionary[]> => {\n const { build, system } = configuration;\n\n // Check for TypeScript warnings before we build\n if (build.checkTypes) {\n logTypeScriptErrors(contentDeclarationFilePath, configuration).catch(\n (e) => {\n console.error('Error during TypeScript validation:', e);\n }\n );\n }\n\n const bundleFilePath = await ensureIntlayerBundle(configuration);\n\n try {\n const dictionariesPromises = contentDeclarationFilePath.map(\n async (path) => {\n const relativePath = relative(configuration.system.baseDir, path);\n\n const dictionary = await loadContentDeclaration(\n path,\n configuration,\n bundleFilePath\n );\n\n return { relativePath, dictionary };\n }\n );\n\n const dictionariesArray = await Promise.all(dictionariesPromises);\n const dictionariesRecord = dictionariesArray.reduce(\n (acc, { relativePath, dictionary }) => {\n if (dictionary) {\n acc[relativePath] = dictionary;\n }\n return acc;\n },\n {} as Record<string, Dictionary>\n );\n\n const contentDeclarations: Dictionary[] = formatLocalDictionaries(\n dictionariesRecord,\n configuration\n ).filter((dictionary) => dictionary.location !== 'remote');\n\n const listFoundDictionaries = contentDeclarations.map((declaration) => ({\n dictionaryKey: declaration.key,\n type: 'local' as const,\n status: 'found' as const,\n }));\n\n onStatusUpdate?.(listFoundDictionaries);\n\n const processedDictionaries = await parallelize(\n contentDeclarations,\n async (contentDeclaration): Promise<Dictionary | undefined> => {\n if (!contentDeclaration) {\n return undefined;\n }\n\n onStatusUpdate?.([\n {\n dictionaryKey: contentDeclaration.key,\n type: 'local',\n status: 'building',\n },\n ]);\n\n const processedContentDeclaration = await processContentDeclaration(\n contentDeclaration as Dictionary,\n configuration\n );\n\n if (!processedContentDeclaration) {\n return undefined;\n }\n\n onStatusUpdate?.([\n {\n dictionaryKey: processedContentDeclaration.key,\n type: 'local',\n status: 'built',\n },\n ]);\n\n return processedContentDeclaration;\n }\n );\n\n return filterInvalidDictionaries(processedDictionaries, configuration, {\n checkSchema: false,\n });\n } catch {\n console.error('Error loading content declarations');\n }\n\n return [];\n};\n"],"mappings":"okBAaA,MAAa,GACX,EACA,IAEA,OAAO,QAAQ,EAAmB,CAAC,KAAK,CAAC,EAAc,MAAW,CAChE,GAAG,EACH,SAAU,EAAK,UAAY,EAAc,YAAY,UAAY,QACjE,QAAS,GAAG,EAAK,IAAI,WAAW,IAChC,SAAU,EACX,EAAE,CAEQ,EAAuB,KAClC,IACoB,CACpB,GAAM,CAAE,UAAW,EAEb,CAAE,MAAK,WAAY,EAAU,EAAe,CAAC,kBAAkB,CAAE,CACrE,MAAO,IAAO,GAAK,GAAK,GAAK,EAC9B,CAAC,CAEI,EAAW,EAAK,EAAO,SAAU,sBAAsB,CAS7D,OAR0B,MAAM,GAAS,GAIvC,MAAM,EAAU,EADO,MAAM,EAAkB,EAAc,CACpB,CACzC,MAAM,EAAI,KAAK,EAGV,GAGI,EAAyB,MACpC,EACA,EACA,IACoC,CACpC,GAAM,CAAE,SAAU,EAEZ,EACJ,GAAmB,MAAM,EAAqB,EAAc,CAE9D,GAAI,CAgBF,OAfmB,MAAM,EAAiB,EAAM,CAC9C,eAAgB,EAAM,SAAW,GAAmB,CACpD,aAAc,CACZ,OAAQ,CACN,GAAI,CACF,oCAAoC,EAAK,IACzC,mCAAmC,EAAc,OAAO,QAAQ,IACjE,CAAC,KAAK;EAAK,CACb,CACF,CACD,QAAS,CACP,SAAU,EACX,CACF,CAAC,OAGK,EAAO,CACd,QAAQ,MAAM,wCAAwC,EAAK,GAAI,EAAM,CACrE,SAIS,EAA0B,MACrC,EACA,EACA,IAC0B,CAC1B,GAAM,CAAE,QAAO,UAAW,EAGtB,EAAM,YACR,EAAoB,EAA4B,EAAc,CAAC,MAC5D,GAAM,CACL,QAAQ,MAAM,sCAAuC,EAAE,EAE1D,CAGH,IAAM,EAAiB,MAAM,EAAqB,EAAc,CAEhE,GAAI,CACF,IAAM,EAAuB,EAA2B,IACtD,KAAO,KASE,CAAE,aARY,EAAS,EAAc,OAAO,QAAS,EAAK,CAQ1C,WANJ,MAAM,EACvB,EACA,EACA,EACD,CAEkC,EAEtC,CAaK,EAAoC,GAXhB,MAAM,QAAQ,IAAI,EAAqB,EACpB,QAC1C,EAAK,CAAE,eAAc,iBAChB,IACF,EAAI,GAAgB,GAEf,GAET,EAAE,CACH,CAIC,EACD,CAAC,OAAQ,GAAe,EAAW,WAAa,SAAS,CAEpD,EAAwB,EAAoB,IAAK,IAAiB,CACtE,cAAe,EAAY,IAC3B,KAAM,QACN,OAAQ,QACT,EAAE,CAwCH,OAtCA,IAAiB,EAAsB,CAsChC,EApCuB,MAAM,EAClC,EACA,KAAO,IAAwD,CAC7D,GAAI,CAAC,EACH,OAGF,IAAiB,CACf,CACE,cAAe,EAAmB,IAClC,KAAM,QACN,OAAQ,WACT,CACF,CAAC,CAEF,IAAM,EAA8B,MAAM,EACxC,EACA,EACD,CAEI,KAYL,OARA,IAAiB,CACf,CACE,cAAe,EAA4B,IAC3C,KAAM,QACN,OAAQ,QACT,CACF,CAAC,CAEK,GAEV,CAEuD,EAAe,CACrE,YAAa,GACd,CAAC,MACI,CACN,QAAQ,MAAM,qCAAqC,CAGrD,MAAO,EAAE"}
1
+ {"version":3,"file":"loadContentDeclaration.mjs","names":[],"sources":["../../../src/loadDictionaries/loadContentDeclaration.ts"],"sourcesContent":["import { writeFile } from 'node:fs/promises';\nimport { join, relative } from 'node:path';\nimport { loadExternalFile } from '@intlayer/config/file';\nimport { cacheDisk, getProjectRequire } from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { processContentDeclaration } from '../buildIntlayerDictionary/processContentDeclaration';\nimport { filterInvalidDictionaries } from '../filterInvalidDictionaries';\nimport { parallelize } from '../utils/parallelize';\nimport { getIntlayerBundle } from './getIntlayerBundle';\nimport type { DictionariesStatus } from './loadDictionaries';\nimport { logTypeScriptErrors } from './logTypeScriptErrors';\n\nexport const formatLocalDictionaries = (\n dictionariesRecord: Record<string, Dictionary>,\n configuration: IntlayerConfig\n): Dictionary[] =>\n Object.entries(dictionariesRecord).map(([relativePath, dict]) => ({\n ...dict,\n location: dict.location ?? configuration.dictionary?.location ?? 'local',\n localId: `${dict.key}::local::${relativePath}`,\n filePath: relativePath,\n }));\n\nexport const ensureIntlayerBundle = async (\n configuration: IntlayerConfig\n): Promise<string> => {\n const { system } = configuration;\n\n const { set, isValid } = cacheDisk(configuration, ['intlayer-bundle'], {\n ttlMs: 1000 * 60 * 60 * 24 * 5, // 5 days\n });\n\n const filePath = join(system.cacheDir, 'intlayer-bundle.cjs');\n const hasIntlayerBundle = await isValid();\n\n if (!hasIntlayerBundle) {\n const intlayerBundle = await getIntlayerBundle(configuration);\n await writeFile(filePath, intlayerBundle);\n await set('ok');\n }\n\n return filePath;\n};\n\nexport const loadContentDeclaration = async (\n path: string,\n configuration: IntlayerConfig,\n bundleFilePath?: string\n): Promise<Dictionary | undefined> => {\n const { build } = configuration;\n\n const resolvedBundleFilePath =\n bundleFilePath ?? (await ensureIntlayerBundle(configuration));\n\n try {\n const dictionary = await loadExternalFile(path, {\n projectRequire: build.require ?? getProjectRequire(),\n buildOptions: {\n banner: {\n js: [\n `globalThis.INTLAYER_FILE_PATH = '${path}';`,\n `globalThis.INTLAYER_BASE_DIR = '${configuration.system.baseDir}';`,\n ].join('\\n'),\n },\n },\n aliases: {\n intlayer: resolvedBundleFilePath,\n },\n });\n\n return dictionary;\n } catch (error) {\n console.error(`Error loading content declaration at ${path}:`, error);\n return undefined;\n }\n};\n\nexport const loadContentDeclarations = async (\n contentDeclarationFilePath: string[],\n configuration: IntlayerConfig,\n onStatusUpdate?: (status: DictionariesStatus[]) => void\n): Promise<Dictionary[]> => {\n const { build, system } = configuration;\n\n // Check for TypeScript warnings before we build\n if (build.checkTypes) {\n logTypeScriptErrors(contentDeclarationFilePath, configuration).catch(\n (e) => {\n console.error('Error during TypeScript validation:', e);\n }\n );\n }\n\n const bundleFilePath = await ensureIntlayerBundle(configuration);\n\n try {\n const dictionariesPromises = contentDeclarationFilePath.map(\n async (path) => {\n const relativePath = relative(configuration.system.baseDir, path);\n\n const dictionary = await loadContentDeclaration(\n path,\n configuration,\n bundleFilePath\n );\n\n return { relativePath, dictionary };\n }\n );\n\n const dictionariesArray = await Promise.all(dictionariesPromises);\n const dictionariesRecord = dictionariesArray.reduce(\n (acc, { relativePath, dictionary }) => {\n if (dictionary) {\n acc[relativePath] = dictionary;\n }\n return acc;\n },\n {} as Record<string, Dictionary>\n );\n\n const contentDeclarations: Dictionary[] = formatLocalDictionaries(\n dictionariesRecord,\n configuration\n ).filter((dictionary) => dictionary.location !== 'remote');\n\n const listFoundDictionaries = contentDeclarations.map((declaration) => ({\n dictionaryKey: declaration.key,\n type: 'local' as const,\n status: 'found' as const,\n }));\n\n onStatusUpdate?.(listFoundDictionaries);\n\n const processedDictionaries = await parallelize(\n contentDeclarations,\n async (contentDeclaration): Promise<Dictionary | undefined> => {\n if (!contentDeclaration) {\n return undefined;\n }\n\n onStatusUpdate?.([\n {\n dictionaryKey: contentDeclaration.key,\n type: 'local',\n status: 'building',\n },\n ]);\n\n const processedContentDeclaration = await processContentDeclaration(\n contentDeclaration as Dictionary,\n configuration\n );\n\n if (!processedContentDeclaration) {\n return undefined;\n }\n\n onStatusUpdate?.([\n {\n dictionaryKey: processedContentDeclaration.key,\n type: 'local',\n status: 'built',\n },\n ]);\n\n return processedContentDeclaration;\n }\n );\n\n return filterInvalidDictionaries(processedDictionaries, configuration, {\n checkSchema: false,\n });\n } catch {\n console.error('Error loading content declarations');\n }\n\n return [];\n};\n"],"mappings":";;;;;;;;;;;AAaA,MAAa,2BACX,oBACA,kBAEA,OAAO,QAAQ,mBAAmB,CAAC,KAAK,CAAC,cAAc,WAAW;CAChE,GAAG;CACH,UAAU,KAAK,YAAY,cAAc,YAAY,YAAY;CACjE,SAAS,GAAG,KAAK,IAAI,WAAW;CAChC,UAAU;CACX,EAAE;AAEL,MAAa,uBAAuB,OAClC,kBACoB;CACpB,MAAM,EAAE,WAAW;CAEnB,MAAM,EAAE,KAAK,YAAY,UAAU,eAAe,CAAC,kBAAkB,EAAE,EACrE,OAAO,MAAO,KAAK,KAAK,KAAK,GAC9B,CAAC;CAEF,MAAM,WAAW,KAAK,OAAO,UAAU,sBAAsB;AAG7D,KAAI,CAFsB,MAAM,SAAS,EAEjB;AAEtB,QAAM,UAAU,UADO,MAAM,kBAAkB,cAAc,CACpB;AACzC,QAAM,IAAI,KAAK;;AAGjB,QAAO;;AAGT,MAAa,yBAAyB,OACpC,MACA,eACA,mBACoC;CACpC,MAAM,EAAE,UAAU;CAElB,MAAM,yBACJ,kBAAmB,MAAM,qBAAqB,cAAc;AAE9D,KAAI;AAgBF,SAfmB,MAAM,iBAAiB,MAAM;GAC9C,gBAAgB,MAAM,WAAW,mBAAmB;GACpD,cAAc,EACZ,QAAQ,EACN,IAAI,CACF,oCAAoC,KAAK,KACzC,mCAAmC,cAAc,OAAO,QAAQ,IACjE,CAAC,KAAK,KAAK,EACb,EACF;GACD,SAAS,EACP,UAAU,wBACX;GACF,CAAC;UAGK,OAAO;AACd,UAAQ,MAAM,wCAAwC,KAAK,IAAI,MAAM;AACrE;;;AAIJ,MAAa,0BAA0B,OACrC,4BACA,eACA,mBAC0B;CAC1B,MAAM,EAAE,OAAO,WAAW;AAG1B,KAAI,MAAM,WACR,qBAAoB,4BAA4B,cAAc,CAAC,OAC5D,MAAM;AACL,UAAQ,MAAM,uCAAuC,EAAE;GAE1D;CAGH,MAAM,iBAAiB,MAAM,qBAAqB,cAAc;AAEhE,KAAI;EACF,MAAM,uBAAuB,2BAA2B,IACtD,OAAO,SAAS;AASd,UAAO;IAAE,cARY,SAAS,cAAc,OAAO,SAAS,KAAK;IAQ1C,YANJ,MAAM,uBACvB,MACA,eACA,eACD;IAEkC;IAEtC;EAaD,MAAM,sBAAoC,yBAXhB,MAAM,QAAQ,IAAI,qBAAqB,EACpB,QAC1C,KAAK,EAAE,cAAc,iBAAiB;AACrC,OAAI,WACF,KAAI,gBAAgB;AAEtB,UAAO;KAET,EAAE,CACH,EAIC,cACD,CAAC,QAAQ,eAAe,WAAW,aAAa,SAAS;EAE1D,MAAM,wBAAwB,oBAAoB,KAAK,iBAAiB;GACtE,eAAe,YAAY;GAC3B,MAAM;GACN,QAAQ;GACT,EAAE;AAEH,mBAAiB,sBAAsB;AAsCvC,SAAO,0BApCuB,MAAM,YAClC,qBACA,OAAO,uBAAwD;AAC7D,OAAI,CAAC,mBACH;AAGF,oBAAiB,CACf;IACE,eAAe,mBAAmB;IAClC,MAAM;IACN,QAAQ;IACT,CACF,CAAC;GAEF,MAAM,8BAA8B,MAAM,0BACxC,oBACA,cACD;AAED,OAAI,CAAC,4BACH;AAGF,oBAAiB,CACf;IACE,eAAe,4BAA4B;IAC3C,MAAM;IACN,QAAQ;IACT,CACF,CAAC;AAEF,UAAO;IAEV,EAEuD,eAAe,EACrE,aAAa,OACd,CAAC;SACI;AACN,UAAQ,MAAM,qCAAqC;;AAGrD,QAAO,EAAE"}