imcp 0.1.7 → 0.1.8-dev

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 (314) hide show
  1. package/dist/cli/commands/install.js +1 -106
  2. package/dist/cli/commands/install.js.map +1 -0
  3. package/dist/cli/commands/list.js +1 -90
  4. package/dist/cli/commands/list.js.map +1 -0
  5. package/dist/cli/commands/pull.js +1 -16
  6. package/dist/cli/commands/pull.js.map +1 -0
  7. package/dist/cli/commands/serve.js +1 -33
  8. package/dist/cli/commands/serve.js.map +1 -0
  9. package/dist/cli/commands/uninstall.js +1 -46
  10. package/dist/cli/commands/uninstall.js.map +1 -0
  11. package/dist/cli/index.js +1 -65
  12. package/dist/cli/index.js.map +1 -0
  13. package/dist/core/installers/clients/BaseClientInstaller.js +1 -282
  14. package/dist/core/installers/clients/BaseClientInstaller.js.map +1 -0
  15. package/dist/core/installers/clients/ClientInstaller.js +1 -163
  16. package/dist/core/installers/clients/ClientInstaller.js.map +1 -0
  17. package/dist/core/installers/clients/ClientInstallerFactory.js +1 -36
  18. package/dist/core/installers/clients/ClientInstallerFactory.js.map +1 -0
  19. package/dist/core/installers/clients/ClineInstaller.js +1 -30
  20. package/dist/core/installers/clients/ClineInstaller.js.map +1 -0
  21. package/dist/core/installers/clients/ExtensionInstaller.js +1 -151
  22. package/dist/core/installers/clients/ExtensionInstaller.js.map +1 -0
  23. package/dist/core/installers/clients/GithubCopilotInstaller.js +1 -68
  24. package/dist/core/installers/clients/GithubCopilotInstaller.js.map +1 -0
  25. package/dist/core/installers/clients/MSRooCodeInstaller.js +1 -28
  26. package/dist/core/installers/clients/MSRooCodeInstaller.js.map +1 -0
  27. package/dist/core/installers/index.js +1 -8
  28. package/dist/core/installers/index.js.map +1 -0
  29. package/dist/core/installers/requirements/BaseInstaller.js +1 -56
  30. package/dist/core/installers/requirements/BaseInstaller.js.map +1 -0
  31. package/dist/core/installers/requirements/CommandInstaller.js +1 -213
  32. package/dist/core/installers/requirements/CommandInstaller.js.map +1 -0
  33. package/dist/core/installers/requirements/GeneralInstaller.js +1 -126
  34. package/dist/core/installers/requirements/GeneralInstaller.js.map +1 -0
  35. package/dist/core/installers/requirements/InstallerFactory.js +1 -99
  36. package/dist/core/installers/requirements/InstallerFactory.js.map +1 -0
  37. package/dist/core/installers/requirements/NpmInstaller.js +1 -235
  38. package/dist/core/installers/requirements/NpmInstaller.js.map +1 -0
  39. package/dist/core/installers/requirements/NugetInstaller.js +1 -188
  40. package/dist/core/installers/requirements/NugetInstaller.js.map +1 -0
  41. package/dist/core/installers/requirements/PipInstaller.js +1 -192
  42. package/dist/core/installers/requirements/PipInstaller.js.map +1 -0
  43. package/dist/core/installers/requirements/RequirementInstaller.js +1 -2
  44. package/dist/core/installers/requirements/RequirementInstaller.js.map +1 -0
  45. package/dist/core/loaders/ConfigurationLoader.js +1 -256
  46. package/dist/core/loaders/ConfigurationLoader.js.map +1 -0
  47. package/dist/core/loaders/ConfigurationProvider.js +1 -383
  48. package/dist/core/loaders/ConfigurationProvider.js.map +1 -0
  49. package/dist/core/loaders/InstallOperationManager.js +1 -310
  50. package/dist/core/loaders/InstallOperationManager.js.map +1 -0
  51. package/dist/core/loaders/ServerSchemaLoader.js +1 -108
  52. package/dist/core/loaders/ServerSchemaLoader.js.map +1 -0
  53. package/dist/core/loaders/ServerSchemaProvider.js +1 -89
  54. package/dist/core/loaders/ServerSchemaProvider.js.map +1 -0
  55. package/dist/core/loaders/SystemSettingsManager.js +1 -256
  56. package/dist/core/loaders/SystemSettingsManager.js.map +1 -0
  57. package/dist/core/metadatas/constants.js +1 -100
  58. package/dist/core/metadatas/constants.js.map +1 -0
  59. package/dist/core/metadatas/recordingConstants.js +1 -46
  60. package/dist/core/metadatas/recordingConstants.js.map +1 -0
  61. package/dist/core/metadatas/types.js +1 -15
  62. package/dist/core/metadatas/types.js.map +1 -0
  63. package/dist/core/onboard/FeedOnboardService.js +1 -422
  64. package/dist/core/onboard/FeedOnboardService.js.map +1 -0
  65. package/dist/core/onboard/OnboardProcessor.js +1 -333
  66. package/dist/core/onboard/OnboardProcessor.js.map +1 -0
  67. package/dist/core/onboard/OnboardStatus.js +1 -9
  68. package/dist/core/onboard/OnboardStatus.js.map +1 -0
  69. package/dist/core/onboard/OnboardStatusManager.js +1 -360
  70. package/dist/core/onboard/OnboardStatusManager.js.map +1 -0
  71. package/dist/core/validators/FeedValidator.js +1 -133
  72. package/dist/core/validators/FeedValidator.js.map +1 -0
  73. package/dist/core/validators/IServerValidator.js +1 -1
  74. package/dist/core/validators/IServerValidator.js.map +1 -0
  75. package/dist/core/validators/SSEServerValidator.js +1 -38
  76. package/dist/core/validators/SSEServerValidator.js.map +1 -0
  77. package/dist/core/validators/ServerValidatorFactory.js +1 -44
  78. package/dist/core/validators/ServerValidatorFactory.js.map +1 -0
  79. package/dist/core/validators/StdioServerValidator.js +1 -281
  80. package/dist/core/validators/StdioServerValidator.js.map +1 -0
  81. package/dist/index.js +1 -18
  82. package/dist/index.js.map +1 -0
  83. package/dist/services/InstallationService.js +1 -81
  84. package/dist/services/InstallationService.js.map +1 -0
  85. package/dist/services/MCPManager.js +1 -197
  86. package/dist/services/MCPManager.js.map +1 -0
  87. package/dist/services/RequirementService.js +1 -548
  88. package/dist/services/RequirementService.js.map +1 -0
  89. package/dist/services/ServerService.js +1 -127
  90. package/dist/services/ServerService.js.map +1 -0
  91. package/dist/services/TelemetryService.js +1 -53
  92. package/dist/services/TelemetryService.js.map +1 -0
  93. package/dist/utils/UpdateCheckTracker.js +1 -79
  94. package/dist/utils/UpdateCheckTracker.js.map +1 -0
  95. package/dist/utils/adoUtils.js +1 -254
  96. package/dist/utils/adoUtils.js.map +1 -0
  97. package/dist/utils/clientUtils.js +1 -65
  98. package/dist/utils/clientUtils.js.map +1 -0
  99. package/dist/utils/feedUtils.js +1 -28
  100. package/dist/utils/feedUtils.js.map +1 -0
  101. package/dist/utils/githubAuth.js +1 -177
  102. package/dist/utils/githubAuth.js.map +1 -0
  103. package/dist/utils/githubUtils.js +1 -125
  104. package/dist/utils/githubUtils.js.map +1 -0
  105. package/dist/utils/logger.js +1 -176
  106. package/dist/utils/logger.js.map +1 -0
  107. package/dist/utils/macroExpressionUtils.js +1 -93
  108. package/dist/utils/macroExpressionUtils.js.map +1 -0
  109. package/dist/utils/osUtils.js +1 -664
  110. package/dist/utils/osUtils.js.map +1 -0
  111. package/dist/utils/versionUtils.js +1 -101
  112. package/dist/utils/versionUtils.js.map +1 -0
  113. package/dist/web/contract/serverContract.js +1 -1
  114. package/dist/web/contract/serverContract.js.map +1 -0
  115. package/dist/web/public/js/api.js +2 -132
  116. package/dist/web/public/js/api.js.map +1 -0
  117. package/dist/web/public/js/detailsWidget.js +2 -264
  118. package/dist/web/public/js/detailsWidget.js.map +1 -0
  119. package/dist/web/public/js/flights/flights.js +2 -127
  120. package/dist/web/public/js/flights/flights.js.map +1 -0
  121. package/dist/web/public/js/modal/index.js +2 -52
  122. package/dist/web/public/js/modal/index.js.map +1 -0
  123. package/dist/web/public/js/modal/installModal.js +2 -162
  124. package/dist/web/public/js/modal/installModal.js.map +1 -0
  125. package/dist/web/public/js/modal/installation.js +2 -266
  126. package/dist/web/public/js/modal/installation.js.map +1 -0
  127. package/dist/web/public/js/modal/loadingModal.js +2 -182
  128. package/dist/web/public/js/modal/loadingModal.js.map +1 -0
  129. package/dist/web/public/js/modal/modalSetup.js +2 -595
  130. package/dist/web/public/js/modal/modalSetup.js.map +1 -0
  131. package/dist/web/public/js/modal/modalUtils.js +2 -37
  132. package/dist/web/public/js/modal/modalUtils.js.map +1 -0
  133. package/dist/web/public/js/modal/versionUtils.js +2 -20
  134. package/dist/web/public/js/modal/versionUtils.js.map +1 -0
  135. package/dist/web/public/js/modal.js +2 -42
  136. package/dist/web/public/js/modal.js.map +1 -0
  137. package/dist/web/public/js/notifications.js +2 -137
  138. package/dist/web/public/js/notifications.js.map +1 -0
  139. package/dist/web/public/js/onboard/formProcessor.js +2 -1037
  140. package/dist/web/public/js/onboard/formProcessor.js.map +1 -0
  141. package/dist/web/public/js/onboard/index.js +2 -374
  142. package/dist/web/public/js/onboard/index.js.map +1 -0
  143. package/dist/web/public/js/onboard/publishHandler.js +2 -172
  144. package/dist/web/public/js/onboard/publishHandler.js.map +1 -0
  145. package/dist/web/public/js/onboard/state.js +2 -76
  146. package/dist/web/public/js/onboard/state.js.map +1 -0
  147. package/dist/web/public/js/onboard/templates.js +2 -342
  148. package/dist/web/public/js/onboard/templates.js.map +1 -0
  149. package/dist/web/public/js/onboard/uiHandlers.js +2 -1076
  150. package/dist/web/public/js/onboard/uiHandlers.js.map +1 -0
  151. package/dist/web/public/js/onboard/validationHandlers.js +2 -493
  152. package/dist/web/public/js/onboard/validationHandlers.js.map +1 -0
  153. package/dist/web/public/js/serverCategoryDetails.js +2 -364
  154. package/dist/web/public/js/serverCategoryDetails.js.map +1 -0
  155. package/dist/web/public/js/serverCategoryList.js +2 -241
  156. package/dist/web/public/js/serverCategoryList.js.map +1 -0
  157. package/dist/web/public/js/settings.js +2 -314
  158. package/dist/web/public/js/settings.js.map +1 -0
  159. package/dist/web/server.js +1 -404
  160. package/dist/web/server.js.map +1 -0
  161. package/package.json +8 -2
  162. package/.github/ISSUE_TEMPLATE/JitAccess.yml +0 -28
  163. package/.github/acl/access.yml +0 -20
  164. package/.github/compliance/inventory.yml +0 -5
  165. package/.github/policies/jit.yml +0 -19
  166. package/.github/workflows/build.yml +0 -28
  167. package/.roo/rules-code/rules.md +0 -88
  168. package/dist/cli/commands/start.d.ts +0 -2
  169. package/dist/cli/commands/start.js +0 -32
  170. package/dist/cli/commands/sync.d.ts +0 -2
  171. package/dist/cli/commands/sync.js +0 -17
  172. package/dist/core/ConfigurationLoader.d.ts +0 -32
  173. package/dist/core/ConfigurationLoader.js +0 -236
  174. package/dist/core/ConfigurationProvider.d.ts +0 -35
  175. package/dist/core/ConfigurationProvider.js +0 -375
  176. package/dist/core/InstallationService.d.ts +0 -50
  177. package/dist/core/InstallationService.js +0 -350
  178. package/dist/core/MCPManager.d.ts +0 -28
  179. package/dist/core/MCPManager.js +0 -188
  180. package/dist/core/RequirementService.d.ts +0 -40
  181. package/dist/core/RequirementService.js +0 -110
  182. package/dist/core/ServerSchemaLoader.d.ts +0 -11
  183. package/dist/core/ServerSchemaLoader.js +0 -43
  184. package/dist/core/ServerSchemaProvider.d.ts +0 -17
  185. package/dist/core/ServerSchemaProvider.js +0 -120
  186. package/dist/core/constants.d.ts +0 -47
  187. package/dist/core/constants.js +0 -94
  188. package/dist/core/installers/BaseInstaller.d.ts +0 -74
  189. package/dist/core/installers/BaseInstaller.js +0 -253
  190. package/dist/core/installers/ClientInstaller.d.ts +0 -23
  191. package/dist/core/installers/ClientInstaller.js +0 -564
  192. package/dist/core/installers/CommandInstaller.d.ts +0 -37
  193. package/dist/core/installers/CommandInstaller.js +0 -173
  194. package/dist/core/installers/GeneralInstaller.d.ts +0 -33
  195. package/dist/core/installers/GeneralInstaller.js +0 -85
  196. package/dist/core/installers/InstallerFactory.d.ts +0 -54
  197. package/dist/core/installers/InstallerFactory.js +0 -97
  198. package/dist/core/installers/NpmInstaller.d.ts +0 -26
  199. package/dist/core/installers/NpmInstaller.js +0 -127
  200. package/dist/core/installers/PipInstaller.d.ts +0 -28
  201. package/dist/core/installers/PipInstaller.js +0 -127
  202. package/dist/core/installers/RequirementInstaller.d.ts +0 -33
  203. package/dist/core/installers/RequirementInstaller.js +0 -3
  204. package/dist/core/types.d.ts +0 -166
  205. package/dist/core/types.js +0 -16
  206. package/dist/services/InstallRequestValidator.d.ts +0 -21
  207. package/dist/services/InstallRequestValidator.js +0 -99
  208. package/dist/web/public/js/modal/installHandler.js +0 -227
  209. package/dist/web/public/js/modal/loadingUI.js +0 -74
  210. package/dist/web/public/js/modal/messageQueue.js +0 -112
  211. package/dist/web/public/js/modal/modalUI.js +0 -214
  212. package/dist/web/public/js/modal/version.js +0 -20
  213. package/dist/web/public/js/onboard/ONBOARDING_PAGE_DESIGN.md +0 -370
  214. package/docs/ONBOARDING_PAGE_DESIGN.md +0 -260
  215. package/docs/Telemetry.md +0 -136
  216. package/memory-bank/activeContext.md +0 -26
  217. package/memory-bank/decisionLog.md +0 -91
  218. package/memory-bank/productContext.md +0 -41
  219. package/memory-bank/progress.md +0 -35
  220. package/memory-bank/systemPatterns.md +0 -10
  221. package/src/cli/commands/install.ts +0 -139
  222. package/src/cli/commands/list.ts +0 -113
  223. package/src/cli/commands/pull.ts +0 -16
  224. package/src/cli/commands/serve.ts +0 -39
  225. package/src/cli/commands/uninstall.ts +0 -64
  226. package/src/cli/index.ts +0 -82
  227. package/src/core/installers/clients/BaseClientInstaller.ts +0 -341
  228. package/src/core/installers/clients/ClientInstaller.ts +0 -222
  229. package/src/core/installers/clients/ClientInstallerFactory.ts +0 -43
  230. package/src/core/installers/clients/ClineInstaller.ts +0 -35
  231. package/src/core/installers/clients/ExtensionInstaller.ts +0 -165
  232. package/src/core/installers/clients/GithubCopilotInstaller.ts +0 -79
  233. package/src/core/installers/clients/MSRooCodeInstaller.ts +0 -32
  234. package/src/core/installers/index.ts +0 -11
  235. package/src/core/installers/requirements/BaseInstaller.ts +0 -85
  236. package/src/core/installers/requirements/CommandInstaller.ts +0 -231
  237. package/src/core/installers/requirements/GeneralInstaller.ts +0 -133
  238. package/src/core/installers/requirements/InstallerFactory.ts +0 -114
  239. package/src/core/installers/requirements/NpmInstaller.ts +0 -271
  240. package/src/core/installers/requirements/NugetInstaller.ts +0 -203
  241. package/src/core/installers/requirements/PipInstaller.ts +0 -207
  242. package/src/core/installers/requirements/RequirementInstaller.ts +0 -42
  243. package/src/core/loaders/ConfigurationLoader.ts +0 -298
  244. package/src/core/loaders/ConfigurationProvider.ts +0 -462
  245. package/src/core/loaders/InstallOperationManager.ts +0 -367
  246. package/src/core/loaders/ServerSchemaLoader.ts +0 -117
  247. package/src/core/loaders/ServerSchemaProvider.ts +0 -99
  248. package/src/core/loaders/SystemSettingsManager.ts +0 -278
  249. package/src/core/metadatas/constants.ts +0 -122
  250. package/src/core/metadatas/recordingConstants.ts +0 -65
  251. package/src/core/metadatas/types.ts +0 -202
  252. package/src/core/onboard/FeedOnboardService.ts +0 -501
  253. package/src/core/onboard/OnboardProcessor.ts +0 -356
  254. package/src/core/onboard/OnboardStatus.ts +0 -60
  255. package/src/core/onboard/OnboardStatusManager.ts +0 -416
  256. package/src/core/validators/FeedValidator.ts +0 -135
  257. package/src/core/validators/IServerValidator.ts +0 -21
  258. package/src/core/validators/SSEServerValidator.ts +0 -43
  259. package/src/core/validators/ServerValidatorFactory.ts +0 -51
  260. package/src/core/validators/StdioServerValidator.ts +0 -313
  261. package/src/index.ts +0 -44
  262. package/src/services/InstallationService.ts +0 -102
  263. package/src/services/MCPManager.ts +0 -249
  264. package/src/services/RequirementService.ts +0 -627
  265. package/src/services/ServerService.ts +0 -161
  266. package/src/services/TelemetryService.ts +0 -59
  267. package/src/utils/UpdateCheckTracker.ts +0 -86
  268. package/src/utils/adoUtils.ts +0 -293
  269. package/src/utils/clientUtils.ts +0 -72
  270. package/src/utils/feedUtils.ts +0 -31
  271. package/src/utils/githubAuth.ts +0 -212
  272. package/src/utils/githubUtils.ts +0 -164
  273. package/src/utils/logger.ts +0 -195
  274. package/src/utils/macroExpressionUtils.ts +0 -104
  275. package/src/utils/osUtils.ts +0 -700
  276. package/src/utils/versionUtils.ts +0 -114
  277. package/src/web/contract/serverContract.ts +0 -74
  278. package/src/web/public/css/detailsWidget.css +0 -235
  279. package/src/web/public/css/modal.css +0 -757
  280. package/src/web/public/css/notifications.css +0 -101
  281. package/src/web/public/css/onboard.css +0 -107
  282. package/src/web/public/css/serverCategoryList.css +0 -120
  283. package/src/web/public/css/serverDetails.css +0 -139
  284. package/src/web/public/index.html +0 -359
  285. package/src/web/public/js/api.js +0 -132
  286. package/src/web/public/js/detailsWidget.js +0 -264
  287. package/src/web/public/js/flights/flights.js +0 -127
  288. package/src/web/public/js/modal/index.js +0 -52
  289. package/src/web/public/js/modal/installModal.js +0 -162
  290. package/src/web/public/js/modal/installation.js +0 -266
  291. package/src/web/public/js/modal/loadingModal.js +0 -182
  292. package/src/web/public/js/modal/modalSetup.js +0 -595
  293. package/src/web/public/js/modal/modalUtils.js +0 -37
  294. package/src/web/public/js/modal/versionUtils.js +0 -20
  295. package/src/web/public/js/modal.js +0 -42
  296. package/src/web/public/js/notifications.js +0 -137
  297. package/src/web/public/js/onboard/formProcessor.js +0 -1037
  298. package/src/web/public/js/onboard/index.js +0 -374
  299. package/src/web/public/js/onboard/publishHandler.js +0 -172
  300. package/src/web/public/js/onboard/state.js +0 -76
  301. package/src/web/public/js/onboard/templates.js +0 -342
  302. package/src/web/public/js/onboard/uiHandlers.js +0 -1076
  303. package/src/web/public/js/onboard/validationHandlers.js +0 -493
  304. package/src/web/public/js/serverCategoryDetails.js +0 -364
  305. package/src/web/public/js/serverCategoryList.js +0 -241
  306. package/src/web/public/js/settings.js +0 -314
  307. package/src/web/public/modal.html +0 -84
  308. package/src/web/public/onboard.html +0 -296
  309. package/src/web/public/settings.html +0 -135
  310. package/src/web/public/styles.css +0 -277
  311. package/src/web/server.ts +0 -478
  312. package/tsconfig.json +0 -18
  313. package/wiki/Installation.md +0 -3
  314. package/wiki/Publish.md +0 -3
@@ -1,29 +1,2 @@
1
- import fs from 'fs/promises';
2
- import { Logger } from './logger.js';
3
- import { LOCAL_FEEDS_DIR } from '../core/metadatas/constants.js';
4
- /**
5
- * Checks if local feeds exist in the LOCAL_FEEDS_DIR
6
- * Returns true if the directory exists and contains at least one .json file
7
- */
8
- export async function hasLocalFeeds() {
9
- try {
10
- Logger.debug('Checking for local feeds existence');
11
- const feedsExist = await fs.access(LOCAL_FEEDS_DIR)
12
- .then(() => true)
13
- .catch(() => false);
14
- if (!feedsExist) {
15
- Logger.debug('Local feeds directory does not exist');
16
- return false;
17
- }
18
- // Check if directory contains any json files
19
- const files = await fs.readdir(LOCAL_FEEDS_DIR);
20
- const hasJsonFiles = files.some(file => file.endsWith('.json'));
21
- Logger.debug(`Local feeds directory ${hasJsonFiles ? 'contains' : 'does not contain'} JSON files`);
22
- return hasJsonFiles;
23
- }
24
- catch (error) {
25
- Logger.error('Error checking local feeds:', error);
26
- return false;
27
- }
28
- }
1
+ import fs from"fs/promises";import{Logger}from"./logger.js";import{LOCAL_FEEDS_DIR}from"../core/metadatas/constants.js";export async function hasLocalFeeds(){try{if(Logger.debug("Checking for local feeds existence"),!await fs.access(LOCAL_FEEDS_DIR).then((()=>!0)).catch((()=>!1)))return Logger.debug("Local feeds directory does not exist"),!1;const e=(await fs.readdir(LOCAL_FEEDS_DIR)).some((e=>e.endsWith(".json")));return Logger.debug(`Local feeds directory ${e?"contains":"does not contain"} JSON files`),e}catch(e){return Logger.error("Error checking local feeds:",e),!1}}
29
2
  //# sourceMappingURL=feedUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["fs","Logger","LOCAL_FEEDS_DIR","async","hasLocalFeeds","debug","access","then","catch","hasJsonFiles","readdir","some","file","endsWith","error"],"sources":["../../src/utils/feedUtils.ts"],"mappings":"OAAOA,OAAQ,qBACNC,WAAc,qBACdC,oBAAuB,wCAMzBC,eAAeC,gBACpB,IAME,GALAH,OAAOI,MAAM,6CACYL,GAAGM,OAAOJ,iBAChCK,MAAK,KAAM,IACXC,OAAM,KAAM,IAIb,OADAP,OAAOI,MAAM,yCACN,EAIT,MACMI,SADcT,GAAGU,QAAQR,kBACJS,MAAKC,GAAQA,EAAKC,SAAS,WAGtD,OADAZ,OAAOI,MAAM,yBAAyBI,EAAe,WAAa,iCAC3DA,CACT,CAAE,MAAOK,GAEP,OADAb,OAAOa,MAAM,8BAA+BA,IACrC,CACT,CACF","ignoreList":[]}
@@ -1,178 +1,2 @@
1
- import { isToolInstalled, installCLI } from './osUtils.js';
2
- import { exec, spawn } from 'child_process';
3
- import util from 'util';
4
- import { Logger } from './logger.js';
5
- import fs from 'fs/promises';
6
- import path from 'path';
7
- import { USER_INFO_PATH } from '../core/metadatas/constants.js';
8
- const execAsync = util.promisify(exec);
9
- // Create a promisified version of spawn that returns a Promise
10
- const spawnAsync = (command, args, options = {}) => {
11
- return new Promise((resolve, reject) => {
12
- const childProcess = spawn(command, args, options);
13
- childProcess.on('close', (code) => {
14
- if (code === 0) {
15
- resolve(code);
16
- }
17
- else {
18
- reject(new Error(`Process exited with code ${code}`));
19
- }
20
- });
21
- childProcess.on('error', (err) => {
22
- reject(err);
23
- });
24
- });
25
- };
26
- class GithubAuthError extends Error {
27
- constructor(message) {
28
- super(message);
29
- this.name = 'GithubAuthError';
30
- }
31
- }
32
- export async function checkGithubAuth() {
33
- Logger.debug('Starting GitHub authentication check');
34
- try {
35
- // Check if gh CLI is installed
36
- if (!await isToolInstalled('gh')) {
37
- Logger.log('Installing required GitHub CLI...');
38
- await installCLI('gh');
39
- // Verify gh CLI was installed correctly, with retry mechanism
40
- if (!await isToolInstalled('gh')) {
41
- throw new Error('Failed to install GitHub CLI. Please install it manually and try again.');
42
- }
43
- Logger.debug('GitHub CLI installed successfully and verified');
44
- }
45
- }
46
- catch (error) {
47
- Logger.error('Error during tool installation:', error);
48
- throw new Error(`Tool installation failed: ${error.message}`);
49
- }
50
- try {
51
- Logger.debug('Checking GitHub authentication status');
52
- // Check if user is authenticated
53
- const { stdout: viewerData } = await execAsync('gh api user');
54
- const viewer = JSON.parse(viewerData);
55
- Logger.debug({
56
- action: 'github_auth_check',
57
- username: viewer.login
58
- });
59
- // Check if user is using company account (ends with _microsoft)
60
- if (!viewer.login.toLowerCase().endsWith('_microsoft')) {
61
- const error = 'Error: You must be logged in with a Microsoft account (username should end with _microsoft). ' +
62
- 'Please run "gh auth logout" and then "gh auth login" with your Microsoft account. Current username: ' +
63
- viewer.login;
64
- Logger.error(error, {
65
- username: viewer.login
66
- });
67
- throw new GithubAuthError(error);
68
- }
69
- // After Microsoft account verification, persist user information
70
- await persistUserInfo();
71
- Logger.debug('GitHub authentication verified successfully with Microsoft account');
72
- }
73
- catch (error) {
74
- if (error instanceof GithubAuthError) {
75
- throw error;
76
- }
77
- // If the error is due to not being authenticated
78
- const errorMessage = error?.stderr || error.message;
79
- if (errorMessage.includes('please run: gh auth login') || errorMessage.includes('GH_TOKEN')) {
80
- Logger.log('GitHub authentication required at the first run. Please login account end with _microsoft.');
81
- try {
82
- // Use spawnAsync for interactive authentication
83
- await spawnAsync('gh', ['auth', 'login', '--web', '--hostname', 'github.com', '--git-protocol', 'https'], {
84
- stdio: 'inherit' // User sees & interacts directly with the process
85
- });
86
- Logger.debug('GitHub authentication process completed');
87
- // Verify the authentication was successful
88
- const { stdout: viewerData } = await execAsync('gh api user');
89
- const viewer = JSON.parse(viewerData);
90
- // Check if user is using company account (ends with _microsoft)
91
- if (!viewer.login.toLowerCase().endsWith('_microsoft')) {
92
- throw new GithubAuthError('You must be logged in with a Microsoft account (username should end with _microsoft).');
93
- }
94
- // After Microsoft account verification, persist user information
95
- await persistUserInfo();
96
- Logger.debug(`Successfully authenticated as ${viewer.login}`);
97
- return; // Auth successful, continue execution
98
- }
99
- catch (loginError) {
100
- Logger.error('Error during GitHub authentication process', loginError);
101
- // If the interactive login failed, provide manual instructions
102
- const authInstructions = '\nError: GitHub authentication required. Please follow these steps:\n\n' +
103
- '1. Run this command:\n' +
104
- ' gh auth login --web --hostname github.com --git-protocol https\n' +
105
- '2. Choose Y when prompted authenticating Git with your GitHub credentials.\n' +
106
- '3. Follow the prompts to login with your Microsoft account (username must end with _microsoft)\n' +
107
- '4. Authorize ai-microsoft organization.\n' +
108
- '5. After successful login, run imcp command again.\n\n';
109
- Logger.log(authInstructions);
110
- throw new GithubAuthError('GitHub authentication required. Please login first and try again.');
111
- }
112
- }
113
- else {
114
- const errorMessage = `Failed to verify GitHub authentication: ${error.message}`;
115
- Logger.error(errorMessage, error);
116
- throw new GithubAuthError(errorMessage);
117
- }
118
- }
119
- }
120
- /**
121
- * Persists GitHub user information to the system-specific settings directory.
122
- * Only performs persistence on non-Windows systems (Linux/macOS).
123
- */
124
- async function persistUserInfo() {
125
- try {
126
- Logger.debug('Starting user information persistence check');
127
- // 1. Skip persistence on Windows systems
128
- if (process.platform === 'win32') {
129
- Logger.debug('Skipping user info persistence on Windows system');
130
- return;
131
- }
132
- // 2. Check if file exists and has all required keys
133
- try {
134
- if (await fs.access(USER_INFO_PATH).then(() => true).catch(() => false)) {
135
- const existingContent = await fs.readFile(USER_INFO_PATH, 'utf8');
136
- const existingData = JSON.parse(existingContent);
137
- if (existingData.alias && existingData.name && existingData.email) {
138
- Logger.debug('User info already exists with all required fields, skipping update');
139
- return;
140
- }
141
- }
142
- }
143
- catch (err) {
144
- Logger.debug('No valid existing user info found, proceeding with persistence');
145
- }
146
- // Proceed with persistence since both checks passed
147
- Logger.debug('Proceeding with user information persistence');
148
- // Get user info from GitHub API
149
- const { stdout: userDataStr } = await execAsync('gh api user');
150
- const userData = JSON.parse(userDataStr);
151
- const { login, name, email } = userData;
152
- Logger.debug({ message: 'Retrieved user information from GitHub API', login, name, email });
153
- // Check if login ends with _microsoft
154
- if (!login.toLowerCase().endsWith('_microsoft')) {
155
- Logger.log(`GitHub login "${login}" does not end with _microsoft, skipping user information persistence`);
156
- return;
157
- }
158
- // Create directory if it doesn't exist
159
- await fs.mkdir(path.dirname(USER_INFO_PATH), { recursive: true });
160
- Logger.debug(`Ensuring directory exists for user info at ${USER_INFO_PATH}`);
161
- // Extract alias from login (remove _microsoft suffix)
162
- const alias = login.toLowerCase().replace(/_microsoft$/, '');
163
- // Prepare user information
164
- const userInfo = {
165
- alias,
166
- name,
167
- email
168
- };
169
- // Write user information to file
170
- await fs.writeFile(USER_INFO_PATH, JSON.stringify(userInfo, null, 2));
171
- Logger.debug({ message: 'User information persisted successfully', path: USER_INFO_PATH, alias });
172
- }
173
- catch (error) {
174
- Logger.error('Failed to persist user information:', error);
175
- // Don't throw - persistence failure shouldn't block auth flow
176
- }
177
- }
1
+ import{isToolInstalled,installCLI}from"./osUtils.js";import{exec,spawn}from"child_process";import util from"util";import{Logger}from"./logger.js";import fs from"fs/promises";import path from"path";import{USER_INFO_PATH}from"../core/metadatas/constants.js";const execAsync=util.promisify(exec),spawnAsync=(e,t,o={})=>new Promise(((i,r)=>{const s=spawn(e,t,o);s.on("close",(e=>{0===e?i(e):r(new Error(`Process exited with code ${e}`))})),s.on("error",(e=>{r(e)}))}));class GithubAuthError extends Error{constructor(e){super(e),this.name="GithubAuthError"}}export async function checkGithubAuth(){Logger.debug("Starting GitHub authentication check");try{if(!await isToolInstalled("gh")){if(Logger.log("Installing required GitHub CLI..."),await installCLI("gh"),!await isToolInstalled("gh"))throw new Error("Failed to install GitHub CLI. Please install it manually and try again.");Logger.debug("GitHub CLI installed successfully and verified")}}catch(e){throw Logger.error("Error during tool installation:",e),new Error(`Tool installation failed: ${e.message}`)}try{Logger.debug("Checking GitHub authentication status");const{stdout:e}=await execAsync("gh api user"),t=JSON.parse(e);if(Logger.debug({action:"github_auth_check",username:t.login}),!t.login.toLowerCase().endsWith("_microsoft")){const e='Error: You must be logged in with a Microsoft account (username should end with _microsoft). Please run "gh auth logout" and then "gh auth login" with your Microsoft account. Current username: '+t.login;throw Logger.error(e,{username:t.login}),new GithubAuthError(e)}await persistUserInfo(),Logger.debug("GitHub authentication verified successfully with Microsoft account")}catch(e){if(e instanceof GithubAuthError)throw e;const t=e?.stderr||e.message;if(!t.includes("please run: gh auth login")&&!t.includes("GH_TOKEN")){const t=`Failed to verify GitHub authentication: ${e.message}`;throw Logger.error(t,e),new GithubAuthError(t)}Logger.log("GitHub authentication required at the first run. Please login account end with _microsoft.");try{await spawnAsync("gh",["auth","login","--web","--hostname","github.com","--git-protocol","https"],{stdio:"inherit"}),Logger.debug("GitHub authentication process completed");const{stdout:e}=await execAsync("gh api user"),t=JSON.parse(e);if(!t.login.toLowerCase().endsWith("_microsoft"))throw new GithubAuthError("You must be logged in with a Microsoft account (username should end with _microsoft).");return await persistUserInfo(),void Logger.debug(`Successfully authenticated as ${t.login}`)}catch(e){Logger.error("Error during GitHub authentication process",e);const t="\nError: GitHub authentication required. Please follow these steps:\n\n1. Run this command:\n gh auth login --web --hostname github.com --git-protocol https\n2. Choose Y when prompted authenticating Git with your GitHub credentials.\n3. Follow the prompts to login with your Microsoft account (username must end with _microsoft)\n4. Authorize ai-microsoft organization.\n5. After successful login, run imcp command again.\n\n";throw Logger.log(t),new GithubAuthError("GitHub authentication required. Please login first and try again.")}}}async function persistUserInfo(){try{if(Logger.debug("Starting user information persistence check"),"win32"===process.platform)return void Logger.debug("Skipping user info persistence on Windows system");try{if(await fs.access(USER_INFO_PATH).then((()=>!0)).catch((()=>!1))){const e=await fs.readFile(USER_INFO_PATH,"utf8"),t=JSON.parse(e);if(t.alias&&t.name&&t.email)return void Logger.debug("User info already exists with all required fields, skipping update")}}catch(e){Logger.debug("No valid existing user info found, proceeding with persistence")}Logger.debug("Proceeding with user information persistence");const{stdout:e}=await execAsync("gh api user"),t=JSON.parse(e),{login:o,name:i,email:r}=t;if(Logger.debug({message:"Retrieved user information from GitHub API",login:o,name:i,email:r}),!o.toLowerCase().endsWith("_microsoft"))return void Logger.log(`GitHub login "${o}" does not end with _microsoft, skipping user information persistence`);await fs.mkdir(path.dirname(USER_INFO_PATH),{recursive:!0}),Logger.debug(`Ensuring directory exists for user info at ${USER_INFO_PATH}`);const s=o.toLowerCase().replace(/_microsoft$/,""),n={alias:s,name:i,email:r};await fs.writeFile(USER_INFO_PATH,JSON.stringify(n,null,2)),Logger.debug({message:"User information persisted successfully",path:USER_INFO_PATH,alias:s})}catch(e){Logger.error("Failed to persist user information:",e)}}
178
2
  //# sourceMappingURL=githubAuth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["isToolInstalled","installCLI","exec","spawn","util","Logger","fs","path","USER_INFO_PATH","execAsync","promisify","spawnAsync","command","args","options","Promise","resolve","reject","childProcess","on","code","Error","err","GithubAuthError","constructor","message","super","this","name","async","checkGithubAuth","debug","log","error","stdout","viewerData","viewer","JSON","parse","action","username","login","toLowerCase","endsWith","persistUserInfo","errorMessage","stderr","includes","stdio","loginError","authInstructions","process","platform","access","then","catch","existingContent","readFile","existingData","alias","email","userDataStr","userData","mkdir","dirname","recursive","replace","userInfo","writeFile","stringify"],"sources":["../../src/utils/githubAuth.ts"],"mappings":"OAASA,gBAAiBC,eAAkB,sBACnCC,KAAMC,UAAa,uBACrBC,SAAU,cACRC,WAAc,qBAChBC,OAAQ,qBACRC,SAAU,cACRC,mBAAsB,iCAS/B,MAAMC,UAAYL,KAAKM,UAAUR,MAG3BS,WAAa,CAACC,EAAiBC,EAAgBC,EAAe,KAC3D,IAAIC,SAAQ,CAACC,EAASC,KAC3B,MAAMC,EAAef,MAAMS,EAASC,EAAMC,GAE1CI,EAAaC,GAAG,SAAUC,IACX,IAATA,EACFJ,EAAQI,GAERH,EAAO,IAAII,MAAM,4BAA4BD,KAC/C,IAGFF,EAAaC,GAAG,SAAUG,IACxBL,EAAOK,EAAI,GACX,IAIN,MAAMC,wBAAwBF,MAC5B,WAAAG,CAAYC,GACVC,MAAMD,GACNE,KAAKC,KAAO,iBACd,SAGKC,eAAeC,kBACpBzB,OAAO0B,MAAM,wCAEb,IAEE,UAAW/B,gBAAgB,MAAO,CAKhC,GAJAK,OAAO2B,IAAI,2CACL/B,WAAW,aAGND,gBAAgB,MACzB,MAAM,IAAIqB,MAAM,2EAGlBhB,OAAO0B,MAAM,iDACf,CACF,CAAE,MAAOE,GAEP,MADA5B,OAAO4B,MAAM,kCAAmCA,GAC1C,IAAIZ,MAAM,6BAA8BY,EAAgBR,UAChE,CAEA,IACEpB,OAAO0B,MAAM,yCAEb,MAAQG,OAAQC,SAAqB1B,UAAU,eACzC2B,EAASC,KAAKC,MAAMH,GAQ1B,GANA9B,OAAO0B,MAAM,CACXQ,OAAQ,oBACRC,SAAUJ,EAAOK,SAIdL,EAAOK,MAAMC,cAAcC,SAAS,cAAe,CACtD,MAAMV,EAAQ,oMAEZG,EAAOK,MAIT,MAHApC,OAAO4B,MAAMA,EAAO,CAClBO,SAAUJ,EAAOK,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Gb,MAAQG,OAAQ2B,SAAsBpD,UAAU,eAC1CqD,EAAWzB,KAAKC,MAAMuB,IACtBpB,MAAEA,EAAKb,KAAEA,EAAIgC,MAAEA,GAAUE,EAK/B,GAHAzD,OAAO0B,MAAM,CAAEN,QAAS,6CAA8CgB,QAAOb,OAAMgC,WAG9EnB,EAAMC,cAAcC,SAAS,cAEhC,YADAtC,OAAO2B,IAAI,iBAAiBS,gFAKxBnC,GAAGyD,MAAMxD,KAAKyD,QAAQxD,gBAAiB,CAAEyD,WAAW,IAC1D5D,OAAO0B,MAAM,8CAA8CvB,kBAG3D,MAAMmD,EAAQlB,EAAMC,cAAcwB,QAAQ,cAAe,IAGnDC,EAAqB,CACzBR,QACA/B,OACAgC,eAIItD,GAAG8D,UAAU5D,eAAgB6B,KAAKgC,UAAUF,EAAU,KAAM,IAClE9D,OAAO0B,MAAM,CAAEN,QAAS,0CAA2ClB,KAAMC,eAAgBmD,SAC3F,CAAE,MAAO1B,GACP5B,OAAO4B,MAAM,sCAAuCA,EAEtD,CACF","ignoreList":[]}
@@ -1,126 +1,2 @@
1
- import { exec } from 'child_process';
2
- import util from 'util';
3
- import fs from 'fs/promises';
4
- import path from 'path';
5
- import { extractZipFile } from './clientUtils.js';
6
- import { SETTINGS_DIR } from '../core/metadatas/constants.js';
7
- const execAsync = util.promisify(exec);
8
- /**
9
- * Get the latest version available for a GitHub repository
10
- * @param execPromise The promise-based exec function
11
- * @param repository The GitHub repository in format 'owner/repo'
12
- * @returns The latest version or tag
13
- */
14
- export async function getGitHubLatestVersion(execPromise, repository) {
15
- try {
16
- // Use GitHub CLI to get the latest release
17
- const { stdout } = await execPromise(`gh release view --repo ${repository} --json tagName --jq .tagName`);
18
- const latestTag = stdout.trim();
19
- // Remove 'v' prefix if present
20
- return latestTag.startsWith('v') ? latestTag.substring(1) : latestTag;
21
- }
22
- catch (error) {
23
- // If gh command fails, try to get the latest tag
24
- const { stdout } = await execPromise(`git ls-remote --tags --refs https://github.com/${repository}.git | sort -t '/' -k 3 -V | tail -n 1 | awk -F/ '{print $3}'`);
25
- let latestTag = stdout.trim();
26
- // Remove 'v' prefix if present
27
- return latestTag.startsWith('v') ? latestTag.substring(1) : latestTag;
28
- }
29
- }
30
- /**
31
- * Downloads a GitHub release asset
32
- * @param repo GitHub repository in format owner/repo
33
- * @param version Version to download, can be "latest"
34
- * @param assetsName Assets name pattern (optional, but either assetsName or assetName must be provided)
35
- * @param assetName Asset name pattern (optional, but either assetsName or assetName must be provided)
36
- * @param isFolder Whether to treat the downloaded asset as a folder (default: false)
37
- * @param targetDirectory Target directory for downloads (default: SETTINGS_DIR/downloads)
38
- * @returns Object containing version and download path
39
- */
40
- export async function downloadGithubRelease(repo, version, assetsName, assetName, isFolder = false, targetDirectory) {
41
- if (!repo) {
42
- throw new Error('GitHub repository is required');
43
- }
44
- if (!assetsName && !assetName) {
45
- throw new Error('Either assetsName or assetName must be specified');
46
- }
47
- const downloadsDir = targetDirectory || path.join(SETTINGS_DIR, 'downloads');
48
- await fs.mkdir(downloadsDir, { recursive: true });
49
- // Get latest version if needed
50
- const { stdout } = await execAsync(`gh release view --repo ${repo} --json tagName --jq .tagName`);
51
- const latestTag = stdout.trim();
52
- let latestVersion = latestTag;
53
- const tagWithVPrefix = latestVersion.startsWith('v');
54
- if (tagWithVPrefix)
55
- latestVersion = latestVersion.substring(1); // Remove 'v' prefix if present
56
- const resolvedVersion = version.includes("latest") ? latestVersion : version;
57
- // Resolve asset names
58
- let resolvedAssetsName = '';
59
- let resolvedAssetName = '';
60
- if (assetsName) {
61
- resolvedAssetsName = assetsName.replace('${latest}', resolvedVersion).replace('${version}', resolvedVersion);
62
- }
63
- if (assetName) {
64
- resolvedAssetName = assetName.replace('${latest}', resolvedVersion).replace('${version}', resolvedVersion);
65
- }
66
- // Validate zip requirement for isFolder
67
- const pattern = resolvedAssetsName || resolvedAssetName;
68
- if (isFolder && (!resolvedAssetsName || !resolvedAssetsName.endsWith('.zip'))) {
69
- throw new Error('When isFolder is true, assetsName must be provided and end with .zip');
70
- }
71
- // Download the release asset
72
- const downloadPath = path.join(downloadsDir, path.basename(pattern));
73
- if (!await fileExists(downloadPath)) {
74
- await execAsync(`gh release download ${tagWithVPrefix ? `v${resolvedVersion}` : resolvedVersion} --repo ${repo} --pattern "${pattern}" -O "${downloadPath}"`);
75
- }
76
- // Handle zip extraction if needed
77
- if (isFolder && downloadPath.endsWith('.zip')) {
78
- const extractDir = path.join(downloadsDir, path.basename(pattern, '.zip'));
79
- await fs.mkdir(extractDir, { recursive: true });
80
- await extractZipFile(downloadPath, { dir: extractDir });
81
- // If resolvedAssetName is specified, look for it in the extracted directory
82
- if (resolvedAssetName) {
83
- const assetPath = path.join(extractDir, resolvedAssetName);
84
- try {
85
- await fs.access(assetPath);
86
- return { version: resolvedVersion, downloadPath: assetPath };
87
- }
88
- catch (error) {
89
- throw new Error(`Asset ${resolvedAssetName} not found in extracted directory ${extractDir}`);
90
- }
91
- }
92
- return { version: resolvedVersion, downloadPath: extractDir };
93
- }
94
- return { version: resolvedVersion, downloadPath };
95
- }
96
- /**
97
- * Helper to handle GitHub release downloads
98
- * @param requirement The requirement configuration
99
- * @param registry The GitHub release registry configuration
100
- * @returns The path to the downloaded file
101
- */
102
- export async function handleGitHubRelease(requirement, registry) {
103
- if (!registry) {
104
- throw new Error('GitHub release registry configuration is required');
105
- }
106
- const { repository, assetsName, assetName } = registry;
107
- if (!repository) {
108
- throw new Error('GitHub repository is required for GitHub release downloads');
109
- }
110
- const isZipAsset = assetsName?.endsWith('.zip') || false;
111
- const result = await downloadGithubRelease(repository, requirement.version, assetsName, assetName, isZipAsset);
112
- return {
113
- resolvedVersion: result.version,
114
- resolvedPath: result.downloadPath
115
- };
116
- }
117
- async function fileExists(filePath) {
118
- try {
119
- await fs.access(filePath);
120
- return true;
121
- }
122
- catch {
123
- return false;
124
- }
125
- }
1
+ import{exec}from"child_process";import util from"util";import fs from"fs/promises";import path from"path";import{extractZipFile}from"./clientUtils.js";import{SETTINGS_DIR}from"../core/metadatas/constants.js";const execAsync=util.promisify(exec);export async function getGitHubLatestVersion(t,e){try{const{stdout:r}=await t(`gh release view --repo ${e} --json tagName --jq .tagName`),s=r.trim();return s.startsWith("v")?s.substring(1):s}catch(r){const{stdout:s}=await t(`git ls-remote --tags --refs https://github.com/${e}.git | sort -t '/' -k 3 -V | tail -n 1 | awk -F/ '{print $3}'`);let i=s.trim();return i.startsWith("v")?i.substring(1):i}}export async function downloadGithubRelease(t,e,r,s,i=!1,a){if(!t)throw new Error("GitHub repository is required");if(!r&&!s)throw new Error("Either assetsName or assetName must be specified");const o=a||path.join(SETTINGS_DIR,"downloads");await fs.mkdir(o,{recursive:!0});const{stdout:n}=await execAsync(`gh release view --repo ${t} --json tagName --jq .tagName`);let c=n.trim();const d=c.startsWith("v");d&&(c=c.substring(1));const l=e.includes("latest")?c:e;let p="",u="";r&&(p=r.replace("${latest}",l).replace("${version}",l)),s&&(u=s.replace("${latest}",l).replace("${version}",l));const h=p||u;if(i&&(!p||!p.endsWith(".zip")))throw new Error("When isFolder is true, assetsName must be provided and end with .zip");const w=path.join(o,path.basename(h));if(await fileExists(w)||await execAsync(`gh release download ${d?`v${l}`:l} --repo ${t} --pattern "${h}" -O "${w}"`),i&&w.endsWith(".zip")){const t=path.join(o,path.basename(h,".zip"));if(await fs.mkdir(t,{recursive:!0}),await extractZipFile(w,{dir:t}),u){const e=path.join(t,u);try{return await fs.access(e),{version:l,downloadPath:e}}catch(e){throw new Error(`Asset ${u} not found in extracted directory ${t}`)}}return{version:l,downloadPath:t}}return{version:l,downloadPath:w}}export async function handleGitHubRelease(t,e){if(!e)throw new Error("GitHub release registry configuration is required");const{repository:r,assetsName:s,assetName:i}=e;if(!r)throw new Error("GitHub repository is required for GitHub release downloads");const a=s?.endsWith(".zip")||!1,o=await downloadGithubRelease(r,t.version,s,i,a);return{resolvedVersion:o.version,resolvedPath:o.downloadPath}}async function fileExists(t){try{return await fs.access(t),!0}catch{return!1}}
126
2
  //# sourceMappingURL=githubUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["exec","util","fs","path","extractZipFile","SETTINGS_DIR","execAsync","promisify","async","getGitHubLatestVersion","execPromise","repository","stdout","latestTag","trim","startsWith","substring","error","downloadGithubRelease","repo","version","assetsName","assetName","isFolder","targetDirectory","Error","downloadsDir","join","mkdir","recursive","latestVersion","tagWithVPrefix","resolvedVersion","includes","resolvedAssetsName","resolvedAssetName","replace","pattern","endsWith","downloadPath","basename","fileExists","extractDir","dir","assetPath","access","handleGitHubRelease","requirement","registry","isZipAsset","result","resolvedPath","filePath"],"sources":["../../src/utils/githubUtils.ts"],"mappings":"OACSA,SAAY,uBACdC,SAAU,cACVC,OAAQ,qBACRC,SAAU,cACRC,mBAAsB,0BAEtBC,iBAAoB,iCAE7B,MAAMC,UAAYL,KAAKM,UAAUP,aAQ1BQ,eAAeC,uBAAuBC,EAA+EC,GACxH,IAEI,MAAMC,OAAEA,SAAiBF,EAAY,0BAA0BC,kCACzDE,EAAYD,EAAOE,OAGzB,OAAOD,EAAUE,WAAW,KAAOF,EAAUG,UAAU,GAAKH,CAChE,CAAE,MAAOI,GAEL,MAAML,OAAEA,SAAiBF,EAAY,kDAAkDC,kEACvF,IAAIE,EAAYD,EAAOE,OAGvB,OAAOD,EAAUE,WAAW,KAAOF,EAAUG,UAAU,GAAKH,CAChE,CACJ,QAiBOL,eAAeU,sBAClBC,EACAC,EACAC,EACAC,EACAC,GAAoB,EACpBC,GAEA,IAAKL,EACD,MAAM,IAAIM,MAAM,iCAGpB,IAAKJ,IAAeC,EAChB,MAAM,IAAIG,MAAM,oDAGpB,MAAMC,EAAeF,GAAmBrB,KAAKwB,KAAKtB,aAAc,mBAC1DH,GAAG0B,MAAMF,EAAc,CAAEG,WAAW,IAG1C,MAAMjB,OAAEA,SAAiBN,UAAU,0BAA0Ba,kCAE7D,IAAIW,EADclB,EAAOE,OAGzB,MAAMiB,EAAiBD,EAAcf,WAAW,KAC5CgB,IAAg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oC,EAAY3B,QACZC,EACAC,EACA2B,GAGJ,MAAO,CACHjB,gBAAiBkB,EAAO9B,QACxB+B,aAAcD,EAAOX,aAE7B,CAEA/B,eAAeiC,WAAWW,GACtB,IAEI,aADMlD,GAAG2C,OAAOO,IACT,CACX,CAAE,MACE,OAAO,CACX,CACJ","ignoreList":[]}
@@ -1,177 +1,2 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
- import os from 'os';
4
- import { SETTINGS_DIR, USER_INFO_PATH } from '../core/metadatas/constants.js';
5
- import { TelemetryService } from '../services/TelemetryService.js';
6
- import { getPackageVersion } from './versionUtils.js';
7
- export var EventType;
8
- (function (EventType) {
9
- EventType["IMCP_SERVE"] = "imcp_serve";
10
- EventType["SERVER_INSTALL"] = "server_install";
11
- EventType["SERVER_UNINSTALL"] = "server_uninstall";
12
- EventType["REQUIREMENT_UPDATE"] = "requirement_update";
13
- EventType["FEED_ONBOARD"] = "feed_onboard";
14
- EventType["FEED_VALIDATE"] = "feed_validate";
15
- })(EventType || (EventType = {}));
16
- export var EventStatus;
17
- (function (EventStatus) {
18
- EventStatus["SUCCESS"] = "success";
19
- EventStatus["FAILED"] = "failed";
20
- })(EventStatus || (EventStatus = {}));
21
- export class Logger {
22
- static verbose = false;
23
- static fileLoggingEnabled = true;
24
- static logsDir = path.join(SETTINGS_DIR, 'logs');
25
- static isTestEnvironment = false;
26
- static packageVersion = getPackageVersion().packageVersion;
27
- static setVerbose(isVerbose) {
28
- this.verbose = isVerbose;
29
- }
30
- static setFileLogging(enabled) {
31
- this.fileLoggingEnabled = enabled;
32
- }
33
- static async ensureLogsDirExists() {
34
- try {
35
- await fs.promises.mkdir(this.logsDir, { recursive: true });
36
- }
37
- catch (error) {
38
- console.error(`Failed to create logs directory: ${error instanceof Error ? error.message : String(error)}`);
39
- // Disable file logging if directory creation fails
40
- this.fileLoggingEnabled = false;
41
- }
42
- }
43
- static getLogFileName() {
44
- const now = new Date();
45
- const year = now.getFullYear();
46
- const month = String(now.getMonth() + 1).padStart(2, '0');
47
- const day = String(now.getDate()).padStart(2, '0');
48
- return `${year}-${month}-${day}.log`;
49
- }
50
- static getTimestamp() {
51
- return new Date().toISOString();
52
- }
53
- static async writeToLogFile(level, content) {
54
- if (!this.fileLoggingEnabled)
55
- return;
56
- try {
57
- await this.ensureLogsDirExists();
58
- const logFile = path.join(this.logsDir, this.getLogFileName());
59
- const logEntry = `[${this.getTimestamp()}] [${level}] ${content}\n`;
60
- await fs.promises.appendFile(logFile, logEntry, { encoding: 'utf8' });
61
- }
62
- catch (error) {
63
- console.error(`Failed to write to log file: ${error instanceof Error ? error.message : String(error)}`);
64
- }
65
- }
66
- static async log(message) {
67
- console.log(message);
68
- await this.writeToLogFile('INFO', message);
69
- }
70
- static async info(message) {
71
- console.info(message);
72
- await this.writeToLogFile('INFO', message);
73
- }
74
- static async warn(message) {
75
- const yellowColor = '\x1b[33m';
76
- const resetColor = '\x1b[0m';
77
- console.warn(`${yellowColor}${message}${resetColor}`);
78
- await this.writeToLogFile('WARN', message);
79
- }
80
- static async debug(message) {
81
- let formattedMessage;
82
- if (typeof message === 'object') {
83
- formattedMessage = JSON.stringify(message, null, 2);
84
- if (this.verbose) {
85
- console.log(formattedMessage);
86
- }
87
- }
88
- else {
89
- formattedMessage = message;
90
- if (this.verbose) {
91
- console.log(message);
92
- }
93
- }
94
- if (this.verbose) {
95
- await this.writeToLogFile('DEBUG', formattedMessage);
96
- }
97
- }
98
- static async error(message, error) {
99
- console.error(message);
100
- let logMessage = message;
101
- if (this.verbose && error) {
102
- if (error instanceof Error) {
103
- const errorDetails = {
104
- name: error.name,
105
- message: error.message,
106
- stack: error.stack
107
- };
108
- console.error('Error details:', errorDetails);
109
- logMessage += `\nError details: ${JSON.stringify(errorDetails, null, 2)}`;
110
- }
111
- else {
112
- console.error('Error details:', error);
113
- logMessage += `\nError details: ${JSON.stringify(error, null, 2)}`;
114
- }
115
- }
116
- await this.writeToLogFile('ERROR', logMessage);
117
- }
118
- static getUsername() {
119
- try {
120
- // If on Windows, use os username directly
121
- if (process.platform === 'win32') {
122
- return os.userInfo().username;
123
- }
124
- // For Mac/Linux users
125
- try {
126
- const userInfoPath = USER_INFO_PATH;
127
- if (fs.existsSync(userInfoPath)) {
128
- const userInfo = JSON.parse(fs.readFileSync(userInfoPath, 'utf8'));
129
- if (userInfo.alias) {
130
- return userInfo.alias;
131
- }
132
- }
133
- }
134
- catch (error) {
135
- this.error('Failed to get user info from file', error);
136
- }
137
- // Fall back to os username if all else fails
138
- return os.userInfo().username;
139
- }
140
- catch (error) {
141
- this.error('Failed to get username', error);
142
- return 'unknown';
143
- }
144
- }
145
- static trackEvent(eventType, dimensions) {
146
- try {
147
- const username = this.getUsername();
148
- // Add username and package version to dimensions
149
- const allDimensions = {
150
- username,
151
- packageVersion: this.packageVersion,
152
- ...dimensions
153
- };
154
- // Log to file
155
- if (this.verbose) {
156
- this.log(`Event: ${eventType}`);
157
- this.log(JSON.stringify(allDimensions, null, 2));
158
- }
159
- // Skip AppInsights in test environment
160
- if (Logger.isTestEnvironment) {
161
- return;
162
- }
163
- // Log to Application Insights
164
- try {
165
- TelemetryService.trackEvent(eventType, allDimensions);
166
- TelemetryService.flush();
167
- }
168
- catch (insightsError) {
169
- this.error('Failed to track event in Application Insights', insightsError);
170
- }
171
- }
172
- catch (error) {
173
- this.error('Failed to log event', error);
174
- }
175
- }
176
- }
1
+ import fs from"fs";import path from"path";import os from"os";import{SETTINGS_DIR,USER_INFO_PATH}from"../core/metadatas/constants.js";import{TelemetryService}from"../services/TelemetryService.js";import{getPackageVersion}from"./versionUtils.js";export var EventType;!function(t){t.IMCP_SERVE="imcp_serve",t.SERVER_INSTALL="server_install",t.SERVER_UNINSTALL="server_uninstall",t.REQUIREMENT_UPDATE="requirement_update",t.FEED_ONBOARD="feed_onboard",t.FEED_VALIDATE="feed_validate"}(EventType||(EventType={}));export var EventStatus;!function(t){t.SUCCESS="success",t.FAILED="failed"}(EventStatus||(EventStatus={}));export class Logger{static verbose=!1;static fileLoggingEnabled=!0;static logsDir=path.join(SETTINGS_DIR,"logs");static isTestEnvironment=!1;static packageVersion=getPackageVersion().packageVersion;static setVerbose(t){this.verbose=t}static setFileLogging(t){this.fileLoggingEnabled=t}static async ensureLogsDirExists(){try{await fs.promises.mkdir(this.logsDir,{recursive:!0})}catch(t){this.fileLoggingEnabled=!1}}static getLogFileName(){const t=new Date;return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}.log`}static getTimestamp(){return(new Date).toISOString()}static async writeToLogFile(t,e){if(this.fileLoggingEnabled)try{await this.ensureLogsDirExists();const s=path.join(this.logsDir,this.getLogFileName()),i=`[${this.getTimestamp()}] [${t}] ${e}\n`;await fs.promises.appendFile(s,i,{encoding:"utf8"})}catch(t){}}static async log(t){await this.writeToLogFile("INFO",t)}static async info(t){await this.writeToLogFile("INFO",t)}static async warn(t){await this.writeToLogFile("WARN",t)}static async debug(t){let e;"object"==typeof t?(e=JSON.stringify(t,null,2),this.verbose):(e=t,this.verbose),this.verbose&&await this.writeToLogFile("DEBUG",e)}static async error(t,e){let s=t;if(this.verbose&&e)if(e instanceof Error){const t={name:e.name,message:e.message,stack:e.stack};s+=`\nError details: ${JSON.stringify(t,null,2)}`}else s+=`\nError details: ${JSON.stringify(e,null,2)}`;await this.writeToLogFile("ERROR",s)}static getUsername(){try{if("win32"===process.platform)return os.userInfo().username;try{const t=USER_INFO_PATH;if(fs.existsSync(t)){const e=JSON.parse(fs.readFileSync(t,"utf8"));if(e.alias)return e.alias}}catch(t){this.error("Failed to get user info from file",t)}return os.userInfo().username}catch(t){return this.error("Failed to get username",t),"unknown"}}static trackEvent(t,e){try{const s={username:this.getUsername(),packageVersion:this.packageVersion,...e};if(this.verbose&&(this.log(`Event: ${t}`),this.log(JSON.stringify(s,null,2))),Logger.isTestEnvironment)return;try{TelemetryService.trackEvent(t,s),TelemetryService.flush()}catch(t){this.error("Failed to track event in Application Insights",t)}}catch(t){this.error("Failed to log event",t)}}}
177
2
  //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["fs","path","os","SETTINGS_DIR","USER_INFO_PATH","TelemetryService","getPackageVersion","EventType","EventStatus","Logger","static","join","packageVersion","setVerbose","isVerbose","this","verbose","setFileLogging","enabled","fileLoggingEnabled","ensureLogsDirExists","promises","mkdir","logsDir","recursive","error","getLogFileName","now","Date","getFullYear","String","getMonth","padStart","getDate","getTimestamp","toISOString","writeToLogFile","level","content","logFile","logEntry","appendFile","encoding","log","message","info","warn","debug","formattedMessage","JSON","stringify","logMessage","Error","errorDetails","name","stack","getUsername","process","platform","userInfo","username","userInfoPath","existsSync","parse","readFileSync","alias","trackEvent","eventType","dimensions","allDimensions","isTestEnvironment","flush","insightsError"],"sources":["../../src/utils/logger.ts"],"mappings":"OAAOA,OAAQ,YACRC,SAAU,cACVC,OAAQ,YACNC,aAAcC,mBAAsB,wCACpCC,qBAAwB,yCACxBC,sBAAyB,2BAElC,IAAYC,WAAZ,SAAYA,GACVA,EAAA,wBACAA,EAAA,gCACAA,EAAA,oCACAA,EAAA,wCACAA,EAAA,4BACAA,EAAA,6BACD,CAPD,CAAYA,sBAAS,YASrB,IAAYC,aAAZ,SAAYA,GACVA,EAAA,kBACAA,EAAA,eACD,CAHD,CAAYA,0BAAW,YAKjB,MAAOC,OACHC,gBAAiB,EACjBA,2BAA4B,EAC5BA,eAAiBT,KAAKU,KAAKR,aAAc,QACzCO,0BAAoC,EACpCA,sBAAwBJ,oBAAoBM,eAEpD,iBAAOC,CAAWC,GAChBC,KAAKC,QAAUF,CACjB,CAEA,qBAAOG,CAAeC,GACpBH,KAAKI,mBAAqBD,CAC5B,CAEQ,gCAAaE,GACnB,UACQpB,GAAGqB,SAASC,MAAMP,KAAKQ,QAAS,CAAEC,WAAW,GACrD,CAAE,MAAOC,GAGPV,KAAKI,oBAAqB,CAC5B,CACF,CAEQ,qBAAOO,GACb,MAAMC,EAAM,IAAIC,KA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