@hubspot/cli 7.8.0-experimental.0 → 7.8.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 (357) hide show
  1. package/bin/cli.js +31 -27
  2. package/commands/__tests__/auth.test.js +5 -0
  3. package/commands/__tests__/doctor.test.js +16 -16
  4. package/commands/__tests__/getStarted.test.js +2 -2
  5. package/commands/__tests__/mcp.test.js +1 -1
  6. package/commands/__tests__/project.test.js +2 -3
  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 -6
  18. package/commands/app/migrate.js +13 -19
  19. package/commands/app/secret/add.js +2 -1
  20. package/commands/app/secret/delete.js +2 -1
  21. package/commands/app/secret/list.js +2 -1
  22. package/commands/app/secret/update.js +2 -1
  23. package/commands/app/secret.js +2 -1
  24. package/commands/app.js +2 -2
  25. package/commands/auth.d.ts +1 -0
  26. package/commands/auth.js +17 -7
  27. package/commands/cms/convertFields.js +7 -9
  28. package/commands/cms/getReactModule.js +9 -14
  29. package/commands/cms/lighthouseScore.js +33 -36
  30. package/commands/cms.js +2 -2
  31. package/commands/completion.js +3 -3
  32. package/commands/config/set.d.ts +1 -1
  33. package/commands/config/set.js +64 -37
  34. package/commands/config.js +2 -2
  35. package/commands/create.js +2 -2
  36. package/commands/customObject/create.js +10 -12
  37. package/commands/customObject/schema/create.js +9 -11
  38. package/commands/customObject/schema/delete.js +16 -16
  39. package/commands/customObject/schema/fetch-all.js +12 -11
  40. package/commands/customObject/schema/fetch.js +15 -15
  41. package/commands/customObject/schema/list.js +4 -4
  42. package/commands/customObject/schema/update.js +13 -13
  43. package/commands/customObject/schema.js +2 -2
  44. package/commands/customObject.js +6 -7
  45. package/commands/doctor.js +8 -11
  46. package/commands/feedback.js +8 -13
  47. package/commands/fetch.js +8 -8
  48. package/commands/filemanager/fetch.js +7 -7
  49. package/commands/filemanager/upload.js +15 -34
  50. package/commands/filemanager.js +2 -2
  51. package/commands/function/deploy.js +11 -29
  52. package/commands/function/list.js +8 -8
  53. package/commands/function/server.js +9 -11
  54. package/commands/function.d.ts +1 -1
  55. package/commands/function.js +2 -2
  56. package/commands/getStarted.d.ts +1 -3
  57. package/commands/getStarted.js +68 -20
  58. package/commands/hubdb/clear.js +7 -15
  59. package/commands/hubdb/create.js +9 -15
  60. package/commands/hubdb/delete.js +8 -15
  61. package/commands/hubdb/fetch.js +6 -9
  62. package/commands/hubdb.d.ts +1 -1
  63. package/commands/hubdb.js +2 -2
  64. package/commands/init.js +2 -3
  65. package/commands/lint.js +16 -16
  66. package/commands/list.js +8 -14
  67. package/commands/logs.js +14 -20
  68. package/commands/mcp/__tests__/setup.test.js +2 -2
  69. package/commands/mcp/setup.js +11 -2
  70. package/commands/mcp.js +3 -3
  71. package/commands/mv.js +6 -17
  72. package/commands/open.js +5 -5
  73. package/commands/project/__tests__/add.test.js +15 -13
  74. package/commands/project/__tests__/create.test.js +6 -6
  75. package/commands/project/__tests__/deploy.test.js +3 -7
  76. package/commands/project/__tests__/devUnifiedFlow.test.js +2 -4
  77. package/commands/project/__tests__/installDeps.test.js +8 -8
  78. package/commands/project/__tests__/list.test.js +31 -0
  79. package/commands/project/__tests__/logs.test.js +1 -4
  80. package/commands/project/__tests__/migrate.test.js +7 -7
  81. package/commands/project/__tests__/migrateApp.test.js +3 -7
  82. package/commands/project/__tests__/profile.test.js +1 -1
  83. package/commands/project/__tests__/validate.test.js +98 -0
  84. package/commands/project/add.d.ts +2 -2
  85. package/commands/project/add.js +7 -10
  86. package/commands/project/cloneApp.js +14 -19
  87. package/commands/project/create.js +4 -11
  88. package/commands/project/deploy.js +5 -5
  89. package/commands/project/dev/deprecatedFlow.js +9 -18
  90. package/commands/project/dev/index.js +21 -18
  91. package/commands/project/dev/unifiedFlow.js +15 -8
  92. package/commands/project/download.js +15 -16
  93. package/commands/project/installDeps.d.ts +2 -2
  94. package/commands/project/installDeps.js +9 -9
  95. package/commands/project/list.d.ts +4 -0
  96. package/commands/project/list.js +62 -0
  97. package/commands/project/listBuilds.js +12 -21
  98. package/commands/project/logs.js +21 -24
  99. package/commands/project/migrate.js +33 -12
  100. package/commands/project/migrateApp.js +10 -17
  101. package/commands/project/open.js +6 -14
  102. package/commands/project/profile/add.js +3 -3
  103. package/commands/project/profile/delete.js +1 -2
  104. package/commands/project/profile.js +2 -3
  105. package/commands/project/upload.js +16 -25
  106. package/commands/project/validate.js +7 -7
  107. package/commands/project/watch.js +13 -22
  108. package/commands/project.js +4 -3
  109. package/commands/sandbox/__tests__/create.test.js +5 -5
  110. package/commands/sandbox/create.js +22 -32
  111. package/commands/sandbox/delete.js +39 -64
  112. package/commands/sandbox.js +2 -2
  113. package/commands/secret/addSecret.js +7 -17
  114. package/commands/secret/deleteSecret.js +10 -20
  115. package/commands/secret/listSecret.js +8 -10
  116. package/commands/secret/updateSecret.js +9 -17
  117. package/commands/secret.js +2 -2
  118. package/commands/testAccount/__tests__/delete.test.js +2 -4
  119. package/commands/testAccount/create.js +2 -2
  120. package/commands/testAccount/delete.d.ts +4 -3
  121. package/commands/testAccount/delete.js +155 -14
  122. package/commands/testAccount/importData.d.ts +1 -1
  123. package/commands/testAccount/importData.js +1 -1
  124. package/commands/testAccount.js +1 -1
  125. package/commands/theme/preview.js +1 -4
  126. package/lang/en.d.ts +365 -111
  127. package/lang/en.js +409 -158
  128. package/lang/en.lyaml +4 -4
  129. package/lib/__tests__/buildAccount.test.js +4 -3
  130. package/lib/__tests__/commonOpts.test.js +1 -1
  131. package/lib/__tests__/dependencyManagement.test.js +1 -1
  132. package/lib/__tests__/developerTestAccounts.test.js +3 -3
  133. package/lib/__tests__/hasFeature.test.js +145 -7
  134. package/lib/__tests__/npm.test.js +1 -1
  135. package/lib/__tests__/oauth.test.js +4 -4
  136. package/lib/__tests__/process.test.js +10 -5
  137. package/lib/__tests__/sandboxSync.test.js +8 -8
  138. package/lib/__tests__/sandboxes.test.js +8 -8
  139. package/lib/__tests__/serverlessLogs.test.js +1 -1
  140. package/lib/__tests__/usageTracking.test.js +5 -5
  141. package/lib/__tests__/validation.test.js +2 -1
  142. package/lib/__tests__/yargsUtils.test.js +83 -9
  143. package/lib/app/__tests__/migrate.test.js +19 -56
  144. package/lib/app/__tests__/migrate_legacy.test.js +1 -1
  145. package/lib/app/migrate.d.ts +2 -8
  146. package/lib/app/migrate.js +6 -81
  147. package/lib/app/migrate_legacy.js +20 -24
  148. package/lib/buildAccount.d.ts +2 -2
  149. package/lib/buildAccount.js +32 -64
  150. package/lib/commonOpts.d.ts +1 -1
  151. package/lib/commonOpts.js +25 -22
  152. package/lib/configMigrate.js +88 -9
  153. package/lib/configOptions.js +7 -0
  154. package/lib/constants.d.ts +22 -1
  155. package/lib/constants.js +26 -1
  156. package/lib/dependencyManagement.d.ts +0 -5
  157. package/lib/dependencyManagement.js +9 -36
  158. package/lib/developerTestAccounts.js +9 -23
  159. package/lib/doctor/Diagnosis.js +11 -23
  160. package/lib/doctor/DiagnosticInfoBuilder.js +12 -11
  161. package/lib/doctor/Doctor.js +42 -90
  162. package/lib/doctor/__tests__/Doctor.test.js +4 -4
  163. package/lib/errorHandlers/index.js +12 -20
  164. package/lib/errorHandlers/suppressError.js +11 -18
  165. package/lib/hasFeature.js +6 -0
  166. package/lib/lang.js +6 -5
  167. package/lib/links.d.ts +1 -0
  168. package/lib/links.js +14 -7
  169. package/lib/mcp/setup.js +1 -1
  170. package/lib/middleware/__test__/commandTargetingUtils.test.js +99 -0
  171. package/lib/middleware/__test__/configMiddleware.test.js +11 -11
  172. package/lib/middleware/__test__/yargsChecksMiddleware.test.js +6 -8
  173. package/lib/middleware/commandTargetingUtils.d.ts +8 -0
  174. package/lib/middleware/commandTargetingUtils.js +74 -0
  175. package/lib/middleware/configMiddleware.d.ts +1 -1
  176. package/lib/middleware/configMiddleware.js +21 -81
  177. package/lib/middleware/fireAlarmMiddleware.js +15 -5
  178. package/lib/middleware/gitMiddleware.js +5 -1
  179. package/lib/middleware/notificationsMiddleware.js +5 -11
  180. package/lib/middleware/yargsChecksMiddleware.js +6 -9
  181. package/lib/npm.js +2 -2
  182. package/lib/oauth.js +5 -5
  183. package/lib/process.js +5 -4
  184. package/lib/projects/__tests__/AppDevModeInterface.test.js +87 -90
  185. package/lib/projects/__tests__/LocalDevProcess.test.js +231 -19
  186. package/lib/projects/__tests__/LocalDevWebsocketServer.test.js +89 -63
  187. package/lib/projects/__tests__/deploy.test.js +73 -8
  188. package/lib/projects/__tests__/localDevProjectHelpers.test.js +6 -2
  189. package/lib/projects/__tests__/platformVersion.test.js +8 -8
  190. package/lib/projects/__tests__/projects.test.js +12 -12
  191. package/lib/projects/__tests__/structure.test.js +3 -3
  192. package/lib/projects/__tests__/upload.test.d.ts +1 -0
  193. package/lib/projects/__tests__/upload.test.js +82 -0
  194. package/lib/projects/add/__tests__/legacyAddComponent.test.js +6 -6
  195. package/lib/projects/add/__tests__/v2AddComponent.test.d.ts +1 -0
  196. package/lib/projects/add/__tests__/{v3AddComponent.test.js → v2AddComponent.test.js} +39 -39
  197. package/lib/projects/add/{v3AddComponent.d.ts → v2AddComponent.d.ts} +1 -1
  198. package/lib/projects/add/{v3AddComponent.js → v2AddComponent.js} +5 -5
  199. package/lib/projects/create/__tests__/legacy.test.js +5 -5
  200. package/lib/projects/create/__tests__/v2.test.d.ts +1 -0
  201. package/lib/projects/create/__tests__/{v3.test.js → v2.test.js} +82 -7
  202. package/lib/projects/create/index.js +4 -4
  203. package/lib/projects/create/legacy.js +2 -2
  204. package/lib/projects/create/{v3.d.ts → v2.d.ts} +3 -3
  205. package/lib/projects/create/{v3.js → v2.js} +16 -13
  206. package/lib/projects/deploy.d.ts +1 -1
  207. package/lib/projects/deploy.js +2 -2
  208. package/lib/projects/localDev/AppDevModeInterface.d.ts +10 -1
  209. package/lib/projects/localDev/AppDevModeInterface.js +118 -89
  210. package/lib/projects/localDev/DevServerManager.d.ts +11 -29
  211. package/lib/projects/localDev/DevServerManager.js +19 -61
  212. package/lib/projects/localDev/DevServerManager_DEPRECATED.d.ts +40 -0
  213. package/lib/projects/localDev/DevServerManager_DEPRECATED.js +120 -0
  214. package/lib/projects/localDev/LocalDevLogger.d.ts +4 -0
  215. package/lib/projects/localDev/LocalDevLogger.js +27 -6
  216. package/lib/projects/localDev/{LocalDevManager.js → LocalDevManager_DEPRECATED.js} +10 -11
  217. package/lib/projects/localDev/LocalDevProcess.d.ts +7 -5
  218. package/lib/projects/localDev/LocalDevProcess.js +93 -21
  219. package/lib/projects/localDev/LocalDevState.d.ts +12 -8
  220. package/lib/projects/localDev/LocalDevState.js +27 -17
  221. package/lib/projects/localDev/LocalDevWebsocketServer.d.ts +6 -1
  222. package/lib/projects/localDev/LocalDevWebsocketServer.js +94 -33
  223. package/lib/projects/localDev/helpers/account.d.ts +1 -1
  224. package/lib/projects/localDev/helpers/account.js +2 -2
  225. package/lib/projects/localDev/helpers/project.d.ts +3 -2
  226. package/lib/projects/localDev/helpers/project.js +49 -10
  227. package/lib/projects/localDev/localDevWebsocketServerUtils.d.ts +7 -0
  228. package/lib/projects/localDev/localDevWebsocketServerUtils.js +19 -0
  229. package/lib/projects/platformVersion.d.ts +1 -1
  230. package/lib/projects/platformVersion.js +1 -1
  231. package/lib/projects/pollProjectBuildAndDeploy.js +4 -4
  232. package/lib/projects/structure.js +6 -6
  233. package/lib/projects/upload.d.ts +1 -1
  234. package/lib/projects/upload.js +17 -8
  235. package/lib/projects/urls.d.ts +0 -1
  236. package/lib/projects/urls.js +0 -3
  237. package/lib/prompts/__tests__/downloadProjectPrompt.test.js +1 -0
  238. package/lib/prompts/__tests__/projectAddPrompt.test.js +10 -10
  239. package/lib/prompts/accountNamePrompt.js +14 -19
  240. package/lib/prompts/accountsPrompt.js +2 -2
  241. package/lib/prompts/cmsFieldPrompt.js +2 -2
  242. package/lib/prompts/createApiSamplePrompt.js +5 -5
  243. package/lib/prompts/createDeveloperTestAccountConfigPrompt.js +10 -1
  244. package/lib/prompts/createFunctionPrompt.js +14 -14
  245. package/lib/prompts/createModulePrompt.js +9 -9
  246. package/lib/prompts/createTemplatePrompt.js +2 -2
  247. package/lib/prompts/downloadProjectPrompt.js +5 -8
  248. package/lib/prompts/installAppPrompt.d.ts +1 -6
  249. package/lib/prompts/installAppPrompt.js +1 -6
  250. package/lib/prompts/personalAccessKeyPrompt.js +3 -3
  251. package/lib/prompts/previewPrompt.js +6 -6
  252. package/lib/prompts/projectAddPrompt.d.ts +2 -2
  253. package/lib/prompts/projectAddPrompt.js +9 -2
  254. package/lib/prompts/projectDevTargetAccountPrompt.js +20 -32
  255. package/lib/prompts/projectNamePrompt.js +4 -8
  256. package/lib/prompts/projectsLogsPrompt.js +2 -4
  257. package/lib/prompts/promptUtils.js +30 -9
  258. package/lib/prompts/sandboxesPrompt.js +7 -7
  259. package/lib/prompts/secretPrompt.js +3 -3
  260. package/lib/prompts/selectAppPrompt.js +3 -3
  261. package/lib/prompts/selectHubDBTablePrompt.js +9 -13
  262. package/lib/prompts/selectProjectTemplatePrompt.js +2 -0
  263. package/lib/prompts/selectPublicAppForMigrationPrompt.js +15 -19
  264. package/lib/prompts/setAsDefaultAccountPrompt.js +4 -8
  265. package/lib/prompts/uploadPrompt.js +5 -5
  266. package/lib/sandboxSync.js +24 -41
  267. package/lib/sandboxes.js +19 -47
  268. package/lib/schema.js +3 -3
  269. package/lib/serverlessLogs.js +11 -13
  270. package/lib/theme/__tests__/migrate.test.d.ts +1 -0
  271. package/lib/theme/__tests__/migrate.test.js +233 -0
  272. package/lib/theme/migrate.d.ts +13 -0
  273. package/lib/theme/migrate.js +90 -0
  274. package/lib/ui/SpinniesManager.d.ts +2 -0
  275. package/lib/ui/SpinniesManager.js +112 -8
  276. package/lib/ui/boxen.js +1 -2
  277. package/lib/ui/git.js +13 -10
  278. package/lib/ui/index.d.ts +4 -0
  279. package/lib/ui/index.js +47 -38
  280. package/lib/ui/serverlessFunctionLogs.js +9 -7
  281. package/lib/ui/uiMessages.d.ts +72 -0
  282. package/lib/ui/uiMessages.js +75 -0
  283. package/lib/usageTracking.js +8 -8
  284. package/lib/validation.js +20 -23
  285. package/lib/yargsUtils.d.ts +1 -1
  286. package/lib/yargsUtils.js +12 -5
  287. package/mcp-server/tools/cms/HsCreateFunctionTool.js +1 -1
  288. package/mcp-server/tools/cms/HsCreateModuleTool.d.ts +2 -2
  289. package/mcp-server/tools/cms/HsCreateModuleTool.js +1 -1
  290. package/mcp-server/tools/cms/HsCreateTemplateTool.js +1 -1
  291. package/mcp-server/tools/cms/HsFunctionLogsTool.js +2 -2
  292. package/mcp-server/tools/cms/HsListFunctionsTool.js +1 -1
  293. package/mcp-server/tools/cms/HsListTool.js +1 -1
  294. package/mcp-server/tools/cms/__tests__/HsCreateFunctionTool.test.js +1 -1
  295. package/mcp-server/tools/cms/__tests__/HsCreateModuleTool.test.js +1 -1
  296. package/mcp-server/tools/cms/__tests__/HsCreateTemplateTool.test.js +1 -1
  297. package/mcp-server/tools/cms/__tests__/HsFunctionLogsTool.test.js +2 -2
  298. package/mcp-server/tools/cms/__tests__/HsListFunctionsTool.test.js +1 -1
  299. package/mcp-server/tools/cms/__tests__/HsListTool.test.js +1 -1
  300. package/mcp-server/tools/index.js +4 -0
  301. package/mcp-server/tools/project/AddFeatureToProjectTool.d.ts +3 -3
  302. package/mcp-server/tools/project/AddFeatureToProjectTool.js +3 -3
  303. package/mcp-server/tools/project/CreateProjectTool.d.ts +3 -3
  304. package/mcp-server/tools/project/CreateProjectTool.js +5 -5
  305. package/mcp-server/tools/project/DeployProjectTool.js +1 -1
  306. package/mcp-server/tools/project/DocFetchTool.js +2 -2
  307. package/mcp-server/tools/project/DocsSearchTool.d.ts +4 -1
  308. package/mcp-server/tools/project/DocsSearchTool.js +7 -7
  309. package/mcp-server/tools/project/GetApiUsagePatternsByAppIdTool.d.ts +23 -0
  310. package/mcp-server/tools/project/GetApiUsagePatternsByAppIdTool.js +68 -0
  311. package/mcp-server/tools/project/GetApplicationInfoTool.d.ts +11 -0
  312. package/mcp-server/tools/project/GetApplicationInfoTool.js +49 -0
  313. package/mcp-server/tools/project/GetConfigValuesTool.d.ts +4 -1
  314. package/mcp-server/tools/project/GetConfigValuesTool.js +13 -7
  315. package/mcp-server/tools/project/GuidedWalkthroughTool.d.ts +2 -2
  316. package/mcp-server/tools/project/GuidedWalkthroughTool.js +1 -1
  317. package/mcp-server/tools/project/UploadProjectTools.js +2 -2
  318. package/mcp-server/tools/project/ValidateProjectTool.js +1 -1
  319. package/mcp-server/tools/project/__tests__/AddFeatureToProjectTool.test.js +1 -1
  320. package/mcp-server/tools/project/__tests__/CreateProjectTool.test.js +2 -2
  321. package/mcp-server/tools/project/__tests__/DeployProjectTool.test.js +1 -1
  322. package/mcp-server/tools/project/__tests__/DocFetchTool.test.js +2 -2
  323. package/mcp-server/tools/project/__tests__/DocsSearchTool.test.js +14 -12
  324. package/mcp-server/tools/project/__tests__/GetApiUsagePatternsByAppIdTool.test.d.ts +1 -0
  325. package/mcp-server/tools/project/__tests__/GetApiUsagePatternsByAppIdTool.test.js +169 -0
  326. package/mcp-server/tools/project/__tests__/GetApplicationInfoTool.test.d.ts +1 -0
  327. package/mcp-server/tools/project/__tests__/GetApplicationInfoTool.test.js +115 -0
  328. package/mcp-server/tools/project/__tests__/GetConfigValuesTool.test.js +9 -8
  329. package/mcp-server/tools/project/__tests__/GuidedWalkthroughTool.test.js +1 -1
  330. package/mcp-server/tools/project/__tests__/UploadProjectTools.test.js +1 -1
  331. package/mcp-server/tools/project/__tests__/ValidateProjectTool.test.js +1 -1
  332. package/mcp-server/tools/project/constants.d.ts +1 -1
  333. package/mcp-server/tools/project/constants.js +9 -3
  334. package/mcp-server/utils/__tests__/cliConfig.test.d.ts +1 -0
  335. package/mcp-server/utils/__tests__/cliConfig.test.js +110 -0
  336. package/mcp-server/utils/cliConfig.d.ts +1 -0
  337. package/mcp-server/utils/cliConfig.js +12 -0
  338. package/mcp-server/utils/toolUsageTracking.js +2 -2
  339. package/package.json +8 -12
  340. package/types/LocalDev.d.ts +19 -3
  341. package/ui/components/HorizontalSelectPrompt.js +1 -1
  342. package/ui/index.js +1 -1
  343. package/commands/getStartedV2.d.ts +0 -9
  344. package/commands/getStartedV2.js +0 -39
  345. package/lib/middleware/__test__/utils.test.js +0 -51
  346. package/lib/middleware/utils.d.ts +0 -8
  347. package/lib/middleware/utils.js +0 -14
  348. package/lib/projects/localDev/DevServerManagerV2.d.ts +0 -22
  349. package/lib/projects/localDev/DevServerManagerV2.js +0 -81
  350. package/ui/components/Ascii.d.ts +0 -10
  351. package/ui/components/Ascii.js +0 -11
  352. package/ui/views/GetStarted.d.ts +0 -7
  353. package/ui/views/GetStarted.js +0 -157
  354. /package/{lib/middleware/__test__/utils.test.d.ts → commands/project/__tests__/list.test.d.ts} +0 -0
  355. /package/{lib/projects/add/__tests__/v3AddComponent.test.d.ts → commands/project/__tests__/validate.test.d.ts} +0 -0
  356. /package/lib/{projects/create/__tests__/v3.test.d.ts → middleware/__test__/commandTargetingUtils.test.d.ts} +0 -0
  357. /package/lib/projects/localDev/{LocalDevManager.d.ts → LocalDevManager_DEPRECATED.d.ts} +0 -0
@@ -1,12 +1,12 @@
1
1
  import yargs from 'yargs';
2
- import { addAccountOptions, addConfigOptions, addUseEnvironmentOptions, addTestingOptions, } from '../../../lib/commonOpts.js';
2
+ import { addConfigOptions, addUseEnvironmentOptions, addTestingOptions, } from '../../../lib/commonOpts.js';
3
3
  import testAccountDeleteCommand from '../delete.js';
4
4
  vi.mock('../../../lib/commonOpts');
5
5
  describe('commands/testAccount/delete', () => {
6
6
  const yargsMock = yargs;
7
7
  describe('command', () => {
8
8
  it('should have the correct command structure', () => {
9
- expect(testAccountDeleteCommand.command).toEqual('delete <test-account-id>');
9
+ expect(testAccountDeleteCommand.command).toEqual('delete [test-account]');
10
10
  });
11
11
  });
12
12
  describe('describe', () => {
@@ -20,8 +20,6 @@ describe('commands/testAccount/delete', () => {
20
20
  expect(yargsMock.example).toHaveBeenCalledTimes(1);
21
21
  expect(addTestingOptions).toHaveBeenCalledTimes(1);
22
22
  expect(addTestingOptions).toHaveBeenCalledWith(yargsMock);
23
- expect(addAccountOptions).toHaveBeenCalledTimes(1);
24
- expect(addAccountOptions).toHaveBeenCalledWith(yargsMock);
25
23
  expect(addConfigOptions).toHaveBeenCalledTimes(1);
26
24
  expect(addConfigOptions).toHaveBeenCalledWith(yargsMock);
27
25
  expect(addUseEnvironmentOptions).toHaveBeenCalledTimes(1);
@@ -13,7 +13,7 @@ import { commands } from '../../lang/en.js';
13
13
  import { createDeveloperTestAccountConfigPrompt } from '../../lib/prompts/createDeveloperTestAccountConfigPrompt.js';
14
14
  import { debugError, logError } from '../../lib/errorHandlers/index.js';
15
15
  import SpinniesManager from '../../lib/ui/SpinniesManager.js';
16
- import { createDeveloperTestAccountV3, saveAccountToConfig, } from '../../lib/buildAccount.js';
16
+ import { createDeveloperTestAccountV2, saveAccountToConfig, } from '../../lib/buildAccount.js';
17
17
  const command = 'create';
18
18
  const describe = commands.testAccount.create.describe;
19
19
  async function handler(args) {
@@ -69,7 +69,7 @@ async function handler(args) {
69
69
  text: commands.testAccount.create.polling.start(testAccountConfig.accountName),
70
70
  });
71
71
  try {
72
- const createResult = await createDeveloperTestAccountV3(derivedAccountId, testAccountConfig);
72
+ const createResult = await createDeveloperTestAccountV2(derivedAccountId, testAccountConfig);
73
73
  resultJson.accountName = createResult.accountName;
74
74
  resultJson.accountId = createResult.accountId;
75
75
  resultJson.personalAccessKey = createResult.personalAccessKey;
@@ -1,6 +1,7 @@
1
- import { CommonArgs, ConfigArgs, AccountArgs, EnvironmentArgs, TestingArgs, YargsCommandModule } from '../../types/Yargs.js';
2
- type DeleteTestAccountArgs = CommonArgs & AccountArgs & ConfigArgs & TestingArgs & EnvironmentArgs & {
3
- testAccountId: number;
1
+ import { CommonArgs, ConfigArgs, EnvironmentArgs, TestingArgs, YargsCommandModule } from '../../types/Yargs.js';
2
+ type DeleteTestAccountArgs = CommonArgs & ConfigArgs & TestingArgs & EnvironmentArgs & {
3
+ testAccount?: string | number;
4
+ force?: boolean;
4
5
  };
5
6
  declare const deleteTestAccountCommand: YargsCommandModule<unknown, DeleteTestAccountArgs>;
6
7
  export default deleteTestAccountCommand;
@@ -1,39 +1,180 @@
1
- import { deleteDeveloperTestAccount } from '@hubspot/local-dev-lib/api/developerTestAccounts';
1
+ import { fetchDeveloperTestAccounts, deleteDeveloperTestAccount, } from '@hubspot/local-dev-lib/api/developerTestAccounts';
2
2
  import { makeYargsBuilder } from '../../lib/yargsUtils.js';
3
3
  import { EXIT_CODES } from '../../lib/enums/exitCodes.js';
4
4
  import { uiLogger } from '../../lib/ui/logger.js';
5
5
  import { trackCommandUsage } from '../../lib/usageTracking.js';
6
6
  import { commands } from '../../lang/en.js';
7
- const command = 'delete <test-account-id>';
7
+ import { deleteAccount, getAccountConfig, getAccountId, getConfigPath, loadConfig, updateDefaultAccount, } from '@hubspot/local-dev-lib/config';
8
+ import { promptUser } from '../../lib/prompts/promptUtils.js';
9
+ import { debugError } from '../../lib/errorHandlers/index.js';
10
+ const command = 'delete [test-account]';
8
11
  const describe = commands.testAccount.delete.describe;
9
- async function handler(args) {
10
- const { derivedAccountId, testAccountId } = args;
11
- trackCommandUsage('test-account-delete', {}, derivedAccountId);
12
+ async function getAccountPromptOptions(derivedAccountId) {
12
13
  try {
13
- await deleteDeveloperTestAccount(derivedAccountId, testAccountId, true);
14
- uiLogger.success(commands.testAccount.delete.success.testAccountDeleted(testAccountId));
14
+ const { data } = await fetchDeveloperTestAccounts(derivedAccountId);
15
+ return data.results.map(testAccount => ({
16
+ name: `${testAccount.accountName} (${testAccount.id})`,
17
+ value: testAccount.id,
18
+ }));
15
19
  }
16
20
  catch (err) {
17
- uiLogger.error(commands.testAccount.delete.errors.failedToDelete);
21
+ uiLogger.error(commands.testAccount.delete.errors.failedToFetchTestAccounts);
22
+ throw err;
23
+ }
24
+ }
25
+ async function accountToDeleteSelectionPrompt(derivedAccountId) {
26
+ const accountData = await getAccountPromptOptions(derivedAccountId);
27
+ if (accountData.length === 0) {
28
+ uiLogger.error(commands.testAccount.delete.errors.noAccountsToDelete(derivedAccountId));
29
+ process.exit(EXIT_CODES.ERROR);
30
+ }
31
+ const { testAccountToDelete } = await promptUser([
32
+ {
33
+ type: 'list',
34
+ name: 'testAccountToDelete',
35
+ pageSize: 20,
36
+ message: commands.testAccount.delete.prompts.selectTestAccounts,
37
+ choices: accountData,
38
+ },
39
+ ]);
40
+ return testAccountToDelete;
41
+ }
42
+ async function confirmDeletion() {
43
+ const { shouldDelete } = await promptUser([
44
+ {
45
+ type: 'confirm',
46
+ name: 'shouldDelete',
47
+ message: commands.testAccount.delete.prompts.confirmDeletion,
48
+ },
49
+ ]);
50
+ return shouldDelete;
51
+ }
52
+ async function deleteTestAccountInHubSpot(derivedAccountId, accountId) {
53
+ try {
54
+ await deleteDeveloperTestAccount(derivedAccountId, accountId, true);
55
+ uiLogger.success(commands.testAccount.delete.success.testAccountDeletedFromHubSpot(accountId));
56
+ }
57
+ catch (e) {
58
+ debugError(e);
59
+ uiLogger.error(commands.testAccount.delete.errors.failedToDelete(accountId));
60
+ }
61
+ }
62
+ async function deleteTestAccountFromConfig(testAccountId, parentAccountName, account) {
63
+ try {
64
+ // If the account isn't in the local config then it wasn't auth'd on the local machine
65
+ if (account && account.name && account.accountType) {
66
+ // If the deleted test account was the default account, replace the default account with the parent account
67
+ loadConfig(getConfigPath()); // Get updated version of the config
68
+ const defaultAccountId = getAccountId(); // We need to get the current default accountId before delete the test account
69
+ await deleteAccount(account.name);
70
+ uiLogger.success(commands.testAccount.delete.success.testAccountDeletedFromConfig(testAccountId));
71
+ if (testAccountId === defaultAccountId) {
72
+ updateDefaultAccount(parentAccountName);
73
+ uiLogger.info(commands.testAccount.delete.info.replaceDefaultAccount(testAccountId, parentAccountName));
74
+ }
75
+ }
76
+ }
77
+ catch (e) {
78
+ debugError(e);
79
+ uiLogger.error(commands.testAccount.delete.errors.failedToDeleteFromConfig(testAccountId));
80
+ }
81
+ }
82
+ async function validateTestAccountConfigs(testAccountId) {
83
+ if (!testAccountId) {
84
+ uiLogger.error(commands.testAccount.delete.errors.testAccountNotFound(testAccountId));
85
+ process.exit(EXIT_CODES.ERROR);
86
+ }
87
+ const testAccountConfig = getAccountConfig(testAccountId);
88
+ if (!testAccountConfig) {
89
+ uiLogger.error(commands.testAccount.delete.errors.testAccountNotFound(testAccountId));
18
90
  process.exit(EXIT_CODES.ERROR);
19
91
  }
92
+ const parentAccountConfig = getAccountConfig(testAccountConfig.parentAccountId);
93
+ if (!parentAccountConfig) {
94
+ uiLogger.error(commands.testAccount.delete.errors.parentAccountNotFound(testAccountId));
95
+ process.exit(EXIT_CODES.ERROR);
96
+ }
97
+ const parentAccountName = parentAccountConfig.name;
98
+ return { testAccountConfig, parentAccountName };
99
+ }
100
+ async function handler(args) {
101
+ const { derivedAccountId, testAccount, force } = args;
102
+ trackCommandUsage('test-account-delete', {}, derivedAccountId);
103
+ let testAccountIdToDelete = 0;
104
+ // See if the account exists
105
+ if (testAccount) {
106
+ const accountId = getAccountId(testAccount);
107
+ await validateTestAccountConfigs(accountId);
108
+ if (accountId) {
109
+ testAccountIdToDelete = accountId;
110
+ }
111
+ }
112
+ // Prompt for selection when name or id aren't provided
113
+ if (!testAccountIdToDelete) {
114
+ try {
115
+ testAccountIdToDelete =
116
+ await accountToDeleteSelectionPrompt(derivedAccountId);
117
+ }
118
+ catch (err) {
119
+ debugError(err);
120
+ uiLogger.error(commands.testAccount.delete.errors.failedToSelectAccount);
121
+ process.exit(EXIT_CODES.ERROR);
122
+ }
123
+ }
124
+ const { testAccountConfig, parentAccountName } = await validateTestAccountConfigs(testAccountIdToDelete);
125
+ // If --force, don't prompt user; else confirm deletion
126
+ let shouldDeleteAccount;
127
+ if (force) {
128
+ shouldDeleteAccount = true;
129
+ }
130
+ else {
131
+ shouldDeleteAccount = await confirmDeletion();
132
+ }
133
+ if (shouldDeleteAccount) {
134
+ const parentAccountId = testAccountConfig.parentAccountId;
135
+ await deleteTestAccountInHubSpot(parentAccountId, testAccountIdToDelete);
136
+ await deleteTestAccountFromConfig(testAccountIdToDelete, parentAccountName, testAccountConfig);
137
+ }
138
+ else {
139
+ uiLogger.info(commands.testAccount.delete.info.deletionCanceled);
140
+ }
20
141
  process.exit(EXIT_CODES.SUCCESS);
21
142
  }
22
143
  function deleteTestAccountBuilder(yargs) {
23
- yargs.positional('test-account-id', {
24
- type: 'number',
25
- description: commands.testAccount.delete.positionals.testAccountId,
26
- required: true,
144
+ yargs.positional('test-account', {
145
+ type: 'string',
146
+ description: commands.testAccount.delete.options.id,
147
+ required: false,
148
+ });
149
+ yargs.option('force', {
150
+ describe: commands.upload.options.force,
151
+ type: 'boolean',
152
+ default: false,
27
153
  });
28
154
  yargs.example([
29
- ['$0 delete 1234567890', commands.testAccount.delete.example(1234567890)],
155
+ [
156
+ '$0 test-account delete 12345678',
157
+ commands.testAccount.delete.examples.withPositionalID(12345678),
158
+ ],
159
+ [
160
+ '$0 test-account delete my-test-account',
161
+ commands.testAccount.delete.examples.withPositionalName('my-test-account'),
162
+ ],
163
+ [
164
+ '$0 test-account delete --test-account=12345678',
165
+ commands.testAccount.delete.examples.withID(12345678),
166
+ ],
167
+ [
168
+ '$0 test-account delete --test-account=my-test-account',
169
+ commands.testAccount.delete.examples.withName('my-test-account'),
170
+ ],
171
+ ['$0 test-account delete', commands.testAccount.delete.examples.withoutId],
30
172
  ]);
31
173
  return yargs;
32
174
  }
33
175
  const builder = makeYargsBuilder(deleteTestAccountBuilder, command, describe, {
34
176
  useGlobalOptions: true,
35
177
  useEnvironmentOptions: true,
36
- useAccountOptions: true,
37
178
  useConfigOptions: true,
38
179
  useTestingOptions: true,
39
180
  });
@@ -1,6 +1,6 @@
1
1
  import { AccountArgs, CommonArgs, ConfigArgs, EnvironmentArgs, YargsCommandModule } from '../../types/Yargs.js';
2
2
  export declare const command = "import-data";
3
- export declare const describe: undefined;
3
+ export declare const describe: "Import data into the CRM";
4
4
  type CrmImportDataArgs = CommonArgs & ConfigArgs & AccountArgs & EnvironmentArgs & {
5
5
  filePath: string | undefined;
6
6
  skipConfirm: boolean | undefined;
@@ -8,7 +8,7 @@ import { handleImportData, handleTargetTestAccountSelectionFlow, } from '../../l
8
8
  import { confirmImportDataPrompt } from '../../lib/prompts/confirmImportDataPrompt.js';
9
9
  import { commands } from '../../lang/en.js';
10
10
  export const command = 'import-data';
11
- export const describe = undefined; // commands.testAccount.subcommands.importData.describe;
11
+ export const describe = commands.testAccount.subcommands.importData.describe;
12
12
  async function handler(args) {
13
13
  const { derivedAccountId, userProvidedAccount, filePath: providedFilePath, skipConfirm, } = args;
14
14
  trackCommandUsage('crm-import-data', {}, derivedAccountId);
@@ -5,7 +5,7 @@ import deleteTestAccountCommand from './testAccount/delete.js';
5
5
  import { makeYargsBuilder } from '../lib/yargsUtils.js';
6
6
  import { commands } from '../lang/en.js';
7
7
  const command = ['test-account', 'test-accounts'];
8
- const describe = undefined; //commands.testAccount.describe;
8
+ const describe = commands.testAccount.describe;
9
9
  function testAccountBuilder(yargs) {
10
10
  yargs
11
11
  .command(createTestAccountCommand)
@@ -15,8 +15,6 @@ import { handleExit, handleKeypress } from '../../lib/process.js';
15
15
  import { getProjectConfig } from '../../lib/projects/config.js';
16
16
  import { findProjectComponents } from '../../lib/projects/structure.js';
17
17
  import { ComponentTypes } from '../../types/Projects.js';
18
- import { hasFeature } from '../../lib/hasFeature.js';
19
- import { FEATURES } from '../../lib/constants.js';
20
18
  import { makeYargsBuilder } from '../../lib/yargsUtils.js';
21
19
  import { uiLogger } from '../../lib/ui/logger.js';
22
20
  const command = 'preview [--src] [--dest]';
@@ -150,8 +148,7 @@ async function handler(args) {
150
148
  catch (e) {
151
149
  uiLogger.warn('Unified dev server requires node 20 to run. Defaulting to legacy preview.');
152
150
  }
153
- const isUngatedForUnified = await hasFeature(derivedAccountId, FEATURES.UNIFIED_THEME_PREVIEW);
154
- if (isUngatedForUnified && createUnifiedDevServer) {
151
+ if (createUnifiedDevServer) {
155
152
  if (port) {
156
153
  process.env['PORT'] = port.toString();
157
154
  }