@hubspot/cli 7.7.30-experimental.0 → 7.7.32-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 (33) hide show
  1. package/lang/en.d.ts +3 -1
  2. package/lang/en.js +4 -2
  3. package/lib/projects/__tests__/AppDevModeInterface.test.js +10 -0
  4. package/lib/projects/localDev/AppDevModeInterface.d.ts +5 -1
  5. package/lib/projects/localDev/AppDevModeInterface.js +33 -10
  6. package/mcp-server/tools/cms/HsCreateFunctionTool.d.ts +32 -0
  7. package/mcp-server/tools/cms/HsCreateFunctionTool.js +96 -0
  8. package/mcp-server/tools/cms/HsCreateTemplateTool.d.ts +26 -0
  9. package/mcp-server/tools/cms/HsCreateTemplateTool.js +75 -0
  10. package/mcp-server/tools/cms/HsListFunctionsTool.d.ts +23 -0
  11. package/mcp-server/tools/cms/HsListFunctionsTool.js +58 -0
  12. package/mcp-server/tools/cms/__tests__/HsCreateFunctionTool.test.d.ts +1 -0
  13. package/mcp-server/tools/cms/__tests__/HsCreateFunctionTool.test.js +251 -0
  14. package/mcp-server/tools/cms/__tests__/HsCreateTemplateTool.test.d.ts +1 -0
  15. package/mcp-server/tools/cms/__tests__/HsCreateTemplateTool.test.js +206 -0
  16. package/mcp-server/tools/cms/__tests__/HsListFunctionsTool.test.d.ts +1 -0
  17. package/mcp-server/tools/cms/__tests__/HsListFunctionsTool.test.js +120 -0
  18. package/mcp-server/tools/index.js +6 -0
  19. package/package.json +2 -1
  20. package/ui/components/BoxWithTitle.d.ts +8 -0
  21. package/ui/components/BoxWithTitle.js +9 -0
  22. package/ui/components/HorizontalSelectPrompt.d.ts +8 -0
  23. package/ui/components/HorizontalSelectPrompt.js +30 -0
  24. package/ui/components/StatusMessageBoxes.d.ts +12 -0
  25. package/ui/components/StatusMessageBoxes.js +31 -0
  26. package/ui/lib/ui-testing-utils.d.ts +9 -0
  27. package/ui/lib/ui-testing-utils.js +47 -0
  28. package/ui/lib/useTerminalSize.d.ts +13 -0
  29. package/ui/lib/useTerminalSize.js +31 -0
  30. package/ui/styles.d.ts +18 -0
  31. package/ui/styles.js +18 -0
  32. package/ui/views/UiSandbox.d.ts +5 -0
  33. package/ui/views/UiSandbox.js +25 -0
@@ -0,0 +1,251 @@
1
+ import { describe, it, expect, vi, beforeEach } from 'vitest';
2
+ import { HsCreateFunctionTool } from '../HsCreateFunctionTool.js';
3
+ import { runCommandInDir } from '../../../utils/project.js';
4
+ import { addFlag } from '../../../utils/command.js';
5
+ import { HTTP_METHODS } from '../../../../types/Cms.js';
6
+ vi.mock('@modelcontextprotocol/sdk/server/mcp.js');
7
+ vi.mock('../../../utils/project');
8
+ vi.mock('../../../utils/command');
9
+ vi.mock('../../../utils/toolUsageTracking', () => ({
10
+ trackToolUsage: vi.fn(),
11
+ }));
12
+ const mockRunCommandInDir = runCommandInDir;
13
+ const mockAddFlag = addFlag;
14
+ describe('HsCreateFunctionTool', () => {
15
+ let mockMcpServer;
16
+ let tool;
17
+ let mockRegisteredTool;
18
+ beforeEach(() => {
19
+ vi.clearAllMocks();
20
+ // @ts-expect-error Not mocking the whole server
21
+ mockMcpServer = {
22
+ registerTool: vi.fn(),
23
+ };
24
+ mockRegisteredTool = {};
25
+ mockMcpServer.registerTool.mockReturnValue(mockRegisteredTool);
26
+ tool = new HsCreateFunctionTool(mockMcpServer);
27
+ });
28
+ describe('register', () => {
29
+ it('should register the tool with the MCP server', () => {
30
+ const result = tool.register();
31
+ expect(mockMcpServer.registerTool).toHaveBeenCalledWith('create-hubspot-cms-function', {
32
+ title: 'Create HubSpot CMS Serverless Function',
33
+ description: `Creates a new HubSpot CMS serverless function using the hs create function command. Functions can be created non-interactively by specifying functionsFolder, filename, and endpointPath. Supports all HTTP methods (${HTTP_METHODS.join(', ')}).`,
34
+ inputSchema: expect.any(Object),
35
+ }, expect.any(Function));
36
+ expect(result).toBe(mockRegisteredTool);
37
+ });
38
+ });
39
+ describe('handler', () => {
40
+ it('should prompt for all missing required parameters', async () => {
41
+ const result = await tool.handler({
42
+ absoluteCurrentWorkingDirectory: '/test/dir',
43
+ });
44
+ expect(result.content).toHaveLength(3);
45
+ expect(result.content[0].text).toContain('Ask the user to provide the folder name for the function');
46
+ expect(result.content[1].text).toContain('Ask the user to provide the filename for the function');
47
+ expect(result.content[2].text).toContain('Ask the user to provide the API endpoint path for the function');
48
+ });
49
+ it('should not prompt when all required params provided', async () => {
50
+ mockAddFlag
51
+ .mockReturnValueOnce('hs create function --functions-folder api')
52
+ .mockReturnValueOnce('hs create function --functions-folder api --filename test-function')
53
+ .mockReturnValueOnce('hs create function --functions-folder api --filename test-function --endpoint-method GET')
54
+ .mockReturnValueOnce('hs create function --functions-folder api --filename test-function --endpoint-method GET --endpoint-path /api/test');
55
+ mockRunCommandInDir.mockResolvedValue({
56
+ stdout: 'Function created successfully',
57
+ stderr: '',
58
+ });
59
+ const result = await tool.handler({
60
+ absoluteCurrentWorkingDirectory: '/test/dir',
61
+ functionsFolder: 'api',
62
+ filename: 'test-function',
63
+ endpointPath: '/api/test',
64
+ });
65
+ expect(result.content).toHaveLength(2);
66
+ expect(result.content[0].text).toContain('Function created successfully');
67
+ });
68
+ it('should prompt for missing functionsFolder when other required params provided', async () => {
69
+ const result = await tool.handler({
70
+ absoluteCurrentWorkingDirectory: '/test/dir',
71
+ filename: 'test-function',
72
+ endpointPath: '/api/test',
73
+ });
74
+ expect(result.content).toHaveLength(1);
75
+ expect(result.content[0].text).toContain('Ask the user to provide the folder name for the function');
76
+ });
77
+ it('should prompt for missing filename when other required params provided', async () => {
78
+ const result = await tool.handler({
79
+ absoluteCurrentWorkingDirectory: '/test/dir',
80
+ functionsFolder: 'api',
81
+ endpointPath: '/api/test',
82
+ });
83
+ expect(result.content).toHaveLength(1);
84
+ expect(result.content[0].text).toContain('Ask the user to provide the filename for the function');
85
+ });
86
+ it('should prompt for missing endpointPath when other required params provided', async () => {
87
+ const result = await tool.handler({
88
+ absoluteCurrentWorkingDirectory: '/test/dir',
89
+ functionsFolder: 'api',
90
+ filename: 'test-function',
91
+ });
92
+ expect(result.content).toHaveLength(1);
93
+ expect(result.content[0].text).toContain('Ask the user to provide the API endpoint path for the function');
94
+ });
95
+ it('should execute command with all required parameters (default GET method)', async () => {
96
+ mockAddFlag
97
+ .mockReturnValueOnce('hs create function --functions-folder api')
98
+ .mockReturnValueOnce('hs create function --functions-folder api --filename test-function')
99
+ .mockReturnValueOnce('hs create function --functions-folder api --filename test-function --endpoint-method GET')
100
+ .mockReturnValueOnce('hs create function --functions-folder api --filename test-function --endpoint-method GET --endpoint-path /api/test');
101
+ mockRunCommandInDir.mockResolvedValue({
102
+ stdout: 'Function created successfully',
103
+ stderr: '',
104
+ });
105
+ const result = await tool.handler({
106
+ absoluteCurrentWorkingDirectory: '/test/dir',
107
+ functionsFolder: 'api',
108
+ filename: 'test-function',
109
+ endpointPath: '/api/test',
110
+ });
111
+ expect(mockAddFlag).toHaveBeenCalledWith('hs create function', 'functions-folder', 'api');
112
+ expect(mockAddFlag).toHaveBeenCalledWith(expect.stringContaining('functions-folder'), 'filename', 'test-function');
113
+ expect(mockAddFlag).toHaveBeenCalledWith(expect.stringContaining('filename'), 'endpoint-method', 'GET');
114
+ expect(mockAddFlag).toHaveBeenCalledWith(expect.stringContaining('endpoint-method'), 'endpoint-path', '/api/test');
115
+ expect(mockRunCommandInDir).toHaveBeenCalledWith('/test/dir', expect.stringContaining('hs create function'));
116
+ expect(result.content).toHaveLength(2);
117
+ expect(result.content[0].text).toContain('Function created successfully');
118
+ });
119
+ it('should execute command with POST method', async () => {
120
+ mockAddFlag
121
+ .mockReturnValueOnce('hs create function --functions-folder api')
122
+ .mockReturnValueOnce('hs create function --functions-folder api --filename post-function')
123
+ .mockReturnValueOnce('hs create function "POST Function" --functions-folder api --filename post-function --endpoint-method POST')
124
+ .mockReturnValueOnce('hs create function "POST Function" --functions-folder api --filename post-function --endpoint-method POST --endpoint-path /api/create');
125
+ mockRunCommandInDir.mockResolvedValue({
126
+ stdout: 'POST function created successfully',
127
+ stderr: '',
128
+ });
129
+ const result = await tool.handler({
130
+ absoluteCurrentWorkingDirectory: '/test/dir',
131
+ functionsFolder: 'api',
132
+ filename: 'post-function',
133
+ endpointMethod: 'POST',
134
+ endpointPath: '/api/create',
135
+ });
136
+ expect(mockAddFlag).toHaveBeenCalledWith(expect.stringContaining('filename'), 'endpoint-method', 'POST');
137
+ expect(result.content[0].text).toContain('POST function created successfully');
138
+ });
139
+ it('should execute command with PUT method', async () => {
140
+ mockAddFlag
141
+ .mockReturnValueOnce('hs create function --functions-folder api')
142
+ .mockReturnValueOnce('hs create function "PUT Function" --functions-folder api --filename put-function')
143
+ .mockReturnValueOnce('hs create function "PUT Function" --functions-folder api --filename put-function --endpoint-method PUT')
144
+ .mockReturnValueOnce('hs create function "PUT Function" --functions-folder api --filename put-function --endpoint-method PUT --endpoint-path /api/update');
145
+ mockRunCommandInDir.mockResolvedValue({
146
+ stdout: 'PUT function created successfully',
147
+ stderr: '',
148
+ });
149
+ const result = await tool.handler({
150
+ absoluteCurrentWorkingDirectory: '/test/dir',
151
+ functionsFolder: 'api',
152
+ filename: 'put-function',
153
+ endpointMethod: 'PUT',
154
+ endpointPath: '/api/update',
155
+ });
156
+ expect(mockAddFlag).toHaveBeenCalledWith(expect.stringContaining('filename'), 'endpoint-method', 'PUT');
157
+ expect(result.content[0].text).toContain('PUT function created successfully');
158
+ });
159
+ it('should execute command with DELETE method', async () => {
160
+ mockAddFlag
161
+ .mockReturnValueOnce('hs create function --functions-folder api')
162
+ .mockReturnValueOnce('hs create function "DELETE Function" --functions-folder api --filename delete-function')
163
+ .mockReturnValueOnce('hs create function "DELETE Function" --functions-folder api --filename delete-function --endpoint-method DELETE')
164
+ .mockReturnValueOnce('hs create function "DELETE Function" --functions-folder api --filename delete-function --endpoint-method DELETE --endpoint-path /api/delete');
165
+ mockRunCommandInDir.mockResolvedValue({
166
+ stdout: 'DELETE function created successfully',
167
+ stderr: '',
168
+ });
169
+ const result = await tool.handler({
170
+ absoluteCurrentWorkingDirectory: '/test/dir',
171
+ functionsFolder: 'api',
172
+ filename: 'delete-function',
173
+ endpointMethod: 'DELETE',
174
+ endpointPath: '/api/delete',
175
+ });
176
+ expect(mockAddFlag).toHaveBeenCalledWith(expect.stringContaining('filename'), 'endpoint-method', 'DELETE');
177
+ expect(result.content[0].text).toContain('DELETE function created successfully');
178
+ });
179
+ it('should execute command with PATCH method', async () => {
180
+ mockAddFlag
181
+ .mockReturnValueOnce('hs create function --functions-folder api')
182
+ .mockReturnValueOnce('hs create function "PATCH Function" --functions-folder api --filename patch-function')
183
+ .mockReturnValueOnce('hs create function "PATCH Function" --functions-folder api --filename patch-function --endpoint-method PATCH')
184
+ .mockReturnValueOnce('hs create function "PATCH Function" --functions-folder api --filename patch-function --endpoint-method PATCH --endpoint-path /api/patch');
185
+ mockRunCommandInDir.mockResolvedValue({
186
+ stdout: 'PATCH function created successfully',
187
+ stderr: '',
188
+ });
189
+ const result = await tool.handler({
190
+ absoluteCurrentWorkingDirectory: '/test/dir',
191
+ functionsFolder: 'api',
192
+ filename: 'patch-function',
193
+ endpointMethod: 'PATCH',
194
+ endpointPath: '/api/patch',
195
+ });
196
+ expect(mockAddFlag).toHaveBeenCalledWith(expect.stringContaining('filename'), 'endpoint-method', 'PATCH');
197
+ expect(result.content[0].text).toContain('PATCH function created successfully');
198
+ });
199
+ it('should handle command execution errors', async () => {
200
+ mockRunCommandInDir.mockRejectedValue(new Error('Function creation failed'));
201
+ const result = await tool.handler({
202
+ absoluteCurrentWorkingDirectory: '/test/dir',
203
+ functionsFolder: 'api',
204
+ filename: 'test-function',
205
+ endpointPath: '/api/test',
206
+ });
207
+ expect(result.content).toHaveLength(1);
208
+ expect(result.content[0].text).toContain('Function creation failed');
209
+ });
210
+ it('should handle stderr output', async () => {
211
+ mockAddFlag
212
+ .mockReturnValueOnce('hs create function "Test Function" --functions-folder api')
213
+ .mockReturnValueOnce('hs create function "Test Function" --functions-folder api --filename test-function')
214
+ .mockReturnValueOnce('hs create function "Test Function" --functions-folder api --filename test-function --endpoint-method GET')
215
+ .mockReturnValueOnce('hs create function "Test Function" --functions-folder api --filename test-function --endpoint-method GET --endpoint-path /api/test');
216
+ mockRunCommandInDir.mockResolvedValue({
217
+ stdout: 'Function created successfully',
218
+ stderr: 'Warning: Using deprecated function syntax',
219
+ });
220
+ const result = await tool.handler({
221
+ absoluteCurrentWorkingDirectory: '/test/dir',
222
+ functionsFolder: 'api',
223
+ filename: 'test-function',
224
+ endpointPath: '/api/test',
225
+ });
226
+ expect(result.content).toHaveLength(2);
227
+ expect(result.content[0].text).toContain('Function created successfully');
228
+ expect(result.content[1].text).toContain('Warning: Using deprecated function syntax');
229
+ });
230
+ it('should execute command with destination path', async () => {
231
+ mockAddFlag
232
+ .mockReturnValueOnce('hs create function "functions/custom" --functions-folder api')
233
+ .mockReturnValueOnce('hs create function "functions/custom" --functions-folder api --filename test-function')
234
+ .mockReturnValueOnce('hs create function "functions/custom" --functions-folder api --filename test-function --endpoint-method GET')
235
+ .mockReturnValueOnce('hs create function "functions/custom" --functions-folder api --filename test-function --endpoint-method GET --endpoint-path /api/test');
236
+ mockRunCommandInDir.mockResolvedValue({
237
+ stdout: 'Function created at custom path',
238
+ stderr: '',
239
+ });
240
+ const result = await tool.handler({
241
+ absoluteCurrentWorkingDirectory: '/test/dir',
242
+ dest: 'functions/custom',
243
+ functionsFolder: 'api',
244
+ filename: 'test-function',
245
+ endpointPath: '/api/test',
246
+ });
247
+ expect(mockRunCommandInDir).toHaveBeenCalledWith('/test/dir', expect.stringContaining('"functions/custom"'));
248
+ expect(result.content[0].text).toContain('Function created at custom path');
249
+ });
250
+ });
251
+ });
@@ -0,0 +1,206 @@
1
+ import { describe, it, expect, vi, beforeEach } from 'vitest';
2
+ import { HsCreateTemplateTool } from '../HsCreateTemplateTool.js';
3
+ import { runCommandInDir } from '../../../utils/project.js';
4
+ import { addFlag } from '../../../utils/command.js';
5
+ import { TEMPLATE_TYPES } from '../../../../types/Cms.js';
6
+ vi.mock('@modelcontextprotocol/sdk/server/mcp.js');
7
+ vi.mock('../../../utils/project');
8
+ vi.mock('../../../utils/command');
9
+ vi.mock('../../../utils/toolUsageTracking', () => ({
10
+ trackToolUsage: vi.fn(),
11
+ }));
12
+ const mockRunCommandInDir = runCommandInDir;
13
+ const mockAddFlag = addFlag;
14
+ describe('HsCreateTemplateTool', () => {
15
+ let mockMcpServer;
16
+ let tool;
17
+ let mockRegisteredTool;
18
+ beforeEach(() => {
19
+ vi.clearAllMocks();
20
+ // @ts-expect-error Not mocking the whole server
21
+ mockMcpServer = {
22
+ registerTool: vi.fn(),
23
+ };
24
+ mockRegisteredTool = {};
25
+ mockMcpServer.registerTool.mockReturnValue(mockRegisteredTool);
26
+ tool = new HsCreateTemplateTool(mockMcpServer);
27
+ });
28
+ describe('register', () => {
29
+ it('should register the tool with the MCP server', () => {
30
+ const result = tool.register();
31
+ expect(mockMcpServer.registerTool).toHaveBeenCalledWith('create-hubspot-cms-template', {
32
+ title: 'Create HubSpot CMS Template',
33
+ description: `Creates a new HubSpot CMS template using the hs create template command. Templates can be created non-interactively by specifying templateType. Supports all template types including: ${TEMPLATE_TYPES.join(', ')}.`,
34
+ inputSchema: expect.any(Object),
35
+ }, expect.any(Function));
36
+ expect(result).toBe(mockRegisteredTool);
37
+ });
38
+ });
39
+ describe('handler', () => {
40
+ it('should prompt for missing required parameters', async () => {
41
+ const result = await tool.handler({
42
+ absoluteCurrentWorkingDirectory: '/test/dir',
43
+ });
44
+ expect(result.content).toHaveLength(2);
45
+ expect(result.content[0].text).toContain('Ask the user to specify the name of the template');
46
+ expect(result.content[1].text).toContain('Ask the user what template type they want to create');
47
+ expect(result.content[1].text).toContain('page-template, email-template, partial, global-partial');
48
+ });
49
+ it('should prompt for missing name only when template type provided', async () => {
50
+ const result = await tool.handler({
51
+ absoluteCurrentWorkingDirectory: '/test/dir',
52
+ templateType: 'page-template',
53
+ });
54
+ expect(result.content).toHaveLength(1);
55
+ expect(result.content[0].text).toContain('Ask the user to specify the name of the template');
56
+ });
57
+ it('should prompt for missing templateType when name provided', async () => {
58
+ const result = await tool.handler({
59
+ absoluteCurrentWorkingDirectory: '/test/dir',
60
+ userSuppliedName: 'Test Template',
61
+ });
62
+ expect(result.content).toHaveLength(1);
63
+ expect(result.content[0].text).toContain('Ask the user what template type they want to create');
64
+ });
65
+ it('should execute command with all required parameters (page template)', async () => {
66
+ mockAddFlag.mockReturnValueOnce('hs create template "Page Template" --template-type page-template');
67
+ mockRunCommandInDir.mockResolvedValue({
68
+ stdout: 'Page template created successfully',
69
+ stderr: '',
70
+ });
71
+ const result = await tool.handler({
72
+ absoluteCurrentWorkingDirectory: '/test/dir',
73
+ userSuppliedName: 'Page Template',
74
+ templateType: 'page-template',
75
+ });
76
+ expect(mockAddFlag).toHaveBeenCalledWith('hs create template "Page Template"', 'template-type', 'page-template');
77
+ expect(mockRunCommandInDir).toHaveBeenCalledWith('/test/dir', 'hs create template "Page Template" --template-type page-template');
78
+ expect(result.content).toHaveLength(2);
79
+ expect(result.content[0].text).toContain('Page template created successfully');
80
+ });
81
+ it('should execute command with email template', async () => {
82
+ mockAddFlag.mockReturnValueOnce('hs create template "Email Template" --template-type email-template');
83
+ mockRunCommandInDir.mockResolvedValue({
84
+ stdout: 'Email template created successfully',
85
+ stderr: '',
86
+ });
87
+ const result = await tool.handler({
88
+ absoluteCurrentWorkingDirectory: '/test/dir',
89
+ userSuppliedName: 'Email Template',
90
+ templateType: 'email-template',
91
+ });
92
+ expect(mockAddFlag).toHaveBeenCalledWith('hs create template "Email Template"', 'template-type', 'email-template');
93
+ expect(result.content[0].text).toContain('Email template created successfully');
94
+ });
95
+ it('should execute command with partial template', async () => {
96
+ mockAddFlag.mockReturnValueOnce('hs create template "Header Partial" --template-type partial');
97
+ mockRunCommandInDir.mockResolvedValue({
98
+ stdout: 'Partial template created successfully',
99
+ stderr: '',
100
+ });
101
+ const result = await tool.handler({
102
+ absoluteCurrentWorkingDirectory: '/test/dir',
103
+ userSuppliedName: 'Header Partial',
104
+ templateType: 'partial',
105
+ });
106
+ expect(mockAddFlag).toHaveBeenCalledWith('hs create template "Header Partial"', 'template-type', 'partial');
107
+ expect(result.content[0].text).toContain('Partial template created successfully');
108
+ });
109
+ it('should execute command with blog-listing-template', async () => {
110
+ mockAddFlag.mockReturnValueOnce('hs create template "Blog Listing" --template-type blog-listing-template');
111
+ mockRunCommandInDir.mockResolvedValue({
112
+ stdout: 'Blog listing template created successfully',
113
+ stderr: '',
114
+ });
115
+ const result = await tool.handler({
116
+ absoluteCurrentWorkingDirectory: '/test/dir',
117
+ userSuppliedName: 'Blog Listing',
118
+ templateType: 'blog-listing-template',
119
+ });
120
+ expect(mockAddFlag).toHaveBeenCalledWith('hs create template "Blog Listing"', 'template-type', 'blog-listing-template');
121
+ expect(result.content[0].text).toContain('Blog listing template created successfully');
122
+ });
123
+ it('should execute command with destination path', async () => {
124
+ mockAddFlag.mockReturnValueOnce('hs create template "Test Template" "templates/custom" --template-type page-template');
125
+ mockRunCommandInDir.mockResolvedValue({
126
+ stdout: 'Template created at custom path',
127
+ stderr: '',
128
+ });
129
+ const result = await tool.handler({
130
+ absoluteCurrentWorkingDirectory: '/test/dir',
131
+ userSuppliedName: 'Test Template',
132
+ dest: 'templates/custom',
133
+ templateType: 'page-template',
134
+ });
135
+ expect(mockRunCommandInDir).toHaveBeenCalledWith('/test/dir', expect.stringContaining('"templates/custom"'));
136
+ expect(result.content[0].text).toContain('Template created at custom path');
137
+ });
138
+ it('should execute command with section template', async () => {
139
+ mockAddFlag.mockReturnValueOnce('hs create template "Hero Section" --template-type section');
140
+ mockRunCommandInDir.mockResolvedValue({
141
+ stdout: 'Section template created successfully',
142
+ stderr: '',
143
+ });
144
+ const result = await tool.handler({
145
+ absoluteCurrentWorkingDirectory: '/test/dir',
146
+ userSuppliedName: 'Hero Section',
147
+ templateType: 'section',
148
+ });
149
+ expect(mockAddFlag).toHaveBeenCalledWith('hs create template "Hero Section"', 'template-type', 'section');
150
+ expect(result.content[0].text).toContain('Section template created successfully');
151
+ });
152
+ it('should execute command with search template', async () => {
153
+ mockAddFlag.mockReturnValueOnce('hs create template "Search Results" --template-type search-template');
154
+ mockRunCommandInDir.mockResolvedValue({
155
+ stdout: 'Search template created successfully',
156
+ stderr: '',
157
+ });
158
+ const result = await tool.handler({
159
+ absoluteCurrentWorkingDirectory: '/test/dir',
160
+ userSuppliedName: 'Search Results',
161
+ templateType: 'search-template',
162
+ });
163
+ expect(mockAddFlag).toHaveBeenCalledWith('hs create template "Search Results"', 'template-type', 'search-template');
164
+ expect(result.content[0].text).toContain('Search template created successfully');
165
+ });
166
+ it('should execute command with blog-post-template', async () => {
167
+ mockAddFlag.mockReturnValueOnce('hs create template "Custom Blog Post" --template-type blog-post-template');
168
+ mockRunCommandInDir.mockResolvedValue({
169
+ stdout: 'Blog post template created successfully',
170
+ stderr: '',
171
+ });
172
+ const result = await tool.handler({
173
+ absoluteCurrentWorkingDirectory: '/test/dir',
174
+ userSuppliedName: 'Custom Blog Post',
175
+ templateType: 'blog-post-template',
176
+ });
177
+ expect(mockAddFlag).toHaveBeenCalledWith('hs create template "Custom Blog Post"', 'template-type', 'blog-post-template');
178
+ expect(result.content[0].text).toContain('Blog post template created successfully');
179
+ });
180
+ it('should handle command execution errors', async () => {
181
+ mockRunCommandInDir.mockRejectedValue(new Error('Template creation failed'));
182
+ const result = await tool.handler({
183
+ absoluteCurrentWorkingDirectory: '/test/dir',
184
+ userSuppliedName: 'Test Template',
185
+ templateType: 'page-template',
186
+ });
187
+ expect(result.content).toHaveLength(1);
188
+ expect(result.content[0].text).toContain('Template creation failed');
189
+ });
190
+ it('should handle stderr output', async () => {
191
+ mockAddFlag.mockReturnValueOnce('hs create template "Test Template" --template-type page-template');
192
+ mockRunCommandInDir.mockResolvedValue({
193
+ stdout: 'Template created successfully',
194
+ stderr: 'Warning: Using deprecated template syntax',
195
+ });
196
+ const result = await tool.handler({
197
+ absoluteCurrentWorkingDirectory: '/test/dir',
198
+ userSuppliedName: 'Test Template',
199
+ templateType: 'page-template',
200
+ });
201
+ expect(result.content).toHaveLength(2);
202
+ expect(result.content[0].text).toContain('Template created successfully');
203
+ expect(result.content[1].text).toContain('Warning: Using deprecated template syntax');
204
+ });
205
+ });
206
+ });
@@ -0,0 +1,120 @@
1
+ import { describe, it, expect, vi, beforeEach } from 'vitest';
2
+ import { HsListFunctionsTool } from '../HsListFunctionsTool.js';
3
+ import { runCommandInDir } from '../../../utils/project.js';
4
+ import { addFlag } from '../../../utils/command.js';
5
+ vi.mock('@modelcontextprotocol/sdk/server/mcp.js');
6
+ vi.mock('../../../utils/project');
7
+ vi.mock('../../../utils/command');
8
+ vi.mock('../../../utils/toolUsageTracking', () => ({
9
+ trackToolUsage: vi.fn(),
10
+ }));
11
+ const mockRunCommandInDir = runCommandInDir;
12
+ const mockAddFlag = addFlag;
13
+ describe('HsListFunctionsTool', () => {
14
+ let mockMcpServer;
15
+ let tool;
16
+ let mockRegisteredTool;
17
+ beforeEach(() => {
18
+ vi.clearAllMocks();
19
+ // @ts-expect-error Not mocking the whole server
20
+ mockMcpServer = {
21
+ registerTool: vi.fn(),
22
+ };
23
+ mockRegisteredTool = {};
24
+ mockMcpServer.registerTool.mockReturnValue(mockRegisteredTool);
25
+ tool = new HsListFunctionsTool(mockMcpServer);
26
+ });
27
+ describe('register', () => {
28
+ it('should register the tool with the MCP server', () => {
29
+ const result = tool.register();
30
+ expect(mockMcpServer.registerTool).toHaveBeenCalledWith('list-hubspot-cms-serverless-functions', {
31
+ title: 'List HubSpot CMS Serverless Functions',
32
+ description: 'Get a list of all serverless functions deployed in a HubSpot portal/account. Shows function routes, HTTP methods, secrets, and timestamps.',
33
+ inputSchema: expect.any(Object),
34
+ }, expect.any(Function));
35
+ expect(result).toBe(mockRegisteredTool);
36
+ });
37
+ });
38
+ describe('handler', () => {
39
+ it('should execute hs function list command with no parameters', async () => {
40
+ mockRunCommandInDir.mockResolvedValue({
41
+ stdout: 'Route | Method | Secrets | Created | Updated\n/api/test | GET | | 2023-01-01 | 2023-01-01',
42
+ stderr: '',
43
+ });
44
+ const result = await tool.handler({
45
+ absoluteCurrentWorkingDirectory: '/test/dir',
46
+ });
47
+ expect(mockRunCommandInDir).toHaveBeenCalledWith('/test/dir', 'hs function list');
48
+ expect(result.content).toHaveLength(2);
49
+ expect(result.content[0].text).toContain('Route | Method | Secrets');
50
+ expect(result.content[1].text).toBe('');
51
+ });
52
+ it('should execute hs function list command with json flag', async () => {
53
+ mockRunCommandInDir.mockResolvedValue({
54
+ stdout: '[{"route": "/api/test", "method": "GET"}]',
55
+ stderr: '',
56
+ });
57
+ const result = await tool.handler({
58
+ absoluteCurrentWorkingDirectory: '/test/dir',
59
+ json: true,
60
+ });
61
+ expect(mockRunCommandInDir).toHaveBeenCalledWith('/test/dir', 'hs function list --json');
62
+ expect(result.content).toHaveLength(2);
63
+ expect(result.content[0].text).toContain('[{"route": "/api/test"');
64
+ expect(result.content[1].text).toBe('');
65
+ });
66
+ it('should execute hs function list command with account parameter', async () => {
67
+ mockAddFlag.mockReturnValue('hs function list --account test-account');
68
+ mockRunCommandInDir.mockResolvedValue({
69
+ stdout: 'account-specific-functions',
70
+ stderr: '',
71
+ });
72
+ const result = await tool.handler({
73
+ absoluteCurrentWorkingDirectory: '/test/dir',
74
+ account: 'test-account',
75
+ });
76
+ expect(mockAddFlag).toHaveBeenCalledWith('hs function list', 'account', 'test-account');
77
+ expect(mockRunCommandInDir).toHaveBeenCalledWith('/test/dir', 'hs function list --account test-account');
78
+ expect(result.content).toHaveLength(2);
79
+ expect(result.content[0].text).toContain('account-specific-functions');
80
+ expect(result.content[1].text).toBe('');
81
+ });
82
+ it('should execute hs function list command with both json and account parameters', async () => {
83
+ mockAddFlag.mockReturnValue('hs function list --json --account test-account');
84
+ mockRunCommandInDir.mockResolvedValue({
85
+ stdout: '[{"route": "/api/test"}]',
86
+ stderr: '',
87
+ });
88
+ const result = await tool.handler({
89
+ absoluteCurrentWorkingDirectory: '/test/dir',
90
+ json: true,
91
+ account: 'test-account',
92
+ });
93
+ expect(mockAddFlag).toHaveBeenCalledWith('hs function list --json', 'account', 'test-account');
94
+ expect(mockRunCommandInDir).toHaveBeenCalledWith('/test/dir', 'hs function list --json --account test-account');
95
+ expect(result.content).toHaveLength(2);
96
+ expect(result.content[0].text).toContain('[{"route": "/api/test"}]');
97
+ expect(result.content[1].text).toBe('');
98
+ });
99
+ it('should handle command execution errors', async () => {
100
+ mockRunCommandInDir.mockRejectedValue(new Error('Command failed'));
101
+ const result = await tool.handler({
102
+ absoluteCurrentWorkingDirectory: '/test/dir',
103
+ });
104
+ expect(result.content).toHaveLength(1);
105
+ expect(result.content[0].text).toContain('Error executing hs function list command: Command failed');
106
+ });
107
+ it('should handle stderr output', async () => {
108
+ mockRunCommandInDir.mockResolvedValue({
109
+ stdout: 'Route | Method | Secrets\n/api/test | GET |',
110
+ stderr: 'Warning: Some warning message',
111
+ });
112
+ const result = await tool.handler({
113
+ absoluteCurrentWorkingDirectory: '/test/dir',
114
+ });
115
+ expect(result.content).toHaveLength(2);
116
+ expect(result.content[0].text).toContain('/api/test | GET');
117
+ expect(result.content[1].text).toContain('Warning: Some warning message');
118
+ });
119
+ });
120
+ });
@@ -9,6 +9,9 @@ import { DocsSearchTool } from './project/DocsSearchTool.js';
9
9
  import { DocFetchTool } from './project/DocFetchTool.js';
10
10
  import { HsListTool } from './cms/HsListTool.js';
11
11
  import { HsCreateModuleTool } from './cms/HsCreateModuleTool.js';
12
+ import { HsCreateTemplateTool } from './cms/HsCreateTemplateTool.js';
13
+ import { HsCreateFunctionTool } from './cms/HsCreateFunctionTool.js';
14
+ import { HsListFunctionsTool } from './cms/HsListFunctionsTool.js';
12
15
  export function registerProjectTools(mcpServer) {
13
16
  return [
14
17
  new UploadProjectTools(mcpServer).register(),
@@ -26,5 +29,8 @@ export function registerCmsTools(mcpServer) {
26
29
  return [
27
30
  new HsListTool(mcpServer).register(),
28
31
  new HsCreateModuleTool(mcpServer).register(),
32
+ new HsCreateTemplateTool(mcpServer).register(),
33
+ new HsCreateFunctionTool(mcpServer).register(),
34
+ new HsListFunctionsTool(mcpServer).register(),
29
35
  ];
30
36
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hubspot/cli",
3
- "version": "7.7.30-experimental.0",
3
+ "version": "7.7.32-experimental.0",
4
4
  "description": "The official CLI for developing on HubSpot",
5
5
  "license": "Apache-2.0",
6
6
  "repository": "https://github.com/HubSpot/hubspot-cli",
@@ -84,6 +84,7 @@
84
84
  "mcp-local": "yarn tsx ./scripts/mcp-local.ts",
85
85
  "prettier:write": "prettier --write './**/*.{ts,js,json}'",
86
86
  "release": "yarn tsx ./scripts/release.ts release",
87
+ "view-ui": "yarn build && yarn tsx ./scripts/view-ui.ts",
87
88
  "test": "vitest run",
88
89
  "test-dev": "vitest",
89
90
  "test-cli": "yarn build && yarn --cwd 'acceptance-tests' test-ci",
@@ -0,0 +1,8 @@
1
+ export interface BoxWithTitleProps {
2
+ title: string;
3
+ message: string;
4
+ titleBackgroundColor?: string;
5
+ borderColor?: string;
6
+ }
7
+ export declare function getBoxWithTitle(props: BoxWithTitleProps): React.ReactNode;
8
+ export declare function BoxWithTitle({ title, message, titleBackgroundColor, borderColor, }: BoxWithTitleProps): React.ReactNode;
@@ -0,0 +1,9 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Box, Text } from 'ink';
3
+ import { CONTAINER_STYLES } from '../styles.js';
4
+ export function getBoxWithTitle(props) {
5
+ return _jsx(BoxWithTitle, { ...props });
6
+ }
7
+ export function BoxWithTitle({ title, message, titleBackgroundColor, borderColor, }) {
8
+ return (_jsxs(Box, { ...CONTAINER_STYLES, borderStyle: "round", borderColor: borderColor, children: [_jsx(Box, { position: "absolute", marginTop: -2, paddingX: 0, alignSelf: "flex-start", justifyContent: "center", alignItems: "center", children: _jsx(Text, { backgroundColor: titleBackgroundColor, bold: true, children: ` ${title} ` }) }), _jsx(Box, { justifyContent: "center", alignItems: "center", children: _jsx(Text, { children: message }) })] }));
9
+ }
@@ -0,0 +1,8 @@
1
+ export interface HorizontalSelectPromptProps {
2
+ defaultOption?: string;
3
+ options: string[];
4
+ onSelect: (value: string) => void;
5
+ prompt?: string;
6
+ }
7
+ export declare function getHorizontalSelectPrompt(props: HorizontalSelectPromptProps): React.ReactNode;
8
+ export declare function HorizontalSelectPrompt({ defaultOption, options, onSelect, prompt, }: HorizontalSelectPromptProps): React.ReactNode;