@hubspot/cli 7.10.0 → 7.11.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (211) 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 +16 -11
  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 +2 -2
  29. package/commands/project/cloneApp.js +2 -2
  30. package/commands/project/create.js +20 -14
  31. package/commands/project/deploy.js +2 -2
  32. package/commands/project/dev/deprecatedFlow.js +4 -5
  33. package/commands/project/dev/index.js +6 -3
  34. package/commands/project/dev/unifiedFlow.js +11 -6
  35. package/commands/project/lint.d.ts +6 -0
  36. package/commands/project/lint.js +178 -0
  37. package/commands/project/logs.js +2 -3
  38. package/commands/project/migrate.js +4 -13
  39. package/commands/project/profile/add.js +6 -7
  40. package/commands/project/profile/delete.js +2 -2
  41. package/commands/project/upload.js +2 -2
  42. package/commands/project/validate.js +2 -2
  43. package/commands/project.js +2 -0
  44. package/commands/sandbox/__tests__/create.test.js +14 -5
  45. package/commands/sandbox/create.js +4 -5
  46. package/commands/sandbox/delete.js +23 -20
  47. package/commands/testAccount/create.js +2 -2
  48. package/commands/testAccount/delete.js +9 -8
  49. package/lang/en.d.ts +54 -12
  50. package/lang/en.js +64 -16
  51. package/lib/__tests__/buildAccount.test.js +22 -30
  52. package/lib/__tests__/commonOpts.test.js +9 -13
  53. package/lib/__tests__/developerTestAccounts.test.js +29 -17
  54. package/lib/__tests__/importData.test.js +20 -10
  55. package/lib/__tests__/oauth.test.js +19 -8
  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/errorHandlers/index.js +10 -7
  80. package/lib/importData.js +8 -7
  81. package/lib/links.js +5 -5
  82. package/lib/middleware/{__test__ → __tests__}/commandTargetingUtils.test.js +3 -3
  83. package/lib/middleware/{__test__ → __tests__}/configMiddleware.test.js +23 -22
  84. package/lib/middleware/{__test__ → __tests__}/gitMiddleware.test.js +9 -7
  85. package/lib/middleware/autoUpdateMiddleware.js +34 -23
  86. package/lib/middleware/commandTargetingUtils.js +3 -2
  87. package/lib/middleware/configMiddleware.d.ts +6 -1
  88. package/lib/middleware/configMiddleware.js +36 -15
  89. package/lib/middleware/fireAlarmMiddleware.js +4 -15
  90. package/lib/middleware/gitMiddleware.js +8 -4
  91. package/lib/oauth.d.ts +2 -2
  92. package/lib/oauth.js +8 -10
  93. package/lib/projects/__tests__/AppDevModeInterface.test.js +17 -6
  94. package/lib/projects/__tests__/DevServerManager.test.js +1 -0
  95. package/lib/projects/__tests__/LocalDevProcess.test.js +1 -0
  96. package/lib/projects/__tests__/components.test.js +2 -22
  97. package/lib/projects/__tests__/deploy.test.js +16 -13
  98. package/lib/projects/__tests__/uieLinting.test.js +640 -0
  99. package/lib/projects/add/__tests__/legacyAddComponent.test.js +1 -1
  100. package/lib/projects/add/__tests__/v2AddComponent.test.js +30 -4
  101. package/lib/projects/add/legacyAddComponent.js +1 -1
  102. package/lib/projects/add/v2AddComponent.js +16 -5
  103. package/lib/projects/components.d.ts +8 -1
  104. package/lib/projects/components.js +91 -8
  105. package/lib/projects/create/__tests__/v2.test.js +11 -0
  106. package/lib/projects/deploy.js +21 -8
  107. package/lib/projects/localDev/AppDevModeInterface.js +2 -2
  108. package/lib/projects/localDev/DevServerManager_DEPRECATED.js +11 -3
  109. package/lib/projects/localDev/LocalDevLogger.js +4 -4
  110. package/lib/projects/localDev/LocalDevManager_DEPRECATED.js +3 -3
  111. package/lib/projects/localDev/helpers/account.d.ts +10 -10
  112. package/lib/projects/localDev/helpers/account.js +6 -11
  113. package/lib/projects/localDev/helpers/process.js +5 -3
  114. package/lib/projects/uieLinting.d.ts +33 -0
  115. package/lib/projects/uieLinting.js +222 -0
  116. package/lib/projects/urls.js +5 -6
  117. package/lib/prompts/__tests__/downloadProjectPrompt.test.js +7 -5
  118. package/lib/prompts/accountNamePrompt.js +3 -3
  119. package/lib/prompts/accountsPrompt.d.ts +1 -1
  120. package/lib/prompts/accountsPrompt.js +6 -7
  121. package/lib/prompts/confirmImportDataPrompt.js +2 -2
  122. package/lib/prompts/downloadProjectPrompt.d.ts +1 -0
  123. package/lib/prompts/downloadProjectPrompt.js +5 -2
  124. package/lib/prompts/importDataTestAccountSelectPrompt.js +4 -5
  125. package/lib/prompts/personalAccessKeyPrompt.js +2 -2
  126. package/lib/prompts/projectDevTargetAccountPrompt.d.ts +3 -3
  127. package/lib/prompts/projectDevTargetAccountPrompt.js +5 -7
  128. package/lib/prompts/sandboxesPrompt.js +7 -8
  129. package/lib/prompts/setAsDefaultAccountPrompt.js +7 -6
  130. package/lib/sandboxSync.d.ts +2 -2
  131. package/lib/sandboxSync.js +3 -9
  132. package/lib/sandboxes.d.ts +4 -4
  133. package/lib/sandboxes.js +6 -11
  134. package/lib/serverlessLogs.js +2 -2
  135. package/lib/theme/__tests__/migrate.test.js +15 -0
  136. package/lib/ui/SpinniesManager.d.ts +5 -7
  137. package/lib/ui/SpinniesManager.js +9 -12
  138. package/lib/ui/__tests__/SpinniesManager.test.d.ts +1 -0
  139. package/lib/ui/__tests__/SpinniesManager.test.js +489 -0
  140. package/lib/ui/index.js +6 -3
  141. package/lib/usageTracking.js +15 -8
  142. package/lib/validation.js +13 -11
  143. package/mcp-server/tools/cms/HsCreateFunctionTool.js +4 -2
  144. package/mcp-server/tools/cms/HsCreateModuleTool.js +4 -2
  145. package/mcp-server/tools/cms/HsCreateTemplateTool.js +4 -2
  146. package/mcp-server/tools/cms/HsFunctionLogsTool.js +4 -2
  147. package/mcp-server/tools/cms/HsListFunctionsTool.js +3 -1
  148. package/mcp-server/tools/cms/HsListTool.js +3 -1
  149. package/mcp-server/tools/cms/__tests__/HsCreateFunctionTool.test.js +1 -0
  150. package/mcp-server/tools/index.js +4 -0
  151. package/mcp-server/tools/project/AddFeatureToProjectTool.js +4 -2
  152. package/mcp-server/tools/project/CreateProjectTool.js +4 -2
  153. package/mcp-server/tools/project/CreateTestAccountTool.js +17 -7
  154. package/mcp-server/tools/project/DeployProjectTool.js +3 -1
  155. package/mcp-server/tools/project/DocFetchTool.js +6 -4
  156. package/mcp-server/tools/project/DocsSearchTool.d.ts +1 -1
  157. package/mcp-server/tools/project/DocsSearchTool.js +10 -8
  158. package/mcp-server/tools/project/GetApiUsagePatternsByAppIdTool.d.ts +1 -1
  159. package/mcp-server/tools/project/GetApiUsagePatternsByAppIdTool.js +9 -7
  160. package/mcp-server/tools/project/GetApplicationInfoTool.js +8 -6
  161. package/mcp-server/tools/project/GetBuildLogsTool.d.ts +26 -0
  162. package/mcp-server/tools/project/GetBuildLogsTool.js +125 -0
  163. package/mcp-server/tools/project/GetBuildStatusTool.d.ts +26 -0
  164. package/mcp-server/tools/project/GetBuildStatusTool.js +166 -0
  165. package/mcp-server/tools/project/GetConfigValuesTool.d.ts +1 -1
  166. package/mcp-server/tools/project/GetConfigValuesTool.js +9 -7
  167. package/mcp-server/tools/project/GuidedWalkthroughTool.d.ts +1 -1
  168. package/mcp-server/tools/project/GuidedWalkthroughTool.js +5 -3
  169. package/mcp-server/tools/project/UploadProjectTools.js +3 -1
  170. package/mcp-server/tools/project/ValidateProjectTool.js +4 -2
  171. package/mcp-server/tools/project/__tests__/CreateTestAccountTool.test.js +12 -2
  172. package/mcp-server/tools/project/__tests__/DocFetchTool.test.js +5 -1
  173. package/mcp-server/tools/project/__tests__/DocsSearchTool.test.js +23 -11
  174. package/mcp-server/tools/project/__tests__/GetApiUsagePatternsByAppIdTool.test.js +7 -5
  175. package/mcp-server/tools/project/__tests__/GetApplicationInfoTool.test.js +7 -5
  176. package/mcp-server/tools/project/__tests__/GetBuildLogsTool.test.d.ts +1 -0
  177. package/mcp-server/tools/project/__tests__/GetBuildLogsTool.test.js +305 -0
  178. package/mcp-server/tools/project/__tests__/GetBuildStatusTool.test.d.ts +1 -0
  179. package/mcp-server/tools/project/__tests__/GetBuildStatusTool.test.js +240 -0
  180. package/mcp-server/tools/project/__tests__/GetConfigValuesTool.test.js +8 -6
  181. package/mcp-server/utils/__tests__/content.test.js +21 -20
  182. package/mcp-server/utils/__tests__/feedbackTracking.test.js +34 -28
  183. package/mcp-server/utils/config.d.ts +1 -0
  184. package/mcp-server/utils/config.js +10 -0
  185. package/mcp-server/utils/content.d.ts +1 -1
  186. package/mcp-server/utils/content.js +2 -2
  187. package/mcp-server/utils/feedbackTracking.d.ts +1 -1
  188. package/mcp-server/utils/feedbackTracking.js +3 -3
  189. package/mcp-server/utils/toolUsageTracking.js +4 -3
  190. package/package.json +9 -9
  191. package/ui/components/BoxWithTitle.d.ts +2 -1
  192. package/ui/components/BoxWithTitle.js +2 -2
  193. package/ui/components/StatusMessageBoxes.d.ts +5 -4
  194. package/ui/components/StatusMessageBoxes.js +8 -8
  195. package/lib/middleware/__test__/notificationsMiddleware.test.js +0 -8
  196. package/lib/middleware/notificationsMiddleware.d.ts +0 -1
  197. package/lib/middleware/notificationsMiddleware.js +0 -28
  198. package/lib/ui/boxen.d.ts +0 -5
  199. package/lib/ui/boxen.js +0 -26
  200. package/mcp-server/utils/__tests__/cliConfig.test.js +0 -110
  201. package/mcp-server/utils/cliConfig.d.ts +0 -1
  202. package/mcp-server/utils/cliConfig.js +0 -12
  203. /package/{lib/middleware/__test__/commandTargetingUtils.test.d.ts → commands/project/__tests__/lint.test.d.ts} +0 -0
  204. /package/lib/middleware/{__test__/configMiddleware.test.d.ts → __tests__/commandTargetingUtils.test.d.ts} +0 -0
  205. /package/lib/middleware/{__test__/gitMiddleware.test.d.ts → __tests__/configMiddleware.test.d.ts} +0 -0
  206. /package/lib/middleware/{__test__/notificationsMiddleware.test.d.ts → __tests__/gitMiddleware.test.d.ts} +0 -0
  207. /package/lib/middleware/{__test__ → __tests__}/requestMiddleware.test.d.ts +0 -0
  208. /package/lib/middleware/{__test__ → __tests__}/requestMiddleware.test.js +0 -0
  209. /package/lib/middleware/{__test__ → __tests__}/yargsChecksMiddleware.test.d.ts +0 -0
  210. /package/lib/middleware/{__test__ → __tests__}/yargsChecksMiddleware.test.js +0 -0
  211. /package/{mcp-server/utils/__tests__/cliConfig.test.d.ts → lib/projects/__tests__/uieLinting.test.d.ts} +0 -0
@@ -1,19 +1,23 @@
1
1
  import { uiLogger } from '../ui/logger.js';
2
2
  import { getSandboxUsageLimits } from '@hubspot/local-dev-lib/api/sandboxHubs';
3
3
  import { fetchTypes } from '@hubspot/local-dev-lib/api/sandboxSync';
4
- import { getAccountId, getConfigAccounts } from '@hubspot/local-dev-lib/config';
4
+ import { getAllConfigAccounts, getConfigAccountIfExists, } from '@hubspot/local-dev-lib/config';
5
5
  import { HUBSPOT_ACCOUNT_TYPES } from '@hubspot/local-dev-lib/constants/config';
6
6
  import { mockHubSpotHttpError } from '../testUtils.js';
7
7
  import { getSandboxTypeAsString, getHasSandboxesByType, getAvailableSyncTypes, validateSandboxUsageLimits, handleSandboxCreateError, } from '../sandboxes.js';
8
+ import { isMissingScopeError, isSpecifiedError, } from '@hubspot/local-dev-lib/errors/index';
8
9
  vi.mock('../ui/logger.js');
9
10
  vi.mock('@hubspot/local-dev-lib/api/sandboxHubs');
10
11
  vi.mock('@hubspot/local-dev-lib/api/sandboxSync');
11
12
  vi.mock('@hubspot/local-dev-lib/config');
12
- const mockedGetAccountId = getAccountId;
13
+ vi.mock('@hubspot/local-dev-lib/errors/index');
14
+ const mockedGetConfigAccountIfExists = getConfigAccountIfExists;
13
15
  const mockedGetSandboxUsageLimits = getSandboxUsageLimits;
14
16
  const mockedFetchTypes = fetchTypes;
15
- const mockedGetConfigAccounts = getConfigAccounts;
17
+ const mockedGetAllConfigAccounts = getAllConfigAccounts;
16
18
  const mockedUiLogger = uiLogger;
19
+ const mockedIsMissingScopeError = isMissingScopeError;
20
+ const mockedIsSpecifiedError = isSpecifiedError;
17
21
  describe('lib/sandboxes', () => {
18
22
  describe('getSandboxTypeAsString()', () => {
19
23
  it('returns "development" for development sandbox type', () => {
@@ -29,14 +33,13 @@ describe('lib/sandboxes', () => {
29
33
  describe('getHasSandboxesByType()', () => {
30
34
  const mockParentAccount = {
31
35
  name: 'Parent Account',
32
- portalId: 123,
33
- authType: undefined,
36
+ accountId: 123,
34
37
  accountType: HUBSPOT_ACCOUNT_TYPES.STANDARD_SANDBOX,
35
38
  env: 'qa',
36
39
  };
37
40
  it('returns true when sandbox of specified type exists', () => {
38
- mockedGetAccountId.mockReturnValue(mockParentAccount.portalId);
39
- mockedGetConfigAccounts.mockReturnValue([
41
+ mockedGetConfigAccountIfExists.mockReturnValue(mockParentAccount);
42
+ mockedGetAllConfigAccounts.mockReturnValue([
40
43
  mockParentAccount,
41
44
  {
42
45
  ...mockParentAccount,
@@ -47,25 +50,25 @@ describe('lib/sandboxes', () => {
47
50
  expect(getHasSandboxesByType(mockParentAccount, HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX)).toBe(true);
48
51
  });
49
52
  it('returns false when no sandbox of specified type exists', () => {
50
- mockedGetConfigAccounts.mockReturnValue([mockParentAccount]);
53
+ mockedGetAllConfigAccounts.mockReturnValue([mockParentAccount]);
51
54
  expect(getHasSandboxesByType(mockParentAccount, HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX)).toBe(false);
52
55
  });
53
56
  });
54
57
  describe('getAvailableSyncTypes()', () => {
55
58
  const mockParentAccount = {
56
59
  name: 'Parent Account',
57
- portalId: 123,
60
+ accountId: 123,
58
61
  env: 'qa',
59
62
  };
60
63
  const mockChildAccount = {
61
64
  ...mockParentAccount,
62
- portalId: 456,
65
+ accountId: 456,
63
66
  };
64
67
  it('returns available sync types when fetch is successful', async () => {
65
68
  const mockSyncTypes = [{ name: 'type1' }, { name: 'type2' }];
66
- mockedGetAccountId
67
- .mockReturnValue(mockParentAccount.portalId)
68
- .mockReturnValue(mockChildAccount.portalId);
69
+ mockedGetConfigAccountIfExists
70
+ .mockReturnValue(mockParentAccount.accountId)
71
+ .mockReturnValue(mockChildAccount.accountId);
69
72
  mockedFetchTypes.mockResolvedValue({
70
73
  data: { results: mockSyncTypes },
71
74
  });
@@ -80,12 +83,11 @@ describe('lib/sandboxes', () => {
80
83
  describe('validateSandboxUsageLimits()', () => {
81
84
  const mockAccount = {
82
85
  name: 'Test Account',
83
- portalId: 123,
84
- authType: undefined,
86
+ accountId: 123,
85
87
  env: 'qa',
86
88
  };
87
89
  it('validates successfully when limits are not reached', async () => {
88
- mockedGetAccountId.mockReturnValue(mockAccount.portalId);
90
+ mockedGetConfigAccountIfExists.mockReturnValue(mockAccount.accountId);
89
91
  mockedGetSandboxUsageLimits.mockResolvedValue({
90
92
  data: {
91
93
  usage: { DEVELOPER: { available: 1, limit: 3 } },
@@ -94,8 +96,8 @@ describe('lib/sandboxes', () => {
94
96
  await expect(validateSandboxUsageLimits(mockAccount, HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX, 'qa')).resolves.not.toThrow();
95
97
  });
96
98
  it('throws error when development sandbox limit is reached', async () => {
97
- mockedGetAccountId.mockReturnValue(mockAccount.portalId);
98
- mockedGetConfigAccounts.mockReturnValue([]);
99
+ mockedGetConfigAccountIfExists.mockReturnValue(mockAccount.accountId);
100
+ mockedGetAllConfigAccounts.mockReturnValue([]);
99
101
  mockedGetSandboxUsageLimits.mockResolvedValue({
100
102
  data: {
101
103
  usage: { DEVELOPER: { available: 0, limit: 1 } },
@@ -116,6 +118,9 @@ describe('lib/sandboxes', () => {
116
118
  category: 'MISSING_SCOPES',
117
119
  },
118
120
  });
121
+ // Mock the error checking function to return true for missing scope error
122
+ mockedIsMissingScopeError.mockReturnValue(true);
123
+ mockedIsSpecifiedError.mockReturnValue(false);
119
124
  expect(() => handleSandboxCreateError(error, mockEnv, mockName, mockAccountId)).toThrow(error);
120
125
  expect(mockedUiLogger.error).toHaveBeenCalledWith(expect.stringMatching(/The personal access key you provided doesn't include sandbox permissions/));
121
126
  expect(mockedUiLogger.info).toHaveBeenCalledWith(expect.stringMatching(/To update CLI permissions for/));
@@ -128,6 +133,9 @@ describe('lib/sandboxes', () => {
128
133
  subCategory: 'SandboxErrors.USER_ACCESS_NOT_ALLOWED',
129
134
  },
130
135
  });
136
+ // Mock the error checking function to return true for this error type
137
+ mockedIsMissingScopeError.mockReturnValue(false);
138
+ mockedIsSpecifiedError.mockReturnValue(true);
131
139
  expect(() => handleSandboxCreateError(error, mockEnv, mockName, mockAccountId)).toThrow(error);
132
140
  expect(mockedUiLogger.error).toHaveBeenCalledWith(expect.stringMatching(/your permission set doesn't allow you to create the sandbox/));
133
141
  });
@@ -139,8 +147,11 @@ describe('lib/sandboxes', () => {
139
147
  subCategory: 'SandboxErrors.DEVELOPMENT_SANDBOX_ACCESS_NOT_ALLOWED',
140
148
  },
141
149
  });
150
+ // Mock the error checking function to return true for this error type
151
+ mockedIsMissingScopeError.mockReturnValue(false);
152
+ mockedIsSpecifiedError.mockReturnValue(true);
142
153
  expect(() => handleSandboxCreateError(error, mockEnv, mockName, mockAccountId)).toThrow(error);
143
- expect(mockedUiLogger.error).toHaveBeenCalledWith(expect.stringMatching(/does not have access to development sandboxes/));
154
+ expect(mockedUiLogger.error).toHaveBeenCalledWith(expect.stringMatching(/Couldn't create.*because your account has been removed from.*or your permission set doesn't allow you to create/));
144
155
  });
145
156
  });
146
157
  });
@@ -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 { getConfig, getConfigAccountById } 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 { trackCommandUsage, trackHelpUsage, trackConvertFieldsUsage, trackAuthAction, trackCommandMetadataUsage, } from '../usageTracking.js';
@@ -9,14 +9,14 @@ vi.mock('@hubspot/local-dev-lib/trackUsage');
9
9
  vi.mock('@hubspot/local-dev-lib/config');
10
10
  vi.mock('../ui/logger.js');
11
11
  const mockedTrackUsage = trackUsage;
12
- const mockedIsTrackingAllowed = isTrackingAllowed;
13
- const mockedGetAccountConfig = getAccountConfig;
12
+ const mockedGetConfig = getConfig;
13
+ const mockedGetConfigAccountById = getConfigAccountById;
14
14
  const mockedUiLogger = uiLogger;
15
15
  describe('lib/usageTracking', () => {
16
16
  const mockPlatform = 'darwin';
17
17
  const mockNodeVersion = 'v16.14.0';
18
18
  beforeEach(() => {
19
- mockedIsTrackingAllowed.mockReturnValue(true);
19
+ mockedGetConfig.mockReturnValue({ allowUsageTracking: true });
20
20
  Object.defineProperty(process, 'platform', { value: mockPlatform });
21
21
  Object.defineProperty(process, 'version', { value: mockNodeVersion });
22
22
  });
@@ -24,7 +24,7 @@ describe('lib/usageTracking', () => {
24
24
  const mockCommand = 'test-command';
25
25
  const mockAccountId = 123;
26
26
  it('should not track when tracking is disabled', async () => {
27
- mockedIsTrackingAllowed.mockReturnValue(false);
27
+ mockedGetConfig.mockReturnValue({ allowUsageTracking: false });
28
28
  await trackCommandUsage(mockCommand);
29
29
  expect(mockedTrackUsage).not.toHaveBeenCalled();
30
30
  });
@@ -41,7 +41,7 @@ describe('lib/usageTracking', () => {
41
41
  }), mockAccountId);
42
42
  });
43
43
  it('should track command usage with custom auth type', async () => {
44
- mockedGetAccountConfig.mockReturnValue({ authType: 'oauth2' });
44
+ mockedGetConfigAccountById.mockReturnValue({ authType: 'oauth2' });
45
45
  await trackCommandUsage(mockCommand, {}, mockAccountId);
46
46
  expect(mockedTrackUsage).toHaveBeenCalledWith('cli-interaction', 'INTERACTION', expect.objectContaining({
47
47
  authType: 'oauth2',
@@ -59,7 +59,7 @@ describe('lib/usageTracking', () => {
59
59
  describe('trackHelpUsage()', () => {
60
60
  const mockCommand = 'help-command';
61
61
  it('should not track when tracking is disabled', async () => {
62
- mockedIsTrackingAllowed.mockReturnValue(false);
62
+ mockedGetConfig.mockReturnValue({ allowUsageTracking: false });
63
63
  await trackHelpUsage(mockCommand);
64
64
  expect(mockedTrackUsage).not.toHaveBeenCalled();
65
65
  });
@@ -82,7 +82,7 @@ describe('lib/usageTracking', () => {
82
82
  describe('trackConvertFieldsUsage()', () => {
83
83
  const mockCommand = 'convert-fields-command';
84
84
  it('should not track when tracking is disabled', async () => {
85
- mockedIsTrackingAllowed.mockReturnValue(false);
85
+ mockedGetConfig.mockReturnValue({ allowUsageTracking: false });
86
86
  await trackConvertFieldsUsage(mockCommand);
87
87
  expect(mockedTrackUsage).not.toHaveBeenCalled();
88
88
  });
@@ -104,7 +104,7 @@ describe('lib/usageTracking', () => {
104
104
  const mockStep = 'init';
105
105
  const mockAccountId = 123;
106
106
  it('should not track when tracking is disabled', async () => {
107
- mockedIsTrackingAllowed.mockReturnValue(false);
107
+ mockedGetConfig.mockReturnValue({ allowUsageTracking: false });
108
108
  await trackAuthAction(mockCommand, mockAuthType, mockStep, mockAccountId);
109
109
  expect(mockedTrackUsage).not.toHaveBeenCalled();
110
110
  });
@@ -127,7 +127,7 @@ describe('lib/usageTracking', () => {
127
127
  const mockMeta = { assetType: 'test-asset' };
128
128
  const mockAccountId = 123;
129
129
  it('should not track when tracking is disabled', async () => {
130
- mockedIsTrackingAllowed.mockReturnValue(false);
130
+ mockedGetConfig.mockReturnValue({ allowUsageTracking: false });
131
131
  await trackCommandMetadataUsage(mockCommand, mockMeta, mockAccountId);
132
132
  expect(mockedTrackUsage).not.toHaveBeenCalled();
133
133
  });
@@ -1,4 +1,4 @@
1
- import { getAccountId, getAccountConfig } from '@hubspot/local-dev-lib/config';
1
+ import { getConfigAccountById, getConfigAccountIfExists, } from '@hubspot/local-dev-lib/config';
2
2
  import { getOauthManager } from '@hubspot/local-dev-lib/oauth';
3
3
  import { accessTokenForPersonalAccessKey } from '@hubspot/local-dev-lib/personalAccessKey';
4
4
  import { validateAccount } from '../validation.js';
@@ -14,47 +14,47 @@ const yargsOption = (option) => ({
14
14
  ...option,
15
15
  });
16
16
  describe('lib/validation', () => {
17
- const getAccountIdMock = getAccountId;
18
- const getAccountConfigMock = getAccountConfig;
17
+ const getConfigAccountIfExistsMock = getConfigAccountIfExists;
18
+ const getConfigAccountByIdMock = getConfigAccountById;
19
19
  const getOauthManagerMock = getOauthManager;
20
20
  const accessTokenForPersonalAccessKeyMock = accessTokenForPersonalAccessKey;
21
21
  describe('validateAccount', () => {
22
22
  it('returns false if an account is missing', async () => {
23
- getAccountIdMock.mockReturnValueOnce(null);
24
- expect(await validateAccount(yargsOption({ account: '123' }))).toBe(false);
23
+ getConfigAccountIfExistsMock.mockReturnValueOnce(null);
24
+ expect(await validateAccount(yargsOption({ derivedAccountId: '123' }))).toBe(false);
25
25
  });
26
26
  it('returns false if an account config is missing', async () => {
27
- getAccountIdMock.mockReturnValueOnce('123');
28
- getAccountConfigMock.mockReturnValueOnce(undefined);
29
- expect(await validateAccount(yargsOption({ account: '123' }))).toBe(false);
27
+ getConfigAccountIfExistsMock.mockReturnValueOnce('123');
28
+ getConfigAccountByIdMock.mockReturnValueOnce(undefined);
29
+ expect(await validateAccount(yargsOption({ derivedAccountId: '123' }))).toBe(false);
30
30
  });
31
31
  it('returns false for oauth2 authType if auth is missing', async () => {
32
- getAccountIdMock.mockReturnValueOnce('123');
33
- getAccountConfigMock.mockReturnValueOnce({
32
+ getConfigAccountIfExistsMock.mockReturnValueOnce('123');
33
+ getConfigAccountByIdMock.mockReturnValueOnce({
34
34
  accountId: '123',
35
35
  authType: 'oauth2',
36
36
  });
37
- expect(await validateAccount(yargsOption({ account: '123' }))).toBe(false);
37
+ expect(await validateAccount(yargsOption({ derivedAccountId: '123' }))).toBe(false);
38
38
  });
39
39
  it('returns false if OAuth is missing configuration', async () => {
40
- getAccountIdMock.mockReturnValueOnce('123');
41
- getAccountConfigMock.mockReturnValueOnce({
40
+ getConfigAccountIfExistsMock.mockReturnValueOnce('123');
41
+ getConfigAccountByIdMock.mockReturnValueOnce({
42
42
  accountId: '123',
43
43
  authType: 'oauth2',
44
44
  auth: {
45
45
  clientId: 'foo',
46
46
  },
47
47
  });
48
- expect(await validateAccount(yargsOption({ account: '123' }))).toBe(false);
48
+ expect(await validateAccount(yargsOption({ derivedAccountId: '123' }))).toBe(false);
49
49
  });
50
50
  it('returns false if an access token was not retrieved', async () => {
51
- getAccountIdMock.mockReturnValueOnce('123');
51
+ getConfigAccountIfExistsMock.mockReturnValueOnce('123');
52
52
  getOauthManagerMock.mockReturnValueOnce({
53
53
  accessToken() {
54
54
  return null;
55
55
  },
56
56
  });
57
- getAccountConfigMock.mockReturnValueOnce({
57
+ getConfigAccountByIdMock.mockReturnValueOnce({
58
58
  accountId: '123',
59
59
  authType: 'oauth2',
60
60
  auth: {
@@ -65,16 +65,16 @@ describe('lib/validation', () => {
65
65
  },
66
66
  },
67
67
  });
68
- expect(await validateAccount(yargsOption({ account: '123' }))).toBe(false);
68
+ expect(await validateAccount(yargsOption({ derivedAccountId: '123' }))).toBe(false);
69
69
  });
70
70
  it('returns false if an getting an access token throws', async () => {
71
- getAccountIdMock.mockReturnValueOnce('123');
71
+ getConfigAccountIfExistsMock.mockReturnValueOnce('123');
72
72
  getOauthManagerMock.mockReturnValueOnce({
73
73
  accessToken() {
74
74
  throw new Error('It failed');
75
75
  },
76
76
  });
77
- getAccountConfigMock.mockReturnValueOnce({
77
+ getConfigAccountByIdMock.mockReturnValueOnce({
78
78
  accountId: '123',
79
79
  authType: 'oauth2',
80
80
  auth: {
@@ -85,16 +85,16 @@ describe('lib/validation', () => {
85
85
  },
86
86
  },
87
87
  });
88
- expect(await validateAccount(yargsOption({ account: '123' }))).toBe(false);
88
+ expect(await validateAccount(yargsOption({ derivedAccountId: '123' }))).toBe(false);
89
89
  });
90
90
  it('returns true if OAuth is configured and an access token is received', async () => {
91
- getAccountIdMock.mockReturnValueOnce('123');
91
+ getConfigAccountIfExistsMock.mockReturnValueOnce('123');
92
92
  getOauthManagerMock.mockReturnValueOnce({
93
93
  accessToken() {
94
94
  return 'yep';
95
95
  },
96
96
  });
97
- getAccountConfigMock.mockReturnValueOnce({
97
+ getConfigAccountByIdMock.mockReturnValueOnce({
98
98
  accountId: '123',
99
99
  authType: 'oauth2',
100
100
  auth: {
@@ -105,40 +105,40 @@ describe('lib/validation', () => {
105
105
  },
106
106
  },
107
107
  });
108
- expect(await validateAccount(yargsOption({ account: '123' }))).toBe(true);
108
+ expect(await validateAccount(yargsOption({ derivedAccountId: '123' }))).toBe(true);
109
109
  });
110
110
  it('returns false if "personalaccesskey" configured and getting an access token throws', async () => {
111
- getAccountIdMock.mockReturnValueOnce('123');
111
+ getConfigAccountIfExistsMock.mockReturnValueOnce('123');
112
112
  accessTokenForPersonalAccessKeyMock.mockImplementationOnce(() => {
113
113
  throw new Error('It failed');
114
114
  });
115
- getAccountConfigMock.mockReturnValueOnce({
115
+ getConfigAccountByIdMock.mockReturnValueOnce({
116
116
  accountId: '123',
117
117
  authType: 'personalaccesskey',
118
118
  personalAccessKey: 'foo',
119
119
  });
120
- expect(await validateAccount(yargsOption({ account: '123' }))).toBe(false);
120
+ expect(await validateAccount(yargsOption({ derivedAccountId: '123' }))).toBe(false);
121
121
  });
122
122
  it('returns true if "personalaccesskey" configured and an access token is received', async () => {
123
- getAccountIdMock.mockReturnValueOnce('123');
123
+ getConfigAccountIfExistsMock.mockReturnValueOnce('123');
124
124
  accessTokenForPersonalAccessKeyMock.mockImplementationOnce(() => {
125
125
  return 'secret-stuff';
126
126
  });
127
- getAccountConfigMock.mockReturnValueOnce({
127
+ getConfigAccountByIdMock.mockReturnValueOnce({
128
128
  accountId: '123',
129
129
  authType: 'personalaccesskey',
130
130
  personalAccessKey: 'foo',
131
131
  });
132
- expect(await validateAccount(yargsOption({ account: '123' }))).toBe(true);
132
+ expect(await validateAccount(yargsOption({ derivedAccountId: '123' }))).toBe(true);
133
133
  });
134
134
  it('returns true if apiKey is configured and present', async () => {
135
- getAccountIdMock.mockReturnValueOnce('123');
136
- getAccountConfigMock.mockReturnValueOnce({
135
+ getConfigAccountIfExistsMock.mockReturnValueOnce('123');
136
+ getConfigAccountByIdMock.mockReturnValueOnce({
137
137
  accountId: '123',
138
138
  authType: 'apikey',
139
139
  apiKey: 'my-secret-key',
140
140
  });
141
- expect(await validateAccount(yargsOption({ account: '123' }))).toBe(true);
141
+ expect(await validateAccount(yargsOption({ derivedAccountId: '123' }))).toBe(true);
142
142
  });
143
143
  });
144
144
  });
@@ -1,9 +1,9 @@
1
- import { CLIAccount } from '@hubspot/local-dev-lib/types/Accounts';
2
- export declare function isStandardAccount(accountConfig: CLIAccount): boolean;
3
- export declare function isSandbox(accountConfig: CLIAccount): boolean;
4
- export declare function isStandardSandbox(accountConfig: CLIAccount): boolean;
5
- export declare function isDevelopmentSandbox(accountConfig: CLIAccount): boolean;
6
- export declare function isDeveloperTestAccount(accountConfig: CLIAccount): boolean;
7
- export declare function isAppDeveloperAccount(accountConfig: CLIAccount): boolean;
8
- export declare function isTestAccountOrSandbox(accountConfig: CLIAccount): boolean;
9
- export declare function isUnifiedAccount(account: CLIAccount): Promise<boolean>;
1
+ import { HubSpotConfigAccount } from '@hubspot/local-dev-lib/types/Accounts';
2
+ export declare function isStandardAccount(accountConfig: HubSpotConfigAccount): boolean;
3
+ export declare function isSandbox(accountConfig: HubSpotConfigAccount): boolean;
4
+ export declare function isStandardSandbox(accountConfig: HubSpotConfigAccount): boolean;
5
+ export declare function isDevelopmentSandbox(accountConfig: HubSpotConfigAccount): boolean;
6
+ export declare function isDeveloperTestAccount(accountConfig: HubSpotConfigAccount): boolean;
7
+ export declare function isAppDeveloperAccount(accountConfig: HubSpotConfigAccount): boolean;
8
+ export declare function isTestAccountOrSandbox(accountConfig: HubSpotConfigAccount): boolean;
9
+ export declare function isUnifiedAccount(account: HubSpotConfigAccount): Promise<boolean>;
@@ -1,6 +1,5 @@
1
1
  import { HUBSPOT_ACCOUNT_TYPES } from '@hubspot/local-dev-lib/constants/config';
2
2
  import { hasUnfiedAppsAccess } from './hasFeature.js';
3
- import { getAccountIdentifier } from '@hubspot/local-dev-lib/config/getAccountIdentifier';
4
3
  function isAccountType(accountConfig, accountType) {
5
4
  return Boolean(accountConfig.accountType && accountType.includes(accountConfig.accountType));
6
5
  }
@@ -35,9 +34,8 @@ export function isTestAccountOrSandbox(accountConfig) {
35
34
  ]);
36
35
  }
37
36
  export async function isUnifiedAccount(account) {
38
- const accountId = getAccountIdentifier(account);
39
- if (!accountId) {
37
+ if (!account.accountId) {
40
38
  return false;
41
39
  }
42
- return hasUnfiedAppsAccess(accountId);
40
+ return hasUnfiedAppsAccess(account.accountId);
43
41
  }
@@ -1,6 +1,7 @@
1
1
  import { uiLogger } from '../../ui/logger.js';
2
2
  import { getCwd, sanitizeFileName } from '@hubspot/local-dev-lib/path';
3
3
  import { extractZipArchive } from '@hubspot/local-dev-lib/archive';
4
+ import { getConfigAccountById } from '@hubspot/local-dev-lib/config';
4
5
  import { validateUid } from '@hubspot/project-parsing-lib';
5
6
  import { UNMIGRATABLE_REASONS } from '@hubspot/local-dev-lib/constants/projects';
6
7
  import { MIGRATION_STATUS } from '@hubspot/local-dev-lib/types/Migration';
@@ -26,6 +27,7 @@ vi.mock('../../ui/SpinniesManager');
26
27
  vi.mock('../../polling');
27
28
  vi.mock('../../../api/migrate');
28
29
  vi.mock('../../hasFeature');
30
+ vi.mock('@hubspot/local-dev-lib/config');
29
31
  vi.mock('../../projects/urls');
30
32
  vi.mock('fs');
31
33
  const mockedUiLogger = uiLogger;
@@ -34,6 +36,7 @@ const mockedSanitizeFileName = sanitizeFileName;
34
36
  const mockedExtractZipArchive = extractZipArchive;
35
37
  const mockedValidateUid = validateUid;
36
38
  const mockedDownloadProject = downloadProject;
39
+ const mockedGetConfigAccountById = getConfigAccountById;
37
40
  const mockedConfirmPrompt = confirmPrompt;
38
41
  const mockedInputPrompt = inputPrompt;
39
42
  const mockedListPrompt = listPrompt;
@@ -83,6 +86,18 @@ describe('lib/app/migrate', () => {
83
86
  mockedValidateUid.mockReturnValue(undefined);
84
87
  mockedHasUnfiedAppsAccess.mockResolvedValue(true);
85
88
  mockedFs.renameSync.mockImplementation(() => { });
89
+ // Mock account config for the test account ID
90
+ mockedGetConfigAccountById.mockReturnValue({
91
+ accountId: ACCOUNT_ID,
92
+ name: 'Test Account',
93
+ authType: 'personalaccesskey',
94
+ auth: {
95
+ tokenInfo: {
96
+ accessToken: 'test-token',
97
+ },
98
+ },
99
+ env: 'prod',
100
+ });
86
101
  });
87
102
  describe('getUnmigratableReason', () => {
88
103
  const testCases = [
@@ -9,6 +9,7 @@ import { projectNameAndDestPrompt as _projectNameAndDestPrompt } from '../../pro
9
9
  import { ensureProjectExists as _ensureProjectExists } from '../../projects/ensureProjectExists.js';
10
10
  import { poll as _poll } from '../../polling.js';
11
11
  import { migrateApp2023_2 } from '../migrate_legacy.js';
12
+ import { getConfigAccountById } from '@hubspot/local-dev-lib/config';
12
13
  // Mock all external dependencies
13
14
  vi.mock('@hubspot/local-dev-lib/api/appsDev');
14
15
  vi.mock('../../ui/logger.js');
@@ -26,6 +27,7 @@ vi.mock('../../usageTracking');
26
27
  vi.mock('../../ui/SpinniesManager');
27
28
  vi.mock('../../process');
28
29
  vi.mock('../../polling');
30
+ vi.mock('@hubspot/local-dev-lib/config');
29
31
  const isAppDeveloperAccount = _isAppDeveloperAccount;
30
32
  const isUnifiedAccount = _isUnifiedAccount;
31
33
  const selectPublicAppForMigrationPrompt = _selectPublicAppForMigrationPrompt;
@@ -57,6 +59,13 @@ describe('migrateApp2023_2', () => {
57
59
  beforeEach(() => {
58
60
  // @ts-expect-error function mismatch
59
61
  vi.spyOn(process, 'exit').mockImplementation(() => { });
62
+ getConfigAccountById.mockReturnValue({
63
+ accountId: mockDerivedAccountId,
64
+ name: 'Test Account',
65
+ authType: 'personalaccesskey',
66
+ personalAccessKey: 'test-key',
67
+ env: 'prod',
68
+ });
60
69
  selectPublicAppForMigrationPrompt.mockResolvedValue({
61
70
  appId,
62
71
  });
@@ -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 { ArgumentsCamelCase } from 'yargs';
3
3
  import { MigrateAppArgs } from './migrate.js';
4
- export declare function migrateApp2023_2(derivedAccountId: number, options: ArgumentsCamelCase<MigrateAppArgs>, accountConfig: CLIAccount): Promise<void>;
4
+ export declare function migrateApp2023_2(derivedAccountId: number, options: ArgumentsCamelCase<MigrateAppArgs>, accountConfig: HubSpotConfigAccount): Promise<void>;
@@ -1,6 +1,6 @@
1
1
  import { DeveloperTestAccountConfig } from '@hubspot/local-dev-lib/types/developerTestAccounts';
2
2
  import { Environment } from '@hubspot/local-dev-lib/types/Config';
3
- import { CLIAccount } from '@hubspot/local-dev-lib/types/Accounts';
3
+ import { HubSpotConfigAccount } from '@hubspot/local-dev-lib/types/Accounts';
4
4
  import { SandboxResponse, V2Sandbox } from '@hubspot/local-dev-lib/types/Sandbox';
5
5
  import { SandboxAccountType } from '../types/Sandboxes.js';
6
6
  export declare function saveAccountToConfig(accountId: number | undefined, accountName: string, env: Environment, personalAccessKey?: string, force?: boolean): Promise<string>;
@@ -9,12 +9,12 @@ export declare function createDeveloperTestAccountV2(parentAccountId: number, te
9
9
  accountId?: number;
10
10
  personalAccessKey?: string;
11
11
  }>;
12
- export declare function buildDeveloperTestAccount(testAccountName: string, parentAccountConfig: CLIAccount, env: Environment, portalLimit: number, useV2?: boolean): Promise<number>;
12
+ export declare function buildDeveloperTestAccount(testAccountName: string, parentAccountConfig: HubSpotConfigAccount, env: Environment, portalLimit: number, useV2?: boolean): Promise<number>;
13
13
  type SandboxAccount = SandboxResponse & {
14
14
  name: string;
15
15
  };
16
- export declare function buildSandbox(sandboxName: string, parentAccountConfig: CLIAccount, sandboxType: SandboxAccountType, env: Environment, force?: boolean): Promise<SandboxAccount>;
17
- export declare function buildV2Sandbox(sandboxName: string, parentAccountConfig: CLIAccount, sandboxType: SandboxAccountType, syncObjectRecords: boolean, env: Environment, force?: boolean): Promise<{
16
+ export declare function buildSandbox(sandboxName: string, parentAccountConfig: HubSpotConfigAccount, sandboxType: SandboxAccountType, env: Environment, force?: boolean): Promise<SandboxAccount>;
17
+ export declare function buildV2Sandbox(sandboxName: string, parentAccountConfig: HubSpotConfigAccount, sandboxType: SandboxAccountType, syncObjectRecords: boolean, env: Environment, force?: boolean): Promise<{
18
18
  sandbox: V2Sandbox;
19
19
  }>;
20
20
  export {};
@@ -1,6 +1,5 @@
1
1
  import { getAccessToken, updateConfigWithAccessToken, } from '@hubspot/local-dev-lib/personalAccessKey';
2
- import { accountNameExistsInConfig, updateAccountConfig, writeConfig, getAccountId, } from '@hubspot/local-dev-lib/config';
3
- import { getAccountIdentifier } from '@hubspot/local-dev-lib/config/getAccountIdentifier';
2
+ import { getConfigAccountIfExists, updateConfigAccount, } from '@hubspot/local-dev-lib/config';
4
3
  import { uiLogger } from './ui/logger.js';
5
4
  import { createDeveloperTestAccount, fetchDeveloperTestAccountGateSyncStatus, generateDeveloperTestAccountPersonalAccessKey, } from '@hubspot/local-dev-lib/api/developerTestAccounts';
6
5
  import { HUBSPOT_ACCOUNT_TYPES } from '@hubspot/local-dev-lib/constants/config';
@@ -28,8 +27,8 @@ export async function saveAccountToConfig(accountId, accountName, env, personalA
28
27
  if (!updatedConfig?.name) {
29
28
  const nameForConfig = accountName.toLowerCase().split(' ').join('-');
30
29
  validName = nameForConfig;
31
- const invalidAccountName = accountNameExistsInConfig(nameForConfig);
32
- if (invalidAccountName) {
30
+ const existingAccount = getConfigAccountIfExists(nameForConfig);
31
+ if (existingAccount) {
33
32
  if (!force) {
34
33
  uiLogger.log('');
35
34
  uiLogger.warn(lib.prompts.accountNamePrompt.errors.accountNameExists(nameForConfig));
@@ -42,13 +41,10 @@ export async function saveAccountToConfig(accountId, accountName, env, personalA
42
41
  }
43
42
  }
44
43
  }
45
- updateAccountConfig({
44
+ updateConfigAccount({
46
45
  ...updatedConfig,
47
- env: updatedConfig?.env,
48
- tokenInfo: updatedConfig?.auth?.tokenInfo,
49
46
  name: validName,
50
47
  });
51
- writeConfig();
52
48
  uiLogger.log('');
53
49
  return validName;
54
50
  }
@@ -83,8 +79,7 @@ export async function createDeveloperTestAccountV2(parentAccountId, testAccountC
83
79
  return result;
84
80
  }
85
81
  export async function buildDeveloperTestAccount(testAccountName, parentAccountConfig, env, portalLimit, useV2 = false) {
86
- const id = getAccountIdentifier(parentAccountConfig);
87
- const parentAccountId = getAccountId(id);
82
+ const parentAccountId = parentAccountConfig.accountId;
88
83
  let testAccountConfig = {
89
84
  accountName: testAccountName,
90
85
  };
@@ -141,8 +136,7 @@ export async function buildSandbox(sandboxName, parentAccountConfig, sandboxType
141
136
  const sandboxTypeKey = sandboxType === HUBSPOT_ACCOUNT_TYPES.STANDARD_SANDBOX
142
137
  ? 'standard'
143
138
  : 'developer';
144
- const id = getAccountIdentifier(parentAccountConfig);
145
- const parentAccountId = getAccountId(id);
139
+ const parentAccountId = parentAccountConfig.accountId;
146
140
  if (!parentAccountId) {
147
141
  throw new Error(lib.sandbox.create[sandboxTypeKey].loading.fail(''));
148
142
  }
@@ -182,8 +176,7 @@ export async function buildV2Sandbox(sandboxName, parentAccountConfig, sandboxTy
182
176
  const sandboxTypeKey = sandboxType === HUBSPOT_ACCOUNT_TYPES.STANDARD_SANDBOX
183
177
  ? 'standard'
184
178
  : 'developer';
185
- const id = getAccountIdentifier(parentAccountConfig);
186
- const parentAccountId = getAccountId(id);
179
+ const parentAccountId = parentAccountConfig.accountId;
187
180
  if (!parentAccountId) {
188
181
  throw new Error(lib.sandbox.create[sandboxTypeKey].loading.fail(''));
189
182
  }
package/lib/commonOpts.js CHANGED
@@ -3,7 +3,7 @@ import yargsParser from 'yargs-parser';
3
3
  import { LOG_LEVEL, setLogLevel } from '@hubspot/local-dev-lib/logger';
4
4
  import { uiLogger } from './ui/logger.js';
5
5
  import { DEFAULT_CMS_PUBLISH_MODE, CMS_PUBLISH_MODE, } from '@hubspot/local-dev-lib/constants/files';
6
- import { getAccountConfig, getAndLoadConfigIfNeeded, } from '@hubspot/local-dev-lib/config';
6
+ import { getConfigAccountById, getConfig } from '@hubspot/local-dev-lib/config';
7
7
  import { debugError } from './errorHandlers/index.js';
8
8
  import { EXIT_CODES } from './enums/exitCodes.js';
9
9
  import { uiCommandReference } from './ui/index.js';
@@ -168,14 +168,14 @@ export function getCmsPublishMode(options) {
168
168
  }
169
169
  // 2. config[account].defaultCmsPublishMode
170
170
  if (options.derivedAccountId) {
171
- const accountConfig = getAccountConfig(options.derivedAccountId);
171
+ const accountConfig = getConfigAccountById(options.derivedAccountId);
172
172
  if (accountConfig && accountConfig.defaultCmsPublishMode) {
173
173
  return accountConfig.defaultCmsPublishMode;
174
174
  }
175
175
  }
176
176
  // 3. config.defaultCmsPublishMode
177
177
  // 4. DEFAULT_CMS_PUBLISH_MODE
178
- const config = getAndLoadConfigIfNeeded();
178
+ const config = getConfig();
179
179
  return ((config && config.defaultCmsPublishMode) ||
180
180
  DEFAULT_CMS_PUBLISH_MODE);
181
181
  }
@@ -1,2 +1,2 @@
1
- export declare function handleMigration(deprecatedConfigPath?: string, hideWarning?: boolean): Promise<boolean>;
2
- export declare function handleMerge(deprecatedConfigPath?: string, force?: boolean, hideWarning?: boolean): Promise<boolean>;
1
+ export declare function handleMigration(hideWarning?: boolean): Promise<boolean>;
2
+ export declare function handleMerge(force?: boolean, hideWarning?: boolean): Promise<boolean>;