@hubspot/cli 6.1.1 → 6.2.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 +2 -2
- package/commands/accounts/clean.js +5 -7
- package/commands/auth.js +5 -5
- package/commands/cms/convertFields.js +2 -2
- package/commands/cms/lighthouseScore.js +47 -36
- package/commands/create/function.js +2 -2
- package/commands/create/module.js +2 -2
- package/commands/create/template.js +2 -2
- package/commands/create.js +3 -5
- package/commands/customObject/create.js +2 -2
- package/commands/customObject/schema/create.js +4 -4
- package/commands/customObject/schema/delete.js +2 -3
- package/commands/customObject/schema/fetch-all.js +2 -5
- package/commands/customObject/schema/fetch.js +2 -4
- package/commands/customObject/schema/list.js +2 -4
- package/commands/customObject/schema/update.js +4 -4
- package/commands/fetch.js +2 -2
- package/commands/filemanager/fetch.js +2 -2
- package/commands/filemanager/upload.js +3 -7
- package/commands/functions/deploy.js +6 -11
- package/commands/functions/list.js +3 -6
- package/commands/hubdb/clear.js +5 -3
- package/commands/hubdb/create.js +2 -2
- package/commands/hubdb/delete.js +2 -2
- package/commands/hubdb/fetch.js +2 -2
- package/commands/init.js +4 -7
- package/commands/lint.js +2 -2
- package/commands/list.js +4 -6
- package/commands/logs.js +6 -3
- package/commands/mv.js +3 -6
- package/commands/project/__tests__/deploy.test.js +37 -26
- package/commands/project/__tests__/logs.test.js +4 -5
- package/commands/project/add.js +2 -2
- package/commands/project/cloneApp.js +14 -10
- package/commands/project/create.js +2 -6
- package/commands/project/deploy.js +9 -12
- package/commands/project/dev.js +6 -5
- package/commands/project/download.js +7 -9
- package/commands/project/listBuilds.js +8 -12
- package/commands/project/logs.js +2 -2
- package/commands/project/migrateApp.js +20 -15
- package/commands/project/upload.js +4 -10
- package/commands/project/watch.js +8 -13
- package/commands/remove.js +2 -5
- package/commands/sandbox/create.js +4 -6
- package/commands/sandbox/delete.js +6 -12
- package/commands/secrets/addSecret.js +2 -5
- package/commands/secrets/deleteSecret.js +2 -5
- package/commands/secrets/listSecrets.js +5 -6
- package/commands/secrets/updateSecret.js +2 -5
- package/commands/theme/preview.js +2 -5
- package/commands/upload.js +3 -7
- package/commands/watch.js +3 -7
- package/lang/en.lyaml +12 -15
- package/lib/LocalDevManager.js +8 -6
- package/lib/__tests__/downloadProjectPrompt.test.js +1 -1
- package/lib/__tests__/projectLogsManager.test.js +19 -17
- package/lib/__tests__/serverlessLogs.test.js +13 -9
- package/lib/buildAccount.js +10 -10
- package/lib/developerTestAccounts.js +27 -27
- package/lib/errorHandlers/index.js +101 -0
- package/lib/errorHandlers/{overrideErrors.js → suppressError.js} +7 -7
- package/lib/hasFeature.js +15 -0
- package/lib/localDev.js +26 -19
- package/lib/marketplace-validate.js +3 -3
- package/lib/oauth.js +1 -1
- package/lib/polling.js +1 -1
- package/lib/projectLogsManager.js +3 -4
- package/lib/projectStructure.js +2 -2
- package/lib/projects.js +34 -24
- package/lib/projectsWatch.js +7 -12
- package/lib/prompts/createProjectPrompt.js +14 -5
- package/lib/prompts/downloadProjectPrompt.js +3 -6
- package/lib/prompts/projectDevTargetAccountPrompt.js +8 -6
- package/lib/prompts/selectPublicAppPrompt.js +3 -3
- package/lib/sandboxSync.js +7 -7
- package/lib/sandboxes.js +11 -7
- package/lib/schema.js +2 -2
- package/lib/serverlessLogs.js +67 -15
- package/lib/upload.js +2 -2
- package/lib/validation.js +2 -2
- package/package.json +6 -6
- package/lib/errorHandlers/apiErrors.js +0 -145
- package/lib/errorHandlers/fileSystemErrors.js +0 -20
- package/lib/errorHandlers/standardErrors.js +0 -103
package/bin/cli.js
CHANGED
|
@@ -6,7 +6,7 @@ const chalk = require('chalk');
|
|
|
6
6
|
|
|
7
7
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
8
8
|
const { addUserAgentHeader } = require('@hubspot/local-dev-lib/http');
|
|
9
|
-
const {
|
|
9
|
+
const { logError } = require('../lib/errorHandlers/index');
|
|
10
10
|
const { setLogLevel, getCommandName } = require('../lib/commonOpts');
|
|
11
11
|
const {
|
|
12
12
|
trackHelpUsage,
|
|
@@ -90,7 +90,7 @@ const handleFailure = (msg, err, yargs) => {
|
|
|
90
90
|
if (msg) {
|
|
91
91
|
logger.error(msg);
|
|
92
92
|
} else if (err) {
|
|
93
|
-
|
|
93
|
+
logError(err);
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
if (msg === null) {
|
|
@@ -17,10 +17,8 @@ const { promptUser } = require('../../lib/prompts/promptUtils');
|
|
|
17
17
|
const { getTableContents } = require('../../lib/ui/table');
|
|
18
18
|
const SpinniesManager = require('../../lib/ui/SpinniesManager');
|
|
19
19
|
const { getConfig, deleteAccount } = require('@hubspot/local-dev-lib/config');
|
|
20
|
-
const {
|
|
21
|
-
isSpecifiedHubSpotAuthError,
|
|
22
|
-
} = require('@hubspot/local-dev-lib/errors/apiErrors');
|
|
23
20
|
const { uiAccountDescription } = require('../../lib/ui');
|
|
21
|
+
const { isSpecifiedError } = require('@hubspot/local-dev-lib/errors/index');
|
|
24
22
|
|
|
25
23
|
const i18nKey = 'commands.accounts.subcommands.clean';
|
|
26
24
|
|
|
@@ -57,13 +55,13 @@ exports.handler = async options => {
|
|
|
57
55
|
await accessTokenForPersonalAccessKey(account.portalId, true);
|
|
58
56
|
} catch (error) {
|
|
59
57
|
if (
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
isSpecifiedError(error, {
|
|
59
|
+
statusCode: 401,
|
|
62
60
|
category: 'INVALID_AUTHENTICATION',
|
|
63
61
|
subCategory: 'LocalDevAuthErrorType.PORTAL_NOT_ACTIVE',
|
|
64
62
|
}) ||
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
isSpecifiedError(error, {
|
|
64
|
+
statusCode: 404,
|
|
67
65
|
category: 'INVALID_AUTHENTICATION',
|
|
68
66
|
subCategory: 'LocalDevAuthErrorType.INVALID_PORTAL_ID',
|
|
69
67
|
})
|
package/commands/auth.js
CHANGED
|
@@ -46,7 +46,7 @@ const { trackAuthAction, trackCommandUsage } = require('../lib/usageTracking');
|
|
|
46
46
|
const { authenticateWithOauth } = require('../lib/oauth');
|
|
47
47
|
const { EXIT_CODES } = require('../lib/enums/exitCodes');
|
|
48
48
|
const { uiFeatureHighlight } = require('../lib/ui');
|
|
49
|
-
const {
|
|
49
|
+
const { logError } = require('../lib/errorHandlers/index');
|
|
50
50
|
|
|
51
51
|
const i18nKey = 'commands.auth';
|
|
52
52
|
|
|
@@ -70,19 +70,19 @@ exports.describe = i18n(`${i18nKey}.describe`, {
|
|
|
70
70
|
});
|
|
71
71
|
|
|
72
72
|
exports.handler = async options => {
|
|
73
|
-
const { type, config:
|
|
73
|
+
const { type, config: c, qa, account } = options;
|
|
74
74
|
const authType =
|
|
75
75
|
(type && type.toLowerCase()) || PERSONAL_ACCESS_KEY_AUTH_METHOD.value;
|
|
76
76
|
setLogLevel(options);
|
|
77
77
|
logDebugInfo(options);
|
|
78
78
|
|
|
79
|
-
if (!getConfigPath()) {
|
|
79
|
+
if (!getConfigPath(c)) {
|
|
80
80
|
logger.error(i18n(`${i18nKey}.errors.noConfigFileFound`));
|
|
81
81
|
process.exit(EXIT_CODES.ERROR);
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
const env = qa ? ENVIRONMENTS.QA : ENVIRONMENTS.PROD;
|
|
85
|
-
loadConfig(
|
|
85
|
+
loadConfig(c);
|
|
86
86
|
checkAndWarnGitInclusion(getConfigPath());
|
|
87
87
|
|
|
88
88
|
trackCommandUsage('auth');
|
|
@@ -117,7 +117,7 @@ exports.handler = async options => {
|
|
|
117
117
|
env
|
|
118
118
|
);
|
|
119
119
|
} catch (e) {
|
|
120
|
-
|
|
120
|
+
logError(e);
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
if (!updatedConfig) {
|
|
@@ -12,7 +12,7 @@ const {
|
|
|
12
12
|
} = require('@hubspot/local-dev-lib/cms/handleFieldsJS');
|
|
13
13
|
|
|
14
14
|
const { trackConvertFieldsUsage } = require('../../lib/usageTracking');
|
|
15
|
-
const {
|
|
15
|
+
const { logError } = require('../../lib/errorHandlers/index');
|
|
16
16
|
const { EXIT_CODES } = require('../../lib/enums/exitCodes');
|
|
17
17
|
const i18nKey = 'commands.convertFields';
|
|
18
18
|
|
|
@@ -64,7 +64,7 @@ exports.handler = async options => {
|
|
|
64
64
|
try {
|
|
65
65
|
filePaths = await walk(src);
|
|
66
66
|
} catch (e) {
|
|
67
|
-
|
|
67
|
+
logError(e);
|
|
68
68
|
}
|
|
69
69
|
const allowedFilePaths = filePaths
|
|
70
70
|
.filter(file => {
|
|
@@ -42,7 +42,7 @@ const selectTheme = async accountId => {
|
|
|
42
42
|
message: i18n(`${i18nKey}.info.promptMessage`),
|
|
43
43
|
choices: async () => {
|
|
44
44
|
try {
|
|
45
|
-
const result = await fetchThemes(accountId, {
|
|
45
|
+
const { data: result } = await fetchThemes(accountId, {
|
|
46
46
|
limit: 500,
|
|
47
47
|
sorting: 'MOST_USED',
|
|
48
48
|
});
|
|
@@ -77,7 +77,7 @@ exports.handler = async options => {
|
|
|
77
77
|
if (themeToCheck) {
|
|
78
78
|
let isValidTheme = true;
|
|
79
79
|
try {
|
|
80
|
-
const result = await fetchThemes(accountId, {
|
|
80
|
+
const { data: result } = await fetchThemes(accountId, {
|
|
81
81
|
name: encodeURIComponent(themeToCheck),
|
|
82
82
|
});
|
|
83
83
|
isValidTheme = result && result.total;
|
|
@@ -98,9 +98,10 @@ exports.handler = async options => {
|
|
|
98
98
|
// Kick off the scoring
|
|
99
99
|
let requestResult;
|
|
100
100
|
try {
|
|
101
|
-
|
|
101
|
+
const { data } = await requestLighthouseScore(accountId, {
|
|
102
102
|
themePath: themeToCheck,
|
|
103
103
|
});
|
|
104
|
+
requestResult = data;
|
|
104
105
|
} catch (err) {
|
|
105
106
|
logger.debug(err);
|
|
106
107
|
}
|
|
@@ -119,16 +120,21 @@ exports.handler = async options => {
|
|
|
119
120
|
});
|
|
120
121
|
|
|
121
122
|
const checkScoreStatus = async () => {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
123
|
+
let desktopScoreStatus = 'COMPLETED';
|
|
124
|
+
if (includeDesktopScore) {
|
|
125
|
+
const { data } = await getLighthouseScoreStatus(accountId, {
|
|
126
|
+
themeId: requestResult.desktopId,
|
|
127
|
+
});
|
|
128
|
+
desktopScoreStatus = data;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
let mobileScoreStatus = 'COMPLETED';
|
|
132
|
+
if (includeDesktopScore) {
|
|
133
|
+
const { data } = await getLighthouseScoreStatus(accountId, {
|
|
134
|
+
themeId: requestResult.mobileId,
|
|
135
|
+
});
|
|
136
|
+
mobileScoreStatus = data;
|
|
137
|
+
}
|
|
132
138
|
|
|
133
139
|
if (
|
|
134
140
|
desktopScoreStatus === 'REQUESTED' ||
|
|
@@ -148,32 +154,37 @@ exports.handler = async options => {
|
|
|
148
154
|
}
|
|
149
155
|
|
|
150
156
|
// Fetch the scoring results
|
|
151
|
-
let desktopScoreResult;
|
|
152
|
-
let mobileScoreResult;
|
|
153
|
-
let verboseViewAverageScoreResult;
|
|
157
|
+
let desktopScoreResult = {};
|
|
158
|
+
let mobileScoreResult = {};
|
|
159
|
+
let verboseViewAverageScoreResult = {};
|
|
154
160
|
try {
|
|
155
161
|
const params = { isAverage: !options.verbose };
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
162
|
+
|
|
163
|
+
if (includeDesktopScore) {
|
|
164
|
+
const { data } = await getLighthouseScore(accountId, {
|
|
165
|
+
...params,
|
|
166
|
+
desktopId: requestResult.desktopId,
|
|
167
|
+
});
|
|
168
|
+
desktopScoreResult = data;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (includeMobileScore) {
|
|
172
|
+
const { data } = await getLighthouseScore(accountId, {
|
|
173
|
+
...params,
|
|
174
|
+
mobileId: requestResult.mobileId,
|
|
175
|
+
});
|
|
176
|
+
mobileScoreResult = data;
|
|
177
|
+
}
|
|
168
178
|
// This is needed to show the average scores above the verbose output
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
179
|
+
if (options.verbose) {
|
|
180
|
+
const { data } = await getLighthouseScore(accountId, {
|
|
181
|
+
...params,
|
|
182
|
+
isAverage: true,
|
|
183
|
+
desktopId: includeDesktopScore ? requestResult.desktopId : null,
|
|
184
|
+
mobileId: includeMobileScore ? requestResult.mobileId : null,
|
|
185
|
+
});
|
|
186
|
+
verboseViewAverageScoreResult = data;
|
|
187
|
+
}
|
|
177
188
|
} catch (err) {
|
|
178
189
|
logger.error(i18n(`${i18nKey}.errors.failedToGetLighthouseScore`));
|
|
179
190
|
process.exit(EXIT_CODES.ERROR);
|
|
@@ -2,7 +2,7 @@ const { createFunction } = require('@hubspot/local-dev-lib/cms/functions');
|
|
|
2
2
|
const {
|
|
3
3
|
createFunctionPrompt,
|
|
4
4
|
} = require('../../lib/prompts/createFunctionPrompt');
|
|
5
|
-
const {
|
|
5
|
+
const { logError } = require('../../lib/errorHandlers/index');
|
|
6
6
|
const { EXIT_CODES } = require('../../lib/enums/exitCodes');
|
|
7
7
|
|
|
8
8
|
module.exports = {
|
|
@@ -12,7 +12,7 @@ module.exports = {
|
|
|
12
12
|
try {
|
|
13
13
|
await createFunction(functionDefinition, dest);
|
|
14
14
|
} catch (e) {
|
|
15
|
-
|
|
15
|
+
logError(e);
|
|
16
16
|
process.exit(EXIT_CODES.ERROR);
|
|
17
17
|
}
|
|
18
18
|
},
|
|
@@ -2,7 +2,7 @@ const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
|
2
2
|
const { createModule } = require('@hubspot/local-dev-lib/cms/modules');
|
|
3
3
|
const { i18n } = require('../../lib/lang');
|
|
4
4
|
const { createModulePrompt } = require('../../lib/prompts/createModulePrompt');
|
|
5
|
-
const {
|
|
5
|
+
const { logError } = require('../../lib/errorHandlers/index');
|
|
6
6
|
const { EXIT_CODES } = require('../../lib/enums/exitCodes');
|
|
7
7
|
|
|
8
8
|
const i18nKey = 'commands.create.subcommands.module';
|
|
@@ -21,7 +21,7 @@ module.exports = {
|
|
|
21
21
|
try {
|
|
22
22
|
await createModule(moduleDefinition, name, dest, getInternalVersion);
|
|
23
23
|
} catch (e) {
|
|
24
|
-
|
|
24
|
+
logError(e);
|
|
25
25
|
process.exit(EXIT_CODES.ERROR);
|
|
26
26
|
}
|
|
27
27
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const { createTemplate } = require('@hubspot/local-dev-lib/cms/templates');
|
|
2
2
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
3
|
-
const {
|
|
3
|
+
const { logError } = require('../../lib/errorHandlers/index');
|
|
4
4
|
const {
|
|
5
5
|
createTemplatePrompt,
|
|
6
6
|
} = require('../../lib/prompts/createTemplatePrompt');
|
|
@@ -24,7 +24,7 @@ module.exports = {
|
|
|
24
24
|
try {
|
|
25
25
|
await createTemplate(name, dest, templateType);
|
|
26
26
|
} catch (e) {
|
|
27
|
-
|
|
27
|
+
logError(e);
|
|
28
28
|
process.exit(EXIT_CODES.ERROR);
|
|
29
29
|
}
|
|
30
30
|
return { templateType };
|
package/commands/create.js
CHANGED
|
@@ -23,9 +23,7 @@
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
const fs = require('fs-extra');
|
|
26
|
-
const {
|
|
27
|
-
logFileSystemErrorInstance,
|
|
28
|
-
} = require('../lib/errorHandlers/fileSystemErrors');
|
|
26
|
+
const { logError } = require('../lib/errorHandlers/index');
|
|
29
27
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
30
28
|
const { setLogLevel, getAccountId } = require('../lib/commonOpts');
|
|
31
29
|
const { logDebugInfo } = require('../lib/debugInfo');
|
|
@@ -87,9 +85,9 @@ exports.handler = async options => {
|
|
|
87
85
|
path: dest,
|
|
88
86
|
})
|
|
89
87
|
);
|
|
90
|
-
|
|
88
|
+
logError(e, {
|
|
91
89
|
filepath: dest,
|
|
92
|
-
|
|
90
|
+
operation: 'write',
|
|
93
91
|
});
|
|
94
92
|
return;
|
|
95
93
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
2
|
-
const {
|
|
2
|
+
const { logError } = require('../../lib/errorHandlers/index');
|
|
3
3
|
const { getAbsoluteFilePath } = require('@hubspot/local-dev-lib/path');
|
|
4
4
|
const {
|
|
5
5
|
checkAndConvertToJson,
|
|
@@ -38,7 +38,7 @@ exports.handler = async options => {
|
|
|
38
38
|
await batchCreateObjects(accountId, name, objectJson);
|
|
39
39
|
logger.success(i18n(`${i18nKey}.success.objectsCreated`));
|
|
40
40
|
} catch (e) {
|
|
41
|
-
|
|
41
|
+
logError(e, { accountId });
|
|
42
42
|
logger.error(
|
|
43
43
|
i18n(`${i18nKey}.errors.creationFailed`, {
|
|
44
44
|
definition,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
2
|
-
const {
|
|
2
|
+
const { logError } = require('../../../lib/errorHandlers/index');
|
|
3
3
|
const { getAbsoluteFilePath } = require('@hubspot/local-dev-lib/path');
|
|
4
4
|
const {
|
|
5
5
|
checkAndConvertToJson,
|
|
@@ -54,17 +54,17 @@ exports.handler = async options => {
|
|
|
54
54
|
})
|
|
55
55
|
);
|
|
56
56
|
} else {
|
|
57
|
-
const
|
|
57
|
+
const { data } = await createObjectSchema(accountId, schemaJson);
|
|
58
58
|
logger.success(
|
|
59
59
|
i18n(`${i18nKey}.success.schemaViewable`, {
|
|
60
60
|
url: `${getHubSpotWebsiteOrigin(
|
|
61
61
|
getEnv() === 'qa' ? ENVIRONMENTS.QA : ENVIRONMENTS.PROD
|
|
62
|
-
)}/contacts/${accountId}/objects/${
|
|
62
|
+
)}/contacts/${accountId}/objects/${data.objectTypeId}`,
|
|
63
63
|
})
|
|
64
64
|
);
|
|
65
65
|
}
|
|
66
66
|
} catch (e) {
|
|
67
|
-
|
|
67
|
+
logError(e, { accountId });
|
|
68
68
|
logger.error(
|
|
69
69
|
i18n(`${i18nKey}.errors.creationFailed`, {
|
|
70
70
|
definition,
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
2
|
-
const { logApiErrorInstance } = require('../../../lib/errorHandlers/apiErrors');
|
|
3
|
-
|
|
4
2
|
const { loadAndValidateOptions } = require('../../../lib/validation');
|
|
5
3
|
const { trackCommandUsage } = require('../../../lib/usageTracking');
|
|
6
4
|
const { getAccountId } = require('../../../lib/commonOpts');
|
|
@@ -8,6 +6,7 @@ const {
|
|
|
8
6
|
deleteObjectSchema,
|
|
9
7
|
} = require('@hubspot/local-dev-lib/api/customObjects');
|
|
10
8
|
const { i18n } = require('../../../lib/lang');
|
|
9
|
+
const { logError } = require('../../../lib/errorHandlers');
|
|
11
10
|
|
|
12
11
|
const i18nKey = 'commands.customObject.subcommands.schema.subcommands.delete';
|
|
13
12
|
|
|
@@ -31,7 +30,7 @@ exports.handler = async options => {
|
|
|
31
30
|
})
|
|
32
31
|
);
|
|
33
32
|
} catch (e) {
|
|
34
|
-
|
|
33
|
+
logError(e);
|
|
35
34
|
logger.error(
|
|
36
35
|
i18n(`${i18nKey}.errors.delete`, {
|
|
37
36
|
name,
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
2
|
-
const {
|
|
3
|
-
logErrorInstance,
|
|
4
|
-
} = require('../../../lib/errorHandlers/standardErrors');
|
|
5
|
-
|
|
6
2
|
const { loadAndValidateOptions } = require('../../../lib/validation');
|
|
7
3
|
const { trackCommandUsage } = require('../../../lib/usageTracking');
|
|
8
4
|
const { getAccountId } = require('../../../lib/commonOpts');
|
|
@@ -12,6 +8,7 @@ const {
|
|
|
12
8
|
} = require('@hubspot/local-dev-lib/customObjects');
|
|
13
9
|
const { i18n } = require('../../../lib/lang');
|
|
14
10
|
const { logSchemas } = require('../../../lib/schema');
|
|
11
|
+
const { logError } = require('../../../lib/errorHandlers');
|
|
15
12
|
|
|
16
13
|
const i18nKey = 'commands.customObject.subcommands.schema.subcommands.fetchAll';
|
|
17
14
|
|
|
@@ -34,7 +31,7 @@ exports.handler = async options => {
|
|
|
34
31
|
})
|
|
35
32
|
);
|
|
36
33
|
} catch (e) {
|
|
37
|
-
|
|
34
|
+
logError(e);
|
|
38
35
|
logger.error(i18n(`${i18nKey}.errors.fetch`));
|
|
39
36
|
}
|
|
40
37
|
};
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
2
|
const { isConfigFlagEnabled } = require('@hubspot/local-dev-lib/config');
|
|
3
3
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
4
|
-
const {
|
|
5
|
-
logErrorInstance,
|
|
6
|
-
} = require('../../../lib/errorHandlers/standardErrors');
|
|
7
4
|
const { CONFIG_FLAGS } = require('../../../lib/constants');
|
|
8
5
|
const {
|
|
9
6
|
downloadSchema,
|
|
@@ -16,6 +13,7 @@ const { loadAndValidateOptions } = require('../../../lib/validation');
|
|
|
16
13
|
const { trackCommandUsage } = require('../../../lib/usageTracking');
|
|
17
14
|
const { getAccountId } = require('../../../lib/commonOpts');
|
|
18
15
|
const { i18n } = require('../../../lib/lang');
|
|
16
|
+
const { logError } = require('../../../lib/errorHandlers');
|
|
19
17
|
|
|
20
18
|
const i18nKey = 'commands.customObject.subcommands.schema.subcommands.fetch';
|
|
21
19
|
|
|
@@ -50,7 +48,7 @@ exports.handler = async options => {
|
|
|
50
48
|
);
|
|
51
49
|
}
|
|
52
50
|
} catch (e) {
|
|
53
|
-
|
|
51
|
+
logError(e);
|
|
54
52
|
logger.error(
|
|
55
53
|
i18n(`${i18nKey}.errors.fetch`, {
|
|
56
54
|
name,
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
2
|
-
const {
|
|
3
|
-
logErrorInstance,
|
|
4
|
-
} = require('../../../lib/errorHandlers/standardErrors');
|
|
2
|
+
const { logError } = require('../../../lib/errorHandlers/index');
|
|
5
3
|
|
|
6
4
|
const { loadAndValidateOptions } = require('../../../lib/validation');
|
|
7
5
|
const { trackCommandUsage } = require('../../../lib/usageTracking');
|
|
@@ -24,7 +22,7 @@ exports.handler = async options => {
|
|
|
24
22
|
try {
|
|
25
23
|
await listSchemas(accountId);
|
|
26
24
|
} catch (e) {
|
|
27
|
-
|
|
25
|
+
logError(e);
|
|
28
26
|
logger.error(i18n(`${i18nKey}.errors.list`));
|
|
29
27
|
}
|
|
30
28
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
2
|
-
const {
|
|
2
|
+
const { logError } = require('../../../lib/errorHandlers/index');
|
|
3
3
|
const { getAbsoluteFilePath } = require('@hubspot/local-dev-lib/path');
|
|
4
4
|
const {
|
|
5
5
|
ENVIRONMENTS,
|
|
@@ -54,17 +54,17 @@ exports.handler = async options => {
|
|
|
54
54
|
})
|
|
55
55
|
);
|
|
56
56
|
} else {
|
|
57
|
-
const
|
|
57
|
+
const { data } = await updateObjectSchema(accountId, name, schemaJson);
|
|
58
58
|
logger.success(
|
|
59
59
|
i18n(`${i18nKey}.success.viewAtUrl`, {
|
|
60
60
|
url: `${getHubSpotWebsiteOrigin(
|
|
61
61
|
getEnv() === 'qa' ? ENVIRONMENTS.QA : ENVIRONMENTS.PROD
|
|
62
|
-
)}/contacts/${accountId}/objects/${
|
|
62
|
+
)}/contacts/${accountId}/objects/${data.objectTypeId}`,
|
|
63
63
|
})
|
|
64
64
|
);
|
|
65
65
|
}
|
|
66
66
|
} catch (e) {
|
|
67
|
-
|
|
67
|
+
logError(e, { accountId });
|
|
68
68
|
logger.error(
|
|
69
69
|
i18n(`${i18nKey}.errors.update`, {
|
|
70
70
|
definition,
|
package/commands/fetch.js
CHANGED
|
@@ -16,7 +16,7 @@ const { i18n } = require('../lib/lang');
|
|
|
16
16
|
|
|
17
17
|
const i18nKey = 'commands.fetch';
|
|
18
18
|
const { EXIT_CODES } = require('../lib/enums/exitCodes');
|
|
19
|
-
const {
|
|
19
|
+
const { logError } = require('../lib/errorHandlers/index');
|
|
20
20
|
|
|
21
21
|
exports.command = 'fetch <src> [dest]';
|
|
22
22
|
exports.describe = i18n(`${i18nKey}.describe`);
|
|
@@ -50,7 +50,7 @@ exports.handler = async options => {
|
|
|
50
50
|
options
|
|
51
51
|
);
|
|
52
52
|
} catch (err) {
|
|
53
|
-
|
|
53
|
+
logError(err);
|
|
54
54
|
process.exit(EXIT_CODES.ERROR);
|
|
55
55
|
}
|
|
56
56
|
};
|
|
@@ -13,7 +13,7 @@ const { i18n } = require('../../lib/lang');
|
|
|
13
13
|
|
|
14
14
|
const i18nKey = 'commands.filemanager.subcommands.fetch';
|
|
15
15
|
const { EXIT_CODES } = require('../../lib/enums/exitCodes');
|
|
16
|
-
const {
|
|
16
|
+
const { logError } = require('../../lib/errorHandlers/index');
|
|
17
17
|
|
|
18
18
|
exports.command = 'fetch <src> [dest]';
|
|
19
19
|
exports.describe = i18n(`${i18nKey}.describe`);
|
|
@@ -44,7 +44,7 @@ exports.handler = async options => {
|
|
|
44
44
|
includeArchived || false
|
|
45
45
|
);
|
|
46
46
|
} catch (err) {
|
|
47
|
-
|
|
47
|
+
logError(err);
|
|
48
48
|
process.exit(EXIT_CODES.ERROR);
|
|
49
49
|
}
|
|
50
50
|
};
|
|
@@ -10,11 +10,7 @@ const {
|
|
|
10
10
|
} = require('@hubspot/local-dev-lib/cms/modules');
|
|
11
11
|
const { shouldIgnoreFile } = require('@hubspot/local-dev-lib/ignoreRules');
|
|
12
12
|
|
|
13
|
-
const {
|
|
14
|
-
ApiErrorContext,
|
|
15
|
-
logApiUploadErrorInstance,
|
|
16
|
-
} = require('../../lib/errorHandlers/apiErrors');
|
|
17
|
-
const { logErrorInstance } = require('../../lib/errorHandlers/standardErrors');
|
|
13
|
+
const { ApiErrorContext, logError } = require('../../lib/errorHandlers/index');
|
|
18
14
|
const {
|
|
19
15
|
addConfigOptions,
|
|
20
16
|
addAccountOptions,
|
|
@@ -106,7 +102,7 @@ exports.handler = async options => {
|
|
|
106
102
|
src,
|
|
107
103
|
})
|
|
108
104
|
);
|
|
109
|
-
|
|
105
|
+
logError(
|
|
110
106
|
error,
|
|
111
107
|
new ApiErrorContext({
|
|
112
108
|
accountId,
|
|
@@ -133,7 +129,7 @@ exports.handler = async options => {
|
|
|
133
129
|
})
|
|
134
130
|
.catch(error => {
|
|
135
131
|
logger.error(i18n(`${i18nKey}.errors.uploadingFailed`));
|
|
136
|
-
|
|
132
|
+
logError(error, {
|
|
137
133
|
accountId,
|
|
138
134
|
});
|
|
139
135
|
});
|
|
@@ -6,10 +6,7 @@ const {
|
|
|
6
6
|
addUseEnvironmentOptions,
|
|
7
7
|
} = require('../../lib/commonOpts');
|
|
8
8
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
9
|
-
const {
|
|
10
|
-
logApiErrorInstance,
|
|
11
|
-
ApiErrorContext,
|
|
12
|
-
} = require('../../lib/errorHandlers/apiErrors');
|
|
9
|
+
const { logError, ApiErrorContext } = require('../../lib/errorHandlers/index');
|
|
13
10
|
|
|
14
11
|
const { poll } = require('../../lib/polling');
|
|
15
12
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
@@ -20,6 +17,7 @@ const {
|
|
|
20
17
|
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
21
18
|
const { outputBuildLog } = require('../../lib/serverlessLogs');
|
|
22
19
|
const { i18n } = require('../../lib/lang');
|
|
20
|
+
const { isHubSpotHttpError } = require('@hubspot/local-dev-lib/errors/index');
|
|
23
21
|
|
|
24
22
|
const i18nKey = 'commands.functions.subcommands.deploy';
|
|
25
23
|
|
|
@@ -61,7 +59,7 @@ exports.handler = async options => {
|
|
|
61
59
|
functionPath,
|
|
62
60
|
})
|
|
63
61
|
).start();
|
|
64
|
-
const buildId = await buildPackage(accountId, functionPath);
|
|
62
|
+
const { data: buildId } = await buildPackage(accountId, functionPath);
|
|
65
63
|
const successResp = await poll(getBuildStatus, accountId, buildId);
|
|
66
64
|
const buildTimeSeconds = (successResp.buildTime / 1000).toFixed(2);
|
|
67
65
|
spinner.stop();
|
|
@@ -75,13 +73,13 @@ exports.handler = async options => {
|
|
|
75
73
|
);
|
|
76
74
|
} catch (e) {
|
|
77
75
|
spinner && spinner.stop && spinner.stop();
|
|
78
|
-
if (e
|
|
76
|
+
if (isHubSpotHttpError(e) && e.status === 404) {
|
|
79
77
|
logger.error(
|
|
80
78
|
i18n(`${i18nKey}.errors.noPackageJson`, {
|
|
81
79
|
functionPath,
|
|
82
80
|
})
|
|
83
81
|
);
|
|
84
|
-
} else if (e
|
|
82
|
+
} else if (isHubSpotHttpError(e) && e.status === 400) {
|
|
85
83
|
logger.error(e.error.message);
|
|
86
84
|
} else if (e.status === 'ERROR') {
|
|
87
85
|
await outputBuildLog(e.cdnUrl);
|
|
@@ -91,10 +89,7 @@ exports.handler = async options => {
|
|
|
91
89
|
})
|
|
92
90
|
);
|
|
93
91
|
} else {
|
|
94
|
-
|
|
95
|
-
e,
|
|
96
|
-
new ApiErrorContext({ accountId, request: functionPath })
|
|
97
|
-
);
|
|
92
|
+
logError(e, new ApiErrorContext({ accountId, request: functionPath }));
|
|
98
93
|
}
|
|
99
94
|
}
|
|
100
95
|
};
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
const { getRoutes } = require('@hubspot/local-dev-lib/api/functions');
|
|
2
2
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
3
|
-
const {
|
|
4
|
-
logApiErrorInstance,
|
|
5
|
-
ApiErrorContext,
|
|
6
|
-
} = require('../../lib/errorHandlers/apiErrors');
|
|
3
|
+
const { logError, ApiErrorContext } = require('../../lib/errorHandlers/index');
|
|
7
4
|
const { getFunctionArrays } = require('../../lib/getFunctionArrays');
|
|
8
5
|
const { getTableContents, getTableHeader } = require('../../lib/ui/table');
|
|
9
6
|
const {
|
|
@@ -31,8 +28,8 @@ exports.handler = async options => {
|
|
|
31
28
|
|
|
32
29
|
logger.debug(i18n(`${i18nKey}.debug.gettingFunctions`));
|
|
33
30
|
|
|
34
|
-
const routesResp = await getRoutes(accountId).catch(async e => {
|
|
35
|
-
|
|
31
|
+
const { data: routesResp } = await getRoutes(accountId).catch(async e => {
|
|
32
|
+
logError(e, new ApiErrorContext({ accountId }));
|
|
36
33
|
process.exit(EXIT_CODES.SUCCESS);
|
|
37
34
|
});
|
|
38
35
|
|
package/commands/hubdb/clear.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
2
|
-
const {
|
|
2
|
+
const { logError } = require('../../lib/errorHandlers/index');
|
|
3
3
|
const { clearHubDbTableRows } = require('@hubspot/local-dev-lib/hubdb');
|
|
4
4
|
const { publishTable } = require('@hubspot/local-dev-lib/api/hubdb');
|
|
5
5
|
|
|
@@ -37,7 +37,9 @@ exports.handler = async options => {
|
|
|
37
37
|
tableId,
|
|
38
38
|
})
|
|
39
39
|
);
|
|
40
|
-
const {
|
|
40
|
+
const {
|
|
41
|
+
data: { rowCount },
|
|
42
|
+
} = await publishTable(accountId, tableId);
|
|
41
43
|
logger.log(
|
|
42
44
|
i18n(`${i18nKey}.logs.rowCount`, {
|
|
43
45
|
rowCount,
|
|
@@ -52,7 +54,7 @@ exports.handler = async options => {
|
|
|
52
54
|
);
|
|
53
55
|
}
|
|
54
56
|
} catch (e) {
|
|
55
|
-
|
|
57
|
+
logError(e);
|
|
56
58
|
}
|
|
57
59
|
};
|
|
58
60
|
|