@hubspot/cli 7.11.8-experimental.0 → 8.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (363) hide show
  1. package/api/__tests__/migrate.test.js +19 -1
  2. package/api/migrate.d.ts +1 -1
  3. package/api/migrate.js +2 -1
  4. package/bin/cli.js +12 -27
  5. package/commands/__tests__/customObject.test.js +0 -2
  6. package/commands/__tests__/doctor.test.js +0 -2
  7. package/commands/__tests__/getStarted.test.js +0 -4
  8. package/commands/__tests__/project.test.js +0 -4
  9. package/commands/__tests__/upgrade.test.js +309 -0
  10. package/commands/account/__tests__/auth.test.js +180 -0
  11. package/commands/account/__tests__/list.test.js +128 -3
  12. package/commands/account/__tests__/rename.test.js +0 -2
  13. package/commands/account/__tests__/use.test.js +138 -0
  14. package/commands/account/auth.js +1 -1
  15. package/commands/account/clean.js +4 -3
  16. package/commands/account/createOverride.js +3 -2
  17. package/commands/account/info.js +2 -2
  18. package/commands/account/list.js +4 -4
  19. package/commands/account/remove.js +3 -2
  20. package/commands/account/removeOverride.js +3 -2
  21. package/commands/account/use.js +4 -3
  22. package/commands/app/__tests__/migrate.test.js +8 -25
  23. package/commands/app/migrate.js +10 -16
  24. package/commands/app/secret/__tests__/add.test.js +112 -0
  25. package/commands/app/secret/add.js +13 -13
  26. package/commands/auth.js +8 -2
  27. package/commands/cms/__tests__/fetch.test.js +114 -15
  28. package/commands/cms/__tests__/upload.test.js +308 -0
  29. package/commands/cms/__tests__/watch.test.js +212 -0
  30. package/commands/cms/app/create.js +2 -3
  31. package/commands/cms/convertFields.js +1 -1
  32. package/commands/cms/fetch.js +3 -2
  33. package/commands/cms/function/deploy.js +2 -2
  34. package/commands/cms/function/list.js +2 -3
  35. package/commands/cms/lighthouseScore.js +19 -27
  36. package/commands/cms/module/marketplace-validate.js +0 -1
  37. package/commands/cms/theme/__tests__/preview.test.js +2 -8
  38. package/commands/cms/theme/create.js +1 -1
  39. package/commands/cms/theme/marketplace-validate.js +0 -1
  40. package/commands/cms/theme/preview.d.ts +0 -1
  41. package/commands/cms/theme/preview.js +12 -52
  42. package/commands/cms/upload.js +3 -3
  43. package/commands/cms/watch.js +3 -3
  44. package/commands/customObject.js +0 -2
  45. package/commands/doctor.js +10 -2
  46. package/commands/filemanager/__tests__/upload.test.js +161 -0
  47. package/commands/getStarted.js +13 -3
  48. package/commands/hubdb/__tests__/list.test.js +0 -9
  49. package/commands/hubdb/list.js +6 -8
  50. package/commands/init.js +8 -2
  51. package/commands/mcp/__tests__/start.test.js +113 -3
  52. package/commands/mcp/setup.js +0 -7
  53. package/commands/mcp/start.d.ts +1 -1
  54. package/commands/mcp/start.js +0 -7
  55. package/commands/project/__tests__/add.test.js +0 -2
  56. package/commands/project/__tests__/create.test.js +2 -2
  57. package/commands/project/__tests__/deploy.test.js +0 -4
  58. package/commands/project/__tests__/dev.test.js +273 -0
  59. package/commands/project/__tests__/devUnifiedFlow.test.js +2 -5
  60. package/commands/project/__tests__/installDeps.test.js +0 -2
  61. package/commands/project/__tests__/lint.test.js +0 -5
  62. package/commands/project/__tests__/logs.test.js +24 -31
  63. package/commands/project/__tests__/migrate.test.js +7 -12
  64. package/commands/project/__tests__/updateDeps.test.js +0 -2
  65. package/commands/project/__tests__/upload.test.js +191 -0
  66. package/commands/project/__tests__/validate.test.js +314 -31
  67. package/commands/project/cloneApp.d.ts +1 -7
  68. package/commands/project/cloneApp.js +1 -149
  69. package/commands/project/create.js +3 -4
  70. package/commands/project/deploy.js +18 -7
  71. package/commands/project/dev/deprecatedFlow.js +0 -2
  72. package/commands/project/dev/index.js +23 -11
  73. package/commands/project/dev/unifiedFlow.d.ts +1 -1
  74. package/commands/project/dev/unifiedFlow.js +1 -4
  75. package/commands/project/list.js +4 -4
  76. package/commands/project/listBuilds.js +2 -7
  77. package/commands/project/logs.js +19 -12
  78. package/commands/project/migrate.js +3 -3
  79. package/commands/project/profile/add.js +1 -1
  80. package/commands/project/profile/delete.js +1 -1
  81. package/commands/project/upload.d.ts +1 -1
  82. package/commands/project/upload.js +13 -4
  83. package/commands/project/validate.js +85 -13
  84. package/commands/project/watch.js +7 -7
  85. package/commands/project.js +0 -4
  86. package/commands/sandbox/__tests__/create.test.js +0 -2
  87. package/commands/secret/__tests__/addSecret.test.js +140 -7
  88. package/commands/secret/addSecret.js +3 -1
  89. package/commands/testAccount/__tests__/create.test.js +6 -1
  90. package/commands/testAccount/__tests__/importData.test.js +0 -1
  91. package/commands/testAccount/create.d.ts +1 -0
  92. package/commands/testAccount/create.js +13 -5
  93. package/commands/upgrade.d.ts +8 -0
  94. package/commands/upgrade.js +119 -0
  95. package/lang/en.d.ts +88 -10
  96. package/lang/en.js +105 -26
  97. package/lib/__tests__/buildAccount.test.js +0 -13
  98. package/lib/__tests__/cliUpgradeUtils.test.js +131 -0
  99. package/lib/__tests__/commonOpts.test.js +0 -1
  100. package/lib/__tests__/dependencyManagement.test.js +633 -13
  101. package/lib/__tests__/developerTestAccounts.test.js +0 -1
  102. package/lib/__tests__/hasFeature.test.js +0 -6
  103. package/lib/__tests__/importData.test.js +0 -1
  104. package/lib/__tests__/npmCli.test.js +84 -0
  105. package/lib/__tests__/oauth.test.js +1 -11
  106. package/lib/__tests__/process.test.js +0 -1
  107. package/lib/__tests__/sandboxSync.test.js +0 -1
  108. package/lib/__tests__/sandboxes.test.js +0 -1
  109. package/lib/__tests__/serverlessLogs.test.js +0 -1
  110. package/lib/__tests__/usageTracking.test.js +39 -6
  111. package/lib/__tests__/validation.test.js +0 -1
  112. package/lib/app/__tests__/migrate.test.js +137 -12
  113. package/lib/app/migrate.d.ts +5 -2
  114. package/lib/app/migrate.js +30 -11
  115. package/lib/app/urls.d.ts +1 -1
  116. package/lib/buildAccount.d.ts +1 -1
  117. package/lib/cliUpgradeUtils.d.ts +22 -0
  118. package/lib/cliUpgradeUtils.js +62 -0
  119. package/lib/cmsAssets/api-sample.js +2 -5
  120. package/lib/cmsAssets/function.js +1 -9
  121. package/lib/cmsAssets/module.js +1 -9
  122. package/lib/cmsAssets/template.js +1 -9
  123. package/lib/configOptions.d.ts +0 -1
  124. package/lib/configOptions.js +1 -5
  125. package/lib/constants.d.ts +6 -0
  126. package/lib/constants.js +10 -4
  127. package/lib/dependencyManagement.d.ts +9 -0
  128. package/lib/dependencyManagement.js +127 -26
  129. package/lib/developerTestAccounts.d.ts +1 -1
  130. package/lib/doctor/Diagnosis.d.ts +1 -0
  131. package/lib/doctor/Diagnosis.js +7 -0
  132. package/lib/doctor/DiagnosticInfoBuilder.d.ts +2 -1
  133. package/lib/doctor/DiagnosticInfoBuilder.js +8 -4
  134. package/lib/doctor/Doctor.d.ts +12 -0
  135. package/lib/doctor/Doctor.js +283 -33
  136. package/lib/doctor/__tests__/Diagnosis.test.js +1 -0
  137. package/lib/doctor/__tests__/Doctor.test.js +201 -51
  138. package/lib/errorHandlers/__tests__/index.test.d.ts +1 -0
  139. package/lib/errorHandlers/__tests__/index.test.js +278 -0
  140. package/lib/errorHandlers/index.d.ts +1 -0
  141. package/lib/errorHandlers/index.js +14 -2
  142. package/lib/http.js +3 -1
  143. package/lib/links.js +2 -3
  144. package/lib/mcp/__tests__/setup.test.js +69 -2
  145. package/lib/mcp/setup.d.ts +1 -0
  146. package/lib/mcp/setup.js +37 -4
  147. package/lib/middleware/__tests__/configMiddleware.test.js +1 -43
  148. package/lib/middleware/__tests__/usageTrackingMiddleware.test.d.ts +1 -0
  149. package/lib/middleware/__tests__/usageTrackingMiddleware.test.js +44 -0
  150. package/lib/middleware/__tests__/yargsChecksMiddleware.test.js +0 -5
  151. package/lib/middleware/autoUpdateMiddleware.js +58 -57
  152. package/lib/middleware/configMiddleware.d.ts +0 -3
  153. package/lib/middleware/configMiddleware.js +0 -11
  154. package/lib/middleware/fireAlarmMiddleware.js +1 -1
  155. package/lib/middleware/spinniesMiddleware.d.ts +1 -0
  156. package/lib/middleware/spinniesMiddleware.js +4 -0
  157. package/lib/middleware/usageTrackingMiddleware.d.ts +13 -0
  158. package/lib/middleware/usageTrackingMiddleware.js +16 -0
  159. package/lib/{npm.d.ts → npm/npmCli.d.ts} +8 -3
  160. package/lib/npm/npmCli.js +59 -0
  161. package/lib/npm/packageJson.d.ts +24 -0
  162. package/lib/npm/packageJson.js +102 -0
  163. package/lib/npm/workspaces.d.ts +12 -0
  164. package/lib/npm/workspaces.js +48 -0
  165. package/lib/oauth.js +1 -3
  166. package/lib/projects/__tests__/AppDevModeInterface.test.js +40 -18
  167. package/lib/projects/__tests__/DevServerManager.test.js +1 -0
  168. package/lib/projects/__tests__/DevSessionManager.test.d.ts +1 -0
  169. package/lib/projects/__tests__/DevSessionManager.test.js +250 -0
  170. package/lib/projects/__tests__/LocalDevProcess.test.js +19 -6
  171. package/lib/projects/__tests__/LocalDevWebsocketServer.test.js +0 -2
  172. package/lib/projects/__tests__/UIExtensionsDevModeInterface.test.js +0 -1
  173. package/lib/projects/__tests__/components.test.js +6 -22
  174. package/lib/projects/__tests__/deploy.test.js +0 -1
  175. package/lib/projects/__tests__/localDevProjectHelpers.test.js +3 -5
  176. package/lib/projects/__tests__/pollProjectBuildAndDeploy.test.d.ts +1 -0
  177. package/lib/projects/__tests__/pollProjectBuildAndDeploy.test.js +328 -0
  178. package/lib/projects/__tests__/projectProfiles.test.d.ts +1 -0
  179. package/lib/projects/__tests__/projectProfiles.test.js +441 -0
  180. package/lib/projects/__tests__/projects.test.js +0 -1
  181. package/lib/projects/__tests__/structure.test.js +0 -1
  182. package/lib/projects/__tests__/uieLinting.test.js +2 -11
  183. package/lib/projects/__tests__/upload.test.js +104 -3
  184. package/lib/projects/add/__tests__/legacyAddComponent.test.js +0 -2
  185. package/lib/projects/add/__tests__/v2AddComponent.test.js +2 -4
  186. package/lib/projects/add/v2AddComponent.js +2 -3
  187. package/lib/projects/components.d.ts +1 -1
  188. package/lib/projects/components.js +4 -4
  189. package/lib/projects/create/__tests__/legacy.test.js +0 -1
  190. package/lib/projects/create/__tests__/v2.test.js +0 -1
  191. package/lib/projects/create/v2.d.ts +1 -1
  192. package/lib/projects/create/v2.js +1 -1
  193. package/lib/projects/ensureProjectExists.js +0 -1
  194. package/lib/projects/localDev/AppDevModeInterface.js +9 -2
  195. package/lib/projects/localDev/DevSessionManager.d.ts +18 -0
  196. package/lib/projects/localDev/DevSessionManager.js +95 -0
  197. package/lib/projects/localDev/LocalDevLogger.d.ts +4 -0
  198. package/lib/projects/localDev/LocalDevLogger.js +18 -7
  199. package/lib/projects/localDev/LocalDevManager_DEPRECATED.d.ts +4 -3
  200. package/lib/projects/localDev/LocalDevManager_DEPRECATED.js +23 -12
  201. package/lib/projects/localDev/LocalDevProcess.d.ts +2 -1
  202. package/lib/projects/localDev/LocalDevProcess.js +18 -7
  203. package/lib/projects/localDev/LocalDevState.d.ts +3 -2
  204. package/lib/projects/localDev/helpers/account.d.ts +1 -1
  205. package/lib/projects/localDev/helpers/devSessionsApi.d.ts +9 -0
  206. package/lib/projects/localDev/helpers/devSessionsApi.js +19 -0
  207. package/lib/projects/localDev/helpers/project.d.ts +1 -1
  208. package/lib/projects/localDev/helpers/project.js +1 -2
  209. package/lib/projects/pollProjectBuildAndDeploy.js +4 -5
  210. package/lib/projects/projectProfiles.d.ts +17 -0
  211. package/lib/projects/projectProfiles.js +140 -0
  212. package/lib/projects/structure.d.ts +1 -1
  213. package/lib/projects/uieLinting.js +6 -8
  214. package/lib/projects/upload.d.ts +9 -1
  215. package/lib/projects/upload.js +11 -5
  216. package/lib/projects/urls.d.ts +1 -0
  217. package/lib/projects/urls.js +3 -3
  218. package/lib/prompts/__tests__/createDeveloperTestAccountConfigPrompt.test.js +8 -4
  219. package/lib/prompts/createDeveloperTestAccountConfigPrompt.d.ts +2 -0
  220. package/lib/prompts/createDeveloperTestAccountConfigPrompt.js +19 -13
  221. package/lib/sandboxSync.d.ts +1 -1
  222. package/lib/sandboxes.d.ts +1 -1
  223. package/lib/serverlessLogs.js +0 -1
  224. package/lib/theme/__tests__/migrate.test.js +12 -4
  225. package/lib/theme/migrate.js +2 -3
  226. package/lib/ui/__tests__/SpinniesManager.test.js +0 -1
  227. package/lib/usageTracking.js +18 -0
  228. package/mcp-server/tools/cms/HsCreateFunctionTool.d.ts +2 -2
  229. package/mcp-server/tools/cms/HsCreateFunctionTool.js +2 -1
  230. package/mcp-server/tools/cms/HsCreateModuleTool.js +2 -1
  231. package/mcp-server/tools/cms/HsCreateTemplateTool.js +2 -1
  232. package/mcp-server/tools/cms/HsFunctionLogsTool.js +2 -2
  233. package/mcp-server/tools/cms/HsListFunctionsTool.js +2 -2
  234. package/mcp-server/tools/cms/HsListTool.js +2 -2
  235. package/mcp-server/tools/cms/__tests__/HsCreateFunctionTool.test.js +4 -4
  236. package/mcp-server/tools/cms/__tests__/HsCreateModuleTool.test.js +4 -4
  237. package/mcp-server/tools/cms/__tests__/HsCreateTemplateTool.test.js +4 -4
  238. package/mcp-server/tools/cms/__tests__/HsFunctionLogsTool.test.js +4 -4
  239. package/mcp-server/tools/cms/__tests__/HsListFunctionsTool.test.js +4 -4
  240. package/mcp-server/tools/cms/__tests__/HsListTool.test.js +4 -4
  241. package/mcp-server/tools/project/AddFeatureToProjectTool.js +4 -3
  242. package/mcp-server/tools/project/CreateProjectTool.js +4 -3
  243. package/mcp-server/tools/project/CreateTestAccountTool.d.ts +7 -2
  244. package/mcp-server/tools/project/CreateTestAccountTool.js +19 -9
  245. package/mcp-server/tools/project/DocFetchTool.js +2 -1
  246. package/mcp-server/tools/project/DocsSearchTool.js +2 -1
  247. package/mcp-server/tools/project/GetApiUsagePatternsByAppIdTool.js +4 -4
  248. package/mcp-server/tools/project/GetApplicationInfoTool.js +5 -5
  249. package/mcp-server/tools/project/GetConfigValuesTool.js +2 -1
  250. package/mcp-server/tools/project/UploadProjectTools.js +6 -3
  251. package/mcp-server/tools/project/ValidateProjectTool.js +2 -1
  252. package/mcp-server/tools/project/__tests__/AddFeatureToProjectTool.test.js +4 -2
  253. package/mcp-server/tools/project/__tests__/CreateProjectTool.test.js +4 -2
  254. package/mcp-server/tools/project/__tests__/CreateTestAccountTool.test.js +23 -4
  255. package/mcp-server/tools/project/__tests__/DeployProjectTool.test.js +3 -1
  256. package/mcp-server/tools/project/__tests__/DocFetchTool.test.js +0 -1
  257. package/mcp-server/tools/project/__tests__/DocsSearchTool.test.js +3 -1
  258. package/mcp-server/tools/project/__tests__/GetApiUsagePatternsByAppIdTool.test.js +4 -2
  259. package/mcp-server/tools/project/__tests__/GetApplicationInfoTool.test.js +8 -5
  260. package/mcp-server/tools/project/__tests__/GetBuildLogsTool.test.js +3 -1
  261. package/mcp-server/tools/project/__tests__/GetBuildStatusTool.test.js +3 -1
  262. package/mcp-server/tools/project/__tests__/GetConfigValuesTool.test.js +7 -3
  263. package/mcp-server/tools/project/__tests__/GuidedWalkthroughTool.test.js +3 -1
  264. package/mcp-server/tools/project/__tests__/UploadProjectTools.test.js +17 -3
  265. package/mcp-server/tools/project/__tests__/ValidateProjectTool.test.js +3 -1
  266. package/mcp-server/utils/__tests__/content.test.js +0 -3
  267. package/mcp-server/utils/__tests__/feedbackTracking.test.js +0 -3
  268. package/mcp-server/utils/__tests__/project.test.js +65 -4
  269. package/mcp-server/utils/project.js +6 -2
  270. package/package.json +15 -17
  271. package/types/Cms.d.ts +1 -1
  272. package/types/Cms.js +2 -0
  273. package/types/LocalDev.d.ts +3 -2
  274. package/types/PackageJson.d.ts +10 -0
  275. package/types/PackageJson.js +1 -0
  276. package/types/ProjectComponents.d.ts +1 -1
  277. package/ui/components/BoxWithTitle.js +1 -1
  278. package/ui/components/Table.d.ts +89 -0
  279. package/ui/components/Table.js +246 -0
  280. package/ui/lib/table.d.ts +2 -0
  281. package/ui/lib/table.js +11 -0
  282. package/ui/playground/Playground.d.ts +5 -0
  283. package/ui/{views/UiSandbox.js → playground/Playground.js} +4 -4
  284. package/ui/{lib/ui-testing-utils.d.ts → playground/fixtures.d.ts} +1 -1
  285. package/ui/{lib/ui-testing-utils.js → playground/fixtures.js} +33 -1
  286. package/ui/render.d.ts +19 -0
  287. package/ui/render.js +44 -0
  288. package/commands/__tests__/create.test.js +0 -53
  289. package/commands/create.d.ts +0 -4
  290. package/commands/create.js +0 -137
  291. package/commands/customObject/__tests__/schema.test.js +0 -53
  292. package/commands/customObject/schema/create.d.ts +0 -4
  293. package/commands/customObject/schema/create.js +0 -34
  294. package/commands/customObject/schema/delete.d.ts +0 -4
  295. package/commands/customObject/schema/delete.js +0 -37
  296. package/commands/customObject/schema/fetch-all.d.ts +0 -4
  297. package/commands/customObject/schema/fetch-all.js +0 -32
  298. package/commands/customObject/schema/fetch.d.ts +0 -4
  299. package/commands/customObject/schema/fetch.js +0 -36
  300. package/commands/customObject/schema/list.d.ts +0 -4
  301. package/commands/customObject/schema/list.js +0 -26
  302. package/commands/customObject/schema/update.d.ts +0 -4
  303. package/commands/customObject/schema/update.js +0 -39
  304. package/commands/customObject/schema.d.ts +0 -3
  305. package/commands/customObject/schema.js +0 -31
  306. package/commands/fetch.d.ts +0 -4
  307. package/commands/fetch.js +0 -52
  308. package/commands/function/deploy.d.ts +0 -4
  309. package/commands/function/deploy.js +0 -31
  310. package/commands/function/list.d.ts +0 -4
  311. package/commands/function/list.js +0 -33
  312. package/commands/function/server.d.ts +0 -4
  313. package/commands/function/server.js +0 -57
  314. package/commands/function.d.ts +0 -3
  315. package/commands/function.js +0 -32
  316. package/commands/lint.d.ts +0 -4
  317. package/commands/lint.js +0 -31
  318. package/commands/list.d.ts +0 -4
  319. package/commands/list.js +0 -31
  320. package/commands/logs.d.ts +0 -4
  321. package/commands/logs.js +0 -58
  322. package/commands/module/marketplace-validate.d.ts +0 -4
  323. package/commands/module/marketplace-validate.js +0 -31
  324. package/commands/module.d.ts +0 -3
  325. package/commands/module.js +0 -23
  326. package/commands/mv.d.ts +0 -4
  327. package/commands/mv.js +0 -35
  328. package/commands/project/__tests__/migrateApp.test.js +0 -78
  329. package/commands/project/migrateApp.d.ts +0 -4
  330. package/commands/project/migrateApp.js +0 -55
  331. package/commands/remove.d.ts +0 -4
  332. package/commands/remove.js +0 -31
  333. package/commands/theme/generate-selectors.d.ts +0 -4
  334. package/commands/theme/generate-selectors.js +0 -30
  335. package/commands/theme/marketplace-validate.d.ts +0 -4
  336. package/commands/theme/marketplace-validate.js +0 -33
  337. package/commands/theme/preview.d.ts +0 -4
  338. package/commands/theme/preview.js +0 -59
  339. package/commands/theme.d.ts +0 -3
  340. package/commands/theme.js +0 -29
  341. package/commands/upload.d.ts +0 -4
  342. package/commands/upload.js +0 -62
  343. package/commands/watch.d.ts +0 -4
  344. package/commands/watch.js +0 -73
  345. package/lib/__tests__/npm.test.js +0 -57
  346. package/lib/__tests__/projectProfiles.test.js +0 -129
  347. package/lib/app/__tests__/migrate_legacy.test.js +0 -143
  348. package/lib/app/migrate_legacy.d.ts +0 -4
  349. package/lib/app/migrate_legacy.js +0 -121
  350. package/lib/npm.js +0 -33
  351. package/lib/projectProfiles.d.ts +0 -7
  352. package/lib/projectProfiles.js +0 -73
  353. package/lib/ui/table.d.ts +0 -3
  354. package/lib/ui/table.js +0 -63
  355. package/ui/index.d.ts +0 -1
  356. package/ui/index.js +0 -6
  357. package/ui/views/UiSandbox.d.ts +0 -5
  358. /package/commands/__tests__/{create.test.d.ts → upgrade.test.d.ts} +0 -0
  359. /package/commands/{customObject/__tests__/schema.test.d.ts → cms/__tests__/upload.test.d.ts} +0 -0
  360. /package/commands/{project/__tests__/migrateApp.test.d.ts → cms/__tests__/watch.test.d.ts} +0 -0
  361. /package/{lib/__tests__/npm.test.d.ts → commands/project/__tests__/dev.test.d.ts} +0 -0
  362. /package/lib/__tests__/{projectProfiles.test.d.ts → cliUpgradeUtils.test.d.ts} +0 -0
  363. /package/lib/{app/__tests__/migrate_legacy.test.d.ts → __tests__/npmCli.test.d.ts} +0 -0
package/lang/en.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import chalk from 'chalk';
2
- import { mapToUserFriendlyName } from '@hubspot/project-parsing-lib';
2
+ import { mapToUserFriendlyName } from '@hubspot/project-parsing-lib/transform';
3
3
  import { PLATFORM_VERSIONS } from '@hubspot/local-dev-lib/constants/projects';
4
4
  import { PERSONAL_ACCESS_KEY_AUTH_METHOD } from '@hubspot/local-dev-lib/constants/auth';
5
5
  import { ARCHIVED_HUBSPOT_CONFIG_YAML_FILE_NAME, GLOBAL_CONFIG_PATH, DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME, } from '@hubspot/local-dev-lib/constants/config';
@@ -10,9 +10,6 @@ import { APP_DISTRIBUTION_TYPES, APP_AUTH_TYPES, PROJECT_CONFIG_FILE, PROJECT_WI
10
10
  export const commands = {
11
11
  generalErrors: {
12
12
  srcIsProject: (src, command) => `"${src}" is in a project folder. Did you mean "hs project ${command}"?`,
13
- handleDeprecatedEnvVariables: {
14
- portalEnvVarDeprecated: 'The HUBSPOT_PORTAL_ID environment variable is deprecated. Please use HUBSPOT_ACCOUNT_ID instead.',
15
- },
16
13
  validateConfigMiddleware: {
17
14
  missingConfigFile: `A HubSpot config file is required to run this command, but none was found. To create a new config file and authenticate a HubSpot account, run ${uiCommandReference('hs account auth')}`,
18
15
  configValidationFailed: (errors) => `Your HubSpot config file is invalid. Please fix the following errors:\n - ${errors.join('\n- ')}`,
@@ -419,7 +416,6 @@ export const commands = {
419
416
  dest: 'Path in HubSpot Design Tools. Can be a net new path. If you wish to preview a site page using your theme changes it must match the path of the theme used by the site.',
420
417
  },
421
418
  options: {
422
- notify: 'Log to specified file when a watch task is triggered and after workers have gone idle. Ex. --notify path/to/file',
423
419
  noSsl: 'Disable HTTPS',
424
420
  port: 'The port on which to start the local server',
425
421
  },
@@ -1026,6 +1022,27 @@ export const commands = {
1026
1022
  },
1027
1023
  outputWritten: (filename) => `Output written to ${chalk.bold(filename)}`,
1028
1024
  },
1025
+ upgrade: {
1026
+ describe: 'Install the latest version of the HubSpot CLI, or a specific version.',
1027
+ options: {
1028
+ version: 'Specific version to install (defaults to latest)',
1029
+ force: 'Skip confirmation prompt and install immediately',
1030
+ beta: 'Install the next version of the HubSpot CLI (beta)',
1031
+ },
1032
+ alreadyLatest: (version, beta) => `You are already running the latest ${beta ? 'beta ' : ''}version (${chalk.bold(version)}).`,
1033
+ alreadyOnVersion: (current) => `You are already running version ${chalk.bold(current)}`,
1034
+ autoUpgradeNotAvailable: (version) => `Unable to auto-upgrade the HubSpot CLI. You can manually install ${chalk.bold(`@hubspot/cli@${version}`)}`,
1035
+ confirmPrompt: (current, version) => `Upgrade from ${current} to version ${version}?`,
1036
+ cancelled: 'Upgrade cancelled.',
1037
+ installing: (version) => `Installing @hubspot/cli@${version}...`,
1038
+ success: (version) => `Successfully installed @hubspot/cli@${version}`,
1039
+ autoUpgradeMessage: `The HubSpot CLI supports automatic updates as an optional feature.\n\nWhen enabled, the CLI will automatically install non-breaking updates within the current major version. Major releases will always require manual upgrades.\n\nRun ${uiCommandReference('hs config set --allow-auto-updates=true')}\n\nYou can change this later at any time with ${uiCommandReference('hs config set')}`,
1040
+ errors: {
1041
+ unableToDetermineLatestVersion: 'Unable to determine the latest version of the HubSpot CLI. Please try again later.',
1042
+ installFailed: 'Failed to install the CLI. Verify that the target version is available and try again.',
1043
+ generic: 'An error occurred while upgrading the CLI.',
1044
+ },
1045
+ },
1029
1046
  filemanager: {
1030
1047
  describe: 'Commands for managing files in the File Manager.',
1031
1048
  subcommands: {
@@ -1198,16 +1215,16 @@ export const commands = {
1198
1215
  codex: 'Codex CLI',
1199
1216
  claudeCode: 'Claude Code',
1200
1217
  cursor: 'Cursor',
1218
+ gemini: 'Gemini CLI',
1201
1219
  windsurf: 'Windsurf',
1202
1220
  vsCode: 'VSCode',
1203
1221
  args: {
1204
- client: 'Target applications to configure',
1222
+ client: 'Target apps to configure',
1205
1223
  docsSearch: 'Should the docs search mcp server be installed',
1206
1224
  },
1207
1225
  success: (derivedTargets) => `You can now use the HubSpot CLI MCP Server in ${derivedTargets.join(', ')}. ${chalk.bold('You may need to restart these tools to apply the changes')}.`,
1208
1226
  errors: {
1209
1227
  needsMcpAccess: (accountId) => `You must opt in to the developer MCP beta to use this feature on ${uiAccountDescription(accountId)}. Try again with a different account or ${uiLink('join the beta now', getProductUpdatesUrl('239890', accountId))}`,
1210
- needsNode20: `This feature requires node >=20`,
1211
1228
  errorParsingJsonFIle: (filename, errorMessage) => `Unable to update ${chalk.bold(filename)} due to invalid JSON: ${errorMessage}`,
1212
1229
  },
1213
1230
  spinners: {
@@ -1226,6 +1243,11 @@ export const commands = {
1226
1243
  configuringCursor: 'Configuring Cursor...',
1227
1244
  failedToConfigureCursor: 'Failed to configure Cursor',
1228
1245
  configuredCursor: 'Configured Cursor',
1246
+ // Gemini
1247
+ configuringGemini: 'Configuring Gemini CLI...',
1248
+ configuredGemini: 'Configured Gemini CLI',
1249
+ geminiNotFound: 'Gemini CLI not found - skipping configuration',
1250
+ geminiInstallFailed: 'Failed to configure Gemini CLI',
1229
1251
  alreadyInstalled: 'HubSpot CLI mcp server already installed, reinstalling',
1230
1252
  // Windsurf
1231
1253
  configuringWindsurf: 'Configuring Windsurf...',
@@ -1239,12 +1261,11 @@ export const commands = {
1239
1261
  },
1240
1262
  prompts: {
1241
1263
  targets: '[--client] Which tools would you like to add the HubSpot CLI MCP server to?',
1242
- targetsRequired: 'Must choose at least one application to configure.',
1264
+ targetsRequired: 'Must choose at least one app to configure.',
1243
1265
  },
1244
1266
  },
1245
1267
  start: {
1246
1268
  errors: {
1247
- needsNode20: `This feature requires node >=20`,
1248
1269
  serverFileNotFound: (serverPath) => `MCP server file not found at ${serverPath}`,
1249
1270
  failedToStart: 'Failed to start MCP server',
1250
1271
  },
@@ -1364,6 +1385,9 @@ export const commands = {
1364
1385
  examples: {
1365
1386
  default: 'Start local dev for the current project',
1366
1387
  },
1388
+ prompts: {
1389
+ selectProfile: '[--profile] Select a profile to use for local development',
1390
+ },
1367
1391
  options: {
1368
1392
  profile: 'The profile to target during local dev',
1369
1393
  projectAccount: 'The id of the account to upload your project to. Must be used with --testing-account. Supported on platform versions 2025.2 and newer.',
@@ -1417,7 +1441,7 @@ export const commands = {
1417
1441
  describe: 'How the app will be distributed.',
1418
1442
  },
1419
1443
  auth: {
1420
- describe: 'Authentication model for the application.',
1444
+ describe: 'Authentication model for the app.',
1421
1445
  },
1422
1446
  features: {
1423
1447
  describe: `Features to include in the project. Only valid if project-base is ${PROJECT_WITH_APP}`,
@@ -1515,13 +1539,13 @@ export const commands = {
1515
1539
  describe: "The path to the component type's location within the hubspot-project-components Github repo: https://github.com/HubSpot/hubspot-project-components",
1516
1540
  },
1517
1541
  distribution: {
1518
- describe: 'The distribution method for the application.',
1542
+ describe: 'The distribution method for the app.',
1519
1543
  },
1520
1544
  auth: {
1521
- describe: 'The authentication type for the application.',
1545
+ describe: 'The authentication type for the app.',
1522
1546
  },
1523
1547
  features: {
1524
- describe: 'Which features to include with the application.',
1548
+ describe: 'Which features to include with the app.',
1525
1549
  },
1526
1550
  },
1527
1551
  creatingComponent: (projectName) => `Adding feature(s) to app [${chalk.bold(projectName)}]\n`,
@@ -1565,6 +1589,7 @@ export const commands = {
1565
1589
  examples: {
1566
1590
  default: 'Deploy the latest build of the current project',
1567
1591
  withOptions: 'Deploy build 5 of the project my-project',
1592
+ withProfile: 'Deploy using the provided profile',
1568
1593
  },
1569
1594
  options: {
1570
1595
  build: 'Project build ID to be deployed',
@@ -1647,6 +1672,7 @@ export const commands = {
1647
1672
  describe: 'Upload your project files and create a new build.',
1648
1673
  examples: {
1649
1674
  default: 'Upload a project into your HubSpot account',
1675
+ withProfile: 'Upload a project into your HubSpot account when using profiles',
1650
1676
  },
1651
1677
  logs: {
1652
1678
  buildSucceeded: (buildId) => `Build #${buildId} succeeded\n`,
@@ -1825,12 +1851,23 @@ export const commands = {
1825
1851
  badVersion: 'This command is only available for projects 2025.2 and later.',
1826
1852
  examples: {
1827
1853
  default: 'Validate the project before uploading',
1854
+ withProfile: 'Validate the project with a profile before uploading.',
1828
1855
  },
1829
1856
  success: (projectName) => `Project ${projectName} is valid and ready to upload`,
1830
- failure: (projectName) => `Project ${projectName} is invalid`,
1857
+ failure: (projectName, profileName) => `Project ${projectName} is invalid${profileName ? ` with profile "${profileName}" applied` : ''}`,
1858
+ failureWithProfile: (profileName) => chalk.bold(`With profile "${profileName}":`),
1859
+ spinners: {
1860
+ validatingProfile: (profileName) => `Validating project with profile "${profileName}"`,
1861
+ profileValidationFailed: (profileName) => `Profile "${profileName}" failed validation`,
1862
+ profileValidationSucceeded: (profileName) => `Project valid with profile "${profileName}" applied`,
1863
+ invalidWithProfile: (profileName) => `Project is invalid with profile "${profileName}" applied`,
1864
+ validatingAllProfiles: 'Validating the project with all profiles',
1865
+ allProfilesValidationSucceeded: 'Project profile validation succeeded',
1866
+ allProfilesValidationFailed: 'Project profile validation failed',
1867
+ },
1831
1868
  options: {
1832
1869
  profile: {
1833
- describe: 'The profile to target for this validation',
1870
+ describe: 'The profile to target for this validation. If no profile is provided, all profiles will be validated.',
1834
1871
  },
1835
1872
  },
1836
1873
  },
@@ -2149,7 +2186,7 @@ export const commands = {
2149
2186
  polling: {
2150
2187
  start: (testAccountName) => `Creating test account "${chalk.bold(testAccountName)}"...`,
2151
2188
  syncing: 'Test account created! Syncing account data... (may take a few minutes - you can exit and the sync will continue)',
2152
- success: (testAccountName, testAccountId) => `Test account "${chalk.bold(testAccountName)}" successfully created with id: ${chalk.bold(testAccountId)}`,
2189
+ success: (testAccountName, testAccountId, parentAccountId) => `Test account "${chalk.bold(testAccountName)}" successfully created with id ${chalk.bold(testAccountId)} under parent account ${uiAccountDescription(parentAccountId)}`,
2153
2190
  createFailure: 'Failed to create test account.',
2154
2191
  },
2155
2192
  options: {
@@ -2161,6 +2198,7 @@ export const commands = {
2161
2198
  serviceLevel: 'Service Hub tier. Options: FREE, STARTER, PROFESSIONAL, ENTERPRISE',
2162
2199
  salesLevel: 'Sales Hub tier. Options: FREE, STARTER, PROFESSIONAL, ENTERPRISE',
2163
2200
  contentLevel: 'CMS Hub tier. Options: FREE, STARTER, PROFESSIONAL, ENTERPRISE',
2201
+ commerceLevel: 'Commerce Hub tier. Options: FREE, PROFESSIONAL, ENTERPRISE',
2164
2202
  },
2165
2203
  example: (configPath) => `Create a test account from the config file at ${configPath}`,
2166
2204
  examples: {
@@ -2171,7 +2209,7 @@ export const commands = {
2171
2209
  },
2172
2210
  createConfig: {
2173
2211
  describe: 'Create a test account config file.',
2174
- pathPrompt: '[--path] Enter the name of the Test Account config file: ',
2212
+ pathPrompt: '[--path] Enter the name of the test account config file: ',
2175
2213
  errors: {
2176
2214
  pathError: 'Path is required',
2177
2215
  pathFormatError: 'Path must end with .json',
@@ -2869,6 +2907,12 @@ export const lib = {
2869
2907
  startError: (message) => `Failed to start local dev server: ${message}`,
2870
2908
  fileChangeError: (message) => `Failed to notify local dev server of file change: ${message}`,
2871
2909
  },
2910
+ devSession: {
2911
+ registrationError: (message) => `Failed to register dev session: ${message}`,
2912
+ missingSessionIdError: 'Failed to connect to dev session: Missing session ID. Please try creating a new dev session.',
2913
+ heartbeatError: (message) => `Failed to send dev session heartbeat: ${message}`,
2914
+ deletionError: (message) => `Failed to delete dev session: ${message}`,
2915
+ },
2872
2916
  },
2873
2917
  AppDevModeInterface: {
2874
2918
  autoInstallStaticAuthApp: {
@@ -2956,7 +3000,7 @@ export const lib = {
2956
3000
  privateApp: `This project contains a private app. Local development of private apps is not supported in developer accounts. Change your default account using ${uiCommandReference('hs account use')}, or link a new account with ${uiAuthCommandReference()}.`,
2957
3001
  },
2958
3002
  validateAccountOption: {
2959
- invalidPublicAppAccount: `This project contains a public app. The "--account" flag must point to a developer test account to develop this project locally. Alternatively, change your default account to an App Developer Account using ${uiCommandReference('hs account use')} and run ${uiCommandReference('hs project dev')} to set up a new Developer Test Account.`,
3003
+ invalidPublicAppAccount: `This project contains a public app. The "--account" flag must point to a developer test account to develop this project locally. Alternatively, change your default account to an app developer account using ${uiCommandReference('hs account use')} and run ${uiCommandReference('hs project dev')} to set up a new developer test account.`,
2960
3004
  invalidPrivateAppAccount: `This project contains a private app. The account specified with the "--account" flag points to a developer account, which do not support the local development of private apps. Update the "--account" flag to point to a standard, sandbox, or developer test account, or change your default account by running ${uiCommandReference('hs account use')}.`,
2961
3005
  nonSandboxWarning: `Testing in a sandbox is strongly recommended. To switch the target account, select an option below or run ${uiCommandReference('hs account use')} before running the command again.`,
2962
3006
  publicAppNonDeveloperTestAccountWarning: `Local development of public apps is only supported in ${chalk.bold('developer test accounts')}.`,
@@ -2979,7 +3023,7 @@ export const lib = {
2979
3023
  },
2980
3024
  middleware: {
2981
3025
  updateNotification: {
2982
- notifyTitle: chalk.bold('CLI update available'),
3026
+ notifyTitle: chalk.bold('Update available'),
2983
3027
  cmsUpdateNotification: (packageName) => `${chalk.bold('The CMS CLI is now the HubSpot CLI')}\n\nTo upgrade, uninstall ${chalk.bold(packageName)}\nand then run ${uiCommandReference('{updateCommand}')}`,
2984
3028
  cliUpdateNotification: (currentVersion, updateCommand, latestVersion) => `HubSpot CLI version ${chalk.cyan(chalk.bold(`${currentVersion}`))} is outdated.\nRun ${uiCommandReference(`${updateCommand}`)} to upgrade to version ${chalk.cyan(chalk.bold(`${latestVersion}`))}`,
2985
3029
  },
@@ -2988,6 +3032,7 @@ export const lib = {
2988
3032
  updateSucceeded: (latestVersion) => `Successfully updated HubSpot CLI to version ${chalk.bold(latestVersion)}`,
2989
3033
  notInstalledGlobally: 'Cannot auto-update the HubSpot CLI because NPM is not installed globally',
2990
3034
  updateFailed: (latestVersion) => `Failed to update HubSpot CLI to version ${chalk.bold(latestVersion)}`,
3035
+ enableAutoUpdatesMessage: `The HubSpot CLI can automatically keep itself up to date.\n\nThis helps ensure compatibility with the HubSpot platform. You can change this later at any time.\n\nRun${uiCommandReference('hs config set --allow-auto-updates=true')}`,
2991
3036
  },
2992
3037
  },
2993
3038
  projectProfiles: {
@@ -3006,7 +3051,9 @@ export const lib = {
3006
3051
  noProjectConfig: 'No project config found. Please run this command from a project directory.',
3007
3052
  profileNotFound: (profileName) => `Profile ${chalk.bold(profileName)} not found.`,
3008
3053
  missingAccountId: (profileName) => `Profile ${chalk.bold(profileName)} is missing an account id.`,
3054
+ listedAccountNotFound: (accountId, profileName) => `The account ${uiAccountDescription(accountId)} is defined in your profile ${chalk.bold(profileName)}, but is missing in your config file`,
3009
3055
  failedToLoadProfile: (profileName) => `Failed to load profile ${chalk.bold(profileName)}.`,
3056
+ profileNotValid: (profileName, errors) => `${chalk.bold(`With profile "${profileName}"`)}:\n\t- ${errors.join('\n\t- ')}`,
3010
3057
  },
3011
3058
  },
3012
3059
  },
@@ -3015,7 +3062,7 @@ export const lib = {
3015
3062
  prompt: {
3016
3063
  marketPlaceDistribution: 'On the HubSpot marketplace',
3017
3064
  privateDistribution: 'Privately',
3018
- distribution: '[--distribution] Choose how to distribute your application:',
3065
+ distribution: '[--distribution] Choose how to distribute your app:',
3019
3066
  auth: '[--auth] Choose your authentication type:',
3020
3067
  staticAuth: 'Static Auth',
3021
3068
  oauth: 'OAuth',
@@ -3342,10 +3389,10 @@ export const lib = {
3342
3389
  keepingCurrentDefault: (accountName) => `Account "${accountName}" will continue to be the default account`,
3343
3390
  },
3344
3391
  createDeveloperTestAccountConfigPrompt: {
3345
- namePrompt: (withFlag = true) => `${withFlag ? '[--name] ' : ''}Enter the name of the Test Account:`,
3346
- descriptionPrompt: (withFlag = true) => `${withFlag ? '[--description] ' : ''}Enter the description of the Test Account:`,
3392
+ namePrompt: (withFlag = true) => `${withFlag ? '[--name] ' : ''}Enter the name of the test account:`,
3393
+ descriptionPrompt: (withFlag = true) => `${withFlag ? '[--description] ' : ''}Enter the description of the test account:`,
3347
3394
  useDefaultAccountLevelsPrompt: {
3348
- message: 'Would you like to create a default Test Account, or customize your own?',
3395
+ message: 'Would you like to create a default test account, or customize your own?',
3349
3396
  default: 'Default (All Hubs, ENTERPRISE)',
3350
3397
  manual: 'Customize my own',
3351
3398
  },
@@ -3356,11 +3403,12 @@ export const lib = {
3356
3403
  service: 'Service',
3357
3404
  sales: 'Sales',
3358
3405
  content: 'Content',
3406
+ commerce: 'Commerce',
3359
3407
  },
3360
3408
  errors: {
3361
3409
  allHubsRequired: 'Select a tier for each hub',
3362
3410
  tiersError: 'Cannot have more than one tier per hub',
3363
- nameRequired: 'The name may not be blank. Please add a name for the Test Account.',
3411
+ nameRequired: 'The name may not be blank. Please add a name for the test account.',
3364
3412
  },
3365
3413
  },
3366
3414
  accountNamePrompt: {
@@ -3739,7 +3787,7 @@ export const lib = {
3739
3787
  notLatestSecondary: (command, hsVersion) => `Run ${uiCommandReference(command)} to upgrade to the latest version ${hsVersion}`,
3740
3788
  latest: (hsVersion) => `HubSpot CLI v${hsVersion} up to date`,
3741
3789
  unableToDetermine: 'Unable to determine if HubSpot CLI is up to date.',
3742
- unableToDetermineSecondary: (command, link) => `Run ${uiCommandReference(command)} to check your installed version; then visit the ${uiLink('npm HubSpot CLI version history', link)} to validate whether you have the latest version`,
3790
+ unableToDetermineSecondary: (link) => `Run ${uiCommandReference('hs --version')} to check your installed version; then visit the ${uiLink('npm HubSpot CLI version history', link)} to validate whether you have the latest version`,
3743
3791
  },
3744
3792
  projectDependenciesChecks: {
3745
3793
  missingDependencies: (dir) => `missing dependencies in ${chalk.bold(dir)}`,
@@ -3753,9 +3801,18 @@ export const lib = {
3753
3801
  },
3754
3802
  port: {
3755
3803
  inUse: (port) => `Port ${port} is in use`,
3756
- inUseSecondary: (command) => `Make sure it is available before running ${uiCommandReference(command)}`,
3804
+ inUseSecondary: `Make sure it is available before running ${uiCommandReference('hs project dev')}`,
3757
3805
  available: (port) => `Port ${port} available for local development`,
3758
3806
  },
3807
+ projectValidation: {
3808
+ valid: 'Project configuration and structure is valid',
3809
+ configInvalid: 'Project configuration is invalid',
3810
+ configMissing: 'Project configuration file not found',
3811
+ sourceDirectoryInvalid: 'Project source directory validation failed',
3812
+ translationFailed: 'Project validation failed',
3813
+ profileValidationFailed: (profileName) => `Project validation failed with profile '${profileName}' applied`,
3814
+ validationDetails: `Run ${uiCommandReference('hs project validate')} for more details.`,
3815
+ },
3759
3816
  diagnosis: {
3760
3817
  cli: {
3761
3818
  header: 'HubSpot CLI install',
@@ -3784,6 +3841,28 @@ export const lib = {
3784
3841
  warnings: (count) => `${chalk.bold('Warning:')} ${count}`,
3785
3842
  },
3786
3843
  },
3844
+ networkChecks: {
3845
+ header: 'Network & API connectivity',
3846
+ hubspotApiReachable: 'HubSpot API is reachable',
3847
+ hubspotApiUnreachable: 'Unable to connect to HubSpot API',
3848
+ hubspotApiUnreachableSecondary: 'Check your internet connection and firewall settings',
3849
+ npmRegistryReachable: 'npm registry is reachable',
3850
+ npmRegistryUnreachable: 'Unable to connect to npm registry',
3851
+ npmRegistryUnreachableSecondary: 'Check your internet connection and npm configuration',
3852
+ },
3853
+ webhookChecks: {
3854
+ header: 'Webhook endpoints',
3855
+ endpointReachable: (url) => `Webhook endpoint reachable: ${url}`,
3856
+ endpointUnreachable: (url) => `Webhook endpoint unreachable: ${url}`,
3857
+ endpointUnreachableSecondary: 'Verify the URL is correct and the server is running',
3858
+ checkType: 'Webhook',
3859
+ },
3860
+ appRedirectChecks: {
3861
+ redirectUrlReachable: (url) => `App redirect URL reachable: ${url}`,
3862
+ redirectUrlUnreachable: (url) => `App redirect URL unreachable: ${url}`,
3863
+ redirectUrlUnreachableSecondary: 'Verify the URL is correct and the server is running',
3864
+ checkType: 'App redirect URL',
3865
+ },
3787
3866
  defaultAccountOverrideFileChecks: {
3788
3867
  overrideActive: (defaultAccountOverrideFile) => `Default account override file is active: ${defaultAccountOverrideFile}`,
3789
3868
  overrideAccountId: (overrideAccountId) => `Active account ID: ${overrideAccountId}`,
@@ -11,7 +11,6 @@ vi.mock('@hubspot/local-dev-lib/personalAccessKey');
11
11
  vi.mock('@hubspot/local-dev-lib/config');
12
12
  vi.mock('@hubspot/local-dev-lib/api/developerTestAccounts');
13
13
  vi.mock('@hubspot/local-dev-lib/api/sandboxHubs');
14
- vi.mock('../ui/logger.js');
15
14
  vi.mock('../errorHandlers/index.js');
16
15
  vi.mock('../prompts/personalAccessKeyPrompt');
17
16
  vi.mock('../prompts/accountNamePrompt');
@@ -65,9 +64,6 @@ describe('lib/buildAccount', () => {
65
64
  mockedGetConfigAccountIfExists.mockResolvedValue(undefined);
66
65
  mockedUpdateConfigAccount.mockReturnValue(undefined);
67
66
  });
68
- afterEach(() => {
69
- vi.clearAllMocks();
70
- });
71
67
  it('should save account with provided personal access key', async () => {
72
68
  const result = await buildAccount.saveAccountToConfig(mockAccountConfig.accountId, mockAccountConfig.name, mockAccountConfig.env, 'test-key');
73
69
  expect(mockedPersonalAccessKeyPrompt).not.toHaveBeenCalled();
@@ -157,9 +153,6 @@ describe('lib/buildAccount', () => {
157
153
  data: mockDeveloperTestAccount,
158
154
  });
159
155
  });
160
- afterEach(() => {
161
- vi.clearAllMocks();
162
- });
163
156
  it('should create a developer test account successfully', async () => {
164
157
  const result = await buildAccount.buildDeveloperTestAccount(mockDeveloperTestAccount.accountName, mockParentAccountConfig, mockParentAccountConfig.env, 10);
165
158
  expect(result).toEqual(mockDeveloperTestAccount.id);
@@ -198,9 +191,6 @@ describe('lib/buildAccount', () => {
198
191
  data: { sandbox: mockSandbox, personalAccessKey: 'test-key' },
199
192
  });
200
193
  });
201
- afterEach(() => {
202
- vi.clearAllMocks();
203
- });
204
194
  it('should create a standard sandbox successfully', async () => {
205
195
  const result = await buildAccount.buildSandbox(mockSandbox.name, mockParentAccountConfig, HUBSPOT_ACCOUNT_TYPES.STANDARD_SANDBOX, mockParentAccountConfig.env, false);
206
196
  expect(result).toEqual({
@@ -254,9 +244,6 @@ describe('lib/buildAccount', () => {
254
244
  data: { personalAccessKey: { encodedOAuthRefreshToken: 'test-key' } },
255
245
  });
256
246
  });
257
- afterEach(() => {
258
- vi.clearAllMocks();
259
- });
260
247
  it('should create a v2 standard sandbox successfully and fetch a personal access key', async () => {
261
248
  const result = await buildAccount.buildV2Sandbox(mockSandbox.name, mockParentAccountConfig, HUBSPOT_ACCOUNT_TYPES.STANDARD_SANDBOX, false, mockParentAccountConfig.env, false);
262
249
  expect(result).toEqual({ sandbox: mockSandbox });
@@ -0,0 +1,131 @@
1
+ import updateNotifier from 'update-notifier';
2
+ import { isCliGloballyInstalled, canCliBeAutoUpgraded, getLatestCliVersion, getCliUpgradeInfo, installCliVersion, } from '../cliUpgradeUtils.js';
3
+ import { isGloballyInstalled, getLatestPackageVersion, executeInstall, isInstalledGloballyWithNPM, } from '../npm/npmCli.js';
4
+ import { pkg } from '../jsonLoader.js';
5
+ vi.mock('../npm/npmCli');
6
+ vi.mock('update-notifier');
7
+ vi.mock('../jsonLoader.js', () => ({
8
+ pkg: {
9
+ name: '@hubspot/cli',
10
+ version: '7.11.2',
11
+ },
12
+ }));
13
+ const mockedIsGloballyInstalled = vi.mocked(isGloballyInstalled);
14
+ const mockedGetLatestPackageVersion = vi.mocked(getLatestPackageVersion);
15
+ const mockedExecuteInstall = vi.mocked(executeInstall);
16
+ const mockedUpdateNotifier = vi.mocked(updateNotifier);
17
+ const mockedIsInstalledGloballyWithNPM = vi.mocked(isInstalledGloballyWithNPM);
18
+ describe('lib/cliUpgradeUtils', () => {
19
+ beforeEach(() => {
20
+ vi.clearAllMocks();
21
+ });
22
+ describe('isCliGloballyInstalled()', () => {
23
+ it('should return true when hs is globally installed', async () => {
24
+ mockedIsGloballyInstalled.mockResolvedValueOnce(true);
25
+ const result = await isCliGloballyInstalled();
26
+ expect(result).toBe(true);
27
+ expect(mockedIsGloballyInstalled).toHaveBeenCalledTimes(1);
28
+ expect(mockedIsGloballyInstalled).toHaveBeenCalledWith('hs');
29
+ });
30
+ it('should return false when hs is not globally installed', async () => {
31
+ mockedIsGloballyInstalled.mockResolvedValueOnce(false);
32
+ const result = await isCliGloballyInstalled();
33
+ expect(result).toBe(false);
34
+ expect(mockedIsGloballyInstalled).toHaveBeenCalledTimes(1);
35
+ expect(mockedIsGloballyInstalled).toHaveBeenCalledWith('hs');
36
+ });
37
+ });
38
+ describe('canCliBeAutoUpgraded()', () => {
39
+ it('should return true when package is installed globally via npm', async () => {
40
+ mockedIsInstalledGloballyWithNPM.mockResolvedValueOnce(true);
41
+ const result = await canCliBeAutoUpgraded();
42
+ expect(result).toBe(true);
43
+ expect(mockedIsInstalledGloballyWithNPM).toHaveBeenCalledTimes(1);
44
+ expect(mockedIsInstalledGloballyWithNPM).toHaveBeenCalledWith(pkg.name);
45
+ });
46
+ it('should return false when package is not installed globally via npm', async () => {
47
+ mockedIsInstalledGloballyWithNPM.mockResolvedValueOnce(false);
48
+ const result = await canCliBeAutoUpgraded();
49
+ expect(result).toBe(false);
50
+ expect(mockedIsInstalledGloballyWithNPM).toHaveBeenCalledTimes(1);
51
+ expect(mockedIsInstalledGloballyWithNPM).toHaveBeenCalledWith(pkg.name);
52
+ });
53
+ });
54
+ describe('getLatestCliVersion()', () => {
55
+ it('should return the latest CLI version', async () => {
56
+ const latest = '7.12.0';
57
+ const next = '7.12.0-beta.1';
58
+ mockedGetLatestPackageVersion.mockResolvedValueOnce({ latest, next });
59
+ const result = await getLatestCliVersion();
60
+ expect(result).toEqual({ latest, next });
61
+ expect(mockedGetLatestPackageVersion).toHaveBeenCalledTimes(1);
62
+ expect(mockedGetLatestPackageVersion).toHaveBeenCalledWith(pkg.name);
63
+ });
64
+ it('should throw errors from getLatestPackageVersion', async () => {
65
+ const errorMessage = 'Failed to get version';
66
+ mockedGetLatestPackageVersion.mockRejectedValueOnce(new Error(errorMessage));
67
+ await expect(getLatestCliVersion()).rejects.toThrow(errorMessage);
68
+ expect(mockedGetLatestPackageVersion).toHaveBeenCalledWith(pkg.name);
69
+ });
70
+ });
71
+ describe('getCliUpgradeInfo()', () => {
72
+ it('should return upgrade info when update is available', () => {
73
+ const mockNotifier = {
74
+ update: {
75
+ current: '7.11.2',
76
+ latest: '7.12.0',
77
+ type: 'minor',
78
+ },
79
+ };
80
+ mockedUpdateNotifier.mockReturnValue(mockNotifier);
81
+ const result = getCliUpgradeInfo();
82
+ expect(result).toMatchObject({
83
+ current: '7.11.2',
84
+ latest: '7.12.0',
85
+ type: 'minor',
86
+ });
87
+ expect(mockedUpdateNotifier).toHaveBeenCalledWith({
88
+ pkg,
89
+ distTag: 'latest',
90
+ shouldNotifyInNpmScript: true,
91
+ });
92
+ });
93
+ it('should return cached info on subsequent calls', () => {
94
+ const mockNotifier = {
95
+ update: {
96
+ current: '7.11.2',
97
+ latest: '7.12.0',
98
+ type: 'minor',
99
+ },
100
+ };
101
+ mockedUpdateNotifier.mockReturnValue(mockNotifier);
102
+ const firstCall = getCliUpgradeInfo();
103
+ const secondCall = getCliUpgradeInfo();
104
+ expect(firstCall).toEqual(secondCall);
105
+ expect(firstCall.current).toBe('7.11.2');
106
+ expect(firstCall.latest).toBe('7.12.0');
107
+ expect(firstCall.type).toBe('minor');
108
+ });
109
+ });
110
+ describe('installCliVersion()', () => {
111
+ it('should install latest version by default', async () => {
112
+ mockedExecuteInstall.mockResolvedValueOnce(undefined);
113
+ await installCliVersion();
114
+ expect(mockedExecuteInstall).toHaveBeenCalledTimes(1);
115
+ expect(mockedExecuteInstall).toHaveBeenCalledWith([`${pkg.name}@latest`], '-g');
116
+ });
117
+ it('should install a specific version when provided', async () => {
118
+ const version = '7.12.0';
119
+ mockedExecuteInstall.mockResolvedValueOnce(undefined);
120
+ await installCliVersion(version);
121
+ expect(mockedExecuteInstall).toHaveBeenCalledTimes(1);
122
+ expect(mockedExecuteInstall).toHaveBeenCalledWith([`${pkg.name}@${version}`], '-g');
123
+ });
124
+ it('should throw errors from executeInstall', async () => {
125
+ const errorMessage = 'Installation failed';
126
+ mockedExecuteInstall.mockRejectedValueOnce(new Error(errorMessage));
127
+ await expect(installCliVersion()).rejects.toThrow(errorMessage);
128
+ expect(mockedExecuteInstall).toHaveBeenCalledWith([`${pkg.name}@latest`], '-g');
129
+ });
130
+ });
131
+ });
@@ -11,7 +11,6 @@ function buildArguments(args) {
11
11
  };
12
12
  }
13
13
  vi.mock('@hubspot/local-dev-lib/config');
14
- vi.mock('../../ui/logger.js');
15
14
  describe('lib/commonOpts', () => {
16
15
  describe('getCmsPublishMode()', () => {
17
16
  const accounts = {