@hubspot/cli 7.6.0-beta.3 → 7.6.0-beta.5
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 +160 -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 +13 -34
- 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 +346 -0
- package/commands/project/__tests__/devUnifiedFlow.test.d.ts +1 -0
- package/commands/project/__tests__/devUnifiedFlow.test.js +423 -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 +3 -2
- package/commands/project/deploy.js +61 -55
- package/commands/project/dev/unifiedFlow.js +7 -6
- 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 +11 -24
- 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 +36 -19
- package/lang/en.js +36 -19
- package/lang/en.lyaml +0 -26
- 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 +259 -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/buildAccount.d.ts +7 -1
- package/lib/buildAccount.js +54 -4
- 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/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 -3
- package/lib/projects/localDev/DevServerManagerV2.js +0 -2
- package/lib/projects/localDev/helpers.d.ts +1 -1
- package/lib/projects/localDev/helpers.js +2 -2
- 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 +11 -10
- package/lib/prompts/createDeveloperTestAccountConfigPrompt.js +78 -35
- 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 +172 -36
- 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 +10 -10
- package/types/Prompts.d.ts +4 -2
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
4
|
+
const sandboxHubs_1 = require("@hubspot/local-dev-lib/api/sandboxHubs");
|
|
5
|
+
const sandboxSync_1 = require("@hubspot/local-dev-lib/api/sandboxSync");
|
|
6
|
+
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
7
|
+
const config_2 = require("@hubspot/local-dev-lib/constants/config");
|
|
8
|
+
const testUtils_1 = require("../testUtils");
|
|
9
|
+
const sandboxes_1 = require("../sandboxes");
|
|
10
|
+
vi.mock('@hubspot/local-dev-lib/logger');
|
|
11
|
+
vi.mock('@hubspot/local-dev-lib/api/sandboxHubs');
|
|
12
|
+
vi.mock('@hubspot/local-dev-lib/api/sandboxSync');
|
|
13
|
+
vi.mock('@hubspot/local-dev-lib/config');
|
|
14
|
+
const mockedGetAccountId = config_1.getAccountId;
|
|
15
|
+
const mockedGetSandboxUsageLimits = sandboxHubs_1.getSandboxUsageLimits;
|
|
16
|
+
const mockedFetchTypes = sandboxSync_1.fetchTypes;
|
|
17
|
+
const mockedGetConfigAccounts = config_1.getConfigAccounts;
|
|
18
|
+
const mockedLogger = logger_1.logger;
|
|
19
|
+
describe('lib/sandboxes', () => {
|
|
20
|
+
describe('getSandboxTypeAsString()', () => {
|
|
21
|
+
it('returns "development" for development sandbox type', () => {
|
|
22
|
+
expect((0, sandboxes_1.getSandboxTypeAsString)(config_2.HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX)).toBe('development');
|
|
23
|
+
});
|
|
24
|
+
it('returns "standard" for standard sandbox type', () => {
|
|
25
|
+
expect((0, sandboxes_1.getSandboxTypeAsString)(config_2.HUBSPOT_ACCOUNT_TYPES.STANDARD_SANDBOX)).toBe('standard');
|
|
26
|
+
});
|
|
27
|
+
it('returns "standard" for undefined input', () => {
|
|
28
|
+
expect((0, sandboxes_1.getSandboxTypeAsString)(undefined)).toBe('standard');
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
describe('getHasSandboxesByType()', () => {
|
|
32
|
+
const mockParentAccount = {
|
|
33
|
+
name: 'Parent Account',
|
|
34
|
+
portalId: 123,
|
|
35
|
+
authType: undefined,
|
|
36
|
+
accountType: config_2.HUBSPOT_ACCOUNT_TYPES.STANDARD_SANDBOX,
|
|
37
|
+
env: 'qa',
|
|
38
|
+
};
|
|
39
|
+
it('returns true when sandbox of specified type exists', () => {
|
|
40
|
+
mockedGetAccountId.mockReturnValue(mockParentAccount.portalId);
|
|
41
|
+
mockedGetConfigAccounts.mockReturnValue([
|
|
42
|
+
mockParentAccount,
|
|
43
|
+
{
|
|
44
|
+
...mockParentAccount,
|
|
45
|
+
parentAccountId: 123,
|
|
46
|
+
accountType: config_2.HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX,
|
|
47
|
+
},
|
|
48
|
+
]);
|
|
49
|
+
expect((0, sandboxes_1.getHasSandboxesByType)(mockParentAccount, config_2.HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX)).toBe(true);
|
|
50
|
+
});
|
|
51
|
+
it('returns false when no sandbox of specified type exists', () => {
|
|
52
|
+
mockedGetConfigAccounts.mockReturnValue([mockParentAccount]);
|
|
53
|
+
expect((0, sandboxes_1.getHasSandboxesByType)(mockParentAccount, config_2.HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX)).toBe(false);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
describe('getAvailableSyncTypes()', () => {
|
|
57
|
+
const mockParentAccount = {
|
|
58
|
+
name: 'Parent Account',
|
|
59
|
+
portalId: 123,
|
|
60
|
+
env: 'qa',
|
|
61
|
+
};
|
|
62
|
+
const mockChildAccount = {
|
|
63
|
+
...mockParentAccount,
|
|
64
|
+
portalId: 456,
|
|
65
|
+
};
|
|
66
|
+
it('returns available sync types when fetch is successful', async () => {
|
|
67
|
+
const mockSyncTypes = [{ name: 'type1' }, { name: 'type2' }];
|
|
68
|
+
mockedGetAccountId
|
|
69
|
+
.mockReturnValue(mockParentAccount.portalId)
|
|
70
|
+
.mockReturnValue(mockChildAccount.portalId);
|
|
71
|
+
mockedFetchTypes.mockResolvedValue({
|
|
72
|
+
data: { results: mockSyncTypes },
|
|
73
|
+
});
|
|
74
|
+
const result = await (0, sandboxes_1.getAvailableSyncTypes)(mockParentAccount, mockChildAccount);
|
|
75
|
+
expect(result).toEqual([{ type: 'type1' }, { type: 'type2' }]);
|
|
76
|
+
});
|
|
77
|
+
it('throws error when sync types fetch fails', async () => {
|
|
78
|
+
mockedFetchTypes.mockResolvedValue({ data: { results: null } });
|
|
79
|
+
await expect((0, sandboxes_1.getAvailableSyncTypes)(mockParentAccount, mockChildAccount)).rejects.toThrow(/Unable to fetch available sandbox sync types/);
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
describe('validateSandboxUsageLimits()', () => {
|
|
83
|
+
const mockAccount = {
|
|
84
|
+
name: 'Test Account',
|
|
85
|
+
portalId: 123,
|
|
86
|
+
authType: undefined,
|
|
87
|
+
env: 'qa',
|
|
88
|
+
};
|
|
89
|
+
it('validates successfully when limits are not reached', async () => {
|
|
90
|
+
mockedGetAccountId.mockReturnValue(mockAccount.portalId);
|
|
91
|
+
mockedGetSandboxUsageLimits.mockResolvedValue({
|
|
92
|
+
data: {
|
|
93
|
+
usage: { DEVELOPER: { available: 1, limit: 3 } },
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
await expect((0, sandboxes_1.validateSandboxUsageLimits)(mockAccount, config_2.HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX, 'qa')).resolves.not.toThrow();
|
|
97
|
+
});
|
|
98
|
+
it('throws error when development sandbox limit is reached', async () => {
|
|
99
|
+
mockedGetAccountId.mockReturnValue(mockAccount.portalId);
|
|
100
|
+
mockedGetConfigAccounts.mockReturnValue([]);
|
|
101
|
+
mockedGetSandboxUsageLimits.mockResolvedValue({
|
|
102
|
+
data: {
|
|
103
|
+
usage: { DEVELOPER: { available: 0, limit: 1 } },
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
await expect((0, sandboxes_1.validateSandboxUsageLimits)(mockAccount, config_2.HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX, 'qa')).rejects.toThrow(/reached the limit of 1 development sandbox/);
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
describe('handleSandboxCreateError()', () => {
|
|
110
|
+
const mockEnv = 'qa';
|
|
111
|
+
const mockName = 'Test Sandbox';
|
|
112
|
+
const mockAccountId = 123;
|
|
113
|
+
it('handles missing scope error', () => {
|
|
114
|
+
const error = (0, testUtils_1.mockHubSpotHttpError)('missing scopes error', {
|
|
115
|
+
status: 403,
|
|
116
|
+
data: {
|
|
117
|
+
message: 'Missing scopes error',
|
|
118
|
+
category: 'MISSING_SCOPES',
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
expect(() => (0, sandboxes_1.handleSandboxCreateError)(error, mockEnv, mockName, mockAccountId)).toThrow(error);
|
|
122
|
+
expect(mockedLogger.error).toHaveBeenCalledWith(expect.stringMatching(/The personal access key you provided doesn't include sandbox permissions/));
|
|
123
|
+
expect(mockedLogger.info).toHaveBeenCalledWith(expect.stringMatching(/To update CLI permissions for/));
|
|
124
|
+
});
|
|
125
|
+
it('handles user access not allowed error', () => {
|
|
126
|
+
const error = (0, testUtils_1.mockHubSpotHttpError)('user access not allowed error', {
|
|
127
|
+
status: 403,
|
|
128
|
+
data: {
|
|
129
|
+
category: 'BANNED',
|
|
130
|
+
subCategory: 'SandboxErrors.USER_ACCESS_NOT_ALLOWED',
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
expect(() => (0, sandboxes_1.handleSandboxCreateError)(error, mockEnv, mockName, mockAccountId)).toThrow(error);
|
|
134
|
+
expect(mockedLogger.error).toHaveBeenCalledWith(expect.stringMatching(/your permission set doesn't allow you to create the sandbox/));
|
|
135
|
+
});
|
|
136
|
+
it('handles 403 gating error', () => {
|
|
137
|
+
const error = (0, testUtils_1.mockHubSpotHttpError)('403 gating error', {
|
|
138
|
+
status: 403,
|
|
139
|
+
data: {
|
|
140
|
+
category: 'BANNED',
|
|
141
|
+
subCategory: 'SandboxErrors.DEVELOPMENT_SANDBOX_ACCESS_NOT_ALLOWED',
|
|
142
|
+
},
|
|
143
|
+
});
|
|
144
|
+
expect(() => (0, sandboxes_1.handleSandboxCreateError)(error, mockEnv, mockName, mockAccountId)).toThrow(error);
|
|
145
|
+
expect(mockedLogger.error).toHaveBeenCalledWith(expect.stringMatching(/does not have access to development sandboxes/));
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,154 @@
|
|
|
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 mock_stdin_1 = __importDefault(require("mock-stdin"));
|
|
7
|
+
const serverlessFunctionLogs_1 = require("../ui/serverlessFunctionLogs");
|
|
8
|
+
const serverlessLogs_1 = require("../serverlessLogs");
|
|
9
|
+
vi.mock('../ui/serverlessFunctionLogs');
|
|
10
|
+
vi.mock('@hubspot/local-dev-lib/logger');
|
|
11
|
+
vi.mock('../ui/SpinniesManager', () => ({
|
|
12
|
+
default: {
|
|
13
|
+
init: vi.fn(),
|
|
14
|
+
add: vi.fn(),
|
|
15
|
+
remove: vi.fn(),
|
|
16
|
+
succeed: vi.fn(),
|
|
17
|
+
fail: vi.fn(),
|
|
18
|
+
stopAll: vi.fn(),
|
|
19
|
+
},
|
|
20
|
+
}));
|
|
21
|
+
vi.useFakeTimers();
|
|
22
|
+
const ACCOUNT_ID = 123;
|
|
23
|
+
describe('lib/serverlessLogs', () => {
|
|
24
|
+
describe('tailLogs()', () => {
|
|
25
|
+
let stdinMock;
|
|
26
|
+
beforeEach(() => {
|
|
27
|
+
// @ts-ignore - we don't need to mock the entire process object
|
|
28
|
+
vi.spyOn(process, 'exit').mockImplementation(() => { });
|
|
29
|
+
stdinMock = mock_stdin_1.default.stdin();
|
|
30
|
+
});
|
|
31
|
+
afterEach(() => {
|
|
32
|
+
vi.clearAllTimers();
|
|
33
|
+
stdinMock.restore();
|
|
34
|
+
});
|
|
35
|
+
it('calls tailCall() to get the next results', async () => {
|
|
36
|
+
const compact = false;
|
|
37
|
+
const fetchLatest = vi.fn(() => {
|
|
38
|
+
return Promise.resolve({
|
|
39
|
+
data: {
|
|
40
|
+
id: '1234',
|
|
41
|
+
executionTime: 510,
|
|
42
|
+
log: 'Log message',
|
|
43
|
+
error: { message: '', type: '', stackTrace: [] },
|
|
44
|
+
status: 'SUCCESS',
|
|
45
|
+
createdAt: 1620232011451,
|
|
46
|
+
memory: '70/128 MB',
|
|
47
|
+
duration: '53.40 ms',
|
|
48
|
+
},
|
|
49
|
+
status: 200,
|
|
50
|
+
statusText: 'OK',
|
|
51
|
+
headers: {},
|
|
52
|
+
config: {},
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
const tailCall = vi.fn(() => {
|
|
56
|
+
return Promise.resolve({
|
|
57
|
+
data: {
|
|
58
|
+
results: [],
|
|
59
|
+
paging: {
|
|
60
|
+
next: {
|
|
61
|
+
after: 'somehash',
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
status: 200,
|
|
66
|
+
statusText: 'OK',
|
|
67
|
+
headers: {},
|
|
68
|
+
config: {},
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
// @ts-ignore - headers is not used in the actual function and does not need to be mocked
|
|
72
|
+
await (0, serverlessLogs_1.tailLogs)(ACCOUNT_ID, 'name', fetchLatest, tailCall, compact);
|
|
73
|
+
vi.runOnlyPendingTimers();
|
|
74
|
+
expect(fetchLatest).toHaveBeenCalled();
|
|
75
|
+
expect(tailCall).toHaveBeenCalledTimes(2);
|
|
76
|
+
});
|
|
77
|
+
it('outputs results', async () => {
|
|
78
|
+
const compact = false;
|
|
79
|
+
const fetchLatest = vi.fn(() => {
|
|
80
|
+
return Promise.resolve({
|
|
81
|
+
data: {
|
|
82
|
+
id: '1234',
|
|
83
|
+
executionTime: 510,
|
|
84
|
+
log: 'Log message',
|
|
85
|
+
error: { message: '', type: '', stackTrace: [], statusCode: null },
|
|
86
|
+
status: 'SUCCESS',
|
|
87
|
+
createdAt: 1620232011451,
|
|
88
|
+
memory: '70/128 MB',
|
|
89
|
+
duration: '53.40 ms',
|
|
90
|
+
},
|
|
91
|
+
status: 200,
|
|
92
|
+
statusText: 'OK',
|
|
93
|
+
headers: {},
|
|
94
|
+
config: {},
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
const latestLogResponse = {
|
|
98
|
+
results: [
|
|
99
|
+
{
|
|
100
|
+
id: '456',
|
|
101
|
+
executionTime: 510,
|
|
102
|
+
log: 'Message 1',
|
|
103
|
+
error: null,
|
|
104
|
+
status: 'SUCCESS',
|
|
105
|
+
createdAt: 1620232011451,
|
|
106
|
+
memory: '70/128 MB',
|
|
107
|
+
duration: '53.40 ms',
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
id: '457',
|
|
111
|
+
executionTime: 510,
|
|
112
|
+
log: 'Message 2',
|
|
113
|
+
error: null,
|
|
114
|
+
status: 'SUCCESS',
|
|
115
|
+
createdAt: 1620232011451,
|
|
116
|
+
memory: '70/128 MB',
|
|
117
|
+
duration: '53.40 ms',
|
|
118
|
+
},
|
|
119
|
+
],
|
|
120
|
+
paging: {
|
|
121
|
+
next: {
|
|
122
|
+
after: 'somehash',
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
};
|
|
126
|
+
const tailCall = vi.fn(() => Promise.resolve({ data: latestLogResponse }));
|
|
127
|
+
// @ts-ignore - headers is not used in the actual function and does not need to be mocked
|
|
128
|
+
await (0, serverlessLogs_1.tailLogs)(ACCOUNT_ID, 'name', fetchLatest, tailCall, compact);
|
|
129
|
+
vi.runOnlyPendingTimers();
|
|
130
|
+
expect(serverlessFunctionLogs_1.outputLogs).toHaveBeenCalledWith(latestLogResponse, expect.objectContaining({ compact }));
|
|
131
|
+
expect(tailCall).toHaveBeenCalledTimes(2);
|
|
132
|
+
});
|
|
133
|
+
it('handles no logs', async () => {
|
|
134
|
+
const compact = false;
|
|
135
|
+
const fetchLatest = vi.fn(() => {
|
|
136
|
+
return Promise.reject({
|
|
137
|
+
message: '',
|
|
138
|
+
type: '',
|
|
139
|
+
stackTrace: [],
|
|
140
|
+
statusCode: 404,
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
const tailCall = vi.fn(() => Promise.reject({
|
|
144
|
+
message: '',
|
|
145
|
+
type: '',
|
|
146
|
+
stackTrace: [],
|
|
147
|
+
statusCode: 404,
|
|
148
|
+
}));
|
|
149
|
+
await (0, serverlessLogs_1.tailLogs)(ACCOUNT_ID, 'name', fetchLatest, tailCall, compact);
|
|
150
|
+
vi.runOnlyPendingTimers();
|
|
151
|
+
expect(tailCall).toHaveBeenCalledTimes(2);
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const trackUsage_1 = require("@hubspot/local-dev-lib/trackUsage");
|
|
4
|
+
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
5
|
+
const auth_1 = require("@hubspot/local-dev-lib/constants/auth");
|
|
6
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
7
|
+
const usageTracking_1 = require("../usageTracking");
|
|
8
|
+
const package_json_1 = require("../../package.json");
|
|
9
|
+
vi.mock('@hubspot/local-dev-lib/trackUsage');
|
|
10
|
+
vi.mock('@hubspot/local-dev-lib/config');
|
|
11
|
+
vi.mock('@hubspot/local-dev-lib/logger');
|
|
12
|
+
const mockedTrackUsage = trackUsage_1.trackUsage;
|
|
13
|
+
const mockedIsTrackingAllowed = config_1.isTrackingAllowed;
|
|
14
|
+
const mockedGetAccountConfig = config_1.getAccountConfig;
|
|
15
|
+
const mockedLogger = logger_1.logger;
|
|
16
|
+
describe('lib/usageTracking', () => {
|
|
17
|
+
const mockPlatform = 'darwin';
|
|
18
|
+
const mockNodeVersion = 'v16.14.0';
|
|
19
|
+
beforeEach(() => {
|
|
20
|
+
mockedIsTrackingAllowed.mockReturnValue(true);
|
|
21
|
+
Object.defineProperty(process, 'platform', { value: mockPlatform });
|
|
22
|
+
Object.defineProperty(process, 'version', { value: mockNodeVersion });
|
|
23
|
+
});
|
|
24
|
+
describe('trackCommandUsage()', () => {
|
|
25
|
+
const mockCommand = 'test-command';
|
|
26
|
+
const mockAccountId = 123;
|
|
27
|
+
it('should not track when tracking is disabled', async () => {
|
|
28
|
+
mockedIsTrackingAllowed.mockReturnValue(false);
|
|
29
|
+
await (0, usageTracking_1.trackCommandUsage)(mockCommand);
|
|
30
|
+
expect(mockedTrackUsage).not.toHaveBeenCalled();
|
|
31
|
+
});
|
|
32
|
+
it('should track command usage with default auth type', async () => {
|
|
33
|
+
await (0, usageTracking_1.trackCommandUsage)(mockCommand, {}, mockAccountId);
|
|
34
|
+
expect(mockedTrackUsage).toHaveBeenCalledWith('cli-interaction', 'INTERACTION', expect.objectContaining({
|
|
35
|
+
action: 'cli-command',
|
|
36
|
+
command: mockCommand,
|
|
37
|
+
os: 'macos',
|
|
38
|
+
nodeVersion: mockNodeVersion,
|
|
39
|
+
nodeMajorVersion: 'v16',
|
|
40
|
+
version: package_json_1.version,
|
|
41
|
+
authType: auth_1.API_KEY_AUTH_METHOD.value,
|
|
42
|
+
}), mockAccountId);
|
|
43
|
+
});
|
|
44
|
+
it('should track command usage with custom auth type', async () => {
|
|
45
|
+
mockedGetAccountConfig.mockReturnValue({ authType: 'oauth2' });
|
|
46
|
+
await (0, usageTracking_1.trackCommandUsage)(mockCommand, {}, mockAccountId);
|
|
47
|
+
expect(mockedTrackUsage).toHaveBeenCalledWith('cli-interaction', 'INTERACTION', expect.objectContaining({
|
|
48
|
+
authType: 'oauth2',
|
|
49
|
+
}), mockAccountId);
|
|
50
|
+
});
|
|
51
|
+
it('should handle tracking errors gracefully', async () => {
|
|
52
|
+
const error = new Error('Tracking failed');
|
|
53
|
+
mockedTrackUsage.mockImplementationOnce(() => {
|
|
54
|
+
throw error;
|
|
55
|
+
});
|
|
56
|
+
await (0, usageTracking_1.trackCommandUsage)(mockCommand);
|
|
57
|
+
expect(mockedLogger.debug).toHaveBeenCalledWith(expect.stringContaining(error.message));
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
describe('trackHelpUsage()', () => {
|
|
61
|
+
const mockCommand = 'help-command';
|
|
62
|
+
it('should not track when tracking is disabled', async () => {
|
|
63
|
+
mockedIsTrackingAllowed.mockReturnValue(false);
|
|
64
|
+
await (0, usageTracking_1.trackHelpUsage)(mockCommand);
|
|
65
|
+
expect(mockedTrackUsage).not.toHaveBeenCalled();
|
|
66
|
+
});
|
|
67
|
+
it('should track help usage with command', async () => {
|
|
68
|
+
await (0, usageTracking_1.trackHelpUsage)(mockCommand);
|
|
69
|
+
expect(mockedTrackUsage).toHaveBeenCalledWith('cli-interaction', 'INTERACTION', expect.objectContaining({
|
|
70
|
+
action: 'cli-help',
|
|
71
|
+
command: mockCommand,
|
|
72
|
+
os: 'macos',
|
|
73
|
+
nodeVersion: mockNodeVersion,
|
|
74
|
+
nodeMajorVersion: 'v16',
|
|
75
|
+
version: package_json_1.version,
|
|
76
|
+
}), undefined);
|
|
77
|
+
});
|
|
78
|
+
it('should track main help usage without command', async () => {
|
|
79
|
+
await (0, usageTracking_1.trackHelpUsage)('');
|
|
80
|
+
expect(mockedLogger.debug).toHaveBeenCalledWith(expect.stringContaining('main command'));
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
describe('trackConvertFieldsUsage()', () => {
|
|
84
|
+
const mockCommand = 'convert-fields-command';
|
|
85
|
+
it('should not track when tracking is disabled', async () => {
|
|
86
|
+
mockedIsTrackingAllowed.mockReturnValue(false);
|
|
87
|
+
await (0, usageTracking_1.trackConvertFieldsUsage)(mockCommand);
|
|
88
|
+
expect(mockedTrackUsage).not.toHaveBeenCalled();
|
|
89
|
+
});
|
|
90
|
+
it('should track convert fields usage', async () => {
|
|
91
|
+
await (0, usageTracking_1.trackConvertFieldsUsage)(mockCommand);
|
|
92
|
+
expect(mockedTrackUsage).toHaveBeenCalledWith('cli-interaction', 'INTERACTION', expect.objectContaining({
|
|
93
|
+
action: 'cli-process-fields',
|
|
94
|
+
command: mockCommand,
|
|
95
|
+
os: 'macos',
|
|
96
|
+
nodeVersion: mockNodeVersion,
|
|
97
|
+
nodeMajorVersion: 'v16',
|
|
98
|
+
version: package_json_1.version,
|
|
99
|
+
}), undefined);
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
describe('trackAuthAction()', () => {
|
|
103
|
+
const mockCommand = 'auth-command';
|
|
104
|
+
const mockAuthType = 'oauth2';
|
|
105
|
+
const mockStep = 'init';
|
|
106
|
+
const mockAccountId = 123;
|
|
107
|
+
it('should not track when tracking is disabled', async () => {
|
|
108
|
+
mockedIsTrackingAllowed.mockReturnValue(false);
|
|
109
|
+
await (0, usageTracking_1.trackAuthAction)(mockCommand, mockAuthType, mockStep, mockAccountId);
|
|
110
|
+
expect(mockedTrackUsage).not.toHaveBeenCalled();
|
|
111
|
+
});
|
|
112
|
+
it('should track auth action', async () => {
|
|
113
|
+
await (0, usageTracking_1.trackAuthAction)(mockCommand, mockAuthType, mockStep, mockAccountId);
|
|
114
|
+
expect(mockedTrackUsage).toHaveBeenCalledWith('cli-interaction', 'INTERACTION', expect.objectContaining({
|
|
115
|
+
action: 'cli-auth',
|
|
116
|
+
command: mockCommand,
|
|
117
|
+
authType: mockAuthType,
|
|
118
|
+
step: mockStep,
|
|
119
|
+
os: 'macos',
|
|
120
|
+
nodeVersion: mockNodeVersion,
|
|
121
|
+
nodeMajorVersion: 'v16',
|
|
122
|
+
version: package_json_1.version,
|
|
123
|
+
}), mockAccountId);
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
describe('trackCommandMetadataUsage()', () => {
|
|
127
|
+
const mockCommand = 'metadata-command';
|
|
128
|
+
const mockMeta = { assetType: 'test-asset' };
|
|
129
|
+
const mockAccountId = 123;
|
|
130
|
+
it('should not track when tracking is disabled', async () => {
|
|
131
|
+
mockedIsTrackingAllowed.mockReturnValue(false);
|
|
132
|
+
await (0, usageTracking_1.trackCommandMetadataUsage)(mockCommand, mockMeta, mockAccountId);
|
|
133
|
+
expect(mockedTrackUsage).not.toHaveBeenCalled();
|
|
134
|
+
});
|
|
135
|
+
it('should track command metadata usage', async () => {
|
|
136
|
+
await (0, usageTracking_1.trackCommandMetadataUsage)(mockCommand, mockMeta, mockAccountId);
|
|
137
|
+
expect(mockedTrackUsage).toHaveBeenCalledWith('cli-interaction', 'INTERACTION', expect.objectContaining({
|
|
138
|
+
action: 'cli-command-metadata',
|
|
139
|
+
command: mockCommand,
|
|
140
|
+
assetType: 'test-asset',
|
|
141
|
+
os: 'macos',
|
|
142
|
+
nodeVersion: mockNodeVersion,
|
|
143
|
+
nodeMajorVersion: 'v16',
|
|
144
|
+
version: package_json_1.version,
|
|
145
|
+
}), mockAccountId);
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
describe('Platform detection', () => {
|
|
149
|
+
it('should return "macos" for darwin platform', async () => {
|
|
150
|
+
Object.defineProperty(process, 'platform', { value: 'darwin' });
|
|
151
|
+
await (0, usageTracking_1.trackHelpUsage)('test');
|
|
152
|
+
expect(mockedTrackUsage).toHaveBeenCalledWith(expect.anything(), expect.anything(), expect.objectContaining({ os: 'macos' }), undefined);
|
|
153
|
+
});
|
|
154
|
+
it('should return "windows" for win32 platform', async () => {
|
|
155
|
+
Object.defineProperty(process, 'platform', { value: 'win32' });
|
|
156
|
+
await (0, usageTracking_1.trackHelpUsage)('test');
|
|
157
|
+
expect(mockedTrackUsage).toHaveBeenCalledWith(expect.anything(), expect.anything(), expect.objectContaining({ os: 'windows' }), undefined);
|
|
158
|
+
});
|
|
159
|
+
it('should return platform name for other platforms', async () => {
|
|
160
|
+
Object.defineProperty(process, 'platform', { value: 'linux' });
|
|
161
|
+
await (0, usageTracking_1.trackHelpUsage)('test');
|
|
162
|
+
expect(mockedTrackUsage).toHaveBeenCalledWith(expect.anything(), expect.anything(), expect.objectContaining({ os: 'linux' }), undefined);
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
4
|
+
const oauth_1 = require("@hubspot/local-dev-lib/oauth");
|
|
5
|
+
const personalAccessKey_1 = require("@hubspot/local-dev-lib/personalAccessKey");
|
|
6
|
+
const validation_1 = require("../validation");
|
|
7
|
+
vi.mock('@hubspot/local-dev-lib/config');
|
|
8
|
+
vi.mock('@hubspot/local-dev-lib/logger');
|
|
9
|
+
vi.mock('@hubspot/local-dev-lib/oauth');
|
|
10
|
+
vi.mock('@hubspot/local-dev-lib/personalAccessKey');
|
|
11
|
+
vi.mock('../commonOpts');
|
|
12
|
+
const yargsOption = (option) => ({
|
|
13
|
+
$0: '',
|
|
14
|
+
_: [''],
|
|
15
|
+
...option,
|
|
16
|
+
});
|
|
17
|
+
describe('lib/validation', () => {
|
|
18
|
+
const getAccountIdMock = config_1.getAccountId;
|
|
19
|
+
const getAccountConfigMock = config_1.getAccountConfig;
|
|
20
|
+
const getOauthManagerMock = oauth_1.getOauthManager;
|
|
21
|
+
const accessTokenForPersonalAccessKeyMock = personalAccessKey_1.accessTokenForPersonalAccessKey;
|
|
22
|
+
describe('validateAccount', () => {
|
|
23
|
+
it('returns false if an account is missing', async () => {
|
|
24
|
+
getAccountIdMock.mockReturnValueOnce(null);
|
|
25
|
+
expect(await (0, validation_1.validateAccount)(yargsOption({ account: '123' }))).toBe(false);
|
|
26
|
+
});
|
|
27
|
+
it('returns false if an account config is missing', async () => {
|
|
28
|
+
getAccountIdMock.mockReturnValueOnce('123');
|
|
29
|
+
getAccountConfigMock.mockReturnValueOnce(undefined);
|
|
30
|
+
expect(await (0, validation_1.validateAccount)(yargsOption({ account: '123' }))).toBe(false);
|
|
31
|
+
});
|
|
32
|
+
it('returns false for oauth2 authType if auth is missing', async () => {
|
|
33
|
+
getAccountIdMock.mockReturnValueOnce('123');
|
|
34
|
+
getAccountConfigMock.mockReturnValueOnce({
|
|
35
|
+
accountId: '123',
|
|
36
|
+
authType: 'oauth2',
|
|
37
|
+
});
|
|
38
|
+
expect(await (0, validation_1.validateAccount)(yargsOption({ account: '123' }))).toBe(false);
|
|
39
|
+
});
|
|
40
|
+
it('returns false if OAuth is missing configuration', async () => {
|
|
41
|
+
getAccountIdMock.mockReturnValueOnce('123');
|
|
42
|
+
getAccountConfigMock.mockReturnValueOnce({
|
|
43
|
+
accountId: '123',
|
|
44
|
+
authType: 'oauth2',
|
|
45
|
+
auth: {
|
|
46
|
+
clientId: 'foo',
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
expect(await (0, validation_1.validateAccount)(yargsOption({ account: '123' }))).toBe(false);
|
|
50
|
+
});
|
|
51
|
+
it('returns false if an access token was not retrieved', async () => {
|
|
52
|
+
getAccountIdMock.mockReturnValueOnce('123');
|
|
53
|
+
getOauthManagerMock.mockReturnValueOnce({
|
|
54
|
+
accessToken() {
|
|
55
|
+
return null;
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
getAccountConfigMock.mockReturnValueOnce({
|
|
59
|
+
accountId: '123',
|
|
60
|
+
authType: 'oauth2',
|
|
61
|
+
auth: {
|
|
62
|
+
clientId: 'foo',
|
|
63
|
+
clientSecret: 'abc',
|
|
64
|
+
tokenInfo: {
|
|
65
|
+
refreshToken: 'def',
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
expect(await (0, validation_1.validateAccount)(yargsOption({ account: '123' }))).toBe(false);
|
|
70
|
+
});
|
|
71
|
+
it('returns false if an getting an access token throws', async () => {
|
|
72
|
+
getAccountIdMock.mockReturnValueOnce('123');
|
|
73
|
+
getOauthManagerMock.mockReturnValueOnce({
|
|
74
|
+
accessToken() {
|
|
75
|
+
throw new Error('It failed');
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
getAccountConfigMock.mockReturnValueOnce({
|
|
79
|
+
accountId: '123',
|
|
80
|
+
authType: 'oauth2',
|
|
81
|
+
auth: {
|
|
82
|
+
clientId: 'foo',
|
|
83
|
+
clientSecret: 'abc',
|
|
84
|
+
tokenInfo: {
|
|
85
|
+
refreshToken: 'def',
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
expect(await (0, validation_1.validateAccount)(yargsOption({ account: '123' }))).toBe(false);
|
|
90
|
+
});
|
|
91
|
+
it('returns true if OAuth is configured and an access token is received', async () => {
|
|
92
|
+
getAccountIdMock.mockReturnValueOnce('123');
|
|
93
|
+
getOauthManagerMock.mockReturnValueOnce({
|
|
94
|
+
accessToken() {
|
|
95
|
+
return 'yep';
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
getAccountConfigMock.mockReturnValueOnce({
|
|
99
|
+
accountId: '123',
|
|
100
|
+
authType: 'oauth2',
|
|
101
|
+
auth: {
|
|
102
|
+
clientId: 'foo',
|
|
103
|
+
clientSecret: 'abc',
|
|
104
|
+
tokenInfo: {
|
|
105
|
+
refreshToken: 'def',
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
expect(await (0, validation_1.validateAccount)(yargsOption({ account: '123' }))).toBe(true);
|
|
110
|
+
});
|
|
111
|
+
it('returns false if "personalaccesskey" configured and getting an access token throws', async () => {
|
|
112
|
+
getAccountIdMock.mockReturnValueOnce('123');
|
|
113
|
+
accessTokenForPersonalAccessKeyMock.mockImplementationOnce(() => {
|
|
114
|
+
throw new Error('It failed');
|
|
115
|
+
});
|
|
116
|
+
getAccountConfigMock.mockReturnValueOnce({
|
|
117
|
+
accountId: '123',
|
|
118
|
+
authType: 'personalaccesskey',
|
|
119
|
+
personalAccessKey: 'foo',
|
|
120
|
+
});
|
|
121
|
+
expect(await (0, validation_1.validateAccount)(yargsOption({ account: '123' }))).toBe(false);
|
|
122
|
+
});
|
|
123
|
+
it('returns true if "personalaccesskey" configured and an access token is received', async () => {
|
|
124
|
+
getAccountIdMock.mockReturnValueOnce('123');
|
|
125
|
+
accessTokenForPersonalAccessKeyMock.mockImplementationOnce(() => {
|
|
126
|
+
return 'secret-stuff';
|
|
127
|
+
});
|
|
128
|
+
getAccountConfigMock.mockReturnValueOnce({
|
|
129
|
+
accountId: '123',
|
|
130
|
+
authType: 'personalaccesskey',
|
|
131
|
+
personalAccessKey: 'foo',
|
|
132
|
+
});
|
|
133
|
+
expect(await (0, validation_1.validateAccount)(yargsOption({ account: '123' }))).toBe(true);
|
|
134
|
+
});
|
|
135
|
+
it('returns true if apiKey is configured and present', async () => {
|
|
136
|
+
getAccountIdMock.mockReturnValueOnce('123');
|
|
137
|
+
getAccountConfigMock.mockReturnValueOnce({
|
|
138
|
+
accountId: '123',
|
|
139
|
+
authType: 'apikey',
|
|
140
|
+
apiKey: 'my-secret-key',
|
|
141
|
+
});
|
|
142
|
+
expect(await (0, validation_1.validateAccount)(yargsOption({ account: '123' }))).toBe(true);
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|