@hubspot/cli 7.7.19-experimental.2 → 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 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const http_1 = require("@hubspot/local-dev-lib/http");
|
|
4
|
+
const Migration_1 = require("@hubspot/local-dev-lib/types/Migration");
|
|
5
|
+
const migrate_1 = require("../migrate");
|
|
6
|
+
vi.mock('@hubspot/local-dev-lib/http');
|
|
7
|
+
const httpMock = http_1.http;
|
|
8
|
+
describe('api/migrate', () => {
|
|
9
|
+
const mockAccountId = 12345;
|
|
10
|
+
const mockPortalId = 12345;
|
|
11
|
+
const mockAppId = 67890;
|
|
12
|
+
const mockMigrationId = 54321;
|
|
13
|
+
const mockPlatformVersion = '2025.2';
|
|
14
|
+
const convertedPlatformVersion = 'V2025_2';
|
|
15
|
+
const mockProjectName = 'Test Project';
|
|
16
|
+
const mockComponentUids = { 'component-1': 'uid-1', 'component-2': 'uid-2' };
|
|
17
|
+
describe('listAppsForMigration', () => {
|
|
18
|
+
it('should call http.get with correct parameters', async () => {
|
|
19
|
+
const mockResponse = {
|
|
20
|
+
migratableApps: [
|
|
21
|
+
{
|
|
22
|
+
appId: 1,
|
|
23
|
+
appName: 'App 1',
|
|
24
|
+
isMigratable: true,
|
|
25
|
+
migrationComponents: [
|
|
26
|
+
{ id: 'comp1', componentType: 'type1', isSupported: true },
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
unmigratableApps: [
|
|
31
|
+
{
|
|
32
|
+
appId: 2,
|
|
33
|
+
appName: 'App 2',
|
|
34
|
+
isMigratable: false,
|
|
35
|
+
unmigratableReason: 'UP_TO_DATE',
|
|
36
|
+
migrationComponents: [
|
|
37
|
+
{ id: 'comp2', componentType: 'type2', isSupported: false },
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
};
|
|
42
|
+
// @ts-expect-error Mock
|
|
43
|
+
httpMock.get.mockResolvedValue(mockResponse);
|
|
44
|
+
const result = await (0, migrate_1.listAppsForMigration)(mockAccountId, mockPlatformVersion);
|
|
45
|
+
expect(http_1.http.get).toHaveBeenCalledWith(mockAccountId, {
|
|
46
|
+
url: 'dfs/migrations/v2/list-apps',
|
|
47
|
+
params: {
|
|
48
|
+
platformVersion: convertedPlatformVersion,
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
expect(result).toEqual(mockResponse);
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
describe('initializeMigration', () => {
|
|
55
|
+
it('should call http.post with correct parameters', async () => {
|
|
56
|
+
const mockResponse = { migrationId: mockMigrationId };
|
|
57
|
+
// @ts-expect-error Mock
|
|
58
|
+
httpMock.post.mockResolvedValue(mockResponse);
|
|
59
|
+
const result = await (0, migrate_1.initializeMigration)(mockAccountId, mockAppId, mockPlatformVersion);
|
|
60
|
+
expect(http_1.http.post).toHaveBeenCalledWith(mockAccountId, {
|
|
61
|
+
url: 'dfs/migrations/v2/migrations',
|
|
62
|
+
data: {
|
|
63
|
+
applicationId: mockAppId,
|
|
64
|
+
platformVersion: convertedPlatformVersion,
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
expect(result).toEqual(mockResponse);
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
describe('continueMigration', () => {
|
|
71
|
+
it('should call http.post with correct parameters', async () => {
|
|
72
|
+
const mockResponse = { migrationId: mockMigrationId };
|
|
73
|
+
// @ts-expect-error Mock
|
|
74
|
+
httpMock.post.mockResolvedValue(mockResponse);
|
|
75
|
+
const result = await (0, migrate_1.continueMigration)(mockPortalId, mockMigrationId, mockComponentUids, mockProjectName);
|
|
76
|
+
expect(http_1.http.post).toHaveBeenCalledWith(mockPortalId, {
|
|
77
|
+
url: 'dfs/migrations/v2/migrations/continue',
|
|
78
|
+
data: {
|
|
79
|
+
migrationId: mockMigrationId,
|
|
80
|
+
projectName: mockProjectName,
|
|
81
|
+
componentUids: mockComponentUids,
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
expect(result).toEqual(mockResponse);
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
describe('checkMigrationStatusV2', () => {
|
|
88
|
+
it('should call http.get with correct parameters for in-progress status', async () => {
|
|
89
|
+
const mockResponse = {
|
|
90
|
+
id: mockMigrationId,
|
|
91
|
+
status: Migration_1.MIGRATION_STATUS.IN_PROGRESS,
|
|
92
|
+
};
|
|
93
|
+
// @ts-expect-error Mock
|
|
94
|
+
httpMock.get.mockResolvedValue(mockResponse);
|
|
95
|
+
const result = await (0, migrate_1.checkMigrationStatusV2)(mockAccountId, mockMigrationId);
|
|
96
|
+
expect(http_1.http.get).toHaveBeenCalledWith(mockAccountId, {
|
|
97
|
+
url: `dfs/migrations/v2/migrations/${mockMigrationId}/status`,
|
|
98
|
+
});
|
|
99
|
+
expect(result).toEqual(mockResponse);
|
|
100
|
+
});
|
|
101
|
+
it('should handle input required status', async () => {
|
|
102
|
+
const mockResponse = {
|
|
103
|
+
id: mockMigrationId,
|
|
104
|
+
status: Migration_1.MIGRATION_STATUS.INPUT_REQUIRED,
|
|
105
|
+
componentsRequiringUids: {
|
|
106
|
+
'component-1': {
|
|
107
|
+
componentType: 'type1',
|
|
108
|
+
componentHint: 'hint1',
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
// @ts-expect-error Mock
|
|
113
|
+
httpMock.get.mockResolvedValue(mockResponse);
|
|
114
|
+
const result = await (0, migrate_1.checkMigrationStatusV2)(mockAccountId, mockMigrationId);
|
|
115
|
+
expect(result).toEqual(mockResponse);
|
|
116
|
+
});
|
|
117
|
+
it('should handle success status', async () => {
|
|
118
|
+
const mockResponse = {
|
|
119
|
+
id: mockMigrationId,
|
|
120
|
+
status: Migration_1.MIGRATION_STATUS.SUCCESS,
|
|
121
|
+
buildId: 98765,
|
|
122
|
+
};
|
|
123
|
+
// @ts-expect-error Mock
|
|
124
|
+
httpMock.get.mockResolvedValue(mockResponse);
|
|
125
|
+
const result = await (0, migrate_1.checkMigrationStatusV2)(mockAccountId, mockMigrationId);
|
|
126
|
+
expect(result).toEqual(mockResponse);
|
|
127
|
+
});
|
|
128
|
+
it('should handle failure status', async () => {
|
|
129
|
+
const mockResponse = {
|
|
130
|
+
id: mockMigrationId,
|
|
131
|
+
status: Migration_1.MIGRATION_STATUS.FAILURE,
|
|
132
|
+
projectErrorDetail: 'Error details',
|
|
133
|
+
componentErrors: [],
|
|
134
|
+
};
|
|
135
|
+
// @ts-expect-error Mock
|
|
136
|
+
httpMock.get.mockResolvedValue(mockResponse);
|
|
137
|
+
const result = await (0, migrate_1.checkMigrationStatusV2)(mockAccountId, mockMigrationId);
|
|
138
|
+
expect(result).toEqual(mockResponse);
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
describe('isMigrationStatus', () => {
|
|
143
|
+
it.each([
|
|
144
|
+
{
|
|
145
|
+
id: 123,
|
|
146
|
+
status: Migration_1.MIGRATION_STATUS.IN_PROGRESS,
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
id: 456,
|
|
150
|
+
status: Migration_1.MIGRATION_STATUS.INPUT_REQUIRED,
|
|
151
|
+
componentsRequiringUids: {
|
|
152
|
+
'component-1': {
|
|
153
|
+
componentType: 'type1',
|
|
154
|
+
componentHint: 'hint1',
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
id: 789,
|
|
160
|
+
status: Migration_1.MIGRATION_STATUS.SUCCESS,
|
|
161
|
+
buildId: 98765,
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
id: 101,
|
|
165
|
+
status: Migration_1.MIGRATION_STATUS.FAILURE,
|
|
166
|
+
projectErrorDetail: 'Error details',
|
|
167
|
+
componentErrors: [],
|
|
168
|
+
},
|
|
169
|
+
])('should return true for valid MigrationStatus object %j', status => {
|
|
170
|
+
expect((0, migrate_1.isMigrationStatus)(status)).toBe(true);
|
|
171
|
+
});
|
|
172
|
+
it.each([null, undefined, 123, 'string', true, false, []])('should return false for non-object value %j', value => {
|
|
173
|
+
expect((0, migrate_1.isMigrationStatus)(value)).toBe(false);
|
|
174
|
+
});
|
|
175
|
+
it.each([
|
|
176
|
+
{},
|
|
177
|
+
{ id: 123 },
|
|
178
|
+
{ status: Migration_1.MIGRATION_STATUS.IN_PROGRESS },
|
|
179
|
+
{ foo: 'bar' },
|
|
180
|
+
])('should return false for invalid object %j', obj => {
|
|
181
|
+
expect((0, migrate_1.isMigrationStatus)(obj)).toBe(false);
|
|
182
|
+
});
|
|
183
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
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 yargs_1 = __importDefault(require("yargs"));
|
|
7
|
+
const auth_1 = __importDefault(require("../account/auth"));
|
|
8
|
+
const list_1 = __importDefault(require("../account/list"));
|
|
9
|
+
const rename_1 = __importDefault(require("../account/rename"));
|
|
10
|
+
const use_1 = __importDefault(require("../account/use"));
|
|
11
|
+
const info_1 = __importDefault(require("../account/info"));
|
|
12
|
+
const remove_1 = __importDefault(require("../account/remove"));
|
|
13
|
+
const clean_1 = __importDefault(require("../account/clean"));
|
|
14
|
+
const createOverride_1 = __importDefault(require("../account/createOverride"));
|
|
15
|
+
const removeOverride_1 = __importDefault(require("../account/removeOverride"));
|
|
16
|
+
const account_1 = __importDefault(require("../account"));
|
|
17
|
+
vi.mock('../account/auth');
|
|
18
|
+
vi.mock('../account/list');
|
|
19
|
+
vi.mock('../account/rename');
|
|
20
|
+
vi.mock('../account/use');
|
|
21
|
+
vi.mock('../account/info');
|
|
22
|
+
vi.mock('../account/remove');
|
|
23
|
+
vi.mock('../account/clean');
|
|
24
|
+
vi.mock('../account/createOverride');
|
|
25
|
+
vi.mock('../account/removeOverride');
|
|
26
|
+
vi.mock('../../lib/commonOpts');
|
|
27
|
+
const commandSpy = vi
|
|
28
|
+
.spyOn(yargs_1.default, 'command')
|
|
29
|
+
.mockReturnValue(yargs_1.default);
|
|
30
|
+
const demandCommandSpy = vi
|
|
31
|
+
.spyOn(yargs_1.default, 'demandCommand')
|
|
32
|
+
.mockReturnValue(yargs_1.default);
|
|
33
|
+
describe('commands/account', () => {
|
|
34
|
+
describe('command', () => {
|
|
35
|
+
it('should have the correct command structure', () => {
|
|
36
|
+
expect(account_1.default.command).toEqual(['account', 'accounts']);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
describe('describe', () => {
|
|
40
|
+
it('should provide a description', () => {
|
|
41
|
+
expect(account_1.default.describe).toBeDefined();
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
describe('builder', () => {
|
|
45
|
+
beforeEach(() => {
|
|
46
|
+
commandSpy.mockClear();
|
|
47
|
+
demandCommandSpy.mockClear();
|
|
48
|
+
});
|
|
49
|
+
const subcommands = [
|
|
50
|
+
auth_1.default,
|
|
51
|
+
list_1.default,
|
|
52
|
+
rename_1.default,
|
|
53
|
+
use_1.default,
|
|
54
|
+
info_1.default,
|
|
55
|
+
remove_1.default,
|
|
56
|
+
clean_1.default,
|
|
57
|
+
createOverride_1.default,
|
|
58
|
+
removeOverride_1.default,
|
|
59
|
+
];
|
|
60
|
+
it('should demand the command takes one positional argument', () => {
|
|
61
|
+
account_1.default.builder(yargs_1.default);
|
|
62
|
+
expect(demandCommandSpy).toHaveBeenCalledTimes(1);
|
|
63
|
+
expect(demandCommandSpy).toHaveBeenCalledWith(1, '');
|
|
64
|
+
});
|
|
65
|
+
it('should add the correct number of sub commands', () => {
|
|
66
|
+
account_1.default.builder(yargs_1.default);
|
|
67
|
+
expect(commandSpy).toHaveBeenCalledTimes(subcommands.length);
|
|
68
|
+
});
|
|
69
|
+
it.each(subcommands)('should attach the %s subcommand', module => {
|
|
70
|
+
account_1.default.builder(yargs_1.default);
|
|
71
|
+
expect(commandSpy).toHaveBeenCalledWith(module);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
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 yargs_1 = __importDefault(require("yargs"));
|
|
7
|
+
const commonOpts_1 = require("../../lib/commonOpts");
|
|
8
|
+
const auth_1 = __importDefault(require("../auth"));
|
|
9
|
+
vi.mock('../../lib/commonOpts');
|
|
10
|
+
const optionsSpy = vi
|
|
11
|
+
.spyOn(mockYargs, 'options')
|
|
12
|
+
.mockReturnValue(yargs_1.default);
|
|
13
|
+
describe('commands/auth', () => {
|
|
14
|
+
describe('command', () => {
|
|
15
|
+
it('should have the correct command structure', () => {
|
|
16
|
+
expect(auth_1.default.command).toEqual('auth');
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
describe('describe', () => {
|
|
20
|
+
it('should provide a description', () => {
|
|
21
|
+
expect(auth_1.default.describe).toBeDefined();
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
describe('builder', () => {
|
|
25
|
+
it('should support the correct options', () => {
|
|
26
|
+
auth_1.default.builder(yargs_1.default);
|
|
27
|
+
expect(optionsSpy).toHaveBeenCalledTimes(1);
|
|
28
|
+
expect(optionsSpy).toHaveBeenCalledWith({
|
|
29
|
+
'auth-type': expect.objectContaining({
|
|
30
|
+
type: 'string',
|
|
31
|
+
choices: ['personalaccesskey', 'oauth2'],
|
|
32
|
+
default: 'personalaccesskey',
|
|
33
|
+
}),
|
|
34
|
+
account: expect.objectContaining({ type: 'string' }),
|
|
35
|
+
'personal-access-key': expect.objectContaining({ type: 'string' }),
|
|
36
|
+
});
|
|
37
|
+
expect(commonOpts_1.addConfigOptions).toHaveBeenCalledTimes(1);
|
|
38
|
+
expect(commonOpts_1.addConfigOptions).toHaveBeenCalledWith(yargs_1.default);
|
|
39
|
+
expect(commonOpts_1.addTestingOptions).toHaveBeenCalledTimes(1);
|
|
40
|
+
expect(commonOpts_1.addTestingOptions).toHaveBeenCalledWith(yargs_1.default);
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
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 yargs_1 = __importDefault(require("yargs"));
|
|
7
|
+
const lighthouseScore_1 = __importDefault(require("../cms/lighthouseScore"));
|
|
8
|
+
const convertFields_1 = __importDefault(require("../cms/convertFields"));
|
|
9
|
+
const getReactModule_1 = __importDefault(require("../cms/getReactModule"));
|
|
10
|
+
const cms_1 = __importDefault(require("../cms"));
|
|
11
|
+
vi.mock('../cms/lighthouseScore');
|
|
12
|
+
vi.mock('../cms/convertFields');
|
|
13
|
+
vi.mock('../cms/getReactModule');
|
|
14
|
+
vi.mock('../../lib/commonOpts');
|
|
15
|
+
const commandSpy = vi
|
|
16
|
+
.spyOn(yargs_1.default, 'command')
|
|
17
|
+
.mockReturnValue(yargs_1.default);
|
|
18
|
+
const demandCommandSpy = vi
|
|
19
|
+
.spyOn(yargs_1.default, 'demandCommand')
|
|
20
|
+
.mockReturnValue(yargs_1.default);
|
|
21
|
+
describe('commands/cms', () => {
|
|
22
|
+
describe('command', () => {
|
|
23
|
+
it('should have the correct command structure', () => {
|
|
24
|
+
expect(cms_1.default.command).toEqual('cms');
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
describe('describe', () => {
|
|
28
|
+
it('should provide a description', () => {
|
|
29
|
+
expect(cms_1.default.describe).toBeDefined();
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
describe('builder', () => {
|
|
33
|
+
const subcommands = [lighthouseScore_1.default, convertFields_1.default, getReactModule_1.default];
|
|
34
|
+
it('should demand the command takes one positional argument', () => {
|
|
35
|
+
cms_1.default.builder(yargs_1.default);
|
|
36
|
+
expect(demandCommandSpy).toHaveBeenCalledTimes(1);
|
|
37
|
+
expect(demandCommandSpy).toHaveBeenCalledWith(1, '');
|
|
38
|
+
});
|
|
39
|
+
it('should add the correct number of sub commands', () => {
|
|
40
|
+
cms_1.default.builder(yargs_1.default);
|
|
41
|
+
expect(commandSpy).toHaveBeenCalledTimes(subcommands.length);
|
|
42
|
+
});
|
|
43
|
+
it.each(subcommands)('should attach the %s subcommand', module => {
|
|
44
|
+
cms_1.default.builder(yargs_1.default);
|
|
45
|
+
expect(module).toBeDefined();
|
|
46
|
+
expect(commandSpy).toHaveBeenCalledWith(module);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
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 yargs_1 = __importDefault(require("yargs"));
|
|
7
|
+
const set_1 = __importDefault(require("../config/set"));
|
|
8
|
+
const migrate_1 = __importDefault(require("../config/migrate"));
|
|
9
|
+
const config_1 = __importDefault(require("../config"));
|
|
10
|
+
vi.mock('../config/set');
|
|
11
|
+
vi.mock('../config/set');
|
|
12
|
+
const commandSpy = vi
|
|
13
|
+
.spyOn(yargs_1.default, 'command')
|
|
14
|
+
.mockReturnValue(yargs_1.default);
|
|
15
|
+
const demandCommandSpy = vi
|
|
16
|
+
.spyOn(yargs_1.default, 'demandCommand')
|
|
17
|
+
.mockReturnValue(yargs_1.default);
|
|
18
|
+
describe('commands/config', () => {
|
|
19
|
+
describe('command', () => {
|
|
20
|
+
it('should have the correct command structure', () => {
|
|
21
|
+
expect(config_1.default.command).toEqual('config');
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
describe('describe', () => {
|
|
25
|
+
it('should provide a description', () => {
|
|
26
|
+
expect(config_1.default.describe).toBeDefined();
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
describe('builder', () => {
|
|
30
|
+
beforeEach(() => {
|
|
31
|
+
commandSpy.mockClear();
|
|
32
|
+
demandCommandSpy.mockClear();
|
|
33
|
+
});
|
|
34
|
+
const subcommands = [set_1.default, migrate_1.default];
|
|
35
|
+
it('should demand the command takes one positional argument', () => {
|
|
36
|
+
config_1.default.builder(yargs_1.default);
|
|
37
|
+
expect(demandCommandSpy).toHaveBeenCalledTimes(1);
|
|
38
|
+
expect(demandCommandSpy).toHaveBeenCalledWith(1, '');
|
|
39
|
+
});
|
|
40
|
+
it('should add the correct number of sub commands', () => {
|
|
41
|
+
config_1.default.builder(yargs_1.default);
|
|
42
|
+
expect(commandSpy).toHaveBeenCalledTimes(subcommands.length);
|
|
43
|
+
});
|
|
44
|
+
it.each(subcommands)('should attach the %s subcommand', module => {
|
|
45
|
+
config_1.default.builder(yargs_1.default);
|
|
46
|
+
expect(commandSpy).toHaveBeenCalledWith(module);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
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 yargs_1 = __importDefault(require("yargs"));
|
|
7
|
+
const create_1 = __importDefault(require("../create"));
|
|
8
|
+
const positionalSpy = vi
|
|
9
|
+
.spyOn(yargs_1.default, 'positional')
|
|
10
|
+
.mockReturnValue(yargs_1.default);
|
|
11
|
+
const optionSpy = vi
|
|
12
|
+
.spyOn(yargs_1.default, 'option')
|
|
13
|
+
.mockReturnValue(yargs_1.default);
|
|
14
|
+
describe('commands/create', () => {
|
|
15
|
+
describe('command', () => {
|
|
16
|
+
it('should have the correct command structure', () => {
|
|
17
|
+
expect(create_1.default.command).toEqual('create <type> [name] [dest]');
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
describe('describe', () => {
|
|
21
|
+
it('should provide a description', () => {
|
|
22
|
+
expect(create_1.default.describe).toBeDefined();
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
describe('builder', () => {
|
|
26
|
+
it('should support the correct positional arguments', () => {
|
|
27
|
+
create_1.default.builder(yargs_1.default);
|
|
28
|
+
expect(positionalSpy).toHaveBeenCalledTimes(3);
|
|
29
|
+
expect(positionalSpy).toHaveBeenCalledWith('type', expect.objectContaining({ type: 'string' }));
|
|
30
|
+
expect(positionalSpy).toHaveBeenCalledWith('name', expect.objectContaining({ type: 'string' }));
|
|
31
|
+
expect(positionalSpy).toHaveBeenCalledWith('dest', expect.objectContaining({ type: 'string' }));
|
|
32
|
+
});
|
|
33
|
+
it('should support the correct options', () => {
|
|
34
|
+
create_1.default.builder(yargs_1.default);
|
|
35
|
+
expect(optionSpy).toHaveBeenCalledWith('internal', expect.objectContaining({ type: 'boolean', hidden: true }));
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
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 yargs_1 = __importDefault(require("yargs"));
|
|
7
|
+
const create_1 = __importDefault(require("../customObject/create"));
|
|
8
|
+
const schema_1 = __importDefault(require("../customObject/schema"));
|
|
9
|
+
const customObject_1 = __importDefault(require("../customObject"));
|
|
10
|
+
vi.mock('../customObject/create');
|
|
11
|
+
vi.mock('../customObject/schema');
|
|
12
|
+
vi.mock('../../lib/commonOpts');
|
|
13
|
+
const commandSpy = vi
|
|
14
|
+
.spyOn(yargs_1.default, 'command')
|
|
15
|
+
.mockReturnValue(yargs_1.default);
|
|
16
|
+
const demandCommandSpy = vi
|
|
17
|
+
.spyOn(yargs_1.default, 'demandCommand')
|
|
18
|
+
.mockReturnValue(yargs_1.default);
|
|
19
|
+
describe('commands/customObject', () => {
|
|
20
|
+
describe('command', () => {
|
|
21
|
+
it('should have the correct command structure', () => {
|
|
22
|
+
expect(customObject_1.default.command).toEqual([
|
|
23
|
+
'custom-object',
|
|
24
|
+
'custom-objects',
|
|
25
|
+
'co',
|
|
26
|
+
]);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
describe('describe', () => {
|
|
30
|
+
it('should provide a description', () => {
|
|
31
|
+
expect(customObject_1.default.describe).toBeDefined();
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
describe('builder', () => {
|
|
35
|
+
beforeEach(() => {
|
|
36
|
+
commandSpy.mockClear();
|
|
37
|
+
demandCommandSpy.mockClear();
|
|
38
|
+
});
|
|
39
|
+
const subcommands = [create_1.default, schema_1.default];
|
|
40
|
+
it('should demand the command takes one positional argument', () => {
|
|
41
|
+
customObject_1.default.builder(yargs_1.default);
|
|
42
|
+
expect(demandCommandSpy).toHaveBeenCalledTimes(1);
|
|
43
|
+
expect(demandCommandSpy).toHaveBeenCalledWith(1, '');
|
|
44
|
+
});
|
|
45
|
+
it('should add the correct number of sub commands', () => {
|
|
46
|
+
customObject_1.default.builder(yargs_1.default);
|
|
47
|
+
expect(commandSpy).toHaveBeenCalledTimes(subcommands.length);
|
|
48
|
+
});
|
|
49
|
+
it.each(subcommands)('should attach the %s subcommand', module => {
|
|
50
|
+
customObject_1.default.builder(yargs_1.default);
|
|
51
|
+
expect(commandSpy).toHaveBeenCalledWith(module);
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,139 @@
|
|
|
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 exitCodes_1 = require("../../lib/enums/exitCodes");
|
|
7
|
+
const yargs_1 = __importDefault(require("yargs"));
|
|
8
|
+
const doctor_1 = __importDefault(require("../doctor"));
|
|
9
|
+
const usageTracking_1 = require("../../lib/usageTracking");
|
|
10
|
+
const Doctor_1 = require("../../lib/doctor/Doctor");
|
|
11
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
12
|
+
const fs_1 = __importDefault(require("fs"));
|
|
13
|
+
const path_1 = require("@hubspot/local-dev-lib/path");
|
|
14
|
+
vi.mock('../../lib/usageTracking');
|
|
15
|
+
vi.mock('../../lib/doctor/Doctor');
|
|
16
|
+
vi.mock('@hubspot/local-dev-lib/logger');
|
|
17
|
+
vi.mock('@hubspot/local-dev-lib/path');
|
|
18
|
+
vi.mock('fs');
|
|
19
|
+
// @ts-expect-error Doesn't match the actual signature because then the linter complains about unused variables
|
|
20
|
+
const DoctorMock = Doctor_1.Doctor;
|
|
21
|
+
const mockedFs = vi.mocked(fs_1.default);
|
|
22
|
+
const getCwd = path_1.getCwd;
|
|
23
|
+
const optionSpy = vi
|
|
24
|
+
.spyOn(yargs_1.default, 'option')
|
|
25
|
+
.mockReturnValue(yargs_1.default);
|
|
26
|
+
const date = new Date('2022-02-22');
|
|
27
|
+
vi.useFakeTimers().setSystemTime(date);
|
|
28
|
+
describe('doctor', () => {
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
30
|
+
let processExitSpy;
|
|
31
|
+
const accountId = 123456;
|
|
32
|
+
beforeEach(() => {
|
|
33
|
+
// @ts-expect-error Doesn't match the actual signature because then the linter complains about unused variables
|
|
34
|
+
processExitSpy = vi.spyOn(process, 'exit').mockImplementation(() => { });
|
|
35
|
+
});
|
|
36
|
+
describe('command', () => {
|
|
37
|
+
it('should have the proper command name', () => {
|
|
38
|
+
expect(doctor_1.default.command).toEqual('doctor');
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
describe('describe', () => {
|
|
42
|
+
it('should have a description', () => {
|
|
43
|
+
expect(doctor_1.default.describe).toEqual('Retrieve diagnostic information about your local HubSpot configurations.');
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
describe('builder', () => {
|
|
47
|
+
it('should apply the correct options', () => {
|
|
48
|
+
doctor_1.default.builder(yargs_1.default);
|
|
49
|
+
expect(optionSpy).toHaveBeenCalledWith('output-dir', {
|
|
50
|
+
describe: 'Directory to save a detailed diagnosis JSON file in',
|
|
51
|
+
type: 'string',
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
describe('handler', () => {
|
|
56
|
+
let diagnosis;
|
|
57
|
+
beforeEach(() => {
|
|
58
|
+
diagnosis = 'Yooooooooooooooo';
|
|
59
|
+
DoctorMock.mockImplementation(() => {
|
|
60
|
+
return {
|
|
61
|
+
diagnose: vi.fn().mockResolvedValue({ diagnosis }),
|
|
62
|
+
accountId,
|
|
63
|
+
};
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
it('should track the command usage', async () => {
|
|
67
|
+
await doctor_1.default.handler({});
|
|
68
|
+
expect(usageTracking_1.trackCommandUsage).toHaveBeenCalledTimes(1);
|
|
69
|
+
expect(usageTracking_1.trackCommandUsage).toHaveBeenCalledWith('doctor', undefined, accountId);
|
|
70
|
+
});
|
|
71
|
+
it('should log the diagnosis if it is defined', async () => {
|
|
72
|
+
await doctor_1.default.handler({});
|
|
73
|
+
expect(logger_1.logger.log).toHaveBeenCalledTimes(1);
|
|
74
|
+
expect(logger_1.logger.log).toHaveBeenCalledWith(diagnosis);
|
|
75
|
+
expect(processExitSpy).toHaveBeenCalledTimes(1);
|
|
76
|
+
expect(processExitSpy).toHaveBeenCalledWith(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
77
|
+
});
|
|
78
|
+
it('should log an error if the diagnosis is undefined', async () => {
|
|
79
|
+
DoctorMock.mockImplementationOnce(() => {
|
|
80
|
+
return {
|
|
81
|
+
diagnose: vi.fn().mockResolvedValue(undefined),
|
|
82
|
+
accountId,
|
|
83
|
+
};
|
|
84
|
+
});
|
|
85
|
+
await doctor_1.default.handler({});
|
|
86
|
+
expect(logger_1.logger.error).toHaveBeenCalledTimes(1);
|
|
87
|
+
expect(logger_1.logger.error).toHaveBeenCalledWith('Error generating diagnosis');
|
|
88
|
+
expect(processExitSpy).toHaveBeenCalledTimes(1);
|
|
89
|
+
expect(processExitSpy).toHaveBeenCalledWith(exitCodes_1.EXIT_CODES.ERROR);
|
|
90
|
+
});
|
|
91
|
+
it('should write the output to a file if output-dir is defined', async () => {
|
|
92
|
+
mockedFs.writeFileSync.mockImplementationOnce(() => { });
|
|
93
|
+
const expectedOutputFile = `/foo/hubspot-doctor-${date.toISOString()}.json`;
|
|
94
|
+
await doctor_1.default.handler({
|
|
95
|
+
outputDir: '/foo',
|
|
96
|
+
});
|
|
97
|
+
expect(logger_1.logger.log).not.toHaveBeenCalled();
|
|
98
|
+
expect(logger_1.logger.error).not.toHaveBeenCalled();
|
|
99
|
+
expect(mockedFs.writeFileSync).toHaveBeenCalledTimes(1);
|
|
100
|
+
expect(mockedFs.writeFileSync).toHaveBeenCalledWith(expectedOutputFile, expect.stringContaining(diagnosis));
|
|
101
|
+
expect(logger_1.logger.success).toHaveBeenCalledTimes(1);
|
|
102
|
+
expect(logger_1.logger.success).toHaveBeenCalledWith(expect.stringMatching(/Output written to /));
|
|
103
|
+
expect(processExitSpy).toHaveBeenCalledTimes(1);
|
|
104
|
+
expect(processExitSpy).toHaveBeenCalledWith(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
105
|
+
});
|
|
106
|
+
it('should handle absolute paths', async () => {
|
|
107
|
+
mockedFs.writeFileSync.mockImplementationOnce(() => { });
|
|
108
|
+
const cwd = '/some/path/to';
|
|
109
|
+
getCwd.mockImplementationOnce(() => cwd);
|
|
110
|
+
const expectedOutputFile = `${cwd}/foo/hubspot-doctor-${date.toISOString()}.json`;
|
|
111
|
+
await doctor_1.default.handler({
|
|
112
|
+
outputDir: './foo',
|
|
113
|
+
});
|
|
114
|
+
expect(logger_1.logger.log).not.toHaveBeenCalled();
|
|
115
|
+
expect(logger_1.logger.error).not.toHaveBeenCalled();
|
|
116
|
+
expect(mockedFs.writeFileSync).toHaveBeenCalledTimes(1);
|
|
117
|
+
expect(mockedFs.writeFileSync).toHaveBeenCalledWith(expectedOutputFile, expect.stringContaining(diagnosis));
|
|
118
|
+
expect(logger_1.logger.success).toHaveBeenCalledTimes(1);
|
|
119
|
+
expect(logger_1.logger.success).toHaveBeenCalledWith(expect.stringMatching(/Output written to /));
|
|
120
|
+
expect(processExitSpy).toHaveBeenCalledTimes(1);
|
|
121
|
+
expect(processExitSpy).toHaveBeenCalledWith(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
122
|
+
});
|
|
123
|
+
it('should log an error message when writing the output fails', async () => {
|
|
124
|
+
const errorMessage = 'Something bad happened';
|
|
125
|
+
mockedFs.writeFileSync.mockImplementationOnce(() => {
|
|
126
|
+
throw new Error(errorMessage);
|
|
127
|
+
});
|
|
128
|
+
await doctor_1.default.handler({
|
|
129
|
+
outputDir: '/foo',
|
|
130
|
+
});
|
|
131
|
+
expect(logger_1.logger.error).toHaveBeenCalledTimes(1);
|
|
132
|
+
expect(logger_1.logger.error).toHaveBeenCalledWith(expect.stringMatching(/Unable to write output to/));
|
|
133
|
+
expect(mockedFs.writeFileSync).toHaveBeenCalledTimes(1);
|
|
134
|
+
expect(mockedFs.writeFileSync).toHaveBeenCalledWith(`/foo/hubspot-doctor-${date.toISOString()}.json`, expect.stringContaining(diagnosis));
|
|
135
|
+
expect(processExitSpy).toHaveBeenCalledTimes(1);
|
|
136
|
+
expect(processExitSpy).toHaveBeenCalledWith(exitCodes_1.EXIT_CODES.ERROR);
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|