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