@hubspot/cli 7.10.0 → 7.10.1-experimental.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 (199) hide show
  1. package/bin/cli.js +5 -4
  2. package/commands/__tests__/getStarted.test.js +10 -0
  3. package/commands/__tests__/project.test.js +3 -0
  4. package/commands/account/__tests__/rename.test.js +10 -3
  5. package/commands/account/auth.js +10 -14
  6. package/commands/account/clean.js +11 -19
  7. package/commands/account/createOverride.js +15 -11
  8. package/commands/account/info.js +8 -5
  9. package/commands/account/list.js +15 -19
  10. package/commands/account/remove.js +23 -22
  11. package/commands/account/removeOverride.js +6 -6
  12. package/commands/account/rename.js +2 -2
  13. package/commands/account/use.js +19 -8
  14. package/commands/app/__tests__/migrate.test.js +8 -4
  15. package/commands/app/migrate.js +2 -2
  16. package/commands/auth.js +18 -14
  17. package/commands/config/migrate.js +5 -5
  18. package/commands/customObject/createSchema.js +2 -3
  19. package/commands/customObject/updateSchema.js +2 -3
  20. package/commands/getStarted.js +2 -3
  21. package/commands/hubdb/__tests__/list.test.js +1 -0
  22. package/commands/hubdb/list.js +2 -2
  23. package/commands/init.js +36 -32
  24. package/commands/project/__tests__/deploy.test.js +10 -5
  25. package/commands/project/__tests__/devUnifiedFlow.test.js +6 -4
  26. package/commands/project/__tests__/lint.test.js +709 -0
  27. package/commands/project/__tests__/logs.test.js +4 -0
  28. package/commands/project/__tests__/validate.test.js +286 -28
  29. package/commands/project/cloneApp.js +2 -2
  30. package/commands/project/deploy.js +16 -8
  31. package/commands/project/dev/deprecatedFlow.js +4 -5
  32. package/commands/project/dev/index.js +19 -7
  33. package/commands/project/dev/unifiedFlow.js +4 -5
  34. package/commands/project/lint.d.ts +6 -0
  35. package/commands/project/lint.js +178 -0
  36. package/commands/project/logs.js +2 -3
  37. package/commands/project/migrate.js +4 -13
  38. package/commands/project/profile/add.js +6 -7
  39. package/commands/project/profile/delete.js +2 -2
  40. package/commands/project/upload.js +10 -4
  41. package/commands/project/validate.js +73 -13
  42. package/commands/project.js +2 -0
  43. package/commands/sandbox/__tests__/create.test.js +14 -5
  44. package/commands/sandbox/create.js +4 -5
  45. package/commands/sandbox/delete.js +23 -20
  46. package/commands/testAccount/create.js +2 -2
  47. package/commands/testAccount/delete.js +9 -8
  48. package/lang/en.d.ts +48 -11
  49. package/lang/en.js +58 -15
  50. package/lib/__tests__/buildAccount.test.js +22 -30
  51. package/lib/__tests__/commonOpts.test.js +9 -13
  52. package/lib/__tests__/developerTestAccounts.test.js +29 -17
  53. package/lib/__tests__/importData.test.js +20 -10
  54. package/lib/__tests__/oauth.test.js +19 -8
  55. package/lib/__tests__/projectProfiles.test.js +273 -32
  56. package/lib/__tests__/sandboxSync.test.js +33 -11
  57. package/lib/__tests__/sandboxes.test.js +30 -19
  58. package/lib/__tests__/usageTracking.test.js +10 -10
  59. package/lib/__tests__/validation.test.js +32 -32
  60. package/lib/accountTypes.d.ts +9 -9
  61. package/lib/accountTypes.js +2 -4
  62. package/lib/app/__tests__/migrate.test.js +15 -0
  63. package/lib/app/__tests__/migrate_legacy.test.js +9 -0
  64. package/lib/app/migrate_legacy.d.ts +2 -2
  65. package/lib/buildAccount.d.ts +4 -4
  66. package/lib/buildAccount.js +7 -14
  67. package/lib/commonOpts.js +3 -3
  68. package/lib/configMigrate.d.ts +2 -2
  69. package/lib/configMigrate.js +42 -18
  70. package/lib/configOptions.js +3 -2
  71. package/lib/developerTestAccounts.d.ts +3 -3
  72. package/lib/developerTestAccounts.js +4 -7
  73. package/lib/doctor/DiagnosticInfoBuilder.d.ts +1 -1
  74. package/lib/doctor/DiagnosticInfoBuilder.js +9 -6
  75. package/lib/doctor/Doctor.js +4 -3
  76. package/lib/doctor/__tests__/Diagnosis.test.js +4 -3
  77. package/lib/doctor/__tests__/DiagnosticInfoBuilder.test.js +17 -9
  78. package/lib/doctor/__tests__/Doctor.test.js +14 -0
  79. package/lib/importData.js +8 -7
  80. package/lib/links.js +5 -5
  81. package/lib/middleware/{__test__ → __tests__}/commandTargetingUtils.test.js +3 -3
  82. package/lib/middleware/{__test__ → __tests__}/configMiddleware.test.js +23 -22
  83. package/lib/middleware/{__test__ → __tests__}/gitMiddleware.test.js +9 -7
  84. package/lib/middleware/autoUpdateMiddleware.js +34 -23
  85. package/lib/middleware/commandTargetingUtils.js +3 -2
  86. package/lib/middleware/configMiddleware.d.ts +6 -1
  87. package/lib/middleware/configMiddleware.js +36 -15
  88. package/lib/middleware/fireAlarmMiddleware.js +4 -15
  89. package/lib/middleware/gitMiddleware.js +8 -4
  90. package/lib/oauth.d.ts +2 -2
  91. package/lib/oauth.js +8 -10
  92. package/lib/projectProfiles.d.ts +4 -3
  93. package/lib/projectProfiles.js +78 -32
  94. package/lib/projects/__tests__/AppDevModeInterface.test.js +17 -6
  95. package/lib/projects/__tests__/DevServerManager.test.js +1 -0
  96. package/lib/projects/__tests__/LocalDevProcess.test.js +1 -0
  97. package/lib/projects/__tests__/deploy.test.js +1 -0
  98. package/lib/projects/__tests__/uieLinting.test.js +640 -0
  99. package/lib/projects/create/__tests__/v2.test.js +11 -0
  100. package/lib/projects/localDev/AppDevModeInterface.js +2 -2
  101. package/lib/projects/localDev/DevServerManager_DEPRECATED.js +2 -2
  102. package/lib/projects/localDev/LocalDevLogger.js +4 -4
  103. package/lib/projects/localDev/LocalDevManager_DEPRECATED.js +3 -3
  104. package/lib/projects/localDev/helpers/account.d.ts +10 -10
  105. package/lib/projects/localDev/helpers/account.js +6 -11
  106. package/lib/projects/uieLinting.d.ts +33 -0
  107. package/lib/projects/uieLinting.js +222 -0
  108. package/lib/projects/urls.js +5 -6
  109. package/lib/prompts/__tests__/downloadProjectPrompt.test.js +7 -5
  110. package/lib/prompts/accountNamePrompt.js +3 -3
  111. package/lib/prompts/accountsPrompt.d.ts +1 -1
  112. package/lib/prompts/accountsPrompt.js +6 -7
  113. package/lib/prompts/confirmImportDataPrompt.js +2 -2
  114. package/lib/prompts/downloadProjectPrompt.d.ts +1 -0
  115. package/lib/prompts/downloadProjectPrompt.js +5 -2
  116. package/lib/prompts/importDataTestAccountSelectPrompt.js +4 -5
  117. package/lib/prompts/personalAccessKeyPrompt.js +2 -2
  118. package/lib/prompts/projectDevTargetAccountPrompt.d.ts +3 -3
  119. package/lib/prompts/projectDevTargetAccountPrompt.js +5 -7
  120. package/lib/prompts/sandboxesPrompt.js +7 -8
  121. package/lib/prompts/setAsDefaultAccountPrompt.js +7 -6
  122. package/lib/sandboxSync.d.ts +2 -2
  123. package/lib/sandboxSync.js +3 -9
  124. package/lib/sandboxes.d.ts +4 -4
  125. package/lib/sandboxes.js +6 -11
  126. package/lib/serverlessLogs.js +2 -2
  127. package/lib/theme/__tests__/migrate.test.js +15 -0
  128. package/lib/ui/index.js +6 -3
  129. package/lib/usageTracking.js +15 -8
  130. package/lib/validation.js +13 -11
  131. package/mcp-server/tools/cms/HsCreateFunctionTool.js +4 -2
  132. package/mcp-server/tools/cms/HsCreateModuleTool.js +4 -2
  133. package/mcp-server/tools/cms/HsCreateTemplateTool.js +4 -2
  134. package/mcp-server/tools/cms/HsFunctionLogsTool.js +4 -2
  135. package/mcp-server/tools/cms/HsListFunctionsTool.js +3 -1
  136. package/mcp-server/tools/cms/HsListTool.js +3 -1
  137. package/mcp-server/tools/cms/__tests__/HsCreateFunctionTool.test.js +1 -0
  138. package/mcp-server/tools/index.js +4 -0
  139. package/mcp-server/tools/project/AddFeatureToProjectTool.js +4 -2
  140. package/mcp-server/tools/project/CreateProjectTool.js +4 -2
  141. package/mcp-server/tools/project/CreateTestAccountTool.js +17 -7
  142. package/mcp-server/tools/project/DeployProjectTool.js +3 -1
  143. package/mcp-server/tools/project/DocFetchTool.js +6 -4
  144. package/mcp-server/tools/project/DocsSearchTool.d.ts +1 -1
  145. package/mcp-server/tools/project/DocsSearchTool.js +10 -8
  146. package/mcp-server/tools/project/GetApiUsagePatternsByAppIdTool.d.ts +1 -1
  147. package/mcp-server/tools/project/GetApiUsagePatternsByAppIdTool.js +9 -7
  148. package/mcp-server/tools/project/GetApplicationInfoTool.js +8 -6
  149. package/mcp-server/tools/project/GetBuildLogsTool.d.ts +26 -0
  150. package/mcp-server/tools/project/GetBuildLogsTool.js +125 -0
  151. package/mcp-server/tools/project/GetBuildStatusTool.d.ts +26 -0
  152. package/mcp-server/tools/project/GetBuildStatusTool.js +166 -0
  153. package/mcp-server/tools/project/GetConfigValuesTool.d.ts +1 -1
  154. package/mcp-server/tools/project/GetConfigValuesTool.js +9 -7
  155. package/mcp-server/tools/project/GuidedWalkthroughTool.d.ts +1 -1
  156. package/mcp-server/tools/project/GuidedWalkthroughTool.js +5 -3
  157. package/mcp-server/tools/project/UploadProjectTools.js +3 -1
  158. package/mcp-server/tools/project/ValidateProjectTool.js +4 -2
  159. package/mcp-server/tools/project/__tests__/CreateTestAccountTool.test.js +12 -2
  160. package/mcp-server/tools/project/__tests__/DocFetchTool.test.js +5 -1
  161. package/mcp-server/tools/project/__tests__/DocsSearchTool.test.js +23 -11
  162. package/mcp-server/tools/project/__tests__/GetApiUsagePatternsByAppIdTool.test.js +7 -5
  163. package/mcp-server/tools/project/__tests__/GetApplicationInfoTool.test.js +7 -5
  164. package/mcp-server/tools/project/__tests__/GetBuildLogsTool.test.d.ts +1 -0
  165. package/mcp-server/tools/project/__tests__/GetBuildLogsTool.test.js +305 -0
  166. package/mcp-server/tools/project/__tests__/GetBuildStatusTool.test.d.ts +1 -0
  167. package/mcp-server/tools/project/__tests__/GetBuildStatusTool.test.js +240 -0
  168. package/mcp-server/tools/project/__tests__/GetConfigValuesTool.test.js +8 -6
  169. package/mcp-server/utils/__tests__/content.test.js +21 -20
  170. package/mcp-server/utils/__tests__/feedbackTracking.test.js +34 -28
  171. package/mcp-server/utils/config.d.ts +1 -0
  172. package/mcp-server/utils/config.js +10 -0
  173. package/mcp-server/utils/content.d.ts +1 -1
  174. package/mcp-server/utils/content.js +2 -2
  175. package/mcp-server/utils/feedbackTracking.d.ts +1 -1
  176. package/mcp-server/utils/feedbackTracking.js +3 -3
  177. package/mcp-server/utils/toolUsageTracking.js +4 -3
  178. package/package.json +9 -9
  179. package/ui/components/BoxWithTitle.d.ts +2 -1
  180. package/ui/components/BoxWithTitle.js +2 -2
  181. package/ui/components/StatusMessageBoxes.d.ts +5 -4
  182. package/ui/components/StatusMessageBoxes.js +8 -8
  183. package/lib/middleware/__test__/notificationsMiddleware.test.js +0 -8
  184. package/lib/middleware/notificationsMiddleware.d.ts +0 -1
  185. package/lib/middleware/notificationsMiddleware.js +0 -28
  186. package/lib/ui/boxen.d.ts +0 -5
  187. package/lib/ui/boxen.js +0 -26
  188. package/mcp-server/utils/__tests__/cliConfig.test.js +0 -110
  189. package/mcp-server/utils/cliConfig.d.ts +0 -1
  190. package/mcp-server/utils/cliConfig.js +0 -12
  191. /package/{lib/middleware/__test__/commandTargetingUtils.test.d.ts → commands/project/__tests__/lint.test.d.ts} +0 -0
  192. /package/lib/middleware/{__test__/configMiddleware.test.d.ts → __tests__/commandTargetingUtils.test.d.ts} +0 -0
  193. /package/lib/middleware/{__test__/gitMiddleware.test.d.ts → __tests__/configMiddleware.test.d.ts} +0 -0
  194. /package/lib/middleware/{__test__/notificationsMiddleware.test.d.ts → __tests__/gitMiddleware.test.d.ts} +0 -0
  195. /package/lib/middleware/{__test__ → __tests__}/requestMiddleware.test.d.ts +0 -0
  196. /package/lib/middleware/{__test__ → __tests__}/requestMiddleware.test.js +0 -0
  197. /package/lib/middleware/{__test__ → __tests__}/yargsChecksMiddleware.test.d.ts +0 -0
  198. /package/lib/middleware/{__test__ → __tests__}/yargsChecksMiddleware.test.js +0 -0
  199. /package/{mcp-server/utils/__tests__/cliConfig.test.d.ts → lib/projects/__tests__/uieLinting.test.d.ts} +0 -0
@@ -1,7 +1,5 @@
1
- import { getAccountId } from '@hubspot/local-dev-lib/config';
2
1
  import { getSandboxUsageLimits } from '@hubspot/local-dev-lib/api/sandboxHubs';
3
2
  import { HUBSPOT_ACCOUNT_TYPES, HUBSPOT_ACCOUNT_TYPE_STRINGS, } from '@hubspot/local-dev-lib/constants/config';
4
- import { getAccountIdentifier } from '@hubspot/local-dev-lib/config/getAccountIdentifier';
5
3
  import { fetchDeveloperTestAccounts } from '@hubspot/local-dev-lib/api/developerTestAccounts';
6
4
  import { promptUser } from './promptUtils.js';
7
5
  import { lib } from '../../lang/en.js';
@@ -12,9 +10,9 @@ import { EXIT_CODES } from '../enums/exitCodes.js';
12
10
  function mapNestedAccount(accountConfig) {
13
11
  const parentAccountId = accountConfig.parentAccountId ?? null;
14
12
  return {
15
- name: uiAccountDescription(getAccountIdentifier(accountConfig), false),
13
+ name: uiAccountDescription(accountConfig.accountId, false),
16
14
  value: {
17
- targetAccountId: getAccountId(accountConfig.name),
15
+ targetAccountId: accountConfig.accountId,
18
16
  createNestedAccount: false,
19
17
  parentAccountId,
20
18
  },
@@ -24,7 +22,7 @@ function getNonConfigDeveloperTestAccountName(account) {
24
22
  return `${account.accountName} [${HUBSPOT_ACCOUNT_TYPE_STRINGS[HUBSPOT_ACCOUNT_TYPES.DEVELOPER_TEST]}] (${account.id})`;
25
23
  }
26
24
  export async function selectSandboxTargetAccountPrompt(accounts, defaultAccountConfig) {
27
- const defaultAccountId = getAccountId(defaultAccountConfig.name);
25
+ const defaultAccountId = defaultAccountConfig.accountId;
28
26
  let choices = [];
29
27
  let sandboxUsage = {
30
28
  STANDARD: { used: 0, available: 0, limit: 0 },
@@ -84,7 +82,7 @@ export async function selectSandboxTargetAccountPrompt(accounts, defaultAccountC
84
82
  return selectTargetAccountPrompt(defaultAccountId, 'sandbox account', choices);
85
83
  }
86
84
  export async function selectDeveloperTestTargetAccountPrompt(accounts, defaultAccountConfig) {
87
- const defaultAccountId = getAccountId(defaultAccountConfig.name);
85
+ const defaultAccountId = defaultAccountConfig.accountId;
88
86
  let devTestAccountsResponse;
89
87
  try {
90
88
  if (defaultAccountId) {
@@ -108,7 +106,7 @@ export async function selectDeveloperTestTargetAccountPrompt(accounts, defaultAc
108
106
  }
109
107
  const devTestAccounts = [];
110
108
  if (devTestAccountsResponse && devTestAccountsResponse.results) {
111
- const accountIds = accounts.map(account => getAccountIdentifier(account));
109
+ const accountIds = accounts.map(account => account.accountId);
112
110
  devTestAccountsResponse.results.forEach(acct => {
113
111
  const inConfig = accountIds.includes(acct.id);
114
112
  devTestAccounts.push({
@@ -2,23 +2,22 @@ import { promptUser } from './promptUtils.js';
2
2
  import { lib } from '../../lang/en.js';
3
3
  import { uiAccountDescription } from '../ui/index.js';
4
4
  import { HUBSPOT_ACCOUNT_TYPES } from '@hubspot/local-dev-lib/constants/config';
5
- import { getAccountIdentifier } from '@hubspot/local-dev-lib/config/getAccountIdentifier';
6
5
  import { isSandbox } from '../accountTypes.js';
7
- import { getConfigDefaultAccount, getConfigAccounts, } from '@hubspot/local-dev-lib/config';
6
+ import { getConfigDefaultAccountIfExists, getAllConfigAccounts, } from '@hubspot/local-dev-lib/config';
8
7
  function mapSandboxAccountChoices(portals) {
9
8
  return (portals
10
9
  ?.filter(p => isSandbox(p))
11
10
  .map(p => ({
12
- name: uiAccountDescription(getAccountIdentifier(p), false),
13
- value: p.name || getAccountIdentifier(p),
11
+ name: uiAccountDescription(p.accountId, false),
12
+ value: p.accountId,
14
13
  })) || []);
15
14
  }
16
15
  function mapNonSandboxAccountChoices(portals) {
17
16
  return (portals
18
17
  ?.filter(p => !isSandbox(p))
19
18
  .map(p => ({
20
- name: `${p.name} (${getAccountIdentifier(p)})`,
21
- value: p.name || getAccountIdentifier(p),
19
+ name: `${p.name} (${p.accountId})`,
20
+ value: p.accountId,
22
21
  })) || []);
23
22
  }
24
23
  export async function sandboxTypePrompt() {
@@ -42,7 +41,7 @@ export async function sandboxTypePrompt() {
42
41
  ]);
43
42
  }
44
43
  export function deleteSandboxPrompt(promptParentAccount = false) {
45
- const accountsList = getConfigAccounts();
44
+ const accountsList = getAllConfigAccounts();
46
45
  const choices = promptParentAccount
47
46
  ? mapNonSandboxAccountChoices(accountsList)
48
47
  : mapSandboxAccountChoices(accountsList);
@@ -58,7 +57,7 @@ export function deleteSandboxPrompt(promptParentAccount = false) {
58
57
  type: 'list',
59
58
  pageSize: 20,
60
59
  choices,
61
- default: getConfigDefaultAccount(),
60
+ default: getConfigDefaultAccountIfExists()?.accountId,
62
61
  },
63
62
  ]);
64
63
  }
@@ -1,25 +1,26 @@
1
- import { updateDefaultAccount, getConfigDefaultAccount, } from '@hubspot/local-dev-lib/config';
1
+ import { setConfigAccountAsDefault, getConfigDefaultAccountIfExists, getAllConfigAccounts, } from '@hubspot/local-dev-lib/config';
2
2
  import { promptUser } from './promptUtils.js';
3
3
  import { lib } from '../../lang/en.js';
4
4
  import { uiLogger } from '../ui/logger.js';
5
5
  export async function setAsDefaultAccountPrompt(accountName) {
6
6
  // Accounts for deprecated and new config
7
- const defaultAccount = getConfigDefaultAccount();
7
+ const defaultAccount = getConfigDefaultAccountIfExists();
8
+ const accounts = getAllConfigAccounts() || [];
8
9
  const { setAsDefault } = await promptUser([
9
10
  {
10
11
  name: 'setAsDefault',
11
12
  type: 'confirm',
12
- when: defaultAccount !== accountName,
13
+ when: accounts.length >= 1 && defaultAccount?.name !== accountName,
13
14
  message: lib.prompts.setAsDefaultAccountPrompt.setAsDefaultAccountMessage,
14
15
  },
15
16
  ]);
16
17
  uiLogger.log('');
17
18
  if (setAsDefault) {
18
- updateDefaultAccount(accountName);
19
+ setConfigAccountAsDefault(accountName);
19
20
  uiLogger.success(lib.prompts.setAsDefaultAccountPrompt.setAsDefaultAccount(accountName));
20
21
  }
21
- else {
22
- uiLogger.log(lib.prompts.setAsDefaultAccountPrompt.keepingCurrentDefault(getConfigDefaultAccount()));
22
+ else if (defaultAccount) {
23
+ uiLogger.log(lib.prompts.setAsDefaultAccountPrompt.keepingCurrentDefault(defaultAccount.name));
23
24
  }
24
25
  return setAsDefault;
25
26
  }
@@ -1,4 +1,4 @@
1
- import { CLIAccount } from '@hubspot/local-dev-lib/types/Accounts';
1
+ import { HubSpotConfigAccount } from '@hubspot/local-dev-lib/types/Accounts';
2
2
  import { Environment } from '@hubspot/local-dev-lib/types/Config';
3
3
  import { SandboxSyncTask } from '../types/Sandboxes.js';
4
- export declare function syncSandbox(accountConfig: CLIAccount, parentAccountConfig: CLIAccount, env: Environment, syncTasks: Array<SandboxSyncTask>, slimInfoMessage?: boolean): Promise<void>;
4
+ export declare function syncSandbox(accountConfig: HubSpotConfigAccount, parentAccountConfig: HubSpotConfigAccount, env: Environment, syncTasks: Array<SandboxSyncTask>, slimInfoMessage?: boolean): Promise<void>;
@@ -3,23 +3,17 @@ import { getHubSpotWebsiteOrigin } from '@hubspot/local-dev-lib/urls';
3
3
  import { uiLogger } from './ui/logger.js';
4
4
  import { initiateSync } from '@hubspot/local-dev-lib/api/sandboxSync';
5
5
  import { isSpecifiedError } from '@hubspot/local-dev-lib/errors/index';
6
- import { getAccountId } from '@hubspot/local-dev-lib/config';
7
- import { getAccountIdentifier } from '@hubspot/local-dev-lib/config/getAccountIdentifier';
8
6
  import { lib } from '../lang/en.js';
9
7
  import { getAvailableSyncTypes, getSandboxTypeAsString } from './sandboxes.js';
10
8
  import { debugError, logError, ApiErrorContext, } from './errorHandlers/index.js';
11
9
  import { uiAccountDescription, uiLine, uiCommandDisabledBanner, } from './ui/index.js';
12
10
  import { isDevelopmentSandbox } from './accountTypes.js';
13
11
  export async function syncSandbox(accountConfig, parentAccountConfig, env, syncTasks, slimInfoMessage = false) {
14
- const id = getAccountIdentifier(accountConfig);
15
- const accountId = getAccountId(id);
16
- const parentId = getAccountIdentifier(parentAccountConfig);
17
- const parentAccountId = getAccountId(parentId);
12
+ const accountId = accountConfig.accountId;
13
+ const parentAccountId = parentAccountConfig.accountId;
18
14
  const isDevSandbox = isDevelopmentSandbox(accountConfig);
19
15
  if (!accountId || !parentAccountId) {
20
- throw new Error(lib.sandbox.sync.failure.invalidUser(accountId ? uiAccountDescription(accountId) : id.toString(), parentAccountId
21
- ? uiAccountDescription(parentAccountId)
22
- : parentId.toString()));
16
+ throw new Error(lib.sandbox.sync.failure.invalidUser(uiAccountDescription(accountId), uiAccountDescription(parentAccountId)));
23
17
  }
24
18
  SpinniesManager.init({
25
19
  succeedColor: 'white',
@@ -1,4 +1,4 @@
1
- import { AccountType, CLIAccount } from '@hubspot/local-dev-lib/types/Accounts';
1
+ import { AccountType, HubSpotConfigAccount } from '@hubspot/local-dev-lib/types/Accounts';
2
2
  import { Environment } from '@hubspot/local-dev-lib/types/Config';
3
3
  import { SandboxSyncTask, SandboxAccountType } from '../types/Sandboxes.js';
4
4
  export declare const SYNC_TYPES: {
@@ -16,7 +16,7 @@ export declare const SANDBOX_TYPE_MAP_V2: {
16
16
  readonly DEVELOPMENT_SANDBOX: "DEVELOPER";
17
17
  };
18
18
  export declare function getSandboxTypeAsString(accountType?: AccountType): string;
19
- export declare function getHasSandboxesByType(parentAccountConfig: CLIAccount, type: AccountType): boolean;
20
- export declare function getAvailableSyncTypes(parentAccountConfig: CLIAccount, config: CLIAccount): Promise<Array<SandboxSyncTask>>;
21
- export declare function validateSandboxUsageLimits(accountConfig: CLIAccount, sandboxType: AccountType, env: Environment): Promise<void>;
19
+ export declare function getHasSandboxesByType(parentAccountConfig: HubSpotConfigAccount, type: AccountType): boolean;
20
+ export declare function getAvailableSyncTypes(parentAccountConfig: HubSpotConfigAccount, config: HubSpotConfigAccount): Promise<Array<SandboxSyncTask>>;
21
+ export declare function validateSandboxUsageLimits(accountConfig: HubSpotConfigAccount, sandboxType: AccountType, env: Environment): Promise<void>;
22
22
  export declare function handleSandboxCreateError(err: unknown, env: Environment, name: string, accountId: number): never;
package/lib/sandboxes.js CHANGED
@@ -1,9 +1,8 @@
1
1
  import { getSandboxUsageLimits } from '@hubspot/local-dev-lib/api/sandboxHubs';
2
2
  import { fetchTypes } from '@hubspot/local-dev-lib/api/sandboxSync';
3
- import { getAccountId, getConfigAccounts } from '@hubspot/local-dev-lib/config';
3
+ import { getAllConfigAccounts } from '@hubspot/local-dev-lib/config';
4
4
  import { getHubSpotWebsiteOrigin } from '@hubspot/local-dev-lib/urls';
5
5
  import { HUBSPOT_ACCOUNT_TYPES } from '@hubspot/local-dev-lib/constants/config';
6
- import { getAccountIdentifier } from '@hubspot/local-dev-lib/config/getAccountIdentifier';
7
6
  import { isMissingScopeError, isSpecifiedError, } from '@hubspot/local-dev-lib/errors/index';
8
7
  import { uiLogger } from './ui/logger.js';
9
8
  import { lib } from '../lang/en.js';
@@ -33,9 +32,8 @@ export function getSandboxTypeAsString(accountType) {
33
32
  return 'standard';
34
33
  }
35
34
  export function getHasSandboxesByType(parentAccountConfig, type) {
36
- const id = getAccountIdentifier(parentAccountConfig);
37
- const parentPortalId = getAccountId(id);
38
- const accountsList = getConfigAccounts() || [];
35
+ const parentPortalId = parentAccountConfig.accountId;
36
+ const accountsList = getAllConfigAccounts();
39
37
  for (const portal of accountsList) {
40
38
  if ((portal.parentAccountId !== null ||
41
39
  portal.parentAccountId !== undefined) &&
@@ -49,10 +47,8 @@ export function getHasSandboxesByType(parentAccountConfig, type) {
49
47
  }
50
48
  // Fetches available sync types for a given sandbox portal
51
49
  export async function getAvailableSyncTypes(parentAccountConfig, config) {
52
- const parentId = getAccountIdentifier(parentAccountConfig);
53
- const parentPortalId = getAccountId(parentId);
54
- const id = getAccountIdentifier(config);
55
- const portalId = getAccountId(id);
50
+ const parentPortalId = parentAccountConfig.accountId;
51
+ const portalId = config.accountId;
56
52
  if (!parentPortalId || !portalId) {
57
53
  throw new Error(lib.sandbox.sync.failure.syncTypeFetch);
58
54
  }
@@ -63,8 +59,7 @@ export async function getAvailableSyncTypes(parentAccountConfig, config) {
63
59
  return syncTypes.map(t => ({ type: t.name }));
64
60
  }
65
61
  export async function validateSandboxUsageLimits(accountConfig, sandboxType, env) {
66
- const id = getAccountIdentifier(accountConfig);
67
- const accountId = getAccountId(id);
62
+ const accountId = accountConfig.accountId;
68
63
  if (!accountId) {
69
64
  throw new Error(lib.sandbox.create.failure.usageLimitsFetch);
70
65
  }
@@ -3,7 +3,7 @@ import chalk from 'chalk';
3
3
  import { uiLogger } from './ui/logger.js';
4
4
  import { isHubSpotHttpError, isMissingScopeError, } from '@hubspot/local-dev-lib/errors/index';
5
5
  import { SCOPE_GROUPS, PERSONAL_ACCESS_KEY_AUTH_METHOD, } from '@hubspot/local-dev-lib/constants/auth';
6
- import { getAccountConfig } from '@hubspot/local-dev-lib/config';
6
+ import { getConfigAccountById } from '@hubspot/local-dev-lib/config';
7
7
  import { fetchScopeData } from '@hubspot/local-dev-lib/api/localDevAuth';
8
8
  import { outputLogs } from './ui/serverlessFunctionLogs.js';
9
9
  import { logError, ApiErrorContext } from './errorHandlers/index.js';
@@ -33,7 +33,7 @@ function handleUserInput() {
33
33
  });
34
34
  }
35
35
  async function verifyAccessKeyAndUserAccess(accountId, scopeGroup) {
36
- const accountConfig = getAccountConfig(accountId);
36
+ const accountConfig = getConfigAccountById(accountId);
37
37
  if (!accountConfig) {
38
38
  return;
39
39
  }
@@ -1,4 +1,5 @@
1
1
  import { getProjectThemeDetails, migrateThemes, } from '@hubspot/project-parsing-lib';
2
+ import { getConfigAccountById } from '@hubspot/local-dev-lib/config';
2
3
  import { confirmPrompt } from '../../prompts/promptUtils.js';
3
4
  import { writeProjectConfig, } from '../../projects/config.js';
4
5
  import { ensureProjectExists } from '../../projects/ensureProjectExists.js';
@@ -13,6 +14,7 @@ vi.mock('../../projects/config');
13
14
  vi.mock('../../projects/ensureProjectExists');
14
15
  vi.mock('../../projects/platformVersion');
15
16
  vi.mock('../../app/migrate');
17
+ vi.mock('@hubspot/local-dev-lib/config');
16
18
  const mockedGetProjectThemeDetails = getProjectThemeDetails;
17
19
  const mockedMigrateThemes = migrateThemes;
18
20
  const mockedConfirmPrompt = confirmPrompt;
@@ -20,6 +22,7 @@ const mockedWriteProjectConfig = writeProjectConfig;
20
22
  const mockedEnsureProjectExists = ensureProjectExists;
21
23
  const mockedUseV2Api = isV2Project;
22
24
  const mockedFetchMigrationApps = fetchMigrationApps;
25
+ const mockedGetConfigAccountById = getConfigAccountById;
23
26
  const ACCOUNT_ID = 123;
24
27
  const PROJECT_NAME = 'Test Project';
25
28
  const PLATFORM_VERSION = '2025.2';
@@ -31,6 +34,18 @@ const createLoadedProjectConfig = (name) => ({
31
34
  describe('lib/theme/migrate', () => {
32
35
  beforeEach(() => {
33
36
  mockedUseV2Api.mockReturnValue(false);
37
+ // Mock account config for the test account ID
38
+ mockedGetConfigAccountById.mockReturnValue({
39
+ accountId: ACCOUNT_ID,
40
+ name: 'Test Account',
41
+ authType: 'personalaccesskey',
42
+ auth: {
43
+ tokenInfo: {
44
+ accessToken: 'test-token',
45
+ },
46
+ },
47
+ env: 'prod',
48
+ });
34
49
  });
35
50
  describe('getHasMigratableThemes', () => {
36
51
  it('should return false when no projectConfig is provided', async () => {
package/lib/ui/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import chalk from 'chalk';
2
- import { getAccountConfig, configFileExists, } from '@hubspot/local-dev-lib/config';
2
+ import { getConfigAccountIfExists, globalConfigFileExists, } from '@hubspot/local-dev-lib/config';
3
3
  import { uiLogger } from './logger.js';
4
4
  import { supportsHyperlinkModule } from './supportHyperlinks.js';
5
5
  import { supportsColor } from './supportsColor.js';
@@ -38,7 +38,7 @@ export function uiLink(linkText, url) {
38
38
  : `${linkText}: ${encodedUrl}`;
39
39
  }
40
40
  export function uiAccountDescription(accountId, bold = true) {
41
- const account = getAccountConfig(accountId || undefined);
41
+ const account = accountId ? getConfigAccountIfExists(accountId) : undefined;
42
42
  let message;
43
43
  if (account && account.accountType) {
44
44
  message = `${account.name ? `${account.name} ` : ''}[${HUBSPOT_ACCOUNT_TYPE_STRINGS[account.accountType]}] (${accountId})`;
@@ -46,6 +46,9 @@ export function uiAccountDescription(accountId, bold = true) {
46
46
  else {
47
47
  message = accountId ? accountId.toString() : '';
48
48
  }
49
+ if (message.trim().length === 0) {
50
+ return 'unknown account';
51
+ }
49
52
  return bold ? chalk.bold(message) : message;
50
53
  }
51
54
  export function uiInfoSection(title, logContent) {
@@ -64,7 +67,7 @@ export function uiCommandReference(command, withQuotes = true) {
64
67
  : commandReference);
65
68
  }
66
69
  export function uiAuthCommandReference({ accountId, qa, } = {}) {
67
- const userIsUsingGlobalConfig = configFileExists(true);
70
+ const userIsUsingGlobalConfig = globalConfigFileExists();
68
71
  let command = 'hs auth';
69
72
  if (userIsUsingGlobalConfig) {
70
73
  command = 'hs account auth';
@@ -1,5 +1,5 @@
1
1
  import { trackUsage } from '@hubspot/local-dev-lib/trackUsage';
2
- import { isTrackingAllowed, getAccountConfig, } from '@hubspot/local-dev-lib/config';
2
+ import { getConfigAccountById, getConfig } from '@hubspot/local-dev-lib/config';
3
3
  import { API_KEY_AUTH_METHOD } from '@hubspot/local-dev-lib/constants/auth';
4
4
  import { uiLogger } from './ui/logger.js';
5
5
  import { pkg } from './jsonLoader.js';
@@ -28,13 +28,17 @@ export function getPlatform() {
28
28
  }
29
29
  }
30
30
  export async function trackCommandUsage(command, meta = {}, accountId) {
31
- if (!isTrackingAllowed()) {
32
- return;
31
+ try {
32
+ const config = getConfig();
33
+ if (config?.allowUsageTracking === false) {
34
+ return;
35
+ }
33
36
  }
37
+ catch (e) { }
34
38
  uiLogger.debug(`Attempting to track usage of "${command}" command`);
35
39
  let authType = 'unknown';
36
40
  if (accountId) {
37
- const accountConfig = getAccountConfig(accountId);
41
+ const accountConfig = getConfigAccountById(accountId);
38
42
  authType =
39
43
  accountConfig && accountConfig.authType
40
44
  ? accountConfig.authType
@@ -49,7 +53,8 @@ export async function trackCommandUsage(command, meta = {}, accountId) {
49
53
  });
50
54
  }
51
55
  export async function trackHelpUsage(command) {
52
- if (!isTrackingAllowed()) {
56
+ const config = getConfig();
57
+ if (config?.allowUsageTracking === false) {
53
58
  return;
54
59
  }
55
60
  if (command) {
@@ -81,13 +86,14 @@ export async function trackAuthAction(command, authType, step, accountId) {
81
86
  });
82
87
  }
83
88
  export async function trackCommandMetadataUsage(command, meta = {}, accountId) {
84
- if (!isTrackingAllowed()) {
89
+ const config = getConfig();
90
+ if (config?.allowUsageTracking === false) {
85
91
  return;
86
92
  }
87
93
  uiLogger.debug(`Attempting to track metadata usage of "${command}" command`);
88
94
  let authType = 'unknown';
89
95
  if (accountId) {
90
- const accountConfig = getAccountConfig(accountId);
96
+ const accountConfig = getConfigAccountById(accountId);
91
97
  authType =
92
98
  accountConfig && accountConfig.authType
93
99
  ? accountConfig.authType
@@ -103,7 +109,8 @@ export async function trackCommandMetadataUsage(command, meta = {}, accountId) {
103
109
  }
104
110
  async function trackCliInteraction({ action, accountId, command, authType, meta = {}, }) {
105
111
  try {
106
- if (!isTrackingAllowed()) {
112
+ const config = getConfig();
113
+ if (config?.allowUsageTracking === false) {
107
114
  return;
108
115
  }
109
116
  const usageTrackingEvent = {
package/lib/validation.js CHANGED
@@ -4,16 +4,17 @@ import { uiLogger } from '../lib/ui/logger.js';
4
4
  import { CMS_PUBLISH_MODE } from '@hubspot/local-dev-lib/constants/files';
5
5
  import { API_KEY_AUTH_METHOD, OAUTH_AUTH_METHOD, PERSONAL_ACCESS_KEY_AUTH_METHOD, } from '@hubspot/local-dev-lib/constants/auth';
6
6
  import { commaSeparatedValues } from '@hubspot/local-dev-lib/text';
7
- import { getConfigPath, getAccountConfig, getAccountId, loadConfigFromEnvironment, } from '@hubspot/local-dev-lib/config';
7
+ import { getConfigFilePath, getConfigAccountById, } from '@hubspot/local-dev-lib/config';
8
8
  import { getOauthManager } from '@hubspot/local-dev-lib/oauth';
9
9
  import { accessTokenForPersonalAccessKey } from '@hubspot/local-dev-lib/personalAccessKey';
10
10
  import { getAbsoluteFilePath, getCwd, getExt, } from '@hubspot/local-dev-lib/path';
11
+ import { ENVIRONMENT_VARIABLES } from '@hubspot/local-dev-lib/constants/config';
11
12
  import { getCmsPublishMode } from './commonOpts.js';
12
13
  import { logError } from './errorHandlers/index.js';
13
14
  import { lib } from '../lang/en.js';
14
15
  export async function validateAccount(options) {
15
16
  const { derivedAccountId, userProvidedAccount } = options;
16
- const accountId = getAccountId(derivedAccountId);
17
+ const accountId = derivedAccountId;
17
18
  if (!accountId) {
18
19
  if (userProvidedAccount) {
19
20
  uiLogger.error(lib.validation.accountNotFoundInConfig(userProvidedAccount));
@@ -23,33 +24,34 @@ export async function validateAccount(options) {
23
24
  }
24
25
  return false;
25
26
  }
26
- if (userProvidedAccount && loadConfigFromEnvironment()) {
27
+ if (userProvidedAccount &&
28
+ process.env[ENVIRONMENT_VARIABLES.USE_ENVIRONMENT_HUBSPOT_CONFIG]) {
27
29
  throw new Error(lib.validation.userProvidedAccount);
28
30
  }
29
- const accountConfig = getAccountConfig(accountId);
31
+ const accountConfig = getConfigAccountById(accountId);
30
32
  if (!accountConfig) {
31
33
  uiLogger.error(lib.validation.accountNotConfigured(accountId));
32
34
  return false;
33
35
  }
34
- const { authType, auth, apiKey, personalAccessKey } = accountConfig;
36
+ const { authType } = accountConfig;
35
37
  if (typeof authType === 'string' && authType !== authType.toLowerCase()) {
36
- uiLogger.error(lib.validation.invalidAuthType(authType, accountId, getConfigPath() || '', commaSeparatedValues([
38
+ uiLogger.error(lib.validation.invalidAuthType(authType, accountId, getConfigFilePath(), commaSeparatedValues([
37
39
  PERSONAL_ACCESS_KEY_AUTH_METHOD,
38
40
  OAUTH_AUTH_METHOD,
39
41
  API_KEY_AUTH_METHOD,
40
42
  ].map(method => method.value))));
41
43
  }
42
44
  if (authType === 'oauth2') {
43
- if (typeof auth !== 'object') {
45
+ if (typeof accountConfig.auth !== 'object') {
44
46
  uiLogger.error(lib.validation.oauth2ConfigMissing(accountId));
45
47
  return false;
46
48
  }
47
- const { clientId, clientSecret, tokenInfo } = auth;
49
+ const { clientId, clientSecret, tokenInfo } = accountConfig.auth;
48
50
  if (!clientId || !clientSecret || !tokenInfo || !tokenInfo.refreshToken) {
49
51
  uiLogger.error(lib.validation.oauth2ConfigIncorrect(accountId));
50
52
  return false;
51
53
  }
52
- const oauth = getOauthManager(accountId, accountConfig);
54
+ const oauth = getOauthManager(accountConfig);
53
55
  try {
54
56
  let accessToken;
55
57
  if (oauth) {
@@ -66,7 +68,7 @@ export async function validateAccount(options) {
66
68
  }
67
69
  }
68
70
  else if (authType === 'personalaccesskey') {
69
- if (!personalAccessKey) {
71
+ if (!accountConfig.personalAccessKey) {
70
72
  uiLogger.error(lib.validation.personalAccessKeyMissing(accountId));
71
73
  return false;
72
74
  }
@@ -82,7 +84,7 @@ export async function validateAccount(options) {
82
84
  return false;
83
85
  }
84
86
  }
85
- else if (!apiKey) {
87
+ else if (!accountConfig.apiKey) {
86
88
  uiLogger.error(lib.validation.authConfigurationMissing(accountId));
87
89
  return false;
88
90
  }
@@ -6,6 +6,7 @@ import { formatTextContents, formatTextContent } from '../../utils/content.js';
6
6
  import { trackToolUsage } from '../../utils/toolUsageTracking.js';
7
7
  import { addFlag } from '../../utils/command.js';
8
8
  import { HTTP_METHODS } from '../../../types/Cms.js';
9
+ import { setupHubSpotConfig } from '../../utils/config.js';
9
10
  const inputSchema = {
10
11
  absoluteCurrentWorkingDirectory,
11
12
  dest: z
@@ -37,6 +38,7 @@ export class HsCreateFunctionTool extends Tool {
37
38
  super(mcpServer);
38
39
  }
39
40
  async handler({ dest, functionsFolder, filename, endpointMethod, endpointPath, absoluteCurrentWorkingDirectory, }) {
41
+ setupHubSpotConfig(absoluteCurrentWorkingDirectory);
40
42
  await trackToolUsage(toolName);
41
43
  const content = [];
42
44
  // Require functions folder
@@ -80,10 +82,10 @@ export class HsCreateFunctionTool extends Tool {
80
82
  }
81
83
  try {
82
84
  const { stdout, stderr } = await runCommandInDir(absoluteCurrentWorkingDirectory, command);
83
- return formatTextContents(absoluteCurrentWorkingDirectory, stdout, stderr);
85
+ return formatTextContents(stdout, stderr);
84
86
  }
85
87
  catch (error) {
86
- return formatTextContents(absoluteCurrentWorkingDirectory, error instanceof Error ? error.message : `${error}`);
88
+ return formatTextContents(error instanceof Error ? error.message : `${error}`);
87
89
  }
88
90
  }
89
91
  register() {
@@ -6,6 +6,7 @@ import { formatTextContents, formatTextContent } from '../../utils/content.js';
6
6
  import { trackToolUsage } from '../../utils/toolUsageTracking.js';
7
7
  import { addFlag } from '../../utils/command.js';
8
8
  import { CONTENT_TYPES } from '../../../types/Cms.js';
9
+ import { setupHubSpotConfig } from '../../utils/config.js';
9
10
  const inputSchema = {
10
11
  absoluteCurrentWorkingDirectory,
11
12
  userSuppliedName: z
@@ -53,6 +54,7 @@ export class HsCreateModuleTool extends Tool {
53
54
  super(mcpServer);
54
55
  }
55
56
  async handler({ userSuppliedName, dest, moduleLabel, reactType, contentTypes, global, availableForNewContent, absoluteCurrentWorkingDirectory, }) {
57
+ setupHubSpotConfig(absoluteCurrentWorkingDirectory);
56
58
  await trackToolUsage(toolName);
57
59
  const content = [];
58
60
  // Always require a name
@@ -102,10 +104,10 @@ export class HsCreateModuleTool extends Tool {
102
104
  }
103
105
  try {
104
106
  const { stdout, stderr } = await runCommandInDir(absoluteCurrentWorkingDirectory, command);
105
- return formatTextContents(absoluteCurrentWorkingDirectory, stdout, stderr);
107
+ return formatTextContents(stdout, stderr);
106
108
  }
107
109
  catch (error) {
108
- return formatTextContents(absoluteCurrentWorkingDirectory, error instanceof Error ? error.message : `${error}`);
110
+ return formatTextContents(error instanceof Error ? error.message : `${error}`);
109
111
  }
110
112
  }
111
113
  register() {
@@ -6,6 +6,7 @@ import { formatTextContents, formatTextContent } from '../../utils/content.js';
6
6
  import { trackToolUsage } from '../../utils/toolUsageTracking.js';
7
7
  import { addFlag } from '../../utils/command.js';
8
8
  import { TEMPLATE_TYPES } from '../../../types/Cms.js';
9
+ import { setupHubSpotConfig } from '../../utils/config.js';
9
10
  const inputSchema = {
10
11
  absoluteCurrentWorkingDirectory,
11
12
  userSuppliedName: z
@@ -29,6 +30,7 @@ export class HsCreateTemplateTool extends Tool {
29
30
  super(mcpServer);
30
31
  }
31
32
  async handler({ userSuppliedName, dest, templateType, absoluteCurrentWorkingDirectory, }) {
33
+ setupHubSpotConfig(absoluteCurrentWorkingDirectory);
32
34
  await trackToolUsage(toolName);
33
35
  const content = [];
34
36
  // Always require a name
@@ -59,10 +61,10 @@ export class HsCreateTemplateTool extends Tool {
59
61
  }
60
62
  try {
61
63
  const { stdout, stderr } = await runCommandInDir(absoluteCurrentWorkingDirectory, command);
62
- return formatTextContents(absoluteCurrentWorkingDirectory, stdout, stderr);
64
+ return formatTextContents(stdout, stderr);
63
65
  }
64
66
  catch (error) {
65
- return formatTextContents(absoluteCurrentWorkingDirectory, error instanceof Error ? error.message : `${error}`);
67
+ return formatTextContents(error instanceof Error ? error.message : `${error}`);
66
68
  }
67
69
  }
68
70
  register() {
@@ -5,6 +5,7 @@ import { absoluteCurrentWorkingDirectory } from '../project/constants.js';
5
5
  import { runCommandInDir } from '../../utils/project.js';
6
6
  import { formatTextContents } from '../../utils/content.js';
7
7
  import { trackToolUsage } from '../../utils/toolUsageTracking.js';
8
+ import { setupHubSpotConfig } from '../../utils/config.js';
8
9
  const inputSchema = {
9
10
  absoluteCurrentWorkingDirectory,
10
11
  endpoint: z
@@ -32,6 +33,7 @@ export class HsFunctionLogsTool extends Tool {
32
33
  super(mcpServer);
33
34
  }
34
35
  async handler({ endpoint, account, latest, compact, limit, absoluteCurrentWorkingDirectory, }) {
36
+ setupHubSpotConfig(absoluteCurrentWorkingDirectory);
35
37
  await trackToolUsage(toolName);
36
38
  // Ensure endpoint doesn't start with '/'
37
39
  const normalizedEndpoint = endpoint.startsWith('/')
@@ -52,11 +54,11 @@ export class HsFunctionLogsTool extends Tool {
52
54
  }
53
55
  try {
54
56
  const { stdout, stderr } = await runCommandInDir(absoluteCurrentWorkingDirectory, command);
55
- return formatTextContents(absoluteCurrentWorkingDirectory, stdout, stderr);
57
+ return formatTextContents(stdout, stderr);
56
58
  }
57
59
  catch (error) {
58
60
  const errorMessage = error instanceof Error ? error.message : String(error);
59
- return formatTextContents(absoluteCurrentWorkingDirectory, `Error executing hs logs command: ${errorMessage}`);
61
+ return formatTextContents(`Error executing hs logs command: ${errorMessage}`);
60
62
  }
61
63
  }
62
64
  register() {
@@ -5,6 +5,7 @@ import { absoluteCurrentWorkingDirectory } from '../project/constants.js';
5
5
  import { runCommandInDir } from '../../utils/project.js';
6
6
  import { formatTextContents } from '../../utils/content.js';
7
7
  import { trackToolUsage } from '../../utils/toolUsageTracking.js';
8
+ import { setupHubSpotConfig } from '../../utils/config.js';
8
9
  const inputSchema = {
9
10
  absoluteCurrentWorkingDirectory,
10
11
  account: z
@@ -24,6 +25,7 @@ export class HsListFunctionsTool extends Tool {
24
25
  super(mcpServer);
25
26
  }
26
27
  async handler({ account, json, absoluteCurrentWorkingDirectory, }) {
28
+ setupHubSpotConfig(absoluteCurrentWorkingDirectory);
27
29
  await trackToolUsage(toolName);
28
30
  let command = 'hs function list';
29
31
  if (json) {
@@ -34,7 +36,7 @@ export class HsListFunctionsTool extends Tool {
34
36
  }
35
37
  try {
36
38
  const { stdout, stderr } = await runCommandInDir(absoluteCurrentWorkingDirectory, command);
37
- return formatTextContents(absoluteCurrentWorkingDirectory, stdout, stderr);
39
+ return formatTextContents(stdout, stderr);
38
40
  }
39
41
  catch (error) {
40
42
  const errorMessage = error instanceof Error ? error.message : String(error);
@@ -5,6 +5,7 @@ import { absoluteCurrentWorkingDirectory } from '../project/constants.js';
5
5
  import { runCommandInDir } from '../../utils/project.js';
6
6
  import { formatTextContents } from '../../utils/content.js';
7
7
  import { trackToolUsage } from '../../utils/toolUsageTracking.js';
8
+ import { setupHubSpotConfig } from '../../utils/config.js';
8
9
  const inputSchema = {
9
10
  absoluteCurrentWorkingDirectory,
10
11
  path: z
@@ -24,6 +25,7 @@ export class HsListTool extends Tool {
24
25
  super(mcpServer);
25
26
  }
26
27
  async handler({ path, account, absoluteCurrentWorkingDirectory, }) {
28
+ setupHubSpotConfig(absoluteCurrentWorkingDirectory);
27
29
  await trackToolUsage(toolName);
28
30
  let command = 'hs list';
29
31
  if (path) {
@@ -34,7 +36,7 @@ export class HsListTool extends Tool {
34
36
  }
35
37
  try {
36
38
  const { stdout, stderr } = await runCommandInDir(absoluteCurrentWorkingDirectory, command);
37
- return formatTextContents(absoluteCurrentWorkingDirectory, stdout, stderr);
39
+ return formatTextContents(stdout, stderr);
38
40
  }
39
41
  catch (error) {
40
42
  const errorMessage = error instanceof Error ? error.message : String(error);
@@ -10,6 +10,7 @@ vi.mock('../../../utils/toolUsageTracking', () => ({
10
10
  trackToolUsage: vi.fn(),
11
11
  }));
12
12
  vi.mock('../../../utils/feedbackTracking');
13
+ vi.mock('@hubspot/local-dev-lib/config');
13
14
  const mockMcpFeedbackRequest = mcpFeedbackRequest;
14
15
  const mockRunCommandInDir = runCommandInDir;
15
16
  const mockAddFlag = addFlag;