@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,344 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
const axios_1 = require("axios");
|
|
40
|
+
const yargs_1 = __importDefault(require("yargs"));
|
|
41
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
42
|
+
const configUtils = __importStar(require("@hubspot/local-dev-lib/config"));
|
|
43
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
44
|
+
const projectApiUtils = __importStar(require("@hubspot/local-dev-lib/api/projects"));
|
|
45
|
+
const ui = __importStar(require("../../../lib/ui"));
|
|
46
|
+
const commonOpts_1 = require("../../../lib/commonOpts");
|
|
47
|
+
const projectUtils = __importStar(require("../../../lib/projects/config"));
|
|
48
|
+
const projectUrlUtils = __importStar(require("../../../lib/projects/urls"));
|
|
49
|
+
const buildAndDeploy_1 = require("../../../lib/projects/buildAndDeploy");
|
|
50
|
+
const projectNamePrompt = __importStar(require("../../../lib/prompts/projectNamePrompt"));
|
|
51
|
+
const promptUtils = __importStar(require("../../../lib/prompts/promptUtils"));
|
|
52
|
+
const usageTracking_1 = require("../../../lib/usageTracking");
|
|
53
|
+
const exitCodes_1 = require("../../../lib/enums/exitCodes");
|
|
54
|
+
const exampleProject_json_1 = __importDefault(require("./fixtures/exampleProject.json"));
|
|
55
|
+
const testUtils_1 = require("../../../lib/testUtils");
|
|
56
|
+
const deploy_1 = __importDefault(require("../deploy"));
|
|
57
|
+
vi.mock('@hubspot/local-dev-lib/logger');
|
|
58
|
+
vi.mock('@hubspot/local-dev-lib/api/projects');
|
|
59
|
+
vi.mock('@hubspot/local-dev-lib/config');
|
|
60
|
+
vi.mock('../../../lib/commonOpts');
|
|
61
|
+
vi.mock('../../../lib/validation');
|
|
62
|
+
vi.mock('../../../lib/projects/config');
|
|
63
|
+
vi.mock('../../../lib/projects/urls');
|
|
64
|
+
vi.mock('../../../lib/projects/buildAndDeploy');
|
|
65
|
+
vi.mock('../../../lib/prompts/projectNamePrompt');
|
|
66
|
+
vi.mock('../../../lib/prompts/promptUtils');
|
|
67
|
+
vi.mock('../../../lib/usageTracking');
|
|
68
|
+
vi.spyOn(ui, 'uiLine');
|
|
69
|
+
const uiLinkSpy = vi.spyOn(ui, 'uiLink').mockImplementation(text => text);
|
|
70
|
+
const uiCommandReferenceSpy = vi.spyOn(ui, 'uiCommandReference');
|
|
71
|
+
const uiAccountDescriptionSpy = vi.spyOn(ui, 'uiAccountDescription');
|
|
72
|
+
const getProjectConfigSpy = vi.spyOn(projectUtils, 'getProjectConfig');
|
|
73
|
+
const projectNamePromptSpy = vi.spyOn(projectNamePrompt, 'projectNamePrompt');
|
|
74
|
+
const getProjectDetailUrlSpy = vi.spyOn(projectUrlUtils, 'getProjectDetailUrl');
|
|
75
|
+
const fetchProjectSpy = vi.spyOn(projectApiUtils, 'fetchProject');
|
|
76
|
+
const deployProjectSpy = vi.spyOn(projectApiUtils, 'deployProject');
|
|
77
|
+
const getAccountConfigSpy = vi.spyOn(configUtils, 'getAccountConfig');
|
|
78
|
+
const promptUserSpy = vi.spyOn(promptUtils, 'promptUser');
|
|
79
|
+
const processExitSpy = vi.spyOn(process, 'exit');
|
|
80
|
+
const optionsSpy = vi
|
|
81
|
+
.spyOn(yargs_1.default, 'options')
|
|
82
|
+
.mockReturnValue(yargs_1.default);
|
|
83
|
+
const exampleSpy = vi
|
|
84
|
+
.spyOn(yargs_1.default, 'example')
|
|
85
|
+
.mockReturnValue(yargs_1.default);
|
|
86
|
+
const conflictsSpy = vi
|
|
87
|
+
.spyOn(yargs_1.default, 'conflicts')
|
|
88
|
+
.mockReturnValue(yargs_1.default);
|
|
89
|
+
describe('commands/project/deploy', () => {
|
|
90
|
+
const projectFlag = 'project';
|
|
91
|
+
const buildFlag = 'build';
|
|
92
|
+
const profileFlag = 'profile';
|
|
93
|
+
const forceFlag = 'force';
|
|
94
|
+
describe('command', () => {
|
|
95
|
+
it('should have the correct command structure', () => {
|
|
96
|
+
expect(deploy_1.default.command).toEqual('deploy');
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
describe('describe', () => {
|
|
100
|
+
it('should contain the beta tag', () => {
|
|
101
|
+
expect(deploy_1.default.describe).toContain('[BETA]');
|
|
102
|
+
});
|
|
103
|
+
it('should provide a description', () => {
|
|
104
|
+
expect(deploy_1.default.describe).toBeDefined();
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
describe('builder', () => {
|
|
108
|
+
it('should support the correct options', () => {
|
|
109
|
+
deploy_1.default.builder(yargs_1.default);
|
|
110
|
+
expect(conflictsSpy).toHaveBeenCalledTimes(2);
|
|
111
|
+
expect(conflictsSpy).toHaveBeenNthCalledWith(1, profileFlag, projectFlag);
|
|
112
|
+
expect(conflictsSpy).toHaveBeenNthCalledWith(2, profileFlag, 'account');
|
|
113
|
+
expect(optionsSpy).toHaveBeenCalledTimes(1);
|
|
114
|
+
expect(optionsSpy).toHaveBeenCalledWith({
|
|
115
|
+
[projectFlag]: expect.objectContaining({ type: 'string' }),
|
|
116
|
+
[buildFlag]: expect.objectContaining({
|
|
117
|
+
alias: ['build-id'],
|
|
118
|
+
type: 'number',
|
|
119
|
+
}),
|
|
120
|
+
[profileFlag]: expect.objectContaining({
|
|
121
|
+
type: 'string',
|
|
122
|
+
alias: ['p'],
|
|
123
|
+
hidden: true,
|
|
124
|
+
}),
|
|
125
|
+
[forceFlag]: expect.objectContaining({
|
|
126
|
+
type: 'boolean',
|
|
127
|
+
alias: ['f'],
|
|
128
|
+
}),
|
|
129
|
+
});
|
|
130
|
+
expect(commonOpts_1.addConfigOptions).toHaveBeenCalledTimes(1);
|
|
131
|
+
expect(commonOpts_1.addConfigOptions).toHaveBeenCalledWith(yargs_1.default);
|
|
132
|
+
expect(commonOpts_1.addAccountOptions).toHaveBeenCalledTimes(1);
|
|
133
|
+
expect(commonOpts_1.addAccountOptions).toHaveBeenCalledWith(yargs_1.default);
|
|
134
|
+
expect(commonOpts_1.addUseEnvironmentOptions).toHaveBeenCalledTimes(1);
|
|
135
|
+
expect(commonOpts_1.addUseEnvironmentOptions).toHaveBeenCalledWith(yargs_1.default);
|
|
136
|
+
});
|
|
137
|
+
it('should provide examples', () => {
|
|
138
|
+
deploy_1.default.builder(yargs_1.default);
|
|
139
|
+
expect(exampleSpy).toHaveBeenCalledTimes(1);
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
describe('handler', () => {
|
|
143
|
+
let projectConfig;
|
|
144
|
+
const accountType = 'STANDARD';
|
|
145
|
+
let args;
|
|
146
|
+
const projectNameFromPrompt = 'project name from prompt';
|
|
147
|
+
const deployDetails = {
|
|
148
|
+
id: 123,
|
|
149
|
+
};
|
|
150
|
+
const projectDetailUrl = 'http://project-details-page-url.com';
|
|
151
|
+
const viewProjectsInHubSpot = 'View project builds in HubSpot';
|
|
152
|
+
beforeEach(() => {
|
|
153
|
+
args = {
|
|
154
|
+
project: 'project name from options',
|
|
155
|
+
buildId: 2,
|
|
156
|
+
derivedAccountId: 1234567890,
|
|
157
|
+
};
|
|
158
|
+
projectConfig = {
|
|
159
|
+
name: 'project name from config',
|
|
160
|
+
srcDir: 'src',
|
|
161
|
+
platformVersion: '2025',
|
|
162
|
+
};
|
|
163
|
+
getProjectConfigSpy.mockResolvedValue({
|
|
164
|
+
projectConfig,
|
|
165
|
+
projectDir: 'projectDir',
|
|
166
|
+
});
|
|
167
|
+
projectNamePromptSpy.mockResolvedValue({
|
|
168
|
+
projectName: projectNameFromPrompt,
|
|
169
|
+
});
|
|
170
|
+
getProjectDetailUrlSpy.mockReturnValue(projectDetailUrl);
|
|
171
|
+
uiLinkSpy.mockImplementation(text => {
|
|
172
|
+
return text;
|
|
173
|
+
});
|
|
174
|
+
getAccountConfigSpy.mockReturnValue({ accountType, env: 'qa' });
|
|
175
|
+
fetchProjectSpy.mockReturnValue((0, testUtils_1.mockHubSpotHttpResponse)(exampleProject_json_1.default));
|
|
176
|
+
deployProjectSpy.mockReturnValue((0, testUtils_1.mockHubSpotHttpResponse)(deployDetails));
|
|
177
|
+
// Spy on process.exit so our tests don't close when it's called
|
|
178
|
+
// @ts-expect-error Doesn't match the actual signature because then the linter complains about unused variables
|
|
179
|
+
processExitSpy.mockImplementation(() => { });
|
|
180
|
+
});
|
|
181
|
+
it('should load the account config for the correct account id', async () => {
|
|
182
|
+
await deploy_1.default.handler(args);
|
|
183
|
+
expect(getAccountConfigSpy).toHaveBeenCalledTimes(1);
|
|
184
|
+
expect(getAccountConfigSpy).toHaveBeenCalledWith(args.derivedAccountId);
|
|
185
|
+
});
|
|
186
|
+
it('should track the command usage', async () => {
|
|
187
|
+
await deploy_1.default.handler(args);
|
|
188
|
+
expect(usageTracking_1.trackCommandUsage).toHaveBeenCalledTimes(1);
|
|
189
|
+
expect(usageTracking_1.trackCommandUsage).toHaveBeenCalledWith('project-deploy', { type: accountType }, args.derivedAccountId);
|
|
190
|
+
});
|
|
191
|
+
it('should load the project config', async () => {
|
|
192
|
+
await deploy_1.default.handler(args);
|
|
193
|
+
expect(getProjectConfigSpy).toHaveBeenCalledTimes(1);
|
|
194
|
+
expect(getProjectConfigSpy).toHaveBeenCalled();
|
|
195
|
+
});
|
|
196
|
+
it('should prompt for the project name', async () => {
|
|
197
|
+
await deploy_1.default.handler(args);
|
|
198
|
+
expect(projectNamePromptSpy).toHaveBeenCalledTimes(1);
|
|
199
|
+
expect(projectNamePromptSpy).toHaveBeenCalledWith(args.derivedAccountId, {
|
|
200
|
+
project: args.project,
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
it('should use the project name from the config is a project args is not provided', async () => {
|
|
204
|
+
delete args.project;
|
|
205
|
+
await deploy_1.default.handler(args);
|
|
206
|
+
expect(projectNamePromptSpy).toHaveBeenCalledTimes(1);
|
|
207
|
+
expect(projectNamePromptSpy).toHaveBeenCalledWith(args.derivedAccountId, {
|
|
208
|
+
project: projectConfig.name,
|
|
209
|
+
});
|
|
210
|
+
});
|
|
211
|
+
it('should fetch the project details', async () => {
|
|
212
|
+
await deploy_1.default.handler(args);
|
|
213
|
+
expect(fetchProjectSpy).toHaveBeenCalledTimes(1);
|
|
214
|
+
expect(fetchProjectSpy).toHaveBeenCalledWith(args.derivedAccountId, projectNameFromPrompt);
|
|
215
|
+
});
|
|
216
|
+
it('should use the name from the prompt if no others are defined', async () => {
|
|
217
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
218
|
+
const { project: __project, ...argsWithoutProject } = args;
|
|
219
|
+
const promptProjectName = 'project name from the prompt';
|
|
220
|
+
projectNamePromptSpy.mockResolvedValue({
|
|
221
|
+
projectName: promptProjectName,
|
|
222
|
+
});
|
|
223
|
+
getProjectConfigSpy.mockResolvedValue({
|
|
224
|
+
projectConfig: null,
|
|
225
|
+
projectDir: null,
|
|
226
|
+
});
|
|
227
|
+
await deploy_1.default.handler(argsWithoutProject);
|
|
228
|
+
expect(projectNamePromptSpy).toHaveBeenCalledTimes(1);
|
|
229
|
+
expect(projectNamePromptSpy).toHaveBeenCalledWith(args.derivedAccountId, {});
|
|
230
|
+
expect(fetchProjectSpy).toHaveBeenCalledTimes(1);
|
|
231
|
+
expect(fetchProjectSpy).toHaveBeenCalledWith(args.derivedAccountId, promptProjectName);
|
|
232
|
+
});
|
|
233
|
+
it('should log an error and exit when latest build is not defined', async () => {
|
|
234
|
+
fetchProjectSpy.mockReturnValue((0, testUtils_1.mockHubSpotHttpResponse)({}));
|
|
235
|
+
await deploy_1.default.handler(args);
|
|
236
|
+
expect(logger_1.logger.error).toHaveBeenCalledTimes(1);
|
|
237
|
+
expect(logger_1.logger.error).toHaveBeenCalledWith('Deploy error: no builds for this project were found.');
|
|
238
|
+
expect(processExitSpy).toHaveBeenCalledTimes(1);
|
|
239
|
+
expect(processExitSpy).toHaveBeenCalledWith(exitCodes_1.EXIT_CODES.ERROR);
|
|
240
|
+
});
|
|
241
|
+
it('should log an error and exit when buildId option is not a valid build', async () => {
|
|
242
|
+
args.buildId = exampleProject_json_1.default.latestBuild.buildId + 1;
|
|
243
|
+
await deploy_1.default.handler(args);
|
|
244
|
+
expect(uiLinkSpy).toHaveBeenCalledTimes(1);
|
|
245
|
+
expect(uiLinkSpy).toHaveBeenCalledWith(viewProjectsInHubSpot, projectDetailUrl);
|
|
246
|
+
expect(logger_1.logger.error).toHaveBeenCalledTimes(1);
|
|
247
|
+
expect(logger_1.logger.error).toHaveBeenCalledWith(`Build ${args.buildId} does not exist for project ${projectNameFromPrompt}. ${viewProjectsInHubSpot}`);
|
|
248
|
+
expect(processExitSpy).toHaveBeenCalledTimes(1);
|
|
249
|
+
expect(processExitSpy).toHaveBeenCalledWith(exitCodes_1.EXIT_CODES.ERROR);
|
|
250
|
+
});
|
|
251
|
+
it('should log an error and exit when buildId option is already deployed', async () => {
|
|
252
|
+
args.buildId = exampleProject_json_1.default.deployedBuildId;
|
|
253
|
+
await deploy_1.default.handler(args);
|
|
254
|
+
expect(uiLinkSpy).toHaveBeenCalledTimes(1);
|
|
255
|
+
expect(uiLinkSpy).toHaveBeenCalledWith(viewProjectsInHubSpot, projectDetailUrl);
|
|
256
|
+
expect(logger_1.logger.error).toHaveBeenCalledTimes(1);
|
|
257
|
+
expect(logger_1.logger.error).toHaveBeenCalledWith(`Build ${args.buildId} is already deployed. ${viewProjectsInHubSpot}`);
|
|
258
|
+
expect(processExitSpy).toHaveBeenCalledTimes(1);
|
|
259
|
+
expect(processExitSpy).toHaveBeenCalledWith(exitCodes_1.EXIT_CODES.ERROR);
|
|
260
|
+
});
|
|
261
|
+
it('should prompt for build id if no option is provided', async () => {
|
|
262
|
+
delete args.buildId;
|
|
263
|
+
promptUserSpy.mockResolvedValue({
|
|
264
|
+
buildId: exampleProject_json_1.default.latestBuild.buildId,
|
|
265
|
+
});
|
|
266
|
+
await deploy_1.default.handler(args);
|
|
267
|
+
expect(promptUserSpy).toHaveBeenCalledTimes(1);
|
|
268
|
+
});
|
|
269
|
+
it('should log an error and exit if the prompted value is invalid', async () => {
|
|
270
|
+
delete args.buildId;
|
|
271
|
+
promptUserSpy.mockResolvedValue({});
|
|
272
|
+
await deploy_1.default.handler(args);
|
|
273
|
+
expect(promptUserSpy).toHaveBeenCalledTimes(1);
|
|
274
|
+
expect(logger_1.logger.error).toHaveBeenCalledTimes(1);
|
|
275
|
+
expect(logger_1.logger.error).toHaveBeenCalledWith('You must specify a build to deploy');
|
|
276
|
+
expect(processExitSpy).toHaveBeenCalledTimes(1);
|
|
277
|
+
expect(processExitSpy).toHaveBeenCalledWith(exitCodes_1.EXIT_CODES.ERROR);
|
|
278
|
+
});
|
|
279
|
+
it('should deploy the project', async () => {
|
|
280
|
+
await deploy_1.default.handler(args);
|
|
281
|
+
expect(deployProjectSpy).toHaveBeenCalledTimes(1);
|
|
282
|
+
expect(deployProjectSpy).toHaveBeenCalledWith(args.derivedAccountId, projectNameFromPrompt, args.buildId, undefined, undefined);
|
|
283
|
+
});
|
|
284
|
+
it('should log an error and exit when the deploy fails', async () => {
|
|
285
|
+
// @ts-expect-error Testing an edge case where the response is empty
|
|
286
|
+
deployProjectSpy.mockResolvedValue({});
|
|
287
|
+
await deploy_1.default.handler(args);
|
|
288
|
+
expect(logger_1.logger.error).toHaveBeenCalledTimes(1);
|
|
289
|
+
expect(logger_1.logger.error).toHaveBeenCalledWith(`Deploy error: an unknown error occurred.`);
|
|
290
|
+
expect(processExitSpy).toHaveBeenCalledTimes(1);
|
|
291
|
+
expect(processExitSpy).toHaveBeenCalledWith(exitCodes_1.EXIT_CODES.ERROR);
|
|
292
|
+
});
|
|
293
|
+
it('should poll the deploy status', async () => {
|
|
294
|
+
await deploy_1.default.handler(args);
|
|
295
|
+
expect(buildAndDeploy_1.pollDeployStatus).toHaveBeenCalledTimes(1);
|
|
296
|
+
expect(buildAndDeploy_1.pollDeployStatus).toHaveBeenCalledWith(args.derivedAccountId, projectNameFromPrompt, deployDetails.id, args.buildId);
|
|
297
|
+
});
|
|
298
|
+
it('log an error and exit if a 404 status is returned', async () => {
|
|
299
|
+
const commandReference = 'hs project upload';
|
|
300
|
+
const accountDescription = 'SuperCoolTestAccount';
|
|
301
|
+
uiCommandReferenceSpy.mockReturnValueOnce(commandReference);
|
|
302
|
+
uiAccountDescriptionSpy.mockReturnValueOnce(accountDescription);
|
|
303
|
+
fetchProjectSpy.mockImplementation(() => {
|
|
304
|
+
throw (0, testUtils_1.mockHubSpotHttpError)('OH NO', {
|
|
305
|
+
status: axios_1.HttpStatusCode.NotFound,
|
|
306
|
+
data: {},
|
|
307
|
+
});
|
|
308
|
+
});
|
|
309
|
+
await deploy_1.default.handler(args);
|
|
310
|
+
expect(logger_1.logger.error).toHaveBeenCalledTimes(1);
|
|
311
|
+
expect(logger_1.logger.error).toHaveBeenCalledWith(`The project ${chalk_1.default.bold(projectNameFromPrompt)} does not exist in account ${accountDescription}. Run ${commandReference} to upload your project files to HubSpot.`);
|
|
312
|
+
expect(processExitSpy).toHaveBeenCalledTimes(1);
|
|
313
|
+
expect(processExitSpy).toHaveBeenCalledWith(exitCodes_1.EXIT_CODES.ERROR);
|
|
314
|
+
});
|
|
315
|
+
it('log an error and exit if a 400 status is returned', async () => {
|
|
316
|
+
const errorMessage = 'Something bad happened';
|
|
317
|
+
fetchProjectSpy.mockImplementation(() => {
|
|
318
|
+
throw (0, testUtils_1.mockHubSpotHttpError)(errorMessage, {
|
|
319
|
+
status: axios_1.HttpStatusCode.BadRequest,
|
|
320
|
+
data: {},
|
|
321
|
+
});
|
|
322
|
+
});
|
|
323
|
+
await deploy_1.default.handler(args);
|
|
324
|
+
expect(logger_1.logger.error).toHaveBeenCalledTimes(1);
|
|
325
|
+
expect(logger_1.logger.error).toHaveBeenCalledWith('The request was bad.');
|
|
326
|
+
expect(processExitSpy).toHaveBeenCalledTimes(1);
|
|
327
|
+
expect(processExitSpy).toHaveBeenCalledWith(exitCodes_1.EXIT_CODES.ERROR);
|
|
328
|
+
});
|
|
329
|
+
it('log an error another unexpected status code is returned', async () => {
|
|
330
|
+
const errorMessage = 'Something bad happened';
|
|
331
|
+
fetchProjectSpy.mockImplementation(() => {
|
|
332
|
+
throw (0, testUtils_1.mockHubSpotHttpError)(errorMessage, {
|
|
333
|
+
status: axios_1.HttpStatusCode.MethodNotAllowed,
|
|
334
|
+
data: {},
|
|
335
|
+
});
|
|
336
|
+
});
|
|
337
|
+
await deploy_1.default.handler(args);
|
|
338
|
+
expect(logger_1.logger.error).toHaveBeenCalledTimes(1);
|
|
339
|
+
expect(logger_1.logger.error).toHaveBeenCalledWith(`The request for 'project deploy' in account ${args.derivedAccountId} failed due to a client error.`);
|
|
340
|
+
expect(processExitSpy).toHaveBeenCalledTimes(1);
|
|
341
|
+
expect(processExitSpy).toHaveBeenCalledWith(exitCodes_1.EXIT_CODES.ERROR);
|
|
342
|
+
});
|
|
343
|
+
});
|
|
344
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|