@hubspot/cli 7.10.0-beta.2 → 7.10.0-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.
- package/bin/cli.js +5 -4
- package/commands/__tests__/getStarted.test.js +10 -0
- package/commands/__tests__/project.test.js +3 -0
- package/commands/account/__tests__/rename.test.js +10 -3
- package/commands/account/auth.js +10 -14
- package/commands/account/clean.js +11 -19
- package/commands/account/createOverride.js +15 -11
- package/commands/account/info.js +8 -5
- package/commands/account/list.js +15 -19
- package/commands/account/remove.js +23 -22
- package/commands/account/removeOverride.js +6 -6
- package/commands/account/rename.js +2 -2
- package/commands/account/use.js +19 -8
- package/commands/app/__tests__/migrate.test.js +8 -4
- package/commands/app/migrate.js +2 -2
- package/commands/auth.js +18 -14
- package/commands/config/migrate.js +5 -5
- package/commands/customObject/createSchema.js +2 -3
- package/commands/customObject/updateSchema.js +2 -3
- package/commands/getStarted.js +2 -3
- package/commands/hubdb/__tests__/list.test.js +1 -0
- package/commands/hubdb/list.js +2 -2
- package/commands/init.js +36 -32
- package/commands/project/__tests__/deploy.test.js +10 -5
- package/commands/project/__tests__/devUnifiedFlow.test.js +6 -4
- package/commands/project/__tests__/lint.test.js +709 -0
- package/commands/project/__tests__/logs.test.js +4 -0
- package/commands/project/__tests__/validate.test.js +2 -2
- package/commands/project/cloneApp.js +2 -2
- package/commands/project/deploy.js +2 -2
- package/commands/project/dev/deprecatedFlow.js +4 -5
- package/commands/project/dev/index.js +6 -3
- package/commands/project/dev/unifiedFlow.js +4 -5
- package/commands/project/lint.d.ts +6 -0
- package/commands/project/lint.js +178 -0
- package/commands/project/logs.js +2 -3
- package/commands/project/profile/add.js +6 -7
- package/commands/project/profile/delete.js +2 -2
- package/commands/project/upload.js +2 -2
- package/commands/project/validate.js +2 -2
- package/commands/project.js +2 -0
- package/commands/sandbox/__tests__/create.test.js +14 -5
- package/commands/sandbox/create.js +4 -5
- package/commands/sandbox/delete.js +23 -20
- package/commands/testAccount/create.js +2 -2
- package/commands/testAccount/delete.js +9 -8
- package/lang/en.d.ts +40 -6
- package/lang/en.js +49 -9
- package/lib/__tests__/buildAccount.test.js +22 -30
- package/lib/__tests__/commonOpts.test.js +9 -13
- package/lib/__tests__/developerTestAccounts.test.js +29 -17
- package/lib/__tests__/importData.test.js +20 -10
- package/lib/__tests__/oauth.test.js +19 -8
- package/lib/__tests__/sandboxSync.test.js +33 -11
- package/lib/__tests__/sandboxes.test.js +30 -19
- package/lib/__tests__/usageTracking.test.js +10 -10
- package/lib/__tests__/validation.test.js +32 -32
- package/lib/accountTypes.d.ts +9 -9
- package/lib/accountTypes.js +2 -4
- package/lib/app/__tests__/migrate.test.js +15 -0
- package/lib/app/__tests__/migrate_legacy.test.js +9 -0
- package/lib/app/migrate_legacy.d.ts +2 -2
- package/lib/buildAccount.d.ts +4 -4
- package/lib/buildAccount.js +7 -14
- package/lib/commonOpts.js +3 -3
- package/lib/configMigrate.d.ts +2 -2
- package/lib/configMigrate.js +42 -18
- package/lib/configOptions.js +3 -2
- package/lib/developerTestAccounts.d.ts +3 -3
- package/lib/developerTestAccounts.js +4 -7
- package/lib/doctor/DiagnosticInfoBuilder.d.ts +1 -1
- package/lib/doctor/DiagnosticInfoBuilder.js +9 -6
- package/lib/doctor/Doctor.js +4 -3
- package/lib/doctor/__tests__/Diagnosis.test.js +4 -3
- package/lib/doctor/__tests__/DiagnosticInfoBuilder.test.js +17 -9
- package/lib/doctor/__tests__/Doctor.test.js +14 -0
- package/lib/importData.js +8 -7
- package/lib/links.js +5 -5
- package/lib/middleware/{__test__ → __tests__}/commandTargetingUtils.test.js +3 -3
- package/lib/middleware/{__test__ → __tests__}/configMiddleware.test.js +23 -22
- package/lib/middleware/{__test__ → __tests__}/gitMiddleware.test.js +9 -7
- package/lib/middleware/autoUpdateMiddleware.js +12 -4
- package/lib/middleware/commandTargetingUtils.js +3 -2
- package/lib/middleware/configMiddleware.d.ts +6 -1
- package/lib/middleware/configMiddleware.js +36 -15
- package/lib/middleware/gitMiddleware.js +8 -4
- package/lib/oauth.d.ts +2 -2
- package/lib/oauth.js +8 -10
- package/lib/projects/__tests__/AppDevModeInterface.test.js +17 -6
- package/lib/projects/__tests__/DevServerManager.test.js +1 -0
- package/lib/projects/__tests__/LocalDevProcess.test.js +1 -0
- package/lib/projects/__tests__/deploy.test.js +1 -0
- package/lib/projects/__tests__/uieLinting.test.js +640 -0
- package/lib/projects/create/__tests__/v2.test.js +11 -0
- package/lib/projects/localDev/AppDevModeInterface.js +2 -2
- package/lib/projects/localDev/DevServerManager_DEPRECATED.js +2 -2
- package/lib/projects/localDev/DevSessionManager.d.ts +17 -0
- package/lib/projects/localDev/DevSessionManager.js +56 -0
- package/lib/projects/localDev/LocalDevLogger.d.ts +3 -0
- package/lib/projects/localDev/LocalDevLogger.js +13 -4
- package/lib/projects/localDev/LocalDevManager_DEPRECATED.js +3 -3
- package/lib/projects/localDev/LocalDevProcess.d.ts +1 -0
- package/lib/projects/localDev/LocalDevProcess.js +12 -1
- package/lib/projects/localDev/LocalDevState.d.ts +3 -0
- package/lib/projects/localDev/LocalDevState.js +9 -0
- package/lib/projects/localDev/helpers/account.d.ts +10 -10
- package/lib/projects/localDev/helpers/account.js +6 -11
- package/lib/projects/localDev/helpers/devSessionsApi.d.ts +9 -0
- package/lib/projects/localDev/helpers/devSessionsApi.js +19 -0
- package/lib/projects/uieLinting.d.ts +33 -0
- package/lib/projects/uieLinting.js +222 -0
- package/lib/projects/urls.js +5 -6
- package/lib/prompts/__tests__/downloadProjectPrompt.test.js +7 -5
- package/lib/prompts/accountNamePrompt.js +3 -3
- package/lib/prompts/accountsPrompt.d.ts +1 -1
- package/lib/prompts/accountsPrompt.js +6 -7
- package/lib/prompts/confirmImportDataPrompt.js +2 -2
- package/lib/prompts/downloadProjectPrompt.d.ts +1 -0
- package/lib/prompts/downloadProjectPrompt.js +5 -2
- package/lib/prompts/importDataTestAccountSelectPrompt.js +4 -5
- package/lib/prompts/personalAccessKeyPrompt.js +2 -2
- package/lib/prompts/projectDevTargetAccountPrompt.d.ts +3 -3
- package/lib/prompts/projectDevTargetAccountPrompt.js +5 -7
- package/lib/prompts/sandboxesPrompt.js +7 -8
- package/lib/prompts/setAsDefaultAccountPrompt.js +7 -6
- package/lib/sandboxSync.d.ts +2 -2
- package/lib/sandboxSync.js +3 -9
- package/lib/sandboxes.d.ts +4 -4
- package/lib/sandboxes.js +6 -11
- package/lib/serverlessLogs.js +2 -2
- package/lib/theme/__tests__/migrate.test.js +15 -0
- package/lib/ui/index.js +6 -3
- package/lib/usageTracking.js +15 -8
- package/lib/validation.js +13 -11
- package/mcp-server/tools/cms/HsCreateFunctionTool.js +4 -2
- package/mcp-server/tools/cms/HsCreateModuleTool.js +4 -2
- package/mcp-server/tools/cms/HsCreateTemplateTool.js +4 -2
- package/mcp-server/tools/cms/HsFunctionLogsTool.js +4 -2
- package/mcp-server/tools/cms/HsListFunctionsTool.js +3 -1
- package/mcp-server/tools/cms/HsListTool.js +3 -1
- package/mcp-server/tools/cms/__tests__/HsCreateFunctionTool.test.js +1 -0
- package/mcp-server/tools/index.js +4 -0
- package/mcp-server/tools/project/AddFeatureToProjectTool.js +4 -2
- package/mcp-server/tools/project/CreateProjectTool.js +4 -2
- package/mcp-server/tools/project/CreateTestAccountTool.js +17 -7
- package/mcp-server/tools/project/DeployProjectTool.js +3 -1
- package/mcp-server/tools/project/DocFetchTool.js +6 -4
- package/mcp-server/tools/project/DocsSearchTool.d.ts +1 -1
- package/mcp-server/tools/project/DocsSearchTool.js +10 -8
- package/mcp-server/tools/project/GetApiUsagePatternsByAppIdTool.d.ts +1 -1
- package/mcp-server/tools/project/GetApiUsagePatternsByAppIdTool.js +9 -7
- package/mcp-server/tools/project/GetApplicationInfoTool.js +8 -6
- package/mcp-server/tools/project/GetBuildLogsTool.d.ts +26 -0
- package/mcp-server/tools/project/GetBuildLogsTool.js +125 -0
- package/mcp-server/tools/project/GetBuildStatusTool.d.ts +26 -0
- package/mcp-server/tools/project/GetBuildStatusTool.js +166 -0
- package/mcp-server/tools/project/GetConfigValuesTool.d.ts +1 -1
- package/mcp-server/tools/project/GetConfigValuesTool.js +9 -7
- package/mcp-server/tools/project/GuidedWalkthroughTool.d.ts +1 -1
- package/mcp-server/tools/project/GuidedWalkthroughTool.js +5 -3
- package/mcp-server/tools/project/UploadProjectTools.js +3 -1
- package/mcp-server/tools/project/ValidateProjectTool.js +4 -2
- package/mcp-server/tools/project/__tests__/CreateTestAccountTool.test.js +12 -2
- package/mcp-server/tools/project/__tests__/DocFetchTool.test.js +5 -1
- package/mcp-server/tools/project/__tests__/DocsSearchTool.test.js +23 -11
- package/mcp-server/tools/project/__tests__/GetApiUsagePatternsByAppIdTool.test.js +7 -5
- package/mcp-server/tools/project/__tests__/GetApplicationInfoTool.test.js +7 -5
- package/mcp-server/tools/project/__tests__/GetBuildLogsTool.test.d.ts +1 -0
- package/mcp-server/tools/project/__tests__/GetBuildLogsTool.test.js +305 -0
- package/mcp-server/tools/project/__tests__/GetBuildStatusTool.test.d.ts +1 -0
- package/mcp-server/tools/project/__tests__/GetBuildStatusTool.test.js +240 -0
- package/mcp-server/tools/project/__tests__/GetConfigValuesTool.test.js +8 -6
- package/mcp-server/utils/__tests__/content.test.js +21 -20
- package/mcp-server/utils/__tests__/feedbackTracking.test.js +34 -28
- package/mcp-server/utils/config.d.ts +1 -0
- package/mcp-server/utils/config.js +10 -0
- package/mcp-server/utils/content.d.ts +1 -1
- package/mcp-server/utils/content.js +2 -2
- package/mcp-server/utils/feedbackTracking.d.ts +1 -1
- package/mcp-server/utils/feedbackTracking.js +3 -3
- package/mcp-server/utils/toolUsageTracking.js +4 -3
- package/package.json +8 -7
- package/types/LocalDev.d.ts +1 -0
- package/lib/middleware/__test__/notificationsMiddleware.test.js +0 -8
- package/lib/middleware/notificationsMiddleware.d.ts +0 -1
- package/lib/middleware/notificationsMiddleware.js +0 -28
- package/mcp-server/utils/__tests__/cliConfig.test.js +0 -110
- package/mcp-server/utils/cliConfig.d.ts +0 -1
- package/mcp-server/utils/cliConfig.js +0 -12
- /package/{lib/middleware/__test__/commandTargetingUtils.test.d.ts → commands/project/__tests__/lint.test.d.ts} +0 -0
- /package/lib/middleware/{__test__/configMiddleware.test.d.ts → __tests__/commandTargetingUtils.test.d.ts} +0 -0
- /package/lib/middleware/{__test__/gitMiddleware.test.d.ts → __tests__/configMiddleware.test.d.ts} +0 -0
- /package/lib/middleware/{__test__/notificationsMiddleware.test.d.ts → __tests__/gitMiddleware.test.d.ts} +0 -0
- /package/lib/middleware/{__test__ → __tests__}/requestMiddleware.test.d.ts +0 -0
- /package/lib/middleware/{__test__ → __tests__}/requestMiddleware.test.js +0 -0
- /package/lib/middleware/{__test__ → __tests__}/yargsChecksMiddleware.test.d.ts +0 -0
- /package/lib/middleware/{__test__ → __tests__}/yargsChecksMiddleware.test.js +0 -0
- /package/{mcp-server/utils/__tests__/cliConfig.test.d.ts → lib/projects/__tests__/uieLinting.test.d.ts} +0 -0
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { DocsSearchTool } from '../DocsSearchTool.js';
|
|
2
2
|
import { http } from '@hubspot/local-dev-lib/http';
|
|
3
3
|
import { isHubSpotHttpError } from '@hubspot/local-dev-lib/errors/index';
|
|
4
|
-
import {
|
|
4
|
+
import { getConfigDefaultAccountIfExists } from '@hubspot/local-dev-lib/config';
|
|
5
5
|
import { mcpFeedbackRequest } from '../../../utils/feedbackTracking.js';
|
|
6
6
|
vi.mock('@modelcontextprotocol/sdk/server/mcp.js');
|
|
7
7
|
vi.mock('@hubspot/local-dev-lib/http');
|
|
8
8
|
vi.mock('@hubspot/local-dev-lib/errors/index');
|
|
9
|
+
vi.mock('@hubspot/local-dev-lib/config');
|
|
9
10
|
vi.mock('../../../utils/toolUsageTracking');
|
|
10
|
-
vi.mock('../../../utils/cliConfig.js');
|
|
11
11
|
vi.mock('../../../utils/feedbackTracking');
|
|
12
12
|
const mockMcpFeedbackRequest = mcpFeedbackRequest;
|
|
13
13
|
const mockHttp = http;
|
|
14
|
-
const mockGetAccountIdFromCliConfig = getAccountIdFromCliConfig;
|
|
15
14
|
const mockIsHubSpotHttpError = vi.mocked(isHubSpotHttpError);
|
|
15
|
+
const mockGetConfigDefaultAccountIfExists = getConfigDefaultAccountIfExists;
|
|
16
16
|
describe('mcp-server/tools/project/DocsSearchTool', () => {
|
|
17
17
|
let mockMcpServer;
|
|
18
18
|
let tool;
|
|
@@ -45,7 +45,7 @@ describe('mcp-server/tools/project/DocsSearchTool', () => {
|
|
|
45
45
|
absoluteCurrentWorkingDirectory: '/foo',
|
|
46
46
|
};
|
|
47
47
|
it('should return auth error message when no account ID is found', async () => {
|
|
48
|
-
|
|
48
|
+
mockGetConfigDefaultAccountIfExists.mockReturnValue(undefined);
|
|
49
49
|
const result = await tool.handler(mockInput);
|
|
50
50
|
expect(result).toEqual({
|
|
51
51
|
content: [
|
|
@@ -57,7 +57,9 @@ describe('mcp-server/tools/project/DocsSearchTool', () => {
|
|
|
57
57
|
});
|
|
58
58
|
});
|
|
59
59
|
it('should return successful results when docs are found', async () => {
|
|
60
|
-
|
|
60
|
+
mockGetConfigDefaultAccountIfExists.mockReturnValue({
|
|
61
|
+
accountId: 12345,
|
|
62
|
+
});
|
|
61
63
|
const mockResponse = {
|
|
62
64
|
results: [
|
|
63
65
|
{
|
|
@@ -81,7 +83,7 @@ describe('mcp-server/tools/project/DocsSearchTool', () => {
|
|
|
81
83
|
data: mockResponse,
|
|
82
84
|
});
|
|
83
85
|
const result = await tool.handler(mockInput);
|
|
84
|
-
expect(
|
|
86
|
+
expect(mockGetConfigDefaultAccountIfExists).toHaveBeenCalled();
|
|
85
87
|
expect(mockHttp.post).toHaveBeenCalledWith(12345, {
|
|
86
88
|
url: 'dev/docs/llms/v1/docs-search',
|
|
87
89
|
data: {
|
|
@@ -109,7 +111,9 @@ describe('mcp-server/tools/project/DocsSearchTool', () => {
|
|
|
109
111
|
expect(resultText).toContain('Test content 2');
|
|
110
112
|
});
|
|
111
113
|
it('should return no results message when no documentation is found', async () => {
|
|
112
|
-
|
|
114
|
+
mockGetConfigDefaultAccountIfExists.mockReturnValue({
|
|
115
|
+
accountId: 12345,
|
|
116
|
+
});
|
|
113
117
|
const mockResponse = {
|
|
114
118
|
results: [],
|
|
115
119
|
};
|
|
@@ -128,7 +132,9 @@ describe('mcp-server/tools/project/DocsSearchTool', () => {
|
|
|
128
132
|
});
|
|
129
133
|
});
|
|
130
134
|
it('should return no results message when results is null', async () => {
|
|
131
|
-
|
|
135
|
+
mockGetConfigDefaultAccountIfExists.mockReturnValue({
|
|
136
|
+
accountId: 12345,
|
|
137
|
+
});
|
|
132
138
|
const mockResponse = {
|
|
133
139
|
results: null,
|
|
134
140
|
};
|
|
@@ -147,7 +153,9 @@ describe('mcp-server/tools/project/DocsSearchTool', () => {
|
|
|
147
153
|
});
|
|
148
154
|
});
|
|
149
155
|
it('should handle HubSpot HTTP errors', async () => {
|
|
150
|
-
|
|
156
|
+
mockGetConfigDefaultAccountIfExists.mockReturnValue({
|
|
157
|
+
accountId: 12345,
|
|
158
|
+
});
|
|
151
159
|
const mockError = {
|
|
152
160
|
toString: () => 'HubSpot API Error: 404 Not Found',
|
|
153
161
|
};
|
|
@@ -164,7 +172,9 @@ describe('mcp-server/tools/project/DocsSearchTool', () => {
|
|
|
164
172
|
});
|
|
165
173
|
});
|
|
166
174
|
it('should handle generic errors', async () => {
|
|
167
|
-
|
|
175
|
+
mockGetConfigDefaultAccountIfExists.mockReturnValue({
|
|
176
|
+
accountId: 12345,
|
|
177
|
+
});
|
|
168
178
|
const mockError = new Error('Network error');
|
|
169
179
|
mockHttp.post.mockRejectedValue(mockError);
|
|
170
180
|
mockIsHubSpotHttpError.mockReturnValue(false);
|
|
@@ -179,7 +189,9 @@ describe('mcp-server/tools/project/DocsSearchTool', () => {
|
|
|
179
189
|
});
|
|
180
190
|
});
|
|
181
191
|
it('should handle non-Error rejections', async () => {
|
|
182
|
-
|
|
192
|
+
mockGetConfigDefaultAccountIfExists.mockReturnValue({
|
|
193
|
+
accountId: 12345,
|
|
194
|
+
});
|
|
183
195
|
mockHttp.post.mockRejectedValue('String error');
|
|
184
196
|
mockIsHubSpotHttpError.mockReturnValue(false);
|
|
185
197
|
const result = await tool.handler(mockInput);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GetApiUsagePatternsByAppIdTool } from '../GetApiUsagePatternsByAppIdTool.js';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import {
|
|
3
|
+
import { getConfigDefaultAccountIfExists } from '@hubspot/local-dev-lib/config';
|
|
4
4
|
import { http } from '@hubspot/local-dev-lib/http';
|
|
5
5
|
import { isHubSpotHttpError } from '@hubspot/local-dev-lib/errors/index';
|
|
6
6
|
import { mcpFeedbackRequest } from '../../../utils/feedbackTracking.js';
|
|
@@ -11,7 +11,7 @@ vi.mock('@hubspot/local-dev-lib/errors/index');
|
|
|
11
11
|
vi.mock('@hubspot/local-dev-lib/config');
|
|
12
12
|
vi.mock('../../../utils/feedbackTracking');
|
|
13
13
|
const mockMcpFeedbackRequest = mcpFeedbackRequest;
|
|
14
|
-
const
|
|
14
|
+
const mockGetConfigDefaultAccountIfExists = getConfigDefaultAccountIfExists;
|
|
15
15
|
const mockHttp = http;
|
|
16
16
|
const mockIsHubSpotHttpError = isHubSpotHttpError;
|
|
17
17
|
describe('mcp-server/tools/project/GetApiUsagePatternsByAppIdTool', () => {
|
|
@@ -89,7 +89,9 @@ describe('mcp-server/tools/project/GetApiUsagePatternsByAppIdTool', () => {
|
|
|
89
89
|
endDate: '2025-12-31',
|
|
90
90
|
};
|
|
91
91
|
beforeEach(() => {
|
|
92
|
-
|
|
92
|
+
mockGetConfigDefaultAccountIfExists.mockReturnValue({
|
|
93
|
+
accountId: 123456789,
|
|
94
|
+
});
|
|
93
95
|
mockIsHubSpotHttpError.mockReturnValue(false);
|
|
94
96
|
});
|
|
95
97
|
it('should return API usage patterns successfully', async () => {
|
|
@@ -118,7 +120,7 @@ describe('mcp-server/tools/project/GetApiUsagePatternsByAppIdTool', () => {
|
|
|
118
120
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
119
121
|
mockHttp.get.mockResolvedValue(mockResponse);
|
|
120
122
|
const result = await tool.handler(input);
|
|
121
|
-
expect(
|
|
123
|
+
expect(mockGetConfigDefaultAccountIfExists).toHaveBeenCalledWith();
|
|
122
124
|
expect(mockHttp.get).toHaveBeenCalledWith(123456789, {
|
|
123
125
|
url: 'app/feature/utilization/public/v3/insights/app/12345/usage-patterns',
|
|
124
126
|
params: {
|
|
@@ -136,7 +138,7 @@ describe('mcp-server/tools/project/GetApiUsagePatternsByAppIdTool', () => {
|
|
|
136
138
|
});
|
|
137
139
|
});
|
|
138
140
|
it('should return error when account ID cannot be determined', async () => {
|
|
139
|
-
|
|
141
|
+
mockGetConfigDefaultAccountIfExists.mockReturnValue(undefined);
|
|
140
142
|
const result = await tool.handler(input);
|
|
141
143
|
expect(result).toEqual({
|
|
142
144
|
content: [
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GetApplicationInfoTool } from '../GetApplicationInfoTool.js';
|
|
2
|
-
import {
|
|
2
|
+
import { getConfigDefaultAccountIfExists } from '@hubspot/local-dev-lib/config';
|
|
3
3
|
import { http } from '@hubspot/local-dev-lib/http';
|
|
4
4
|
import { isHubSpotHttpError } from '@hubspot/local-dev-lib/errors/index';
|
|
5
5
|
import { mcpFeedbackRequest } from '../../../utils/feedbackTracking.js';
|
|
@@ -10,7 +10,7 @@ vi.mock('@hubspot/local-dev-lib/errors/index');
|
|
|
10
10
|
vi.mock('@hubspot/local-dev-lib/config');
|
|
11
11
|
vi.mock('../../../utils/feedbackTracking');
|
|
12
12
|
const mockMcpFeedbackRequest = mcpFeedbackRequest;
|
|
13
|
-
const
|
|
13
|
+
const mockGetConfigDefaultAccountIfExists = getConfigDefaultAccountIfExists;
|
|
14
14
|
const mockHttp = http;
|
|
15
15
|
const mockIsHubSpotHttpError = isHubSpotHttpError;
|
|
16
16
|
describe('mcp-server/tools/project/GetApplicationInfoTool', () => {
|
|
@@ -42,7 +42,9 @@ describe('mcp-server/tools/project/GetApplicationInfoTool', () => {
|
|
|
42
42
|
describe('handler', () => {
|
|
43
43
|
const input = { absoluteCurrentWorkingDirectory: '/test/dir' };
|
|
44
44
|
beforeEach(() => {
|
|
45
|
-
|
|
45
|
+
mockGetConfigDefaultAccountIfExists.mockReturnValue({
|
|
46
|
+
accountId: 123456789,
|
|
47
|
+
});
|
|
46
48
|
mockIsHubSpotHttpError.mockReturnValue(false);
|
|
47
49
|
});
|
|
48
50
|
it('should return application information successfully', async () => {
|
|
@@ -67,7 +69,7 @@ describe('mcp-server/tools/project/GetApplicationInfoTool', () => {
|
|
|
67
69
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
68
70
|
mockHttp.get.mockResolvedValue(mockResponse);
|
|
69
71
|
const result = await tool.handler(input);
|
|
70
|
-
expect(
|
|
72
|
+
expect(mockGetConfigDefaultAccountIfExists).toHaveBeenCalledWith();
|
|
71
73
|
expect(mockHttp.get).toHaveBeenCalledWith(123456789, {
|
|
72
74
|
url: 'app/feature/utilization/public/v3/insights/apps',
|
|
73
75
|
});
|
|
@@ -81,7 +83,7 @@ describe('mcp-server/tools/project/GetApplicationInfoTool', () => {
|
|
|
81
83
|
});
|
|
82
84
|
});
|
|
83
85
|
it('should return error when account ID cannot be determined', async () => {
|
|
84
|
-
|
|
86
|
+
mockGetConfigDefaultAccountIfExists.mockReturnValue(undefined);
|
|
85
87
|
const result = await tool.handler(input);
|
|
86
88
|
expect(result).toEqual({
|
|
87
89
|
content: [
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
import { GetBuildLogsTool } from '../GetBuildLogsTool.js';
|
|
2
|
+
import { http } from '@hubspot/local-dev-lib/http';
|
|
3
|
+
import { isHubSpotHttpError } from '@hubspot/local-dev-lib/errors/index';
|
|
4
|
+
import { getProjectConfig, validateProjectConfig, } from '../../../../lib/projects/config.js';
|
|
5
|
+
import { mcpFeedbackRequest } from '../../../utils/feedbackTracking.js';
|
|
6
|
+
import { getConfigDefaultAccountIfExists } from '@hubspot/local-dev-lib/config';
|
|
7
|
+
vi.mock('@modelcontextprotocol/sdk/server/mcp.js');
|
|
8
|
+
vi.mock('../../../utils/toolUsageTracking');
|
|
9
|
+
vi.mock('../../../utils/cliConfig');
|
|
10
|
+
vi.mock('@hubspot/local-dev-lib/http');
|
|
11
|
+
vi.mock('@hubspot/local-dev-lib/errors/index');
|
|
12
|
+
vi.mock('../../../../lib/projects/config.js');
|
|
13
|
+
vi.mock('../../../utils/feedbackTracking');
|
|
14
|
+
vi.mock('@hubspot/local-dev-lib/config');
|
|
15
|
+
const mockMcpFeedbackRequest = mcpFeedbackRequest;
|
|
16
|
+
const mockGetConfigDefaultAccountIfExists = getConfigDefaultAccountIfExists;
|
|
17
|
+
const mockHttpGet = http.get;
|
|
18
|
+
const mockIsHubSpotHttpError = isHubSpotHttpError;
|
|
19
|
+
const mockGetProjectConfig = getProjectConfig;
|
|
20
|
+
const mockValidateProjectConfig = validateProjectConfig;
|
|
21
|
+
const TEST_ACCOUNT_ID = 123456789;
|
|
22
|
+
const TEST_PROJECT_NAME = 'test-project';
|
|
23
|
+
const TEST_PROJECT_PATH = '/test/project';
|
|
24
|
+
const TEST_WORKING_DIR = '/test';
|
|
25
|
+
const TEST_BUILD_ID = 123;
|
|
26
|
+
const TEST_PLATFORM_VERSION = '2025.2';
|
|
27
|
+
function createMockLog(overrides = {}) {
|
|
28
|
+
return {
|
|
29
|
+
lineNumber: 1,
|
|
30
|
+
logLevel: 'INFO',
|
|
31
|
+
message: 'Starting build validation',
|
|
32
|
+
pipelineStepId: 1,
|
|
33
|
+
pipelineSubstepId: 'test-step',
|
|
34
|
+
pipelineSubstepName: 'test-component',
|
|
35
|
+
timestamp: Date.now(),
|
|
36
|
+
...overrides,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function createMockLogs() {
|
|
40
|
+
return {
|
|
41
|
+
pipelineStage: 'BUILD',
|
|
42
|
+
pipelineStepId: 2,
|
|
43
|
+
projectName: TEST_PROJECT_NAME,
|
|
44
|
+
logs: [
|
|
45
|
+
{
|
|
46
|
+
pipelineStepId: 2,
|
|
47
|
+
pipelineSubstepId: 'test-app-id',
|
|
48
|
+
pipelineStage: 'BUILD',
|
|
49
|
+
projectName: TEST_PROJECT_NAME,
|
|
50
|
+
logs: [
|
|
51
|
+
createMockLog({
|
|
52
|
+
lineNumber: 1,
|
|
53
|
+
logLevel: 'INFO',
|
|
54
|
+
message: "Starting build validation for app 'Test App'",
|
|
55
|
+
pipelineSubstepName: 'test-app',
|
|
56
|
+
pipelineSubstepId: 'test-app-id',
|
|
57
|
+
}),
|
|
58
|
+
createMockLog({
|
|
59
|
+
lineNumber: 2,
|
|
60
|
+
logLevel: 'INFO',
|
|
61
|
+
message: "Successfully validated app configuration for 'Test App'",
|
|
62
|
+
pipelineSubstepName: 'test-app',
|
|
63
|
+
pipelineSubstepId: 'test-app-id',
|
|
64
|
+
}),
|
|
65
|
+
],
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
pipelineStepId: 2,
|
|
69
|
+
pipelineSubstepId: 'test-card-id',
|
|
70
|
+
pipelineStage: 'BUILD',
|
|
71
|
+
projectName: TEST_PROJECT_NAME,
|
|
72
|
+
logs: [
|
|
73
|
+
createMockLog({
|
|
74
|
+
lineNumber: 1,
|
|
75
|
+
logLevel: 'INFO',
|
|
76
|
+
message: 'Starting card build...',
|
|
77
|
+
pipelineSubstepName: 'test-card',
|
|
78
|
+
pipelineSubstepId: 'test-card-id',
|
|
79
|
+
}),
|
|
80
|
+
createMockLog({
|
|
81
|
+
lineNumber: 2,
|
|
82
|
+
logLevel: 'INFO',
|
|
83
|
+
message: 'Validating card configuration...',
|
|
84
|
+
pipelineSubstepName: 'test-card',
|
|
85
|
+
pipelineSubstepId: 'test-card-id',
|
|
86
|
+
}),
|
|
87
|
+
createMockLog({
|
|
88
|
+
lineNumber: 3,
|
|
89
|
+
logLevel: 'ERROR',
|
|
90
|
+
message: 'Failed to build card. The preview image file /app/cards/assets/preview.png was not found. Make sure the file exists in /app/cards and try again.',
|
|
91
|
+
pipelineSubstepName: 'test-card',
|
|
92
|
+
pipelineSubstepId: 'test-card-id',
|
|
93
|
+
}),
|
|
94
|
+
],
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
pipelineStepId: 2,
|
|
98
|
+
pipelineSubstepId: 'test-webhook-id',
|
|
99
|
+
pipelineStage: 'BUILD',
|
|
100
|
+
projectName: TEST_PROJECT_NAME,
|
|
101
|
+
logs: [
|
|
102
|
+
createMockLog({
|
|
103
|
+
lineNumber: 1,
|
|
104
|
+
logLevel: 'WARN',
|
|
105
|
+
message: 'Deprecated API usage detected in webhook configuration',
|
|
106
|
+
pipelineSubstepName: 'test-webhook',
|
|
107
|
+
pipelineSubstepId: 'test-webhook-id',
|
|
108
|
+
}),
|
|
109
|
+
],
|
|
110
|
+
},
|
|
111
|
+
],
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
function createLogsResponse(data) {
|
|
115
|
+
return {
|
|
116
|
+
data,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
function createMockProjectConfig(overrides = {}) {
|
|
120
|
+
return {
|
|
121
|
+
name: TEST_PROJECT_NAME,
|
|
122
|
+
srcDir: 'src',
|
|
123
|
+
platformVersion: TEST_PLATFORM_VERSION,
|
|
124
|
+
...overrides,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
function expectTextContent(result, ...expectedStrings) {
|
|
128
|
+
expectedStrings.forEach(str => {
|
|
129
|
+
expect(result.content[1].text).toContain(str);
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
describe('mcp-server/tools/project/GetBuildLogsTool', () => {
|
|
133
|
+
let mockMcpServer;
|
|
134
|
+
let tool;
|
|
135
|
+
let mockRegisteredTool;
|
|
136
|
+
beforeEach(() => {
|
|
137
|
+
vi.clearAllMocks();
|
|
138
|
+
// @ts-expect-error Not mocking the whole thing
|
|
139
|
+
mockMcpServer = {
|
|
140
|
+
registerTool: vi.fn(),
|
|
141
|
+
};
|
|
142
|
+
mockRegisteredTool = {};
|
|
143
|
+
mockMcpServer.registerTool.mockReturnValue(mockRegisteredTool);
|
|
144
|
+
mockMcpFeedbackRequest.mockResolvedValue('');
|
|
145
|
+
tool = new GetBuildLogsTool(mockMcpServer);
|
|
146
|
+
// Default mock implementations
|
|
147
|
+
mockGetConfigDefaultAccountIfExists.mockReturnValue({
|
|
148
|
+
accountId: TEST_ACCOUNT_ID,
|
|
149
|
+
});
|
|
150
|
+
mockIsHubSpotHttpError.mockReturnValue(false);
|
|
151
|
+
mockGetProjectConfig.mockResolvedValue({
|
|
152
|
+
projectConfig: createMockProjectConfig(),
|
|
153
|
+
projectDir: TEST_PROJECT_PATH,
|
|
154
|
+
});
|
|
155
|
+
mockValidateProjectConfig.mockImplementation(() => { });
|
|
156
|
+
});
|
|
157
|
+
describe('register', () => {
|
|
158
|
+
it('should register tool with correct parameters', () => {
|
|
159
|
+
const result = tool.register();
|
|
160
|
+
expect(mockMcpServer.registerTool).toHaveBeenCalledWith('get-build-logs', expect.objectContaining({
|
|
161
|
+
title: 'Get HubSpot Project Build Logs',
|
|
162
|
+
description: expect.stringContaining('Retrieves build logs for a specific HubSpot project build'),
|
|
163
|
+
inputSchema: expect.anything(),
|
|
164
|
+
}), expect.any(Function));
|
|
165
|
+
expect(result).toBe(mockRegisteredTool);
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
describe('handler', () => {
|
|
169
|
+
const baseInput = {
|
|
170
|
+
absoluteProjectPath: TEST_PROJECT_PATH,
|
|
171
|
+
absoluteCurrentWorkingDirectory: TEST_WORKING_DIR,
|
|
172
|
+
buildId: TEST_BUILD_ID,
|
|
173
|
+
logLevel: 'ALL',
|
|
174
|
+
};
|
|
175
|
+
describe('error handling', () => {
|
|
176
|
+
it('should return error when account ID cannot be determined', async () => {
|
|
177
|
+
mockGetConfigDefaultAccountIfExists.mockReturnValue(undefined);
|
|
178
|
+
const result = await tool.handler(baseInput);
|
|
179
|
+
expect(result).toEqual({
|
|
180
|
+
content: [
|
|
181
|
+
{
|
|
182
|
+
type: 'text',
|
|
183
|
+
text: TEST_WORKING_DIR,
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
type: 'text',
|
|
187
|
+
text: 'No account ID found. Please run `hs account auth` to configure an account, or set a default account with `hs account use <account>`',
|
|
188
|
+
},
|
|
189
|
+
],
|
|
190
|
+
});
|
|
191
|
+
expect(mockHttpGet).not.toHaveBeenCalled();
|
|
192
|
+
});
|
|
193
|
+
it('should handle HubSpot HTTP errors', async () => {
|
|
194
|
+
const error = new Error('API Error');
|
|
195
|
+
mockIsHubSpotHttpError.mockReturnValue(true);
|
|
196
|
+
mockHttpGet.mockRejectedValue(error);
|
|
197
|
+
const result = await tool.handler(baseInput);
|
|
198
|
+
expectTextContent(result, 'API Error');
|
|
199
|
+
});
|
|
200
|
+
it('should handle generic errors', async () => {
|
|
201
|
+
const error = new Error('Generic error');
|
|
202
|
+
mockIsHubSpotHttpError.mockReturnValue(false);
|
|
203
|
+
mockHttpGet.mockRejectedValue(error);
|
|
204
|
+
const result = await tool.handler(baseInput);
|
|
205
|
+
expectTextContent(result, 'Generic error');
|
|
206
|
+
});
|
|
207
|
+
it('should handle empty logs', async () => {
|
|
208
|
+
const emptyLogsResponse = {
|
|
209
|
+
pipelineStage: 'BUILD',
|
|
210
|
+
pipelineStepId: 2,
|
|
211
|
+
projectName: TEST_PROJECT_NAME,
|
|
212
|
+
logs: [],
|
|
213
|
+
};
|
|
214
|
+
mockHttpGet.mockResolvedValue(
|
|
215
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
216
|
+
createLogsResponse(emptyLogsResponse));
|
|
217
|
+
const result = await tool.handler(baseInput);
|
|
218
|
+
expectTextContent(result, `No logs found for build #${TEST_BUILD_ID}`, TEST_PROJECT_NAME);
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
describe('log fetching', () => {
|
|
222
|
+
it('should fetch and display all logs', async () => {
|
|
223
|
+
const mockLogs = createMockLogs();
|
|
224
|
+
mockHttpGet.mockResolvedValue(
|
|
225
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
226
|
+
createLogsResponse(mockLogs));
|
|
227
|
+
const result = await tool.handler(baseInput);
|
|
228
|
+
expect(mockGetProjectConfig).toHaveBeenCalledWith(TEST_PROJECT_PATH);
|
|
229
|
+
expect(mockHttpGet).toHaveBeenCalledWith(TEST_ACCOUNT_ID, {
|
|
230
|
+
url: `dfs/logging/v1/logs/projects/${TEST_PROJECT_NAME}/builds/${TEST_BUILD_ID}`,
|
|
231
|
+
});
|
|
232
|
+
expectTextContent(result, `Logs for build #${TEST_BUILD_ID}`, TEST_PROJECT_NAME, 'ALL level', 'Starting build validation', 'Successfully validated', 'Failed to build card', 'Deprecated API usage');
|
|
233
|
+
});
|
|
234
|
+
it('should filter logs by ERROR level', async () => {
|
|
235
|
+
const mockLogs = createMockLogs();
|
|
236
|
+
mockHttpGet.mockResolvedValue(
|
|
237
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
238
|
+
createLogsResponse(mockLogs));
|
|
239
|
+
const result = await tool.handler({
|
|
240
|
+
...baseInput,
|
|
241
|
+
logLevel: 'ERROR',
|
|
242
|
+
});
|
|
243
|
+
expectTextContent(result, 'ERROR level', 'Failed to build card', 'preview.png was not found');
|
|
244
|
+
expect(result.content[1].text).not.toContain('Starting build');
|
|
245
|
+
expect(result.content[1].text).not.toContain('Deprecated API');
|
|
246
|
+
});
|
|
247
|
+
it('should filter logs by WARN level', async () => {
|
|
248
|
+
const mockLogs = createMockLogs();
|
|
249
|
+
mockHttpGet.mockResolvedValue(
|
|
250
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
251
|
+
createLogsResponse(mockLogs));
|
|
252
|
+
const result = await tool.handler({
|
|
253
|
+
...baseInput,
|
|
254
|
+
logLevel: 'WARN',
|
|
255
|
+
});
|
|
256
|
+
expectTextContent(result, 'WARN level', 'Deprecated API usage detected');
|
|
257
|
+
expect(result.content[1].text).not.toContain('Starting build');
|
|
258
|
+
expect(result.content[1].text).not.toContain('Failed to build card');
|
|
259
|
+
});
|
|
260
|
+
it('should filter logs by INFO level', async () => {
|
|
261
|
+
const mockLogs = createMockLogs();
|
|
262
|
+
mockHttpGet.mockResolvedValue(
|
|
263
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
264
|
+
createLogsResponse(mockLogs));
|
|
265
|
+
const result = await tool.handler({
|
|
266
|
+
...baseInput,
|
|
267
|
+
logLevel: 'INFO',
|
|
268
|
+
});
|
|
269
|
+
expectTextContent(result, 'INFO level', 'Starting build validation', 'Successfully validated');
|
|
270
|
+
expect(result.content[1].text).not.toContain('Failed to build card');
|
|
271
|
+
expect(result.content[1].text).not.toContain('Deprecated API');
|
|
272
|
+
});
|
|
273
|
+
it('should show all logs when no logs match filter', async () => {
|
|
274
|
+
const infoOnlyResponse = {
|
|
275
|
+
pipelineStage: 'BUILD',
|
|
276
|
+
pipelineStepId: 2,
|
|
277
|
+
projectName: TEST_PROJECT_NAME,
|
|
278
|
+
logs: [
|
|
279
|
+
{
|
|
280
|
+
pipelineStepId: 2,
|
|
281
|
+
pipelineSubstepId: 'info-only-id',
|
|
282
|
+
pipelineStage: 'BUILD',
|
|
283
|
+
projectName: TEST_PROJECT_NAME,
|
|
284
|
+
logs: [
|
|
285
|
+
createMockLog({
|
|
286
|
+
logLevel: 'INFO',
|
|
287
|
+
message: 'Info message only',
|
|
288
|
+
pipelineSubstepId: 'info-only-id',
|
|
289
|
+
}),
|
|
290
|
+
],
|
|
291
|
+
},
|
|
292
|
+
],
|
|
293
|
+
};
|
|
294
|
+
mockHttpGet.mockResolvedValue(
|
|
295
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
296
|
+
createLogsResponse(infoOnlyResponse));
|
|
297
|
+
const result = await tool.handler({
|
|
298
|
+
...baseInput,
|
|
299
|
+
logLevel: 'ERROR',
|
|
300
|
+
});
|
|
301
|
+
expectTextContent(result, `No ERROR level logs found`, `build #${TEST_BUILD_ID}`, 'Showing all logs instead', 'Info message only');
|
|
302
|
+
});
|
|
303
|
+
});
|
|
304
|
+
});
|
|
305
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|