@hubspot/cli 7.6.0-beta.2 → 7.6.0-beta.4
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/api/__tests__/migrate.test.d.ts +1 -0
- package/api/__tests__/migrate.test.js +183 -0
- package/bin/cli.js +6 -2
- package/commands/__tests__/account.test.d.ts +1 -0
- package/commands/__tests__/account.test.js +74 -0
- package/commands/__tests__/auth.test.d.ts +1 -0
- package/commands/__tests__/auth.test.js +43 -0
- package/commands/__tests__/cms.test.d.ts +1 -0
- package/commands/__tests__/cms.test.js +49 -0
- package/commands/__tests__/config.test.d.ts +1 -0
- package/commands/__tests__/config.test.js +49 -0
- package/commands/__tests__/create.test.d.ts +1 -0
- package/commands/__tests__/create.test.js +38 -0
- package/commands/__tests__/customObject.test.d.ts +1 -0
- package/commands/__tests__/customObject.test.js +54 -0
- package/commands/__tests__/doctor.test.d.ts +1 -0
- package/commands/__tests__/doctor.test.js +139 -0
- package/commands/__tests__/feedback.test.d.ts +1 -0
- package/commands/__tests__/feedback.test.js +62 -0
- package/commands/__tests__/fetch.test.d.ts +1 -0
- package/commands/__tests__/fetch.test.js +56 -0
- package/commands/__tests__/filemanager.test.d.ts +1 -0
- package/commands/__tests__/filemanager.test.js +50 -0
- package/commands/__tests__/function.test.d.ts +1 -0
- package/commands/__tests__/function.test.js +51 -0
- package/commands/__tests__/getStarted.test.d.ts +1 -0
- package/commands/__tests__/getStarted.test.js +170 -0
- package/commands/__tests__/hubdb.test.d.ts +1 -0
- package/commands/__tests__/hubdb.test.js +55 -0
- package/commands/__tests__/init.test.d.ts +1 -0
- package/commands/__tests__/init.test.js +47 -0
- package/commands/__tests__/lint.test.d.ts +1 -0
- package/commands/__tests__/lint.test.js +38 -0
- package/commands/__tests__/list.test.d.ts +1 -0
- package/commands/__tests__/list.test.js +47 -0
- package/commands/__tests__/logs.test.d.ts +1 -0
- package/commands/__tests__/logs.test.js +70 -0
- package/commands/__tests__/mcp.test.d.ts +1 -0
- package/commands/__tests__/mcp.test.js +51 -0
- package/commands/__tests__/mv.test.d.ts +1 -0
- package/commands/__tests__/mv.test.js +84 -0
- package/commands/__tests__/open.test.d.ts +1 -0
- package/commands/__tests__/open.test.js +96 -0
- package/commands/__tests__/project.test.d.ts +1 -0
- package/commands/__tests__/project.test.js +100 -0
- package/commands/__tests__/remove.test.d.ts +1 -0
- package/commands/__tests__/remove.test.js +77 -0
- package/commands/__tests__/sandbox.test.d.ts +1 -0
- package/commands/__tests__/sandbox.test.js +49 -0
- package/commands/__tests__/secret.test.d.ts +1 -0
- package/commands/__tests__/secret.test.js +54 -0
- package/commands/__tests__/testAccount.test.d.ts +1 -0
- package/commands/__tests__/testAccount.test.js +60 -0
- package/commands/__tests__/theme.test.d.ts +1 -0
- package/commands/__tests__/theme.test.js +52 -0
- package/commands/account/__tests__/auth.test.d.ts +1 -0
- package/commands/account/__tests__/auth.test.js +31 -0
- package/commands/account/__tests__/clean.test.d.ts +1 -0
- package/commands/account/__tests__/clean.test.js +33 -0
- package/commands/account/__tests__/createOverride.test.d.ts +1 -0
- package/commands/account/__tests__/createOverride.test.js +37 -0
- package/commands/account/__tests__/info.test.d.ts +1 -0
- package/commands/account/__tests__/info.test.js +33 -0
- package/commands/account/__tests__/list.test.d.ts +1 -0
- package/commands/account/__tests__/list.test.js +33 -0
- package/commands/account/__tests__/remove.test.d.ts +1 -0
- package/commands/account/__tests__/remove.test.js +41 -0
- package/commands/account/__tests__/removeOverride.d.ts +1 -0
- package/commands/account/__tests__/removeOverride.js +30 -0
- package/commands/account/__tests__/rename.test.d.ts +1 -0
- package/commands/account/__tests__/rename.test.js +47 -0
- package/commands/account/__tests__/use.test.d.ts +1 -0
- package/commands/account/__tests__/use.test.js +37 -0
- package/commands/app/__tests__/migrate.test.d.ts +1 -0
- package/commands/app/__tests__/migrate.test.js +129 -0
- package/commands/app/secret/__tests__/add.test.d.ts +1 -0
- package/commands/app/secret/__tests__/add.test.js +33 -0
- package/commands/app/secret/__tests__/delete.test.d.ts +1 -0
- package/commands/app/secret/__tests__/delete.test.js +33 -0
- package/commands/app/secret/__tests__/list.test.d.ts +1 -0
- package/commands/app/secret/__tests__/list.test.js +30 -0
- package/commands/app/secret/__tests__/update.test.d.ts +1 -0
- package/commands/app/secret/__tests__/update.test.js +33 -0
- package/commands/customObject/__tests__/create.test.d.ts +1 -0
- package/commands/customObject/__tests__/create.test.js +45 -0
- package/commands/customObject/__tests__/schema.test.d.ts +1 -0
- package/commands/customObject/__tests__/schema.test.js +58 -0
- package/commands/customObject/schema/__tests__/create.test.d.ts +1 -0
- package/commands/customObject/schema/__tests__/create.test.js +33 -0
- package/commands/customObject/schema/__tests__/delete.test.d.ts +1 -0
- package/commands/customObject/schema/__tests__/delete.test.js +47 -0
- package/commands/customObject/schema/__tests__/fetch-all.test.d.ts +1 -0
- package/commands/customObject/schema/__tests__/fetch-all.test.js +46 -0
- package/commands/customObject/schema/__tests__/fetch.test.d.ts +1 -0
- package/commands/customObject/schema/__tests__/fetch.test.js +50 -0
- package/commands/customObject/schema/__tests__/list.test.d.ts +1 -0
- package/commands/customObject/schema/__tests__/list.test.js +34 -0
- package/commands/customObject/schema/__tests__/update.test.d.ts +1 -0
- package/commands/customObject/schema/__tests__/update.test.js +45 -0
- package/commands/fetch.js +0 -1
- package/commands/filemanager/__tests__/fetch.test.d.ts +1 -0
- package/commands/filemanager/__tests__/fetch.test.js +37 -0
- package/commands/filemanager/__tests__/upload.test.d.ts +1 -0
- package/commands/filemanager/__tests__/upload.test.js +35 -0
- package/commands/getStarted.js +8 -14
- package/commands/hubdb/__tests__/clear.test.d.ts +1 -0
- package/commands/hubdb/__tests__/clear.test.js +33 -0
- package/commands/hubdb/__tests__/create.test.d.ts +1 -0
- package/commands/hubdb/__tests__/create.test.js +33 -0
- package/commands/hubdb/__tests__/delete.test.d.ts +1 -0
- package/commands/hubdb/__tests__/delete.test.js +33 -0
- package/commands/hubdb/__tests__/fetch.test.d.ts +1 -0
- package/commands/hubdb/__tests__/fetch.test.js +33 -0
- package/commands/hubdb/__tests__/list.test.d.ts +1 -0
- package/commands/hubdb/__tests__/list.test.js +101 -0
- package/commands/logs.js +0 -1
- package/commands/mcp/__tests__/setup.test.d.ts +1 -0
- package/commands/mcp/__tests__/setup.test.js +31 -0
- package/commands/mcp/__tests__/start.test.d.ts +1 -0
- package/commands/mcp/__tests__/start.test.js +32 -0
- package/commands/mcp/setup.js +1 -0
- package/commands/mcp/start.d.ts +4 -1
- package/commands/mcp/start.js +8 -3
- package/commands/open.js +14 -12
- package/commands/project/__tests__/add.test.d.ts +1 -0
- package/commands/project/__tests__/add.test.js +48 -0
- package/commands/project/__tests__/create.test.d.ts +1 -0
- package/commands/project/__tests__/create.test.js +45 -0
- package/commands/project/__tests__/deploy.test.d.ts +1 -0
- package/commands/project/__tests__/deploy.test.js +350 -0
- package/commands/project/__tests__/devUnifiedFlow.test.d.ts +1 -0
- package/commands/project/__tests__/devUnifiedFlow.test.js +419 -0
- package/commands/project/__tests__/download.test.d.ts +1 -0
- package/commands/project/__tests__/download.test.js +44 -0
- package/commands/project/__tests__/fixtures/exampleProject.json +33 -0
- package/commands/project/__tests__/installDeps.test.d.ts +1 -0
- package/commands/project/__tests__/installDeps.test.js +180 -0
- package/commands/project/__tests__/listBuilds.test.d.ts +1 -0
- package/commands/project/__tests__/listBuilds.test.js +43 -0
- package/commands/project/__tests__/logs.test.d.ts +1 -0
- package/commands/project/__tests__/logs.test.js +246 -0
- package/commands/project/__tests__/migrate.test.d.ts +1 -0
- package/commands/project/__tests__/migrate.test.js +116 -0
- package/commands/project/__tests__/migrateApp.test.d.ts +1 -0
- package/commands/project/__tests__/migrateApp.test.js +87 -0
- package/commands/project/__tests__/open.test.d.ts +1 -0
- package/commands/project/__tests__/open.test.js +44 -0
- package/commands/project/__tests__/profile.test.d.ts +1 -0
- package/commands/project/__tests__/profile.test.js +47 -0
- package/commands/project/__tests__/upload.test.d.ts +1 -0
- package/commands/project/__tests__/upload.test.js +48 -0
- package/commands/project/__tests__/watch.test.d.ts +1 -0
- package/commands/project/__tests__/watch.test.js +40 -0
- package/commands/project/deploy.d.ts +1 -0
- package/commands/project/deploy.js +21 -10
- package/commands/sandbox/__tests__/create.test.d.ts +1 -0
- package/commands/sandbox/__tests__/create.test.js +36 -0
- package/commands/sandbox/__tests__/delete.test.d.ts +1 -0
- package/commands/sandbox/__tests__/delete.test.js +36 -0
- package/commands/secret/__tests__/addSecret.test.d.ts +1 -0
- package/commands/secret/__tests__/addSecret.test.js +34 -0
- package/commands/secret/__tests__/deleteSecret.test.d.ts +1 -0
- package/commands/secret/__tests__/deleteSecret.test.js +46 -0
- package/commands/secret/__tests__/listSecret.test.d.ts +1 -0
- package/commands/secret/__tests__/listSecret.test.js +34 -0
- package/commands/secret/__tests__/updateSecret.test.d.ts +1 -0
- package/commands/secret/__tests__/updateSecret.test.js +34 -0
- package/commands/testAccount/__tests__/create.test.d.ts +1 -0
- package/commands/testAccount/__tests__/create.test.js +38 -0
- package/commands/testAccount/__tests__/createConfig.test.d.ts +1 -0
- package/commands/testAccount/__tests__/createConfig.test.js +37 -0
- package/commands/testAccount/__tests__/delete.test.d.ts +1 -0
- package/commands/testAccount/__tests__/delete.test.js +36 -0
- package/commands/testAccount/create.js +16 -3
- package/commands/testAccount/createConfig.d.ts +0 -2
- package/commands/testAccount/createConfig.js +7 -8
- package/commands/theme/__tests__/generate-selectors.test.d.ts +1 -0
- package/commands/theme/__tests__/generate-selectors.test.js +33 -0
- package/commands/theme/__tests__/marketplace-validate.test.d.ts +1 -0
- package/commands/theme/__tests__/marketplace-validate.test.js +41 -0
- package/commands/theme/__tests__/preview.test.d.ts +1 -0
- package/commands/theme/__tests__/preview.test.js +65 -0
- package/lang/en.d.ts +15 -2
- package/lang/en.js +15 -2
- package/lib/__tests__/accountTypes.test.d.ts +1 -0
- package/lib/__tests__/accountTypes.test.js +100 -0
- package/lib/__tests__/buildAccount.test.d.ts +1 -0
- package/lib/__tests__/buildAccount.test.js +231 -0
- package/lib/__tests__/commonOpts.test.d.ts +1 -0
- package/lib/__tests__/commonOpts.test.js +87 -0
- package/lib/__tests__/dependencyManagement.test.d.ts +1 -0
- package/lib/__tests__/dependencyManagement.test.js +180 -0
- package/lib/__tests__/developerTestAccounts.test.d.ts +1 -0
- package/lib/__tests__/developerTestAccounts.test.js +180 -0
- package/lib/__tests__/hasFeature.test.d.ts +1 -0
- package/lib/__tests__/hasFeature.test.js +37 -0
- package/lib/__tests__/npm.test.d.ts +1 -0
- package/lib/__tests__/npm.test.js +62 -0
- package/lib/__tests__/oauth.test.d.ts +1 -0
- package/lib/__tests__/oauth.test.js +113 -0
- package/lib/__tests__/parsing.test.d.ts +1 -0
- package/lib/__tests__/parsing.test.js +36 -0
- package/lib/__tests__/polling.test.d.ts +1 -0
- package/lib/__tests__/polling.test.js +78 -0
- package/lib/__tests__/process.test.d.ts +1 -0
- package/lib/__tests__/process.test.js +90 -0
- package/lib/__tests__/projectProfiles.test.d.ts +1 -0
- package/lib/__tests__/projectProfiles.test.js +134 -0
- package/lib/__tests__/sandboxSync.test.d.ts +1 -0
- package/lib/__tests__/sandboxSync.test.js +131 -0
- package/lib/__tests__/sandboxes.test.d.ts +1 -0
- package/lib/__tests__/sandboxes.test.js +148 -0
- package/lib/__tests__/serverlessLogs.test.d.ts +1 -0
- package/lib/__tests__/serverlessLogs.test.js +154 -0
- package/lib/__tests__/usageTracking.test.d.ts +1 -0
- package/lib/__tests__/usageTracking.test.js +165 -0
- package/lib/__tests__/validation.test.d.ts +1 -0
- package/lib/__tests__/validation.test.js +145 -0
- package/lib/__tests__/yargsUtils.test.d.ts +1 -0
- package/lib/__tests__/yargsUtils.test.js +74 -0
- package/lib/app/__tests__/migrate.test.d.ts +1 -0
- package/lib/app/__tests__/migrate.test.js +495 -0
- package/lib/app/__tests__/migrate_legacy.test.d.ts +1 -0
- package/lib/app/__tests__/migrate_legacy.test.js +136 -0
- package/lib/app/migrate.js +2 -6
- package/lib/dependencyManagement.d.ts +1 -1
- package/lib/dependencyManagement.js +2 -2
- package/lib/doctor/Diagnosis.js +11 -11
- package/lib/doctor/Doctor.js +42 -42
- package/lib/doctor/__tests__/Diagnosis.test.d.ts +1 -0
- package/lib/doctor/__tests__/Diagnosis.test.js +87 -0
- package/lib/doctor/__tests__/DiagnosticInfoBuilder.test.d.ts +1 -0
- package/lib/doctor/__tests__/DiagnosticInfoBuilder.test.js +172 -0
- package/lib/doctor/__tests__/Doctor.test.d.ts +1 -0
- package/lib/doctor/__tests__/Doctor.test.js +398 -0
- package/lib/errorHandlers/index.js +8 -0
- package/lib/mcp/setup.js +26 -5
- package/lib/middleware/__test__/configMiddleware.test.js +12 -12
- package/lib/middleware/__test__/gitMiddleware.test.js +4 -4
- package/lib/middleware/__test__/notificationsMiddleware.test.js +2 -2
- package/lib/middleware/__test__/requestMiddleware.test.js +2 -2
- package/lib/middleware/__test__/yargsChecksMiddleware.test.js +7 -7
- package/lib/middleware/notificationsMiddleware.js +16 -13
- package/lib/projects/__tests__/AppDevModeInterface.test.d.ts +1 -0
- package/lib/projects/__tests__/AppDevModeInterface.test.js +517 -0
- package/lib/projects/__tests__/LocalDevProcess.test.d.ts +1 -0
- package/lib/projects/__tests__/LocalDevProcess.test.js +314 -0
- package/lib/projects/__tests__/LocalDevWebsocketServer.test.d.ts +1 -0
- package/lib/projects/__tests__/LocalDevWebsocketServer.test.js +175 -0
- package/lib/projects/__tests__/ProjectLogsManager.test.d.ts +1 -0
- package/lib/projects/__tests__/ProjectLogsManager.test.js +191 -0
- package/lib/projects/__tests__/buildAndDeploy.test.d.ts +1 -0
- package/lib/projects/__tests__/buildAndDeploy.test.js +25 -0
- package/lib/projects/__tests__/components.test.d.ts +1 -0
- package/lib/projects/__tests__/components.test.js +186 -0
- package/lib/projects/__tests__/projects.test.d.ts +1 -0
- package/lib/projects/__tests__/projects.test.js +89 -0
- package/lib/projects/__tests__/structure.test.d.ts +1 -0
- package/lib/projects/__tests__/structure.test.js +249 -0
- package/lib/projects/add/__tests__/legacyAddComponent.test.d.ts +1 -0
- package/lib/projects/add/__tests__/legacyAddComponent.test.js +206 -0
- package/lib/projects/add/__tests__/v3AddComponent.test.d.ts +1 -0
- package/lib/projects/add/__tests__/v3AddComponent.test.js +190 -0
- package/lib/projects/create/__tests__/legacy.test.d.ts +1 -0
- package/lib/projects/create/__tests__/legacy.test.js +126 -0
- package/lib/projects/create/__tests__/v3.test.d.ts +1 -0
- package/lib/projects/create/__tests__/v3.test.js +80 -0
- package/lib/projects/create/v3.d.ts +3 -2
- package/lib/projects/create/v3.js +2 -2
- package/lib/projects/localDev/DevServerManager.js +0 -1
- package/lib/projects/upload.js +1 -1
- package/lib/prompts/__tests__/downloadProjectPrompt.test.d.ts +1 -0
- package/lib/prompts/__tests__/downloadProjectPrompt.test.js +30 -0
- package/lib/prompts/__tests__/projectsLogsPrompt.test.d.ts +1 -0
- package/lib/prompts/__tests__/projectsLogsPrompt.test.js +42 -0
- package/lib/prompts/createDeveloperTestAccountConfigPrompt.d.ts +10 -9
- package/lib/prompts/createDeveloperTestAccountConfigPrompt.js +75 -31
- package/lib/prompts/createModulePrompt.js +1 -2
- package/lib/prompts/projectAddPrompt.d.ts +2 -1
- package/lib/prompts/projectAddPrompt.js +2 -1
- package/lib/prompts/promptUtils.d.ts +2 -2
- package/lib/prompts/promptUtils.js +161 -35
- package/lib/prompts/selectProjectTemplatePrompt.d.ts +2 -1
- package/lib/prompts/selectProjectTemplatePrompt.js +2 -1
- package/lib/schema.js +5 -1
- package/lib/testUtils.js +1 -2
- package/lib/ui/SpinniesManager.js +0 -1
- package/lib/ui/index.js +1 -1
- package/lib/ui/supportHyperlinks.js +2 -2
- package/lib/ui/supportsColor.js +2 -2
- package/lib/usageTracking.d.ts +11 -0
- package/lib/usageTracking.js +67 -73
- package/lib/utils/hasFlag.d.ts +1 -0
- package/lib/utils/hasFlag.js +15 -0
- package/lib/yargsUtils.d.ts +2 -1
- package/lib/yargsUtils.js +3 -13
- package/mcp-server/tools/project/AddFeatureToProject.js +4 -1
- package/mcp-server/tools/project/CreateProjectTool.d.ts +2 -2
- package/mcp-server/tools/project/CreateProjectTool.js +4 -1
- package/mcp-server/tools/project/DeployProject.js +4 -1
- package/mcp-server/tools/project/GuidedWalkthroughTool.js +4 -1
- package/mcp-server/tools/project/UploadProjectTools.js +4 -1
- package/mcp-server/tools/project/ValidateProjectTool.js +4 -1
- package/mcp-server/tools/project/__tests__/AddFeatureToProject.test.d.ts +1 -0
- package/mcp-server/tools/project/__tests__/AddFeatureToProject.test.js +153 -0
- package/mcp-server/tools/project/__tests__/CreateProjectTool.test.d.ts +1 -0
- package/mcp-server/tools/project/__tests__/CreateProjectTool.test.js +130 -0
- package/mcp-server/tools/project/__tests__/DeployProject.test.d.ts +1 -0
- package/mcp-server/tools/project/__tests__/DeployProject.test.js +121 -0
- package/mcp-server/tools/project/__tests__/GuidedWalkthroughTool.test.d.ts +1 -0
- package/mcp-server/tools/project/__tests__/GuidedWalkthroughTool.test.js +128 -0
- package/mcp-server/tools/project/__tests__/UploadProjectTools.test.d.ts +1 -0
- package/mcp-server/tools/project/__tests__/UploadProjectTools.test.js +109 -0
- package/mcp-server/tools/project/__tests__/ValidateProjectTool.test.d.ts +1 -0
- package/mcp-server/tools/project/__tests__/ValidateProjectTool.test.js +112 -0
- package/mcp-server/utils/__tests__/command.test.d.ts +1 -0
- package/mcp-server/utils/__tests__/command.test.js +47 -0
- package/mcp-server/utils/__tests__/project.test.d.ts +1 -0
- package/mcp-server/utils/__tests__/project.test.js +84 -0
- package/mcp-server/utils/project.js +3 -0
- package/mcp-server/utils/toolUsageTracking.d.ts +1 -0
- package/mcp-server/utils/toolUsageTracking.js +25 -0
- package/package.json +9 -9
- package/types/Prompts.d.ts +4 -2
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const GuidedWalkthroughTool_1 = require("../GuidedWalkthroughTool");
|
|
4
|
+
const command_1 = require("../../../utils/command");
|
|
5
|
+
vi.mock('@modelcontextprotocol/sdk/server/mcp.js');
|
|
6
|
+
vi.mock('../../../utils/command');
|
|
7
|
+
vi.mock('../../../utils/toolUsageTracking');
|
|
8
|
+
const mockExecAsync = command_1.execAsync;
|
|
9
|
+
describe('mcp-server/tools/project/GuidedWalkthroughTool', () => {
|
|
10
|
+
let mockMcpServer;
|
|
11
|
+
let tool;
|
|
12
|
+
let mockRegisteredTool;
|
|
13
|
+
beforeEach(() => {
|
|
14
|
+
vi.clearAllMocks();
|
|
15
|
+
// @ts-expect-error Not mocking whole server
|
|
16
|
+
mockMcpServer = {
|
|
17
|
+
registerTool: vi.fn(),
|
|
18
|
+
};
|
|
19
|
+
mockRegisteredTool = {};
|
|
20
|
+
mockMcpServer.registerTool.mockReturnValue(mockRegisteredTool);
|
|
21
|
+
tool = new GuidedWalkthroughTool_1.GuidedWalkthroughTool(mockMcpServer);
|
|
22
|
+
});
|
|
23
|
+
describe('register', () => {
|
|
24
|
+
it('should register tool with correct parameters', () => {
|
|
25
|
+
const result = tool.register();
|
|
26
|
+
expect(mockMcpServer.registerTool).toHaveBeenCalledWith('guided-walkthrough-hubspot-cli', {
|
|
27
|
+
title: 'Guided walkthrough of the CLI',
|
|
28
|
+
description: 'Give the user a guided walkthrough of the HubSpot CLI.',
|
|
29
|
+
inputSchema: expect.any(Object),
|
|
30
|
+
}, tool.handler);
|
|
31
|
+
expect(result).toBe(mockRegisteredTool);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
describe('handler', () => {
|
|
35
|
+
it('should show help for hs init command', async () => {
|
|
36
|
+
const helpOutput = 'Usage: hs init [options]\nInitialize HubSpot CLI';
|
|
37
|
+
mockExecAsync.mockResolvedValue({
|
|
38
|
+
stdout: helpOutput,
|
|
39
|
+
stderr: '',
|
|
40
|
+
});
|
|
41
|
+
const result = await tool.handler({ command: 'hs init' });
|
|
42
|
+
expect(mockExecAsync).toHaveBeenCalledWith('hs init --help');
|
|
43
|
+
expect(result.content).toHaveLength(1);
|
|
44
|
+
expect(result.content[0].text).toContain(helpOutput);
|
|
45
|
+
expect(result.content[0].text).toContain('hs auth');
|
|
46
|
+
});
|
|
47
|
+
it('should show help for hs auth command', async () => {
|
|
48
|
+
const helpOutput = 'Usage: hs auth [options]\nAuthenticate with HubSpot';
|
|
49
|
+
mockExecAsync.mockResolvedValue({
|
|
50
|
+
stdout: helpOutput,
|
|
51
|
+
stderr: '',
|
|
52
|
+
});
|
|
53
|
+
const result = await tool.handler({ command: 'hs auth' });
|
|
54
|
+
expect(mockExecAsync).toHaveBeenCalledWith('hs auth --help');
|
|
55
|
+
expect(result.content[0].text).toContain(helpOutput);
|
|
56
|
+
expect(result.content[0].text).toContain('hs project create');
|
|
57
|
+
});
|
|
58
|
+
it('should show help for hs project create command', async () => {
|
|
59
|
+
const helpOutput = 'Usage: hs project create [options]\nCreate a new project';
|
|
60
|
+
mockExecAsync.mockResolvedValue({
|
|
61
|
+
stdout: helpOutput,
|
|
62
|
+
stderr: '',
|
|
63
|
+
});
|
|
64
|
+
const result = await tool.handler({ command: 'hs project create' });
|
|
65
|
+
expect(mockExecAsync).toHaveBeenCalledWith('hs project create --help');
|
|
66
|
+
expect(result.content[0].text).toContain(helpOutput);
|
|
67
|
+
expect(result.content[0].text).toContain('hs project upload');
|
|
68
|
+
});
|
|
69
|
+
it('should show help for hs project upload command', async () => {
|
|
70
|
+
const helpOutput = 'Usage: hs project upload [options]\nUpload project to HubSpot';
|
|
71
|
+
mockExecAsync.mockResolvedValue({
|
|
72
|
+
stdout: helpOutput,
|
|
73
|
+
stderr: '',
|
|
74
|
+
});
|
|
75
|
+
const result = await tool.handler({ command: 'hs project upload' });
|
|
76
|
+
expect(mockExecAsync).toHaveBeenCalledWith('hs project upload --help');
|
|
77
|
+
expect(result.content[0].text).toContain(helpOutput);
|
|
78
|
+
expect(result.content[0].text).toContain('hs project dev');
|
|
79
|
+
});
|
|
80
|
+
it('should handle command without next step', async () => {
|
|
81
|
+
const helpOutput = 'Usage: hs project dev [options]\nStart development server';
|
|
82
|
+
mockExecAsync.mockResolvedValue({
|
|
83
|
+
stdout: helpOutput,
|
|
84
|
+
stderr: '',
|
|
85
|
+
});
|
|
86
|
+
// Test with a command that doesn't have a next command
|
|
87
|
+
const result = await tool.handler({ command: 'hs project upload' });
|
|
88
|
+
expect(result.content[0].text).toContain(helpOutput);
|
|
89
|
+
expect(result.content[0].text).toContain('hs project dev');
|
|
90
|
+
});
|
|
91
|
+
it('should handle no command provided', async () => {
|
|
92
|
+
const result = await tool.handler({});
|
|
93
|
+
expect(mockExecAsync).not.toHaveBeenCalled();
|
|
94
|
+
expect(result.content).toEqual([
|
|
95
|
+
{
|
|
96
|
+
type: 'text',
|
|
97
|
+
text: 'Is there another command you would like to learn more about?',
|
|
98
|
+
},
|
|
99
|
+
]);
|
|
100
|
+
});
|
|
101
|
+
it('should handle undefined command', async () => {
|
|
102
|
+
const result = await tool.handler({ command: undefined });
|
|
103
|
+
expect(mockExecAsync).not.toHaveBeenCalled();
|
|
104
|
+
expect(result.content).toEqual([
|
|
105
|
+
{
|
|
106
|
+
type: 'text',
|
|
107
|
+
text: 'Is there another command you would like to learn more about?',
|
|
108
|
+
},
|
|
109
|
+
]);
|
|
110
|
+
});
|
|
111
|
+
it('should handle execAsync errors', async () => {
|
|
112
|
+
const error = new Error('Command not found');
|
|
113
|
+
mockExecAsync.mockRejectedValue(error);
|
|
114
|
+
await expect(tool.handler({ command: 'hs init' })).rejects.toThrow('Command not found');
|
|
115
|
+
});
|
|
116
|
+
it('should format help text with proper instructions', async () => {
|
|
117
|
+
const helpOutput = 'Usage: hs init\nOptions:\n --help Show help';
|
|
118
|
+
mockExecAsync.mockResolvedValue({
|
|
119
|
+
stdout: helpOutput,
|
|
120
|
+
stderr: '',
|
|
121
|
+
});
|
|
122
|
+
const result = await tool.handler({ command: 'hs init' });
|
|
123
|
+
expect(result.content[0].text).toContain('Display this help output for the user amd wait for them to acknowledge:');
|
|
124
|
+
expect(result.content[0].text).toContain(helpOutput);
|
|
125
|
+
expect(result.content[0].text).toContain('Once they are ready, A good command to look at next is hs auth');
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const UploadProjectTools_1 = require("../UploadProjectTools");
|
|
4
|
+
const project_1 = require("../../../utils/project");
|
|
5
|
+
vi.mock('@modelcontextprotocol/sdk/server/mcp.js');
|
|
6
|
+
vi.mock('../../../utils/project');
|
|
7
|
+
vi.mock('../../../utils/toolUsageTracking');
|
|
8
|
+
const mockRunCommandInDir = project_1.runCommandInDir;
|
|
9
|
+
describe('mcp-server/tools/project/UploadProjectTools', () => {
|
|
10
|
+
let mockMcpServer;
|
|
11
|
+
let tool;
|
|
12
|
+
let mockRegisteredTool;
|
|
13
|
+
beforeEach(() => {
|
|
14
|
+
vi.clearAllMocks();
|
|
15
|
+
// @ts-expect-error noy mocking whole server
|
|
16
|
+
mockMcpServer = {
|
|
17
|
+
registerTool: vi.fn(),
|
|
18
|
+
};
|
|
19
|
+
mockRegisteredTool = {};
|
|
20
|
+
mockMcpServer.registerTool.mockReturnValue(mockRegisteredTool);
|
|
21
|
+
tool = new UploadProjectTools_1.UploadProjectTools(mockMcpServer);
|
|
22
|
+
});
|
|
23
|
+
describe('register', () => {
|
|
24
|
+
it('should register tool with correct parameters', () => {
|
|
25
|
+
const result = tool.register();
|
|
26
|
+
expect(mockMcpServer.registerTool).toHaveBeenCalledWith('upload-hubspot-project', {
|
|
27
|
+
title: 'Upload HubSpot Project',
|
|
28
|
+
description: expect.stringContaining('Uploads the HubSpot project in current working directory.'),
|
|
29
|
+
inputSchema: expect.any(Object),
|
|
30
|
+
}, tool.handler);
|
|
31
|
+
expect(result).toBe(mockRegisteredTool);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
describe('handler', () => {
|
|
35
|
+
const input = {
|
|
36
|
+
absoluteProjectPath: '/test/project',
|
|
37
|
+
};
|
|
38
|
+
it('should upload project successfully', async () => {
|
|
39
|
+
mockRunCommandInDir.mockResolvedValue({
|
|
40
|
+
stdout: 'Project uploaded successfully',
|
|
41
|
+
stderr: '',
|
|
42
|
+
});
|
|
43
|
+
const result = await tool.handler(input);
|
|
44
|
+
expect(mockRunCommandInDir).toHaveBeenCalledWith('/test/project', 'hs project upload --force-create');
|
|
45
|
+
expect(result).toEqual({
|
|
46
|
+
content: [
|
|
47
|
+
{ type: 'text', text: 'Project uploaded successfully' },
|
|
48
|
+
{ type: 'text', text: '' },
|
|
49
|
+
],
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
it('should handle upload with warnings', async () => {
|
|
53
|
+
mockRunCommandInDir.mockResolvedValue({
|
|
54
|
+
stdout: 'Project uploaded with warnings',
|
|
55
|
+
stderr: 'Warning: some files were ignored',
|
|
56
|
+
});
|
|
57
|
+
const result = await tool.handler(input);
|
|
58
|
+
expect(result.content).toEqual([
|
|
59
|
+
{ type: 'text', text: 'Project uploaded with warnings' },
|
|
60
|
+
{ type: 'text', text: 'Warning: some files were ignored' },
|
|
61
|
+
]);
|
|
62
|
+
});
|
|
63
|
+
it('should handle upload errors', async () => {
|
|
64
|
+
const error = new Error('Upload failed');
|
|
65
|
+
mockRunCommandInDir.mockRejectedValue(error);
|
|
66
|
+
await expect(tool.handler(input)).rejects.toThrow('Upload failed');
|
|
67
|
+
});
|
|
68
|
+
it('should use force-create flag', async () => {
|
|
69
|
+
mockRunCommandInDir.mockResolvedValue({
|
|
70
|
+
stdout: 'Project created and uploaded',
|
|
71
|
+
stderr: '',
|
|
72
|
+
});
|
|
73
|
+
await tool.handler(input);
|
|
74
|
+
expect(mockRunCommandInDir).toHaveBeenCalledWith('/test/project', 'hs project upload --force-create');
|
|
75
|
+
});
|
|
76
|
+
it('should handle empty stdout and stderr', async () => {
|
|
77
|
+
mockRunCommandInDir.mockResolvedValue({
|
|
78
|
+
stdout: '',
|
|
79
|
+
stderr: '',
|
|
80
|
+
});
|
|
81
|
+
const result = await tool.handler(input);
|
|
82
|
+
expect(result.content).toEqual([
|
|
83
|
+
{ type: 'text', text: '' },
|
|
84
|
+
{ type: 'text', text: '' },
|
|
85
|
+
]);
|
|
86
|
+
});
|
|
87
|
+
it('should work with different project paths', async () => {
|
|
88
|
+
mockRunCommandInDir.mockResolvedValue({
|
|
89
|
+
stdout: 'Upload complete',
|
|
90
|
+
stderr: '',
|
|
91
|
+
});
|
|
92
|
+
const differentInput = {
|
|
93
|
+
absoluteProjectPath: '/different/path/to/project',
|
|
94
|
+
};
|
|
95
|
+
await tool.handler(differentInput);
|
|
96
|
+
expect(mockRunCommandInDir).toHaveBeenCalledWith('/different/path/to/project', 'hs project upload --force-create');
|
|
97
|
+
});
|
|
98
|
+
it('should handle very long output', async () => {
|
|
99
|
+
const longOutput = 'A'.repeat(10000);
|
|
100
|
+
mockRunCommandInDir.mockResolvedValue({
|
|
101
|
+
stdout: longOutput,
|
|
102
|
+
stderr: 'Long stderr output',
|
|
103
|
+
});
|
|
104
|
+
const result = await tool.handler(input);
|
|
105
|
+
expect(result.content[0].text).toBe(longOutput);
|
|
106
|
+
expect(result.content[1].text).toBe('Long stderr output');
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const ValidateProjectTool_1 = require("../ValidateProjectTool");
|
|
4
|
+
const project_1 = require("../../../utils/project");
|
|
5
|
+
vi.mock('@modelcontextprotocol/sdk/server/mcp.js');
|
|
6
|
+
vi.mock('../../../utils/project');
|
|
7
|
+
vi.mock('../../../utils/toolUsageTracking');
|
|
8
|
+
const mockRunCommandInDir = project_1.runCommandInDir;
|
|
9
|
+
describe('mcp-server/tools/project/ValidateProjectTool', () => {
|
|
10
|
+
let mockMcpServer;
|
|
11
|
+
let tool;
|
|
12
|
+
let mockRegisteredTool;
|
|
13
|
+
beforeEach(() => {
|
|
14
|
+
vi.clearAllMocks();
|
|
15
|
+
// @ts-expect-error Not mocking the whole thing
|
|
16
|
+
mockMcpServer = {
|
|
17
|
+
registerTool: vi.fn(),
|
|
18
|
+
};
|
|
19
|
+
mockRegisteredTool = {};
|
|
20
|
+
mockMcpServer.registerTool.mockReturnValue(mockRegisteredTool);
|
|
21
|
+
tool = new ValidateProjectTool_1.ValidateProjectTool(mockMcpServer);
|
|
22
|
+
});
|
|
23
|
+
describe('register', () => {
|
|
24
|
+
it('should register tool with correct parameters', () => {
|
|
25
|
+
const result = tool.register();
|
|
26
|
+
expect(mockMcpServer.registerTool).toHaveBeenCalledWith('validate-hubspot-project', {
|
|
27
|
+
title: expect.stringContaining('Validate HubSpot Project'),
|
|
28
|
+
description: expect.stringContaining('Validates the HubSpot project and its configuration files.'),
|
|
29
|
+
inputSchema: expect.any(Object),
|
|
30
|
+
}, tool.handler);
|
|
31
|
+
expect(result).toBe(mockRegisteredTool);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
describe('handler', () => {
|
|
35
|
+
const input = {
|
|
36
|
+
absoluteProjectPath: '/test/project',
|
|
37
|
+
};
|
|
38
|
+
it('should validate project successfully', async () => {
|
|
39
|
+
mockRunCommandInDir.mockResolvedValue({
|
|
40
|
+
stdout: 'Project validation successful',
|
|
41
|
+
stderr: '',
|
|
42
|
+
});
|
|
43
|
+
const result = await tool.handler(input);
|
|
44
|
+
expect(mockRunCommandInDir).toHaveBeenCalledWith('/test/project', 'hs project validate');
|
|
45
|
+
expect(result).toEqual({
|
|
46
|
+
content: [
|
|
47
|
+
{ type: 'text', text: 'Project validation successful' },
|
|
48
|
+
{ type: 'text', text: '' },
|
|
49
|
+
],
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
it('should handle validation with warnings', async () => {
|
|
53
|
+
mockRunCommandInDir.mockResolvedValue({
|
|
54
|
+
stdout: 'Project is valid',
|
|
55
|
+
stderr: 'Warning: some files may need updates',
|
|
56
|
+
});
|
|
57
|
+
const result = await tool.handler(input);
|
|
58
|
+
expect(result.content).toEqual([
|
|
59
|
+
{ type: 'text', text: 'Project is valid' },
|
|
60
|
+
{ type: 'text', text: 'Warning: some files may need updates' },
|
|
61
|
+
]);
|
|
62
|
+
});
|
|
63
|
+
it('should handle validation errors', async () => {
|
|
64
|
+
const error = new Error('Validation failed');
|
|
65
|
+
mockRunCommandInDir.mockRejectedValue(error);
|
|
66
|
+
const result = await tool.handler(input);
|
|
67
|
+
expect(result).toEqual({
|
|
68
|
+
content: [{ type: 'text', text: 'Validation failed' }],
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
it('should handle non-Error rejection', async () => {
|
|
72
|
+
mockRunCommandInDir.mockRejectedValue('String error');
|
|
73
|
+
const result = await tool.handler(input);
|
|
74
|
+
expect(result).toEqual({
|
|
75
|
+
content: [{ type: 'text', text: 'String error' }],
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
it('should handle empty stdout and stderr', async () => {
|
|
79
|
+
mockRunCommandInDir.mockResolvedValue({
|
|
80
|
+
stdout: 'stdout',
|
|
81
|
+
stderr: 'stderr',
|
|
82
|
+
});
|
|
83
|
+
const result = await tool.handler(input);
|
|
84
|
+
expect(result.content).toEqual([
|
|
85
|
+
{ type: 'text', text: 'stdout' },
|
|
86
|
+
{ type: 'text', text: 'stderr' },
|
|
87
|
+
]);
|
|
88
|
+
});
|
|
89
|
+
it('should work with different project paths', async () => {
|
|
90
|
+
mockRunCommandInDir.mockResolvedValue({
|
|
91
|
+
stdout: 'Validation complete',
|
|
92
|
+
stderr: '',
|
|
93
|
+
});
|
|
94
|
+
const differentInput = {
|
|
95
|
+
absoluteProjectPath: '/different/path/to/project',
|
|
96
|
+
};
|
|
97
|
+
await tool.handler(differentInput);
|
|
98
|
+
expect(mockRunCommandInDir).toHaveBeenCalledWith('/different/path/to/project', 'hs project validate');
|
|
99
|
+
});
|
|
100
|
+
it('should handle validation errors with stderr', async () => {
|
|
101
|
+
mockRunCommandInDir.mockResolvedValue({
|
|
102
|
+
stdout: '',
|
|
103
|
+
stderr: 'Error: Missing required configuration file',
|
|
104
|
+
});
|
|
105
|
+
const result = await tool.handler(input);
|
|
106
|
+
expect(result.content).toEqual([
|
|
107
|
+
{ type: 'text', text: '' },
|
|
108
|
+
{ type: 'text', text: 'Error: Missing required configuration file' },
|
|
109
|
+
]);
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const command_1 = require("../command");
|
|
4
|
+
vi.mock('child_process');
|
|
5
|
+
vi.mock('util');
|
|
6
|
+
describe('mcp-server/utils/command', () => {
|
|
7
|
+
describe('addFlag', () => {
|
|
8
|
+
it('should add string flag to command', () => {
|
|
9
|
+
const result = (0, command_1.addFlag)('hs project create', 'name', 'test-project');
|
|
10
|
+
expect(result).toBe('hs project create --name "test-project"');
|
|
11
|
+
});
|
|
12
|
+
it('should add number flag to command', () => {
|
|
13
|
+
const result = (0, command_1.addFlag)('hs project deploy', 'build', 123);
|
|
14
|
+
expect(result).toBe('hs project deploy --build "123"');
|
|
15
|
+
});
|
|
16
|
+
it('should add boolean flag to command', () => {
|
|
17
|
+
const result = (0, command_1.addFlag)('hs project upload', 'watch', true);
|
|
18
|
+
expect(result).toBe('hs project upload --watch "true"');
|
|
19
|
+
});
|
|
20
|
+
it('should add array flag to command', () => {
|
|
21
|
+
const result = (0, command_1.addFlag)('hs project create', 'features', [
|
|
22
|
+
'card',
|
|
23
|
+
'settings',
|
|
24
|
+
]);
|
|
25
|
+
expect(result).toBe('hs project create --features "card" "settings"');
|
|
26
|
+
});
|
|
27
|
+
it('should handle empty array', () => {
|
|
28
|
+
const result = (0, command_1.addFlag)('hs project create', 'features', []);
|
|
29
|
+
expect(result).toBe('hs project create --features ');
|
|
30
|
+
});
|
|
31
|
+
it('should handle array with one item', () => {
|
|
32
|
+
const result = (0, command_1.addFlag)('hs project create', 'features', ['card']);
|
|
33
|
+
expect(result).toBe('hs project create --features "card"');
|
|
34
|
+
});
|
|
35
|
+
it('should handle special characters in string values', () => {
|
|
36
|
+
const result = (0, command_1.addFlag)('hs project create', 'name', 'my-project with spaces');
|
|
37
|
+
expect(result).toBe('hs project create --name "my-project with spaces"');
|
|
38
|
+
});
|
|
39
|
+
it('should handle special characters in array values', () => {
|
|
40
|
+
const result = (0, command_1.addFlag)('hs project create', 'features', [
|
|
41
|
+
'card with spaces',
|
|
42
|
+
'settings',
|
|
43
|
+
]);
|
|
44
|
+
expect(result).toBe('hs project create --features "card with spaces" "settings"');
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const project_1 = require("../project");
|
|
7
|
+
const command_1 = require("../command");
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
vi.mock('../command');
|
|
11
|
+
vi.mock('fs');
|
|
12
|
+
vi.mock('path');
|
|
13
|
+
const mockExecAsync = command_1.execAsync;
|
|
14
|
+
const mockExistsSync = fs_1.default.existsSync;
|
|
15
|
+
const mockMkdirSync = fs_1.default.mkdirSync;
|
|
16
|
+
const mockResolve = path_1.default.resolve;
|
|
17
|
+
describe('mcp-server/utils/project', () => {
|
|
18
|
+
beforeEach(() => {
|
|
19
|
+
vi.clearAllMocks();
|
|
20
|
+
});
|
|
21
|
+
describe('runCommandInDir', () => {
|
|
22
|
+
const mockDirectory = '/test/directory';
|
|
23
|
+
const mockCommand = 'npm install';
|
|
24
|
+
const mockResolvedPath = '/resolved/test/directory';
|
|
25
|
+
beforeEach(() => {
|
|
26
|
+
mockResolve.mockReturnValue(mockResolvedPath);
|
|
27
|
+
});
|
|
28
|
+
it('should run command in existing directory', async () => {
|
|
29
|
+
const expectedResult = {
|
|
30
|
+
stdout: 'command output',
|
|
31
|
+
stderr: '',
|
|
32
|
+
};
|
|
33
|
+
mockExistsSync.mockReturnValue(true);
|
|
34
|
+
mockExecAsync.mockResolvedValue(expectedResult);
|
|
35
|
+
const result = await (0, project_1.runCommandInDir)(mockDirectory, mockCommand);
|
|
36
|
+
expect(mockExistsSync).toHaveBeenCalledWith(mockDirectory);
|
|
37
|
+
expect(mockMkdirSync).not.toHaveBeenCalled();
|
|
38
|
+
expect(mockResolve).toHaveBeenCalledWith(mockDirectory);
|
|
39
|
+
expect(mockExecAsync).toHaveBeenCalledWith(mockCommand, expect.objectContaining({
|
|
40
|
+
cwd: mockResolvedPath,
|
|
41
|
+
env: expect.any(Object),
|
|
42
|
+
}));
|
|
43
|
+
expect(result).toEqual(expectedResult);
|
|
44
|
+
});
|
|
45
|
+
it('should create directory if it does not exist', async () => {
|
|
46
|
+
const expectedResult = {
|
|
47
|
+
stdout: 'command output',
|
|
48
|
+
stderr: '',
|
|
49
|
+
};
|
|
50
|
+
mockExistsSync.mockReturnValue(false);
|
|
51
|
+
mockExecAsync.mockResolvedValue(expectedResult);
|
|
52
|
+
const result = await (0, project_1.runCommandInDir)(mockDirectory, mockCommand);
|
|
53
|
+
expect(mockExistsSync).toHaveBeenCalledWith(mockDirectory);
|
|
54
|
+
expect(mockMkdirSync).toHaveBeenCalledWith(mockDirectory);
|
|
55
|
+
expect(mockResolve).toHaveBeenCalledWith(mockDirectory);
|
|
56
|
+
expect(mockExecAsync).toHaveBeenCalledWith(mockCommand, expect.objectContaining({
|
|
57
|
+
cwd: mockResolvedPath,
|
|
58
|
+
env: expect.any(Object),
|
|
59
|
+
}));
|
|
60
|
+
expect(result).toEqual(expectedResult);
|
|
61
|
+
});
|
|
62
|
+
it('should propagate execAsync errors', async () => {
|
|
63
|
+
const error = new Error('Command failed');
|
|
64
|
+
mockExistsSync.mockReturnValue(true);
|
|
65
|
+
mockExecAsync.mockRejectedValue(error);
|
|
66
|
+
await expect((0, project_1.runCommandInDir)(mockDirectory, mockCommand)).rejects.toThrow('Command failed');
|
|
67
|
+
expect(mockExecAsync).toHaveBeenCalledWith(mockCommand, expect.objectContaining({
|
|
68
|
+
cwd: mockResolvedPath,
|
|
69
|
+
env: expect.any(Object),
|
|
70
|
+
}));
|
|
71
|
+
});
|
|
72
|
+
it('should handle stderr in results', async () => {
|
|
73
|
+
const expectedResult = {
|
|
74
|
+
stdout: 'some output',
|
|
75
|
+
stderr: 'warning message',
|
|
76
|
+
};
|
|
77
|
+
mockExistsSync.mockReturnValue(true);
|
|
78
|
+
mockExecAsync.mockResolvedValue(expectedResult);
|
|
79
|
+
const result = await (0, project_1.runCommandInDir)(mockDirectory, mockCommand);
|
|
80
|
+
expect(result.stdout).toBe('some output');
|
|
81
|
+
expect(result.stderr).toBe('warning message');
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
});
|
|
@@ -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,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/cli",
|
|
3
|
-
"version": "7.6.0-beta.
|
|
3
|
+
"version": "7.6.0-beta.4",
|
|
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.
|
|
9
|
-
"@hubspot/project-parsing-lib": "0.5.
|
|
8
|
+
"@hubspot/local-dev-lib": "3.13.1",
|
|
9
|
+
"@hubspot/project-parsing-lib": "0.5.2",
|
|
10
10
|
"@hubspot/serverless-dev-runtime": "7.0.6",
|
|
11
11
|
"@hubspot/theme-preview-dev-server": "0.0.10",
|
|
12
12
|
"@hubspot/ui-extensions-dev-server": "0.9.2",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"express": "4.21.2",
|
|
20
20
|
"findup-sync": "4.0.0",
|
|
21
21
|
"fs-extra": "8.1.0",
|
|
22
|
-
"inquirer": "
|
|
22
|
+
"inquirer": "12.7.0",
|
|
23
23
|
"js-yaml": "4.1.0",
|
|
24
24
|
"moment": "2.30.1",
|
|
25
25
|
"open": "7.4.2",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"@types/express": "^5.0.0",
|
|
39
39
|
"@types/findup-sync": "^4.0.5",
|
|
40
40
|
"@types/fs-extra": "^11.0.4",
|
|
41
|
-
"@types/jest": "^29.5.14",
|
|
42
41
|
"@types/js-yaml": "^4.0.9",
|
|
42
|
+
"@types/node": "^24.1.0",
|
|
43
43
|
"@types/semver": "^7.5.8",
|
|
44
44
|
"@types/tmp": "^0.2.6",
|
|
45
45
|
"@types/ws": "^8.18.1",
|
|
@@ -50,15 +50,14 @@
|
|
|
50
50
|
"eslint": "^8.56.0",
|
|
51
51
|
"eslint-plugin-import": "^2.31.0",
|
|
52
52
|
"husky": "^4.3.8",
|
|
53
|
-
"jest": "^29.5.0",
|
|
54
53
|
"lint-staged": "^10.5.4",
|
|
55
54
|
"madge": "^8.0.0",
|
|
56
55
|
"mock-stdin": "^1.0.0",
|
|
57
56
|
"prettier": "^3.4.2",
|
|
58
57
|
"semver": "^7.6.3",
|
|
59
|
-
"ts-jest": "^29.2.5",
|
|
60
58
|
"ts-node": "^10.9.2",
|
|
61
|
-
"typescript": "^5.6.2"
|
|
59
|
+
"typescript": "^5.6.2",
|
|
60
|
+
"vitest": "^2.1.9"
|
|
62
61
|
},
|
|
63
62
|
"optionalDependencies": {
|
|
64
63
|
"@hubspot/cms-dev-server": "^1.0.9",
|
|
@@ -78,7 +77,8 @@
|
|
|
78
77
|
"mcp-local": "yarn ts-node ./scripts/mcp-local.ts",
|
|
79
78
|
"prettier:write": "prettier --write './**/*.{ts,js,json}'",
|
|
80
79
|
"release": "yarn ts-node ./scripts/release.ts release",
|
|
81
|
-
"test": "
|
|
80
|
+
"test": "vitest run",
|
|
81
|
+
"test-dev": "vitest",
|
|
82
82
|
"test-cli": "yarn build && yarn --cwd 'acceptance-tests' test-ci",
|
|
83
83
|
"test-cli-debug": "yarn build && yarn --cwd 'acceptance-tests' test-debug",
|
|
84
84
|
"test-cli-latest": "yarn build && yarn build-docker && docker container run -it --rm --name=hs-cli-container hs-cli-image yarn --cwd 'acceptance-tests' test-latest",
|
package/types/Prompts.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Separator } from '@inquirer/prompts';
|
|
1
2
|
export type GenericPromptResponse = {
|
|
2
3
|
[key: string]: any;
|
|
3
4
|
};
|
|
@@ -6,9 +7,10 @@ export type PromptChoices<T = any> = Array<string | {
|
|
|
6
7
|
name: string;
|
|
7
8
|
value?: T;
|
|
8
9
|
disabled?: string | boolean;
|
|
9
|
-
|
|
10
|
+
checked?: boolean;
|
|
11
|
+
} | Separator>;
|
|
10
12
|
export type PromptWhen = boolean | (() => boolean);
|
|
11
|
-
type PromptOperand = string | number | boolean | string[] | boolean[] | null;
|
|
13
|
+
export type PromptOperand = string | number | boolean | string[] | boolean[] | null;
|
|
12
14
|
export type PromptConfig<T extends GenericPromptResponse> = {
|
|
13
15
|
name: keyof T;
|
|
14
16
|
type?: PromptType;
|