@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,180 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
37
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
38
|
+
const config_2 = require("@hubspot/local-dev-lib/constants/config");
|
|
39
|
+
const developerTestAccounts_1 = require("@hubspot/local-dev-lib/api/developerTestAccounts");
|
|
40
|
+
const testUtils_1 = require("../testUtils");
|
|
41
|
+
const errorHandlers = __importStar(require("../errorHandlers"));
|
|
42
|
+
const developerTestAccounts_2 = require("../developerTestAccounts");
|
|
43
|
+
vi.mock('@hubspot/local-dev-lib/config');
|
|
44
|
+
vi.mock('@hubspot/local-dev-lib/logger');
|
|
45
|
+
vi.mock('@hubspot/local-dev-lib/api/developerTestAccounts');
|
|
46
|
+
vi.mock('../errorHandlers');
|
|
47
|
+
const mockedGetAccountId = config_1.getAccountId;
|
|
48
|
+
const mockedGetConfigAccounts = config_1.getConfigAccounts;
|
|
49
|
+
const mockedFetchDeveloperTestAccounts = developerTestAccounts_1.fetchDeveloperTestAccounts;
|
|
50
|
+
const APP_DEVELOPER_ACCOUNT_1 = {
|
|
51
|
+
name: 'app-developer-1',
|
|
52
|
+
accountId: 123,
|
|
53
|
+
accountType: config_2.HUBSPOT_ACCOUNT_TYPES.APP_DEVELOPER,
|
|
54
|
+
env: 'prod',
|
|
55
|
+
};
|
|
56
|
+
const APP_DEVELOPER_ACCOUNT_2 = {
|
|
57
|
+
name: 'app-developer-2',
|
|
58
|
+
accountId: 456,
|
|
59
|
+
accountType: config_2.HUBSPOT_ACCOUNT_TYPES.APP_DEVELOPER,
|
|
60
|
+
env: 'prod',
|
|
61
|
+
};
|
|
62
|
+
const accounts = [
|
|
63
|
+
APP_DEVELOPER_ACCOUNT_1,
|
|
64
|
+
APP_DEVELOPER_ACCOUNT_2,
|
|
65
|
+
{
|
|
66
|
+
name: 'test-account',
|
|
67
|
+
accountId: 789,
|
|
68
|
+
parentAccountId: APP_DEVELOPER_ACCOUNT_1.accountId,
|
|
69
|
+
accountType: config_2.HUBSPOT_ACCOUNT_TYPES.DEVELOPER_TEST,
|
|
70
|
+
env: 'prod',
|
|
71
|
+
},
|
|
72
|
+
];
|
|
73
|
+
describe('lib/developerTestAccounts', () => {
|
|
74
|
+
describe('getHasDevTestAccounts()', () => {
|
|
75
|
+
it('should return true if there are developer test accounts associated with the account', () => {
|
|
76
|
+
mockedGetAccountId.mockReturnValueOnce(APP_DEVELOPER_ACCOUNT_1.accountId);
|
|
77
|
+
mockedGetConfigAccounts.mockReturnValueOnce(accounts);
|
|
78
|
+
const result = (0, developerTestAccounts_2.getHasDevTestAccounts)(APP_DEVELOPER_ACCOUNT_1);
|
|
79
|
+
expect(result).toBe(true);
|
|
80
|
+
});
|
|
81
|
+
it('should return false if there are no developer test accounts associated with the account', () => {
|
|
82
|
+
mockedGetAccountId.mockReturnValueOnce(APP_DEVELOPER_ACCOUNT_2.accountId);
|
|
83
|
+
mockedGetConfigAccounts.mockReturnValueOnce(accounts);
|
|
84
|
+
const result = (0, developerTestAccounts_2.getHasDevTestAccounts)(APP_DEVELOPER_ACCOUNT_2);
|
|
85
|
+
expect(result).toBe(false);
|
|
86
|
+
});
|
|
87
|
+
it('should return false if there are no accounts configured', () => {
|
|
88
|
+
mockedGetAccountId.mockReturnValueOnce(APP_DEVELOPER_ACCOUNT_1.accountId);
|
|
89
|
+
mockedGetConfigAccounts.mockReturnValueOnce(undefined);
|
|
90
|
+
const result = (0, developerTestAccounts_2.getHasDevTestAccounts)(APP_DEVELOPER_ACCOUNT_1);
|
|
91
|
+
expect(result).toBe(false);
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
describe('validateDevTestAccountUsageLimits()', () => {
|
|
95
|
+
afterEach(() => {
|
|
96
|
+
mockedGetAccountId.mockRestore();
|
|
97
|
+
mockedFetchDeveloperTestAccounts.mockRestore();
|
|
98
|
+
});
|
|
99
|
+
it('should return null if the account id is not found', async () => {
|
|
100
|
+
mockedGetAccountId.mockReturnValueOnce(undefined);
|
|
101
|
+
const result = await (0, developerTestAccounts_2.validateDevTestAccountUsageLimits)(APP_DEVELOPER_ACCOUNT_1);
|
|
102
|
+
expect(result).toBe(null);
|
|
103
|
+
});
|
|
104
|
+
it('should return null if there is no developer test account data', async () => {
|
|
105
|
+
mockedGetAccountId.mockReturnValueOnce(APP_DEVELOPER_ACCOUNT_1.accountId);
|
|
106
|
+
mockedFetchDeveloperTestAccounts.mockResolvedValueOnce({
|
|
107
|
+
data: null,
|
|
108
|
+
});
|
|
109
|
+
const result = await (0, developerTestAccounts_2.validateDevTestAccountUsageLimits)(APP_DEVELOPER_ACCOUNT_1);
|
|
110
|
+
expect(result).toBe(null);
|
|
111
|
+
});
|
|
112
|
+
it('should return the test account data if the account has not reached the limit', async () => {
|
|
113
|
+
mockedGetAccountId.mockReturnValueOnce(APP_DEVELOPER_ACCOUNT_1.accountId);
|
|
114
|
+
const testAccountData = {
|
|
115
|
+
maxTestPortals: 10,
|
|
116
|
+
results: [],
|
|
117
|
+
};
|
|
118
|
+
mockedFetchDeveloperTestAccounts.mockResolvedValueOnce({
|
|
119
|
+
data: testAccountData,
|
|
120
|
+
});
|
|
121
|
+
const result = await (0, developerTestAccounts_2.validateDevTestAccountUsageLimits)(APP_DEVELOPER_ACCOUNT_1);
|
|
122
|
+
expect(result).toEqual(expect.objectContaining(testAccountData));
|
|
123
|
+
});
|
|
124
|
+
it('should throw an error if the account has reached the limit', async () => {
|
|
125
|
+
mockedGetAccountId.mockReturnValueOnce(APP_DEVELOPER_ACCOUNT_1.accountId);
|
|
126
|
+
mockedFetchDeveloperTestAccounts.mockResolvedValueOnce({
|
|
127
|
+
data: {
|
|
128
|
+
maxTestPortals: 0,
|
|
129
|
+
results: [{}],
|
|
130
|
+
},
|
|
131
|
+
});
|
|
132
|
+
await expect((0, developerTestAccounts_2.validateDevTestAccountUsageLimits)(APP_DEVELOPER_ACCOUNT_1)).rejects.toThrow();
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
describe('handleDeveloperTestAccountCreateError()', () => {
|
|
136
|
+
let loggerErrorSpy;
|
|
137
|
+
let logErrorSpy;
|
|
138
|
+
beforeEach(() => {
|
|
139
|
+
loggerErrorSpy = vi.spyOn(logger_1.logger, 'error');
|
|
140
|
+
logErrorSpy = vi.spyOn(errorHandlers, 'logError');
|
|
141
|
+
});
|
|
142
|
+
afterEach(() => {
|
|
143
|
+
loggerErrorSpy.mockRestore();
|
|
144
|
+
logErrorSpy.mockRestore();
|
|
145
|
+
});
|
|
146
|
+
it('should log and throw an error if the account is missing the required scopes', () => {
|
|
147
|
+
const missingScopesError = (0, testUtils_1.mockHubSpotHttpError)('Missing scopes error', {
|
|
148
|
+
status: 403,
|
|
149
|
+
data: {
|
|
150
|
+
message: 'Missing scopes error',
|
|
151
|
+
category: 'MISSING_SCOPES',
|
|
152
|
+
},
|
|
153
|
+
});
|
|
154
|
+
expect(() => (0, developerTestAccounts_2.handleDeveloperTestAccountCreateError)(missingScopesError, APP_DEVELOPER_ACCOUNT_1.accountId, 'prod', 10)).toThrow('Missing scopes error');
|
|
155
|
+
expect(loggerErrorSpy).toHaveBeenCalled();
|
|
156
|
+
});
|
|
157
|
+
it('should log and throw an error if the account is missing the required scopes', () => {
|
|
158
|
+
const portalLimitReachedError = (0, testUtils_1.mockHubSpotHttpError)('Portal limit reached error', {
|
|
159
|
+
status: 400,
|
|
160
|
+
data: {
|
|
161
|
+
message: 'Portal limit reached error',
|
|
162
|
+
errorType: 'TEST_PORTAL_LIMIT_REACHED',
|
|
163
|
+
},
|
|
164
|
+
});
|
|
165
|
+
expect(() => (0, developerTestAccounts_2.handleDeveloperTestAccountCreateError)(portalLimitReachedError, APP_DEVELOPER_ACCOUNT_1.accountId, 'prod', 10)).toThrow('Portal limit reached error');
|
|
166
|
+
expect(loggerErrorSpy).toHaveBeenCalled();
|
|
167
|
+
});
|
|
168
|
+
it('should log a generic error message for an unknown error type', () => {
|
|
169
|
+
const someUnknownError = (0, testUtils_1.mockHubSpotHttpError)('Some unknown error', {
|
|
170
|
+
status: 400,
|
|
171
|
+
data: {
|
|
172
|
+
message: 'Some unknown error',
|
|
173
|
+
category: 'SOME_UNKNOWN_ERROR',
|
|
174
|
+
},
|
|
175
|
+
});
|
|
176
|
+
expect(() => (0, developerTestAccounts_2.handleDeveloperTestAccountCreateError)(someUnknownError, APP_DEVELOPER_ACCOUNT_1.accountId, 'prod', 10)).toThrow('Some unknown error');
|
|
177
|
+
expect(logErrorSpy).toHaveBeenCalled();
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const localDevAuth_1 = require("@hubspot/local-dev-lib/api/localDevAuth");
|
|
4
|
+
const hasFeature_1 = require("../hasFeature");
|
|
5
|
+
vi.mock('@hubspot/local-dev-lib/api/localDevAuth');
|
|
6
|
+
const mockedFetchEnabledFeatures = localDevAuth_1.fetchEnabledFeatures;
|
|
7
|
+
describe('lib/hasFeature', () => {
|
|
8
|
+
describe('hasFeature()', () => {
|
|
9
|
+
const accountId = 123;
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
mockedFetchEnabledFeatures.mockResolvedValueOnce({
|
|
12
|
+
data: {
|
|
13
|
+
enabledFeatures: {
|
|
14
|
+
'feature-1': true,
|
|
15
|
+
'feature-2': false,
|
|
16
|
+
'feature-3': true,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
it('should return true if the feature is enabled', async () => {
|
|
22
|
+
// @ts-expect-error test data
|
|
23
|
+
const result = await (0, hasFeature_1.hasFeature)(accountId, 'feature-1');
|
|
24
|
+
expect(result).toBe(true);
|
|
25
|
+
});
|
|
26
|
+
it('should return false if the feature is not enabled', async () => {
|
|
27
|
+
// @ts-expect-error test data
|
|
28
|
+
const result = await (0, hasFeature_1.hasFeature)(accountId, 'feature-2');
|
|
29
|
+
expect(result).toBe(false);
|
|
30
|
+
});
|
|
31
|
+
it('should return false if the feature is not present', async () => {
|
|
32
|
+
// @ts-expect-error test data
|
|
33
|
+
const result = await (0, hasFeature_1.hasFeature)(accountId, 'feature-4');
|
|
34
|
+
expect(result).toBe(false);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
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 util_1 = __importDefault(require("util"));
|
|
7
|
+
const npm_1 = require("../npm");
|
|
8
|
+
const package_json_1 = __importDefault(require("../../package.json"));
|
|
9
|
+
vi.mock('@hubspot/local-dev-lib/logger');
|
|
10
|
+
vi.mock('../ui/SpinniesManager');
|
|
11
|
+
describe('lib/npm', () => {
|
|
12
|
+
let execMock;
|
|
13
|
+
function mockedPromisify(execMock) {
|
|
14
|
+
return vi
|
|
15
|
+
.fn()
|
|
16
|
+
.mockReturnValue(execMock);
|
|
17
|
+
}
|
|
18
|
+
beforeEach(() => {
|
|
19
|
+
execMock = vi.fn();
|
|
20
|
+
util_1.default.promisify = mockedPromisify(execMock);
|
|
21
|
+
});
|
|
22
|
+
describe('isGloballyInstalled()', () => {
|
|
23
|
+
it('should return true when exec is successful', async () => {
|
|
24
|
+
const actual = await (0, npm_1.isGloballyInstalled)(npm_1.DEFAULT_PACKAGE_MANAGER);
|
|
25
|
+
expect(actual).toBe(true);
|
|
26
|
+
expect(execMock).toHaveBeenCalledTimes(1);
|
|
27
|
+
expect(execMock).toHaveBeenCalledWith(`${npm_1.DEFAULT_PACKAGE_MANAGER} --version`);
|
|
28
|
+
});
|
|
29
|
+
it('should return false when exec is unsuccessful', async () => {
|
|
30
|
+
execMock.mockImplementationOnce(() => {
|
|
31
|
+
throw new Error('unsuccessful');
|
|
32
|
+
});
|
|
33
|
+
util_1.default.promisify = mockedPromisify(execMock);
|
|
34
|
+
const actual = await (0, npm_1.isGloballyInstalled)(npm_1.DEFAULT_PACKAGE_MANAGER);
|
|
35
|
+
expect(actual).toBe(false);
|
|
36
|
+
expect(execMock).toHaveBeenCalledTimes(1);
|
|
37
|
+
expect(execMock).toHaveBeenCalledWith(`${npm_1.DEFAULT_PACKAGE_MANAGER} --version`);
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
describe('getLatestCliVersion()', () => {
|
|
41
|
+
it('should return the version correctly', async () => {
|
|
42
|
+
const latest = '1.0.0';
|
|
43
|
+
const next = '1.0.0.beta.1';
|
|
44
|
+
execMock.mockResolvedValueOnce({
|
|
45
|
+
stdout: JSON.stringify({ latest, next }),
|
|
46
|
+
});
|
|
47
|
+
util_1.default.promisify = mockedPromisify(execMock);
|
|
48
|
+
const actual = await (0, npm_1.getLatestCliVersion)();
|
|
49
|
+
expect(actual).toEqual({ latest, next });
|
|
50
|
+
expect(execMock).toHaveBeenCalledWith(`npm info ${package_json_1.default.name} dist-tags --json`);
|
|
51
|
+
});
|
|
52
|
+
it('should throw any errors that encounter with the check', async () => {
|
|
53
|
+
const errorMessage = 'unsuccessful';
|
|
54
|
+
execMock.mockImplementationOnce(() => {
|
|
55
|
+
throw new Error(errorMessage);
|
|
56
|
+
});
|
|
57
|
+
util_1.default.promisify = mockedPromisify(execMock);
|
|
58
|
+
await expect(() => (0, npm_1.getLatestCliVersion)()).rejects.toThrow(errorMessage);
|
|
59
|
+
expect(execMock).toHaveBeenCalledWith(`npm info ${package_json_1.default.name} dist-tags --json`);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,113 @@
|
|
|
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 express_1 = __importDefault(require("express"));
|
|
7
|
+
const open_1 = __importDefault(require("open"));
|
|
8
|
+
const OAuth2Manager_1 = require("@hubspot/local-dev-lib/models/OAuth2Manager");
|
|
9
|
+
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
10
|
+
const oauth_1 = require("@hubspot/local-dev-lib/oauth");
|
|
11
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
12
|
+
const environments_1 = require("@hubspot/local-dev-lib/constants/environments");
|
|
13
|
+
const auth_1 = require("@hubspot/local-dev-lib/constants/auth");
|
|
14
|
+
const oauth_2 = require("../oauth");
|
|
15
|
+
vi.mock('express');
|
|
16
|
+
vi.mock('open');
|
|
17
|
+
vi.mock('@hubspot/local-dev-lib/models/OAuth2Manager');
|
|
18
|
+
vi.mock('@hubspot/local-dev-lib/config');
|
|
19
|
+
vi.mock('@hubspot/local-dev-lib/oauth');
|
|
20
|
+
vi.mock('@hubspot/local-dev-lib/logger');
|
|
21
|
+
const mockedExpress = express_1.default;
|
|
22
|
+
const mockedOAuth2Manager = OAuth2Manager_1.OAuth2Manager;
|
|
23
|
+
const mockedGetAccountConfig = config_1.getAccountConfig;
|
|
24
|
+
describe('lib/oauth', () => {
|
|
25
|
+
const mockExpressReq = {
|
|
26
|
+
query: { code: 'test-auth-code' },
|
|
27
|
+
};
|
|
28
|
+
const mockExpressResp = { send: vi.fn() };
|
|
29
|
+
const mockAccountConfig = {
|
|
30
|
+
accountId: 123,
|
|
31
|
+
clientId: 'test-client-id',
|
|
32
|
+
clientSecret: 'test-client-secret',
|
|
33
|
+
scopes: ['test-scope'],
|
|
34
|
+
env: environments_1.ENVIRONMENTS.PROD,
|
|
35
|
+
};
|
|
36
|
+
beforeEach(() => {
|
|
37
|
+
mockedExpress.mockReturnValue({
|
|
38
|
+
get: vi.fn().mockImplementation((path, callback) => {
|
|
39
|
+
if (path === '/oauth-callback') {
|
|
40
|
+
callback(mockExpressReq, mockExpressResp);
|
|
41
|
+
}
|
|
42
|
+
}),
|
|
43
|
+
listen: vi.fn().mockReturnValue({ close: vi.fn() }),
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
afterEach(() => {
|
|
47
|
+
vi.clearAllMocks();
|
|
48
|
+
});
|
|
49
|
+
describe('authenticateWithOauth()', () => {
|
|
50
|
+
it('should setup OAuth and authenticate successfully', async () => {
|
|
51
|
+
// Mock successful OAuth flow
|
|
52
|
+
const mockOAuth2Manager = {
|
|
53
|
+
account: mockAccountConfig,
|
|
54
|
+
exchangeForTokens: vi.fn().mockResolvedValue({}),
|
|
55
|
+
};
|
|
56
|
+
mockedOAuth2Manager.mockImplementation(() => mockOAuth2Manager);
|
|
57
|
+
mockedGetAccountConfig.mockReturnValue({
|
|
58
|
+
env: environments_1.ENVIRONMENTS.PROD,
|
|
59
|
+
});
|
|
60
|
+
await (0, oauth_2.authenticateWithOauth)(mockAccountConfig);
|
|
61
|
+
// Verify OAuth2Manager was initialized correctly
|
|
62
|
+
expect(mockedOAuth2Manager).toHaveBeenCalledWith({
|
|
63
|
+
...mockAccountConfig,
|
|
64
|
+
env: environments_1.ENVIRONMENTS.PROD,
|
|
65
|
+
});
|
|
66
|
+
// Verify logger was called
|
|
67
|
+
expect(logger_1.logger.log).toHaveBeenCalledWith('Authorizing');
|
|
68
|
+
// Verify OAuth tokens were added to config
|
|
69
|
+
expect(oauth_1.addOauthToAccountConfig).toHaveBeenCalledWith(mockOAuth2Manager);
|
|
70
|
+
});
|
|
71
|
+
it('should handle missing clientId', async () => {
|
|
72
|
+
const invalidConfig = {
|
|
73
|
+
...mockAccountConfig,
|
|
74
|
+
clientId: undefined,
|
|
75
|
+
};
|
|
76
|
+
mockedOAuth2Manager.mockImplementation(() => ({
|
|
77
|
+
account: invalidConfig,
|
|
78
|
+
}));
|
|
79
|
+
const exitSpy = vi.spyOn(process, 'exit').mockImplementation(() => {
|
|
80
|
+
throw new Error('exit');
|
|
81
|
+
});
|
|
82
|
+
await expect((0, oauth_2.authenticateWithOauth)(invalidConfig)).rejects.toThrow('exit');
|
|
83
|
+
expect(logger_1.logger.error).toHaveBeenCalled();
|
|
84
|
+
expect(exitSpy).toHaveBeenCalled();
|
|
85
|
+
exitSpy.mockRestore();
|
|
86
|
+
});
|
|
87
|
+
it('should use default scopes when none provided', async () => {
|
|
88
|
+
const configWithoutScopes = {
|
|
89
|
+
...mockAccountConfig,
|
|
90
|
+
scopes: undefined,
|
|
91
|
+
};
|
|
92
|
+
const mockOAuth2Manager = {
|
|
93
|
+
account: configWithoutScopes,
|
|
94
|
+
exchangeForTokens: vi.fn().mockResolvedValue({}),
|
|
95
|
+
};
|
|
96
|
+
mockedOAuth2Manager.mockImplementation(() => mockOAuth2Manager);
|
|
97
|
+
await (0, oauth_2.authenticateWithOauth)(configWithoutScopes);
|
|
98
|
+
// Verify default scopes were used
|
|
99
|
+
expect(open_1.default).toHaveBeenCalledWith(expect.stringContaining(encodeURIComponent(auth_1.DEFAULT_OAUTH_SCOPES.join(' '))), expect.anything());
|
|
100
|
+
});
|
|
101
|
+
it('should handle OAuth exchange failure', async () => {
|
|
102
|
+
const mockOAuth2Manager = {
|
|
103
|
+
account: mockAccountConfig,
|
|
104
|
+
exchangeForTokens: vi
|
|
105
|
+
.fn()
|
|
106
|
+
.mockRejectedValue(new Error('Exchange failed')),
|
|
107
|
+
};
|
|
108
|
+
mockedOAuth2Manager.mockImplementation(() => mockOAuth2Manager);
|
|
109
|
+
await (0, oauth_2.authenticateWithOauth)(mockAccountConfig);
|
|
110
|
+
expect(mockExpressResp.send).toHaveBeenCalledWith(expect.stringContaining('Authorization failed'));
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const parsing_1 = require("../parsing");
|
|
4
|
+
describe('lib/parsing', () => {
|
|
5
|
+
describe('parseStringToNumber', () => {
|
|
6
|
+
it('should parse valid integer strings', () => {
|
|
7
|
+
expect((0, parsing_1.parseStringToNumber)('123')).toBe(123);
|
|
8
|
+
expect((0, parsing_1.parseStringToNumber)('0')).toBe(0);
|
|
9
|
+
expect((0, parsing_1.parseStringToNumber)('-456')).toBe(-456);
|
|
10
|
+
expect((0, parsing_1.parseStringToNumber)('999')).toBe(999);
|
|
11
|
+
});
|
|
12
|
+
it('should parse strings with leading zeros', () => {
|
|
13
|
+
expect((0, parsing_1.parseStringToNumber)('007')).toBe(7);
|
|
14
|
+
expect((0, parsing_1.parseStringToNumber)('0123')).toBe(123);
|
|
15
|
+
});
|
|
16
|
+
it('should throw error for strings with leading whitespace', () => {
|
|
17
|
+
expect(() => (0, parsing_1.parseStringToNumber)(' 42')).toThrow('Unable to parse string to number');
|
|
18
|
+
expect(() => (0, parsing_1.parseStringToNumber)('\t123')).toThrow('Unable to parse string to number');
|
|
19
|
+
});
|
|
20
|
+
it('should throw error for invalid number strings', () => {
|
|
21
|
+
expect(() => (0, parsing_1.parseStringToNumber)('abc')).toThrow('Unable to parse string to number');
|
|
22
|
+
expect(() => (0, parsing_1.parseStringToNumber)('')).toThrow('Unable to parse string to number');
|
|
23
|
+
expect(() => (0, parsing_1.parseStringToNumber)('NaN')).toThrow('Unable to parse string to number');
|
|
24
|
+
});
|
|
25
|
+
it('should throw error for strings with non-numeric characters', () => {
|
|
26
|
+
expect(() => (0, parsing_1.parseStringToNumber)('123abc')).toThrow('Unable to parse string to number');
|
|
27
|
+
expect(() => (0, parsing_1.parseStringToNumber)('456def')).toThrow('Unable to parse string to number');
|
|
28
|
+
expect(() => (0, parsing_1.parseStringToNumber)('12.34')).toThrow('Unable to parse string to number');
|
|
29
|
+
});
|
|
30
|
+
it('should throw error for strings with mixed content', () => {
|
|
31
|
+
expect(() => (0, parsing_1.parseStringToNumber)('123 456')).toThrow('Unable to parse string to number');
|
|
32
|
+
expect(() => (0, parsing_1.parseStringToNumber)('1,234')).toThrow('Unable to parse string to number');
|
|
33
|
+
expect(() => (0, parsing_1.parseStringToNumber)('1.23e4')).toThrow('Unable to parse string to number');
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const polling_1 = require("../polling");
|
|
4
|
+
const constants_1 = require("../constants");
|
|
5
|
+
// Helper to create a mock polling callback
|
|
6
|
+
const createMockCallback = (responses) => {
|
|
7
|
+
let callCount = 0;
|
|
8
|
+
return vi.fn(() => {
|
|
9
|
+
const response = responses[callCount];
|
|
10
|
+
callCount++;
|
|
11
|
+
return Promise.resolve({ data: response });
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
describe('lib/polling', () => {
|
|
15
|
+
beforeEach(() => {
|
|
16
|
+
vi.useFakeTimers();
|
|
17
|
+
});
|
|
18
|
+
afterEach(() => {
|
|
19
|
+
vi.useRealTimers();
|
|
20
|
+
});
|
|
21
|
+
describe('poll()', () => {
|
|
22
|
+
it('should resolve when status is SUCCESS', async () => {
|
|
23
|
+
const mockCallback = createMockCallback([
|
|
24
|
+
{ status: polling_1.DEFAULT_POLLING_STATES.STARTED },
|
|
25
|
+
{ status: polling_1.DEFAULT_POLLING_STATES.SUCCESS },
|
|
26
|
+
]);
|
|
27
|
+
const pollPromise = (0, polling_1.poll)(mockCallback);
|
|
28
|
+
// Fast-forward through two polling intervals
|
|
29
|
+
vi.advanceTimersByTime(constants_1.DEFAULT_POLLING_DELAY * 2);
|
|
30
|
+
const result = await pollPromise;
|
|
31
|
+
expect(result.status).toBe(polling_1.DEFAULT_POLLING_STATES.SUCCESS);
|
|
32
|
+
expect(mockCallback).toHaveBeenCalledTimes(2);
|
|
33
|
+
});
|
|
34
|
+
it('should reject when status is ERROR', async () => {
|
|
35
|
+
const mockCallback = createMockCallback([
|
|
36
|
+
{ status: polling_1.DEFAULT_POLLING_STATES.STARTED },
|
|
37
|
+
{ status: polling_1.DEFAULT_POLLING_STATES.ERROR },
|
|
38
|
+
]);
|
|
39
|
+
const pollPromise = (0, polling_1.poll)(mockCallback);
|
|
40
|
+
vi.advanceTimersByTime(constants_1.DEFAULT_POLLING_DELAY * 2);
|
|
41
|
+
await expect(pollPromise).rejects.toEqual({
|
|
42
|
+
status: polling_1.DEFAULT_POLLING_STATES.ERROR,
|
|
43
|
+
});
|
|
44
|
+
expect(mockCallback).toHaveBeenCalledTimes(2);
|
|
45
|
+
});
|
|
46
|
+
it('should reject when status is FAILURE', async () => {
|
|
47
|
+
const mockCallback = createMockCallback([
|
|
48
|
+
{ status: polling_1.DEFAULT_POLLING_STATES.STARTED },
|
|
49
|
+
{ status: polling_1.DEFAULT_POLLING_STATES.FAILURE },
|
|
50
|
+
]);
|
|
51
|
+
const pollPromise = (0, polling_1.poll)(mockCallback);
|
|
52
|
+
vi.advanceTimersByTime(constants_1.DEFAULT_POLLING_DELAY * 2);
|
|
53
|
+
await expect(pollPromise).rejects.toEqual({
|
|
54
|
+
status: polling_1.DEFAULT_POLLING_STATES.FAILURE,
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
it('should reject when status is REVERTED', async () => {
|
|
58
|
+
const mockCallback = createMockCallback([
|
|
59
|
+
{ status: polling_1.DEFAULT_POLLING_STATES.STARTED },
|
|
60
|
+
{ status: polling_1.DEFAULT_POLLING_STATES.REVERTED },
|
|
61
|
+
]);
|
|
62
|
+
const pollPromise = (0, polling_1.poll)(mockCallback);
|
|
63
|
+
vi.advanceTimersByTime(constants_1.DEFAULT_POLLING_DELAY * 2);
|
|
64
|
+
await expect(pollPromise).rejects.toEqual({
|
|
65
|
+
status: polling_1.DEFAULT_POLLING_STATES.REVERTED,
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
it('should reject when callback throws an error', async () => {
|
|
69
|
+
const mockCallback = vi
|
|
70
|
+
.fn()
|
|
71
|
+
.mockRejectedValue(new Error('Network error'));
|
|
72
|
+
const pollPromise = (0, polling_1.poll)(mockCallback);
|
|
73
|
+
vi.advanceTimersByTime(constants_1.DEFAULT_POLLING_DELAY);
|
|
74
|
+
await expect(pollPromise).rejects.toThrow('Network error');
|
|
75
|
+
expect(mockCallback).toHaveBeenCalledTimes(1);
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,90 @@
|
|
|
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 readline_1 = __importDefault(require("readline"));
|
|
7
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
8
|
+
const process_1 = require("../process");
|
|
9
|
+
vi.mock('readline');
|
|
10
|
+
vi.mock('@hubspot/local-dev-lib/logger');
|
|
11
|
+
const mockedReadline = readline_1.default;
|
|
12
|
+
const mockedLogger = logger_1.logger;
|
|
13
|
+
const mockedSetLogLevel = logger_1.setLogLevel;
|
|
14
|
+
const processRemoveListenerSpy = vi.spyOn(process, 'removeAllListeners');
|
|
15
|
+
const processOnSpy = vi.spyOn(process, 'on');
|
|
16
|
+
describe('lib/process', () => {
|
|
17
|
+
describe('handleExit()', () => {
|
|
18
|
+
const mockCallback = vi.fn();
|
|
19
|
+
it('should set up listeners for all termination signals', () => {
|
|
20
|
+
(0, process_1.handleExit)(mockCallback);
|
|
21
|
+
process_1.TERMINATION_SIGNALS.forEach(signal => {
|
|
22
|
+
expect(processRemoveListenerSpy).toHaveBeenCalledWith(signal);
|
|
23
|
+
expect(processOnSpy).toHaveBeenCalledWith(signal, expect.any(Function));
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
it('should handle SIGHUP signal correctly', async () => {
|
|
27
|
+
(0, process_1.handleExit)(mockCallback);
|
|
28
|
+
// Get the callback function passed to process.on for SIGHUP
|
|
29
|
+
const sighupCallback = processOnSpy.mock.calls.find(call => call[0] === 'SIGHUP')?.[1];
|
|
30
|
+
expect(sighupCallback).toBeDefined();
|
|
31
|
+
sighupCallback();
|
|
32
|
+
expect(mockedSetLogLevel).toHaveBeenCalledWith(logger_1.LOG_LEVEL.NONE);
|
|
33
|
+
expect(mockCallback).toHaveBeenCalledWith({ isSIGHUP: true });
|
|
34
|
+
expect(mockedLogger.debug).toHaveBeenCalledWith(expect.stringContaining('SIGHUP'));
|
|
35
|
+
});
|
|
36
|
+
it('should handle non-SIGHUP signals correctly', async () => {
|
|
37
|
+
(0, process_1.handleExit)(mockCallback);
|
|
38
|
+
// Get the callback function passed to process.on for SIGINT
|
|
39
|
+
const sigintCallback = processOnSpy.mock.calls.find(call => call[0] === 'SIGINT')?.[1];
|
|
40
|
+
expect(sigintCallback).toBeDefined();
|
|
41
|
+
sigintCallback();
|
|
42
|
+
expect(mockedSetLogLevel).not.toHaveBeenCalled();
|
|
43
|
+
expect(mockCallback).toHaveBeenCalledWith({ isSIGHUP: false });
|
|
44
|
+
expect(mockedLogger.debug).toHaveBeenCalledWith(expect.stringContaining('SIGINT'));
|
|
45
|
+
});
|
|
46
|
+
it('should prevent duplicate exit handling', async () => {
|
|
47
|
+
(0, process_1.handleExit)(mockCallback);
|
|
48
|
+
// Get the callback function passed to process.on for SIGINT
|
|
49
|
+
const sigintCallback = processOnSpy.mock.calls.find(call => call[0] === 'SIGINT')?.[1];
|
|
50
|
+
expect(sigintCallback).toBeDefined();
|
|
51
|
+
sigintCallback();
|
|
52
|
+
sigintCallback(); // Second call should be ignored
|
|
53
|
+
expect(mockCallback).toHaveBeenCalledTimes(1);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
describe('handleKeypress()', () => {
|
|
57
|
+
const mockCallback = vi.fn();
|
|
58
|
+
it('should set up keypress handling correctly', () => {
|
|
59
|
+
// Mock process.stdin
|
|
60
|
+
Object.defineProperty(process, 'stdin', {
|
|
61
|
+
value: {
|
|
62
|
+
isTTY: true,
|
|
63
|
+
setRawMode: vi.fn(),
|
|
64
|
+
on: vi.fn(),
|
|
65
|
+
removeAllListeners: vi.fn(),
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
mockedReadline.createInterface.mockReturnValue({});
|
|
69
|
+
mockedReadline.emitKeypressEvents.mockImplementation(() => { });
|
|
70
|
+
(0, process_1.handleKeypress)(mockCallback);
|
|
71
|
+
expect(mockedReadline.createInterface).toHaveBeenCalledWith(process.stdin, process.stdout);
|
|
72
|
+
expect(mockedReadline.emitKeypressEvents).toHaveBeenCalledWith(process.stdin);
|
|
73
|
+
expect(process.stdin.setRawMode).toHaveBeenCalledWith(true);
|
|
74
|
+
expect(process.stdin.removeAllListeners).toHaveBeenCalledWith('keypress');
|
|
75
|
+
expect(process.stdin.on).toHaveBeenCalledWith('keypress', expect.any(Function));
|
|
76
|
+
});
|
|
77
|
+
it('should not set raw mode when stdin is not TTY', () => {
|
|
78
|
+
// Mock process.stdin as non-TTY
|
|
79
|
+
Object.defineProperty(process, 'stdin', {
|
|
80
|
+
value: {
|
|
81
|
+
isTTY: false,
|
|
82
|
+
on: vi.fn(),
|
|
83
|
+
removeAllListeners: vi.fn(),
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
(0, process_1.handleKeypress)(mockCallback);
|
|
87
|
+
expect(process.stdin.setRawMode).toBeUndefined();
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|