@hubspot/cli 7.5.11-experimental.0 → 7.6.0-beta.1
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/bin/cli.js +102 -95
- package/commands/account/auth.d.ts +5 -7
- package/commands/account/auth.js +74 -87
- package/commands/account/clean.d.ts +3 -7
- package/commands/account/clean.js +16 -9
- package/commands/account/createOverride.d.ts +3 -7
- package/commands/account/createOverride.js +23 -6
- package/commands/account/info.d.ts +3 -7
- package/commands/account/info.js +13 -5
- package/commands/account/list.d.ts +3 -7
- package/commands/account/list.js +15 -8
- package/commands/account/remove.d.ts +3 -7
- package/commands/account/remove.js +21 -9
- package/commands/account/removeOverride.d.ts +3 -7
- package/commands/account/removeOverride.js +23 -6
- package/commands/account/rename.d.ts +3 -7
- package/commands/account/rename.js +16 -9
- package/commands/account/use.d.ts +5 -9
- package/commands/account/use.js +14 -6
- package/commands/account.d.ts +3 -4
- package/commands/account.js +33 -58
- package/commands/app/migrate.d.ts +1 -2
- package/commands/app/migrate.js +7 -8
- package/commands/app/secret/add.d.ts +7 -0
- package/commands/app/secret/add.js +64 -0
- package/commands/app/secret/delete.d.ts +8 -0
- package/commands/app/secret/delete.js +87 -0
- package/commands/app/secret/list.d.ts +6 -0
- package/commands/app/secret/list.js +64 -0
- package/commands/app/secret/update.d.ts +7 -0
- package/commands/app/secret/update.js +77 -0
- package/commands/app/secret.d.ts +3 -0
- package/commands/app/secret.js +30 -0
- package/commands/app.d.ts +2 -5
- package/commands/app.js +10 -8
- package/commands/auth.d.ts +5 -7
- package/commands/auth.js +29 -28
- package/commands/cms/convertFields.d.ts +7 -1
- package/commands/cms/convertFields.js +57 -41
- package/commands/cms/getReactModule.d.ts +7 -1
- package/commands/cms/getReactModule.js +52 -34
- package/commands/cms/lighthouseScore.d.ts +8 -1
- package/commands/cms/lighthouseScore.js +129 -100
- package/commands/cms.d.ts +3 -1
- package/commands/cms.js +22 -15
- package/commands/completion.d.ts +3 -1
- package/commands/completion.js +23 -12
- package/commands/config/migrate.d.ts +3 -7
- package/commands/config/migrate.js +37 -46
- package/commands/config/set.d.ts +5 -6
- package/commands/config/set.js +38 -14
- package/commands/config.d.ts +3 -4
- package/commands/config.js +18 -44
- package/commands/create/api-sample.d.ts +3 -1
- package/commands/create/api-sample.js +34 -38
- package/commands/create/app.d.ts +3 -1
- package/commands/create/app.js +9 -7
- package/commands/create/function.d.ts +3 -1
- package/commands/create/function.js +11 -10
- package/commands/create/index.d.ts +5 -1
- package/commands/create/index.js +23 -11
- package/commands/create/module.d.ts +3 -1
- package/commands/create/module.js +14 -13
- package/commands/create/react-app.d.ts +3 -1
- package/commands/create/react-app.js +10 -7
- package/commands/create/template.d.ts +3 -1
- package/commands/create/template.js +14 -14
- package/commands/create/vue-app.d.ts +3 -1
- package/commands/create/vue-app.js +10 -7
- package/commands/create/webpack-serverless.d.ts +3 -1
- package/commands/create/webpack-serverless.js +10 -7
- package/commands/create/website-theme.d.ts +3 -1
- package/commands/create/website-theme.js +10 -9
- package/commands/create.d.ts +4 -24
- package/commands/create.js +62 -74
- package/commands/customObject/create.d.ts +4 -9
- package/commands/customObject/create.js +17 -10
- package/commands/customObject/schema/create.d.ts +4 -9
- package/commands/customObject/schema/create.js +18 -11
- package/commands/customObject/schema/delete.d.ts +4 -9
- package/commands/customObject/schema/delete.js +17 -10
- package/commands/customObject/schema/fetch-all.d.ts +4 -9
- package/commands/customObject/schema/fetch-all.js +17 -10
- package/commands/customObject/schema/fetch.d.ts +4 -9
- package/commands/customObject/schema/fetch.js +17 -10
- package/commands/customObject/schema/list.d.ts +4 -8
- package/commands/customObject/schema/list.js +17 -10
- package/commands/customObject/schema/update.d.ts +4 -9
- package/commands/customObject/schema/update.js +18 -11
- package/commands/customObject/schema.d.ts +3 -5
- package/commands/customObject/schema.js +27 -54
- package/commands/customObject.d.ts +3 -4
- package/commands/customObject.js +18 -45
- package/commands/doctor.d.ts +6 -8
- package/commands/doctor.js +30 -21
- package/commands/feedback.d.ts +4 -1
- package/commands/feedback.js +38 -47
- package/commands/fetch.d.ts +12 -1
- package/commands/fetch.js +49 -33
- package/commands/filemanager/fetch.d.ts +4 -9
- package/commands/filemanager/fetch.js +18 -11
- package/commands/filemanager/upload.d.ts +4 -9
- package/commands/filemanager/upload.js +17 -11
- package/commands/filemanager.d.ts +3 -4
- package/commands/filemanager.js +18 -41
- package/commands/function/deploy.d.ts +6 -1
- package/commands/function/deploy.js +70 -50
- package/commands/function/list.d.ts +6 -1
- package/commands/function/list.js +44 -32
- package/commands/function/server.d.ts +10 -1
- package/commands/function/server.js +49 -38
- package/commands/function.d.ts +5 -1
- package/commands/function.js +22 -10
- package/commands/getStarted.d.ts +9 -0
- package/commands/getStarted.js +227 -0
- package/commands/hubdb/clear.d.ts +4 -9
- package/commands/hubdb/clear.js +17 -10
- package/commands/hubdb/create.d.ts +4 -9
- package/commands/hubdb/create.js +17 -10
- package/commands/hubdb/delete.d.ts +4 -9
- package/commands/hubdb/delete.js +17 -10
- package/commands/hubdb/fetch.d.ts +4 -9
- package/commands/hubdb/fetch.js +17 -10
- package/commands/hubdb/list.d.ts +4 -0
- package/commands/hubdb/list.js +83 -0
- package/commands/hubdb.d.ts +3 -2
- package/commands/hubdb.js +23 -45
- package/commands/init.d.ts +3 -7
- package/commands/init.js +17 -8
- package/commands/lint.d.ts +6 -4
- package/commands/lint.js +42 -43
- package/commands/list.d.ts +3 -7
- package/commands/list.js +17 -11
- package/commands/logs.d.ts +10 -1
- package/commands/logs.js +53 -44
- package/commands/mcp/setup.d.ts +7 -0
- package/commands/mcp/setup.js +52 -0
- package/commands/mcp/start.d.ts +3 -0
- package/commands/mcp/start.js +77 -0
- package/commands/mcp.d.ts +3 -0
- package/commands/mcp.js +26 -0
- package/commands/module/marketplace-validate.d.ts +6 -1
- package/commands/module/marketplace-validate.js +39 -29
- package/commands/module.d.ts +3 -1
- package/commands/module.js +23 -10
- package/commands/mv.d.ts +3 -7
- package/commands/mv.js +17 -11
- package/commands/open.d.ts +3 -7
- package/commands/open.js +17 -11
- package/commands/project/add.d.ts +5 -2
- package/commands/project/add.js +43 -80
- package/commands/project/cloneApp.d.ts +1 -1
- package/commands/project/cloneApp.js +2 -2
- package/commands/project/create.d.ts +2 -8
- package/commands/project/create.js +84 -55
- package/commands/project/deploy.d.ts +2 -0
- package/commands/project/deploy.js +67 -13
- package/commands/project/dev/deprecatedFlow.d.ts +8 -2
- package/commands/project/dev/deprecatedFlow.js +9 -1
- package/commands/project/dev/index.d.ts +1 -4
- package/commands/project/dev/index.js +88 -31
- package/commands/project/dev/unifiedFlow.d.ts +11 -2
- package/commands/project/dev/unifiedFlow.js +81 -41
- package/commands/project/listBuilds.js +2 -5
- package/commands/project/migrate.d.ts +1 -0
- package/commands/project/profile/add.d.ts +7 -0
- package/commands/project/profile/add.js +209 -0
- package/commands/project/profile/delete.d.ts +6 -0
- package/commands/project/profile/delete.js +123 -0
- package/commands/project/profile.d.ts +3 -0
- package/commands/project/profile.js +25 -0
- package/commands/project/upload.d.ts +1 -0
- package/commands/project/upload.js +22 -8
- package/commands/project/validate.d.ts +6 -0
- package/commands/project/validate.js +82 -0
- package/commands/project.js +4 -2
- package/commands/remove.d.ts +3 -7
- package/commands/remove.js +22 -22
- package/commands/sandbox/create.d.ts +4 -9
- package/commands/sandbox/create.js +18 -11
- package/commands/sandbox/delete.d.ts +4 -9
- package/commands/sandbox/delete.js +18 -11
- package/commands/sandbox.d.ts +3 -4
- package/commands/sandbox.js +18 -43
- package/commands/secret/addSecret.d.ts +4 -9
- package/commands/secret/addSecret.js +17 -10
- package/commands/secret/deleteSecret.d.ts +4 -9
- package/commands/secret/deleteSecret.js +17 -10
- package/commands/secret/listSecret.d.ts +4 -9
- package/commands/secret/listSecret.js +17 -10
- package/commands/secret/updateSecret.d.ts +4 -9
- package/commands/secret/updateSecret.js +17 -10
- package/commands/secret.d.ts +3 -4
- package/commands/secret.js +23 -48
- package/commands/testAccount/create.d.ts +6 -0
- package/commands/testAccount/create.js +100 -0
- package/commands/testAccount/createConfig.d.ts +10 -0
- package/commands/testAccount/createConfig.js +98 -0
- package/commands/testAccount/delete.d.ts +6 -0
- package/commands/testAccount/delete.js +48 -0
- package/commands/testAccount.d.ts +3 -0
- package/commands/testAccount.js +28 -0
- package/commands/theme/generate-selectors.d.ts +3 -7
- package/commands/theme/generate-selectors.js +20 -15
- package/commands/theme/marketplace-validate.d.ts +4 -9
- package/commands/theme/marketplace-validate.js +22 -17
- package/commands/theme/preview.d.ts +4 -9
- package/commands/theme/preview.js +32 -26
- package/commands/theme.d.ts +3 -4
- package/commands/theme.js +22 -47
- package/commands/upload.d.ts +12 -1
- package/commands/upload.js +116 -134
- package/commands/watch.d.ts +14 -1
- package/commands/watch.js +74 -75
- package/lang/en.d.ts +1135 -660
- package/lang/en.js +935 -471
- package/lang/en.lyaml +30 -213
- package/lib/accountTypes.js +1 -2
- package/lib/app/migrate.d.ts +23 -0
- package/lib/app/migrate.js +29 -6
- package/lib/app/migrate_legacy.js +7 -7
- package/lib/app/urls.d.ts +16 -0
- package/lib/app/urls.js +16 -0
- package/lib/commonOpts.d.ts +1 -3
- package/lib/commonOpts.js +1 -1
- package/lib/configMigrate.d.ts +2 -2
- package/lib/configMigrate.js +34 -55
- package/lib/configOptions.d.ts +4 -0
- package/lib/configOptions.js +41 -46
- package/lib/constants.d.ts +29 -0
- package/lib/constants.js +30 -1
- package/lib/dependencyManagement.d.ts +0 -5
- package/lib/dependencyManagement.js +13 -39
- package/lib/doctor/Doctor.js +3 -2
- package/lib/errorHandlers/index.js +7 -0
- package/lib/filesystem.d.ts +1 -1
- package/lib/generateSelectors.js +3 -5
- package/lib/interpolation.d.ts +2 -3
- package/lib/lang.d.ts +2 -3
- package/lib/marketplaceValidate.d.ts +12 -2
- package/lib/marketplaceValidate.js +22 -29
- package/lib/mcp/setup.d.ts +21 -0
- package/lib/mcp/setup.js +218 -0
- package/lib/middleware/autoUpdateMiddleware.d.ts +1 -0
- package/lib/middleware/autoUpdateMiddleware.js +89 -0
- package/lib/middleware/configMiddleware.js +23 -0
- package/lib/middleware/fireAlarmMiddleware.d.ts +2 -2
- package/lib/middleware/fireAlarmMiddleware.js +5 -3
- package/lib/npm.d.ts +9 -0
- package/lib/npm.js +36 -0
- package/lib/projectProfiles.d.ts +7 -0
- package/lib/projectProfiles.js +83 -0
- package/lib/projects/add/legacyAddComponent.d.ts +5 -0
- package/lib/projects/add/legacyAddComponent.js +48 -0
- package/lib/projects/add/v3AddComponent.d.ts +8 -0
- package/lib/projects/add/v3AddComponent.js +85 -0
- package/lib/projects/buildAndDeploy.js +18 -3
- package/lib/projects/components.d.ts +2 -0
- package/lib/projects/components.js +82 -0
- package/lib/projects/create/index.d.ts +23 -0
- package/lib/projects/create/index.js +33 -0
- package/lib/projects/create/legacy.d.ts +6 -0
- package/lib/projects/{create.js → create/legacy.js} +20 -11
- package/lib/projects/create/v3.d.ts +27 -0
- package/lib/projects/create/v3.js +158 -0
- package/lib/projects/localDev/AppDevModeInterface.d.ts +30 -0
- package/lib/projects/localDev/AppDevModeInterface.js +215 -0
- package/lib/projects/localDev/DevServerManagerV2.d.ts +11 -22
- package/lib/projects/localDev/DevServerManagerV2.js +19 -15
- package/lib/projects/localDev/LocalDevLogger.d.ts +30 -0
- package/lib/projects/localDev/LocalDevLogger.js +159 -0
- package/lib/projects/localDev/LocalDevManager.js +12 -5
- package/lib/projects/localDev/LocalDevProcess.d.ts +34 -0
- package/lib/projects/localDev/LocalDevProcess.js +201 -0
- package/lib/projects/localDev/LocalDevState.d.ts +50 -0
- package/lib/projects/localDev/LocalDevState.js +119 -0
- package/lib/projects/localDev/LocalDevWatcher.d.ts +10 -0
- package/lib/projects/localDev/LocalDevWatcher.js +53 -0
- package/lib/projects/localDev/LocalDevWebsocketServer.d.ts +20 -0
- package/lib/projects/localDev/LocalDevWebsocketServer.js +131 -0
- package/lib/projects/localDev/helpers.d.ts +3 -2
- package/lib/projects/localDev/helpers.js +32 -2
- package/lib/projects/upload.d.ts +5 -1
- package/lib/projects/upload.js +60 -20
- package/lib/projects/urls.d.ts +3 -0
- package/lib/projects/urls.js +17 -1
- package/lib/prompts/createApiSamplePrompt.d.ts +2 -10
- package/lib/prompts/createDeveloperTestAccountConfigPrompt.d.ts +17 -0
- package/lib/prompts/createDeveloperTestAccountConfigPrompt.js +96 -0
- package/lib/prompts/createProjectPrompt.d.ts +14 -5
- package/lib/prompts/createProjectPrompt.js +38 -13
- package/lib/prompts/createTemplatePrompt.d.ts +22 -4
- package/lib/prompts/installAppPrompt.d.ts +2 -0
- package/lib/prompts/installAppPrompt.js +45 -0
- package/lib/prompts/personalAccessKeyPrompt.js +35 -24
- package/lib/prompts/projectAddPrompt.d.ts +5 -1
- package/lib/prompts/projectAddPrompt.js +35 -7
- package/lib/prompts/projectDevTargetAccountPrompt.d.ts +6 -1
- package/lib/prompts/projectDevTargetAccountPrompt.js +6 -6
- package/lib/prompts/promptUtils.d.ts +4 -1
- package/lib/prompts/promptUtils.js +5 -1
- package/lib/prompts/selectAppPrompt.d.ts +2 -0
- package/lib/prompts/selectAppPrompt.js +40 -0
- package/lib/prompts/{selectPublicAppPrompt.d.ts → selectPublicAppForMigrationPrompt.d.ts} +1 -1
- package/lib/prompts/{selectPublicAppPrompt.js → selectPublicAppForMigrationPrompt.js} +8 -8
- package/lib/prompts/setAsDefaultAccountPrompt.js +10 -0
- package/lib/testUtils.d.ts +3 -3
- package/lib/testUtils.js +8 -9
- package/lib/ui/index.js +4 -1
- package/lib/upload.d.ts +1 -1
- package/lib/validation.js +4 -5
- package/lib/yargsUtils.d.ts +4 -0
- package/lib/yargsUtils.js +6 -0
- package/mcp-server/server.d.ts +1 -0
- package/mcp-server/server.js +18 -0
- package/mcp-server/tools/index.d.ts +2 -0
- package/mcp-server/tools/index.js +19 -0
- package/mcp-server/tools/project/AddFeatureToProject.d.ts +29 -0
- package/mcp-server/tools/project/AddFeatureToProject.js +85 -0
- package/mcp-server/tools/project/CreateProjectTool.d.ts +35 -0
- package/mcp-server/tools/project/CreateProjectTool.js +104 -0
- package/mcp-server/tools/project/DeployProject.d.ts +20 -0
- package/mcp-server/tools/project/DeployProject.js +50 -0
- package/mcp-server/tools/project/GuidedWalkthroughTool.d.ts +17 -0
- package/mcp-server/tools/project/GuidedWalkthroughTool.js +58 -0
- package/mcp-server/tools/project/UploadProjectTools.d.ts +17 -0
- package/mcp-server/tools/project/UploadProjectTools.js +35 -0
- package/mcp-server/tools/project/ValidateProjectTool.d.ts +17 -0
- package/mcp-server/tools/project/ValidateProjectTool.js +35 -0
- package/mcp-server/tools/project/constants.d.ts +3 -0
- package/mcp-server/tools/project/constants.js +13 -0
- package/mcp-server/types.d.ts +14 -0
- package/mcp-server/types.js +17 -0
- package/mcp-server/utils/command.d.ts +3 -0
- package/mcp-server/utils/command.js +16 -0
- package/mcp-server/utils/content.d.ts +3 -0
- package/mcp-server/utils/content.js +21 -0
- package/mcp-server/utils/project.d.ts +5 -0
- package/mcp-server/utils/project.js +17 -0
- package/package.json +24 -16
- package/types/Cms.d.ts +30 -0
- package/types/Cms.js +2 -0
- package/types/LocalDev.d.ts +35 -0
- package/types/LocalDev.js +2 -0
- package/types/Projects.d.ts +19 -2
- package/types/Prompts.d.ts +0 -7
- package/types/Yargs.d.ts +10 -1
- package/lib/projects/create.d.ts +0 -5
- package/lib/projects/localDev/LocalDevManagerV2.d.ts +0 -64
- package/lib/projects/localDev/LocalDevManagerV2.js +0 -345
- package/lib/prompts/installPublicAppPrompt.d.ts +0 -1
- package/lib/prompts/installPublicAppPrompt.js +0 -41
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const project_parsing_lib_1 = require("@hubspot/project-parsing-lib");
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const LocalDevState_1 = __importDefault(require("./LocalDevState"));
|
|
9
|
+
const LocalDevLogger_1 = __importDefault(require("./LocalDevLogger"));
|
|
10
|
+
const DevServerManagerV2_1 = __importDefault(require("./DevServerManagerV2"));
|
|
11
|
+
const exitCodes_1 = require("../../enums/exitCodes");
|
|
12
|
+
const transform_1 = require("@hubspot/project-parsing-lib/src/lib/transform");
|
|
13
|
+
const config_1 = require("../config");
|
|
14
|
+
const upload_1 = require("../upload");
|
|
15
|
+
const buildAndDeploy_1 = require("../buildAndDeploy");
|
|
16
|
+
class LocalDevProcess {
|
|
17
|
+
state;
|
|
18
|
+
_logger;
|
|
19
|
+
devServerManager;
|
|
20
|
+
constructor(options) {
|
|
21
|
+
this.state = new LocalDevState_1.default(options);
|
|
22
|
+
this._logger = new LocalDevLogger_1.default(this.state);
|
|
23
|
+
this.devServerManager = new DevServerManagerV2_1.default({
|
|
24
|
+
localDevState: this.state,
|
|
25
|
+
logger: this._logger,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
get projectDir() {
|
|
29
|
+
return this.state.projectDir;
|
|
30
|
+
}
|
|
31
|
+
get projectId() {
|
|
32
|
+
return this.state.projectId;
|
|
33
|
+
}
|
|
34
|
+
get projectName() {
|
|
35
|
+
return this.state.projectName;
|
|
36
|
+
}
|
|
37
|
+
get targetProjectAccountId() {
|
|
38
|
+
return this.state.targetProjectAccountId;
|
|
39
|
+
}
|
|
40
|
+
get targetTestingAccountId() {
|
|
41
|
+
return this.state.targetTestingAccountId;
|
|
42
|
+
}
|
|
43
|
+
get projectNodes() {
|
|
44
|
+
return this.state.projectNodes;
|
|
45
|
+
}
|
|
46
|
+
get logger() {
|
|
47
|
+
return this._logger;
|
|
48
|
+
}
|
|
49
|
+
get configFilesUpdatedSinceLastUpload() {
|
|
50
|
+
return this.state.configFilesUpdatedSinceLastUpload;
|
|
51
|
+
}
|
|
52
|
+
async setupDevServers() {
|
|
53
|
+
try {
|
|
54
|
+
await this.devServerManager.setup();
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
catch (e) {
|
|
58
|
+
this.logger.devServerSetupError(e);
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
async startDevServers() {
|
|
63
|
+
try {
|
|
64
|
+
await this.devServerManager.start();
|
|
65
|
+
}
|
|
66
|
+
catch (e) {
|
|
67
|
+
this.logger.devServerStartError(e);
|
|
68
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
async cleanupDevServers() {
|
|
72
|
+
try {
|
|
73
|
+
await this.devServerManager.cleanup();
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
catch (e) {
|
|
77
|
+
this.logger.devServerCleanupError(e);
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
compareLocalProjectToDeployed() {
|
|
82
|
+
const deployedComponentNames = this.state.deployedBuild.subbuildStatuses.map(subbuildStatus => subbuildStatus.buildName);
|
|
83
|
+
const missingProjectNodes = [];
|
|
84
|
+
Object.values(this.projectNodes).forEach(node => {
|
|
85
|
+
if (!deployedComponentNames.includes(node.uid)) {
|
|
86
|
+
const userFriendlyName = (0, transform_1.mapToUserFriendlyName)(node.componentType);
|
|
87
|
+
const label = userFriendlyName ? `[${userFriendlyName}] ` : '';
|
|
88
|
+
missingProjectNodes.push(`${label}${node.uid}`);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
if (missingProjectNodes.length) {
|
|
92
|
+
this.logger.missingComponentsWarning(missingProjectNodes);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
async projectConfigValidForUpload() {
|
|
96
|
+
const { projectConfig } = await (0, config_1.getProjectConfig)();
|
|
97
|
+
if (!projectConfig) {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
Object.keys(projectConfig).forEach(key => {
|
|
101
|
+
const field = key;
|
|
102
|
+
if (projectConfig[field] !== this.state.projectConfig[field]) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
async updateProjectNodes() {
|
|
109
|
+
const intermediateRepresentation = await (0, project_parsing_lib_1.translateForLocalDev)({
|
|
110
|
+
projectSourceDir: path_1.default.join(this.state.projectDir, this.state.projectConfig.srcDir),
|
|
111
|
+
platformVersion: this.state.projectConfig.platformVersion,
|
|
112
|
+
accountId: this.state.targetProjectAccountId,
|
|
113
|
+
}, {
|
|
114
|
+
configFilesUpdatedSinceLastUpload: this.state.configFilesUpdatedSinceLastUpload,
|
|
115
|
+
});
|
|
116
|
+
this.state.projectNodes =
|
|
117
|
+
intermediateRepresentation.intermediateNodesIndexedByUid;
|
|
118
|
+
}
|
|
119
|
+
async handleFileChange(filePath, event) {
|
|
120
|
+
await this.updateProjectNodes();
|
|
121
|
+
try {
|
|
122
|
+
this.devServerManager.fileChange({ filePath, event });
|
|
123
|
+
}
|
|
124
|
+
catch (e) {
|
|
125
|
+
this.logger.fileChangeError(e);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
async handleConfigFileChange(filePath, event) {
|
|
129
|
+
if (event === 'add' || event === 'change') {
|
|
130
|
+
this.state.addUpdatedConfigFileUpdatedSinceLastUpload(filePath);
|
|
131
|
+
}
|
|
132
|
+
await this.updateProjectNodes();
|
|
133
|
+
this.logger.uploadWarning();
|
|
134
|
+
}
|
|
135
|
+
async start() {
|
|
136
|
+
this.logger.resetSpinnies();
|
|
137
|
+
// Local dev currently relies on the existence of a deployed build in the target account
|
|
138
|
+
if (!this.state.deployedBuild) {
|
|
139
|
+
this.logger.noDeployedBuild();
|
|
140
|
+
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
141
|
+
}
|
|
142
|
+
const setupSucceeded = await this.setupDevServers();
|
|
143
|
+
if (!setupSucceeded) {
|
|
144
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
145
|
+
}
|
|
146
|
+
this.logger.startupMessage();
|
|
147
|
+
await this.startDevServers();
|
|
148
|
+
this.logger.monitorConsoleOutput();
|
|
149
|
+
// Verify that there are no mismatches between components in the local project
|
|
150
|
+
// and components in the deployed build of the project.
|
|
151
|
+
this.compareLocalProjectToDeployed();
|
|
152
|
+
}
|
|
153
|
+
async stop(showProgress = true) {
|
|
154
|
+
if (showProgress) {
|
|
155
|
+
this.logger.cleanupStart();
|
|
156
|
+
}
|
|
157
|
+
const cleanupSucceeded = await this.cleanupDevServers();
|
|
158
|
+
if (!cleanupSucceeded) {
|
|
159
|
+
if (showProgress) {
|
|
160
|
+
this.logger.cleanupError();
|
|
161
|
+
}
|
|
162
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
163
|
+
}
|
|
164
|
+
if (showProgress) {
|
|
165
|
+
this.logger.cleanupSuccess();
|
|
166
|
+
}
|
|
167
|
+
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
168
|
+
}
|
|
169
|
+
async uploadProject() {
|
|
170
|
+
this.logger.uploadInitiated();
|
|
171
|
+
const isUploadable = await this.projectConfigValidForUpload();
|
|
172
|
+
if (!isUploadable) {
|
|
173
|
+
this.logger.projectConfigMismatch();
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
176
|
+
const { uploadError } = await (0, upload_1.handleProjectUpload)({
|
|
177
|
+
accountId: this.state.targetProjectAccountId,
|
|
178
|
+
projectConfig: this.state.projectConfig,
|
|
179
|
+
projectDir: this.state.projectDir,
|
|
180
|
+
callbackFunc: buildAndDeploy_1.pollProjectBuildAndDeploy,
|
|
181
|
+
sendIR: true,
|
|
182
|
+
skipValidation: true,
|
|
183
|
+
});
|
|
184
|
+
if (uploadError) {
|
|
185
|
+
this.logger.uploadError(uploadError);
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
this.state.resetConfigFilesUpdatedSinceLastUpload();
|
|
189
|
+
this.updateProjectNodes();
|
|
190
|
+
this.logger.uploadSuccess();
|
|
191
|
+
this.logger.clearUploadWarnings();
|
|
192
|
+
return true;
|
|
193
|
+
}
|
|
194
|
+
addStateListener(key, listener, callOnInit = false) {
|
|
195
|
+
this.state.addListener(key, listener, callOnInit);
|
|
196
|
+
}
|
|
197
|
+
sendDevServerMessage(message) {
|
|
198
|
+
this.state.devServerMessage = message;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
exports.default = LocalDevProcess;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Build } from '@hubspot/local-dev-lib/types/Build';
|
|
2
|
+
import { IntermediateRepresentationNodeLocalDev } from '@hubspot/project-parsing-lib/src/lib/types';
|
|
3
|
+
import { Environment } from '@hubspot/local-dev-lib/types/Config';
|
|
4
|
+
import { ProjectConfig } from '../../../types/Projects';
|
|
5
|
+
import { LocalDevStateConstructorOptions, LocalDevStateListener, AppLocalDevData, LocalDevServerMessage } from '../../../types/LocalDev';
|
|
6
|
+
declare class LocalDevState {
|
|
7
|
+
private _targetProjectAccountId;
|
|
8
|
+
private _targetTestingAccountId;
|
|
9
|
+
private _projectConfig;
|
|
10
|
+
private _projectDir;
|
|
11
|
+
private _projectId;
|
|
12
|
+
private _projectName;
|
|
13
|
+
private _debug;
|
|
14
|
+
private _deployedBuild?;
|
|
15
|
+
private _isGithubLinked;
|
|
16
|
+
private _projectNodes;
|
|
17
|
+
private _env;
|
|
18
|
+
private _listeners;
|
|
19
|
+
private _configFilesUpdatedSinceLastUpload;
|
|
20
|
+
private _appData;
|
|
21
|
+
private _devServerMessage;
|
|
22
|
+
constructor({ targetProjectAccountId, targetTestingAccountId, projectConfig, projectDir, projectId, projectName, debug, deployedBuild, isGithubLinked, initialProjectNodes, env, }: LocalDevStateConstructorOptions);
|
|
23
|
+
private runListeners;
|
|
24
|
+
get targetProjectAccountId(): number;
|
|
25
|
+
get targetTestingAccountId(): number;
|
|
26
|
+
get projectConfig(): ProjectConfig;
|
|
27
|
+
get projectDir(): string;
|
|
28
|
+
get projectId(): number;
|
|
29
|
+
get projectName(): string;
|
|
30
|
+
get debug(): boolean;
|
|
31
|
+
get deployedBuild(): Build | undefined;
|
|
32
|
+
get isGithubLinked(): boolean;
|
|
33
|
+
get projectNodes(): {
|
|
34
|
+
[key: string]: IntermediateRepresentationNodeLocalDev;
|
|
35
|
+
};
|
|
36
|
+
set projectNodes(nodes: {
|
|
37
|
+
[key: string]: IntermediateRepresentationNodeLocalDev;
|
|
38
|
+
});
|
|
39
|
+
get env(): Environment;
|
|
40
|
+
get configFilesUpdatedSinceLastUpload(): Set<string>;
|
|
41
|
+
addUpdatedConfigFileUpdatedSinceLastUpload(filePath: string): void;
|
|
42
|
+
resetConfigFilesUpdatedSinceLastUpload(): void;
|
|
43
|
+
get appData(): Record<string, AppLocalDevData>;
|
|
44
|
+
getAppDataByUid(uid: string): AppLocalDevData | undefined;
|
|
45
|
+
setAppDataForUid(uid: string, appData: AppLocalDevData): void;
|
|
46
|
+
get devServerMessage(): string;
|
|
47
|
+
set devServerMessage(message: LocalDevServerMessage);
|
|
48
|
+
addListener<K extends keyof LocalDevState>(key: K, listener: LocalDevStateListener<K>, callOnInit?: boolean): void;
|
|
49
|
+
}
|
|
50
|
+
export default LocalDevState;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const constants_1 = require("../../constants");
|
|
4
|
+
class LocalDevState {
|
|
5
|
+
_targetProjectAccountId;
|
|
6
|
+
_targetTestingAccountId;
|
|
7
|
+
_projectConfig;
|
|
8
|
+
_projectDir;
|
|
9
|
+
_projectId;
|
|
10
|
+
_projectName;
|
|
11
|
+
_debug;
|
|
12
|
+
_deployedBuild;
|
|
13
|
+
_isGithubLinked;
|
|
14
|
+
_projectNodes;
|
|
15
|
+
_env;
|
|
16
|
+
_listeners;
|
|
17
|
+
_configFilesUpdatedSinceLastUpload;
|
|
18
|
+
_appData;
|
|
19
|
+
_devServerMessage;
|
|
20
|
+
constructor({ targetProjectAccountId, targetTestingAccountId, projectConfig, projectDir, projectId, projectName, debug, deployedBuild, isGithubLinked, initialProjectNodes, env, }) {
|
|
21
|
+
this._targetProjectAccountId = targetProjectAccountId;
|
|
22
|
+
this._targetTestingAccountId = targetTestingAccountId;
|
|
23
|
+
this._projectConfig = projectConfig;
|
|
24
|
+
this._projectDir = projectDir;
|
|
25
|
+
this._projectId = projectId;
|
|
26
|
+
this._projectName = projectName;
|
|
27
|
+
this._debug = debug || false;
|
|
28
|
+
this._deployedBuild = deployedBuild;
|
|
29
|
+
this._isGithubLinked = isGithubLinked;
|
|
30
|
+
this._projectNodes = initialProjectNodes;
|
|
31
|
+
this._env = env;
|
|
32
|
+
this._configFilesUpdatedSinceLastUpload = new Set();
|
|
33
|
+
this._appData = {};
|
|
34
|
+
this._devServerMessage = constants_1.LOCAL_DEV_SERVER_MESSAGE_TYPES.INITIAL;
|
|
35
|
+
this._listeners = {};
|
|
36
|
+
}
|
|
37
|
+
runListeners(key) {
|
|
38
|
+
if (this._listeners[key] && this._listeners[key].length) {
|
|
39
|
+
this._listeners[key].forEach(listener => listener(this[key]));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
get targetProjectAccountId() {
|
|
43
|
+
return this._targetProjectAccountId;
|
|
44
|
+
}
|
|
45
|
+
get targetTestingAccountId() {
|
|
46
|
+
return this._targetTestingAccountId;
|
|
47
|
+
}
|
|
48
|
+
get projectConfig() {
|
|
49
|
+
return {
|
|
50
|
+
...this._projectConfig,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
get projectDir() {
|
|
54
|
+
return this._projectDir;
|
|
55
|
+
}
|
|
56
|
+
get projectId() {
|
|
57
|
+
return this._projectId;
|
|
58
|
+
}
|
|
59
|
+
get projectName() {
|
|
60
|
+
return this._projectName;
|
|
61
|
+
}
|
|
62
|
+
get debug() {
|
|
63
|
+
return this._debug;
|
|
64
|
+
}
|
|
65
|
+
get deployedBuild() {
|
|
66
|
+
return (this._deployedBuild && {
|
|
67
|
+
...this._deployedBuild,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
get isGithubLinked() {
|
|
71
|
+
return this._isGithubLinked;
|
|
72
|
+
}
|
|
73
|
+
get projectNodes() {
|
|
74
|
+
return { ...this._projectNodes };
|
|
75
|
+
}
|
|
76
|
+
set projectNodes(nodes) {
|
|
77
|
+
this._projectNodes = nodes;
|
|
78
|
+
this.runListeners('projectNodes');
|
|
79
|
+
}
|
|
80
|
+
get env() {
|
|
81
|
+
return this._env;
|
|
82
|
+
}
|
|
83
|
+
get configFilesUpdatedSinceLastUpload() {
|
|
84
|
+
return this._configFilesUpdatedSinceLastUpload;
|
|
85
|
+
}
|
|
86
|
+
addUpdatedConfigFileUpdatedSinceLastUpload(filePath) {
|
|
87
|
+
this._configFilesUpdatedSinceLastUpload.add(filePath);
|
|
88
|
+
}
|
|
89
|
+
resetConfigFilesUpdatedSinceLastUpload() {
|
|
90
|
+
this._configFilesUpdatedSinceLastUpload.clear();
|
|
91
|
+
}
|
|
92
|
+
get appData() {
|
|
93
|
+
return { ...this._appData };
|
|
94
|
+
}
|
|
95
|
+
getAppDataByUid(uid) {
|
|
96
|
+
return { ...this._appData[uid] };
|
|
97
|
+
}
|
|
98
|
+
setAppDataForUid(uid, appData) {
|
|
99
|
+
this._appData[uid] = appData;
|
|
100
|
+
this.runListeners('appData');
|
|
101
|
+
}
|
|
102
|
+
get devServerMessage() {
|
|
103
|
+
return this._devServerMessage;
|
|
104
|
+
}
|
|
105
|
+
set devServerMessage(message) {
|
|
106
|
+
this._devServerMessage = message;
|
|
107
|
+
this.runListeners('devServerMessage');
|
|
108
|
+
}
|
|
109
|
+
addListener(key, listener, callOnInit = false) {
|
|
110
|
+
if (!this._listeners[key]) {
|
|
111
|
+
this._listeners[key] = [];
|
|
112
|
+
}
|
|
113
|
+
this._listeners[key].push(listener);
|
|
114
|
+
if (callOnInit) {
|
|
115
|
+
listener(this[key]);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
exports.default = LocalDevState;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import LocalDevProcess from './LocalDevProcess';
|
|
2
|
+
declare class LocalDevWatcher {
|
|
3
|
+
private localDevProcess;
|
|
4
|
+
private watcher;
|
|
5
|
+
constructor(localDevProcess: LocalDevProcess);
|
|
6
|
+
private handleWatchEvent;
|
|
7
|
+
start(): void;
|
|
8
|
+
stop(): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
export default LocalDevWatcher;
|
|
@@ -0,0 +1,53 @@
|
|
|
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 path_1 = __importDefault(require("path"));
|
|
7
|
+
const chokidar_1 = __importDefault(require("chokidar"));
|
|
8
|
+
const constants_1 = require("../../constants");
|
|
9
|
+
const WATCH_EVENTS = {
|
|
10
|
+
add: 'add',
|
|
11
|
+
change: 'change',
|
|
12
|
+
unlink: 'unlink',
|
|
13
|
+
unlinkDir: 'unlinkDir',
|
|
14
|
+
};
|
|
15
|
+
class LocalDevWatcher {
|
|
16
|
+
localDevProcess;
|
|
17
|
+
watcher;
|
|
18
|
+
constructor(localDevProcess) {
|
|
19
|
+
this.localDevProcess = localDevProcess;
|
|
20
|
+
this.watcher = null;
|
|
21
|
+
}
|
|
22
|
+
handleWatchEvent(filePath, event, configPaths) {
|
|
23
|
+
if (configPaths.includes(filePath)) {
|
|
24
|
+
return this.localDevProcess.handleConfigFileChange(filePath, event);
|
|
25
|
+
}
|
|
26
|
+
return this.localDevProcess.handleFileChange(filePath, event);
|
|
27
|
+
}
|
|
28
|
+
start() {
|
|
29
|
+
this.watcher = chokidar_1.default.watch(this.localDevProcess.projectDir, {
|
|
30
|
+
ignoreInitial: true,
|
|
31
|
+
ignored: ['**/dist'],
|
|
32
|
+
});
|
|
33
|
+
const configPaths = Object.values(this.localDevProcess.projectNodes).map(component => component.localDev.componentConfigPath);
|
|
34
|
+
const projectConfigPath = path_1.default.join(this.localDevProcess.projectDir, constants_1.PROJECT_CONFIG_FILE);
|
|
35
|
+
configPaths.push(projectConfigPath);
|
|
36
|
+
this.watcher.on('add', filePath => {
|
|
37
|
+
this.handleWatchEvent(filePath, WATCH_EVENTS.add, configPaths);
|
|
38
|
+
});
|
|
39
|
+
this.watcher.on('change', filePath => {
|
|
40
|
+
this.handleWatchEvent(filePath, WATCH_EVENTS.change, configPaths);
|
|
41
|
+
});
|
|
42
|
+
this.watcher.on('unlink', filePath => {
|
|
43
|
+
this.handleWatchEvent(filePath, WATCH_EVENTS.unlink, configPaths);
|
|
44
|
+
});
|
|
45
|
+
this.watcher.on('unlinkDir', filePath => {
|
|
46
|
+
this.handleWatchEvent(filePath, WATCH_EVENTS.unlinkDir, configPaths);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
async stop() {
|
|
50
|
+
await this.watcher?.close();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.default = LocalDevWatcher;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import LocalDevProcess from './LocalDevProcess';
|
|
2
|
+
declare class LocalDevWebsocketServer {
|
|
3
|
+
private server?;
|
|
4
|
+
private _websocket?;
|
|
5
|
+
private debug?;
|
|
6
|
+
private localDevProcess;
|
|
7
|
+
private ALLOWED_ORIGINS;
|
|
8
|
+
constructor(localDevProcess: LocalDevProcess, debug?: boolean);
|
|
9
|
+
private websocket;
|
|
10
|
+
private log;
|
|
11
|
+
private logError;
|
|
12
|
+
private sendMessage;
|
|
13
|
+
private handleUpload;
|
|
14
|
+
private setupMessageHandlers;
|
|
15
|
+
private sendProjectData;
|
|
16
|
+
private setupStateListeners;
|
|
17
|
+
start(): Promise<void>;
|
|
18
|
+
shutdown(): void;
|
|
19
|
+
}
|
|
20
|
+
export default LocalDevWebsocketServer;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const ws_1 = require("ws");
|
|
4
|
+
const portManager_1 = require("@hubspot/local-dev-lib/portManager");
|
|
5
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
6
|
+
const constants_1 = require("../../constants");
|
|
7
|
+
const en_1 = require("../../../lang/en");
|
|
8
|
+
const SERVER_INSTANCE_ID = 'local-dev-ui-websocket-server';
|
|
9
|
+
const LOG_PREFIX = '[LocalDevWebsocketServer]';
|
|
10
|
+
class LocalDevWebsocketServer {
|
|
11
|
+
server;
|
|
12
|
+
_websocket;
|
|
13
|
+
debug;
|
|
14
|
+
localDevProcess;
|
|
15
|
+
ALLOWED_ORIGINS = [
|
|
16
|
+
'https://app.hubspot.com',
|
|
17
|
+
'https://app.hubspotqa.com',
|
|
18
|
+
'https://local.hubspot.com',
|
|
19
|
+
'https://local.hubspotqa.com',
|
|
20
|
+
];
|
|
21
|
+
constructor(localDevProcess, debug) {
|
|
22
|
+
this.localDevProcess = localDevProcess;
|
|
23
|
+
this.debug = debug;
|
|
24
|
+
}
|
|
25
|
+
websocket() {
|
|
26
|
+
if (!this._websocket) {
|
|
27
|
+
throw new Error(en_1.lib.LocalDevWebsocketServer.errors.notInitialized(LOG_PREFIX));
|
|
28
|
+
}
|
|
29
|
+
return this._websocket;
|
|
30
|
+
}
|
|
31
|
+
log(message) {
|
|
32
|
+
if (this.debug) {
|
|
33
|
+
logger_1.logger.log(LOG_PREFIX, message);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
logError(message) {
|
|
37
|
+
if (this.debug) {
|
|
38
|
+
logger_1.logger.error(LOG_PREFIX, message);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
sendMessage(message) {
|
|
42
|
+
this.websocket().send(JSON.stringify(message));
|
|
43
|
+
}
|
|
44
|
+
async handleUpload() {
|
|
45
|
+
const uploadSuccess = await this.localDevProcess.uploadProject();
|
|
46
|
+
if (uploadSuccess) {
|
|
47
|
+
this.sendMessage({
|
|
48
|
+
type: constants_1.LOCAL_DEV_UI_MESSAGE_SEND_TYPES.UPLOAD_SUCCESS,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
this.sendMessage({
|
|
53
|
+
type: constants_1.LOCAL_DEV_UI_MESSAGE_SEND_TYPES.UPLOAD_FAILURE,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
setupMessageHandlers() {
|
|
58
|
+
this.websocket().on('message', data => {
|
|
59
|
+
try {
|
|
60
|
+
const message = JSON.parse(data.toString());
|
|
61
|
+
if (!message.type) {
|
|
62
|
+
this.logError(en_1.lib.LocalDevWebsocketServer.errors.missingTypeField(data.toString()));
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
switch (message.type) {
|
|
66
|
+
case constants_1.LOCAL_DEV_UI_MESSAGE_RECEIVE_TYPES.UPLOAD:
|
|
67
|
+
this.handleUpload();
|
|
68
|
+
break;
|
|
69
|
+
default:
|
|
70
|
+
this.logError(en_1.lib.LocalDevWebsocketServer.errors.unknownMessageType(message.type));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
catch (e) {
|
|
74
|
+
this.logError(en_1.lib.LocalDevWebsocketServer.errors.invalidJSON(data.toString()));
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
sendProjectData() {
|
|
79
|
+
this.sendMessage({
|
|
80
|
+
type: constants_1.LOCAL_DEV_UI_MESSAGE_SEND_TYPES.UPDATE_PROJECT_DATA,
|
|
81
|
+
data: {
|
|
82
|
+
projectName: this.localDevProcess.projectName,
|
|
83
|
+
projectId: this.localDevProcess.projectId,
|
|
84
|
+
targetProjectAccountId: this.localDevProcess.targetProjectAccountId,
|
|
85
|
+
targetTestingAccountId: this.localDevProcess.targetTestingAccountId,
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
setupStateListeners() {
|
|
90
|
+
this.localDevProcess.addStateListener('projectNodes', nodes => {
|
|
91
|
+
this.sendMessage({
|
|
92
|
+
type: constants_1.LOCAL_DEV_UI_MESSAGE_SEND_TYPES.UPDATE_PROJECT_NODES,
|
|
93
|
+
data: nodes,
|
|
94
|
+
});
|
|
95
|
+
}, true);
|
|
96
|
+
this.localDevProcess.addStateListener('appData', appData => {
|
|
97
|
+
this.sendMessage({
|
|
98
|
+
type: constants_1.LOCAL_DEV_UI_MESSAGE_SEND_TYPES.UPDATE_APP_DATA,
|
|
99
|
+
data: appData,
|
|
100
|
+
});
|
|
101
|
+
}, true);
|
|
102
|
+
}
|
|
103
|
+
async start() {
|
|
104
|
+
const portManagerIsRunning = await (0, portManager_1.isPortManagerServerRunning)();
|
|
105
|
+
if (!portManagerIsRunning) {
|
|
106
|
+
throw new Error(en_1.lib.LocalDevWebsocketServer.errors.portManagerNotRunning(LOG_PREFIX));
|
|
107
|
+
}
|
|
108
|
+
const portData = await (0, portManager_1.requestPorts)([{ instanceId: SERVER_INSTANCE_ID }]);
|
|
109
|
+
const port = portData[SERVER_INSTANCE_ID];
|
|
110
|
+
this.server = new ws_1.WebSocketServer({ port });
|
|
111
|
+
this.log(en_1.lib.LocalDevWebsocketServer.logs.startup(port));
|
|
112
|
+
this.server.on('connection', (ws, req) => {
|
|
113
|
+
const origin = req.headers.origin;
|
|
114
|
+
if (!origin || !this.ALLOWED_ORIGINS.includes(origin)) {
|
|
115
|
+
ws.close(1008, en_1.lib.LocalDevWebsocketServer.errors.originNotAllowed(origin));
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
this._websocket = ws;
|
|
119
|
+
this.sendProjectData();
|
|
120
|
+
this.setupMessageHandlers();
|
|
121
|
+
this.setupStateListeners();
|
|
122
|
+
this.localDevProcess.sendDevServerMessage(constants_1.LOCAL_DEV_SERVER_MESSAGE_TYPES.WEBSOCKET_SERVER_CONNECTED);
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
shutdown() {
|
|
126
|
+
this.server?.close();
|
|
127
|
+
this.server = undefined;
|
|
128
|
+
this._websocket = undefined;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
exports.default = LocalDevWebsocketServer;
|
|
@@ -4,7 +4,7 @@ import { DeveloperTestAccount } from '@hubspot/local-dev-lib/types/developerTest
|
|
|
4
4
|
import { Project } from '@hubspot/local-dev-lib/types/Project';
|
|
5
5
|
import { Build } from '@hubspot/local-dev-lib/types/Build';
|
|
6
6
|
import { ProjectConfig } from '../../../types/Projects';
|
|
7
|
-
import { ProjectDevTargetAccountPromptResponse } from '
|
|
7
|
+
import { ProjectDevTargetAccountPromptResponse } from '../../prompts/projectDevTargetAccountPrompt';
|
|
8
8
|
export declare function confirmDefaultAccountIsTarget(accountConfig: CLIAccount): Promise<void>;
|
|
9
9
|
export declare function checkIfDefaultAccountIsSupported(accountConfig: CLIAccount, hasPublicApps: boolean): Promise<void>;
|
|
10
10
|
export declare function checkIfParentAccountIsAuthed(accountConfig: CLIAccount): void;
|
|
@@ -14,6 +14,7 @@ export declare function createSandboxForLocalDev(accountId: number, accountConfi
|
|
|
14
14
|
export declare function createDeveloperTestAccountForLocalDev(accountId: number, accountConfig: CLIAccount, env: Environment): Promise<number>;
|
|
15
15
|
export declare function useExistingDevTestAccount(env: Environment, account: DeveloperTestAccount): Promise<void>;
|
|
16
16
|
export declare function createNewProjectForLocalDev(projectConfig: ProjectConfig, targetAccountId: number, shouldCreateWithoutConfirmation: boolean, hasPublicApps: boolean): Promise<Project>;
|
|
17
|
-
export declare function createInitialBuildForNewProject(projectConfig: ProjectConfig, projectDir: string, targetAccountId: number, sendIR?: boolean): Promise<Build>;
|
|
17
|
+
export declare function createInitialBuildForNewProject(projectConfig: ProjectConfig, projectDir: string, targetAccountId: number, sendIR?: boolean, profile?: string): Promise<Build>;
|
|
18
18
|
export declare function getAccountHomeUrl(accountId: number): string;
|
|
19
19
|
export declare function hasSandboxes(account: CLIAccount): Promise<boolean>;
|
|
20
|
+
export declare function selectAccountTypePrompt(accountConfig: CLIAccount): Promise<string | null>;
|
|
@@ -15,6 +15,7 @@ exports.createNewProjectForLocalDev = createNewProjectForLocalDev;
|
|
|
15
15
|
exports.createInitialBuildForNewProject = createInitialBuildForNewProject;
|
|
16
16
|
exports.getAccountHomeUrl = getAccountHomeUrl;
|
|
17
17
|
exports.hasSandboxes = hasSandboxes;
|
|
18
|
+
exports.selectAccountTypePrompt = selectAccountTypePrompt;
|
|
18
19
|
const config_1 = require("@hubspot/local-dev-lib/constants/config");
|
|
19
20
|
const index_1 = require("@hubspot/local-dev-lib/errors/index");
|
|
20
21
|
const urls_1 = require("@hubspot/local-dev-lib/urls");
|
|
@@ -212,7 +213,7 @@ async function createNewProjectForLocalDev(projectConfig, targetAccountId, shoul
|
|
|
212
213
|
.publicAppProjectMustExistExplanation
|
|
213
214
|
: en_1.lib.localDevHelpers.createNewProjectForLocalDev
|
|
214
215
|
.projectMustExistExplanation;
|
|
215
|
-
const explanationString = explanationLangFunction(
|
|
216
|
+
const explanationString = explanationLangFunction(projectConfig.name, targetAccountId);
|
|
216
217
|
logger_1.uiLogger.log('');
|
|
217
218
|
(0, ui_1.uiLine)();
|
|
218
219
|
logger_1.uiLogger.log(explanationString);
|
|
@@ -253,7 +254,7 @@ function projectUploadCallback(accountId, projectConfig, tempFile, buildId) {
|
|
|
253
254
|
}
|
|
254
255
|
// Create an initial build if the project was newly created in the account
|
|
255
256
|
// Return the newly deployed build
|
|
256
|
-
async function createInitialBuildForNewProject(projectConfig, projectDir, targetAccountId, sendIR) {
|
|
257
|
+
async function createInitialBuildForNewProject(projectConfig, projectDir, targetAccountId, sendIR, profile) {
|
|
257
258
|
const { result: initialUploadResult, uploadError } = await (0, upload_1.handleProjectUpload)({
|
|
258
259
|
accountId: targetAccountId,
|
|
259
260
|
projectConfig,
|
|
@@ -264,6 +265,7 @@ async function createInitialBuildForNewProject(projectConfig, projectDir, target
|
|
|
264
265
|
forceCreate: true,
|
|
265
266
|
skipValidation: true,
|
|
266
267
|
sendIR,
|
|
268
|
+
profile,
|
|
267
269
|
});
|
|
268
270
|
if (uploadError) {
|
|
269
271
|
if ((0, index_1.isSpecifiedError)(uploadError, {
|
|
@@ -319,3 +321,31 @@ async function hasSandboxes(account) {
|
|
|
319
321
|
return false;
|
|
320
322
|
}
|
|
321
323
|
}
|
|
324
|
+
// Top level prompt to choose the type of account to test on
|
|
325
|
+
async function selectAccountTypePrompt(accountConfig) {
|
|
326
|
+
const hasAccessToSandboxes = await hasSandboxes(accountConfig);
|
|
327
|
+
const result = await (0, promptUtils_1.listPrompt)(en_1.lib.localDevHelpers.selectAccountTypePrompt.message, {
|
|
328
|
+
choices: [
|
|
329
|
+
{
|
|
330
|
+
name: en_1.lib.localDevHelpers.selectAccountTypePrompt
|
|
331
|
+
.developerTestAccountOption,
|
|
332
|
+
value: config_1.HUBSPOT_ACCOUNT_TYPES.DEVELOPER_TEST,
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
name: en_1.lib.localDevHelpers.selectAccountTypePrompt
|
|
336
|
+
.sandboxAccountOption,
|
|
337
|
+
value: config_1.HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX,
|
|
338
|
+
disabled: !hasAccessToSandboxes
|
|
339
|
+
? en_1.lib.localDevHelpers.selectAccountTypePrompt
|
|
340
|
+
.sandboxAccountOptionDisabled
|
|
341
|
+
: false,
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
name: en_1.lib.localDevHelpers.selectAccountTypePrompt
|
|
345
|
+
.productionAccountOption,
|
|
346
|
+
value: null,
|
|
347
|
+
},
|
|
348
|
+
],
|
|
349
|
+
});
|
|
350
|
+
return result;
|
|
351
|
+
}
|
package/lib/projects/upload.d.ts
CHANGED
|
@@ -15,6 +15,10 @@ type HandleProjectUploadArg<T> = {
|
|
|
15
15
|
isUploadCommand?: boolean;
|
|
16
16
|
sendIR?: boolean;
|
|
17
17
|
skipValidation?: boolean;
|
|
18
|
+
profile?: string;
|
|
18
19
|
};
|
|
19
|
-
export declare function handleProjectUpload<T>({ accountId, projectConfig, projectDir, callbackFunc, uploadMessage, forceCreate, isUploadCommand, sendIR, skipValidation, }: HandleProjectUploadArg<T>): Promise<ProjectUploadResult<T>>;
|
|
20
|
+
export declare function handleProjectUpload<T>({ accountId, projectConfig, projectDir, callbackFunc, profile, uploadMessage, forceCreate, isUploadCommand, sendIR, skipValidation, }: HandleProjectUploadArg<T>): Promise<ProjectUploadResult<T>>;
|
|
21
|
+
export declare function validateSourceDirectory(srcDir: string, projectConfig: ProjectConfig): void;
|
|
22
|
+
export declare function validateNoHSMetaMismatch(srcDir: string, projectConfig: ProjectConfig): Promise<void>;
|
|
23
|
+
export declare function handleTranslate(projectDir: string, projectConfig: ProjectConfig, accountId: number, skipValidation: boolean, profile: string | undefined): Promise<unknown>;
|
|
20
24
|
export {};
|