@hubspot/cli 7.7.19-experimental.3 → 7.7.20-experimental.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/__tests__/migrate.test.d.ts +1 -0
- package/api/__tests__/migrate.test.js +183 -0
- 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/app.js +1 -6
- 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/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/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 +344 -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/dev/unifiedFlow.js +1 -1
- 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 +40 -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 +24 -14
- 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 +6 -65
- package/lang/en.js +6 -65
- 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 +171 -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/buildAccount.d.ts +1 -7
- package/lib/buildAccount.js +4 -54
- 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/mcp/setup.js +18 -2
- 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/localDev/DevServerManager.js +0 -1
- package/lib/projects/localDev/helpers.d.ts +1 -1
- package/lib/projects/localDev/helpers.js +2 -2
- package/lib/projects/structure.d.ts +2 -2
- package/lib/projects/upload.d.ts +1 -2
- package/lib/projects/upload.js +0 -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 +43 -81
- package/lib/schema.js +5 -1
- package/lib/ui/SpinniesManager.js +0 -1
- package/lib/ui/supportHyperlinks.js +2 -2
- package/lib/ui/supportsColor.js +2 -2
- 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/__tests__/AddFeatureToProject.test.d.ts +1 -0
- package/mcp-server/tools/project/__tests__/AddFeatureToProject.test.js +152 -0
- package/mcp-server/tools/project/__tests__/CreateProjectTool.test.d.ts +1 -0
- package/mcp-server/tools/project/__tests__/CreateProjectTool.test.js +129 -0
- package/mcp-server/tools/project/__tests__/DeployProject.test.d.ts +1 -0
- package/mcp-server/tools/project/__tests__/DeployProject.test.js +120 -0
- package/mcp-server/tools/project/__tests__/GuidedWalkthroughTool.test.d.ts +1 -0
- package/mcp-server/tools/project/__tests__/GuidedWalkthroughTool.test.js +127 -0
- package/mcp-server/tools/project/__tests__/UploadProjectTools.test.d.ts +1 -0
- package/mcp-server/tools/project/__tests__/UploadProjectTools.test.js +108 -0
- package/mcp-server/tools/project/__tests__/ValidateProjectTool.test.d.ts +1 -0
- package/mcp-server/tools/project/__tests__/ValidateProjectTool.test.js +111 -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 +81 -0
- package/package.json +8 -8
- package/commands/app/install.d.ts +0 -8
- package/commands/app/install.js +0 -127
|
@@ -0,0 +1,108 @@
|
|
|
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
|
+
const mockRunCommandInDir = project_1.runCommandInDir;
|
|
8
|
+
describe('mcp-server/tools/project/UploadProjectTools', () => {
|
|
9
|
+
let mockMcpServer;
|
|
10
|
+
let tool;
|
|
11
|
+
let mockRegisteredTool;
|
|
12
|
+
beforeEach(() => {
|
|
13
|
+
vi.clearAllMocks();
|
|
14
|
+
// @ts-expect-error noy mocking whole server
|
|
15
|
+
mockMcpServer = {
|
|
16
|
+
registerTool: vi.fn(),
|
|
17
|
+
};
|
|
18
|
+
mockRegisteredTool = {};
|
|
19
|
+
mockMcpServer.registerTool.mockReturnValue(mockRegisteredTool);
|
|
20
|
+
tool = new UploadProjectTools_1.UploadProjectTools(mockMcpServer);
|
|
21
|
+
});
|
|
22
|
+
describe('register', () => {
|
|
23
|
+
it('should register tool with correct parameters', () => {
|
|
24
|
+
const result = tool.register();
|
|
25
|
+
expect(mockMcpServer.registerTool).toHaveBeenCalledWith('upload-hubspot-project', {
|
|
26
|
+
title: 'Upload HubSpot Project',
|
|
27
|
+
description: expect.stringContaining('Uploads the HubSpot project in current working directory.'),
|
|
28
|
+
inputSchema: expect.any(Object),
|
|
29
|
+
}, tool.handler);
|
|
30
|
+
expect(result).toBe(mockRegisteredTool);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
describe('handler', () => {
|
|
34
|
+
const input = {
|
|
35
|
+
absoluteProjectPath: '/test/project',
|
|
36
|
+
};
|
|
37
|
+
it('should upload project successfully', async () => {
|
|
38
|
+
mockRunCommandInDir.mockResolvedValue({
|
|
39
|
+
stdout: 'Project uploaded successfully',
|
|
40
|
+
stderr: '',
|
|
41
|
+
});
|
|
42
|
+
const result = await tool.handler(input);
|
|
43
|
+
expect(mockRunCommandInDir).toHaveBeenCalledWith('/test/project', 'hs project upload --force-create');
|
|
44
|
+
expect(result).toEqual({
|
|
45
|
+
content: [
|
|
46
|
+
{ type: 'text', text: 'Project uploaded successfully' },
|
|
47
|
+
{ type: 'text', text: '' },
|
|
48
|
+
],
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
it('should handle upload with warnings', async () => {
|
|
52
|
+
mockRunCommandInDir.mockResolvedValue({
|
|
53
|
+
stdout: 'Project uploaded with warnings',
|
|
54
|
+
stderr: 'Warning: some files were ignored',
|
|
55
|
+
});
|
|
56
|
+
const result = await tool.handler(input);
|
|
57
|
+
expect(result.content).toEqual([
|
|
58
|
+
{ type: 'text', text: 'Project uploaded with warnings' },
|
|
59
|
+
{ type: 'text', text: 'Warning: some files were ignored' },
|
|
60
|
+
]);
|
|
61
|
+
});
|
|
62
|
+
it('should handle upload errors', async () => {
|
|
63
|
+
const error = new Error('Upload failed');
|
|
64
|
+
mockRunCommandInDir.mockRejectedValue(error);
|
|
65
|
+
await expect(tool.handler(input)).rejects.toThrow('Upload failed');
|
|
66
|
+
});
|
|
67
|
+
it('should use force-create flag', async () => {
|
|
68
|
+
mockRunCommandInDir.mockResolvedValue({
|
|
69
|
+
stdout: 'Project created and uploaded',
|
|
70
|
+
stderr: '',
|
|
71
|
+
});
|
|
72
|
+
await tool.handler(input);
|
|
73
|
+
expect(mockRunCommandInDir).toHaveBeenCalledWith('/test/project', 'hs project upload --force-create');
|
|
74
|
+
});
|
|
75
|
+
it('should handle empty stdout and stderr', async () => {
|
|
76
|
+
mockRunCommandInDir.mockResolvedValue({
|
|
77
|
+
stdout: '',
|
|
78
|
+
stderr: '',
|
|
79
|
+
});
|
|
80
|
+
const result = await tool.handler(input);
|
|
81
|
+
expect(result.content).toEqual([
|
|
82
|
+
{ type: 'text', text: '' },
|
|
83
|
+
{ type: 'text', text: '' },
|
|
84
|
+
]);
|
|
85
|
+
});
|
|
86
|
+
it('should work with different project paths', async () => {
|
|
87
|
+
mockRunCommandInDir.mockResolvedValue({
|
|
88
|
+
stdout: 'Upload complete',
|
|
89
|
+
stderr: '',
|
|
90
|
+
});
|
|
91
|
+
const differentInput = {
|
|
92
|
+
absoluteProjectPath: '/different/path/to/project',
|
|
93
|
+
};
|
|
94
|
+
await tool.handler(differentInput);
|
|
95
|
+
expect(mockRunCommandInDir).toHaveBeenCalledWith('/different/path/to/project', 'hs project upload --force-create');
|
|
96
|
+
});
|
|
97
|
+
it('should handle very long output', async () => {
|
|
98
|
+
const longOutput = 'A'.repeat(10000);
|
|
99
|
+
mockRunCommandInDir.mockResolvedValue({
|
|
100
|
+
stdout: longOutput,
|
|
101
|
+
stderr: 'Long stderr output',
|
|
102
|
+
});
|
|
103
|
+
const result = await tool.handler(input);
|
|
104
|
+
expect(result.content[0].text).toBe(longOutput);
|
|
105
|
+
expect(result.content[1].text).toBe('Long stderr output');
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,111 @@
|
|
|
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
|
+
const mockRunCommandInDir = project_1.runCommandInDir;
|
|
8
|
+
describe('mcp-server/tools/project/ValidateProjectTool', () => {
|
|
9
|
+
let mockMcpServer;
|
|
10
|
+
let tool;
|
|
11
|
+
let mockRegisteredTool;
|
|
12
|
+
beforeEach(() => {
|
|
13
|
+
vi.clearAllMocks();
|
|
14
|
+
// @ts-expect-error Not mocking the whole thing
|
|
15
|
+
mockMcpServer = {
|
|
16
|
+
registerTool: vi.fn(),
|
|
17
|
+
};
|
|
18
|
+
mockRegisteredTool = {};
|
|
19
|
+
mockMcpServer.registerTool.mockReturnValue(mockRegisteredTool);
|
|
20
|
+
tool = new ValidateProjectTool_1.ValidateProjectTool(mockMcpServer);
|
|
21
|
+
});
|
|
22
|
+
describe('register', () => {
|
|
23
|
+
it('should register tool with correct parameters', () => {
|
|
24
|
+
const result = tool.register();
|
|
25
|
+
expect(mockMcpServer.registerTool).toHaveBeenCalledWith('validate-hubspot-project', {
|
|
26
|
+
title: expect.stringContaining('Validate HubSpot Project'),
|
|
27
|
+
description: expect.stringContaining('Validates the HubSpot project and its configuration files.'),
|
|
28
|
+
inputSchema: expect.any(Object),
|
|
29
|
+
}, tool.handler);
|
|
30
|
+
expect(result).toBe(mockRegisteredTool);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
describe('handler', () => {
|
|
34
|
+
const input = {
|
|
35
|
+
absoluteProjectPath: '/test/project',
|
|
36
|
+
};
|
|
37
|
+
it('should validate project successfully', async () => {
|
|
38
|
+
mockRunCommandInDir.mockResolvedValue({
|
|
39
|
+
stdout: 'Project validation successful',
|
|
40
|
+
stderr: '',
|
|
41
|
+
});
|
|
42
|
+
const result = await tool.handler(input);
|
|
43
|
+
expect(mockRunCommandInDir).toHaveBeenCalledWith('/test/project', 'hs project validate');
|
|
44
|
+
expect(result).toEqual({
|
|
45
|
+
content: [
|
|
46
|
+
{ type: 'text', text: 'Project validation successful' },
|
|
47
|
+
{ type: 'text', text: '' },
|
|
48
|
+
],
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
it('should handle validation with warnings', async () => {
|
|
52
|
+
mockRunCommandInDir.mockResolvedValue({
|
|
53
|
+
stdout: 'Project is valid',
|
|
54
|
+
stderr: 'Warning: some files may need updates',
|
|
55
|
+
});
|
|
56
|
+
const result = await tool.handler(input);
|
|
57
|
+
expect(result.content).toEqual([
|
|
58
|
+
{ type: 'text', text: 'Project is valid' },
|
|
59
|
+
{ type: 'text', text: 'Warning: some files may need updates' },
|
|
60
|
+
]);
|
|
61
|
+
});
|
|
62
|
+
it('should handle validation errors', async () => {
|
|
63
|
+
const error = new Error('Validation failed');
|
|
64
|
+
mockRunCommandInDir.mockRejectedValue(error);
|
|
65
|
+
const result = await tool.handler(input);
|
|
66
|
+
expect(result).toEqual({
|
|
67
|
+
content: [{ type: 'text', text: 'Validation failed' }],
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
it('should handle non-Error rejection', async () => {
|
|
71
|
+
mockRunCommandInDir.mockRejectedValue('String error');
|
|
72
|
+
const result = await tool.handler(input);
|
|
73
|
+
expect(result).toEqual({
|
|
74
|
+
content: [{ type: 'text', text: 'String error' }],
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
it('should handle empty stdout and stderr', async () => {
|
|
78
|
+
mockRunCommandInDir.mockResolvedValue({
|
|
79
|
+
stdout: 'stdout',
|
|
80
|
+
stderr: 'stderr',
|
|
81
|
+
});
|
|
82
|
+
const result = await tool.handler(input);
|
|
83
|
+
expect(result.content).toEqual([
|
|
84
|
+
{ type: 'text', text: 'stdout' },
|
|
85
|
+
{ type: 'text', text: 'stderr' },
|
|
86
|
+
]);
|
|
87
|
+
});
|
|
88
|
+
it('should work with different project paths', async () => {
|
|
89
|
+
mockRunCommandInDir.mockResolvedValue({
|
|
90
|
+
stdout: 'Validation complete',
|
|
91
|
+
stderr: '',
|
|
92
|
+
});
|
|
93
|
+
const differentInput = {
|
|
94
|
+
absoluteProjectPath: '/different/path/to/project',
|
|
95
|
+
};
|
|
96
|
+
await tool.handler(differentInput);
|
|
97
|
+
expect(mockRunCommandInDir).toHaveBeenCalledWith('/different/path/to/project', 'hs project validate');
|
|
98
|
+
});
|
|
99
|
+
it('should handle validation errors with stderr', async () => {
|
|
100
|
+
mockRunCommandInDir.mockResolvedValue({
|
|
101
|
+
stdout: '',
|
|
102
|
+
stderr: 'Error: Missing required configuration file',
|
|
103
|
+
});
|
|
104
|
+
const result = await tool.handler(input);
|
|
105
|
+
expect(result.content).toEqual([
|
|
106
|
+
{ type: 'text', text: '' },
|
|
107
|
+
{ type: 'text', text: 'Error: Missing required configuration file' },
|
|
108
|
+
]);
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
});
|
|
@@ -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,81 @@
|
|
|
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, {
|
|
40
|
+
cwd: mockResolvedPath,
|
|
41
|
+
});
|
|
42
|
+
expect(result).toEqual(expectedResult);
|
|
43
|
+
});
|
|
44
|
+
it('should create directory if it does not exist', async () => {
|
|
45
|
+
const expectedResult = {
|
|
46
|
+
stdout: 'command output',
|
|
47
|
+
stderr: '',
|
|
48
|
+
};
|
|
49
|
+
mockExistsSync.mockReturnValue(false);
|
|
50
|
+
mockExecAsync.mockResolvedValue(expectedResult);
|
|
51
|
+
const result = await (0, project_1.runCommandInDir)(mockDirectory, mockCommand);
|
|
52
|
+
expect(mockExistsSync).toHaveBeenCalledWith(mockDirectory);
|
|
53
|
+
expect(mockMkdirSync).toHaveBeenCalledWith(mockDirectory);
|
|
54
|
+
expect(mockResolve).toHaveBeenCalledWith(mockDirectory);
|
|
55
|
+
expect(mockExecAsync).toHaveBeenCalledWith(mockCommand, {
|
|
56
|
+
cwd: mockResolvedPath,
|
|
57
|
+
});
|
|
58
|
+
expect(result).toEqual(expectedResult);
|
|
59
|
+
});
|
|
60
|
+
it('should propagate execAsync errors', async () => {
|
|
61
|
+
const error = new Error('Command failed');
|
|
62
|
+
mockExistsSync.mockReturnValue(true);
|
|
63
|
+
mockExecAsync.mockRejectedValue(error);
|
|
64
|
+
await expect((0, project_1.runCommandInDir)(mockDirectory, mockCommand)).rejects.toThrow('Command failed');
|
|
65
|
+
expect(mockExecAsync).toHaveBeenCalledWith(mockCommand, {
|
|
66
|
+
cwd: mockResolvedPath,
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
it('should handle stderr in results', async () => {
|
|
70
|
+
const expectedResult = {
|
|
71
|
+
stdout: 'some output',
|
|
72
|
+
stderr: 'warning message',
|
|
73
|
+
};
|
|
74
|
+
mockExistsSync.mockReturnValue(true);
|
|
75
|
+
mockExecAsync.mockResolvedValue(expectedResult);
|
|
76
|
+
const result = await (0, project_1.runCommandInDir)(mockDirectory, mockCommand);
|
|
77
|
+
expect(result.stdout).toBe('some output');
|
|
78
|
+
expect(result.stderr).toBe('warning message');
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
});
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/cli",
|
|
3
|
-
"version": "7.7.
|
|
3
|
+
"version": "7.7.20-experimental.0",
|
|
4
4
|
"description": "The official CLI for developing on HubSpot",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": "https://github.com/HubSpot/hubspot-cli",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@hubspot/local-dev-lib": "3.
|
|
9
|
-
"@hubspot/project-parsing-lib": "0.
|
|
8
|
+
"@hubspot/local-dev-lib": "3.12.0",
|
|
9
|
+
"@hubspot/project-parsing-lib": "0.0.21-experimental.0",
|
|
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",
|
|
@@ -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",
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { CommonArgs, ConfigArgs, AccountArgs, EnvironmentArgs, YargsCommandModule, JSONOutputArgs } from '../../types/Yargs';
|
|
2
|
-
type InstallAppArgs = CommonArgs & ConfigArgs & AccountArgs & EnvironmentArgs & JSONOutputArgs & {
|
|
3
|
-
appUid?: string;
|
|
4
|
-
projectName?: string;
|
|
5
|
-
testAccountId: number;
|
|
6
|
-
};
|
|
7
|
-
declare const installAppCommand: YargsCommandModule<unknown, InstallAppArgs>;
|
|
8
|
-
export default installAppCommand;
|
package/commands/app/install.js
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
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 developerTestAccounts_1 = require("@hubspot/local-dev-lib/api/developerTestAccounts");
|
|
7
|
-
const usageTracking_1 = require("../../lib/usageTracking");
|
|
8
|
-
const en_1 = require("../../lang/en");
|
|
9
|
-
const exitCodes_1 = require("../../lib/enums/exitCodes");
|
|
10
|
-
const yargsUtils_1 = require("../../lib/yargsUtils");
|
|
11
|
-
const constants_1 = require("../../lib/constants");
|
|
12
|
-
const logger_1 = require("../../lib/ui/logger");
|
|
13
|
-
const SpinniesManager_1 = __importDefault(require("../../lib/ui/SpinniesManager"));
|
|
14
|
-
const errorHandlers_1 = require("../../lib/errorHandlers");
|
|
15
|
-
const polling_1 = require("../../lib/polling");
|
|
16
|
-
const config_1 = require("../../lib/projects/config");
|
|
17
|
-
const upload_1 = require("../../lib/projects/upload");
|
|
18
|
-
const structure_1 = require("../../lib/projects/structure");
|
|
19
|
-
const command = 'install <test-account-id>';
|
|
20
|
-
const describe = undefined; // commands.app.subcommands.install.describe;
|
|
21
|
-
async function handler(args) {
|
|
22
|
-
const { derivedAccountId, appUid, projectName, testAccountId, formatOutputAsJson, } = args;
|
|
23
|
-
(0, usageTracking_1.trackCommandUsage)('app-install', {}, derivedAccountId);
|
|
24
|
-
const jsonOutput = {};
|
|
25
|
-
let targetProjectName = projectName;
|
|
26
|
-
let targetAppUid = appUid;
|
|
27
|
-
const { projectConfig, projectDir } = await (0, config_1.getProjectConfig)();
|
|
28
|
-
if (!targetProjectName) {
|
|
29
|
-
(0, config_1.validateProjectConfig)(projectConfig, projectDir);
|
|
30
|
-
targetProjectName = projectConfig?.name;
|
|
31
|
-
}
|
|
32
|
-
if (!targetProjectName) {
|
|
33
|
-
logger_1.uiLogger.error(en_1.commands.app.subcommands.install.errors.mustSpecifyProjectName);
|
|
34
|
-
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
35
|
-
}
|
|
36
|
-
let isAppOauth = true;
|
|
37
|
-
if (!targetAppUid) {
|
|
38
|
-
const intermediateRepresentation = await (0, upload_1.handleTranslate)(projectDir, projectConfig, derivedAccountId, true, undefined);
|
|
39
|
-
if (intermediateRepresentation) {
|
|
40
|
-
Object.values(intermediateRepresentation.intermediateNodesIndexedByUid).forEach(node => {
|
|
41
|
-
if ((0, structure_1.isAppIRNode)(node)) {
|
|
42
|
-
targetAppUid = node.uid;
|
|
43
|
-
isAppOauth = node.config.auth.type === constants_1.APP_AUTH_TYPES.OAUTH;
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
if (!targetAppUid) {
|
|
49
|
-
logger_1.uiLogger.error(en_1.commands.app.subcommands.install.errors.noAppUidFound);
|
|
50
|
-
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
51
|
-
}
|
|
52
|
-
if (!isAppOauth) {
|
|
53
|
-
logger_1.uiLogger.error(en_1.commands.app.subcommands.install.errors.appMustBeOauth);
|
|
54
|
-
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
55
|
-
}
|
|
56
|
-
try {
|
|
57
|
-
const { data } = await (0, developerTestAccounts_1.installOauthAppIntoDeveloperTestAccount)(derivedAccountId, testAccountId, targetProjectName, targetAppUid);
|
|
58
|
-
if (data?.authCodes.length > 0) {
|
|
59
|
-
jsonOutput.authCode = data.authCodes[0].authCode;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
catch (err) {
|
|
63
|
-
(0, errorHandlers_1.logError)(err);
|
|
64
|
-
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
65
|
-
}
|
|
66
|
-
SpinniesManager_1.default.init({
|
|
67
|
-
succeedColor: 'white',
|
|
68
|
-
});
|
|
69
|
-
SpinniesManager_1.default.add('installApp', {
|
|
70
|
-
text: en_1.commands.app.subcommands.install.polling.start,
|
|
71
|
-
});
|
|
72
|
-
let appInstallSucceeded = false;
|
|
73
|
-
try {
|
|
74
|
-
await (0, polling_1.poll)(() => (0, developerTestAccounts_1.fetchDeveloperTestAccountOauthAppInstallStatus)(derivedAccountId, targetProjectName, targetAppUid), {
|
|
75
|
-
successStates: ['SUCCESS'],
|
|
76
|
-
errorStates: [],
|
|
77
|
-
});
|
|
78
|
-
appInstallSucceeded = true;
|
|
79
|
-
}
|
|
80
|
-
catch (err) {
|
|
81
|
-
SpinniesManager_1.default.fail('installApp');
|
|
82
|
-
(0, errorHandlers_1.logError)(err);
|
|
83
|
-
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
84
|
-
}
|
|
85
|
-
if (!appInstallSucceeded) {
|
|
86
|
-
SpinniesManager_1.default.fail('installApp');
|
|
87
|
-
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
88
|
-
}
|
|
89
|
-
SpinniesManager_1.default.succeed('installApp', {
|
|
90
|
-
text: en_1.commands.app.subcommands.install.polling.success,
|
|
91
|
-
});
|
|
92
|
-
if (formatOutputAsJson) {
|
|
93
|
-
logger_1.uiLogger.json(jsonOutput);
|
|
94
|
-
}
|
|
95
|
-
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
96
|
-
}
|
|
97
|
-
function installAppBuilder(yargs) {
|
|
98
|
-
yargs.positional('test-account-id', {
|
|
99
|
-
describe: en_1.commands.app.subcommands.install.positionals.testAccountId,
|
|
100
|
-
required: true,
|
|
101
|
-
type: 'number',
|
|
102
|
-
});
|
|
103
|
-
yargs.option('app-uid', {
|
|
104
|
-
describe: en_1.commands.app.subcommands.install.options.appUid,
|
|
105
|
-
type: 'string',
|
|
106
|
-
});
|
|
107
|
-
yargs.option('project-name', {
|
|
108
|
-
describe: en_1.commands.app.subcommands.install.options.projectName,
|
|
109
|
-
type: 'string',
|
|
110
|
-
});
|
|
111
|
-
yargs.example('install 1234567890 --app-uid=my-app-uid --project-name=my-project', en_1.commands.app.subcommands.install.example);
|
|
112
|
-
return yargs;
|
|
113
|
-
}
|
|
114
|
-
const builder = (0, yargsUtils_1.makeYargsBuilder)(installAppBuilder, command, en_1.commands.app.subcommands.install.describe, {
|
|
115
|
-
useGlobalOptions: true,
|
|
116
|
-
useAccountOptions: true,
|
|
117
|
-
useConfigOptions: true,
|
|
118
|
-
useEnvironmentOptions: true,
|
|
119
|
-
useJSONOutputOptions: true,
|
|
120
|
-
});
|
|
121
|
-
const installAppCommand = {
|
|
122
|
-
command,
|
|
123
|
-
describe,
|
|
124
|
-
handler,
|
|
125
|
-
builder,
|
|
126
|
-
};
|
|
127
|
-
exports.default = installAppCommand;
|