@hubspot/cli 7.5.11-experimental.0 → 7.6.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 (352) hide show
  1. package/bin/cli.js +102 -95
  2. package/commands/account/auth.d.ts +5 -7
  3. package/commands/account/auth.js +74 -87
  4. package/commands/account/clean.d.ts +3 -7
  5. package/commands/account/clean.js +16 -9
  6. package/commands/account/createOverride.d.ts +3 -7
  7. package/commands/account/createOverride.js +23 -6
  8. package/commands/account/info.d.ts +3 -7
  9. package/commands/account/info.js +13 -5
  10. package/commands/account/list.d.ts +3 -7
  11. package/commands/account/list.js +15 -8
  12. package/commands/account/remove.d.ts +3 -7
  13. package/commands/account/remove.js +21 -9
  14. package/commands/account/removeOverride.d.ts +3 -7
  15. package/commands/account/removeOverride.js +23 -6
  16. package/commands/account/rename.d.ts +3 -7
  17. package/commands/account/rename.js +16 -9
  18. package/commands/account/use.d.ts +5 -9
  19. package/commands/account/use.js +14 -6
  20. package/commands/account.d.ts +3 -4
  21. package/commands/account.js +33 -58
  22. package/commands/app/migrate.d.ts +1 -2
  23. package/commands/app/migrate.js +7 -8
  24. package/commands/app/secret/add.d.ts +7 -0
  25. package/commands/app/secret/add.js +64 -0
  26. package/commands/app/secret/delete.d.ts +8 -0
  27. package/commands/app/secret/delete.js +87 -0
  28. package/commands/app/secret/list.d.ts +6 -0
  29. package/commands/app/secret/list.js +64 -0
  30. package/commands/app/secret/update.d.ts +7 -0
  31. package/commands/app/secret/update.js +77 -0
  32. package/commands/app/secret.d.ts +3 -0
  33. package/commands/app/secret.js +30 -0
  34. package/commands/app.d.ts +2 -5
  35. package/commands/app.js +10 -8
  36. package/commands/auth.d.ts +5 -7
  37. package/commands/auth.js +29 -28
  38. package/commands/cms/convertFields.d.ts +7 -1
  39. package/commands/cms/convertFields.js +57 -41
  40. package/commands/cms/getReactModule.d.ts +7 -1
  41. package/commands/cms/getReactModule.js +52 -34
  42. package/commands/cms/lighthouseScore.d.ts +8 -1
  43. package/commands/cms/lighthouseScore.js +129 -100
  44. package/commands/cms.d.ts +3 -1
  45. package/commands/cms.js +22 -15
  46. package/commands/completion.d.ts +3 -1
  47. package/commands/completion.js +23 -12
  48. package/commands/config/migrate.d.ts +3 -7
  49. package/commands/config/migrate.js +37 -46
  50. package/commands/config/set.d.ts +5 -6
  51. package/commands/config/set.js +38 -14
  52. package/commands/config.d.ts +3 -4
  53. package/commands/config.js +18 -44
  54. package/commands/create/api-sample.d.ts +3 -1
  55. package/commands/create/api-sample.js +34 -38
  56. package/commands/create/app.d.ts +3 -1
  57. package/commands/create/app.js +9 -7
  58. package/commands/create/function.d.ts +3 -1
  59. package/commands/create/function.js +11 -10
  60. package/commands/create/index.d.ts +5 -1
  61. package/commands/create/index.js +23 -11
  62. package/commands/create/module.d.ts +3 -1
  63. package/commands/create/module.js +14 -13
  64. package/commands/create/react-app.d.ts +3 -1
  65. package/commands/create/react-app.js +10 -7
  66. package/commands/create/template.d.ts +3 -1
  67. package/commands/create/template.js +14 -14
  68. package/commands/create/vue-app.d.ts +3 -1
  69. package/commands/create/vue-app.js +10 -7
  70. package/commands/create/webpack-serverless.d.ts +3 -1
  71. package/commands/create/webpack-serverless.js +10 -7
  72. package/commands/create/website-theme.d.ts +3 -1
  73. package/commands/create/website-theme.js +10 -9
  74. package/commands/create.d.ts +4 -24
  75. package/commands/create.js +62 -74
  76. package/commands/customObject/create.d.ts +4 -9
  77. package/commands/customObject/create.js +17 -10
  78. package/commands/customObject/schema/create.d.ts +4 -9
  79. package/commands/customObject/schema/create.js +18 -11
  80. package/commands/customObject/schema/delete.d.ts +4 -9
  81. package/commands/customObject/schema/delete.js +17 -10
  82. package/commands/customObject/schema/fetch-all.d.ts +4 -9
  83. package/commands/customObject/schema/fetch-all.js +17 -10
  84. package/commands/customObject/schema/fetch.d.ts +4 -9
  85. package/commands/customObject/schema/fetch.js +17 -10
  86. package/commands/customObject/schema/list.d.ts +4 -8
  87. package/commands/customObject/schema/list.js +17 -10
  88. package/commands/customObject/schema/update.d.ts +4 -9
  89. package/commands/customObject/schema/update.js +18 -11
  90. package/commands/customObject/schema.d.ts +3 -5
  91. package/commands/customObject/schema.js +27 -54
  92. package/commands/customObject.d.ts +3 -4
  93. package/commands/customObject.js +18 -45
  94. package/commands/doctor.d.ts +6 -8
  95. package/commands/doctor.js +30 -21
  96. package/commands/feedback.d.ts +4 -1
  97. package/commands/feedback.js +38 -47
  98. package/commands/fetch.d.ts +12 -1
  99. package/commands/fetch.js +49 -33
  100. package/commands/filemanager/fetch.d.ts +4 -9
  101. package/commands/filemanager/fetch.js +18 -11
  102. package/commands/filemanager/upload.d.ts +4 -9
  103. package/commands/filemanager/upload.js +17 -11
  104. package/commands/filemanager.d.ts +3 -4
  105. package/commands/filemanager.js +18 -41
  106. package/commands/function/deploy.d.ts +6 -1
  107. package/commands/function/deploy.js +70 -50
  108. package/commands/function/list.d.ts +6 -1
  109. package/commands/function/list.js +44 -32
  110. package/commands/function/server.d.ts +10 -1
  111. package/commands/function/server.js +49 -38
  112. package/commands/function.d.ts +5 -1
  113. package/commands/function.js +22 -10
  114. package/commands/getStarted.d.ts +9 -0
  115. package/commands/getStarted.js +227 -0
  116. package/commands/hubdb/clear.d.ts +4 -9
  117. package/commands/hubdb/clear.js +17 -10
  118. package/commands/hubdb/create.d.ts +4 -9
  119. package/commands/hubdb/create.js +17 -10
  120. package/commands/hubdb/delete.d.ts +4 -9
  121. package/commands/hubdb/delete.js +17 -10
  122. package/commands/hubdb/fetch.d.ts +4 -9
  123. package/commands/hubdb/fetch.js +17 -10
  124. package/commands/hubdb/list.d.ts +4 -0
  125. package/commands/hubdb/list.js +83 -0
  126. package/commands/hubdb.d.ts +3 -2
  127. package/commands/hubdb.js +23 -45
  128. package/commands/init.d.ts +3 -7
  129. package/commands/init.js +17 -8
  130. package/commands/lint.d.ts +6 -4
  131. package/commands/lint.js +42 -43
  132. package/commands/list.d.ts +3 -7
  133. package/commands/list.js +17 -11
  134. package/commands/logs.d.ts +10 -1
  135. package/commands/logs.js +53 -44
  136. package/commands/mcp/setup.d.ts +7 -0
  137. package/commands/mcp/setup.js +52 -0
  138. package/commands/mcp/start.d.ts +3 -0
  139. package/commands/mcp/start.js +77 -0
  140. package/commands/mcp.d.ts +3 -0
  141. package/commands/mcp.js +26 -0
  142. package/commands/module/marketplace-validate.d.ts +6 -1
  143. package/commands/module/marketplace-validate.js +39 -29
  144. package/commands/module.d.ts +3 -1
  145. package/commands/module.js +23 -10
  146. package/commands/mv.d.ts +3 -7
  147. package/commands/mv.js +17 -11
  148. package/commands/open.d.ts +3 -7
  149. package/commands/open.js +17 -11
  150. package/commands/project/add.d.ts +5 -2
  151. package/commands/project/add.js +43 -80
  152. package/commands/project/cloneApp.d.ts +1 -1
  153. package/commands/project/cloneApp.js +2 -2
  154. package/commands/project/create.d.ts +2 -8
  155. package/commands/project/create.js +84 -55
  156. package/commands/project/deploy.d.ts +2 -0
  157. package/commands/project/deploy.js +67 -13
  158. package/commands/project/dev/deprecatedFlow.d.ts +8 -2
  159. package/commands/project/dev/deprecatedFlow.js +9 -1
  160. package/commands/project/dev/index.d.ts +1 -4
  161. package/commands/project/dev/index.js +88 -31
  162. package/commands/project/dev/unifiedFlow.d.ts +11 -2
  163. package/commands/project/dev/unifiedFlow.js +81 -41
  164. package/commands/project/listBuilds.js +2 -5
  165. package/commands/project/migrate.d.ts +1 -0
  166. package/commands/project/profile/add.d.ts +7 -0
  167. package/commands/project/profile/add.js +209 -0
  168. package/commands/project/profile/delete.d.ts +6 -0
  169. package/commands/project/profile/delete.js +123 -0
  170. package/commands/project/profile.d.ts +3 -0
  171. package/commands/project/profile.js +25 -0
  172. package/commands/project/upload.d.ts +1 -0
  173. package/commands/project/upload.js +22 -8
  174. package/commands/project/validate.d.ts +6 -0
  175. package/commands/project/validate.js +82 -0
  176. package/commands/project.js +4 -2
  177. package/commands/remove.d.ts +3 -7
  178. package/commands/remove.js +22 -22
  179. package/commands/sandbox/create.d.ts +4 -9
  180. package/commands/sandbox/create.js +18 -11
  181. package/commands/sandbox/delete.d.ts +4 -9
  182. package/commands/sandbox/delete.js +18 -11
  183. package/commands/sandbox.d.ts +3 -4
  184. package/commands/sandbox.js +18 -43
  185. package/commands/secret/addSecret.d.ts +4 -9
  186. package/commands/secret/addSecret.js +17 -10
  187. package/commands/secret/deleteSecret.d.ts +4 -9
  188. package/commands/secret/deleteSecret.js +17 -10
  189. package/commands/secret/listSecret.d.ts +4 -9
  190. package/commands/secret/listSecret.js +17 -10
  191. package/commands/secret/updateSecret.d.ts +4 -9
  192. package/commands/secret/updateSecret.js +17 -10
  193. package/commands/secret.d.ts +3 -4
  194. package/commands/secret.js +23 -48
  195. package/commands/testAccount/create.d.ts +6 -0
  196. package/commands/testAccount/create.js +100 -0
  197. package/commands/testAccount/createConfig.d.ts +10 -0
  198. package/commands/testAccount/createConfig.js +98 -0
  199. package/commands/testAccount/delete.d.ts +6 -0
  200. package/commands/testAccount/delete.js +48 -0
  201. package/commands/testAccount.d.ts +3 -0
  202. package/commands/testAccount.js +28 -0
  203. package/commands/theme/generate-selectors.d.ts +3 -7
  204. package/commands/theme/generate-selectors.js +20 -15
  205. package/commands/theme/marketplace-validate.d.ts +4 -9
  206. package/commands/theme/marketplace-validate.js +22 -17
  207. package/commands/theme/preview.d.ts +4 -9
  208. package/commands/theme/preview.js +32 -26
  209. package/commands/theme.d.ts +3 -4
  210. package/commands/theme.js +22 -47
  211. package/commands/upload.d.ts +12 -1
  212. package/commands/upload.js +116 -134
  213. package/commands/watch.d.ts +14 -1
  214. package/commands/watch.js +74 -75
  215. package/lang/en.d.ts +1135 -660
  216. package/lang/en.js +935 -471
  217. package/lang/en.lyaml +30 -213
  218. package/lib/accountTypes.js +1 -2
  219. package/lib/app/migrate.d.ts +23 -0
  220. package/lib/app/migrate.js +29 -6
  221. package/lib/app/migrate_legacy.js +7 -7
  222. package/lib/app/urls.d.ts +16 -0
  223. package/lib/app/urls.js +16 -0
  224. package/lib/commonOpts.d.ts +1 -3
  225. package/lib/commonOpts.js +1 -1
  226. package/lib/configMigrate.d.ts +2 -2
  227. package/lib/configMigrate.js +34 -55
  228. package/lib/configOptions.d.ts +4 -0
  229. package/lib/configOptions.js +41 -46
  230. package/lib/constants.d.ts +29 -0
  231. package/lib/constants.js +30 -1
  232. package/lib/dependencyManagement.d.ts +0 -5
  233. package/lib/dependencyManagement.js +13 -39
  234. package/lib/doctor/Doctor.js +3 -2
  235. package/lib/errorHandlers/index.js +7 -0
  236. package/lib/filesystem.d.ts +1 -1
  237. package/lib/generateSelectors.js +3 -5
  238. package/lib/interpolation.d.ts +2 -3
  239. package/lib/lang.d.ts +2 -3
  240. package/lib/marketplaceValidate.d.ts +12 -2
  241. package/lib/marketplaceValidate.js +22 -29
  242. package/lib/mcp/setup.d.ts +21 -0
  243. package/lib/mcp/setup.js +218 -0
  244. package/lib/middleware/autoUpdateMiddleware.d.ts +1 -0
  245. package/lib/middleware/autoUpdateMiddleware.js +89 -0
  246. package/lib/middleware/configMiddleware.js +23 -0
  247. package/lib/middleware/fireAlarmMiddleware.d.ts +2 -2
  248. package/lib/middleware/fireAlarmMiddleware.js +5 -3
  249. package/lib/npm.d.ts +9 -0
  250. package/lib/npm.js +36 -0
  251. package/lib/projectProfiles.d.ts +7 -0
  252. package/lib/projectProfiles.js +83 -0
  253. package/lib/projects/add/legacyAddComponent.d.ts +5 -0
  254. package/lib/projects/add/legacyAddComponent.js +48 -0
  255. package/lib/projects/add/v3AddComponent.d.ts +8 -0
  256. package/lib/projects/add/v3AddComponent.js +85 -0
  257. package/lib/projects/buildAndDeploy.js +18 -3
  258. package/lib/projects/components.d.ts +2 -0
  259. package/lib/projects/components.js +82 -0
  260. package/lib/projects/create/index.d.ts +23 -0
  261. package/lib/projects/create/index.js +33 -0
  262. package/lib/projects/create/legacy.d.ts +6 -0
  263. package/lib/projects/{create.js → create/legacy.js} +20 -11
  264. package/lib/projects/create/v3.d.ts +27 -0
  265. package/lib/projects/create/v3.js +158 -0
  266. package/lib/projects/localDev/AppDevModeInterface.d.ts +30 -0
  267. package/lib/projects/localDev/AppDevModeInterface.js +215 -0
  268. package/lib/projects/localDev/DevServerManagerV2.d.ts +11 -22
  269. package/lib/projects/localDev/DevServerManagerV2.js +19 -15
  270. package/lib/projects/localDev/LocalDevLogger.d.ts +30 -0
  271. package/lib/projects/localDev/LocalDevLogger.js +159 -0
  272. package/lib/projects/localDev/LocalDevManager.js +12 -5
  273. package/lib/projects/localDev/LocalDevProcess.d.ts +34 -0
  274. package/lib/projects/localDev/LocalDevProcess.js +201 -0
  275. package/lib/projects/localDev/LocalDevState.d.ts +50 -0
  276. package/lib/projects/localDev/LocalDevState.js +119 -0
  277. package/lib/projects/localDev/LocalDevWatcher.d.ts +10 -0
  278. package/lib/projects/localDev/LocalDevWatcher.js +53 -0
  279. package/lib/projects/localDev/LocalDevWebsocketServer.d.ts +20 -0
  280. package/lib/projects/localDev/LocalDevWebsocketServer.js +131 -0
  281. package/lib/projects/localDev/helpers.d.ts +3 -2
  282. package/lib/projects/localDev/helpers.js +32 -2
  283. package/lib/projects/upload.d.ts +5 -1
  284. package/lib/projects/upload.js +60 -20
  285. package/lib/projects/urls.d.ts +3 -0
  286. package/lib/projects/urls.js +17 -1
  287. package/lib/prompts/createApiSamplePrompt.d.ts +2 -10
  288. package/lib/prompts/createDeveloperTestAccountConfigPrompt.d.ts +17 -0
  289. package/lib/prompts/createDeveloperTestAccountConfigPrompt.js +96 -0
  290. package/lib/prompts/createProjectPrompt.d.ts +14 -5
  291. package/lib/prompts/createProjectPrompt.js +38 -13
  292. package/lib/prompts/createTemplatePrompt.d.ts +22 -4
  293. package/lib/prompts/installAppPrompt.d.ts +2 -0
  294. package/lib/prompts/installAppPrompt.js +45 -0
  295. package/lib/prompts/personalAccessKeyPrompt.js +35 -24
  296. package/lib/prompts/projectAddPrompt.d.ts +5 -1
  297. package/lib/prompts/projectAddPrompt.js +35 -7
  298. package/lib/prompts/projectDevTargetAccountPrompt.d.ts +6 -1
  299. package/lib/prompts/projectDevTargetAccountPrompt.js +6 -6
  300. package/lib/prompts/promptUtils.d.ts +4 -1
  301. package/lib/prompts/promptUtils.js +5 -1
  302. package/lib/prompts/selectAppPrompt.d.ts +2 -0
  303. package/lib/prompts/selectAppPrompt.js +40 -0
  304. package/lib/prompts/{selectPublicAppPrompt.d.ts → selectPublicAppForMigrationPrompt.d.ts} +1 -1
  305. package/lib/prompts/{selectPublicAppPrompt.js → selectPublicAppForMigrationPrompt.js} +8 -8
  306. package/lib/prompts/setAsDefaultAccountPrompt.js +10 -0
  307. package/lib/testUtils.d.ts +3 -3
  308. package/lib/testUtils.js +8 -9
  309. package/lib/ui/index.js +4 -1
  310. package/lib/upload.d.ts +1 -1
  311. package/lib/validation.js +4 -5
  312. package/lib/yargsUtils.d.ts +4 -0
  313. package/lib/yargsUtils.js +6 -0
  314. package/mcp-server/server.d.ts +1 -0
  315. package/mcp-server/server.js +18 -0
  316. package/mcp-server/tools/index.d.ts +2 -0
  317. package/mcp-server/tools/index.js +19 -0
  318. package/mcp-server/tools/project/AddFeatureToProject.d.ts +29 -0
  319. package/mcp-server/tools/project/AddFeatureToProject.js +85 -0
  320. package/mcp-server/tools/project/CreateProjectTool.d.ts +35 -0
  321. package/mcp-server/tools/project/CreateProjectTool.js +104 -0
  322. package/mcp-server/tools/project/DeployProject.d.ts +20 -0
  323. package/mcp-server/tools/project/DeployProject.js +50 -0
  324. package/mcp-server/tools/project/GuidedWalkthroughTool.d.ts +17 -0
  325. package/mcp-server/tools/project/GuidedWalkthroughTool.js +58 -0
  326. package/mcp-server/tools/project/UploadProjectTools.d.ts +17 -0
  327. package/mcp-server/tools/project/UploadProjectTools.js +35 -0
  328. package/mcp-server/tools/project/ValidateProjectTool.d.ts +17 -0
  329. package/mcp-server/tools/project/ValidateProjectTool.js +35 -0
  330. package/mcp-server/tools/project/constants.d.ts +3 -0
  331. package/mcp-server/tools/project/constants.js +13 -0
  332. package/mcp-server/types.d.ts +14 -0
  333. package/mcp-server/types.js +17 -0
  334. package/mcp-server/utils/command.d.ts +3 -0
  335. package/mcp-server/utils/command.js +16 -0
  336. package/mcp-server/utils/content.d.ts +3 -0
  337. package/mcp-server/utils/content.js +21 -0
  338. package/mcp-server/utils/project.d.ts +5 -0
  339. package/mcp-server/utils/project.js +17 -0
  340. package/package.json +24 -16
  341. package/types/Cms.d.ts +30 -0
  342. package/types/Cms.js +2 -0
  343. package/types/LocalDev.d.ts +35 -0
  344. package/types/LocalDev.js +2 -0
  345. package/types/Projects.d.ts +19 -2
  346. package/types/Prompts.d.ts +0 -7
  347. package/types/Yargs.d.ts +10 -1
  348. package/lib/projects/create.d.ts +0 -5
  349. package/lib/projects/localDev/LocalDevManagerV2.d.ts +0 -64
  350. package/lib/projects/localDev/LocalDevManagerV2.js +0 -345
  351. package/lib/prompts/installPublicAppPrompt.d.ts +0 -1
  352. package/lib/prompts/installPublicAppPrompt.js +0 -41
@@ -10,8 +10,7 @@ exports.processValidationErrors = processValidationErrors;
10
10
  exports.displayValidationResults = displayValidationResults;
11
11
  const chalk_1 = __importDefault(require("chalk"));
12
12
  const marketplaceValidation_1 = require("@hubspot/local-dev-lib/api/marketplaceValidation");
13
- const logger_1 = require("@hubspot/local-dev-lib/logger");
14
- const lang_1 = require("./lang");
13
+ const logger_1 = require("./ui/logger");
15
14
  const exitCodes_1 = require("./enums/exitCodes");
16
15
  const SLEEP_TIME = 2000;
17
16
  async function kickOffValidation(accountId, assetType, src) {
@@ -25,7 +24,7 @@ async function kickOffValidation(accountId, assetType, src) {
25
24
  return requestResult;
26
25
  }
27
26
  catch (err) {
28
- logger_1.logger.debug(err);
27
+ logger_1.uiLogger.debug(err);
29
28
  process.exit(exitCodes_1.EXIT_CODES.ERROR);
30
29
  }
31
30
  }
@@ -43,7 +42,7 @@ async function pollForValidationFinish(accountId, validationId) {
43
42
  await checkValidationStatus();
44
43
  }
45
44
  catch (err) {
46
- logger_1.logger.debug(err);
45
+ logger_1.uiLogger.debug(err);
47
46
  process.exit(exitCodes_1.EXIT_CODES.ERROR);
48
47
  }
49
48
  }
@@ -55,69 +54,63 @@ async function fetchValidationResults(accountId, validationId) {
55
54
  return validationResults;
56
55
  }
57
56
  catch (err) {
58
- logger_1.logger.debug(err);
57
+ logger_1.uiLogger.debug(err);
59
58
  process.exit(exitCodes_1.EXIT_CODES.ERROR);
60
59
  }
61
60
  }
62
- function processValidationErrors(i18nKey, validationResults) {
61
+ function processValidationErrors(invalidPathError, validationResults) {
63
62
  if (validationResults.errors.length) {
64
63
  const { assetPath, errors } = validationResults;
65
64
  errors.forEach(err => {
66
65
  if (err.failureReasonType === 'DOWNLOAD_EMPTY') {
67
- logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.invalidPath`, {
68
- path: assetPath,
69
- }));
66
+ logger_1.uiLogger.error(invalidPathError(assetPath));
70
67
  }
71
68
  else {
72
- logger_1.logger.error(`${err.context}`);
69
+ logger_1.uiLogger.error(`${err.context}`);
73
70
  }
74
71
  });
75
72
  process.exit(exitCodes_1.EXIT_CODES.ERROR);
76
73
  }
77
74
  }
78
- function displayFileInfo(file, line, i18nKey) {
75
+ function displayFileInfo(file, line, resultsCopy) {
79
76
  if (file) {
80
- logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.results.warnings.file`, {
81
- file,
82
- }));
77
+ logger_1.uiLogger.log(resultsCopy.warnings.file(file));
83
78
  }
84
79
  if (line) {
85
- logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.results.warnings.lineNumber`, {
86
- line,
87
- }));
80
+ logger_1.uiLogger.log(resultsCopy.warnings.lineNumber(line.toString()));
88
81
  }
89
82
  }
90
- function displayResults(checks, i18nKey) {
83
+ function displayResults(checks, resultsCopy) {
91
84
  if (checks) {
92
85
  const { status, results } = checks;
93
86
  if (status === 'FAIL') {
94
87
  const failedValidations = results.filter(test => test.status === 'FAIL');
95
88
  const warningValidations = results.filter(test => test.status === 'WARN');
96
89
  failedValidations.forEach(val => {
97
- logger_1.logger.error(`${val.message}`);
98
- displayFileInfo(val.file, val.line, i18nKey);
90
+ logger_1.uiLogger.error(`${val.message}`);
91
+ displayFileInfo(val.file, val.line, resultsCopy);
99
92
  });
100
93
  warningValidations.forEach(val => {
101
- logger_1.logger.warn(`${val.message}`);
102
- displayFileInfo(val.file, val.line, i18nKey);
94
+ logger_1.uiLogger.warn(`${val.message}`);
95
+ displayFileInfo(val.file, val.line, resultsCopy);
103
96
  });
104
97
  }
105
98
  if (status === 'PASS') {
106
- logger_1.logger.success((0, lang_1.i18n)(`${i18nKey}.results.noErrors`));
99
+ logger_1.uiLogger.success(resultsCopy.noErrors);
107
100
  results.forEach(test => {
108
101
  if (test.status === 'WARN') {
109
- logger_1.logger.warn(`${test.message}`);
110
- displayFileInfo(test.file, test.line, i18nKey);
102
+ logger_1.uiLogger.warn(`${test.message}`);
103
+ displayFileInfo(test.file, test.line, resultsCopy);
111
104
  }
112
105
  });
113
106
  }
114
107
  }
115
108
  return;
116
109
  }
117
- function displayValidationResults(i18nKey, validationResults) {
110
+ function displayValidationResults(resultsCopy, validationResults) {
118
111
  Object.keys(validationResults.results).forEach(type => {
119
- logger_1.logger.log(chalk_1.default.bold((0, lang_1.i18n)(`${i18nKey}.results.${type.toLowerCase()}`)));
120
- displayResults(validationResults.results[type], i18nKey);
121
- logger_1.logger.log();
112
+ logger_1.uiLogger.log(chalk_1.default.bold(resultsCopy[type.toLowerCase()]));
113
+ displayResults(validationResults.results[type], resultsCopy);
114
+ logger_1.uiLogger.log('');
122
115
  });
123
116
  }
@@ -0,0 +1,21 @@
1
+ export declare const supportedTools: ({
2
+ name: "Claude Code";
3
+ value: string;
4
+ } | {
5
+ name: "Cursor";
6
+ value: string;
7
+ } | {
8
+ name: "Windsurf";
9
+ value: string;
10
+ })[];
11
+ interface McpCommand {
12
+ command: string;
13
+ args: string[];
14
+ }
15
+ export declare function addMintlifyMcpServer(installTargets: string[]): Promise<void>;
16
+ export declare function setupMintlify(derivedTargets?: string[]): Promise<boolean>;
17
+ export declare function addMcpServerToConfig(targets: string[] | undefined): Promise<string[]>;
18
+ export declare function setupClaudeCode(mcpCommand?: McpCommand): Promise<boolean>;
19
+ export declare function setupCursor(mcpCommand?: McpCommand): boolean;
20
+ export declare function setupWindsurf(mcpCommand?: McpCommand): boolean;
21
+ export {};
@@ -0,0 +1,218 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.supportedTools = void 0;
7
+ exports.addMintlifyMcpServer = addMintlifyMcpServer;
8
+ exports.setupMintlify = setupMintlify;
9
+ exports.addMcpServerToConfig = addMcpServerToConfig;
10
+ exports.setupClaudeCode = setupClaudeCode;
11
+ exports.setupCursor = setupCursor;
12
+ exports.setupWindsurf = setupWindsurf;
13
+ const logger_1 = require("../ui/logger");
14
+ const en_1 = require("../../lang/en");
15
+ const promptUtils_1 = require("../prompts/promptUtils");
16
+ const SpinniesManager_1 = __importDefault(require("../ui/SpinniesManager"));
17
+ const errorHandlers_1 = require("../errorHandlers");
18
+ const command_1 = require("../../mcp-server/utils/command");
19
+ const child_process_1 = require("child_process");
20
+ const path_1 = __importDefault(require("path"));
21
+ const os_1 = __importDefault(require("os"));
22
+ const fs_extra_1 = __importDefault(require("fs-extra"));
23
+ const fs_1 = require("fs");
24
+ const mcpServerName = 'hubspot-cli-mcp';
25
+ const claudeCode = 'claude';
26
+ const windsurf = 'windsurf';
27
+ const cursor = 'cursor';
28
+ const supportedMintlifyClients = [windsurf, cursor];
29
+ exports.supportedTools = [
30
+ { name: en_1.commands.mcp.setup.claudeCode, value: claudeCode },
31
+ { name: en_1.commands.mcp.setup.cursor, value: cursor },
32
+ { name: en_1.commands.mcp.setup.windsurf, value: windsurf },
33
+ ];
34
+ const defaultMcpCommand = {
35
+ command: 'hs',
36
+ args: ['mcp', 'start'],
37
+ };
38
+ async function addMintlifyMcpServer(installTargets) {
39
+ await runSetupFunction(() => setupMintlify(installTargets));
40
+ }
41
+ async function setupMintlify(derivedTargets = supportedMintlifyClients) {
42
+ logger_1.uiLogger.info(en_1.commands.mcp.setup.installingDocSearch);
43
+ logger_1.uiLogger.log('');
44
+ return new Promise(resolve => {
45
+ const subcommands = ['mint-mcp', 'add', 'hubspot-migration'];
46
+ const docsSearchClients = derivedTargets.filter(target => supportedMintlifyClients.includes(target));
47
+ const childProcess = (0, child_process_1.spawn)(`npx`, docsSearchClients && docsSearchClients.length
48
+ ? [...subcommands, '--client', ...docsSearchClients]
49
+ : subcommands, {
50
+ stdio: 'inherit',
51
+ });
52
+ childProcess.on('exit', code => {
53
+ if (code !== 0) {
54
+ resolve(false);
55
+ }
56
+ resolve(true);
57
+ });
58
+ });
59
+ }
60
+ async function addMcpServerToConfig(targets) {
61
+ try {
62
+ let derivedTargets = [];
63
+ if (!targets || targets.length === 0) {
64
+ const { selectedTargets } = await (0, promptUtils_1.promptUser)({
65
+ name: 'selectedTargets',
66
+ type: 'checkbox',
67
+ message: en_1.commands.mcp.setup.prompts.targets,
68
+ choices: exports.supportedTools,
69
+ validate: (choices) => {
70
+ return choices.length === 0
71
+ ? en_1.commands.mcp.setup.prompts.targetsRequired
72
+ : true;
73
+ },
74
+ });
75
+ derivedTargets = selectedTargets;
76
+ }
77
+ else {
78
+ derivedTargets = targets;
79
+ }
80
+ SpinniesManager_1.default.init();
81
+ if (derivedTargets.includes(claudeCode)) {
82
+ await runSetupFunction(setupClaudeCode);
83
+ }
84
+ if (derivedTargets.includes(cursor)) {
85
+ await runSetupFunction(setupCursor);
86
+ }
87
+ if (derivedTargets.includes(windsurf)) {
88
+ await runSetupFunction(setupWindsurf);
89
+ }
90
+ logger_1.uiLogger.info(en_1.commands.mcp.setup.success(derivedTargets));
91
+ return derivedTargets;
92
+ }
93
+ catch (error) {
94
+ SpinniesManager_1.default.fail('mcpSetup', {
95
+ text: en_1.commands.mcp.setup.spinners.failedToConfigure,
96
+ });
97
+ throw error;
98
+ }
99
+ }
100
+ async function runSetupFunction(func) {
101
+ const result = await func();
102
+ if (!result) {
103
+ throw new Error();
104
+ }
105
+ }
106
+ function setupMcpConfigFile(config) {
107
+ try {
108
+ SpinniesManager_1.default.add('spinner', {
109
+ text: config.configuringMessage,
110
+ });
111
+ if (!(0, fs_1.existsSync)(config.configPath)) {
112
+ fs_extra_1.default.writeFileSync(config.configPath, JSON.stringify({}, null, 2));
113
+ }
114
+ let mcpConfig = {};
115
+ try {
116
+ const configContent = fs_extra_1.default.readFileSync(config.configPath, 'utf8');
117
+ mcpConfig = JSON.parse(configContent);
118
+ }
119
+ catch (error) {
120
+ SpinniesManager_1.default.fail('spinner', {
121
+ text: config.failedMessage,
122
+ });
123
+ (0, errorHandlers_1.logError)(error);
124
+ return false;
125
+ }
126
+ // Initialize mcpServers if it doesn't exist
127
+ if (!mcpConfig.mcpServers) {
128
+ mcpConfig.mcpServers = {};
129
+ }
130
+ // Add or update HubSpot CLI MCP server
131
+ mcpConfig.mcpServers[mcpServerName] = {
132
+ ...config.mcpCommand,
133
+ };
134
+ // Write the updated config
135
+ fs_extra_1.default.writeFileSync(config.configPath, JSON.stringify(mcpConfig, null, 2));
136
+ SpinniesManager_1.default.succeed('spinner', {
137
+ text: config.configuredMessage,
138
+ });
139
+ return true;
140
+ }
141
+ catch (error) {
142
+ SpinniesManager_1.default.fail('spinner', {
143
+ text: config.failedMessage,
144
+ });
145
+ (0, errorHandlers_1.logError)(error);
146
+ return false;
147
+ }
148
+ }
149
+ async function setupClaudeCode(mcpCommand = defaultMcpCommand) {
150
+ try {
151
+ SpinniesManager_1.default.add('claudeCode', {
152
+ text: en_1.commands.mcp.setup.spinners.configuringClaudeCode,
153
+ });
154
+ try {
155
+ // Check if claude command is available
156
+ await (0, command_1.execAsync)('claude --version');
157
+ // Run claude mcp add command
158
+ const mcpConfig = JSON.stringify({
159
+ type: 'stdio',
160
+ ...mcpCommand,
161
+ });
162
+ const { stdout } = await (0, command_1.execAsync)('claude mcp list');
163
+ if (stdout.includes(mcpServerName)) {
164
+ SpinniesManager_1.default.update('claudeCode', {
165
+ text: en_1.commands.mcp.setup.spinners.alreadyInstalled,
166
+ });
167
+ await (0, command_1.execAsync)(`claude mcp remove "${mcpServerName}" --scope user`);
168
+ }
169
+ await (0, command_1.execAsync)(`claude mcp add-json "${mcpServerName}" '${mcpConfig}' --scope user`);
170
+ SpinniesManager_1.default.succeed('claudeCode', {
171
+ text: en_1.commands.mcp.setup.spinners.configuredClaudeCode,
172
+ });
173
+ return true;
174
+ }
175
+ catch (error) {
176
+ if (error instanceof Error &&
177
+ error.message.includes('claude: command not found')) {
178
+ SpinniesManager_1.default.fail('claudeCode', {
179
+ text: en_1.commands.mcp.setup.spinners.claudeCodeNotFound,
180
+ });
181
+ }
182
+ else {
183
+ SpinniesManager_1.default.fail('claudeCode', {
184
+ text: en_1.commands.mcp.setup.spinners.claudeCodeInstallFailed,
185
+ });
186
+ (0, errorHandlers_1.logError)(error);
187
+ }
188
+ return false;
189
+ }
190
+ }
191
+ catch (error) {
192
+ SpinniesManager_1.default.fail('claudeCode', {
193
+ text: en_1.commands.mcp.setup.spinners.claudeCodeInstallFailed,
194
+ });
195
+ (0, errorHandlers_1.logError)(error);
196
+ return false;
197
+ }
198
+ }
199
+ function setupCursor(mcpCommand = defaultMcpCommand) {
200
+ const cursorConfigPath = path_1.default.join(os_1.default.homedir(), '.cursor', 'mcp.json');
201
+ return setupMcpConfigFile({
202
+ configPath: cursorConfigPath,
203
+ configuringMessage: en_1.commands.mcp.setup.spinners.configuringCursor,
204
+ configuredMessage: en_1.commands.mcp.setup.spinners.configuredCursor,
205
+ failedMessage: en_1.commands.mcp.setup.spinners.failedToConfigureCursor,
206
+ mcpCommand,
207
+ });
208
+ }
209
+ function setupWindsurf(mcpCommand = defaultMcpCommand) {
210
+ const windsurfConfigPath = path_1.default.join(os_1.default.homedir(), '.codeium', 'windsurf', 'mcp_config.json');
211
+ return setupMcpConfigFile({
212
+ configPath: windsurfConfigPath,
213
+ configuringMessage: en_1.commands.mcp.setup.spinners.configuringWindsurf,
214
+ configuredMessage: en_1.commands.mcp.setup.spinners.configuredWindsurf,
215
+ failedMessage: en_1.commands.mcp.setup.spinners.failedToConfigureWindsurf,
216
+ mcpCommand,
217
+ });
218
+ }
@@ -0,0 +1 @@
1
+ export declare function autoUpdateCLI(): Promise<void>;
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.autoUpdateCLI = autoUpdateCLI;
7
+ // Update-notifier is CommonJS, so we need to use require
8
+ const updateNotifier = require('update-notifier');
9
+ const config_1 = require("@hubspot/local-dev-lib/config");
10
+ const package_json_1 = __importDefault(require("../../package.json"));
11
+ const ui_1 = require("../ui");
12
+ const SpinniesManager_1 = __importDefault(require("../ui/SpinniesManager"));
13
+ const en_1 = require("../../lang/en");
14
+ const npm_1 = require("../npm");
15
+ const errorHandlers_1 = require("../errorHandlers");
16
+ const logger_1 = require("../ui/logger");
17
+ // Default behavior is to check for notifications at most once per day
18
+ // update-notifier stores the last checked date in the user's home directory
19
+ const notifier = updateNotifier({
20
+ pkg: { ...package_json_1.default, name: '@hubspot/cli' },
21
+ distTag: 'latest',
22
+ shouldNotifyInNpmScript: true,
23
+ });
24
+ const CMS_CLI_PACKAGE_NAME = '@hubspot/cms-cli';
25
+ function updateNotification() {
26
+ notifier.notify({
27
+ message: package_json_1.default.name === CMS_CLI_PACKAGE_NAME
28
+ ? en_1.lib.middleware.updateNotification.cmsUpdateNotification(CMS_CLI_PACKAGE_NAME)
29
+ : en_1.lib.middleware.updateNotification.cliUpdateNotification,
30
+ defer: false,
31
+ boxenOptions: {
32
+ borderColor: ui_1.UI_COLORS.MARIGOLD_DARK,
33
+ margin: 1,
34
+ padding: 1,
35
+ textAlignment: 'center',
36
+ borderStyle: 'round',
37
+ title: package_json_1.default.name === CMS_CLI_PACKAGE_NAME
38
+ ? null
39
+ : en_1.lib.middleware.updateNotification.notifyTitle,
40
+ },
41
+ });
42
+ }
43
+ async function autoUpdateCLI() {
44
+ // This lets us back to default update-notifier behavior
45
+ let showManualInstallHelp = true;
46
+ if (notifier &&
47
+ notifier.update &&
48
+ !process.env.SKIP_HUBSPOT_CLI_AUTO_UPDATES &&
49
+ (0, config_1.isConfigFlagEnabled)('allowAutoUpdates')) {
50
+ // Ignore all update notifications if the current version is a pre-release
51
+ if (!notifier.update.current.includes('-')) {
52
+ // Attempt auto-update if the current version is not the latest version
53
+ // Never auto-update for major version updates b/c they are breaking
54
+ if (!['major', 'latest'].includes(notifier.update.type)) {
55
+ SpinniesManager_1.default.init({
56
+ succeedColor: 'white',
57
+ });
58
+ SpinniesManager_1.default.add('cliAutoUpdate', {
59
+ text: en_1.lib.middleware.autoUpdateCLI.updateAvailable(notifier.update.latest),
60
+ });
61
+ try {
62
+ if ((await (0, npm_1.isGloballyInstalled)(npm_1.DEFAULT_PACKAGE_MANAGER)) &&
63
+ (await (0, npm_1.isGloballyInstalled)('hs'))) {
64
+ await (0, npm_1.executeInstall)(['@hubspot/cli@latest'], '-g');
65
+ showManualInstallHelp = false;
66
+ SpinniesManager_1.default.succeed('cliAutoUpdate', {
67
+ text: en_1.lib.middleware.autoUpdateCLI.updateSucceeded(notifier.update.latest),
68
+ });
69
+ logger_1.uiLogger.log('');
70
+ }
71
+ else {
72
+ SpinniesManager_1.default.fail('cliAutoUpdate', {
73
+ text: en_1.lib.middleware.autoUpdateCLI.notInstalledGlobally,
74
+ });
75
+ }
76
+ }
77
+ catch (e) {
78
+ (0, errorHandlers_1.debugError)(e);
79
+ SpinniesManager_1.default.fail('cliAutoUpdate', {
80
+ text: en_1.lib.middleware.autoUpdateCLI.updateFailed(notifier.update.latest),
81
+ });
82
+ }
83
+ }
84
+ }
85
+ }
86
+ if (showManualInstallHelp) {
87
+ updateNotification();
88
+ }
89
+ }
@@ -40,6 +40,13 @@ async function injectAccountIdMiddleware(argv) {
40
40
  const SKIP_CONFIG_VALIDATION = {
41
41
  init: { target: true },
42
42
  auth: { target: true },
43
+ mcp: {
44
+ target: false,
45
+ subCommands: {
46
+ setup: { target: true },
47
+ start: { target: true },
48
+ },
49
+ },
43
50
  };
44
51
  async function loadConfigMiddleware(argv) {
45
52
  // Skip this when no command is provided
@@ -55,6 +62,7 @@ async function loadConfigMiddleware(argv) {
55
62
  if (!(0, config_1.configFileExists)(true) &&
56
63
  (0, utils_1.isTargetedCommand)(argv._, {
57
64
  account: { target: false, subCommands: { auth: { target: true } } },
65
+ config: { target: false, subCommands: { migrate: { target: true } } },
58
66
  })) {
59
67
  return;
60
68
  }
@@ -86,6 +94,7 @@ const accountsSubCommands = {
86
94
  list: { target: true },
87
95
  ls: { target: true },
88
96
  remove: { target: true },
97
+ use: { target: true },
89
98
  },
90
99
  };
91
100
  const sandboxesSubCommands = {
@@ -94,13 +103,27 @@ const sandboxesSubCommands = {
94
103
  delete: { target: true },
95
104
  },
96
105
  };
106
+ const configSubCommands = {
107
+ target: false,
108
+ subCommands: {
109
+ migrate: { target: true },
110
+ },
111
+ };
97
112
  const SKIP_ACCOUNT_VALIDATION = {
98
113
  init: { target: true },
99
114
  auth: { target: true },
115
+ mcp: {
116
+ target: false,
117
+ subCommands: {
118
+ setup: { target: true },
119
+ start: { target: true },
120
+ },
121
+ },
100
122
  account: accountsSubCommands,
101
123
  accounts: accountsSubCommands,
102
124
  sandbox: sandboxesSubCommands,
103
125
  sandboxes: sandboxesSubCommands,
126
+ config: configSubCommands,
104
127
  };
105
128
  async function validateAccountOptions(argv) {
106
129
  // Skip this when no command is provided
@@ -1,4 +1,4 @@
1
1
  import { Arguments } from 'yargs';
2
- export declare function checkFireAlarms(args: Arguments<{
3
- derivedAccountId: number;
2
+ export declare function checkFireAlarms(argv: Arguments<{
3
+ derivedAccountId?: number;
4
4
  }>): Promise<void>;
@@ -112,10 +112,12 @@ async function logFireAlarms(accountId, command, version) {
112
112
  });
113
113
  }
114
114
  }
115
- async function checkFireAlarms(args) {
116
- const { derivedAccountId } = args;
115
+ async function checkFireAlarms(argv) {
116
+ const { derivedAccountId } = argv;
117
117
  try {
118
- await logFireAlarms(derivedAccountId, args._.join(' '), package_json_1.default.version);
118
+ if (derivedAccountId) {
119
+ await logFireAlarms(derivedAccountId, argv._.join(' '), package_json_1.default.version);
120
+ }
119
121
  }
120
122
  catch (error) {
121
123
  (0, errorHandlers_1.debugError)(error);
package/lib/npm.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ export declare const DEFAULT_PACKAGE_MANAGER = "npm";
2
+ export declare function isGloballyInstalled(packageName: string): Promise<boolean>;
3
+ export declare function getLatestCliVersion(): Promise<{
4
+ latest: string;
5
+ next: string;
6
+ }>;
7
+ export declare function executeInstall(packages?: string[], flags?: string | null, options?: {
8
+ cwd?: string;
9
+ }): Promise<void>;
package/lib/npm.js ADDED
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.DEFAULT_PACKAGE_MANAGER = void 0;
7
+ exports.isGloballyInstalled = isGloballyInstalled;
8
+ exports.getLatestCliVersion = getLatestCliVersion;
9
+ exports.executeInstall = executeInstall;
10
+ const child_process_1 = require("child_process");
11
+ const util_1 = __importDefault(require("util"));
12
+ const logger_1 = require("@hubspot/local-dev-lib/logger");
13
+ const package_json_1 = __importDefault(require("../package.json"));
14
+ exports.DEFAULT_PACKAGE_MANAGER = 'npm';
15
+ async function isGloballyInstalled(packageName) {
16
+ const exec = util_1.default.promisify(child_process_1.exec);
17
+ try {
18
+ await exec(`${packageName} --version`);
19
+ return true;
20
+ }
21
+ catch (e) {
22
+ return false;
23
+ }
24
+ }
25
+ async function getLatestCliVersion() {
26
+ const exec = util_1.default.promisify(child_process_1.exec);
27
+ const { stdout } = await exec(`npm info ${package_json_1.default.name} dist-tags --json`);
28
+ const { latest, next } = JSON.parse(stdout);
29
+ return { latest, next };
30
+ }
31
+ async function executeInstall(packages = [], flags, options) {
32
+ const installCommand = `${exports.DEFAULT_PACKAGE_MANAGER} install${flags ? ` ${flags}` : ''} ${packages.join(' ')}`;
33
+ logger_1.logger.debug('Running ', installCommand);
34
+ const exec = util_1.default.promisify(child_process_1.exec);
35
+ await exec(installCommand, options);
36
+ }
@@ -0,0 +1,7 @@
1
+ import { HsProfileFile } from '@hubspot/project-parsing-lib/src/lib/types';
2
+ import { ProjectConfig } from '../types/Projects';
3
+ export declare function logProfileHeader(profileName: string): void;
4
+ export declare function logProfileFooter(profile: HsProfileFile, includeVariables?: boolean): void;
5
+ export declare function loadProfile(projectConfig: ProjectConfig | null, projectDir: string | null, profileName: string): HsProfileFile | undefined;
6
+ export declare function exitIfUsingProfiles(projectConfig: ProjectConfig | null, projectDir: string | null): Promise<void>;
7
+ export declare function loadAndValidateProfile(projectConfig: ProjectConfig | null, projectDir: string | null, argsProfile: string | undefined): Promise<number | undefined>;
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.logProfileHeader = logProfileHeader;
7
+ exports.logProfileFooter = logProfileFooter;
8
+ exports.loadProfile = loadProfile;
9
+ exports.exitIfUsingProfiles = exitIfUsingProfiles;
10
+ exports.loadAndValidateProfile = loadAndValidateProfile;
11
+ const path_1 = __importDefault(require("path"));
12
+ const project_parsing_lib_1 = require("@hubspot/project-parsing-lib");
13
+ const en_1 = require("../lang/en");
14
+ const ui_1 = require("./ui");
15
+ const logger_1 = require("./ui/logger");
16
+ const exitCodes_1 = require("./enums/exitCodes");
17
+ function logProfileHeader(profileName) {
18
+ (0, ui_1.uiLine)();
19
+ (0, ui_1.uiBetaTag)(en_1.lib.projectProfiles.logs.usingProfile((0, project_parsing_lib_1.getHsProfileFilename)(profileName)));
20
+ logger_1.uiLogger.log('');
21
+ }
22
+ function logProfileFooter(profile, includeVariables = false) {
23
+ logger_1.uiLogger.log(en_1.lib.projectProfiles.logs.profileTargetAccount(profile.accountId));
24
+ if (includeVariables) {
25
+ logger_1.uiLogger.log('');
26
+ logger_1.uiLogger.log(en_1.lib.projectProfiles.logs.profileVariables);
27
+ Object.entries(profile.variables ?? {}).forEach(([key, value]) => {
28
+ logger_1.uiLogger.log(` ${key}: ${value}`);
29
+ });
30
+ }
31
+ (0, ui_1.uiLine)();
32
+ logger_1.uiLogger.log('');
33
+ }
34
+ function loadProfile(projectConfig, projectDir, profileName) {
35
+ if (!projectConfig || !projectDir) {
36
+ logger_1.uiLogger.error(en_1.lib.projectProfiles.loadProfile.errors.noProjectConfig);
37
+ return;
38
+ }
39
+ const projectSourceDir = path_1.default.join(projectDir, projectConfig.srcDir);
40
+ const profileFilename = (0, project_parsing_lib_1.getHsProfileFilename)(profileName);
41
+ try {
42
+ const profile = (0, project_parsing_lib_1.loadHsProfileFile)(projectSourceDir, profileName);
43
+ if (!profile) {
44
+ logger_1.uiLogger.error(en_1.lib.projectProfiles.loadProfile.errors.profileNotFound(profileFilename));
45
+ return;
46
+ }
47
+ if (!profile.accountId) {
48
+ logger_1.uiLogger.error(en_1.lib.projectProfiles.loadProfile.errors.missingAccountId(profileFilename));
49
+ return;
50
+ }
51
+ return profile;
52
+ }
53
+ catch (e) {
54
+ logger_1.uiLogger.error(en_1.lib.projectProfiles.loadProfile.errors.failedToLoadProfile(profileFilename));
55
+ return;
56
+ }
57
+ }
58
+ async function exitIfUsingProfiles(projectConfig, projectDir) {
59
+ if (projectConfig && projectDir) {
60
+ const existingProfiles = await (0, project_parsing_lib_1.getAllHsProfiles)(path_1.default.join(projectDir, projectConfig.srcDir));
61
+ if (existingProfiles.length > 0) {
62
+ logger_1.uiLogger.error(en_1.lib.projectProfiles.exitIfUsingProfiles.errors.noProfileSpecified);
63
+ process.exit(exitCodes_1.EXIT_CODES.ERROR);
64
+ }
65
+ }
66
+ }
67
+ async function loadAndValidateProfile(projectConfig, projectDir, argsProfile) {
68
+ if (argsProfile) {
69
+ logProfileHeader(argsProfile);
70
+ const profile = loadProfile(projectConfig, projectDir, argsProfile);
71
+ if (!profile) {
72
+ (0, ui_1.uiLine)();
73
+ process.exit(exitCodes_1.EXIT_CODES.ERROR);
74
+ }
75
+ logProfileFooter(profile, true);
76
+ return profile.accountId;
77
+ }
78
+ else {
79
+ // A profile must be specified if this project has profiles configured
80
+ await exitIfUsingProfiles(projectConfig, projectDir);
81
+ }
82
+ return undefined;
83
+ }