@hubspot/cli 6.1.0 → 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
|
@@ -26,10 +26,7 @@ const {
|
|
|
26
26
|
uiAccountDescription,
|
|
27
27
|
} = require('../../lib/ui');
|
|
28
28
|
const SpinniesManager = require('../../lib/ui/SpinniesManager');
|
|
29
|
-
const {
|
|
30
|
-
logApiErrorInstance,
|
|
31
|
-
ApiErrorContext,
|
|
32
|
-
} = require('../../lib/errorHandlers/apiErrors');
|
|
29
|
+
const { logError, ApiErrorContext } = require('../../lib/errorHandlers/index');
|
|
33
30
|
const { EXIT_CODES } = require('../../lib/enums/exitCodes');
|
|
34
31
|
const { promptUser } = require('../../lib/prompts/promptUtils');
|
|
35
32
|
const { isAppDeveloperAccount } = require('../../lib/accountTypes');
|
|
@@ -96,7 +93,10 @@ exports.handler = async options => {
|
|
|
96
93
|
});
|
|
97
94
|
|
|
98
95
|
try {
|
|
99
|
-
const selectedApp = await fetchPublicAppMetadata(
|
|
96
|
+
const { data: selectedApp } = await fetchPublicAppMetadata(
|
|
97
|
+
appId,
|
|
98
|
+
accountId
|
|
99
|
+
);
|
|
100
100
|
// preventProjectMigrations returns true if we have not added app to allowlist config.
|
|
101
101
|
// listingInfo will only exist for marketplace apps
|
|
102
102
|
const preventProjectMigrations = selectedApp.preventProjectMigrations;
|
|
@@ -106,7 +106,7 @@ exports.handler = async options => {
|
|
|
106
106
|
process.exit(EXIT_CODES.ERROR);
|
|
107
107
|
}
|
|
108
108
|
} catch (error) {
|
|
109
|
-
|
|
109
|
+
logError(error, new ApiErrorContext({ accountId }));
|
|
110
110
|
process.exit(EXIT_CODES.ERROR);
|
|
111
111
|
}
|
|
112
112
|
|
|
@@ -136,7 +136,7 @@ exports.handler = async options => {
|
|
|
136
136
|
process.exit(EXIT_CODES.ERROR);
|
|
137
137
|
}
|
|
138
138
|
} catch (error) {
|
|
139
|
-
|
|
139
|
+
logError(error, new ApiErrorContext({ accountId }));
|
|
140
140
|
process.exit(EXIT_CODES.ERROR);
|
|
141
141
|
}
|
|
142
142
|
|
|
@@ -180,7 +180,11 @@ exports.handler = async options => {
|
|
|
180
180
|
}
|
|
181
181
|
});
|
|
182
182
|
|
|
183
|
-
const migrateResponse = await migrateApp(
|
|
183
|
+
const { data: migrateResponse } = await migrateApp(
|
|
184
|
+
accountId,
|
|
185
|
+
appId,
|
|
186
|
+
projectName
|
|
187
|
+
);
|
|
184
188
|
const { id } = migrateResponse;
|
|
185
189
|
const pollResponse = await poll(checkMigrationStatus, accountId, id);
|
|
186
190
|
const { status, project } = pollResponse;
|
|
@@ -189,7 +193,11 @@ exports.handler = async options => {
|
|
|
189
193
|
const { env } = getAccountConfig(accountId);
|
|
190
194
|
const baseUrl = getHubSpotWebsiteOrigin(env);
|
|
191
195
|
|
|
192
|
-
const zippedProject = await downloadProject(
|
|
196
|
+
const { data: zippedProject } = await downloadProject(
|
|
197
|
+
accountId,
|
|
198
|
+
projectName,
|
|
199
|
+
1
|
|
200
|
+
);
|
|
193
201
|
|
|
194
202
|
await extractZipArchive(
|
|
195
203
|
zippedProject,
|
|
@@ -232,13 +240,10 @@ exports.handler = async options => {
|
|
|
232
240
|
text: i18n(`${i18nKey}.migrationStatus.failure`),
|
|
233
241
|
failColor: 'white',
|
|
234
242
|
});
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
error.errors.forEach(e =>
|
|
238
|
-
logApiErrorInstance(e, new ApiErrorContext({ accountId }))
|
|
239
|
-
);
|
|
243
|
+
if (error.errors) {
|
|
244
|
+
error.errors.forEach(logError);
|
|
240
245
|
} else {
|
|
241
|
-
|
|
246
|
+
logError(error, new ApiErrorContext({ accountId }));
|
|
242
247
|
}
|
|
243
248
|
|
|
244
249
|
process.exit(EXIT_CODES.ERROR);
|
|
@@ -20,12 +20,9 @@ const {
|
|
|
20
20
|
} = require('../../lib/projects');
|
|
21
21
|
const { i18n } = require('../../lib/lang');
|
|
22
22
|
const { getAccountConfig } = require('@hubspot/local-dev-lib/config');
|
|
23
|
-
const { isSpecifiedError } = require('@hubspot/local-dev-lib/errors/
|
|
23
|
+
const { isSpecifiedError } = require('@hubspot/local-dev-lib/errors/index');
|
|
24
24
|
const { PROJECT_ERROR_TYPES } = require('../../lib/constants');
|
|
25
|
-
const {
|
|
26
|
-
logApiErrorInstance,
|
|
27
|
-
ApiErrorContext,
|
|
28
|
-
} = require('../../lib/errorHandlers/apiErrors');
|
|
25
|
+
const { logError, ApiErrorContext } = require('../../lib/errorHandlers/index');
|
|
29
26
|
const { EXIT_CODES } = require('../../lib/enums/exitCodes');
|
|
30
27
|
|
|
31
28
|
const i18nKey = 'commands.project.subcommands.upload';
|
|
@@ -71,7 +68,7 @@ exports.handler = async options => {
|
|
|
71
68
|
logger.error(i18n(`${i18nKey}.errors.projectLockedError`));
|
|
72
69
|
logger.log();
|
|
73
70
|
} else {
|
|
74
|
-
|
|
71
|
+
logError(
|
|
75
72
|
result.uploadError,
|
|
76
73
|
new ApiErrorContext({
|
|
77
74
|
accountId,
|
|
@@ -102,10 +99,7 @@ exports.handler = async options => {
|
|
|
102
99
|
process.exit(EXIT_CODES.SUCCESS);
|
|
103
100
|
}
|
|
104
101
|
} catch (e) {
|
|
105
|
-
|
|
106
|
-
e,
|
|
107
|
-
new ApiErrorContext({ accountId, request: 'project upload' })
|
|
108
|
-
);
|
|
102
|
+
logError(e, new ApiErrorContext({ accountId, request: 'project upload' }));
|
|
109
103
|
process.exit(EXIT_CODES.ERROR);
|
|
110
104
|
}
|
|
111
105
|
};
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
const { i18n } = require('../../lib/lang');
|
|
2
2
|
const { createWatcher } = require('../../lib/projectsWatch');
|
|
3
|
-
const {
|
|
4
|
-
logApiErrorInstance,
|
|
5
|
-
ApiErrorContext,
|
|
6
|
-
} = require('../../lib/errorHandlers/apiErrors');
|
|
3
|
+
const { logError, ApiErrorContext } = require('../../lib/errorHandlers/index');
|
|
7
4
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
8
5
|
const { PROJECT_ERROR_TYPES } = require('../../lib/constants');
|
|
9
6
|
const {
|
|
@@ -27,7 +24,7 @@ const {
|
|
|
27
24
|
cancelStagedBuild,
|
|
28
25
|
fetchProjectBuilds,
|
|
29
26
|
} = require('@hubspot/local-dev-lib/api/projects');
|
|
30
|
-
const { isSpecifiedError } = require('@hubspot/local-dev-lib/errors/
|
|
27
|
+
const { isSpecifiedError } = require('@hubspot/local-dev-lib/errors/index');
|
|
31
28
|
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
32
29
|
const { EXIT_CODES } = require('../../lib/enums/exitCodes');
|
|
33
30
|
const { handleKeypress, handleExit } = require('../../lib/process');
|
|
@@ -71,7 +68,7 @@ const handleUserInput = (accountId, projectName, currentBuildId) => {
|
|
|
71
68
|
) {
|
|
72
69
|
process.exit(EXIT_CODES.SUCCESS);
|
|
73
70
|
} else {
|
|
74
|
-
|
|
71
|
+
logError(err, new ApiErrorContext({ accountId }));
|
|
75
72
|
process.exit(EXIT_CODES.ERROR);
|
|
76
73
|
}
|
|
77
74
|
}
|
|
@@ -103,11 +100,9 @@ exports.handler = async options => {
|
|
|
103
100
|
await ensureProjectExists(accountId, projectConfig.name);
|
|
104
101
|
|
|
105
102
|
try {
|
|
106
|
-
const {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
options
|
|
110
|
-
);
|
|
103
|
+
const {
|
|
104
|
+
data: { results: builds },
|
|
105
|
+
} = await fetchProjectBuilds(accountId, projectConfig.name, options);
|
|
111
106
|
const hasNoBuilds = !builds || !builds.length;
|
|
112
107
|
|
|
113
108
|
const startWatching = async () => {
|
|
@@ -139,7 +134,7 @@ exports.handler = async options => {
|
|
|
139
134
|
logger.error(i18n(`${i18nKey}.errors.projectLockedError`));
|
|
140
135
|
logger.log();
|
|
141
136
|
} else {
|
|
142
|
-
|
|
137
|
+
logError(
|
|
143
138
|
result.uploadError,
|
|
144
139
|
new ApiErrorContext({
|
|
145
140
|
accountId,
|
|
@@ -153,7 +148,7 @@ exports.handler = async options => {
|
|
|
153
148
|
await startWatching();
|
|
154
149
|
}
|
|
155
150
|
} catch (e) {
|
|
156
|
-
|
|
151
|
+
logError(e, new ApiErrorContext({ accountId }));
|
|
157
152
|
}
|
|
158
153
|
};
|
|
159
154
|
|
package/commands/remove.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
const { deleteFile } = require('@hubspot/local-dev-lib/api/fileMapper');
|
|
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
|
|
|
8
5
|
const {
|
|
9
6
|
addConfigOptions,
|
|
@@ -36,7 +33,7 @@ exports.handler = async options => {
|
|
|
36
33
|
logger.error(
|
|
37
34
|
i18n(`${i18nKey}.errors.deleteFailed`, { accountId, path: hsPath })
|
|
38
35
|
);
|
|
39
|
-
|
|
36
|
+
logError(
|
|
40
37
|
error,
|
|
41
38
|
new ApiErrorContext({
|
|
42
39
|
accountId,
|
|
@@ -22,10 +22,8 @@ const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
|
22
22
|
const { sandboxTypePrompt } = require('../../lib/prompts/sandboxesPrompt');
|
|
23
23
|
const { promptUser } = require('../../lib/prompts/promptUtils');
|
|
24
24
|
const { syncSandbox } = require('../../lib/sandboxSync');
|
|
25
|
-
const {
|
|
26
|
-
const {
|
|
27
|
-
isMissingScopeError,
|
|
28
|
-
} = require('@hubspot/local-dev-lib/errors/apiErrors');
|
|
25
|
+
const { logError } = require('../../lib/errorHandlers/index');
|
|
26
|
+
const { isMissingScopeError } = require('@hubspot/local-dev-lib/errors/index');
|
|
29
27
|
const { getHubSpotWebsiteOrigin } = require('@hubspot/local-dev-lib/urls');
|
|
30
28
|
const {
|
|
31
29
|
HUBSPOT_ACCOUNT_TYPES,
|
|
@@ -102,7 +100,7 @@ exports.handler = async options => {
|
|
|
102
100
|
})
|
|
103
101
|
);
|
|
104
102
|
} else {
|
|
105
|
-
|
|
103
|
+
logError(err);
|
|
106
104
|
}
|
|
107
105
|
process.exit(EXIT_CODES.ERROR);
|
|
108
106
|
}
|
|
@@ -167,7 +165,7 @@ exports.handler = async options => {
|
|
|
167
165
|
}
|
|
168
166
|
await handleSyncSandbox(availableSyncTasks);
|
|
169
167
|
} catch (err) {
|
|
170
|
-
|
|
168
|
+
logError(err);
|
|
171
169
|
throw err;
|
|
172
170
|
}
|
|
173
171
|
|
|
@@ -8,15 +8,9 @@ const {
|
|
|
8
8
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
9
9
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
10
10
|
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
11
|
-
const {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
} = require('../../lib/errorHandlers/standardErrors');
|
|
15
|
-
const {
|
|
16
|
-
isSpecifiedError,
|
|
17
|
-
isSpecifiedHubSpotAuthError,
|
|
18
|
-
} = require('@hubspot/local-dev-lib/errors/apiErrors');
|
|
19
|
-
const { deleteSandbox } = require('@hubspot/local-dev-lib/sandboxes');
|
|
11
|
+
const { logError, debugError } = require('../../lib/errorHandlers/index');
|
|
12
|
+
const { isSpecifiedError } = require('@hubspot/local-dev-lib/errors/index');
|
|
13
|
+
const { deleteSandbox } = require('@hubspot/local-dev-lib/api/sandboxHubs');
|
|
20
14
|
const { i18n } = require('../../lib/lang');
|
|
21
15
|
const { deleteSandboxPrompt } = require('../../lib/prompts/sandboxesPrompt');
|
|
22
16
|
const {
|
|
@@ -169,9 +163,9 @@ exports.handler = async options => {
|
|
|
169
163
|
}
|
|
170
164
|
process.exit(EXIT_CODES.SUCCESS);
|
|
171
165
|
} catch (err) {
|
|
172
|
-
|
|
166
|
+
debugError(err);
|
|
173
167
|
|
|
174
|
-
if (
|
|
168
|
+
if (isSpecifiedError(err, { statusCode: 401 })) {
|
|
175
169
|
// Intercept invalid key error
|
|
176
170
|
// This command uses the parent portal PAK to delete a sandbox, so we must specify which account needs a new key
|
|
177
171
|
logger.log('');
|
|
@@ -221,7 +215,7 @@ exports.handler = async options => {
|
|
|
221
215
|
}
|
|
222
216
|
process.exit(EXIT_CODES.SUCCESS);
|
|
223
217
|
} else {
|
|
224
|
-
|
|
218
|
+
logError(err);
|
|
225
219
|
}
|
|
226
220
|
process.exit(EXIT_CODES.ERROR);
|
|
227
221
|
}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
2
|
-
const {
|
|
3
|
-
logApiErrorInstance,
|
|
4
|
-
ApiErrorContext,
|
|
5
|
-
} = require('../../lib/errorHandlers/apiErrors');
|
|
2
|
+
const { logError, ApiErrorContext } = require('../../lib/errorHandlers/index');
|
|
6
3
|
const { addSecret } = require('@hubspot/local-dev-lib/api/secrets');
|
|
7
4
|
|
|
8
5
|
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
@@ -47,7 +44,7 @@ exports.handler = async options => {
|
|
|
47
44
|
secretName,
|
|
48
45
|
})
|
|
49
46
|
);
|
|
50
|
-
|
|
47
|
+
logError(
|
|
51
48
|
err,
|
|
52
49
|
new ApiErrorContext({
|
|
53
50
|
request: 'add secret',
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
2
|
-
const {
|
|
3
|
-
ApiErrorContext,
|
|
4
|
-
logApiErrorInstance,
|
|
5
|
-
} = require('../../lib/errorHandlers/apiErrors');
|
|
2
|
+
const { ApiErrorContext, logError } = require('../../lib/errorHandlers/index');
|
|
6
3
|
const { deleteSecret } = require('@hubspot/local-dev-lib/api/secrets');
|
|
7
4
|
|
|
8
5
|
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
@@ -44,7 +41,7 @@ exports.handler = async options => {
|
|
|
44
41
|
secretName,
|
|
45
42
|
})
|
|
46
43
|
);
|
|
47
|
-
|
|
44
|
+
logError(
|
|
48
45
|
err,
|
|
49
46
|
new ApiErrorContext({
|
|
50
47
|
request: 'delete a secret',
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
2
|
-
const {
|
|
3
|
-
logApiErrorInstance,
|
|
4
|
-
ApiErrorContext,
|
|
5
|
-
} = require('../../lib/errorHandlers/apiErrors');
|
|
2
|
+
const { logError, ApiErrorContext } = require('../../lib/errorHandlers/index');
|
|
6
3
|
const { fetchSecrets } = require('@hubspot/local-dev-lib/api/secrets');
|
|
7
4
|
|
|
8
5
|
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
@@ -29,7 +26,9 @@ exports.handler = async options => {
|
|
|
29
26
|
trackCommandUsage('secrets-list', null, accountId);
|
|
30
27
|
|
|
31
28
|
try {
|
|
32
|
-
const {
|
|
29
|
+
const {
|
|
30
|
+
data: { results },
|
|
31
|
+
} = await fetchSecrets(accountId);
|
|
33
32
|
const groupLabel = i18n(`${i18nKey}.groupLabel`, {
|
|
34
33
|
accountIdentifier: uiAccountDescription(accountId),
|
|
35
34
|
});
|
|
@@ -38,7 +37,7 @@ exports.handler = async options => {
|
|
|
38
37
|
logger.groupEnd(groupLabel);
|
|
39
38
|
} catch (err) {
|
|
40
39
|
logger.error(i18n(`${i18nKey}.errors.list`));
|
|
41
|
-
|
|
40
|
+
logError(
|
|
42
41
|
err,
|
|
43
42
|
new ApiErrorContext({
|
|
44
43
|
request: 'add secret',
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
2
|
-
const {
|
|
3
|
-
ApiErrorContext,
|
|
4
|
-
logApiErrorInstance,
|
|
5
|
-
} = require('../../lib/errorHandlers/apiErrors');
|
|
2
|
+
const { ApiErrorContext, logError } = require('../../lib/errorHandlers/index');
|
|
6
3
|
const { updateSecret } = require('@hubspot/local-dev-lib/api/secrets');
|
|
7
4
|
|
|
8
5
|
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
@@ -48,7 +45,7 @@ exports.handler = async options => {
|
|
|
48
45
|
secretName,
|
|
49
46
|
})
|
|
50
47
|
);
|
|
51
|
-
|
|
48
|
+
logError(
|
|
52
49
|
err,
|
|
53
50
|
new ApiErrorContext({
|
|
54
51
|
request: 'update secret',
|
|
@@ -21,10 +21,7 @@ const {
|
|
|
21
21
|
FILE_UPLOAD_RESULT_TYPES,
|
|
22
22
|
} = require('@hubspot/local-dev-lib/constants/files');
|
|
23
23
|
const cliProgress = require('cli-progress');
|
|
24
|
-
const {
|
|
25
|
-
ApiErrorContext,
|
|
26
|
-
logApiUploadErrorInstance,
|
|
27
|
-
} = require('../../lib/errorHandlers/apiErrors');
|
|
24
|
+
const { ApiErrorContext, logError } = require('../../lib/errorHandlers/index');
|
|
28
25
|
const { handleExit, handleKeypress } = require('../../lib/process');
|
|
29
26
|
const { getThemeJSONPath } = require('@hubspot/local-dev-lib/cms/themes');
|
|
30
27
|
const { getProjectConfig } = require('../../lib/projects');
|
|
@@ -160,7 +157,7 @@ exports.handler = async options => {
|
|
|
160
157
|
results.forEach(result => {
|
|
161
158
|
if (result.resultType == FILE_UPLOAD_RESULT_TYPES.FAILURE) {
|
|
162
159
|
logger.error('Uploading file "%s" to "%s" failed', result.file, dest);
|
|
163
|
-
|
|
160
|
+
logError(
|
|
164
161
|
result.error,
|
|
165
162
|
new ApiErrorContext({
|
|
166
163
|
accountId,
|
package/commands/upload.js
CHANGED
|
@@ -14,11 +14,7 @@ const {
|
|
|
14
14
|
isAllowedExtension,
|
|
15
15
|
} = require('@hubspot/local-dev-lib/path');
|
|
16
16
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
17
|
-
const {
|
|
18
|
-
ApiErrorContext,
|
|
19
|
-
logApiUploadErrorInstance,
|
|
20
|
-
} = require('../lib/errorHandlers/apiErrors');
|
|
21
|
-
const { logErrorInstance } = require('../lib/errorHandlers/standardErrors');
|
|
17
|
+
const { ApiErrorContext, logError } = require('../lib/errorHandlers/index');
|
|
22
18
|
const {
|
|
23
19
|
validateSrcAndDestPaths,
|
|
24
20
|
} = require('@hubspot/local-dev-lib/cms/modules');
|
|
@@ -182,7 +178,7 @@ exports.handler = async options => {
|
|
|
182
178
|
src,
|
|
183
179
|
})
|
|
184
180
|
);
|
|
185
|
-
|
|
181
|
+
logError(
|
|
186
182
|
error,
|
|
187
183
|
new ApiErrorContext({
|
|
188
184
|
accountId,
|
|
@@ -270,7 +266,7 @@ exports.handler = async options => {
|
|
|
270
266
|
src,
|
|
271
267
|
})
|
|
272
268
|
);
|
|
273
|
-
|
|
269
|
+
logError(error, {
|
|
274
270
|
accountId,
|
|
275
271
|
});
|
|
276
272
|
process.exit(EXIT_CODES.WARNING);
|
package/commands/watch.js
CHANGED
|
@@ -18,11 +18,7 @@ const { validateMode, loadAndValidateOptions } = require('../lib/validation');
|
|
|
18
18
|
const { trackCommandUsage } = require('../lib/usageTracking');
|
|
19
19
|
const { i18n } = require('../lib/lang');
|
|
20
20
|
const { getUploadableFileList } = require('../lib/upload');
|
|
21
|
-
const {
|
|
22
|
-
const {
|
|
23
|
-
logApiUploadErrorInstance,
|
|
24
|
-
ApiErrorContext,
|
|
25
|
-
} = require('../lib/errorHandlers/apiErrors');
|
|
21
|
+
const { logError, ApiErrorContext } = require('../lib/errorHandlers/index');
|
|
26
22
|
const i18nKey = 'commands.watch';
|
|
27
23
|
|
|
28
24
|
const { EXIT_CODES } = require('../lib/enums/exitCodes');
|
|
@@ -99,7 +95,7 @@ exports.handler = async options => {
|
|
|
99
95
|
accountId,
|
|
100
96
|
})
|
|
101
97
|
);
|
|
102
|
-
|
|
98
|
+
logError(error, {
|
|
103
99
|
accountId,
|
|
104
100
|
});
|
|
105
101
|
};
|
|
@@ -112,7 +108,7 @@ exports.handler = async options => {
|
|
|
112
108
|
accountId,
|
|
113
109
|
})
|
|
114
110
|
);
|
|
115
|
-
|
|
111
|
+
logError(
|
|
116
112
|
error,
|
|
117
113
|
new ApiErrorContext({
|
|
118
114
|
accountId,
|
package/lang/en.lyaml
CHANGED
|
@@ -1008,7 +1008,9 @@ en:
|
|
|
1008
1008
|
localDev:
|
|
1009
1009
|
confirmDefaultAccountIsTarget:
|
|
1010
1010
|
declineDefaultAccountExplanation: "To develop on a different account, run {{ useCommand }} to change your default account, then re-run {{ devCommand }}."
|
|
1011
|
-
|
|
1011
|
+
checkIfDefaultAccountIsSupported:
|
|
1012
|
+
publicApp: "This project contains a public app. Local development of public apps is only supported on developer accounts and developer test accounts. Change your default account using {{ useCommand }}, or link a new account with {{ authCommand }}."
|
|
1013
|
+
privateApp: "This project contains a private app. Local development of private apps is not supported in developer accounts. Change your default account using {{ useCommand }}, or link a new account with {{ authCommand }}."
|
|
1012
1014
|
validateAccountOption:
|
|
1013
1015
|
invalidPublicAppAccount: "This project contains a public app. The \"--account\" flag must point to a developer test account to develop this project locally. Alternatively, change your default account to an App Developer Account using {{ useCommand }} and run {{ devCommand }} to set up a new Developer Test Account."
|
|
1014
1016
|
invalidPrivateAppAccount: "This project contains a private app. The account specified with the \"--account\" flag points to a developer account, which do not support the local development of private apps. Update the \"--account\" flag to point to a standard, sandbox, or developer test account, or change your default account by running {{ useCommand }}."
|
|
@@ -1401,23 +1403,12 @@ en:
|
|
|
1401
1403
|
notSuperAdmin: "Couldn't run the sync because you are not a super admin in {{ account }}. Ask the account owner for super admin access to the sandbox."
|
|
1402
1404
|
objectNotFound: "Couldn't sync the sandbox because {{#bold}}{{ account }}{{/bold}} may have been deleted through the UI. Run {{#bold}}hs sandbox delete{{/bold}} to remove this account from the config. "
|
|
1403
1405
|
errorHandlers:
|
|
1404
|
-
|
|
1406
|
+
index:
|
|
1405
1407
|
errorOccurred: "Error: {{ error }}"
|
|
1406
1408
|
errorContext: "Context: {{ context }}"
|
|
1407
1409
|
errorCause: "Cause: {{ cause }}"
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
unknownErrorOccurred: "An unknown error has occurred"
|
|
1411
|
-
fileSystemErrors:
|
|
1412
|
-
errorOccurred: "An error occurred while {{ fileAction }} {{ filepath }}."
|
|
1413
|
-
errorExplanation: "This is the result of a system error: {{ errorMessage }}"
|
|
1414
|
-
apiErrors:
|
|
1415
|
-
verifyAccessKeyAndUserAccess:
|
|
1416
|
-
fetchScopeDataError: "Error verifying access of scopeGroup {{ scopeGroup }}: {{ error }}"
|
|
1417
|
-
portalMissingScope: "Your account does not have access to this action. Talk to an account admin to request it."
|
|
1418
|
-
userMissingScope: "You don't have access to this action. Ask an account admin to change your permissions in Users & Teams settings."
|
|
1419
|
-
genericMissingScope: "Your access key does not allow this action. Please generate a new access key by running `hs auth personalaccesskey`."
|
|
1420
|
-
overrideErrors:
|
|
1410
|
+
unknownErrorOccurred: "An unknown error has occurred."
|
|
1411
|
+
suppressErrors:
|
|
1421
1412
|
platformVersionErrors:
|
|
1422
1413
|
header: "Platform version update required"
|
|
1423
1414
|
unspecifiedPlatformVersion: "Projects with an {{#bold}}{{platformVersion}}{{/bold}} are no longer supported."
|
|
@@ -1427,3 +1418,9 @@ en:
|
|
|
1427
1418
|
docsLink: "Projects platform versioning (BETA)"
|
|
1428
1419
|
betaLink: "For more info, see {{ docsLink }}."
|
|
1429
1420
|
missingScopeError: "Couldn't execute the {{ request }} because the access key for {{ accountName }} is missing required scopes. To update scopes, run {{ authCommand }}. Then deactivate the existing key and generate a new one that includes the missing scopes."
|
|
1421
|
+
serverless:
|
|
1422
|
+
verifyAccessKeyAndUserAccess:
|
|
1423
|
+
fetchScopeDataError: "Error verifying access of scopeGroup {{ scopeGroup }}: {{ error }}"
|
|
1424
|
+
portalMissingScope: "Your account does not have access to this action. Talk to an account admin to request it."
|
|
1425
|
+
userMissingScope: "You don't have access to this action. Ask an account admin to change your permissions in Users & Teams settings."
|
|
1426
|
+
genericMissingScope: "Your access key does not allow this action. Please generate a new access key by running `hs auth personalaccesskey`."
|
package/lib/LocalDevManager.js
CHANGED
|
@@ -34,7 +34,7 @@ const {
|
|
|
34
34
|
uiLink,
|
|
35
35
|
uiLine,
|
|
36
36
|
} = require('./ui');
|
|
37
|
-
const {
|
|
37
|
+
const { logError } = require('./errorHandlers/index');
|
|
38
38
|
const { installPublicAppPrompt } = require('./prompts/installPublicAppPrompt');
|
|
39
39
|
const {
|
|
40
40
|
activeInstallConfirmationPrompt,
|
|
@@ -99,7 +99,7 @@ class LocalDevManager {
|
|
|
99
99
|
await this.checkActivePublicAppInstalls();
|
|
100
100
|
await this.checkPublicAppInstallation();
|
|
101
101
|
} catch (e) {
|
|
102
|
-
|
|
102
|
+
logError(e);
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
}
|
|
@@ -109,7 +109,7 @@ class LocalDevManager {
|
|
|
109
109
|
return;
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
const portalPublicApps = await fetchPublicAppsForPortal(
|
|
112
|
+
const { data: portalPublicApps } = await fetchPublicAppsForPortal(
|
|
113
113
|
this.targetProjectAccountId
|
|
114
114
|
);
|
|
115
115
|
|
|
@@ -119,7 +119,7 @@ class LocalDevManager {
|
|
|
119
119
|
|
|
120
120
|
// TODO: Update to account for new API with { data }
|
|
121
121
|
const {
|
|
122
|
-
uniquePortalInstallCount,
|
|
122
|
+
data: { uniquePortalInstallCount },
|
|
123
123
|
} = await fetchPublicAppProductionInstallCounts(
|
|
124
124
|
activePublicAppData.id,
|
|
125
125
|
this.targetProjectAccountId
|
|
@@ -264,14 +264,16 @@ class LocalDevManager {
|
|
|
264
264
|
process.exit(EXIT_CODES.SUCCESS);
|
|
265
265
|
}
|
|
266
266
|
|
|
267
|
-
getActiveAppInstallationData() {
|
|
268
|
-
|
|
267
|
+
async getActiveAppInstallationData() {
|
|
268
|
+
const { data } = await fetchAppInstallationData(
|
|
269
269
|
this.targetAccountId,
|
|
270
270
|
this.projectId,
|
|
271
271
|
this.activeApp.config.uid,
|
|
272
272
|
this.activeApp.config.auth.requiredScopes,
|
|
273
273
|
this.activeApp.config.auth.optionalScopes
|
|
274
274
|
);
|
|
275
|
+
|
|
276
|
+
return data;
|
|
275
277
|
}
|
|
276
278
|
|
|
277
279
|
async checkPublicAppInstallation() {
|
|
@@ -50,24 +50,26 @@ describe('cli/lib/projectLogsManager', () => {
|
|
|
50
50
|
getProjectConfig.mockResolvedValue(projectConfig);
|
|
51
51
|
ensureProjectExists.mockResolvedValue(projectDetails);
|
|
52
52
|
fetchProjectComponentsMetadata.mockResolvedValue({
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
deployOutput: {
|
|
59
|
-
appId,
|
|
60
|
-
},
|
|
61
|
-
featureComponents: [
|
|
62
|
-
...functions,
|
|
63
|
-
{
|
|
64
|
-
type: {
|
|
65
|
-
name: 'NOT_AN_APP_FUNCTION',
|
|
66
|
-
},
|
|
53
|
+
data: {
|
|
54
|
+
topLevelComponentMetadata: [
|
|
55
|
+
{
|
|
56
|
+
type: {
|
|
57
|
+
name: 'PRIVATE_APP',
|
|
67
58
|
},
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
59
|
+
deployOutput: {
|
|
60
|
+
appId,
|
|
61
|
+
},
|
|
62
|
+
featureComponents: [
|
|
63
|
+
...functions,
|
|
64
|
+
{
|
|
65
|
+
type: {
|
|
66
|
+
name: 'NOT_AN_APP_FUNCTION',
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
},
|
|
71
73
|
});
|
|
72
74
|
});
|
|
73
75
|
|
|
@@ -71,14 +71,16 @@ describe('@hubspot/cli/lib/serverlessLogs', () => {
|
|
|
71
71
|
|
|
72
72
|
const fetchLatest = jest.fn(() => {
|
|
73
73
|
return Promise.resolve({
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
74
|
+
data: {
|
|
75
|
+
id: '1234',
|
|
76
|
+
executionTime: 510,
|
|
77
|
+
log: 'Log message',
|
|
78
|
+
error: null,
|
|
79
|
+
status: 'SUCCESS',
|
|
80
|
+
createdAt: 1620232011451,
|
|
81
|
+
memory: '70/128 MB',
|
|
82
|
+
duration: '53.40 ms',
|
|
83
|
+
},
|
|
82
84
|
});
|
|
83
85
|
});
|
|
84
86
|
const latestLogResponse = {
|
|
@@ -110,7 +112,9 @@ describe('@hubspot/cli/lib/serverlessLogs', () => {
|
|
|
110
112
|
},
|
|
111
113
|
},
|
|
112
114
|
};
|
|
113
|
-
const tailCall = jest.fn(() =>
|
|
115
|
+
const tailCall = jest.fn(() =>
|
|
116
|
+
Promise.resolve({ data: latestLogResponse })
|
|
117
|
+
);
|
|
114
118
|
|
|
115
119
|
await tailLogs({
|
|
116
120
|
accountId: ACCOUNT_ID,
|