@hubspot/cli 5.1.4-beta.7 → 5.2.1-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/accounts/use.js +1 -1
- package/commands/cms/convertFields.js +1 -1
- package/commands/project/dev.js +1 -1
- package/commands/project/upload.js +1 -1
- package/commands/theme/preview.js +4 -2
- package/lib/commonOpts.js +0 -9
- package/lib/errorHandlers/apiErrors.js +7 -224
- package/lib/errorHandlers/fileSystemErrors.js +5 -40
- package/lib/errorHandlers/standardErrors.js +3 -9
- package/lib/process.js +0 -5
- package/lib/projects.js +4 -2
- package/lib/projectsWatch.js +1 -1
- package/lib/prompts/cmsFieldPrompt.js +1 -1
- package/lib/serverlessLogs.js +9 -1
- package/lib/validation.js +3 -3
- package/package.json +5 -6
package/commands/accounts/use.js
CHANGED
|
@@ -4,7 +4,7 @@ const {
|
|
|
4
4
|
getConfigPath,
|
|
5
5
|
updateDefaultAccount,
|
|
6
6
|
getAccountId: getAccountIdFromConfig,
|
|
7
|
-
} = require('@hubspot/
|
|
7
|
+
} = require('@hubspot/local-dev-lib/config');
|
|
8
8
|
|
|
9
9
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
10
10
|
const { i18n } = require('../../lib/lang');
|
|
@@ -9,7 +9,7 @@ const { i18n } = require('../../lib/lang');
|
|
|
9
9
|
const {
|
|
10
10
|
FieldsJs,
|
|
11
11
|
isConvertableFieldJs,
|
|
12
|
-
} = require('@hubspot/local-dev-lib/cms/
|
|
12
|
+
} = require('@hubspot/local-dev-lib/cms/handleFieldsJS');
|
|
13
13
|
|
|
14
14
|
const { trackConvertFieldsUsage } = require('../../lib/usageTracking');
|
|
15
15
|
const { logErrorInstance } = require('../../lib/errorHandlers/standardErrors');
|
package/commands/project/dev.js
CHANGED
|
@@ -62,10 +62,10 @@ const { getHubSpotWebsiteOrigin } = require('@hubspot/local-dev-lib/urls');
|
|
|
62
62
|
const {
|
|
63
63
|
logApiErrorInstance,
|
|
64
64
|
ApiErrorContext,
|
|
65
|
-
isSpecifiedError, // Migrate isSpecifiedError to local-dev-lib version only after uploadProject is migrated to local-dev-lib
|
|
66
65
|
} = require('../../lib/errorHandlers/apiErrors');
|
|
67
66
|
const {
|
|
68
67
|
isMissingScopeError,
|
|
68
|
+
isSpecifiedError,
|
|
69
69
|
} = require('@hubspot/local-dev-lib/errors/apiErrors');
|
|
70
70
|
const { logErrorInstance } = require('../../lib/errorHandlers/standardErrors');
|
|
71
71
|
const { isDeveloperTestAccount } = require('../../lib/developerTestAccounts');
|
|
@@ -19,11 +19,11 @@ const {
|
|
|
19
19
|
} = require('../../lib/projects');
|
|
20
20
|
const { i18n } = require('../../lib/lang');
|
|
21
21
|
const { getAccountConfig } = require('@hubspot/local-dev-lib/config');
|
|
22
|
+
const { isSpecifiedError } = require('@hubspot/local-dev-lib/errors/apiErrors');
|
|
22
23
|
const { PROJECT_ERROR_TYPES } = require('../../lib/constants');
|
|
23
24
|
const {
|
|
24
25
|
logApiErrorInstance,
|
|
25
26
|
ApiErrorContext,
|
|
26
|
-
isSpecifiedError,
|
|
27
27
|
} = require('../../lib/errorHandlers/apiErrors');
|
|
28
28
|
const { EXIT_CODES } = require('../../lib/enums/exitCodes');
|
|
29
29
|
|
|
@@ -14,7 +14,9 @@ const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
|
14
14
|
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
15
15
|
const { previewPrompt } = require('../../lib/prompts/previewPrompt');
|
|
16
16
|
const { EXIT_CODES } = require('../../lib/enums/exitCodes');
|
|
17
|
-
const {
|
|
17
|
+
const {
|
|
18
|
+
FILE_UPLOAD_RESULT_TYPES,
|
|
19
|
+
} = require('@hubspot/local-dev-lib/constants/files');
|
|
18
20
|
const i18nKey = 'cli.commands.preview';
|
|
19
21
|
const cliProgress = require('cli-progress');
|
|
20
22
|
const {
|
|
@@ -121,7 +123,7 @@ exports.handler = async options => {
|
|
|
121
123
|
});
|
|
122
124
|
initialUploadProgressBar.stop();
|
|
123
125
|
results.forEach(result => {
|
|
124
|
-
if (result.resultType ==
|
|
126
|
+
if (result.resultType == FILE_UPLOAD_RESULT_TYPES.FAILURE) {
|
|
125
127
|
logger.error('Uploading file "%s" to "%s" failed', result.file, dest);
|
|
126
128
|
logApiUploadErrorInstance(
|
|
127
129
|
result.error,
|
package/lib/commonOpts.js
CHANGED
|
@@ -2,9 +2,6 @@ const {
|
|
|
2
2
|
LOG_LEVEL,
|
|
3
3
|
setLogLevel: setLoggerLogLevel,
|
|
4
4
|
} = require('@hubspot/local-dev-lib/logger');
|
|
5
|
-
const {
|
|
6
|
-
setLogLevel: setCliLibLoggerLogLevel,
|
|
7
|
-
} = require('@hubspot/cli-lib/logger');
|
|
8
5
|
const {
|
|
9
6
|
DEFAULT_MODE,
|
|
10
7
|
MODE,
|
|
@@ -74,14 +71,8 @@ const setLogLevel = (options = {}) => {
|
|
|
74
71
|
const { debug } = options;
|
|
75
72
|
if (debug) {
|
|
76
73
|
setLoggerLogLevel(LOG_LEVEL.DEBUG);
|
|
77
|
-
|
|
78
|
-
// TODO remove this when we remove cli-lib as a dep
|
|
79
|
-
setCliLibLoggerLogLevel(LOG_LEVEL.DEBUG);
|
|
80
74
|
} else {
|
|
81
75
|
setLoggerLogLevel(LOG_LEVEL.LOG);
|
|
82
|
-
|
|
83
|
-
// TODO remove this when we remove cli-lib as a dep
|
|
84
|
-
setCliLibLoggerLogLevel(LOG_LEVEL.LOG);
|
|
85
76
|
}
|
|
86
77
|
};
|
|
87
78
|
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
2
2
|
const { getAccountConfig } = require('@hubspot/local-dev-lib/config');
|
|
3
3
|
const {
|
|
4
|
+
isMissingScopeError,
|
|
5
|
+
isApiUploadValidationError,
|
|
4
6
|
getAxiosErrorWithContext,
|
|
7
|
+
parseValidationErrors,
|
|
5
8
|
} = require('@hubspot/local-dev-lib/errors/apiErrors');
|
|
6
9
|
const {
|
|
7
10
|
SCOPE_GROUPS,
|
|
8
11
|
PERSONAL_ACCESS_KEY_AUTH_METHOD,
|
|
9
12
|
} = require('@hubspot/local-dev-lib/constants/auth');
|
|
10
|
-
const {
|
|
11
|
-
fetchScopeData,
|
|
12
|
-
} = require('@hubspot/cli-lib/api/localDevAuth/authenticated');
|
|
13
|
+
const { fetchScopeData } = require('@hubspot/local-dev-lib/api/localDevAuth');
|
|
13
14
|
const {
|
|
14
15
|
debugErrorAndContext,
|
|
15
16
|
logErrorInstance,
|
|
@@ -20,80 +21,6 @@ const { i18n } = require('../lang');
|
|
|
20
21
|
|
|
21
22
|
const i18nKey = 'cli.lib.errorHandlers.apiErrors';
|
|
22
23
|
|
|
23
|
-
const isApiStatusCodeError = err =>
|
|
24
|
-
err.name === 'StatusCodeError' ||
|
|
25
|
-
(err.statusCode >= 100 && err.statusCode < 600);
|
|
26
|
-
|
|
27
|
-
const isApiUploadValidationError = err =>
|
|
28
|
-
!!(
|
|
29
|
-
err.statusCode === 400 &&
|
|
30
|
-
err.response &&
|
|
31
|
-
err.response.body &&
|
|
32
|
-
(err.response.body.message || err.response.body.errors)
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
const isMissingScopeError = err =>
|
|
36
|
-
err.name === 'StatusCodeError' &&
|
|
37
|
-
err.statusCode === 403 &&
|
|
38
|
-
err.error &&
|
|
39
|
-
err.error.category === 'MISSING_SCOPES';
|
|
40
|
-
|
|
41
|
-
const isGatingError = err =>
|
|
42
|
-
isSpecifiedError(err, { statusCode: 403, category: 'GATED' });
|
|
43
|
-
|
|
44
|
-
const isSpecifiedError = (err, { statusCode, category, subCategory } = {}) => {
|
|
45
|
-
const statusCodeErr = !statusCode || err.statusCode === statusCode;
|
|
46
|
-
const categoryErr =
|
|
47
|
-
!category || (err.error && err.error.category === category);
|
|
48
|
-
const subCategoryErr =
|
|
49
|
-
!subCategory || (err.error && err.error.subCategory === subCategory);
|
|
50
|
-
|
|
51
|
-
return (
|
|
52
|
-
err.name === 'StatusCodeError' &&
|
|
53
|
-
statusCodeErr &&
|
|
54
|
-
categoryErr &&
|
|
55
|
-
subCategoryErr
|
|
56
|
-
);
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
const isSpecifiedHubSpotAuthError = (
|
|
60
|
-
err,
|
|
61
|
-
{ statusCode, category, subCategory }
|
|
62
|
-
) => {
|
|
63
|
-
const statusCodeErr = !statusCode || err.statusCode === statusCode;
|
|
64
|
-
const categoryErr = !category || err.category === category;
|
|
65
|
-
const subCategoryErr = !subCategory || err.subCategory === subCategory;
|
|
66
|
-
return (
|
|
67
|
-
err.name === 'HubSpotAuthError' &&
|
|
68
|
-
statusCodeErr &&
|
|
69
|
-
categoryErr &&
|
|
70
|
-
subCategoryErr
|
|
71
|
-
);
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
const parseValidationErrors = (responseBody = {}) => {
|
|
75
|
-
const errorMessages = [];
|
|
76
|
-
|
|
77
|
-
const { errors, message } = responseBody;
|
|
78
|
-
|
|
79
|
-
if (message) {
|
|
80
|
-
errorMessages.push(message);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
if (errors) {
|
|
84
|
-
const specificErrors = errors.map(error => {
|
|
85
|
-
let errorMessage = error.message;
|
|
86
|
-
if (error.errorTokens && error.errorTokens.line) {
|
|
87
|
-
errorMessage = `line ${error.errorTokens.line}: ${errorMessage}`;
|
|
88
|
-
}
|
|
89
|
-
return errorMessage;
|
|
90
|
-
});
|
|
91
|
-
errorMessages.push(...specificErrors);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return errorMessages;
|
|
95
|
-
};
|
|
96
|
-
|
|
97
24
|
class ApiErrorContext extends ErrorContext {
|
|
98
25
|
constructor(props = {}) {
|
|
99
26
|
super(props);
|
|
@@ -112,142 +39,13 @@ class ApiErrorContext extends ErrorContext {
|
|
|
112
39
|
*/
|
|
113
40
|
function logValidationErrors(error, context) {
|
|
114
41
|
const { response = {} } = error;
|
|
115
|
-
const validationErrors = parseValidationErrors(response.
|
|
42
|
+
const validationErrors = parseValidationErrors(response.data);
|
|
116
43
|
if (validationErrors.length) {
|
|
117
|
-
validationErrors.
|
|
118
|
-
logger.error(err);
|
|
119
|
-
});
|
|
44
|
+
logger.error(validationErrors.join('\n- '));
|
|
120
45
|
}
|
|
121
46
|
debugErrorAndContext(error, context);
|
|
122
47
|
}
|
|
123
48
|
|
|
124
|
-
/**
|
|
125
|
-
* Message segments for API messages.
|
|
126
|
-
*
|
|
127
|
-
* @enum {string}
|
|
128
|
-
*/
|
|
129
|
-
const ApiMethodVerbs = {
|
|
130
|
-
DEFAULT: 'request',
|
|
131
|
-
DELETE: 'delete',
|
|
132
|
-
GET: 'request',
|
|
133
|
-
PATCH: 'update',
|
|
134
|
-
POST: 'post',
|
|
135
|
-
PUT: 'update',
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Message segments for API messages.
|
|
140
|
-
*
|
|
141
|
-
* @enum {string}
|
|
142
|
-
*/
|
|
143
|
-
const ApiMethodPrepositions = {
|
|
144
|
-
DEFAULT: 'for',
|
|
145
|
-
DELETE: 'of',
|
|
146
|
-
GET: 'for',
|
|
147
|
-
PATCH: 'to',
|
|
148
|
-
POST: 'to',
|
|
149
|
-
PUT: 'to',
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Logs messages for an error instance resulting from API interaction.
|
|
154
|
-
*
|
|
155
|
-
* @param {StatusCodeError} error
|
|
156
|
-
* @param {ApiErrorContext} context
|
|
157
|
-
*/
|
|
158
|
-
function logApiStatusCodeError(error, context) {
|
|
159
|
-
const { statusCode } = error;
|
|
160
|
-
const { method } = error.options || {};
|
|
161
|
-
const { projectName } = context;
|
|
162
|
-
const isPutOrPost = method === 'PUT' || method === 'POST';
|
|
163
|
-
const action = ApiMethodVerbs[method] || ApiMethodVerbs.DEFAULT;
|
|
164
|
-
const preposition =
|
|
165
|
-
ApiMethodPrepositions[method] || ApiMethodPrepositions.DEFAULT;
|
|
166
|
-
let messageDetail = '';
|
|
167
|
-
{
|
|
168
|
-
const request = context.request
|
|
169
|
-
? `${action} ${preposition} "${context.request}"`
|
|
170
|
-
: action;
|
|
171
|
-
messageDetail = `${request} in account ${context.accountId}`;
|
|
172
|
-
}
|
|
173
|
-
const errorMessage = [];
|
|
174
|
-
if (isPutOrPost && context.payload) {
|
|
175
|
-
errorMessage.push(`Unable to upload "${context.payload}".`);
|
|
176
|
-
}
|
|
177
|
-
const isProjectMissingScopeError = isMissingScopeError(error) && projectName;
|
|
178
|
-
const isProjectGatingError = isGatingError(error) && projectName;
|
|
179
|
-
switch (statusCode) {
|
|
180
|
-
case 400:
|
|
181
|
-
errorMessage.push(i18n(`${i18nKey}.codes.400`, { messageDetail }));
|
|
182
|
-
break;
|
|
183
|
-
case 401:
|
|
184
|
-
errorMessage.push(i18n(`${i18nKey}.codes.401`, { messageDetail }));
|
|
185
|
-
break;
|
|
186
|
-
case 403:
|
|
187
|
-
if (isProjectMissingScopeError) {
|
|
188
|
-
errorMessage.push(
|
|
189
|
-
i18n(`${i18nKey}.codes.403MissingScope`, {
|
|
190
|
-
accountId: context.accountId || '',
|
|
191
|
-
})
|
|
192
|
-
);
|
|
193
|
-
} else if (isProjectGatingError) {
|
|
194
|
-
errorMessage.push(
|
|
195
|
-
i18n(`${i18nKey}.codes.403Gating`, {
|
|
196
|
-
accountId: context.accountId || '',
|
|
197
|
-
})
|
|
198
|
-
);
|
|
199
|
-
} else {
|
|
200
|
-
errorMessage.push(i18n(`${i18nKey}.codes.403`, { messageDetail }));
|
|
201
|
-
}
|
|
202
|
-
break;
|
|
203
|
-
case 404:
|
|
204
|
-
if (context.request) {
|
|
205
|
-
errorMessage.push(
|
|
206
|
-
i18n(`${i18nKey}.codes.404Request`, {
|
|
207
|
-
action: action || 'request',
|
|
208
|
-
request: context.request,
|
|
209
|
-
account: context.accountId || '',
|
|
210
|
-
})
|
|
211
|
-
);
|
|
212
|
-
} else {
|
|
213
|
-
errorMessage.push(i18n(`${i18nKey}.codes.404`, { messageDetail }));
|
|
214
|
-
}
|
|
215
|
-
break;
|
|
216
|
-
case 429:
|
|
217
|
-
errorMessage.push(i18n(`${i18nKey}.codes.429`, { messageDetail }));
|
|
218
|
-
break;
|
|
219
|
-
case 503:
|
|
220
|
-
errorMessage.push(i18n(`${i18nKey}.codes.503`, { messageDetail }));
|
|
221
|
-
break;
|
|
222
|
-
default:
|
|
223
|
-
if (statusCode >= 500 && statusCode < 600) {
|
|
224
|
-
errorMessage.push(
|
|
225
|
-
i18n(`${i18nKey}.codes.500Generic`, { messageDetail })
|
|
226
|
-
);
|
|
227
|
-
} else if (statusCode >= 400 && statusCode < 500) {
|
|
228
|
-
i18n(`${i18nKey}.codes.400Generic`, { messageDetail });
|
|
229
|
-
} else {
|
|
230
|
-
errorMessage.push(i18n(`${i18nKey}.codes.generic`, { messageDetail }));
|
|
231
|
-
}
|
|
232
|
-
break;
|
|
233
|
-
}
|
|
234
|
-
if (
|
|
235
|
-
error.error &&
|
|
236
|
-
error.error.message &&
|
|
237
|
-
!isProjectMissingScopeError &&
|
|
238
|
-
!isProjectGatingError
|
|
239
|
-
) {
|
|
240
|
-
errorMessage.push(error.error.message);
|
|
241
|
-
}
|
|
242
|
-
if (error.error && error.error.errors) {
|
|
243
|
-
error.error.errors.forEach(err => {
|
|
244
|
-
errorMessage.push('\n- ' + err.message);
|
|
245
|
-
});
|
|
246
|
-
}
|
|
247
|
-
logger.error(errorMessage.join(' '));
|
|
248
|
-
debugErrorAndContext(error, context);
|
|
249
|
-
}
|
|
250
|
-
|
|
251
49
|
/**
|
|
252
50
|
* Logs a message for an error instance resulting from API interaction.
|
|
253
51
|
*
|
|
@@ -255,19 +53,12 @@ function logApiStatusCodeError(error, context) {
|
|
|
255
53
|
* @param {ApiErrorContext} context
|
|
256
54
|
*/
|
|
257
55
|
function logApiErrorInstance(error, context) {
|
|
258
|
-
// Use the new local-dev-lib error handler
|
|
259
|
-
// NOTE: This will eventually replace the logic in logApiStatusCodeError
|
|
260
56
|
if (error.isAxiosError) {
|
|
261
57
|
if (overrideErrors(error)) return;
|
|
262
58
|
const errorWithContext = getAxiosErrorWithContext(error, context);
|
|
263
59
|
logger.error(errorWithContext.message);
|
|
264
60
|
return;
|
|
265
61
|
}
|
|
266
|
-
// StatusCodeError
|
|
267
|
-
if (isApiStatusCodeError(error)) {
|
|
268
|
-
logApiStatusCodeError(error, context);
|
|
269
|
-
return;
|
|
270
|
-
}
|
|
271
62
|
logErrorInstance(error, context);
|
|
272
63
|
}
|
|
273
64
|
|
|
@@ -344,12 +135,7 @@ async function logServerlessFunctionApiErrorInstance(
|
|
|
344
135
|
return;
|
|
345
136
|
}
|
|
346
137
|
|
|
347
|
-
|
|
348
|
-
if (isApiStatusCodeError(error)) {
|
|
349
|
-
logApiStatusCodeError(error, context);
|
|
350
|
-
return;
|
|
351
|
-
}
|
|
352
|
-
logErrorInstance(error, context);
|
|
138
|
+
logApiErrorInstance(error, context);
|
|
353
139
|
}
|
|
354
140
|
|
|
355
141
|
module.exports = {
|
|
@@ -358,7 +144,4 @@ module.exports = {
|
|
|
358
144
|
logApiErrorInstance,
|
|
359
145
|
logApiUploadErrorInstance,
|
|
360
146
|
logServerlessFunctionApiErrorInstance,
|
|
361
|
-
isMissingScopeError,
|
|
362
|
-
isSpecifiedError,
|
|
363
|
-
isSpecifiedHubSpotAuthError,
|
|
364
147
|
};
|
|
@@ -1,24 +1,7 @@
|
|
|
1
|
-
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
2
1
|
const {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} = require('./standardErrors');
|
|
7
|
-
const { i18n } = require('../lang');
|
|
8
|
-
|
|
9
|
-
const i18nKey = 'cli.lib.errorHandlers.fileSystemErrors';
|
|
10
|
-
|
|
11
|
-
class FileSystemErrorContext extends ErrorContext {
|
|
12
|
-
constructor(props = {}) {
|
|
13
|
-
super(props);
|
|
14
|
-
/** @type {string} */
|
|
15
|
-
this.filepath = props.filepath || '';
|
|
16
|
-
/** @type {boolean} */
|
|
17
|
-
this.read = !!props.read;
|
|
18
|
-
/** @type {boolean} */
|
|
19
|
-
this.write = !!props.write;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
2
|
+
getFileSystemError,
|
|
3
|
+
} = require('@hubspot/local-dev-lib/errors/fileSystemErrors');
|
|
4
|
+
const { debugErrorAndContext, logErrorInstance } = require('./standardErrors');
|
|
22
5
|
|
|
23
6
|
/**
|
|
24
7
|
* Logs a message for an error instance resulting from filesystem interaction.
|
|
@@ -27,29 +10,11 @@ class FileSystemErrorContext extends ErrorContext {
|
|
|
27
10
|
* @param {FileSystemErrorContext} context
|
|
28
11
|
*/
|
|
29
12
|
function logFileSystemErrorInstance(error, context) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
fileAction = 'reading from';
|
|
33
|
-
} else if (context.write) {
|
|
34
|
-
fileAction = 'writing to';
|
|
35
|
-
} else {
|
|
36
|
-
fileAction = 'accessing';
|
|
37
|
-
}
|
|
38
|
-
const filepath = context.filepath
|
|
39
|
-
? `"${context.filepath}"`
|
|
40
|
-
: 'a file or folder';
|
|
41
|
-
const message = [i18n(`${i18nKey}.errorOccurred`, { fileAction, filepath })];
|
|
42
|
-
// Many `fs` errors will be `SystemError`s
|
|
43
|
-
if (isSystemError(error)) {
|
|
44
|
-
message.push(
|
|
45
|
-
i18n(`${i18nKey}.errorExplanation`, { errorMessage: error.message })
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
logger.error(message.join(' '));
|
|
13
|
+
const fileSystemError = getFileSystemError(error, context);
|
|
14
|
+
logErrorInstance(fileSystemError.message, context);
|
|
49
15
|
debugErrorAndContext(error, context);
|
|
50
16
|
}
|
|
51
17
|
|
|
52
18
|
module.exports = {
|
|
53
|
-
FileSystemErrorContext,
|
|
54
19
|
logFileSystemErrorInstance,
|
|
55
20
|
};
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
const util = require('util');
|
|
2
|
-
const {
|
|
3
|
-
HubSpotAuthError,
|
|
4
|
-
} = require('@hubspot/local-dev-lib/models/HubSpotAuthError');
|
|
5
2
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
3
|
+
const {
|
|
4
|
+
isSystemError,
|
|
5
|
+
} = require('@hubspot/local-dev-lib/errors/standardErrors');
|
|
6
6
|
const { i18n } = require('../lang');
|
|
7
7
|
|
|
8
8
|
const i18nKey = 'cli.lib.errorHandlers.standardErrors';
|
|
9
9
|
|
|
10
|
-
const isSystemError = err =>
|
|
11
|
-
err.errno != null && err.code != null && err.syscall != null;
|
|
12
|
-
const isFatalError = err => err instanceof HubSpotAuthError;
|
|
13
|
-
|
|
14
10
|
// TODO: Make these TS interfaces
|
|
15
11
|
class ErrorContext {
|
|
16
12
|
constructor(props = {}) {
|
|
@@ -103,7 +99,5 @@ function logErrorInstance(error, context) {
|
|
|
103
99
|
module.exports = {
|
|
104
100
|
debugErrorAndContext,
|
|
105
101
|
ErrorContext,
|
|
106
|
-
isFatalError,
|
|
107
|
-
isSystemError,
|
|
108
102
|
logErrorInstance,
|
|
109
103
|
};
|
package/lib/process.js
CHANGED
|
@@ -4,7 +4,6 @@ const {
|
|
|
4
4
|
setLogLevel,
|
|
5
5
|
LOG_LEVEL,
|
|
6
6
|
} = require('@hubspot/local-dev-lib/logger');
|
|
7
|
-
const { setLogLevel: setCliLibLogLevel } = require('@hubspot/cli-lib/logger');
|
|
8
7
|
const { i18n } = require('./lang');
|
|
9
8
|
|
|
10
9
|
const i18nKey = 'cli.lib.process';
|
|
@@ -33,10 +32,6 @@ const handleExit = callback => {
|
|
|
33
32
|
// Prevent logs when terminal closes
|
|
34
33
|
if (isSIGHUP) {
|
|
35
34
|
setLogLevel(LOG_LEVEL.NONE);
|
|
36
|
-
|
|
37
|
-
// Update the log level in cli-lib's instance of the logger
|
|
38
|
-
// We can remove this when we remove cli-lib as a dep
|
|
39
|
-
setCliLibLogLevel(LOG_LEVEL.NONE);
|
|
40
35
|
}
|
|
41
36
|
|
|
42
37
|
logger.debug(i18n(`${i18nKey}.exitDebug`, { signal }));
|
package/lib/projects.js
CHANGED
|
@@ -27,7 +27,10 @@ const {
|
|
|
27
27
|
fetchProject,
|
|
28
28
|
uploadProject,
|
|
29
29
|
} = require('@hubspot/local-dev-lib/api/projects');
|
|
30
|
-
const {
|
|
30
|
+
const {
|
|
31
|
+
isSpecifiedError,
|
|
32
|
+
isSpecifiedHubSpotAuthError,
|
|
33
|
+
} = require('@hubspot/local-dev-lib/errors/apiErrors');
|
|
31
34
|
const { shouldIgnoreFile } = require('@hubspot/local-dev-lib/ignoreRules');
|
|
32
35
|
const { getCwd, getAbsoluteFilePath } = require('@hubspot/local-dev-lib/path');
|
|
33
36
|
const { downloadGithubRepoContents } = require('@hubspot/local-dev-lib/github');
|
|
@@ -39,7 +42,6 @@ const SpinniesManager = require('./ui/SpinniesManager');
|
|
|
39
42
|
const {
|
|
40
43
|
logApiErrorInstance,
|
|
41
44
|
ApiErrorContext,
|
|
42
|
-
isSpecifiedHubSpotAuthError,
|
|
43
45
|
} = require('./errorHandlers/apiErrors');
|
|
44
46
|
const { HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH } = require('./constants');
|
|
45
47
|
|
package/lib/projectsWatch.js
CHANGED
|
@@ -6,7 +6,7 @@ const {
|
|
|
6
6
|
logApiErrorInstance,
|
|
7
7
|
ApiErrorContext,
|
|
8
8
|
} = require('./errorHandlers/apiErrors');
|
|
9
|
-
const { i18n } = require('
|
|
9
|
+
const { i18n } = require('./lang');
|
|
10
10
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
11
11
|
const { isAllowedExtension } = require('@hubspot/local-dev-lib/path');
|
|
12
12
|
const { shouldIgnoreFile } = require('@hubspot/local-dev-lib/ignoreRules');
|
|
@@ -2,7 +2,7 @@ const path = require('path');
|
|
|
2
2
|
const fs = require('fs');
|
|
3
3
|
const { promptUser } = require('./promptUtils');
|
|
4
4
|
const { i18n } = require('../lang');
|
|
5
|
-
const escapeRegExp = require('@hubspot/
|
|
5
|
+
const escapeRegExp = require('@hubspot/local-dev-lib/escapeRegExp');
|
|
6
6
|
const i18nKey = 'cli.lib.prompts.uploadPrompt';
|
|
7
7
|
const FIELDS_FILES = ['fields.json', 'fields.js', 'fields.cjs', 'fields.mjs'];
|
|
8
8
|
|
package/lib/serverlessLogs.js
CHANGED
|
@@ -9,12 +9,20 @@ const {
|
|
|
9
9
|
logApiErrorInstance,
|
|
10
10
|
ApiErrorContext,
|
|
11
11
|
} = require('./errorHandlers/apiErrors');
|
|
12
|
-
const { base64EncodeString } = require('@hubspot/cli-lib/lib/encoding');
|
|
13
12
|
|
|
14
13
|
const { EXIT_CODES } = require('../lib/enums/exitCodes');
|
|
15
14
|
|
|
16
15
|
const TAIL_DELAY = 5000;
|
|
17
16
|
|
|
17
|
+
const base64EncodeString = valueToEncode => {
|
|
18
|
+
if (typeof valueToEncode !== 'string') {
|
|
19
|
+
return valueToEncode;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const stringBuffer = Buffer.from(valueToEncode);
|
|
23
|
+
return encodeURIComponent(stringBuffer.toString('base64'));
|
|
24
|
+
};
|
|
25
|
+
|
|
18
26
|
const handleUserInput = () => {
|
|
19
27
|
const onTerminate = async () => {
|
|
20
28
|
SpinniesManager.remove('tailLogs');
|
package/lib/validation.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
4
|
-
const {
|
|
4
|
+
const { MODE } = require('@hubspot/local-dev-lib/constants/files');
|
|
5
5
|
const {
|
|
6
6
|
API_KEY_AUTH_METHOD,
|
|
7
7
|
OAUTH_AUTH_METHOD,
|
|
@@ -175,10 +175,10 @@ async function validateAccount(options) {
|
|
|
175
175
|
*/
|
|
176
176
|
function validateMode(options) {
|
|
177
177
|
const mode = getMode(options);
|
|
178
|
-
if (
|
|
178
|
+
if (MODE[mode]) {
|
|
179
179
|
return true;
|
|
180
180
|
}
|
|
181
|
-
const modesMessage = `Available modes are: ${Object.values(
|
|
181
|
+
const modesMessage = `Available modes are: ${Object.values(MODE).join(
|
|
182
182
|
', '
|
|
183
183
|
)}.`;
|
|
184
184
|
if (mode != null) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/cli",
|
|
3
|
-
"version": "5.1
|
|
3
|
+
"version": "5.2.1-beta.0",
|
|
4
4
|
"description": "CLI for working with HubSpot",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -8,11 +8,10 @@
|
|
|
8
8
|
"url": "https://github.com/HubSpot/hubspot-cms-tools"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@hubspot/
|
|
12
|
-
"@hubspot/
|
|
13
|
-
"@hubspot/serverless-dev-runtime": "5.1.4-beta.6",
|
|
11
|
+
"@hubspot/local-dev-lib": "^0.3.13",
|
|
12
|
+
"@hubspot/serverless-dev-runtime": "5.2.1-beta.0",
|
|
14
13
|
"@hubspot/theme-preview-dev-server": "0.0.4",
|
|
15
|
-
"@hubspot/ui-extensions-dev-server": "0.8.
|
|
14
|
+
"@hubspot/ui-extensions-dev-server": "0.8.12",
|
|
16
15
|
"archiver": "^5.3.0",
|
|
17
16
|
"chalk": "^4.1.2",
|
|
18
17
|
"chokidar": "^3.0.1",
|
|
@@ -46,5 +45,5 @@
|
|
|
46
45
|
"publishConfig": {
|
|
47
46
|
"access": "public"
|
|
48
47
|
},
|
|
49
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "ce6013a55ac84a69335200abbcbc6fc8080585b7"
|
|
50
49
|
}
|