@hubspot/cli 7.6.0-beta.11 → 7.6.0-beta.13

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 (158) hide show
  1. package/commands/app/__tests__/migrate.test.js +1 -0
  2. package/commands/getStarted.js +7 -20
  3. package/commands/mcp/setup.d.ts +0 -1
  4. package/commands/mcp/setup.js +11 -11
  5. package/commands/project/__tests__/add.test.js +64 -0
  6. package/commands/project/__tests__/create.test.js +57 -0
  7. package/commands/project/__tests__/deploy.test.js +3 -2
  8. package/commands/project/add.d.ts +1 -1
  9. package/commands/project/add.js +3 -5
  10. package/commands/project/create.js +7 -2
  11. package/commands/project/deploy.js +9 -61
  12. package/commands/project/dev/index.js +1 -1
  13. package/commands/project/dev/unifiedFlow.js +4 -1
  14. package/commands/project/migrate.js +26 -7
  15. package/commands/project/upload.js +2 -2
  16. package/commands/project/validate.js +1 -1
  17. package/commands/project/watch.js +2 -2
  18. package/lang/en.d.ts +20 -5
  19. package/lang/en.js +38 -22
  20. package/lang/en.lyaml +12 -12
  21. package/lib/__tests__/hasFeature.test.js +145 -7
  22. package/lib/__tests__/importData.test.js +1 -1
  23. package/lib/app/__tests__/migrate.test.js +14 -51
  24. package/lib/app/migrate.d.ts +2 -8
  25. package/lib/app/migrate.js +5 -73
  26. package/lib/constants.d.ts +4 -0
  27. package/lib/constants.js +4 -0
  28. package/lib/errorHandlers/index.d.ts +4 -0
  29. package/lib/errorHandlers/index.js +1 -1
  30. package/lib/hasFeature.js +6 -0
  31. package/lib/importData.js +1 -1
  32. package/lib/links.d.ts +1 -0
  33. package/lib/links.js +10 -3
  34. package/lib/mcp/setup.d.ts +0 -2
  35. package/lib/mcp/setup.js +4 -29
  36. package/lib/projects/__tests__/AppDevModeInterface.test.js +71 -44
  37. package/lib/projects/__tests__/LocalDevProcess.test.js +1 -0
  38. package/lib/projects/__tests__/components.test.js +164 -7
  39. package/lib/projects/__tests__/deploy.test.js +164 -0
  40. package/lib/projects/__tests__/platformVersion.test.d.ts +1 -0
  41. package/lib/projects/__tests__/{buildAndDeploy.test.js → platformVersion.test.js} +2 -2
  42. package/lib/projects/add/__tests__/legacyAddComponent.test.js +49 -6
  43. package/lib/projects/add/__tests__/v3AddComponent.test.js +142 -8
  44. package/lib/projects/add/legacyAddComponent.d.ts +1 -1
  45. package/lib/projects/add/legacyAddComponent.js +5 -1
  46. package/lib/projects/add/v3AddComponent.d.ts +2 -1
  47. package/lib/projects/add/v3AddComponent.js +22 -5
  48. package/lib/projects/components.d.ts +1 -0
  49. package/lib/projects/components.js +27 -1
  50. package/lib/projects/create/__tests__/v3.test.js +97 -9
  51. package/lib/projects/create/index.js +2 -2
  52. package/lib/projects/create/legacy.js +1 -1
  53. package/lib/projects/create/v3.d.ts +2 -2
  54. package/lib/projects/create/v3.js +35 -12
  55. package/lib/projects/deploy.d.ts +13 -0
  56. package/lib/projects/deploy.js +63 -0
  57. package/lib/projects/localDev/AppDevModeInterface.d.ts +5 -3
  58. package/lib/projects/localDev/AppDevModeInterface.js +110 -47
  59. package/lib/projects/localDev/DevServerManagerV2.js +1 -0
  60. package/lib/projects/localDev/LocalDevProcess.js +3 -1
  61. package/lib/projects/localDev/LocalDevState.d.ts +5 -2
  62. package/lib/projects/localDev/LocalDevState.js +9 -1
  63. package/lib/projects/localDev/helpers/project.d.ts +2 -2
  64. package/lib/projects/localDev/helpers/project.js +6 -8
  65. package/lib/projects/platformVersion.d.ts +1 -0
  66. package/lib/projects/platformVersion.js +10 -0
  67. package/lib/projects/{buildAndDeploy.d.ts → pollProjectBuildAndDeploy.d.ts} +0 -1
  68. package/lib/projects/{buildAndDeploy.js → pollProjectBuildAndDeploy.js} +0 -10
  69. package/lib/projects/upload.js +1 -1
  70. package/lib/projects/urls.d.ts +1 -0
  71. package/lib/projects/urls.js +3 -0
  72. package/lib/prompts/__tests__/projectAddPrompt.test.d.ts +1 -0
  73. package/lib/prompts/__tests__/projectAddPrompt.test.js +143 -0
  74. package/lib/prompts/__tests__/selectProjectTemplatePrompt.test.d.ts +1 -0
  75. package/lib/prompts/__tests__/selectProjectTemplatePrompt.test.js +160 -0
  76. package/lib/prompts/createDeveloperTestAccountConfigPrompt.js +1 -0
  77. package/lib/prompts/importDataFilePathPrompt.js +4 -2
  78. package/lib/prompts/installAppPrompt.d.ts +6 -1
  79. package/lib/prompts/installAppPrompt.js +6 -1
  80. package/lib/prompts/projectAddPrompt.js +1 -1
  81. package/lib/prompts/promptUtils.d.ts +5 -0
  82. package/lib/prompts/promptUtils.js +9 -0
  83. package/lib/prompts/selectProjectTemplatePrompt.js +1 -1
  84. package/lib/theme/__tests__/migrate.test.d.ts +1 -0
  85. package/lib/theme/__tests__/migrate.test.js +233 -0
  86. package/lib/theme/migrate.d.ts +13 -0
  87. package/lib/theme/migrate.js +90 -0
  88. package/lib/ui/index.js +3 -6
  89. package/lib/usageTracking.js +2 -2
  90. package/mcp-server/tools/cms/HsCreateFunctionTool.d.ts +32 -0
  91. package/mcp-server/tools/cms/HsCreateFunctionTool.js +96 -0
  92. package/mcp-server/tools/cms/HsCreateModuleTool.d.ts +38 -0
  93. package/mcp-server/tools/cms/HsCreateModuleTool.js +118 -0
  94. package/mcp-server/tools/cms/HsCreateTemplateTool.d.ts +26 -0
  95. package/mcp-server/tools/cms/HsCreateTemplateTool.js +75 -0
  96. package/mcp-server/tools/cms/HsFunctionLogsTool.d.ts +32 -0
  97. package/mcp-server/tools/cms/HsFunctionLogsTool.js +76 -0
  98. package/mcp-server/tools/cms/HsListFunctionsTool.d.ts +23 -0
  99. package/mcp-server/tools/cms/HsListFunctionsTool.js +58 -0
  100. package/mcp-server/tools/cms/HsListTool.js +1 -1
  101. package/mcp-server/tools/cms/__tests__/HsCreateFunctionTool.test.d.ts +1 -0
  102. package/mcp-server/tools/cms/__tests__/HsCreateFunctionTool.test.js +251 -0
  103. package/mcp-server/tools/cms/__tests__/HsCreateModuleTool.test.d.ts +1 -0
  104. package/mcp-server/tools/cms/__tests__/HsCreateModuleTool.test.js +224 -0
  105. package/mcp-server/tools/cms/__tests__/HsCreateTemplateTool.test.d.ts +1 -0
  106. package/mcp-server/tools/cms/__tests__/HsCreateTemplateTool.test.js +206 -0
  107. package/mcp-server/tools/cms/__tests__/HsFunctionLogsTool.test.d.ts +1 -0
  108. package/mcp-server/tools/cms/__tests__/HsFunctionLogsTool.test.js +183 -0
  109. package/mcp-server/tools/cms/__tests__/HsListFunctionsTool.test.d.ts +1 -0
  110. package/mcp-server/tools/cms/__tests__/HsListFunctionsTool.test.js +120 -0
  111. package/mcp-server/tools/cms/__tests__/HsListTool.test.js +1 -1
  112. package/mcp-server/tools/index.js +13 -1
  113. package/mcp-server/tools/project/AddFeatureToProjectTool.d.ts +3 -3
  114. package/mcp-server/tools/project/AddFeatureToProjectTool.js +3 -3
  115. package/mcp-server/tools/project/CreateProjectTool.d.ts +3 -3
  116. package/mcp-server/tools/project/CreateProjectTool.js +5 -5
  117. package/mcp-server/tools/project/DeployProjectTool.js +1 -1
  118. package/mcp-server/tools/project/DocFetchTool.js +2 -2
  119. package/mcp-server/tools/project/DocsSearchTool.d.ts +4 -1
  120. package/mcp-server/tools/project/DocsSearchTool.js +7 -7
  121. package/mcp-server/tools/project/GetConfigValuesTool.d.ts +4 -1
  122. package/mcp-server/tools/project/GetConfigValuesTool.js +14 -8
  123. package/mcp-server/tools/project/GuidedWalkthroughTool.js +1 -1
  124. package/mcp-server/tools/project/UploadProjectTools.js +2 -2
  125. package/mcp-server/tools/project/ValidateProjectTool.js +1 -1
  126. package/mcp-server/tools/project/__tests__/AddFeatureToProjectTool.test.js +1 -1
  127. package/mcp-server/tools/project/__tests__/CreateProjectTool.test.js +1 -1
  128. package/mcp-server/tools/project/__tests__/DeployProjectTool.test.js +1 -1
  129. package/mcp-server/tools/project/__tests__/DocFetchTool.test.js +2 -2
  130. package/mcp-server/tools/project/__tests__/DocsSearchTool.test.js +14 -12
  131. package/mcp-server/tools/project/__tests__/GetConfigValuesTool.test.js +9 -8
  132. package/mcp-server/tools/project/__tests__/GuidedWalkthroughTool.test.js +1 -1
  133. package/mcp-server/tools/project/__tests__/UploadProjectTools.test.js +1 -1
  134. package/mcp-server/tools/project/__tests__/ValidateProjectTool.test.js +1 -1
  135. package/mcp-server/tools/project/constants.d.ts +1 -1
  136. package/mcp-server/tools/project/constants.js +14 -6
  137. package/mcp-server/utils/__tests__/cliConfig.test.d.ts +1 -0
  138. package/mcp-server/utils/__tests__/cliConfig.test.js +110 -0
  139. package/mcp-server/utils/cliConfig.d.ts +1 -0
  140. package/mcp-server/utils/cliConfig.js +12 -0
  141. package/package.json +4 -3
  142. package/types/LocalDev.d.ts +2 -1
  143. package/types/Projects.d.ts +1 -0
  144. package/ui/components/BoxWithTitle.d.ts +8 -0
  145. package/ui/components/BoxWithTitle.js +9 -0
  146. package/ui/components/HorizontalSelectPrompt.d.ts +8 -0
  147. package/ui/components/HorizontalSelectPrompt.js +30 -0
  148. package/ui/components/StatusMessageBoxes.d.ts +12 -0
  149. package/ui/components/StatusMessageBoxes.js +31 -0
  150. package/ui/lib/ui-testing-utils.d.ts +9 -0
  151. package/ui/lib/ui-testing-utils.js +47 -0
  152. package/ui/lib/useTerminalSize.d.ts +13 -0
  153. package/ui/lib/useTerminalSize.js +31 -0
  154. package/ui/styles.d.ts +18 -0
  155. package/ui/styles.js +18 -0
  156. package/ui/views/UiSandbox.d.ts +5 -0
  157. package/ui/views/UiSandbox.js +25 -0
  158. /package/lib/projects/__tests__/{buildAndDeploy.test.d.ts → deploy.test.d.ts} +0 -0
@@ -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-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,183 @@
1
+ import { describe, it, expect, vi, beforeEach } from 'vitest';
2
+ import { HsFunctionLogsTool } from '../HsFunctionLogsTool.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('HsFunctionLogsTool', () => {
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 HsFunctionLogsTool(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('get-cms-serverless-function-logs', expect.objectContaining({
31
+ title: 'Get HubSpot CMS serverless function logs for an endpoint',
32
+ description: 'Retrieve logs for HubSpot CMS serverless functions. Use this tool to help debug issues with serverless functions by reading the production logs. Supports various options like latest, compact, and limiting results. Use after listing functions with list-cms-serverless-functions to get the endpoint path.',
33
+ inputSchema: expect.any(Object),
34
+ }), expect.any(Function));
35
+ expect(result).toBe(mockRegisteredTool);
36
+ });
37
+ });
38
+ describe('handler', () => {
39
+ it('should execute basic hs logs command with endpoint', async () => {
40
+ mockRunCommandInDir.mockResolvedValue({
41
+ stdout: '2023-01-01 10:00:00 INFO Function executed successfully',
42
+ stderr: '',
43
+ });
44
+ const result = await tool.handler({
45
+ absoluteCurrentWorkingDirectory: '/test/dir',
46
+ endpoint: 'my-function',
47
+ });
48
+ expect(mockRunCommandInDir).toHaveBeenCalledWith('/test/dir', 'hs logs my-function');
49
+ expect(result.content).toHaveLength(2);
50
+ expect(result.content[0].text).toContain('Function executed successfully');
51
+ expect(result.content[1].text).toBe('');
52
+ });
53
+ it('should strip leading slash from endpoint', async () => {
54
+ mockRunCommandInDir.mockResolvedValue({
55
+ stdout: '2023-01-01 10:00:00 INFO Function executed successfully',
56
+ stderr: '',
57
+ });
58
+ const result = await tool.handler({
59
+ absoluteCurrentWorkingDirectory: '/test/dir',
60
+ endpoint: '/api/my-endpoint',
61
+ });
62
+ expect(mockRunCommandInDir).toHaveBeenCalledWith('/test/dir', 'hs logs api/my-endpoint');
63
+ expect(result.content).toHaveLength(2);
64
+ expect(result.content[0].text).toContain('Function executed successfully');
65
+ expect(result.content[1].text).toBe('');
66
+ });
67
+ it('should execute hs logs command with latest flag', async () => {
68
+ mockAddFlag.mockReturnValue('hs logs my-endpoint --latest');
69
+ mockRunCommandInDir.mockResolvedValue({
70
+ stdout: '2023-01-01 10:00:00 INFO Latest log entry',
71
+ stderr: '',
72
+ });
73
+ const result = await tool.handler({
74
+ absoluteCurrentWorkingDirectory: '/test/dir',
75
+ endpoint: 'my-endpoint',
76
+ latest: true,
77
+ });
78
+ expect(mockAddFlag).toHaveBeenCalledWith('hs logs my-endpoint', 'latest', true);
79
+ expect(mockRunCommandInDir).toHaveBeenCalledWith('/test/dir', 'hs logs my-endpoint --latest');
80
+ expect(result.content).toHaveLength(2);
81
+ expect(result.content[0].text).toContain('Latest log entry');
82
+ expect(result.content[1].text).toBe('');
83
+ });
84
+ it('should execute hs logs command with compact flag', async () => {
85
+ mockAddFlag.mockReturnValue('hs logs my-endpoint --compact');
86
+ mockRunCommandInDir.mockResolvedValue({
87
+ stdout: 'compact log output',
88
+ stderr: '',
89
+ });
90
+ const result = await tool.handler({
91
+ absoluteCurrentWorkingDirectory: '/test/dir',
92
+ endpoint: 'my-endpoint',
93
+ compact: true,
94
+ });
95
+ expect(mockAddFlag).toHaveBeenCalledWith('hs logs my-endpoint', 'compact', true);
96
+ expect(mockRunCommandInDir).toHaveBeenCalledWith('/test/dir', 'hs logs my-endpoint --compact');
97
+ expect(result.content).toHaveLength(2);
98
+ expect(result.content[0].text).toContain('compact log output');
99
+ expect(result.content[1].text).toBe('');
100
+ });
101
+ it('should execute hs logs command with limit parameter', async () => {
102
+ mockAddFlag.mockReturnValue('hs logs my-endpoint --limit 10');
103
+ mockRunCommandInDir.mockResolvedValue({
104
+ stdout: 'limited log entries',
105
+ stderr: '',
106
+ });
107
+ const result = await tool.handler({
108
+ absoluteCurrentWorkingDirectory: '/test/dir',
109
+ endpoint: 'my-endpoint',
110
+ limit: 10,
111
+ });
112
+ expect(mockAddFlag).toHaveBeenCalledWith('hs logs my-endpoint', 'limit', 10);
113
+ expect(mockRunCommandInDir).toHaveBeenCalledWith('/test/dir', 'hs logs my-endpoint --limit 10');
114
+ expect(result.content).toHaveLength(2);
115
+ expect(result.content[0].text).toContain('limited log entries');
116
+ expect(result.content[1].text).toBe('');
117
+ });
118
+ it('should execute hs logs command with account parameter', async () => {
119
+ mockAddFlag.mockReturnValue('hs logs my-endpoint --account test-account');
120
+ mockRunCommandInDir.mockResolvedValue({
121
+ stdout: 'account-specific logs',
122
+ stderr: '',
123
+ });
124
+ const result = await tool.handler({
125
+ absoluteCurrentWorkingDirectory: '/test/dir',
126
+ endpoint: 'my-endpoint',
127
+ account: 'test-account',
128
+ });
129
+ expect(mockAddFlag).toHaveBeenCalledWith('hs logs my-endpoint', 'account', 'test-account');
130
+ expect(mockRunCommandInDir).toHaveBeenCalledWith('/test/dir', 'hs logs my-endpoint --account test-account');
131
+ expect(result.content).toHaveLength(2);
132
+ expect(result.content[0].text).toContain('account-specific logs');
133
+ expect(result.content[1].text).toBe('');
134
+ });
135
+ it('should execute hs logs command with multiple parameters', async () => {
136
+ mockAddFlag
137
+ .mockReturnValueOnce('hs logs my-endpoint --latest')
138
+ .mockReturnValueOnce('hs logs my-endpoint --latest --compact')
139
+ .mockReturnValueOnce('hs logs my-endpoint --latest --compact --account test-account');
140
+ mockRunCommandInDir.mockResolvedValue({
141
+ stdout: 'latest compact logs',
142
+ stderr: '',
143
+ });
144
+ const result = await tool.handler({
145
+ absoluteCurrentWorkingDirectory: '/test/dir',
146
+ endpoint: 'my-endpoint',
147
+ latest: true,
148
+ compact: true,
149
+ account: 'test-account',
150
+ });
151
+ expect(mockAddFlag).toHaveBeenCalledTimes(3);
152
+ expect(mockAddFlag).toHaveBeenNthCalledWith(1, 'hs logs my-endpoint', 'latest', true);
153
+ expect(mockAddFlag).toHaveBeenNthCalledWith(2, 'hs logs my-endpoint --latest', 'compact', true);
154
+ expect(mockAddFlag).toHaveBeenNthCalledWith(3, 'hs logs my-endpoint --latest --compact', 'account', 'test-account');
155
+ expect(mockRunCommandInDir).toHaveBeenCalledWith('/test/dir', 'hs logs my-endpoint --latest --compact --account test-account');
156
+ expect(result.content).toHaveLength(2);
157
+ expect(result.content[0].text).toContain('latest compact logs');
158
+ expect(result.content[1].text).toBe('');
159
+ });
160
+ it('should handle command execution errors', async () => {
161
+ mockRunCommandInDir.mockRejectedValue(new Error('Function not found'));
162
+ const result = await tool.handler({
163
+ absoluteCurrentWorkingDirectory: '/test/dir',
164
+ endpoint: 'non-existent-function',
165
+ });
166
+ expect(result.content).toHaveLength(1);
167
+ expect(result.content[0].text).toContain('Error executing hs logs command: Function not found');
168
+ });
169
+ it('should handle stderr output', async () => {
170
+ mockRunCommandInDir.mockResolvedValue({
171
+ stdout: 'function logs',
172
+ stderr: 'Warning: Function may be slow to respond',
173
+ });
174
+ const result = await tool.handler({
175
+ absoluteCurrentWorkingDirectory: '/test/dir',
176
+ endpoint: 'slow-function',
177
+ });
178
+ expect(result.content).toHaveLength(2);
179
+ expect(result.content[0].text).toContain('function logs');
180
+ expect(result.content[1].text).toContain('Warning: Function may be slow to respond');
181
+ });
182
+ });
183
+ });
@@ -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-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
+ });
@@ -27,7 +27,7 @@ describe('HsListTool', () => {
27
27
  describe('register', () => {
28
28
  it('should register the tool with the MCP server', () => {
29
29
  const result = tool.register();
30
- expect(mockMcpServer.registerTool).toHaveBeenCalledWith('list-hubspot-cms-remote-contents', {
30
+ expect(mockMcpServer.registerTool).toHaveBeenCalledWith('list-cms-remote-contents', {
31
31
  title: 'List HubSpot CMS Directory Contents',
32
32
  description: 'List remote contents of a HubSpot CMS directory.',
33
33
  inputSchema: expect.any(Object),
@@ -8,6 +8,11 @@ import { GetConfigValuesTool } from './project/GetConfigValuesTool.js';
8
8
  import { DocsSearchTool } from './project/DocsSearchTool.js';
9
9
  import { DocFetchTool } from './project/DocFetchTool.js';
10
10
  import { HsListTool } from './cms/HsListTool.js';
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';
15
+ import { HsFunctionLogsTool } from './cms/HsFunctionLogsTool.js';
11
16
  export function registerProjectTools(mcpServer) {
12
17
  return [
13
18
  new UploadProjectTools(mcpServer).register(),
@@ -22,5 +27,12 @@ export function registerProjectTools(mcpServer) {
22
27
  ];
23
28
  }
24
29
  export function registerCmsTools(mcpServer) {
25
- return [new HsListTool(mcpServer).register()];
30
+ return [
31
+ new HsListTool(mcpServer).register(),
32
+ new HsCreateModuleTool(mcpServer).register(),
33
+ new HsCreateTemplateTool(mcpServer).register(),
34
+ new HsCreateFunctionTool(mcpServer).register(),
35
+ new HsListFunctionsTool(mcpServer).register(),
36
+ new HsFunctionLogsTool(mcpServer).register(),
37
+ ];
26
38
  }
@@ -6,19 +6,19 @@ declare const inputSchemaZodObject: z.ZodObject<{
6
6
  addApp: z.ZodBoolean;
7
7
  distribution: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"marketplace">, z.ZodLiteral<"private">]>>;
8
8
  auth: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"static">, z.ZodLiteral<"oauth">]>>;
9
- features: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodLiteral<"card">, z.ZodLiteral<"settings">, z.ZodLiteral<"app-function">, z.ZodLiteral<"webhooks">, z.ZodLiteral<"workflow-action">]>, "many">>;
9
+ features: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodLiteral<"card">, z.ZodLiteral<"settings">, z.ZodLiteral<"app-function">, z.ZodLiteral<"webhooks">, z.ZodLiteral<"workflow-action">, z.ZodLiteral<"workflow-action-tool">, z.ZodLiteral<"app-object">, z.ZodLiteral<"app-event">, z.ZodLiteral<"scim">, z.ZodLiteral<"page">]>, "many">>;
10
10
  }, "strip", z.ZodTypeAny, {
11
11
  absoluteProjectPath: string;
12
12
  addApp: boolean;
13
13
  auth?: "oauth" | "static" | undefined;
14
14
  distribution?: "marketplace" | "private" | undefined;
15
- features?: ("card" | "settings" | "app-function" | "webhooks" | "workflow-action")[] | undefined;
15
+ features?: ("card" | "settings" | "page" | "app-event" | "workflow-action-tool" | "workflow-action" | "app-function" | "webhooks" | "app-object" | "scim")[] | undefined;
16
16
  }, {
17
17
  absoluteProjectPath: string;
18
18
  addApp: boolean;
19
19
  auth?: "oauth" | "static" | undefined;
20
20
  distribution?: "marketplace" | "private" | undefined;
21
- features?: ("card" | "settings" | "app-function" | "webhooks" | "workflow-action")[] | undefined;
21
+ features?: ("card" | "settings" | "page" | "app-event" | "workflow-action-tool" | "workflow-action" | "app-function" | "webhooks" | "app-object" | "scim")[] | undefined;
22
22
  }>;
23
23
  export type AddFeatureInputSchema = z.infer<typeof inputSchemaZodObject>;
24
24
  export declare class AddFeatureToProjectTool extends Tool<AddFeatureInputSchema> {
@@ -16,20 +16,20 @@ const inputSchema = {
16
16
  z.literal(APP_DISTRIBUTION_TYPES.MARKETPLACE),
17
17
  z.literal(APP_DISTRIBUTION_TYPES.PRIVATE),
18
18
  ]))
19
- .describe('Private is used if you do not wish to distribute your application on the HubSpot marketplace. If not specified by the user, do not choose for them. This cannot be changed after a project is uploaded.'),
19
+ .describe('If not specified by the user, DO NOT choose for them. This cannot be changed after a project is uploaded. Private is used if you do not wish to distribute your application on the HubSpot marketplace. '),
20
20
  auth: z
21
21
  .optional(z.union([
22
22
  z.literal(APP_AUTH_TYPES.STATIC),
23
23
  z.literal(APP_AUTH_TYPES.OAUTH),
24
24
  ]))
25
- .describe('Static uses a static non changing authentication token, and is only available for private distribution. If not specified by the user, do not choose for them. This cannot be changed after a project is uploaded.'),
25
+ .describe('If not specified by the user, DO NOT choose for them. This cannot be changed after a project is uploaded. Static uses a static non changing authentication token, and is only available for private distribution. '),
26
26
  features,
27
27
  };
28
28
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
29
29
  const inputSchemaZodObject = z.object({
30
30
  ...inputSchema,
31
31
  });
32
- const toolName = 'add-feature-to-hubspot-project';
32
+ const toolName = 'add-feature-to-project';
33
33
  export class AddFeatureToProjectTool extends Tool {
34
34
  constructor(mcpServer) {
35
35
  super(mcpServer);
@@ -8,7 +8,7 @@ declare const inputSchemaZodObject: z.ZodObject<{
8
8
  projectBase: z.ZodUnion<[z.ZodLiteral<"empty">, z.ZodLiteral<"app">]>;
9
9
  distribution: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"marketplace">, z.ZodLiteral<"private">]>>;
10
10
  auth: z.ZodOptional<z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"static">, z.ZodLiteral<"oauth">]>>>;
11
- features: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodLiteral<"card">, z.ZodLiteral<"settings">, z.ZodLiteral<"app-function">, z.ZodLiteral<"webhooks">, z.ZodLiteral<"workflow-action">]>, "many">>;
11
+ features: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodLiteral<"card">, z.ZodLiteral<"settings">, z.ZodLiteral<"app-function">, z.ZodLiteral<"webhooks">, z.ZodLiteral<"workflow-action">, z.ZodLiteral<"workflow-action-tool">, z.ZodLiteral<"app-object">, z.ZodLiteral<"app-event">, z.ZodLiteral<"scim">, z.ZodLiteral<"page">]>, "many">>;
12
12
  }, "strip", z.ZodTypeAny, {
13
13
  projectBase: "app" | "empty";
14
14
  absoluteCurrentWorkingDirectory: string;
@@ -16,7 +16,7 @@ declare const inputSchemaZodObject: z.ZodObject<{
16
16
  name?: string | undefined;
17
17
  auth?: "oauth" | "static" | undefined;
18
18
  distribution?: "marketplace" | "private" | undefined;
19
- features?: ("card" | "settings" | "app-function" | "webhooks" | "workflow-action")[] | undefined;
19
+ features?: ("card" | "settings" | "page" | "app-event" | "workflow-action-tool" | "workflow-action" | "app-function" | "webhooks" | "app-object" | "scim")[] | undefined;
20
20
  }, {
21
21
  projectBase: "app" | "empty";
22
22
  absoluteCurrentWorkingDirectory: string;
@@ -24,7 +24,7 @@ declare const inputSchemaZodObject: z.ZodObject<{
24
24
  name?: string | undefined;
25
25
  auth?: "oauth" | "static" | undefined;
26
26
  distribution?: "marketplace" | "private" | undefined;
27
- features?: ("card" | "settings" | "app-function" | "webhooks" | "workflow-action")[] | undefined;
27
+ features?: ("card" | "settings" | "page" | "app-event" | "workflow-action-tool" | "workflow-action" | "app-function" | "webhooks" | "app-object" | "scim")[] | undefined;
28
28
  }>;
29
29
  export type CreateProjectInputSchema = z.infer<typeof inputSchemaZodObject>;
30
30
  export declare class CreateProjectTool extends Tool<CreateProjectInputSchema> {