@intlayer/cli 8.4.4 → 8.4.6

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 (305) hide show
  1. package/dist/cjs/IntlayerEventListener.cjs +186 -1
  2. package/dist/cjs/IntlayerEventListener.cjs.map +1 -1
  3. package/dist/cjs/_virtual/_rolldown/runtime.cjs +29 -0
  4. package/dist/cjs/_virtual/_utils_asset.cjs +98 -0
  5. package/dist/cjs/auth/login.cjs +90 -2
  6. package/dist/cjs/auth/login.cjs.map +1 -1
  7. package/dist/cjs/build.cjs +30 -1
  8. package/dist/cjs/build.cjs.map +1 -1
  9. package/dist/cjs/ci.cjs +76 -1
  10. package/dist/cjs/ci.cjs.map +1 -1
  11. package/dist/cjs/cli.cjs +485 -1
  12. package/dist/cjs/cli.cjs.map +1 -1
  13. package/dist/cjs/config.cjs +15 -1
  14. package/dist/cjs/config.cjs.map +1 -1
  15. package/dist/cjs/editor.cjs +50 -1
  16. package/dist/cjs/editor.cjs.map +1 -1
  17. package/dist/cjs/extract.cjs +108 -1
  18. package/dist/cjs/extract.cjs.map +1 -1
  19. package/dist/cjs/fill/deepMergeContent.cjs +27 -1
  20. package/dist/cjs/fill/deepMergeContent.cjs.map +1 -1
  21. package/dist/cjs/fill/fill.cjs +89 -1
  22. package/dist/cjs/fill/fill.cjs.map +1 -1
  23. package/dist/cjs/fill/formatAutoFilledFilePath.cjs +32 -1
  24. package/dist/cjs/fill/formatAutoFilledFilePath.cjs.map +1 -1
  25. package/dist/cjs/fill/formatFillData.cjs +91 -1
  26. package/dist/cjs/fill/formatFillData.cjs.map +1 -1
  27. package/dist/cjs/fill/getAvailableLocalesInDictionary.cjs +26 -1
  28. package/dist/cjs/fill/getAvailableLocalesInDictionary.cjs.map +1 -1
  29. package/dist/cjs/fill/getFilterMissingContentPerLocale.cjs +51 -1
  30. package/dist/cjs/fill/getFilterMissingContentPerLocale.cjs.map +1 -1
  31. package/dist/cjs/fill/index.cjs +6 -1
  32. package/dist/cjs/fill/listTranslationsTasks.cjs +72 -1
  33. package/dist/cjs/fill/listTranslationsTasks.cjs.map +1 -1
  34. package/dist/cjs/fill/translateDictionary.cjs +241 -1
  35. package/dist/cjs/fill/translateDictionary.cjs.map +1 -1
  36. package/dist/cjs/fill/writeFill.cjs +53 -1
  37. package/dist/cjs/fill/writeFill.cjs.map +1 -1
  38. package/dist/cjs/getTargetDictionary.cjs +36 -1
  39. package/dist/cjs/getTargetDictionary.cjs.map +1 -1
  40. package/dist/cjs/index.cjs +44 -1
  41. package/dist/cjs/init.cjs +22 -1
  42. package/dist/cjs/init.cjs.map +1 -1
  43. package/dist/cjs/initMCP.cjs +69 -1
  44. package/dist/cjs/initMCP.cjs.map +1 -1
  45. package/dist/cjs/initSkills.cjs +93 -1
  46. package/dist/cjs/initSkills.cjs.map +1 -1
  47. package/dist/cjs/listContentDeclaration.cjs +42 -1
  48. package/dist/cjs/listContentDeclaration.cjs.map +1 -1
  49. package/dist/cjs/listProjects.cjs +28 -1
  50. package/dist/cjs/listProjects.cjs.map +1 -1
  51. package/dist/cjs/liveSync.cjs +153 -8
  52. package/dist/cjs/liveSync.cjs.map +1 -1
  53. package/dist/cjs/pull.cjs +153 -1
  54. package/dist/cjs/pull.cjs.map +1 -1
  55. package/dist/cjs/push/pullLog.cjs +105 -3
  56. package/dist/cjs/push/pullLog.cjs.map +1 -1
  57. package/dist/cjs/push/push.cjs +212 -1
  58. package/dist/cjs/push/push.cjs.map +1 -1
  59. package/dist/cjs/pushConfig.cjs +22 -1
  60. package/dist/cjs/pushConfig.cjs.map +1 -1
  61. package/dist/cjs/pushLog.cjs +86 -3
  62. package/dist/cjs/pushLog.cjs.map +1 -1
  63. package/dist/cjs/reviewDoc/reviewDoc.cjs +73 -1
  64. package/dist/cjs/reviewDoc/reviewDoc.cjs.map +1 -1
  65. package/dist/cjs/reviewDoc/reviewDocBlockAware.cjs +98 -1
  66. package/dist/cjs/reviewDoc/reviewDocBlockAware.cjs.map +1 -1
  67. package/dist/cjs/searchDoc.cjs +41 -1
  68. package/dist/cjs/searchDoc.cjs.map +1 -1
  69. package/dist/cjs/test/index.cjs +7 -1
  70. package/dist/cjs/test/listMissingTranslations.cjs +66 -1
  71. package/dist/cjs/test/listMissingTranslations.cjs.map +1 -1
  72. package/dist/cjs/test/test.cjs +56 -1
  73. package/dist/cjs/test/test.cjs.map +1 -1
  74. package/dist/cjs/translateDoc/index.cjs +9 -1
  75. package/dist/cjs/translateDoc/translateDoc.cjs +79 -1
  76. package/dist/cjs/translateDoc/translateDoc.cjs.map +1 -1
  77. package/dist/cjs/translateDoc/translateFile.cjs +106 -2
  78. package/dist/cjs/translateDoc/translateFile.cjs.map +1 -1
  79. package/dist/cjs/translateDoc/validation.cjs +49 -5
  80. package/dist/cjs/translateDoc/validation.cjs.map +1 -1
  81. package/dist/cjs/translation-alignment/alignBlocks.cjs +67 -1
  82. package/dist/cjs/translation-alignment/alignBlocks.cjs.map +1 -1
  83. package/dist/cjs/translation-alignment/computeSimilarity.cjs +25 -1
  84. package/dist/cjs/translation-alignment/computeSimilarity.cjs.map +1 -1
  85. package/dist/cjs/translation-alignment/fingerprintBlock.cjs +23 -1
  86. package/dist/cjs/translation-alignment/fingerprintBlock.cjs.map +1 -1
  87. package/dist/cjs/translation-alignment/index.cjs +22 -1
  88. package/dist/cjs/translation-alignment/mapChangedLinesToBlocks.cjs +18 -1
  89. package/dist/cjs/translation-alignment/mapChangedLinesToBlocks.cjs.map +1 -1
  90. package/dist/cjs/translation-alignment/normalizeBlock.cjs +22 -1
  91. package/dist/cjs/translation-alignment/normalizeBlock.cjs.map +1 -1
  92. package/dist/cjs/translation-alignment/pipeline.cjs +37 -1
  93. package/dist/cjs/translation-alignment/pipeline.cjs.map +1 -1
  94. package/dist/cjs/translation-alignment/planActions.cjs +46 -1
  95. package/dist/cjs/translation-alignment/planActions.cjs.map +1 -1
  96. package/dist/cjs/translation-alignment/rebuildDocument.cjs +49 -2
  97. package/dist/cjs/translation-alignment/rebuildDocument.cjs.map +1 -1
  98. package/dist/cjs/translation-alignment/segmentDocument.cjs +66 -5
  99. package/dist/cjs/translation-alignment/segmentDocument.cjs.map +1 -1
  100. package/dist/cjs/utils/calculateChunks.cjs +89 -2
  101. package/dist/cjs/utils/calculateChunks.cjs.map +1 -1
  102. package/dist/cjs/utils/checkAccess.cjs +83 -1
  103. package/dist/cjs/utils/checkAccess.cjs.map +1 -1
  104. package/dist/cjs/utils/checkConfigConsistency.cjs +16 -1
  105. package/dist/cjs/utils/checkConfigConsistency.cjs.map +1 -1
  106. package/dist/cjs/utils/checkFileModifiedRange.cjs +81 -1
  107. package/dist/cjs/utils/checkFileModifiedRange.cjs.map +1 -1
  108. package/dist/cjs/utils/checkLastUpdateTime.cjs +19 -1
  109. package/dist/cjs/utils/checkLastUpdateTime.cjs.map +1 -1
  110. package/dist/cjs/utils/chunkInference.cjs +45 -1
  111. package/dist/cjs/utils/chunkInference.cjs.map +1 -1
  112. package/dist/cjs/utils/fixChunkStartEndChars.cjs +27 -3
  113. package/dist/cjs/utils/fixChunkStartEndChars.cjs.map +1 -1
  114. package/dist/cjs/utils/formatTimeDiff.cjs +20 -1
  115. package/dist/cjs/utils/formatTimeDiff.cjs.map +1 -1
  116. package/dist/cjs/utils/getIsFileUpdatedRecently.cjs +16 -1
  117. package/dist/cjs/utils/getIsFileUpdatedRecently.cjs.map +1 -1
  118. package/dist/cjs/utils/getOutputFilePath.cjs +108 -1
  119. package/dist/cjs/utils/getOutputFilePath.cjs.map +1 -1
  120. package/dist/cjs/utils/getParentPackageJSON.cjs +20 -1
  121. package/dist/cjs/utils/getParentPackageJSON.cjs.map +1 -1
  122. package/dist/cjs/utils/listSpecialChars.cjs +54 -2
  123. package/dist/cjs/utils/listSpecialChars.cjs.map +1 -1
  124. package/dist/cjs/utils/mapChunksBetweenFiles.cjs +102 -1
  125. package/dist/cjs/utils/mapChunksBetweenFiles.cjs.map +1 -1
  126. package/dist/cjs/utils/openBrowser.cjs +19 -1
  127. package/dist/cjs/utils/openBrowser.cjs.map +1 -1
  128. package/dist/cjs/utils/reorderParagraphs.cjs +91 -3
  129. package/dist/cjs/utils/reorderParagraphs.cjs.map +1 -1
  130. package/dist/cjs/utils/setupAI.cjs +66 -1
  131. package/dist/cjs/utils/setupAI.cjs.map +1 -1
  132. package/dist/cjs/watch.cjs +47 -1
  133. package/dist/cjs/watch.cjs.map +1 -1
  134. package/dist/esm/IntlayerEventListener.mjs +183 -1
  135. package/dist/esm/IntlayerEventListener.mjs.map +1 -1
  136. package/dist/esm/_virtual/_rolldown/runtime.mjs +8 -0
  137. package/dist/esm/_virtual/_utils_asset.mjs +97 -0
  138. package/dist/esm/auth/login.mjs +86 -2
  139. package/dist/esm/auth/login.mjs.map +1 -1
  140. package/dist/esm/build.mjs +28 -1
  141. package/dist/esm/build.mjs.map +1 -1
  142. package/dist/esm/ci.mjs +74 -1
  143. package/dist/esm/ci.mjs.map +1 -1
  144. package/dist/esm/cli.mjs +482 -1
  145. package/dist/esm/cli.mjs.map +1 -1
  146. package/dist/esm/config.mjs +13 -1
  147. package/dist/esm/config.mjs.map +1 -1
  148. package/dist/esm/editor.mjs +50 -1
  149. package/dist/esm/editor.mjs.map +1 -0
  150. package/dist/esm/extract.mjs +104 -1
  151. package/dist/esm/extract.mjs.map +1 -1
  152. package/dist/esm/fill/deepMergeContent.mjs +25 -1
  153. package/dist/esm/fill/deepMergeContent.mjs.map +1 -1
  154. package/dist/esm/fill/fill.mjs +86 -1
  155. package/dist/esm/fill/fill.mjs.map +1 -1
  156. package/dist/esm/fill/formatAutoFilledFilePath.mjs +30 -1
  157. package/dist/esm/fill/formatAutoFilledFilePath.mjs.map +1 -1
  158. package/dist/esm/fill/formatFillData.mjs +89 -1
  159. package/dist/esm/fill/formatFillData.mjs.map +1 -1
  160. package/dist/esm/fill/getAvailableLocalesInDictionary.mjs +24 -1
  161. package/dist/esm/fill/getAvailableLocalesInDictionary.mjs.map +1 -1
  162. package/dist/esm/fill/getFilterMissingContentPerLocale.mjs +49 -1
  163. package/dist/esm/fill/getFilterMissingContentPerLocale.mjs.map +1 -1
  164. package/dist/esm/fill/index.mjs +4 -1
  165. package/dist/esm/fill/listTranslationsTasks.mjs +69 -1
  166. package/dist/esm/fill/listTranslationsTasks.mjs.map +1 -1
  167. package/dist/esm/fill/translateDictionary.mjs +238 -1
  168. package/dist/esm/fill/translateDictionary.mjs.map +1 -1
  169. package/dist/esm/fill/writeFill.mjs +51 -1
  170. package/dist/esm/fill/writeFill.mjs.map +1 -1
  171. package/dist/esm/getTargetDictionary.mjs +33 -1
  172. package/dist/esm/getTargetDictionary.mjs.map +1 -1
  173. package/dist/esm/index.mjs +20 -1
  174. package/dist/esm/init.mjs +19 -1
  175. package/dist/esm/init.mjs.map +1 -1
  176. package/dist/esm/initMCP.mjs +65 -1
  177. package/dist/esm/initMCP.mjs.map +1 -1
  178. package/dist/esm/initSkills.mjs +87 -1
  179. package/dist/esm/initSkills.mjs.map +1 -1
  180. package/dist/esm/listContentDeclaration.mjs +39 -1
  181. package/dist/esm/listContentDeclaration.mjs.map +1 -1
  182. package/dist/esm/listProjects.mjs +26 -1
  183. package/dist/esm/listProjects.mjs.map +1 -1
  184. package/dist/esm/liveSync.mjs +150 -8
  185. package/dist/esm/liveSync.mjs.map +1 -1
  186. package/dist/esm/pull.mjs +150 -1
  187. package/dist/esm/pull.mjs.map +1 -1
  188. package/dist/esm/push/pullLog.mjs +102 -3
  189. package/dist/esm/push/pullLog.mjs.map +1 -1
  190. package/dist/esm/push/push.mjs +208 -1
  191. package/dist/esm/push/push.mjs.map +1 -1
  192. package/dist/esm/pushConfig.mjs +20 -1
  193. package/dist/esm/pushConfig.mjs.map +1 -1
  194. package/dist/esm/pushLog.mjs +83 -3
  195. package/dist/esm/pushLog.mjs.map +1 -1
  196. package/dist/esm/reviewDoc/reviewDoc.mjs +69 -1
  197. package/dist/esm/reviewDoc/reviewDoc.mjs.map +1 -1
  198. package/dist/esm/reviewDoc/reviewDocBlockAware.mjs +95 -1
  199. package/dist/esm/reviewDoc/reviewDocBlockAware.mjs.map +1 -1
  200. package/dist/esm/searchDoc.mjs +39 -1
  201. package/dist/esm/searchDoc.mjs.map +1 -1
  202. package/dist/esm/test/index.mjs +4 -1
  203. package/dist/esm/test/listMissingTranslations.mjs +63 -1
  204. package/dist/esm/test/listMissingTranslations.mjs.map +1 -1
  205. package/dist/esm/test/test.mjs +53 -1
  206. package/dist/esm/test/test.mjs.map +1 -1
  207. package/dist/esm/translateDoc/index.mjs +5 -1
  208. package/dist/esm/translateDoc/translateDoc.mjs +75 -1
  209. package/dist/esm/translateDoc/translateDoc.mjs.map +1 -1
  210. package/dist/esm/translateDoc/translateFile.mjs +103 -2
  211. package/dist/esm/translateDoc/translateFile.mjs.map +1 -1
  212. package/dist/esm/translateDoc/validation.mjs +46 -5
  213. package/dist/esm/translateDoc/validation.mjs.map +1 -1
  214. package/dist/esm/translation-alignment/alignBlocks.mjs +66 -1
  215. package/dist/esm/translation-alignment/alignBlocks.mjs.map +1 -1
  216. package/dist/esm/translation-alignment/computeSimilarity.mjs +22 -1
  217. package/dist/esm/translation-alignment/computeSimilarity.mjs.map +1 -1
  218. package/dist/esm/translation-alignment/fingerprintBlock.mjs +20 -1
  219. package/dist/esm/translation-alignment/fingerprintBlock.mjs.map +1 -1
  220. package/dist/esm/translation-alignment/index.mjs +11 -1
  221. package/dist/esm/translation-alignment/mapChangedLinesToBlocks.mjs +16 -1
  222. package/dist/esm/translation-alignment/mapChangedLinesToBlocks.mjs.map +1 -1
  223. package/dist/esm/translation-alignment/normalizeBlock.mjs +20 -1
  224. package/dist/esm/translation-alignment/normalizeBlock.mjs.map +1 -1
  225. package/dist/esm/translation-alignment/pipeline.mjs +35 -1
  226. package/dist/esm/translation-alignment/pipeline.mjs.map +1 -1
  227. package/dist/esm/translation-alignment/planActions.mjs +44 -1
  228. package/dist/esm/translation-alignment/planActions.mjs.map +1 -1
  229. package/dist/esm/translation-alignment/rebuildDocument.mjs +46 -2
  230. package/dist/esm/translation-alignment/rebuildDocument.mjs.map +1 -1
  231. package/dist/esm/translation-alignment/segmentDocument.mjs +64 -5
  232. package/dist/esm/translation-alignment/segmentDocument.mjs.map +1 -1
  233. package/dist/esm/utils/calculateChunks.mjs +87 -2
  234. package/dist/esm/utils/calculateChunks.mjs.map +1 -1
  235. package/dist/esm/utils/checkAccess.mjs +79 -1
  236. package/dist/esm/utils/checkAccess.mjs.map +1 -1
  237. package/dist/esm/utils/checkConfigConsistency.mjs +14 -1
  238. package/dist/esm/utils/checkConfigConsistency.mjs.map +1 -1
  239. package/dist/esm/utils/checkFileModifiedRange.mjs +80 -1
  240. package/dist/esm/utils/checkFileModifiedRange.mjs.map +1 -1
  241. package/dist/esm/utils/checkLastUpdateTime.mjs +17 -1
  242. package/dist/esm/utils/checkLastUpdateTime.mjs.map +1 -1
  243. package/dist/esm/utils/chunkInference.mjs +43 -1
  244. package/dist/esm/utils/chunkInference.mjs.map +1 -1
  245. package/dist/esm/utils/fixChunkStartEndChars.mjs +25 -3
  246. package/dist/esm/utils/fixChunkStartEndChars.mjs.map +1 -1
  247. package/dist/esm/utils/formatTimeDiff.mjs +18 -1
  248. package/dist/esm/utils/formatTimeDiff.mjs.map +1 -1
  249. package/dist/esm/utils/getIsFileUpdatedRecently.mjs +14 -1
  250. package/dist/esm/utils/getIsFileUpdatedRecently.mjs.map +1 -1
  251. package/dist/esm/utils/getOutputFilePath.mjs +104 -1
  252. package/dist/esm/utils/getOutputFilePath.mjs.map +1 -1
  253. package/dist/esm/utils/getParentPackageJSON.mjs +18 -1
  254. package/dist/esm/utils/getParentPackageJSON.mjs.map +1 -1
  255. package/dist/esm/utils/listSpecialChars.mjs +52 -2
  256. package/dist/esm/utils/listSpecialChars.mjs.map +1 -1
  257. package/dist/esm/utils/mapChunksBetweenFiles.mjs +100 -1
  258. package/dist/esm/utils/mapChunksBetweenFiles.mjs.map +1 -1
  259. package/dist/esm/utils/openBrowser.mjs +17 -1
  260. package/dist/esm/utils/openBrowser.mjs.map +1 -1
  261. package/dist/esm/utils/reorderParagraphs.mjs +90 -3
  262. package/dist/esm/utils/reorderParagraphs.mjs.map +1 -1
  263. package/dist/esm/utils/setupAI.mjs +63 -1
  264. package/dist/esm/utils/setupAI.mjs.map +1 -1
  265. package/dist/esm/watch.mjs +45 -1
  266. package/dist/esm/watch.mjs.map +1 -1
  267. package/dist/types/fill/fill.d.ts +1 -1
  268. package/dist/types/fill/fill.d.ts.map +1 -1
  269. package/dist/types/fill/formatFillData.d.ts.map +1 -1
  270. package/dist/types/fill/translateDictionary.d.ts +1 -1
  271. package/dist/types/getTargetDictionary.d.ts +19 -2
  272. package/dist/types/getTargetDictionary.d.ts.map +1 -0
  273. package/dist/types/index.d.ts +2 -2
  274. package/dist/types/reviewDoc/reviewDocBlockAware.d.ts +1 -1
  275. package/dist/types/test/index.d.ts +2 -2
  276. package/dist/types/test/listMissingTranslations.d.ts +28 -2
  277. package/dist/types/test/listMissingTranslations.d.ts.map +1 -0
  278. package/dist/types/test/test.d.ts +11 -2
  279. package/dist/types/test/test.d.ts.map +1 -0
  280. package/dist/types/translateDoc/index.d.ts +1 -1
  281. package/dist/types/translateDoc/translateDoc.d.ts +1 -1
  282. package/dist/types/translateDoc/translateFile.d.ts +1 -1
  283. package/dist/types/translateDoc/types.d.ts +48 -2
  284. package/dist/types/translateDoc/types.d.ts.map +1 -0
  285. package/dist/types/utils/chunkInference.d.ts +1 -1
  286. package/dist/types/utils/getOutputFilePath.d.ts +18 -1
  287. package/dist/types/utils/getOutputFilePath.d.ts.map +1 -1
  288. package/dist/types/utils/setupAI.d.ts +21 -2
  289. package/dist/types/utils/setupAI.d.ts.map +1 -0
  290. package/package.json +12 -12
  291. package/dist/cjs/_utils_asset-ghp_Cjwk.cjs +0 -2
  292. package/dist/cjs/chunk-Bmb41Sf3.cjs +0 -1
  293. package/dist/esm/_utils_asset-B187VPMw.mjs +0 -2
  294. package/dist/esm/editor-D8BGlLzF.mjs +0 -2
  295. package/dist/esm/editor-D8BGlLzF.mjs.map +0 -1
  296. package/dist/types/getTargetDictionary-RBSRtaQj.d.ts +0 -19
  297. package/dist/types/getTargetDictionary-RBSRtaQj.d.ts.map +0 -1
  298. package/dist/types/listMissingTranslations-DxKw7nqI.d.ts +0 -28
  299. package/dist/types/listMissingTranslations-DxKw7nqI.d.ts.map +0 -1
  300. package/dist/types/setupAI-Bosjx7ah.d.ts +0 -21
  301. package/dist/types/setupAI-Bosjx7ah.d.ts.map +0 -1
  302. package/dist/types/test-DUTiJR5_.d.ts +0 -11
  303. package/dist/types/test-DUTiJR5_.d.ts.map +0 -1
  304. package/dist/types/types-BKvc3FmV.d.ts +0 -48
  305. package/dist/types/types-BKvc3FmV.d.ts.map +0 -1
@@ -1,2 +1,66 @@
1
- import{findProjectRoot as e}from"./init.mjs";import{PLATFORM_OPTIONS as t,getDetectedPlatform as n}from"./initSkills.mjs";import{resolve as r}from"node:path";import{PLATFORMS as i,installMCP as a}from"@intlayer/chokidar/cli";import o from"enquirer";import*as s from"@clack/prompts";const c=async c=>{let l=e(c?r(c):process.cwd());s.intro(`Initializing Intlayer MCP Server`);let u=n(),d;try{d=(await o.prompt({type:`autocomplete`,name:`platforms`,message:`Which platform are you using? (Type to search)`,multiple:!1,initial:u?i.indexOf(u):void 0,choices:t.map(e=>({name:e.value,message:e.label,hint:e.hint}))})).platforms}catch{s.cancel(`Operation cancelled.`);return}if(!d){s.cancel(`Operation cancelled. No platform selected.`);return}let f=await s.select({message:`Which transport method do you want to use?`,options:[{value:`stdio`,label:`Local server (stdio)`,hint:`Recommended. Integrates all features including CLI tools.`},{value:`sse`,label:`Remote server (SSE)`,hint:`Hosted by Intlayer. Documentation only.`}]});if(s.isCancel(f)||!f){s.cancel(`Operation cancelled.`);return}let p=s.spinner();p.start(`Configuring MCP Server...`);try{let e=await a(l,d,f);p.stop(`MCP Server configured successfully`),s.note(e,`Success`)}catch(e){p.stop(`Failed to configure MCP Server`),s.log.error(e instanceof Error?e.message:String(e))}s.outro(`Intlayer MCP Server initialization complete`)};export{c as initMCP};
1
+ import { findProjectRoot } from "./init.mjs";
2
+ import { PLATFORM_OPTIONS, getDetectedPlatform } from "./initSkills.mjs";
3
+ import { resolve } from "node:path";
4
+ import { PLATFORMS, installMCP } from "@intlayer/chokidar/cli";
5
+ import enquirer from "enquirer";
6
+ import * as p from "@clack/prompts";
7
+
8
+ //#region src/initMCP.ts
9
+ const initMCP = async (projectRoot) => {
10
+ const root = findProjectRoot(projectRoot ? resolve(projectRoot) : process.cwd());
11
+ p.intro("Initializing Intlayer MCP Server");
12
+ const detectedPlatform = getDetectedPlatform();
13
+ let platform;
14
+ try {
15
+ platform = (await enquirer.prompt({
16
+ type: "autocomplete",
17
+ name: "platforms",
18
+ message: "Which platform are you using? (Type to search)",
19
+ multiple: false,
20
+ initial: detectedPlatform ? PLATFORMS.indexOf(detectedPlatform) : void 0,
21
+ choices: PLATFORM_OPTIONS.map((opt) => ({
22
+ name: opt.value,
23
+ message: opt.label,
24
+ hint: opt.hint
25
+ }))
26
+ })).platforms;
27
+ } catch {
28
+ p.cancel("Operation cancelled.");
29
+ return;
30
+ }
31
+ if (!platform) {
32
+ p.cancel("Operation cancelled. No platform selected.");
33
+ return;
34
+ }
35
+ const transport = await p.select({
36
+ message: "Which transport method do you want to use?",
37
+ options: [{
38
+ value: "stdio",
39
+ label: "Local server (stdio)",
40
+ hint: "Recommended. Integrates all features including CLI tools."
41
+ }, {
42
+ value: "sse",
43
+ label: "Remote server (SSE)",
44
+ hint: "Hosted by Intlayer. Documentation only."
45
+ }]
46
+ });
47
+ if (p.isCancel(transport) || !transport) {
48
+ p.cancel("Operation cancelled.");
49
+ return;
50
+ }
51
+ const s = p.spinner();
52
+ s.start("Configuring MCP Server...");
53
+ try {
54
+ const result = await installMCP(root, platform, transport);
55
+ s.stop("MCP Server configured successfully");
56
+ p.note(result, "Success");
57
+ } catch (error) {
58
+ s.stop("Failed to configure MCP Server");
59
+ p.log.error(error instanceof Error ? error.message : String(error));
60
+ }
61
+ p.outro("Intlayer MCP Server initialization complete");
62
+ };
63
+
64
+ //#endregion
65
+ export { initMCP };
2
66
  //# sourceMappingURL=initMCP.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"initMCP.mjs","names":[],"sources":["../../src/initMCP.ts"],"sourcesContent":["import { resolve } from 'node:path';\nimport * as p from '@clack/prompts';\nimport {\n installMCP,\n type MCPTransport,\n PLATFORMS,\n} from '@intlayer/chokidar/cli';\nimport enquirer from 'enquirer';\nimport { findProjectRoot } from './init';\nimport { getDetectedPlatform, PLATFORM_OPTIONS } from './initSkills';\n\nexport const initMCP = async (projectRoot?: string) => {\n const root = findProjectRoot(\n projectRoot ? resolve(projectRoot) : process.cwd()\n );\n\n p.intro('Initializing Intlayer MCP Server');\n\n const detectedPlatform = getDetectedPlatform();\n\n let platform: any;\n try {\n const response = await enquirer.prompt<{ platforms: any }>({\n type: 'autocomplete',\n name: 'platforms',\n message: 'Which platform are you using? (Type to search)',\n multiple: false,\n initial: detectedPlatform\n ? PLATFORMS.indexOf(detectedPlatform)\n : undefined,\n choices: PLATFORM_OPTIONS.map((opt) => ({\n name: opt.value,\n message: opt.label,\n hint: opt.hint,\n })),\n });\n platform = response.platforms;\n } catch {\n p.cancel('Operation cancelled.');\n return;\n }\n\n if (!platform) {\n p.cancel('Operation cancelled. No platform selected.');\n return;\n }\n\n const transport = (await p.select({\n message: 'Which transport method do you want to use?',\n options: [\n {\n value: 'stdio',\n label: 'Local server (stdio)',\n hint: 'Recommended. Integrates all features including CLI tools.',\n },\n {\n value: 'sse',\n label: 'Remote server (SSE)',\n hint: 'Hosted by Intlayer. Documentation only.',\n },\n ],\n })) as MCPTransport;\n\n if (p.isCancel(transport) || !transport) {\n p.cancel('Operation cancelled.');\n return;\n }\n\n const s = p.spinner();\n s.start('Configuring MCP Server...');\n\n try {\n const result = await installMCP(root, platform, transport);\n\n s.stop('MCP Server configured successfully');\n\n p.note(result, 'Success');\n } catch (error) {\n s.stop('Failed to configure MCP Server');\n p.log.error(error instanceof Error ? error.message : String(error));\n }\n\n p.outro('Intlayer MCP Server initialization complete');\n};\n"],"mappings":"0RAWA,MAAa,EAAU,KAAO,IAAyB,CACrD,IAAM,EAAO,EACX,EAAc,EAAQ,EAAY,CAAG,QAAQ,KAAK,CACnD,CAED,EAAE,MAAM,mCAAmC,CAE3C,IAAM,EAAmB,GAAqB,CAE1C,EACJ,GAAI,CAeF,GAdiB,MAAM,EAAS,OAA2B,CACzD,KAAM,eACN,KAAM,YACN,QAAS,iDACT,SAAU,GACV,QAAS,EACL,EAAU,QAAQ,EAAiB,CACnC,IAAA,GACJ,QAAS,EAAiB,IAAK,IAAS,CACtC,KAAM,EAAI,MACV,QAAS,EAAI,MACb,KAAM,EAAI,KACX,EAAE,CACJ,CAAC,EACkB,eACd,CACN,EAAE,OAAO,uBAAuB,CAChC,OAGF,GAAI,CAAC,EAAU,CACb,EAAE,OAAO,6CAA6C,CACtD,OAGF,IAAM,EAAa,MAAM,EAAE,OAAO,CAChC,QAAS,6CACT,QAAS,CACP,CACE,MAAO,QACP,MAAO,uBACP,KAAM,4DACP,CACD,CACE,MAAO,MACP,MAAO,sBACP,KAAM,0CACP,CACF,CACF,CAAC,CAEF,GAAI,EAAE,SAAS,EAAU,EAAI,CAAC,EAAW,CACvC,EAAE,OAAO,uBAAuB,CAChC,OAGF,IAAM,EAAI,EAAE,SAAS,CACrB,EAAE,MAAM,4BAA4B,CAEpC,GAAI,CACF,IAAM,EAAS,MAAM,EAAW,EAAM,EAAU,EAAU,CAE1D,EAAE,KAAK,qCAAqC,CAE5C,EAAE,KAAK,EAAQ,UAAU,OAClB,EAAO,CACd,EAAE,KAAK,iCAAiC,CACxC,EAAE,IAAI,MAAM,aAAiB,MAAQ,EAAM,QAAU,OAAO,EAAM,CAAC,CAGrE,EAAE,MAAM,8CAA8C"}
1
+ {"version":3,"file":"initMCP.mjs","names":[],"sources":["../../src/initMCP.ts"],"sourcesContent":["import { resolve } from 'node:path';\nimport * as p from '@clack/prompts';\nimport {\n installMCP,\n type MCPTransport,\n PLATFORMS,\n} from '@intlayer/chokidar/cli';\nimport enquirer from 'enquirer';\nimport { findProjectRoot } from './init';\nimport { getDetectedPlatform, PLATFORM_OPTIONS } from './initSkills';\n\nexport const initMCP = async (projectRoot?: string) => {\n const root = findProjectRoot(\n projectRoot ? resolve(projectRoot) : process.cwd()\n );\n\n p.intro('Initializing Intlayer MCP Server');\n\n const detectedPlatform = getDetectedPlatform();\n\n let platform: any;\n try {\n const response = await enquirer.prompt<{ platforms: any }>({\n type: 'autocomplete',\n name: 'platforms',\n message: 'Which platform are you using? (Type to search)',\n multiple: false,\n initial: detectedPlatform\n ? PLATFORMS.indexOf(detectedPlatform)\n : undefined,\n choices: PLATFORM_OPTIONS.map((opt) => ({\n name: opt.value,\n message: opt.label,\n hint: opt.hint,\n })),\n });\n platform = response.platforms;\n } catch {\n p.cancel('Operation cancelled.');\n return;\n }\n\n if (!platform) {\n p.cancel('Operation cancelled. No platform selected.');\n return;\n }\n\n const transport = (await p.select({\n message: 'Which transport method do you want to use?',\n options: [\n {\n value: 'stdio',\n label: 'Local server (stdio)',\n hint: 'Recommended. Integrates all features including CLI tools.',\n },\n {\n value: 'sse',\n label: 'Remote server (SSE)',\n hint: 'Hosted by Intlayer. Documentation only.',\n },\n ],\n })) as MCPTransport;\n\n if (p.isCancel(transport) || !transport) {\n p.cancel('Operation cancelled.');\n return;\n }\n\n const s = p.spinner();\n s.start('Configuring MCP Server...');\n\n try {\n const result = await installMCP(root, platform, transport);\n\n s.stop('MCP Server configured successfully');\n\n p.note(result, 'Success');\n } catch (error) {\n s.stop('Failed to configure MCP Server');\n p.log.error(error instanceof Error ? error.message : String(error));\n }\n\n p.outro('Intlayer MCP Server initialization complete');\n};\n"],"mappings":";;;;;;;;AAWA,MAAa,UAAU,OAAO,gBAAyB;CACrD,MAAM,OAAO,gBACX,cAAc,QAAQ,YAAY,GAAG,QAAQ,KAAK,CACnD;AAED,GAAE,MAAM,mCAAmC;CAE3C,MAAM,mBAAmB,qBAAqB;CAE9C,IAAI;AACJ,KAAI;AAeF,cAdiB,MAAM,SAAS,OAA2B;GACzD,MAAM;GACN,MAAM;GACN,SAAS;GACT,UAAU;GACV,SAAS,mBACL,UAAU,QAAQ,iBAAiB,GACnC;GACJ,SAAS,iBAAiB,KAAK,SAAS;IACtC,MAAM,IAAI;IACV,SAAS,IAAI;IACb,MAAM,IAAI;IACX,EAAE;GACJ,CAAC,EACkB;SACd;AACN,IAAE,OAAO,uBAAuB;AAChC;;AAGF,KAAI,CAAC,UAAU;AACb,IAAE,OAAO,6CAA6C;AACtD;;CAGF,MAAM,YAAa,MAAM,EAAE,OAAO;EAChC,SAAS;EACT,SAAS,CACP;GACE,OAAO;GACP,OAAO;GACP,MAAM;GACP,EACD;GACE,OAAO;GACP,OAAO;GACP,MAAM;GACP,CACF;EACF,CAAC;AAEF,KAAI,EAAE,SAAS,UAAU,IAAI,CAAC,WAAW;AACvC,IAAE,OAAO,uBAAuB;AAChC;;CAGF,MAAM,IAAI,EAAE,SAAS;AACrB,GAAE,MAAM,4BAA4B;AAEpC,KAAI;EACF,MAAM,SAAS,MAAM,WAAW,MAAM,UAAU,UAAU;AAE1D,IAAE,KAAK,qCAAqC;AAE5C,IAAE,KAAK,QAAQ,UAAU;UAClB,OAAO;AACd,IAAE,KAAK,iCAAiC;AACxC,IAAE,IAAI,MAAM,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,CAAC;;AAGrE,GAAE,MAAM,8CAA8C"}
@@ -1,2 +1,88 @@
1
- import{findProjectRoot as e}from"./init.mjs";import{existsSync as t,readFileSync as n}from"node:fs";import{join as r,resolve as i}from"node:path";import{PLATFORMS as a,PLATFORMS_METADATA as o,SKILLS as s,SKILLS_METADATA as c,getInitialSkills as l,installSkills as u}from"@intlayer/chokidar/cli";import d from"enquirer";import*as f from"@clack/prompts";const p=a.filter(e=>o[e].check).map(e=>({check:o[e].check??(()=>!1),platform:e})),m=a.map(e=>({value:e,label:o[e].label,hint:`(${o[e].dir})`})),h=()=>p.find(({check:e})=>e())?.platform,g=e=>{try{let i=r(e,`package.json`);if(!t(i))return{};let{dependencies:a={},devDependencies:o={}}=JSON.parse(n(i,`utf-8`));return{...a,...o}}catch{return{}}},_=async t=>{let n=e(t?i(t):process.cwd());f.intro(`Initializing Intlayer skills`);let r=h(),o;try{o=(await d.prompt({type:`autocomplete`,name:`platforms`,message:`Which platforms are you using? (Type to search)`,multiple:!1,initial:r?a.indexOf(r):void 0,choices:m.map(e=>({name:e.value,message:e.label,hint:e.hint}))})).platforms}catch{f.cancel(`Operation cancelled.`);return}if(!o){f.log.warn(`No platform selected. Nothing to install.`);return}let p=l(g(n)),_=await f.multiselect({message:`Select the documentation skills to provide to your AI:`,initialValues:p,options:s.map(e=>({value:e,label:e,hint:c[e]})),required:!1});if(f.isCancel(_)||!_||_.length===0){f.cancel(`Operation cancelled. No skills selected.`);return}let v=f.spinner();v.start(`Installing skills...`);try{let e=await u(n,o,_);v.stop(`Skills installed successfully`),f.note(e,`Success`)}catch(e){v.stop(`Failed to install skills`),f.log.error(e instanceof Error?e.message:String(e))}f.outro(`Intlayer skills initialization complete`)};export{m as PLATFORM_OPTIONS,h as getDetectedPlatform,_ as initSkills};
1
+ import { findProjectRoot } from "./init.mjs";
2
+ import { existsSync, readFileSync } from "node:fs";
3
+ import { join, resolve } from "node:path";
4
+ import { PLATFORMS, PLATFORMS_METADATA, SKILLS, SKILLS_METADATA, getInitialSkills, installSkills } from "@intlayer/chokidar/cli";
5
+ import enquirer from "enquirer";
6
+ import * as p from "@clack/prompts";
7
+
8
+ //#region src/initSkills.ts
9
+ const PLATFORM_CHECKS = PLATFORMS.filter((platform) => PLATFORMS_METADATA[platform].check).map((platform) => ({
10
+ check: PLATFORMS_METADATA[platform].check ?? (() => false),
11
+ platform
12
+ }));
13
+ const PLATFORM_OPTIONS = PLATFORMS.map((platform) => ({
14
+ value: platform,
15
+ label: PLATFORMS_METADATA[platform].label,
16
+ hint: `(${PLATFORMS_METADATA[platform].dir})`
17
+ }));
18
+ const getDetectedPlatform = () => PLATFORM_CHECKS.find(({ check }) => check())?.platform;
19
+ const getDependencies = (root) => {
20
+ try {
21
+ const packageJsonPath = join(root, "package.json");
22
+ if (!existsSync(packageJsonPath)) return {};
23
+ const { dependencies = {}, devDependencies = {} } = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
24
+ return {
25
+ ...dependencies,
26
+ ...devDependencies
27
+ };
28
+ } catch {
29
+ return {};
30
+ }
31
+ };
32
+ const initSkills = async (projectRoot) => {
33
+ const root = findProjectRoot(projectRoot ? resolve(projectRoot) : process.cwd());
34
+ p.intro("Initializing Intlayer skills");
35
+ const detectedPlatform = getDetectedPlatform();
36
+ let platform;
37
+ try {
38
+ platform = (await enquirer.prompt({
39
+ type: "autocomplete",
40
+ name: "platforms",
41
+ message: "Which platforms are you using? (Type to search)",
42
+ multiple: false,
43
+ initial: detectedPlatform ? PLATFORMS.indexOf(detectedPlatform) : void 0,
44
+ choices: PLATFORM_OPTIONS.map((opt) => ({
45
+ name: opt.value,
46
+ message: opt.label,
47
+ hint: opt.hint
48
+ }))
49
+ })).platforms;
50
+ } catch {
51
+ p.cancel("Operation cancelled.");
52
+ return;
53
+ }
54
+ if (!platform) {
55
+ p.log.warn("No platform selected. Nothing to install.");
56
+ return;
57
+ }
58
+ const initialValues = getInitialSkills(getDependencies(root));
59
+ const selectedSkills = await p.multiselect({
60
+ message: "Select the documentation skills to provide to your AI:",
61
+ initialValues,
62
+ options: SKILLS.map((skill) => ({
63
+ value: skill,
64
+ label: skill,
65
+ hint: SKILLS_METADATA[skill]
66
+ })),
67
+ required: false
68
+ });
69
+ if (p.isCancel(selectedSkills) || !selectedSkills || selectedSkills.length === 0) {
70
+ p.cancel("Operation cancelled. No skills selected.");
71
+ return;
72
+ }
73
+ const s = p.spinner();
74
+ s.start("Installing skills...");
75
+ try {
76
+ const result = await installSkills(root, platform, selectedSkills);
77
+ s.stop("Skills installed successfully");
78
+ p.note(result, "Success");
79
+ } catch (error) {
80
+ s.stop("Failed to install skills");
81
+ p.log.error(error instanceof Error ? error.message : String(error));
82
+ }
83
+ p.outro("Intlayer skills initialization complete");
84
+ };
85
+
86
+ //#endregion
87
+ export { PLATFORM_OPTIONS, getDetectedPlatform, initSkills };
2
88
  //# sourceMappingURL=initSkills.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"initSkills.mjs","names":[],"sources":["../../src/initSkills.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\nimport * as p from '@clack/prompts';\nimport {\n getInitialSkills,\n installSkills,\n PLATFORMS,\n PLATFORMS_METADATA,\n type Platform,\n SKILLS,\n SKILLS_METADATA,\n} from '@intlayer/chokidar/cli';\nimport enquirer from 'enquirer';\nimport { findProjectRoot } from './init';\n\nconst PLATFORM_CHECKS: Array<{ check: () => boolean; platform: Platform }> =\n PLATFORMS.filter((platform) => PLATFORMS_METADATA[platform].check).map(\n (platform) => ({\n check: PLATFORMS_METADATA[platform].check ?? (() => false),\n platform,\n })\n );\n\nexport const PLATFORM_OPTIONS: Array<{\n value: Platform;\n label: string;\n hint: string;\n}> = PLATFORMS.map((platform) => ({\n value: platform,\n label: PLATFORMS_METADATA[platform].label,\n hint: `(${PLATFORMS_METADATA[platform].dir})`,\n}));\n\nexport const getDetectedPlatform = (): Platform | undefined =>\n PLATFORM_CHECKS.find(({ check }) => check())?.platform;\n\nconst getDependencies = (root: string): Record<string, string> => {\n try {\n const packageJsonPath = join(root, 'package.json');\n if (!existsSync(packageJsonPath)) return {};\n\n const { dependencies = {}, devDependencies = {} } = JSON.parse(\n readFileSync(packageJsonPath, 'utf-8')\n );\n return { ...dependencies, ...devDependencies };\n } catch {\n return {};\n }\n};\n\nexport const initSkills = async (projectRoot?: string) => {\n const root = findProjectRoot(\n projectRoot ? resolve(projectRoot) : process.cwd()\n );\n\n p.intro('Initializing Intlayer skills');\n\n const detectedPlatform = getDetectedPlatform();\n\n let platform: Platform;\n try {\n const response = await enquirer.prompt<{ platforms: Platform }>({\n type: 'autocomplete',\n name: 'platforms',\n message: 'Which platforms are you using? (Type to search)',\n multiple: false,\n initial: detectedPlatform\n ? PLATFORMS.indexOf(detectedPlatform)\n : undefined,\n choices: PLATFORM_OPTIONS.map((opt) => ({\n name: opt.value,\n message: opt.label,\n hint: opt.hint,\n })),\n });\n platform = response.platforms;\n } catch {\n p.cancel('Operation cancelled.');\n return;\n }\n\n if (!platform) {\n p.log.warn('No platform selected. Nothing to install.');\n return;\n }\n\n const dependencies = getDependencies(root);\n const initialValues = getInitialSkills(dependencies);\n\n const selectedSkills = await p.multiselect({\n message: 'Select the documentation skills to provide to your AI:',\n initialValues,\n options: SKILLS.map((skill) => ({\n value: skill,\n label: skill,\n hint: SKILLS_METADATA[skill],\n })),\n required: false,\n });\n\n if (\n p.isCancel(selectedSkills) ||\n !selectedSkills ||\n (selectedSkills as string[]).length === 0\n ) {\n p.cancel('Operation cancelled. No skills selected.');\n return;\n }\n\n const s = p.spinner();\n s.start('Installing skills...');\n\n try {\n const result = await installSkills(root, platform, selectedSkills);\n\n s.stop('Skills installed successfully');\n\n p.note(result, 'Success');\n } catch (error) {\n s.stop('Failed to install skills');\n p.log.error(error instanceof Error ? error.message : String(error));\n }\n\n p.outro('Intlayer skills initialization complete');\n};\n"],"mappings":"gWAeA,MAAM,EACJ,EAAU,OAAQ,GAAa,EAAmB,GAAU,MAAM,CAAC,IAChE,IAAc,CACb,MAAO,EAAmB,GAAU,YAAgB,IACpD,WACD,EACF,CAEU,EAIR,EAAU,IAAK,IAAc,CAChC,MAAO,EACP,MAAO,EAAmB,GAAU,MACpC,KAAM,IAAI,EAAmB,GAAU,IAAI,GAC5C,EAAE,CAEU,MACX,EAAgB,MAAM,CAAE,WAAY,GAAO,CAAC,EAAE,SAE1C,EAAmB,GAAyC,CAChE,GAAI,CACF,IAAM,EAAkB,EAA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2B,CAClC,EAAE,IAAI,MAAM,aAAiB,MAAQ,EAAM,QAAU,OAAO,EAAM,CAAC,CAGrE,EAAE,MAAM,0CAA0C"}
1
+ {"version":3,"file":"initSkills.mjs","names":[],"sources":["../../src/initSkills.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\nimport * as p from '@clack/prompts';\nimport {\n getInitialSkills,\n installSkills,\n PLATFORMS,\n PLATFORMS_METADATA,\n type Platform,\n SKILLS,\n SKILLS_METADATA,\n} from '@intlayer/chokidar/cli';\nimport enquirer from 'enquirer';\nimport { findProjectRoot } from './init';\n\nconst PLATFORM_CHECKS: Array<{ check: () => boolean; platform: Platform }> =\n PLATFORMS.filter((platform) => PLATFORMS_METADATA[platform].check).map(\n (platform) => ({\n check: PLATFORMS_METADATA[platform].check ?? (() => false),\n platform,\n })\n );\n\nexport const PLATFORM_OPTIONS: Array<{\n value: Platform;\n label: string;\n hint: string;\n}> = PLATFORMS.map((platform) => ({\n value: platform,\n label: PLATFORMS_METADATA[platform].label,\n hint: `(${PLATFORMS_METADATA[platform].dir})`,\n}));\n\nexport const getDetectedPlatform = (): Platform | undefined =>\n PLATFORM_CHECKS.find(({ check }) => check())?.platform;\n\nconst getDependencies = (root: string): Record<string, string> => {\n try {\n const packageJsonPath = join(root, 'package.json');\n if (!existsSync(packageJsonPath)) return {};\n\n const { dependencies = {}, devDependencies = {} } = JSON.parse(\n readFileSync(packageJsonPath, 'utf-8')\n );\n return { ...dependencies, ...devDependencies };\n } catch {\n return {};\n }\n};\n\nexport const initSkills = async (projectRoot?: string) => {\n const root = findProjectRoot(\n projectRoot ? resolve(projectRoot) : process.cwd()\n );\n\n p.intro('Initializing Intlayer skills');\n\n const detectedPlatform = getDetectedPlatform();\n\n let platform: Platform;\n try {\n const response = await enquirer.prompt<{ platforms: Platform }>({\n type: 'autocomplete',\n name: 'platforms',\n message: 'Which platforms are you using? (Type to search)',\n multiple: false,\n initial: detectedPlatform\n ? PLATFORMS.indexOf(detectedPlatform)\n : undefined,\n choices: PLATFORM_OPTIONS.map((opt) => ({\n name: opt.value,\n message: opt.label,\n hint: opt.hint,\n })),\n });\n platform = response.platforms;\n } catch {\n p.cancel('Operation cancelled.');\n return;\n }\n\n if (!platform) {\n p.log.warn('No platform selected. Nothing to install.');\n return;\n }\n\n const dependencies = getDependencies(root);\n const initialValues = getInitialSkills(dependencies);\n\n const selectedSkills = await p.multiselect({\n message: 'Select the documentation skills to provide to your AI:',\n initialValues,\n options: SKILLS.map((skill) => ({\n value: skill,\n label: skill,\n hint: SKILLS_METADATA[skill],\n })),\n required: false,\n });\n\n if (\n p.isCancel(selectedSkills) ||\n !selectedSkills ||\n (selectedSkills as string[]).length === 0\n ) {\n p.cancel('Operation cancelled. No skills selected.');\n return;\n }\n\n const s = p.spinner();\n s.start('Installing skills...');\n\n try {\n const result = await installSkills(root, platform, selectedSkills);\n\n s.stop('Skills installed successfully');\n\n p.note(result, 'Success');\n } catch (error) {\n s.stop('Failed to install skills');\n p.log.error(error instanceof Error ? error.message : String(error));\n }\n\n p.outro('Intlayer skills initialization complete');\n};\n"],"mappings":";;;;;;;;AAeA,MAAM,kBACJ,UAAU,QAAQ,aAAa,mBAAmB,UAAU,MAAM,CAAC,KAChE,cAAc;CACb,OAAO,mBAAmB,UAAU,gBAAgB;CACpD;CACD,EACF;AAEH,MAAa,mBAIR,UAAU,KAAK,cAAc;CAChC,OAAO;CACP,OAAO,mBAAmB,UAAU;CACpC,MAAM,IAAI,mBAAmB,UAAU,IAAI;CAC5C,EAAE;AAEH,MAAa,4BACX,gBAAgB,MAAM,EAAE,YAAY,OAAO,CAAC,EAAE;AAEhD,MAAM,mBAAmB,SAAyC;AAChE,KAAI;EACF,MAAM,kBAAkB,KAAK,MAAM,eAAe;AAClD,MAAI,CAAC,WAAW,gBAAgB,CAAE,QAAO,EAAE;EAE3C,MAAM,EAAE,eAAe,EAAE,EAAE,kBAAkB,EAAE,KAAK,KAAK,MACvD,a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
@@ -1,2 +1,40 @@
1
- import{relative as e}from"node:path";import{formatPath as t}from"@intlayer/chokidar/utils";import{colon as n,colorizeKey as r,colorizeNumber as i,getAppLogger as a}from"@intlayer/config/logger";import{getConfiguration as o}from"@intlayer/config/node";import{getUnmergedDictionaries as s}from"@intlayer/unmerged-dictionaries-entry";const c=t=>{let n=o(t?.configOptions),r=s(n);return Object.values(r).flat().map(r=>({key:r.key??``,path:t?.absolute?r.filePath??`Remote`:e(n.system.baseDir,r.filePath??`Remote`)}))},l=e=>{let s=c(e);if(e?.json){console.log(JSON.stringify(s));return}let l=a(o(e?.configOptions)),u=s.map(e=>[n(` - ${r(e.key)}`,{colSize:s.map(e=>e.key.length),maxSize:60}),` - `,t(e.path)].join(``));l(`Content declaration files:`),u.forEach(e=>{l(e,{level:`info`})}),l(`Total content declaration files: ${i(s.length)}`)};export{l as listContentDeclaration,c as listContentDeclarationRows};
1
+ import { relative } from "node:path";
2
+ import { formatPath } from "@intlayer/chokidar/utils";
3
+ import { colon, colorizeKey, colorizeNumber, getAppLogger } from "@intlayer/config/logger";
4
+ import { getConfiguration } from "@intlayer/config/node";
5
+ import { getUnmergedDictionaries } from "@intlayer/unmerged-dictionaries-entry";
6
+
7
+ //#region src/listContentDeclaration.ts
8
+ const listContentDeclarationRows = (options) => {
9
+ const config = getConfiguration(options?.configOptions);
10
+ const unmergedDictionariesRecord = getUnmergedDictionaries(config);
11
+ return Object.values(unmergedDictionariesRecord).flat().map((dictionary) => ({
12
+ key: dictionary.key ?? "",
13
+ path: options?.absolute ? dictionary.filePath ?? "Remote" : relative(config.system.baseDir, dictionary.filePath ?? "Remote")
14
+ }));
15
+ };
16
+ const listContentDeclaration = (options) => {
17
+ const rows = listContentDeclarationRows(options);
18
+ if (options?.json) {
19
+ console.log(JSON.stringify(rows));
20
+ return;
21
+ }
22
+ const appLogger = getAppLogger(getConfiguration(options?.configOptions));
23
+ const lines = rows.map((row) => [
24
+ colon(` - ${colorizeKey(row.key)}`, {
25
+ colSize: rows.map((row) => row.key.length),
26
+ maxSize: 60
27
+ }),
28
+ " - ",
29
+ formatPath(row.path)
30
+ ].join(""));
31
+ appLogger(`Content declaration files:`);
32
+ lines.forEach((line) => {
33
+ appLogger(line, { level: "info" });
34
+ });
35
+ appLogger(`Total content declaration files: ${colorizeNumber(rows.length)}`);
36
+ };
37
+
38
+ //#endregion
39
+ export { listContentDeclaration, listContentDeclarationRows };
2
40
  //# sourceMappingURL=listContentDeclaration.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"listContentDeclaration.mjs","names":[],"sources":["../../src/listContentDeclaration.ts"],"sourcesContent":["import { relative } from 'node:path';\nimport { formatPath } from '@intlayer/chokidar/utils';\nimport {\n colon,\n colorizeKey,\n colorizeNumber,\n getAppLogger,\n} from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\n\ntype ListContentDeclarationOptions = {\n configOptions?: GetConfigurationOptions;\n json?: boolean;\n absolute?: boolean;\n};\n\nexport const listContentDeclarationRows = (\n options?: ListContentDeclarationOptions\n) => {\n const config = getConfiguration(options?.configOptions);\n\n const unmergedDictionariesRecord = getUnmergedDictionaries(config);\n\n const rows = Object.values(unmergedDictionariesRecord)\n .flat()\n .map((dictionary) => ({\n key: dictionary.key ?? '',\n path: options?.absolute\n ? (dictionary.filePath ?? 'Remote')\n : relative(config.system.baseDir, dictionary.filePath ?? 'Remote'),\n }));\n return rows;\n};\n\nexport const listContentDeclaration = (\n options?: ListContentDeclarationOptions\n) => {\n const rows = listContentDeclarationRows(options);\n\n if (options?.json) {\n console.log(JSON.stringify(rows));\n return;\n }\n\n const config = getConfiguration(options?.configOptions);\n const appLogger = getAppLogger(config);\n\n const lines = rows.map((row) =>\n [\n colon(` - ${colorizeKey(row.key)}`, {\n colSize: rows.map((row) => row.key.length),\n maxSize: 60,\n }),\n ' - ',\n formatPath(row.path),\n ].join('')\n );\n\n appLogger(`Content declaration files:`);\n\n lines.forEach((line) => {\n appLogger(line, {\n level: 'info',\n });\n });\n\n appLogger(`Total content declaration files: ${colorizeNumber(rows.length)}`);\n};\n"],"mappings":"2UAoBA,MAAa,EACX,GACG,CACH,IAAM,EAAS,EAAiB,GAAS,cAAc,CAEjD,EAA6B,EAAwB,EAAO,CAUlE,OARa,OAAO,OAAO,EAA2B,CACnD,MAAM,CACN,IAAK,IAAgB,CACpB,IAAK,EAAW,KAAO,GACvB,KAAM,GAAS,SACV,EAAW,UAAY,SACxB,EAAS,EAAO,OAAO,QAAS,EAAW,UAAY,SAAS,CACrE,EAAE,EAIM,EACX,GACG,CACH,IAAM,EAAO,EAA2B,EAAQ,CAEhD,GAAI,GAAS,KAAM,CACjB,QAAQ,IAAI,KAAK,UAAU,EAAK,CAAC,CACjC,OAIF,IAAM,EAAY,EADH,EAAiB,GAAS,cAAc,CACjB,CAEhC,EAAQ,EAAK,IAAK,GACtB,CACE,EAAM,MAAM,EAAY,EAAI,IAAI,GAAI,CAClC,QAAS,EAAK,IAAK,GAAQ,EAAI,IAAI,OAAO,CAC1C,QAAS,GACV,CAAC,CACF,MACA,EAAW,EAAI,KAAK,CACrB,CAAC,KAAK,GAAG,CACX,CAED,EAAU,6BAA6B,CAEvC,EAAM,QAAS,GAAS,CACtB,EAAU,EAAM,CACd,MAAO,OACR,CAAC,EACF,CAEF,EAAU,oCAAoC,EAAe,EAAK,OAAO,GAAG"}
1
+ {"version":3,"file":"listContentDeclaration.mjs","names":[],"sources":["../../src/listContentDeclaration.ts"],"sourcesContent":["import { relative } from 'node:path';\nimport { formatPath } from '@intlayer/chokidar/utils';\nimport {\n colon,\n colorizeKey,\n colorizeNumber,\n getAppLogger,\n} from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\n\ntype ListContentDeclarationOptions = {\n configOptions?: GetConfigurationOptions;\n json?: boolean;\n absolute?: boolean;\n};\n\nexport const listContentDeclarationRows = (\n options?: ListContentDeclarationOptions\n) => {\n const config = getConfiguration(options?.configOptions);\n\n const unmergedDictionariesRecord = getUnmergedDictionaries(config);\n\n const rows = Object.values(unmergedDictionariesRecord)\n .flat()\n .map((dictionary) => ({\n key: dictionary.key ?? '',\n path: options?.absolute\n ? (dictionary.filePath ?? 'Remote')\n : relative(config.system.baseDir, dictionary.filePath ?? 'Remote'),\n }));\n return rows;\n};\n\nexport const listContentDeclaration = (\n options?: ListContentDeclarationOptions\n) => {\n const rows = listContentDeclarationRows(options);\n\n if (options?.json) {\n console.log(JSON.stringify(rows));\n return;\n }\n\n const config = getConfiguration(options?.configOptions);\n const appLogger = getAppLogger(config);\n\n const lines = rows.map((row) =>\n [\n colon(` - ${colorizeKey(row.key)}`, {\n colSize: rows.map((row) => row.key.length),\n maxSize: 60,\n }),\n ' - ',\n formatPath(row.path),\n ].join('')\n );\n\n appLogger(`Content declaration files:`);\n\n lines.forEach((line) => {\n appLogger(line, {\n level: 'info',\n });\n });\n\n appLogger(`Total content declaration files: ${colorizeNumber(rows.length)}`);\n};\n"],"mappings":";;;;;;;AAoBA,MAAa,8BACX,YACG;CACH,MAAM,SAAS,iBAAiB,SAAS,cAAc;CAEvD,MAAM,6BAA6B,wBAAwB,OAAO;AAUlE,QARa,OAAO,OAAO,2BAA2B,CACnD,MAAM,CACN,KAAK,gBAAgB;EACpB,KAAK,WAAW,OAAO;EACvB,MAAM,SAAS,WACV,WAAW,YAAY,WACxB,SAAS,OAAO,OAAO,SAAS,WAAW,YAAY,SAAS;EACrE,EAAE;;AAIP,MAAa,0BACX,YACG;CACH,MAAM,OAAO,2BAA2B,QAAQ;AAEhD,KAAI,SAAS,MAAM;AACjB,UAAQ,IAAI,KAAK,UAAU,KAAK,CAAC;AACjC;;CAIF,MAAM,YAAY,aADH,iBAAiB,SAAS,cAAc,CACjB;CAEtC,MAAM,QAAQ,KAAK,KAAK,QACtB;EACE,MAAM,MAAM,YAAY,IAAI,IAAI,IAAI;GAClC,SAAS,KAAK,KAAK,QAAQ,IAAI,IAAI,OAAO;GAC1C,SAAS;GACV,CAAC;EACF;EACA,WAAW,IAAI,KAAK;EACrB,CAAC,KAAK,GAAG,CACX;AAED,WAAU,6BAA6B;AAEvC,OAAM,SAAS,SAAS;AACtB,YAAU,MAAM,EACd,OAAO,QACR,CAAC;GACF;AAEF,WAAU,oCAAoC,eAAe,KAAK,OAAO,GAAG"}
@@ -1,2 +1,27 @@
1
- import{relative as e}from"node:path";import{listProjects as t}from"@intlayer/chokidar/cli";const n=async n=>{let{searchDir:r,projectsPath:i}=await t(n),a=i.map(t=>n?.absolute?t:e(r,t)).map(e=>e===``?`.`:e);if(n?.json){console.dir(a,{depth:null,arrayLimit:null});return}if(i.length===0){console.log(`No Intlayer projects found.`);return}console.log(`Found ${i.length} Intlayer project(s):\n`),i.forEach(e=>{console.log(` - ${e}`)})};export{n as listProjectsCommand};
1
+ import { relative } from "node:path";
2
+ import { listProjects } from "@intlayer/chokidar/cli";
3
+
4
+ //#region src/listProjects.ts
5
+ const listProjectsCommand = async (options) => {
6
+ const { searchDir, projectsPath } = await listProjects(options);
7
+ const projectsRelativePath = projectsPath.map((projectPath) => options?.absolute ? projectPath : relative(searchDir, projectPath)).map((projectPath) => projectPath === "" ? "." : projectPath);
8
+ if (options?.json) {
9
+ console.dir(projectsRelativePath, {
10
+ depth: null,
11
+ arrayLimit: null
12
+ });
13
+ return;
14
+ }
15
+ if (projectsPath.length === 0) {
16
+ console.log("No Intlayer projects found.");
17
+ return;
18
+ }
19
+ console.log(`Found ${projectsPath.length} Intlayer project(s):\n`);
20
+ projectsPath.forEach((project) => {
21
+ console.log(` - ${project}`);
22
+ });
23
+ };
24
+
25
+ //#endregion
26
+ export { listProjectsCommand };
2
27
  //# sourceMappingURL=listProjects.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"listProjects.mjs","names":[],"sources":["../../src/listProjects.ts"],"sourcesContent":["import { relative } from 'node:path';\nimport { type ListProjectsOptions, listProjects } from '@intlayer/chokidar/cli';\n\nexport type ListProjectsCommandOptions = ListProjectsOptions & {\n json?: boolean;\n absolute?: boolean;\n};\n\nexport const listProjectsCommand = async (\n options?: ListProjectsCommandOptions\n) => {\n const { searchDir, projectsPath } = await listProjects(options);\n\n const projectsRelativePath = projectsPath\n .map((projectPath) =>\n options?.absolute ? projectPath : relative(searchDir, projectPath)\n )\n .map((projectPath) => (projectPath === '' ? '.' : projectPath));\n\n if (options?.json) {\n console.dir(projectsRelativePath, { depth: null, arrayLimit: null });\n return;\n }\n\n if (projectsPath.length === 0) {\n console.log('No Intlayer projects found.');\n return;\n }\n\n console.log(`Found ${projectsPath.length} Intlayer project(s):\\n`);\n projectsPath.forEach((project) => {\n console.log(` - ${project}`);\n });\n};\n"],"mappings":"2FAQA,MAAa,EAAsB,KACjC,IACG,CACH,GAAM,CAAE,YAAW,gBAAiB,MAAM,EAAa,EAAQ,CAEzD,EAAuB,EAC1B,IAAK,GACJ,GAAS,SAAW,EAAc,EAAS,EAAW,EAAY,CACnE,CACA,IAAK,GAAiB,IAAgB,GAAK,IAAM,EAAa,CAEjE,GAAI,GAAS,KAAM,CACjB,QAAQ,IAAI,EAAsB,CAAE,MAAO,KAAM,WAAY,KAAM,CAAC,CACpE,OAGF,GAAI,EAAa,SAAW,EAAG,CAC7B,QAAQ,IAAI,8BAA8B,CAC1C,OAGF,QAAQ,IAAI,SAAS,EAAa,OAAO,yBAAyB,CAClE,EAAa,QAAS,GAAY,CAChC,QAAQ,IAAI,OAAO,IAAU,EAC7B"}
1
+ {"version":3,"file":"listProjects.mjs","names":[],"sources":["../../src/listProjects.ts"],"sourcesContent":["import { relative } from 'node:path';\nimport { type ListProjectsOptions, listProjects } from '@intlayer/chokidar/cli';\n\nexport type ListProjectsCommandOptions = ListProjectsOptions & {\n json?: boolean;\n absolute?: boolean;\n};\n\nexport const listProjectsCommand = async (\n options?: ListProjectsCommandOptions\n) => {\n const { searchDir, projectsPath } = await listProjects(options);\n\n const projectsRelativePath = projectsPath\n .map((projectPath) =>\n options?.absolute ? projectPath : relative(searchDir, projectPath)\n )\n .map((projectPath) => (projectPath === '' ? '.' : projectPath));\n\n if (options?.json) {\n console.dir(projectsRelativePath, { depth: null, arrayLimit: null });\n return;\n }\n\n if (projectsPath.length === 0) {\n console.log('No Intlayer projects found.');\n return;\n }\n\n console.log(`Found ${projectsPath.length} Intlayer project(s):\\n`);\n projectsPath.forEach((project) => {\n console.log(` - ${project}`);\n });\n};\n"],"mappings":";;;;AAQA,MAAa,sBAAsB,OACjC,YACG;CACH,MAAM,EAAE,WAAW,iBAAiB,MAAM,aAAa,QAAQ;CAE/D,MAAM,uBAAuB,aAC1B,KAAK,gBACJ,SAAS,WAAW,cAAc,SAAS,WAAW,YAAY,CACnE,CACA,KAAK,gBAAiB,gBAAgB,KAAK,MAAM,YAAa;AAEjE,KAAI,SAAS,MAAM;AACjB,UAAQ,IAAI,sBAAsB;GAAE,OAAO;GAAM,YAAY;GAAM,CAAC;AACpE;;AAGF,KAAI,aAAa,WAAW,GAAG;AAC7B,UAAQ,IAAI,8BAA8B;AAC1C;;AAGF,SAAQ,IAAI,SAAS,aAAa,OAAO,yBAAyB;AAClE,cAAa,SAAS,YAAY;AAChC,UAAQ,IAAI,OAAO,UAAU;GAC7B"}
@@ -1,10 +1,152 @@
1
- import{IntlayerEventListener as e}from"./IntlayerEventListener.mjs";import{buildDictionary as t}from"@intlayer/chokidar/build";import{runParallel as n}from"@intlayer/chokidar/utils";import{getAppLogger as r}from"@intlayer/config/logger";import{getConfiguration as i}from"@intlayer/config/node";import{getUnmergedDictionaries as a}from"@intlayer/unmerged-dictionaries-entry";import{createServer as o}from"node:http";import s from"@intlayer/config/package.json"with{type:"json"};import{getLocalizedContent as c}from"@intlayer/core/plugins";import{getDictionaries as l}from"@intlayer/dictionaries-entry";const u=async(e,n)=>{r(n)(`Writing dictionary ${e.key}`),await t([e],n)},d=async t=>{let d=i(t?.configOptions),f=r(d),{liveSyncPort:p,liveSyncURL:m}=d.editor,h=null,g=null;if(t?.with&&(h=n(t.with),h.result.catch(()=>{})),d.editor.liveSync&&d.editor.backendURL&&d.editor.clientId&&d.editor.clientSecret){g=new e(d),g.onConnectionOpen=()=>{f(`Live sync connection established`)},g.onConnectionError=e=>{let t=e;f(`Live sync connection error: ${t.message??`Unknown error`}`,{level:`warn`}),(t.message?.includes(`terminated`)||t.message?.includes(`closed`))&&f(`Server connection was terminated, automatic reconnection will be attempted...`,{level:`info`})},g.onDictionaryAdded=e=>u(e,d),g.onDictionaryChange=e=>u(e,d),g.onDictionaryDeleted=e=>u(e,d);try{await g.initialize()}catch(e){f(`Failed to initialize IntlayerEventListener:`,{level:`error`}),f(`Error: ${e instanceof Error?e.message:String(e)}`,{level:`error`})}}else d.editor.liveSync?(!d.editor.clientId||!d.editor.clientSecret)&&f(`Missing client credentials for hot reload. Please configure clientId and clientSecret`):f(`Hot reload is disabled. Please enable it in the configuration (editor.liveSync).`);let _=o(async(e,t)=>{if(e.method===`OPTIONS`){t.writeHead(200,{"Access-Control-Allow-Origin":`*`,"Access-Control-Allow-Methods":`GET, POST, PUT, DELETE, OPTIONS`,"Access-Control-Allow-Headers":`Content-Type, Authorization`}),t.end();return}if(e.url?.startsWith(`/dictionaries`)){t.writeHead(200,{"Content-Type":`application/json; charset=utf-8`,"Cache-Control":`no-store`,"Access-Control-Allow-Origin":`*`,"Access-Control-Allow-Methods":`GET, POST, PUT, DELETE, OPTIONS`,"Access-Control-Allow-Headers":`Content-Type, Authorization`});let n=l(d);if(e.url.startsWith(`/dictionaries/`)){let[r,i]=decodeURIComponent(e.url).slice(14).split(`/`),a=n[r]??null;if(i){let e=c(a.content,i,{dictionaryKey:r,keyPath:[]});t.end(JSON.stringify(e));return}t.end(JSON.stringify(a));return}t.end(JSON.stringify(n));return}if(e.url?.startsWith(`/unmerged_dictionaries`)){t.writeHead(200,{"Content-Type":`application/json; charset=utf-8`,"Cache-Control":`no-store`,"Access-Control-Allow-Origin":`*`,"Access-Control-Allow-Methods":`GET, POST, PUT, DELETE, OPTIONS`,"Access-Control-Allow-Headers":`Content-Type, Authorization`});let n=a(d);if(e.url.startsWith(`/unmerged_dictionaries/`)){let r=n[decodeURIComponent(e.url.slice(23))]??null;t.end(JSON.stringify(r));return}t.end(JSON.stringify(n));return}if(e.url===`/configuration`){t.writeHead(200,{"Content-Type":`application/json; charset=utf-8`,"Cache-Control":`no-store`,"Access-Control-Allow-Origin":`*`,"Access-Control-Allow-Methods":`GET, POST, PUT, DELETE, OPTIONS`,"Access-Control-Allow-Headers":`Content-Type, Authorization`}),t.end(JSON.stringify(d));return}if(e.url===`/health`){t.writeHead(200,{"Content-Type":`application/json; charset=utf-8`}),t.end(JSON.stringify({status:`ok`}));return}t.end(`Not found`)}),v=()=>d.editor.liveSync?`\x1B[32m✓ Enabled\x1B[0m`:`\x1B[31m✗ Disabled\x1B[0m`;_.listen(p,()=>{console.log(`
2
- \x1b[1;90mINTLAYER v${s.version}\x1b[0m
1
+ import { IntlayerEventListener } from "./IntlayerEventListener.mjs";
2
+ import { buildDictionary } from "@intlayer/chokidar/build";
3
+ import { runParallel } from "@intlayer/chokidar/utils";
4
+ import { getAppLogger } from "@intlayer/config/logger";
5
+ import { getConfiguration } from "@intlayer/config/node";
6
+ import { getUnmergedDictionaries } from "@intlayer/unmerged-dictionaries-entry";
7
+ import { createServer } from "node:http";
8
+ import packageJson from "@intlayer/config/package.json" with { type: "json" };
9
+ import { getLocalizedContent } from "@intlayer/core/plugins";
10
+ import { getDictionaries } from "@intlayer/dictionaries-entry";
11
+
12
+ //#region src/liveSync.ts
13
+ const writeDictionary = async (dictionary, configuration) => {
14
+ getAppLogger(configuration)(`Writing dictionary ${dictionary.key}`);
15
+ await buildDictionary([dictionary], configuration);
16
+ };
17
+ const liveSync = async (options) => {
18
+ const configuration = getConfiguration(options?.configOptions);
19
+ const appLogger = getAppLogger(configuration);
20
+ const { liveSyncPort, liveSyncURL } = configuration.editor;
21
+ let parallelProcess = null;
22
+ let eventListener = null;
23
+ if (options?.with) {
24
+ parallelProcess = runParallel(options.with);
25
+ parallelProcess.result.catch(() => {});
26
+ }
27
+ if (configuration.editor.liveSync && configuration.editor.backendURL && configuration.editor.clientId && configuration.editor.clientSecret) {
28
+ eventListener = new IntlayerEventListener(configuration);
29
+ eventListener.onConnectionOpen = () => {
30
+ appLogger("Live sync connection established");
31
+ };
32
+ eventListener.onConnectionError = (error) => {
33
+ const errorEvent = error;
34
+ appLogger(`Live sync connection error: ${errorEvent.message ?? "Unknown error"}`, { level: "warn" });
35
+ if (errorEvent.message?.includes("terminated") || errorEvent.message?.includes("closed")) appLogger("Server connection was terminated, automatic reconnection will be attempted...", { level: "info" });
36
+ };
37
+ eventListener.onDictionaryAdded = (dictionary) => writeDictionary(dictionary, configuration);
38
+ eventListener.onDictionaryChange = (dictionary) => writeDictionary(dictionary, configuration);
39
+ eventListener.onDictionaryDeleted = (dictionary) => writeDictionary(dictionary, configuration);
40
+ try {
41
+ await eventListener.initialize();
42
+ } catch (error) {
43
+ appLogger("Failed to initialize IntlayerEventListener:", { level: "error" });
44
+ appLogger(`Error: ${error instanceof Error ? error.message : String(error)}`, { level: "error" });
45
+ }
46
+ } else if (!configuration.editor.liveSync) appLogger("Hot reload is disabled. Please enable it in the configuration (editor.liveSync).");
47
+ else if (!configuration.editor.clientId || !configuration.editor.clientSecret) appLogger("Missing client credentials for hot reload. Please configure clientId and clientSecret");
48
+ const server = createServer(async (req, res) => {
49
+ if (req.method === "OPTIONS") {
50
+ res.writeHead(200, {
51
+ "Access-Control-Allow-Origin": "*",
52
+ "Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS",
53
+ "Access-Control-Allow-Headers": "Content-Type, Authorization"
54
+ });
55
+ res.end();
56
+ return;
57
+ }
58
+ if (req.url?.startsWith("/dictionaries")) {
59
+ res.writeHead(200, {
60
+ "Content-Type": "application/json; charset=utf-8",
61
+ "Cache-Control": "no-store",
62
+ "Access-Control-Allow-Origin": "*",
63
+ "Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS",
64
+ "Access-Control-Allow-Headers": "Content-Type, Authorization"
65
+ });
66
+ const dictionaries = getDictionaries(configuration);
67
+ if (req.url.startsWith("/dictionaries/")) {
68
+ const [key, locale] = decodeURIComponent(req.url).slice(14).split("/");
69
+ const dictionary = dictionaries[key] ?? null;
70
+ if (locale) {
71
+ const sourceLocaleContent = getLocalizedContent(dictionary.content, locale, {
72
+ dictionaryKey: key,
73
+ keyPath: []
74
+ });
75
+ res.end(JSON.stringify(sourceLocaleContent));
76
+ return;
77
+ }
78
+ res.end(JSON.stringify(dictionary));
79
+ return;
80
+ }
81
+ res.end(JSON.stringify(dictionaries));
82
+ return;
83
+ }
84
+ if (req.url?.startsWith("/unmerged_dictionaries")) {
85
+ res.writeHead(200, {
86
+ "Content-Type": "application/json; charset=utf-8",
87
+ "Cache-Control": "no-store",
88
+ "Access-Control-Allow-Origin": "*",
89
+ "Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS",
90
+ "Access-Control-Allow-Headers": "Content-Type, Authorization"
91
+ });
92
+ const unmergedDictionaries = getUnmergedDictionaries(configuration);
93
+ if (req.url.startsWith("/unmerged_dictionaries/")) {
94
+ const one = unmergedDictionaries[decodeURIComponent(req.url.slice(23))] ?? null;
95
+ res.end(JSON.stringify(one));
96
+ return;
97
+ }
98
+ res.end(JSON.stringify(unmergedDictionaries));
99
+ return;
100
+ }
101
+ if (req.url === "/configuration") {
102
+ res.writeHead(200, {
103
+ "Content-Type": "application/json; charset=utf-8",
104
+ "Cache-Control": "no-store",
105
+ "Access-Control-Allow-Origin": "*",
106
+ "Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS",
107
+ "Access-Control-Allow-Headers": "Content-Type, Authorization"
108
+ });
109
+ res.end(JSON.stringify(configuration));
110
+ return;
111
+ }
112
+ if (req.url === "/health") {
113
+ res.writeHead(200, { "Content-Type": "application/json; charset=utf-8" });
114
+ res.end(JSON.stringify({ status: "ok" }));
115
+ return;
116
+ }
117
+ res.end("Not found");
118
+ });
119
+ const getLiveSyncParam = () => {
120
+ if (!configuration.editor.liveSync) return "\x1B[31m✗ Disabled\x1B[0m";
121
+ return "\x1B[32m✓ Enabled\x1B[0m";
122
+ };
123
+ server.listen(liveSyncPort, () => {
124
+ console.log(`
125
+ \x1b[1;90mINTLAYER v${packageJson.version}\x1b[0m
3
126
 
4
- Live server running at: \x1b[90m${m}\x1b[0m
5
- - Backend URL: \x1b[90m${d.editor.backendURL??`-`}\x1b[0m
6
- - Live sync: ${v()}
7
- - Parallel process: ${t?.with?`\x1b[90m${Array.isArray(t.with)?t.with.join(` `):t.with}\x1b[0m`:`-`}
8
- - Access key: ${d.editor.clientId??`-`}
9
- `)});let y=()=>{g&&(f(`Closing SSE connection...`),g.cleanup()),h&&h.kill(),_.close(()=>{f(`Live sync server stopped`),process.exit(0)})};process.on(`SIGINT`,y),process.on(`SIGTERM`,y),process.on(`exit`,y)};export{d as liveSync};
127
+ Live server running at: \x1b[90m${liveSyncURL}\x1b[0m
128
+ - Backend URL: \x1b[90m${configuration.editor.backendURL ?? "-"}\x1b[0m
129
+ - Live sync: ${getLiveSyncParam()}
130
+ - Parallel process: ${options?.with ? `\x1b[90m${Array.isArray(options.with) ? options.with.join(" ") : options.with}\x1b[0m` : "-"}
131
+ - Access key: ${configuration.editor.clientId ?? "-"}
132
+ `);
133
+ });
134
+ const cleanup = () => {
135
+ if (eventListener) {
136
+ appLogger("Closing SSE connection...");
137
+ eventListener.cleanup();
138
+ }
139
+ if (parallelProcess) parallelProcess.kill();
140
+ server.close(() => {
141
+ appLogger("Live sync server stopped");
142
+ process.exit(0);
143
+ });
144
+ };
145
+ process.on("SIGINT", cleanup);
146
+ process.on("SIGTERM", cleanup);
147
+ process.on("exit", cleanup);
148
+ };
149
+
150
+ //#endregion
151
+ export { liveSync };
10
152
  //# sourceMappingURL=liveSync.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"liveSync.mjs","names":[],"sources":["../../src/liveSync.ts"],"sourcesContent":["import { createServer } from 'node:http';\n// @ts-ignore: @intlayer/backend is not built yet\nimport type { DictionaryAPI } from '@intlayer/backend';\nimport { buildDictionary } from '@intlayer/chokidar/build';\nimport { type ParallelHandle, runParallel } from '@intlayer/chokidar/utils';\nimport { getAppLogger } from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport packageJson from '@intlayer/config/package.json' with { type: 'json' };\nimport { getLocalizedContent } from '@intlayer/core/plugins';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\nimport { IntlayerEventListener } from './IntlayerEventListener';\n\ntype LiveSyncOptions = {\n with?: string | string[];\n configOptions?: GetConfigurationOptions;\n};\n\nconst writeDictionary = async (\n dictionary: DictionaryAPI,\n configuration: IntlayerConfig\n) => {\n const appLogger = getAppLogger(configuration);\n appLogger(`Writing dictionary ${dictionary.key}`);\n await buildDictionary([dictionary], configuration);\n};\n\nexport const liveSync = async (options?: LiveSyncOptions) => {\n const configuration = getConfiguration(options?.configOptions);\n const appLogger = getAppLogger(configuration);\n\n const { liveSyncPort, liveSyncURL } = configuration.editor;\n\n let parallelProcess: ParallelHandle | null = null;\n let eventListener: IntlayerEventListener | null = null;\n let _isHotReloadConnected = false;\n let _connectionStatus = 'disconnected'; // 'connected', 'connecting', 'reconnecting', 'disconnected', 'error'\n\n // Start the parallel process if provided\n if (options?.with) {\n parallelProcess = runParallel(options.with);\n // Handle the promise to avoid unhandled rejection\n parallelProcess.result.catch(() => {\n // Parallel process failed or was terminated\n });\n }\n\n // Initialize the event listener for hot reload if configured\n if (\n configuration.editor.liveSync &&\n configuration.editor.backendURL &&\n configuration.editor.clientId &&\n configuration.editor.clientSecret\n ) {\n eventListener = new IntlayerEventListener(configuration);\n _connectionStatus = 'connecting';\n\n // Set up connection callbacks\n eventListener.onConnectionOpen = () => {\n _connectionStatus = 'connected';\n _isHotReloadConnected = true;\n appLogger('Live sync connection established');\n };\n\n eventListener.onConnectionError = (error) => {\n _connectionStatus = 'error';\n _isHotReloadConnected = false;\n const errorEvent = error as any;\n appLogger(\n `Live sync connection error: ${errorEvent.message ?? 'Unknown error'}`,\n {\n level: 'warn',\n }\n );\n\n // If this is a \"terminated: other side closed\" error, it's likely a server restart\n if (\n errorEvent.message?.includes('terminated') ||\n errorEvent.message?.includes('closed')\n ) {\n appLogger(\n 'Server connection was terminated, automatic reconnection will be attempted...',\n {\n level: 'info',\n }\n );\n _connectionStatus = 'reconnecting';\n }\n };\n\n // Set up dictionary change callbacks\n eventListener.onDictionaryAdded = (dictionary) =>\n writeDictionary(dictionary, configuration);\n eventListener.onDictionaryChange = (dictionary) =>\n writeDictionary(dictionary, configuration);\n eventListener.onDictionaryDeleted = (dictionary) =>\n writeDictionary(dictionary, configuration);\n\n try {\n await eventListener.initialize();\n } catch (error) {\n _connectionStatus = 'error';\n _isHotReloadConnected = false;\n appLogger('Failed to initialize IntlayerEventListener:', {\n level: 'error',\n });\n appLogger(\n `Error: ${error instanceof Error ? error.message : String(error)}`,\n {\n level: 'error',\n }\n );\n }\n } else if (!configuration.editor.liveSync) {\n appLogger(\n 'Hot reload is disabled. Please enable it in the configuration (editor.liveSync).'\n );\n } else if (\n !configuration.editor.clientId ||\n !configuration.editor.clientSecret\n ) {\n appLogger(\n 'Missing client credentials for hot reload. Please configure clientId and clientSecret'\n );\n }\n\n const server = createServer(async (req, res) => {\n // Handle CORS preflight requests\n if (req.method === 'OPTIONS') {\n res.writeHead(200, {\n 'Access-Control-Allow-Origin': '*',\n 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',\n 'Access-Control-Allow-Headers': 'Content-Type, Authorization',\n });\n\n res.end();\n return;\n }\n\n if (req.url?.startsWith('/dictionaries')) {\n res.writeHead(200, {\n 'Content-Type': 'application/json; charset=utf-8',\n 'Cache-Control': 'no-store',\n 'Access-Control-Allow-Origin': '*',\n 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',\n 'Access-Control-Allow-Headers': 'Content-Type, Authorization',\n });\n const dictionaries = getDictionaries(configuration);\n\n const prefix = '/dictionaries/';\n if (req.url.startsWith(prefix)) {\n const [key, locale] = decodeURIComponent(req.url)\n .slice(prefix.length)\n .split('/');\n\n const dictionary = dictionaries[key] ?? null;\n\n if (locale) {\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\n const sourceLocaleContent = getLocalizedContent(\n dictionary.content,\n locale,\n {\n dictionaryKey: key,\n keyPath: [],\n }\n );\n\n res.end(JSON.stringify(sourceLocaleContent));\n return;\n }\n\n res.end(JSON.stringify(dictionary));\n return;\n }\n\n res.end(JSON.stringify(dictionaries));\n return;\n }\n\n if (req.url?.startsWith('/unmerged_dictionaries')) {\n res.writeHead(200, {\n 'Content-Type': 'application/json; charset=utf-8',\n 'Cache-Control': 'no-store',\n 'Access-Control-Allow-Origin': '*',\n 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',\n 'Access-Control-Allow-Headers': 'Content-Type, Authorization',\n });\n const unmergedDictionaries = getUnmergedDictionaries(configuration);\n\n const prefix = '/unmerged_dictionaries/';\n if (req.url.startsWith(prefix)) {\n const key = decodeURIComponent(req.url.slice(prefix.length));\n const one = unmergedDictionaries[key] ?? null;\n\n res.end(JSON.stringify(one));\n return;\n }\n\n res.end(JSON.stringify(unmergedDictionaries));\n return;\n }\n\n if (req.url === '/configuration') {\n res.writeHead(200, {\n 'Content-Type': 'application/json; charset=utf-8',\n 'Cache-Control': 'no-store',\n 'Access-Control-Allow-Origin': '*',\n 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',\n 'Access-Control-Allow-Headers': 'Content-Type, Authorization',\n });\n res.end(JSON.stringify(configuration));\n return;\n }\n\n if (req.url === '/health') {\n res.writeHead(200, {\n 'Content-Type': 'application/json; charset=utf-8',\n });\n res.end(JSON.stringify({ status: 'ok' }));\n return;\n }\n\n res.end('Not found');\n return;\n });\n\n const getLiveSyncParam = () => {\n if (!configuration.editor.liveSync) return '\\x1b[31m✗ Disabled\\x1b[0m';\n\n return '\\x1b[32m✓ Enabled\\x1b[0m';\n };\n server.listen(liveSyncPort, () => {\n console.log(`\n \\x1b[1;90mINTLAYER v${packageJson.version}\\x1b[0m\n \n Live server running at: \\x1b[90m${liveSyncURL}\\x1b[0m\n - Backend URL: \\x1b[90m${configuration.editor.backendURL ?? '-'}\\x1b[0m\n - Live sync: ${getLiveSyncParam()}\n - Parallel process: ${options?.with ? `\\x1b[90m${Array.isArray(options.with) ? options.with.join(' ') : options.with}\\x1b[0m` : '-'}\n - Access key: ${configuration.editor.clientId ?? '-'}\n `);\n });\n\n // Cleanup function to terminate child process and event listener when the main process exits\n const cleanup = () => {\n // Clean up event listener\n if (eventListener) {\n appLogger('Closing SSE connection...');\n eventListener.cleanup();\n }\n\n if (parallelProcess) {\n parallelProcess.kill();\n }\n\n server.close(() => {\n appLogger('Live sync server stopped');\n process.exit(0);\n });\n };\n\n // Handle process termination signals\n process.on('SIGINT', cleanup);\n process.on('SIGTERM', cleanup);\n process.on('exit', cleanup);\n};\n"],"mappings":"ylBAsBA,MAAM,EAAkB,MACtB,EACA,IACG,CACe,EAAa,EAAc,CACnC,sBAAsB,EAAW,MAAM,CACjD,MAAM,EAAgB,CAAC,EAAW,CAAE,EAAc,EAGvC,EAAW,KAAO,IAA8B,CAC3D,IAAM,EAAgB,EAAiB,GAAS,cAAc,CACxD,EAAY,EAAa,EAAc,CAEvC,CAAE,eAAc,eAAgB,EAAc,OAEhD,EAAyC,KACzC,EAA8C,KAclD,GATI,GAAS,OACX,EAAkB,EAAY,EAAQ,KAAK,CAE3C,EAAgB,OAAO,UAAY,GAEjC,EAKF,EAAc,OAAO,UACrB,EAAc,OAAO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AO,WAAW,MAAM,QAAQ,EAAQ,KAAK,CAAG,EAAQ,KAAK,KAAK,IAAI,CAAG,EAAQ,KAAK,SAAW,IAAI;yCAC9G,EAAc,OAAO,UAAY,IAAI;QACtE,EACJ,CAGF,IAAM,MAAgB,CAEhB,IACF,EAAU,4BAA4B,CACtC,EAAc,SAAS,EAGrB,GACF,EAAgB,MAAM,CAGxB,EAAO,UAAY,CACjB,EAAU,2BAA2B,CACrC,QAAQ,KAAK,EAAE,EACf,EAIJ,QAAQ,GAAG,SAAU,EAAQ,CAC7B,QAAQ,GAAG,UAAW,EAAQ,CAC9B,QAAQ,GAAG,OAAQ,EAAQ"}
1
+ {"version":3,"file":"liveSync.mjs","names":[],"sources":["../../src/liveSync.ts"],"sourcesContent":["import { createServer } from 'node:http';\n// @ts-ignore: @intlayer/backend is not built yet\nimport type { DictionaryAPI } from '@intlayer/backend';\nimport { buildDictionary } from '@intlayer/chokidar/build';\nimport { type ParallelHandle, runParallel } from '@intlayer/chokidar/utils';\nimport { getAppLogger } from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport packageJson from '@intlayer/config/package.json' with { type: 'json' };\nimport { getLocalizedContent } from '@intlayer/core/plugins';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\nimport { IntlayerEventListener } from './IntlayerEventListener';\n\ntype LiveSyncOptions = {\n with?: string | string[];\n configOptions?: GetConfigurationOptions;\n};\n\nconst writeDictionary = async (\n dictionary: DictionaryAPI,\n configuration: IntlayerConfig\n) => {\n const appLogger = getAppLogger(configuration);\n appLogger(`Writing dictionary ${dictionary.key}`);\n await buildDictionary([dictionary], configuration);\n};\n\nexport const liveSync = async (options?: LiveSyncOptions) => {\n const configuration = getConfiguration(options?.configOptions);\n const appLogger = getAppLogger(configuration);\n\n const { liveSyncPort, liveSyncURL } = configuration.editor;\n\n let parallelProcess: ParallelHandle | null = null;\n let eventListener: IntlayerEventListener | null = null;\n let _isHotReloadConnected = false;\n let _connectionStatus = 'disconnected'; // 'connected', 'connecting', 'reconnecting', 'disconnected', 'error'\n\n // Start the parallel process if provided\n if (options?.with) {\n parallelProcess = runParallel(options.with);\n // Handle the promise to avoid unhandled rejection\n parallelProcess.result.catch(() => {\n // Parallel process failed or was terminated\n });\n }\n\n // Initialize the event listener for hot reload if configured\n if (\n configuration.editor.liveSync &&\n configuration.editor.backendURL &&\n configuration.editor.clientId &&\n configuration.editor.clientSecret\n ) {\n eventListener = new IntlayerEventListener(configuration);\n _connectionStatus = 'connecting';\n\n // Set up connection callbacks\n eventListener.onConnectionOpen = () => {\n _connectionStatus = 'connected';\n _isHotReloadConnected = true;\n appLogger('Live sync connection established');\n };\n\n eventListener.onConnectionError = (error) => {\n _connectionStatus = 'error';\n _isHotReloadConnected = false;\n const errorEvent = error as any;\n appLogger(\n `Live sync connection error: ${errorEvent.message ?? 'Unknown error'}`,\n {\n level: 'warn',\n }\n );\n\n // If this is a \"terminated: other side closed\" error, it's likely a server restart\n if (\n errorEvent.message?.includes('terminated') ||\n errorEvent.message?.includes('closed')\n ) {\n appLogger(\n 'Server connection was terminated, automatic reconnection will be attempted...',\n {\n level: 'info',\n }\n );\n _connectionStatus = 'reconnecting';\n }\n };\n\n // Set up dictionary change callbacks\n eventListener.onDictionaryAdded = (dictionary) =>\n writeDictionary(dictionary, configuration);\n eventListener.onDictionaryChange = (dictionary) =>\n writeDictionary(dictionary, configuration);\n eventListener.onDictionaryDeleted = (dictionary) =>\n writeDictionary(dictionary, configuration);\n\n try {\n await eventListener.initialize();\n } catch (error) {\n _connectionStatus = 'error';\n _isHotReloadConnected = false;\n appLogger('Failed to initialize IntlayerEventListener:', {\n level: 'error',\n });\n appLogger(\n `Error: ${error instanceof Error ? error.message : String(error)}`,\n {\n level: 'error',\n }\n );\n }\n } else if (!configuration.editor.liveSync) {\n appLogger(\n 'Hot reload is disabled. Please enable it in the configuration (editor.liveSync).'\n );\n } else if (\n !configuration.editor.clientId ||\n !configuration.editor.clientSecret\n ) {\n appLogger(\n 'Missing client credentials for hot reload. Please configure clientId and clientSecret'\n );\n }\n\n const server = createServer(async (req, res) => {\n // Handle CORS preflight requests\n if (req.method === 'OPTIONS') {\n res.writeHead(200, {\n 'Access-Control-Allow-Origin': '*',\n 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',\n 'Access-Control-Allow-Headers': 'Content-Type, Authorization',\n });\n\n res.end();\n return;\n }\n\n if (req.url?.startsWith('/dictionaries')) {\n res.writeHead(200, {\n 'Content-Type': 'application/json; charset=utf-8',\n 'Cache-Control': 'no-store',\n 'Access-Control-Allow-Origin': '*',\n 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',\n 'Access-Control-Allow-Headers': 'Content-Type, Authorization',\n });\n const dictionaries = getDictionaries(configuration);\n\n const prefix = '/dictionaries/';\n if (req.url.startsWith(prefix)) {\n const [key, locale] = decodeURIComponent(req.url)\n .slice(prefix.length)\n .split('/');\n\n const dictionary = dictionaries[key] ?? null;\n\n if (locale) {\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\n const sourceLocaleContent = getLocalizedContent(\n dictionary.content,\n locale,\n {\n dictionaryKey: key,\n keyPath: [],\n }\n );\n\n res.end(JSON.stringify(sourceLocaleContent));\n return;\n }\n\n res.end(JSON.stringify(dictionary));\n return;\n }\n\n res.end(JSON.stringify(dictionaries));\n return;\n }\n\n if (req.url?.startsWith('/unmerged_dictionaries')) {\n res.writeHead(200, {\n 'Content-Type': 'application/json; charset=utf-8',\n 'Cache-Control': 'no-store',\n 'Access-Control-Allow-Origin': '*',\n 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',\n 'Access-Control-Allow-Headers': 'Content-Type, Authorization',\n });\n const unmergedDictionaries = getUnmergedDictionaries(configuration);\n\n const prefix = '/unmerged_dictionaries/';\n if (req.url.startsWith(prefix)) {\n const key = decodeURIComponent(req.url.slice(prefix.length));\n const one = unmergedDictionaries[key] ?? null;\n\n res.end(JSON.stringify(one));\n return;\n }\n\n res.end(JSON.stringify(unmergedDictionaries));\n return;\n }\n\n if (req.url === '/configuration') {\n res.writeHead(200, {\n 'Content-Type': 'application/json; charset=utf-8',\n 'Cache-Control': 'no-store',\n 'Access-Control-Allow-Origin': '*',\n 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',\n 'Access-Control-Allow-Headers': 'Content-Type, Authorization',\n });\n res.end(JSON.stringify(configuration));\n return;\n }\n\n if (req.url === '/health') {\n res.writeHead(200, {\n 'Content-Type': 'application/json; charset=utf-8',\n });\n res.end(JSON.stringify({ status: 'ok' }));\n return;\n }\n\n res.end('Not found');\n return;\n });\n\n const getLiveSyncParam = () => {\n if (!configuration.editor.liveSync) return '\\x1b[31m✗ Disabled\\x1b[0m';\n\n return '\\x1b[32m✓ Enabled\\x1b[0m';\n };\n server.listen(liveSyncPort, () => {\n console.log(`\n \\x1b[1;90mINTLAYER v${packageJson.version}\\x1b[0m\n \n Live server running at: \\x1b[90m${liveSyncURL}\\x1b[0m\n - Backend URL: \\x1b[90m${configuration.editor.backendURL ?? '-'}\\x1b[0m\n - Live sync: ${getLiveSyncParam()}\n - Parallel process: ${options?.with ? `\\x1b[90m${Array.isArray(options.with) ? options.with.join(' ') : options.with}\\x1b[0m` : '-'}\n - Access key: ${configuration.editor.clientId ?? '-'}\n `);\n });\n\n // Cleanup function to terminate child process and event listener when the main process exits\n const cleanup = () => {\n // Clean up event listener\n if (eventListener) {\n appLogger('Closing SSE connection...');\n eventListener.cleanup();\n }\n\n if (parallelProcess) {\n parallelProcess.kill();\n }\n\n server.close(() => {\n appLogger('Live sync server stopped');\n process.exit(0);\n });\n };\n\n // Handle process termination signals\n process.on('SIGINT', cleanup);\n process.on('SIGTERM', cleanup);\n process.on('exit', cleanup);\n};\n"],"mappings":";;;;;;;;;;;;AAsB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