@hubspot/cli 5.0.2-beta.1 → 5.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.js +1 -1
- package/commands/accounts/clean.js +1 -1
- package/commands/auth.js +1 -1
- package/commands/config/set/defaultMode.js +1 -1
- package/commands/create.js +1 -1
- package/commands/customObject/create.js +1 -1
- package/commands/customObject/schema/create.js +3 -1
- package/commands/customObject/schema/delete.js +3 -1
- package/commands/customObject/schema/fetch-all.js +3 -1
- package/commands/customObject/schema/fetch.js +3 -1
- package/commands/customObject/schema/list.js +3 -1
- package/commands/customObject/schema/update.js +3 -1
- package/commands/filemanager/upload.js +2 -2
- package/commands/functions/deploy.js +1 -1
- package/commands/functions/list.js +1 -1
- package/commands/hubdb/clear.js +1 -1
- package/commands/hubdb/create.js +1 -1
- package/commands/hubdb/delete.js +1 -1
- package/commands/hubdb/fetch.js +1 -1
- package/commands/init.js +1 -1
- package/commands/lint.js +1 -1
- package/commands/list.js +1 -1
- package/commands/mv.js +1 -1
- package/commands/project/add.js +1 -1
- package/commands/project/create.js +1 -0
- package/commands/project/deploy.js +1 -1
- package/commands/project/dev.js +5 -6
- package/commands/project/download.js +1 -1
- package/commands/project/listBuilds.js +1 -1
- package/commands/project/logs.js +1 -1
- package/commands/project/upload.js +2 -4
- package/commands/project/watch.js +1 -1
- package/commands/remove.js +1 -1
- package/commands/sandbox/create.js +2 -4
- package/commands/sandbox/delete.js +7 -6
- package/commands/sandbox/sync.js +2 -6
- package/commands/secrets/addSecret.js +1 -1
- package/commands/secrets/deleteSecret.js +1 -1
- package/commands/secrets/listSecrets.js +1 -1
- package/commands/secrets/updateSecret.js +1 -1
- package/commands/upload.js +2 -2
- package/lang/en.lyaml +35 -0
- package/lib/errorHandlers/apiErrors.js +352 -0
- package/lib/errorHandlers/fileSystemErrors.js +55 -0
- package/lib/errorHandlers/standardErrors.js +95 -0
- package/lib/projects.js +3 -5
- package/lib/projectsWatch.js +1 -1
- package/lib/prompts/downloadProjectPrompt.js +1 -1
- package/lib/prompts/projectsLogsPrompt.js +1 -1
- package/lib/sandbox-create.js +2 -2
- package/lib/sandbox-sync.js +5 -5
- package/lib/serverlessLogs.js +1 -1
- package/lib/ui.js +1 -0
- package/lib/validation.js +1 -1
- package/package.json +4 -3
package/bin/cli.js
CHANGED
|
@@ -5,7 +5,7 @@ const updateNotifier = require('update-notifier');
|
|
|
5
5
|
const chalk = require('chalk');
|
|
6
6
|
|
|
7
7
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
8
|
-
const { logErrorInstance } = require('
|
|
8
|
+
const { logErrorInstance } = require('../lib/errorHandlers/standardErrors');
|
|
9
9
|
const { setLogLevel, getCommandName } = require('../lib/commonOpts');
|
|
10
10
|
const {
|
|
11
11
|
trackHelpUsage,
|
|
@@ -21,7 +21,7 @@ const SpinniesManager = require('../../lib/SpinniesManager');
|
|
|
21
21
|
const { deleteAccount } = require('@hubspot/cli-lib/lib/config');
|
|
22
22
|
const {
|
|
23
23
|
isSpecifiedHubSpotAuthError,
|
|
24
|
-
} = require('
|
|
24
|
+
} = require('../../lib/errorHandlers/apiErrors');
|
|
25
25
|
|
|
26
26
|
const i18nKey = 'cli.commands.accounts.subcommands.clean';
|
|
27
27
|
|
package/commands/auth.js
CHANGED
|
@@ -16,7 +16,7 @@ const {
|
|
|
16
16
|
getConfig,
|
|
17
17
|
getConfigPath,
|
|
18
18
|
} = require('@hubspot/cli-lib/lib/config');
|
|
19
|
-
const { commaSeparatedValues } = require('@hubspot/
|
|
19
|
+
const { commaSeparatedValues } = require('@hubspot/local-dev-lib/text');
|
|
20
20
|
const { promptUser } = require('../lib/prompts/promptUtils');
|
|
21
21
|
const {
|
|
22
22
|
personalAccessKeyPrompt,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
2
2
|
const { updateDefaultMode } = require('@hubspot/cli-lib/lib/config');
|
|
3
3
|
const { Mode } = require('@hubspot/cli-lib');
|
|
4
|
-
const { commaSeparatedValues } = require('@hubspot/
|
|
4
|
+
const { commaSeparatedValues } = require('@hubspot/local-dev-lib/text');
|
|
5
5
|
const { trackCommandUsage } = require('../../../lib/usageTracking');
|
|
6
6
|
const { promptUser } = require('../../../lib/prompts/promptUtils');
|
|
7
7
|
const { i18n } = require('../../../lib/lang');
|
package/commands/create.js
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
const fs = require('fs-extra');
|
|
25
25
|
const {
|
|
26
26
|
logFileSystemErrorInstance,
|
|
27
|
-
} = require('
|
|
27
|
+
} = require('../lib/errorHandlers/fileSystemErrors');
|
|
28
28
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
29
29
|
const { setLogLevel, getAccountId } = require('../lib/commonOpts');
|
|
30
30
|
const { logDebugInfo } = require('../lib/debugInfo');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
2
|
-
const { logErrorInstance } = require('
|
|
2
|
+
const { logErrorInstance } = require('../../lib/errorHandlers/standardErrors');
|
|
3
3
|
const { getAbsoluteFilePath } = require('@hubspot/cli-lib/path');
|
|
4
4
|
const {
|
|
5
5
|
isFileValidJSON,
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
2
|
-
const {
|
|
2
|
+
const {
|
|
3
|
+
logErrorInstance,
|
|
4
|
+
} = require('../../../lib/errorHandlers/standardErrors');
|
|
3
5
|
const { getAbsoluteFilePath } = require('@hubspot/cli-lib/path');
|
|
4
6
|
const {
|
|
5
7
|
isFileValidJSON,
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
2
|
-
const {
|
|
2
|
+
const {
|
|
3
|
+
logErrorInstance,
|
|
4
|
+
} = require('../../../lib/errorHandlers/standardErrors');
|
|
3
5
|
|
|
4
6
|
const { loadAndValidateOptions } = require('../../../lib/validation');
|
|
5
7
|
const { trackCommandUsage } = require('../../../lib/usageTracking');
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
2
|
-
const {
|
|
2
|
+
const {
|
|
3
|
+
logErrorInstance,
|
|
4
|
+
} = require('../../../lib/errorHandlers/standardErrors');
|
|
3
5
|
|
|
4
6
|
const { loadAndValidateOptions } = require('../../../lib/validation');
|
|
5
7
|
const { trackCommandUsage } = require('../../../lib/usageTracking');
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
2
|
const { isConfigFlagEnabled } = require('@hubspot/cli-lib');
|
|
3
3
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
4
|
-
const {
|
|
4
|
+
const {
|
|
5
|
+
logErrorInstance,
|
|
6
|
+
} = require('../../../lib/errorHandlers/standardErrors');
|
|
5
7
|
const { ConfigFlags } = require('@hubspot/cli-lib/lib/constants');
|
|
6
8
|
const { downloadSchema, getResolvedPath } = require('@hubspot/cli-lib/schema');
|
|
7
9
|
const { fetchSchema } = require('@hubspot/cli-lib/api/fileTransport');
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
2
|
-
const {
|
|
2
|
+
const {
|
|
3
|
+
logErrorInstance,
|
|
4
|
+
} = require('../../../lib/errorHandlers/standardErrors');
|
|
3
5
|
|
|
4
6
|
const { loadAndValidateOptions } = require('../../../lib/validation');
|
|
5
7
|
const { trackCommandUsage } = require('../../../lib/usageTracking');
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
2
|
-
const {
|
|
2
|
+
const {
|
|
3
|
+
logErrorInstance,
|
|
4
|
+
} = require('../../../lib/errorHandlers/standardErrors');
|
|
3
5
|
const { getAbsoluteFilePath } = require('@hubspot/cli-lib/path');
|
|
4
6
|
const {
|
|
5
7
|
isFileValidJSON,
|
|
@@ -6,10 +6,10 @@ const { uploadFile } = require('@hubspot/cli-lib/api/fileManager');
|
|
|
6
6
|
const { getCwd, convertToUnixPath } = require('@hubspot/cli-lib/path');
|
|
7
7
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
8
8
|
const {
|
|
9
|
-
logErrorInstance,
|
|
10
9
|
ApiErrorContext,
|
|
11
10
|
logApiUploadErrorInstance,
|
|
12
|
-
} = require('
|
|
11
|
+
} = require('../../lib/errorHandlers/apiErrors');
|
|
12
|
+
const { logErrorInstance } = require('../../lib/errorHandlers/standardErrors');
|
|
13
13
|
const { validateSrcAndDestPaths } = require('@hubspot/cli-lib/modules');
|
|
14
14
|
const { shouldIgnoreFile } = require('@hubspot/cli-lib/ignoreRules');
|
|
15
15
|
|
|
@@ -9,7 +9,7 @@ const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
|
9
9
|
const {
|
|
10
10
|
logApiErrorInstance,
|
|
11
11
|
ApiErrorContext,
|
|
12
|
-
} = require('
|
|
12
|
+
} = require('../../lib/errorHandlers/apiErrors');
|
|
13
13
|
const { POLLING_DELAY } = require('@hubspot/cli-lib/lib/constants');
|
|
14
14
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
15
15
|
const {
|
|
@@ -3,7 +3,7 @@ const { logger } = require('@hubspot/cli-lib/logger');
|
|
|
3
3
|
const {
|
|
4
4
|
logApiErrorInstance,
|
|
5
5
|
ApiErrorContext,
|
|
6
|
-
} = require('
|
|
6
|
+
} = require('../../lib/errorHandlers/apiErrors');
|
|
7
7
|
const { getFunctionArrays } = require('../../lib/getFunctionArrays');
|
|
8
8
|
const {
|
|
9
9
|
getTableContents,
|
package/commands/hubdb/clear.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
2
|
-
const { logErrorInstance } = require('
|
|
2
|
+
const { logErrorInstance } = require('../../lib/errorHandlers/standardErrors');
|
|
3
3
|
const { clearHubDbTableRows } = require('@hubspot/cli-lib/hubdb');
|
|
4
4
|
const { publishTable } = require('@hubspot/cli-lib/api/hubdb');
|
|
5
5
|
|
package/commands/hubdb/create.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
2
|
|
|
3
3
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
4
|
-
const { logErrorInstance } = require('
|
|
4
|
+
const { logErrorInstance } = require('../../lib/errorHandlers/standardErrors');
|
|
5
5
|
const { getCwd } = require('@hubspot/cli-lib/path');
|
|
6
6
|
const { createHubDbTable } = require('@hubspot/cli-lib/hubdb');
|
|
7
7
|
|
package/commands/hubdb/delete.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
2
|
-
const { logErrorInstance } = require('
|
|
2
|
+
const { logErrorInstance } = require('../../lib/errorHandlers/standardErrors');
|
|
3
3
|
const { deleteTable } = require('@hubspot/cli-lib/api/hubdb');
|
|
4
4
|
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
5
5
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
package/commands/hubdb/fetch.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
2
|
-
const { logErrorInstance } = require('
|
|
2
|
+
const { logErrorInstance } = require('../../lib/errorHandlers/standardErrors');
|
|
3
3
|
const { downloadHubDbTable } = require('@hubspot/cli-lib/hubdb');
|
|
4
4
|
|
|
5
5
|
const { loadAndValidateOptions } = require('../../lib/validation');
|
package/commands/init.js
CHANGED
|
@@ -9,7 +9,7 @@ const {
|
|
|
9
9
|
const { addConfigOptions } = require('../lib/commonOpts');
|
|
10
10
|
const { handleExit } = require('../lib/process');
|
|
11
11
|
const { checkAndUpdateGitignore } = require('@hubspot/cli-lib/lib/git');
|
|
12
|
-
const { logErrorInstance } = require('
|
|
12
|
+
const { logErrorInstance } = require('../lib/errorHandlers/standardErrors');
|
|
13
13
|
const {
|
|
14
14
|
DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME,
|
|
15
15
|
PERSONAL_ACCESS_KEY_AUTH_METHOD,
|
package/commands/lint.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const { lint } = require('@hubspot/cli-lib/validate');
|
|
2
2
|
const { printHublValidationResult } = require('../lib/hublValidate');
|
|
3
3
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
4
|
-
const { logErrorInstance } = require('
|
|
4
|
+
const { logErrorInstance } = require('../lib/errorHandlers/standardErrors');
|
|
5
5
|
|
|
6
6
|
const {
|
|
7
7
|
addConfigOptions,
|
package/commands/list.js
CHANGED
|
@@ -12,7 +12,7 @@ const { logger } = require('@hubspot/cli-lib/logger');
|
|
|
12
12
|
const {
|
|
13
13
|
logApiErrorInstance,
|
|
14
14
|
ApiErrorContext,
|
|
15
|
-
} = require('
|
|
15
|
+
} = require('../lib/errorHandlers/apiErrors');
|
|
16
16
|
const {
|
|
17
17
|
getDirectoryContentsByPath,
|
|
18
18
|
} = require('@hubspot/cli-lib/api/fileMapper');
|
package/commands/mv.js
CHANGED
package/commands/project/add.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
2
2
|
const { getAccountId } = require('@hubspot/cli-lib/lib/config');
|
|
3
|
-
const { logErrorInstance } = require('
|
|
3
|
+
const { logErrorInstance } = require('../../lib/errorHandlers/standardErrors');
|
|
4
4
|
const { fetchReleaseData } = require('@hubspot/cli-lib/github');
|
|
5
5
|
|
|
6
6
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
@@ -9,7 +9,7 @@ const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
|
9
9
|
const {
|
|
10
10
|
logApiErrorInstance,
|
|
11
11
|
ApiErrorContext,
|
|
12
|
-
} = require('
|
|
12
|
+
} = require('../../lib/errorHandlers/apiErrors');
|
|
13
13
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
14
14
|
const { deployProject, fetchProject } = require('@hubspot/cli-lib/api/dfs');
|
|
15
15
|
const { loadAndValidateOptions } = require('../../lib/validation');
|
package/commands/project/dev.js
CHANGED
|
@@ -50,18 +50,17 @@ const {
|
|
|
50
50
|
PROJECT_DEPLOY_TEXT,
|
|
51
51
|
ERROR_TYPES,
|
|
52
52
|
} = require('@hubspot/cli-lib/lib/constants');
|
|
53
|
-
|
|
54
|
-
logErrorInstance,
|
|
55
|
-
logApiErrorInstance,
|
|
56
|
-
ApiErrorContext,
|
|
57
|
-
} = require('@hubspot/cli-lib/errorHandlers');
|
|
53
|
+
|
|
58
54
|
const { buildSandbox } = require('../../lib/sandbox-create');
|
|
59
55
|
const { syncSandbox } = require('../../lib/sandbox-sync');
|
|
60
56
|
const { getHubSpotWebsiteOrigin } = require('@hubspot/cli-lib/lib/urls');
|
|
61
57
|
const {
|
|
58
|
+
logApiErrorInstance,
|
|
59
|
+
ApiErrorContext,
|
|
62
60
|
isMissingScopeError,
|
|
63
61
|
isSpecifiedError,
|
|
64
|
-
} = require('
|
|
62
|
+
} = require('../../lib/errorHandlers/apiErrors');
|
|
63
|
+
const { logErrorInstance } = require('../../lib/errorHandlers/standardErrors');
|
|
65
64
|
|
|
66
65
|
const i18nKey = 'cli.commands.project.subcommands.dev';
|
|
67
66
|
|
|
@@ -10,7 +10,7 @@ const { getCwd } = require('@hubspot/cli-lib/path');
|
|
|
10
10
|
const {
|
|
11
11
|
logApiErrorInstance,
|
|
12
12
|
ApiErrorContext,
|
|
13
|
-
} = require('
|
|
13
|
+
} = require('../../lib/errorHandlers/apiErrors');
|
|
14
14
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
15
15
|
const { extractZipArchive } = require('@hubspot/cli-lib/archive');
|
|
16
16
|
const {
|
|
@@ -11,7 +11,7 @@ const { i18n } = require('../../lib/lang');
|
|
|
11
11
|
const {
|
|
12
12
|
logApiErrorInstance,
|
|
13
13
|
ApiErrorContext,
|
|
14
|
-
} = require('
|
|
14
|
+
} = require('../../lib/errorHandlers/apiErrors');
|
|
15
15
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
16
16
|
const {
|
|
17
17
|
fetchProject,
|
package/commands/project/logs.js
CHANGED
|
@@ -21,13 +21,11 @@ const {
|
|
|
21
21
|
const { i18n } = require('../../lib/lang');
|
|
22
22
|
const { getAccountConfig } = require('@hubspot/cli-lib');
|
|
23
23
|
const { ERROR_TYPES } = require('@hubspot/cli-lib/lib/constants');
|
|
24
|
-
const {
|
|
25
|
-
isSpecifiedError,
|
|
26
|
-
} = require('@hubspot/cli-lib/errorHandlers/apiErrors');
|
|
27
24
|
const {
|
|
28
25
|
logApiErrorInstance,
|
|
29
26
|
ApiErrorContext,
|
|
30
|
-
|
|
27
|
+
isSpecifiedError,
|
|
28
|
+
} = require('../../lib/errorHandlers/apiErrors');
|
|
31
29
|
const { EXIT_CODES } = require('../../lib/enums/exitCodes');
|
|
32
30
|
|
|
33
31
|
const i18nKey = 'cli.commands.project.subcommands.upload';
|
|
@@ -3,7 +3,7 @@ const { createWatcher } = require('../../lib/projectsWatch');
|
|
|
3
3
|
const {
|
|
4
4
|
logApiErrorInstance,
|
|
5
5
|
ApiErrorContext,
|
|
6
|
-
} = require('
|
|
6
|
+
} = require('../../lib/errorHandlers/apiErrors');
|
|
7
7
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
8
8
|
const { ERROR_TYPES } = require('@hubspot/cli-lib/lib/constants');
|
|
9
9
|
const {
|
package/commands/remove.js
CHANGED
|
@@ -32,10 +32,8 @@ const {
|
|
|
32
32
|
} = require('../../lib/prompts/sandboxesPrompt');
|
|
33
33
|
const { promptUser } = require('../../lib/prompts/promptUtils');
|
|
34
34
|
const { syncSandbox } = require('../../lib/sandbox-sync');
|
|
35
|
-
const { logErrorInstance } = require('
|
|
36
|
-
const {
|
|
37
|
-
isMissingScopeError,
|
|
38
|
-
} = require('@hubspot/cli-lib/errorHandlers/apiErrors');
|
|
35
|
+
const { logErrorInstance } = require('../../lib/errorHandlers/standardErrors');
|
|
36
|
+
const { isMissingScopeError } = require('../../lib/errorHandlers/apiErrors');
|
|
39
37
|
const { getHubSpotWebsiteOrigin } = require('@hubspot/cli-lib/lib/urls');
|
|
40
38
|
|
|
41
39
|
const i18nKey = 'cli.commands.sandbox.subcommands.create';
|
|
@@ -9,9 +9,13 @@ const { logger } = require('@hubspot/cli-lib/logger');
|
|
|
9
9
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
10
10
|
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
11
11
|
const {
|
|
12
|
+
logErrorInstance,
|
|
12
13
|
debugErrorAndContext,
|
|
13
|
-
} = require('
|
|
14
|
-
const {
|
|
14
|
+
} = require('../../lib/errorHandlers/standardErrors');
|
|
15
|
+
const {
|
|
16
|
+
isSpecifiedError,
|
|
17
|
+
isSpecifiedHubSpotAuthError,
|
|
18
|
+
} = require('../../lib/errorHandlers/apiErrors');
|
|
15
19
|
const { deleteSandbox } = require('@hubspot/cli-lib/sandboxes');
|
|
16
20
|
const { i18n } = require('../../lib/lang');
|
|
17
21
|
const { getConfig, getEnv, getAccountConfig } = require('@hubspot/cli-lib');
|
|
@@ -26,10 +30,7 @@ const {
|
|
|
26
30
|
const { EXIT_CODES } = require('../../lib/enums/exitCodes');
|
|
27
31
|
const { promptUser } = require('../../lib/prompts/promptUtils');
|
|
28
32
|
const { getHubSpotWebsiteOrigin } = require('@hubspot/cli-lib/lib/urls');
|
|
29
|
-
|
|
30
|
-
isSpecifiedError,
|
|
31
|
-
isSpecifiedHubSpotAuthError,
|
|
32
|
-
} = require('@hubspot/cli-lib/errorHandlers/apiErrors');
|
|
33
|
+
|
|
33
34
|
const { getAccountName } = require('../../lib/sandboxes');
|
|
34
35
|
const { getValidEnv } = require('@hubspot/cli-lib/lib/environment');
|
|
35
36
|
|
package/commands/sandbox/sync.js
CHANGED
|
@@ -24,12 +24,8 @@ const {
|
|
|
24
24
|
} = require('../../lib/sandboxes');
|
|
25
25
|
const { syncSandbox } = require('../../lib/sandbox-sync');
|
|
26
26
|
const { getValidEnv } = require('@hubspot/cli-lib/lib/environment');
|
|
27
|
-
const {
|
|
28
|
-
|
|
29
|
-
} = require('@hubspot/cli-lib/errorHandlers/apiErrors');
|
|
30
|
-
const {
|
|
31
|
-
logErrorInstance,
|
|
32
|
-
} = require('@hubspot/cli-lib/errorHandlers/standardErrors');
|
|
27
|
+
const { isSpecifiedError } = require('../../lib/errorHandlers/apiErrors');
|
|
28
|
+
const { logErrorInstance } = require('../../lib/errorHandlers/standardErrors');
|
|
33
29
|
|
|
34
30
|
const i18nKey = 'cli.commands.sandbox.subcommands.sync';
|
|
35
31
|
|
|
@@ -2,7 +2,7 @@ const { logger } = require('@hubspot/cli-lib/logger');
|
|
|
2
2
|
const {
|
|
3
3
|
logServerlessFunctionApiErrorInstance,
|
|
4
4
|
ApiErrorContext,
|
|
5
|
-
} = require('
|
|
5
|
+
} = require('../../lib/errorHandlers/apiErrors');
|
|
6
6
|
const { addSecret } = require('@hubspot/cli-lib/api/secrets');
|
|
7
7
|
|
|
8
8
|
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
@@ -2,7 +2,7 @@ const { logger } = require('@hubspot/cli-lib/logger');
|
|
|
2
2
|
const {
|
|
3
3
|
logServerlessFunctionApiErrorInstance,
|
|
4
4
|
ApiErrorContext,
|
|
5
|
-
} = require('
|
|
5
|
+
} = require('../../lib/errorHandlers/apiErrors');
|
|
6
6
|
const { deleteSecret } = require('@hubspot/cli-lib/api/secrets');
|
|
7
7
|
|
|
8
8
|
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
@@ -2,7 +2,7 @@ const { logger } = require('@hubspot/cli-lib/logger');
|
|
|
2
2
|
const {
|
|
3
3
|
logServerlessFunctionApiErrorInstance,
|
|
4
4
|
ApiErrorContext,
|
|
5
|
-
} = require('
|
|
5
|
+
} = require('../../lib/errorHandlers/apiErrors');
|
|
6
6
|
const { fetchSecrets } = require('@hubspot/cli-lib/api/secrets');
|
|
7
7
|
|
|
8
8
|
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
@@ -2,7 +2,7 @@ const { logger } = require('@hubspot/cli-lib/logger');
|
|
|
2
2
|
const {
|
|
3
3
|
logServerlessFunctionApiErrorInstance,
|
|
4
4
|
ApiErrorContext,
|
|
5
|
-
} = require('
|
|
5
|
+
} = require('../../lib/errorHandlers/apiErrors');
|
|
6
6
|
const { updateSecret } = require('@hubspot/cli-lib/api/secrets');
|
|
7
7
|
|
|
8
8
|
const { loadAndValidateOptions } = require('../../lib/validation');
|
package/commands/upload.js
CHANGED
|
@@ -10,10 +10,10 @@ const {
|
|
|
10
10
|
} = require('@hubspot/cli-lib/path');
|
|
11
11
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
12
12
|
const {
|
|
13
|
-
logErrorInstance,
|
|
14
13
|
ApiErrorContext,
|
|
15
14
|
logApiUploadErrorInstance,
|
|
16
|
-
} = require('
|
|
15
|
+
} = require('../lib/errorHandlers/apiErrors');
|
|
16
|
+
const { logErrorInstance } = require('../lib/errorHandlers/standardErrors');
|
|
17
17
|
const { validateSrcAndDestPaths } = require('@hubspot/cli-lib/modules');
|
|
18
18
|
const { shouldIgnoreFile } = require('@hubspot/cli-lib/ignoreRules');
|
|
19
19
|
|
package/lang/en.lyaml
CHANGED
|
@@ -994,6 +994,10 @@ en:
|
|
|
994
994
|
sandboxSyncStandardCommand:
|
|
995
995
|
command: "hs sandbox sync"
|
|
996
996
|
message: "Run {{ command }} to to update all supported assets to your sandbox from production"
|
|
997
|
+
sampleProjects:
|
|
998
|
+
linkText: "HubSpot's sample projects"
|
|
999
|
+
url: "https://developers.hubspot.com/docs/platform/sample-projects?utm_source=cli&utm_content=project_create_whats_next"
|
|
1000
|
+
message: "See {{ link }}"
|
|
997
1001
|
commonOpts:
|
|
998
1002
|
options:
|
|
999
1003
|
portal:
|
|
@@ -1259,6 +1263,37 @@ en:
|
|
|
1259
1263
|
label: "Lead Flows"
|
|
1260
1264
|
marketing-email:
|
|
1261
1265
|
label: "Marketing emails"
|
|
1266
|
+
errorHandlers:
|
|
1267
|
+
standardErrors:
|
|
1268
|
+
errorOccurred: "Error: {{ error }}"
|
|
1269
|
+
errorContext: "Context: {{ context }}"
|
|
1270
|
+
systemErrorOccurred: "A system error has occurred: {{ errorMessage }}"
|
|
1271
|
+
genericErrorOccurred: "A {{ name }} has occurred."
|
|
1272
|
+
unknownErrorOccurred: "An unknown error has occurred"
|
|
1273
|
+
fileSystemErrors:
|
|
1274
|
+
errorOccurred: "An error occurred while {{ fileAction }} {{ filepath }}."
|
|
1275
|
+
errorExplanation: "This is the result of a system error: {{ errorMessage }}"
|
|
1276
|
+
apiErrors:
|
|
1277
|
+
messageDetail: "{{ request }} in account {{ accountId }}"
|
|
1278
|
+
unableToUpload: 'Unable to upload "{{ payload }}.'
|
|
1279
|
+
codes:
|
|
1280
|
+
400: "The {{ messageDetail }} was bad."
|
|
1281
|
+
401: "The {{ messageDetail }} was unauthorized."
|
|
1282
|
+
403MissingScope: "Couldn't run the project command because there are scopes missing in your production account. To update scopes, deactivate your current personal access key for {{ accountId }}, and generate a new one. Then run `hs auth` to update the CLI with the new key."
|
|
1283
|
+
403Gating: "The current target account {{ accountId }} does not have access to HubSpot projects. To opt in to the CRM Development Beta and use projects, visit https://app.hubspot.com/l/whats-new/betas?productUpdateId=13860216."
|
|
1284
|
+
403: "The {{ messageDetail }} was forbidden."
|
|
1285
|
+
404Request: 'The {{ action }} failed because "{{ request }}" was not found in account {{ accountId }}.'
|
|
1286
|
+
404: "The {{ messageDetail }} was not found."
|
|
1287
|
+
429: "The {{ messageDetail }} surpassed the rate limit. Retry in one minute."
|
|
1288
|
+
503: "The {{ messageDetail }} could not be handled at this time. Please try again or visit https://help.hubspot.com/ to submit a ticket or contact HubSpot Support if the issue persists."
|
|
1289
|
+
500generic: "The {{ messageDetail }} failed due to a server error. Please try again or visit https://help.hubspot.com/ to submit a ticket or contact HubSpot Support if the issue persists."
|
|
1290
|
+
400generic: "The {{ messageDetail }} failed due to a client error."
|
|
1291
|
+
generic: "The {{ messageDetail }} failed."
|
|
1292
|
+
verifyAccessKeyAndUserAccess:
|
|
1293
|
+
fetchScopeDataError: "Error verifying access of scopeGroup {{ scopeGroup }}: {{ error }}"
|
|
1294
|
+
portalMissingScope: "Your account does not have access to this action. Talk to an account admin to request it."
|
|
1295
|
+
userMissingScope: "You don't have access to this action. Ask an account admin to change your permissions in Users & Teams settings."
|
|
1296
|
+
genericMissingScope: "Your access key does not allow this action. Please generate a new access key by running `hs auth personalaccesskey`."
|
|
1262
1297
|
|
|
1263
1298
|
|
|
1264
1299
|
|
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
const { logger } = require('@hubspot/cli-lib/logger');
|
|
2
|
+
const { getAccountConfig } = require('@hubspot/cli-lib/lib/config');
|
|
3
|
+
const {
|
|
4
|
+
SCOPE_GROUPS,
|
|
5
|
+
PERSONAL_ACCESS_KEY_AUTH_METHOD,
|
|
6
|
+
} = require('@hubspot/cli-lib/lib/constants');
|
|
7
|
+
const {
|
|
8
|
+
fetchScopeData,
|
|
9
|
+
} = require('@hubspot/cli-lib/api/localDevAuth/authenticated');
|
|
10
|
+
const {
|
|
11
|
+
debugErrorAndContext,
|
|
12
|
+
logErrorInstance,
|
|
13
|
+
ErrorContext,
|
|
14
|
+
} = require('./standardErrors');
|
|
15
|
+
const { i18n } = require('../lang');
|
|
16
|
+
|
|
17
|
+
const i18nKey = 'cli.lib.errorHandlers.apiErrors';
|
|
18
|
+
|
|
19
|
+
const isApiStatusCodeError = err =>
|
|
20
|
+
err.name === 'StatusCodeError' ||
|
|
21
|
+
(err.statusCode >= 100 && err.statusCode < 600);
|
|
22
|
+
|
|
23
|
+
const isApiUploadValidationError = err =>
|
|
24
|
+
!!(
|
|
25
|
+
err.statusCode === 400 &&
|
|
26
|
+
err.response &&
|
|
27
|
+
err.response.body &&
|
|
28
|
+
(err.response.body.message || err.response.body.errors)
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
const isMissingScopeError = err =>
|
|
32
|
+
err.name === 'StatusCodeError' &&
|
|
33
|
+
err.statusCode === 403 &&
|
|
34
|
+
err.error &&
|
|
35
|
+
err.error.category === 'MISSING_SCOPES';
|
|
36
|
+
|
|
37
|
+
const isGatingError = err =>
|
|
38
|
+
isSpecifiedError(err, { statusCode: 403, category: 'GATED' });
|
|
39
|
+
|
|
40
|
+
const isSpecifiedError = (err, { statusCode, category, subCategory } = {}) => {
|
|
41
|
+
const statusCodeErr = !statusCode || err.statusCode === statusCode;
|
|
42
|
+
const categoryErr =
|
|
43
|
+
!category || (err.error && err.error.category === category);
|
|
44
|
+
const subCategoryErr =
|
|
45
|
+
!subCategory || (err.error && err.error.subCategory === subCategory);
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
err.name === 'StatusCodeError' &&
|
|
49
|
+
statusCodeErr &&
|
|
50
|
+
categoryErr &&
|
|
51
|
+
subCategoryErr
|
|
52
|
+
);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const isSpecifiedHubSpotAuthError = (
|
|
56
|
+
err,
|
|
57
|
+
{ statusCode, category, subCategory }
|
|
58
|
+
) => {
|
|
59
|
+
const statusCodeErr = !statusCode || err.statusCode === statusCode;
|
|
60
|
+
const categoryErr = !category || err.category === category;
|
|
61
|
+
const subCategoryErr = !subCategory || err.subCategory === subCategory;
|
|
62
|
+
return (
|
|
63
|
+
err.name === 'HubSpotAuthError' &&
|
|
64
|
+
statusCodeErr &&
|
|
65
|
+
categoryErr &&
|
|
66
|
+
subCategoryErr
|
|
67
|
+
);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const parseValidationErrors = (responseBody = {}) => {
|
|
71
|
+
const errorMessages = [];
|
|
72
|
+
|
|
73
|
+
const { errors, message } = responseBody;
|
|
74
|
+
|
|
75
|
+
if (message) {
|
|
76
|
+
errorMessages.push(message);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (errors) {
|
|
80
|
+
const specificErrors = errors.map(error => {
|
|
81
|
+
let errorMessage = error.message;
|
|
82
|
+
if (error.errorTokens && error.errorTokens.line) {
|
|
83
|
+
errorMessage = `line ${error.errorTokens.line}: ${errorMessage}`;
|
|
84
|
+
}
|
|
85
|
+
return errorMessage;
|
|
86
|
+
});
|
|
87
|
+
errorMessages.push(...specificErrors);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return errorMessages;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
class ApiErrorContext extends ErrorContext {
|
|
94
|
+
constructor(props = {}) {
|
|
95
|
+
super(props);
|
|
96
|
+
/** @type {string} */
|
|
97
|
+
this.request = props.request || '';
|
|
98
|
+
/** @type {string} */
|
|
99
|
+
this.payload = props.payload || '';
|
|
100
|
+
/** @type {string} */
|
|
101
|
+
this.projectName = props.projectName || '';
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* @param {Error} error
|
|
107
|
+
* @param {ApiErrorContext} context
|
|
108
|
+
*/
|
|
109
|
+
function logValidationErrors(error, context) {
|
|
110
|
+
const { response = {} } = error;
|
|
111
|
+
const validationErrors = parseValidationErrors(response.body);
|
|
112
|
+
if (validationErrors.length) {
|
|
113
|
+
validationErrors.forEach(err => {
|
|
114
|
+
logger.error(err);
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
debugErrorAndContext(error, context);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Message segments for API messages.
|
|
122
|
+
*
|
|
123
|
+
* @enum {string}
|
|
124
|
+
*/
|
|
125
|
+
const ApiMethodVerbs = {
|
|
126
|
+
DEFAULT: 'request',
|
|
127
|
+
DELETE: 'delete',
|
|
128
|
+
GET: 'request',
|
|
129
|
+
PATCH: 'update',
|
|
130
|
+
POST: 'post',
|
|
131
|
+
PUT: 'update',
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Message segments for API messages.
|
|
136
|
+
*
|
|
137
|
+
* @enum {string}
|
|
138
|
+
*/
|
|
139
|
+
const ApiMethodPrepositions = {
|
|
140
|
+
DEFAULT: 'for',
|
|
141
|
+
DELETE: 'of',
|
|
142
|
+
GET: 'for',
|
|
143
|
+
PATCH: 'to',
|
|
144
|
+
POST: 'to',
|
|
145
|
+
PUT: 'to',
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Logs messages for an error instance resulting from API interaction.
|
|
150
|
+
*
|
|
151
|
+
* @param {StatusCodeError} error
|
|
152
|
+
* @param {ApiErrorContext} context
|
|
153
|
+
*/
|
|
154
|
+
function logApiStatusCodeError(error, context) {
|
|
155
|
+
const { statusCode } = error;
|
|
156
|
+
const { method } = error.options || {};
|
|
157
|
+
const { projectName } = context;
|
|
158
|
+
const isPutOrPost = method === 'PUT' || method === 'POST';
|
|
159
|
+
const action = ApiMethodVerbs[method] || ApiMethodVerbs.DEFAULT;
|
|
160
|
+
const preposition =
|
|
161
|
+
ApiMethodPrepositions[method] || ApiMethodPrepositions.DEFAULT;
|
|
162
|
+
let messageDetail = '';
|
|
163
|
+
{
|
|
164
|
+
const request = context.request
|
|
165
|
+
? `${action} ${preposition} "${context.request}"`
|
|
166
|
+
: action;
|
|
167
|
+
messageDetail = `${request} in account ${context.accountId}`;
|
|
168
|
+
}
|
|
169
|
+
const errorMessage = [];
|
|
170
|
+
if (isPutOrPost && context.payload) {
|
|
171
|
+
errorMessage.push(`Unable to upload "${context.payload}".`);
|
|
172
|
+
}
|
|
173
|
+
const isProjectMissingScopeError = isMissingScopeError(error) && projectName;
|
|
174
|
+
const isProjectGatingError = isGatingError(error) && projectName;
|
|
175
|
+
switch (statusCode) {
|
|
176
|
+
case 400:
|
|
177
|
+
errorMessage.push(i18n(`${i18nKey}.codes.400`, { messageDetail }));
|
|
178
|
+
break;
|
|
179
|
+
case 401:
|
|
180
|
+
errorMessage.push(i18n(`${i18nKey}.codes.401`, { messageDetail }));
|
|
181
|
+
break;
|
|
182
|
+
case 403:
|
|
183
|
+
if (isProjectMissingScopeError) {
|
|
184
|
+
errorMessage.push(
|
|
185
|
+
i18n(`${i18nKey}.codes.403MissingScope`, {
|
|
186
|
+
accountId: context.accountId || '',
|
|
187
|
+
})
|
|
188
|
+
);
|
|
189
|
+
} else if (isProjectGatingError) {
|
|
190
|
+
errorMessage.push(
|
|
191
|
+
i18n(`${i18nKey}.codes.403Gating`, {
|
|
192
|
+
accountId: context.accountId || '',
|
|
193
|
+
})
|
|
194
|
+
);
|
|
195
|
+
} else {
|
|
196
|
+
errorMessage.push(i18n(`${i18nKey}.codes.403`, { messageDetail }));
|
|
197
|
+
}
|
|
198
|
+
break;
|
|
199
|
+
case 404:
|
|
200
|
+
if (context.request) {
|
|
201
|
+
errorMessage.push(
|
|
202
|
+
i18n(`${i18nKey}.codes.404Request`, {
|
|
203
|
+
action: action || 'request',
|
|
204
|
+
request: context.request,
|
|
205
|
+
account: context.accountId || '',
|
|
206
|
+
})
|
|
207
|
+
);
|
|
208
|
+
} else {
|
|
209
|
+
errorMessage.push(i18n(`${i18nKey}.codes.404`, { messageDetail }));
|
|
210
|
+
}
|
|
211
|
+
break;
|
|
212
|
+
case 429:
|
|
213
|
+
errorMessage.push(i18n(`${i18nKey}.codes.429`, { messageDetail }));
|
|
214
|
+
break;
|
|
215
|
+
case 503:
|
|
216
|
+
errorMessage.push(i18n(`${i18nKey}.codes.503`, { messageDetail }));
|
|
217
|
+
break;
|
|
218
|
+
default:
|
|
219
|
+
if (statusCode >= 500 && statusCode < 600) {
|
|
220
|
+
errorMessage.push(
|
|
221
|
+
i18n(`${i18nKey}.codes.500Generic`, { messageDetail })
|
|
222
|
+
);
|
|
223
|
+
} else if (statusCode >= 400 && statusCode < 500) {
|
|
224
|
+
i18n(`${i18nKey}.codes.400Generic`, { messageDetail });
|
|
225
|
+
} else {
|
|
226
|
+
errorMessage.push(i18n(`${i18nKey}.codes.generic`, { messageDetail }));
|
|
227
|
+
}
|
|
228
|
+
break;
|
|
229
|
+
}
|
|
230
|
+
if (
|
|
231
|
+
error.error &&
|
|
232
|
+
error.error.message &&
|
|
233
|
+
!isProjectMissingScopeError &&
|
|
234
|
+
!isProjectGatingError
|
|
235
|
+
) {
|
|
236
|
+
errorMessage.push(error.error.message);
|
|
237
|
+
}
|
|
238
|
+
if (error.error && error.error.errors) {
|
|
239
|
+
error.error.errors.forEach(err => {
|
|
240
|
+
errorMessage.push('\n- ' + err.message);
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
logger.error(errorMessage.join(' '));
|
|
244
|
+
debugErrorAndContext(error, context);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Logs a message for an error instance resulting from API interaction.
|
|
249
|
+
*
|
|
250
|
+
* @param {Error|SystemError|Object} error
|
|
251
|
+
* @param {ApiErrorContext} context
|
|
252
|
+
*/
|
|
253
|
+
function logApiErrorInstance(error, context) {
|
|
254
|
+
// StatusCodeError
|
|
255
|
+
if (isApiStatusCodeError(error)) {
|
|
256
|
+
logApiStatusCodeError(error, context);
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
logErrorInstance(error, context);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Logs a message for an error instance resulting from filemapper API upload.
|
|
264
|
+
*
|
|
265
|
+
* @param {Error|SystemError|Object} error
|
|
266
|
+
* @param {ApiErrorContext} context
|
|
267
|
+
*/
|
|
268
|
+
function logApiUploadErrorInstance(error, context) {
|
|
269
|
+
if (isApiUploadValidationError(error)) {
|
|
270
|
+
logValidationErrors(error, context);
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
logApiErrorInstance(error, context);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
async function verifyAccessKeyAndUserAccess(accountId, scopeGroup) {
|
|
277
|
+
const accountConfig = getAccountConfig(accountId);
|
|
278
|
+
const { authType } = accountConfig;
|
|
279
|
+
if (authType !== PERSONAL_ACCESS_KEY_AUTH_METHOD.value) {
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
let scopesData;
|
|
284
|
+
try {
|
|
285
|
+
scopesData = await fetchScopeData(accountId, scopeGroup);
|
|
286
|
+
} catch (e) {
|
|
287
|
+
logger.debug(
|
|
288
|
+
i18n(`${i18nKey}.verifyAccessKeyAndUserAccess.fetchScopeDataError`, {
|
|
289
|
+
scopeGroup,
|
|
290
|
+
error: e,
|
|
291
|
+
})
|
|
292
|
+
);
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
const { portalScopesInGroup, userScopesInGroup } = scopesData;
|
|
296
|
+
|
|
297
|
+
if (!portalScopesInGroup.length) {
|
|
298
|
+
logger.error(
|
|
299
|
+
i18n(`${i18nKey}.verifyAccessKeyAndUserAccess.portalMissingScope`)
|
|
300
|
+
);
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
if (!portalScopesInGroup.every(s => userScopesInGroup.includes(s))) {
|
|
305
|
+
logger.error(
|
|
306
|
+
i18n(`${i18nKey}.verifyAccessKeyAndUserAccess.userMissingScope`)
|
|
307
|
+
);
|
|
308
|
+
return;
|
|
309
|
+
} else {
|
|
310
|
+
logger.error(
|
|
311
|
+
i18n(`${i18nKey}.verifyAccessKeyAndUserAccess.genericMissingScope`)
|
|
312
|
+
);
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Logs a message for an error instance resulting from API interaction
|
|
319
|
+
* related to serverless function.
|
|
320
|
+
*
|
|
321
|
+
* @param {int} accountId
|
|
322
|
+
* @param {Error|SystemError|Object} error
|
|
323
|
+
* @param {ApiErrorContext} context
|
|
324
|
+
*/
|
|
325
|
+
async function logServerlessFunctionApiErrorInstance(
|
|
326
|
+
accountId,
|
|
327
|
+
error,
|
|
328
|
+
context
|
|
329
|
+
) {
|
|
330
|
+
if (isMissingScopeError(error)) {
|
|
331
|
+
await verifyAccessKeyAndUserAccess(accountId, SCOPE_GROUPS.functions);
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
// StatusCodeError
|
|
336
|
+
if (isApiStatusCodeError(error)) {
|
|
337
|
+
logApiStatusCodeError(error, context);
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
logErrorInstance(error, context);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
module.exports = {
|
|
344
|
+
ApiErrorContext,
|
|
345
|
+
parseValidationErrors,
|
|
346
|
+
logApiErrorInstance,
|
|
347
|
+
logApiUploadErrorInstance,
|
|
348
|
+
logServerlessFunctionApiErrorInstance,
|
|
349
|
+
isMissingScopeError,
|
|
350
|
+
isSpecifiedError,
|
|
351
|
+
isSpecifiedHubSpotAuthError,
|
|
352
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
const { logger } = require('@hubspot/cli-lib/logger');
|
|
2
|
+
const {
|
|
3
|
+
ErrorContext,
|
|
4
|
+
isSystemError,
|
|
5
|
+
debugErrorAndContext,
|
|
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
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Logs a message for an error instance resulting from filesystem interaction.
|
|
25
|
+
*
|
|
26
|
+
* @param {Error|SystemError|Object} error
|
|
27
|
+
* @param {FileSystemErrorContext} context
|
|
28
|
+
*/
|
|
29
|
+
function logFileSystemErrorInstance(error, context) {
|
|
30
|
+
let fileAction = '';
|
|
31
|
+
if (context.read) {
|
|
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(' '));
|
|
49
|
+
debugErrorAndContext(error, context);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
module.exports = {
|
|
53
|
+
FileSystemErrorContext,
|
|
54
|
+
logFileSystemErrorInstance,
|
|
55
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
const { HubSpotAuthError } = require('@hubspot/cli-lib/lib/models/Errors');
|
|
2
|
+
const { logger } = require('@hubspot/cli-lib/logger');
|
|
3
|
+
const { i18n } = require('../lang');
|
|
4
|
+
|
|
5
|
+
const i18nKey = 'cli.lib.errorHandlers.standardErrors';
|
|
6
|
+
|
|
7
|
+
const isSystemError = err =>
|
|
8
|
+
err.errno != null && err.code != null && err.syscall != null;
|
|
9
|
+
const isFatalError = err => err instanceof HubSpotAuthError;
|
|
10
|
+
|
|
11
|
+
// TODO: Make these TS interfaces
|
|
12
|
+
class ErrorContext {
|
|
13
|
+
constructor(props = {}) {
|
|
14
|
+
/** @type {number} */
|
|
15
|
+
this.accountId = props.accountId;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Logs (debug) the error and context objects.
|
|
21
|
+
*
|
|
22
|
+
* @param {SystemError} error
|
|
23
|
+
* @param {ErrorContext} context
|
|
24
|
+
*/
|
|
25
|
+
function debugErrorAndContext(error, context) {
|
|
26
|
+
if (error.name === 'StatusCodeError') {
|
|
27
|
+
const { statusCode, message, response } = error;
|
|
28
|
+
logger.debug(
|
|
29
|
+
i18n(`${i18nKey}.errorOccurred`, {
|
|
30
|
+
error: {
|
|
31
|
+
statusCode,
|
|
32
|
+
message,
|
|
33
|
+
url: response.request.href,
|
|
34
|
+
method: response.request.method,
|
|
35
|
+
response: response.body,
|
|
36
|
+
headers: response.headers,
|
|
37
|
+
},
|
|
38
|
+
})
|
|
39
|
+
);
|
|
40
|
+
} else {
|
|
41
|
+
logger.debug(i18n(`${i18nKey}.errorOccurred`, { error }));
|
|
42
|
+
}
|
|
43
|
+
logger.debug(i18n(`${i18nKey}.errorContext`, { context }));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Logs a SystemError
|
|
48
|
+
* @see {@link https://nodejs.org/api/errors.html#errors_class_systemerror}
|
|
49
|
+
*
|
|
50
|
+
* @param {SystemError} error
|
|
51
|
+
* @param {ErrorContext} context
|
|
52
|
+
*/
|
|
53
|
+
function logSystemError(error, context) {
|
|
54
|
+
logger.error(
|
|
55
|
+
i18n(`${i18nKey}.systemErrorOccurred`, { error: error.message })
|
|
56
|
+
);
|
|
57
|
+
debugErrorAndContext(error, context);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Logs a message for an error instance of type not asserted.
|
|
62
|
+
*
|
|
63
|
+
* @param {Error|SystemError|Object} error
|
|
64
|
+
* @param {ErrorContext} context
|
|
65
|
+
*/
|
|
66
|
+
function logErrorInstance(error, context) {
|
|
67
|
+
// SystemError
|
|
68
|
+
if (isSystemError(error)) {
|
|
69
|
+
logSystemError(error, context);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if (error instanceof Error || error.message || error.reason) {
|
|
73
|
+
// Error or Error subclass
|
|
74
|
+
const name = error.name || 'Error';
|
|
75
|
+
const message = [i18n(`${i18nKey}.genericErrorOccurred`, { name })];
|
|
76
|
+
[(error.message, error.reason)].forEach(msg => {
|
|
77
|
+
if (msg) {
|
|
78
|
+
message.push(msg);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
logger.error(message.join(' '));
|
|
82
|
+
} else {
|
|
83
|
+
// Unknown errors
|
|
84
|
+
logger.error(i18n(`${i18nKey}.unknownErrorOccurred`));
|
|
85
|
+
}
|
|
86
|
+
debugErrorAndContext(error, context);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
module.exports = {
|
|
90
|
+
debugErrorAndContext,
|
|
91
|
+
ErrorContext,
|
|
92
|
+
isFatalError,
|
|
93
|
+
isSystemError,
|
|
94
|
+
logErrorInstance,
|
|
95
|
+
};
|
package/lib/projects.js
CHANGED
|
@@ -29,10 +29,6 @@ const {
|
|
|
29
29
|
fetchProject,
|
|
30
30
|
uploadProject,
|
|
31
31
|
} = require('@hubspot/cli-lib/api/dfs');
|
|
32
|
-
const {
|
|
33
|
-
logApiErrorInstance,
|
|
34
|
-
ApiErrorContext,
|
|
35
|
-
} = require('@hubspot/cli-lib/errorHandlers');
|
|
36
32
|
const { shouldIgnoreFile } = require('@hubspot/cli-lib/ignoreRules');
|
|
37
33
|
const { getCwd, getAbsoluteFilePath } = require('@hubspot/cli-lib/path');
|
|
38
34
|
const { downloadGitHubRepoContents } = require('@hubspot/cli-lib/github');
|
|
@@ -42,9 +38,11 @@ const { uiLine, uiLink, uiAccountDescription } = require('../lib/ui');
|
|
|
42
38
|
const { i18n } = require('./lang');
|
|
43
39
|
const SpinniesManager = require('./SpinniesManager');
|
|
44
40
|
const {
|
|
41
|
+
logApiErrorInstance,
|
|
42
|
+
ApiErrorContext,
|
|
45
43
|
isSpecifiedError,
|
|
46
44
|
isSpecifiedHubSpotAuthError,
|
|
47
|
-
} = require('
|
|
45
|
+
} = require('./errorHandlers/apiErrors');
|
|
48
46
|
const { HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH } = require('./constants');
|
|
49
47
|
|
|
50
48
|
const i18nKey = 'cli.lib.projects';
|
package/lib/projectsWatch.js
CHANGED
|
@@ -5,7 +5,7 @@ const { default: PQueue } = require('p-queue');
|
|
|
5
5
|
const {
|
|
6
6
|
logApiErrorInstance,
|
|
7
7
|
ApiErrorContext,
|
|
8
|
-
} = require('
|
|
8
|
+
} = require('./errorHandlers/apiErrors');
|
|
9
9
|
const { i18n } = require('@hubspot/cli-lib/lib/lang');
|
|
10
10
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
11
11
|
const { isAllowedExtension } = require('@hubspot/cli-lib/path');
|
|
@@ -4,7 +4,7 @@ const { fetchProjects } = require('@hubspot/cli-lib/api/dfs');
|
|
|
4
4
|
const {
|
|
5
5
|
logApiErrorInstance,
|
|
6
6
|
ApiErrorContext,
|
|
7
|
-
} = require('
|
|
7
|
+
} = require('../../lib/errorHandlers/apiErrors');
|
|
8
8
|
const { EXIT_CODES } = require('../enums/exitCodes');
|
|
9
9
|
const { i18n } = require('../lang');
|
|
10
10
|
|
|
@@ -6,7 +6,7 @@ const { getProjectConfig, ensureProjectExists } = require('../projects');
|
|
|
6
6
|
const {
|
|
7
7
|
logApiErrorInstance,
|
|
8
8
|
ApiErrorContext,
|
|
9
|
-
} = require('
|
|
9
|
+
} = require('../../lib/errorHandlers/apiErrors');
|
|
10
10
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
11
11
|
const { EXIT_CODES } = require('../enums/exitCodes');
|
|
12
12
|
|
package/lib/sandbox-create.js
CHANGED
|
@@ -12,11 +12,11 @@ const { logger } = require('@hubspot/cli-lib/logger');
|
|
|
12
12
|
const {
|
|
13
13
|
debugErrorAndContext,
|
|
14
14
|
logErrorInstance,
|
|
15
|
-
} = require('
|
|
15
|
+
} = require('./errorHandlers/standardErrors');
|
|
16
16
|
const {
|
|
17
17
|
isMissingScopeError,
|
|
18
18
|
isSpecifiedError,
|
|
19
|
-
} = require('
|
|
19
|
+
} = require('./errorHandlers/apiErrors');
|
|
20
20
|
const { getHubSpotWebsiteOrigin } = require('@hubspot/cli-lib/lib/urls');
|
|
21
21
|
const { getEnv, getAccountId } = require('@hubspot/cli-lib');
|
|
22
22
|
const { createSandbox } = require('@hubspot/cli-lib/sandboxes');
|
package/lib/sandbox-sync.js
CHANGED
|
@@ -11,17 +11,17 @@ const {
|
|
|
11
11
|
syncTypes,
|
|
12
12
|
} = require('./sandboxes');
|
|
13
13
|
const { initiateSync } = require('@hubspot/cli-lib/sandboxes');
|
|
14
|
-
const {
|
|
14
|
+
const {
|
|
15
|
+
debugErrorAndContext,
|
|
16
|
+
logErrorInstance,
|
|
17
|
+
} = require('./errorHandlers/standardErrors');
|
|
15
18
|
const {
|
|
16
19
|
isSpecifiedError,
|
|
17
20
|
isMissingScopeError,
|
|
18
|
-
} = require('
|
|
21
|
+
} = require('./errorHandlers/apiErrors');
|
|
19
22
|
const { getSandboxTypeAsString } = require('./sandboxes');
|
|
20
23
|
const { getAccountId } = require('@hubspot/cli-lib');
|
|
21
24
|
const { uiAccountDescription } = require('./ui');
|
|
22
|
-
const {
|
|
23
|
-
debugErrorAndContext,
|
|
24
|
-
} = require('@hubspot/cli-lib/errorHandlers/standardErrors');
|
|
25
25
|
|
|
26
26
|
const i18nKey = 'cli.lib.sandbox.sync';
|
|
27
27
|
|
package/lib/serverlessLogs.js
CHANGED
|
@@ -8,7 +8,7 @@ const {
|
|
|
8
8
|
logServerlessFunctionApiErrorInstance,
|
|
9
9
|
logApiErrorInstance,
|
|
10
10
|
ApiErrorContext,
|
|
11
|
-
} = require('
|
|
11
|
+
} = require('./errorHandlers/apiErrors');
|
|
12
12
|
const { base64EncodeString } = require('@hubspot/cli-lib/lib/encoding');
|
|
13
13
|
|
|
14
14
|
const { EXIT_CODES } = require('../lib/enums/exitCodes');
|
package/lib/ui.js
CHANGED
|
@@ -106,6 +106,7 @@ const uiFeatureHighlight = (commands, title) => {
|
|
|
106
106
|
const commandKey = `${i18nKey}.commandKeys.${c}`;
|
|
107
107
|
const message = i18n(`${commandKey}.message`, {
|
|
108
108
|
command: uiCommandReference(i18n(`${commandKey}.command`)),
|
|
109
|
+
link: uiLink(i18n(`${commandKey}.linkText`), i18n(`${commandKey}.url`)),
|
|
109
110
|
});
|
|
110
111
|
if (i !== 0) {
|
|
111
112
|
logger.log('');
|
package/lib/validation.js
CHANGED
|
@@ -13,7 +13,7 @@ const {
|
|
|
13
13
|
OAUTH_AUTH_METHOD,
|
|
14
14
|
PERSONAL_ACCESS_KEY_AUTH_METHOD,
|
|
15
15
|
} = require('@hubspot/cli-lib/lib/constants');
|
|
16
|
-
const { commaSeparatedValues } = require('@hubspot/
|
|
16
|
+
const { commaSeparatedValues } = require('@hubspot/local-dev-lib/text');
|
|
17
17
|
const { getAbsoluteFilePath } = require('@hubspot/cli-lib/path');
|
|
18
18
|
const { getOauthManager } = require('@hubspot/cli-lib/oauth');
|
|
19
19
|
const {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/cli",
|
|
3
|
-
"version": "5.0.2
|
|
3
|
+
"version": "5.0.2",
|
|
4
4
|
"description": "CLI for working with HubSpot",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@hubspot/cli-lib": "^5.0.1",
|
|
12
|
-
"@hubspot/
|
|
12
|
+
"@hubspot/local-dev-lib": "^0.0.7",
|
|
13
|
+
"@hubspot/serverless-dev-runtime": "5.0.2",
|
|
13
14
|
"@hubspot/ui-extensions-dev-server": "^0.8.0",
|
|
14
15
|
"archiver": "^5.3.0",
|
|
15
16
|
"chalk": "^4.1.2",
|
|
@@ -44,5 +45,5 @@
|
|
|
44
45
|
"publishConfig": {
|
|
45
46
|
"access": "public"
|
|
46
47
|
},
|
|
47
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "44cbdf6dae130e268015d3e9afb612729b539915"
|
|
48
49
|
}
|