@hubspot/cli 7.8.1-experimental.0 → 7.8.3-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/commands/__tests__/getStarted.test.js +2 -2
- package/commands/__tests__/mcp.test.js +1 -1
- package/commands/__tests__/project.test.js +0 -3
- package/commands/app/__tests__/migrate.test.js +0 -1
- package/commands/app/migrate.js +4 -5
- package/commands/app/secret/add.js +2 -1
- package/commands/app/secret/delete.js +2 -1
- package/commands/app/secret/list.js +2 -1
- package/commands/app/secret/update.js +2 -1
- package/commands/app/secret.js +2 -1
- package/commands/app.js +2 -2
- package/commands/config/set.js +0 -1
- package/commands/feedback.js +1 -1
- package/commands/getStarted.d.ts +0 -2
- package/commands/getStarted.js +2 -2
- package/commands/mcp/__tests__/setup.test.js +2 -2
- package/commands/mcp/setup.js +3 -2
- package/commands/mcp.js +3 -3
- package/commands/project/__tests__/create.test.js +6 -6
- package/commands/project/__tests__/deploy.test.js +0 -3
- package/commands/project/__tests__/devUnifiedFlow.test.js +2 -4
- package/commands/project/__tests__/logs.test.js +0 -3
- package/commands/project/__tests__/migrate.test.js +1 -2
- package/commands/project/__tests__/migrateApp.test.js +1 -2
- package/commands/project/__tests__/profile.test.js +1 -1
- package/commands/project/add.js +1 -5
- package/commands/project/create.js +3 -9
- package/commands/project/deploy.js +2 -2
- package/commands/project/dev/index.js +4 -3
- package/commands/project/dev/unifiedFlow.js +5 -3
- package/commands/project/download.js +1 -2
- package/commands/project/installDeps.js +1 -2
- package/commands/project/listBuilds.js +2 -2
- package/commands/project/logs.js +2 -2
- package/commands/project/migrate.js +15 -6
- package/commands/project/migrateApp.js +1 -2
- package/commands/project/open.js +1 -2
- package/commands/project/profile/add.js +3 -3
- package/commands/project/profile/delete.js +1 -2
- package/commands/project/profile.js +2 -3
- package/commands/project/upload.js +2 -2
- package/commands/project/validate.js +1 -1
- package/commands/project/watch.js +2 -2
- package/commands/project.js +1 -2
- package/commands/sandbox/delete.js +1 -1
- package/commands/testAccount/importData.d.ts +1 -1
- package/commands/testAccount/importData.js +1 -1
- package/commands/testAccount.js +1 -1
- package/lang/en.d.ts +11 -3
- package/lang/en.js +13 -5
- package/lib/constants.d.ts +5 -0
- package/lib/constants.js +5 -0
- package/lib/mcp/setup.js +1 -1
- package/lib/middleware/fireAlarmMiddleware.js +15 -5
- package/lib/projects/__tests__/LocalDevProcess.test.js +227 -16
- package/lib/projects/__tests__/LocalDevWebsocketServer.test.js +16 -21
- package/lib/projects/__tests__/deploy.test.js +71 -6
- package/lib/projects/__tests__/localDevProjectHelpers.test.js +4 -2
- package/lib/projects/create/__tests__/v3.test.js +79 -4
- package/lib/projects/create/v3.js +8 -6
- package/lib/projects/localDev/AppDevModeInterface.js +5 -5
- package/lib/projects/localDev/LocalDevLogger.d.ts +4 -0
- package/lib/projects/localDev/LocalDevLogger.js +22 -0
- package/lib/projects/localDev/LocalDevProcess.d.ts +7 -5
- package/lib/projects/localDev/LocalDevProcess.js +90 -19
- package/lib/projects/localDev/LocalDevState.d.ts +9 -8
- package/lib/projects/localDev/LocalDevState.js +18 -17
- package/lib/projects/localDev/LocalDevWebsocketServer.d.ts +2 -0
- package/lib/projects/localDev/LocalDevWebsocketServer.js +55 -23
- package/lib/projects/localDev/helpers/project.js +5 -1
- package/lib/projects/localDev/localDevWebsocketServerUtils.d.ts +4 -0
- package/lib/projects/localDev/localDevWebsocketServerUtils.js +10 -0
- package/lib/projects/pollProjectBuildAndDeploy.js +4 -4
- package/lib/prompts/projectAddPrompt.js +2 -1
- package/lib/prompts/promptUtils.js +3 -0
- package/lib/prompts/selectProjectTemplatePrompt.js +2 -0
- package/package.json +4 -4
- package/types/LocalDev.d.ts +19 -3
- package/ui/index.js +1 -1
|
@@ -52,6 +52,7 @@ export async function createV3App(providedAuth, providedDistribution) {
|
|
|
52
52
|
const componentTypeToGateMap = {
|
|
53
53
|
[AppEventsKey]: FEATURES.APP_EVENTS,
|
|
54
54
|
[PagesKey]: FEATURES.APPS_HOME,
|
|
55
|
+
'workflow-action-tool': FEATURES.AGENT_TOOLS,
|
|
55
56
|
};
|
|
56
57
|
export async function calculateComponentTemplateChoices(components, authType, distribution, accountId, projectMetadata) {
|
|
57
58
|
const enabledComponents = [];
|
|
@@ -73,18 +74,19 @@ export async function calculateComponentTemplateChoices(components, authType, di
|
|
|
73
74
|
}
|
|
74
75
|
if (Array.isArray(supportedAuthTypes) &&
|
|
75
76
|
authType &&
|
|
76
|
-
!supportedAuthTypes.includes(authType)) {
|
|
77
|
+
!supportedAuthTypes.includes(authType.toLowerCase())) {
|
|
77
78
|
disabledReasons.push(commands.project.add.error.authTypeNotAllowed(authType));
|
|
78
79
|
}
|
|
79
80
|
if (Array.isArray(supportedDistributions) &&
|
|
80
81
|
distribution &&
|
|
81
|
-
!supportedDistributions.includes(distribution)) {
|
|
82
|
+
!supportedDistributions.includes(distribution.toLowerCase())) {
|
|
82
83
|
disabledReasons.push(commands.project.add.error.distributionNotAllowed(distribution));
|
|
83
84
|
}
|
|
84
|
-
|
|
85
|
-
|
|
85
|
+
const templateGate = componentTypeToGateMap[template.cliSelector || template.type];
|
|
86
|
+
if (templateGate) {
|
|
87
|
+
const isUngated = await hasFeature(accountId, templateGate);
|
|
86
88
|
if (!isUngated) {
|
|
87
|
-
disabledReasons.
|
|
89
|
+
disabledReasons.unshift(commands.project.add.error.portalDoesNotHaveAccessToThisFeature(accountId));
|
|
88
90
|
}
|
|
89
91
|
}
|
|
90
92
|
if (disabledReasons.length > 0) {
|
|
@@ -96,7 +98,7 @@ export async function calculateComponentTemplateChoices(components, authType, di
|
|
|
96
98
|
}
|
|
97
99
|
else {
|
|
98
100
|
enabledComponents.push({
|
|
99
|
-
name: template.label
|
|
101
|
+
name: `${template.label} [${template.cliSelector || template.type}]`,
|
|
100
102
|
value: template,
|
|
101
103
|
});
|
|
102
104
|
}
|
|
@@ -75,7 +75,7 @@ class AppDevModeInterface {
|
|
|
75
75
|
// );
|
|
76
76
|
// }
|
|
77
77
|
async getAppInstallUrl() {
|
|
78
|
-
if (this.appNode?.config.auth.type === APP_AUTH_TYPES.OAUTH) {
|
|
78
|
+
if (this.appNode?.config.auth.type.toLowerCase() === APP_AUTH_TYPES.OAUTH) {
|
|
79
79
|
return getOauthAppInstallUrl({
|
|
80
80
|
targetAccountId: this.localDevState.targetTestingAccountId,
|
|
81
81
|
env: this.localDevState.env,
|
|
@@ -216,12 +216,12 @@ class AppDevModeInterface {
|
|
|
216
216
|
const newDistribution = newAppNode?.config.distribution;
|
|
217
217
|
const oldAuthType = this.appNode?.config.auth.type;
|
|
218
218
|
const newAuthType = newAppNode?.config.auth.type;
|
|
219
|
-
if (newDistribution === APP_DISTRIBUTION_TYPES.MARKETPLACE &&
|
|
220
|
-
oldDistribution !== APP_DISTRIBUTION_TYPES.MARKETPLACE) {
|
|
219
|
+
if (newDistribution?.toLowerCase() === APP_DISTRIBUTION_TYPES.MARKETPLACE &&
|
|
220
|
+
oldDistribution?.toLowerCase() !== APP_DISTRIBUTION_TYPES.MARKETPLACE) {
|
|
221
221
|
this.localDevState.addUploadWarning(lib.AppDevModeInterface.distributionChanged);
|
|
222
222
|
}
|
|
223
|
-
else if (newAuthType === APP_AUTH_TYPES.OAUTH &&
|
|
224
|
-
oldAuthType !== APP_AUTH_TYPES.OAUTH) {
|
|
223
|
+
else if (newAuthType?.toLowerCase() === APP_AUTH_TYPES.OAUTH &&
|
|
224
|
+
oldAuthType?.toLowerCase() !== APP_AUTH_TYPES.OAUTH) {
|
|
225
225
|
this.localDevState.addUploadWarning(lib.AppDevModeInterface.authTypeChanged);
|
|
226
226
|
}
|
|
227
227
|
};
|
|
@@ -18,9 +18,13 @@ declare class LocalDevLogger {
|
|
|
18
18
|
cleanupError(): void;
|
|
19
19
|
cleanupSuccess(): void;
|
|
20
20
|
uploadInitiated(): void;
|
|
21
|
+
deployInitiated(): void;
|
|
21
22
|
projectConfigMismatch(): void;
|
|
22
23
|
uploadError(error: unknown): void;
|
|
23
24
|
uploadSuccess(): void;
|
|
25
|
+
uploadSuccessAutoDeployDisabled(): void;
|
|
26
|
+
deployError(error?: unknown): void;
|
|
27
|
+
deploySuccess(): void;
|
|
24
28
|
monitorConsoleOutput(): void;
|
|
25
29
|
}
|
|
26
30
|
export default LocalDevLogger;
|
|
@@ -112,6 +112,9 @@ class LocalDevLogger {
|
|
|
112
112
|
uploadInitiated() {
|
|
113
113
|
uiLogger.log(lib.LocalDevProcess.uploadInitiated);
|
|
114
114
|
}
|
|
115
|
+
deployInitiated() {
|
|
116
|
+
uiLogger.log(lib.LocalDevProcess.deployInitiated);
|
|
117
|
+
}
|
|
115
118
|
projectConfigMismatch() {
|
|
116
119
|
uiLogger.log(lib.LocalDevProcess.projectConfigMismatch);
|
|
117
120
|
}
|
|
@@ -127,6 +130,25 @@ class LocalDevLogger {
|
|
|
127
130
|
uiLine();
|
|
128
131
|
logger.log('');
|
|
129
132
|
}
|
|
133
|
+
uploadSuccessAutoDeployDisabled() {
|
|
134
|
+
uiLogger.warn(lib.LocalDevProcess.uploadSuccessAutoDeployDisabled);
|
|
135
|
+
uiLine();
|
|
136
|
+
logger.log('');
|
|
137
|
+
}
|
|
138
|
+
deployError(error) {
|
|
139
|
+
logger.log('');
|
|
140
|
+
if (error) {
|
|
141
|
+
logError(error);
|
|
142
|
+
}
|
|
143
|
+
uiLogger.log(lib.LocalDevProcess.deployFailed);
|
|
144
|
+
logger.log('');
|
|
145
|
+
}
|
|
146
|
+
deploySuccess() {
|
|
147
|
+
logger.log('');
|
|
148
|
+
uiLogger.log(lib.LocalDevProcess.deploySuccess);
|
|
149
|
+
uiLine();
|
|
150
|
+
logger.log('');
|
|
151
|
+
}
|
|
130
152
|
monitorConsoleOutput() {
|
|
131
153
|
const originalStdoutWrite = process.stdout.write.bind(process.stdout);
|
|
132
154
|
function customStdoutWrite(chunk, encoding, callback) {
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { IntermediateRepresentationNodeLocalDev } from '@hubspot/project-parsing-lib/src/lib/types.js';
|
|
2
|
+
import { Project } from '@hubspot/local-dev-lib/types/Project';
|
|
2
3
|
import LocalDevState from './LocalDevState.js';
|
|
3
4
|
import LocalDevLogger from './LocalDevLogger.js';
|
|
4
|
-
import { LocalDevStateConstructorOptions, LocalDevStateListener, LocalDevServerMessage } from '../../../types/LocalDev.js';
|
|
5
|
+
import { LocalDevStateConstructorOptions, LocalDevStateListener, LocalDevServerMessage, LocalDevProjectUploadResult, LocalDevProjectDeployResult } from '../../../types/LocalDev.js';
|
|
5
6
|
declare class LocalDevProcess {
|
|
6
7
|
private state;
|
|
7
8
|
private _logger;
|
|
8
9
|
private devServerManager;
|
|
9
10
|
constructor(options: LocalDevStateConstructorOptions);
|
|
10
11
|
get projectDir(): string;
|
|
11
|
-
get
|
|
12
|
-
get projectName(): string;
|
|
12
|
+
get projectData(): Project;
|
|
13
13
|
get targetProjectAccountId(): number;
|
|
14
14
|
get targetTestingAccountId(): number;
|
|
15
15
|
get projectNodes(): {
|
|
@@ -22,13 +22,15 @@ declare class LocalDevProcess {
|
|
|
22
22
|
private projectConfigValidForUpload;
|
|
23
23
|
private getIntermediateRepresentation;
|
|
24
24
|
private updateProjectNodes;
|
|
25
|
-
private
|
|
25
|
+
private updateProjectNodesAfterDeploy;
|
|
26
26
|
private openLocalDevUi;
|
|
27
|
+
private updateProjectData;
|
|
27
28
|
handleFileChange(filePath: string, event: string): Promise<void>;
|
|
28
29
|
handleConfigFileChange(): Promise<void>;
|
|
29
30
|
start(): Promise<void>;
|
|
30
31
|
stop(showProgress?: boolean): Promise<void>;
|
|
31
|
-
uploadProject(): Promise<
|
|
32
|
+
uploadProject(): Promise<LocalDevProjectUploadResult>;
|
|
33
|
+
deployLatestBuild(force?: boolean): Promise<LocalDevProjectDeployResult>;
|
|
32
34
|
addStateListener<K extends keyof LocalDevState>(key: K, listener: LocalDevStateListener<K>): void;
|
|
33
35
|
sendDevServerMessage(message: LocalDevServerMessage): void;
|
|
34
36
|
removeStateListener<K extends keyof LocalDevState>(key: K, listener: LocalDevStateListener<K>): void;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { translateForLocalDev } from '@hubspot/project-parsing-lib';
|
|
2
2
|
import { hasLocalStateFlag } from '@hubspot/local-dev-lib/config';
|
|
3
|
+
import { fetchProject } from '@hubspot/local-dev-lib/api/projects';
|
|
3
4
|
import path from 'path';
|
|
4
5
|
import open from 'open';
|
|
5
6
|
import LocalDevState from './LocalDevState.js';
|
|
@@ -8,10 +9,13 @@ import DevServerManagerV2 from './DevServerManagerV2.js';
|
|
|
8
9
|
import { EXIT_CODES } from '../../enums/exitCodes.js';
|
|
9
10
|
import { getProjectConfig } from '../config.js';
|
|
10
11
|
import { handleProjectUpload } from '../upload.js';
|
|
12
|
+
import { handleProjectDeploy } from '../deploy.js';
|
|
11
13
|
import { pollProjectBuildAndDeploy } from '../pollProjectBuildAndDeploy.js';
|
|
12
14
|
import { getLocalDevUiUrl } from '../urls.js';
|
|
13
|
-
import { CONFIG_LOCAL_STATE_FLAGS } from '../../constants.js';
|
|
15
|
+
import { CONFIG_LOCAL_STATE_FLAGS, PROJECT_DEPLOY_STATES, } from '../../constants.js';
|
|
14
16
|
import { isAutoOpenBrowserEnabled } from '../../configOptions.js';
|
|
17
|
+
import { lib } from '../../../lang/en.js';
|
|
18
|
+
import { debugError } from '../../errorHandlers/index.js';
|
|
15
19
|
class LocalDevProcess {
|
|
16
20
|
state;
|
|
17
21
|
_logger;
|
|
@@ -27,11 +31,8 @@ class LocalDevProcess {
|
|
|
27
31
|
get projectDir() {
|
|
28
32
|
return this.state.projectDir;
|
|
29
33
|
}
|
|
30
|
-
get
|
|
31
|
-
return this.state.
|
|
32
|
-
}
|
|
33
|
-
get projectName() {
|
|
34
|
-
return this.state.projectName;
|
|
34
|
+
get projectData() {
|
|
35
|
+
return this.state.projectData;
|
|
35
36
|
}
|
|
36
37
|
get targetProjectAccountId() {
|
|
37
38
|
return this.state.targetProjectAccountId;
|
|
@@ -87,34 +88,43 @@ class LocalDevProcess {
|
|
|
87
88
|
});
|
|
88
89
|
return true;
|
|
89
90
|
}
|
|
90
|
-
getIntermediateRepresentation(
|
|
91
|
+
getIntermediateRepresentation(projectNodesAtLastDeploy) {
|
|
91
92
|
return translateForLocalDev({
|
|
92
93
|
projectSourceDir: path.join(this.state.projectDir, this.state.projectConfig.srcDir),
|
|
93
94
|
platformVersion: this.state.projectConfig.platformVersion,
|
|
94
95
|
accountId: this.state.targetProjectAccountId,
|
|
95
96
|
}, {
|
|
96
|
-
projectNodesAtLastUpload,
|
|
97
|
+
projectNodesAtLastUpload: projectNodesAtLastDeploy,
|
|
97
98
|
profile: this.state.profile,
|
|
98
99
|
});
|
|
99
100
|
}
|
|
100
101
|
async updateProjectNodes() {
|
|
101
|
-
const intermediateRepresentation = await this.getIntermediateRepresentation(this.state.
|
|
102
|
+
const intermediateRepresentation = await this.getIntermediateRepresentation(this.state.projectNodesAtLastDeploy);
|
|
102
103
|
this.state.projectNodes =
|
|
103
104
|
intermediateRepresentation.intermediateNodesIndexedByUid;
|
|
104
105
|
this.state.projectProfileData = intermediateRepresentation.profileData;
|
|
105
106
|
}
|
|
106
|
-
async
|
|
107
|
+
async updateProjectNodesAfterDeploy() {
|
|
107
108
|
const intermediateRepresentation = await this.getIntermediateRepresentation();
|
|
108
109
|
this.state.projectNodes =
|
|
109
110
|
intermediateRepresentation.intermediateNodesIndexedByUid;
|
|
110
111
|
this.state.projectProfileData = intermediateRepresentation.profileData;
|
|
111
|
-
this.state.
|
|
112
|
+
this.state.projectNodesAtLastDeploy =
|
|
112
113
|
intermediateRepresentation.intermediateNodesIndexedByUid;
|
|
113
114
|
}
|
|
114
115
|
openLocalDevUi() {
|
|
115
116
|
const showWelcomeScreen = !hasLocalStateFlag(CONFIG_LOCAL_STATE_FLAGS.LOCAL_DEV_UI_WELCOME);
|
|
116
117
|
open(getLocalDevUiUrl(this.state.targetTestingAccountId, showWelcomeScreen));
|
|
117
118
|
}
|
|
119
|
+
async updateProjectData() {
|
|
120
|
+
try {
|
|
121
|
+
const { data: projectData } = await fetchProject(this.state.targetProjectAccountId, this.state.projectConfig.name);
|
|
122
|
+
this.state.projectData = projectData;
|
|
123
|
+
}
|
|
124
|
+
catch (e) {
|
|
125
|
+
debugError(e);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
118
128
|
async handleFileChange(filePath, event) {
|
|
119
129
|
await this.updateProjectNodes();
|
|
120
130
|
try {
|
|
@@ -162,24 +172,85 @@ class LocalDevProcess {
|
|
|
162
172
|
const isUploadable = await this.projectConfigValidForUpload();
|
|
163
173
|
if (!isUploadable) {
|
|
164
174
|
this.logger.projectConfigMismatch();
|
|
165
|
-
return
|
|
175
|
+
return {
|
|
176
|
+
uploadSuccess: false,
|
|
177
|
+
buildSuccess: false,
|
|
178
|
+
deploySuccess: false,
|
|
179
|
+
};
|
|
166
180
|
}
|
|
167
|
-
const { uploadError } = await handleProjectUpload({
|
|
181
|
+
const { uploadError, result } = await handleProjectUpload({
|
|
168
182
|
accountId: this.state.targetProjectAccountId,
|
|
169
183
|
projectConfig: this.state.projectConfig,
|
|
170
184
|
projectDir: this.state.projectDir,
|
|
171
185
|
callbackFunc: pollProjectBuildAndDeploy,
|
|
172
186
|
sendIR: true,
|
|
173
|
-
skipValidation: true,
|
|
174
187
|
});
|
|
188
|
+
const deploy = result?.deployResult;
|
|
175
189
|
if (uploadError) {
|
|
176
190
|
this.logger.uploadError(uploadError);
|
|
177
|
-
return
|
|
191
|
+
return {
|
|
192
|
+
uploadSuccess: false,
|
|
193
|
+
buildSuccess: false,
|
|
194
|
+
deploySuccess: false,
|
|
195
|
+
deployId: deploy?.deployId,
|
|
196
|
+
};
|
|
178
197
|
}
|
|
179
|
-
await this.
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
198
|
+
await this.updateProjectData();
|
|
199
|
+
if (deploy && deploy.status === PROJECT_DEPLOY_STATES.FAILURE) {
|
|
200
|
+
return {
|
|
201
|
+
uploadSuccess: false,
|
|
202
|
+
buildSuccess: true,
|
|
203
|
+
deploySuccess: false,
|
|
204
|
+
deployId: deploy.deployId,
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
else if (!deploy) {
|
|
208
|
+
this.logger.uploadSuccessAutoDeployDisabled();
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
await this.updateProjectNodesAfterDeploy();
|
|
212
|
+
this.state.clearUploadWarnings();
|
|
213
|
+
this.logger.uploadSuccess();
|
|
214
|
+
}
|
|
215
|
+
return {
|
|
216
|
+
uploadSuccess: true,
|
|
217
|
+
buildSuccess: true,
|
|
218
|
+
deploySuccess: Boolean(deploy),
|
|
219
|
+
deployId: deploy?.deployId,
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
async deployLatestBuild(force = false) {
|
|
223
|
+
this.logger.deployInitiated();
|
|
224
|
+
if (!this.state.projectData.latestBuild) {
|
|
225
|
+
this.logger.deployError(lib.LocalDevProcess.noBuildToDeploy);
|
|
226
|
+
return {
|
|
227
|
+
success: false,
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
let deploy;
|
|
231
|
+
try {
|
|
232
|
+
deploy = await handleProjectDeploy(this.state.targetProjectAccountId, this.state.projectConfig.name, this.state.projectData.latestBuild.buildId, true, force);
|
|
233
|
+
}
|
|
234
|
+
catch (error) {
|
|
235
|
+
this.logger.deployError(error);
|
|
236
|
+
return {
|
|
237
|
+
success: false,
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
const success = deploy?.status === PROJECT_DEPLOY_STATES.SUCCESS;
|
|
241
|
+
if (success) {
|
|
242
|
+
await this.updateProjectData();
|
|
243
|
+
this.logger.deploySuccess();
|
|
244
|
+
await this.updateProjectNodesAfterDeploy();
|
|
245
|
+
this.state.clearUploadWarnings();
|
|
246
|
+
}
|
|
247
|
+
else {
|
|
248
|
+
this.logger.deployError();
|
|
249
|
+
}
|
|
250
|
+
return {
|
|
251
|
+
success,
|
|
252
|
+
deployId: deploy?.deployId,
|
|
253
|
+
};
|
|
183
254
|
}
|
|
184
255
|
addStateListener(key, listener) {
|
|
185
256
|
this.state.addListener(key, listener);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { IntermediateRepresentationNodeLocalDev, HSProfileVariables } from '@hubspot/project-parsing-lib/src/lib/types.js';
|
|
2
2
|
import { Environment } from '@hubspot/local-dev-lib/types/Config';
|
|
3
|
+
import { Project } from '@hubspot/local-dev-lib/types/Project';
|
|
3
4
|
import { ProjectConfig } from '../../../types/Projects.js';
|
|
4
5
|
import { LocalDevStateConstructorOptions, LocalDevStateListener, AppLocalDevData, LocalDevServerMessage } from '../../../types/LocalDev.js';
|
|
5
6
|
declare class LocalDevState {
|
|
@@ -8,26 +9,23 @@ declare class LocalDevState {
|
|
|
8
9
|
private _profile?;
|
|
9
10
|
private _projectConfig;
|
|
10
11
|
private _projectDir;
|
|
11
|
-
private
|
|
12
|
-
private _projectName;
|
|
12
|
+
private _projectData;
|
|
13
13
|
private _debug;
|
|
14
14
|
private _projectNodes;
|
|
15
15
|
private _projectProfileData;
|
|
16
|
-
private
|
|
16
|
+
private _projectNodesAtLastDeploy;
|
|
17
17
|
private _env;
|
|
18
18
|
private _listeners;
|
|
19
19
|
private _appData;
|
|
20
20
|
private _devServerMessage;
|
|
21
21
|
private _uploadWarnings;
|
|
22
|
-
constructor({ targetProjectAccountId, targetTestingAccountId, projectConfig, projectDir,
|
|
22
|
+
constructor({ targetProjectAccountId, targetTestingAccountId, projectConfig, projectDir, projectData, debug, initialProjectNodes, initialProjectProfileData, profile, env, }: LocalDevStateConstructorOptions);
|
|
23
23
|
private runListeners;
|
|
24
24
|
get targetProjectAccountId(): number;
|
|
25
25
|
get targetTestingAccountId(): number;
|
|
26
26
|
get profile(): string | undefined;
|
|
27
27
|
get projectConfig(): ProjectConfig;
|
|
28
28
|
get projectDir(): string;
|
|
29
|
-
get projectId(): number;
|
|
30
|
-
get projectName(): string;
|
|
31
29
|
get debug(): boolean;
|
|
32
30
|
get projectNodes(): {
|
|
33
31
|
[key: string]: IntermediateRepresentationNodeLocalDev;
|
|
@@ -37,12 +35,15 @@ declare class LocalDevState {
|
|
|
37
35
|
});
|
|
38
36
|
get projectProfileData(): HSProfileVariables;
|
|
39
37
|
set projectProfileData(profileData: HSProfileVariables);
|
|
40
|
-
get
|
|
38
|
+
get projectNodesAtLastDeploy(): {
|
|
41
39
|
[key: string]: IntermediateRepresentationNodeLocalDev;
|
|
42
40
|
};
|
|
43
|
-
set
|
|
41
|
+
set projectNodesAtLastDeploy(nodes: {
|
|
44
42
|
[key: string]: IntermediateRepresentationNodeLocalDev;
|
|
45
43
|
});
|
|
44
|
+
get projectData(): Project;
|
|
45
|
+
get projectId(): number;
|
|
46
|
+
set projectData(projectData: Project);
|
|
46
47
|
get env(): Environment;
|
|
47
48
|
get appData(): Record<string, AppLocalDevData>;
|
|
48
49
|
getAppDataByUid(uid: string): AppLocalDevData | undefined;
|
|
@@ -5,28 +5,26 @@ class LocalDevState {
|
|
|
5
5
|
_profile;
|
|
6
6
|
_projectConfig;
|
|
7
7
|
_projectDir;
|
|
8
|
-
|
|
9
|
-
_projectName;
|
|
8
|
+
_projectData;
|
|
10
9
|
_debug;
|
|
11
10
|
_projectNodes;
|
|
12
11
|
_projectProfileData;
|
|
13
|
-
|
|
12
|
+
_projectNodesAtLastDeploy;
|
|
14
13
|
_env;
|
|
15
14
|
_listeners;
|
|
16
15
|
_appData;
|
|
17
16
|
_devServerMessage;
|
|
18
17
|
_uploadWarnings;
|
|
19
|
-
constructor({ targetProjectAccountId, targetTestingAccountId, projectConfig, projectDir,
|
|
18
|
+
constructor({ targetProjectAccountId, targetTestingAccountId, projectConfig, projectDir, projectData, debug, initialProjectNodes, initialProjectProfileData, profile, env, }) {
|
|
20
19
|
this._targetProjectAccountId = targetProjectAccountId;
|
|
21
20
|
this._targetTestingAccountId = targetTestingAccountId;
|
|
22
21
|
this._profile = profile;
|
|
23
22
|
this._projectConfig = projectConfig;
|
|
24
23
|
this._projectDir = projectDir;
|
|
25
|
-
this.
|
|
26
|
-
this._projectName = projectName;
|
|
24
|
+
this._projectData = projectData;
|
|
27
25
|
this._debug = debug || false;
|
|
28
26
|
this._projectNodes = initialProjectNodes;
|
|
29
|
-
this.
|
|
27
|
+
this._projectNodesAtLastDeploy = initialProjectNodes;
|
|
30
28
|
this._projectProfileData = initialProjectProfileData;
|
|
31
29
|
this._env = env;
|
|
32
30
|
this._appData = {};
|
|
@@ -54,12 +52,6 @@ class LocalDevState {
|
|
|
54
52
|
get projectDir() {
|
|
55
53
|
return this._projectDir;
|
|
56
54
|
}
|
|
57
|
-
get projectId() {
|
|
58
|
-
return this._projectId;
|
|
59
|
-
}
|
|
60
|
-
get projectName() {
|
|
61
|
-
return this._projectName;
|
|
62
|
-
}
|
|
63
55
|
get debug() {
|
|
64
56
|
return this._debug;
|
|
65
57
|
}
|
|
@@ -76,11 +68,20 @@ class LocalDevState {
|
|
|
76
68
|
set projectProfileData(profileData) {
|
|
77
69
|
this._projectProfileData = profileData;
|
|
78
70
|
}
|
|
79
|
-
get
|
|
80
|
-
return structuredClone(this.
|
|
71
|
+
get projectNodesAtLastDeploy() {
|
|
72
|
+
return structuredClone(this._projectNodesAtLastDeploy);
|
|
73
|
+
}
|
|
74
|
+
set projectNodesAtLastDeploy(nodes) {
|
|
75
|
+
this._projectNodesAtLastDeploy = nodes;
|
|
76
|
+
}
|
|
77
|
+
get projectData() {
|
|
78
|
+
return structuredClone(this._projectData);
|
|
79
|
+
}
|
|
80
|
+
get projectId() {
|
|
81
|
+
return this.projectData.id;
|
|
81
82
|
}
|
|
82
|
-
set
|
|
83
|
-
this.
|
|
83
|
+
set projectData(projectData) {
|
|
84
|
+
this._projectData = projectData;
|
|
84
85
|
}
|
|
85
86
|
get env() {
|
|
86
87
|
return this._env;
|
|
@@ -9,7 +9,9 @@ declare class LocalDevWebsocketServer {
|
|
|
9
9
|
private logError;
|
|
10
10
|
private sendMessage;
|
|
11
11
|
private handleUpload;
|
|
12
|
+
private handleDeploy;
|
|
12
13
|
private setupMessageHandlers;
|
|
14
|
+
private sendCliMetadata;
|
|
13
15
|
private sendProjectData;
|
|
14
16
|
private setupProjectNodesListener;
|
|
15
17
|
private setupAppDataListener;
|
|
@@ -2,10 +2,13 @@ import { WebSocketServer } from 'ws';
|
|
|
2
2
|
import { isPortManagerServerRunning, requestPorts, } from '@hubspot/local-dev-lib/portManager';
|
|
3
3
|
import { logger } from '@hubspot/local-dev-lib/logger';
|
|
4
4
|
import { addLocalStateFlag } from '@hubspot/local-dev-lib/config';
|
|
5
|
-
import { LOCAL_DEV_UI_MESSAGE_SEND_TYPES,
|
|
5
|
+
import { LOCAL_DEV_UI_MESSAGE_SEND_TYPES, LOCAL_DEV_SERVER_MESSAGE_TYPES, CONFIG_LOCAL_STATE_FLAGS, } from '../../constants.js';
|
|
6
6
|
import { lib } from '../../../lang/en.js';
|
|
7
7
|
import { removeAnsiCodes } from '../../ui/removeAnsiCodes.js';
|
|
8
|
+
import { isDeployWebsocketMessage, isViewedWelcomeScreenWebsocketMessage, isUploadWebsocketMessage, } from './localDevWebsocketServerUtils.js';
|
|
9
|
+
import pkg from '../../../package.json' with { type: 'json' };
|
|
8
10
|
const SERVER_INSTANCE_ID = 'local-dev-ui-websocket-server';
|
|
11
|
+
const LOCAL_DEV_WEBSOCKET_SERVER_VERSION = 1;
|
|
9
12
|
const LOG_PREFIX = '[LocalDevWebsocketServer]';
|
|
10
13
|
class LocalDevWebsocketServer {
|
|
11
14
|
server;
|
|
@@ -35,17 +38,32 @@ class LocalDevWebsocketServer {
|
|
|
35
38
|
websocket.send(JSON.stringify(message));
|
|
36
39
|
}
|
|
37
40
|
async handleUpload(websocket) {
|
|
38
|
-
const uploadSuccess = await this.localDevProcess.uploadProject();
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
41
|
+
const { uploadSuccess, buildSuccess, deploySuccess, deployId } = await this.localDevProcess.uploadProject();
|
|
42
|
+
this.sendMessage(websocket, {
|
|
43
|
+
type: uploadSuccess
|
|
44
|
+
? LOCAL_DEV_UI_MESSAGE_SEND_TYPES.UPLOAD_SUCCESS
|
|
45
|
+
: LOCAL_DEV_UI_MESSAGE_SEND_TYPES.UPLOAD_FAILURE,
|
|
46
|
+
data: {
|
|
47
|
+
latestBuild: this.localDevProcess.projectData.latestBuild,
|
|
48
|
+
deployedBuild: this.localDevProcess.projectData.deployedBuild,
|
|
49
|
+
buildSuccess,
|
|
50
|
+
deploySuccess,
|
|
51
|
+
deployId,
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
async handleDeploy(websocket, force) {
|
|
56
|
+
const { success, deployId } = await this.localDevProcess.deployLatestBuild(force);
|
|
57
|
+
this.sendMessage(websocket, {
|
|
58
|
+
type: success
|
|
59
|
+
? LOCAL_DEV_UI_MESSAGE_SEND_TYPES.DEPLOY_SUCCESS
|
|
60
|
+
: LOCAL_DEV_UI_MESSAGE_SEND_TYPES.DEPLOY_FAILURE,
|
|
61
|
+
data: {
|
|
62
|
+
latestBuild: this.localDevProcess.projectData.latestBuild,
|
|
63
|
+
deployedBuild: this.localDevProcess.projectData.deployedBuild,
|
|
64
|
+
latestDeployId: deployId,
|
|
65
|
+
},
|
|
66
|
+
});
|
|
49
67
|
}
|
|
50
68
|
setupMessageHandlers(websocket) {
|
|
51
69
|
websocket.on('message', data => {
|
|
@@ -55,15 +73,17 @@ class LocalDevWebsocketServer {
|
|
|
55
73
|
this.logError(lib.LocalDevWebsocketServer.errors.missingTypeField(data.toString()));
|
|
56
74
|
return;
|
|
57
75
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
76
|
+
if (isUploadWebsocketMessage(message)) {
|
|
77
|
+
this.handleUpload(websocket);
|
|
78
|
+
}
|
|
79
|
+
else if (isDeployWebsocketMessage(message)) {
|
|
80
|
+
this.handleDeploy(websocket, message.data.force);
|
|
81
|
+
}
|
|
82
|
+
else if (isViewedWelcomeScreenWebsocketMessage(message)) {
|
|
83
|
+
addLocalStateFlag(CONFIG_LOCAL_STATE_FLAGS.LOCAL_DEV_UI_WELCOME);
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
this.logError(lib.LocalDevWebsocketServer.errors.unknownMessageType(message.type));
|
|
67
87
|
}
|
|
68
88
|
}
|
|
69
89
|
catch (e) {
|
|
@@ -71,12 +91,23 @@ class LocalDevWebsocketServer {
|
|
|
71
91
|
}
|
|
72
92
|
});
|
|
73
93
|
}
|
|
94
|
+
sendCliMetadata(websocket) {
|
|
95
|
+
this.sendMessage(websocket, {
|
|
96
|
+
type: LOCAL_DEV_UI_MESSAGE_SEND_TYPES.CLI_METADATA,
|
|
97
|
+
data: {
|
|
98
|
+
cliVersion: pkg.version,
|
|
99
|
+
localDevWebsocketServerVersion: LOCAL_DEV_WEBSOCKET_SERVER_VERSION,
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
}
|
|
74
103
|
sendProjectData(websocket) {
|
|
75
104
|
this.sendMessage(websocket, {
|
|
76
105
|
type: LOCAL_DEV_UI_MESSAGE_SEND_TYPES.UPDATE_PROJECT_DATA,
|
|
77
106
|
data: {
|
|
78
|
-
projectName: this.localDevProcess.
|
|
79
|
-
projectId: this.localDevProcess.
|
|
107
|
+
projectName: this.localDevProcess.projectData.name,
|
|
108
|
+
projectId: this.localDevProcess.projectData.id,
|
|
109
|
+
latestBuild: this.localDevProcess.projectData.latestBuild,
|
|
110
|
+
deployedBuild: this.localDevProcess.projectData.deployedBuild,
|
|
80
111
|
targetProjectAccountId: this.localDevProcess.targetProjectAccountId,
|
|
81
112
|
targetTestingAccountId: this.localDevProcess.targetTestingAccountId,
|
|
82
113
|
},
|
|
@@ -139,6 +170,7 @@ class LocalDevWebsocketServer {
|
|
|
139
170
|
ws.close(1008, lib.LocalDevWebsocketServer.errors.originNotAllowed(origin));
|
|
140
171
|
return;
|
|
141
172
|
}
|
|
173
|
+
this.sendCliMetadata(ws);
|
|
142
174
|
this.sendProjectData(ws);
|
|
143
175
|
this.setupMessageHandlers(ws);
|
|
144
176
|
this.setupStateListeners(ws);
|
|
@@ -18,7 +18,7 @@ import SpinniesManager from '../../../ui/SpinniesManager.js';
|
|
|
18
18
|
import { EXIT_CODES } from '../../../enums/exitCodes.js';
|
|
19
19
|
import { handleProjectUpload } from '../../upload.js';
|
|
20
20
|
import { pollProjectBuildAndDeploy } from '../../pollProjectBuildAndDeploy.js';
|
|
21
|
-
import { logError } from '../../../errorHandlers/index.js';
|
|
21
|
+
import { debugError, logError } from '../../../errorHandlers/index.js';
|
|
22
22
|
import { ApiErrorContext } from '../../../errorHandlers/index.js';
|
|
23
23
|
// Prompt the user to create a new project if one doesn't exist on their target account
|
|
24
24
|
export async function createNewProjectForLocalDev(projectConfig, targetAccountId, shouldCreateWithoutConfirmation, hasPublicApps) {
|
|
@@ -163,6 +163,10 @@ export async function isDeployedProjectUpToDateWithLocal(projectConfig, accountI
|
|
|
163
163
|
}, { profile });
|
|
164
164
|
return isDeepEqual(localProjectNodes, deployedProjectNodes, ['localDev']);
|
|
165
165
|
}
|
|
166
|
+
catch (err) {
|
|
167
|
+
debugError(err);
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
166
170
|
finally {
|
|
167
171
|
// Clean up temporary directory
|
|
168
172
|
if (tempDir && (await fs.pathExists(tempDir))) {
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { LocalDevDeployWebsocketMessage, LocalDevWebsocketMessage } from '../../../types/LocalDev.js';
|
|
2
|
+
export declare function isUploadWebsocketMessage(message: LocalDevWebsocketMessage): boolean;
|
|
3
|
+
export declare function isDeployWebsocketMessage(message: LocalDevWebsocketMessage): message is LocalDevDeployWebsocketMessage;
|
|
4
|
+
export declare function isViewedWelcomeScreenWebsocketMessage(message: LocalDevWebsocketMessage): boolean;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { LOCAL_DEV_UI_MESSAGE_RECEIVE_TYPES } from '../../constants.js';
|
|
2
|
+
export function isUploadWebsocketMessage(message) {
|
|
3
|
+
return message.type === LOCAL_DEV_UI_MESSAGE_RECEIVE_TYPES.UPLOAD;
|
|
4
|
+
}
|
|
5
|
+
export function isDeployWebsocketMessage(message) {
|
|
6
|
+
return message.type === LOCAL_DEV_UI_MESSAGE_RECEIVE_TYPES.DEPLOY;
|
|
7
|
+
}
|
|
8
|
+
export function isViewedWelcomeScreenWebsocketMessage(message) {
|
|
9
|
+
return (message.type === LOCAL_DEV_UI_MESSAGE_RECEIVE_TYPES.VIEWED_WELCOME_SCREEN);
|
|
10
|
+
}
|
|
@@ -278,10 +278,10 @@ export async function displayWarnLogs(accountId, projectName, taskId, isDeploy =
|
|
|
278
278
|
}
|
|
279
279
|
}
|
|
280
280
|
if (result && result.logs) {
|
|
281
|
-
const
|
|
282
|
-
|
|
283
|
-
uiLogger.warn(log
|
|
284
|
-
if (i <
|
|
281
|
+
const dedupedLogs = result.logs.reduce((acc, log) => acc.add(log.message), new Set());
|
|
282
|
+
Array.from(dedupedLogs).forEach((log, i) => {
|
|
283
|
+
uiLogger.warn(log);
|
|
284
|
+
if (i < dedupedLogs.size - 1) {
|
|
285
285
|
uiLogger.log('');
|
|
286
286
|
}
|
|
287
287
|
});
|
|
@@ -62,10 +62,11 @@ export async function projectAddPromptV3(components, selectedFeatures) {
|
|
|
62
62
|
const result = await promptUser([
|
|
63
63
|
{
|
|
64
64
|
name: 'componentTemplate',
|
|
65
|
-
message: lib.prompts.projectAddPrompt.
|
|
65
|
+
message: lib.prompts.projectAddPrompt.selectFeatures,
|
|
66
66
|
when: !selectedFeatures && selectedComponents.length === 0,
|
|
67
67
|
type: 'checkbox',
|
|
68
68
|
choices: components,
|
|
69
|
+
pageSize: components.length,
|
|
69
70
|
},
|
|
70
71
|
]);
|
|
71
72
|
if (!result.componentTemplate) {
|