@hubspot/cli 7.4.8 → 7.4.9-beta.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/commands/account/createOverride.js +9 -0
- package/commands/account/remove.js +6 -1
- package/commands/account/removeOverride.js +9 -0
- 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 +24 -15
- package/commands/completion.d.ts +3 -1
- package/commands/completion.js +25 -12
- 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 +55 -73
- 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 +20 -45
- package/commands/feedback.d.ts +7 -1
- package/commands/feedback.js +36 -20
- package/commands/fetch.d.ts +12 -1
- package/commands/fetch.js +49 -33
- 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 +24 -10
- 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.d.ts +3 -2
- package/commands/hubdb.js +23 -45
- package/commands/lint.d.ts +6 -4
- package/commands/lint.js +44 -43
- package/commands/logs.d.ts +10 -1
- package/commands/logs.js +53 -44
- package/commands/module/marketplace-validate.d.ts +6 -1
- package/commands/module/marketplace-validate.js +39 -27
- package/commands/module.d.ts +3 -1
- package/commands/module.js +22 -10
- package/commands/project/dev/unifiedFlow.js +28 -5
- 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 +20 -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 +25 -48
- package/commands/upload.d.ts +12 -1
- package/commands/upload.js +118 -97
- package/commands/watch.d.ts +14 -1
- package/commands/watch.js +76 -65
- package/lang/en.d.ts +565 -543
- package/lang/en.js +360 -338
- package/lang/en.lyaml +3 -0
- package/lib/constants.d.ts +5 -0
- package/lib/constants.js +6 -1
- package/lib/errorHandlers/suppressError.js +12 -19
- package/lib/filesystem.d.ts +1 -1
- package/lib/interpolation.d.ts +2 -3
- package/lib/lang.d.ts +2 -3
- package/lib/projects/buildAndDeploy.js +17 -2
- package/lib/projects/localDev/AppDevModeInterface.d.ts +25 -0
- package/lib/projects/localDev/AppDevModeInterface.js +117 -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 +158 -0
- package/lib/projects/localDev/LocalDevManager.js +2 -3
- package/lib/projects/localDev/LocalDevProcess.d.ts +41 -0
- package/lib/projects/localDev/LocalDevProcess.js +178 -0
- package/lib/projects/localDev/LocalDevWatcher.d.ts +10 -0
- package/lib/projects/localDev/LocalDevWatcher.js +55 -0
- package/lib/projects/localDev/LocalDevWebsocketServer.d.ts +15 -0
- package/lib/projects/localDev/LocalDevWebsocketServer.js +80 -0
- package/lib/prompts/createApiSamplePrompt.d.ts +2 -10
- package/lib/prompts/createTemplatePrompt.d.ts +22 -4
- package/lib/upload.d.ts +1 -1
- package/lib/yargsUtils.d.ts +4 -0
- package/lib/yargsUtils.js +6 -0
- package/package.json +5 -3
- package/types/Cms.d.ts +30 -0
- package/types/Cms.js +2 -0
- package/types/LocalDev.d.ts +22 -0
- package/types/LocalDev.js +2 -0
- package/types/Yargs.d.ts +5 -0
- package/lib/projects/localDev/LocalDevManagerV2.d.ts +0 -64
- package/lib/projects/localDev/LocalDevManagerV2.js +0 -345
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { IntermediateRepresentationNodeLocalDev } from '@hubspot/project-parsing-lib/src/lib/types';
|
|
2
|
+
import { Build } from '@hubspot/local-dev-lib/types/Build';
|
|
3
|
+
import { Environment } from '@hubspot/local-dev-lib/types/Config';
|
|
4
|
+
import { ProjectConfig } from '../../../types/Projects';
|
|
5
|
+
import LocalDevLogger from './LocalDevLogger';
|
|
6
|
+
type LocalDevProcessConstructorOptions = {
|
|
7
|
+
targetProjectAccountId: number;
|
|
8
|
+
targetTestingAccountId: number;
|
|
9
|
+
projectConfig: ProjectConfig;
|
|
10
|
+
projectDir: string;
|
|
11
|
+
projectId: number;
|
|
12
|
+
debug?: boolean;
|
|
13
|
+
deployedBuild?: Build;
|
|
14
|
+
isGithubLinked: boolean;
|
|
15
|
+
initialProjectNodes: {
|
|
16
|
+
[key: string]: IntermediateRepresentationNodeLocalDev;
|
|
17
|
+
};
|
|
18
|
+
env: Environment;
|
|
19
|
+
};
|
|
20
|
+
declare class LocalDevProcess {
|
|
21
|
+
private state;
|
|
22
|
+
private _logger;
|
|
23
|
+
private devServerManager;
|
|
24
|
+
constructor({ targetProjectAccountId, targetTestingAccountId, projectConfig, projectDir, projectId, debug, deployedBuild, isGithubLinked, initialProjectNodes, env, }: LocalDevProcessConstructorOptions);
|
|
25
|
+
get projectDir(): string;
|
|
26
|
+
get projectNodes(): {
|
|
27
|
+
[key: string]: IntermediateRepresentationNodeLocalDev;
|
|
28
|
+
};
|
|
29
|
+
get logger(): LocalDevLogger;
|
|
30
|
+
private setupDevServers;
|
|
31
|
+
private startDevServers;
|
|
32
|
+
private cleanupDevServers;
|
|
33
|
+
private compareLocalProjectToDeployed;
|
|
34
|
+
private projectConfigValidForUpload;
|
|
35
|
+
handleFileChange(filePath: string, event: string): void;
|
|
36
|
+
start(): Promise<void>;
|
|
37
|
+
stop(showProgress?: boolean): Promise<void>;
|
|
38
|
+
updateProjectNodes(): Promise<void>;
|
|
39
|
+
uploadProject(): Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
export default LocalDevProcess;
|
|
@@ -0,0 +1,178 @@
|
|
|
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 LocalDevLogger_1 = __importDefault(require("./LocalDevLogger"));
|
|
9
|
+
const DevServerManagerV2_1 = __importDefault(require("./DevServerManagerV2"));
|
|
10
|
+
const exitCodes_1 = require("../../enums/exitCodes");
|
|
11
|
+
const transform_1 = require("@hubspot/project-parsing-lib/src/lib/transform");
|
|
12
|
+
const config_1 = require("../config");
|
|
13
|
+
const upload_1 = require("../upload");
|
|
14
|
+
const buildAndDeploy_1 = require("../buildAndDeploy");
|
|
15
|
+
class LocalDevProcess {
|
|
16
|
+
state;
|
|
17
|
+
_logger;
|
|
18
|
+
devServerManager;
|
|
19
|
+
constructor({ targetProjectAccountId, targetTestingAccountId, projectConfig, projectDir, projectId, debug, deployedBuild, isGithubLinked, initialProjectNodes, env, }) {
|
|
20
|
+
this.state = {
|
|
21
|
+
targetProjectAccountId,
|
|
22
|
+
targetTestingAccountId,
|
|
23
|
+
projectConfig,
|
|
24
|
+
projectDir,
|
|
25
|
+
projectId,
|
|
26
|
+
debug: debug || false,
|
|
27
|
+
deployedBuild,
|
|
28
|
+
isGithubLinked,
|
|
29
|
+
projectNodes: initialProjectNodes,
|
|
30
|
+
env,
|
|
31
|
+
};
|
|
32
|
+
this._logger = new LocalDevLogger_1.default(this.state);
|
|
33
|
+
this.devServerManager = new DevServerManagerV2_1.default({
|
|
34
|
+
localDevState: this.state,
|
|
35
|
+
logger: this._logger,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
get projectDir() {
|
|
39
|
+
return this.state.projectDir;
|
|
40
|
+
}
|
|
41
|
+
get projectNodes() {
|
|
42
|
+
return this.state.projectNodes;
|
|
43
|
+
}
|
|
44
|
+
get logger() {
|
|
45
|
+
return this._logger;
|
|
46
|
+
}
|
|
47
|
+
async setupDevServers() {
|
|
48
|
+
try {
|
|
49
|
+
await this.devServerManager.setup();
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
catch (e) {
|
|
53
|
+
this.logger.devServerSetupError(e);
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
async startDevServers() {
|
|
58
|
+
try {
|
|
59
|
+
await this.devServerManager.start();
|
|
60
|
+
}
|
|
61
|
+
catch (e) {
|
|
62
|
+
this.logger.devServerStartError(e);
|
|
63
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
async cleanupDevServers() {
|
|
67
|
+
try {
|
|
68
|
+
await this.devServerManager.cleanup();
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
catch (e) {
|
|
72
|
+
this.logger.devServerCleanupError(e);
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
compareLocalProjectToDeployed() {
|
|
77
|
+
const deployedComponentNames = this.state.deployedBuild.subbuildStatuses.map(subbuildStatus => subbuildStatus.buildName);
|
|
78
|
+
const missingProjectNodes = [];
|
|
79
|
+
Object.values(this.projectNodes).forEach(node => {
|
|
80
|
+
if (!deployedComponentNames.includes(node.uid)) {
|
|
81
|
+
const userFriendlyName = (0, transform_1.mapToUserFriendlyName)(node.componentType);
|
|
82
|
+
const label = userFriendlyName ? `[${userFriendlyName}] ` : '';
|
|
83
|
+
missingProjectNodes.push(`${label}${node.uid}`);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
if (missingProjectNodes.length) {
|
|
87
|
+
this.logger.missingComponentsWarning(missingProjectNodes);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
async projectConfigValidForUpload() {
|
|
91
|
+
const { projectConfig } = await (0, config_1.getProjectConfig)();
|
|
92
|
+
if (!projectConfig) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
Object.keys(projectConfig).forEach(key => {
|
|
96
|
+
const field = key;
|
|
97
|
+
if (projectConfig[field] !== this.state.projectConfig[field]) {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
handleFileChange(filePath, event) {
|
|
104
|
+
try {
|
|
105
|
+
this.devServerManager.fileChange({ filePath, event });
|
|
106
|
+
}
|
|
107
|
+
catch (e) {
|
|
108
|
+
this.logger.fileChangeError(e);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
async start() {
|
|
112
|
+
this.logger.resetSpinnies();
|
|
113
|
+
// Local dev currently relies on the existence of a deployed build in the target account
|
|
114
|
+
if (!this.state.deployedBuild) {
|
|
115
|
+
this.logger.noDeployedBuild();
|
|
116
|
+
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
117
|
+
}
|
|
118
|
+
const setupSucceeded = await this.setupDevServers();
|
|
119
|
+
if (!setupSucceeded) {
|
|
120
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
121
|
+
}
|
|
122
|
+
this.logger.startupMessage();
|
|
123
|
+
await this.startDevServers();
|
|
124
|
+
this.logger.monitorConsoleOutput();
|
|
125
|
+
// Verify that there are no mismatches between components in the local project
|
|
126
|
+
// and components in the deployed build of the project.
|
|
127
|
+
this.compareLocalProjectToDeployed();
|
|
128
|
+
}
|
|
129
|
+
async stop(showProgress = true) {
|
|
130
|
+
if (showProgress) {
|
|
131
|
+
this.logger.cleanupStart();
|
|
132
|
+
}
|
|
133
|
+
const cleanupSucceeded = await this.cleanupDevServers();
|
|
134
|
+
if (!cleanupSucceeded) {
|
|
135
|
+
if (showProgress) {
|
|
136
|
+
this.logger.cleanupError();
|
|
137
|
+
}
|
|
138
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
139
|
+
}
|
|
140
|
+
if (showProgress) {
|
|
141
|
+
this.logger.cleanupSuccess();
|
|
142
|
+
}
|
|
143
|
+
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
144
|
+
}
|
|
145
|
+
async updateProjectNodes() {
|
|
146
|
+
const intermediateRepresentation = await (0, project_parsing_lib_1.translateForLocalDev)({
|
|
147
|
+
projectSourceDir: path_1.default.join(this.state.projectDir, this.state.projectConfig.srcDir),
|
|
148
|
+
platformVersion: this.state.projectConfig.platformVersion,
|
|
149
|
+
accountId: this.state.targetProjectAccountId,
|
|
150
|
+
});
|
|
151
|
+
this.state.projectNodes =
|
|
152
|
+
intermediateRepresentation.intermediateNodesIndexedByUid;
|
|
153
|
+
}
|
|
154
|
+
async uploadProject() {
|
|
155
|
+
this.logger.uploadInitiated();
|
|
156
|
+
const isUploadable = await this.projectConfigValidForUpload();
|
|
157
|
+
if (!isUploadable) {
|
|
158
|
+
this.logger.projectConfigMismatch();
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
const { uploadError } = await (0, upload_1.handleProjectUpload)({
|
|
162
|
+
accountId: this.state.targetProjectAccountId,
|
|
163
|
+
projectConfig: this.state.projectConfig,
|
|
164
|
+
projectDir: this.state.projectDir,
|
|
165
|
+
callbackFunc: buildAndDeploy_1.pollProjectBuildAndDeploy,
|
|
166
|
+
sendIR: true,
|
|
167
|
+
skipValidation: true,
|
|
168
|
+
});
|
|
169
|
+
if (uploadError) {
|
|
170
|
+
this.logger.uploadError(uploadError);
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
this.logger.uploadSuccess();
|
|
174
|
+
this.logger.clearUploadWarnings();
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
exports.default = LocalDevProcess;
|
|
@@ -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,55 @@
|
|
|
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
|
+
async handleWatchEvent(filePath, event, configPaths) {
|
|
23
|
+
await this.localDevProcess.updateProjectNodes();
|
|
24
|
+
if (configPaths.includes(filePath)) {
|
|
25
|
+
this.localDevProcess.logger.uploadWarning();
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
this.localDevProcess.handleFileChange(filePath, event);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
start() {
|
|
32
|
+
this.watcher = chokidar_1.default.watch(this.localDevProcess.projectDir, {
|
|
33
|
+
ignoreInitial: true,
|
|
34
|
+
});
|
|
35
|
+
const configPaths = Object.values(this.localDevProcess.projectNodes).map(component => component.localDev.componentConfigPath);
|
|
36
|
+
const projectConfigPath = path_1.default.join(this.localDevProcess.projectDir, constants_1.PROJECT_CONFIG_FILE);
|
|
37
|
+
configPaths.push(projectConfigPath);
|
|
38
|
+
this.watcher.on('add', filePath => {
|
|
39
|
+
this.handleWatchEvent(filePath, WATCH_EVENTS.add, configPaths);
|
|
40
|
+
});
|
|
41
|
+
this.watcher.on('change', filePath => {
|
|
42
|
+
this.handleWatchEvent(filePath, WATCH_EVENTS.change, configPaths);
|
|
43
|
+
});
|
|
44
|
+
this.watcher.on('unlink', filePath => {
|
|
45
|
+
this.handleWatchEvent(filePath, WATCH_EVENTS.unlink, configPaths);
|
|
46
|
+
});
|
|
47
|
+
this.watcher.on('unlinkDir', filePath => {
|
|
48
|
+
this.handleWatchEvent(filePath, WATCH_EVENTS.unlinkDir, configPaths);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
async stop() {
|
|
52
|
+
await this.watcher?.close();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.default = LocalDevWatcher;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import LocalDevProcess from './LocalDevProcess';
|
|
2
|
+
declare class LocalDevWebsocketServer {
|
|
3
|
+
private server?;
|
|
4
|
+
private _websocket?;
|
|
5
|
+
private debug?;
|
|
6
|
+
private localDevProcess;
|
|
7
|
+
constructor(localDevProcess: LocalDevProcess, debug?: boolean);
|
|
8
|
+
private websocket;
|
|
9
|
+
private log;
|
|
10
|
+
private logError;
|
|
11
|
+
private setupMessageHandlers;
|
|
12
|
+
start(): Promise<void>;
|
|
13
|
+
shutdown(): void;
|
|
14
|
+
}
|
|
15
|
+
export default LocalDevWebsocketServer;
|
|
@@ -0,0 +1,80 @@
|
|
|
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
|
+
constructor(localDevProcess, debug) {
|
|
16
|
+
this.localDevProcess = localDevProcess;
|
|
17
|
+
this.debug = debug;
|
|
18
|
+
}
|
|
19
|
+
websocket() {
|
|
20
|
+
if (!this._websocket) {
|
|
21
|
+
throw new Error(en_1.lib.LocalDevWebsocketServer.errors.notInitialized(LOG_PREFIX));
|
|
22
|
+
}
|
|
23
|
+
return this._websocket;
|
|
24
|
+
}
|
|
25
|
+
log(message) {
|
|
26
|
+
if (this.debug) {
|
|
27
|
+
logger_1.logger.log(LOG_PREFIX, message);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
logError(message) {
|
|
31
|
+
if (this.debug) {
|
|
32
|
+
logger_1.logger.error(LOG_PREFIX, message);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
setupMessageHandlers() {
|
|
36
|
+
this.websocket().on('message', data => {
|
|
37
|
+
try {
|
|
38
|
+
const message = JSON.parse(data.toString());
|
|
39
|
+
if (!message.type) {
|
|
40
|
+
this.logError(en_1.lib.LocalDevWebsocketServer.errors.missingTypeField(data.toString()));
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
switch (message.type) {
|
|
44
|
+
case constants_1.LOCAL_DEV_UI_WEBSOCKET_MESSAGE_TYPES.UPLOAD:
|
|
45
|
+
this.localDevProcess.uploadProject();
|
|
46
|
+
break;
|
|
47
|
+
case constants_1.LOCAL_DEV_UI_WEBSOCKET_MESSAGE_TYPES.INSTALL_DEPS:
|
|
48
|
+
break;
|
|
49
|
+
case constants_1.LOCAL_DEV_UI_WEBSOCKET_MESSAGE_TYPES.APP_INSTALLED:
|
|
50
|
+
break;
|
|
51
|
+
default:
|
|
52
|
+
this.logError(en_1.lib.LocalDevWebsocketServer.errors.unknownMessageType(message.type));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
catch (e) {
|
|
56
|
+
this.logError(en_1.lib.LocalDevWebsocketServer.errors.invalidJSON(data.toString()));
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
async start() {
|
|
61
|
+
const portManagerIsRunning = await (0, portManager_1.isPortManagerServerRunning)();
|
|
62
|
+
if (!portManagerIsRunning) {
|
|
63
|
+
throw new Error(en_1.lib.LocalDevWebsocketServer.errors.portManagerNotRunning(LOG_PREFIX));
|
|
64
|
+
}
|
|
65
|
+
const portData = await (0, portManager_1.requestPorts)([{ instanceId: SERVER_INSTANCE_ID }]);
|
|
66
|
+
const port = portData[SERVER_INSTANCE_ID];
|
|
67
|
+
this.server = new ws_1.WebSocketServer({ port });
|
|
68
|
+
this.log(en_1.lib.LocalDevWebsocketServer.logs.startup(port));
|
|
69
|
+
this.server.on('connection', ws => {
|
|
70
|
+
this._websocket = ws;
|
|
71
|
+
this.setupMessageHandlers();
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
shutdown() {
|
|
75
|
+
this.server?.close();
|
|
76
|
+
this.server = undefined;
|
|
77
|
+
this._websocket = undefined;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.default = LocalDevWebsocketServer;
|
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
name: string;
|
|
3
|
-
description: string;
|
|
4
|
-
id: string;
|
|
5
|
-
languages: string[];
|
|
6
|
-
};
|
|
7
|
-
type SampleConfig = {
|
|
8
|
-
samples: SampleChoice[];
|
|
9
|
-
};
|
|
1
|
+
import { ApiSampleConfig } from '../../types/Cms';
|
|
10
2
|
type SampleTypePromptResponse = {
|
|
11
3
|
sampleType?: string;
|
|
12
4
|
};
|
|
@@ -14,5 +6,5 @@ type LanguagePromptResponse = {
|
|
|
14
6
|
sampleLanguage?: string;
|
|
15
7
|
};
|
|
16
8
|
type CreateApiSamplePromptResponse = SampleTypePromptResponse & LanguagePromptResponse;
|
|
17
|
-
export declare function createApiSamplePrompt(samplesConfig:
|
|
9
|
+
export declare function createApiSamplePrompt(samplesConfig: ApiSampleConfig): Promise<CreateApiSamplePromptResponse>;
|
|
18
10
|
export {};
|
|
@@ -1,7 +1,25 @@
|
|
|
1
|
-
declare const templateTypeChoices: {
|
|
2
|
-
name:
|
|
3
|
-
value:
|
|
4
|
-
}
|
|
1
|
+
declare const templateTypeChoices: [{
|
|
2
|
+
readonly name: "page";
|
|
3
|
+
readonly value: "page-template";
|
|
4
|
+
}, {
|
|
5
|
+
readonly name: "email";
|
|
6
|
+
readonly value: "email-template";
|
|
7
|
+
}, {
|
|
8
|
+
readonly name: "partial";
|
|
9
|
+
readonly value: "partial";
|
|
10
|
+
}, {
|
|
11
|
+
readonly name: "global partial";
|
|
12
|
+
readonly value: "global-partial";
|
|
13
|
+
}, {
|
|
14
|
+
readonly name: "blog listing";
|
|
15
|
+
readonly value: "blog-listing-template";
|
|
16
|
+
}, {
|
|
17
|
+
readonly name: "blog post";
|
|
18
|
+
readonly value: "blog-post-template";
|
|
19
|
+
}, {
|
|
20
|
+
readonly name: "search results";
|
|
21
|
+
readonly value: "search-template";
|
|
22
|
+
}];
|
|
5
23
|
interface CreateTemplatePromptResponse {
|
|
6
24
|
templateType: (typeof templateTypeChoices)[number]['value'];
|
|
7
25
|
}
|
package/lib/upload.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function getUploadableFileList(src: string, convertFields
|
|
1
|
+
export declare function getUploadableFileList(src: string, convertFields?: boolean): Promise<string[]>;
|
package/lib/yargsUtils.d.ts
CHANGED
|
@@ -6,4 +6,8 @@ export declare function makeYargsBuilder<T>(callback: (yargs: Argv) => Argv<T>,
|
|
|
6
6
|
useConfigOptions?: boolean;
|
|
7
7
|
useEnvironmentOptions?: boolean;
|
|
8
8
|
useTestingOptions?: boolean;
|
|
9
|
+
useCmsPublishModeOptions?: boolean | {
|
|
10
|
+
read?: boolean;
|
|
11
|
+
write?: boolean;
|
|
12
|
+
};
|
|
9
13
|
}): (yargs: Argv) => Promise<Argv<T>>;
|
package/lib/yargsUtils.js
CHANGED
|
@@ -32,6 +32,12 @@ function makeYargsBuilder(callback, command, describe, options = {}) {
|
|
|
32
32
|
if (options.useTestingOptions) {
|
|
33
33
|
(0, commonOpts_1.addTestingOptions)(yargs);
|
|
34
34
|
}
|
|
35
|
+
if (options.useCmsPublishModeOptions) {
|
|
36
|
+
const opts = typeof options.useCmsPublishModeOptions === 'object'
|
|
37
|
+
? options.useCmsPublishModeOptions
|
|
38
|
+
: { write: true };
|
|
39
|
+
(0, commonOpts_1.addCmsPublishModeOptions)(yargs, opts);
|
|
40
|
+
}
|
|
35
41
|
const result = callback(yargs);
|
|
36
42
|
// Must go last to pick up available options
|
|
37
43
|
await (0, commonOpts_1.addCustomHelpOutput)(result, command, describe);
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/cli",
|
|
3
|
-
"version": "7.4.
|
|
3
|
+
"version": "7.4.9-beta.0",
|
|
4
4
|
"description": "The official CLI for developing on HubSpot",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": "https://github.com/HubSpot/hubspot-cli",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@hubspot/local-dev-lib": "3.5.
|
|
9
|
-
"@hubspot/project-parsing-lib": "0.1.
|
|
8
|
+
"@hubspot/local-dev-lib": "3.5.6",
|
|
9
|
+
"@hubspot/project-parsing-lib": "0.1.11",
|
|
10
10
|
"@hubspot/serverless-dev-runtime": "7.0.2",
|
|
11
11
|
"@hubspot/theme-preview-dev-server": "0.0.10",
|
|
12
12
|
"@hubspot/ui-extensions-dev-server": "0.8.52",
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"table": "6.9.0",
|
|
29
29
|
"tmp": "0.2.3",
|
|
30
30
|
"update-notifier": "5.1.0",
|
|
31
|
+
"ws": "^8.18.2",
|
|
31
32
|
"yargs": "17.7.2",
|
|
32
33
|
"yargs-parser": "21.1.1"
|
|
33
34
|
},
|
|
@@ -41,6 +42,7 @@
|
|
|
41
42
|
"@types/js-yaml": "^4.0.9",
|
|
42
43
|
"@types/semver": "^7.5.8",
|
|
43
44
|
"@types/tmp": "^0.2.6",
|
|
45
|
+
"@types/ws": "^8.18.1",
|
|
44
46
|
"@types/yargs": "^17.0.33",
|
|
45
47
|
"@typescript-eslint/eslint-plugin": "^8.30.1",
|
|
46
48
|
"@typescript-eslint/parser": "^8.11.0",
|
package/types/Cms.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { CommonArgs, ConfigArgs } from './Yargs';
|
|
2
|
+
export type CreateArgs = CommonArgs & ConfigArgs & {
|
|
3
|
+
branch?: string;
|
|
4
|
+
type: string;
|
|
5
|
+
dest: string;
|
|
6
|
+
name: string;
|
|
7
|
+
internal?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export type CmsAssetOperationArgs = {
|
|
10
|
+
assetType: string;
|
|
11
|
+
name: string;
|
|
12
|
+
dest: string;
|
|
13
|
+
getInternalVersion: boolean;
|
|
14
|
+
commandArgs: CreateArgs;
|
|
15
|
+
};
|
|
16
|
+
export type CreatableCmsAsset = {
|
|
17
|
+
hidden: boolean;
|
|
18
|
+
dest: (args: CmsAssetOperationArgs) => string;
|
|
19
|
+
validate?: (args: CmsAssetOperationArgs) => boolean;
|
|
20
|
+
execute: (args: CmsAssetOperationArgs) => Promise<void>;
|
|
21
|
+
};
|
|
22
|
+
export type ApiSampleChoice = {
|
|
23
|
+
name: string;
|
|
24
|
+
description: string;
|
|
25
|
+
id: string;
|
|
26
|
+
languages: string[];
|
|
27
|
+
};
|
|
28
|
+
export type ApiSampleConfig = {
|
|
29
|
+
samples: ApiSampleChoice[];
|
|
30
|
+
};
|
package/types/Cms.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { IntermediateRepresentationNodeLocalDev } from '@hubspot/project-parsing-lib/src/lib/types';
|
|
2
|
+
import { Build } from '@hubspot/local-dev-lib/types/Build';
|
|
3
|
+
import { Environment } from '@hubspot/local-dev-lib/types/Config';
|
|
4
|
+
import { ProjectConfig } from './Projects';
|
|
5
|
+
export type LocalDevState = {
|
|
6
|
+
targetProjectAccountId: number;
|
|
7
|
+
targetTestingAccountId: number;
|
|
8
|
+
projectConfig: ProjectConfig;
|
|
9
|
+
projectDir: string;
|
|
10
|
+
projectId: number;
|
|
11
|
+
debug: boolean;
|
|
12
|
+
deployedBuild?: Build;
|
|
13
|
+
isGithubLinked: boolean;
|
|
14
|
+
projectNodes: {
|
|
15
|
+
[key: string]: IntermediateRepresentationNodeLocalDev;
|
|
16
|
+
};
|
|
17
|
+
env: Environment;
|
|
18
|
+
};
|
|
19
|
+
export type LocalDevWebsocketMessage = {
|
|
20
|
+
type: string;
|
|
21
|
+
data: unknown;
|
|
22
|
+
};
|
package/types/Yargs.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Options, CommandModule, Argv } from 'yargs';
|
|
2
|
+
import { CmsPublishMode } from '@hubspot/local-dev-lib/types/Files';
|
|
2
3
|
export type CommonArgs = {
|
|
3
4
|
derivedAccountId: number;
|
|
4
5
|
providedAccountId?: number;
|
|
@@ -27,6 +28,10 @@ export type ProjectDevArgs = CommonArgs & ConfigArgs & EnvironmentArgs;
|
|
|
27
28
|
export type TestingArgs = {
|
|
28
29
|
qa?: boolean;
|
|
29
30
|
};
|
|
31
|
+
export type CmsPublishModeArgs = {
|
|
32
|
+
'cms-publish-mode'?: CmsPublishMode;
|
|
33
|
+
m?: CmsPublishMode;
|
|
34
|
+
};
|
|
30
35
|
export interface YargsCommandModule<T, U> extends CommandModule<T, U> {
|
|
31
36
|
builder: (yargs: Argv) => Promise<Argv<U>>;
|
|
32
37
|
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { FSWatcher } from 'chokidar';
|
|
2
|
-
import { Build } from '@hubspot/local-dev-lib/types/Build';
|
|
3
|
-
import { PublicApp } from '@hubspot/local-dev-lib/types/Apps';
|
|
4
|
-
import { Environment } from '@hubspot/local-dev-lib/types/Config';
|
|
5
|
-
import { ProjectConfig } from '../../../types/Projects';
|
|
6
|
-
import { IntermediateRepresentationNodeLocalDev } from '@hubspot/project-parsing-lib/src/lib/types';
|
|
7
|
-
import { AppIRNode } from '../../../types/ProjectComponents';
|
|
8
|
-
type LocalDevManagerConstructorOptions = {
|
|
9
|
-
targetProjectAccountId: number;
|
|
10
|
-
targetTestingAccountId: number;
|
|
11
|
-
projectConfig: ProjectConfig;
|
|
12
|
-
projectDir: string;
|
|
13
|
-
projectId: number;
|
|
14
|
-
debug?: boolean;
|
|
15
|
-
deployedBuild?: Build;
|
|
16
|
-
isGithubLinked: boolean;
|
|
17
|
-
projectNodes: {
|
|
18
|
-
[key: string]: IntermediateRepresentationNodeLocalDev;
|
|
19
|
-
};
|
|
20
|
-
env: Environment;
|
|
21
|
-
};
|
|
22
|
-
declare class LocalDevManagerV2 {
|
|
23
|
-
targetProjectAccountId: number;
|
|
24
|
-
targetTestingAccountId: number;
|
|
25
|
-
projectConfig: ProjectConfig;
|
|
26
|
-
projectDir: string;
|
|
27
|
-
projectId: number;
|
|
28
|
-
debug: boolean;
|
|
29
|
-
deployedBuild?: Build;
|
|
30
|
-
isGithubLinked: boolean;
|
|
31
|
-
watcher: FSWatcher | null;
|
|
32
|
-
uploadWarnings: {
|
|
33
|
-
[key: string]: boolean;
|
|
34
|
-
};
|
|
35
|
-
projectNodes: {
|
|
36
|
-
[key: string]: IntermediateRepresentationNodeLocalDev;
|
|
37
|
-
};
|
|
38
|
-
activeApp: AppIRNode | null;
|
|
39
|
-
activePublicAppData: PublicApp | null;
|
|
40
|
-
env: Environment;
|
|
41
|
-
publicAppActiveInstalls: number | null;
|
|
42
|
-
projectSourceDir: string;
|
|
43
|
-
mostRecentUploadWarning: string | null;
|
|
44
|
-
constructor(options: LocalDevManagerConstructorOptions);
|
|
45
|
-
setActiveApp(appUid?: string): Promise<void>;
|
|
46
|
-
setActivePublicAppData(): Promise<void>;
|
|
47
|
-
checkActivePublicAppInstalls(): Promise<void>;
|
|
48
|
-
start(): Promise<void>;
|
|
49
|
-
stop(showProgress?: boolean): Promise<void>;
|
|
50
|
-
checkPublicAppInstallation(): Promise<void>;
|
|
51
|
-
updateKeypressListeners(): void;
|
|
52
|
-
getUploadCommand(): string;
|
|
53
|
-
logUploadWarning(reason?: string): void;
|
|
54
|
-
monitorConsoleOutput(): void;
|
|
55
|
-
compareLocalProjectToDeployed(): void;
|
|
56
|
-
startWatching(): void;
|
|
57
|
-
stopWatching(): Promise<void>;
|
|
58
|
-
handleWatchEvent(filePath: string, event: string, configPaths: string[]): void;
|
|
59
|
-
devServerSetup(): Promise<boolean>;
|
|
60
|
-
devServerStart(): Promise<void>;
|
|
61
|
-
devServerFileChange(filePath: string, event: string): void;
|
|
62
|
-
devServerCleanup(): Promise<boolean>;
|
|
63
|
-
}
|
|
64
|
-
export default LocalDevManagerV2;
|