@hubspot/cli 7.7.20-experimental.0 → 7.7.21-experimental.1

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 (62) hide show
  1. package/bin/cli.js +6 -2
  2. package/commands/__tests__/getStarted.test.js +0 -10
  3. package/commands/app/__tests__/install.test.d.ts +1 -0
  4. package/commands/app/__tests__/install.test.js +52 -0
  5. package/commands/app/install.d.ts +8 -0
  6. package/commands/app/install.js +127 -0
  7. package/commands/app.js +6 -1
  8. package/commands/getStarted.js +12 -27
  9. package/commands/mcp/setup.js +1 -0
  10. package/commands/mcp/start.d.ts +4 -1
  11. package/commands/mcp/start.js +8 -3
  12. package/commands/project/__tests__/deploy.test.js +27 -25
  13. package/commands/project/__tests__/devUnifiedFlow.test.js +20 -16
  14. package/commands/project/create.js +1 -1
  15. package/commands/project/deploy.d.ts +3 -2
  16. package/commands/project/deploy.js +61 -55
  17. package/commands/project/dev/unifiedFlow.js +7 -6
  18. package/commands/testAccount/__tests__/createConfig.test.js +0 -3
  19. package/commands/testAccount/create.js +14 -24
  20. package/commands/testAccount/createConfig.d.ts +0 -2
  21. package/commands/testAccount/createConfig.js +7 -8
  22. package/lang/en.d.ts +61 -23
  23. package/lang/en.js +62 -24
  24. package/lang/en.lyaml +0 -26
  25. package/lib/__tests__/buildAccount.test.js +30 -2
  26. package/lib/__tests__/usageTracking.test.js +8 -14
  27. package/lib/buildAccount.d.ts +7 -1
  28. package/lib/buildAccount.js +54 -4
  29. package/lib/mcp/setup.js +8 -3
  30. package/lib/projects/add/legacyAddComponent.js +1 -1
  31. package/lib/projects/add/v3AddComponent.js +1 -1
  32. package/lib/projects/localDev/DevServerManager.js +0 -2
  33. package/lib/projects/localDev/DevServerManagerV2.js +0 -2
  34. package/lib/projects/localDev/helpers.d.ts +1 -1
  35. package/lib/projects/localDev/helpers.js +2 -2
  36. package/lib/projects/structure.d.ts +2 -2
  37. package/lib/projects/upload.d.ts +2 -1
  38. package/lib/projects/upload.js +2 -1
  39. package/lib/prompts/createDeveloperTestAccountConfigPrompt.d.ts +11 -10
  40. package/lib/prompts/createDeveloperTestAccountConfigPrompt.js +73 -31
  41. package/lib/prompts/promptUtils.js +66 -56
  42. package/lib/ui/index.js +1 -1
  43. package/lib/usageTracking.d.ts +11 -0
  44. package/lib/usageTracking.js +67 -73
  45. package/mcp-server/tools/project/AddFeatureToProject.js +4 -1
  46. package/mcp-server/tools/project/CreateProjectTool.d.ts +2 -2
  47. package/mcp-server/tools/project/CreateProjectTool.js +4 -1
  48. package/mcp-server/tools/project/DeployProject.js +4 -1
  49. package/mcp-server/tools/project/GuidedWalkthroughTool.js +4 -1
  50. package/mcp-server/tools/project/UploadProjectTools.js +4 -1
  51. package/mcp-server/tools/project/ValidateProjectTool.js +4 -1
  52. package/mcp-server/tools/project/__tests__/AddFeatureToProject.test.js +1 -0
  53. package/mcp-server/tools/project/__tests__/CreateProjectTool.test.js +1 -0
  54. package/mcp-server/tools/project/__tests__/DeployProject.test.js +1 -0
  55. package/mcp-server/tools/project/__tests__/GuidedWalkthroughTool.test.js +1 -0
  56. package/mcp-server/tools/project/__tests__/UploadProjectTools.test.js +1 -0
  57. package/mcp-server/tools/project/__tests__/ValidateProjectTool.test.js +1 -0
  58. package/mcp-server/utils/__tests__/project.test.js +9 -6
  59. package/mcp-server/utils/project.js +3 -0
  60. package/mcp-server/utils/toolUsageTracking.d.ts +1 -0
  61. package/mcp-server/utils/toolUsageTracking.js +25 -0
  62. package/package.json +4 -4
@@ -5,6 +5,7 @@ const types_1 = require("../../types");
5
5
  const zod_1 = require("zod");
6
6
  const command_1 = require("../../utils/command");
7
7
  const content_1 = require("../../utils/content");
8
+ const toolUsageTracking_1 = require("../../utils/toolUsageTracking");
8
9
  const nextCommands = {
9
10
  'hs init': 'hs auth',
10
11
  'hs auth': 'hs project create',
@@ -26,11 +27,13 @@ const inputSchema = {
26
27
  const inputSchemaZodObject = zod_1.z.object({
27
28
  ...inputSchema,
28
29
  });
30
+ const toolName = 'guided-walkthrough-hubspot-cli';
29
31
  class GuidedWalkthroughTool extends types_1.Tool {
30
32
  constructor(mcpServer) {
31
33
  super(mcpServer);
32
34
  }
33
35
  async handler({ command }) {
36
+ await (0, toolUsageTracking_1.trackToolUsage)(toolName);
34
37
  if (command) {
35
38
  const { stdout } = await (0, command_1.execAsync)(`${command} --help`);
36
39
  return (0, content_1.formatTextContents)(`Display this help output for the user amd wait for them to acknowledge: ${stdout}. ${nextCommands[command] ? `Once they are ready, A good command to look at next is ${nextCommands[command]}` : ''}`);
@@ -38,7 +41,7 @@ class GuidedWalkthroughTool extends types_1.Tool {
38
41
  return (0, content_1.formatTextContents)('Is there another command you would like to learn more about?');
39
42
  }
40
43
  register() {
41
- return this.mcpServer.registerTool('guided-walkthrough-hubspot-cli', {
44
+ return this.mcpServer.registerTool(toolName, {
42
45
  title: 'Guided walkthrough of the CLI',
43
46
  description: 'Give the user a guided walkthrough of the HubSpot CLI.',
44
47
  inputSchema: {
@@ -9,6 +9,7 @@ const project_1 = require("../../utils/project");
9
9
  const constants_1 = require("./constants");
10
10
  const zod_1 = __importDefault(require("zod"));
11
11
  const content_1 = require("../../utils/content");
12
+ const toolUsageTracking_1 = require("../../utils/toolUsageTracking");
12
13
  const inputSchema = {
13
14
  absoluteProjectPath: constants_1.absoluteProjectPath,
14
15
  };
@@ -16,16 +17,18 @@ const inputSchema = {
16
17
  const inputSchemaZodObject = zod_1.default.object({
17
18
  ...inputSchema,
18
19
  });
20
+ const toolName = 'upload-hubspot-project';
19
21
  class UploadProjectTools extends types_1.Tool {
20
22
  constructor(mcpServer) {
21
23
  super(mcpServer);
22
24
  }
23
25
  async handler({ absoluteProjectPath, }) {
26
+ await (0, toolUsageTracking_1.trackToolUsage)(toolName);
24
27
  const { stdout, stderr } = await (0, project_1.runCommandInDir)(absoluteProjectPath, `hs project upload --force-create`);
25
28
  return (0, content_1.formatTextContents)(stdout, stderr);
26
29
  }
27
30
  register() {
28
- return this.mcpServer.registerTool('upload-hubspot-project', {
31
+ return this.mcpServer.registerTool(toolName, {
29
32
  title: 'Upload HubSpot Project',
30
33
  description: 'Uploads the HubSpot project in current working directory. If the project does not exist, it will be created. MUST be ran from within the project directory. DO NOT run this tool unless the user specifies they would like to upload the project, it is potentially destructive',
31
34
  inputSchema,
@@ -6,16 +6,19 @@ const zod_1 = require("zod");
6
6
  const constants_1 = require("./constants");
7
7
  const project_1 = require("../../utils/project");
8
8
  const content_1 = require("../../utils/content");
9
+ const toolUsageTracking_1 = require("../../utils/toolUsageTracking");
9
10
  const inputSchema = {
10
11
  absoluteProjectPath: constants_1.absoluteProjectPath,
11
12
  };
12
13
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
13
14
  const inputSchemaZodObject = zod_1.z.object({ ...inputSchema });
15
+ const toolName = 'validate-hubspot-project';
14
16
  class ValidateProjectTool extends types_1.Tool {
15
17
  constructor(mcpServer) {
16
18
  super(mcpServer);
17
19
  }
18
20
  async handler({ absoluteProjectPath, }) {
21
+ await (0, toolUsageTracking_1.trackToolUsage)(toolName);
19
22
  try {
20
23
  const { stdout, stderr } = await (0, project_1.runCommandInDir)(absoluteProjectPath, 'hs project validate');
21
24
  return (0, content_1.formatTextContents)(stdout, stderr);
@@ -25,7 +28,7 @@ class ValidateProjectTool extends types_1.Tool {
25
28
  }
26
29
  }
27
30
  register() {
28
- return this.mcpServer.registerTool('validate-hubspot-project', {
31
+ return this.mcpServer.registerTool(toolName, {
29
32
  title: 'Validate HubSpot Project',
30
33
  description: 'Validates the HubSpot project and its configuration files. This tool does not need to be ran before uploading the project',
31
34
  inputSchema,
@@ -8,6 +8,7 @@ vi.mock('@modelcontextprotocol/sdk/server/mcp.js');
8
8
  vi.mock('../../../utils/project');
9
9
  vi.mock('../../../utils/command');
10
10
  vi.mock('../../../../lib/constants');
11
+ vi.mock('../../../utils/toolUsageTracking');
11
12
  const mockRunCommandInDir = project_1.runCommandInDir;
12
13
  const mockAddFlag = command_1.addFlag;
13
14
  describe('mcp-server/tools/project/AddFeatureToProject', () => {
@@ -10,6 +10,7 @@ vi.mock('../../../utils/project');
10
10
  vi.mock('../../../utils/command');
11
11
  vi.mock('../../../../lib/constants');
12
12
  vi.mock('../../../../lib/projects/create/v3');
13
+ vi.mock('../../../utils/toolUsageTracking');
13
14
  const mockRunCommandInDir = project_1.runCommandInDir;
14
15
  const mockAddFlag = command_1.addFlag;
15
16
  describe('mcp-server/tools/project/CreateProjectTool', () => {
@@ -6,6 +6,7 @@ const command_1 = require("../../../utils/command");
6
6
  vi.mock('@modelcontextprotocol/sdk/server/mcp.js');
7
7
  vi.mock('../../../utils/project');
8
8
  vi.mock('../../../utils/command');
9
+ vi.mock('../../../utils/toolUsageTracking');
9
10
  const mockRunCommandInDir = project_1.runCommandInDir;
10
11
  const mockAddFlag = command_1.addFlag;
11
12
  describe('mcp-server/tools/project/DeployProject', () => {
@@ -4,6 +4,7 @@ const GuidedWalkthroughTool_1 = require("../GuidedWalkthroughTool");
4
4
  const command_1 = require("../../../utils/command");
5
5
  vi.mock('@modelcontextprotocol/sdk/server/mcp.js');
6
6
  vi.mock('../../../utils/command');
7
+ vi.mock('../../../utils/toolUsageTracking');
7
8
  const mockExecAsync = command_1.execAsync;
8
9
  describe('mcp-server/tools/project/GuidedWalkthroughTool', () => {
9
10
  let mockMcpServer;
@@ -4,6 +4,7 @@ const UploadProjectTools_1 = require("../UploadProjectTools");
4
4
  const project_1 = require("../../../utils/project");
5
5
  vi.mock('@modelcontextprotocol/sdk/server/mcp.js');
6
6
  vi.mock('../../../utils/project');
7
+ vi.mock('../../../utils/toolUsageTracking');
7
8
  const mockRunCommandInDir = project_1.runCommandInDir;
8
9
  describe('mcp-server/tools/project/UploadProjectTools', () => {
9
10
  let mockMcpServer;
@@ -4,6 +4,7 @@ const ValidateProjectTool_1 = require("../ValidateProjectTool");
4
4
  const project_1 = require("../../../utils/project");
5
5
  vi.mock('@modelcontextprotocol/sdk/server/mcp.js');
6
6
  vi.mock('../../../utils/project');
7
+ vi.mock('../../../utils/toolUsageTracking');
7
8
  const mockRunCommandInDir = project_1.runCommandInDir;
8
9
  describe('mcp-server/tools/project/ValidateProjectTool', () => {
9
10
  let mockMcpServer;
@@ -36,9 +36,10 @@ describe('mcp-server/utils/project', () => {
36
36
  expect(mockExistsSync).toHaveBeenCalledWith(mockDirectory);
37
37
  expect(mockMkdirSync).not.toHaveBeenCalled();
38
38
  expect(mockResolve).toHaveBeenCalledWith(mockDirectory);
39
- expect(mockExecAsync).toHaveBeenCalledWith(mockCommand, {
39
+ expect(mockExecAsync).toHaveBeenCalledWith(mockCommand, expect.objectContaining({
40
40
  cwd: mockResolvedPath,
41
- });
41
+ env: expect.any(Object),
42
+ }));
42
43
  expect(result).toEqual(expectedResult);
43
44
  });
44
45
  it('should create directory if it does not exist', async () => {
@@ -52,9 +53,10 @@ describe('mcp-server/utils/project', () => {
52
53
  expect(mockExistsSync).toHaveBeenCalledWith(mockDirectory);
53
54
  expect(mockMkdirSync).toHaveBeenCalledWith(mockDirectory);
54
55
  expect(mockResolve).toHaveBeenCalledWith(mockDirectory);
55
- expect(mockExecAsync).toHaveBeenCalledWith(mockCommand, {
56
+ expect(mockExecAsync).toHaveBeenCalledWith(mockCommand, expect.objectContaining({
56
57
  cwd: mockResolvedPath,
57
- });
58
+ env: expect.any(Object),
59
+ }));
58
60
  expect(result).toEqual(expectedResult);
59
61
  });
60
62
  it('should propagate execAsync errors', async () => {
@@ -62,9 +64,10 @@ describe('mcp-server/utils/project', () => {
62
64
  mockExistsSync.mockReturnValue(true);
63
65
  mockExecAsync.mockRejectedValue(error);
64
66
  await expect((0, project_1.runCommandInDir)(mockDirectory, mockCommand)).rejects.toThrow('Command failed');
65
- expect(mockExecAsync).toHaveBeenCalledWith(mockCommand, {
67
+ expect(mockExecAsync).toHaveBeenCalledWith(mockCommand, expect.objectContaining({
66
68
  cwd: mockResolvedPath,
67
- });
69
+ env: expect.any(Object),
70
+ }));
68
71
  });
69
72
  it('should handle stderr in results', async () => {
70
73
  const expectedResult = {
@@ -13,5 +13,8 @@ async function runCommandInDir(directory, command) {
13
13
  }
14
14
  return (0, command_1.execAsync)(command, {
15
15
  cwd: path_1.default.resolve(directory),
16
+ env: {
17
+ ...process.env,
18
+ },
16
19
  });
17
20
  }
@@ -0,0 +1 @@
1
+ export declare function trackToolUsage(toolName: string): Promise<void>;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.trackToolUsage = trackToolUsage;
4
+ const trackUsage_1 = require("@hubspot/local-dev-lib/trackUsage");
5
+ const logger_1 = require("@hubspot/local-dev-lib/logger");
6
+ const usageTracking_1 = require("../../lib/usageTracking");
7
+ const config_1 = require("@hubspot/local-dev-lib/config");
8
+ async function trackToolUsage(toolName) {
9
+ if (!(0, config_1.isTrackingAllowed)()) {
10
+ return;
11
+ }
12
+ const usageTrackingEvent = {
13
+ action: 'cli-mcp-tool-invocation',
14
+ os: (0, usageTracking_1.getPlatform)(),
15
+ ...(0, usageTracking_1.getNodeVersionData)(),
16
+ command: toolName,
17
+ type: process.env.HUBSPOT_MCP_AI_AGENT,
18
+ };
19
+ const accountId = (0, config_1.getAccountId)() || undefined;
20
+ try {
21
+ logger_1.logger.info('Tracking tool usage');
22
+ await (0, trackUsage_1.trackUsage)('cli-interaction', usageTracking_1.EventClass.INTERACTION, usageTrackingEvent, accountId);
23
+ }
24
+ catch (error) { }
25
+ }
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@hubspot/cli",
3
- "version": "7.7.20-experimental.0",
3
+ "version": "7.7.21-experimental.1",
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",
7
7
  "dependencies": {
8
- "@hubspot/local-dev-lib": "3.12.0",
9
- "@hubspot/project-parsing-lib": "0.0.21-experimental.0",
8
+ "@hubspot/local-dev-lib": "3.14.0",
9
+ "@hubspot/project-parsing-lib": "0.5.3",
10
10
  "@hubspot/serverless-dev-runtime": "7.0.6",
11
11
  "@hubspot/theme-preview-dev-server": "0.0.10",
12
- "@hubspot/ui-extensions-dev-server": "0.9.2",
12
+ "@hubspot/ui-extensions-dev-server": "0.9.4",
13
13
  "archiver": "7.0.1",
14
14
  "boxen": "8.0.1",
15
15
  "chalk": "4.1.2",