@intlayer/chokidar 6.1.6 → 7.0.0-canary.1

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 (464) hide show
  1. package/dist/{cjs → assets}/getContentDeclarationFileTemplate/cjsTemplate.txt +3 -2
  2. package/dist/{cjs → assets}/getContentDeclarationFileTemplate/esmTemplate.txt +2 -1
  3. package/dist/{cjs → assets}/getContentDeclarationFileTemplate/jsonTemplate.txt +2 -1
  4. package/dist/{cjs → assets}/getContentDeclarationFileTemplate/tsTemplate.txt +2 -1
  5. package/dist/cjs/_virtual/_utils_asset.cjs +104 -0
  6. package/dist/cjs/_virtual/rolldown_runtime.cjs +25 -0
  7. package/dist/cjs/buildIntlayerDictionary/buildIntlayerDictionary.cjs +42 -80
  8. package/dist/cjs/buildIntlayerDictionary/buildIntlayerDictionary.cjs.map +1 -1
  9. package/dist/cjs/buildIntlayerDictionary/index.cjs +5 -25
  10. package/dist/cjs/buildIntlayerDictionary/processContentDeclaration.cjs +21 -42
  11. package/dist/cjs/buildIntlayerDictionary/processContentDeclaration.cjs.map +1 -1
  12. package/dist/cjs/buildIntlayerDictionary/writeDynamicDictionary.cjs +79 -116
  13. package/dist/cjs/buildIntlayerDictionary/writeDynamicDictionary.cjs.map +1 -1
  14. package/dist/cjs/buildIntlayerDictionary/writeFetchDictionary.cjs +62 -86
  15. package/dist/cjs/buildIntlayerDictionary/writeFetchDictionary.cjs.map +1 -1
  16. package/dist/cjs/buildIntlayerDictionary/writeMergedDictionary.cjs +48 -69
  17. package/dist/cjs/buildIntlayerDictionary/writeMergedDictionary.cjs.map +1 -1
  18. package/dist/cjs/buildIntlayerDictionary/writeRemoteDictionary.cjs +42 -52
  19. package/dist/cjs/buildIntlayerDictionary/writeRemoteDictionary.cjs.map +1 -1
  20. package/dist/cjs/buildIntlayerDictionary/writeUnmergedDictionary.cjs +60 -82
  21. package/dist/cjs/buildIntlayerDictionary/writeUnmergedDictionary.cjs.map +1 -1
  22. package/dist/cjs/cleanOutputDir.cjs +20 -60
  23. package/dist/cjs/cleanOutputDir.cjs.map +1 -1
  24. package/dist/cjs/createDictionaryEntryPoint/createDictionaryEntryPoint.cjs +64 -103
  25. package/dist/cjs/createDictionaryEntryPoint/createDictionaryEntryPoint.cjs.map +1 -1
  26. package/dist/cjs/createDictionaryEntryPoint/generateDictionaryListContent.cjs +41 -73
  27. package/dist/cjs/createDictionaryEntryPoint/generateDictionaryListContent.cjs.map +1 -1
  28. package/dist/cjs/createDictionaryEntryPoint/getBuiltDictionariesPath.cjs +19 -49
  29. package/dist/cjs/createDictionaryEntryPoint/getBuiltDictionariesPath.cjs.map +1 -1
  30. package/dist/cjs/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.cjs +20 -50
  31. package/dist/cjs/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.cjs.map +1 -1
  32. package/dist/cjs/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.cjs +20 -50
  33. package/dist/cjs/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.cjs.map +1 -1
  34. package/dist/cjs/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.cjs +19 -49
  35. package/dist/cjs/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.cjs.map +1 -1
  36. package/dist/cjs/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.cjs +19 -49
  37. package/dist/cjs/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.cjs.map +1 -1
  38. package/dist/cjs/createDictionaryEntryPoint/index.cjs +15 -35
  39. package/dist/cjs/createType/createModuleAugmentation.cjs +56 -108
  40. package/dist/cjs/createType/createModuleAugmentation.cjs.map +1 -1
  41. package/dist/cjs/createType/createType.cjs +29 -58
  42. package/dist/cjs/createType/createType.cjs.map +1 -1
  43. package/dist/cjs/createType/index.cjs +7 -25
  44. package/dist/cjs/fetchDistantDictionaries.cjs +49 -77
  45. package/dist/cjs/fetchDistantDictionaries.cjs.map +1 -1
  46. package/dist/cjs/filterInvalidDictionaries.cjs +26 -59
  47. package/dist/cjs/filterInvalidDictionaries.cjs.map +1 -1
  48. package/dist/cjs/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs +32 -68
  49. package/dist/cjs/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs.map +1 -1
  50. package/dist/cjs/handleAdditionalContentDeclarationFile.cjs +32 -51
  51. package/dist/cjs/handleAdditionalContentDeclarationFile.cjs.map +1 -1
  52. package/dist/cjs/handleContentDeclarationFileChange.cjs +35 -56
  53. package/dist/cjs/handleContentDeclarationFileChange.cjs.map +1 -1
  54. package/dist/cjs/handleUnlinkedContentDeclarationFile.cjs +36 -0
  55. package/dist/cjs/handleUnlinkedContentDeclarationFile.cjs.map +1 -0
  56. package/dist/cjs/index.cjs +103 -156
  57. package/dist/cjs/listDictionariesPath.cjs +27 -59
  58. package/dist/cjs/listDictionariesPath.cjs.map +1 -1
  59. package/dist/cjs/listGitFiles.cjs +93 -162
  60. package/dist/cjs/listGitFiles.cjs.map +1 -1
  61. package/dist/cjs/loadDictionaries/getIntlayerBundle.cjs +70 -0
  62. package/dist/cjs/loadDictionaries/getIntlayerBundle.cjs.map +1 -0
  63. package/dist/cjs/loadDictionaries/index.cjs +11 -29
  64. package/dist/cjs/loadDictionaries/loadContentDeclaration.cjs +68 -90
  65. package/dist/cjs/loadDictionaries/loadContentDeclaration.cjs.map +1 -1
  66. package/dist/cjs/loadDictionaries/loadDictionaries.cjs +111 -166
  67. package/dist/cjs/loadDictionaries/loadDictionaries.cjs.map +1 -1
  68. package/dist/cjs/loadDictionaries/loadLocalDictionaries.cjs +27 -53
  69. package/dist/cjs/loadDictionaries/loadLocalDictionaries.cjs.map +1 -1
  70. package/dist/cjs/loadDictionaries/loadRemoteDictionaries.cjs +60 -102
  71. package/dist/cjs/loadDictionaries/loadRemoteDictionaries.cjs.map +1 -1
  72. package/dist/cjs/loadDictionaries/log.cjs +107 -182
  73. package/dist/cjs/loadDictionaries/log.cjs.map +1 -1
  74. package/dist/cjs/prepareIntlayer.cjs +73 -130
  75. package/dist/cjs/prepareIntlayer.cjs.map +1 -1
  76. package/dist/cjs/reduceDictionaryContent/applyMask.cjs +27 -61
  77. package/dist/cjs/reduceDictionaryContent/applyMask.cjs.map +1 -1
  78. package/dist/cjs/reduceDictionaryContent/reduceDictionaryContent.cjs +10 -32
  79. package/dist/cjs/reduceDictionaryContent/reduceDictionaryContent.cjs.map +1 -1
  80. package/dist/cjs/utils/chunkJSON.cjs +329 -0
  81. package/dist/cjs/utils/chunkJSON.cjs.map +1 -0
  82. package/dist/cjs/utils/extractErrorMessage.cjs +92 -135
  83. package/dist/cjs/utils/extractErrorMessage.cjs.map +1 -1
  84. package/dist/cjs/utils/formatter.cjs +19 -49
  85. package/dist/cjs/utils/formatter.cjs.map +1 -1
  86. package/dist/cjs/utils/getChunk.cjs +34 -0
  87. package/dist/cjs/utils/getChunk.cjs.map +1 -0
  88. package/dist/cjs/utils/getFileHash.cjs +9 -40
  89. package/dist/cjs/utils/getFileHash.cjs.map +1 -1
  90. package/dist/cjs/utils/getFormatFromExtension.cjs +23 -54
  91. package/dist/cjs/utils/getFormatFromExtension.cjs.map +1 -1
  92. package/dist/cjs/utils/kebabCaseToCamelCase.cjs +11 -36
  93. package/dist/cjs/utils/kebabCaseToCamelCase.cjs.map +1 -1
  94. package/dist/cjs/utils/pLimit.cjs +128 -0
  95. package/dist/cjs/utils/pLimit.cjs.map +1 -0
  96. package/dist/cjs/utils/parallelize.cjs +10 -169
  97. package/dist/cjs/utils/parallelize.cjs.map +1 -1
  98. package/dist/cjs/utils/parallelizeGlobal.cjs +29 -0
  99. package/dist/cjs/utils/parallelizeGlobal.cjs.map +1 -0
  100. package/dist/cjs/utils/reduceObjectFormat.cjs +31 -0
  101. package/dist/cjs/utils/reduceObjectFormat.cjs.map +1 -0
  102. package/dist/cjs/utils/resolveObjectPromises.cjs +18 -48
  103. package/dist/cjs/utils/resolveObjectPromises.cjs.map +1 -1
  104. package/dist/cjs/utils/runOnce.cjs +80 -57
  105. package/dist/cjs/utils/runOnce.cjs.map +1 -1
  106. package/dist/cjs/utils/runParallel.cjs +163 -74
  107. package/dist/cjs/utils/runParallel.cjs.map +1 -1
  108. package/dist/cjs/utils/sortAlphabetically.cjs +5 -27
  109. package/dist/cjs/utils/sortAlphabetically.cjs.map +1 -1
  110. package/dist/cjs/utils/splitTextByLine.cjs +11 -0
  111. package/dist/cjs/utils/splitTextByLine.cjs.map +1 -0
  112. package/dist/cjs/utils/verifyIdenticObjectFormat copy.cjs +54 -0
  113. package/dist/cjs/utils/verifyIdenticObjectFormat copy.cjs.map +1 -0
  114. package/dist/cjs/utils/verifyIdenticObjectFormat.cjs +60 -0
  115. package/dist/cjs/utils/verifyIdenticObjectFormat.cjs.map +1 -0
  116. package/dist/cjs/watcher.cjs +61 -83
  117. package/dist/cjs/watcher.cjs.map +1 -1
  118. package/dist/cjs/writeConfiguration/index.cjs +15 -35
  119. package/dist/cjs/writeConfiguration/index.cjs.map +1 -1
  120. package/dist/cjs/writeContentDeclaration/detectExportedComponentName.cjs +25 -51
  121. package/dist/cjs/writeContentDeclaration/detectExportedComponentName.cjs.map +1 -1
  122. package/dist/cjs/writeContentDeclaration/dictionaryStatus.cjs +0 -17
  123. package/dist/cjs/writeContentDeclaration/index.cjs +9 -33
  124. package/dist/cjs/writeContentDeclaration/processContentDeclarationContent.cjs +77 -0
  125. package/dist/cjs/writeContentDeclaration/processContentDeclarationContent.cjs.map +1 -0
  126. package/dist/cjs/writeContentDeclaration/transformJSFile.cjs +1731 -755
  127. package/dist/cjs/writeContentDeclaration/transformJSFile.cjs.map +1 -1
  128. package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs +113 -112
  129. package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs.map +1 -1
  130. package/dist/cjs/writeContentDeclaration/writeJSFile.cjs +56 -66
  131. package/dist/cjs/writeContentDeclaration/writeJSFile.cjs.map +1 -1
  132. package/dist/cjs/writeFileIfChanged.cjs +10 -43
  133. package/dist/cjs/writeFileIfChanged.cjs.map +1 -1
  134. package/dist/cjs/writeJsonIfChanged.cjs +14 -31
  135. package/dist/cjs/writeJsonIfChanged.cjs.map +1 -1
  136. package/dist/esm/_virtual/_utils_asset.mjs +100 -0
  137. package/dist/esm/_virtual/rolldown_runtime.mjs +8 -0
  138. package/dist/esm/buildIntlayerDictionary/buildIntlayerDictionary.mjs +35 -54
  139. package/dist/esm/buildIntlayerDictionary/buildIntlayerDictionary.mjs.map +1 -1
  140. package/dist/esm/buildIntlayerDictionary/index.mjs +4 -3
  141. package/dist/esm/buildIntlayerDictionary/processContentDeclaration.mjs +18 -17
  142. package/dist/esm/buildIntlayerDictionary/processContentDeclaration.mjs.map +1 -1
  143. package/dist/esm/buildIntlayerDictionary/writeDynamicDictionary.mjs +69 -91
  144. package/dist/esm/buildIntlayerDictionary/writeDynamicDictionary.mjs.map +1 -1
  145. package/dist/esm/buildIntlayerDictionary/writeFetchDictionary.mjs +53 -61
  146. package/dist/esm/buildIntlayerDictionary/writeFetchDictionary.mjs.map +1 -1
  147. package/dist/esm/buildIntlayerDictionary/writeMergedDictionary.mjs +40 -42
  148. package/dist/esm/buildIntlayerDictionary/writeMergedDictionary.mjs.map +1 -1
  149. package/dist/esm/buildIntlayerDictionary/writeRemoteDictionary.mjs +35 -25
  150. package/dist/esm/buildIntlayerDictionary/writeRemoteDictionary.mjs.map +1 -1
  151. package/dist/esm/buildIntlayerDictionary/writeUnmergedDictionary.mjs +53 -56
  152. package/dist/esm/buildIntlayerDictionary/writeUnmergedDictionary.mjs.map +1 -1
  153. package/dist/esm/cleanOutputDir.mjs +17 -36
  154. package/dist/esm/cleanOutputDir.mjs.map +1 -1
  155. package/dist/esm/createDictionaryEntryPoint/createDictionaryEntryPoint.mjs +51 -70
  156. package/dist/esm/createDictionaryEntryPoint/createDictionaryEntryPoint.mjs.map +1 -1
  157. package/dist/esm/createDictionaryEntryPoint/generateDictionaryListContent.mjs +36 -47
  158. package/dist/esm/createDictionaryEntryPoint/generateDictionaryListContent.mjs.map +1 -1
  159. package/dist/esm/createDictionaryEntryPoint/getBuiltDictionariesPath.mjs +14 -14
  160. package/dist/esm/createDictionaryEntryPoint/getBuiltDictionariesPath.mjs.map +1 -1
  161. package/dist/esm/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.mjs +15 -15
  162. package/dist/esm/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.mjs.map +1 -1
  163. package/dist/esm/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.mjs +15 -15
  164. package/dist/esm/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.mjs.map +1 -1
  165. package/dist/esm/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.mjs +14 -14
  166. package/dist/esm/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.mjs.map +1 -1
  167. package/dist/esm/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.mjs +14 -14
  168. package/dist/esm/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.mjs.map +1 -1
  169. package/dist/esm/createDictionaryEntryPoint/index.mjs +9 -8
  170. package/dist/esm/createType/createModuleAugmentation.mjs +48 -71
  171. package/dist/esm/createType/createModuleAugmentation.mjs.map +1 -1
  172. package/dist/esm/createType/createType.mjs +24 -35
  173. package/dist/esm/createType/createType.mjs.map +1 -1
  174. package/dist/esm/createType/index.mjs +4 -3
  175. package/dist/esm/fetchDistantDictionaries.mjs +45 -52
  176. package/dist/esm/fetchDistantDictionaries.mjs.map +1 -1
  177. package/dist/esm/filterInvalidDictionaries.mjs +22 -37
  178. package/dist/esm/filterInvalidDictionaries.mjs.map +1 -1
  179. package/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs +31 -42
  180. package/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs.map +1 -1
  181. package/dist/esm/handleAdditionalContentDeclarationFile.mjs +27 -24
  182. package/dist/esm/handleAdditionalContentDeclarationFile.mjs.map +1 -1
  183. package/dist/esm/handleContentDeclarationFileChange.mjs +30 -29
  184. package/dist/esm/handleContentDeclarationFileChange.mjs.map +1 -1
  185. package/dist/esm/handleUnlinkedContentDeclarationFile.mjs +34 -0
  186. package/dist/esm/handleUnlinkedContentDeclarationFile.mjs.map +1 -0
  187. package/dist/esm/index.mjs +39 -99
  188. package/dist/esm/listDictionariesPath.mjs +24 -24
  189. package/dist/esm/listDictionariesPath.mjs.map +1 -1
  190. package/dist/esm/listGitFiles.mjs +83 -124
  191. package/dist/esm/listGitFiles.mjs.map +1 -1
  192. package/dist/esm/loadDictionaries/getIntlayerBundle.mjs +66 -0
  193. package/dist/esm/loadDictionaries/getIntlayerBundle.mjs.map +1 -0
  194. package/dist/esm/loadDictionaries/index.mjs +6 -5
  195. package/dist/esm/loadDictionaries/loadContentDeclaration.mjs +61 -70
  196. package/dist/esm/loadDictionaries/loadContentDeclaration.mjs.map +1 -1
  197. package/dist/esm/loadDictionaries/loadDictionaries.mjs +105 -146
  198. package/dist/esm/loadDictionaries/loadDictionaries.mjs.map +1 -1
  199. package/dist/esm/loadDictionaries/loadLocalDictionaries.mjs +23 -31
  200. package/dist/esm/loadDictionaries/loadLocalDictionaries.mjs.map +1 -1
  201. package/dist/esm/loadDictionaries/loadRemoteDictionaries.mjs +52 -74
  202. package/dist/esm/loadDictionaries/loadRemoteDictionaries.mjs.map +1 -1
  203. package/dist/esm/loadDictionaries/log.mjs +105 -165
  204. package/dist/esm/loadDictionaries/log.mjs.map +1 -1
  205. package/dist/esm/prepareIntlayer.mjs +64 -97
  206. package/dist/esm/prepareIntlayer.mjs.map +1 -1
  207. package/dist/esm/reduceDictionaryContent/applyMask.mjs +26 -37
  208. package/dist/esm/reduceDictionaryContent/applyMask.mjs.map +1 -1
  209. package/dist/esm/reduceDictionaryContent/reduceDictionaryContent.mjs +7 -7
  210. package/dist/esm/reduceDictionaryContent/reduceDictionaryContent.mjs.map +1 -1
  211. package/dist/esm/utils/chunkJSON.mjs +327 -0
  212. package/dist/esm/utils/chunkJSON.mjs.map +1 -0
  213. package/dist/esm/utils/extractErrorMessage.mjs +91 -111
  214. package/dist/esm/utils/extractErrorMessage.mjs.map +1 -1
  215. package/dist/esm/utils/formatter.mjs +10 -12
  216. package/dist/esm/utils/formatter.mjs.map +1 -1
  217. package/dist/esm/utils/getChunk.mjs +34 -0
  218. package/dist/esm/utils/getChunk.mjs.map +1 -0
  219. package/dist/esm/utils/getFileHash.mjs +6 -5
  220. package/dist/esm/utils/getFileHash.mjs.map +1 -1
  221. package/dist/esm/utils/getFormatFromExtension.mjs +21 -29
  222. package/dist/esm/utils/getFormatFromExtension.mjs.map +1 -1
  223. package/dist/esm/utils/kebabCaseToCamelCase.mjs +10 -12
  224. package/dist/esm/utils/kebabCaseToCamelCase.mjs.map +1 -1
  225. package/dist/esm/utils/pLimit.mjs +126 -0
  226. package/dist/esm/utils/pLimit.mjs.map +1 -0
  227. package/dist/esm/utils/parallelize.mjs +10 -144
  228. package/dist/esm/utils/parallelize.mjs.map +1 -1
  229. package/dist/esm/utils/parallelizeGlobal.mjs +27 -0
  230. package/dist/esm/utils/parallelizeGlobal.mjs.map +1 -0
  231. package/dist/esm/utils/reduceObjectFormat.mjs +30 -0
  232. package/dist/esm/utils/reduceObjectFormat.mjs.map +1 -0
  233. package/dist/esm/utils/resolveObjectPromises.mjs +17 -24
  234. package/dist/esm/utils/resolveObjectPromises.mjs.map +1 -1
  235. package/dist/esm/utils/runOnce.mjs +76 -33
  236. package/dist/esm/utils/runOnce.mjs.map +1 -1
  237. package/dist/esm/utils/runParallel.mjs +160 -40
  238. package/dist/esm/utils/runParallel.mjs.map +1 -1
  239. package/dist/esm/utils/sortAlphabetically.mjs +4 -3
  240. package/dist/esm/utils/sortAlphabetically.mjs.map +1 -1
  241. package/dist/esm/utils/splitTextByLine.mjs +10 -0
  242. package/dist/esm/utils/splitTextByLine.mjs.map +1 -0
  243. package/dist/esm/utils/verifyIdenticObjectFormat copy.mjs +53 -0
  244. package/dist/esm/utils/verifyIdenticObjectFormat copy.mjs.map +1 -0
  245. package/dist/esm/utils/verifyIdenticObjectFormat.mjs +59 -0
  246. package/dist/esm/utils/verifyIdenticObjectFormat.mjs.map +1 -0
  247. package/dist/esm/watcher.mjs +53 -58
  248. package/dist/esm/watcher.mjs.map +1 -1
  249. package/dist/esm/writeConfiguration/index.mjs +11 -10
  250. package/dist/esm/writeConfiguration/index.mjs.map +1 -1
  251. package/dist/esm/writeContentDeclaration/detectExportedComponentName.mjs +24 -27
  252. package/dist/esm/writeContentDeclaration/detectExportedComponentName.mjs.map +1 -1
  253. package/dist/esm/writeContentDeclaration/dictionaryStatus.mjs +0 -1
  254. package/dist/esm/writeContentDeclaration/index.mjs +6 -7
  255. package/dist/esm/writeContentDeclaration/processContentDeclarationContent.mjs +71 -0
  256. package/dist/esm/writeContentDeclaration/processContentDeclarationContent.mjs.map +1 -0
  257. package/dist/esm/writeContentDeclaration/transformJSFile.mjs +1726 -735
  258. package/dist/esm/writeContentDeclaration/transformJSFile.mjs.map +1 -1
  259. package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs +105 -76
  260. package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs.map +1 -1
  261. package/dist/esm/writeContentDeclaration/writeJSFile.mjs +48 -46
  262. package/dist/esm/writeContentDeclaration/writeJSFile.mjs.map +1 -1
  263. package/dist/esm/writeFileIfChanged.mjs +7 -18
  264. package/dist/esm/writeFileIfChanged.mjs.map +1 -1
  265. package/dist/esm/writeJsonIfChanged.mjs +14 -7
  266. package/dist/esm/writeJsonIfChanged.mjs.map +1 -1
  267. package/dist/types/buildIntlayerDictionary/buildIntlayerDictionary.d.ts +14 -7
  268. package/dist/types/buildIntlayerDictionary/buildIntlayerDictionary.d.ts.map +1 -1
  269. package/dist/types/buildIntlayerDictionary/index.d.ts +3 -3
  270. package/dist/types/buildIntlayerDictionary/processContentDeclaration.d.ts +7 -2
  271. package/dist/types/buildIntlayerDictionary/processContentDeclaration.d.ts.map +1 -1
  272. package/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts +14 -10
  273. package/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts.map +1 -1
  274. package/dist/types/buildIntlayerDictionary/writeFetchDictionary.d.ts +8 -3
  275. package/dist/types/buildIntlayerDictionary/writeFetchDictionary.d.ts.map +1 -1
  276. package/dist/types/buildIntlayerDictionary/writeMergedDictionary.d.ts +12 -7
  277. package/dist/types/buildIntlayerDictionary/writeMergedDictionary.d.ts.map +1 -1
  278. package/dist/types/buildIntlayerDictionary/writeRemoteDictionary.d.ts +8 -2
  279. package/dist/types/buildIntlayerDictionary/writeRemoteDictionary.d.ts.map +1 -1
  280. package/dist/types/buildIntlayerDictionary/writeUnmergedDictionary.d.ts +10 -6
  281. package/dist/types/buildIntlayerDictionary/writeUnmergedDictionary.d.ts.map +1 -1
  282. package/dist/types/cleanOutputDir.d.ts +6 -1
  283. package/dist/types/cleanOutputDir.d.ts.map +1 -1
  284. package/dist/types/createDictionaryEntryPoint/createDictionaryEntryPoint.d.ts +6 -1
  285. package/dist/types/createDictionaryEntryPoint/createDictionaryEntryPoint.d.ts.map +1 -1
  286. package/dist/types/createDictionaryEntryPoint/generateDictionaryListContent.d.ts +6 -1
  287. package/dist/types/createDictionaryEntryPoint/generateDictionaryListContent.d.ts.map +1 -1
  288. package/dist/types/createDictionaryEntryPoint/getBuiltDictionariesPath.d.ts +7 -1
  289. package/dist/types/createDictionaryEntryPoint/getBuiltDictionariesPath.d.ts.map +1 -1
  290. package/dist/types/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.d.ts +7 -1
  291. package/dist/types/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.d.ts.map +1 -1
  292. package/dist/types/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.d.ts +7 -1
  293. package/dist/types/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.d.ts.map +1 -1
  294. package/dist/types/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.d.ts +7 -1
  295. package/dist/types/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.d.ts.map +1 -1
  296. package/dist/types/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.d.ts +7 -1
  297. package/dist/types/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.d.ts.map +1 -1
  298. package/dist/types/createDictionaryEntryPoint/index.d.ts +8 -8
  299. package/dist/types/createType/createModuleAugmentation.d.ts +8 -5
  300. package/dist/types/createType/createModuleAugmentation.d.ts.map +1 -1
  301. package/dist/types/createType/createType.d.ts +7 -4
  302. package/dist/types/createType/createType.d.ts.map +1 -1
  303. package/dist/types/createType/index.d.ts +3 -3
  304. package/dist/types/fetchDistantDictionaries.d.ts +10 -7
  305. package/dist/types/fetchDistantDictionaries.d.ts.map +1 -1
  306. package/dist/types/filterInvalidDictionaries.d.ts +7 -4
  307. package/dist/types/filterInvalidDictionaries.d.ts.map +1 -1
  308. package/dist/types/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.d.ts +6 -2
  309. package/dist/types/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.d.ts.map +1 -1
  310. package/dist/types/handleAdditionalContentDeclarationFile.d.ts +6 -2
  311. package/dist/types/handleAdditionalContentDeclarationFile.d.ts.map +1 -1
  312. package/dist/types/handleContentDeclarationFileChange.d.ts +6 -2
  313. package/dist/types/handleContentDeclarationFileChange.d.ts.map +1 -1
  314. package/dist/types/handleUnlinkedContentDeclarationFile.d.ts +7 -0
  315. package/dist/types/handleUnlinkedContentDeclarationFile.d.ts.map +1 -0
  316. package/dist/types/index.d.ts +49 -33
  317. package/dist/types/listDictionariesPath.d.ts +7 -2
  318. package/dist/types/listDictionariesPath.d.ts.map +1 -1
  319. package/dist/types/listGitFiles.d.ts +24 -12
  320. package/dist/types/listGitFiles.d.ts.map +1 -1
  321. package/dist/types/loadDictionaries/getIntlayerBundle.d.ts +11 -0
  322. package/dist/types/loadDictionaries/getIntlayerBundle.d.ts.map +1 -0
  323. package/dist/types/loadDictionaries/index.d.ts +5 -5
  324. package/dist/types/loadDictionaries/loadContentDeclaration.d.ts +8 -5
  325. package/dist/types/loadDictionaries/loadContentDeclaration.d.ts.map +1 -1
  326. package/dist/types/loadDictionaries/loadDictionaries.d.ts +18 -14
  327. package/dist/types/loadDictionaries/loadDictionaries.d.ts.map +1 -1
  328. package/dist/types/loadDictionaries/loadLocalDictionaries.d.ts +6 -3
  329. package/dist/types/loadDictionaries/loadLocalDictionaries.d.ts.map +1 -1
  330. package/dist/types/loadDictionaries/loadRemoteDictionaries.d.ts +13 -8
  331. package/dist/types/loadDictionaries/loadRemoteDictionaries.d.ts.map +1 -1
  332. package/dist/types/loadDictionaries/log.d.ts +28 -24
  333. package/dist/types/loadDictionaries/log.d.ts.map +1 -1
  334. package/dist/types/prepareIntlayer.d.ts +12 -2
  335. package/dist/types/prepareIntlayer.d.ts.map +1 -1
  336. package/dist/types/reduceDictionaryContent/applyMask.d.ts +6 -2
  337. package/dist/types/reduceDictionaryContent/applyMask.d.ts.map +1 -1
  338. package/dist/types/reduceDictionaryContent/reduceDictionaryContent.d.ts +6 -2
  339. package/dist/types/reduceDictionaryContent/reduceDictionaryContent.d.ts.map +1 -1
  340. package/dist/types/utils/chunkJSON.d.ts +56 -0
  341. package/dist/types/utils/chunkJSON.d.ts.map +1 -0
  342. package/dist/types/utils/extractErrorMessage.d.ts +4 -1
  343. package/dist/types/utils/extractErrorMessage.d.ts.map +1 -1
  344. package/dist/types/utils/formatter.d.ts +8 -3
  345. package/dist/types/utils/formatter.d.ts.map +1 -1
  346. package/dist/types/utils/getChunk.d.ts +11 -0
  347. package/dist/types/utils/getChunk.d.ts.map +1 -0
  348. package/dist/types/utils/getFileHash.d.ts +4 -1
  349. package/dist/types/utils/getFileHash.d.ts.map +1 -1
  350. package/dist/types/utils/getFormatFromExtension.d.ts +7 -4
  351. package/dist/types/utils/getFormatFromExtension.d.ts.map +1 -1
  352. package/dist/types/utils/kebabCaseToCamelCase.d.ts +4 -1
  353. package/dist/types/utils/kebabCaseToCamelCase.d.ts.map +1 -1
  354. package/dist/types/utils/pLimit.d.ts +16 -0
  355. package/dist/types/utils/pLimit.d.ts.map +1 -0
  356. package/dist/types/utils/parallelize.d.ts +4 -13
  357. package/dist/types/utils/parallelize.d.ts.map +1 -1
  358. package/dist/types/utils/parallelizeGlobal.d.ts +22 -0
  359. package/dist/types/utils/parallelizeGlobal.d.ts.map +1 -0
  360. package/dist/types/utils/reduceObjectFormat.d.ts +17 -0
  361. package/dist/types/utils/reduceObjectFormat.d.ts.map +1 -0
  362. package/dist/types/utils/resolveObjectPromises.d.ts +4 -1
  363. package/dist/types/utils/resolveObjectPromises.d.ts.map +1 -1
  364. package/dist/types/utils/runOnce.d.ts +23 -2
  365. package/dist/types/utils/runOnce.d.ts.map +1 -1
  366. package/dist/types/utils/runParallel.d.ts +9 -6
  367. package/dist/types/utils/runParallel.d.ts.map +1 -1
  368. package/dist/types/utils/sortAlphabetically.d.ts +4 -1
  369. package/dist/types/utils/sortAlphabetically.d.ts.map +1 -1
  370. package/dist/types/utils/splitTextByLine.d.ts +5 -0
  371. package/dist/types/utils/splitTextByLine.d.ts.map +1 -0
  372. package/dist/types/utils/verifyIdenticObjectFormat copy.d.ts +23 -0
  373. package/dist/types/utils/verifyIdenticObjectFormat copy.d.ts.map +1 -0
  374. package/dist/types/utils/verifyIdenticObjectFormat.d.ts +23 -0
  375. package/dist/types/utils/verifyIdenticObjectFormat.d.ts.map +1 -0
  376. package/dist/types/watcher.d.ts +13 -9
  377. package/dist/types/watcher.d.ts.map +1 -1
  378. package/dist/types/writeConfiguration/index.d.ts +6 -2
  379. package/dist/types/writeConfiguration/index.d.ts.map +1 -1
  380. package/dist/types/writeContentDeclaration/detectExportedComponentName.d.ts +4 -1
  381. package/dist/types/writeContentDeclaration/detectExportedComponentName.d.ts.map +1 -1
  382. package/dist/types/writeContentDeclaration/dictionaryStatus.d.ts +4 -1
  383. package/dist/types/writeContentDeclaration/dictionaryStatus.d.ts.map +1 -1
  384. package/dist/types/writeContentDeclaration/index.d.ts +6 -7
  385. package/dist/types/writeContentDeclaration/processContentDeclarationContent.d.ts +7 -0
  386. package/dist/types/writeContentDeclaration/processContentDeclarationContent.d.ts.map +1 -0
  387. package/dist/types/writeContentDeclaration/transformJSFile.d.ts +33 -6
  388. package/dist/types/writeContentDeclaration/transformJSFile.d.ts.map +1 -1
  389. package/dist/types/writeContentDeclaration/writeContentDeclaration.d.ts +14 -6
  390. package/dist/types/writeContentDeclaration/writeContentDeclaration.d.ts.map +1 -1
  391. package/dist/types/writeContentDeclaration/writeJSFile.d.ts +7 -3
  392. package/dist/types/writeContentDeclaration/writeJSFile.d.ts.map +1 -1
  393. package/dist/types/writeFileIfChanged.d.ts +7 -2
  394. package/dist/types/writeFileIfChanged.d.ts.map +1 -1
  395. package/dist/types/writeJsonIfChanged.d.ts +7 -2
  396. package/dist/types/writeJsonIfChanged.d.ts.map +1 -1
  397. package/package.json +48 -54
  398. package/LICENSE +0 -202
  399. package/dist/cjs/buildIntlayerDictionary/index.cjs.map +0 -1
  400. package/dist/cjs/createDictionaryEntryPoint/index.cjs.map +0 -1
  401. package/dist/cjs/createType/index.cjs.map +0 -1
  402. package/dist/cjs/handleUnlikedContentDeclarationFile.cjs +0 -57
  403. package/dist/cjs/handleUnlikedContentDeclarationFile.cjs.map +0 -1
  404. package/dist/cjs/index.cjs.map +0 -1
  405. package/dist/cjs/loadDictionaries/index.cjs.map +0 -1
  406. package/dist/cjs/mergeDictionaries.cjs +0 -143
  407. package/dist/cjs/mergeDictionaries.cjs.map +0 -1
  408. package/dist/cjs/orderDictionaries.cjs +0 -71
  409. package/dist/cjs/orderDictionaries.cjs.map +0 -1
  410. package/dist/cjs/prepareContentDeclaration.cjs +0 -93
  411. package/dist/cjs/prepareContentDeclaration.cjs.map +0 -1
  412. package/dist/cjs/processPerLocaleDictionary.cjs +0 -49
  413. package/dist/cjs/processPerLocaleDictionary.cjs.map +0 -1
  414. package/dist/cjs/utils/getExtention.cjs +0 -37
  415. package/dist/cjs/utils/getExtention.cjs.map +0 -1
  416. package/dist/cjs/writeContentDeclaration/dictionaryStatus.cjs.map +0 -1
  417. package/dist/cjs/writeContentDeclaration/formatCode.cjs +0 -78
  418. package/dist/cjs/writeContentDeclaration/formatCode.cjs.map +0 -1
  419. package/dist/cjs/writeContentDeclaration/index.cjs.map +0 -1
  420. package/dist/esm/buildIntlayerDictionary/index.mjs.map +0 -1
  421. package/dist/esm/createDictionaryEntryPoint/index.mjs.map +0 -1
  422. package/dist/esm/createType/index.mjs.map +0 -1
  423. package/dist/esm/getContentDeclarationFileTemplate/cjsTemplate.txt +0 -9
  424. package/dist/esm/getContentDeclarationFileTemplate/esmTemplate.txt +0 -9
  425. package/dist/esm/getContentDeclarationFileTemplate/jsonTemplate.txt +0 -5
  426. package/dist/esm/getContentDeclarationFileTemplate/tsTemplate.txt +0 -8
  427. package/dist/esm/handleUnlikedContentDeclarationFile.mjs +0 -33
  428. package/dist/esm/handleUnlikedContentDeclarationFile.mjs.map +0 -1
  429. package/dist/esm/index.mjs.map +0 -1
  430. package/dist/esm/loadDictionaries/index.mjs.map +0 -1
  431. package/dist/esm/mergeDictionaries.mjs +0 -109
  432. package/dist/esm/mergeDictionaries.mjs.map +0 -1
  433. package/dist/esm/orderDictionaries.mjs +0 -37
  434. package/dist/esm/orderDictionaries.mjs.map +0 -1
  435. package/dist/esm/prepareContentDeclaration.mjs +0 -72
  436. package/dist/esm/prepareContentDeclaration.mjs.map +0 -1
  437. package/dist/esm/processPerLocaleDictionary.mjs +0 -25
  438. package/dist/esm/processPerLocaleDictionary.mjs.map +0 -1
  439. package/dist/esm/utils/getExtention.mjs +0 -13
  440. package/dist/esm/utils/getExtention.mjs.map +0 -1
  441. package/dist/esm/writeContentDeclaration/dictionaryStatus.mjs.map +0 -1
  442. package/dist/esm/writeContentDeclaration/formatCode.mjs +0 -44
  443. package/dist/esm/writeContentDeclaration/formatCode.mjs.map +0 -1
  444. package/dist/esm/writeContentDeclaration/index.mjs.map +0 -1
  445. package/dist/types/buildIntlayerDictionary/index.d.ts.map +0 -1
  446. package/dist/types/createDictionaryEntryPoint/index.d.ts.map +0 -1
  447. package/dist/types/createType/index.d.ts.map +0 -1
  448. package/dist/types/handleUnlikedContentDeclarationFile.d.ts +0 -3
  449. package/dist/types/handleUnlikedContentDeclarationFile.d.ts.map +0 -1
  450. package/dist/types/index.d.ts.map +0 -1
  451. package/dist/types/loadDictionaries/index.d.ts.map +0 -1
  452. package/dist/types/mergeDictionaries.d.ts +0 -3
  453. package/dist/types/mergeDictionaries.d.ts.map +0 -1
  454. package/dist/types/orderDictionaries.d.ts +0 -10
  455. package/dist/types/orderDictionaries.d.ts.map +0 -1
  456. package/dist/types/prepareContentDeclaration.d.ts +0 -3
  457. package/dist/types/prepareContentDeclaration.d.ts.map +0 -1
  458. package/dist/types/processPerLocaleDictionary.d.ts +0 -32
  459. package/dist/types/processPerLocaleDictionary.d.ts.map +0 -1
  460. package/dist/types/utils/getExtention.d.ts +0 -3
  461. package/dist/types/utils/getExtention.d.ts.map +0 -1
  462. package/dist/types/writeContentDeclaration/formatCode.d.ts +0 -2
  463. package/dist/types/writeContentDeclaration/formatCode.d.ts.map +0 -1
  464. package/dist/types/writeContentDeclaration/index.d.ts.map +0 -1
@@ -1,116 +1,117 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ const require_utils_getFormatFromExtension = require('../utils/getFormatFromExtension.cjs');
3
+ const require_writeContentDeclaration_processContentDeclarationContent = require('./processContentDeclarationContent.cjs');
4
+ const require_writeContentDeclaration_writeJSFile = require('./writeJSFile.cjs');
5
+ let node_path = require("node:path");
6
+ node_path = require_rolldown_runtime.__toESM(node_path);
7
+ let __intlayer_core = require("@intlayer/core");
8
+ __intlayer_core = require_rolldown_runtime.__toESM(__intlayer_core);
9
+ let __intlayer_unmerged_dictionaries_entry = require("@intlayer/unmerged-dictionaries-entry");
10
+ __intlayer_unmerged_dictionaries_entry = require_rolldown_runtime.__toESM(__intlayer_unmerged_dictionaries_entry);
11
+ let node_fs_promises = require("node:fs/promises");
12
+ node_fs_promises = require_rolldown_runtime.__toESM(node_fs_promises);
13
+ let deep_equal = require("deep-equal");
14
+ deep_equal = require_rolldown_runtime.__toESM(deep_equal);
15
+
16
+ //#region src/writeContentDeclaration/writeContentDeclaration.ts
17
+ const formatContentDeclaration = async (dictionary, configuration, localeList) => {
18
+ /**
19
+ * Clean Markdown, Insertion, File, etc. node metadata
20
+ */
21
+ const processedDictionary = await require_writeContentDeclaration_processContentDeclarationContent.processContentDeclarationContent(dictionary);
22
+ let content = processedDictionary.content;
23
+ /**
24
+ * Filter locales content
25
+ */
26
+ if (dictionary.locale) content = (0, __intlayer_core.getPerLocaleDictionary)(processedDictionary, dictionary.locale).content;
27
+ else if (localeList) content = (0, __intlayer_core.getFilteredLocalesDictionary)(processedDictionary, localeList).content;
28
+ let pluginFormatResult = {
29
+ ...dictionary,
30
+ content
31
+ };
32
+ /**
33
+ * Format the dictionary with the plugins
34
+ */
35
+ for await (const plugin of configuration.plugins ?? []) if (plugin.formatOutput) {
36
+ const formattedResult = await plugin.formatOutput?.({
37
+ dictionary: pluginFormatResult,
38
+ configuration
39
+ });
40
+ if (formattedResult) pluginFormatResult = formattedResult;
41
+ }
42
+ if (!(pluginFormatResult.content && pluginFormatResult.key)) return pluginFormatResult;
43
+ let result = {
44
+ key: dictionary.key,
45
+ content,
46
+ locale: dictionary.locale,
47
+ fill: dictionary.fill,
48
+ filled: dictionary.filled,
49
+ tags: dictionary.tags,
50
+ title: dictionary.title,
51
+ description: dictionary.description,
52
+ priority: dictionary.priority
53
+ };
54
+ if (require_utils_getFormatFromExtension.getFormatFromExtension(dictionary.filePath ? (0, node_path.extname)(dictionary.filePath) : ".json") === "json" && pluginFormatResult.content && pluginFormatResult.key) result = {
55
+ $schema: "https://intlayer.org/schema.json",
56
+ ...result
57
+ };
58
+ return result;
11
59
  };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
60
+ const defaultOptions = { newDictionariesPath: "intlayer-dictionaries" };
61
+ const writeContentDeclaration = async (dictionary, configuration, options) => {
62
+ const { content } = configuration;
63
+ const { baseDir } = content;
64
+ const { newDictionariesPath, localeList } = {
65
+ ...defaultOptions,
66
+ ...options
67
+ };
68
+ const newDictionaryLocationPath = (0, node_path.join)(baseDir, newDictionariesPath);
69
+ const existingDictionary = (0, __intlayer_unmerged_dictionaries_entry.getUnmergedDictionaries)(configuration)[dictionary.key]?.find((el) => el.localId === dictionary.localId);
70
+ const formattedContentDeclaration = await formatContentDeclaration(dictionary, configuration, localeList);
71
+ if (existingDictionary?.filePath) {
72
+ const isSameContent = (0, deep_equal.default)(existingDictionary.content, dictionary.content);
73
+ const filePath = (0, node_path.resolve)(configuration.content.baseDir, existingDictionary.filePath);
74
+ if (isSameContent) return {
75
+ status: "up-to-date",
76
+ path: filePath
77
+ };
78
+ await writeFileWithDirectories(filePath, formattedContentDeclaration, configuration);
79
+ return {
80
+ status: "updated",
81
+ path: filePath
82
+ };
83
+ }
84
+ if (dictionary.filePath) {
85
+ const filePath = (0, node_path.resolve)(configuration.content.baseDir, dictionary.filePath);
86
+ await writeFileWithDirectories(filePath, formattedContentDeclaration, configuration);
87
+ return {
88
+ status: "created",
89
+ path: filePath
90
+ };
91
+ }
92
+ const contentDeclarationPath = (0, node_path.join)(newDictionaryLocationPath, `${dictionary.key}.content.json`);
93
+ await writeFileWithDirectories(contentDeclarationPath, formattedContentDeclaration, configuration);
94
+ return {
95
+ status: "imported",
96
+ path: contentDeclarationPath
97
+ };
19
98
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var writeContentDeclaration_exports = {};
30
- __export(writeContentDeclaration_exports, {
31
- writeContentDeclaration: () => writeContentDeclaration
32
- });
33
- module.exports = __toCommonJS(writeContentDeclaration_exports);
34
- var import_config = require("@intlayer/config");
35
- var import_unmerged_dictionaries_entry = require("@intlayer/unmerged-dictionaries-entry");
36
- var import_deep_equal = __toESM(require("deep-equal"));
37
- var import_promises = require("fs/promises");
38
- var import_path = require("path");
39
- var import_prepareContentDeclaration = require('../prepareContentDeclaration.cjs');
40
- var import_writeJSFile = require('./writeJSFile.cjs');
41
- const DEFAULT_NEW_DICTIONARY_PATH = "intlayer-dictionaries";
42
- const formatContentDeclaration = async (dictionary) => {
43
- const preparedContentDeclaration = await (0, import_prepareContentDeclaration.prepareContentDeclaration)(dictionary);
44
- const { filePath, $schema, ...dictionaryWithoutPath } = preparedContentDeclaration;
45
- const formattedContentDeclaration = {
46
- $schema: "https://intlayer.org/schema.json",
47
- ...dictionaryWithoutPath
48
- };
49
- return formattedContentDeclaration;
99
+ const writeFileWithDirectories = async (absoluteFilePath, dictionary, configuration) => {
100
+ await (0, node_fs_promises.mkdir)((0, node_path.dirname)(absoluteFilePath), { recursive: true });
101
+ const extension = (0, node_path.extname)(absoluteFilePath);
102
+ if (!configuration.content.fileExtensions.map((extension$1) => (0, node_path.extname)(extension$1)).includes(extension)) throw new Error(`Invalid file extension: ${extension}, file: ${absoluteFilePath}`);
103
+ if (extension === ".json") {
104
+ await (0, node_fs_promises.writeFile)(absoluteFilePath, `${JSON.stringify(dictionary, null, 2)}\n`);
105
+ return;
106
+ }
107
+ await require_writeContentDeclaration_writeJSFile.writeJSFile(absoluteFilePath, dictionary, configuration);
108
+ try {
109
+ await (0, node_fs_promises.rm)(configuration.content.cacheDir, { recursive: true });
110
+ } catch (error) {
111
+ if (error && typeof error === "object" && "code" in error && error.code !== "ENOENT") throw error;
112
+ }
50
113
  };
51
- const writeContentDeclaration = async (dictionary, config = (0, import_config.getConfiguration)(), newDictionariesPath) => {
52
- const { content } = config;
53
- const { baseDir } = content;
54
- const newDictionaryRelativeLocationPath = newDictionariesPath ?? DEFAULT_NEW_DICTIONARY_PATH;
55
- const newDictionaryLocationPath = (0, import_path.join)(
56
- baseDir,
57
- newDictionaryRelativeLocationPath
58
- );
59
- const unmergedDictionariesRecord = (0, import_unmerged_dictionaries_entry.getUnmergedDictionaries)(config);
60
- const unmergedDictionaries = unmergedDictionariesRecord[dictionary.key];
61
- const existingDictionary = unmergedDictionaries.filter(
62
- (el) => el.localId === dictionary.localId
63
- );
64
- const formattedContentDeclaration = await formatContentDeclaration(dictionary);
65
- if (existingDictionary && dictionary.filePath) {
66
- const filePath = (0, import_path.join)(config.content.baseDir, dictionary.filePath);
67
- const isSameFile = (0, import_deep_equal.default)(existingDictionary, dictionary);
68
- if (isSameFile) {
69
- return {
70
- status: "up-to-date",
71
- path: filePath
72
- };
73
- }
74
- await writeFileWithDirectories(
75
- filePath,
76
- formattedContentDeclaration,
77
- config
78
- );
79
- return { status: "updated", path: filePath };
80
- }
81
- const contentDeclarationPath = (0, import_path.join)(
82
- newDictionaryLocationPath,
83
- `${dictionary.key}.content.json`
84
- );
85
- await writeFileWithDirectories(
86
- contentDeclarationPath,
87
- formattedContentDeclaration,
88
- config
89
- );
90
- return {
91
- status: "imported",
92
- path: contentDeclarationPath
93
- };
94
- };
95
- const writeFileWithDirectories = async (filePath, data, configuration) => {
96
- const dir = (0, import_path.dirname)(filePath);
97
- await (0, import_promises.mkdir)(dir, { recursive: true });
98
- const extension = (0, import_path.extname)(filePath);
99
- const acceptedExtensions = configuration.content.fileExtensions.map(
100
- (extension2) => (0, import_path.extname)(extension2)
101
- );
102
- if (!acceptedExtensions.includes(extension)) {
103
- throw new Error(`Invalid file extension: ${extension}, file: ${filePath}`);
104
- }
105
- if (extension === ".json") {
106
- const jsonDictionary = JSON.stringify(data, null, 2);
107
- await (0, import_promises.writeFile)(filePath, jsonDictionary);
108
- return;
109
- }
110
- await (0, import_writeJSFile.writeJSFile)(filePath, data, configuration);
111
- };
112
- // Annotate the CommonJS export names for ESM import in node:
113
- 0 && (module.exports = {
114
- writeContentDeclaration
115
- });
114
+
115
+ //#endregion
116
+ exports.writeContentDeclaration = writeContentDeclaration;
116
117
  //# sourceMappingURL=writeContentDeclaration.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/writeContentDeclaration/writeContentDeclaration.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config';\nimport { type IntlayerConfig } from '@intlayer/config/client';\nimport type { Dictionary } from '@intlayer/core';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\nimport deepEqual from 'deep-equal';\nimport { mkdir, writeFile } from 'fs/promises';\nimport { dirname, extname, join } from 'path';\nimport { prepareContentDeclaration } from '../prepareContentDeclaration';\nimport type { DictionaryStatus } from './dictionaryStatus';\nimport { writeJSFile } from './writeJSFile';\n\nconst DEFAULT_NEW_DICTIONARY_PATH = 'intlayer-dictionaries';\n\nconst formatContentDeclaration = async (dictionary: Dictionary) => {\n // Clean Markdown, Insertion, File, etc. node metadata\n const preparedContentDeclaration =\n await prepareContentDeclaration(dictionary);\n\n // Remove the filePath from the dictionary and set $schema\n const { filePath, $schema, ...dictionaryWithoutPath } =\n preparedContentDeclaration;\n\n const formattedContentDeclaration = {\n $schema: 'https://intlayer.org/schema.json',\n ...dictionaryWithoutPath,\n };\n\n return formattedContentDeclaration;\n};\n\nexport const writeContentDeclaration = async (\n dictionary: Dictionary,\n config: IntlayerConfig = getConfiguration(),\n newDictionariesPath?: string\n): Promise<{ status: DictionaryStatus; path: string }> => {\n const { content } = config;\n const { baseDir } = content;\n\n const newDictionaryRelativeLocationPath =\n newDictionariesPath ?? DEFAULT_NEW_DICTIONARY_PATH;\n const newDictionaryLocationPath = join(\n baseDir,\n newDictionaryRelativeLocationPath\n );\n\n const unmergedDictionariesRecord = getUnmergedDictionaries(config);\n const unmergedDictionaries = unmergedDictionariesRecord[\n dictionary.key\n ] as Dictionary[];\n\n const existingDictionary = unmergedDictionaries.filter(\n (el) => el.localId === dictionary.localId\n );\n\n const formattedContentDeclaration =\n await formatContentDeclaration(dictionary);\n\n if (existingDictionary && dictionary.filePath) {\n const filePath = join(config.content.baseDir, dictionary.filePath);\n\n // Compare existing dictionary with distant dictionary\n const isSameFile = deepEqual(existingDictionary, dictionary);\n\n // Up to date, nothing to do\n if (isSameFile) {\n return {\n status: 'up-to-date',\n path: filePath,\n };\n }\n\n await writeFileWithDirectories(\n filePath,\n formattedContentDeclaration,\n config\n );\n\n return { status: 'updated', path: filePath };\n }\n\n // No existing dictionary, write to new location\n const contentDeclarationPath = join(\n newDictionaryLocationPath,\n `${dictionary.key}.content.json`\n );\n\n await writeFileWithDirectories(\n contentDeclarationPath,\n formattedContentDeclaration,\n config\n );\n\n return {\n status: 'imported',\n path: contentDeclarationPath,\n };\n};\n\nconst writeFileWithDirectories = async (\n filePath: string,\n data: string | Buffer,\n configuration: IntlayerConfig\n): Promise<void> => {\n // Extract the directory from the file path\n const dir = dirname(filePath);\n\n // Create the directory recursively\n await mkdir(dir, { recursive: true });\n\n const extension = extname(filePath);\n const acceptedExtensions = configuration.content.fileExtensions.map(\n (extension) => extname(extension)\n );\n\n if (!acceptedExtensions.includes(extension)) {\n throw new Error(`Invalid file extension: ${extension}, file: ${filePath}`);\n }\n\n if (extension === '.json') {\n const jsonDictionary = JSON.stringify(data, null, 2);\n\n // Write the file\n await writeFile(filePath, jsonDictionary);\n\n return;\n }\n\n await writeJSFile(filePath, data as unknown as Dictionary, configuration);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAiC;AAGjC,yCAAwC;AACxC,wBAAsB;AACtB,sBAAiC;AACjC,kBAAuC;AACvC,uCAA0C;AAE1C,yBAA4B;AAE5B,MAAM,8BAA8B;AAEpC,MAAM,2BAA2B,OAAO,eAA2B;AAEjE,QAAM,6BACJ,UAAM,4DAA0B,UAAU;AAG5C,QAAM,EAAE,UAAU,SAAS,GAAG,sBAAsB,IAClD;AAEF,QAAM,8BAA8B;AAAA,IAClC,SAAS;AAAA,IACT,GAAG;AAAA,EACL;AAEA,SAAO;AACT;AAEO,MAAM,0BAA0B,OACrC,YACA,aAAyB,gCAAiB,GAC1C,wBACwD;AACxD,QAAM,EAAE,QAAQ,IAAI;AACpB,QAAM,EAAE,QAAQ,IAAI;AAEpB,QAAM,oCACJ,uBAAuB;AACzB,QAAM,gCAA4B;AAAA,IAChC;AAAA,IACA;AAAA,EACF;AAEA,QAAM,iCAA6B,4DAAwB,MAAM;AACjE,QAAM,uBAAuB,2BAC3B,WAAW,GACb;AAEA,QAAM,qBAAqB,qBAAqB;AAAA,IAC9C,CAAC,OAAO,GAAG,YAAY,WAAW;AAAA,EACpC;AAEA,QAAM,8BACJ,MAAM,yBAAyB,UAAU;AAE3C,MAAI,sBAAsB,WAAW,UAAU;AAC7C,UAAM,eAAW,kBAAK,OAAO,QAAQ,SAAS,WAAW,QAAQ;AAGjE,UAAM,iBAAa,kBAAAA,SAAU,oBAAoB,UAAU;AAG3D,QAAI,YAAY;AACd,aAAO;AAAA,QACL,QAAQ;AAAA,QACR,MAAM;AAAA,MACR;AAAA,IACF;AAEA,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAEA,WAAO,EAAE,QAAQ,WAAW,MAAM,SAAS;AAAA,EAC7C;AAGA,QAAM,6BAAyB;AAAA,IAC7B;AAAA,IACA,GAAG,WAAW,GAAG;AAAA,EACnB;AAEA,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,SAAO;AAAA,IACL,QAAQ;AAAA,IACR,MAAM;AAAA,EACR;AACF;AAEA,MAAM,2BAA2B,OAC/B,UACA,MACA,kBACkB;AAElB,QAAM,UAAM,qBAAQ,QAAQ;AAG5B,YAAM,uBAAM,KAAK,EAAE,WAAW,KAAK,CAAC;AAEpC,QAAM,gBAAY,qBAAQ,QAAQ;AAClC,QAAM,qBAAqB,cAAc,QAAQ,eAAe;AAAA,IAC9D,CAACC,mBAAc,qBAAQA,UAAS;AAAA,EAClC;AAEA,MAAI,CAAC,mBAAmB,SAAS,SAAS,GAAG;AAC3C,UAAM,IAAI,MAAM,2BAA2B,SAAS,WAAW,QAAQ,EAAE;AAAA,EAC3E;AAEA,MAAI,cAAc,SAAS;AACzB,UAAM,iBAAiB,KAAK,UAAU,MAAM,MAAM,CAAC;AAGnD,cAAM,2BAAU,UAAU,cAAc;AAExC;AAAA,EACF;AAEA,YAAM,gCAAY,UAAU,MAA+B,aAAa;AAC1E;","names":["deepEqual","extension"]}
1
+ {"version":3,"file":"writeContentDeclaration.cjs","names":["processContentDeclarationContent","pluginFormatResult: any","result: Dictionary","getFormatFromExtension","extension","writeJSFile"],"sources":["../../../src/writeContentDeclaration/writeContentDeclaration.ts"],"sourcesContent":["import { mkdir, rm, writeFile } from 'node:fs/promises';\nimport { dirname, extname, join, resolve } from 'node:path';\nimport {\n getFilteredLocalesDictionary,\n getPerLocaleDictionary,\n} from '@intlayer/core';\nimport type {\n Dictionary,\n IntlayerConfig,\n Locale,\n LocalesValues,\n} from '@intlayer/types';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\nimport deepEqual from 'deep-equal';\nimport {\n type Extension,\n getFormatFromExtension,\n} from '../utils/getFormatFromExtension';\nimport type { DictionaryStatus } from './dictionaryStatus';\nimport { processContentDeclarationContent } from './processContentDeclarationContent';\nimport { writeJSFile } from './writeJSFile';\n\nconst formatContentDeclaration = async (\n dictionary: Dictionary,\n configuration: IntlayerConfig,\n localeList?: LocalesValues[]\n) => {\n /**\n * Clean Markdown, Insertion, File, etc. node metadata\n */\n const processedDictionary =\n await processContentDeclarationContent(dictionary);\n\n let content = processedDictionary.content;\n\n /**\n * Filter locales content\n */\n\n if (dictionary.locale) {\n content = getPerLocaleDictionary(\n processedDictionary,\n dictionary.locale\n ).content;\n } else if (localeList) {\n content = getFilteredLocalesDictionary(\n processedDictionary,\n localeList\n ).content;\n }\n\n let pluginFormatResult: any = {\n ...dictionary,\n content,\n } satisfies Dictionary;\n\n /**\n * Format the dictionary with the plugins\n */\n\n for await (const plugin of configuration.plugins ?? []) {\n if (plugin.formatOutput) {\n const formattedResult = await plugin.formatOutput?.({\n dictionary: pluginFormatResult,\n configuration,\n });\n\n if (formattedResult) {\n pluginFormatResult = formattedResult;\n }\n }\n }\n\n const isDictionaryFormat =\n pluginFormatResult.content && pluginFormatResult.key;\n\n if (!isDictionaryFormat) return pluginFormatResult;\n\n let result: Dictionary = {\n key: dictionary.key,\n content,\n locale: dictionary.locale,\n fill: dictionary.fill,\n filled: dictionary.filled,\n tags: dictionary.tags,\n title: dictionary.title,\n description: dictionary.description,\n priority: dictionary.priority,\n };\n\n /**\n * Add $schema to the dictionary\n */\n const extension = (\n dictionary.filePath ? extname(dictionary.filePath) : '.json'\n ) as Extension;\n const format = getFormatFromExtension(extension);\n\n if (\n format === 'json' &&\n pluginFormatResult.content &&\n pluginFormatResult.key\n ) {\n result = {\n $schema: 'https://intlayer.org/schema.json',\n ...result,\n };\n }\n\n return result;\n};\n\ntype WriteContentDeclarationOptions = {\n newDictionariesPath?: string;\n localeList?: LocalesValues[];\n fallbackLocale?: Locale;\n};\n\nconst defaultOptions = {\n newDictionariesPath: 'intlayer-dictionaries',\n} satisfies WriteContentDeclarationOptions;\n\nexport const writeContentDeclaration = async (\n dictionary: Dictionary,\n configuration: IntlayerConfig,\n options?: WriteContentDeclarationOptions\n): Promise<{ status: DictionaryStatus; path: string }> => {\n const { content } = configuration;\n const { baseDir } = content;\n const { newDictionariesPath, localeList } = {\n ...defaultOptions,\n ...options,\n };\n\n const newDictionaryLocationPath = join(baseDir, newDictionariesPath);\n\n const unmergedDictionariesRecord = getUnmergedDictionaries(configuration);\n const unmergedDictionaries = unmergedDictionariesRecord[\n dictionary.key\n ] as Dictionary[];\n\n const existingDictionary = unmergedDictionaries?.find(\n (el) => el.localId === dictionary.localId\n );\n\n const formattedContentDeclaration = await formatContentDeclaration(\n dictionary,\n configuration,\n localeList\n );\n\n if (existingDictionary?.filePath) {\n // Compare existing dictionary content with new dictionary content\n const isSameContent = deepEqual(\n existingDictionary.content,\n dictionary.content\n );\n\n const filePath = resolve(\n configuration.content.baseDir,\n existingDictionary.filePath\n );\n\n // Up to date, nothing to do\n if (isSameContent) {\n return {\n status: 'up-to-date',\n path: filePath,\n };\n }\n\n await writeFileWithDirectories(\n filePath,\n formattedContentDeclaration,\n configuration\n );\n\n return { status: 'updated', path: filePath };\n }\n\n if (dictionary.filePath) {\n const filePath = resolve(\n configuration.content.baseDir,\n dictionary.filePath\n );\n await writeFileWithDirectories(\n filePath,\n formattedContentDeclaration,\n configuration\n );\n\n return { status: 'created', path: filePath };\n }\n\n // No existing dictionary, write to new location\n const contentDeclarationPath = join(\n newDictionaryLocationPath,\n `${dictionary.key}.content.json`\n );\n\n await writeFileWithDirectories(\n contentDeclarationPath,\n formattedContentDeclaration,\n configuration\n );\n\n return {\n status: 'imported',\n path: contentDeclarationPath,\n };\n};\n\nconst writeFileWithDirectories = async (\n absoluteFilePath: string,\n dictionary: Dictionary,\n configuration: IntlayerConfig\n): Promise<void> => {\n // Extract the directory from the file path\n const dir = dirname(absoluteFilePath);\n\n // Create the directory recursively\n await mkdir(dir, { recursive: true });\n\n const extension = extname(absoluteFilePath);\n const acceptedExtensions = configuration.content.fileExtensions.map(\n (extension) => extname(extension)\n );\n\n if (!acceptedExtensions.includes(extension)) {\n throw new Error(\n `Invalid file extension: ${extension}, file: ${absoluteFilePath}`\n );\n }\n\n if (extension === '.json') {\n const jsonDictionary = JSON.stringify(dictionary, null, 2);\n\n // Write the file\n await writeFile(absoluteFilePath, `${jsonDictionary}\\n`); // Add a new line at the end of the file to avoid formatting issues with VSCode\n\n return;\n }\n\n await writeJSFile(absoluteFilePath, dictionary, configuration);\n\n // remove the cache as content has changed\n // Will force a new preparation of the intlayer on next build\n try {\n await rm(configuration.content.cacheDir, { recursive: true });\n } catch (error) {\n if (\n error &&\n typeof error === 'object' &&\n 'code' in error &&\n (error as { code: string }).code !== 'ENOENT'\n ) {\n throw error;\n }\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAsBA,MAAM,2BAA2B,OAC/B,YACA,eACA,eACG;;;;CAIH,MAAM,sBACJ,MAAMA,kGAAiC,WAAW;CAEpD,IAAI,UAAU,oBAAoB;;;;AAMlC,KAAI,WAAW,OACb,uDACE,qBACA,WAAW,OACZ,CAAC;UACO,WACT,6DACE,qBACA,WACD,CAAC;CAGJ,IAAIC,qBAA0B;EAC5B,GAAG;EACH;EACD;;;;AAMD,YAAW,MAAM,UAAU,cAAc,WAAW,EAAE,CACpD,KAAI,OAAO,cAAc;EACvB,MAAM,kBAAkB,MAAM,OAAO,eAAe;GAClD,YAAY;GACZ;GACD,CAAC;AAEF,MAAI,gBACF,sBAAqB;;AAQ3B,KAAI,EAFF,mBAAmB,WAAW,mBAAmB,KAE1B,QAAO;CAEhC,IAAIC,SAAqB;EACvB,KAAK,WAAW;EAChB;EACA,QAAQ,WAAW;EACnB,MAAM,WAAW;EACjB,QAAQ,WAAW;EACnB,MAAM,WAAW;EACjB,OAAO,WAAW;EAClB,aAAa,WAAW;EACxB,UAAU,WAAW;EACtB;AAUD,KAFeC,4DAFb,WAAW,kCAAmB,WAAW,SAAS,GAAG,QAEP,KAGnC,UACX,mBAAmB,WACnB,mBAAmB,IAEnB,UAAS;EACP,SAAS;EACT,GAAG;EACJ;AAGH,QAAO;;AAST,MAAM,iBAAiB,EACrB,qBAAqB,yBACtB;AAED,MAAa,0BAA0B,OACrC,YACA,eACA,YACwD;CACxD,MAAM,EAAE,YAAY;CACpB,MAAM,EAAE,YAAY;CACpB,MAAM,EAAE,qBAAqB,eAAe;EAC1C,GAAG;EACH,GAAG;EACJ;CAED,MAAM,gDAAiC,SAAS,oBAAoB;CAOpE,MAAM,yFALqD,cAAc,CAEvE,WAAW,MAGoC,MAC9C,OAAO,GAAG,YAAY,WAAW,QACnC;CAED,MAAM,8BAA8B,MAAM,yBACxC,YACA,eACA,WACD;AAED,KAAI,oBAAoB,UAAU;EAEhC,MAAM,wCACJ,mBAAmB,SACnB,WAAW,QACZ;EAED,MAAM,kCACJ,cAAc,QAAQ,SACtB,mBAAmB,SACpB;AAGD,MAAI,cACF,QAAO;GACL,QAAQ;GACR,MAAM;GACP;AAGH,QAAM,yBACJ,UACA,6BACA,cACD;AAED,SAAO;GAAE,QAAQ;GAAW,MAAM;GAAU;;AAG9C,KAAI,WAAW,UAAU;EACvB,MAAM,kCACJ,cAAc,QAAQ,SACtB,WAAW,SACZ;AACD,QAAM,yBACJ,UACA,6BACA,cACD;AAED,SAAO;GAAE,QAAQ;GAAW,MAAM;GAAU;;CAI9C,MAAM,6CACJ,2BACA,GAAG,WAAW,IAAI,eACnB;AAED,OAAM,yBACJ,wBACA,6BACA,cACD;AAED,QAAO;EACL,QAAQ;EACR,MAAM;EACP;;AAGH,MAAM,2BAA2B,OAC/B,kBACA,YACA,kBACkB;AAKlB,0DAHoB,iBAAiB,EAGpB,EAAE,WAAW,MAAM,CAAC;CAErC,MAAM,mCAAoB,iBAAiB;AAK3C,KAAI,CAJuB,cAAc,QAAQ,eAAe,KAC7D,uCAAsBC,YAAU,CAClC,CAEuB,SAAS,UAAU,CACzC,OAAM,IAAI,MACR,2BAA2B,UAAU,UAAU,mBAChD;AAGH,KAAI,cAAc,SAAS;AAIzB,wCAAgB,kBAAkB,GAHX,KAAK,UAAU,YAAY,MAAM,EAAE,CAGN,IAAI;AAExD;;AAGF,OAAMC,wDAAY,kBAAkB,YAAY,cAAc;AAI9D,KAAI;AACF,iCAAS,cAAc,QAAQ,UAAU,EAAE,WAAW,MAAM,CAAC;UACtD,OAAO;AACd,MACE,SACA,OAAO,UAAU,YACjB,UAAU,SACT,MAA2B,SAAS,SAErC,OAAM"}
@@ -1,68 +1,58 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ const require_getContentDeclarationFileTemplate_getContentDeclarationFileTemplate = require('../getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs');
3
+ const require_utils_getFormatFromExtension = require('../utils/getFormatFromExtension.cjs');
4
+ const require_writeContentDeclaration_transformJSFile = require('./transformJSFile.cjs');
5
+ let node_fs = require("node:fs");
6
+ node_fs = require_rolldown_runtime.__toESM(node_fs);
7
+ let __intlayer_config = require("@intlayer/config");
8
+ __intlayer_config = require_rolldown_runtime.__toESM(__intlayer_config);
9
+ let node_path = require("node:path");
10
+ node_path = require_rolldown_runtime.__toESM(node_path);
11
+ let node_fs_promises = require("node:fs/promises");
12
+ node_fs_promises = require_rolldown_runtime.__toESM(node_fs_promises);
13
+ let node_child_process = require("node:child_process");
14
+ node_child_process = require_rolldown_runtime.__toESM(node_child_process);
15
+
16
+ //#region src/writeContentDeclaration/writeJSFile.ts
17
+ /**
18
+ * Updates a JavaScript/TypeScript file based on the provided JSON instructions.
19
+ * It targets a specific dictionary object within the file (identified by its 'key' property)
20
+ * and updates its 'content' entries. Currently, it focuses on modifying arguments
21
+ * of 't' (translation) function calls.
22
+ */
23
+ const writeJSFile = async (filePath, dictionary, configuration) => {
24
+ const { key, locale, filled } = dictionary;
25
+ const appLogger = (0, __intlayer_config.getAppLogger)(configuration);
26
+ if (!(0, node_fs.existsSync)(filePath)) {
27
+ const format = require_utils_getFormatFromExtension.getFormatFromExtension((0, node_path.extname)(filePath));
28
+ appLogger("File does not exist, creating it", { isVerbose: true });
29
+ await (0, node_fs_promises.writeFile)(filePath, await require_getContentDeclarationFileTemplate_getContentDeclarationFileTemplate.getContentDeclarationFileTemplate(key, format, {
30
+ locale,
31
+ filled
32
+ }), "utf-8");
33
+ }
34
+ const finalCode = await require_writeContentDeclaration_transformJSFile.transformJSFile(await (0, node_fs_promises.readFile)(filePath, "utf-8"), dictionary);
35
+ try {
36
+ await (0, node_fs_promises.writeFile)(filePath, finalCode, "utf-8");
37
+ (0, __intlayer_config.logger)(`Successfully updated ${filePath}`, {
38
+ level: "info",
39
+ isVerbose: true
40
+ });
41
+ } catch (error) {
42
+ const err = error;
43
+ (0, __intlayer_config.logger)(`Failed to write updated file: ${filePath}`, { level: "error" });
44
+ throw new Error(`Failed to write updated file ${filePath}: ${err.message}`);
45
+ }
46
+ if (configuration.editor.formatCommand) try {
47
+ (0, node_child_process.execSync)(configuration.editor.formatCommand.replace("{{file}}", filePath), {
48
+ stdio: "inherit",
49
+ cwd: configuration.content.baseDir
50
+ });
51
+ } catch (error) {
52
+ console.error(error);
53
+ }
9
54
  };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var writeJSFile_exports = {};
20
- __export(writeJSFile_exports, {
21
- writeJSFile: () => writeJSFile
22
- });
23
- module.exports = __toCommonJS(writeJSFile_exports);
24
- var import_config = require("@intlayer/config");
25
- var import_fs = require("fs");
26
- var import_promises = require("fs/promises");
27
- var import_path = require("path");
28
- var import_getContentDeclarationFileTemplate = require('../getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs');
29
- var import_getFormatFromExtension = require('../utils/getFormatFromExtension.cjs');
30
- var import_formatCode = require('./formatCode.cjs');
31
- var import_transformJSFile = require('./transformJSFile.cjs');
32
- const writeJSFile = async (filePath, dictionary, configuration = (0, import_config.getConfiguration)()) => {
33
- const { key, locale, autoFilled } = dictionary;
34
- const appLogger = (0, import_config.getAppLogger)(configuration);
35
- if (!(0, import_fs.existsSync)(filePath)) {
36
- const fileExtension = (0, import_path.extname)(filePath);
37
- let format = (0, import_getFormatFromExtension.getFormatFromExtension)(fileExtension);
38
- appLogger("File does not exist, creating it", {
39
- isVerbose: true
40
- });
41
- const template = await (0, import_getContentDeclarationFileTemplate.getContentDeclarationFileTemplate)(key, format, {
42
- locale,
43
- autoFilled
44
- });
45
- await (0, import_promises.writeFile)(filePath, template, "utf-8");
46
- }
47
- const fileContent = await (0, import_promises.readFile)(filePath, "utf-8");
48
- const finalCode = await (0, import_transformJSFile.transformJSFile)(fileContent, dictionary);
49
- const formattedCode = await (0, import_formatCode.formatCode)(filePath, finalCode);
50
- try {
51
- await (0, import_promises.writeFile)(filePath, formattedCode, "utf-8");
52
- (0, import_config.logger)(`Successfully updated ${filePath}`, {
53
- level: "info",
54
- isVerbose: true
55
- });
56
- } catch (error) {
57
- const err = error;
58
- (0, import_config.logger)(`Failed to write updated file: ${filePath}`, {
59
- level: "error"
60
- });
61
- throw new Error(`Failed to write updated file ${filePath}: ${err.message}`);
62
- }
63
- };
64
- // Annotate the CommonJS export names for ESM import in node:
65
- 0 && (module.exports = {
66
- writeJSFile
67
- });
55
+
56
+ //#endregion
57
+ exports.writeJSFile = writeJSFile;
68
58
  //# sourceMappingURL=writeJSFile.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/writeContentDeclaration/writeJSFile.ts"],"sourcesContent":["import {\n getAppLogger,\n getConfiguration,\n IntlayerConfig,\n logger,\n} from '@intlayer/config';\nimport { Dictionary } from '@intlayer/core';\nimport { existsSync } from 'fs';\nimport { readFile, writeFile } from 'fs/promises';\nimport { extname } from 'path';\nimport { getContentDeclarationFileTemplate } from '../getContentDeclarationFileTemplate/getContentDeclarationFileTemplate';\nimport {\n Extension,\n getFormatFromExtension,\n} from '../utils/getFormatFromExtension';\nimport { formatCode } from './formatCode';\nimport { transformJSFile } from './transformJSFile';\n\n/**\n * Updates a JavaScript/TypeScript file based on the provided JSON instructions.\n * It targets a specific dictionary object within the file (identified by its 'key' property)\n * and updates its 'content' entries. Currently, it focuses on modifying arguments\n * of 't' (translation) function calls.\n */\nexport const writeJSFile = async (\n filePath: string,\n dictionary: Dictionary,\n configuration: IntlayerConfig = getConfiguration()\n): Promise<void> => {\n const { key, locale, autoFilled } = dictionary;\n const appLogger = getAppLogger(configuration);\n\n // Check if the file exist\n if (!existsSync(filePath)) {\n const fileExtension = extname(filePath) as Extension;\n\n let format = getFormatFromExtension(fileExtension);\n\n appLogger('File does not exist, creating it', {\n isVerbose: true,\n });\n const template = await getContentDeclarationFileTemplate(key, format, {\n locale,\n autoFilled,\n });\n\n await writeFile(filePath, template, 'utf-8');\n }\n\n const fileContent = await readFile(filePath, 'utf-8');\n\n const finalCode = await transformJSFile(fileContent, dictionary);\n\n const formattedCode = await formatCode(filePath, finalCode);\n\n // Write the modified code back to the file\n try {\n await writeFile(filePath, formattedCode, 'utf-8');\n logger(`Successfully updated ${filePath}`, {\n level: 'info',\n isVerbose: true,\n });\n } catch (error) {\n const err = error as Error;\n logger(`Failed to write updated file: ${filePath}`, {\n level: 'error',\n });\n throw new Error(`Failed to write updated file ${filePath}: ${err.message}`);\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAKO;AAEP,gBAA2B;AAC3B,sBAAoC;AACpC,kBAAwB;AACxB,+CAAkD;AAClD,oCAGO;AACP,wBAA2B;AAC3B,6BAAgC;AAQzB,MAAM,cAAc,OACzB,UACA,YACA,oBAAgC,gCAAiB,MAC/B;AAClB,QAAM,EAAE,KAAK,QAAQ,WAAW,IAAI;AACpC,QAAM,gBAAY,4BAAa,aAAa;AAG5C,MAAI,KAAC,sBAAW,QAAQ,GAAG;AACzB,UAAM,oBAAgB,qBAAQ,QAAQ;AAEtC,QAAI,aAAS,sDAAuB,aAAa;AAEjD,cAAU,oCAAoC;AAAA,MAC5C,WAAW;AAAA,IACb,CAAC;AACD,UAAM,WAAW,UAAM,4EAAkC,KAAK,QAAQ;AAAA,MACpE;AAAA,MACA;AAAA,IACF,CAAC;AAED,cAAM,2BAAU,UAAU,UAAU,OAAO;AAAA,EAC7C;AAEA,QAAM,cAAc,UAAM,0BAAS,UAAU,OAAO;AAEpD,QAAM,YAAY,UAAM,wCAAgB,aAAa,UAAU;AAE/D,QAAM,gBAAgB,UAAM,8BAAW,UAAU,SAAS;AAG1D,MAAI;AACF,cAAM,2BAAU,UAAU,eAAe,OAAO;AAChD,8BAAO,wBAAwB,QAAQ,IAAI;AAAA,MACzC,OAAO;AAAA,MACP,WAAW;AAAA,IACb,CAAC;AAAA,EACH,SAAS,OAAO;AACd,UAAM,MAAM;AACZ,8BAAO,iCAAiC,QAAQ,IAAI;AAAA,MAClD,OAAO;AAAA,IACT,CAAC;AACD,UAAM,IAAI,MAAM,gCAAgC,QAAQ,KAAK,IAAI,OAAO,EAAE;AAAA,EAC5E;AACF;","names":[]}
1
+ {"version":3,"file":"writeJSFile.cjs","names":["getFormatFromExtension","getContentDeclarationFileTemplate","transformJSFile"],"sources":["../../../src/writeContentDeclaration/writeJSFile.ts"],"sourcesContent":["import { execSync } from 'node:child_process';\nimport { existsSync } from 'node:fs';\nimport { readFile, writeFile } from 'node:fs/promises';\nimport { extname } from 'node:path';\nimport { getAppLogger, logger } from '@intlayer/config';\nimport type { Dictionary, IntlayerConfig } from '@intlayer/types';\nimport { getContentDeclarationFileTemplate } from '../getContentDeclarationFileTemplate/getContentDeclarationFileTemplate';\nimport {\n type Extension,\n getFormatFromExtension,\n} from '../utils/getFormatFromExtension';\nimport { transformJSFile } from './transformJSFile';\n\n/**\n * Updates a JavaScript/TypeScript file based on the provided JSON instructions.\n * It targets a specific dictionary object within the file (identified by its 'key' property)\n * and updates its 'content' entries. Currently, it focuses on modifying arguments\n * of 't' (translation) function calls.\n */\nexport const writeJSFile = async (\n filePath: string,\n dictionary: Dictionary,\n configuration: IntlayerConfig\n): Promise<void> => {\n const { key, locale, filled } = dictionary;\n const appLogger = getAppLogger(configuration);\n\n // Check if the file exist\n if (!existsSync(filePath)) {\n const fileExtension = extname(filePath) as Extension;\n\n const format = getFormatFromExtension(fileExtension);\n\n appLogger('File does not exist, creating it', {\n isVerbose: true,\n });\n const template = await getContentDeclarationFileTemplate(key, format, {\n locale,\n filled,\n });\n\n await writeFile(filePath, template, 'utf-8');\n }\n\n const fileContent = await readFile(filePath, 'utf-8');\n\n const finalCode = await transformJSFile(fileContent, dictionary);\n\n // Write the modified code back to the file\n try {\n await writeFile(filePath, finalCode, 'utf-8');\n logger(`Successfully updated ${filePath}`, {\n level: 'info',\n isVerbose: true,\n });\n } catch (error) {\n const err = error as Error;\n logger(`Failed to write updated file: ${filePath}`, {\n level: 'error',\n });\n throw new Error(`Failed to write updated file ${filePath}: ${err.message}`);\n }\n\n if (configuration.editor.formatCommand) {\n try {\n execSync(\n configuration.editor.formatCommand.replace('{{file}}', filePath),\n {\n stdio: 'inherit',\n cwd: configuration.content.baseDir,\n }\n );\n } catch (error) {\n console.error(error);\n }\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAmBA,MAAa,cAAc,OACzB,UACA,YACA,kBACkB;CAClB,MAAM,EAAE,KAAK,QAAQ,WAAW;CAChC,MAAM,gDAAyB,cAAc;AAG7C,KAAI,yBAAY,SAAS,EAAE;EAGzB,MAAM,SAASA,mFAFe,SAAS,CAEa;AAEpD,YAAU,oCAAoC,EAC5C,WAAW,MACZ,CAAC;AAMF,wCAAgB,UALC,MAAMC,8GAAkC,KAAK,QAAQ;GACpE;GACA;GACD,CAAC,EAEkC,QAAQ;;CAK9C,MAAM,YAAY,MAAMC,gEAFJ,qCAAe,UAAU,QAAQ,EAEA,WAAW;AAGhE,KAAI;AACF,wCAAgB,UAAU,WAAW,QAAQ;AAC7C,gCAAO,wBAAwB,YAAY;GACzC,OAAO;GACP,WAAW;GACZ,CAAC;UACK,OAAO;EACd,MAAM,MAAM;AACZ,gCAAO,iCAAiC,YAAY,EAClD,OAAO,SACR,CAAC;AACF,QAAM,IAAI,MAAM,gCAAgC,SAAS,IAAI,IAAI,UAAU;;AAG7E,KAAI,cAAc,OAAO,cACvB,KAAI;AACF,mCACE,cAAc,OAAO,cAAc,QAAQ,YAAY,SAAS,EAChE;GACE,OAAO;GACP,KAAK,cAAc,QAAQ;GAC5B,CACF;UACM,OAAO;AACd,UAAQ,MAAM,MAAM"}
@@ -1,46 +1,13 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var writeFileIfChanged_exports = {};
20
- __export(writeFileIfChanged_exports, {
21
- writeFileIfChanged: () => writeFileIfChanged
22
- });
23
- module.exports = __toCommonJS(writeFileIfChanged_exports);
24
- var import_node_crypto = require("node:crypto");
25
- var import_node_fs = require("node:fs");
26
- var import_promises = require("node:fs/promises");
27
- const hashFile = async (path) => {
28
- const h = (0, import_node_crypto.createHash)("sha256");
29
- const rs = (0, import_node_fs.createReadStream)(path);
30
- rs.on("data", (chunk) => h.update(chunk));
31
- await new Promise((res, rej) => {
32
- rs.on("end", () => res());
33
- rs.on("error", rej);
34
- });
35
- return h.digest("hex");
36
- };
37
- const isReadableStream = (value) => !!value && typeof value === "object" && typeof value.pipe === "function";
1
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
+ let node_fs_promises = require("node:fs/promises");
3
+ node_fs_promises = require_rolldown_runtime.__toESM(node_fs_promises);
4
+
5
+ //#region src/writeFileIfChanged.ts
38
6
  const writeFileIfChanged = async (path, dataOrStream, { encoding = "utf8" } = {}) => {
39
- await (0, import_promises.writeFile)(path, dataOrStream, { encoding });
40
- return true;
7
+ await (0, node_fs_promises.writeFile)(path, dataOrStream, { encoding });
8
+ return true;
41
9
  };
42
- // Annotate the CommonJS export names for ESM import in node:
43
- 0 && (module.exports = {
44
- writeFileIfChanged
45
- });
10
+
11
+ //#endregion
12
+ exports.writeFileIfChanged = writeFileIfChanged;
46
13
  //# sourceMappingURL=writeFileIfChanged.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/writeFileIfChanged.ts"],"sourcesContent":["import { createHash } from 'node:crypto';\nimport { createReadStream } from 'node:fs';\nimport { writeFile } from 'node:fs/promises';\nimport { Readable } from 'node:stream';\n\nconst hashFile = async (path: string) => {\n const h = createHash('sha256');\n const rs = createReadStream(path);\n rs.on('data', (chunk) => h.update(chunk));\n await new Promise<void>((res, rej) => {\n rs.on('end', () => res());\n rs.on('error', rej);\n });\n return h.digest('hex');\n};\n\nconst isReadableStream = (value: unknown): value is Readable =>\n !!value &&\n typeof value === 'object' &&\n typeof (value as any).pipe === 'function';\n\nexport const writeFileIfChanged = async (\n path: string,\n dataOrStream: string,\n { encoding = 'utf8' }: { encoding?: BufferEncoding } = {}\n): Promise<boolean> => {\n // Disabled because it's too slow. Build time increases from 3s to 7s.\n await writeFile(path, dataOrStream, { encoding });\n\n // 1) write new content to temporary file (stream-safe)\n // const tmp = `${path}.tmp`;\n\n // if (isReadableStream(dataOrStream)) {\n // await pipeline(dataOrStream, createWriteStream(tmp));\n // } else {\n // // dataOrStream = string | Buffer\n // const buf = Buffer.isBuffer(dataOrStream)\n // ? dataOrStream\n // : Buffer.from(dataOrStream, encoding);\n // await writeFile(tmp, buf);\n // }\n\n // 2) if old file exists, compare hashes (streaming)\n // let same = false;\n // try {\n // const [oldHash, newHash] = await Promise.all([\n // hashFile(path),\n // hashFile(tmp),\n // ]);\n // same = oldHash === newHash;\n // } catch {\n // // old file missing -> will replace\n // }\n\n // if (same) {\n // await rm(tmp);\n // return false; // no change\n // }\n\n // 3) atomic replacement\n // On Unix, rename is atomic. On Windows, if file exists, we can delete it first.\n // try {\n // await rename(tmp, path);\n // } catch {\n // try {\n // await rm(path);\n // } catch {}\n // await rename(tmp, path);\n // }\n\n return true; // changed\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAA2B;AAC3B,qBAAiC;AACjC,sBAA0B;AAG1B,MAAM,WAAW,OAAO,SAAiB;AACvC,QAAM,QAAI,+BAAW,QAAQ;AAC7B,QAAM,SAAK,iCAAiB,IAAI;AAChC,KAAG,GAAG,QAAQ,CAAC,UAAU,EAAE,OAAO,KAAK,CAAC;AACxC,QAAM,IAAI,QAAc,CAAC,KAAK,QAAQ;AACpC,OAAG,GAAG,OAAO,MAAM,IAAI,CAAC;AACxB,OAAG,GAAG,SAAS,GAAG;AAAA,EACpB,CAAC;AACD,SAAO,EAAE,OAAO,KAAK;AACvB;AAEA,MAAM,mBAAmB,CAAC,UACxB,CAAC,CAAC,SACF,OAAO,UAAU,YACjB,OAAQ,MAAc,SAAS;AAE1B,MAAM,qBAAqB,OAChC,MACA,cACA,EAAE,WAAW,OAAO,IAAmC,CAAC,MACnC;AAErB,YAAM,2BAAU,MAAM,cAAc,EAAE,SAAS,CAAC;AA2ChD,SAAO;AACT;","names":[]}
1
+ {"version":3,"file":"writeFileIfChanged.cjs","names":[],"sources":["../../src/writeFileIfChanged.ts"],"sourcesContent":["import { writeFile } from 'node:fs/promises';\n// import { createHash } from 'node:crypto';\n// import { createReadStream } from 'node:fs';\n// import type { Readable } from 'node:stream';\n\n// const hashFile = async (path: string) => {\n// const h = createHash('sha256');\n// const rs = createReadStream(path);\n// rs.on('data', (chunk) => h.update(chunk));\n// await new Promise<void>((res, rej) => {\n// rs.on('end', () => res());\n// rs.on('error', rej);\n// });\n// return h.digest('hex');\n// };\n\n// const isReadableStream = (value: unknown): value is Readable =>\n// !!value &&\n// typeof value === 'object' &&\n// typeof (value as any).pipe === 'function';\n\nexport const writeFileIfChanged = async (\n path: string,\n dataOrStream: string,\n { encoding = 'utf8' }: { encoding?: BufferEncoding } = {}\n): Promise<boolean> => {\n // Disabled because it's too slow. Build time increases from 3s to 7s.\n await writeFile(path, dataOrStream, { encoding });\n\n // 1) write new content to temporary file (stream-safe)\n // const tmp = `${path}.tmp`;\n\n // if (isReadableStream(dataOrStream)) {\n // await pipeline(dataOrStream, createWriteStream(tmp));\n // } else {\n // // dataOrStream = string | Buffer\n // const buf = Buffer.isBuffer(dataOrStream)\n // ? dataOrStream\n // : Buffer.from(dataOrStream, encoding);\n // await writeFile(tmp, buf);\n // }\n\n // 2) if old file exists, compare hashes (streaming)\n // let same = false;\n // try {\n // const [oldHash, newHash] = await Promise.all([\n // hashFile(path),\n // hashFile(tmp),\n // ]);\n // same = oldHash === newHash;\n // } catch {\n // // old file missing -> will replace\n // }\n\n // if (same) {\n // await rm(tmp);\n // return false; // no change\n // }\n\n // 3) atomic replacement\n // On Unix, rename is atomic. On Windows, if file exists, we can delete it first.\n // try {\n // await rename(tmp, path);\n // } catch {\n // try {\n // await rm(path);\n // } catch {}\n // await rename(tmp, path);\n // }\n\n return true; // changed\n};\n"],"mappings":";;;;;AAqBA,MAAa,qBAAqB,OAChC,MACA,cACA,EAAE,WAAW,WAA0C,EAAE,KACpC;AAErB,uCAAgB,MAAM,cAAc,EAAE,UAAU,CAAC;AA2CjD,QAAO"}
@@ -1,34 +1,17 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var writeJsonIfChanged_exports = {};
20
- __export(writeJsonIfChanged_exports, {
21
- writeJsonIfChanged: () => writeJsonIfChanged
22
- });
23
- module.exports = __toCommonJS(writeJsonIfChanged_exports);
24
- var import_writeFileIfChanged = require('./writeFileIfChanged.cjs');
1
+ const require_writeFileIfChanged = require('./writeFileIfChanged.cjs');
2
+
3
+ //#region src/writeJsonIfChanged.ts
25
4
  const writeJsonIfChanged = async (path, data, { pretty = process.env.NODE_ENV === "development" } = {}) => {
26
- const space = pretty ? 2 : void 0;
27
- const json = JSON.stringify(data, null, space);
28
- return await (0, import_writeFileIfChanged.writeFileIfChanged)(path, json);
5
+ const space = pretty ? 2 : void 0;
6
+ let json = "{}";
7
+ try {
8
+ json = JSON.stringify(data, null, space);
9
+ } catch (error) {
10
+ console.error(`Error while parsing data to JSON for ${path}:`, error);
11
+ }
12
+ return await require_writeFileIfChanged.writeFileIfChanged(path, json);
29
13
  };
30
- // Annotate the CommonJS export names for ESM import in node:
31
- 0 && (module.exports = {
32
- writeJsonIfChanged
33
- });
14
+
15
+ //#endregion
16
+ exports.writeJsonIfChanged = writeJsonIfChanged;
34
17
  //# sourceMappingURL=writeJsonIfChanged.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/writeJsonIfChanged.ts"],"sourcesContent":["import { writeFileIfChanged } from './writeFileIfChanged';\n\nexport const writeJsonIfChanged = async <T>(\n path: string,\n data: T,\n { pretty = process.env.NODE_ENV === 'development' } = {}\n): Promise<boolean> => {\n const space = pretty ? 2 : undefined;\n const json = JSON.stringify(data, null, space);\n\n return await writeFileIfChanged(path, json);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gCAAmC;AAE5B,MAAM,qBAAqB,OAChC,MACA,MACA,EAAE,SAAS,QAAQ,IAAI,aAAa,cAAc,IAAI,CAAC,MAClC;AACrB,QAAM,QAAQ,SAAS,IAAI;AAC3B,QAAM,OAAO,KAAK,UAAU,MAAM,MAAM,KAAK;AAE7C,SAAO,UAAM,8CAAmB,MAAM,IAAI;AAC5C;","names":[]}
1
+ {"version":3,"file":"writeJsonIfChanged.cjs","names":["writeFileIfChanged"],"sources":["../../src/writeJsonIfChanged.ts"],"sourcesContent":["import { writeFileIfChanged } from './writeFileIfChanged';\n\nexport const writeJsonIfChanged = async <T>(\n path: string,\n data: T,\n { pretty = process.env.NODE_ENV === 'development' } = {}\n): Promise<boolean> => {\n const space = pretty ? 2 : undefined;\n\n let json = '{}';\n\n try {\n json = JSON.stringify(data, null, space);\n } catch (error) {\n console.error(`Error while parsing data to JSON for ${path}:`, error);\n }\n\n return await writeFileIfChanged(path, json);\n};\n"],"mappings":";;;AAEA,MAAa,qBAAqB,OAChC,MACA,MACA,EAAE,SAAS,QAAQ,IAAI,aAAa,kBAAkB,EAAE,KACnC;CACrB,MAAM,QAAQ,SAAS,IAAI;CAE3B,IAAI,OAAO;AAEX,KAAI;AACF,SAAO,KAAK,UAAU,MAAM,MAAM,MAAM;UACjC,OAAO;AACd,UAAQ,MAAM,wCAAwC,KAAK,IAAI,MAAM;;AAGvE,QAAO,MAAMA,8CAAmB,MAAM,KAAK"}