@hubspot/cli 7.8.12-experimental.0 → 7.9.0-beta.0

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 (451) hide show
  1. package/bin/cli.js +31 -25
  2. package/commands/__tests__/auth.test.js +5 -0
  3. package/commands/__tests__/cms.test.js +44 -1
  4. package/commands/__tests__/customObject.test.js +22 -1
  5. package/commands/__tests__/doctor.test.js +16 -16
  6. package/commands/__tests__/project.test.js +2 -0
  7. package/commands/account/auth.js +1 -0
  8. package/commands/account/clean.js +18 -27
  9. package/commands/account/createOverride.js +13 -31
  10. package/commands/account/info.js +20 -31
  11. package/commands/account/list.js +16 -22
  12. package/commands/account/remove.js +12 -20
  13. package/commands/account/removeOverride.js +11 -21
  14. package/commands/account/rename.js +6 -9
  15. package/commands/account/use.js +12 -26
  16. package/commands/account.js +2 -2
  17. package/commands/app/__tests__/migrate.test.js +5 -5
  18. package/commands/app/migrate.js +13 -18
  19. package/commands/app.js +1 -6
  20. package/commands/auth.d.ts +1 -0
  21. package/commands/auth.js +17 -7
  22. package/commands/{__tests__/remove.test.js → cms/__tests__/delete.test.js} +8 -8
  23. package/commands/{__tests__ → cms/__tests__}/fetch.test.js +3 -3
  24. package/commands/{__tests__ → cms/__tests__}/function.test.js +7 -3
  25. package/commands/{__tests__ → cms/__tests__}/lint.test.js +3 -3
  26. package/commands/{__tests__ → cms/__tests__}/list.test.js +3 -3
  27. package/commands/{__tests__ → cms/__tests__}/mv.test.js +3 -3
  28. package/commands/{__tests__ → cms/__tests__}/theme.test.js +9 -2
  29. package/commands/cms/app/create.d.ts +9 -0
  30. package/commands/cms/app/create.js +82 -0
  31. package/commands/cms/app.d.ts +3 -0
  32. package/commands/cms/app.js +17 -0
  33. package/commands/cms/convertFields.js +7 -9
  34. package/commands/cms/delete.d.ts +6 -0
  35. package/commands/cms/delete.js +43 -0
  36. package/commands/cms/fetch.d.ts +12 -0
  37. package/commands/cms/fetch.js +79 -0
  38. package/commands/{__tests__ → cms/function/__tests__}/logs.test.js +4 -5
  39. package/commands/cms/function/create.d.ts +12 -0
  40. package/commands/cms/function/create.js +84 -0
  41. package/commands/cms/function/deploy.d.ts +6 -0
  42. package/commands/cms/function/deploy.js +89 -0
  43. package/commands/cms/function/list.d.ts +6 -0
  44. package/commands/cms/function/list.js +60 -0
  45. package/commands/cms/function/logs.d.ts +10 -0
  46. package/commands/cms/function/logs.js +135 -0
  47. package/commands/cms/function/server.d.ts +10 -0
  48. package/commands/cms/function/server.js +69 -0
  49. package/commands/cms/function.d.ts +3 -0
  50. package/commands/cms/function.js +27 -0
  51. package/commands/cms/getReactModule.js +9 -14
  52. package/commands/cms/lighthouseScore.js +33 -36
  53. package/commands/cms/lint.d.ts +6 -0
  54. package/commands/cms/lint.js +83 -0
  55. package/commands/cms/list.d.ts +6 -0
  56. package/commands/cms/list.js +96 -0
  57. package/commands/cms/module/create.d.ts +11 -0
  58. package/commands/cms/module/create.js +84 -0
  59. package/commands/cms/module/marketplace-validate.d.ts +6 -0
  60. package/commands/cms/module/marketplace-validate.js +45 -0
  61. package/commands/cms/module.d.ts +3 -0
  62. package/commands/cms/module.js +17 -0
  63. package/commands/cms/mv.d.ts +7 -0
  64. package/commands/cms/mv.js +60 -0
  65. package/commands/cms/template/create.d.ts +9 -0
  66. package/commands/cms/template/create.js +72 -0
  67. package/commands/cms/template.d.ts +3 -0
  68. package/commands/cms/template.js +17 -0
  69. package/commands/{theme → cms/theme}/__tests__/marketplace-validate.test.js +2 -2
  70. package/commands/{theme → cms/theme}/__tests__/preview.test.js +2 -2
  71. package/commands/cms/theme/create.d.ts +6 -0
  72. package/commands/cms/theme/create.js +58 -0
  73. package/commands/cms/theme/generate-selectors.d.ts +6 -0
  74. package/commands/cms/theme/generate-selectors.js +171 -0
  75. package/commands/cms/theme/marketplace-validate.d.ts +6 -0
  76. package/commands/cms/theme/marketplace-validate.js +46 -0
  77. package/commands/cms/theme/preview.d.ts +12 -0
  78. package/commands/cms/theme/preview.js +224 -0
  79. package/commands/cms/theme.d.ts +3 -0
  80. package/commands/cms/theme.js +25 -0
  81. package/commands/cms/upload.d.ts +12 -0
  82. package/commands/cms/upload.js +212 -0
  83. package/commands/cms/watch.d.ts +14 -0
  84. package/commands/cms/watch.js +138 -0
  85. package/commands/cms/webpack/create.d.ts +6 -0
  86. package/commands/cms/webpack/create.js +58 -0
  87. package/commands/cms/webpack.d.ts +3 -0
  88. package/commands/cms/webpack.js +17 -0
  89. package/commands/cms.js +28 -2
  90. package/commands/completion.js +3 -3
  91. package/commands/config/set.d.ts +1 -1
  92. package/commands/config/set.js +64 -36
  93. package/commands/config.js +2 -2
  94. package/commands/create.js +6 -4
  95. package/commands/customObject/{schema/__tests__/create.test.js → __tests__/createSchema.test.js} +5 -5
  96. package/commands/customObject/{schema/__tests__/delete.test.js → __tests__/deleteSchema.test.js} +5 -5
  97. package/commands/customObject/{schema/__tests__/fetch-all.test.js → __tests__/fetch-all-schemas.test.js} +5 -5
  98. package/commands/customObject/{schema/__tests__/fetch.test.js → __tests__/fetchSchema.test.js} +5 -5
  99. package/commands/customObject/{schema/__tests__/list.test.js → __tests__/listSchemas.test.js} +5 -5
  100. package/commands/customObject/{schema/__tests__/update.test.js → __tests__/updateSchema.test.js} +5 -5
  101. package/commands/customObject/create.js +10 -12
  102. package/commands/customObject/createSchema.d.ts +6 -0
  103. package/commands/customObject/createSchema.js +56 -0
  104. package/commands/customObject/deleteSchema.d.ts +7 -0
  105. package/commands/customObject/deleteSchema.js +69 -0
  106. package/commands/customObject/fetchAllSchemas.d.ts +6 -0
  107. package/commands/customObject/fetchAllSchemas.js +57 -0
  108. package/commands/customObject/fetchSchema.d.ts +7 -0
  109. package/commands/customObject/fetchSchema.js +67 -0
  110. package/commands/customObject/listSchemas.d.ts +4 -0
  111. package/commands/customObject/listSchemas.js +35 -0
  112. package/commands/customObject/schema/create.d.ts +4 -6
  113. package/commands/customObject/schema/create.js +13 -38
  114. package/commands/customObject/schema/delete.d.ts +4 -7
  115. package/commands/customObject/schema/delete.js +15 -50
  116. package/commands/customObject/schema/fetch-all.d.ts +4 -6
  117. package/commands/customObject/schema/fetch-all.js +14 -40
  118. package/commands/customObject/schema/fetch.d.ts +4 -7
  119. package/commands/customObject/schema/fetch.js +14 -49
  120. package/commands/customObject/schema/list.d.ts +4 -4
  121. package/commands/customObject/schema/list.js +10 -19
  122. package/commands/customObject/schema/update.d.ts +4 -7
  123. package/commands/customObject/schema/update.js +15 -50
  124. package/commands/customObject/schema.js +5 -3
  125. package/commands/customObject/updateSchema.d.ts +7 -0
  126. package/commands/customObject/updateSchema.js +71 -0
  127. package/commands/customObject.js +22 -8
  128. package/commands/doctor.js +8 -11
  129. package/commands/feedback.js +7 -12
  130. package/commands/fetch.d.ts +4 -12
  131. package/commands/fetch.js +20 -47
  132. package/commands/filemanager/fetch.js +7 -7
  133. package/commands/filemanager/upload.js +15 -34
  134. package/commands/filemanager.js +2 -2
  135. package/commands/function/deploy.d.ts +4 -6
  136. package/commands/function/deploy.js +14 -89
  137. package/commands/function/list.d.ts +4 -6
  138. package/commands/function/list.js +14 -40
  139. package/commands/function/server.d.ts +4 -10
  140. package/commands/function/server.js +22 -31
  141. package/commands/function.d.ts +2 -4
  142. package/commands/function.js +25 -14
  143. package/commands/getStarted.js +2 -2
  144. package/commands/hubdb/clear.js +7 -15
  145. package/commands/hubdb/create.js +9 -15
  146. package/commands/hubdb/delete.js +8 -15
  147. package/commands/hubdb/fetch.js +6 -9
  148. package/commands/hubdb.d.ts +1 -1
  149. package/commands/hubdb.js +2 -2
  150. package/commands/init.js +2 -3
  151. package/commands/lint.d.ts +4 -6
  152. package/commands/lint.js +13 -65
  153. package/commands/list.d.ts +4 -6
  154. package/commands/list.js +14 -81
  155. package/commands/logs.d.ts +4 -10
  156. package/commands/logs.js +25 -94
  157. package/commands/module/marketplace-validate.d.ts +4 -6
  158. package/commands/module/marketplace-validate.js +15 -27
  159. package/commands/module.d.ts +2 -2
  160. package/commands/module.js +17 -15
  161. package/commands/mv.d.ts +4 -7
  162. package/commands/mv.js +14 -51
  163. package/commands/open.js +5 -5
  164. package/commands/project/__tests__/add.test.js +15 -13
  165. package/commands/project/__tests__/deploy.test.js +3 -4
  166. package/commands/project/__tests__/devUnifiedFlow.test.js +32 -0
  167. package/commands/project/__tests__/installDeps.test.js +8 -8
  168. package/commands/project/__tests__/list.test.js +31 -0
  169. package/commands/project/__tests__/logs.test.js +1 -1
  170. package/commands/project/__tests__/migrate.test.js +6 -5
  171. package/commands/project/__tests__/migrateApp.test.js +2 -5
  172. package/commands/project/__tests__/validate.test.js +98 -0
  173. package/commands/project/add.d.ts +2 -2
  174. package/commands/project/add.js +6 -5
  175. package/commands/project/cloneApp.js +14 -19
  176. package/commands/project/create.js +1 -2
  177. package/commands/project/deploy.js +3 -3
  178. package/commands/project/dev/deprecatedFlow.js +9 -18
  179. package/commands/project/dev/index.js +19 -17
  180. package/commands/project/dev/unifiedFlow.js +11 -4
  181. package/commands/project/download.js +15 -15
  182. package/commands/project/installDeps.d.ts +2 -2
  183. package/commands/project/installDeps.js +9 -8
  184. package/commands/project/list.d.ts +4 -0
  185. package/commands/project/list.js +62 -0
  186. package/commands/project/listBuilds.js +11 -20
  187. package/commands/project/logs.js +21 -24
  188. package/commands/project/migrate.js +5 -2
  189. package/commands/project/migrateApp.js +9 -15
  190. package/commands/project/open.js +6 -13
  191. package/commands/project/upload.d.ts +2 -2
  192. package/commands/project/upload.js +17 -26
  193. package/commands/project/validate.js +6 -6
  194. package/commands/project/watch.js +13 -22
  195. package/commands/project.js +4 -2
  196. package/commands/remove.d.ts +4 -6
  197. package/commands/remove.js +12 -24
  198. package/commands/sandbox/__tests__/create.test.js +5 -5
  199. package/commands/sandbox/create.js +22 -32
  200. package/commands/sandbox/delete.js +38 -63
  201. package/commands/sandbox.js +2 -2
  202. package/commands/secret/addSecret.js +7 -17
  203. package/commands/secret/deleteSecret.js +10 -20
  204. package/commands/secret/listSecret.js +8 -10
  205. package/commands/secret/updateSecret.js +9 -17
  206. package/commands/secret.js +2 -2
  207. package/commands/testAccount/__tests__/delete.test.js +2 -4
  208. package/commands/testAccount/create.js +2 -5
  209. package/commands/testAccount/delete.d.ts +4 -3
  210. package/commands/testAccount/delete.js +155 -14
  211. package/commands/theme/generate-selectors.d.ts +4 -6
  212. package/commands/theme/generate-selectors.js +14 -152
  213. package/commands/theme/marketplace-validate.d.ts +4 -6
  214. package/commands/theme/marketplace-validate.js +14 -25
  215. package/commands/theme/preview.d.ts +4 -12
  216. package/commands/theme/preview.js +18 -183
  217. package/commands/theme.d.ts +2 -2
  218. package/commands/theme.js +19 -13
  219. package/commands/upload.d.ts +4 -12
  220. package/commands/upload.js +19 -169
  221. package/commands/watch.d.ts +4 -14
  222. package/commands/watch.js +23 -88
  223. package/lang/en.d.ts +863 -542
  224. package/lang/en.js +912 -595
  225. package/lang/en.lyaml +4 -4
  226. package/lib/__tests__/buildAccount.test.js +4 -3
  227. package/lib/__tests__/commonOpts.test.js +1 -1
  228. package/lib/__tests__/dependencyManagement.test.js +1 -1
  229. package/lib/__tests__/developerTestAccounts.test.js +3 -3
  230. package/lib/__tests__/npm.test.js +1 -1
  231. package/lib/__tests__/oauth.test.js +4 -4
  232. package/lib/__tests__/process.test.js +10 -5
  233. package/lib/__tests__/sandboxSync.test.js +8 -8
  234. package/lib/__tests__/sandboxes.test.js +8 -8
  235. package/lib/__tests__/serverlessLogs.test.js +1 -1
  236. package/lib/__tests__/usageTracking.test.js +5 -5
  237. package/lib/__tests__/validation.test.js +2 -1
  238. package/lib/__tests__/yargsUtils.test.js +83 -9
  239. package/lib/app/__tests__/migrate.test.js +5 -5
  240. package/lib/app/__tests__/migrate_legacy.test.js +1 -1
  241. package/lib/app/migrate.js +1 -1
  242. package/lib/app/migrate_legacy.js +20 -24
  243. package/lib/buildAccount.d.ts +2 -2
  244. package/lib/buildAccount.js +32 -64
  245. package/lib/commonOpts.d.ts +1 -1
  246. package/lib/commonOpts.js +25 -22
  247. package/lib/configMigrate.js +88 -9
  248. package/lib/configOptions.js +7 -0
  249. package/lib/constants.d.ts +15 -1
  250. package/lib/constants.js +19 -1
  251. package/lib/dependencyManagement.js +9 -27
  252. package/lib/developerTestAccounts.js +9 -23
  253. package/lib/doctor/Diagnosis.js +11 -23
  254. package/lib/doctor/DiagnosticInfoBuilder.js +12 -11
  255. package/lib/doctor/Doctor.js +42 -90
  256. package/lib/doctor/__tests__/Doctor.test.js +4 -4
  257. package/lib/errorHandlers/index.js +12 -20
  258. package/lib/errorHandlers/suppressError.js +11 -18
  259. package/lib/generateSelectors.js +1 -1
  260. package/lib/lang.js +6 -5
  261. package/lib/links.js +4 -4
  262. package/lib/middleware/__test__/commandTargetingUtils.test.js +99 -0
  263. package/lib/middleware/__test__/configMiddleware.test.js +11 -11
  264. package/lib/middleware/__test__/yargsChecksMiddleware.test.js +6 -8
  265. package/lib/middleware/autoUpdateMiddleware.d.ts +2 -1
  266. package/lib/middleware/autoUpdateMiddleware.js +12 -2
  267. package/lib/middleware/commandTargetingUtils.d.ts +8 -0
  268. package/lib/middleware/commandTargetingUtils.js +74 -0
  269. package/lib/middleware/configMiddleware.d.ts +1 -1
  270. package/lib/middleware/configMiddleware.js +21 -81
  271. package/lib/middleware/gitMiddleware.js +5 -1
  272. package/lib/middleware/notificationsMiddleware.js +5 -11
  273. package/lib/middleware/yargsChecksMiddleware.js +6 -9
  274. package/lib/npm.js +2 -2
  275. package/lib/oauth.js +5 -5
  276. package/lib/process.js +5 -4
  277. package/lib/projectProfiles.d.ts +1 -1
  278. package/lib/projectProfiles.js +2 -10
  279. package/lib/projects/__tests__/AppDevModeInterface.test.js +101 -135
  280. package/lib/projects/__tests__/DevServerManager.test.js +183 -0
  281. package/lib/projects/__tests__/LocalDevProcess.test.js +6 -5
  282. package/lib/projects/__tests__/LocalDevWebsocketServer.test.js +76 -45
  283. package/lib/projects/__tests__/UIExtensionsDevModeInterface.test.d.ts +1 -0
  284. package/lib/projects/__tests__/UIExtensionsDevModeInterface.test.js +161 -0
  285. package/lib/projects/__tests__/deploy.test.js +9 -9
  286. package/lib/projects/__tests__/localDevProjectHelpers.test.js +2 -0
  287. package/lib/projects/__tests__/platformVersion.test.js +8 -8
  288. package/lib/projects/__tests__/projects.test.js +12 -12
  289. package/lib/projects/__tests__/structure.test.js +3 -3
  290. package/lib/projects/__tests__/upload.test.d.ts +1 -0
  291. package/lib/projects/__tests__/upload.test.js +82 -0
  292. package/lib/projects/add/__tests__/legacyAddComponent.test.js +6 -6
  293. package/lib/projects/add/__tests__/v2AddComponent.test.d.ts +1 -0
  294. package/lib/projects/add/__tests__/{v3AddComponent.test.js → v2AddComponent.test.js} +39 -39
  295. package/lib/projects/add/{v3AddComponent.d.ts → v2AddComponent.d.ts} +1 -1
  296. package/lib/projects/add/{v3AddComponent.js → v2AddComponent.js} +5 -5
  297. package/lib/projects/create/__tests__/legacy.test.js +5 -5
  298. package/lib/projects/create/__tests__/v2.test.d.ts +1 -0
  299. package/lib/projects/create/__tests__/{v3.test.js → v2.test.js} +3 -3
  300. package/lib/projects/create/index.js +4 -4
  301. package/lib/projects/create/legacy.js +2 -2
  302. package/lib/projects/create/{v3.d.ts → v2.d.ts} +3 -3
  303. package/lib/projects/create/{v3.js → v2.js} +5 -5
  304. package/lib/projects/deploy.d.ts +1 -1
  305. package/lib/projects/deploy.js +2 -2
  306. package/lib/projects/localDev/AppDevModeInterface.d.ts +11 -3
  307. package/lib/projects/localDev/AppDevModeInterface.js +128 -115
  308. package/lib/projects/localDev/DevServerManager.d.ts +10 -29
  309. package/lib/projects/localDev/DevServerManager.js +20 -76
  310. package/lib/projects/localDev/DevServerManager_DEPRECATED.d.ts +40 -0
  311. package/lib/projects/localDev/DevServerManager_DEPRECATED.js +120 -0
  312. package/lib/projects/localDev/LocalDevLogger.js +10 -11
  313. package/lib/projects/localDev/{LocalDevManager.js → LocalDevManager_DEPRECATED.js} +10 -11
  314. package/lib/projects/localDev/LocalDevProcess.js +3 -2
  315. package/lib/projects/localDev/LocalDevState.d.ts +3 -0
  316. package/lib/projects/localDev/LocalDevState.js +9 -0
  317. package/lib/projects/localDev/LocalDevWebsocketServer.d.ts +4 -1
  318. package/lib/projects/localDev/LocalDevWebsocketServer.js +46 -16
  319. package/lib/projects/localDev/UIExtensionsDevModeInterface.d.ts +13 -0
  320. package/lib/projects/localDev/UIExtensionsDevModeInterface.js +37 -0
  321. package/lib/projects/localDev/helpers/account.d.ts +1 -1
  322. package/lib/projects/localDev/helpers/account.js +2 -2
  323. package/lib/projects/localDev/helpers/process.d.ts +1 -0
  324. package/lib/projects/localDev/helpers/process.js +15 -0
  325. package/lib/projects/localDev/helpers/project.d.ts +1 -0
  326. package/lib/projects/localDev/helpers/project.js +39 -3
  327. package/lib/projects/localDev/localDevWebsocketServerUtils.d.ts +3 -0
  328. package/lib/projects/localDev/localDevWebsocketServerUtils.js +9 -0
  329. package/lib/projects/platformVersion.d.ts +1 -1
  330. package/lib/projects/platformVersion.js +1 -1
  331. package/lib/projects/structure.d.ts +2 -2
  332. package/lib/projects/structure.js +6 -6
  333. package/lib/projects/upload.d.ts +2 -3
  334. package/lib/projects/upload.js +17 -9
  335. package/lib/projects/urls.d.ts +0 -1
  336. package/lib/projects/urls.js +0 -3
  337. package/lib/prompts/__tests__/downloadProjectPrompt.test.js +1 -0
  338. package/lib/prompts/__tests__/projectAddPrompt.test.js +10 -10
  339. package/lib/prompts/accountNamePrompt.js +14 -19
  340. package/lib/prompts/accountsPrompt.js +2 -2
  341. package/lib/prompts/cmsFieldPrompt.js +2 -2
  342. package/lib/prompts/createApiSamplePrompt.js +5 -5
  343. package/lib/prompts/createDeveloperTestAccountConfigPrompt.js +10 -1
  344. package/lib/prompts/createFunctionPrompt.js +14 -14
  345. package/lib/prompts/createModulePrompt.js +9 -9
  346. package/lib/prompts/createTemplatePrompt.js +2 -2
  347. package/lib/prompts/downloadProjectPrompt.js +5 -8
  348. package/lib/prompts/installAppPrompt.d.ts +1 -6
  349. package/lib/prompts/installAppPrompt.js +1 -6
  350. package/lib/prompts/personalAccessKeyPrompt.js +3 -3
  351. package/lib/prompts/previewPrompt.js +6 -6
  352. package/lib/prompts/projectAddPrompt.d.ts +2 -2
  353. package/lib/prompts/projectAddPrompt.js +7 -1
  354. package/lib/prompts/projectDevTargetAccountPrompt.js +20 -32
  355. package/lib/prompts/projectNamePrompt.js +4 -8
  356. package/lib/prompts/projectsLogsPrompt.js +2 -4
  357. package/lib/prompts/promptUtils.js +27 -9
  358. package/lib/prompts/sandboxesPrompt.js +7 -7
  359. package/lib/prompts/secretPrompt.js +3 -3
  360. package/lib/prompts/selectAppPrompt.js +3 -3
  361. package/lib/prompts/selectHubDBTablePrompt.js +9 -13
  362. package/lib/prompts/selectPublicAppForMigrationPrompt.js +15 -19
  363. package/lib/prompts/setAsDefaultAccountPrompt.js +4 -8
  364. package/lib/prompts/uploadPrompt.js +5 -5
  365. package/lib/sandboxSync.js +24 -41
  366. package/lib/sandboxes.js +19 -47
  367. package/lib/schema.js +3 -3
  368. package/lib/serverlessLogs.js +11 -13
  369. package/lib/theme/__tests__/migrate.test.js +6 -6
  370. package/lib/theme/migrate.js +2 -2
  371. package/lib/ui/SpinniesManager.d.ts +2 -0
  372. package/lib/ui/SpinniesManager.js +7 -0
  373. package/lib/ui/boxen.js +1 -2
  374. package/lib/ui/git.js +13 -10
  375. package/lib/ui/index.d.ts +6 -0
  376. package/lib/ui/index.js +55 -38
  377. package/lib/ui/serverlessFunctionLogs.js +9 -7
  378. package/lib/ui/uiMessages.d.ts +73 -0
  379. package/lib/ui/uiMessages.js +76 -0
  380. package/lib/usageTracking.js +7 -7
  381. package/lib/validation.js +20 -23
  382. package/lib/yargsUtils.d.ts +1 -1
  383. package/lib/yargsUtils.js +12 -5
  384. package/mcp-server/tools/cms/HsCreateModuleTool.d.ts +4 -4
  385. package/mcp-server/tools/index.js +4 -0
  386. package/mcp-server/tools/project/GetApiUsagePatternsByAppIdTool.d.ts +23 -0
  387. package/mcp-server/tools/project/GetApiUsagePatternsByAppIdTool.js +68 -0
  388. package/mcp-server/tools/project/GetApplicationInfoTool.d.ts +11 -0
  389. package/mcp-server/tools/project/GetApplicationInfoTool.js +49 -0
  390. package/mcp-server/tools/project/GetConfigValuesTool.js +2 -2
  391. package/mcp-server/tools/project/GuidedWalkthroughTool.d.ts +2 -2
  392. package/mcp-server/tools/project/__tests__/CreateProjectTool.test.js +1 -1
  393. package/mcp-server/tools/project/__tests__/GetApiUsagePatternsByAppIdTool.test.d.ts +1 -0
  394. package/mcp-server/tools/project/__tests__/GetApiUsagePatternsByAppIdTool.test.js +169 -0
  395. package/mcp-server/tools/project/__tests__/GetApplicationInfoTool.test.d.ts +1 -0
  396. package/mcp-server/tools/project/__tests__/GetApplicationInfoTool.test.js +115 -0
  397. package/mcp-server/utils/toolUsageTracking.js +2 -2
  398. package/package.json +8 -7
  399. package/types/Cms.d.ts +6 -6
  400. package/types/Yargs.d.ts +1 -1
  401. package/commands/app/__tests__/install.test.js +0 -47
  402. package/commands/app/install.d.ts +0 -8
  403. package/commands/app/install.js +0 -122
  404. package/lib/middleware/__test__/utils.test.js +0 -51
  405. package/lib/middleware/utils.d.ts +0 -8
  406. package/lib/middleware/utils.js +0 -14
  407. package/lib/projects/localDev/DevServerManagerV2.d.ts +0 -22
  408. package/lib/projects/localDev/DevServerManagerV2.js +0 -81
  409. /package/commands/{customObject/schema → cms}/__tests__/delete.test.d.ts +0 -0
  410. /package/commands/{__tests__ → cms/__tests__}/fetch.test.d.ts +0 -0
  411. /package/commands/{__tests__ → cms/__tests__}/function.test.d.ts +0 -0
  412. /package/commands/{__tests__ → cms/__tests__}/lint.test.d.ts +0 -0
  413. /package/commands/{__tests__ → cms/__tests__}/list.test.d.ts +0 -0
  414. /package/commands/{__tests__ → cms/__tests__}/mv.test.d.ts +0 -0
  415. /package/commands/{__tests__ → cms/__tests__}/theme.test.d.ts +0 -0
  416. /package/commands/{__tests__ → cms/function/__tests__}/logs.test.d.ts +0 -0
  417. /package/commands/{theme → cms/theme}/__tests__/generate-selectors.test.d.ts +0 -0
  418. /package/commands/{theme → cms/theme}/__tests__/generate-selectors.test.js +0 -0
  419. /package/commands/{theme → cms/theme}/__tests__/marketplace-validate.test.d.ts +0 -0
  420. /package/commands/{theme → cms/theme}/__tests__/preview.test.d.ts +0 -0
  421. /package/commands/{__tests__/remove.test.d.ts → customObject/__tests__/createSchema.test.d.ts} +0 -0
  422. /package/commands/{app/__tests__/install.test.d.ts → customObject/__tests__/deleteSchema.test.d.ts} +0 -0
  423. /package/commands/customObject/{schema/__tests__/create.test.d.ts → __tests__/fetch-all-schemas.test.d.ts} +0 -0
  424. /package/commands/customObject/{schema/__tests__/fetch-all.test.d.ts → __tests__/fetchSchema.test.d.ts} +0 -0
  425. /package/commands/customObject/{schema/__tests__/fetch.test.d.ts → __tests__/listSchemas.test.d.ts} +0 -0
  426. /package/commands/customObject/{schema/__tests__/list.test.d.ts → __tests__/updateSchema.test.d.ts} +0 -0
  427. /package/commands/{customObject/schema/__tests__/update.test.d.ts → project/__tests__/list.test.d.ts} +0 -0
  428. /package/{lib/middleware/__test__/utils.test.d.ts → commands/project/__tests__/validate.test.d.ts} +0 -0
  429. /package/{commands/create → lib/cmsAssets}/api-sample.d.ts +0 -0
  430. /package/{commands/create → lib/cmsAssets}/api-sample.js +0 -0
  431. /package/{commands/create → lib/cmsAssets}/app.d.ts +0 -0
  432. /package/{commands/create → lib/cmsAssets}/app.js +0 -0
  433. /package/{commands/create → lib/cmsAssets}/function.d.ts +0 -0
  434. /package/{commands/create → lib/cmsAssets}/function.js +0 -0
  435. /package/{commands/create → lib/cmsAssets}/index.d.ts +0 -0
  436. /package/{commands/create → lib/cmsAssets}/index.js +0 -0
  437. /package/{commands/create → lib/cmsAssets}/module.d.ts +0 -0
  438. /package/{commands/create → lib/cmsAssets}/module.js +0 -0
  439. /package/{commands/create → lib/cmsAssets}/react-app.d.ts +0 -0
  440. /package/{commands/create → lib/cmsAssets}/react-app.js +0 -0
  441. /package/{commands/create → lib/cmsAssets}/template.d.ts +0 -0
  442. /package/{commands/create → lib/cmsAssets}/template.js +0 -0
  443. /package/{commands/create → lib/cmsAssets}/vue-app.d.ts +0 -0
  444. /package/{commands/create → lib/cmsAssets}/vue-app.js +0 -0
  445. /package/{commands/create → lib/cmsAssets}/webpack-serverless.d.ts +0 -0
  446. /package/{commands/create → lib/cmsAssets}/webpack-serverless.js +0 -0
  447. /package/{commands/create → lib/cmsAssets}/website-theme.d.ts +0 -0
  448. /package/{commands/create → lib/cmsAssets}/website-theme.js +0 -0
  449. /package/lib/{projects/add/__tests__/v3AddComponent.test.d.ts → middleware/__test__/commandTargetingUtils.test.d.ts} +0 -0
  450. /package/lib/projects/{create/__tests__/v3.test.d.ts → __tests__/DevServerManager.test.d.ts} +0 -0
  451. /package/lib/projects/localDev/{LocalDevManager.d.ts → LocalDevManager_DEPRECATED.d.ts} +0 -0
@@ -1,27 +1,24 @@
1
1
  import { fetchAppInstallationData } from '@hubspot/local-dev-lib/api/localDevAuth';
2
- import { fetchPublicAppsForPortal, fetchPublicAppProductionInstallCounts,
3
- // installStaticAuthAppOnTestAccount,
4
- } from '@hubspot/local-dev-lib/api/appsDev';
5
- import { DevModeUnifiedInterface as UIEDevModeInterface } from '@hubspot/ui-extensions-dev-server';
6
- import { requestPorts } from '@hubspot/local-dev-lib/portManager';
2
+ import { fetchAppMetadataByUid, fetchPublicAppProductionInstallCounts, installStaticAuthAppOnTestAccount, } from '@hubspot/local-dev-lib/api/appsDev';
3
+ import { getAccountConfig } from '@hubspot/local-dev-lib/config';
7
4
  import { APP_AUTH_TYPES, APP_DISTRIBUTION_TYPES, APP_INSTALLATION_STATES, LOCAL_DEV_SERVER_MESSAGE_TYPES, } from '../../constants.js';
8
5
  import { EXIT_CODES } from '../../enums/exitCodes.js';
9
6
  import { isAppIRNode } from '../../projects/structure.js';
10
7
  import { uiLine } from '../../ui/index.js';
11
8
  import { logError } from '../../errorHandlers/index.js';
12
- import {
13
- // installAppAutoPrompt,
14
- installAppBrowserPrompt, } from '../../prompts/installAppPrompt.js';
9
+ import { installAppAutoPrompt, installAppBrowserPrompt, } from '../../prompts/installAppPrompt.js';
15
10
  import { confirmPrompt } from '../../prompts/promptUtils.js';
16
11
  import { lib } from '../../../lang/en.js';
17
12
  import { uiLogger } from '../../ui/logger.js';
18
13
  import { getOauthAppInstallUrl, getStaticAuthAppInstallUrl, } from '../../app/urls.js';
14
+ import { isDeveloperTestAccount, isSandbox } from '../../accountTypes.js';
19
15
  import SpinniesManager from '../../ui/SpinniesManager.js';
20
16
  class AppDevModeInterface {
21
17
  localDevState;
22
18
  localDevLogger;
23
19
  _appNode;
24
20
  marketplaceAppInstalls;
21
+ appInstallResolve;
25
22
  constructor(options) {
26
23
  this.localDevState = options.localDevState;
27
24
  this.localDevLogger = options.localDevLogger;
@@ -43,10 +40,18 @@ class AppDevModeInterface {
43
40
  return this._appNode;
44
41
  }
45
42
  get appData() {
43
+ // These checks are primarily for type safety
44
+ // App data will never be accessed before being set
46
45
  if (!this.appNode) {
47
- return undefined;
46
+ uiLogger.log(lib.AppDevModeInterface.appDataNotFound);
47
+ process.exit(EXIT_CODES.ERROR);
48
+ }
49
+ const data = this.localDevState.getAppDataByUid(this.appNode.uid);
50
+ if (!data) {
51
+ uiLogger.log(lib.AppDevModeInterface.appDataNotFound);
52
+ process.exit(EXIT_CODES.ERROR);
48
53
  }
49
- return this.localDevState.getAppDataByUid(this.appNode.uid);
54
+ return data;
50
55
  }
51
56
  set appData(appData) {
52
57
  if (!this.appNode) {
@@ -54,56 +59,47 @@ class AppDevModeInterface {
54
59
  }
55
60
  this.localDevState.setAppDataForUid(this.appNode.uid, appData);
56
61
  }
57
- // @TODO: Restore test account auto install functionality
58
- // private isAutomaticallyInstallable(): boolean {
59
- // const targetTestingAccount = getAccountConfig(
60
- // this.localDevState.targetTestingAccountId
61
- // );
62
- // if (!targetTestingAccount) {
63
- // return false;
64
- // }
65
- // const isTestAccount =
66
- // isDeveloperTestAccount(targetTestingAccount) ||
67
- // isSandbox(targetTestingAccount);
68
- // const hasCorrectParent =
69
- // targetTestingAccount.parentAccountId ===
70
- // this.localDevState.targetProjectAccountId;
71
- // return (
72
- // isTestAccount &&
73
- // hasCorrectParent &&
74
- // this.appNode?.config.auth.type === APP_AUTH_TYPES.STATIC
75
- // );
76
- // }
62
+ isStaticAuthApp() {
63
+ return (this.appNode?.config.auth.type.toLowerCase() === APP_AUTH_TYPES.STATIC);
64
+ }
65
+ isOAuthApp() {
66
+ return (this.appNode?.config.auth.type.toLowerCase() === APP_AUTH_TYPES.OAUTH);
67
+ }
68
+ isAutomaticallyInstallable() {
69
+ const targetTestingAccount = getAccountConfig(this.localDevState.targetTestingAccountId);
70
+ if (!targetTestingAccount) {
71
+ return false;
72
+ }
73
+ const isTestAccount = isDeveloperTestAccount(targetTestingAccount) ||
74
+ isSandbox(targetTestingAccount);
75
+ const hasCorrectParent = targetTestingAccount.parentAccountId ===
76
+ this.localDevState.targetProjectAccountId;
77
+ return isTestAccount && hasCorrectParent && this.isStaticAuthApp();
78
+ }
77
79
  async getAppInstallUrl() {
78
- if (this.appNode?.config.auth.type.toLowerCase() === APP_AUTH_TYPES.OAUTH) {
80
+ if (this.appNode && this.isOAuthApp()) {
79
81
  return getOauthAppInstallUrl({
80
82
  targetAccountId: this.localDevState.targetTestingAccountId,
81
83
  env: this.localDevState.env,
82
- clientId: this.appData.clientId, // This is only called after checking that appData exists
84
+ clientId: this.appData.clientId,
83
85
  scopes: this.appNode.config.auth.requiredScopes,
84
86
  redirectUrls: this.appNode.config.auth.redirectUrls,
85
87
  });
86
88
  }
87
- const { data: { results }, } = await fetchPublicAppsForPortal(this.localDevState.targetProjectAccountId);
88
- const app = results.find(app => app.sourceId === this.appNode?.uid);
89
- if (!app) {
90
- uiLogger.error(lib.LocalDevManager.appNotFound(this.localDevState.targetProjectAccountId, this.appNode?.uid));
91
- process.exit(EXIT_CODES.ERROR);
92
- }
93
89
  return getStaticAuthAppInstallUrl({
94
90
  targetAccountId: this.localDevState.targetTestingAccountId,
95
91
  env: this.localDevState.env,
96
- appId: app.id,
92
+ appId: this.appData.id,
97
93
  });
98
94
  }
99
95
  async fetchAppData() {
100
96
  SpinniesManager.add('fetchAppData', {
101
97
  text: lib.AppDevModeInterface.fetchAppData.checking(this.appNode?.config.name || ''),
102
98
  });
103
- let portalApps = [];
99
+ let appData;
104
100
  try {
105
- const { data: { results }, } = await fetchPublicAppsForPortal(this.localDevState.targetProjectAccountId);
106
- portalApps = results;
101
+ const { data } = await fetchAppMetadataByUid(this.appNode.uid, this.localDevState.targetProjectAccountId);
102
+ appData = data;
107
103
  }
108
104
  catch (e) {
109
105
  SpinniesManager.fail('fetchAppData', {
@@ -112,7 +108,6 @@ class AppDevModeInterface {
112
108
  logError(e);
113
109
  process.exit(EXIT_CODES.ERROR);
114
110
  }
115
- const appData = portalApps.find(({ sourceId }) => sourceId === this.appNode?.uid);
116
111
  if (!appData) {
117
112
  return;
118
113
  }
@@ -121,13 +116,13 @@ class AppDevModeInterface {
121
116
  id: appData.id,
122
117
  clientId: appData.clientId,
123
118
  name: appData.name,
124
- installationState: APP_INSTALLATION_STATES.NOT_INSTALLED,
119
+ installationState: APP_INSTALLATION_STATES.UNKNOWN,
125
120
  scopeGroupIds: appData.scopeGroupIds,
126
121
  };
127
122
  this.marketplaceAppInstalls = uniquePortalInstallCount;
128
123
  }
129
124
  async checkMarketplaceAppInstalls() {
130
- if (!this.appData || !this.marketplaceAppInstalls) {
125
+ if (!this.marketplaceAppInstalls) {
131
126
  return;
132
127
  }
133
128
  SpinniesManager.fail('fetchAppData', {
@@ -143,50 +138,58 @@ class AppDevModeInterface {
143
138
  }
144
139
  this.localDevState.addUploadWarning(lib.AppDevModeInterface.defaultMarketplaceAppWarning(this.marketplaceAppInstalls));
145
140
  }
146
- // @TODO: Restore test account auto install functionality
147
- // private async autoInstallStaticAuthApp(): Promise<void> {
148
- // const shouldInstall = await installAppAutoPrompt();
149
- // if (!shouldInstall) {
150
- // uiLogger.log(lib.AppDevModeInterface.autoInstallDeclined);
151
- // process.exit(EXIT_CODES.SUCCESS);
152
- // }
153
- // await installStaticAuthAppOnTestAccount(
154
- // this.appData!.id,
155
- // this.localDevState.targetTestingAccountId,
156
- // this.appData!.scopeGroupIds
157
- // );
158
- // }
141
+ async waitUntilAppIsInstalled(installUrl) {
142
+ uiLogger.log(lib.AppDevModeInterface.waitUntilAppIsInstalled.link(installUrl));
143
+ SpinniesManager.add('waitUntilAppIsInstalled', {
144
+ text: lib.AppDevModeInterface.waitUntilAppIsInstalled.waiting,
145
+ });
146
+ await new Promise(resolve => {
147
+ this.appInstallResolve = resolve;
148
+ });
149
+ SpinniesManager.succeed('waitUntilAppIsInstalled', {
150
+ text: lib.AppDevModeInterface.waitUntilAppIsInstalled.success(this.appNode?.config.name || '', this.localDevState.targetTestingAccountId),
151
+ });
152
+ }
153
+ async autoInstallStaticAuthApp() {
154
+ const shouldInstall = await installAppAutoPrompt();
155
+ if (!shouldInstall) {
156
+ uiLogger.log(lib.AppDevModeInterface.autoInstallDeclined);
157
+ process.exit(EXIT_CODES.SUCCESS);
158
+ }
159
+ uiLogger.log('');
160
+ SpinniesManager.add('autoInstallStaticAuthApp', {
161
+ text: lib.AppDevModeInterface.autoInstallStaticAuthApp.installing(this.appData.name, this.localDevState.targetTestingAccountId),
162
+ });
163
+ try {
164
+ await installStaticAuthAppOnTestAccount(this.appData.id, this.localDevState.targetTestingAccountId, this.appData.scopeGroupIds);
165
+ SpinniesManager.succeed('autoInstallStaticAuthApp', {
166
+ text: lib.AppDevModeInterface.autoInstallStaticAuthApp.success(this.appData.name, this.localDevState.targetTestingAccountId),
167
+ });
168
+ return true;
169
+ }
170
+ catch (e) {
171
+ SpinniesManager.fail('autoInstallStaticAuthApp', {
172
+ text: lib.AppDevModeInterface.autoInstallStaticAuthApp.error(this.appData.name, this.localDevState.targetTestingAccountId),
173
+ failColor: 'white',
174
+ });
175
+ return false;
176
+ }
177
+ }
159
178
  async installAppOrOpenInstallUrl(isReinstall) {
160
- // @TODO: Restore test account auto install functionality
161
- // if (this.isAutomaticallyInstallable()) {
162
- // try {
163
- // await this.autoInstallStaticAuthApp();
164
- // uiLogger.success(
165
- // lib.AppDevModeInterface.autoInstallSuccess(
166
- // this.appData!.name,
167
- // this.localDevState.targetTestingAccountId
168
- // )
169
- // );
170
- // return;
171
- // } catch (e) {
172
- // uiLogger.error(
173
- // lib.AppDevModeInterface.autoInstallError(
174
- // this.appData!.name,
175
- // this.localDevState.targetTestingAccountId
176
- // )
177
- // );
178
- // }
179
- // }
179
+ if (this.isAutomaticallyInstallable()) {
180
+ const installSuccess = await this.autoInstallStaticAuthApp();
181
+ if (installSuccess) {
182
+ return;
183
+ }
184
+ }
180
185
  const installUrl = await this.getAppInstallUrl();
181
- await installAppBrowserPrompt(installUrl, isReinstall, {
182
- testingAccountId: this.localDevState.targetTestingAccountId,
183
- projectAccountId: this.localDevState.targetProjectAccountId,
184
- projectName: this.localDevState.projectConfig.name,
185
- appUid: this.appNode.uid,
186
- });
186
+ await installAppBrowserPrompt(installUrl, isReinstall);
187
+ if (!isReinstall) {
188
+ await this.waitUntilAppIsInstalled(installUrl);
189
+ }
187
190
  }
188
191
  async checkTestAccountAppInstallation() {
189
- if (!this.appNode || !this.appData) {
192
+ if (!this.appNode) {
190
193
  return {};
191
194
  }
192
195
  const { data: { isInstalledWithScopeGroups, previouslyAuthorizedScopeGroups }, } = await fetchAppInstallationData(this.localDevState.targetTestingAccountId, this.localDevState.projectId, this.appNode.uid, this.appNode.config.auth.requiredScopes, this.appNode.config.auth.optionalScopes);
@@ -203,11 +206,46 @@ class AppDevModeInterface {
203
206
  installationState: APP_INSTALLATION_STATES.INSTALLED_WITH_OUTDATED_SCOPES,
204
207
  };
205
208
  }
209
+ else {
210
+ this.appData = {
211
+ ...this.appData,
212
+ installationState: APP_INSTALLATION_STATES.NOT_INSTALLED,
213
+ };
214
+ }
206
215
  return { needsInstall: !isInstalledWithScopeGroups, isReinstall };
207
216
  }
208
- onDevServerMessage = (message) => {
217
+ resolveAppInstallPromise() {
218
+ if (this.appInstallResolve) {
219
+ this.appInstallResolve();
220
+ this.appInstallResolve = undefined;
221
+ }
222
+ }
223
+ handleAppInstallSuccessDevServerMessage() {
224
+ this.resolveAppInstallPromise();
225
+ this.appData = {
226
+ ...this.appData,
227
+ installationState: APP_INSTALLATION_STATES.INSTALLED,
228
+ };
229
+ }
230
+ handleAppInstallInitiatedDevServerMessage() {
231
+ this.resolveAppInstallPromise();
232
+ }
233
+ handleAppInstallFailureDevServerMessage() {
234
+ uiLogger.error(lib.AppDevModeInterface.installationFailed);
235
+ process.exit(EXIT_CODES.ERROR);
236
+ }
237
+ onDevServerMessage = async (message) => {
209
238
  if (message === LOCAL_DEV_SERVER_MESSAGE_TYPES.WEBSOCKET_SERVER_CONNECTED) {
210
- this.checkTestAccountAppInstallation();
239
+ await this.checkTestAccountAppInstallation();
240
+ }
241
+ else if (message === LOCAL_DEV_SERVER_MESSAGE_TYPES.STATIC_AUTH_APP_INSTALL_SUCCESS) {
242
+ this.handleAppInstallSuccessDevServerMessage();
243
+ }
244
+ else if (message === LOCAL_DEV_SERVER_MESSAGE_TYPES.STATIC_AUTH_APP_INSTALL_FAILURE) {
245
+ this.handleAppInstallFailureDevServerMessage();
246
+ }
247
+ else if (message === LOCAL_DEV_SERVER_MESSAGE_TYPES.OAUTH_APP_INSTALL_INITIATED) {
248
+ this.handleAppInstallInitiatedDevServerMessage();
211
249
  }
212
250
  };
213
251
  onChangeProjectNodes = (nodes) => {
@@ -225,17 +263,11 @@ class AppDevModeInterface {
225
263
  this.localDevState.addUploadWarning(lib.AppDevModeInterface.authTypeChanged);
226
264
  }
227
265
  };
228
- setUpStateListeners() {
229
- this.localDevState.addListener('devServerMessage', this.onDevServerMessage);
230
- this.localDevState.addListener('projectNodes', this.onChangeProjectNodes);
231
- }
232
266
  removeStateListeners() {
233
267
  this.localDevState.removeListener('devServerMessage', this.onDevServerMessage);
234
268
  this.localDevState.removeListener('projectNodes', this.onChangeProjectNodes);
235
269
  }
236
- // @ts-expect-error TODO: reconcile types between CLI and UIE Dev Server
237
- // In the future, update UIE Dev Server to use LocalDevState
238
- async setup(args) {
270
+ async setup() {
239
271
  if (!this.appNode) {
240
272
  return;
241
273
  }
@@ -252,6 +284,7 @@ class AppDevModeInterface {
252
284
  failColor: 'white',
253
285
  });
254
286
  }
287
+ this.localDevState.addListener('devServerMessage', this.onDevServerMessage);
255
288
  await this.installAppOrOpenInstallUrl(isReinstall || false);
256
289
  }
257
290
  else {
@@ -266,32 +299,12 @@ class AppDevModeInterface {
266
299
  catch (e) {
267
300
  logError(e);
268
301
  }
269
- this.setUpStateListeners();
270
- return UIEDevModeInterface.setup(args);
271
302
  }
272
303
  async start() {
273
- if (!this.appNode) {
274
- return;
275
- }
276
- return UIEDevModeInterface.start({
277
- accountId: this.localDevState.targetTestingAccountId,
278
- // @ts-expect-error TODO: reconcile types between CLI and UIE Dev Server
279
- projectConfig: this.localDevState.projectConfig,
280
- requestPorts,
281
- });
282
- }
283
- async fileChange(filePath, event) {
284
- if (!this.appNode) {
285
- return;
286
- }
287
- return UIEDevModeInterface.fileChange(filePath, event);
304
+ this.localDevState.addListener('projectNodes', this.onChangeProjectNodes);
288
305
  }
289
306
  async cleanup() {
290
- if (!this.appNode) {
291
- return;
292
- }
293
307
  this.removeStateListeners();
294
- return UIEDevModeInterface.cleanup();
295
308
  }
296
309
  }
297
310
  export default AppDevModeInterface;
@@ -1,40 +1,21 @@
1
- import { ProjectConfig, ComponentTypes, Component } from '../../../types/Projects.js';
2
- type DevServerInterface = {
3
- setup?: Function;
4
- start?: (options: object) => Promise<void>;
5
- fileChange?: (filePath: string, event: string) => Promise<void>;
6
- cleanup?: () => Promise<void>;
7
- };
8
- type ComponentsByType = {
9
- [key in ComponentTypes]?: {
10
- [key: string]: Component;
11
- };
1
+ import LocalDevState from './LocalDevState.js';
2
+ import LocalDevLogger from './LocalDevLogger.js';
3
+ type DevServerManagerConstructorOptions = {
4
+ localDevState: LocalDevState;
5
+ logger: LocalDevLogger;
12
6
  };
13
7
  declare class DevServerManager {
14
8
  private initialized;
15
9
  private started;
16
- private componentsByType;
17
10
  private devServers;
18
- constructor();
19
- iterateDevServers(callback: (serverInterface: DevServerInterface, compatibleComponents: {
20
- [key: string]: Component;
21
- }) => Promise<void>): Promise<void>;
22
- arrangeComponentsByType(components: Component[]): ComponentsByType;
23
- setup({ components, onUploadRequired, accountId, setActiveApp, }: {
24
- components: Component[];
25
- onUploadRequired: () => void;
26
- accountId: number;
27
- setActiveApp: (appUid: string | undefined) => Promise<void>;
28
- }): Promise<void>;
29
- start({ accountId, projectConfig, }: {
30
- accountId: number;
31
- projectConfig: ProjectConfig;
32
- }): Promise<void>;
11
+ constructor(options: DevServerManagerConstructorOptions);
12
+ private iterateDevServers;
13
+ setup(): Promise<void>;
14
+ start(): Promise<void>;
33
15
  fileChange({ filePath, event, }: {
34
16
  filePath: string;
35
17
  event: string;
36
18
  }): Promise<void>;
37
19
  cleanup(): Promise<void>;
38
20
  }
39
- declare const Manager: DevServerManager;
40
- export default Manager;
21
+ export default DevServerManager;
@@ -1,93 +1,39 @@
1
- import { logger } from '@hubspot/local-dev-lib/logger';
2
- import { DevModeInterface as UIEDevModeInterface } from '@hubspot/ui-extensions-dev-server';
3
- import { startPortManagerServer, stopPortManagerServer, requestPorts, } from '@hubspot/local-dev-lib/portManager';
4
- import { getHubSpotApiOrigin, getHubSpotWebsiteOrigin, } from '@hubspot/local-dev-lib/urls';
5
- import { getAccountConfig } from '@hubspot/local-dev-lib/config';
6
- import { ComponentTypes, } from '../../../types/Projects.js';
1
+ import AppDevModeInterface from './AppDevModeInterface.js';
7
2
  import { lib } from '../../../lang/en.js';
8
- import { uiLogger } from '../../ui/logger.js';
9
- const SERVER_KEYS = {
10
- privateApp: 'privateApp',
11
- publicApp: 'publicApp',
12
- };
3
+ import UIExtensionsDevModeInterface from './UIExtensionsDevModeInterface.js';
13
4
  class DevServerManager {
14
5
  initialized;
15
6
  started;
16
- componentsByType;
17
7
  devServers;
18
- constructor() {
8
+ constructor(options) {
19
9
  this.initialized = false;
20
10
  this.started = false;
21
- this.componentsByType = {};
22
- this.devServers = {
23
- [SERVER_KEYS.privateApp]: {
24
- componentType: ComponentTypes.PrivateApp,
25
- serverInterface: UIEDevModeInterface,
26
- },
27
- [SERVER_KEYS.publicApp]: {
28
- componentType: ComponentTypes.PublicApp,
29
- serverInterface: UIEDevModeInterface,
30
- },
31
- };
11
+ const AppsDevServer = new AppDevModeInterface({
12
+ localDevState: options.localDevState,
13
+ localDevLogger: options.logger,
14
+ });
15
+ const UIExtensionsDevServer = new UIExtensionsDevModeInterface({
16
+ localDevState: options.localDevState,
17
+ });
18
+ this.devServers = [AppsDevServer, UIExtensionsDevServer];
32
19
  }
33
20
  async iterateDevServers(callback) {
34
- const serverKeys = Object.keys(this.devServers);
35
- for (let i = 0; i < serverKeys.length; i++) {
36
- const serverKey = serverKeys[i];
37
- const devServer = this.devServers[serverKey];
38
- const compatibleComponents = this.componentsByType[devServer.componentType] || {};
39
- if (Object.keys(compatibleComponents).length) {
40
- await callback(devServer.serverInterface, compatibleComponents);
41
- }
42
- else {
43
- uiLogger.debug(lib.DevServerManager.noCompatibleComponents(serverKey));
44
- }
45
- }
21
+ await Promise.all(this.devServers.map(devServer => callback(devServer)));
46
22
  }
47
- arrangeComponentsByType(components) {
48
- return components.reduce((acc, component) => {
49
- if (!acc[component.type]) {
50
- acc[component.type] = {};
23
+ async setup() {
24
+ for (const devServer of this.devServers) {
25
+ if (devServer.setup) {
26
+ // Run setup functions in order
27
+ await devServer.setup();
51
28
  }
52
- if ('name' in component.config && component.config.name) {
53
- acc[component.type][component.config.name] = component;
54
- }
55
- return acc;
56
- }, {});
57
- }
58
- async setup({ components, onUploadRequired, accountId, setActiveApp, }) {
59
- this.componentsByType = this.arrangeComponentsByType(components);
60
- let env;
61
- const accountConfig = getAccountConfig(accountId);
62
- if (accountConfig) {
63
- env = accountConfig.env;
64
29
  }
65
- await startPortManagerServer();
66
- await this.iterateDevServers(async (serverInterface, compatibleComponents) => {
67
- if (serverInterface.setup) {
68
- await serverInterface.setup({
69
- components: compatibleComponents,
70
- onUploadRequired,
71
- logger,
72
- urls: {
73
- api: getHubSpotApiOrigin(env),
74
- web: getHubSpotWebsiteOrigin(env),
75
- },
76
- setActiveApp,
77
- });
78
- }
79
- });
80
30
  this.initialized = true;
81
31
  }
82
- async start({ accountId, projectConfig, }) {
32
+ async start() {
83
33
  if (this.initialized) {
84
34
  await this.iterateDevServers(async (serverInterface) => {
85
35
  if (serverInterface.start) {
86
- await serverInterface.start({
87
- accountId,
88
- projectConfig,
89
- requestPorts,
90
- });
36
+ await serverInterface.start();
91
37
  }
92
38
  });
93
39
  }
@@ -112,9 +58,7 @@ class DevServerManager {
112
58
  await serverInterface.cleanup();
113
59
  }
114
60
  });
115
- await stopPortManagerServer();
116
61
  }
117
62
  }
118
63
  }
119
- const Manager = new DevServerManager();
120
- export default Manager;
64
+ export default DevServerManager;
@@ -0,0 +1,40 @@
1
+ import { ProjectConfig, ComponentTypes, Component } from '../../../types/Projects.js';
2
+ type DevServerInterface = {
3
+ setup?: Function;
4
+ start?: (options: object) => Promise<void>;
5
+ fileChange?: (filePath: string, event: string) => Promise<void>;
6
+ cleanup?: () => Promise<void>;
7
+ };
8
+ type ComponentsByType = {
9
+ [key in ComponentTypes]?: {
10
+ [key: string]: Component;
11
+ };
12
+ };
13
+ declare class DevServerManager_DEPRECATED {
14
+ private initialized;
15
+ private started;
16
+ private componentsByType;
17
+ private devServers;
18
+ constructor();
19
+ iterateDevServers(callback: (serverInterface: DevServerInterface, compatibleComponents: {
20
+ [key: string]: Component;
21
+ }) => Promise<void>): Promise<void>;
22
+ arrangeComponentsByType(components: Component[]): ComponentsByType;
23
+ setup({ components, onUploadRequired, accountId, setActiveApp, }: {
24
+ components: Component[];
25
+ onUploadRequired: () => void;
26
+ accountId: number;
27
+ setActiveApp: (appUid: string | undefined) => Promise<void>;
28
+ }): Promise<void>;
29
+ start({ accountId, projectConfig, }: {
30
+ accountId: number;
31
+ projectConfig: ProjectConfig;
32
+ }): Promise<void>;
33
+ fileChange({ filePath, event, }: {
34
+ filePath: string;
35
+ event: string;
36
+ }): Promise<void>;
37
+ cleanup(): Promise<void>;
38
+ }
39
+ declare const Manager: DevServerManager_DEPRECATED;
40
+ export default Manager;