@hubspot/cli 7.0.2-experimental.0 → 7.0.2
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 +7 -2
- package/commands/account/info.d.ts +7 -0
- package/commands/account/info.js +28 -25
- package/commands/account/remove.js +4 -4
- package/commands/account/use.js +3 -3
- package/commands/auth.js +3 -3
- package/commands/function/deploy.js +1 -1
- package/commands/init.js +1 -1
- package/commands/logs.js +1 -7
- package/commands/project/cloneApp.js +1 -1
- package/commands/project/create.js +6 -0
- package/commands/project/installDeps.js +2 -4
- package/commands/project/migrateApp.js +1 -1
- package/commands/project/upload.js +5 -10
- package/commands/project/watch.js +4 -4
- package/commands/sandbox/create.js +2 -8
- package/commands/sandbox/delete.js +6 -10
- package/lang/en.lyaml +9 -4
- package/lib/LocalDevManager.d.ts +58 -1
- package/lib/LocalDevManager.js +162 -122
- package/lib/buildAccount.d.ts +12 -0
- package/lib/buildAccount.js +110 -95
- package/lib/commonOpts.d.ts +4 -8
- package/lib/commonOpts.js +2 -14
- package/lib/constants.d.ts +1 -7
- package/lib/constants.js +2 -8
- package/lib/developerTestAccounts.d.ts +1 -0
- package/lib/developerTestAccounts.js +1 -0
- package/lib/localDev.d.ts +17 -1
- package/lib/localDev.js +203 -197
- package/lib/polling.d.ts +13 -5
- package/lib/polling.js +21 -7
- package/lib/projects/buildAndDeploy.d.ts +1 -7
- package/lib/projects/buildAndDeploy.js +3 -3
- package/lib/projects/index.js +9 -4
- package/lib/projects/structure.d.ts +3 -0
- package/lib/projects/structure.js +21 -0
- package/lib/projects/upload.d.ts +4 -3
- package/lib/projects/upload.js +7 -31
- package/lib/prompts/createProjectPrompt.js +8 -1
- package/lib/prompts/installPublicAppPrompt.d.ts +1 -1
- package/lib/prompts/personalAccessKeyPrompt.d.ts +1 -1
- package/lib/prompts/projectDevTargetAccountPrompt.d.ts +2 -2
- package/lib/sandboxes.d.ts +1 -1
- package/lib/serverlessLogs.d.ts +4 -1
- package/lib/serverlessLogs.js +64 -60
- package/lib/ui/serverlessFunctionLogs.d.ts +8 -0
- package/lib/ui/serverlessFunctionLogs.js +1 -3
- package/lib/validation.d.ts +2 -0
- package/lib/validation.js +5 -8
- package/package.json +3 -4
- package/types/Projects.d.ts +8 -2
- package/types/Yargs.d.ts +14 -0
- package/types/Yargs.js +2 -0
package/lib/LocalDevManager.js
CHANGED
|
@@ -1,27 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
const { confirmPrompt } = require('./prompts/promptUtils');
|
|
6
|
+
const path_1 = __importDefault(require("path"));
|
|
7
|
+
const chokidar_1 = __importDefault(require("chokidar"));
|
|
8
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
10
|
+
const localDevAuth_1 = require("@hubspot/local-dev-lib/api/localDevAuth");
|
|
11
|
+
const appsDev_1 = require("@hubspot/local-dev-lib/api/appsDev");
|
|
12
|
+
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
13
|
+
const constants_1 = require("./constants");
|
|
14
|
+
const SpinniesManager_1 = __importDefault(require("./ui/SpinniesManager"));
|
|
15
|
+
const DevServerManager_1 = __importDefault(require("./DevServerManager"));
|
|
16
|
+
const exitCodes_1 = require("./enums/exitCodes");
|
|
17
|
+
const urls_1 = require("./projects/urls");
|
|
18
|
+
const localDev_1 = require("./localDev");
|
|
19
|
+
const structure_1 = require("./projects/structure");
|
|
20
|
+
const Projects_1 = require("../types/Projects");
|
|
21
|
+
const ui_1 = require("./ui");
|
|
22
|
+
const index_1 = require("./errorHandlers/index");
|
|
23
|
+
const installPublicAppPrompt_1 = require("./prompts/installPublicAppPrompt");
|
|
24
|
+
const promptUtils_1 = require("./prompts/promptUtils");
|
|
25
|
+
const lang_1 = require("./lang");
|
|
26
|
+
const process_1 = require("./process");
|
|
25
27
|
const WATCH_EVENTS = {
|
|
26
28
|
add: 'add',
|
|
27
29
|
change: 'change',
|
|
@@ -30,10 +32,27 @@ const WATCH_EVENTS = {
|
|
|
30
32
|
};
|
|
31
33
|
const i18nKey = 'lib.LocalDevManager';
|
|
32
34
|
class LocalDevManager {
|
|
35
|
+
targetAccountId;
|
|
36
|
+
targetProjectAccountId;
|
|
37
|
+
projectConfig;
|
|
38
|
+
projectDir;
|
|
39
|
+
projectId;
|
|
40
|
+
debug;
|
|
41
|
+
deployedBuild;
|
|
42
|
+
isGithubLinked;
|
|
43
|
+
watcher;
|
|
44
|
+
uploadWarnings;
|
|
45
|
+
runnableComponents;
|
|
46
|
+
activeApp;
|
|
47
|
+
activePublicAppData;
|
|
48
|
+
env;
|
|
49
|
+
publicAppActiveInstalls;
|
|
50
|
+
projectSourceDir;
|
|
51
|
+
mostRecentUploadWarning;
|
|
33
52
|
constructor(options) {
|
|
34
53
|
this.targetAccountId = options.targetAccountId;
|
|
35
54
|
// The account that the project exists in. This is not always the targetAccountId
|
|
36
|
-
this.targetProjectAccountId = options.parentAccountId
|
|
55
|
+
this.targetProjectAccountId = options.parentAccountId;
|
|
37
56
|
this.projectConfig = options.projectConfig;
|
|
38
57
|
this.projectDir = options.projectDir;
|
|
39
58
|
this.projectId = options.projectId;
|
|
@@ -47,30 +66,32 @@ class LocalDevManager {
|
|
|
47
66
|
this.activePublicAppData = null;
|
|
48
67
|
this.env = options.env;
|
|
49
68
|
this.publicAppActiveInstalls = null;
|
|
50
|
-
this.
|
|
69
|
+
this.mostRecentUploadWarning = null;
|
|
70
|
+
this.projectSourceDir = path_1.default.join(this.projectDir, this.projectConfig.srcDir);
|
|
51
71
|
if (!this.targetAccountId || !this.projectConfig || !this.projectDir) {
|
|
52
|
-
logger.log(i18n(`${i18nKey}.failedToInitialize`));
|
|
53
|
-
process.exit(EXIT_CODES.ERROR);
|
|
72
|
+
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.failedToInitialize`));
|
|
73
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
54
74
|
}
|
|
55
75
|
}
|
|
56
76
|
async setActiveApp(appUid) {
|
|
57
77
|
if (!appUid) {
|
|
58
|
-
logger.error(i18n(`${i18nKey}.missingUid`, {
|
|
59
|
-
devCommand: uiCommandReference('hs project dev'),
|
|
78
|
+
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.missingUid`, {
|
|
79
|
+
devCommand: (0, ui_1.uiCommandReference)('hs project dev'),
|
|
60
80
|
}));
|
|
61
|
-
process.exit(EXIT_CODES.ERROR);
|
|
81
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
62
82
|
}
|
|
63
|
-
this.activeApp =
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
83
|
+
this.activeApp =
|
|
84
|
+
this.runnableComponents.find(component => {
|
|
85
|
+
return (0, structure_1.getComponentUid)(component) === appUid;
|
|
86
|
+
}) || null;
|
|
87
|
+
if ((0, structure_1.componentIsPublicApp)(this.activeApp)) {
|
|
67
88
|
try {
|
|
68
89
|
await this.setActivePublicAppData();
|
|
69
90
|
await this.checkActivePublicAppInstalls();
|
|
70
91
|
await this.checkPublicAppInstallation();
|
|
71
92
|
}
|
|
72
93
|
catch (e) {
|
|
73
|
-
logError(e);
|
|
94
|
+
(0, index_1.logError)(e);
|
|
74
95
|
}
|
|
75
96
|
}
|
|
76
97
|
}
|
|
@@ -78,10 +99,12 @@ class LocalDevManager {
|
|
|
78
99
|
if (!this.activeApp) {
|
|
79
100
|
return;
|
|
80
101
|
}
|
|
81
|
-
const { data: { results: portalPublicApps }, } = await fetchPublicAppsForPortal(this.targetProjectAccountId);
|
|
82
|
-
const activePublicAppData = portalPublicApps.find(({ sourceId }) => sourceId === this.activeApp
|
|
83
|
-
|
|
84
|
-
|
|
102
|
+
const { data: { results: portalPublicApps }, } = await (0, appsDev_1.fetchPublicAppsForPortal)(this.targetProjectAccountId);
|
|
103
|
+
const activePublicAppData = portalPublicApps.find(({ sourceId }) => sourceId === (0, structure_1.getComponentUid)(this.activeApp));
|
|
104
|
+
if (!activePublicAppData) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const { data: { uniquePortalInstallCount }, } = await (0, appsDev_1.fetchPublicAppProductionInstallCounts)(activePublicAppData.id, this.targetProjectAccountId);
|
|
85
108
|
this.activePublicAppData = activePublicAppData;
|
|
86
109
|
this.publicAppActiveInstalls = uniquePortalInstallCount;
|
|
87
110
|
}
|
|
@@ -91,54 +114,54 @@ class LocalDevManager {
|
|
|
91
114
|
this.publicAppActiveInstalls < 1) {
|
|
92
115
|
return;
|
|
93
116
|
}
|
|
94
|
-
uiLine();
|
|
95
|
-
logger.warn(i18n(`${i18nKey}.activeInstallWarning.installCount`, {
|
|
117
|
+
(0, ui_1.uiLine)();
|
|
118
|
+
logger_1.logger.warn((0, lang_1.i18n)(`${i18nKey}.activeInstallWarning.installCount`, {
|
|
96
119
|
appName: this.activePublicAppData.name,
|
|
97
120
|
installCount: this.publicAppActiveInstalls,
|
|
98
121
|
installText: this.publicAppActiveInstalls === 1 ? 'install' : 'installs',
|
|
99
122
|
}));
|
|
100
|
-
logger.log(i18n(`${i18nKey}.activeInstallWarning.explanation`));
|
|
101
|
-
uiLine();
|
|
102
|
-
const proceed = await confirmPrompt(i18n(`${i18nKey}.activeInstallWarning.confirmationPrompt`), { defaultAnswer: false });
|
|
123
|
+
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.activeInstallWarning.explanation`));
|
|
124
|
+
(0, ui_1.uiLine)();
|
|
125
|
+
const proceed = await (0, promptUtils_1.confirmPrompt)((0, lang_1.i18n)(`${i18nKey}.activeInstallWarning.confirmationPrompt`), { defaultAnswer: false });
|
|
103
126
|
if (!proceed) {
|
|
104
|
-
process.exit(EXIT_CODES.SUCCESS);
|
|
127
|
+
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
105
128
|
}
|
|
106
129
|
}
|
|
107
130
|
async start() {
|
|
108
|
-
|
|
109
|
-
|
|
131
|
+
SpinniesManager_1.default.stopAll();
|
|
132
|
+
SpinniesManager_1.default.init();
|
|
110
133
|
// Local dev currently relies on the existence of a deployed build in the target account
|
|
111
134
|
if (!this.deployedBuild) {
|
|
112
|
-
logger.error(i18n(`${i18nKey}.noDeployedBuild`, {
|
|
135
|
+
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.noDeployedBuild`, {
|
|
113
136
|
projectName: this.projectConfig.name,
|
|
114
|
-
accountIdentifier: uiAccountDescription(this.targetProjectAccountId),
|
|
137
|
+
accountIdentifier: (0, ui_1.uiAccountDescription)(this.targetProjectAccountId),
|
|
115
138
|
uploadCommand: this.getUploadCommand(),
|
|
116
139
|
}));
|
|
117
|
-
logger.log();
|
|
118
|
-
process.exit(EXIT_CODES.SUCCESS);
|
|
140
|
+
logger_1.logger.log();
|
|
141
|
+
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
119
142
|
}
|
|
120
143
|
const setupSucceeded = await this.devServerSetup();
|
|
121
144
|
if (!setupSucceeded) {
|
|
122
|
-
process.exit(EXIT_CODES.ERROR);
|
|
145
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
123
146
|
}
|
|
124
147
|
else if (!this.debug) {
|
|
125
148
|
console.clear();
|
|
126
149
|
}
|
|
127
|
-
uiBetaTag(i18n(`${i18nKey}.betaMessage`));
|
|
128
|
-
logger.log(uiLink(i18n(`${i18nKey}.learnMoreLocalDevServer`), 'https://developers.hubspot.com/docs/platform/project-cli-commands#start-a-local-development-server'));
|
|
129
|
-
logger.log();
|
|
130
|
-
logger.log(
|
|
131
|
-
accountIdentifier: uiAccountDescription(this.targetAccountId),
|
|
150
|
+
(0, ui_1.uiBetaTag)((0, lang_1.i18n)(`${i18nKey}.betaMessage`));
|
|
151
|
+
logger_1.logger.log((0, ui_1.uiLink)((0, lang_1.i18n)(`${i18nKey}.learnMoreLocalDevServer`), 'https://developers.hubspot.com/docs/platform/project-cli-commands#start-a-local-development-server'));
|
|
152
|
+
logger_1.logger.log();
|
|
153
|
+
logger_1.logger.log(chalk_1.default.hex(ui_1.UI_COLORS.SORBET)((0, lang_1.i18n)(`${i18nKey}.running`, {
|
|
154
|
+
accountIdentifier: (0, ui_1.uiAccountDescription)(this.targetAccountId),
|
|
132
155
|
projectName: this.projectConfig.name,
|
|
133
156
|
})));
|
|
134
|
-
logger.log(uiLink(i18n(`${i18nKey}.viewProjectLink`), getProjectDetailUrl(this.projectConfig.name, this.targetProjectAccountId)));
|
|
135
|
-
if (this.activeApp
|
|
136
|
-
logger.log(uiLink(i18n(`${i18nKey}.viewTestAccountLink`), getAccountHomeUrl(this.targetAccountId)));
|
|
157
|
+
logger_1.logger.log((0, ui_1.uiLink)((0, lang_1.i18n)(`${i18nKey}.viewProjectLink`), (0, urls_1.getProjectDetailUrl)(this.projectConfig.name, this.targetProjectAccountId) || ''));
|
|
158
|
+
if (this.activeApp?.type === Projects_1.ComponentTypes.PublicApp) {
|
|
159
|
+
logger_1.logger.log((0, ui_1.uiLink)((0, lang_1.i18n)(`${i18nKey}.viewTestAccountLink`), (0, localDev_1.getAccountHomeUrl)(this.targetAccountId)));
|
|
137
160
|
}
|
|
138
|
-
logger.log();
|
|
139
|
-
logger.log(i18n(`${i18nKey}.quitHelper`));
|
|
140
|
-
uiLine();
|
|
141
|
-
logger.log();
|
|
161
|
+
logger_1.logger.log();
|
|
162
|
+
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.quitHelper`));
|
|
163
|
+
(0, ui_1.uiLine)();
|
|
164
|
+
logger_1.logger.log();
|
|
142
165
|
await this.devServerStart();
|
|
143
166
|
// Initialize project file watcher to detect configuration file changes
|
|
144
167
|
this.startWatching();
|
|
@@ -150,81 +173,84 @@ class LocalDevManager {
|
|
|
150
173
|
}
|
|
151
174
|
async stop(showProgress = true) {
|
|
152
175
|
if (showProgress) {
|
|
153
|
-
|
|
154
|
-
text: i18n(`${i18nKey}.exitingStart`),
|
|
176
|
+
SpinniesManager_1.default.add('cleanupMessage', {
|
|
177
|
+
text: (0, lang_1.i18n)(`${i18nKey}.exitingStart`),
|
|
155
178
|
});
|
|
156
179
|
}
|
|
157
180
|
await this.stopWatching();
|
|
158
181
|
const cleanupSucceeded = await this.devServerCleanup();
|
|
159
182
|
if (!cleanupSucceeded) {
|
|
160
183
|
if (showProgress) {
|
|
161
|
-
|
|
162
|
-
text: i18n(`${i18nKey}.exitingFail`),
|
|
184
|
+
SpinniesManager_1.default.fail('cleanupMessage', {
|
|
185
|
+
text: (0, lang_1.i18n)(`${i18nKey}.exitingFail`),
|
|
163
186
|
});
|
|
164
187
|
}
|
|
165
|
-
process.exit(EXIT_CODES.ERROR);
|
|
188
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
166
189
|
}
|
|
167
190
|
if (showProgress) {
|
|
168
|
-
|
|
169
|
-
text: i18n(`${i18nKey}.exitingSucceed`),
|
|
191
|
+
SpinniesManager_1.default.succeed('cleanupMessage', {
|
|
192
|
+
text: (0, lang_1.i18n)(`${i18nKey}.exitingSucceed`),
|
|
170
193
|
});
|
|
171
194
|
}
|
|
172
|
-
process.exit(EXIT_CODES.SUCCESS);
|
|
173
|
-
}
|
|
174
|
-
async getActiveAppInstallationData() {
|
|
175
|
-
const { data } = await fetchAppInstallationData(this.targetAccountId, this.projectId, this.activeApp.config.uid, this.activeApp.config.auth.requiredScopes, this.activeApp.config.auth.optionalScopes);
|
|
176
|
-
return data;
|
|
195
|
+
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
177
196
|
}
|
|
178
197
|
async checkPublicAppInstallation() {
|
|
179
|
-
|
|
198
|
+
if (!(0, structure_1.componentIsPublicApp)(this.activeApp) || !this.activePublicAppData) {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
const { data: { isInstalledWithScopeGroups, previouslyAuthorizedScopeGroups }, } = await (0, localDevAuth_1.fetchAppInstallationData)(this.targetAccountId, this.projectId, this.activeApp.config.uid, this.activeApp.config.auth.requiredScopes, this.activeApp.config.auth.optionalScopes);
|
|
180
202
|
const isReinstall = previouslyAuthorizedScopeGroups.length > 0;
|
|
181
203
|
if (!isInstalledWithScopeGroups) {
|
|
182
|
-
await installPublicAppPrompt(this.env, this.targetAccountId, this.activePublicAppData.clientId, this.activeApp.config.auth.requiredScopes, this.activeApp.config.auth.redirectUrls, isReinstall);
|
|
204
|
+
await (0, installPublicAppPrompt_1.installPublicAppPrompt)(this.env, this.targetAccountId, this.activePublicAppData.clientId, this.activeApp.config.auth.requiredScopes, this.activeApp.config.auth.redirectUrls, isReinstall);
|
|
183
205
|
}
|
|
184
206
|
}
|
|
185
207
|
updateKeypressListeners() {
|
|
186
|
-
handleKeypress(async (key) => {
|
|
208
|
+
(0, process_1.handleKeypress)(async (key) => {
|
|
187
209
|
if ((key.ctrl && key.name === 'c') || key.name === 'q') {
|
|
188
210
|
this.stop();
|
|
189
211
|
}
|
|
190
212
|
});
|
|
191
213
|
}
|
|
192
214
|
getUploadCommand() {
|
|
193
|
-
const currentDefaultAccount = getConfigDefaultAccount();
|
|
194
|
-
return this.targetProjectAccountId !== getAccountId(currentDefaultAccount)
|
|
195
|
-
? uiCommandReference(`hs project upload --account=${this.targetProjectAccountId}`)
|
|
196
|
-
: uiCommandReference('hs project upload');
|
|
215
|
+
const currentDefaultAccount = (0, config_1.getConfigDefaultAccount)() || undefined;
|
|
216
|
+
return this.targetProjectAccountId !== (0, config_1.getAccountId)(currentDefaultAccount)
|
|
217
|
+
? (0, ui_1.uiCommandReference)(`hs project upload --account=${this.targetProjectAccountId}`)
|
|
218
|
+
: (0, ui_1.uiCommandReference)('hs project upload');
|
|
197
219
|
}
|
|
198
220
|
logUploadWarning(reason) {
|
|
199
|
-
let warning
|
|
200
|
-
if (
|
|
221
|
+
let warning;
|
|
222
|
+
if (reason) {
|
|
223
|
+
warning = reason;
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
201
226
|
warning =
|
|
202
|
-
this.activeApp
|
|
227
|
+
(0, structure_1.componentIsPublicApp)(this.activeApp) &&
|
|
228
|
+
this.publicAppActiveInstalls &&
|
|
203
229
|
this.publicAppActiveInstalls > 0
|
|
204
|
-
? i18n(`${i18nKey}.uploadWarning.defaultPublicAppWarning`, {
|
|
230
|
+
? (0, lang_1.i18n)(`${i18nKey}.uploadWarning.defaultPublicAppWarning`, {
|
|
205
231
|
installCount: this.publicAppActiveInstalls,
|
|
206
232
|
installText: this.publicAppActiveInstalls === 1 ? 'install' : 'installs',
|
|
207
233
|
})
|
|
208
|
-
: i18n(`${i18nKey}.uploadWarning.defaultWarning`);
|
|
234
|
+
: (0, lang_1.i18n)(`${i18nKey}.uploadWarning.defaultWarning`);
|
|
209
235
|
}
|
|
210
236
|
// Avoid logging the warning to the console if it is currently the most
|
|
211
237
|
// recently logged warning. We do not want to spam the console with the same message.
|
|
212
238
|
if (!this.uploadWarnings[warning]) {
|
|
213
|
-
logger.log();
|
|
214
|
-
logger.warn(i18n(`${i18nKey}.uploadWarning.header`, { warning }));
|
|
215
|
-
logger.log(i18n(`${i18nKey}.uploadWarning.stopDev`, {
|
|
216
|
-
command: uiCommandReference('hs project dev'),
|
|
239
|
+
logger_1.logger.log();
|
|
240
|
+
logger_1.logger.warn((0, lang_1.i18n)(`${i18nKey}.uploadWarning.header`, { warning }));
|
|
241
|
+
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.uploadWarning.stopDev`, {
|
|
242
|
+
command: (0, ui_1.uiCommandReference)('hs project dev'),
|
|
217
243
|
}));
|
|
218
244
|
if (this.isGithubLinked) {
|
|
219
|
-
logger.log(i18n(`${i18nKey}.uploadWarning.pushToGithub`));
|
|
245
|
+
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.uploadWarning.pushToGithub`));
|
|
220
246
|
}
|
|
221
247
|
else {
|
|
222
|
-
logger.log(i18n(`${i18nKey}.uploadWarning.runUpload`, {
|
|
248
|
+
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.uploadWarning.runUpload`, {
|
|
223
249
|
command: this.getUploadCommand(),
|
|
224
250
|
}));
|
|
225
251
|
}
|
|
226
|
-
logger.log(i18n(`${i18nKey}.uploadWarning.restartDev`, {
|
|
227
|
-
command: uiCommandReference('hs project dev'),
|
|
252
|
+
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.uploadWarning.restartDev`, {
|
|
253
|
+
command: (0, ui_1.uiCommandReference)('hs project dev'),
|
|
228
254
|
}));
|
|
229
255
|
this.mostRecentUploadWarning = warning;
|
|
230
256
|
this.uploadWarnings[warning] = true;
|
|
@@ -232,50 +258,57 @@ class LocalDevManager {
|
|
|
232
258
|
}
|
|
233
259
|
monitorConsoleOutput() {
|
|
234
260
|
const originalStdoutWrite = process.stdout.write.bind(process.stdout);
|
|
235
|
-
|
|
261
|
+
function customStdoutWrite(chunk, encoding, callback) {
|
|
236
262
|
// Reset the most recently logged warning
|
|
237
263
|
if (this.mostRecentUploadWarning &&
|
|
238
264
|
this.uploadWarnings[this.mostRecentUploadWarning]) {
|
|
239
265
|
delete this.uploadWarnings[this.mostRecentUploadWarning];
|
|
240
266
|
}
|
|
267
|
+
if (typeof encoding === 'function') {
|
|
268
|
+
return originalStdoutWrite(chunk, callback);
|
|
269
|
+
}
|
|
241
270
|
return originalStdoutWrite(chunk, encoding, callback);
|
|
242
|
-
}
|
|
271
|
+
}
|
|
272
|
+
customStdoutWrite.bind(this);
|
|
273
|
+
process.stdout.write = customStdoutWrite;
|
|
243
274
|
}
|
|
244
275
|
compareLocalProjectToDeployed() {
|
|
245
276
|
const deployedComponentNames = this.deployedBuild.subbuildStatuses.map(subbuildStatus => subbuildStatus.buildName);
|
|
246
277
|
const missingComponents = [];
|
|
247
|
-
this.runnableComponents
|
|
248
|
-
|
|
249
|
-
|
|
278
|
+
this.runnableComponents
|
|
279
|
+
.filter(structure_1.componentIsApp)
|
|
280
|
+
.forEach(({ type, config, path }) => {
|
|
281
|
+
if (Object.values(Projects_1.ComponentTypes).includes(type)) {
|
|
282
|
+
const cardConfigs = (0, structure_1.getAppCardConfigs)(config, path);
|
|
250
283
|
if (!deployedComponentNames.includes(config.name)) {
|
|
251
|
-
missingComponents.push(`${i18n(`${i18nKey}.uploadWarning.appLabel`)} ${config.name}`);
|
|
284
|
+
missingComponents.push(`${(0, lang_1.i18n)(`${i18nKey}.uploadWarning.appLabel`)} ${config.name}`);
|
|
252
285
|
}
|
|
253
286
|
cardConfigs.forEach(cardConfig => {
|
|
254
287
|
if (cardConfig.data &&
|
|
255
288
|
cardConfig.data.title &&
|
|
256
289
|
!deployedComponentNames.includes(cardConfig.data.title)) {
|
|
257
|
-
missingComponents.push(`${i18n(`${i18nKey}.uploadWarning.uiExtensionLabel`)} ${cardConfig.data.title}`);
|
|
290
|
+
missingComponents.push(`${(0, lang_1.i18n)(`${i18nKey}.uploadWarning.uiExtensionLabel`)} ${cardConfig.data.title}`);
|
|
258
291
|
}
|
|
259
292
|
});
|
|
260
293
|
}
|
|
261
294
|
});
|
|
262
295
|
if (missingComponents.length) {
|
|
263
|
-
this.logUploadWarning(i18n(`${i18nKey}.uploadWarning.missingComponents`, {
|
|
296
|
+
this.logUploadWarning((0, lang_1.i18n)(`${i18nKey}.uploadWarning.missingComponents`, {
|
|
264
297
|
missingComponents: missingComponents.join(', '),
|
|
265
298
|
}));
|
|
266
299
|
}
|
|
267
300
|
}
|
|
268
301
|
startWatching() {
|
|
269
|
-
this.watcher =
|
|
302
|
+
this.watcher = chokidar_1.default.watch(this.projectDir, {
|
|
270
303
|
ignoreInitial: true,
|
|
271
304
|
});
|
|
272
305
|
const configPaths = this.runnableComponents
|
|
273
|
-
.filter(({ type }) => Object.values(ComponentTypes).includes(type))
|
|
306
|
+
.filter(({ type }) => Object.values(Projects_1.ComponentTypes).includes(type))
|
|
274
307
|
.map(component => {
|
|
275
|
-
const appConfigPath =
|
|
308
|
+
const appConfigPath = path_1.default.join(component.path, structure_1.CONFIG_FILES[component.type]);
|
|
276
309
|
return appConfigPath;
|
|
277
310
|
});
|
|
278
|
-
const projectConfigPath =
|
|
311
|
+
const projectConfigPath = path_1.default.join(this.projectDir, constants_1.PROJECT_CONFIG_FILE);
|
|
279
312
|
configPaths.push(projectConfigPath);
|
|
280
313
|
this.watcher.on('add', filePath => {
|
|
281
314
|
this.handleWatchEvent(filePath, WATCH_EVENTS.add, configPaths);
|
|
@@ -291,7 +324,7 @@ class LocalDevManager {
|
|
|
291
324
|
});
|
|
292
325
|
}
|
|
293
326
|
async stopWatching() {
|
|
294
|
-
await this.watcher
|
|
327
|
+
await this.watcher?.close();
|
|
295
328
|
}
|
|
296
329
|
handleWatchEvent(filePath, event, configPaths) {
|
|
297
330
|
if (configPaths.includes(filePath)) {
|
|
@@ -303,7 +336,7 @@ class LocalDevManager {
|
|
|
303
336
|
}
|
|
304
337
|
async devServerSetup() {
|
|
305
338
|
try {
|
|
306
|
-
await
|
|
339
|
+
await DevServerManager_1.default.setup({
|
|
307
340
|
components: this.runnableComponents,
|
|
308
341
|
onUploadRequired: this.logUploadWarning.bind(this),
|
|
309
342
|
accountId: this.targetAccountId,
|
|
@@ -313,52 +346,59 @@ class LocalDevManager {
|
|
|
313
346
|
}
|
|
314
347
|
catch (e) {
|
|
315
348
|
if (this.debug) {
|
|
316
|
-
logger.error(e);
|
|
349
|
+
logger_1.logger.error(e);
|
|
317
350
|
}
|
|
318
|
-
logger.error(i18n(`${i18nKey}.devServer.setupError`, {
|
|
351
|
+
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.devServer.setupError`, {
|
|
352
|
+
message: e instanceof Error ? e.message : '',
|
|
353
|
+
}));
|
|
319
354
|
return false;
|
|
320
355
|
}
|
|
321
356
|
}
|
|
322
357
|
async devServerStart() {
|
|
323
358
|
try {
|
|
324
|
-
await
|
|
359
|
+
await DevServerManager_1.default.start({
|
|
325
360
|
accountId: this.targetAccountId,
|
|
326
361
|
projectConfig: this.projectConfig,
|
|
327
362
|
});
|
|
328
363
|
}
|
|
329
364
|
catch (e) {
|
|
330
365
|
if (this.debug) {
|
|
331
|
-
logger.error(e);
|
|
366
|
+
logger_1.logger.error(e);
|
|
332
367
|
}
|
|
333
|
-
logger.error(i18n(`${i18nKey}.devServer.startError`, {
|
|
334
|
-
|
|
368
|
+
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.devServer.startError`, {
|
|
369
|
+
message: e instanceof Error ? e.message : '',
|
|
370
|
+
}));
|
|
371
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
335
372
|
}
|
|
336
373
|
}
|
|
337
374
|
devServerFileChange(filePath, event) {
|
|
338
375
|
try {
|
|
339
|
-
|
|
376
|
+
DevServerManager_1.default.fileChange({ filePath, event });
|
|
340
377
|
}
|
|
341
378
|
catch (e) {
|
|
342
379
|
if (this.debug) {
|
|
343
|
-
logger.error(e);
|
|
380
|
+
logger_1.logger.error(e);
|
|
344
381
|
}
|
|
345
|
-
logger.error(i18n(`${i18nKey}.devServer.fileChangeError`, {
|
|
346
|
-
message: e.message,
|
|
382
|
+
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.devServer.fileChangeError`, {
|
|
383
|
+
message: e instanceof Error ? e.message : '',
|
|
347
384
|
}));
|
|
348
385
|
}
|
|
349
386
|
}
|
|
350
387
|
async devServerCleanup() {
|
|
351
388
|
try {
|
|
352
|
-
await
|
|
389
|
+
await DevServerManager_1.default.cleanup();
|
|
353
390
|
return true;
|
|
354
391
|
}
|
|
355
392
|
catch (e) {
|
|
356
393
|
if (this.debug) {
|
|
357
|
-
logger.error(e);
|
|
394
|
+
logger_1.logger.error(e);
|
|
358
395
|
}
|
|
359
|
-
logger.error(i18n(`${i18nKey}.devServer.cleanupError`, {
|
|
396
|
+
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.devServer.cleanupError`, {
|
|
397
|
+
message: e instanceof Error ? e.message : '',
|
|
398
|
+
}));
|
|
360
399
|
return false;
|
|
361
400
|
}
|
|
362
401
|
}
|
|
363
402
|
}
|
|
403
|
+
exports.default = LocalDevManager;
|
|
364
404
|
module.exports = LocalDevManager;
|
package/lib/buildAccount.d.ts
CHANGED
|
@@ -1 +1,13 @@
|
|
|
1
|
+
import { HUBSPOT_ACCOUNT_TYPES } from '@hubspot/local-dev-lib/constants/config';
|
|
2
|
+
import { Environment } from '@hubspot/local-dev-lib/types/Config';
|
|
3
|
+
import { CLIAccount } from '@hubspot/local-dev-lib/types/Accounts';
|
|
4
|
+
import { DeveloperTestAccount } from '@hubspot/local-dev-lib/types/developerTestAccounts';
|
|
5
|
+
import { SandboxResponse } from '@hubspot/local-dev-lib/types/Sandbox';
|
|
6
|
+
export declare function saveAccountToConfig(accountId: number | undefined, accountName: string, env: Environment, personalAccessKey?: string, force?: boolean): Promise<string>;
|
|
7
|
+
export declare function buildDeveloperTestAccount(name: string, accountConfig: CLIAccount, env: Environment, portalLimit: number): Promise<DeveloperTestAccount>;
|
|
8
|
+
type SandboxType = typeof HUBSPOT_ACCOUNT_TYPES.STANDARD_SANDBOX | typeof HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX;
|
|
9
|
+
type SandboxAccount = SandboxResponse & {
|
|
10
|
+
name: string;
|
|
11
|
+
};
|
|
12
|
+
export declare function buildSandbox(name: string, accountConfig: CLIAccount, sandboxType: SandboxType, env: Environment, force?: boolean): Promise<SandboxAccount>;
|
|
1
13
|
export {};
|