@intlayer/chokidar 8.1.2 → 8.1.3

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 (396) hide show
  1. package/dist/assets/installSkills/skills/angular.md +3 -0
  2. package/dist/assets/installSkills/skills/astro.md +3 -0
  3. package/dist/assets/installSkills/skills/cli.md +7 -4
  4. package/dist/assets/installSkills/skills/config.md +3 -0
  5. package/dist/assets/installSkills/skills/content.md +3 -0
  6. package/dist/assets/installSkills/skills/next_js.md +3 -0
  7. package/dist/assets/installSkills/skills/preact.md +3 -2
  8. package/dist/assets/installSkills/skills/react.md +3 -0
  9. package/dist/assets/installSkills/skills/solid.md +3 -0
  10. package/dist/assets/installSkills/skills/svelte.md +3 -0
  11. package/dist/assets/installSkills/skills/usage.md +2 -0
  12. package/dist/assets/installSkills/skills/vue.md +3 -0
  13. package/dist/cjs/_virtual/_rolldown/runtime.cjs +1 -29
  14. package/dist/cjs/_virtual/_utils_asset.cjs +2 -98
  15. package/dist/cjs/build.cjs +1 -51
  16. package/dist/cjs/buildIntlayerDictionary/buildIntlayerDictionary.cjs +1 -53
  17. package/dist/cjs/buildIntlayerDictionary/buildIntlayerDictionary.cjs.map +1 -1
  18. package/dist/cjs/buildIntlayerDictionary/index.cjs +1 -6
  19. package/dist/cjs/buildIntlayerDictionary/processContentDeclaration.cjs +1 -26
  20. package/dist/cjs/buildIntlayerDictionary/processContentDeclaration.cjs.map +1 -1
  21. package/dist/cjs/buildIntlayerDictionary/writeDynamicDictionary.cjs +4 -78
  22. package/dist/cjs/buildIntlayerDictionary/writeDynamicDictionary.cjs.map +1 -1
  23. package/dist/cjs/buildIntlayerDictionary/writeFetchDictionary.cjs +4 -62
  24. package/dist/cjs/buildIntlayerDictionary/writeFetchDictionary.cjs.map +1 -1
  25. package/dist/cjs/buildIntlayerDictionary/writeMergedDictionary.cjs +1 -46
  26. package/dist/cjs/buildIntlayerDictionary/writeMergedDictionary.cjs.map +1 -1
  27. package/dist/cjs/buildIntlayerDictionary/writeRemoteDictionary.cjs +1 -50
  28. package/dist/cjs/buildIntlayerDictionary/writeRemoteDictionary.cjs.map +1 -1
  29. package/dist/cjs/buildIntlayerDictionary/writeUnmergedDictionary.cjs +1 -59
  30. package/dist/cjs/buildIntlayerDictionary/writeUnmergedDictionary.cjs.map +1 -1
  31. package/dist/cjs/cleanOutputDir.cjs +1 -30
  32. package/dist/cjs/cleanOutputDir.cjs.map +1 -1
  33. package/dist/cjs/cleanRemovedContentDeclaration.cjs +1 -96
  34. package/dist/cjs/cleanRemovedContentDeclaration.cjs.map +1 -1
  35. package/dist/cjs/cli.cjs +1 -21
  36. package/dist/cjs/createDictionaryEntryPoint/createDictionaryEntryPoint.cjs +1 -70
  37. package/dist/cjs/createDictionaryEntryPoint/createDictionaryEntryPoint.cjs.map +1 -1
  38. package/dist/cjs/createDictionaryEntryPoint/generateDictionaryListContent.cjs +7 -41
  39. package/dist/cjs/createDictionaryEntryPoint/generateDictionaryListContent.cjs.map +1 -1
  40. package/dist/cjs/createDictionaryEntryPoint/getBuiltDictionariesPath.cjs +1 -23
  41. package/dist/cjs/createDictionaryEntryPoint/getBuiltDictionariesPath.cjs.map +1 -1
  42. package/dist/cjs/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.cjs +1 -24
  43. package/dist/cjs/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.cjs.map +1 -1
  44. package/dist/cjs/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.cjs +1 -24
  45. package/dist/cjs/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.cjs.map +1 -1
  46. package/dist/cjs/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.cjs +1 -23
  47. package/dist/cjs/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.cjs.map +1 -1
  48. package/dist/cjs/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.cjs +1 -23
  49. package/dist/cjs/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.cjs.map +1 -1
  50. package/dist/cjs/createDictionaryEntryPoint/index.cjs +1 -16
  51. package/dist/cjs/createType/createModuleAugmentation.cjs +9 -110
  52. package/dist/cjs/createType/createModuleAugmentation.cjs.map +1 -1
  53. package/dist/cjs/createType/createType.cjs +1 -29
  54. package/dist/cjs/createType/createType.cjs.map +1 -1
  55. package/dist/cjs/createType/index.cjs +1 -8
  56. package/dist/cjs/fetchDistantDictionaries.cjs +1 -50
  57. package/dist/cjs/fetchDistantDictionaries.cjs.map +1 -1
  58. package/dist/cjs/filterInvalidDictionaries.cjs +1 -49
  59. package/dist/cjs/filterInvalidDictionaries.cjs.map +1 -1
  60. package/dist/cjs/formatDictionary.cjs +1 -49
  61. package/dist/cjs/formatDictionary.cjs.map +1 -1
  62. package/dist/cjs/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs +1 -39
  63. package/dist/cjs/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs.map +1 -1
  64. package/dist/cjs/handleAdditionalContentDeclarationFile.cjs +1 -34
  65. package/dist/cjs/handleAdditionalContentDeclarationFile.cjs.map +1 -1
  66. package/dist/cjs/handleContentDeclarationFileChange.cjs +1 -49
  67. package/dist/cjs/handleContentDeclarationFileChange.cjs.map +1 -1
  68. package/dist/cjs/handleContentDeclarationFileMoved.cjs +1 -24
  69. package/dist/cjs/handleContentDeclarationFileMoved.cjs.map +1 -1
  70. package/dist/cjs/handleUnlinkedContentDeclarationFile.cjs +1 -37
  71. package/dist/cjs/handleUnlinkedContentDeclarationFile.cjs.map +1 -1
  72. package/dist/cjs/index.cjs +1 -131
  73. package/dist/cjs/init/index.cjs +1 -242
  74. package/dist/cjs/init/index.cjs.map +1 -1
  75. package/dist/cjs/init/utils/configManipulation.cjs +1 -164
  76. package/dist/cjs/init/utils/configManipulation.cjs.map +1 -1
  77. package/dist/cjs/init/utils/fileSystem.cjs +1 -30
  78. package/dist/cjs/init/utils/fileSystem.cjs.map +1 -1
  79. package/dist/cjs/init/utils/index.cjs +1 -13
  80. package/dist/cjs/init/utils/jsonParser.cjs +3 -42
  81. package/dist/cjs/init/utils/jsonParser.cjs.map +1 -1
  82. package/dist/cjs/init/utils/tsConfig.cjs +1 -18
  83. package/dist/cjs/init/utils/tsConfig.cjs.map +1 -1
  84. package/dist/cjs/initConfig/index.cjs +1 -38
  85. package/dist/cjs/initConfig/index.cjs.map +1 -1
  86. package/dist/cjs/installSkills/index.cjs +1 -172
  87. package/dist/cjs/installSkills/index.cjs.map +1 -1
  88. package/dist/cjs/listDictionariesPath.cjs +1 -41
  89. package/dist/cjs/listDictionariesPath.cjs.map +1 -1
  90. package/dist/cjs/listGitFiles.cjs +5 -95
  91. package/dist/cjs/listGitFiles.cjs.map +1 -1
  92. package/dist/cjs/listProjects.cjs +1 -47
  93. package/dist/cjs/listProjects.cjs.map +1 -1
  94. package/dist/cjs/loadDictionaries/getIntlayerBundle.cjs +1 -66
  95. package/dist/cjs/loadDictionaries/getIntlayerBundle.cjs.map +1 -1
  96. package/dist/cjs/loadDictionaries/index.cjs +1 -12
  97. package/dist/cjs/loadDictionaries/loadContentDeclaration.cjs +2 -72
  98. package/dist/cjs/loadDictionaries/loadContentDeclaration.cjs.map +1 -1
  99. package/dist/cjs/loadDictionaries/loadDictionaries.cjs +1 -125
  100. package/dist/cjs/loadDictionaries/loadDictionaries.cjs.map +1 -1
  101. package/dist/cjs/loadDictionaries/loadLocalDictionaries.cjs +1 -28
  102. package/dist/cjs/loadDictionaries/loadLocalDictionaries.cjs.map +1 -1
  103. package/dist/cjs/loadDictionaries/loadRemoteDictionaries.cjs +1 -61
  104. package/dist/cjs/loadDictionaries/loadRemoteDictionaries.cjs.map +1 -1
  105. package/dist/cjs/loadDictionaries/log.cjs +3 -135
  106. package/dist/cjs/loadDictionaries/log.cjs.map +1 -1
  107. package/dist/cjs/prepareIntlayer.cjs +1 -95
  108. package/dist/cjs/prepareIntlayer.cjs.map +1 -1
  109. package/dist/cjs/reduceDictionaryContent/applyMask.cjs +1 -30
  110. package/dist/cjs/reduceDictionaryContent/applyMask.cjs.map +1 -1
  111. package/dist/cjs/reduceDictionaryContent/reduceDictionaryContent.cjs +1 -12
  112. package/dist/cjs/reduceDictionaryContent/reduceDictionaryContent.cjs.map +1 -1
  113. package/dist/cjs/transformFiles/extractDictionaryKey.cjs +1 -16
  114. package/dist/cjs/transformFiles/extractDictionaryKey.cjs.map +1 -1
  115. package/dist/cjs/transformFiles/index.cjs +1 -10
  116. package/dist/cjs/transformFiles/transformFiles.cjs +1 -251
  117. package/dist/cjs/transformFiles/transformFiles.cjs.map +1 -1
  118. package/dist/cjs/utils/autoDecorateContent.cjs +1 -87
  119. package/dist/cjs/utils/autoDecorateContent.cjs.map +1 -1
  120. package/dist/cjs/utils/buildFilesList.cjs +1 -50
  121. package/dist/cjs/utils/buildFilesList.cjs.map +1 -1
  122. package/dist/cjs/utils/chunkJSON.cjs +1 -336
  123. package/dist/cjs/utils/chunkJSON.cjs.map +1 -1
  124. package/dist/cjs/utils/formatter.cjs +1 -16
  125. package/dist/cjs/utils/formatter.cjs.map +1 -1
  126. package/dist/cjs/utils/getChunk.cjs +1 -34
  127. package/dist/cjs/utils/getChunk.cjs.map +1 -1
  128. package/dist/cjs/utils/getComponentTransformPattern.cjs +1 -48
  129. package/dist/cjs/utils/getComponentTransformPattern.cjs.map +1 -1
  130. package/dist/cjs/utils/getFileHash.cjs +1 -12
  131. package/dist/cjs/utils/getFileHash.cjs.map +1 -1
  132. package/dist/cjs/utils/getFormatFromExtension.cjs +1 -31
  133. package/dist/cjs/utils/getFormatFromExtension.cjs.map +1 -1
  134. package/dist/cjs/utils/index.cjs +1 -46
  135. package/dist/cjs/utils/pLimit.cjs +1 -128
  136. package/dist/cjs/utils/pLimit.cjs.map +1 -1
  137. package/dist/cjs/utils/parallelize.cjs +1 -11
  138. package/dist/cjs/utils/parallelize.cjs.map +1 -1
  139. package/dist/cjs/utils/parallelizeGlobal.cjs +1 -29
  140. package/dist/cjs/utils/parallelizeGlobal.cjs.map +1 -1
  141. package/dist/cjs/utils/reduceObjectFormat.cjs +1 -31
  142. package/dist/cjs/utils/reduceObjectFormat.cjs.map +1 -1
  143. package/dist/cjs/utils/resolveObjectPromises.cjs +1 -21
  144. package/dist/cjs/utils/resolveObjectPromises.cjs.map +1 -1
  145. package/dist/cjs/utils/runOnce.cjs +1 -95
  146. package/dist/cjs/utils/runOnce.cjs.map +1 -1
  147. package/dist/cjs/utils/runParallel/bin.cjs +1 -54
  148. package/dist/cjs/utils/runParallel/bin.cjs.map +1 -1
  149. package/dist/cjs/utils/runParallel/bootstrap.cjs +1 -24
  150. package/dist/cjs/utils/runParallel/bootstrap.cjs.map +1 -1
  151. package/dist/cjs/utils/runParallel/index.cjs +1 -110
  152. package/dist/cjs/utils/runParallel/index.cjs.map +1 -1
  153. package/dist/cjs/utils/runParallel/pidTree.cjs +1 -145
  154. package/dist/cjs/utils/runParallel/pidTree.cjs.map +1 -1
  155. package/dist/cjs/utils/runParallel/ps.cjs +1 -49
  156. package/dist/cjs/utils/runParallel/ps.cjs.map +1 -1
  157. package/dist/cjs/utils/runParallel/runTask.cjs +1 -154
  158. package/dist/cjs/utils/runParallel/runTask.cjs.map +1 -1
  159. package/dist/cjs/utils/runParallel/spawnPosix.cjs +1 -59
  160. package/dist/cjs/utils/runParallel/spawnPosix.cjs.map +1 -1
  161. package/dist/cjs/utils/runParallel/spawnWin32.cjs +1 -43
  162. package/dist/cjs/utils/runParallel/spawnWin32.cjs.map +1 -1
  163. package/dist/cjs/utils/runParallel/wmic.cjs +1 -52
  164. package/dist/cjs/utils/runParallel/wmic.cjs.map +1 -1
  165. package/dist/cjs/utils/sortAlphabetically.cjs +1 -7
  166. package/dist/cjs/utils/sortAlphabetically.cjs.map +1 -1
  167. package/dist/cjs/utils/splitTextByLine.cjs +1 -11
  168. package/dist/cjs/utils/splitTextByLine.cjs.map +1 -1
  169. package/dist/cjs/utils/verifyIdenticObjectFormat.cjs +1 -60
  170. package/dist/cjs/utils/verifyIdenticObjectFormat.cjs.map +1 -1
  171. package/dist/cjs/watcher.cjs +1 -95
  172. package/dist/cjs/watcher.cjs.map +1 -1
  173. package/dist/cjs/writeConfiguration/index.cjs +1 -34
  174. package/dist/cjs/writeConfiguration/index.cjs.map +1 -1
  175. package/dist/cjs/writeContentDeclaration/detectExportedComponentName.cjs +1 -28
  176. package/dist/cjs/writeContentDeclaration/detectExportedComponentName.cjs.map +1 -1
  177. package/dist/cjs/writeContentDeclaration/detectFormatCommand.cjs +1 -31
  178. package/dist/cjs/writeContentDeclaration/detectFormatCommand.cjs.map +1 -1
  179. package/dist/cjs/writeContentDeclaration/index.cjs +1 -12
  180. package/dist/cjs/writeContentDeclaration/processContentDeclarationContent.cjs +1 -93
  181. package/dist/cjs/writeContentDeclaration/processContentDeclarationContent.cjs.map +1 -1
  182. package/dist/cjs/writeContentDeclaration/transformJSFile.cjs +2 -1775
  183. package/dist/cjs/writeContentDeclaration/transformJSFile.cjs.map +1 -1
  184. package/dist/cjs/writeContentDeclaration/transformJSONFile.cjs +1 -77
  185. package/dist/cjs/writeContentDeclaration/transformJSONFile.cjs.map +1 -1
  186. package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs +1 -123
  187. package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs.map +1 -1
  188. package/dist/cjs/writeContentDeclaration/writeJSFile.cjs +1 -71
  189. package/dist/cjs/writeContentDeclaration/writeJSFile.cjs.map +1 -1
  190. package/dist/cjs/writeFileIfChanged.cjs +1 -12
  191. package/dist/cjs/writeFileIfChanged.cjs.map +1 -1
  192. package/dist/cjs/writeJsonIfChanged.cjs +1 -17
  193. package/dist/cjs/writeJsonIfChanged.cjs.map +1 -1
  194. package/dist/esm/_virtual/_rolldown/runtime.mjs +1 -8
  195. package/dist/esm/_virtual/_utils_asset.mjs +2 -97
  196. package/dist/esm/build.mjs +1 -24
  197. package/dist/esm/buildIntlayerDictionary/buildIntlayerDictionary.mjs +1 -51
  198. package/dist/esm/buildIntlayerDictionary/buildIntlayerDictionary.mjs.map +1 -1
  199. package/dist/esm/buildIntlayerDictionary/index.mjs +1 -4
  200. package/dist/esm/buildIntlayerDictionary/processContentDeclaration.mjs +1 -24
  201. package/dist/esm/buildIntlayerDictionary/processContentDeclaration.mjs.map +1 -1
  202. package/dist/esm/buildIntlayerDictionary/writeDynamicDictionary.mjs +4 -75
  203. package/dist/esm/buildIntlayerDictionary/writeDynamicDictionary.mjs.map +1 -1
  204. package/dist/esm/buildIntlayerDictionary/writeFetchDictionary.mjs +4 -59
  205. package/dist/esm/buildIntlayerDictionary/writeFetchDictionary.mjs.map +1 -1
  206. package/dist/esm/buildIntlayerDictionary/writeMergedDictionary.mjs +1 -44
  207. package/dist/esm/buildIntlayerDictionary/writeMergedDictionary.mjs.map +1 -1
  208. package/dist/esm/buildIntlayerDictionary/writeRemoteDictionary.mjs +1 -48
  209. package/dist/esm/buildIntlayerDictionary/writeRemoteDictionary.mjs.map +1 -1
  210. package/dist/esm/buildIntlayerDictionary/writeUnmergedDictionary.mjs +1 -56
  211. package/dist/esm/buildIntlayerDictionary/writeUnmergedDictionary.mjs.map +1 -1
  212. package/dist/esm/cleanOutputDir.mjs +1 -28
  213. package/dist/esm/cleanOutputDir.mjs.map +1 -1
  214. package/dist/esm/cleanRemovedContentDeclaration.mjs +1 -93
  215. package/dist/esm/cleanRemovedContentDeclaration.mjs.map +1 -1
  216. package/dist/esm/cli.mjs +1 -8
  217. package/dist/esm/createDictionaryEntryPoint/createDictionaryEntryPoint.mjs +1 -68
  218. package/dist/esm/createDictionaryEntryPoint/createDictionaryEntryPoint.mjs.map +1 -1
  219. package/dist/esm/createDictionaryEntryPoint/generateDictionaryListContent.mjs +7 -39
  220. package/dist/esm/createDictionaryEntryPoint/generateDictionaryListContent.mjs.map +1 -1
  221. package/dist/esm/createDictionaryEntryPoint/getBuiltDictionariesPath.mjs +1 -20
  222. package/dist/esm/createDictionaryEntryPoint/getBuiltDictionariesPath.mjs.map +1 -1
  223. package/dist/esm/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.mjs +1 -21
  224. package/dist/esm/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.mjs.map +1 -1
  225. package/dist/esm/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.mjs +1 -21
  226. package/dist/esm/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.mjs.map +1 -1
  227. package/dist/esm/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.mjs +1 -20
  228. package/dist/esm/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.mjs.map +1 -1
  229. package/dist/esm/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.mjs +1 -20
  230. package/dist/esm/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.mjs.map +1 -1
  231. package/dist/esm/createDictionaryEntryPoint/index.mjs +1 -9
  232. package/dist/esm/createType/createModuleAugmentation.mjs +9 -106
  233. package/dist/esm/createType/createModuleAugmentation.mjs.map +1 -1
  234. package/dist/esm/createType/createType.mjs +1 -26
  235. package/dist/esm/createType/createType.mjs.map +1 -1
  236. package/dist/esm/createType/index.mjs +1 -4
  237. package/dist/esm/fetchDistantDictionaries.mjs +1 -48
  238. package/dist/esm/fetchDistantDictionaries.mjs.map +1 -1
  239. package/dist/esm/filterInvalidDictionaries.mjs +1 -46
  240. package/dist/esm/filterInvalidDictionaries.mjs.map +1 -1
  241. package/dist/esm/formatDictionary.mjs +1 -44
  242. package/dist/esm/formatDictionary.mjs.map +1 -1
  243. package/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs +1 -37
  244. package/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs.map +1 -1
  245. package/dist/esm/handleAdditionalContentDeclarationFile.mjs +1 -32
  246. package/dist/esm/handleAdditionalContentDeclarationFile.mjs.map +1 -1
  247. package/dist/esm/handleContentDeclarationFileChange.mjs +1 -47
  248. package/dist/esm/handleContentDeclarationFileChange.mjs.map +1 -1
  249. package/dist/esm/handleContentDeclarationFileMoved.mjs +1 -22
  250. package/dist/esm/handleContentDeclarationFileMoved.mjs.map +1 -1
  251. package/dist/esm/handleUnlinkedContentDeclarationFile.mjs +1 -35
  252. package/dist/esm/handleUnlinkedContentDeclarationFile.mjs.map +1 -1
  253. package/dist/esm/index.mjs +1 -57
  254. package/dist/esm/init/index.mjs +1 -240
  255. package/dist/esm/init/index.mjs.map +1 -1
  256. package/dist/esm/init/utils/configManipulation.mjs +1 -161
  257. package/dist/esm/init/utils/configManipulation.mjs.map +1 -1
  258. package/dist/esm/init/utils/fileSystem.mjs +1 -26
  259. package/dist/esm/init/utils/fileSystem.mjs.map +1 -1
  260. package/dist/esm/init/utils/index.mjs +1 -6
  261. package/dist/esm/init/utils/jsonParser.mjs +3 -40
  262. package/dist/esm/init/utils/jsonParser.mjs.map +1 -1
  263. package/dist/esm/init/utils/tsConfig.mjs +1 -16
  264. package/dist/esm/init/utils/tsConfig.mjs.map +1 -1
  265. package/dist/esm/initConfig/index.mjs +1 -36
  266. package/dist/esm/initConfig/index.mjs.map +1 -1
  267. package/dist/esm/installSkills/index.mjs +1 -167
  268. package/dist/esm/installSkills/index.mjs.map +1 -1
  269. package/dist/esm/listDictionariesPath.mjs +1 -37
  270. package/dist/esm/listDictionariesPath.mjs.map +1 -1
  271. package/dist/esm/listGitFiles.mjs +5 -90
  272. package/dist/esm/listGitFiles.mjs.map +1 -1
  273. package/dist/esm/listProjects.mjs +1 -43
  274. package/dist/esm/listProjects.mjs.map +1 -1
  275. package/dist/esm/loadDictionaries/getIntlayerBundle.mjs +1 -65
  276. package/dist/esm/loadDictionaries/getIntlayerBundle.mjs.map +1 -1
  277. package/dist/esm/loadDictionaries/index.mjs +1 -6
  278. package/dist/esm/loadDictionaries/loadContentDeclaration.mjs +2 -69
  279. package/dist/esm/loadDictionaries/loadContentDeclaration.mjs.map +1 -1
  280. package/dist/esm/loadDictionaries/loadDictionaries.mjs +1 -123
  281. package/dist/esm/loadDictionaries/loadDictionaries.mjs.map +1 -1
  282. package/dist/esm/loadDictionaries/loadLocalDictionaries.mjs +1 -26
  283. package/dist/esm/loadDictionaries/loadLocalDictionaries.mjs.map +1 -1
  284. package/dist/esm/loadDictionaries/loadRemoteDictionaries.mjs +1 -58
  285. package/dist/esm/loadDictionaries/loadRemoteDictionaries.mjs.map +1 -1
  286. package/dist/esm/loadDictionaries/log.mjs +3 -132
  287. package/dist/esm/loadDictionaries/log.mjs.map +1 -1
  288. package/dist/esm/prepareIntlayer.mjs +1 -92
  289. package/dist/esm/prepareIntlayer.mjs.map +1 -1
  290. package/dist/esm/reduceDictionaryContent/applyMask.mjs +1 -28
  291. package/dist/esm/reduceDictionaryContent/applyMask.mjs.map +1 -1
  292. package/dist/esm/reduceDictionaryContent/reduceDictionaryContent.mjs +1 -10
  293. package/dist/esm/reduceDictionaryContent/reduceDictionaryContent.mjs.map +1 -1
  294. package/dist/esm/transformFiles/extractDictionaryKey.mjs +1 -14
  295. package/dist/esm/transformFiles/extractDictionaryKey.mjs.map +1 -1
  296. package/dist/esm/transformFiles/index.mjs +1 -4
  297. package/dist/esm/transformFiles/transformFiles.mjs +1 -244
  298. package/dist/esm/transformFiles/transformFiles.mjs.map +1 -1
  299. package/dist/esm/utils/autoDecorateContent.mjs +1 -85
  300. package/dist/esm/utils/autoDecorateContent.mjs.map +1 -1
  301. package/dist/esm/utils/buildFilesList.mjs +1 -47
  302. package/dist/esm/utils/buildFilesList.mjs.map +1 -1
  303. package/dist/esm/utils/chunkJSON.mjs +1 -333
  304. package/dist/esm/utils/chunkJSON.mjs.map +1 -1
  305. package/dist/esm/utils/formatter.mjs +1 -12
  306. package/dist/esm/utils/formatter.mjs.map +1 -1
  307. package/dist/esm/utils/getChunk.mjs +1 -33
  308. package/dist/esm/utils/getChunk.mjs.map +1 -1
  309. package/dist/esm/utils/getComponentTransformPattern.mjs +1 -44
  310. package/dist/esm/utils/getComponentTransformPattern.mjs.map +1 -1
  311. package/dist/esm/utils/getFileHash.mjs +1 -9
  312. package/dist/esm/utils/getFileHash.mjs.map +1 -1
  313. package/dist/esm/utils/getFormatFromExtension.mjs +1 -28
  314. package/dist/esm/utils/getFormatFromExtension.mjs.map +1 -1
  315. package/dist/esm/utils/index.mjs +1 -20
  316. package/dist/esm/utils/pLimit.mjs +1 -125
  317. package/dist/esm/utils/pLimit.mjs.map +1 -1
  318. package/dist/esm/utils/parallelize.mjs +1 -10
  319. package/dist/esm/utils/parallelize.mjs.map +1 -1
  320. package/dist/esm/utils/parallelizeGlobal.mjs +1 -26
  321. package/dist/esm/utils/parallelizeGlobal.mjs.map +1 -1
  322. package/dist/esm/utils/reduceObjectFormat.mjs +1 -29
  323. package/dist/esm/utils/reduceObjectFormat.mjs.map +1 -1
  324. package/dist/esm/utils/resolveObjectPromises.mjs +1 -19
  325. package/dist/esm/utils/resolveObjectPromises.mjs.map +1 -1
  326. package/dist/esm/utils/runOnce.mjs +1 -92
  327. package/dist/esm/utils/runOnce.mjs.map +1 -1
  328. package/dist/esm/utils/runParallel/bin.mjs +1 -52
  329. package/dist/esm/utils/runParallel/bin.mjs.map +1 -1
  330. package/dist/esm/utils/runParallel/bootstrap.mjs +1 -22
  331. package/dist/esm/utils/runParallel/bootstrap.mjs.map +1 -1
  332. package/dist/esm/utils/runParallel/index.mjs +1 -108
  333. package/dist/esm/utils/runParallel/index.mjs.map +1 -1
  334. package/dist/esm/utils/runParallel/pidTree.mjs +1 -142
  335. package/dist/esm/utils/runParallel/pidTree.mjs.map +1 -1
  336. package/dist/esm/utils/runParallel/ps.mjs +1 -46
  337. package/dist/esm/utils/runParallel/ps.mjs.map +1 -1
  338. package/dist/esm/utils/runParallel/runTask.mjs +1 -152
  339. package/dist/esm/utils/runParallel/runTask.mjs.map +1 -1
  340. package/dist/esm/utils/runParallel/spawnPosix.mjs +1 -57
  341. package/dist/esm/utils/runParallel/spawnPosix.mjs.map +1 -1
  342. package/dist/esm/utils/runParallel/spawnWin32.mjs +1 -41
  343. package/dist/esm/utils/runParallel/spawnWin32.mjs.map +1 -1
  344. package/dist/esm/utils/runParallel/wmic.mjs +1 -49
  345. package/dist/esm/utils/runParallel/wmic.mjs.map +1 -1
  346. package/dist/esm/utils/sortAlphabetically.mjs +1 -5
  347. package/dist/esm/utils/sortAlphabetically.mjs.map +1 -1
  348. package/dist/esm/utils/splitTextByLine.mjs +1 -9
  349. package/dist/esm/utils/splitTextByLine.mjs.map +1 -1
  350. package/dist/esm/utils/verifyIdenticObjectFormat.mjs +1 -58
  351. package/dist/esm/utils/verifyIdenticObjectFormat.mjs.map +1 -1
  352. package/dist/esm/watcher.mjs +1 -92
  353. package/dist/esm/watcher.mjs.map +1 -1
  354. package/dist/esm/writeConfiguration/index.mjs +1 -31
  355. package/dist/esm/writeConfiguration/index.mjs.map +1 -1
  356. package/dist/esm/writeContentDeclaration/detectExportedComponentName.mjs +1 -26
  357. package/dist/esm/writeContentDeclaration/detectExportedComponentName.mjs.map +1 -1
  358. package/dist/esm/writeContentDeclaration/detectFormatCommand.mjs +1 -29
  359. package/dist/esm/writeContentDeclaration/detectFormatCommand.mjs.map +1 -1
  360. package/dist/esm/writeContentDeclaration/index.mjs +1 -7
  361. package/dist/esm/writeContentDeclaration/processContentDeclarationContent.mjs +1 -91
  362. package/dist/esm/writeContentDeclaration/processContentDeclarationContent.mjs.map +1 -1
  363. package/dist/esm/writeContentDeclaration/transformJSFile.mjs +2 -1773
  364. package/dist/esm/writeContentDeclaration/transformJSFile.mjs.map +1 -1
  365. package/dist/esm/writeContentDeclaration/transformJSONFile.mjs +1 -75
  366. package/dist/esm/writeContentDeclaration/transformJSONFile.mjs.map +1 -1
  367. package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs +1 -121
  368. package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs.map +1 -1
  369. package/dist/esm/writeContentDeclaration/writeJSFile.mjs +1 -69
  370. package/dist/esm/writeContentDeclaration/writeJSFile.mjs.map +1 -1
  371. package/dist/esm/writeFileIfChanged.mjs +1 -10
  372. package/dist/esm/writeFileIfChanged.mjs.map +1 -1
  373. package/dist/esm/writeJsonIfChanged.mjs +1 -16
  374. package/dist/esm/writeJsonIfChanged.mjs.map +1 -1
  375. package/dist/types/build.d.ts +3 -1
  376. package/dist/types/buildIntlayerDictionary/buildIntlayerDictionary.d.ts.map +1 -1
  377. package/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts.map +1 -1
  378. package/dist/types/buildIntlayerDictionary/writeFetchDictionary.d.ts.map +1 -1
  379. package/dist/types/buildIntlayerDictionary/writeMergedDictionary.d.ts.map +1 -1
  380. package/dist/types/buildIntlayerDictionary/writeRemoteDictionary.d.ts.map +1 -1
  381. package/dist/types/createDictionaryEntryPoint/generateDictionaryListContent.d.ts.map +1 -1
  382. package/dist/types/fetchDistantDictionaries.d.ts.map +1 -1
  383. package/dist/types/index.d.ts +16 -24
  384. package/dist/types/initConfig/index.d.ts +1 -1
  385. package/dist/types/initConfig/index.d.ts.map +1 -1
  386. package/dist/types/listGitFiles.d.ts.map +1 -1
  387. package/dist/types/loadDictionaries/getIntlayerBundle.d.ts.map +1 -1
  388. package/dist/types/loadDictionaries/loadContentDeclaration.d.ts.map +1 -1
  389. package/dist/types/prepareIntlayer.d.ts.map +1 -1
  390. package/dist/types/transformFiles/transformFiles.d.ts +1 -1
  391. package/dist/types/transformFiles/transformFiles.d.ts.map +1 -1
  392. package/dist/types/utils/formatter.d.ts +1 -1
  393. package/dist/types/watcher.d.ts +1 -1
  394. package/dist/types/writeContentDeclaration/processContentDeclarationContent.d.ts.map +1 -1
  395. package/dist/types/writeContentDeclaration/transformJSFile.d.ts.map +1 -1
  396. package/package.json +10 -15
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["ANSIColors","exists","x","readFileFromRoot","writeFileToRoot","v","findTsConfigFiles","parseJSONWithComments","initConfig","updateViteConfig","updateNextConfig"],"sources":["../../../src/init/index.ts"],"sourcesContent":["import {\n ANSIColors,\n colorize,\n colorizePath,\n getAlias,\n getConfiguration,\n logger,\n v,\n x,\n} from '@intlayer/config';\nimport { initConfig } from '../initConfig';\nimport {\n exists,\n findTsConfigFiles,\n parseJSONWithComments,\n readFileFromRoot,\n updateNextConfig,\n updateViteConfig,\n writeFileToRoot,\n} from './utils';\n\n/**\n * Documentation URL Constants\n */\nconst DocumentationRouter = {\n NextJS: 'https://intlayer.org/doc/environment/nextjs.md',\n NextJS_15: 'https://intlayer.org/doc/environment/nextjs/15.md',\n NextJS_14: 'https://intlayer.org/doc/environment/nextjs/14.md',\n CRA: 'https://intlayer.org/doc/environment/create-react-app.md',\n Astro: 'https://intlayer.org/doc/environment/astro.md',\n ViteAndReact: 'https://intlayer.org/doc/environment/vite-and-react.md',\n ViteAndReact_ReactRouterV7:\n 'https://intlayer.org/doc/environment/vite-and-react/react-router-v7.md',\n ViteAndReact_ReactRouterV7_FSRoutes:\n 'https://intlayer.org/doc/environment/vite-and-react/react-router-v7-fs-routes.md',\n ViteAndVue: 'https://intlayer.org/doc/environment/vite-and-vue.md',\n ViteAndSolid: 'https://intlayer.org/doc/environment/vite-and-solid.md',\n ViteAndSvelte: 'https://intlayer.org/doc/environment/vite-and-svelte.md',\n ViteAndPreact: 'https://intlayer.org/doc/environment/vite-and-preact.md',\n TanStackRouter: 'https://intlayer.org/doc/environment/tanstack.md',\n NuxtAndVue: 'https://intlayer.org/doc/environment/nuxt-and-vue.md',\n Angular: 'https://intlayer.org/doc/environment/angular.md',\n SvelteKit: 'https://intlayer.org/doc/environment/sveltekit.md',\n ReactNativeAndExpo:\n 'https://intlayer.org/doc/environment/react-native-and-expo.md',\n Lynx: 'https://intlayer.org/doc/environment/lynx-and-react.md',\n Express: 'https://intlayer.org/doc/environment/express.md',\n NestJS: 'https://intlayer.org/doc/environment/nestjs.md',\n Fastify: 'https://intlayer.org/doc/environment/fastify.md',\n Default: 'https://intlayer.org/doc/get-started',\n\n // Check for competitors libs\n NextIntl: 'https://intlayer.org/blog/intlayer-with-next-intl.md',\n ReactI18Next: 'https://intlayer.org/blog/intlayer-with-react-i18next.md',\n ReactIntl: 'https://intlayer.org/blog/intlayer-with-react-intl.md',\n NextI18Next: 'https://intlayer.org/blog/intlayer-with-next-i18next.md',\n VueI18n: 'https://intlayer.org/blog/intlayer-with-vue-i18n.md',\n};\n\n/**\n * Helper: Detects the environment and returns the doc URL\n */\nconst getDocumentationUrl = (packageJson: any): string => {\n const deps = {\n ...packageJson.dependencies,\n ...packageJson.devDependencies,\n };\n\n /**\n * Helper to check if a version string matches a specific major version\n * Matches: \"15\", \"^15.0.0\", \"~15.2\", \"15.0.0-beta\"\n */\n const isVersion = (versionString: string, major: number): boolean => {\n if (!versionString || typeof versionString !== 'string') return false;\n const regex = new RegExp(`^[\\\\^~]?${major}(?:\\\\.|$)`);\n return regex.test(versionString);\n };\n\n // Mobile / Cross-platform\n if (deps['@lynx-js/react'] || deps['@lynx-js/core']) {\n return DocumentationRouter.Lynx;\n }\n if (deps['react-native'] || deps['expo']) {\n return DocumentationRouter.ReactNativeAndExpo;\n }\n\n // Meta-frameworks (Next, Nuxt, Astro, SvelteKit)\n if (deps['next']) {\n const version = deps['next'];\n\n if (isVersion(version, 14)) {\n return DocumentationRouter.NextJS_14;\n }\n\n if (isVersion(version, 15)) {\n return DocumentationRouter.NextJS_15;\n }\n\n return DocumentationRouter.NextJS;\n }\n\n if (deps['nuxt']) return DocumentationRouter.NuxtAndVue;\n if (deps['astro']) return DocumentationRouter.Astro;\n if (deps['@sveltejs/kit']) return DocumentationRouter.SvelteKit;\n\n // Routers (TanStack & React Router v7)\n if (deps['@tanstack/react-router']) {\n return DocumentationRouter.TanStackRouter;\n }\n\n // Check for React Router v7\n const reactRouterVersion = deps['react-router'];\n if (reactRouterVersion && typeof reactRouterVersion === 'string') {\n // Distinguish between standard v7 and v7 with FS routes\n if (deps['@react-router/fs-routes']) {\n return DocumentationRouter.ViteAndReact_ReactRouterV7_FSRoutes;\n }\n\n // Use Regex to ensure it is v7\n if (isVersion(reactRouterVersion, 7)) {\n return DocumentationRouter.ViteAndReact_ReactRouterV7;\n }\n }\n\n // Vite Ecosystem (General)\n if (deps['vite']) {\n if (deps['vue']) return DocumentationRouter.ViteAndVue;\n if (deps['solid-js']) return DocumentationRouter.ViteAndSolid;\n if (deps['svelte']) return DocumentationRouter.ViteAndSvelte;\n if (deps['preact']) return DocumentationRouter.ViteAndPreact;\n\n // Default to React if Vite is present but specific other frameworks aren't found\n return DocumentationRouter.ViteAndReact;\n }\n\n // Other Web Frameworks\n if (deps['react-scripts']) return DocumentationRouter.CRA;\n if (deps['@angular/core']) return DocumentationRouter.Angular;\n\n // Backend\n if (deps['@nestjs/core']) return DocumentationRouter.NestJS;\n if (deps['express']) return DocumentationRouter.Express;\n if (deps['fastify']) return DocumentationRouter.Fastify;\n\n // Competitor Libs (Migration Guides)\n // We check these last as specific environment setup is usually higher priority,\n // but if no specific framework logic matched (or as a fallback), we guide to migration.\n if (deps['next-intl']) return DocumentationRouter.NextIntl;\n if (deps['react-i18next'] || deps['i18next'])\n return DocumentationRouter.ReactI18Next;\n if (deps['react-intl']) return DocumentationRouter.ReactIntl;\n if (deps['next-i18next']) return DocumentationRouter.NextI18Next;\n if (deps['vue-i18n']) return DocumentationRouter.VueI18n;\n\n return DocumentationRouter.Default;\n};\n\n/**\n * MAIN LOGIC\n */\nexport const initIntlayer = async (rootDir: string) => {\n logger(colorize('Checking Intlayer configuration...', ANSIColors.CYAN));\n\n // READ PACKAGE.JSON\n const packageJsonPath = 'package.json';\n if (!(await exists(rootDir, packageJsonPath))) {\n logger(\n `${x} No ${colorizePath('package.json')} found. Please run this script from the project root.`,\n { level: 'error' }\n );\n process.exit(1);\n }\n\n const packageJsonContent = await readFileFromRoot(rootDir, packageJsonPath);\n let packageJson: Record<string, any>;\n try {\n packageJson = JSON.parse(packageJsonContent);\n } catch {\n logger(`${x} Could not parse ${colorizePath('package.json')}.`, {\n level: 'error',\n });\n process.exit(1);\n }\n\n // Determine the correct documentation URL based on dependencies\n const guideUrl = getDocumentationUrl(packageJson);\n\n // 2. CHECK .GITIGNORE\n const gitignorePath = '.gitignore';\n if (await exists(rootDir, gitignorePath)) {\n const gitignoreContent = await readFileFromRoot(rootDir, gitignorePath);\n\n if (!gitignoreContent.includes('intlayer')) {\n const newContent = `${gitignoreContent}\\n# Intlayer\\n.intlayer\\n`;\n await writeFileToRoot(rootDir, gitignorePath, newContent);\n logger(\n `${v} Added ${colorizePath('.intlayer')} to ${colorizePath(gitignorePath)}`\n );\n } else {\n logger(`${v} ${colorizePath(gitignorePath)} already includes .intlayer`);\n }\n }\n\n // CHECK TSCONFIGS\n const tsConfigFiles = await findTsConfigFiles(rootDir);\n let hasTsConfig = false;\n\n for (const fileName of tsConfigFiles) {\n if (await exists(rootDir, fileName)) {\n hasTsConfig = true;\n try {\n const fileContent = await readFileFromRoot(rootDir, fileName);\n const config = parseJSONWithComments(fileContent);\n const typeDefinition = '.intlayer/**/*.ts';\n\n let updated = false;\n\n if (!config.include) {\n // Skip if no include array (solution-style)\n } else if (\n Array.isArray(config.include) &&\n !(config.include as string[]).some((pattern: string) =>\n pattern.includes('.intlayer')\n )\n ) {\n config.include.push(typeDefinition);\n updated = true;\n } else if (config.include.includes(typeDefinition)) {\n logger(\n `${v} ${colorizePath(fileName)} already includes intlayer types`\n );\n }\n\n if (updated) {\n await writeFileToRoot(\n rootDir,\n fileName,\n JSON.stringify(config, null, 2)\n );\n logger(\n `${v} Updated ${colorizePath(fileName)} to include intlayer types`\n );\n }\n } catch {\n logger(\n `${x} Could not parse or update ${colorizePath(fileName)}. You may need to add ${colorizePath('.intlayer/types/**/*.ts')} manually.`,\n { level: 'warn' }\n );\n }\n }\n }\n\n // INITIALIZE CONFIG FILE\n const format = hasTsConfig ? 'intlayer.config.ts' : 'intlayer.config.mjs';\n await initConfig(format, rootDir);\n\n let hasAliasConfiguration = false;\n\n // CHECK VITE CONFIG\n const viteConfigs = ['vite.config.ts', 'vite.config.js', 'vite.config.mjs'];\n for (const file of viteConfigs) {\n if (await exists(rootDir, file)) {\n hasAliasConfiguration = true;\n const content = await readFileFromRoot(rootDir, file);\n\n if (!content.includes('vite-intlayer')) {\n const extension = file.split('.').pop()!;\n const updatedContent = updateViteConfig(content, extension);\n await writeFileToRoot(rootDir, file, updatedContent);\n logger(`${v} Updated ${colorizePath(file)} to include Intlayer plugin`);\n }\n break;\n }\n }\n\n // CHECK NEXT CONFIG\n const nextConfigs = ['next.config.js', 'next.config.mjs', 'next.config.ts'];\n for (const file of nextConfigs) {\n if (await exists(rootDir, file)) {\n hasAliasConfiguration = true;\n const content = await readFileFromRoot(rootDir, file);\n\n if (!content.includes('next-intlayer')) {\n const extension = file.split('.').pop()!;\n const updatedContent = updateNextConfig(content, extension);\n await writeFileToRoot(rootDir, file, updatedContent);\n logger(`${v} Updated ${colorizePath(file)} to include Intlayer plugin`);\n }\n break;\n }\n }\n\n // CHECK WEBPACK CONFIG\n const webpackConfigs = [\n 'webpack.config.js',\n 'webpack.config.ts',\n 'webpack.config.mjs',\n 'webpack.config.cjs',\n ];\n for (const file of webpackConfigs) {\n if (await exists(rootDir, file)) {\n hasAliasConfiguration = true;\n logger(\n `${v} Found ${colorizePath(\n file\n )}. Make sure to configure aliases manually or use the Intlayer Webpack plugin.`\n );\n break;\n }\n }\n\n if (!hasAliasConfiguration) {\n const configuration = getConfiguration({ baseDir: rootDir });\n const aliases = getAlias({ configuration });\n\n if (hasTsConfig && tsConfigFiles.length > 0) {\n const tsConfigPath =\n tsConfigFiles.find((f) => f === 'tsconfig.json') || tsConfigFiles[0];\n const tsConfigContent = await readFileFromRoot(rootDir, tsConfigPath);\n const config = parseJSONWithComments(tsConfigContent);\n\n config.compilerOptions ??= {};\n config.compilerOptions.paths ??= {};\n\n let updated = false;\n\n Object.entries(aliases).forEach(([alias, path]) => {\n if (!config.compilerOptions.paths[alias]) {\n config.compilerOptions.paths[alias] = [path];\n updated = true;\n }\n });\n\n if (updated) {\n await writeFileToRoot(\n rootDir,\n tsConfigPath,\n JSON.stringify(config, null, 2)\n );\n logger(\n `${v} Updated ${colorizePath(\n tsConfigPath\n )} to include Intlayer aliases`\n );\n }\n } else {\n const jsConfigPath = 'jsconfig.json';\n if (await exists(rootDir, jsConfigPath)) {\n const jsConfigContent = await readFileFromRoot(rootDir, jsConfigPath);\n const config = parseJSONWithComments(jsConfigContent);\n\n config.compilerOptions ??= {};\n config.compilerOptions.paths ??= {};\n\n let updated = false;\n\n Object.entries(aliases).forEach(([alias, path]) => {\n if (!config.compilerOptions.paths[alias]) {\n config.compilerOptions.paths[alias] = [path];\n updated = true;\n }\n });\n\n if (updated) {\n await writeFileToRoot(\n rootDir,\n jsConfigPath,\n JSON.stringify(config, null, 2)\n );\n logger(\n `${v} Updated ${colorizePath(\n jsConfigPath\n )} to include Intlayer aliases`\n );\n }\n } else {\n packageJson.imports ??= {};\n\n let updated = false;\n\n Object.entries(aliases).forEach(([alias, path]) => {\n const importAlias = alias.replace('@', '#');\n const importPath = path.startsWith('.') ? path : `./${path}`;\n\n if (!packageJson.imports[importAlias]) {\n packageJson.imports[importAlias] = importPath;\n updated = true;\n }\n });\n\n if (updated) {\n await writeFileToRoot(\n rootDir,\n packageJsonPath,\n JSON.stringify(packageJson, null, 2)\n );\n logger(\n `${v} Updated ${colorizePath(\n packageJsonPath\n )} to include Intlayer imports`\n );\n }\n }\n }\n }\n\n // FINAL SUCCESS MESSAGE\n logger(`${v} ${colorize('Intlayer init setup complete.', ANSIColors.GREEN)}`);\n logger([\n colorize('Next →', ANSIColors.MAGENTA),\n colorize(\n `Follow the instructions in the documentation to complete the setup:`,\n ANSIColors.GREY_LIGHT\n ),\n colorizePath(guideUrl),\n ]);\n};\n"],"mappings":";;;;;;;;;;;;;AAwBA,MAAM,sBAAsB;CAC1B,QAAQ;CACR,WAAW;CACX,WAAW;CACX,KAAK;CACL,OAAO;CACP,cAAc;CACd,4BACE;CACF,qCACE;CACF,YAAY;CACZ,cAAc;CACd,eAAe;CACf,eAAe;CACf,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,aAAa,EAAE;IAEvC,MAAM,SAASM,oDADS,MAAMJ,+CAAiB,SAAS,aAAa,CAChB;AAErD,WAAO,oBAAoB,EAAE;AAC7B,WAAO,gBAAgB,UAAU,EAAE;IAEnC,IAAI,UAAU;AAEd,WAAO,QAAQ,QAAQ,CAAC,SAAS,CAAC,OAAO,UAAU;AACjD,SAAI,CAAC,OAAO,gBAAgB,MAAM,QAAQ;AACxC,aAAO,gBAAgB,MAAM,SAAS,CAAC,KAAK;AAC5C,gBAAU;;MAEZ;AAEF,QAAI,SAAS;AACX,WAAMC,8CACJ,SACA,cACA,KAAK,UAAU,QAAQ,MAAM,EAAE,CAChC;AACD,kCACE,GAAGC,mBAAE,8CACH,aACD,CAAC,8BACH;;UAEE;AACL,gBAAY,YAAY,EAAE;IAE1B,IAAI,UAAU;AAEd,WAAO,QAAQ,QAAQ,CAAC,SAAS,CAAC,OAAO,UAAU;KACjD,MAAM,cAAc,MAAM,QAAQ,KAAK,IAAI;KAC3C,MAAM,aAAa,KAAK,WAAW,IAAI,GAAG,OAAO,KAAK;AAEtD,SAAI,CAAC,YAAY,QAAQ,cAAc;AACrC,kBAAY,QAAQ,eAAe;AACnC,gBAAU;;MAEZ;AAEF,QAAI,SAAS;AACX,WAAMD,8CACJ,SACA,iBACA,KAAK,UAAU,aAAa,MAAM,EAAE,CACrC;AACD,kCACE,GAAGC,mBAAE,8CACH,gBACD,CAAC,8BACH;;;;;AAOT,8BAAO,GAAGA,mBAAE,kCAAY,iCAAiCL,4BAAW,MAAM,GAAG;AAC7E,8BAAO;iCACI,UAAUA,4BAAW,QAAQ;iCAEpC,uEACAA,4BAAW,WACZ;qCACY,SAAS;EACvB,CAAC"}
1
+ {"version":3,"file":"index.cjs","names":["ANSIColors","exists","x","readFileFromRoot","writeFileToRoot","v","findTsConfigFiles","parseJSONWithComments","initConfig","updateViteConfig","updateNextConfig"],"sources":["../../../src/init/index.ts"],"sourcesContent":["import {\n ANSIColors,\n colorize,\n colorizePath,\n logger,\n v,\n x,\n} from '@intlayer/config/logger';\nimport { getConfiguration } from '@intlayer/config/node';\nimport { getAlias } from '@intlayer/config/utils';\nimport { initConfig } from '../initConfig';\nimport {\n exists,\n findTsConfigFiles,\n parseJSONWithComments,\n readFileFromRoot,\n updateNextConfig,\n updateViteConfig,\n writeFileToRoot,\n} from './utils';\n\n/**\n * Documentation URL Constants\n */\nconst DocumentationRouter = {\n NextJS: 'https://intlayer.org/doc/environment/nextjs.md',\n NextJS_15: 'https://intlayer.org/doc/environment/nextjs/15.md',\n NextJS_14: 'https://intlayer.org/doc/environment/nextjs/14.md',\n CRA: 'https://intlayer.org/doc/environment/create-react-app.md',\n Astro: 'https://intlayer.org/doc/environment/astro.md',\n ViteAndReact: 'https://intlayer.org/doc/environment/vite-and-react.md',\n ViteAndReact_ReactRouterV7:\n 'https://intlayer.org/doc/environment/vite-and-react/react-router-v7.md',\n ViteAndReact_ReactRouterV7_FSRoutes:\n 'https://intlayer.org/doc/environment/vite-and-react/react-router-v7-fs-routes.md',\n ViteAndVue: 'https://intlayer.org/doc/environment/vite-and-vue.md',\n ViteAndSolid: 'https://intlayer.org/doc/environment/vite-and-solid.md',\n ViteAndSvelte: 'https://intlayer.org/doc/environment/vite-and-svelte.md',\n ViteAndPreact: 'https://intlayer.org/doc/environment/vite-and-preact.md',\n TanStackRouter: 'https://intlayer.org/doc/environment/tanstack.md',\n NuxtAndVue: 'https://intlayer.org/doc/environment/nuxt-and-vue.md',\n Angular: 'https://intlayer.org/doc/environment/angular.md',\n SvelteKit: 'https://intlayer.org/doc/environment/sveltekit.md',\n ReactNativeAndExpo:\n 'https://intlayer.org/doc/environment/react-native-and-expo.md',\n Lynx: 'https://intlayer.org/doc/environment/lynx-and-react.md',\n Express: 'https://intlayer.org/doc/environment/express.md',\n NestJS: 'https://intlayer.org/doc/environment/nestjs.md',\n Fastify: 'https://intlayer.org/doc/environment/fastify.md',\n Default: 'https://intlayer.org/doc/get-started',\n\n // Check for competitors libs\n NextIntl: 'https://intlayer.org/blog/intlayer-with-next-intl.md',\n ReactI18Next: 'https://intlayer.org/blog/intlayer-with-react-i18next.md',\n ReactIntl: 'https://intlayer.org/blog/intlayer-with-react-intl.md',\n NextI18Next: 'https://intlayer.org/blog/intlayer-with-next-i18next.md',\n VueI18n: 'https://intlayer.org/blog/intlayer-with-vue-i18n.md',\n};\n\n/**\n * Helper: Detects the environment and returns the doc URL\n */\nconst getDocumentationUrl = (packageJson: any): string => {\n const deps = {\n ...packageJson.dependencies,\n ...packageJson.devDependencies,\n };\n\n /**\n * Helper to check if a version string matches a specific major version\n * Matches: \"15\", \"^15.0.0\", \"~15.2\", \"15.0.0-beta\"\n */\n const isVersion = (versionString: string, major: number): boolean => {\n if (!versionString || typeof versionString !== 'string') return false;\n const regex = new RegExp(`^[\\\\^~]?${major}(?:\\\\.|$)`);\n return regex.test(versionString);\n };\n\n // Mobile / Cross-platform\n if (deps['@lynx-js/react'] || deps['@lynx-js/core']) {\n return DocumentationRouter.Lynx;\n }\n if (deps['react-native'] || deps.expo) {\n return DocumentationRouter.ReactNativeAndExpo;\n }\n\n // Meta-frameworks (Next, Nuxt, Astro, SvelteKit)\n if (deps.next) {\n const version = deps.next;\n\n if (isVersion(version, 14)) {\n return DocumentationRouter.NextJS_14;\n }\n\n if (isVersion(version, 15)) {\n return DocumentationRouter.NextJS_15;\n }\n\n return DocumentationRouter.NextJS;\n }\n\n if (deps.nuxt) return DocumentationRouter.NuxtAndVue;\n if (deps.astro) return DocumentationRouter.Astro;\n if (deps['@sveltejs/kit']) return DocumentationRouter.SvelteKit;\n\n // Routers (TanStack & React Router v7)\n if (deps['@tanstack/react-router']) {\n return DocumentationRouter.TanStackRouter;\n }\n\n // Check for React Router v7\n const reactRouterVersion = deps['react-router'];\n if (reactRouterVersion && typeof reactRouterVersion === 'string') {\n // Distinguish between standard v7 and v7 with FS routes\n if (deps['@react-router/fs-routes']) {\n return DocumentationRouter.ViteAndReact_ReactRouterV7_FSRoutes;\n }\n\n // Use Regex to ensure it is v7\n if (isVersion(reactRouterVersion, 7)) {\n return DocumentationRouter.ViteAndReact_ReactRouterV7;\n }\n }\n\n // Vite Ecosystem (General)\n if (deps.vite) {\n if (deps.vue) return DocumentationRouter.ViteAndVue;\n if (deps['solid-js']) return DocumentationRouter.ViteAndSolid;\n if (deps.svelte) return DocumentationRouter.ViteAndSvelte;\n if (deps.preact) return DocumentationRouter.ViteAndPreact;\n\n // Default to React if Vite is present but specific other frameworks aren't found\n return DocumentationRouter.ViteAndReact;\n }\n\n // Other Web Frameworks\n if (deps['react-scripts']) return DocumentationRouter.CRA;\n if (deps['@angular/core']) return DocumentationRouter.Angular;\n\n // Backend\n if (deps['@nestjs/core']) return DocumentationRouter.NestJS;\n if (deps.express) return DocumentationRouter.Express;\n if (deps.fastify) return DocumentationRouter.Fastify;\n\n // Competitor Libs (Migration Guides)\n // We check these last as specific environment setup is usually higher priority,\n // but if no specific framework logic matched (or as a fallback), we guide to migration.\n if (deps['next-intl']) return DocumentationRouter.NextIntl;\n if (deps['react-i18next'] || deps.i18next)\n return DocumentationRouter.ReactI18Next;\n if (deps['react-intl']) return DocumentationRouter.ReactIntl;\n if (deps['next-i18next']) return DocumentationRouter.NextI18Next;\n if (deps['vue-i18n']) return DocumentationRouter.VueI18n;\n\n return DocumentationRouter.Default;\n};\n\n/**\n * MAIN LOGIC\n */\nexport const initIntlayer = async (rootDir: string) => {\n logger(colorize('Checking Intlayer configuration...', ANSIColors.CYAN));\n\n // READ PACKAGE.JSON\n const packageJsonPath = 'package.json';\n if (!(await exists(rootDir, packageJsonPath))) {\n logger(\n `${x} No ${colorizePath('package.json')} found. Please run this script from the project root.`,\n { level: 'error' }\n );\n process.exit(1);\n }\n\n const packageJsonContent = await readFileFromRoot(rootDir, packageJsonPath);\n let packageJson: Record<string, any>;\n try {\n packageJson = JSON.parse(packageJsonContent);\n } catch {\n logger(`${x} Could not parse ${colorizePath('package.json')}.`, {\n level: 'error',\n });\n process.exit(1);\n }\n\n // Determine the correct documentation URL based on dependencies\n const guideUrl = getDocumentationUrl(packageJson);\n\n // 2. CHECK .GITIGNORE\n const gitignorePath = '.gitignore';\n if (await exists(rootDir, gitignorePath)) {\n const gitignoreContent = await readFileFromRoot(rootDir, gitignorePath);\n\n if (!gitignoreContent.includes('intlayer')) {\n const newContent = `${gitignoreContent}\\n# Intlayer\\n.intlayer\\n`;\n await writeFileToRoot(rootDir, gitignorePath, newContent);\n logger(\n `${v} Added ${colorizePath('.intlayer')} to ${colorizePath(gitignorePath)}`\n );\n } else {\n logger(`${v} ${colorizePath(gitignorePath)} already includes .intlayer`);\n }\n }\n\n // CHECK TSCONFIGS\n const tsConfigFiles = await findTsConfigFiles(rootDir);\n let hasTsConfig = false;\n\n for (const fileName of tsConfigFiles) {\n if (await exists(rootDir, fileName)) {\n hasTsConfig = true;\n try {\n const fileContent = await readFileFromRoot(rootDir, fileName);\n const config = parseJSONWithComments(fileContent);\n const typeDefinition = '.intlayer/**/*.ts';\n\n let updated = false;\n\n if (!config.include) {\n // Skip if no include array (solution-style)\n } else if (\n Array.isArray(config.include) &&\n !(config.include as string[]).some((pattern: string) =>\n pattern.includes('.intlayer')\n )\n ) {\n config.include.push(typeDefinition);\n updated = true;\n } else if (config.include.includes(typeDefinition)) {\n logger(\n `${v} ${colorizePath(fileName)} already includes intlayer types`\n );\n }\n\n if (updated) {\n await writeFileToRoot(\n rootDir,\n fileName,\n JSON.stringify(config, null, 2)\n );\n logger(\n `${v} Updated ${colorizePath(fileName)} to include intlayer types`\n );\n }\n } catch {\n logger(\n `${x} Could not parse or update ${colorizePath(fileName)}. You may need to add ${colorizePath('.intlayer/types/**/*.ts')} manually.`,\n { level: 'warn' }\n );\n }\n }\n }\n\n // INITIALIZE CONFIG FILE\n const format = hasTsConfig ? 'intlayer.config.ts' : 'intlayer.config.mjs';\n await initConfig(format, rootDir);\n\n let hasAliasConfiguration = false;\n\n // CHECK VITE CONFIG\n const viteConfigs = ['vite.config.ts', 'vite.config.js', 'vite.config.mjs'];\n for (const file of viteConfigs) {\n if (await exists(rootDir, file)) {\n hasAliasConfiguration = true;\n const content = await readFileFromRoot(rootDir, file);\n\n if (!content.includes('vite-intlayer')) {\n const extension = file.split('.').pop()!;\n const updatedContent = updateViteConfig(content, extension);\n await writeFileToRoot(rootDir, file, updatedContent);\n logger(`${v} Updated ${colorizePath(file)} to include Intlayer plugin`);\n }\n break;\n }\n }\n\n // CHECK NEXT CONFIG\n const nextConfigs = ['next.config.js', 'next.config.mjs', 'next.config.ts'];\n for (const file of nextConfigs) {\n if (await exists(rootDir, file)) {\n hasAliasConfiguration = true;\n const content = await readFileFromRoot(rootDir, file);\n\n if (!content.includes('next-intlayer')) {\n const extension = file.split('.').pop()!;\n const updatedContent = updateNextConfig(content, extension);\n await writeFileToRoot(rootDir, file, updatedContent);\n logger(`${v} Updated ${colorizePath(file)} to include Intlayer plugin`);\n }\n break;\n }\n }\n\n // CHECK WEBPACK CONFIG\n const webpackConfigs = [\n 'webpack.config.js',\n 'webpack.config.ts',\n 'webpack.config.mjs',\n 'webpack.config.cjs',\n ];\n for (const file of webpackConfigs) {\n if (await exists(rootDir, file)) {\n hasAliasConfiguration = true;\n logger(\n `${v} Found ${colorizePath(\n file\n )}. Make sure to configure aliases manually or use the Intlayer Webpack plugin.`\n );\n break;\n }\n }\n\n if (!hasAliasConfiguration) {\n const configuration = getConfiguration({ baseDir: rootDir });\n const aliases = getAlias({ configuration });\n\n if (hasTsConfig && tsConfigFiles.length > 0) {\n const tsConfigPath =\n tsConfigFiles.find((f) => f === 'tsconfig.json') || tsConfigFiles[0];\n const tsConfigContent = await readFileFromRoot(rootDir, tsConfigPath);\n const config = parseJSONWithComments(tsConfigContent);\n\n config.compilerOptions ??= {};\n config.compilerOptions.paths ??= {};\n\n let updated = false;\n\n Object.entries(aliases).forEach(([alias, path]) => {\n if (!config.compilerOptions.paths[alias]) {\n config.compilerOptions.paths[alias] = [path];\n updated = true;\n }\n });\n\n if (updated) {\n await writeFileToRoot(\n rootDir,\n tsConfigPath,\n JSON.stringify(config, null, 2)\n );\n logger(\n `${v} Updated ${colorizePath(\n tsConfigPath\n )} to include Intlayer aliases`\n );\n }\n } else {\n const jsConfigPath = 'jsconfig.json';\n if (await exists(rootDir, jsConfigPath)) {\n const jsConfigContent = await readFileFromRoot(rootDir, jsConfigPath);\n const config = parseJSONWithComments(jsConfigContent);\n\n config.compilerOptions ??= {};\n config.compilerOptions.paths ??= {};\n\n let updated = false;\n\n Object.entries(aliases).forEach(([alias, path]) => {\n if (!config.compilerOptions.paths[alias]) {\n config.compilerOptions.paths[alias] = [path];\n updated = true;\n }\n });\n\n if (updated) {\n await writeFileToRoot(\n rootDir,\n jsConfigPath,\n JSON.stringify(config, null, 2)\n );\n logger(\n `${v} Updated ${colorizePath(\n jsConfigPath\n )} to include Intlayer aliases`\n );\n }\n } else {\n packageJson.imports ??= {};\n\n let updated = false;\n\n Object.entries(aliases).forEach(([alias, path]) => {\n const importAlias = alias.replace('@', '#');\n const importPath = path.startsWith('.') ? path : `./${path}`;\n\n if (!packageJson.imports[importAlias]) {\n packageJson.imports[importAlias] = importPath;\n updated = true;\n }\n });\n\n if (updated) {\n await writeFileToRoot(\n rootDir,\n packageJsonPath,\n JSON.stringify(packageJson, null, 2)\n );\n logger(\n `${v} Updated ${colorizePath(\n packageJsonPath\n )} to include Intlayer imports`\n );\n }\n }\n }\n }\n\n // FINAL SUCCESS MESSAGE\n logger(`${v} ${colorize('Intlayer init setup complete.', ANSIColors.GREEN)}`);\n logger([\n colorize('Next →', ANSIColors.MAGENTA),\n colorize(\n `Follow the instructions in the documentation to complete the setup:`,\n ANSIColors.GREY_LIGHT\n ),\n colorizePath(guideUrl),\n ]);\n};\n"],"mappings":"iaAwBA,MAAM,EAAsB,CAC1B,OAAQ,iDACR,UAAW,oDACX,UAAW,oDACX,IAAK,2DACL,MAAO,gDACP,aAAc,yDACd,2BACE,yEACF,oCACE,mFACF,WAAY,uDACZ,aAAc,yDACd,cAAe,0D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BAEpC,sEACAA,EAAAA,WAAW,WACZ,oBACY,EAAS,CACvB,CAAC"}
@@ -1,165 +1,2 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
3
- let ts_morph = require("ts-morph");
4
-
5
- //#region src/init/utils/configManipulation.ts
6
- /**
7
- * Checks if a module is already imported or required in the source file.
8
- */
9
- const isModuleImported = (sourceFile, moduleName) => {
10
- const hasImport = sourceFile.getImportDeclarations().some((i) => i.getModuleSpecifierValue() === moduleName);
11
- const hasRequire = sourceFile.getDescendantsOfKind(ts_morph.SyntaxKind.CallExpression).some((c) => {
12
- return c.getExpression().getText() === "require" && c.getArguments()[0]?.asKind(ts_morph.SyntaxKind.StringLiteral)?.getLiteralValue() === moduleName;
13
- });
14
- return hasImport || hasRequire;
15
- };
16
- /**
17
- * Checks if the file should be treated as CommonJS.
18
- */
19
- const isCJS = (content, extension) => {
20
- if (extension === "cjs") return true;
21
- if (["mjs", "ts"].includes(extension)) return false;
22
- return content.includes("module.exports") && !content.includes("import ") && !content.includes("export ");
23
- };
24
- /**
25
- * Updates a Vite configuration file to include the Intlayer plugin.
26
- * @param content The content of the vite.config file
27
- * @param extension The file extension (ts, js, mjs, cjs)
28
- * @returns The updated content
29
- */
30
- const updateViteConfig = (content, extension) => {
31
- const sourceFile = new ts_morph.Project({ useInMemoryFileSystem: true }).createSourceFile(`vite.config.${extension}`, content);
32
- const isCJSFile = isCJS(content, extension);
33
- if (!isModuleImported(sourceFile, "vite-intlayer")) if (isCJSFile) sourceFile.insertVariableStatement(0, {
34
- declarationKind: "const",
35
- declarations: [{
36
- name: "{ intlayer }",
37
- initializer: "require(\"vite-intlayer\")"
38
- }]
39
- });
40
- else sourceFile.addImportDeclaration({
41
- moduleSpecifier: "vite-intlayer",
42
- namedImports: ["intlayer"]
43
- });
44
- let configObject;
45
- const exportDefault = sourceFile.getExportAssignment((e) => !e.isExportEquals());
46
- if (exportDefault) {
47
- const expression = exportDefault.getExpression();
48
- if (expression.getKind() === ts_morph.SyntaxKind.CallExpression) {
49
- const call = expression.asKind(ts_morph.SyntaxKind.CallExpression);
50
- if (call?.getExpression().getText() === "defineConfig") {
51
- const arg = call.getArguments()[0];
52
- if (arg?.getKind() === ts_morph.SyntaxKind.ObjectLiteralExpression) configObject = arg.asKind(ts_morph.SyntaxKind.ObjectLiteralExpression);
53
- }
54
- } else if (expression.getKind() === ts_morph.SyntaxKind.ObjectLiteralExpression) configObject = expression.asKind(ts_morph.SyntaxKind.ObjectLiteralExpression);
55
- else if (expression.getKind() === ts_morph.SyntaxKind.Identifier) {
56
- const definitions = expression.asKind(ts_morph.SyntaxKind.Identifier)?.getDefinitions();
57
- if (definitions && definitions.length > 0) {
58
- const node = definitions[0].getDeclarationNode();
59
- if (node?.getKind() === ts_morph.SyntaxKind.VariableDeclaration) {
60
- const init = node.asKind(ts_morph.SyntaxKind.VariableDeclaration)?.getInitializer();
61
- if (init?.getKind() === ts_morph.SyntaxKind.ObjectLiteralExpression) configObject = init.asKind(ts_morph.SyntaxKind.ObjectLiteralExpression);
62
- }
63
- }
64
- }
65
- }
66
- if (!configObject) {
67
- const expressionStatements = sourceFile.getStatements();
68
- for (const statement of expressionStatements) if (statement.getKind() === ts_morph.SyntaxKind.ExpressionStatement) {
69
- const expr = statement.asKind(ts_morph.SyntaxKind.ExpressionStatement)?.getExpression();
70
- if (expr?.getKind() === ts_morph.SyntaxKind.BinaryExpression) {
71
- const binary = expr.asKind(ts_morph.SyntaxKind.BinaryExpression);
72
- if (binary?.getLeft().getText() === "module.exports" && binary.getOperatorToken().getKind() === ts_morph.SyntaxKind.EqualsToken) {
73
- const right = binary.getRight();
74
- if (right.getKind() === ts_morph.SyntaxKind.ObjectLiteralExpression) configObject = right.asKind(ts_morph.SyntaxKind.ObjectLiteralExpression);
75
- else if (right.getKind() === ts_morph.SyntaxKind.CallExpression) {
76
- const call = right.asKind(ts_morph.SyntaxKind.CallExpression);
77
- if (call?.getExpression().getText() === "defineConfig") {
78
- const arg = call.getArguments()[0];
79
- if (arg?.getKind() === ts_morph.SyntaxKind.ObjectLiteralExpression) configObject = arg.asKind(ts_morph.SyntaxKind.ObjectLiteralExpression);
80
- }
81
- } else if (right.getKind() === ts_morph.SyntaxKind.Identifier) {
82
- const definitions = right.asKind(ts_morph.SyntaxKind.Identifier)?.getDefinitions();
83
- if (definitions && definitions.length > 0) {
84
- const node = definitions[0].getDeclarationNode();
85
- if (node?.getKind() === ts_morph.SyntaxKind.VariableDeclaration) {
86
- const init = node.asKind(ts_morph.SyntaxKind.VariableDeclaration)?.getInitializer();
87
- if (init?.getKind() === ts_morph.SyntaxKind.ObjectLiteralExpression) configObject = init.asKind(ts_morph.SyntaxKind.ObjectLiteralExpression);
88
- }
89
- }
90
- }
91
- }
92
- }
93
- }
94
- }
95
- if (configObject) {
96
- let pluginsProp = configObject.getProperty("plugins");
97
- if (!pluginsProp) {
98
- configObject.addPropertyAssignment({
99
- name: "plugins",
100
- initializer: "[]"
101
- });
102
- pluginsProp = configObject.getProperty("plugins");
103
- }
104
- if (pluginsProp?.getKind() === ts_morph.SyntaxKind.PropertyAssignment) {
105
- const initializer = pluginsProp.asKind(ts_morph.SyntaxKind.PropertyAssignment)?.getInitializer();
106
- if (initializer?.getKind() === ts_morph.SyntaxKind.ArrayLiteralExpression) {
107
- const array = initializer.asKind(ts_morph.SyntaxKind.ArrayLiteralExpression);
108
- if (!array?.getElements().some((el) => el.getText().includes("intlayer("))) array?.addElement("intlayer()");
109
- }
110
- }
111
- }
112
- return sourceFile.getFullText();
113
- };
114
- /**
115
- * Updates a Next.js configuration file to wrap the export with withIntlayer.
116
- * @param content The content of the next.config file
117
- * @param extension The file extension (ts, js, mjs, cjs)
118
- * @returns The updated content
119
- */
120
- const updateNextConfig = (content, extension) => {
121
- const sourceFile = new ts_morph.Project({ useInMemoryFileSystem: true }).createSourceFile(`next.config.${extension}`, content);
122
- const isCJSFile = isCJS(content, extension);
123
- if (!isModuleImported(sourceFile, "next-intlayer/server")) if (isCJSFile) sourceFile.insertVariableStatement(0, {
124
- declarationKind: "const",
125
- declarations: [{
126
- name: "{ withIntlayer }",
127
- initializer: "require(\"next-intlayer/server\")"
128
- }]
129
- });
130
- else sourceFile.addImportDeclaration({
131
- moduleSpecifier: "next-intlayer/server",
132
- namedImports: ["withIntlayer"]
133
- });
134
- let updated = false;
135
- const exportDefault = sourceFile.getExportAssignment((e) => !e.isExportEquals());
136
- if (exportDefault) {
137
- const expression = exportDefault.getExpression();
138
- if (!expression.getText().includes("withIntlayer")) {
139
- exportDefault.setExpression(`withIntlayer(${expression.getText()})`);
140
- updated = true;
141
- }
142
- }
143
- if (!updated) {
144
- const expressionStatements = sourceFile.getStatements();
145
- for (const statement of expressionStatements) if (statement.getKind() === ts_morph.SyntaxKind.ExpressionStatement) {
146
- const expr = statement.asKind(ts_morph.SyntaxKind.ExpressionStatement)?.getExpression();
147
- if (expr?.getKind() === ts_morph.SyntaxKind.BinaryExpression) {
148
- const binary = expr.asKind(ts_morph.SyntaxKind.BinaryExpression);
149
- if (binary?.getLeft().getText() === "module.exports" && binary.getOperatorToken().getKind() === ts_morph.SyntaxKind.EqualsToken) {
150
- const right = binary.getRight();
151
- if (!right.getText().includes("withIntlayer")) {
152
- right.replaceWithText(`withIntlayer(${right.getText()})`);
153
- updated = true;
154
- }
155
- }
156
- }
157
- }
158
- }
159
- return sourceFile.getFullText();
160
- };
161
-
162
- //#endregion
163
- exports.updateNextConfig = updateNextConfig;
164
- exports.updateViteConfig = updateViteConfig;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../../_virtual/_rolldown/runtime.cjs`);let e=require(`ts-morph`);const t=(t,n)=>{let r=t.getImportDeclarations().some(e=>e.getModuleSpecifierValue()===n),i=t.getDescendantsOfKind(e.SyntaxKind.CallExpression).some(t=>t.getExpression().getText()===`require`&&t.getArguments()[0]?.asKind(e.SyntaxKind.StringLiteral)?.getLiteralValue()===n);return r||i},n=(e,t)=>t===`cjs`?!0:[`mjs`,`ts`].includes(t)?!1:e.includes(`module.exports`)&&!e.includes(`import `)&&!e.includes(`export `),r=(r,i)=>{let a=new e.Project({useInMemoryFileSystem:!0}).createSourceFile(`vite.config.${i}`,r),o=n(r,i);t(a,`vite-intlayer`)||(o?a.insertVariableStatement(0,{declarationKind:`const`,declarations:[{name:`{ intlayer }`,initializer:`require("vite-intlayer")`}]}):a.addImportDeclaration({moduleSpecifier:`vite-intlayer`,namedImports:[`intlayer`]}));let s,c=a.getExportAssignment(e=>!e.isExportEquals());if(c){let t=c.getExpression();if(t.getKind()===e.SyntaxKind.CallExpression){let n=t.asKind(e.SyntaxKind.CallExpression);if(n?.getExpression().getText()===`defineConfig`){let t=n.getArguments()[0];t?.getKind()===e.SyntaxKind.ObjectLiteralExpression&&(s=t.asKind(e.SyntaxKind.ObjectLiteralExpression))}}else if(t.getKind()===e.SyntaxKind.ObjectLiteralExpression)s=t.asKind(e.SyntaxKind.ObjectLiteralExpression);else if(t.getKind()===e.SyntaxKind.Identifier){let n=t.asKind(e.SyntaxKind.Identifier)?.getDefinitions();if(n&&n.length>0){let t=n[0].getDeclarationNode();if(t?.getKind()===e.SyntaxKind.VariableDeclaration){let n=t.asKind(e.SyntaxKind.VariableDeclaration)?.getInitializer();n?.getKind()===e.SyntaxKind.ObjectLiteralExpression&&(s=n.asKind(e.SyntaxKind.ObjectLiteralExpression))}}}}if(!s){let t=a.getStatements();for(let n of t)if(n.getKind()===e.SyntaxKind.ExpressionStatement){let t=n.asKind(e.SyntaxKind.ExpressionStatement)?.getExpression();if(t?.getKind()===e.SyntaxKind.BinaryExpression){let n=t.asKind(e.SyntaxKind.BinaryExpression);if(n?.getLeft().getText()===`module.exports`&&n.getOperatorToken().getKind()===e.SyntaxKind.EqualsToken){let t=n.getRight();if(t.getKind()===e.SyntaxKind.ObjectLiteralExpression)s=t.asKind(e.SyntaxKind.ObjectLiteralExpression);else if(t.getKind()===e.SyntaxKind.CallExpression){let n=t.asKind(e.SyntaxKind.CallExpression);if(n?.getExpression().getText()===`defineConfig`){let t=n.getArguments()[0];t?.getKind()===e.SyntaxKind.ObjectLiteralExpression&&(s=t.asKind(e.SyntaxKind.ObjectLiteralExpression))}}else if(t.getKind()===e.SyntaxKind.Identifier){let n=t.asKind(e.SyntaxKind.Identifier)?.getDefinitions();if(n&&n.length>0){let t=n[0].getDeclarationNode();if(t?.getKind()===e.SyntaxKind.VariableDeclaration){let n=t.asKind(e.SyntaxKind.VariableDeclaration)?.getInitializer();n?.getKind()===e.SyntaxKind.ObjectLiteralExpression&&(s=n.asKind(e.SyntaxKind.ObjectLiteralExpression))}}}}}}}if(s){let t=s.getProperty(`plugins`);if(t||=(s.addPropertyAssignment({name:`plugins`,initializer:`[]`}),s.getProperty(`plugins`)),t?.getKind()===e.SyntaxKind.PropertyAssignment){let n=t.asKind(e.SyntaxKind.PropertyAssignment)?.getInitializer();if(n?.getKind()===e.SyntaxKind.ArrayLiteralExpression){let t=n.asKind(e.SyntaxKind.ArrayLiteralExpression);t?.getElements().some(e=>e.getText().includes(`intlayer(`))||t?.addElement(`intlayer()`)}}}return a.getFullText()},i=(r,i)=>{let a=new e.Project({useInMemoryFileSystem:!0}).createSourceFile(`next.config.${i}`,r),o=n(r,i);t(a,`next-intlayer/server`)||(o?a.insertVariableStatement(0,{declarationKind:`const`,declarations:[{name:`{ withIntlayer }`,initializer:`require("next-intlayer/server")`}]}):a.addImportDeclaration({moduleSpecifier:`next-intlayer/server`,namedImports:[`withIntlayer`]}));let s=!1,c=a.getExportAssignment(e=>!e.isExportEquals());if(c){let e=c.getExpression();e.getText().includes(`withIntlayer`)||(c.setExpression(`withIntlayer(${e.getText()})`),s=!0)}if(!s){let t=a.getStatements();for(let n of t)if(n.getKind()===e.SyntaxKind.ExpressionStatement){let t=n.asKind(e.SyntaxKind.ExpressionStatement)?.getExpression();if(t?.getKind()===e.SyntaxKind.BinaryExpression){let n=t.asKind(e.SyntaxKind.BinaryExpression);if(n?.getLeft().getText()===`module.exports`&&n.getOperatorToken().getKind()===e.SyntaxKind.EqualsToken){let e=n.getRight();e.getText().includes(`withIntlayer`)||(e.replaceWithText(`withIntlayer(${e.getText()})`),s=!0)}}}}return a.getFullText()};exports.updateNextConfig=i,exports.updateViteConfig=r;
165
2
  //# sourceMappingURL=configManipulation.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"configManipulation.cjs","names":["SyntaxKind","Project"],"sources":["../../../../src/init/utils/configManipulation.ts"],"sourcesContent":["import {\n type ObjectLiteralExpression,\n Project,\n type SourceFile,\n SyntaxKind,\n} from 'ts-morph';\n\n/**\n * Checks if a module is already imported or required in the source file.\n */\nconst isModuleImported = (\n sourceFile: SourceFile,\n moduleName: string\n): boolean => {\n const hasImport = sourceFile\n .getImportDeclarations()\n .some((i) => i.getModuleSpecifierValue() === moduleName);\n\n const hasRequire = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .some((c) => {\n const expression = c.getExpression();\n return (\n expression.getText() === 'require' &&\n c\n .getArguments()[0]\n ?.asKind(SyntaxKind.StringLiteral)\n ?.getLiteralValue() === moduleName\n );\n });\n\n return hasImport || hasRequire;\n};\n\n/**\n * Checks if the file should be treated as CommonJS.\n */\nconst isCJS = (content: string, extension: string): boolean => {\n if (extension === 'cjs') return true;\n if (['mjs', 'ts'].includes(extension)) return false;\n\n return (\n content.includes('module.exports') &&\n !content.includes('import ') &&\n !content.includes('export ')\n );\n};\n\n/**\n * Updates a Vite configuration file to include the Intlayer plugin.\n * @param content The content of the vite.config file\n * @param extension The file extension (ts, js, mjs, cjs)\n * @returns The updated content\n */\nexport const updateViteConfig = (\n content: string,\n extension: string\n): string => {\n const project = new Project({ useInMemoryFileSystem: true });\n const sourceFile = project.createSourceFile(\n `vite.config.${extension}`,\n content\n );\n\n const isCJSFile = isCJS(content, extension);\n\n // Add import if missing\n const hasIntlayerImport = isModuleImported(sourceFile, 'vite-intlayer');\n\n if (!hasIntlayerImport) {\n if (isCJSFile) {\n sourceFile.insertVariableStatement(0, {\n declarationKind: 'const' as any,\n declarations: [\n {\n name: '{ intlayer }',\n initializer: 'require(\"vite-intlayer\")',\n },\n ],\n });\n } else {\n sourceFile.addImportDeclaration({\n moduleSpecifier: 'vite-intlayer',\n namedImports: ['intlayer'],\n });\n }\n }\n\n // Find the configuration object\n let configObject: ObjectLiteralExpression | undefined;\n\n // Case: export default defineConfig({...})\n const exportDefault = sourceFile.getExportAssignment(\n (e) => !e.isExportEquals()\n );\n if (exportDefault) {\n const expression = exportDefault.getExpression();\n\n if (expression.getKind() === SyntaxKind.CallExpression) {\n const call = expression.asKind(SyntaxKind.CallExpression);\n\n if (call?.getExpression().getText() === 'defineConfig') {\n const arg = call.getArguments()[0];\n\n if (arg?.getKind() === SyntaxKind.ObjectLiteralExpression) {\n configObject = arg.asKind(SyntaxKind.ObjectLiteralExpression);\n }\n }\n } else if (expression.getKind() === SyntaxKind.ObjectLiteralExpression) {\n // Case: export default {...}\n configObject = expression.asKind(SyntaxKind.ObjectLiteralExpression);\n } else if (expression.getKind() === SyntaxKind.Identifier) {\n // Case: const config = {...}; export default config;\n const identifier = expression.asKind(SyntaxKind.Identifier);\n const definitions = identifier?.getDefinitions();\n\n if (definitions && definitions.length > 0) {\n const node = definitions[0].getDeclarationNode();\n\n if (node?.getKind() === SyntaxKind.VariableDeclaration) {\n const init = node\n .asKind(SyntaxKind.VariableDeclaration)\n ?.getInitializer();\n\n if (init?.getKind() === SyntaxKind.ObjectLiteralExpression) {\n configObject = init.asKind(SyntaxKind.ObjectLiteralExpression);\n }\n }\n }\n }\n }\n\n // Case: module.exports = {...}\n if (!configObject) {\n const expressionStatements = sourceFile.getStatements();\n for (const statement of expressionStatements) {\n if (statement.getKind() === SyntaxKind.ExpressionStatement) {\n const expr = statement\n .asKind(SyntaxKind.ExpressionStatement)\n ?.getExpression();\n\n if (expr?.getKind() === SyntaxKind.BinaryExpression) {\n const binary = expr.asKind(SyntaxKind.BinaryExpression);\n\n if (\n binary?.getLeft().getText() === 'module.exports' &&\n binary.getOperatorToken().getKind() === SyntaxKind.EqualsToken\n ) {\n const right = binary.getRight();\n\n if (right.getKind() === SyntaxKind.ObjectLiteralExpression) {\n configObject = right.asKind(SyntaxKind.ObjectLiteralExpression);\n } else if (right.getKind() === SyntaxKind.CallExpression) {\n // Case: module.exports = defineConfig({...})\n const call = right.asKind(SyntaxKind.CallExpression);\n\n if (call?.getExpression().getText() === 'defineConfig') {\n const arg = call.getArguments()[0];\n\n if (arg?.getKind() === SyntaxKind.ObjectLiteralExpression) {\n configObject = arg.asKind(SyntaxKind.ObjectLiteralExpression);\n }\n }\n } else if (right.getKind() === SyntaxKind.Identifier) {\n // Case: const config = {...}; module.exports = config;\n const identifier = right.asKind(SyntaxKind.Identifier);\n const definitions = identifier?.getDefinitions();\n\n if (definitions && definitions.length > 0) {\n const node = definitions[0].getDeclarationNode();\n\n if (node?.getKind() === SyntaxKind.VariableDeclaration) {\n const init = node\n .asKind(SyntaxKind.VariableDeclaration)\n ?.getInitializer();\n\n if (init?.getKind() === SyntaxKind.ObjectLiteralExpression) {\n configObject = init.asKind(\n SyntaxKind.ObjectLiteralExpression\n );\n }\n }\n }\n }\n }\n }\n }\n }\n }\n\n // 3. Update plugins array\n if (configObject) {\n let pluginsProp = configObject.getProperty('plugins');\n\n if (!pluginsProp) {\n configObject.addPropertyAssignment({\n name: 'plugins',\n initializer: '[]',\n });\n pluginsProp = configObject.getProperty('plugins');\n }\n\n if (pluginsProp?.getKind() === SyntaxKind.PropertyAssignment) {\n const initializer = pluginsProp\n .asKind(SyntaxKind.PropertyAssignment)\n ?.getInitializer();\n\n if (initializer?.getKind() === SyntaxKind.ArrayLiteralExpression) {\n const array = initializer.asKind(SyntaxKind.ArrayLiteralExpression);\n const hasIntlayer = array\n ?.getElements()\n .some((el) => el.getText().includes('intlayer('));\n\n if (!hasIntlayer) {\n array?.addElement('intlayer()');\n }\n }\n }\n }\n\n return sourceFile.getFullText();\n};\n\n/**\n * Updates a Next.js configuration file to wrap the export with withIntlayer.\n * @param content The content of the next.config file\n * @param extension The file extension (ts, js, mjs, cjs)\n * @returns The updated content\n */\nexport const updateNextConfig = (\n content: string,\n extension: string\n): string => {\n const project = new Project({ useInMemoryFileSystem: true });\n const sourceFile = project.createSourceFile(\n `next.config.${extension}`,\n content\n );\n\n const isCJSFile = isCJS(content, extension);\n\n // 1. Add import if missing\n const hasIntlayerImport = isModuleImported(\n sourceFile,\n 'next-intlayer/server'\n );\n\n if (!hasIntlayerImport) {\n if (isCJSFile) {\n sourceFile.insertVariableStatement(0, {\n declarationKind: 'const' as any,\n declarations: [\n {\n name: '{ withIntlayer }',\n initializer: 'require(\"next-intlayer/server\")',\n },\n ],\n });\n } else {\n sourceFile.addImportDeclaration({\n moduleSpecifier: 'next-intlayer/server',\n namedImports: ['withIntlayer'],\n });\n }\n }\n\n // 2. Wrap export\n let updated = false;\n\n // Case: export default ...\n const exportDefault = sourceFile.getExportAssignment(\n (e) => !e.isExportEquals()\n );\n if (exportDefault) {\n const expression = exportDefault.getExpression();\n\n if (!expression.getText().includes('withIntlayer')) {\n exportDefault.setExpression(`withIntlayer(${expression.getText()})`);\n updated = true;\n }\n }\n\n // Case: module.exports = ...\n if (!updated) {\n const expressionStatements = sourceFile.getStatements();\n for (const statement of expressionStatements) {\n if (statement.getKind() === SyntaxKind.ExpressionStatement) {\n const expr = statement\n .asKind(SyntaxKind.ExpressionStatement)\n ?.getExpression();\n\n if (expr?.getKind() === SyntaxKind.BinaryExpression) {\n const binary = expr.asKind(SyntaxKind.BinaryExpression);\n\n if (\n binary?.getLeft().getText() === 'module.exports' &&\n binary.getOperatorToken().getKind() === SyntaxKind.EqualsToken\n ) {\n const right = binary.getRight();\n\n if (!right.getText().includes('withIntlayer')) {\n right.replaceWithText(`withIntlayer(${right.getText()})`);\n updated = true;\n }\n }\n }\n }\n }\n }\n\n return sourceFile.getFullText();\n};\n"],"mappings":";;;;;;;;AAUA,MAAM,oB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F,CAAC;KAEF,YAAW,qBAAqB;EAC9B,iBAAiB;EACjB,cAAc,CAAC,eAAe;EAC/B,CAAC;CAKN,IAAI,UAAU;CAGd,MAAM,gBAAgB,WAAW,qBAC9B,MAAM,CAAC,EAAE,gBAAgB,CAC3B;AACD,KAAI,eAAe;EACjB,MAAM,aAAa,cAAc,eAAe;AAEhD,MAAI,CAAC,WAAW,SAAS,CAAC,SAAS,eAAe,EAAE;AAClD,iBAAc,cAAc,gBAAgB,WAAW,SAAS,CAAC,GAAG;AACpE,aAAU;;;AAKd,KAAI,CAAC,SAAS;EACZ,MAAM,uBAAuB,WAAW,eAAe;AACvD,OAAK,MAAM,aAAa,qBACtB,KAAI,UAAU,SAAS,KAAKD,oBAAW,qBAAqB;GAC1D,MAAM,OAAO,UACV,OAAOA,oBAAW,oBAAoB,EACrC,eAAe;AAEnB,OAAI,MAAM,SAAS,KAAKA,oBAAW,kBAAkB;IACnD,MAAM,SAAS,KAAK,OAAOA,oBAAW,iBAAiB;AAEvD,QACE,QAAQ,SAAS,CAAC,SAAS,KAAK,oBAChC,OAAO,kBAAkB,CAAC,SAAS,KAAKA,oBAAW,aACnD;KACA,MAAM,QAAQ,OAAO,UAAU;AAE/B,SAAI,CAAC,MAAM,SAAS,CAAC,SAAS,eAAe,EAAE;AAC7C,YAAM,gBAAgB,gBAAgB,MAAM,SAAS,CAAC,GAAG;AACzD,gBAAU;;;;;;AAQtB,QAAO,WAAW,aAAa"}
1
+ {"version":3,"file":"configManipulation.cjs","names":["SyntaxKind","Project"],"sources":["../../../../src/init/utils/configManipulation.ts"],"sourcesContent":["import {\n type ObjectLiteralExpression,\n Project,\n type SourceFile,\n SyntaxKind,\n} from 'ts-morph';\n\n/**\n * Checks if a module is already imported or required in the source file.\n */\nconst isModuleImported = (\n sourceFile: SourceFile,\n moduleName: string\n): boolean => {\n const hasImport = sourceFile\n .getImportDeclarations()\n .some((i) => i.getModuleSpecifierValue() === moduleName);\n\n const hasRequire = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .some((c) => {\n const expression = c.getExpression();\n return (\n expression.getText() === 'require' &&\n c\n .getArguments()[0]\n ?.asKind(SyntaxKind.StringLiteral)\n ?.getLiteralValue() === moduleName\n );\n });\n\n return hasImport || hasRequire;\n};\n\n/**\n * Checks if the file should be treated as CommonJS.\n */\nconst isCJS = (content: string, extension: string): boolean => {\n if (extension === 'cjs') return true;\n if (['mjs', 'ts'].includes(extension)) return false;\n\n return (\n content.includes('module.exports') &&\n !content.includes('import ') &&\n !content.includes('export ')\n );\n};\n\n/**\n * Updates a Vite configuration file to include the Intlayer plugin.\n * @param content The content of the vite.config file\n * @param extension The file extension (ts, js, mjs, cjs)\n * @returns The updated content\n */\nexport const updateViteConfig = (\n content: string,\n extension: string\n): string => {\n const project = new Project({ useInMemoryFileSystem: true });\n const sourceFile = project.createSourceFile(\n `vite.config.${extension}`,\n content\n );\n\n const isCJSFile = isCJS(content, extension);\n\n // Add import if missing\n const hasIntlayerImport = isModuleImported(sourceFile, 'vite-intlayer');\n\n if (!hasIntlayerImport) {\n if (isCJSFile) {\n sourceFile.insertVariableStatement(0, {\n declarationKind: 'const' as any,\n declarations: [\n {\n name: '{ intlayer }',\n initializer: 'require(\"vite-intlayer\")',\n },\n ],\n });\n } else {\n sourceFile.addImportDeclaration({\n moduleSpecifier: 'vite-intlayer',\n namedImports: ['intlayer'],\n });\n }\n }\n\n // Find the configuration object\n let configObject: ObjectLiteralExpression | undefined;\n\n // Case: export default defineConfig({...})\n const exportDefault = sourceFile.getExportAssignment(\n (e) => !e.isExportEquals()\n );\n if (exportDefault) {\n const expression = exportDefault.getExpression();\n\n if (expression.getKind() === SyntaxKind.CallExpression) {\n const call = expression.asKind(SyntaxKind.CallExpression);\n\n if (call?.getExpression().getText() === 'defineConfig') {\n const arg = call.getArguments()[0];\n\n if (arg?.getKind() === SyntaxKind.ObjectLiteralExpression) {\n configObject = arg.asKind(SyntaxKind.ObjectLiteralExpression);\n }\n }\n } else if (expression.getKind() === SyntaxKind.ObjectLiteralExpression) {\n // Case: export default {...}\n configObject = expression.asKind(SyntaxKind.ObjectLiteralExpression);\n } else if (expression.getKind() === SyntaxKind.Identifier) {\n // Case: const config = {...}; export default config;\n const identifier = expression.asKind(SyntaxKind.Identifier);\n const definitions = identifier?.getDefinitions();\n\n if (definitions && definitions.length > 0) {\n const node = definitions[0].getDeclarationNode();\n\n if (node?.getKind() === SyntaxKind.VariableDeclaration) {\n const init = node\n .asKind(SyntaxKind.VariableDeclaration)\n ?.getInitializer();\n\n if (init?.getKind() === SyntaxKind.ObjectLiteralExpression) {\n configObject = init.asKind(SyntaxKind.ObjectLiteralExpression);\n }\n }\n }\n }\n }\n\n // Case: module.exports = {...}\n if (!configObject) {\n const expressionStatements = sourceFile.getStatements();\n for (const statement of expressionStatements) {\n if (statement.getKind() === SyntaxKind.ExpressionStatement) {\n const expr = statement\n .asKind(SyntaxKind.ExpressionStatement)\n ?.getExpression();\n\n if (expr?.getKind() === SyntaxKind.BinaryExpression) {\n const binary = expr.asKind(SyntaxKind.BinaryExpression);\n\n if (\n binary?.getLeft().getText() === 'module.exports' &&\n binary.getOperatorToken().getKind() === SyntaxKind.EqualsToken\n ) {\n const right = binary.getRight();\n\n if (right.getKind() === SyntaxKind.ObjectLiteralExpression) {\n configObject = right.asKind(SyntaxKind.ObjectLiteralExpression);\n } else if (right.getKind() === SyntaxKind.CallExpression) {\n // Case: module.exports = defineConfig({...})\n const call = right.asKind(SyntaxKind.CallExpression);\n\n if (call?.getExpression().getText() === 'defineConfig') {\n const arg = call.getArguments()[0];\n\n if (arg?.getKind() === SyntaxKind.ObjectLiteralExpression) {\n configObject = arg.asKind(SyntaxKind.ObjectLiteralExpression);\n }\n }\n } else if (right.getKind() === SyntaxKind.Identifier) {\n // Case: const config = {...}; module.exports = config;\n const identifier = right.asKind(SyntaxKind.Identifier);\n const definitions = identifier?.getDefinitions();\n\n if (definitions && definitions.length > 0) {\n const node = definitions[0].getDeclarationNode();\n\n if (node?.getKind() === SyntaxKind.VariableDeclaration) {\n const init = node\n .asKind(SyntaxKind.VariableDeclaration)\n ?.getInitializer();\n\n if (init?.getKind() === SyntaxKind.ObjectLiteralExpression) {\n configObject = init.asKind(\n SyntaxKind.ObjectLiteralExpression\n );\n }\n }\n }\n }\n }\n }\n }\n }\n }\n\n // 3. Update plugins array\n if (configObject) {\n let pluginsProp = configObject.getProperty('plugins');\n\n if (!pluginsProp) {\n configObject.addPropertyAssignment({\n name: 'plugins',\n initializer: '[]',\n });\n pluginsProp = configObject.getProperty('plugins');\n }\n\n if (pluginsProp?.getKind() === SyntaxKind.PropertyAssignment) {\n const initializer = pluginsProp\n .asKind(SyntaxKind.PropertyAssignment)\n ?.getInitializer();\n\n if (initializer?.getKind() === SyntaxKind.ArrayLiteralExpression) {\n const array = initializer.asKind(SyntaxKind.ArrayLiteralExpression);\n const hasIntlayer = array\n ?.getElements()\n .some((el) => el.getText().includes('intlayer('));\n\n if (!hasIntlayer) {\n array?.addElement('intlayer()');\n }\n }\n }\n }\n\n return sourceFile.getFullText();\n};\n\n/**\n * Updates a Next.js configuration file to wrap the export with withIntlayer.\n * @param content The content of the next.config file\n * @param extension The file extension (ts, js, mjs, cjs)\n * @returns The updated content\n */\nexport const updateNextConfig = (\n content: string,\n extension: string\n): string => {\n const project = new Project({ useInMemoryFileSystem: true });\n const sourceFile = project.createSourceFile(\n `next.config.${extension}`,\n content\n );\n\n const isCJSFile = isCJS(content, extension);\n\n // 1. Add import if missing\n const hasIntlayerImport = isModuleImported(\n sourceFile,\n 'next-intlayer/server'\n );\n\n if (!hasIntlayerImport) {\n if (isCJSFile) {\n sourceFile.insertVariableStatement(0, {\n declarationKind: 'const' as any,\n declarations: [\n {\n name: '{ withIntlayer }',\n initializer: 'require(\"next-intlayer/server\")',\n },\n ],\n });\n } else {\n sourceFile.addImportDeclaration({\n moduleSpecifier: 'next-intlayer/server',\n namedImports: ['withIntlayer'],\n });\n }\n }\n\n // 2. Wrap export\n let updated = false;\n\n // Case: export default ...\n const exportDefault = sourceFile.getExportAssignment(\n (e) => !e.isExportEquals()\n );\n if (exportDefault) {\n const expression = exportDefault.getExpression();\n\n if (!expression.getText().includes('withIntlayer')) {\n exportDefault.setExpression(`withIntlayer(${expression.getText()})`);\n updated = true;\n }\n }\n\n // Case: module.exports = ...\n if (!updated) {\n const expressionStatements = sourceFile.getStatements();\n for (const statement of expressionStatements) {\n if (statement.getKind() === SyntaxKind.ExpressionStatement) {\n const expr = statement\n .asKind(SyntaxKind.ExpressionStatement)\n ?.getExpression();\n\n if (expr?.getKind() === SyntaxKind.BinaryExpression) {\n const binary = expr.asKind(SyntaxKind.BinaryExpression);\n\n if (\n binary?.getLeft().getText() === 'module.exports' &&\n binary.getOperatorToken().getKind() === SyntaxKind.EqualsToken\n ) {\n const right = binary.getRight();\n\n if (!right.getText().includes('withIntlayer')) {\n right.replaceWithText(`withIntlayer(${right.getText()})`);\n updated = true;\n }\n }\n }\n }\n }\n }\n\n return sourceFile.getFullText();\n};\n"],"mappings":"6IAUA,MAAM,GACJ,EACA,IACY,CACZ,IAAM,EAAY,EACf,uBAAuB,CACvB,KAAM,GAAM,EAAE,yBAAyB,GAAK,EAAW,CAEpD,EAAa,EAChB,qBAAqBA,EAAAA,WAAW,eAAe,CAC/C,KAAM,GACc,EAAE,eAAe,CAEvB,SAAS,GAAK,WACzB,EACG,cAAc,CAAC,IACd,OAAOA,EAAAA,WAAW,cAAc,EAChC,iBAAiB,GAAK,EAE5B,CAEJ,OAAO,GAAa,GAMhB,GAAS,EAAiB,IAC1B,IAAc,MAAc,GAC5B,CAAC,MAAO,KAAK,CAAC,SAAS,EAAU,CAAS,GAG5C,EAAQ,SAAS,iBAAiB,EAClC,CAAC,EAAQ,SAAS,UAAU,EAC5B,CAAC,EAAQ,SAAS,UAAU,CAUnB,GACX,EACA,IACW,CAEX,IAAM,EADU,IAAIC,EAAAA,QAAQ,CAAE,sBAAuB,GAAM,CAAC,CACjC,iBACzB,eAA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AA,WAAW,iBAAiB,CAEvD,GACE,GAAQ,SAAS,CAAC,SAAS,GAAK,kBAChC,EAAO,kBAAkB,CAAC,SAAS,GAAKA,EAAAA,WAAW,YACnD,CACA,IAAM,EAAQ,EAAO,UAAU,CAE1B,EAAM,SAAS,CAAC,SAAS,eAAe,GAC3C,EAAM,gBAAgB,gBAAgB,EAAM,SAAS,CAAC,GAAG,CACzD,EAAU,OAQtB,OAAO,EAAW,aAAa"}
@@ -1,31 +1,2 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
3
- let node_fs_promises = require("node:fs/promises");
4
- let node_path = require("node:path");
5
-
6
- //#region src/init/utils/fileSystem.ts
7
- /**
8
- * Helper to check if a file exists
9
- */
10
- const exists = async (rootDir, filePath) => {
11
- try {
12
- await (0, node_fs_promises.access)((0, node_path.join)(rootDir, filePath));
13
- return true;
14
- } catch {
15
- return false;
16
- }
17
- };
18
- /**
19
- * Helper to read a file
20
- */
21
- const readFileFromRoot = async (rootDir, filePath) => await (0, node_fs_promises.readFile)((0, node_path.join)(rootDir, filePath), "utf8");
22
- /**
23
- * Helper to write a file
24
- */
25
- const writeFileToRoot = async (rootDir, filePath, content) => await (0, node_fs_promises.writeFile)((0, node_path.join)(rootDir, filePath), content, "utf8");
26
-
27
- //#endregion
28
- exports.exists = exists;
29
- exports.readFileFromRoot = readFileFromRoot;
30
- exports.writeFileToRoot = writeFileToRoot;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../../_virtual/_rolldown/runtime.cjs`);let e=require(`node:fs/promises`),t=require(`node:path`);const n=async(n,r)=>{try{return await(0,e.access)((0,t.join)(n,r)),!0}catch{return!1}},r=async(n,r)=>await(0,e.readFile)((0,t.join)(n,r),`utf8`),i=async(n,r,i)=>await(0,e.writeFile)((0,t.join)(n,r),i,`utf8`);exports.exists=n,exports.readFileFromRoot=r,exports.writeFileToRoot=i;
31
2
  //# sourceMappingURL=fileSystem.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"fileSystem.cjs","names":[],"sources":["../../../../src/init/utils/fileSystem.ts"],"sourcesContent":["import { access, readFile, writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\n\n/**\n * Helper to check if a file exists\n */\nexport const exists = async (rootDir: string, filePath: string) => {\n try {\n await access(join(rootDir, filePath));\n return true;\n } catch {\n return false;\n }\n};\n\n/**\n * Helper to read a file\n */\nexport const readFileFromRoot = async (rootDir: string, filePath: string) =>\n await readFile(join(rootDir, filePath), 'utf8');\n\n/**\n * Helper to write a file\n */\nexport const writeFileToRoot = async (\n rootDir: string,\n filePath: string,\n content: string\n) => await writeFile(join(rootDir, filePath), content, 'utf8');\n"],"mappings":";;;;;;;;;AAMA,MAAa,SAAS,OAAO,SAAiB,aAAqB;AACjE,KAAI;AACF,yDAAkB,SAAS,SAAS,CAAC;AACrC,SAAO;SACD;AACN,SAAO;;;;;;AAOX,MAAa,mBAAmB,OAAO,SAAiB,aACtD,yDAAoB,SAAS,SAAS,EAAE,OAAO;;;;AAKjD,MAAa,kBAAkB,OAC7B,SACA,UACA,YACG,0DAAqB,SAAS,SAAS,EAAE,SAAS,OAAO"}
1
+ {"version":3,"file":"fileSystem.cjs","names":[],"sources":["../../../../src/init/utils/fileSystem.ts"],"sourcesContent":["import { access, readFile, writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\n\n/**\n * Helper to check if a file exists\n */\nexport const exists = async (rootDir: string, filePath: string) => {\n try {\n await access(join(rootDir, filePath));\n return true;\n } catch {\n return false;\n }\n};\n\n/**\n * Helper to read a file\n */\nexport const readFileFromRoot = async (rootDir: string, filePath: string) =>\n await readFile(join(rootDir, filePath), 'utf8');\n\n/**\n * Helper to write a file\n */\nexport const writeFileToRoot = async (\n rootDir: string,\n filePath: string,\n content: string\n) => await writeFile(join(rootDir, filePath), content, 'utf8');\n"],"mappings":"4KAMA,MAAa,EAAS,MAAO,EAAiB,IAAqB,CACjE,GAAI,CAEF,OADA,MAAA,EAAA,EAAA,SAAA,EAAA,EAAA,MAAkB,EAAS,EAAS,CAAC,CAC9B,QACD,CACN,MAAO,KAOE,EAAmB,MAAO,EAAiB,IACtD,MAAA,EAAA,EAAA,WAAA,EAAA,EAAA,MAAoB,EAAS,EAAS,CAAE,OAAO,CAKpC,EAAkB,MAC7B,EACA,EACA,IACG,MAAA,EAAA,EAAA,YAAA,EAAA,EAAA,MAAqB,EAAS,EAAS,CAAE,EAAS,OAAO"}
@@ -1,13 +1 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_init_utils_configManipulation = require('./configManipulation.cjs');
3
- const require_init_utils_fileSystem = require('./fileSystem.cjs');
4
- const require_init_utils_jsonParser = require('./jsonParser.cjs');
5
- const require_init_utils_tsConfig = require('./tsConfig.cjs');
6
-
7
- exports.exists = require_init_utils_fileSystem.exists;
8
- exports.findTsConfigFiles = require_init_utils_tsConfig.findTsConfigFiles;
9
- exports.parseJSONWithComments = require_init_utils_jsonParser.parseJSONWithComments;
10
- exports.readFileFromRoot = require_init_utils_fileSystem.readFileFromRoot;
11
- exports.updateNextConfig = require_init_utils_configManipulation.updateNextConfig;
12
- exports.updateViteConfig = require_init_utils_configManipulation.updateViteConfig;
13
- exports.writeFileToRoot = require_init_utils_fileSystem.writeFileToRoot;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./configManipulation.cjs`),t=require(`./fileSystem.cjs`),n=require(`./jsonParser.cjs`),r=require(`./tsConfig.cjs`);exports.exists=t.exists,exports.findTsConfigFiles=r.findTsConfigFiles,exports.parseJSONWithComments=n.parseJSONWithComments,exports.readFileFromRoot=t.readFileFromRoot,exports.updateNextConfig=e.updateNextConfig,exports.updateViteConfig=e.updateViteConfig,exports.writeFileToRoot=t.writeFileToRoot;
@@ -1,43 +1,4 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
-
3
- //#region src/init/utils/jsonParser.ts
4
- /**
5
- * Helper to parse JSON that may contain comments (tsconfig allows comments)
6
- */
7
- const parseJSONWithComments = (jsonString) => {
8
- try {
9
- return JSON.parse(jsonString);
10
- } catch {}
11
- const cleanedLines = jsonString.split("\n").map((line) => {
12
- let inString = false;
13
- let result = "";
14
- for (let i = 0; i < line.length; i++) {
15
- const char = line[i];
16
- const nextChar = line[i + 1];
17
- if (char === "\"" && (i === 0 || line[i - 1] !== "\\")) {
18
- inString = !inString;
19
- result += char;
20
- continue;
21
- }
22
- if (inString) {
23
- result += char;
24
- continue;
25
- }
26
- if (char === "/" && nextChar === "/") break;
27
- if (char === "/" && nextChar === "*") {
28
- const endIndex = line.indexOf("*/", i + 2);
29
- if (endIndex !== -1) {
30
- i = endIndex + 1;
31
- continue;
32
- }
33
- }
34
- result += char;
35
- }
36
- return result;
37
- });
38
- return JSON.parse(cleanedLines.join("\n"));
39
- };
40
-
41
- //#endregion
42
- exports.parseJSONWithComments = parseJSONWithComments;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=e=>{try{return JSON.parse(e)}catch{}let t=e.split(`
2
+ `).map(e=>{let t=!1,n=``;for(let r=0;r<e.length;r++){let i=e[r],a=e[r+1];if(i===`"`&&(r===0||e[r-1]!==`\\`)){t=!t,n+=i;continue}if(t){n+=i;continue}if(i===`/`&&a===`/`)break;if(i===`/`&&a===`*`){let t=e.indexOf(`*/`,r+2);if(t!==-1){r=t+1;continue}}n+=i}return n});return JSON.parse(t.join(`
3
+ `))};exports.parseJSONWithComments=e;
43
4
  //# sourceMappingURL=jsonParser.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"jsonParser.cjs","names":[],"sources":["../../../../src/init/utils/jsonParser.ts"],"sourcesContent":["/**\n * Helper to parse JSON that may contain comments (tsconfig allows comments)\n */\nexport const parseJSONWithComments = (jsonString: string) => {\n // First, try parsing as-is (most tsconfig files don't have comments)\n try {\n return JSON.parse(jsonString);\n } catch {\n // If that fails, try stripping comments\n // Note: This simple approach removes comments line by line to avoid\n // matching glob patterns like /* and */ that appear in paths\n }\n\n // Process line by line to safely remove comments\n const lines = jsonString.split('\\n');\n const cleanedLines = lines.map((line) => {\n // Track if we're inside a string\n let inString = false;\n let result = '';\n\n for (let i = 0; i < line.length; i++) {\n const char = line[i];\n const nextChar = line[i + 1];\n\n // Handle string boundaries (accounting for escaped quotes)\n if (char === '\"' && (i === 0 || line[i - 1] !== '\\\\')) {\n inString = !inString;\n result += char;\n continue;\n }\n\n // If we're inside a string, keep the character\n if (inString) {\n result += char;\n continue;\n }\n\n // Check for single-line comment outside of strings\n if (char === '/' && nextChar === '/') {\n // Rest of line is a comment, stop here\n break;\n }\n\n // Check for multi-line comment start (/* ... */)\n // For simplicity, we only handle single-line /* */ comments here\n if (char === '/' && nextChar === '*') {\n const endIndex = line.indexOf('*/', i + 2);\n if (endIndex !== -1) {\n // Skip the comment\n i = endIndex + 1;\n continue;\n }\n }\n\n result += char;\n }\n\n return result;\n });\n\n return JSON.parse(cleanedLines.join('\\n'));\n};\n"],"mappings":";;;;;;AAGA,MAAa,yBAAyB,eAAuB;AAE3D,KAAI;AACF,SAAO,KAAK,MAAM,WAAW;SACvB;CAQR,MAAM,eADQ,WAAW,MAAM,KAAK,CACT,KAAK,SAAS;EAEvC,IAAI,WAAW;EACf,IAAI,SAAS;AAEb,OAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;GACpC,MAAM,OAAO,KAAK;GAClB,MAAM,WAAW,KAAK,IAAI;AAG1B,OAAI,SAAS,SAAQ,MAAM,KAAK,KAAK,IAAI,OAAO,OAAO;AACrD,eAAW,CAAC;AACZ,cAAU;AACV;;AAIF,OAAI,UAAU;AACZ,cAAU;AACV;;AAIF,OAAI,SAAS,OAAO,aAAa,IAE/B;AAKF,OAAI,SAAS,OAAO,aAAa,KAAK;IACpC,MAAM,WAAW,KAAK,QAAQ,MAAM,IAAI,EAAE;AAC1C,QAAI,aAAa,IAAI;AAEnB,SAAI,WAAW;AACf;;;AAIJ,aAAU;;AAGZ,SAAO;GACP;AAEF,QAAO,KAAK,MAAM,aAAa,KAAK,KAAK,CAAC"}
1
+ {"version":3,"file":"jsonParser.cjs","names":[],"sources":["../../../../src/init/utils/jsonParser.ts"],"sourcesContent":["/**\n * Helper to parse JSON that may contain comments (tsconfig allows comments)\n */\nexport const parseJSONWithComments = (jsonString: string) => {\n // First, try parsing as-is (most tsconfig files don't have comments)\n try {\n return JSON.parse(jsonString);\n } catch {\n // If that fails, try stripping comments\n // Note: This simple approach removes comments line by line to avoid\n // matching glob patterns like /* and */ that appear in paths\n }\n\n // Process line by line to safely remove comments\n const lines = jsonString.split('\\n');\n const cleanedLines = lines.map((line) => {\n // Track if we're inside a string\n let inString = false;\n let result = '';\n\n for (let i = 0; i < line.length; i++) {\n const char = line[i];\n const nextChar = line[i + 1];\n\n // Handle string boundaries (accounting for escaped quotes)\n if (char === '\"' && (i === 0 || line[i - 1] !== '\\\\')) {\n inString = !inString;\n result += char;\n continue;\n }\n\n // If we're inside a string, keep the character\n if (inString) {\n result += char;\n continue;\n }\n\n // Check for single-line comment outside of strings\n if (char === '/' && nextChar === '/') {\n // Rest of line is a comment, stop here\n break;\n }\n\n // Check for multi-line comment start (/* ... */)\n // For simplicity, we only handle single-line /* */ comments here\n if (char === '/' && nextChar === '*') {\n const endIndex = line.indexOf('*/', i + 2);\n if (endIndex !== -1) {\n // Skip the comment\n i = endIndex + 1;\n continue;\n }\n }\n\n result += char;\n }\n\n return result;\n });\n\n return JSON.parse(cleanedLines.join('\\n'));\n};\n"],"mappings":"mEAGA,MAAa,EAAyB,GAAuB,CAE3D,GAAI,CACF,OAAO,KAAK,MAAM,EAAW,MACvB,EAQR,IAAM,EADQ,EAAW,MAAM;EAAK,CACT,IAAK,GAAS,CAEvC,IAAI,EAAW,GACX,EAAS,GAEb,IAAK,IAAI,EAAI,EAAG,EAAI,EAAK,OAAQ,IAAK,CACpC,IAAM,EAAO,EAAK,GACZ,EAAW,EAAK,EAAI,GAG1B,GAAI,IAAS,MAAQ,IAAM,GAAK,EAAK,EAAI,KAAO,MAAO,CACrD,EAAW,CAAC,EACZ,GAAU,EACV,SAIF,GAAI,EAAU,CACZ,GAAU,EACV,SAIF,GAAI,IAAS,KAAO,IAAa,IAE/B,MAKF,GAAI,IAAS,KAAO,IAAa,IAAK,CACpC,IAAM,EAAW,EAAK,QAAQ,KAAM,EAAI,EAAE,CAC1C,GAAI,IAAa,GAAI,CAEnB,EAAI,EAAW,EACf,UAIJ,GAAU,EAGZ,OAAO,GACP,CAEF,OAAO,KAAK,MAAM,EAAa,KAAK;EAAK,CAAC"}
@@ -1,19 +1,2 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
3
- let node_fs_promises = require("node:fs/promises");
4
-
5
- //#region src/init/utils/tsConfig.ts
6
- /**
7
- * Helper to find all tsconfig files (tsconfig.json, tsconfig.*.json)
8
- */
9
- const findTsConfigFiles = async (rootDir) => {
10
- try {
11
- return (await (0, node_fs_promises.readdir)(rootDir)).filter((file) => file === "tsconfig.json" || /^tsconfig\..+\.json$/.test(file));
12
- } catch {
13
- return [];
14
- }
15
- };
16
-
17
- //#endregion
18
- exports.findTsConfigFiles = findTsConfigFiles;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../../_virtual/_rolldown/runtime.cjs`);let e=require(`node:fs/promises`);const t=async t=>{try{return(await(0,e.readdir)(t)).filter(e=>e===`tsconfig.json`||/^tsconfig\..+\.json$/.test(e))}catch{return[]}};exports.findTsConfigFiles=t;
19
2
  //# sourceMappingURL=tsConfig.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"tsConfig.cjs","names":[],"sources":["../../../../src/init/utils/tsConfig.ts"],"sourcesContent":["import { readdir } from 'node:fs/promises';\n\n/**\n * Helper to find all tsconfig files (tsconfig.json, tsconfig.*.json)\n */\nexport const findTsConfigFiles = async (rootDir: string): Promise<string[]> => {\n try {\n const files = await readdir(rootDir);\n\n return files.filter(\n (file) => file === 'tsconfig.json' || /^tsconfig\\..+\\.json$/.test(file)\n );\n } catch {\n return [];\n }\n};\n"],"mappings":";;;;;;;;AAKA,MAAa,oBAAoB,OAAO,YAAuC;AAC7E,KAAI;AAGF,UAFc,oCAAc,QAAQ,EAEvB,QACV,SAAS,SAAS,mBAAmB,uBAAuB,KAAK,KAAK,CACxE;SACK;AACN,SAAO,EAAE"}
1
+ {"version":3,"file":"tsConfig.cjs","names":[],"sources":["../../../../src/init/utils/tsConfig.ts"],"sourcesContent":["import { readdir } from 'node:fs/promises';\n\n/**\n * Helper to find all tsconfig files (tsconfig.json, tsconfig.*.json)\n */\nexport const findTsConfigFiles = async (rootDir: string): Promise<string[]> => {\n try {\n const files = await readdir(rootDir);\n\n return files.filter(\n (file) => file === 'tsconfig.json' || /^tsconfig\\..+\\.json$/.test(file)\n );\n } catch {\n return [];\n }\n};\n"],"mappings":"qJAKA,MAAa,EAAoB,KAAO,IAAuC,CAC7E,GAAI,CAGF,OAFc,MAAA,EAAA,EAAA,SAAc,EAAQ,EAEvB,OACV,GAAS,IAAS,iBAAmB,uBAAuB,KAAK,EAAK,CACxE,MACK,CACN,MAAO,EAAE"}
@@ -1,39 +1,2 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
- const require__utils_asset = require('../_virtual/_utils_asset.cjs');
4
- let _intlayer_config = require("@intlayer/config");
5
- let node_fs_promises = require("node:fs/promises");
6
- let node_path = require("node:path");
7
-
8
- //#region src/initConfig/index.ts
9
- /**
10
- * UTILITIES
11
- */
12
- const rootDir = process.cwd();
13
- const writeFileToRoot = async (filePath, content) => await (0, node_fs_promises.writeFile)((0, node_path.join)(rootDir, filePath), content, "utf8");
14
- const getTemplatePath = (format) => {
15
- switch (format) {
16
- case "ts": return "./templates/ts.txt";
17
- case "cjs": return "./templates/cjs.txt";
18
- case "mjs": return "./templates/mjs.txt";
19
- case "js": return "./templates/mjs.txt";
20
- case "json": return "./templates/json.txt";
21
- default: return "./templates/ts.txt";
22
- }
23
- };
24
- /**
25
- * Initialize the Intlayer configuration file
26
- */
27
- const initConfig = async (format, baseDir) => {
28
- const { configurationFilePath } = (0, _intlayer_config.searchConfigurationFile)(baseDir);
29
- if (configurationFilePath) {
30
- (0, _intlayer_config.logger)(`${_intlayer_config.v} ${(0, _intlayer_config.colorizePath)((0, node_path.relative)(baseDir, configurationFilePath))} already exists`);
31
- return;
32
- }
33
- await writeFileToRoot(format, require__utils_asset.readAsset(getTemplatePath(format.split(".").pop())));
34
- (0, _intlayer_config.logger)(`Created ${format}`);
35
- };
36
-
37
- //#endregion
38
- exports.initConfig = initConfig;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`../_virtual/_utils_asset.cjs`);let t=require(`@intlayer/config/node`),n=require(`node:fs/promises`),r=require(`node:path`),i=require(`@intlayer/config/logger`);const a=process.cwd(),o=async(e,t)=>await(0,n.writeFile)((0,r.join)(a,e),t,`utf8`),s=e=>{switch(e){case`ts`:return`./templates/ts.txt`;case`cjs`:return`./templates/cjs.txt`;case`mjs`:return`./templates/mjs.txt`;case`js`:return`./templates/mjs.txt`;case`json`:return`./templates/json.txt`;default:return`./templates/ts.txt`}},c=async(n,a)=>{let{configurationFilePath:c}=(0,t.searchConfigurationFile)(a);if(c){(0,i.logger)(`${i.v} ${(0,i.colorizePath)((0,r.relative)(a,c))} already exists`);return}await o(n,e.readAsset(s(n.split(`.`).pop()))),(0,i.logger)(`Created ${n}`)};exports.initConfig=c;
39
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["v","readAsset"],"sources":["../../../src/initConfig/index.ts"],"sourcesContent":["import { writeFile } from 'node:fs/promises';\nimport { join, relative } from 'node:path';\nimport { readAsset } from 'utils:asset';\nimport {\n colorizePath,\n type configurationFilesCandidates,\n logger,\n searchConfigurationFile,\n v,\n} from '@intlayer/config';\n\n/**\n * UTILITIES\n */\nconst rootDir = process.cwd();\n\n// Helper to write a file\nconst writeFileToRoot = async (filePath: string, content: string) =>\n await writeFile(join(rootDir, filePath), content, 'utf8');\n\ntype ConfigFormat = 'ts' | 'cjs' | 'mjs' | 'js' | 'json';\n\nconst getTemplatePath = (format: ConfigFormat) => {\n switch (format) {\n case 'ts':\n return './templates/ts.txt';\n case 'cjs':\n return './templates/cjs.txt';\n case 'mjs':\n return './templates/mjs.txt';\n case 'js':\n return './templates/mjs.txt';\n case 'json':\n return './templates/json.txt';\n default:\n return './templates/ts.txt';\n }\n};\n\n/**\n * Initialize the Intlayer configuration file\n */\nexport const initConfig = async (\n format: (typeof configurationFilesCandidates)[number],\n baseDir: string\n) => {\n // Search for configuration file\n const { configurationFilePath } = searchConfigurationFile(baseDir);\n\n // return if the configuration file is found\n if (configurationFilePath) {\n const relativePath = relative(baseDir, configurationFilePath);\n logger(`${v} ${colorizePath(relativePath)} already exists`);\n return;\n }\n\n // Extract the format from the filename (e.g. 'intlayer.config.ts' -> 'ts')\n const extension = format.split('.').pop() as ConfigFormat;\n\n const templatePath = getTemplatePath(extension);\n const configContent = readAsset(templatePath);\n\n await writeFileToRoot(format, configContent);\n logger(`Created ${format}`);\n};\n"],"mappings":";;;;;;;;;;;AAcA,MAAM,UAAU,QAAQ,KAAK;AAG7B,MAAM,kBAAkB,OAAO,UAAkB,YAC/C,0DAAqB,SAAS,SAAS,EAAE,SAAS,OAAO;AAI3D,MAAM,mBAAmB,WAAyB;AAChD,SAAQ,QAAR;EACE,KAAK,KACH,QAAO;EACT,KAAK,MACH,QAAO;EACT,KAAK,MACH,QAAO;EACT,KAAK,KACH,QAAO;EACT,KAAK,OACH,QAAO;EACT,QACE,QAAO;;;;;;AAOb,MAAa,aAAa,OACxB,QACA,YACG;CAEH,MAAM,EAAE,wEAAkD,QAAQ;AAGlE,KAAI,uBAAuB;AAEzB,+BAAO,GAAGA,mBAAE,8DADkB,SAAS,sBAAsB,CACpB,CAAC,iBAAiB;AAC3D;;AASF,OAAM,gBAAgB,QAFAC,+BADD,gBAFH,OAAO,MAAM,IAAI,CAAC,KAAK,CAEM,CACF,CAED;AAC5C,8BAAO,WAAW,SAAS"}
1
+ {"version":3,"file":"index.cjs","names":["v","readAsset"],"sources":["../../../src/initConfig/index.ts"],"sourcesContent":["import { writeFile } from 'node:fs/promises';\nimport { join, relative } from 'node:path';\nimport { readAsset } from 'utils:asset';\nimport { colorizePath, logger, v } from '@intlayer/config/logger';\nimport {\n type configurationFilesCandidates,\n searchConfigurationFile,\n} from '@intlayer/config/node';\n\n/**\n * UTILITIES\n */\nconst rootDir = process.cwd();\n\n// Helper to write a file\nconst writeFileToRoot = async (filePath: string, content: string) =>\n await writeFile(join(rootDir, filePath), content, 'utf8');\n\ntype ConfigFormat = 'ts' | 'cjs' | 'mjs' | 'js' | 'json';\n\nconst getTemplatePath = (format: ConfigFormat) => {\n switch (format) {\n case 'ts':\n return './templates/ts.txt';\n case 'cjs':\n return './templates/cjs.txt';\n case 'mjs':\n return './templates/mjs.txt';\n case 'js':\n return './templates/mjs.txt';\n case 'json':\n return './templates/json.txt';\n default:\n return './templates/ts.txt';\n }\n};\n\n/**\n * Initialize the Intlayer configuration file\n */\nexport const initConfig = async (\n format: (typeof configurationFilesCandidates)[number],\n baseDir: string\n) => {\n // Search for configuration file\n const { configurationFilePath } = searchConfigurationFile(baseDir);\n\n // return if the configuration file is found\n if (configurationFilePath) {\n const relativePath = relative(baseDir, configurationFilePath);\n logger(`${v} ${colorizePath(relativePath)} already exists`);\n return;\n }\n\n // Extract the format from the filename (e.g. 'intlayer.config.ts' -> 'ts')\n const extension = format.split('.').pop() as ConfigFormat;\n\n const templatePath = getTemplatePath(extension);\n const configContent = readAsset(templatePath);\n\n await writeFileToRoot(format, configContent);\n logger(`Created ${format}`);\n};\n"],"mappings":"iSAYA,MAAM,EAAU,QAAQ,KAAK,CAGvB,EAAkB,MAAO,EAAkB,IAC/C,MAAA,EAAA,EAAA,YAAA,EAAA,EAAA,MAAqB,EAAS,EAAS,CAAE,EAAS,OAAO,CAIrD,EAAmB,GAAyB,CAChD,OAAQ,EAAR,CACE,IAAK,KACH,MAAO,qBACT,IAAK,MACH,MAAO,sBACT,IAAK,MACH,MAAO,sBACT,IAAK,KACH,MAAO,sBACT,IAAK,OACH,MAAO,uBACT,QACE,MAAO,uBAOA,EAAa,MACxB,EACA,IACG,CAEH,GAAM,CAAE,0BAAA,EAAA,EAAA,yBAAkD,EAAQ,CAGlE,GAAI,EAAuB,EAEzB,EAAA,EAAA,QAAO,GAAGA,EAAAA,EAAE,IAAA,EAAA,EAAA,eAAA,EAAA,EAAA,UADkB,EAAS,EAAsB,CACpB,CAAC,iBAAiB,CAC3D,OASF,MAAM,EAAgB,EAFAC,EAAAA,UADD,EAFH,EAAO,MAAM,IAAI,CAAC,KAAK,CAEM,CACF,CAED,EAC5C,EAAA,EAAA,QAAO,WAAW,IAAS"}